@runtypelabs/react-flow 0.1.3 → 0.1.5

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/dist/index.mjs CHANGED
@@ -642,8 +642,7 @@ function useRuntypeFlow(options) {
642
642
  setError(null);
643
643
  try {
644
644
  const flow = await client.flows.get(id);
645
- const stepsResponse = await client.flowSteps.getByFlow(id);
646
- const steps = Array.isArray(stepsResponse) ? stepsResponse : [];
645
+ const steps = Array.isArray(flow.flowSteps) ? flow.flowSteps : [];
647
646
  let newNodes = flowStepsToNodes(steps, {
648
647
  onChange: handleStepChange,
649
648
  onDelete: handleStepDelete
@@ -679,22 +678,15 @@ function useRuntypeFlow(options) {
679
678
  const steps = nodesToFlowSteps(nodes);
680
679
  await client.flows.update(flowId, {
681
680
  name: flowName,
682
- description: flowDescription
683
- });
684
- const existingSteps = await client.flowSteps.getByFlow(flowId);
685
- for (const step of existingSteps) {
686
- await client.flowSteps.delete(step.id);
687
- }
688
- for (const step of steps) {
689
- await client.flowSteps.create({
690
- flowId,
681
+ description: flowDescription,
682
+ flow_steps: steps.map((step) => ({
691
683
  type: step.type,
692
684
  name: step.name,
693
685
  order: step.order,
694
686
  enabled: step.enabled,
695
687
  config: step.config
696
- });
697
- }
688
+ }))
689
+ });
698
690
  setHasUnsavedChanges(false);
699
691
  lastSavedState.current = JSON.stringify(steps);
700
692
  return {