@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>
240 lines (216 loc) • 6.49 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 GetEdgeConfigRequest = {
edgeConfigId: 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 type GetEdgeConfigPurpose2 = {
type: "experimentation";
resourceId: string;
};
export type GetEdgeConfigPurpose1 = {
type: "flags";
projectId: string;
};
export type GetEdgeConfigPurpose =
| GetEdgeConfigPurpose1
| GetEdgeConfigPurpose2;
/**
* Keeps track of the current state of the Edge Config while it gets transferred.
*/
export type GetEdgeConfigTransfer = {
fromAccountId: string;
startedAt: number;
doneAt: number | null;
};
export type GetEdgeConfigSchema = {};
/**
* The EdgeConfig.
*/
export type GetEdgeConfigResponseBody = {
id: string;
createdAt: number;
/**
* The ID of the user who created the Edge Config, optional because it is not always set.
*/
createdBy?: string | undefined;
ownerId: string;
/**
* Name for the Edge 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?: GetEdgeConfigPurpose1 | GetEdgeConfigPurpose2 | undefined;
deletedAt?: number | null | undefined;
/**
* Keeps track of the current state of the Edge Config while it gets transferred.
*/
transfer?: GetEdgeConfigTransfer | undefined;
schema?: GetEdgeConfigSchema | undefined;
/**
* Timestamp of when the Edge Config was synced to DynamoDB initially. It is only set when syncing the entire Edge Config, not when updating.
*/
syncedToDynamoAt?: number | undefined;
sizeInBytes: number;
itemCount: number;
};
/** @internal */
export type GetEdgeConfigRequest$Outbound = {
edgeConfigId: string;
teamId?: string | undefined;
slug?: string | undefined;
};
/** @internal */
export const GetEdgeConfigRequest$outboundSchema: z.ZodType<
GetEdgeConfigRequest$Outbound,
z.ZodTypeDef,
GetEdgeConfigRequest
> = z.object({
edgeConfigId: z.string(),
teamId: z.string().optional(),
slug: z.string().optional(),
});
export function getEdgeConfigRequestToJSON(
getEdgeConfigRequest: GetEdgeConfigRequest,
): string {
return JSON.stringify(
GetEdgeConfigRequest$outboundSchema.parse(getEdgeConfigRequest),
);
}
/** @internal */
export const GetEdgeConfigPurpose2$inboundSchema: z.ZodType<
GetEdgeConfigPurpose2,
z.ZodTypeDef,
unknown
> = z.object({
type: types.literal("experimentation"),
resourceId: types.string(),
});
export function getEdgeConfigPurpose2FromJSON(
jsonString: string,
): SafeParseResult<GetEdgeConfigPurpose2, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetEdgeConfigPurpose2$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetEdgeConfigPurpose2' from JSON`,
);
}
/** @internal */
export const GetEdgeConfigPurpose1$inboundSchema: z.ZodType<
GetEdgeConfigPurpose1,
z.ZodTypeDef,
unknown
> = z.object({
type: types.literal("flags"),
projectId: types.string(),
});
export function getEdgeConfigPurpose1FromJSON(
jsonString: string,
): SafeParseResult<GetEdgeConfigPurpose1, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetEdgeConfigPurpose1$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetEdgeConfigPurpose1' from JSON`,
);
}
/** @internal */
export const GetEdgeConfigPurpose$inboundSchema: z.ZodType<
GetEdgeConfigPurpose,
z.ZodTypeDef,
unknown
> = z.union([
z.lazy(() => GetEdgeConfigPurpose1$inboundSchema),
z.lazy(() => GetEdgeConfigPurpose2$inboundSchema),
]);
export function getEdgeConfigPurposeFromJSON(
jsonString: string,
): SafeParseResult<GetEdgeConfigPurpose, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetEdgeConfigPurpose$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetEdgeConfigPurpose' from JSON`,
);
}
/** @internal */
export const GetEdgeConfigTransfer$inboundSchema: z.ZodType<
GetEdgeConfigTransfer,
z.ZodTypeDef,
unknown
> = z.object({
fromAccountId: types.string(),
startedAt: types.number(),
doneAt: types.nullable(types.number()),
});
export function getEdgeConfigTransferFromJSON(
jsonString: string,
): SafeParseResult<GetEdgeConfigTransfer, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetEdgeConfigTransfer$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetEdgeConfigTransfer' from JSON`,
);
}
/** @internal */
export const GetEdgeConfigSchema$inboundSchema: z.ZodType<
GetEdgeConfigSchema,
z.ZodTypeDef,
unknown
> = z.object({});
export function getEdgeConfigSchemaFromJSON(
jsonString: string,
): SafeParseResult<GetEdgeConfigSchema, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetEdgeConfigSchema$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetEdgeConfigSchema' from JSON`,
);
}
/** @internal */
export const GetEdgeConfigResponseBody$inboundSchema: z.ZodType<
GetEdgeConfigResponseBody,
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(() => GetEdgeConfigPurpose1$inboundSchema),
z.lazy(() => GetEdgeConfigPurpose2$inboundSchema),
]),
),
deletedAt: z.nullable(types.number()).optional(),
transfer: types.optional(z.lazy(() => GetEdgeConfigTransfer$inboundSchema)),
schema: types.optional(z.lazy(() => GetEdgeConfigSchema$inboundSchema)),
syncedToDynamoAt: types.optional(types.number()),
sizeInBytes: types.number(),
itemCount: types.number(),
});
export function getEdgeConfigResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<GetEdgeConfigResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetEdgeConfigResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetEdgeConfigResponseBody' from JSON`,
);
}