UNPKG

@vercel/sdk

Version:

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

2,595 lines 68.9 kB
/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { remap as remap$ } from "../lib/primitives.js";
import { 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 { Flag, Flag$inboundSchema } from "./flag.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export type UpdateFlagValue4 = {};

export type UpdateFlagVariants = {
  /**
   * The id of the variant
   */
  id: string;
  /**
   * A label for the variant
   */
  label?: string | undefined;
  /**
   * A description of the variant
   */
  description?: string | undefined;
  value?: any | undefined;
};

/**
 * Allows linking this environment to another environment so this flag will be evaluated with the other flag's configuration
 */
export type UpdateFlagReuse = {
  /**
   * Whether the reuse is active or not
   */
  active: boolean;
  /**
   * The environment to link to
   */
  environment: string;
};

export type UpdateFlagTargets = {
  note?: string | undefined;
  value: string;
};

export type UpdateFlagPausedOutcome = {
  type?: any | undefined;
  variantId: string;
};

export type UpdateFlagLhs2 = {
  type?: any | undefined;
  kind: string;
  attribute: string;
};

export type UpdateFlagLhs1 = {
  type?: any | undefined;
};

export type UpdateFlagLhs = UpdateFlagLhs2 | UpdateFlagLhs1;

export const UpdateFlagCmp = {
  Eq: "eq",
  NotEq: "!eq",
  OneOf: "oneOf",
  NotOneOf: "!oneOf",
  ContainsAllOf: "containsAllOf",
  ContainsAnyOf: "containsAnyOf",
  ContainsNoneOf: "containsNoneOf",
  StartsWith: "startsWith",
  NotStartsWith: "!startsWith",
  EndsWith: "endsWith",
  NotEndsWith: "!endsWith",
  Contains: "contains",
  NotContains: "!contains",
  Ex: "ex",
  NotEx: "!ex",
  Gt: "gt",
  Gte: "gte",
  Lt: "lt",
  Lte: "lte",
  Regex: "regex",
  NotRegex: "!regex",
  Before: "before",
  After: "after",
} as const;
export type UpdateFlagCmp = ClosedEnum<typeof UpdateFlagCmp>;

export type UpdateFlagRhs2 = {
  type?: any | undefined;
  pattern: string;
  flags: string;
};

export const UpdateFlagRhsType = {
  ListInline: "list/inline",
  List: "list",
} as const;
export type UpdateFlagRhsType = ClosedEnum<typeof UpdateFlagRhsType>;

export type UpdateFlagItems2 = {
  label?: string | undefined;
  note?: string | undefined;
  value: string;
};

export type UpdateFlagItems1 = {
  label?: string | undefined;
  note?: string | undefined;
  value: number;
};

export type UpdateFlagRhsItems = UpdateFlagItems1 | UpdateFlagItems2;

export type UpdateFlagRhs1 = {
  type: UpdateFlagRhsType;
  items: Array<UpdateFlagItems1 | UpdateFlagItems2>;
};

export type UpdateFlagRhs =
  | UpdateFlagRhs2
  | UpdateFlagRhs1
  | string
  | number
  | boolean;

export type UpdateFlagCmpOptions = {
  ignoreCase?: boolean | undefined;
};

export type UpdateFlagConditions = {
  lhs: UpdateFlagLhs2 | UpdateFlagLhs1;
  cmp: UpdateFlagCmp;
  rhs?: UpdateFlagRhs2 | UpdateFlagRhs1 | string | number | boolean | undefined;
  cmpOptions?: UpdateFlagCmpOptions | undefined;
};

export type UpdateFlagOutcomeFeatureFlagsBase = {
  type?: any | undefined;
  kind: string;
  attribute: string;
};

export type UpdateFlagOutcomeSlots = {
  /**
   * Promille of traffic for rollToVariant (0-100_000, where 1_000 = 1%)
   */
  promille: number;
  /**
   * How long this promille is served in ms before moving to the next slot.
   */
  durationMs: number;
};

export type UpdateFlagOutcome3 = {
  type?: any | undefined;
  base: UpdateFlagOutcomeFeatureFlagsBase;
  /**
   * Epoch ms when the rollout begins
   */
  startTimestamp: number;
  /**
   * The variant to roll away from
   */
  rollFromVariantId: string;
  /**
   * The variant to roll towards
   */
  rollToVariantId: string;
  /**
   * This variant will be used when the base attribute does not exist
   */
  defaultVariantId: string;
  /**
   * Each slot defines a promille and how long it is served for. After all slots expire, 100% is served indefinitely. The final implicit 100% slot does not need to be listed. Example: [[5_000, 21_600_000], [10_000, 28_800_000]] means 5‰ for 6h, then 10‰ for 8h, then 100% indefinitely.
   */
  slots: Array<UpdateFlagOutcomeSlots>;
};

export type UpdateFlagOutcomeBase = {
  type?: any | undefined;
  kind: string;
  attribute: string;
};

export type UpdateFlagOutcome2 = {
  type?: any | undefined;
  base: UpdateFlagOutcomeBase;
  /**
   * The distribution for each variant
   */
  weights: { [k: string]: number };
  /**
   * This variant will be used when the base attribute does not exist
   */
  defaultVariantId: string;
};

export type UpdateFlagOutcome1 = {
  type?: any | undefined;
  variantId: string;
};

export type UpdateFlagOutcome =
  | UpdateFlagOutcome3
  | UpdateFlagOutcome2
  | UpdateFlagOutcome1;

export type UpdateFlagRules = {
  id: string;
  conditions: Array<UpdateFlagConditions>;
  outcome: UpdateFlagOutcome3 | UpdateFlagOutcome2 | UpdateFlagOutcome1;
};

export type UpdateFlagFallthroughFeatureFlagsBase = {
  type?: any | undefined;
  kind: string;
  attribute: string;
};

export type UpdateFlagFallthroughSlots = {
  /**
   * Promille of traffic for rollToVariant (0-100_000, where 1_000 = 1%)
   */
  promille: number;
  /**
   * How long this promille is served in ms before moving to the next slot.
   */
  durationMs: number;
};

export type UpdateFlagFallthrough3 = {
  type?: any | undefined;
  base: UpdateFlagFallthroughFeatureFlagsBase;
  /**
   * Epoch ms when the rollout begins
   */
  startTimestamp: number;
  /**
   * The variant to roll away from
   */
  rollFromVariantId: string;
  /**
   * The variant to roll towards
   */
  rollToVariantId: string;
  /**
   * This variant will be used when the base attribute does not exist
   */
  defaultVariantId: string;
  /**
   * Each slot defines a promille and how long it is served for. After all slots expire, 100% is served indefinitely. The final implicit 100% slot does not need to be listed. Example: [[5_000, 21_600_000], [10_000, 28_800_000]] means 5‰ for 6h, then 10‰ for 8h, then 100% indefinitely.
   */
  slots: Array<UpdateFlagFallthroughSlots>;
};

export type UpdateFlagFallthroughBase = {
  type?: any | undefined;
  kind: string;
  attribute: string;
};

export type UpdateFlagFallthrough2 = {
  type?: any | undefined;
  base: UpdateFlagFallthroughBase;
  /**
   * The distribution for each variant
   */
  weights: { [k: string]: number };
  /**
   * This variant will be used when the base attribute does not exist
   */
  defaultVariantId: string;
};

export type UpdateFlagFallthrough1 = {
  type?: any | undefined;
  variantId: string;
};

export type UpdateFlagFallthrough =
  | UpdateFlagFallthrough3
  | UpdateFlagFallthrough2
  | UpdateFlagFallthrough1;

export type UpdateFlagEnvironments = {
  active: boolean;
  /**
   * Allows linking this environment to another environment so this flag will be evaluated with the other flag's configuration
   */
  reuse?: UpdateFlagReuse | undefined;
  /**
   * Allows assigning targets to variants while bypassing the flag's rules
   */
  targets?: {
    [k: string]: { [k: string]: { [k: string]: Array<UpdateFlagTargets> } };
  } | undefined;
  pausedOutcome: UpdateFlagPausedOutcome;
  rules: Array<UpdateFlagRules>;
  fallthrough:
    | UpdateFlagFallthrough3
    | UpdateFlagFallthrough2
    | UpdateFlagFallthrough1;
  /**
   * The revision of the environment config
   */
  revision?: number | undefined;
};

export const UpdateFlagState = {
  Active: "active",
  Archived: "archived",
} as const;
export type UpdateFlagState = ClosedEnum<typeof UpdateFlagState>;

export type UpdateFlagRequestBody = {
  /**
   * The user who created this patch
   */
  createdBy?: string | undefined;
  /**
   * Additional message for this version
   */
  message?: string | undefined;
  /**
   * The variants of the flag
   */
  variants?: Array<UpdateFlagVariants> | undefined;
  /**
   * The configuration for the flag in different environments
   */
  environments?: { [k: string]: UpdateFlagEnvironments } | undefined;
  /**
   * A random seed to prevent split points in different flags from having the same targets
   */
  seed?: number | undefined;
  /**
   * A description of the flag
   */
  description?: string | undefined;
  state?: UpdateFlagState | undefined;
  /**
   * The user ids of the maintainers of the flag
   */
  maintainerIds?: Array<string> | undefined;
  /**
   * Whether this flag is marked as permanent, indicating it should not be removed
   */
  permanent?: boolean | undefined;
  /**
   * Tags for categorizing the flag
   */
  tags?: Array<string> | undefined;
};

export type UpdateFlagRequest = {
  /**
   * The project id or name
   */
  projectIdOrName: string;
  /**
   * The flag id or name
   */
  flagIdOrSlug: string;
  /**
   * Etag to match, can be used interchangeably with the `if-match` header
   */
  ifMatch?: string | undefined;
  /**
   * Whether to include metadata in the response
   */
  withMetadata?: boolean | undefined;
  /**
   * The Team identifier to perform the request on behalf of.
   */
  teamId?: string | undefined;
  /**
   * The Team slug to perform the request on behalf of.
   */
  slug?: string | undefined;
  requestBody?: UpdateFlagRequestBody | undefined;
};

export type ResponseBodyValue =
  | string
  | number
  | { [k: string]: any }
  | Array<any>
  | boolean;

export type ResponseBodyVariants = {
  description?: string | undefined;
  label?: string | undefined;
  value: string | number | { [k: string]: any } | Array<any> | boolean | null;
  id: string;
};

export type ResponseBodyReuse = {
  active: boolean;
  environment: string;
};

export type UpdateFlagResponseBodyTargets = {
  note?: string | undefined;
  value: string;
};

export const UpdateFlagResponseBodyType = {
  Variant: "variant",
} as const;
export type UpdateFlagResponseBodyType = ClosedEnum<
  typeof UpdateFlagResponseBodyType
>;

export type ResponseBodyPausedOutcome = {
  type: UpdateFlagResponseBodyType;
  variantId: string;
};

export type UpdateFlagFallthrough4 = {
  type: "experiment";
};

export const UpdateFlagFallthroughFeatureFlagsResponse200ApplicationJSONType = {
  Entity: "entity",
} as const;
export type UpdateFlagFallthroughFeatureFlagsResponse200ApplicationJSONType =
  ClosedEnum<
    typeof UpdateFlagFallthroughFeatureFlagsResponse200ApplicationJSONType
  >;

export type UpdateFlagFallthroughFeatureFlagsResponse200Base = {
  type: UpdateFlagFallthroughFeatureFlagsResponse200ApplicationJSONType;
  kind: string;
  attribute: string;
};

export type UpdateFlagFallthroughFeatureFlagsSlots = {
  promille: number;
  durationMs: number;
};

export type UpdateFlagFallthroughFeatureFlags3 = {
  type: "rollout";
  base: UpdateFlagFallthroughFeatureFlagsResponse200Base;
  defaultVariantId: string;
  startTimestamp: number;
  rollFromVariantId: string;
  rollToVariantId: string;
  slots: Array<UpdateFlagFallthroughFeatureFlagsSlots>;
};

export const UpdateFlagFallthroughFeatureFlagsResponse200ApplicationJSONResponseBodyType =
  {
    Entity: "entity",
  } as const;
export type UpdateFlagFallthroughFeatureFlagsResponse200ApplicationJSONResponseBodyType =
  ClosedEnum<
    typeof UpdateFlagFallthroughFeatureFlagsResponse200ApplicationJSONResponseBodyType
  >;

export type UpdateFlagFallthroughFeatureFlagsResponseBase = {
  type:
    UpdateFlagFallthroughFeatureFlagsResponse200ApplicationJSONResponseBodyType;
  kind: string;
  attribute: string;
};

export type UpdateFlagFallthroughFeatureFlags2 = {
  type: "split";
  base: UpdateFlagFallthroughFeatureFlagsResponseBase;
  weights: { [k: string]: number };
  defaultVariantId: string;
};

export type UpdateFlagFallthroughFeatureFlags1 = {
  type: "variant";
  variantId: string;
};

export type ResponseBodyFallthrough =
  | UpdateFlagFallthroughFeatureFlags1
  | UpdateFlagFallthroughFeatureFlags2
  | UpdateFlagFallthroughFeatureFlags3
  | UpdateFlagFallthrough4;

export type UpdateFlagOutcome4 = {
  type: "experiment";
};

export const UpdateFlagOutcomeFeatureFlagsResponse200ApplicationJSONType = {
  Entity: "entity",
} as const;
export type UpdateFlagOutcomeFeatureFlagsResponse200ApplicationJSONType =
  ClosedEnum<
    typeof UpdateFlagOutcomeFeatureFlagsResponse200ApplicationJSONType
  >;

export type UpdateFlagOutcomeFeatureFlagsResponse200Base = {
  type: UpdateFlagOutcomeFeatureFlagsResponse200ApplicationJSONType;
  kind: string;
  attribute: string;
};

export type UpdateFlagOutcomeFeatureFlagsSlots = {
  promille: number;
  durationMs: number;
};

export type UpdateFlagOutcomeFeatureFlags3 = {
  type: "rollout";
  base: UpdateFlagOutcomeFeatureFlagsResponse200Base;
  defaultVariantId: string;
  startTimestamp: number;
  rollFromVariantId: string;
  rollToVariantId: string;
  slots: Array<UpdateFlagOutcomeFeatureFlagsSlots>;
};

export const UpdateFlagOutcomeFeatureFlagsResponse200ApplicationJSONResponseBodyType =
  {
    Entity: "entity",
  } as const;
export type UpdateFlagOutcomeFeatureFlagsResponse200ApplicationJSONResponseBodyType =
  ClosedEnum<
    typeof UpdateFlagOutcomeFeatureFlagsResponse200ApplicationJSONResponseBodyType
  >;

export type UpdateFlagOutcomeFeatureFlagsResponseBase = {
  type: UpdateFlagOutcomeFeatureFlagsResponse200ApplicationJSONResponseBodyType;
  kind: string;
  attribute: string;
};

export type UpdateFlagOutcomeFeatureFlags2 = {
  type: "split";
  base: UpdateFlagOutcomeFeatureFlagsResponseBase;
  weights: { [k: string]: number };
  defaultVariantId: string;
};

export type UpdateFlagOutcomeFeatureFlags1 = {
  type: "variant";
  variantId: string;
};

export type ResponseBodyOutcome =
  | UpdateFlagOutcomeFeatureFlags1
  | UpdateFlagOutcomeFeatureFlags2
  | UpdateFlagOutcomeFeatureFlags3
  | UpdateFlagOutcome4;

export const UpdateFlagRhsFeatureFlagsResponseType = {
  Regex: "regex",
} as const;
export type UpdateFlagRhsFeatureFlagsResponseType = ClosedEnum<
  typeof UpdateFlagRhsFeatureFlagsResponseType
>;

export type UpdateFlagRhs4 = {
  type: UpdateFlagRhsFeatureFlagsResponseType;
  pattern: string;
  flags: string;
};

export const UpdateFlagRhsFeatureFlagsType = {
  List: "list",
  ListInline: "list/inline",
} as const;
export type UpdateFlagRhsFeatureFlagsType = ClosedEnum<
  typeof UpdateFlagRhsFeatureFlagsType
>;

export type UpdateFlagItemsFeatureFlags2 = {
  label?: string | undefined;
  note?: string | undefined;
  value: string;
};

export type UpdateFlagItemsFeatureFlags1 = {
  label?: string | undefined;
  note?: string | undefined;
  value: number;
};

export type UpdateFlagRhsFeatureFlagsItems =
  | UpdateFlagItemsFeatureFlags1
  | UpdateFlagItemsFeatureFlags2;

export type UpdateFlagRhs3 = {
  type: UpdateFlagRhsFeatureFlagsType;
  items: Array<UpdateFlagItemsFeatureFlags1 | UpdateFlagItemsFeatureFlags2>;
};

export type ResponseBodyRhs =
  | UpdateFlagRhs4
  | UpdateFlagRhs3
  | string
  | number
  | boolean;

export type ResponseBodyCmpOptions = {
  ignoreCase?: boolean | undefined;
};

export type UpdateFlagLhsFeatureFlags2 = {
  type: "entity";
  kind: string;
  attribute: string;
};

export type UpdateFlagLhsFeatureFlags1 = {
  type: "segment";
};

export type ResponseBodyLhs =
  | UpdateFlagLhsFeatureFlags1
  | UpdateFlagLhsFeatureFlags2;

export const ResponseBodyCmp = {
  NotContains: "!contains",
  NotEndsWith: "!endsWith",
  NotEq: "!eq",
  NotEx: "!ex",
  NotOneOf: "!oneOf",
  NotRegex: "!regex",
  NotStartsWith: "!startsWith",
  After: "after",
  Before: "before",
  Contains: "contains",
  ContainsAllOf: "containsAllOf",
  ContainsAnyOf: "containsAnyOf",
  ContainsNoneOf: "containsNoneOf",
  EndsWith: "endsWith",
  Eq: "eq",
  Ex: "ex",
  Gt: "gt",
  Gte: "gte",
  Lt: "lt",
  Lte: "lte",
  OneOf: "oneOf",
  Regex: "regex",
  StartsWith: "startsWith",
} as const;
export type ResponseBodyCmp = ClosedEnum<typeof ResponseBodyCmp>;

export type ResponseBodyConditions = {
  rhs?: UpdateFlagRhs4 | UpdateFlagRhs3 | string | number | boolean | undefined;
  cmpOptions?: ResponseBodyCmpOptions | undefined;
  lhs: UpdateFlagLhsFeatureFlags1 | UpdateFlagLhsFeatureFlags2;
  cmp: ResponseBodyCmp;
};

export type ResponseBodyRules = {
  id: string;
  outcome:
    | UpdateFlagOutcomeFeatureFlags1
    | UpdateFlagOutcomeFeatureFlags2
    | UpdateFlagOutcomeFeatureFlags3
    | UpdateFlagOutcome4;
  conditions: Array<ResponseBodyConditions>;
};

export type ResponseBodyEnvironments = {
  reuse?: ResponseBodyReuse | undefined;
  targets?: {
    [k: string]: {
      [k: string]: { [k: string]: Array<UpdateFlagResponseBodyTargets> };
    };
  } | undefined;
  revision?: number | undefined;
  pausedOutcome: ResponseBodyPausedOutcome;
  fallthrough:
    | UpdateFlagFallthroughFeatureFlags1
    | UpdateFlagFallthroughFeatureFlags2
    | UpdateFlagFallthroughFeatureFlags3
    | UpdateFlagFallthrough4;
  active: boolean;
  rules: Array<ResponseBodyRules>;
};

export const ResponseBodyKind = {
  Boolean: "boolean",
  Json: "json",
  Number: "number",
  String: "string",
} as const;
export type ResponseBodyKind = ClosedEnum<typeof ResponseBodyKind>;

export const ResponseBodyState = {
  Active: "active",
  Archived: "archived",
} as const;
export type ResponseBodyState = ClosedEnum<typeof ResponseBodyState>;

export const ResponseBodyTypeName = {
  Flag: "flag",
} as const;
export type ResponseBodyTypeName = ClosedEnum<typeof ResponseBodyTypeName>;

export type UpdateFlagResponseBody1 = {
  description?: string | undefined;
  variants: Array<ResponseBodyVariants>;
  id: string;
  environments: { [k: string]: ResponseBodyEnvironments };
  kind: ResponseBodyKind;
  revision: number;
  seed: number;
  state: ResponseBodyState;
  maintainerIds?: Array<string> | undefined;
  permanent?: boolean | undefined;
  tags?: Array<string> | undefined;
  slug: string;
  createdAt: number;
  updatedAt: number;
  updatedBy?: string | undefined;
  createdBy: string;
  ownerId: string;
  projectId: string;
  typeName: ResponseBodyTypeName;
};

export type UpdateFlagResponseBody = UpdateFlagResponseBody1 | Flag;

/** @internal */
export type UpdateFlagValue4$Outbound = {};

/** @internal */
export const UpdateFlagValue4$outboundSchema: z.ZodType<
  UpdateFlagValue4$Outbound,
  z.ZodTypeDef,
  UpdateFlagValue4
> = z.object({});

export function updateFlagValue4ToJSON(
  updateFlagValue4: UpdateFlagValue4,
): string {
  return JSON.stringify(
    UpdateFlagValue4$outboundSchema.parse(updateFlagValue4),
  );
}

/** @internal */
export type UpdateFlagVariants$Outbound = {
  id: string;
  label?: string | undefined;
  description?: string | undefined;
  value?: any | undefined;
};

/** @internal */
export const UpdateFlagVariants$outboundSchema: z.ZodType<
  UpdateFlagVariants$Outbound,
  z.ZodTypeDef,
  UpdateFlagVariants
> = z.object({
  id: z.string(),
  label: z.string().optional(),
  description: z.string().optional(),
  value: z.any().optional(),
});

export function updateFlagVariantsToJSON(
  updateFlagVariants: UpdateFlagVariants,
): string {
  return JSON.stringify(
    UpdateFlagVariants$outboundSchema.parse(updateFlagVariants),
  );
}

/** @internal */
export type UpdateFlagReuse$Outbound = {
  active: boolean;
  environment: string;
};

/** @internal */
export const UpdateFlagReuse$outboundSchema: z.ZodType<
  UpdateFlagReuse$Outbound,
  z.ZodTypeDef,
  UpdateFlagReuse
> = z.object({
  active: z.boolean(),
  environment: z.string(),
});

export function updateFlagReuseToJSON(
  updateFlagReuse: UpdateFlagReuse,
): string {
  return JSON.stringify(UpdateFlagReuse$outboundSchema.parse(updateFlagReuse));
}

/** @internal */
export type UpdateFlagTargets$Outbound = {
  note?: string | undefined;
  value: string;
};

/** @internal */
export const UpdateFlagTargets$outboundSchema: z.ZodType<
  UpdateFlagTargets$Outbound,
  z.ZodTypeDef,
  UpdateFlagTargets
> = z.object({
  note: z.string().optional(),
  value: z.string(),
});

export function updateFlagTargetsToJSON(
  updateFlagTargets: UpdateFlagTargets,
): string {
  return JSON.stringify(
    UpdateFlagTargets$outboundSchema.parse(updateFlagTargets),
  );
}

/** @internal */
export type UpdateFlagPausedOutcome$Outbound = {
  type?: any | undefined;
  variantId: string;
};

/** @internal */
export const UpdateFlagPausedOutcome$outboundSchema: z.ZodType<
  UpdateFlagPausedOutcome$Outbound,
  z.ZodTypeDef,
  UpdateFlagPausedOutcome
> = z.object({
  type: z.any().optional(),
  variantId: z.string(),
});

export function updateFlagPausedOutcomeToJSON(
  updateFlagPausedOutcome: UpdateFlagPausedOutcome,
): string {
  return JSON.stringify(
    UpdateFlagPausedOutcome$outboundSchema.parse(updateFlagPausedOutcome),
  );
}

/** @internal */
export type UpdateFlagLhs2$Outbound = {
  type?: any | undefined;
  kind: string;
  attribute: string;
};

/** @internal */
export const UpdateFlagLhs2$outboundSchema: z.ZodType<
  UpdateFlagLhs2$Outbound,
  z.ZodTypeDef,
  UpdateFlagLhs2
> = z.object({
  type: z.any().optional(),
  kind: z.string(),
  attribute: z.string(),
});

export function updateFlagLhs2ToJSON(updateFlagLhs2: UpdateFlagLhs2): string {
  return JSON.stringify(UpdateFlagLhs2$outboundSchema.parse(updateFlagLhs2));
}

/** @internal */
export type UpdateFlagLhs1$Outbound = {
  type?: any | undefined;
};

/** @internal */
export const UpdateFlagLhs1$outboundSchema: z.ZodType<
  UpdateFlagLhs1$Outbound,
  z.ZodTypeDef,
  UpdateFlagLhs1
> = z.object({
  type: z.any().optional(),
});

export function updateFlagLhs1ToJSON(updateFlagLhs1: UpdateFlagLhs1): string {
  return JSON.stringify(UpdateFlagLhs1$outboundSchema.parse(updateFlagLhs1));
}

/** @internal */
export type UpdateFlagLhs$Outbound =
  | UpdateFlagLhs2$Outbound
  | UpdateFlagLhs1$Outbound;

/** @internal */
export const UpdateFlagLhs$outboundSchema: z.ZodType<
  UpdateFlagLhs$Outbound,
  z.ZodTypeDef,
  UpdateFlagLhs
> = smartUnion([
  z.lazy(() => UpdateFlagLhs2$outboundSchema),
  z.lazy(() => UpdateFlagLhs1$outboundSchema),
]);

export function updateFlagLhsToJSON(updateFlagLhs: UpdateFlagLhs): string {
  return JSON.stringify(UpdateFlagLhs$outboundSchema.parse(updateFlagLhs));
}

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

/** @internal */
export type UpdateFlagRhs2$Outbound = {
  type?: any | undefined;
  pattern: string;
  flags: string;
};

/** @internal */
export const UpdateFlagRhs2$outboundSchema: z.ZodType<
  UpdateFlagRhs2$Outbound,
  z.ZodTypeDef,
  UpdateFlagRhs2
> = z.object({
  type: z.any().optional(),
  pattern: z.string(),
  flags: z.string(),
});

export function updateFlagRhs2ToJSON(updateFlagRhs2: UpdateFlagRhs2): string {
  return JSON.stringify(UpdateFlagRhs2$outboundSchema.parse(updateFlagRhs2));
}

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

/** @internal */
export type UpdateFlagItems2$Outbound = {
  label?: string | undefined;
  note?: string | undefined;
  value: string;
};

/** @internal */
export const UpdateFlagItems2$outboundSchema: z.ZodType<
  UpdateFlagItems2$Outbound,
  z.ZodTypeDef,
  UpdateFlagItems2
> = z.object({
  label: z.string().optional(),
  note: z.string().optional(),
  value: z.string(),
});

export function updateFlagItems2ToJSON(
  updateFlagItems2: UpdateFlagItems2,
): string {
  return JSON.stringify(
    UpdateFlagItems2$outboundSchema.parse(updateFlagItems2),
  );
}

/** @internal */
export type UpdateFlagItems1$Outbound = {
  label?: string | undefined;
  note?: string | undefined;
  value: number;
};

/** @internal */
export const UpdateFlagItems1$outboundSchema: z.ZodType<
  UpdateFlagItems1$Outbound,
  z.ZodTypeDef,
  UpdateFlagItems1
> = z.object({
  label: z.string().optional(),
  note: z.string().optional(),
  value: z.number(),
});

export function updateFlagItems1ToJSON(
  updateFlagItems1: UpdateFlagItems1,
): string {
  return JSON.stringify(
    UpdateFlagItems1$outboundSchema.parse(updateFlagItems1),
  );
}

/** @internal */
export type UpdateFlagRhsItems$Outbound =
  | UpdateFlagItems1$Outbound
  | UpdateFlagItems2$Outbound;

/** @internal */
export const UpdateFlagRhsItems$outboundSchema: z.ZodType<
  UpdateFlagRhsItems$Outbound,
  z.ZodTypeDef,
  UpdateFlagRhsItems
> = smartUnion([
  z.lazy(() => UpdateFlagItems1$outboundSchema),
  z.lazy(() => UpdateFlagItems2$outboundSchema),
]);

export function updateFlagRhsItemsToJSON(
  updateFlagRhsItems: UpdateFlagRhsItems,
): string {
  return JSON.stringify(
    UpdateFlagRhsItems$outboundSchema.parse(updateFlagRhsItems),
  );
}

/** @internal */
export type UpdateFlagRhs1$Outbound = {
  type: string;
  items: Array<UpdateFlagItems1$Outbound | UpdateFlagItems2$Outbound>;
};

/** @internal */
export const UpdateFlagRhs1$outboundSchema: z.ZodType<
  UpdateFlagRhs1$Outbound,
  z.ZodTypeDef,
  UpdateFlagRhs1
> = z.object({
  type: UpdateFlagRhsType$outboundSchema,
  items: z.array(
    smartUnion([
      z.lazy(() => UpdateFlagItems1$outboundSchema),
      z.lazy(() => UpdateFlagItems2$outboundSchema),
    ]),
  ),
});

export function updateFlagRhs1ToJSON(updateFlagRhs1: UpdateFlagRhs1): string {
  return JSON.stringify(UpdateFlagRhs1$outboundSchema.parse(updateFlagRhs1));
}

/** @internal */
export type UpdateFlagRhs$Outbound =
  | UpdateFlagRhs2$Outbound
  | UpdateFlagRhs1$Outbound
  | string
  | number
  | boolean;

/** @internal */
export const UpdateFlagRhs$outboundSchema: z.ZodType<
  UpdateFlagRhs$Outbound,
  z.ZodTypeDef,
  UpdateFlagRhs
> = smartUnion([
  z.lazy(() => UpdateFlagRhs2$outboundSchema),
  z.lazy(() => UpdateFlagRhs1$outboundSchema),
  z.string(),
  z.number(),
  z.boolean(),
]);

export function updateFlagRhsToJSON(updateFlagRhs: UpdateFlagRhs): string {
  return JSON.stringify(UpdateFlagRhs$outboundSchema.parse(updateFlagRhs));
}

/** @internal */
export type UpdateFlagCmpOptions$Outbound = {
  ignoreCase?: boolean | undefined;
};

/** @internal */
export const UpdateFlagCmpOptions$outboundSchema: z.ZodType<
  UpdateFlagCmpOptions$Outbound,
  z.ZodTypeDef,
  UpdateFlagCmpOptions
> = z.object({
  ignoreCase: z.boolean().optional(),
});

export function updateFlagCmpOptionsToJSON(
  updateFlagCmpOptions: UpdateFlagCmpOptions,
): string {
  return JSON.stringify(
    UpdateFlagCmpOptions$outboundSchema.parse(updateFlagCmpOptions),
  );
}

/** @internal */
export type UpdateFlagConditions$Outbound = {
  lhs: UpdateFlagLhs2$Outbound | UpdateFlagLhs1$Outbound;
  cmp: string;
  rhs?:
    | UpdateFlagRhs2$Outbound
    | UpdateFlagRhs1$Outbound
    | string
    | number
    | boolean
    | undefined;
  cmpOptions?: UpdateFlagCmpOptions$Outbound | undefined;
};

/** @internal */
export const UpdateFlagConditions$outboundSchema: z.ZodType<
  UpdateFlagConditions$Outbound,
  z.ZodTypeDef,
  UpdateFlagConditions
> = z.object({
  lhs: smartUnion([
    z.lazy(() => UpdateFlagLhs2$outboundSchema),
    z.lazy(() => UpdateFlagLhs1$outboundSchema),
  ]),
  cmp: UpdateFlagCmp$outboundSchema,
  rhs: smartUnion([
    z.lazy(() => UpdateFlagRhs2$outboundSchema),
    z.lazy(() => UpdateFlagRhs1$outboundSchema),
    z.string(),
    z.number(),
    z.boolean(),
  ]).optional(),
  cmpOptions: z.lazy(() => UpdateFlagCmpOptions$outboundSchema).optional(),
});

export function updateFlagConditionsToJSON(
  updateFlagConditions: UpdateFlagConditions,
): string {
  return JSON.stringify(
    UpdateFlagConditions$outboundSchema.parse(updateFlagConditions),
  );
}

/** @internal */
export type UpdateFlagOutcomeFeatureFlagsBase$Outbound = {
  type?: any | undefined;
  kind: string;
  attribute: string;
};

/** @internal */
export const UpdateFlagOutcomeFeatureFlagsBase$outboundSchema: z.ZodType<
  UpdateFlagOutcomeFeatureFlagsBase$Outbound,
  z.ZodTypeDef,
  UpdateFlagOutcomeFeatureFlagsBase
> = z.object({
  type: z.any().optional(),
  kind: z.string(),
  attribute: z.string(),
});

export function updateFlagOutcomeFeatureFlagsBaseToJSON(
  updateFlagOutcomeFeatureFlagsBase: UpdateFlagOutcomeFeatureFlagsBase,
): string {
  return JSON.stringify(
    UpdateFlagOutcomeFeatureFlagsBase$outboundSchema.parse(
      updateFlagOutcomeFeatureFlagsBase,
    ),
  );
}

/** @internal */
export type UpdateFlagOutcomeSlots$Outbound = {
  promille: number;
  durationMs: number;
};

/** @internal */
export const UpdateFlagOutcomeSlots$outboundSchema: z.ZodType<
  UpdateFlagOutcomeSlots$Outbound,
  z.ZodTypeDef,
  UpdateFlagOutcomeSlots
> = z.object({
  promille: z.number(),
  durationMs: z.number(),
});

export function updateFlagOutcomeSlotsToJSON(
  updateFlagOutcomeSlots: UpdateFlagOutcomeSlots,
): string {
  return JSON.stringify(
    UpdateFlagOutcomeSlots$outboundSchema.parse(updateFlagOutcomeSlots),
  );
}

/** @internal */
export type UpdateFlagOutcome3$Outbound = {
  type?: any | undefined;
  base: UpdateFlagOutcomeFeatureFlagsBase$Outbound;
  startTimestamp: number;
  rollFromVariantId: string;
  rollToVariantId: string;
  defaultVariantId: string;
  slots: Array<UpdateFlagOutcomeSlots$Outbound>;
};

/** @internal */
export const UpdateFlagOutcome3$outboundSchema: z.ZodType<
  UpdateFlagOutcome3$Outbound,
  z.ZodTypeDef,
  UpdateFlagOutcome3
> = z.object({
  type: z.any().optional(),
  base: z.lazy(() => UpdateFlagOutcomeFeatureFlagsBase$outboundSchema),
  startTimestamp: z.number(),
  rollFromVariantId: z.string(),
  rollToVariantId: z.string(),
  defaultVariantId: z.string(),
  slots: z.array(z.lazy(() => UpdateFlagOutcomeSlots$outboundSchema)),
});

export function updateFlagOutcome3ToJSON(
  updateFlagOutcome3: UpdateFlagOutcome3,
): string {
  return JSON.stringify(
    UpdateFlagOutcome3$outboundSchema.parse(updateFlagOutcome3),
  );
}

/** @internal */
export type UpdateFlagOutcomeBase$Outbound = {
  type?: any | undefined;
  kind: string;
  attribute: string;
};

/** @internal */
export const UpdateFlagOutcomeBase$outboundSchema: z.ZodType<
  UpdateFlagOutcomeBase$Outbound,
  z.ZodTypeDef,
  UpdateFlagOutcomeBase
> = z.object({
  type: z.any().optional(),
  kind: z.string(),
  attribute: z.string(),
});

export function updateFlagOutcomeBaseToJSON(
  updateFlagOutcomeBase: UpdateFlagOutcomeBase,
): string {
  return JSON.stringify(
    UpdateFlagOutcomeBase$outboundSchema.parse(updateFlagOutcomeBase),
  );
}

/** @internal */
export type UpdateFlagOutcome2$Outbound = {
  type?: any | undefined;
  base: UpdateFlagOutcomeBase$Outbound;
  weights: { [k: string]: number };
  defaultVariantId: string;
};

/** @internal */
export const UpdateFlagOutcome2$outboundSchema: z.ZodType<
  UpdateFlagOutcome2$Outbound,
  z.ZodTypeDef,
  UpdateFlagOutcome2
> = z.object({
  type: z.any().optional(),
  base: z.lazy(() => UpdateFlagOutcomeBase$outboundSchema),
  weights: z.record(z.number()),
  defaultVariantId: z.string(),
});

export function updateFlagOutcome2ToJSON(
  updateFlagOutcome2: UpdateFlagOutcome2,
): string {
  return JSON.stringify(
    UpdateFlagOutcome2$outboundSchema.parse(updateFlagOutcome2),
  );
}

/** @internal */
export type UpdateFlagOutcome1$Outbound = {
  type?: any | undefined;
  variantId: string;
};

/** @internal */
export const UpdateFlagOutcome1$outboundSchema: z.ZodType<
  UpdateFlagOutcome1$Outbound,
  z.ZodTypeDef,
  UpdateFlagOutcome1
> = z.object({
  type: z.any().optional(),
  variantId: z.string(),
});

export function updateFlagOutcome1ToJSON(
  updateFlagOutcome1: UpdateFlagOutcome1,
): string {
  return JSON.stringify(
    UpdateFlagOutcome1$outboundSchema.parse(updateFlagOutcome1),
  );
}

/** @internal */
export type UpdateFlagOutcome$Outbound =
  | UpdateFlagOutcome3$Outbound
  | UpdateFlagOutcome2$Outbound
  | UpdateFlagOutcome1$Outbound;

/** @internal */
export const UpdateFlagOutcome$outboundSchema: z.ZodType<
  UpdateFlagOutcome$Outbound,
  z.ZodTypeDef,
  UpdateFlagOutcome
> = smartUnion([
  z.lazy(() => UpdateFlagOutcome3$outboundSchema),
  z.lazy(() => UpdateFlagOutcome2$outboundSchema),
  z.lazy(() => UpdateFlagOutcome1$outboundSchema),
]);

export function updateFlagOutcomeToJSON(
  updateFlagOutcome: UpdateFlagOutcome,
): string {
  return JSON.stringify(
    UpdateFlagOutcome$outboundSchema.parse(updateFlagOutcome),
  );
}

/** @internal */
export type UpdateFlagRules$Outbound = {
  id: string;
  conditions: Array<UpdateFlagConditions$Outbound>;
  outcome:
    | UpdateFlagOutcome3$Outbound
    | UpdateFlagOutcome2$Outbound
    | UpdateFlagOutcome1$Outbound;
};

/** @internal */
export const UpdateFlagRules$outboundSchema: z.ZodType<
  UpdateFlagRules$Outbound,
  z.ZodTypeDef,
  UpdateFlagRules
> = z.object({
  id: z.string(),
  conditions: z.array(z.lazy(() => UpdateFlagConditions$outboundSchema)),
  outcome: smartUnion([
    z.lazy(() => UpdateFlagOutcome3$outboundSchema),
    z.lazy(() => UpdateFlagOutcome2$outboundSchema),
    z.lazy(() => UpdateFlagOutcome1$outboundSchema),
  ]),
});

export function updateFlagRulesToJSON(
  updateFlagRules: UpdateFlagRules,
): string {
  return JSON.stringify(UpdateFlagRules$outboundSchema.parse(updateFlagRules));
}

/** @internal */
export type UpdateFlagFallthroughFeatureFlagsBase$Outbound = {
  type?: any | undefined;
  kind: string;
  attribute: string;
};

/** @internal */
export const UpdateFlagFallthroughFeatureFlagsBase$outboundSchema: z.ZodType<
  UpdateFlagFallthroughFeatureFlagsBase$Outbound,
  z.ZodTypeDef,
  UpdateFlagFallthroughFeatureFlagsBase
> = z.object({
  type: z.any().optional(),
  kind: z.string(),
  attribute: z.string(),
});

export function updateFlagFallthroughFeatureFlagsBaseToJSON(
  updateFlagFallthroughFeatureFlagsBase: UpdateFlagFallthroughFeatureFlagsBase,
): string {
  return JSON.stringify(
    UpdateFlagFallthroughFeatureFlagsBase$outboundSchema.parse(
      updateFlagFallthroughFeatureFlagsBase,
    ),
  );
}

/** @internal */
export type UpdateFlagFallthroughSlots$Outbound = {
  promille: number;
  durationMs: number;
};

/** @internal */
export const UpdateFlagFallthroughSlots$outboundSchema: z.ZodType<
  UpdateFlagFallthroughSlots$Outbound,
  z.ZodTypeDef,
  UpdateFlagFallthroughSlots
> = z.object({
  promille: z.number(),
  durationMs: z.number(),
});

export function updateFlagFallthroughSlotsToJSON(
  updateFlagFallthroughSlots: UpdateFlagFallthroughSlots,
): string {
  return JSON.stringify(
    UpdateFlagFallthroughSlots$outboundSchema.parse(updateFlagFallthroughSlots),
  );
}

/** @internal */
export type UpdateFlagFallthrough3$Outbound = {
  type?: any | undefined;
  base: UpdateFlagFallthroughFeatureFlagsBase$Outbound;
  startTimestamp: number;
  rollFromVariantId: string;
  rollToVariantId: string;
  defaultVariantId: string;
  slots: Array<UpdateFlagFallthroughSlots$Outbound>;
};

/** @internal */
export const UpdateFlagFallthrough3$outboundSchema: z.ZodType<
  UpdateFlagFallthrough3$Outbound,
  z.ZodTypeDef,
  UpdateFlagFallthrough3
> = z.object({
  type: z.any().optional(),
  base: z.lazy(() => UpdateFlagFallthroughFeatureFlagsBase$outboundSchema),
  startTimestamp: z.number(),
  rollFromVariantId: z.string(),
  rollToVariantId: z.string(),
  defaultVariantId: z.string(),
  slots: z.array(z.lazy(() => UpdateFlagFallthroughSlots$outboundSchema)),
});

export function updateFlagFallthrough3ToJSON(
  updateFlagFallthrough3: UpdateFlagFallthrough3,
): string {
  return JSON.stringify(
    UpdateFlagFallthrough3$outboundSchema.parse(updateFlagFallthrough3),
  );
}

/** @internal */
export type UpdateFlagFallthroughBase$Outbound = {
  type?: any | undefined;
  kind: string;
  attribute: string;
};

/** @internal */
export const UpdateFlagFallthroughBase$outboundSchema: z.ZodType<
  UpdateFlagFallthroughBase$Outbound,
  z.ZodTypeDef,
  UpdateFlagFallthroughBase
> = z.object({
  type: z.any().optional(),
  kind: z.string(),
  attribute: z.string(),
});

export function updateFlagFallthroughBaseToJSON(
  updateFlagFallthroughBase: UpdateFlagFallthroughBase,
): string {
  return JSON.stringify(
    UpdateFlagFallthroughBase$outboundSchema.parse(updateFlagFallthroughBase),
  );
}

/** @internal */
export type UpdateFlagFallthrough2$Outbound = {
  type?: any | undefined;
  base: UpdateFlagFallthroughBase$Outbound;
  weights: { [k: string]: number };
  defaultVariantId: string;
};

/** @internal */
export const UpdateFlagFallthrough2$outboundSchema: z.ZodType<
  UpdateFlagFallthrough2$Outbound,
  z.ZodTypeDef,
  UpdateFlagFallthrough2
> = z.object({
  type: z.any().optional(),
  base: z.lazy(() => UpdateFlagFallthroughBase$outboundSchema),
  weights: z.record(z.number()),
  defaultVariantId: z.string(),
});

export function updateFlagFallthrough2ToJSON(
  updateFlagFallthrough2: UpdateFlagFallthrough2,
): string {
  return JSON.stringify(
    UpdateFlagFallthrough2$outboundSchema.parse(updateFlagFallthrough2),
  );
}

/** @internal */
export type UpdateFlagFallthrough1$Outbound = {
  type?: any | undefined;
  variantId: string;
};

/** @internal */
export const UpdateFlagFallthrough1$outboundSchema: z.ZodType<
  UpdateFlagFallthrough1$Outbound,
  z.ZodTypeDef,
  UpdateFlagFallthrough1
> = z.object({
  type: z.any().optional(),
  variantId: z.string(),
});

export function updateFlagFallthrough1ToJSON(
  updateFlagFallthrough1: UpdateFlagFallthrough1,
): string {
  return JSON.stringify(
    UpdateFlagFallthrough1$outboundSchema.parse(updateFlagFallthrough1),
  );
}

/** @internal */
export type UpdateFlagFallthrough$Outbound =
  | UpdateFlagFallthrough3$Outbound
  | UpdateFlagFallthrough2$Outbound
  | UpdateFlagFallthrough1$Outbound;

/** @internal */
export const UpdateFlagFallthrough$outboundSchema: z.ZodType<
  UpdateFlagFallthrough$Outbound,
  z.ZodTypeDef,
  UpdateFlagFallthrough
> = smartUnion([
  z.lazy(() => UpdateFlagFallthrough3$outboundSchema),
  z.lazy(() => UpdateFlagFallthrough2$outboundSchema),
  z.lazy(() => UpdateFlagFallthrough1$outboundSchema),
]);

export function updateFlagFallthroughToJSON(
  updateFlagFallthrough: UpdateFlagFallthrough,
): string {
  return JSON.stringify(
    UpdateFlagFallthrough$outboundSchema.parse(updateFlagFallthrough),
  );
}

/** @internal */
export type UpdateFlagEnvironments$Outbound = {
  active: boolean;
  reuse?: UpdateFlagReuse$Outbound | undefined;
  targets?: {
    [k: string]: {
      [k: string]: { [k: string]: Array<UpdateFlagTargets$Outbound> };
    };
  } | undefined;
  pausedOutcome: UpdateFlagPausedOutcome$Outbound;
  rules: Array<UpdateFlagRules$Outbound>;
  fallthrough:
    | UpdateFlagFallthrough3$Outbound
    | UpdateFlagFallthrough2$Outbound
    | UpdateFlagFallthrough1$Outbound;
  revision?: number | undefined;
};

/** @internal */
export const UpdateFlagEnvironments$outboundSchema: z.ZodType<
  UpdateFlagEnvironments$Outbound,
  z.ZodTypeDef,
  UpdateFlagEnvironments
> = z.object({
  active: z.boolean(),
  reuse: z.lazy(() => UpdateFlagReuse$outboundSchema).optional(),
  targets: z.record(
    z.record(z.record(z.array(z.lazy(() => UpdateFlagTargets$outboundSchema)))),
  ).optional(),
  pausedOutcome: z.lazy(() => UpdateFlagPausedOutcome$outboundSchema),
  rules: z.array(z.lazy(() => UpdateFlagRules$outboundSchema)),
  fallthrough: smartUnion([
    z.lazy(() => UpdateFlagFallthrough3$outboundSchema),
    z.lazy(() => UpdateFlagFallthrough2$outboundSchema),
    z.lazy(() => UpdateFlagFallthrough1$outboundSchema),
  ]),
  revision: z.number().optional(),
});

export function updateFlagEnvironmentsToJSON(
  updateFlagEnvironments: UpdateFlagEnvironments,
): string {
  return JSON.stringify(
    UpdateFlagEnvironments$outboundSchema.parse(updateFlagEnvironments),
  );
}

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

/** @internal */
export type UpdateFlagRequestBody$Outbound = {
  createdBy?: string | undefined;
  message?: string | undefined;
  variants?: Array<UpdateFlagVariants$Outbound> | undefined;
  environments?: { [k: string]: UpdateFlagEnvironments$Outbound } | undefined;
  seed?: number | undefined;
  description?: string | undefined;
  state?: string | undefined;
  maintainerIds?: Array<string> | undefined;
  permanent?: boolean | undefined;
  tags?: Array<string> | undefined;
};

/** @internal */
export const UpdateFlagRequestBody$outboundSchema: z.ZodType<
  UpdateFlagRequestBody$Outbound,
  z.ZodTypeDef,
  UpdateFlagRequestBody
> = z.object({
  createdBy: z.string().optional(),
  message: z.string().optional(),
  variants: z.array(z.lazy(() => UpdateFlagVariants$outboundSchema)).optional(),
  environments: z.record(z.lazy(() => UpdateFlagEnvironments$outboundSchema))
    .optional(),
  seed: z.number().optional(),
  description: z.string().optional(),
  state: UpdateFlagState$outboundSchema.optional(),
  maintainerIds: z.array(z.string()).optional(),
  permanent: z.boolean().optional(),
  tags: z.array(z.string()).optional(),
});

export function updateFlagRequestBodyToJSON(
  updateFlagRequestBody: UpdateFlagRequestBody,
): string {
  return JSON.stringify(
    UpdateFlagRequestBody$outboundSchema.parse(updateFlagRequestBody),
  );
}

/** @internal */
export type UpdateFlagRequest$Outbound = {
  projectIdOrName: string;
  flagIdOrSlug: string;
  ifMatch?: string | undefined;
  withMetadata?: boolean | undefined;
  teamId?: string | undefined;
  slug?: string | undefined;
  RequestBody?: UpdateFlagRequestBody$Outbound | undefined;
};

/** @internal */
export const UpdateFlagRequest$outboundSchema: z.ZodType<
  UpdateFlagRequest$Outbound,
  z.ZodTypeDef,
  UpdateFlagRequest
> = z.object({
  projectIdOrName: z.string(),
  flagIdOrSlug: z.string(),
  ifMatch: z.string().optional(),
  withMetadata: z.boolean().optional(),
  teamId: z.string().optional(),
  slug: z.string().optional(),
  requestBody: z.lazy(() => UpdateFlagRequestBody$outboundSchema).optional(),
}).transform((v) => {
  return remap$(v, {
    requestBody: "RequestBody",
  });
});

export function updateFlagRequestToJSON(
  updateFlagRequest: UpdateFlagRequest,
): string {
  return JSON.stringify(
    UpdateFlagRequest$outboundSchema.parse(updateFlagRequest),
  );
}

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

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

/** @internal */
export const ResponseBodyVariants$inboundSchema: z.ZodType<
  ResponseBodyVariants,
  z.ZodTypeDef,
  unknown
> = z.object({
  description: types.optional(types.string()),
  label: types.optional(types.string()),
  value: types.nullable(
    smartUnion([
      types.string(),
      types.number(),
      z.record(z.any()),
      z.array(z.any()),
      types.boolean(),
    ]),
  ),
  id: types.string(),
});

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

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

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

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

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

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

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

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

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

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

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

/** @internal */
export const UpdateFlagFallthroughFeatureFlagsResponse200Base$inboundSchema:
  z.ZodType<
    UpdateFlagFallthroughFeatureFlagsResponse200Base,
    z.ZodTypeDef,
    unknown
  > = z.object({
    type:
      UpdateFlagFallthroughFeatureFlagsResponse200ApplicationJSONType$inboundSchema,
    kind: types.string(),
    attribute: types.string(),
  });

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

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

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

/** @internal */
export const UpdateFlagFallthroughFeatureFlags3$inboundSchema: z.ZodType<
  UpdateFlagFallthroughFeatureFlags3,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("rollout"),
  base: z.lazy(() =>
    UpdateFlagFallthroughFeatureFlagsResponse200Base$inboundSchema
  ),
  defaultVariantId: types.string(),
  startTimestamp: types.number(),
  rollFromVariantId: types.string(),
  rollToVariantId: types.string(),
  slots: z.array(
    z.lazy(() => UpdateFlagFallthroughFeatureFlagsSlots$inboundSchema),
  ),
});

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

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

