Implement native BPMN workflows and guided modes
This commit is contained in:
+189
-2
@@ -6,6 +6,7 @@ import {
|
||||
} from "@govoplan/core-webui";
|
||||
import type {
|
||||
DefinitionGraph,
|
||||
DefinitionGraphEdge,
|
||||
DefinitionGraphNode,
|
||||
DefinitionGraphNodeType
|
||||
} from "@govoplan/core-webui/definition-graph";
|
||||
@@ -13,10 +14,39 @@ import type {
|
||||
export type WorkflowStatus = "draft" | "active" | "archived";
|
||||
export type DefinitionScopeType = "system" | "tenant" | "group" | "user";
|
||||
export type DefinitionKind = "flow" | "template";
|
||||
export type WorkflowGraphNode = DefinitionGraphNode;
|
||||
export type WorkflowGraph = DefinitionGraph & {
|
||||
export type WorkflowExecutionMode = "guided" | "automated" | "hybrid";
|
||||
export type WorkflowStartOrigin =
|
||||
| "user"
|
||||
| "api"
|
||||
| "schedule"
|
||||
| "event"
|
||||
| "parent_workflow"
|
||||
| "dependency"
|
||||
| "retry"
|
||||
| "replay"
|
||||
| "backfill";
|
||||
export type WorkflowGraphNode = DefinitionGraphNode & {
|
||||
size?: { width: number; height: number } | null;
|
||||
parent_id?: string | null;
|
||||
process_id?: string | null;
|
||||
};
|
||||
export type WorkflowGraphEdge = DefinitionGraphEdge & {
|
||||
type:
|
||||
| "bpmn.sequenceFlow"
|
||||
| "bpmn.messageFlow"
|
||||
| "bpmn.association"
|
||||
| "bpmn.dataInputAssociation"
|
||||
| "bpmn.dataOutputAssociation"
|
||||
| "bpmn.conversationLink";
|
||||
label: string;
|
||||
config: Record<string, unknown>;
|
||||
waypoints: Array<{ x: number; y: number }>;
|
||||
};
|
||||
export type WorkflowGraph = Omit<DefinitionGraph, "nodes" | "edges"> & {
|
||||
schema_version: 1;
|
||||
nodes: WorkflowGraphNode[];
|
||||
edges: WorkflowGraphEdge[];
|
||||
metadata: Record<string, unknown>;
|
||||
};
|
||||
|
||||
export type WorkflowDiagnostic = {
|
||||
@@ -29,6 +59,71 @@ export type WorkflowDiagnostic = {
|
||||
|
||||
export type WorkflowNodeType = DefinitionGraphNodeType;
|
||||
|
||||
export type BpmnRuntimeKind = "model_only" | "native_graph" | "external";
|
||||
|
||||
export type BpmnDiagnostic = {
|
||||
severity: "error" | "warning" | "info";
|
||||
code: string;
|
||||
message: string;
|
||||
element_id?: string | null;
|
||||
};
|
||||
|
||||
export type BpmnAdapterProfile = {
|
||||
id: string;
|
||||
version: string;
|
||||
label: string;
|
||||
description: string;
|
||||
conformance: string;
|
||||
runtime_kind: BpmnRuntimeKind;
|
||||
executable: boolean;
|
||||
supported_elements: string[];
|
||||
supported_event_definitions: string[];
|
||||
requirements: string[];
|
||||
};
|
||||
|
||||
export type BpmnInspection = {
|
||||
valid_xml: boolean;
|
||||
definitions_id?: string | null;
|
||||
target_namespace?: string | null;
|
||||
process_count: number;
|
||||
executable_process_count: number;
|
||||
collaboration_count: number;
|
||||
choreography_count: number;
|
||||
element_counts: Record<string, number>;
|
||||
support_counts: Record<string, number>;
|
||||
elements: Array<{
|
||||
element_type: string;
|
||||
element_id?: string | null;
|
||||
name?: string | null;
|
||||
parent_type?: string | null;
|
||||
parent_id?: string | null;
|
||||
support_level: "interchange_only" | "native_mapping" | "native_execution";
|
||||
}>;
|
||||
diagnostics: BpmnDiagnostic[];
|
||||
adapter_id?: string | null;
|
||||
adapter_version?: string | null;
|
||||
runtime_kind?: BpmnRuntimeKind | null;
|
||||
executable: boolean;
|
||||
activatable: boolean;
|
||||
};
|
||||
|
||||
export type BpmnRevisionSummary = {
|
||||
format: "bpmn-2.0";
|
||||
content_hash: string;
|
||||
adapter_id: string;
|
||||
adapter_version: string;
|
||||
runtime_kind: BpmnRuntimeKind;
|
||||
executable: boolean;
|
||||
adapter_available: boolean;
|
||||
};
|
||||
|
||||
export type BpmnRevisionDocument = BpmnRevisionSummary & {
|
||||
definition_id: string;
|
||||
revision: number;
|
||||
xml: string;
|
||||
inspection: BpmnInspection;
|
||||
};
|
||||
|
||||
export type WorkflowRevision = {
|
||||
id: string;
|
||||
revision: number;
|
||||
@@ -37,6 +132,10 @@ export type WorkflowRevision = {
|
||||
content_hash: string;
|
||||
library_id: string;
|
||||
library_version: string;
|
||||
execution_mode: WorkflowExecutionMode;
|
||||
view_id?: string | null;
|
||||
view_revision_id?: string | null;
|
||||
bpmn?: BpmnRevisionSummary | null;
|
||||
created_by?: string | null;
|
||||
created_at: string;
|
||||
};
|
||||
@@ -134,6 +233,15 @@ export type WorkflowInstance = {
|
||||
definition_name: string;
|
||||
definition_revision: number;
|
||||
definition_hash: string;
|
||||
execution_mode: WorkflowExecutionMode;
|
||||
start_origin: WorkflowStartOrigin;
|
||||
view_context?: {
|
||||
view_id: string;
|
||||
revision_id?: string | null;
|
||||
visible_surface_ids: string[];
|
||||
step_id?: string | null;
|
||||
node_id?: string | null;
|
||||
} | null;
|
||||
status: WorkflowInstanceStatus;
|
||||
idempotency_key: string;
|
||||
correlation_id?: string | null;
|
||||
@@ -157,6 +265,11 @@ export type WorkflowDefinitionPayload = {
|
||||
name: string;
|
||||
description?: string | null;
|
||||
graph: WorkflowGraph;
|
||||
bpmn?: {
|
||||
xml: string;
|
||||
adapter_id: string;
|
||||
adapter_version?: string | null;
|
||||
} | null;
|
||||
metadata: Record<string, unknown>;
|
||||
scope_type: DefinitionScopeType;
|
||||
scope_id?: string | null;
|
||||
@@ -165,8 +278,68 @@ export type WorkflowDefinitionPayload = {
|
||||
allow_start: boolean;
|
||||
allow_reuse: boolean;
|
||||
allow_automation: boolean;
|
||||
execution_mode: WorkflowExecutionMode;
|
||||
view_id?: string | null;
|
||||
view_revision_id?: string | null;
|
||||
};
|
||||
|
||||
export async function getBpmnSupportProfile(
|
||||
settings: ApiSettings
|
||||
): Promise<{
|
||||
specification: string;
|
||||
model_namespace: string;
|
||||
interchange: string;
|
||||
native_runtime: string;
|
||||
native_execution_elements: string[];
|
||||
native_mapping_elements: string[];
|
||||
adapters: BpmnAdapterProfile[];
|
||||
}> {
|
||||
return apiFetch(settings, "/api/v1/workflow/bpmn/profile");
|
||||
}
|
||||
|
||||
export function inspectWorkflowBpmn(
|
||||
settings: ApiSettings,
|
||||
payload: {
|
||||
xml: string;
|
||||
adapter_id: string;
|
||||
adapter_version?: string | null;
|
||||
activation?: boolean;
|
||||
}
|
||||
): Promise<BpmnInspection> {
|
||||
return apiFetch(settings, "/api/v1/workflow/bpmn/inspect", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
}
|
||||
|
||||
export function compileWorkflowBpmn(
|
||||
settings: ApiSettings,
|
||||
payload: {
|
||||
xml: string;
|
||||
adapter_id: string;
|
||||
adapter_version?: string | null;
|
||||
}
|
||||
): Promise<{
|
||||
adapter: BpmnAdapterProfile;
|
||||
graph: WorkflowGraph;
|
||||
inspection: BpmnInspection;
|
||||
}> {
|
||||
return apiFetch(settings, "/api/v1/workflow/bpmn/compile", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
}
|
||||
|
||||
export function renderWorkflowBpmn(
|
||||
settings: ApiSettings,
|
||||
payload: { graph: WorkflowGraph; name?: string }
|
||||
): Promise<{ xml: string; inspection: BpmnInspection }> {
|
||||
return apiFetch(settings, "/api/v1/workflow/bpmn/render", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
}
|
||||
|
||||
export async function listWorkflowNodeTypes(
|
||||
settings: ApiSettings
|
||||
): Promise<{ id: string; version: string; allows_cycles: boolean; nodes: WorkflowNodeType[] }> {
|
||||
@@ -224,6 +397,9 @@ export function deriveWorkflowDefinition(
|
||||
allow_start: boolean;
|
||||
allow_reuse: boolean;
|
||||
allow_automation: boolean;
|
||||
execution_mode?: WorkflowExecutionMode | null;
|
||||
view_id?: string | null;
|
||||
view_revision_id?: string | null;
|
||||
}
|
||||
): Promise<WorkflowDefinition> {
|
||||
return apiFetch(
|
||||
@@ -244,6 +420,17 @@ export async function listWorkflowRevisions(
|
||||
return response.revisions;
|
||||
}
|
||||
|
||||
export function getWorkflowRevisionBpmn(
|
||||
settings: ApiSettings,
|
||||
definitionId: string,
|
||||
revision: number
|
||||
): Promise<BpmnRevisionDocument> {
|
||||
return apiFetch(
|
||||
settings,
|
||||
`/api/v1/workflow/definitions/${encodeURIComponent(definitionId)}/revisions/${revision}/bpmn`
|
||||
);
|
||||
}
|
||||
|
||||
export function activateWorkflowDefinition(
|
||||
settings: ApiSettings,
|
||||
definitionId: string,
|
||||
|
||||
Reference in New Issue
Block a user