/*
 * 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 {
  AliasAssignedAt,
  AliasAssignedAt$inboundSchema,
  AliasError,
  AliasError$inboundSchema,
  AliasWarning,
  AliasWarning$inboundSchema,
  Build,
  Build$inboundSchema,
  Builds,
  Builds$inboundSchema,
  ChecksConclusion,
  ChecksConclusion$inboundSchema,
  ChecksState,
  ChecksState$inboundSchema,
  CreateDeploymentCreator,
  CreateDeploymentCreator$inboundSchema,
  CreateDeploymentGitSource,
  CreateDeploymentGitSource$inboundSchema,
  CreateDeploymentNodeVersion,
  CreateDeploymentNodeVersion$inboundSchema,
  CreateDeploymentPlan,
  CreateDeploymentPlan$inboundSchema,
  CreateDeploymentProject,
  CreateDeploymentProject$inboundSchema,
  CreateDeploymentProjectSettings,
  CreateDeploymentProjectSettings$inboundSchema,
  CreateDeploymentRoutesHas,
  CreateDeploymentRoutesHas$inboundSchema,
  CreateDeploymentSource,
  CreateDeploymentSource$inboundSchema,
  CreateDeploymentStatus,
  CreateDeploymentStatus$inboundSchema,
  CreateDeploymentTarget,
  CreateDeploymentTarget$inboundSchema,
  CreateDeploymentTeam,
  CreateDeploymentTeam$inboundSchema,
  CreateDeploymentType,
  CreateDeploymentType$inboundSchema,
  CreateDeploymentValueDeployments2,
  CreateDeploymentValueDeployments2$inboundSchema,
  Crons,
  Crons$inboundSchema,
  CustomEnvironment,
  CustomEnvironment$inboundSchema,
  Functions,
  Functions$inboundSchema,
  Images,
  Images$inboundSchema,
  Integrations,
  Integrations$inboundSchema,
  Lambdas,
  Lambdas$inboundSchema,
  ManualProvisioning,
  ManualProvisioning$inboundSchema,
  Missing2,
  Missing2$inboundSchema,
  OidcTokenClaims,
  OidcTokenClaims$inboundSchema,
  OomReport,
  OomReport$inboundSchema,
  Platform,
  Platform$inboundSchema,
  ReadyState,
  ReadyState$inboundSchema,
  ReadySubstate,
  ReadySubstate$inboundSchema,
  Routes2,
  Routes2$inboundSchema,
  Routes3,
  Routes3$inboundSchema,
} from "./createdeploymentvaluedeployments2.js";
import { FlagJSONValue, FlagJSONValue$inboundSchema } from "./flagjsonvalue.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export type MissingValue = string | CreateDeploymentValueDeployments2;

export type Missing1 = {
  type: "host";
  value: string | CreateDeploymentValueDeployments2;
};

export type CreateDeploymentRoutesMissing =
  | Missing1
  | (Missing2 & { type: "cookie" })
  | (Missing2 & { type: "header" })
  | (Missing2 & { type: "query" });

export const RoutesAction = {
  Challenge: "challenge",
  Deny: "deny",
} as const;
export type RoutesAction = ClosedEnum<typeof RoutesAction>;

export type CreateDeploymentRoutesMitigate = {
  action: RoutesAction;
};

export const RoutesType = {
  RequestHeaders: "request.headers",
  RequestQuery: "request.query",
  ResponseHeaders: "response.headers",
} as const;
export type RoutesType = ClosedEnum<typeof RoutesType>;

export const CreateDeploymentRoutesOp = {
  Append: "append",
  Delete: "delete",
  Set: "set",
} as const;
export type CreateDeploymentRoutesOp = ClosedEnum<
  typeof CreateDeploymentRoutesOp
>;

export type KeyEq = string | number;

export type Key2 = {
  eq?: string | number | undefined;
  neq?: string | undefined;
  inc?: Array<string> | undefined;
  ninc?: Array<string> | undefined;
  pre?: string | undefined;
  suf?: string | undefined;
  gt?: number | undefined;
  gte?: number | undefined;
  lt?: number | undefined;
  lte?: number | undefined;
};

export type CreateDeploymentRoutesKey = string | Key2;

export type RoutesTarget = {
  key: string | Key2;
};

export type Args = string | Array<string>;

export type CreateDeploymentRoutesTransforms = {
  type: RoutesType;
  op: CreateDeploymentRoutesOp;
  target: RoutesTarget;
  args?: string | Array<string> | undefined;
  env?: Array<string> | undefined;
};

export type Locale = {
  redirect?: { [k: string]: string } | undefined;
  cookie?: string | undefined;
};

export const DestinationType = {
  Service: "service",
} as const;
export type DestinationType = ClosedEnum<typeof DestinationType>;

export type Destination2 = {
  type: DestinationType;
  service: string;
  /**
   * Routing-only path used to select a route inside the target service.
   */
  path?: string | undefined;
};

