-
Notifications
You must be signed in to change notification settings - Fork 48
/
server.ts
126 lines (108 loc) · 3.68 KB
/
server.ts
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import { IExecution , ILogger , IItem, IItemData , IDefinition, IConfiguration, IAppDelegate, IDataStore,IModelsDatastore } from '../';
import { EventEmitter } from 'events';
import { IUserService } from './User';
interface IBPMNServer {
engine: IEngine;
listener: EventEmitter;
configuration: IConfiguration;
logger: ILogger;
definitions: IModelsDatastore;
appDelegate: IAppDelegate;
dataStore: IDataStore;
cache: ICacheManager;
cron: ICron;
userService: IUserService;
}
interface IServerComponent {
server: IBPMNServer;
configuration: IConfiguration;
logger: ILogger;
cron: any;
cache;
appDelegate: IAppDelegate;
engine: any;
dataStore: IDataStore;
definitions;
}
interface IEngine {
/**
* loads a definitions and start execution
*
* @param name name of the process to start
* @param data input data
* @param startNodeId in process has multiple start node; you need to specify which one
*/
start(name: any, data?: any, startNodeId?: string, userName?: string, options?: any): Promise<IExecution>;
/**
* restores an instance into memeory or provides you access to a running instance
*
* this will also resume execution
*
* @param instanceQuery criteria to fetch the instance
*
* query example: { id: instanceId}
* { data: {caseId: 1005}}
* { items.id : 'abcc111322'}
* { items.itemKey : 'businesskey here'}
*
*/
get(instanceQuery: any): Promise<IExecution>;
/**
* Continue an existing item that is in a wait state
*
* -------------------------------------------------
* scenario:
* itemId {itemId: value }
* itemKey {itemKey: value}
* instance,task {instanceId: instanceId, elementId: value }
*
* @param itemQuery criteria to retrieve the item
* @param data
*/
invoke(itemQuery: any, data: {}, userName?: string, options?: {}): Promise<IExecution>;
assign(itemQuery: any, data: {}, assignment: {}, userName: string,options?:{}): Promise<IExecution>;
startRepeatTimerEvent(instanceId, prevItem: IItem, data: {},options?:{}) : Promise<IExecution>;
/**
*
* Invoking an event (usually start event of a secondary process) against an existing instance
* or
* Invoking a start event (of a secondary process) against an existing instance
* ----------------------------------------------------------------------------
* instance,task
*```
* {instanceId: instanceId, elementId: value }
*```
*
* @param instanceId
* @param elementId
* @param data
*/
startEvent(instanceId: any, elementId: any, data?: {}): Promise<IExecution>;
/**
*
* signal/message raise a signal or throw a message
*
* will seach for a matching event/task given the signalId/messageId
*
* that can be againt a running instance or it may start a new instance
* ----------------------------------------------------------------------------
* @param messageId the id of the message or signal as per bpmn definition
* @param matchingKey should match the itemKey (if specified)
* @param data message data
*/
//signal(messageId: any, matchingKey: any, data?: {}): Promise<IExecution>;
throwMessage(messageId, data: {}, matchingQuery: {}): Promise<IExecution>;
throwSignal(signalId, data: {}, matchingQuery: {});
}
interface ICron {
checkTimers(duration);
start();
startTimers();
}
interface ICacheManager {
list();
add(execution: IExecution);
remove(instanceId);
shutdown();
}
export { IBPMNServer , IEngine , ICron ,ICacheManager , IServerComponent }