UNPKG

@vercel/sdk

Version:

<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>

1,941 lines 58.1 kB
/*
 * 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 {
  collectExtraKeys as collectExtraKeys$,
  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 { SDKValidationError } from "./sdkvalidationerror.js";

export type Connect = {
  enabled?: boolean | undefined;
};

/**
 * Controls whether directory sync events are processed. - 'SETUP': Directory connected but role mappings not yet configured. Events are acknowledged but not processed. - 'ACTIVE': Fully configured. Events are processed normally. - undefined: Legacy directory (pre-feature), treat as 'ACTIVE' for backwards compatibility.
 */
export const SyncState = {
  Active: "ACTIVE",
  Setup: "SETUP",
} as const;
/**
 * Controls whether directory sync events are processed. - 'SETUP': Directory connected but role mappings not yet configured. Events are acknowledged but not processed. - 'ACTIVE': Fully configured. Events are processed normally. - undefined: Legacy directory (pre-feature), treat as 'ACTIVE' for backwards compatibility.
 */
export type SyncState = ClosedEnum<typeof SyncState>;

/**
 * Information for the SAML Single Sign-On configuration.
 */
export type Connection = {
  /**
   * Current status of the connection.
   */
  status: string;
  /**
   * The Identity Provider "type", for example Okta.
   */
  type: string;
  /**
   * Current state of the connection.
   */
  state: string;
  /**
   * Timestamp (in milliseconds) of when the configuration was connected.
   */
  connectedAt: number;
  /**
   * Timestamp (in milliseconds) of when the last webhook event was received from WorkOS.
   */
  lastReceivedWebhookEvent?: number | undefined;
  /**
   * Timestamp (in milliseconds) of when the last directory sync was performed.
   */
  lastSyncedAt?: number | undefined;
  /**
   * Controls whether directory sync events are processed. - 'SETUP': Directory connected but role mappings not yet configured. Events are acknowledged but not processed. - 'ACTIVE': Fully configured. Events are processed normally. - undefined: Legacy directory (pre-feature), treat as 'ACTIVE' for backwards compatibility.
   */
  syncState?: SyncState | undefined;
};

/**
 * Controls whether directory sync events are processed. - 'SETUP': Directory connected but role mappings not yet configured. Events are acknowledged but not processed. - 'ACTIVE': Fully configured. Events are processed normally. - undefined: Legacy directory (pre-feature), treat as 'ACTIVE' for backwards compatibility.
 */
export const TeamSyncState = {
  Active: "ACTIVE",
  Setup: "SETUP",
} as const;
/**
 * Controls whether directory sync events are processed. - 'SETUP': Directory connected but role mappings not yet configured. Events are acknowledged but not processed. - 'ACTIVE': Fully configured. Events are processed normally. - undefined: Legacy directory (pre-feature), treat as 'ACTIVE' for backwards compatibility.
 */
export type TeamSyncState = ClosedEnum<typeof TeamSyncState>;

/**
 * Information for the Directory Sync configuration.
 */
export type Directory = {
  /**
   * The Identity Provider "type", for example Okta.
   */
  type: string;
  /**
   * Current state of the connection.
   */
  state: string;
  /**
   * Timestamp (in milliseconds) of when the configuration was connected.
   */
  connectedAt: number;
  /**
   * Timestamp (in milliseconds) of when the last webhook event was received from WorkOS.
   */
  lastReceivedWebhookEvent?: number | undefined;
  /**
   * Timestamp (in milliseconds) of when the last directory sync was performed.
   */
  lastSyncedAt?: number | undefined;
  /**
   * Controls whether directory sync events are processed. - 'SETUP': Directory connected but role mappings not yet configured. Events are acknowledged but not processed. - 'ACTIVE': Fully configured. Events are processed normally. - undefined: Legacy directory (pre-feature), treat as 'ACTIVE' for backwards compatibility.
   */
  syncState?: TeamSyncState | undefined;
};

/**
 * The default redirect URI to use after successful SAML authentication.
 */
export const DefaultRedirectUri = {
  V0App: "v0.app",
  V0Dev: "v0.dev",
  VercelCom: "vercel.com",
} as const;
/**
 * The default redirect URI to use after successful SAML authentication.
 */
export type DefaultRedirectUri = ClosedEnum<typeof DefaultRedirectUri>;

export const Roles2 = {
  Billing: "BILLING",
  Contributor: "CONTRIBUTOR",
  Developer: "DEVELOPER",
  Member: "MEMBER",
  Owner: "OWNER",
  Security: "SECURITY",
  Viewer: "VIEWER",
  ViewerForPlus: "VIEWER_FOR_PLUS",
} as const;
export type Roles2 = ClosedEnum<typeof Roles2>;

/**
 * When "Directory Sync" is configured, this object contains a mapping of which Directory Group (by ID) should be assigned to which Vercel Team "role".
 */
export type Roles1 = {
  accessGroupId: string;
};

export type Roles = Roles1 | Roles2;

/**
 * When "Single Sign-On (SAML)" is configured, this object contains information regarding the configuration of the Identity Provider (IdP).
 */
