@onify/flow-extensions 9.1.1 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types/index.d.ts CHANGED
@@ -1,58 +1,317 @@
1
1
  declare module '@onify/flow-extensions' {
2
- import { SequenceFlow, TimerEventDefinition, ElementBase, IExtension, ContextInstance } from 'bpmn-elements';
3
- import { extendFn as extendFunction } from 'moddle-context-serializer';
2
+ import type { SequenceFlow, TimerEventDefinition } from 'bpmn-elements';
3
+ /**
4
+ * Onify flow extensions factory, pass to the engine as `extensions: { onify: extensions }`
5
+ * @returns undefined for an element without camunda extension data, letting bpmn-elements skip it (and e.g. attach its built-in `assignOutput` extension)
6
+ */
7
+ export function extensions(element: import("bpmn-elements").ElementBase, context: import("bpmn-elements").ContextInstance): import("bpmn-elements").IExtension | undefined;
8
+ /**
9
+ * Extend function for moddle-context-serializer, registers scripts and timers at serialize time
10
+ * */
11
+ export function extendFn(behaviour: import("bpmn-moddle").BaseElement & Record<string, any>, context: import("moddle-context-serializer").ExtendContext): void;
12
+ export class OnifySequenceFlow extends SequenceFlow {
13
+ extensions: OnifyExtensions;
14
+ #private;
15
+ }
16
+ export class OnifyTimerEventDefinition extends TimerEventDefinition {
17
+ /**
18
+ * Supported timeCycle formats
19
+ * */
20
+ get supports(): string[];
21
+ }
22
+ /**
23
+ * assembled element extensions
24
+ */
25
+ type OnifyExtensions = {
26
+ /**
27
+ * enter/end formatting
28
+ */
29
+ format?: FormatActivity | FormatProcess | undefined;
30
+ /**
31
+ * service factory
32
+ */
33
+ Service?: import("bpmn-elements").IActivityBehaviour | undefined;
34
+ /**
35
+ * camunda:InputOutput
36
+ */
37
+ io?: InputOutput | undefined;
38
+ /**
39
+ * camunda:Properties
40
+ */
41
+ properties?: IOProperties | undefined;
42
+ /**
43
+ * camunda:FormData
44
+ */
45
+ form?: IOForm | undefined;
46
+ /**
47
+ * camunda:ExecutionListener
48
+ */
49
+ listeners?: ExecutionListeners | undefined;
50
+ };
51
+ class FormatActivity {
52
+
53
+ constructor(activity: import("bpmn-elements").Activity);
54
+ activity: import("bpmn-elements").Activity;
55
+ resultVariable: any;
56
+ timeCycles: never[] | undefined;
57
+ hasFormatting: boolean;
58
+
59
+ resolve(elementApi: import("bpmn-elements").IApi<import("bpmn-elements").Activity>): any;
60
+ }
61
+ class FormatProcess {
62
+
63
+ constructor(bp: import("bpmn-elements").Process);
64
+ process: import("bpmn-elements").Process;
65
+ _historyTTL: any;
66
+
67
+ resolve(elementApi: import("bpmn-elements").IApi<import("bpmn-elements").Process>): any;
68
+ }
69
+ class IOBase {
70
+ constructor(parm: any);
71
+
72
+ name: string;
73
+
74
+ type: string;
75
+
76
+ behaviour: any;
77
+
78
+ getValue(activity: import("bpmn-elements").Activity, executionMessage: import("bpmn-elements").ElementBrokerMessage): Promise<{
79
+ name: any;
80
+ }>;
81
+ }
82
+ class InputOutput {
83
+
84
+ constructor(parentId: string, behaviour: any, context: import("bpmn-elements").ContextInstance);
85
+ parentId: string;
86
+ context: import("bpmn-elements").ContextInstance;
87
+ input: IOBase[];
88
+ output: IOBase[];
89
+
90
+ getInput(activity: import("bpmn-elements").Activity, executionMessage: import("bpmn-elements").ElementBrokerMessage): Promise<Record<string, any>>;
91
+
92
+ getOutput(activity: import("bpmn-elements").Activity, executionMessage: import("bpmn-elements").ElementBrokerMessage): Promise<Record<string, any>>;
93
+ /**
94
+ * @param parentId parent element id
95
+ * @param list list of IO behaviours
96
+ * @param ioType type of IO
97
+ * */
98
+ _map(parentId: string, list: any[], ioType: string, context: import("bpmn-elements").ContextInstance): IOBase[];
99
+ }
100
+ class IOProperties {
101
+ constructor(activity: any, behaviour: any);
102
+ activity: any;
103
+ behaviour: any;
104
+ /**
105
+ * @param : import('bpmn-elements').IApi<any>} elementApi
106
+ * */
107
+ resolve(elementApi: any): Record<string, any>;
108
+ }
109
+ class IOForm {
110
+ constructor(activity: any, behaviour: any);
111
+ activity: any;
112
+ behaviour: any;
113
+
114
+ resolve(elementApi: import("bpmn-elements").IApi<import("bpmn-elements").Activity>): Record<string, any>;
115
+ }
116
+ class ExecutionListeners {
117
+
118
+ constructor(activity: import("bpmn-elements").Activity | import("bpmn-elements").SequenceFlow, context: import("bpmn-elements").ContextInstance);
119
+ activity: import("bpmn-elements").Activity | import("bpmn-elements").SequenceFlow;
120
+ context: import("bpmn-elements").ContextInstance;
121
+
122
+ listeners: (ScriptListener | ExpressionListener)[];
123
+ get length(): number;
124
+ get onStart(): boolean;
125
+ get onEnd(): boolean;
126
+ get onTake(): boolean;
127
+ add(extension: any, pos: any): void;
128
+ execute(event: any, message: any): Promise<{}>;
129
+ }
130
+ class ScriptListener extends Listener {
131
+ /**
132
+ * @param pos execution listener position
133
+ */
134
+ constructor(activity: import("bpmn-elements").Activity | import("bpmn-elements").SequenceFlow, context: import("bpmn-elements").ContextInstance, extension: {
135
+ script: {
136
+ $type: string;
137
+ [x: string]: any;
138
+ };
139
+ [x: string]: any;
140
+ }, pos: number);
141
+ id: string;
142
+ execute(api: any): Promise<any>;
143
+ _register(context: any, id: any, script: any): void;
144
+ }
145
+ class ExpressionListener extends Listener {
146
+ execute(api: any): Promise<{
147
+ expression: any;
148
+ }>;
149
+ }
150
+ class Listener {
151
+
152
+ constructor(activity: import("bpmn-elements").Activity | import("bpmn-elements").SequenceFlow, context: import("bpmn-elements").ContextInstance, extension: {
153
+ $type: string;
154
+ event: string;
155
+ [x: string]: any;
156
+ });
157
+ activity: import("bpmn-elements").Activity | import("bpmn-elements").SequenceFlow;
158
+ environment: import("bpmn-elements").Environment;
159
+ context: import("bpmn-elements").ContextInstance;
160
+ extension: {
161
+ [x: string]: any;
162
+ $type: string;
163
+ event: string;
164
+ };
165
+ type: string;
166
+ event: string;
167
+
168
+ execute(_api: import("bpmn-elements").IApi<any>): Promise<any>;
169
+
170
+ _getScope(api: import("bpmn-elements").IApi<any>, extend?: Record<string, any>): {
171
+ type: string;
172
+ listener: {
173
+ event: string;
174
+ };
175
+ fields: Required<import("smqp").MessageFields>;
176
+ content: import("bpmn-elements").ElementMessageContent;
177
+ properties: import("smqp").MessageProperties;
178
+ environment: import("bpmn-elements").Environment;
179
+ logger: import("bpmn-elements").ILogger;
180
+ };
181
+
182
+ _getFields(environment: import("bpmn-elements").Environment, scope: any): Record<string, any>;
183
+ }
4
184
 
5
- export class OnifySequenceFlow extends SequenceFlow {}
6
- export class OnifyTimerEventDefinition extends TimerEventDefinition {
7
- readonly supports: string[];
8
- }
9
- export function extensions(element: ElementBase, context: ContextInstance): IExtension;
10
- export const extendFn: extendFunction;
185
+ export {};
11
186
  }
