1.0.1 • Published 5 years ago

@genestack/system-api v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Genestack system APIs to use in browser

Installation

npm install @genestack/system-api

loadApplication()

Returns a Promise that resolves when all application resources are loaded. Promise resolution handler is called with the object that represents current application.

import {loadApplication} from '@genestack/system-api';

loadApplication().then((app) => {
    console.log(app.applicationId); // "your-vendor/your-app-id"
})

Application object properties

NameTypeComment
applicationIdstringyour-vendor/your-app-id
parametersArrayArray of parameters app was loaded with (usually list of file accessions)
actionstringAction app was loaded with (e.g. openInBrowser, openFile, createFromSources etc.)
applicationVersionstringApplication version
applicationNamestringHuman readable application name
pathnamestringpathname URL part of the application, e.g. /endpoint/application/run/your-vendor/your-app-id
resourcePathstringURL part, pointing towards root folder of application resources, use it e.g. like `${app.resourcePath}relative/path/to/image.png`

loadApplicationProperties()

Returns a Promise that resolves with application properties. Promise resolution handler is called with the object that represents the properties of the application with the applicationId argument.

loadApplicationProperties(applicationId).then(({pathname, applicationId}) => {
    console.log(pathname);
    console.log(applicationId)
})

applicationId is the string identifier of any deployed application.

appProperties properties

NameTypeComment
pathnamestringpathname URL part of the application, e.g. /endpoint/application/run/your-vendor/your-app-id
applicationIdstringApplication identifier

invokeMethod()

Invoke a Java method from an application's class. Returns a Promise that is resolved with serialized/deserialized value that method returns or rejected with the Error object in case of any failure.

This method could be used only when application is fully loaded.

import {loadApplication, invokeMethod} from '@genestack/system-api';

loadApplication().then(() => {
    invokeMethod(options).then((result) => {
        console.log(result); // whatever your server method returns
    })
})

Method invocation options

ParameterRequiredTypeDefaultComment
applicationIdstringId of application in format "vendor/application"
methodstringApplication method name
parametersArrayA list of parameters that method accepts. Each parameter should be JSON serializable
showBusyIndicatorbooleanfalseWhether a global busy indicator should be shown
extendSessionbooleantrueIf true, this method call will extend current user session
handlerFunctionSuccess handler. Called with method's returned value, the same as the Promise resolution value
errorHandlerFunctionError handler. The same as the Promise rejection value

showNotification()

Shows the system notification notification (at the top of the application page) Returns a Promise.

import {showNotification} from '@genestack/system-api';

showNotification('Hello, World!', 'success');

Method invocation options

ParameterRequiredTypedefaultComment
messagestringText message
typestringwarningOne of success, warning, error