export type Saml = {
  /**
   * Information for the SAML Single Sign-On configuration.
   */
  connection?: Connection | undefined;
  /**
   * Information for the Directory Sync configuration.
   */
  directory?: Directory | undefined;
  /**
   * When `true`, interactions with the Team **must** be done with an authentication token that has been authenticated with the Team's SAML Single Sign-On provider.
   */
  enforced: boolean;
  /**
   * The default redirect URI to use after successful SAML authentication.
   */
  defaultRedirectUri?: DefaultRedirectUri | undefined;
  /**
   * When "Directory Sync" is configured, this object contains a mapping of which Directory Group (by ID) should be assigned to which Vercel Team "role".
   */
  roles?: { [k: string]: Roles1 | Roles2 } | undefined;
};

export const TeamTeamRoles = {
  Billing: "BILLING",
  Contributor: "CONTRIBUTOR",
  Developer: "DEVELOPER",
  Member: "MEMBER",
  Owner: "OWNER",
  Security: "SECURITY",
  Viewer: "VIEWER",
  ViewerForPlus: "VIEWER_FOR_PLUS",
} as const;
export type TeamTeamRoles = ClosedEnum<typeof TeamTeamRoles>;

export const TeamTeamPermissions = {
  CreateProject: "CreateProject",
  EnvVariableManager: "EnvVariableManager",
  EnvironmentManager: "EnvironmentManager",
  FullProductionDeployment: "FullProductionDeployment",
  IntegrationManager: "IntegrationManager",
  OrgAdmin: "OrgAdmin",
  OrgViewer: "OrgViewer",
  UsageViewer: "UsageViewer",
  V0Builder: "V0Builder",
  V0Chatter: "V0Chatter",
  V0Viewer: "V0Viewer",
} as const;
export type TeamTeamPermissions = ClosedEnum<typeof TeamTeamPermissions>;

/**
 * Default roles for the team.
 */
export type DefaultRoles = {
  teamRoles?: Array<TeamTeamRoles> | undefined;
  teamPermissions?: Array<TeamTeamPermissions> | undefined;
};

export type BuildEntitlements = {
  enhancedBuilds?: boolean | undefined;
};

/**
 * Default build machine type for new builds
 */
export const Default = {
  Elastic: "elastic",
  Enhanced: "enhanced",
  Standard: "standard",
  Turbo: "turbo",
} as const;
/**
 * Default build machine type for new builds
 */
export type Default = ClosedEnum<typeof Default>;

/**
 * Build machine configuration
 */
export type BuildMachine = {
  /**
   * Default build machine type for new builds
   */
  default?: Default | undefined;
};

export type ResourceConfig = {
  /**
   * The total amount of concurrent builds that can be used.
   */
  concurrentBuilds?: number | undefined;
  /**
   * Whether every build for this team / user has elastic concurrency enabled automatically.
   */
  elasticConcurrencyEnabled?: boolean | undefined;
  /**
   * The maximum size in kilobytes of an Edge Config. Only specified if a custom limit is set.
   */
  edgeConfigSize?: number | undefined;
  /**
   * The maximum number of edge configs an account can create.
   */
  edgeConfigs?: number | undefined;
  /**
   * The maximum number of kv databases an account can create.
   */
  kvDatabases?: number | undefined;
  /**
   * The maximum number of blob stores an account can create.
   */
  blobStores?: number | undefined;
  /**
   * The maximum number of postgres databases an account can create.
   */
  postgresDatabases?: number | undefined;
  /**
   * The maximum number of custom environments allowed per project.
   */
  customEnvironmentsPerProject?: number | undefined;
  /**
   * The maximum memory size (in MB) for a serverless function. Only specified if a custom limit is set.
   */
  serverlessFunctionMaxMemorySize?: number | undefined;
  buildEntitlements?: BuildEntitlements | undefined;
  /**
   * Build machine configuration
   */
  buildMachine?: BuildMachine | undefined;
};

export type DisableHardAutoBlocks = number | boolean;

/**
 * Is remote caching enabled for this team
 */
export type RemoteCaching = {
  enabled?: boolean | undefined;
};

export type PasswordProtection = {
  deploymentType: string;
};

export type SsoProtection = {
  deploymentType: string;
};

/**
 * Default deployment protection for this team null indicates protection is disabled
 */
export type DefaultDeploymentProtection = {
  passwordProtection?: PasswordProtection | null | undefined;
  ssoProtection?: SsoProtection | null | undefined;
};

/**
 * Default Passport configuration for new projects in this team.
 */
export const DeploymentType = {
  All: "all",
  AllExceptCustomDomains: "all_except_custom_domains",
  Preview: "preview",
  ProdDeploymentUrlsAndAllPreviews: "prod_deployment_urls_and_all_previews",
} as const;
/**
 * Default Passport configuration for new projects in this team.
 */
export type DeploymentType = ClosedEnum<typeof DeploymentType>;

/**
 * Default Passport configuration for new projects in this team.
 */
export type DefaultPassport = {
  /**
   * Default Passport configuration for new projects in this team.
   */
  connectorId: string;
  /**
   * Default Passport configuration for new projects in this team.
   */
  deploymentType: DeploymentType;
};

/**
 * Default deployment expiration settings for this team
 */
