/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { remap as remap$ } from "../lib/primitives.js";
import { safeParse } from "../lib/schemas.js";
import { ClosedEnum } from "../types/enums.js";
import { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import { smartUnion } from "../types/smartUnion.js";
import { FlagJSONValue, FlagJSONValue$inboundSchema } from "./flagjsonvalue.js";
import {
  CancelDeploymentRoutes,
  CancelDeploymentRoutes$inboundSchema,
  IncludeFiles,
  IncludeFiles$inboundSchema,
  Services2,
  Services2$inboundSchema,
  ServicesType,
  ServicesType$inboundSchema,
  Trigger,
  Trigger$inboundSchema,
} from "./includefiles.js";
import {
  AliasAssignedAt,
  AliasAssignedAt$inboundSchema,
  AliasError,
  AliasError$inboundSchema,
  AliasWarning,
  AliasWarning$inboundSchema,
  Atproto,
  Atproto$inboundSchema,
  Build,
  Build$inboundSchema,
  Builds,
  Builds$inboundSchema,
  CancelDeploymentCreator,
  CancelDeploymentCreator$inboundSchema,
  CancelDeploymentCustomEnvironment,
  CancelDeploymentCustomEnvironment$inboundSchema,
  CancelDeploymentGitSource,
  CancelDeploymentGitSource$inboundSchema,
  CancelDeploymentNodeVersion,
  CancelDeploymentNodeVersion$inboundSchema,
  CancelDeploymentPlan,
  CancelDeploymentPlan$inboundSchema,
  CancelDeploymentProject,
  CancelDeploymentProject$inboundSchema,
  CancelDeploymentProjectSettings,
  CancelDeploymentProjectSettings$inboundSchema,
  CancelDeploymentResourceConfig,
  CancelDeploymentResourceConfig$inboundSchema,
  CancelDeploymentSource,
  CancelDeploymentSource$inboundSchema,
  CancelDeploymentStatus,
  CancelDeploymentStatus$inboundSchema,
  CancelDeploymentTarget,
  CancelDeploymentTarget$inboundSchema,
  CancelDeploymentTeam,
  CancelDeploymentTeam$inboundSchema,
  CancelDeploymentType,
  CancelDeploymentType$inboundSchema,
  ChecksConclusion,
  ChecksConclusion$inboundSchema,
  ChecksState,
  ChecksState$inboundSchema,
  Crons,
  Crons$inboundSchema,
  Functions,
  Functions$inboundSchema,
  Images,
  Images$inboundSchema,
  Integrations,
  Integrations$inboundSchema,
  Lambdas,
  Lambdas$inboundSchema,
  ManualProvisioning,
  ManualProvisioning$inboundSchema,
  OidcTokenClaims,
  OidcTokenClaims$inboundSchema,
  OomReport,
  OomReport$inboundSchema,
  ReadyState,
  ReadyState$inboundSchema,
  ReadySubstate,
  ReadySubstate$inboundSchema,
} from "./locale.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export type ExcludeFiles = string | Array<string>;

export const CancelDeploymentServicesArchitecture = {
  Arm64: "arm64",
  X8664: "x86_64",
} as const;
export type CancelDeploymentServicesArchitecture = ClosedEnum<
  typeof CancelDeploymentServicesArchitecture
>;

export const CancelDeploymentMaxDurationDeploymentsResponse2 = {
  Max: "max",
} as const;
export type CancelDeploymentMaxDurationDeploymentsResponse2 = ClosedEnum<
  typeof CancelDeploymentMaxDurationDeploymentsResponse2
>;

export type CancelDeploymentServicesMaxDuration =
  | number
  | CancelDeploymentMaxDurationDeploymentsResponse2;

export const CancelDeploymentServicesMode = {
  Strict: "strict",
} as const;
export type CancelDeploymentServicesMode = ClosedEnum<
  typeof CancelDeploymentServicesMode
>;

export type CancelDeploymentServicesAffinity = {
  mode: CancelDeploymentServicesMode;
};

export type CancelDeploymentExperimentalTriggersDeploymentsResponse3 = {
  /**
   * Event type - must be "schedule/v1beta" (REQUIRED)
   */
  type: "schedule/v1beta";
};

/**
 * Queue trigger input event for v2beta (from vercel.json config). Consumer name is implicitly derived from the function path. Only one trigger per function is allowed.
 */
export type CancelDeploymentExperimentalTriggersDeploymentsResponse2 = {
  /**
   * Event type - must be "queue/v2beta" (REQUIRED)
   */
  type: "queue/v2beta";
  /**
   * Name of the queue topic to consume from (REQUIRED)
   */
  topic: string;
  /**
   * Maximum number of delivery attempts for message processing (OPTIONAL) This represents the total number of times a message can be delivered, not the number of retries. Must be at least 1 if specified. Behavior when not specified depends on the server's default configuration.
   */
  maxDeliveries?: number | undefined;
  /**
   * Delay in seconds before retrying failed executions (OPTIONAL) Behavior when not specified depends on the server's default configuration.
   */
  retryAfterSeconds?: number | undefined;
  /**
   * Initial delay in seconds before first execution attempt (OPTIONAL) Must be 0 or greater. Use 0 for no initial delay. Behavior when not specified depends on the server's default configuration.
   */
  initialDelaySeconds?: number | undefined;
  /**
   * Maximum number of concurrent executions for this consumer (OPTIONAL) Must be at least 1 if specified. Behavior when not specified depends on the server's default configuration.
   */
  maxConcurrency?: number | undefined;
};

/**
 * Queue trigger input event for v1beta (from vercel.json config). Requires explicit consumer name.
 */
export type CancelDeploymentExperimentalTriggersDeploymentsResponse1 = {
  /**
   * Event type - must be "queue/v1beta" (REQUIRED)
   */
  type: "queue/v1beta";
  /**
   * Name of the consumer group for this trigger (REQUIRED)
   */
  consumer: string;
  /**
   * Name of the queue topic to consume from (REQUIRED)
   */
  topic: string;
  /**
   * Maximum number of delivery attempts for message processing (OPTIONAL) This represents the total number of times a message can be delivered, not the number of retries. Must be at least 1 if specified. Behavior when not specified depends on the server's default configuration.
   */
  maxDeliveries?: number | undefined;
  /**
   * Delay in seconds before retrying failed executions (OPTIONAL) Behavior when not specified depends on the server's default configuration.
   */
  retryAfterSeconds?: number | undefined;
  /**
   * Initial delay in seconds before first execution attempt (OPTIONAL) Must be 0 or greater. Use 0 for no initial delay. Behavior when not specified depends on the server's default configuration.
   */
  initialDelaySeconds?: number | undefined;
  /**
   * Maximum number of concurrent executions for this consumer (OPTIONAL) Must be at least 1 if specified. Behavior when not specified depends on the server's default configuration.
   */
  maxConcurrency?: number | undefined;
};

export type CancelDeploymentServicesExperimentalTriggers =
  | CancelDeploymentExperimentalTriggersDeploymentsResponse1
  | CancelDeploymentExperimentalTriggersDeploymentsResponse2
  | CancelDeploymentExperimentalTriggersDeploymentsResponse3;

export type CancelDeploymentServicesFunctions = {
  architecture?: CancelDeploymentServicesArchitecture | undefined;
  memory?: number | undefined;
  maxDuration?:
    | number
    | CancelDeploymentMaxDurationDeploymentsResponse2
    | undefined;
  affinity?: CancelDeploymentServicesAffinity | undefined;
  maxConcurrency?: number | undefined;
  regions?: Array<string> | undefined;
  functionFailoverRegions?: Array<string> | undefined;
  runtime?: string | undefined;
  includeFiles?: string | undefined;
  excludeFiles?: string | undefined;
  experimentalTriggers?:
    | Array<
      | CancelDeploymentExperimentalTriggersDeploymentsResponse1
      | CancelDeploymentExperimentalTriggersDeploymentsResponse2
      | CancelDeploymentExperimentalTriggersDeploymentsResponse3
    >
    | undefined;
  supportsCancellation?: boolean | undefined;
};

export type ServicesProjectSettings = {
  framework?: string | null | undefined;
  devCommand?: string | null | undefined;
  installCommand?: string | null | undefined;
  buildCommand?: string | null | undefined;
  outputDirectory?: string | null | undefined;
  rootDirectory?: string | null | undefined;
  nodeVersion?: string | undefined;
  monorepoManager?: string | null | undefined;
  createdAt?: number | undefined;
  autoExposeSystemEnvs?: boolean | undefined;
  sourceFilesOutsideRootDirectory?: boolean | undefined;
  directoryListing?: boolean | undefined;
  gitForkProtection?: boolean | undefined;
  commandForIgnoringBuildStep?: string | null | undefined;
};

/**
 * Enforced runtime for explicitly configured Routing Middleware.
 */
export const MiddlewareRuntime = {
  Nodejs: "nodejs",
} as const;
/**
 * Enforced runtime for explicitly configured Routing Middleware.
 */
export type MiddlewareRuntime = ClosedEnum<typeof MiddlewareRuntime>;

export type MiddlewareMatcher = string | Array<string>;

export type ServicesConfig = {
  bunVersion?: string | undefined;
  maxLambdaSize?: string | undefined;
  includeFiles?: IncludeFiles | undefined;
  excludeFiles?: string | Array<string> | undefined;
  bundle?: boolean | undefined;
  ldsflags?: string | undefined;
  helpers?: boolean | undefined;
  rust?: string | undefined;
  debug?: boolean | undefined;
  zeroConfig?: boolean | undefined;
  import?: { [k: string]: string } | undefined;
  functions?: { [k: string]: CancelDeploymentServicesFunctions } | undefined;
  projectSettings?: ServicesProjectSettings | undefined;
  outputDirectory?: string | undefined;
  installCommand?: string | undefined;
  buildCommand?: string | undefined;
  devCommand?: string | undefined;
  framework?: string | null | undefined;
  nodeVersion?: string | undefined;
  middleware?: boolean | undefined;
  /**
   * Enforced runtime for explicitly configured Routing Middleware.
   */
  middlewareRuntime?: MiddlewareRuntime | undefined;
  middlewareMatcher?: string | Array<string> | undefined;
  /**
   * Owning service name; scopes per-function config such as the v2beta consumer.
   */
  serviceName?: string | undefined;
  /**
   * Buildpack runtime slug (e.g. "ruby").
   */
  buildpack?: string | undefined;
};

export type Builder = {
  use: string;
  src?: string | undefined;
  config?: ServicesConfig | undefined;
};

export const RoutePrefixSource = {
  Configured: "configured",
  Generated: "generated",
} as const;
export type RoutePrefixSource = ClosedEnum<typeof RoutePrefixSource>;

export type Schedule = string | Array<string>;

export type Topics2 = {
  topic: string;
  retryAfterSeconds?: number | undefined;
  initialDelaySeconds?: number | undefined;
};

export type Topics = Array<string> | Array<Topics2>;

export const CancelDeploymentServicesType = {
  ServiceRef: "service-ref",
} as const;
export type CancelDeploymentServicesType = ClosedEnum<
  typeof CancelDeploymentServicesType
>;

export type ServicesEnv = {
  type: CancelDeploymentServicesType;
  service: string;
};

/**
 * Services detected during build from vercel.json experimentalServices or auto-detected from project structure. Used to inject service URLs as environment variables at runtime.
 */
export type Services1 = {
  schema: "experimentalServices";
  name: string;
  type: ServicesType;
  trigger?: Trigger | undefined;
  group?: string | undefined;
  workspace: string;
  entrypoint?: string | undefined;
  framework?: string | undefined;
  builder: Builder;
  runtime?: string | undefined;
  buildCommand?: string | undefined;
  installCommand?: string | undefined;
  preDeployCommand?: string | undefined;
  routePrefix?: string | undefined;
  routePrefixSource?: RoutePrefixSource | undefined;
  subdomain?: string | undefined;
  schedule?: string | Array<string> | undefined;
  handlerFunction?: string | undefined;
  topics?: Array<string> | Array<Topics2> | undefined;
  env?: { [k: string]: ServicesEnv } | undefined;
};

export type Services = Services1 | Services2;

export const CancelDeploymentGitRepoDeploymentsResponseOwnerType = {
  Team: "team",
  User: "user",
} as const;
export type CancelDeploymentGitRepoDeploymentsResponseOwnerType = ClosedEnum<
  typeof CancelDeploymentGitRepoDeploymentsResponseOwnerType
>;

export type GitRepo5 = {
  /**
   * Owner (namespace) slug.
   */
  owner: string;
  repo: string;
  /**
   * Origin repository id.
   */
  repoId: string;
  type: "cursor-origin";
  path: string;
  defaultBranch: string;
  name: string;
  private: boolean;
  ownerType: CancelDeploymentGitRepoDeploymentsResponseOwnerType;
};

export const CancelDeploymentGitRepoDeploymentsOwnerType = {
  Team: "team",
  User: "user",
} as const;
export type CancelDeploymentGitRepoDeploymentsOwnerType = ClosedEnum<
  typeof CancelDeploymentGitRepoDeploymentsOwnerType
>;

export type GitRepo4 = {
  org: string;
  repo: string;
  type: "vercel";
  path: string;
  defaultBranch: string;
  name: string;
  private: boolean;
  ownerType: CancelDeploymentGitRepoDeploymentsOwnerType;
};

export const CancelDeploymentGitRepoOwnerType = {
  Team: "team",
  User: "user",
} as const;
export type CancelDeploymentGitRepoOwnerType = ClosedEnum<
  typeof CancelDeploymentGitRepoOwnerType
>;

export type GitRepo3 = {
  owner: string;
  repoUuid: string;
  slug: string;
  type: "bitbucket";
  workspaceUuid: string;
  path: string;
  defaultBranch: string;
  name: string;
  private: boolean;
  ownerType: CancelDeploymentGitRepoOwnerType;
};

export const GitRepoOwnerType = {
  Team: "team",
  User: "user",
} as const;
export type GitRepoOwnerType = ClosedEnum<typeof GitRepoOwnerType>;

export type GitRepo2 = {
  org: string;
  repo: string;
  repoId: number;
  type: "github";
  repoOwnerId: number;
  path: string;
  defaultBranch: string;
  name: string;
  private: boolean;
  ownerType: GitRepoOwnerType;
};

export const OwnerType = {
  Team: "team",
  User: "user",
} as const;
export type OwnerType = ClosedEnum<typeof OwnerType>;

export type GitRepo1 = {
  namespace: string;
  projectId: number;
  type: "gitlab";
  url: string;
  path: string;
  defaultBranch: string;
  name: string;
  private: boolean;
  ownerType: OwnerType;
};

export type GitRepo = GitRepo1 | GitRepo2 | GitRepo3 | GitRepo4 | GitRepo5;

/**
 * Flags defined in the Build Output API, used by this deployment. Primarily used by the Toolbar to know about the used flags.
 */
export type Flags2 = {};

export type FlagsOptions = {
  value: FlagJSONValue | null;
  label?: string | undefined;
};

export type FlagsDefinitions = {
  options?: Array<FlagsOptions> | undefined;
  url?: string | undefined;
  description?: string | undefined;
};

/**
 * Flags defined in the Build Output API, used by this deployment. Primarily used by the Toolbar to know about the used flags.
 */
export type Flags1 = {
  definitions: { [k: string]: FlagsDefinitions };
};

export type Flags = Flags1 | Array<Flags2>;

/**
 * The result of the microfrontends config upload during deployment creation / build. Only set for default app deployments. The config upload is attempted during deployment create, and then again during the build. If the config is not in the root directory, or the deployment is prebuilt, the config cannot be uploaded during deployment create. The upload during deployment build finds the config even if it's not in the root directory, as it has access to all files. Uploading the config during create is ideal, as then all child deployments are guaranteed to have access to the default app deployment config even if the default app has not yet started building. If the config is not uploaded, the child app will show as building until the config has been uploaded during the default app build. - `success` - The config was uploaded successfully, either when the deployment was created or during the build. - `waiting_on_build` - The config could not be uploaded during deployment create, will be attempted again during the build. - `no_config` - No config was found. Only set once the build has not found the config in any of the deployment's files. - `undefined` - Legacy deployments, or there was an error uploading the config during deployment create.
 */
export const MfeConfigUploadState = {
  NoConfig: "no_config",
  Success: "success",
  WaitingOnBuild: "waiting_on_build",
} as const;
/**
 * The result of the microfrontends config upload during deployment creation / build. Only set for default app deployments. The config upload is attempted during deployment create, and then again during the build. If the config is not in the root directory, or the deployment is prebuilt, the config cannot be uploaded during deployment create. The upload during deployment build finds the config even if it's not in the root directory, as it has access to all files. Uploading the config during create is ideal, as then all child deployments are guaranteed to have access to the default app deployment config even if the default app has not yet started building. If the config is not uploaded, the child app will show as building until the config has been uploaded during the default app build. - `success` - The config was uploaded successfully, either when the deployment was created or during the build. - `waiting_on_build` - The config could not be uploaded during deployment create, will be attempted again during the build. - `no_config` - No config was found. Only set once the build has not found the config in any of the deployment's files. - `undefined` - Legacy deployments, or there was an error uploading the config during deployment create.
 */
export type MfeConfigUploadState = ClosedEnum<typeof MfeConfigUploadState>;

export type CancelDeploymentMicrofrontends2 = {
  isDefaultApp: true;
  /**
   * The result of the microfrontends config upload during deployment creation / build. Only set for default app deployments. The config upload is attempted during deployment create, and then again during the build. If the config is not in the root directory, or the deployment is prebuilt, the config cannot be uploaded during deployment create. The upload during deployment build finds the config even if it's not in the root directory, as it has access to all files. Uploading the config during create is ideal, as then all child deployments are guaranteed to have access to the default app deployment config even if the default app has not yet started building. If the config is not uploaded, the child app will show as building until the config has been uploaded during the default app build. - `success` - The config was uploaded successfully, either when the deployment was created or during the build. - `waiting_on_build` - The config could not be uploaded during deployment create, will be attempted again during the build. - `no_config` - No config was found. Only set once the build has not found the config in any of the deployment's files. - `undefined` - Legacy deployments, or there was an error uploading the config during deployment create.
   */
  mfeConfigUploadState?: MfeConfigUploadState | undefined;
  /**
   * The project name of the default app of this deployment's microfrontends group.
   */
  defaultAppProjectName: string;
  /**
   * A path that is used to take screenshots and as the default path in preview links when a domain for this microfrontend is shown in the UI.
   */
  defaultRoute?: string | undefined;
  /**
   * The group of microfrontends that this project belongs to. Each microfrontend project must belong to a microfrontends group that is the set of microfrontends that are used together.
   */
  groupIds: Array<string>;
};

export type CancelDeploymentMicrofrontends1 = {
  isDefaultApp?: false | undefined;
  /**
   * The project name of the default app of this deployment's microfrontends group.
   */
  defaultAppProjectName: string;
  /**
   * A path that is used to take screenshots and as the default path in preview links when a domain for this microfrontend is shown in the UI.
   */
  defaultRoute?: string | undefined;
  /**
   * The group of microfrontends that this project belongs to. Each microfrontend project must belong to a microfrontends group that is the set of microfrontends that are used together.
   */
  groupIds: Array<string>;
};

export type CancelDeploymentMicrofrontends =
  | CancelDeploymentMicrofrontends2
  | CancelDeploymentMicrofrontends1;

/**
 * The external platform that created the deployment (e.g. its display name).
 */
export type CancelDeploymentDeploymentsSource = {
  /**
   * Display name of the platform.
   */
  name: string;
};

/**
 * Whether the value is an opaque identifier or a URL.
 */
export const CancelDeploymentDeploymentsResponseType = {
  Id: "id",
  Url: "url",
} as const;
/**
 * Whether the value is an opaque identifier or a URL.
 */
export type CancelDeploymentDeploymentsResponseType = ClosedEnum<
  typeof CancelDeploymentDeploymentsResponseType
>;

/**
 * Reference back to the entity on the platform that initiated the deployment.
 */
export type CancelDeploymentOrigin = {
  /**
   * Whether the value is an opaque identifier or a URL.
   */
  type: CancelDeploymentDeploymentsResponseType;
  /**
   * The identifier or URL pointing to the originating entity.
   */
  value: string;
};

/**
 * The user on the external platform who triggered the deployment.
 */
export type CancelDeploymentDeploymentsCreator = {
  /**
   * Display name of the platform user.
   */
  name: string;
  /**
   * URL of the platform user's avatar image.
   */
  avatar?: string | undefined;
};

/**
 * Metadata about the source platform that triggered the deployment. Allows us to map a deployment back to a platform (e.g. the chat that created it)
 */
export type Platform = {
  /**
   * The external platform that created the deployment (e.g. its display name).
   */
  source: CancelDeploymentDeploymentsSource;
  /**
   * Reference back to the entity on the platform that initiated the deployment.
   */
  origin: CancelDeploymentOrigin;
  /**
   * The user on the external platform who triggered the deployment.
   */
  creator: CancelDeploymentDeploymentsCreator;
  /**
   * Arbitrary key-value metadata provided by the platform.
   */
  meta?: { [k: string]: string } | undefined;
};

export const FunctionType = {
  Fluid: "fluid",
  Standard: "standard",
} as const;
export type FunctionType = ClosedEnum<typeof FunctionType>;

export const FunctionMemoryType = {
  Performance: "performance",
  PerformanceXl: "performance_xl",
  Standard: "standard",
  StandardLegacy: "standard_legacy",
} as const;
export type FunctionMemoryType = ClosedEnum<typeof FunctionMemoryType>;

/**
 * Build resource configuration snapshot for this deployment.
 */
export const CancelDeploymentConfiguration = {
  SkipNamespaceQueue: "SKIP_NAMESPACE_QUEUE",
  WaitForNamespaceQueue: "WAIT_FOR_NAMESPACE_QUEUE",
} as const;
/**
 * Build resource configuration snapshot for this deployment.
 */
export type CancelDeploymentConfiguration = ClosedEnum<
  typeof CancelDeploymentConfiguration
>;

/**
 * Build resource configuration snapshot for this deployment.
 */
export type CancelDeploymentBuildQueue = {
  /**
   * Build resource configuration snapshot for this deployment.
   */
  configuration?: CancelDeploymentConfiguration | undefined;
};

/**
 * When elastic concurrency is used for this deployment, a value is set. The value tells the reason where the setting was coming from. - TEAM_SETTING: Inherited from team settings - PROJECT_SETTING: Inherited from project settings - SKIP_QUEUE: Manually triggered by user to skip the queues
 */
export const ElasticConcurrency = {
  ProjectSetting: "PROJECT_SETTING",
  SkipQueue: "SKIP_QUEUE",
  TeamSetting: "TEAM_SETTING",
} as const;
/**
 * When elastic concurrency is used for this deployment, a value is set. The value tells the reason where the setting was coming from. - TEAM_SETTING: Inherited from team settings - PROJECT_SETTING: Inherited from project settings - SKIP_QUEUE: Manually triggered by user to skip the queues
 */
export type ElasticConcurrency = ClosedEnum<typeof ElasticConcurrency>;

/**
 * Machine type that was used for the build.
 */
export const CancelDeploymentPurchaseType = {
  Basic: "basic",
  Enhanced: "enhanced",
  Standard: "standard",
  Turbo: "turbo",
} as const;
/**
 * Machine type that was used for the build.
 */
export type CancelDeploymentPurchaseType = ClosedEnum<
  typeof CancelDeploymentPurchaseType
>;

export type CancelDeploymentDeploymentsBuildMachine = {
  /**
   * Machine type that was used for the build.
   */
  purchaseType?: CancelDeploymentPurchaseType | null | undefined;
};

/**
 * Build resource configuration snapshot for this deployment.
 */
export type CancelDeploymentDeploymentsResourceConfig = {
  /**
   * Build resource configuration snapshot for this deployment.
   */
  buildQueue?: CancelDeploymentBuildQueue | undefined;
  /**
   * When elastic concurrency is used for this deployment, a value is set. The value tells the reason where the setting was coming from. - TEAM_SETTING: Inherited from team settings - PROJECT_SETTING: Inherited from project settings - SKIP_QUEUE: Manually triggered by user to skip the queues
   */
  elasticConcurrency?: ElasticConcurrency | undefined;
  buildMachine?: CancelDeploymentDeploymentsBuildMachine | undefined;
};

/**
 * Since February 2025 the configuration must include snapshot data at the time of deployment creation to capture properties for the /deployments/:id/config endpoint utilized for displaying Deployment Configuration on the frontend This is optional because older deployments may not have this data captured
 */
export type CancelDeploymentConfig = {
  version?: number | undefined;
  functionType: FunctionType;
  functionMemoryType: FunctionMemoryType;
  functionTimeout: number | null;
  secureComputePrimaryRegion: string | null;
  secureComputeFallbackRegion: string | null;
  isUsingActiveCPU?: boolean | undefined;
  /**
   * Build resource configuration snapshot for this deployment.
   */
  resourceConfig?: CancelDeploymentDeploymentsResourceConfig | undefined;
};

export const CancelDeploymentDeploymentsState = {
  Failed: "failed",
  Pending: "pending",
  Succeeded: "succeeded",
} as const;
export type CancelDeploymentDeploymentsState = ClosedEnum<
  typeof CancelDeploymentDeploymentsState
>;

/**
 * Condensed check data. Retrieve individual check and check run data using api-checks v2 routes.
 */
export type DeploymentAlias = {
  state: CancelDeploymentDeploymentsState;
  startedAt: number;
  completedAt?: number | undefined;
};

export type CancelDeploymentChecks = {
  /**
   * Condensed check data. Retrieve individual check and check run data using api-checks v2 routes.
   */
  deploymentAlias: DeploymentAlias;
};

/**
 * The NSNB decision code for the seat block. TODO: We should consolidate block types.
 */
export const BlockCode = {
  CommitAuthorRequired: "COMMIT_AUTHOR_REQUIRED",
  TeamAccessRequired: "TEAM_ACCESS_REQUIRED",
} as const;
/**
 * The NSNB decision code for the seat block. TODO: We should consolidate block types.
 */
export type BlockCode = ClosedEnum<typeof BlockCode>;

export type CancelDeploymentGitUserId = string | number;

/**
 * The git provider type associated with gitUserId.
 */
export const CancelDeploymentGitProvider = {
  Bitbucket: "bitbucket",
  Github: "github",
  Gitlab: "gitlab",
} as const;
/**
 * The git provider type associated with gitUserId.
 */
export type CancelDeploymentGitProvider = ClosedEnum<
  typeof CancelDeploymentGitProvider
>;

/**
 * NSNB Blocked metadata
 */
export type SeatBlock = {
  /**
   * The NSNB decision code for the seat block. TODO: We should consolidate block types.
   */
  blockCode: BlockCode;
  /**
   * The blocked vercel user ID.
   */
  userId?: string | undefined;
  /**
   * Determines if the user was verified during the block. In the git integration case, the commit sender was the author.
   */
  isVerified?: boolean | undefined;
  gitUserId?: string | number | undefined;
  /**
   * The git provider type associated with gitUserId.
   */
  gitProvider?: CancelDeploymentGitProvider | undefined;
};

/**
 * Commit metadata from the git commit author
 */
export type CommitMeta = {
  /**
   * Email from git commit author
   */
  email?: string | undefined;
  /**
   * Name from git commit author
   */
  name?: string | undefined;
  /**
   * Whether the commit was signed/verified (GitHub only, others return undefined)
   */
  isVerified?: boolean | undefined;
};

export type CancelDeploymentId = string | number;

/**
 * Git provider user associated with the commit author email (only set if resolved)
 */
export type GitUser = {
  id: string | number;
  /**
   * Git provider username/login
   */
  login: string;
  /**
   * User type
   */
  type?: string | undefined;
  /**
   * The git provider (github, gitlab, bitbucket)
   */
  provider?: string | undefined;
};

/**
 * Vercel user linked to the git provider account (only set if resolved)
 */
export type VercelUser = {
  /**
   * Vercel user ID
   */
  id: string;
  /**
   * Vercel username
   */
  username: string;
  /**
   * Team roles at time of deployment
   */
  teamRoles?: Array<string> | undefined;
};

/**
 * Attribution metadata for the deployment, linking commit author to git and Vercel users. Only populated when the `enable-deployment-attribution` flag is enabled.
 */
export type CancelDeploymentAttribution = {
  /**
   * Commit metadata from the git commit author
   */
  commitMeta?: CommitMeta | undefined;
  /**
   * Git provider user associated with the commit author email (only set if resolved)
   */
  gitUser?: GitUser | undefined;
  /**
   * Vercel user linked to the git provider account (only set if resolved)
   */
  vercelUser?: VercelUser | undefined;
};

/**
 * Returns the updated deployment object with `readyState` set to `CANCELED`. The build has been stopped and this action is irreversible.
 */
export type CancelDeploymentResponseBody = {
  aliasAssignedAt?: AliasAssignedAt | null | undefined;
  alwaysRefuseToBuild?: boolean | undefined;
  build: Build;
  buildArtifactUrls?: Array<string> | undefined;
  builds?: Array<Builds> | undefined;
  env: Array<string>;
  resourceConfig?: CancelDeploymentResourceConfig | undefined;
  inspectorUrl: string | null;
  isInConcurrentBuildsQueue: boolean;
  isInSystemBuildsQueue: boolean;
  projectSettings: CancelDeploymentProjectSettings;
  integrations?: Integrations | undefined;
  images?: Images | undefined;
  /**
   * A list of all the aliases (default aliases, staging aliases and production aliases) that were assigned upon deployment creation
   */
  alias?: Array<string> | undefined;
  /**
   * A boolean that will be true when the aliases from the alias property were assigned successfully
   */
  aliasAssigned: boolean;
  bootedAt: number;
  buildingAt: number;
  /**
   * Since April 2025 it necessary for On-Demand Concurrency Minutes calculation
   */
  buildContainerFinishedAt?: number | undefined;
  buildSkipped: boolean;
  /**
   * Information about the deployment creator
   */
  creator: CancelDeploymentCreator;
  initReadyAt?: number | undefined;
  isFirstBranchDeployment?: boolean | undefined;
  lambdas?: Array<Lambdas> | undefined;
  /**
   * A boolean representing if the deployment is public or not. By default this is `false`
   */
  public: boolean;
  ready?: number | undefined;
  status: CancelDeploymentStatus;
  /**
   * The team that owns the deployment if any
   */
  team?: CancelDeploymentTeam | undefined;
  /**
   * An array of domains that were provided by the user when creating the Deployment.
   */
  userAliases?: Array<string> | undefined;
  /**
   * Whether or not preview comments are enabled for the deployment
   */
  previewCommentsEnabled?: boolean | undefined;
  ttyBuildLogs?: boolean | undefined;
  customEnvironment?: CancelDeploymentCustomEnvironment | undefined;
  oomReport?: OomReport | undefined;
  readyStateReason?: string | undefined;
  /**
   * A string holding the unique ID of the deployment
   */
  id: string;
  /**
   * If defined, either `staging` if a staging alias in the format `<project>.<team>.now.sh` was assigned upon creation, or `production` if the aliases from `alias` were assigned. `null` value indicates the "preview" deployment.
   */
  target?: CancelDeploymentTarget | null | undefined;
  /**
   * The state of the deployment depending on the process of deploying, or if it is ready or in an error state
   */
  readyState: ReadyState;
  /**
   * An object that will contain a `code` and a `message` when the aliasing fails, otherwise the value will be `null`
   */
  aliasError?: AliasError | null | undefined;
  aliasWarning?: AliasWarning | null | undefined;
  errorCode?: string | undefined;
  errorMessage?: string | null | undefined;
  /**
   * A number containing the date when the deployment was created in milliseconds
   */
  createdAt: number;
  /**
   * The name of the project associated with the deployment at the time that the deployment was created
   */
  name: string;
  type: CancelDeploymentType;
  aliasFinal?: string | null | undefined;
  /**
   * applies to custom domains only, defaults to `true`
   */
  autoAssignCustomDomains?: boolean | undefined;
  automaticAliases?: Array<string> | undefined;
  buildErrorAt?: number | undefined;
  checksState?: ChecksState | undefined;
  checksConclusion?: ChecksConclusion | undefined;
  /**
   * A number containing the date when the deployment was deleted at milliseconds
   */
  deletedAt?: number | null | undefined;
  /**
   * Computed field that is only available for deployments with a microfrontend configuration.
   */
  defaultRoute?: string | undefined;
  canceledAt?: number | undefined;
  errorLink?: string | undefined;
  errorStep?: string | undefined;
  /**
   * Since November 2023 this field defines a set of regions that we will deploy the lambda to passively Lambdas will be deployed to these regions but only invoked if all of the primary `regions` are marked as out of service
   */
  passiveRegions?: Array<string> | undefined;
  gitSource?: CancelDeploymentGitSource | undefined;
  /**
   * Present when deployment was created with manual provisioning enabled, either explicitly or via the experimental BYOC git flow. The deployment stays in INITIALIZING until /continue is called.
   */
  manualProvisioning?: ManualProvisioning | undefined;
  meta: { [k: string]: string };
  originCacheRegion?: string | undefined;
  /**
   * If set it overrides the `projectSettings.nodeVersion` for this deployment.
   */
  nodeVersion?: CancelDeploymentNodeVersion | undefined;
  /**
   * The public project information associated with the deployment.
   */
  project?: CancelDeploymentProject | undefined;
  prebuilt?: boolean | undefined;
  /**
   * Substate of deployment when readyState is 'READY' Tracks whether or not deployment has seen production traffic: - STAGED: never seen production traffic - ROLLING: in the process of having production traffic gradually transitioned. - PROMOTED: has seen production traffic
   */
  readySubstate?: ReadySubstate | undefined;
  /**
   * The regions the deployment exists in
   */
  regions: Array<string>;
  /**
   * flag to indicate if the deployment was deleted by retention policy
   */
  softDeletedByRetention?: boolean | undefined;
  /**
   * Where was the deployment created from. Best-effort guess for metrics only — not authoritative; do not gate behavior on it.
   */
  source?: CancelDeploymentSource | undefined;
  /**
   * A number containing the date when the deployment was undeleted at milliseconds
   */
  undeletedAt?: number | undefined;
  /**
   * A string with the unique URL of the deployment
   */
  url: string;
  /**
   * Since January 2025 User-configured deployment ID for skew protection with pre-built deployments. This is set when users configure a custom deploymentId in their next.config.js file. This allows Next.js to use skew protection even when deployments are pre-built outside of Vercel's build system.
   */
  userConfiguredDeploymentId?: string | undefined;
  /**
   * The platform version that was used to create the deployment.
   */
  version: number;
  oidcTokenClaims?: OidcTokenClaims | undefined;
  projectId: string;
  plan: CancelDeploymentPlan;
  connectBuildsEnabled?: boolean | undefined;
  connectConfigurationId?: string | undefined;
  createdIn: string;
  crons?: Array<Crons> | undefined;
  atproto?: Atproto | undefined;
  functions?: { [k: string]: Functions } | null | undefined;
  /**
   * Whether this deployment completed through the instant static fast path.
   */
  isInstantStatic?: boolean | undefined;
  monorepoManager?: string | null | undefined;
  ownerId: string;
  /**
   * Since November 2023 this field defines a Secure Compute network that will only be used to deploy passive lambdas to (as in passiveRegions)
   */
  passiveConnectConfigurationId?: string | undefined;
  routes: Array<CancelDeploymentRoutes> | null;
  /**
   * Services detected during build from vercel.json experimentalServices or auto-detected from project structure. Used to inject service URLs as environment variables at runtime.
   */
  services?: Array<Services1 | Services2> | undefined;
  gitRepo?:
    | GitRepo1
    | GitRepo2
    | GitRepo3
    | GitRepo4
    | GitRepo5
    | null
    | undefined;
  flags?: Flags1 | Array<Flags2> | undefined;
  microfrontends?:
    | CancelDeploymentMicrofrontends2
    | CancelDeploymentMicrofrontends1
    | undefined;
  /**
   * Metadata about the source platform that triggered the deployment. Allows us to map a deployment back to a platform (e.g. the chat that created it)
   */
  platform?: Platform | undefined;
  /**
   * Since February 2025 the configuration must include snapshot data at the time of deployment creation to capture properties for the /deployments/:id/config endpoint utilized for displaying Deployment Configuration on the frontend This is optional because older deployments may not have this data captured
   */
  config?: CancelDeploymentConfig | undefined;
  checks?: CancelDeploymentChecks | undefined;
  /**
   * NSNB Blocked metadata
   */
  seatBlock?: SeatBlock | undefined;
  /**
   * Attribution metadata for the deployment, linking commit author to git and Vercel users. Only populated when the `enable-deployment-attribution` flag is enabled.
   */
  attribution?: CancelDeploymentAttribution | undefined;
};

/** @internal */
export const ExcludeFiles$inboundSchema: z.ZodType<
  ExcludeFiles,
  z.ZodTypeDef,
  unknown
> = smartUnion([types.string(), z.array(types.string())]);

export function excludeFilesFromJSON(
  jsonString: string,
): SafeParseResult<ExcludeFiles, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ExcludeFiles$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ExcludeFiles' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentServicesArchitecture$inboundSchema:
  z.ZodNativeEnum<typeof CancelDeploymentServicesArchitecture> = z.nativeEnum(
    CancelDeploymentServicesArchitecture,
  );

/** @internal */
export const CancelDeploymentMaxDurationDeploymentsResponse2$inboundSchema:
  z.ZodNativeEnum<typeof CancelDeploymentMaxDurationDeploymentsResponse2> = z
    .nativeEnum(CancelDeploymentMaxDurationDeploymentsResponse2);

/** @internal */
export const CancelDeploymentServicesMaxDuration$inboundSchema: z.ZodType<
  CancelDeploymentServicesMaxDuration,
  z.ZodTypeDef,
  unknown
> = smartUnion([
  types.number(),
  CancelDeploymentMaxDurationDeploymentsResponse2$inboundSchema,
]);

export function cancelDeploymentServicesMaxDurationFromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentServicesMaxDuration, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) =>
      CancelDeploymentServicesMaxDuration$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentServicesMaxDuration' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentServicesMode$inboundSchema: z.ZodNativeEnum<
  typeof CancelDeploymentServicesMode
