@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>
289 lines (264 loc) • 7.72 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 { Pagination, Pagination$inboundSchema } from "./pagination.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
export type GetRecordsRequest = {
domain: string;
/**
* Maximum number of records to list from a request.
*/
limit?: string | undefined;
/**
* Get records created after this JavaScript timestamp.
*/
since?: string | undefined;
/**
* Get records created before this JavaScript timestamp.
*/
until?: string | 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 const GetRecordsResponseBodyDnsType = {
A: "A",
Aaaa: "AAAA",
Alias: "ALIAS",
Caa: "CAA",
Cname: "CNAME",
Https: "HTTPS",
Mx: "MX",
Ns: "NS",
Srv: "SRV",
Txt: "TXT",
} as const;
export type GetRecordsResponseBodyDnsType = ClosedEnum<
typeof GetRecordsResponseBodyDnsType
>;
export type ResponseBodyRecords = {
id: string;
slug: string;
name: string;
type: GetRecordsResponseBodyDnsType;
value: string;
mxPriority?: number | undefined;
priority?: number | undefined;
creator: string;
created: number | null;
updated: number | null;
createdAt: number | null;
updatedAt: number | null;
ttl?: number | undefined;
comment?: string | undefined;
};
/**
* Successful response retrieving a list of paginated DNS records.
*/
export type GetRecordsResponseBody3 = {
records: Array<ResponseBodyRecords>;
/**
* This object contains information related to the pagination of the current request, including the necessary parameters to get the next or previous page of data.
*/
pagination: Pagination;
};
export const GetRecordsResponseBodyType = {
A: "A",
Aaaa: "AAAA",
Alias: "ALIAS",
Caa: "CAA",
Cname: "CNAME",
Https: "HTTPS",
Mx: "MX",
Ns: "NS",
Srv: "SRV",
Txt: "TXT",
} as const;
export type GetRecordsResponseBodyType = ClosedEnum<
typeof GetRecordsResponseBodyType
>;
export type Records = {
id: string;
slug: string;
name: string;
type: GetRecordsResponseBodyType;
value: string;
mxPriority?: number | undefined;
priority?: number | undefined;
creator: string;
created: number | null;
updated: number | null;
createdAt: number | null;
updatedAt: number | null;
ttl?: number | undefined;
comment?: string | undefined;
};
export type GetRecordsResponseBody2 = {
records: Array<Records>;
};
/**
* Successful response retrieving a list of paginated DNS records.
*/
export type GetRecordsResponseBody =
| GetRecordsResponseBody3
| GetRecordsResponseBody2
| string;
/** @internal */
export type GetRecordsRequest$Outbound = {
domain: string;
limit?: string | undefined;
since?: string | undefined;
until?: string | undefined;
teamId?: string | undefined;
slug?: string | undefined;
};
/** @internal */
export const GetRecordsRequest$outboundSchema: z.ZodType<
GetRecordsRequest$Outbound,
z.ZodTypeDef,
GetRecordsRequest
> = z.object({
domain: z.string(),
limit: z.string().optional(),
since: z.string().optional(),
until: z.string().optional(),
teamId: z.string().optional(),
slug: z.string().optional(),
});
export function getRecordsRequestToJSON(
getRecordsRequest: GetRecordsRequest,
): string {
return JSON.stringify(
GetRecordsRequest$outboundSchema.parse(getRecordsRequest),
);
}
/** @internal */
export const GetRecordsResponseBodyDnsType$inboundSchema: z.ZodNativeEnum<
typeof GetRecordsResponseBodyDnsType
> = z.nativeEnum(GetRecordsResponseBodyDnsType);
/** @internal */
export const ResponseBodyRecords$inboundSchema: z.ZodType<
ResponseBodyRecords,
z.ZodTypeDef,
unknown
> = z.object({
id: types.string(),
slug: types.string(),
name: types.string(),
type: GetRecordsResponseBodyDnsType$inboundSchema,
value: types.string(),
mxPriority: types.optional(types.number()),
priority: types.optional(types.number()),
creator: types.string(),
created: types.nullable(types.number()),
updated: types.nullable(types.number()),
createdAt: types.nullable(types.number()),
updatedAt: types.nullable(types.number()),
ttl: types.optional(types.number()),
comment: types.optional(types.string()),
});
export function responseBodyRecordsFromJSON(
jsonString: string,
): SafeParseResult<ResponseBodyRecords, SDKValidationError> {
return safeParse(
jsonString,
(x) => ResponseBodyRecords$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ResponseBodyRecords' from JSON`,
);
}
/** @internal */
export const GetRecordsResponseBody3$inboundSchema: z.ZodType<
GetRecordsResponseBody3,
z.ZodTypeDef,
unknown
> = z.object({
records: z.array(z.lazy(() => ResponseBodyRecords$inboundSchema)),
pagination: Pagination$inboundSchema,
});
export function getRecordsResponseBody3FromJSON(
jsonString: string,
): SafeParseResult<GetRecordsResponseBody3, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetRecordsResponseBody3$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetRecordsResponseBody3' from JSON`,
);
}
/** @internal */
export const GetRecordsResponseBodyType$inboundSchema: z.ZodNativeEnum<
typeof GetRecordsResponseBodyType
> = z.nativeEnum(GetRecordsResponseBodyType);
/** @internal */
export const Records$inboundSchema: z.ZodType<Records, z.ZodTypeDef, unknown> =
z.object({
id: types.string(),
slug: types.string(),
name: types.string(),
type: GetRecordsResponseBodyType$inboundSchema,
value: types.string(),
mxPriority: types.optional(types.number()),
priority: types.optional(types.number()),
creator: types.string(),
created: types.nullable(types.number()),
updated: types.nullable(types.number()),
createdAt: types.nullable(types.number()),
updatedAt: types.nullable(types.number()),
ttl: types.optional(types.number()),
comment: types.optional(types.string()),
});
export function recordsFromJSON(
jsonString: string,
): SafeParseResult<Records, SDKValidationError> {
return safeParse(
jsonString,
(x) => Records$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Records' from JSON`,
);
}
/** @internal */
export const GetRecordsResponseBody2$inboundSchema: z.ZodType<
GetRecordsResponseBody2,
z.ZodTypeDef,
unknown
> = z.object({
records: z.array(z.lazy(() => Records$inboundSchema)),
});
export function getRecordsResponseBody2FromJSON(
jsonString: string,
): SafeParseResult<GetRecordsResponseBody2, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetRecordsResponseBody2$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetRecordsResponseBody2' from JSON`,
);
}
/** @internal */
export const GetRecordsResponseBody$inboundSchema: z.ZodType<
GetRecordsResponseBody,
z.ZodTypeDef,
unknown
> = smartUnion([
z.lazy(() => GetRecordsResponseBody3$inboundSchema),
z.lazy(() => GetRecordsResponseBody2$inboundSchema),
types.string(),
]);
export function getRecordsResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<GetRecordsResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetRecordsResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetRecordsResponseBody' from JSON`,
);
}