/* * 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 { SubscriptionPreferenceDto, SubscriptionPreferenceDto$inboundSchema, } from "./subscriptionpreferencedto.js"; import { TopicDto, TopicDto$inboundSchema } from "./topicdto.js"; /** * The subscriber information */ export type Subscriber = { /** * 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 SubscriptionResponseDto = { /** * The unique identifier of the subscription */ id: string; /** * The identifier of the subscription */ identifier?: string | undefined; /** * The name of the subscription */ name?: string | undefined; /** * The topic information */ topic: TopicDto; /** * The subscriber information */ subscriber: Subscriber | null; /** * The preferences for workflows in this subscription */ preferences?: Array | undefined; /** * 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 Subscriber$inboundSchema: z.ZodType< Subscriber, 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 subscriberFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Subscriber$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Subscriber' from JSON`, ); } /** @internal */ export const SubscriptionResponseDto$inboundSchema: z.ZodType< SubscriptionResponseDto, z.ZodTypeDef, unknown > = z.object({ _id: z.string(), identifier: z.string().optional(), name: z.string().optional(), topic: TopicDto$inboundSchema, subscriber: z.nullable(z.lazy(() => Subscriber$inboundSchema)), preferences: z.array(SubscriptionPreferenceDto$inboundSchema).optional(), contextKeys: z.array(z.string()).optional(), createdAt: z.string(), updatedAt: z.string(), }).transform((v) => { return remap$(v, { "_id": "id", }); }); export function subscriptionResponseDtoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubscriptionResponseDto$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubscriptionResponseDto' from JSON`, ); }