mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Fix flow triggers being registered multiple times (#13783)
Fixes #13739
This commit is contained in:
committed by
GitHub
parent
ef2b629c9b
commit
2efff9fd16
@@ -1,49 +1,64 @@
|
||||
import { FlowRaw } from '@directus/shared/types';
|
||||
import { getMessenger, Messenger } from '../messenger';
|
||||
import { getFlowManager } from '../flows';
|
||||
import { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types';
|
||||
import { ItemsService } from './items';
|
||||
|
||||
export class FlowsService extends ItemsService<FlowRaw> {
|
||||
messenger: Messenger;
|
||||
|
||||
constructor(options: AbstractServiceOptions) {
|
||||
super('directus_flows', options);
|
||||
this.messenger = getMessenger();
|
||||
}
|
||||
|
||||
async createOne(data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey> {
|
||||
const flowManager = getFlowManager();
|
||||
|
||||
const result = await super.createOne(data, opts);
|
||||
this.messenger.publish('flows', { type: 'reload' });
|
||||
await flowManager.reload();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async createMany(data: Partial<Item>[], opts?: MutationOptions): Promise<PrimaryKey[]> {
|
||||
const flowManager = getFlowManager();
|
||||
|
||||
const result = await super.createMany(data, opts);
|
||||
this.messenger.publish('flows', { type: 'reload' });
|
||||
await flowManager.reload();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async updateOne(key: PrimaryKey, data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey> {
|
||||
const flowManager = getFlowManager();
|
||||
|
||||
const result = await super.updateOne(key, data, opts);
|
||||
this.messenger.publish('flows', { type: 'reload' });
|
||||
await flowManager.reload();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async updateMany(keys: PrimaryKey[], data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey[]> {
|
||||
const flowManager = getFlowManager();
|
||||
|
||||
const result = await super.updateMany(keys, data, opts);
|
||||
this.messenger.publish('flows', { type: 'reload' });
|
||||
await flowManager.reload();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async deleteOne(key: PrimaryKey, opts?: MutationOptions): Promise<PrimaryKey> {
|
||||
const flowManager = getFlowManager();
|
||||
|
||||
const result = await super.deleteOne(key, opts);
|
||||
this.messenger.publish('flows', { type: 'reload' });
|
||||
await flowManager.reload();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async deleteMany(keys: PrimaryKey[], opts?: MutationOptions): Promise<PrimaryKey[]> {
|
||||
const flowManager = getFlowManager();
|
||||
|
||||
const result = await super.deleteMany(keys, opts);
|
||||
this.messenger.publish('flows', { type: 'reload' });
|
||||
await flowManager.reload();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +1,64 @@
|
||||
import { OperationRaw } from '@directus/shared/types';
|
||||
import { getMessenger, Messenger } from '../messenger';
|
||||
import { getFlowManager } from '../flows';
|
||||
import { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types';
|
||||
import { ItemsService } from './items';
|
||||
|
||||
export class OperationsService extends ItemsService<OperationRaw> {
|
||||
messenger: Messenger;
|
||||
|
||||
constructor(options: AbstractServiceOptions) {
|
||||
super('directus_operations', options);
|
||||
this.messenger = getMessenger();
|
||||
}
|
||||
|
||||
async createOne(data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey> {
|
||||
const flowManager = getFlowManager();
|
||||
|
||||
const result = await super.createOne(data, opts);
|
||||
this.messenger.publish('flows', { type: 'reload' });
|
||||
await flowManager.reload();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async createMany(data: Partial<Item>[], opts?: MutationOptions): Promise<PrimaryKey[]> {
|
||||
const flowManager = getFlowManager();
|
||||
|
||||
const result = await super.createMany(data, opts);
|
||||
this.messenger.publish('flows', { type: 'reload' });
|
||||
await flowManager.reload();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async updateOne(key: PrimaryKey, data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey> {
|
||||
const flowManager = getFlowManager();
|
||||
|
||||
const result = await super.updateOne(key, data, opts);
|
||||
this.messenger.publish('flows', { type: 'reload' });
|
||||
await flowManager.reload();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async updateMany(keys: PrimaryKey[], data: Partial<Item>, opts?: MutationOptions): Promise<PrimaryKey[]> {
|
||||
const flowManager = getFlowManager();
|
||||
|
||||
const result = await super.updateMany(keys, data, opts);
|
||||
this.messenger.publish('flows', { type: 'reload' });
|
||||
await flowManager.reload();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async deleteOne(key: PrimaryKey, opts?: MutationOptions): Promise<PrimaryKey> {
|
||||
const flowManager = getFlowManager();
|
||||
|
||||
const result = await super.deleteOne(key, opts);
|
||||
this.messenger.publish('flows', { type: 'reload' });
|
||||
await flowManager.reload();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async deleteMany(keys: PrimaryKey[], opts?: MutationOptions): Promise<PrimaryKey[]> {
|
||||
const flowManager = getFlowManager();
|
||||
|
||||
const result = await super.deleteMany(keys, opts);
|
||||
this.messenger.publish('flows', { type: 'reload' });
|
||||
await flowManager.reload();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user