Vex · API

mergeScopePolicies

mergeScopePolicies merges the policies of a user with several roles (here member and usher) into one that permits whatever any of them permits. Where two policies grant the same phase, the rule set with fewer match conditions wins, because every match narrows the rows. A phase granted by only one policy keeps that policy’s rules.

Member policy, entities
{
  shows: { read: [] },
  bookings: {
    read: [{ match: 'member_id', to: 'memberId' }],
    insert: [{ set: 'member_id', to: 'memberId' }],
  },
}
Usher policy, entities
{
  shows: { read: [] },
  members: { read: [] },
  bookings: { read: [] },
}
Merged policy
{
  default: 'deny',
  entities: {
    shows: { read: [] },
    bookings: {
      read: [],
      insert: [{ set: 'member_id', to: 'memberId' }],
    },
    members: { read: [] },
  },
}
Output matches the expected value

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