> = z.nativeEnum(CancelDeploymentServicesMode);

/** @internal */
export const CancelDeploymentServicesAffinity$inboundSchema: z.ZodType<
  CancelDeploymentServicesAffinity,
  z.ZodTypeDef,
  unknown
> = z.object({
  mode: CancelDeploymentServicesMode$inboundSchema,
});

export function cancelDeploymentServicesAffinityFromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentServicesAffinity, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CancelDeploymentServicesAffinity$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentServicesAffinity' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentExperimentalTriggersDeploymentsResponse3$inboundSchema:
  z.ZodType<
    CancelDeploymentExperimentalTriggersDeploymentsResponse3,
    z.ZodTypeDef,
    unknown
  > = z.object({
    type: types.literal("schedule/v1beta"),
  });

export function cancelDeploymentExperimentalTriggersDeploymentsResponse3FromJSON(
  jsonString: string,
): SafeParseResult<
  CancelDeploymentExperimentalTriggersDeploymentsResponse3,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      CancelDeploymentExperimentalTriggersDeploymentsResponse3$inboundSchema
        .parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentExperimentalTriggersDeploymentsResponse3' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentExperimentalTriggersDeploymentsResponse2$inboundSchema:
  z.ZodType<
    CancelDeploymentExperimentalTriggersDeploymentsResponse2,
    z.ZodTypeDef,
    unknown
  > = z.object({
    type: types.literal("queue/v2beta"),
    topic: types.string(),
    maxDeliveries: types.optional(types.number()),
    retryAfterSeconds: types.optional(types.number()),
    initialDelaySeconds: types.optional(types.number()),
    maxConcurrency: types.optional(types.number()),
  });

