/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 5b4abba4bc69 */ 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 { CommandDeploymentInfo, CommandDeploymentInfo$inboundSchema, } from "./commanddeploymentinfo.js"; import { CommandProjectInfo, CommandProjectInfo$inboundSchema, } from "./commandprojectinfo.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; /** * Command states in the Commands protocol lifecycle */ export const CommandListItemResponseState = { PendingUpload: "PENDING_UPLOAD", Pending: "PENDING", Dispatched: "DISPATCHED", Succeeded: "SUCCEEDED", Failed: "FAILED", Expired: "EXPIRED", } as const; /** * Command states in the Commands protocol lifecycle */ export type CommandListItemResponseState = ClosedEnum< typeof CommandListItemResponseState >; /** * Delivery mode for this command (push/pull), derived from the target at creation time */ export const CommandListItemResponseDeploymentModel = { Push: "push", Pull: "pull", } as const; /** * Delivery mode for this command (push/pull), derived from the target at creation time */ export type CommandListItemResponseDeploymentModel = ClosedEnum< typeof CommandListItemResponseDeploymentModel >; /** * The kind of command-capable resource a command targets. */ export const CommandListItemResponseResourceType = { Worker: "worker", Container: "container", Daemon: "daemon", } as const; /** * The kind of command-capable resource a command targets. */ export type CommandListItemResponseResourceType = ClosedEnum< typeof CommandListItemResponseResourceType >; /** * Resource the command is addressed to; null on commands created before target routing */ export type CommandListItemResponseTarget = { /** * 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: CommandListItemResponseResourceType; }; /** * Whether a successful operation result is included or withheld pending explicit confirmation */ export const CommandListItemResponseResultAvailability = { Available: "available", Protected: "protected", } as const; /** * Whether a successful operation result is included or withheld pending explicit confirmation */ export type CommandListItemResponseResultAvailability = ClosedEnum< typeof CommandListItemResponseResultAvailability >; export type CommandListItemResponse = { /** * 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: CommandListItemResponseState; /** * Delivery mode for this command (push/pull), derived from the target at creation time */ deploymentModel: CommandListItemResponseDeploymentModel; /** * Resource the command is addressed to; null on commands created before target routing */ target: CommandListItemResponseTarget | 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?: CommandListItemResponseResultAvailability | undefined; deployment?: CommandDeploymentInfo | undefined; project?: CommandProjectInfo | undefined; }; /** @internal */ export const CommandListItemResponseState$inboundSchema: z.ZodEnum< typeof CommandListItemResponseState > = z.enum(CommandListItemResponseState); /** @internal */ export const CommandListItemResponseDeploymentModel$inboundSchema: z.ZodEnum< typeof CommandListItemResponseDeploymentModel > = z.enum(CommandListItemResponseDeploymentModel); /** @internal */ export const CommandListItemResponseResourceType$inboundSchema: z.ZodEnum< typeof CommandListItemResponseResourceType > = z.enum(CommandListItemResponseResourceType); /** @internal */ export const CommandListItemResponseTarget$inboundSchema: z.ZodType< CommandListItemResponseTarget, unknown > = z.object({ resourceId: z.string(), resourceType: CommandListItemResponseResourceType$inboundSchema, }); export function commandListItemResponseTargetFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CommandListItemResponseTarget$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CommandListItemResponseTarget' from JSON`, ); } /** @internal */ export const CommandListItemResponseResultAvailability$inboundSchema: z.ZodEnum< typeof CommandListItemResponseResultAvailability > = z.enum(CommandListItemResponseResultAvailability); /** @internal */ export const CommandListItemResponse$inboundSchema: z.ZodType< CommandListItemResponse, unknown > = z.object({ id: z.string(), deploymentId: z.string(), projectId: z.string(), workspaceId: z.string(), name: z.string(), state: CommandListItemResponseState$inboundSchema, deploymentModel: CommandListItemResponseDeploymentModel$inboundSchema, target: z.nullable(z.lazy(() => CommandListItemResponseTarget$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: CommandListItemResponseResultAvailability$inboundSchema .optional(), deployment: CommandDeploymentInfo$inboundSchema.optional(), project: CommandProjectInfo$inboundSchema.optional(), }); export function commandListItemResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CommandListItemResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CommandListItemResponse' from JSON`, ); }