/*
 * 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 { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type LibraryOut = {
  id: string;
  name: string;
  createdAt: Date;
  updatedAt: Date;
  ownerId: string | null;
  ownerType: string;
  totalSize: number;
  nbDocuments: number;
  chunkSize: number | null;
  emoji?: string | null | undefined;
  description?: string | null | undefined;
  generatedDescription?: string | null | undefined;
  explicitUserMembersCount?: number | null | undefined;
  explicitWorkspaceMembersCount?: number | null | undefined;
  orgSharingRole?: string | null | undefined;
  /**
   * Generated Name
   */
  generatedName?: string | null | undefined;
};

/** @internal */
export const LibraryOut$inboundSchema: z.ZodType<
  LibraryOut,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: z.string(),
  name: z.string(),
  created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
  updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
  owner_id: z.nullable(z.string()),
  owner_type: z.string(),
  total_size: z.number().int(),
  nb_documents: z.number().int(),
  chunk_size: z.nullable(z.number().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.number().int()).optional(),
  explicit_workspace_members_count: z.nullable(z.number().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 libraryOutFromJSON(
  jsonString: string,
): SafeParseResult<LibraryOut, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => LibraryOut$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'LibraryOut' from JSON`,
  );
}
