/*
 * 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 {
  Block,
  Block$inboundSchema,
  BlockHistory4,
  BlockHistory4$inboundSchema,
  CreateProjectDeploymentPolicy,
  CreateProjectDeploymentPolicy$inboundSchema,
  CreateProjectGitComments,
  CreateProjectGitComments$inboundSchema,
  CreateProjectHasProjectsResponse1,
  CreateProjectHasProjectsResponse1$inboundSchema,
  CreateProjectHasProjectsResponse2,
  CreateProjectHasProjectsResponse2$inboundSchema,
  CreateProjectHistory,
  CreateProjectHistory$inboundSchema,
  CreateProjectOidcTokenConfig,
  CreateProjectOidcTokenConfig$inboundSchema,
  CreateProjectPassport,
  CreateProjectPassport$inboundSchema,
  CreateProjectPermissions,
  CreateProjectPermissions$inboundSchema,
  CreateProjectProjectsResourceConfig,
  CreateProjectProjectsResourceConfig$inboundSchema,
  CreateProjectProjectsSsoProtection,
  CreateProjectProjectsSsoProtection$inboundSchema,
  CreateProjectRollbackDescription,
  CreateProjectRollbackDescription$inboundSchema,
  CreateProjectSandbox,
  CreateProjectSandbox$inboundSchema,
  CreateProjectSecurity,
  CreateProjectSecurity$inboundSchema,
  CreateProjectStaticIps,
  CreateProjectStaticIps$inboundSchema,
  CreateProjectTargets,
  CreateProjectTargets$inboundSchema,
  CreateProjectTier,
  CreateProjectTier$inboundSchema,
  CreateProjectTrustedIps,
  CreateProjectTrustedIps$inboundSchema,
  CreateProjectTrustedSources,
  CreateProjectTrustedSources$inboundSchema,
  CreateProjectWebAnalytics,
  CreateProjectWebAnalytics$inboundSchema,
  DefaultResourceConfig,
  DefaultResourceConfig$inboundSchema,
  Features,
  Features$inboundSchema,
  GitProviderOptions,
  GitProviderOptions$inboundSchema,
  LastAliasRequest,
  LastAliasRequest$inboundSchema,
  LastRollbackTarget,
  LastRollbackTarget$inboundSchema,
  ProtectionBypass,
  ProtectionBypass$inboundSchema,
  ProtectionConfig,
  ProtectionConfig$inboundSchema,
  RollingRelease,
  RollingRelease$inboundSchema,
  UsageStatus,
  UsageStatus$inboundSchema,
} from "./createprojecthasprojectsresponse1.js";
import {
  Alias,
  Alias$inboundSchema,
  Analytics,
  Analytics$inboundSchema,
  Blobs,
  Blobs$inboundSchema,
  CreateProjectConnectConfigurations,
  CreateProjectConnectConfigurations$inboundSchema,
  CreateProjectCreator,
  CreateProjectCreator$inboundSchema,
  CreateProjectCrons,
  CreateProjectCrons$inboundSchema,
  CreateProjectCustomEnvironments,
  CreateProjectCustomEnvironments$inboundSchema,
  CreateProjectDataCache,
  CreateProjectDataCache$inboundSchema,
  CreateProjectEnv,
  CreateProjectEnv$inboundSchema,
  CreateProjectExpiration,
  CreateProjectExpiration$inboundSchema,
  CreateProjectIpBuckets,
  CreateProjectIpBuckets$inboundSchema,
  CreateProjectMicrofrontends,
  CreateProjectMicrofrontends$inboundSchema,
  CreateProjectNodeVersion,
  CreateProjectNodeVersion$inboundSchema,
  CreateProjectOptionsAllowlist,
  CreateProjectOptionsAllowlist$inboundSchema,
  CreateProjectPasswordProtection,
  CreateProjectPasswordProtection$inboundSchema,
  CreateProjectProjectsFramework,
  CreateProjectProjectsFramework$inboundSchema,
  CreateProjectServices,
  CreateProjectServices$inboundSchema,
  DeploymentExpiration,
  DeploymentExpiration$inboundSchema,
  Jobs,
  Jobs$inboundSchema,
  LatestDeployments,
  LatestDeployments$inboundSchema,
  Link,
  Link$inboundSchema,
  SpeedInsights,
  SpeedInsights$inboundSchema,
} from "./createprojectpasswordprotection.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export type RouteHas =
  | CreateProjectHasProjectsResponse1
  | CreateProjectHasProjectsResponse2;

export const RouteAction = {
  BlockLegalCwc: "block_legal_cwc",
} as const;
export type RouteAction = ClosedEnum<typeof RouteAction>;

export type RouteMitigate = {
  action: RouteAction;
};

export type Route2 = {
  has: Array<
    CreateProjectHasProjectsResponse1 | CreateProjectHasProjectsResponse2
  >;
  mitigate: RouteMitigate;
  src?: string | undefined;
};

export type Route1 = {
  src: string;
  status: number;
  expiry?: number | undefined;
};

export type BlockHistoryRoute = Route1 | Route2;

export type BlockHistory3 = {
  action: "route-blocked";
  route: Route1 | Route2;
  reason: string;
  createdAt: number;
  caseId?: string | undefined;
  actor?: string | undefined;
  comment?: string | undefined;
  ineligibleForAppeal?: boolean | undefined;
  isCascading?: boolean | undefined;
};

export type BlockHistory2 = {
  action: "unblocked";
  createdAt: number;
  caseId?: string | undefined;
  actor?: string | undefined;
  comment?: string | undefined;
  ineligibleForAppeal?: boolean | undefined;
  isCascading?: boolean | undefined;
};

export type BlockHistory1 = {
  action: "blocked";
  reason: string;
  statusCode: number;
  createdAt: number;
  caseId?: string | undefined;
  actor?: string | undefined;
  comment?: string | undefined;
  ineligibleForAppeal?: boolean | undefined;
  isCascading?: boolean | undefined;
};

export type CreateProjectBlockHistory =
  | BlockHistory1
  | BlockHistory2
  | BlockHistory3
  | BlockHistory4;

export const CreateProjectProjectsResponse200Action = {
  AddDeploymentInterstitial: "add-deployment-interstitial",
  AddProjectInterstitial: "add-project-interstitial",
  RemoveDeploymentInterstitial: "remove-deployment-interstitial",
  RemoveProjectInterstitial: "remove-project-interstitial",
} as const;
export type CreateProjectProjectsResponse200Action = ClosedEnum<
  typeof CreateProjectProjectsResponse200Action
>;

export type InterstitialHistory = {
  action: CreateProjectProjectsResponse200Action;
  createdAt: number;
  caseId?: string | undefined;
  reason?: string | undefined;
  actor?: string | undefined;
  comment?: string | undefined;
};

export type CreateProjectAbuse = {
  scanner?: string | undefined;
  history: Array<CreateProjectHistory>;
  updatedAt: number;
  block?: Block | undefined;
  blockHistory?:
    | Array<BlockHistory1 | BlockHistory2 | BlockHistory3 | BlockHistory4>
    | undefined;
  interstitial?: boolean | undefined;
  interstitialHistory?: Array<InterstitialHistory> | undefined;
};

export type CreateProjectHasProjectsValue = {
  eq: string;
};

export type CreateProjectHas2 = {
  type: "host";
  value: CreateProjectHasProjectsValue;
};

export const CreateProjectHasKey = {
  XVercelIpCountry: "x-vercel-ip-country",
} as const;
export type CreateProjectHasKey = ClosedEnum<typeof CreateProjectHasKey>;

export type CreateProjectHasValue = {
  eq: string;
};

export type CreateProjectHas1 = {
  type: "header";
  key: CreateProjectHasKey;
  value: CreateProjectHasValue;
};

export type InternalRoutesHas = CreateProjectHas1 | CreateProjectHas2;

export const InternalRoutesAction = {
  BlockLegalCwc: "block_legal_cwc",
} as const;
export type InternalRoutesAction = ClosedEnum<typeof InternalRoutesAction>;

export type InternalRoutesMitigate = {
  action: InternalRoutesAction;
};

export type InternalRoutes2 = {
  has: Array<CreateProjectHas1 | CreateProjectHas2>;
  mitigate: InternalRoutesMitigate;
  src?: string | undefined;
};

export type InternalRoutes1 = {
  src: string;
  status: number;
  expiry?: number | undefined;
};

export type InternalRoutes = InternalRoutes1 | InternalRoutes2;

export const CreateProjectAction = {
  Accept: "accept",
  Cancel: "cancel",
  Delete: "delete",
} as const;
export type CreateProjectAction = ClosedEnum<typeof CreateProjectAction>;

export type CreateProjectValuePreviousValue = string | number | boolean;

export type CreateProjectValueCurrentValue = string | number | boolean;

export type Value3 = {
  previousValue: string | number | boolean;
  currentValue: string | number | boolean;
};

export type CreateProjectValue = Value3 | string | number | boolean;

export type CreateProjectDismissedToasts = {
  key: string;
  dismissedAt: number;
  action: CreateProjectAction;
  value: Value3 | string | number | boolean | null;
};

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

/**
 * Which tracing destination this rule applies to. `internal` is the hidden Vercel production-tracing drain (internal delivery); `external` is any customer-configured drain. Derived from the owning drain's delivery type when project tracing is computed; absent on configs persisted before this field existed.
 */
