treege 3.0.0-beta.5 → 3.0.0-beta.50
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/LICENSE +18 -12
- package/README.md +313 -52
- package/dist/DefaultInputs-lez0rJ7m.js +1761 -0
- package/dist/ThemeContext-BbA-sJ85.js +1353 -0
- package/dist/editor/components/input/ComboboxWithCreate.d.ts +2 -1
- package/dist/editor/components/styles/EditorStyles.d.ts +2 -0
- package/dist/editor/constants/defaultNode.d.ts +1 -1
- package/dist/editor/constants/edgeTypes.d.ts +3 -2
- package/dist/editor/constants/inputTypeIcons.d.ts +3 -0
- package/dist/editor/constants/nodeSpacing.d.ts +33 -0
- package/dist/editor/constants/nodeTypes.d.ts +4 -5
- package/dist/editor/context/OpenApiContext.d.ts +79 -0
- package/dist/editor/context/TreegeEditorContext.d.ts +60 -1
- package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
- package/dist/editor/features/TreegeEditor/controls/MiniMapControl.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/dialogs/AuthorizeDialog.d.ts +20 -0
- package/dist/editor/features/TreegeEditor/dialogs/ChangeNodeTypeDialog.d.ts +2 -0
- package/dist/editor/features/TreegeEditor/dialogs/DeleteNodeDialog.d.ts +2 -0
- package/dist/editor/features/TreegeEditor/dialogs/HeadersDialog.d.ts +19 -0
- package/dist/editor/features/TreegeEditor/dialogs/OpenApiDialog.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/edges/ConditionalEdge.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/edges/DefaultEdge.d.ts +3 -0
- package/dist/editor/features/TreegeEditor/forms/OptionsSourceForm.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/forms/SubmitConfigForm.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/inputs/ApiUrlCombobox.d.ts +30 -0
- package/dist/editor/features/TreegeEditor/inputs/ComboboxPattern.d.ts +2 -1
- package/dist/editor/features/TreegeEditor/inputs/OptionImageField.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/inputs/SelectNodeGroup.d.ts +22 -1
- package/dist/editor/features/TreegeEditor/layout/AutoLayout.d.ts +15 -0
- package/dist/editor/features/TreegeEditor/nodes/TreegeNode.d.ts +5 -0
- package/dist/editor/features/TreegeEditor/nodes/components/BottomHandleDropdown.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeGroupBadge.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeImage.d.ts +5 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeImageButton.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeInputPreview.d.ts +12 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeLabelInput.d.ts +10 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeMoreMenu.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeRequiredButton.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeStackOrderButtons.d.ts +6 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeTypeBadge.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +4 -2
- package/dist/editor/features/TreegeEditor/panel/AIGeneratorDialog.d.ts +16 -0
- package/dist/editor/features/TreegeEditor/panel/ActionsPanel.d.ts +7 -2
- package/dist/editor/features/TreegeEditor/panel/MultiSelectionPanel.d.ts +7 -0
- package/dist/editor/hooks/useAvailableParentFields.d.ts +13 -0
- package/dist/editor/hooks/useFlowActions.d.ts +6 -2
- package/dist/editor/hooks/useFlowConnections.d.ts +13 -0
- package/dist/editor/hooks/useHistoryStore.d.ts +26 -0
- package/dist/editor/hooks/useIsStackedEdge.d.ts +8 -0
- package/dist/editor/hooks/useNodesSelection.d.ts +5 -5
- package/dist/editor/hooks/useStackPosition.d.ts +14 -0
- package/dist/editor/hooks/useUndoRedo.d.ts +31 -0
- package/dist/editor/types/ai.d.ts +65 -0
- package/dist/editor/types/editor.d.ts +71 -9
- package/dist/editor/types/openapi.d.ts +81 -0
- package/dist/editor/utils/aiFlowGenerator.d.ts +5 -0
- package/dist/editor/utils/dagreLayout.d.ts +8 -0
- package/dist/editor/utils/edge.d.ts +14 -0
- package/dist/editor/utils/groupColor.d.ts +14 -0
- package/dist/editor/utils/image.d.ts +7 -0
- package/dist/editor/utils/inputTypeIcon.d.ts +6 -0
- package/dist/editor/utils/openapi.d.ts +35 -0
- package/dist/editor/utils/stackPositionIndex.d.ts +9 -0
- package/dist/editor-BEhbmVtH.js +5740 -0
- package/dist/editor.js +3 -8
- package/dist/main.js +4 -53
- package/dist/renderer/context/TreegeConfigContext.d.ts +3 -27
- package/dist/renderer/context/TreegeRendererContext.d.ts +100 -2
- package/dist/renderer/features/TreegeRenderer/native/TreegeRenderer.d.ts +19 -11
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultFormWrapper.d.ts +7 -7
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputWrapper.d.ts +9 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputs.d.ts +21 -15
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultStep.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButton.d.ts +9 -7
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButtonWrapper.d.ts +11 -0
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultUI.d.ts +8 -7
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAddressInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAutocompleteInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultCheckboxInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateRangeInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultFileInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHiddenInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHttpInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultNumberInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultPasswordInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultRadioInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSelectInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSwitchInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextareaInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeRangeInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +92 -24
- package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultFormWrapper.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultInputWrapper.d.ts +9 -0
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultStep.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAddressInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAutocompleteInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultCheckboxInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateRangeInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultFileInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHiddenInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHttpInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultNumberInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultPasswordInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultRadioInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSelectInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSubmitInput.d.ts +3 -0
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSwitchInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextAreaInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeRangeInput.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/styles/RendererStyles.d.ts +2 -0
- package/dist/renderer/hooks/useInputOptions.d.ts +28 -0
- package/dist/renderer/hooks/useRenderNode.d.ts +57 -0
- package/dist/renderer/hooks/useSubmitHandler.d.ts +35 -0
- package/dist/renderer/hooks/useTranslate.d.ts +6 -4
- package/dist/renderer/index.d.ts +3 -1
- package/dist/renderer/index.native.d.ts +19 -0
- package/dist/renderer/types/renderer.d.ts +131 -33
- package/dist/renderer/utils/flow.d.ts +1 -18
- package/dist/renderer/utils/form.d.ts +22 -2
- package/dist/renderer/utils/http.d.ts +129 -0
- package/dist/renderer/utils/node.d.ts +18 -1
- package/dist/renderer/utils/sanitize.d.ts +85 -0
- package/dist/renderer/utils/sanitize.native.d.ts +69 -0
- package/dist/renderer/utils/step.d.ts +27 -0
- package/dist/renderer/utils/submit.d.ts +48 -0
- package/dist/renderer-native.d.ts +2 -0
- package/dist/renderer-native.js +3580 -0
- package/dist/renderer.js +3 -46
- package/dist/shared/components/ui/badge.d.ts +2 -2
- package/dist/shared/components/ui/button.d.ts +3 -3
- package/dist/shared/components/ui/collapsible.d.ts +1 -1
- package/dist/shared/components/ui/command.d.ts +1 -1
- package/dist/shared/components/ui/dropdown-menu.d.ts +1 -1
- package/dist/shared/components/ui/field.d.ts +24 -0
- package/dist/shared/components/ui/form.d.ts +1 -1
- package/dist/shared/components/ui/popover.d.ts +4 -2
- package/dist/shared/components/ui/select.d.ts +3 -1
- package/dist/shared/components/ui/sheet.d.ts +1 -1
- package/dist/shared/components/ui/toggle-group.d.ts +7 -0
- package/dist/shared/components/ui/toggle.d.ts +9 -0
- package/dist/shared/components/ui/tooltip.d.ts +1 -1
- package/dist/shared/constants/colors.d.ts +45 -0
- package/dist/shared/constants/inputType.d.ts +1 -0
- package/dist/shared/constants/node.d.ts +0 -1
- package/dist/shared/context/ThemeContext.d.ts +2 -0
- package/dist/shared/context/ThemeContext.native.d.ts +22 -0
- package/dist/shared/hooks/useMediaQuery.d.ts +12 -0
- package/dist/shared/hooks/useThemeColors.d.ts +37 -0
- package/dist/shared/locales/ar.json.d.ts +220 -18
- package/dist/shared/locales/de.json.d.ts +221 -19
- package/dist/shared/locales/en.json.d.ts +222 -20
- package/dist/shared/locales/es.json.d.ts +221 -19
- package/dist/shared/locales/fr.json.d.ts +221 -19
- package/dist/shared/locales/it.json.d.ts +221 -19
- package/dist/shared/locales/pt.json.d.ts +221 -19
- package/dist/shared/types/edge.d.ts +6 -0
- package/dist/shared/types/node.d.ts +109 -7
- package/dist/shared/utils/inputTypeGuards.d.ts +7 -0
- package/dist/shared/utils/nodeTypeGuards.d.ts +1 -6
- package/package.json +48 -22
- package/dist/ThemeContext-D4xMOrdt.js +0 -759
- package/dist/TreegeEditor-B8FP1rKR.js +0 -2153
- package/dist/TreegeRenderer-BOCobRLr.js +0 -1414
- package/dist/editor/features/TreegeEditor/forms/FlowNodeForm.d.ts +0 -2
- package/dist/editor/features/TreegeEditor/inputs/SelectInputType.d.ts +0 -7
- package/dist/editor/features/TreegeEditor/nodes/FlowNode.d.ts +0 -6
- package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +0 -6
- package/dist/editor/features/TreegeEditor/nodes/InputNode.d.ts +0 -6
- package/dist/editor/features/TreegeEditor/nodes/UINode.d.ts +0 -6
- package/dist/editor/hooks/useEdgesSelection.d.ts +0 -11
- package/dist/renderer/features/TreegeRenderer/native/components/DefaultGroup.d.ts +0 -7
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultGroup.d.ts +0 -6
- /package/dist/editor/components/{data-display/logo.d.ts → branding/Logo.d.ts} +0 -0
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { OnConnect, OnConnectEnd, OnEdgesDelete } from '@xyflow/react';
|
|
2
|
+
/**
|
|
3
|
+
* Shape passed to the node-creating actions (`onAddFromHandle`, `onInsertAfter`,
|
|
4
|
+
* and the internal `createNodeAndConnect`). Lets callers seed the new node's
|
|
5
|
+
* `type` and `data` while React Flow handles position, id, etc.
|
|
6
|
+
*/
|
|
7
|
+
export type NodeInit = {
|
|
8
|
+
type: string;
|
|
9
|
+
data?: Record<string, unknown>;
|
|
10
|
+
};
|
|
2
11
|
/**
|
|
3
12
|
* Custom hook to manage flow connections, including connecting nodes,
|
|
4
13
|
* handling connection ends, and deleting edges with conditional logic.
|
|
@@ -8,8 +17,12 @@ declare const useFlowConnections: () => {
|
|
|
8
17
|
source: string;
|
|
9
18
|
target: string;
|
|
10
19
|
}) => boolean;
|
|
20
|
+
moveStackNodeDown: (nodeId: string) => void;
|
|
21
|
+
moveStackNodeUp: (nodeId: string) => void;
|
|
22
|
+
onAddFromHandle: (sourceNodeId: string, nodeInit?: NodeInit) => void;
|
|
11
23
|
onConnect: OnConnect;
|
|
12
24
|
onConnectEnd: OnConnectEnd;
|
|
13
25
|
onEdgesDelete: OnEdgesDelete;
|
|
26
|
+
onInsertAfter: (sourceNodeId: string, nodeInit?: NodeInit) => void;
|
|
14
27
|
};
|
|
15
28
|
export default useFlowConnections;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Edge, Node } from '@xyflow/react';
|
|
2
|
+
type Snapshot = {
|
|
3
|
+
nodes: Node[];
|
|
4
|
+
edges: Edge[];
|
|
5
|
+
};
|
|
6
|
+
type HistoryStore = {
|
|
7
|
+
past: Snapshot[];
|
|
8
|
+
future: Snapshot[];
|
|
9
|
+
pushPast: (snapshot: Snapshot) => void;
|
|
10
|
+
popPast: () => Snapshot | undefined;
|
|
11
|
+
pushFuture: (snapshot: Snapshot) => void;
|
|
12
|
+
popFuture: () => Snapshot | undefined;
|
|
13
|
+
clearFuture: () => void;
|
|
14
|
+
reset: () => void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Zustand store backing the editor's undo/redo history.
|
|
18
|
+
*
|
|
19
|
+
* Holds two stacks of `{ nodes, edges }` snapshots: `past` (states to undo into) and
|
|
20
|
+
* `future` (states to redo into). Both are capped at `MAX_HISTORY` to bound memory.
|
|
21
|
+
*
|
|
22
|
+
* Consumed exclusively by `useUndoRedo` — components should not read or mutate this
|
|
23
|
+
* store directly. Call `reset()` when loading a new flow to drop stale history.
|
|
24
|
+
*/
|
|
25
|
+
declare const useHistoryStore: import('zustand').UseBoundStore<import('zustand').StoreApi<HistoryStore>>;
|
|
26
|
+
export default useHistoryStore;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An edge is "stacked" when it connects two nodes that belong to the same
|
|
3
|
+
* visual chain — i.e. the source has a linear child (position "first" or
|
|
4
|
+
* "middle") and the target has a linear parent (position "middle" or "last").
|
|
5
|
+
* Stacked edges are not rendered: their endpoints touch border-to-border in
|
|
6
|
+
* the layout, making the line redundant.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useIsStackedEdge: (source: string, target: string) => boolean;
|
|
@@ -10,10 +10,10 @@ declare const useNodesSelection: <TNodeData extends TreegeNodeData = TreegeNodeD
|
|
|
10
10
|
nodes: TreegeNode[];
|
|
11
11
|
selectedNode: ({
|
|
12
12
|
id: string;
|
|
13
|
-
position: import('@xyflow/
|
|
13
|
+
position: import('@xyflow/system').XYPosition;
|
|
14
14
|
data: TreegeNodeData;
|
|
15
|
-
sourcePosition?: import('@xyflow/
|
|
16
|
-
targetPosition?: import('@xyflow/
|
|
15
|
+
sourcePosition?: import('@xyflow/system').Position;
|
|
16
|
+
targetPosition?: import('@xyflow/system').Position;
|
|
17
17
|
hidden?: boolean;
|
|
18
18
|
selected?: boolean;
|
|
19
19
|
dragging?: boolean;
|
|
@@ -28,10 +28,10 @@ declare const useNodesSelection: <TNodeData extends TreegeNodeData = TreegeNodeD
|
|
|
28
28
|
initialHeight?: number;
|
|
29
29
|
parentId?: string;
|
|
30
30
|
zIndex?: number;
|
|
31
|
-
extent?: "parent" | import('@xyflow/
|
|
31
|
+
extent?: "parent" | import('@xyflow/system').CoordinateExtent | null;
|
|
32
32
|
expandParent?: boolean;
|
|
33
33
|
ariaLabel?: string;
|
|
34
|
-
origin?: import('@xyflow/
|
|
34
|
+
origin?: import('@xyflow/system').NodeOrigin;
|
|
35
35
|
handles?: import('@xyflow/system').NodeHandle[];
|
|
36
36
|
measured?: {
|
|
37
37
|
width?: number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StackPosition } from '../utils/stackPositionIndex';
|
|
2
|
+
export type StackPositionInfo = {
|
|
3
|
+
position: StackPosition;
|
|
4
|
+
isStackHead: boolean;
|
|
5
|
+
isStackTail: boolean;
|
|
6
|
+
isStackMiddle: boolean;
|
|
7
|
+
isStackSingle: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Returns the stack position of `nodeId` plus convenience booleans derived from
|
|
11
|
+
* it. Uses a shallow equality selector so consumers only re-render when one of
|
|
12
|
+
* the booleans actually flips, not on every edge mutation.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useStackPosition: (nodeId: string) => StackPositionInfo;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { OnBeforeDelete } from '@xyflow/react';
|
|
2
|
+
type UseUndoRedoOptions = {
|
|
3
|
+
enableShortcuts?: boolean;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Snapshot-based undo/redo for the ReactFlow editor.
|
|
7
|
+
*
|
|
8
|
+
* Maintains `past` / `future` stacks of `{ nodes, edges }` snapshots in `useHistoryStore`.
|
|
9
|
+
* Callers must invoke `takeSnapshot()` before any mutation they want to be undoable
|
|
10
|
+
* (drag start, node/edge creation, deletion, type change, …); the hook itself does
|
|
11
|
+
* not observe ReactFlow state changes.
|
|
12
|
+
*
|
|
13
|
+
* @param enableShortcuts - When true, binds Cmd/Ctrl+Z (undo) and Cmd/Ctrl+Shift+Z /
|
|
14
|
+
* Cmd/Ctrl+Y (redo) to the window. Should be enabled in a single root component
|
|
15
|
+
* (e.g. the editor) to avoid duplicate listeners.
|
|
16
|
+
*
|
|
17
|
+
* @returns
|
|
18
|
+
* - `takeSnapshot`: pushes the current flow onto `past` and clears `future`.
|
|
19
|
+
* - `onBeforeDelete`: adapter typed for ReactFlow's `onBeforeDelete` prop.
|
|
20
|
+
* - `undo` / `redo`: restore the previous / next snapshot.
|
|
21
|
+
* - `canUndo` / `canRedo`: booleans driven by stack length, suitable for disabling UI buttons.
|
|
22
|
+
*/
|
|
23
|
+
declare const useUndoRedo: ({ enableShortcuts }?: UseUndoRedoOptions) => {
|
|
24
|
+
canRedo: boolean;
|
|
25
|
+
canUndo: boolean;
|
|
26
|
+
onBeforeDelete: OnBeforeDelete;
|
|
27
|
+
redo: () => void;
|
|
28
|
+
takeSnapshot: () => void;
|
|
29
|
+
undo: () => void;
|
|
30
|
+
};
|
|
31
|
+
export default useUndoRedo;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Edge, Node } from '@xyflow/react';
|
|
2
|
+
/**
|
|
3
|
+
* AI Provider types for tree generation
|
|
4
|
+
*/
|
|
5
|
+
export type AIProvider = "gemini" | "openai" | "deepseek" | "claude";
|
|
6
|
+
/**
|
|
7
|
+
* AI Configuration for tree generation
|
|
8
|
+
*/
|
|
9
|
+
export interface AIConfig {
|
|
10
|
+
/**
|
|
11
|
+
* The AI provider to use
|
|
12
|
+
* @default "gemini"
|
|
13
|
+
*/
|
|
14
|
+
provider?: AIProvider;
|
|
15
|
+
/**
|
|
16
|
+
* API key for the selected provider
|
|
17
|
+
*/
|
|
18
|
+
apiKey: string;
|
|
19
|
+
/**
|
|
20
|
+
* Optional model name override
|
|
21
|
+
* - Gemini: "gemini-2.5-flash" (default), "gemini-2.5-pro-preview-03-25"
|
|
22
|
+
* - OpenAI: "gpt-4o-mini" (default), "gpt-4o", "gpt-3.5-turbo"
|
|
23
|
+
* - DeepSeek: "deepseek-chat" (default)
|
|
24
|
+
* - Claude: "claude-3-5-haiku-20241022" (default), "claude-3-5-sonnet-20241022"
|
|
25
|
+
*/
|
|
26
|
+
model?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Temperature for generation (0-1, default: 0.7)
|
|
29
|
+
*/
|
|
30
|
+
temperature?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* AI Generation request
|
|
34
|
+
*/
|
|
35
|
+
export interface AIGenerationRequest {
|
|
36
|
+
/**
|
|
37
|
+
* User prompt describing the desired tree/form
|
|
38
|
+
*/
|
|
39
|
+
prompt: string;
|
|
40
|
+
/**
|
|
41
|
+
* AI configuration
|
|
42
|
+
*/
|
|
43
|
+
config: AIConfig;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* AI Generation response
|
|
47
|
+
*/
|
|
48
|
+
export interface AIGenerationResponse {
|
|
49
|
+
/**
|
|
50
|
+
* Generated nodes
|
|
51
|
+
*/
|
|
52
|
+
nodes: Node[];
|
|
53
|
+
/**
|
|
54
|
+
* Generated edges
|
|
55
|
+
*/
|
|
56
|
+
edges: Edge[];
|
|
57
|
+
/**
|
|
58
|
+
* Optional explanation or metadata
|
|
59
|
+
*/
|
|
60
|
+
metadata?: {
|
|
61
|
+
explanation?: string;
|
|
62
|
+
nodesCount?: number;
|
|
63
|
+
edgesCount?: number;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
import { Edge, Node } from '@xyflow/react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { AIConfig } from './ai';
|
|
4
|
+
import { OpenApiDocument } from './openapi';
|
|
5
|
+
import { Flow, HttpHeader } from '../../shared/types/node';
|
|
6
|
+
export interface ExtraMenuItem {
|
|
4
7
|
/**
|
|
5
|
-
*
|
|
6
|
-
* Note: Individual defaultNodes/defaultEdges props take precedence over this.
|
|
8
|
+
* Label displayed in the menu item.
|
|
7
9
|
*/
|
|
8
|
-
|
|
10
|
+
label: ReactNode;
|
|
9
11
|
/**
|
|
10
|
-
*
|
|
12
|
+
* Optional icon rendered before the label.
|
|
11
13
|
*/
|
|
12
|
-
|
|
14
|
+
icon?: ReactNode;
|
|
13
15
|
/**
|
|
14
|
-
*
|
|
16
|
+
* Callback triggered when the menu item is clicked.
|
|
15
17
|
*/
|
|
16
|
-
|
|
18
|
+
onClick?: () => void;
|
|
19
|
+
/**
|
|
20
|
+
* When true, styles the item as destructive.
|
|
21
|
+
*/
|
|
22
|
+
destructive?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface TreegeEditorProps {
|
|
25
|
+
/**
|
|
26
|
+
* Default flow structure containing combined nodes and edges.
|
|
27
|
+
* Note: Individual defaultNodes/defaultEdges props take precedence over this.
|
|
28
|
+
*/
|
|
29
|
+
flow?: Flow | null;
|
|
17
30
|
/**
|
|
18
31
|
* Callback function triggered when exporting JSON data.
|
|
19
32
|
*/
|
|
@@ -34,4 +47,53 @@ export interface TreegeEditorProps {
|
|
|
34
47
|
* Language for the editor interface.
|
|
35
48
|
*/
|
|
36
49
|
language?: string;
|
|
50
|
+
/**
|
|
51
|
+
* AI configuration for tree generation
|
|
52
|
+
*/
|
|
53
|
+
aiConfig?: AIConfig;
|
|
54
|
+
/**
|
|
55
|
+
* Additional CSS class names for custom styling.
|
|
56
|
+
*/
|
|
57
|
+
className?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Extra menu items to append to the "more" dropdown of the actions panel.
|
|
60
|
+
*/
|
|
61
|
+
extraMenuItems?: ExtraMenuItem[];
|
|
62
|
+
/**
|
|
63
|
+
* OpenAPI 3.x source used to power URL/route suggestions inside HTTP and
|
|
64
|
+
* Options-source forms, and to drive the Authorize flow. Accepts either:
|
|
65
|
+
* - a pre-parsed `OpenApiDocument` object
|
|
66
|
+
* - a URL string (the editor fetches it on mount and toasts on failure)
|
|
67
|
+
*
|
|
68
|
+
* Users can still load one at runtime via the editor's "OpenAPI" button.
|
|
69
|
+
*/
|
|
70
|
+
openApi?: OpenApiDocument | string;
|
|
71
|
+
/**
|
|
72
|
+
* Base URL used for OpenAPI route resolution. When set, it takes precedence
|
|
73
|
+
* over the document's `servers[0].url` — useful when the spec points at a
|
|
74
|
+
* different environment than the one to call (e.g. staging vs prod).
|
|
75
|
+
*/
|
|
76
|
+
openApiBaseUrl?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Global HTTP headers applied to in-editor requests (e.g. the "Detect
|
|
79
|
+
* fields" button in `OptionsSourceForm`). Pass the same value you give to
|
|
80
|
+
* `TreegeRenderer` so editor-time previews use the same auth and headers
|
|
81
|
+
* that the runtime form will use.
|
|
82
|
+
*/
|
|
83
|
+
headers?: HttpHeader[];
|
|
84
|
+
/**
|
|
85
|
+
* Called when the user submits the Authorize dialog. Receives the resulting
|
|
86
|
+
* HTTP headers (`Authorization`, API key headers…). The consumer is expected
|
|
87
|
+
* to forward those headers to `TreegeRenderer` (or `TreegeConfigProvider`)
|
|
88
|
+
* via its `headers` prop so every request issued by the form is authenticated.
|
|
89
|
+
*/
|
|
90
|
+
onAuthorize?: (headers: HttpHeader[]) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Called whenever the user edits the global headers via the editor's
|
|
93
|
+
* built-in "Global headers" dialog. The component is controlled — the
|
|
94
|
+
* parent is expected to update its `headers` state in response and pass
|
|
95
|
+
* the new list back via the `headers` prop, so every editor-time and
|
|
96
|
+
* runtime request reflects the change.
|
|
97
|
+
*/
|
|
98
|
+
onHeadersChange?: (headers: HttpHeader[]) => void;
|
|
37
99
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal OpenAPI 3.x types — only what the editor needs to suggest API
|
|
3
|
+
* routes and authenticate against an API. Not a full OpenAPI definition.
|
|
4
|
+
*
|
|
5
|
+
* Swagger 2.0 (`swagger: "2.0"`) is intentionally not supported.
|
|
6
|
+
*/
|
|
7
|
+
export interface OpenApiDocument {
|
|
8
|
+
openapi: string;
|
|
9
|
+
info?: {
|
|
10
|
+
title?: string;
|
|
11
|
+
version?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
};
|
|
14
|
+
servers?: Array<{
|
|
15
|
+
url: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
}>;
|
|
18
|
+
paths: Record<string, OpenApiPathItem | undefined>;
|
|
19
|
+
components?: {
|
|
20
|
+
securitySchemes?: Record<string, OpenApiSecurityScheme | undefined>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface OpenApiPathItem {
|
|
24
|
+
get?: OpenApiOperation;
|
|
25
|
+
put?: OpenApiOperation;
|
|
26
|
+
post?: OpenApiOperation;
|
|
27
|
+
delete?: OpenApiOperation;
|
|
28
|
+
patch?: OpenApiOperation;
|
|
29
|
+
}
|
|
30
|
+
export interface OpenApiOperation {
|
|
31
|
+
summary?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
tags?: string[];
|
|
34
|
+
operationId?: string;
|
|
35
|
+
}
|
|
36
|
+
/** HTTP Bearer auth scheme. */
|
|
37
|
+
export interface OpenApiHttpBearerScheme {
|
|
38
|
+
type: "http";
|
|
39
|
+
scheme: "bearer";
|
|
40
|
+
bearerFormat?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Header-based API key auth scheme. */
|
|
44
|
+
export interface OpenApiApiKeyHeaderScheme {
|
|
45
|
+
type: "apiKey";
|
|
46
|
+
in: "header";
|
|
47
|
+
name: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* OAuth2 with the `password` grant. The user provides username + password
|
|
52
|
+
* directly, the editor exchanges them at `tokenUrl` and uses the returned
|
|
53
|
+
* access token as a Bearer header.
|
|
54
|
+
*
|
|
55
|
+
* Other OAuth2 flows (`authorization_code`, `client_credentials`, `implicit`)
|
|
56
|
+
* are out of scope — they require browser redirects, server-side state, or
|
|
57
|
+
* PKCE.
|
|
58
|
+
*/
|
|
59
|
+
export interface OpenApiOAuth2PasswordScheme {
|
|
60
|
+
type: "oauth2";
|
|
61
|
+
/** Resolved against `servers[0].url` when the spec uses a relative path. */
|
|
62
|
+
tokenUrl: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Security schemes the editor supports today. Other schemes (OAuth2 flows
|
|
67
|
+
* other than password, cookie/query API keys, openIdConnect) are filtered
|
|
68
|
+
* out at extraction time.
|
|
69
|
+
*/
|
|
70
|
+
export type OpenApiSecurityScheme = OpenApiHttpBearerScheme | OpenApiApiKeyHeaderScheme | OpenApiOAuth2PasswordScheme;
|
|
71
|
+
export type ApiRouteMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
72
|
+
/**
|
|
73
|
+
* One operation extracted from an OpenAPI document, flattened to a single
|
|
74
|
+
* (method, path) record for easy listing.
|
|
75
|
+
*/
|
|
76
|
+
export interface ApiRoute {
|
|
77
|
+
method: ApiRouteMethod;
|
|
78
|
+
path: string;
|
|
79
|
+
summary?: string;
|
|
80
|
+
operationId?: string;
|
|
81
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Edge, Node } from '@xyflow/react';
|
|
2
|
+
export type LayoutDirection = "TB" | "LR";
|
|
3
|
+
export interface LayoutOptions {
|
|
4
|
+
direction?: LayoutDirection;
|
|
5
|
+
horizontalSpacing?: number;
|
|
6
|
+
verticalSpacing?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const getLayoutedElements: (nodes: Node[], edges: Edge[], options?: LayoutOptions) => Node[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Edge } from '@xyflow/react';
|
|
2
|
+
/**
|
|
3
|
+
* Re-normalize outgoing edges from a set of affected parent nodes: if a parent
|
|
4
|
+
* now has a single remaining child, convert its outgoing edge back to a
|
|
5
|
+
* "default" type and drop condition-specific data fields.
|
|
6
|
+
*
|
|
7
|
+
* Used after edge or node deletions to keep conditional edges in sync with the
|
|
8
|
+
* presence of siblings.
|
|
9
|
+
*
|
|
10
|
+
* @param edges - The edges remaining after deletion
|
|
11
|
+
* @param affectedParents - Source node IDs whose children changed
|
|
12
|
+
* @returns A new edges array with affected edges normalized
|
|
13
|
+
*/
|
|
14
|
+
export declare const normalizeConditionalEdges: (edges: Edge[], affectedParents: Set<string>) => Edge[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic color for a group, derived from its id.
|
|
3
|
+
*
|
|
4
|
+
* Why HSL + inline style (rather than a Tailwind class):
|
|
5
|
+
* Tailwind purges classes at build time and can't synthesize `bg-{color}`
|
|
6
|
+
* from a runtime hash. Picking from a fixed palette would cap the number of
|
|
7
|
+
* distinguishable groups; HSL with a hashed hue gives effectively unlimited
|
|
8
|
+
* distinct, stable colors with no Tailwind-side configuration.
|
|
9
|
+
*
|
|
10
|
+
* Saturation/lightness are fixed (65% / 45%) so every group lands in the
|
|
11
|
+
* same readable, mid-contrast band on both light and dark themes — only the
|
|
12
|
+
* hue varies between groups.
|
|
13
|
+
*/
|
|
14
|
+
export declare const getGroupColor: (groupId?: string) => string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const MAX_IMAGE_INPUT_BYTES: number;
|
|
2
|
+
/**
|
|
3
|
+
* Converts an image file to a resized JPEG base64 data URL.
|
|
4
|
+
* Rejects files that are not images or exceed MAX_IMAGE_INPUT_BYTES.
|
|
5
|
+
* Dimensions are capped at MAX_DIMENSION × MAX_DIMENSION to keep the JSON small.
|
|
6
|
+
*/
|
|
7
|
+
export declare const imageFileToOptimizedDataUrl: (file: File) => Promise<string>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ApiRoute, OpenApiDocument, OpenApiSecurityScheme } from '../types/openapi';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard validating that `value` is a usable OpenAPI 3.x document.
|
|
4
|
+
* Rejects 2.0 (Swagger) since we don't support it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isOpenApi3Document: (value: unknown) => value is OpenApiDocument;
|
|
7
|
+
/**
|
|
8
|
+
* Load an OpenAPI document from either a remote URL or a raw JSON string.
|
|
9
|
+
* Throws when the input is empty, unreachable, malformed JSON, or not an
|
|
10
|
+
* OpenAPI 3.x document.
|
|
11
|
+
*/
|
|
12
|
+
export declare const loadOpenApiDocument: (input: string) => Promise<OpenApiDocument>;
|
|
13
|
+
/**
|
|
14
|
+
* Flatten every (method, path) tuple defined in the document, preserving
|
|
15
|
+
* the path declaration order.
|
|
16
|
+
*/
|
|
17
|
+
export declare const extractApiRoutes: (doc: OpenApiDocument) => ApiRoute[];
|
|
18
|
+
/** Returns the first declared server URL (with any trailing slash trimmed). */
|
|
19
|
+
export declare const getBaseUrl: (doc: OpenApiDocument) => string;
|
|
20
|
+
/** Resolve a path to a full URL using the document's first server. */
|
|
21
|
+
export declare const resolveRouteUrl: (doc: OpenApiDocument, path: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Extract every supported security scheme from the document. Schemes other
|
|
24
|
+
* than `http+bearer` and `apiKey-in-header` are silently dropped — they're
|
|
25
|
+
* out of MVP scope.
|
|
26
|
+
*/
|
|
27
|
+
export declare const extractSecuritySchemes: (doc: OpenApiDocument) => Array<{
|
|
28
|
+
name: string;
|
|
29
|
+
scheme: OpenApiSecurityScheme;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Resolve a `tokenUrl` (which the OpenAPI spec sometimes leaves relative)
|
|
33
|
+
* against the document's first declared server URL.
|
|
34
|
+
*/
|
|
35
|
+
export declare const resolveTokenUrl: (tokenUrl: string, doc: OpenApiDocument) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Edge } from '@xyflow/react';
|
|
2
|
+
export type StackPosition = "single" | "first" | "middle" | "last";
|
|
3
|
+
/**
|
|
4
|
+
* Memoizes the positions map keyed by the edges array reference. React Flow
|
|
5
|
+
* keeps that reference stable between unrelated updates (drag, selection, …),
|
|
6
|
+
* so selectors that read from this map effectively perform a Map lookup
|
|
7
|
+
* outside of edge mutations.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getPositions: (edges: Edge[]) => Map<string, StackPosition>;
|