export type DefaultExpirationSettings = {
  /**
   * Number of days to keep non-production deployments (mostly preview deployments) before soft deletion.
   */
  expirationDays?: number | undefined;
  /**
   * Number of days to keep production deployments before soft deletion.
   */
  expirationDaysProduction?: number | undefined;
  /**
   * Number of days to keep canceled deployments before soft deletion.
   */
  expirationDaysCanceled?: number | undefined;
  /**
   * Number of days to keep errored deployments before soft deletion.
   */
  expirationDaysErrored?: number | undefined;
  /**
   * Minimum number of production deployments to keep for this project, even if they are over the production expiration limit.
   */
  deploymentsToKeep?: number | undefined;
};

/**
 * Default job configuration applied to new projects created in this team.
 */
export type Lint = {
  /**
   * Default job configuration applied to new projects created in this team.
   */
  targets: Array<string>;
};

/**
 * Default job configuration applied to new projects created in this team.
 */
export type Typecheck = {
  /**
   * Default job configuration applied to new projects created in this team.
   */
  targets: Array<string>;
};

/**
 * Default job configuration applied to new projects created in this team.
 */
export type MfeConfigPresent = {
  /**
   * Default job configuration applied to new projects created in this team.
   */
  targets: Array<string>;
};

/**
 * Default job configuration applied to new projects created in this team.
 */
export type DefaultProjectJobs = {
  /**
   * Default job configuration applied to new projects created in this team.
   */
  lint?: Lint | undefined;
  /**
   * Default job configuration applied to new projects created in this team.
   */
  typecheck?: Typecheck | undefined;
  /**
   * Default job configuration applied to new projects created in this team.
   */
  mfeConfigPresent?: MfeConfigPresent | undefined;
};

/**
 * Whether toolbar is enabled on preview deployments
 */
export const EnablePreviewFeedback = {
  Default: "default",
  DefaultForce: "default-force",
  Off: "off",
  OffForce: "off-force",
  On: "on",
  OnForce: "on-force",
} as const;
/**
 * Whether toolbar is enabled on preview deployments
 */
export type EnablePreviewFeedback = ClosedEnum<typeof EnablePreviewFeedback>;

/**
 * Whether toolbar is enabled on production deployments
 */
export const EnableProductionFeedback = {
  Default: "default",
  DefaultForce: "default-force",
  Off: "off",
  OffForce: "off-force",
  On: "on",
  OnForce: "on-force",
} as const;
/**
 * Whether toolbar is enabled on production deployments
 */
export type EnableProductionFeedback = ClosedEnum<
  typeof EnableProductionFeedback
>;

/**
 * Sensitive environment variable policy for this team
 */
export const SensitiveEnvironmentVariablePolicy = {
  Default: "default",
  Off: "off",
  On: "on",
} as const;
/**
 * Sensitive environment variable policy for this team
 */
export type SensitiveEnvironmentVariablePolicy = ClosedEnum<
  typeof SensitiveEnvironmentVariablePolicy
>;

/**
 * Controls who can request access to protected deployments.
 */
export const DpAccessRequestsMode = {
  All: "all",
  EmailDomain: "email-domain",
  None: "none",
} as const;
/**
 * Controls who can request access to protected deployments.
 */
export type DpAccessRequestsMode = ClosedEnum<typeof DpAccessRequestsMode>;

export type IpBuckets = {
  bucket: string;
  supportUntil?: number | undefined;
  default?: boolean | undefined;
};

/**
 * When enabled, deployment protection settings require stricter permissions (owner-only).
 */
export type StrictDeploymentProtectionSettings = {
  enabled: boolean;
  updatedAt: number;
};

/**
 * When enabled, creating shareable links requires Owner role.
 */
export type StrictShareableLinks = {
  enabled: boolean;
  updatedAt: number;
};

export const Preference = {
  AutoApproval: "auto-approval",
  Block: "block",
  ManualApproval: "manual-approval",
} as const;
export type Preference = ClosedEnum<typeof Preference>;

/**
 * NSNB configuration for the team.
 */
export type NsnbConfig = {
  preference: Preference;
};

/**
 * Allowlist entry for GitLab, which uses nested groups rather than a flat org/repo. `namespace` is the full group path (e.g. `group` or `group/subgroup`); `project` is the leaf project name. Omit `project` to match any project under the namespace. Namespace is matched case-insensitively.
 */
export type Sources2 = {
  provider: "gitlab";
  namespace: string;
  project?: string | undefined;
};

export const SourcesProvider = {
  Bitbucket: "bitbucket",
  Github: "github",
} as const;
export type SourcesProvider = ClosedEnum<typeof SourcesProvider>;

/**
 * Allowlist entry for GitHub and Bitbucket, whose repos are identified by a flat `org`/`repo` (Bitbucket's workspace/owner maps to `org`, its repo slug to `repo`). Omit `repo` to match any repo in the org. Org is matched case-insensitively.
 */
export type Sources1 = {
  provider: SourcesProvider;
  org: string;
  repo?: string | undefined;
};

export type Sources =
  | (Sources1 & { provider: "bitbucket" })
  | (Sources1 & { provider: "github" })
  | Sources2;

export type Environments2 = {
  type: "custom";
  environmentId: string;
};

export const EnvironmentsTarget = {
  Preview: "preview",
  Production: "production",
} as const;
export type EnvironmentsTarget = ClosedEnum<typeof EnvironmentsTarget>;