export const CreateProjectDestination = {
  External: "external",
  Internal: "internal",
} as const;
/**
 * Which tracing destination this rule applies to. `internal` is the hidden Vercel production-tracing drain (internal delivery); `external` is any customer-configured drain. Derived from the owning drain's delivery type when project tracing is computed; absent on configs persisted before this field existed.
 */
export type CreateProjectDestination = ClosedEnum<
  typeof CreateProjectDestination
>;

export type CreateProjectSamplingRules = {
  rate: number;
  env?: CreateProjectProjectsEnv | undefined;
  requestPath?: string | undefined;
  /**
   * Which tracing destination this rule applies to. `internal` is the hidden Vercel production-tracing drain (internal delivery); `external` is any customer-configured drain. Derived from the owning drain's delivery type when project tracing is computed; absent on configs persisted before this field existed.
   */
  destination?: CreateProjectDestination | undefined;
};

export type CreateProjectTracing = {
  domains?: string | undefined;
  ignorePaths?: Array<string> | undefined;
  samplingRules?: Array<CreateProjectSamplingRules> | undefined;
};

/**
 * The project was successfuly created
 */
export type CreateProjectResponseBody = {
  accountId: string;
  creator?: CreateProjectCreator | undefined;
  alias: Array<Alias>;
  analytics?: Analytics | undefined;
  appliedCve55182Migration?: boolean | undefined;
  speedInsights?: SpeedInsights | undefined;
  autoExposeSystemEnvs?: boolean | undefined;
  autoAssignCustomDomains?: boolean | undefined;
  autoAssignCustomDomainsUpdatedBy?: string | undefined;
  buildCommand?: string | null | undefined;
  commandForIgnoringBuildStep?: string | null | undefined;
  connectConfigurations?:
    | Array<CreateProjectConnectConfigurations>
    | null
    | undefined;
  connectConfigurationId?: string | null | undefined;
  connectBuildsEnabled?: boolean | undefined;
  passiveConnectConfigurationId?: string | null | undefined;
  createdAt?: number | undefined;
  customerSupportCodeVisibility?: boolean | undefined;
  crons?: CreateProjectCrons | undefined;
  dataCache?: CreateProjectDataCache | undefined;
  /**
   * Retention policies for deployments. These are enforced at the project level, but we also maintain an instance of this at the team level as a default policy that gets applied to new projects.
   */
  deploymentExpiration: DeploymentExpiration;
  expiration?: CreateProjectExpiration | undefined;
  devCommand?: string | null | undefined;
  directoryListing: boolean;
  installCommand?: string | null | undefined;
  env?: Array<CreateProjectEnv> | undefined;
  customEnvironments?: Array<CreateProjectCustomEnvironments> | undefined;
  framework?: CreateProjectProjectsFramework | null | undefined;
  services?: Array<CreateProjectServices> | undefined;
  gitForkProtection?: boolean | undefined;
  gitLFS?: boolean | undefined;
  id: string;
  ipBuckets?: Array<CreateProjectIpBuckets> | undefined;
  jobs?: Jobs | undefined;
  latestDeployments?: Array<LatestDeployments> | undefined;
  link?: Link | undefined;
  blobs?: Blobs | undefined;
  microfrontends?: CreateProjectMicrofrontends | undefined;
  name: string;
  nodeVersion: CreateProjectNodeVersion;
  optionsAllowlist?: CreateProjectOptionsAllowlist | null | undefined;
  outputDirectory?: string | null | undefined;
  passwordProtection?: CreateProjectPasswordProtection | null | undefined;
  passport?: CreateProjectPassport | null | undefined;
  protectionConfig?: ProtectionConfig | undefined;
  sandbox?: CreateProjectSandbox | undefined;
  productionDeploymentsFastLane?: boolean | undefined;
  resourceConfig: CreateProjectProjectsResourceConfig;
  /**
   * Description of why a project was rolled back, and by whom. Note that lastAliasRequest contains the from/to details of the rollback.
   */
  rollbackDescription?: CreateProjectRollbackDescription | undefined;
  /**
   * Project-level rolling release configuration that defines how deployments should be gradually rolled out
   */
  rollingRelease?: RollingRelease | null | undefined;
  defaultResourceConfig: DefaultResourceConfig;
  rootDirectory?: string | null | undefined;
  serverlessFunctionZeroConfigFailover?: boolean | undefined;
  skewProtectionBoundaryAt?: number | undefined;
  skewProtectionMaxAge?: number | undefined;
  skewProtectionAllowedDomains?: Array<string> | undefined;
  skipGitConnectDuringLink?: boolean | undefined;
  staticIps?: CreateProjectStaticIps | undefined;
  sourceFilesOutsideRootDirectory?: boolean | undefined;
  enableAffectedProjectsDeployments?: boolean | undefined;
  enableExternalRewriteCaching?: boolean | undefined;
  ssoProtection?: CreateProjectProjectsSsoProtection | null | undefined;
  targets?: { [k: string]: CreateProjectTargets | null } | undefined;
  transferCompletedAt?: number | undefined;
  transferStartedAt?: number | undefined;
  transferToAccountId?: string | undefined;
  transferredFromAccountId?: string | undefined;
  updatedAt?: number | undefined;
  live?: boolean | undefined;
  enablePreviewFeedback?: boolean | null | undefined;
  enableProductionFeedback?: boolean | null | undefined;
  permissions?: CreateProjectPermissions | undefined;
  lastRollbackTarget?: LastRollbackTarget | null | undefined;
  lastAliasRequest?: LastAliasRequest | null | undefined;
  protectionBypass?: { [k: string]: ProtectionBypass } | undefined;
  hasActiveBranches?: boolean | undefined;
  trustedIps?: CreateProjectTrustedIps | null | undefined;
  trustedSources?: CreateProjectTrustedSources | null | undefined;
  gitComments?: CreateProjectGitComments | undefined;
  gitProviderOptions?: GitProviderOptions | undefined;
  paused?: boolean | undefined;
  concurrencyBucketName?: string | undefined;
  webAnalytics?: CreateProjectWebAnalytics | undefined;
  security?: CreateProjectSecurity | undefined;
  oidcTokenConfig?: CreateProjectOidcTokenConfig | undefined;
  /**
   * Project shape. `null` on a rule list clears the project's override for that rule type (fall back to team for every env); omitting is equivalent. Setting `deploymentPolicy` itself to `null` clears every override at once. Kept structurally distinct from {@link TeamDeploymentPolicy} so the two storage locations don't share a type by accident.
   */
  deploymentPolicy?: CreateProjectDeploymentPolicy | null | undefined;
  tier?: CreateProjectTier | undefined;
  usageStatus?: UsageStatus | undefined;
  features?: Features | undefined;
  v0?: boolean | undefined;
  v0Created?: boolean | undefined;
  abuse?: CreateProjectAbuse | undefined;
  internalRoutes?: Array<InternalRoutes1 | InternalRoutes2> | undefined;
  hasDeployments?: boolean | undefined;
  dismissedToasts?: Array<CreateProjectDismissedToasts> | undefined;
  protectedSourcemaps?: boolean | undefined;
  tracing?: CreateProjectTracing | undefined;
  avatar?: string | null | undefined;
};

