/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 53e7557eada4 */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of the user generated content (UGC datasource). */ export const DocumentSpecUgcType2 = { Announcements: "ANNOUNCEMENTS", Answers: "ANSWERS", Artifacts: "ARTIFACTS", Collections: "COLLECTIONS", Shortcuts: "SHORTCUTS", Chats: "CHATS", } as const; /** * The type of the user generated content (UGC datasource). */ export type DocumentSpecUgcType2 = OpenEnum; export type DocumentSpec4 = { /** * The type of the user generated content (UGC datasource). */ ugcType: DocumentSpecUgcType2; /** * The string id for user generated content. Used for CHATS. */ ugcId: string; /** * The specific type of the user generated content type. */ docType?: string | undefined; }; /** * The type of the user generated content (UGC datasource). */ export const DocumentSpecUgcType1 = { Announcements: "ANNOUNCEMENTS", Answers: "ANSWERS", Collections: "COLLECTIONS", Shortcuts: "SHORTCUTS", Chats: "CHATS", } as const; /** * The type of the user generated content (UGC datasource). */ export type DocumentSpecUgcType1 = OpenEnum; export type DocumentSpec3 = { /** * The type of the user generated content (UGC datasource). */ ugcType: DocumentSpecUgcType1; /** * The numeric id for user generated content. Used for ANNOUNCEMENTS, ANSWERS, COLLECTIONS, SHORTCUTS. */ contentId: number; /** * The specific type of the user generated content type. */ docType?: string | undefined; }; export type DocumentSpec2 = { /** * The ID of the document. */ id: string; }; export type DocumentSpec1 = { /** * The URL of the document. */ url: string; }; export type DocumentSpecUnion = | DocumentSpec3 | DocumentSpec4 | DocumentSpec1 | DocumentSpec2; /** @internal */ export const DocumentSpecUgcType2$inboundSchema: z.ZodType< DocumentSpecUgcType2, z.ZodTypeDef, unknown > = openEnums.inboundSchema(DocumentSpecUgcType2); /** @internal */ export const DocumentSpecUgcType2$outboundSchema: z.ZodType< string, z.ZodTypeDef, DocumentSpecUgcType2 > = openEnums.outboundSchema(DocumentSpecUgcType2); /** @internal */ export const DocumentSpec4$inboundSchema: z.ZodType< DocumentSpec4, z.ZodTypeDef, unknown > = z.object({ ugcType: DocumentSpecUgcType2$inboundSchema, ugcId: z.string(), docType: z.string().optional(), }); /** @internal */ export type DocumentSpec4$Outbound = { ugcType: string; ugcId: string; docType?: string | undefined; }; /** @internal */ export const DocumentSpec4$outboundSchema: z.ZodType< DocumentSpec4$Outbound, z.ZodTypeDef, DocumentSpec4 > = z.object({ ugcType: DocumentSpecUgcType2$outboundSchema, ugcId: z.string(), docType: z.string().optional(), }); export function documentSpec4ToJSON(documentSpec4: DocumentSpec4): string { return JSON.stringify(DocumentSpec4$outboundSchema.parse(documentSpec4)); } export function documentSpec4FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DocumentSpec4$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DocumentSpec4' from JSON`, ); } /** @internal */ export const DocumentSpecUgcType1$inboundSchema: z.ZodType< DocumentSpecUgcType1, z.ZodTypeDef, unknown > = openEnums.inboundSchema(DocumentSpecUgcType1); /** @internal */ export const DocumentSpecUgcType1$outboundSchema: z.ZodType< string, z.ZodTypeDef, DocumentSpecUgcType1 > = openEnums.outboundSchema(DocumentSpecUgcType1); /** @internal */ export const DocumentSpec3$inboundSchema: z.ZodType< DocumentSpec3, z.ZodTypeDef, unknown > = z.object({ ugcType: DocumentSpecUgcType1$inboundSchema, contentId: z.number().int(), docType: z.string().optional(), }); /** @internal */ export type DocumentSpec3$Outbound = { ugcType: string; contentId: number; docType?: string | undefined; }; /** @internal */ export const DocumentSpec3$outboundSchema: z.ZodType< DocumentSpec3$Outbound, z.ZodTypeDef, DocumentSpec3 > = z.object({ ugcType: DocumentSpecUgcType1$outboundSchema, contentId: z.number().int(), docType: z.string().optional(), }); export function documentSpec3ToJSON(documentSpec3: DocumentSpec3): string { return JSON.stringify(DocumentSpec3$outboundSchema.parse(documentSpec3)); } export function documentSpec3FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DocumentSpec3$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DocumentSpec3' from JSON`, ); } /** @internal */ export const DocumentSpec2$inboundSchema: z.ZodType< DocumentSpec2, z.ZodTypeDef, unknown > = z.object({ id: z.string(), }); /** @internal */ export type DocumentSpec2$Outbound = { id: string; }; /** @internal */ export const DocumentSpec2$outboundSchema: z.ZodType< DocumentSpec2$Outbound, z.ZodTypeDef, DocumentSpec2 > = z.object({ id: z.string(), }); export function documentSpec2ToJSON(documentSpec2: DocumentSpec2): string { return JSON.stringify(DocumentSpec2$outboundSchema.parse(documentSpec2)); } export function documentSpec2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DocumentSpec2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DocumentSpec2' from JSON`, ); } /** @internal */ export const DocumentSpec1$inboundSchema: z.ZodType< DocumentSpec1, z.ZodTypeDef, unknown > = z.object({ url: z.string(), }); /** @internal */ export type DocumentSpec1$Outbound = { url: string; }; /** @internal */ export const DocumentSpec1$outboundSchema: z.ZodType< DocumentSpec1$Outbound, z.ZodTypeDef, DocumentSpec1 > = z.object({ url: z.string(), }); export function documentSpec1ToJSON(documentSpec1: DocumentSpec1): string { return JSON.stringify(DocumentSpec1$outboundSchema.parse(documentSpec1)); } export function documentSpec1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DocumentSpec1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DocumentSpec1' from JSON`, ); } /** @internal */ export const DocumentSpecUnion$inboundSchema: z.ZodType< DocumentSpecUnion, z.ZodTypeDef, unknown > = z.union([ z.lazy(() => DocumentSpec3$inboundSchema), z.lazy(() => DocumentSpec4$inboundSchema), z.lazy(() => DocumentSpec1$inboundSchema), z.lazy(() => DocumentSpec2$inboundSchema), ]); /** @internal */ export type DocumentSpecUnion$Outbound = | DocumentSpec3$Outbound | DocumentSpec4$Outbound | DocumentSpec1$Outbound | DocumentSpec2$Outbound; /** @internal */ export const DocumentSpecUnion$outboundSchema: z.ZodType< DocumentSpecUnion$Outbound, z.ZodTypeDef, DocumentSpecUnion > = z.union([ z.lazy(() => DocumentSpec3$outboundSchema), z.lazy(() => DocumentSpec4$outboundSchema), z.lazy(() => DocumentSpec1$outboundSchema), z.lazy(() => DocumentSpec2$outboundSchema), ]); export function documentSpecUnionToJSON( documentSpecUnion: DocumentSpecUnion, ): string { return JSON.stringify( DocumentSpecUnion$outboundSchema.parse(documentSpecUnion), ); } export function documentSpecUnionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DocumentSpecUnion$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DocumentSpecUnion' from JSON`, ); }