@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>
114 lines (101 loc) • 2.98 kB
text/typescript
/*
* 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 { 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 CreateTraceSessionRequestBody = {
/**
* The project ID the deployment belongs to.
*/
projectId: string;
/**
* The deployment hostname to scope the trace session to.
*/
hostname: string;
};
export type CreateTraceSessionRequest = {
/**
* 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?: CreateTraceSessionRequestBody | undefined;
};
export type CreateTraceSessionResponseBody = {
token: string;
};
/** @internal */
export type CreateTraceSessionRequestBody$Outbound = {
projectId: string;
hostname: string;
};
/** @internal */
export const CreateTraceSessionRequestBody$outboundSchema: z.ZodType<
CreateTraceSessionRequestBody$Outbound,
z.ZodTypeDef,
CreateTraceSessionRequestBody
> = z.object({
projectId: z.string(),
hostname: z.string(),
});
export function createTraceSessionRequestBodyToJSON(
createTraceSessionRequestBody: CreateTraceSessionRequestBody,
): string {
return JSON.stringify(
CreateTraceSessionRequestBody$outboundSchema.parse(
createTraceSessionRequestBody,
),
);
}
/** @internal */
export type CreateTraceSessionRequest$Outbound = {
teamId?: string | undefined;
slug?: string | undefined;
RequestBody?: CreateTraceSessionRequestBody$Outbound | undefined;
};
/** @internal */
export const CreateTraceSessionRequest$outboundSchema: z.ZodType<
CreateTraceSessionRequest$Outbound,
z.ZodTypeDef,
CreateTraceSessionRequest
> = z.object({
teamId: z.string().optional(),
slug: z.string().optional(),
requestBody: z.lazy(() => CreateTraceSessionRequestBody$outboundSchema)
.optional(),
}).transform((v) => {
return remap$(v, {
requestBody: "RequestBody",
});
});
export function createTraceSessionRequestToJSON(
createTraceSessionRequest: CreateTraceSessionRequest,
): string {
return JSON.stringify(
CreateTraceSessionRequest$outboundSchema.parse(createTraceSessionRequest),
);
}
/** @internal */
export const CreateTraceSessionResponseBody$inboundSchema: z.ZodType<
CreateTraceSessionResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
token: types.string(),
});
export function createTraceSessionResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<CreateTraceSessionResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => CreateTraceSessionResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CreateTraceSessionResponseBody' from JSON`,
);
}