Rosetta API

Methods

(inner) deregisterAPI(apiRef, data)

Deregister an API defined by an extension definition objects.

Parameters:
NameTypeDescription
apiRefobject

reference to the rosetta api object

dataArray

a JSON objects representing a custom API that have been registered. See registerAPI data parameter for schema.

Throws:

An error if the deregister failed.

(inner) deregisterAPIs(apiRef, dataArray) → {Array}

Deregister APIs from an array of JSON API extension definition objects.

Parameters:
NameTypeDescription
apiRefobject

reference to the rosetta api object

dataArrayArray

an array of JSON objects, each representing a custom APIs that have been registered. See registerAPI data parameter for schema.

Returns:

An array of errors indicating any APIs that failed to deregister. An empty array if all were successful.

Type: 
Array

(inner) generateTernDefsForCustomAPIs(apiRef, dataArray, config) → {Object}

Generate Tern definitions for a set of custom APIs. The Tern definitions can be used for intellisense support.

Parameters:
NameTypeDescription
apiRefObject

reference to the rosetta API object tree where to register the method.

dataArrayArray

an array of JSON objects, each representing a custom API to register. See registerAPI data parameter for schema.

configObject

contains the name for the api definitions and the name for the formula definitions.

Returns:

An object containing a property 'API' for the Rosetta API Tern defintions. If the lang parameter is 'notes' or 'open formula' in any of the custom definition objects, then the property 'Formula' will contain the formula Tern definitions.

Type: 
Object

(inner) getActionEventObject() → {*}

Volt MX framework based API: getActionEventObject; Gets the Action Event Object

Throws:

Error object with string representing the failure message

Type
Object
Returns:

The current Action Event Object

Type: 
*

(inner) getCurrentServerDatabase() → {String}

Volt MX framework based API: getCurrentServerDatabase; Get the server location and file name being used under the VoltMX API layer

Throws:

Error object with string representing the failure message

Type
Object
Returns:

The server location and file name of the database under the VoltMX API layer

Type: 
String

(inner) getCurrentServiceName() → {String}

Volt MX framework based API: getCurrentServiceName; Gets the current service name being used under the VoltMX API layer

Throws:

Error object with string representing the failure message

Type
Object
Returns:

The current service name under the VoltMX API layer

Type: 
String

(inner) getDefaultAPI() → {string}

Set getDefaultAPI

Returns:

the default API currently set

Type: 
string

(inner) getDefaultContext() → {string}

Get default context

Returns:

the currently set default context (all|local|db)

Type: 
string

(inner) getDefaultFramework() → {string}

Get default framework

Returns:

default framework (JS or VMX)

Type: 
string

(inner) getDefaultServiceType() → {String}

Volt MX framework based API: getDefaultServiceType; returns the default service type under the VoltMX API layer expressed as a string

Throws:

Error object with string representing the failure message

Type
String
Returns:

The default service type under the VoltMX API layer

Type: 
String

(inner) getServiceType(serviceName) → {string}

getServiceType

Parameters:
NameTypeDescription
serviceNamestring

for the Volt MX Object Service

Returns:

the service type for the specified service

Type: 
string

(inner) getTernFileNames() → {Object}

Get the names for the Tern files generated for the Rosetta API.

Returns:

The names of the tern file definitions generated for the Rossetta API. Keys are "API" for the Rosetta javascript API, "Notes" for the Notes formula, and "OpenFormula" for OpenFormula.

Type: 
Object

(inner) isCurrentAPINotes() → {boolean}

Is current API Notes.

Returns:

True if the current API is set to Notes; false otherwise

Type: 
boolean

(inner) isCurrentAPIOpenFormula() → {boolean}

Is current API Open Formula.

Returns:

True if the current API is set to Open Formula false otherwise

Type: 
boolean

(inner) isCurrentContextAll() → {boolean}

Is current context all?

Returns:

true if the current context is set to all; false otherwise

Type: 
boolean

(inner) isCurrentContextDb() → {boolean}

Is current context database?

Returns:

true if the current context is set to db; false otherwise

Type: 
boolean

(inner) isCurrentContextLocal() → {boolean}

Is current context local?

Returns:

true if the current context is set to local; false otherwise

Type: 
boolean

(inner) isCurrentFrameworkDRAPI() → {boolean}

Is current framework Javascript.

Returns:

True if the current framework is set to js; false otherwise

Type: 
boolean

(inner) isCurrentFrameworkJS() → {boolean}

Is current framework Javascript.

Returns:

True if the current framework is set to js; false otherwise

Type: 
boolean

(inner) isCurrentFrameworkVoltMX() → {boolean}

Is current framework Volt MX.

Returns:

True if the current framework is set to vmx; false otherwise

Type: 
boolean

(inner) isCurrentServiceTypeIntegration() → {Boolean}

Volt MX framework based API: isCurrentServiceTypeIntegration; Is current service type "integration"?

Throws:

Error object with string representing the failure message

Type
Object
Returns:

