/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: d9b7aedd4e1f */ import * as z from "zod/v4"; import { safeParse } from "../lib/schemas.js"; import { ClosedEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; /** * Command states in the Commands protocol lifecycle */ export const CommandState = { PendingUpload: "PENDING_UPLOAD", Pending: "PENDING", Dispatched: "DISPATCHED", Succeeded: "SUCCEEDED", Failed: "FAILED", Expired: "EXPIRED", } as const; /** * Command states in the Commands protocol lifecycle */ export type CommandState = ClosedEnum; /** * Delivery mode for this command (push/pull), derived from the target at creation time */ export const CommandDeploymentModel = { Push: "push", Pull: "pull", } as const; /** * Delivery mode for this command (push/pull), derived from the target at creation time */ export type CommandDeploymentModel = ClosedEnum; /** * The kind of command-capable resource a command targets. */ export const CommandResourceType = { Worker: "worker", Container: "container", Daemon: "daemon", } as const; /** * The kind of command-capable resource a command targets. */ export type CommandResourceType = ClosedEnum; /** * Resource the command is addressed to; null on commands created before target routing */ export type CommandTarget = { /** * The resource ID within the deployment's stack (e.g. a Worker/Container/Daemon id). */ resourceId: string; /** * The kind of command-capable resource a command targets. */ resourceType: CommandResourceType; }; /** * Whether a successful operation result is included or withheld pending explicit confirmation */ export const CommandResultAvailability = { Available: "available", Protected: "protected", } as const; /** * Whether a successful operation result is included or withheld pending explicit confirmation */ export type CommandResultAvailability = ClosedEnum< typeof CommandResultAvailability >; export type Command = { /** * Unique identifier for the command. */ id: string; /** * Unique identifier for the deployment. */ deploymentId: string; /** * Unique identifier for the project. */ projectId: string; /** * Unique identifier for the workspace. */ workspaceId: string; /** * Command name (e.g., 'analyze-repository', 'sync-data') */ name: string; /** * Command states in the Commands protocol lifecycle */ state: CommandState; /** * Delivery mode for this command (push/pull), derived from the target at creation time */ deploymentModel: CommandDeploymentModel; /** * Resource the command is addressed to; null on commands created before target routing */ target: CommandTarget | null; /** * Current attempt number */ attempt: number | null; /** * Optional deadline for command execution */ deadline: Date | null; /** * Size of command params in bytes */ requestSizeBytes: number | null; /** * Size of command response in bytes */ responseSizeBytes: number | null; /** * When the command was created */ createdAt: Date; /** * When the command was dispatched to the deployment */ dispatchedAt: Date | null; /** * When the command completed */ completedAt: Date | null; /** * Error details if command failed */ error: { [k: string]: any | null } | null; /** * Decoded command result when available */ result?: any | null | undefined; /** * Whether a successful operation result is included or withheld pending explicit confirmation */ resultAvailability?: CommandResultAvailability | undefined; }; /** @internal */ export const CommandState$inboundSchema: z.ZodEnum = z .enum(CommandState); /** @internal */ export const CommandDeploymentModel$inboundSchema: z.ZodEnum< typeof CommandDeploymentModel > = z.enum(CommandDeploymentModel); /** @internal */ export const CommandResourceType$inboundSchema: z.ZodEnum< typeof CommandResourceType > = z.enum(CommandResourceType); /** @internal */ export const CommandTarget$inboundSchema: z.ZodType = z .object({ resourceId: z.string(), resourceType: CommandResourceType$inboundSchema, }); export function commandTargetFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CommandTarget$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CommandTarget' from JSON`, ); } /** @internal */ export const CommandResultAvailability$inboundSchema: z.ZodEnum< typeof CommandResultAvailability > = z.enum(CommandResultAvailability); /** @internal */ export const Command$inboundSchema: z.ZodType = z.object({ id: z.string(), deploymentId: z.string(), projectId: z.string(), workspaceId: z.string(), name: z.string(), state: CommandState$inboundSchema, deploymentModel: CommandDeploymentModel$inboundSchema, target: z.nullable(z.lazy(() => CommandTarget$inboundSchema)), attempt: z.nullable(z.number()), deadline: z.nullable( z.iso.datetime({ offset: true }).transform(v => new Date(v)), ), requestSizeBytes: z.nullable(z.number()), responseSizeBytes: z.nullable(z.number()), createdAt: z.iso.datetime({ offset: true }).transform(v => new Date(v)), dispatchedAt: z.nullable( z.iso.datetime({ offset: true }).transform(v => new Date(v)), ), completedAt: z.nullable( z.iso.datetime({ offset: true }).transform(v => new Date(v)), ), error: z.nullable(z.record(z.string(), z.nullable(z.any()))), result: z.nullable(z.any()).optional(), resultAvailability: CommandResultAvailability$inboundSchema.optional(), }); export function commandFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Command$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Command' from JSON`, ); }