@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>
165 lines (148 loc) • 3.9 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 Utm = {
/**
* UTM source
*/
utmSource?: string | undefined;
/**
* UTM medium
*/
utmMedium?: string | undefined;
/**
* UTM campaign
*/
utmCampaign?: string | undefined;
/**
* UTM term
*/
utmTerm?: string | undefined;
};
/**
* Attribution information for the session or current page
*/
export type Attribution = {
/**
* Session referrer
*/
sessionReferrer?: string | undefined;
/**
* Session landing page
*/
landingPage?: string | undefined;
/**
* Referrer to the signup page
*/
pageBeforeConversionPage?: string | undefined;
utm?: Utm | undefined;
};
export type CreateTeamRequestBody = {
/**
* The desired slug for the Team
*/
slug: string;
/**
* The desired name for the Team. It will be generated from the provided slug if nothing is provided
*/
name?: string | undefined;
/**
* Attribution information for the session or current page
*/
attribution?: Attribution | undefined;
};
/**
* The team was created successfully
*/
export type CreateTeamResponseBody = {
/**
* Id of the created team
*/
id: string;
slug: string;
};
/** @internal */
export type Utm$Outbound = {
utmSource?: string | undefined;
utmMedium?: string | undefined;
utmCampaign?: string | undefined;
utmTerm?: string | undefined;
};
/** @internal */
export const Utm$outboundSchema: z.ZodType<Utm$Outbound, z.ZodTypeDef, Utm> = z
.object({
utmSource: z.string().optional(),
utmMedium: z.string().optional(),
utmCampaign: z.string().optional(),
utmTerm: z.string().optional(),
});
export function utmToJSON(utm: Utm): string {
return JSON.stringify(Utm$outboundSchema.parse(utm));
}
/** @internal */
export type Attribution$Outbound = {
sessionReferrer?: string | undefined;
landingPage?: string | undefined;
pageBeforeConversionPage?: string | undefined;
utm?: Utm$Outbound | undefined;
};
/** @internal */
export const Attribution$outboundSchema: z.ZodType<
Attribution$Outbound,
z.ZodTypeDef,
Attribution
> = z.object({
sessionReferrer: z.string().optional(),
landingPage: z.string().optional(),
pageBeforeConversionPage: z.string().optional(),
utm: z.lazy(() => Utm$outboundSchema).optional(),
});
export function attributionToJSON(attribution: Attribution): string {
return JSON.stringify(Attribution$outboundSchema.parse(attribution));
}
/** @internal */
export type CreateTeamRequestBody$Outbound = {
slug: string;
name?: string | undefined;
attribution?: Attribution$Outbound | undefined;
};
/** @internal */
export const CreateTeamRequestBody$outboundSchema: z.ZodType<
CreateTeamRequestBody$Outbound,
z.ZodTypeDef,
CreateTeamRequestBody
> = z.object({
slug: z.string(),
name: z.string().optional(),
attribution: z.lazy(() => Attribution$outboundSchema).optional(),
});
export function createTeamRequestBodyToJSON(
createTeamRequestBody: CreateTeamRequestBody,
): string {
return JSON.stringify(
CreateTeamRequestBody$outboundSchema.parse(createTeamRequestBody),
);
}
/** @internal */
export const CreateTeamResponseBody$inboundSchema: z.ZodType<
CreateTeamResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
id: types.string(),
slug: types.string(),
});
export function createTeamResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<CreateTeamResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => CreateTeamResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CreateTeamResponseBody' from JSON`,
);
}