{"_id":"@opuscapita/fsm-core","_rev":"58-c17ed61dc20ce1653c21544f3403a249","name":"@opuscapita/fsm-core","dist-tags":{"latest":"0.0.1-beta.5"},"versions":{"0.0.1-beta.0":{"name":"@opuscapita/fsm-core","version":"0.0.1-beta.0","author":{"name":"Alexey Sergeev","email":"sab@scand.com"},"license":"Apache-2.0","_id":"@opuscapita/fsm-core@0.0.1-beta.0","maintainers":[{"name":"kirillvolkovich","email":"kirill.volkovich@jcatalog.com"}],"homepage":"https://github.com/OpusCapita/fsm/tree/master/core#readme","bugs":{"url":"https://github.com/OpusCapita/fsm/issues"},"nyc":{"lines":100,"exclude":["**/*.spec.js"],"branches":100,"functions":100,"sourceMap":false,"instrument":false,"statements":100,"check-coverage":true},"dist":{"shasum":"a5d07c896cb3a5792bf9dd56c9a524cb3f782274","tarball":"https://registry.npmjs.org/@opuscapita/fsm-core/-/fsm-core-0.0.1-beta.0.tgz","integrity":"sha512-YJO+b3YT93INBbTKlr5I2l1Lh2mMMoc3/nHnZsXaOLnxhDhSIIw41xRW4YXwmSJNVqGg532JbvjgyykBXJ9ehg==","signatures":[{"sig":"MEYCIQDYNYoxf+05gp+m6foCPNTxH9we5nT0YX8C0kyVEk1F6wIhANy9I5WjEJ67M2E/++nCsTaI6zzdc1FcWKInmcIOiUez","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"a5d07c896cb3a5792bf9dd56c9a524cb3f782274","scripts":{"lint":"eslint src","test":"rimraf ./.nyc_output ./coverage && cross-env nyc --reporter=lcov --reporter=text mocha --require config/mocha-setup.js --recursive 'src/**/*.spec.js'","build":"cross-env NODE_ENV=production webpack --config config/webpack.config.js","test-only":"mocha src/**/*.spec.js --require config/mocha-setup.js","publish-release":"update-changelog -- --all && npm run build && npm-publish --release"},"_npmUser":{"name":"kirillvolkovich","email":"kirill.volkovich@jcatalog.com"},"repository":{"url":"https://github.com/OpusCapita/fsm/tree/master/core","type":"git"},"_npmVersion":"4.6.1","description":"FSM workflow (for Node.js)","directories":{},"_nodeVersion":"6.9.1","dependencies":{"bluebird":"3.5.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"devDependencies":{"nyc":"11.0.2","mocha":"3.3.0","eslint":"3.12.2","rimraf":"2.6.1","webpack":"3.0.0","cross-env":"5.0.1","babel-core":"6.24.0","babel-eslint":"6.1.2","babel-loader":"6.4.1","babel-register":"6.24.1","babel-preset-react":"6.24.1","babel-preset-es2015":"6.24.1","eslint-plugin-react":"6.8.0","babel-preset-stage-0":"6.24.1","mocha-junit-reporter":"1.13.0","babel-plugin-istanbul":"4.1.4","@opuscapita/npm-scripts":"2.0.0-beta.2","eslint-config-opuscapita":"1.0.3"},"_npmOperationalInternal":{"tmp":"tmp/fsm-core-0.0.1-beta.0.tgz_1499348306592_0.03261732147075236","host":"s3://npm-registry-packages"}},"0.0.1-beta.1":{"name":"@opuscapita/fsm-core","version":"0.0.1-beta.1","author":{"name":"Alexey Sergeev","email":"sab@scand.com"},"license":"Apache-2.0","_id":"@opuscapita/fsm-core@0.0.1-beta.1","maintainers":[{"name":"eriihine","email":"esa.riihinen@gmail.com"},{"name":"havantkim","email":"kimmo.havantola@opuscapita.com"},{"name":"ilkkalehtinen","email":"ilkka.lehtinen@opuscapita.com"},{"name":"gr4per","email":"arne.graeper@opuscapita.com"},{"name":"kirillvolkovich","email":"kirill.volkovich@jcatalog.com"},{"name":"alexeysergeev","email":"sab@scand.com"}],"homepage":"https://github.com/OpusCapita/fsm/tree/master/core#readme","bugs":{"url":"https://github.com/OpusCapita/fsm/issues"},"nyc":{"lines":100,"exclude":["**/*.spec.js"],"branches":100,"functions":100,"sourceMap":false,"instrument":false,"statements":100,"check-coverage":true},"dist":{"shasum":"9ba912796a0df211d9cbe1994d0a2f4e81bd6067","tarball":"https://registry.npmjs.org/@opuscapita/fsm-core/-/fsm-core-0.0.1-beta.1.tgz","integrity":"sha512-ptKSsC7XYpVECNQOi3yhKipsG4EQaJ0xkXfkrXFeAWi9y/4iG0XoGs38+gfmTun2TNOf1iMkjYqoMia6Xo1CfQ==","signatures":[{"sig":"MEUCIQC7NVCjuT/I+yl3pwdxqqZHJIe3v2HGrYSSvGT2oBfEqAIgbnq0CjjTI0pnbGLPI1ymFRhSEGedbGN2y/BZxFAw6i8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./lib/index.js","_from":".","files":["lib"],"_shasum":"9ba912796a0df211d9cbe1994d0a2f4e81bd6067","scripts":{"lint":"eslint src","test":"rimraf ./.nyc_output ./coverage && cross-env nyc --reporter=lcov --reporter=text mocha --require config/mocha-setup.js --recursive 'src/**/*.spec.js'","build":"cross-env NODE_ENV=production webpack --config config/webpack.config.js","test-only":"mocha src/**/*.spec.js --require config/mocha-setup.js","publish-release":"update-changelog -- --all && npm run build && npm-publish --release"},"_npmUser":{"name":"kirillvolkovich","email":"kirill.volkovich@jcatalog.com"},"repository":{"url":"https://github.com/OpusCapita/fsm/tree/master/core","type":"git"},"_npmVersion":"4.6.1","description":"FSM workflow (for Node.js)","directories":{},"_nodeVersion":"6.9.1","dependencies":{"bluebird":"3.5.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"devDependencies":{"nyc":"11.0.2","mocha":"3.3.0","eslint":"3.12.2","rimraf":"2.6.1","webpack":"3.0.0","cross-env":"5.0.1","babel-core":"6.24.0","babel-eslint":"6.1.2","babel-loader":"6.4.1","babel-register":"6.24.1","babel-preset-react":"6.24.1","babel-preset-es2015":"6.24.1","eslint-plugin-react":"6.8.0","babel-preset-stage-0":"6.24.1","mocha-junit-reporter":"1.13.0","babel-plugin-istanbul":"4.1.4","@opuscapita/npm-scripts":"2.0.0-beta.2","eslint-config-opuscapita":"1.0.3"},"_npmOperationalInternal":{"tmp":"tmp/fsm-core-0.0.1-beta.1.tgz_1499349684727_0.89716143370606","host":"s3://npm-registry-packages"}},"0.0.1-beta.3":{"name":"@opuscapita/fsm-core","version":"0.0.1-beta.3","author":{"name":"Alexey Sergeev","email":"sab@scand.com"},"license":"Apache-2.0","_id":"@opuscapita/fsm-core@0.0.1-beta.3","maintainers":[{"name":"tamkov-sc","email":"tamkov@scand.com"},{"name":"eriihine","email":"esa.riihinen@gmail.com"},{"name":"havantkim","email":"kimmo.havantola@opuscapita.com"},{"name":"ilkkalehtinen","email":"ilkka.lehtinen@opuscapita.com"},{"name":"gr4per","email":"arne.graeper@opuscapita.com"},{"name":"kirillvolkovich","email":"kirill.volkovich@jcatalog.com"},{"name":"alexeysergeev","email":"sab@scand.com"}],"homepage":"https://github.com/OpusCapita/fsm/tree/master/core#readme","bugs":{"url":"https://github.com/OpusCapita/fsm/issues"},"nyc":{"lines":100,"exclude":["**/*.spec.js"],"branches":100,"functions":100,"sourceMap":false,"instrument":false,"statements":100,"check-coverage":true},"dist":{"shasum":"85179b1890df9ecb807b7a06b5a26a0a39f3f2e3","tarball":"https://registry.npmjs.org/@opuscapita/fsm-core/-/fsm-core-0.0.1-beta.3.tgz","integrity":"sha512-6O84D1K3X8ViuvROJ3Rd7tEAlzkhwTNnBGx45y/041ttASei7+EI7KmsRTzcDtgI37/4SsEhtl/We2x9HCuEOw==","signatures":[{"sig":"MEUCIQDZW9gfIRnAYFHhOyWyJySNngdrnyloSUFAbuzY28QNJwIge29rLctRE21EfXd/XTkBpJnhQK/ns0PTVOkWqWnNp04=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./lib/index.js","_from":".","files":["lib"],"_shasum":"85179b1890df9ecb807b7a06b5a26a0a39f3f2e3","scripts":{"lint":"eslint src","test":"rimraf ./.nyc_output ./coverage && cross-env nyc --reporter=lcov --reporter=text mocha --require config/mocha-setup.js --recursive 'src/**/*.spec.js'","build":"cross-env NODE_ENV=production webpack --config config/webpack.config.js","test-only":"mocha src/**/*.spec.js --require config/mocha-setup.js","publish-release":"update-changelog -- --all && npm run build && npm-publish --release"},"_npmUser":{"name":"kirillvolkovich","email":"kirill.volkovich@jcatalog.com"},"repository":{"url":"https://github.com/OpusCapita/fsm/tree/master/core","type":"git"},"_npmVersion":"4.6.1","description":"FSM workflow (for Node.js)","directories":{},"_nodeVersion":"6.9.1","dependencies":{"bluebird":"3.5.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"devDependencies":{"nyc":"11.0.2","mocha":"3.3.0","eslint":"3.12.2","rimraf":"2.6.1","webpack":"3.0.0","cross-env":"5.0.1","babel-core":"6.24.0","babel-eslint":"6.1.2","babel-loader":"6.4.1","babel-register":"6.24.1","babel-preset-react":"6.24.1","babel-preset-es2015":"6.24.1","eslint-plugin-react":"6.8.0","babel-preset-stage-0":"6.24.1","mocha-junit-reporter":"1.13.0","babel-plugin-istanbul":"4.1.4","@opuscapita/npm-scripts":"2.0.0-beta.2","eslint-config-opuscapita":"1.0.3"},"_npmOperationalInternal":{"tmp":"tmp/fsm-core-0.0.1-beta.3.tgz_1500017594165_0.9948146278038621","host":"s3://npm-registry-packages"}},"0.0.1-beta.4":{"name":"@opuscapita/fsm-core","version":"0.0.1-beta.4","author":{"name":"Alexey Sergeev","email":"sab@scand.com"},"license":"Apache-2.0","_id":"@opuscapita/fsm-core@0.0.1-beta.4","maintainers":[{"name":"tamkov-sc","email":"tamkov@scand.com"},{"name":"eriihine","email":"esa.riihinen@gmail.com"},{"name":"havantkim","email":"kimmo.havantola@opuscapita.com"},{"name":"ilkkalehtinen","email":"ilkka.lehtinen@opuscapita.com"},{"name":"gr4per","email":"arne.graeper@opuscapita.com"},{"name":"kirillvolkovich","email":"kirill.volkovich@jcatalog.com"},{"name":"alexeysergeev","email":"sab@scand.com"}],"homepage":"https://github.com/OpusCapita/fsm/tree/master/core#readme","bugs":{"url":"https://github.com/OpusCapita/fsm/issues"},"nyc":{"lines":100,"exclude":["**/*.spec.js"],"branches":100,"functions":100,"sourceMap":false,"instrument":false,"statements":100,"check-coverage":true},"dist":{"shasum":"7c9b0ddc726412feb6965a12493bdfa481a0777b","tarball":"https://registry.npmjs.org/@opuscapita/fsm-core/-/fsm-core-0.0.1-beta.4.tgz","integrity":"sha512-FW60oWDhQfcROFvlBGP6kOOZcuA4OR2U9n298pdcHbl3Kt8s2LEPE/t4psX66AVSdRWDHBDFxkMCvW3dOucc4g==","signatures":[{"sig":"MEUCID0XO05ZIwwpTQwInBJosDcGMuHRadC2N7VZB79hPsp/AiEAwj3KgJBlpvnTR8lhuFYAiRw5YPyVkCb7Y64Xrcs1kAs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./lib/index.js","_from":".","files":["lib"],"_shasum":"7c9b0ddc726412feb6965a12493bdfa481a0777b","scripts":{"lint":"eslint src","test":"rimraf ./.nyc_output ./coverage && cross-env nyc --reporter=lcov --reporter=text mocha --require config/mocha-setup.js --recursive 'src/**/*.spec.js'","build":"cross-env NODE_ENV=production webpack --config config/webpack.config.js","test-only":"mocha src/**/*.spec.js --require config/mocha-setup.js","publish-release":"update-changelog -- --all && npm run build && npm-publish --release"},"_npmUser":{"name":"alexeysergeev","email":"sab@scand.com"},"repository":{"url":"https://github.com/OpusCapita/fsm/tree/master/core","type":"git"},"_npmVersion":"3.10.10","description":"FSM workflow (for Node.js)","directories":{},"_nodeVersion":"6.9.4","dependencies":{"bluebird":"3.5.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"devDependencies":{"nyc":"11.0.2","mocha":"3.3.0","eslint":"3.12.2","rimraf":"2.6.1","webpack":"3.0.0","cross-env":"5.0.1","babel-core":"6.24.0","babel-eslint":"6.1.2","babel-loader":"6.4.1","babel-register":"6.24.1","babel-preset-react":"6.24.1","babel-preset-es2015":"6.24.1","eslint-plugin-react":"6.8.0","babel-preset-stage-0":"6.24.1","mocha-junit-reporter":"1.13.0","babel-plugin-istanbul":"4.1.4","@opuscapita/npm-scripts":"2.0.0-beta.2","eslint-config-opuscapita":"1.0.3"},"_npmOperationalInternal":{"tmp":"tmp/fsm-core-0.0.1-beta.4.tgz_1500292276837_0.00859255832619965","host":"s3://npm-registry-packages"}},"0.0.1-beta.5":{"name":"@opuscapita/fsm-core","version":"0.0.1-beta.5","author":{"name":"Alexey Sergeev","email":"sab@scand.com"},"license":"Apache-2.0","_id":"@opuscapita/fsm-core@0.0.1-beta.5","maintainers":[{"name":"tamkov-sc","email":"tamkov@scand.com"},{"name":"eriihine","email":"esa.riihinen@gmail.com"},{"name":"havantkim","email":"kimmo.havantola@opuscapita.com"},{"name":"ilkkalehtinen","email":"ilkka.lehtinen@opuscapita.com"},{"name":"gr4per","email":"arne.graeper@opuscapita.com"},{"name":"kirillvolkovich","email":"kirill.volkovich@jcatalog.com"},{"name":"alexeysergeev","email":"sab@scand.com"}],"homepage":"https://github.com/OpusCapita/fsm/tree/master/core#readme","bugs":{"url":"https://github.com/OpusCapita/fsm/issues"},"nyc":{"lines":100,"exclude":["**/*.spec.js"],"branches":100,"functions":100,"sourceMap":false,"instrument":false,"statements":100,"check-coverage":true},"dist":{"shasum":"84d011df0611a240a911b2288e2a9b256cf9f3dd","tarball":"https://registry.npmjs.org/@opuscapita/fsm-core/-/fsm-core-0.0.1-beta.5.tgz","integrity":"sha512-vGRgw0lGp/P95whm66z+324tzNUTa90LpkZTXlI/3jz+3bZf8Ty7qfQzRYMuOwaDwBbIDv5+5vhrpqK72dRp8w==","signatures":[{"sig":"MEQCIDrGETTj+T8G1p0pPLFtLxcbDmkoJNsYGOBEMGMs9rfyAiAPtpFTLtRCcdr09Qfwa6h0/kzagoLbN+XIDy1uzFeYig==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./lib/index.js","_from":".","files":["lib"],"_shasum":"84d011df0611a240a911b2288e2a9b256cf9f3dd","scripts":{"lint":"eslint src","test":"rimraf ./.nyc_output ./coverage && cross-env nyc --reporter=lcov --reporter=text mocha --require config/mocha-setup.js --recursive 'src/**/*.spec.js'","build":"cross-env NODE_ENV=production webpack --config config/webpack.config.js","test-only":"mocha src/**/*.spec.js --require config/mocha-setup.js","publish-release":"update-changelog -- --all && npm run build && npm-publish --release"},"_npmUser":{"name":"kirillvolkovich","email":"kirill.volkovich@jcatalog.com"},"repository":{"url":"https://github.com/OpusCapita/fsm/tree/master/core","type":"git"},"_npmVersion":"3.10.10","description":"FSM workflow (for Node.js)","directories":{},"_nodeVersion":"6.11.0","dependencies":{"bluebird":"3.5.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"devDependencies":{"nyc":"11.0.2","mocha":"3.3.0","eslint":"3.12.2","rimraf":"2.6.1","webpack":"3.0.0","cross-env":"5.0.1","babel-core":"6.24.0","babel-eslint":"6.1.2","babel-loader":"6.4.1","babel-register":"6.24.1","babel-preset-react":"6.24.1","babel-preset-es2015":"6.24.1","eslint-plugin-react":"6.8.0","babel-preset-stage-0":"6.24.1","mocha-junit-reporter":"1.13.0","babel-plugin-istanbul":"4.1.4","@opuscapita/npm-scripts":"2.0.0-beta.2","eslint-config-opuscapita":"1.0.3"},"_npmOperationalInternal":{"tmp":"tmp/fsm-core-0.0.1-beta.5.tgz_1500304933706_0.07022379944100976","host":"s3://npm-registry-packages"}}},"time":{"created":"2017-07-06T13:38:28.414Z","modified":"2026-04-15T16:05:13.735Z","0.0.1-beta.0":"2017-07-06T13:38:28.414Z","0.0.1-beta.1":"2017-07-06T14:01:26.957Z","0.0.1-beta.3":"2017-07-14T07:33:15.456Z","0.0.1-beta.4":"2017-07-17T11:51:18.049Z","0.0.1-beta.5":"2017-07-17T15:22:14.918Z"},"bugs":{"url":"https://github.com/OpusCapita/fsm/issues"},"author":{"name":"Alexey Sergeev","email":"sab@scand.com"},"license":"Apache-2.0","homepage":"https://github.com/OpusCapita/fsm/tree/master/core#readme","repository":{"url":"https://github.com/OpusCapita/fsm/tree/master/core","type":"git"},"description":"FSM workflow (for Node.js)","maintainers":[{"email":"kacpermklosowski@gmail.com","name":"kuos"},{"email":"pim.machineuser@opuscapita.com","name":"ocmachineuser"},{"email":"elzbieta.rymarkiewicz-czapiewska@opuscapita.com","name":"elaczapiewska"},{"email":"ocbuildautomation@opuscapita.com","name":"ocautomation"},{"email":"piotr.krzysztof.murdzia@gmail.com","name":"piotr.krzysztof.murdzia"},{"email":"domin25001@gmail.com","name":"dsbbl"},{"email":"stefan.machnow@opuscapita.com","name":"smachnow"},{"email":"ilham.kaddouri@opuscapita.com","name":"ilhamkadduri"},{"email":"michal.blachu14@gmail.com","name":"mblachu"}],"readme":"# FSM core\n\nMachine and its definition.\n\n## How To Use\n\n### Install package\n\nRun ```npm install @opuscapita/fsm-core``` to get up and running.\n\n### Use in code\n\n```javascript\nimport { MachineDefinition, Machine } from '@opuscapita/fsm-core';\n```\n\n## Machine definition\n\nMachine definition consist of:\n- [schema](#schema)\n- [actions](#action)\n- conditions [guards](#guard-conditions) &amp; [automatic](#automatic-conditions)\n\n### Example\n\n```javascript\nconst machineDefinition = new MachineDefinition({\n  schema: {\n    name: \"invoice approval\",               \n    initialState: \"open\",                   \n    finalStates: [\"approved\"],\n    objectStateFieldName: \"status\",         \n    transitions: [\n      {\n          from: \"open\",                    \n          event: \"approve\",                 \n          guards: [                       \n            {                               \n              \"name\": \"validate\",\n              \"arguments\": {\n                \"argument1\": \"value1\",\n                \"argument2\": \"value2\"\n              }\n            }\n          ],\n          to: \"approved\",                   \n          actions: [                       \n            {                                \n              \"name\": \"archive\",\n              \"arguments\": {\n                \"argument1\": \"value1\",\n                \"argument2\": \"value2\"\n              }\n            }\n          ],\n          automatic: [                          \n            {                                \n                \"name\": \"lastlyUpdatedMoreThan24hAgo\",\n                \"arguments\": {\n                  \"argument1\": \"value1\",\n                  \"argument2\": \"value2\"\n                }\n            }\n          ]\n      }\n    ]\n  },\n  actions: {\n    archive: function({argument1, argument1}) {}\n  },\n  conditions: {\n    validate: function({argument1, argument1}) {},\n    lastlyUpdatedMoreThan24hAgo: function({argument1, argument1}) {}\n  }\n});\n```\n\n### Schema\n\nDefines machine transitions and initialization options. Could be presented as oriented graph, where each node represents state and directed edges are used to represent transition from one state to another.\n\n#### Transitions\n\nIn schema you needs to define an array of available machine transitions. Typically a transition is triggered by an _event_ and happens between _from_ and _to_ states. Optionally each transition can have _actions_, _guards_ and/or _automatic_ (conditions).\n\n#### Initial state\n\nYou can define the initial state by setting the _initialState_ property:\n\n```javascript\nvar machineDefinition = new MachineDefinition({\n  schema: {\n    initial: 'start'\n    transitions: [\n      {from: 'start', event: 'run', to: 'finish'}\n    ]\n  }\n});\n\nconst object = {status: 'none'};\nconst machine = new Machine(machineDefinition);\nmachine.start(object).then(({object}) => {\n  console.log(machine.currentState({object}));\n  // start  \n});\n```\n\nif initial state is not specified, then 'none' will be used (TBD)\n\n#### Final states\n\nYou can define the final states (one or many) by setting the _finalStates_ property:\n\n```javascript\nvar machineDefinition = new MachineDefinition({\n  schema: {\n    initial: 'start',\n    finalStates: ['finish'],\n    transitions: [\n      {from: 'start', event: 'run', to: 'finish'}\n    ]\n  }\n});\n```\n\n### Code (Actions and Conditions(guards/automatic))\n\n[Ideas & thoughts](actionsAndConditions.md)\n\n#### Action\n\nActions (action = function) are executed during transition (not during existing or entering states). Action references specific function by name. Action implemented separately from schema. Each action accepts named arguments explicitly defined in transition and implicit arguments like _object_, _from_, _to_, etc. During transition machine executes each action in defined order. Each action gets _actionExecutionResutls_ argument which serves as an accumulator from perviously called actions, where each property is an action name and value is value returned by action.\n\n#### Guard (conditions)\n\nGuards are used to protect transitions. Guard works as 'if' condition. Technically guard is defined the same way like as action, it is a function. The difference is that it should always return boolean value (true or false).\n\nNote: similar to [Spring State Machine Guards](http://docs.spring.io/spring-statemachine/docs/current/reference/htmlsingle/#configuring-guards)\n\n#### Automatic (conditions)\n\nTransition could be marked as automatic using corresponding property. It could be:\n- true (boolean value) - e.g. this transition is always automatic\n- array of conditions(functions, each return true or false) \nCheck for whether object in current state has (at least one) automatic transition needs to be done by external **[task manager](../task-manager)** (inside the application). Basing on evaluated results task manager will be able to take a decision to send event without user interaction.\n\n\n## Stateful object as a process\n\nMachine does not have own state, all the transitions are performed over object which state is changed by machine. Object is used by Machine as a mutable parameter passed to guards and actions.\n\n```javascript\nvar machineDefinition = new MachineDefinition({\n  schema: {\n    initial: 'start'\n    finalStates: ['finish'],\n    transitions: [\n      {from: 'start', event: 'run', to: 'finish'}\n    ]\n  }\n});\n\nconst object = {status: 'none'};\nconst machine = new Machine(machineDefinition);\nmachine.start(object).then(({object}) => {\n  console.log(machine.currentState({object}));\n  // start\n  return machine.sendEvent({object, event: 'start'})\n}).then(({object}) => {\n  console.log(machine.currentState({object}));\n  // finish\n});\n```\n\n## Machine\n### API\n\n```javascript\nvar machineDefinition = new MachineDefinition({schema, guards, actions})\n// register workflow\nvar machine = new Machine(machineDefinition, context);\n\n// start/initialize machine/workflow\nmachine.start({object})\n\n// returns a list of available transitions: {event, from, to, request..}, e.g. event\n// request is used to pass parameters to guards for some dynamic calculation, e.g. when event availability depends \n// on current user information as roles and etc. \nmachine.availableTransitions({object})\n// returns a list of available automatic transitions: {event, from, to, ..}, e.g. event\n// if machine schema is adequate then there should be not more than 1 such transition\nmachine.availableAutomaticTransitions({})\n\n// send 'event' and pass addition 'request' data that is posted by user/app\n// returns promise, in case of successful transition then function will be called\n// with one parameter that is an JSON with the following structure:\n// - object - object in new state (the same reference that is passed as parameter)\nmachine.sendEvent({object, event, request})\n\nmachine.currentState({ object })     // gets current state\nmachine.is({ object, state})         // is object in state\nmachine.isInFinalState({ object })   // returns true iff object is in one of final states\nmachine.can({ object, event })       // whether event is available\nmachine.cannot({ object, event })    // whether event is not available\n\n// hooks (tbd)\nmachine.onStartTransition()   // returns promise\nmachine.onFinishTransition()  // returns promise\n```\n","readmeFilename":"README.md"}