Options
All
  • Public
  • Public/Protected
  • All
Menu

SAP Cloud SDK for JavaScript Logo

@sap-cloud-sdk/core

This package contains the core functionality of the SAP Cloud SDK as well as the Cloud Platform abstractions.

Installation

$ npm install @sap-cloud-sdk/core

Usage

The core is the heart of the SAP Cloud SDK and contains the functionality that is essential to every project powered by the SDK. Any OData client built by the SAP Cloud SDK, be it the VDM or clients built by the generator are using the core. We recommend to install this in addition to your clients.

Below is an example showing how you can build and execute your request with multiple filters by using an function called and.

import { and } from '@sap-cloud-sdk/core';
import { BusinessPartner } from '@sap/cloud-sdk-vdm-business-partner-service';

// Build your filters
const firstNameFilter = BusinessPartner.FIRST_NAME.equals('firstName');
const lastNameFilter = BusinessPartner.LAST_NAME.equals('lastName');

// Execute your request with two filters
BusinessPartner.requestBuilder()
.getAll()
.filter(and(firstNameFilter, lastNameFilter))
.execute(yourDestination);

For more detailed overview visit our OData client documentation.

Support

The recommended way to get in touch with us is to create an issue in our github repository. Select the issue category Bug, Feature or Question depending on the nature of your request. We try to provide fixes, features and answers as soon as possible.

We also monitor questions on StackOverflow and ansers.sap.com but prefer issues on github.

Contribute

If you would like to contribute to the SAP Cloud SDK, please make yourself familiar with our contributing guidelines and follow the given instructions.

Links



License

The SAP Cloud SDK is released under the Apache License Version 2.0.

Index

References

Namespaces

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

References

ActionFunctionImportRequestBuilderBase

Renames and re-exports ActionFunctionImportRequestBuilder

ActionImportParameter

Renames and re-exports FunctionImportParameter

ActionImportParameters

Renames and re-exports FunctionImportParameters

CreateRequestBuilderV2

Renames and re-exports CreateRequestBuilder

CustomFieldV2

Renames and re-exports CustomField

DeleteRequestBuilderV2

Renames and re-exports DeleteRequestBuilder

EdmToPrimitiveV2

Renames and re-exports EdmToPrimitive

EdmTypeV2

Renames and re-exports EdmType

EntityV2

Renames and re-exports Entity

FunctionImportRequestBuilderV2

Renames and re-exports FunctionImportRequestBuilder

GetAllRequestBuilderV2

Renames and re-exports GetAllRequestBuilder

GetByKeyRequestBuilderV2

Renames and re-exports GetByKeyRequestBuilder

MethodRequestBuilderBase

Renames and re-exports MethodRequestBuilder

ODataBatchChangeSetV2

Renames and re-exports ODataBatchChangeSet

ODataBatchRequestBuilderV2

Renames and re-exports ODataBatchRequestBuilder

ODataFunctionImportRequestConfigV2

Renames and re-exports ODataFunctionImportRequestConfig

UpdateRequestBuilderV2

Renames and re-exports UpdateRequestBuilder

deserializeComplexTypeV2

Renames and re-exports deserializeComplexType

deserializeEntityV2

Renames and re-exports deserializeEntity

entitySerializerV2

Renames and re-exports entitySerializer

extractODataEtagV2

Renames and re-exports extractODataEtag

getExpandV2

Renames and re-exports getExpand

getSelectV2

Renames and re-exports getSelect

oDataUriV2

Renames and re-exports oDataUri

responseDataAccessorV4

Renames and re-exports responseDataAccessor

serializeComplexTypeV2

Renames and re-exports serializeEntity

serializeEntityNonCustomFieldsV2

Renames and re-exports serializeEntityNonCustomFields

serializeEntityV2

Renames and re-exports serializeEntity

toBatchChangeSetV2

Renames and re-exports toBatchChangeSet

toBatchRetrieveBodyV2

Renames and re-exports toBatchRetrieveBody

Type aliases

AuthenticationType

AuthenticationType: "PrincipalPropagation" | "NoAuthentication" | "BasicAuthentication" | "OAuth2SAMLBearerAssertion" | "OAuth2ClientCredentials" | "OAuth2UserTokenExchange" | "ClientCertificateAuthentication" | "OAuth2JWTBearer" | "OAuth2Password"

BatchResponse

CollectionFieldType

CollectionFieldType<CollectionFieldT>: CollectionFieldT | ComplexTypeNamespace<CollectionFieldT>

Convenience type to reflect the type of the instances of a collection field. The actual type of the elements for complex type collections is ComplexTypeNamespace.

typeparam CollectionFieldT

Type of of elements of the collection. This can either be an EDM type or complex type.

Type parameters

ConstructorOrField

ConstructorOrField<EntityT, ComplexT>: Constructable<EntityT> | ComplexTypeField<EntityT, ComplexT, boolean, boolean>

Union type to represent the parent of a field. This can either be an entity constructor or a complex type field.

Type parameters

DeepFieldType

DeepFieldType: FieldType | {}
deprecated

Since v1.18.0. Use FieldType instead. Represents types of nested fields.

DestinationOptions

DestinationProxyType

DestinationProxyType: "OnPremise" | "Internet" | null

DestinationRetrievalOptions

Options to use while fetching destinations. Encompasses both DestinationCachingOptions and ResilienceOptions interfaces.

DestinationSelectionStrategy

DestinationSelectionStrategy: (allDestinations: AllDestinations, destinationName: string) => Destination | null

Type declaration

    • (allDestinations: AllDestinations, destinationName: string): Destination | null
    • Parameters

      • allDestinations: AllDestinations
      • destinationName: string

      Returns Destination | null

DestinationServiceCredentials

DestinationServiceCredentials: ServiceCredentials & { identityzone: string; instanceid: string; tenantid: string; tenantmode: string; uaadomain: string; uri: string; url: string; verificationkey: string; xsappname: string }

Credentials for the Destination service.

EdmToPrimitive

EdmToPrimitive<T>: T extends "Edm.Int16" | "Edm.Int32" | "Edm.Single" | "Edm.Double" | "Edm.Float" | "Edm.Byte" | "Edm.SByte" ? number : T extends "Edm.Decimal" | "Edm.Int64" ? BigNumber : T extends "Edm.DateTime" | "Edm.DateTimeOffset" ? moment.Moment : T extends "Edm.String" | "Edm.Guid" ? string : T extends "Edm.Boolean" ? boolean : T extends "Edm.Time" ? Time : any

Type parameters

EdmToPrimitiveV4

EdmToPrimitiveV4<T>: T extends "Edm.Int16" | "Edm.Int32" | "Edm.Single" | "Edm.Double" | "Edm.Float" | "Edm.Byte" | "Edm.SByte" ? number : T extends "Edm.Decimal" | "Edm.Int64" ? BigNumber : T extends "Edm.DateTime" | "Edm.DateTimeOffset" ? moment.Moment : T extends "Edm.String" | "Edm.Guid" ? string : T extends "Edm.Boolean" ? boolean : T extends "Edm.Time" ? Time : any

Type parameters

EdmType

Allowed Edm types for OData v2.

EdmTypeCommon

EdmTypeDifferentConverters

EdmTypeDifferentConverters: "Edm.DateTimeOffset"

EdmTypeForEdmOrFieldType

EdmTypeForEdmOrFieldType<EdmOrFieldT>: EdmOrFieldT extends EdmTypeShared<"any"> ? EdmOrFieldT : EdmTypeShared<"any">

Convenience type to support legacy EdmTypeField with field type as generic parameter. This will become obsolete in the next major version update.

Type parameters

EdmTypeSameConverters

EdmTypeSameConverters: "Edm.String" | "Edm.Boolean" | "Edm.Decimal" | "Edm.Double" | "Edm.Single" | "Edm.Float" | "Edm.Int16" | "Edm.Int32" | "Edm.Int64" | "Edm.SByte" | "Edm.Binary" | "Edm.Guid" | "Edm.Byte" | "Edm.Any"

EdmTypeSameConvertersUri

EdmTypeSameConvertersUri: Exclude<EdmTypeSameConverters, "Edm.Guid" | "Edm.Decimal">

EdmTypeShared

Type parameters

EdmTypeV4

Allowed Edm types for OData v4.

EntityBuilderType

EntityBuilderType<EntityT, EntityTypeT>: { [ property in keyof Required<EntityTypeT>]: (value: EntityTypeT[property]) => EntityBuilderType<EntityT, EntityTypeT> } & EntityBuilder<EntityT, EntityTypeT>

Type parameters

EnumType

EnumType<T>: `${T}`

Convenient type to reflect all the values of a string based enum as a union type.

typeparam T

String based enum type

see

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-1.html#template-literal-types

Type parameters

  • T: string

ExclusiveEdmTypeV2

ExclusiveEdmTypeV2: "Edm.DateTime" | "Edm.Time"

ExclusiveEdmTypeV4

ExclusiveEdmTypeV4: "Edm.Date" | "Edm.Duration" | "Edm.TimeOfDay" | "Edm.Enum"

ExecuteHttpRequestFn

ExecuteHttpRequestFn<ReturnT>: (request: HttpRequest) => Promise<ReturnT>

Type parameters

  • ReturnT

Type declaration

Expandable

Expandable<EntityT>: ODataVersionOf<EntityT> extends "v2" ? never : OneToOneLink<EntityT, any> | OneToManyLink<EntityT, any> | AllFields<EntityT>

Represents all expandables, i.e. everything that can be used in an .expand statement. Only relevant for OData v4 requests.

typeparam EntityT

Type of the entity to be selected on

Type parameters

FieldType

FieldType: string | number | boolean | Time | moment.Moment | moment.Duration | BigNumber | null | undefined

Union type to represent all possible types of a field.

FieldTypeByEdmType

FieldTypeByEdmType<EdmOrFieldT, NullableT>: NullableFieldType<EdmOrFieldT extends EdmTypeShared<"any"> ? NonNullableFieldTypeByEdmType<EdmOrFieldT> : EdmOrFieldT, NullableT>

Convenience type that maps the given EDM type to a FieldType. It also considers whether the field is nullable.

typeparam EdmOrFieldT

EDM type of the field. Deprecated: Field type of the field.

typeparam NullableT

Boolean type that represents whether the field is nullable.

Type parameters

FilterFunctionParameterType

FilterFunctionParameterType<EntityT>: FilterFunctionPrimitiveParameterType | Field<EntityT, boolean, boolean> | FilterFunction<EntityT, FieldType | FieldType[]> | FilterFunctionPrimitiveParameterType[]

Type of a parameter of a filter function. This can either be a primitive type, a reference to a field or another filter function.

Type parameters

FilterFunctionPrimitiveParameterType

FilterFunctionPrimitiveParameterType: number | string | moment.Moment

Primitive type of a parameter of a filter function.

FilterFunctionReturnType

FilterFunctionReturnType: "boolean" | "int" | "double" | "decimal" | "string"

FilterFunctionReturnTypeV4

FilterFunctionReturnTypeV4: FilterFunctionReturnType | CollectionReturnType | "datetimeoffset"

FilterLambdaOperator

FilterLambdaOperator: "any" | "all"

hidden

FilterOperator

FilterOperator: FilterOperatorString | FilterOperatorBoolean | FilterOperatorNumber

FilterOperatorByType

FilterOperatorByType<FieldT>: FieldT extends string ? FilterOperatorString : FieldT extends number ? FilterOperatorNumber : FilterOperatorBoolean

Type parameters

Filterable

Filterable<EntityT, LinkedEntityT>: Filter<EntityT, FieldType | FieldType[]> | FilterLink<EntityT> | FilterList<EntityT> | FilterLambdaExpression<EntityT> | UnaryFilter<EntityT> | BooleanFilterFunction<EntityT> | OneToManyLink<EntityT, LinkedEntityT>

A union of all types that can be used for filtering.

typeparam EntityT

Type of the entity to be filtered on

Type parameters

FunctionImportParameters

