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>

156 lines (142 loc) 4.41 kB
/* * 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 { Flag, Flag$inboundSchema } from "./flag.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * The state of the flags to retrieve. Defaults to `active`. */ export const ListFlagsQueryParamState = { Active: "active", Archived: "archived", } as const; /** * The state of the flags to retrieve. Defaults to `active`. */ export type ListFlagsQueryParamState = ClosedEnum< typeof ListFlagsQueryParamState >; export type ListFlagsRequest = { /** * The project id or name */ projectIdOrName: string; /** * The state of the flags to retrieve. Defaults to `active`. */ state?: ListFlagsQueryParamState | undefined; /** * Deprecated. Whether to include creator metadata in each flag in the response. Resolve creator identity client-side (e.g. via the team members endpoint) instead; this parameter will be removed in a future release. Use `GET /v1/projects/:id/feature-flags/flags/:flagIdOrSlug?withMetadata=true` for single-flag lookups that need creator metadata. */ withMetadata?: boolean | undefined; /** * Maximum number of flags to return. When not set, all flags are returned. */ limit?: number | undefined; /** * Pagination cursor to continue from. */ cursor?: string | undefined; /** * Search flags by their slug or description. Case-insensitive. */ search?: string | undefined; /** * Filter flags by tag. Repeat the parameter for multiple tags (all must match). */ tags?: Array<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 type ListFlagsPagination = { next: string | null; }; export type ListFlagsResponseBody = { data: Array<Flag>; pagination: ListFlagsPagination; }; /** @internal */ export const ListFlagsQueryParamState$outboundSchema: z.ZodNativeEnum< typeof ListFlagsQueryParamState > = z.nativeEnum(ListFlagsQueryParamState); /** @internal */ export type ListFlagsRequest$Outbound = { projectIdOrName: string; state?: string | undefined; withMetadata?: boolean | undefined; limit?: number | undefined; cursor?: string | undefined; search?: string | undefined; tags?: Array<string> | undefined; teamId?: string | undefined; slug?: string | undefined; }; /** @internal */ export const ListFlagsRequest$outboundSchema: z.ZodType< ListFlagsRequest$Outbound, z.ZodTypeDef, ListFlagsRequest > = z.object({ projectIdOrName: z.string(), state: ListFlagsQueryParamState$outboundSchema.optional(), withMetadata: z.boolean().optional(), limit: z.number().int().optional(), cursor: z.string().optional(), search: z.string().optional(), tags: z.array(z.string()).optional(), teamId: z.string().optional(), slug: z.string().optional(), }); export function listFlagsRequestToJSON( listFlagsRequest: ListFlagsRequest, ): string { return JSON.stringify( ListFlagsRequest$outboundSchema.parse(listFlagsRequest), ); } /** @internal */ export const ListFlagsPagination$inboundSchema: z.ZodType< ListFlagsPagination, z.ZodTypeDef, unknown > = z.object({ next: types.nullable(types.string()), }); export function listFlagsPaginationFromJSON( jsonString: string, ): SafeParseResult<ListFlagsPagination, SDKValidationError> { return safeParse( jsonString, (x) => ListFlagsPagination$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListFlagsPagination' from JSON`, ); } /** @internal */ export const ListFlagsResponseBody$inboundSchema: z.ZodType< ListFlagsResponseBody, z.ZodTypeDef, unknown > = z.object({ data: z.array(Flag$inboundSchema), pagination: z.lazy(() => ListFlagsPagination$inboundSchema), }); export function listFlagsResponseBodyFromJSON( jsonString: string, ): SafeParseResult<ListFlagsResponseBody, SDKValidationError> { return safeParse( jsonString, (x) => ListFlagsResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListFlagsResponseBody' from JSON`, ); }