@motiadev/workbench 0.7.2-beta.135-685562 → 0.7.2-beta.135-604391

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 (55) hide show
  1. package/dist/src/App.js +2 -2
  2. package/dist/src/components/flow/base-edge.js +1 -1
  3. package/dist/src/components/logs/log-detail.js +1 -1
  4. package/dist/src/components/observability/trace-item/trace-item-detail.js +1 -2
  5. package/dist/src/components/observability/trace-item/trace-item.js +1 -1
  6. package/dist/src/components/observability/traces-groups.js +1 -1
  7. package/dist/src/components/states/state-editor.js +1 -1
  8. package/dist/src/components/states/state-sidebar.js +1 -1
  9. package/dist/src/components/ui/table.js +1 -1
  10. package/dist/src/components/ui/theme-toggle.js +1 -1
  11. package/dist/src/index.css +10 -6
  12. package/dist/src/lib/utils.d.ts +0 -2
  13. package/dist/src/lib/utils.js +0 -5
  14. package/dist/src/publicComponents/base-node/feature-card.js +1 -1
  15. package/dist/src/publicComponents/base-node/node-header.js +1 -1
  16. package/dist/src/publicComponents/base-node/node-sidebar.js +1 -1
  17. package/dist/tsconfig.app.tsbuildinfo +1 -1
  18. package/dist/tsconfig.node.tsbuildinfo +1 -1
  19. package/package.json +4 -3
  20. package/dist/src/components/endpoints/endpoint-badge.d.ts +0 -10
  21. package/dist/src/components/endpoints/endpoint-badge.js +0 -22
  22. package/dist/src/components/endpoints/endpoint-body-panel.d.ts +0 -13
  23. package/dist/src/components/endpoints/endpoint-body-panel.js +0 -16
  24. package/dist/src/components/endpoints/endpoint-call.d.ts +0 -7
  25. package/dist/src/components/endpoints/endpoint-call.js +0 -58
  26. package/dist/src/components/endpoints/endpoint-description.d.ts +0 -7
  27. package/dist/src/components/endpoints/endpoint-description.js +0 -13
  28. package/dist/src/components/endpoints/endpoint-path-params-panel.d.ts +0 -8
  29. package/dist/src/components/endpoints/endpoint-path-params-panel.js +0 -17
  30. package/dist/src/components/endpoints/endpoint-query-params-panel.d.ts +0 -8
  31. package/dist/src/components/endpoints/endpoint-query-params-panel.js +0 -16
  32. package/dist/src/components/endpoints/endpoint-response-schema.d.ts +0 -10
  33. package/dist/src/components/endpoints/endpoint-response-schema.js +0 -17
  34. package/dist/src/components/endpoints/endpoint-response.d.ts +0 -8
  35. package/dist/src/components/endpoints/endpoint-response.js +0 -50
  36. package/dist/src/components/endpoints/endpoint-side-panel.d.ts +0 -8
  37. package/dist/src/components/endpoints/endpoint-side-panel.js +0 -25
  38. package/dist/src/components/endpoints/endpoints-page.d.ts +0 -1
  39. package/dist/src/components/endpoints/endpoints-page.js +0 -14
  40. package/dist/src/components/endpoints/hooks/use-get-endpoints.d.ts +0 -2
  41. package/dist/src/components/endpoints/hooks/use-get-endpoints.js +0 -8
  42. package/dist/src/components/endpoints/hooks/use-json-schema-to-json.d.ts +0 -4
  43. package/dist/src/components/endpoints/hooks/use-json-schema-to-json.js +0 -11
  44. package/dist/src/components/endpoints/hooks/use-path-params.d.ts +0 -1
  45. package/dist/src/components/endpoints/hooks/use-path-params.js +0 -4
  46. package/dist/src/components/endpoints/hooks/use-state-stream.d.ts +0 -7
  47. package/dist/src/components/endpoints/hooks/use-state-stream.js +0 -11
  48. package/dist/src/components/endpoints/hooks/utils.d.ts +0 -1
  49. package/dist/src/components/endpoints/hooks/utils.js +0 -29
  50. package/dist/src/components/endpoints/response-body.d.ts +0 -7
  51. package/dist/src/components/endpoints/response-body.js +0 -6
  52. package/dist/src/components/sidebar/sidebar.d.ts +0 -8
  53. package/dist/src/components/sidebar/sidebar.js +0 -39
  54. /package/dist/src/components/{endpoints → ui}/json-editor.d.ts +0 -0
  55. /package/dist/src/components/{endpoints → ui}/json-editor.js +0 -0
