UNPKG

@squarecloud/api

Version:
1 lines 1.96 kB
{"version":3,"sources":["../../src/types/client.ts"],"sourcesContent":["import EventEmitter from \"events\";\n\nimport type {\n\tApplication,\n\tApplicationStatus,\n\tBaseApplication,\n\tUser,\n\tWebsiteApplication,\n} from \"@/structures\";\nimport type { Backup } from \"@/structures/backup\";\n\nexport class TypedEventEmitter<TEvents extends Record<string, any>> {\n\tprivate emitter = new EventEmitter();\n\n\temit<TEventName extends keyof TEvents & string>(\n\t\teventName: TEventName,\n\t\t...eventArg: TEvents[TEventName]\n\t) {\n\t\tthis.emitter.emit(eventName, ...(eventArg as []));\n\t}\n\n\ton<TEventName extends keyof TEvents & string>(\n\t\teventName: TEventName,\n\t\thandler: (...eventArg: TEvents[TEventName]) => void,\n\t) {\n\t\tthis.emitter.on(eventName, handler as any);\n\t}\n\n\toff<TEventName extends keyof TEvents & string>(\n\t\teventName: TEventName,\n\t\thandler: (...eventArg: TEvents[TEventName]) => void,\n\t) {\n\t\tthis.emitter.off(eventName, handler as any);\n\t}\n}\n\nexport interface ClientEvents {\n\tlogsUpdate: [\n\t\tapplication: BaseApplication | Application | WebsiteApplication,\n\t\tbefore: string | undefined,\n\t\tafter: string,\n\t];\n\tbackupsUpdate: [\n\t\tapplication: BaseApplication | Application | WebsiteApplication,\n\t\tbefore: Backup[] | undefined,\n\t\tafter: Backup[],\n\t];\n\tstatusUpdate: [\n\t\tapplication: BaseApplication | Application | WebsiteApplication,\n\t\tbefore: ApplicationStatus | undefined,\n\t\tafter: ApplicationStatus,\n\t];\n\tuserUpdate: [before: User | undefined, after: User];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AAWlB,IAAM,oBAAN,MAA6D;AAAA,EAA7D;AACN,wBAAQ,WAAU,IAAI,cAAAA,QAAa;AAAA;AAAA,EAEnC,KACC,cACG,UACF;AACD,SAAK,QAAQ,KAAK,WAAW,GAAI,QAAe;AAAA,EACjD;AAAA,EAEA,GACC,WACA,SACC;AACD,SAAK,QAAQ,GAAG,WAAW,OAAc;AAAA,EAC1C;AAAA,EAEA,IACC,WACA,SACC;AACD,SAAK,QAAQ,IAAI,WAAW,OAAc;AAAA,EAC3C;AACD;","names":["EventEmitter"]}