code refactor

This commit is contained in:
anovazzi1 2024-01-05 17:08:12 -03:00
commit ac448bdd09
39 changed files with 122 additions and 150 deletions

View file

@ -1,6 +1,6 @@
import _ from "lodash"; import _ from "lodash";
import { useContext, useEffect, useState } from "react"; import { useContext, useEffect, useState } from "react";
import { useLocation, useNavigate } from "react-router-dom"; import { useLocation } from "react-router-dom";
import "reactflow/dist/style.css"; import "reactflow/dist/style.css";
import "./App.css"; import "./App.css";
@ -15,12 +15,12 @@ import {
FETCH_ERROR_DESCRIPION, FETCH_ERROR_DESCRIPION,
FETCH_ERROR_MESSAGE, FETCH_ERROR_MESSAGE,
} from "./constants/constants"; } from "./constants/constants";
import { locationContext } from "./contexts/locationContext";
import { typesContext } from "./contexts/typesContext";
import Router from "./routes";
import { AuthContext } from "./contexts/authContext"; import { AuthContext } from "./contexts/authContext";
import { FlowsContext } from "./contexts/flowsContext"; import { FlowsContext } from "./contexts/flowsContext";
import { locationContext } from "./contexts/locationContext";
import { typesContext } from "./contexts/typesContext";
import { getVersion } from "./controllers/API"; import { getVersion } from "./controllers/API";
import Router from "./routes";
import useAlertStore from "./stores/alertStore"; import useAlertStore from "./stores/alertStore";
export default function App() { export default function App() {
@ -139,7 +139,7 @@ export default function App() {
// get data from db // get data from db
refreshFlows(); refreshFlows();
} }
getVersion().then((data) => { getVersion().then((data) => {
setVersion(data.version); setVersion(data.version);
}); });

View file

@ -30,6 +30,7 @@ import { FlowsContext } from "../../../../contexts/flowsContext";
import { typesContext } from "../../../../contexts/typesContext"; import { typesContext } from "../../../../contexts/typesContext";
import { undoRedoContext } from "../../../../contexts/undoRedoContext"; import { undoRedoContext } from "../../../../contexts/undoRedoContext";
import { postCustomComponentUpdate } from "../../../../controllers/API"; import { postCustomComponentUpdate } from "../../../../controllers/API";
import useAlertStore from "../../../../stores/alertStore";
import useFlowStore from "../../../../stores/flowStore"; import useFlowStore from "../../../../stores/flowStore";
import { APIClassType } from "../../../../types/api"; import { APIClassType } from "../../../../types/api";
import { ParameterComponentType } from "../../../../types/components"; import { ParameterComponentType } from "../../../../types/components";
@ -47,7 +48,6 @@ import {
nodeNames, nodeNames,
} from "../../../../utils/styleUtils"; } from "../../../../utils/styleUtils";
import { classNames, groupByFamily } from "../../../../utils/utils"; import { classNames, groupByFamily } from "../../../../utils/utils";
import useAlertStore from "../../../../stores/alertStore";
export default function ParameterComponent({ export default function ParameterComponent({
left, left,
@ -68,14 +68,14 @@ export default function ParameterComponent({
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
const refHtml = useRef<HTMLDivElement & ReactNode>(null); const refHtml = useRef<HTMLDivElement & ReactNode>(null);
const infoHtml = useRef<HTMLDivElement & ReactNode>(null); const infoHtml = useRef<HTMLDivElement & ReactNode>(null);
const setErrorData = useAlertStore((state) => state.setErrorData); const updateNodeInternals = useUpdateNodeInternals(); const setErrorData = useAlertStore((state) => state.setErrorData);
const updateNodeInternals = useUpdateNodeInternals();
const [position, setPosition] = useState(0); const [position, setPosition] = useState(0);
const { tabId, flows } = useContext(FlowsContext); const { tabId, flows } = useContext(FlowsContext);
const nodes = useFlowStore((state) => state.nodes); const nodes = useFlowStore((state) => state.nodes);
const edges = useFlowStore((state) => state.edges); const edges = useFlowStore((state) => state.edges);
const setNode = useFlowStore((state) => state.setNode); const setNode = useFlowStore((state) => state.setNode);
const flow = flows.find((flow) => flow.id === tabId)?.data?.nodes ?? null; const flow = flows.find((flow) => flow.id === tabId)?.data?.nodes ?? null;
// Update component position // Update component position

View file

@ -10,13 +10,13 @@ import { useSSE } from "../../contexts/SSEContext";
import { typesContext } from "../../contexts/typesContext"; import { typesContext } from "../../contexts/typesContext";
import { undoRedoContext } from "../../contexts/undoRedoContext"; import { undoRedoContext } from "../../contexts/undoRedoContext";
import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent"; import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent";
import useFlowStore from "../../stores/flowStore";
import { validationStatusType } from "../../types/components"; import { validationStatusType } from "../../types/components";
import { NodeDataType } from "../../types/flow"; import { NodeDataType } from "../../types/flow";
import { handleKeyDown, scapedJSONStringfy } from "../../utils/reactflowUtils"; import { handleKeyDown, scapedJSONStringfy } from "../../utils/reactflowUtils";
import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils"; import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils";
import { classNames, cn, getFieldTitle } from "../../utils/utils"; import { classNames, cn, getFieldTitle } from "../../utils/utils";
import ParameterComponent from "./components/parameterComponent"; import ParameterComponent from "./components/parameterComponent";
import useFlowStore from "../../stores/flowStore";
export default function GenericNode({ export default function GenericNode({
data, data,

View file

@ -1,18 +1,17 @@
import { useContext, useState } from "react"; import { useState } from "react";
import IconComponent from "../../components/genericIconComponent"; import IconComponent from "../../components/genericIconComponent";
import { import {
Popover, Popover,
PopoverContent, PopoverContent,
PopoverTrigger, PopoverTrigger,
} from "../../components/ui/popover"; } from "../../components/ui/popover";
import useAlertStore from "../../stores/alertStore";
import { AlertDropdownType } from "../../types/alerts"; import { AlertDropdownType } from "../../types/alerts";
import SingleAlert from "./components/singleAlertComponent"; import SingleAlert from "./components/singleAlertComponent";
import useAlertStore from "../../stores/alertStore";
export default function AlertDropdown({ export default function AlertDropdown({
children, children,
}: AlertDropdownType): JSX.Element { }: AlertDropdownType): JSX.Element {
const notificationList = useAlertStore((state) => state.notificationList); const notificationList = useAlertStore((state) => state.notificationList);
const clearNotificationList = useAlertStore( const clearNotificationList = useAlertStore(
(state) => state.clearNotificationList (state) => state.clearNotificationList
@ -24,7 +23,6 @@ export default function AlertDropdown({
(state) => state.setNotificationCenter (state) => state.setNotificationCenter
); );
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
return ( return (

View file

@ -2,6 +2,7 @@ import { useContext, useEffect, useState } from "react";
import { FlowsContext } from "../../contexts/flowsContext"; import { FlowsContext } from "../../contexts/flowsContext";
import { getComponent, postLikeComponent } from "../../controllers/API"; import { getComponent, postLikeComponent } from "../../controllers/API";
import DeleteConfirmationModal from "../../modals/DeleteConfirmationModal"; import DeleteConfirmationModal from "../../modals/DeleteConfirmationModal";
import useAlertStore from "../../stores/alertStore";
import { useStoreStore } from "../../stores/storeStore"; import { useStoreStore } from "../../stores/storeStore";
import { storeComponent } from "../../types/store"; import { storeComponent } from "../../types/store";
import cloneFLowWithParent from "../../utils/storeUtils"; import cloneFLowWithParent from "../../utils/storeUtils";
@ -17,7 +18,6 @@ import {
CardHeader, CardHeader,
CardTitle, CardTitle,
} from "../ui/card"; } from "../ui/card";
import useAlertStore from "../../stores/alertStore";
export default function CollectionCardComponent({ export default function CollectionCardComponent({
data, data,

View file

@ -6,13 +6,13 @@ import { postBuildInit } from "../../../controllers/API";
import { FlowType } from "../../../types/flow"; import { FlowType } from "../../../types/flow";
import { FlowsContext } from "../../../contexts/flowsContext"; import { FlowsContext } from "../../../contexts/flowsContext";
import useAlertStore from "../../../stores/alertStore";
import useFlowStore from "../../../stores/flowStore";
import { parsedDataType } from "../../../types/components"; import { parsedDataType } from "../../../types/components";
import { FlowsState } from "../../../types/tabs"; import { FlowsState } from "../../../types/tabs";
import { validateNodes } from "../../../utils/reactflowUtils"; import { validateNodes } from "../../../utils/reactflowUtils";
import RadialProgressComponent from "../../RadialProgress"; import RadialProgressComponent from "../../RadialProgress";
import IconComponent from "../../genericIconComponent"; import IconComponent from "../../genericIconComponent";
import useFlowStore from "../../../stores/flowStore";
import useAlertStore from "../../../stores/alertStore";
export default function BuildTrigger({ export default function BuildTrigger({
open, open,
@ -30,7 +30,7 @@ export default function BuildTrigger({
const edges = useFlowStore((state) => state.edges); const edges = useFlowStore((state) => state.edges);
const setErrorData = useAlertStore((state) => state.setErrorData); const setErrorData = useAlertStore((state) => state.setErrorData);
const setSuccessData = useAlertStore((state) => state.setSuccessData); const setSuccessData = useAlertStore((state) => state.setSuccessData);
const [isIconTouched, setIsIconTouched] = useState(false); const [isIconTouched, setIsIconTouched] = useState(false);
const eventClick = isBuilding ? "pointer-events-none" : ""; const eventClick = isBuilding ? "pointer-events-none" : "";
const [progress, setProgress] = useState(0); const [progress, setProgress] = useState(0);

View file

@ -1,15 +1,14 @@
import { Transition } from "@headlessui/react"; import { Transition } from "@headlessui/react";
import { useContext } from "react";
import { import {
CHAT_CANNOT_OPEN_DESCRIPTION, CHAT_CANNOT_OPEN_DESCRIPTION,
CHAT_CANNOT_OPEN_TITLE, CHAT_CANNOT_OPEN_TITLE,
FLOW_NOT_BUILT_DESCRIPTION, FLOW_NOT_BUILT_DESCRIPTION,
FLOW_NOT_BUILT_TITLE, FLOW_NOT_BUILT_TITLE,
} from "../../../constants/constants"; } from "../../../constants/constants";
import useAlertStore from "../../../stores/alertStore";
import { chatTriggerPropType } from "../../../types/components"; import { chatTriggerPropType } from "../../../types/components";
import IconComponent from "../../genericIconComponent"; import IconComponent from "../../genericIconComponent";
import useAlertStore from "../../../stores/alertStore";
export default function ChatTrigger({ export default function ChatTrigger({
open, open,

View file

@ -8,8 +8,8 @@ import * as _ from "lodash";
import { FlowsContext } from "../../contexts/flowsContext"; import { FlowsContext } from "../../contexts/flowsContext";
import { getBuildStatus } from "../../controllers/API"; import { getBuildStatus } from "../../controllers/API";
import FormModal from "../../modals/formModal"; import FormModal from "../../modals/formModal";
import { NodeType } from "../../types/flow";
import useFlowStore from "../../stores/flowStore"; import useFlowStore from "../../stores/flowStore";
import { NodeType } from "../../types/flow";
export default function Chat({ flow }: ChatType): JSX.Element { export default function Chat({ flow }: ChatType): JSX.Element {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@ -17,8 +17,7 @@ export default function Chat({ flow }: ChatType): JSX.Element {
const isBuilt = useFlowStore((state) => state.isBuilt); const isBuilt = useFlowStore((state) => state.isBuilt);
const setIsBuilt = useFlowStore((state) => state.setIsBuilt); const setIsBuilt = useFlowStore((state) => state.setIsBuilt);
const isPending = useFlowStore((state) => state.isPending); const isPending = useFlowStore((state) => state.isPending);
const { tabsState } = const { tabsState } = useContext(FlowsContext);
useContext(FlowsContext);
useEffect(() => { useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => { const handleKeyDown = (event: KeyboardEvent) => {

View file

@ -1,5 +1,5 @@
import { cloneDeep } from "lodash"; import { cloneDeep } from "lodash";
import { useContext, useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import { oneDark } from "react-syntax-highlighter/dist/cjs/styles/prism"; import { oneDark } from "react-syntax-highlighter/dist/cjs/styles/prism";
import AccordionComponent from "../../components/AccordionComponent"; import AccordionComponent from "../../components/AccordionComponent";
@ -29,6 +29,7 @@ import {
} from "../../components/ui/tabs"; } from "../../components/ui/tabs";
import { LANGFLOW_SUPPORTED_TYPES } from "../../constants/constants"; import { LANGFLOW_SUPPORTED_TYPES } from "../../constants/constants";
import { useDarkStore } from "../../stores/darkStore"; import { useDarkStore } from "../../stores/darkStore";
import useFlowStore from "../../stores/flowStore";
import { codeTabsPropsType } from "../../types/components"; import { codeTabsPropsType } from "../../types/components";
import { import {
convertObjToArray, convertObjToArray,
@ -40,7 +41,6 @@ import { classNames } from "../../utils/utils";
import DictComponent from "../dictComponent"; import DictComponent from "../dictComponent";
import IconComponent from "../genericIconComponent"; import IconComponent from "../genericIconComponent";
import KeypairListComponent from "../keypairListComponent"; import KeypairListComponent from "../keypairListComponent";
import useFlowStore from "../../stores/flowStore";
export default function CodeTabsComponent({ export default function CodeTabsComponent({
flow, flow,

View file

@ -11,10 +11,10 @@ import {
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { undoRedoContext } from "../../../../contexts/undoRedoContext"; import { undoRedoContext } from "../../../../contexts/undoRedoContext";
import FlowSettingsModal from "../../../../modals/flowSettingsModal"; import FlowSettingsModal from "../../../../modals/flowSettingsModal";
import useAlertStore from "../../../../stores/alertStore";
import { menuBarPropsType } from "../../../../types/components"; import { menuBarPropsType } from "../../../../types/components";
import IconComponent from "../../../genericIconComponent"; import IconComponent from "../../../genericIconComponent";
import { Button } from "../../../ui/button"; import { Button } from "../../../ui/button";
import useAlertStore from "../../../../stores/alertStore";
export const MenuBar = ({ flows, tabId }: menuBarPropsType): JSX.Element => { export const MenuBar = ({ flows, tabId }: menuBarPropsType): JSX.Element => {
const { addFlow } = useContext(FlowsContext); const { addFlow } = useContext(FlowsContext);

View file

@ -6,6 +6,7 @@ import { USER_PROJECTS_HEADER } from "../../constants/constants";
import { AuthContext } from "../../contexts/authContext"; import { AuthContext } from "../../contexts/authContext";
import { FlowsContext } from "../../contexts/flowsContext"; import { FlowsContext } from "../../contexts/flowsContext";
import useAlertStore from "../../stores/alertStore";
import { useDarkStore } from "../../stores/darkStore"; import { useDarkStore } from "../../stores/darkStore";
import { useStoreStore } from "../../stores/storeStore"; import { useStoreStore } from "../../stores/storeStore";
import { gradients } from "../../utils/styleUtils"; import { gradients } from "../../utils/styleUtils";
@ -21,7 +22,6 @@ import {
} from "../ui/dropdown-menu"; } from "../ui/dropdown-menu";
import { Separator } from "../ui/separator"; import { Separator } from "../ui/separator";
import MenuBar from "./components/menuBar"; import MenuBar from "./components/menuBar";
import useAlertStore from "../../stores/alertStore";
export default function Header(): JSX.Element { export default function Header(): JSX.Element {
const { flows, tabId } = useContext(FlowsContext); const { flows, tabId } = useContext(FlowsContext);

View file

@ -1,9 +1,9 @@
import { useContext, useEffect, useState } from "react"; import { useContext, useEffect, useState } from "react";
import { FlowsContext } from "../../contexts/flowsContext"; import { FlowsContext } from "../../contexts/flowsContext";
import { uploadFile } from "../../controllers/API"; import { uploadFile } from "../../controllers/API";
import useAlertStore from "../../stores/alertStore";
import { FileComponentType } from "../../types/components"; import { FileComponentType } from "../../types/components";
import IconComponent from "../genericIconComponent"; import IconComponent from "../genericIconComponent";
import useAlertStore from "../../stores/alertStore";
export default function InputFileComponent({ export default function InputFileComponent({
value, value,
@ -15,7 +15,8 @@ export default function InputFileComponent({
}: FileComponentType): JSX.Element { }: FileComponentType): JSX.Element {
const [myValue, setMyValue] = useState(value); const [myValue, setMyValue] = useState(value);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const setErrorData = useAlertStore((state) => state.setErrorData); const { tabId } = useContext(FlowsContext); const setErrorData = useAlertStore((state) => state.setErrorData);
const { tabId } = useContext(FlowsContext);
// Clear component state // Clear component state
useEffect(() => { useEffect(() => {

View file

@ -1,9 +1,9 @@
import { createContext, useContext, useEffect, useState } from "react"; import { createContext, useEffect, useState } from "react";
import Cookies from "universal-cookie"; import Cookies from "universal-cookie";
import { autoLogin as autoLoginApi, getLoggedUser } from "../controllers/API"; import { autoLogin as autoLoginApi, getLoggedUser } from "../controllers/API";
import useAlertStore from "../stores/alertStore";
import { Users } from "../types/api"; import { Users } from "../types/api";
import { AuthContextType } from "../types/contexts/auth"; import { AuthContextType } from "../types/contexts/auth";
import useAlertStore from "../stores/alertStore";
const initialValue: AuthContextType = { const initialValue: AuthContextType = {
isAdmin: false, isAdmin: false,

View file

@ -1,56 +1,33 @@
import { AxiosError } from "axios"; import { AxiosError } from "axios";
import _, { cloneDeep } from "lodash"; import _, { cloneDeep } from "lodash";
import { import { ReactNode, createContext, useContext, useRef, useState } from "react";
ReactNode,
createContext,
useCallback,
useContext,
useRef,
useState,
} from "react";
import { import {
Edge, Edge,
EdgeChange,
Node, Node,
NodeChange,
ReactFlowJsonObject, ReactFlowJsonObject,
Viewport, Viewport,
XYPosition, XYPosition,
addEdge,
useEdgesState,
useNodesState,
} from "reactflow"; } from "reactflow";
import ShortUniqueId from "short-unique-id"; import ShortUniqueId from "short-unique-id";
import { import {
deleteFlowFromDatabase, deleteFlowFromDatabase,
downloadFlowsFromDatabase, downloadFlowsFromDatabase,
getVersion,
readFlowsFromDatabase, readFlowsFromDatabase,
saveFlowToDatabase, saveFlowToDatabase,
updateFlowInDatabase, updateFlowInDatabase,
uploadFlowsToDatabase, uploadFlowsToDatabase,
} from "../controllers/API"; } from "../controllers/API";
import useAlertStore from "../stores/alertStore";
import useFlowStore from "../stores/flowStore";
import { APIClassType } from "../types/api"; import { APIClassType } from "../types/api";
import { tweakType } from "../types/components"; import { FlowType, NodeDataType } from "../types/flow";
import {
FlowType,
NodeDataType,
NodeType,
sourceHandleType,
targetHandleType,
} from "../types/flow";
import { FlowsContextType, FlowsState } from "../types/tabs"; import { FlowsContextType, FlowsState } from "../types/tabs";
import { import {
addVersionToDuplicates, addVersionToDuplicates,
checkOldEdgesHandles,
cleanEdges,
createFlowComponent, createFlowComponent,
processFlowEdges, processFlowEdges,
removeFileNameFromComponents, removeFileNameFromComponents,
scapeJSONParse,
scapedJSONStringfy,
updateEdges, updateEdges,
updateEdgesHandleIds,
updateIds, updateIds,
} from "../utils/reactflowUtils"; } from "../utils/reactflowUtils";
import { import {
@ -58,10 +35,7 @@ import {
getRandomDescription, getRandomDescription,
getRandomName, getRandomName,
} from "../utils/utils"; } from "../utils/utils";
import { AuthContext } from "./authContext";
import { typesContext } from "./typesContext"; import { typesContext } from "./typesContext";
import useFlowStore from "../stores/flowStore";
import useAlertStore from "../stores/alertStore";
const uid = new ShortUniqueId({ length: 5 }); const uid = new ShortUniqueId({ length: 5 });
@ -102,7 +76,7 @@ export function FlowsProvider({ children }: { children: ReactNode }) {
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [flows, setFlows] = useState<Array<FlowType>>([]); const [flows, setFlows] = useState<Array<FlowType>>([]);
const [tabsState, setTabsState] = useState<FlowsState>({}); const [tabsState, setTabsState] = useState<FlowsState>({});
const {setData} = useContext(typesContext); const { setData } = useContext(typesContext);
const nodes = useFlowStore((state) => state.nodes); const nodes = useFlowStore((state) => state.nodes);
const edges = useFlowStore((state) => state.edges); const edges = useFlowStore((state) => state.edges);
@ -498,7 +472,6 @@ export function FlowsProvider({ children }: { children: ReactNode }) {
// Initialize state variable for the version // Initialize state variable for the version
const [version, setVersion] = useState(""); const [version, setVersion] = useState("");
return ( return (
<FlowsContext.Provider <FlowsContext.Provider
value={{ value={{

View file

@ -6,12 +6,11 @@ import {
useEffect, useEffect,
useState, useState,
} from "react"; } from "react";
import { ReactFlowInstance } from "reactflow";
import { getAll, getHealth } from "../controllers/API"; import { getAll, getHealth } from "../controllers/API";
import useAlertStore from "../stores/alertStore";
import { APIKindType } from "../types/api"; import { APIKindType } from "../types/api";
import { typesContextType } from "../types/typesContext"; import { typesContextType } from "../types/typesContext";
import { AuthContext } from "./authContext"; import { AuthContext } from "./authContext";
import useAlertStore from "../stores/alertStore";
//context to share types adn functions from nodes to flow //context to share types adn functions from nodes to flow

View file

@ -6,6 +6,7 @@ import {
useEffect, useEffect,
useState, useState,
} from "react"; } from "react";
import useFlowStore from "../stores/flowStore";
import { import {
HistoryItem, HistoryItem,
UseUndoRedoOptions, UseUndoRedoOptions,
@ -13,7 +14,6 @@ import {
} from "../types/typesContext"; } from "../types/typesContext";
import { isWrappedWithClass } from "../utils/utils"; import { isWrappedWithClass } from "../utils/utils";
import { FlowsContext } from "./flowsContext"; import { FlowsContext } from "./flowsContext";
import useFlowStore from "../stores/flowStore";
const initialValue = { const initialValue = {
undo: () => {}, undo: () => {},
@ -29,8 +29,7 @@ const defaultOptions: UseUndoRedoOptions = {
export const undoRedoContext = createContext<undoRedoContextType>(initialValue); export const undoRedoContext = createContext<undoRedoContextType>(initialValue);
export function UndoRedoProvider({ children }) { export function UndoRedoProvider({ children }) {
const { tabId, flows } = const { tabId, flows } = useContext(FlowsContext);
useContext(FlowsContext);
const setNodes = useFlowStore((state) => state.setNodes); const setNodes = useFlowStore((state) => state.setNodes);
const setEdges = useFlowStore((state) => state.setEdges); const setEdges = useFlowStore((state) => state.setEdges);

View file

@ -1,5 +1,5 @@
import { cloneDeep } from "lodash"; import { cloneDeep } from "lodash";
import { forwardRef, useContext, useEffect, useState } from "react"; import { forwardRef, useEffect, useState } from "react";
import ShadTooltip from "../../components/ShadTooltipComponent"; import ShadTooltip from "../../components/ShadTooltipComponent";
import CodeAreaComponent from "../../components/codeAreaComponent"; import CodeAreaComponent from "../../components/codeAreaComponent";
import DictComponent from "../../components/dictComponent"; import DictComponent from "../../components/dictComponent";
@ -28,6 +28,7 @@ import {
LANGFLOW_SUPPORTED_TYPES, LANGFLOW_SUPPORTED_TYPES,
limitScrollFieldsModal, limitScrollFieldsModal,
} from "../../constants/constants"; } from "../../constants/constants";
import useFlowStore from "../../stores/flowStore";
import { NodeDataType } from "../../types/flow"; import { NodeDataType } from "../../types/flow";
import { import {
convertObjToArray, convertObjToArray,
@ -37,7 +38,6 @@ import {
} from "../../utils/reactflowUtils"; } from "../../utils/reactflowUtils";
import { classNames } from "../../utils/utils"; import { classNames } from "../../utils/utils";
import BaseModal from "../baseModal"; import BaseModal from "../baseModal";
import useFlowStore from "../../stores/flowStore";
const EditNodeModal = forwardRef( const EditNodeModal = forwardRef(
( (

View file

@ -1,13 +1,13 @@
import * as Form from "@radix-ui/react-form"; import * as Form from "@radix-ui/react-form";
import { useContext, useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import IconComponent from "../../components/genericIconComponent"; import IconComponent from "../../components/genericIconComponent";
import { Button } from "../../components/ui/button"; import { Button } from "../../components/ui/button";
import { Input } from "../../components/ui/input"; import { Input } from "../../components/ui/input";
import { createApiKey } from "../../controllers/API"; import { createApiKey } from "../../controllers/API";
import useAlertStore from "../../stores/alertStore";
import { ApiKeyType } from "../../types/components"; import { ApiKeyType } from "../../types/components";
import { nodeIconsLucide } from "../../utils/styleUtils"; import { nodeIconsLucide } from "../../utils/styleUtils";
import BaseModal from "../baseModal"; import BaseModal from "../baseModal";
import useAlertStore from "../../stores/alertStore";
export default function SecretKeyModal({ export default function SecretKeyModal({
title, title,

View file

@ -5,10 +5,10 @@ import { Button } from "../../components/ui/button";
import { Input } from "../../components/ui/input"; import { Input } from "../../components/ui/input";
import { AuthContext } from "../../contexts/authContext"; import { AuthContext } from "../../contexts/authContext";
import { addApiKeyStore } from "../../controllers/API"; import { addApiKeyStore } from "../../controllers/API";
import useAlertStore from "../../stores/alertStore";
import { useStoreStore } from "../../stores/storeStore"; import { useStoreStore } from "../../stores/storeStore";
import { StoreApiKeyType } from "../../types/components"; import { StoreApiKeyType } from "../../types/components";
import BaseModal from "../baseModal"; import BaseModal from "../baseModal";
import useAlertStore from "../../stores/alertStore";
export default function StoreApiKeyModal({ export default function StoreApiKeyModal({
children, children,

View file

@ -4,17 +4,17 @@ import "ace-builds/src-noconflict/mode-python";
import "ace-builds/src-noconflict/theme-github"; import "ace-builds/src-noconflict/theme-github";
import "ace-builds/src-noconflict/theme-twilight"; import "ace-builds/src-noconflict/theme-twilight";
// import "ace-builds/webpack-resolver"; // import "ace-builds/webpack-resolver";
import { useContext, useEffect, useState } from "react"; import { useEffect, useState } from "react";
import AceEditor from "react-ace"; import AceEditor from "react-ace";
import IconComponent from "../../components/genericIconComponent"; import IconComponent from "../../components/genericIconComponent";
import { Button } from "../../components/ui/button"; import { Button } from "../../components/ui/button";
import { Input } from "../../components/ui/input"; import { Input } from "../../components/ui/input";
import { CODE_PROMPT_DIALOG_SUBTITLE } from "../../constants/constants"; import { CODE_PROMPT_DIALOG_SUBTITLE } from "../../constants/constants";
import { postCustomComponent, postValidateCode } from "../../controllers/API"; import { postCustomComponent, postValidateCode } from "../../controllers/API";
import useAlertStore from "../../stores/alertStore";
import { useDarkStore } from "../../stores/darkStore"; import { useDarkStore } from "../../stores/darkStore";
import { codeAreaModalPropsType } from "../../types/components"; import { codeAreaModalPropsType } from "../../types/components";
import BaseModal from "../baseModal"; import BaseModal from "../baseModal";
import useAlertStore from "../../stores/alertStore";
export default function CodeAreaModal({ export default function CodeAreaModal({
value, value,
@ -30,7 +30,8 @@ export default function CodeAreaModal({
const [height, setHeight] = useState<string | null>(null); const [height, setHeight] = useState<string | null>(null);
const setSuccessData = useAlertStore((state) => state.setSuccessData); const setSuccessData = useAlertStore((state) => state.setSuccessData);
const setErrorData = useAlertStore((state) => state.setErrorData); const [error, setError] = useState<{ const setErrorData = useAlertStore((state) => state.setErrorData);
const [error, setError] = useState<{
detail: { error: string | undefined; traceback: string | undefined }; detail: { error: string | undefined; traceback: string | undefined };
} | null>(null); } | null>(null);

View file

@ -5,9 +5,9 @@ import { Button } from "../../components/ui/button";
import { Checkbox } from "../../components/ui/checkbox"; import { Checkbox } from "../../components/ui/checkbox";
import { EXPORT_DIALOG_SUBTITLE } from "../../constants/constants"; import { EXPORT_DIALOG_SUBTITLE } from "../../constants/constants";
import { FlowsContext } from "../../contexts/flowsContext"; import { FlowsContext } from "../../contexts/flowsContext";
import useAlertStore from "../../stores/alertStore";
import { removeApiKeys } from "../../utils/reactflowUtils"; import { removeApiKeys } from "../../utils/reactflowUtils";
import BaseModal from "../baseModal"; import BaseModal from "../baseModal";
import useAlertStore from "../../stores/alertStore";
const ExportModal = forwardRef( const ExportModal = forwardRef(
(props: { children: ReactNode }, ref): JSX.Element => { (props: { children: ReactNode }, ref): JSX.Element => {

View file

@ -24,10 +24,10 @@ import { CHAT_FORM_DIALOG_SUBTITLE } from "../../constants/constants";
import { AuthContext } from "../../contexts/authContext"; import { AuthContext } from "../../contexts/authContext";
import { FlowsContext } from "../../contexts/flowsContext"; import { FlowsContext } from "../../contexts/flowsContext";
import { getBuildStatus } from "../../controllers/API"; import { getBuildStatus } from "../../controllers/API";
import useAlertStore from "../../stores/alertStore";
import useFlowStore from "../../stores/flowStore"; import useFlowStore from "../../stores/flowStore";
import { FlowsState } from "../../types/tabs"; import { FlowsState } from "../../types/tabs";
import { validateNodes } from "../../utils/reactflowUtils"; import { validateNodes } from "../../utils/reactflowUtils";
import useAlertStore from "../../stores/alertStore";
export default function FormModal({ export default function FormModal({
flow, flow,
@ -65,7 +65,8 @@ export default function FormModal({
const [chatHistory, setChatHistory] = useState<ChatMessageType[]>([]); const [chatHistory, setChatHistory] = useState<ChatMessageType[]>([]);
const template = useRef(tabsState[flow.id].formKeysData.template); const template = useRef(tabsState[flow.id].formKeysData.template);
const { accessToken } = useContext(AuthContext); const { accessToken } = useContext(AuthContext);
const setErrorData = useAlertStore((state) => state.setErrorData); const ws = useRef<WebSocket | null>(null); const setErrorData = useAlertStore((state) => state.setErrorData);
const ws = useRef<WebSocket | null>(null);
const [lockChat, setLockChat] = useState(false); const [lockChat, setLockChat] = useState(false);
const isOpen = useRef(open); const isOpen = useRef(open);
const messagesRef = useRef<HTMLDivElement | null>(null); const messagesRef = useRef<HTMLDivElement | null>(null);

View file

@ -1,4 +1,4 @@
import { useContext, useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import SanitizedHTMLWrapper from "../../components/SanitizedHTMLWrapper"; import SanitizedHTMLWrapper from "../../components/SanitizedHTMLWrapper";
import ShadTooltip from "../../components/ShadTooltipComponent"; import ShadTooltip from "../../components/ShadTooltipComponent";
import IconComponent from "../../components/genericIconComponent"; import IconComponent from "../../components/genericIconComponent";
@ -14,11 +14,11 @@ import {
} from "../../constants/constants"; } from "../../constants/constants";
import { TypeModal } from "../../constants/enums"; import { TypeModal } from "../../constants/enums";
import { postValidatePrompt } from "../../controllers/API"; import { postValidatePrompt } from "../../controllers/API";
import useAlertStore from "../../stores/alertStore";
import { genericModalPropsType } from "../../types/components"; import { genericModalPropsType } from "../../types/components";
import { handleKeyDown } from "../../utils/reactflowUtils"; import { handleKeyDown } from "../../utils/reactflowUtils";
import { classNames, varHighlightHTML } from "../../utils/utils"; import { classNames, varHighlightHTML } from "../../utils/utils";
import BaseModal from "../baseModal"; import BaseModal from "../baseModal";
import useAlertStore from "../../stores/alertStore";
export default function GenericModal({ export default function GenericModal({
field_name = "", field_name = "",

View file

@ -12,6 +12,7 @@ import {
saveFlowStore, saveFlowStore,
updateFlowStore, updateFlowStore,
} from "../../controllers/API"; } from "../../controllers/API";
import useAlertStore from "../../stores/alertStore";
import { useStoreStore } from "../../stores/storeStore"; import { useStoreStore } from "../../stores/storeStore";
import { FlowType } from "../../types/flow"; import { FlowType } from "../../types/flow";
import { import {
@ -22,7 +23,6 @@ import {
import { getTagsIds } from "../../utils/storeUtils"; import { getTagsIds } from "../../utils/storeUtils";
import ConfirmationModal from "../ConfirmationModal"; import ConfirmationModal from "../ConfirmationModal";
import BaseModal from "../baseModal"; import BaseModal from "../baseModal";
import useAlertStore from "../../stores/alertStore";
export default function ShareModal({ export default function ShareModal({
component, component,
@ -44,7 +44,8 @@ export default function ShareModal({
const hasApiKey = useStoreStore((state) => state.hasApiKey); const hasApiKey = useStoreStore((state) => state.hasApiKey);
const setSuccessData = useAlertStore((state) => state.setSuccessData); const setSuccessData = useAlertStore((state) => state.setSuccessData);
const setErrorData = useAlertStore((state) => state.setErrorData); const [internalOpen, internalSetOpen] = useState(children ? false : true); const setErrorData = useAlertStore((state) => state.setErrorData);
const [internalOpen, internalSetOpen] = useState(children ? false : true);
const [openConfirmationModal, setOpenConfirmationModal] = useState(false); const [openConfirmationModal, setOpenConfirmationModal] = useState(false);
const nameComponent = is_component ? "component" : "flow"; const nameComponent = is_component ? "component" : "flow";

View file

@ -5,12 +5,12 @@ import { Input } from "../../../components/ui/input";
import { CONTROL_LOGIN_STATE } from "../../../constants/constants"; import { CONTROL_LOGIN_STATE } from "../../../constants/constants";
import { AuthContext } from "../../../contexts/authContext"; import { AuthContext } from "../../../contexts/authContext";
import { getLoggedUser, onLogin } from "../../../controllers/API"; import { getLoggedUser, onLogin } from "../../../controllers/API";
import useAlertStore from "../../../stores/alertStore";
import { LoginType } from "../../../types/api"; import { LoginType } from "../../../types/api";
import { import {
inputHandlerEventType, inputHandlerEventType,
loginInputStateType, loginInputStateType,
} from "../../../types/components"; } from "../../../types/components";
import useAlertStore from "../../../stores/alertStore";
export default function LoginAdminPage() { export default function LoginAdminPage() {
const navigate = useNavigate(); const navigate = useNavigate();

View file

@ -30,9 +30,9 @@ import {
} from "../../controllers/API"; } from "../../controllers/API";
import ConfirmationModal from "../../modals/ConfirmationModal"; import ConfirmationModal from "../../modals/ConfirmationModal";
import UserManagementModal from "../../modals/UserManagementModal"; import UserManagementModal from "../../modals/UserManagementModal";
import useAlertStore from "../../stores/alertStore";
import { Users } from "../../types/api"; import { Users } from "../../types/api";
import { UserInputType } from "../../types/components"; import { UserInputType } from "../../types/components";
import useAlertStore from "../../stores/alertStore";
export default function AdminPage() { export default function AdminPage() {
const [inputValue, setInputValue] = useState(""); const [inputValue, setInputValue] = useState("");

View file

@ -24,13 +24,14 @@ import {
LAST_USED_SPAN_1, LAST_USED_SPAN_1,
LAST_USED_SPAN_2, LAST_USED_SPAN_2,
} from "../../constants/constants"; } from "../../constants/constants";
import { ApiKey } from "../../types/components";
import useAlertStore from "../../stores/alertStore"; import useAlertStore from "../../stores/alertStore";
import { ApiKey } from "../../types/components";
export default function ApiKeysPage() { export default function ApiKeysPage() {
const [loadingKeys, setLoadingKeys] = useState(true); const [loadingKeys, setLoadingKeys] = useState(true);
const setSuccessData = useAlertStore((state) => state.setSuccessData); const setSuccessData = useAlertStore((state) => state.setSuccessData);
const setErrorData = useAlertStore((state) => state.setErrorData); const { userData } = useContext(AuthContext); const setErrorData = useAlertStore((state) => state.setErrorData);
const { userData } = useContext(AuthContext);
const [userId, setUserId] = useState(""); const [userId, setUserId] = useState("");
const keysList = useRef([]); const keysList = useRef([]);

View file

@ -9,6 +9,7 @@ import { typesContext } from "../../../../contexts/typesContext";
import ApiModal from "../../../../modals/ApiModal"; import ApiModal from "../../../../modals/ApiModal";
import ExportModal from "../../../../modals/exportModal"; import ExportModal from "../../../../modals/exportModal";
import ShareModal from "../../../../modals/shareModal"; import ShareModal from "../../../../modals/shareModal";
import useAlertStore from "../../../../stores/alertStore";
import useFlowStore from "../../../../stores/flowStore"; import useFlowStore from "../../../../stores/flowStore";
import { useStoreStore } from "../../../../stores/storeStore"; import { useStoreStore } from "../../../../stores/storeStore";
import { APIClassType, APIObjectType } from "../../../../types/api"; import { APIClassType, APIObjectType } from "../../../../types/api";
@ -24,7 +25,6 @@ import {
} from "../../../../utils/utils"; } from "../../../../utils/utils";
import DisclosureComponent from "../DisclosureComponent"; import DisclosureComponent from "../DisclosureComponent";
import SidebarDraggableComponent from "./sideBarDraggableComponent"; import SidebarDraggableComponent from "./sideBarDraggableComponent";
import useAlertStore from "../../../../stores/alertStore";
export default function ExtraSidebar(): JSX.Element { export default function ExtraSidebar(): JSX.Element {
const { data, templates, getFilterEdge, setFilterEdge } = const { data, templates, getFilterEdge, setFilterEdge } =

View file

@ -10,12 +10,12 @@ import { CONTROL_PATCH_USER_STATE } from "../../constants/constants";
import { AuthContext } from "../../contexts/authContext"; import { AuthContext } from "../../contexts/authContext";
import { FlowsContext } from "../../contexts/flowsContext"; import { FlowsContext } from "../../contexts/flowsContext";
import { resetPassword, updateUser } from "../../controllers/API"; import { resetPassword, updateUser } from "../../controllers/API";
import useAlertStore from "../../stores/alertStore";
import { import {
inputHandlerEventType, inputHandlerEventType,
patchUserInputStateType, patchUserInputStateType,
} from "../../types/components"; } from "../../types/components";
import { gradients } from "../../utils/styleUtils"; import { gradients } from "../../utils/styleUtils";
import useAlertStore from "../../stores/alertStore";
export default function ProfileSettingsPage(): JSX.Element { export default function ProfileSettingsPage(): JSX.Element {
const { setTabId } = useContext(FlowsContext); const { setTabId } = useContext(FlowsContext);

View file

@ -28,10 +28,10 @@ import {
getStoreTags, getStoreTags,
} from "../../controllers/API"; } from "../../controllers/API";
import StoreApiKeyModal from "../../modals/StoreApiKeyModal"; import StoreApiKeyModal from "../../modals/StoreApiKeyModal";
import useAlertStore from "../../stores/alertStore";
import { useStoreStore } from "../../stores/storeStore"; import { useStoreStore } from "../../stores/storeStore";
import { storeComponent } from "../../types/store"; import { storeComponent } from "../../types/store";
import { cn } from "../../utils/utils"; import { cn } from "../../utils/utils";
import useAlertStore from "../../stores/alertStore";
export default function StorePage(): JSX.Element { export default function StorePage(): JSX.Element {
const hasApiKey = useStoreStore((state) => state.hasApiKey); const hasApiKey = useStoreStore((state) => state.hasApiKey);

View file

@ -1,5 +1,5 @@
import * as Form from "@radix-ui/react-form"; import * as Form from "@radix-ui/react-form";
import { FormEvent, useContext, useEffect, useState } from "react"; import { FormEvent, useEffect, useState } from "react";
import { Link, useNavigate } from "react-router-dom"; import { Link, useNavigate } from "react-router-dom";
import InputComponent from "../../components/inputComponent"; import InputComponent from "../../components/inputComponent";
import { Button } from "../../components/ui/button"; import { Button } from "../../components/ui/button";
@ -9,12 +9,12 @@ import {
SIGN_UP_SUCCESS, SIGN_UP_SUCCESS,
} from "../../constants/constants"; } from "../../constants/constants";
import { addUser } from "../../controllers/API"; import { addUser } from "../../controllers/API";
import useAlertStore from "../../stores/alertStore";
import { import {
UserInputType, UserInputType,
inputHandlerEventType, inputHandlerEventType,
signUpInputStateType, signUpInputStateType,
} from "../../types/components"; } from "../../types/components";
import useAlertStore from "../../stores/alertStore";
export default function SignUp(): JSX.Element { export default function SignUp(): JSX.Element {
const [inputState, setInputState] = const [inputState, setInputState] =

View file

@ -5,10 +5,6 @@ import {
EdgeChange, EdgeChange,
Node, Node,
NodeChange, NodeChange,
OnConnect,
OnEdgesChange,
OnNodesChange,
ReactFlowInstance,
addEdge, addEdge,
applyEdgeChanges, applyEdgeChanges,
applyNodeChanges, applyNodeChanges,
@ -20,6 +16,7 @@ import {
sourceHandleType, sourceHandleType,
targetHandleType, targetHandleType,
} from "../types/flow"; } from "../types/flow";
import { FlowStoreType } from "../types/zustand/flow";
import { import {
cleanEdges, cleanEdges,
getHandleId, getHandleId,
@ -27,7 +24,6 @@ import {
scapeJSONParse, scapeJSONParse,
scapedJSONStringfy, scapedJSONStringfy,
} from "../utils/reactflowUtils"; } from "../utils/reactflowUtils";
import { FlowStoreType } from "../types/zustand/flow";
// this is our useStore hook that we can use in our components to get parts of the store and call actions // this is our useStore hook that we can use in our components to get parts of the store and call actions
const useFlowStore = create<FlowStoreType>((set, get) => ({ const useFlowStore = create<FlowStoreType>((set, get) => ({

View file

@ -1,11 +1,11 @@
import { create } from "zustand"; import { create } from "zustand";
import { FlowsManagerStoreType } from "../types/zustand/flowsManager"; import { FlowsManagerStoreType } from "../types/zustand/flowsManager";
let currentFlowId: string = ""; let currentFlowId: string = "";
const useFlowsManagerStore = create<FlowsManagerStoreType>((set, get) => ({ const useFlowsManagerStore = create<FlowsManagerStoreType>((set, get) => ({
flows: [], flows: [],
currentFlow: get().flows[currentFlowId], currentFlow: get().flows[currentFlowId],
})); }));
export default useFlowsManagerStore; export default useFlowsManagerStore;

View file

@ -1,5 +1,4 @@
import { Edge, EdgeChange, Node, NodeChange, XYPosition } from "reactflow"; import { XYPosition } from "reactflow";
import { tweakType } from "../components";
import { FlowType, NodeDataType } from "../flow"; import { FlowType, NodeDataType } from "../flow";
type OnChange<ChangesType> = (changes: ChangesType[]) => void; type OnChange<ChangesType> = (changes: ChangesType[]) => void;

View file

@ -1,4 +1,4 @@
import { Edge, Node, ReactFlowInstance } from "reactflow"; import { Edge, Node } from "reactflow";
import { AlertItemType } from "../alerts"; import { AlertItemType } from "../alerts";
import { APIClassType, APIDataType } from "../api"; import { APIClassType, APIDataType } from "../api";

View file

@ -1,8 +1,8 @@
export type DarkStoreType = { export type DarkStoreType = {
dark: boolean; dark: boolean;
stars: number; stars: number;
gradientIndex: number; gradientIndex: number;
setDark: (dark: boolean) => void; setDark: (dark: boolean) => void;
setStars: (stars: number) => void; setStars: (stars: number) => void;
setGradientIndex: (gradientIndex: number) => void; setGradientIndex: (gradientIndex: number) => void;
}; };

View file

@ -1,25 +1,32 @@
import { Node, Edge, OnEdgesChange, OnNodesChange, ReactFlowInstance, OnConnect } from "reactflow"; import {
Edge,
Node,
OnConnect,
OnEdgesChange,
OnNodesChange,
ReactFlowInstance,
} from "reactflow";
export type FlowStoreType = { export type FlowStoreType = {
reactFlowInstance: ReactFlowInstance | null; reactFlowInstance: ReactFlowInstance | null;
setReactFlowInstance: (newState: ReactFlowInstance) => void; setReactFlowInstance: (newState: ReactFlowInstance) => void;
nodes: Node[]; nodes: Node[];
edges: Edge[]; edges: Edge[];
onNodesChange: OnNodesChange; onNodesChange: OnNodesChange;
onEdgesChange: OnEdgesChange; onEdgesChange: OnEdgesChange;
setNodes: (update: Node[] | ((oldState: Node[]) => Node[])) => void; setNodes: (update: Node[] | ((oldState: Node[]) => Node[])) => void;
setEdges: (update: Edge[] | ((oldState: Edge[]) => Edge[])) => void; setEdges: (update: Edge[] | ((oldState: Edge[]) => Edge[])) => void;
setNode: (id: string, update: Node | ((oldState: Node) => Node)) => void; setNode: (id: string, update: Node | ((oldState: Node) => Node)) => void;
getNode: (id: string) => Node | undefined; getNode: (id: string) => Node | undefined;
onConnect: OnConnect; onConnect: OnConnect;
deleteNode: (nodeId: string | Array<string>) => void; deleteNode: (nodeId: string | Array<string>) => void;
deleteEdge: (edgeId: string | Array<string>) => void; deleteEdge: (edgeId: string | Array<string>) => void;
paste: ( paste: (
selection: { nodes: any; edges: any }, selection: { nodes: any; edges: any },
position: { x: number; y: number; paneX?: number; paneY?: number } position: { x: number; y: number; paneX?: number; paneY?: number }
) => void; ) => void;
isBuilt: boolean; isBuilt: boolean;
setIsBuilt: (isBuilt: boolean) => void; setIsBuilt: (isBuilt: boolean) => void;
isPending: boolean; isPending: boolean;
setPending: (pending: boolean) => void; setPending: (pending: boolean) => void;
}; };

View file

@ -1,8 +1,6 @@
import { XYPosition } from "reactflow"; import { FlowType } from "../../flow";
import { FlowType, NodeDataType } from "../../flow";
import { FlowsState } from "../../tabs";
export type FlowsManagerStoreType = { export type FlowsManagerStoreType = {
flows: Array<FlowType>; flows: Array<FlowType>;
currentFlow: FlowType | undefined; currentFlow: FlowType | undefined;
}; };

View file

@ -148,9 +148,7 @@ export function updateTemplate(
return clonedObject; return clonedObject;
} }
export function updateIds( export function updateIds(newFlow: ReactFlowJsonObject) {
newFlow: ReactFlowJsonObject,
) {
let idsMap = {}; let idsMap = {};
if (newFlow.nodes) if (newFlow.nodes)
@ -280,7 +278,7 @@ export function updateEdges(edges: Edge[]) {
: "stroke-gray-900 ") + " stroke-connection"; : "stroke-gray-900 ") + " stroke-connection";
edge.animated = targetHandleObject.type === "Text"; edge.animated = targetHandleObject.type === "Text";
}); });
}; }
export function addVersionToDuplicates(flow: FlowType, flows: FlowType[]) { export function addVersionToDuplicates(flow: FlowType, flows: FlowType[]) {
const existingNames = flows.map((item) => item.name); const existingNames = flows.map((item) => item.name);
@ -513,13 +511,15 @@ export function getNodeId(nodeType: string) {
return nodeType + "-" + uid(); return nodeType + "-" + uid();
} }
export function getHandleId(source: string, sourceHandle: string, target: string, targetHandle: string){ export function getHandleId(
return "reactflow__edge-" + source: string,
source + sourceHandle: string,
sourceHandle + target: string,
"-" + targetHandle: string
target + ) {
targetHandle; return (
"reactflow__edge-" + source + sourceHandle + "-" + target + targetHandle
);
} }
export function generateFlow( export function generateFlow(