/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: ad5dd32ac710 */ 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 { Document, Document$inboundSchema } from "./document.js"; import { FacetFilter, FacetFilter$inboundSchema } from "./facetfilter.js"; import { ObjectPermissions, ObjectPermissions$inboundSchema, } from "./objectpermissions.js"; import { Person, Person$inboundSchema } from "./person.js"; import { StructuredText, StructuredText$inboundSchema, } from "./structuredtext.js"; import { Thumbnail, Thumbnail$inboundSchema } from "./thumbnail.js"; /** * This determines whether this is a Social Feed post or a regular announcement. */ export const AnnouncementChannel = { Main: "MAIN", SocialFeed: "SOCIAL_FEED", } as const; /** * This determines whether this is a Social Feed post or a regular announcement. */ export type AnnouncementChannel = OpenEnum; /** * This determines whether this is an external-link post or a regular announcement post. TEXT - Regular announcement that can contain rich text. LINK - Announcement that is linked to an external site. */ export const AnnouncementPostType = { Text: "TEXT", Link: "LINK", } as const; /** * This determines whether this is an external-link post or a regular announcement post. TEXT - Regular announcement that can contain rich text. LINK - Announcement that is linked to an external site. */ export type AnnouncementPostType = OpenEnum; export type AnnouncementViewerInfo = { /** * Whether the viewer has dismissed the announcement. */ isDismissed?: boolean | undefined; /** * Whether the viewer has read the announcement. */ isRead?: boolean | undefined; }; export type Announcement = { /** * The date and time at which the announcement becomes active. */ startTime?: Date | undefined; /** * The date and time at which the announcement expires. */ endTime?: Date | undefined; /** * The headline of the announcement. */ title?: string | undefined; body?: StructuredText | undefined; /** * An emoji used to indicate the nature of the announcement. */ emoji?: string | undefined; thumbnail?: Thumbnail | undefined; banner?: Thumbnail | undefined; /** * Filters which restrict who should see the announcement. Values are taken from the corresponding filters in people search. */ audienceFilters?: Array | undefined; /** * The Glean Document ID of the source document this Announcement was created from (e.g. Slack thread). */ sourceDocumentId?: string | undefined; /** * Whether or not to hide an author attribution. */ hideAttribution?: boolean | undefined; /** * This determines whether this is a Social Feed post or a regular announcement. */ channel?: AnnouncementChannel | undefined; /** * This determines whether this is an external-link post or a regular announcement post. TEXT - Regular announcement that can contain rich text. LINK - Announcement that is linked to an external site. */ postType?: AnnouncementPostType | undefined; /** * Used by the Social Feed to pin posts to the front of the feed. */ isPrioritized?: boolean | undefined; /** * URL for viewing the announcement. It will be set to document URL for announcements from other datasources e.g. simpplr. Can only be written when channel="SOCIAL_FEED". */ viewUrl?: string | undefined; /** * The opaque id of the associated draft. */ draftId?: number | undefined; permissions?: ObjectPermissions | undefined; /** * The opaque id of the announcement. */ id?: number | undefined; author?: Person | undefined; /** * Server Unix timestamp of the creation time (in seconds since epoch UTC). */ createTimestamp?: number | undefined; /** * Server Unix timestamp of the last update time (in seconds since epoch UTC). */ lastUpdateTimestamp?: number | undefined; updatedBy?: Person | undefined; viewerInfo?: AnnouncementViewerInfo | undefined; sourceDocument?: Document | undefined; /** * Whether or not the announcement is published. */ isPublished?: boolean | undefined; }; /** @internal */ export const AnnouncementChannel$inboundSchema: z.ZodType< AnnouncementChannel, z.ZodTypeDef, unknown > = openEnums.inboundSchema(AnnouncementChannel); /** @internal */ export const AnnouncementPostType$inboundSchema: z.ZodType< AnnouncementPostType, z.ZodTypeDef, unknown > = openEnums.inboundSchema(AnnouncementPostType); /** @internal */ export const AnnouncementViewerInfo$inboundSchema: z.ZodType< AnnouncementViewerInfo, z.ZodTypeDef, unknown > = z.object({ isDismissed: z.boolean().optional(), isRead: z.boolean().optional(), }); export function announcementViewerInfoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AnnouncementViewerInfo$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AnnouncementViewerInfo' from JSON`, ); } /** @internal */ export const Announcement$inboundSchema: z.ZodType< Announcement, z.ZodTypeDef, unknown > = z.object({ startTime: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), endTime: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), title: z.string().optional(), body: StructuredText$inboundSchema.optional(), emoji: z.string().optional(), thumbnail: Thumbnail$inboundSchema.optional(), banner: Thumbnail$inboundSchema.optional(), audienceFilters: z.array(FacetFilter$inboundSchema).optional(), sourceDocumentId: z.string().optional(), hideAttribution: z.boolean().optional(), channel: AnnouncementChannel$inboundSchema.optional(), postType: AnnouncementPostType$inboundSchema.optional(), isPrioritized: z.boolean().optional(), viewUrl: z.string().optional(), draftId: z.number().int().optional(), permissions: ObjectPermissions$inboundSchema.optional(), id: z.number().int().optional(), author: Person$inboundSchema.optional(), createTimestamp: z.number().int().optional(), lastUpdateTimestamp: z.number().int().optional(), updatedBy: Person$inboundSchema.optional(), viewerInfo: z.lazy(() => AnnouncementViewerInfo$inboundSchema).optional(), sourceDocument: Document$inboundSchema.optional(), isPublished: z.boolean().optional(), }); export function announcementFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Announcement$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Announcement' from JSON`, ); }