FunctionImportParameters<ParametersT>: { [ K in keyof ParametersT]: FunctionImportParameter<ParametersT[K]> }

Internal representation of all parameters of a function import as a map

typeparam ParametersT

External representation of all parameters

Type parameters

  • ParametersT

HttpRequest

IsOrderableField

IsOrderableField<EdmT>: EdmT extends OrderableEdmType ? true : false

Convenience type to determine whether a field should be orderable. If the given EdmT is of type OrderableEdmTypes, it is orderable.

typeparam EdmT

EDM type of the field.

Type parameters

IsSelectableField

IsSelectableField<FieldOfT>: FieldOfT extends Constructable<any> ? true : false

Convenience type to determine whether a field should be selectable. If the given FieldOfT is the type of an entity, it is selectable.

typeparam FieldOfT

Type of the entity or complex type field this field belongs to.

Type parameters

JwtKeyMapping

JwtKeyMapping<InterfaceT, JwtKeysT>: { [ key in keyof InterfaceT]: { keyInJwt: JwtKeysT extends string ? JwtKeysT : keyof JwtKeysT; extractorFunction: any } }

Type parameters

  • InterfaceT

  • JwtKeysT

Method

Method: "get" | "GET" | "delete" | "DELETE" | "head" | "HEAD" | "options" | "OPTIONS" | "post" | "POST" | "put" | "PUT" | "patch" | "PATCH"

HTTP Methods supported by the http-client.

ODataVersionOf

ODataVersionOf<T>: T["_oDataVersion"]

Type parameters

Orderable

Orderable<EntityT>: Order<EntityT> | OrderLink<EntityT, EntityBase>

A union of all types that can be used for ordering.

typeparam EntityT

Type of the entity to be ordered

Type parameters

OrderableEdmType

OrderableEdmType: "Edm.Decimal" | "Edm.Double" | "Edm.Single" | "Edm.Float" | "Edm.Int16" | "Edm.Int32" | "Edm.Int64" | "Edm.SByte" | "Edm.Byte" | "Edm.DateTime" | "Edm.DateTimeOffset" | "Edm.Time" | "Edm.Date" | "Edm.Duration" | "Edm.TimeOfDay"

EDM types that can be compared with greaterThan, greaterOrEqual, lessThan and lessOrEqual.

OrderableInput

OrderableInput<EntityT>: SimpleTypeFields<EntityT> | Link<EntityT, EntityBase> | ComplexTypePropertyFields<EntityT, any>

A union of all types that can be used as input for ordering.

typeparam EntityT

Type of the entity to be ordered

Type parameters

RegisteredJWTClaims

deprecated

Since v1.46.0. This interface will not be replaced. Use the higher level JWT types directly. Interface to represent the registered claims of a JWT.

RequestMethodType

RequestMethodType: "get" | "post" | "patch" | "delete" | "put"

Selectable

Selectable<EntityT>: ODataVersionOf<EntityT> extends "v2" ? SimpleTypeFields<EntityT> | Link<EntityT> | ComplexTypeField<EntityT, any, boolean, boolean> | CustomField<EntityT, boolean> | CollectionField<EntityT, any, boolean, boolean> | AllFields<EntityT> : ODataVersionOf<EntityT> extends "v4" ? SimpleTypeFields<EntityT> | ComplexTypeField<EntityT, any, boolean, boolean> | CustomField<EntityT, boolean> | CollectionField<EntityT, any, boolean, boolean> | AllFields<EntityT> : never

Type parameters

ServiceCredentials

ServiceCredentials: { clientid: string } & ({ clientsecret: string } | { certificate: string; key: string })

Unspecific representation of a service's credentials as read from VCAP_SERVICES (for Cloud Foundry) or mounted secrets (for K8S).

XsuaaServiceCredentials

XsuaaServiceCredentials: ServiceCredentials & { identityzone: string; identityzoneid: string; sburl: string; tenantid: string; tenantmode: string; uaadomain: string; url: string; verificationkey: string; xsappname: string }

Credentials for the XSUAA service.

Variables

DestinationSelectionStrategies

DestinationSelectionStrategies: { alwaysProvider: typeof alwaysProvider; alwaysSubscriber: typeof alwaysSubscriber; subscriberFirst: typeof subscriberFirst }

Selector of destination selection strategies. See alwaysProvider, alwaysSubscriber and subscriberFirst for more information available selection strategies.

Type declaration

EnvironmentAccessor

EnvironmentAccessor: { getDestinationBasicCredentials: typeof getDestinationBasicCredentials; getDestinationServiceCredentials: typeof getDestinationServiceCredentials; getDestinationServiceCredentialsList: typeof getDestinationServiceCredentialsList; getDestinationServiceUri: typeof getDestinationServiceUri; getEnvironmentVariable: typeof getEnvironmentVariable; getServiceCredentialsList: typeof getServiceCredentialsList; getServiceList: typeof getServiceList; getVcapService: typeof getVcapService; getXsuaaServiceCredentials: typeof getXsuaaServiceCredentials }
deprecated

Since v1.5.0. Use directly exported functions instead

Type declaration

circuitBreakerDefaultOptions

circuitBreakerDefaultOptions: { errorThresholdPercentage: number; resetTimeout: number; timeout: number; volumeThreshold: number }

Type declaration

  • errorThresholdPercentage: number
  • resetTimeout: number
  • timeout: number
  • volumeThreshold: number

clientCredentialsTokenCache

clientCredentialsTokenCache: { cacheRetrievedToken: any; clear: any; getCacheInstance: any; getGrantTokenFromCache: any }

Type declaration

  • cacheRetrievedToken:function
    • cacheRetrievedToken(url: any, credentialsOrClientId: string | ClientCredentials, token: ClientCredentialsResponse): void
    • Parameters

      • url: any
      • credentialsOrClientId: string | ClientCredentials
      • token: ClientCredentialsResponse

      Returns void

  • clear:function
    • clear(): void
    • Returns void

  • getCacheInstance:function
    • getCacheInstance(): Cache<ClientCredentialsResponse>
    • Returns Cache<ClientCredentialsResponse>

  • getGrantTokenFromCache:function
    • getGrantTokenFromCache(url: any, credentialsOrClientId: string | ClientCredentials): undefined | ClientCredentialsResponse
    • Parameters

      Returns undefined | ClientCredentialsResponse

content_transfer_encoding_line

content_transfer_encoding_line: "Content-Transfer-Encoding: binary" = "Content-Transfer-Encoding: binary"
deprecated

Since v1.30.0.

defaultDisallowedKeys

defaultDisallowedKeys: string[]

A list of request config keys that are not allowed to be customized by default.

deserializersCommon

deserializersCommon: EdmTypeMapping

destinationCache

destinationCache: { cacheRetrievedDestination: any; cacheRetrievedDestinations: any; clear: any; getCacheInstance: any; retrieveDestinationFromCache: any }

Type declaration

  • cacheRetrievedDestination:function
    • Parameters

      Returns void

  • cacheRetrievedDestinations:function
    • cacheRetrievedDestinations(decodedJwt: Record<string, any>, retrievedDestinations: DestinationsByType, isolation: IsolationStrategy): void
    • Parameters

      • decodedJwt: Record<string, any>
      • retrievedDestinations: DestinationsByType
      • isolation: IsolationStrategy

      Returns void

  • clear:function
    • clear(): void
    • Returns void

  • getCacheInstance:function
    • Returns Cache<Destination>

  • retrieveDestinationFromCache:function
    • Parameters

      Returns undefined | Destination

destinationServiceCache

destinationServiceCache: { cacheRetrievedDestinations: any; clear: any; getCacheInstance: any; retrieveDestinationsFromCache: any }

Type declaration

  • cacheRetrievedDestinations:function
    • cacheRetrievedDestinations(destinationServiceUri: string, decodedJwt: JwtPayload, destinations: Destination[], isolationStrategy?: IsolationStrategy): void
    • Parameters

      Returns void

  • clear:function
    • clear(): void
    • Returns void

  • getCacheInstance:function
    • Returns Cache<Destination[]>

  • retrieveDestinationsFromCache:function
    • Parameters

      Returns undefined | Destination[]

entityDeserializerV2

entityDeserializerV2: EntityDeserializer

Entity deserializer instance for v2 entities. See EntityDeserializer for the provided methods.

entityDeserializerV4

entityDeserializerV4: EntityDeserializer

Entity deserializer instance for v4 entities. See EntityDeserializer for the provided methods.

entitySerializer

entitySerializer: EntitySerializer

Entity serializer instance for v2 entities. See EntitySerializer for the provided methods.

entitySerializerV4

entitySerializerV4: EntitySerializer

Entity serializer instance for v4 entities. See EntitySerializer for the provided methods.

filterFunctions

filterFunctions: { ceiling: ceiling; concat: concat; day: day; endsWith: endsWith; floor: floor; hour: hour; indexOf: indexOf; isOf: isOf; length: length; minute: minute; month: month; replace: typeof replace; round: round; second: second; startsWith: startsWith; substring: substring; substringOf: typeof substringOf; toLower: toLower; toUpper: toUpper; trim: trim; year: year }

OData v2 specific filter functions

Type declaration

  • ceiling: ceiling
  • concat: concat
  • day: day
  • endsWith: endsWith
  • floor: floor
  • hour: hour
  • indexOf: indexOf
  • isOf: isOf
  • length: length
  • minute: minute
  • month: month
  • replace: typeof replace
  • round: round
  • second: second
  • startsWith: startsWith
  • substring: substring
  • substringOf: typeof substringOf
  • toLower: toLower
  • toUpper: toUpper
  • trim: trim
  • year: year

filterFunctionsV4

filterFunctionsV4: { ceiling: ceiling; concat: concat; contains: typeof contains; day: day; endsWith: endsWith; floor: floor; fractionalSeconds: typeof fractionalSeconds; hasSubsequence: typeof hasSubsequence; hasSubset: typeof hasSubset; hour: hour; indexOf: indexOf; isOf: isOf; length: length; matchesPattern: typeof matchesPattern; maxDateTime: typeof maxDateTime; minDateTime: typeof minDateTime; minute: minute; month: month; now: typeof now; round: round; second: second; startsWith: startsWith; substring: substring; toLower: toLower; toUpper: toUpper; totalOffsetMinutes: typeof totalOffsetMinutes; trim: trim; year: year }

OData v4 specific filter functions

Type declaration

  • ceiling: ceiling
  • concat: concat
  • contains: typeof contains
  • day: day
  • endsWith: endsWith
  • floor: floor
  • fractionalSeconds: typeof fractionalSeconds
  • hasSubsequence: typeof hasSubsequence
  • hasSubset: typeof hasSubset
  • hour: hour
  • indexOf: indexOf
  • isOf: isOf
  • length: length
  • matchesPattern: typeof matchesPattern
  • maxDateTime: typeof maxDateTime
  • minDateTime: typeof minDateTime
  • minute: minute
  • month: month
  • now: typeof now
  • round: round
  • second: second
  • startsWith: startsWith
  • substring: substring
  • toLower: toLower
  • toUpper: toUpper
  • totalOffsetMinutes: typeof totalOffsetMinutes
  • trim: trim
  • year: year

http_version

http_version: "HTTP/1.1" = "HTTP/1.1"
deprecated

Since v1.30.0.

mappingTenantFields

mappingTenantFields: JwtKeyMapping<Tenant, "zid" | "zdn">

Mapping between key name in the Tenant and key name in decoded JWT.

mappingUserFields

mappingUserFields: JwtKeyMapping<UserData, "user_id" | "user_name" | "given_name" | "family_name" | "email" | "scope" | "xs.user.attributes">

Mapping between key name in the User and key name in decoded JWT and the

numberReturnTypeMapping

numberReturnTypeMapping: Record<string, "Edm.Int32" | "Edm.Double" | "Edm.Decimal">

oDataUri

oDataUri: ODataUri

Instance of the ODataUri conversion interface for OData v2.

oDataUriV4

oDataUriV4: ODataUri

