@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>
193 lines (175 loc) • 5.11 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 { ClosedEnum } from "../types/enums.js";
import { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
export const UpdateRouteVersionsAction = {
Promote: "promote",
Restore: "restore",
Discard: "discard",
} as const;
export type UpdateRouteVersionsAction = ClosedEnum<
typeof UpdateRouteVersionsAction
>;
export type UpdateRouteVersionsRequestBody = {
id: string;
action: UpdateRouteVersionsAction;
};
export type UpdateRouteVersionsRequest = {
projectId: 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?: UpdateRouteVersionsRequestBody | undefined;
};
/**
* A version of routing rules stored in S3.
*/
export type UpdateRouteVersionsVersion = {
/**
* Unique identifier for the version.
*/
id: string;
/**
* The S3 key where the routing rules are stored.
*/
s3Key: string;
/**
* Timestamp of when this version was last modified.
*/
lastModified: number;
/**
* The user who created this version.
*/
createdBy: string;
/**
* Whether this version is staged and not yet promoted to production.
*/
isStaging?: boolean | undefined;
/**
* Whether this version is currently live in production.
*/
isLive?: boolean | undefined;
/**
* The number of routing rules in this version.
*/
ruleCount?: number | undefined;
/**
* The staging alias for previewing this version.
*/
alias?: string | undefined;
};
export type UpdateRouteVersionsResponseBody = {
/**
* A version of routing rules stored in S3.
*/
version: UpdateRouteVersionsVersion;
};
/** @internal */
export const UpdateRouteVersionsAction$outboundSchema: z.ZodNativeEnum<
typeof UpdateRouteVersionsAction
> = z.nativeEnum(UpdateRouteVersionsAction);
/** @internal */
export type UpdateRouteVersionsRequestBody$Outbound = {
id: string;
action: string;
};
/** @internal */
export const UpdateRouteVersionsRequestBody$outboundSchema: z.ZodType<
UpdateRouteVersionsRequestBody$Outbound,
z.ZodTypeDef,
UpdateRouteVersionsRequestBody
> = z.object({
id: z.string(),
action: UpdateRouteVersionsAction$outboundSchema,
});
export function updateRouteVersionsRequestBodyToJSON(
updateRouteVersionsRequestBody: UpdateRouteVersionsRequestBody,
): string {
return JSON.stringify(
UpdateRouteVersionsRequestBody$outboundSchema.parse(
updateRouteVersionsRequestBody,
),
);
}
/** @internal */
export type UpdateRouteVersionsRequest$Outbound = {
projectId: string;
teamId?: string | undefined;
slug?: string | undefined;
RequestBody?: UpdateRouteVersionsRequestBody$Outbound | undefined;
};
/** @internal */
export const UpdateRouteVersionsRequest$outboundSchema: z.ZodType<
UpdateRouteVersionsRequest$Outbound,
z.ZodTypeDef,
UpdateRouteVersionsRequest
> = z.object({
projectId: z.string(),
teamId: z.string().optional(),
slug: z.string().optional(),
requestBody: z.lazy(() => UpdateRouteVersionsRequestBody$outboundSchema)
.optional(),
}).transform((v) => {
return remap$(v, {
requestBody: "RequestBody",
});
});
export function updateRouteVersionsRequestToJSON(
updateRouteVersionsRequest: UpdateRouteVersionsRequest,
): string {
return JSON.stringify(
UpdateRouteVersionsRequest$outboundSchema.parse(updateRouteVersionsRequest),
);
}
/** @internal */
export const UpdateRouteVersionsVersion$inboundSchema: z.ZodType<
UpdateRouteVersionsVersion,
z.ZodTypeDef,
unknown
> = z.object({
id: types.string(),
s3Key: types.string(),
lastModified: types.number(),
createdBy: types.string(),
isStaging: types.optional(types.boolean()),
isLive: types.optional(types.boolean()),
ruleCount: types.optional(types.number()),
alias: types.optional(types.string()),
});
export function updateRouteVersionsVersionFromJSON(
jsonString: string,
): SafeParseResult<UpdateRouteVersionsVersion, SDKValidationError> {
return safeParse(
jsonString,
(x) => UpdateRouteVersionsVersion$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'UpdateRouteVersionsVersion' from JSON`,
);
}
/** @internal */
export const UpdateRouteVersionsResponseBody$inboundSchema: z.ZodType<
UpdateRouteVersionsResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
version: z.lazy(() => UpdateRouteVersionsVersion$inboundSchema),
});
export function updateRouteVersionsResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<UpdateRouteVersionsResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => UpdateRouteVersionsResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'UpdateRouteVersionsResponseBody' from JSON`,
);
}