export type Environments1 = {
  type: "system";
  target: EnvironmentsTarget;
};

export type TeamEnvironments = Environments1 | Environments2;

/**
 * `enabled: true` with empty `sources` is deny-all.
 */
export type GitSources = {
  sources: Array<
    | (Sources1 & { provider: "bitbucket" })
    | (Sources1 & { provider: "github" })
    | Sources2
  >;
  enabled: boolean;
  environments: Array<Environments1 | Environments2>;
};

/**
 * Customer-configurable deployment sources. Every deploy classifies to exactly one. JSON schema in `packages/deployment-policy/schemas/body.ts` enumerates exactly these values. - `'git'` — git provider webhook. - `'cli'` — Vercel CLI (legacy classic-token CLI and SIWV CLI both). - `'rest-api'` — direct user/team-token REST upload. Does NOT cover deploy hooks, Marketplace integrations, or first-party app tokens. - `'deploy-hook'` — project deploy-hook URL. The URL is the credential. - `'integration'` — third-party Marketplace actor: Marketplace integration token, user-delegated OAuth from a Marketplace app, or an unrecognized third-party Vercel App. First-party Vercel Apps are never `'integration'`. - `'v0'` — the v0 product surface (entitlement-gated). v0 deploys through the CLI under the hood, but classifies as its own source so a team can allow or deny v0 independently of `'cli'`. First-party Vercel apps (Toolbar, etc.) classify as `'first-party'` — see `ClassifiedSource` in `./checks`. They're not in this union because they aren't customer-configurable; they bypass `checkDeploymentSources` entirely. v0 is intentionally NOT among them: like the CLI, it's a real product surface and is policy-controllable.
 */
export const TeamSources = {
  Cli: "cli",
  DeployHook: "deploy-hook",
  Git: "git",
  Integration: "integration",
  RestApi: "rest-api",
  V0: "v0",
} as const;
/**
 * Customer-configurable deployment sources. Every deploy classifies to exactly one. JSON schema in `packages/deployment-policy/schemas/body.ts` enumerates exactly these values. - `'git'` — git provider webhook. - `'cli'` — Vercel CLI (legacy classic-token CLI and SIWV CLI both). - `'rest-api'` — direct user/team-token REST upload. Does NOT cover deploy hooks, Marketplace integrations, or first-party app tokens. - `'deploy-hook'` — project deploy-hook URL. The URL is the credential. - `'integration'` — third-party Marketplace actor: Marketplace integration token, user-delegated OAuth from a Marketplace app, or an unrecognized third-party Vercel App. First-party Vercel Apps are never `'integration'`. - `'v0'` — the v0 product surface (entitlement-gated). v0 deploys through the CLI under the hood, but classifies as its own source so a team can allow or deny v0 independently of `'cli'`. First-party Vercel apps (Toolbar, etc.) classify as `'first-party'` — see `ClassifiedSource` in `./checks`. They're not in this union because they aren't customer-configurable; they bypass `checkDeploymentSources` entirely. v0 is intentionally NOT among them: like the CLI, it's a real product surface and is policy-controllable.
 */
export type TeamSources = ClosedEnum<typeof TeamSources>;

export type TeamEnvironments2 = {
  type: "custom";
  environmentId: string;
};

export const TeamEnvironmentsTarget = {
  Preview: "preview",
  Production: "production",
} as const;
export type TeamEnvironmentsTarget = ClosedEnum<typeof TeamEnvironmentsTarget>;

export type TeamEnvironments1 = {
  type: "system";
  target: TeamEnvironmentsTarget;
};

export type TeamDeploymentPolicyEnvironments =
  | TeamEnvironments1
  | TeamEnvironments2;

/**
 * `enabled: true` with empty `sources` is deny-all.
 */
export type DeploymentSources = {
  sources: Array<TeamSources>;
  enabled: boolean;
  environments: Array<TeamEnvironments1 | TeamEnvironments2>;
};

/**
 * Composable deployment-time policy for the team. Used as the default for every project on the team, with optional per-project overrides on `project.deploymentPolicy`.
 */
export type DeploymentPolicy = {
  gitSources?: Array<GitSources> | undefined;
  deploymentSources?: Array<DeploymentSources> | undefined;
};

export type Entitlements = {
  entitlement: string;
};

export const TeamRole = {
  Billing: "BILLING",
  Contributor: "CONTRIBUTOR",
  Developer: "DEVELOPER",
  Member: "MEMBER",
  Owner: "OWNER",
  Security: "SECURITY",
  Viewer: "VIEWER",
  ViewerForPlus: "VIEWER_FOR_PLUS",
} as const;
export type TeamRole = ClosedEnum<typeof TeamRole>;

export const TeamMembershipTeamRoles = {
  Billing: "BILLING",
  Contributor: "CONTRIBUTOR",
  Developer: "DEVELOPER",
  Member: "MEMBER",
  Owner: "OWNER",
  Security: "SECURITY",
  Viewer: "VIEWER",
  ViewerForPlus: "VIEWER_FOR_PLUS",
} as const;
export type TeamMembershipTeamRoles = ClosedEnum<
  typeof TeamMembershipTeamRoles
>;

