@powersync/service-module-mysql 0.6.4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/api/MySQLRouteAPIAdapter.d.ts +1 -1
  3. package/dist/api/MySQLRouteAPIAdapter.js +1 -1
  4. package/dist/api/MySQLRouteAPIAdapter.js.map +1 -1
  5. package/dist/replication/BinLogReplicationJob.d.ts +2 -0
  6. package/dist/replication/BinLogReplicationJob.js +10 -3
  7. package/dist/replication/BinLogReplicationJob.js.map +1 -1
  8. package/dist/replication/BinLogReplicator.d.ts +1 -0
  9. package/dist/replication/BinLogReplicator.js +22 -0
  10. package/dist/replication/BinLogReplicator.js.map +1 -1
  11. package/dist/replication/BinLogStream.d.ts +17 -1
  12. package/dist/replication/BinLogStream.js +126 -174
  13. package/dist/replication/BinLogStream.js.map +1 -1
  14. package/dist/replication/MySQLConnectionManager.d.ts +1 -1
  15. package/dist/replication/MySQLConnectionManager.js +2 -1
  16. package/dist/replication/MySQLConnectionManager.js.map +1 -1
  17. package/dist/replication/zongji/BinLogListener.d.ts +54 -0
  18. package/dist/replication/zongji/BinLogListener.js +192 -0
  19. package/dist/replication/zongji/BinLogListener.js.map +1 -0
  20. package/dist/replication/zongji/zongji-utils.d.ts +5 -4
  21. package/dist/replication/zongji/zongji-utils.js +3 -0
  22. package/dist/replication/zongji/zongji-utils.js.map +1 -1
  23. package/dist/types/types.d.ts +2 -0
  24. package/dist/types/types.js +5 -1
  25. package/dist/types/types.js.map +1 -1
  26. package/dist/utils/mysql-utils.js +1 -0
  27. package/dist/utils/mysql-utils.js.map +1 -1
  28. package/package.json +10 -10
  29. package/src/api/MySQLRouteAPIAdapter.ts +1 -1
  30. package/src/replication/BinLogReplicationJob.ts +11 -3
  31. package/src/replication/BinLogReplicator.ts +25 -0
  32. package/src/replication/BinLogStream.ts +151 -201
  33. package/src/replication/MySQLConnectionManager.ts +2 -1
  34. package/src/replication/zongji/BinLogListener.ts +243 -0
  35. package/src/replication/zongji/zongji-utils.ts +10 -5
  36. package/src/types/types.ts +8 -1
  37. package/src/utils/mysql-utils.ts +1 -0
  38. package/test/src/BinLogListener.test.ts +161 -0
  39. package/test/src/BinLogStream.test.ts +4 -9
  40. package/test/src/mysql-to-sqlite.test.ts +1 -1
  41. package/test/src/util.ts +12 -0
  42. package/test/tsconfig.json +1 -1
  43. package/tsconfig.tsbuildinfo +1 -1
  44. package/src/replication/zongji/zongji.d.ts +0 -129
@@ -1,129 +0,0 @@
1
- declare module '@powersync/mysql-zongji' {
2
- import { Socket } from 'net';
3
-
4
- export type ZongjiOptions = {
5
- host: string;
6
- user: string;
7
- password: string;
8
- dateStrings?: boolean;
9
- timeZone?: string;
10
- };
11
-
12
- interface DatabaseFilter {
13
- [databaseName: string]: string[] | true;
14
- }
15
-
16
- export type StartOptions = {
17
- includeEvents?: string[];
18
- excludeEvents?: string[];
19
- /**
20
- * Describe which databases and tables to include (Only for row events). Use database names as the key and pass an array of table names or true (for the entire database).
21
- * Example: { 'my_database': ['allow_table', 'another_table'], 'another_db': true }
22
- */
23
- includeSchema?: DatabaseFilter;
24
- /**
25
- * Object describing which databases and tables to exclude (Same format as includeSchema)
26
- * Example: { 'other_db': ['disallowed_table'], 'ex_db': true }
27
- */
28
- excludeSchema?: DatabaseFilter;
29
- /**
30
- * BinLog position filename to start reading events from
31
- */
32
- filename?: string;
33
- /**
34
- * BinLog position offset to start reading events from in file specified
35
- */
36
- position?: number;
37
-
38
- /**
39
- * Unique server ID for this replication client.
40
- */
41
- serverId?: number;
42
- };
43
-
44
- export type ColumnSchema = {
45
- COLUMN_NAME: string;
46
- COLLATION_NAME: string;
47
- CHARACTER_SET_NAME: string;
48
- COLUMN_COMMENT: string;
49
- COLUMN_TYPE: string;
50
- };
51
-
52
- export type ColumnDefinition = {
53
- name: string;
54
- charset: string;
55
- type: number;
56
- metadata: Record<string, any>;
57
- };
58
-
59
- export type TableMapEntry = {
60
- columnSchemas: ColumnSchema[];
61
- parentSchema: string;
62
- tableName: string;
63
- columns: ColumnDefinition[];
64
- };
65
-
66
- export type BaseBinLogEvent = {
67
- timestamp: number;
68
- getEventName(): string;
69
-
70
- /**
71
- * Next position in BinLog file to read from after
72
- * this event.
73
- */
74
- nextPosition: number;
75
- /**
76
- * Size of this event
77
- */
78
- size: number;
79
- flags: number;
80
- useChecksum: boolean;
81
- };
82
-
83
- export type BinLogRotationEvent = BaseBinLogEvent & {
84
- binlogName: string;
85
- position: number;
86
- };
87
-
88
- export type BinLogGTIDLogEvent = BaseBinLogEvent & {
89
- serverId: Buffer;
90
- transactionRange: number;
91
- };
92
-
93
- export type BinLogXidEvent = BaseBinLogEvent & {
94
- xid: number;
95
- };
96
-
97
- export type BinLogMutationEvent = BaseBinLogEvent & {
98
- tableId: number;
99
- numberOfColumns: number;
100
- tableMap: Record<string, TableMapEntry>;
101
- rows: Record<string, any>[];
102
- };
103
-
104
- export type BinLogUpdateEvent = Omit<BinLogMutationEvent, 'rows'> & {
105
- rows: {
106
- before: Record<string, any>;
107
- after: Record<string, any>;
108
- }[];
109
- };
110
-
111
- export type BinLogEvent = BinLogRotationEvent | BinLogGTIDLogEvent | BinLogXidEvent | BinLogMutationEvent;
112
-
113
- // @vlasky/mysql Connection
114
- export interface MySQLConnection {
115
- _socket?: Socket;
116
- /** There are other forms of this method as well - this is the most basic one. */
117
- query(sql: string, callback: (error: any, results: any, fields: any) => void): void;
118
- }
119
-
120
- export default class ZongJi {
121
- connection: MySQLConnection;
122
- constructor(options: ZongjiOptions);
123
-
124
- start(options: StartOptions): void;
125
- stop(): void;
126
-
127
- on(type: 'binlog' | string, callback: (event: BinLogEvent) => void);
128
- }
129
- }