export function cancelDeploymentExperimentalTriggersDeploymentsResponse2FromJSON(
  jsonString: string,
): SafeParseResult<
  CancelDeploymentExperimentalTriggersDeploymentsResponse2,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      CancelDeploymentExperimentalTriggersDeploymentsResponse2$inboundSchema
        .parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentExperimentalTriggersDeploymentsResponse2' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentExperimentalTriggersDeploymentsResponse1$inboundSchema:
  z.ZodType<
    CancelDeploymentExperimentalTriggersDeploymentsResponse1,
    z.ZodTypeDef,
    unknown
  > = z.object({
    type: types.literal("queue/v1beta"),
    consumer: types.string(),
    topic: types.string(),
    maxDeliveries: types.optional(types.number()),
    retryAfterSeconds: types.optional(types.number()),
    initialDelaySeconds: types.optional(types.number()),
    maxConcurrency: types.optional(types.number()),
  });

export function cancelDeploymentExperimentalTriggersDeploymentsResponse1FromJSON(
  jsonString: string,
): SafeParseResult<
  CancelDeploymentExperimentalTriggersDeploymentsResponse1,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      CancelDeploymentExperimentalTriggersDeploymentsResponse1$inboundSchema
        .parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentExperimentalTriggersDeploymentsResponse1' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentServicesExperimentalTriggers$inboundSchema:
  z.ZodType<
    CancelDeploymentServicesExperimentalTriggers,
    z.ZodTypeDef,
    unknown
  > = z.union([
    z.lazy(() =>
      CancelDeploymentExperimentalTriggersDeploymentsResponse1$inboundSchema
    ),
    z.lazy(() =>
      CancelDeploymentExperimentalTriggersDeploymentsResponse2$inboundSchema
    ),
    z.lazy(() =>
      CancelDeploymentExperimentalTriggersDeploymentsResponse3$inboundSchema
    ),
  ]);