export const TeamMembershipTeamPermissions = {
  CreateProject: "CreateProject",
  EnvVariableManager: "EnvVariableManager",
  EnvironmentManager: "EnvironmentManager",
  FullProductionDeployment: "FullProductionDeployment",
  IntegrationManager: "IntegrationManager",
  OrgAdmin: "OrgAdmin",
  OrgViewer: "OrgViewer",
  UsageViewer: "UsageViewer",
  V0Builder: "V0Builder",
  V0Chatter: "V0Chatter",
  V0Viewer: "V0Viewer",
} as const;
export type TeamMembershipTeamPermissions = ClosedEnum<
  typeof TeamMembershipTeamPermissions
>;

export const TeamOrigin = {
  AccountUpdate: "account-update",
  Bitbucket: "bitbucket",
  Dsync: "dsync",
  Feedback: "feedback",
  Github: "github",
  Gitlab: "gitlab",
  Import: "import",
  Link: "link",
  Mail: "mail",
  NsnbAutoApprove: "nsnb-auto-approve",
  NsnbHobbyUpgrade: "nsnb-hobby-upgrade",
  NsnbInvite: "nsnb-invite",
  NsnbRedeploy: "nsnb-redeploy",
  NsnbRedeployAttributionCard: "nsnb-redeploy-attribution-card",
  NsnbRequestAccess: "nsnb-request-access",
  NsnbViewerUpgrade: "nsnb-viewer-upgrade",
  OrganizationTeams: "organization-teams",
  Saml: "saml",
  Teams: "teams",
} as const;
export type TeamOrigin = ClosedEnum<typeof TeamOrigin>;

export type GitUserId = string | number;

export type JoinedFrom = {
  origin: TeamOrigin;
  commitId?: string | undefined;
  repoId?: string | undefined;
  repoPath?: string | undefined;
  gitUserId?: string | number | undefined;
  gitUserLogin?: string | undefined;
  ssoUserId?: string | undefined;
  ssoConnectedAt?: number | undefined;
  idpUserId?: string | undefined;
  dsyncUserId?: string | undefined;
  dsyncConnectedAt?: number | undefined;
};

/**
 * The membership of the authenticated User in relation to the Team.
 */
export type Membership = {
  uid?: string | undefined;
  entitlements?: Array<Entitlements> | undefined;
  teamId?: string | undefined;
  confirmed: true;
  accessRequestedAt?: number | undefined;
  role: TeamRole;
  teamRoles?: Array<TeamMembershipTeamRoles> | undefined;
  teamPermissions?: Array<TeamMembershipTeamPermissions> | undefined;
  createdAt: number;
  created: number;
  joinedFrom?: JoinedFrom | undefined;
};

/**
 * Data representing a Team.
 */
