@rytass/bpm-core-shared 0.1.10 → 0.2.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,96 @@
1
+ import { FormDefinitionSchema, FormFieldDefinition, FormFieldOption } from './form';
2
+ import { ApproverResolver, ServiceAction, WorkflowDefinition, WorkflowEdge, WorkflowEdgeConditionOperator, WorkflowEdgeData, WorkflowNode, WorkflowNodeTriggerMode } from './workflow';
3
+ /**
4
+ * Pure, framework-agnostic structural operations over a {@link WorkflowDefinition}.
5
+ *
6
+ * This module is the canonical home for every transform that the template
7
+ * designer performs on the workflow graph. It intentionally contains **no**
8
+ * React, DOM, or layout (dagre) dependency so that both the frontend designer
9
+ * and the backend can share the exact same semantics, and so the LLM command
10
+ * layer ({@link ./workflow-command}) can be built on top of it.
11
+ *
12
+ * Pixel layout (dagre) and ReactFlow node/edge mapping stay in the React lib;
13
+ * the structures here only describe the logical graph.
14
+ */
15
+ /** Node types a user can add from the palette (start/end are implicit). */
16
+ export type NodePaletteType = 'exclusiveGateway' | 'serviceTask' | 'userTask';
17
+ export declare const WORKFLOW_INPUT_HANDLE_ID = "input";
18
+ export declare const WORKFLOW_OUTPUT_HANDLE_ID = "output";
19
+ export declare const WORKFLOW_NODE_TYPE_LABELS: Readonly<Record<WorkflowNode['type'], string>>;
20
+ export interface ConditionOperatorOption {
21
+ readonly id: WorkflowEdgeConditionOperator;
22
+ readonly name: string;
23
+ }
24
+ export declare const CONDITION_OPERATOR_OPTIONS: readonly ConditionOperatorOption[];
25
+ export declare const CONDITION_OPERATORS_REQUIRING_VALUE: readonly WorkflowEdgeConditionOperator[];
26
+ export interface WorkflowConnectionCandidate {
27
+ readonly source?: string | null;
28
+ readonly sourceHandle?: string | null;
29
+ readonly target?: string | null;
30
+ readonly targetHandle?: string | null;
31
+ }
32
+ /** Result of inserting a node, including the post-insert selection intent. */
33
+ export interface WorkflowNodeInsertResult {
34
+ readonly definition: WorkflowDefinition;
35
+ readonly editingEdgeId: string | null;
36
+ readonly selectedEdgeIds: readonly string[];
37
+ readonly selectedNodeId: string | null;
38
+ }
39
+ /**
40
+ * Factory used to mint workflow edge ids. Injectable so callers (e.g. tests or
41
+ * a deterministic reducer run) can supply stable ids; defaults to a
42
+ * time + random suffix to match the original designer behaviour.
43
+ */
44
+ export type WorkflowEdgeIdFactory = (source: string, target: string) => string;
45
+ export declare function defaultWorkflowEdgeId(source: string, target: string): string;
46
+ export declare function renameWorkflowNode(node: WorkflowNode, label: string): WorkflowNode;
47
+ export declare function applyWorkflowNodeTriggerMode(node: WorkflowNode, triggerMode: WorkflowNodeTriggerMode): WorkflowNode;
48
+ export declare function normalizeDesignerWorkflowDefinition(definition: WorkflowDefinition): WorkflowDefinition;
49
+ export declare function removeAsyncNotifyOutgoingEdges(definition: WorkflowDefinition): WorkflowDefinition;
50
+ export declare function normalizeSingleIncomingTriggerModes(definition: WorkflowDefinition): WorkflowDefinition;
51
+ export declare function createWorkflowNode(type: NodePaletteType, index: number): WorkflowNode;
52
+ export declare function readNextWorkflowNodeIndex(nodes: readonly WorkflowNode[], type: NodePaletteType): number;
53
+ export declare function createWorkflowEdge(source: string, target: string, data: WorkflowEdgeData, createId?: WorkflowEdgeIdFactory): WorkflowEdge;
54
+ export declare function readInsertedOutgoingEdgeData(node: WorkflowNode): WorkflowEdgeData;
55
+ export declare function insertWorkflowNodeIntoDefinition({ createId, definition, node, selectedEdgeId, selectedNodeId, }: {
56
+ readonly createId?: WorkflowEdgeIdFactory;
57
+ readonly definition: WorkflowDefinition;
58
+ readonly node: WorkflowNode;
59
+ readonly selectedEdgeId: string | null;
60
+ readonly selectedNodeId: string | null;
61
+ }): WorkflowNodeInsertResult;
62
+ export declare function insertWorkflowNodeAtEdge(definition: WorkflowDefinition, node: WorkflowNode, edge: WorkflowEdge, createId?: WorkflowEdgeIdFactory): WorkflowNodeInsertResult;
63
+ export declare function insertWorkflowNodeAfterNode(definition: WorkflowDefinition, node: WorkflowNode, sourceNode: WorkflowNode, createId?: WorkflowEdgeIdFactory): WorkflowNodeInsertResult;
64
+ export declare function readFallbackWorkflowDefinition(): WorkflowDefinition;
65
+ export declare function isEmptyDesignerWorkflowDefinition(definition: WorkflowDefinition): boolean;
66
+ export declare function isWorkflowConnectionValid(connection: WorkflowConnectionCandidate, nodes: readonly WorkflowNode[]): boolean;
67
+ export declare function isWorkflowNodeRemovable(node: WorkflowNode): boolean;
68
+ export declare function isWorkflowNodeInputConnectable(node: WorkflowNode): boolean;
69
+ export declare function isWorkflowNodeOutputConnectable(node: WorkflowNode): boolean;
70
+ export declare function isAsyncNotifyServiceTask(node: WorkflowNode): boolean;
71
+ export declare function isExclusiveGatewaySourceEdge(edge: WorkflowEdge, nodes: readonly WorkflowNode[]): boolean;
72
+ export declare function isParallelGatewaySourceEdge(edge: WorkflowEdge, nodes: readonly WorkflowNode[]): boolean;
73
+ export declare function toggleSelectedEdgeId(edgeIds: readonly string[], edgeId: string): readonly string[];
74
+ export declare function readWorkflowDefinitionIssue(definition: WorkflowDefinition): string | null;
75
+ export declare function readApproverResolverIssue(resolver: ApproverResolver): string | null;
76
+ export declare function hasConfiguredConditionEdges(definition: WorkflowDefinition): boolean;
77
+ export declare function readServiceTaskMemberIds(action: ServiceAction): readonly string[];
78
+ export declare function readConditionField(schema: FormDefinitionSchema | null, fieldKey: string | null): FormFieldDefinition | null;
79
+ export declare function readConditionOperator(value: string | null): WorkflowEdgeConditionOperator | null;
80
+ export declare function readConditionOperatorIds(field: FormFieldDefinition): readonly WorkflowEdgeConditionOperator[];
81
+ export interface ConditionValueOption {
82
+ readonly id: string;
83
+ readonly name: string;
84
+ }
85
+ export declare function readConditionValueOptions(field: FormFieldDefinition | null): readonly ConditionValueOption[];
86
+ export declare function readNextConditionOperator(field: FormFieldDefinition | null, operator: WorkflowEdgeConditionOperator | null): WorkflowEdgeConditionOperator | undefined;
87
+ export declare function readNextConditionValue(field: FormFieldDefinition | null, operator: WorkflowEdgeConditionOperator | undefined, value: string | null): string | undefined;
88
+ export declare function shouldConditionOperatorUseValue(operator: WorkflowEdgeConditionOperator): boolean;
89
+ export declare function readConditionLabel(field: FormFieldDefinition | null, operator: WorkflowEdgeConditionOperator | undefined, value: string | undefined): string | undefined;
90
+ export declare function readConditionOperatorLabel(operator: WorkflowEdgeConditionOperator): string;
91
+ export declare function readConditionValueLabel(field: FormFieldDefinition, value: string): string;
92
+ export declare function readFormFieldOption(options: readonly FormFieldOption[], value: string): FormFieldOption | null;
93
+ export declare function readConditionExpression(field: FormFieldDefinition | null, operator: WorkflowEdgeConditionOperator | undefined, value: string | undefined): string | undefined;
94
+ export declare function readFormFieldReference(fieldKey: string): string;
95
+ export declare function readConditionExpressionOperator(operator: WorkflowEdgeConditionOperator): string;
96
+ export declare function readConditionExpressionValue(field: FormFieldDefinition, value: string): string;