12
187
 
13
188
  declare module '@onify/flow-extensions/FlowScripts' {
14
- import { IScripts, Script, ExecutionScope } from 'bpmn-elements';
15
- import { SerializableElement } from 'moddle-context-serializer';
16
- import { ScriptOptions } from 'node:vm';
189
+ import type { Script } from 'node:vm';
190
+ /**
191
+ * Flow scripts provider
192
+ * @param flowName Flow name
193
+ * @param resourceBase External resource base
194
+ * @param runContext Optional script globals
195
+ * @param timeout Optional execution timeout in milliseconds, default 60000
196
+ */
197
+ export function FlowScripts(flowName: string, resourceBase: string, runContext?: any, timeout?: number): void;
198
+ export class FlowScripts {
199
+ /**
200
+ * Flow scripts provider
201
+ * @param flowName Flow name
202
+ * @param resourceBase External resource base
203
+ * @param runContext Optional script globals
204
+ * @param timeout Optional execution timeout in milliseconds, default 60000
205
+ */
206
+ constructor(flowName: string, resourceBase: string, runContext?: any, timeout?: number);
207
+ flowName: string;
208
+
209
+ scripts: Map<string, JavaScript | JavaScriptResource>;
210
+ timeout: number;
211
+ runContext: any;
212
+ /**
213
+ * Register script element
214
+ * */
215
+ register({ id, type, behaviour }: import("moddle-context-serializer").SerializableElement): void;
216
+ /**
217
+ * Get registered script
218
+ * */
219
+ getScript(scriptType: string, { id }: {
220
+ id: string;
221
+ }): JavaScript | JavaScriptResource | undefined;
222
+ [kResources]: string;
223
+ }
224
+ /**
225
+ * Java script
226
+ *
227
+ */
228
+ export function JavaScript(flowName: string, scriptBody: string | Buffer, runContext?: any, options?: import("node:vm").ScriptOptions & {
229
+ filename?: string;
230
+ timeout?: number;
231
+ }): void;
232
+ export class JavaScript {
233
+ /**
234
+ * Java script
235
+ *
236
+ */
237
+ constructor(flowName: string, scriptBody: string | Buffer, runContext?: any, options?: import("node:vm").ScriptOptions & {
238
+ filename?: string;
239
+ timeout?: number;
240
+ });
241
+ flowName: string;
242
+ options: (import("node:vm").ScriptOptions & {
243
+ filename?: string;
244
+ timeout?: number;
245
+ }) | undefined;
246
+ runContext: any;
247
+ timeout: number | undefined;
248
+ script: Script | undefined;
249
+ /**
250
+ * Execute script
251
+ * */
252
+ execute(executionContext: import("bpmn-elements").ExecutionScope, callback: CallableFunction): Promise<any>;
253
+ [kSyntaxError]: FlowSyntaxError;
254
+ }
255
+ /**
256
+ * Java script resource
257
+ * @param resource Resource name or path
258
+ * @param resourceBase Resource base
259
+ *
260
+ */
261
+ export function JavaScriptResource(flowName: string, resource: string, resourceBase: string, runContext?: any, options?: import("node:vm").ScriptOptions & {
262
+ filename?: string;
263
+ timeout?: number;
264
+ }): void;
265
+ export class JavaScriptResource {
266
+ /**
267
+ * Java script resource
268
+ * @param resource Resource name or path
269
+ * @param resourceBase Resource base
270
+ *
271
+ */
272
+ constructor(flowName: string, resource: string, resourceBase: string, runContext?: any, options?: import("node:vm").ScriptOptions & {
273
+ filename?: string;
274
+ timeout?: number;
275
+ });
276
+ flowName: string;
277
+ resource: string;
278
+ runContext: any;
279
+ options: (import("node:vm").ScriptOptions & {
280
+ filename?: string;
281
+ timeout?: number;
282
+ }) | undefined;
283
+ timeout: number | undefined;
284
+ resourceBase: string;
285
+ /**
286
+ * Get javascript resource content
287
+ * @param resourceBase Resource base
288
+ * @param resource Resolved resource name or path
289
+ * @returns Resource content
290
+ */
291
+ getResourceContent(resourceBase: string, resource: string): Promise<string | Buffer>;
292
+ /**
293
+ * Execute script resource
294
+ * */
295
+ execute(executionContext: import("bpmn-elements").ExecutionScope, callback: CallableFunction): Promise<any>;
296
+ }
297
+ export class FlowScriptError extends Error {
298
+
299
+ constructor(fromErr: Error);
300
+ }
301
+ export class FlowSyntaxError extends Error {
302
+
303
+ constructor(fromErr: Error);
304
+ }
305
+ export class FlowResourceError extends FlowScriptError {
306
+
307
+ constructor(fromErr: Error, filename?: string);
308
+ filename: string | undefined;
309
+ inner: Error;
310
+ }
311
+ const kResources: unique symbol;
312
+ const kSyntaxError: unique symbol;
17
313
 
18
- type registerArgument = SerializableElement | { id: string; type: string; behavior: any };
19
-
20
- export interface FlowScriptOptions extends ScriptOptions {
21
- timeout?: number;
22
- }
23
-
24
- export class FlowScripts implements IScripts {
25
- /**
26
- * @param flowName Flow name
27
- * @param resourceBase External resource base
28
- * @param runContext Optional script globals
29
- * @param timeout Optional execution timeout in milliseconds, default 60000
30
- */
31
- constructor(flowName: string, resourceBase: string, runContext?: any, timeout?: number);
32
- flowName: string;
33
- timeout: number;
34
- /** Registered scripts */
35
- get scripts(): Map<string, Script | JavaScriptResource>;
36
- /** Registered scripts */
37
- register(element: registerArgument): Script | undefined;
38
- getScript(language: string, identifier: { id: string; [x: string]: any }): Script;
39
- }
40
-
41
- export class JavaScript implements Script {
42
- constructor(flowName: string, scriptBody: string | Buffer, runContext: any, options?: FlowScriptOptions);
43
- get flowName(): string;
44
- get runContext(): unknown;
45
- get options(): FlowScriptOptions;
46
- execute(executionContext: ExecutionScope, callback: CallableFunction): void;
47
- }
48
-
49
- export class JavaScriptResource extends JavaScript {
50
- constructor(flowName: string, resource: string, resourceBase: string, runContext?: unknown, options?: FlowScriptOptions);
51
- /**
52
- * Get javascript resource content
53
- * @param resourceBase Resource base
54
- * @param resource Resolved resource name or path
55
- */
56
- getResourceContent(resourceBase: string, resource: string): Promise<string | Buffer>;
57
- }
314
+ export {};
58
315
  }