export type Team = {
  connect?: Connect | undefined;
  /**
   * The ID of the user who created the Team.
   */
  creatorId: string;
  /**
   * Timestamp (in milliseconds) of when the Team was last updated.
   */
  updatedAt: number;
  /**
   * Hostname that'll be matched with emails on sign-up to automatically join the Team.
   */
  emailDomain?: string | null | undefined;
  /**
   * When "Single Sign-On (SAML)" is configured, this object contains information regarding the configuration of the Identity Provider (IdP).
   */
  saml?: Saml | undefined;
  /**
   * Code that can be used to join this Team. Only visible to Team owners.
   */
  inviteCode?: string | undefined;
  /**
   * A short description of the Team.
   */
  description: string | null;
  /**
   * Default roles for the team.
   */
  defaultRoles?: DefaultRoles | undefined;
  /**
   * The prefix that is prepended to automatic aliases.
   */
  stagingPrefix: string;
  resourceConfig?: ResourceConfig | undefined;
  /**
   * The hostname that is current set as preview deployment suffix.
   */
  previewDeploymentSuffix?: string | null | undefined;
  /**
   * Whether the team is a platform team.
   */
  platform?: boolean | undefined;
  disableHardAutoBlocks?: number | boolean | undefined;
  /**
   * Is remote caching enabled for this team
   */
  remoteCaching?: RemoteCaching | undefined;
  /**
   * Default deployment protection for this team null indicates protection is disabled
   */
  defaultDeploymentProtection?: DefaultDeploymentProtection | undefined;
  /**
   * Default Passport configuration for new projects in this team.
   */
  defaultPassport?: DefaultPassport | null | undefined;
  /**
   * Default deployment expiration settings for this team
   */
  defaultExpirationSettings?: DefaultExpirationSettings | undefined;
  /**
   * Default job configuration applied to new projects created in this team.
   */
  defaultProjectJobs?: DefaultProjectJobs | undefined;
  /**
   * Whether toolbar is enabled on preview deployments
   */
  enablePreviewFeedback?: EnablePreviewFeedback | null | undefined;
  /**
   * Whether toolbar is enabled on production deployments
   */
  enableProductionFeedback?: EnableProductionFeedback | null | undefined;
  /**
   * Sensitive environment variable policy for this team
   */
  sensitiveEnvironmentVariablePolicy?:
    | SensitiveEnvironmentVariablePolicy
    | null
    | undefined;
  /**
   * Indicates if IP addresses should be accessible in observability (o11y) tooling
   */
  hideIpAddresses?: boolean | null | undefined;
  /**
   * Indicates if IP addresses should be accessible in log drains
   */
  hideIpAddressesInLogDrains?: boolean | null | undefined;
  /**
   * Controls who can request access to protected deployments.
   */
  dpAccessRequestsMode?: DpAccessRequestsMode | undefined;
  ipBuckets?: Array<IpBuckets> | undefined;
  /**
   * When enabled, all projects in the team require commits to be signed and verified by the git provider before deployments will be created. Projects may override this via `project.gitProviderOptions.requireVerifiedCommits` (gated by `Project:Update`).
   */
  requireVerifiedCommits?: boolean | undefined;
  /**
   * Default for projects in the team. When `true`, projects in this team will not emit GitHub repository-dispatch events on deployment events unless the project explicitly overrides this setting via `project.gitProviderOptions.disableRepositoryDispatchEvents`.
   */
  disableRepositoryDispatchEvents?: boolean | undefined;
  /**
   * When enabled, deployment protection settings require stricter permissions (owner-only).
   */
  strictDeploymentProtectionSettings?:
    | StrictDeploymentProtectionSettings
    | undefined;
  /**
   * When enabled, creating shareable links requires Owner role.
   */
  strictShareableLinks?: StrictShareableLinks | undefined;
  /**
   * NSNB configuration for the team.
   */
  nsnbConfig?: NsnbConfig | undefined;
  /**
   * Composable deployment-time policy for the team. Used as the default for every project on the team, with optional per-project overrides on `project.deploymentPolicy`.
   */
  deploymentPolicy?: DeploymentPolicy | undefined;
  /**
   * Timestamp (ms) after which personal access tokens created at or before this time are considered invalid for this team.
   */
  personalAccessTokensInvalidatedAt?: number | undefined;
  /**
   * Timestamp (ms) after which Vercel App tokens created at or before this time are considered invalid for this team.
   */
  appTokensInvalidatedAt?: number | undefined;
  /**
   * Timestamp (ms) after which API keys created at or before this time are considered invalid for this team.
   */
  apiKeysInvalidatedAt?: number | undefined;
  /**
   * Timestamp (ms) after which integration tokens created at or before this time are considered invalid for this team.
   */
  integrationTokensInvalidatedAt?: number | undefined;
  /**
   * The Team's unique identifier.
   */
  id: string;
  /**
   * The Team's slug, which is unique across the Vercel platform.
   */
  slug: string;
  /**
   * Name associated with the Team account, or `null` if none has been provided.
   */
  name: string | null;
  /**
   * The ID of the file used as avatar for this Team.
   */
  avatar: string | null;
  /**
   * The membership of the authenticated User in relation to the Team.
   */
  membership?: Membership | undefined;
  /**
   * UNIX timestamp (in milliseconds) when the Team was created.
   */
  createdAt: number;
  /**
   * The organizationId for child teams created under an organization.
   */
  parentId?: string | undefined;
  additionalProperties?: { [k: string]: any } | undefined;
};

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

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

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

/** @internal */
export const Connection$inboundSchema: z.ZodType<
  Connection,
  z.ZodTypeDef,
  unknown
> = z.object({
  status: types.string(),
  type: types.string(),
  state: types.string(),
  connectedAt: types.number(),
  lastReceivedWebhookEvent: types.optional(types.number()),
  lastSyncedAt: types.optional(types.number()),
  syncState: types.optional(SyncState$inboundSchema),
});

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

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

/** @internal */
export const Directory$inboundSchema: z.ZodType<
  Directory,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.string(),
  state: types.string(),
  connectedAt: types.number(),
  lastReceivedWebhookEvent: types.optional(types.number()),
  lastSyncedAt: types.optional(types.number()),
  syncState: types.optional(TeamSyncState$inboundSchema),
});

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

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

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

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

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

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

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

/** @internal */
export const Saml$inboundSchema: z.ZodType<Saml, z.ZodTypeDef, unknown> = z
  .object({
    connection: types.optional(z.lazy(() => Connection$inboundSchema)),
    directory: types.optional(z.lazy(() => Directory$inboundSchema)),
    enforced: types.boolean(),
    defaultRedirectUri: types.optional(DefaultRedirectUri$inboundSchema),
    roles: types.optional(
      z.record(smartUnion([
        z.lazy(() => Roles1$inboundSchema),
        Roles2$inboundSchema,
      ])),
    ),
  });

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

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

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

/** @internal */
export const DefaultRoles$inboundSchema: z.ZodType<
  DefaultRoles,
  z.ZodTypeDef,
  unknown
> = z.object({
  teamRoles: types.optional(z.array(TeamTeamRoles$inboundSchema)),
  teamPermissions: types.optional(z.array(TeamTeamPermissions$inboundSchema)),
});

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

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

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

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

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

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

/** @internal */
export const ResourceConfig$inboundSchema: z.ZodType<
  ResourceConfig,
  z.ZodTypeDef,
  unknown
> = z.object({
  concurrentBuilds: types.optional(types.number()),
  elasticConcurrencyEnabled: types.optional(types.boolean()),
  edgeConfigSize: types.optional(types.number()),
  edgeConfigs: types.optional(types.number()),
  kvDatabases: types.optional(types.number()),
  blobStores: types.optional(types.number()),
  postgresDatabases: types.optional(types.number()),
  customEnvironmentsPerProject: types.optional(types.number()),
  serverlessFunctionMaxMemorySize: types.optional(types.number()),
  buildEntitlements: types.optional(
    z.lazy(() => BuildEntitlements$inboundSchema),
  ),
  buildMachine: types.optional(z.lazy(() => BuildMachine$inboundSchema)),
});

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

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

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

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

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

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

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

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

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

