import { FindAndCountAllResponse } from '../interfaces/find-and-count-all-response.interface'; export function fetchAllResponse( response: FindAndCountAllResponse, responseClass: new (content: T, additionalParams?: AdditionalParams) => ResponseClass, additionalParamFunction?: (content: T) => AdditionalParams ): FetchAllResponse { const content = []; if (response.rows && response.rows.length > 0) { content.push( ...response.rows.map((row) => { const additionalParams: AdditionalParams = additionalParamFunction ? additionalParamFunction(row) : undefined; return new responseClass(row, additionalParams); }) ); } return { content, totalElements: response.count }; } export interface FetchAllResponse { content: T[]; totalElements: number; }