Class: RoleVersionRepository
Defined in: server/access/role-version-repository.ts:34
Append-only versions of a role — the flattened permission set + assignment
metadata. Mirrors RuleVersionRepository.
Extends
VersionRepository<PrismaClient,RbacRoleVersions,CreateInput,string,Tx<PrismaClient>>
Constructors
Constructor
new RoleVersionRepository(prismaClient: PrismaClientLike<Tx<PrismaClient<PrismaClientOptions, never, DefaultArgs>>> & PrismaClient<PrismaClientOptions, never, DefaultArgs>, options?: RepositoryOptions): RoleVersionRepository;Defined in: server/persistence/base-repository.ts:68
Parameters
| Parameter | Type |
|---|---|
prismaClient | PrismaClientLike<Tx<PrismaClient<PrismaClientOptions, never, DefaultArgs>>> & PrismaClient<PrismaClientOptions, never, DefaultArgs> |
options | RepositoryOptions |
Returns
RoleVersionRepository
Inherited from
Properties
ENTITY_TYPE?
protected readonly optional ENTITY_TYPE?: string;Defined in: server/persistence/base-repository.ts:61
Set ENTITY_TYPE in child repositories to enable automatic activity
logging. When set, create/update/delete operations auto-log unless
silenced with .silent. Requires an activity model on the consumer's
Prisma schema.
Inherited from
logger?
protected readonly optional logger?: Logger;Defined in: server/persistence/base-repository.ts:64
Inherited from
prismaClient
protected prismaClient: PrismaClientLike<Tx<PrismaClient<PrismaClientOptions, never, DefaultArgs>>> & PrismaClient<PrismaClientOptions, never, DefaultArgs>;Defined in: server/persistence/base-repository.ts:69
Inherited from
VersionRepository.prismaClient
Accessors
actorId
Get Signature
get protected actorId(): string | null | undefined;Defined in: server/persistence/base-repository.ts:76
Returns
string | null | undefined
Inherited from
auditCreate
Get Signature
get protected auditCreate(): {
createdBy: string | null | undefined;
updatedBy: string | null | undefined;
};Defined in: server/persistence/base-repository.ts:90
Returns
{
createdBy: string | null | undefined;
updatedBy: string | null | undefined;
}createdBy
createdBy: string | null | undefined = actorId;updatedBy
updatedBy: string | null | undefined = actorId;Inherited from
auditDelete
Get Signature
get protected auditDelete(): {
deletedAt: Date;
deletedBy: string | null | undefined;
};Defined in: server/persistence/base-repository.ts:99
Returns
{
deletedAt: Date;
deletedBy: string | null | undefined;
}deletedAt
deletedAt: Date;deletedBy
deletedBy: string | null | undefined;Inherited from
auditUpdate
Get Signature
get protected auditUpdate(): {
updatedBy: string | null | undefined;
};Defined in: server/persistence/base-repository.ts:95
Returns
{
updatedBy: string | null | undefined;
}updatedBy
updatedBy: string | null | undefined;Inherited from
silent
Get Signature
get silent(): this;Defined in: server/persistence/base-repository.ts:115
Suppress activity logging for the next mutation call. One-shot: the flag is consumed by the next create/update/delete.
Example
await repo.silent.update(id, data); // no activity logged
await repo.update(id, data); // activity logged normallyReturns
this
Inherited from
tx
Get Signature
get protected tx(): TTx;Defined in: server/persistence/base-repository.ts:86
The current Prisma handle: the active transaction if one is running on this async context, otherwise the raw client.
Returns
TTx
Inherited from
Methods
_count()
protected _count(): Promise<number>;Defined in: server/access/role-version-repository.ts:58
Returns
Promise<number>
Overrides
_countByParentId()
protected _countByParentId(roleId: string): Promise<number>;Defined in: server/access/role-version-repository.ts:86
Parameters
| Parameter | Type |
|---|---|
roleId | string |
Returns
Promise<number>
Overrides
VersionRepository._countByParentId
_create()
protected _create(input: CreateInput): Promise<{
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}>;Defined in: server/access/role-version-repository.ts:92
Parameters
| Parameter | Type |
|---|---|
input | CreateInput |
Returns
Promise<{
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}>
Overrides
_exists()
protected _exists(id: string): Promise<boolean>;Defined in: server/access/role-version-repository.ts:51
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Promise<boolean>
Overrides
_findById()
protected _findById(id: string): Promise<
| {
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}
| null>;Defined in: server/access/role-version-repository.ts:45
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Promise<
| {
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}
| null>
Overrides
_findByParentId()
protected _findByParentId(roleId: string): Promise<{
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}[]>;Defined in: server/access/role-version-repository.ts:79
Parameters
| Parameter | Type |
|---|---|
roleId | string |
Returns
Promise<{
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}[]>
Overrides
VersionRepository._findByParentId
_findMany()
protected _findMany(pagination: {
page: number;
pageSize: number;
}): Promise<{
items: {
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}[];
total: number;
}>;Defined in: server/access/role-version-repository.ts:62
Parameters
| Parameter | Type |
|---|---|
pagination | { page: number; pageSize: number; } |
pagination.page | number |
pagination.pageSize | number |
Returns
Promise<{
items: {
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}[];
total: number;
}>
Overrides
consumeSilent()
protected consumeSilent(): boolean;Defined in: server/persistence/base-repository.ts:128
Consume and reset the silent flag. Called by template methods.
Returns
boolean
Inherited from
VersionRepository.consumeSilent
count()
count(): Promise<number>;Defined in: server/persistence/base-repository.ts:191
Returns
Promise<number>
Inherited from
countByParentId()
countByParentId(parentId: string): Promise<number>;Defined in: server/persistence/base-repository.ts:261
Parameters
| Parameter | Type |
|---|---|
parentId | string |
Returns
Promise<number>
Inherited from
VersionRepository.countByParentId
create()
create(input: CreateInput): Promise<{
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}>;Defined in: server/persistence/base-repository.ts:265
Parameters
| Parameter | Type |
|---|---|
input | CreateInput |
Returns
Promise<{
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}>
Inherited from
exists()
exists(id: string): Promise<boolean>;Defined in: server/persistence/base-repository.ts:187
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Promise<boolean>
Inherited from
findById()
findById(id: string): Promise<
| {
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}
| null>;Defined in: server/persistence/base-repository.ts:177
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Promise<
| {
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}
| null>
Inherited from
findByIdOrThrow()
findByIdOrThrow(id: string): Promise<{
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}>;Defined in: server/persistence/base-repository.ts:181
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Promise<{
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}>
Inherited from
VersionRepository.findByIdOrThrow
findByParentId()
findByParentId(parentId: string): Promise<{
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}[]>;Defined in: server/persistence/base-repository.ts:233
Parameters
| Parameter | Type |
|---|---|
parentId | string |
Returns
Promise<{
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}[]>
Inherited from
VersionRepository.findByParentId
findByRoleId()
findByRoleId(roleId: string): Promise<{
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}[]>;Defined in: server/access/role-version-repository.ts:110
Parameters
| Parameter | Type |
|---|---|
roleId | string |
Returns
Promise<{
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}[]>
findLatestByParentId()
findLatestByParentId(parentId: string): Promise<
| {
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}
| null>;Defined in: server/persistence/base-repository.ts:237
Parameters
| Parameter | Type |
|---|---|
parentId | string |
Returns
Promise<
| {
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}
| null>
Inherited from
VersionRepository.findLatestByParentId
findLatestByRoleId()
findLatestByRoleId(roleId: string): Promise<
| {
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}
| null>;Defined in: server/access/role-version-repository.ts:114
Parameters
| Parameter | Type |
|---|---|
roleId | string |
Returns
Promise<
| {
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}
| null>
findMany()
findMany(pagination: {
page: number;
pageSize: number;
}): Promise<OffsetPaginatedResult<{
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}>>;Defined in: server/persistence/base-repository.ts:195
Parameters
| Parameter | Type |
|---|---|
pagination | { page: number; pageSize: number; } |
pagination.page | number |
pagination.pageSize | number |
Returns
Promise<OffsetPaginatedResult<{
allowedGrantScopes: JsonValue;
assignableByOrgAdmins: boolean;
changeReason: string | null;
createdAt: Date;
createdBy: string | null;
deletedAt: Date | null;
deletedBy: string | null;
id: string;
maxAssignableScope: RbacMaxAssignableScope;
permissions: JsonValue;
roleId: string;
systemManaged: boolean;
versionNumber: number;
}>>
Inherited from
getNextVersionNumber()
getNextVersionNumber(parentId: string): Promise<number>;Defined in: server/persistence/base-repository.ts:256
Next version number = highest versionNumber among the rows
_findByParentId returns, plus one. Subclasses typically filter
_findByParentId to deletedAt: null, so this counts only live rows.
That is collision-safe only while the subclass never soft-deletes
version rows. If a subclass gains a discard/soft-delete path AND its
@@unique(parentId, versionNumber) constraint counts soft-deleted rows
(Postgres unique indexes do), reusing a discarded row's number will
violate the constraint. Such a subclass must override to compute the
max over all rows including soft-deleted — see
FormSchemaVersionRepository.nextVersionNumber. Promote that into a
shared abstract hook here once a second repo needs it.
Parameters
| Parameter | Type |
|---|---|
parentId | string |
Returns
Promise<number>
Inherited from
VersionRepository.getNextVersionNumber
logActivity()
protected logActivity(
_entityId: string,
_action: string,
_metadata?: Record<string, unknown>
): Promise<void>;Defined in: server/persistence/base-repository.ts:140
Log an activity entry.
NOTE: This is not implemented because there's no activity model implemented in taproot yet! https://linear.app/kaizenlabs/issue/ENG-7846/add-activity-log-tables
Parameters
| Parameter | Type |
|---|---|
_entityId | string |
_action | string |
_metadata? | Record<string, unknown> |
Returns
Promise<void>
Inherited from
nextVersionNumber()
nextVersionNumber(roleId: string): Promise<number>;Defined in: server/access/role-version-repository.ts:118
Parameters
| Parameter | Type |
|---|---|
roleId | string |
Returns
Promise<number>
notFoundError()
protected notFoundError(id: string): Error;Defined in: server/access/role-version-repository.ts:41
Create a not-found error. Override to provide custom error types.
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Error