/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: fbab2831fd0a */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { CollectionItem, CollectionItem$inboundSchema, CollectionItem$Outbound, CollectionItem$outboundSchema, } from "./collectionitem.js"; import { CollectionPinnedMetadata, CollectionPinnedMetadata$inboundSchema, CollectionPinnedMetadata$Outbound, CollectionPinnedMetadata$outboundSchema, } from "./collectionpinnedmetadata.js"; import { FacetFilter, FacetFilter$inboundSchema, FacetFilter$Outbound, FacetFilter$outboundSchema, } from "./facetfilter.js"; import { ObjectPermissions, ObjectPermissions$inboundSchema, ObjectPermissions$Outbound, ObjectPermissions$outboundSchema, } from "./objectpermissions.js"; import { Person, Person$inboundSchema, Person$Outbound, Person$outboundSchema, } from "./person.js"; import { Thumbnail, Thumbnail$inboundSchema, Thumbnail$Outbound, Thumbnail$outboundSchema, } from "./thumbnail.js"; import { UserRoleSpecification, UserRoleSpecification$inboundSchema, UserRoleSpecification$Outbound, UserRoleSpecification$outboundSchema, } from "./userrolespecification.js"; export type Collection = { /** * The unique name of the Collection. */ name: string; /** * A brief summary of the Collection's contents. */ description: string; /** * A list of added user roles for the Collection. */ addedRoles?: Array | undefined; /** * A list of removed user roles for the Collection. */ removedRoles?: Array | undefined; /** * Filters which restrict who should see this Collection. Values are taken from the corresponding filters in people search. */ audienceFilters?: Array | undefined; /** * The emoji icon of this Collection. */ icon?: string | undefined; /** * Indicates whether edits are allowed for everyone or only admins. */ adminLocked?: boolean | undefined; /** * The parent of this Collection, or 0 if it's a top-level Collection. */ parentId?: number | undefined; thumbnail?: Thumbnail | undefined; /** * The datasource type this Collection can hold. */ allowedDatasource?: string | undefined; permissions?: ObjectPermissions | undefined; /** * The unique ID of the Collection. */ id: number; createTime?: Date | undefined; updateTime?: Date | undefined; creator?: Person | undefined; updatedBy?: Person | undefined; /** * The number of items currently in the Collection. Separated from the actual items so we can grab the count without items. */ itemCount?: number | undefined; /** * The number of children Collections. Separated from the actual children so we can grab the count without children. */ childCount?: number | undefined; /** * The items in this Collection. */ items?: Array | undefined; pinMetadata?: CollectionPinnedMetadata | undefined; /** * The names of the shortcuts (Go Links) that point to this Collection. */ shortcuts?: Array | undefined; /** * The children Collections of this Collection. */ children?: Array | undefined; /** * A list of user roles for the Collection. */ roles?: Array | undefined; }; /** @internal */ export const Collection$inboundSchema: z.ZodType< Collection, z.ZodTypeDef, unknown > = z.object({ name: z.string(), description: z.string(), addedRoles: z.array(z.lazy(() => UserRoleSpecification$inboundSchema)) .optional(), removedRoles: z.array(z.lazy(() => UserRoleSpecification$inboundSchema)) .optional(), audienceFilters: z.array(FacetFilter$inboundSchema).optional(), icon: z.string().optional(), adminLocked: z.boolean().optional(), parentId: z.number().int().optional(), thumbnail: Thumbnail$inboundSchema.optional(), allowedDatasource: z.string().optional(), permissions: ObjectPermissions$inboundSchema.optional(), id: z.number().int(), createTime: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), updateTime: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), creator: z.lazy(() => Person$inboundSchema).optional(), updatedBy: z.lazy(() => Person$inboundSchema).optional(), itemCount: z.number().int().optional(), childCount: z.number().int().optional(), items: z.array(z.lazy(() => CollectionItem$inboundSchema)).optional(), pinMetadata: CollectionPinnedMetadata$inboundSchema.optional(), shortcuts: z.array(z.string()).optional(), children: z.array(z.lazy(() => Collection$inboundSchema)).optional(), roles: z.array(z.lazy(() => UserRoleSpecification$inboundSchema)).optional(), }); /** @internal */ export type Collection$Outbound = { name: string; description: string; addedRoles?: Array | undefined; removedRoles?: Array | undefined; audienceFilters?: Array | undefined; icon?: string | undefined; adminLocked?: boolean | undefined; parentId?: number | undefined; thumbnail?: Thumbnail$Outbound | undefined; allowedDatasource?: string | undefined; permissions?: ObjectPermissions$Outbound | undefined; id: number; createTime?: string | undefined; updateTime?: string | undefined; creator?: Person$Outbound | undefined; updatedBy?: Person$Outbound | undefined; itemCount?: number | undefined; childCount?: number | undefined; items?: Array | undefined; pinMetadata?: CollectionPinnedMetadata$Outbound | undefined; shortcuts?: Array | undefined; children?: Array | undefined; roles?: Array | undefined; }; /** @internal */ export const Collection$outboundSchema: z.ZodType< Collection$Outbound, z.ZodTypeDef, Collection > = z.object({ name: z.string(), description: z.string(), addedRoles: z.array(z.lazy(() => UserRoleSpecification$outboundSchema)) .optional(), removedRoles: z.array(z.lazy(() => UserRoleSpecification$outboundSchema)) .optional(), audienceFilters: z.array(FacetFilter$outboundSchema).optional(), icon: z.string().optional(), adminLocked: z.boolean().optional(), parentId: z.number().int().optional(), thumbnail: Thumbnail$outboundSchema.optional(), allowedDatasource: z.string().optional(), permissions: ObjectPermissions$outboundSchema.optional(), id: z.number().int(), createTime: z.date().transform(v => v.toISOString()).optional(), updateTime: z.date().transform(v => v.toISOString()).optional(), creator: z.lazy(() => Person$outboundSchema).optional(), updatedBy: z.lazy(() => Person$outboundSchema).optional(), itemCount: z.number().int().optional(), childCount: z.number().int().optional(), items: z.array(z.lazy(() => CollectionItem$outboundSchema)).optional(), pinMetadata: CollectionPinnedMetadata$outboundSchema.optional(), shortcuts: z.array(z.string()).optional(), children: z.array(z.lazy(() => Collection$outboundSchema)).optional(), roles: z.array(z.lazy(() => UserRoleSpecification$outboundSchema)).optional(), }); export function collectionToJSON(collection: Collection): string { return JSON.stringify(Collection$outboundSchema.parse(collection)); } export function collectionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Collection$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Collection' from JSON`, ); }