import { ButtonAction } from "@/components/ButtonActionLoader"; import { CodeBlock } from "@/components/CodeBlock"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { ScrollArea } from "@/components/ui/scroll-area"; import { TableCell, TableRow } from "@/components/ui/table"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { getInputsFromWorkflow } from "@/lib/getInputsFromWorkflow"; import { getRelativeTime } from "@/lib/getRelativeTime"; import { removePublicShareDeployment } from "@/server/curdDeploments"; import type { findAllDeployments } from "@/server/findAllRuns"; import { ExternalLink } from "lucide-react"; import { headers } from "next/headers"; import Link from "next/link"; const curlTemplate = ` curl --request POST \ --url \ --header "Content-Type: application/json" \ --data "{ "deployment_id": "" }" `; const curlTemplate_checkStatus = ` curl --request GET \ --url "/api/run?run_id=xxx" \ --header "Content-Type: application/json" `; const jsTemplate = ` const { run_id } = await fetch("", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer " + process.env.COMFY_DEPLOY_API_KEY, }, body: JSON.stringify({ deployment_id: "", inputs: {} }), }).then(response => response.json()) `; const jsTemplate_checkStatus = ` const run_id = ""; const output = fetch("?run_id=" + run_id, { method: "GET", headers: { "Content-Type": "application/json", "Authorization": "Bearer " + process.env.COMFY_DEPLOY_API_KEY, }, }).then(response => response.json()) `; const jsClientSetupTemplate = ` const client = new ComfyDeployClient({ apiBase: "", apiToken: process.env.COMFY_DEPLOY_API_KEY!, }); `; const jsClientSetupTemplateHostedVersion = ` const client = new ComfyDeployClient({ apiToken: process.env.COMFY_DEPLOY_API_KEY!, }); `; const jsClientCreateRunTemplate = ` const { run_id } = await client.run("", { inputs: {} }); `; const jsClientCreateRunNoInputsTemplate = ` const { run_id } = await client.run(""); `; const clientTemplate_checkStatus = ` const run = await client.getRun(run_id); `; export function DeploymentDisplay({ deployment, }: { deployment: Awaited>[0]; }) { const headersList = headers(); const host = headersList.get("host") || ""; const protocol = headersList.get("x-forwarded-proto") || ""; const domain = `${protocol}://${host}`; const workflowInput = getInputsFromWorkflow(deployment.version); return ( {deployment.environment} {deployment.version?.version} {deployment.machine?.name} {getRelativeTime(deployment.updated_at)} {deployment.environment} Deployment Code for your deployment client {deployment.environment !== "public-share" ? ( Server Client NodeJS Fetch CURL
Copy and paste the ComfyDeployClient form  here
Create a run via deployment id 0 ? jsClientCreateRunTemplate : jsClientCreateRunNoInputsTemplate, deployment, domain, workflowInput )} /> Check the status of the run, and retrieve the outputs
Trigger the workflow Check the status of the run, and retrieve the outputs
) : (
)}
); } function formatCode( codeTemplate: string, deployment: Awaited>[0], domain: string, inputs?: ReturnType, inputsTabs?: number ) { if (inputs && inputs.length > 0) { codeTemplate = codeTemplate.replace( "inputs: {}", `inputs: ${JSON.stringify( Object.fromEntries( inputs.map((x) => { return [x?.input_id, ""]; }) ), null, 2 ) .split("\n") .map((line, index) => (index === 0 ? line : ` ${line}`)) // Add two spaces indentation except for the first line .join("\n")}` ); } else { codeTemplate = codeTemplate.replace( ` inputs: {}`, "" ); } return codeTemplate .replace("", `${domain ?? "http://localhost:3000"}/api/run`) .replace("", deployment.id) .replace("", domain ?? "http://localhost:3000"); }