@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>
175 lines (156 loc) • 4.87 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 { Drive, Drive$inboundSchema } from "./drive.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
export type GetOrCreateDriveRequestBody = {
/**
* The project ID or name to associate the drive with. Required unless using a Vercel OIDC token scoped to a project.
*/
projectId?: string | undefined;
/**
* Maximum drive size in bytes. Defaults to 100 GiB when omitted.
*/
maxSizeBytes?: number | undefined;
};
export type GetOrCreateDriveRequest = {
/**
* Name for the drive. Must be unique per project and URL-safe (alphanumeric, hyphens, underscores).
*/
name: 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?: GetOrCreateDriveRequestBody | undefined;
};
export type GetOrCreateDriveSandboxesResponseBody = {
/**
* This object contains information related to a Vercel Sandbox Drive.
*/
drive: Drive;
};
export type GetOrCreateDriveResponseBody = {
/**
* This object contains information related to a Vercel Sandbox Drive.
*/
drive: Drive;
};
export type GetOrCreateDriveResponse =
| GetOrCreateDriveResponseBody
| GetOrCreateDriveSandboxesResponseBody;
/** @internal */
export type GetOrCreateDriveRequestBody$Outbound = {
projectId?: string | undefined;
maxSizeBytes?: number | undefined;
};
/** @internal */
export const GetOrCreateDriveRequestBody$outboundSchema: z.ZodType<
GetOrCreateDriveRequestBody$Outbound,
z.ZodTypeDef,
GetOrCreateDriveRequestBody
> = z.object({
projectId: z.string().optional(),
maxSizeBytes: z.number().int().optional(),
});
export function getOrCreateDriveRequestBodyToJSON(
getOrCreateDriveRequestBody: GetOrCreateDriveRequestBody,
): string {
return JSON.stringify(
GetOrCreateDriveRequestBody$outboundSchema.parse(
getOrCreateDriveRequestBody,
),
);
}
/** @internal */
export type GetOrCreateDriveRequest$Outbound = {
name: string;
teamId?: string | undefined;
slug?: string | undefined;
RequestBody?: GetOrCreateDriveRequestBody$Outbound | undefined;
};
/** @internal */
export const GetOrCreateDriveRequest$outboundSchema: z.ZodType<
GetOrCreateDriveRequest$Outbound,
z.ZodTypeDef,
GetOrCreateDriveRequest
> = z.object({
name: z.string(),
teamId: z.string().optional(),
slug: z.string().optional(),
requestBody: z.lazy(() => GetOrCreateDriveRequestBody$outboundSchema)
.optional(),
}).transform((v) => {
return remap$(v, {
requestBody: "RequestBody",
});
});
export function getOrCreateDriveRequestToJSON(
getOrCreateDriveRequest: GetOrCreateDriveRequest,
): string {
return JSON.stringify(
GetOrCreateDriveRequest$outboundSchema.parse(getOrCreateDriveRequest),
);
}
/** @internal */
export const GetOrCreateDriveSandboxesResponseBody$inboundSchema: z.ZodType<
GetOrCreateDriveSandboxesResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
drive: Drive$inboundSchema,
});
export function getOrCreateDriveSandboxesResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<GetOrCreateDriveSandboxesResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
GetOrCreateDriveSandboxesResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetOrCreateDriveSandboxesResponseBody' from JSON`,
);
}
/** @internal */
export const GetOrCreateDriveResponseBody$inboundSchema: z.ZodType<
GetOrCreateDriveResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
drive: Drive$inboundSchema,
});
export function getOrCreateDriveResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<GetOrCreateDriveResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetOrCreateDriveResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetOrCreateDriveResponseBody' from JSON`,
);
}
/** @internal */
export const GetOrCreateDriveResponse$inboundSchema: z.ZodType<
GetOrCreateDriveResponse,
z.ZodTypeDef,
unknown
> = smartUnion([
z.lazy(() => GetOrCreateDriveResponseBody$inboundSchema),
z.lazy(() => GetOrCreateDriveSandboxesResponseBody$inboundSchema),
]);
export function getOrCreateDriveResponseFromJSON(
jsonString: string,
): SafeParseResult<GetOrCreateDriveResponse, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetOrCreateDriveResponse$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetOrCreateDriveResponse' from JSON`,
);
}