@motiadev/workbench 0.0.6 → 0.0.7-build.20250529212805
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 +21 -0
- package/README.md +95 -40
- package/dist/README.md +105 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.html +31 -0
- package/dist/index.js +0 -1
- package/dist/middleware.d.ts +2 -2
- package/dist/middleware.js +10 -17
- package/dist/postcss.config.mjs +9 -0
- package/dist/src/components/app-sidebar.d.ts +0 -1
- package/dist/src/components/app-sidebar.js +15 -8
- package/dist/src/components/endpoints/endpoint-badge.d.ts +10 -0
- package/dist/src/components/endpoints/endpoint-badge.js +22 -0
- package/dist/src/components/endpoints/endpoint-call.d.ts +8 -0
- package/dist/src/components/endpoints/endpoint-call.js +57 -0
- package/dist/src/components/endpoints/endpoints.d.ts +1 -0
- package/dist/src/components/endpoints/endpoints.js +34 -0
- package/dist/src/components/endpoints/hooks/use-get-endpoints.d.ts +15 -0
- package/dist/src/components/endpoints/hooks/use-get-endpoints.js +8 -0
- package/dist/src/components/endpoints/hooks/use-json-schema-to-json.d.ts +4 -0
- package/dist/src/components/endpoints/hooks/use-json-schema-to-json.js +11 -0
- package/dist/src/components/endpoints/hooks/use-path-params.d.ts +1 -0
- package/dist/src/components/endpoints/hooks/use-path-params.js +4 -0
- package/dist/src/components/endpoints/hooks/use-state-stream.d.ts +4 -0
- package/dist/src/components/endpoints/hooks/use-state-stream.js +8 -0
- package/dist/src/components/endpoints/hooks/utils.d.ts +1 -0
- package/dist/src/components/endpoints/hooks/utils.js +29 -0
- package/dist/src/components/endpoints/response-body.d.ts +7 -0
- package/dist/src/components/endpoints/response-body.js +6 -0
- package/dist/src/components/endpoints/selected-endpoint.d.ts +7 -0
- package/dist/src/components/endpoints/selected-endpoint.js +7 -0
- package/dist/src/components/{log-console.d.ts → logs/log-console.d.ts} +0 -1
- package/dist/src/components/logs/log-console.js +69 -0
- package/dist/src/components/logs/log-detail.d.ts +8 -0
- package/dist/src/components/logs/log-detail.js +15 -0
- package/dist/src/components/logs/log-field.d.ts +8 -0
- package/dist/src/components/logs/log-field.js +20 -0
- package/dist/src/components/{log-level-badge.d.ts → logs/log-level-badge.d.ts} +2 -1
- package/dist/src/components/{log-level-badge.js → logs/log-level-badge.js} +2 -2
- package/dist/src/components/logs/log-level-dot.d.ts +4 -0
- package/dist/src/components/logs/log-level-dot.js +17 -0
- package/dist/src/components/logs/logs.d.ts +1 -0
- package/dist/src/components/logs/logs.js +18 -0
- package/dist/src/components/root-motia.d.ts +2 -0
- package/dist/src/components/root-motia.js +5 -0
- package/dist/src/components/states/hooks/states-hooks.d.ts +3 -0
- package/dist/src/components/states/hooks/states-hooks.js +36 -0
- package/dist/src/components/states/state-detail.d.ts +7 -0
- package/dist/src/components/states/state-detail.js +12 -0
- package/dist/src/components/states/state-value.d.ts +8 -0
- package/dist/src/components/states/state-value.js +51 -0
- package/dist/src/components/states/states.d.ts +1 -0
- package/dist/src/components/states/states.js +21 -0
- package/dist/src/components/ui/badge.d.ts +3 -4
- package/dist/src/components/ui/badge.js +4 -4
- package/dist/src/components/ui/button.d.ts +2 -3
- package/dist/src/components/ui/button.js +2 -3
- package/dist/src/components/ui/collapsible.d.ts +1 -2
- package/dist/src/components/ui/collapsible.js +1 -1
- package/dist/src/components/ui/dialog.d.ts +2 -3
- package/dist/src/components/ui/dialog.js +12 -12
- package/dist/src/components/ui/dropdown-menu.d.ts +25 -0
- package/dist/src/components/ui/dropdown-menu.js +50 -0
- package/dist/src/components/ui/input.d.ts +0 -1
- package/dist/src/components/ui/label.d.ts +3 -4
- package/dist/src/components/ui/label.js +6 -6
- package/dist/src/components/ui/select.d.ts +2 -3
- package/dist/src/components/ui/select.js +14 -15
- package/dist/src/components/ui/separator.d.ts +0 -1
- package/dist/src/components/ui/sheet.d.ts +1 -2
- package/dist/src/components/ui/sheet.js +2 -2
- package/dist/src/components/ui/sidebar.d.ts +12 -67
- package/dist/src/components/ui/sidebar.js +14 -219
- package/dist/src/components/ui/skeleton.d.ts +1 -1
- package/dist/src/components/ui/switch.d.ts +2 -3
- package/dist/src/components/ui/switch.js +4 -4
- package/dist/src/components/ui/table.d.ts +0 -1
- package/dist/src/components/ui/table.js +1 -1
- package/dist/src/components/ui/textarea.d.ts +1 -2
- package/dist/src/components/ui/textarea.js +4 -4
- package/dist/src/components/ui/theme-toggle.d.ts +2 -0
- package/dist/src/components/ui/theme-toggle.js +11 -0
- package/dist/src/components/ui/tooltip.d.ts +0 -1
- package/dist/src/hooks/use-debounced.d.ts +1 -0
- package/dist/src/hooks/use-debounced.js +18 -0
- package/dist/src/hooks/use-list-flows.d.ts +0 -2
- package/dist/src/hooks/use-list-flows.js +6 -10
- package/dist/src/hooks/use-log-listener.d.ts +1 -6
- package/dist/src/hooks/use-log-listener.js +3 -18
- package/dist/src/hooks/use-mobile.d.ts +0 -1
- package/dist/src/hooks/use-theme.d.ts +6 -0
- package/dist/src/hooks/use-theme.js +28 -0
- package/dist/src/index.css +169 -0
- package/dist/src/lib/utils.d.ts +0 -1
- package/dist/src/main.d.ts +0 -8
- package/dist/src/main.js +11 -7
- package/dist/src/publicComponents/api-node.d.ts +2 -5
- package/dist/src/publicComponents/api-node.js +3 -3
- package/dist/src/publicComponents/base-handle.d.ts +1 -1
- package/dist/src/publicComponents/base-handle.js +5 -2
- package/dist/src/publicComponents/base-node.d.ts +5 -5
- package/dist/src/publicComponents/base-node.js +13 -8
- package/dist/src/publicComponents/colorMap.d.ts +6 -0
- package/dist/src/publicComponents/colorMap.js +6 -0
- package/dist/src/publicComponents/components/header-bar.d.ts +11 -0
- package/dist/src/publicComponents/components/header-bar.js +15 -0
- package/dist/src/publicComponents/cron-node.d.ts +2 -0
- package/dist/src/publicComponents/cron-node.js +7 -0
- package/dist/src/publicComponents/emits.d.ts +1 -1
- package/dist/src/publicComponents/emits.js +2 -2
- package/dist/src/publicComponents/event-node.d.ts +0 -2
- package/dist/src/publicComponents/event-node.js +3 -5
- package/dist/src/publicComponents/node-details.d.ts +17 -0
- package/dist/src/publicComponents/node-details.js +19 -0
- package/dist/src/publicComponents/node-props.d.ts +5 -3
- package/dist/src/publicComponents/noop-node.d.ts +0 -1
- package/dist/src/publicComponents/noop-node.js +1 -1
- package/dist/src/publicComponents/subscribe.d.ts +2 -3
- package/dist/src/publicComponents/subscribe.js +2 -2
- package/dist/src/route-wrapper.d.ts +2 -4
- package/dist/src/route-wrapper.js +2 -2
- package/dist/src/routes/endpoints-page.d.ts +1 -0
- package/dist/src/routes/endpoints-page.js +5 -0
- package/dist/src/routes/flow.d.ts +1 -0
- package/dist/src/routes/flow.js +22 -0
- package/dist/src/routes/index.d.ts +1 -2
- package/dist/src/routes/index.js +5 -8
- package/dist/src/routes/logs-page.d.ts +1 -0
- package/dist/src/routes/logs-page.js +12 -0
- package/dist/src/routes/states-page.d.ts +1 -0
- package/dist/src/routes/states-page.js +5 -0
- package/dist/src/stores/use-logs.d.ts +3 -2
- package/dist/src/stores/use-logs.js +52 -6
- package/dist/src/views/flow/arrow-head.d.ts +2 -2
- package/dist/src/views/flow/arrow-head.js +5 -1
- package/dist/src/views/flow/base-edge.d.ts +0 -1
- package/dist/src/views/flow/base-edge.js +25 -10
- package/dist/src/views/flow/flow-loader.d.ts +0 -1
- package/dist/src/views/flow/flow-loader.js +1 -1
- package/dist/src/views/flow/flow-view.d.ts +7 -2
- package/dist/src/views/flow/flow-view.js +44 -20
- package/dist/src/views/flow/hooks/use-get-flow-state.d.ts +14 -5
- package/dist/src/views/flow/hooks/use-get-flow-state.js +17 -8
- package/dist/src/views/flow/hooks/use-organize-nodes.d.ts +0 -1
- package/dist/src/views/flow/hooks/use-save-workflow-config.d.ts +9 -0
- package/dist/src/views/flow/hooks/use-save-workflow-config.js +23 -0
- package/dist/src/views/flow/legend.d.ts +3 -3
- package/dist/src/views/flow/legend.js +49 -39
- package/dist/src/views/flow/node-organizer.d.ts +1 -1
- package/dist/src/views/flow/node-organizer.js +4 -2
- package/dist/src/views/flow/nodes/api-flow-node.d.ts +0 -1
- package/dist/src/views/flow/nodes/event-flow-node.d.ts +0 -1
- package/dist/src/views/flow/nodes/language-indicator.d.ts +0 -1
- package/dist/src/views/flow/nodes/language-indicator.js +7 -7
- package/dist/src/views/flow/nodes/nodes.types.d.ts +39 -6
- package/dist/src/views/flow/nodes/noop-flow-node.d.ts +0 -1
- package/dist/tailwind.config.js +9 -77
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/tsconfig.node.tsbuildinfo +1 -1
- package/package.json +36 -42
- package/postcss.config.mjs +9 -0
- package/dist/index.d.ts.map +0 -1
- package/dist/middleware.d.ts.map +0 -1
- package/dist/src/components/app-sidebar.d.ts.map +0 -1
- package/dist/src/components/log-console.d.ts.map +0 -1
- package/dist/src/components/log-console.js +0 -20
- package/dist/src/components/log-level-badge.d.ts.map +0 -1
- package/dist/src/components/ui/badge.d.ts.map +0 -1
- package/dist/src/components/ui/button.d.ts.map +0 -1
- package/dist/src/components/ui/collapsible.d.ts.map +0 -1
- package/dist/src/components/ui/dialog.d.ts.map +0 -1
- package/dist/src/components/ui/input.d.ts.map +0 -1
- package/dist/src/components/ui/label.d.ts.map +0 -1
- package/dist/src/components/ui/select.d.ts.map +0 -1
- package/dist/src/components/ui/separator.d.ts.map +0 -1
- package/dist/src/components/ui/sheet.d.ts.map +0 -1
- package/dist/src/components/ui/sidebar.d.ts.map +0 -1
- package/dist/src/components/ui/skeleton.d.ts.map +0 -1
- package/dist/src/components/ui/switch.d.ts.map +0 -1
- package/dist/src/components/ui/table.d.ts.map +0 -1
- package/dist/src/components/ui/textarea.d.ts.map +0 -1
- package/dist/src/components/ui/tooltip.d.ts.map +0 -1
- package/dist/src/hooks/use-list-flows.d.ts.map +0 -1
- package/dist/src/hooks/use-log-listener.d.ts.map +0 -1
- package/dist/src/hooks/use-mobile.d.ts.map +0 -1
- package/dist/src/lib/utils.d.ts.map +0 -1
- package/dist/src/main.d.ts.map +0 -1
- package/dist/src/publicComponents/api-node.d.ts.map +0 -1
- package/dist/src/publicComponents/base-handle.d.ts.map +0 -1
- package/dist/src/publicComponents/base-node.d.ts.map +0 -1
- package/dist/src/publicComponents/emits.d.ts.map +0 -1
- package/dist/src/publicComponents/event-node.d.ts.map +0 -1
- package/dist/src/publicComponents/node-props.d.ts.map +0 -1
- package/dist/src/publicComponents/noop-node.d.ts.map +0 -1
- package/dist/src/publicComponents/subscribe.d.ts.map +0 -1
- package/dist/src/route-wrapper.d.ts.map +0 -1
- package/dist/src/routeTree.gen.d.ts +0 -53
- package/dist/src/routeTree.gen.d.ts.map +0 -1
- package/dist/src/routeTree.gen.js +0 -45
- package/dist/src/routes/__root.d.ts +0 -2
- package/dist/src/routes/__root.d.ts.map +0 -1
- package/dist/src/routes/__root.js +0 -15
- package/dist/src/routes/flow/$id.d.ts +0 -4
- package/dist/src/routes/flow/$id.d.ts.map +0 -1
- package/dist/src/routes/flow/$id.js +0 -15
- package/dist/src/routes/index.d.ts.map +0 -1
- package/dist/src/stores/use-logs.d.ts.map +0 -1
- package/dist/src/views/flow/arrow-head.d.ts.map +0 -1
- package/dist/src/views/flow/base-edge.d.ts.map +0 -1
- package/dist/src/views/flow/flow-loader.d.ts.map +0 -1
- package/dist/src/views/flow/flow-view.d.ts.map +0 -1
- package/dist/src/views/flow/hooks/use-get-flow-state.d.ts.map +0 -1
- package/dist/src/views/flow/hooks/use-organize-nodes.d.ts.map +0 -1
- package/dist/src/views/flow/legend.d.ts.map +0 -1
- package/dist/src/views/flow/node-organizer.d.ts.map +0 -1
- package/dist/src/views/flow/nodes/api-flow-node.d.ts.map +0 -1
- package/dist/src/views/flow/nodes/event-flow-node.d.ts.map +0 -1
- package/dist/src/views/flow/nodes/json-schema-form.d.ts +0 -9
- package/dist/src/views/flow/nodes/json-schema-form.d.ts.map +0 -1
- package/dist/src/views/flow/nodes/json-schema-form.js +0 -35
- package/dist/src/views/flow/nodes/language-indicator.d.ts.map +0 -1
- package/dist/src/views/flow/nodes/nodes.types.d.ts.map +0 -1
- package/dist/src/views/flow/nodes/noop-flow-node.d.ts.map +0 -1
- package/dist/tailwind.config.d.ts +0 -4
- package/dist/tailwind.config.d.ts.map +0 -1
- package/dist/vite.config.d.ts +0 -11
- package/dist/vite.config.d.ts.map +0 -1
- package/dist/vite.config.js +0 -18
- package/eslint.config.js +0 -28
- package/index.html +0 -19
- package/index.tsx +0 -10
- package/middleware.ts +0 -48
- package/postcss.config.js +0 -6
- package/src/assets/.empty +0 -0
- package/src/components/app-sidebar.tsx +0 -55
- package/src/components/log-console.tsx +0 -76
- package/src/components/log-level-badge.tsx +0 -12
- package/src/components/ui/badge.tsx +0 -31
- package/src/components/ui/button.tsx +0 -47
- package/src/components/ui/collapsible.tsx +0 -9
- package/src/components/ui/dialog.tsx +0 -120
- package/src/components/ui/input.tsx +0 -21
- package/src/components/ui/label.tsx +0 -26
- package/src/components/ui/select.tsx +0 -157
- package/src/components/ui/separator.tsx +0 -22
- package/src/components/ui/sheet.tsx +0 -106
- package/src/components/ui/sidebar.tsx +0 -637
- package/src/components/ui/skeleton.tsx +0 -7
- package/src/components/ui/switch.tsx +0 -27
- package/src/components/ui/table.tsx +0 -76
- package/src/components/ui/textarea.tsx +0 -22
- package/src/components/ui/tooltip.tsx +0 -32
- package/src/hooks/use-list-flows.tsx +0 -20
- package/src/hooks/use-log-listener.tsx +0 -32
- package/src/hooks/use-mobile.tsx +0 -19
- package/src/index.css +0 -190
- package/src/lib/utils.ts +0 -6
- package/src/main.tsx +0 -28
- package/src/publicComponents/api-node.tsx +0 -28
- package/src/publicComponents/base-handle.tsx +0 -43
- package/src/publicComponents/base-node.tsx +0 -57
- package/src/publicComponents/emits.tsx +0 -22
- package/src/publicComponents/event-node.tsx +0 -36
- package/src/publicComponents/node-props.tsx +0 -15
- package/src/publicComponents/noop-node.tsx +0 -21
- package/src/publicComponents/subscribe.tsx +0 -19
- package/src/route-wrapper.tsx +0 -9
- package/src/routeTree.gen.ts +0 -109
- package/src/routes/__root.tsx +0 -26
- package/src/routes/flow/$id.tsx +0 -21
- package/src/routes/index.tsx +0 -13
- package/src/stores/use-logs.ts +0 -22
- package/src/views/flow/arrow-head.tsx +0 -13
- package/src/views/flow/base-edge.tsx +0 -31
- package/src/views/flow/flow-loader.tsx +0 -3
- package/src/views/flow/flow-view.tsx +0 -72
- package/src/views/flow/hooks/use-get-flow-state.tsx +0 -93
- package/src/views/flow/hooks/use-organize-nodes.ts +0 -60
- package/src/views/flow/legend.tsx +0 -96
- package/src/views/flow/node-organizer.tsx +0 -70
- package/src/views/flow/nodes/api-flow-node.tsx +0 -6
- package/src/views/flow/nodes/event-flow-node.tsx +0 -6
- package/src/views/flow/nodes/json-schema-form.tsx +0 -110
- package/src/views/flow/nodes/language-indicator.tsx +0 -74
- package/src/views/flow/nodes/nodes.types.ts +0 -36
- package/src/views/flow/nodes/noop-flow-node.tsx +0 -6
- package/src/vite-env.d.ts +0 -1
- package/tailwind.config.ts +0 -75
- package/tsconfig.app.json +0 -32
- package/tsconfig.json +0 -14
- package/tsconfig.node.json +0 -32
- package/tsconfig.node.tsbuildinfo +0 -1
- package/vite.config.ts +0 -14
- /package/{components.json → dist/components.json} +0 -0
- /package/{public → dist/public}/.empty +0 -0
package/src/route-wrapper.tsx
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AppSidebar } from './components/app-sidebar'
|
|
2
|
-
import { SidebarProvider } from './components/ui/sidebar'
|
|
3
|
-
|
|
4
|
-
export const RouteWrapper = ({ children }: { children: React.ReactNode }) => (
|
|
5
|
-
<SidebarProvider>
|
|
6
|
-
<AppSidebar />
|
|
7
|
-
{children}
|
|
8
|
-
</SidebarProvider>
|
|
9
|
-
)
|
package/src/routeTree.gen.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
|
|
5
|
-
// noinspection JSUnusedGlobalSymbols
|
|
6
|
-
|
|
7
|
-
// This file was automatically generated by TanStack Router.
|
|
8
|
-
// You should NOT make any changes in this file as it will be overwritten.
|
|
9
|
-
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|
10
|
-
|
|
11
|
-
// Import Routes
|
|
12
|
-
|
|
13
|
-
import { Route as rootRoute } from './routes/__root'
|
|
14
|
-
import { Route as IndexImport } from './routes/index'
|
|
15
|
-
import { Route as FlowIdImport } from './routes/flow/$id'
|
|
16
|
-
|
|
17
|
-
// Create/Update Routes
|
|
18
|
-
|
|
19
|
-
const IndexRoute = IndexImport.update({
|
|
20
|
-
id: '/',
|
|
21
|
-
path: '/',
|
|
22
|
-
getParentRoute: () => rootRoute,
|
|
23
|
-
} as any)
|
|
24
|
-
|
|
25
|
-
const FlowIdRoute = FlowIdImport.update({
|
|
26
|
-
id: '/flow/$id',
|
|
27
|
-
path: '/flow/$id',
|
|
28
|
-
getParentRoute: () => rootRoute,
|
|
29
|
-
} as any)
|
|
30
|
-
|
|
31
|
-
// Populate the FileRoutesByPath interface
|
|
32
|
-
|
|
33
|
-
declare module '@tanstack/react-router' {
|
|
34
|
-
interface FileRoutesByPath {
|
|
35
|
-
'/': {
|
|
36
|
-
id: '/'
|
|
37
|
-
path: '/'
|
|
38
|
-
fullPath: '/'
|
|
39
|
-
preLoaderRoute: typeof IndexImport
|
|
40
|
-
parentRoute: typeof rootRoute
|
|
41
|
-
}
|
|
42
|
-
'/flow/$id': {
|
|
43
|
-
id: '/flow/$id'
|
|
44
|
-
path: '/flow/$id'
|
|
45
|
-
fullPath: '/flow/$id'
|
|
46
|
-
preLoaderRoute: typeof FlowIdImport
|
|
47
|
-
parentRoute: typeof rootRoute
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Create and export the route tree
|
|
53
|
-
|
|
54
|
-
export interface FileRoutesByFullPath {
|
|
55
|
-
'/': typeof IndexRoute
|
|
56
|
-
'/flow/$id': typeof FlowIdRoute
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface FileRoutesByTo {
|
|
60
|
-
'/': typeof IndexRoute
|
|
61
|
-
'/flow/$id': typeof FlowIdRoute
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface FileRoutesById {
|
|
65
|
-
__root__: typeof rootRoute
|
|
66
|
-
'/': typeof IndexRoute
|
|
67
|
-
'/flow/$id': typeof FlowIdRoute
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface FileRouteTypes {
|
|
71
|
-
fileRoutesByFullPath: FileRoutesByFullPath
|
|
72
|
-
fullPaths: '/' | '/flow/$id'
|
|
73
|
-
fileRoutesByTo: FileRoutesByTo
|
|
74
|
-
to: '/' | '/flow/$id'
|
|
75
|
-
id: '__root__' | '/' | '/flow/$id'
|
|
76
|
-
fileRoutesById: FileRoutesById
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface RootRouteChildren {
|
|
80
|
-
IndexRoute: typeof IndexRoute
|
|
81
|
-
FlowIdRoute: typeof FlowIdRoute
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const rootRouteChildren: RootRouteChildren = {
|
|
85
|
-
IndexRoute: IndexRoute,
|
|
86
|
-
FlowIdRoute: FlowIdRoute,
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export const routeTree = rootRoute._addFileChildren(rootRouteChildren)._addFileTypes<FileRouteTypes>()
|
|
90
|
-
|
|
91
|
-
/* ROUTE_MANIFEST_START
|
|
92
|
-
{
|
|
93
|
-
"routes": {
|
|
94
|
-
"__root__": {
|
|
95
|
-
"filePath": "__root.tsx",
|
|
96
|
-
"children": [
|
|
97
|
-
"/",
|
|
98
|
-
"/flow/$id"
|
|
99
|
-
]
|
|
100
|
-
},
|
|
101
|
-
"/": {
|
|
102
|
-
"filePath": "index.tsx"
|
|
103
|
-
},
|
|
104
|
-
"/flow/$id": {
|
|
105
|
-
"filePath": "flow/$id.tsx"
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
ROUTE_MANIFEST_END */
|
package/src/routes/__root.tsx
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { RouteWrapper } from '@/route-wrapper'
|
|
2
|
-
import { createRootRoute, Outlet } from '@tanstack/react-router'
|
|
3
|
-
import React, { Suspense } from 'react'
|
|
4
|
-
|
|
5
|
-
const TanStackRouterDevtools =
|
|
6
|
-
process.env.NODE_ENV === 'production'
|
|
7
|
-
? () => null // Render nothing in production
|
|
8
|
-
: React.lazy(() =>
|
|
9
|
-
// Lazy load in development
|
|
10
|
-
import('@tanstack/router-devtools').then((res) => ({
|
|
11
|
-
default: res.TanStackRouterDevtools,
|
|
12
|
-
// For Embedded Mode
|
|
13
|
-
// default: res.TanStackRouterDevtoolsPanel
|
|
14
|
-
})),
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
const RouteComponent = () => (
|
|
18
|
-
<RouteWrapper>
|
|
19
|
-
<Outlet />
|
|
20
|
-
<Suspense>
|
|
21
|
-
<TanStackRouterDevtools />
|
|
22
|
-
</Suspense>
|
|
23
|
-
</RouteWrapper>
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
export const Route = createRootRoute({ component: RouteComponent })
|
package/src/routes/flow/$id.tsx
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { FlowView } from '@/views/flow/flow-view'
|
|
2
|
-
import { createFileRoute } from '@tanstack/react-router'
|
|
3
|
-
|
|
4
|
-
export const Route = createFileRoute('/flow/$id')({
|
|
5
|
-
component: Flow,
|
|
6
|
-
loader: async ({ params }) => {
|
|
7
|
-
return fetch(`/flows/${params.id}`)
|
|
8
|
-
.then((res) => res.json())
|
|
9
|
-
.then((flow) => ({ flow }))
|
|
10
|
-
},
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
function Flow() {
|
|
14
|
-
const { flow } = Route.useLoaderData()
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<div className="w-screen h-screen">
|
|
18
|
-
<FlowView flow={flow} />
|
|
19
|
-
</div>
|
|
20
|
-
)
|
|
21
|
-
}
|
package/src/routes/index.tsx
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from '@tanstack/react-router'
|
|
2
|
-
|
|
3
|
-
export const Route = createFileRoute('/')({
|
|
4
|
-
component: Index,
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
function Index() {
|
|
8
|
-
return (
|
|
9
|
-
<div className="flex items-center justify-center w-full h-screen">
|
|
10
|
-
<p className="text-gray-500">Select a flow</p>
|
|
11
|
-
</div>
|
|
12
|
-
)
|
|
13
|
-
}
|
package/src/stores/use-logs.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { create } from 'zustand'
|
|
2
|
-
|
|
3
|
-
export type Log = {
|
|
4
|
-
level: string
|
|
5
|
-
time: number
|
|
6
|
-
msg: string
|
|
7
|
-
traceId: string
|
|
8
|
-
flows: string[]
|
|
9
|
-
[key: string]: any
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type LogsState = {
|
|
13
|
-
logs: Log[]
|
|
14
|
-
addLog: (log: Log) => void
|
|
15
|
-
resetLogs: () => void
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const useLogs = create<LogsState>()((set) => ({
|
|
19
|
-
logs: [],
|
|
20
|
-
addLog: (log) => set((state) => ({ ...state, logs: [...state.logs, log] })),
|
|
21
|
-
resetLogs: () => set({ logs: [] }),
|
|
22
|
-
}))
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
type Props = {
|
|
4
|
-
color: string
|
|
5
|
-
id: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const ArrowHead: React.FC<Props> = (props) => (
|
|
9
|
-
<marker id={props.id} viewBox="-5 -5 10 10" markerUnits="strokeWidth" markerWidth="10" markerHeight="10">
|
|
10
|
-
<line x1={0} y1={0} x2={2} y2={-2} stroke={props.color} strokeWidth="1" strokeOpacity="1" strokeLinecap="round" />
|
|
11
|
-
<line x1={-2} y1={-2} x2={0} y2={0} stroke={props.color} strokeWidth="1" strokeOpacity="1" strokeLinecap="round" />
|
|
12
|
-
</marker>
|
|
13
|
-
)
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { BaseEdge as BaseReactFlowEdge, EdgeProps, getSmoothStepPath } from '@xyflow/react'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
export const BaseEdge: React.FC<EdgeProps> = (props) => {
|
|
5
|
-
const { sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, data } = props
|
|
6
|
-
|
|
7
|
-
const [edgePath] = getSmoothStepPath({
|
|
8
|
-
sourceX,
|
|
9
|
-
sourceY,
|
|
10
|
-
targetX,
|
|
11
|
-
targetY,
|
|
12
|
-
sourcePosition,
|
|
13
|
-
targetPosition,
|
|
14
|
-
borderRadius: 20,
|
|
15
|
-
offset: 10,
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<BaseReactFlowEdge
|
|
20
|
-
path={edgePath}
|
|
21
|
-
style={{
|
|
22
|
-
stroke: data?.variant === 'virtual' ? 'rgb(147, 169, 197)' : 'rgb(133, 176, 132)',
|
|
23
|
-
strokeWidth: 0.5,
|
|
24
|
-
shapeRendering: 'geometricPrecision',
|
|
25
|
-
fill: 'none',
|
|
26
|
-
mixBlendMode: 'screen',
|
|
27
|
-
}}
|
|
28
|
-
className="edge-animated"
|
|
29
|
-
/>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Background, BackgroundVariant, ReactFlow } from '@xyflow/react'
|
|
2
|
-
import '@xyflow/react/dist/style.css'
|
|
3
|
-
import { BaseEdge } from './base-edge'
|
|
4
|
-
import { ArrowHead } from './arrow-head'
|
|
5
|
-
import { useGetFlowState, FlowResponse } from './hooks/use-get-flow-state'
|
|
6
|
-
import { useCallback, useEffect, useState } from 'react'
|
|
7
|
-
import { NodeOrganizer } from './node-organizer'
|
|
8
|
-
import { FlowLoader } from './flow-loader'
|
|
9
|
-
import { useLogListener } from '@/hooks/use-log-listener'
|
|
10
|
-
import { LogConsole } from '@/components/log-console'
|
|
11
|
-
import { Legend } from './legend'
|
|
12
|
-
|
|
13
|
-
const edgeTypes = {
|
|
14
|
-
base: BaseEdge,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type Props = {
|
|
18
|
-
flow: FlowResponse
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const FlowView: React.FC<Props> = ({ flow }) => {
|
|
22
|
-
const { nodes, edges, onNodesChange, onEdgesChange, nodeTypes } = useGetFlowState(flow)
|
|
23
|
-
const [initialized, setInitialized] = useState(false)
|
|
24
|
-
const [hoveredType, setHoveredType] = useState<string | null>(null)
|
|
25
|
-
|
|
26
|
-
useLogListener()
|
|
27
|
-
|
|
28
|
-
useEffect(() => setInitialized(false), [flow])
|
|
29
|
-
const onInitialized = useCallback(() => {
|
|
30
|
-
setTimeout(() => setInitialized(true), 10)
|
|
31
|
-
}, [])
|
|
32
|
-
|
|
33
|
-
const highlightClass = (nodeType?: string) => {
|
|
34
|
-
if (!hoveredType) return ''
|
|
35
|
-
return nodeType === hoveredType
|
|
36
|
-
? 'shadow-[0_0_15px_rgba(255,255,255,0.15)] border border-white/30 scale-[1.02] transition-all duration-300'
|
|
37
|
-
: 'opacity-30 transition-all duration-300'
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const nodesWithHighlights = nodes.map((node) => ({
|
|
41
|
-
...node,
|
|
42
|
-
className: highlightClass(node.data.type), // Access type from `data.type`
|
|
43
|
-
}))
|
|
44
|
-
|
|
45
|
-
if (!nodeTypes) {
|
|
46
|
-
return null
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<div className="w-full h-full relative bg-black">
|
|
51
|
-
{!initialized && <FlowLoader />}
|
|
52
|
-
<Legend onHover={setHoveredType} />
|
|
53
|
-
<ReactFlow
|
|
54
|
-
nodes={nodesWithHighlights}
|
|
55
|
-
edges={edges}
|
|
56
|
-
nodeTypes={nodeTypes}
|
|
57
|
-
edgeTypes={edgeTypes}
|
|
58
|
-
onNodesChange={onNodesChange}
|
|
59
|
-
onEdgesChange={onEdgesChange}
|
|
60
|
-
>
|
|
61
|
-
<Background variant={BackgroundVariant.Dots} gap={20} size={1} color="#444" />
|
|
62
|
-
<NodeOrganizer onInitialized={onInitialized} />
|
|
63
|
-
<svg>
|
|
64
|
-
<defs>
|
|
65
|
-
<ArrowHead color="#B3B3B3" id="arrowhead" />
|
|
66
|
-
</defs>
|
|
67
|
-
</svg>
|
|
68
|
-
</ReactFlow>
|
|
69
|
-
<LogConsole />
|
|
70
|
-
</div>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { Edge, Node, useEdgesState, useNodesState } from '@xyflow/react'
|
|
2
|
-
import { useEffect, useState } from 'react'
|
|
3
|
-
import type { EdgeData, NodeData } from '../nodes/nodes.types'
|
|
4
|
-
import { ApiFlowNode } from '../nodes/api-flow-node'
|
|
5
|
-
import { NoopFlowNode } from '../nodes/noop-flow-node'
|
|
6
|
-
import { EventFlowNode } from '../nodes/event-flow-node'
|
|
7
|
-
|
|
8
|
-
type Emit = string | { type: string; label?: string }
|
|
9
|
-
|
|
10
|
-
type FlowStep = {
|
|
11
|
-
id: string
|
|
12
|
-
name: string
|
|
13
|
-
type: 'event' | 'api' | 'noop'
|
|
14
|
-
description?: string
|
|
15
|
-
subscribes?: string[]
|
|
16
|
-
emits: Emit[]
|
|
17
|
-
virtualEmits?: Emit[]
|
|
18
|
-
action?: 'webhook'
|
|
19
|
-
webhookUrl?: string
|
|
20
|
-
language?: string
|
|
21
|
-
nodeComponentPath?: string
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type FlowResponse = {
|
|
25
|
-
id: string
|
|
26
|
-
name: string
|
|
27
|
-
steps: FlowStep[]
|
|
28
|
-
edges: FlowEdge[]
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type FlowEdge = {
|
|
32
|
-
id: string
|
|
33
|
-
source: string
|
|
34
|
-
target: string
|
|
35
|
-
data: EdgeData
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
type FlowState = {
|
|
39
|
-
nodes: Node<NodeData>[]
|
|
40
|
-
edges: Edge<EdgeData>[]
|
|
41
|
-
nodeTypes: Record<string, React.ComponentType<any>>
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function importFlow(flow: FlowResponse): Promise<FlowState> {
|
|
45
|
-
const nodeTypes: Record<string, React.ComponentType<any>> = {
|
|
46
|
-
event: EventFlowNode,
|
|
47
|
-
api: ApiFlowNode,
|
|
48
|
-
noop: NoopFlowNode,
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Load custom node components if they exist
|
|
52
|
-
for (const step of flow.steps) {
|
|
53
|
-
if (step.nodeComponentPath) {
|
|
54
|
-
const module = await import(/* @vite-ignore */ step.nodeComponentPath)
|
|
55
|
-
nodeTypes[step.nodeComponentPath] = module.default
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Create nodes from steps
|
|
60
|
-
const nodes: Node<NodeData>[] = flow.steps.map((step) => ({
|
|
61
|
-
id: step.id,
|
|
62
|
-
type: step.nodeComponentPath ? step.nodeComponentPath : step.type,
|
|
63
|
-
position: { x: 0, y: 0 },
|
|
64
|
-
data: step,
|
|
65
|
-
language: step.language,
|
|
66
|
-
}))
|
|
67
|
-
|
|
68
|
-
// Use the edges provided by the API, adding required ReactFlow properties
|
|
69
|
-
const edges: Edge<EdgeData>[] = flow.edges.map((edge) => ({
|
|
70
|
-
...edge,
|
|
71
|
-
type: 'base',
|
|
72
|
-
}))
|
|
73
|
-
|
|
74
|
-
return { nodes, edges, nodeTypes }
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export const useGetFlowState = (flow: FlowResponse) => {
|
|
78
|
-
const [nodeTypes, setNodeTypes] = useState<Record<string, React.ComponentType<any>>>()
|
|
79
|
-
const [nodes, setNodes, onNodesChange] = useNodesState<Node<NodeData>>([])
|
|
80
|
-
const [edges, setEdges, onEdgesChange] = useEdgesState<Edge<EdgeData>>([])
|
|
81
|
-
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
if (!flow) return
|
|
84
|
-
|
|
85
|
-
importFlow(flow).then(({ nodes, edges, nodeTypes }) => {
|
|
86
|
-
setNodes(nodes)
|
|
87
|
-
setEdges(edges)
|
|
88
|
-
setNodeTypes(nodeTypes)
|
|
89
|
-
})
|
|
90
|
-
}, [flow])
|
|
91
|
-
|
|
92
|
-
return { nodes, edges, onNodesChange, onEdgesChange, nodeTypes }
|
|
93
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Edge, Node } from '@xyflow/react'
|
|
2
|
-
import dagre from 'dagre'
|
|
3
|
-
import { useEffect, useRef } from 'react'
|
|
4
|
-
import { EventNodeData, EdgeData, ApiNodeData } from '../nodes/nodes.types'
|
|
5
|
-
|
|
6
|
-
const organizeNodes = (
|
|
7
|
-
nodes: Node<EventNodeData | ApiNodeData>[],
|
|
8
|
-
edges: Edge<EdgeData>[],
|
|
9
|
-
): Node<EventNodeData | ApiNodeData>[] => {
|
|
10
|
-
const dagreGraph = new dagre.graphlib.Graph({ compound: true })
|
|
11
|
-
dagreGraph.setDefaultEdgeLabel(() => ({}))
|
|
12
|
-
|
|
13
|
-
// Top-to-bottom layout
|
|
14
|
-
dagreGraph.setGraph({ rankdir: 'TB', ranksep: 80, nodesep: 60, edgesep: 20, ranker: 'tight-tree' })
|
|
15
|
-
|
|
16
|
-
nodes.forEach((node) => {
|
|
17
|
-
dagreGraph.setNode(node.id, { width: node.measured?.width, height: node.measured?.height })
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
edges.forEach((edge) => {
|
|
21
|
-
if (typeof edge.label === 'string') {
|
|
22
|
-
dagreGraph.setEdge(edge.source, edge.target, {
|
|
23
|
-
label: edge.label ?? '',
|
|
24
|
-
width: edge.label.length * 40, // Add width for the label
|
|
25
|
-
height: 30, // Add height for the label
|
|
26
|
-
labelpos: 'c', // Position label in center
|
|
27
|
-
})
|
|
28
|
-
} else {
|
|
29
|
-
dagreGraph.setEdge(edge.source, edge.target)
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
dagre.layout(dagreGraph)
|
|
34
|
-
|
|
35
|
-
return nodes.map((node) => {
|
|
36
|
-
const { x, y } = dagreGraph.node(node.id)
|
|
37
|
-
const position = {
|
|
38
|
-
x: x - (node.measured?.width ?? 0) / 2,
|
|
39
|
-
y: y - (node.measured?.height ?? 0) / 2,
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return { ...node, position }
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const useOrganizeNodes = (
|
|
47
|
-
nodes: Node<EventNodeData | ApiNodeData>[],
|
|
48
|
-
edges: Edge<EdgeData>[],
|
|
49
|
-
setNodes: (nodes: Node<EventNodeData | ApiNodeData>[]) => void,
|
|
50
|
-
) => {
|
|
51
|
-
const organizedRef = useRef<boolean>(false)
|
|
52
|
-
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (!nodes.length || !edges.length || !nodes[0].measured || organizedRef.current) return
|
|
55
|
-
|
|
56
|
-
const layoutedNodes = organizeNodes(nodes, edges)
|
|
57
|
-
setNodes(layoutedNodes)
|
|
58
|
-
organizedRef.current = true
|
|
59
|
-
}, [nodes, edges, setNodes])
|
|
60
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
export const Legend = ({ onHover }: { onHover: (type: string | null) => void }) => {
|
|
2
|
-
const legendItems = [
|
|
3
|
-
{
|
|
4
|
-
label: 'Event (Core)',
|
|
5
|
-
type: 'event',
|
|
6
|
-
bgColor: 'bg-green-950/40',
|
|
7
|
-
description: 'Core logic components that process events.',
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
label: 'API',
|
|
11
|
-
type: 'api',
|
|
12
|
-
bgColor: 'bg-blue-950/40',
|
|
13
|
-
description: 'HTTP endpoints that trigger flows.',
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
label: 'Noop (Non-Operation)',
|
|
17
|
-
type: 'noop',
|
|
18
|
-
bgColor: 'bg-zinc-950/40',
|
|
19
|
-
description: 'Placeholder nodes for external processes.',
|
|
20
|
-
},
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
const edgeLegendItems = [
|
|
24
|
-
{
|
|
25
|
-
label: 'Event Edge',
|
|
26
|
-
color: 'rgb(133, 176, 132)', // Solid green line
|
|
27
|
-
description: 'Represents an event emitted and subscribed by steps.',
|
|
28
|
-
dashed: true,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
label: 'Virtual Edge',
|
|
32
|
-
color: 'rgb(147, 169, 197)', // Dotted blue line
|
|
33
|
-
description: 'Represents virtual connections.',
|
|
34
|
-
dashed: true,
|
|
35
|
-
},
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
const renderSwatch = (bgColor: string) => (
|
|
39
|
-
<div className="relative group">
|
|
40
|
-
<div className="absolute -inset-[1px] rounded bg-gradient-to-r from-white/20 to-white/10" />
|
|
41
|
-
<div className={`relative ${bgColor} w-8 h-8 rounded border border-white/10`} />
|
|
42
|
-
<div className="absolute inset-0 -z-10 translate-y-0.5 translate-x-0.5 bg-black/20 rounded border border-white/5" />
|
|
43
|
-
</div>
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
const renderEdgeSwatch = (color: string, dashed: boolean) => (
|
|
47
|
-
<svg width="48" height="10" viewBox="0 0 48 10" xmlns="http://www.w3.org/2000/svg">
|
|
48
|
-
<line
|
|
49
|
-
x1="0"
|
|
50
|
-
y1="5"
|
|
51
|
-
x2="48"
|
|
52
|
-
y2="5"
|
|
53
|
-
stroke={color}
|
|
54
|
-
strokeWidth=".8"
|
|
55
|
-
strokeDasharray={dashed ? '4 3' : 'none'} // Match the dashed or solid style
|
|
56
|
-
strokeLinecap="round" // Rounded edges
|
|
57
|
-
/>
|
|
58
|
-
</svg>
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<div className="absolute right-4 top-4 font-mono rounded-lg border border-white/20 p-4 z-10 shadow-xl">
|
|
63
|
-
<div className="text-sm text-white mb-3 font-semibold">Flow Legend</div>
|
|
64
|
-
<div className="flex flex-col gap-3">
|
|
65
|
-
{legendItems.map((item) => (
|
|
66
|
-
<div
|
|
67
|
-
key={item.type}
|
|
68
|
-
onMouseEnter={() => onHover(item.type)}
|
|
69
|
-
onMouseLeave={() => onHover(null)}
|
|
70
|
-
className="group cursor-pointer transition-all hover:bg-white/5 rounded p-1 -mx-1"
|
|
71
|
-
>
|
|
72
|
-
<div className="flex items-start gap-3">
|
|
73
|
-
{renderSwatch(item.bgColor)}
|
|
74
|
-
<div className="flex-1">
|
|
75
|
-
<div className="text-white text-xs font-medium">{item.label}</div>
|
|
76
|
-
<div className="text-white/60 text-xs mt-0.5">{item.description}</div>
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
79
|
-
</div>
|
|
80
|
-
))}
|
|
81
|
-
</div>
|
|
82
|
-
<div className="text-sm text-white mt-4 mb-3 font-semibold">Edge Legend</div>
|
|
83
|
-
<div className="flex flex-col gap-3">
|
|
84
|
-
{edgeLegendItems.map((item) => (
|
|
85
|
-
<div key={item.label} className="flex items-start gap-3">
|
|
86
|
-
{renderEdgeSwatch(item.color, item.dashed)}
|
|
87
|
-
<div className="flex-1">
|
|
88
|
-
<div className="text-white text-xs font-medium">{item.label}</div>
|
|
89
|
-
<div className="text-white/60 text-xs mt-0.5">{item.description}</div>
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
))}
|
|
93
|
-
</div>
|
|
94
|
-
</div>
|
|
95
|
-
)
|
|
96
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Edge, Node, useNodesInitialized, useReactFlow } from '@xyflow/react'
|
|
2
|
-
import dagre from 'dagre'
|
|
3
|
-
import { useEffect } from 'react'
|
|
4
|
-
import { EventNodeData, EdgeData, ApiNodeData } from './nodes/nodes.types'
|
|
5
|
-
|
|
6
|
-
const organizeNodes = (
|
|
7
|
-
nodes: Node<EventNodeData | ApiNodeData>[],
|
|
8
|
-
edges: Edge<EdgeData>[],
|
|
9
|
-
): Node<EventNodeData | ApiNodeData>[] => {
|
|
10
|
-
const dagreGraph = new dagre.graphlib.Graph({ compound: true })
|
|
11
|
-
dagreGraph.setDefaultEdgeLabel(() => ({}))
|
|
12
|
-
|
|
13
|
-
// Top-to-bottom layout
|
|
14
|
-
dagreGraph.setGraph({ rankdir: 'TB', ranksep: 80, nodesep: 60, edgesep: 20, ranker: 'tight-tree' })
|
|
15
|
-
|
|
16
|
-
nodes.forEach((node) => {
|
|
17
|
-
dagreGraph.setNode(node.id, { width: node.measured?.width, height: node.measured?.height })
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
edges.forEach((edge) => {
|
|
21
|
-
if (typeof edge.label === 'string') {
|
|
22
|
-
dagreGraph.setEdge(edge.source, edge.target, {
|
|
23
|
-
label: edge.label ?? '',
|
|
24
|
-
width: edge.label.length * 40, // Add width for the label
|
|
25
|
-
height: 30, // Add height for the label
|
|
26
|
-
labelpos: 'c', // Position label in center
|
|
27
|
-
})
|
|
28
|
-
} else {
|
|
29
|
-
dagreGraph.setEdge(edge.source, edge.target)
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
dagre.layout(dagreGraph)
|
|
34
|
-
|
|
35
|
-
return nodes.map((node) => {
|
|
36
|
-
const { x, y } = dagreGraph.node(node.id)
|
|
37
|
-
const position = {
|
|
38
|
-
x: x - (node.measured?.width ?? 0) / 2,
|
|
39
|
-
y: y - (node.measured?.height ?? 0) / 2,
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return { ...node, position }
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
type Props = {
|
|
47
|
-
onInitialized: () => void
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export const NodeOrganizer: React.FC<Props> = ({ onInitialized }) => {
|
|
51
|
-
const { setNodes, getNodes, getEdges, fitView } = useReactFlow()
|
|
52
|
-
const nodesInitialized = useNodesInitialized()
|
|
53
|
-
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (nodesInitialized) {
|
|
56
|
-
const nodes = getNodes() as Node<EventNodeData | ApiNodeData>[]
|
|
57
|
-
const edges = getEdges() as Edge<EdgeData>[]
|
|
58
|
-
const organizedNodes = organizeNodes(nodes, edges)
|
|
59
|
-
|
|
60
|
-
setNodes(organizedNodes)
|
|
61
|
-
onInitialized()
|
|
62
|
-
|
|
63
|
-
setTimeout(async () => {
|
|
64
|
-
await fitView()
|
|
65
|
-
}, 1)
|
|
66
|
-
}
|
|
67
|
-
}, [nodesInitialized, onInitialized])
|
|
68
|
-
|
|
69
|
-
return null
|
|
70
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { EventNode } from '../../../publicComponents/event-node'
|
|
2
|
-
import { EventNodeProps } from '../../../publicComponents/node-props'
|
|
3
|
-
|
|
4
|
-
export const EventFlowNode = ({ data }: EventNodeProps) => {
|
|
5
|
-
return <EventNode className="relative" data={data}></EventNode>
|
|
6
|
-
}
|