@nanobpm/engine-wasm 0.5.0 → 0.7.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.
package/README.md CHANGED
@@ -13,6 +13,7 @@ The package ships **two independent engines** from one install, selectable by
13
13
  | --- | --- | ---: | --- |
14
14
  | `@nanobpm/engine-wasm` | **lean** — primary state only | ~252 KB | demos, the modeler, debuggers, anything that reads via `snapshot()` / `events()` |
15
15
  | `@nanobpm/engine-wasm/readmodel` | **read-model** — lean surface **+** the gateway's C8-style REST read methods | ~561 KB | full-surface app testing in CI that wants gateway read parity |
16
+ | `@nanobpm/engine-wasm/readmodel-types` | **types only** — the DTOs the read-model `search*` / `get*ByKey` methods return | 0 KB (erased) | typing read-model query results in a consumer (e.g. `@nanobpm/bojtos-kit`) without hand-mirroring the shapes |
16
17
 
17
18
  ## Why two binaries (not a runtime toggle)
18
19
 
@@ -96,6 +97,27 @@ cleared by `reset()`.
96
97
  long values are truncated with `isTruncated: true`.
97
98
  Mirrors `POST /variables/search`.
98
99
 
100
+ ### Typing the results — `@nanobpm/engine-wasm/readmodel-types`
101
+
102
+ The methods above hand off opaque JSON strings (the wasm boundary is strings), so
103
+ the subpath `@nanobpm/engine-wasm/readmodel-types` ships the **DTO types** for
104
+ those results — `UserTaskSearchQueryResult`, `ProcessInstanceSearchQueryResult`,
105
+ `VariableSearchQueryResult`, `FormResult`, `ResourceResult` — so a consumer can
106
+ type them without hand-mirroring the shapes:
107
+
108
+ ```ts
109
+ import type { UserTaskSearchQueryResult } from "@nanobpm/engine-wasm/readmodel-types";
110
+
111
+ const open = JSON.parse(
112
+ engine.searchUserTasks(JSON.stringify({ state: "CREATED" })),
113
+ ) as UserTaskSearchQueryResult;
114
+ ```
115
+
116
+ These are **derived** from the single source of truth — the Camunda-parity REST
117
+ OpenAPI in `spec/` — by `engine-wasm/readmodel-types` (`@hey-api/openapi-ts`); a
118
+ CI drift guard regenerates and fails on any stale artifact. The subpath is
119
+ types-only (its runtime module is empty), so importing it adds zero wire weight.
120
+
99
121
  ## Choosing a subpath
100
122
 
101
123
  - **Reach for lean** for demos, the modeler, debuggers/adapters, and anything
