/*
 * 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 { Pagination, Pagination$inboundSchema } from "./pagination.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export type GetDeploymentsRequest = {
  /**
   * Name of the deployment.
   */
  app?: string | undefined;
  /**
   * Gets the deployment created after this Date timestamp. (default: current time)
   */
  from?: number | undefined;
  /**
   * Maximum number of deployments to list from a request.
   */
  limit?: number | undefined;
  /**
   * Filter deployments from the given ID or name.
   */
  projectId?: string | undefined;
  /**
   * Filter deployments from the given project IDs. Cannot be used when projectId is specified.
   */
  projectIds?: Array<string> | undefined;
  /**
   * Filter deployments based on the environment.
   */
  target?: string | undefined;
  /**
   * Gets the deployment created before this Date timestamp. (default: current time)
   */
  to?: number | undefined;
  /**
   * Filter out deployments based on users who have created the deployment.
   */
  users?: string | undefined;
  /**
   * Get Deployments created after this JavaScript timestamp.
   */
  since?: number | undefined;
  /**
   * Get Deployments created before this JavaScript timestamp.
   */
  until?: number | undefined;
  /**
   * Filter deployments based on their state (`BUILDING`, `ERROR`, `INITIALIZING`, `QUEUED`, `READY`, `CANCELED`, `BLOCKED`)
   */
  state?: string | undefined;
  /**
   * Filter deployments based on their rollback candidacy
   */
  rollbackCandidate?: boolean | undefined;
  /**
   * Filter deployments based on the branch name
   */
  branch?: string | undefined;
  /**
   * Filter deployments based on the SHA
   */
  sha?: string | undefined;
  /**
   * The Team identifier to perform the request on behalf of.
   */
  teamId?: string | undefined;
  /**
   * The Team slug to perform the request on behalf of.
   */
  slug?: string | undefined;
};

/**
 * The source of the deployment.
 */
export const GetDeploymentsSource = {
  ApiTriggerGitDeploy: "api-trigger-git-deploy",
  Cli: "cli",
  CloneRepo: "clone/repo",
  Drop: "drop",
  Git: "git",
  Import: "import",
  ImportRepo: "import/repo",
  Redeploy: "redeploy",
  V0Web: "v0-web",
} as const;
/**
 * The source of the deployment.
 */
export type GetDeploymentsSource = ClosedEnum<typeof GetDeploymentsSource>;

/**
 * In which state is the deployment.
 */
export const GetDeploymentsState = {
  Blocked: "BLOCKED",
  Building: "BUILDING",
  Canceled: "CANCELED",
  Deleted: "DELETED",
  Error: "ERROR",
  Initializing: "INITIALIZING",
  Queued: "QUEUED",
  Ready: "READY",
} as const;
/**
 * In which state is the deployment.
 */
export type GetDeploymentsState = ClosedEnum<typeof GetDeploymentsState>;

/**
 * In which state is the deployment.
 */
export const GetDeploymentsReadyState = {
  Blocked: "BLOCKED",
  Building: "BUILDING",
  Canceled: "CANCELED",
  Deleted: "DELETED",
  Error: "ERROR",
  Initializing: "INITIALIZING",
  Queued: "QUEUED",
  Ready: "READY",
} as const;
/**
 * In which state is the deployment.
 */
export type GetDeploymentsReadyState = ClosedEnum<
  typeof GetDeploymentsReadyState
>;

/**
 * The type of the deployment.
 */
export const GetDeploymentsType = {
  Lambdas: "LAMBDAS",
} as const;
/**
 * The type of the deployment.
 */
export type GetDeploymentsType = ClosedEnum<typeof GetDeploymentsType>;

/**
 * Metadata information of the user who created the deployment.
 */
export type GetDeploymentsCreator = {
  /**
   * The unique identifier of the user.
   */
  uid: string;
  /**
   * The email address of the user.
   */
  email?: string | undefined;
  /**
   * The username of the user.
   */
  username?: string | undefined;
  /**
   * The GitHub login of the user.
   */
  githubLogin?: string | undefined;
  /**
   * The GitLab login of the user.
   */
  gitlabLogin?: string | undefined;
};

