@nanobpm/engine-wasm 0.4.0 → 0.6.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,386 @@
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
+ * Deploy a single `form-js` `.form` resource (the verbatim form-js JSON
140
+ * document). Mirrors the native deploy decomposition, which registers a
141
+ * `.form` resource as a [`Command::DeployForms`] (stored, not executed) so
142
+ * `getFormByKey` can serve its schema. The form-js document's `id` is the
143
+ * form identifier used for versioning/lookup — a body without a non-empty
144
+ * string `id` is a client error (native parity). The deploy resource name is
145
+ * derived as `<id>.form`.
146
+ *
147
+ * Returns a JSON object
148
+ * `{ "formKey": "...", "formId": "...", "version": N, "resourceName": "...", "snapshot": {...} }`
149
+ * on success, or throws a JS error carrying the parse/deploy failure message.
150
+ */
151
+ deployForm(schema: string): string;
152
+ /**
153
+ * Deploy a single generic resource (any deployed file that is not a
154
+ * BPMN/DMN/form — e.g. a Markdown agent prompt) under `resource_name` with
155
+ * the given verbatim `content`. Mirrors the native deploy decomposition,
156
+ * which registers such a file as a [`Command::DeployGenericResources`]
157
+ * (stored, not executed) so `getResourceByKey` can serve its content. The
158
+ * `resource_id` is the filename (`resource_name`), matching Zeebe's default
159
+ * resource transformer.
160
+ *
161
+ * Returns a JSON object
162
+ * `{ "resourceKey": "...", "resourceId": "...", "version": N, "resourceName": "...", "snapshot": {...} }`
163
+ * on success, or throws a JS error carrying the deploy failure message.
164
+ */
165
+ deployResource(resource_name: string, content: string): string;
166
+ /**
167
+ * The full ordered event log emitted so far, as a JSON array of
168
+ * `{ seq, now, type, ...payload }`. Useful for a step-through / trace view.
169
+ */
170
+ events(): string;
171
+ /**
172
+ * Fail a waiting job by key with the given remaining `retries` and message.
173
+ * With no retries left this raises an incident (visible in the snapshot).
174
+ */
175
+ failJob(job_key: string, retries: number, message: string): string;
176
+ /**
177
+ * The latest deployed form for `form_key`, as a `FormResult` JSON object
178
+ * (`{ tenantId, formId, schema, version, formKey }`), or JSON `null` when no
179
+ * form with that key exists. Mirrors `GET /forms/{formKey}`.
180
+ */
181
+ getFormByKey(form_key: string): string;
182
+ /**
183
+ * The generic resource for `resource_key`, as a `ResourceResult` JSON object,
184
+ * or JSON `null` when no resource with that key exists. Mirrors
185
+ * `GET /resources/{resourceKey}`.
186
+ */
187
+ getResourceByKey(resource_key: string): string;
188
+ /**
189
+ * Migrate a running process instance to a target process definition (Zeebe
190
+ * "migrate process instance"): re-point every active element instance at the
191
+ * mapped element of `target_process_definition_key` and re-home the instance.
192
+ * `mapping_instructions_json` is a JSON array of
193
+ * `{ sourceElementId: string, targetElementId: string }`. Returns the
194
+ * snapshot.
195
+ */
196
+ migrate(instance_key: string, target_process_definition_key: string, mapping_instructions_json: string): string;
197
+ /**
198
+ * Modify a running process instance (Zeebe "modify process instance"): move
199
+ * tokens by terminating existing element instances and/or activating new
200
+ * ones. `activate_instructions_json` is a JSON array of
201
+ * `{ elementId: string, variables?: object }` (variables are merged into the
202
+ * instance's root scope before the token is placed);
203
+ * `terminate_instructions_json` is a JSON array of element-instance keys,
204
+ * each a decimal string or a `{ elementInstanceKey: string }` object.
205
+ * Activations run at the process root scope. Returns the snapshot.
206
+ */
207
+ modify(instance_key: string, activate_instructions_json: string, terminate_instructions_json: string): string;
208
+ /**
209
+ * Create a fresh, empty simulated engine. The virtual clock starts at 0.
210
+ */
211
+ constructor();
212
+ /**
213
+ * Discard all engine state (deployed definitions, instances, jobs, timers,
214
+ * the event log and the virtual clock), returning the engine to the same
215
+ * pristine state as a freshly constructed one. Callers redeploy afterwards
216
+ * to start a clean run — this is what makes a re-run start from zero
217
+ * completed instances rather than accumulating across runs.
218
+ */
219
+ reset(): void;
220
+ /**
221
+ * Resolve an open incident by key, retrying the work that failed (a job
222
+ * incident returns the parked job — which must have retries left — to the
223
+ * activatable pool; a gateway incident re-evaluates; an uncaught-error
224
+ * incident re-creates the service-task job). Returns the snapshot.
225
+ */
226
+ resolveIncident(incident_key: string): string;
227
+ /**
228
+ * All process instances, as a `ProcessInstanceSearchQueryResult` JSON object
229
+ * (`{ items: [...], page: {...} }`). The request body is shape-validated like
230
+ * `POST /process-instances/search`, but filter/sort/page fields are not yet
231
+ * honoured — every instance is returned. Do not rely on gateway-side
232
+ * filtering through this method yet.
233
+ */
234
+ searchProcessInstances(filter_json: string): string;
235
+ /**
236
+ * The user tasks matching an optional `{ state? }` filter, as a
237
+ * `UserTaskSearchQueryResult` JSON object (`{ items: [...], page: {...} }`).
238
+ * The `state` filter (e.g. `"CREATED"`) is honoured through the read model,
239
+ * not hardcoded. Mirrors `POST /user-tasks/search`.
240
+ */
241
+ searchUserTasks(filter_json: string): string;
242
+ /**
243
+ * All variables, as a `VariableSearchQueryResult` JSON object
244
+ * (`{ items: [...], page: {...} }`). The request body is shape-validated like
245
+ * `POST /variables/search`, but filter/sort/page fields are not yet honoured —
246
+ * every variable is returned. Values longer than `VARIABLE_VALUE_PREVIEW_LEN`
247
+ * are truncated with `isTruncated: true`; shorter values pass through intact
248
+ * with `isTruncated: false`. There is no `truncateValues` opt-out yet.
249
+ */
250
+ searchVariables(filter_json: string): string;
251
+ /**
252
+ * Merge variables into a scope (a process-instance key or an element-instance
253
+ * key). When `local` is true the values are written strictly into the target
254
+ * scope; otherwise they propagate upward to the nearest ancestor scope that
255
+ * defines each name (Zeebe `SetVariables` semantics). Returns the snapshot.
256
+ */
257
+ setVariables(scope_key: string, variables_json: string, local: boolean): string;
258
+ /**
259
+ * The current simulation state as a JSON [`Snapshot`].
260
+ */
261
+ snapshot(): string;
262
+ /**
263
+ * Throw a BPMN business error from a waiting job by key. If the job's
264
+ * activity has a matching error boundary/event-subprocess catch it is
265
+ * interrupted and the error-handling path runs; otherwise an incident is
266
+ * raised. The job is activated first if needed, so the UI can throw an
267
+ * error directly from a freshly-created job. Returns the snapshot.
268
+ */
269
+ throwError(job_key: string, error_code: string, error_message: string): string;
270
+ /**
271
+ * Set the engine clock to a wall-clock instant (ms), then trigger due timers
272
+ * and expire lapsed job locks. The embedded host calls this with `Date.now()`
273
+ * so `engine-core` stays clock-free while running as a real runtime. The
274
+ * clock never moves backwards. Returns the snapshot.
275
+ */
276
+ tickNow(now_ms: number): string;
277
+ /**
278
+ * Clear a user task's assignee. The task must be in the `Created` state.
279
+ * Returns the snapshot.
280
+ */
281
+ unassignUserTask(user_task_key: string): string;
282
+ /**
283
+ * Set a job's remaining retries by key. Used to recover a job parked on a
284
+ * no-retries incident before resolving that incident; does not by itself
285
+ * unblock the job. Returns the snapshot.
286
+ */
287
+ updateRetries(job_key: string, retries: number): string;
288
+ /**
289
+ * Update a user task's attributes from a JSON changeset object. Recognised
290
+ * keys (all optional): `candidateGroups` / `candidateUsers` (string arrays),
291
+ * `dueDate` / `followUpDate` (ISO-8601 string, or `null`/`""` to clear),
292
+ * `priority` (0..=100). Only present keys are changed. The task must be in
293
+ * the `Created` state. Returns the snapshot.
294
+ */
295
+ updateUserTask(user_task_key: string, changeset_json: string): string;
296
+ /**
297
+ * Whether a debug run is currently paused at a breakpoint.
298
+ */
299
+ readonly debugIsPaused: boolean;
300
+ /**
301
+ * The current virtual clock (milliseconds).
302
+ */
303
+ readonly now: number;
304
+ }
305
+
306
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
307
+
308
+ export interface InitOutput {
309
+ readonly memory: WebAssembly.Memory;
310
+ readonly __wbg_testengine_free: (a: number, b: number) => void;
311
+ readonly testengine_activateJobs: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
312
+ readonly testengine_advanceTime: (a: number, b: number, c: number) => void;
313
+ readonly testengine_assignUserTask: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
314
+ readonly testengine_broadcastSignal: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
315
+ readonly testengine_cancelInstance: (a: number, b: number, c: number, d: number) => void;
316
+ readonly testengine_completeAgentJob: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
317
+ readonly testengine_completeJob: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
318
+ readonly testengine_completeUserTask: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
319
+ readonly testengine_correlateMessage: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
320
+ readonly testengine_createInstance: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
321
+ readonly testengine_debugClear: (a: number) => void;
322
+ readonly testengine_debugCreateInstance: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
323
+ readonly testengine_debugIsPaused: (a: number) => number;
324
+ readonly testengine_debugResume: (a: number, b: number) => void;
325
+ readonly testengine_debugStep: (a: number, b: number) => void;
326
+ readonly testengine_deploy: (a: number, b: number, c: number, d: number) => void;
327
+ readonly testengine_deployForm: (a: number, b: number, c: number, d: number) => void;
328
+ readonly testengine_deployResource: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
329
+ readonly testengine_events: (a: number, b: number) => void;
330
+ readonly testengine_failJob: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
331
+ readonly testengine_getFormByKey: (a: number, b: number, c: number, d: number) => void;
332
+ readonly testengine_getResourceByKey: (a: number, b: number, c: number, d: number) => void;
333
+ readonly testengine_migrate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
334
+ readonly testengine_modify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
335
+ readonly testengine_new: () => number;
336
+ readonly testengine_now: (a: number) => number;
337
+ readonly testengine_reset: (a: number) => void;
338
+ readonly testengine_resolveIncident: (a: number, b: number, c: number, d: number) => void;
339
+ readonly testengine_searchProcessInstances: (a: number, b: number, c: number, d: number) => void;
340
+ readonly testengine_searchUserTasks: (a: number, b: number, c: number, d: number) => void;
341
+ readonly testengine_searchVariables: (a: number, b: number, c: number, d: number) => void;
342
+ readonly testengine_setVariables: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
343
+ readonly testengine_snapshot: (a: number, b: number) => void;
344
+ readonly testengine_throwError: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
345
+ readonly testengine_tickNow: (a: number, b: number, c: number) => void;
346
+ readonly testengine_unassignUserTask: (a: number, b: number, c: number, d: number) => void;
347
+ readonly testengine_updateRetries: (a: number, b: number, c: number, d: number, e: number) => void;
348
+ readonly testengine_updateUserTask: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
349
+ readonly sqlite3_os_init: () => number;
350
+ readonly sqlite3_os_end: () => number;
351
+ readonly rust_sqlite_wasm_localtime: (a: number) => number;
352
+ readonly rust_sqlite_wasm_malloc: (a: number) => number;
353
+ readonly rust_sqlite_wasm_free: (a: number) => void;
354
+ readonly rust_sqlite_wasm_realloc: (a: number, b: number) => number;
355
+ readonly rust_sqlite_wasm_abort: () => void;
356
+ readonly rust_sqlite_wasm_assert_fail: (a: number, b: number, c: number, d: number) => void;
357
+ readonly rust_sqlite_wasm_calloc: (a: number, b: number) => number;
358
+ readonly rust_sqlite_wasm_getentropy: (a: number, b: number) => number;
359
+ readonly __wbindgen_export: (a: number) => void;
360
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
361
+ readonly __wbindgen_export2: (a: number, b: number) => number;
362
+ readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
363
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
364
+ }
365
+
366
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
367
+
368
+ /**
369
+ * Instantiates the given `module`, which can either be bytes or
370
+ * a precompiled `WebAssembly.Module`.
371
+ *
372
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
373
+ *
374
+ * @returns {InitOutput}
375
+ */
376
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
377
+
378
+ /**
379
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
380
+ * for everything else, calls `WebAssembly.instantiate` directly.
381
+ *
382
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
383
+ *
384
+ * @returns {Promise<InitOutput>}
385
+ */
386
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;