316
+
317
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,52 @@
1
+ {
2
+ "version": 3,
3
+ "file": "index.d.ts",
4
+ "names": [
5
+ "extensions",
6
+ "extendFn",
7
+ "OnifySequenceFlow",
8
+ "OnifyTimerEventDefinition",
9
+ "FormatActivity",
10
+ "FormatProcess",
11
+ "IOBase",
12
+ "InputOutput",
13
+ "IOProperties",
14
+ "IOForm",
15
+ "ExecutionListeners",
16
+ "ScriptListener",
17
+ "ExpressionListener",
18
+ "Listener",
19
+ "FlowScripts",
20
+ "JavaScript",
21
+ "JavaScriptResource",
22
+ "FlowScriptError",
23
+ "FlowSyntaxError",
24
+ "FlowResourceError",
25
+ "kResources",
26
+ "kSyntaxError"
27
+ ],
28
+ "sources": [
29
+ "../src/index.js",
30
+ "../src/OnifySequenceFlow.js",
31
+ "../src/OnifyTimerEventDefinition.js",
32
+ "../src/formatters.js",
33
+ "../src/IO.js",
34
+ "../src/IOProperties.js",
35
+ "../src/IOForm.js",
36
+ "../src/ExecutionListeners.js",
37
+ "../test/helpers/FlowScripts.js"
38
+ ],
39
+ "sourcesContent": [
40
+ null,
41
+ null,
42
+ null,
43
+ null,
44
+ null,
45
+ null,
46
+ null,
47
+ null,
48
+ null
49
+ ],
50
+ "mappings": ";;;;;;iBAcgBA,UAAUA;;;;iBAuBVC,QAAQA;cClCXC,iBAAiBA;;;;cCAjBC,yBAAyBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OCHzBC,cAAcA;;;;;;;;;;OAqDdC,aAAaA;;;;;;;;OCrDbC,MAAMA;;;;;;;;;;;;;OAoHNC,WAAWA;;;;;;;;;;;;;;;;;;OCpHXC,YAAYA;;;;;;;;;OCEZC,MAAMA;;;;;;;OCuHNC,kBAAkBA;;;;;;;;;;;;;;OAzDzBC,cAAcA;;;;;;;;;;;;;;;OAkDdC,kBAAkBA;;;;;OAlHlBC,QAAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCwEEC,WAAWA;cAAXA,WAAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+DXC,UAAUA;;;;cAAVA,UAAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6DVC,kBAAkBA;;;;cAAlBA,kBAAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA7LrBC,eAAeA;;;;cAuBfC,eAAeA;;;;cAuBfC,iBAAiBA;;;;;;OAhDxBC,UAAUA;OADVC,YAAYA",
51
+ "ignoreList": []
52
+ }