@@ -135,6 +135,34 @@ export class TestEngine {
135
135
  * JS error carrying the parse/deploy failure message.
136
136
  */
137
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;
138
166
  /**
139
167
  * The full ordered event log emitted so far, as a JSON array of
140
168
  * `{ seq, now, type, ...payload }`. Useful for a step-through / trace view.
@@ -260,6 +288,8 @@ export interface InitOutput {
260
288
  readonly testengine_debugResume: (a: number, b: number) => void;
261
289
  readonly testengine_debugStep: (a: number, b: number) => void;
262
290
  readonly testengine_deploy: (a: number, b: number, c: number, d: number) => void;
291
+ readonly testengine_deployForm: (a: number, b: number, c: number, d: number) => void;
292
+ readonly testengine_deployResource: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
263
293
  readonly testengine_events: (a: number, b: number) => void;
264
294
  readonly testengine_failJob: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
265
295
  readonly testengine_migrate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
@@ -562,6 +562,91 @@ export class TestEngine {
562
562
  wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
563
563
  }
564
564
  }
565
+ /**
566
+ * Deploy a single `form-js` `.form` resource (the verbatim form-js JSON
567
+ * document). Mirrors the native deploy decomposition, which registers a
568
+ * `.form` resource as a [`Command::DeployForms`] (stored, not executed) so
569
+ * `getFormByKey` can serve its schema. The form-js document's `id` is the
570
+ * form identifier used for versioning/lookup — a body without a non-empty
571
+ * string `id` is a client error (native parity). The deploy resource name is
572
+ * derived as `<id>.form`.
573
+ *
574
+ * Returns a JSON object
575
+ * `{ "formKey": "...", "formId": "...", "version": N, "resourceName": "...", "snapshot": {...} }`
576
+ * on success, or throws a JS error carrying the parse/deploy failure message.
577
+ * @param {string} schema
578
+ * @returns {string}
579
+ */
580
+ deployForm(schema) {
581
+ let deferred3_0;
582
+ let deferred3_1;
583
+ try {
584
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
585
+ const ptr0 = passStringToWasm0(schema, wasm.__wbindgen_export, wasm.__wbindgen_export2);
586
+ const len0 = WASM_VECTOR_LEN;
587
+ wasm.testengine_deployForm(retptr, this.__wbg_ptr, ptr0, len0);
588
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
589
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
590
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
591
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
592
+ var ptr2 = r0;
593
+ var len2 = r1;
594
+ if (r3) {
595
+ ptr2 = 0; len2 = 0;
596
+ throw takeObject(r2);
597
+ }
598
+ deferred3_0 = ptr2;
599
+ deferred3_1 = len2;
600
+ return getStringFromWasm0(ptr2, len2);
601
+ } finally {
602
+ wasm.__wbindgen_add_to_stack_pointer(16);
603
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
604
+ }
605
+ }
606
+ /**
607
+ * Deploy a single generic resource (any deployed file that is not a
608
+ * BPMN/DMN/form — e.g. a Markdown agent prompt) under `resource_name` with
609
+ * the given verbatim `content`. Mirrors the native deploy decomposition,
610
+ * which registers such a file as a [`Command::DeployGenericResources`]
611
+ * (stored, not executed) so `getResourceByKey` can serve its content. The
612
+ * `resource_id` is the filename (`resource_name`), matching Zeebe's default
613
+ * resource transformer.
614
+ *
615
+ * Returns a JSON object
616
+ * `{ "resourceKey": "...", "resourceId": "...", "version": N, "resourceName": "...", "snapshot": {...} }`
617
+ * on success, or throws a JS error carrying the deploy failure message.
618
+ * @param {string} resource_name
619
+ * @param {string} content
620
+ * @returns {string}
621
+ */
622
+ deployResource(resource_name, content) {
623
+ let deferred4_0;
624
+ let deferred4_1;
625
+ try {
626
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
627
+ const ptr0 = passStringToWasm0(resource_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
628
+ const len0 = WASM_VECTOR_LEN;
629
+ const ptr1 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
630
+ const len1 = WASM_VECTOR_LEN;
631
+ wasm.testengine_deployResource(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
632
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
633
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
634
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
635
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
636
+ var ptr3 = r0;
637
+ var len3 = r1;
638
+ if (r3) {
639
+ ptr3 = 0; len3 = 0;
640
+ throw takeObject(r2);
641
+ }
642
+ deferred4_0 = ptr3;
643
+ deferred4_1 = len3;
644
+ return getStringFromWasm0(ptr3, len3);
645
+ } finally {
646
+ wasm.__wbindgen_add_to_stack_pointer(16);
647
+ wasm.__wbindgen_export3(deferred4_0, deferred4_1, 1);
648
+ }
649
+ }
565
650
  /**
566
651
  * The full ordered event log emitted so far, as a JSON array of
567
652
  * `{ seq, now, type, ...payload }`. Useful for a step-through / trace view.
Binary file
@@ -18,6 +18,8 @@ export const testengine_debugIsPaused: (a: number) => number;
18
18
  export const testengine_debugResume: (a: number, b: number) => void;
19
19
  export const testengine_debugStep: (a: number, b: number) => void;
20
20
  export const testengine_deploy: (a: number, b: number, c: number, d: number) => void;
21
+ export const testengine_deployForm: (a: number, b: number, c: number, d: number) => void;
22
+ export const testengine_deployResource: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
21
23
  export const testengine_events: (a: number, b: number) => void;
22
24
  export const testengine_failJob: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
23
25
  export const testengine_migrate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanobpm/engine-wasm",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "The nanobpmn engine (engine-core) compiled to WebAssembly for in-browser BPMN execution: deploy a diagram, start instances, activate/complete jobs, and read live snapshots/traces. Published as two subpath entrypoints — a lean baseline engine (default) and a read-model engine (the gateway's C8-style REST read surface). The substrate for the Bojtos demo framework (ADR 0043) and the console test-run panel.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -21,6 +21,10 @@
21
21
  "types": "./readmodel/nanobpmn_engine.d.ts",
22
22
  "default": "./readmodel/nanobpmn_engine.js"
23
23
  },
24
+ "./readmodel-types": {
25
+ "types": "./readmodel-types/index.d.ts",
26
+ "default": "./readmodel-types/index.js"
27
+ },
24
28
  "./lean/nanobpmn_engine_bg.wasm": "./lean/nanobpmn_engine_bg.wasm",
25
29
  "./readmodel/nanobpmn_engine_bg.wasm": "./readmodel/nanobpmn_engine_bg.wasm"
26
30
  },
@@ -33,6 +37,9 @@
33
37
  "readmodel/nanobpmn_engine.d.ts",
34
38
  "readmodel/nanobpmn_engine_bg.wasm",
35
39
  "readmodel/nanobpmn_engine_bg.wasm.d.ts",
40
+ "readmodel-types/index.js",
41
+ "readmodel-types/index.d.ts",
42
+ "readmodel-types/types.gen.d.ts",
36
43
  "README.md"
37
44
  ],
38
45
  "sideEffects": [
@@ -135,6 +135,34 @@ export class TestEngine {
135
135
  * JS error carrying the parse/deploy failure message.
136
136
  */
137
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;
138
166
  /**
139
167
  * The full ordered event log emitted so far, as a JSON array of
140
168
  * `{ seq, now, type, ...payload }`. Useful for a step-through / trace view.
@@ -296,6 +324,8 @@ export interface InitOutput {
296
324
  readonly testengine_debugResume: (a: number, b: number) => void;
297
325
  readonly testengine_debugStep: (a: number, b: number) => void;
298
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;
299
329
  readonly testengine_events: (a: number, b: number) => void;
300
330
  readonly testengine_failJob: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
301
331
  readonly testengine_getFormByKey: (a: number, b: number, c: number, d: number) => void;
@@ -562,6 +562,91 @@ export class TestEngine {
562
562
  wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
563
563
  }
564
564
  }
565
+ /**
566
+ * Deploy a single `form-js` `.form` resource (the verbatim form-js JSON
567
+ * document). Mirrors the native deploy decomposition, which registers a
568
+ * `.form` resource as a [`Command::DeployForms`] (stored, not executed) so
569
+ * `getFormByKey` can serve its schema. The form-js document's `id` is the
570
+ * form identifier used for versioning/lookup — a body without a non-empty
571
+ * string `id` is a client error (native parity). The deploy resource name is
572
+ * derived as `<id>.form`.
573
+ *
574
+ * Returns a JSON object
575
+ * `{ "formKey": "...", "formId": "...", "version": N, "resourceName": "...", "snapshot": {...} }`
576
+ * on success, or throws a JS error carrying the parse/deploy failure message.
577
+ * @param {string} schema
578
+ * @returns {string}
579
+ */
580
+ deployForm(schema) {
581
+ let deferred3_0;
582
+ let deferred3_1;
583
+ try {
584
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
585
+ const ptr0 = passStringToWasm0(schema, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
586
+ const len0 = WASM_VECTOR_LEN;
587
+ wasm.testengine_deployForm(retptr, this.__wbg_ptr, ptr0, len0);
588
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
589
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
590
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
591
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
592
+ var ptr2 = r0;
593
+ var len2 = r1;
594
+ if (r3) {
595
+ ptr2 = 0; len2 = 0;
596
+ throw takeObject(r2);
597
+ }
598
+ deferred3_0 = ptr2;
599
+ deferred3_1 = len2;
600
+ return getStringFromWasm0(ptr2, len2);
601
+ } finally {
602
+ wasm.__wbindgen_add_to_stack_pointer(16);
603
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
604
+ }
605
+ }
606
+ /**
607
+ * Deploy a single generic resource (any deployed file that is not a
608
+ * BPMN/DMN/form — e.g. a Markdown agent prompt) under `resource_name` with
609
+ * the given verbatim `content`. Mirrors the native deploy decomposition,
610
+ * which registers such a file as a [`Command::DeployGenericResources`]
611
+ * (stored, not executed) so `getResourceByKey` can serve its content. The
612
+ * `resource_id` is the filename (`resource_name`), matching Zeebe's default
613
+ * resource transformer.
614
+ *
615
+ * Returns a JSON object
616
+ * `{ "resourceKey": "...", "resourceId": "...", "version": N, "resourceName": "...", "snapshot": {...} }`
617
+ * on success, or throws a JS error carrying the deploy failure message.
618
+ * @param {string} resource_name
619
+ * @param {string} content
620
+ * @returns {string}
621
+ */
622
+ deployResource(resource_name, content) {
623
+ let deferred4_0;
624
+ let deferred4_1;
625
+ try {
626
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
627
+ const ptr0 = passStringToWasm0(resource_name, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
628
+ const len0 = WASM_VECTOR_LEN;
629
+ const ptr1 = passStringToWasm0(content, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
630
+ const len1 = WASM_VECTOR_LEN;
631
+ wasm.testengine_deployResource(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
632
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
633
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
634
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
635
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
636
+ var ptr3 = r0;
637
+ var len3 = r1;
638
+ if (r3) {
639
+ ptr3 = 0; len3 = 0;
640
+ throw takeObject(r2);
641
+ }
642
+ deferred4_0 = ptr3;
643
+ deferred4_1 = len3;
644
+ return getStringFromWasm0(ptr3, len3);
645
+ } finally {
646
+ wasm.__wbindgen_add_to_stack_pointer(16);
647
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
648
+ }
649
+ }
565
650
  /**
566
651
  * The full ordered event log emitted so far, as a JSON array of
567
652
  * `{ seq, now, type, ...payload }`. Useful for a step-through / trace view.
Binary file
@@ -18,6 +18,8 @@ export const testengine_debugIsPaused: (a: number) => number;
18
18
  export const testengine_debugResume: (a: number, b: number) => void;
19
19
  export const testengine_debugStep: (a: number, b: number) => void;
20
20
  export const testengine_deploy: (a: number, b: number, c: number, d: number) => void;
21
+ export const testengine_deployForm: (a: number, b: number, c: number, d: number) => void;
22
+ export const testengine_deployResource: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
21
23
  export const testengine_events: (a: number, b: number) => void;
22
24
  export const testengine_failJob: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
23
25
  export const testengine_getFormByKey: (a: number, b: number, c: number, d: number) => void;
@@ -0,0 +1,28 @@
1
+ // Public surface of `@nanobpm/engine-wasm/readmodel-types`: the derived DTO
2
+ // types for the read-model engine's query results, so browser consumers
3
+ // (@nanobpm/bojtos-kit → the web-demo-framework) can type
4
+ // `searchUserTasks` / `searchProcessInstances` / `searchVariables` /
5
+ // `getFormByKey` / `getResourceByKey` without hand-mirroring the shapes.
6
+ //
7
+ // These are re-exported from the generated `types.gen.d.ts`, which is derived
8
+ // from the single source of truth — the Camunda-parity REST OpenAPI in `spec/`
9
+ // — via `engine-wasm/readmodel-types` (`npm run gen`). Do not hand-edit; a
10
+ // stale artifact fails CI (`npm run check` = regen + `git diff --exit-code`).
11
+ export type {
12
+ // `searchUserTasks(filter): UserTaskSearchQueryResult`
13
+ UserTaskSearchQueryResult,
14
+ UserTaskResult,
15
+ // `searchProcessInstances(filter): ProcessInstanceSearchQueryResult`
16
+ ProcessInstanceSearchQueryResult,
17
+ ProcessInstanceResult,
18
+ // `searchVariables(filter): VariableSearchQueryResult`
19
+ VariableSearchQueryResult,
20
+ VariableResult,
21
+ // `getFormByKey(key): FormResult | null`
22
+ FormResult,
23
+ // `getResourceByKey(key): ResourceResult | null`
24
+ ResourceResult,
25
+ // Shared search envelope (`{ items, page }`) the *SearchQueryResult types extend.
26
+ SearchQueryResponse,
27
+ SearchQueryPageResponse,
28
+ } from "./types.gen.js";
@@ -0,0 +1,6 @@
1
+ // Runtime-empty: `@nanobpm/engine-wasm/readmodel-types` ships types only (the
2
+ // read-model DTOs are compile-time contracts; the actual JSON is minted by the
3
+ // wasm engine's `search*` / `get*ByKey` methods). This stub exists so the
4
+ // package subpath resolves under Node's `exports` map; all real declarations
5
+ // live in the sibling `index.d.ts` / `types.gen.d.ts`.
6
+ export {};