import { BookOpenIcon } from "@heroicons/react/20/solid"; import { CodeBlock } from "~/components/code/CodeBlock"; import { LinkButton } from "~/components/primitives/Buttons"; import { Header3 } from "~/components/primitives/Headers"; import { Paragraph } from "~/components/primitives/Paragraph"; import { TextLink } from "~/components/primitives/TextLink"; import { docsPath } from "~/utils/pathBuilder"; export function SchemaTabContent({ schema, inferredSchema, title = "Payload schema", description, showDocsLink = true, }: { schema?: unknown; inferredSchema?: unknown; title?: string; description?: string; showDocsLink?: boolean; }) { if (schema) { return (
{title} {showDocsLink ? ( {description ?? ( <> JSON Schema defined by this task via{" "} schemaTask. )} ) : description ? ( {description} ) : null}
); } if (inferredSchema) { return (
Inferred schema Schema inferred from recent run payloads. For an exact schema, use schemaTask. schemaTask docs
); } return (
No schema defined Use schemaTask to define a payload schema for this task. The schema will appear here and can be used by AI to generate example payloads. schemaTask docs
); } const exampleCode = `import { schemaTask } from "@trigger.dev/sdk"; import { z } from "zod"; export const myTask = schemaTask({ id: "my-task", schema: z.object({ name: z.string(), email: z.string().email(), count: z.number().int().positive(), }), run: async (payload) => { // payload is fully typed console.log(payload.name); }, });`;