export type Destination = Destination2 | string;

export type Routes1 = {
  src: string;
  dest?: string | undefined;
  headers?: { [k: string]: string } | undefined;
  methods?: Array<string> | undefined;
  continue?: boolean | undefined;
  override?: boolean | undefined;
  caseSensitive?: boolean | undefined;
  check?: boolean | undefined;
  important?: boolean | undefined;
  status?: number | undefined;
  has?: Array<CreateDeploymentRoutesHas> | undefined;
  missing?:
    | Array<
      | Missing1
      | (Missing2 & { type: "cookie" })
      | (Missing2 & { type: "header" })
      | (Missing2 & { type: "query" })
    >
    | undefined;
  mitigate?: CreateDeploymentRoutesMitigate | undefined;
  transforms?: Array<CreateDeploymentRoutesTransforms> | undefined;
  env?: Array<string> | undefined;
  locale?: Locale | undefined;
  /**
   * Aliases for `src`, `dest`, and `status`. These provide consistency with the `rewrites`, `redirects`, and `headers` fields which use `source`, `destination`, and `statusCode`. During normalization, the string forms are converted to their canonical forms (`src`, `dest`, `status`) and stripped from the route object. `destination` may also be a service-targeted object, in which case routing is delegated into the named service's internal route table and the object is preserved as-is (not folded into `dest`).
   */
  source?: string | undefined;
  destination?: Destination2 | string | undefined;
  statusCode?: number | undefined;
  /**
   * A middleware key within the `output` key under the build result. Overrides a `middleware` definition.
   */
  middlewarePath?: string | undefined;
  /**
   * The original middleware matchers.
   */
  middlewareRawSrc?: Array<string> | undefined;
  /**
   * A middleware index in the `middleware` key under the build result
   */
  middleware?: number | undefined;
  respectOriginCacheControl?: boolean | undefined;
};

export type CreateDeploymentRoutes = Routes3 | Routes1 | Routes2;

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

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

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

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

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;

/**
 * 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 CreateDeploymentFlagsOptions = {
  value: FlagJSONValue | null;
  label?: string | undefined;
};

export type CreateDeploymentFlagsDefinitions = {
  options?: Array<CreateDeploymentFlagsOptions> | 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]: CreateDeploymentFlagsDefinitions };
};

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 CreateDeploymentMicrofrontends2 = {
  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 CreateDeploymentMicrofrontends1 = {
  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 CreateDeploymentMicrofrontends =
  | CreateDeploymentMicrofrontends2
  | CreateDeploymentMicrofrontends1;

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 CreateDeploymentConfiguration = {
  SkipNamespaceQueue: "SKIP_NAMESPACE_QUEUE",
  WaitForNamespaceQueue: "WAIT_FOR_NAMESPACE_QUEUE",
} as const;
/**
 * Build resource configuration snapshot for this deployment.
 */
export type CreateDeploymentConfiguration = ClosedEnum<
  typeof CreateDeploymentConfiguration
>;

/**
 * Build resource configuration snapshot for this deployment.
 */
