/*
 * 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 SharingOut = {
  libraryId: string;
  userId?: string | null | undefined;
  orgId: string;
  role: string;
  shareWithType: string;
  shareWithUuid: string | null;
};

/** @internal */
export const SharingOut$inboundSchema: z.ZodType<
  SharingOut,
  z.ZodTypeDef,
  unknown
> = z.object({
  library_id: z.string(),
  user_id: z.nullable(z.string()).optional(),
  org_id: z.string(),
  role: z.string(),
  share_with_type: z.string(),
  share_with_uuid: z.nullable(z.string()),
}).transform((v) => {
  return remap$(v, {
    "library_id": "libraryId",
    "user_id": "userId",
    "org_id": "orgId",
    "share_with_type": "shareWithType",
    "share_with_uuid": "shareWithUuid",
  });
});

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