/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { TopicDto, TopicDto$inboundSchema } from "./topicdto.js"; /** * The subscriber information */ export type SubscriptionDtoSubscriber = { /** * The identifier of the subscriber */ id: string; /** * The external identifier of the subscriber */ subscriberId: string; /** * The avatar URL of the subscriber */ avatar?: string | null | undefined; /** * The first name of the subscriber */ firstName?: string | null | undefined; /** * The last name of the subscriber */ lastName?: string | null | undefined; /** * The email of the subscriber */ email?: string | null | undefined; }; export type SubscriptionDto = { /** * The unique identifier of the subscription */ id: string; /** * The identifier of the subscription */ identifier?: string | undefined; /** * The topic information */ topic: TopicDto; /** * The subscriber information */ subscriber: SubscriptionDtoSubscriber | null; /** * Context keys that scope this subscription (e.g., tenant:org-a, project:proj-123) */ contextKeys?: Array | undefined; /** * The creation date of the subscription */ createdAt: string; /** * The last update date of the subscription */ updatedAt: string; }; /** @internal */ export const SubscriptionDtoSubscriber$inboundSchema: z.ZodType< SubscriptionDtoSubscriber, z.ZodTypeDef, unknown > = z.object({ _id: z.string(), subscriberId: z.string(), avatar: z.nullable(z.string()).optional(), firstName: z.nullable(z.string()).optional(), lastName: z.nullable(z.string()).optional(), email: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "_id": "id", }); }); export function subscriptionDtoSubscriberFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubscriptionDtoSubscriber$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubscriptionDtoSubscriber' from JSON`, ); } /** @internal */ export const SubscriptionDto$inboundSchema: z.ZodType< SubscriptionDto, z.ZodTypeDef, unknown > = z.object({ _id: z.string(), identifier: z.string().optional(), topic: TopicDto$inboundSchema, subscriber: z.nullable(z.lazy(() => SubscriptionDtoSubscriber$inboundSchema)), contextKeys: z.array(z.string()).optional(), createdAt: z.string(), updatedAt: z.string(), }).transform((v) => { return remap$(v, { "_id": "id", }); }); export function subscriptionDtoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubscriptionDto$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubscriptionDto' from JSON`, ); }