export type CreateDeploymentBuildQueue = {
  /**
   * Build resource configuration snapshot for this deployment.
   */
  configuration?: CreateDeploymentConfiguration | 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 CreateDeploymentPurchaseType = {
  Enhanced: "enhanced",
  Standard: "standard",
  Turbo: "turbo",
} as const;
/**
 * Machine type that was used for the build.
 */
export type CreateDeploymentPurchaseType = ClosedEnum<
  typeof CreateDeploymentPurchaseType
>;

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

/**
 * Build resource configuration snapshot for this deployment.
 */
export type CreateDeploymentResourceConfig = {
  /**
   * Build resource configuration snapshot for this deployment.
   */
  buildQueue?: CreateDeploymentBuildQueue | 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?: CreateDeploymentBuildMachine | 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 Config = {
  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?: CreateDeploymentResourceConfig | undefined;
};

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

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

export type CreateDeploymentChecks = {
  /**
   * 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 CreateDeploymentGitUserId = string | number;

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

/**
 * 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?: CreateDeploymentGitProvider | 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 CreateDeploymentId = 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 CreateDeploymentAttribution = {
  /**
   * 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;
};

/**
 * The successfully created deployment
 */
export type CreateDeploymentResponseBody = {
  aliasAssignedAt?: AliasAssignedAt | null | undefined;
  alwaysRefuseToBuild?: boolean | undefined;
  build: Build;
  buildArtifactUrls?: Array<string> | undefined;
  builds?: Array<Builds> | undefined;
  env: Array<string>;
  inspectorUrl: string | null;
  isInConcurrentBuildsQueue: boolean;
  isInSystemBuildsQueue: boolean;
  projectSettings: CreateDeploymentProjectSettings;
  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: CreateDeploymentCreator;
  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: CreateDeploymentStatus;
  /**
   * The team that owns the deployment if any
   */
  team?: CreateDeploymentTeam | 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?: CustomEnvironment | undefined;
  oomReport?: OomReport | undefined;
  readyStateReason?: string | undefined;
  aliasWarning?: AliasWarning | null | undefined;
  /**
   * A string holding the unique ID of the deployment
   */
  id: string;
  /**
   * A number containing the date when the deployment was created in milliseconds
   */
  createdAt: number;
  /**
   * The state of the deployment depending on the process of deploying, or if it is ready or in an error state
   */
  readyState: ReadyState;
  /**
   * The name of the project associated with the deployment at the time that the deployment was created
   */
  name: string;
  type: CreateDeploymentType;
  errorMessage?: string | null | undefined;
  /**
   * An object that will contain a `code` and a `message` when the aliasing fails, otherwise the value will be `null`
   */
  aliasError?: AliasError | null | undefined;
  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;
  errorCode?: string | 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?: CreateDeploymentGitSource | 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?: CreateDeploymentNodeVersion | undefined;
  /**
   * The public project information associated with the deployment.
   */
  project?: CreateDeploymentProject | 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?: CreateDeploymentSource | undefined;
  /**
   * 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?: CreateDeploymentTarget | null | 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: CreateDeploymentPlan;
  /**
   * 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;
  connectBuildsEnabled?: boolean | undefined;
  connectConfigurationId?: string | undefined;
  createdIn: string;
  crons?: Array<Crons> | undefined;
  functions?: { [k: string]: Functions } | null | 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<Routes3 | Routes1 | Routes2> | null;
  gitRepo?: GitRepo1 | GitRepo2 | GitRepo3 | GitRepo4 | null | undefined;
  flags?: Flags1 | Array<Flags2> | undefined;
  microfrontends?:
    | CreateDeploymentMicrofrontends2
    | CreateDeploymentMicrofrontends1
    | 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?: Config | undefined;
  checks?: CreateDeploymentChecks | 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?: CreateDeploymentAttribution | undefined;
};

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

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

/** @internal */
export const Missing1$inboundSchema: z.ZodType<
  Missing1,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("host"),
  value: smartUnion([
    types.string(),
    CreateDeploymentValueDeployments2$inboundSchema,
  ]),
});

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

/** @internal */
export const CreateDeploymentRoutesMissing$inboundSchema: z.ZodType<
  CreateDeploymentRoutesMissing,
  z.ZodTypeDef,
  unknown
> = z.union([
  z.lazy(() => Missing1$inboundSchema),
  Missing2$inboundSchema.and(z.object({ type: z.literal("cookie") })),
  Missing2$inboundSchema.and(z.object({ type: z.literal("header") })),
  Missing2$inboundSchema.and(z.object({ type: z.literal("query") })),
]);

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

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

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

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

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

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

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

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

/** @internal */
export const Key2$inboundSchema: z.ZodType<Key2, z.ZodTypeDef, unknown> = z
  .object({
    eq: types.optional(smartUnion([types.string(), types.number()])),
    neq: types.optional(types.string()),
    inc: types.optional(z.array(types.string())),
    ninc: types.optional(z.array(types.string())),
    pre: types.optional(types.string()),
    suf: types.optional(types.string()),
    gt: types.optional(types.number()),
    gte: types.optional(types.number()),
    lt: types.optional(types.number()),
    lte: types.optional(types.number()),
  });

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

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

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

/** @internal */
export const RoutesTarget$inboundSchema: z.ZodType<
  RoutesTarget,
  z.ZodTypeDef,
  unknown
> = z.object({
  key: smartUnion([types.string(), z.lazy(() => Key2$inboundSchema)]),
});

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

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

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

/** @internal */
export const CreateDeploymentRoutesTransforms$inboundSchema: z.ZodType<
  CreateDeploymentRoutesTransforms,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: RoutesType$inboundSchema,
  op: CreateDeploymentRoutesOp$inboundSchema,
  target: z.lazy(() => RoutesTarget$inboundSchema),
  args: types.optional(smartUnion([types.string(), z.array(types.string())])),
  env: types.optional(z.array(types.string())),
});

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

