codehooks-js 1.3.7 → 1.3.8
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/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 +1254 -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 +14 -3
package/types/webserver.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export function serveStatic(options: any, app: any, filestore: any
|
|
1
|
+
export function serveStatic(options: any, app: any, filestore: any): void;
|
|
2
2
|
export function render(viewFile: any, data: any, settings: any, cb: any): Promise<any>;
|
|
3
|
+
//# sourceMappingURL=webserver.d.mts.map
|
|
@@ -7,12 +7,10 @@ export default _default;
|
|
|
7
7
|
* StepsEngine class that manages step-based workflows
|
|
8
8
|
* @extends EventEmitter
|
|
9
9
|
*/
|
|
10
|
-
declare class StepsEngine
|
|
10
|
+
declare class StepsEngine {
|
|
11
11
|
static instance: any;
|
|
12
12
|
static collectionName: string;
|
|
13
13
|
static queuePrefix: string;
|
|
14
|
-
static timeout: number;
|
|
15
|
-
static maxStepCount: number;
|
|
16
14
|
/**
|
|
17
15
|
* Set the collection name for storing steps data
|
|
18
16
|
* @param {string} name - Collection name
|
|
@@ -25,37 +23,12 @@ declare class StepsEngine extends EventEmitter<[never]> {
|
|
|
25
23
|
* @throws {Error} If prefix is not a non-empty string
|
|
26
24
|
*/
|
|
27
25
|
static setQueuePrefix(prefix: string): void;
|
|
28
|
-
/**
|
|
29
|
-
* Set the timeout for steps jobs
|
|
30
|
-
* @param {number} timeout - Timeout in milliseconds
|
|
31
|
-
* @throws {Error} If timeout is not a positive number
|
|
32
|
-
*/
|
|
33
|
-
static setTimeout(timeout: number): void;
|
|
34
|
-
/**
|
|
35
|
-
* Set the maximum step count for a steps workflow
|
|
36
|
-
* @param {number} maxStepCount - Maximum step count
|
|
37
|
-
* @throws {Error} If maxStepCount is not a positive number
|
|
38
|
-
*/
|
|
39
|
-
static setMaxStepCount(maxStepCount: number): void;
|
|
40
26
|
/**
|
|
41
27
|
* Get the singleton instance of StepsEngine
|
|
42
28
|
* @returns {StepsEngine} The singleton instance
|
|
43
29
|
*/
|
|
44
30
|
static getInstance(): StepsEngine;
|
|
45
|
-
|
|
46
|
-
definitions: Map<any, any>;
|
|
47
|
-
/**
|
|
48
|
-
* Configure the steps engine
|
|
49
|
-
* @param {Object} config - Configuration object
|
|
50
|
-
* @param {string} config.collectionName - Collection name
|
|
51
|
-
* @param {string} config.queuePrefix - Queue prefix
|
|
52
|
-
* @param {number} config.timeout - Timeout in milliseconds
|
|
53
|
-
*/
|
|
54
|
-
configure(config: {
|
|
55
|
-
collectionName: string;
|
|
56
|
-
queuePrefix: string;
|
|
57
|
-
timeout: number;
|
|
58
|
-
}): void;
|
|
31
|
+
definitions: any;
|
|
59
32
|
/**
|
|
60
33
|
* Get the step definition for a specific step
|
|
61
34
|
* @param {string} stepsName - Name of the steps workflow
|
|
@@ -106,10 +79,9 @@ declare class StepsEngine extends EventEmitter<[never]> {
|
|
|
106
79
|
* @param {string} stepsName - Name of the steps workflow
|
|
107
80
|
* @param {string} instanceId - ID of the steps instance
|
|
108
81
|
* @param {Object} state - New state to update with
|
|
109
|
-
* @param {Object} options - Options for the update, { continue: false } to avoid continuing the the step
|
|
110
82
|
* @returns {Promise<Object>} The updated state
|
|
111
83
|
*/
|
|
112
|
-
updateState(stepsName: string, instanceId: string, state: any
|
|
84
|
+
updateState(stepsName: string, instanceId: string, state: any): Promise<any>;
|
|
113
85
|
/**
|
|
114
86
|
* Set the complete state of a steps instance
|
|
115
87
|
* @param {string} instanceId - ID of the steps instance
|
|
@@ -127,13 +99,6 @@ declare class StepsEngine extends EventEmitter<[never]> {
|
|
|
127
99
|
continue(stepsName: string, instanceId: string): Promise<{
|
|
128
100
|
qId: string;
|
|
129
101
|
}>;
|
|
130
|
-
/**
|
|
131
|
-
* Continue all timed out steps instances
|
|
132
|
-
* @returns {Promise<Array<{qId: string}>>} Array of results containing queue IDs for continued workflows
|
|
133
|
-
*/
|
|
134
|
-
continueAllTimedOut(): Promise<Array<{
|
|
135
|
-
qId: string;
|
|
136
|
-
}>>;
|
|
137
102
|
/**
|
|
138
103
|
* Get the status of a steps instance
|
|
139
104
|
* @param {string} id - ID of the steps instance
|
|
@@ -145,7 +110,7 @@ declare class StepsEngine extends EventEmitter<[never]> {
|
|
|
145
110
|
* @param {Object} filter - Filter criteria for steps workflows
|
|
146
111
|
* @returns {Promise<Array>} List of steps instances
|
|
147
112
|
*/
|
|
148
|
-
|
|
113
|
+
listSteps(filter: any): Promise<any[]>;
|
|
149
114
|
/**
|
|
150
115
|
* Cancel a steps instance
|
|
151
116
|
* @param {string} id - ID of the steps instance to cancel
|
|
@@ -153,4 +118,4 @@ declare class StepsEngine extends EventEmitter<[never]> {
|
|
|
153
118
|
*/
|
|
154
119
|
cancelSteps(id: string): Promise<any>;
|
|
155
120
|
}
|
|
156
|
-
|
|
121
|
+
//# sourceMappingURL=engine.d.mts.map
|
|
@@ -2,14 +2,10 @@ export namespace StepsConfig {
|
|
|
2
2
|
export { setCollectionName };
|
|
3
3
|
export { setQueuePrefix };
|
|
4
4
|
}
|
|
5
|
-
export const configure: (config: {
|
|
6
|
-
collectionName: string;
|
|
7
|
-
queuePrefix: string;
|
|
8
|
-
timeout: number;
|
|
9
|
-
}) => void;
|
|
10
5
|
export { Steps };
|
|
11
6
|
export default StepsEngine;
|
|
12
7
|
import { setCollectionName } from './engine.mjs';
|
|
13
8
|
import { setQueuePrefix } from './engine.mjs';
|
|
14
9
|
import { Steps } from './engine.mjs';
|
|
15
10
|
import StepsEngine from './engine.mjs';
|
|
11
|
+
//# sourceMappingURL=index.d.mts.map
|
package/workflow/engine.mjs
CHANGED
|
@@ -207,11 +207,14 @@ class StepsEngine extends EventEmitter {
|
|
|
207
207
|
// get a fresh copy of the parallel steps
|
|
208
208
|
const fresh = await connection.findOne(StepsEngine.collectionName, { _id: instanceId });
|
|
209
209
|
fresh.parallelSteps[mergedState.nextStep].done = true;
|
|
210
|
-
fresh.parallelSteps[mergedState.nextStep].nextStep = nextStep;
|
|
210
|
+
fresh.parallelSteps[mergedState.nextStep].nextStep = nextStep;
|
|
211
|
+
//fresh.parallelSteps[mergedState.nextStep].previousStep = mergedState.previousStep || null;
|
|
211
212
|
delete fresh._id;
|
|
212
|
-
await connection.updateOne(StepsEngine.collectionName,
|
|
213
|
+
const updated = await connection.updateOne(StepsEngine.collectionName,
|
|
213
214
|
{ _id: instanceId },
|
|
214
215
|
{ $set: { ...fresh, parallelSteps: fresh.parallelSteps } });
|
|
216
|
+
//console.debug('updated', updated.parallelSteps);
|
|
217
|
+
mergedState.parallelSteps = fresh.parallelSteps;
|
|
215
218
|
// Check if all parallel steps are done
|
|
216
219
|
const allStepsDone = Object.values(fresh.parallelSteps).every(step => step.done);
|
|
217
220
|
if (!allStepsDone) {
|
|
@@ -219,6 +222,14 @@ class StepsEngine extends EventEmitter {
|
|
|
219
222
|
resolve();
|
|
220
223
|
return;
|
|
221
224
|
} else {
|
|
225
|
+
// validate that all parallel steps have the same next step
|
|
226
|
+
const nextSteps = Object.values(fresh.parallelSteps).map(step => step.nextStep);
|
|
227
|
+
const uniqueNextSteps = [...new Set(nextSteps)];
|
|
228
|
+
if (uniqueNextSteps.length > 1) {
|
|
229
|
+
throw new Error('Parallel steps must join to the same next step');
|
|
230
|
+
}
|
|
231
|
+
// reset the parallel steps
|
|
232
|
+
mergedState.parallelSteps = {};
|
|
222
233
|
console.debug('All parallel steps are done');
|
|
223
234
|
}
|
|
224
235
|
}
|
|
@@ -241,7 +252,7 @@ class StepsEngine extends EventEmitter {
|
|
|
241
252
|
if (Array.isArray(nextStep)) {
|
|
242
253
|
const now = new Date().toISOString();
|
|
243
254
|
const metadata = nextStep.reduce((acc, step) => {
|
|
244
|
-
acc[step] = { done: false, startTime: now };
|
|
255
|
+
acc[step] = { done: false, startTime: now, previousStep: mergedState.previousStep };
|
|
245
256
|
return acc;
|
|
246
257
|
}, {});
|
|
247
258
|
const metadataDoc = await connection.updateOne(StepsEngine.collectionName,
|