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

import * as z from "zod/v3";
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";

export const Reason = {
  BlockedForPlatformAbuse: "BLOCKED_FOR_PLATFORM_ABUSE",
  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 Reason = ClosedEnum<typeof Reason>;

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

/**
 * When the User account has been "soft blocked", this property will contain the date when the restriction was enacted, and the identifier for why.
 */
export type SoftBlock = {
  blockedAt: number;
  reason: Reason;
  blockedDueToOverageType?: BlockedDueToOverageType | undefined;
};

/**
 * An object containing billing infomation associated with the User account.
 */
export type Billing = {};

/**
 * An object containing infomation related to the amount of platform resources may be allocated to the User account.
 */
export type AuthUserBuildEntitlements = {
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  enhancedBuilds?: boolean | undefined;
};

/**
 * An object containing infomation related to the amount of platform resources may be allocated to the User account.
 */
export const AuthUserConfiguration = {
  SkipNamespaceQueue: "SKIP_NAMESPACE_QUEUE",
  WaitForNamespaceQueue: "WAIT_FOR_NAMESPACE_QUEUE",
} as const;
/**
 * An object containing infomation related to the amount of platform resources may be allocated to the User account.
 */
export type AuthUserConfiguration = ClosedEnum<typeof AuthUserConfiguration>;

/**
 * An object containing infomation related to the amount of platform resources may be allocated to the User account.
 */
export type BuildQueue = {
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  configuration?: AuthUserConfiguration | undefined;
};

/**
 * An object containing infomation related to the amount of platform resources may be allocated to the User account.
 */
export type AuthUserSecurity = {
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  customRules?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  ipBlocks?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  ipBypass?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  rateLimit?: number | undefined;
};

/**
 * An object containing infomation related to the amount of platform resources may be allocated to the User account.
 */
export type AuthUserResourceConfig = {
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  nodeType?: string | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  concurrentBuilds?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  elasticConcurrencyEnabled?: boolean | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  buildEntitlements?: AuthUserBuildEntitlements | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  buildQueue?: BuildQueue | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  awsAccountType?: string | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  awsAccountIds?: Array<string> | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  cfZoneName?: string | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  imageOptimizationType?: string | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  edgeConfigs?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  edgeConfigSize?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  edgeFunctionMaxSizeBytes?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  edgeFunctionExecutionTimeoutMs?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  serverlessFunctionMaxMemorySize?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  kvDatabases?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  postgresDatabases?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  blobStores?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  integrationStores?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  cronJobsPerProject?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  microfrontendGroupsPerTeam?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  microfrontendProjectsPerGroup?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  flagsExplorerOverridesThreshold?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  flagsExplorerUnlimitedOverrides?: boolean | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  customEnvironmentsPerProject?: number | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  security?: AuthUserSecurity | undefined;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  bulkRedirectsFreeLimitOverride?: number | undefined;
};

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

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

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

/**
 * set of dashboard view preferences (cards or list) per scopeId
 */
export type ActiveDashboardViews = {
  scopeId: string;
  viewPreference?: ViewPreference | null | undefined;
  favoritesViewPreference?: FavoritesViewPreference | null | undefined;
  recentsViewPreference?: RecentsViewPreference | null | undefined;
};

export type ImportFlowGitNamespace = string | number;

export type ImportFlowGitNamespaceId = string | number;

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

export type GitNamespaceId = string | number;

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

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

/**
 * A record of when, under a certain scopeId, a toast was dismissed
 */
export type DismissedToasts = {
  name: string;
  dismissals: Array<Dismissals>;
};

/**
 * A list of projects and spaces across teams that a user has marked as a favorite.
 */
export type FavoriteProjectsAndSpaces = {
  teamId: string;
  projectId: string;
};

/**
 * remote caching settings
 */
export type AuthUserRemoteCaching = {
  enabled?: boolean | undefined;
};

/**
 * data cache settings
 */
export type DataCache = {
  excessBillingEnabled?: boolean | undefined;
};

export type WebAnalytics = {
  blockedFrom?: number | undefined;
  blockedUntil?: number | undefined;
  isCurrentlyBlocked: boolean;
};

/**
 * Feature blocks for the user
 */
export type FeatureBlocks = {
  webAnalytics?: WebAnalytics | undefined;
};

export type ManagedTeams = {
  name: string;
  avatar: string | null;
};

/**
 * Context for the Update Account screen. Present only when `isAccountUpdateRequired` is true. `managedTeams` is empty for orphan mode (user matches an EMU domain but is not on the team).
 */
export type AccountUpdateContext = {
  managedTeams: Array<ManagedTeams>;
};

/**
 * Data for the currently authenticated User.
 */
export type AuthUser = {
  /**
   * UNIX timestamp (in milliseconds) when the User account was created.
   */
  createdAt: number;
  /**
   * When the User account has been "soft blocked", this property will contain the date when the restriction was enacted, and the identifier for why.
   */
  softBlock: SoftBlock | null;
  /**
   * An object containing billing infomation associated with the User account.
   */
  billing: Billing | null;
  /**
   * An object containing infomation related to the amount of platform resources may be allocated to the User account.
   */
  resourceConfig: AuthUserResourceConfig;
  /**
   * Prefix that will be used in the URL of "Preview" deployments created by the User account.
   */
  stagingPrefix: string;
  /**
   * set of dashboard view preferences (cards or list) per scopeId
   */
  activeDashboardViews?: Array<ActiveDashboardViews> | undefined;
  importFlowGitNamespace?: string | number | null | undefined;
  importFlowGitNamespaceId?: string | number | null | undefined;
  importFlowGitProvider?: ImportFlowGitProvider | null | undefined;
  preferredScopesAndGitNamespaces?:
    | Array<PreferredScopesAndGitNamespaces>
    | undefined;
  /**
   * A record of when, under a certain scopeId, a toast was dismissed
   */
  dismissedToasts?: Array<DismissedToasts> | undefined;
  /**
   * A list of projects and spaces across teams that a user has marked as a favorite.
   */
  favoriteProjectsAndSpaces?: Array<FavoriteProjectsAndSpaces> | undefined;
  /**
   * Whether the user has a trial available for a paid plan subscription.
   */
  hasTrialAvailable: boolean;
  /**
   * remote caching settings
   */
  remoteCaching?: AuthUserRemoteCaching | undefined;
  /**
   * data cache settings
   */
  dataCache?: DataCache | undefined;
  /**
   * Feature blocks for the user
   */
  featureBlocks?: FeatureBlocks | undefined;
  /**
   * When `true`, the user must complete the EMU Update Account flow before they can use the dashboard.
   */
  isAccountUpdateRequired?: boolean | undefined;
  /**
   * Context for the Update Account screen. Present only when `isAccountUpdateRequired` is true. `managedTeams` is empty for orphan mode (user matches an EMU domain but is not on the team).
   */
  accountUpdateContext?: AccountUpdateContext | undefined;
  /**
   * The User's unique identifier.
   */
  id: string;
  /**
   * Email address associated with the User account.
   */
  email: string;
  /**
   * Name associated with the User account, or `null` if none has been provided.
   */
  name: string | null;
  /**
   * Unique username associated with the User account.
   */
  username: string;
  /**
   * SHA1 hash of the avatar for the User account. Can be used in conjuction with the ... endpoint to retrieve the avatar image.
   */
  avatar: string | null;
  /**
   * The user's default team.
   */
  defaultTeamId: string | null;
  /**
   * Indicates whether the user is managed by an enterprise.
   */
  isEnterpriseManaged?: boolean | undefined;
};

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

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

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

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

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

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

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

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

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

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

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

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

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

/** @internal */
export const AuthUserResourceConfig$inboundSchema: z.ZodType<
  AuthUserResourceConfig,
  z.ZodTypeDef,
  unknown
> = z.object({
  nodeType: types.optional(types.string()),
  concurrentBuilds: types.optional(types.number()),
  elasticConcurrencyEnabled: types.optional(types.boolean()),
  buildEntitlements: types.optional(
    z.lazy(() => AuthUserBuildEntitlements$inboundSchema),
  ),
  buildQueue: types.optional(z.lazy(() => BuildQueue$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()),
  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(() => AuthUserSecurity$inboundSchema)),
  bulkRedirectsFreeLimitOverride: types.optional(types.number()),
});

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/** @internal */
export const WebAnalytics$inboundSchema: z.ZodType<
  WebAnalytics,
  z.ZodTypeDef,
  unknown
> = z.object({
  blockedFrom: types.optional(types.number()),
  blockedUntil: types.optional(types.number()),
  isCurrentlyBlocked: types.boolean(),
});

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

/** @internal */
export const FeatureBlocks$inboundSchema: z.ZodType<
  FeatureBlocks,
  z.ZodTypeDef,
  unknown
> = z.object({
  webAnalytics: types.optional(z.lazy(() => WebAnalytics$inboundSchema)),
});

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

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

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

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

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

/** @internal */
export const AuthUser$inboundSchema: z.ZodType<
  AuthUser,
  z.ZodTypeDef,
  unknown
> = z.object({
  createdAt: types.number(),
  softBlock: types.nullable(z.lazy(() => SoftBlock$inboundSchema)),
  billing: types.nullable(z.lazy(() => Billing$inboundSchema)),
  resourceConfig: z.lazy(() => AuthUserResourceConfig$inboundSchema),
  stagingPrefix: types.string(),
  activeDashboardViews: types.optional(
    z.array(z.lazy(() => ActiveDashboardViews$inboundSchema)),
  ),
  importFlowGitNamespace: z.nullable(
    smartUnion([types.string(), types.number()]),
  ).optional(),
  importFlowGitNamespaceId: z.nullable(
    smartUnion([types.string(), types.number()]),
  ).optional(),
  importFlowGitProvider: z.nullable(ImportFlowGitProvider$inboundSchema)
    .optional(),
  preferredScopesAndGitNamespaces: types.optional(
    z.array(z.lazy(() => PreferredScopesAndGitNamespaces$inboundSchema)),
  ),
  dismissedToasts: types.optional(
    z.array(z.lazy(() => DismissedToasts$inboundSchema)),
  ),
  favoriteProjectsAndSpaces: types.optional(
    z.array(z.lazy(() => FavoriteProjectsAndSpaces$inboundSchema)),
  ),
  hasTrialAvailable: types.boolean(),
  remoteCaching: types.optional(
    z.lazy(() => AuthUserRemoteCaching$inboundSchema),
  ),
  dataCache: types.optional(z.lazy(() => DataCache$inboundSchema)),
  featureBlocks: types.optional(z.lazy(() => FeatureBlocks$inboundSchema)),
  isAccountUpdateRequired: types.optional(types.boolean()),
  accountUpdateContext: types.optional(
    z.lazy(() => AccountUpdateContext$inboundSchema),
  ),
  id: types.string(),
  email: types.string(),
  name: types.nullable(types.string()),
  username: types.string(),
  avatar: types.nullable(types.string()),
  defaultTeamId: types.nullable(types.string()),
  isEnterpriseManaged: types.optional(types.boolean()),
});

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