/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { safeParse } from "../lib/schemas.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { Command, Command$inboundSchema, Command$Outbound, Command$outboundSchema, } from "./command.js"; import { CommandPriority, CommandPriority$inboundSchema, CommandPriority$outboundSchema, } from "./commandpriority.js"; import { CommandStatus, CommandStatus$inboundSchema, CommandStatus$outboundSchema, } from "./commandstatus.js"; import { CommandTrigger, CommandTrigger$inboundSchema, CommandTrigger$outboundSchema, } from "./commandtrigger.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; export type CommandResource = { id?: number | undefined; name?: string | null | undefined; commandName?: string | null | undefined; message?: string | null | undefined; body?: Command | undefined; priority?: CommandPriority | undefined; status?: CommandStatus | undefined; queued?: Date | undefined; started?: Date | null | undefined; ended?: Date | null | undefined; duration?: string | null | undefined; exception?: string | null | undefined; trigger?: CommandTrigger | undefined; clientUserAgent?: string | null | undefined; stateChangeTime?: Date | null | undefined; sendUpdatesToClient?: boolean | undefined; updateScheduledTask?: boolean | undefined; lastExecutionTime?: Date | null | undefined; }; /** @internal */ export const CommandResource$inboundSchema: z.ZodType< CommandResource, z.ZodTypeDef, unknown > = z.object({ id: z.number().int().optional(), name: z.nullable(z.string()).optional(), commandName: z.nullable(z.string()).optional(), message: z.nullable(z.string()).optional(), body: Command$inboundSchema.optional(), priority: CommandPriority$inboundSchema.optional(), status: CommandStatus$inboundSchema.optional(), queued: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), started: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), ended: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), duration: z.nullable(z.string()).optional(), exception: z.nullable(z.string()).optional(), trigger: CommandTrigger$inboundSchema.optional(), clientUserAgent: z.nullable(z.string()).optional(), stateChangeTime: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), sendUpdatesToClient: z.boolean().optional(), updateScheduledTask: z.boolean().optional(), lastExecutionTime: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }); /** @internal */ export type CommandResource$Outbound = { id?: number | undefined; name?: string | null | undefined; commandName?: string | null | undefined; message?: string | null | undefined; body?: Command$Outbound | undefined; priority?: string | undefined; status?: string | undefined; queued?: string | undefined; started?: string | null | undefined; ended?: string | null | undefined; duration?: string | null | undefined; exception?: string | null | undefined; trigger?: string | undefined; clientUserAgent?: string | null | undefined; stateChangeTime?: string | null | undefined; sendUpdatesToClient?: boolean | undefined; updateScheduledTask?: boolean | undefined; lastExecutionTime?: string | null | undefined; }; /** @internal */ export const CommandResource$outboundSchema: z.ZodType< CommandResource$Outbound, z.ZodTypeDef, CommandResource > = z.object({ id: z.number().int().optional(), name: z.nullable(z.string()).optional(), commandName: z.nullable(z.string()).optional(), message: z.nullable(z.string()).optional(), body: Command$outboundSchema.optional(), priority: CommandPriority$outboundSchema.optional(), status: CommandStatus$outboundSchema.optional(), queued: z.date().transform(v => v.toISOString()).optional(), started: z.nullable(z.date().transform(v => v.toISOString())).optional(), ended: z.nullable(z.date().transform(v => v.toISOString())).optional(), duration: z.nullable(z.string()).optional(), exception: z.nullable(z.string()).optional(), trigger: CommandTrigger$outboundSchema.optional(), clientUserAgent: z.nullable(z.string()).optional(), stateChangeTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), sendUpdatesToClient: z.boolean().optional(), updateScheduledTask: z.boolean().optional(), lastExecutionTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CommandResource$ { /** @deprecated use `CommandResource$inboundSchema` instead. */ export const inboundSchema = CommandResource$inboundSchema; /** @deprecated use `CommandResource$outboundSchema` instead. */ export const outboundSchema = CommandResource$outboundSchema; /** @deprecated use `CommandResource$Outbound` instead. */ export type Outbound = CommandResource$Outbound; } export function commandResourceToJSON( commandResource: CommandResource, ): string { return JSON.stringify(CommandResource$outboundSchema.parse(commandResource)); } export function commandResourceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CommandResource$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CommandResource' from JSON`, ); }