export function cancelDeploymentServicesExperimentalTriggersFromJSON(
  jsonString: string,
): SafeParseResult<
  CancelDeploymentServicesExperimentalTriggers,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      CancelDeploymentServicesExperimentalTriggers$inboundSchema.parse(
        JSON.parse(x),
      ),
    `Failed to parse 'CancelDeploymentServicesExperimentalTriggers' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentServicesFunctions$inboundSchema: z.ZodType<
  CancelDeploymentServicesFunctions,
  z.ZodTypeDef,
  unknown
> = z.object({
  architecture: types.optional(
    CancelDeploymentServicesArchitecture$inboundSchema,
  ),
  memory: types.optional(types.number()),
  maxDuration: types.optional(
    smartUnion([
      types.number(),
      CancelDeploymentMaxDurationDeploymentsResponse2$inboundSchema,
    ]),
  ),
  affinity: types.optional(
    z.lazy(() => CancelDeploymentServicesAffinity$inboundSchema),
  ),
  maxConcurrency: types.optional(types.number()),
  regions: types.optional(z.array(types.string())),
  functionFailoverRegions: types.optional(z.array(types.string())),
  runtime: types.optional(types.string()),
  includeFiles: types.optional(types.string()),
  excludeFiles: types.optional(types.string()),
  experimentalTriggers: types.optional(
    z.array(z.union([
      z.lazy(() =>
        CancelDeploymentExperimentalTriggersDeploymentsResponse1$inboundSchema
      ),
      z.lazy(() =>
        CancelDeploymentExperimentalTriggersDeploymentsResponse2$inboundSchema
      ),
      z.lazy(() =>
        CancelDeploymentExperimentalTriggersDeploymentsResponse3$inboundSchema
      ),
    ])),
  ),
  supportsCancellation: types.optional(types.boolean()),
});

export function cancelDeploymentServicesFunctionsFromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentServicesFunctions, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CancelDeploymentServicesFunctions$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentServicesFunctions' from JSON`,
  );
}

