@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.
Files changed (295) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -40
  3. package/dist/README.md +105 -0
  4. package/dist/index.d.ts +1 -2
  5. package/dist/index.html +31 -0
  6. package/dist/index.js +0 -1
  7. package/dist/middleware.d.ts +2 -2
  8. package/dist/middleware.js +10 -17
  9. package/dist/postcss.config.mjs +9 -0
  10. package/dist/src/components/app-sidebar.d.ts +0 -1
  11. package/dist/src/components/app-sidebar.js +15 -8
  12. package/dist/src/components/endpoints/endpoint-badge.d.ts +10 -0
  13. package/dist/src/components/endpoints/endpoint-badge.js +22 -0
  14. package/dist/src/components/endpoints/endpoint-call.d.ts +8 -0
  15. package/dist/src/components/endpoints/endpoint-call.js +57 -0
  16. package/dist/src/components/endpoints/endpoints.d.ts +1 -0
  17. package/dist/src/components/endpoints/endpoints.js +34 -0
  18. package/dist/src/components/endpoints/hooks/use-get-endpoints.d.ts +15 -0
  19. package/dist/src/components/endpoints/hooks/use-get-endpoints.js +8 -0
  20. package/dist/src/components/endpoints/hooks/use-json-schema-to-json.d.ts +4 -0
  21. package/dist/src/components/endpoints/hooks/use-json-schema-to-json.js +11 -0
  22. package/dist/src/components/endpoints/hooks/use-path-params.d.ts +1 -0
  23. package/dist/src/components/endpoints/hooks/use-path-params.js +4 -0
  24. package/dist/src/components/endpoints/hooks/use-state-stream.d.ts +4 -0
  25. package/dist/src/components/endpoints/hooks/use-state-stream.js +8 -0
  26. package/dist/src/components/endpoints/hooks/utils.d.ts +1 -0
  27. package/dist/src/components/endpoints/hooks/utils.js +29 -0
  28. package/dist/src/components/endpoints/response-body.d.ts +7 -0
  29. package/dist/src/components/endpoints/response-body.js +6 -0
  30. package/dist/src/components/endpoints/selected-endpoint.d.ts +7 -0
  31. package/dist/src/components/endpoints/selected-endpoint.js +7 -0
  32. package/dist/src/components/{log-console.d.ts → logs/log-console.d.ts} +0 -1
  33. package/dist/src/components/logs/log-console.js +69 -0
  34. package/dist/src/components/logs/log-detail.d.ts +8 -0
  35. package/dist/src/components/logs/log-detail.js +15 -0
  36. package/dist/src/components/logs/log-field.d.ts +8 -0
  37. package/dist/src/components/logs/log-field.js +20 -0
  38. package/dist/src/components/{log-level-badge.d.ts → logs/log-level-badge.d.ts} +2 -1
  39. package/dist/src/components/{log-level-badge.js → logs/log-level-badge.js} +2 -2
  40. package/dist/src/components/logs/log-level-dot.d.ts +4 -0
  41. package/dist/src/components/logs/log-level-dot.js +17 -0
  42. package/dist/src/components/logs/logs.d.ts +1 -0
  43. package/dist/src/components/logs/logs.js +18 -0
  44. package/dist/src/components/root-motia.d.ts +2 -0
  45. package/dist/src/components/root-motia.js +5 -0
  46. package/dist/src/components/states/hooks/states-hooks.d.ts +3 -0
  47. package/dist/src/components/states/hooks/states-hooks.js +36 -0
  48. package/dist/src/components/states/state-detail.d.ts +7 -0
  49. package/dist/src/components/states/state-detail.js +12 -0
  50. package/dist/src/components/states/state-value.d.ts +8 -0
  51. package/dist/src/components/states/state-value.js +51 -0
  52. package/dist/src/components/states/states.d.ts +1 -0
  53. package/dist/src/components/states/states.js +21 -0
  54. package/dist/src/components/ui/badge.d.ts +3 -4
  55. package/dist/src/components/ui/badge.js +4 -4
  56. package/dist/src/components/ui/button.d.ts +2 -3
  57. package/dist/src/components/ui/button.js +2 -3
  58. package/dist/src/components/ui/collapsible.d.ts +1 -2
  59. package/dist/src/components/ui/collapsible.js +1 -1
  60. package/dist/src/components/ui/dialog.d.ts +2 -3
  61. package/dist/src/components/ui/dialog.js +12 -12
  62. package/dist/src/components/ui/dropdown-menu.d.ts +25 -0
  63. package/dist/src/components/ui/dropdown-menu.js +50 -0
  64. package/dist/src/components/ui/input.d.ts +0 -1
  65. package/dist/src/components/ui/label.d.ts +3 -4
  66. package/dist/src/components/ui/label.js +6 -6
  67. package/dist/src/components/ui/select.d.ts +2 -3
  68. package/dist/src/components/ui/select.js +14 -15
  69. package/dist/src/components/ui/separator.d.ts +0 -1
  70. package/dist/src/components/ui/sheet.d.ts +1 -2
  71. package/dist/src/components/ui/sheet.js +2 -2
  72. package/dist/src/components/ui/sidebar.d.ts +12 -67
  73. package/dist/src/components/ui/sidebar.js +14 -219
  74. package/dist/src/components/ui/skeleton.d.ts +1 -1
  75. package/dist/src/components/ui/switch.d.ts +2 -3
  76. package/dist/src/components/ui/switch.js +4 -4
  77. package/dist/src/components/ui/table.d.ts +0 -1
  78. package/dist/src/components/ui/table.js +1 -1
  79. package/dist/src/components/ui/textarea.d.ts +1 -2
  80. package/dist/src/components/ui/textarea.js +4 -4
  81. package/dist/src/components/ui/theme-toggle.d.ts +2 -0
  82. package/dist/src/components/ui/theme-toggle.js +11 -0
  83. package/dist/src/components/ui/tooltip.d.ts +0 -1
  84. package/dist/src/hooks/use-debounced.d.ts +1 -0
  85. package/dist/src/hooks/use-debounced.js +18 -0
  86. package/dist/src/hooks/use-list-flows.d.ts +0 -2
  87. package/dist/src/hooks/use-list-flows.js +6 -10
  88. package/dist/src/hooks/use-log-listener.d.ts +1 -6
  89. package/dist/src/hooks/use-log-listener.js +3 -18
  90. package/dist/src/hooks/use-mobile.d.ts +0 -1
  91. package/dist/src/hooks/use-theme.d.ts +6 -0
  92. package/dist/src/hooks/use-theme.js +28 -0
  93. package/dist/src/index.css +169 -0
  94. package/dist/src/lib/utils.d.ts +0 -1
  95. package/dist/src/main.d.ts +0 -8
  96. package/dist/src/main.js +11 -7
  97. package/dist/src/publicComponents/api-node.d.ts +2 -5
  98. package/dist/src/publicComponents/api-node.js +3 -3
  99. package/dist/src/publicComponents/base-handle.d.ts +1 -1
  100. package/dist/src/publicComponents/base-handle.js +5 -2
  101. package/dist/src/publicComponents/base-node.d.ts +5 -5
  102. package/dist/src/publicComponents/base-node.js +13 -8
  103. package/dist/src/publicComponents/colorMap.d.ts +6 -0
  104. package/dist/src/publicComponents/colorMap.js +6 -0
  105. package/dist/src/publicComponents/components/header-bar.d.ts +11 -0
  106. package/dist/src/publicComponents/components/header-bar.js +15 -0
  107. package/dist/src/publicComponents/cron-node.d.ts +2 -0
  108. package/dist/src/publicComponents/cron-node.js +7 -0
  109. package/dist/src/publicComponents/emits.d.ts +1 -1
  110. package/dist/src/publicComponents/emits.js +2 -2
  111. package/dist/src/publicComponents/event-node.d.ts +0 -2
  112. package/dist/src/publicComponents/event-node.js +3 -5
  113. package/dist/src/publicComponents/node-details.d.ts +17 -0
  114. package/dist/src/publicComponents/node-details.js +19 -0
  115. package/dist/src/publicComponents/node-props.d.ts +5 -3
  116. package/dist/src/publicComponents/noop-node.d.ts +0 -1
  117. package/dist/src/publicComponents/noop-node.js +1 -1
  118. package/dist/src/publicComponents/subscribe.d.ts +2 -3
  119. package/dist/src/publicComponents/subscribe.js +2 -2
  120. package/dist/src/route-wrapper.d.ts +2 -4
  121. package/dist/src/route-wrapper.js +2 -2
  122. package/dist/src/routes/endpoints-page.d.ts +1 -0
  123. package/dist/src/routes/endpoints-page.js +5 -0
  124. package/dist/src/routes/flow.d.ts +1 -0
  125. package/dist/src/routes/flow.js +22 -0
  126. package/dist/src/routes/index.d.ts +1 -2
  127. package/dist/src/routes/index.js +5 -8
  128. package/dist/src/routes/logs-page.d.ts +1 -0
  129. package/dist/src/routes/logs-page.js +12 -0
  130. package/dist/src/routes/states-page.d.ts +1 -0
  131. package/dist/src/routes/states-page.js +5 -0
  132. package/dist/src/stores/use-logs.d.ts +3 -2
  133. package/dist/src/stores/use-logs.js +52 -6
  134. package/dist/src/views/flow/arrow-head.d.ts +2 -2
  135. package/dist/src/views/flow/arrow-head.js +5 -1
  136. package/dist/src/views/flow/base-edge.d.ts +0 -1
  137. package/dist/src/views/flow/base-edge.js +25 -10
  138. package/dist/src/views/flow/flow-loader.d.ts +0 -1
  139. package/dist/src/views/flow/flow-loader.js +1 -1
  140. package/dist/src/views/flow/flow-view.d.ts +7 -2
  141. package/dist/src/views/flow/flow-view.js +44 -20
  142. package/dist/src/views/flow/hooks/use-get-flow-state.d.ts +14 -5
  143. package/dist/src/views/flow/hooks/use-get-flow-state.js +17 -8
  144. package/dist/src/views/flow/hooks/use-organize-nodes.d.ts +0 -1
  145. package/dist/src/views/flow/hooks/use-save-workflow-config.d.ts +9 -0
  146. package/dist/src/views/flow/hooks/use-save-workflow-config.js +23 -0
  147. package/dist/src/views/flow/legend.d.ts +3 -3
  148. package/dist/src/views/flow/legend.js +49 -39
  149. package/dist/src/views/flow/node-organizer.d.ts +1 -1
  150. package/dist/src/views/flow/node-organizer.js +4 -2
  151. package/dist/src/views/flow/nodes/api-flow-node.d.ts +0 -1
  152. package/dist/src/views/flow/nodes/event-flow-node.d.ts +0 -1
  153. package/dist/src/views/flow/nodes/language-indicator.d.ts +0 -1
  154. package/dist/src/views/flow/nodes/language-indicator.js +7 -7
  155. package/dist/src/views/flow/nodes/nodes.types.d.ts +39 -6
  156. package/dist/src/views/flow/nodes/noop-flow-node.d.ts +0 -1
  157. package/dist/tailwind.config.js +9 -77
  158. package/dist/tsconfig.app.tsbuildinfo +1 -1
  159. package/dist/tsconfig.node.tsbuildinfo +1 -1
  160. package/package.json +36 -42
  161. package/postcss.config.mjs +9 -0
  162. package/dist/index.d.ts.map +0 -1
  163. package/dist/middleware.d.ts.map +0 -1
  164. package/dist/src/components/app-sidebar.d.ts.map +0 -1
  165. package/dist/src/components/log-console.d.ts.map +0 -1
  166. package/dist/src/components/log-console.js +0 -20
  167. package/dist/src/components/log-level-badge.d.ts.map +0 -1
  168. package/dist/src/components/ui/badge.d.ts.map +0 -1
  169. package/dist/src/components/ui/button.d.ts.map +0 -1
  170. package/dist/src/components/ui/collapsible.d.ts.map +0 -1
  171. package/dist/src/components/ui/dialog.d.ts.map +0 -1
  172. package/dist/src/components/ui/input.d.ts.map +0 -1
  173. package/dist/src/components/ui/label.d.ts.map +0 -1
  174. package/dist/src/components/ui/select.d.ts.map +0 -1
  175. package/dist/src/components/ui/separator.d.ts.map +0 -1
  176. package/dist/src/components/ui/sheet.d.ts.map +0 -1
  177. package/dist/src/components/ui/sidebar.d.ts.map +0 -1
  178. package/dist/src/components/ui/skeleton.d.ts.map +0 -1
  179. package/dist/src/components/ui/switch.d.ts.map +0 -1
  180. package/dist/src/components/ui/table.d.ts.map +0 -1
  181. package/dist/src/components/ui/textarea.d.ts.map +0 -1
  182. package/dist/src/components/ui/tooltip.d.ts.map +0 -1
  183. package/dist/src/hooks/use-list-flows.d.ts.map +0 -1
  184. package/dist/src/hooks/use-log-listener.d.ts.map +0 -1
  185. package/dist/src/hooks/use-mobile.d.ts.map +0 -1
  186. package/dist/src/lib/utils.d.ts.map +0 -1
  187. package/dist/src/main.d.ts.map +0 -1
  188. package/dist/src/publicComponents/api-node.d.ts.map +0 -1
  189. package/dist/src/publicComponents/base-handle.d.ts.map +0 -1
  190. package/dist/src/publicComponents/base-node.d.ts.map +0 -1
  191. package/dist/src/publicComponents/emits.d.ts.map +0 -1
  192. package/dist/src/publicComponents/event-node.d.ts.map +0 -1
  193. package/dist/src/publicComponents/node-props.d.ts.map +0 -1
  194. package/dist/src/publicComponents/noop-node.d.ts.map +0 -1
  195. package/dist/src/publicComponents/subscribe.d.ts.map +0 -1
  196. package/dist/src/route-wrapper.d.ts.map +0 -1
  197. package/dist/src/routeTree.gen.d.ts +0 -53
  198. package/dist/src/routeTree.gen.d.ts.map +0 -1
  199. package/dist/src/routeTree.gen.js +0 -45
  200. package/dist/src/routes/__root.d.ts +0 -2
  201. package/dist/src/routes/__root.d.ts.map +0 -1
  202. package/dist/src/routes/__root.js +0 -15
  203. package/dist/src/routes/flow/$id.d.ts +0 -4
  204. package/dist/src/routes/flow/$id.d.ts.map +0 -1
  205. package/dist/src/routes/flow/$id.js +0 -15
  206. package/dist/src/routes/index.d.ts.map +0 -1
  207. package/dist/src/stores/use-logs.d.ts.map +0 -1
  208. package/dist/src/views/flow/arrow-head.d.ts.map +0 -1
  209. package/dist/src/views/flow/base-edge.d.ts.map +0 -1
  210. package/dist/src/views/flow/flow-loader.d.ts.map +0 -1
  211. package/dist/src/views/flow/flow-view.d.ts.map +0 -1
  212. package/dist/src/views/flow/hooks/use-get-flow-state.d.ts.map +0 -1
  213. package/dist/src/views/flow/hooks/use-organize-nodes.d.ts.map +0 -1
  214. package/dist/src/views/flow/legend.d.ts.map +0 -1
  215. package/dist/src/views/flow/node-organizer.d.ts.map +0 -1
  216. package/dist/src/views/flow/nodes/api-flow-node.d.ts.map +0 -1
  217. package/dist/src/views/flow/nodes/event-flow-node.d.ts.map +0 -1
  218. package/dist/src/views/flow/nodes/json-schema-form.d.ts +0 -9
  219. package/dist/src/views/flow/nodes/json-schema-form.d.ts.map +0 -1
  220. package/dist/src/views/flow/nodes/json-schema-form.js +0 -35
  221. package/dist/src/views/flow/nodes/language-indicator.d.ts.map +0 -1
  222. package/dist/src/views/flow/nodes/nodes.types.d.ts.map +0 -1
  223. package/dist/src/views/flow/nodes/noop-flow-node.d.ts.map +0 -1
  224. package/dist/tailwind.config.d.ts +0 -4
  225. package/dist/tailwind.config.d.ts.map +0 -1
  226. package/dist/vite.config.d.ts +0 -11
  227. package/dist/vite.config.d.ts.map +0 -1
  228. package/dist/vite.config.js +0 -18
  229. package/eslint.config.js +0 -28
  230. package/index.html +0 -19
  231. package/index.tsx +0 -10
  232. package/middleware.ts +0 -48
  233. package/postcss.config.js +0 -6
  234. package/src/assets/.empty +0 -0
  235. package/src/components/app-sidebar.tsx +0 -55
  236. package/src/components/log-console.tsx +0 -76
  237. package/src/components/log-level-badge.tsx +0 -12
  238. package/src/components/ui/badge.tsx +0 -31
  239. package/src/components/ui/button.tsx +0 -47
  240. package/src/components/ui/collapsible.tsx +0 -9
  241. package/src/components/ui/dialog.tsx +0 -120
  242. package/src/components/ui/input.tsx +0 -21
  243. package/src/components/ui/label.tsx +0 -26
  244. package/src/components/ui/select.tsx +0 -157
  245. package/src/components/ui/separator.tsx +0 -22
  246. package/src/components/ui/sheet.tsx +0 -106
  247. package/src/components/ui/sidebar.tsx +0 -637
  248. package/src/components/ui/skeleton.tsx +0 -7
  249. package/src/components/ui/switch.tsx +0 -27
  250. package/src/components/ui/table.tsx +0 -76
  251. package/src/components/ui/textarea.tsx +0 -22
  252. package/src/components/ui/tooltip.tsx +0 -32
  253. package/src/hooks/use-list-flows.tsx +0 -20
  254. package/src/hooks/use-log-listener.tsx +0 -32
  255. package/src/hooks/use-mobile.tsx +0 -19
  256. package/src/index.css +0 -190
  257. package/src/lib/utils.ts +0 -6
  258. package/src/main.tsx +0 -28
  259. package/src/publicComponents/api-node.tsx +0 -28
  260. package/src/publicComponents/base-handle.tsx +0 -43
  261. package/src/publicComponents/base-node.tsx +0 -57
  262. package/src/publicComponents/emits.tsx +0 -22
  263. package/src/publicComponents/event-node.tsx +0 -36
  264. package/src/publicComponents/node-props.tsx +0 -15
  265. package/src/publicComponents/noop-node.tsx +0 -21
  266. package/src/publicComponents/subscribe.tsx +0 -19
  267. package/src/route-wrapper.tsx +0 -9
  268. package/src/routeTree.gen.ts +0 -109
  269. package/src/routes/__root.tsx +0 -26
  270. package/src/routes/flow/$id.tsx +0 -21
  271. package/src/routes/index.tsx +0 -13
  272. package/src/stores/use-logs.ts +0 -22
  273. package/src/views/flow/arrow-head.tsx +0 -13
  274. package/src/views/flow/base-edge.tsx +0 -31
  275. package/src/views/flow/flow-loader.tsx +0 -3
  276. package/src/views/flow/flow-view.tsx +0 -72
  277. package/src/views/flow/hooks/use-get-flow-state.tsx +0 -93
  278. package/src/views/flow/hooks/use-organize-nodes.ts +0 -60
  279. package/src/views/flow/legend.tsx +0 -96
  280. package/src/views/flow/node-organizer.tsx +0 -70
  281. package/src/views/flow/nodes/api-flow-node.tsx +0 -6
  282. package/src/views/flow/nodes/event-flow-node.tsx +0 -6
  283. package/src/views/flow/nodes/json-schema-form.tsx +0 -110
  284. package/src/views/flow/nodes/language-indicator.tsx +0 -74
  285. package/src/views/flow/nodes/nodes.types.ts +0 -36
  286. package/src/views/flow/nodes/noop-flow-node.tsx +0 -6
  287. package/src/vite-env.d.ts +0 -1
  288. package/tailwind.config.ts +0 -75
  289. package/tsconfig.app.json +0 -32
  290. package/tsconfig.json +0 -14
  291. package/tsconfig.node.json +0 -32
  292. package/tsconfig.node.tsbuildinfo +0 -1
  293. package/vite.config.ts +0 -14
  294. /package/{components.json → dist/components.json} +0 -0
  295. /package/{public → dist/public}/.empty +0 -0