/** @internal */
export const RouteHas$inboundSchema: z.ZodType<
  RouteHas,
  z.ZodTypeDef,
  unknown
> = z.union([
  CreateProjectHasProjectsResponse1$inboundSchema,
  CreateProjectHasProjectsResponse2$inboundSchema,
]);

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

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

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

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

/** @internal */
export const Route2$inboundSchema: z.ZodType<Route2, z.ZodTypeDef, unknown> = z
  .object({
    has: z.array(
      z.union([
        CreateProjectHasProjectsResponse1$inboundSchema,
        CreateProjectHasProjectsResponse2$inboundSchema,
      ]),
    ),
    mitigate: z.lazy(() => RouteMitigate$inboundSchema),
    src: types.optional(types.string()),
  });

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

/** @internal */
export const Route1$inboundSchema: z.ZodType<Route1, z.ZodTypeDef, unknown> = z
  .object({
    src: types.string(),
    status: types.number(),
    expiry: types.optional(types.number()),
  });

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

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

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

/** @internal */
export const BlockHistory3$inboundSchema: z.ZodType<
  BlockHistory3,
  z.ZodTypeDef,
  unknown
> = z.object({
  action: types.literal("route-blocked"),
  route: smartUnion([
    z.lazy(() => Route1$inboundSchema),
    z.lazy(() => Route2$inboundSchema),
  ]),
  reason: types.string(),
  createdAt: types.number(),
  caseId: types.optional(types.string()),
  actor: types.optional(types.string()),
  comment: types.optional(types.string()),
  ineligibleForAppeal: types.optional(types.boolean()),
  isCascading: types.optional(types.boolean()),
});

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