Instance of the ODataUri conversion interface for OData v4.

part_content_type_line

part_content_type_line: "Content-Type: application/http" = "Content-Type: application/http"
deprecated

Since v1.30.0.

responseDataAccessor

responseDataAccessor: ResponseDataAccessor

serializersCommom

serializersCommom: EdmTypeMapping
deprecated

Since v1.27.0. Use serializersCommon instead.

serializersCommon

serializersCommon: EdmTypeMapping

verificationKeyCache

verificationKeyCache: Cache<TokenKey>

Functions

addAuthorizationHeader

  • addAuthorizationHeader<RequestT>(request: ODataRequest<RequestT>, headers: Record<string, string>): Promise<Record<string, string>>
  • deprecated

    Since v1.20.0. Use buildAuthorizationHeaders instead. Adds authorization headers for a given ODataRequest to existing headers.

    Type parameters

    • RequestT: ODataRequestConfig<RequestT>

    Parameters

    • request: ODataRequest<RequestT>

      an ODataRequest.

    • headers: Record<string, string>

      The headers that should be added to.

    Returns Promise<Record<string, string>>

    The provided headers with the new authorization headers.

addDestinationToRequestConfig

  • Builds a DestinationHttpRequestConfig for the given destination and then merges it into the given request configuration. Setting of the given request configuration take precedence over any destination related configuration.

    Type parameters

    Parameters

    Returns Promise<T & DestinationHttpRequestConfig>

    The given request config merged with the config built for the given destination.

addProxyConfiguration

  • Given a destination and a JWT (required for subscriber destinations), this function will add a proxy configuration to a destination. See also ProxyConfiguration.

    This function will reject if no connectivity service is bound, no XSUAA service with plan application is bound or the client credentials grant with the XSUAA service fails.

    deprecated

    Since v1.16.0. Use addProxyConfigurationOnPrem instead.

    Parameters

    • destination: Destination

      The destination to which the proxy configuration should be added.

    • Optional jwt: string

      The JWT of the current user.

    Returns Promise<Destination>

    A promise resolving to the destination with the added proxy configuration.

addProxyConfigurationInternet

  • addProxyConfigurationInternet(destination: any): Destination
  • Adds the proxy configuration to a destination based on web proxies defined in environment variables. See ProxyConfiguration and proxyStrategy for details.

    Parameters

    • destination: any

      to which the proxy configuration is added.

    Returns Destination

    Destination containing the configuration for web proxy.

addProxyConfigurationOnPrem

  • Parameters

    Returns Promise<Destination>

all

  • Will return the entity if all elements of the one-to-many link relation fulfill the condition.

    Type parameters

    Parameters

    • Rest ...filters: Filterable<EntityT, LinkedEntityT>[]

      A filter condition like MyEntity.someMultiLink.someProperty.eq('value')

    Returns FilterLambdaExpression<EntityT>

    The lambda filter function to be considered in the query

alwaysProvider

  • alwaysProvider(allDestinations: AllDestinations, destinationName: string): Destination | null
  • Constraints the selection to provider destinations.

    Parameters

    • allDestinations: AllDestinations

      Retrieved destinations.

    • destinationName: string

      Name of the destination to retrieve.

    Returns Destination | null

    the destination to retrieve, returns null, if no matched provider destination is found.

alwaysSubscriber

  • alwaysSubscriber(allDestinations: AllDestinations, destinationName: string): Destination | null
  • Constraints the selection to subscriber destinations.

    Parameters

    • allDestinations: AllDestinations

      Retrieved destinations.

    • destinationName: string

      Name of the destination to retrieve.

    Returns Destination | null

    the destination to retrieve, returns null, if no matched subscriber destination is found.

and

  • Combine Filterables with logical and to create a FilterList.

    Example:

    Entity.requestBuilder()
    .getAll()
    .filter(and(filterExp1, filterExp2));

    Note that the GetAllRequestBuilderV2.filter and GetAllRequestBuilderV4.filter method take a rest parameter and thereby an array of filter expressions that are then combined conjunctively. As a consequence following is equivalent to the example above:

    Entity.requestBuilder()
    .getAll()
    .filter(filterExp1, filterExp2);

    Type parameters

    • EntityT: EntityBase<EntityT>

      Type of the entity filter on.

    Parameters

    • expressions: Filterable<EntityT, any>[]

      Filterables to be combined with logical and.

    Returns FilterList<EntityT>

    The newly created FilterList.

  • Type parameters

    Parameters

    Returns FilterList<EntityT>

any

  • Will return the entity if at least one element of the one-to-many link relation fulfills the condition.

    Type parameters

    Parameters

    • Rest ...filters: Filterable<EntityT, LinkedEntityT>[]

      A filter condition like MyEntity.someMultiLink.someProperty.eq('value')

    Returns FilterLambdaExpression<EntityT>

    The lambda filter function to be considered in the query

asc

  • Create new Order by orderBy._fieldName in ascending order.

    Type parameters

    • EntityT: EntityBase<EntityT>

      Type of the entity to be ordered

    Parameters

    Returns Order<EntityT>

    New order

audiences

  • audiences(decodedToken: JwtPayload): Set<string>
  • Retrieve the audiences of a decoded JWT based on the audiences and scopes in the token.

    Parameters

    • decodedToken: JwtPayload

      Token to retrieve the audiences from.

    Returns Set<string>

    A set of audiences.

basicHeader

  • basicHeader(username: string, password: string): string
  • Parameters

    • username: string
    • password: string

    Returns string

buildAndAddAuthorizationHeader

  • buildAndAddAuthorizationHeader(destination: Destination): (headers: Record<string, any>) => Promise<Record<string, string>>
  • deprecated

    Since v1.20.0. Use buildAuthorizationHeaders instead. Adds authorization headers for a given destination to existing headers.

    Parameters

    Returns (headers: Record<string, any>) => Promise<Record<string, string>>

    The provided headers with the new authorization headers.

      • (headers: Record<string, any>): Promise<Record<string, string>>
      • Parameters

        • headers: Record<string, any>

          The headers that should be added to.

        Returns Promise<Record<string, string>>

        The provided headers with the new authorization headers.

buildAuthorizationHeaders

  • buildAuthorizationHeaders(destination: Destination): Promise<Record<string, string>>
  • Parameters

    Returns Promise<Record<string, string>>

buildAxiosRequestConfig

  • experimental

    This API is experimental and might change in newer versions. Use with caution.

    Type parameters

    Parameters

    • destination: Destination | DestinationNameAndJwt

      A destination or a destination name and a JWT.

    • Optional requestConfig: Partial<T>

      Any object representing an HTTP request.

    Returns Promise<AxiosRequestConfig>

buildCsrfHeaders

  • Get CSRF token and cookies for a destination and request configuration. The CSRF token and cookies will be retrieved based on the URL of the destination and the custom configuration given by the requestConfig. If there is a relative url in the requestConfig it will be appended to the destination's URL, an absolute URL overwrites the destination related URL.

    Type parameters

    Parameters

    • destination: Destination | DestinationNameAndJwt

      The destination to get the headers from

    • requestConfig: Partial<T>

      An http request configuration containing additional information about the request, like URL or headers

    Returns Promise<Record<string, any>>

    A promise to an object containing the CSRF related headers

buildHeadersForDestination

  • buildHeadersForDestination(destination: Destination, customHeaders?: Record<string, any>): Promise<Record<string, string>>
  • Parameters

    • destination: Destination
    • Optional customHeaders: Record<string, any>

    Returns Promise<Record<string, string>>

buildHttpRequest

ceiling

  • Build a filter function to ceil a number. Evaluates to double or decimal, defaults to double.

    Type parameters

    Parameters

    • num: number | Field<EntityT, boolean, boolean> | NumberFilterFunction<EntityT>

      The number to ceil. This can either be a number, a reference to a field or another filter function.

    • Optional returnType: "double" | "decimal"

      The return type to use.

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

checkMandatoryValue

  • checkMandatoryValue<InterfaceT, JwtKeysT>(key: keyof InterfaceT, mapping: JwtKeyMapping<InterfaceT, JwtKeysT>, jwtPayload: JwtPayload): void
  • Checks if a given key is present in the decoded JWT. If not, an error is thrown.

    Type parameters

    • InterfaceT

    • JwtKeysT

    Parameters

    • key: keyof InterfaceT

      The key of the representation in typescript

    • mapping: JwtKeyMapping<InterfaceT, JwtKeysT>

      The mapping between the typescript keys and the JWT key

    • jwtPayload: JwtPayload

      JWT payload to check fo the given key.

    Returns void

clientCredentialsGrant

  • deprecated

    Since v1.49.0 Use @sap/xssec lib instead. Executes a client credentials grant request. If the first parameter is an instance of XsuaaServiceCredentials, the response's access_token will be verified. If the first parameter is a URI, the response will not be verified.

    Parameters

    • tokenServiceUrlOrXsuaaServiceCredentials: string | XsuaaServiceCredentials

      The URL of the token service or the credentials of a XSUAA service instance.

    • clientCredentials: ClientCredentials

      Client credentials for which to request a token.

    • Optional options: ResilienceOptions

      Options to use by retrieving access token.

    • Optional customBody: Record<string, any>

      Object containing value required for the body request.

    Returns Promise<ClientCredentialsResponse>

    A promise resolving to the response.

concat

  • Build a filter function to concatenate two strings. Evaluates to string.

    Type parameters

    Parameters

    • str1: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The first string to concatenate. This can either be a string, a reference to a field or another filter function.

    • str2: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The second string to concatenate. This can either be a string, a reference to a field or another filter function.

    Returns StringFilterFunction<EntityT>

    The newly created filter function

contains

  • Build a filter function to test whether a string is a substring of the other. Evaluates to boolean.

    Type parameters

    Parameters

    • substr: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The substring to test for. This can either be a string, a reference to a field or another filter function.

    • str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The string to test. This can either be a string, a reference to a field or another filter function.

    Returns BooleanFilterFunction<EntityT>

    The newly created filter function

createComplexType

  • createComplexType<ComplexT>(json: any, converters: {}): ComplexT
  • deprecated

    Since v1.25.0. use deserializeComplexType instead.

    Type parameters

    • ComplexT

    Parameters

    • json: any

      A raw json object to deserialize a complex type from.

    • converters: {}

      A list of rules on how to convert json to the respective type in JavaScript or TypeScript.

      • [converter: string]: CallableFunction

    Returns ComplexT

    A deserialized complex type representation.

createGetFilter

  • Creates a getFilter function using the OData v2 or OData v4 URI converter. The concrete filter getters are initiated in odata/v2/uri-conversion/odata-uri.ts and odata/v4/uri-conversion/odata-uri.ts.

    Parameters

    Returns GetFilter

    The filter getter. See interface GetFilter

createGetResourcePathForKeys

  • createGetResourcePathForKeys(uriConverter: UriConverter): GetResourcePathForKeys
  • Creates a getResourcePathForKeys function using the OData v2 or OData v4 URI converter. The concrete instances for v2 or v4 are initiated in odata/v2/uri-conversion/odata-uri.ts and odata/v4/uri-conversion/odata-uri.ts.

    Parameters

    Returns GetResourcePathForKeys

    The filter getter. See GetFilter

customAttributes

  • customAttributes(jwtPayload: JwtPayload): Map<string, string[]>
  • Extracts the custom attributes from the JWT.

    Parameters

    • jwtPayload: JwtPayload

      Token payload to read the custom attributes from.

    Returns Map<string, string[]>

    Custom attributes added by the XSUAA service to the issued JWT.

day

  • Build a filter function to get the day of a date. Evaluates to int.

    Type parameters

    Parameters

    • date: Moment | Field<EntityT, boolean, boolean>

      The date to get the day for. This can either be a date (Moment) or a reference to a field.

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

decodeJwt

  • decodeJwt(token: string): JwtPayload
  • Decode JWT.

    Parameters

    • token: string

      JWT to be decoded

    Returns JwtPayload

    Decoded payload.

