db4ai 0.3.0 → 0.3.2
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/dist/chunk-3DWAMVV5.js +305 -0
- package/dist/chunk-3DWAMVV5.js.map +1 -0
- package/dist/chunk-COTPYBYM.js +618 -0
- package/dist/chunk-COTPYBYM.js.map +1 -0
- package/dist/chunk-EERD6CDF.js +735 -0
- package/dist/chunk-EERD6CDF.js.map +1 -0
- package/dist/chunk-FUF4HJTC.js +758 -0
- package/dist/chunk-FUF4HJTC.js.map +1 -0
- package/dist/chunk-JLL6FH5L.js +16 -0
- package/dist/chunk-JLL6FH5L.js.map +1 -0
- package/dist/chunk-JXFW6AIT.js +192 -0
- package/dist/chunk-JXFW6AIT.js.map +1 -0
- package/dist/chunk-XLSYCQPG.js +854 -0
- package/dist/chunk-XLSYCQPG.js.map +1 -0
- package/dist/chunk-Y5IXAS7F.js +569 -0
- package/dist/chunk-Y5IXAS7F.js.map +1 -0
- package/dist/cli/bin.d.ts +13 -12
- package/dist/cli/bin.js +277 -307
- package/dist/cli/bin.js.map +1 -1
- package/dist/cli/dashboard/index.d.ts +295 -14
- package/dist/cli/dashboard/index.js +60 -15
- package/dist/cli/dashboard/index.js.map +1 -1
- package/dist/cli/index.d.ts +10 -16
- package/dist/cli/index.js +94 -47
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/runtime/index.d.ts +52 -23
- package/dist/cli/runtime/index.js +10 -704
- package/dist/cli/runtime/index.js.map +1 -1
- package/dist/cli/scanner/index.d.ts +17 -15
- package/dist/cli/scanner/index.js +8 -639
- package/dist/cli/scanner/index.js.map +1 -1
- package/dist/cli/seed/index.d.ts +16 -12
- package/dist/cli/seed/index.js +12 -773
- package/dist/cli/seed/index.js.map +1 -1
- package/dist/cli/sync/index.d.ts +54 -53
- package/dist/cli/sync/index.js +23 -704
- package/dist/cli/sync/index.js.map +1 -1
- package/dist/cli/terminal.d.ts +9 -8
- package/dist/cli/terminal.js +6 -209
- package/dist/cli/terminal.js.map +1 -1
- package/dist/cli/workflow/index.d.ts +18 -10
- package/dist/cli/workflow/index.js +6 -307
- package/dist/cli/workflow/index.js.map +1 -1
- package/dist/handlers.d.ts +10 -9
- package/dist/handlers.js +6 -38
- package/dist/handlers.js.map +1 -1
- package/dist/index.d.ts +120 -118
- package/dist/index.js +1972 -3125
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
- package/dist/cli/bin.d.ts.map +0 -1
- package/dist/cli/dashboard/App.d.ts +0 -16
- package/dist/cli/dashboard/App.d.ts.map +0 -1
- package/dist/cli/dashboard/App.js +0 -116
- package/dist/cli/dashboard/App.js.map +0 -1
- package/dist/cli/dashboard/components/index.d.ts +0 -70
- package/dist/cli/dashboard/components/index.d.ts.map +0 -1
- package/dist/cli/dashboard/components/index.js +0 -192
- package/dist/cli/dashboard/components/index.js.map +0 -1
- package/dist/cli/dashboard/hooks/index.d.ts +0 -76
- package/dist/cli/dashboard/hooks/index.d.ts.map +0 -1
- package/dist/cli/dashboard/hooks/index.js +0 -201
- package/dist/cli/dashboard/hooks/index.js.map +0 -1
- package/dist/cli/dashboard/index.d.ts.map +0 -1
- package/dist/cli/dashboard/types.d.ts +0 -84
- package/dist/cli/dashboard/types.d.ts.map +0 -1
- package/dist/cli/dashboard/types.js +0 -5
- package/dist/cli/dashboard/types.js.map +0 -1
- package/dist/cli/dashboard/views/index.d.ts +0 -51
- package/dist/cli/dashboard/views/index.d.ts.map +0 -1
- package/dist/cli/dashboard/views/index.js +0 -72
- package/dist/cli/dashboard/views/index.js.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/runtime/index.d.ts.map +0 -1
- package/dist/cli/scanner/index.d.ts.map +0 -1
- package/dist/cli/seed/index.d.ts.map +0 -1
- package/dist/cli/sync/index.d.ts.map +0 -1
- package/dist/cli/terminal.d.ts.map +0 -1
- package/dist/cli/workflow/index.d.ts.map +0 -1
- package/dist/errors.d.ts +0 -43
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -47
- package/dist/errors.js.map +0 -1
- package/dist/handlers.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/types.d.ts +0 -276
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -12
- package/dist/types.js.map +0 -1
|
@@ -1,308 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { randomUUID } from 'node:crypto';
|
|
8
|
-
// =============================================================================
|
|
9
|
-
// Workflow Runner Implementation
|
|
10
|
-
// =============================================================================
|
|
11
|
-
export function createWorkflowRunner(db, eventsAPI) {
|
|
12
|
-
const workflows = new Map();
|
|
13
|
-
const executions = new Map();
|
|
14
|
-
const abortControllers = new Map();
|
|
15
|
-
const eventUnsubscribers = [];
|
|
16
|
-
const runQueues = new Map();
|
|
17
|
-
const runningCounts = new Map();
|
|
18
|
-
let isWatching = false;
|
|
19
|
-
// Store internal handlers for event triggering
|
|
20
|
-
const internalHandlers = new Map();
|
|
21
|
-
const matchesPatternInternal = (pattern, type, action) => {
|
|
22
|
-
const [patternType, patternAction] = pattern.split('.');
|
|
23
|
-
const typeMatches = patternType === '*' || patternType === type;
|
|
24
|
-
const actionMatches = patternAction === '*' || patternAction === action;
|
|
25
|
-
return typeMatches && actionMatches;
|
|
26
|
-
};
|
|
27
|
-
// Store reference to original emit function
|
|
28
|
-
const originalEmit = eventsAPI.emit;
|
|
29
|
-
// Create a function that triggers internal handlers and calls the current emit
|
|
30
|
-
const triggerInternalHandlers = async (event) => {
|
|
31
|
-
for (const [pattern, handlers] of internalHandlers.entries()) {
|
|
32
|
-
if (matchesPatternInternal(pattern, event.type, event.action)) {
|
|
33
|
-
for (const handler of handlers) {
|
|
34
|
-
await handler(event);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
// Intercept emit calls by wrapping the vi.fn()
|
|
40
|
-
// We use Object.defineProperty to intercept calls while preserving vi.fn() methods
|
|
41
|
-
const originalEmitFn = eventsAPI.emit;
|
|
42
|
-
const emitProxy = new Proxy(originalEmitFn, {
|
|
43
|
-
apply: async (target, thisArg, args) => {
|
|
44
|
-
const eventOrString = args[0];
|
|
45
|
-
// If called with a DBEvent object, trigger internal handlers first
|
|
46
|
-
if (typeof eventOrString !== 'string' && eventOrString?.type && eventOrString?.action) {
|
|
47
|
-
await triggerInternalHandlers(eventOrString);
|
|
48
|
-
}
|
|
49
|
-
// Call the original function (which might have been replaced by mockImplementation)
|
|
50
|
-
return Reflect.apply(target, thisArg, args);
|
|
51
|
-
},
|
|
52
|
-
get: (target, prop, receiver) => {
|
|
53
|
-
// Pass through all properties (including mockImplementation, mock, etc.)
|
|
54
|
-
return Reflect.get(target, prop, receiver);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
eventsAPI.emit = emitProxy;
|
|
58
|
-
const createLogger = (runId, workflowName) => ({
|
|
59
|
-
info: (message, data) => {
|
|
60
|
-
console.info(`[${workflowName}:${runId}] ${message}`, data ?? '');
|
|
61
|
-
},
|
|
62
|
-
warn: (message, data) => {
|
|
63
|
-
console.warn(`[${workflowName}:${runId}] ${message}`, data ?? '');
|
|
64
|
-
},
|
|
65
|
-
error: (message, data) => {
|
|
66
|
-
console.error(`[${workflowName}:${runId}] ${message}`, data ?? '');
|
|
67
|
-
},
|
|
68
|
-
debug: (message, data) => {
|
|
69
|
-
console.debug(`[${workflowName}:${runId}] ${message}`, data ?? '');
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
const executeWorkflow = async (config, entity, runId, attempt, input) => {
|
|
73
|
-
const abortController = new AbortController();
|
|
74
|
-
abortControllers.set(runId, abortController);
|
|
75
|
-
const execution = executions.get(runId);
|
|
76
|
-
execution.status = 'running';
|
|
77
|
-
execution.attempt = attempt;
|
|
78
|
-
try {
|
|
79
|
-
const context = {
|
|
80
|
-
entity: entity,
|
|
81
|
-
db: {
|
|
82
|
-
generate: db.generate,
|
|
83
|
-
relationships: db.relationships,
|
|
84
|
-
get: db.get,
|
|
85
|
-
list: db.list,
|
|
86
|
-
update: db.update,
|
|
87
|
-
},
|
|
88
|
-
emit: (event, data) => {
|
|
89
|
-
// Call eventsAPI.emit with the string event name first, then data
|
|
90
|
-
// This allows tests to capture the emitted event in string format
|
|
91
|
-
;
|
|
92
|
-
eventsAPI.emit(event, data);
|
|
93
|
-
},
|
|
94
|
-
log: createLogger(runId, config.name),
|
|
95
|
-
workflow: {
|
|
96
|
-
name: config.name,
|
|
97
|
-
runId,
|
|
98
|
-
attempt,
|
|
99
|
-
},
|
|
100
|
-
signal: abortController.signal,
|
|
101
|
-
input,
|
|
102
|
-
};
|
|
103
|
-
// Apply timeout
|
|
104
|
-
const timeout = config.timeout ?? 30000;
|
|
105
|
-
let timeoutId;
|
|
106
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
107
|
-
timeoutId = setTimeout(() => {
|
|
108
|
-
abortController.abort();
|
|
109
|
-
reject(new Error('Workflow timeout'));
|
|
110
|
-
}, timeout);
|
|
111
|
-
});
|
|
112
|
-
try {
|
|
113
|
-
await Promise.race([config.handler(context), timeoutPromise]);
|
|
114
|
-
}
|
|
115
|
-
finally {
|
|
116
|
-
clearTimeout(timeoutId);
|
|
117
|
-
}
|
|
118
|
-
execution.status = 'completed';
|
|
119
|
-
execution.completedAt = Date.now();
|
|
120
|
-
}
|
|
121
|
-
catch (err) {
|
|
122
|
-
const maxRetries = config.maxRetries ?? 0;
|
|
123
|
-
if (attempt < maxRetries && !abortController.signal.aborted) {
|
|
124
|
-
const retryDelay = config.retryDelay ?? 1000;
|
|
125
|
-
await new Promise((r) => setTimeout(r, retryDelay));
|
|
126
|
-
return executeWorkflow(config, entity, runId, attempt + 1, input);
|
|
127
|
-
}
|
|
128
|
-
execution.status = abortController.signal.aborted ? 'cancelled' : 'failed';
|
|
129
|
-
execution.error = err instanceof Error ? err.message : String(err);
|
|
130
|
-
execution.completedAt = Date.now();
|
|
131
|
-
}
|
|
132
|
-
finally {
|
|
133
|
-
abortControllers.delete(runId);
|
|
134
|
-
const count = runningCounts.get(config.name) ?? 0;
|
|
135
|
-
runningCounts.set(config.name, Math.max(0, count - 1));
|
|
136
|
-
// Process next in queue
|
|
137
|
-
const queue = runQueues.get(config.name) ?? [];
|
|
138
|
-
if (queue.length > 0) {
|
|
139
|
-
const next = queue.shift();
|
|
140
|
-
runQueues.set(config.name, queue);
|
|
141
|
-
next();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
const scheduleExecution = async (config, entity, runId, input) => {
|
|
146
|
-
const concurrency = config.concurrency ?? 1;
|
|
147
|
-
const currentRunning = runningCounts.get(config.name) ?? 0;
|
|
148
|
-
if (currentRunning >= concurrency) {
|
|
149
|
-
// Queue the execution
|
|
150
|
-
return new Promise((resolve) => {
|
|
151
|
-
const queue = runQueues.get(config.name) ?? [];
|
|
152
|
-
queue.push(async () => {
|
|
153
|
-
await scheduleExecution(config, entity, runId, input);
|
|
154
|
-
resolve();
|
|
155
|
-
});
|
|
156
|
-
runQueues.set(config.name, queue);
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
runningCounts.set(config.name, currentRunning + 1);
|
|
160
|
-
await executeWorkflow(config, entity, runId, 1, input);
|
|
161
|
-
};
|
|
162
|
-
const matchesPattern = (pattern, type, action) => {
|
|
163
|
-
const [patternType, patternAction] = pattern.split('.');
|
|
164
|
-
const typeMatches = patternType === '*' || patternType === type;
|
|
165
|
-
const actionMatches = patternAction === '*' || patternAction === action;
|
|
166
|
-
return typeMatches && actionMatches;
|
|
167
|
-
};
|
|
168
|
-
return {
|
|
169
|
-
register(config) {
|
|
170
|
-
if (workflows.has(config.name)) {
|
|
171
|
-
throw new Error(`Workflow '${config.name}' already exists`);
|
|
172
|
-
}
|
|
173
|
-
workflows.set(config.name, config);
|
|
174
|
-
},
|
|
175
|
-
registerAll(configs) {
|
|
176
|
-
for (const config of configs) {
|
|
177
|
-
this.register(config);
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
unregister(name) {
|
|
181
|
-
workflows.delete(name);
|
|
182
|
-
},
|
|
183
|
-
async watch() {
|
|
184
|
-
if (isWatching)
|
|
185
|
-
return;
|
|
186
|
-
isWatching = true;
|
|
187
|
-
for (const [, config] of workflows) {
|
|
188
|
-
if (typeof config.trigger === 'string' && config.trigger !== 'manual') {
|
|
189
|
-
const handler = async (event) => {
|
|
190
|
-
const entity = event.data;
|
|
191
|
-
// Apply filter if present
|
|
192
|
-
if (config.filter) {
|
|
193
|
-
const shouldProcess = await config.filter(entity);
|
|
194
|
-
if (!shouldProcess)
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
const runId = randomUUID();
|
|
198
|
-
executions.set(runId, {
|
|
199
|
-
runId,
|
|
200
|
-
workflowName: config.name,
|
|
201
|
-
status: 'pending',
|
|
202
|
-
startedAt: Date.now(),
|
|
203
|
-
entityId: event.entityId,
|
|
204
|
-
entityType: event.type,
|
|
205
|
-
attempt: 0,
|
|
206
|
-
});
|
|
207
|
-
await scheduleExecution(config, {
|
|
208
|
-
...entity,
|
|
209
|
-
$id: entity.$id ?? event.entityId,
|
|
210
|
-
$rowid: entity.$rowid ?? event.entityRowid
|
|
211
|
-
}, runId);
|
|
212
|
-
};
|
|
213
|
-
// Store handler in internal map for direct triggering
|
|
214
|
-
// (We don't use eventsAPI.on to avoid double-triggering when test doesn't override mock)
|
|
215
|
-
const existingHandlers = internalHandlers.get(config.trigger) ?? [];
|
|
216
|
-
internalHandlers.set(config.trigger, [...existingHandlers, handler]);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
async stop() {
|
|
221
|
-
isWatching = false;
|
|
222
|
-
for (const unsubscribe of eventUnsubscribers) {
|
|
223
|
-
unsubscribe();
|
|
224
|
-
}
|
|
225
|
-
eventUnsubscribers.length = 0;
|
|
226
|
-
internalHandlers.clear();
|
|
227
|
-
},
|
|
228
|
-
async run(name, options) {
|
|
229
|
-
const config = workflows.get(name);
|
|
230
|
-
if (!config) {
|
|
231
|
-
throw new Error(`Workflow '${name}' not found`);
|
|
232
|
-
}
|
|
233
|
-
const runId = randomUUID();
|
|
234
|
-
let entity = {};
|
|
235
|
-
// Parse target if provided
|
|
236
|
-
if (options?.target) {
|
|
237
|
-
const [type, id] = options.target.split(':');
|
|
238
|
-
const fetched = await db.get(type, id);
|
|
239
|
-
entity = fetched;
|
|
240
|
-
}
|
|
241
|
-
executions.set(runId, {
|
|
242
|
-
runId,
|
|
243
|
-
workflowName: name,
|
|
244
|
-
status: 'pending',
|
|
245
|
-
startedAt: Date.now(),
|
|
246
|
-
entityId: entity.$id,
|
|
247
|
-
entityType: options?.target?.split(':')[0],
|
|
248
|
-
attempt: 0,
|
|
249
|
-
});
|
|
250
|
-
const executePromise = scheduleExecution(config, { ...entity, $id: entity.$id ?? 'manual', $rowid: entity.$rowid ?? 0 }, runId, options?.input);
|
|
251
|
-
if (options?.wait) {
|
|
252
|
-
await executePromise;
|
|
253
|
-
}
|
|
254
|
-
return runId;
|
|
255
|
-
},
|
|
256
|
-
active() {
|
|
257
|
-
return Array.from(executions.values());
|
|
258
|
-
},
|
|
259
|
-
get(name) {
|
|
260
|
-
return workflows.get(name);
|
|
261
|
-
},
|
|
262
|
-
list() {
|
|
263
|
-
return Array.from(workflows.values());
|
|
264
|
-
},
|
|
265
|
-
stats() {
|
|
266
|
-
const all = Array.from(executions.values());
|
|
267
|
-
return {
|
|
268
|
-
total: all.length,
|
|
269
|
-
running: all.filter((e) => e.status === 'running').length,
|
|
270
|
-
completed: all.filter((e) => e.status === 'completed').length,
|
|
271
|
-
failed: all.filter((e) => e.status === 'failed').length,
|
|
272
|
-
cancelled: all.filter((e) => e.status === 'cancelled').length,
|
|
273
|
-
};
|
|
274
|
-
},
|
|
275
|
-
async cancel(runId) {
|
|
276
|
-
const controller = abortControllers.get(runId);
|
|
277
|
-
if (controller) {
|
|
278
|
-
controller.abort();
|
|
279
|
-
}
|
|
280
|
-
const execution = executions.get(runId);
|
|
281
|
-
if (execution) {
|
|
282
|
-
execution.status = 'cancelled';
|
|
283
|
-
execution.completedAt = Date.now();
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
async cancelAll(name) {
|
|
287
|
-
for (const [runId, execution] of executions) {
|
|
288
|
-
if (execution.workflowName === name && execution.status === 'running') {
|
|
289
|
-
await this.cancel(runId);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
// Clear queue
|
|
293
|
-
runQueues.delete(name);
|
|
294
|
-
},
|
|
295
|
-
async waitFor(runId, timeout = 30000) {
|
|
296
|
-
const start = Date.now();
|
|
297
|
-
while (Date.now() - start < timeout) {
|
|
298
|
-
const execution = executions.get(runId);
|
|
299
|
-
if (execution && (execution.status === 'completed' || execution.status === 'failed' || execution.status === 'cancelled')) {
|
|
300
|
-
return execution;
|
|
301
|
-
}
|
|
302
|
-
await new Promise((r) => setTimeout(r, 50));
|
|
303
|
-
}
|
|
304
|
-
throw new Error(`Timeout waiting for workflow ${runId}`);
|
|
305
|
-
},
|
|
306
|
-
};
|
|
307
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
createWorkflowRunner
|
|
3
|
+
} from "../../chunk-3DWAMVV5.js";
|
|
4
|
+
export {
|
|
5
|
+
createWorkflowRunner
|
|
6
|
+
};
|
|
308
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../cli/workflow/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAuHxC,gFAAgF;AAChF,iCAAiC;AACjC,gFAAgF;AAEhF,MAAM,UAAU,oBAAoB,CAAC,EAAU,EAAE,SAAwB;IACvE,MAAM,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAA;IACnD,MAAM,UAAU,G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AAI,CAAC,GAAG,EAAE,CAAA;YACxB,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,OAAO,EAAE,CAAC;gBACpC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;gBACvC,IAAI,SAAS,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,WAAW,IAAI,SAAS,CAAC,MAAM,KAAK,QAAQ,IAAI,SAAS,CAAC,MAAM,KAAK,WAAW,CAAC,EAAE,CAAC;oBACzH,OAAO,SAAS,CAAA;gBAClB,CAAC;gBACD,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;YAC7C,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,gCAAgC,KAAK,EAAE,CAAC,CAAA;QAC1D,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/handlers.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* }
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
interface SerializedFunction {
|
|
18
18
|
/** The name of the function (e.g., '$created', 'validateUser') */
|
|
19
19
|
name: string;
|
|
20
20
|
/** The stringified function body */
|
|
@@ -43,7 +43,7 @@ export interface SerializedFunction {
|
|
|
43
43
|
* // { name: '$created', body: 'async (entity, $) => {...}', params: ['entity', '$'], async: true }
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
declare function serializeFunction(name: string, fn: Function): SerializedFunction;
|
|
47
47
|
/**
|
|
48
48
|
* Entity-level lifecycle handler types.
|
|
49
49
|
*
|
|
@@ -64,7 +64,7 @@ export declare function serializeFunction(name: string, fn: Function): Serialize
|
|
|
64
64
|
* })
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
|
-
|
|
67
|
+
type EntityHandlerType = '$created' | '$updated' | '$deleted';
|
|
68
68
|
/**
|
|
69
69
|
* Schema-level lifecycle handler types.
|
|
70
70
|
*
|
|
@@ -82,7 +82,7 @@ export type EntityHandlerType = '$created' | '$updated' | '$deleted';
|
|
|
82
82
|
* })
|
|
83
83
|
* ```
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
type SchemaHandlerType = '$seeded' | '$ready' | '$error';
|
|
86
86
|
/**
|
|
87
87
|
* All lifecycle handler types (entity + schema level).
|
|
88
88
|
*
|
|
@@ -90,7 +90,7 @@ export type SchemaHandlerType = '$seeded' | '$ready' | '$error';
|
|
|
90
90
|
* - Entity handlers: `$created`, `$updated`, `$deleted`
|
|
91
91
|
* - Schema handlers: `$seeded`, `$ready`, `$error`
|
|
92
92
|
*/
|
|
93
|
-
|
|
93
|
+
type LifecycleHandlerType = EntityHandlerType | SchemaHandlerType;
|
|
94
94
|
/**
|
|
95
95
|
* State machine handler types.
|
|
96
96
|
*
|
|
@@ -113,14 +113,14 @@ export type LifecycleHandlerType = EntityHandlerType | SchemaHandlerType;
|
|
|
113
113
|
* })
|
|
114
114
|
* ```
|
|
115
115
|
*/
|
|
116
|
-
|
|
116
|
+
type StateHandlerType = '$entry' | '$exit';
|
|
117
117
|
/**
|
|
118
118
|
* Handler execution result from the sandboxed environment.
|
|
119
119
|
*
|
|
120
120
|
* Contains the outcome of executing a serialized handler function
|
|
121
121
|
* in an isolated V8 sandbox.
|
|
122
122
|
*/
|
|
123
|
-
|
|
123
|
+
interface HandlerExecutionResult {
|
|
124
124
|
/** Whether execution completed without error */
|
|
125
125
|
success: boolean;
|
|
126
126
|
/** Return value from the handler (if any) */
|
|
@@ -136,7 +136,7 @@ export interface HandlerExecutionResult {
|
|
|
136
136
|
* Console output from handlers is captured and returned
|
|
137
137
|
* for debugging and monitoring purposes.
|
|
138
138
|
*/
|
|
139
|
-
|
|
139
|
+
interface HandlerLogEntry {
|
|
140
140
|
/** Log level (log, warn, error, info, debug) */
|
|
141
141
|
level: 'log' | 'warn' | 'error' | 'info' | 'debug';
|
|
142
142
|
/** The log message content */
|
|
@@ -144,4 +144,5 @@ export interface HandlerLogEntry {
|
|
|
144
144
|
/** Timestamp when the log was created */
|
|
145
145
|
timestamp: number;
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
|
|
148
|
+
export { type EntityHandlerType, type HandlerExecutionResult, type HandlerLogEntry, type LifecycleHandlerType, type SchemaHandlerType, type SerializedFunction, type StateHandlerType, serializeFunction };
|
package/dist/handlers.js
CHANGED
|
@@ -1,39 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Serialize a function for server-side execution.
|
|
9
|
-
*
|
|
10
|
-
* Converts a JavaScript function into a serializable format that can be
|
|
11
|
-
* sent to the server and executed in a sandboxed environment.
|
|
12
|
-
*
|
|
13
|
-
* @param name - The name to assign to the serialized function
|
|
14
|
-
* @param fn - The function to serialize
|
|
15
|
-
* @returns A SerializedFunction object
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* const handler = async (entity: any, $: any) => {
|
|
20
|
-
* await $.OtherType(entity.name)
|
|
21
|
-
* }
|
|
22
|
-
* const serialized = serializeFunction('$created', handler)
|
|
23
|
-
* // { name: '$created', body: 'async (entity, $) => {...}', params: ['entity', '$'], async: true }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export function serializeFunction(name, fn) {
|
|
27
|
-
const fnStr = fn.toString();
|
|
28
|
-
const isAsync = fnStr.trimStart().startsWith('async');
|
|
29
|
-
let params = [];
|
|
30
|
-
const paramMatch = fnStr.match(/^(?:async\s*)?(?:function\s*\w*)?\s*\(([^)]*)\)/);
|
|
31
|
-
if (paramMatch && paramMatch[1]) {
|
|
32
|
-
params = paramMatch[1]
|
|
33
|
-
.split(',')
|
|
34
|
-
.map((p) => p.trim().split(':')[0].split('=')[0].trim())
|
|
35
|
-
.filter(Boolean);
|
|
36
|
-
}
|
|
37
|
-
return { name, body: fnStr, params, async: isAsync };
|
|
38
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
serializeFunction
|
|
3
|
+
} from "./chunk-JLL6FH5L.js";
|
|
4
|
+
export {
|
|
5
|
+
serializeFunction
|
|
6
|
+
};
|
|
39
7
|
//# sourceMappingURL=handlers.js.map
|
package/dist/handlers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|