@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>
200 lines (180 loc) • 5.84 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 * as types from "../types/primitives.js";
import { smartUnion } from "../types/smartUnion.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
import { Snapshot, Snapshot$inboundSchema } from "./snapshot.js";
/**
* Sort direction for results by creation time.
*/
export const ListSessionSnapshotsQueryParamSortOrder = {
Asc: "asc",
Desc: "desc",
} as const;
/**
* Sort direction for results by creation time.
*/
export type ListSessionSnapshotsQueryParamSortOrder = ClosedEnum<
typeof ListSessionSnapshotsQueryParamSortOrder
>;
export type ListSessionSnapshotsRequest = {
/**
* The unique identifier or name of the project to list snapshots for.
*/
project?: string | undefined;
/**
* Name for the sandbox. Must be unique per project and URL-safe (alphanumeric, hyphens, underscores).
*/
name?: string | undefined;
/**
* Maximum number of snapshots to return in the response. Used for pagination.
*/
limit?: number | undefined;
/**
* Opaque pagination cursor from a previous response.
*/
cursor?: string | undefined;
/**
* Sort direction for results by creation time.
*/
sortOrder?: ListSessionSnapshotsQueryParamSortOrder | 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;
};
export type ListSessionSnapshotsResponseBodyPagination = {
count: number;
next: string | null;
};
export type ListSessionSnapshotsResponseBody2 = {
snapshots: Array<Snapshot>;
pagination: ListSessionSnapshotsResponseBodyPagination;
};
export type ListSessionSnapshotsResponseBody1 = {};
export type ListSessionSnapshotsResponseBody =
| ListSessionSnapshotsResponseBody2
| ListSessionSnapshotsResponseBody1;
/** @internal */
export const ListSessionSnapshotsQueryParamSortOrder$outboundSchema:
z.ZodNativeEnum<typeof ListSessionSnapshotsQueryParamSortOrder> = z
.nativeEnum(ListSessionSnapshotsQueryParamSortOrder);
/** @internal */
export type ListSessionSnapshotsRequest$Outbound = {
project?: string | undefined;
name?: string | undefined;
limit: number;
cursor?: string | undefined;
sortOrder: string;
teamId?: string | undefined;
slug?: string | undefined;
};
/** @internal */
export const ListSessionSnapshotsRequest$outboundSchema: z.ZodType<
ListSessionSnapshotsRequest$Outbound,
z.ZodTypeDef,
ListSessionSnapshotsRequest
> = z.object({
project: z.string().optional(),
name: z.string().optional(),
limit: z.number().default(20),
cursor: z.string().optional(),
sortOrder: ListSessionSnapshotsQueryParamSortOrder$outboundSchema.default(
"desc",
),
teamId: z.string().optional(),
slug: z.string().optional(),
});
export function listSessionSnapshotsRequestToJSON(
listSessionSnapshotsRequest: ListSessionSnapshotsRequest,
): string {
return JSON.stringify(
ListSessionSnapshotsRequest$outboundSchema.parse(
listSessionSnapshotsRequest,
),
);
}
/** @internal */
export const ListSessionSnapshotsResponseBodyPagination$inboundSchema:
z.ZodType<ListSessionSnapshotsResponseBodyPagination, z.ZodTypeDef, unknown> =
z.object({
count: types.number(),
next: types.nullable(types.string()),
});
export function listSessionSnapshotsResponseBodyPaginationFromJSON(
jsonString: string,
): SafeParseResult<
ListSessionSnapshotsResponseBodyPagination,
SDKValidationError
> {
return safeParse(
jsonString,
(x) =>
ListSessionSnapshotsResponseBodyPagination$inboundSchema.parse(
JSON.parse(x),
),
`Failed to parse 'ListSessionSnapshotsResponseBodyPagination' from JSON`,
);
}
/** @internal */
export const ListSessionSnapshotsResponseBody2$inboundSchema: z.ZodType<
ListSessionSnapshotsResponseBody2,
z.ZodTypeDef,
unknown
> = z.object({
snapshots: z.array(Snapshot$inboundSchema),
pagination: z.lazy(() =>
ListSessionSnapshotsResponseBodyPagination$inboundSchema
),
});
export function listSessionSnapshotsResponseBody2FromJSON(
jsonString: string,
): SafeParseResult<ListSessionSnapshotsResponseBody2, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListSessionSnapshotsResponseBody2$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListSessionSnapshotsResponseBody2' from JSON`,
);
}
/** @internal */
export const ListSessionSnapshotsResponseBody1$inboundSchema: z.ZodType<
ListSessionSnapshotsResponseBody1,
z.ZodTypeDef,
unknown
> = z.object({});
export function listSessionSnapshotsResponseBody1FromJSON(
jsonString: string,
): SafeParseResult<ListSessionSnapshotsResponseBody1, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListSessionSnapshotsResponseBody1$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListSessionSnapshotsResponseBody1' from JSON`,
);
}
/** @internal */
export const ListSessionSnapshotsResponseBody$inboundSchema: z.ZodType<
ListSessionSnapshotsResponseBody,
z.ZodTypeDef,
unknown
> = smartUnion([
z.lazy(() => ListSessionSnapshotsResponseBody2$inboundSchema),
z.lazy(() => ListSessionSnapshotsResponseBody1$inboundSchema),
]);
export function listSessionSnapshotsResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<ListSessionSnapshotsResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => ListSessionSnapshotsResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ListSessionSnapshotsResponseBody' from JSON`,
);
}