Session

Session

Simplicite application session.

Constructor

new Session(params)

Description:
  • Constructor
Source:
Parameters:
Name Type Description
params object Parameters
Properties
Name Type Attributes Default Description
url string Base URL of the Simplicite application
scheme string URL scheme (e.g. 'https') of the Simplicite application (not needed if url is set)
host string Hostname or IP address (e.g. 'host.mydomain.com') of the Simplicite application (not needed if url is set)
port number Port (e.g. 443) of the Simplicite application (not needed if url is set)
root string Root context URL (e.g. '/myapp') the Simplicite application (not needed if url is set)
endpoint boolean <optional>
'api' Endpoint ('api'|'ui'|'uipublic')
username string <optional>
Username (not needed for the public UI endpoint)
password string <optional>
Password (not needed for the public UI endpoint)
authtoken string <optional>
Authentication token (if set, username and password are not needed; not needed for the public UI endpoint)
authheader string <optional>
Authorization HTTP header name (defaults to the standard Authorization, the alternative is the value of the SIMPLICITE_AUTH_HEADER constant, not needed for public endpoint)
ajaxkey string <optional>
Ajax key (only useful for usage from the generic UI)
debug boolean <optional>
false Debug mode?
debugHandler function <optional>
Debug handler function
infoHandler function <optional>
Info handler function
warningHandler function <optional>
Warning handler function
errorHandler function <optional>
Error handler function
logHandler function <optional>
Log handler function

Members

ajaxkey :string

Description:
  • Ajax key
Source:
Ajax key
Type:
  • string

appinfo :object

Description:
  • Application info
Source:
Application info
Type:
  • object

authheader :string

Description:
  • Authorization HTTP header name
Source:
Authorization HTTP header name
Type:
  • string

authtoken :string

Description:
  • Auth token
Source:
Auth token
Type:
  • string

authtokenexpiry :Date

Description:
  • Auth token expiry date
Source:
Auth token expiry date
Type:
  • Date

constants

Description:
  • Constants
Source:
Constants

debugMode :boolean

Description:
  • Debug mode enabled?
Source:
Debug mode enabled?
Type:
  • boolean

devinfo :object

Description:
  • Development info
Source:
Development info
Type:
  • object

endpoint :string

Description:
  • Endpoint
Source:
Endpoint
Type:
  • string

grant :Grant

Description:
  • Grant
Source:
Grant
Type:

news :array

Description:
  • News
Source:
News
Type:
  • array

parameters :object

Description:
  • Parameters
Source:
Parameters
Type:
  • object

password :string

Description:
  • Password
Source:
Password
Type:
  • string

sessionid :string

Description:
  • Session ID
Source:
Session ID
Type:
  • string

sysinfo :object

Description:
  • System info
Source:
System info
Type:
  • object

username :string

Description:
  • Username
Source:
Username
Type:
  • string

Methods

(async) changePassword(pwd, optsopt) → {promise.<object>}

Description:
  • Change password
Source:
Parameters:
Name Type Attributes Description
pwd string Password
opts object <optional>
Options
Properties
Name Type Attributes Description
error function <optional>
Error handler function
businessCase string <optional>
Business case label
Returns:
A promise to the change password result
Type
promise.<object>

clear()

Description:
  • Clears all data (credentials, objects, ...)
Source:

compressData(data) → {Promise.<Blob>}

Description:
  • Compress data as blob
Source:
Parameters:
Name Type Description
data string | any Data to compress
Returns:
Promise to the compressed data blob
Type
Promise.<Blob>

debug(…args)

Description:
  • Debug handler
Source:
Parameters:
Name Type Attributes Description
args any <repeatable>
Arguments

error(…args)

Description:
  • Error handler
Source:
Parameters:
Name Type Attributes Description
args any <repeatable>
Arguments

(async) getAppInfo(optsopt) → {promise.<object>}

Description:
  • Get application info
