/* * 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 { CommandTrigger, CommandTrigger$inboundSchema, CommandTrigger$outboundSchema, } from "./commandtrigger.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; export type Command = { sendUpdatesToClient?: boolean | undefined; updateScheduledTask?: boolean | undefined; completionMessage?: string | null | undefined; requiresDiskAccess?: boolean | undefined; isExclusive?: boolean | undefined; isTypeExclusive?: boolean | undefined; name?: string | null | undefined; lastExecutionTime?: Date | null | undefined; lastStartTime?: Date | null | undefined; trigger?: CommandTrigger | undefined; suppressMessages?: boolean | undefined; clientUserAgent?: string | null | undefined; }; /** @internal */ export const Command$inboundSchema: z.ZodType = z.object({ sendUpdatesToClient: z.boolean().optional(), updateScheduledTask: z.boolean().optional(), completionMessage: z.nullable(z.string()).optional(), requiresDiskAccess: z.boolean().optional(), isExclusive: z.boolean().optional(), isTypeExclusive: z.boolean().optional(), name: z.nullable(z.string()).optional(), lastExecutionTime: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), lastStartTime: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), trigger: CommandTrigger$inboundSchema.optional(), suppressMessages: z.boolean().optional(), clientUserAgent: z.nullable(z.string()).optional(), }); /** @internal */ export type Command$Outbound = { sendUpdatesToClient?: boolean | undefined; updateScheduledTask?: boolean | undefined; completionMessage?: string | null | undefined; requiresDiskAccess?: boolean | undefined; isExclusive?: boolean | undefined; isTypeExclusive?: boolean | undefined; name?: string | null | undefined; lastExecutionTime?: string | null | undefined; lastStartTime?: string | null | undefined; trigger?: string | undefined; suppressMessages?: boolean | undefined; clientUserAgent?: string | null | undefined; }; /** @internal */ export const Command$outboundSchema: z.ZodType< Command$Outbound, z.ZodTypeDef, Command > = z.object({ sendUpdatesToClient: z.boolean().optional(), updateScheduledTask: z.boolean().optional(), completionMessage: z.nullable(z.string()).optional(), requiresDiskAccess: z.boolean().optional(), isExclusive: z.boolean().optional(), isTypeExclusive: z.boolean().optional(), name: z.nullable(z.string()).optional(), lastExecutionTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), lastStartTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), trigger: CommandTrigger$outboundSchema.optional(), suppressMessages: z.boolean().optional(), clientUserAgent: z.nullable(z.string()).optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Command$ { /** @deprecated use `Command$inboundSchema` instead. */ export const inboundSchema = Command$inboundSchema; /** @deprecated use `Command$outboundSchema` instead. */ export const outboundSchema = Command$outboundSchema; /** @deprecated use `Command$Outbound` instead. */ export type Outbound = Command$Outbound; } export function commandToJSON(command: Command): string { return JSON.stringify(Command$outboundSchema.parse(command)); } export function commandFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Command$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Command' from JSON`, ); }