@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>
151 lines (134 loc) • 4.47 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import { remap as remap$ } from "../lib/primitives.js";
import { safeParse } from "../lib/schemas.js";
import { Result as SafeParseResult } from "../types/fp.js";
import { smartUnion } from "../types/smartUnion.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
import { Session, Session$inboundSchema } from "./session.js";
import { Snapshot, Snapshot$inboundSchema } from "./snapshot.js";
/**
* The number of milliseconds after which the snapshot will expire and be deleted. Use 0 for no expiration.
*/
export type CreateSessionSnapshotExpiration = any | number;
export type CreateSessionSnapshotRequestBody = {
/**
* The number of milliseconds after which the snapshot will expire and be deleted. Use 0 for no expiration.
*/
expiration?: any | number | undefined;
};
export type CreateSessionSnapshotRequest = {
/**
* The unique identifier of the session to snapshot.
*/
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;
requestBody?: CreateSessionSnapshotRequestBody | undefined;
};
export type CreateSessionSnapshotResponseBody = {
/**
* This object contains information related to a Snapshot of a Vercel Sandbox session (v2 API).
*/
snapshot: Snapshot;
/**
* This object contains information related to a Vercel Sandbox Session. v2 endpoints return "session" instead of "sandbox" as the response wrapper key.
*/
session: Session;
};
/** @internal */
export type CreateSessionSnapshotExpiration$Outbound = any | number;
/** @internal */
export const CreateSessionSnapshotExpiration$outboundSchema: z.ZodType<
CreateSessionSnapshotExpiration$Outbound,
z.ZodTypeDef,
CreateSessionSnapshotExpiration
> = smartUnion([z.any(), z.number().int()]);
export function createSessionSnapshotExpirationToJSON(
createSessionSnapshotExpiration: CreateSessionSnapshotExpiration,
): string {
return JSON.stringify(
CreateSessionSnapshotExpiration$outboundSchema.parse(
createSessionSnapshotExpiration,
),
);
}
/** @internal */
export type CreateSessionSnapshotRequestBody$Outbound = {
expiration?: any | number | undefined;
};
/** @internal */
export const CreateSessionSnapshotRequestBody$outboundSchema: z.ZodType<
CreateSessionSnapshotRequestBody$Outbound,
z.ZodTypeDef,
CreateSessionSnapshotRequestBody
> = z.object({
expiration: smartUnion([z.any(), z.number().int()]).optional(),
});
export function createSessionSnapshotRequestBodyToJSON(
createSessionSnapshotRequestBody: CreateSessionSnapshotRequestBody,
): string {
return JSON.stringify(
CreateSessionSnapshotRequestBody$outboundSchema.parse(
createSessionSnapshotRequestBody,
),
);
}
/** @internal */
export type CreateSessionSnapshotRequest$Outbound = {
sessionId: string;
teamId?: string | undefined;
slug?: string | undefined;
RequestBody?: CreateSessionSnapshotRequestBody$Outbound | undefined;
};
/** @internal */
export const CreateSessionSnapshotRequest$outboundSchema: z.ZodType<
CreateSessionSnapshotRequest$Outbound,
z.ZodTypeDef,
CreateSessionSnapshotRequest
> = z.object({
sessionId: z.string(),
teamId: z.string().optional(),
slug: z.string().optional(),
requestBody: z.lazy(() => CreateSessionSnapshotRequestBody$outboundSchema)
.optional(),
}).transform((v) => {
return remap$(v, {
requestBody: "RequestBody",
});
});
export function createSessionSnapshotRequestToJSON(
createSessionSnapshotRequest: CreateSessionSnapshotRequest,
): string {
return JSON.stringify(
CreateSessionSnapshotRequest$outboundSchema.parse(
createSessionSnapshotRequest,
),
);
}
/** @internal */
export const CreateSessionSnapshotResponseBody$inboundSchema: z.ZodType<
CreateSessionSnapshotResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
snapshot: Snapshot$inboundSchema,
session: Session$inboundSchema,
});
export function createSessionSnapshotResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<CreateSessionSnapshotResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => CreateSessionSnapshotResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CreateSessionSnapshotResponseBody' from JSON`,
);
}