Source:
Parameters:
Name Type Attributes Description
opts object <optional>
Options
Properties
Name Type Attributes Description
error function <optional>
Error handler function
businessCase string <optional>
Business case label
Returns:
A promise to the application info (also available as the appinfo member)
Type
promise.<object>

getBasicAuthHeader() → {string}

Description:
  • Basic HTTP authorization header value
Source:
Returns:
HTTP authorization header value
Type
string

getBearerTokenHeader() → {string}

Description:
  • Get bearer token header value
Source:
Returns:
Bearer token header value
Type
string

getBusinessObject(name, instanceopt) → {BusinessObject}

Description:
  • Get business object
Source:
Parameters:
Name Type Attributes Description
name string Business object name
instance string <optional>
Business object instance name, defaults to js_<object name>
Returns:
Business object
Type
BusinessObject

getBusinessObjectCacheKey(name, instanceopt) → {object}

Description:
  • Get business object cache key
Source:
Parameters:
Name Type Attributes Description
name string Business object name
instance string <optional>
Business object instance name, defaults to js_<object name>
Returns:
Business object cache key
Type
object

(async) getDevInfo(moduleopt, optsopt) → {promise.<object>}

Description:
  • Get development info
Source:
Parameters:
Name Type Attributes Description
module string <optional>
Module name
opts object <optional>
Options
Properties
Name Type Attributes Description
error function <optional>
Error handler function
businessCase string <optional>
Business case label
Returns:
A promise to the development info (also available as the devinfo member)
Type
promise.<object>

getError(err, statusopt, originopt) → {object}

Description:
  • Get error object
Source:
Parameters:
Name Type Attributes Description
err string | object Error
Properties
Name Type Description
message string Error message
status number <optional>
Optional error status (defaults to 200)
origin string <optional>
Optional error origin
Returns:
Error object
Type
object

getExternalObject(name)

Description:
  • Get an external object
Source:
Parameters:
Name Type Description
name string External object name

(async) getGrant(optsopt) → {promise.<Grant>}

Description:
  • Get grant (current user data)
Source:
Parameters:
Name Type Attributes Description
opts object <optional>
Options
Properties
Name Type Attributes Default Description
inlinePicture boolean <optional>
false Inline user picture?
includeTexts boolean <optional>
false Include texts?
includeSysparams boolean <optional>
false Include system parameters?
error function <optional>
Error handler function
businessCase string <optional>
Business case label
Returns:
A promise to the grant (also available as the grant member)
Type
promise.<Grant>

(async) getHealth(optsopt) → {promise.<object>}

Description:
  • Get health check (no need to be authenticated)
Source:
Parameters:
Name Type Attributes Description
opts object <optional>
Options
Properties
Name Type Attributes Default Description
full boolean <optional>
false Full health check?
error function <optional>
Error handler function
Returns:
Promise to the health data
Type
promise.<object>

getModuleVersion()

Description:
  • Get API client module version
Source:

(async) getNews(optsopt) → {promise.<array>}

Description:
  • Get news
Source:
Parameters:
Name Type Attributes Description
opts object <optional>
Options
Properties
Name Type Attributes Default Description
inlineImages boolean <optional>
false Inline news images?
error function <optional>
Error handler function
businessCase string <optional>
Business case label
Returns:
A promise to the list of news (also available as the news member)
Type
promise.<array>

getPath(action, optsopt)

Description:
  • Get path
Source:
Parameters:
Name Type Attributes Description
action string Action
opts object <optional>
Options
Properties
Name Type Attributes Description
businessCase string <optional>
Business case label

getResourceURL(code, typeopt, objectopt, objIdopt)

Description:
  • Get a resource URL
Source:
Parameters:
Name Type Attributes Default Description
code string Resource code
type string <optional>
IMG Resource type (IMG=image (default), ICO=Icon, CSS=stylesheet, JS=Javascript, HTML=HTML)
object string <optional>
Object name (not required for global resources)
objId string <optional>
Object ID (not required for global resources)

