UNPKG

@sap-cloud-sdk/odata-common

Version:

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

29 lines (28 loc) 1.5 kB
import type { EntityBase } from './entity-base'; import type { ComplexTypeNamespace } from './selectable'; import type { DeSerializers } from './de-serializers'; import type { EntityApi } from './entity-api'; /** * Interface representing the return type of the builder function {@link entitySerializer}. */ export interface EntitySerializer { /** * Converts an instance of an entity class into a JSON payload to be sent to an OData service. */ serializeEntity: <EntityT extends EntityBase>(entity: EntityT, entityApi: EntityApi<EntityT, any>, diff?: boolean) => Record<string, any>; /** * Method to serialize a complex type to JSON. */ serializeComplexType: <ComplexTypeNamespaceT extends ComplexTypeNamespace<any> = any>(fieldValue: any, complexTypeNameSpace: ComplexTypeNamespaceT) => any; /** * Like {@link EntitySerializer#serializeEntity} ignoring custom fields. */ serializeEntityNonCustomFields: <EntityT extends EntityBase>(entity: EntityT, entityApi: EntityApi<EntityT, any>) => Record<string, any>; } /** * Constructs an entitySerializer given the OData v2 or v4 specific tsToEdm method. * The concrete serializers are created in odata/v2/entity-serializer.ts and odata/v4/entity-serializer.ts. * @param deSerializers - (De-)serializers used for transformation. * @returns A entity serializer as defined by {@link EntitySerializer}. */ export declare function entitySerializer(deSerializers: DeSerializers): EntitySerializer;