Vex · API

createScopePolicy

createScopePolicy builds a scope policy from a role’s grants, a behaviors map and an optional profile name. A grant such as bookings.read decides whether a phase is present; the behaviors define the rules of a granted phase under the named profile. The returned policy has default: 'deny': it denies everything it does not list.

Grants
['shows.read', 'bookings.read', 'bookings.write.insert']
Behaviors
{
  bookings: {
    default: { read: [] },
    personal: {
      read: [{ match: 'member_id', to: 'memberId' }],
      insert: [{ set: 'member_id', to: 'memberId' }],
    },
  },
}
Profile
'personal'
Policy
{
  default: 'deny',
  entities: {
    shows: { read: [] },
    bookings: {
      read: [{ match: 'member_id', to: 'memberId' }],
      insert: [{ set: 'member_id', to: 'memberId' }],
    },
  },
}
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.