(async) getSysInfo(optsopt) → {promise.<object>}

Description:
  • Get system info
Source:
Parameters:
Name Type Attributes Description
opts object <optional>
Options
Properties
Name Type Attributes Description
error function <optional>
Error handler function
businessCase string <optional>
Business case label
Returns:
A promise to the system info (also available as the sysinfo member)
Type
promise.<object>

health(optsopt) → {promise.<object>}

Description:
  • Alias to getHealth
Source:
Parameters:
Name Type Attributes Description
opts object <optional>
Options
Properties
Name Type Attributes Default Description
full boolean <optional>
false Full health check?
error function <optional>
Error handler function
Returns:
Promise to the health data
Type
promise.<object>

(async) indexSearch(query, objectopt, optsopt) → {promise.<array>}

Description:
  • Index search
Source:
Parameters:
Name Type Attributes Description
query string Index search query
object string <optional>
Object
opts object <optional>
Options
Properties
Name Type Attributes Default Description
metadata boolean <optional>
false Add meta data for each result
context number <optional>
Context
error function <optional>
Error handler function
businessCase string <optional>
Business case label
Returns:
A promise to a list of index search records
Type
promise.<array>

info(…args)

Description:
  • Info handler
Source:
Parameters:
Name Type Attributes Description
args any <repeatable>
Arguments

isAuthTokenExpired() → {boolean}

Description:
  • Is the auth token expired?
Source:
Returns:
true if the auth token is expired
Type
boolean

log(…args)

Description:
  • Log handler
Source:
Parameters:
Name Type Attributes Description
args any <repeatable>
Arguments

(async) login(optsopt) → {promise.<object>}

Description:
  • Login
Source:
Parameters:
Name Type Attributes Description
opts object <optional>
Options
Properties
Name Type Attributes Description
username string <optional>
Username (exclusive with authentication token)
password string <optional>
Password (required if username is set)
authtoken string <optional>
Authentication token ((exclusive with username)
error function <optional>
Error handler function
Returns:
Promise to the login result
Type
promise.<object>

(async) logout(callback, optsopt) → {promise.<object>}

Description:
  • Logout
Source:
Parameters:
Name Type Attributes Description
callback function Callback (called upon success)
opts object <optional>
Options
Properties
Name Type Attributes Description
error function <optional>
Error handler function
Returns:
Promise to the logout result
Type
promise.<object>

parseResponse(res, statusopt) → {object}

Description:
  • Parse response
Source:
Parameters:
Name Type Attributes Default Description
res object Response to parse
status number <optional>
200 HTTP status
Returns:
Error object
Type
object

sendRequest(path, dataopt, callbackopt, errorHandleropt)

Description:
  • Send request
Source:
Parameters:
Name Type Attributes Description
path string Path
data object <optional>
Data
callback function <optional>
Callback
errorHandler function <optional>
Error handler

setAjaxKey(key)

Description:
  • Set Ajax key
Source:
Parameters:
Name Type Description
key string Ajax key

setAuthToken(token)

Description:
  • Set auth token
Source:
Parameters:
Name Type Description
token string Auth token

setAuthTokenExpiryDate(expiry)

Description:
  • Set auth token expiry date
Source:
Parameters:
Name Type Description
expiry Date Auth token expiry

setPassword(pwd)

Description:
  • Set password
Source:
Parameters:
Name Type Description
pwd string Password

setUsername(usr)

Description:
  • Set username
Source:
Parameters:
Name Type Description
usr string Username

uncompressData(blob) → {Promise.<string>}

Description:
  • Uncompress blob
Source:
Parameters:
Name Type Description
blob Blob Compressed data blob
Returns:
Promise to the uncompressed string
Type
Promise.<string>

warn(…args)

Description:
  • Warning handler
Source:
Parameters:
Name Type Attributes Description
args any <repeatable>
Arguments