/** @internal */
export const BlockHistory2$inboundSchema: z.ZodType<
  BlockHistory2,
  z.ZodTypeDef,
  unknown
> = z.object({
  action: types.literal("unblocked"),
  createdAt: types.number(),
  caseId: types.optional(types.string()),
  actor: types.optional(types.string()),
  comment: types.optional(types.string()),
  ineligibleForAppeal: types.optional(types.boolean()),
  isCascading: types.optional(types.boolean()),
});

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

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

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

/** @internal */
export const CreateProjectBlockHistory$inboundSchema: z.ZodType<
  CreateProjectBlockHistory,
  z.ZodTypeDef,
  unknown
> = z.union([
  z.lazy(() => BlockHistory1$inboundSchema),
  z.lazy(() => BlockHistory2$inboundSchema),
  z.lazy(() => BlockHistory3$inboundSchema),
  BlockHistory4$inboundSchema,
]);

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

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

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

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

/** @internal */
export const CreateProjectAbuse$inboundSchema: z.ZodType<
  CreateProjectAbuse,
  z.ZodTypeDef,
  unknown
> = z.object({
  scanner: types.optional(types.string()),
  history: z.array(CreateProjectHistory$inboundSchema),
  updatedAt: types.number(),
  block: types.optional(Block$inboundSchema),
  blockHistory: types.optional(
    z.array(z.union([
      z.lazy(() => BlockHistory1$inboundSchema),
      z.lazy(() =>
        BlockHistory2$inboundSchema
      ),
      z.lazy(() => BlockHistory3$inboundSchema),
      BlockHistory4$inboundSchema,
    ])),
  ),
  interstitial: types.optional(types.boolean()),
  interstitialHistory: types.optional(
    z.array(z.lazy(() => InterstitialHistory$inboundSchema)),
  ),
});

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

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

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

