import { AbstractServiceOptions, Item, PrimaryKey } from '../types'; import { register } from '../webhooks'; import { ItemsService, MutationOptions } from './items'; export class WebhooksService extends ItemsService { constructor(options: AbstractServiceOptions) { super('directus_webhooks', options); } async createOne(data: Partial, opts?: MutationOptions): Promise { const result = await super.createOne(data, opts); await register(); return result; } async createMany(data: Partial[], opts?: MutationOptions): Promise { const result = await super.createMany(data, opts); await register(); return result; } async updateOne(key: PrimaryKey, data: Partial, opts?: MutationOptions): Promise { const result = await super.updateOne(key, data, opts); await register(); return result; } async updateMany(keys: PrimaryKey[], data: Partial, opts?: MutationOptions): Promise { const result = await super.updateMany(keys, data, opts); await register(); return result; } async deleteOne(key: PrimaryKey, opts?: MutationOptions): Promise { const result = await super.deleteOne(key, opts); await register(); return result; } async deleteMany(keys: PrimaryKey[], opts?: MutationOptions): Promise { const result = await super.deleteMany(keys, opts); await register(); return result; } /** * @deprecated Use `createOne` or `createMany` instead */ async create(data: Partial[]): Promise; async create(data: Partial): Promise; async create(data: Partial | Partial[]): Promise { const result = await super.create(data); await register(); return result; } /** * @deprecated Use `updateOne` or `updateMany` instead */ update(data: Partial, keys: PrimaryKey[]): Promise; update(data: Partial, key: PrimaryKey): Promise; update(data: Partial[]): Promise; async update( data: Partial | Partial[], key?: PrimaryKey | PrimaryKey[] ): Promise { const result = await super.update(data, key as any); await register(); return result; } /** * @deprecated Use `deleteOne` or `deleteMany` instead */ delete(key: PrimaryKey): Promise; delete(keys: PrimaryKey[]): Promise; async delete(key: PrimaryKey | PrimaryKey[]): Promise { const result = await super.delete(key as any); await register(); return result; } }