/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 39d99c5709c0 */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ScopeType, ScopeType$inboundSchema, ScopeType$outboundSchema, } from "./scopetype.js"; /** * Describes the write permissions levels that a user has for a specific feature */ export type WritePermission = { /** * Describes the scope for a ReadPermission, WritePermission, or GrantPermission object */ scopeType?: ScopeType | undefined; /** * True if user has create permission for this feature and scope */ create?: boolean | undefined; /** * True if user has update permission for this feature and scope */ update?: boolean | undefined; /** * True if user has delete permission for this feature and scope */ delete?: boolean | undefined; }; /** @internal */ export const WritePermission$inboundSchema: z.ZodType< WritePermission, z.ZodTypeDef, unknown > = z.object({ scopeType: ScopeType$inboundSchema.optional(), create: z.boolean().optional(), update: z.boolean().optional(), delete: z.boolean().optional(), }); /** @internal */ export type WritePermission$Outbound = { scopeType?: string | undefined; create?: boolean | undefined; update?: boolean | undefined; delete?: boolean | undefined; }; /** @internal */ export const WritePermission$outboundSchema: z.ZodType< WritePermission$Outbound, z.ZodTypeDef, WritePermission > = z.object({ scopeType: ScopeType$outboundSchema.optional(), create: z.boolean().optional(), update: z.boolean().optional(), delete: z.boolean().optional(), }); export function writePermissionToJSON( writePermission: WritePermission, ): string { return JSON.stringify(WritePermission$outboundSchema.parse(writePermission)); } export function writePermissionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WritePermission$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WritePermission' from JSON`, ); }