/** @internal */
export const CreateProjectHas2$inboundSchema: z.ZodType<
  CreateProjectHas2,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("host"),
  value: z.lazy(() => CreateProjectHasProjectsValue$inboundSchema),
});

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

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

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

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

/** @internal */
export const CreateProjectHas1$inboundSchema: z.ZodType<
  CreateProjectHas1,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("header"),
  key: CreateProjectHasKey$inboundSchema,
  value: z.lazy(() => CreateProjectHasValue$inboundSchema),
});

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

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

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

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

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

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

/** @internal */
export const InternalRoutes2$inboundSchema: z.ZodType<
  InternalRoutes2,
  z.ZodTypeDef,
  unknown
> = z.object({
  has: z.array(
    z.union([
      z.lazy(() => CreateProjectHas1$inboundSchema),
      z.lazy(() => CreateProjectHas2$inboundSchema),
    ]),
  ),
  mitigate: z.lazy(() => InternalRoutesMitigate$inboundSchema),
  src: types.optional(types.string()),
});

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

/** @internal */
export const InternalRoutes1$inboundSchema: z.ZodType<
  InternalRoutes1,
  z.ZodTypeDef,
  unknown
> = z.object({
  src: types.string(),
  status: types.number(),
  expiry: types.optional(types.number()),
});

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

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

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

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

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

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

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

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

/** @internal */
export const Value3$inboundSchema: z.ZodType<Value3, z.ZodTypeDef, unknown> = z
  .object({
    previousValue: smartUnion([
      types.string(),
      types.number(),
      types.boolean(),
    ]),
    currentValue: smartUnion([types.string(), types.number(), types.boolean()]),
  });

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

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

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