decodeJwtComplete

  • decodeJwtComplete(token: string): Jwt
  • Decode JWT and return the complete decoded token.

    Parameters

    • token: string

      JWT to be decoded.

    Returns Jwt

    Decoded token containing payload, header and signature.

desc

  • Create new Order by orderBy._fieldName in descending order.

    Type parameters

    • EntityT: EntityBase<EntityT>

      Type of the entity to be ordered

    Parameters

    Returns Order<EntityT>

    New order

deserializeBatchResponse

  • Deserialize the parsed batch response.

    Parameters

    • parsedBatchResponse: (ResponseData | ResponseData[])[]

      Two dimensional list of parsed batch sub responses.

    • entityToConstructorMap: Record<string, Constructable<EntityBase, unknown>>

      A map that holds the entity type to constructor mapping.

    • responseDataAccessor: ResponseDataAccessor

      Response data access module.

    • deserializer: EntityDeserializer<any>

      Entity deserializer.

    Returns (ErrorResponse | ReadResponse | WriteResponses)[]

    An array of parsed sub responses of the batch response.

Const deserializeComplexType

  • Parameters

    Returns any

Const deserializeComplexTypeV4

  • Parameters

    Returns any

Const deserializeEntity

  • deserializeEntity(json: any, entityConstructor: Constructable<any, unknown>, requestHeader?: any): any
  • Parameters

    • json: any
    • entityConstructor: Constructable<any, unknown>
    • Optional requestHeader: any

    Returns any

Const deserializeEntityV4

  • deserializeEntityV4(json: any, entityConstructor: Constructable<any, unknown>, requestHeader?: any): any
  • Parameters

    • json: any
    • entityConstructor: Constructable<any, unknown>
    • Optional requestHeader: any

    Returns any

destinationForServiceBinding

  • Tries to build a destination from a service binding with the given name. Throws an error if no services are bound at all, no service with the given name can be found, or the service type is not supported. The last error can be circumvent by using the second parameter to provide a custom function that transforms a service binding to a destination.

    Parameters

    Returns Destination

    A destination.

detectNewLineSymbol

  • detectNewLineSymbol(str: string): string
  • Detects the system dependent line break in a string.

    Parameters

    • str: string

      The string to check for line breaks. Should have at least two lines, otherwise an error will be thrown.

    Returns string

    The system dependent line break

endsWith

  • Build a filter function to test whether a string ends with another. Evaluates to boolean.

    Type parameters

    Parameters

    • str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The string to test. This can either be a string, a reference to a field or another filter function.

    • suffix: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The suffix to test for. This can either be a string, a reference to a field or another filter function.

    Returns BooleanFilterFunction<EntityT>

    The newly created filter function

entityDeserializer

  • entityDeserializer(edmToTs: EdmToTsTypeV2<any> | EdmToTsTypeV4<any>, extractODataETag: ExtractODataETagType, extractDataFromOneToManyLink: ExtractDataFromOneToManyLinkType): EntityDeserializer
  • 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

    Parameters

    • edmToTs: EdmToTsTypeV2<any> | EdmToTsTypeV4<any>

      Converters emd input to ts values.

    • extractODataETag: ExtractODataETagType

      Extractor for the ETag.

    • extractDataFromOneToManyLink: ExtractDataFromOneToManyLinkType

      Extractor for data related to one to many links.

    Returns EntityDeserializer

    a entity deserializer as defined by EntityDeserializer

execute

executeHttpRequest

extractClientCredentials

extractCustomFields

  • extractCustomFields<EntityT, JsonT>(json: Partial<JsonT>, entityConstructor: Constructable<EntityT, unknown>): Record<string, any>
  • 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.

    Type parameters

    Parameters

    • json: Partial<JsonT>

      The JSON payload.

    • entityConstructor: Constructable<EntityT, unknown>

      The constructor function of the entity class.

    Returns Record<string, any>

    An object containing the custom fields as key-value pairs.

extractEtagFromHeader

  • extractEtagFromHeader(headers: any): string | undefined
  • Parameters

    • headers: any

    Returns string | undefined

extractODataEtag

  • extractODataEtag(json: Record<string, any>): string | undefined
  • Extractor for the ETag for OData v2 responses used in entityDeserializer.

    Parameters

    • json: Record<string, any>

      Response data from which the ETag is extracted.

    Returns string | undefined

    The ETag.

extractODataEtagV4

  • extractODataEtagV4(json: Record<string, any>): string | undefined
  • Extractor for the ETag for OData v4 responses used in entityDeserializer.

    Parameters

    • json: Record<string, any>

      Response data from which the ETag is extracted.

    Returns string | undefined

    The ETag.

fetchDestination

  • Fetches a specific destination by name from the given URI, including authorization tokens. For destinations with authenticationType OAuth2SAMLBearerAssertion, this call will trigger the OAuth2SAMLBearerFlow against the target destination. In this pass the access token as string. Fetches a specific destination with authenticationType OAuth2UserTokenExchange by name from the given URI, including authorization tokens.

    Parameters

    • destinationServiceUri: string

      The URI of the destination service

    • token: string | AuthAndExchangeTokens

      The access token or AuthAndExchangeTokens if you want to include the X-user-token for OAuth2UserTokenExchange.

    • destinationName: string

      The name of the desired destination

    • Optional options: ResilienceOptions & CachingOptions

      Options to use by retrieving destinations

    Returns Promise<Destination>

    A Promise resolving to the destination

fetchInstanceDestinations

  • Fetches all instance destinations from the given URI.

    Parameters

    • destinationServiceUri: string

      The URI of the destination service

    • jwt: string

      The access token

    • Optional options: ResilienceOptions & CachingOptions

      Options to use by retrieving destinations

    Returns Promise<Destination[]>

    A promise resolving to a list of instance destinations

fetchSubaccountDestinations

  • Fetches all subaccount destinations from the given URI.

    Parameters

    • destinationServiceUri: string

      The URI of the destination service

    • jwt: string

      The access token

    • Optional options: ResilienceOptions & CachingOptions

      Options to use by retrieving destinations

    Returns Promise<Destination[]>

    A promise resolving to a list of subaccount destinations

fetchVerificationKeys

  • fetchVerificationKeys(xsuaaCredentials: XsuaaServiceCredentials, jku?: string): Promise<TokenKey[]>
  • fetchVerificationKeys(url: string, clientId: string, clientSecret: string): Promise<TokenKey[]>
  • fetchVerificationKeys(url: string): Promise<TokenKey[]>
  • Deprecated since v1.49.0. Use fetchVerificationKeys(url: string) instead. Credentials are ignored. Fetches verification keys from the XSUAA service for the given credentials.

    Parameters

    • xsuaaCredentials: XsuaaServiceCredentials

      Credentials of the XSUAA service instance.

    • Optional jku: string

      Value of the jku property in the JWT header. If not provided the old legacy URL xsuaaCredentials.url/token_keys is used as a fallback which will not work for subscriber accounts created after 14th of April 2020.

    Returns Promise<TokenKey[]>

    An array of TokenKeys.

  • Deprecated since v1.49.0. Use fetchVerificationKeys(url: string) instead. Credentials are ignored. Fetches verification keys from the XSUAA service for the given URL, with the given pair of credentials.

    Parameters

    • url: string

      URL of the XSUAA service instance.

    • clientId: string

      Client ID of the XSUAA service instance.

    • clientSecret: string

      Client secret of the XSUAA service instance.

    Returns Promise<TokenKey[]>

    An array of token keys.

  • Fetches verification keys from the XSUAA service for the given URL.

    Parameters

    • url: string

      URL of the XSUAA service instance.

    Returns Promise<TokenKey[]>

    An array of token keys.

filterCustomRequestConfig

  • filterCustomRequestConfig(customRequestConfig: Record<string, string>, disallowedKeys?: string[]): Record<string, string>
  • Filter disallowed keys from a given custom request config object.

    Parameters

    • customRequestConfig: Record<string, string>

      a given custom request config object to be filtered

    • Optional disallowedKeys: string[]

      A list of keys that are not allowed to be customized.

    Returns Record<string, string>

    Filtered custom request config object.

filterFunction

filterFunctionV4

  • Type parameters

    Parameters

    Returns BooleanFilterFunction<EntityT>

  • Type parameters

    Parameters

    Returns NumberFilterFunction<EntityT>

  • Type parameters

    Parameters

    Returns StringFilterFunction<EntityT>

  • Type parameters

    Parameters

    Returns DateFilterFunction<EntityT>

  • Type parameters

    Parameters

    Returns CollectionFilterFunction<EntityT, boolean>

  • Type parameters

    Parameters

    Returns CollectionFilterFunction<EntityT, string>

  • Type parameters

    Parameters

    Returns CollectionFilterFunction<EntityT, number>

  • Type parameters

    Parameters

    Returns CollectionFilterFunction<EntityT, moment.Moment>

filterNullishValues

  • filterNullishValues(headers?: Record<string, any>): Record<string, any>
  • deprecated

    Since v1.32.0. Use pickNonNullish instead.

    Filter headers that have nullish values.

    Parameters

    • headers: Record<string, any> = {}

      A header object to be filtered.

    Returns Record<string, any>

    • A filtered header object containing only headers with non-nullish values.

floor

  • Build a filter function to floor a number. Evaluates to double or decimal, defaults to double.

    Type parameters

    Parameters

    • num: number | Field<EntityT, boolean, boolean> | NumberFilterFunction<EntityT>

      The number to floor. This can either be a number, a reference to a field or another filter function.

    • Optional returnType: "double" | "decimal"

      The return type to use.

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

fractionalSeconds

  • Build a filter function to get the fractional seconds of a date. Evaluates to decimal.

    Type parameters

    Parameters

    • date: Moment | Field<EntityT, boolean, boolean>

      The date to get the fractional seconds for. This can either be a date (Moment) or a reference to a field.

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

getAgentConfig

  • Returns the http or https-agent config depending on the destination URL. If the destination contains a proxy configuration, the agent will be a proxy-agent. If not it will be the default http-agent coming from node.

    Parameters

    • destination: Destination

      determining which kind of configuration is returned

    Returns HttpAgentConfig | HttpsAgentConfig

    The http or http-agent configuration.

getAuthHeaders

  • getAuthHeaders(destination: Destination, customHeaders?: Record<string, any>): Promise<Record<string, string>>
  • Parameters

    • destination: Destination
    • Optional customHeaders: Record<string, any>

    Returns Promise<Record<string, string>>

getAxiosConfigWithDefaults

  • Builds an Axios config with default configuration i.e. no_proxy, default http and https agent and GET as request method.

    Returns HttpRequestConfig

    AxiosRequestConfig with default parameters

getAxiosConfigWithDefaultsWithoutMethod

  • Returns Omit<HttpRequestConfig, "method">

getCollectionResult

  • getCollectionResult(data: any): any[]
  • Extract the collection data from the response. If the data does not contain a collection an empty array is returned.

    Parameters

    • data: any

      Response of the OData v4 service.

    Returns any[]

    Collection extracted from the response.

getDestination

  • Builds a destination from one of three sources (in the given order):

    • from the environment variable "destinations"
    • from service bindings
    • from the destination service

    If you want to get a destination only from a specific source, use the corresponding function directly (getDestinationFromEnvByName, destinationForServiceBinding, getDestinationFromDestinationService).

    Parameters

    • name: string

      The name of the destination to be retrieved.

    • Optional options: DestinationOptions

      Configuration for how to retrieve destinations from the destination service.

    Returns Promise<Destination | null>

    A promise returning the requested destination on success.

getDestinationBasicCredentials

  • getDestinationBasicCredentials(): BasicCredentials
  • Basic Credentials Getter from Destination service credentials needed for JWT generator.

    Returns BasicCredentials

    Basic credentials.

getDestinationByName

  • deprecated

    Since v1.4.2. Use getDestinationFromEnvByName instead.

    Get a destination from the environment variables by name. Throws an error if there are multiple destinations with the same name. This is discouraged for productive use! Use destination-accessor/useOrFetchDestination for fetching destinations from the Cloud Foundry destination service.

    Parameters

    • name: string

      Name of the destination

    Returns Destination | null

    The requested destination if existent, otherwise null

