import { WorkOSApiError } from '../core/index.js'; import type { WorkOSOrganizationMembership } from './entities.js'; import type { WorkOSStore } from './store.js'; /** * A membership's role slugs the way production lists them: the priority role first, then the * rest in the organization's role priority order. A slug resolves the way the authorization * endpoints resolve it — an organization role shadows an environment role — and the priority is * read at call time, so a change to it shows on the next read without rewriting memberships. * Slugs that name no defined role keep the order they were written in, after the defined ones. * Rows written before `roles` existed carry only the singular `role`, which reads as a one-role * list. */ export declare function membershipRoleSlugs(ws: WorkOSStore, m: Pick): string[]; /** `slugs` deduplicated and in role priority order; see membershipRoleSlugs. */ export declare function orderRoleSlugs(ws: WorkOSStore, organizationId: string, slugs: readonly string[]): string[]; /** * The first of `slugs` that names no role an organization membership can hold — no role of * that organization, no environment role, and not one of the built-in two — or undefined when * all resolve. Production answers such a slug with `invalid_role`; the status differs by route * (422 on memberships, 400 on invitations), so the caller raises the error. */ export declare function undefinedRoleSlug(ws: WorkOSStore, organizationId: string, slugs: readonly string[]): string | undefined; /** * The fields a role-set write stores: `role` is the priority role and `roles` the whole set in * priority order, so every writer goes through here and the two never disagree. */ export declare function membershipRoleFields(ws: WorkOSStore, organizationId: string, slugs: readonly string[]): Pick; /** * The role slugs a membership request body names: `role_slugs` for several roles (what * production accepts once multiple roles are enabled) or the singular `role_slug`, never both. * Undefined when the body names neither, so an update can leave the roles alone. */ export declare function roleSlugsFromBody(body: Record): string[] | undefined; /** * Production's answer to a role slug that resolves to no role: the body is the same everywhere, * the status is the route's — 422 from the membership endpoints, 400 from invitations. */ export declare function invalidRole(status: 400 | 422): WorkOSApiError;