@@ -1,5 +1,5 @@
1
- import { EventNodeData, ApiNodeData, NoopNodeData } from '../views/flow/nodes/nodes.types';
2
- export type BaseNodeProps = EventNodeProps | NoopNodeProps | ApiNodeProps;
1
+ import { EventNodeData, ApiNodeData, NoopNodeData, CronNodeData } from '../views/flow/nodes/nodes.types';
2
+ export type BaseNodeProps = EventNodeProps | NoopNodeProps | ApiNodeProps | CronNodeProps;
3
3
  export type EventNodeProps = {
4
4
  data: EventNodeData;
5
5
  };
@@ -9,4 +9,6 @@ export type NoopNodeProps = {
9
9
  export type ApiNodeProps = {
10
10
  data: ApiNodeData;
11
11
  };
12
- //# sourceMappingURL=node-props.d.ts.map
12
+ export type CronNodeProps = {
13
+ data: CronNodeData;
14
+ };
@@ -5,4 +5,3 @@ type Props = PropsWithChildren<{
5
5
  }>;
6
6
  export declare const NoopNode: ({ data, children }: Props) => import("react/jsx-runtime").JSX.Element;
7
7
  export {};
8
- //# sourceMappingURL=noop-node.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { BaseNode } from './base-node';
3
3
  export const NoopNode = ({ data, children }) => {
4
- return (_jsxs(BaseNode, { variant: "noop", title: data.name, disableSourceHandle: !data.emits?.length, disableTargetHandle: !data.subscribes?.length, children: [data.description && _jsx("div", { className: "text-sm max-w-[300px] text-white/60", children: data.description }), children] }));
4
+ return (_jsxs(BaseNode, { variant: "noop", title: data.name, disableSourceHandle: !data.virtualEmits.length, disableTargetHandle: !data.subscribes?.length, children: [data.description && _jsx("div", { className: "text-sm max-w-[300px] text-muted-foreground", children: data.description }), children] }));
5
5
  };
@@ -1,5 +1,4 @@
1
- import { EventNodeData } from '../views/flow/nodes/nodes.types';
1
+ import React from 'react';
2
2
  export declare const Subscribe: React.FC<{
3
- data: EventNodeData;
3
+ subscribes: string[];
4
4
  }>;
5
- //# sourceMappingURL=subscribe.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Eye } from 'lucide-react';
3
- export const Subscribe = ({ data }) => {
4
- return (_jsx(_Fragment, { children: data.subscribes.map((subscribe) => (_jsxs("div", { className: "flex gap-2 items-center text-xs text-white/60", "data-testid": `subscribes__${subscribe}`, children: [_jsx(Eye, { className: "w-3 h-3 text-white/40" }), _jsx("div", { className: "font-mono tracking-wider", children: subscribe })] }, subscribe))) }));
3
+ export const Subscribe = ({ subscribes }) => {
4
+ return (_jsx(_Fragment, { children: subscribes.map((subscribe) => (_jsxs("div", { className: "flex gap-2 items-center text-xs text-muted-foreground", "data-testid": `subscribes__${subscribe}`, children: [_jsx(Eye, { className: "w-4 h-4 text-muted-foreground/60" }), _jsx("div", { className: "font-mono tracking-wider", children: subscribe })] }, subscribe))) }));
5
5
  };
@@ -1,4 +1,2 @@
1
- export declare const RouteWrapper: ({ children }: {
2
- children: React.ReactNode;
3
- }) => import("react/jsx-runtime").JSX.Element;
4
- //# sourceMappingURL=route-wrapper.d.ts.map
1
+ import React, { PropsWithChildren } from 'react';
2
+ export declare const RouteWrapper: React.FC<PropsWithChildren>;
@@ -1,4 +1,4 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { AppSidebar } from './components/app-sidebar';
3
- import { SidebarProvider } from './components/ui/sidebar';
4
- export const RouteWrapper = ({ children }) => (_jsxs(SidebarProvider, { children: [_jsx(AppSidebar, {}), children] }));
3
+ import { ReactFlowProvider } from '@xyflow/react';
4
+ export const RouteWrapper = ({ children }) => (_jsx("div", { className: "flex flex-row bg-background text-foreground", children: _jsxs(ReactFlowProvider, { children: [_jsx(AppSidebar, {}), _jsx("div", { className: "flex-1", children: children })] }) }));
@@ -0,0 +1 @@
1
+ export declare const EndpointsPage: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Endpoints } from '../components/endpoints/endpoints';
3
+ export const EndpointsPage = () => {
4
+ return _jsx(Endpoints, {});
5
+ };
@@ -0,0 +1 @@
1
+ export declare const Flow: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FlowView } from '@/views/flow/flow-view';
3
+ import { useCallback, useEffect, useState } from 'react';
4
+ import { useParams } from 'react-router';
5
+ export const Flow = () => {
6
+ const { id } = useParams();
7
+ const flowId = id;
8
+ const [flow, setFlow] = useState(null);
9
+ const [flowConfig, setFlowConfig] = useState(null);
10
+ const fetchFlow = useCallback(() => {
11
+ Promise.all([fetch(`/flows/${flowId}`), fetch(`/flows/${flowId}/config`)])
12
+ .then(([flowRes, configRes]) => Promise.all([flowRes.json(), configRes.json()]))
13
+ .then(([flow, config]) => {
14
+ setFlow(flow);
15
+ setFlowConfig(config);
16
+ });
17
+ }, [flowId]);
18
+ useEffect(fetchFlow, [fetchFlow]);
19
+ if (!flow || flow.error)
20
+ return (_jsx("div", { className: "w-full h-screen bg-background flex flex-col items-center justify-center", children: _jsx("p", { children: flow?.error }) }));
21
+ return (_jsx("div", { className: "w-full h-screen bg-background", children: _jsx(FlowView, { flow: flow, flowConfig: flowConfig }) }));
22
+ };
@@ -1,2 +1 @@
1
- export declare const Route: import("@tanstack/react-router").Route<import("@tanstack/react-router").RootRoute<undefined, {}, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, {}, undefined, unknown, unknown>, "/", "/", "/", "/", undefined, Record<never, string>, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, {}, undefined, unknown>;
2
- //# sourceMappingURL=index.d.ts.map
1
+ export declare const Index: () => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,5 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createFileRoute } from '@tanstack/react-router';
3
- export const Route = createFileRoute('/')({
4
- component: Index,
5
- });
6
- function Index() {
7
- return (_jsx("div", { className: "flex items-center justify-center w-full h-screen", children: _jsx("p", { className: "text-gray-500", children: "Select a flow" }) }));
8
- }
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button } from '../components/ui/button';
3
+ export const Index = () => {
4
+ return (_jsxs("div", { className: "flex flex-col items-center justify-center w-full h-screen gap-10 bg-gradient-to-r from-background via-background to-muted", children: [_jsx("h1", { className: "text-5xl font-extrabold max-w-[600px] text-center text-foreground", children: "Code-first framework for intelligent workflows" }), _jsx("div", { className: "max-w-[600px] text-center text-xl font-medium text-muted-foreground", children: "Write in any language. Automate anything. From AI agents to backend automation, Motia runs event-driven workflows with zero overhead." }), _jsx("div", { className: "p-[1px] min-w-[600px] rounded-lg shadow-lg border border-border", children: _jsx("div", { className: "rounded-lg bg-card p-8 font-semibold text-xl min-h-[100px] flex items-center", children: _jsxs("div", { className: "flex items-center gap-2 font-mono", children: [_jsx("span", { className: "text-primary", children: "$" }), _jsx("span", { className: "text-card-foreground", children: "npx motia generate step" })] }) }) }), _jsxs("div", { className: "flex flex-col gap-8 items-center", children: [_jsx("span", { className: "text-muted-foreground text-xl", children: "or" }), _jsx("a", { href: "https://motia.dev/docs", target: "_blank", children: _jsx(Button, { size: "lg", className: "text-xl py-6 px-8", children: "Read developer docs" }) })] })] }));
5
+ };
@@ -0,0 +1 @@
1
+ export declare const LogsPage: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Logs } from '../components/logs/logs';
3
+ import { useLogs } from '../stores/use-logs';
4
+ import { useEffect } from 'react';
5
+ export const LogsPage = () => {
6
+ const setUnreadLogsCount = useLogs((state) => state.setUnreadLogsCount);
7
+ useEffect(() => {
8
+ setUnreadLogsCount(0);
9
+ return () => setUnreadLogsCount(0);
10
+ }, [setUnreadLogsCount]);
11
+ return (_jsxs("div", { className: "w-full h-screen overflow-hidden bg-background text-foreground", children: [_jsxs("header", { className: "p-4 border-b border-border", children: [_jsx("h1", { className: "text-2xl font-bold text-foreground", children: "Logs" }), _jsx("span", { className: "text-sm text-muted-foreground", children: "Check all logs saved locally" })] }), _jsx(Logs, {})] }));
12
+ };
@@ -0,0 +1 @@
1
+ export declare const StatesPage: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { States } from '../components/states/states';
3
+ export const StatesPage = () => {
4
+ return (_jsxs("div", { className: "w-full h-screen overflow-hidden bg-background text-foreground", children: [_jsxs("header", { className: "p-4 border-b border-border", children: [_jsx("h1", { className: "text-xl font-bold text-foreground", children: "State details" }), _jsx("span", { className: "text-sm text-muted-foreground", children: "Check all states saved locally along with all fields" })] }), _jsx(States, {})] }));
5
+ };
@@ -10,6 +10,7 @@ export type LogsState = {
10
10
  logs: Log[];
11
11
  addLog: (log: Log) => void;
12
12
  resetLogs: () => void;
13
+ unreadLogsCount: number;
14
+ setUnreadLogsCount: (count: number) => void;
13
15
  };
