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

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type Library = {
  id: string;
  name: string;
  createdAt: Date;
  updatedAt: Date;
  ownerId: string | null;
  ownerType: string;
  totalSize: number;
  nbDocuments: number;
  /**
   * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
   */
  chunkSize: number | null;
  /**
   * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
   */
  emoji?: string | null | undefined;
  description?: string | null | undefined;
  /**
   * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
   */
  generatedDescription?: string | null | undefined;
  /**
   * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
   */
  explicitUserMembersCount?: number | null | undefined;
  /**
   * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
   */
  explicitWorkspaceMembersCount?: number | null | undefined;
  /**
   * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
   */
  orgSharingRole?: string | null | undefined;
  /**
   * Generated Name
   *
   * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
   */
  generatedName?: string | null | undefined;
};

/** @internal */
export const Library$inboundSchema: z.ZodType<Library, unknown> = z.object({
  id: z.string(),
  name: z.string(),
  created_at: z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  updated_at: z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  owner_id: z.nullable(z.string()),
  owner_type: z.string(),
  total_size: z.int(),
  nb_documents: z.int(),
  chunk_size: z.nullable(z.int()),
  emoji: z.nullable(z.string()).optional(),
  description: z.nullable(z.string()).optional(),
  generated_description: z.nullable(z.string()).optional(),
  explicit_user_members_count: z.nullable(z.int()).optional(),
  explicit_workspace_members_count: z.nullable(z.int()).optional(),
  org_sharing_role: z.nullable(z.string()).optional(),
  generated_name: z.nullable(z.string()).optional(),
}).transform((v) => {
  return remap$(v, {
    "created_at": "createdAt",
    "updated_at": "updatedAt",
    "owner_id": "ownerId",
    "owner_type": "ownerType",
    "total_size": "totalSize",
    "nb_documents": "nbDocuments",
    "chunk_size": "chunkSize",
    "generated_description": "generatedDescription",
    "explicit_user_members_count": "explicitUserMembersCount",
    "explicit_workspace_members_count": "explicitWorkspaceMembersCount",
    "org_sharing_role": "orgSharingRole",
    "generated_name": "generatedName",
  });
});

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