diff --git a/.changeset/five-otters-attack.md b/.changeset/five-otters-attack.md new file mode 100644 index 0000000..ddb9dfa --- /dev/null +++ b/.changeset/five-otters-attack.md @@ -0,0 +1,5 @@ +--- +'@powersync/mysql-zongji': minor +--- + +Added type definitions for binlog query event diff --git a/types/index.d.ts b/types/index.d.ts index eb0e4c9..ad32153 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,4 +1,5 @@ import { Socket } from 'net'; +import { EventEmitter } from 'events'; /** * The types described here were added on an adhoc basis based on requirements in the Powersync Service. @@ -153,13 +154,22 @@ export type BinLogTableMapEvent = BaseBinLogEvent & { columnTypes: number[]; }; +export type BinLogQueryEvent = BaseBinLogEvent & { + query: string; + executionTime: number; + errorCode: number; + schema: string; + statusVars: string; +}; + export type BinLogEvent = | BinLogRotationEvent | BinLogGTIDLogEvent | BinLogXidEvent | BinLogRowEvent | BinLogRowUpdateEvent - | BinLogTableMapEvent; + | BinLogTableMapEvent + | BinLogQueryEvent; // @vlasky/mysql Connection export interface MySQLConnection { @@ -168,7 +178,7 @@ export interface MySQLConnection { query(sql: string, callback: (error: any, results: any, fields: any) => void): void; } -export declare class ZongJi { +export declare class ZongJi extends EventEmitter { stopped: boolean; connection: MySQLConnection; constructor(options: ZongjiOptions); @@ -177,6 +187,4 @@ export declare class ZongJi { stop(): void; pause(): void; resume(): void; - - on(type: 'binlog' | string, callback: (event: BinLogEvent) => void): void; }