getDestinationFromDestinationService

  • Retrieves a destination with the given name from the Cloud Foundry destination service. Returns null, if no destination can be found. Requires the following service bindings: destination, XSUAA By default, selects subscriber over provider and instance over subaccount destinations.

    If the destinations are read from the environment, the jwt will be ignored.

    Parameters

    • name: string

      The name of the destination to be retrieved.

    • options: DestinationOptions

      Configuration for how to retrieve destinations from the destination service.

    Returns Promise<Destination | null>

    A promise returning the requested destination on success.

getDestinationFromEnvByName

  • getDestinationFromEnvByName(name: string): Destination | null
  • Get a destination from the environment variables by name. If there are multiple destinations with the same name the first one will be used. This is discouraged for productive use! Use destination-accessor/useOrFetchDestination for fetching destinations from the Cloud Foundry destination service.

    Parameters

    • name: string

      Name of the destination

    Returns Destination | null

    The requested destination if existent, otherwise null

getDestinationOptions

  • deprecated

    Since v1.0.1. Use getDestination instead.

    Retrieves a destination with the given name from the Cloud Foundry destination service. Returns null, if no destination can be found. Requires the following service bindings: destination, XSUAA By default, selects subscriber over provider and instance over subaccount destinations.

    If the destinations are read from the environment, the jwt will be ignored.

    Parameters

    • name: string

      The name of the destination to be retrieved.

    • Optional options: DestinationOptions

      The options of the fetching query of the destination that include the JWT of the current request and the strategy for selecting a destination.

    Returns Promise<Destination | null>

    A promise returning the requested destination on success.

getDestinationService

  • Get destination service if one is present.

    throws

    Error in case no destination service is found in the VCAP variables

    Returns Service

    Destination service

getDestinationServiceCredentials

  • getDestinationServiceCredentials(): any
  • First 'destination' credentials getter.

    Returns any

    The 'destination' credentials object or null, if it does not exist.

getDestinationServiceCredentialsList

  • Destination credentials getter.

    Returns DestinationServiceCredentials[]

    A list of 'credentials' objects in 'destination' service.

getDestinationServiceUri

  • getDestinationServiceUri(): string | null
  • Destination URI getter NOTICE: If there exist more than one destination/uri, the function returns the first entry.

    Returns string | null

    The first existing uri in destination or null, if not found.

getDestinations

  • deprecated

    Since v1.4.2. Use getDestinationsFromEnv instead.

    Get all destinations from the environment variable "destinations". This is discouraged for productive use! Use destination-accessor/useOrFetchDestination for fetching destinations from the Cloud Foundry destination service.

    Returns Destination[]

    A list of destinations

getDestinationsFromEnv

  • Get all destinations from the environment variable "destinations". This is discouraged for productive use! Use useOrFetchDestination for fetching destinations from the Cloud Foundry destination service.

    Returns Destination[]

    A list of destinations

getEdmType

  • Convenience method to get the EdmTypeShared from the overloaded constructor. The two scenarios are:

    • complexTypeNameOrEdmType is of type EdmTypeShared and edmTypeOrUndefined is undefined
    • complexTypeNameOrEdmType is of type string and edmTypeOrUndefined is of type EdmTypeShared

    Type parameters

    Parameters

    • complexTypeNameOrEdmType: string | EdmTypeShared<VersionT>

      Either the name of the complex type or the EDM type.

    • Optional edmTypeOrUndefined: EdmTypeShared<VersionT>

      Either the EDM type or undefined.

    Returns EdmTypeShared<VersionT>

    The EDM type resolved for the two arguments.

getEntityConstructor

  • getEntityConstructor<EntityT, ComplexT>(fieldOf: ConstructorOrField<EntityT, ComplexT>): Constructable<EntityT>
  • Convenience method to get the entity constructor of the parent of a complex type.

    Type parameters

    Parameters

    • fieldOf: ConstructorOrField<EntityT, ComplexT>

      Either an entity constructor or another complex type field.

    Returns Constructable<EntityT>

    The constructor of the transitive parent entity;

getEntityKeys

  • getEntityKeys<EntityT>(entity: EntityT, entityConstructor: Constructable<EntityT, unknown>): Record<string, any>
  • Helper function that maps an entity to its keys map with their original names.

    Type parameters

    Parameters

    • entity: EntityT

      Entity to map

    • entityConstructor: Constructable<EntityT, unknown>

      The constructor of the entity

    Returns Record<string, any>

    object that includes all keys that represent given entity

getEnvironmentVariable

  • getEnvironmentVariable(name: string): string | undefined | null
  • Environment variables accessor.

    Parameters

    • name: string

      Environment variable name.

    Returns string | undefined | null

    Env variable value if defined. null: If not defined.

getExpand

  • getExpand<EntityT>(selects?: Selectable<EntityT>[]): Partial<{ expand: string }>
  • Get an object containing the given expand as a query parameter, or an empty object if none was given. In this OData v2 expand, selected properties are automatically added to the expand.

    Type parameters

    • EntityT: Entity<EntityT>

      Type of the entity to expand on

    Parameters

    • Optional selects: Selectable<EntityT>[]

      The selects which are expanded if necessary

    Returns Partial<{ expand: string }>

    An object containing the query parameter or an empty object

getExpandV4

  • getExpandV4<EntityT>(expands: undefined | Expandable<EntityT>[], entityConstructor: Constructable<EntityT, unknown>): Partial<{ expand: string }>
  • Get an object containing the given expand as a query parameter, or an empty object if none was given.

    Type parameters

    • EntityT: EntityV4<EntityT>

      Type of the entity to expand on

    Parameters

    • expands: undefined | Expandable<EntityT>[]

      The expands to transform to a query parameter

    • entityConstructor: Constructable<EntityT, unknown>

      Constructor type of the entity to expand on

    Returns Partial<{ expand: string }>

    An object containing the query parameter or an empty object

getFieldOptions

  • getFieldOptions<NullableT, SelectableT>(fieldOptions?: FieldOptions<NullableT, SelectableT>): Required<FieldOptions<NullableT, SelectableT>>
  • Get field options merged with default values. The given options take precedence.

    Type parameters

    • NullableT: boolean = false

    • SelectableT: boolean = false

    Parameters

    • Optional fieldOptions: FieldOptions<NullableT, SelectableT>

      Given options.

    Returns Required<FieldOptions<NullableT, SelectableT>>

    Given options merged with default values.

getGrantTokenCacheKey

  • getGrantTokenCacheKey(url: string, credentialsOrClientId: string | ClientCredentials): string
  • Parameters

    Returns string

getHeader

  • getHeader(key: string, headers?: Record<string, any>): Record<string, any>
  • deprecated

    Since v1.32.0. Use pickIgnoreCase instead.

    Find a header in a given header object, if available, independent of the case (lower / upper).

    Parameters

    • key: string

      Name of the header to be found.

    • headers: Record<string, any> = {}

      Header object to be searched for given key.

    Returns Record<string, any>

    • An object containing the given key (and value) in its original case, as found in headers or an empty object if not found.

getHeaderValue

  • getHeaderValue(key: string, headers?: Record<string, any>): any | undefined
  • deprecated

    Since v1.32.0. Use pickValueIgnoreCase instead.

    Get the value of a header based on the given key, independent of the case (lower / upper).

    Parameters

    • key: string

      Name of the header to be found.

    • headers: Record<string, any> = {}

      Header object to be searched for given key.

    Returns any | undefined

    The value of the header with the given key or undefined.

getHeaders

  • getHeaders(keys: string[], headers?: Record<string, any>): Record<string, any>
  • deprecated

    Since v1.32.0. Use pickIgnoreCase instead.

    Find headers in a given header object, if available, independent of the case (lower / upper).

    Parameters

    • keys: string[]

      Name of the header to be found.

    • headers: Record<string, any> = {}

      Header object to be searched for given key.

    Returns Record<string, any>

    • An object containing the given keys (and values) in its original case, as found in headers or an empty object if not found.

getLine

  • deprecated

    Since v1.30.0. This function won't be replaced. Serialize a request to a one line string containing the HTTP method, URL and HTTP version. For Example: GET /sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartnerAddress?$format=json&$top=1 HTTP/1.1

    Parameters

    Returns string

    The serialized request as <HTTP method> <URL> <HTTP version>.

getLinkedCollectionResult

  • getLinkedCollectionResult(data: any): any[]
  • Extract the collection data from the one to many link response. If the data does not contain a collection an empty array is returned.

    Parameters

    • data: any

      Response of the one to many link.

    Returns any[]

    Collection extracted from the response.

getOAuth2ClientCredentialsToken

  • getOAuth2ClientCredentialsToken(destination: Destination): Promise<ClientCredentialsResponse>
  • deprecated

    Since v1.47.0. Retrieves an access token required for "OAuth2ClientCredentials" destination authentication type.

    Parameters

    • destination: Destination

      A destination having OAuth2ClientCredentials authentication type

    Returns Promise<ClientCredentialsResponse>

    A promise returning the requested access token on success.

getOrderBy

  • getOrderBy<EntityT>(orderBy: Orderable<EntityT>[]): Partial<{ orderby: string }>
  • Get an object containing the given order bys as query parameter, or an empty object if none was given.

    Type parameters

    • EntityT: EntityBase<EntityT>

      Type of the entity to order

    Parameters

    • orderBy: Orderable<EntityT>[]

      A list of orderables to get the query parameters for

    Returns Partial<{ orderby: string }>

    An object containing the query parameter or an empty object

getProtocolOrDefault

  • Extracts the http protocol from the destination URL. The default value is http if no protocol is given.

    throws

    Error in case a unsupported protocol is given in the destination URL like rfc://example.com.

    Parameters

    • destination: Destination

      URL of this destination is parsed

    Returns Protocol

    The protocol, either https or http.

getQueryParametersForFilter

  • getQueryParametersForFilter<EntityT>(filter: Filterable<EntityT, any>, entityConstructor: Constructable<EntityT, unknown>): Partial<{ filter: string }>
  • deprecated

    Since v1.21.0. Use ODataUri.getFilter instead. Get an object containing the given filter as query parameter, or an empty object if none was given.

    Type parameters

    • EntityT: Entity<EntityT>

      Type of the entity to filter on

    Parameters

    • filter: Filterable<EntityT, any>

      The filter to transform to a query parameter

    • entityConstructor: Constructable<EntityT, unknown>

      Constructor type of the entity to filter on

    Returns Partial<{ filter: string }>

    An object containing the query parameter or an empty object

getQueryParametersForOrderBy

  • getQueryParametersForOrderBy<EntityT>(orderBy: Orderable<EntityT>[]): Partial<{ orderby: string }>
  • deprecated

    Since v1.21.0. Use ODataUri.getOrderBy instead. Get an object containing the given order bys as query parameter, or an empty object if none was given.

    Type parameters

    • EntityT: Entity<EntityT>

      Type of the entity to order

    Parameters

    • orderBy: Orderable<EntityT>[]

      A list of orderables to get the query parameters for

    Returns Partial<{ orderby: string }>

    An object containing the query parameter or an empty object

getQueryParametersForSelection

  • getQueryParametersForSelection<EntityT>(selects?: Selectable<EntityT>[]): Partial<{ expand: string; select: string }>
  • deprecated

    Since v1.21.0. Use ODataUri.getSelect and ODataUri.getExpand instead.

    Get an object containing the given Selectables as query parameter, or an empty object if none were given. This retrieves where in addition to the selection (select) there is also an expansion (expand) needed.

    Type parameters

    • EntityT: Entity<EntityT>

      Type of the entity to get the selection for

    Parameters

    • Optional selects: Selectable<EntityT>[]

      The list of selectables to be transformed to query parameters

    Returns Partial<{ expand: string; select: string }>

    An object containing the query parameters or an empty object

