@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.
@@ -0,0 +1,10 @@
1
+ # @runtypelabs/react-flow-example
2
+
3
+ ## 0.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [9ec83bd]
8
+ - Updated dependencies [a63f268]
9
+ - @runtypelabs/sdk@0.3.0
10
+ - @runtypelabs/react-flow@0.1.4
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/react-flow-example",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -23,4 +23,3 @@
23
23
  "vite": "^5.0.0"
24
24
  }
25
25
  }
26
-
@@ -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
- // Fetch flow steps
592
- const stepsResponse = await fetch(`${API_BASE_URL}/flow-steps/flow/${flowId}`, {
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.2",
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/shared": "1.0.0",
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 '@runtypelabs/shared'
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
- // Get flow steps
146
- const stepsResponse = await client.flowSteps.getByFlow(id)
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)
@@ -1,5 +1,5 @@
1
1
  import type { Node, Edge, NodeProps } from '@xyflow/react'
2
- import type { FlowStepType, PromptStepMode } from '@runtypelabs/shared'
2
+ import type { FlowStepType, PromptStepMode } from '../flow-step-types'
3
3
  import type { RuntypeClient } from '@runtypelabs/sdk'
4
4
 
5
5
  // ============================================================================
@@ -1,5 +1,5 @@
1
1
  import type { FlowStep, RuntypeNode, RuntypeEdge, RuntypeNodeData } from '../types'
2
- import type { FlowStepType } from '@runtypelabs/shared'
2
+ import type { FlowStepType } from '../flow-step-types'
3
3
 
4
4
  // ============================================================================
5
5
  // Constants