0.4.2 • Published 6 months ago

@sap/apihub-enterprise-service-provider v0.4.2

Weekly downloads
-
License
See LICENSE.txt
Repository
-
Last release
6 months ago

The apihub-enterprise-service-provider Repository

Overview

apihub-enterprise-service-provider is an npm package that provides the APIs necessary for exposing API Business Hub Enterprise destination systems, products and services. This package also exposes an interface for actions and queries related to the user's registration and subscription.

Usage

To add this package as a dependency in your package.json file, under the "dependencies" section, add the following dependency: "@sap/apihub-enterprise-service-provider": [Version]

Public APIs

ApiHubEntProviderRepository

getDestinations

Description: Provides a list of 'API Business Hub Enterprise' destination systems
Signature:

async getDestinations(filter?: Filter)

Input:
    filter (optional): For additional filters on the destination list to be received
Output: A list of API Business Hub Enterprise Destination Systems

getServiceRetriever

Description: Retrieves an instance of the API Business Hub Enterprise's implementation of the ServiceRetriever interface
Signature:

getServiceRetriever(): ApiHubEntServiceRetrieverInterface

Input: none
Output: An instance that implements the ApiHubEntServiceRetrieverInterface

ApiHubEntDestinationSystem

getProducts

Description: Provides a list of 'API Business Hub Enterprise' product systems
Signature:

getProducts(options?: Record<string, any>): Promise<ApiHubEntProductSystem[]>

Input:
    options (optional): Accepts the following optional parameters:
         credentials: For services that require authentication
Output: A list of API Business Hub Enterprise Product Systems

ApiHubEntProductSystem

getServices

Description: Provides a list of 'API Business Hub Enterprise' services
Signature:

async getServices(options?: Record<string, any>): Promise<Service[]>

Input:
    options (optional): Accepts the following optional parameters:
         credentials: For services that require authentication
Output: A list of services

getMetadata

Description: Provides the metadata of a 'API Business Hub Enterprise' service
Signature:

async getMetadata(
      service: Service, 
      encoding: EncodingMode, 
      options?: Record<string, any>, 
      _relativeUrl?: string, 
      credentials?: Authentication): Promise<ServiceMetadata>

Input:
    service: The details of the service we want to get the metadata for
    encoding: For metadata it should always be EncodingMode.XML
    options: Accepts the following parameters:
         apiHubKey: API Business Hub Enterprise authentication methods
    credentials (optional): For services that require authentication
Output: An object that contains the metadata XML string of the service

getJsonLiveData

Description: Provides live data from the 'API Business Hub Enterprise' service
Signature:

async getJsonLiveData(
      service: Service, 
      _relativeServiceUrl: string, 
      entityName: string, 
      options?: Record<string, any>): Promise<ServiceCommon>

Input:
    service: The details of the service we want to get the metadata for
    entityName: The name of the entity in the service we want the live data for
    options: Accepts the following parameters:
         apiHubKey: API Business Hub Enterprise authentication methods
        filter (optional): For additional query parameters to pass to the service. For example: new Filter(new Map([[ServiceRequestKey.TopRows, "2""]]))
Output: An object that contains a JSON string with live data from the service

getServiceSwagger

Description: Provides Swagger from the 'API Business Hub Enterprise' service
Signature:

async getServiceSwagger(serviceId: string): Promise<string | undefined>

Input:
    serviceId: The ID of the service that we want to get the Swagger for
Output: A JSON string with Swagger data of the service

AdministrationManager

getSubscriptions

Description: A static method that retrieves the user's subscriptions
Signature:

static async getSubscriptions(
    destinationName:string, 
    userName: string, 
    productName?: string, 
    options?: Record<string, any>)
    : Promise<ApiHubEntSubscription[]>

Input:
    destinationName: The name of the destination system
    userName: The name of the current user
    productName (optional): Product's name in order to get the subscription list for only that specific product
    options (optional): Accepts the following optional parameters:
         credentials: For services that require authentication
Output: A list of the user's subscriptions in this destination system

getRegistrationData

Description: A static method that retrieves the user's registration information
Signature:

  static async getRegistrationData(
    destinationName:string, 
    userName: string, 
    options?: Record<string, any>)
    : Promise<RegistrationData | undefined>

Input:
    destinationName: The name of the destination system
    userName: The name of the current user
    options (optional): Accepts the following optional parameters:
         credentials: For services that require authentication
Output: A RegistrationData object

registerUser

Description: A static method that registers the user
Signature:

  static async registerUser(
    registrationParams: RegistrationParams, 
    options?: Record<string, any>)
    : Promise<RegistrationData>

Input:
    RegistrationParams: An input object with all the parameters for the registration request
    options (optional): Accepts the following optional parameters:
         credentials: For services that require authentication
Output: A RegistrationData object

subscribeUser

Description: A static method that subscribes the user's app
Signature:

static async subscribeUser(
  subscriptionParams: SubscriptionParams, 
  options?: Record<string, any>)
  : Promise<SubscribeResponse>

Input:
    SubscriptionParams: An input object with all the parameters for the subscription request
    options (optional): Accepts the following optional parameters:
         credentials: For services that require authentication
Output: A SubscribeResponse object with the response to the registration request

getAdministrationRaw

Description: Retrieves an instance of the API Business Hub Enterprise's implementation of the ServiceRetriever interface
Signature:

  static getAdministrationRaw() :AdministrationManagerRawInterface

Input: none
Output: An instance that implements the AdministrationManagerRawInterface

Types

API Business Hub Enterprise Subscription

productId: string
appName: string
id: string
title: string
description: string
appKey: string
creationDate: string
isSubscribed: boolean

Registration Parameters

destinationName (string): API Business Hub Enterprise destination provider system
userId (string): The current user's username
firstName (string): The current user's first name
lastName (string): The current user's last name
emailId (string): The current user's email address
country (string): The current user's country
roles (AccessRole[]): The list of roles associated with the user

Access Role

role (SubscriptionRole): System role
status (SubscriptionStatus, optional): The current user's first name
requestReason (string, optional): The current user's last name

Registration Data

accessRoles: AccessRole[]

Subscription Parameters

destinationName (string): API Business Hub Enterprise destination provider system
username (string): The current user's username
productName (string): The product name to register to
appName (string): The user's application name to register

Subscribe Response

key: string: unknown

Example Flow

Can be found at test\flow\testFlow.ts