Options to use while fetching destinations. Encompasses both DestinationCachingOptions and ResilienceOptions interfaces.
Union type to represent all possible types of a field.
A union of all types that can be used for filtering.
Type of the entity to be filtered on
Internal representation of all parameters of a function import as a map
External represenation of all parameters
A union of all types that can be used for ordering.
Type of the entity to be ordered
A union of all types that can be used as input for ordering.
Type of the entity to be ordered
Represents all selectables, i.e. everything that can be used in a .select
statement.
Type of the entity to be selected on
Builds a DestinationHttpRequestConfig for the given destination, merges it into the given requestConfig and executes it (using Axios).
Adds authorization headers for a given ODataRequest to existing headers.
an ODataRequest.
The headers that should be added to.
The provided headers with the new authorization headers.
Builds a DestinationHttpRequestConfig for the given destination and then merges it into the given requestConfig. NOTE: If the properties baseURL, httpClient, and httpsClient exist on the given requestConfig, they will be overwritten. Headers will be merged, whereby any headers built from the given destination will overwrite existing headers (e.g. the Authorization header).
A destination or a destination name and a JWT.
Any object representing an HTTP request.
The given request config merged with the config built for the given 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.
The destination to which the proxy configuration should be added.
The JWT of the current user.
A promise resolving to the destiation with the added proxy configuration.
Constraints the selection to provider destinations.
Retrieved destinations
Name of the destination to retrieve
the destination to retrieve, returns null if no matched provider destination is found
Constraints the selection to subscriber destinations.
Retrieved destinations
Name of the destination to retrieve
the destination to retrieve, returns null if no matched subscriber destination is found
Create a FilterList by combining Filterables with logical and
.
Example:
Entity.requestBuilder()
.getAll()
.filter(and(filterExp1, filterExp2));
Note that the GetAllRequestBuilder.filter method takes a rest parameter and thereby an array of filter expressions that are then combined conjunctively. As a consequence following is equivalent to the example above:
Entity.requestBuilder()
.getAll()
.filter(filterExp1, filterExp2);
Type of the entity to be filtered on
Filterables to be combined with logical and
The newly created FilterList
Create new Order by orderBy.fieldName
in ascending order.
Type of the entity to be ordered
Field or link to be ordered by
New order
Retrieve the audiences of a decoded JWT based on the audiences and scopes in the token.
Token to retrieve the audiences from.
A set of audiences.
Adds authorization headers for a given destination to existing headers.
A destination.
The provided headers with the new authorization headers.
Create object containing all headers, including custom headers for a given OData request configuration and destination. Custom headers override duplicate headers.
OData request configuration to create headers for
Key-value pairs where the key is the name of a header property and the value is the respective value
Builds the authorization, proxy authorization and SAP client headers for a given destination.
A destination.
HTTP headers for the given destination.
Builds a DestinationHttpRequestConfig for the given destination. If a destination name (and a JWT) are provided, it will try to resolve the destination.
A destination or a destination name and a JWT.
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 an URI, the response will not be verified.
The URI or the credentials of a XSUAA service instance.
Client credentials for which to request a token
Options to use by retrieving access token
Object containing value required for the body request
A promise resolving to the response
Decode JWT.
JWT to be decoded
Decoded payload.
Create new Order by orderBy.fieldName
in descending order.
Type of the entity to be ordered
Field or link to be ordered by
New order
Converts the JSON payload for a single entity into an instance of the corresponding generated entity class.
The JSON payload.
The constructor function of the entity class.
An instance of the entity class.
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.
The name of the service.
Options to customize the behavior of this function.
A destination.
Takes as paramter a function that expects an HttpRequest and returns a Promise of HttpResponse. Returns a function that takes a destination and a request, 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!
Optional: a function that can execute an HttpRequestConfig.
A function expecting destination and a request.
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.
The JSON payload.
The constructor function of the entity class.
An object containing the custom fields as key-value pairs.
Fetches a specific destination by name from the given URI, including authorization tokens. For destinations with authenticationType OAuth2SAMLBearerAssertion, this call will trigger the OAuth2SAMLBearerFlow against the target destination.
The URI of the destination service
The access token
The name of the desired destination
Options to use by retrieving destinations
A Promise resolving to the destination
Fetches all instance destinations from the given URI.
The URI of the destination service
The access token
Options to use by retrieving destinations
A promise resolving to a list of instance destinations
Fetches all subaccount destinations from the given URI.
The URI of the destination service
The access token
Options to use by retrieving destinations
A promise resolving to a list of subaccount destinations
Builds a destination from one of three sources (in the given order):
If you want to get a destination only from a specific source, use the corresponding function directly
(getDestinationFromEnvByName
, destinationForServiceBinding
, getDestinationFromDestinationService
).
The name of the destination to be retrieved.
Configuration for how to retrieve destinations from the destination service.
A promise returning the requested destination on success.
Basic Credentials Getter from Destination service credentials needed for JWT generator.
credentials.
Name of the destination
The requested destination if existent, otherwise 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.
The name of the destination to be retrieved.
Configuration for how to retrieve destinations from the destination service.
A promise returning the requested destination on success.
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.
Name of the destination
The requested destination if existent, otherwise null
The name of the destination to be retrieved.
The options of the fetching query of the destination that include the JWT of the current request and the strategy for selecting a destination.
A promise returning the requested destination on success.
First 'destination' credentials getter.
'destination' credentials object. null: if there is no existing 'destination' credentials
Destination credentials getter.
Destination URI getter NOTICE: If there exist more than one destination/uri, the function returns the first entry.
A list of destinations
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.
A list of destinations
Helper function that maps an entity to its keys map with their original names.
Entity to map
The constructor of the entity
object that includes all keys that represent given entity
Environment variables accessor.
Environment variable name.
Env variable value if defined. null: If not defined.
Retrieves an access token required for "OAuth2ClientCredentials" destination authentication type.
A destination having OAuth2ClientCredentials
authentication type
A promise returning the requested access token on success.
Get an object containing the given filter as query parameter, or an empty object if none was given.
Type of the entity to filter on
The filter to transform to a query parameter
Constructor type of the entity to filter on
} An object containing the query parameter or an empty object
Get an object containing the given order bys as query parameter, or an empty object if none was given.
Type of the entity to order
A list of orderables to get the query parameters for
} An object containing the query parameter or an empty object
Get an object containing the given Selectables as query parameter, or an empty object if none were given.
This retrieves where in addition to the selection (select
) there is also an expansion (expand
) needed.
Type of the entity to get the selection for
The list of selectables to be transformed to query parameters
An object containing the query parameters or an empty object
Get the resource path of an entity specified by key-value pairs.
Type of the entity to get the resource path for
Key-value pairs where the key is the name of a key property of the given entity and the value is the respective value
Constructor type of the entity to get the resource path for
The path to the resource
Credentials list getter for a given service.
Fetched credentials objects of existing service in 'VCAP_SERVICES'.
Services getter for a given service.
Service name.
List of service bindings of the given type. Returns an empty array if no service binding exists for the given type.
'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).
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 returns null. If no decoded JWT is specified, then returns the first existing XSUAA credential service plan "application".
Either an encoded or decoded JWT.
The credentials for a match, otherwise null.
Compare two decoded JWTs based on their tenantIds.
User JWT
Provider JWT
Whether the tenant is identical.
Get the issuer url of a decoded JWT.
Token to read the issuer url from.
The issuer url if available.
Create a FilterList by combining Filterables with logical or
.
Example:
Entity.requestBuilder()
.getAll()
.filter(or(filterExp1, filterExp2));
Type of the entity to be filtered on
Filterables to be combined with logical or
The newly created FilterList
Takes a JSON object returned by any of the calls to the destination service and returns an SDK compatible destination object.
A JSON object returned by the destination service.
An SDK compatible destination object.
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.
The URI or the credentials of a XSUAA service instance.
The credentials (client_id, client_secret) if the target XSUAA service instance.
The refresh token that should be used to generate a new access token.
Options to use by retrieving access token.
A promise resolving to the response of the XSUAA service.
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
Request to retrieve the JWT from
JWT found in header
Takes an existing or a parsed destination and returns an SDK compatible destination object.
A JSON object returned by the destination service.
An SDK compatible destination object.
Converts from seconds to time in HH:MM:SS format.
Number of seconds to convert (should be positive).
Time The converted time from the given number of seconds
Converts an instance of an entity class into a JSON payload to be sent to an OData service.
An instance of an entity.
The constructor function of that entity.
JSON.
Converts an instance of an entity class into a JSON payload to be sent to an OData service, ignoring custom fields.
An instance of an entity.
The constructor function of that entity.
JSON.
Prioritizes the selection of subscriber destinations.
Retrieved destinations
Name of the destination to retrieve
the destination to retrieve, returns null if no matched destination is found
Get the tenant id of a decoded JWT.
Token to read the tenant id from.
The tenant id if available.
Converts the given time to seconds in positive numerical format.
Time to convert.
number Time in seconds.
Converts a string to the format used by properties. Use this for serialization in the VDM.
The string to be transformed.
The transformed string.
Converts a string to the case used by static helpers in the VDM. Use this for serialization in the VDM.
The string to be transformed.
The input string in the case used by static helpers in the VDM.
Converts a string to a human readable format, e.g. it transforms to_BusinessPartner
to To Business Partner
. Use this for serialization in the VDM.
The string to be transformed.
The transformed string.
Converts a string to the format used by properties. Use this for serialization in the VDM.
The string to be transformed.
The transformed string.
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:
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.
A destination or the necessary parameters to fetch one.
Caching options by fetching destination.
A promise resolving to the requested destination on success.
Get the user id of a decoded JWT.
Token to read the user id from.
The user id if available.
Executes a user token grant request against the given URI.
The URI of the target XSUAA service instance.
The JWT of the user on whose behalf the request is executed.
The client_id of the target XSUAA service instance.
Options to use by retrieving access token
A promise resolving to the response of the XSUAA service.
Verifies the given JWT and returns the decoded payload.
JWT to be verified
A Promise to the decoded and verified JWT.
Verifies the given JWT with the given key and returns the decoded payload.
JWT to be verified
Key to use for verification
A Promise to the decoded and verified JWT.
Wraps the access token in header's authorization.
Token to attach in request header
The request header that holds the access token
Selector of destination selection strategies. See alwaysProvider, alwaysSubscriber and subscriberFirst for more information available selection strategies.
cloud-sdk-core
This is the core of the SAP Cloud SDK for JavaScript. It contains the core functionality for the Virtual Data Model (VDM) as well as the Cloud Platform abstractions.