/** @internal */
export const UpdateFlagFallthroughFeatureFlagsResponseBase$inboundSchema:
  z.ZodType<
    UpdateFlagFallthroughFeatureFlagsResponseBase,
    z.ZodTypeDef,
    unknown
  > = z.object({
    type:
      UpdateFlagFallthroughFeatureFlagsResponse200ApplicationJSONResponseBodyType$inboundSchema,
    kind: types.string(),
    attribute: types.string(),
  });

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

/** @internal */
export const UpdateFlagFallthroughFeatureFlags2$inboundSchema: z.ZodType<
  UpdateFlagFallthroughFeatureFlags2,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("split"),
  base: z.lazy(() =>
    UpdateFlagFallthroughFeatureFlagsResponseBase$inboundSchema
  ),
  weights: z.record(types.number()),
  defaultVariantId: types.string(),
});

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

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

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

/** @internal */
export const ResponseBodyFallthrough$inboundSchema: z.ZodType<
  ResponseBodyFallthrough,
  z.ZodTypeDef,
  unknown
> = z.union([
  z.lazy(() => UpdateFlagFallthroughFeatureFlags1$inboundSchema),
  z.lazy(() => UpdateFlagFallthroughFeatureFlags2$inboundSchema),
  z.lazy(() => UpdateFlagFallthroughFeatureFlags3$inboundSchema),
  z.lazy(() => UpdateFlagFallthrough4$inboundSchema),
]);

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

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

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

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

