@odata2ts/odata2ts 0.35.0 → 0.36.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/lib/app.js +1 -0
  3. package/lib/app.js.map +1 -1
  4. package/lib/data-model/DataModel.js +20 -3
  5. package/lib/data-model/DataModel.js.map +1 -1
  6. package/lib/data-model/DataModelDigestion.d.ts +15 -0
  7. package/lib/data-model/DataModelDigestion.js +73 -22
  8. package/lib/data-model/DataModelDigestion.js.map +1 -1
  9. package/lib/data-model/DataTypeModel.d.ts +3 -0
  10. package/lib/data-model/DataTypeModel.js.map +1 -1
  11. package/lib/data-model/validation/NameClashValidator.js +12 -2
  12. package/lib/data-model/validation/NameClashValidator.js.map +1 -1
  13. package/lib/generator/ImportContainer.d.ts +10 -8
  14. package/lib/generator/ImportContainer.js +93 -72
  15. package/lib/generator/ImportContainer.js.map +1 -1
  16. package/lib/generator/ModelGenerator.js +40 -15
  17. package/lib/generator/ModelGenerator.js.map +1 -1
  18. package/lib/generator/QueryObjectGenerator.js +42 -33
  19. package/lib/generator/QueryObjectGenerator.js.map +1 -1
  20. package/lib/generator/ServiceGenerator.js +35 -22
  21. package/lib/generator/ServiceGenerator.js.map +1 -1
  22. package/lib/generator/import/ImportObjects.d.ts +12 -12
  23. package/lib/generator/import/ImportObjects.js +12 -12
  24. package/lib/generator/import/ImportObjects.js.map +1 -1
  25. package/lib/project/FileHandler.d.ts +4 -14
  26. package/lib/project/FileHandler.js +14 -6
  27. package/lib/project/FileHandler.js.map +1 -1
  28. package/lib/project/ProjectManager.d.ts +1 -0
  29. package/lib/project/ProjectManager.js +8 -5
  30. package/lib/project/ProjectManager.js.map +1 -1
  31. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceGenerator.js","sourceRoot":"","sources":["../../src/generator/ServiceGenerator.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,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,CAAC,CAAC,QAAQ,WAClD,CAAC,MAAM;oBACL,CAAC,CAAC,oBAAoB;wBACpB,aAAa,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,4BAA4B,CAAC,CAAC,CAAC,IAAI,KACpE,kBAAkB,CAAC,IACrB,wBAAwB;oBAC1B,CAAC,CAAC,SAAS,CAAC,OAAO;wBACnB,CAAC,CAAC,sFAAsF;4BACtF,wBAAwB,kBAAkB,CAAC,IAAI,wBAAwB;wBACzE,CAAC,CAAC,sBAAsB;4BACtB,YAAY,kBAAkB,CAAC,IAAI,wBACzC,GAAG;gBACH,UAAU,CAAC,CAAC,CAAC,UAAU,OAAO,6BAA6B,CAAC,CAAC,CAAC,EAAE;aACjE;SACF,CAAC;IACJ,CAAC;IAEO,gBAAgB,CAAC,OAAwB,EAAE,UAAuC;QACxF,MAAM,YAAY,GAAgB,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,YAAY;YACxD,CAAC,CAAC,2BAAW,CAAC,uBAAuB;YACrC,CAAC,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,mDAA4B;gBAClD,CAAC,CAAC,2BAAW,CAAC,kBAAkB;gBAChC,CAAC,CAAC,2BAAW,CAAC,kBAAkB,CAAC;QAEnC,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport deepmerge from \"deepmerge\";\r\nimport {\r\n ClassDeclarationStructure,\r\n MethodDeclarationStructure,\r\n OptionalKind,\r\n PropertyDeclarationStructure,\r\n Scope,\r\n} from \"ts-morph\";\r\nimport { upperCaseFirst } from \"upper-case-first\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport {\r\n ActionImportType,\r\n ComplexType,\r\n DataTypes,\r\n EntityContainerModel,\r\n EntityType,\r\n FunctionImportType,\r\n OperationType,\r\n OperationTypes,\r\n PropertyModel,\r\n ReturnTypeModel,\r\n SingletonType,\r\n} from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { ConfigFileOptions } from \"../OptionModel\";\r\nimport { FileHandler } from \"../project/FileHandler\";\r\nimport { ProjectManager } from \"../project/ProjectManager\";\r\nimport { ClientApiImports, CoreImports, QueryObjectImports, ServiceImports } from \"./import/ImportObjects\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nexport interface PropsAndOps extends Required<Pick<ClassDeclarationStructure, \"properties\" | \"methods\">> {}\r\n\r\nexport interface ServiceGeneratorOptions\r\n extends Pick<ConfigFileOptions, \"enablePrimitivePropertyServices\" | \"v4BigNumberAsString\"> {}\r\n\r\nexport async function generateServices(\r\n project: ProjectManager,\r\n dataModel: DataModel,\r\n version: ODataVersions,\r\n namingHelper: NamingHelper,\r\n options?: ServiceGeneratorOptions\r\n) {\r\n const generator = new ServiceGenerator(project, dataModel, version, namingHelper, options);\r\n return generator.generate();\r\n}\r\n\r\nclass ServiceGenerator {\r\n constructor(\r\n private project: ProjectManager,\r\n private dataModel: DataModel,\r\n private version: ODataVersions,\r\n private namingHelper: NamingHelper,\r\n private options: ServiceGeneratorOptions = {}\r\n ) {}\r\n\r\n private isV4BigNumber() {\r\n return this.options.v4BigNumberAsString && this.version === ODataVersions.V4;\r\n }\r\n\r\n public async generate(): Promise<void> {\r\n const mainServiceName = this.namingHelper.getMainServiceName();\r\n this.project.initServices();\r\n\r\n await Promise.all([\r\n this.generateMainService(mainServiceName),\r\n ...this.generateEntityTypeServices(),\r\n ...this.generateComplexTypeServices(),\r\n ]);\r\n\r\n return this.project.finalizeServices();\r\n }\r\n\r\n private async generateMainService(mainServiceName: string) {\r\n const mainServiceFile = this.project.getMainServiceFile();\r\n const importContainer = mainServiceFile.getImports();\r\n const container = this.dataModel.getEntityContainer();\r\n const unboundOperations = [...Object.values(container.functions), ...Object.values(container.actions)];\r\n\r\n const [httpClient] = importContainer.addClientApi(ClientApiImports.ODataHttpClient);\r\n const [rootService] = importContainer.addServiceObject(this.version, ServiceImports.ODataService);\r\n\r\n const { properties, methods }: PropsAndOps = deepmerge(\r\n this.generateMainServiceProperties(container, importContainer),\r\n this.generateMainServiceOperations(unboundOperations, importContainer)\r\n );\r\n\r\n mainServiceFile.getFile().addClass({\r\n isExported: true,\r\n name: mainServiceName,\r\n typeParameters: [`in out ClientType extends ${httpClient}`],\r\n extends: `${rootService}<ClientType>`,\r\n ctors: this.isV4BigNumber()\r\n ? [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n ],\r\n statements: [`super(client, basePath, true);`],\r\n },\r\n ]\r\n : [],\r\n properties,\r\n methods,\r\n });\r\n }\r\n\r\n private generateMainServiceProperties(\r\n container: EntityContainerModel,\r\n importContainer: ImportContainer\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n Object.values(container.entitySets).forEach(({ name, odataName, entityType }) => {\r\n result.methods.push(this.generateRelatedServiceGetter(name, odataName, entityType, importContainer));\r\n });\r\n\r\n Object.values(container.singletons).forEach((singleton) => {\r\n result.properties.push(this.generateSingletonProp(importContainer, singleton));\r\n result.methods.push(this.generateSingletonGetter(singleton));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateMainServiceOperations(\r\n ops: Array<FunctionImportType | ActionImportType>,\r\n importContainer: ImportContainer\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n ops.forEach(({ operation, name }) => {\r\n const op = this.dataModel.getUnboundOperationType(operation);\r\n if (!op) {\r\n throw new Error(`Operation \"${operation}\" not found!`);\r\n }\r\n\r\n result.properties.push(this.generateQOperationProp(op));\r\n result.methods.push(this.generateMethod(name, op, importContainer, \"\"));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateRelatedServiceGetter(\r\n propName: string,\r\n odataPropName: string,\r\n entityType: EntityType,\r\n imports: ImportContainer\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const idName = imports.addGeneratedModel(entityType.id.fqName, entityType.id.modelName);\r\n const idFunctionName = imports.addGeneratedQObject(entityType.id.fqName, entityType.id.qName);\r\n const serviceName = imports.addGeneratedService(entityType.fqName, entityType.serviceName);\r\n const collectionName = imports.addGeneratedService(entityType.fqName, entityType.serviceCollectionName);\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(propName),\r\n parameters: [\r\n {\r\n name: \"id\",\r\n type: `${idName} | undefined`,\r\n hasQuestionToken: true,\r\n },\r\n ],\r\n overloads: [\r\n {\r\n parameters: [],\r\n returnType: `${collectionName}<ClientType>`,\r\n },\r\n {\r\n parameters: [\r\n {\r\n name: \"id\",\r\n type: idName,\r\n },\r\n ],\r\n returnType: `${serviceName}<ClientType>`,\r\n },\r\n ],\r\n statements: [\r\n `const fieldName = \"${odataPropName}\";`,\r\n `const { client, path } = this.__base;`,\r\n 'return typeof id === \"undefined\" || id === null',\r\n `? new ${collectionName}(client, path, fieldName)`,\r\n `: new ${serviceName}(client, path, new ${idFunctionName}(fieldName).buildUrl(id));`,\r\n ],\r\n };\r\n }\r\n\r\n private generateSingletonProp(\r\n importContainer: ImportContainer,\r\n singleton: SingletonType\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n const { name, entityType } = singleton;\r\n const type = entityType.serviceName;\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(name),\r\n type: `${type}<ClientType>`,\r\n hasQuestionToken: true,\r\n };\r\n }\r\n\r\n private generateQOperationProp = (operation: OperationType) => {\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(operation.qName),\r\n type: operation.qName,\r\n hasQuestionToken: true,\r\n };\r\n };\r\n\r\n private generateSingletonGetter(singleton: SingletonType): OptionalKind<MethodDeclarationStructure> {\r\n const { name, odataName, entityType } = singleton;\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(name);\r\n const serviceType = entityType.serviceName;\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n ` const { client, path } = this.__base;`,\r\n // prettier-ignore\r\n ` ${propName} = new ${serviceType}(client, path, \"${odataName}\")`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private generateEntityTypeService(file: FileHandler, model: ComplexType) {\r\n const importContainer = file.getImports();\r\n\r\n const operations = this.dataModel.getEntityTypeOperations(model.fqName);\r\n const props = [...model.baseProps, ...model.props];\r\n\r\n const [entityServiceType] = importContainer.addServiceObject(this.version, ServiceImports.EntityTypeService);\r\n const [httpClient] = importContainer.addClientApi(ClientApiImports.ODataHttpClient);\r\n\r\n // note: predictable first imports => no need to take renaming into account\r\n const modelName = importContainer.addGeneratedModel(model.fqName, model.modelName);\r\n const editableModelName = importContainer.addGeneratedModel(model.fqName, model.editableName);\r\n const qName = importContainer.addGeneratedQObject(model.fqName, model.qName);\r\n const qObjectName = importContainer.addGeneratedQObject(model.fqName, firstCharLowerCase(model.qName));\r\n\r\n const { properties, methods }: PropsAndOps = deepmerge(\r\n this.generateServiceProperties(importContainer, model.serviceName, props),\r\n this.generateServiceOperations(importContainer, model, operations)\r\n );\r\n\r\n // generate EntityTypeService\r\n file.getFile().addClass({\r\n isExported: true,\r\n name: model.serviceName,\r\n typeParameters: [`in out ClientType extends ${httpClient}`],\r\n extends: entityServiceType + `<ClientType, ${modelName}, ${editableModelName}, ${qName}>`,\r\n ctors: [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n { name: \"name\", type: \"string\" },\r\n ],\r\n statements: [`super(client, basePath, name, ${qObjectName}${this.isV4BigNumber() ? \", true\" : \"\"});`],\r\n },\r\n ],\r\n properties,\r\n methods,\r\n });\r\n }\r\n\r\n private generateServiceProperties(\r\n importContainer: ImportContainer,\r\n serviceName: string,\r\n props: Array<PropertyModel>\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n props.forEach((prop) => {\r\n // complex types, collection of complex types or entityTypes\r\n if ((prop.dataType === DataTypes.ModelType && !prop.isCollection) || prop.dataType === DataTypes.ComplexType) {\r\n result.properties.push(this.generateModelProp(importContainer, prop));\r\n result.methods.push(this.generateModelPropGetter(importContainer, prop));\r\n } else if (prop.isCollection) {\r\n // collection of entity types\r\n if (prop.dataType === DataTypes.ModelType) {\r\n const entityType = this.dataModel.getEntityType(prop.fqType);\r\n if (!entityType) {\r\n throw new Error(`Entity type \"${prop.fqType}\" specified by property not found!`);\r\n }\r\n\r\n result.methods.push(\r\n this.generateRelatedServiceGetter(prop.name, prop.odataName, entityType, importContainer)\r\n );\r\n }\r\n // collection of primitive or enum types\r\n else {\r\n result.properties.push(this.generatePrimitiveCollectionProp(importContainer, prop));\r\n result.methods.push(this.generatePrimitiveCollectionGetter(importContainer, prop));\r\n }\r\n }\r\n // generation of services for each primitive property: turned off by default\r\n else if (this.options.enablePrimitivePropertyServices && prop.dataType === DataTypes.PrimitiveType) {\r\n result.properties.push(this.generatePrimitiveTypeProp(importContainer, prop));\r\n result.methods.push(this.generatePrimitiveTypeGetter(importContainer, prop));\r\n }\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateServiceOperations(\r\n importContainer: ImportContainer,\r\n model: ComplexType,\r\n operations: Array<OperationType>\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n operations.forEach((operation) => {\r\n result.properties.push(this.generateQOperationProp(operation));\r\n result.methods.push(this.generateMethod(operation.name, operation, importContainer, model.fqName));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateModelProp(imports: ImportContainer, prop: PropertyModel): PropertyDeclarationStructure {\r\n const propModel = this.dataModel.getModel(prop.fqType) as ComplexType;\r\n let propModelType: string;\r\n\r\n if (prop.isCollection) {\r\n const modelName = imports.addGeneratedModel(propModel.fqName, propModel.modelName);\r\n const editableModelName = imports.addGeneratedModel(propModel.fqName, propModel.editableName);\r\n const qModelName = imports.addGeneratedQObject(propModel.fqName, propModel.qName);\r\n const [collectionServiceType] = imports.addServiceObject(this.version, ServiceImports.CollectionService);\r\n\r\n propModelType = `${collectionServiceType}<ClientType, ${modelName}, ${qModelName}, ${editableModelName}>`;\r\n } else {\r\n const serviceName = imports.addGeneratedService(propModel.fqName, propModel.serviceName);\r\n propModelType = `${serviceName}<ClientType>`;\r\n }\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: propModelType,\r\n hasQuestionToken: true,\r\n } as PropertyDeclarationStructure;\r\n }\r\n\r\n private generatePrimitiveCollectionProp(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n if (!prop.qObject) {\r\n throw new Error(\"Illegal State: [qObject] must be provided for Collection types!\");\r\n }\r\n\r\n const [collectionServiceType] = imports.addServiceObject(this.version, ServiceImports.CollectionService);\r\n const isEnum = prop.dataType === DataTypes.EnumType;\r\n let qType: string;\r\n let type: string;\r\n\r\n if (!isEnum) {\r\n // TODO move string concat (StringCollection, GuidCollection...) to better place\r\n [type, qType] = imports.addFromQObject(`${upperCaseFirst(prop.type)}Collection`, prop.qObject);\r\n } else {\r\n const propEnum = this.dataModel.getModel(prop.fqType)!;\r\n const propTypeModel = imports.addGeneratedModel(propEnum.fqName, propEnum.modelName);\r\n [type, qType] = imports.addQObject(QueryObjectImports.EnumCollection, QueryObjectImports.QEnumCollection);\r\n type = `${type}<${propTypeModel}>`;\r\n }\r\n\r\n const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: `${collectionType}`,\r\n hasQuestionToken: true,\r\n };\r\n }\r\n\r\n private generatePrimitiveTypeProp(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n const [serviceType] = imports.addServiceObject(this.version, ServiceImports.PrimitiveTypeService);\r\n const type = prop.typeModule ? imports.addCustomType(prop.typeModule, prop.type) : prop.type;\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: `${serviceType}<ClientType, ${type}>`,\r\n hasQuestionToken: true,\r\n };\r\n }\r\n\r\n private generateModelPropGetter(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const model = this.dataModel.getModel(prop.fqType) as ComplexType;\r\n const isComplexCollection = prop.isCollection && model.dataType === DataTypes.ComplexType;\r\n\r\n const type = isComplexCollection\r\n ? imports.addServiceObject(this.version, ServiceImports.CollectionService)[0]\r\n : prop.isCollection\r\n ? model.serviceCollectionName\r\n : model.serviceName;\r\n const typeWithGenerics = isComplexCollection\r\n ? `${type}<ClientType, ${imports.addGeneratedModel(model.fqName, model.modelName)}, ${imports.addGeneratedQObject(\r\n model.fqName,\r\n model.qName\r\n )}, ${imports.addGeneratedModel(model.fqName, model.editableName)}>`\r\n : `${type}<ClientType>`;\r\n\r\n const privateSrvProp = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n returnType: typeWithGenerics,\r\n statements: [\r\n `if(!${privateSrvProp}) {`,\r\n ` const { client, path } = this.__base;`,\r\n // prettier-ignore\r\n ` ${privateSrvProp} = new ${type}(client, path, \"${prop.odataName}\"${isComplexCollection ? `, ${imports.addGeneratedQObject(model.fqName, firstCharLowerCase(model.qName))}`: \"\"})`,\r\n \"}\",\r\n `return ${privateSrvProp}`,\r\n ],\r\n };\r\n }\r\n\r\n private generatePrimitiveCollectionGetter(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const [collectionServiceType] = imports.addServiceObject(this.version, ServiceImports.CollectionService);\r\n const instanceName = firstCharLowerCase(prop.qObject!);\r\n const [qInstanceName] = imports.addFromQObject(instanceName);\r\n\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n ` const { client, path } = this.__base;`,\r\n // prettier-ignore\r\n ` ${propName} = new ${collectionServiceType}(client, path, \"${prop.odataName}\", ${qInstanceName}${this.isV4BigNumber() ? \", true\": \"\"})`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private generatePrimitiveTypeGetter(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const [serviceType] = imports.addServiceObject(this.version, ServiceImports.PrimitiveTypeService);\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n // for V2: mapped name must be specified\r\n const useMappedName = this.version === ODataVersions.V2 && prop.name !== prop.odataName;\r\n // for V4: big number support\r\n const useBigNumber = this.isV4BigNumber();\r\n const addParamString = useMappedName ? `, \"${prop.name}\"` : useBigNumber ? \", true\" : \"\";\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n ` const { client, path, qModel } = this.__base;`,\r\n ` ${propName} = new ${serviceType}(client, path, \"${prop.odataName}\", qModel.${prop.name}.converter${addParamString})`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private generateEntityCollectionService(file: FileHandler, model: EntityType) {\r\n const importContainer = file.getImports();\r\n const editableModelName = model.editableName;\r\n const qObjectName = firstCharLowerCase(model.qName);\r\n\r\n const [entitySetServiceType] = importContainer.addServiceObject(this.version, ServiceImports.EntitySetService);\r\n const paramsModelName = importContainer.addGeneratedModel(model.id.fqName, model.id.modelName);\r\n const qIdFunctionName = importContainer.addGeneratedQObject(model.id.fqName, model.id.qName);\r\n\r\n const collectionOperations = this.dataModel.getEntitySetOperations(model.fqName);\r\n\r\n const { properties, methods } = this.generateServiceOperations(importContainer, model, collectionOperations);\r\n\r\n file.getFile().addClass({\r\n isExported: true,\r\n name: model.serviceCollectionName,\r\n typeParameters: [\"in out ClientType extends ODataHttpClient\"],\r\n extends:\r\n entitySetServiceType +\r\n `<ClientType, ${model.modelName}, ${editableModelName}, ${model.qName}, ${paramsModelName}>`,\r\n ctors: [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n { name: \"name\", type: \"string\" },\r\n ],\r\n statements: [\r\n `super(client, basePath, name, ${qObjectName}, new ${qIdFunctionName}(name)${\r\n this.isV4BigNumber() ? \", true\" : \"\"\r\n });`,\r\n ],\r\n },\r\n ],\r\n properties,\r\n methods,\r\n });\r\n }\r\n\r\n private generateEntityTypeServices(): Array<Promise<void>> {\r\n // build service file for each entity, consisting of EntityTypeService & EntityCollectionService\r\n return this.dataModel.getEntityTypes().map((model) => {\r\n const file = this.project.createOrGetServiceFile(model.folderPath, model.serviceName, [\r\n model.serviceName,\r\n model.serviceCollectionName,\r\n ]);\r\n\r\n // entity type service\r\n this.generateEntityTypeService(file, model);\r\n // entity collection service if this entity specified keys at all\r\n if (model.keyNames.length) {\r\n this.generateEntityCollectionService(file, model);\r\n }\r\n\r\n return this.project.finalizeFile(file);\r\n });\r\n }\r\n\r\n private generateComplexTypeServices(): Array<Promise<void>> {\r\n // build service file for complex types\r\n return this.dataModel.getComplexTypes().map((model) => {\r\n const file = this.project.createOrGetServiceFile(model.folderPath, model.serviceName, [model.serviceName]);\r\n\r\n // entity type service\r\n this.generateEntityTypeService(file, model);\r\n\r\n return this.project.finalizeFile(file);\r\n });\r\n }\r\n\r\n private generateMethod(\r\n name: string,\r\n operation: OperationType,\r\n importContainer: ImportContainer,\r\n baseFqName: string\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const isFunc = operation.type === OperationTypes.Function;\r\n const returnType = operation.returnType;\r\n const hasParams = operation.parameters.length > 0;\r\n\r\n // importing dependencies\r\n const [httpClientConfigModel, odataResponse] = importContainer.addClientApi(\r\n ClientApiImports.ODataHttpClientConfig,\r\n ClientApiImports.HttpResponseModel\r\n );\r\n const responseStructure = this.importReturnType(importContainer, returnType);\r\n const qOperationName = importContainer.addGeneratedQObject(baseFqName, operation.qName);\r\n const rtType =\r\n returnType?.type && returnType.dataType !== DataTypes.PrimitiveType\r\n ? importContainer.addGeneratedModel(returnType.fqType, returnType.type)\r\n : returnType?.type;\r\n const paramsModelName = hasParams\r\n ? importContainer.addGeneratedModel(baseFqName, operation.paramsModelName)\r\n : undefined;\r\n\r\n const requestConfigParam = {\r\n name: \"requestConfig\",\r\n hasQuestionToken: true,\r\n type: `${httpClientConfigModel}<ClientType>`,\r\n };\r\n const qOpProp = \"this.\" + this.namingHelper.getPrivatePropName(operation.qName);\r\n\r\n return {\r\n scope: Scope.Public,\r\n isAsync: true,\r\n name,\r\n parameters: hasParams ? [{ name: \"params\", type: paramsModelName }, requestConfigParam] : [requestConfigParam],\r\n returnType: `Promise<${odataResponse}<${responseStructure}<${rtType || \"void\"}>>>`,\r\n statements: [\r\n `if(!${qOpProp}) {`,\r\n ` ${qOpProp} = new ${qOperationName}()`,\r\n \"}\",\r\n\r\n `const { addFullPath, client, getDefaultHeaders } = this.__base;`,\r\n `const url = addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? \"params\" : \"\"}));`,\r\n `${returnType ? \"const response = await \" : \"return\"} client.${\r\n !isFunc\r\n ? // actions: since V4\r\n `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : \"{}\"}, ${\r\n requestConfigParam.name\r\n }, getDefaultHeaders())`\r\n : operation.usePost\r\n ? // V2 POST => BUT values are still query params, they are not part of the request body\r\n `post(url, undefined, ${requestConfigParam.name}, getDefaultHeaders())`\r\n : // functions: since V2\r\n `get(url, ${requestConfigParam.name}, getDefaultHeaders())`\r\n };`,\r\n returnType ? `return ${qOpProp}.convertResponse(response);` : \"\",\r\n ],\r\n };\r\n }\r\n\r\n private importReturnType(imports: ImportContainer, returnType: ReturnTypeModel | undefined): string {\r\n const typeToImport: CoreImports = returnType?.isCollection\r\n ? CoreImports.ODataCollectionResponse\r\n : returnType?.dataType === DataTypes.PrimitiveType\r\n ? CoreImports.ODataValueResponse\r\n : CoreImports.ODataModelResponse;\r\n\r\n return imports.addCoreLib(this.version, typeToImport)[0];\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ServiceGenerator.js","sourceRoot":"","sources":["../../src/generator/ServiceGenerator.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,kEAAkC;AAClC,uCAMkB;AAClB,uDAAkD;AAClD,sDAA2D;AAiB3D,gDAA0D;AAG1D,0DAA2G;AAQ3G,SAAsB,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;AATD,4CASC;AAED,MAAM,gBAAgB;IACpB,YACU,OAAuB,EACvB,SAAoB,EACpB,OAAsB,EACtB,YAA0B,EAC1B,UAAmC,EAAE;QAJrC,YAAO,GAAP,OAAO,CAAgB;QACvB,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAe;QACtB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,YAAO,GAAP,OAAO,CAA8B;QAyJvC,2BAAsB,GAAG,CAAC,SAAwB,EAAE,EAAE;YA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pE,kBAAkB,CAAC,IACrB,wBAAwB;oBAC1B,CAAC,CAAC,SAAS,CAAC,OAAO;wBACnB,CAAC,CAAC,sFAAsF;4BACtF,wBAAwB,kBAAkB,CAAC,IAAI,wBAAwB;wBACzE,CAAC,CAAC,sBAAsB;4BACtB,YAAY,kBAAkB,CAAC,IAAI,wBACzC,GAAG;gBACH,UAAU,CAAC,CAAC,CAAC,UAAU,OAAO,6BAA6B,CAAC,CAAC,CAAC,EAAE;aACjE;SACF,CAAC;IACJ,CAAC;IAEO,gBAAgB,CAAC,OAAwB,EAAE,UAAuC;QACxF,MAAM,YAAY,GAAgB,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,YAAY;YACxD,CAAC,CAAC,2BAAW,CAAC,uBAAuB;YACrC,CAAC,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,mDAA4B;gBAClD,CAAC,CAAC,2BAAW,CAAC,kBAAkB;gBAChC,CAAC,CAAC,2BAAW,CAAC,kBAAkB,CAAC;QAEnC,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACxD,CAAC;CACF","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport deepmerge from \"deepmerge\";\r\nimport {\r\n ClassDeclarationStructure,\r\n MethodDeclarationStructure,\r\n OptionalKind,\r\n PropertyDeclarationStructure,\r\n Scope,\r\n} from \"ts-morph\";\r\nimport { upperCaseFirst } from \"upper-case-first\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport {\r\n ActionImportType,\r\n ComplexType,\r\n DataTypes,\r\n EntityContainerModel,\r\n EntityType,\r\n FunctionImportType,\r\n OperationType,\r\n OperationTypes,\r\n PropertyModel,\r\n ReturnTypeModel,\r\n SingletonType,\r\n} from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { ConfigFileOptions, Modes } from \"../OptionModel\";\r\nimport { FileHandler } from \"../project/FileHandler\";\r\nimport { ProjectManager } from \"../project/ProjectManager\";\r\nimport { ClientApiImports, CoreImports, QueryObjectImports, ServiceImports } from \"./import/ImportObjects\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nexport interface PropsAndOps extends Required<Pick<ClassDeclarationStructure, \"properties\" | \"methods\">> {}\r\n\r\nexport interface ServiceGeneratorOptions\r\n extends Pick<ConfigFileOptions, \"enablePrimitivePropertyServices\" | \"v4BigNumberAsString\"> {}\r\n\r\nexport async function generateServices(\r\n project: ProjectManager,\r\n dataModel: DataModel,\r\n version: ODataVersions,\r\n namingHelper: NamingHelper,\r\n options?: ServiceGeneratorOptions\r\n) {\r\n const generator = new ServiceGenerator(project, dataModel, version, namingHelper, options);\r\n return generator.generate();\r\n}\r\n\r\nclass ServiceGenerator {\r\n constructor(\r\n private project: ProjectManager,\r\n private dataModel: DataModel,\r\n private version: ODataVersions,\r\n private namingHelper: NamingHelper,\r\n private options: ServiceGeneratorOptions = {}\r\n ) {}\r\n\r\n private isV4BigNumber() {\r\n return this.options.v4BigNumberAsString && this.version === ODataVersions.V4;\r\n }\r\n\r\n public async generate(): Promise<void> {\r\n const mainServiceName = this.namingHelper.getMainServiceName();\r\n this.project.initServices();\r\n\r\n await Promise.all([\r\n this.generateMainService(mainServiceName),\r\n ...this.generateEntityTypeServices(),\r\n ...this.generateComplexTypeServices(),\r\n ]);\r\n\r\n return this.project.finalizeServices();\r\n }\r\n\r\n private async generateMainService(mainServiceName: string) {\r\n const mainServiceFile = this.project.getMainServiceFile();\r\n const importContainer = mainServiceFile.getImports();\r\n const container = this.dataModel.getEntityContainer();\r\n const unboundOperations = [...Object.values(container.functions), ...Object.values(container.actions)];\r\n\r\n const httpClient = importContainer.addClientApi(ClientApiImports.ODataHttpClient);\r\n const rootService = importContainer.addServiceObject(this.version, ServiceImports.ODataService);\r\n\r\n const { properties, methods }: PropsAndOps = deepmerge(\r\n this.generateMainServiceProperties(container, importContainer),\r\n this.generateMainServiceOperations(unboundOperations, importContainer)\r\n );\r\n\r\n mainServiceFile.getFile().addClass({\r\n isExported: true,\r\n name: mainServiceName,\r\n typeParameters: [`in out ClientType extends ${httpClient}`],\r\n extends: `${rootService}<ClientType>`,\r\n ctors: this.isV4BigNumber()\r\n ? [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n ],\r\n statements: [`super(client, basePath, true);`],\r\n },\r\n ]\r\n : [],\r\n properties,\r\n methods,\r\n });\r\n }\r\n\r\n private generateMainServiceProperties(\r\n container: EntityContainerModel,\r\n importContainer: ImportContainer\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n Object.values(container.entitySets).forEach(({ name, odataName, entityType }) => {\r\n result.methods.push(this.generateRelatedServiceGetter(name, odataName, entityType, importContainer));\r\n });\r\n\r\n Object.values(container.singletons).forEach((singleton) => {\r\n result.properties.push(this.generateSingletonProp(importContainer, singleton));\r\n result.methods.push(this.generateSingletonGetter(singleton));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateMainServiceOperations(\r\n ops: Array<FunctionImportType | ActionImportType>,\r\n importContainer: ImportContainer\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n ops.forEach(({ operation, name }) => {\r\n const op = this.dataModel.getUnboundOperationType(operation);\r\n if (!op) {\r\n throw new Error(`Operation \"${operation}\" not found!`);\r\n }\r\n\r\n result.properties.push(this.generateQOperationProp(op));\r\n result.methods.push(this.generateMethod(name, op, importContainer, \"\"));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateRelatedServiceGetter(\r\n propName: string,\r\n odataPropName: string,\r\n entityType: EntityType,\r\n imports: ImportContainer\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const idName = imports.addGeneratedModel(entityType.id.fqName, entityType.id.modelName);\r\n const idFunctionName = imports.addGeneratedQObject(entityType.id.fqName, entityType.id.qName);\r\n const serviceName = imports.addGeneratedService(entityType.fqName, entityType.serviceName);\r\n const collectionName = imports.addGeneratedService(entityType.fqName, entityType.serviceCollectionName);\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(propName),\r\n parameters: [\r\n {\r\n name: \"id\",\r\n type: `${idName} | undefined`,\r\n hasQuestionToken: true,\r\n },\r\n ],\r\n overloads: [\r\n {\r\n parameters: [],\r\n returnType: `${collectionName}<ClientType>`,\r\n },\r\n {\r\n parameters: [\r\n {\r\n name: \"id\",\r\n type: idName,\r\n },\r\n ],\r\n returnType: `${serviceName}<ClientType>`,\r\n },\r\n ],\r\n statements: [\r\n `const fieldName = \"${odataPropName}\";`,\r\n `const { client, path } = this.__base;`,\r\n 'return typeof id === \"undefined\" || id === null',\r\n `? new ${collectionName}(client, path, fieldName)`,\r\n `: new ${serviceName}(client, path, new ${idFunctionName}(fieldName).buildUrl(id));`,\r\n ],\r\n };\r\n }\r\n\r\n private generateSingletonProp(\r\n importContainer: ImportContainer,\r\n singleton: SingletonType\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n const { name, entityType } = singleton;\r\n const type = entityType.serviceName;\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(name),\r\n type: `${type}<ClientType>`,\r\n hasQuestionToken: true,\r\n };\r\n }\r\n\r\n private generateQOperationProp = (operation: OperationType) => {\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(operation.qName),\r\n type: operation.qName,\r\n hasQuestionToken: true,\r\n };\r\n };\r\n\r\n private generateSingletonGetter(singleton: SingletonType): OptionalKind<MethodDeclarationStructure> {\r\n const { name, odataName, entityType } = singleton;\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(name);\r\n const serviceType = entityType.serviceName;\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n ` const { client, path } = this.__base;`,\r\n // prettier-ignore\r\n ` ${propName} = new ${serviceType}(client, path, \"${odataName}\")`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private generateEntityTypeService(file: FileHandler, model: ComplexType) {\r\n const importContainer = file.getImports();\r\n\r\n const operations = this.dataModel.getEntityTypeOperations(model.fqName);\r\n const props = [...model.baseProps, ...model.props];\r\n\r\n const entityServiceType = importContainer.addServiceObject(this.version, ServiceImports.EntityTypeService);\r\n const httpClient = importContainer.addClientApi(ClientApiImports.ODataHttpClient);\r\n\r\n // note: predictable first imports => no need to take renaming into account\r\n const modelName = importContainer.addGeneratedModel(model.fqName, model.modelName);\r\n const editableModelName = importContainer.addGeneratedModel(model.fqName, model.editableName);\r\n const qName = importContainer.addGeneratedQObject(model.fqName, model.qName);\r\n const qObjectName = importContainer.addGeneratedQObject(model.fqName, firstCharLowerCase(model.qName));\r\n\r\n const { properties, methods }: PropsAndOps = deepmerge(\r\n this.generateServiceProperties(importContainer, model.serviceName, props),\r\n this.generateServiceOperations(importContainer, model, operations)\r\n );\r\n\r\n // generate EntityTypeService\r\n file.getFile().addClass({\r\n isExported: true,\r\n name: model.serviceName,\r\n typeParameters: [`in out ClientType extends ${httpClient}`],\r\n extends: entityServiceType + `<ClientType, ${modelName}, ${editableModelName}, ${qName}>`,\r\n ctors: [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n { name: \"name\", type: \"string\" },\r\n ],\r\n statements: [`super(client, basePath, name, ${qObjectName}${this.isV4BigNumber() ? \", true\" : \"\"});`],\r\n },\r\n ],\r\n properties,\r\n methods,\r\n });\r\n }\r\n\r\n private generateServiceProperties(\r\n importContainer: ImportContainer,\r\n serviceName: string,\r\n props: Array<PropertyModel>\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n props.forEach((prop) => {\r\n // complex types, collection of complex types or entityTypes\r\n if ((prop.dataType === DataTypes.ModelType && !prop.isCollection) || prop.dataType === DataTypes.ComplexType) {\r\n result.properties.push(this.generateModelProp(importContainer, prop));\r\n result.methods.push(this.generateModelPropGetter(importContainer, prop));\r\n } else if (prop.isCollection) {\r\n // collection of entity types\r\n if (prop.dataType === DataTypes.ModelType) {\r\n const entityType = this.dataModel.getEntityType(prop.fqType);\r\n if (!entityType) {\r\n throw new Error(`Entity type \"${prop.fqType}\" specified by property not found!`);\r\n }\r\n\r\n result.methods.push(\r\n this.generateRelatedServiceGetter(prop.name, prop.odataName, entityType, importContainer)\r\n );\r\n }\r\n // collection of primitive or enum types\r\n else {\r\n result.properties.push(this.generatePrimitiveCollectionProp(importContainer, prop));\r\n result.methods.push(this.generatePrimitiveCollectionGetter(importContainer, prop));\r\n }\r\n }\r\n // generation of services for each primitive property: turned off by default\r\n else if (this.options.enablePrimitivePropertyServices && prop.dataType === DataTypes.PrimitiveType) {\r\n result.properties.push(this.generatePrimitiveTypeProp(importContainer, prop));\r\n result.methods.push(this.generatePrimitiveTypeGetter(importContainer, prop));\r\n }\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateServiceOperations(\r\n importContainer: ImportContainer,\r\n model: ComplexType,\r\n operations: Array<OperationType>\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n operations.forEach((operation) => {\r\n result.properties.push(this.generateQOperationProp(operation));\r\n result.methods.push(this.generateMethod(operation.name, operation, importContainer, model.fqName));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateModelProp(imports: ImportContainer, prop: PropertyModel): PropertyDeclarationStructure {\r\n const propModel = this.dataModel.getModel(prop.fqType) as ComplexType;\r\n let propModelType: string;\r\n\r\n if (prop.isCollection) {\r\n const modelName = imports.addGeneratedModel(propModel.fqName, propModel.modelName);\r\n const editableModelName = imports.addGeneratedModel(propModel.fqName, propModel.editableName);\r\n const qModelName = imports.addGeneratedQObject(propModel.fqName, propModel.qName);\r\n const collectionServiceType = imports.addServiceObject(this.version, ServiceImports.CollectionService);\r\n\r\n propModelType = `${collectionServiceType}<ClientType, ${modelName}, ${qModelName}, ${editableModelName}>`;\r\n } else {\r\n const serviceName = imports.addGeneratedService(propModel.fqName, propModel.serviceName);\r\n propModelType = `${serviceName}<ClientType>`;\r\n }\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: propModelType,\r\n hasQuestionToken: true,\r\n } as PropertyDeclarationStructure;\r\n }\r\n\r\n private generatePrimitiveCollectionProp(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n if (!prop.qObject) {\r\n throw new Error(\"Illegal State: [qObject] must be provided for Collection types!\");\r\n }\r\n\r\n const collectionServiceType = imports.addServiceObject(this.version, ServiceImports.CollectionService);\r\n const isEnum = prop.dataType === DataTypes.EnumType;\r\n let qType: string;\r\n let type: string;\r\n\r\n if (!isEnum) {\r\n // TODO move string concat (StringCollection, GuidCollection...) to better place\r\n qType = imports.addQObject(prop.qObject);\r\n type = imports.addQObjectType(`${upperCaseFirst(prop.type)}Collection`);\r\n } else {\r\n const propEnum = this.dataModel.getModel(prop.fqType)!;\r\n const propTypeModel = imports.addGeneratedModel(propEnum.fqName, propEnum.modelName);\r\n qType = imports.addQObject(QueryObjectImports.QEnumCollection);\r\n type = `${imports.addQObjectType(QueryObjectImports.EnumCollection)}<${propTypeModel}>`;\r\n }\r\n\r\n const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: `${collectionType}`,\r\n hasQuestionToken: true,\r\n };\r\n }\r\n\r\n private generatePrimitiveTypeProp(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n const serviceType = imports.addServiceObject(this.version, ServiceImports.PrimitiveTypeService);\r\n const type = prop.typeModule ? imports.addCustomType(prop.typeModule, prop.type, true) : prop.type;\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: `${serviceType}<ClientType, ${type}>`,\r\n hasQuestionToken: true,\r\n };\r\n }\r\n\r\n private generateModelPropGetter(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const model = this.dataModel.getModel(prop.fqType) as ComplexType;\r\n const isComplexCollection = prop.isCollection && model.dataType === DataTypes.ComplexType;\r\n\r\n const type = isComplexCollection\r\n ? imports.addServiceObject(this.version, ServiceImports.CollectionService)\r\n : prop.isCollection\r\n ? model.serviceCollectionName\r\n : model.serviceName;\r\n const typeWithGenerics = isComplexCollection\r\n ? `${type}<ClientType, ${imports.addGeneratedModel(model.fqName, model.modelName)}, ${imports.addGeneratedQObject(\r\n model.fqName,\r\n model.qName\r\n )}, ${imports.addGeneratedModel(model.fqName, model.editableName)}>`\r\n : `${type}<ClientType>`;\r\n\r\n const privateSrvProp = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n returnType: typeWithGenerics,\r\n statements: [\r\n `if(!${privateSrvProp}) {`,\r\n ` const { client, path } = this.__base;`,\r\n // prettier-ignore\r\n ` ${privateSrvProp} = new ${type}(client, path, \"${prop.odataName}\"${isComplexCollection ? `, ${imports.addGeneratedQObject(model.fqName, firstCharLowerCase(model.qName))}`: \"\"})`,\r\n \"}\",\r\n `return ${privateSrvProp}`,\r\n ],\r\n };\r\n }\r\n\r\n private generatePrimitiveCollectionGetter(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const collectionServiceType = imports.addServiceObject(this.version, ServiceImports.CollectionService);\r\n const instanceName = firstCharLowerCase(prop.qObject!);\r\n const qInstanceName = imports.addQObject(instanceName);\r\n\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n ` const { client, path } = this.__base;`,\r\n // prettier-ignore\r\n ` ${propName} = new ${collectionServiceType}(client, path, \"${prop.odataName}\", ${qInstanceName}${this.isV4BigNumber() ? \", true\": \"\"})`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private generatePrimitiveTypeGetter(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const serviceType = imports.addServiceObject(this.version, ServiceImports.PrimitiveTypeService);\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n // for V2: mapped name must be specified\r\n const useMappedName = this.version === ODataVersions.V2 && prop.name !== prop.odataName;\r\n // for V4: big number support\r\n const useBigNumber = this.isV4BigNumber();\r\n const addParamString = useMappedName ? `, \"${prop.name}\"` : useBigNumber ? \", true\" : \"\";\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n ` const { client, path, qModel } = this.__base;`,\r\n ` ${propName} = new ${serviceType}(client, path, \"${prop.odataName}\", qModel.${prop.name}.converter${addParamString})`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private generateEntityCollectionService(file: FileHandler, model: EntityType) {\r\n const importContainer = file.getImports();\r\n const editableModelName = model.editableName;\r\n const qObjectName = firstCharLowerCase(model.qName);\r\n\r\n const entitySetServiceType = importContainer.addServiceObject(this.version, ServiceImports.EntitySetService);\r\n const paramsModelName = importContainer.addGeneratedModel(model.id.fqName, model.id.modelName);\r\n const qIdFunctionName = importContainer.addGeneratedQObject(model.id.fqName, model.id.qName);\r\n\r\n const collectionOperations = this.dataModel.getEntitySetOperations(model.fqName);\r\n\r\n const { properties, methods } = this.generateServiceOperations(importContainer, model, collectionOperations);\r\n\r\n file.getFile().addClass({\r\n isExported: true,\r\n name: model.serviceCollectionName,\r\n typeParameters: [\"in out ClientType extends ODataHttpClient\"],\r\n extends:\r\n entitySetServiceType +\r\n `<ClientType, ${model.modelName}, ${editableModelName}, ${model.qName}, ${paramsModelName}>`,\r\n ctors: [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n { name: \"name\", type: \"string\" },\r\n ],\r\n statements: [\r\n `super(client, basePath, name, ${qObjectName}, new ${qIdFunctionName}(name)${\r\n this.isV4BigNumber() ? \", true\" : \"\"\r\n });`,\r\n ],\r\n },\r\n ],\r\n properties,\r\n methods,\r\n });\r\n }\r\n\r\n private generateEntityTypeServices(): Array<Promise<void>> {\r\n // build service file for each entity, consisting of EntityTypeService & EntityCollectionService\r\n return this.dataModel\r\n .getEntityTypes()\r\n .filter((model) => model.genMode === Modes.service || model.genMode === Modes.all)\r\n .map((model) => {\r\n const file = this.project.createOrGetServiceFile(model.folderPath, model.serviceName, [\r\n model.serviceName,\r\n model.serviceCollectionName,\r\n ]);\r\n\r\n // entity type service\r\n this.generateEntityTypeService(file, model);\r\n // entity collection service if this entity specified keys at all\r\n if (model.keyNames.length) {\r\n this.generateEntityCollectionService(file, model);\r\n }\r\n\r\n return this.project.finalizeFile(file);\r\n });\r\n }\r\n\r\n private generateComplexTypeServices(): Array<Promise<void>> {\r\n // build service file for complex types\r\n return this.dataModel\r\n .getComplexTypes()\r\n .filter((model) => model.genMode === Modes.service || model.genMode === Modes.all)\r\n .map((model) => {\r\n const file = this.project.createOrGetServiceFile(model.folderPath, model.serviceName, [model.serviceName]);\r\n\r\n // entity type service\r\n this.generateEntityTypeService(file, model);\r\n\r\n return this.project.finalizeFile(file);\r\n });\r\n }\r\n\r\n private generateMethod(\r\n name: string,\r\n operation: OperationType,\r\n importContainer: ImportContainer,\r\n baseFqName: string\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const isFunc = operation.type === OperationTypes.Function;\r\n const returnType = operation.returnType;\r\n const hasParams = operation.parameters.length > 0 || operation.overrides?.length;\r\n const isParamsOptional = !![operation.parameters, ...(operation.overrides ?? [])].find((pSet) => pSet.length === 0);\r\n\r\n // importing dependencies\r\n const httpClientConfigModel = importContainer.addClientApi(ClientApiImports.ODataHttpClientConfig);\r\n const odataResponse = importContainer.addClientApi(ClientApiImports.HttpResponseModel);\r\n const responseStructure = this.importReturnType(importContainer, returnType);\r\n const qOperationName = importContainer.addGeneratedQObject(baseFqName, operation.qName);\r\n const rtType =\r\n returnType?.type && returnType.dataType !== DataTypes.PrimitiveType\r\n ? importContainer.addGeneratedModel(returnType.fqType, returnType.type)\r\n : returnType?.type;\r\n const paramsModelName = hasParams\r\n ? importContainer.addGeneratedModel(baseFqName, operation.paramsModelName)\r\n : undefined;\r\n\r\n const requestConfigParam = {\r\n name: \"requestConfig\",\r\n hasQuestionToken: true,\r\n type: `${httpClientConfigModel}<ClientType>`,\r\n };\r\n const qOpProp = \"this.\" + this.namingHelper.getPrivatePropName(operation.qName);\r\n\r\n return {\r\n scope: Scope.Public,\r\n isAsync: true,\r\n name,\r\n parameters: hasParams\r\n ? [{ name: \"params\", type: paramsModelName, hasQuestionToken: isParamsOptional }, requestConfigParam]\r\n : [requestConfigParam],\r\n returnType: `Promise<${odataResponse}<${responseStructure}<${rtType || \"void\"}>>>`,\r\n statements: [\r\n `if(!${qOpProp}) {`,\r\n ` ${qOpProp} = new ${qOperationName}()`,\r\n \"}\",\r\n\r\n `const { addFullPath, client, getDefaultHeaders } = this.__base;`,\r\n `const url = addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? \"params\" : \"\"}));`,\r\n `${returnType ? \"const response = await \" : \"return\"} client.${\r\n !isFunc\r\n ? // actions: since V4\r\n `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : \"{}\"}, ${\r\n requestConfigParam.name\r\n }, getDefaultHeaders())`\r\n : operation.usePost\r\n ? // V2 POST => BUT values are still query params, they are not part of the request body\r\n `post(url, undefined, ${requestConfigParam.name}, getDefaultHeaders())`\r\n : // functions: since V2\r\n `get(url, ${requestConfigParam.name}, getDefaultHeaders())`\r\n };`,\r\n returnType ? `return ${qOpProp}.convertResponse(response);` : \"\",\r\n ],\r\n };\r\n }\r\n\r\n private importReturnType(imports: ImportContainer, returnType: ReturnTypeModel | undefined): string {\r\n const typeToImport: CoreImports = returnType?.isCollection\r\n ? CoreImports.ODataCollectionResponse\r\n : returnType?.dataType === DataTypes.PrimitiveType\r\n ? CoreImports.ODataValueResponse\r\n : CoreImports.ODataModelResponse;\r\n\r\n return imports.addCoreLib(this.version, typeToImport);\r\n }\r\n}\r\n"]}
