UNPKG

@sap-cloud-sdk/odata-common

Version:

SAP Cloud SDK for JavaScript common functions of OData client generator and OpenAPI clint generator.

79 lines (78 loc) 2.74 kB
import type { HttpResponse } from '@sap-cloud-sdk/http-client'; /** * Detects the system dependent line break in a string. * @param str - The string to check for line breaks. Should have at least two lines, otherwise an error will be thrown. * @returns The system dependent line break * @internal */ export declare function detectNewLineSymbol(str: string): string; /** * Get the response body from the string representation of a response. * @param response - String representation of a response. * @returns The response body as a one line string. * @internal */ export declare function getResponseBody(response: string): string; /** * Split a batch response into an array of sub responses for the retrieve requests and changesets. * @param response - The raw HTTP response. * @returns A list of sub responses represented as strings. * @internal */ export declare function splitBatchResponse(response: HttpResponse): string[]; /** * Split a changeset (sub) response into an array of sub responses. * @param changeSetResponse - The string representation of a change set response. * @returns A list of sub responses represented as strings. * @internal */ export declare function splitChangeSetResponse(changeSetResponse: string): string[]; /** * Split a string representation of a response into sub responses given its boundary. * @param response - The string representation of the response to split. * @param boundary - The boundary to split by. * @returns A list of sub responses represented as strings. * @internal */ export declare function splitResponse(response: string, boundary: string): string[]; /** * Parse the HTTP code of response. * @param response - String representation of the response. * @returns The HTTP code. * @internal */ export declare function parseHttpCode(response: string): number; /** * Parse the body and http code of a batch sub response. * @param response - A batch sub response. * @returns The parsed response.s * @internal */ export declare function parseResponseData(response: string): ResponseData; /** * Parse the complete batch HTTP response. * @param batchResponse - HTTP response of a batch request. * @returns An array of parsed sub responses of the batch response. * @internal */ export declare function parseBatchResponse(batchResponse: HttpResponse): (ResponseData | ResponseData[])[]; /** * Check if httpCode is in [200,300[ range. * @param httpCode - Code to be checked * @returns boolean * @internal */ export declare function isHttpSuccessCode(httpCode: number): boolean; /** * @internal */ export interface ResponseData { /** * @internal */ body: Record<string, any>; /** * @internal */ httpCode: number; }