/** @internal */
export const UpdateFlagOutcomeFeatureFlagsResponse200Base$inboundSchema:
  z.ZodType<
    UpdateFlagOutcomeFeatureFlagsResponse200Base,
    z.ZodTypeDef,
    unknown
  > = z.object({
    type:
      UpdateFlagOutcomeFeatureFlagsResponse200ApplicationJSONType$inboundSchema,
    kind: types.string(),
    attribute: types.string(),
  });

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

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

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

/** @internal */
export const UpdateFlagOutcomeFeatureFlags3$inboundSchema: z.ZodType<
  UpdateFlagOutcomeFeatureFlags3,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("rollout"),
  base: z.lazy(() =>
    UpdateFlagOutcomeFeatureFlagsResponse200Base$inboundSchema
  ),
  defaultVariantId: types.string(),
  startTimestamp: types.number(),
  rollFromVariantId: types.string(),
  rollToVariantId: types.string(),
  slots: z.array(
    z.lazy(() => UpdateFlagOutcomeFeatureFlagsSlots$inboundSchema),
  ),
});

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

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

/** @internal */
export const UpdateFlagOutcomeFeatureFlagsResponseBase$inboundSchema: z.ZodType<
  UpdateFlagOutcomeFeatureFlagsResponseBase,
  z.ZodTypeDef,
  unknown