getResourcePathForKeys

  • getResourcePathForKeys<EntityT>(keys: undefined | Record<string, FieldType>, entityConstructor: Constructable<EntityT, unknown>): string
  • deprecated

    Since v1.21.0. Use ODataUri.getResourcePathForKeys instead. Get the resource path of an entity specified by key-value pairs.

    Type parameters

    • EntityT: EntityBase<EntityT>

      Type of the entity to get the resource path for

    Parameters

    • keys: undefined | Record<string, FieldType>

      Key-value pairs where the key is the name of a key property of the given entity and the value is the respective value

    • entityConstructor: Constructable<EntityT, unknown>

      Constructor type of the entity to get the resource path for

    Returns string

    The path to the resource

getResponseBody

  • getResponseBody(response: string): string
  • Get the response body from the string representation of a response.

    Parameters

    • response: string

      String representation of a response.

    Returns string

    The response body as a one line string.

getSelect

  • getSelect<EntityT>(selects?: Selectable<EntityT>[]): Partial<{ select: string }>
  • Get an object containing the given Selectables as query parameter, or an empty object if none were given. This retrieves where in addition to the selection (select) there is also an expansion (expand) needed.

    Type parameters

    • EntityT: Entity<EntityT>

      Type of the entity to get the selection for

    Parameters

    • Optional selects: Selectable<EntityT>[]

      The list of selectables to be transformed to query parameters

    Returns Partial<{ select: string }>

    An object containing the query parameters or an empty object

getSelectV4

  • getSelectV4<EntityT>(selects?: Selectable<EntityT>[]): Partial<{ select: string }>
  • Get an object containing the given Selectables as query parameter, or an empty object if none were given. In OData v4 selected properties are not automatically expanded anymore and a manual expand needs to be performed.

    Type parameters

    • EntityT: EntityV4<EntityT>

      Type of the entity to get the selection for

    Parameters

    • Optional selects: Selectable<EntityT>[]

      The list of selectables to be transformed to query parameters

    Returns Partial<{ select: string }>

    An object containing the query parameters or an empty object

getService

  • getService(service: string): Service | undefined
  • Returns the first found instance for the given service type.

    Parameters

    • service: string

      The service type.

    Returns Service | undefined

    The first found service.

getServiceCredentialsList

  • getServiceCredentialsList(service: string): any[]
  • Credentials list getter for a given service.

    Parameters

    • service: string

      Service name

    Returns any[]

    Fetched credentials objects of existing service in 'VCAP_SERVICES'.

getServiceList

  • getServiceList(service: string): Service[]
  • Services getter for a given service.

    Parameters

    • service: string

      Service name.

    Returns Service[]

    List of service bindings of the given type. Returns an empty array if no service binding exists for the given type.

getSingleResult

  • getSingleResult(data: any): Record<string, any>
  • Extract the single entry data from the response. If the data does not contain a single object an empty object is returned.

    Parameters

    • data: any

      Response of the OData v4 service.

    Returns Record<string, any>

    A single object extracted from the response.

getUrlProtocol

  • deprecated

    Since v1.5.1. use getProtocolOrDefault instead Takes the destination URL and return everything before the ://.

    Parameters

    • destination: Destination

      URL of this destination is parsed

    Returns Protocol | undefined

    The protocol either undefined if no :// is found or anything before the delimiter.

getVcapService

  • getVcapService(): Record<string, any> | null
  • 'VCAP_SERVICES' Getter from environment variables. This function returns the VCAP_SERVICES as object or null, if it is not defined (i.e. no services are bound to the application).

    Returns Record<string, any> | null

    'VCAP_SERVICES' found in environment variables or null, if not defined. The key denotes the name ov the service and the value is the definition.

getXsuaaServiceCredentials

  • Takes a decoded JWT and uses the client_id and audience claims to determine the XSUAA service instance that issued the JWT. Returns the credentials if a match is found, otherwise throws an error. If no decoded JWT is specified, then returns the first existing XSUAA credential service plan "application".

    Parameters

    • Optional token: string | JwtPayload

      Either an encoded or decoded JWT.

    Returns XsuaaServiceCredentials

    The credentials for a match, otherwise null.

hasSubsequence

  • hasSubsequence<EntityT, ParamT, ReturnT>(subsequence: ParamT[] | Field<EntityT, boolean, boolean> | CollectionFilterFunction<EntityT, ReturnT>, sequence: ParamT[] | Field<EntityT, boolean, boolean> | CollectionFilterFunction<EntityT, ReturnT>): BooleanFilterFunction<EntityT>
  • Build a filter function to test whether a set is a subsequence of the other, i. e. whether the second parameter can be transformed into the first by removing items. Evaluates to boolean.

    Type parameters

    Parameters

    • subsequence: ParamT[] | Field<EntityT, boolean, boolean> | CollectionFilterFunction<EntityT, ReturnT>

      The subsequence to test for. This can either be an array, a reference to a field or another filter function.

    • sequence: ParamT[] | Field<EntityT, boolean, boolean> | CollectionFilterFunction<EntityT, ReturnT>

      The sequence to test. This can either be an array, a reference to a field or another filter function.

    Returns BooleanFilterFunction<EntityT>

    The newly created filter function

hasSubset

  • hasSubset<EntityT, ParamT, ReturnT>(subset: ParamT[] | CollectionField<EntityT, any, boolean, boolean> | CollectionFilterFunction<EntityT, ReturnT>, set: ParamT[] | CollectionField<EntityT, any, boolean, boolean> | CollectionFilterFunction<EntityT, ReturnT>): BooleanFilterFunction<EntityT>
  • Build a filter function to test whether a set is a subset of the other, i. e. whether the second parameter can be transformed into the first by reordering and / or removing items. Evaluates to boolean.

    Type parameters

    Parameters

    • subset: ParamT[] | CollectionField<EntityT, any, boolean, boolean> | CollectionFilterFunction<EntityT, ReturnT>

      The subset to test for. This can either be an array, a reference to a field or another filter function.

    • set: ParamT[] | CollectionField<EntityT, any, boolean, boolean> | CollectionFilterFunction<EntityT, ReturnT>

      The set to test. This can either be an array, a reference to a field or another filter function.

    Returns BooleanFilterFunction<EntityT>

    The newly created filter function

headerForClientCredentials

  • Parameters

    Returns string

hour

  • Build a filter function to get the hour of a date. Evaluates to int.

    Type parameters

    Parameters

    • date: Moment | Field<EntityT, boolean, boolean>

      The date to get the hour for. This can either be a date (Moment) or a reference to a field.

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

indexOf

  • Build a filter function to get the start index of a substring. Evaluates to int.

    Type parameters

    Parameters

    • str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The string to get the index from. This can either be a string, a reference to a field or another filter function.

    • substr: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The substring to get the index for. This can either be a string, a reference to a field or another filter function.

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

isBooleanFilterFunction

  • Type parameters

    Parameters

    Returns filterable is BooleanFilterFunction<EntityT>

isCollectionResult

  • isCollectionResult(data: any): boolean
  • Checks if the data contains a collection result.

    Parameters

    • data: any

      Response of the OData v4 service

    Returns boolean

    true, if the data is a collection result

isComplexTypeNameSpace

  • Parameters

    • val: any

    Returns val is ComplexTypeNamespace<any>

isDestination

  • isDestination(destination: any): destination is Destination
  • Parameters

    • destination: any

    Returns destination is Destination

isDestinationNameAndJwt

  • Parameters

    • destination: any

    Returns destination is DestinationNameAndJwt

isEdmType

  • Check whether a value is an EdmType. This will yield positive results for every string starting with Edm..

    Parameters

    • val: any

      Value to test.

    Returns val is EdmTypeCommon | ExclusiveEdmTypeV2 | ExclusiveEdmTypeV4

    Whether the given value is of type EdmTypeShared

isFilter

  • isFilter<T, FieldT>(filterable: Filterable<T, any>): filterable is Filter<T, FieldT>
  • Type parameters

    Parameters

    Returns filterable is Filter<T, FieldT>

isFilterLambdaExpression

  • hidden

    Type parameters

    Parameters

    Returns filterable is FilterLambdaExpression<EntityT>

isFilterLink

  • isFilterLink<EntityT, LinkedT>(filterable: Filterable<EntityT, any>): filterable is FilterLink<EntityT, LinkedT>
  • Type parameters

    Parameters

    Returns filterable is FilterLink<EntityT, LinkedT>

isFilterList

  • Type parameters

    Parameters

    Returns filterable is FilterList<T>

isHttpSuccessCode

  • isHttpSuccessCode(httpCode: number): boolean
  • Parameters

    • httpCode: number

    Returns boolean

isIdenticalTenant

  • isIdenticalTenant(userTokenPayload: JwtPayload, providerTokenPayload: JwtPayload): boolean
  • Compare two decoded JWTs based on their tenantIds.

    Parameters

    • userTokenPayload: JwtPayload

      User JWT payload.

    • providerTokenPayload: JwtPayload

      Provider JWT payload.

    Returns boolean

    Whether the tenant is identical.

isNavigationProperty

  • isNavigationProperty(key: string, entityConstructor: any): boolean
  • Checks if the property with name key of the entity is a navigation property.

    Parameters

    • key: string

      Name of the property.

    • entityConstructor: any

      Constructor of the entity.

    Returns boolean

    A boolean denoting whether an entity is a navigation property or not.

isOf

  • Build a filter function to test whether a selection is of a given type. Evaluates to boolean.

    Type parameters

    Parameters

    • type: string

      The type to test for, e. g. API_BUSINESS_PARTNER.A_BusinessPartner.

    Returns BooleanFilterFunction<EntityT>

    The newly created filter function

  • Build a filter function to test whether a field is of a given type. Evaluates to boolean.

    Type parameters

    Parameters

    • expression: Field<EntityT, boolean, boolean>

      A reference to a field to test for type.

    • type: string

      The type to test for, e. g. API_BUSINESS_PARTNER.A_BusinessPartner.

    Returns BooleanFilterFunction<EntityT>

    The newly created filter function

isOrderableEdmType

isUnaryFilter

  • Type parameters

    Parameters

    Returns filterable is UnaryFilter<T>

isUserToken

  • The user JWT can be a full JWT containing user information but also a reduced one setting only the iss value This method divides the two cases.

    Parameters

    • token: undefined | JwtPair

      Token to be investigated

    Returns token is JwtPair

    Boolean value with true if the input is a UserJwtPair

isWithETag

  • isWithETag(config: any): config is WithETag
  • Parameters

    • config: any

    Returns config is WithETag

issuerUrl

  • issuerUrl(decodedToken: JwtPayload): string | undefined
  • Get the issuer URL of a decoded JWT.

    Parameters

    • decodedToken: JwtPayload

      Token to read the issuer URL from.

    Returns string | undefined

    The issuer URL if available.

jwtBearerToken

  • Returns a jwt bearer token that can be used to call the given service. The token is fetched via a JWT bearer token grant using the user token + client credentials.

    Throws an error if there is no instance of the given service type or the XSUAA service, or if the request to the XSUAA service fails.

    Parameters

    • userJwt: string

      The JWT of the user for whom the access token should be fetched

    • service: string | Service

      The type of the service or an instance of Service.

    • Optional options: ResilienceOptions

      Options to influence resilience behavior (see ResilienceOptions). By default, usage of a circuit breaker is enabled.

    Returns Promise<string>

    A jwt bearer token.

jwtBearerTokenGrant

  • deprecated

    Since v1.49.0 Use @sap/xssec lib instead. Executes a JWT bearer token grant request against the given URI.

    Parameters

    • tokenServiceUrlOrXsuaaServiceCredentials: string | XsuaaServiceCredentials

      The URL of the token service or the credentials of a XSUAA service instance.

    • clientCredentials: ClientCredentials

      The credentials (client_id, client_secret) of the target XSUAA service instance.

    • userJwt: string

      The JWT of the user on whose behalf the request is executed.

    • Optional options: ResilienceOptions

      Options to use by retrieving access token.

    Returns Promise<ClientCredentialsResponse>

    A promise resolving to the response of the XSUAA service.

