@nanobpm/engine-wasm 0.4.0 → 0.5.0

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.
@@ -0,0 +1,356 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * A simulated engine instance bound to one modeler session.
6
+ */
7
+ export class TestEngine {
8
+ free(): void;
9
+ [Symbol.dispose](): void;
10
+ /**
11
+ * Activate up to `max_jobs` `Created` jobs of `job_type`, locking them to
12
+ * `worker` until `now + timeout_ms`. Returns a JSON array of activated jobs
13
+ * (key, type, instance/element, retries, variables) for the dispatch loop to
14
+ * hand to worker handlers. The host owns the wall clock via `tickNow`.
15
+ */
16
+ activateJobs(job_type: string, max_jobs: number, timeout_ms: number, worker: string): string;
17
+ /**
18
+ * Advance the virtual clock by `by_ms` milliseconds, firing any timers that
19
+ * become due and expiring any lapsed job locks.
20
+ */
21
+ advanceTime(by_ms: number): string;
22
+ /**
23
+ * Assign a user task to `assignee`. When `allow_override` is false and the
24
+ * task already has an assignee the command is rejected (it must be
25
+ * unassigned first). Returns the snapshot.
26
+ */
27
+ assignUserTask(user_task_key: string, assignee: string, allow_override: boolean): string;
28
+ /**
29
+ * Broadcast a signal by name to **every** open subscription that matches,
30
+ * across all instances, merging `variables_json` into each correlated
31
+ * instance. Signals correlate by name only and are not buffered. Returns
32
+ * the snapshot.
33
+ */
34
+ broadcastSignal(signal_name: string, variables_json: string): string;
35
+ /**
36
+ * Cancel (terminate) a running process instance by key. Every token is
37
+ * discarded, pending jobs are canceled, and the instance transitions to
38
+ * `Terminated`. Returns the snapshot.
39
+ */
40
+ cancelInstance(instance_key: string): string;
41
+ /**
42
+ * Complete an ad-hoc sub-process **agent** job — the container's
43
+ * JOB_WORKER job (Camunda's agentic `aiagent-job-worker`) — carrying the
44
+ * agent's activate-element instructions so the engine runs the selected
45
+ * inner "tools" this turn (ADR 0023 seam 2/3; Camunda `JobResult` /
46
+ * `activateElements[]`). This is the browser seam that the plain
47
+ * `completeJob` deliberately omits (it always sends
48
+ * `adhoc_result: None`).
49
+ *
50
+ * `agent_result_json` shape (camelCase, mirroring Camunda's agentic
51
+ * `JobResult`):
52
+ * ```json
53
+ * { "activateElements": [{ "elementId": "toolA", "variables": { "q": 1 } }],
54
+ * "completionConditionFulfilled": false,
55
+ * "cancelRemainingInstances": false }
56
+ * ```
57
+ * Empty/whitespace ⇒ a no-op result, so the container completes this turn
58
+ * (no tool activated). `variables_json` merges instance variables exactly
59
+ * like `completeJob` — e.g. the agent's final
60
+ * decision when it signals `completionConditionFulfilled`.
61
+ */
62
+ completeAgentJob(job_key: string, variables_json: string, agent_result_json: string): string;
63
+ /**
64
+ * Complete a waiting job by key, merging `variables_json` (a JSON object
65
+ * string) into the instance. The job is activated first if it has not been
66
+ * already, so the UI can complete a freshly-created job directly.
67
+ */
68
+ completeJob(job_key: string, variables_json: string): string;
69
+ /**
70
+ * Complete a waiting user task by key, merging `variables_json` into the
71
+ * instance before the parked token resumes. The task must be in the
72
+ * `Created` state. Returns the snapshot.
73
+ */
74
+ completeUserTask(user_task_key: string, variables_json: string): string;
75
+ /**
76
+ * Correlate a message to any instance waiting on it: publishes `message_name`
77
+ * with the given `correlation_key` (the value the waiting subscription's
78
+ * `correlationKey` expression resolved to) and merges `variables_json` (a
79
+ * JSON object string) into each correlated instance. This unblocks a message
80
+ * intermediate catch / receive task without an external broker — the
81
+ * in-browser equivalent of an app publishing a message. Returns the snapshot.
82
+ */
83
+ correlateMessage(message_name: string, correlation_key: string, variables_json: string): string;
84
+ /**
85
+ * Start a new instance of `process_id`, seeding it with the given variables
86
+ * (a JSON object string; pass `"{}"` or `""` for none). `version` selects a
87
+ * specific process **version** number (Zeebe by-id semantics); pass
88
+ * `undefined`/`null` (or a non-positive value) for the latest version.
89
+ * Returns the post-run [`Snapshot`] with a top-level `created` field holding
90
+ * the new instance key.
91
+ */
92
+ createInstance(process_id: string, variables_json: string, version?: number | null): string;
93
+ /**
94
+ * Stop debugging, keeping the state the run produced. If the run is paused
95
+ * mid-command, that in-flight command is first **finished normally** (its
96
+ * breakpoints are cleared and it is resumed once) so the engine lands on the
97
+ * same run-to-completion (RTC) quiescent state a plain command would produce
98
+ * — never a partial, non-RTC intermediate one that later mutators could
99
+ * build on (the hole [`TestEngine::guard_paused`] exists to prevent). To
100
+ * discard the run's state entirely instead, use [`TestEngine::reset`].
101
+ */
102
+ debugClear(): void;
103
+ /**
104
+ * Begin a **debug** run of a `CreateInstance` command: deploy first (as
105
+ * usual), then call this to start the instance under the stepping executor,
106
+ * pausing at the first breakpoint (or running to completion if none match).
107
+ *
108
+ * `breakpoints_json` is a JSON array of `{ kind, id? }`:
109
+ * ```json
110
+ * [{ "kind": "elementActivated", "id": "Task_Charge" },
111
+ * { "kind": "elementCompleted", "id": "Gateway_1" },
112
+ * { "kind": "processCompleted" },
113
+ * { "kind": "everyStep" }]
114
+ * ```
115
+ * Returns the debug state JSON (see [`TestEngine::debug_state`]). Starting a
116
+ * new debug run replaces any previous *finished* session; it is rejected
117
+ * while a run is still paused (`debugIsPaused`) — resume or clear that run
118
+ * first, so its intermediate state isn't stranded live in the engine.
119
+ */
120
+ debugCreateInstance(process_id: string, variables_json: string, breakpoints_json: string): string;
121
+ /**
122
+ * Resume a paused debug run until the next breakpoint or completion. No-op if
123
+ * no session is active or it has already finished. Returns the debug state.
124
+ */
125
+ debugResume(): string;
126
+ /**
127
+ * Advance a paused debug run by exactly one step, then pause again (unless
128
+ * that step drained the command). No-op if no session is active or it has
129
+ * already finished. Returns the debug state.
130
+ */
131
+ debugStep(): string;
132
+ /**
133
+ * Parse and deploy a BPMN resource. Returns a JSON object
134
+ * `{ "processIds": [...], "snapshot": {...} }` on success, or throws a
135
+ * JS error carrying the parse/deploy failure message.
136
+ */
137
+ deploy(xml: string): string;
138
+ /**
139
+ * The full ordered event log emitted so far, as a JSON array of
140
+ * `{ seq, now, type, ...payload }`. Useful for a step-through / trace view.
141
+ */
142
+ events(): string;
143
+ /**
144
+ * Fail a waiting job by key with the given remaining `retries` and message.
145
+ * With no retries left this raises an incident (visible in the snapshot).
146
+ */
147
+ failJob(job_key: string, retries: number, message: string): string;
148
+ /**
149
+ * The latest deployed form for `form_key`, as a `FormResult` JSON object
150
+ * (`{ tenantId, formId, schema, version, formKey }`), or JSON `null` when no
151
+ * form with that key exists. Mirrors `GET /forms/{formKey}`.
152
+ */
153
+ getFormByKey(form_key: string): string;
154
+ /**
155
+ * The generic resource for `resource_key`, as a `ResourceResult` JSON object,
156
+ * or JSON `null` when no resource with that key exists. Mirrors
157
+ * `GET /resources/{resourceKey}`.
158
+ */
159
+ getResourceByKey(resource_key: string): string;
160
+ /**
161
+ * Migrate a running process instance to a target process definition (Zeebe
162
+ * "migrate process instance"): re-point every active element instance at the
163
+ * mapped element of `target_process_definition_key` and re-home the instance.
164
+ * `mapping_instructions_json` is a JSON array of
165
+ * `{ sourceElementId: string, targetElementId: string }`. Returns the
166
+ * snapshot.
167
+ */
168
+ migrate(instance_key: string, target_process_definition_key: string, mapping_instructions_json: string): string;
169
+ /**
170
+ * Modify a running process instance (Zeebe "modify process instance"): move
171
+ * tokens by terminating existing element instances and/or activating new
172
+ * ones. `activate_instructions_json` is a JSON array of
173
+ * `{ elementId: string, variables?: object }` (variables are merged into the
174
+ * instance's root scope before the token is placed);
175
+ * `terminate_instructions_json` is a JSON array of element-instance keys,
176
+ * each a decimal string or a `{ elementInstanceKey: string }` object.
177
+ * Activations run at the process root scope. Returns the snapshot.
178
+ */
179
+ modify(instance_key: string, activate_instructions_json: string, terminate_instructions_json: string): string;
180
+ /**
181
+ * Create a fresh, empty simulated engine. The virtual clock starts at 0.
182
+ */
183
+ constructor();
184
+ /**
185
+ * Discard all engine state (deployed definitions, instances, jobs, timers,
186
+ * the event log and the virtual clock), returning the engine to the same
187
+ * pristine state as a freshly constructed one. Callers redeploy afterwards
188
+ * to start a clean run — this is what makes a re-run start from zero
189
+ * completed instances rather than accumulating across runs.
190
+ */
191
+ reset(): void;
192
+ /**
193
+ * Resolve an open incident by key, retrying the work that failed (a job
194
+ * incident returns the parked job — which must have retries left — to the
195
+ * activatable pool; a gateway incident re-evaluates; an uncaught-error
196
+ * incident re-creates the service-task job). Returns the snapshot.
197
+ */
198
+ resolveIncident(incident_key: string): string;
199
+ /**
200
+ * All process instances, as a `ProcessInstanceSearchQueryResult` JSON object
201
+ * (`{ items: [...], page: {...} }`). The request body is shape-validated like
202
+ * `POST /process-instances/search`, but filter/sort/page fields are not yet
203
+ * honoured — every instance is returned. Do not rely on gateway-side
204
+ * filtering through this method yet.
205
+ */
206
+ searchProcessInstances(filter_json: string): string;
207
+ /**
208
+ * The user tasks matching an optional `{ state? }` filter, as a
209
+ * `UserTaskSearchQueryResult` JSON object (`{ items: [...], page: {...} }`).
210
+ * The `state` filter (e.g. `"CREATED"`) is honoured through the read model,
211
+ * not hardcoded. Mirrors `POST /user-tasks/search`.
212
+ */
213
+ searchUserTasks(filter_json: string): string;
214
+ /**
215
+ * All variables, as a `VariableSearchQueryResult` JSON object
216
+ * (`{ items: [...], page: {...} }`). The request body is shape-validated like
217
+ * `POST /variables/search`, but filter/sort/page fields are not yet honoured —
218
+ * every variable is returned. Values longer than `VARIABLE_VALUE_PREVIEW_LEN`
219
+ * are truncated with `isTruncated: true`; shorter values pass through intact
220
+ * with `isTruncated: false`. There is no `truncateValues` opt-out yet.
221
+ */
222
+ searchVariables(filter_json: string): string;
223
+ /**
224
+ * Merge variables into a scope (a process-instance key or an element-instance
225
+ * key). When `local` is true the values are written strictly into the target
226
+ * scope; otherwise they propagate upward to the nearest ancestor scope that
227
+ * defines each name (Zeebe `SetVariables` semantics). Returns the snapshot.
228
+ */
229
+ setVariables(scope_key: string, variables_json: string, local: boolean): string;
230
+ /**
231
+ * The current simulation state as a JSON [`Snapshot`].
232
+ */
233
+ snapshot(): string;
234
+ /**
235
+ * Throw a BPMN business error from a waiting job by key. If the job's
236
+ * activity has a matching error boundary/event-subprocess catch it is
237
+ * interrupted and the error-handling path runs; otherwise an incident is
238
+ * raised. The job is activated first if needed, so the UI can throw an
239
+ * error directly from a freshly-created job. Returns the snapshot.
240
+ */
241
+ throwError(job_key: string, error_code: string, error_message: string): string;
242
+ /**
243
+ * Set the engine clock to a wall-clock instant (ms), then trigger due timers
244
+ * and expire lapsed job locks. The embedded host calls this with `Date.now()`
245
+ * so `engine-core` stays clock-free while running as a real runtime. The
246
+ * clock never moves backwards. Returns the snapshot.
247
+ */
248
+ tickNow(now_ms: number): string;
249
+ /**
250
+ * Clear a user task's assignee. The task must be in the `Created` state.
251
+ * Returns the snapshot.
252
+ */
253
+ unassignUserTask(user_task_key: string): string;
254
+ /**
255
+ * Set a job's remaining retries by key. Used to recover a job parked on a
256
+ * no-retries incident before resolving that incident; does not by itself
257
+ * unblock the job. Returns the snapshot.
258
+ */
259
+ updateRetries(job_key: string, retries: number): string;
260
+ /**
261
+ * Update a user task's attributes from a JSON changeset object. Recognised
262
+ * keys (all optional): `candidateGroups` / `candidateUsers` (string arrays),
263
+ * `dueDate` / `followUpDate` (ISO-8601 string, or `null`/`""` to clear),
264
+ * `priority` (0..=100). Only present keys are changed. The task must be in
265
+ * the `Created` state. Returns the snapshot.
266
+ */
267
+ updateUserTask(user_task_key: string, changeset_json: string): string;
268
+ /**
269
+ * Whether a debug run is currently paused at a breakpoint.
270
+ */
271
+ readonly debugIsPaused: boolean;
272
+ /**
273
+ * The current virtual clock (milliseconds).
274
+ */
275
+ readonly now: number;
276
+ }
277
+
278
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
279
+
280
+ export interface InitOutput {
281
+ readonly memory: WebAssembly.Memory;
282
+ readonly __wbg_testengine_free: (a: number, b: number) => void;
283
+ readonly testengine_activateJobs: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
284
+ readonly testengine_advanceTime: (a: number, b: number, c: number) => void;
285
+ readonly testengine_assignUserTask: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
286
+ readonly testengine_broadcastSignal: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
287
+ readonly testengine_cancelInstance: (a: number, b: number, c: number, d: number) => void;
288
+ readonly testengine_completeAgentJob: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
289
+ readonly testengine_completeJob: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
290
+ readonly testengine_completeUserTask: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
291
+ readonly testengine_correlateMessage: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
292
+ readonly testengine_createInstance: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
293
+ readonly testengine_debugClear: (a: number) => void;
294
+ readonly testengine_debugCreateInstance: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
295
+ readonly testengine_debugIsPaused: (a: number) => number;
296
+ readonly testengine_debugResume: (a: number, b: number) => void;
297
+ readonly testengine_debugStep: (a: number, b: number) => void;
298
+ readonly testengine_deploy: (a: number, b: number, c: number, d: number) => void;
299
+ readonly testengine_events: (a: number, b: number) => void;
300
+ readonly testengine_failJob: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
301
+ readonly testengine_getFormByKey: (a: number, b: number, c: number, d: number) => void;
302
+ readonly testengine_getResourceByKey: (a: number, b: number, c: number, d: number) => void;
303
+ readonly testengine_migrate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
304
+ readonly testengine_modify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
305
+ readonly testengine_new: () => number;
306
+ readonly testengine_now: (a: number) => number;
307
+ readonly testengine_reset: (a: number) => void;
308
+ readonly testengine_resolveIncident: (a: number, b: number, c: number, d: number) => void;
309
+ readonly testengine_searchProcessInstances: (a: number, b: number, c: number, d: number) => void;
310
+ readonly testengine_searchUserTasks: (a: number, b: number, c: number, d: number) => void;
311
+ readonly testengine_searchVariables: (a: number, b: number, c: number, d: number) => void;
312
+ readonly testengine_setVariables: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
313
+ readonly testengine_snapshot: (a: number, b: number) => void;
314
+ readonly testengine_throwError: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
315
+ readonly testengine_tickNow: (a: number, b: number, c: number) => void;
316
+ readonly testengine_unassignUserTask: (a: number, b: number, c: number, d: number) => void;
317
+ readonly testengine_updateRetries: (a: number, b: number, c: number, d: number, e: number) => void;
318
+ readonly testengine_updateUserTask: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
319
+ readonly sqlite3_os_init: () => number;
320
+ readonly sqlite3_os_end: () => number;
321
+ readonly rust_sqlite_wasm_localtime: (a: number) => number;
322
+ readonly rust_sqlite_wasm_malloc: (a: number) => number;
323
+ readonly rust_sqlite_wasm_free: (a: number) => void;
324
+ readonly rust_sqlite_wasm_realloc: (a: number, b: number) => number;
325
+ readonly rust_sqlite_wasm_abort: () => void;
326
+ readonly rust_sqlite_wasm_assert_fail: (a: number, b: number, c: number, d: number) => void;
327
+ readonly rust_sqlite_wasm_calloc: (a: number, b: number) => number;
328
+ readonly rust_sqlite_wasm_getentropy: (a: number, b: number) => number;
329
+ readonly __wbindgen_export: (a: number) => void;
330
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
331
+ readonly __wbindgen_export2: (a: number, b: number) => number;
332
+ readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
333
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
334
+ }
335
+
336
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
337
+
338
+ /**
339
+ * Instantiates the given `module`, which can either be bytes or
340
+ * a precompiled `WebAssembly.Module`.
341
+ *
342
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
343
+ *
344
+ * @returns {InitOutput}
345
+ */
346
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
347
+
348
+ /**
349
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
350
+ * for everything else, calls `WebAssembly.instantiate` directly.
351
+ *
352
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
353
+ *
354
+ * @returns {Promise<InitOutput>}
355
+ */
356
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;