/** @internal */
export const Locale$inboundSchema: z.ZodType<Locale, z.ZodTypeDef, unknown> = z
  .object({
    redirect: types.optional(z.record(types.string())),
    cookie: types.optional(types.string()),
  });

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

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

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

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

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

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

/** @internal */
export const Routes1$inboundSchema: z.ZodType<Routes1, z.ZodTypeDef, unknown> =
  z.object({
    src: types.string(),
    dest: types.optional(types.string()),
    headers: types.optional(z.record(types.string())),
    methods: types.optional(z.array(types.string())),
    continue: types.optional(types.boolean()),
    override: types.optional(types.boolean()),
    caseSensitive: types.optional(types.boolean()),
    check: types.optional(types.boolean()),
    important: types.optional(types.boolean()),
    status: types.optional(types.number()),
    has: types.optional(z.array(CreateDeploymentRoutesHas$inboundSchema)),
    missing: types.optional(
      z.array(z.union([
        z.lazy(() => Missing1$inboundSchema),
        Missing2$inboundSchema.and(z.object({ type: z.literal("cookie") })),
        Missing2$inboundSchema.and(z.object({ type: z.literal("header") })),
        Missing2$inboundSchema.and(z.object({ type: z.literal("query") })),
      ])),
    ),
    mitigate: types.optional(
      z.lazy(() => CreateDeploymentRoutesMitigate$inboundSchema),
    ),
    transforms: types.optional(
      z.array(z.lazy(() => CreateDeploymentRoutesTransforms$inboundSchema)),
    ),
    env: types.optional(z.array(types.string())),
    locale: types.optional(z.lazy(() => Locale$inboundSchema)),
    source: types.optional(types.string()),
    destination: types.optional(
      smartUnion([z.lazy(() => Destination2$inboundSchema), types.string()]),
    ),
    statusCode: types.optional(types.number()),
    middlewarePath: types.optional(types.string()),
    middlewareRawSrc: types.optional(z.array(types.string())),
    middleware: types.optional(types.number()),
    respectOriginCacheControl: types.optional(types.boolean()),
  });

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

/** @internal */
export const CreateDeploymentRoutes$inboundSchema: z.ZodType<
  CreateDeploymentRoutes,
  z.ZodTypeDef,
  unknown