14
- export declare const useLogs: import("zustand").UseBoundStore<import("zustand").StoreApi<LogsState>>;
15
- //# sourceMappingURL=use-logs.d.ts.map
16
+ export declare function useLogs<SelectorOutput = LogsState>(selector?: (state: LogsState) => SelectorOutput): SelectorOutput;
@@ -1,6 +1,52 @@
1
- import { create } from 'zustand';
2
- export const useLogs = create()((set) => ({
3
- logs: [],
4
- addLog: (log) => set((state) => ({ ...state, logs: [...state.logs, log] })),
5
- resetLogs: () => set({ logs: [] }),
6
- }));
1
+ import { useSyncExternalStore, useCallback } from 'react';
2
+ const listeners = new Set();
3
+ let currentLogs = [];
4
+ let currentUnreadLogsCount = 0;
5
+ let memoizedSnapshot;
6
+ const updateMemoizedSnapshot = () => {
7
+ memoizedSnapshot = {
8
+ logs: currentLogs,
9
+ unreadLogsCount: currentUnreadLogsCount,
10
+ addLog: storeActions.addLog,
11
+ resetLogs: storeActions.resetLogs,
12
+ setUnreadLogsCount: storeActions.setUnreadLogsCount,
13
+ };
14
+ };
15
+ const notify = () => {
16
+ listeners.forEach((listener) => listener());
17
+ };
18
+ const storeActions = {
19
+ addLog: (log) => {
20
+ currentLogs = [log, ...currentLogs];
21
+ currentUnreadLogsCount += 1;
22
+ updateMemoizedSnapshot();
23
+ notify();
24
+ },
25
+ resetLogs: () => {
26
+ if (currentLogs.length === 0 && currentUnreadLogsCount === 0) {
27
+ return;
28
+ }
29
+ currentLogs = [];
30
+ currentUnreadLogsCount = 0;
31
+ updateMemoizedSnapshot();
32
+ notify();
33
+ },
34
+ setUnreadLogsCount: (count) => {
35
+ if (currentUnreadLogsCount === count) {
36
+ return;
37
+ }
38
+ currentUnreadLogsCount = count;
39
+ updateMemoizedSnapshot();
40
+ notify();
41
+ },
42
+ };
43
+ updateMemoizedSnapshot();
44
+ // Stable subscribe function so React doesn't unnecessarily tear down the subscription
45
+ const subscribe = (onStoreChange) => {
46
+ listeners.add(onStoreChange);
47
+ return () => listeners.delete(onStoreChange);
48
+ };
49
+ export function useLogs(selector = (state) => state) {
50
+ const getSnapshot = useCallback(() => selector(memoizedSnapshot), [selector]);
51
+ return useSyncExternalStore(subscribe, getSnapshot);
52
+ }
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  type Props = {
3
- color: string;
3
+ color?: string;
4
4
  id: string;
5
+ className?: string;
5
6
  };