> = z.object({
  type:
    UpdateFlagOutcomeFeatureFlagsResponse200ApplicationJSONResponseBodyType$inboundSchema,
  kind: types.string(),
  attribute: types.string(),
});

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

/** @internal */
export const UpdateFlagOutcomeFeatureFlags2$inboundSchema: z.ZodType<
  UpdateFlagOutcomeFeatureFlags2,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("split"),
  base: z.lazy(() => UpdateFlagOutcomeFeatureFlagsResponseBase$inboundSchema),
  weights: z.record(types.number()),
  defaultVariantId: types.string(),
});

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

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

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

/** @internal */
export const ResponseBodyOutcome$inboundSchema: z.ZodType<
  ResponseBodyOutcome,
  z.ZodTypeDef,
  unknown
> = z.union([
  z.lazy(() => UpdateFlagOutcomeFeatureFlags1$inboundSchema),
  z.lazy(() => UpdateFlagOutcomeFeatureFlags2$inboundSchema),
  z.lazy(() => UpdateFlagOutcomeFeatureFlags3$inboundSchema),
  z.lazy(() => UpdateFlagOutcome4$inboundSchema),
]);

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

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

/** @internal */
export const UpdateFlagRhs4$inboundSchema: z.ZodType<
  UpdateFlagRhs4,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: UpdateFlagRhsFeatureFlagsResponseType$inboundSchema,
  pattern: types.string(),
  flags: types.string(),
});

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

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

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

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