/** @internal */
export const CreateProjectDismissedToasts$inboundSchema: z.ZodType<
  CreateProjectDismissedToasts,
  z.ZodTypeDef,
  unknown
> = z.object({
  key: types.string(),
  dismissedAt: types.number(),
  action: CreateProjectAction$inboundSchema,
  value: types.nullable(
    smartUnion([
      z.lazy(() => Value3$inboundSchema),
      types.string(),
      types.number(),
      types.boolean(),
    ]),
  ),
});

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

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

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

/** @internal */
export const CreateProjectSamplingRules$inboundSchema: z.ZodType<
  CreateProjectSamplingRules,
  z.ZodTypeDef,
  unknown
> = z.object({
  rate: types.number(),
  env: types.optional(CreateProjectProjectsEnv$inboundSchema),
  requestPath: types.optional(types.string()),
  destination: types.optional(CreateProjectDestination$inboundSchema),
});

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

/** @internal */
export const CreateProjectTracing$inboundSchema: z.ZodType<
  CreateProjectTracing,
  z.ZodTypeDef,
  unknown
> = z.object({
  domains: types.optional(types.string()),
  ignorePaths: types.optional(z.array(types.string())),
  samplingRules: types.optional(
    z.array(z.lazy(() => CreateProjectSamplingRules$inboundSchema)),
  ),
});

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