/**
 * On which environment has the deployment been deployed to.
 */
export const GetDeploymentsTarget = {
  Production: "production",
  Staging: "staging",
} as const;
/**
 * On which environment has the deployment been deployed to.
 */
export type GetDeploymentsTarget = ClosedEnum<typeof GetDeploymentsTarget>;

/**
 * An error object in case aliasing of the deployment failed.
 */
export type GetDeploymentsAliasError = {
  code: string;
  message: string;
};

export type GetDeploymentsAliasAssigned = number | boolean;

/**
 * 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 gradually transitioning production traffic - PROMOTED: has seen production traffic
 */
export const GetDeploymentsReadySubstate = {
  Promoted: "PROMOTED",
  Rolling: "ROLLING",
  Staged: "STAGED",
} as const;
/**
 * 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 gradually transitioning production traffic - PROMOTED: has seen production traffic
 */
export type GetDeploymentsReadySubstate = ClosedEnum<
  typeof GetDeploymentsReadySubstate
>;

/**
 * State of all registered checks
 */
export const GetDeploymentsChecksState = {
  Completed: "completed",
  Registered: "registered",
  Running: "running",
} as const;
/**
 * State of all registered checks
 */
export type GetDeploymentsChecksState = ClosedEnum<
  typeof GetDeploymentsChecksState
>;

/**
 * Conclusion for checks
 */
export const GetDeploymentsChecksConclusion = {
  Canceled: "canceled",
  Failed: "failed",
  Skipped: "skipped",
  Succeeded: "succeeded",
} as const;
/**
 * Conclusion for checks
 */
export type GetDeploymentsChecksConclusion = ClosedEnum<
  typeof GetDeploymentsChecksConclusion
>;

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

/**
 * Detailed information about v2 deployment checks. Includes information about blocked workflows in the deployment lifecycle.
 */
export type GetDeploymentsDeploymentAlias = {
  state: GetDeploymentsDeploymentsResponseState;
  startedAt: number;
  completedAt?: number | undefined;
};

/**
 * Detailed information about v2 deployment checks. Includes information about blocked workflows in the deployment lifecycle.
 */
export type GetDeploymentsChecks = {
  /**
   * Detailed information about v2 deployment checks. Includes information about blocked workflows in the deployment lifecycle.
   */
  deploymentAlias: GetDeploymentsDeploymentAlias;
};

/**
 * Indicates if the deployment encountered an out-of-memory error.
 */
export const GetDeploymentsOomReport = {
  OutOfMemory: "out-of-memory",
} as const;
/**
 * Indicates if the deployment encountered an out-of-memory error.
 */
export type GetDeploymentsOomReport = ClosedEnum<
  typeof GetDeploymentsOomReport
>;

/**
 * Current provisioning state
 */
export const GetDeploymentsDeploymentsState = {
  Complete: "COMPLETE",
  Pending: "PENDING",
  Timeout: "TIMEOUT",
} as const;
/**
 * Current provisioning state
 */
export type GetDeploymentsDeploymentsState = ClosedEnum<
  typeof GetDeploymentsDeploymentsState
>;

export type GetDeploymentsManualProvisioning = {
  /**
   * Current provisioning state
   */
  state: GetDeploymentsDeploymentsState;
  /**
   * Timestamp when manual provisioning completed
   */
  completedAt?: number | undefined;
};

