Files
calendar/packages/features/pbac/domain/models/Role.ts
T
Lauris SkraucisandGitHub 45278a2195 feat: api v2 pbac support (#24402)
* feat: Pbac decorator and guard

* feat: v2 roles endpoints

* fix: test

* fix: starting v2

* fix: test error

* fix: test api keys

* fix fixture

* test permission creation

* feat: permissions endpoints

* refactors

* refactor: project structure

* test: role permissions crud

* test: permissions endpoint negative tests

* docs: org, team permissions swagger

* unit tests for validator

* Update roles.guard.ts

* fix type

* test: error messages

* refactor: dont throw error in pbac

* delete redundant test file

* feedback: logging error

* fix: persist role.permissions when updating role.otherProperty

* refactor: use output service to return permissions

* refactor: service functions return current permissions

* refactor: remove OrganizationsRepository from providers

* refactor: try catch possibly duplicate create

* refactor: require min length name if provided

* refactor: org role has orgId and team role teamId

* fix: pbac guard caching

* fix: e2e tests in parallel

* refactor: use IsTeamInOrg guard for orgs teams roles and permissions endpoints

* refactor: use redis service getter and setter

* refactor: invalidate team permissions cache when permissions change

* refactor: delete keys instead of versioning when caching
2025-11-06 17:14:55 +00:00

53 lines
968 B
TypeScript

import type { PermissionString } from "../types/permission-registry";
export const RoleType = {
SYSTEM: "SYSTEM",
CUSTOM: "CUSTOM",
} as const;
export type RoleType = (typeof RoleType)[keyof typeof RoleType];
export interface RolePermission {
id: string;
roleId: string;
resource: string;
action: string;
createdAt: Date;
}
export interface Role {
id: string;
name: string;
color?: string;
description?: string;
teamId?: number;
type: RoleType;
permissions: RolePermission[];
createdAt: Date;
updatedAt: Date;
}
// Value Objects
export interface CreateRoleData {
name: string;
color?: string;
description?: string;
teamId?: number;
permissions: PermissionString[];
type?: RoleType;
}
export interface UpdateRolePermissionsData {
roleId: string;
permissions?: PermissionString[];
updates?: {
color?: string;
name?: string;
};
}
export type PermissionChange = {
resource: string;
action: string;
};