/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 67bd9ea10330 */ import * as z from "zod/v4"; import { safeParse } from "../lib/schemas.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { DeploymentPortalManagedDnsRecord, DeploymentPortalManagedDnsRecord$inboundSchema, } from "./deploymentportalmanageddnsrecord.js"; import { DomainEndpointKind, DomainEndpointKind$inboundSchema, } from "./domainendpointkind.js"; import { DomainEndpointOwner, DomainEndpointOwner$inboundSchema, } from "./domainendpointowner.js"; import { DomainEndpointStatus, DomainEndpointStatus$inboundSchema, } from "./domainendpointstatus.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; /** * Canonical error container that provides a structured way to represent errors * * @remarks * with rich metadata including error codes, human-readable messages, context, * and chaining capabilities for error propagation. * * This struct is designed to be both machine-readable and user-friendly, * supporting serialization for API responses and detailed error reporting * in distributed systems. */ export type DomainEndpointError = { /** * A unique identifier for the type of error. * * @remarks * * This should be a short, machine-readable string that can be used * by clients to programmatically handle different error types. * Examples: "NOT_FOUND", "VALIDATION_ERROR", "TIMEOUT" */ code: string; /** * Additional diagnostic information about the error context. * * @remarks * * This optional field can contain structured data providing more details * about the error, such as validation errors, request parameters that * caused the issue, or other relevant context information. */ context?: any | null | undefined; /** * Optional human-facing remediation hint. */ hint?: string | null | undefined; /** * HTTP status code for this error. * * @remarks * * Used when converting the error to an HTTP response. If None, falls back to * the error type's default status code or 500. */ httpStatusCode?: number | null | undefined; /** * Indicates if this is an internal error that should not be exposed to users. * * @remarks * * When `true`, this error contains sensitive information or implementation * details that should not be shown to end-users. Such errors should be * logged for debugging but replaced with generic error messages in responses. */ internal: boolean; /** * Human-readable error message. * * @remarks * * This message should be clear and actionable for developers or end-users, * providing context about what went wrong and potentially how to fix it. */ message: string; /** * Indicates whether the operation that caused the error should be retried. * * @remarks * * When `true`, the error is transient and the operation might succeed * if attempted again. When `false`, retrying the same operation is * unlikely to succeed without changes. */ retryable: boolean; /** * The underlying error that caused this error, creating an error chain. * * @remarks * * This allows for proper error propagation and debugging by maintaining * the full context of how an error occurred through multiple layers * of an application. */ source?: any | null | undefined; }; export type DomainEndpoint = { /** * Unique identifier for the domain endpoint. */ id: string; /** * Unique identifier for the workspace. */ workspaceId: string; /** * Unique identifier for the domain. */ domainId: string; kind: DomainEndpointKind; owner: DomainEndpointOwner; hostname: string; status: DomainEndpointStatus; provider?: string | null | undefined; providerState?: { [k: string]: any | null } | null | undefined; managedDnsRecords: Array; /** * Canonical error container that provides a structured way to represent errors * * @remarks * with rich metadata including error codes, human-readable messages, context, * and chaining capabilities for error propagation. * * This struct is designed to be both machine-readable and user-friendly, * supporting serialization for API responses and detailed error reporting * in distributed systems. */ error?: DomainEndpointError | null | undefined; lockedAt?: Date | null | undefined; lockedBy?: string | null | undefined; retryAttempts: number; nextStepAfter?: Date | null | undefined; createdAt: Date; updatedAt: Date; }; /** @internal */ export const DomainEndpointError$inboundSchema: z.ZodType< DomainEndpointError, unknown > = z.object({ code: z.string(), context: z.nullable(z.any()).optional(), hint: z.nullable(z.string()).optional(), httpStatusCode: z.nullable(z.int()).optional(), internal: z.boolean(), message: z.string(), retryable: z.boolean().default(false), source: z.nullable(z.any()).optional(), }); export function domainEndpointErrorFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DomainEndpointError$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DomainEndpointError' from JSON`, ); } /** @internal */ export const DomainEndpoint$inboundSchema: z.ZodType = z.object({ id: z.string(), workspaceId: z.string(), domainId: z.string(), kind: DomainEndpointKind$inboundSchema, owner: DomainEndpointOwner$inboundSchema, hostname: z.string(), status: DomainEndpointStatus$inboundSchema, provider: z.nullable(z.string()).optional(), providerState: z.nullable(z.record(z.string(), z.nullable(z.any()))) .optional(), managedDnsRecords: z.array(DeploymentPortalManagedDnsRecord$inboundSchema), error: z.nullable(z.lazy(() => DomainEndpointError$inboundSchema)) .optional(), lockedAt: z.nullable( z.iso.datetime({ offset: true }).transform(v => new Date(v)), ).optional(), lockedBy: z.nullable(z.string()).optional(), retryAttempts: z.int(), nextStepAfter: z.nullable( z.iso.datetime({ offset: true }).transform(v => new Date(v)), ).optional(), createdAt: z.iso.datetime({ offset: true }).transform(v => new Date(v)), updatedAt: z.iso.datetime({ offset: true }).transform(v => new Date(v)), }); export function domainEndpointFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DomainEndpoint$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DomainEndpoint' from JSON`, ); }