export const GetDeploymentsFramework = {
  ActixWeb: "actix-web",
  Angular: "angular",
  Ash: "ash",
  Astro: "astro",
  Axum: "axum",
  Blitzjs: "blitzjs",
  Brunch: "brunch",
  Bun: "bun",
  CreateReactApp: "create-react-app",
  Django: "django",
  Docusaurus: "docusaurus",
  Docusaurus2: "docusaurus-2",
  Dojo: "dojo",
  Eleventy: "eleventy",
  Elysia: "elysia",
  Ember: "ember",
  Eve: "eve",
  Express: "express",
  Fastapi: "fastapi",
  Fasthtml: "fasthtml",
  Fastify: "fastify",
  Flask: "flask",
  Gatsby: "gatsby",
  Go: "go",
  Gridsome: "gridsome",
  H3: "h3",
  Hexo: "hexo",
  Hono: "hono",
  Hugo: "hugo",
  Hydrogen: "hydrogen",
  IonicAngular: "ionic-angular",
  IonicReact: "ionic-react",
  Jekyll: "jekyll",
  Koa: "koa",
  Mastra: "mastra",
  Middleman: "middleman",
  Nestjs: "nestjs",
  Nextjs: "nextjs",
  Nitro: "nitro",
  Node: "node",
  Nuxtjs: "nuxtjs",
  Parcel: "parcel",
  Polymer: "polymer",
  Preact: "preact",
  Python: "python",
  ReactRouter: "react-router",
  Redwoodjs: "redwoodjs",
  Remix: "remix",
  Ruby: "ruby",
  Rust: "rust",
  Saber: "saber",
  Sanity: "sanity",
  SanityV2: "sanity-v2",
  Sapper: "sapper",
  Scully: "scully",
  Services: "services",
  Solidstart: "solidstart",
  Solidstart1: "solidstart-1",
  Stencil: "stencil",
  Storybook: "storybook",
  Svelte: "svelte",
  Sveltekit: "sveltekit",
  Sveltekit1: "sveltekit-1",
  TanstackStart: "tanstack-start",
  Umijs: "umijs",
  Vite: "vite",
  Vitepress: "vitepress",
  Vue: "vue",
  Vuepress: "vuepress",
  Xmcp: "xmcp",
  Zola: "zola",
} as const;
export type GetDeploymentsFramework = ClosedEnum<
  typeof GetDeploymentsFramework
>;

export const GetDeploymentsNodeVersion = {
  TenDotX: "10.x",
  TwelveDotX: "12.x",
  FourteenDotX: "14.x",
  SixteenDotX: "16.x",
  EighteenDotX: "18.x",
  TwentyDotX: "20.x",
  TwentyTwoDotX: "22.x",
  TwentyFourDotX: "24.x",
  EightDot10DotX: "8.10.x",
} as const;
export type GetDeploymentsNodeVersion = ClosedEnum<
  typeof GetDeploymentsNodeVersion
>;

export type GetDeploymentsSpeedInsights = {
  id: string;
  enabledAt?: number | undefined;
  disabledAt?: number | undefined;
  canceledAt?: number | undefined;
  hasData?: boolean | undefined;
  paidAt?: number | undefined;
};

export type GetDeploymentsWebAnalytics = {
  id: string;
  disabledAt?: number | undefined;
  canceledAt?: number | undefined;
  enabledAt?: number | undefined;
  hasData?: true | undefined;
};

/**
 * Since June '23
 */
export type GetDeploymentsGitComments = {
  /**
   * Whether the Vercel bot should comment on PRs
   */
  onPullRequest: boolean;
  /**
   * Whether the Vercel bot should comment on commits
   */
  onCommit: boolean;
};

/**
 * The project settings which was used for this deployment
 */
export type GetDeploymentsProjectSettings = {
  framework?: GetDeploymentsFramework | null | undefined;
  gitForkProtection?: boolean | undefined;
  customerSupportCodeVisibility?: boolean | undefined;
  gitLFS?: boolean | undefined;
  devCommand?: string | null | undefined;
  installCommand?: string | null | undefined;
  buildCommand?: string | null | undefined;
  nodeVersion?: GetDeploymentsNodeVersion | undefined;
  outputDirectory?: string | null | undefined;
  rootDirectory?: string | null | undefined;
  sourceFilesOutsideRootDirectory?: boolean | undefined;
  commandForIgnoringBuildStep?: string | null | undefined;
  createdAt?: number | undefined;
  speedInsights?: GetDeploymentsSpeedInsights | undefined;
  webAnalytics?: GetDeploymentsWebAnalytics | undefined;
  skipGitConnectDuringLink?: boolean | undefined;
  /**
   * Since June '23
   */
  gitComments?: GetDeploymentsGitComments | undefined;
};

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

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

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