/** @internal */
export const CreateProjectResponseBody$inboundSchema: z.ZodType<
  CreateProjectResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  accountId: types.string(),
  creator: types.optional(CreateProjectCreator$inboundSchema),
  alias: z.array(Alias$inboundSchema),
  analytics: types.optional(Analytics$inboundSchema),
  appliedCve55182Migration: types.optional(types.boolean()),
  speedInsights: types.optional(SpeedInsights$inboundSchema),
  autoExposeSystemEnvs: types.optional(types.boolean()),
  autoAssignCustomDomains: types.optional(types.boolean()),
  autoAssignCustomDomainsUpdatedBy: types.optional(types.string()),
  buildCommand: z.nullable(types.string()).optional(),
  commandForIgnoringBuildStep: z.nullable(types.string()).optional(),
  connectConfigurations: z.nullable(
    z.array(CreateProjectConnectConfigurations$inboundSchema),
  ).optional(),
  connectConfigurationId: z.nullable(types.string()).optional(),
  connectBuildsEnabled: types.optional(types.boolean()),
  passiveConnectConfigurationId: z.nullable(types.string()).optional(),
  createdAt: types.optional(types.number()),
  customerSupportCodeVisibility: types.optional(types.boolean()),
  crons: types.optional(CreateProjectCrons$inboundSchema),
  dataCache: types.optional(CreateProjectDataCache$inboundSchema),
  deploymentExpiration: DeploymentExpiration$inboundSchema,
  expiration: types.optional(CreateProjectExpiration$inboundSchema),
  devCommand: z.nullable(types.string()).optional(),
  directoryListing: types.boolean(),
  installCommand: z.nullable(types.string()).optional(),
  env: types.optional(z.array(CreateProjectEnv$inboundSchema)),
  customEnvironments: types.optional(
    z.array(CreateProjectCustomEnvironments$inboundSchema),
  ),
  framework: z.nullable(CreateProjectProjectsFramework$inboundSchema)
    .optional(),
  services: types.optional(z.array(CreateProjectServices$inboundSchema)),
  gitForkProtection: types.optional(types.boolean()),
  gitLFS: types.optional(types.boolean()),
  id: types.string(),
  ipBuckets: types.optional(z.array(CreateProjectIpBuckets$inboundSchema)),
  jobs: types.optional(Jobs$inboundSchema),
  latestDeployments: types.optional(z.array(LatestDeployments$inboundSchema)),
  link: types.optional(Link$inboundSchema),
  blobs: types.optional(Blobs$inboundSchema),
  microfrontends: types.optional(CreateProjectMicrofrontends$inboundSchema),
  name: types.string(),
  nodeVersion: CreateProjectNodeVersion$inboundSchema,
  optionsAllowlist: z.nullable(CreateProjectOptionsAllowlist$inboundSchema)
    .optional(),
  outputDirectory: z.nullable(types.string()).optional(),
  passwordProtection: z.nullable(CreateProjectPasswordProtection$inboundSchema)
    .optional(),
  passport: z.nullable(CreateProjectPassport$inboundSchema).optional(),
  protectionConfig: types.optional(ProtectionConfig$inboundSchema),
  sandbox: types.optional(CreateProjectSandbox$inboundSchema),
  productionDeploymentsFastLane: types.optional(types.boolean()),
  resourceConfig: CreateProjectProjectsResourceConfig$inboundSchema,
  rollbackDescription: types.optional(
    CreateProjectRollbackDescription$inboundSchema,
  ),
  rollingRelease: z.nullable(RollingRelease$inboundSchema).optional(),
  defaultResourceConfig: DefaultResourceConfig$inboundSchema,
  rootDirectory: z.nullable(types.string()).optional(),
  serverlessFunctionZeroConfigFailover: types.optional(types.boolean()),
  skewProtectionBoundaryAt: types.optional(types.number()),
  skewProtectionMaxAge: types.optional(types.number()),
  skewProtectionAllowedDomains: types.optional(z.array(types.string())),
  skipGitConnectDuringLink: types.optional(types.boolean()),
  staticIps: types.optional(CreateProjectStaticIps$inboundSchema),
  sourceFilesOutsideRootDirectory: types.optional(types.boolean()),
  enableAffectedProjectsDeployments: types.optional(types.boolean()),
  enableExternalRewriteCaching: types.optional(types.boolean()),
  ssoProtection: z.nullable(CreateProjectProjectsSsoProtection$inboundSchema)
    .optional(),
  targets: types.optional(
    z.record(types.nullable(CreateProjectTargets$inboundSchema)),
  ),
  transferCompletedAt: types.optional(types.number()),
  transferStartedAt: types.optional(types.number()),
  transferToAccountId: types.optional(types.string()),
  transferredFromAccountId: types.optional(types.string()),
  updatedAt: types.optional(types.number()),
  live: types.optional(types.boolean()),
  enablePreviewFeedback: z.nullable(types.boolean()).optional(),
  enableProductionFeedback: z.nullable(types.boolean()).optional(),
  permissions: types.optional(CreateProjectPermissions$inboundSchema),
  lastRollbackTarget: z.nullable(LastRollbackTarget$inboundSchema).optional(),
  lastAliasRequest: z.nullable(LastAliasRequest$inboundSchema).optional(),
  protectionBypass: types.optional(z.record(ProtectionBypass$inboundSchema)),
  hasActiveBranches: types.optional(types.boolean()),
  trustedIps: z.nullable(CreateProjectTrustedIps$inboundSchema).optional(),
  trustedSources: z.nullable(CreateProjectTrustedSources$inboundSchema)
    .optional(),
  gitComments: types.optional(CreateProjectGitComments$inboundSchema),
  gitProviderOptions: types.optional(GitProviderOptions$inboundSchema),
  paused: types.optional(types.boolean()),
  concurrencyBucketName: types.optional(types.string()),
  webAnalytics: types.optional(CreateProjectWebAnalytics$inboundSchema),
  security: types.optional(CreateProjectSecurity$inboundSchema),
  oidcTokenConfig: types.optional(CreateProjectOidcTokenConfig$inboundSchema),
  deploymentPolicy: z.nullable(CreateProjectDeploymentPolicy$inboundSchema)
    .optional(),
  tier: types.optional(CreateProjectTier$inboundSchema),
  usageStatus: types.optional(UsageStatus$inboundSchema),
  features: types.optional(Features$inboundSchema),
  v0: types.optional(types.boolean()),
  v0Created: types.optional(types.boolean()),
  abuse: types.optional(z.lazy(() => CreateProjectAbuse$inboundSchema)),
  internalRoutes: types.optional(
    z.array(smartUnion([
      z.lazy(() => InternalRoutes1$inboundSchema),
      z.lazy(() =>
        InternalRoutes2$inboundSchema
      ),
    ])),
  ),
  hasDeployments: types.optional(types.boolean()),
  dismissedToasts: types.optional(
    z.array(z.lazy(() => CreateProjectDismissedToasts$inboundSchema)),
  ),
  protectedSourcemaps: types.optional(types.boolean()),
  tracing: types.optional(z.lazy(() => CreateProjectTracing$inboundSchema)),
  avatar: z.nullable(types.string()).optional(),
});

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