@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>
86 lines (77 loc) • 2.21 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 { Result as SafeParseResult } from "../types/fp.js";
import {
SandboxPublicRoute,
SandboxPublicRoute$inboundSchema,
} from "./sandboxpublicroute.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
import { Session, Session$inboundSchema } from "./session.js";
export type GetSessionRequest = {
/**
* The unique identifier of the session to retrieve.
*/
sessionId: string;
/**
* 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 session was retrieved successfully.
*/
export type GetSessionResponseBody = {
/**
* This object contains information related to a Vercel Sandbox Session. v2 endpoints return "session" instead of "sandbox" as the response wrapper key.
*/
session: Session;
routes: Array<SandboxPublicRoute>;
};
/** @internal */
export type GetSessionRequest$Outbound = {
sessionId: string;
teamId?: string | undefined;
slug?: string | undefined;
};
/** @internal */
export const GetSessionRequest$outboundSchema: z.ZodType<
GetSessionRequest$Outbound,
z.ZodTypeDef,
GetSessionRequest
> = z.object({
sessionId: z.string(),
teamId: z.string().optional(),
slug: z.string().optional(),
});
export function getSessionRequestToJSON(
getSessionRequest: GetSessionRequest,
): string {
return JSON.stringify(
GetSessionRequest$outboundSchema.parse(getSessionRequest),
);
}
/** @internal */
export const GetSessionResponseBody$inboundSchema: z.ZodType<
GetSessionResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
session: Session$inboundSchema,
routes: z.array(SandboxPublicRoute$inboundSchema),
});
export function getSessionResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<GetSessionResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetSessionResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetSessionResponseBody' from JSON`,
);
}