@vercel/sdk
Version:
<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>
113 lines (102 loc) • 3.07 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import { safeParse } from "../lib/schemas.js";
import { ClosedEnum } from "../types/enums.js";
import { Result as SafeParseResult } from "../types/fp.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
import {
SessionCommand,
SessionCommand$inboundSchema,
} from "./sessioncommand.js";
/**
* If set to "true", the request will block until the command finishes execution. Useful for synchronously waiting for command completion.
*/
export const Wait = {
True: "true",
False: "false",
} as const;
/**
* If set to "true", the request will block until the command finishes execution. Useful for synchronously waiting for command completion.
*/
export type Wait = ClosedEnum<typeof Wait>;
export type GetSessionCommandRequest = {
/**
* The unique identifier of the session containing the command.
*/
sessionId: string;
/**
* The unique identifier of the command to retrieve.
*/
cmdId: string;
/**
* If set to "true", the request will block until the command finishes execution. Useful for synchronously waiting for command completion.
*/
wait?: Wait | undefined;
/**
* The Team identifier to perform the request on behalf of.
*/
teamId?: string | undefined;
/**
* The Team slug to perform the request on behalf of.
*/
slug?: string | undefined;
};
/**
* The command data along with the exit code if the command did finish.
*/
export type GetSessionCommandResponseBody = {
/**
* This object represents a command run in a Vercel Sandbox session (v2 API).
*/
command: SessionCommand;
};
/** @internal */
export const Wait$outboundSchema: z.ZodNativeEnum<typeof Wait> = z.nativeEnum(
Wait,
);
/** @internal */
export type GetSessionCommandRequest$Outbound = {
sessionId: string;
cmdId: string;
wait: string;
teamId?: string | undefined;
slug?: string | undefined;
};
/** @internal */
export const GetSessionCommandRequest$outboundSchema: z.ZodType<
GetSessionCommandRequest$Outbound,
z.ZodTypeDef,
GetSessionCommandRequest
> = z.object({
sessionId: z.string(),
cmdId: z.string(),
wait: Wait$outboundSchema.default("false"),
teamId: z.string().optional(),
slug: z.string().optional(),
});
export function getSessionCommandRequestToJSON(
getSessionCommandRequest: GetSessionCommandRequest,
): string {
return JSON.stringify(
GetSessionCommandRequest$outboundSchema.parse(getSessionCommandRequest),
);
}
/** @internal */
export const GetSessionCommandResponseBody$inboundSchema: z.ZodType<
GetSessionCommandResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
command: SessionCommand$inboundSchema,
});
export function getSessionCommandResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<GetSessionCommandResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetSessionCommandResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetSessionCommandResponseBody' from JSON`,
);
}