/* * 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"; export type Tenant = { /** * User-defined system ID for the tenant. */ id?: string | undefined; /** * Number of destinations associated with the tenant. */ destinationsCount?: number | undefined; /** * List of subscribed topics across all destinations for this tenant. */ topics?: Array | undefined; /** * Arbitrary key-value pairs for storing contextual information about the tenant. */ metadata?: { [k: string]: string } | null | undefined; /** * ISO Date when the tenant was created. */ createdAt?: Date | undefined; /** * ISO Date when the tenant was last updated. */ updatedAt?: Date | undefined; }; /** @internal */ export const Tenant$inboundSchema: z.ZodType = z .object({ id: z.string().optional(), destinations_count: z.number().int().optional(), topics: z.array(z.string()).optional(), metadata: z.nullable(z.record(z.string())).optional(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ).optional(), updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ).optional(), }).transform((v) => { return remap$(v, { "destinations_count": "destinationsCount", "created_at": "createdAt", "updated_at": "updatedAt", }); }); /** @internal */ export type Tenant$Outbound = { id?: string | undefined; destinations_count?: number | undefined; topics?: Array | undefined; metadata?: { [k: string]: string } | null | undefined; created_at?: string | undefined; updated_at?: string | undefined; }; /** @internal */ export const Tenant$outboundSchema: z.ZodType< Tenant$Outbound, z.ZodTypeDef, Tenant > = z.object({ id: z.string().optional(), destinationsCount: z.number().int().optional(), topics: z.array(z.string()).optional(), metadata: z.nullable(z.record(z.string())).optional(), createdAt: z.date().transform(v => v.toISOString()).optional(), updatedAt: z.date().transform(v => v.toISOString()).optional(), }).transform((v) => { return remap$(v, { destinationsCount: "destinations_count", createdAt: "created_at", updatedAt: "updated_at", }); }); export function tenantToJSON(tenant: Tenant): string { return JSON.stringify(Tenant$outboundSchema.parse(tenant)); } export function tenantFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Tenant$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Tenant' from JSON`, ); }