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

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
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 | undefined;
  attributes?:
    | {
      [k: string]:
        | boolean
        | string
        | number
        | number
        | Date
        | Array<string>
        | Array<number>
        | Array<number>
        | Array<boolean>;
    }
    | null
    | undefined;
  /**
   * If set, the document will be automatically deleted after this date.
   */
  expiresAt?: Date | 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 | undefined;
  attributes?:
    | {
      [k: string]:
        | boolean
        | string
        | number
        | number
        | string
        | Array<string>
        | Array<number>
        | Array<number>
        | Array<boolean>;
    }
    | null
    | undefined;
  expires_at?: string | null | undefined;
};

/** @internal */
export const UpdateDocumentRequest$outboundSchema: z.ZodType<
  UpdateDocumentRequest$Outbound,
  UpdateDocumentRequest
> = z.object({
  name: 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(),
  expiresAt: z.nullable(z.date().transform(v => v.toISOString())).optional(),
}).transform((v) => {
  return remap$(v, {
    expiresAt: "expires_at",
  });
});

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