> = smartUnion([
  Routes3$inboundSchema,
  z.lazy(() => Routes1$inboundSchema),
  Routes2$inboundSchema,
]);

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

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

/** @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: CreateDeploymentGitRepoDeploymentsOwnerType$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 CreateDeploymentGitRepoOwnerType$inboundSchema: z.ZodNativeEnum<
  typeof CreateDeploymentGitRepoOwnerType
> = z.nativeEnum(CreateDeploymentGitRepoOwnerType);

/** @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: CreateDeploymentGitRepoOwnerType$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),
  ]);

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 CreateDeploymentFlagsOptions$inboundSchema: z.ZodType<
  CreateDeploymentFlagsOptions,
  z.ZodTypeDef,
  unknown
> = z.object({
  value: types.nullable(FlagJSONValue$inboundSchema),
  label: types.optional(types.string()),
});

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

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

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

/** @internal */
export const Flags1$inboundSchema: z.ZodType<Flags1, z.ZodTypeDef, unknown> = z
  .object({
    definitions: z.record(
      z.lazy(() => CreateDeploymentFlagsDefinitions$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 CreateDeploymentMicrofrontends2$inboundSchema: z.ZodType<
  CreateDeploymentMicrofrontends2,
  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 createDeploymentMicrofrontends2FromJSON(
  jsonString: string,
): SafeParseResult<CreateDeploymentMicrofrontends2, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CreateDeploymentMicrofrontends2$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CreateDeploymentMicrofrontends2' from JSON`,
  );
}

/** @internal */
export const CreateDeploymentMicrofrontends1$inboundSchema: z.ZodType<
  CreateDeploymentMicrofrontends1,
  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 createDeploymentMicrofrontends1FromJSON(
  jsonString: string,
): SafeParseResult<CreateDeploymentMicrofrontends1, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CreateDeploymentMicrofrontends1$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CreateDeploymentMicrofrontends1' from JSON`,
  );
}

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

export function createDeploymentMicrofrontendsFromJSON(
  jsonString: string,
): SafeParseResult<CreateDeploymentMicrofrontends, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CreateDeploymentMicrofrontends$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CreateDeploymentMicrofrontends' 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 CreateDeploymentConfiguration$inboundSchema: z.ZodNativeEnum<
  typeof CreateDeploymentConfiguration
> = z.nativeEnum(CreateDeploymentConfiguration);

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

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

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

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

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

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

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

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

/** @internal */
export const Config$inboundSchema: z.ZodType<Config, 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(() => CreateDeploymentResourceConfig$inboundSchema),
    ),
  });

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

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

/** @internal */
export const DeploymentAlias$inboundSchema: z.ZodType<
  DeploymentAlias,
  z.ZodTypeDef,
  unknown
