/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 56629a04610c
 */

import * as z from "zod/v4";
import { smartUnion } from "../../types/smartUnion.js";

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

export type UpdateDocumentRequest = {
  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,
  Attributes
> = smartUnion([
  z.boolean(),
  z.string(),
  z.int(),
  z.number(),
  z.date().transform(v => v.toISOString()),
  z.array(z.string()),
  z.array(z.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 UpdateDocumentRequest$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 UpdateDocumentRequest$outboundSchema: z.ZodType<
  UpdateDocumentRequest$Outbound,
  UpdateDocumentRequest
> = z.object({
  name: z.nullable(z.string()).optional(),
  attributes: z.nullable(
    z.record(
      z.string(),
      smartUnion([
        z.boolean(),
        z.string(),
        z.int(),
        z.number(),
        z.date().transform(v => v.toISOString()),
        z.array(z.string()),
        z.array(z.int()),
        z.array(z.number()),
        z.array(z.boolean()),
      ]),
    ),
  ).optional(),
});

export function updateDocumentRequestToJSON(
  updateDocumentRequest: UpdateDocumentRequest,
): string {
  return JSON.stringify(
    UpdateDocumentRequest$outboundSchema.parse(updateDocumentRequest),
  );
}
