MCPcopy Index your code
hub / github.com/TanStack/ai / createFixture

Function createFixture

packages/ai-devtools/src/components/hooks/ToolFixtureForm.tsx:52–82  ·  view source on GitHub ↗
(name?: string)

Source from the content-addressed store, hash-verified

50 }
51
52 const createFixture = (name?: string): ToolFixtureRecord | undefined => {
53 try {
54 setError(null)
55 const createdAt = Date.now()
56 const parsedInput =
57 fields().length > 0
58 ? parseObjectInput(fields(), inputValues())
59 : parseJson(rawInput(), 'Input')
60 const parsedOutput = parseJson(output(), 'Output')
61 return {
62 id: `fixture:${props.hook.id}:${props.tool.name}:${createdAt}:${Math.random()
63 .toString(36)
64 .slice(2)}`,
65 createdAt,
66 ...(name ? { name } : {}),
67 hookId: props.hook.id,
68 ...(props.hook.threadId ? { threadId: props.hook.threadId } : {}),
69 toolName: props.tool.name,
70 input: parsedInput,
71 output: parsedOutput,
72 execute: true,
73 }
74 } catch (fixtureError) {
75 setError(
76 fixtureError instanceof Error
77 ? fixtureError.message
78 : 'Unable to create fixture.',
79 )
80 return undefined
81 }
82 }
83
84 const handleFire = () => {
85 const fixture = createFixture()

Callers 2

handleFireFunction · 0.85
handleConfirmSaveFunction · 0.85

Calls 5

parseObjectInputFunction · 0.85
parseJsonFunction · 0.85
outputFunction · 0.85
nowMethod · 0.80
toStringMethod · 0.80

Tested by

no test coverage detected