@@ -27,18 +27,18 @@ export declare const VERSIONED_CORE_IMPORTS: CoreImports[];
27
27
  * Most relevant, but not all imports from query objects library
28
28
  */
29
29
  export declare enum QueryObjectImports {
30
- QueryObject = 0,
31
- QId = 1,
32
- QFunction = 2,
33
- QAction = 3,
34
- EnumCollection = 4,
35
- QEnumCollection = 5,
36
- qEnumCollection = 6,
37
- QCollectionPath = 7,
38
- QEntityCollectionPath = 8,
39
- OperationReturnType = 9,
40
- ReturnTypes = 10,
41
- QComplexParam = 11
30
+ QueryObject = "QueryObject",
31
+ QId = "QId",
32
+ QFunction = "QFunction",
33
+ QAction = "QAction",
34
+ EnumCollection = "EnumCollection",
35
+ QEnumCollection = "QEnumCollection",
36
+ qEnumCollection = "qEnumCollection",
37
+ QCollectionPath = "QCollectionPath",
38
+ QEntityCollectionPath = "QEntityCollectionPath",
39
+ OperationReturnType = "OperationReturnType",
40
+ ReturnTypes = "ReturnTypes",
41
+ QComplexParam = "QComplexParam"
42
42
  }
43
43
  /**
44
44
  * All imports from HTTP client API.
@@ -36,18 +36,18 @@ exports.VERSIONED_CORE_IMPORTS = [
36
36
  */