/** @internal */
export const ServicesProjectSettings$inboundSchema: z.ZodType<
  ServicesProjectSettings,
  z.ZodTypeDef,
  unknown
> = z.object({
  framework: z.nullable(types.string()).optional(),
  devCommand: z.nullable(types.string()).optional(),
  installCommand: z.nullable(types.string()).optional(),
  buildCommand: z.nullable(types.string()).optional(),
  outputDirectory: z.nullable(types.string()).optional(),
  rootDirectory: z.nullable(types.string()).optional(),
  nodeVersion: types.optional(types.string()),
  monorepoManager: z.nullable(types.string()).optional(),
  createdAt: types.optional(types.number()),
  autoExposeSystemEnvs: types.optional(types.boolean()),
  sourceFilesOutsideRootDirectory: types.optional(types.boolean()),
  directoryListing: types.optional(types.boolean()),
  gitForkProtection: types.optional(types.boolean()),
  commandForIgnoringBuildStep: z.nullable(types.string()).optional(),
});

export function servicesProjectSettingsFromJSON(
  jsonString: string,
): SafeParseResult<ServicesProjectSettings, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ServicesProjectSettings$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ServicesProjectSettings' from JSON`,
  );
}

/** @internal */
export const MiddlewareRuntime$inboundSchema: z.ZodNativeEnum<
  typeof MiddlewareRuntime
> = z.nativeEnum(MiddlewareRuntime);

/** @internal */
export const MiddlewareMatcher$inboundSchema: z.ZodType<
  MiddlewareMatcher,
  z.ZodTypeDef,
  unknown
> = smartUnion([types.string(), z.array(types.string())]);

export function middlewareMatcherFromJSON(
  jsonString: string,
): SafeParseResult<MiddlewareMatcher, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => MiddlewareMatcher$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'MiddlewareMatcher' from JSON`,
  );
}

/** @internal */
export const ServicesConfig$inboundSchema: z.ZodType<
  ServicesConfig,
  z.ZodTypeDef,
  unknown
> = z.object({
  bunVersion: types.optional(types.string()),
  maxLambdaSize: types.optional(types.string()),
  includeFiles: types.optional(IncludeFiles$inboundSchema),
  excludeFiles: types.optional(
    smartUnion([types.string(), z.array(types.string())]),
  ),
  bundle: types.optional(types.boolean()),
  ldsflags: types.optional(types.string()),
  helpers: types.optional(types.boolean()),
  rust: types.optional(types.string()),
  debug: types.optional(types.boolean()),
  zeroConfig: types.optional(types.boolean()),
  import: types.optional(z.record(types.string())),
  functions: types.optional(
    z.record(z.lazy(() => CancelDeploymentServicesFunctions$inboundSchema)),
  ),
  projectSettings: types.optional(
    z.lazy(() => ServicesProjectSettings$inboundSchema),
  ),
  outputDirectory: types.optional(types.string()),
  installCommand: types.optional(types.string()),
  buildCommand: types.optional(types.string()),
  devCommand: types.optional(types.string()),
  framework: z.nullable(types.string()).optional(),
  nodeVersion: types.optional(types.string()),
  middleware: types.optional(types.boolean()),
  middlewareRuntime: types.optional(MiddlewareRuntime$inboundSchema),
  middlewareMatcher: types.optional(
    smartUnion([types.string(), z.array(types.string())]),
  ),
  serviceName: types.optional(types.string()),
  buildpack: types.optional(types.string()),
});

export function servicesConfigFromJSON(
  jsonString: string,
): SafeParseResult<ServicesConfig, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ServicesConfig$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ServicesConfig' from JSON`,
  );
}

/** @internal */
export const Builder$inboundSchema: z.ZodType<Builder, z.ZodTypeDef, unknown> =
  z.object({
    use: types.string(),
    src: types.optional(types.string()),
    config: types.optional(z.lazy(() => ServicesConfig$inboundSchema)),
  });

export function builderFromJSON(
  jsonString: string,
): SafeParseResult<Builder, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Builder$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Builder' from JSON`,
  );
}

