-
Notifications
You must be signed in to change notification settings - Fork 3
/
fsm.js
31 lines (28 loc) · 868 Bytes
/
fsm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Machine, MachineDefinition } from '@opuscapita/fsm-workflow-core';
import history from '@opuscapita/fsm-workflow-history';
import actions from '../data/actions';
import conditions from '../data/conditions';
import { objectIdProp } from '../../common';
import schema from '../schema';
import objectConfig from '../objectConfig';
class FSM {
init = async function(sequelize) {
this.history = await history(sequelize)
}
get machine() {
return new Machine({
machineDefinition: new MachineDefinition({
schema: schema.getSchema(),
actions,
conditions,
objectConfiguration: objectConfig.getConfig()
}),
convertObjectToReference: object => ({
businessObjType: 'invoice',
businessObjId: object[objectIdProp]
}),
history: this.history
})
}
}
export default new FSM();