@mastra/playground-ui 1.0.0-alpha.9 → 1.0.1-alpha.0
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/dist/components/dynamic-form/default-field-map.d.ts +16 -0
- package/dist/components/dynamic-form/fields/array-field.d.ts +17 -0
- package/dist/components/dynamic-form/fields/boolean-field.d.ts +12 -0
- package/dist/components/dynamic-form/fields/creatable-field.d.ts +17 -0
- package/dist/components/dynamic-form/fields/date-field.d.ts +12 -0
- package/dist/components/dynamic-form/fields/enum-field.d.ts +16 -0
- package/dist/components/dynamic-form/fields/index.d.ts +10 -0
- package/dist/components/dynamic-form/fields/number-field.d.ts +12 -0
- package/dist/components/dynamic-form/fields/object-field.d.ts +27 -0
- package/dist/components/dynamic-form/fields/record-field.d.ts +14 -0
- package/dist/components/dynamic-form/fields/string-field.d.ts +14 -0
- package/dist/components/dynamic-form/fields/union-field.d.ts +28 -0
- package/dist/components/dynamic-form/index.d.ts +11 -0
- package/dist/components/dynamic-form/resolvers/index.d.ts +4 -0
- package/dist/components/dynamic-form/schema-resolver.d.ts +21 -0
- package/dist/components/dynamic-form/schema.d.ts +70 -0
- package/dist/components/dynamic-form/utils.d.ts +12 -0
- package/dist/components/ui/calendar.d.ts +8 -0
- package/dist/components/ui/code-block.d.ts +7 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/command.d.ts +78 -0
- package/dist/components/ui/copy-button.d.ts +7 -0
- package/dist/components/ui/date-picker.d.ts +23 -0
- package/dist/components/ui/label.d.ts +5 -0
- package/dist/components/ui/popover.d.ts +6 -0
- package/dist/components/ui/select.d.ts +9 -0
- package/dist/components/ui/switch.d.ts +4 -0
- package/dist/components/ui/textarea.d.ts +5 -0
- package/dist/domains/workflows/context/workflow-run-context.d.ts +12 -0
- package/dist/domains/workflows/index.d.ts +2 -0
- package/dist/domains/workflows/workflow/utils.d.ts +9 -1
- package/dist/domains/workflows/workflow/workflow-trigger.d.ts +5 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +9 -0
- package/dist/hooks/use-workflows.d.ts +32 -1
- package/dist/index.es.js +1730 -77
- package/dist/index.es.js.map +1 -1
- package/dist/lib/object.d.ts +50 -0
- package/dist/lib/string.d.ts +1 -0
- package/package.json +37 -22
package/dist/index.es.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import React__default, { useState, useRef, useCallback, useEffect, useLayoutEffect, Suspense, useMemo, forwardRef, memo, createContext, useContext, Fragment as Fragment$1 } from 'react';
|
|
4
4
|
import { useSWRConfig } from 'swr';
|
|
5
5
|
import { MastraClient } from '@mastra/client-js';
|
|
6
|
-
import { Check, Copy, X, FileIcon, Paperclip, Square, ArrowUp, Dot, ArrowDown, CheckIcon, CopyIcon, ChevronLeftIcon, ChevronRightIcon, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, Braces, Clock1, ChevronDown, XIcon, Footprints, AlertCircleIcon } from 'lucide-react';
|
|
6
|
+
import { Check, Copy, X, FileIcon, Paperclip, Square, ArrowUp, Dot, ArrowDown, CheckIcon, CopyIcon, ChevronLeftIcon, ChevronRightIcon, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, Braces, Clock1, ChevronDown, XIcon, Footprints, AlertCircleIcon, Plus, CalendarIcon, Loader2 } from 'lucide-react';
|
|
7
7
|
import { Slot } from '@radix-ui/react-slot';
|
|
8
8
|
import { omit } from 'remeda';
|
|
9
9
|
import { motion, AnimatePresence } from 'motion/react';
|
|
@@ -16,7 +16,7 @@ import { unstable_memoizeMarkdownComponents, useIsMarkdownCodeBlock, MarkdownTex
|
|
|
16
16
|
import '@assistant-ui/react-markdown/styles/dot.css';
|
|
17
17
|
import { makePrismAsyncSyntaxHighlighter } from '@assistant-ui/react-syntax-highlighter';
|
|
18
18
|
import { coldarkDark } from 'react-syntax-highlighter/dist/cjs/styles/prism';
|
|
19
|
-
import { format, formatDistanceToNow } from 'date-fns';
|
|
19
|
+
import { format, formatDistanceToNow, isValid } from 'date-fns';
|
|
20
20
|
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
21
21
|
import { toast } from 'sonner';
|
|
22
22
|
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
@@ -28,6 +28,23 @@ import { useReactTable, getCoreRowModel, flexRender } from '@tanstack/react-tabl
|
|
|
28
28
|
import { MarkerType, Handle, Position, useNodesState, useEdgesState, ReactFlow, Controls, MiniMap, Background, BackgroundVariant } from '@xyflow/react';
|
|
29
29
|
import '@xyflow/react/dist/style.css';
|
|
30
30
|
import Dagre from '@dagrejs/dagre';
|
|
31
|
+
import { Highlight, themes } from 'prism-react-renderer';
|
|
32
|
+
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
33
|
+
import jsonSchemaToZod from 'json-schema-to-zod';
|
|
34
|
+
import { parse } from 'superjson';
|
|
35
|
+
import * as z from 'zod';
|
|
36
|
+
import { z as z$1, ZodNumber, ZodBoolean, ZodDate, ZodLiteral, ZodEnum, ZodArray, ZodUnion } from 'zod';
|
|
37
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
38
|
+
import { useFieldArray, Controller, useWatch, useForm } from 'react-hook-form';
|
|
39
|
+
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
40
|
+
import { Command as Command$1 } from 'cmdk';
|
|
41
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
42
|
+
import { useDebouncedCallback } from 'use-debounce';
|
|
43
|
+
import { DayPicker } from 'react-day-picker';
|
|
44
|
+
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
45
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
46
|
+
import { v4 } from '@lukeed/uuid';
|
|
47
|
+
import { CodeBlock as CodeBlock$1 } from 'react-code-block';
|
|
31
48
|
|
|
32
49
|
import './index.css';function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
33
50
|
|
|
@@ -2820,7 +2837,7 @@ const Button = React.forwardRef(
|
|
|
2820
2837
|
);
|
|
2821
2838
|
Button.displayName = "Button";
|
|
2822
2839
|
|
|
2823
|
-
function useCopyToClipboard$
|
|
2840
|
+
function useCopyToClipboard$2({ text, copyMessage = "Copied to clipboard!" }) {
|
|
2824
2841
|
const [isCopied, setIsCopied] = useState(false);
|
|
2825
2842
|
const [error, setError] = useState("");
|
|
2826
2843
|
const timeoutRef = useRef(null);
|
|
@@ -2841,8 +2858,8 @@ function useCopyToClipboard$1({ text, copyMessage = "Copied to clipboard!" }) {
|
|
|
2841
2858
|
return { isCopied, handleCopy, error };
|
|
2842
2859
|
}
|
|
2843
2860
|
|
|
2844
|
-
function CopyButton({ content, copyMessage, classname }) {
|
|
2845
|
-
const { isCopied, handleCopy } = useCopyToClipboard$
|
|
2861
|
+
function CopyButton$1({ content, copyMessage, classname }) {
|
|
2862
|
+
const { isCopied, handleCopy } = useCopyToClipboard$2({
|
|
2846
2863
|
text: content,
|
|
2847
2864
|
copyMessage
|
|
2848
2865
|
});
|
|
@@ -3262,7 +3279,7 @@ const CodeBlock = ({ children, className, language, ...restProps }) => {
|
|
|
3262
3279
|
children: /* @__PURE__ */ jsx(HighlightedPre, { language, className: preClass, children: code })
|
|
3263
3280
|
}
|
|
3264
3281
|
),
|
|
3265
|
-
/* @__PURE__ */ jsx("div", { className: "invisible absolute right-2 top-2 flex space-x-1 rounded-lg p-1 opacity-0 transition-all duration-200 group-hover/code:visible group-hover/code:opacity-100", children: /* @__PURE__ */ jsx(CopyButton, { content: code, copyMessage: "Copied code to clipboard" }) })
|
|
3282
|
+
/* @__PURE__ */ jsx("div", { className: "invisible absolute right-2 top-2 flex space-x-1 rounded-lg p-1 opacity-0 transition-all duration-200 group-hover/code:visible group-hover/code:opacity-100", children: /* @__PURE__ */ jsx(CopyButton$1, { content: code, copyMessage: "Copied code to clipboard" }) })
|
|
3266
3283
|
] });
|
|
3267
3284
|
};
|
|
3268
3285
|
function childrenTakeAllStringContents(element) {
|
|
@@ -3754,7 +3771,7 @@ const MarkdownTextImpl = () => {
|
|
|
3754
3771
|
};
|
|
3755
3772
|
const MarkdownText = memo(MarkdownTextImpl);
|
|
3756
3773
|
const CodeHeader = ({ language, code }) => {
|
|
3757
|
-
const { isCopied, copyToClipboard } = useCopyToClipboard();
|
|
3774
|
+
const { isCopied, copyToClipboard } = useCopyToClipboard$1();
|
|
3758
3775
|
const onCopy = () => {
|
|
3759
3776
|
if (!code || isCopied) return;
|
|
3760
3777
|
copyToClipboard(code);
|
|
@@ -3801,7 +3818,7 @@ const CodeHeader = ({ language, code }) => {
|
|
|
3801
3818
|
}
|
|
3802
3819
|
);
|
|
3803
3820
|
};
|
|
3804
|
-
const useCopyToClipboard = ({
|
|
3821
|
+
const useCopyToClipboard$1 = ({
|
|
3805
3822
|
copiedDuration = 1500
|
|
3806
3823
|
} = {}) => {
|
|
3807
3824
|
const [isCopied, setIsCopied] = useState(false);
|
|
@@ -6097,44 +6114,126 @@ const useWorkflow = (workflowId, baseUrl) => {
|
|
|
6097
6114
|
}, [workflowId]);
|
|
6098
6115
|
return { workflow, isLoading };
|
|
6099
6116
|
};
|
|
6117
|
+
const useExecuteWorkflow = (baseUrl) => {
|
|
6118
|
+
const [isExecutingWorkflow, setIsExecutingWorkflow] = useState(false);
|
|
6119
|
+
const client = new MastraClient({
|
|
6120
|
+
baseUrl: baseUrl || ""
|
|
6121
|
+
});
|
|
6122
|
+
const executeWorkflow = async ({ workflowId, input }) => {
|
|
6123
|
+
try {
|
|
6124
|
+
setIsExecutingWorkflow(true);
|
|
6125
|
+
const response = await client.getWorkflow(workflowId).execute(input || {});
|
|
6126
|
+
return response;
|
|
6127
|
+
} catch (error) {
|
|
6128
|
+
console.error("Error executing workflow:", error);
|
|
6129
|
+
throw error;
|
|
6130
|
+
} finally {
|
|
6131
|
+
setIsExecutingWorkflow(false);
|
|
6132
|
+
}
|
|
6133
|
+
};
|
|
6134
|
+
const createWorkflowRun = async ({ workflowId, input }) => {
|
|
6135
|
+
try {
|
|
6136
|
+
const response = await client.getWorkflow(workflowId).startRun(input || {});
|
|
6137
|
+
return response;
|
|
6138
|
+
} catch (error) {
|
|
6139
|
+
console.error("Error creating workflow run:", error);
|
|
6140
|
+
throw error;
|
|
6141
|
+
}
|
|
6142
|
+
};
|
|
6143
|
+
return { executeWorkflow, createWorkflowRun, isExecutingWorkflow };
|
|
6144
|
+
};
|
|
6145
|
+
const useWatchWorkflow = (baseUrl) => {
|
|
6146
|
+
const [isWatchingWorkflow, setIsWatchingWorkflow] = useState(false);
|
|
6147
|
+
const [watchResult, setWatchResult] = useState(null);
|
|
6148
|
+
const watchWorkflow = async ({ workflowId, runId }) => {
|
|
6149
|
+
try {
|
|
6150
|
+
setIsWatchingWorkflow(true);
|
|
6151
|
+
const client = new MastraClient({
|
|
6152
|
+
baseUrl
|
|
6153
|
+
});
|
|
6154
|
+
const watchSubscription = client.getWorkflow(workflowId).watch({ runId });
|
|
6155
|
+
if (!watchSubscription) {
|
|
6156
|
+
throw new Error("Error watching workflow");
|
|
6157
|
+
}
|
|
6158
|
+
for await (const record of watchSubscription) {
|
|
6159
|
+
setWatchResult(record);
|
|
6160
|
+
}
|
|
6161
|
+
} catch (error) {
|
|
6162
|
+
console.error("Error watching workflow:", error);
|
|
6163
|
+
throw error;
|
|
6164
|
+
} finally {
|
|
6165
|
+
setIsWatchingWorkflow(false);
|
|
6166
|
+
}
|
|
6167
|
+
};
|
|
6168
|
+
return { watchWorkflow, isWatchingWorkflow, watchResult };
|
|
6169
|
+
};
|
|
6170
|
+
const useResumeWorkflow = (baseUrl) => {
|
|
6171
|
+
const [isResumingWorkflow, setIsResumingWorkflow] = useState(false);
|
|
6172
|
+
const resumeWorkflow = async ({
|
|
6173
|
+
workflowId,
|
|
6174
|
+
stepId,
|
|
6175
|
+
runId,
|
|
6176
|
+
context
|
|
6177
|
+
}) => {
|
|
6178
|
+
try {
|
|
6179
|
+
setIsResumingWorkflow(true);
|
|
6180
|
+
const client = new MastraClient({
|
|
6181
|
+
baseUrl: baseUrl || ""
|
|
6182
|
+
});
|
|
6183
|
+
const response = await client.getWorkflow(workflowId).resume({ stepId, runId, context });
|
|
6184
|
+
return response;
|
|
6185
|
+
} catch (error) {
|
|
6186
|
+
console.error("Error resuming workflow:", error);
|
|
6187
|
+
throw error;
|
|
6188
|
+
} finally {
|
|
6189
|
+
setIsResumingWorkflow(false);
|
|
6190
|
+
}
|
|
6191
|
+
};
|
|
6192
|
+
return { resumeWorkflow, isResumingWorkflow };
|
|
6193
|
+
};
|
|
6100
6194
|
|
|
6101
|
-
function extractConditions(group) {
|
|
6195
|
+
function extractConditions(group, type) {
|
|
6102
6196
|
let result = [];
|
|
6103
6197
|
if (!group) return result;
|
|
6104
6198
|
function recurse(group2, conj) {
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
const [
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
}
|
|
6125
|
-
if ("and" in group2) {
|
|
6126
|
-
for (const subGroup of group2.and) {
|
|
6127
|
-
recurse({ ...subGroup }, "and");
|
|
6199
|
+
if (typeof group2 === "string") {
|
|
6200
|
+
result.push({ type, fnString: group2 });
|
|
6201
|
+
} else {
|
|
6202
|
+
const simpleCondition = Object.entries(group2).find(([key]) => key.includes("."));
|
|
6203
|
+
if (simpleCondition) {
|
|
6204
|
+
const [key, queryValue] = simpleCondition;
|
|
6205
|
+
const [stepId, ...pathParts] = key.split(".");
|
|
6206
|
+
const ref = {
|
|
6207
|
+
step: {
|
|
6208
|
+
id: stepId
|
|
6209
|
+
},
|
|
6210
|
+
path: pathParts.join(".")
|
|
6211
|
+
};
|
|
6212
|
+
result.push({
|
|
6213
|
+
type,
|
|
6214
|
+
ref,
|
|
6215
|
+
query: { [queryValue === true || queryValue === false ? "is" : "eq"]: String(queryValue) },
|
|
6216
|
+
conj
|
|
6217
|
+
});
|
|
6128
6218
|
}
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6219
|
+
if ("ref" in group2) {
|
|
6220
|
+
const { ref, query } = group2;
|
|
6221
|
+
result.push({ type, ref, query, conj });
|
|
6222
|
+
}
|
|
6223
|
+
if ("and" in group2) {
|
|
6224
|
+
for (const subGroup of group2.and) {
|
|
6225
|
+
recurse({ ...subGroup }, "and");
|
|
6226
|
+
}
|
|
6227
|
+
}
|
|
6228
|
+
if ("or" in group2) {
|
|
6229
|
+
for (const subGroup of group2.or) {
|
|
6230
|
+
recurse({ ...subGroup }, "or");
|
|
6231
|
+
}
|
|
6133
6232
|
}
|
|
6134
6233
|
}
|
|
6135
6234
|
}
|
|
6136
6235
|
recurse(group);
|
|
6137
|
-
return result;
|
|
6236
|
+
return result.reverse();
|
|
6138
6237
|
}
|
|
6139
6238
|
const getLayoutedElements = (nodes, edges) => {
|
|
6140
6239
|
const g = new Dagre.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
|
|
@@ -6144,7 +6243,7 @@ const getLayoutedElements = (nodes, edges) => {
|
|
|
6144
6243
|
(node) => g.setNode(node.id, {
|
|
6145
6244
|
...node,
|
|
6146
6245
|
width: node.measured?.width ?? 274,
|
|
6147
|
-
height: node.measured?.height ?? 100
|
|
6246
|
+
height: node.measured?.height ?? (node?.data?.isLarge ? 260 : 100)
|
|
6148
6247
|
})
|
|
6149
6248
|
);
|
|
6150
6249
|
Dagre.layout(g);
|
|
@@ -6152,7 +6251,7 @@ const getLayoutedElements = (nodes, edges) => {
|
|
|
6152
6251
|
nodes: nodes.map((node) => {
|
|
6153
6252
|
const position = g.node(node.id);
|
|
6154
6253
|
const x = position.x - (node.measured?.width ?? 274) / 2;
|
|
6155
|
-
const y = position.y - (node.measured?.height ?? 100) / 2;
|
|
6254
|
+
const y = position.y - (node.measured?.height ?? (node?.data?.isLarge ? 260 : 100)) / 2;
|
|
6156
6255
|
return { ...node, position: { x, y } };
|
|
6157
6256
|
}),
|
|
6158
6257
|
edges
|
|
@@ -6190,16 +6289,21 @@ const contructNodesAndEdges = ({
|
|
|
6190
6289
|
type: "default-node",
|
|
6191
6290
|
id: nodes.some((node) => node.id === step2.step.id) ? `${step2.step.id}-${i}` : step2.step.id
|
|
6192
6291
|
};
|
|
6193
|
-
|
|
6194
|
-
|
|
6292
|
+
let conditionType = "when";
|
|
6293
|
+
if (step2.config?.serializedWhen) {
|
|
6294
|
+
conditionType = step2.step.id === "__start_if" ? "if" : step2.step.id === "__start_else" ? "else" : "when";
|
|
6295
|
+
const conditions = extractConditions(step2.config.serializedWhen, conditionType);
|
|
6195
6296
|
const conditionStep = {
|
|
6196
6297
|
id: crypto.randomUUID(),
|
|
6197
6298
|
conditions,
|
|
6198
|
-
type: "condition-node"
|
|
6299
|
+
type: "condition-node",
|
|
6300
|
+
isLarge: (conditions?.length > 1 || conditions.some(({ fnString }) => !!fnString)) && conditionType !== "else"
|
|
6199
6301
|
};
|
|
6200
6302
|
acc.push(conditionStep);
|
|
6201
6303
|
}
|
|
6202
|
-
|
|
6304
|
+
if (conditionType === "when") {
|
|
6305
|
+
acc.push(newStep);
|
|
6306
|
+
}
|
|
6203
6307
|
return acc;
|
|
6204
6308
|
}, []);
|
|
6205
6309
|
const newNodes = [...steps].map((step2, index) => {
|
|
@@ -6213,7 +6317,8 @@ const contructNodesAndEdges = ({
|
|
|
6213
6317
|
label: step2.label,
|
|
6214
6318
|
description: step2.description,
|
|
6215
6319
|
withoutTopHandle: subscriberGraph?.[step2.id] ? false : index === 0,
|
|
6216
|
-
withoutBottomHandle: subscriberGraph ? false : index === steps.length - 1
|
|
6320
|
+
withoutBottomHandle: subscriberGraph ? false : index === steps.length - 1,
|
|
6321
|
+
isLarge: step2.isLarge
|
|
6217
6322
|
}
|
|
6218
6323
|
};
|
|
6219
6324
|
});
|
|
@@ -6245,16 +6350,21 @@ const contructNodesAndEdges = ({
|
|
|
6245
6350
|
type: "default-node",
|
|
6246
6351
|
id: nodes.some((node) => node.id === step2.step.id) ? `${step2.step.id}-${i}` : step2.step.id
|
|
6247
6352
|
};
|
|
6248
|
-
|
|
6249
|
-
|
|
6353
|
+
let conditionType = "when";
|
|
6354
|
+
if (step2.config?.serializedWhen) {
|
|
6355
|
+
conditionType = step2.step.id === "__start_if" ? "if" : step2.step.id === "__start_else" ? "else" : "when";
|
|
6356
|
+
const conditions = extractConditions(step2.config.serializedWhen, conditionType);
|
|
6250
6357
|
const conditionStep = {
|
|
6251
6358
|
id: crypto.randomUUID(),
|
|
6252
6359
|
conditions,
|
|
6253
|
-
type: "condition-node"
|
|
6360
|
+
type: "condition-node",
|
|
6361
|
+
isLarge: (conditions?.length > 1 || conditions.some(({ fnString }) => !!fnString)) && conditionType !== "else"
|
|
6254
6362
|
};
|
|
6255
6363
|
acc.push(conditionStep);
|
|
6256
6364
|
}
|
|
6257
|
-
|
|
6365
|
+
if (conditionType === "when") {
|
|
6366
|
+
acc.push(newStep);
|
|
6367
|
+
}
|
|
6258
6368
|
return acc;
|
|
6259
6369
|
}, []);
|
|
6260
6370
|
const newNodes = [...steps].map((step2, index) => {
|
|
@@ -6267,7 +6377,8 @@ const contructNodesAndEdges = ({
|
|
|
6267
6377
|
conditions: step2.conditions,
|
|
6268
6378
|
label: step2.label,
|
|
6269
6379
|
description: step2.description,
|
|
6270
|
-
withoutBottomHandle: originalSteps.some(({ id }) => id === step2.label && id !== step2.id) || subscriberGraph ? false : index === steps.length - 1
|
|
6380
|
+
withoutBottomHandle: originalSteps.some(({ id }) => id === step2.label && id !== step2.id) || subscriberGraph ? false : index === steps.length - 1,
|
|
6381
|
+
isLarge: step2.isLarge
|
|
6271
6382
|
}
|
|
6272
6383
|
};
|
|
6273
6384
|
});
|
|
@@ -6337,35 +6448,80 @@ const Text = ({ className, weight, variant, as: Tag = "span", size, ...props })
|
|
|
6337
6448
|
return /* @__PURE__ */ jsx(Tag, { className: cn(textVariants({ size, variant, weight, className })), ...props });
|
|
6338
6449
|
};
|
|
6339
6450
|
|
|
6451
|
+
const Collapsible = CollapsiblePrimitive.Root;
|
|
6452
|
+
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
|
|
6453
|
+
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
|
|
6454
|
+
|
|
6340
6455
|
function WorkflowConditionNode({ data }) {
|
|
6341
6456
|
const { conditions } = data;
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6457
|
+
const [open, setOpen] = useState(true);
|
|
6458
|
+
const type = conditions[0]?.type;
|
|
6459
|
+
const isCollapsible = (conditions.some((condition) => condition.fnString) || conditions?.length > 1) && type !== "else";
|
|
6460
|
+
return /* @__PURE__ */ jsxs(
|
|
6461
|
+
Collapsible,
|
|
6462
|
+
{
|
|
6463
|
+
open: !isCollapsible ? true : open,
|
|
6464
|
+
onOpenChange: (_open) => {
|
|
6465
|
+
if (isCollapsible) {
|
|
6466
|
+
setOpen(_open);
|
|
6467
|
+
}
|
|
6468
|
+
},
|
|
6469
|
+
className: cn("bg-mastra-bg-3 rounded-md w-[274px] flex flex-col p-2 gap-2"),
|
|
6470
|
+
children: [
|
|
6471
|
+
/* @__PURE__ */ jsx(Handle, { type: "target", position: Position.Top, style: { visibility: "hidden" } }),
|
|
6472
|
+
/* @__PURE__ */ jsxs(CollapsibleTrigger, { className: "flex items-center justify-between w-full", children: [
|
|
6473
|
+
/* @__PURE__ */ jsx(
|
|
6474
|
+
Text,
|
|
6475
|
+
{
|
|
6476
|
+
size: "xs",
|
|
6477
|
+
weight: "medium",
|
|
6478
|
+
className: "text-mastra-el-3 bg-mastra-bg-11 my-auto block rounded-[0.125rem] px-2 py-1 text-[10px] w-fit",
|
|
6479
|
+
children: type.toUpperCase()
|
|
6480
|
+
}
|
|
6481
|
+
),
|
|
6482
|
+
isCollapsible && /* @__PURE__ */ jsx(
|
|
6483
|
+
ChevronDown,
|
|
6484
|
+
{
|
|
6485
|
+
className: cn("w-4 h-4 transition-transform", {
|
|
6486
|
+
"transform rotate-180": open
|
|
6487
|
+
})
|
|
6488
|
+
}
|
|
6489
|
+
)
|
|
6490
|
+
] }),
|
|
6491
|
+
type === "else" ? null : /* @__PURE__ */ jsx(CollapsibleContent, { className: "flex flex-col gap-2", children: conditions.map((condition, index) => {
|
|
6492
|
+
return condition.fnString ? /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(Highlight, { theme: themes.oneDark, code: String(condition.fnString).trim(), language: "javascript", children: ({ className, style, tokens, getLineProps, getTokenProps }) => /* @__PURE__ */ jsx(
|
|
6493
|
+
"pre",
|
|
6494
|
+
{
|
|
6495
|
+
className: `${className} relative font-mono text-sm overflow-x-auto p-3 w-full rounded-lg mt-2 dark:bg-zinc-800`,
|
|
6496
|
+
style: { ...style, maxHeight: "9.62rem" },
|
|
6497
|
+
children: tokens.map((line, i) => /* @__PURE__ */ jsxs("div", { ...getLineProps({ line }), children: [
|
|
6498
|
+
/* @__PURE__ */ jsx("span", { className: "inline-block mr-2 text-muted-foreground", children: i + 1 }),
|
|
6499
|
+
line.map((token, key) => /* @__PURE__ */ jsx("span", { ...getTokenProps({ token }) }, key))
|
|
6500
|
+
] }, i))
|
|
6501
|
+
}
|
|
6502
|
+
) }) }, `${condition.fnString}-${index}`) : /* @__PURE__ */ jsx(Fragment$1, { children: condition.ref?.step ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
6503
|
+
index === 0 ? null : /* @__PURE__ */ jsx(
|
|
6504
|
+
Text,
|
|
6505
|
+
{
|
|
6506
|
+
size: "xs",
|
|
6507
|
+
weight: "medium",
|
|
6508
|
+
className: "text-mastra-el-3 bg-mastra-bg-11 my-auto block rounded-[0.125rem] px-2 py-1 text-[10px]",
|
|
6509
|
+
children: condition.conj?.toLocaleUpperCase() || "WHEN"
|
|
6510
|
+
}
|
|
6511
|
+
),
|
|
6512
|
+
/* @__PURE__ */ jsxs(Text, { size: "xs", className: " text-mastra-el-3 flex-1", children: [
|
|
6513
|
+
condition.ref.step.id || condition.ref.step,
|
|
6514
|
+
"'s ",
|
|
6515
|
+
condition.ref.path,
|
|
6516
|
+
" ",
|
|
6517
|
+
Object.entries(condition.query).map(([key, value]) => `${key} ${String(value)}`)
|
|
6518
|
+
] })
|
|
6519
|
+
] }) : null }, `${condition.ref?.path}-${index}`);
|
|
6520
|
+
}) }),
|
|
6521
|
+
/* @__PURE__ */ jsx(Handle, { type: "source", position: Position.Bottom, style: { visibility: "hidden" } })
|
|
6522
|
+
]
|
|
6523
|
+
}
|
|
6524
|
+
);
|
|
6369
6525
|
}
|
|
6370
6526
|
|
|
6371
6527
|
function WorkflowDefaultNode({ data }) {
|
|
@@ -6413,6 +6569,9 @@ const lodashTitleCase = (str) => {
|
|
|
6413
6569
|
const camelCased = str.replace(/[-_\s]+(.)?/g, (_, char) => char ? char.toUpperCase() : "").replace(/^(.)/, (char) => char.toLowerCase());
|
|
6414
6570
|
return camelCased.replace(/([A-Z])/g, " $1").replace(/^./, (str2) => str2.toUpperCase()).trim();
|
|
6415
6571
|
};
|
|
6572
|
+
const toTitleCase = (str, splitChar = " ") => {
|
|
6573
|
+
return str.split(splitChar).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
6574
|
+
};
|
|
6416
6575
|
|
|
6417
6576
|
function WorkflowGraph({ workflowId, baseUrl }) {
|
|
6418
6577
|
const { workflow, isLoading } = useWorkflow(workflowId, baseUrl);
|
|
@@ -6476,5 +6635,1499 @@ const WorkflowsTable = ({
|
|
|
6476
6635
|
);
|
|
6477
6636
|
};
|
|
6478
6637
|
|
|
6479
|
-
|
|
6638
|
+
const transformToNestObject = (error) => {
|
|
6639
|
+
const fieldErrors = {};
|
|
6640
|
+
error.errors.forEach((err) => {
|
|
6641
|
+
if (err.path.length > 0) {
|
|
6642
|
+
const path = err.path.join(".");
|
|
6643
|
+
fieldErrors[path] = {
|
|
6644
|
+
type: "validation",
|
|
6645
|
+
message: err.message
|
|
6646
|
+
};
|
|
6647
|
+
}
|
|
6648
|
+
});
|
|
6649
|
+
return fieldErrors;
|
|
6650
|
+
};
|
|
6651
|
+
function resolveSerializedZodOutput(obj) {
|
|
6652
|
+
return Function("z", `"use strict";return (${obj});`)(z$1);
|
|
6653
|
+
}
|
|
6654
|
+
|
|
6655
|
+
const customZodUnionResolver = (schemaUnion, discriminator) => {
|
|
6656
|
+
return async (values) => {
|
|
6657
|
+
const schema = schemaUnion?._def?.options?.find(
|
|
6658
|
+
(option) => option?.shape?.[discriminator]?._def?.value === values[discriminator]
|
|
6659
|
+
) || z$1.object({ [discriminator]: z$1.string() });
|
|
6660
|
+
const filteredValues = Object.fromEntries(Object.entries(values).filter(([key]) => schema?.shape?.[key]));
|
|
6661
|
+
const result = schema.safeParse(filteredValues);
|
|
6662
|
+
if (result.success) {
|
|
6663
|
+
return { values: result.data, errors: {} };
|
|
6664
|
+
} else {
|
|
6665
|
+
const errors = transformToNestObject(result.error);
|
|
6666
|
+
return { values: {}, errors };
|
|
6667
|
+
}
|
|
6668
|
+
};
|
|
6669
|
+
};
|
|
6670
|
+
|
|
6671
|
+
function ArrayField({ name, control, renderField, isStringField }) {
|
|
6672
|
+
const { fields, append, remove } = useFieldArray({
|
|
6673
|
+
control,
|
|
6674
|
+
name
|
|
6675
|
+
});
|
|
6676
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2 w-full", children: [
|
|
6677
|
+
fields.map((field, index) => /* @__PURE__ */ jsxs("div", { className: "relative w-full flex items-center gap-2", children: [
|
|
6678
|
+
renderField({ fieldName: `${name}.${index}`, index }),
|
|
6679
|
+
/* @__PURE__ */ jsx(
|
|
6680
|
+
Button,
|
|
6681
|
+
{
|
|
6682
|
+
type: "button",
|
|
6683
|
+
variant: "ghost",
|
|
6684
|
+
size: "icon",
|
|
6685
|
+
className: "absolute -right-2 -top-2",
|
|
6686
|
+
onClick: () => remove(index),
|
|
6687
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
6688
|
+
}
|
|
6689
|
+
)
|
|
6690
|
+
] }, field.id)),
|
|
6691
|
+
/* @__PURE__ */ jsxs(
|
|
6692
|
+
Button,
|
|
6693
|
+
{
|
|
6694
|
+
type: "button",
|
|
6695
|
+
variant: "outline",
|
|
6696
|
+
size: "sm",
|
|
6697
|
+
className: "w-full",
|
|
6698
|
+
onClick: () => append(isStringField ? { root: "" } : {}),
|
|
6699
|
+
children: [
|
|
6700
|
+
/* @__PURE__ */ jsx(Plus, { className: "mr-2 h-4 w-4" }),
|
|
6701
|
+
"Add Item"
|
|
6702
|
+
]
|
|
6703
|
+
}
|
|
6704
|
+
)
|
|
6705
|
+
] });
|
|
6706
|
+
}
|
|
6707
|
+
|
|
6708
|
+
const Switch = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
6709
|
+
SwitchPrimitives.Root,
|
|
6710
|
+
{
|
|
6711
|
+
className: cn(
|
|
6712
|
+
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-mastra-bg-7 data-[state=unchecked]:bg-input",
|
|
6713
|
+
className
|
|
6714
|
+
),
|
|
6715
|
+
...props,
|
|
6716
|
+
ref,
|
|
6717
|
+
children: /* @__PURE__ */ jsx(
|
|
6718
|
+
SwitchPrimitives.Thumb,
|
|
6719
|
+
{
|
|
6720
|
+
className: cn(
|
|
6721
|
+
"pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
|
|
6722
|
+
)
|
|
6723
|
+
}
|
|
6724
|
+
)
|
|
6725
|
+
}
|
|
6726
|
+
));
|
|
6727
|
+
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
6728
|
+
|
|
6729
|
+
function BooleanField({ name, control, handleFieldChange }) {
|
|
6730
|
+
return /* @__PURE__ */ jsx(
|
|
6731
|
+
Controller,
|
|
6732
|
+
{
|
|
6733
|
+
name,
|
|
6734
|
+
control,
|
|
6735
|
+
render: ({ field }) => /* @__PURE__ */ jsx(
|
|
6736
|
+
Switch,
|
|
6737
|
+
{
|
|
6738
|
+
checked: field.value,
|
|
6739
|
+
onCheckedChange: (checked) => {
|
|
6740
|
+
field.onChange(checked);
|
|
6741
|
+
handleFieldChange?.({ key: name, value: checked });
|
|
6742
|
+
}
|
|
6743
|
+
}
|
|
6744
|
+
)
|
|
6745
|
+
}
|
|
6746
|
+
);
|
|
6747
|
+
}
|
|
6748
|
+
|
|
6749
|
+
const Command = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
6750
|
+
Command$1,
|
|
6751
|
+
{
|
|
6752
|
+
ref,
|
|
6753
|
+
className: cn(
|
|
6754
|
+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
|
6755
|
+
className
|
|
6756
|
+
),
|
|
6757
|
+
...props
|
|
6758
|
+
}
|
|
6759
|
+
));
|
|
6760
|
+
Command.displayName = Command$1.displayName;
|
|
6761
|
+
const CommandInput = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: [
|
|
6762
|
+
/* @__PURE__ */ jsx(Search, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
|
|
6763
|
+
/* @__PURE__ */ jsx(
|
|
6764
|
+
Command$1.Input,
|
|
6765
|
+
{
|
|
6766
|
+
ref,
|
|
6767
|
+
className: cn(
|
|
6768
|
+
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
6769
|
+
className
|
|
6770
|
+
),
|
|
6771
|
+
...props
|
|
6772
|
+
}
|
|
6773
|
+
)
|
|
6774
|
+
] }));
|
|
6775
|
+
CommandInput.displayName = Command$1.Input.displayName;
|
|
6776
|
+
const CommandList = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
6777
|
+
Command$1.List,
|
|
6778
|
+
{
|
|
6779
|
+
ref,
|
|
6780
|
+
className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className),
|
|
6781
|
+
...props
|
|
6782
|
+
}
|
|
6783
|
+
));
|
|
6784
|
+
CommandList.displayName = Command$1.List.displayName;
|
|
6785
|
+
const CommandEmpty = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(Command$1.Empty, { ref, className: "py-6 text-center text-sm", ...props }));
|
|
6786
|
+
CommandEmpty.displayName = Command$1.Empty.displayName;
|
|
6787
|
+
const CommandGroup = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
6788
|
+
Command$1.Group,
|
|
6789
|
+
{
|
|
6790
|
+
ref,
|
|
6791
|
+
className: cn(
|
|
6792
|
+
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
|
6793
|
+
className
|
|
6794
|
+
),
|
|
6795
|
+
...props
|
|
6796
|
+
}
|
|
6797
|
+
));
|
|
6798
|
+
CommandGroup.displayName = Command$1.Group.displayName;
|
|
6799
|
+
const CommandSeparator = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Command$1.Separator, { ref, className: cn("-mx-1 h-px bg-border", className), ...props }));
|
|
6800
|
+
CommandSeparator.displayName = Command$1.Separator.displayName;
|
|
6801
|
+
const CommandItem = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
6802
|
+
Command$1.Item,
|
|
6803
|
+
{
|
|
6804
|
+
ref,
|
|
6805
|
+
className: cn(
|
|
6806
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
6807
|
+
className
|
|
6808
|
+
),
|
|
6809
|
+
...props
|
|
6810
|
+
}
|
|
6811
|
+
));
|
|
6812
|
+
CommandItem.displayName = Command$1.Item.displayName;
|
|
6813
|
+
|
|
6814
|
+
const Popover = PopoverPrimitive.Root;
|
|
6815
|
+
const PopoverTrigger = PopoverPrimitive.Trigger;
|
|
6816
|
+
const PopoverContent = React.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
6817
|
+
PopoverPrimitive.Content,
|
|
6818
|
+
{
|
|
6819
|
+
ref,
|
|
6820
|
+
align,
|
|
6821
|
+
sideOffset,
|
|
6822
|
+
className: cn(
|
|
6823
|
+
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
6824
|
+
className
|
|
6825
|
+
),
|
|
6826
|
+
...props
|
|
6827
|
+
}
|
|
6828
|
+
) }));
|
|
6829
|
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
6830
|
+
|
|
6831
|
+
function CreatableField({ name, control, options = [], handleFieldChange, placeholder }) {
|
|
6832
|
+
const [openPopover, setOpenPopover] = React.useState(false);
|
|
6833
|
+
const [inputValue, setInputValue] = React.useState("");
|
|
6834
|
+
return /* @__PURE__ */ jsx(
|
|
6835
|
+
Controller,
|
|
6836
|
+
{
|
|
6837
|
+
name,
|
|
6838
|
+
control,
|
|
6839
|
+
render: ({ field }) => {
|
|
6840
|
+
const selectedValues = field.value || [];
|
|
6841
|
+
const removeValue = (valueToRemove) => {
|
|
6842
|
+
const newValues = selectedValues.filter((v) => v !== valueToRemove);
|
|
6843
|
+
field.onChange(newValues);
|
|
6844
|
+
handleFieldChange?.({ key: name, value: newValues });
|
|
6845
|
+
};
|
|
6846
|
+
const addValue = (value) => {
|
|
6847
|
+
if (!value) return;
|
|
6848
|
+
const newValues = [...selectedValues, value];
|
|
6849
|
+
field.onChange(newValues);
|
|
6850
|
+
handleFieldChange?.({ key: name, value: newValues });
|
|
6851
|
+
setInputValue("");
|
|
6852
|
+
setOpenPopover(false);
|
|
6853
|
+
};
|
|
6854
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
6855
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: selectedValues.map((value) => /* @__PURE__ */ jsxs(Badge, { className: "flex items-center gap-1", children: [
|
|
6856
|
+
value,
|
|
6857
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-4 w-4 p-0", onClick: () => removeValue(value), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
|
|
6858
|
+
] }, value)) }),
|
|
6859
|
+
/* @__PURE__ */ jsxs(Popover, { open: openPopover, onOpenChange: setOpenPopover, children: [
|
|
6860
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: "w-full justify-start", children: [
|
|
6861
|
+
/* @__PURE__ */ jsx(Plus, { className: "mr-2 h-4 w-4" }),
|
|
6862
|
+
placeholder || "Add item"
|
|
6863
|
+
] }) }),
|
|
6864
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "p-0", align: "start", children: /* @__PURE__ */ jsxs(Command, { children: [
|
|
6865
|
+
/* @__PURE__ */ jsx(CommandInput, { placeholder: "Enter value...", value: inputValue, onValueChange: setInputValue }),
|
|
6866
|
+
/* @__PURE__ */ jsx(CommandList, { children: /* @__PURE__ */ jsxs(CommandGroup, { children: [
|
|
6867
|
+
options.filter((opt) => !selectedValues.includes(opt.value)).map((option) => /* @__PURE__ */ jsx(CommandItem, { onSelect: () => addValue(option.value), children: option.label }, option.value)),
|
|
6868
|
+
inputValue && /* @__PURE__ */ jsxs(CommandItem, { onSelect: () => addValue(inputValue), children: [
|
|
6869
|
+
'Create "',
|
|
6870
|
+
inputValue,
|
|
6871
|
+
'"'
|
|
6872
|
+
] })
|
|
6873
|
+
] }) })
|
|
6874
|
+
] }) })
|
|
6875
|
+
] })
|
|
6876
|
+
] });
|
|
6877
|
+
}
|
|
6878
|
+
}
|
|
6879
|
+
);
|
|
6880
|
+
}
|
|
6881
|
+
|
|
6882
|
+
function Calendar({ className, classNames, showOutsideDays = true, ...props }) {
|
|
6883
|
+
return /* @__PURE__ */ jsx(
|
|
6884
|
+
DayPicker,
|
|
6885
|
+
{
|
|
6886
|
+
showOutsideDays,
|
|
6887
|
+
className: cn("p-3", className),
|
|
6888
|
+
classNames: {
|
|
6889
|
+
months: "flex flex-col space-y-4 sm:space-y-0",
|
|
6890
|
+
month: "space-y-4",
|
|
6891
|
+
month_caption: "flex justify-center pt-1 relative items-center",
|
|
6892
|
+
caption_label: "text-sm text-text font-medium",
|
|
6893
|
+
nav: "space-x-1 flex items-center",
|
|
6894
|
+
button_previous: cn(
|
|
6895
|
+
buttonVariants({ variant: "outline" }),
|
|
6896
|
+
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
|
|
6897
|
+
"absolute left-4 top-[56px] z-10"
|
|
6898
|
+
),
|
|
6899
|
+
button_next: cn(
|
|
6900
|
+
buttonVariants({ variant: "outline" }),
|
|
6901
|
+
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
|
|
6902
|
+
"absolute right-4 top-[56px] z-10"
|
|
6903
|
+
),
|
|
6904
|
+
month_grid: "w-full border-collapse space-y-1",
|
|
6905
|
+
weekdays: "flex",
|
|
6906
|
+
weekday: "text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",
|
|
6907
|
+
week: "flex w-full mt-2",
|
|
6908
|
+
day: cn(
|
|
6909
|
+
buttonVariants({ variant: "ghost" }),
|
|
6910
|
+
"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",
|
|
6911
|
+
props.mode === "range" ? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md" : "[&:has([aria-selected])]:rounded-md",
|
|
6912
|
+
"h-8 w-8 p-0 hover:bg-lightGray-7/50 font-normal aria-selected:opacity-100"
|
|
6913
|
+
),
|
|
6914
|
+
range_start: "day-range-start",
|
|
6915
|
+
range_end: "day-range-end",
|
|
6916
|
+
selected: "!bg-primary !text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
|
|
6917
|
+
today: "bg-lightGray-7/50 text-accent-foreground",
|
|
6918
|
+
outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
|
|
6919
|
+
disabled: "text-muted-foreground opacity-50",
|
|
6920
|
+
range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground",
|
|
6921
|
+
hidden: "invisible",
|
|
6922
|
+
...classNames
|
|
6923
|
+
},
|
|
6924
|
+
components: {
|
|
6925
|
+
Chevron: ({ orientation }) => /* @__PURE__ */ jsx(
|
|
6926
|
+
CalendarIcon,
|
|
6927
|
+
{
|
|
6928
|
+
className: cn("h-4 w-4", {
|
|
6929
|
+
"rotate-180": orientation === "up",
|
|
6930
|
+
"rotate-90": orientation === "left",
|
|
6931
|
+
"-rotate-90": orientation === "right"
|
|
6932
|
+
})
|
|
6933
|
+
}
|
|
6934
|
+
)
|
|
6935
|
+
},
|
|
6936
|
+
...props
|
|
6937
|
+
}
|
|
6938
|
+
);
|
|
6939
|
+
}
|
|
6940
|
+
Calendar.displayName = "Calendar";
|
|
6941
|
+
|
|
6942
|
+
const DatePicker = ({
|
|
6943
|
+
value,
|
|
6944
|
+
setValue,
|
|
6945
|
+
children,
|
|
6946
|
+
className,
|
|
6947
|
+
placeholder,
|
|
6948
|
+
...props
|
|
6949
|
+
}) => {
|
|
6950
|
+
const [openPopover, setOpenPopover] = React.useState(false);
|
|
6951
|
+
return /* @__PURE__ */ jsxs(Popover, { open: openPopover, onOpenChange: setOpenPopover, children: [
|
|
6952
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: children ? children : /* @__PURE__ */ jsx(
|
|
6953
|
+
DefaultButton,
|
|
6954
|
+
{
|
|
6955
|
+
value,
|
|
6956
|
+
placeholder,
|
|
6957
|
+
className,
|
|
6958
|
+
"data-testid": "datepicker-button"
|
|
6959
|
+
}
|
|
6960
|
+
) }),
|
|
6961
|
+
/* @__PURE__ */ jsx(
|
|
6962
|
+
PopoverContent,
|
|
6963
|
+
{
|
|
6964
|
+
className: "backdrop-blur-4xl w-auto p-0 bg-[#171717]",
|
|
6965
|
+
align: "start",
|
|
6966
|
+
"data-testid": "datepicker-calendar",
|
|
6967
|
+
children: /* @__PURE__ */ jsx(
|
|
6968
|
+
DatePickerOnly,
|
|
6969
|
+
{
|
|
6970
|
+
value,
|
|
6971
|
+
setValue: (v) => setValue(v ? /* @__PURE__ */ new Date(`${v}z`) : null),
|
|
6972
|
+
clearable: props.clearable,
|
|
6973
|
+
setOpenPopover,
|
|
6974
|
+
...props
|
|
6975
|
+
}
|
|
6976
|
+
)
|
|
6977
|
+
}
|
|
6978
|
+
)
|
|
6979
|
+
] });
|
|
6980
|
+
};
|
|
6981
|
+
const DatePickerOnly = ({
|
|
6982
|
+
value,
|
|
6983
|
+
setValue,
|
|
6984
|
+
setOpenPopover,
|
|
6985
|
+
clearable,
|
|
6986
|
+
placeholder,
|
|
6987
|
+
className,
|
|
6988
|
+
...props
|
|
6989
|
+
}) => {
|
|
6990
|
+
const [inputValue, setInputValue] = React.useState(value ? format(value, "PP") : "");
|
|
6991
|
+
const [selected, setSelected] = React.useState(value ? new Date(value) : void 0);
|
|
6992
|
+
const debouncedDateUpdate = useDebouncedCallback((date) => {
|
|
6993
|
+
if (isValid(date)) {
|
|
6994
|
+
setSelected(date);
|
|
6995
|
+
setValue?.(date);
|
|
6996
|
+
setOpenPopover?.(false);
|
|
6997
|
+
}
|
|
6998
|
+
}, 2e3);
|
|
6999
|
+
const handleInputChange = (e) => {
|
|
7000
|
+
setInputValue(e.currentTarget.value);
|
|
7001
|
+
const date = new Date(e.target.value);
|
|
7002
|
+
debouncedDateUpdate(date);
|
|
7003
|
+
};
|
|
7004
|
+
const handleDaySelect = (date) => {
|
|
7005
|
+
setSelected(date);
|
|
7006
|
+
setValue?.(date);
|
|
7007
|
+
setOpenPopover?.(false);
|
|
7008
|
+
if (date) {
|
|
7009
|
+
setInputValue(format(date, "PP"));
|
|
7010
|
+
} else {
|
|
7011
|
+
setInputValue("");
|
|
7012
|
+
}
|
|
7013
|
+
};
|
|
7014
|
+
const handleMonthSelect = (date) => {
|
|
7015
|
+
setSelected(date);
|
|
7016
|
+
if (date) {
|
|
7017
|
+
setInputValue(format(date, "PP"));
|
|
7018
|
+
} else {
|
|
7019
|
+
setInputValue("");
|
|
7020
|
+
}
|
|
7021
|
+
};
|
|
7022
|
+
return /* @__PURE__ */ jsxs(
|
|
7023
|
+
"div",
|
|
7024
|
+
{
|
|
7025
|
+
"aria-label": "Choose date",
|
|
7026
|
+
className: "relative mt-2 flex flex-col gap-2",
|
|
7027
|
+
onKeyDown: (e) => {
|
|
7028
|
+
e.stopPropagation();
|
|
7029
|
+
if (e.key === "Escape") {
|
|
7030
|
+
setOpenPopover?.(false);
|
|
7031
|
+
}
|
|
7032
|
+
},
|
|
7033
|
+
children: [
|
|
7034
|
+
/* @__PURE__ */ jsx("div", { className: "w-full px-3", children: /* @__PURE__ */ jsx(
|
|
7035
|
+
Input,
|
|
7036
|
+
{
|
|
7037
|
+
type: "text",
|
|
7038
|
+
value: inputValue,
|
|
7039
|
+
onChange: handleInputChange,
|
|
7040
|
+
placeholder,
|
|
7041
|
+
className
|
|
7042
|
+
}
|
|
7043
|
+
) }),
|
|
7044
|
+
/* @__PURE__ */ jsx(
|
|
7045
|
+
Calendar,
|
|
7046
|
+
{
|
|
7047
|
+
mode: "single",
|
|
7048
|
+
month: selected,
|
|
7049
|
+
selected,
|
|
7050
|
+
onMonthChange: handleMonthSelect,
|
|
7051
|
+
onSelect: handleDaySelect,
|
|
7052
|
+
...props
|
|
7053
|
+
}
|
|
7054
|
+
),
|
|
7055
|
+
/* @__PURE__ */ jsx("div", { className: "px-3 pb-2", children: clearable && /* @__PURE__ */ jsx(
|
|
7056
|
+
Button,
|
|
7057
|
+
{
|
|
7058
|
+
variant: "outline",
|
|
7059
|
+
tabIndex: 0,
|
|
7060
|
+
className: "w-full !opacity-50 duration-200 hover:!opacity-100",
|
|
7061
|
+
onClick: () => {
|
|
7062
|
+
setValue(null);
|
|
7063
|
+
setSelected(void 0);
|
|
7064
|
+
setInputValue("");
|
|
7065
|
+
setOpenPopover?.(false);
|
|
7066
|
+
},
|
|
7067
|
+
children: "Clear"
|
|
7068
|
+
}
|
|
7069
|
+
) })
|
|
7070
|
+
]
|
|
7071
|
+
}
|
|
7072
|
+
);
|
|
7073
|
+
};
|
|
7074
|
+
const DefaultButton = React.forwardRef(
|
|
7075
|
+
({ value, placeholder, className, ...props }, ref) => {
|
|
7076
|
+
return /* @__PURE__ */ jsxs(
|
|
7077
|
+
Button,
|
|
7078
|
+
{
|
|
7079
|
+
ref,
|
|
7080
|
+
variant: "outline",
|
|
7081
|
+
className: cn(
|
|
7082
|
+
"bg-neutral-825 border-neutral-775 w-full justify-start whitespace-nowrap rounded-md border px-2 py-0 text-left flex items-center gap-1",
|
|
7083
|
+
className
|
|
7084
|
+
),
|
|
7085
|
+
...props,
|
|
7086
|
+
children: [
|
|
7087
|
+
/* @__PURE__ */ jsx(CalendarIcon, { className: "h-4 w-4" }),
|
|
7088
|
+
value ? /* @__PURE__ */ jsx("span", { className: "text-white", children: format(value, "PPP") }) : /* @__PURE__ */ jsx("span", { className: "text-gray", children: placeholder ?? "Pick a date" })
|
|
7089
|
+
]
|
|
7090
|
+
}
|
|
7091
|
+
);
|
|
7092
|
+
}
|
|
7093
|
+
);
|
|
7094
|
+
DefaultButton.displayName = "DefaultButton";
|
|
7095
|
+
|
|
7096
|
+
function DateField({ name, control, handleFieldChange }) {
|
|
7097
|
+
return /* @__PURE__ */ jsx(
|
|
7098
|
+
Controller,
|
|
7099
|
+
{
|
|
7100
|
+
name,
|
|
7101
|
+
control,
|
|
7102
|
+
render: ({ field }) => /* @__PURE__ */ jsx(
|
|
7103
|
+
DatePicker,
|
|
7104
|
+
{
|
|
7105
|
+
value: field.value,
|
|
7106
|
+
setValue: (date) => {
|
|
7107
|
+
const newDate = date ? new Date(date).toISOString() : date;
|
|
7108
|
+
field.onChange(newDate);
|
|
7109
|
+
handleFieldChange?.({ key: name, value: newDate });
|
|
7110
|
+
}
|
|
7111
|
+
}
|
|
7112
|
+
)
|
|
7113
|
+
}
|
|
7114
|
+
);
|
|
7115
|
+
}
|
|
7116
|
+
|
|
7117
|
+
const Select = SelectPrimitive.Root;
|
|
7118
|
+
const SelectValue = SelectPrimitive.Value;
|
|
7119
|
+
const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
7120
|
+
SelectPrimitive.Trigger,
|
|
7121
|
+
{
|
|
7122
|
+
ref,
|
|
7123
|
+
className: cn(
|
|
7124
|
+
"flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
7125
|
+
className
|
|
7126
|
+
),
|
|
7127
|
+
...props,
|
|
7128
|
+
children: [
|
|
7129
|
+
children,
|
|
7130
|
+
/* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 opacity-50" }) })
|
|
7131
|
+
]
|
|
7132
|
+
}
|
|
7133
|
+
));
|
|
7134
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
7135
|
+
const SelectContent = React.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
7136
|
+
SelectPrimitive.Content,
|
|
7137
|
+
{
|
|
7138
|
+
ref,
|
|
7139
|
+
className: cn(
|
|
7140
|
+
"relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
7141
|
+
position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
7142
|
+
className
|
|
7143
|
+
),
|
|
7144
|
+
position,
|
|
7145
|
+
...props,
|
|
7146
|
+
children: /* @__PURE__ */ jsx(
|
|
7147
|
+
SelectPrimitive.Viewport,
|
|
7148
|
+
{
|
|
7149
|
+
className: cn(
|
|
7150
|
+
"p-1",
|
|
7151
|
+
position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
|
7152
|
+
),
|
|
7153
|
+
children
|
|
7154
|
+
}
|
|
7155
|
+
)
|
|
7156
|
+
}
|
|
7157
|
+
) }));
|
|
7158
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
7159
|
+
const SelectItem = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
7160
|
+
SelectPrimitive.Item,
|
|
7161
|
+
{
|
|
7162
|
+
ref,
|
|
7163
|
+
className: cn(
|
|
7164
|
+
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-mastra-el-5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
7165
|
+
className
|
|
7166
|
+
),
|
|
7167
|
+
...props,
|
|
7168
|
+
children: [
|
|
7169
|
+
/* @__PURE__ */ jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }) }),
|
|
7170
|
+
/* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
|
|
7171
|
+
]
|
|
7172
|
+
}
|
|
7173
|
+
));
|
|
7174
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
7175
|
+
|
|
7176
|
+
function EnumField({ name, control, options, handleFieldChange }) {
|
|
7177
|
+
return /* @__PURE__ */ jsx(
|
|
7178
|
+
Controller,
|
|
7179
|
+
{
|
|
7180
|
+
name,
|
|
7181
|
+
control,
|
|
7182
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(
|
|
7183
|
+
Select,
|
|
7184
|
+
{
|
|
7185
|
+
value: field.value,
|
|
7186
|
+
onValueChange: (value) => {
|
|
7187
|
+
field.onChange(value);
|
|
7188
|
+
handleFieldChange?.({ key: name, value });
|
|
7189
|
+
},
|
|
7190
|
+
children: [
|
|
7191
|
+
/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select an option" }) }),
|
|
7192
|
+
/* @__PURE__ */ jsx(SelectContent, { children: options.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, className: "text-white", children: option.label }, option.value)) })
|
|
7193
|
+
]
|
|
7194
|
+
}
|
|
7195
|
+
)
|
|
7196
|
+
}
|
|
7197
|
+
);
|
|
7198
|
+
}
|
|
7199
|
+
|
|
7200
|
+
const Textarea = React.forwardRef(({ className, ...props }, ref) => {
|
|
7201
|
+
return /* @__PURE__ */ jsx(
|
|
7202
|
+
"textarea",
|
|
7203
|
+
{
|
|
7204
|
+
className: cn(
|
|
7205
|
+
"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
7206
|
+
className
|
|
7207
|
+
),
|
|
7208
|
+
ref,
|
|
7209
|
+
...props
|
|
7210
|
+
}
|
|
7211
|
+
);
|
|
7212
|
+
});
|
|
7213
|
+
Textarea.displayName = "Textarea";
|
|
7214
|
+
|
|
7215
|
+
function StringField({ name, control, handleFieldChange, isMultiline, placeholder }) {
|
|
7216
|
+
const Component = isMultiline ? Textarea : Input;
|
|
7217
|
+
return /* @__PURE__ */ jsx(
|
|
7218
|
+
Controller,
|
|
7219
|
+
{
|
|
7220
|
+
name,
|
|
7221
|
+
control,
|
|
7222
|
+
render: ({ field }) => /* @__PURE__ */ jsx(
|
|
7223
|
+
Component,
|
|
7224
|
+
{
|
|
7225
|
+
...field,
|
|
7226
|
+
className: "w-full",
|
|
7227
|
+
placeholder,
|
|
7228
|
+
onChange: (e) => {
|
|
7229
|
+
field.onChange(e);
|
|
7230
|
+
handleFieldChange?.({ key: name, value: e.target.value });
|
|
7231
|
+
}
|
|
7232
|
+
}
|
|
7233
|
+
)
|
|
7234
|
+
}
|
|
7235
|
+
);
|
|
7236
|
+
}
|
|
7237
|
+
|
|
7238
|
+
const labelVariants = cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
7239
|
+
const Label = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(LabelPrimitive.Root, { ref, className: cn(labelVariants(), className), ...props }));
|
|
7240
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
7241
|
+
|
|
7242
|
+
const getPath = (object, path) => {
|
|
7243
|
+
if (typeof path === "string") {
|
|
7244
|
+
path = path?.split(".");
|
|
7245
|
+
}
|
|
7246
|
+
return path?.reduce((obj, key) => obj && obj[key] !== void 0 ? obj[key] : void 0, object);
|
|
7247
|
+
};
|
|
7248
|
+
const flattenObject = (object, endKeys = [], flattenArrayValue) => {
|
|
7249
|
+
let newObj = {};
|
|
7250
|
+
function recurseDip(obj, path) {
|
|
7251
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
7252
|
+
let newPath = [...path, key];
|
|
7253
|
+
if (value && value.constructor === Object) {
|
|
7254
|
+
const hasOnlyEndKeys = endKeys?.length ? endKeys.every((v) => Object.keys(value).includes(v)) : false;
|
|
7255
|
+
if (hasOnlyEndKeys) {
|
|
7256
|
+
newObj = { ...newObj, [newPath.join(".")]: value };
|
|
7257
|
+
} else {
|
|
7258
|
+
recurseDip(value, newPath);
|
|
7259
|
+
}
|
|
7260
|
+
} else if (Array.isArray(value)) {
|
|
7261
|
+
const contructValue = value.reduce((a, b) => ({ ...a, [value.indexOf(b)]: b }), {});
|
|
7262
|
+
recurseDip(contructValue, newPath);
|
|
7263
|
+
} else {
|
|
7264
|
+
newObj = { ...newObj, [newPath.join(".")]: value };
|
|
7265
|
+
}
|
|
7266
|
+
}
|
|
7267
|
+
}
|
|
7268
|
+
recurseDip(object, []);
|
|
7269
|
+
return newObj;
|
|
7270
|
+
};
|
|
7271
|
+
|
|
7272
|
+
var FormConfigType = /* @__PURE__ */ ((FormConfigType2) => {
|
|
7273
|
+
FormConfigType2["STRING"] = "STRING";
|
|
7274
|
+
FormConfigType2["NUMBER"] = "NUMBER";
|
|
7275
|
+
FormConfigType2["DATE"] = "DATE";
|
|
7276
|
+
FormConfigType2["ENUM"] = "ENUM";
|
|
7277
|
+
FormConfigType2["ARRAY"] = "ARRAY";
|
|
7278
|
+
FormConfigType2["BOOLEAN"] = "BOOLEAN";
|
|
7279
|
+
FormConfigType2["RECORD"] = "RECORD";
|
|
7280
|
+
FormConfigType2["OBJECT"] = "OBJECT";
|
|
7281
|
+
FormConfigType2["UNION"] = "UNION";
|
|
7282
|
+
FormConfigType2["CREATABLE"] = "CREATABLE";
|
|
7283
|
+
FormConfigType2["SELECT"] = "SELECT";
|
|
7284
|
+
FormConfigType2["MULTI_SELECT"] = "MULTI_SELECT";
|
|
7285
|
+
return FormConfigType2;
|
|
7286
|
+
})(FormConfigType || {});
|
|
7287
|
+
function getFormConfigTypesFromSchemaDef({
|
|
7288
|
+
schema,
|
|
7289
|
+
isOptional = false
|
|
7290
|
+
}) {
|
|
7291
|
+
if (schema instanceof z$1.ZodObject) {
|
|
7292
|
+
return { type: "OBJECT" /* OBJECT */, isOptional };
|
|
7293
|
+
}
|
|
7294
|
+
if (schema instanceof z$1.ZodString) {
|
|
7295
|
+
if (schema instanceof z$1.ZodString && schema._def.checks.some((check) => check.kind === "datetime")) {
|
|
7296
|
+
return { type: "DATE" /* DATE */, isOptional };
|
|
7297
|
+
}
|
|
7298
|
+
return { type: "STRING" /* STRING */, isOptional };
|
|
7299
|
+
} else if (schema instanceof ZodNumber) {
|
|
7300
|
+
return { type: "NUMBER" /* NUMBER */, isOptional };
|
|
7301
|
+
} else if (schema instanceof ZodBoolean) {
|
|
7302
|
+
return { type: "BOOLEAN" /* BOOLEAN */, isOptional };
|
|
7303
|
+
} else if (schema instanceof ZodDate) {
|
|
7304
|
+
return { type: "DATE" /* DATE */, isOptional };
|
|
7305
|
+
} else if (schema instanceof ZodLiteral) {
|
|
7306
|
+
return {
|
|
7307
|
+
type: "ENUM" /* ENUM */,
|
|
7308
|
+
isOptional,
|
|
7309
|
+
options: [{ label: schema.value, value: schema.value }]
|
|
7310
|
+
};
|
|
7311
|
+
} else if (schema instanceof ZodEnum) {
|
|
7312
|
+
return {
|
|
7313
|
+
type: "ENUM" /* ENUM */,
|
|
7314
|
+
isOptional,
|
|
7315
|
+
options: schema.options.map((v) => ({ label: v, value: v }))
|
|
7316
|
+
};
|
|
7317
|
+
} else if (schema instanceof ZodArray) {
|
|
7318
|
+
return {
|
|
7319
|
+
type: "ARRAY" /* ARRAY */,
|
|
7320
|
+
isOptional,
|
|
7321
|
+
options: schema.element instanceof ZodEnum ? schema.element.options.map((v) => ({ label: v, value: v })) : []
|
|
7322
|
+
};
|
|
7323
|
+
} else if (schema instanceof z$1.ZodOptional || schema instanceof z$1.ZodDefault) {
|
|
7324
|
+
return getFormConfigTypesFromSchemaDef({ schema: schema._def.innerType, isOptional: true });
|
|
7325
|
+
} else if (schema instanceof z$1.ZodEffects) {
|
|
7326
|
+
return getFormConfigTypesFromSchemaDef({ schema: schema._def.schema, isOptional });
|
|
7327
|
+
} else if (schema instanceof z$1.ZodRecord) {
|
|
7328
|
+
return {
|
|
7329
|
+
type: "RECORD" /* RECORD */,
|
|
7330
|
+
isOptional,
|
|
7331
|
+
innerSchema: schema._def.valueType
|
|
7332
|
+
};
|
|
7333
|
+
} else {
|
|
7334
|
+
return { type: "STRING" /* STRING */, isOptional };
|
|
7335
|
+
}
|
|
7336
|
+
}
|
|
7337
|
+
function schemaToFormFieldRenderer({
|
|
7338
|
+
schema,
|
|
7339
|
+
errors,
|
|
7340
|
+
renderFieldMap,
|
|
7341
|
+
schemaField,
|
|
7342
|
+
renderLabel,
|
|
7343
|
+
control,
|
|
7344
|
+
variables,
|
|
7345
|
+
onFieldChange,
|
|
7346
|
+
schemaOptions,
|
|
7347
|
+
values,
|
|
7348
|
+
isOptional = false,
|
|
7349
|
+
isNullable = false
|
|
7350
|
+
}) {
|
|
7351
|
+
const fieldConfig = getFormConfigTypesFromSchemaDef({ schema, isOptional });
|
|
7352
|
+
const parentFieldValue = schemaOptions?.parentField ? getPath(values, schemaOptions?.parentField) : "";
|
|
7353
|
+
if (schemaOptions?.parentField && !parentFieldValue) {
|
|
7354
|
+
return null;
|
|
7355
|
+
}
|
|
7356
|
+
if (!renderFieldMap) return;
|
|
7357
|
+
const flattenedErrors = flattenObject(errors, ["message", "type"]);
|
|
7358
|
+
const fieldOptions = schemaOptions?.parentField ? schemaOptions?.options?.[parentFieldValue] : schemaOptions?.options || fieldConfig.options;
|
|
7359
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 mt-3 w-full", children: [
|
|
7360
|
+
renderLabel ? renderLabel({ isOptional: Boolean(fieldConfig.isOptional), schemaField }) : /* @__PURE__ */ jsxs(Label, { className: "flex gap-0.5 capitalize", htmlFor: schemaField, "aria-required": !fieldConfig.isOptional, children: [
|
|
7361
|
+
!fieldConfig?.isOptional && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" }),
|
|
7362
|
+
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: toTitleCase(schemaField.split(".").pop() || "") })
|
|
7363
|
+
] }),
|
|
7364
|
+
renderFieldMap[fieldConfig.type]({
|
|
7365
|
+
name: schemaField,
|
|
7366
|
+
options: fieldOptions,
|
|
7367
|
+
control,
|
|
7368
|
+
variables,
|
|
7369
|
+
innerSchema: fieldConfig.innerSchema,
|
|
7370
|
+
handleFieldChange: onFieldChange,
|
|
7371
|
+
isNullable
|
|
7372
|
+
}),
|
|
7373
|
+
flattenedErrors?.[schemaField] ? /* @__PURE__ */ jsx(Text, { size: "xs", className: "text-red-500", children: flattenedErrors[schemaField]?.message }) : null
|
|
7374
|
+
] }, schemaField);
|
|
7375
|
+
}
|
|
7376
|
+
|
|
7377
|
+
function UnionField({
|
|
7378
|
+
renderDynamicForm,
|
|
7379
|
+
schema,
|
|
7380
|
+
handleFieldChange,
|
|
7381
|
+
control,
|
|
7382
|
+
formValues,
|
|
7383
|
+
errors,
|
|
7384
|
+
parentField,
|
|
7385
|
+
action,
|
|
7386
|
+
isOptional = false,
|
|
7387
|
+
isNullable = false,
|
|
7388
|
+
depth
|
|
7389
|
+
}) {
|
|
7390
|
+
const fieldConfig = getFormConfigTypesFromSchemaDef({ schema, isOptional });
|
|
7391
|
+
if (schema instanceof ZodUnion) {
|
|
7392
|
+
const schemaOptions = schema.options;
|
|
7393
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
7394
|
+
/* @__PURE__ */ jsxs(Label, { className: "flex gap-0.5 capitalize mb-2", htmlFor: parentField, "aria-required": !fieldConfig.isOptional, children: [
|
|
7395
|
+
!fieldConfig?.isOptional && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" }),
|
|
7396
|
+
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: toTitleCase(parentField) })
|
|
7397
|
+
] }),
|
|
7398
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4", children: schemaOptions.map((schemaOption, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
7399
|
+
index >= 1 && /* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3 text-center", size: "xs", children: "or" }),
|
|
7400
|
+
/* @__PURE__ */ jsx("div", { className: "ring-1 ring-white/10 p-2 rounded-md relative", children: renderDynamicForm({
|
|
7401
|
+
schema: schemaOption,
|
|
7402
|
+
handleFieldChange,
|
|
7403
|
+
control,
|
|
7404
|
+
formValues,
|
|
7405
|
+
errors,
|
|
7406
|
+
parentField,
|
|
7407
|
+
action,
|
|
7408
|
+
isOptional,
|
|
7409
|
+
isNullable,
|
|
7410
|
+
depth
|
|
7411
|
+
}) })
|
|
7412
|
+
] }, index)) })
|
|
7413
|
+
] });
|
|
7414
|
+
}
|
|
7415
|
+
return null;
|
|
7416
|
+
}
|
|
7417
|
+
|
|
7418
|
+
function ObjectField({
|
|
7419
|
+
renderDynamicForm,
|
|
7420
|
+
schema,
|
|
7421
|
+
handleFieldChange,
|
|
7422
|
+
control,
|
|
7423
|
+
formValues,
|
|
7424
|
+
errors,
|
|
7425
|
+
parentField,
|
|
7426
|
+
action,
|
|
7427
|
+
isArray = false,
|
|
7428
|
+
isOptional = false,
|
|
7429
|
+
depth
|
|
7430
|
+
}) {
|
|
7431
|
+
const fieldConfig = getFormConfigTypesFromSchemaDef({ schema, isOptional });
|
|
7432
|
+
const { fields, append, remove } = useFieldArray({
|
|
7433
|
+
control,
|
|
7434
|
+
name: parentField
|
|
7435
|
+
});
|
|
7436
|
+
function handleAddForm() {
|
|
7437
|
+
append({});
|
|
7438
|
+
}
|
|
7439
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
7440
|
+
/* @__PURE__ */ jsxs(Label, { className: "flex gap-0.5 capitalize mb-2", htmlFor: parentField, "aria-required": !fieldConfig.isOptional, children: [
|
|
7441
|
+
!fieldConfig?.isOptional && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" }),
|
|
7442
|
+
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: toTitleCase(parentField) })
|
|
7443
|
+
] }),
|
|
7444
|
+
isArray ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7445
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4", children: fields.map((field, index) => /* @__PURE__ */ jsxs("div", { className: "ring-1 ring-white/10 p-2 rounded-md relative", children: [
|
|
7446
|
+
/* @__PURE__ */ jsx(
|
|
7447
|
+
Button,
|
|
7448
|
+
{
|
|
7449
|
+
type: "button",
|
|
7450
|
+
variant: "ghost",
|
|
7451
|
+
size: "icon",
|
|
7452
|
+
onClick: () => remove(index),
|
|
7453
|
+
className: "absolute top-0 right-0",
|
|
7454
|
+
children: /* @__PURE__ */ jsx(XIcon, { className: "text-icon h-3.5 w-3.5" })
|
|
7455
|
+
}
|
|
7456
|
+
),
|
|
7457
|
+
renderDynamicForm({
|
|
7458
|
+
schema: schema instanceof ZodArray ? schema.element : schema,
|
|
7459
|
+
handleFieldChange,
|
|
7460
|
+
control,
|
|
7461
|
+
formValues,
|
|
7462
|
+
errors,
|
|
7463
|
+
parentField: `${parentField}.${index}`,
|
|
7464
|
+
action,
|
|
7465
|
+
isOptional,
|
|
7466
|
+
depth
|
|
7467
|
+
})
|
|
7468
|
+
] }, field.id)) }),
|
|
7469
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4", children: /* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", className: "w-full text-xs h-9", onClick: handleAddForm, children: [
|
|
7470
|
+
"Add ",
|
|
7471
|
+
toTitleCase(parentField.split(".").pop() || "")
|
|
7472
|
+
] }) })
|
|
7473
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "ring-1 ring-white/10 p-2 rounded-md relative", children: renderDynamicForm({
|
|
7474
|
+
schema,
|
|
7475
|
+
handleFieldChange,
|
|
7476
|
+
control,
|
|
7477
|
+
formValues,
|
|
7478
|
+
errors,
|
|
7479
|
+
parentField,
|
|
7480
|
+
action,
|
|
7481
|
+
isOptional,
|
|
7482
|
+
depth
|
|
7483
|
+
}) })
|
|
7484
|
+
] });
|
|
7485
|
+
}
|
|
7486
|
+
|
|
7487
|
+
function NumberField({ name, control, handleFieldChange }) {
|
|
7488
|
+
return /* @__PURE__ */ jsx(
|
|
7489
|
+
Controller,
|
|
7490
|
+
{
|
|
7491
|
+
name,
|
|
7492
|
+
control,
|
|
7493
|
+
render: ({ field }) => /* @__PURE__ */ jsx(
|
|
7494
|
+
Input,
|
|
7495
|
+
{
|
|
7496
|
+
...field,
|
|
7497
|
+
type: "number",
|
|
7498
|
+
onChange: (e) => {
|
|
7499
|
+
const value = e.target.value === "" ? void 0 : Number(e.target.value);
|
|
7500
|
+
field.onChange(value);
|
|
7501
|
+
handleFieldChange?.({ key: name, value });
|
|
7502
|
+
}
|
|
7503
|
+
}
|
|
7504
|
+
)
|
|
7505
|
+
}
|
|
7506
|
+
);
|
|
7507
|
+
}
|
|
7508
|
+
|
|
7509
|
+
function RecordField({ name, control, handleFieldChange }) {
|
|
7510
|
+
const formValue = useWatch({ control, name }) || {};
|
|
7511
|
+
const [pairs, setPairs] = React.useState(
|
|
7512
|
+
() => Object.entries(formValue).map(([key, value]) => ({
|
|
7513
|
+
id: key || v4(),
|
|
7514
|
+
key,
|
|
7515
|
+
value
|
|
7516
|
+
}))
|
|
7517
|
+
);
|
|
7518
|
+
React.useEffect(() => {
|
|
7519
|
+
if (pairs.length === 0) {
|
|
7520
|
+
setPairs([{ id: v4(), key: "", value: "" }]);
|
|
7521
|
+
}
|
|
7522
|
+
}, [pairs]);
|
|
7523
|
+
const updateForm = React.useCallback(
|
|
7524
|
+
(newPairs) => {
|
|
7525
|
+
if (!handleFieldChange) return;
|
|
7526
|
+
const value = newPairs.reduce(
|
|
7527
|
+
(acc, pair) => {
|
|
7528
|
+
if (pair.key) {
|
|
7529
|
+
acc[pair.key] = pair.value;
|
|
7530
|
+
}
|
|
7531
|
+
return acc;
|
|
7532
|
+
},
|
|
7533
|
+
{}
|
|
7534
|
+
);
|
|
7535
|
+
handleFieldChange({ key: name, value });
|
|
7536
|
+
},
|
|
7537
|
+
[handleFieldChange, name]
|
|
7538
|
+
);
|
|
7539
|
+
const handleChange = (id, field, newValue) => {
|
|
7540
|
+
setPairs((prev) => prev.map((pair) => pair.id === id ? { ...pair, [field]: newValue } : pair));
|
|
7541
|
+
};
|
|
7542
|
+
const handleBlur = () => {
|
|
7543
|
+
updateForm(pairs);
|
|
7544
|
+
};
|
|
7545
|
+
const addPair = () => {
|
|
7546
|
+
const newPairs = [...pairs, { id: v4(), key: "", value: "" }];
|
|
7547
|
+
setPairs(newPairs);
|
|
7548
|
+
updateForm(newPairs);
|
|
7549
|
+
};
|
|
7550
|
+
const removePair = (id) => {
|
|
7551
|
+
const newPairs = pairs.filter((p) => p.id !== id);
|
|
7552
|
+
if (newPairs.length === 0) {
|
|
7553
|
+
newPairs.push({ id: v4(), key: "", value: "" });
|
|
7554
|
+
}
|
|
7555
|
+
setPairs(newPairs);
|
|
7556
|
+
updateForm(newPairs);
|
|
7557
|
+
};
|
|
7558
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7559
|
+
pairs.map((pair) => /* @__PURE__ */ jsxs("div", { className: "relative space-y-2 rounded-lg border p-4", children: [
|
|
7560
|
+
/* @__PURE__ */ jsx(
|
|
7561
|
+
Button,
|
|
7562
|
+
{
|
|
7563
|
+
type: "button",
|
|
7564
|
+
variant: "ghost",
|
|
7565
|
+
size: "icon",
|
|
7566
|
+
className: "absolute right-2 top-2",
|
|
7567
|
+
onClick: () => removePair(pair.id),
|
|
7568
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
7569
|
+
}
|
|
7570
|
+
),
|
|
7571
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
7572
|
+
/* @__PURE__ */ jsx(
|
|
7573
|
+
Input,
|
|
7574
|
+
{
|
|
7575
|
+
placeholder: "Key",
|
|
7576
|
+
value: pair.key,
|
|
7577
|
+
onChange: (e) => handleChange(pair.id, "key", e.target.value),
|
|
7578
|
+
onBlur: handleBlur
|
|
7579
|
+
}
|
|
7580
|
+
),
|
|
7581
|
+
/* @__PURE__ */ jsx(
|
|
7582
|
+
Input,
|
|
7583
|
+
{
|
|
7584
|
+
placeholder: "Value",
|
|
7585
|
+
value: pair.value,
|
|
7586
|
+
onChange: (e) => handleChange(pair.id, "value", e.target.value),
|
|
7587
|
+
onBlur: handleBlur
|
|
7588
|
+
}
|
|
7589
|
+
)
|
|
7590
|
+
] })
|
|
7591
|
+
] }, pair.id)),
|
|
7592
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", size: "sm", className: "w-full", onClick: addPair, children: [
|
|
7593
|
+
/* @__PURE__ */ jsx(Plus, { className: "mr-2 h-4 w-4" }),
|
|
7594
|
+
"Add Key-Value Pair"
|
|
7595
|
+
] })
|
|
7596
|
+
] });
|
|
7597
|
+
}
|
|
7598
|
+
|
|
7599
|
+
function getDefaultFieldMap() {
|
|
7600
|
+
return {
|
|
7601
|
+
[FormConfigType.STRING]: (props) => {
|
|
7602
|
+
const { options, ...rest } = props;
|
|
7603
|
+
if (options?.length) {
|
|
7604
|
+
return /* @__PURE__ */ jsx(EnumField, { ...rest, options });
|
|
7605
|
+
}
|
|
7606
|
+
return /* @__PURE__ */ jsx(StringField, { ...rest });
|
|
7607
|
+
},
|
|
7608
|
+
[FormConfigType.NUMBER]: (props) => {
|
|
7609
|
+
return /* @__PURE__ */ jsx(NumberField, { ...props });
|
|
7610
|
+
},
|
|
7611
|
+
[FormConfigType.BOOLEAN]: (props) => {
|
|
7612
|
+
return /* @__PURE__ */ jsx(BooleanField, { ...props });
|
|
7613
|
+
},
|
|
7614
|
+
[FormConfigType.DATE]: (props) => {
|
|
7615
|
+
return /* @__PURE__ */ jsx(DateField, { ...props });
|
|
7616
|
+
},
|
|
7617
|
+
[FormConfigType.ENUM]: (props) => {
|
|
7618
|
+
const { options = [] } = props;
|
|
7619
|
+
return /* @__PURE__ */ jsx(EnumField, { ...props, options });
|
|
7620
|
+
},
|
|
7621
|
+
[FormConfigType.ARRAY]: (props) => {
|
|
7622
|
+
const renderField = ({ fieldName, index: _index }) => {
|
|
7623
|
+
return getDefaultFieldMap()[FormConfigType.STRING]({
|
|
7624
|
+
...props,
|
|
7625
|
+
name: fieldName
|
|
7626
|
+
});
|
|
7627
|
+
};
|
|
7628
|
+
return /* @__PURE__ */ jsx(ArrayField, { ...props, renderField });
|
|
7629
|
+
},
|
|
7630
|
+
[FormConfigType.RECORD]: (props) => {
|
|
7631
|
+
return /* @__PURE__ */ jsx(RecordField, { ...props });
|
|
7632
|
+
},
|
|
7633
|
+
[FormConfigType.OBJECT]: (props) => {
|
|
7634
|
+
const { innerSchema, name, control, handleFieldChange } = props;
|
|
7635
|
+
if (!innerSchema) return null;
|
|
7636
|
+
return /* @__PURE__ */ jsx(
|
|
7637
|
+
ObjectField,
|
|
7638
|
+
{
|
|
7639
|
+
schema: innerSchema,
|
|
7640
|
+
control,
|
|
7641
|
+
parentField: name,
|
|
7642
|
+
handleFieldChange: (field, value) => handleFieldChange({ key: field, value }),
|
|
7643
|
+
formValues: {},
|
|
7644
|
+
errors: {},
|
|
7645
|
+
renderDynamicForm: (props2) => resolveSchema({ ...props2, handleFieldChange })
|
|
7646
|
+
}
|
|
7647
|
+
);
|
|
7648
|
+
},
|
|
7649
|
+
[FormConfigType.UNION]: (props) => {
|
|
7650
|
+
const { innerSchema, name, control, handleFieldChange } = props;
|
|
7651
|
+
if (!innerSchema || !(innerSchema instanceof z.ZodUnion)) return null;
|
|
7652
|
+
return /* @__PURE__ */ jsx(
|
|
7653
|
+
UnionField,
|
|
7654
|
+
{
|
|
7655
|
+
schema: innerSchema,
|
|
7656
|
+
control,
|
|
7657
|
+
parentField: name,
|
|
7658
|
+
handleFieldChange: (field, value) => handleFieldChange({ key: field, value }),
|
|
7659
|
+
renderDynamicForm: (fieldProps) => {
|
|
7660
|
+
const fieldType = getFormConfigTypesFromSchemaDef({ schema: fieldProps.schema });
|
|
7661
|
+
return getDefaultFieldMap()[fieldType.type]({
|
|
7662
|
+
...props,
|
|
7663
|
+
...fieldProps,
|
|
7664
|
+
control,
|
|
7665
|
+
handleFieldChange
|
|
7666
|
+
});
|
|
7667
|
+
},
|
|
7668
|
+
formValues: {},
|
|
7669
|
+
errors: {}
|
|
7670
|
+
}
|
|
7671
|
+
);
|
|
7672
|
+
},
|
|
7673
|
+
[FormConfigType.CREATABLE]: (props) => {
|
|
7674
|
+
return /* @__PURE__ */ jsx(CreatableField, { ...props });
|
|
7675
|
+
},
|
|
7676
|
+
[FormConfigType.SELECT]: (props) => {
|
|
7677
|
+
const { options = [] } = props;
|
|
7678
|
+
return /* @__PURE__ */ jsx(EnumField, { ...props, options });
|
|
7679
|
+
},
|
|
7680
|
+
[FormConfigType.MULTI_SELECT]: (props) => {
|
|
7681
|
+
return /* @__PURE__ */ jsx(CreatableField, { ...props });
|
|
7682
|
+
}
|
|
7683
|
+
};
|
|
7684
|
+
}
|
|
7685
|
+
|
|
7686
|
+
function adaptHandleFieldChange(handler) {
|
|
7687
|
+
return (field, value) => handler({ key: field, value });
|
|
7688
|
+
}
|
|
7689
|
+
function resolveSchema({
|
|
7690
|
+
schema,
|
|
7691
|
+
parentField,
|
|
7692
|
+
control,
|
|
7693
|
+
formValues,
|
|
7694
|
+
errors,
|
|
7695
|
+
handleFieldChange,
|
|
7696
|
+
isOptional = false,
|
|
7697
|
+
isNullable = false,
|
|
7698
|
+
depth = 0
|
|
7699
|
+
}) {
|
|
7700
|
+
if (depth > 10) {
|
|
7701
|
+
console.warn("Maximum schema resolution depth reached. Possible circular reference.");
|
|
7702
|
+
return null;
|
|
7703
|
+
}
|
|
7704
|
+
if (schema instanceof z$1.ZodObject) {
|
|
7705
|
+
return Object.entries(schema.shape).map(([field, fieldSchema]) => {
|
|
7706
|
+
const currentField = parentField ? `${parentField}.${field}` : field;
|
|
7707
|
+
return resolveSchemaComponent({
|
|
7708
|
+
schema: fieldSchema,
|
|
7709
|
+
parentField: currentField,
|
|
7710
|
+
control,
|
|
7711
|
+
formValues,
|
|
7712
|
+
errors,
|
|
7713
|
+
handleFieldChange,
|
|
7714
|
+
isOptional,
|
|
7715
|
+
isNullable
|
|
7716
|
+
});
|
|
7717
|
+
});
|
|
7718
|
+
}
|
|
7719
|
+
return resolveSchemaComponent({
|
|
7720
|
+
schema,
|
|
7721
|
+
parentField,
|
|
7722
|
+
control,
|
|
7723
|
+
formValues,
|
|
7724
|
+
errors,
|
|
7725
|
+
handleFieldChange,
|
|
7726
|
+
isOptional,
|
|
7727
|
+
isNullable
|
|
7728
|
+
});
|
|
7729
|
+
}
|
|
7730
|
+
function resolveSchemaComponent({
|
|
7731
|
+
schema,
|
|
7732
|
+
parentField,
|
|
7733
|
+
control,
|
|
7734
|
+
formValues,
|
|
7735
|
+
errors,
|
|
7736
|
+
handleFieldChange,
|
|
7737
|
+
isOptional = false,
|
|
7738
|
+
isNullable = false
|
|
7739
|
+
}) {
|
|
7740
|
+
if (schema instanceof z$1.ZodDefault) return null;
|
|
7741
|
+
if (schema instanceof z$1.ZodOptional) {
|
|
7742
|
+
return resolveSchemaComponent({
|
|
7743
|
+
schema: schema._def.innerType,
|
|
7744
|
+
parentField,
|
|
7745
|
+
control,
|
|
7746
|
+
formValues,
|
|
7747
|
+
errors,
|
|
7748
|
+
handleFieldChange,
|
|
7749
|
+
isOptional: true,
|
|
7750
|
+
isNullable
|
|
7751
|
+
});
|
|
7752
|
+
}
|
|
7753
|
+
if (schema instanceof z$1.ZodObject) {
|
|
7754
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-8 py-8 w-full", children: /* @__PURE__ */ jsx(
|
|
7755
|
+
ObjectField,
|
|
7756
|
+
{
|
|
7757
|
+
schema,
|
|
7758
|
+
control,
|
|
7759
|
+
parentField,
|
|
7760
|
+
handleFieldChange: (field, value) => handleFieldChange({ key: field, value }),
|
|
7761
|
+
formValues,
|
|
7762
|
+
errors,
|
|
7763
|
+
isOptional,
|
|
7764
|
+
renderDynamicForm: (props) => resolveSchema({ ...props, handleFieldChange })
|
|
7765
|
+
}
|
|
7766
|
+
) }, parentField);
|
|
7767
|
+
}
|
|
7768
|
+
if (schema instanceof z$1.ZodUnion) {
|
|
7769
|
+
if (schema.options.some((s) => s instanceof z$1.ZodNull)) {
|
|
7770
|
+
const nonNullSchema = schema.options.find((s) => !(s instanceof z$1.ZodNull));
|
|
7771
|
+
return resolveSchemaComponent({
|
|
7772
|
+
schema: z$1.optional(nonNullSchema),
|
|
7773
|
+
parentField,
|
|
7774
|
+
control,
|
|
7775
|
+
formValues,
|
|
7776
|
+
errors,
|
|
7777
|
+
handleFieldChange,
|
|
7778
|
+
isNullable: true
|
|
7779
|
+
});
|
|
7780
|
+
}
|
|
7781
|
+
return /* @__PURE__ */ jsx(
|
|
7782
|
+
UnionField,
|
|
7783
|
+
{
|
|
7784
|
+
schema,
|
|
7785
|
+
control,
|
|
7786
|
+
parentField,
|
|
7787
|
+
handleFieldChange: adaptHandleFieldChange(handleFieldChange),
|
|
7788
|
+
formValues,
|
|
7789
|
+
errors,
|
|
7790
|
+
isOptional,
|
|
7791
|
+
isNullable,
|
|
7792
|
+
renderDynamicForm: (props) => resolveSchema({
|
|
7793
|
+
...props,
|
|
7794
|
+
handleFieldChange: (props2) => handleFieldChange(props2)
|
|
7795
|
+
})
|
|
7796
|
+
}
|
|
7797
|
+
);
|
|
7798
|
+
}
|
|
7799
|
+
if (schema instanceof z$1.ZodArray) {
|
|
7800
|
+
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col gap-8 py-8", children: /* @__PURE__ */ jsx(
|
|
7801
|
+
ArrayField,
|
|
7802
|
+
{
|
|
7803
|
+
control,
|
|
7804
|
+
name: parentField,
|
|
7805
|
+
isStringField: schema.element instanceof z$1.ZodString,
|
|
7806
|
+
renderField: (props) => {
|
|
7807
|
+
const fieldSchema = schema.element;
|
|
7808
|
+
let currentField = props.fieldName;
|
|
7809
|
+
if (fieldSchema instanceof z$1.ZodString) {
|
|
7810
|
+
currentField = `${currentField}.root`;
|
|
7811
|
+
}
|
|
7812
|
+
return resolveSchemaComponent({
|
|
7813
|
+
schema: fieldSchema,
|
|
7814
|
+
parentField: currentField,
|
|
7815
|
+
control,
|
|
7816
|
+
formValues,
|
|
7817
|
+
errors,
|
|
7818
|
+
handleFieldChange
|
|
7819
|
+
});
|
|
7820
|
+
}
|
|
7821
|
+
}
|
|
7822
|
+
) }, parentField);
|
|
7823
|
+
}
|
|
7824
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full", children: schemaToFormFieldRenderer({
|
|
7825
|
+
schema,
|
|
7826
|
+
schemaField: parentField,
|
|
7827
|
+
control,
|
|
7828
|
+
values: formValues,
|
|
7829
|
+
errors,
|
|
7830
|
+
renderFieldMap: getDefaultFieldMap(),
|
|
7831
|
+
onFieldChange: handleFieldChange
|
|
7832
|
+
}) }, parentField);
|
|
7833
|
+
}
|
|
7834
|
+
|
|
7835
|
+
function DynamicForm({
|
|
7836
|
+
schema,
|
|
7837
|
+
onSubmit,
|
|
7838
|
+
defaultValues,
|
|
7839
|
+
isSubmitLoading,
|
|
7840
|
+
submitButtonLabel = "Submit"
|
|
7841
|
+
}) {
|
|
7842
|
+
const schemaTypeName = schema?._def?.typeName;
|
|
7843
|
+
const discriminatedUnionSchemaOptions = schema?._def?.options;
|
|
7844
|
+
const discriminatedUnionSchemaDiscriminator = schema?._def?.discriminator;
|
|
7845
|
+
const wrappedSchema = schemaTypeName !== "ZodObject" ? z$1.object({ items: schema }) : schema;
|
|
7846
|
+
const form = useForm({
|
|
7847
|
+
resolver: schemaTypeName === "ZodDiscriminatedUnion" ? customZodUnionResolver(wrappedSchema, discriminatedUnionSchemaDiscriminator) : zodResolver(wrappedSchema),
|
|
7848
|
+
defaultValues
|
|
7849
|
+
});
|
|
7850
|
+
const { control, handleSubmit, watch } = form;
|
|
7851
|
+
const formValues = form.watch();
|
|
7852
|
+
const discriminatorValue = discriminatedUnionSchemaDiscriminator ? watch(discriminatedUnionSchemaDiscriminator) : void 0;
|
|
7853
|
+
const resolvedSchema = schemaTypeName === "ZodDiscriminatedUnion" ? discriminatedUnionSchemaOptions?.find(
|
|
7854
|
+
(option) => option?.shape?.[discriminatedUnionSchemaDiscriminator]?._def?.value === discriminatorValue
|
|
7855
|
+
) || z$1.object({ [discriminatedUnionSchemaDiscriminator]: z$1.string() }) : wrappedSchema;
|
|
7856
|
+
function handleFieldChange({ key, value }) {
|
|
7857
|
+
if (key === discriminatedUnionSchemaDiscriminator) {
|
|
7858
|
+
form.setValue(key, value);
|
|
7859
|
+
} else {
|
|
7860
|
+
form.setValue(key, value);
|
|
7861
|
+
}
|
|
7862
|
+
}
|
|
7863
|
+
const wrappedOnSubmit = (values) => {
|
|
7864
|
+
if (schemaTypeName !== "ZodObject") {
|
|
7865
|
+
return onSubmit(values.items);
|
|
7866
|
+
}
|
|
7867
|
+
return onSubmit(values);
|
|
7868
|
+
};
|
|
7869
|
+
return /* @__PURE__ */ jsx(ScrollArea, { className: "h-full w-full", children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit(wrappedOnSubmit), className: "flex flex-col gap-4 p-4 w-full", children: [
|
|
7870
|
+
resolveSchema({
|
|
7871
|
+
schema: resolvedSchema,
|
|
7872
|
+
parentField: "",
|
|
7873
|
+
control,
|
|
7874
|
+
formValues,
|
|
7875
|
+
errors: form.formState.errors,
|
|
7876
|
+
handleFieldChange
|
|
7877
|
+
}),
|
|
7878
|
+
/* @__PURE__ */ jsx(Button, { disabled: isSubmitLoading, type: "submit", children: isSubmitLoading ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : submitButtonLabel })
|
|
7879
|
+
] }) });
|
|
7880
|
+
}
|
|
7881
|
+
|
|
7882
|
+
function CodeBlockDemo({
|
|
7883
|
+
code = "",
|
|
7884
|
+
language = "ts",
|
|
7885
|
+
filename,
|
|
7886
|
+
className
|
|
7887
|
+
}) {
|
|
7888
|
+
return /* @__PURE__ */ jsxs(CodeBlock$1, { code, language, theme: themes.oneDark, children: [
|
|
7889
|
+
filename ? /* @__PURE__ */ jsx("div", { className: "absolute w-full px-6 py-2 pl-4 text-sm rounded bg-mastra-bg-2 text-mastra-el-6/50", children: filename }) : null,
|
|
7890
|
+
/* @__PURE__ */ jsx(
|
|
7891
|
+
CodeBlock$1.Code,
|
|
7892
|
+
{
|
|
7893
|
+
className: cn("bg-transparent h-full p-6 rounded-xl whitespace-pre-wrap", filename ? "pt-10" : "", className),
|
|
7894
|
+
children: /* @__PURE__ */ jsx("div", { className: "table-row", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
7895
|
+
/* @__PURE__ */ jsx(CodeBlock$1.LineNumber, { className: "table-cell pr-4 text-sm text-right select-none text-gray-500/50" }),
|
|
7896
|
+
/* @__PURE__ */ jsx(CodeBlock$1.LineContent, { className: "flex", children: /* @__PURE__ */ jsx(CodeBlock$1.Token, { className: "font-mono text-sm mastra-token" }) })
|
|
7897
|
+
] }) })
|
|
7898
|
+
}
|
|
7899
|
+
)
|
|
7900
|
+
] });
|
|
7901
|
+
}
|
|
7902
|
+
|
|
7903
|
+
function useCopyToClipboard({ text, copyMessage = "Copied to clipboard!" }) {
|
|
7904
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
7905
|
+
const timeoutRef = useRef(null);
|
|
7906
|
+
const handleCopy = useCallback(() => {
|
|
7907
|
+
navigator.clipboard.writeText(text).then(() => {
|
|
7908
|
+
toast.success(copyMessage);
|
|
7909
|
+
setIsCopied(true);
|
|
7910
|
+
if (timeoutRef.current) {
|
|
7911
|
+
clearTimeout(timeoutRef.current);
|
|
7912
|
+
timeoutRef.current = null;
|
|
7913
|
+
}
|
|
7914
|
+
timeoutRef.current = setTimeout(() => {
|
|
7915
|
+
setIsCopied(false);
|
|
7916
|
+
}, 2e3);
|
|
7917
|
+
}).catch(() => {
|
|
7918
|
+
toast.error("Failed to copy to clipboard.");
|
|
7919
|
+
});
|
|
7920
|
+
}, [text, copyMessage]);
|
|
7921
|
+
return { isCopied, handleCopy };
|
|
7922
|
+
}
|
|
7923
|
+
|
|
7924
|
+
function CopyButton({ content, copyMessage, classname }) {
|
|
7925
|
+
const { isCopied, handleCopy } = useCopyToClipboard({
|
|
7926
|
+
text: content,
|
|
7927
|
+
copyMessage
|
|
7928
|
+
});
|
|
7929
|
+
return /* @__PURE__ */ jsxs(
|
|
7930
|
+
Button,
|
|
7931
|
+
{
|
|
7932
|
+
variant: "ghost",
|
|
7933
|
+
size: "icon",
|
|
7934
|
+
className: cn("relative h-6 w-6", classname),
|
|
7935
|
+
"aria-label": "Copy to clipboard",
|
|
7936
|
+
onClick: handleCopy,
|
|
7937
|
+
children: [
|
|
7938
|
+
/* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsx(Check, { className: cn("h-4 w-4 transition-transform ease-in-out", isCopied ? "scale-100" : "scale-0") }) }),
|
|
7939
|
+
/* @__PURE__ */ jsx(Copy, { className: cn("h-4 w-4 transition-transform ease-in-out", isCopied ? "scale-0" : "scale-100") })
|
|
7940
|
+
]
|
|
7941
|
+
}
|
|
7942
|
+
);
|
|
7943
|
+
}
|
|
7944
|
+
|
|
7945
|
+
const WorkflowRunContext = createContext({});
|
|
7946
|
+
function WorkflowRunProvider({ children }) {
|
|
7947
|
+
const [result, setResult] = useState(null);
|
|
7948
|
+
const [payload, setPayload] = useState(null);
|
|
7949
|
+
const clearData = () => {
|
|
7950
|
+
setResult(null);
|
|
7951
|
+
setPayload(null);
|
|
7952
|
+
};
|
|
7953
|
+
return /* @__PURE__ */ jsx(
|
|
7954
|
+
WorkflowRunContext.Provider,
|
|
7955
|
+
{
|
|
7956
|
+
value: {
|
|
7957
|
+
result,
|
|
7958
|
+
setResult,
|
|
7959
|
+
payload,
|
|
7960
|
+
setPayload,
|
|
7961
|
+
clearData
|
|
7962
|
+
},
|
|
7963
|
+
children
|
|
7964
|
+
}
|
|
7965
|
+
);
|
|
7966
|
+
}
|
|
7967
|
+
|
|
7968
|
+
function WorkflowTrigger({
|
|
7969
|
+
workflowId,
|
|
7970
|
+
baseUrl,
|
|
7971
|
+
setRunId
|
|
7972
|
+
}) {
|
|
7973
|
+
const { result, setResult, payload, setPayload } = useContext(WorkflowRunContext);
|
|
7974
|
+
const { isLoading, workflow } = useWorkflow(workflowId, baseUrl);
|
|
7975
|
+
const { createWorkflowRun } = useExecuteWorkflow(baseUrl);
|
|
7976
|
+
const { watchWorkflow, watchResult, isWatchingWorkflow } = useWatchWorkflow(baseUrl);
|
|
7977
|
+
const { resumeWorkflow, isResumingWorkflow } = useResumeWorkflow(baseUrl);
|
|
7978
|
+
const [suspendedSteps, setSuspendedSteps] = useState([]);
|
|
7979
|
+
const triggerSchema = workflow?.triggerSchema;
|
|
7980
|
+
const handleExecuteWorkflow = async (data) => {
|
|
7981
|
+
if (!workflow) return;
|
|
7982
|
+
setResult(null);
|
|
7983
|
+
const { runId } = await createWorkflowRun({ workflowId, input: data });
|
|
7984
|
+
setRunId?.(runId);
|
|
7985
|
+
watchWorkflow({ workflowId, runId });
|
|
7986
|
+
};
|
|
7987
|
+
const handleResumeWorkflow = async (step) => {
|
|
7988
|
+
if (!workflow) return;
|
|
7989
|
+
const { stepId, runId, context } = step;
|
|
7990
|
+
resumeWorkflow({
|
|
7991
|
+
stepId,
|
|
7992
|
+
runId,
|
|
7993
|
+
context,
|
|
7994
|
+
workflowId
|
|
7995
|
+
});
|
|
7996
|
+
watchWorkflow({ workflowId, runId });
|
|
7997
|
+
};
|
|
7998
|
+
const watchResultToUse = result ?? watchResult;
|
|
7999
|
+
const workflowActivePaths = watchResultToUse?.activePaths ?? [];
|
|
8000
|
+
useEffect(() => {
|
|
8001
|
+
if (!watchResultToUse?.activePaths || !result?.runId) return;
|
|
8002
|
+
const suspended = watchResultToUse.activePaths.filter((path) => watchResultToUse.context?.steps?.[path.stepId]?.status === "suspended").map((path) => ({
|
|
8003
|
+
stepId: path.stepId,
|
|
8004
|
+
runId: result.runId
|
|
8005
|
+
}));
|
|
8006
|
+
setSuspendedSteps(suspended);
|
|
8007
|
+
}, [watchResultToUse, result]);
|
|
8008
|
+
useEffect(() => {
|
|
8009
|
+
if (watchResult) {
|
|
8010
|
+
setResult(watchResult);
|
|
8011
|
+
}
|
|
8012
|
+
}, [watchResult]);
|
|
8013
|
+
if (isLoading) {
|
|
8014
|
+
return /* @__PURE__ */ jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs", children: /* @__PURE__ */ jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[100px_1fr] gap-2", children: [
|
|
8015
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-3" }),
|
|
8016
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-3" })
|
|
8017
|
+
] }) }) });
|
|
8018
|
+
}
|
|
8019
|
+
if (!workflow) return null;
|
|
8020
|
+
if (!triggerSchema) {
|
|
8021
|
+
return /* @__PURE__ */ jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs w-[400px]", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
8022
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-4 px-4", children: /* @__PURE__ */ jsx(Button, { className: "w-full", disabled: isWatchingWorkflow, onClick: () => handleExecuteWorkflow(null), children: isWatchingWorkflow ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : "Trigger" }) }),
|
|
8023
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
8024
|
+
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3 px-4", size: "xs", children: "Output" }),
|
|
8025
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ jsx(
|
|
8026
|
+
CopyButton,
|
|
8027
|
+
{
|
|
8028
|
+
classname: "absolute z-40 top-4 right-4 w-8 h-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity duration-150 ease-in-out",
|
|
8029
|
+
content: JSON.stringify(result ?? {}, null, 2)
|
|
8030
|
+
}
|
|
8031
|
+
) }),
|
|
8032
|
+
/* @__PURE__ */ jsx(
|
|
8033
|
+
CodeBlockDemo,
|
|
8034
|
+
{
|
|
8035
|
+
className: "w-[368px] overflow-x-auto",
|
|
8036
|
+
code: JSON.stringify(result ?? {}, null, 2),
|
|
8037
|
+
language: "json"
|
|
8038
|
+
}
|
|
8039
|
+
)
|
|
8040
|
+
] })
|
|
8041
|
+
] }) });
|
|
8042
|
+
}
|
|
8043
|
+
const zodInputSchema = resolveSerializedZodOutput(jsonSchemaToZod(parse(triggerSchema)));
|
|
8044
|
+
return /* @__PURE__ */ jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs w-[400px]", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
8045
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
8046
|
+
suspendedSteps.length > 0 ? suspendedSteps?.map((step) => /* @__PURE__ */ jsxs("div", { className: "px-4", children: [
|
|
8047
|
+
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: step.stepId }),
|
|
8048
|
+
/* @__PURE__ */ jsx(
|
|
8049
|
+
DynamicForm,
|
|
8050
|
+
{
|
|
8051
|
+
schema: z$1.record(z$1.string(), z$1.any()),
|
|
8052
|
+
isSubmitLoading: isResumingWorkflow,
|
|
8053
|
+
submitButtonLabel: "Resume",
|
|
8054
|
+
onSubmit: (data) => {
|
|
8055
|
+
handleResumeWorkflow({
|
|
8056
|
+
stepId: step.stepId,
|
|
8057
|
+
runId: step.runId,
|
|
8058
|
+
context: data
|
|
8059
|
+
});
|
|
8060
|
+
}
|
|
8061
|
+
}
|
|
8062
|
+
)
|
|
8063
|
+
] })) : /* @__PURE__ */ jsx(Fragment, {}),
|
|
8064
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between w-full", children: [
|
|
8065
|
+
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3 px-4", size: "xs", children: "Input" }),
|
|
8066
|
+
isResumingWorkflow ? /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
|
|
8067
|
+
/* @__PURE__ */ jsx(Loader2, { className: "animate-spin w-3 h-3 text-mastra-el-accent" }),
|
|
8068
|
+
" Resuming workflow"
|
|
8069
|
+
] }) : /* @__PURE__ */ jsx(Fragment, {})
|
|
8070
|
+
] }),
|
|
8071
|
+
/* @__PURE__ */ jsx(
|
|
8072
|
+
DynamicForm,
|
|
8073
|
+
{
|
|
8074
|
+
schema: zodInputSchema,
|
|
8075
|
+
defaultValues: payload,
|
|
8076
|
+
isSubmitLoading: isWatchingWorkflow,
|
|
8077
|
+
onSubmit: (data) => {
|
|
8078
|
+
setPayload(data);
|
|
8079
|
+
handleExecuteWorkflow(data);
|
|
8080
|
+
}
|
|
8081
|
+
}
|
|
8082
|
+
)
|
|
8083
|
+
] }),
|
|
8084
|
+
workflowActivePaths.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
8085
|
+
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3 px-4", size: "xs", children: "Status" }),
|
|
8086
|
+
/* @__PURE__ */ jsx("div", { className: "px-4", children: workflowActivePaths?.map((activePath, idx) => {
|
|
8087
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col mt-2 border overflow-hidden", children: activePath?.stepPath?.map((sp, idx2) => {
|
|
8088
|
+
const status = activePath?.status === "completed" ? "Completed" : sp === activePath?.stepId ? activePath?.status.charAt(0).toUpperCase() + activePath?.status.slice(1) : "Completed";
|
|
8089
|
+
const statusIcon = status === "Completed" ? /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-green-500 rounded-full" }) : /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-yellow-500 animate-pulse rounded-full" });
|
|
8090
|
+
return /* @__PURE__ */ jsxs(
|
|
8091
|
+
"div",
|
|
8092
|
+
{
|
|
8093
|
+
className: `
|
|
8094
|
+
flex items-center justify-between p-3
|
|
8095
|
+
${idx2 !== activePath.stepPath.length - 1 ? "border-b" : ""}
|
|
8096
|
+
bg-white/5
|
|
8097
|
+
`,
|
|
8098
|
+
children: [
|
|
8099
|
+
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: sp.charAt(0).toUpperCase() + sp.slice(1) }),
|
|
8100
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
8101
|
+
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: statusIcon }),
|
|
8102
|
+
status
|
|
8103
|
+
] })
|
|
8104
|
+
]
|
|
8105
|
+
},
|
|
8106
|
+
idx2
|
|
8107
|
+
);
|
|
8108
|
+
}) }, idx);
|
|
8109
|
+
}) })
|
|
8110
|
+
] }),
|
|
8111
|
+
result && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
8112
|
+
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3 px-4", size: "xs", children: "Output" }),
|
|
8113
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ jsx(
|
|
8114
|
+
CopyButton,
|
|
8115
|
+
{
|
|
8116
|
+
classname: "absolute z-40 top-4 right-4 w-8 h-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity duration-150 ease-in-out",
|
|
8117
|
+
content: JSON.stringify(result, null, 2)
|
|
8118
|
+
}
|
|
8119
|
+
) }),
|
|
8120
|
+
/* @__PURE__ */ jsx(
|
|
8121
|
+
CodeBlockDemo,
|
|
8122
|
+
{
|
|
8123
|
+
className: "w-[368px] overflow-x-auto",
|
|
8124
|
+
code: JSON.stringify(result, null, 2),
|
|
8125
|
+
language: "json"
|
|
8126
|
+
}
|
|
8127
|
+
)
|
|
8128
|
+
] })
|
|
8129
|
+
] }) });
|
|
8130
|
+
}
|
|
8131
|
+
|
|
8132
|
+
export { AgentChat, AgentEvals, AgentTraces, AgentsTable, Chat, WorkflowGraph, WorkflowRunContext, WorkflowRunProvider, WorkflowTraces, WorkflowTrigger, WorkflowsTable };
|
|
6480
8133
|
//# sourceMappingURL=index.es.js.map
|