/** @internal */
export const RoutePrefixSource$inboundSchema: z.ZodNativeEnum<
  typeof RoutePrefixSource
> = z.nativeEnum(RoutePrefixSource);

/** @internal */
export const Schedule$inboundSchema: z.ZodType<
  Schedule,
  z.ZodTypeDef,
  unknown
> = smartUnion([types.string(), z.array(types.string())]);

export function scheduleFromJSON(
  jsonString: string,
): SafeParseResult<Schedule, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Schedule$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Schedule' from JSON`,
  );
}

/** @internal */
export const Topics2$inboundSchema: z.ZodType<Topics2, z.ZodTypeDef, unknown> =
  z.object({
    topic: types.string(),
    retryAfterSeconds: types.optional(types.number()),
    initialDelaySeconds: types.optional(types.number()),
  });

export function topics2FromJSON(
  jsonString: string,
): SafeParseResult<Topics2, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Topics2$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Topics2' from JSON`,
  );
}

/** @internal */
export const Topics$inboundSchema: z.ZodType<Topics, z.ZodTypeDef, unknown> =
  smartUnion([
    z.array(types.string()),
    z.array(z.lazy(() => Topics2$inboundSchema)),
  ]);

export function topicsFromJSON(
  jsonString: string,
): SafeParseResult<Topics, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Topics$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Topics' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentServicesType$inboundSchema: z.ZodNativeEnum<
  typeof CancelDeploymentServicesType
> = z.nativeEnum(CancelDeploymentServicesType);

/** @internal */
export const ServicesEnv$inboundSchema: z.ZodType<
  ServicesEnv,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: CancelDeploymentServicesType$inboundSchema,
  service: types.string(),
});

export function servicesEnvFromJSON(
  jsonString: string,
): SafeParseResult<ServicesEnv, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ServicesEnv$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ServicesEnv' from JSON`,
  );
}

/** @internal */
export const Services1$inboundSchema: z.ZodType<
  Services1,
  z.ZodTypeDef,
  unknown
> = z.object({
  schema: types.literal("experimentalServices"),
  name: types.string(),
  type: ServicesType$inboundSchema,
  trigger: types.optional(Trigger$inboundSchema),
  group: types.optional(types.string()),
  workspace: types.string(),
  entrypoint: types.optional(types.string()),
  framework: types.optional(types.string()),
  builder: z.lazy(() => Builder$inboundSchema),
  runtime: types.optional(types.string()),
  buildCommand: types.optional(types.string()),
  installCommand: types.optional(types.string()),
  preDeployCommand: types.optional(types.string()),
  routePrefix: types.optional(types.string()),
  routePrefixSource: types.optional(RoutePrefixSource$inboundSchema),
  subdomain: types.optional(types.string()),
  schedule: types.optional(
    smartUnion([types.string(), z.array(types.string())]),
  ),
  handlerFunction: types.optional(types.string()),
  topics: types.optional(
    smartUnion([
      z.array(types.string()),
      z.array(z.lazy(() => Topics2$inboundSchema)),
    ]),
  ),
  env: types.optional(z.record(z.lazy(() => ServicesEnv$inboundSchema))),
});

export function services1FromJSON(
  jsonString: string,
): SafeParseResult<Services1, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Services1$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Services1' from JSON`,
  );
}

/** @internal */
export const Services$inboundSchema: z.ZodType<
  Services,
  z.ZodTypeDef,
  unknown
> = z.union([z.lazy(() => Services1$inboundSchema), Services2$inboundSchema]);

export function servicesFromJSON(
  jsonString: string,
): SafeParseResult<Services, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Services$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Services' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentGitRepoDeploymentsResponseOwnerType$inboundSchema:
  z.ZodNativeEnum<typeof CancelDeploymentGitRepoDeploymentsResponseOwnerType> =
    z.nativeEnum(CancelDeploymentGitRepoDeploymentsResponseOwnerType);

/** @internal */
export const GitRepo5$inboundSchema: z.ZodType<
  GitRepo5,
  z.ZodTypeDef,
  unknown
> = z.object({
  owner: types.string(),
  repo: types.string(),
  repoId: types.string(),
  type: types.literal("cursor-origin"),
  path: types.string(),
  defaultBranch: types.string(),
  name: types.string(),
  private: types.boolean(),
  ownerType: CancelDeploymentGitRepoDeploymentsResponseOwnerType$inboundSchema,
});

export function gitRepo5FromJSON(
  jsonString: string,
): SafeParseResult<GitRepo5, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GitRepo5$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GitRepo5' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentGitRepoDeploymentsOwnerType$inboundSchema:
  z.ZodNativeEnum<typeof CancelDeploymentGitRepoDeploymentsOwnerType> = z
    .nativeEnum(CancelDeploymentGitRepoDeploymentsOwnerType);

/** @internal */
export const GitRepo4$inboundSchema: z.ZodType<
  GitRepo4,
  z.ZodTypeDef,
  unknown
> = z.object({
  org: types.string(),
  repo: types.string(),
  type: types.literal("vercel"),
  path: types.string(),
  defaultBranch: types.string(),
  name: types.string(),
  private: types.boolean(),
  ownerType: CancelDeploymentGitRepoDeploymentsOwnerType$inboundSchema,
});

export function gitRepo4FromJSON(
  jsonString: string,
): SafeParseResult<GitRepo4, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GitRepo4$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GitRepo4' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentGitRepoOwnerType$inboundSchema: z.ZodNativeEnum<
  typeof CancelDeploymentGitRepoOwnerType
> = z.nativeEnum(CancelDeploymentGitRepoOwnerType);

/** @internal */
export const GitRepo3$inboundSchema: z.ZodType<
  GitRepo3,
  z.ZodTypeDef,
  unknown
> = z.object({
  owner: types.string(),
  repoUuid: types.string(),
  slug: types.string(),
  type: types.literal("bitbucket"),
  workspaceUuid: types.string(),
  path: types.string(),
  defaultBranch: types.string(),
  name: types.string(),
  private: types.boolean(),
  ownerType: CancelDeploymentGitRepoOwnerType$inboundSchema,
});

export function gitRepo3FromJSON(
  jsonString: string,
): SafeParseResult<GitRepo3, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GitRepo3$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GitRepo3' from JSON`,
  );
}

/** @internal */
export const GitRepoOwnerType$inboundSchema: z.ZodNativeEnum<
  typeof GitRepoOwnerType
> = z.nativeEnum(GitRepoOwnerType);

/** @internal */
export const GitRepo2$inboundSchema: z.ZodType<
  GitRepo2,
  z.ZodTypeDef,
  unknown
> = z.object({
  org: types.string(),
  repo: types.string(),
  repoId: types.number(),
  type: types.literal("github"),
  repoOwnerId: types.number(),
  path: types.string(),
  defaultBranch: types.string(),
  name: types.string(),
  private: types.boolean(),
  ownerType: GitRepoOwnerType$inboundSchema,
});

export function gitRepo2FromJSON(
  jsonString: string,
): SafeParseResult<GitRepo2, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GitRepo2$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GitRepo2' from JSON`,
  );
}

/** @internal */
export const OwnerType$inboundSchema: z.ZodNativeEnum<typeof OwnerType> = z
  .nativeEnum(OwnerType);

/** @internal */
export const GitRepo1$inboundSchema: z.ZodType<
  GitRepo1,
  z.ZodTypeDef,
  unknown
> = z.object({
  namespace: types.string(),
  projectId: types.number(),
  type: types.literal("gitlab"),
  url: types.string(),
  path: types.string(),
  defaultBranch: types.string(),
  name: types.string(),
  private: types.boolean(),
  ownerType: OwnerType$inboundSchema,
});

export function gitRepo1FromJSON(
  jsonString: string,
): SafeParseResult<GitRepo1, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GitRepo1$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GitRepo1' from JSON`,
  );
}

/** @internal */
export const GitRepo$inboundSchema: z.ZodType<GitRepo, z.ZodTypeDef, unknown> =
  z.union([
    z.lazy(() => GitRepo1$inboundSchema),
    z.lazy(() => GitRepo2$inboundSchema),
    z.lazy(() => GitRepo3$inboundSchema),
    z.lazy(() => GitRepo4$inboundSchema),
    z.lazy(() => GitRepo5$inboundSchema),
  ]);

export function gitRepoFromJSON(
  jsonString: string,
): SafeParseResult<GitRepo, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GitRepo$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GitRepo' from JSON`,
  );
}

/** @internal */
export const Flags2$inboundSchema: z.ZodType<Flags2, z.ZodTypeDef, unknown> = z
  .object({});

export function flags2FromJSON(
  jsonString: string,
): SafeParseResult<Flags2, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Flags2$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Flags2' from JSON`,
  );
}

/** @internal */
export const FlagsOptions$inboundSchema: z.ZodType<
  FlagsOptions,
  z.ZodTypeDef,
  unknown
> = z.object({
  value: types.nullable(FlagJSONValue$inboundSchema),
  label: types.optional(types.string()),
});

export function flagsOptionsFromJSON(
  jsonString: string,
): SafeParseResult<FlagsOptions, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => FlagsOptions$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'FlagsOptions' from JSON`,
  );
}

/** @internal */
export const FlagsDefinitions$inboundSchema: z.ZodType<
  FlagsDefinitions,
  z.ZodTypeDef,
  unknown
> = z.object({
  options: types.optional(z.array(z.lazy(() => FlagsOptions$inboundSchema))),
  url: types.optional(types.string()),
  description: types.optional(types.string()),
});

export function flagsDefinitionsFromJSON(
  jsonString: string,
): SafeParseResult<FlagsDefinitions, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => FlagsDefinitions$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'FlagsDefinitions' from JSON`,
  );
}

