UNPKG

@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>

391 lines (347 loc) 10.6 kB
/* * 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 type GetCheckRequest = { /** * The deployment to get the check for. */ deploymentId: string; /** * The check to fetch */ checkId: 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; }; export const GetCheckStatus = { Completed: "completed", Registered: "registered", Running: "running", } as const; export type GetCheckStatus = ClosedEnum<typeof GetCheckStatus>; export const GetCheckConclusion = { Canceled: "canceled", Failed: "failed", Neutral: "neutral", Skipped: "skipped", Stale: "stale", Succeeded: "succeeded", } as const; export type GetCheckConclusion = ClosedEnum<typeof GetCheckConclusion>; export const GetCheckSource = { WebVitals: "web-vitals", } as const; export type GetCheckSource = ClosedEnum<typeof GetCheckSource>; export type GetCheckFCP = { value: number | null; previousValue?: number | undefined; source: GetCheckSource; }; export const GetCheckChecksSource = { WebVitals: "web-vitals", } as const; export type GetCheckChecksSource = ClosedEnum<typeof GetCheckChecksSource>; export type GetCheckLCP = { value: number | null; previousValue?: number | undefined; source: GetCheckChecksSource; }; export const GetCheckChecksResponseSource = { WebVitals: "web-vitals", } as const; export type GetCheckChecksResponseSource = ClosedEnum< typeof GetCheckChecksResponseSource >; export type GetCheckCLS = { value: number | null; previousValue?: number | undefined; source: GetCheckChecksResponseSource; }; export const GetCheckChecksResponse200Source = { WebVitals: "web-vitals", } as const; export type GetCheckChecksResponse200Source = ClosedEnum< typeof GetCheckChecksResponse200Source >; export type GetCheckTBT = { value: number | null; previousValue?: number | undefined; source: GetCheckChecksResponse200Source; }; export const GetCheckChecksResponse200ApplicationJSONSource = { WebVitals: "web-vitals", } as const; export type GetCheckChecksResponse200ApplicationJSONSource = ClosedEnum< typeof GetCheckChecksResponse200ApplicationJSONSource >; export type GetCheckVirtualExperienceScore = { value: number | null; previousValue?: number | undefined; source: GetCheckChecksResponse200ApplicationJSONSource; }; export type GetCheckMetrics = { fcp: GetCheckFCP; lcp: GetCheckLCP; cls: GetCheckCLS; tbt: GetCheckTBT; virtualExperienceScore?: GetCheckVirtualExperienceScore | undefined; }; export type GetCheckOutput = { metrics?: GetCheckMetrics | undefined; }; export type GetCheckResponseBody = { id: string; name: string; createdAt: number; updatedAt: number; deploymentId: string; status: GetCheckStatus; conclusion?: GetCheckConclusion | undefined; externalId?: string | undefined; output?: GetCheckOutput | undefined; completedAt?: number | undefined; path?: string | undefined; blocking: boolean; detailsUrl?: string | undefined; integrationId: string; startedAt?: number | undefined; rerequestable?: boolean | undefined; }; /** @internal */ export type GetCheckRequest$Outbound = { deploymentId: string; checkId: string; teamId?: string | undefined; slug?: string | undefined; }; /** @internal */ export const GetCheckRequest$outboundSchema: z.ZodType< GetCheckRequest$Outbound, z.ZodTypeDef, GetCheckRequest > = z.object({ deploymentId: z.string(), checkId: z.string(), teamId: z.string().optional(), slug: z.string().optional(), }); export function getCheckRequestToJSON( getCheckRequest: GetCheckRequest, ): string { return JSON.stringify(GetCheckRequest$outboundSchema.parse(getCheckRequest)); } /** @internal */ export const GetCheckStatus$inboundSchema: z.ZodNativeEnum< typeof GetCheckStatus > = z.nativeEnum(GetCheckStatus); /** @internal */ export const GetCheckConclusion$inboundSchema: z.ZodNativeEnum< typeof GetCheckConclusion > = z.nativeEnum(GetCheckConclusion); /** @internal */ export const GetCheckSource$inboundSchema: z.ZodNativeEnum< typeof GetCheckSource > = z.nativeEnum(GetCheckSource); /** @internal */ export const GetCheckFCP$inboundSchema: z.ZodType< GetCheckFCP, z.ZodTypeDef, unknown > = z.object({ value: types.nullable(types.number()), previousValue: types.optional(types.number()), source: GetCheckSource$inboundSchema, }); export function getCheckFCPFromJSON( jsonString: string, ): SafeParseResult<GetCheckFCP, SDKValidationError> { return safeParse( jsonString, (x) => GetCheckFCP$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetCheckFCP' from JSON`, ); } /** @internal */ export const GetCheckChecksSource$inboundSchema: z.ZodNativeEnum< typeof GetCheckChecksSource > = z.nativeEnum(GetCheckChecksSource); /** @internal */ export const GetCheckLCP$inboundSchema: z.ZodType< GetCheckLCP, z.ZodTypeDef, unknown > = z.object({ value: types.nullable(types.number()), previousValue: types.optional(types.number()), source: GetCheckChecksSource$inboundSchema, }); export function getCheckLCPFromJSON( jsonString: string, ): SafeParseResult<GetCheckLCP, SDKValidationError> { return safeParse( jsonString, (x) => GetCheckLCP$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetCheckLCP' from JSON`, ); } /** @internal */ export const GetCheckChecksResponseSource$inboundSchema: z.ZodNativeEnum< typeof GetCheckChecksResponseSource > = z.nativeEnum(GetCheckChecksResponseSource); /** @internal */ export const GetCheckCLS$inboundSchema: z.ZodType< GetCheckCLS, z.ZodTypeDef, unknown > = z.object({ value: types.nullable(types.number()), previousValue: types.optional(types.number()), source: GetCheckChecksResponseSource$inboundSchema, }); export function getCheckCLSFromJSON( jsonString: string, ): SafeParseResult<GetCheckCLS, SDKValidationError> { return safeParse( jsonString, (x) => GetCheckCLS$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetCheckCLS' from JSON`, ); } /** @internal */ export const GetCheckChecksResponse200Source$inboundSchema: z.ZodNativeEnum< typeof GetCheckChecksResponse200Source > = z.nativeEnum(GetCheckChecksResponse200Source); /** @internal */ export const GetCheckTBT$inboundSchema: z.ZodType< GetCheckTBT, z.ZodTypeDef, unknown > = z.object({ value: types.nullable(types.number()), previousValue: types.optional(types.number()), source: GetCheckChecksResponse200Source$inboundSchema, }); export function getCheckTBTFromJSON( jsonString: string, ): SafeParseResult<GetCheckTBT, SDKValidationError> { return safeParse( jsonString, (x) => GetCheckTBT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetCheckTBT' from JSON`, ); } /** @internal */ export const GetCheckChecksResponse200ApplicationJSONSource$inboundSchema: z.ZodNativeEnum<typeof GetCheckChecksResponse200ApplicationJSONSource> = z .nativeEnum(GetCheckChecksResponse200ApplicationJSONSource); /** @internal */ export const GetCheckVirtualExperienceScore$inboundSchema: z.ZodType< GetCheckVirtualExperienceScore, z.ZodTypeDef, unknown > = z.object({ value: types.nullable(types.number()), previousValue: types.optional(types.number()), source: GetCheckChecksResponse200ApplicationJSONSource$inboundSchema, }); export function getCheckVirtualExperienceScoreFromJSON( jsonString: string, ): SafeParseResult<GetCheckVirtualExperienceScore, SDKValidationError> { return safeParse( jsonString, (x) => GetCheckVirtualExperienceScore$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetCheckVirtualExperienceScore' from JSON`, ); } /** @internal */ export const GetCheckMetrics$inboundSchema: z.ZodType< GetCheckMetrics, z.ZodTypeDef, unknown > = z.object({ FCP: z.lazy(() => GetCheckFCP$inboundSchema), LCP: z.lazy(() => GetCheckLCP$inboundSchema), CLS: z.lazy(() => GetCheckCLS$inboundSchema), TBT: z.lazy(() => GetCheckTBT$inboundSchema), virtualExperienceScore: types.optional( z.lazy(() => GetCheckVirtualExperienceScore$inboundSchema), ), }).transform((v) => { return remap$(v, { "FCP": "fcp", "LCP": "lcp", "CLS": "cls", "TBT": "tbt", }); }); export function getCheckMetricsFromJSON( jsonString: string, ): SafeParseResult<GetCheckMetrics, SDKValidationError> { return safeParse( jsonString, (x) => GetCheckMetrics$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetCheckMetrics' from JSON`, ); } /** @internal */ export const GetCheckOutput$inboundSchema: z.ZodType< GetCheckOutput, z.ZodTypeDef, unknown > = z.object({ metrics: types.optional(z.lazy(() => GetCheckMetrics$inboundSchema)), }); export function getCheckOutputFromJSON( jsonString: string, ): SafeParseResult<GetCheckOutput, SDKValidationError> { return safeParse( jsonString, (x) => GetCheckOutput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetCheckOutput' from JSON`, ); } /** @internal */ export const GetCheckResponseBody$inboundSchema: z.ZodType< GetCheckResponseBody, z.ZodTypeDef, unknown > = z.object({ id: types.string(), name: types.string(), createdAt: types.number(), updatedAt: types.number(), deploymentId: types.string(), status: GetCheckStatus$inboundSchema, conclusion: types.optional(GetCheckConclusion$inboundSchema), externalId: types.optional(types.string()), output: types.optional(z.lazy(() => GetCheckOutput$inboundSchema)), completedAt: types.optional(types.number()), path: types.optional(types.string()), blocking: types.boolean(), detailsUrl: types.optional(types.string()), integrationId: types.string(), startedAt: types.optional(types.number()), rerequestable: types.optional(types.boolean()), }); export function getCheckResponseBodyFromJSON( jsonString: string, ): SafeParseResult<GetCheckResponseBody, SDKValidationError> { return safeParse( jsonString, (x) => GetCheckResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetCheckResponseBody' from JSON`, ); }