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
- setCurrentTime(currentTime) ⇒ 
object Ensures there is a proper current time
- init(engine, templateLogic, contractJson, currentTime) ⇒ 
object Invoke Ergo contract initialization
- execute(engine, templateLogic, contractJson, stateJson, currentTime, requestJson) ⇒ 
object Execute 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
- .execute(ergoPaths, ctoPaths, contractName, contractInput, stateInput, currentTime, requestsInput) ⇒ 
object - .invoke(ergoPaths, ctoPaths, contractName, clauseName, contractInput, stateInput, currentTime, paramsInput) ⇒ 
object - .init(ergoPaths, ctoPaths, contractName, contractInput, currentTime, paramsInput) ⇒ 
object - .parseCTOtoFileSync(ctoPath) ⇒ 
string - .parseCTOtoFile(ctoPath) ⇒ 
string 
 - .execute(ergoPaths, ctoPaths, contractName, contractInput, stateInput, currentTime, requestsInput) ⇒ 
 
Commands.execute(ergoPaths, ctoPaths, contractName, contractInput, stateInput, currentTime, requestsInput) ⇒ object
Execute an Ergo contract with a request
Kind: static method of Commands  
Returns: object - Promise to the result of execution
| Param | Type | Description | 
|---|---|---|
| ergoPaths | Array.<string> | paths to the Ergo modules | 
| ctoPaths | Array.<string> | paths to CTO models | 
| contractName | string | of the contract | 
| contractInput | string | the contract data | 
| stateInput | string | the contract state | 
| currentTime | string | the definition of 'now' | 
| requestsInput | Array.<string> | the requests | 
Commands.invoke(ergoPaths, ctoPaths, contractName, clauseName, contractInput, stateInput, currentTime, paramsInput) ⇒ object
Invoke an Ergo contract's clause
Kind: static method of Commands  
Returns: object - Promise to the result of invocation
| Param | Type | Description | 
|---|---|---|
| ergoPaths | Array.<string> | paths to the Ergo modules | 
| ctoPaths | Array.<string> | paths to CTO models | 
| contractName | string | the contract | 
| 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' | 
| paramsInput | object | the parameters for the clause | 
Commands.init(ergoPaths, ctoPaths, contractName, contractInput, currentTime, paramsInput) ⇒ object
Invoke init for an Ergo contract
Kind: static method of Commands  
Returns: object - Promise to the result of execution
| Param | Type | Description | 
|---|---|---|
| ergoPaths | Array.<string> | paths to the Ergo modules | 
| ctoPaths | Array.<string> | paths to CTO models | 
| contractName | string | the contract name | 
| contractInput | string | the contract data | 
| currentTime | string | the definition of 'now' | 
| paramsInput | object | the parameters for the clause | 
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 | 
setCurrentTime(currentTime) ⇒ object
Ensures there is a proper current time
Kind: global function
Returns: object - if valid, the moment object for the current time
| Param | Type | Description | 
|---|---|---|
| currentTime | string | the definition of 'now' | 
init(engine, templateLogic, contractJson, currentTime) ⇒ 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 | 
| templateLogic | object | the Template Logic | 
| contractJson | object | contract data in JSON | 
| currentTime | string | the definition of 'now' | 
execute(engine, templateLogic, contractJson, stateJson, currentTime, requestJson) ⇒ object
Execute the Ergo contract with a request
Kind: global function
Returns: object - Promise to the response
| Param | Type | Description | 
|---|---|---|
| engine | object | the execution engine | 
| templateLogic | object | the Template Logic | 
| contractJson | object | contract data in JSON | 
| stateJson | object | state data in JSON | 
| currentTime | string | the definition of 'now' | 
| 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 |