/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 538e574c1c41 */ 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"; import { Collection, Collection$inboundSchema, Collection$Outbound, Collection$outboundSchema, } from "./collection.js"; import { Document, Document$inboundSchema, Document$Outbound, Document$outboundSchema, } from "./document.js"; import { Person, Person$inboundSchema, Person$Outbound, Person$outboundSchema, } from "./person.js"; import { Shortcut, Shortcut$inboundSchema, Shortcut$Outbound, Shortcut$outboundSchema, } from "./shortcut.js"; export const CollectionItemItemType = { Document: "DOCUMENT", Text: "TEXT", Url: "URL", Collection: "COLLECTION", } as const; export type CollectionItemItemType = OpenEnum; export type CollectionItem = { /** * The optional name of the Collection item. */ name?: string | undefined; /** * A helpful description of why this CollectionItem is in the Collection that it's in. */ description?: string | undefined; /** * The emoji icon for this CollectionItem. Only used for Text type items. */ icon?: string | undefined; /** * The Collection ID of the Collection that this CollectionItem belongs in. */ collectionId: number; /** * If this CollectionItem is indexed, the Glean Document ID of that document. */ documentId?: string | undefined; /** * The URL of this CollectionItem. */ url?: string | undefined; /** * Unique identifier for the item within the Collection it belongs to. */ itemId?: string | undefined; createdBy?: Person | undefined; /** * Unix timestamp for when the item was first added (in seconds since epoch UTC). */ createdAt?: Date | undefined; document?: Document | undefined; shortcut?: Shortcut | undefined; collection?: Collection | undefined; itemType: CollectionItemItemType; }; /** @internal */ export const CollectionItemItemType$inboundSchema: z.ZodType< CollectionItemItemType, z.ZodTypeDef, unknown > = openEnums.inboundSchema(CollectionItemItemType); /** @internal */ export const CollectionItemItemType$outboundSchema: z.ZodType< string, z.ZodTypeDef, CollectionItemItemType > = openEnums.outboundSchema(CollectionItemItemType); /** @internal */ export const CollectionItem$inboundSchema: z.ZodType< CollectionItem, z.ZodTypeDef, unknown > = z.object({ name: z.string().optional(), description: z.string().optional(), icon: z.string().optional(), collectionId: z.number().int(), documentId: z.string().optional(), url: z.string().optional(), itemId: z.string().optional(), createdBy: z.lazy(() => Person$inboundSchema).optional(), createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), document: z.lazy(() => Document$inboundSchema).optional(), shortcut: z.lazy(() => Shortcut$inboundSchema).optional(), collection: z.lazy(() => Collection$inboundSchema).optional(), itemType: CollectionItemItemType$inboundSchema, }); /** @internal */ export type CollectionItem$Outbound = { name?: string | undefined; description?: string | undefined; icon?: string | undefined; collectionId: number; documentId?: string | undefined; url?: string | undefined; itemId?: string | undefined; createdBy?: Person$Outbound | undefined; createdAt?: string | undefined; document?: Document$Outbound | undefined; shortcut?: Shortcut$Outbound | undefined; collection?: Collection$Outbound | undefined; itemType: string; }; /** @internal */ export const CollectionItem$outboundSchema: z.ZodType< CollectionItem$Outbound, z.ZodTypeDef, CollectionItem > = z.object({ name: z.string().optional(), description: z.string().optional(), icon: z.string().optional(), collectionId: z.number().int(), documentId: z.string().optional(), url: z.string().optional(), itemId: z.string().optional(), createdBy: z.lazy(() => Person$outboundSchema).optional(), createdAt: z.date().transform(v => v.toISOString()).optional(), document: z.lazy(() => Document$outboundSchema).optional(), shortcut: z.lazy(() => Shortcut$outboundSchema).optional(), collection: z.lazy(() => Collection$outboundSchema).optional(), itemType: CollectionItemItemType$outboundSchema, }); export function collectionItemToJSON(collectionItem: CollectionItem): string { return JSON.stringify(CollectionItem$outboundSchema.parse(collectionItem)); } export function collectionItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CollectionItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CollectionItem' from JSON`, ); }