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

/**
 * The payload of the event, if requested.
 */
export type TwoHundredAndThirteen = {
  projectId: string;
  previous: UserEventPayloadPrevious | null;
  next: UserEventPayloadNext;
};

/**
 * The payload of the event, if requested.
 */
export type TwoHundredAndTwelve = {
  ownerId: string;
  source: string;
  cause: string;
};

/**
 * The payload of the event, if requested.
 */
export type TwoHundredAndEleven = {
  ownerId: string;
  source: string;
  cause: string;
  blockReason?: string | undefined;
};

/**
 * The payload of the event, if requested.
 */
export type TwoHundredAndTen = {
  ownerId: string;
  source: string;
  cause: string;
  reason?: string | null | undefined;
};

export type SiftRoute = {
  name: string;
};

/**
 * The payload of the event, if requested.
 */
export type TwoHundredAndNine = {
  ownerId: string;
  source: string;
  cause: string;
  blockReason?: string | undefined;
  siftRoute?: SiftRoute | undefined;
};

export const PreviousMode = {
  Organization: "organization",
  Team: "team",
} as const;
export type PreviousMode = ClosedEnum<typeof PreviousMode>;

export const PayloadMode = {
  Organization: "organization",
  Team: "team",
} as const;
export type PayloadMode = ClosedEnum<typeof PayloadMode>;

/**
 * The payload of the event, if requested.
 */
export type TwoHundredAndEight = {
  organizationId: string;
  teamId: string;
  teamName: string;
  previousMode: PreviousMode;
  mode: PayloadMode;
};

export const BillingPlan = {
  Enterprise: "enterprise",
  Platform: "platform",
} as const;
export type BillingPlan = ClosedEnum<typeof BillingPlan>;

/**
 * The payload of the event, if requested.
 */
export type TwoHundredAndSeven = {
  organizationId: string;
  teamId: string;
  billingPlan: BillingPlan;
};

/**
 * The payload of the event, if requested.
 */
export type TwoHundredAndSix = {
  organizationId: string;
  slug: string;
};

/**
 * The payload of the event, if requested.
 */
export type TwoHundredAndFive = {
  directoryGroupId: string;
  directoryId: string;
  organizationId: string;
};

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

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

export type PayloadNext = {
  default?: PayloadDefault | undefined;
  roles: { [k: string]: PayloadRoles };
};

/**
 * The payload of the event, if requested.
 */
export type TwoHundredAndFour = {
  directoryGroupId: string;
  directoryId: string;
  groupName: string;
  next: PayloadNext;
  organizationId: string;
};

/**
 * The payload of the event, if requested.
 */
export type TwoHundredAndThree = {
  organizationId: string;
  rootTeamId: string;
  slug: string;
  name: string;
};

/**
 * The payload of the event, if requested.
 */
export type TwoHundredAndTwo = {
  projectId?: string | undefined;
  projectName: string;
};

/**
 * The payload of the event, if requested.
 */
export type TwoHundredAndOne = {
  alertId: string;
  alertName: string;
};

export type Microfrontends3 = {
  updatedAt: number;
  groupIds: Array<any>;
  enabled: false;
  freeProjectForLegacyLimits?: boolean | undefined;
};

export type Microfrontends2 = {
  isDefaultApp?: false | undefined;
  /**
   * Whether observability data should be routed to this microfrontend project or a root project.
   */
  routeObservabilityToThisProject?: boolean | undefined;
  /**
   * Whether to add microfrontends routing to aliases. This means domains in this project will route as a microfrontend.
   */
  doNotRouteWithMicrofrontendsRouting?: boolean | undefined;
  /**
   * Timestamp when the microfrontends settings were last updated.
   */
  updatedAt: number;
  /**
   * The group IDs of microfrontends that this project belongs to. Each microfrontend project must belong to a microfrontends group that is the set of microfrontends that are used together.
   */
  groupIds: Array<string>;
  /**
   * Whether microfrontends are enabled for this project.
   */
  enabled: true;
  /**
   * A path that is used to take screenshots and as the default path in preview links when a domain for this microfrontend is shown in the UI. Includes the leading slash, e.g. `/docs`
   */
  defaultRoute?: string | undefined;
  /**
   * Whether the project was part of the legacy limits for hobby and pro-trial before billing was added. This field is only set when the team is upgraded to a paid plan and we are backfilling the subscription status. We cap the subscription to 2 projects and set this field for the 3rd project. When this field is set, the project is not charged for and we do not call any billing APIs for this project.
   */
  freeProjectForLegacyLimits?: boolean | undefined;
};

export type Microfrontends1 = {
  isDefaultApp: true;
  /**
   * Timestamp when the microfrontends settings were last updated.
   */
  updatedAt: number;
  /**
   * The group IDs of microfrontends that this project belongs to. Each microfrontend project must belong to a microfrontends group that is the set of microfrontends that are used together.
   */
  groupIds: Array<string>;
  /**
   * Whether microfrontends are enabled for this project.
   */
  enabled: true;
  /**
   * A path that is used to take screenshots and as the default path in preview links when a domain for this microfrontend is shown in the UI. Includes the leading slash, e.g. `/docs`
   */
  defaultRoute?: string | undefined;
  /**
   * Whether the project was part of the legacy limits for hobby and pro-trial before billing was added. This field is only set when the team is upgraded to a paid plan and we are backfilling the subscription status. We cap the subscription to 2 projects and set this field for the 3rd project. When this field is set, the project is not charged for and we do not call any billing APIs for this project.
   */
  freeProjectForLegacyLimits?: boolean | undefined;
};

export type Microfrontends =
  | Microfrontends1
  | Microfrontends2
  | Microfrontends3;

export type UserEventPayload200Project = {
  id: string;
  name: string;
  microfrontends?:
    | Microfrontends1
    | Microfrontends2
    | Microfrontends3
    | undefined;
};

export type UserEventMicrofrontends3 = {
  updatedAt: number;
  groupIds: Array<any>;
  enabled: false;
  freeProjectForLegacyLimits?: boolean | undefined;
};

export type UserEventMicrofrontends2 = {
  isDefaultApp?: false | undefined;
  /**
   * Whether observability data should be routed to this microfrontend project or a root project.
   */
  routeObservabilityToThisProject?: boolean | undefined;
  /**
   * Whether to add microfrontends routing to aliases. This means domains in this project will route as a microfrontend.
   */
  doNotRouteWithMicrofrontendsRouting?: boolean | undefined;
  /**
   * Timestamp when the microfrontends settings were last updated.
   */
  updatedAt: number;
  /**
   * The group IDs of microfrontends that this project belongs to. Each microfrontend project must belong to a microfrontends group that is the set of microfrontends that are used together.
   */
  groupIds: Array<string>;
  /**
   * Whether microfrontends are enabled for this project.
   */
  enabled: true;
  /**
   * A path that is used to take screenshots and as the default path in preview links when a domain for this microfrontend is shown in the UI. Includes the leading slash, e.g. `/docs`
   */
  defaultRoute?: string | undefined;
  /**
   * Whether the project was part of the legacy limits for hobby and pro-trial before billing was added. This field is only set when the team is upgraded to a paid plan and we are backfilling the subscription status. We cap the subscription to 2 projects and set this field for the 3rd project. When this field is set, the project is not charged for and we do not call any billing APIs for this project.
   */
  freeProjectForLegacyLimits?: boolean | undefined;
};

export type UserEventMicrofrontends1 = {
  isDefaultApp: true;
  /**
   * Timestamp when the microfrontends settings were last updated.
   */
  updatedAt: number;
  /**
   * The group IDs of microfrontends that this project belongs to. Each microfrontend project must belong to a microfrontends group that is the set of microfrontends that are used together.
   */
  groupIds: Array<string>;
  /**
   * Whether microfrontends are enabled for this project.
   */
  enabled: true;
  /**
   * A path that is used to take screenshots and as the default path in preview links when a domain for this microfrontend is shown in the UI. Includes the leading slash, e.g. `/docs`
   */
  defaultRoute?: string | undefined;
  /**
   * Whether the project was part of the legacy limits for hobby and pro-trial before billing was added. This field is only set when the team is upgraded to a paid plan and we are backfilling the subscription status. We cap the subscription to 2 projects and set this field for the 3rd project. When this field is set, the project is not charged for and we do not call any billing APIs for this project.
   */
  freeProjectForLegacyLimits?: boolean | undefined;
};

