I have a series of roles with ascending permissions. I also have series of issue states. I expect both of these to be represented as TypeScript enums.
I wish to provide a series of available actions, for different roles, for issues in different states:

I have a couple of related challenges.
actions[engineer][newReqest] = ["Claim"]
actions[engineer][liveRequest] = ["Submit for review"]
Can anybody point me to the TypeScript object type that best suits the above scenario?
I've attempted a solution in a playground. I supports the domain-expert-legible assignment, but I have some remaining TS errors. It could probably be improved...
enum Roles {
Engineer,
TeamLeader,
Manager
}
enum IssueStates {
New,
Live,
Closed
}
const actions = []
actions[IssueStates.New] = []
actions[IssueStates.Live] = []
actions[IssueStates.Closed] = []
actions[IssueStates.New][Roles.Engineer] = ["Claim"]
actions[IssueStates.Live][Roles.Engineer] = ["Submit"]
actions[IssueStates.Live][Roles.TeamLeader] = ["Accept", "Reject"]
actions[IssueStates.Closed][Roles.Manager] = ["ReOpen"]
const actionsFor = (tblActions: any, state: IssueStates, role: Roles): Array<String> => {
const forState = tblActions[state]
const actions = forState.filter((element: any, index: number) => index <= role)
return actions.flat(2) || []
}
console.log("Team leader for live issue", actionsFor(actions, IssueStates.Live, Roles.TeamLeader))
console.log("Team leader for closed issue", actionsFor(actions, IssueStates.Closed, Roles.TeamLeader))
console.log("Manager for closed issue", actionsFor(actions, IssueStates.Closed, Roles.Manager))
let summary = ""
for(let state in IssueStates) {
if(!isNaN(+state)) {
for(let role in Roles) {
if(!isNaN(+role)) {
summary += state + ", " + role + ", " + actionsFor(actions, state, role) + "\n"
}
}
}
}
console.log("Summary", "\n", summary)