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>

147 lines (133 loc) 4.44 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 { ClosedEnum } from "../types/enums.js"; /** * One of `LOCAL` or `REMOTE`. `LOCAL` specifies that the cache event was from the user's filesystem cache. `REMOTE` specifies that the cache event is from a remote cache. */ export const RecordEventsSource = { Local: "LOCAL", Remote: "REMOTE", } as const; /** * One of `LOCAL` or `REMOTE`. `LOCAL` specifies that the cache event was from the user's filesystem cache. `REMOTE` specifies that the cache event is from a remote cache. */ export type RecordEventsSource = ClosedEnum<typeof RecordEventsSource>; /** * One of `HIT` or `MISS`. `HIT` specifies that a cached artifact for `hash` was found in the cache. `MISS` specifies that a cached artifact with `hash` was not found. */ export const Event = { Hit: "HIT", Miss: "MISS", } as const; /** * One of `HIT` or `MISS`. `HIT` specifies that a cached artifact for `hash` was found in the cache. `MISS` specifies that a cached artifact with `hash` was not found. */ export type Event = ClosedEnum<typeof Event>; export type RequestBody = { /** * A UUID (universally unique identifer) for the session that generated this event. */ sessionId: string; /** * One of `LOCAL` or `REMOTE`. `LOCAL` specifies that the cache event was from the user's filesystem cache. `REMOTE` specifies that the cache event is from a remote cache. */ source: RecordEventsSource; /** * One of `HIT` or `MISS`. `HIT` specifies that a cached artifact for `hash` was found in the cache. `MISS` specifies that a cached artifact with `hash` was not found. */ event: Event; /** * The artifact hash */ hash: string; /** * The time taken to generate the artifact. This should be sent as a body parameter on `HIT` events. */ duration?: number | undefined; }; export type RecordEventsRequest = { /** * The continuous integration or delivery environment where this artifact is downloaded. */ xArtifactClientCi?: string | undefined; /** * 1 if the client is an interactive shell. Otherwise 0 */ xArtifactClientInteractive?: number | 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; requestBody: Array<RequestBody>; }; /** @internal */ export const RecordEventsSource$outboundSchema: z.ZodNativeEnum< typeof RecordEventsSource > = z.nativeEnum(RecordEventsSource); /** @internal */ export const Event$outboundSchema: z.ZodNativeEnum<typeof Event> = z.nativeEnum( Event, ); /** @internal */ export type RequestBody$Outbound = { sessionId: string; source: string; event: string; hash: string; duration?: number | undefined; }; /** @internal */ export const RequestBody$outboundSchema: z.ZodType< RequestBody$Outbound, z.ZodTypeDef, RequestBody > = z.object({ sessionId: z.string(), source: RecordEventsSource$outboundSchema, event: Event$outboundSchema, hash: z.string(), duration: z.number().optional(), }); export function requestBodyToJSON(requestBody: RequestBody): string { return JSON.stringify(RequestBody$outboundSchema.parse(requestBody)); } /** @internal */ export type RecordEventsRequest$Outbound = { "'x-Artifact-Client-Ci'"?: string | undefined; "'x-Artifact-Client-Interactive'"?: number | undefined; teamId?: string | undefined; slug?: string | undefined; RequestBody: Array<RequestBody$Outbound>; }; /** @internal */ export const RecordEventsRequest$outboundSchema: z.ZodType< RecordEventsRequest$Outbound, z.ZodTypeDef, RecordEventsRequest > = z.object({ xArtifactClientCi: z.string().optional(), xArtifactClientInteractive: z.number().int().optional(), teamId: z.string().optional(), slug: z.string().optional(), requestBody: z.array(z.lazy(() => RequestBody$outboundSchema)), }).transform((v) => { return remap$(v, { xArtifactClientCi: "'x-Artifact-Client-Ci'", xArtifactClientInteractive: "'x-Artifact-Client-Interactive'", requestBody: "RequestBody", }); }); export function recordEventsRequestToJSON( recordEventsRequest: RecordEventsRequest, ): string { return JSON.stringify( RecordEventsRequest$outboundSchema.parse(recordEventsRequest), ); }