true if the current service type is set to integration

Type: 
Boolean

(inner) isCurrentServiceTypeOfflineObjects() → {Boolean}

Volt MX framework based API: isCurrentServiceTypeOfflineObjects; Is current service type "object.offline"?

Throws:

Error object with string representing the failure message

Type
Object
Returns:

true if the current service type is set to object.offline

Type: 
Boolean

(inner) isCurrentServiceTypeOnlineObjects() → {Boolean}

Volt MX framework based API: isCurrentServiceTypeOnlineObjects; Is current service type "object.online"?

Throws:

Error object with string representing the failure message

Type
Object
Returns:

true if the current service type is set to object.online

Type: 
Boolean

(inner) parseCustomData(data) → {object}

Parse information from an object defining an extened API.

Parameters:
NameTypeDescription
dataobject

object defining the extended API.

Returns:

Information about the extended API defined by data. The following keys will be returned: name, namef, funcArgs, cat, lang, and code. The any optional settings in data will be resolved to values in the returned object. funcArgs will contain any arguments defined for name.

Type: 
object

(inner) registerAPI(apiRef, data) → {Object}

Register an API by adding it as an object to the referential array of APIs Defines/redefines the Rosetta API library by creating/updating a node in the API object The API object may be redefined if when using the existing category, name, language combination If language param is supplied, the API node will also define the method at the formula language level and the main method will point to call the method inside the language object

Parameters:
NameTypeDescription
apiRefObject

required. reference to the rosetta API object tree where to register the method.

dataObject

required. object defining the extended API. object props as follows:

  • "name" :required. the API method name to register under rosetta
  • "cat" :optional. the category name where the API name will be defined under. default: "Custom"
  • "lang" :optional. the formula language implementation layer to register the method under. default: undefined
  • "namef":optional. the method name to use in the formula lang implementations layer. default: name arg
  • "code" : <String|Function> optional. a string with the formula to convert or a callback function. default: noop: () => {}
Throws:

Error object string representing registration failure

Type
String
Returns:

the return value from registerCustomAPI

Type: 
Object
Example
// code as actual js arrow function object, default params for the rest
// defines <rosettaObj>.Custom.hello = s => alert(`hello $(s)}`)
registerAPI(
  apiRef:rosettajs,
  {
    "name":"hello(s)",
    "code": s => alert(`hello $(s)}`)
  }
);

// code as actual js function object,
// defines <rosettaObj>.Text.hello(args...) -> .Text._notes.Hello_Test(args...) = function(name) { return "hello " + name; }
registerAPI(
  apiRef:rosettajs,
  {
    "name": "hello(name)",
    "cat": "Text",
    "lang": "notes",
    "namef": "Hello_Test",
    "code": function(name) { return "hello " + name; }
  }
);

