@sap-cloud-sdk/core
- Version 1.54.2
- Published
- 1.64 MB
- 14 dependencies
- Apache-2.0 license
Install
npm i @sap-cloud-sdk/core
yarn add @sap-cloud-sdk/core
pnpm add @sap-cloud-sdk/core
Overview
[[include:core/README.md]]
@sap-cloud-sdk/core
Index
Variables
- circuitBreakerDefaultOptions
- clientCredentialsTokenCache
- content_transfer_encoding_line
- defaultDisallowedKeys
- deserializersCommon
- destinationCache
- DestinationSelectionStrategies
- destinationServiceCache
- entityDeserializerV2
- entityDeserializerV4
- entitySerializer
- entitySerializerV2
- entitySerializerV4
- EnvironmentAccessor
- filterFunctions
- filterFunctionsV4
- http_version
- mappingTenantFields
- mappingUserFields
- numberReturnTypeMapping
- oDataUri
- oDataUriV2
- oDataUriV4
- part_content_type_line
- responseDataAccessor
- responseDataAccessorV4
- serializersCommom
- serializersCommon
- uriConverter
- uriConverters
- uriConvertersCommon
- uriConvertersV2
- uriConvertersV4
- uriConverterV2
- uriConverterV4
- verificationKeyCache
Functions
- addAuthorizationHeader()
- addDestinationToRequestConfig()
- addProxyConfiguration()
- addProxyConfigurationInternet()
- addProxyConfigurationOnPrem()
- all()
- alwaysProvider()
- alwaysSubscriber()
- and()
- any()
- asc()
- audiences()
- basicHeader()
- buildAndAddAuthorizationHeader()
- buildAuthorizationHeaders()
- buildAxiosRequestConfig()
- buildCsrfHeaders()
- buildHeadersForDestination()
- buildHttpRequest()
- ceiling()
- checkMandatoryValue()
- clientCredentialsGrant()
- concat()
- contains()
- convertToUriForEdmString()
- createComplexType()
- createFilterFunction()
- createGetFilter()
- createGetResourcePathForKeys()
- customAttributes()
- day()
- decodeJwt()
- desc()
- deserializeBatchResponse()
- deserializeComplexType()
- deserializeComplexTypeV2()
- deserializeComplexTypeV4()
- deserializeEntity()
- deserializeEntityV2()
- deserializeEntityV4()
- destinationForServiceBinding()
- detectNewLineSymbol()
- edmDateTimeToMoment()
- edmToTs()
- edmToTsV2()
- edmToTsV4()
- endsWith()
- entityDeserializer()
- execute()
- executeHttpRequest()
- extractClientCredentials()
- extractCustomFields()
- extractEtagFromHeader()
- extractODataEtag()
- extractODataEtagV2()
- extractODataEtagV4()
- fetchInstanceDestinations()
- fetchSubaccountDestinations()
- fetchVerificationKeys()
- filterCustomRequestConfig()
- filterFunction()
- filterFunctionV4()
- filterNullishValues()
- floor()
- fractionalSeconds()
- fromEdmToNumber()
- fromNumberToEdm()
- getAgentConfig()
- getAuthHeaders()
- getAxiosConfigWithDefaults()
- getAxiosConfigWithDefaultsWithoutMethod()
- getCollectionResult()
- getDestination()
- getDestinationBasicCredentials()
- getDestinationByName()
- getDestinationCacheKey()
- getDestinationCacheKeyStrict()
- getDestinationConfig()
- getDestinationFromDestinationService()
- getDestinationFromEnvByName()
- getDestinationOptions()
- getDestinations()
- getDestinationsEnvVariable()
- getDestinationService()
- getDestinationServiceCredentials()
- getDestinationServiceCredentialsList()
- getDestinationServiceUri()
- getDestinationsFromEnv()
- getEdmType()
- getEntityConstructor()
- getEntityKeys()
- getEnvironmentVariable()
- getExpand()
- getExpandV2()
- getExpandV4()
- getFieldOptions()
- getGrantTokenCacheKey()
- getHeader()
- getHeaders()
- getHeaderValue()
- getLine()
- getLinkedCollectionResult()
- getOAuth2ClientCredentialsToken()
- getOrderBy()
- getProtocolOrDefault()
- getQueryParametersForFilter()
- getQueryParametersForOrderBy()
- getQueryParametersForSelection()
- getResourcePathForKeys()
- getResponseBody()
- getSelect()
- getSelectV2()
- getSelectV4()
- getService()
- getServiceCredentialsList()
- getServiceList()
- getSingleResult()
- getUrlProtocol()
- getVcapService()
- getXsuaaServiceCredentials()
- hasSubsequence()
- hasSubset()
- headerForClientCredentials()
- hour()
- indexOf()
- isBooleanFilterFunction()
- isCollectionResult()
- isComplexTypeNameSpace()
- isDestination()
- isDestinationConfiguration()
- isDestinationJson()
- isDestinationNameAndJwt()
- isEdmType()
- isExistentProperty()
- isExpandedProperty()
- isFilter()
- isFilterLambdaExpression()
- isFilterLink()
- isFilterList()
- isHttpSuccessCode()
- isIdenticalTenant()
- isNavigationProperty()
- isOf()
- isOrderableEdmType()
- isSelectedProperty()
- issuerUrl()
- isUnaryFilter()
- isUserToken()
- isWithETag()
- jwtBearerToken()
- jwtBearerTokenGrant()
- length()
- matchesPattern()
- maxDateTime()
- mergeHeaders()
- minDateTime()
- minute()
- momentToEdmDateTime()
- month()
- noDestinationErrorMessage()
- nonEnumerable()
- not()
- now()
- or()
- parseBatchResponse()
- parseDestination()
- parseEntityNameFromMetadataUri()
- parseHttpCode()
- parseProxyEnv()
- parseResponseData()
- prependDollar()
- proxyAgent()
- proxyHostAndPort()
- proxyStrategy()
- readPropertyWithWarn()
- refreshTokenGrant()
- removePropertyOnCondition()
- replaceDuplicateKeys()
- resolveService()
- retrieveJwt()
- round()
- sanitizeDestination()
- searchEnvVariablesForDestination()
- searchServiceBindingForDestination()
- second()
- secondsToTime()
- serializeBatchRequest()
- serializeChangeSet()
- serializeComplexType()
- serializeComplexTypeV2()
- serializeComplexTypeV4()
- serializeEntity()
- serializeEntityNonCustomFields()
- serializeEntityNonCustomFieldsV2()
- serializeEntityNonCustomFieldsV4()
- serializeEntityV2()
- serializeRequest()
- serviceToken()
- shouldHandleCsrfToken()
- splitBatchResponse()
- splitChangeSetResponse()
- splitResponse()
- startsWith()
- subscriberFirst()
- substring()
- substringOf()
- tenantFromJwt()
- throwErrorWhenReturnTypeIsUnionType()
- timeToSeconds()
- toBatchChangeSet()
- toBatchChangeSetV2()
- toBatchChangeSetV4()
- toBatchRetrieveBody()
- toBatchRetrieveBodyV2()
- toBatchRetrieveBodyV4()
- toDestinationNameUrl()
- toFilterableList()
- toGuid()
- toLower()
- toPascalCase()
- toPropertyFormat()
- toSanitizedHeaderObject()
- toStaticPropertyFormat()
- totalOffsetMinutes()
- toTitleFormat()
- toTypeNameFormat()
- toUpper()
- transformReturnValueForComplexType()
- transformReturnValueForComplexTypeList()
- transformReturnValueForComplexTypeListV2()
- transformReturnValueForComplexTypeListV4()
- transformReturnValueForComplexTypeV2()
- transformReturnValueForComplexTypeV4()
- transformReturnValueForEdmType()
- transformReturnValueForEdmTypeList()
- transformReturnValueForEdmTypeListV2()
- transformReturnValueForEdmTypeListV4()
- transformReturnValueForEdmTypeV2()
- transformReturnValueForEdmTypeV4()
- transformReturnValueForEntity()
- transformReturnValueForEntityList()
- transformReturnValueForEntityListV2()
- transformReturnValueForEntityListV4()
- transformReturnValueForEntityV2()
- transformReturnValueForEntityV4()
- transformReturnValueForUndefined()
- transformReturnValueForUndefinedV2()
- transformReturnValueForUndefinedV4()
- trim()
- tsToEdm()
- tsToEdmV2()
- tsToEdmV4()
- urlAndAgent()
- useOrFetchDestination()
- userApprovedServiceToken()
- userFromJwt()
- userTokenGrant()
- verifyJwt()
- verifyJwtWithKey()
- wrapJwtInHeader()
- year()
Classes
EntityBase
- asObject()
- entityBuilder()
- getCurrentMapKeys()
- getCurrentStateForKey()
- getCustomField()
- getCustomFields()
- getUpdatedCustomFields()
- getUpdatedProperties()
- getUpdatedPropertyNames()
- hasCustomField()
- initializeCustomFields()
- isConflictingCustomField()
- isVisitedEntity()
- remoteState
- setCustomField()
- setCustomFields()
- setOrInitializeRemoteState()
- setVersionIdentifier()
- versionIdentifier
ODataRequestConfig
- addCustomHeaders()
- addCustomQueryParameters()
- addCustomRequestConfiguration()
- appendedPaths
- appendPath()
- contentType
- customHeaders
- customQueryParameters
- customRequestConfiguration
- customServicePath
- defaultHeaders
- defaultServicePath
- fetchCsrfToken
- method
- payload
- prependDollarToQueryParameters()
- queryParameters()
- resourcePath()
UpdateRequestBuilderBase
- entity
- entitySerializer
- executeRequest()
- executeRequestRaw()
- extractODataEtag
- getPayload()
- ignoredFields()
- ignoreVersionIdentifier()
- isEmptyObject()
- oDataUri
- payloadManipulator
- prepare()
- replaceWholeEntityWithPut()
- requiredFields()
- setIgnoredFields()
- setRequiredFields()
- setVersionIdentifier()
- withCustomVersionIdentifier()
Interfaces
Destination
- authentication
- authTokens
- certificates
- clientId
- clientSecret
- cloudConnectorLocationId
- forwardAuthToken
- headers
- isTestDestination
- isTrustingAllCertificates
- keyStoreName
- keyStorePassword
- name
- origin
- originalProperties
- password
- proxyConfiguration
- proxyType
- queryParameters
- sapClient
- systemUser
- tokenServicePassword
- tokenServiceUrl
- tokenServiceUser
- type
- url
- username
Enums
Type Aliases
- ActionImportParameters
- AuthenticationType
- BatchResponse
- CollectionFieldType
- ComplexTypePropertyFields
- ConstructorOrField
- DeepFieldType
- DestinationOptions
- DestinationProxyType
- DestinationRetrievalOptions
- DestinationSelectionStrategy
- DestinationServiceCredentials
- EdmToPrimitive
- EdmToPrimitiveV2
- EdmToPrimitiveV4
- EdmType
- EdmTypeCommon
- EdmTypeDifferentConverters
- EdmTypeForEdmOrFieldType
- EdmTypeSameConverters
- EdmTypeSameConvertersUri
- EdmTypeShared
- EdmTypeV2
- EdmTypeV4
- EntityBuilderType
- EnumType
- ExclusiveEdmTypeV2
- ExclusiveEdmTypeV4
- ExecuteHttpRequestFn
- Expandable
- FieldType
- FieldTypeByEdmType
- Filterable
- FilterFunctionParameterType
- FilterFunctionPrimitiveParameterType
- FilterFunctionReturnType
- FilterFunctionReturnTypeV4
- FilterLambdaOperator
- FilterOperator
- FilterOperatorByType
- FunctionImportParameters
- HttpRequest
- IsOrderableField
- IsSelectableField
- JwtKeyMapping
- Method
- ODataVersionOf
- Orderable
- OrderableEdmType
- OrderableInput
- RegisteredJWTClaims
- RequestMethodType
- Selectable
- ServiceCredentials
- SimpleTypeFields
- XsuaaServiceCredentials
Namespaces
Variables
variable circuitBreakerDefaultOptions
const circuitBreakerDefaultOptions: { timeout: number; errorThresholdPercentage: number; volumeThreshold: number; resetTimeout: number;};
variable clientCredentialsTokenCache
const clientCredentialsTokenCache: { getGrantTokenFromCache: ( url: any, credentialsOrClientId: ClientCredentials | string ) => ClientCredentialsResponse | undefined; cacheRetrievedToken: ( url: any, credentialsOrClientId: ClientCredentials | string, token: ClientCredentialsResponse ) => void; clear: () => void; getCacheInstance: () => Cache<ClientCredentialsResponse>;};
variable content_transfer_encoding_line
const content_transfer_encoding_line: string;
Deprecated
Since v1.30.0.
variable defaultDisallowedKeys
const defaultDisallowedKeys: string[];
A list of request config keys that are not allowed to be customized by default.
variable deserializersCommon
const deserializersCommon: EdmTypeMapping;
variable destinationCache
const destinationCache: { retrieveDestinationFromCache: ( decodedJwt: Record<string, any>, name: string, isolation: IsolationStrategy ) => Destination | undefined; cacheRetrievedDestination: ( decodedJwt: Record<string, any>, destination: Destination, isolation: IsolationStrategy ) => void; cacheRetrievedDestinations: ( decodedJwt: Record<string, any>, retrievedDestinations: DestinationsByType, isolation: IsolationStrategy ) => void; clear: () => void; getCacheInstance: () => Cache<Destination>;};
variable DestinationSelectionStrategies
const 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.
variable destinationServiceCache
const destinationServiceCache: { retrieveDestinationsFromCache: ( targetUrl: string, decodedJwt: JwtPayload, isolationStrategy?: IsolationStrategy | undefined ) => Destination[] | undefined; cacheRetrievedDestinations: ( destinationServiceUri: string, decodedJwt: JwtPayload, destinations: Destination[], isolationStrategy?: IsolationStrategy | undefined ) => void; clear: () => void; getCacheInstance: () => Cache<Destination[]>;};
variable entityDeserializerV2
const entityDeserializerV2: EntityDeserializer<any>;
Entity deserializer instance for v2 entities. See [[EntityDeserializer]] for the provided methods.
variable entityDeserializerV4
const entityDeserializerV4: EntityDeserializer<any>;
Entity deserializer instance for v4 entities. See [[EntityDeserializer]] for the provided methods.
variable entitySerializer
const entitySerializer: EntitySerializer<any, any>;
Entity serializer instance for v2 entities. See [[EntitySerializer]] for the provided methods.
variable entitySerializerV2
const entitySerializerV2: EntitySerializer<any, any>;
Entity serializer instance for v2 entities. See [[EntitySerializer]] for the provided methods.
variable entitySerializerV4
const entitySerializerV4: EntitySerializer<any, any>;
Entity serializer instance for v4 entities. See [[EntitySerializer]] for the provided methods.
variable EnvironmentAccessor
const EnvironmentAccessor: { getDestinationBasicCredentials: typeof getDestinationBasicCredentials; getDestinationServiceCredentials: typeof getDestinationServiceCredentials; getDestinationServiceCredentialsList: typeof getDestinationServiceCredentialsList; getServiceCredentialsList: typeof getServiceCredentialsList; getServiceList: typeof getServiceList; getVcapService: typeof getVcapService; getEnvironmentVariable: typeof getEnvironmentVariable; getDestinationServiceUri: typeof getDestinationServiceUri; getXsuaaServiceCredentials: typeof getXsuaaServiceCredentials;};
Deprecated
Since v1.5.0. Use directly exported functions instead
variable filterFunctions
const filterFunctions: { substringOf: typeof substringOf; replace: typeof replace; endsWith: typeof import('../odata-common').endsWith; startsWith: typeof import('../odata-common').startsWith; length: typeof import('../odata-common').length; indexOf: typeof import('../odata-common').indexOf; substring: typeof import('../odata-common').substring; toLower: typeof import('../odata-common').toLower; toUpper: typeof import('../odata-common').toUpper; trim: typeof import('../odata-common').trim; concat: typeof import('../odata-common').concat; round: typeof import('../odata-common').round; floor: typeof import('../odata-common').floor; ceiling: typeof import('../odata-common').ceiling; day: typeof import('../odata-common').day; hour: typeof import('../odata-common').hour; minute: typeof import('../odata-common').minute; month: typeof import('../odata-common').month; second: typeof import('../odata-common').second; year: typeof import('../odata-common').year; isOf: typeof import('../odata-common').isOf;};
OData v2 specific filter functions
variable filterFunctionsV4
const filterFunctionsV4: { contains: typeof contains; matchesPattern: typeof matchesPattern; fractionalSeconds: typeof fractionalSeconds; totalOffsetMinutes: typeof totalOffsetMinutes; maxDateTime: typeof maxDateTime; minDateTime: typeof minDateTime; now: typeof now; hasSubset: typeof hasSubset; hasSubsequence: typeof hasSubsequence; endsWith: typeof import('../odata-common').endsWith; startsWith: typeof import('../odata-common').startsWith; length: typeof import('../odata-common').length; indexOf: typeof import('../odata-common').indexOf; substring: typeof import('../odata-common').substring; toLower: typeof import('../odata-common').toLower; toUpper: typeof import('../odata-common').toUpper; trim: typeof import('../odata-common').trim; concat: typeof import('../odata-common').concat; round: typeof import('../odata-common').round; floor: typeof import('../odata-common').floor; ceiling: typeof import('../odata-common').ceiling; day: typeof import('../odata-common').day; hour: typeof import('../odata-common').hour; minute: typeof import('../odata-common').minute; month: typeof import('../odata-common').month; second: typeof import('../odata-common').second; year: typeof import('../odata-common').year; isOf: typeof import('../odata-common').isOf;};
OData v4 specific filter functions
variable http_version
const http_version: string;
Deprecated
Since v1.30.0.
variable mappingTenantFields
const mappingTenantFields: JwtKeyMapping<Tenant, 'zid' | 'zdn'>;
Mapping between key name in the Tenant and key name in decoded JWT.
variable mappingUserFields
const 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
variable numberReturnTypeMapping
const numberReturnTypeMapping: Record< string, 'Edm.Decimal' | 'Edm.Double' | 'Edm.Int32'>;
variable oDataUri
const oDataUri: ODataUriBase;
Instance of the [[ODataUri]] conversion interface for OData v2.
variable oDataUriV2
const oDataUriV2: ODataUriBase;
Instance of the [[ODataUri]] conversion interface for OData v2.
variable oDataUriV4
const oDataUriV4: ODataUri;
Instance of the [[ODataUri]] conversion interface for OData v4.
variable part_content_type_line
const part_content_type_line: string;
Deprecated
Since v1.30.0.
variable responseDataAccessor
const responseDataAccessor: ResponseDataAccessor;
variable responseDataAccessorV4
const responseDataAccessorV4: ResponseDataAccessor;
variable serializersCommom
const serializersCommom: EdmTypeMapping;
Deprecated
Since v1.27.0. Use [[serializersCommon]] instead.
variable serializersCommon
const serializersCommon: EdmTypeMapping;
variable uriConverter
const uriConverter: UriConverter;
variable uriConverters
const uriConverters: UriConverterMapping;
variable uriConvertersCommon
const uriConvertersCommon: UriConverterMapping;
variable uriConvertersV2
const uriConvertersV2: UriConverterMapping;
variable uriConvertersV4
const uriConvertersV4: UriConverterMapping;
variable uriConverterV2
const uriConverterV2: UriConverter;
variable uriConverterV4
const uriConverterV4: UriConverter;
variable verificationKeyCache
const verificationKeyCache: Cache<TokenKey>;
Functions
function addAuthorizationHeader
addAuthorizationHeader: <RequestT extends ODataRequestConfig>( request: ODataRequest<RequestT>, headers: Record<string, string>) => Promise<Record<string, string>>;
Parameter request
an ODataRequest.
Parameter headers
The headers that should be added to.
Returns
The provided headers with the new authorization headers.
Deprecated
Since v1.20.0. Use [[buildAuthorizationHeaders]] instead. Adds authorization headers for a given ODataRequest to existing headers.
function addDestinationToRequestConfig
addDestinationToRequestConfig: <T extends HttpRequestConfig>( destination: Destination | DestinationNameAndJwt, requestConfig: T) => Promise<T & DestinationHttpRequestConfig>;
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.
Parameter destination
A destination or a destination name and a JWT.
Parameter requestConfig
Any object representing an HTTP request.
Returns
The given request config merged with the config built for the given destination.
function addProxyConfiguration
addProxyConfiguration: ( destination: Destination, jwt?: string) => Promise<Destination>;
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.
Parameter destination
The destination to which the proxy configuration should be added.
Parameter jwt
The JWT of the current user.
Returns
A promise resolving to the destination with the added proxy configuration.
Deprecated
Since v1.16.0. Use [[addProxyConfigurationOnPrem]] instead.
function 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.
Parameter destination
to which the proxy configuration is added.
Returns
Destination containing the configuration for web proxy.
function addProxyConfigurationOnPrem
addProxyConfigurationOnPrem: ( destination: Destination, jwt: string | JwtPair | undefined) => Promise<Destination>;
function all
all: <EntityT extends EntityBase, LinkedEntityT extends EntityBase>( ...filters: Filterable<EntityT, LinkedEntityT>[]) => FilterLambdaExpression<EntityT>;
Will return the entity if all elements of the one-to-many link relation fulfill the condition.
Parameter filters
A filter condition like MyEntity.someMultiLink.someProperty.eq('value')
Returns
The lambda filter function to be considered in the query
function alwaysProvider
alwaysProvider: ( allDestinations: AllDestinations, destinationName: string) => Destination | null;
Constraints the selection to provider destinations.
Parameter allDestinations
Retrieved destinations.
Parameter destinationName
Name of the destination to retrieve.
Returns
the destination to retrieve, returns
null
, if no matched provider destination is found.
function alwaysSubscriber
alwaysSubscriber: ( allDestinations: AllDestinations, destinationName: string) => Destination | null;
Constraints the selection to subscriber destinations.
Parameter allDestinations
Retrieved destinations.
Parameter destinationName
Name of the destination to retrieve.
Returns
the destination to retrieve, returns
null
, if no matched subscriber destination is found.
function and
and: { <EntityT extends Entity>( expressions: Filterable<EntityT>[] ): FilterList<EntityT>; <EntityT extends Entity>( ...expressions: Filterable<EntityT, any>[] ): FilterList<EntityT>;};
Combine [[Filterable]]s with logical
and
to create a [[FilterList]].Example:
Entity.requestBuilder().getAll().filter(and(filterExp1, filterExp2));Note that the [[GetAllRequestBuilder.filter | 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);Parameter expressions
Filterables to be combined with logical
and
.Returns
The newly created FilterList.
function any
any: <EntityT extends EntityBase, LinkedEntityT extends EntityBase>( ...filters: Filterable<EntityT, LinkedEntityT>[]) => FilterLambdaExpression<EntityT>;
Will return the entity if at least one element of the one-to-many link relation fulfills the condition.
Parameter filters
A filter condition like MyEntity.someMultiLink.someProperty.eq('value')
Returns
The lambda filter function to be considered in the query
function asc
asc: <EntityT extends Entity>( orderBy: OrderableInput<EntityT>) => Order<EntityT>;
Create new Order by
orderBy._fieldName
in ascending order.Parameter orderBy
Field or link to be ordered by
Returns
New order
function audiences
audiences: (decodedToken: JwtPayload) => Set<string>;
Retrieve the audiences of a decoded JWT based on the audiences and scopes in the token.
Parameter decodedToken
Token to retrieve the audiences from.
Returns
A set of audiences.
function basicHeader
basicHeader: (username: string, password: string) => string;
function buildAndAddAuthorizationHeader
buildAndAddAuthorizationHeader: ( destination: Destination) => (headers: Record<string, any>) => Promise<Record<string, string>>;
Parameter destination
A destination.
Parameter headers
The headers that should be added to.
Returns
The provided headers with the new authorization headers.
Deprecated
Since v1.20.0. Use [[buildAuthorizationHeaders]] instead. Adds authorization headers for a given destination to existing headers.
function buildAuthorizationHeaders
buildAuthorizationHeaders: ( destination: Destination, customAuthHeader?: AuthenticationHeaderCloud | AuthenticationHeaderOnPrem) => Promise<AuthenticationHeaders>;
function buildAxiosRequestConfig
buildAxiosRequestConfig: <T extends HttpRequestConfig>( destination: Destination | DestinationNameAndJwt, requestConfig?: Partial<T>) => Promise<AxiosRequestConfig>;
This API is experimental and might change in newer versions. Use with caution.
Parameter destination
A destination or a destination name and a JWT.
Parameter requestConfig
Any object representing an HTTP request.
Modifiers
@experimental
function buildCsrfHeaders
buildCsrfHeaders: <T extends HttpRequestConfig>( destination: Destination | DestinationNameAndJwt, requestConfig: Partial<T>) => Promise<Record<string, any>>;
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 therequestConfig
it will be appended to the destination's URL, an absolute URL overwrites the destination related URL.Parameter destination
The destination to get the headers from
Parameter requestConfig
An http request configuration containing additional information about the request, like URL or headers
Returns
A promise to an object containing the CSRF related headers
function buildHeadersForDestination
buildHeadersForDestination: ( destination: Destination, customHeaders?: Record<string, any>) => Promise<Record<string, string>>;
function buildHttpRequest
buildHttpRequest: ( destination: Destination | DestinationNameAndJwt, customHeaders?: Record<string, any>) => Promise<DestinationHttpRequestConfig>;
Builds a [[DestinationHttpRequestConfig]] for the given destination. If a destination name (and a JWT) are provided, it will try to resolve the destination.
Parameter destination
A destination or a destination name and a JWT.
Parameter customHeaders
Custom default headers for the resulting HTTP request.
Returns
A [[DestinationHttpRequestConfig]].
function ceiling
ceiling: <EntityT extends Entity>( num: number | Field<EntityT, boolean, boolean> | NumberFilterFunction<EntityT>, returnType?: 'double' | 'decimal') => NumberFilterFunction<EntityT>;
Build a filter function to ceil a number. Evaluates to double or decimal, defaults to double.
Parameter num
The number to ceil. This can either be a number, a reference to a field or another filter function.
Parameter returnType
The return type to use.
Returns
The newly created filter function
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.
Parameter key
The key of the representation in typescript
Parameter mapping
The mapping between the typescript keys and the JWT key
Parameter jwtPayload
JWT payload to check fo the given key.
function clientCredentialsGrant
clientCredentialsGrant: ( tokenServiceUrlOrXsuaaServiceCredentials: string | XsuaaServiceCredentials, clientCredentials: ClientCredentials, options?: ResilienceOptions, customBody?: Record<string, any>) => Promise<ClientCredentialsResponse>;
Parameter tokenServiceUrlOrXsuaaServiceCredentials
The URL of the token service or the credentials of a XSUAA service instance.
Parameter clientCredentials
Client credentials for which to request a token.
Parameter options
Options to use by retrieving access token.
Parameter customBody
Object containing value required for the body request.
Returns
A promise resolving to the response.
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.
function concat
concat: <EntityT extends Entity>( str1: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>, str2: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>) => StringFilterFunction<EntityT>;
Build a filter function to concatenate two strings. Evaluates to string.
Parameter str1
The first string to concatenate. This can either be a string, a reference to a field or another filter function.
Parameter str2
The second string to concatenate. This can either be a string, a reference to a field or another filter function.
Returns
The newly created filter function
function contains
contains: <EntityT extends Entity>( substr: | string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>, str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>) => BooleanFilterFunction<EntityT>;
Build a filter function to test whether a string is a substring of the other. Evaluates to boolean.
Parameter substr
The substring to test for. This can either be a string, a reference to a field or another filter function.
Parameter str
The string to test. This can either be a string, a reference to a field or another filter function.
Returns
The newly created filter function
function convertToUriForEdmString
convertToUriForEdmString: (value: any) => string;
function createComplexType
createComplexType: <ComplexT>( json: any, converters: { [converter: string]: CallableFunction }) => ComplexT;
Parameter json
A raw json object to deserialize a complex type from.
Parameter converters
A list of rules on how to convert json to the respective type in JavaScript or TypeScript.
Returns
A deserialized complex type representation.
Deprecated
Since v1.25.0. use [[deserializeComplexType]] instead.
function createFilterFunction
createFilterFunction: <EntityT extends Entity>( functionName: string, returnType: FilterFunctionReturnType, ...parameters: FilterFunctionParameterType<EntityT>[]) => | BooleanFilterFunction<EntityT> | NumberFilterFunction<EntityT> | StringFilterFunction<EntityT>;
function createGetFilter
createGetFilter: (uriConverter: UriConverter) => GetFilter;
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.
Parameter uriConverter
Uri converter for v2 or v4.
Returns
The filter getter. See interface [[GetFilter]]
function 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.
Parameter uriConverter
Uri converter for v2 or v4.
Returns
The filter getter. See [[GetFilter]]
function customAttributes
customAttributes: (jwtPayload: JwtPayload) => Map<string, string[]>;
Extracts the custom attributes from the JWT.
Parameter jwtPayload
Token payload to read the custom attributes from.
Returns
Custom attributes added by the XSUAA service to the issued JWT.
function day
day: <EntityT extends Entity>( date: moment.Moment | Field<EntityT, boolean, boolean>) => NumberFilterFunction<EntityT>;
Build a filter function to get the day of a date. Evaluates to int.
Parameter date
The date to get the day for. This can either be a date (Moment) or a reference to a field.
Returns
The newly created filter function
function decodeJwt
decodeJwt: (token: string) => JwtPayload;
Decode JWT.
Parameter token
JWT to be decoded
Returns
Decoded payload.
function desc
desc: <EntityT extends Entity>( orderBy: OrderableInput<EntityT>) => Order<EntityT>;
Create new Order by
orderBy._fieldName
in descending order.Parameter orderBy
Field or link to be ordered by
Returns
New order
function deserializeBatchResponse
deserializeBatchResponse: ( parsedBatchResponse: (ResponseData[] | ResponseData)[], entityToConstructorMap: Record<string, Constructable<Entity>>, responseDataAccessor: ResponseDataAccessor, deserializer: EntityDeserializer) => (ErrorResponse | ReadResponse | WriteResponses)[];
Deserialize the parsed batch response.
Parameter parsedBatchResponse
Two dimensional list of parsed batch sub responses.
Parameter entityToConstructorMap
A map that holds the entity type to constructor mapping.
Parameter responseDataAccessor
Response data access module.
Parameter deserializer
Entity deserializer.
Returns
An array of parsed sub responses of the batch response.
function deserializeComplexType
deserializeComplexType: ( json: Record<string, any>, complexType: import('..').ComplexTypeNamespace<any>) => any;
function deserializeComplexTypeV2
deserializeComplexTypeV2: ( json: Record<string, any>, complexType: import('..').ComplexTypeNamespace<any>) => any;
function deserializeComplexTypeV4
deserializeComplexTypeV4: ( json: Record<string, any>, complexType: import('..').ComplexTypeNamespace<any>) => any;
function deserializeEntity
deserializeEntity: ( json: any, entityConstructor: import('..').Constructable<any, unknown>, requestHeader?: any) => any;
function deserializeEntityV2
deserializeEntityV2: ( json: any, entityConstructor: import('..').Constructable<any, unknown>, requestHeader?: any) => any;
function deserializeEntityV4
deserializeEntityV4: ( json: any, entityConstructor: import('..').Constructable<any, unknown>, requestHeader?: any) => any;
function destinationForServiceBinding
destinationForServiceBinding: ( serviceInstanceName: string, options?: DestinationForServiceBindingsOptions) => Destination;
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.
Parameter serviceInstanceName
The name of the service.
Parameter options
Options to customize the behavior of this function.
Returns
A destination.
function detectNewLineSymbol
detectNewLineSymbol: (str: string) => string;
Detects the system dependent line break in a string.
Parameter str
The string to check for line breaks. Should have at least two lines, otherwise an error will be thrown.
Returns
The system dependent line break
function edmDateTimeToMoment
edmDateTimeToMoment: (edmDateTime: string) => moment.Moment;
This function can be used for both Edm.DateTime and and Edm.DateTimeOffset.
function edmToTs
edmToTs: <T extends EdmType>( value: any, edmType: EdmTypeShared<'v2'>) => EdmToPrimitive<T>;
function edmToTsV2
edmToTsV2: <T extends EdmType>( value: any, edmType: EdmTypeShared<'v2'>) => EdmToPrimitive<T>;
function edmToTsV4
edmToTsV4: <T extends EdmType>( value: any, edmType: EdmTypeShared<'v4'>) => EdmToPrimitive<T>;
function endsWith
endsWith: <EntityT extends Entity>( str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>, suffix: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>) => BooleanFilterFunction<EntityT>;
Build a filter function to test whether a string ends with another. Evaluates to boolean.
Parameter str
The string to test. This can either be a string, a reference to a field or another filter function.
Parameter suffix
The suffix to test for. This can either be a string, a reference to a field or another filter function.
Returns
The newly created filter function
function entityDeserializer
entityDeserializer: ( edmToTs: EdmToTsTypeV2 | EdmToTsTypeV4, 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
Parameter edmToTs
Converters emd input to ts values.
Parameter extractODataETag
Extractor for the ETag.
Parameter extractDataFromOneToManyLink
Extractor for data related to one to many links.
Returns
a entity deserializer as defined by [[EntityDeserializer]]
function execute
execute: <ReturnT>( executeFn: ExecuteHttpRequestFn<ReturnT>) => <T extends HttpRequestConfig>( destination: Destination | DestinationNameAndJwt, requestConfig: T, options?: HttpRequestOptions | undefined) => Promise<ReturnT>;
Takes as parameter a function that expects an [[HttpRequest]] and returns a Promise of [[HttpResponse]]. Returns a function that takes a destination and a request-config (extends [[HttpRequestConfig]]), builds an [[HttpRequest]] from them, and calls the provided execute function.
NOTE: If you simply want to execute a request without passing your own execute function, use [[executeHttpRequest]] instead.
Parameter executeFn
A function that can execute an [[HttpRequestConfig]].
Returns
A function expecting destination and a request.
function executeHttpRequest
executeHttpRequest: <T extends HttpRequestConfig>( destination: Destination | DestinationNameAndJwt, requestConfig: T, options?: HttpRequestOptions) => Promise<HttpResponse>;
Builds a [[DestinationHttpRequestConfig]] for the given destination, merges it into the given requestConfig and executes it (using Axios).
Parameter destination
A destination or a destination name and a JWT.
Parameter requestConfig
Any object representing an HTTP request.
Parameter options
An [[HttpRequestOptions]] of the http request for configuring e.g., csrf token delegation. By default, the SDK will not fetch the csrf token.
Returns
A promise resolving to an [[HttpResponse]].
function extractClientCredentials
extractClientCredentials: ( serviceCreds: ServiceCredentials) => ClientCredentials;
Extracts the credentials of a service into an instance of [[ClientCredentials]].
Parameter serviceCreds
The credentials of a service as read from VCAP_SERVICES.
Returns
A [[ClientCredentials]] instance.
function extractCustomFields
extractCustomFields: <EntityT extends Entity, JsonT>( json: Partial<JsonT>, entityConstructor: Constructable<EntityT>) => 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.
Parameter json
The JSON payload.
Parameter entityConstructor
The constructor function of the entity class.
Returns
An object containing the custom fields as key-value pairs.
function extractEtagFromHeader
extractEtagFromHeader: (headers: any) => string | undefined;
function extractODataEtag
extractODataEtag: (json: Record<string, any>) => string | undefined;
Extractor for the ETag for OData v2 responses used in [[entityDeserializer]].
Parameter json
Response data from which the ETag is extracted.
Returns
The ETag.
function extractODataEtagV2
extractODataEtagV2: (json: Record<string, any>) => string | undefined;
Extractor for the ETag for OData v2 responses used in [[entityDeserializer]].
Parameter json
Response data from which the ETag is extracted.
Returns
The ETag.
function extractODataEtagV4
extractODataEtagV4: (json: Record<string, any>) => string | undefined;
Extractor for the ETag for OData v4 responses used in [[entityDeserializer]].
Parameter json
Response data from which the ETag is extracted.
Returns
The ETag.
function fetchInstanceDestinations
fetchInstanceDestinations: ( destinationServiceUri: string, jwt: string, options?: ResilienceOptions & CachingOptions) => Promise<Destination[]>;
Fetches all instance destinations from the given URI.
Parameter destinationServiceUri
The URI of the destination service
Parameter jwt
The access token
Parameter options
Options to use by retrieving destinations
Returns
A promise resolving to a list of instance destinations
function fetchSubaccountDestinations
fetchSubaccountDestinations: ( destinationServiceUri: string, jwt: string, options?: ResilienceOptions & CachingOptions) => Promise<Destination[]>;
Fetches all subaccount destinations from the given URI.
Parameter destinationServiceUri
The URI of the destination service
Parameter jwt
The access token
Parameter options
Options to use by retrieving destinations
Returns
A promise resolving to a list of subaccount destinations
function fetchVerificationKeys
fetchVerificationKeys: { (xsuaaCredentials: XsuaaServiceCredentials, jku?: string): Promise<TokenKey[]>; (url: string, clientId: string, clientSecret: string): Promise<TokenKey[]>; (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.Parameter xsuaaCredentials
Credentials of the XSUAA service instance.
Parameter jku
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
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.Parameter url
URL of the XSUAA service instance.
Parameter clientId
Client ID of the XSUAA service instance.
Parameter clientSecret
Client secret of the XSUAA service instance.
Returns
An array of token keys.
Fetches verification keys from the XSUAA service for the given URL.
Parameter url
URL of the XSUAA service instance.
Returns
An array of token keys.
function filterCustomRequestConfig
filterCustomRequestConfig: ( customRequestConfig: Record<string, string>, disallowedKeys?: string[]) => Record<string, string>;
Filter disallowed keys from a given custom request config object.
Parameter customRequestConfig
a given custom request config object to be filtered
Parameter disallowedKeys
A list of keys that are not allowed to be customized.
Returns
Filtered custom request config object.
function filterFunction
filterFunction: { <EntityT extends Entity>( functionName: string, returnType: 'boolean', ...parameters: FilterFunctionParameterType<EntityT>[] ): BooleanFilterFunction<EntityT>; <EntityT extends Entity>( functionName: string, returnType: 'int' | 'double' | 'decimal', ...parameters: any[] ): NumberFilterFunction<EntityT>; <EntityT extends Entity>( functionName: string, returnType: 'string', ...parameters: any[] ): StringFilterFunction<EntityT>;};
function filterFunctionV4
filterFunctionV4: { <EntityT extends Entity>( functionName: string, returnType: 'boolean', ...parameters: FilterFunctionParameterType<EntityT>[] ): BooleanFilterFunction<EntityT>; <EntityT extends Entity>( functionName: string, returnType: 'int' | 'double' | 'decimal', ...parameters: any[] ): NumberFilterFunction<EntityT>; <EntityT extends Entity>( functionName: string, returnType: 'string', ...parameters: any[] ): StringFilterFunction<EntityT>; <EntityT extends Entity>( functionName: string, returnType: 'datetimeoffset', ...parameters: any[] ): DateFilterFunction<EntityT>; <EntityT extends Entity>( functionName: string, returnType: 'boolean[]', ...parameters: any[] ): CollectionFilterFunction<EntityT, boolean>; <EntityT extends Entity>( functionName: string, returnType: 'string[]', ...parameters: any[] ): CollectionFilterFunction<EntityT, string>; <EntityT extends Entity>( functionName: string, returnType: 'int[]' | 'double[]' | 'decimal[]', ...parameters: any[] ): CollectionFilterFunction<EntityT, number>; <EntityT extends Entity>( functionName: string, returnType: 'datetimeoffset[]', ...parameters: any[] ): CollectionFilterFunction<EntityT, moment.Moment>;};
function filterNullishValues
filterNullishValues: (headers?: Record<string, any>) => Record<string, any>;
Parameter headers
A header object to be filtered.
Returns
- A filtered header object containing only headers with non-nullish values.
Deprecated
Since v1.32.0. Use [[pickNonNullish]] instead.
Filter headers that have nullish values.
function floor
floor: <EntityT extends Entity>( num: number | Field<EntityT, boolean, boolean> | NumberFilterFunction<EntityT>, returnType?: 'double' | 'decimal') => NumberFilterFunction<EntityT>;
Build a filter function to floor a number. Evaluates to double or decimal, defaults to double.
Parameter num
The number to floor. This can either be a number, a reference to a field or another filter function.
Parameter returnType
The return type to use.
Returns
The newly created filter function
function fractionalSeconds
fractionalSeconds: <EntityT extends Entity>( date: moment.Moment | Field<EntityT, boolean, boolean>) => NumberFilterFunction<EntityT>;
Build a filter function to get the fractional seconds of a date. Evaluates to decimal.
Parameter date
The date to get the fractional seconds for. This can either be a date (Moment) or a reference to a field.
Returns
The newly created filter function
function fromEdmToNumber
fromEdmToNumber: (value: string | number) => number;
function fromNumberToEdm
fromNumberToEdm: (value: number) => number | string;
function getAgentConfig
getAgentConfig: (destination: Destination) => HttpAgentConfig | HttpsAgentConfig;
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.
Parameter destination
determining which kind of configuration is returned
Returns
The http or http-agent configuration.
function getAuthHeaders
getAuthHeaders: ( destination: Destination, customHeaders?: Record<string, any>) => Promise<AuthenticationHeaders>;
function getAxiosConfigWithDefaults
getAxiosConfigWithDefaults: () => HttpRequestConfig;
Builds an Axios config with default configuration i.e. no_proxy, default http and https agent and GET as request method.
Returns
AxiosRequestConfig with default parameters
function getAxiosConfigWithDefaultsWithoutMethod
getAxiosConfigWithDefaultsWithoutMethod: () => Omit<HttpRequestConfig, 'method'>;
function 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.
Parameter data
Response of the OData v4 service.
Returns
Collection extracted from the response.
function getDestination
getDestination: ( name: string, options?: DestinationOptions) => Promise<Destination | null>;
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
).Parameter name
The name of the destination to be retrieved.
Parameter options
Configuration for how to retrieve destinations from the destination service.
Returns
A promise returning the requested destination on success.
function getDestinationBasicCredentials
getDestinationBasicCredentials: () => BasicCredentials;
Basic Credentials Getter from Destination service credentials needed for JWT generator.
Returns
Basic credentials.
function getDestinationByName
getDestinationByName: (name: string) => Destination | null;
Parameter name
Name of the destination
Returns
The requested destination if existent, otherwise
null
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.
function getDestinationCacheKey
getDestinationCacheKey: ( decodedJwt: Record<string, any>, destinationName: string, isolationStrategy: IsolationStrategy) => string;
Parameter decodedJwt
The decoded JWT of the current request.
Parameter destinationName
The name of the destination.
Parameter isolationStrategy
The strategy used to isolate cache entries.
Returns
The cache key.
Deprecated
Since v1.52.0. Use [[getDestinationCacheKeyStrict]] instead. Calculates a cache key based on the jwt and destination name for the given isolation strategy. Cache keys for strategies are non-overlapping, i.e. using a cache key for strategy [[IsolationStrategy.Tenant]] will not result in a cache hit for a destination that has been cached with strategy [[IsolationStrategy.Tenant_User]].
function getDestinationCacheKeyStrict
getDestinationCacheKeyStrict: ( decodedJwt: Record<string, any>, destinationName: string, isolationStrategy?: IsolationStrategy) => string | undefined;
Calculates a cache key based on the jwt and destination name for the given isolation strategy. Cache keys for strategies are non-overlapping, i.e. using a cache key for strategy [[IsolationStrategy.Tenant]] will not result in a cache hit for a destination that has been cached with strategy [[IsolationStrategy.Tenant_User]].
Parameter decodedJwt
The decoded JWT of the current request.
Parameter destinationName
The name of the destination.
Parameter isolationStrategy
The strategy used to isolate cache entries.
Returns
The cache key.
function getDestinationConfig
getDestinationConfig: (dest?: string | Destination) => Destination | null;
function getDestinationFromDestinationService
getDestinationFromDestinationService: ( name: string, options: DestinationOptions) => Promise<Destination | null>;
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.
Parameter name
The name of the destination to be retrieved.
Parameter options
Configuration for how to retrieve destinations from the destination service.
Returns
A promise returning the requested destination on success.
function 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.
Parameter name
Name of the destination
Returns
The requested destination if existent, otherwise
null
function getDestinationOptions
getDestinationOptions: ( name: string, options?: DestinationOptions) => Promise<Destination | null>;
Parameter name
The name of the destination to be retrieved.
Parameter options
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
A promise returning the requested destination on success.
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.
function getDestinations
getDestinations: () => Destination[];
Returns
A list of destinations
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.
function getDestinationsEnvVariable
getDestinationsEnvVariable: () => string | undefined;
function getDestinationService
getDestinationService: () => Service;
Get destination service if one is present.
Returns
Destination service
Throws
Error in case no destination service is found in the VCAP variables
function getDestinationServiceCredentials
getDestinationServiceCredentials: () => any;
First 'destination' credentials getter.
Returns
The 'destination' credentials object or
null
, if it does not exist.
function getDestinationServiceCredentialsList
getDestinationServiceCredentialsList: () => DestinationServiceCredentials[];
Destination credentials getter.
Returns
A list of 'credentials' objects in 'destination' service.
function getDestinationServiceUri
getDestinationServiceUri: () => string | null;
Destination URI getter NOTICE: If there exist more than one destination/uri, the function returns the first entry.
Returns
The first existing uri in destination or
null
, if not found.
function getDestinationsFromEnv
getDestinationsFromEnv: () => Destination[];
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
A list of destinations
function getEdmType
getEdmType: <VersionT extends unknown>( complexTypeNameOrEdmType: string | EdmTypeShared<VersionT>, edmTypeOrUndefined?: EdmTypeShared<VersionT>) => EdmTypeShared<VersionT>;
Convenience method to get the [[EdmTypeShared]] from the overloaded constructor. The two scenarios are: -
complexTypeNameOrEdmType
is of typeEdmTypeShared
andedmTypeOrUndefined
isundefined
-complexTypeNameOrEdmType
is of typestring
andedmTypeOrUndefined
is of typeEdmTypeShared
Parameter complexTypeNameOrEdmType
Either the name of the complex type or the EDM type.
Parameter edmTypeOrUndefined
Either the EDM type or
undefined
.Returns
The EDM type resolved for the two arguments.
function getEntityConstructor
getEntityConstructor: <EntityT extends Entity, ComplexT>( fieldOf: ConstructorOrField<EntityT, ComplexT>) => Constructable<EntityT>;
Convenience method to get the entity constructor of the parent of a complex type.
Parameter fieldOf
Either an entity constructor or another complex type field.
Returns
The constructor of the transitive parent entity;
function getEntityKeys
getEntityKeys: <EntityT extends Entity>( entity: EntityT, entityConstructor: Constructable<EntityT>) => Record<string, any>;
Helper function that maps an entity to its keys map with their original names.
Parameter entity
Entity to map
Parameter entityConstructor
The constructor of the entity
Returns
object that includes all keys that represent given entity
function getEnvironmentVariable
getEnvironmentVariable: (name: string) => string | undefined | null;
Environment variables accessor.
Parameter name
Environment variable name.
Returns
Env variable value if defined. null: If not defined.
function getExpand
getExpand: <EntityT extends Entity>( 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.
Parameter selects
The selects which are expanded if necessary
Parameter entityConstructor
Constructor type of the entity to expand on
Returns
An object containing the query parameter or an empty object
function getExpandV2
getExpandV2: <EntityT extends Entity>( 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.
Parameter selects
The selects which are expanded if necessary
Parameter entityConstructor
Constructor type of the entity to expand on
Returns
An object containing the query parameter or an empty object
function getExpandV4
getExpandV4: <EntityT extends Entity>( expands: Expandable<EntityT>[] | undefined, entityConstructor: Constructable<EntityT>) => Partial<{ expand: string }>;
Get an object containing the given expand as a query parameter, or an empty object if none was given.
Parameter expands
The expands to transform to a query parameter
Parameter entityConstructor
Constructor type of the entity to expand on
Returns
An object containing the query parameter or an empty object
function getFieldOptions
getFieldOptions: < NullableT extends boolean = false, SelectableT extends boolean = false>( fieldOptions?: FieldOptions<NullableT, SelectableT>) => Required<FieldOptions<NullableT, SelectableT>>;
Get field options merged with default values. The given options take precedence.
Parameter fieldOptions
Given options.
Returns
Given options merged with default values.
function getGrantTokenCacheKey
getGrantTokenCacheKey: ( url: string, credentialsOrClientId: ClientCredentials | string) => string;
function getHeader
getHeader: (key: string, headers?: Record<string, any>) => Record<string, any>;
Parameter key
Name of the header to be found.
Parameter headers
Header object to be searched for given key.
Returns
- An object containing the given key (and value) in its original case, as found in
headers
or an empty object if not found.Deprecated
Since v1.32.0. Use [[pickIgnoreCase]] instead.
Find a header in a given header object, if available, independent of the case (lower / upper).
function getHeaders
getHeaders: ( keys: string[], headers?: Record<string, any>) => Record<string, any>;
Parameter keys
Name of the header to be found.
Parameter headers
Header object to be searched for given key.
Returns
- An object containing the given keys (and values) in its original case, as found in
headers
or an empty object if not found.Deprecated
Since v1.32.0. Use [[pickIgnoreCase]] instead.
Find headers in a given header object, if available, independent of the case (lower / upper).
function getHeaderValue
getHeaderValue: (key: string, headers?: Record<string, any>) => any | undefined;
Parameter key
Name of the header to be found.
Parameter headers
Header object to be searched for given key.
Returns
The value of the header with the given key or
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).
function getLine
getLine: (request: MethodRequestBuilder) => string;
Parameter request
One of [[GetAllRequestBuilder | getAll]], [[GetByKeyRequestBuilder | getByKey]], [[CreateRequestBuilder | create]], [[UpdateRequestBuilder | update]] or [[DeleteRequestBuilder | delete]] request builder.
Returns
The serialized request as
<HTTP method> <URL> <HTTP version>
.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
function 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.
Parameter data
Response of the one to many link.
Returns
Collection extracted from the response.
function getOAuth2ClientCredentialsToken
getOAuth2ClientCredentialsToken: ( destination: Destination) => Promise<ClientCredentialsResponse>;
Parameter destination
A destination having
OAuth2ClientCredentials
authentication typeReturns
A promise returning the requested access token on success.
Deprecated
Since v1.47.0. Retrieves an access token required for "OAuth2ClientCredentials" destination authentication type.
function getOrderBy
getOrderBy: <EntityT extends Entity>( 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.
Parameter orderBy
A list of orderables to get the query parameters for
Returns
An object containing the query parameter or an empty object
function getProtocolOrDefault
getProtocolOrDefault: (destination: Destination) => Protocol;
Extracts the http protocol from the destination URL. The default value is http if no protocol is given.
Parameter destination
URL of this destination is parsed
Returns
The protocol, either https or http.
Throws
Error in case a unsupported protocol is given in the destination URL like rfc://example.com.
function getQueryParametersForFilter
getQueryParametersForFilter: <EntityT extends Entity>( filter: Filterable<EntityT>, entityConstructor: Constructable<EntityT>) => Partial<{ filter: string }>;
Parameter filter
The filter to transform to a query parameter
Parameter entityConstructor
Constructor type of the entity to filter on
Returns
An object containing the query parameter or an empty object
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.
function getQueryParametersForOrderBy
getQueryParametersForOrderBy: <EntityT extends Entity>( orderBy: Orderable<EntityT>[]) => Partial<{ orderby: string }>;
Parameter orderBy
A list of orderables to get the query parameters for
Returns
An object containing the query parameter or an empty object
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.
function getQueryParametersForSelection
getQueryParametersForSelection: <EntityT extends Entity>( selects?: Selectable<EntityT>[]) => Partial<{ select: string; expand: string }>;
Parameter selects
The list of selectables to be transformed to query parameters
Returns
An object containing the query parameters or an empty object
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.
function getResourcePathForKeys
getResourcePathForKeys: <EntityT extends EntityBase>( keys: Record<string, FieldType> | undefined, entityConstructor: Constructable<EntityT>) => string;
Parameter keys
Key-value pairs where the key is the name of a key property of the given entity and the value is the respective value
Parameter entityConstructor
Constructor type of the entity to get the resource path for
Parameter uriConverter
OData version specific converter for strings in URIs
Returns
The path to the resource
Deprecated
Since v1.21.0. Use [[ODataUri.getResourcePathForKeys]] instead. Get the resource path of an entity specified by key-value pairs.
function getResponseBody
getResponseBody: (response: string) => string;
Get the response body from the string representation of a response.
Parameter response
String representation of a response.
Returns
The response body as a one line string.
function getSelect
getSelect: <EntityT extends Entity>( 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.Parameter selects
The list of selectables to be transformed to query parameters
Returns
An object containing the query parameters or an empty object
function getSelectV2
getSelectV2: <EntityT extends Entity>( 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.Parameter selects
The list of selectables to be transformed to query parameters
Returns
An object containing the query parameters or an empty object
function getSelectV4
getSelectV4: <EntityT extends Entity>( 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.
Parameter selects
The list of selectables to be transformed to query parameters
Returns
An object containing the query parameters or an empty object
function getService
getService: (service: string) => Service | undefined;
Returns the first found instance for the given service type.
Parameter service
The service type.
Returns
The first found service.
function getServiceCredentialsList
getServiceCredentialsList: (service: string) => any[];
Credentials list getter for a given service.
Parameter service
Service name
Returns
Fetched credentials objects of existing service in 'VCAP_SERVICES'.
function getServiceList
getServiceList: (service: string) => Service[];
Services getter for a given service.
Parameter service
Service name.
Returns
List of service bindings of the given type. Returns an empty array if no service binding exists for the given type.
function 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.
Parameter data
Response of the OData v4 service.
Returns
A single object extracted from the response.
function getUrlProtocol
getUrlProtocol: (destination: Destination) => Protocol | undefined;
Parameter destination
URL of this destination is parsed
Returns
The protocol either
undefined
if no://
is found or anything before the delimiter.Deprecated
Since v1.5.1. use getProtocolOrDefault instead Takes the destination URL and return everything before the
://
.
function 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
'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.
function getXsuaaServiceCredentials
getXsuaaServiceCredentials: ( token?: JwtPayload | string) => XsuaaServiceCredentials;
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".
Parameter token
Either an encoded or decoded JWT.
Returns
The credentials for a match, otherwise
null
.
function hasSubsequence
hasSubsequence: < EntityT extends Entity, ParamT extends unknown, ReturnT extends unknown>( 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.
Parameter subsequence
The subsequence to test for. This can either be an array, a reference to a field or another filter function.
Parameter sequence
The sequence to test. This can either be an array, a reference to a field or another filter function.
Returns
The newly created filter function
function hasSubset
hasSubset: < EntityT extends Entity, ParamT extends unknown, ReturnT extends unknown>( 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.
Parameter subset
The subset to test for. This can either be an array, a reference to a field or another filter function.
Parameter set
The set to test. This can either be an array, a reference to a field or another filter function.
Returns
The newly created filter function
function headerForClientCredentials
headerForClientCredentials: (clientCredentials: ClientCredentials) => string;
function hour
hour: <EntityT extends Entity>( date: moment.Moment | Field<EntityT, boolean, boolean>) => NumberFilterFunction<EntityT>;
Build a filter function to get the hour of a date. Evaluates to int.
Parameter date
The date to get the hour for. This can either be a date (Moment) or a reference to a field.
Returns
The newly created filter function
function indexOf
indexOf: <EntityT extends Entity>( str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>, substr: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>) => NumberFilterFunction<EntityT>;
Build a filter function to get the start index of a substring. Evaluates to int.
Parameter str
The string to get the index from. This can either be a string, a reference to a field or another filter function.
Parameter substr
The substring to get the index for. This can either be a string, a reference to a field or another filter function.
Returns
The newly created filter function
function isBooleanFilterFunction
isBooleanFilterFunction: <EntityT extends Entity>( filterable: Filterable<EntityT>) => filterable is BooleanFilterFunction<EntityT>;
function isCollectionResult
isCollectionResult: (data: any) => boolean;
Checks if the data contains a collection result.
Parameter data
Response of the OData v4 service
Returns
true
, if the data is a collection result
function isComplexTypeNameSpace
isComplexTypeNameSpace: (val: any) => val is ComplexTypeNamespace<any>;
function isDestination
isDestination: (destination: any) => destination is Destination;
function isDestinationConfiguration
isDestinationConfiguration: ( destination: any) => destination is DestinationConfiguration;
function isDestinationJson
isDestinationJson: (destination: any) => destination is DestinationJson;
function isDestinationNameAndJwt
isDestinationNameAndJwt: ( destination: any) => destination is DestinationNameAndJwt;
function isEdmType
isEdmType: ( val: any) => val is EdmTypeCommon | ExclusiveEdmTypeV2 | ExclusiveEdmTypeV4;
Check whether a value is an EdmType. This will yield positive results for every string starting with
Edm.
.Parameter val
Value to test.
Returns
Whether the given value is of type [[EdmTypeShared]]
function isExistentProperty
isExistentProperty: <EntityT extends Entity, LinkedEntityT extends Entity>( json: any, link: Link<EntityT, LinkedEntityT>) => boolean;
function isExpandedProperty
isExpandedProperty: <EntityT extends Entity, LinkedEntityT extends Entity>( json: any, link: Link<EntityT, LinkedEntityT>) => boolean;
function isFilter
isFilter: <T extends Entity, FieldT extends unknown>( filterable: Filterable<T>) => filterable is Filter<T, FieldT>;
function isFilterLambdaExpression
isFilterLambdaExpression: <EntityT extends Entity>( filterable: Filterable<EntityT>) => filterable is FilterLambdaExpression<EntityT>;
hidden
function isFilterLink
isFilterLink: <EntityT extends Entity, LinkedT extends Entity>( filterable: Filterable<EntityT>) => filterable is FilterLink<EntityT, LinkedT>;
function isFilterList
isFilterList: <T extends Entity>( filterable: Filterable<T>) => filterable is FilterList<T>;
function isHttpSuccessCode
isHttpSuccessCode: (httpCode: number) => boolean;
function isIdenticalTenant
isIdenticalTenant: ( userTokenPayload: JwtPayload, providerTokenPayload: JwtPayload) => boolean;
Compare two decoded JWTs based on their
tenantId
s.Parameter userTokenPayload
User JWT payload.
Parameter providerTokenPayload
Provider JWT payload.
Returns
Whether the tenant is identical.
function isNavigationProperty
isNavigationProperty: (key: string, entityConstructor: any) => boolean;
Checks if the property with name key of the entity is a navigation property.
Parameter key
Name of the property.
Parameter entityConstructor
Constructor of the entity.
Returns
A boolean denoting whether an entity is a navigation property or not.
function isOf
isOf: { <EntityT extends Entity>(type: string): BooleanFilterFunction<EntityT>; <EntityT extends Entity>( expression: Field<EntityT, boolean, boolean>, type: string ): BooleanFilterFunction<EntityT>;};
Build a filter function to test whether a selection is of a given type. Evaluates to boolean.
Parameter type
The type to test for, e. g.
API_BUSINESS_PARTNER.A_BusinessPartner
.Returns
The newly created filter function
Build a filter function to test whether a field is of a given type. Evaluates to boolean.
Parameter expression
A reference to a field to test for type.
Parameter type
The type to test for, e. g.
API_BUSINESS_PARTNER.A_BusinessPartner
.Returns
The newly created filter function
function isOrderableEdmType
isOrderableEdmType: (edmType: EdmTypeShared<'any'>) => boolean;
Convenience function to check whether a given EDM type is of type [[OrderableEdmType]].
Parameter edmType
Literal EDM type string to check.
Returns
Whether the given
edmType
is of type [[OrderableEdmType]].
function isSelectedProperty
isSelectedProperty: <EntityT extends Entity>( json: any, field: Field<EntityT> | Link<EntityT>) => boolean;
function issuerUrl
issuerUrl: (decodedToken: JwtPayload) => string | undefined;
Get the issuer URL of a decoded JWT.
Parameter decodedToken
Token to read the issuer URL from.
Returns
The issuer URL if available.
function isUnaryFilter
isUnaryFilter: <T extends Entity>( filterable: Filterable<T>) => filterable is UnaryFilter<T>;
function isUserToken
isUserToken: (token: JwtPair | undefined) => token is JwtPair;
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.
Parameter token
Token to be investigated
Returns
Boolean value with true if the input is a UserJwtPair
function isWithETag
isWithETag: (config: any) => config is WithETag;
function jwtBearerToken
jwtBearerToken: ( userJwt: string, service: string | Service, options?: ResilienceOptions) => Promise<string>;
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.
Parameter userJwt
The JWT of the user for whom the access token should be fetched
Parameter service
The type of the service or an instance of [[Service]].
Parameter options
Options to influence resilience behavior (see [[ResilienceOptions]]). By default, usage of a circuit breaker is enabled.
Returns
A jwt bearer token.
function jwtBearerTokenGrant
jwtBearerTokenGrant: ( tokenServiceUrlOrXsuaaServiceCredentials: string | XsuaaServiceCredentials, clientCredentials: ClientCredentials, userJwt: string, options?: ResilienceOptions) => Promise<ClientCredentialsResponse>;
Parameter tokenServiceUrlOrXsuaaServiceCredentials
The URL of the token service or the credentials of a XSUAA service instance.
Parameter clientCredentials
The credentials (client_id, client_secret) of the target XSUAA service instance.
Parameter userJwt
The JWT of the user on whose behalf the request is executed.
Parameter options
Options to use by retrieving access token.
Returns
A promise resolving to the response of the XSUAA service.
Deprecated
Since v1.49.0 Use
@sap/xssec
lib instead. Executes a JWT bearer token grant request against the given URI.
function length
length: <EntityT extends Entity>( str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>) => NumberFilterFunction<EntityT>;
Build a filter function to get the length of a string. Evaluates to int.
Parameter str
The string to compute the length for. This can either be a string, a reference to a field or another filter function.
Returns
The newly created filter function
function matchesPattern
matchesPattern: <EntityT extends Entity>( str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>, regex: string) => BooleanFilterFunction<EntityT>;
Build a filter function to test whether a string matches a pattern. Evaluates to boolean.
Parameter str
The string to get the index from. This can either be a string, a reference to a field or another filter function.
Parameter regex
The pattern to test against. This should be a regular expression as a string.
Returns
The newly created filter function
function maxDateTime
maxDateTime: <EntityT extends Entity>() => NumberFilterFunction<EntityT>;
Build a filter function to get the latest possible point in time. Evaluates to DateTimeOffset.
Returns
The newly created filter function
function mergeHeaders
mergeHeaders: ( headers?: Record<string, any>, customHeaders?: Record<string, any>) => Record<string, any>;
Parameter headers
A base header object that contains the headers that will be compared with
customHeaders
.Parameter customHeaders
A header object to be compared with headers. Only headers present in
headers
will be compared.Returns
- 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 bycustomHeaders
will be used.Deprecated
Since v1.32.0. Use [[mergeIgnoreCase]] instead.
Create a header object by merging two header objects, where the custom headers take precedence.
function minDateTime
minDateTime: <EntityT extends Entity>() => NumberFilterFunction<EntityT>;
Build a filter function to get the earliest possible point in time. Evaluates to DateTimeOffset.
Returns
The newly created filter function
function minute
minute: <EntityT extends Entity>( date: moment.Moment | Field<EntityT, boolean, boolean>) => NumberFilterFunction<EntityT>;
Build a filter function to get the minute of a date. Evaluates to int.
Parameter date
The date to get the minute for. This can either be a date (Moment) or a reference to a field.
Returns
The newly created filter function
function momentToEdmDateTime
momentToEdmDateTime: (momentInstance: moment.Moment) => string;
This function can be used for both Edm.DateTime and and Edm.DateTimeOffset.
function month
month: <EntityT extends Entity>( date: moment.Moment | Field<EntityT, boolean, boolean>) => NumberFilterFunction<EntityT>;
Build a filter function to get the month of a date. Evaluates to int.
Parameter date
The date to get the month for. This can either be a date (Moment) or a reference to a field.
Returns
The newly created filter function
function noDestinationErrorMessage
noDestinationErrorMessage: ( destination: Destination | DestinationNameAndJwt) => string;
function nonEnumerable
nonEnumerable: (target: any, propertyKey: string) => void;
function not
not: <EntityT extends Entity>( filter: Filterable<EntityT>) => UnaryFilter<EntityT>;
Negate a filter.
Parameter filter
The filter to negate.
Returns
The negated filter.
function now
now: <EntityT extends Entity>() => NumberFilterFunction<EntityT>;
Build a filter function to get the current point in time. Evaluates to DateTimeOffset.
Returns
The newly created filter function
function or
or: { <EntityT extends Entity>( expressions: Filterable<EntityT>[] ): FilterList<EntityT>; <EntityT extends Entity>( ...expressions: Filterable<EntityT, any>[] ): FilterList<EntityT>;};
Combine [[Filterable]]s with logical
or
to create a [[FilterList]].Example:
Entity.requestBuilder().getAll().filter(or(filterExp1, filterExp2));Parameter expressions
Filterables to be combined with logical
or
Returns
The newly created FilterList
function parseBatchResponse
parseBatchResponse: ( batchResponse: HttpResponse) => (ResponseData | ResponseData[])[];
Parse the complete batch HTTP response.
Parameter batchResponse
HTTP response of a batch request.
Returns
An array of parsed sub responses of the batch response.
function parseDestination
parseDestination: ( destinationJson: DestinationJson | DestinationConfiguration) => Destination;
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.
Parameter destinationJson
A JSON object returned by the destination service.
Returns
An SDK compatible destination object.
function 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.Parameter uri
The URI to parse the entity name from
Returns
The entity name.
function parseHttpCode
parseHttpCode: (response: string) => number;
Parse the HTTP code of response.
Parameter response
String representation of the response.
Returns
The HTTP code.
function parseProxyEnv
parseProxyEnv: (proxyEnvValue: string) => ProxyConfiguration | undefined;
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.Parameter proxyEnvValue
Environment variable which is parsed.
Returns
Configuration with default values or
undefined
if the parsing failed.
function parseResponseData
parseResponseData: (response: string) => ResponseData;
Parse the body and http code of a batch sub response.
Parameter response
A batch sub response.
Returns
The parsed response.s
function prependDollar
prependDollar: (param: string) => string;
function proxyAgent
proxyAgent: ( destination: Destination, options?: AgentOptions) => HttpAgentConfig | HttpsAgentConfig;
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
Parameter destination
Destination containing the proxy configurations
Parameter options
Additional options for the agent
Returns
The http(s)-agent containing the proxy configuration
function proxyHostAndPort
proxyHostAndPort: () => HostAndPort;
function proxyStrategy
proxyStrategy: (destination: Destination) => 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]].
Parameter destination
from which the proxy strategy is derived.
Returns
ProxyStrategy possible values are noProxy, internetProxy or onPremProxy.
function readPropertyWithWarn
readPropertyWithWarn: (jwtPayload: JwtPayload, property: string) => any;
function refreshTokenGrant
refreshTokenGrant: ( tokenServiceUrlOrXsuaaServiceCredentials: string | XsuaaServiceCredentials, clientCredentials: ClientCredentials, refreshToken: string, options?: ResilienceOptions) => Promise<UserTokenResponse>;
Parameter tokenServiceUrlOrXsuaaServiceCredentials
The URL of the token service or the credentials of a XSUAA service instance.
Parameter clientCredentials
The credentials (client_id, client_secret) of the target XSUAA service instance.
Parameter refreshToken
The refresh token that should be used to generate a new access token.
Parameter options
Options to use by retrieving access token.
Returns
A promise resolving to the response of the XSUAA service.
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.
function removePropertyOnCondition
removePropertyOnCondition: ( condition: (objectEntry: [string, any]) => boolean, body: Record<string, any>) => Record<string, any>;
function replaceDuplicateKeys
replaceDuplicateKeys: ( headers?: Record<string, any>, customHeaders?: Record<string, any>) => Record<string, any>;
Parameter headers
A base header object that contains the headers that will be compared with
customHeaders
.Parameter customHeaders
A header object to be compared with headers. Only headers present in
headers
will be compared.Returns
- An object containing all keys from the original
headers
object, where headers present in thecustomHeaders
are replaced. Note that the case (upper / lower) used bycustomHeaders
will be used.Deprecated
Since v1.32.0. Use [[mergeLeftIgnoreCase]] instead.
Create a header object by replacing headers that are set as custom headers.
function resolveService
resolveService: (service: string | Service) => Service;
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.
Parameter service
A string representing the service type or a [[Service]] instance.
Returns
A [[Service]] instance.
function 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 '.Parameter req
Request to retrieve the JWT from
Returns
JWT found in header
function round
round: <EntityT extends Entity>( num: number | Field<EntityT, boolean, boolean> | NumberFilterFunction<EntityT>, returnType?: 'double' | 'decimal') => NumberFilterFunction<EntityT>;
Build a filter function to round a number. Evaluates to double or decimal, defaults to double.
Parameter num
The number to round. This can either be a number, a reference to a field or another filter function.
Parameter returnType
The return type to use.
Returns
The newly created filter function
function sanitizeDestination
sanitizeDestination: (destination: Record<string, any>) => Destination;
Takes an existing or a parsed destination and returns an SDK compatible destination object.
Parameter destination
An object that adheres to the [[Destination]] interface.
Returns
An SDK compatible destination object.
function searchEnvVariablesForDestination
searchEnvVariablesForDestination: ( name: string, options?: DestinationOptions) => Destination | undefined;
function searchServiceBindingForDestination
searchServiceBindingForDestination: (name: string) => Destination | undefined;
function second
second: <EntityT extends Entity>( date: moment.Moment | Field<EntityT, boolean, boolean>) => NumberFilterFunction<EntityT>;
Build a filter function to get the second of a date. Evaluates to int.
Parameter date
The date to get the second for. This can either be a date (moment.Moment) or a reference to a field.
Returns
The newly created filter function
function secondsToTime
secondsToTime: (n: number) => Time;
Converts from seconds to time as [[Time]].
Parameter n
Number of seconds to convert (should be positive).
Returns
Time The converted time from the given number of seconds
function 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.
Parameter request
Batch request to serialize.
Parameter options
Request serialization options.
Returns
String representation of the batch request.
function serializeChangeSet
serializeChangeSet: ( changeSet: BatchChangeSet, options?: BatchRequestSerializationOptions) => string | undefined;
Serialize change set to string.
Parameter changeSet
Change set containing a collection of write operations.
Parameter options
Request serialization options.
Returns
The serialized string representation of a change set.
function serializeComplexType
serializeComplexType: (fieldValue: any, complexTypeNameSpace: any) => any;
function serializeComplexTypeV2
serializeComplexTypeV2: ( entity: any, entityConstructor: import('..').Constructable<any, unknown>, diff?: boolean | undefined) => Record<string, any>;
function serializeComplexTypeV4
serializeComplexTypeV4: (fieldValue: any, complexTypeNameSpace: any) => any;
function serializeEntity
serializeEntity: ( entity: any, entityConstructor: import('..').Constructable<any, unknown>, diff?: boolean | undefined) => Record<string, any>;
function serializeEntityNonCustomFields
serializeEntityNonCustomFields: ( entity: any, entityConstructor: import('..').Constructable<any, unknown>) => Record<string, any>;
function serializeEntityNonCustomFieldsV2
serializeEntityNonCustomFieldsV2: ( entity: any, entityConstructor: import('..').Constructable<any, unknown>) => Record<string, any>;
function serializeEntityNonCustomFieldsV4
serializeEntityNonCustomFieldsV4: ( entity: any, entityConstructor: import('..').Constructable<any, unknown>) => Record<string, any>;
function serializeEntityV2
serializeEntityV2: ( entity: any, entityConstructor: import('..').Constructable<any, unknown>, diff?: boolean | undefined) => Record<string, any>;
function serializeRequest
serializeRequest: ( request: MethodRequestBuilder, options?: BatchRequestSerializationOptions) => string;
Serialize a multipart request to string.
Parameter request
One of [[GetAllRequestBuilder | getAll]], [[GetByKeyRequestBuilder | getByKey]], [[CreateRequestBuilder | create]], [[UpdateRequestBuilder | update]] or [[DeleteRequestBuilder | delete]] request builder.
Parameter options
Request serialization options.
Returns
The serialized string representation of a multipart request, including the multipart headers.
function serviceToken
serviceToken: ( service: string | Service, options?: CachingOptions & ResilienceOptions & { userJwt?: string | JwtPayload; xsuaaCredentials?: XsuaaServiceCredentials; }) => Promise<string>;
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.
Parameter service
The type of the service or an instance of [[Service]].
Parameter options
Options to influence caching and resilience behavior (see [[CachingOptions]] and [[ResilienceOptions]], respectively) and a JWT. By default, caching and usage of a circuit breaker are enabled.
Returns
Access token.
function shouldHandleCsrfToken
shouldHandleCsrfToken: ( requestConfig: HttpRequestConfig, options: HttpRequestOptions) => boolean;
function splitBatchResponse
splitBatchResponse: (response: HttpResponse) => string[];
Split a batch response into an array of sub responses for the retrieve requests and changesets.
Parameter response
The raw HTTP response.
Returns
A list of sub responses represented as strings.
function splitChangeSetResponse
splitChangeSetResponse: (changeSetResponse: string) => string[];
Split a changeset (sub) response into an array of sub responses.
Parameter changeSetResponse
The string representation of a change set response.
Returns
A list of sub responses represented as strings.
function splitResponse
splitResponse: (response: string, boundary: string) => string[];
Split a string representation of a response into sub responses given its boundary.
Parameter response
The string representation of the response to split.
Parameter boundary
The boundary to split by.
Returns
A list of sub responses represented as strings.
function startsWith
startsWith: <EntityT extends Entity>( str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>, prefix: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>) => BooleanFilterFunction<EntityT>;
Build a filter function to test whether a string starts with another. Evaluates to boolean.
Parameter str
The string to test. This can either be a string, a reference to a field or another filter function.
Parameter prefix
The prefix to test for. This can either be a string, a reference to a field or another filter function.
Returns
The newly created filter function
function subscriberFirst
subscriberFirst: ( allDestinations: AllDestinations, destinationName: string) => Destination | null;
Prioritizes the selection of subscriber destinations.
Parameter allDestinations
Retrieved destinations.
Parameter destinationName
Name of the destination to retrieve.
Returns
the destination to retrieve, returns
null
if no matched destination is found.
function substring
substring: <EntityT extends Entity>( str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>, pos: number | Field<EntityT, boolean, boolean> | NumberFilterFunction<EntityT>, len?: number | Field<EntityT, boolean, boolean> | NumberFilterFunction<EntityT>) => StringFilterFunction<EntityT>;
Build a filter function to get a substring starting from a designated position. Evaluates to string.
Parameter str
The string to get a substring from. This can either be a string, a reference to a field or another filter function.
Parameter pos
The starting position of the substring. This can be either a number, a reference to a field or another filter function.
Parameter len
The length of the substring. This can be either a number, a reference to a field or another filter function.
Returns
The newly created filter function
function substringOf
substringOf: <EntityT extends Entity>( substr: | string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>, str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>) => BooleanFilterFunction<EntityT>;
Build a filter function to test whether a string is a substring of the other. Evaluates to boolean.
Parameter substr
The substring to test for. This can either be a string, a reference to a field or another filter function.
Parameter str
The string to test. This can either be a string, a reference to a field or another filter function.
Returns
The newly created filter function
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.Parameter jwtPayload
Token payload to get the tenant information from.
Returns
Representation of the tenant.
function throwErrorWhenReturnTypeIsUnionType
throwErrorWhenReturnTypeIsUnionType: ( data: any, functionActionName: string) => never;
function timeToSeconds
timeToSeconds: (time: Time) => number;
Converts the given time to seconds in positive numerical format.
Parameter time
Time to convert.
Returns
number Time in seconds.
function toBatchChangeSet
toBatchChangeSet: < T extends | CreateRequestBuilder<Entity> | UpdateRequestBuilder<Entity> | DeleteRequestBuilder<Entity>>( changeSet: BatchChangeSet<T>) => string | undefined;
Parameter changeSet
Change set containing a collection of write operations.
Returns
The serialized string representation of a change set.
Deprecated
Since v1.30.0. Use [[serializeChangeSet]] instead. Serialize change set to string.
function toBatchChangeSetV2
toBatchChangeSetV2: < T extends | CreateRequestBuilder<Entity> | UpdateRequestBuilder<Entity> | DeleteRequestBuilder<Entity>>( changeSet: BatchChangeSet<T>) => string | undefined;
Parameter changeSet
Change set containing a collection of write operations.
Returns
The serialized string representation of a change set.
Deprecated
Since v1.30.0. Use [[serializeChangeSet]] instead. Serialize change set to string.
function toBatchChangeSetV4
toBatchChangeSetV4: < T extends | CreateRequestBuilder<Entity> | UpdateRequestBuilder<Entity> | DeleteRequestBuilder<Entity>>( changeSet: BatchChangeSet<T>) => string | undefined;
Parameter changeSet
Change set containing a collection of write operations.
Returns
The serialized string representation of a change set.
Deprecated
Since v1.30.0. Use [[serializeChangeSet]] instead. Serialize change set to string.
function toBatchRetrieveBody
toBatchRetrieveBody: ( request: GetAllRequestBuilder<Entity> | GetByKeyRequestBuilder<Entity>) => string;
Parameter request
The request builder of the retrieve request.
Returns
The request body.
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 ***
function toBatchRetrieveBodyV2
toBatchRetrieveBodyV2: ( request: GetAllRequestBuilder<Entity> | GetByKeyRequestBuilder<Entity>) => string;
Parameter request
The request builder of the retrieve request.
Returns
The request body.
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 ***
function toBatchRetrieveBodyV4
toBatchRetrieveBodyV4: ( request: GetAllRequestBuilder<Entity> | GetByKeyRequestBuilder<Entity>) => string;
Parameter request
The request builder of the retrieve request.
Returns
The request body.
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 ***
function toDestinationNameUrl
toDestinationNameUrl: ( destination: Destination | DestinationNameAndJwt) => string;
function toFilterableList
toFilterableList: <EntityT extends Entity, LinkedEntityT extends Entity>( filters: Filterable<EntityT, LinkedEntityT>[]) => Filterable<EntityT>[];
function toGuid
toGuid: (value: string) => string;
function toLower
toLower: <EntityT extends Entity>( str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>) => StringFilterFunction<EntityT>;
Build a filter function to transform a string to lower case. Evaluates to string.
Parameter str
The string to transform. This can either be a string, a reference to a field or another filter function.
Returns
The newly created filter function
function toPascalCase
toPascalCase: (str: string) => string;
Parameter str
The string to be transformed.
Returns
The transformed string.
Deprecated
Since v1.32.2. Use functions from
@sap-cloud-sdk/util
instead. Converts a string to PascalCase format e.g. "MyNameInPascalCase".
function toPropertyFormat
toPropertyFormat: (str: string) => string;
Parameter str
The string to be transformed.
Returns
The transformed 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.
function toSanitizedHeaderObject
toSanitizedHeaderObject: (key: string, value: any) => Record<string, any>;
Parameter key
Name of the header.
Parameter value
Value of the header.
Returns
- An object containing the given key and value of an empty object.
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.
function toStaticPropertyFormat
toStaticPropertyFormat: (str: string) => string;
Parameter str
The string to be transformed.
Returns
The transformed 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.
function totalOffsetMinutes
totalOffsetMinutes: <EntityT extends Entity>( date: moment.Moment | Field<EntityT, boolean, boolean>) => NumberFilterFunction<EntityT>;
Build a filter function to get the signed number of minutes in the time zone offset. Evaluates to int.
Parameter date
The date to get the offset minutes for. This can either be a date (Moment) or a reference to a field.
Returns
The newly created filter function
function toTitleFormat
toTitleFormat: (str: string) => string;
Parameter str
The string to be transformed.
Returns
The transformed 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 transformsto_BusinessPartner
toTo Business Partner
. Use this for serialization.
function toTypeNameFormat
toTypeNameFormat: (str: string) => string;
Parameter str
The string to be transformed.
Returns
The transformed 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.
function toUpper
toUpper: <EntityT extends Entity>( str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>) => StringFilterFunction<EntityT>;
Build a filter function to transform a string to upper case. Evaluates to string.
Parameter str
The string to transform. This can either be a string, a reference to a field or another filter function.
Returns
The newly created filter function
function transformReturnValueForComplexType
transformReturnValueForComplexType: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT;
function transformReturnValueForComplexTypeList
transformReturnValueForComplexTypeList: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT[];
function transformReturnValueForComplexTypeListV2
transformReturnValueForComplexTypeListV2: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT[];
function transformReturnValueForComplexTypeListV4
transformReturnValueForComplexTypeListV4: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT[];
function transformReturnValueForComplexTypeV2
transformReturnValueForComplexTypeV2: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT;
function transformReturnValueForComplexTypeV4
transformReturnValueForComplexTypeV4: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT;
function transformReturnValueForEdmType
transformReturnValueForEdmType: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT;
function transformReturnValueForEdmTypeList
transformReturnValueForEdmTypeList: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT[];
function transformReturnValueForEdmTypeListV2
transformReturnValueForEdmTypeListV2: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT[];
function transformReturnValueForEdmTypeListV4
transformReturnValueForEdmTypeListV4: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT[];
function transformReturnValueForEdmTypeV2
transformReturnValueForEdmTypeV2: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT;
function transformReturnValueForEdmTypeV4
transformReturnValueForEdmTypeV4: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT;
function transformReturnValueForEntity
transformReturnValueForEntity: <ReturnT extends Entity>( data: any, entityConstructor: Constructable<ReturnT>) => ReturnT;
function transformReturnValueForEntityList
transformReturnValueForEntityList: <ReturnT extends Entity>( data: any, entityConstructor: Constructable<ReturnT>) => ReturnT[];
function transformReturnValueForEntityListV2
transformReturnValueForEntityListV2: <ReturnT extends Entity>( data: any, entityConstructor: Constructable<ReturnT>) => ReturnT[];
function transformReturnValueForEntityListV4
transformReturnValueForEntityListV4: <ReturnT extends Entity>( data: any, entityConstructor: Constructable<ReturnT>) => ReturnT[];
function transformReturnValueForEntityV2
transformReturnValueForEntityV2: <ReturnT extends Entity>( data: any, entityConstructor: Constructable<ReturnT>) => ReturnT;
function transformReturnValueForEntityV4
transformReturnValueForEntityV4: <ReturnT extends Entity>( data: any, entityConstructor: Constructable<ReturnT>) => ReturnT;
function transformReturnValueForUndefined
transformReturnValueForUndefined: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT;
function transformReturnValueForUndefinedV2
transformReturnValueForUndefinedV2: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT;
function transformReturnValueForUndefinedV4
transformReturnValueForUndefinedV4: <ReturnT>( data: any, builderFn: (data: any) => ReturnT) => ReturnT;
function trim
trim: <EntityT extends Entity>( str: string | Field<EntityT, boolean, boolean> | StringFilterFunction<EntityT>) => StringFilterFunction<EntityT>;
Build a filter function to trim whitespace from a string. Evaluates to string.
Parameter str
The string to trim whitespace from. This can either be a string, a reference to a field or another filter function.
Returns
The newly created filter function
function tsToEdm
tsToEdm: (value: any, edmType: EdmTypeShared<'v2'>) => any;
function tsToEdmV2
tsToEdmV2: (value: any, edmType: EdmTypeShared<'v2'>) => any;
function tsToEdmV4
tsToEdmV4: (value: any, edmType: EdmTypeShared<'v4'>) => any;
function urlAndAgent
urlAndAgent: ( targetUri: string) => Pick<HttpRequestConfig, 'url' | '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 thetargetUri
.Parameter targetUri
Used as baseURL in request config.
Returns
HttpRequestConfig containing baseUrl and http(s) agents.
function useOrFetchDestination
useOrFetchDestination: ( destination: Destination | DestinationNameAndJwt, options?: DestinationOptions) => Promise<Destination | null>;
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.
Parameter destination
A destination or the necessary parameters to fetch one.
Parameter options
Caching options by fetching destination.
Returns
A promise resolving to the requested destination on success.
function userApprovedServiceToken
userApprovedServiceToken: ( userJwt: string, service: string | Service, options?: ResilienceOptions) => Promise<string>;
Parameter userJwt
The JWT of the user for whom the access token should be fetched.
Parameter service
The type of the service or an instance of [[Service]].
Parameter options
Options to influence resilience behavior (see [[ResilienceOptions]]). By default, usage of a circuit breaker is enabled.
Returns
A user approved access token.
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.
function userFromJwt
userFromJwt: (jwtPayload: JwtPayload) => User;
Creates a user object from the decoded JWT. Throws an error if no
id
oruserName
property is present on the JWT payload.Parameter jwtPayload
Token payload to get the user from.
Returns
Representation of the user.
function userTokenGrant
userTokenGrant: ( tokenServiceUrlOrXsuaaServiceCredentials: string | XsuaaServiceCredentials, userJwt: string, clientId: string, options?: ResilienceOptions) => Promise<UserTokenResponse>;
Parameter tokenServiceUrlOrXsuaaServiceCredentials
The URL of the token service or the credentials of a XSUAA service instance.
Parameter userJwt
The JWT of the user on whose behalf the request is executed.
Parameter clientId
The client_id of the target XSUAA service instance.
Parameter options
Options to use by retrieving access token
Returns
A promise resolving to the response of the XSUAA service.
Deprecated
Since v1.41.0 Use [[jwtBearerTokenGrant]] instead. Executes a user token grant request against the given URI.
function verifyJwt
verifyJwt: (token: string, options?: VerifyJwtOptions) => Promise<JwtPayload>;
Verifies the given JWT and returns the decoded payload.
Parameter token
JWT to be verified
Parameter options
Options to control certain aspects of JWT verification behavior.
Returns
A Promise to the decoded and verified JWT.
function verifyJwtWithKey
verifyJwtWithKey: (token: string, key: string) => Promise<JwtPayload>;
Verifies the given JWT with the given key and returns the decoded payload.
Parameter token
JWT to be verified.
Parameter key
Key to use for verification.
Returns
A Promise to the decoded and verified JWT.
function wrapJwtInHeader
wrapJwtInHeader: (token: string) => { headers: { [key: string]: any; Authorization: string };};
Wraps the access token in header's authorization.
Parameter token
Token to attach in request header
Returns
The request header that holds the access token
function year
year: <EntityT extends Entity>( date: moment.Moment | Field