Options
All
  • Public
  • Public/Protected
  • All
Menu

Class JmixRestConnection

Hierarchy

  • JmixRestConnection

Index

Constructors

constructor

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

    • name: string = ""
    • apiUrl: string = "/rest/"
    • restClientId: string = "client"
    • restClientSecret: string = "secret"
    • defaultLocale: string = "en"
    • storage: Storage = ...
    • Optional apiVersion: any

    Returns JmixRestConnection

Properties

apiUrl

apiUrl: string = "/rest/"

Optional apiVersion

apiVersion: any

defaultLocale

defaultLocale: string = "en"

enumsCache

enumsCache: EnumInfo[]

Private enumsLoadingListeners

enumsLoadingListeners: ((enums: any[]) => {})[] = ...

Private localeChangeListeners

localeChangeListeners: ((locale: string) => {})[] = ...

messagesCache

messagesCache: EntityMessages

Private messagesLoadingListeners

messagesLoadingListeners: ((messages: EntityMessages) => {})[] = ...

name

name: string = ""

restClientId

restClientId: string = "client"

restClientSecret

restClientSecret: string = "secret"

Private tokenExpiryListeners

tokenExpiryListeners: (() => {})[] = ...

Private Static LOCALE_STORAGE_KEY

LOCALE_STORAGE_KEY: string = "jmixLocale"

Static NOT_SUPPORTED_BY_API_VERSION

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

Private Static REST_TOKEN_STORAGE_KEY

REST_TOKEN_STORAGE_KEY: string = "jmixRestAccessToken"

Private Static USER_NAME_STORAGE_KEY

USER_NAME_STORAGE_KEY: string = "jmixRestUserName"

Accessors

locale

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

restApiToken

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

Methods

Private _getBasicAuthHeaders

  • _getBasicAuthHeaders(): {}

Private checkStatus

  • checkStatus(response: Response): any

cleanup

  • cleanup(): void

Private clearAuthData

  • clearAuthData(): void

commitEntity

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

    • T: { id?: string | object }

    Parameters

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

    Returns Promise<Partial<T>>

deleteEntity

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

    • entityName: string
    • id: string | object
    • 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>

fetchJson

  • fetchJson<T>(method: string, path: string, data?: any, fetchOptions?: FetchOptions): Promise<T>
  • Shorthand for fetch that already has 'json' as default 'handleAs' property

    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

getEffectivePermissions

getFile

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

getFileUploadURL

  • getFileUploadURL(): string

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

loadEntities

loadEntitiesMessages

loadEntitiesWithCount

loadEntity

  • loadEntity<T>(entityName: string, id: string | object, options?: { view?: string }, fetchOptions?: FetchOptions): Promise<SerializedEntity<T>>
  • Type parameters

    • T

    Parameters

    • entityName: string
    • id: string | object
    • Optional options: { view?: string }
      • 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?: TokenOptions): Promise<{ access_token: string }>
  • Logs in user and stores token in provided storage.

    Parameters

    • login: string
    • password: string
    • Optional options: TokenOptions

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

    Returns Promise<{ access_token: string }>

    }

logout

onEnumsLoaded

  • onEnumsLoaded(c: any): () => ((enums: any[]) => {})[]
  • Parameters

    • c: any

    Returns () => ((enums: any[]) => {})[]

      • (): ((enums: any[]) => {})[]
      • Returns ((enums: any[]) => {})[]

onLocaleChange

  • onLocaleChange(c: any): () => ((locale: string) => {})[]
  • Parameters

    • c: any

    Returns () => ((locale: string) => {})[]

      • (): ((locale: string) => {})[]
      • Returns ((locale: string) => {})[]

onMessagesLoaded

  • onMessagesLoaded(c: any): () => ((messages: EntityMessages) => {})[]

onTokenExpiry

  • onTokenExpiry(c: any): () => (() => {})[]
  • Parameters

    • c: any

    Returns () => (() => {})[]

      • (): (() => {})[]
      • Returns (() => {})[]

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: () => Promise<unknown>): Promise<any>
  • deprecated

    todo not need when we work with jmix-rest

    Type parameters

    • T

    Parameters

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

    Returns Promise<any>

revokeToken

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

    • token: string
    • Optional revokeEndpoint: string

    Returns Promise<any>

searchEntities

searchEntitiesWithCount

setSessionLocale

  • setSessionLocale(): Promise<void>
  • since

    Jmix REST 0.7.0, Generic REST API 7.2.0

    Returns Promise<void>

Generated using TypeDoc