Options
All
  • Public
  • Public/Protected
  • All
Menu

Super class for all representations of OData v4 entity types.

Hierarchy

Index

Constructors

Properties

_customFields: Record<string, any>

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.

_oDataVersion: "v4"
_versionIdentifier: string

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 "*".

remoteState: {}

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.

Type declaration

  • [keys: string]: any
_defaultServicePath: string
_entityName: string
_serviceName: string

Accessors

  • get versionIdentifier(): string
  • ETag version identifier accessor.

    Returns string

    The ETag version identifier of the retrieved entity, returns undefined if not retrieved.

Methods

  • asObject(visitedEntities?: EntityBase[]): Record<string, any>
  • Creates an object containing all defined properties, navigation properties and custom fields in the entity.

    Parameters

    • Optional visitedEntities: EntityBase[]

      List of entities to check in case of circular dependencies.

    Returns Record<string, any>

    Entity as an object with all defined entity fields

  • getCurrentMapKeys(visitedEntities?: EntityBase[]): any
  • deprecated

    Since v1.34.1. Use asObject instead. Returns a map of all defined fields in entity to their current values.

    Parameters

    • Optional visitedEntities: EntityBase[]

      List of entities to check in case of circular dependencies.

    Returns any

    Entity with all defined entity fields

  • getCurrentStateForKey(key: string, visitedEntities?: EntityBase[]): any
  • getCustomField(fieldName: string): any
  • Custom field value getter.

    Parameters

    • fieldName: string

      The name of the custom field

    Returns any

    The value of the corresponding custom field

  • getCustomFields(): Record<string, any>
  • Returns a map that contains all entity custom fields.

    Returns Record<string, any>

    A map of all defined custom fields in the entity

  • getUpdatedCustomFields(): Record<string, any>
  • Returns all updated custom field properties compared to the last known remote state.

    Returns Record<string, any>

    An object containing all updated custom properties, with their new values.

  • getUpdatedProperties(): Record<string, any>
  • 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 Record<string, any>

    Entity with all properties that changed

  • getUpdatedPropertyNames(): string[]
  • 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 string[]

    Entity with all properties that changed

  • hasCustomField(fieldName: string): boolean
  • Validates whether a custom field exists in the entity.

    Parameters

    • fieldName: string

      The name of the custom field to update

    Returns boolean

    A boolean value, that indicates whether a custom field is defined in entity

  • initializeCustomFields(customFields: Record<string, any>): EntityV4
  • deprecated

    Since v1.34.1. Use setCustomFields instead. Sets all retrieved custom fields in entity.

    Parameters

    • customFields: Record<string, any>

      Extracted custom fields from a retrieved entity.

    Returns EntityV4

    The entity itself, to facilitate method chaining.

  • isConflictingCustomField(customFieldName: string): boolean
  • Validates whether a field name does not conflict with an original field name and thus can be defined as custom fields.

    Parameters

    • customFieldName: string

      Field name to check

    Returns boolean

    Boolean value that describes whether a field name can be defined as custom field

  • isVisitedEntity<EntityT>(entity: EntityT, visitedEntities?: EntityBase[]): boolean
  • setCustomField(fieldName: string, value: any): EntityV4
  • 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.

    Parameters

    • fieldName: string

      The name of the custom field to update

    • value: any

      The value of the field

    Returns EntityV4

    The entity itself, to facilitate method chaining

  • setCustomFields(customFields: Record<string, any>): EntityV4
  • Sets custom fields on an entity.

    Parameters

    • customFields: Record<string, any>

      Custom fields to set on the entity.

    Returns EntityV4

    The entity itself, to facilitate method chaining

  • setOrInitializeRemoteState(state?: Record<string, any>): EntityV4
  • 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.

    Parameters

    • Optional state: Record<string, any>

      State to be set as remote state.

    Returns EntityV4

    The entity itself, to facilitate method chaining

  • setVersionIdentifier(etag: undefined | string): EntityV4
  • Set the ETag version identifier of the retrieved entity.

    Parameters

    • etag: undefined | string

      The returned ETag version of the entity.

    Returns EntityV4

    The entity itself, to facilitate method chaining.

    Copyright Ⓒ 2023 SAP SE or an SAP affiliate company. All rights reserved.

  • customFieldSelector<EntityT, NullableT>(fieldName: string, entityConstructor: Constructable<EntityT, unknown>, isNullable?: NullableT): CustomFieldV4<EntityT, NullableT>
  • Type parameters

    • EntityT: EntityV4<EntityT>

    • NullableT: boolean = false

    Parameters

    • fieldName: string
    • entityConstructor: Constructable<EntityT, unknown>
    • Optional isNullable: NullableT

    Returns CustomFieldV4<EntityT, NullableT>

  • entityBuilder<EntityT, EntityTypeT>(entityConstructor: Constructable<EntityT, EntityTypeT>): EntityBuilderType<EntityT, EntityTypeT>
  • Type parameters

    Parameters

    • entityConstructor: Constructable<EntityT, EntityTypeT>

    Returns EntityBuilderType<EntityT, EntityTypeT>