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/user-query.ts
Views: 687
import { z } from "../framework";12import { FailedAPIOperationSchema } from "./common";3import { AccountIdSchema } from "./accounts/common";4import { ProjectIdSchema } from "./projects/common";56const ExampleUserQuerySchema = z.object({7accounts: z8.object({9account_id: AccountIdSchema.nullable(),10email_address: z.string().nullable(),11})12.describe(13`Used to query for the account id and e-mail address of the account corresponding to14the API key provided in this request.`,15),16});1718const ExampleDirectoryListingSchema = z.object({19listings: z20.object({21project_id: ProjectIdSchema,22path: z23.string()24.nullable()25.describe("Path relative to user's `$HOME` directory."),26listing: z27.union([28z.null(),29z.array(30z.object({31name: z.string().describe("File name."),32size: z.number().min(0).describe("File size."),33mtime: z34.number()35.describe("Time at which the file was last modified."),36}),37),38])39.describe(40"This field should be `null` when querying for a list of files.",41),42})43.describe(44"Object containing project id and file path for which to list files.",45),46});4748const GenericUserQuerySchema = z.any();4950// OpenAPI spec51//52export const UserQueryInputSchema = z53.object({54query: z.union([55ExampleUserQuerySchema,56ExampleDirectoryListingSchema,57GenericUserQuerySchema.describe(58`Many other generic queries are supported; you can learn more about this endpoint59by viewing the corresponding CoCalc source code at60https://github.com/sagemathinc/cocalc/blob/master/src/packages/next/pages/api/v2/user-query.ts.`,61),62]),63})64.describe(65`Used to fetch or set data corresponding to a particular account. Generally speaking,66when \`null\` values are provided for a specific field, this endpoint acts as a67getter; otherwise, it acts as a setter for the provided fields.`,68);6970export const UserQueryOutputSchema = z.union([71FailedAPIOperationSchema,72z.object({73query: z.union([74ExampleUserQuerySchema.describe(75`An example response for an e-mail address and account id query.`,76),77ExampleDirectoryListingSchema.describe(78"An example response for a directory listing query.",79),80GenericUserQuerySchema.describe(81`Generally, the object returned from this request mimics the structure of the82input query with fields populated as applicable. For more information on this83request, check out the corresponding CoCalc source code at84https://github.com/sagemathinc/cocalc/blob/master/src/packages/next/pages/api/v2/user-query.ts.`,85),86]),87}),88]);8990export type UserQueryInput = z.infer<typeof UserQueryInputSchema>;91export type UserQueryOutput = z.infer<typeof UserQueryOutputSchema>;929394