6
7
  export declare const ArrowHead: React.FC<Props>;
7
8
  export {};
8
- //# sourceMappingURL=arrow-head.d.ts.map
@@ -1,2 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export const ArrowHead = (props) => (_jsxs("marker", { id: props.id, viewBox: "-5 -5 10 10", markerUnits: "strokeWidth", markerWidth: "10", markerHeight: "10", children: [_jsx("line", { x1: 0, y1: 0, x2: 2, y2: -2, stroke: props.color, strokeWidth: "1", strokeOpacity: "1", strokeLinecap: "round" }), _jsx("line", { x1: -2, y1: -2, x2: 0, y2: 0, stroke: props.color, strokeWidth: "1", strokeOpacity: "1", strokeLinecap: "round" })] }));
2
+ export const ArrowHead = (props) => {
3
+ // Use CSS custom property for theme-aware coloring, fallback to provided color
4
+ const strokeColor = props.color || 'var(--arrow-color, #B3B3B3)';
5
+ return (_jsxs("marker", { id: props.id, viewBox: "-5 -5 10 10", markerUnits: "strokeWidth", markerWidth: "10", markerHeight: "10", className: props.className, children: [_jsx("line", { x1: 0, y1: 0, x2: 2, y2: -2, stroke: strokeColor, strokeWidth: "1", strokeOpacity: "1", strokeLinecap: "round" }), _jsx("line", { x1: -2, y1: -2, x2: 0, y2: 0, stroke: strokeColor, strokeWidth: "1", strokeOpacity: "1", strokeLinecap: "round" })] }));
6
+ };
@@ -1,4 +1,3 @@
1
1
  import { EdgeProps } from '@xyflow/react';
