Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CubaApp

Hierarchy

  • CubaApp

Index

Constructors

constructor

  • new CubaApp(name?: string, apiUrl?: string, restClientId?: string, restClientSecret?: string, defaultLocale?: string, storage?: Storage, apiVersion?: any): CubaApp
  • Parameters

    • Default value name: string = ""
    • Default value apiUrl: string = "/app/rest/"
    • Default value restClientId: string = "client"
    • Default value restClientSecret: string = "secret"
    • Default value defaultLocale: string = "en"
    • Default value storage: Storage = new DefaultStorage()
    • Optional apiVersion: any

    Returns CubaApp

Properties

apiUrl

apiUrl: string

Optional apiVersion

apiVersion: any

defaultLocale

defaultLocale: string

enumsCache

enumsCache: EnumInfo[]

Private enumsLoadingListeners

enumsLoadingListeners: Array<function> = []

Private localeChangeListeners

localeChangeListeners: Array<function> = []

messagesCache

messagesCache: EntityMessages

Private messagesLoadingListeners

messagesLoadingListeners: Array<function> = []

name

name: string

restClientId

restClientId: string

restClientSecret

restClientSecret: string

Private storage

storage: Storage

Private tokenExpiryListeners

tokenExpiryListeners: Array<function> = []

Static Private LOCALE_STORAGE_KEY

LOCALE_STORAGE_KEY: string = "cubaLocale"

Static NOT_SUPPORTED_BY_API_VERSION

NOT_SUPPORTED_BY_API_VERSION: string = "Not supported by current REST API version"

Static Private REST_TOKEN_STORAGE_KEY

REST_TOKEN_STORAGE_KEY: string = "cubaAccessToken"

Static Private USER_NAME_STORAGE_KEY

USER_NAME_STORAGE_KEY: string = "cubaUserName"

Accessors

locale

  • get locale(): string
  • set locale(locale: string): void

restApiToken

  • get restApiToken(): string
  • set restApiToken(token: string): void

Methods

Private _getBasicAuthHeaders

  • _getBasicAuthHeaders(): object
  • Returns object

    • [header: string]: string

Private checkStatus

  • checkStatus(response: Response): any
  • Parameters

    • response: Response

    Returns any

cleanup

  • cleanup(): void

Private clearAuthData

  • clearAuthData(): void

commitEntity

  • commitEntity<T>(entityName: string, entity: T, fetchOptions?: FetchOptions): Promise<Partial<T>>
  • Type parameters

    • T: object

    Parameters

    • entityName: string
    • entity: T
    • Optional fetchOptions: FetchOptions

    Returns Promise<Partial<T>>

deleteEntity

  • deleteEntity(entityName: string, id: any, fetchOptions?: FetchOptions): Promise<void>
  • Parameters

    • entityName: string
    • id: any
    • Optional fetchOptions: FetchOptions

    Returns Promise<void>

fetch

  • fetch<T>(method: string, path: string, data?: any, fetchOptions?: FetchOptions): Promise<T>
  • Type parameters

    • T

    Parameters

    • method: string
    • path: string
    • Optional data: any
    • Optional fetchOptions: FetchOptions

    Returns Promise<T>

getApiVersion

  • getApiVersion(fetchOptions?: FetchOptions): Promise<string>
  • Returns REST API version number without performing side effects

    Parameters

    Returns Promise<string>

    REST API version number

getFile

  • getFile(id: string, fetchOptions?: FetchOptions): Promise<Blob>

getFileUploadURL

  • getFileUploadURL(): string

getPermissions

getRoles

getUserInfo

invokeService

  • invokeService<T>(serviceName: string, methodName: string, params: any, fetchOptions?: FetchOptions): Promise<T>
  • Type parameters

    • T

    Parameters

    • serviceName: string
    • methodName: string
    • params: any
    • Optional fetchOptions: FetchOptions

    Returns Promise<T>

Private isFeatureSupported

  • isFeatureSupported(minVersion: string): Promise<boolean>
  • Parameters

    • minVersion: string

    Returns Promise<boolean>

Private isTokenExpiredResponse

  • isTokenExpiredResponse(resp: Response): boolean
  • Parameters

    • resp: Response

    Returns boolean

loadEntities

loadEntitiesMessages

loadEntitiesWithCount

loadEntity

  • Type parameters

    • T

    Parameters

    • entityName: string
    • id: any
    • Optional options: object
      • Optional view?: string
    • Optional fetchOptions: FetchOptions

    Returns Promise<SerializedEntity<T>>

loadEntityMetadata

loadEntityView

  • loadEntityView(entityName: string, viewName: string, fetchOptions?: FetchOptions): Promise<View>

loadEntityViews

  • loadEntityViews(entityName: string, fetchOptions?: FetchOptions): Promise<View[]>

loadEnums

loadMetadata

login

  • login(login: string, password: string, options?: LoginOptions): Promise<object>
  • Logs in user and stores token in provided storage.

    Parameters

    • login: string
    • password: string
    • Optional options: LoginOptions

      You can use custom endpoints e.g. {tokenEndpoint:'ldap/token'}.

    Returns Promise<object>

    }

logout

  • logout(): Promise<any>

onEnumsLoaded

  • onEnumsLoaded(c: any): (Anonymous function)
  • Parameters

    • c: any

    Returns (Anonymous function)

onLocaleChange

  • onLocaleChange(c: any): (Anonymous function)
  • Parameters

    • c: any

    Returns (Anonymous function)

onMessagesLoaded

  • onMessagesLoaded(c: any): (Anonymous function)
  • Parameters

    • c: any

    Returns (Anonymous function)

onTokenExpiry

  • onTokenExpiry(c: any): (Anonymous function)
  • Parameters

    • c: any

    Returns (Anonymous function)

query

queryCount

  • queryCount(entityName: string, queryName: string, params?: any, fetchOptions?: FetchOptions): Promise<number>
  • Parameters

    • entityName: string
    • queryName: string
    • Optional params: any
    • Optional fetchOptions: FetchOptions

    Returns Promise<number>

queryWithCount

refreshApiVersion

  • refreshApiVersion(): Promise<string>
  • Updates stored REST API version number (which is used in feature detection mechanism) with a value acquired by making a request to a version endpoint, and returns an updated value.

    Returns Promise<string>

    REST API version number

Private requestIfSupported

  • requestIfSupported<T>(minVersion: string, requestCallback: function): Promise<any>
  • Type parameters

    • T

    Parameters

    • minVersion: string
    • requestCallback: function
        • (): Promise<unknown>
        • Returns Promise<unknown>

    Returns Promise<any>

revokeToken

  • revokeToken(token: string): Promise<any>
  • Parameters

    • token: string

    Returns Promise<any>

searchEntities

searchEntitiesWithCount

setSessionLocale

  • setSessionLocale(): Promise<void>
  • since

    CUBA REST JS 0.7.0, Generic REST API 7.2.0

    Returns Promise<void>

Generated using TypeDoc