MCPcopy
hub / github.com/tldraw/tldraw / can

Function can

packages/dotcom-shared/src/roles.ts:36–41  ·  view source on GitHub ↗
(role: string | null | undefined, capability: Capability)

Source from the content-addressed store, hash-verified

34 * throwing, so callers never have to validate it first.
35 */
36export function can(role: string | null | undefined, capability: Capability): boolean {
37 if (!isRole(role)) return false
38 // `satisfies` narrows each array to a tuple of its own literals, so the cast
39 // widens it back to the full Capability union for `includes`.
40 return (roles[role] as readonly Capability[]).includes(capability)
41}
42
43/** Whether a string is a known role name. */
44export function isRole(role: string | null | undefined): role is Role {

Callers 11

createMutatorsFunction · 0.90
roles.test.tsFile · 0.90
WorkspaceSettingsDialogFunction · 0.90
canUpdateFileMethod · 0.90
useHasFileAdminRightsFunction · 0.90
onRequestMethod · 0.90
onDownloadTldrMethod · 0.90
canAccessFilesMethod · 0.90
validateUploadMethod · 0.90
requireWriteAccessToFileFunction · 0.90

Calls 2

isRoleFunction · 0.85
includesMethod · 0.80

Tested by

no test coverage detected