2
2
  import React from 'react';
3
3
  export declare const BaseEdge: React.FC<EdgeProps>;
4
- //# sourceMappingURL=base-edge.d.ts.map
@@ -1,8 +1,23 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { BaseEdge as BaseReactFlowEdge, getSmoothStepPath } from '@xyflow/react';
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { BaseEdge as BaseReactFlowEdge, EdgeLabelRenderer, getSmoothStepPath } from '@xyflow/react';
3
+ import { cva } from 'class-variance-authority';
4
+ import { cn } from '@/lib/utils';
5
+ const labelVariants = cva('absolute pointer-events-all text-cs border p-1 px-2', {
6
+ variants: {
7
+ color: {
8
+ default: 'border-[#b3b3b3] bg-[#060014] text-gray-100 font-semibold border-solid rounded-full',
9
+ conditional: 'bg-amber-300 border-amber-950 text-amber-950 border-solid font-semibold italic rounded-lg',
10
+ },
11
+ },
12
+ defaultVariants: {
13
+ color: 'default',
14
+ },
15
+ });
3
16
  export const BaseEdge = (props) => {
4
17
  const { sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, data } = props;
5
- const [edgePath] = getSmoothStepPath({
18
+ const label = data?.label;
19
+ const labelVariant = data?.labelVariant;
20
+ const [edgePath, labelX, labelY] = getSmoothStepPath({
6
21
  sourceX,
7
22
  sourceY,
8
23
  targetX,
@@ -12,11 +27,11 @@ export const BaseEdge = (props) => {
12
27
  borderRadius: 20,
13
28
  offset: 10,
14
29
  });
15
- return (_jsx(BaseReactFlowEdge, { path: edgePath, style: {
16
- stroke: data?.variant === 'virtual' ? 'rgb(147, 169, 197)' : 'rgb(133, 176, 132)',
17
- strokeWidth: 0.5,
18
- shapeRendering: 'geometricPrecision',
19
- fill: 'none',
20
- mixBlendMode: 'screen',
21
- }, className: "edge-animated" }));
30
+ return (_jsxs(_Fragment, { children: [_jsx(BaseReactFlowEdge, { path: edgePath, style: {
31
+ stroke: data?.variant === 'virtual' ? 'rgb(111, 111, 111)' : '#0094FF',
32
+ strokeWidth: 2,
33
+ shapeRendering: 'geometricPrecision',
34
+ fill: 'none',
35
+ mixBlendMode: 'screen',
36
+ }, className: "edge-animated" }), label && (_jsx(EdgeLabelRenderer, { children: _jsx("div", { className: cn(labelVariants({ color: labelVariant })), style: { transform: `translateX(-50%) translateY(-50%) translate(${labelX}px, ${labelY}px)` }, children: _jsx("div", { className: "text-xs font-mono", children: label }) }) }))] }));
22
37
  };
@@ -1,2 +1 @@
1
1
  export declare const FlowLoader: () => import("react/jsx-runtime").JSX.Element;
2
- //# sourceMappingURL=flow-loader.d.ts.map
@@ -1,4 +1,4 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  export const FlowLoader = () => {
3
- return _jsx("div", { className: "absolute z-10 inset-0 w-full h-full bg-[#060911]" });
3
+ return _jsx("div", { className: "absolute z-10 inset-0 w-full h-full bg-background" });
4
4
  };
@@ -1,8 +1,13 @@
1
+ import React from 'react';
2
+ import { EdgeData, NodeData } from './nodes/nodes.types';
3
+ import { FlowConfigResponse, FlowResponse } from './hooks/use-get-flow-state';
4
+ import { Node as ReactFlowNode, Edge as ReactFlowEdge } from '@xyflow/react';
1
5
  import '@xyflow/react/dist/style.css';
2
- import { FlowResponse } from './hooks/use-get-flow-state';
6
+ export type FlowNode = ReactFlowNode<NodeData>;
7
+ export type FlowEdge = ReactFlowEdge<EdgeData>;
3
8
  type Props = {
4
9
  flow: FlowResponse;
10
+ flowConfig: FlowConfigResponse;
5
11
  };
6
12
  export declare const FlowView: React.FC<Props>;
7
13
  export {};
8
- //# sourceMappingURL=flow-view.d.ts.map
@@ -1,40 +1,64 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Background, BackgroundVariant, ReactFlow } from '@xyflow/react';
3
- import '@xyflow/react/dist/style.css';
4
- import { BaseEdge } from './base-edge';
2
+ import { LogConsole } from '@/components/logs/log-console';
3
+ import { Background, BackgroundVariant, ReactFlow, useReactFlow } from '@xyflow/react';
4
+ import { useCallback, useEffect, useMemo, useState } from 'react';
5
5
  import { ArrowHead } from './arrow-head';
6
- import { useGetFlowState } from './hooks/use-get-flow-state';
7
- import { useCallback, useEffect, useState } from 'react';
8
- import { NodeOrganizer } from './node-organizer';
6
+ import { BaseEdge } from './base-edge';
9
7
  import { FlowLoader } from './flow-loader';
10
- import { useLogListener } from '@/hooks/use-log-listener';
11
- import { LogConsole } from '@/components/log-console';
8
+ import { useGetFlowState } from './hooks/use-get-flow-state';
12
9
  import { Legend } from './legend';
10
+ import { useSaveWorkflowConfig } from './hooks/use-save-workflow-config';
11
+ import { NodeOrganizer } from './node-organizer';
12
+ import { useDebounced } from '@/hooks/use-debounced';
13
+ import '@xyflow/react/dist/style.css';
13
14
  const edgeTypes = {
14
15
  base: BaseEdge,
15
16
  };
16
- export const FlowView = ({ flow }) => {
17
- const { nodes, edges, onNodesChange, onEdgesChange, nodeTypes } = useGetFlowState(flow);
17
+ export const FlowView = ({ flow, flowConfig }) => {
18
+ const { nodes, edges, onNodesChange, onEdgesChange, nodeTypes } = useGetFlowState(flow, flowConfig);
18
19
  const [initialized, setInitialized] = useState(false);
20
+ const { getNodes } = useReactFlow();
21
+ const { saveConfig } = useSaveWorkflowConfig(flow.id);
19
22
  const [hoveredType, setHoveredType] = useState(null);
20
- useLogListener();
21
23
  useEffect(() => setInitialized(false), [flow]);
22
24
  const onInitialized = useCallback(() => {
23
25
  setTimeout(() => setInitialized(true), 10);
24
26
  }, []);
25
- const highlightClass = (nodeType) => {
27
+ const getClassName = useCallback((nodeType) => {
26
28
  if (!hoveredType)
27
29
  return '';
28
- return nodeType === hoveredType
29
- ? 'shadow-[0_0_15px_rgba(255,255,255,0.15)] border border-white/30 scale-[1.02] transition-all duration-300'
30
- : 'opacity-30 transition-all duration-300';
31
- };
32
- const nodesWithHighlights = nodes.map((node) => ({
30
+ if (nodeType) {
31
+ return nodeType === hoveredType
32
+ ? 'border border-border scale-[1.02] transition-all duration-300'
33
+ : 'opacity-30 transition-all duration-300';
34
+ }
35
+ // If no nodeType is provided, this is an edge
36
+ return 'opacity-30 transition-all duration-300';
37
+ }, [hoveredType]);
38
+ const nodesWithHighlights = useMemo(() => nodes.map((node) => ({
33
39
  ...node,
34
- className: highlightClass(node.data.type), // Access type from `data.type`
35
- }));
40
+ className: getClassName(node.data.type),
41
+ })), [nodes, getClassName]);
42
+ const edgesWithHighlights = useMemo(() => edges.map((edge) => ({
43
+ ...edge,
44
+ className: getClassName(), // No argument means it's an edge
45
+ })), [edges, getClassName]);
46
+ const saveFlowConfig = useCallback(() => {
47
+ const steps = getNodes().reduce((acc, node) => {
48
+ if (node.data.filePath) {
49
+ acc[node.data.filePath] = node.position;
50
+ }
51
+ return acc;
52
+ }, {});
53
+ return saveConfig(steps);
54
+ }, [saveConfig, getNodes]);
55
+ const debouncedSaveConfig = useDebounced(saveFlowConfig);
56
+ const onNodesChangeHandler = useCallback((changes) => {
57
+ onNodesChange(changes);
58
+ debouncedSaveConfig();
59
+ }, [onNodesChange, debouncedSaveConfig]);
36
60
  if (!nodeTypes) {
37
61
  return null;
38
62
  }
39
- return (_jsxs("div", { className: "w-full h-full relative bg-black", children: [!initialized && _jsx(FlowLoader, {}), _jsx(Legend, { onHover: setHoveredType }), _jsxs(ReactFlow, { nodes: nodesWithHighlights, edges: edges, nodeTypes: nodeTypes, edgeTypes: edgeTypes, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, children: [_jsx(Background, { variant: BackgroundVariant.Dots, gap: 20, size: 1, color: "#444" }), _jsx(NodeOrganizer, { onInitialized: onInitialized }), _jsx("svg", { children: _jsx("defs", { children: _jsx(ArrowHead, { color: "#B3B3B3", id: "arrowhead" }) }) })] }), _jsx(LogConsole, {})] }));
63
+ return (_jsxs("div", { className: "w-full h-full relative bg-background", children: [!initialized && _jsx(FlowLoader, {}), _jsx(Legend, { onHover: setHoveredType }), _jsxs(ReactFlow, { nodes: nodesWithHighlights, edges: edgesWithHighlights, nodeTypes: nodeTypes, edgeTypes: edgeTypes, onNodesChange: onNodesChangeHandler, onEdgesChange: onEdgesChange, children: [_jsx(Background, { variant: BackgroundVariant.Dots, gap: 50, size: 2, className: "[--xy-background-color-dots:theme(colors.muted.DEFAULT)] [--xy-background-color:theme(colors.background)]" }), _jsx(NodeOrganizer, { onInitialized: onInitialized }), _jsx("svg", { className: "[--arrow-color:theme(colors.muted.foreground)]", children: _jsx("defs", { children: _jsx(ArrowHead, { id: "arrowhead" }) }) })] }), _jsx(LogConsole, {})] }));
40
64
  };
@@ -1,13 +1,14 @@
1
1
  import { Edge, Node } from '@xyflow/react';
2
+ import React from 'react';
2
3
  import type { EdgeData, NodeData } from '../nodes/nodes.types';
3
4
  type Emit = string | {
4
- type: string;
5
+ topic: string;
5
6
  label?: string;
6
7
  };
7
8
  type FlowStep = {
8
9
  id: string;
9
10
  name: string;
10
- type: 'event' | 'api' | 'noop';
11
+ type: 'event' | 'api' | 'noop' | 'cron';
11
12
  description?: string;
12
13
  subscribes?: string[];
13
14
  emits: Emit[];
@@ -16,12 +17,17 @@ type FlowStep = {
16
17
  webhookUrl?: string;
17
18
  language?: string;
18
19
  nodeComponentPath?: string;
20
+ filePath?: string;
19
21
  };
20
22
  export type FlowResponse = {
21
23
  id: string;
22
24
  name: string;
23
25
  steps: FlowStep[];
24
26
  edges: FlowEdge[];
27
+ error?: string;
28
+ };
29
+ export type FlowConfigResponse = {
30
+ [key: string]: Position;
25
31
  };
26
32
  type FlowEdge = {
27
33
  id: string;
@@ -29,12 +35,15 @@ type FlowEdge = {
29
35
  target: string;
30
36
  data: EdgeData;
31
37
  };
32
- export declare const useGetFlowState: (flow: FlowResponse) => {
38
+ type Position = {
39
+ x: number;
40
+ y: number;
41
+ };
42
+ export declare const useGetFlowState: (flow: FlowResponse, flowConfig: FlowConfigResponse) => {
33
43
  nodes: Node<NodeData>[];
34
44
  edges: Edge<EdgeData>[];
35
45
  onNodesChange: import("@xyflow/react").OnNodesChange<Node<NodeData>>;
36
46
  onEdgesChange: import("@xyflow/react").OnEdgesChange<Edge<EdgeData>>;
37
- nodeTypes: Record<string, import("react").ComponentType<any>> | undefined;
47
+ nodeTypes: Record<string, React.ComponentType<any>> | undefined;
38
48
  };
39
49
  export {};
40
- //# sourceMappingURL=use-get-flow-state.d.ts.map
@@ -3,24 +3,32 @@ import { useEffect, useState } from 'react';
3
3
  import { ApiFlowNode } from '../nodes/api-flow-node';
4
4
  import { NoopFlowNode } from '../nodes/noop-flow-node';
5
5
  import { EventFlowNode } from '../nodes/event-flow-node';
6
- async function importFlow(flow) {
6
+ import { CronNode } from '@/publicComponents/cron-node';
7
+ const getNodePosition = (flowConfig, stepName) => {
8
+ const position = flowConfig[stepName];
9
+ return position || { x: 0, y: 0 };
10
+ };
11
+ async function importFlow(flow, flowConfig) {
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
13
  const nodeTypes = {
8
14
  event: EventFlowNode,
9
15
  api: ApiFlowNode,
10
16
  noop: NoopFlowNode,
17
+ cron: CronNode,
11
18
  };
12
19
  // Load custom node components if they exist
13
20
  for (const step of flow.steps) {
14
21
  if (step.nodeComponentPath) {
15
- const module = await import(/* @vite-ignore */ step.nodeComponentPath);
16
- nodeTypes[step.nodeComponentPath] = module.default;
22
+ const module = await import(/* @vite-ignore */ `/@fs/${step.nodeComponentPath}`);
23
+ nodeTypes[step.nodeComponentPath] = module.Node ?? module.default;
17
24
  }
18
25
  }
19
26
  // Create nodes from steps
20
27
  const nodes = flow.steps.map((step) => ({
21
28
  id: step.id,
22
29
  type: step.nodeComponentPath ? step.nodeComponentPath : step.type,
23
- position: { x: 0, y: 0 },
30
+ filePath: step.filePath,
31
+ position: step.filePath ? getNodePosition(flowConfig, step.filePath) : { x: 0, y: 0 },
24
32
  data: step,
25
33
  language: step.language,
26
34
  }));
@@ -31,18 +39,19 @@ async function importFlow(flow) {
31
39
  }));
32
40
  return { nodes, edges, nodeTypes };
33
41
  }
34
- export const useGetFlowState = (flow) => {
42
+ export const useGetFlowState = (flow, flowConfig) => {
43
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
44
  const [nodeTypes, setNodeTypes] = useState();
36
45
  const [nodes, setNodes, onNodesChange] = useNodesState([]);
37
46
  const [edges, setEdges, onEdgesChange] = useEdgesState([]);
38
47
  useEffect(() => {
39
- if (!flow)
48
+ if (!flow || flow.error)
40
49
  return;
41
- importFlow(flow).then(({ nodes, edges, nodeTypes }) => {
50
+ importFlow(flow, flowConfig).then(({ nodes, edges, nodeTypes }) => {
42
51
  setNodes(nodes);
43
52
  setEdges(edges);
44
53
  setNodeTypes(nodeTypes);
45
54
  });
46
- }, [flow]);
55
+ }, [flow, flowConfig, setNodes, setEdges, setNodeTypes]);
47
56
  return { nodes, edges, onNodesChange, onEdgesChange, nodeTypes };
48
57
  };
@@ -1,4 +1,3 @@
1
1
  import { Edge, Node } from '@xyflow/react';
2
2
  import { EventNodeData, EdgeData, ApiNodeData } from '../nodes/nodes.types';
3
3
  export declare const useOrganizeNodes: (nodes: Node<EventNodeData | ApiNodeData>[], edges: Edge<EdgeData>[], setNodes: (nodes: Node<EventNodeData | ApiNodeData>[]) => void) => void;
4
- //# sourceMappingURL=use-organize-nodes.d.ts.map
@@ -0,0 +1,9 @@
1
+ export type NodePosition = {
2
+ [key: string]: {
3
+ x: number;
4
+ y: number;
5
+ };
6
+ };
7
+ export declare const useSaveWorkflowConfig: (flowId: string) => {
8
+ saveConfig: (body: NodePosition) => Promise<any>;
9
+ };
@@ -0,0 +1,23 @@
1
+ import { useCallback } from 'react';
2
+ export const useSaveWorkflowConfig = (flowId) => {
3
+ const saveConfig = useCallback(async (body) => {
4
+ try {
5
+ const response = await fetch(`/flows/${flowId}/config`, {
6
+ method: 'POST',
7
+ headers: {
8
+ 'Content-Type': 'application/json',
9
+ },
10
+ body: JSON.stringify({ [flowId]: body }),
11
+ });
12
+ if (!response.ok) {
13
+ throw new Error(`Failed to save config: ${response.statusText}`);
14
+ }
15
+ return await response.json();
16
+ }
17
+ catch (error) {
18
+ console.error('Error saving workflow config:', error);
19
+ throw error;
20
+ }
21
+ }, [flowId]);
22
+ return { saveConfig };
23
+ };
@@ -1,4 +1,4 @@
1
- export declare const Legend: ({ onHover }: {
1
+ import { FC } from 'react';
2
+ export declare const Legend: FC<{
2
3
  onHover: (type: string | null) => void;
3
- }) => import("react/jsx-runtime").JSX.Element;
4
- //# sourceMappingURL=legend.d.ts.map
4
+ }>;