/** @internal */
export const Flags1$inboundSchema: z.ZodType<Flags1, z.ZodTypeDef, unknown> = z
  .object({
    definitions: z.record(z.lazy(() => FlagsDefinitions$inboundSchema)),
  });

export function flags1FromJSON(
  jsonString: string,
): SafeParseResult<Flags1, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Flags1$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Flags1' from JSON`,
  );
}

/** @internal */
export const Flags$inboundSchema: z.ZodType<Flags, z.ZodTypeDef, unknown> =
  smartUnion([
    z.lazy(() => Flags1$inboundSchema),
    z.array(z.lazy(() => Flags2$inboundSchema)),
  ]);

export function flagsFromJSON(
  jsonString: string,
): SafeParseResult<Flags, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Flags$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Flags' from JSON`,
  );
}

/** @internal */
export const MfeConfigUploadState$inboundSchema: z.ZodNativeEnum<
  typeof MfeConfigUploadState
> = z.nativeEnum(MfeConfigUploadState);

/** @internal */
export const CancelDeploymentMicrofrontends2$inboundSchema: z.ZodType<
  CancelDeploymentMicrofrontends2,
  z.ZodTypeDef,
  unknown
> = z.object({
  isDefaultApp: types.literal(true),
  mfeConfigUploadState: types.optional(MfeConfigUploadState$inboundSchema),
  defaultAppProjectName: types.string(),
  defaultRoute: types.optional(types.string()),
  groupIds: z.array(types.string()),
});

export function cancelDeploymentMicrofrontends2FromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentMicrofrontends2, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CancelDeploymentMicrofrontends2$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentMicrofrontends2' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentMicrofrontends1$inboundSchema: z.ZodType<
  CancelDeploymentMicrofrontends1,
  z.ZodTypeDef,
  unknown
> = z.object({
  isDefaultApp: types.optional(types.literal(false)),
  defaultAppProjectName: types.string(),
  defaultRoute: types.optional(types.string()),
  groupIds: z.array(types.string()),
});

export function cancelDeploymentMicrofrontends1FromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentMicrofrontends1, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CancelDeploymentMicrofrontends1$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentMicrofrontends1' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentMicrofrontends$inboundSchema: z.ZodType<
  CancelDeploymentMicrofrontends,
  z.ZodTypeDef,
  unknown
> = smartUnion([
  z.lazy(() => CancelDeploymentMicrofrontends2$inboundSchema),
  z.lazy(() => CancelDeploymentMicrofrontends1$inboundSchema),
]);

export function cancelDeploymentMicrofrontendsFromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentMicrofrontends, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CancelDeploymentMicrofrontends$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentMicrofrontends' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentDeploymentsSource$inboundSchema: z.ZodType<
  CancelDeploymentDeploymentsSource,
  z.ZodTypeDef,
  unknown
> = z.object({
  name: types.string(),
});

export function cancelDeploymentDeploymentsSourceFromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentDeploymentsSource, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CancelDeploymentDeploymentsSource$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentDeploymentsSource' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentDeploymentsResponseType$inboundSchema:
  z.ZodNativeEnum<typeof CancelDeploymentDeploymentsResponseType> = z
    .nativeEnum(CancelDeploymentDeploymentsResponseType);

/** @internal */
export const CancelDeploymentOrigin$inboundSchema: z.ZodType<
  CancelDeploymentOrigin,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: CancelDeploymentDeploymentsResponseType$inboundSchema,
  value: types.string(),
});

export function cancelDeploymentOriginFromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentOrigin, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CancelDeploymentOrigin$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentOrigin' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentDeploymentsCreator$inboundSchema: z.ZodType<
  CancelDeploymentDeploymentsCreator,
  z.ZodTypeDef,
  unknown
> = z.object({
  name: types.string(),
  avatar: types.optional(types.string()),
});

export function cancelDeploymentDeploymentsCreatorFromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentDeploymentsCreator, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) =>
      CancelDeploymentDeploymentsCreator$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentDeploymentsCreator' from JSON`,
  );
}

/** @internal */
export const Platform$inboundSchema: z.ZodType<
  Platform,
  z.ZodTypeDef,
  unknown
> = z.object({
  source: z.lazy(() => CancelDeploymentDeploymentsSource$inboundSchema),
  origin: z.lazy(() => CancelDeploymentOrigin$inboundSchema),
  creator: z.lazy(() => CancelDeploymentDeploymentsCreator$inboundSchema),
  meta: types.optional(z.record(types.string())),
});

export function platformFromJSON(
  jsonString: string,
): SafeParseResult<Platform, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Platform$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Platform' from JSON`,
  );
}

/** @internal */
export const FunctionType$inboundSchema: z.ZodNativeEnum<typeof FunctionType> =
  z.nativeEnum(FunctionType);

/** @internal */
export const FunctionMemoryType$inboundSchema: z.ZodNativeEnum<
  typeof FunctionMemoryType
> = z.nativeEnum(FunctionMemoryType);

/** @internal */
export const CancelDeploymentConfiguration$inboundSchema: z.ZodNativeEnum<
  typeof CancelDeploymentConfiguration
> = z.nativeEnum(CancelDeploymentConfiguration);

/** @internal */
export const CancelDeploymentBuildQueue$inboundSchema: z.ZodType<
  CancelDeploymentBuildQueue,
  z.ZodTypeDef,
  unknown
> = z.object({
  configuration: types.optional(CancelDeploymentConfiguration$inboundSchema),
});

export function cancelDeploymentBuildQueueFromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentBuildQueue, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CancelDeploymentBuildQueue$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentBuildQueue' from JSON`,
  );
}

/** @internal */
export const ElasticConcurrency$inboundSchema: z.ZodNativeEnum<
  typeof ElasticConcurrency
> = z.nativeEnum(ElasticConcurrency);

/** @internal */
export const CancelDeploymentPurchaseType$inboundSchema: z.ZodNativeEnum<
  typeof CancelDeploymentPurchaseType
> = z.nativeEnum(CancelDeploymentPurchaseType);

/** @internal */
export const CancelDeploymentDeploymentsBuildMachine$inboundSchema: z.ZodType<
  CancelDeploymentDeploymentsBuildMachine,
  z.ZodTypeDef,
  unknown
> = z.object({
  purchaseType: z.nullable(CancelDeploymentPurchaseType$inboundSchema)
    .optional(),
});

export function cancelDeploymentDeploymentsBuildMachineFromJSON(
  jsonString: string,
): SafeParseResult<
  CancelDeploymentDeploymentsBuildMachine,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      CancelDeploymentDeploymentsBuildMachine$inboundSchema.parse(
        JSON.parse(x),
      ),
    `Failed to parse 'CancelDeploymentDeploymentsBuildMachine' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentDeploymentsResourceConfig$inboundSchema: z.ZodType<
  CancelDeploymentDeploymentsResourceConfig,
  z.ZodTypeDef,
  unknown
> = z.object({
  buildQueue: types.optional(
    z.lazy(() => CancelDeploymentBuildQueue$inboundSchema),
  ),
  elasticConcurrency: types.optional(ElasticConcurrency$inboundSchema),
  buildMachine: types.optional(
    z.lazy(() => CancelDeploymentDeploymentsBuildMachine$inboundSchema),
  ),
});

export function cancelDeploymentDeploymentsResourceConfigFromJSON(
  jsonString: string,
): SafeParseResult<
  CancelDeploymentDeploymentsResourceConfig,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      CancelDeploymentDeploymentsResourceConfig$inboundSchema.parse(
        JSON.parse(x),
      ),
    `Failed to parse 'CancelDeploymentDeploymentsResourceConfig' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentConfig$inboundSchema: z.ZodType<
  CancelDeploymentConfig,
  z.ZodTypeDef,
  unknown
> = z.object({
  version: types.optional(types.number()),
  functionType: FunctionType$inboundSchema,
  functionMemoryType: FunctionMemoryType$inboundSchema,
  functionTimeout: types.nullable(types.number()),
  secureComputePrimaryRegion: types.nullable(types.string()),
  secureComputeFallbackRegion: types.nullable(types.string()),
  isUsingActiveCPU: types.optional(types.boolean()),
  resourceConfig: types.optional(
    z.lazy(() => CancelDeploymentDeploymentsResourceConfig$inboundSchema),
  ),
});

export function cancelDeploymentConfigFromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentConfig, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CancelDeploymentConfig$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentConfig' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentDeploymentsState$inboundSchema: z.ZodNativeEnum<
  typeof CancelDeploymentDeploymentsState
> = z.nativeEnum(CancelDeploymentDeploymentsState);

/** @internal */
export const DeploymentAlias$inboundSchema: z.ZodType<
  DeploymentAlias,
  z.ZodTypeDef,
  unknown
> = z.object({
  state: CancelDeploymentDeploymentsState$inboundSchema,
  startedAt: types.number(),
  completedAt: types.optional(types.number()),
});

export function deploymentAliasFromJSON(
  jsonString: string,
): SafeParseResult<DeploymentAlias, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => DeploymentAlias$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'DeploymentAlias' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentChecks$inboundSchema: z.ZodType<
  CancelDeploymentChecks,
  z.ZodTypeDef,
  unknown
> = z.object({
  "deployment-alias": z.lazy(() => DeploymentAlias$inboundSchema),
}).transform((v) => {
  return remap$(v, {
    "deployment-alias": "deploymentAlias",
  });
});

export function cancelDeploymentChecksFromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentChecks, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CancelDeploymentChecks$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentChecks' from JSON`,
  );
}

/** @internal */
export const BlockCode$inboundSchema: z.ZodNativeEnum<typeof BlockCode> = z
  .nativeEnum(BlockCode);