/** @internal */
export const DefaultDeploymentProtection$inboundSchema: z.ZodType<
  DefaultDeploymentProtection,
  z.ZodTypeDef,
  unknown
> = z.object({
  passwordProtection: z.nullable(z.lazy(() => PasswordProtection$inboundSchema))
    .optional(),
  ssoProtection: z.nullable(z.lazy(() => SsoProtection$inboundSchema))
    .optional(),
});

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

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

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

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

/** @internal */
export const DefaultExpirationSettings$inboundSchema: z.ZodType<
  DefaultExpirationSettings,
  z.ZodTypeDef,
  unknown
> = z.object({
  expirationDays: types.optional(types.number()),
  expirationDaysProduction: types.optional(types.number()),
  expirationDaysCanceled: types.optional(types.number()),
  expirationDaysErrored: types.optional(types.number()),
  deploymentsToKeep: types.optional(types.number()),
});

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

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

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

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

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

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

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

/** @internal */
export const DefaultProjectJobs$inboundSchema: z.ZodType<
  DefaultProjectJobs,
  z.ZodTypeDef,
  unknown
> = z.object({
  lint: types.optional(z.lazy(() => Lint$inboundSchema)),
  typecheck: types.optional(z.lazy(() => Typecheck$inboundSchema)),
  "mfe-config-present": types.optional(
    z.lazy(() => MfeConfigPresent$inboundSchema),
  ),
}).transform((v) => {
  return remap$(v, {
    "mfe-config-present": "mfeConfigPresent",
  });
});

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

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

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

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

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

/** @internal */
export const IpBuckets$inboundSchema: z.ZodType<
  IpBuckets,
  z.ZodTypeDef,
  unknown
> = z.object({
  bucket: types.string(),
  supportUntil: types.optional(types.number()),
  default: types.optional(types.boolean()),
});

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

/** @internal */
export const StrictDeploymentProtectionSettings$inboundSchema: z.ZodType<
  StrictDeploymentProtectionSettings,
  z.ZodTypeDef,
  unknown
> = z.object({
  enabled: types.boolean(),
  updatedAt: types.number(),
});

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

/** @internal */
export const StrictShareableLinks$inboundSchema: z.ZodType<
  StrictShareableLinks,
  z.ZodTypeDef,
  unknown
> = z.object({
  enabled: types.boolean(),
  updatedAt: types.number(),
});

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

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

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

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

/** @internal */
export const Sources2$inboundSchema: z.ZodType<
  Sources2,
  z.ZodTypeDef,
  unknown
> = z.object({
  provider: types.literal("gitlab"),
  namespace: types.string(),
  project: types.optional(types.string()),
});

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

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

/** @internal */
export const Sources1$inboundSchema: z.ZodType<
  Sources1,
  z.ZodTypeDef,
  unknown
> = z.object({
  provider: SourcesProvider$inboundSchema,
  org: types.string(),
  repo: types.optional(types.string()),
});

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

/** @internal */
export const Sources$inboundSchema: z.ZodType<Sources, z.ZodTypeDef, unknown> =
  z.union([
    z.lazy(() => Sources1$inboundSchema).and(
      z.object({ provider: z.literal("bitbucket") }),
    ),
    z.lazy(() => Sources1$inboundSchema).and(
      z.object({ provider: z.literal("github") }),
    ),
    z.lazy(() => Sources2$inboundSchema),
  ]);

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

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

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

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

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

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

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

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

/** @internal */
export const GitSources$inboundSchema: z.ZodType<
  GitSources,
  z.ZodTypeDef,
  unknown
> = z.object({
  sources: z.array(
    z.union([
      z.lazy(() => Sources1$inboundSchema).and(
        z.object({ provider: z.literal("bitbucket") }),
      ),
      z.lazy(() => Sources1$inboundSchema).and(
        z.object({ provider: z.literal("github") }),
      ),
      z.lazy(() => Sources2$inboundSchema),
    ]),
  ),
  enabled: types.boolean(),
  environments: z.array(
    z.union([
      z.lazy(() => Environments1$inboundSchema),
      z.lazy(() => Environments2$inboundSchema),
    ]),
  ),
});

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

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

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

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

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

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

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

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

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

/** @internal */
export const DeploymentSources$inboundSchema: z.ZodType<
  DeploymentSources,
  z.ZodTypeDef,
  unknown
> = z.object({
  sources: z.array(TeamSources$inboundSchema),
  enabled: types.boolean(),
  environments: z.array(
    z.union([
      z.lazy(() => TeamEnvironments1$inboundSchema),
      z.lazy(() => TeamEnvironments2$inboundSchema),
    ]),
  ),
});

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

/** @internal */
export const DeploymentPolicy$inboundSchema: z.ZodType<
  DeploymentPolicy,
  z.ZodTypeDef,
  unknown
> = z.object({
  gitSources: types.optional(z.array(z.lazy(() => GitSources$inboundSchema))),
  deploymentSources: types.optional(
    z.array(z.lazy(() => DeploymentSources$inboundSchema)),
  ),
});

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

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

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

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

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

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

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

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

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

