@motiadev/workbench 0.4.4-beta.97 → 0.5.0-beta.99

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.
@@ -1,6 +1,7 @@
1
1
  import { FC } from 'react';
2
2
  type JsonEditorProps = {
3
3
  value: string;
4
+ height?: number | string;
4
5
  schema?: Record<string, unknown>;
5
6
  onChange: (value: string) => void;
6
7
  onValidate?: (isValid: boolean) => void;
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo } from 'react';
3
3
  import Editor, { useMonaco } from '@monaco-editor/react';
4
4
  import { useThemeStore } from '@/stores/use-theme-store';
5
- export const JsonEditor = ({ value, schema, onChange, onValidate }) => {
5
+ export const JsonEditor = ({ value, height = 300, schema, onChange, onValidate }) => {
6
6
  const monaco = useMonaco();
7
7
  const theme = useThemeStore((state) => state.theme);
8
8
  const editorTheme = useMemo(() => (theme === 'dark' ? 'vs-dark' : 'light'), [theme]);
@@ -22,7 +22,7 @@ export const JsonEditor = ({ value, schema, onChange, onValidate }) => {
22
22
  : [],
23
23
  });
24
24
  }, [monaco, schema]);
25
- return (_jsx(Editor, { "data-testid": "json-editor", height: "200px", language: "json", value: value, theme: editorTheme, onChange: (value) => {
25
+ return (_jsx(Editor, { "data-testid": "json-editor", height: height, language: "json", value: value, theme: editorTheme, onChange: (value) => {
26
26
  if (!value) {
27
27
  onValidate?.(false);
28
28
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Badge } from '../ui/badge';
2
+ import { Badge } from '@motiadev/ui';
3
3
  const map = {
4
4
  info: 'info',
5
5
  error: 'error',
@@ -1,6 +1,6 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Sidebar } from '@/components/sidebar/sidebar';
3
- import { Badge } from '@/components/ui/badge';
3
+ import { Badge } from '@motiadev/ui';
4
4
  import { formatDuration } from '@/lib/utils';
5
5
  import { X } from 'lucide-react';
6
6
  import { memo } from 'react';
@@ -1,18 +1,18 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { cva } from 'class-variance-authority';
3
- const statusVariants = cva('inline-flex items-center rounded-full px-4 py-1 text-xs font-bold transition-colors', {
4
- variants: {
5
- status: {
6
- running: 'dark:bg-accent-100 dark:text-accent-1000 bg-accent-200 text-accent-900 capitalize',
7
- completed: 'bg-accent-1000 text-white',
8
- failed: 'bg-destructive/10 text-destructive capitalize',
9
- default: 'dark:bg-gray-800/30 dark:text-gray-500 bg-gray-100 text-gray-800',
10
- },
11
- },
12
- defaultVariants: {
13
- status: 'default',
14
- },
15
- });
2
+ import { Badge } from '@motiadev/ui';
3
+ import { useMemo } from 'react';
16
4
  export const TraceStatusBadge = ({ status, duration }) => {
17
- return _jsx("div", { className: statusVariants({ status }), children: duration && status !== 'failed' ? duration : status });
5
+ const variant = useMemo(() => {
6
+ if (status === 'running') {
7
+ return 'info';
8
+ }
9
+ if (status === 'completed') {
10
+ return 'success';
11
+ }
12
+ if (status === 'failed') {
13
+ return 'error';
14
+ }
15
+ return 'default';
16
+ }, [status]);
17
+ return _jsx(Badge, { variant: variant, children: duration && status !== 'failed' ? duration : status });
18
18
  };
@@ -1,34 +1,3 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Badge } from '@/components/ui/badge';
3
- import { Panel } from '@motiadev/ui';
4
- import { Copy, Database, Hash } from 'lucide-react';
5
- import { useMemo } from 'react';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
6
2
  import JsonView from 'react18-json-view';
7
- export const StateDetails = ({ state }) => {
8
- const stateMetadata = useMemo(() => {
9
- const valueSize = JSON.stringify(state.value).length;
10
- const sizeLabel = valueSize < 1024 ? `${valueSize} bytes` : `${(valueSize / 1024).toFixed(1)} KB`;
11
- return {
12
- size: sizeLabel,
13
- isComplex: typeof state.value === 'object' && state.value !== null,
14
- hasNesting: typeof state.value === 'object' &&
15
- state.value !== null &&
16
- Object.values(state.value).some((v) => typeof v === 'object'),
17
- };
18
- }, [state.value]);
19
- const copyToClipboard = async () => {
20
- try {
21
- await navigator.clipboard.writeText(JSON.stringify(state.value, null, 2));
22
- }
23
- catch (err) {
24
- console.error('Failed to copy to clipboard:', err);
25
- }
26
- };
27
- return (_jsxs(Panel, { title: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Database, { className: "w-4 h-4" }), _jsx("h3", { className: "text-sm font-semibold text-foreground", children: "State Overview" })] }), actions: [
28
- {
29
- icon: _jsx(Copy, {}),
30
- onClick: copyToClipboard,
31
- label: 'Copy',
32
- },
33
- ], children: [_jsxs("div", { className: "space-y-3", children: [_jsxs("div", { className: "grid grid-cols-2 gap-2 text-xs", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("span", { className: "text-muted-foreground font-medium", children: "Type" }), _jsx("div", { children: _jsx(Badge, { variant: "secondary", className: "text-xs", children: state.type }) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("span", { className: "text-muted-foreground font-medium", children: "Size" }), _jsx("div", { className: "text-foreground font-mono", children: stateMetadata.size })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("span", { className: "text-muted-foreground font-medium", children: "Group ID" }), _jsx("div", { className: "text-foreground font-mono text-xs bg-background px-2 py-1 rounded border", children: state.groupId })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("span", { className: "text-muted-foreground font-medium", children: "Key" }), _jsxs("div", { className: "text-foreground font-mono text-xs bg-background px-2 py-1 rounded border flex items-center gap-1", children: [_jsx(Hash, { className: "w-3 h-3" }), state.key] })] })] }), stateMetadata.isComplex && (_jsx("div", { className: "pt-2 border-t border-border/50", children: _jsxs("div", { className: "flex gap-2", children: [_jsx(Badge, { variant: "outline", className: "text-xs", children: stateMetadata.hasNesting ? 'Nested Object' : 'Simple Object' }), Array.isArray(state.value) && (_jsxs(Badge, { variant: "outline", className: "text-xs", children: [state.value.length, " items"] }))] }) }))] }), _jsxs("div", { className: "space-y-2", children: [_jsx("h3", { className: "text-sm font-semibold text-foreground", children: "Value Structure" }), _jsx("div", { className: "bg-background border border-border rounded-lg p-3 overflow-auto max-h-[400px]", children: _jsx(JsonView, { src: state.value, theme: "default", enableClipboard: false, collapsed: 2 }) })] })] }));
34
- };
3
+ export const StateDetails = ({ state }) => _jsx(JsonView, { src: state.value, theme: "default" });
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Button, Panel } from '@motiadev/ui';
3
- import { AlertCircle, Check, Database, Loader2, Save } from 'lucide-react';
4
- import { useState, useCallback, useEffect, useRef } from 'react';
2
+ import { Button } from '@motiadev/ui';
3
+ import { AlertCircle, Check, Loader2, Save } from 'lucide-react';
4
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
5
  import { JsonEditor } from '../endpoints/json-editor';