export type PayloadMicrofrontends =
  | UserEventMicrofrontends1
  | UserEventMicrofrontends2
  | UserEventMicrofrontends3;

export type UserEventPayload200PrevProject = {
  microfrontends?:
    | UserEventMicrofrontends1
    | UserEventMicrofrontends2
    | UserEventMicrofrontends3
    | undefined;
};

export type PayloadPrev = {
  project: UserEventPayload200PrevProject;
};

export type PayloadGroup = {
  id: string;
  slug: string;
  name: string;
};

/**
 * The payload of the event, if requested.
 */
export type TwoHundred = {
  project: UserEventPayload200Project;
  prev: PayloadPrev;
  group: PayloadGroup;
};

export type UserEventPayload199Project = {
  id: string;
  name: string;
};

export type Group = {
  id: string;
  slug: string;
  name: string;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndNinetyNine = {
  project: UserEventPayload199Project;
  group: Group;
};

export type Prev = {
  name: string;
  slug: string;
  fallbackEnvironment: string;
  enablePolyrepoBranchRouting?: boolean | undefined;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndNinetyEight = {
  id: string;
  slug?: string | undefined;
  name?: string | undefined;
  fallbackEnvironment?: string | undefined;
  enablePolyrepoBranchRouting?: boolean | undefined;
  prev: Prev;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndNinetySeven = {
  id: string;
  slug: string;
  name: string;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndNinetySix = {
  enabled: boolean;
  allowedIntegrationCount?: number | undefined;
  allowedIntegrationIds?: Array<string> | undefined;
};

export type Periods = {
  periodNumber: number;
  percent: string;
  startDate: string;
  endDate: string;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndNinetyFive = {
  periods: Array<Periods>;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndNinetyFour = {
  projectId: string;
  toDeploymentId: string;
  projectName: string;
};

export type Names = {
  en: string;
};

export type City = {
  names: Names;
};

export type PayloadNames = {
  en: string;
};

export type Country = {
  names: PayloadNames;
};

export type UserEventPayloadNames = {
  en: string;
};

export type MostSpecificSubdivision = {
  names: UserEventPayloadNames;
};

export type Geolocation = {
  city?: City | undefined;
  country: Country;
  mostSpecificSubdivision?: MostSpecificSubdivision | undefined;
  regionName?: string | undefined;
};

export const UserEvent2Origin = {
  RecoveryCode: "recovery-code",
  Totp: "totp",
  Webauthn: "webauthn",
} as const;
export type UserEvent2Origin = ClosedEnum<typeof UserEvent2Origin>;

export type Two2 = {
  origin: UserEvent2Origin;
};

export const TwoOrigin = {
  Apple: "apple",
  Bitbucket: "bitbucket",
  Chatgpt: "chatgpt",
  Email: "email",
  EmuRecovery: "emu-recovery",
  Github: "github",
  Gitlab: "gitlab",
  Google: "google",
  Invite: "invite",
  MagicLink: "magic-link",
  Otp: "otp",
  OtpLink: "otp-link",
  Saml: "saml",
  Webauthn: "webauthn",
} as const;
export type TwoOrigin = ClosedEnum<typeof TwoOrigin>;

export type Two1 = {
  origin: TwoOrigin;
  username?: string | undefined;
  teamId?: string | undefined;
  legacy?: boolean | undefined;
  ssoType?: string | undefined;
};

export type Factors2 = Two1 | Two2;

export const OneOrigin = {
  Apple: "apple",
  Bitbucket: "bitbucket",
  Chatgpt: "chatgpt",
  Email: "email",
  EmuRecovery: "emu-recovery",
  Github: "github",
  Gitlab: "gitlab",
  Google: "google",
  Invite: "invite",
  MagicLink: "magic-link",
  Otp: "otp",
  OtpLink: "otp-link",
  Saml: "saml",
  Webauthn: "webauthn",
} as const;
export type OneOrigin = ClosedEnum<typeof OneOrigin>;

export type One1 = {
  origin: OneOrigin;
  username?: string | undefined;
  teamId?: string | undefined;
  legacy?: boolean | undefined;
  ssoType?: string | undefined;
};

export type Factors1 = One1;

export type Factors = Array<One1> | Array<Two1 | Two2>;

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndNinetyThree = {
  userAgent?: string | undefined;
  geolocation?: Geolocation | null | undefined;
  env?: string | undefined;
  os?: string | undefined;
  /**
   * Browser login correlation ID. This is not an authentication credential.
   */
  loginSessionId?: string | undefined;
  username?: string | undefined;
  ssoType?: string | undefined;
  factors?: Array<One1> | Array<Two1 | Two2> | undefined;
  viaOTP?: boolean | undefined;
  viaGithub?: boolean | undefined;
  viaGitlab?: boolean | undefined;
  viaBitbucket?: boolean | undefined;
  viaGoogle?: boolean | undefined;
  viaApple?: boolean | undefined;
  viaSamlSso?: boolean | undefined;
  viaPasskey?: boolean | undefined;
};

export const UserEventPayload192Provider = {
  Apple: "apple",
  Bitbucket: "bitbucket",
  Chatgpt: "chatgpt",
  Github: "github",
  GithubCustomHost: "github-custom-host",
  GithubLimited: "github-limited",
  Gitlab: "gitlab",
  Google: "google",
  Saml: "saml",
} as const;
export type UserEventPayload192Provider = ClosedEnum<
  typeof UserEventPayload192Provider
>;

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndNinetyTwo = {
  provider: UserEventPayload192Provider;
};

export const UserEventPayload191Provider = {
  Apple: "apple",
  Bitbucket: "bitbucket",
  Chatgpt: "chatgpt",
  Github: "github",
  GithubCustomHost: "github-custom-host",
  GithubLimited: "github-limited",
  Gitlab: "gitlab",
  Google: "google",
  Saml: "saml",
} as const;
export type UserEventPayload191Provider = ClosedEnum<
  typeof UserEventPayload191Provider
>;

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndNinetyOne = {
  provider: UserEventPayload191Provider;
  login: string;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndNinety = {
  logDrainUrl: string;
  integrationName?: string | undefined;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndEightyNine = {
  logDrainUrl: string | null;
  integrationName?: string | undefined;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndEightyEight = {
  issuerId: string;
  issuerName: string;
  kind: string;
  policyKey: string;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndEightySeven = {
  issuerId: string;
  issuerName: string;
  kind: string;
  projectId?: string | undefined;
  clientId?: string | undefined;
  environments?: Array<string> | undefined;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndEightySix = {
  issuerId: string;
  issuerName: string;
  keyId?: string | undefined;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndEightyFive = {
  issuerId: string;
  issuerName: string;
  managedBy?: string | undefined;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndEightyFour = {
  issuerId: string;
  issuerName: string;
  algorithm: string;
  origin: string;
  managedBy?: string | undefined;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndEightyThree = {
  integrationId: string;
  integrationSlug: string;
  integrationName: string;
};

export const UserEventPayload182RequestKind = {
  GetKeyData: "get_key_data",
} as const;
export type UserEventPayload182RequestKind = ClosedEnum<
  typeof UserEventPayload182RequestKind
>;

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndEightyTwo = {
  resourceId: string;
  integrationId: string;
  integrationSlug: string;
  integrationProductSlug: string;
  configurationId: string;
  errorCode?: string | undefined;
  requestKind: UserEventPayload182RequestKind;
  key: string;
};

export const UserEventPayloadRequestKind = {
  GetKeysMetadata: "get_keys_metadata",
} as const;
export type UserEventPayloadRequestKind = ClosedEnum<
  typeof UserEventPayloadRequestKind
>;

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndEightyOne = {
  resourceId: string;
  integrationId: string;
  integrationSlug: string;
  integrationProductSlug: string;
  configurationId: string;
  errorCode?: string | undefined;
  requestKind: UserEventPayloadRequestKind;
  keys: Array<string>;
};

export const PayloadRequestKind = {
  ListKeys: "list_keys",
} as const;
export type PayloadRequestKind = ClosedEnum<typeof PayloadRequestKind>;

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndEighty = {
  resourceId: string;
  integrationId: string;
  integrationSlug: string;
  integrationProductSlug: string;
  configurationId: string;
  errorCode?: string | undefined;
  requestKind: PayloadRequestKind;
  pattern?: string | undefined;
  type?: string | undefined;
};

export const RequestKind = {
  RawCommands: "raw_commands",
} as const;
export type RequestKind = ClosedEnum<typeof RequestKind>;

export type Commands = {
  command: string;
  errorCode?: string | undefined;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndSeventyNine = {
  resourceId: string;
  integrationId: string;
  integrationSlug: string;
  integrationProductSlug: string;
  configurationId: string;
  errorCode?: string | undefined;
  requestKind: RequestKind;
  readonly: boolean;
  commands: Array<Commands>;
  errorIndex?: number | undefined;
};

export const QueryType = {
  DataEdit: "data-edit",
  DataView: "data-view",
  Schema: "schema",
  User: "user",
} as const;
export type QueryType = ClosedEnum<typeof QueryType>;

export type PrimaryKey = {
  column: string;
  value: string | null;
};

export type Queries = {
  command: string | null;
  rowCount?: number | undefined;
  tables?: Array<string> | undefined;
  primaryKey?: Array<PrimaryKey> | undefined;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndSeventyEight = {
  resourceId: string;
  integrationId: string;
  integrationSlug: string;
  integrationProductSlug: string;
  configurationId: string;
  databaseName: string;
  queryType: QueryType;
  readonly: boolean;
  rolledBack: boolean;
  failedQueryIndex: number | null;
  errorCode: string | null;
  queryCount: number;
  queries: Array<Queries>;
};

export const ProjectIds2 = {
  All: "all",
} as const;
export type ProjectIds2 = ClosedEnum<typeof ProjectIds2>;

export type ProjectIds = Array<string> | ProjectIds2;

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndSeventySeven = {
  integrationId: string;
  configurationId: string;
  integrationSlug: string;
  integrationName: string;
  ownerId: string;
  projectIds?: Array<string> | ProjectIds2 | undefined;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndSeventySix = {
  integrationId: string;
  configurationId: string;
  integrationSlug: string;
  integrationName: string;
  ownerId: string;
  billingPlanId: string;
  billingPlanName?: string | undefined;
};

export type Configurations = {
  integrationId: string;
  configurationId: string;
  integrationSlug: string;
  integrationName?: string | undefined;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndSeventyFive = {
  configurations: Array<Configurations>;
  ownerId: string;
};

export type PayloadIntegration = {
  id: string;
  slug: string;
  name: string;
  configurationId: string;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndSeventyFour = {
  integration: PayloadIntegration;
  originTeamId: string;
  originTeamName: string;
};

export type Integration = {
  id: string;
  slug: string;
  name: string;
  configurationId: string;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndSeventyThree = {
  integration: Integration;
  destinationTeamId: string;
  destinationTeamName: string;
};

/**
 * The payload of the event, if requested.
 */
export type OneHundredAndSeventyTwo = {
  integrationId: string;
  configurationId: string;
  integrationSlug: string;
  integrationName: string;
  ownerId: string;
  projectIds?: Array<string> | undefined;
  confirmedScopes: Array<string>;
};

export const UserEventPayload171Action = {
  Blocked: "blocked",
  HardBlocked: "hard-blocked",
  SoftBlocked: "soft-blocked",
  Unblocked: "unblocked",
} as const;
export type UserEventPayload171Action = ClosedEnum<
  typeof UserEventPayload171Action
>;

/**
 * Since June 2023
 */
export type BlockHistory = {
  action: UserEventPayload171Action;
  createdAt: number;
  caseId?: string | undefined;
  reason: string;
  actor?: string | undefined;
  statusCode?: number | undefined;
  comment?: string | undefined;
  ineligibleForAppeal?: boolean | undefined;
};

/**
 * (scanner history). Since November 2021. First element is newest.
 */
export type History = {
  scanner: string;
  reason: string;
  by: string;
  byId: string;
  at: number;
};

/**
 * Since June 2026. A hard block that is scheduled (the delay varies by source; see `executeAt`) but not yet executed. Powers admin visibility, scheduler dedup, and cancellation. Cleared on execution or when the team is unblocked/reviewed before `executeAt`; the executor treats its absence as "block cancelled".
 */
export type ScheduledBlock = {
  /**
   * Unix ms timestamp of the scheduled EventBridge execution.
   */
  executeAt: number;
  /**
   * Violation reason (string value of the `Violation` enum).
   */
  reason: string;
  /**
   * What triggered the scheduled block (string value of `TeamBlockSource`).
   */
  source: string;
  /**
   * Unix ms timestamp of when the marker was written.
   */
  createdAt: number;
  /**
   * Absent from the automated evaluation path, which has no case.
   */
  caseId?: string | undefined;
  /**
   * EventBridge schedule name, persisted so the pending event can be cancelled.
   */
  scheduleName?: string | undefined;
};

export type Abuse = {
  /**
   * Since June 2023
   */
  blockHistory?: Array<BlockHistory> | undefined;
  /**
   * Since March 2022. Helps abuse checks by tracking git auths. Format: `<platform>:<detail>:<value>`
   */
  gitAuthHistory?: Array<string> | undefined;
  /**
   * (scanner history). Since November 2021. First element is newest.
   */
  history?: Array<History> | undefined;
  /**
   * Since September 2023. How often did this owner trigger an actual git lineage deploy block?
   */
  gitLineageBlocks?: number | undefined;
  /**
   * Since September 2023. How often did this owner trigger a git lineage deploy block dry run?
   */
  gitLineageBlocksDry?: number | undefined;
  /**
   * Since November 2021. Guides the abuse scanner in build container.
   */
  scanner?: string | undefined;
  /**
   * Since December 2025. UTC timestamp string of when an auto-unblock is scheduled. Format: "Wed, 03 Dec 2025 20:32:13 GMT"
   */
  scheduledUnblockAt?: string | undefined;
  /**
   * Since June 2026. A hard block that is scheduled (the delay varies by source; see `executeAt`) but not yet executed. Powers admin visibility, scheduler dedup, and cancellation. Cleared on execution or when the team is unblocked/reviewed before `executeAt`; the executor treats its absence as "block cancelled".
   */
  scheduledBlock?: ScheduledBlock | undefined;
  /**
   * Since November 2021
   */
  updatedAt: number;
  creationUserAgent?: string | undefined;
  creationIp?: string | undefined;
  removedPhoneNumbers?: string | undefined;
};

export const UserEventPayload171Plan = {
  Enterprise: "enterprise",
  Hobby: "hobby",
  Pro: "pro",
} as const;
export type UserEventPayload171Plan = ClosedEnum<
  typeof UserEventPayload171Plan
>;

export type PayloadBilling = {
  plan: UserEventPayload171Plan;
};

export type Credentials2 = {
  type: "github-oauth-custom-host";
  host: string;
  id: string;
};

export const CredentialsType = {
  Apple: "apple",
  Bitbucket: "bitbucket",
  Chatgpt: "chatgpt",
  GithubOauth: "github-oauth",
  GithubOauthLimited: "github-oauth-limited",
  Gitlab: "gitlab",
  Google: "google",
  Vercel: "vercel",
} as const;
export type CredentialsType = ClosedEnum<typeof CredentialsType>;

export type Credentials1 = {
  type: CredentialsType;
  id: string;
};

export type Credentials =
  | (Credentials1 & { type: "apple" })
  | (Credentials1 & { type: "bitbucket" })
  | (Credentials1 & { type: "chatgpt" })
  | (Credentials1 & { type: "github-oauth" })
  | (Credentials1 & { type: "github-oauth-limited" })
  | (Credentials1 & { type: "gitlab" })
  | (Credentials1 & { type: "google" })
  | (Credentials1 & { type: "vercel" })
  | Credentials2;

export type PayloadDataCache = {
  excessBillingEnabled?: boolean | undefined;
};

export type PayloadDismissals = {
  scopeId: string;
  createdAt: number;
};

export type PayloadDismissedToasts = {
  name: string;
  dismissals: Array<PayloadDismissals>;
};

export type PayloadFavoriteProjectsAndSpaces = {
  teamId: string;
  projectId: string;
};

export type PayloadImportFlowGitNamespace = string | number;

export type PayloadImportFlowGitNamespaceId = string | number;

export const PayloadImportFlowGitProvider = {
  Bitbucket: "bitbucket",
  CursorOrigin: "cursor-origin",
  Github: "github",
  GithubCustomHost: "github-custom-host",
  GithubLimited: "github-limited",
  Gitlab: "gitlab",
  Vercel: "vercel",
} as const;
export type PayloadImportFlowGitProvider = ClosedEnum<
  typeof PayloadImportFlowGitProvider
>;

export type PayloadGitNamespaceId = string | number;

export type PayloadPreferredScopesAndGitNamespaces = {
  scopeId: string;
  gitNamespaceId: string | number | null;
};

export type PreventAutoBlocking = number | boolean;

export const PayloadWidget = {
  AnalyticsOnline: "analytics-online",
  AnalyticsPageViews: "analytics-page-views",
  AnalyticsVisitors: "analytics-visitors",
  FirewallAllowed: "firewall-allowed",
  FirewallDenied: "firewall-denied",
  ObservabilityAlert: "observability-alert",
  ObservabilityEdgeRequests: "observability-edge-requests",
  ObservabilityErrorRate: "observability-error-rate",
  ObservabilityFunctionInvocations: "observability-function-invocations",
  Shortcut: "shortcut",
  SpeedInsightsCls: "speed-insights-cls",
  SpeedInsightsLcp: "speed-insights-lcp",
  SpeedInsightsRes: "speed-insights-res",
} as const;
export type PayloadWidget = ClosedEnum<typeof PayloadWidget>;

export type Config = {
  url: string;
};

export type ProjectCardWidgetPreferences = {
  projectId: string;
  widget: PayloadWidget;
  config?: Config | undefined;
};

/**
 * Represents configuration for remote caching
 */
export type UserEventPayloadRemoteCaching = {
  enabled?: boolean | undefined;
};

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

export const UserEventPayload171Configuration = {
  SkipNamespaceQueue: "SKIP_NAMESPACE_QUEUE",
  WaitForNamespaceQueue: "WAIT_FOR_NAMESPACE_QUEUE",
} as const;
export type UserEventPayload171Configuration = ClosedEnum<
  typeof UserEventPayload171Configuration
>;

export type PayloadBuildQueue = {
  configuration?: UserEventPayload171Configuration | undefined;
};

export type PayloadSecurity = {
  rateLimit?: number | undefined;
  customRules?: number | undefined;
  ipBlocks?: number | undefined;
  ipBypass?: number | undefined;
};

/**
 * Default build machine type for new deployments. This must be used in combination with the buildEntitlements field. It is respected over Vercel's notion of the default build machine, and was originally implemented to allow Teams to "downgrade". - Hobby customers cannot set this, because they only have access to one machine type - Pro customers get Turbo machines by default, so this field is effectively for downgrading - ENT customers cannot set this (yet), because their default is based on their contract. https://linear.app/vercel/project/self-serve-build-machines-for-enterprise-customers-0cbc357e26d2/overview
 */
export const UserEventPayloadDefault = {
  Basic: "basic",
  Elastic: "elastic",
  Enhanced: "enhanced",
  Standard: "standard",
  Turbo: "turbo",
} as const;
/**
 * Default build machine type for new deployments. This must be used in combination with the buildEntitlements field. It is respected over Vercel's notion of the default build machine, and was originally implemented to allow Teams to "downgrade". - Hobby customers cannot set this, because they only have access to one machine type - Pro customers get Turbo machines by default, so this field is effectively for downgrading - ENT customers cannot set this (yet), because their default is based on their contract. https://linear.app/vercel/project/self-serve-build-machines-for-enterprise-customers-0cbc357e26d2/overview
 */
export type UserEventPayloadDefault = ClosedEnum<
  typeof UserEventPayloadDefault
>;

/**
 * Build machine configuration recorded on a team or user `resourceConfig`. This is deliberately separate from the build machine config recorded on a deployment (`DeploymentBuildMachine` in `@api/deployments-types`). A team/user only expresses its default machine for new deployments; the per-build fields (`purchaseType`, `defaultPurchaseType`, `machineSelectionType`, `cores`, `memory`) are recorded on the deployment record when a build actually runs and never belong on a team/user document.
 */
export type PayloadBuildMachine = {
  /**
   * Default build machine type for new deployments. This must be used in combination with the buildEntitlements field. It is respected over Vercel's notion of the default build machine, and was originally implemented to allow Teams to "downgrade". - Hobby customers cannot set this, because they only have access to one machine type - Pro customers get Turbo machines by default, so this field is effectively for downgrading - ENT customers cannot set this (yet), because their default is based on their contract. https://linear.app/vercel/project/self-serve-build-machines-for-enterprise-customers-0cbc357e26d2/overview
   */
  default?: UserEventPayloadDefault | undefined;
};

export type PayloadResourceConfig = {
  concurrentBuilds?: number | undefined;
  nodeType?: string | undefined;
  elasticConcurrencyEnabled?: boolean | undefined;
  buildEntitlements?: PayloadBuildEntitlements | undefined;
  buildQueue?: PayloadBuildQueue | undefined;
  awsAccountType?: string | undefined;
  awsAccountIds?: Array<string> | undefined;
  cfZoneName?: string | undefined;
  imageOptimizationType?: string | undefined;
  edgeConfigs?: number | undefined;
  edgeConfigSize?: number | undefined;
  edgeFunctionMaxSizeBytes?: number | undefined;
  edgeFunctionExecutionTimeoutMs?: number | undefined;
  serverlessFunctionMaxDuration?: number | undefined;
  serverlessFunctionMaxMemorySize?: number | undefined;
  kvDatabases?: number | undefined;
  postgresDatabases?: number | undefined;
  blobStores?: number | undefined;
  integrationStores?: number | undefined;
  cronJobsPerProject?: number | undefined;
  microfrontendGroupsPerTeam?: number | undefined;
  microfrontendProjectsPerGroup?: number | undefined;
  flagsExplorerOverridesThreshold?: number | undefined;
  flagsExplorerUnlimitedOverrides?: boolean | undefined;
  customEnvironmentsPerProject?: number | undefined;
  security?: PayloadSecurity | undefined;
  bulkRedirectsFreeLimitOverride?: number | undefined;
  /**
   * Build machine configuration recorded on a team or user `resourceConfig`. This is deliberately separate from the build machine config recorded on a deployment (`DeploymentBuildMachine` in `@api/deployments-types`). A team/user only expresses its default machine for new deployments; the per-build fields (`purchaseType`, `defaultPurchaseType`, `machineSelectionType`, `cores`, `memory`) are recorded on the deployment record when a build actually runs and never belong on a team/user document.
   */
  buildMachine?: PayloadBuildMachine | undefined;
};

/**
 * Overrides for a ramp (slew-rate) admission limit, which bounds how quickly the allowed rate may change over time rather than capping a fixed quantity. All three are expressed in units per minute. - `minRate`: the floor the allowed rate never drops below. Also the cold-start rate a new or idle consumer begins at. - `maxRate`: the ceiling the allowed rate may climb to. - `stepPerMinute`: how much the allowed rate moves per minute of activity — the slope at which it ramps up toward `maxRate` (and, where supported, decays back down toward `minRate`).
 */
export type ResourceLimits2 = {
  minRate?: number | undefined;
  maxRate?: number | undefined;
  stepPerMinute?: number | undefined;
};

/**
 * Override for a token-bucket rate limit: a fixed quantity per duration.
 */
export type ResourceLimits1 = {
  max: number;
  duration: number;
};

export type ResourceLimits = ResourceLimits1 | ResourceLimits2;

export const PayloadViewPreference = {
  Cards: "cards",
  List: "list",
} as const;
export type PayloadViewPreference = ClosedEnum<typeof PayloadViewPreference>;

export const PayloadFavoritesViewPreference = {
  Closed: "closed",
  Open: "open",
} as const;
export type PayloadFavoritesViewPreference = ClosedEnum<
  typeof PayloadFavoritesViewPreference
>;

export const PayloadRecentsViewPreference = {
  Closed: "closed",
  Open: "open",
} as const;
export type PayloadRecentsViewPreference = ClosedEnum<
  typeof PayloadRecentsViewPreference
>;

export type PayloadActiveDashboardViews = {
  scopeId: string;
  viewPreference?: PayloadViewPreference | null | undefined;
  favoritesViewPreference?: PayloadFavoritesViewPreference | null | undefined;
  recentsViewPreference?: PayloadRecentsViewPreference | null | undefined;
};

export type SecondaryEmails = {
  email: string;
  verified: boolean;
};

export type PayloadRules = {
  email: string;
};

export type EmailNotifications = {
  rules?: { [k: string]: PayloadRules } | undefined;
};

export type PayloadReasons = {
  name: string;
  value: string;
};

export type SiftScores = {
  score: number;
  reasons: Array<PayloadReasons>;
};

export const UserEventPayloadName = {
  String: "string",
} as const;
export type UserEventPayloadName = ClosedEnum<typeof UserEventPayloadName>;

export type PayloadSiftRoute = {
  name: UserEventPayloadName;
};

export const UserEventPayload171Reason = {
  BlockedForPlatformAbuse: "BLOCKED_FOR_PLATFORM_ABUSE",
  DomainOwnerDeletionRequest: "DOMAIN_OWNER_DELETION_REQUEST",
  EnterpriseTrialEnded: "ENTERPRISE_TRIAL_ENDED",
  EnterpriseUnpaidInvoice: "ENTERPRISE_UNPAID_INVOICE",
  ExposureCapExceeded: "EXPOSURE_CAP_EXCEEDED",
  FairUseLimitsExceeded: "FAIR_USE_LIMITS_EXCEEDED",
  SubscriptionCanceled: "SUBSCRIPTION_CANCELED",
  SubscriptionExpired: "SUBSCRIPTION_EXPIRED",
  UnpaidInvoice: "UNPAID_INVOICE",
} as const;
export type UserEventPayload171Reason = ClosedEnum<
  typeof UserEventPayload171Reason
>;

export const PayloadBlockedDueToOverageType = {
  AnalyticsUsage: "analyticsUsage",
  Artifacts: "artifacts",
  Bandwidth: "bandwidth",
  BlobDataTransfer: "blobDataTransfer",
  BlobTotalAdvancedRequests: "blobTotalAdvancedRequests",
  BlobTotalAvgSizeInBytes: "blobTotalAvgSizeInBytes",
  BlobTotalGetResponseObjectSizeInBytes:
    "blobTotalGetResponseObjectSizeInBytes",
  BlobTotalSimpleRequests: "blobTotalSimpleRequests",
  ConnectDataTransfer: "connectDataTransfer",
  DataCacheRead: "dataCacheRead",
  DataCacheWrite: "dataCacheWrite",
  EdgeConfigRead: "edgeConfigRead",
  EdgeConfigWrite: "edgeConfigWrite",
  EdgeFunctionExecutionUnits: "edgeFunctionExecutionUnits",
  EdgeMiddlewareInvocations: "edgeMiddlewareInvocations",
  EdgeRequest: "edgeRequest",
  EdgeRequestAdditionalCpuDuration: "edgeRequestAdditionalCpuDuration",
  ElasticConcurrencyBuildSlots: "elasticConcurrencyBuildSlots",
  FastDataTransfer: "fastDataTransfer",
  FastOriginTransfer: "fastOriginTransfer",
  FluidCpuDuration: "fluidCpuDuration",
  FluidDuration: "fluidDuration",
  FunctionDuration: "functionDuration",
  FunctionInvocation: "functionInvocation",
  ImageOptimizationCacheRead: "imageOptimizationCacheRead",
  ImageOptimizationCacheWrite: "imageOptimizationCacheWrite",
  ImageOptimizationTransformation: "imageOptimizationTransformation",
  LogDrainsVolume: "logDrainsVolume",
  MonitoringMetric: "monitoringMetric",
  ObservabilityEvent: "observabilityEvent",
  OnDemandConcurrencyMinutes: "onDemandConcurrencyMinutes",
  RuntimeCacheRead: "runtimeCacheRead",
  RuntimeCacheWrite: "runtimeCacheWrite",
  ServerlessFunctionExecution: "serverlessFunctionExecution",
  SourceImages: "sourceImages",
  WafOwaspExcessBytes: "wafOwaspExcessBytes",
  WafOwaspRequests: "wafOwaspRequests",
  WafRateLimitRequest: "wafRateLimitRequest",
  WebAnalyticsEvent: "webAnalyticsEvent",
} as const;
export type PayloadBlockedDueToOverageType = ClosedEnum<
  typeof PayloadBlockedDueToOverageType
>;

export type PayloadSoftBlock = {
  blockedAt: number;
  reason: UserEventPayload171Reason;
  blockedDueToOverageType?: PayloadBlockedDueToOverageType | undefined;
  /**
   * Since September 2026. Set only by `billing-usage-alerts` for usage plans with a `blockDurationMs`; its presence marks a pause that expires on its own.
   */
  unpauseAt?: number | undefined;
};

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

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

export const UserEventPayloadTeamPermissions = {
  AiGatewayApiKeyOwnedBySelf: "AiGatewayApiKeyOwnedBySelf",
  AiGatewayBudgetManager: "AiGatewayBudgetManager",
  AiGatewayCredits: "AiGatewayCredits",
  AiGatewaySettings: "AiGatewaySettings",
  AiGatewayTranscriptsManager: "AiGatewayTranscriptsManager",
  AiGatewayTranscriptsViewer: "AiGatewayTranscriptsViewer",
  ConnectorManager: "ConnectorManager",
  CreateProject: "CreateProject",
  EnvVariableManager: "EnvVariableManager",
  EnvironmentManager: "EnvironmentManager",
  FullProductionDeployment: "FullProductionDeployment",
  IntegrationManager: "IntegrationManager",
  OrgAdmin: "OrgAdmin",
  OrgViewer: "OrgViewer",
  UsageViewer: "UsageViewer",
  V0Builder: "V0Builder",
  V0Chatter: "V0Chatter",
  V0Viewer: "V0Viewer",
  WorkflowDecryptor: "WorkflowDecryptor",
} as const;
export type UserEventPayloadTeamPermissions = ClosedEnum<
  typeof UserEventPayloadTeamPermissions
>;

export const UserEventPayload171Origin = {
  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 UserEventPayload171Origin = ClosedEnum<
  typeof UserEventPayload171Origin
>;

export type UserEventPayload171GitUserId = string | number;

/** @internal */
export const TwoHundredAndThirteen$inboundSchema: z.ZodType<
  TwoHundredAndThirteen,
  z.ZodTypeDef,
  unknown
> = z.object({
  projectId: types.string(),
  previous: types.nullable(UserEventPayloadPrevious$inboundSchema),
  next: UserEventPayloadNext$inboundSchema,
});

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

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

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

/** @internal */
export const TwoHundredAndEleven$inboundSchema: z.ZodType<
  TwoHundredAndEleven,
  z.ZodTypeDef,
  unknown
> = z.object({
  ownerId: types.string(),
  source: types.string(),
  cause: types.string(),
  blockReason: types.optional(types.string()),
});

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

/** @internal */
export const TwoHundredAndTen$inboundSchema: z.ZodType<
  TwoHundredAndTen,
  z.ZodTypeDef,
  unknown
> = z.object({
  ownerId: types.string(),
  source: types.string(),
  cause: types.string(),
  reason: z.nullable(types.string()).optional(),
});

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

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

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

/** @internal */
export const TwoHundredAndNine$inboundSchema: z.ZodType<
  TwoHundredAndNine,
  z.ZodTypeDef,
  unknown
> = z.object({
  ownerId: types.string(),
  source: types.string(),
  cause: types.string(),
  blockReason: types.optional(types.string()),
  siftRoute: types.optional(z.lazy(() => SiftRoute$inboundSchema)),
});

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

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

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

/** @internal */
export const TwoHundredAndEight$inboundSchema: z.ZodType<
  TwoHundredAndEight,
  z.ZodTypeDef,
  unknown
> = z.object({
  organizationId: types.string(),
  teamId: types.string(),
  teamName: types.string(),
  previousMode: PreviousMode$inboundSchema,
  mode: PayloadMode$inboundSchema,
});

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

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

/** @internal */
export const TwoHundredAndSeven$inboundSchema: z.ZodType<
  TwoHundredAndSeven,
  z.ZodTypeDef,
  unknown
> = z.object({
  organizationId: types.string(),
  teamId: types.string(),
  billingPlan: BillingPlan$inboundSchema,
});

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

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

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

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

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

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

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

/** @internal */
export const PayloadNext$inboundSchema: z.ZodType<
  PayloadNext,
  z.ZodTypeDef,
  unknown
> = z.object({
  default: types.optional(PayloadDefault$inboundSchema),
  roles: z.record(PayloadRoles$inboundSchema),
});

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

/** @internal */
export const TwoHundredAndFour$inboundSchema: z.ZodType<
  TwoHundredAndFour,
  z.ZodTypeDef,
  unknown
> = z.object({
  directoryGroupId: types.string(),
  directoryId: types.string(),
  groupName: types.string(),
  next: z.lazy(() => PayloadNext$inboundSchema),
  organizationId: types.string(),
});

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

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

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

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

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

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

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

/** @internal */
export const Microfrontends3$inboundSchema: z.ZodType<
  Microfrontends3,
  z.ZodTypeDef,
  unknown
> = z.object({
  updatedAt: types.number(),
  groupIds: z.array(z.any()),
  enabled: types.literal(false),
  freeProjectForLegacyLimits: types.optional(types.boolean()),
});

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

/** @internal */
export const Microfrontends2$inboundSchema: z.ZodType<
  Microfrontends2,
  z.ZodTypeDef,
  unknown
> = z.object({
  isDefaultApp: types.optional(types.literal(false)),
  routeObservabilityToThisProject: types.optional(types.boolean()),
  doNotRouteWithMicrofrontendsRouting: types.optional(types.boolean()),
  updatedAt: types.number(),
  groupIds: z.array(types.string()),
  enabled: types.literal(true),
  defaultRoute: types.optional(types.string()),
  freeProjectForLegacyLimits: types.optional(types.boolean()),
});

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

/** @internal */
export const Microfrontends1$inboundSchema: z.ZodType<
  Microfrontends1,
  z.ZodTypeDef,
  unknown
> = z.object({
  isDefaultApp: types.literal(true),
  updatedAt: types.number(),
  groupIds: z.array(types.string()),
  enabled: types.literal(true),
  defaultRoute: types.optional(types.string()),
  freeProjectForLegacyLimits: types.optional(types.boolean()),
});

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

/** @internal */
export const Microfrontends$inboundSchema: z.ZodType<
  Microfrontends,
  z.ZodTypeDef,
  unknown
> = smartUnion([
  z.lazy(() => Microfrontends1$inboundSchema),
  z.lazy(() => Microfrontends2$inboundSchema),
  z.lazy(() => Microfrontends3$inboundSchema),
]);

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

/** @internal */
export const UserEventPayload200Project$inboundSchema: z.ZodType<
  UserEventPayload200Project,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: types.string(),
  name: types.string(),
  microfrontends: types.optional(
    smartUnion([
      z.lazy(() => Microfrontends1$inboundSchema),
      z.lazy(() => Microfrontends2$inboundSchema),
      z.lazy(() => Microfrontends3$inboundSchema),
    ]),
  ),
});

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

/** @internal */
export const UserEventMicrofrontends3$inboundSchema: z.ZodType<
  UserEventMicrofrontends3,
  z.ZodTypeDef,
  unknown
> = z.object({
  updatedAt: types.number(),
  groupIds: z.array(z.any()),
  enabled: types.literal(false),
  freeProjectForLegacyLimits: types.optional(types.boolean()),
});

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

/** @internal */
export const UserEventMicrofrontends2$inboundSchema: z.ZodType<
  UserEventMicrofrontends2,
  z.ZodTypeDef,
  unknown
> = z.object({
  isDefaultApp: types.optional(types.literal(false)),
  routeObservabilityToThisProject: types.optional(types.boolean()),
  doNotRouteWithMicrofrontendsRouting: types.optional(types.boolean()),
  updatedAt: types.number(),
  groupIds: z.array(types.string()),
  enabled: types.literal(true),
  defaultRoute: types.optional(types.string()),
  freeProjectForLegacyLimits: types.optional(types.boolean()),
});

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

/** @internal */
export const UserEventMicrofrontends1$inboundSchema: z.ZodType<
  UserEventMicrofrontends1,
  z.ZodTypeDef,
  unknown
> = z.object({
  isDefaultApp: types.literal(true),
  updatedAt: types.number(),
  groupIds: z.array(types.string()),
  enabled: types.literal(true),
  defaultRoute: types.optional(types.string()),
  freeProjectForLegacyLimits: types.optional(types.boolean()),
});

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

/** @internal */
export const PayloadMicrofrontends$inboundSchema: z.ZodType<
  PayloadMicrofrontends,
  z.ZodTypeDef,
  unknown
> = smartUnion([
  z.lazy(() => UserEventMicrofrontends1$inboundSchema),
  z.lazy(() => UserEventMicrofrontends2$inboundSchema),
  z.lazy(() => UserEventMicrofrontends3$inboundSchema),
]);

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

/** @internal */
export const UserEventPayload200PrevProject$inboundSchema: z.ZodType<
  UserEventPayload200PrevProject,
  z.ZodTypeDef,
  unknown
> = z.object({
  microfrontends: types.optional(
    smartUnion([
      z.lazy(() => UserEventMicrofrontends1$inboundSchema),
      z.lazy(() => UserEventMicrofrontends2$inboundSchema),
      z.lazy(() => UserEventMicrofrontends3$inboundSchema),
    ]),
  ),
});

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

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

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

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

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

/** @internal */
export const TwoHundred$inboundSchema: z.ZodType<
  TwoHundred,
  z.ZodTypeDef,
  unknown
> = z.object({
  project: z.lazy(() => UserEventPayload200Project$inboundSchema),
  prev: z.lazy(() => PayloadPrev$inboundSchema),
  group: z.lazy(() => PayloadGroup$inboundSchema),
});

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

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

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

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

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

/** @internal */
export const OneHundredAndNinetyNine$inboundSchema: z.ZodType<
  OneHundredAndNinetyNine,
  z.ZodTypeDef,
  unknown
> = z.object({
  project: z.lazy(() => UserEventPayload199Project$inboundSchema),
  group: z.lazy(() => Group$inboundSchema),
});

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

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

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

/** @internal */
export const OneHundredAndNinetyEight$inboundSchema: z.ZodType<
  OneHundredAndNinetyEight,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: types.string(),
  slug: types.optional(types.string()),
  name: types.optional(types.string()),
  fallbackEnvironment: types.optional(types.string()),
  enablePolyrepoBranchRouting: types.optional(types.boolean()),
  prev: z.lazy(() => Prev$inboundSchema),
});

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

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

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

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

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

/** @internal */
export const Periods$inboundSchema: z.ZodType<Periods, z.ZodTypeDef, unknown> =
  z.object({
    periodNumber: types.number(),
    percent: types.string(),
    startDate: types.string(),
    endDate: types.string(),
  });

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/** @internal */
export const Geolocation$inboundSchema: z.ZodType<
  Geolocation,
  z.ZodTypeDef,
  unknown
> = z.object({
  city: types.optional(z.lazy(() => City$inboundSchema)),
  country: z.lazy(() => Country$inboundSchema),
  most_specific_subdivision: types.optional(
    z.lazy(() => MostSpecificSubdivision$inboundSchema),
  ),
  regionName: types.optional(types.string()),
}).transform((v) => {
  return remap$(v, {
    "most_specific_subdivision": "mostSpecificSubdivision",
  });
});

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

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

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

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

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

/** @internal */
export const Two1$inboundSchema: z.ZodType<Two1, z.ZodTypeDef, unknown> = z
  .object({
    origin: TwoOrigin$inboundSchema,
    username: types.optional(types.string()),
    teamId: types.optional(types.string()),
    legacy: types.optional(types.boolean()),
    ssoType: types.optional(types.string()),
  });

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

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

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

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

/** @internal */
export const One1$inboundSchema: z.ZodType<One1, z.ZodTypeDef, unknown> = z
  .object({
    origin: OneOrigin$inboundSchema,
    username: types.optional(types.string()),
    teamId: types.optional(types.string()),
    legacy: types.optional(types.boolean()),
    ssoType: types.optional(types.string()),
  });

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

/** @internal */
export const Factors1$inboundSchema: z.ZodType<
  Factors1,
  z.ZodTypeDef,
  unknown
> = z.lazy(() => One1$inboundSchema);

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

/** @internal */
export const Factors$inboundSchema: z.ZodType<Factors, z.ZodTypeDef, unknown> =
  smartUnion([
    z.array(z.lazy(() => One1$inboundSchema)),
    z.array(smartUnion([
      z.lazy(() => Two1$inboundSchema),
      z.lazy(() => Two2$inboundSchema),
    ])),
  ]);

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

/** @internal */
export const OneHundredAndNinetyThree$inboundSchema: z.ZodType<
  OneHundredAndNinetyThree,
  z.ZodTypeDef,
  unknown
> = z.object({
  userAgent: types.optional(types.string()),
  geolocation: z.nullable(z.lazy(() => Geolocation$inboundSchema)).optional(),
  env: types.optional(types.string()),
  os: types.optional(types.string()),
  loginSessionId: types.optional(types.string()),
  username: types.optional(types.string()),
  ssoType: types.optional(types.string()),
  factors: types.optional(
    smartUnion([
      z.array(z.lazy(() => One1$inboundSchema)),
      z.array(smartUnion([
        z.lazy(() => Two1$inboundSchema),
        z.lazy(() => Two2$inboundSchema),
      ])),
    ]),
  ),
  viaOTP: types.optional(types.boolean()),
  viaGithub: types.optional(types.boolean()),
  viaGitlab: types.optional(types.boolean()),
  viaBitbucket: types.optional(types.boolean()),
  viaGoogle: types.optional(types.boolean()),
  viaApple: types.optional(types.boolean()),
  viaSamlSso: types.optional(types.boolean()),
  viaPasskey: types.optional(types.boolean()),
});

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

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

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

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

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

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

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

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

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

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

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

/** @internal */
export const OneHundredAndEightyEight$inboundSchema: z.ZodType<
  OneHundredAndEightyEight,
  z.ZodTypeDef,
  unknown
> = z.object({
  issuerId: types.string(),
  issuerName: types.string(),
  kind: types.string(),
  policyKey: types.string(),
});

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

/** @internal */
export const OneHundredAndEightySeven$inboundSchema: z.ZodType<
  OneHundredAndEightySeven,
  z.ZodTypeDef,
  unknown
> = z.object({
  issuerId: types.string(),
  issuerName: types.string(),
  kind: types.string(),
  projectId: types.optional(types.string()),
  clientId: types.optional(types.string()),
  environments: types.optional(z.array(types.string())),
});

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

/** @internal */
export const OneHundredAndEightySix$inboundSchema: z.ZodType<
  OneHundredAndEightySix,
  z.ZodTypeDef,
  unknown
> = z.object({
  issuerId: types.string(),
  issuerName: types.string(),
  keyId: types.optional(types.string()),
});

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

/** @internal */
export const OneHundredAndEightyFive$inboundSchema: z.ZodType<
  OneHundredAndEightyFive,
  z.ZodTypeDef,
  unknown
> = z.object({
  issuerId: types.string(),
  issuerName: types.string(),
  managedBy: types.optional(types.string()),
});

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

/** @internal */
export const OneHundredAndEightyFour$inboundSchema: z.ZodType<
  OneHundredAndEightyFour,
  z.ZodTypeDef,
  unknown
> = z.object({
  issuerId: types.string(),
  issuerName: types.string(),
  algorithm: types.string(),
  origin: types.string(),
  managedBy: types.optional(types.string()),
});

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

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

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

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

/** @internal */
export const OneHundredAndEightyTwo$inboundSchema: z.ZodType<
  OneHundredAndEightyTwo,
  z.ZodTypeDef,
  unknown
> = z.object({
  resourceId: types.string(),
  integrationId: types.string(),
  integrationSlug: types.string(),
  integrationProductSlug: types.string(),
  configurationId: types.string(),
  errorCode: types.optional(types.string()),
  requestKind: UserEventPayload182RequestKind$inboundSchema,
  key: types.string(),
});

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

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

/** @internal */
export const OneHundredAndEightyOne$inboundSchema: z.ZodType<
  OneHundredAndEightyOne,
  z.ZodTypeDef,
  unknown
> = z.object({
  resourceId: types.string(),
  integrationId: types.string(),
  integrationSlug: types.string(),
  integrationProductSlug: types.string(),
  configurationId: types.string(),
  errorCode: types.optional(types.string()),
  requestKind: UserEventPayloadRequestKind$inboundSchema,
  keys: z.array(types.string()),
});

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

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

/** @internal */
export const OneHundredAndEighty$inboundSchema: z.ZodType<
  OneHundredAndEighty,
  z.ZodTypeDef,
  unknown
> = z.object({
  resourceId: types.string(),
  integrationId: types.string(),
  integrationSlug: types.string(),
  integrationProductSlug: types.string(),
  configurationId: types.string(),
  errorCode: types.optional(types.string()),
  requestKind: PayloadRequestKind$inboundSchema,
  pattern: types.optional(types.string()),
  type: types.optional(types.string()),
});

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

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

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

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

/** @internal */
export const OneHundredAndSeventyNine$inboundSchema: z.ZodType<
  OneHundredAndSeventyNine,
  z.ZodTypeDef,
  unknown
> = z.object({
  resourceId: types.string(),
  integrationId: types.string(),
  integrationSlug: types.string(),
  integrationProductSlug: types.string(),
  configurationId: types.string(),
  errorCode: types.optional(types.string()),
  requestKind: RequestKind$inboundSchema,
  readonly: types.boolean(),
  commands: z.array(z.lazy(() => Commands$inboundSchema)),
  errorIndex: types.optional(types.number()),
});

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

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

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

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

/** @internal */
export const Queries$inboundSchema: z.ZodType<Queries, z.ZodTypeDef, unknown> =
  z.object({
    command: types.nullable(types.string()),
    rowCount: types.optional(types.number()),
    tables: types.optional(z.array(types.string())),
    primaryKey: types.optional(z.array(z.lazy(() => PrimaryKey$inboundSchema))),
  });

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

/** @internal */
export const OneHundredAndSeventyEight$inboundSchema: z.ZodType<
  OneHundredAndSeventyEight,
  z.ZodTypeDef,
  unknown
> = z.object({
  resourceId: types.string(),
  integrationId: types.string(),
  integrationSlug: types.string(),
  integrationProductSlug: types.string(),
  configurationId: types.string(),
  databaseName: types.string(),
  queryType: QueryType$inboundSchema,
  readonly: types.boolean(),
  rolledBack: types.boolean(),
  failedQueryIndex: types.nullable(types.number()),
  errorCode: types.nullable(types.string()),
  queryCount: types.number(),
  queries: z.array(z.lazy(() => Queries$inboundSchema)),
});

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

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

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

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

/** @internal */
export const OneHundredAndSeventySeven$inboundSchema: z.ZodType<
  OneHundredAndSeventySeven,
  z.ZodTypeDef,
  unknown
> = z.object({
  integrationId: types.string(),
  configurationId: types.string(),
  integrationSlug: types.string(),
  integrationName: types.string(),
  ownerId: types.string(),
  projectIds: types.optional(
    smartUnion([z.array(types.string()), ProjectIds2$inboundSchema]),
  ),
});

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

/** @internal */
export const OneHundredAndSeventySix$inboundSchema: z.ZodType<
  OneHundredAndSeventySix,
  z.ZodTypeDef,
  unknown
> = z.object({
  integrationId: types.string(),
  configurationId: types.string(),
  integrationSlug: types.string(),
  integrationName: types.string(),
  ownerId: types.string(),
  billingPlanId: types.string(),
  billingPlanName: types.optional(types.string()),
});

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

/** @internal */
export const Configurations$inboundSchema: z.ZodType<
  Configurations,
  z.ZodTypeDef,
  unknown
> = z.object({
  integrationId: types.string(),
  configurationId: types.string(),
  integrationSlug: types.string(),
  integrationName: types.optional(types.string()),
});

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

/** @internal */
export const OneHundredAndSeventyFive$inboundSchema: z.ZodType<
  OneHundredAndSeventyFive,
  z.ZodTypeDef,
  unknown
> = z.object({
  configurations: z.array(z.lazy(() => Configurations$inboundSchema)),
  ownerId: types.string(),
});

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

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

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

/** @internal */
export const OneHundredAndSeventyFour$inboundSchema: z.ZodType<
  OneHundredAndSeventyFour,
  z.ZodTypeDef,
  unknown
> = z.object({
  integration: z.lazy(() => PayloadIntegration$inboundSchema),
  originTeamId: types.string(),
  originTeamName: types.string(),
});

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

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

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

/** @internal */
export const OneHundredAndSeventyThree$inboundSchema: z.ZodType<
  OneHundredAndSeventyThree,
  z.ZodTypeDef,
  unknown
> = z.object({
  integration: z.lazy(() => Integration$inboundSchema),
  destinationTeamId: types.string(),
  destinationTeamName: types.string(),
});

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

/** @internal */
export const OneHundredAndSeventyTwo$inboundSchema: z.ZodType<
  OneHundredAndSeventyTwo,
  z.ZodTypeDef,
  unknown
> = z.object({
  integrationId: types.string(),
  configurationId: types.string(),
  integrationSlug: types.string(),
  integrationName: types.string(),
  ownerId: types.string(),
  projectIds: types.optional(z.array(types.string())),
  confirmedScopes: z.array(types.string()),
});

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

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

/** @internal */
export const BlockHistory$inboundSchema: z.ZodType<
  BlockHistory,
  z.ZodTypeDef,
  unknown
> = z.object({
  action: UserEventPayload171Action$inboundSchema,
  createdAt: types.number(),
  caseId: types.optional(types.string()),
  reason: types.string(),
  actor: types.optional(types.string()),
  statusCode: types.optional(types.number()),
  comment: types.optional(types.string()),
  ineligibleForAppeal: types.optional(types.boolean()),
});

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

/** @internal */
export const History$inboundSchema: z.ZodType<History, z.ZodTypeDef, unknown> =
  z.object({
    scanner: types.string(),
    reason: types.string(),
    by: types.string(),
    byId: types.string(),
    at: types.number(),
  });

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

/** @internal */
export const ScheduledBlock$inboundSchema: z.ZodType<
  ScheduledBlock,
  z.ZodTypeDef,
  unknown
> = z.object({
  executeAt: types.number(),
  reason: types.string(),
  source: types.string(),
  createdAt: types.number(),
  caseId: types.optional(types.string()),
  scheduleName: types.optional(types.string()),
});

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

/** @internal */
export const Abuse$inboundSchema: z.ZodType<Abuse, z.ZodTypeDef, unknown> = z
  .object({
    blockHistory: types.optional(
      z.array(z.lazy(() => BlockHistory$inboundSchema)),
    ),
    gitAuthHistory: types.optional(z.array(types.string())),
    history: types.optional(z.array(z.lazy(() => History$inboundSchema))),
    gitLineageBlocks: types.optional(types.number()),
    gitLineageBlocksDry: types.optional(types.number()),
    scanner: types.optional(types.string()),
    scheduledUnblockAt: types.optional(types.string()),
    scheduledBlock: types.optional(z.lazy(() => ScheduledBlock$inboundSchema)),
    updatedAt: types.number(),
    creationUserAgent: types.optional(types.string()),
    creationIp: types.optional(types.string()),
    removedPhoneNumbers: types.optional(types.string()),
  });

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

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

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

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

/** @internal */
export const Credentials2$inboundSchema: z.ZodType<
  Credentials2,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("github-oauth-custom-host"),
  host: types.string(),
  id: types.string(),
});

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

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

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

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

/** @internal */
export const Credentials$inboundSchema: z.ZodType<
  Credentials,
  z.ZodTypeDef,
  unknown
> = z.union([
  z.lazy(() => Credentials1$inboundSchema).and(
    z.object({ type: z.literal("apple") }),
  ),
  z.lazy(() => Credentials1$inboundSchema).and(
    z.object({ type: z.literal("bitbucket") }),
  ),
  z.lazy(() => Credentials1$inboundSchema).and(
    z.object({ type: z.literal("chatgpt") }),
  ),
  z.lazy(() => Credentials1$inboundSchema).and(
    z.object({ type: z.literal("github-oauth") }),
  ),
  z.lazy(() => Credentials1$inboundSchema).and(
    z.object({ type: z.literal("github-oauth-limited") }),
  ),
  z.lazy(() => Credentials1$inboundSchema).and(
    z.object({ type: z.literal("gitlab") }),
  ),
  z.lazy(() => Credentials1$inboundSchema).and(
    z.object({ type: z.literal("google") }),
  ),
  z.lazy(() => Credentials1$inboundSchema).and(
    z.object({ type: z.literal("vercel") }),
  ),
  z.lazy(() => Credentials2$inboundSchema),
]);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/** @internal */
export const PayloadPreferredScopesAndGitNamespaces$inboundSchema: z.ZodType<
  PayloadPreferredScopesAndGitNamespaces,
  z.ZodTypeDef,
  unknown
> = z.object({
  scopeId: types.string(),
  gitNamespaceId: types.nullable(smartUnion([types.string(), types.number()])),
});

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

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

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

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

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

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

/** @internal */
export const ProjectCardWidgetPreferences$inboundSchema: z.ZodType<
  ProjectCardWidgetPreferences,
  z.ZodTypeDef,
  unknown
> = z.object({
  projectId: types.string(),
  widget: PayloadWidget$inboundSchema,
  config: types.optional(z.lazy(() => Config$inboundSchema)),
});

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

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

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

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

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

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

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

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

/** @internal */
export const PayloadSecurity$inboundSchema: z.ZodType<
  PayloadSecurity,
  z.ZodTypeDef,
  unknown
> = z.object({
  rateLimit: types.optional(types.number()),
  customRules: types.optional(types.number()),
  ipBlocks: types.optional(types.number()),
  ipBypass: types.optional(types.number()),
});

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

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

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

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

/** @internal */
export const PayloadResourceConfig$inboundSchema: z.ZodType<
  PayloadResourceConfig,
  z.ZodTypeDef,
  unknown
> = z.object({
  concurrentBuilds: types.optional(types.number()),
  nodeType: types.optional(types.string()),
  elasticConcurrencyEnabled: types.optional(types.boolean()),
  buildEntitlements: types.optional(
    z.lazy(() => PayloadBuildEntitlements$inboundSchema),
  ),
  buildQueue: types.optional(z.lazy(() => PayloadBuildQueue$inboundSchema)),
  awsAccountType: types.optional(types.string()),
  awsAccountIds: types.optional(z.array(types.string())),
  cfZoneName: types.optional(types.string()),
  imageOptimizationType: types.optional(types.string()),
  edgeConfigs: types.optional(types.number()),
  edgeConfigSize: types.optional(types.number()),
  edgeFunctionMaxSizeBytes: types.optional(types.number()),
  edgeFunctionExecutionTimeoutMs: types.optional(types.number()),
  serverlessFunctionMaxDuration: types.optional(types.number()),
  serverlessFunctionMaxMemorySize: types.optional(types.number()),
  kvDatabases: types.optional(types.number()),
  postgresDatabases: types.optional(types.number()),
  blobStores: types.optional(types.number()),
  integrationStores: types.optional(types.number()),
  cronJobsPerProject: types.optional(types.number()),
  microfrontendGroupsPerTeam: types.optional(types.number()),
  microfrontendProjectsPerGroup: types.optional(types.number()),
  flagsExplorerOverridesThreshold: types.optional(types.number()),
  flagsExplorerUnlimitedOverrides: types.optional(types.boolean()),
  customEnvironmentsPerProject: types.optional(types.number()),
  security: types.optional(z.lazy(() => PayloadSecurity$inboundSchema)),
  bulkRedirectsFreeLimitOverride: types.optional(types.number()),
  buildMachine: types.optional(z.lazy(() => PayloadBuildMachine$inboundSchema)),
});

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

/** @internal */
export const ResourceLimits2$inboundSchema: z.ZodType<
  ResourceLimits2,
  z.ZodTypeDef,
  unknown
> = z.object({
  minRate: types.optional(types.number()),
  maxRate: types.optional(types.number()),
  stepPerMinute: types.optional(types.number()),
});

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

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

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

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

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

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

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

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

/** @internal */
export const PayloadActiveDashboardViews$inboundSchema: z.ZodType<
  PayloadActiveDashboardViews,
  z.ZodTypeDef,
  unknown
> = z.object({
  scopeId: types.string(),
  viewPreference: z.nullable(PayloadViewPreference$inboundSchema).optional(),
  favoritesViewPreference: z.nullable(
    PayloadFavoritesViewPreference$inboundSchema,
  ).optional(),
  recentsViewPreference: z.nullable(PayloadRecentsViewPreference$inboundSchema)
    .optional(),
});

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

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

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

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

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

/** @internal */
export const EmailNotifications$inboundSchema: z.ZodType<
  EmailNotifications,
  z.ZodTypeDef,
  unknown
> = z.object({
  rules: types.optional(z.record(z.lazy(() => PayloadRules$inboundSchema))),
});

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

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

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

/** @internal */
export const SiftScores$inboundSchema: z.ZodType<
  SiftScores,
  z.ZodTypeDef,
  unknown
> = z.object({
  score: types.number(),
  reasons: z.array(z.lazy(() => PayloadReasons$inboundSchema)),
});

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

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

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

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

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

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

/** @internal */
export const PayloadSoftBlock$inboundSchema: z.ZodType<
  PayloadSoftBlock,
  z.ZodTypeDef,
  unknown
> = z.object({
  blockedAt: types.number(),
  reason: UserEventPayload171Reason$inboundSchema,
  blockedDueToOverageType: types.optional(
    PayloadBlockedDueToOverageType$inboundSchema,
  ),
  unpauseAt: types.optional(types.number()),
});

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

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

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

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

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

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

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