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 - .invoke(template, files, clauseName, contractInput, stateInput, [currentTime], [utcOffset], paramsInput, warnings) ⇒ 
object - .initialize(template, files, contractInput, [currentTime], [utcOffset], paramsInput, warnings) ⇒ 
object - .parseCTOtoFileSync(ctoPath) ⇒ 
string - .parseCTOtoFile(ctoPath) ⇒ 
string 
 - .trigger(template, files, contractInput, stateInput, [currentTime], [utcOffset], requestsInput, warnings) ⇒ 
 
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
| Param | Type | Description | 
|---|---|---|
| template | string | template directory | 
| files | Array.<string> | input files | 
| contractInput | string | the contract data | 
| stateInput | string | the contract state | 
| [currentTime] | string | the definition of 'now', defaults to current time | 
| [utcOffset] | number | UTC Offset for this execution, defaults to local offset | 
| requestsInput | Array.<string> | the requests | 
| warnings | boolean | whether 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
| Param | Type | Description | 
|---|---|---|
| template | string | template directory | 
| files | Array.<string> | input files | 
| clauseName | string | the name of the clause to invoke | 
| contractInput | string | the contract data | 
| stateInput | string | the contract state | 
| [currentTime] | string | the definition of 'now', defaults to current time | 
| [utcOffset] | number | UTC Offset for this execution, defaults to local offset | 
| paramsInput | object | the parameters for the clause | 
| warnings | boolean | whether 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
| Param | Type | Description | 
|---|---|---|
| template | string | template directory | 
| files | Array.<string> | input files | 
| contractInput | string | the contract data | 
| [currentTime] | string | the definition of 'now', defaults to current time | 
| [utcOffset] | number | UTC Offset for this execution, defaults to local offset | 
| paramsInput | object | the parameters for the clause | 
| warnings | boolean | whether 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
| Param | Type | Description | 
|---|---|---|
| ctoPath | string | path 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
| Param | Type | Description | 
|---|---|---|
| ctoPath | string | path to CTO model file | 
getJson(input) ⇒ object
Load a file or JSON string
Kind: global function
Returns: object - JSON object
| Param | Type | Description | 
|---|---|---|
| input | object | either 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
| Param | Type | Description | 
|---|---|---|
| template | string | template directory | 
| files | Array.<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
| Param | Type | Description | 
|---|---|---|
| path | String | to a local directory | 
| [options] | Object | an 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
| Param | Type | Description | 
|---|---|---|
| buffer | Buffer | the buffer to a Zip (zip) file | 
| [options] | Object | an 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
| Param | Type | Description | 
|---|---|---|
| files | Array.<String> | file names | 
| [options] | Object | an 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
| Param | Type | Description | 
|---|---|---|
| modelManager | object | the Concerto model manager | 
| contract | object | the contract JSON | 
| utcOffset | number | UTC Offset for DateTime values | 
| options | object | parameters for contract variables validation | 
validateInput(modelManager, input, utcOffset) ⇒ object
Validate input JSON
Kind: global function
Returns: object - the validated input
| Param | Type | Description | 
|---|---|---|
| modelManager | object | the Concerto model manager | 
| input | object | the input JSON | 
| utcOffset | number | UTC Offset for DateTime values | 
validateStandard(modelManager, input, utcOffset) ⇒ object
Validate standard
Kind: global function
Returns: object - the validated input
| Param | Type | Description | 
|---|---|---|
| modelManager | object | the Concerto model manager | 
| input | object | the input JSON | 
| utcOffset | number | UTC Offset for DateTime values | 
validateInputRecord(modelManager, input, utcOffset) ⇒ object
Validate input JSON record
Kind: global function
Returns: object - the validated input
| Param | Type | Description | 
|---|---|---|
| modelManager | object | the Concerto model manager | 
| input | object | the input JSON record | 
| utcOffset | number | UTC Offset for DateTime values | 
validateOutput(modelManager, output, utcOffset) ⇒ object
Validate output JSON
Kind: global function
Returns: object - the validated output
| Param | Type | Description | 
|---|---|---|
| modelManager | object | the Concerto model manager | 
| output | object | the output JSON | 
| utcOffset | number | UTC Offset for DateTime values | 
validateOutputArray(modelManager, output, utcOffset) ⇒ Array.<object>
Validate output JSON array
Kind: global function
Returns: Array.<object> - the validated output array
| Param | Type | Description | 
|---|---|---|
| modelManager | object | the Concerto model manager | 
| output | * | the output JSON array | 
| utcOffset | number | UTC 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
| Param | Type | Description | 
|---|---|---|
| engine | object | the execution engine | 
| logicManager | object | the Template Logic | 
| contractJson | object | contract data in JSON | 
| currentTime | string | the definition of 'now' | 
| utcOffset | utcOffset | UTC 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
| Param | Type | Description | 
|---|---|---|
| engine | object | the execution engine | 
| logicManager | object | the Template Logic | 
| contractJson | object | contract data in JSON | 
| stateJson | object | state data in JSON | 
| currentTime | string | the definition of 'now' | 
| utcOffset | utcOffset | UTC Offset for this execution | 
| requestJson | object | state data in JSON | 
resolveRootDir(parameters) ⇒ string
Resolve the root directory
Kind: global function
Returns: string - root directory used to resolve file names
| Param | Type | Description | 
|---|---|---|
| parameters | string | Cucumber's World parameters | 
compareComponent(expected, actual)
Compare actual and expected result components
Kind: global function
| Param | Type | Description | 
|---|---|---|
| expected | string | the expected component as specified in the test workload | 
| actual | string | the actual component as returned by the engine | 
compareSuccess(expected, actual)
Compare actual result and expected result
Kind: global function
| Param | Type | Description | 
|---|---|---|
| expected | string | the expected successful result as specified in the test workload | 
| actual | string | the successful result as returned by the engine |