// code as stringified js function body,
// defines <rosettaObj>.Text.hellop(args...) -> .Text._notes.HelloPhone_Test(args...) = function(name,phone) { return `hello ${name}. phone is ${phone}` }
registerAPI(
  apiRef:rosettajs,
  {
    "name": "hellop(name,phone)",
    "cat": "Text",
    "lang": "notes",
    "namef": "HelloPhone_Test",
    "code": "{ return `hello ${name}. phone is ${phone}` }"
  }

// code as stringified notes formula code (gets auto-converted to rosettajs),
// defines <rosettaObj>.Custom.myAbs -> .Custom._notes.myAbs(args...) = n => { return rosettajs.Math.abs(n)+10 }`)
registerAPI(
  apiRef:rosettajs,
  {
    "name":"myAbs(n)",
    "code": "@Abs(n)+10;"
  }
);

// code as stringified open formula code (gets auto-converted to rosettajs),
// defines <rosettaObj>.Custom.myAbs -> .Custom._openFormula.MYABS(args...) = n => { return rosettajs.Math.abs(n)+10 }`)
registerAPI(
  apiRef:rosettajs,
  {
    "name":"myAbs(n)",
    "namef": "MYABS"
    "code": "=ABS(n)+10;"
  }
);

(inner) registerAPIs(apiRef, dataArray) → {Array}

Register APIs from an array of JSON API extension definition objects. Each object in the array must adhere to schema required in registerAPI method

Parameters:
NameTypeDescription
apiRefString

required. reference to the rosetta api object tree

dataArrayArray

an array of JSON objects, each representing a custom API to register. See registerAPI data parameter for schema.

Throws:

Error object string representing registration failure

Type
String
Returns:

Array of callbacks for the API methods registered

Type: 
Array
Example
registerAPI(
  apiRef:rosettajs,
  [
    { // defines: <rosettajs>.Custom.simplest = () => { }
      "name": "simplest"
    },
    { // defines: <rosettajs>.Text.simpler = () => { }
      "name": "simpler",
      "cat": "Text",
    },
    { // defines: <rosettajs>.Text.simple = function(x) { return x+1; }
      "name": "simple(x)",
      "cat": "Text",
      "code": function(x) { return x+1; }
    },
    { // defines: <rosettajs>.Text.simple = function(x) { this._notes.simple(): function(x) { return x+1; } }
      "name": "simpleNotes(x)",
      "cat": "Text",
      "lang": "notes",
      "code": function(x) { return x+1; }
    },
    { // defines: <rosettajs>.Text.simple = function(x) { this._notes.ADVanceNOTES123(): function(x) { return x+1; } }
      "name": "advancedNotes(x)",
      "cat": "Text",
      "lang": "notes",
      "namef": "ADVanceNOTES123",
      "code": function(x) { return x+1; }
    },
    {
      "cat": "Text",
      "name": "hello(name)",
      "lang": "notes",
      "namef": "Hello",
      "code": function(name) { return "hello " + name; }
    },
    {
      "name": "goodbye(name)",
      "lang": "notes",
      "cat": "Text",
      "code": function(name) { return "bye bye " + name; }
    },
    { // defines: <rosettajs>.Custom.weather = function(x) { this._openFormula.WEATHER(): function(zip) { return "Sunny in " + zip; } }
      "name": "WEATHER(zip)",
      "lang": "open formula",
      "cat": "Custom",
      "code": function (zip) { return "Sunny in " + zip; }
    },
    { // defines: <rosettajs>.Custom.absPlusX = function(n,x) { this._notes.absPlusX(): javascript conversion result from "@Abs(n)+x" }
      "name": "AbsPlusX(n; x)",
      "lang": "notes",
      "cat": "Custom",
      "code": "@Abs(n)+x;"
    }
  ]
);

(inner) rosettajsLogger() → {*}

Volt MX framework based API: rosettajsLogger; returns the logger object under the VoltMX API layer

Throws:

Error object with string representing the failure message

Type
String
Returns:

The rosettajs logger object under the VoltMX API layer

Type: 
*

(inner) setActionEventObject(eventobject)

Volt MX framework based API: setActionEventObject; Sets the Action Event Object

Parameters:
NameTypeDescription
eventobject*

The Action Event Object used by Action Widgets.

Throws:

Error object with string representing the failure message

Type
Object

(inner) setCurrentServerDatabase(serverDatabase)

Volt MX framework based API: setCurrentServerDatabase; Sets the server location and file name to be used under the VoltMX API layer

Parameters:
NameTypeDescription
serverDatabase*

The server location and file name of the database.

Throws:

Error object with string representing the failure message

Type
Object

(inner) setDefaultAPIAsNotes() → {string}

Set default API to Notes when an underlaying Open Formula API function with the same name exists.

Returns:

The default API

Type: 
string

(inner) setDefaultAPIAsOpenFormula() → {string}

Set default API to Open Formula when an underlaying Notes API function with the same name exists.

Returns:

The default API

Type: 
string

(inner) setDefaultContextAsAll() → {string}

Set default context to all

Returns:

The default context

Type: 
string

(inner) setDefaultContextAsDb() → {string}

Set default context to db

Returns:

The default context

Type: 
string

(inner) setDefaultContextAsLocal() → {string}

Set default context to local

Returns:

The default context

Type: 
string

(inner) setDefaultFrameworkAsDRAPI() → {string}

Set default framework to drapi

Returns:

The default framework

Type: 
string

(inner) setDefaultFrameworkAsJS() → {string}

Set default framework to javascript

Returns:

The default framework

Type: 
string

(inner) setDefaultFrameworkAsVoltMX() → {string}

Set default framework to voltmx

Returns:

The default framework

Type: 
string

(inner) setDefaultServiceTypeAsIntegration() → {String}

Volt MX framework based API: setDefaultServiceTypeAsIntegration; Sets the default service type to "integration", under the VoltMX API layer

Throws:

Error object with string representing the failure message

Type
Object
Returns:

The default service type

Type: 
String

(inner) setDefaultServiceTypeAsOfflineObjects() → {String}

Volt MX framework based API: setDefaultServiceTypeAsOfflineObjects; Sets the default service type to "object.offline", under the VoltMX API layer

Throws:

Error object with string representing the failure message

Type
Object
Returns:

The default service type

Type: 
String

(inner) setDefaultServiceTypeAsOnlineObjects() → {String}

Volt MX framework based API: setDefaultServiceTypeAsOnlineObjects; Sets the default service type to "object.online", under the VoltMX API layer

Throws:

Error object with string representing the failure message

Type
Object
Returns:

The default service type

Type: 
String

(inner) setServiceTypeAsOfflineObjects(serviceName) → {string}

setServiceTypeAsOfflineObjects(serviceName)

Parameters:
NameTypeDescription
serviceNamestring

for the Volt MX Object Service

Returns:

the service type for the specified service

Type: 
string

(inner) setServiceTypeAsOnlineObjects(serviceName) → {string}

setServiceTypeAsOnlineObjects(serviceName)

Parameters:
NameTypeDescription
serviceNamestring

for the Volt MX Object Service

Returns:

the service type for the specified service

Type: 
string