length

  • Build a filter function to get the length of a string. Evaluates to int.

    Type parameters

    Parameters

    • str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The string to compute the length for. This can either be a string, a reference to a field or another filter function.

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

matchesPattern

  • Build a filter function to test whether a string matches a pattern. Evaluates to boolean.

    Type parameters

    Parameters

    • str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The string to get the index from. This can either be a string, a reference to a field or another filter function.

    • regex: string

      The pattern to test against. This should be a regular expression as a string.

    Returns BooleanFilterFunction<EntityT>

    The newly created filter function

maxDateTime

  • Build a filter function to get the latest possible point in time. Evaluates to DateTimeOffset.

    Type parameters

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

mergeHeaders

  • mergeHeaders(headers?: Record<string, any>, customHeaders?: Record<string, any>): Record<string, any>
  • deprecated

    Since v1.32.0. Use mergeIgnoreCase instead.

    Create a header object by merging two header objects, where the custom headers take precedence.

    Parameters

    • headers: Record<string, any> = {}

      A base header object that contains the headers that will be compared with customHeaders.

    • customHeaders: Record<string, any> = {}

      A header object to be compared with headers. Only headers present in headers will be compared.

    Returns Record<string, any>

    • An object containing all keys from both the header objects, where headers present in the customHeaders are replaced. Note that the case (upper / lower) used by customHeaders will be used.

minDateTime

  • Build a filter function to get the earliest possible point in time. Evaluates to DateTimeOffset.

    Type parameters

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

minute

  • Build a filter function to get the minute of a date. Evaluates to int.

    Type parameters

    Parameters

    • date: Moment | Field<EntityT, boolean, boolean>

      The date to get the minute for. This can either be a date (Moment) or a reference to a field.

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

month

  • Build a filter function to get the month of a date. Evaluates to int.

    Type parameters

    Parameters

    • date: Moment | Field<EntityT, boolean, boolean>

      The date to get the month for. This can either be a date (Moment) or a reference to a field.

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

noDestinationErrorMessage

Const nonEnumerable

  • nonEnumerable(target: any, propertyKey: string): void
  • Parameters

    • target: any
    • propertyKey: string

    Returns void

not

  • Negate a filter.

    Type parameters

    Parameters

    • filter: Filterable<EntityT, any>

      The filter to negate.

    Returns UnaryFilter<EntityT>

    The negated filter.

now

  • Build a filter function to get the current point in time. Evaluates to DateTimeOffset.

    Type parameters

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

or

  • Combine Filterables with logical or to create a FilterList.

    Example:

    Entity.requestBuilder()
    .getAll()
    .filter(or(filterExp1, filterExp2));

    Type parameters

    • EntityT: EntityBase<EntityT>

      Type of the entity filter on.

    Parameters

    • expressions: Filterable<EntityT, any>[]

      Filterables to be combined with logical or

    Returns FilterList<EntityT>

    The newly created FilterList

  • Type parameters

    Parameters

    Returns FilterList<EntityT>

parseBatchResponse

  • Parse the complete batch HTTP response.

    Parameters

    • batchResponse: HttpResponse

      HTTP response of a batch request.

    Returns (ResponseData | ResponseData[])[]

    An array of parsed sub responses of the batch response.

parseDestination

  • Takes a JSON object returned by any of the calls to the destination service and returns an SDK compatible destination object. This function only accepts destination configurations of type 'HTTP' and will error if no 'URL' is given.

    Parameters

    Returns Destination

    An SDK compatible destination object.

parseEntityNameFromMetadataUri

  • parseEntityNameFromMetadataUri(uri: string): string
  • Parse the entity name from the metadata uri. This should be the __metadata property of a single entity in the response.

    Parameters

    • uri: string

      The URI to parse the entity name from

    Returns string

    The entity name.

parseHttpCode

  • parseHttpCode(response: string): number
  • Parse the HTTP code of response.

    Parameters

    • response: string

      String representation of the response.

    Returns number

    The HTTP code.

parseProxyEnv

  • Parses the environment variable for the web proxy and extracts the values considering defaults like http for the protocol and 80 or 443 for the port. The general pattern to be parsed is protocol://user:password@host:port, where everything besides the host is optional. Special characters in the user and password need to be percent encoded.

    Parameters

    • proxyEnvValue: string

      Environment variable which is parsed.

    Returns ProxyConfiguration | undefined

    Configuration with default values or undefined if the parsing failed.

parseResponseData

  • Parse the body and http code of a batch sub response.

    Parameters

    • response: string

      A batch sub response.

    Returns ResponseData

    The parsed response.s

prependDollar

  • prependDollar(param: string): string
  • Parameters

    • param: string

    Returns string

proxyAgent

  • Builds the http(s)-agent config. Note that the proxy agent type like http or https is determined by the destination RUL protocol. The protocol from the proxy is unrelated to this and in most cases http. All additional options are forwarded to tls.connect and net.connect see https://github.com/TooTallNate/node-https-proxy-agent#new-httpsproxyagentobject-options

    Parameters

    • destination: Destination

      Destination containing the proxy configurations

    • Optional options: AgentOptions

      Additional options for the agent

    Returns HttpAgentConfig | HttpsAgentConfig

    The http(s)-agent containing the proxy configuration

proxyHostAndPort

  • proxyHostAndPort(): HostAndPort
  • Returns HostAndPort

proxyStrategy

  • Determines the proxy strategy. If noProxy is set the ProxyConfiguration in the destination is omitted. For onPremProxy or internetProxy the connectivity service or environment variables are checked to fill the ProxyConfiguration.

    Parameters

    • destination: Destination

      from which the proxy strategy is derived.

    Returns ProxyStrategy

    ProxyStrategy possible values are noProxy, internetProxy or onPremProxy.

readPropertyWithWarn

  • readPropertyWithWarn(jwtPayload: JwtPayload, property: string): any
  • Parameters

    • jwtPayload: JwtPayload
    • property: string

    Returns any

refreshTokenGrant

  • deprecated

    Since v1.41.0 Use jwtBearerTokenGrant instead. Executes a refresh token grant request against the given URI. If the first parameter is an instance of XsuaaServiceCredentials, the response's access_token will be verified. If the first parameter is an URI, the response will not be verified.

    Parameters

    • tokenServiceUrlOrXsuaaServiceCredentials: string | XsuaaServiceCredentials

      The URL of the token service or the credentials of a XSUAA service instance.

    • clientCredentials: ClientCredentials

      The credentials (client_id, client_secret) of the target XSUAA service instance.

    • refreshToken: string

      The refresh token that should be used to generate a new access token.

    • Optional options: ResilienceOptions

      Options to use by retrieving access token.

    Returns Promise<UserTokenResponse>

    A promise resolving to the response of the XSUAA service.

replaceDuplicateKeys

  • replaceDuplicateKeys(headers?: Record<string, any>, customHeaders?: Record<string, any>): Record<string, any>
  • deprecated

    Since v1.32.0. Use mergeLeftIgnoreCase instead.

    Create a header object by replacing headers that are set as custom headers.

    Parameters

    • headers: Record<string, any> = {}

      A base header object that contains the headers that will be compared with customHeaders.

    • customHeaders: Record<string, any> = {}

      A header object to be compared with headers. Only headers present in headers will be compared.

    Returns Record<string, any>

    • An object containing all keys from the original headers object, where headers present in the customHeaders are replaced. Note that the case (upper / lower) used by customHeaders will be used.

resolveService

  • Takes a string that represents the service type and resolves it by calling getService. If the parameter is already an instance of Service, it is returned directly.

    Throws an error when no service can be found for the given type.

    Parameters

    • service: string | Service

      A string representing the service type or a Service instance.

    Returns Service

    A Service instance.

retrieveJwt

  • retrieveJwt(req: IncomingMessage): string | undefined
  • Retrieve JWT from a request that is based on the node IncomingMessage. Fails if no authorization header is given or has the wrong format. Expected format is 'Bearer '.

    Parameters

    • req: IncomingMessage

      Request to retrieve the JWT from

    Returns string | undefined

    JWT found in header

round

  • Build a filter function to round a number. Evaluates to double or decimal, defaults to double.

    Type parameters

    Parameters

    • num: number | Field<EntityT, boolean, boolean> | NumberFilterFunction<EntityT>

      The number to round. This can either be a number, a reference to a field or another filter function.

    • Optional returnType: "double" | "decimal"

      The return type to use.

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

sanitizeDestination

  • sanitizeDestination(destination: Record<string, any>): Destination
  • Takes an existing or a parsed destination and returns an SDK compatible destination object.

    Parameters

    • destination: Record<string, any>

      An object that adheres to the Destination interface.

    Returns Destination

    An SDK compatible destination object.

searchServiceBindingForDestination

  • searchServiceBindingForDestination(name: string): Destination | undefined
  • Parameters

    • name: string

    Returns Destination | undefined

second

  • Build a filter function to get the second of a date. Evaluates to int.

    Type parameters

    Parameters

    • date: Moment | Field<EntityT, boolean, boolean>

      The date to get the second for. This can either be a date (moment.Moment) or a reference to a field.

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

secondsToTime

  • secondsToTime(n: number): Time
  • Converts from seconds to time as Time.

    Parameters

    • n: number

      Number of seconds to convert (should be positive).

    Returns Time

    Time The converted time from the given number of seconds

serializeBatchRequest

  • serializeBatchRequest(request: BatchRequestBuilder, options?: BatchRequestSerializationOptions): string
  • Serialize a batch request to string. This is used for the batch request payload when executing the request.

    Parameters

    • request: BatchRequestBuilder

      Batch request to serialize.

    • Optional options: BatchRequestSerializationOptions

      Request serialization options.

    Returns string

    String representation of the batch request.

serializeChangeSet

  • serializeChangeSet(changeSet: BatchChangeSet<any>, options?: BatchRequestSerializationOptions): string | undefined
  • Serialize change set to string.

    Parameters

    • changeSet: BatchChangeSet<any>

      Change set containing a collection of write operations.

    • Optional options: BatchRequestSerializationOptions

      Request serialization options.

    Returns string | undefined

    The serialized string representation of a change set.

Const serializeComplexType

  • serializeComplexType(fieldValue: any, complexTypeNameSpace: any): any
  • Parameters

    • fieldValue: any
    • complexTypeNameSpace: any

    Returns any

Const serializeComplexTypeV4

  • serializeComplexTypeV4(fieldValue: any, complexTypeNameSpace: any): any
  • Parameters

    • fieldValue: any
    • complexTypeNameSpace: any

    Returns any

Const serializeEntity

  • serializeEntity(entity: any, entityConstructor: Constructable<any, unknown>, diff?: boolean): Record<string, any>
  • Parameters

    • entity: any
    • entityConstructor: Constructable<any, unknown>
    • Optional diff: boolean

    Returns Record<string, any>

Const serializeEntityNonCustomFields

  • serializeEntityNonCustomFields(entity: any, entityConstructor: Constructable<any, unknown>): Record<string, any>
  • Parameters

    • entity: any
    • entityConstructor: Constructable<any, unknown>

    Returns Record<string, any>

Const serializeEntityNonCustomFieldsV4

  • serializeEntityNonCustomFieldsV4(entity: any, entityConstructor: Constructable<any, unknown>): Record<string, any>
  • Parameters

    • entity: any
    • entityConstructor: Constructable<any, unknown>

    Returns Record<string, any>

serializeRequest

  • serializeRequest(request: MethodRequestBuilder<any>, options?: BatchRequestSerializationOptions): string
  • Serialize a multipart request to string.

    Parameters

    Returns string

    The serialized string representation of a multipart request, including the multipart headers.

serviceToken

  • Returns an access token that can be used to call the given service. The token is fetched via a client credentials grant with the credentials of the given service. If multiple instances of the provided service exist, the first instance will be selected. When a JWT is passed, the tenant of the JWT will be used when performing the grant. When no JWT is passed, the grant will be performed using the provider tenant.

    Throws an error if there is no instance of the given service type or the XSUAA service, or if the request to the XSUAA service fails.

    Parameters

    Returns Promise<string>

    Access token.

