Node.js 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.
- setCurrentTime(currentTime) ⇒
object Ensures there is a proper current time
- init(engine, logicManager, contractJson, currentTime) ⇒
object Invoke Ergo contract initialization
- trigger(engine, logicManager, contractJson, stateJson, currentTime, 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
- .draft(template, files, contractInput, currentTime, options) ⇒
object - .trigger(template, files, contractInput, stateInput, currentTime, requestsInput, warnings) ⇒
object - .invoke(template, files, clauseName, contractInput, stateInput, currentTime, paramsInput, warnings) ⇒
object - .initialize(template, files, contractInput, currentTime, paramsInput, warnings) ⇒
object - .parseCTOtoFileSync(ctoPath) ⇒
string - .parseCTOtoFile(ctoPath) ⇒
string
- .draft(template, files, contractInput, currentTime, options) ⇒
Commands.draft(template, files, contractInput, currentTime, options) ⇒ object
Invoke draft 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' |
| options | object | to the text generation |
Commands.trigger(template, files, contractInput, stateInput, currentTime, 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' |
| requestsInput | Array.<string> | the requests |
| warnings | boolean | whether to print warnings |
Commands.invoke(template, files, clauseName, contractInput, stateInput, currentTime, 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' |
| paramsInput | object | the parameters for the clause |
| warnings | boolean | whether to print warnings |
Commands.initialize(template, files, contractInput, currentTime, 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' |
| 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. |
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, logicManager, 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 |
| logicManager | object | the Template Logic |
| contractJson | object | contract data in JSON |
| currentTime | string | the definition of 'now' |
trigger(engine, logicManager, contractJson, stateJson, currentTime, 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' |
| 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 |