codehooks-js 1.3.7 → 1.3.9
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/index.js +5 -6
- package/package.json +2 -4
- package/types/aggregation/index.d.mts +38 -1
- package/types/crudlify/index.d.mts +9 -5
- package/types/crudlify/lib/eventhooks.d.mts +1 -0
- package/types/crudlify/lib/query/q2m/index.d.mts +7 -0
- package/types/crudlify/lib/query/q2m/q2m.d.mts +1 -0
- package/types/crudlify/lib/schema/json-schema/index.d.mts +1 -0
- package/types/crudlify/lib/schema/yup/index.d.mts +2 -1
- package/types/crudlify/lib/schema/zod/index.d.mts +1 -0
- package/types/index.d.ts +1373 -126
- package/types/webserver.d.mts +2 -1
- package/types/workflow/engine.d.mts +5 -40
- package/types/workflow/index.d.mts +1 -5
- package/workflow/engine.mjs +362 -109
- package/workflow/index.mjs +2 -14
package/types/index.d.ts
CHANGED
|
@@ -1,138 +1,1385 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Built-in persistent datastore.
|
|
3
|
+
* - Datastore is capable of serving NoSQL object data and Key-Value data.
|
|
4
|
+
*/
|
|
5
|
+
export type Datastore = {
|
|
6
|
+
/**
|
|
7
|
+
* - Connect to Datastore
|
|
8
|
+
*/
|
|
9
|
+
open: () => Promise<DatastoreAPI>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @type {Datastore}
|
|
14
|
+
*/
|
|
15
|
+
export const Datastore: Datastore;
|
|
16
|
+
/**
|
|
17
|
+
* @type {Datastore}
|
|
18
|
+
*/
|
|
19
|
+
export const datastore: Datastore;
|
|
3
20
|
export const aggregation: typeof agg;
|
|
4
21
|
export const crudlify: typeof crud;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Express style API
|
|
25
|
+
* @type {Codehooks}
|
|
26
|
+
*/
|
|
5
27
|
export const coho: Codehooks;
|
|
6
28
|
export const app: Codehooks;
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function createChannel(path: any, ...hook: any[]): void;
|
|
13
|
-
function publishEvent(channel: any, data: any, query?: {}): Promise<any>;
|
|
14
|
-
function createListener(channel: any, data: any): Promise<any>;
|
|
15
|
-
function getListeners(channel: any): Promise<any>;
|
|
16
|
-
function getListener(channel: any, listenerID: any): Promise<any>;
|
|
17
|
-
function removeListener(channel: any, listenerID: any): Promise<any>;
|
|
18
|
-
}
|
|
29
|
+
export const coderunner: any;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Scheduled background worker functions
|
|
33
|
+
*/
|
|
19
34
|
export namespace schedule {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
function runAt(date: any, payload: any, worker: string): Promise<any>;
|
|
36
|
+
function run(payload: any, worker: string): Promise<any>;
|
|
37
|
+
function cron(
|
|
38
|
+
cronExpression: string,
|
|
39
|
+
...hook: ((
|
|
40
|
+
request: httpRequest,
|
|
41
|
+
response: httpResponse,
|
|
42
|
+
next: nextFunction
|
|
43
|
+
) => any)[]
|
|
44
|
+
): void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Real time publish subscribe events
|
|
48
|
+
*/
|
|
49
|
+
export namespace realtime {
|
|
50
|
+
type SSEListener = {
|
|
51
|
+
_id: string;
|
|
52
|
+
[key: string]: any;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Create a real time channel for clients for listen to and server to publish to
|
|
56
|
+
* @param path string - e.g. '/goals'
|
|
57
|
+
* @example
|
|
58
|
+
* realtime.createChannel('/goals')
|
|
59
|
+
*/
|
|
60
|
+
function createChannel(path: string, ...hook: any): void;
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @param channel string - e.g. '/goals'
|
|
64
|
+
* @param data object - Event object to publish
|
|
65
|
+
* @param query object - optional matching criteria for listeners to get the event
|
|
66
|
+
* @example
|
|
67
|
+
* realtime.publishEvent('/goals', {player: "Rod", score: 2})
|
|
68
|
+
*/
|
|
69
|
+
function publishEvent(
|
|
70
|
+
channel: string,
|
|
71
|
+
data: object,
|
|
72
|
+
query?: object
|
|
73
|
+
): Promise<object>;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Create a listener to use to connect to an EventSource later
|
|
77
|
+
* @param path string - Channel
|
|
78
|
+
* @param data object - Listener topics of interest
|
|
79
|
+
* @returns Promise with SSEListener
|
|
80
|
+
*/
|
|
81
|
+
function createListener(path: string, data: object): Promise<SSEListener>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get a listener topics
|
|
85
|
+
* @param path string - Channel
|
|
86
|
+
* @param listenerID - A valid _id for a listener
|
|
87
|
+
*/
|
|
88
|
+
function getListener(path: string, listenerID: string): Promise<SSEListener>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get all listeners on channel
|
|
92
|
+
* @param path string - Channel
|
|
93
|
+
*/
|
|
94
|
+
function getListeners(path: string): Promise<SSEListener[]>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Delete a listenerID
|
|
98
|
+
* @param path string - Channel
|
|
99
|
+
* @param listenerID - A valid listenerID
|
|
100
|
+
*/
|
|
101
|
+
function removeListener(
|
|
102
|
+
path: string,
|
|
103
|
+
listenerID: string
|
|
104
|
+
): Promise<SSEListener>;
|
|
23
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Virtual filesystem
|
|
108
|
+
*/
|
|
24
109
|
export namespace filestore {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Raad file content as stream
|
|
112
|
+
* @see {@link https://codehooks.io/docs/fileapi#filestoregetreadstreampath API docs}
|
|
113
|
+
* @param path Absolute path to file
|
|
114
|
+
* @param options Not in use
|
|
115
|
+
* @returns Promise EventEmitter with chunks on data
|
|
116
|
+
* @example
|
|
117
|
+
* app.get('/image', async (req: httpRequest, res: httpResponse) => {
|
|
118
|
+
* const bufStream = await filestore.getReadStream('/img/logo.png');
|
|
119
|
+
* res.set('content-type', 'image/png')
|
|
120
|
+
* bufStream.on('data', (buf) => {
|
|
121
|
+
* res.write(buf, 'buffer')
|
|
122
|
+
* })
|
|
123
|
+
* .on('end', () => {
|
|
124
|
+
* res.end()
|
|
125
|
+
* })
|
|
126
|
+
* })
|
|
127
|
+
*/
|
|
128
|
+
function getReadStream(path: string, options?: any): Promise<any>;
|
|
129
|
+
/**
|
|
130
|
+
* Read file content as string
|
|
131
|
+
* @see {@link https://codehooks.io/docs/fileapi#filestorereadfilepath API docs}
|
|
132
|
+
* @param path Absolute path to file
|
|
133
|
+
* @param options
|
|
134
|
+
* @returns Promise File content as string
|
|
135
|
+
*/
|
|
136
|
+
function readFile(path: string, options?: any): Promise<String>;
|
|
137
|
+
/**
|
|
138
|
+
* Save file binary buffer
|
|
139
|
+
* @see {@link https://codehooks.io/docs/fileapi#filestoresavefilepath-filestream API docs}
|
|
140
|
+
* @param path Abolute path to file, e.g. /static/home.html
|
|
141
|
+
* @param buffer Stream data
|
|
142
|
+
* @param options Not in use
|
|
143
|
+
* @returns Promise with save result
|
|
144
|
+
* @example
|
|
145
|
+
* import {PassThrough} from 'stream';
|
|
146
|
+
* app.post('/file', async (req, res) => {
|
|
147
|
+
* try {
|
|
148
|
+
* const stream = new PassThrough();
|
|
149
|
+
* req.pipe(stream);
|
|
150
|
+
* const result = await filestore.saveFile('/static.html', stream);
|
|
151
|
+
* res.end(result)
|
|
152
|
+
* } catch (error) {
|
|
153
|
+
* console.error(error)
|
|
154
|
+
* res.status(404).end('Bad upload')
|
|
155
|
+
* }
|
|
156
|
+
* })
|
|
157
|
+
*/
|
|
158
|
+
function saveFile(path: string, buffer: any, options?: any): Promise<any>;
|
|
159
|
+
/**
|
|
160
|
+
* Delete file
|
|
161
|
+
* @see {@link https://codehooks.io/docs/fileapi#filestoredeletefilepath API docs}
|
|
162
|
+
* @param path
|
|
163
|
+
* @param options
|
|
164
|
+
*/
|
|
165
|
+
function deleteFile(path: string, options?: any): Promise<any>;
|
|
166
|
+
/**
|
|
167
|
+
* List file directories and files
|
|
168
|
+
* @see {@link https://codehooks.io/docs/fileapi#filestorelistpath API docs}
|
|
169
|
+
* @param path
|
|
170
|
+
* @param options
|
|
171
|
+
*/
|
|
172
|
+
function list(path: string, options?: any): Promise<Array<Object>>;
|
|
173
|
+
/**
|
|
174
|
+
* Read binary buffer from file
|
|
175
|
+
* @param path Path to file
|
|
176
|
+
* @returns Promise with Buffer
|
|
177
|
+
* @example
|
|
178
|
+
* const myBuf = await filestore.getFileAsBuffer('/images/logo.png');
|
|
179
|
+
*/
|
|
180
|
+
function readFileAsBuffer(path: any): Promise<any>;
|
|
31
181
|
}
|
|
32
182
|
export default _coho;
|
|
183
|
+
/**
|
|
184
|
+
* keyvalOptions
|
|
185
|
+
*/
|
|
186
|
+
export type keyvalOptions = {
|
|
187
|
+
/**
|
|
188
|
+
* - Time to live in milliseconds
|
|
189
|
+
*/
|
|
190
|
+
ttl: number;
|
|
191
|
+
/**
|
|
192
|
+
* - Name of isolated keyspace
|
|
193
|
+
*/
|
|
194
|
+
keyspace: string;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* NoSQL API
|
|
198
|
+
*/
|
|
199
|
+
export type NoSQLAPI = {
|
|
200
|
+
/**
|
|
201
|
+
* - Get object by ID, returns a Promise with the object
|
|
202
|
+
*/
|
|
203
|
+
getOne: (query: string | object) => Promise<object>;
|
|
204
|
+
/**
|
|
205
|
+
* - Get object by ID, returns a Promise with the object - alias for getOne
|
|
206
|
+
*/
|
|
207
|
+
findOne: (query: string | object) => Promise<object>;
|
|
208
|
+
/**
|
|
209
|
+
* - Get stream of objects by query
|
|
210
|
+
* https://codehooks.io/docs/nosql-database-api#getmanycollection-query-options
|
|
211
|
+
*/
|
|
212
|
+
getMany: (query: object, options?: object) => DataStream;
|
|
213
|
+
/**
|
|
214
|
+
* - Get stream of objects by query, alias for getMany
|
|
215
|
+
*/
|
|
216
|
+
find: (query: object, options?: object) => DataStream;
|
|
217
|
+
/**
|
|
218
|
+
* - Insert a new data object into a collection in the current Datastore
|
|
219
|
+
*/
|
|
220
|
+
insertOne: (document: object) => Promise<object>;
|
|
221
|
+
/**
|
|
222
|
+
* - Update one data object by ID in a datastore collection.
|
|
223
|
+
* - Input document is patched with the matched database object
|
|
224
|
+
* @param query string | object
|
|
225
|
+
* @param document object
|
|
226
|
+
* @param updateoperators object
|
|
227
|
+
* @param options object - {upsert: true}
|
|
228
|
+
* @returns Promise<object>
|
|
229
|
+
*/
|
|
230
|
+
updateOne: (
|
|
231
|
+
query: string | object,
|
|
232
|
+
document: object,
|
|
233
|
+
updateoperators?: object,
|
|
234
|
+
options?: object
|
|
235
|
+
) => Promise<object>;
|
|
236
|
+
/**
|
|
237
|
+
* - Update multiple data objects in a datastore collection.
|
|
238
|
+
* - Input document is patched with the matched database objects
|
|
239
|
+
*/
|
|
240
|
+
updateMany: (
|
|
241
|
+
query: object,
|
|
242
|
+
document: object,
|
|
243
|
+
options?: object
|
|
244
|
+
) => Promise<object>;
|
|
245
|
+
/**
|
|
246
|
+
* - Replace one data object by ID in a datastore collection.
|
|
247
|
+
* - Input document overwrites the matched database object, the _id value is not overwritten.
|
|
248
|
+
*/
|
|
249
|
+
replaceOne: (
|
|
250
|
+
query: string | object,
|
|
251
|
+
document: object,
|
|
252
|
+
options?: object
|
|
253
|
+
) => Promise<object>;
|
|
254
|
+
/**
|
|
255
|
+
* - Replace multiple data objects in a datastore collection.
|
|
256
|
+
* - Input document overwrites the matched database objects. The _id value is not overwritten
|
|
257
|
+
*/
|
|
258
|
+
replaceMany: (
|
|
259
|
+
query: object,
|
|
260
|
+
document: object,
|
|
261
|
+
options?: object
|
|
262
|
+
) => Promise<object>;
|
|
263
|
+
/**
|
|
264
|
+
* - Remove one data object by ID in a collection in the current Datastore
|
|
265
|
+
*/
|
|
266
|
+
removeOne: (query: string | object) => Promise<object>;
|
|
267
|
+
/**
|
|
268
|
+
* - Remove multiple data objects in a collection in the current Datastore
|
|
269
|
+
*/
|
|
270
|
+
removeMany: (query: object) => Promise<object>;
|
|
271
|
+
/**
|
|
272
|
+
* Validate database colletion data agains JSON-Schema
|
|
273
|
+
* @param schema JSON-schema
|
|
274
|
+
* @returns Promise with result
|
|
275
|
+
*/
|
|
276
|
+
createSchema: (schema: object) => Promise<object>;
|
|
277
|
+
/**
|
|
278
|
+
* Validate database colletion data agains JSON-Schema
|
|
279
|
+
* @param schema JSON-schema
|
|
280
|
+
* @returns Promise with result
|
|
281
|
+
*/
|
|
282
|
+
setSchema: (schema: object) => Promise<object>;
|
|
283
|
+
/**
|
|
284
|
+
* Remove JSON-schema for database collection
|
|
285
|
+
* @param collection string
|
|
286
|
+
* @returns Promise with result
|
|
287
|
+
*/
|
|
288
|
+
removeSchema: () => Promise<object>;
|
|
289
|
+
/**
|
|
290
|
+
* Get JSON-schema for database collection
|
|
291
|
+
* @returns Promise with result
|
|
292
|
+
*/
|
|
293
|
+
getSchema: () => Promise<object>;
|
|
294
|
+
/**
|
|
295
|
+
* Count database collection items
|
|
296
|
+
* @returns Promise result
|
|
297
|
+
*/
|
|
298
|
+
count: () => Promise<object>;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Database API
|
|
302
|
+
*/
|
|
303
|
+
export type DatastoreAPI = {
|
|
304
|
+
/**
|
|
305
|
+
* - Get database collection by string name, returns an NoSQL API object
|
|
306
|
+
*/
|
|
307
|
+
collection: (collection: string) => NoSQLAPI;
|
|
308
|
+
/**
|
|
309
|
+
* - Get object by ID, returns a Promise with the object
|
|
310
|
+
*/
|
|
311
|
+
getOne: (collection: string, query: string | object) => Promise<any>;
|
|
312
|
+
/**
|
|
313
|
+
* - Get stream of objects by query
|
|
314
|
+
* * https://codehooks.io/docs/nosql-database-api#getmanycollection-query-options
|
|
315
|
+
*/
|
|
316
|
+
getMany: (collection: string, query?: object, options?: object) => DataStream;
|
|
317
|
+
/**
|
|
318
|
+
* - Get object by ID, returns a Promise with the object (alias for getOne)
|
|
319
|
+
*/
|
|
320
|
+
findOne: (collection: string, query: string | object) => Promise<any>;
|
|
321
|
+
/**
|
|
322
|
+
* - Alias for getMany
|
|
323
|
+
* https://codehooks.io/docs/nosql-database-api#getmanycollection-query-options
|
|
324
|
+
*/
|
|
325
|
+
find: (collection: string, query?: object, options?: object) => DataStream;
|
|
326
|
+
/**
|
|
327
|
+
* - Insert a new data object into a collection in the current Datastore
|
|
328
|
+
*/
|
|
329
|
+
insertOne: (collection: string, document: object) => Promise<object>;
|
|
330
|
+
/**
|
|
331
|
+
* - Update one data object by ID in a datastore collection.
|
|
332
|
+
* - Input document is patched with the matched database object
|
|
333
|
+
* @param collection string
|
|
334
|
+
* @param query string | object
|
|
335
|
+
* @param updateoperators object
|
|
336
|
+
* @param options object - {upsert: true}
|
|
337
|
+
* @returns Promise<any>
|
|
338
|
+
*/
|
|
339
|
+
updateOne: (
|
|
340
|
+
collection: string,
|
|
341
|
+
query: string | object,
|
|
342
|
+
updateoperators?: object,
|
|
343
|
+
options?: object
|
|
344
|
+
) => Promise<any>;
|
|
345
|
+
/**
|
|
346
|
+
* - Update multiple data objects in a datastore collection.
|
|
347
|
+
* - Input document is patched with the matched database objects
|
|
348
|
+
*/
|
|
349
|
+
updateMany: (
|
|
350
|
+
collection: string,
|
|
351
|
+
query: object,
|
|
352
|
+
document: object,
|
|
353
|
+
updateoperators?: object
|
|
354
|
+
) => Promise<any>;
|
|
355
|
+
/**
|
|
356
|
+
* - Replace one data object by ID in a datastore collection.
|
|
357
|
+
* - Input document overwrites the matched database object, the _id value is not overwritten.
|
|
358
|
+
*/
|
|
359
|
+
replaceOne: (
|
|
360
|
+
collection: string,
|
|
361
|
+
query: string | object,
|
|
362
|
+
options?: object
|
|
363
|
+
) => Promise<any>;
|
|
364
|
+
/**
|
|
365
|
+
* - Replace multiple data objects in a datastore collection.
|
|
366
|
+
* - Input document overwrites the matched database objects. The _id value is not overwritten
|
|
367
|
+
*/
|
|
368
|
+
replaceMany: (
|
|
369
|
+
collection: string,
|
|
370
|
+
query: object,
|
|
371
|
+
options?: object
|
|
372
|
+
) => Promise<any>;
|
|
373
|
+
/**
|
|
374
|
+
* - Remove one data object by ID in a collection in the current Datastore
|
|
375
|
+
*/
|
|
376
|
+
removeOne: (collection: string, query: string | object) => Promise<any>;
|
|
377
|
+
/**
|
|
378
|
+
* - Remove multiple data objects in a collection in the current Datastore
|
|
379
|
+
*/
|
|
380
|
+
removeMany: (collection: string, query: object) => Promise<any>;
|
|
381
|
+
/**
|
|
382
|
+
* - Set a key-value pair in the current Datastore
|
|
383
|
+
*/
|
|
384
|
+
set: (key: string, value: string | object, options?: object) => Promise<any>;
|
|
385
|
+
/**
|
|
386
|
+
* - Get a key-value pair in the current Datastore
|
|
387
|
+
*/
|
|
388
|
+
get: (key: string, options?: object) => Promise<any>;
|
|
389
|
+
/**
|
|
390
|
+
* - Get all key-value pair that matches keypattern in the current Datastore
|
|
391
|
+
*/
|
|
392
|
+
getAll: (keypattern: string, options?: object) => DataStream;
|
|
393
|
+
/**
|
|
394
|
+
* - Increment a key-value pair in the current Datastore
|
|
395
|
+
*/
|
|
396
|
+
incr: (key: string, value: number, options?: object) => Promise<any>;
|
|
397
|
+
/**
|
|
398
|
+
* - Decrement a key-value pair in the current Datastore
|
|
399
|
+
*/
|
|
400
|
+
decr: (key: string, value: number, options?: object) => Promise<any>;
|
|
401
|
+
/**
|
|
402
|
+
* - Delete a key-value pair in the current Datastore
|
|
403
|
+
*/
|
|
404
|
+
del: (key: string, value: object) => Promise<any>;
|
|
405
|
+
/**
|
|
406
|
+
* - Delete a range of key-value pairs in the current Datastore
|
|
407
|
+
*/
|
|
408
|
+
delAll: (keypattern: string, options?: object) => Promise<any>;
|
|
409
|
+
/**
|
|
410
|
+
* - Add a queued job in a datastore.
|
|
411
|
+
* - Jobs in the queue are processed by your worker function.
|
|
412
|
+
*/
|
|
413
|
+
enqueue: (topic: string, document: object, options?: object) => Promise<any>;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Queue each item from the result of a database query to a worker function
|
|
417
|
+
* @see {@link https://codehooks.io/docs/queueapi#enqueuefromquerycollection-query-topic-options Codehooks docs}
|
|
418
|
+
* @param collection Collection name
|
|
419
|
+
* @param query Database Query
|
|
420
|
+
* @param topic Worker function topic string
|
|
421
|
+
* @param options Query options
|
|
422
|
+
* @returns Promise
|
|
423
|
+
* @example
|
|
424
|
+
* async function someFunction() {
|
|
425
|
+
* const query = {"Market Category": "G"};
|
|
426
|
+
* const topic = 'stockWorker';
|
|
427
|
+
* const qres = await conn.enqueueFromQuery('stocks', query, topic);
|
|
428
|
+
* }
|
|
429
|
+
*
|
|
430
|
+
* app.worker('stockWorker', (req: httpRequest, res: httpResponse) => {
|
|
431
|
+
* const { body } = req;
|
|
432
|
+
* console.log('Working on', body.payload)
|
|
433
|
+
* // do stuff with body.payload
|
|
434
|
+
* res.end()
|
|
435
|
+
* })
|
|
436
|
+
*/
|
|
437
|
+
enqueueFromQuery: (
|
|
438
|
+
collection: string,
|
|
439
|
+
query: object,
|
|
440
|
+
topic: string,
|
|
441
|
+
options?: object
|
|
442
|
+
) => Promise<object>;
|
|
443
|
+
/**
|
|
444
|
+
* Validate database colletion data agains JSON-Schema
|
|
445
|
+
* @param collection string
|
|
446
|
+
* @param schema JSON-schema
|
|
447
|
+
* @returns Promise with result
|
|
448
|
+
*/
|
|
449
|
+
createSchema: (collection: string, schema: object) => Promise<object>;
|
|
450
|
+
/**
|
|
451
|
+
* Validate database colletion data agains JSON-Schema
|
|
452
|
+
* @param collection string
|
|
453
|
+
* @param schema JSON-schema
|
|
454
|
+
* @returns Promise with result
|
|
455
|
+
*/
|
|
456
|
+
setSchema: (collection: string, schema: object) => Promise<object>;
|
|
457
|
+
/**
|
|
458
|
+
* Remove JSON-schema for database collection
|
|
459
|
+
* @param collection string
|
|
460
|
+
* @returns Promise with result
|
|
461
|
+
*/
|
|
462
|
+
removeSchema: (collection: string) => Promise<object>;
|
|
463
|
+
/**
|
|
464
|
+
* Get JSON-schema for database collection
|
|
465
|
+
* @param collection string
|
|
466
|
+
* @returns Promise with result
|
|
467
|
+
*/
|
|
468
|
+
getSchema: (collection: string) => Promise<object>;
|
|
469
|
+
/**
|
|
470
|
+
* Count database collection items
|
|
471
|
+
* @returns Promise result
|
|
472
|
+
*/
|
|
473
|
+
count: (collection: string) => Promise<object>;
|
|
474
|
+
};
|
|
475
|
+
/**
|
|
476
|
+
* Persistent NoSql and Kev-Value datastore
|
|
477
|
+
*/
|
|
478
|
+
export type DataStream = {
|
|
479
|
+
/**
|
|
480
|
+
* - Emits data, stream.on('data', (data) => //console.debug(data))
|
|
481
|
+
*/
|
|
482
|
+
on: (event: string, callback: (data: any) => any) => void;
|
|
483
|
+
/**
|
|
484
|
+
* - Pipe datastream to JSON output
|
|
485
|
+
*/
|
|
486
|
+
json: (response: httpResponse) => void;
|
|
487
|
+
/**
|
|
488
|
+
* - Return an array of objects
|
|
489
|
+
*/
|
|
490
|
+
toArray: () => Promise<object[]>;
|
|
491
|
+
/**
|
|
492
|
+
* Return an iterator
|
|
493
|
+
* @param data
|
|
494
|
+
* @returns Promise with iterator
|
|
495
|
+
*/
|
|
496
|
+
forEach: (data: object) => Promise<object>;
|
|
497
|
+
};
|
|
498
|
+
export type httpRequest = {
|
|
499
|
+
/**
|
|
500
|
+
* - HTTP header key value pairs, e.g. req.headers['content-type']
|
|
501
|
+
*/
|
|
502
|
+
headers: any;
|
|
503
|
+
/**
|
|
504
|
+
* - Get the URL query parameters as key-value pairs
|
|
505
|
+
*/
|
|
506
|
+
query: any;
|
|
507
|
+
/**
|
|
508
|
+
* - Get the URL route variables as key-value pairs
|
|
509
|
+
*/
|
|
510
|
+
params: any;
|
|
511
|
+
/**
|
|
512
|
+
* - Get the request body
|
|
513
|
+
* - JSON payload
|
|
514
|
+
*/
|
|
515
|
+
body: any;
|
|
516
|
+
/**
|
|
517
|
+
* - Get the URL full path, e.g. /dev/myroute
|
|
518
|
+
*/
|
|
519
|
+
path: string;
|
|
520
|
+
/**
|
|
521
|
+
* - Get the URL api path, e.g. /myroute
|
|
522
|
+
*/
|
|
523
|
+
apiPath: string;
|
|
524
|
+
/**
|
|
525
|
+
* - Get the URL full path and query parameter string
|
|
526
|
+
*/
|
|
527
|
+
originalUrl: string;
|
|
528
|
+
/**
|
|
529
|
+
* - Get the HTTP request verb
|
|
530
|
+
*/
|
|
531
|
+
method: string;
|
|
532
|
+
/**
|
|
533
|
+
* - Get the project URL domain name
|
|
534
|
+
*/
|
|
535
|
+
hostname: string;
|
|
536
|
+
/**
|
|
537
|
+
* Pipe data to stream
|
|
538
|
+
* @param data
|
|
539
|
+
* @returns
|
|
540
|
+
*/
|
|
541
|
+
pipe: (data: any) => void;
|
|
542
|
+
};
|
|
543
|
+
export type httpResponse = {
|
|
544
|
+
/**
|
|
545
|
+
* - End request (optional: send text|JSON data to client)
|
|
546
|
+
*/
|
|
547
|
+
end: (data: string | object | void) => void;
|
|
548
|
+
/**
|
|
549
|
+
* - Send text|JSON data to client and end request
|
|
550
|
+
* @example
|
|
551
|
+
* res.end()
|
|
552
|
+
* res.status(404).end()
|
|
553
|
+
*/
|
|
554
|
+
send: (data: string | object) => void;
|
|
555
|
+
/**
|
|
556
|
+
* - End request and send JSON data to client
|
|
557
|
+
* @example
|
|
558
|
+
* res.json({ user: 'tobi' })
|
|
559
|
+
* res.status(500).json({ error: 'message' })
|
|
560
|
+
*/
|
|
561
|
+
json: (document: object) => any;
|
|
562
|
+
/**
|
|
563
|
+
* - Write stream data to the client response.
|
|
564
|
+
* - Content-type must be set before any write operations
|
|
565
|
+
* - set optional type to 'buffer' for binary write operations
|
|
566
|
+
* @example
|
|
567
|
+
* res.set('content-type', 'text/plain')
|
|
568
|
+
* res.write('line one')
|
|
569
|
+
* res.write('\n')
|
|
570
|
+
* res.write('line two')
|
|
571
|
+
* res.end()
|
|
572
|
+
*/
|
|
573
|
+
write: (data: any, type?: string) => any;
|
|
574
|
+
/**
|
|
575
|
+
* - Set a response header value,
|
|
576
|
+
* @example
|
|
577
|
+
* res.set('Content-Type', 'text/html; charset=UTF-8');
|
|
578
|
+
*/
|
|
579
|
+
set: (header: string, value: string) => any;
|
|
580
|
+
/**
|
|
581
|
+
* - Set multiple response header values,
|
|
582
|
+
* @example
|
|
583
|
+
* res.headers({'Content-Type': 'text/html; charset=UTF-8','X-myheader': '123456890'});
|
|
584
|
+
*/
|
|
585
|
+
headers: (headers: object) => any;
|
|
586
|
+
/**
|
|
587
|
+
* Set a response header value
|
|
588
|
+
* @param header string
|
|
589
|
+
* @param value string
|
|
590
|
+
* @returns
|
|
591
|
+
*/
|
|
592
|
+
setHeader: (header: string, value: string | string[]) => any;
|
|
593
|
+
/**
|
|
594
|
+
* Remove any default headers from a response
|
|
595
|
+
* @param header string
|
|
596
|
+
* @returns
|
|
597
|
+
*/
|
|
598
|
+
removeHeader: (header: string) => any;
|
|
599
|
+
/**
|
|
600
|
+
* - Return a HTTP response status code for a client request,
|
|
601
|
+
* @example
|
|
602
|
+
* res.status(401).end();
|
|
603
|
+
*/
|
|
604
|
+
status: (code: number) => any;
|
|
605
|
+
/**
|
|
606
|
+
* - Render template with object data
|
|
607
|
+
* @example
|
|
608
|
+
* res.render('services', {title: "Services page"})
|
|
609
|
+
*/
|
|
610
|
+
render: (template: string, context: object) => void;
|
|
611
|
+
/**
|
|
612
|
+
* - Sets the response header to redirect client request
|
|
613
|
+
* @param statusCode - optional, set to 302 by default
|
|
614
|
+
* @param url
|
|
615
|
+
* @returns
|
|
616
|
+
* @example
|
|
617
|
+
* res.redirect('/assets/login.html'); // default status 302, Temporary
|
|
618
|
+
* res.redirect(301, '/home/correct.html'); // status code 301, Permanently
|
|
619
|
+
*/
|
|
620
|
+
redirect: (statusCode: number | string, url?: string) => void;
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
export type nextFunction = (error?: string) => void;
|
|
624
|
+
|
|
625
|
+
export type Filesystem = {
|
|
626
|
+
/**
|
|
627
|
+
* - Get binary file input stream. Takes a path (string) to file (e.g. /static/logo.png) and an options object (Object) for future use. Returns a Promise resolving to a binary data stream emitter.
|
|
628
|
+
*/
|
|
629
|
+
getReadStream: (filePath: string, options?: any) => Promise<any>;
|
|
630
|
+
/**
|
|
631
|
+
* - Get file as text. Takes an absolute path (string) to file (e.g. /static/home.html) and an options object (Object) for future use. Returns a Promise resolving to the file content (string).
|
|
632
|
+
*/
|
|
633
|
+
readFile: (filePath: string, options?: any) => Promise<string>;
|
|
634
|
+
/**
|
|
635
|
+
* - Save file binary buffer. Takes an absolute path (string) to file (e.g. /static/home.html), a buffer (Buffer) to save, and file meta data (Object). Returns a Promise resolving to the save result.
|
|
636
|
+
*/
|
|
637
|
+
saveFile: (filePath: string, buf: any, options?: any) => Promise<any>;
|
|
638
|
+
/**
|
|
639
|
+
* - Delete a file. Takes an absolute path (string) to file and an options object (Object) for future use. Returns a Promise resolving to the result.
|
|
640
|
+
*/
|
|
641
|
+
deleteFile: (filePath: string, options?: any) => Promise<any>;
|
|
642
|
+
/**
|
|
643
|
+
* - List content of a file directory. Takes an absolute path (string) to file and an options object (Object) for future use. Returns a Promise resolving to the result.
|
|
644
|
+
*/
|
|
645
|
+
list: (filePath: string, options?: any) => Promise<any>;
|
|
646
|
+
/**
|
|
647
|
+
* - Read file into a Buffer. Takes an absolute path (*) to file. Returns a Promise resolving to a Buffer.
|
|
648
|
+
*/
|
|
649
|
+
readFileAsBuffer: (filePath: any) => Promise<any>;
|
|
650
|
+
};
|
|
33
651
|
import { agg } from './aggregation/index.mjs';
|
|
34
|
-
import
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
652
|
+
import * as crud from './crudlify/index.mjs';
|
|
653
|
+
|
|
654
|
+
export class Codehooks {
|
|
655
|
+
static getInstance(): Codehooks;
|
|
656
|
+
/**
|
|
657
|
+
* Express style api
|
|
658
|
+
*/
|
|
659
|
+
settings: {};
|
|
660
|
+
routes: {};
|
|
661
|
+
queues: {};
|
|
662
|
+
jobs: {};
|
|
663
|
+
auths: {};
|
|
664
|
+
appmiddleware: any[];
|
|
665
|
+
datastore: any;
|
|
666
|
+
listeners: any[];
|
|
667
|
+
workers: {};
|
|
668
|
+
/**
|
|
669
|
+
* POST requests - e.g. app.post('/foo', callbackFunction)
|
|
670
|
+
* @example
|
|
671
|
+
* app.post('/myroute', (req, res) => {
|
|
672
|
+
* //console.debug('Body', req.body)
|
|
673
|
+
* res.json({"message": "thanks!"})
|
|
674
|
+
* })
|
|
675
|
+
* @param {string} path - API route, e.g. '/foo'
|
|
676
|
+
* @param {...function(httpRequest, httpResponse, function(string):void)} hook - callback function(s) with parameters (req, res, [next])
|
|
677
|
+
*/
|
|
678
|
+
post: (
|
|
679
|
+
path: string,
|
|
680
|
+
...hook: ((
|
|
681
|
+
request: httpRequest,
|
|
682
|
+
response: httpResponse,
|
|
683
|
+
next: nextFunction
|
|
684
|
+
) => any)[]
|
|
685
|
+
) => void;
|
|
686
|
+
/**
|
|
687
|
+
* GET requests - e.g. app.get('/foo/:ID', callbackFunction)
|
|
688
|
+
* @example
|
|
689
|
+
* app.get('/myroute', (req, res) => {
|
|
690
|
+
* //console.debug('Params', req.params)
|
|
691
|
+
* res.json({"message": "thanks!"})
|
|
692
|
+
* })
|
|
693
|
+
* @param {string} path - API route, e.g. '/foo/:ID'
|
|
694
|
+
* @param {...function(httpRequest, httpResponse, function(string):void)} hook - callback function(s) with parameters (req, res, [next])
|
|
695
|
+
*/
|
|
696
|
+
get: (
|
|
697
|
+
path: string,
|
|
698
|
+
...hook: ((
|
|
699
|
+
request: httpRequest,
|
|
700
|
+
response: httpResponse,
|
|
701
|
+
next: nextFunction
|
|
702
|
+
) => any)[]
|
|
703
|
+
) => void;
|
|
704
|
+
/**
|
|
705
|
+
* PUT requests
|
|
706
|
+
* @example
|
|
707
|
+
* app.put('/myroute', (req, res) => {
|
|
708
|
+
* //console.debug('Body', req.body)
|
|
709
|
+
* res.json({"message": "thanks!"})
|
|
710
|
+
* })
|
|
711
|
+
* @param {string} path - API route, e.g. '/foo/:ID'
|
|
712
|
+
* @param {...function(httpRequest, httpResponse, function(string):void):void} hook - callback function(s) with parameters (req, res, [next])
|
|
713
|
+
*/
|
|
714
|
+
put: (
|
|
715
|
+
path: string,
|
|
716
|
+
...hook: ((
|
|
717
|
+
request: httpRequest,
|
|
718
|
+
response: httpResponse,
|
|
719
|
+
next: nextFunction
|
|
720
|
+
) => void)[]
|
|
721
|
+
) => void;
|
|
722
|
+
/**
|
|
723
|
+
* PATCH requests
|
|
724
|
+
* @example
|
|
725
|
+
* app.patch('/myroute', (req, res) => {
|
|
726
|
+
* //console.debug('Body', req.body)
|
|
727
|
+
* res.json({"message": "thanks!"})
|
|
728
|
+
* })
|
|
729
|
+
* @param {string} path - API route, e.g. '/foo/:ID'
|
|
730
|
+
* @param {...function(httpRequest, httpResponse, function(string):void)} hook - callback function(s) with parameters (req, res, [next])
|
|
731
|
+
*/
|
|
732
|
+
patch: (
|
|
733
|
+
path: string,
|
|
734
|
+
...hook: ((
|
|
735
|
+
request: httpRequest,
|
|
736
|
+
response: httpResponse,
|
|
737
|
+
next: nextFunction
|
|
738
|
+
) => any)[]
|
|
739
|
+
) => void;
|
|
740
|
+
/**
|
|
741
|
+
* DELETE requests - app.delete('/foo', callbackFunction)
|
|
742
|
+
* @example
|
|
743
|
+
* app.delete('/myroute', (req, res) => {
|
|
744
|
+
* res.json({"message": "thanks!"})
|
|
745
|
+
* })
|
|
746
|
+
* @param {string} path - API route, e.g. '/foo/:ID'
|
|
747
|
+
* @param {...function(httpRequest, httpResponse, function(string):void)} hook - callback function(s) with parameters (req, res, [next])
|
|
748
|
+
*/
|
|
749
|
+
delete: (
|
|
750
|
+
path: string,
|
|
751
|
+
...hook: ((
|
|
752
|
+
request: httpRequest,
|
|
753
|
+
response: httpResponse,
|
|
754
|
+
next: nextFunction
|
|
755
|
+
) => any)[]
|
|
756
|
+
) => void;
|
|
757
|
+
/**
|
|
758
|
+
* All HTTP methods - app.all('/pets/cat', (req, res) => res.end('Mjau'))
|
|
759
|
+
* @example
|
|
760
|
+
* app.all('/myroute', (req, res) => {
|
|
761
|
+
* //console.debug('Body', req.body || 'no body')
|
|
762
|
+
* res.json({"message": "thanks!"})
|
|
763
|
+
* })
|
|
764
|
+
* @param {string} path - API route, e.g. '- API endpoint route, e.g. '/pets'
|
|
765
|
+
* @param {...function(httpRequest, httpResponse, function(string)):void} hook - callback function(s) with parameters (req, res, [next])
|
|
766
|
+
*/
|
|
767
|
+
all: (
|
|
768
|
+
path: string,
|
|
769
|
+
...hook: ((
|
|
770
|
+
request: httpRequest,
|
|
771
|
+
response: httpResponse,
|
|
772
|
+
next: (error?: string) => any
|
|
773
|
+
) => void)[]
|
|
774
|
+
) => void;
|
|
775
|
+
/**
|
|
776
|
+
* Allow custom authentication
|
|
777
|
+
* @example
|
|
778
|
+
* app.auth('/*', (req, res, next) => {
|
|
779
|
+
* if (1 === 1) {
|
|
780
|
+
* next()
|
|
781
|
+
* } else {
|
|
782
|
+
* res.status(403).end('No soup!')
|
|
783
|
+
* }
|
|
784
|
+
* })
|
|
785
|
+
* @param {string|RegExp} path - API route, e.g. '/foo/*'
|
|
786
|
+
* @param {...function(httpRequest, httpResponse, function(string):void):void} hook - callback function(s) with parameters (req, res, [next])
|
|
787
|
+
*/
|
|
788
|
+
auth: (
|
|
789
|
+
path: string | RegExp,
|
|
790
|
+
...hook: ((
|
|
791
|
+
request: httpRequest,
|
|
792
|
+
response: httpResponse,
|
|
793
|
+
next: nextFunction
|
|
794
|
+
) => void)[]
|
|
795
|
+
) => void;
|
|
796
|
+
/**
|
|
797
|
+
* Global middleware
|
|
798
|
+
* @example
|
|
799
|
+
* // global middleware
|
|
800
|
+
* app.use((req, res, next) => {
|
|
801
|
+
* //console.debug("Global middleware was here!");
|
|
802
|
+
* next(); // proceed
|
|
803
|
+
* })
|
|
804
|
+
* @param {...function(httpRequest, httpResponse, function(string):void):void} hook - callback function(s) with parameters (req, res, next)
|
|
805
|
+
*/
|
|
806
|
+
use(
|
|
807
|
+
...hook: ((
|
|
808
|
+
request: httpRequest,
|
|
809
|
+
response: httpResponse,
|
|
810
|
+
next: nextFunction
|
|
811
|
+
) => void)[]
|
|
812
|
+
): void;
|
|
813
|
+
/**
|
|
814
|
+
* Global middleware
|
|
815
|
+
* @example
|
|
816
|
+
* // middleware on a route defined by a regular expression
|
|
817
|
+
* app.use(/^\/(foo|bar)/, (req, res, next) => {
|
|
818
|
+
* //console.debug("RegExp route middleware was here!");
|
|
819
|
+
* next(); // proceed
|
|
820
|
+
* })
|
|
821
|
+
* @param {RegExp} regex
|
|
822
|
+
* @param {...function(httpRequest, httpResponse, function(string):void):void} hook - callback function(s) with parameters (req, res, next)
|
|
823
|
+
*/
|
|
824
|
+
use(
|
|
825
|
+
regex: RegExp,
|
|
826
|
+
...hook: ((
|
|
827
|
+
request: httpRequest,
|
|
828
|
+
response: httpResponse,
|
|
829
|
+
next: nextFunction
|
|
830
|
+
) => void)[]
|
|
831
|
+
): void;
|
|
832
|
+
/**
|
|
833
|
+
* Global middleware
|
|
834
|
+
* @example
|
|
835
|
+
* // middleware on a specific route
|
|
836
|
+
* app.use('/myroute', (req, res, next) => {
|
|
837
|
+
* //console.debug("Route middleware was here!");
|
|
838
|
+
* next(); // proceed
|
|
839
|
+
* })
|
|
840
|
+
* @param {string} path
|
|
841
|
+
* @param {...function(httpRequest, httpResponse, function(string):void):void} hook - callback function(s) with parameters (req, res, next)
|
|
842
|
+
*/
|
|
843
|
+
use(
|
|
844
|
+
path: string,
|
|
845
|
+
...hook: ((
|
|
846
|
+
request: httpRequest,
|
|
847
|
+
response: httpResponse,
|
|
848
|
+
next: nextFunction
|
|
849
|
+
) => void)[]
|
|
850
|
+
): void;
|
|
851
|
+
/**
|
|
852
|
+
* Global route middleware
|
|
853
|
+
* @example
|
|
854
|
+
* // Global middleware on a specific route
|
|
855
|
+
* app.use('/myroute', (req, res, next) => {
|
|
856
|
+
* //console.debug("Route middleware was here!");
|
|
857
|
+
* next(); // proceed
|
|
858
|
+
* })
|
|
859
|
+
* @param {string|RegExp} path - Optional API route or RegExp, e.g. '/myroute/*'
|
|
860
|
+
* @param {...function(httpRequest, httpResponse, function(string):void):void} hook - callback function(s) with parameters (req, res, next)
|
|
861
|
+
*/
|
|
862
|
+
useRoute: (
|
|
863
|
+
path: string | RegExp,
|
|
864
|
+
...hook: ((
|
|
865
|
+
request: httpRequest,
|
|
866
|
+
response: httpResponse,
|
|
867
|
+
next: nextFunction
|
|
868
|
+
) => void)[]
|
|
869
|
+
) => void;
|
|
870
|
+
/**
|
|
871
|
+
* Process queue job items for topic
|
|
872
|
+
* @param {string} topic
|
|
873
|
+
* @param {...function(httpRequest, httpResponse, function(string):void)} hook - callback function(s) with parameters (req, res, [next])
|
|
874
|
+
*/
|
|
875
|
+
queue: (
|
|
876
|
+
topic: string,
|
|
877
|
+
...hook: ((
|
|
878
|
+
request: httpRequest,
|
|
879
|
+
response: httpResponse,
|
|
880
|
+
next: nextFunction
|
|
881
|
+
) => any)[]
|
|
882
|
+
) => void;
|
|
883
|
+
/**
|
|
884
|
+
* Add application worker function
|
|
885
|
+
* @param {object} name a unique worker name or JSON configuration
|
|
886
|
+
* @param {...function(httpRequest, httpResponse, function(string):void)} hook - callback function(s) with parameters (req, res, [next])
|
|
887
|
+
* @example
|
|
888
|
+
* app.worker('myworker', (data, job) => {
|
|
889
|
+
* const {body:{payload}} = data
|
|
890
|
+
* //console.debug('worker payload data', payload)
|
|
891
|
+
* // do stuff with payload data
|
|
892
|
+
* job.end()
|
|
893
|
+
*})
|
|
894
|
+
* @example
|
|
895
|
+
* app.worker({name: 'myworker', workers: 5}, (data, job) => {
|
|
896
|
+
* const {body:{payload}} = data
|
|
897
|
+
* //console.debug('worker payload data', payload)
|
|
898
|
+
* // do stuff with payload data
|
|
899
|
+
* job.end()
|
|
900
|
+
*})
|
|
901
|
+
*/
|
|
902
|
+
worker: (
|
|
903
|
+
name: string | object,
|
|
904
|
+
...hook: ((
|
|
905
|
+
request: httpRequest,
|
|
906
|
+
response: httpResponse,
|
|
907
|
+
next: nextFunction
|
|
908
|
+
) => any)[]
|
|
909
|
+
) => void;
|
|
910
|
+
/**
|
|
911
|
+
* Create cron background jobs
|
|
912
|
+
* @example
|
|
913
|
+
* // call function each minute
|
|
914
|
+
* app.job('* * * * *', (req, res) => {
|
|
915
|
+
* //console.debug('tick each minute')
|
|
916
|
+
* res.end()
|
|
917
|
+
* })
|
|
918
|
+
* @param {string} cronExpression - cron expression
|
|
919
|
+
* @param {...function(httpRequest, httpResponse, function(string):void)} hook - callback function(s) with parameters (req, res, [next])
|
|
920
|
+
*/
|
|
921
|
+
job: (
|
|
922
|
+
cronExpression: string,
|
|
923
|
+
...hook: ((
|
|
924
|
+
request: httpRequest,
|
|
925
|
+
response: httpResponse,
|
|
926
|
+
next: nextFunction
|
|
927
|
+
) => any)[]
|
|
928
|
+
) => void;
|
|
929
|
+
/**
|
|
930
|
+
* Set up a server-sent events channel endpoint (SSE).
|
|
931
|
+
* This method registers a set of middleware (hooks) for the channel and defines an SSE endpoint.
|
|
932
|
+
*
|
|
933
|
+
* @param {string} path - The channel on which to establish a real-time connection. This acts as the base path for the SSE endpoint.
|
|
934
|
+
* @param {...function(httpRequest, httpResponse, function(string):void)} hook - Optional middleware functions to be applied to the channel (access check for example). These functions are executed in the order they are provided.
|
|
935
|
+
*/
|
|
936
|
+
realtime(
|
|
937
|
+
path: string,
|
|
938
|
+
...hook: ((
|
|
939
|
+
request: httpRequest,
|
|
940
|
+
response: httpResponse,
|
|
941
|
+
next: nextFunction
|
|
942
|
+
) => any)[]
|
|
943
|
+
): void;
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Serve static file content from a source code diretory
|
|
947
|
+
* @param {Object} options -
|
|
948
|
+
* - options.route - API route to serve assets
|
|
949
|
+
* - options.directory - path to directory with assets/files
|
|
950
|
+
* - options.default - default file name if root is /
|
|
951
|
+
@param {...function(httpRequest, httpResponse, function(string):void)} hook - Optional middleware functions to be applied before resource is served
|
|
952
|
+
* @example
|
|
953
|
+
* app.static({route:'/static', directory: '/assets'}, (req, res, next) => {
|
|
954
|
+
* console.log("Serving a static resource", req.path);
|
|
955
|
+
* next();
|
|
956
|
+
* })
|
|
957
|
+
* @returns void
|
|
958
|
+
*/
|
|
959
|
+
static: (options: any,
|
|
960
|
+
...hook: ((
|
|
961
|
+
request: httpRequest,
|
|
962
|
+
response: httpResponse,
|
|
963
|
+
next: nextFunction
|
|
964
|
+
) => any)[]) => void;
|
|
965
|
+
/**
|
|
966
|
+
* Serve file content from a blob storage diretory
|
|
967
|
+
* @param {Object} options - {route: "/documents", directory: "/docs"}
|
|
968
|
+
* @returns void
|
|
969
|
+
*/
|
|
970
|
+
storage: (options: any,
|
|
971
|
+
...hook: ((
|
|
972
|
+
request: httpRequest,
|
|
973
|
+
response: httpResponse,
|
|
974
|
+
next: nextFunction
|
|
975
|
+
) => any)[]) => void;
|
|
976
|
+
/**
|
|
977
|
+
* Configuration settings
|
|
978
|
+
* @param {string} key
|
|
979
|
+
* @param {*} val
|
|
980
|
+
* @example
|
|
981
|
+
* app.set('views', '/views')
|
|
982
|
+
* app.set('view engine', {"hbs": handlebars})
|
|
983
|
+
*/
|
|
984
|
+
set: (key: string, val: any) => void;
|
|
985
|
+
/**
|
|
986
|
+
*
|
|
987
|
+
* @param {string} view
|
|
988
|
+
* @param {object} data
|
|
989
|
+
* @param {function(string):void)} cb
|
|
990
|
+
*/
|
|
991
|
+
render: (view: string, data: object, cb: any) => Promise<void>;
|
|
992
|
+
/**
|
|
993
|
+
* Create CRUD REST API for database
|
|
994
|
+
* @see {@link https://codehooks.io/docs/database-rest-api}
|
|
995
|
+
* @see {@link https://codehooks.io/docs/database-rest-api#data-validation-with-yup Data validation with Yup, Zod, JSON.schema}
|
|
996
|
+
* @param {object} schema
|
|
997
|
+
* @param {object} options - Optional {prefix: "/crud"} serve all crud routes under sub route /crud/*
|
|
998
|
+
* @returns Promise - Eventhooks
|
|
999
|
+
*/
|
|
1000
|
+
crudlify: (
|
|
1001
|
+
schema?: object,
|
|
1002
|
+
options?: object
|
|
1003
|
+
) => Promise<import('./crudlify/lib/eventhooks.mjs').EventHooks>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Returns the Codehooks serverless definitions used by a serverless runtime engine
|
|
1006
|
+
* @example
|
|
1007
|
+
* export default app.init();
|
|
1008
|
+
* @returns {Object} App instance
|
|
1009
|
+
*/
|
|
1010
|
+
init: (cb?: any) => any;
|
|
1011
|
+
/**
|
|
1012
|
+
* Alias for app.init()
|
|
1013
|
+
* @example
|
|
1014
|
+
* export default app.start();
|
|
1015
|
+
* @returns {Object} App instance
|
|
1016
|
+
*/
|
|
1017
|
+
start: (cb?: any) => any;
|
|
1018
|
+
/**
|
|
1019
|
+
* Use Node Express app to run standalone
|
|
1020
|
+
* All Codehooks routes will be applied as Express Routes
|
|
1021
|
+
* @param {Object} express app instance
|
|
1022
|
+
* @param {Object} options for Datastore and routing space
|
|
1023
|
+
*/
|
|
1024
|
+
useExpress: (express: any, options: any) => Promise<void>;
|
|
1025
|
+
/**
|
|
1026
|
+
* Set Datastore interface
|
|
1027
|
+
* @param {*} ds
|
|
1028
|
+
*/
|
|
1029
|
+
setDatastore: (ds: any) => void;
|
|
1030
|
+
getDatastore: () => {
|
|
1031
|
+
open: () => Promise<any>;
|
|
1032
|
+
};
|
|
1033
|
+
addListener: (observer: any) => void;
|
|
1034
|
+
/**
|
|
1035
|
+
* Create a new workflow
|
|
1036
|
+
* @param name - Unique identifier for the workflow
|
|
1037
|
+
* @param description - Human-readable description of the workflow
|
|
1038
|
+
* @param steps - Object containing step definitions
|
|
1039
|
+
* @param options - Optional configuration options
|
|
1040
|
+
* @returns Workflow instance for managing the workflow
|
|
1041
|
+
*/
|
|
1042
|
+
createWorkflow: (name: string, description: string, steps: WorkflowDefinition, options?: WorkflowConfig) => Workflow;
|
|
1043
|
+
/**
|
|
1044
|
+
* Register a workflow with the application
|
|
1045
|
+
* @param name - Unique identifier for the workflow
|
|
1046
|
+
* @param description - Human-readable description
|
|
1047
|
+
* @param steps - Step definitions
|
|
1048
|
+
* @returns Promise with the registered workflow name
|
|
1049
|
+
*/
|
|
1050
|
+
registerWorkflow: (name: string, description: string, steps: WorkflowDefinition) => Promise<string>;
|
|
134
1051
|
}
|
|
135
|
-
import { Steps as Workflow } from './workflow/index.mjs';
|
|
136
|
-
import { StepsConfig as WorkflowConfig } from './workflow/index.mjs';
|
|
137
1052
|
declare const _coho: Codehooks;
|
|
138
|
-
|
|
1053
|
+
|
|
1054
|
+
/**
|
|
1055
|
+
* Events emitted by the workflow engine
|
|
1056
|
+
*/
|
|
1057
|
+
export type WorkflowEvents = {
|
|
1058
|
+
/**
|
|
1059
|
+
* Emitted when a new workflow is registered
|
|
1060
|
+
* @event
|
|
1061
|
+
*/
|
|
1062
|
+
'workflowCreated': { name: string; description: string };
|
|
1063
|
+
|
|
1064
|
+
/**
|
|
1065
|
+
* Emitted when a new workflow instance is started
|
|
1066
|
+
* @event
|
|
1067
|
+
*/
|
|
1068
|
+
'workflowStarted': { name: string; initialState: any };
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* Emitted when a step begins execution
|
|
1072
|
+
* @event
|
|
1073
|
+
*/
|
|
1074
|
+
'stepStarted': { workflowName: string; step: string; state: any; instanceId: string };
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Emitted when a step's state is updated
|
|
1078
|
+
* @event
|
|
1079
|
+
*/
|
|
1080
|
+
'stateUpdated': { workflowName: string; state: any; instanceId: string };
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* Emitted when a step is waiting for input
|
|
1084
|
+
* @event
|
|
1085
|
+
*/
|
|
1086
|
+
'stepWaiting': { workflowName: string; step: string; instanceId: string };
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* Emitted when a workflow instance is continued after waiting
|
|
1090
|
+
* @event
|
|
1091
|
+
*/
|
|
1092
|
+
'workflowContinued': { workflowName: string; step: string; instanceId: string };
|
|
1093
|
+
|
|
1094
|
+
/**
|
|
1095
|
+
* Emitted when a workflow instance is completed
|
|
1096
|
+
* @event
|
|
1097
|
+
*/
|
|
1098
|
+
'completed': { message: string; state: any };
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* Emitted when a workflow instance is cancelled
|
|
1102
|
+
* @event
|
|
1103
|
+
*/
|
|
1104
|
+
'cancelled': { id: string };
|
|
1105
|
+
|
|
1106
|
+
/**
|
|
1107
|
+
* Emitted when an error occurs
|
|
1108
|
+
* @event
|
|
1109
|
+
*/
|
|
1110
|
+
'error': { error: Error };
|
|
1111
|
+
};
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* Definition of a workflow step function
|
|
1115
|
+
*/
|
|
1116
|
+
export type WorkflowDefinition = Record<string, (state: any, callback: (nextStep: string | string[] | null, newState: any, options?: any) => void) => Promise<void>>;
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* Configuration options for a workflow step
|
|
1120
|
+
*/
|
|
1121
|
+
export type StepOptions = {
|
|
1122
|
+
/** Timeout in milliseconds for this specific step */
|
|
1123
|
+
timeout?: number;
|
|
1124
|
+
/** Maximum number of retries for this step */
|
|
1125
|
+
maxRetries?: number;
|
|
1126
|
+
};
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* Configuration options for the Workflow engine
|
|
1130
|
+
*/
|
|
1131
|
+
export type WorkflowConfig = {
|
|
1132
|
+
/** Collection name for storing workflow data */
|
|
1133
|
+
collectionName?: string;
|
|
1134
|
+
/** Queue prefix for workflow jobs */
|
|
1135
|
+
queuePrefix?: string;
|
|
1136
|
+
/** Global timeout in milliseconds for workflow steps */
|
|
1137
|
+
timeout?: number;
|
|
1138
|
+
/** Maximum number of times a step can be executed */
|
|
1139
|
+
maxStepCount?: number;
|
|
1140
|
+
/** Step-specific configuration options */
|
|
1141
|
+
steps?: Record<string, StepOptions>;
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* Engine for managing workflow-based applications
|
|
1146
|
+
* @extends Workflow
|
|
1147
|
+
*/
|
|
1148
|
+
export type WorkflowEngine = Workflow & {
|
|
1149
|
+
/**
|
|
1150
|
+
* Register a new workflow
|
|
1151
|
+
* @param name - Unique identifier for the workflow
|
|
1152
|
+
* @param description - Human-readable description
|
|
1153
|
+
* @param steps - Step definitions
|
|
1154
|
+
*/
|
|
1155
|
+
register: (name: string, description: string, steps: WorkflowDefinition) => Promise<string>;
|
|
1156
|
+
};
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* Workflow engine for managing step-based applications
|
|
1160
|
+
* @extends EventEmitter
|
|
1161
|
+
*/
|
|
1162
|
+
export type Workflow = {
|
|
1163
|
+
/**
|
|
1164
|
+
* Configure the workflow engine
|
|
1165
|
+
* @param options - Configuration options
|
|
1166
|
+
* @param options.collectionName - Collection name for storing workflow data
|
|
1167
|
+
* @param options.queuePrefix - Queue prefix for workflow jobs
|
|
1168
|
+
* @param options.timeout - Timeout in milliseconds for workflow steps
|
|
1169
|
+
* @param options.maxStepCount - Maximum number of times a step can be executed
|
|
1170
|
+
* @param options.steps - Workflow step configuration
|
|
1171
|
+
* @example
|
|
1172
|
+
* workflow.configure({
|
|
1173
|
+
* collectionName: 'workflows',
|
|
1174
|
+
* queuePrefix: 'workflow',
|
|
1175
|
+
* timeout: 30000,
|
|
1176
|
+
* maxStepCount: 3,
|
|
1177
|
+
* steps: {
|
|
1178
|
+
* stepName: {
|
|
1179
|
+
* timeout: 3000,
|
|
1180
|
+
* maxRetries: 3
|
|
1181
|
+
* }
|
|
1182
|
+
* }
|
|
1183
|
+
* });
|
|
1184
|
+
*/
|
|
1185
|
+
configure: (options: WorkflowConfig) => void;
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* Register a new workflow
|
|
1189
|
+
* @param app - Codehooks application instance
|
|
1190
|
+
* @param name - Unique identifier for the workflow
|
|
1191
|
+
* @param description - Human-readable description
|
|
1192
|
+
* @param definition - Object containing step definitions
|
|
1193
|
+
* @returns Promise with the registered workflow name
|
|
1194
|
+
*/
|
|
1195
|
+
register: (app: Codehooks, name: string, description: string, definition: Record<string, Function>) => Promise<string>;
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* Start a new workflow instance
|
|
1199
|
+
* @param name - Name of the workflow to start
|
|
1200
|
+
* @param initialState - Initial state for the workflow instance
|
|
1201
|
+
* @returns Promise with the workflow instance ID
|
|
1202
|
+
*/
|
|
1203
|
+
start: (name: string, initialState: any) => Promise<{ id: string }>;
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* Update the state of a workflow instance
|
|
1207
|
+
* @param workflowName - Name of the workflow
|
|
1208
|
+
* @param instanceId - ID of the workflow instance
|
|
1209
|
+
* @param state - New state to update with
|
|
1210
|
+
* @param options - Options for the update, { continue: false } to avoid continuing the step
|
|
1211
|
+
* @returns Promise with the updated state
|
|
1212
|
+
*/
|
|
1213
|
+
updateState: (workflowName: string, instanceId: string, state: any, options?: UpdateOptions) => Promise<any>;
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* Continue a paused workflow instance
|
|
1217
|
+
* @param workflowName - Name of the workflow
|
|
1218
|
+
* @param instanceId - ID of the workflow instance
|
|
1219
|
+
* @param reset - Whether to reset all step counts (true) or just the current step (false)
|
|
1220
|
+
* @returns Promise with the queue ID for the continued step
|
|
1221
|
+
*/
|
|
1222
|
+
continue: (workflowName: string, instanceId: string, reset?: boolean) => Promise<{ qId: string }>;
|
|
1223
|
+
|
|
1224
|
+
/**
|
|
1225
|
+
* Get the status of a workflow instance
|
|
1226
|
+
* @param id - ID of the workflow instance
|
|
1227
|
+
* @returns Promise with the workflow status
|
|
1228
|
+
*/
|
|
1229
|
+
getWorkflowStatus: (id: string) => Promise<any>;
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* Get all workflow instances matching a filter
|
|
1233
|
+
* @param filter - Filter criteria for workflows
|
|
1234
|
+
* @returns Promise with list of workflow instances
|
|
1235
|
+
*/
|
|
1236
|
+
getInstances: (filter: any) => Promise<any[]>;
|
|
1237
|
+
|
|
1238
|
+
/**
|
|
1239
|
+
* Cancel a workflow instance
|
|
1240
|
+
* @param id - ID of the workflow instance to cancel
|
|
1241
|
+
* @returns Promise with the cancellation result
|
|
1242
|
+
*/
|
|
1243
|
+
cancelWorkflow: (id: string) => Promise<any>;
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* Register an event listener
|
|
1247
|
+
* @param event - Name of the event to listen for
|
|
1248
|
+
* @param listener - Callback function to handle the event
|
|
1249
|
+
* @example
|
|
1250
|
+
* workflow.on('stepStarted', ({ workflowName, step, state, instanceId }) => {
|
|
1251
|
+
* console.log(`Step ${step} started in workflow ${workflowName}`);
|
|
1252
|
+
* });
|
|
1253
|
+
*/
|
|
1254
|
+
on: (event: WorkflowEvent, listener: (data: WorkflowEventData) => void) => Workflow;
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* Register a one-time event listener
|
|
1258
|
+
* @param event - Name of the event to listen for
|
|
1259
|
+
* @param listener - Callback function to handle the event
|
|
1260
|
+
*/
|
|
1261
|
+
once: (event: WorkflowEvent, listener: (data: WorkflowEventData) => void) => Workflow;
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* Remove an event listener
|
|
1265
|
+
* @param event - Name of the event
|
|
1266
|
+
* @param listener - Callback function to remove
|
|
1267
|
+
*/
|
|
1268
|
+
off: (event: WorkflowEvent, listener: (data: WorkflowEventData) => void) => Workflow;
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* Emit an event
|
|
1272
|
+
* @param event - Name of the event to emit
|
|
1273
|
+
* @param data - Event data
|
|
1274
|
+
*/
|
|
1275
|
+
emit: (event: WorkflowEvent, data: WorkflowEventData) => boolean;
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Continue all timed out workflow instances
|
|
1279
|
+
* @returns Promise with array of results containing queue IDs for continued workflows
|
|
1280
|
+
*/
|
|
1281
|
+
continueAllTimedOut: () => Promise<Array<{qId: string}>>;
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* Check if a specific step in a workflow instance has timed out
|
|
1285
|
+
* @param workflow - The workflow instance to check
|
|
1286
|
+
* @returns Object containing timeout status and details
|
|
1287
|
+
* @example
|
|
1288
|
+
* const status = workflow.isStepTimedOut(workflowInstance);
|
|
1289
|
+
* // Returns:
|
|
1290
|
+
* // {
|
|
1291
|
+
* // isTimedOut: boolean,
|
|
1292
|
+
* // executionTime?: number, // if step has finished
|
|
1293
|
+
* // runningTime?: number, // if step is still running
|
|
1294
|
+
* // timeout: number, // actual timeout value used
|
|
1295
|
+
* // step: string, // name of the step checked
|
|
1296
|
+
* // startTime: string, // ISO timestamp
|
|
1297
|
+
* // finishTime?: string, // if step has finished
|
|
1298
|
+
* // currentTime?: string, // if step is still running
|
|
1299
|
+
* // timeoutSource: 'stepConfig' | 'defaultOptions' | 'globalTimeout'
|
|
1300
|
+
* // }
|
|
1301
|
+
*/
|
|
1302
|
+
isStepTimedOut: (workflow: any) => {
|
|
1303
|
+
isTimedOut: boolean;
|
|
1304
|
+
executionTime?: number;
|
|
1305
|
+
runningTime?: number;
|
|
1306
|
+
timeout: number;
|
|
1307
|
+
step: string;
|
|
1308
|
+
startTime: string;
|
|
1309
|
+
finishTime?: string;
|
|
1310
|
+
currentTime?: string;
|
|
1311
|
+
timeoutSource: 'stepConfig' | 'defaultOptions' | 'globalTimeout';
|
|
1312
|
+
reason?: string;
|
|
1313
|
+
};
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* Find all workflow instances with timed out steps
|
|
1317
|
+
* @param filter - Optional filter criteria for workflows
|
|
1318
|
+
* @returns Promise with array of workflow instances that have timed out steps
|
|
1319
|
+
* @example
|
|
1320
|
+
* const timedOutWorkflows = await workflow.findTimedOutSteps();
|
|
1321
|
+
* // Returns array of workflows with timeout details:
|
|
1322
|
+
* // [{
|
|
1323
|
+
* // workflowId: string,
|
|
1324
|
+
* // workflowName: string,
|
|
1325
|
+
* // isTimedOut: true,
|
|
1326
|
+
* // executionTime?: number,
|
|
1327
|
+
* // runningTime?: number,
|
|
1328
|
+
* // timeout: number,
|
|
1329
|
+
* // step: string,
|
|
1330
|
+
* // startTime: string,
|
|
1331
|
+
* // finishTime?: string,
|
|
1332
|
+
* // currentTime?: string,
|
|
1333
|
+
* // timeoutSource: string
|
|
1334
|
+
* // }]
|
|
1335
|
+
*/
|
|
1336
|
+
findTimedOutSteps: (filter?: any) => Promise<Array<{
|
|
1337
|
+
workflowId: string;
|
|
1338
|
+
workflowName: string;
|
|
1339
|
+
isTimedOut: boolean;
|
|
1340
|
+
executionTime?: number;
|
|
1341
|
+
runningTime?: number;
|
|
1342
|
+
timeout: number;
|
|
1343
|
+
step: string;
|
|
1344
|
+
startTime: string;
|
|
1345
|
+
finishTime?: string;
|
|
1346
|
+
currentTime?: string;
|
|
1347
|
+
timeoutSource: 'stepConfig' | 'defaultOptions' | 'globalTimeout';
|
|
1348
|
+
}>>;
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1351
|
+
/**
|
|
1352
|
+
* Options for updating workflow state
|
|
1353
|
+
*/
|
|
1354
|
+
export type UpdateOptions = {
|
|
1355
|
+
/** Whether to continue to the next step after update */
|
|
1356
|
+
continue?: boolean;
|
|
1357
|
+
};
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* Workflow event types
|
|
1361
|
+
*/
|
|
1362
|
+
export type WorkflowEvent =
|
|
1363
|
+
| 'workflowCreated'
|
|
1364
|
+
| 'workflowStarted'
|
|
1365
|
+
| 'workflowContinued'
|
|
1366
|
+
| 'stepStarted'
|
|
1367
|
+
| 'stepEnqueued'
|
|
1368
|
+
| 'stateUpdated'
|
|
1369
|
+
| 'completed'
|
|
1370
|
+
| 'cancelled'
|
|
1371
|
+
| 'error';
|
|
1372
|
+
|
|
1373
|
+
/**
|
|
1374
|
+
* Data structure for workflow events
|
|
1375
|
+
*/
|
|
1376
|
+
export type WorkflowEventData = {
|
|
1377
|
+
workflowName: string;
|
|
1378
|
+
step?: string;
|
|
1379
|
+
state?: any;
|
|
1380
|
+
instanceId?: string;
|
|
1381
|
+
error?: Error;
|
|
1382
|
+
[key: string]: any;
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1385
|
+
//# sourceMappingURL=index.d.ts.map
|