37
37
  var QueryObjectImports;
38
38
  (function (QueryObjectImports) {
39
- QueryObjectImports[QueryObjectImports["QueryObject"] = 0] = "QueryObject";
40
- QueryObjectImports[QueryObjectImports["QId"] = 1] = "QId";
41
- QueryObjectImports[QueryObjectImports["QFunction"] = 2] = "QFunction";
42
- QueryObjectImports[QueryObjectImports["QAction"] = 3] = "QAction";
43
- QueryObjectImports[QueryObjectImports["EnumCollection"] = 4] = "EnumCollection";
44
- QueryObjectImports[QueryObjectImports["QEnumCollection"] = 5] = "QEnumCollection";
45
- QueryObjectImports[QueryObjectImports["qEnumCollection"] = 6] = "qEnumCollection";
46
- QueryObjectImports[QueryObjectImports["QCollectionPath"] = 7] = "QCollectionPath";
47
- QueryObjectImports[QueryObjectImports["QEntityCollectionPath"] = 8] = "QEntityCollectionPath";
48
- QueryObjectImports[QueryObjectImports["OperationReturnType"] = 9] = "OperationReturnType";
49
- QueryObjectImports[QueryObjectImports["ReturnTypes"] = 10] = "ReturnTypes";
50
- QueryObjectImports[QueryObjectImports["QComplexParam"] = 11] = "QComplexParam";
39
+ QueryObjectImports["QueryObject"] = "QueryObject";
40
+ QueryObjectImports["QId"] = "QId";
41
+ QueryObjectImports["QFunction"] = "QFunction";
42
+ QueryObjectImports["QAction"] = "QAction";
43
+ QueryObjectImports["EnumCollection"] = "EnumCollection";
44
+ QueryObjectImports["QEnumCollection"] = "QEnumCollection";
45
+ QueryObjectImports["qEnumCollection"] = "qEnumCollection";
46
+ QueryObjectImports["QCollectionPath"] = "QCollectionPath";
47
+ QueryObjectImports["QEntityCollectionPath"] = "QEntityCollectionPath";
48
+ QueryObjectImports["OperationReturnType"] = "OperationReturnType";
49
+ QueryObjectImports["ReturnTypes"] = "ReturnTypes";
50
+ QueryObjectImports["QComplexParam"] = "QComplexParam";
51
51
  })(QueryObjectImports || (exports.QueryObjectImports = QueryObjectImports = {}));
