add roles serveces
This commit is contained in:
parent
2ac837ebab
commit
e64d0a8c02
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "directus-helpers",
|
"name": "directus-helpers",
|
||||||
"version": "1.3.0",
|
"version": "1.4.0",
|
||||||
"description": "Helpers Directus Extensions",
|
"description": "Helpers Directus Extensions",
|
||||||
"author": "AntoXa PRO <info@antoxa.pro>",
|
"author": "AntoXa PRO <info@antoxa.pro>",
|
||||||
"homepage": "https://antoxahub.ru/antoxa/directus-helpers",
|
"homepage": "https://antoxahub.ru/antoxa/directus-helpers",
|
||||||
|
@ -2,7 +2,8 @@ import type { SchemaOverview, Accountability } from '@directus/types'
|
|||||||
import type {
|
import type {
|
||||||
ItemsService,
|
ItemsService,
|
||||||
FilesService,
|
FilesService,
|
||||||
UsersService
|
UsersService,
|
||||||
|
RolesService
|
||||||
} from '@directus/api/dist/services'
|
} from '@directus/api/dist/services'
|
||||||
|
|
||||||
export type TFactoryServicesOpts = {
|
export type TFactoryServicesOpts = {
|
||||||
@ -20,6 +21,7 @@ export class FactoryServices<TTypes extends TFactoryTypes = any> {
|
|||||||
private _items: Partial<TServices<keyof TTypes>> = {}
|
private _items: Partial<TServices<keyof TTypes>> = {}
|
||||||
private _files: FilesService | null = null
|
private _files: FilesService | null = null
|
||||||
private _users: UsersService | null = null
|
private _users: UsersService | null = null
|
||||||
|
private _roles: RolesService | null = null
|
||||||
|
|
||||||
constructor(opts: TFactoryServicesOpts) {
|
constructor(opts: TFactoryServicesOpts) {
|
||||||
this.opts = opts
|
this.opts = opts
|
||||||
@ -49,11 +51,21 @@ export class FactoryServices<TTypes extends TFactoryTypes = any> {
|
|||||||
|
|
||||||
get users() {
|
get users() {
|
||||||
if (!this._users) {
|
if (!this._users) {
|
||||||
this._users = new this.opts.services.UserService({
|
this._users = new this.opts.services.UsersService({
|
||||||
schema: this.opts.schema,
|
schema: this.opts.schema,
|
||||||
accountability: this.opts.accountability
|
accountability: this.opts.accountability
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return this._users as UsersService
|
return this._users as UsersService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get roles() {
|
||||||
|
if (!this._roles) {
|
||||||
|
this._roles = new this.opts.services.RolesService({
|
||||||
|
schema: this.opts.schema,
|
||||||
|
accountability: this.opts.accountability
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return this._roles as RolesService
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user