@sap-cloud-sdk/odata-common
Version:
SAP Cloud SDK for JavaScript common functions of OData client generator and OpenAPI clint generator.
43 lines (42 loc) • 2.21 kB
TypeScript
import type { DeSerializers } from './de-serializers';
import type { EntityBase } from './entity-base';
import type { ComplexTypeNamespace } from './selectable';
import type { EntityApi } from './entity-api';
/**
* Interface representing the return type of the builder function {@link entityDeserializer}.
*/
export interface EntityDeserializer {
/**
* Method to deserialize the full entity from JSON to an entity object.
*/
deserializeEntity: <EntityT extends EntityBase = EntityBase>(json: any, entityApi: EntityApi<EntityT, any>, requestHeader?: any) => EntityT;
/**
* Method to deserialize the full entity from JSON to the complex type property.
*/
deserializeComplexType: (json: Record<string, any>, complexType: ComplexTypeNamespace<any>) => any;
}
/**
* Constructs an entityDeserializer given the OData v2 or v4 specific methods.
* The concrete deserializers are created in odata/v2/entity-deserializer.ts and odata/v4/entity-deserializer.ts.
* @param deSerializers - (De-)serializers used for transformation.
* @param extractODataETag - Extractor for the ETag.
* @param extractDataFromOneToManyLink - Extractor for data related to one to many links.
* @returns An entity deserializer as defined by {@link EntityDeserializer}.
*/
export declare function entityDeserializer<T extends DeSerializers>(deSerializers: T, extractODataETag: (json: Record<string, any>) => string | undefined, extractDataFromOneToManyLink: (data: any) => any[]): EntityDeserializer;
/**
* Extract eTag from custom header ignoring case.
* @param headers - Headers from which the etag is extracted.
* @returns string | undefined
* @internal
*/
export declare function extractEtagFromHeader(headers: any): string | undefined;
/**
* Extracts all custom fields from the JSON payload for a single entity.
* In this context, a custom fields is every property that is not known in the corresponding entity class.
* @param json - The JSON payload.
* @param schema - TODO
* @returns An object containing the custom fields as key-value pairs.
* @internal
*/
export declare function extractCustomFields<JsonT>(json: Partial<JsonT>, schema: Record<string, any>): Record<string, any>;