52
52
  /**
53
53
  * All imports from HTTP client API.
@@ -1 +1 @@
1
- {"version":3,"file":"ImportObjects.js","sourceRoot":"","sources":["../../../src/generator/import/ImportObjects.ts"],"names":[],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AAoB;IACnC,cAAc,CAAC,iBAAiB;IAChC,cAAc,CAAC,gBAAgB;CAChC,CAAC","sourcesContent":["/**\r\n * All module names of the main dependencies.\r\n */\r\nexport const LIB_MODULES = {\r\n core: \"@odata2ts/odata-core\",\r\n qObject: \"@odata2ts/odata-query-objects\",\r\n clientApi: \"@odata2ts/http-client-api\",\r\n service: \"@odata2ts/odata-service\",\r\n};\r\n\r\n/**\r\n * All imported entity names from the core API.\r\n * Includes versioned file names, i.e. according to OData version.\r\n */\r\nexport enum CoreImports {\r\n DeferredContent,\r\n ODataCollectionResponse, // versioned\r\n ODataModelResponse, // versioned\r\n ODataValueResponse, // versioned\r\n}\r\n\r\n/**\r\n * For all core imports that are versioned two files exist, one for V2, one for V4.\r\n * ODataCollectionResponse = ODataCollectionResponseV2 + ODataCollectionResponseV4\r\n *\r\n */\r\nexport const VERSIONED_CORE_IMPORTS = [\r\n CoreImports.ODataCollectionResponse,\r\n CoreImports.ODataValueResponse,\r\n CoreImports.ODataModelResponse,\r\n];\r\n\r\n/**\r\n * Most relevant, but not all imports from query objects library\r\n */\r\nexport enum QueryObjectImports {\r\n QueryObject,\r\n QId,\r\n QFunction,\r\n QAction,\r\n EnumCollection,\r\n QEnumCollection,\r\n qEnumCollection,\r\n QCollectionPath,\r\n QEntityCollectionPath,\r\n OperationReturnType,\r\n ReturnTypes,\r\n QComplexParam,\r\n}\r\n\r\n/**\r\n * All imports from HTTP client API.\r\n */\r\nexport enum ClientApiImports {\r\n ODataHttpClient,\r\n ODataHttpClientConfig,\r\n HttpResponseModel,\r\n}\r\n\r\n/**\r\n * All imports from service library.\r\n * Includes versioned file names, i.e. according to OData version.\r\n */\r\nexport enum ServiceImports {\r\n ODataService,\r\n EntityTypeService,\r\n PrimitiveTypeService,\r\n CollectionService,\r\n EntitySetService,\r\n}\r\n\r\n/**\r\n * For all versioned imports two files exist, one for V2, one for V4.\r\n * EntityTypeService = EntityTypeServiceV2 + EntityTypeServiceV4\r\n */\r\nexport const VERSIONED_SERVICE_IMPORTS = [\r\n ServiceImports.EntityTypeService,\r\n ServiceImports.PrimitiveTypeService,\r\n ServiceImports.CollectionService,\r\n ServiceImports.EntitySetService,\r\n];\r\n"]}
1
+ {"version":3,"file":"ImportObjects.js","sourceRoot":"","sources":["../../../src/generator/import/ImportObjects.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,+BAA+B;IACxC,SAAS,EAAE,2BAA2B;IACtC,OAAO,EAAE,yBAAyB;CACnC,CAAC;AAEF;;;GAGG;AACH,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,mEAAe,CAAA;IACf,mFAAuB,CAAA;IACvB,yEAAkB,CAAA;IAClB,yEAAkB,CAAA;AACpB,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAED;;;;GAIG;AACU,QAAA,sBAAsB,GAAG;IACpC,WAAW,CAAC,uBAAuB;IACnC,WAAW,CAAC,kBAAkB;IAC9B,WAAW,CAAC,kBAAkB;CAC/B,CAAC;AAEF;;GAEG;AACH,IAAY,kBAaX;AAbD,WAAY,kBAAkB;IAC5B,iDAA2B,CAAA;IAC3B,iCAAW,CAAA;IACX,6CAAuB,CAAA;IACvB,yCAAmB,CAAA;IACnB,uDAAiC,CAAA;IACjC,yDAAmC,CAAA;IACnC,yDAAmC,CAAA;IACnC,yDAAmC,CAAA;IACnC,qEAA+C,CAAA;IAC/C,iEAA2C,CAAA;IAC3C,iDAA2B,CAAA;IAC3B,qDAA+B,CAAA;AACjC,CAAC,EAbW,kBAAkB,kCAAlB,kBAAkB,QAa7B;AAED;;GAEG;AACH,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,6EAAe,CAAA;IACf,yFAAqB,CAAA;IACrB,iFAAiB,CAAA;AACnB,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B;AAED;;;GAGG;AACH,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,mEAAY,CAAA;IACZ,6EAAiB,CAAA;IACjB,mFAAoB,CAAA;IACpB,6EAAiB,CAAA;IACjB,2EAAgB,CAAA;AAClB,CAAC,EANW,cAAc,8BAAd,cAAc,QAMzB;AAED;;;GAGG;AACU,QAAA,yBAAyB,GAAG;IACvC,cAAc,CAAC,iBAAiB;IAChC,cAAc,CAAC,oBAAoB;IACnC,cAAc,CAAC,iBAAiB;IAChC,cAAc,CAAC,gBAAgB;CAChC,CAAC","sourcesContent":["/**\r\n * All module names of the main dependencies.\r\n */\r\nexport const LIB_MODULES = {\r\n core: \"@odata2ts/odata-core\",\r\n qObject: \"@odata2ts/odata-query-objects\",\r\n clientApi: \"@odata2ts/http-client-api\",\r\n service: \"@odata2ts/odata-service\",\r\n};\r\n\r\n/**\r\n * All imported entity names from the core API.\r\n * Includes versioned file names, i.e. according to OData version.\r\n */\r\nexport enum CoreImports {\r\n DeferredContent,\r\n ODataCollectionResponse, // versioned\r\n ODataModelResponse, // versioned\r\n ODataValueResponse, // versioned\r\n}\r\n\r\n/**\r\n * For all core imports that are versioned two files exist, one for V2, one for V4.\r\n * ODataCollectionResponse = ODataCollectionResponseV2 + ODataCollectionResponseV4\r\n *\r\n */\r\nexport const VERSIONED_CORE_IMPORTS = [\r\n CoreImports.ODataCollectionResponse,\r\n CoreImports.ODataValueResponse,\r\n CoreImports.ODataModelResponse,\r\n];\r\n\r\n/**\r\n * Most relevant, but not all imports from query objects library\r\n */\r\nexport enum QueryObjectImports {\r\n QueryObject = \"QueryObject\",\r\n QId = \"QId\",\r\n QFunction = \"QFunction\",\r\n QAction = \"QAction\",\r\n EnumCollection = \"EnumCollection\",\r\n QEnumCollection = \"QEnumCollection\",\r\n qEnumCollection = \"qEnumCollection\",\r\n QCollectionPath = \"QCollectionPath\",\r\n QEntityCollectionPath = \"QEntityCollectionPath\",\r\n OperationReturnType = \"OperationReturnType\",\r\n ReturnTypes = \"ReturnTypes\",\r\n QComplexParam = \"QComplexParam\",\r\n}\r\n\r\n/**\r\n * All imports from HTTP client API.\r\n */\r\nexport enum ClientApiImports {\r\n ODataHttpClient,\r\n ODataHttpClientConfig,\r\n HttpResponseModel,\r\n}\r\n\r\n/**\r\n * All imports from service library.\r\n * Includes versioned file names, i.e. according to OData version.\r\n */\r\nexport enum ServiceImports {\r\n ODataService,\r\n EntityTypeService,\r\n PrimitiveTypeService,\r\n CollectionService,\r\n EntitySetService,\r\n}\r\n\r\n/**\r\n * For all versioned imports two files exist, one for V2, one for V4.\r\n * EntityTypeService = EntityTypeServiceV2 + EntityTypeServiceV4\r\n */\r\nexport const VERSIONED_SERVICE_IMPORTS = [\r\n ServiceImports.EntityTypeService,\r\n ServiceImports.PrimitiveTypeService,\r\n ServiceImports.CollectionService,\r\n ServiceImports.EntitySetService,\r\n];\r\n"]}
@@ -1,5 +1,4 @@
1
1
  import { SourceFile } from "ts-morph";
2
- import { DataModel } from "../data-model/DataModel";
3
2
  import { ImportContainer } from "../generator/ImportContainer";
4
3
  import { EmitModes } from "../OptionModel";
5
4
  import { FileFormatter } from "./formatter/FileFormatter";
@@ -7,22 +6,13 @@ export declare class FileHandler {
7
6
  readonly path: string;
8
7
  readonly fileName: string;
9
8
  protected readonly file: SourceFile;
10
- protected mainFileNames: {
11
- model: string;
12
- qObject: string;
13
- service: string;
14
- };
15
- protected bundledFileGeneration: boolean;
9
+ protected readonly importContainer: ImportContainer;
16
10
  protected formatter: FileFormatter | undefined;
17
- private readonly importContainer;
18
- constructor(path: string, fileName: string, file: SourceFile, dataModel: DataModel, mainFileNames: {
19
- model: string;
20
- qObject: string;
21
- service: string;
22
- }, bundledFileGeneration: boolean, formatter: FileFormatter | undefined, reservedNames: Array<string> | undefined);
11
+ readonly allowTypeChecking: boolean;
12
+ constructor(path: string, fileName: string, file: SourceFile, importContainer: ImportContainer, formatter: FileFormatter | undefined, allowTypeChecking: boolean);
23
13
  getFullFilePath(): string;
24
14
  getFile(): SourceFile;
25
15
  getImports(): ImportContainer;
26
- write(emitMode: EmitModes): Promise<void | import("ts-morph").EmitResult>;
16
+ write(emitMode: EmitModes, noOutput?: boolean): Promise<void | import("ts-morph").EmitResult>;
27
17
  private formatAndWriteFile;
28
18
  }
@@ -3,17 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FileHandler = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const promises_1 = require("fs/promises");
6
- const ImportContainer_1 = require("../generator/ImportContainer");
7
6
  const OptionModel_1 = require("../OptionModel");
8
7
  class FileHandler {
9
- constructor(path, fileName, file, dataModel, mainFileNames, bundledFileGeneration, formatter, reservedNames) {
8
+ constructor(path, fileName, file, importContainer, formatter, allowTypeChecking) {
10
9
  this.path = path;
11
10
  this.fileName = fileName;
12
11
  this.file = file;
13
- this.mainFileNames = mainFileNames;
14
- this.bundledFileGeneration = bundledFileGeneration;
12
+ this.importContainer = importContainer;
15
13
  this.formatter = formatter;
16
- this.importContainer = new ImportContainer_1.ImportContainer(path, fileName, dataModel, mainFileNames, bundledFileGeneration, reservedNames);
14
+ this.allowTypeChecking = allowTypeChecking;
17
15
  }
18
16
  getFullFilePath() {
19
17
  return this.path ? `${this.path}/${this.fileName}` : this.fileName;
@@ -24,9 +22,19 @@ class FileHandler {
24
22
  getImports() {
25
23
  return this.importContainer;
26
24
  }
27
- write(emitMode) {
25
+ write(emitMode, noOutput = false) {
28
26
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
29
27
  this.file.addImportDeclarations(this.importContainer.getImportDeclarations());
28
+ // add ts-nocheck to beginning of each file
29
+ if (!this.allowTypeChecking) {
30
+ const stmts = this.file.addStatements((writer) => {
31
+ writer.writeLine("// @ts-nocheck");
32
+ });
33
+ stmts[0].setOrder(0);
34
+ }
35
+ if (noOutput) {
36
+ return;
37
+ }
30
38
  switch (emitMode) {
31
39
  case OptionModel_1.EmitModes.js:
32
40
  case OptionModel_1.EmitModes.js_dts:
@@ -1 +1 @@
1
- {"version":3,"file":"FileHandler.js","sourceRoot":"","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,EAAE,CAAC,CAAC;gBACpD,KAAK,uBAAS,CAAC,EAAE;oBACf,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBACnC;oBACE,MAAM,IAAI,KAAK,CAAC,cAAc,QAAQ,eAAe,CAAC,CAAC;aAC1D;QACH,CAAC;KAAA;IAEa,kBAAkB;;YAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACzC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YAExC,IAAI;gBACF,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;gBAElF,IAAI;oBACF,OAAO,IAAA,oBAAS,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;iBACvC;gBAAC,OAAO,UAAU,EAAE;oBACnB,OAAO,CAAC,KAAK,CAAC,0BAA0B,QAAQ,GAAG,EAAE,UAAU,CAAC,CAAC;oBACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBACjB;aACF;YAAC,OAAO,eAAe,EAAE;gBACxB,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;gBACpD,MAAM,IAAA,oBAAS,EAAC,WAAW,EAAE,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,QAAQ,EAAE,KAAI,mBAAmB,CAAC,CAAC;gBACjF,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;aAClB;QACH,CAAC;KAAA;CACF;AAtED,kCAsEC","sourcesContent":["import { writeFile } from \"fs/promises\";\r\n\r\nimport { SourceFile } from \"ts-morph\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport { ImportContainer } from \"../generator/ImportContainer\";\r\nimport { EmitModes } from \"../OptionModel\";\r\nimport { FileFormatter } from \"./formatter/FileFormatter\";\r\n\r\nexport class FileHandler {\r\n private readonly importContainer: ImportContainer;\r\n\r\n constructor(\r\n public readonly path: string,\r\n public readonly fileName: string,\r\n protected readonly file: SourceFile,\r\n dataModel: DataModel,\r\n protected mainFileNames: { model: string; qObject: string; service: string },\r\n protected bundledFileGeneration: boolean,\r\n protected formatter: FileFormatter | undefined,\r\n reservedNames: Array<string> | undefined\r\n ) {\r\n this.importContainer = new ImportContainer(\r\n path,\r\n fileName,\r\n dataModel,\r\n mainFileNames,\r\n bundledFileGeneration,\r\n reservedNames\r\n );\r\n }\r\n\r\n public getFullFilePath() {\r\n return this.path ? `${this.path}/${this.fileName}` : this.fileName;\r\n }\r\n\r\n public getFile() {\r\n return this.file;\r\n }\r\n\r\n public getImports() {\r\n return this.importContainer;\r\n }\r\n\r\n public async write(emitMode: EmitModes) {\r\n this.file.addImportDeclarations(this.importContainer.getImportDeclarations());\r\n\r\n switch (emitMode) {\r\n case EmitModes.js:\r\n case EmitModes.js_dts:\r\n return this.file.emit();\r\n case EmitModes.dts:\r\n return this.file.emit({ emitOnlyDtsFiles: true });\r\n case EmitModes.ts:\r\n return this.formatAndWriteFile();\r\n default:\r\n throw new Error(`Emit mode \"${emitMode}\" is invalid!`);\r\n }\r\n }\r\n\r\n private async formatAndWriteFile() {\r\n const fileName = this.file.getFilePath();\r\n const content = this.file.getFullText();\r\n\r\n try {\r\n const formatted = this.formatter ? await this.formatter.format(content) : content;\r\n\r\n try {\r\n return writeFile(fileName, formatted);\r\n } catch (writeError) {\r\n console.error(`Failed to write file [/${fileName}]`, writeError);\r\n process.exit(3);\r\n }\r\n } catch (formattingError) {\r\n console.error(\"Formatting failed\", formattingError);\r\n await writeFile(\"error.log\", formattingError?.toString() || \"no error message!\");\r\n process.exit(99);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"FileHandler.js","sourceRoot":"","sources":["../../src/project/FileHandler.ts"],"names":[],"mappings":";;;;AAAA,0CAAwC;AAKxC,gD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ts-morph\";\r\n\r\nimport { ImportContainer } from \"../generator/ImportContainer\";\r\nimport { EmitModes } from \"../OptionModel\";\r\nimport { FileFormatter } from \"./formatter/FileFormatter\";\r\n\r\nexport class FileHandler {\r\n constructor(\r\n public readonly path: string,\r\n public readonly fileName: string,\r\n protected readonly file: SourceFile,\r\n protected readonly importContainer: ImportContainer,\r\n protected formatter: FileFormatter | undefined,\r\n public readonly allowTypeChecking: boolean\r\n ) {}\r\n\r\n public getFullFilePath() {\r\n return this.path ? `${this.path}/${this.fileName}` : this.fileName;\r\n }\r\n\r\n public getFile() {\r\n return this.file;\r\n }\r\n\r\n public getImports() {\r\n return this.importContainer;\r\n }\r\n\r\n public async write(emitMode: EmitModes, noOutput = false) {\r\n this.file.addImportDeclarations(this.importContainer.getImportDeclarations());\r\n // add ts-nocheck to beginning of each file\r\n if (!this.allowTypeChecking) {\r\n const stmts = this.file.addStatements((writer) => {\r\n writer.writeLine(\"// @ts-nocheck\");\r\n });\r\n stmts[0].setOrder(0);\r\n }\r\n\r\n if (noOutput) {\r\n return;\r\n }\r\n\r\n switch (emitMode) {\r\n case EmitModes.js:\r\n case EmitModes.js_dts:\r\n return this.file.emit();\r\n case EmitModes.dts:\r\n return this.file.emit({ emitOnlyDtsFiles: true });\r\n case EmitModes.ts:\r\n return this.formatAndWriteFile();\r\n default:\r\n throw new Error(`Emit mode \"${emitMode}\" is invalid!`);\r\n }\r\n }\r\n\r\n private async formatAndWriteFile() {\r\n const fileName = this.file.getFilePath();\r\n const content = this.file.getFullText();\r\n\r\n try {\r\n const formatted = this.formatter ? await this.formatter.format(content) : content;\r\n\r\n try {\r\n return writeFile(fileName, formatted);\r\n } catch (writeError) {\r\n console.error(`Failed to write file [/${fileName}]`, writeError);\r\n process.exit(3);\r\n }\r\n } catch (formattingError) {\r\n console.error(\"Formatting failed\", formattingError);\r\n await writeFile(\"error.log\", formattingError?.toString() || \"no error message!\");\r\n process.exit(99);\r\n }\r\n }\r\n}\r\n"]}
@@ -12,6 +12,7 @@ export interface ProjectManagerOptions {
12
12
  * for testing purposes, turn this on and retrieve all generated files via getCachedFiles
13
13
  */
14
14
  noOutput?: boolean;
15
+ allowTypeChecking?: boolean;
15
16
  }
16
17
  export declare function createProjectManager(outputDir: string, emitMode: EmitModes, namingHelper: NamingHelper, dataModel: DataModel, options: ProjectManagerOptions): Promise<ProjectManager>;
17
18
  export declare class ProjectManager {
@@ -6,6 +6,7 @@ const path = tslib_1.__importStar(require("path"));
6
6
  const fs_extra_1 = require("fs-extra");
7
7
  const ts_morph_1 = require("ts-morph");
8
8
  const processors_1 = require("xml2js/lib/processors");
9
+ const ImportContainer_1 = require("../generator/ImportContainer");
9
10
  const FileHandler_1 = require("./FileHandler");
10
11
  const formatter_1 = require("./formatter");
11
12
  const TsMorphHelper_1 = require("./TsMorphHelper");
@@ -51,16 +52,17 @@ class ProjectManager {
51
52
  writeFile(fileHandler) {
52
53
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
53
54
  if (this.options.noOutput) {
54
- fileHandler.getFile().addImportDeclarations(fileHandler.getImports().getImportDeclarations());
55
+ yield fileHandler.write(this.emitMode, true);
55
56
  this.cachedFiles.set(fileHandler.getFullFilePath(), fileHandler.getFile());
56
57
  return;
57
58
  }
58
59
  return fileHandler.write(this.emitMode);
59
60
  });
60
61
  }
61
- createFile(name, reservedNames, additionalPath = "") {
62
+ createFile(name, reservedNames, additionalPath = "", forceTypeChecking = false) {
62
63
  const fileName = path.join(this.outputDir, additionalPath, `${name}.ts`);
63
- return new FileHandler_1.FileHandler(additionalPath, name, this.project.createSourceFile(fileName), this.dataModel, this.namingHelper.getFileNames(), !!this.options.bundledFileGeneration, this.formatter, reservedNames);
64
+ const imports = new ImportContainer_1.ImportContainer(additionalPath, name, this.dataModel, this.namingHelper.getFileNames(), !!this.options.bundledFileGeneration, reservedNames);
65
+ return new FileHandler_1.FileHandler(additionalPath, name, this.project.createSourceFile(fileName), imports, this.formatter, forceTypeChecking || !!this.options.allowTypeChecking);
64
66
  }
65
67
  init() {
66
68
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -161,7 +163,7 @@ class ProjectManager {
161
163
  }
162
164
  createOrGetMainModelFile(reservedNames) {
163
165
  if (!this.mainModelFile) {
164
- this.mainModelFile = this.createFile(this.namingHelper.getFileNames().model, reservedNames);
166
+ this.mainModelFile = this.createFile(this.namingHelper.getFileNames().model, reservedNames, "", true);
165
167
  }
166
168
  return this.mainModelFile;
167
169
  }
@@ -175,7 +177,8 @@ class ProjectManager {
175
177
  if (this.mainModelFile) {
176
178
  return this.mainModelFile;
177
179
  }
178
- return this.createFile(name, reservedNames, folderPath);
180
+ // model files always allow for type checking
181
+ return this.createFile(name, reservedNames, folderPath, true);
179
182
  }
180
183
  createOrGetQObjectFile(folderPath, name, reservedNames) {
181
184
  if (this.mainQFile) {
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectManager.js","sourceRoot":"","sources":["../../src/project/ProjectManager.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAE7B,uCAAqC;AACrC,uCAAgE;AAChE,sDAA2D;AAM3D,+CAA4C;AAC5C,2CAA8C;AAE9C,mDAA6D;AAY7D,SAAsB,oBAAoB,CACxC,SAAiB,EACjB,QAAmB,EACnB,YAA0B,EAC1B,SAAoB,EACpB,OAA8B;;QAE9B,MAAM,EAAE,WAAW,GAAG,KAAK,EAAE,YAAY,GAAG,eAAe,EAAE,GAAG,OAAO,CAAC;QACxE,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,IAAA,2BAAe,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE1F,MAAM,YAAY,GAAoB,MAAM,IAAA,0CAA0B,EAAC,YAAY,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAE1G,MAAM,EAAE,GAAG,IAAI,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,kB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ND,wCA8NC","sourcesContent":["import * as path from \"path\";\r\n\r\nimport { ensureDir } from \"fs-extra\";\r\nimport { CompilerOptions, Project, SourceFile } from \"ts-morph\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport { EntityType } from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { EmitModes } from \"../OptionModel\";\r\nimport { FileHandler } from \"./FileHandler\";\r\nimport { createFormatter } from \"./formatter\";\r\nimport { FileFormatter } from \"./formatter/FileFormatter\";\r\nimport { loadTsMorphCompilerOptions } from \"./TsMorphHelper\";\r\n\r\nexport interface ProjectManagerOptions {\r\n usePrettier?: boolean;\r\n tsConfigPath?: string;\r\n bundledFileGeneration?: boolean;\r\n /**\r\n * for testing purposes, turn this on and retrieve all generated files via getCachedFiles\r\n */\r\n noOutput?: boolean;\r\n}\r\n\r\nexport async function createProjectManager(\r\n outputDir: string,\r\n emitMode: EmitModes,\r\n namingHelper: NamingHelper,\r\n dataModel: DataModel,\r\n options: ProjectManagerOptions\r\n): Promise<ProjectManager> {\r\n const { usePrettier = false, tsConfigPath = \"tsconfig.json\" } = options;\r\n const formatter = usePrettier ? await createFormatter(outputDir, usePrettier) : undefined;\r\n\r\n const compilerOpts: CompilerOptions = await loadTsMorphCompilerOptions(tsConfigPath, emitMode, outputDir);\r\n\r\n const pm = new ProjectManager(outputDir, emitMode, namingHelper, dataModel, formatter, compilerOpts, {\r\n usePrettier,\r\n tsConfigPath,\r\n ...options,\r\n });\r\n\r\n await pm.init();\r\n\r\n return pm;\r\n}\r\n\r\nexport class ProjectManager {\r\n private project!: Project;\r\n\r\n private mainServiceFile: FileHandler | undefined;\r\n private mainModelFile: FileHandler | undefined;\r\n private mainQFile: FileHandler | undefined;\r\n\r\n private readonly cachedFiles: Map<string, SourceFile> | undefined;\r\n\r\n constructor(\r\n protected outputDir: string,\r\n protected emitMode: EmitModes,\r\n protected namingHelper: NamingHelper,\r\n protected dataModel: DataModel,\r\n protected formatter: FileFormatter | undefined,\r\n compilerOptions: CompilerOptions | undefined,\r\n protected options: ProjectManagerOptions\r\n ) {\r\n // Create ts-morph project\r\n this.project = new Project({\r\n // manipulationSettings: this.formatter.getSettings(),\r\n skipAddingFilesFromTsConfig: true,\r\n compilerOptions,\r\n });\r\n\r\n if (options.noOutput) {\r\n this.cachedFiles = new Map();\r\n }\r\n }\r\n\r\n public getDataModel() {\r\n return this.dataModel;\r\n }\r\n\r\n /**\r\n * Only filled when noOutput=true\r\n */\r\n public getCachedFiles() {\r\n return this.cachedFiles!;\r\n }\r\n\r\n private async writeFile(fileHandler: FileHandler) {\r\n if (this.options.noOutput) {\r\n fileHandler.getFile().addImportDeclarations(fileHandler.getImports().getImportDeclarations());\r\n this.cachedFiles!.set(fileHandler.getFullFilePath(), fileHandler.getFile());\r\n return;\r\n }\r\n\r\n return fileHandler.write(this.emitMode);\r\n }\r\n\r\n private createFile(\r\n name: string,\r\n reservedNames?: Array<string> | undefined,\r\n additionalPath: string = \"\"\r\n ): FileHandler {\r\n const fileName = path.join(this.outputDir, additionalPath, `${name}.ts`);\r\n\r\n return new FileHandler(\r\n additionalPath,\r\n name,\r\n this.project.createSourceFile(fileName),\r\n this.dataModel,\r\n this.namingHelper.getFileNames(),\r\n !!this.options.bundledFileGeneration,\r\n this.formatter,\r\n reservedNames\r\n );\r\n }\r\n\r\n public async init() {\r\n if (!this.options.bundledFileGeneration) {\r\n // ensure folder for each model: we do this at this point for performance reasons\r\n await Promise.all(\r\n this.dataModel.getModelTypes().map((mt) => ensureDir(path.join(this.outputDir, mt.folderPath)))\r\n );\r\n }\r\n\r\n const typePart = this.emitMode.toUpperCase().replace(\"_\", \" & \");\r\n console.log(`Prepared to emit ${typePart} files.`);\r\n }\r\n\r\n public initModels() {\r\n if (this.options.bundledFileGeneration) {\r\n // collect reserved names, that is names of classes we're going to create => imports must take them into account\r\n const reservedWords = this.dataModel.getModelTypes().reduce<Array<string>>((collector, model) => {\r\n const asEntityType = model as EntityType;\r\n collector.push(model.modelName);\r\n if (asEntityType.editableName) {\r\n collector.push(asEntityType.editableName);\r\n }\r\n if (asEntityType.id?.modelName) {\r\n collector.push(asEntityType.id.modelName);\r\n }\r\n this.dataModel.getAllEntityOperations(model.fqName).forEach((op) => {\r\n if (op.parameters.length) {\r\n collector.push(op.paramsModelName);\r\n }\r\n });\r\n\r\n return collector;\r\n }, []);\r\n this.dataModel.getUnboundOperationTypes().forEach((op) => {\r\n if (op.parameters.length) {\r\n reservedWords.push(op.paramsModelName);\r\n }\r\n });\r\n\r\n this.mainModelFile = this.createFile(this.namingHelper.getFileNames().model, reservedWords);\r\n }\r\n }\r\n\r\n public async finalizeModels() {\r\n if (\r\n this.mainModelFile &&\r\n (this.options.bundledFileGeneration || this.mainModelFile.getFile().getFullText().length)\r\n ) {\r\n await this.writeFile(this.mainModelFile);\r\n }\r\n }\r\n\r\n public initQObjects() {\r\n if (this.options.bundledFileGeneration) {\r\n // collect reserved names, that is names of classes we're going to create => imports must take them into account\r\n const reservedWords = this.dataModel.getModelTypes().reduce<Array<string>>((collector, model) => {\r\n const asEntityType = model as EntityType;\r\n if (asEntityType.qName) {\r\n collector.push(asEntityType.qName, firstCharLowerCase(asEntityType.qName));\r\n }\r\n if (asEntityType.id?.qName) {\r\n collector.push(asEntityType.id.qName);\r\n }\r\n this.dataModel.getAllEntityOperations(model.fqName).forEach((op) => {\r\n collector.push(op.qName);\r\n });\r\n\r\n return collector;\r\n }, []);\r\n this.dataModel.getUnboundOperationTypes().forEach((op) => {\r\n reservedWords.push(op.qName);\r\n });\r\n\r\n this.mainQFile = this.createFile(this.namingHelper.getFileNames().qObject, reservedWords);\r\n }\r\n }\r\n\r\n public async finalizeQObjects() {\r\n if (this.mainQFile && (this.options.bundledFileGeneration || this.mainQFile.getFile().getFullText().length)) {\r\n await this.writeFile(this.mainQFile);\r\n }\r\n }\r\n\r\n public initServices() {\r\n const mainServiceName = this.namingHelper.getMainServiceName();\r\n const reservedNames = [mainServiceName];\r\n\r\n if (this.options.bundledFileGeneration) {\r\n [...this.dataModel.getEntityTypes(), ...this.dataModel.getComplexTypes()].reduce((collector, model) => {\r\n collector.push(model.serviceName, model.serviceCollectionName);\r\n return collector;\r\n }, reservedNames);\r\n }\r\n\r\n this.mainServiceFile = this.createFile(mainServiceName, reservedNames);\r\n }\r\n\r\n public async finalizeServices() {\r\n if (this.mainServiceFile) {\r\n await this.writeFile(this.mainServiceFile);\r\n }\r\n }\r\n\r\n public getMainServiceFile() {\r\n return this.mainServiceFile!;\r\n }\r\n\r\n public createOrGetMainModelFile(reservedNames?: Array<string>) {\r\n if (!this.mainModelFile) {\r\n this.mainModelFile = this.createFile(this.namingHelper.getFileNames().model, reservedNames);\r\n }\r\n return this.mainModelFile;\r\n }\r\n\r\n public createOrGetMainQObjectFile(reservedNames?: Array<string>) {\r\n if (!this.mainQFile) {\r\n this.mainQFile = this.createFile(this.namingHelper.getFileNames().qObject, reservedNames);\r\n }\r\n return this.mainQFile;\r\n }\r\n\r\n public createOrGetModelFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\r\n if (this.mainModelFile) {\r\n return this.mainModelFile;\r\n }\r\n\r\n return this.createFile(name, reservedNames, folderPath);\r\n }\r\n public createOrGetQObjectFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\r\n if (this.mainQFile) {\r\n return this.mainQFile;\r\n }\r\n\r\n return this.createFile(name, reservedNames, folderPath);\r\n }\r\n public createOrGetServiceFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\r\n if (this.options.bundledFileGeneration) {\r\n return this.mainServiceFile!;\r\n }\r\n\r\n return this.createFile(name, reservedNames, folderPath);\r\n }\r\n\r\n public async finalizeFile(file: FileHandler) {\r\n // write individual files in unbundled mode & if this is not one of the main files on root level\r\n if (\r\n !this.options.bundledFileGeneration &&\r\n file.path !== \"\" &&\r\n !Object.values(this.namingHelper.getFileNames()).includes(file.fileName)\r\n ) {\r\n await this.writeFile(file);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ProjectManager.js","sourceRoot":"","sources":["../../src/project/ProjectManager.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAE7B,uCAAqC;AACrC,uCAAgE;AAChE,sDAA2D;AAK3D,kEAA+D;AAE/D,+CAA4C;AAC5C,2CAA8C;AAE9C,mDAA6D;AAa7D,SAAsB,oBAAoB,CACxC,SAAiB,EACjB,QAAmB,EACnB,YAA0B,EAC1B,SAAoB,EACpB,OAA8B;;QAE9B,MAAM,EAAE,WAAW,GAAG,KAAK,EAAE,YAAY,GAAG,eAAe,EAAE,GAAG,OAAO,CAAC;QACxE,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,IAAA,2BAAe,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE1F,MAAM,YAAY,GAAoB,MAAM,IAAA,0CAA0B,EAAC,YAAY,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAE1G,MAAM,EAAE,GAAG,IAAI,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,kBACjG,WAAW;YACX,YAAY,IACT,OAAO,EACV,CAAC;QAEH,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;QAEhB,OAAO,EAAE,CAAC;IACZ,CAAC;CAAA;AArBD,oDAqBC;AAED,MAAa,cAAc;IASzB,YACY,SAAiB,EACjB,QAAmB,EACnB,YAA0B,EAC1B,SAAoB,EACpB,SAAoC,EAC9C,eAA4C,EAClC,OAA8B;QAN9B,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAW;QACnB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,cAAS,GAAT,SAAS,CAAW;QACpB,cAAS,GAAT,SAAS,CAA2B;QAEpC,YAAO,GAAP,OAAO,CAAuB;QAExC,0B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EAAE;YACtB,OAAO,IAAI,CAAC,aAAa,CAAC;SAC3B;QAED,6CAA6C;QAC7C,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAChE,CAAC;IACM,sBAAsB,CAAC,UAAkB,EAAE,IAAY,EAAE,aAAyC;QACvG,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,OAAO,IAAI,CAAC,SAAS,CAAC;SACvB;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;IACM,sBAAsB,CAAC,UAAkB,EAAE,IAAY,EAAE,aAAyC;QACvG,IAAI,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE;YACtC,OAAO,IAAI,CAAC,eAAgB,CAAC;SAC9B;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;IAEY,YAAY,CAAC,IAAiB;;YACzC,gGAAgG;YAChG,IACE,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB;gBACnC,IAAI,CAAC,IAAI,KAAK,EAAE;gBAChB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EACxE;gBACA,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;aAC5B;QACH,CAAC;KAAA;CACF;AAvOD,wCAuOC","sourcesContent":["import * as path from \"path\";\r\n\r\nimport { ensureDir } from \"fs-extra\";\r\nimport { CompilerOptions, Project, SourceFile } from \"ts-morph\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport { EntityType } from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { ImportContainer } from \"../generator/ImportContainer\";\r\nimport { EmitModes } from \"../OptionModel\";\r\nimport { FileHandler } from \"./FileHandler\";\r\nimport { createFormatter } from \"./formatter\";\r\nimport { FileFormatter } from \"./formatter/FileFormatter\";\r\nimport { loadTsMorphCompilerOptions } from \"./TsMorphHelper\";\r\n\r\nexport interface ProjectManagerOptions {\r\n usePrettier?: boolean;\r\n tsConfigPath?: string;\r\n bundledFileGeneration?: boolean;\r\n /**\r\n * for testing purposes, turn this on and retrieve all generated files via getCachedFiles\r\n */\r\n noOutput?: boolean;\r\n allowTypeChecking?: boolean;\r\n}\r\n\r\nexport async function createProjectManager(\r\n outputDir: string,\r\n emitMode: EmitModes,\r\n namingHelper: NamingHelper,\r\n dataModel: DataModel,\r\n options: ProjectManagerOptions\r\n): Promise<ProjectManager> {\r\n const { usePrettier = false, tsConfigPath = \"tsconfig.json\" } = options;\r\n const formatter = usePrettier ? await createFormatter(outputDir, usePrettier) : undefined;\r\n\r\n const compilerOpts: CompilerOptions = await loadTsMorphCompilerOptions(tsConfigPath, emitMode, outputDir);\r\n\r\n const pm = new ProjectManager(outputDir, emitMode, namingHelper, dataModel, formatter, compilerOpts, {\r\n usePrettier,\r\n tsConfigPath,\r\n ...options,\r\n });\r\n\r\n await pm.init();\r\n\r\n return pm;\r\n}\r\n\r\nexport class ProjectManager {\r\n private project!: Project;\r\n\r\n private mainServiceFile: FileHandler | undefined;\r\n private mainModelFile: FileHandler | undefined;\r\n private mainQFile: FileHandler | undefined;\r\n\r\n private readonly cachedFiles: Map<string, SourceFile> | undefined;\r\n\r\n constructor(\r\n protected outputDir: string,\r\n protected emitMode: EmitModes,\r\n protected namingHelper: NamingHelper,\r\n protected dataModel: DataModel,\r\n protected formatter: FileFormatter | undefined,\r\n compilerOptions: CompilerOptions | undefined,\r\n protected options: ProjectManagerOptions\r\n ) {\r\n // Create ts-morph project\r\n this.project = new Project({\r\n // manipulationSettings: this.formatter.getSettings(),\r\n skipAddingFilesFromTsConfig: true,\r\n compilerOptions,\r\n });\r\n\r\n if (options.noOutput) {\r\n this.cachedFiles = new Map();\r\n }\r\n }\r\n\r\n public getDataModel() {\r\n return this.dataModel;\r\n }\r\n\r\n /**\r\n * Only filled when noOutput=true\r\n */\r\n public getCachedFiles() {\r\n return this.cachedFiles!;\r\n }\r\n\r\n private async writeFile(fileHandler: FileHandler) {\r\n if (this.options.noOutput) {\r\n await fileHandler.write(this.emitMode, true);\r\n this.cachedFiles!.set(fileHandler.getFullFilePath(), fileHandler.getFile());\r\n\r\n return;\r\n }\r\n\r\n return fileHandler.write(this.emitMode);\r\n }\r\n\r\n private createFile(\r\n name: string,\r\n reservedNames?: Array<string> | undefined,\r\n additionalPath: string = \"\",\r\n forceTypeChecking = false\r\n ): FileHandler {\r\n const fileName = path.join(this.outputDir, additionalPath, `${name}.ts`);\r\n const imports = new ImportContainer(\r\n additionalPath,\r\n name,\r\n this.dataModel,\r\n this.namingHelper.getFileNames(),\r\n !!this.options.bundledFileGeneration,\r\n reservedNames\r\n );\r\n\r\n return new FileHandler(\r\n additionalPath,\r\n name,\r\n this.project.createSourceFile(fileName),\r\n imports,\r\n this.formatter,\r\n forceTypeChecking || !!this.options.allowTypeChecking\r\n );\r\n }\r\n\r\n public async init() {\r\n if (!this.options.bundledFileGeneration) {\r\n // ensure folder for each model: we do this at this point for performance reasons\r\n await Promise.all(\r\n this.dataModel.getModelTypes().map((mt) => ensureDir(path.join(this.outputDir, mt.folderPath)))\r\n );\r\n }\r\n\r\n const typePart = this.emitMode.toUpperCase().replace(\"_\", \" & \");\r\n console.log(`Prepared to emit ${typePart} files.`);\r\n }\r\n\r\n public initModels() {\r\n if (this.options.bundledFileGeneration) {\r\n // collect reserved names, that is names of classes we're going to create => imports must take them into account\r\n const reservedWords = this.dataModel.getModelTypes().reduce<Array<string>>((collector, model) => {\r\n const asEntityType = model as EntityType;\r\n collector.push(model.modelName);\r\n if (asEntityType.editableName) {\r\n collector.push(asEntityType.editableName);\r\n }\r\n if (asEntityType.id?.modelName) {\r\n collector.push(asEntityType.id.modelName);\r\n }\r\n this.dataModel.getAllEntityOperations(model.fqName).forEach((op) => {\r\n if (op.parameters.length) {\r\n collector.push(op.paramsModelName);\r\n }\r\n });\r\n\r\n return collector;\r\n }, []);\r\n this.dataModel.getUnboundOperationTypes().forEach((op) => {\r\n if (op.parameters.length) {\r\n reservedWords.push(op.paramsModelName);\r\n }\r\n });\r\n\r\n this.mainModelFile = this.createFile(this.namingHelper.getFileNames().model, reservedWords);\r\n }\r\n }\r\n\r\n public async finalizeModels() {\r\n if (\r\n this.mainModelFile &&\r\n (this.options.bundledFileGeneration || this.mainModelFile.getFile().getFullText().length)\r\n ) {\r\n await this.writeFile(this.mainModelFile);\r\n }\r\n }\r\n\r\n public initQObjects() {\r\n if (this.options.bundledFileGeneration) {\r\n // collect reserved names, that is names of classes we're going to create => imports must take them into account\r\n const reservedWords = this.dataModel.getModelTypes().reduce<Array<string>>((collector, model) => {\r\n const asEntityType = model as EntityType;\r\n if (asEntityType.qName) {\r\n collector.push(asEntityType.qName, firstCharLowerCase(asEntityType.qName));\r\n }\r\n if (asEntityType.id?.qName) {\r\n collector.push(asEntityType.id.qName);\r\n }\r\n this.dataModel.getAllEntityOperations(model.fqName).forEach((op) => {\r\n collector.push(op.qName);\r\n });\r\n\r\n return collector;\r\n }, []);\r\n this.dataModel.getUnboundOperationTypes().forEach((op) => {\r\n reservedWords.push(op.qName);\r\n });\r\n\r\n this.mainQFile = this.createFile(this.namingHelper.getFileNames().qObject, reservedWords);\r\n }\r\n }\r\n\r\n public async finalizeQObjects() {\r\n if (this.mainQFile && (this.options.bundledFileGeneration || this.mainQFile.getFile().getFullText().length)) {\r\n await this.writeFile(this.mainQFile);\r\n }\r\n }\r\n\r\n public initServices() {\r\n const mainServiceName = this.namingHelper.getMainServiceName();\r\n const reservedNames = [mainServiceName];\r\n\r\n if (this.options.bundledFileGeneration) {\r\n [...this.dataModel.getEntityTypes(), ...this.dataModel.getComplexTypes()].reduce((collector, model) => {\r\n collector.push(model.serviceName, model.serviceCollectionName);\r\n return collector;\r\n }, reservedNames);\r\n }\r\n\r\n this.mainServiceFile = this.createFile(mainServiceName, reservedNames);\r\n }\r\n\r\n public async finalizeServices() {\r\n if (this.mainServiceFile) {\r\n await this.writeFile(this.mainServiceFile);\r\n }\r\n }\r\n\r\n public getMainServiceFile() {\r\n return this.mainServiceFile!;\r\n }\r\n\r\n public createOrGetMainModelFile(reservedNames?: Array<string>) {\r\n if (!this.mainModelFile) {\r\n this.mainModelFile = this.createFile(this.namingHelper.getFileNames().model, reservedNames, \"\", true);\r\n }\r\n return this.mainModelFile;\r\n }\r\n\r\n public createOrGetMainQObjectFile(reservedNames?: Array<string>) {\r\n if (!this.mainQFile) {\r\n this.mainQFile = this.createFile(this.namingHelper.getFileNames().qObject, reservedNames);\r\n }\r\n return this.mainQFile;\r\n }\r\n\r\n public createOrGetModelFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\r\n if (this.mainModelFile) {\r\n return this.mainModelFile;\r\n }\r\n\r\n // model files always allow for type checking\r\n return this.createFile(name, reservedNames, folderPath, true);\r\n }\r\n public createOrGetQObjectFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\r\n if (this.mainQFile) {\r\n return this.mainQFile;\r\n }\r\n\r\n return this.createFile(name, reservedNames, folderPath);\r\n }\r\n public createOrGetServiceFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\r\n if (this.options.bundledFileGeneration) {\r\n return this.mainServiceFile!;\r\n }\r\n\r\n return this.createFile(name, reservedNames, folderPath);\r\n }\r\n\r\n public async finalizeFile(file: FileHandler) {\r\n // write individual files in unbundled mode & if this is not one of the main files on root level\r\n if (\r\n !this.options.bundledFileGeneration &&\r\n file.path !== \"\" &&\r\n !Object.values(this.namingHelper.getFileNames()).includes(file.fileName)\r\n ) {\r\n await this.writeFile(file);\r\n }\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odata2ts/odata2ts",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -47,8 +47,8 @@
47
47
  "v4"
48
48
  ],
49
49
  "peerDependencies": {
50
- "@odata2ts/odata-query-objects": "^0.21.0",
51
- "@odata2ts/odata-service": "^0.19.0"
50
+ "@odata2ts/odata-query-objects": "^0.22.0",
51
+ "@odata2ts/odata-service": "^0.19.1"
52
52
  },
53
53
  "dependencies": {
54
54
  "@odata2ts/converter-api": "^0.1.2",
@@ -75,8 +75,8 @@
75
75
  },
76
76
  "devDependencies": {
77
77
  "@odata2ts/converter-v2-to-v4": "^0.1.4",
78
- "@odata2ts/odata-query-objects": "^0.21.0",
79
- "@odata2ts/odata-service": "^0.19.0",
78
+ "@odata2ts/odata-query-objects": "^0.22.0",
79
+ "@odata2ts/odata-service": "^0.19.1",
80
80
  "@odata2ts/test-converters": "^0.3.1",
81
81
  "@types/fs-extra": "^11.0.1",
82
82
  "@types/jest": "^29.5.2",
@@ -90,6 +90,6 @@
90
90
  "typescript": "^5.1.3"
91
91
  },
92
92
  "types": "./lib/index.d.ts",
93
- "gitHead": "9ae4af562769396e5b031b819042edb9d8cb4479",
93
+ "gitHead": "5df6ef0b40b3e5f886fdd0bc010ade9754667b45",
94
94
  "readme": "README.md"
95
95
  }