/**
 * The user on the external platform who triggered the deployment.
 */
export type GetDeploymentsDeploymentsCreator = {
  /**
   * 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.
 */
export type GetDeploymentsPlatform = {
  /**
   * The external platform that created the deployment (e.g. its display name).
   */
  source: GetDeploymentsDeploymentsSource;
  /**
   * Reference back to the entity on the platform that initiated the deployment.
   */
  origin: GetDeploymentsOrigin;
  /**
   * The user on the external platform who triggered the deployment.
   */
  creator: GetDeploymentsDeploymentsCreator;
  /**
   * Arbitrary key-value metadata provided by the platform.
   */
  meta?: { [k: string]: string } | undefined;
};

/**
 * The custom environment used for this deployment, if any
 */
export type GetDeploymentsCustomEnvironment = {
  id: string;
  slug?: string | undefined;
};

/**
 * The NSNB decision code for the seat block. TODO: We should consolidate block types.
 */
export const GetDeploymentsBlockCode = {
  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 GetDeploymentsBlockCode = ClosedEnum<
  typeof GetDeploymentsBlockCode
>;

export type GetDeploymentsGitUserId = string | number;

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

/**
 * NSNB Blocked metadata
 */
export type GetDeploymentsSeatBlock = {
  /**
   * The NSNB decision code for the seat block. TODO: We should consolidate block types.
   */
  blockCode: GetDeploymentsBlockCode;
  /**
   * 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?: GetDeploymentsGitProvider | undefined;
};

/**
 * Commit metadata from the git commit author
 */
export type GetDeploymentsCommitMeta = {
  /**
   * 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 GetDeploymentsId = string | number;

/**
 * Git provider user associated with the commit author email (only set if resolved)
 */
export type GetDeploymentsGitUser = {
  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 GetDeploymentsVercelUser = {
  /**
   * Vercel user ID
   */
  id: string;
  /**
   * Vercel username
   */
  username: string;
  /**
   * Team roles at time of deployment
   */
  teamRoles?: Array<string> | undefined;
};

/**
 * Commit attribution metadata
 */
export type GetDeploymentsAttribution = {
  /**
   * Commit metadata from the git commit author
   */
  commitMeta?: GetDeploymentsCommitMeta | undefined;
  /**
   * Git provider user associated with the commit author email (only set if resolved)
   */
  gitUser?: GetDeploymentsGitUser | undefined;
  /**
   * Vercel user linked to the git provider account (only set if resolved)
   */
  vercelUser?: GetDeploymentsVercelUser | undefined;
};

export type Deployments = {
  /**
   * The unique identifier of the deployment.
   */
  uid: string;
  /**
   * The name of the deployment.
   */
  name: string;
  /**
   * The project ID of the deployment
   */
  projectId: string;
  /**
   * The URL of the deployment.
   */
  url: string;
  /**
   * Timestamp of when the deployment got created.
   */
  created: number;
  /**
   * The default route that should be used for screenshots and links if configured with microfrontends.
   */
  defaultRoute?: string | undefined;
  /**
   * Timestamp of when the deployment got deleted.
   */
  deleted?: number | undefined;
  /**
   * Timestamp of when the deployment was undeleted.
   */
  undeleted?: number | undefined;
  /**
   * Optional flag to indicate if the deployment was soft deleted by retention policy.
   */
  softDeletedByRetention?: boolean | undefined;
  /**
   * The source of the deployment.
   */
  source?: GetDeploymentsSource | undefined;
  /**
   * In which state is the deployment.
   */
  state?: GetDeploymentsState | undefined;
  /**
   * In which state is the deployment.
   */
  readyState?: GetDeploymentsReadyState | undefined;
  /**
   * The type of the deployment.
   */
  type: GetDeploymentsType;
  /**
   * Metadata information of the user who created the deployment.
   */
  creator: GetDeploymentsCreator;
  /**
   * Metadata information from the Git provider.
   */
  meta?: { [k: string]: string } | undefined;
  /**
   * On which environment has the deployment been deployed to.
   */
  target?: GetDeploymentsTarget | null | undefined;
  /**
   * An error object in case aliasing of the deployment failed.
   */
  aliasError?: GetDeploymentsAliasError | null | undefined;
  aliasAssigned?: number | boolean | null | undefined;
  /**
   * Timestamp of when the deployment got created.
   */
  createdAt?: number | undefined;
  /**
   * Timestamp of when the deployment started building at.
   */
  buildingAt?: number | undefined;
  /**
   * Timestamp of when the deployment got ready.
   */
  ready?: number | 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 gradually transitioning production traffic - PROMOTED: has seen production traffic
   */
  readySubstate?: GetDeploymentsReadySubstate | undefined;
  /**
   * State of all registered checks
   */
  checksState?: GetDeploymentsChecksState | undefined;
  /**
   * Conclusion for checks
   */
  checksConclusion?: GetDeploymentsChecksConclusion | undefined;
  /**
   * Detailed information about v2 deployment checks. Includes information about blocked workflows in the deployment lifecycle.
   */
  checks?: GetDeploymentsChecks | undefined;
  /**
   * Vercel URL to inspect the deployment.
   */
  inspectorUrl: string | null;
  /**
   * Error code when the deployment is in an error state.
   */
  errorCode?: string | undefined;
  /**
   * Error message when the deployment is in an canceled or error state.
   */
  errorMessage?: string | null | undefined;
  /**
   * Indicates if the deployment encountered an out-of-memory error.
   */
  oomReport?: GetDeploymentsOomReport | undefined;
  /**
   * Deployment can be used for instant rollback
   */
  isRollbackCandidate?: boolean | null | undefined;
  prebuilt?: boolean | undefined;
  manualProvisioning?: GetDeploymentsManualProvisioning | undefined;
  /**
   * The project settings which was used for this deployment
   */
  projectSettings?: GetDeploymentsProjectSettings | undefined;
  /**
   * The flag saying if Secure Compute network is used for builds
   */
  connectBuildsEnabled?: boolean | undefined;
  /**
   * The ID of Secure Compute network used for this deployment
   */
  connectConfigurationId?: string | undefined;
  /**
   * The ID of Secure Compute network used for this deployment's passive functions
   */
  passiveConnectConfigurationId?: string | undefined;
  /**
   * The expiration configured by the project retention policy
   */
  expiration?: number | undefined;
  /**
   * The expiration proposed to replace the existing expiration
   */
  proposedExpiration?: number | undefined;
  /**
   * Metadata about the source platform that triggered the deployment.
   */
  platform?: GetDeploymentsPlatform | undefined;
  /**
   * The custom environment used for this deployment, if any
   */
  customEnvironment?: GetDeploymentsCustomEnvironment | undefined;
  /**
   * NSNB Blocked metadata
   */
  seatBlock?: GetDeploymentsSeatBlock | undefined;
  /**
   * Commit attribution metadata
   */
  attribution?: GetDeploymentsAttribution | undefined;
};

export type GetDeploymentsResponseBody = {
  /**
   * This object contains information related to the pagination of the current request, including the necessary parameters to get the next or previous page of data.
   */
  pagination: Pagination;
  deployments: Array<Deployments>;
};

/** @internal */
export type GetDeploymentsRequest$Outbound = {
  app?: string | undefined;
  from?: number | undefined;
  limit?: number | undefined;
  projectId?: string | undefined;
  projectIds?: Array<string> | undefined;
  target?: string | undefined;
  to?: number | undefined;
  users?: string | undefined;
  since?: number | undefined;
  until?: number | undefined;
  state?: string | undefined;
  rollbackCandidate?: boolean | undefined;
  branch?: string | undefined;
  sha?: string | undefined;
  teamId?: string | undefined;
  slug?: string | undefined;
};

/** @internal */
export const GetDeploymentsRequest$outboundSchema: z.ZodType<
  GetDeploymentsRequest$Outbound,
  z.ZodTypeDef,
  GetDeploymentsRequest
> = z.object({
  app: z.string().optional(),
  from: z.number().optional(),
  limit: z.number().optional(),
  projectId: z.string().optional(),
  projectIds: z.array(z.string()).optional(),
  target: z.string().optional(),
  to: z.number().optional(),
  users: z.string().optional(),
  since: z.number().optional(),
  until: z.number().optional(),
  state: z.string().optional(),
  rollbackCandidate: z.boolean().optional(),
  branch: z.string().optional(),
  sha: z.string().optional(),
  teamId: z.string().optional(),
  slug: z.string().optional(),
});

export function getDeploymentsRequestToJSON(
  getDeploymentsRequest: GetDeploymentsRequest,
): string {
  return JSON.stringify(
    GetDeploymentsRequest$outboundSchema.parse(getDeploymentsRequest),
  );
}

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

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

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

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

/** @internal */
export const GetDeploymentsCreator$inboundSchema: z.ZodType<
  GetDeploymentsCreator,
  z.ZodTypeDef,
  unknown
> = z.object({
  uid: types.string(),
  email: types.optional(types.string()),
  username: types.optional(types.string()),
  githubLogin: types.optional(types.string()),
  gitlabLogin: types.optional(types.string()),
});

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/** @internal */
export const GetDeploymentsSpeedInsights$inboundSchema: z.ZodType<
  GetDeploymentsSpeedInsights,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: types.string(),
  enabledAt: types.optional(types.number()),
  disabledAt: types.optional(types.number()),
  canceledAt: types.optional(types.number()),
  hasData: types.optional(types.boolean()),
  paidAt: types.optional(types.number()),
});

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

/** @internal */
export const GetDeploymentsWebAnalytics$inboundSchema: z.ZodType<
  GetDeploymentsWebAnalytics,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: types.string(),
  disabledAt: types.optional(types.number()),
  canceledAt: types.optional(types.number()),
  enabledAt: types.optional(types.number()),
  hasData: types.optional(types.literal(true)),
});

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

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

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

/** @internal */
export const GetDeploymentsProjectSettings$inboundSchema: z.ZodType<
  GetDeploymentsProjectSettings,
  z.ZodTypeDef,
  unknown
> = z.object({
  framework: z.nullable(GetDeploymentsFramework$inboundSchema).optional(),
  gitForkProtection: types.optional(types.boolean()),
  customerSupportCodeVisibility: types.optional(types.boolean()),
  gitLFS: types.optional(types.boolean()),
  devCommand: z.nullable(types.string()).optional(),
  installCommand: z.nullable(types.string()).optional(),
  buildCommand: z.nullable(types.string()).optional(),
  nodeVersion: types.optional(GetDeploymentsNodeVersion$inboundSchema),
  outputDirectory: z.nullable(types.string()).optional(),
  rootDirectory: z.nullable(types.string()).optional(),
  sourceFilesOutsideRootDirectory: types.optional(types.boolean()),
  commandForIgnoringBuildStep: z.nullable(types.string()).optional(),
  createdAt: types.optional(types.number()),
  speedInsights: types.optional(
    z.lazy(() => GetDeploymentsSpeedInsights$inboundSchema),
  ),
  webAnalytics: types.optional(
    z.lazy(() => GetDeploymentsWebAnalytics$inboundSchema),
  ),
  skipGitConnectDuringLink: types.optional(types.boolean()),
  gitComments: types.optional(
    z.lazy(() => GetDeploymentsGitComments$inboundSchema),
  ),
});

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/** @internal */
export const GetDeploymentsAttribution$inboundSchema: z.ZodType<
  GetDeploymentsAttribution,
  z.ZodTypeDef,
  unknown
> = z.object({
  commitMeta: types.optional(
    z.lazy(() => GetDeploymentsCommitMeta$inboundSchema),
  ),
  gitUser: types.optional(z.lazy(() => GetDeploymentsGitUser$inboundSchema)),
  vercelUser: types.optional(
    z.lazy(() => GetDeploymentsVercelUser$inboundSchema),
  ),
});

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

/** @internal */
export const Deployments$inboundSchema: z.ZodType<
  Deployments,
  z.ZodTypeDef,
  unknown
> = z.object({
  uid: types.string(),
  name: types.string(),
  projectId: types.string(),
  url: types.string(),
  created: types.number(),
  defaultRoute: types.optional(types.string()),
  deleted: types.optional(types.number()),
  undeleted: types.optional(types.number()),
  softDeletedByRetention: types.optional(types.boolean()),
  source: types.optional(GetDeploymentsSource$inboundSchema),
  state: types.optional(GetDeploymentsState$inboundSchema),
  readyState: types.optional(GetDeploymentsReadyState$inboundSchema),
  type: GetDeploymentsType$inboundSchema,
  creator: z.lazy(() => GetDeploymentsCreator$inboundSchema),
  meta: types.optional(z.record(types.string())),
  target: z.nullable(GetDeploymentsTarget$inboundSchema).optional(),
  aliasError: z.nullable(z.lazy(() => GetDeploymentsAliasError$inboundSchema))
    .optional(),
  aliasAssigned: z.nullable(smartUnion([types.number(), types.boolean()]))
    .optional(),
  createdAt: types.optional(types.number()),
  buildingAt: types.optional(types.number()),
  ready: types.optional(types.number()),
  readySubstate: types.optional(GetDeploymentsReadySubstate$inboundSchema),
  checksState: types.optional(GetDeploymentsChecksState$inboundSchema),
  checksConclusion: types.optional(
    GetDeploymentsChecksConclusion$inboundSchema,
  ),
  checks: types.optional(z.lazy(() => GetDeploymentsChecks$inboundSchema)),
  inspectorUrl: types.nullable(types.string()),
  errorCode: types.optional(types.string()),
  errorMessage: z.nullable(types.string()).optional(),
  oomReport: types.optional(GetDeploymentsOomReport$inboundSchema),
  isRollbackCandidate: z.nullable(types.boolean()).optional(),
  prebuilt: types.optional(types.boolean()),
  manualProvisioning: types.optional(
    z.lazy(() => GetDeploymentsManualProvisioning$inboundSchema),
  ),
  projectSettings: types.optional(
    z.lazy(() => GetDeploymentsProjectSettings$inboundSchema),
  ),
  connectBuildsEnabled: types.optional(types.boolean()),
  connectConfigurationId: types.optional(types.string()),
  passiveConnectConfigurationId: types.optional(types.string()),
  expiration: types.optional(types.number()),
  proposedExpiration: types.optional(types.number()),
  platform: types.optional(z.lazy(() => GetDeploymentsPlatform$inboundSchema)),
  customEnvironment: types.optional(
    z.lazy(() => GetDeploymentsCustomEnvironment$inboundSchema),
  ),
  seatBlock: types.optional(
    z.lazy(() => GetDeploymentsSeatBlock$inboundSchema),
  ),
  attribution: types.optional(
    z.lazy(() => GetDeploymentsAttribution$inboundSchema),
  ),
});

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

/** @internal */
export const GetDeploymentsResponseBody$inboundSchema: z.ZodType<
  GetDeploymentsResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  pagination: Pagination$inboundSchema,
  deployments: z.array(z.lazy(() => Deployments$inboundSchema)),
});

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