@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>
222 lines (202 loc) • 6.03 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 * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
/**
* The redirect object to edit. The source field is used to match the redirect to modify.
*/
export type Redirect = {
source: string;
destination?: string | undefined;
statusCode?: number | undefined;
permanent?: boolean | undefined;
caseSensitive?: boolean | undefined;
query?: boolean | undefined;
preserveQueryParams?: boolean | undefined;
};
export type EditRedirectRequestBody = {
name?: string | undefined;
/**
* The redirect object to edit. The source field is used to match the redirect to modify.
*/
redirect: Redirect;
/**
* If true, restores the redirect from the latest production version to staging.
*/
restore?: boolean | undefined;
};
export type EditRedirectRequest = {
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?: EditRedirectRequestBody | undefined;
};
export type EditRedirectVersion = {
/**
* The unique identifier for the version.
*/
id: string;
/**
* The key of the version. The key may be duplicated across versions if the contents are the same as a different version.
*/
key: string;
lastModified: number;
createdBy: string;
/**
* Optional name for the version. If not provided, defaults to an ISO timestamp string.
*/
name?: string | undefined;
/**
* Whether this version has not been promoted to production yet and is not serving end users.
*/
isStaging?: boolean | undefined;
/**
* Whether this version is currently live in production.
*/
isLive?: boolean | undefined;
/**
* The number of redirects in this version.
*/
redirectCount?: number | undefined;
/**
* The staging link for previewing redirects in this version.
*/
alias?: string | undefined;
};
export type EditRedirectResponseBody = {
alias: string | null;
version: EditRedirectVersion;
};
/** @internal */
export type Redirect$Outbound = {
source: string;
destination?: string | undefined;
statusCode?: number | undefined;
permanent?: boolean | undefined;
caseSensitive?: boolean | undefined;
query?: boolean | undefined;
preserveQueryParams?: boolean | undefined;
};
/** @internal */
export const Redirect$outboundSchema: z.ZodType<
Redirect$Outbound,
z.ZodTypeDef,
Redirect
> = z.object({
source: z.string(),
destination: z.string().optional(),
statusCode: z.number().optional(),
permanent: z.boolean().optional(),
caseSensitive: z.boolean().optional(),
query: z.boolean().optional(),
preserveQueryParams: z.boolean().optional(),
});
export function redirectToJSON(redirect: Redirect): string {
return JSON.stringify(Redirect$outboundSchema.parse(redirect));
}
/** @internal */
export type EditRedirectRequestBody$Outbound = {
name?: string | undefined;
redirect: Redirect$Outbound;
restore?: boolean | undefined;
};
/** @internal */
export const EditRedirectRequestBody$outboundSchema: z.ZodType<
EditRedirectRequestBody$Outbound,
z.ZodTypeDef,
EditRedirectRequestBody
> = z.object({
name: z.string().optional(),
redirect: z.lazy(() => Redirect$outboundSchema),
restore: z.boolean().optional(),
});
export function editRedirectRequestBodyToJSON(
editRedirectRequestBody: EditRedirectRequestBody,
): string {
return JSON.stringify(
EditRedirectRequestBody$outboundSchema.parse(editRedirectRequestBody),
);
}
/** @internal */
export type EditRedirectRequest$Outbound = {
projectId: string;
teamId?: string | undefined;
slug?: string | undefined;
RequestBody?: EditRedirectRequestBody$Outbound | undefined;
};
/** @internal */
export const EditRedirectRequest$outboundSchema: z.ZodType<
EditRedirectRequest$Outbound,
z.ZodTypeDef,
EditRedirectRequest
> = z.object({
projectId: z.string(),
teamId: z.string().optional(),
slug: z.string().optional(),
requestBody: z.lazy(() => EditRedirectRequestBody$outboundSchema).optional(),
}).transform((v) => {
return remap$(v, {
requestBody: "RequestBody",
});
});
export function editRedirectRequestToJSON(
editRedirectRequest: EditRedirectRequest,
): string {
return JSON.stringify(
EditRedirectRequest$outboundSchema.parse(editRedirectRequest),
);
}
/** @internal */
export const EditRedirectVersion$inboundSchema: z.ZodType<
EditRedirectVersion,
z.ZodTypeDef,
unknown
> = z.object({
id: types.string(),
key: types.string(),
lastModified: types.number(),
createdBy: types.string(),
name: types.optional(types.string()),
isStaging: types.optional(types.boolean()),
isLive: types.optional(types.boolean()),
redirectCount: types.optional(types.number()),
alias: types.optional(types.string()),
});
export function editRedirectVersionFromJSON(
jsonString: string,
): SafeParseResult<EditRedirectVersion, SDKValidationError> {
return safeParse(
jsonString,
(x) => EditRedirectVersion$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'EditRedirectVersion' from JSON`,
);
}
/** @internal */
export const EditRedirectResponseBody$inboundSchema: z.ZodType<
EditRedirectResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
alias: types.nullable(types.string()),
version: z.lazy(() => EditRedirectVersion$inboundSchema),
});
export function editRedirectResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<EditRedirectResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => EditRedirectResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'EditRedirectResponseBody' from JSON`,
);
}