@runtypelabs/react-flow 0.1.2 → 0.1.4
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +16 -0
- package/dist/index.js +5 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -13
- package/dist/index.mjs.map +1 -1
- package/example/CHANGELOG.md +10 -0
- package/example/package.json +1 -2
- package/example/src/App.tsx +3 -15
- package/package.json +2 -3
- package/src/flow-step-types.ts +32 -0
- package/src/hooks/useRuntypeFlow.ts +9 -20
- package/src/types/index.ts +1 -1
- package/src/utils/adapter.ts +1 -1
package/example/package.json
CHANGED
package/example/src/App.tsx
CHANGED
|
@@ -577,7 +577,7 @@ function FlowBrowserPanel({ isOpen, onClose, onLoadFlow }: FlowBrowserPanelProps
|
|
|
577
577
|
setLoadingFlowId(flowId)
|
|
578
578
|
setError(null)
|
|
579
579
|
try {
|
|
580
|
-
// Fetch flow details
|
|
580
|
+
// Fetch flow details with embedded steps
|
|
581
581
|
const flowResponse = await fetch(`${API_BASE_URL}/flows/${flowId}`, {
|
|
582
582
|
headers: {
|
|
583
583
|
'Authorization': `Bearer ${API_KEY}`,
|
|
@@ -588,20 +588,8 @@ function FlowBrowserPanel({ isOpen, onClose, onLoadFlow }: FlowBrowserPanelProps
|
|
|
588
588
|
}
|
|
589
589
|
const flowData = await flowResponse.json()
|
|
590
590
|
|
|
591
|
-
//
|
|
592
|
-
const
|
|
593
|
-
headers: {
|
|
594
|
-
'Authorization': `Bearer ${API_KEY}`,
|
|
595
|
-
},
|
|
596
|
-
})
|
|
597
|
-
if (!stepsResponse.ok) {
|
|
598
|
-
throw new Error(`Failed to fetch flow steps: ${stepsResponse.status}`)
|
|
599
|
-
}
|
|
600
|
-
const stepsData = await stepsResponse.json()
|
|
601
|
-
|
|
602
|
-
// Convert API response to FlowStep format
|
|
603
|
-
// API returns { data: [...steps], flow_id, flowName }
|
|
604
|
-
const stepsArray = stepsData.data || stepsData.steps || stepsData || []
|
|
591
|
+
// Use flow steps from the flow response (consolidated endpoint)
|
|
592
|
+
const stepsArray = flowData.flow_steps || flowData.flowSteps || []
|
|
605
593
|
const steps: FlowStep[] = stepsArray.map((step: any) => ({
|
|
606
594
|
id: step.id,
|
|
607
595
|
type: step.type,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runtypelabs/react-flow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "React Flow adapter for building visual flow editors with Runtype",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"*.css"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@runtypelabs/
|
|
20
|
-
"@runtypelabs/sdk": "0.2.0"
|
|
19
|
+
"@runtypelabs/sdk": "0.3.0"
|
|
21
20
|
},
|
|
22
21
|
"peerDependencies": {
|
|
23
22
|
"@xyflow/react": "^12.0.0",
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flow Step Types
|
|
3
|
+
*
|
|
4
|
+
* Note: These types are inlined from the internal shared package to avoid
|
|
5
|
+
* requiring users to install @runtypelabs/shared.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export type ContextStepType =
|
|
9
|
+
| 'fetch-url'
|
|
10
|
+
| 'retrieve-record'
|
|
11
|
+
| 'fetch-github'
|
|
12
|
+
| 'api-call'
|
|
13
|
+
| 'transform-data'
|
|
14
|
+
| 'conditional'
|
|
15
|
+
| 'set-variable'
|
|
16
|
+
| 'upsert-record'
|
|
17
|
+
| 'send-email'
|
|
18
|
+
| 'send-text'
|
|
19
|
+
| 'send-event'
|
|
20
|
+
| 'send-stream'
|
|
21
|
+
| 'update-record'
|
|
22
|
+
| 'search'
|
|
23
|
+
| 'generate-embedding'
|
|
24
|
+
| 'vector-search'
|
|
25
|
+
| 'tool-call'
|
|
26
|
+
| 'wait-until'
|
|
27
|
+
| 'paginate-api'
|
|
28
|
+
| 'store-vector'
|
|
29
|
+
|
|
30
|
+
export type FlowStepType = 'prompt' | ContextStepType
|
|
31
|
+
|
|
32
|
+
export type PromptStepMode = 'task' | 'agent'
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
createDefaultStep,
|
|
24
24
|
} from '../utils/adapter'
|
|
25
25
|
import { autoLayout } from '../utils/layout'
|
|
26
|
-
import type { FlowStepType } from '
|
|
26
|
+
import type { FlowStepType } from '../flow-step-types'
|
|
27
27
|
|
|
28
28
|
// ============================================================================
|
|
29
29
|
// Hook Options
|
|
@@ -140,11 +140,11 @@ export function useRuntypeFlow(options: UseRuntypeFlowOptions): UseRuntypeFlowRe
|
|
|
140
140
|
setError(null)
|
|
141
141
|
|
|
142
142
|
try {
|
|
143
|
+
// Get flow with embedded steps
|
|
143
144
|
const flow = await client.flows.get(id)
|
|
144
|
-
|
|
145
|
-
//
|
|
146
|
-
const
|
|
147
|
-
const steps: FlowStep[] = Array.isArray(stepsResponse) ? stepsResponse : []
|
|
145
|
+
|
|
146
|
+
// Use flow steps from the flow response (consolidated endpoint)
|
|
147
|
+
const steps: FlowStep[] = Array.isArray(flow.flowSteps) ? flow.flowSteps : []
|
|
148
148
|
|
|
149
149
|
// Convert to React Flow nodes
|
|
150
150
|
let newNodes = flowStepsToNodes(steps, {
|
|
@@ -193,29 +193,18 @@ export function useRuntypeFlow(options: UseRuntypeFlowOptions): UseRuntypeFlowRe
|
|
|
193
193
|
try {
|
|
194
194
|
const steps = nodesToFlowSteps(nodes)
|
|
195
195
|
|
|
196
|
-
// Update flow metadata
|
|
196
|
+
// Update flow with metadata and steps in one atomic operation
|
|
197
197
|
await client.flows.update(flowId, {
|
|
198
198
|
name: flowName,
|
|
199
199
|
description: flowDescription,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
// Update steps - delete existing and create new
|
|
203
|
-
const existingSteps = await client.flowSteps.getByFlow(flowId)
|
|
204
|
-
for (const step of existingSteps) {
|
|
205
|
-
await client.flowSteps.delete(step.id)
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Create new steps
|
|
209
|
-
for (const step of steps) {
|
|
210
|
-
await client.flowSteps.create({
|
|
211
|
-
flowId,
|
|
200
|
+
flow_steps: steps.map(step => ({
|
|
212
201
|
type: step.type,
|
|
213
202
|
name: step.name,
|
|
214
203
|
order: step.order,
|
|
215
204
|
enabled: step.enabled,
|
|
216
205
|
config: step.config,
|
|
217
|
-
})
|
|
218
|
-
}
|
|
206
|
+
})),
|
|
207
|
+
})
|
|
219
208
|
|
|
220
209
|
setHasUnsavedChanges(false)
|
|
221
210
|
lastSavedState.current = JSON.stringify(steps)
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Node, Edge, NodeProps } from '@xyflow/react'
|
|
2
|
-
import type { FlowStepType, PromptStepMode } from '
|
|
2
|
+
import type { FlowStepType, PromptStepMode } from '../flow-step-types'
|
|
3
3
|
import type { RuntypeClient } from '@runtypelabs/sdk'
|
|
4
4
|
|
|
5
5
|
// ============================================================================
|
package/src/utils/adapter.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FlowStep, RuntypeNode, RuntypeEdge, RuntypeNodeData } from '../types'
|
|
2
|
-
import type { FlowStepType } from '
|
|
2
|
+
import type { FlowStepType } from '../flow-step-types'
|
|
3
3
|
|
|
4
4
|
// ============================================================================
|
|
5
5
|
// Constants
|