Skip to main content

Ergo API

Classes

Commands

Utility class that implements the commands exposed by the Ergo CLI.

Functions

getJson(input)object

Load a file or JSON string

loadTemplate(template, files)Promise.<LogicManager>

Load a template from directory or files

fromDirectory(path, [options])Promise.<LogicManager>

Builds a LogicManager from a directory.

fromZip(buffer, [options])Promise.<LogicManager>

Builds a LogicManager from a Zip.

fromFiles(files, [options])Promise.<LogicManager>

Builds a LogicManager from files.

validateContract(modelManager, contract, utcOffset, options)object

Validate contract JSON

validateInput(modelManager, input, utcOffset)object

Validate input JSON

validateStandard(modelManager, input, utcOffset)object

Validate standard

validateInputRecord(modelManager, input, utcOffset)object

Validate input JSON record

validateOutput(modelManager, output, utcOffset)object

Validate output JSON

validateOutputArray(modelManager, output, utcOffset)Array.<object>

Validate output JSON array

init(engine, logicManager, contractJson, currentTime, utcOffset)object

Invoke Ergo contract initialization

trigger(engine, logicManager, contractJson, stateJson, currentTime, utcOffset, requestJson)object

Trigger the Ergo contract with a request

resolveRootDir(parameters)string

Resolve the root directory

compareComponent(expected, actual)

Compare actual and expected result components

compareSuccess(expected, actual)

Compare actual result and expected result

Commands

Utility class that implements the commands exposed by the Ergo CLI.

Kind: global class

Commands.trigger(template, files, contractInput, stateInput, [currentTime], [utcOffset], requestsInput, warnings) ⇒ object

Send a request an Ergo contract

Kind: static method of Commands
Returns: object - Promise to the result of execution

ParamTypeDescription
templatestringtemplate directory
filesArray.<string>input files
contractInputstringthe contract data
stateInputstringthe contract state
[currentTime]stringthe definition of 'now', defaults to current time
[utcOffset]numberUTC Offset for this execution, defaults to local offset
requestsInputArray.<string>the requests
warningsbooleanwhether to print warnings

Commands.invoke(template, files, clauseName, contractInput, stateInput, [currentTime], [utcOffset], paramsInput, warnings) ⇒ object

Invoke an Ergo contract's clause

Kind: static method of Commands
Returns: object - Promise to the result of invocation

ParamTypeDescription
templatestringtemplate directory
filesArray.<string>input files
clauseNamestringthe name of the clause to invoke
contractInputstringthe contract data
stateInputstringthe contract state
[currentTime]stringthe definition of 'now', defaults to current time
[utcOffset]numberUTC Offset for this execution, defaults to local offset
paramsInputobjectthe parameters for the clause
warningsbooleanwhether to print warnings

Commands.initialize(template, files, contractInput, [currentTime], [utcOffset], paramsInput, warnings) ⇒ object

Invoke init for an Ergo contract

Kind: static method of Commands
Returns: object - Promise to the result of execution

ParamTypeDescription
templatestringtemplate directory
filesArray.<string>input files
contractInputstringthe contract data
[currentTime]stringthe definition of 'now', defaults to current time
[utcOffset]numberUTC Offset for this execution, defaults to local offset
paramsInputobjectthe parameters for the clause
warningsbooleanwhether to print warnings

Commands.parseCTOtoFileSync(ctoPath) ⇒ string

Parse CTO to JSON File

Kind: static method of Commands
Returns: string - The name of the generated CTOJ model file

ParamTypeDescription
ctoPathstringpath to CTO model file

Commands.parseCTOtoFile(ctoPath) ⇒ string

Parse CTO to JSON File

Kind: static method of Commands
Returns: string - The name of the generated CTOJ model file

ParamTypeDescription
ctoPathstringpath to CTO model file

getJson(input) ⇒ object

Load a file or JSON string

Kind: global function
Returns: object - JSON object

ParamTypeDescription
inputobjecteither a file name or a json string

loadTemplate(template, files) ⇒ Promise.<LogicManager>

Load a template from directory or files

Kind: global function
Returns: Promise.<LogicManager> - a Promise to the instantiated logicmanager

ParamTypeDescription
templatestringtemplate directory
filesArray.<string>input files

fromDirectory(path, [options]) ⇒ Promise.<LogicManager>

Builds a LogicManager from a directory.

Kind: global function
Returns: Promise.<LogicManager> - a Promise to the instantiated logicmanager

ParamTypeDescription
pathStringto a local directory
[options]Objectan optional set of options to configure the instance.

fromZip(buffer, [options]) ⇒ Promise.<LogicManager>

Builds a LogicManager from a Zip.

Kind: global function
Returns: Promise.<LogicManager> - a Promise to the instantiated logicmanager

ParamTypeDescription
bufferBufferthe buffer to a Zip (zip) file
[options]Objectan optional set of options to configure the instance.

fromFiles(files, [options]) ⇒ Promise.<LogicManager>

Builds a LogicManager from files.

Kind: global function
Returns: Promise.<LogicManager> - a Promise to the instantiated logicmanager

ParamTypeDescription
filesArray.<String>file names
[options]Objectan optional set of options to configure the instance.

validateContract(modelManager, contract, utcOffset, options) ⇒ object

Validate contract JSON

Kind: global function
Returns: object - the validated contract

ParamTypeDescription
modelManagerobjectthe Concerto model manager
contractobjectthe contract JSON
utcOffsetnumberUTC Offset for DateTime values
optionsobjectparameters for contract variables validation

validateInput(modelManager, input, utcOffset) ⇒ object

Validate input JSON

Kind: global function
Returns: object - the validated input

ParamTypeDescription
modelManagerobjectthe Concerto model manager
inputobjectthe input JSON
utcOffsetnumberUTC Offset for DateTime values

validateStandard(modelManager, input, utcOffset) ⇒ object

Validate standard

Kind: global function
Returns: object - the validated input

ParamTypeDescription
modelManagerobjectthe Concerto model manager
inputobjectthe input JSON
utcOffsetnumberUTC Offset for DateTime values

validateInputRecord(modelManager, input, utcOffset) ⇒ object

Validate input JSON record

Kind: global function
Returns: object - the validated input

ParamTypeDescription
modelManagerobjectthe Concerto model manager
inputobjectthe input JSON record
utcOffsetnumberUTC Offset for DateTime values

validateOutput(modelManager, output, utcOffset) ⇒ object

Validate output JSON

Kind: global function
Returns: object - the validated output

ParamTypeDescription
modelManagerobjectthe Concerto model manager
outputobjectthe output JSON
utcOffsetnumberUTC Offset for DateTime values

validateOutputArray(modelManager, output, utcOffset) ⇒ Array.<object>

Validate output JSON array

Kind: global function
Returns: Array.<object> - the validated output array

ParamTypeDescription
modelManagerobjectthe Concerto model manager
output*the output JSON array
utcOffsetnumberUTC Offset for DateTime values

init(engine, logicManager, contractJson, currentTime, utcOffset) ⇒ object

Invoke Ergo contract initialization

Kind: global function
Returns: object - Promise to the initial state of the contract

ParamTypeDescription
engineobjectthe execution engine
logicManagerobjectthe Template Logic
contractJsonobjectcontract data in JSON
currentTimestringthe definition of 'now'
utcOffsetutcOffsetUTC Offset for this execution

trigger(engine, logicManager, contractJson, stateJson, currentTime, utcOffset, requestJson) ⇒ object

Trigger the Ergo contract with a request

Kind: global function
Returns: object - Promise to the response

ParamTypeDescription
engineobjectthe execution engine
logicManagerobjectthe Template Logic
contractJsonobjectcontract data in JSON
stateJsonobjectstate data in JSON
currentTimestringthe definition of 'now'
utcOffsetutcOffsetUTC Offset for this execution
requestJsonobjectstate data in JSON

resolveRootDir(parameters) ⇒ string

Resolve the root directory

Kind: global function
Returns: string - root directory used to resolve file names

ParamTypeDescription
parametersstringCucumber's World parameters

compareComponent(expected, actual)

Compare actual and expected result components

Kind: global function

ParamTypeDescription
expectedstringthe expected component as specified in the test workload
actualstringthe actual component as returned by the engine

compareSuccess(expected, actual)

Compare actual result and expected result

Kind: global function

ParamTypeDescription
expectedstringthe expected successful result as specified in the test workload
actualstringthe successful result as returned by the engine