@elqnt/workflow 2.1.1 → 2.1.3

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.
Files changed (2) hide show
  1. package/README.md +235 -0
  2. package/package.json +5 -5
package/README.md ADDED
@@ -0,0 +1,235 @@
1
+ # @elqnt/workflow
2
+
3
+ Workflow definitions and execution for Eloquent platform. Provides models, API functions, and React hooks for building and managing workflows.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @elqnt/workflow
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ### Using React Hooks
14
+
15
+ ```typescript
16
+ import { useWorkflows, useWorkflowInstances } from "@elqnt/workflow/hooks";
17
+
18
+ function WorkflowManager() {
19
+ const { listWorkflows, createWorkflow, loading, error } = useWorkflows({
20
+ baseUrl: process.env.NEXT_PUBLIC_API_GATEWAY_URL!,
21
+ orgId: currentOrgId,
22
+ });
23
+
24
+ const { createInstance, executeNode } = useWorkflowInstances({
25
+ baseUrl: process.env.NEXT_PUBLIC_API_GATEWAY_URL!,
26
+ orgId: currentOrgId,
27
+ });
28
+
29
+ // List all workflows
30
+ const workflows = await listWorkflows();
31
+
32
+ // Create a new workflow instance and execute
33
+ const instance = await createInstance(workflowId, {
34
+ variables: { customerId: "123" },
35
+ autoExecute: true,
36
+ });
37
+ }
38
+ ```
39
+
40
+ ### Using API Functions Directly
41
+
42
+ ```typescript
43
+ import {
44
+ listWorkflowsApi,
45
+ createWorkflowApi,
46
+ createWorkflowInstanceApi,
47
+ } from "@elqnt/workflow/api";
48
+
49
+ const response = await listWorkflowsApi({
50
+ baseUrl: "https://api.elqnt.ai",
51
+ orgId: "org-uuid",
52
+ });
53
+
54
+ if (response.data) {
55
+ console.log("Workflows:", response.data.definitions);
56
+ }
57
+ ```
58
+
59
+ ## Exports
60
+
61
+ | Import Path | Description |
62
+ |-------------|-------------|
63
+ | `@elqnt/workflow` | All exports |
64
+ | `@elqnt/workflow/api` | Browser API functions |
65
+ | `@elqnt/workflow/hooks` | React hooks |
66
+ | `@elqnt/workflow/models` | TypeScript types (generated from Go via tygo) |
67
+
68
+ ## API Reference
69
+
70
+ ### API Functions (`@elqnt/workflow/api`)
71
+
72
+ #### Workflow Definitions
73
+
74
+ | Function | Description |
75
+ |----------|-------------|
76
+ | `listWorkflowsApi(options)` | List all workflow definitions |
77
+ | `getWorkflowApi(workflowId, options)` | Get a specific workflow |
78
+ | `createWorkflowApi(workflow, options)` | Create a new workflow |
79
+ | `updateWorkflowApi(workflowId, workflow, options)` | Update a workflow |
80
+ | `deleteWorkflowApi(workflowId, options)` | Delete a workflow |
81
+
82
+ #### Workflow Instances
83
+
84
+ | Function | Description |
85
+ |----------|-------------|
86
+ | `createWorkflowInstanceApi(definitionId, data, options)` | Create and optionally start an instance |
87
+ | `getWorkflowInstanceApi(instanceId, options)` | Get instance details |
88
+ | `listWorkflowInstancesApi(definitionId, options)` | List instances for a workflow |
89
+ | `updateWorkflowInstanceStatusApi(instanceId, status, options)` | Update instance status |
90
+ | `executeWorkflowNodeApi(instanceId, nodeId, input, options)` | Execute a specific node |
91
+ | `resumeWorkflowNodeApi(instanceId, nodeId, result, options)` | Resume a waiting node |
92
+ | `retryWorkflowNodeApi(instanceId, nodeId, options)` | Retry a failed node |
93
+
94
+ #### Workflow Templates
95
+
96
+ | Function | Description |
97
+ |----------|-------------|
98
+ | `listWorkflowTemplatesApi(options)` | List available templates |
99
+ | `getWorkflowTemplateApi(templateId, options)` | Get template details |
100
+ | `instantiateWorkflowTemplateApi(templateId, params, options)` | Create workflow from template |
101
+
102
+ ### React Hooks (`@elqnt/workflow/hooks`)
103
+
104
+ #### `useWorkflows(options)`
105
+
106
+ Hook for workflow definition CRUD operations.
107
+
108
+ ```typescript
109
+ const {
110
+ loading, // boolean - operation in progress
111
+ error, // string | null - error message
112
+ listWorkflows, // () => Promise<WorkflowDefinition[]>
113
+ getWorkflow, // (id) => Promise<WorkflowDefinition | null>
114
+ createWorkflow, // (workflow) => Promise<WorkflowDefinition | null>
115
+ updateWorkflow, // (id, workflow) => Promise<WorkflowDefinition | null>
116
+ deleteWorkflow, // (id) => Promise<boolean>
117
+ } = useWorkflows({ baseUrl, orgId });
118
+ ```
119
+
120
+ #### `useWorkflowInstances(options)`
121
+
122
+ Hook for workflow instance operations.
123
+
124
+ ```typescript
125
+ const {
126
+ loading,
127
+ error,
128
+ listInstances, // (definitionId, filters?) => Promise<WorkflowInstance[]>
129
+ getInstance, // (instanceId) => Promise<WorkflowInstance | null>
130
+ createInstance, // (definitionId, data?) => Promise<WorkflowInstance | null>
131
+ updateStatus, // (instanceId, status) => Promise<WorkflowInstance | null>
132
+ executeNode, // (instanceId, nodeId, input) => Promise<object | null>
133
+ resumeNode, // (instanceId, nodeId, result) => Promise<WorkflowInstance | null>
134
+ retryNode, // (instanceId, nodeId) => Promise<WorkflowInstance | null>
135
+ } = useWorkflowInstances({ baseUrl, orgId });
136
+ ```
137
+
138
+ #### `useWorkflowTemplates(options)`
139
+
140
+ Hook for workflow template operations.
141
+
142
+ ```typescript
143
+ const {
144
+ loading,
145
+ error,
146
+ listTemplates, // (category?) => Promise<WorkflowTemplate[]>
147
+ getTemplate, // (templateId) => Promise<WorkflowTemplate | null>
148
+ instantiateTemplate, // (templateId, params) => Promise<WorkflowDefinition | null>
149
+ } = useWorkflowTemplates({ baseUrl, orgId });
150
+ ```
151
+
152
+ ## Types (`@elqnt/workflow/models`)
153
+
154
+ Key types generated from Go via tygo:
155
+
156
+ ```typescript
157
+ import type {
158
+ // Definitions
159
+ WorkflowDefinition,
160
+ WorkflowNode,
161
+ WorkflowEdge,
162
+ WorkflowVariables,
163
+ NodeDefinition,
164
+
165
+ // Instances
166
+ WorkflowInstance,
167
+ InstanceState,
168
+ NodeState,
169
+ ExecutionContext,
170
+
171
+ // Status enums
172
+ InstanceStatus,
173
+ NodeStatus,
174
+ EdgeStatus,
175
+
176
+ // Node types
177
+ NodeType,
178
+ NodeSubType,
179
+ EdgeType,
180
+ WorkflowType,
181
+ } from "@elqnt/workflow/models";
182
+ ```
183
+
184
+ ### Instance Status
185
+
186
+ ```typescript
187
+ const InstanceStatusNew: InstanceStatus = "NEW";
188
+ const InstanceStatusRunning: InstanceStatus = "RUNNING";
189
+ const InstanceStatusWaiting: InstanceStatus = "WAITING";
190
+ const InstanceStatusPaused: InstanceStatus = "PAUSED";
191
+ const InstanceStatusCompleted: InstanceStatus = "COMPLETED";
192
+ const InstanceStatusFailed: InstanceStatus = "FAILED";
193
+ ```
194
+
195
+ ### Node Types
196
+
197
+ ```typescript
198
+ const NodeTypeTrigger: NodeType = "trigger";
199
+ const NodeTypeHumanAction: NodeType = "humanAction";
200
+ const NodeTypeAgent: NodeType = "agent";
201
+ const NodeTypeAction: NodeType = "action";
202
+ const NodeTypeLogic: NodeType = "logic";
203
+ const NodeTypeLoop: NodeType = "loop";
204
+ const NodeTypeDelay: NodeType = "delay";
205
+ const NodeTypeData: NodeType = "data";
206
+ // ... and more
207
+ ```
208
+
209
+ ### Workflow Definition Structure
210
+
211
+ ```typescript
212
+ interface WorkflowDefinition {
213
+ id?: string;
214
+ name: string; // Normalized: lowercase, dashes
215
+ title: string; // Display name
216
+ description: string;
217
+ type: WorkflowType; // "entity", "chat", "document", etc.
218
+ nodes: { [key: string]: WorkflowNode };
219
+ edges: WorkflowEdge[];
220
+ entryPoints: string[]; // Start node IDs
221
+ variables: WorkflowVariables;
222
+ permissions: WorkflowPermissions;
223
+ metadata: WorkflowMetadata;
224
+ }
225
+ ```
226
+
227
+ ## Peer Dependencies
228
+
229
+ - `@reduxjs/toolkit` ^2.0.0
230
+ - `react` ^18.0.0 || ^19.0.0
231
+ - `react-redux` ^9.0.0
232
+
233
+ ## License
234
+
235
+ Private - Eloquent Platform
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elqnt/workflow",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Workflow definitions and execution for Eloquent platform - models, API, hooks, and store",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -36,9 +36,9 @@
36
36
  "directory": "packages/workflow"
37
37
  },
38
38
  "dependencies": {
39
- "@elqnt/entity": "2.1.1",
40
- "@elqnt/types": "2.0.9",
41
- "@elqnt/api-client": "1.0.3"
39
+ "@elqnt/entity": "2.2.0",
40
+ "@elqnt/types": "2.0.13",
41
+ "@elqnt/api-client": "1.0.4"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@reduxjs/toolkit": "^2.0.0",
@@ -52,7 +52,7 @@
52
52
  "react-redux": "^9.1.2",
53
53
  "tsup": "^8.0.0",
54
54
  "typescript": "^5.0.0",
55
- "@elqnt/api-client": "1.0.3"
55
+ "@elqnt/api-client": "1.0.4"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsup",