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

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

/** @internal */
export const Sharing$inboundSchema: z.ZodType<Sharing, 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 sharingFromJSON(
  jsonString: string,
): SafeParseResult<Sharing, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Sharing$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Sharing' from JSON`,
  );
}