/** @internal */
export const JoinedFrom$inboundSchema: z.ZodType<
  JoinedFrom,
  z.ZodTypeDef,
  unknown
> = z.object({
  origin: TeamOrigin$inboundSchema,
  commitId: types.optional(types.string()),
  repoId: types.optional(types.string()),
  repoPath: types.optional(types.string()),
  gitUserId: types.optional(smartUnion([types.string(), types.number()])),
  gitUserLogin: types.optional(types.string()),
  ssoUserId: types.optional(types.string()),
  ssoConnectedAt: types.optional(types.number()),
  idpUserId: types.optional(types.string()),
  dsyncUserId: types.optional(types.string()),
  dsyncConnectedAt: types.optional(types.number()),
});

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

/** @internal */
export const Membership$inboundSchema: z.ZodType<
  Membership,
  z.ZodTypeDef,
  unknown
> = z.object({
  uid: types.optional(types.string()),
  entitlements: types.optional(
    z.array(z.lazy(() => Entitlements$inboundSchema)),
  ),
  teamId: types.optional(types.string()),
  confirmed: types.literal(true),
  accessRequestedAt: types.optional(types.number()),
  role: TeamRole$inboundSchema,
  teamRoles: types.optional(z.array(TeamMembershipTeamRoles$inboundSchema)),
  teamPermissions: types.optional(
    z.array(TeamMembershipTeamPermissions$inboundSchema),
  ),
  createdAt: types.number(),
  created: types.number(),
  joinedFrom: types.optional(z.lazy(() => JoinedFrom$inboundSchema)),
});

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

/** @internal */
export const Team$inboundSchema: z.ZodType<Team, z.ZodTypeDef, unknown> =
  collectExtraKeys$(
    z.object({
      connect: types.optional(z.lazy(() => Connect$inboundSchema)),
      creatorId: types.string(),
      updatedAt: types.number(),
      emailDomain: z.nullable(types.string()).optional(),
      saml: types.optional(z.lazy(() => Saml$inboundSchema)),
      inviteCode: types.optional(types.string()),
      description: types.nullable(types.string()),
      defaultRoles: types.optional(z.lazy(() => DefaultRoles$inboundSchema)),
      stagingPrefix: types.string(),
      resourceConfig: types.optional(
        z.lazy(() => ResourceConfig$inboundSchema),
      ),
      previewDeploymentSuffix: z.nullable(types.string()).optional(),
      platform: types.optional(types.boolean()),
      disableHardAutoBlocks: types.optional(
        smartUnion([types.number(), types.boolean()]),
      ),
      remoteCaching: types.optional(z.lazy(() => RemoteCaching$inboundSchema)),
      defaultDeploymentProtection: types.optional(
        z.lazy(() => DefaultDeploymentProtection$inboundSchema),
      ),
      defaultPassport: z.nullable(z.lazy(() => DefaultPassport$inboundSchema))
        .optional(),
      defaultExpirationSettings: types.optional(
        z.lazy(() => DefaultExpirationSettings$inboundSchema),
      ),
      defaultProjectJobs: types.optional(
        z.lazy(() => DefaultProjectJobs$inboundSchema),
      ),
      enablePreviewFeedback: z.nullable(EnablePreviewFeedback$inboundSchema)
        .optional(),
      enableProductionFeedback: z.nullable(
        EnableProductionFeedback$inboundSchema,
      ).optional(),
      sensitiveEnvironmentVariablePolicy: z.nullable(
        SensitiveEnvironmentVariablePolicy$inboundSchema,
      ).optional(),
      hideIpAddresses: z.nullable(types.boolean()).optional(),
      hideIpAddressesInLogDrains: z.nullable(types.boolean()).optional(),
      dpAccessRequestsMode: types.optional(DpAccessRequestsMode$inboundSchema),
      ipBuckets: types.optional(z.array(z.lazy(() => IpBuckets$inboundSchema))),
      requireVerifiedCommits: types.optional(types.boolean()),
      disableRepositoryDispatchEvents: types.optional(types.boolean()),
      strictDeploymentProtectionSettings: types.optional(
        z.lazy(() => StrictDeploymentProtectionSettings$inboundSchema),
      ),
      strictShareableLinks: types.optional(
        z.lazy(() => StrictShareableLinks$inboundSchema),
      ),
      nsnbConfig: types.optional(z.lazy(() => NsnbConfig$inboundSchema)),
      deploymentPolicy: types.optional(
        z.lazy(() => DeploymentPolicy$inboundSchema),
      ),
      personalAccessTokensInvalidatedAt: types.optional(types.number()),
      appTokensInvalidatedAt: types.optional(types.number()),
      apiKeysInvalidatedAt: types.optional(types.number()),
      integrationTokensInvalidatedAt: types.optional(types.number()),
      id: types.string(),
      slug: types.string(),
      name: types.nullable(types.string()),
      avatar: types.nullable(types.string()),
      membership: types.optional(z.lazy(() => Membership$inboundSchema)),
      createdAt: types.number(),
      parentId: types.optional(types.string()),
    }).catchall(z.any()),
    "additionalProperties",
    true,
  );

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