/** @internal */
export const UpdateFlagItemsFeatureFlags1$inboundSchema: z.ZodType<
  UpdateFlagItemsFeatureFlags1,
  z.ZodTypeDef,
  unknown
> = z.object({
  label: types.optional(types.string()),
  note: types.optional(types.string()),
  value: types.number(),
});

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

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

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

/** @internal */
export const UpdateFlagRhs3$inboundSchema: z.ZodType<
  UpdateFlagRhs3,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: UpdateFlagRhsFeatureFlagsType$inboundSchema,
  items: z.array(
    smartUnion([
      z.lazy(() => UpdateFlagItemsFeatureFlags1$inboundSchema),
      z.lazy(() => UpdateFlagItemsFeatureFlags2$inboundSchema),
    ]),
  ),
});

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

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

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

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

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

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

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

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

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

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

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

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

/** @internal */
export const ResponseBodyConditions$inboundSchema: z.ZodType<
  ResponseBodyConditions,
  z.ZodTypeDef,
  unknown
> = z.object({
  rhs: types.optional(
    smartUnion([
      z.lazy(() => UpdateFlagRhs4$inboundSchema),
      z.lazy(() => UpdateFlagRhs3$inboundSchema),
      types.string(),
      types.number(),
      types.boolean(),
    ]),
  ),
  cmpOptions: types.optional(
    z.lazy(() => ResponseBodyCmpOptions$inboundSchema),
  ),
  lhs: z.union([
    z.lazy(() => UpdateFlagLhsFeatureFlags1$inboundSchema),
    z.lazy(() => UpdateFlagLhsFeatureFlags2$inboundSchema),
  ]),
  cmp: ResponseBodyCmp$inboundSchema,
});

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

