UNPKG

5.24 kBTypeScriptView Raw
1import { EntitySubscriberInterface } from "./EntitySubscriberInterface";
2import { ObjectLiteral } from "../common/ObjectLiteral";
3import { QueryRunner } from "../query-runner/QueryRunner";
4import { EntityMetadata } from "../metadata/EntityMetadata";
5import { BroadcasterResult } from "./BroadcasterResult";
6import { ColumnMetadata } from "../metadata/ColumnMetadata";
7import { RelationMetadata } from "../metadata/RelationMetadata";
8/**
9 * Broadcaster provides a helper methods to broadcast events to the subscribers.
10 */
11export declare class Broadcaster {
12 private queryRunner;
13 constructor(queryRunner: QueryRunner);
14 /**
15 * Broadcasts "BEFORE_INSERT" event.
16 * Before insert event is executed before entity is being inserted to the database for the first time.
17 * All subscribers and entity listeners who listened to this event will be executed at this point.
18 * Subscribers and entity listeners can return promises, it will wait until they are resolved.
19 *
20 * Note: this method has a performance-optimized code organization, do not change code structure.
21 */
22 broadcastBeforeInsertEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral): void;
23 /**
24 * Broadcasts "BEFORE_UPDATE" event.
25 * Before update event is executed before entity is being updated in the database.
26 * All subscribers and entity listeners who listened to this event will be executed at this point.
27 * Subscribers and entity listeners can return promises, it will wait until they are resolved.
28 *
29 * Note: this method has a performance-optimized code organization, do not change code structure.
30 */
31 broadcastBeforeUpdateEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral, updatedColumns?: ColumnMetadata[], updatedRelations?: RelationMetadata[]): void;
32 /**
33 * Broadcasts "BEFORE_REMOVE" event.
34 * Before remove event is executed before entity is being removed from the database.
35 * All subscribers and entity listeners who listened to this event will be executed at this point.
36 * Subscribers and entity listeners can return promises, it will wait until they are resolved.
37 *
38 * Note: this method has a performance-optimized code organization, do not change code structure.
39 */
40 broadcastBeforeRemoveEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral): void;
41 /**
42 * Broadcasts "AFTER_INSERT" event.
43 * After insert event is executed after entity is being persisted to the database for the first time.
44 * All subscribers and entity listeners who listened to this event will be executed at this point.
45 * Subscribers and entity listeners can return promises, it will wait until they are resolved.
46 *
47 * Note: this method has a performance-optimized code organization, do not change code structure.
48 */
49 broadcastAfterInsertEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral): void;
50 /**
51 * Broadcasts "AFTER_UPDATE" event.
52 * After update event is executed after entity is being updated in the database.
53 * All subscribers and entity listeners who listened to this event will be executed at this point.
54 * Subscribers and entity listeners can return promises, it will wait until they are resolved.
55 *
56 * Note: this method has a performance-optimized code organization, do not change code structure.
57 */
58 broadcastAfterUpdateEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral, updatedColumns?: ColumnMetadata[], updatedRelations?: RelationMetadata[]): void;
59 /**
60 * Broadcasts "AFTER_REMOVE" event.
61 * After remove event is executed after entity is being removed from the database.
62 * All subscribers and entity listeners who listened to this event will be executed at this point.
63 * Subscribers and entity listeners can return promises, it will wait until they are resolved.
64 *
65 * Note: this method has a performance-optimized code organization, do not change code structure.
66 */
67 broadcastAfterRemoveEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral): void;
68 /**
69 * Broadcasts "AFTER_LOAD" event for all given entities, and their sub-entities.
70 * After load event is executed after entity has been loaded from the database.
71 * All subscribers and entity listeners who listened to this event will be executed at this point.
72 * Subscribers and entity listeners can return promises, it will wait until they are resolved.
73 *
74 * Note: this method has a performance-optimized code organization, do not change code structure.
75 */
76 broadcastLoadEventsForAll(result: BroadcasterResult, metadata: EntityMetadata, entities: ObjectLiteral[]): void;
77 /**
78 * Checks if subscriber's methods can be executed by checking if its don't listen to the particular entity,
79 * or listens our entity.
80 */
81 protected isAllowedSubscriber(subscriber: EntitySubscriberInterface<any>, target: Function | string): boolean;
82}