/* * 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"; import { PermissionSet, PermissionSet$inboundSchema } from "./permissionset.js"; import { RoleAssigneeType, RoleAssigneeType$inboundSchema, } from "./roleassigneetype.js"; export type Role = { /** * Always `role`. */ type: "role"; /** * The unique ID for the role. */ id: string; /** * The human-readable name of the role. */ name: string; /** * The unique, human-readable identifier for the role. */ slug: string; /** * A description of the access this role grants. */ description: string; /** * The permissions granted by a role. */ permissions: PermissionSet; /** * The types of resource this role can be assigned to. */ assignableTo: Array; /** * The slugs of the roles this role is an add-on of. Empty when this role is not an add-on. */ appliesTo: Array; /** * Whether this role can be assigned on its own, without being combined with another role. */ isStandaloneAssignable: boolean; }; /** @internal */ export const Role$inboundSchema: z.ZodType = z .object({ type: z.literal("role").default("role"), id: z.string(), name: z.string(), slug: z.string(), description: z.string(), permissions: PermissionSet$inboundSchema, assignable_to: z.array(RoleAssigneeType$inboundSchema), applies_to: z.array(z.string()), is_standalone_assignable: z.boolean(), }).transform((v) => { return remap$(v, { "assignable_to": "assignableTo", "applies_to": "appliesTo", "is_standalone_assignable": "isStandaloneAssignable", }); }); export function roleFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Role$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Role' from JSON`, ); }