@nanobpm/bojtos-react 0.2.0 → 0.3.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/dist/index.d.ts +2 -2
- package/dist/useBojtos.d.ts +11 -2
- package/dist/useBojtos.js +2 -0
- package/package.json +2 -2
- package/src/index.ts +3 -0
- package/src/useBojtos.ts +17 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export { useBojtos, type UseBojtosOptions, type BojtosControls, type BojtosPhase
|
|
|
2
2
|
export { Bojtos, type BojtosProps, type TraceEvent } from "./Bojtos.js";
|
|
3
3
|
export { OrderFulfillmentDemo, ORDER_FULFILLMENT_BPMN, orderFulfillmentWorkers, } from "./examples/orderFulfillment.js";
|
|
4
4
|
export { BpmnRuntimeView, type BpmnRuntimeViewProps, } from "./BpmnRuntimeView.js";
|
|
5
|
-
export { JobFailure, type JobHandler, type JobResult, type DispatchOptions, type DispatchResult, type RoundResult, } from "@nanobpm/bojtos-kit";
|
|
6
|
-
export type { BojtosSession, Snapshot, InstanceDto, JobDto, ActivatedJob, IncidentDto, TimerDto, ActiveEl, WasmEvent, } from "@nanobpm/bojtos-kit";
|
|
5
|
+
export { JobFailure, type JobHandler, type JobResult, type AgentHandler, type DispatchOptions, type DispatchResult, type RoundResult, } from "@nanobpm/bojtos-kit";
|
|
6
|
+
export type { BojtosSession, Snapshot, InstanceDto, JobDto, ActivatedJob, IncidentDto, TimerDto, ActiveEl, AgentActivation, AgentResult, WasmEvent, } from "@nanobpm/bojtos-kit";
|
package/dist/useBojtos.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DispatchOptions, type JobHandler, type RoundResult, type Snapshot, type WasmEvent, type WasmSource } from "@nanobpm/bojtos-kit";
|
|
1
|
+
import { type AgentResult, type DispatchOptions, type JobHandler, type RoundResult, type Snapshot, type WasmEvent, type WasmSource } from "@nanobpm/bojtos-kit";
|
|
2
2
|
/** Lifecycle of the in-browser engine load. */
|
|
3
3
|
export type BojtosPhase = "loading" | "ready" | "error";
|
|
4
4
|
export interface UseBojtosOptions {
|
|
@@ -28,6 +28,13 @@ export interface BojtosControls {
|
|
|
28
28
|
createInstance(processId: string, variablesJson: string): Snapshot | null;
|
|
29
29
|
/** Complete a waiting job, merging output variables. */
|
|
30
30
|
completeJob(jobKey: string, variablesJson: string): Snapshot | null;
|
|
31
|
+
/**
|
|
32
|
+
* Complete an ad-hoc sub-process's **agent** job with an {@link AgentResult}
|
|
33
|
+
* (activate tools this turn / signal completion / merge variables). For the
|
|
34
|
+
* usual dispatch-loop case, register agents via `runWorkers`/`stepWorkers`
|
|
35
|
+
* `opts.agents` instead of calling this directly.
|
|
36
|
+
*/
|
|
37
|
+
completeAgentJob(jobKey: string, result: AgentResult): Snapshot | null;
|
|
31
38
|
/** Fail a waiting job (raises an incident with no retries left). */
|
|
32
39
|
failJob(jobKey: string, retries: number, message: string): Snapshot | null;
|
|
33
40
|
/**
|
|
@@ -42,7 +49,9 @@ export interface BojtosControls {
|
|
|
42
49
|
/**
|
|
43
50
|
* Run the registered worker handlers until the process settles (activate →
|
|
44
51
|
* handler → complete/fail), then reflect the resulting snapshot/events.
|
|
45
|
-
*
|
|
52
|
+
* Register ad-hoc **agent** handlers via `opts.agents` to drive
|
|
53
|
+
* `adHocSubProcess` tool activation in the same loop. Resolves to the settled
|
|
54
|
+
* snapshot, or null if there is no live session.
|
|
46
55
|
*/
|
|
47
56
|
runWorkers(workers: Record<string, JobHandler>, opts?: DispatchOptions): Promise<Snapshot | null>;
|
|
48
57
|
/**
|
package/dist/useBojtos.js
CHANGED
|
@@ -92,6 +92,7 @@ export function useBojtos({ bpmn, wasm }) {
|
|
|
92
92
|
}, []);
|
|
93
93
|
const createInstance = useCallback((processId, variablesJson) => run((s) => s.createInstance(processId, variablesJson)), [run]);
|
|
94
94
|
const completeJob = useCallback((jobKey, variablesJson) => run((s) => s.completeJob(jobKey, variablesJson)), [run]);
|
|
95
|
+
const completeAgentJob = useCallback((jobKey, result) => run((s) => s.completeAgentJob(jobKey, result)), [run]);
|
|
95
96
|
const failJob = useCallback((jobKey, retries, message) => run((s) => s.failJob(jobKey, retries, message)), [run]);
|
|
96
97
|
const advanceTime = useCallback((byMs) => run((s) => s.advanceTime(byMs)), [run]);
|
|
97
98
|
const correlateMessage = useCallback((messageName, correlationKey, variablesJson) => run((s) => s.correlateMessage(messageName, correlationKey, variablesJson)), [run]);
|
|
@@ -167,6 +168,7 @@ export function useBojtos({ bpmn, wasm }) {
|
|
|
167
168
|
events,
|
|
168
169
|
createInstance,
|
|
169
170
|
completeJob,
|
|
171
|
+
completeAgentJob,
|
|
170
172
|
failJob,
|
|
171
173
|
advanceTime,
|
|
172
174
|
correlateMessage,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nanobpm/bojtos-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "React binding for the Bojtos in-browser BPMN demo framework (ADR 0043): the useBojtos hook (owns the engine session + reactive snapshot/event state) and the <BpmnRuntimeView> live token/incident diagram. Built on @nanobpm/bojtos-kit; the console test-run panel is its first consumer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"prepack": "npm run build"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@nanobpm/bojtos-kit": "^0.
|
|
33
|
+
"@nanobpm/bojtos-kit": "^0.3.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"bpmn-js": ">=17",
|
package/src/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ export {
|
|
|
24
24
|
JobFailure,
|
|
25
25
|
type JobHandler,
|
|
26
26
|
type JobResult,
|
|
27
|
+
type AgentHandler,
|
|
27
28
|
type DispatchOptions,
|
|
28
29
|
type DispatchResult,
|
|
29
30
|
type RoundResult,
|
|
@@ -37,5 +38,7 @@ export type {
|
|
|
37
38
|
IncidentDto,
|
|
38
39
|
TimerDto,
|
|
39
40
|
ActiveEl,
|
|
41
|
+
AgentActivation,
|
|
42
|
+
AgentResult,
|
|
40
43
|
WasmEvent,
|
|
41
44
|
} from "@nanobpm/bojtos-kit";
|
package/src/useBojtos.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
import {
|
|
3
|
+
type AgentResult,
|
|
3
4
|
type BojtosSession,
|
|
4
5
|
createBojtosSession,
|
|
5
6
|
type DispatchOptions,
|
|
@@ -43,6 +44,13 @@ export interface BojtosControls {
|
|
|
43
44
|
createInstance(processId: string, variablesJson: string): Snapshot | null;
|
|
44
45
|
/** Complete a waiting job, merging output variables. */
|
|
45
46
|
completeJob(jobKey: string, variablesJson: string): Snapshot | null;
|
|
47
|
+
/**
|
|
48
|
+
* Complete an ad-hoc sub-process's **agent** job with an {@link AgentResult}
|
|
49
|
+
* (activate tools this turn / signal completion / merge variables). For the
|
|
50
|
+
* usual dispatch-loop case, register agents via `runWorkers`/`stepWorkers`
|
|
51
|
+
* `opts.agents` instead of calling this directly.
|
|
52
|
+
*/
|
|
53
|
+
completeAgentJob(jobKey: string, result: AgentResult): Snapshot | null;
|
|
46
54
|
/** Fail a waiting job (raises an incident with no retries left). */
|
|
47
55
|
failJob(jobKey: string, retries: number, message: string): Snapshot | null;
|
|
48
56
|
/**
|
|
@@ -61,7 +69,9 @@ export interface BojtosControls {
|
|
|
61
69
|
/**
|
|
62
70
|
* Run the registered worker handlers until the process settles (activate →
|
|
63
71
|
* handler → complete/fail), then reflect the resulting snapshot/events.
|
|
64
|
-
*
|
|
72
|
+
* Register ad-hoc **agent** handlers via `opts.agents` to drive
|
|
73
|
+
* `adHocSubProcess` tool activation in the same loop. Resolves to the settled
|
|
74
|
+
* snapshot, or null if there is no live session.
|
|
65
75
|
*/
|
|
66
76
|
runWorkers(
|
|
67
77
|
workers: Record<string, JobHandler>,
|
|
@@ -189,6 +199,11 @@ export function useBojtos({ bpmn, wasm }: UseBojtosOptions): BojtosControls {
|
|
|
189
199
|
run((s) => s.completeJob(jobKey, variablesJson)),
|
|
190
200
|
[run],
|
|
191
201
|
);
|
|
202
|
+
const completeAgentJob = useCallback(
|
|
203
|
+
(jobKey: string, result: AgentResult) =>
|
|
204
|
+
run((s) => s.completeAgentJob(jobKey, result)),
|
|
205
|
+
[run],
|
|
206
|
+
);
|
|
192
207
|
const failJob = useCallback(
|
|
193
208
|
(jobKey: string, retries: number, message: string) =>
|
|
194
209
|
run((s) => s.failJob(jobKey, retries, message)),
|
|
@@ -285,6 +300,7 @@ export function useBojtos({ bpmn, wasm }: UseBojtosOptions): BojtosControls {
|
|
|
285
300
|
events,
|
|
286
301
|
createInstance,
|
|
287
302
|
completeJob,
|
|
303
|
+
completeAgentJob,
|
|
288
304
|
failJob,
|
|
289
305
|
advanceTime,
|
|
290
306
|
correlateMessage,
|