/*
 * 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 { EntityType, EntityType$outboundSchema } from "./entitytype.js";
import { ShareEnum, ShareEnum$outboundSchema } from "./shareenum.js";

export type SharingIn = {
  orgId?: string | null | undefined;
  level: ShareEnum;
  /**
   * The id of the entity (user, workspace or organization) to share with
   */
  shareWithUuid: string;
  /**
   * The type of entity, used to share a library.
   */
  shareWithType: EntityType;
};

/** @internal */
export type SharingIn$Outbound = {
  org_id?: string | null | undefined;
  level: string;
  share_with_uuid: string;
  share_with_type: string;
};

/** @internal */
export const SharingIn$outboundSchema: z.ZodType<
  SharingIn$Outbound,
  z.ZodTypeDef,
  SharingIn
> = z.object({
  orgId: z.nullable(z.string()).optional(),
  level: ShareEnum$outboundSchema,
  shareWithUuid: z.string(),
  shareWithType: EntityType$outboundSchema,
}).transform((v) => {
  return remap$(v, {
    orgId: "org_id",
    shareWithUuid: "share_with_uuid",
    shareWithType: "share_with_type",
  });
});

export function sharingInToJSON(sharingIn: SharingIn): string {
  return JSON.stringify(SharingIn$outboundSchema.parse(sharingIn));
}