@@ -1,8 +0,0 @@
1
- import { FC } from 'react';
2
- type EndpointResponseProps = {
3
- responseCode: number | string | undefined;
4
- responseBody: Record<string, any> | undefined;
5
- executionTime?: number;
6
- };
7
- export declare const EndpointResponse: FC<EndpointResponseProps>;
8
- export {};
@@ -1,50 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useStateStream } from '@/components/endpoints/hooks/use-state-stream';
3
- import { useThemeStore } from '@/stores/use-theme-store';
4
- import { Panel } from '@motiadev/ui';
5
- import { XCircle } from 'lucide-react';
6
- import { useMemo } from 'react';
7
- import ReactJson from 'react18-json-view';
8
- const getStatusMessage = (status) => {
9
- switch (status) {
10
- case 200:
11
- return 'OK';
12
- case 201:
13
- return 'Created';
14
- case 204:
15
- return 'No Content';
16
- case 400:
17
- return 'Bad Request';
18
- case 401:
19
- return 'Unauthorized';
20
- case 403:
21
- return 'Forbidden';
22
- case 404:
23
- return 'Not Found';
24
- case 500:
25
- return 'Internal Server Error';
26
- default:
27
- return 'Unknown Status';
28
- }
29
- };
30
- export const EndpointResponse = ({ responseCode, executionTime, responseBody }) => {
31
- const theme = useThemeStore((state) => state.theme);
32
- const { data, isStreamed, originalData } = useStateStream(responseBody);
33
- const statusMessage = useMemo(() => getStatusMessage(Number(responseCode)), [responseCode]);
34
- const isError = Number(responseCode) >= 400;
35
- if (!responseBody || !responseCode) {
36
- return null;
37
- }
38
- return (_jsx(Panel, { "data-testid": 'endpoint-response-container', tabs: isStreamed
39
- ? [
40
- {
41
- label: 'Streamed Response',
42
- content: (_jsx(ReactJson, { src: data, dark: theme === 'dark', style: { backgroundColor: 'transparent' } })),
43
- },
44
- {
45
- label: 'Original',
46
- content: (_jsx(ReactJson, { src: originalData, dark: theme === 'dark', style: { backgroundColor: 'transparent' } })),
47
- },
48
- ]
49
- : undefined, title: _jsxs("div", { className: "flex flex-row justify-between items-center flex-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [isError && _jsx(XCircle, { className: "text-red-500 w-4 h-4" }), _jsxs("span", { className: "font-bold text-xs", children: [responseCode, " - ", statusMessage] })] }), !!executionTime && (_jsxs("span", { className: "text-xs text-muted-foreground justify-self-end", children: ["Execution time: ", _jsxs("span", { className: "font-bold", children: [executionTime, "ms"] })] }))] }), subtitle: isStreamed && (_jsxs("span", { className: "col-span-2 flex flex-row items-center font-medium text-card-foreground text-xs mt-2", children: [_jsxs("span", { className: "inline-block w-2 h-2 rounded-full bg-green-500 mr-2 relative", children: [_jsx("span", { className: "absolute inset-0 rounded-full bg-green-500 animate-[ping_1.5s_ease-in-out_infinite]" }), _jsx("span", { className: "absolute inset-0 rounded-full bg-green-500" })] }), "Object is being streamed, this is not the actual response from the API Endpoint"] })), children: !isStreamed && (_jsx(ReactJson, { src: data, dark: theme === 'dark', style: { backgroundColor: 'transparent' } })) }));
50
- };
@@ -1,8 +0,0 @@
1
- import { ApiEndpoint } from '@/types/endpoint';
2
- import { FC } from 'react';
3
- type Props = {
4
- endpoint: ApiEndpoint;
5
- onClose: () => void;
6
- };
7
- export declare const EndpointSidePanel: FC<Props>;
8
- export {};
@@ -1,25 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Sidebar } from '@/components/sidebar/sidebar';
3
- import { X } from 'lucide-react';
4
- import { EndpointBadge } from './endpoint-badge';
5
- import { EndpointCall } from './endpoint-call';
6
- import { EndpointDescription } from './endpoint-description';
7
- export const EndpointSidePanel = ({ endpoint, onClose }) => {
8
- return (_jsx(Sidebar, { initialWidth: 600, subtitle: endpoint.description, title: _jsxs("div", { className: "flex flex-row gap-2 items-center", children: [_jsx(EndpointBadge, { variant: endpoint.method, children: endpoint.method.toUpperCase() }), _jsx("span", { className: "text-md font-bold", children: endpoint.path })] }), onClose: onClose, tabs: [
9
- {
10
- label: 'Details',
11
- content: _jsx(EndpointDescription, { endpoint: endpoint }),
12
- 'data-testid': 'endpoint-details-tab',
13
- },
14
- {
15
- label: 'Call',
16
- content: _jsx(EndpointCall, { endpoint: endpoint }),
17
- 'data-testid': 'endpoint-call-tab',
18
- },
19
- ], actions: [
20
- {
21
- icon: _jsx(X, { className: "cursor-pointer w-4 h-4", onClick: onClose }),
22
- onClick: onClose,
23
- },
24
- ] }));
25
- };
@@ -1 +0,0 @@
1
- export declare const EndpointsPage: () => import("react/jsx-runtime").JSX.Element;
@@ -1,14 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { cn } from '@/lib/utils';
3
- import { useGlobalStore } from '@/stores/use-global-store';
4
- import { useMemo } from 'react';
5
- import { EndpointBadge } from './endpoint-badge';
6
- import { EndpointSidePanel } from './endpoint-side-panel';
7
- import { useGetEndpoints } from './hooks/use-get-endpoints';
8
- export const EndpointsPage = () => {
9
- const endpoints = useGetEndpoints();
10
- const selectedEndpointId = useGlobalStore((state) => state.selectedEndpointId);
11
- const selectEndpointId = useGlobalStore((state) => state.selectEndpointId);
12
- const selectedEndpoint = useMemo(() => selectedEndpointId && endpoints.find((endpoint) => endpoint.id === selectedEndpointId), [endpoints, selectedEndpointId]);
13
- return (_jsxs("div", { className: "flex flex-row w-full h-full", children: [_jsx("div", { className: "flex flex-col flex-1 overflow-y-auto", children: endpoints.map((endpoint) => (_jsx("div", { "data-testid": `endpoint-${endpoint.method}-${endpoint.path}`, className: cn(selectedEndpoint === endpoint && 'bg-muted-foreground/10', 'cursor-pointer select-none'), onClick: () => selectEndpointId(endpoint.id), children: _jsxs("div", { className: "flex flex-row gap-2 items-center hover:bg-muted-foreground/10 p-2", children: [_jsx(EndpointBadge, { variant: endpoint.method, children: endpoint.method.toUpperCase() }), _jsx("span", { className: "text-md font-mono font-bold whitespace-nowrap", children: endpoint.path }), _jsx("span", { className: "text-md text-muted-foreground truncate", children: endpoint.description })] }) }, `${endpoint.method} ${endpoint.path}`))) }), selectedEndpoint && (_jsx(EndpointSidePanel, { endpoint: selectedEndpoint, onClose: () => selectEndpointId(undefined) }))] }));
14
- };
@@ -1,2 +0,0 @@
1
- import { ApiEndpoint } from '@/types/endpoint';
2
- export declare const useGetEndpoints: () => ApiEndpoint[];
@@ -1,8 +0,0 @@
1
- import { useStreamGroup } from '@motiadev/stream-client-react';
2
- export const useGetEndpoints = () => {
3
- const { data: endpoints } = useStreamGroup({
4
- streamName: '__motia.api-endpoints',
5
- groupId: 'default',
6
- });
7
- return endpoints;
8
- };
@@ -1,4 +0,0 @@
1
- export declare const useJsonSchemaToJson: (schema: Record<string, any> | undefined) => {
2
- body: string;
3
- setBody: import("react").Dispatch<import("react").SetStateAction<string>>;
4
- };
@@ -1,11 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { convertJsonSchemaToJson } from './utils';
3
- export const useJsonSchemaToJson = (schema) => {
4
- const [body, setBody] = useState('');
5
- useEffect(() => {
6
- if (schema) {
7
- setBody(JSON.stringify(convertJsonSchemaToJson(schema), null, 2));
8
- }
9
- }, [schema]);
10
- return { body, setBody };
11
- };
@@ -1 +0,0 @@
1
- export declare const usePathParams: (path: string) => string[];
@@ -1,4 +0,0 @@
1
- export const usePathParams = (path) => {
2
- const pathParams = path.match(/:(\w+)/g);
3
- return pathParams?.map((param) => param.slice(1)) ?? [];
4
- };
@@ -1,7 +0,0 @@
1
- export declare const useStateStream: (object: Record<string, any> | undefined) => {
2
- data: {};
3
- originalData: any[] | {
4
- [x: string]: any;
5
- };
6
- isStreamed: boolean;
7
- };
@@ -1,11 +0,0 @@
1
- import { useStreamItem } from '@motiadev/stream-client-react';
2
- export const useStateStream = (object) => {
3
- const { __motia, ...rest } = object || {};
4
- const { data } = useStreamItem(__motia);
5
- const originalData = Array.isArray(object) ? object : rest || object;
6
- return {
7
- data: data || originalData,
8
- originalData,
9
- isStreamed: !!__motia,
10
- };
11
- };
@@ -1 +0,0 @@
1
- export declare const convertJsonSchemaToJson: (schema?: Record<string, any>) => any;
@@ -1,29 +0,0 @@
1
- export const convertJsonSchemaToJson = (schema) => {
2
- if (!schema)
3
- return {};
4
- if (schema.type === 'object') {
5
- const result = {};
6
- if (schema.properties) {
7
- Object.entries(schema.properties).forEach(([key, value]) => {
8
- result[key] = convertJsonSchemaToJson(value);
9
- });
10
- }
11
- return result;
12
- }
13
- switch (schema.type) {
14
- case 'array':
15
- return [convertJsonSchemaToJson(schema.items)];
16
- case 'string':
17
- return schema.enum?.[0] ?? schema.description ?? 'string';
18
- case 'number':
19
- return schema.description ?? 0;
20
- case 'integer':
21
- return 0;
22
- case 'boolean':
23
- return schema.description ?? false;
24
- case 'null':
25
- return schema.description ?? null;
26
- default:
27
- return undefined;
28
- }
29
- };
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- type Props = {
3
- status: string;
4
- body: Record<string, any>;
5
- };
6
- export declare const ResponseBody: React.FC<Props>;
7
- export {};
@@ -1,6 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useJsonSchemaToJson } from './hooks/use-json-schema-to-json';
3
- export const ResponseBody = ({ status, body }) => {
4
- const { body: responseBody } = useJsonSchemaToJson(body);
5
- return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("span", { className: "text-xs font-bold", children: status }), _jsx("span", { className: "text-xs font-mono dark:bg-black/50 bg-white/50 p-2 rounded-lg whitespace-pre-wrap", children: responseBody })] }));
6
- };
@@ -1,8 +0,0 @@
1
- import { type PanelProps } from '@motiadev/ui';
2
- import { FC } from 'react';
3
- export declare const APP_SIDEBAR_CONTAINER_ID = "app-sidebar-container";
4
- export type SidebarProps = PanelProps & {
5
- onClose: () => void;
6
- initialWidth?: number;
7
- };
8
- export declare const Sidebar: FC<SidebarProps>;
@@ -1,39 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Panel } from '@motiadev/ui';
3
- import { createPortal } from 'react-dom';
4
- import { useEffect, useMemo } from 'react';
5
- import { useResizable } from 'react-use-resizable';
6
- import { Equal } from 'lucide-react';
7
- export const APP_SIDEBAR_CONTAINER_ID = 'app-sidebar-container';
8
- const CLOSE_PREVIOUS_SIDEBAR_EVENT = 'close-previous-sidebar';
9
- export const Sidebar = ({ initialWidth, onClose, ...props }) => {
10
- const sidebarId = useMemo(() => Symbol(), []);
11
- const { getRootProps, getHandleProps } = useResizable({
12
- lockVertical: true,
13
- initialWidth: initialWidth ?? 400,
14
- initialHeight: '100%',
15
- onDragStart: () => {
16
- document.body.style.userSelect = 'none';
17
- },
18
- onDragEnd: () => {
19
- document.body.style.userSelect = '';
20
- },
21
- });
22
- useEffect(() => {
23
- const event = new CustomEvent(CLOSE_PREVIOUS_SIDEBAR_EVENT, { detail: { sidebarId } });
24
- window.dispatchEvent(event);
25
- const handleClose = (e) => {
26
- const customEvent = e;
27
- if (customEvent.detail.sidebarId !== sidebarId) {
28
- onClose();
29
- }
30
- };
31
- window.addEventListener(CLOSE_PREVIOUS_SIDEBAR_EVENT, handleClose);
32
- return () => {
33
- window.removeEventListener(CLOSE_PREVIOUS_SIDEBAR_EVENT, handleClose);
34
- };
35
- }, [sidebarId, onClose]);
36
- return createPortal(_jsxs("div", { ...getRootProps(), className: "pr-2 py-2 relative", children: [_jsx("div", { ...getHandleProps({
37
- reverse: true,
38
- }), className: "flex h-6 w-6 items-center justify-center rounded-full bg-background border border-border absolute top-1/2 -translate-y-1/2 -left-4 z-20", children: _jsx(Equal, { className: "rotate-90 w-4 h-4 text-muted-foreground" }) }), _jsx(Panel, { ...props, variant: "outlined", className: "max-h-[calc(100vh-80px)] h-full", "data-testid": "sidebar-panel" })] }), document.querySelector(`#${APP_SIDEBAR_CONTAINER_ID}`));
39
- };