add user service
This commit is contained in:
parent
540c165e94
commit
5e772c525a
@ -1,8 +1,7 @@
|
||||
{
|
||||
"name": "directus-helpers",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.0",
|
||||
"description": "Helpers Directus Extensions",
|
||||
"license": "ISC",
|
||||
"author": "AntoXa PRO <info@antoxa.pro>",
|
||||
"homepage": "https://antoxahub.ru/antoxa/directus-helpers",
|
||||
"repository": {
|
||||
@ -30,9 +29,6 @@
|
||||
"build": "vite build",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"keywords": [
|
||||
"Directus"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@directus/api": "latest",
|
||||
"@directus/extensions-sdk": "latest",
|
||||
|
@ -1,5 +1,9 @@
|
||||
import type { SchemaOverview, Accountability } from '@directus/types'
|
||||
import type { ItemsService, FilesService } from '@directus/api/dist/services'
|
||||
import type {
|
||||
ItemsService,
|
||||
FilesService,
|
||||
UsersService
|
||||
} from '@directus/api/dist/services'
|
||||
|
||||
export type TFactoryServicesOpts = {
|
||||
services: any
|
||||
@ -10,13 +14,12 @@ export type TFactoryServicesOpts = {
|
||||
type TServices<K extends keyof any> = { [P in K]: any }
|
||||
export type TFactoryTypes = Record<string, any>
|
||||
|
||||
export class FactoryServices<
|
||||
TTypes extends TFactoryTypes = any,
|
||||
> {
|
||||
export class FactoryServices<TTypes extends TFactoryTypes = any> {
|
||||
private opts: TFactoryServicesOpts
|
||||
|
||||
private _items: Partial<TServices<keyof TTypes>> = {}
|
||||
private _files: FilesService | null = null
|
||||
private _users: UsersService | null = null
|
||||
|
||||
constructor(opts: TFactoryServicesOpts) {
|
||||
this.opts = opts
|
||||
@ -43,5 +46,14 @@ export class FactoryServices<
|
||||
}
|
||||
return this._files as FilesService
|
||||
}
|
||||
}
|
||||
|
||||
users() {
|
||||
if (!this._users) {
|
||||
this._users = new this.opts.services.UserService({
|
||||
schema: this.opts.schema,
|
||||
accountability: this.opts.accountability
|
||||
})
|
||||
}
|
||||
return this._users as UsersService
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user