shouldHandleCsrfToken

splitBatchResponse

  • Split a batch response into an array of sub responses for the retrieve requests and changesets.

    Parameters

    Returns string[]

    A list of sub responses represented as strings.

splitChangeSetResponse

  • splitChangeSetResponse(changeSetResponse: string): string[]
  • Split a changeset (sub) response into an array of sub responses.

    Parameters

    • changeSetResponse: string

      The string representation of a change set response.

    Returns string[]

    A list of sub responses represented as strings.

splitResponse

  • splitResponse(response: string, boundary: string): string[]
  • Split a string representation of a response into sub responses given its boundary.

    Parameters

    • response: string

      The string representation of the response to split.

    • boundary: string

      The boundary to split by.

    Returns string[]

    A list of sub responses represented as strings.

startsWith

  • Build a filter function to test whether a string starts with another. Evaluates to boolean.

    Type parameters

    Parameters

    • str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The string to test. This can either be a string, a reference to a field or another filter function.

    • prefix: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The prefix to test for. This can either be a string, a reference to a field or another filter function.

    Returns BooleanFilterFunction<EntityT>

    The newly created filter function

subscriberFirst

  • subscriberFirst(allDestinations: AllDestinations, destinationName: string): Destination | null
  • Prioritizes the selection of subscriber destinations.

    Parameters

    • allDestinations: AllDestinations

      Retrieved destinations.

    • destinationName: string

      Name of the destination to retrieve.

    Returns Destination | null

    the destination to retrieve, returns null if no matched destination is found.

substring

  • Build a filter function to get a substring starting from a designated position. Evaluates to string.

    Type parameters

    Parameters

    • str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The string to get a substring from. This can either be a string, a reference to a field or another filter function.

    • pos: number | Field<EntityT, boolean, boolean> | NumberFilterFunction<EntityT>

      The starting position of the substring. This can be either a number, a reference to a field or another filter function.

    • Optional len: number | Field<EntityT, boolean, boolean> | NumberFilterFunction<EntityT>

      The length of the substring. This can be either a number, a reference to a field or another filter function.

    Returns StringFilterFunction<EntityT>

    The newly created filter function

substringOf

  • Build a filter function to test whether a string is a substring of the other. Evaluates to boolean.

    Type parameters

    Parameters

    • substr: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The substring to test for. This can either be a string, a reference to a field or another filter function.

    • str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The string to test. This can either be a string, a reference to a field or another filter function.

    Returns BooleanFilterFunction<EntityT>

    The newly created filter function

tenantFromJwt

  • tenantFromJwt(jwtPayload: JwtPayload): Tenant
  • Creates a tenant object from the JWT payload. Throws an error if the property id is not present in the payload.

    Parameters

    • jwtPayload: JwtPayload

      Token payload to get the tenant information from.

    Returns Tenant

    Representation of the tenant.

throwErrorWhenReturnTypeIsUnionType

  • throwErrorWhenReturnTypeIsUnionType(data: any, functionActionName: string): never
  • Parameters

    • data: any
    • functionActionName: string

    Returns never

timeToSeconds

  • timeToSeconds(time: Time): number
  • Converts the given time to seconds in positive numerical format.

    Parameters

    • time: Time

      Time to convert.

    Returns number

    number Time in seconds.

toBatchChangeSet

toBatchChangeSetV4

  • toBatchChangeSetV4<T>(changeSet: BatchChangeSet<T>): string | undefined

toBatchRetrieveBody

  • deprecated

    Since v1.30.0. Use serializeRequest instead. Build a string as the request body of the retrieve request. Below is an example of the generated body, where the two empty line are mandatory to make the request valid. *** example starts *** Content-Type: application/http Content-Transfer-Encoding: binary

    GET /SomeUrl/API_BUSINESS_PARTNER/A_BusinessPartnerBank?$format=json&$top=1 HTTP/1.1

    *** example ends ***

    Parameters

    Returns string

    The request body.

toBatchRetrieveBodyV4

  • deprecated

    Since v1.30.0. Use serializeRequest instead. Build a string as the request body of the retrieve request. Below is an example of the generated body, where the two empty line are mandatory to make the request valid. *** example starts *** Content-Type: application/http Content-Transfer-Encoding: binary

    GET /SomeUrl/API_BUSINESS_PARTNER/A_BusinessPartnerBank?$format=json&$top=1 HTTP/1.1

    *** example ends ***

    Parameters

    Returns string

    The request body.

toFilterableList

  • toFilterableList<EntityT, LinkedEntityT>(filters: Filterable<EntityT, LinkedEntityT>[]): Filterable<EntityT>[]
  • Type parameters

    Parameters

    Returns Filterable<EntityT>[]

Const toGuid

  • toGuid(value: string): string
  • Parameters

    • value: string

    Returns string

toLower

  • Build a filter function to transform a string to lower case. Evaluates to string.

    Type parameters

    Parameters

    • str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The string to transform. This can either be a string, a reference to a field or another filter function.

    Returns StringFilterFunction<EntityT>

    The newly created filter function

toPascalCase

  • toPascalCase(str: string): string
  • deprecated

    Since v1.32.2. Use functions from @sap-cloud-sdk/util instead. Converts a string to PascalCase format e.g. "MyNameInPascalCase".

    Parameters

    • str: string

      The string to be transformed.

    Returns string

    The transformed string.

toPropertyFormat

  • toPropertyFormat(str: string): string
  • deprecated

    Since v1.32.2. Use functions from @sap-cloud-sdk/util instead. Converts a string to the format used by properties. Use this for serialization.

    Parameters

    • str: string

      The string to be transformed.

    Returns string

    The transformed string.

toSanitizedHeaderObject

  • toSanitizedHeaderObject(key: string, value: any): Record<string, any>
  • deprecated

    Since v1.32.0. Use toSanitizedObject instead. Create a header object based on the given key and value if neither key nor value are nullish.

    Parameters

    • key: string

      Name of the header.

    • value: any

      Value of the header.

    Returns Record<string, any>

    • An object containing the given key and value of an empty object.

toStaticPropertyFormat

  • toStaticPropertyFormat(str: string): string
  • deprecated

    Since v1.32.2. Use functions from @sap-cloud-sdk/util instead. Converts a string to the format used by static properties. Use this for serialization.

    Parameters

    • str: string

      The string to be transformed.

    Returns string

    The transformed string.

toTitleFormat

  • toTitleFormat(str: string): string
  • deprecated

    Since v1.32.2. Use functions from @sap-cloud-sdk/util instead. Converts a string to a human readable format, e.g. it transforms to_BusinessPartner to To Business Partner. Use this for serialization.

    Parameters

    • str: string

      The string to be transformed.

    Returns string

    The transformed string.

toTypeNameFormat

  • toTypeNameFormat(str: string): string
  • deprecated

    Since v1.32.2. Use functions from @sap-cloud-sdk/util instead. Converts a string to the format used by properties. Use this for serialization.

    Parameters

    • str: string

      The string to be transformed.

    Returns string

    The transformed string.

toUpper

  • Build a filter function to transform a string to upper case. Evaluates to string.

    Type parameters

    Parameters

    • str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The string to transform. This can either be a string, a reference to a field or another filter function.

    Returns StringFilterFunction<EntityT>

    The newly created filter function

totalOffsetMinutes

  • Build a filter function to get the signed number of minutes in the time zone offset. Evaluates to int.

    Type parameters

    Parameters

    • date: Moment | Field<EntityT, boolean, boolean>

      The date to get the offset minutes for. This can either be a date (Moment) or a reference to a field.

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

trim

  • Build a filter function to trim whitespace from a string. Evaluates to string.

    Type parameters

    Parameters

    • str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>

      The string to trim whitespace from. This can either be a string, a reference to a field or another filter function.

    Returns StringFilterFunction<EntityT>

    The newly created filter function

urlAndAgent

  • urlAndAgent(targetUri: string): Pick<HttpRequestConfig, "baseURL" | "httpAgent" | "httpsAgent" | "proxy">
  • Builds part of the request config containing the URL and if needed proxy agents or normal http agents. Considers the no_proxy environment variable together with the targetUri.

    Parameters

    • targetUri: string

      Used as baseURL in request config.

    Returns Pick<HttpRequestConfig, "baseURL" | "httpAgent" | "httpsAgent" | "proxy">

    HttpRequestConfig containing baseUrl and http(s) agents.

useOrFetchDestination

  • Returns the parameter if it is a destination, calls getDestination otherwise (which will try to fetch the destination from the Cloud Foundry destination service).

    Fetching a destination requires:

    • a binding to exactly one XSUAA service instance with service plan "application"
    • a binding to a destination service instance

    If either of the prerequisites is not met or one of the services returns an error, this function will either throw an error or return a promise that rejects.

    Parameters

    Returns Promise<Destination | null>

    A promise resolving to the requested destination on success.

userApprovedServiceToken

  • deprecated

    Since v1.41.0 Use jwtBearerToken instead. Returns a user approved access token that can be used to call the given service on behalf of the given user. The token is fetched via user token + refresh token grant. This can be necessary for scenarios in which a token for a service is required, but the service needs to know about the user on whose behalf the request is performed (for example to let the destination service perform principal propagation with SAP S/4HANA Cloud).

    Throws an error if there is no instance of the given service type or the XSUAA service, or if the request to the XSUAA service fails.

    Parameters

    • userJwt: string

      The JWT of the user for whom the access token should be fetched.

    • service: string | Service

      The type of the service or an instance of Service.

    • Optional options: ResilienceOptions

      Options to influence resilience behavior (see ResilienceOptions). By default, usage of a circuit breaker is enabled.

    Returns Promise<string>

    A user approved access token.

userFromJwt

  • userFromJwt(jwtPayload: JwtPayload): User
  • Creates a user object from the decoded JWT. Throws an error if no id or userName property is present on the JWT payload.

    Parameters

    • jwtPayload: JwtPayload

      Token payload to get the user from.

    Returns User

    Representation of the user.

userTokenGrant

  • deprecated

    Since v1.41.0 Use jwtBearerTokenGrant instead. Executes a user token grant request against the given URI.

    Parameters

    • tokenServiceUrlOrXsuaaServiceCredentials: string | XsuaaServiceCredentials

      The URL of the token service or the credentials of a XSUAA service instance.

    • userJwt: string

      The JWT of the user on whose behalf the request is executed.

    • clientId: string

      The client_id of the target XSUAA service instance.

    • Optional options: ResilienceOptions

      Options to use by retrieving access token

    Returns Promise<UserTokenResponse>

    A promise resolving to the response of the XSUAA service.

verifyJwt

  • Verifies the given JWT and returns the decoded payload.

    Parameters

    • token: string

      JWT to be verified

    • Optional options: VerifyJwtOptions

      Options to control certain aspects of JWT verification behavior.

    Returns Promise<JwtPayload>

    A Promise to the decoded and verified JWT.

verifyJwtWithKey

  • verifyJwtWithKey(token: string, key: string): Promise<JwtPayload>
  • Verifies the given JWT with the given key and returns the decoded payload.

    Parameters

    • token: string

      JWT to be verified.

    • key: string

      Key to use for verification.

    Returns Promise<JwtPayload>

    A Promise to the decoded and verified JWT.

wrapJwtInHeader

  • wrapJwtInHeader(token: string): AxiosRequestConfig
  • Wraps the access token in header's authorization.

    Parameters

    • token: string

      Token to attach in request header

    Returns AxiosRequestConfig

    The request header that holds the access token

year

  • Build a filter function to get the year of a date. Evaluates to int.

    Type parameters

    Parameters

    • date: Moment | Field<EntityT, boolean, boolean>

      The date to get the year for. This can either be a date (Moment) or a reference to a field.

    Returns NumberFilterFunction<EntityT>

    The newly created filter function

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