import { EntityBuilder } from './entity-builder'; import { Link, Field, Selectable, CustomField } from './selectable'; import { RequestBuilder } from './request-builder'; export declare type ODataVersionOf = T['_oDataVersion']; /** * @hidden */ export interface Constructable { _serviceName: string; _entityName: string; _defaultServicePath: string; _allFields: (Selectable | Field | Link)[]; _keyFields: (Selectable | Field)[]; _keys: { [keys: string]: Selectable | Field; }; new (...args: any[]): EntityT; requestBuilder(): RequestBuilder; builder(): EntityBuilderType; customField(fieldName: string, isNullable?: boolean): CustomField; } export declare type EntityBuilderType = { [property in keyof Required]: (value: EntityTypeT[property]) => EntityBuilderType; } & EntityBuilder; /** * Super class for all representations of OData entity types. */ export declare abstract class Entity { static _serviceName: string; static _entityName: string; static _defaultServicePath: string; protected static entityBuilder(entityConstructor: Constructable): EntityBuilderType; /** * The remote state of the entity. * Remote state refers to the last known state of the entity on the remote system from which it has been retrieved or to which it has been posted. * It is stored as map, where the keys are stored in the format of the original OData properties. */ protected remoteState: { [keys: string]: any; }; /** * The current ETag version of the entity in the remote system. * The ETag identified the version of the in the remote system. It will be automatically set in the "if-match" header of update requests and can be set as a custom header for delete requests. * When no ETag is provided by the remote system the value of this variable defaults to "*". */ protected _versionIdentifier: string; /** * A mapper representing custom fields in an entity. * Custom fields are represented by their field names and the corresponding values. * A custom field can be added or updated using [[setCustomField]] method. */ protected _customFields: Record; abstract readonly _oDataVersion: any; constructor(); /** * ETag version identifier accessor. * @returns The ETag version identifier of the retrieved entity, returns `undefined` if not retrieved. */ get versionIdentifier(): string; /** * Returns a map that contains all entity custom fields. * @returns A map of all defined custom fields in the entity */ getCustomFields(): Record; /** * Custom field value getter. * @param fieldName - The name of the custom field * @returns The value of the corresponding custom field */ getCustomField(fieldName: string): any; /** * Sets a new custom field in the entity or updates it. * Throws an error, if the provided custom field name is already defined by an original field in entity. * @param fieldName - The name of the custom field to update * @param value - The value of the field * @returns The entity itself, to facilitate method chaining */ setCustomField(fieldName: string, value: any): this; /** * Validates whether a custom field exists in the entity. * @param fieldName - The name of the custom field to update * @returns A boolean value, that indicates whether a custom field is defined in entity */ hasCustomField(fieldName: string): boolean; /** * Sets custom fields on an entity. * @param customFields - Custom fields to set on the entity. * @returns The entity itself, to facilitate method chaining */ setCustomFields(customFields: Record): this; /** * @deprecated Since v1.34.1. Use [[setCustomFields]] instead. * Sets all retrieved custom fields in entity. * @param customFields - Extracted custom fields from a retrieved entity. * @returns The entity itself, to facilitate method chaining. */ initializeCustomFields(customFields: Record): this; /** * Set the ETag version identifier of the retrieved entity. * @param etag - The returned ETag version of the entity. * @returns The entity itself, to facilitate method chaining. */ setVersionIdentifier(etag: string | undefined): this; /** * @deprecated Since 1.12.0. Will be hidden in version 2.0. * Initializes or sets the remoteState of the entity. * This function is called on all read, create and update requests. * This function should be called after [[initializeCustomFields]], if custom fields are defined. * @param state - State to be set as remote state. * @returns The entity itself, to facilitate method chaining */ setOrInitializeRemoteState(state?: Record): this; /** * Returns all updated custom field properties compared to the last known remote state. * @returns An object containing all updated custom properties, with their new values. */ getUpdatedCustomFields(): Record; /** * Returns all changed properties compared to the last known remote state. * The returned properties do not include custom fields. * Use [[getUpdatedCustomFields]], if you need custom fields. * @returns Entity with all properties that changed */ getUpdatedProperties(): Record; /** * Returns all changed property names compared to the last known remote state. * The returned properties names do not include custom fields. * Use [[getUpdatedCustomFields]], if you need custom fields. * @returns Entity with all properties that changed */ getUpdatedPropertyNames(): string[]; /** * @deprecated Since v1.34.1. Use [[asObject]] instead. * Returns a map of all defined fields in entity to their current values. * @param visitedEntities - List of entities to check in case of circular dependencies. * @returns Entity with all defined entity fields */ protected getCurrentMapKeys(visitedEntities?: Entity[]): any; protected isVisitedEntity(entity: EntityT, visitedEntities?: Entity[]): boolean; protected getCurrentStateForKey(key: string, visitedEntities?: Entity[]): any; /** * Validates whether a field name does not conflict with an original field name and thus can be defined as custom fields. * @param customFieldName - Field name to check * @returns Boolean value that describes whether a field name can be defined as custom field */ protected isConflictingCustomField(customFieldName: string): boolean; /** * Creates an object containing all defined properties, navigation properties and custom fields in the entity. * @param visitedEntities - List of entities to check in case of circular dependencies. * @returns Entity as an object with all defined entity fields */ protected asObject(visitedEntities?: Entity[]): Record; } /** * @hidden */ export interface EntityIdentifiable { readonly _entityConstructor: Constructable; readonly _entity: T; } /** * @hidden */ export declare function isSelectedProperty(json: any, field: Field | Link): boolean; /** * @hidden */ export declare function isExistentProperty(json: any, link: Link): boolean; /** * @hidden */ export declare function isExpandedProperty(json: any, link: Link): boolean; export { Entity as EntityBase }; //# sourceMappingURL=entity.d.ts.map