/** @internal */
export const CancelDeploymentGitUserId$inboundSchema: z.ZodType<
  CancelDeploymentGitUserId,
  z.ZodTypeDef,
  unknown
> = smartUnion([types.string(), types.number()]);

export function cancelDeploymentGitUserIdFromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentGitUserId, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CancelDeploymentGitUserId$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentGitUserId' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentGitProvider$inboundSchema: z.ZodNativeEnum<
  typeof CancelDeploymentGitProvider
> = z.nativeEnum(CancelDeploymentGitProvider);

/** @internal */
export const SeatBlock$inboundSchema: z.ZodType<
  SeatBlock,
  z.ZodTypeDef,
  unknown
> = z.object({
  blockCode: BlockCode$inboundSchema,
  userId: types.optional(types.string()),
  isVerified: types.optional(types.boolean()),
  gitUserId: types.optional(smartUnion([types.string(), types.number()])),
  gitProvider: types.optional(CancelDeploymentGitProvider$inboundSchema),
});

export function seatBlockFromJSON(
  jsonString: string,
): SafeParseResult<SeatBlock, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => SeatBlock$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'SeatBlock' from JSON`,
  );
}

/** @internal */
export const CommitMeta$inboundSchema: z.ZodType<
  CommitMeta,
  z.ZodTypeDef,
  unknown
> = z.object({
  email: types.optional(types.string()),
  name: types.optional(types.string()),
  isVerified: types.optional(types.boolean()),
});

export function commitMetaFromJSON(
  jsonString: string,
): SafeParseResult<CommitMeta, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CommitMeta$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CommitMeta' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentId$inboundSchema: z.ZodType<
  CancelDeploymentId,
  z.ZodTypeDef,
  unknown
> = smartUnion([types.string(), types.number()]);

export function cancelDeploymentIdFromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentId, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CancelDeploymentId$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentId' from JSON`,
  );
}

/** @internal */
export const GitUser$inboundSchema: z.ZodType<GitUser, z.ZodTypeDef, unknown> =
  z.object({
    id: smartUnion([types.string(), types.number()]),
    login: types.string(),
    type: types.optional(types.string()),
    provider: types.optional(types.string()),
  });

export function gitUserFromJSON(
  jsonString: string,
): SafeParseResult<GitUser, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GitUser$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GitUser' from JSON`,
  );
}

/** @internal */
export const VercelUser$inboundSchema: z.ZodType<
  VercelUser,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: types.string(),
  username: types.string(),
  teamRoles: types.optional(z.array(types.string())),
});

export function vercelUserFromJSON(
  jsonString: string,
): SafeParseResult<VercelUser, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => VercelUser$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'VercelUser' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentAttribution$inboundSchema: z.ZodType<
  CancelDeploymentAttribution,
  z.ZodTypeDef,
  unknown
> = z.object({
  commitMeta: types.optional(z.lazy(() => CommitMeta$inboundSchema)),
  gitUser: types.optional(z.lazy(() => GitUser$inboundSchema)),
  vercelUser: types.optional(z.lazy(() => VercelUser$inboundSchema)),
});

export function cancelDeploymentAttributionFromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentAttribution, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CancelDeploymentAttribution$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentAttribution' from JSON`,
  );
}

/** @internal */
export const CancelDeploymentResponseBody$inboundSchema: z.ZodType<
  CancelDeploymentResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  aliasAssignedAt: z.nullable(AliasAssignedAt$inboundSchema).optional(),
  alwaysRefuseToBuild: types.optional(types.boolean()),
  build: Build$inboundSchema,
  buildArtifactUrls: types.optional(z.array(types.string())),
  builds: types.optional(z.array(Builds$inboundSchema)),
  env: z.array(types.string()),
  resourceConfig: types.optional(CancelDeploymentResourceConfig$inboundSchema),
  inspectorUrl: types.nullable(types.string()),
  isInConcurrentBuildsQueue: types.boolean(),
  isInSystemBuildsQueue: types.boolean(),
  projectSettings: CancelDeploymentProjectSettings$inboundSchema,
  integrations: types.optional(Integrations$inboundSchema),
  images: types.optional(Images$inboundSchema),
  alias: types.optional(z.array(types.string())),
  aliasAssigned: types.boolean(),
  bootedAt: types.number(),
  buildingAt: types.number(),
  buildContainerFinishedAt: types.optional(types.number()),
  buildSkipped: types.boolean(),
  creator: CancelDeploymentCreator$inboundSchema,
  initReadyAt: types.optional(types.number()),
  isFirstBranchDeployment: types.optional(types.boolean()),
  lambdas: types.optional(z.array(Lambdas$inboundSchema)),
  public: types.boolean(),
  ready: types.optional(types.number()),
  status: CancelDeploymentStatus$inboundSchema,
  team: types.optional(CancelDeploymentTeam$inboundSchema),
  userAliases: types.optional(z.array(types.string())),
  previewCommentsEnabled: types.optional(types.boolean()),
  ttyBuildLogs: types.optional(types.boolean()),
  customEnvironment: types.optional(
    CancelDeploymentCustomEnvironment$inboundSchema,
  ),
  oomReport: types.optional(OomReport$inboundSchema),
  readyStateReason: types.optional(types.string()),
  id: types.string(),
  target: z.nullable(CancelDeploymentTarget$inboundSchema).optional(),
  readyState: ReadyState$inboundSchema,
  aliasError: z.nullable(AliasError$inboundSchema).optional(),
  aliasWarning: z.nullable(AliasWarning$inboundSchema).optional(),
  errorCode: types.optional(types.string()),
  errorMessage: z.nullable(types.string()).optional(),
  createdAt: types.number(),
  name: types.string(),
  type: CancelDeploymentType$inboundSchema,
  aliasFinal: z.nullable(types.string()).optional(),
  autoAssignCustomDomains: types.optional(types.boolean()),
  automaticAliases: types.optional(z.array(types.string())),
  buildErrorAt: types.optional(types.number()),
  checksState: types.optional(ChecksState$inboundSchema),
  checksConclusion: types.optional(ChecksConclusion$inboundSchema),
  deletedAt: z.nullable(types.number()).optional(),
  defaultRoute: types.optional(types.string()),
  canceledAt: types.optional(types.number()),
  errorLink: types.optional(types.string()),
  errorStep: types.optional(types.string()),
  passiveRegions: types.optional(z.array(types.string())),
  gitSource: types.optional(CancelDeploymentGitSource$inboundSchema),
  manualProvisioning: types.optional(ManualProvisioning$inboundSchema),
  meta: z.record(types.string()),
  originCacheRegion: types.optional(types.string()),
  nodeVersion: types.optional(CancelDeploymentNodeVersion$inboundSchema),
  project: types.optional(CancelDeploymentProject$inboundSchema),
  prebuilt: types.optional(types.boolean()),
  readySubstate: types.optional(ReadySubstate$inboundSchema),
  regions: z.array(types.string()),
  softDeletedByRetention: types.optional(types.boolean()),
  source: types.optional(CancelDeploymentSource$inboundSchema),
  undeletedAt: types.optional(types.number()),
  url: types.string(),
  userConfiguredDeploymentId: types.optional(types.string()),
  version: types.number(),
  oidcTokenClaims: types.optional(OidcTokenClaims$inboundSchema),
  projectId: types.string(),
  plan: CancelDeploymentPlan$inboundSchema,
  connectBuildsEnabled: types.optional(types.boolean()),
  connectConfigurationId: types.optional(types.string()),
  createdIn: types.string(),
  crons: types.optional(z.array(Crons$inboundSchema)),
  atproto: types.optional(Atproto$inboundSchema),
  functions: z.nullable(z.record(Functions$inboundSchema)).optional(),
  isInstantStatic: types.optional(types.boolean()),
  monorepoManager: z.nullable(types.string()).optional(),
  ownerId: types.string(),
  passiveConnectConfigurationId: types.optional(types.string()),
  routes: types.nullable(z.array(CancelDeploymentRoutes$inboundSchema)),
  services: types.optional(
    z.array(z.union([
      z.lazy(() => Services1$inboundSchema),
      Services2$inboundSchema,
    ])),
  ),
  gitRepo: z.nullable(
    z.union([
      z.lazy(() => GitRepo1$inboundSchema),
      z.lazy(() => GitRepo2$inboundSchema),
      z.lazy(() => GitRepo3$inboundSchema),
      z.lazy(() => GitRepo4$inboundSchema),
      z.lazy(() => GitRepo5$inboundSchema),
    ]),
  ).optional(),
  flags: types.optional(
    smartUnion([
      z.lazy(() => Flags1$inboundSchema),
      z.array(z.lazy(() => Flags2$inboundSchema)),
    ]),
  ),
  microfrontends: types.optional(
    smartUnion([
      z.lazy(() => CancelDeploymentMicrofrontends2$inboundSchema),
      z.lazy(() => CancelDeploymentMicrofrontends1$inboundSchema),
    ]),
  ),
  platform: types.optional(z.lazy(() => Platform$inboundSchema)),
  config: types.optional(z.lazy(() => CancelDeploymentConfig$inboundSchema)),
  checks: types.optional(z.lazy(() => CancelDeploymentChecks$inboundSchema)),
  seatBlock: types.optional(z.lazy(() => SeatBlock$inboundSchema)),
  attribution: types.optional(
    z.lazy(() => CancelDeploymentAttribution$inboundSchema),
  ),
});

export function cancelDeploymentResponseBodyFromJSON(
  jsonString: string,
): SafeParseResult<CancelDeploymentResponseBody, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CancelDeploymentResponseBody$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CancelDeploymentResponseBody' from JSON`,
  );
}
