UNPKG

sanity

Version:

Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches

35 lines (28 loc) 933 B
import {map} from 'rxjs/operators' import {debugRolesParam$} from '../../debugParams' import {type Grant} from '../types' import * as grants from './exampleGrants' import {type ExampleRoleName} from './exampleRoles' const DEBUG_ROLE_GRANTS_MAP: Record<ExampleRoleName, Grant[]> = { // basic administrator: grants.administrator, editor: grants.editor, developer: grants.developer, contributor: grants.contributor, viewer: grants.viewer, // custom restricted: grants.restricted, requiresApproval: grants.requiresApproval, // legacy read: grants.viewer, write: grants.editor, } // todo: merge other resource keys(?) export const debugGrants$ = debugRolesParam$.pipe( map((roles) => { if (!roles.length) return null return roles .filter((value) => Boolean(value) && value in DEBUG_ROLE_GRANTS_MAP) .flatMap((roleName: ExampleRoleName) => DEBUG_ROLE_GRANTS_MAP[roleName] || []) }), )