import { VdmActionImport , VdmFunctionImport } from '../vdm-types' ; import { isEntityNotDeserializable } from '../edmx-to-vdm/common' ; function actionFunctionImportReturnType ( actionOrFunctionImport , requestBuilderName ) { let type = actionOrFunctionImport . returnType . returnType ; const returnType = actionOrFunctionImport . returnType ; if ( isEntityNotDeserializable ( returnType ) ) { type = wrapRequestBuilderAroundType ( requestBuilderName , actionOrFunctionImport . parametersTypeName , type ) ; type = `Omit<${ type }, 'execute'>` ; return type ; } if ( returnType . isCollection ) { type = `${ type }[]` ; } if ( returnType . isNullable ) { type = `${ type } | null` ; } type = wrapRequestBuilderAroundType ( requestBuilderName , actionOrFunctionImport . parametersTypeName , type ) ; return type ; } function wrapRequestBuilderAroundType ( requestBuilderName , parameterName , type ) { return `${ requestBuilderName }<DeSerializersT, ${ parameterName }<DeSerializersT>, ${ type }>` ; } internal export function actionImportReturnType ( actionImport ) { return actionFunctionImportReturnType ( actionImport , 'ActionImportRequestBuilder' ) ; } internal export function functionImportReturnType ( actionImport ) { return actionFunctionImportReturnType ( actionImport , 'FunctionImportRequestBuilder' ) ; }