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

import * as z from "zod/v3";

export type Attributes =
  | boolean
  | string
  | number
  | number
  | Date
  | Array<string>
  | Array<number>
  | Array<number>
  | Array<boolean>;

export type DocumentUpdateIn = {
  name?: string | null | undefined;
  attributes?:
    | {
      [k: string]:
        | boolean
        | string
        | number
        | number
        | Date
        | Array<string>
        | Array<number>
        | Array<number>
        | Array<boolean>;
    }
    | null
    | undefined;
};

/** @internal */
export type Attributes$Outbound =
  | boolean
  | string
  | number
  | number
  | string
  | Array<string>
  | Array<number>
  | Array<number>
  | Array<boolean>;

/** @internal */
export const Attributes$outboundSchema: z.ZodType<
  Attributes$Outbound,
  z.ZodTypeDef,
  Attributes
> = z.union([
  z.boolean(),
  z.string(),
  z.number().int(),
  z.number(),
  z.date().transform(v => v.toISOString()),
  z.array(z.string()),
  z.array(z.number().int()),
  z.array(z.number()),
  z.array(z.boolean()),
]);

export function attributesToJSON(attributes: Attributes): string {
  return JSON.stringify(Attributes$outboundSchema.parse(attributes));
}

/** @internal */
export type DocumentUpdateIn$Outbound = {
  name?: string | null | undefined;
  attributes?:
    | {
      [k: string]:
        | boolean
        | string
        | number
        | number
        | string
        | Array<string>
        | Array<number>
        | Array<number>
        | Array<boolean>;
    }
    | null
    | undefined;
};

/** @internal */
export const DocumentUpdateIn$outboundSchema: z.ZodType<
  DocumentUpdateIn$Outbound,
  z.ZodTypeDef,
  DocumentUpdateIn
> = z.object({
  name: z.nullable(z.string()).optional(),
  attributes: z.nullable(
    z.record(
      z.union([
        z.boolean(),
        z.string(),
        z.number().int(),
        z.number(),
        z.date().transform(v => v.toISOString()),
        z.array(z.string()),
        z.array(z.number().int()),
        z.array(z.number()),
        z.array(z.boolean()),
      ]),
    ),
  ).optional(),
});

export function documentUpdateInToJSON(
  documentUpdateIn: DocumentUpdateIn,
): string {
  return JSON.stringify(
    DocumentUpdateIn$outboundSchema.parse(documentUpdateIn),
  );
}
