Skip to content

Commit

Permalink
refactor(service): users/auth: role database type changes
Browse files Browse the repository at this point in the history
  • Loading branch information
restjohn committed Dec 1, 2024
1 parent 08a1dc7 commit ae54610
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions service/src/models/role.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@

import mongoose from 'mongoose'
import { AnyPermission } from '../entities/authorization/entities.permissions'

type Callback<R> = (err: any, result?: R) => any

export declare interface RoleDocument {
id: string
_id: mongoose.Types.ObjectId
name: string
description?: string
permissions: AnyPermission[]
}

export type RoleModelInstance = mongoose.HydratedDocument<RoleDocument>

export declare type RoleJson = Omit<RoleDocument, '_id'>

export declare function getRoleById(id: string, callback: Callback<RoleDocument | null>): void
export declare function getRole(name: string, callback: Callback<RoleDocument | null>): void
export declare function getRoles(callback: Callback<RoleDocument[]>): void
export declare function createRole(role: RoleDocument, callback: Callback<RoleDocument>): void
export declare function updateRole(id: string, update: Partial<RoleDocument>, callback: Callback<RoleDocument>): void
export declare function deleteRole(role: RoleDocument, callback: Callback<RoleDocument>): void
export declare function getRoleById(id: string, callback: Callback<RoleModelInstance | null>): void
export declare function getRole(name: string, callback: Callback<RoleModelInstance | null>): void
export declare function getRoles(callback: Callback<RoleModelInstance[]>): void
export declare function createRole(role: Omit<RoleDocument, '_id'>, callback: Callback<RoleModelInstance>): void
export declare function updateRole(id: string, update: Partial<RoleDocument>, callback: Callback<RoleModelInstance>): void
export declare function deleteRole(role: RoleModelInstance, callback: Callback<RoleModelInstance>): void

0 comments on commit ae54610

Please sign in to comment.