DSCP Process Management Flow
npm install @digicatapult/dscp-process-managementA Library for managing restricted process flows in DSCP.
For the basic application to work and for locally run tests to work docker-compose up must be run.
The build command should be run first to create the converted ts files.
``shell`
npm run build
To start the basic application
`shell`
npm run local
To install npm CLI tool. It will be linked to local binaries so can be executed as process-management
`shell`
npm i -g
`sh`
process-management help
dscp-process-management takes the following arguments to configure the Polkadot.js API connection:
| variable | required | default | description |
| :------- | :------: | :---------: | :-------------------------------------------------------------------------------------------------------------------- |
| host | N | localhost | The hostname of the dscp-node the API should connect to |port
| | N | 9944 | The port of the dscp-node the API should connect to |user
| | Y | - | The Substrate URI representing the private key to use when making dscp-node transactions. //Alice for dev chain |
For the full list of available restrictions see dscp-node
Returns all available commands
`sh
$ process-management
Usage: process management [options] [command]
a command line interface for managing chain processes
Options:
-v, --version output current version
--help display help for command
Commands:
list [options] A command for listing all active process flows
create [options]
disable [options]
help [command] display help for command
`
`sh
$ process-management help create
Usage: process management create [options]
A command for persisting process flows onto the chain
Options:
--dryRun to validate process and response locally before persisting on the chain, default - false
--verbose Returns all information about the transation, default - false
-h, --host
-p, --port
-f, --file
-u, --user
--help display help for command
#
$ process-management create -h localhost -p 9944 -u //Alice '[{"name":"A test","version":1,"program":[{"restriction":{"FixedNumberOfOutputs":{"numOutputs":1}}},{"restriction":{"None":{}}},{"op":"Or"}]}]'
{
'A test': {
message: 'Transaction for new process A test has been successfully submitted',
process: {
id: 'A test',
version: 1,
status: 'Enabled',
program: [
{ restriction: { FixedNumberOfOutputs: { numOutputs: 1 } } },
{ restriction: { None: {} } },
{ op: 'Or' }
]
}
}
}
`
Or use a .json file
``
process-management create -h localhost -p 9944 -u //Alice "$(cat exampleProcess.json)"
`sh
$ process-management help disable
Usage: process management disable [options]
A command for disabling an existing process flows. Required process ID and version
Arguments:
id a valid process id that you would like to disable
version a version number of a process
Options:
--dryRun to validate process and response locally before persisting on the chain, default - false
-h, --host
-p, --port
--print print debugging info
-u, --user
--help display help for command
#
{
'B test': {
message: 'Transaction for new process B test has been successfully submitted',
process: {
id: 'B test',
version: 1,
status: 'Enabled',
program: [
{ restriction: { FixedNumberOfOutputs: { numOutputs: 1 } } },
{ restriction: { None: {} } },
{ op: 'Or' }
]
}
}
}
$ process-management disable -u //Alice 'B test' '1'
{
message: 'Process has been disabled',
process: { id: 'B test', version: 1, status: 'Disabled' }
}
`
`sh
$ process-management list --help
Usage: process management list [options]
A command for listing all active process flows
Options:
-h, --host
-p, --port
--raw print processes with hex values and extra keys such as "createdAtHash"
--active returns only active process flows
--disabled returns only disabled process flows
--print print debugging info
--help display help for command
#
$ process-management list --active
[
{
id: 'default',
version: 1,
status: 'Enabled',
program: [ { restriction: { none: null } } ]
}
]
`
Unit tests can be run without docker using:
`shell`
npm run test:unit
To run the integration test suite first bring up the test dependency services using docker
`shell`
docker compose -f ./docker-compose-test.yaml up -d
And then to run the tests
`shell``
npm run test