/** @internal */
export const ResponseBodyRules$inboundSchema: z.ZodType<
  ResponseBodyRules,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: types.string(),
  outcome: z.union([
    z.lazy(() => UpdateFlagOutcomeFeatureFlags1$inboundSchema),
    z.lazy(() => UpdateFlagOutcomeFeatureFlags2$inboundSchema),
    z.lazy(() => UpdateFlagOutcomeFeatureFlags3$inboundSchema),
    z.lazy(() => UpdateFlagOutcome4$inboundSchema),
  ]),
  conditions: z.array(z.lazy(() => ResponseBodyConditions$inboundSchema)),
});

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

/** @internal */
export const ResponseBodyEnvironments$inboundSchema: z.ZodType<
  ResponseBodyEnvironments,
  z.ZodTypeDef,
  unknown
> = z.object({
  reuse: types.optional(z.lazy(() => ResponseBodyReuse$inboundSchema)),
  targets: types.optional(
    z.record(z.record(z.record(z.array(z.lazy(() =>
      UpdateFlagResponseBodyTargets$inboundSchema
    ))))),
  ),
  revision: types.optional(types.number()),
  pausedOutcome: z.lazy(() => ResponseBodyPausedOutcome$inboundSchema),
  fallthrough: z.union([
    z.lazy(() => UpdateFlagFallthroughFeatureFlags1$inboundSchema),
    z.lazy(() => UpdateFlagFallthroughFeatureFlags2$inboundSchema),
    z.lazy(() => UpdateFlagFallthroughFeatureFlags3$inboundSchema),
    z.lazy(() => UpdateFlagFallthrough4$inboundSchema),
  ]),
  active: types.boolean(),
  rules: z.array(z.lazy(() => ResponseBodyRules$inboundSchema)),
});

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

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

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

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

/** @internal */
export const UpdateFlagResponseBody1$inboundSchema: z.ZodType<
  UpdateFlagResponseBody1,
  z.ZodTypeDef,
  unknown
> = z.object({
  description: types.optional(types.string()),
  variants: z.array(z.lazy(() => ResponseBodyVariants$inboundSchema)),
  id: types.string(),
  environments: z.record(z.lazy(() => ResponseBodyEnvironments$inboundSchema)),
  kind: ResponseBodyKind$inboundSchema,
  revision: types.number(),
  seed: types.number(),
  state: ResponseBodyState$inboundSchema,
  maintainerIds: types.optional(z.array(types.string())),
  permanent: types.optional(types.boolean()),
  tags: types.optional(z.array(types.string())),
  slug: types.string(),
  createdAt: types.number(),
  updatedAt: types.number(),
  updatedBy: types.optional(types.string()),
  createdBy: types.string(),
  ownerId: types.string(),
  projectId: types.string(),
  typeName: ResponseBodyTypeName$inboundSchema,
});

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

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

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