Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/lib/api/schema/latex.ts
Views: 687
import { z } from "../framework";12import { DEFAULT_LATEX_COMMAND } from "../latex";34import { FailedAPIOperationSchema } from "./common";56// OpenAPI spec7//8export const LatexInputSchema = z9.object({10path: z11.string()12.describe(13`Path to a .tex file. If the file doesn't exist, it is created with the14given content. Also, if the directory containing path doesn't exist, it15is created. If the path starts with \`/tmp\` (e.g.,16\`/tmp/foo/bar.tex\`), then we do always do \`rm /tmp/foo/bar.*\` to17clean up temporary files. We do _not_ do this unless the path starts18with \`/tmp\`.`,19),20content: z21.string()22.optional()23.describe(24`Textual content of the .tex file on which you want to run LaTeX. If25not given, path must refer to an actual file already in the project.26Then the path \`.tex\` file is created and this content written to it.`,27),28project_id: z29.string()30.uuid()31.optional()32.describe(33`The v4 uuid of a project you have access to. If not given, your most34recent project is used, or if you have no projects, one is created. The35project is started if it isn't already running. **WARNING:** if the36project isn't running you may get an error while it is starting; if you37retry in a few seconds then it works.`,38),39command: z40.string()41.optional()42.describe(43`LaTeX build command. This will be run from the directory containing44path and should produce the output pdf file. If not given, we use45\`${DEFAULT_LATEX_COMMAND} filename.tex\`.`,46),47timeout: z48.number()49.gte(5)50.default(30)51.describe(52`If given, this is a timeout in seconds for how long the LaTeX build53command can run before it is killed. You should increase this from the54default if you're building large documents. See also the55\`only_read_pdf\` option.`,56),57ttl: z58.number()59.gte(60)60.describe("Time in seconds for which generated PDF url is valid.")61.default(3600),62only_read_pdf: z63.boolean()64.optional()65.describe( `Instead of running LaTeX, we **only** try to grab the output pdf if it66exists. Currently, you must also specify the \`project_id\` if you use67this option, since we haven't implemented a way to know in which project68the latex command was run. When true, \`only_read_pdf\` is the same as69when it is false, except only the step involving reading the pdf70happens. Use this if compiling times out for some reason due to network71timeout requirements. **NOTE:** \`only_read_pdf\` doesn't currently72get the compilation output log.`,73),74})75.describe(76`Turn LaTeX .tex file contents into a pdf. This run in a CoCalc project77with a configurable timeout and command, so can involve arbitrarily78sophisticated processing.`,79)8081export const LatexOutputSchema = z.union([82FailedAPIOperationSchema,83z.object({84compile: z.object({85stdout: z.string(),86stderr: z.string(),87exit_code: z.number(),88}),89url: z90.string()91.describe("URL where you can view the generated PDF file"),92pdf: z93.string()94.describe(95`Information about reading the PDF from disk, e.g., an error if the PDF96does not exist.`,97),98}),99]);100101export type LatexInput = z.infer<typeof LatexInputSchema>;102export type LatexOutput = z.infer<typeof LatexOutputSchema>;103104105