@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>
229 lines (205 loc) • 5.83 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 { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
export type GetEdgeConfigsRequest = {
/**
* 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 type Purpose2 = {
type: "experimentation";
resourceId: string;
};
export type Purpose1 = {
type: "flags";
projectId: string;
};
export type Purpose = Purpose1 | Purpose2;
/**
* Keeps track of the current state of the Global Config while it gets transferred.
*/
export type Transfer = {
fromAccountId: string;
startedAt: number;
doneAt: number | null;
};
export type Schema = {};
/**
* List of all global configs.
*/
export type GetEdgeConfigsResponseBody = {
id: string;
createdAt: number;
/**
* The ID of the user who created the Global Config, optional because it is not always set.
*/
createdBy?: string | undefined;
ownerId: string;
/**
* Name for the Global Config Names are not unique. Must start with an alphabetic character and can contain only alphanumeric characters and underscores).
*/
slug: string;
updatedAt: number;
digest: string;
purpose?: Purpose1 | Purpose2 | undefined;
deletedAt?: number | null | undefined;
/**
* Keeps track of the current state of the Global Config while it gets transferred.
*/
transfer?: Transfer | undefined;
schema?: Schema | undefined;
/**
* Timestamp of when the Global Config was synced to DynamoDB initially. It is only set when syncing the entire Global Config, not when updating.
*/
syncedToDynamoAt?: number | undefined;
sizeInBytes: number;
itemCount: number;
};
/** @internal */
export type GetEdgeConfigsRequest$Outbound = {
teamId?: string | undefined;
slug?: string | undefined;
};
/** @internal */
export const GetEdgeConfigsRequest$outboundSchema: z.ZodType<
GetEdgeConfigsRequest$Outbound,
z.ZodTypeDef,
GetEdgeConfigsRequest
> = z.object({
teamId: z.string().optional(),
slug: z.string().optional(),
});
export function getEdgeConfigsRequestToJSON(
getEdgeConfigsRequest: GetEdgeConfigsRequest,
): string {
return JSON.stringify(
GetEdgeConfigsRequest$outboundSchema.parse(getEdgeConfigsRequest),
);
}
/** @internal */
export const Purpose2$inboundSchema: z.ZodType<
Purpose2,
z.ZodTypeDef,
unknown
> = z.object({
type: types.literal("experimentation"),
resourceId: types.string(),
});
export function purpose2FromJSON(
jsonString: string,
): SafeParseResult<Purpose2, SDKValidationError> {
return safeParse(
jsonString,
(x) => Purpose2$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Purpose2' from JSON`,
);
}
/** @internal */
export const Purpose1$inboundSchema: z.ZodType<
Purpose1,
z.ZodTypeDef,
unknown
> = z.object({
type: types.literal("flags"),
projectId: types.string(),
});
export function purpose1FromJSON(
jsonString: string,
): SafeParseResult<Purpose1, SDKValidationError> {
return safeParse(
jsonString,
(x) => Purpose1$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Purpose1' from JSON`,
);
}
/** @internal */
export const Purpose$inboundSchema: z.ZodType<Purpose, z.ZodTypeDef, unknown> =
z.union([
z.lazy(() => Purpose1$inboundSchema),
z.lazy(() => Purpose2$inboundSchema),
]);
export function purposeFromJSON(
jsonString: string,
): SafeParseResult<Purpose, SDKValidationError> {
return safeParse(
jsonString,
(x) => Purpose$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Purpose' from JSON`,
);
}
/** @internal */
export const Transfer$inboundSchema: z.ZodType<
Transfer,
z.ZodTypeDef,
unknown
> = z.object({
fromAccountId: types.string(),
startedAt: types.number(),
doneAt: types.nullable(types.number()),
});
export function transferFromJSON(
jsonString: string,
): SafeParseResult<Transfer, SDKValidationError> {
return safeParse(
jsonString,
(x) => Transfer$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Transfer' from JSON`,
);
}
/** @internal */
export const Schema$inboundSchema: z.ZodType<Schema, z.ZodTypeDef, unknown> = z
.object({});
export function schemaFromJSON(
jsonString: string,
): SafeParseResult<Schema, SDKValidationError> {
return safeParse(
jsonString,
(x) => Schema$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Schema' from JSON`,
);
}
/** @internal */
export const GetEdgeConfigsResponseBody$inboundSchema: z.ZodType<
GetEdgeConfigsResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
id: types.string(),
createdAt: types.number(),
createdBy: types.optional(types.string()),
ownerId: types.string(),
slug: types.string(),
updatedAt: types.number(),
digest: types.string(),
purpose: types.optional(
z.union([
z.lazy(() => Purpose1$inboundSchema),
z.lazy(() => Purpose2$inboundSchema),
]),
),
deletedAt: z.nullable(types.number()).optional(),
transfer: types.optional(z.lazy(() => Transfer$inboundSchema)),
schema: types.optional(z.lazy(() => Schema$inboundSchema)),
syncedToDynamoAt: types.optional(types.number()),
sizeInBytes: types.number(),
itemCount: types.number(),
});
export function getEdgeConfigsResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<GetEdgeConfigsResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetEdgeConfigsResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetEdgeConfigsResponseBody' from JSON`,
);
}