6
6
  export const StateEditor = ({ state }) => {
7
7
  const [isRequestLoading, setIsRequestLoading] = useState(false);
@@ -58,5 +58,14 @@ export const StateEditor = ({ state }) => {
58
58
  setHasChanges(false);
59
59
  setSaveStatus('idle');
60
60
  }, [state.value]);
61
- return (_jsxs(Panel, { title: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Database, { className: "w-4 h-4" }), _jsx("h3", { className: "text-sm font-semibold text-foreground", children: "Edit State Value" })] }), children: [_jsx("p", { className: "text-xs text-muted-foreground mb-3", children: "Modify the state value using the JSON editor below. Changes will be saved to the system when you click Save." }), _jsxs("div", { className: "text-xs text-muted-foreground space-y-1", children: [_jsxs("div", { children: [_jsx("strong", { children: "Group:" }), " ", _jsx("code", { className: "bg-background px-1 py-0.5 rounded", children: state.groupId })] }), _jsxs("div", { children: [_jsx("strong", { children: "Key:" }), " ", _jsx("code", { className: "bg-background px-1 py-0.5 rounded", children: state.key })] })] }), _jsxs("div", { className: "space-y-3 pt-2", children: [_jsxs("div", { className: "relative", children: [_jsx(JsonEditor, { value: jsonValue, onChange: handleJsonChange, onValidate: setIsValid }), !isValid && (_jsxs("div", { className: "absolute top-2 right-2 bg-destructive/90 text-destructive-foreground px-2 py-1 rounded text-xs flex items-center gap-1", children: [_jsx(AlertCircle, { className: "w-3 h-3" }), "Invalid JSON"] }))] }), saveStatus === 'success' && (_jsx("div", { className: "bg-green-50 dark:bg-green-950/20 border border-green-200 dark:border-green-800 rounded-lg p-3", children: _jsxs("div", { className: "flex items-center gap-2 text-green-700 dark:text-green-400 text-sm", children: [_jsx(Check, { className: "w-4 h-4" }), "State saved successfully!"] }) })), saveStatus === 'error' && (_jsx("div", { className: "bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-800 rounded-lg p-3", children: _jsxs("div", { className: "flex items-center gap-2 text-red-700 dark:text-red-400 text-sm", children: [_jsx(AlertCircle, { className: "w-4 h-4" }), "Failed to save state. Please try again."] }) }))] }), _jsxs("div", { className: "flex items-center justify-between pt-2", children: [_jsx("div", { className: "text-xs text-muted-foreground", children: hasChanges ? (_jsxs("span", { className: "flex items-center gap-1", children: [_jsx("div", { className: "w-2 h-2 bg-orange-500 rounded-full" }), "Unsaved changes"] })) : (_jsxs("span", { className: "flex items-center gap-1", children: [_jsx("div", { className: "w-2 h-2 bg-green-500 rounded-full" }), "Up to date"] })) }), _jsxs("div", { className: "flex items-center gap-2", children: [hasChanges && (_jsx(Button, { variant: "secondary", onClick: resetChanges, disabled: isRequestLoading, children: "Reset" })), _jsx(Button, { onClick: handleSave, variant: "accent", disabled: isRequestLoading || !isValid || !hasChanges, "data-testid": "state-save-button", children: isRequestLoading ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { className: "w-3 h-3 animate-spin mr-1" }), "Saving..."] })) : (_jsxs(_Fragment, { children: [_jsx(Save, { className: "w-3 h-3 mr-1" }), "Save Changes"] })) })] })] })] }));
61
+ const statusView = useMemo(() => {
62
+ if (saveStatus === 'success') {
63
+ return (_jsx("div", { className: "bg-green-50 dark:bg-green-950/20 border border-green-200 dark:border-green-800 rounded-lg p-2", children: _jsxs("div", { className: "flex items-center gap-2 text-green-700 dark:text-green-400 text-sm", children: [_jsx(Check, { className: "w-4 h-4" }), "State saved successfully!"] }) }));
64
+ }
65
+ if (saveStatus === 'error') {
66
+ return (_jsx("div", { className: "bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-800 rounded-lg p-2", children: _jsxs("div", { className: "flex items-center gap-2 text-red-700 dark:text-red-400 text-sm", children: [_jsx(AlertCircle, { className: "w-4 h-4" }), "Failed to save state. Please try again."] }) }));
67
+ }
68
+ return (_jsx("div", { className: "text-xs text-muted-foreground", children: hasChanges ? (_jsxs("span", { className: "flex items-center gap-1", children: [_jsx("div", { className: "w-2 h-2 bg-orange-500 rounded-full" }), "Unsaved changes"] })) : (_jsxs("span", { className: "flex items-center gap-1", children: [_jsx("div", { className: "w-2 h-2 bg-green-500 rounded-full" }), "Up to date"] })) }));
69
+ }, [saveStatus, hasChanges]);
70
+ return (_jsxs("div", { className: "flex flex-col gap-2 h-full", children: [_jsx("p", { className: "text-xs text-muted-foreground", children: "Modify the state value using the JSON editor below." }), _jsx("div", { className: "space-y-3 pt-2 flex flex-col", children: _jsxs("div", { className: "relative flex-1", children: [_jsx(JsonEditor, { value: jsonValue, onChange: handleJsonChange, onValidate: setIsValid, height: 'calc(100vh - 300px)' }), !isValid && (_jsxs("div", { className: "absolute top-2 right-2 bg-destructive/90 text-destructive-foreground px-2 py-1 rounded text-xs flex items-center gap-1", children: [_jsx(AlertCircle, { className: "w-3 h-3" }), "Invalid JSON"] }))] }) }), _jsxs("div", { className: "flex items-center justify-between pt-2", children: [statusView, _jsxs("div", { className: "flex items-center gap-2", children: [hasChanges && (_jsx(Button, { variant: "secondary", onClick: resetChanges, disabled: isRequestLoading, children: "Reset" })), _jsx(Button, { onClick: handleSave, variant: "accent", disabled: isRequestLoading || !isValid || !hasChanges, "data-testid": "state-save-button", children: isRequestLoading ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { className: "w-3 h-3 animate-spin mr-1" }), "Saving..."] })) : (_jsxs(_Fragment, { children: [_jsx(Save, { className: "w-3 h-3 mr-1" }), "Save Changes"] })) })] })] })] }));
62
71
  };
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { ChevronRight, X } from 'lucide-react';
3
3
  import { useCallback, useState } from 'react';
4
4
  import { Sidebar } from '@/components/sidebar/sidebar';
5
- import { Label } from '@/components/ui/label';
5
+ import { Label } from '@motiadev/ui';
6
6
  import { LanguageIndicator } from '@/publicComponents/base-node/language-indicator';
7
7
  import { Subscribe } from './base-node/subscribe';
8
8
  import { Emits } from './base-node/emits';