> = z.object({
  state: CreateDeploymentDeploymentsState$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 CreateDeploymentChecks$inboundSchema: z.ZodType<
  CreateDeploymentChecks,
  z.ZodTypeDef,
  unknown
> = z.object({
  "deployment-alias": z.lazy(() => DeploymentAlias$inboundSchema),
}).transform((v) => {
  return remap$(v, {
    "deployment-alias": "deploymentAlias",
  });
});

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

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

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

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

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

/** @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(CreateDeploymentGitProvider$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 CreateDeploymentId$inboundSchema: z.ZodType<
  CreateDeploymentId,
  z.ZodTypeDef,
  unknown
> = smartUnion([types.string(), types.number()]);

export function createDeploymentIdFromJSON(
  jsonString: string,
): SafeParseResult<CreateDeploymentId, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CreateDeploymentId$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CreateDeploymentId' 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 CreateDeploymentAttribution$inboundSchema: z.ZodType<
  CreateDeploymentAttribution,
  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 createDeploymentAttributionFromJSON(
  jsonString: string,
): SafeParseResult<CreateDeploymentAttribution, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CreateDeploymentAttribution$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CreateDeploymentAttribution' from JSON`,
  );
}

/** @internal */
export const CreateDeploymentResponseBody$inboundSchema: z.ZodType<
  CreateDeploymentResponseBody,
  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()),
  inspectorUrl: types.nullable(types.string()),
  isInConcurrentBuildsQueue: types.boolean(),
  isInSystemBuildsQueue: types.boolean(),
  projectSettings: CreateDeploymentProjectSettings$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: CreateDeploymentCreator$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: CreateDeploymentStatus$inboundSchema,
  team: types.optional(CreateDeploymentTeam$inboundSchema),
  userAliases: types.optional(z.array(types.string())),
  previewCommentsEnabled: types.optional(types.boolean()),
  ttyBuildLogs: types.optional(types.boolean()),
  customEnvironment: types.optional(CustomEnvironment$inboundSchema),
  oomReport: types.optional(OomReport$inboundSchema),
  readyStateReason: types.optional(types.string()),
  aliasWarning: z.nullable(AliasWarning$inboundSchema).optional(),
  id: types.string(),
  createdAt: types.number(),
  readyState: ReadyState$inboundSchema,
  name: types.string(),
  type: CreateDeploymentType$inboundSchema,
  errorMessage: z.nullable(types.string()).optional(),
  aliasError: z.nullable(AliasError$inboundSchema).optional(),
  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()),
  errorCode: types.optional(types.string()),
  errorLink: types.optional(types.string()),
  errorStep: types.optional(types.string()),
  passiveRegions: types.optional(z.array(types.string())),
  gitSource: types.optional(CreateDeploymentGitSource$inboundSchema),
  manualProvisioning: types.optional(ManualProvisioning$inboundSchema),
  meta: z.record(types.string()),
  originCacheRegion: types.optional(types.string()),
  nodeVersion: types.optional(CreateDeploymentNodeVersion$inboundSchema),
  project: types.optional(CreateDeploymentProject$inboundSchema),
  prebuilt: types.optional(types.boolean()),
  readySubstate: types.optional(ReadySubstate$inboundSchema),
  regions: z.array(types.string()),
  softDeletedByRetention: types.optional(types.boolean()),
  source: types.optional(CreateDeploymentSource$inboundSchema),
  target: z.nullable(CreateDeploymentTarget$inboundSchema).optional(),
  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: CreateDeploymentPlan$inboundSchema,
  platform: types.optional(Platform$inboundSchema),
  connectBuildsEnabled: types.optional(types.boolean()),
  connectConfigurationId: types.optional(types.string()),
  createdIn: types.string(),
  crons: types.optional(z.array(Crons$inboundSchema)),
  functions: z.nullable(z.record(Functions$inboundSchema)).optional(),
  monorepoManager: z.nullable(types.string()).optional(),
  ownerId: types.string(),
  passiveConnectConfigurationId: types.optional(types.string()),
  routes: types.nullable(
    z.array(smartUnion([
      Routes3$inboundSchema,
      z.lazy(() => Routes1$inboundSchema),
      Routes2$inboundSchema,
    ])),
  ),
  gitRepo: z.nullable(
    z.union([
      z.lazy(() => GitRepo1$inboundSchema),
      z.lazy(() => GitRepo2$inboundSchema),
      z.lazy(() => GitRepo3$inboundSchema),
      z.lazy(() => GitRepo4$inboundSchema),
    ]),
  ).optional(),
  flags: types.optional(
    smartUnion([
      z.lazy(() => Flags1$inboundSchema),
      z.array(z.lazy(() => Flags2$inboundSchema)),
    ]),
  ),
  microfrontends: types.optional(
    smartUnion([
      z.lazy(() => CreateDeploymentMicrofrontends2$inboundSchema),
      z.lazy(() => CreateDeploymentMicrofrontends1$inboundSchema),
    ]),
  ),
  config: types.optional(z.lazy(() => Config$inboundSchema)),
  checks: types.optional(z.lazy(() => CreateDeploymentChecks$inboundSchema)),
  seatBlock: types.optional(z.lazy(() => SeatBlock$inboundSchema)),
  attribution: types.optional(
    z.lazy(() => CreateDeploymentAttribution$inboundSchema),
  ),
});

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