feat(server): server-side events (#5669)

This commit is contained in:
Jason Rasmussen
2023-12-13 12:23:51 -05:00
committed by GitHub
parent 36196f2a5d
commit b34abf25f0
15 changed files with 114 additions and 63 deletions
@@ -1,6 +1,6 @@
export const ICommunicationRepository = 'ICommunicationRepository';
export enum CommunicationEvent {
export enum ClientEvent {
UPLOAD_SUCCESS = 'on_upload_success',
ASSET_DELETE = 'on_asset_delete',
ASSET_TRASH = 'on_asset_trash',
@@ -13,10 +13,17 @@ export enum CommunicationEvent {
NEW_RELEASE = 'on_new_release',
}
export type Callback = (userId: string) => Promise<void>;
export enum ServerEvent {
CONFIG_UPDATE = 'config:update',
}
export type OnConnectCallback = (userId: string) => Promise<void>;
export type OnServerEventCallback = () => Promise<void>;
export interface ICommunicationRepository {
send(event: CommunicationEvent, userId: string, data: any): void;
broadcast(event: CommunicationEvent, data: any): void;
addEventListener(event: 'connect', callback: Callback): void;
send(event: ClientEvent, userId: string, data: any): void;
broadcast(event: ClientEvent, data: any): void;
on(event: 'connect', callback: OnConnectCallback): void;
on(event: ServerEvent, callback: OnServerEventCallback): void;
sendServerEvent(event: ServerEvent): void;
}
@@ -46,7 +46,6 @@ export type JobItem =
// Storage Template
| { name: JobName.STORAGE_TEMPLATE_MIGRATION; data?: IBaseJob }
| { name: JobName.STORAGE_TEMPLATE_MIGRATION_SINGLE; data: IEntityJob }
| { name: JobName.SYSTEM_CONFIG_CHANGE; data?: IBaseJob }
// Migration
| { name: JobName.QUEUE_MIGRATION; data?: IBaseJob }