@delali/sirannon-db 0.3.4-next.62 → 0.3.4

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 (108) hide show
  1. package/README.md +79 -56
  2. package/dist/backup/index.d.ts +44 -45
  3. package/dist/backup/index.mjs +7 -7
  4. package/dist/backup-scheduler/index.d.ts +42 -41
  5. package/dist/backup-scheduler/index.mjs +4 -4
  6. package/dist/baseline-Co3iIsN_.d.ts +19 -0
  7. package/dist/change-tracker-DqCdeEyx.d.ts +128 -0
  8. package/dist/{chunk-VOSJBZ6Q.mjs → chunk-2ES3DT4A.mjs} +71 -33
  9. package/dist/{chunk-6CMCO7S4.mjs → chunk-2O3PP4CF.mjs} +1 -1
  10. package/dist/{chunk-E7Q7HE46.mjs → chunk-3BZLZ47R.mjs} +26 -26
  11. package/dist/chunk-4KASJKKK.mjs +2501 -0
  12. package/dist/{chunk-MYNI2WFS.mjs → chunk-52XW3Z76.mjs} +40 -8
  13. package/dist/chunk-55YRLSM2.mjs +57 -0
  14. package/dist/{chunk-KDAHYFW7.mjs → chunk-6AOJCNRU.mjs} +5 -5
  15. package/dist/{chunk-KXTYR2OQ.mjs → chunk-A3PHCO6W.mjs} +39 -111
  16. package/dist/chunk-ADNWEHGZ.mjs +299 -0
  17. package/dist/{chunk-2QLXDHAP.mjs → chunk-BLMRNSUG.mjs} +11 -2
  18. package/dist/chunk-BVMZJOVM.mjs +5 -0
  19. package/dist/{chunk-IWGIYDMZ.mjs → chunk-BZWDPF4G.mjs} +1 -1
  20. package/dist/{chunk-YVF2ZJTE.mjs → chunk-CZL4D3BM.mjs} +1 -1
  21. package/dist/{chunk-7SC2TZAS.mjs → chunk-DX4WGJL7.mjs} +2 -2
  22. package/dist/{chunk-45MKELYA.mjs → chunk-ESTZZPT5.mjs} +132 -13
  23. package/dist/{chunk-QP5L5DFJ.mjs → chunk-FJPR2CJX.mjs} +3 -3
  24. package/dist/chunk-HR7K3GZW.mjs +36 -0
  25. package/dist/{chunk-LXCGPZPA.mjs → chunk-IEKIYO4V.mjs} +1 -1
  26. package/dist/{chunk-TUD5CJ76.mjs → chunk-KB4OLJAD.mjs} +26 -19
  27. package/dist/{chunk-PBRXXISQ.mjs → chunk-KINDFBQP.mjs} +3 -2
  28. package/dist/{chunk-E6IMX7RS.mjs → chunk-KJLNYOOL.mjs} +2 -2
  29. package/dist/{chunk-BTTFW4Z4.mjs → chunk-KU32OT4H.mjs} +2 -10
  30. package/dist/{chunk-JQWGHSEH.mjs → chunk-NVSQ2T5Q.mjs} +71 -70
  31. package/dist/{chunk-W4EUTJNT.mjs → chunk-NZGSDALX.mjs} +94 -96
  32. package/dist/{chunk-U445A3C4.mjs → chunk-QGVRRKB2.mjs} +1 -1
  33. package/dist/{chunk-GYCEJNU4.mjs → chunk-R7GBXNTO.mjs} +1 -1
  34. package/dist/{chunk-7C36BCSN.mjs → chunk-VDN6FHU4.mjs} +1 -1
  35. package/dist/{chunk-6IYS4WLH.mjs → chunk-VO3ZWA2G.mjs} +142 -115
  36. package/dist/chunk-WOMADPM4.mjs +12 -0
  37. package/dist/{chunk-OUSWVNWT.mjs → chunk-YCMB6GR4.mjs} +1 -1
  38. package/dist/{chunk-YNTDOFTN.mjs → chunk-YW7IKQ7T.mjs} +1 -1
  39. package/dist/{chunk-M2BEAH5I.mjs → chunk-ZN4HI5FK.mjs} +126 -72
  40. package/dist/{chunk-SBL6GN43.mjs → chunk-ZYWI45EN.mjs} +1 -1
  41. package/dist/client/index.d.ts +135 -137
  42. package/dist/client/index.mjs +177 -82
  43. package/dist/client/topology.d.ts +31 -31
  44. package/dist/client/topology.mjs +42 -23
  45. package/dist/client-base-BxTocU1x.d.ts +398 -0
  46. package/dist/client-streams-YKANXMWO.mjs +112 -0
  47. package/dist/codegen/cli.mjs +4 -4
  48. package/dist/codegen/index.d.ts +36 -29
  49. package/dist/codegen/index.mjs +4 -4
  50. package/dist/core/index.d.ts +130 -115
  51. package/dist/core/index.mjs +387 -297
  52. package/dist/core/writer-worker.mjs +3 -3
  53. package/dist/database-CGDsXW1K.d.ts +959 -0
  54. package/dist/database-backup-DcLhxoa1.d.ts +143 -0
  55. package/dist/driver/better-sqlite3.d.ts +11 -10
  56. package/dist/driver/better-sqlite3.mjs +11 -11
  57. package/dist/driver/bun.d.ts +9 -8
  58. package/dist/driver/expo.d.ts +6 -7
  59. package/dist/driver/node.d.ts +11 -10
  60. package/dist/driver/node.mjs +13 -11
  61. package/dist/driver/wa-sqlite.d.ts +6 -6
  62. package/dist/errors-CJUkQ-KL.d.ts +199 -0
  63. package/dist/file-migrations/index.d.ts +20 -18
  64. package/dist/file-migrations/index.mjs +3 -3
  65. package/dist/forward-rpc-VRWFZXHN.mjs +44 -0
  66. package/dist/operation-registry-CGhNT-Sn.d.ts +96 -0
  67. package/dist/primary-wins-CHNOYuN7.d.ts +81 -0
  68. package/dist/protocol-DFpNNsIT.d.ts +153 -0
  69. package/dist/query-types-5B02ixH0.d.ts +129 -0
  70. package/dist/react/index.d.ts +22 -22
  71. package/dist/replication/coordinator/etcd.d.ts +37 -31
  72. package/dist/replication/coordinator/etcd.mjs +296 -131
  73. package/dist/replication/index.d.ts +201 -161
  74. package/dist/replication/index.mjs +630 -529
  75. package/dist/restore-options-CH8mE-Tb.d.ts +84 -0
  76. package/dist/server/index.d.ts +201 -191
  77. package/dist/server/index.mjs +736 -619
  78. package/dist/server-options-aYtCkefX.d.ts +317 -0
  79. package/dist/server-streams-24XL4T43.mjs +254 -0
  80. package/dist/sirannon-J3EgPVD7.d.ts +179 -0
  81. package/dist/transport/grpc.d.ts +37 -24
  82. package/dist/transport/grpc.mjs +83 -3199
  83. package/dist/transport/memory.d.ts +25 -26
  84. package/dist/transport/memory.mjs +18 -9
  85. package/dist/types-BrAiDGOb.d.ts +505 -0
  86. package/dist/types-CEJG0eFS.d.ts +88 -0
  87. package/dist/types-Dc8oWlxj.d.ts +1580 -0
  88. package/dist/types-DqODKeOq.d.ts +123 -0
  89. package/dist/types-guEKSzMr.d.ts +367 -0
  90. package/package.json +7 -7
  91. package/dist/baseline-D93hcIEE.d.ts +0 -17
  92. package/dist/change-tracker-CjRFuZdB.d.ts +0 -144
  93. package/dist/client-base-Cmd9EVme.d.ts +0 -397
  94. package/dist/database-BLQvqjsw.d.ts +0 -917
  95. package/dist/database-backup-B7oszQ2n.d.ts +0 -141
  96. package/dist/errors-Dei4GdBb.d.ts +0 -196
  97. package/dist/operation-registry-oiPuSYI6.d.ts +0 -94
  98. package/dist/primary-wins-B0np8JS3.d.ts +0 -85
  99. package/dist/protocol-HI-nY8DD.d.ts +0 -152
  100. package/dist/query-types-p1liOP-b.d.ts +0 -127
  101. package/dist/restore-options-CksYsH1l.d.ts +0 -83
  102. package/dist/server-options-Bj5iJnjx.d.ts +0 -292
  103. package/dist/sirannon-BPxC5tC2.d.ts +0 -178
  104. package/dist/types-B0EhgDbr.d.ts +0 -340
  105. package/dist/types-CbjfRwrK.d.ts +0 -499
  106. package/dist/types-CjhxcjhA.d.ts +0 -123
  107. package/dist/types-DPSmjU54.d.ts +0 -1518
  108. package/dist/types-DTO4CYhW.d.ts +0 -88
@@ -0,0 +1,2501 @@
1
+ import { TransportError } from './chunk-KU32OT4H.mjs';
2
+ import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
3
+ import { makeGenericClientConstructor, ServerCredentials, credentials } from '@grpc/grpc-js';
4
+ import { readFileSync } from 'fs';
5
+
6
+ function createBaseColumnValue() {
7
+ return {
8
+ nullValue: void 0,
9
+ stringValue: void 0,
10
+ intValue: void 0,
11
+ floatValue: void 0,
12
+ blobValue: void 0,
13
+ boolValue: void 0
14
+ };
15
+ }
16
+ var ColumnValue = {
17
+ encode(message, writer = new BinaryWriter()) {
18
+ if (message.nullValue !== void 0) {
19
+ writer.uint32(8).bool(message.nullValue);
20
+ }
21
+ if (message.stringValue !== void 0) {
22
+ writer.uint32(18).string(message.stringValue);
23
+ }
24
+ if (message.intValue !== void 0) {
25
+ if (BigInt.asIntN(64, message.intValue) !== message.intValue) {
26
+ throw new globalThis.Error("value provided for field message.intValue of type int64 too large");
27
+ }
28
+ writer.uint32(24).int64(message.intValue);
29
+ }
30
+ if (message.floatValue !== void 0) {
31
+ writer.uint32(33).double(message.floatValue);
32
+ }
33
+ if (message.blobValue !== void 0) {
34
+ writer.uint32(42).bytes(message.blobValue);
35
+ }
36
+ if (message.boolValue !== void 0) {
37
+ writer.uint32(48).bool(message.boolValue);
38
+ }
39
+ return writer;
40
+ },
41
+ decode(input, length) {
42
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
43
+ const end = length === void 0 ? reader.len : reader.pos + length;
44
+ const message = createBaseColumnValue();
45
+ while (reader.pos < end) {
46
+ const tag = reader.uint32();
47
+ switch (tag >>> 3) {
48
+ case 1: {
49
+ if (tag !== 8) {
50
+ break;
51
+ }
52
+ message.nullValue = reader.bool();
53
+ continue;
54
+ }
55
+ case 2: {
56
+ if (tag !== 18) {
57
+ break;
58
+ }
59
+ message.stringValue = reader.string();
60
+ continue;
61
+ }
62
+ case 3: {
63
+ if (tag !== 24) {
64
+ break;
65
+ }
66
+ message.intValue = reader.int64();
67
+ continue;
68
+ }
69
+ case 4: {
70
+ if (tag !== 33) {
71
+ break;
72
+ }
73
+ message.floatValue = reader.double();
74
+ continue;
75
+ }
76
+ case 5: {
77
+ if (tag !== 42) {
78
+ break;
79
+ }
80
+ message.blobValue = Buffer.from(reader.bytes());
81
+ continue;
82
+ }
83
+ case 6: {
84
+ if (tag !== 48) {
85
+ break;
86
+ }
87
+ message.boolValue = reader.bool();
88
+ continue;
89
+ }
90
+ }
91
+ if ((tag & 7) === 4 || tag === 0) {
92
+ break;
93
+ }
94
+ reader.skip(tag & 7);
95
+ }
96
+ return message;
97
+ },
98
+ fromJSON(object) {
99
+ return {
100
+ nullValue: isSet(object.nullValue) ? globalThis.Boolean(object.nullValue) : isSet(object.null_value) ? globalThis.Boolean(object.null_value) : void 0,
101
+ stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : isSet(object.string_value) ? globalThis.String(object.string_value) : void 0,
102
+ intValue: isSet(object.intValue) ? BigInt(object.intValue) : isSet(object.int_value) ? BigInt(object.int_value) : void 0,
103
+ floatValue: isSet(object.floatValue) ? globalThis.Number(object.floatValue) : isSet(object.float_value) ? globalThis.Number(object.float_value) : void 0,
104
+ blobValue: isSet(object.blobValue) ? Buffer.from(bytesFromBase64(object.blobValue)) : isSet(object.blob_value) ? Buffer.from(bytesFromBase64(object.blob_value)) : void 0,
105
+ boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : isSet(object.bool_value) ? globalThis.Boolean(object.bool_value) : void 0
106
+ };
107
+ },
108
+ toJSON(message) {
109
+ const obj = {};
110
+ if (message.nullValue !== void 0) {
111
+ obj.nullValue = message.nullValue;
112
+ }
113
+ if (message.stringValue !== void 0) {
114
+ obj.stringValue = message.stringValue;
115
+ }
116
+ if (message.intValue !== void 0) {
117
+ obj.intValue = message.intValue.toString();
118
+ }
119
+ if (message.floatValue !== void 0) {
120
+ obj.floatValue = message.floatValue;
121
+ }
122
+ if (message.blobValue !== void 0) {
123
+ obj.blobValue = base64FromBytes(message.blobValue);
124
+ }
125
+ if (message.boolValue !== void 0) {
126
+ obj.boolValue = message.boolValue;
127
+ }
128
+ return obj;
129
+ },
130
+ create(base) {
131
+ return ColumnValue.fromPartial(base ?? {});
132
+ },
133
+ fromPartial(object) {
134
+ const message = createBaseColumnValue();
135
+ message.nullValue = object.nullValue ?? void 0;
136
+ message.stringValue = object.stringValue ?? void 0;
137
+ message.intValue = object.intValue ?? void 0;
138
+ message.floatValue = object.floatValue ?? void 0;
139
+ message.blobValue = object.blobValue ?? void 0;
140
+ message.boolValue = object.boolValue ?? void 0;
141
+ return message;
142
+ }
143
+ };
144
+ function createBaseRowData() {
145
+ return { fields: {} };
146
+ }
147
+ var RowData = {
148
+ encode(message, writer = new BinaryWriter()) {
149
+ globalThis.Object.entries(message.fields).forEach(([key, value]) => {
150
+ RowData_FieldsEntry.encode({ key, value }, writer.uint32(10).fork()).join();
151
+ });
152
+ return writer;
153
+ },
154
+ decode(input, length) {
155
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
156
+ const end = length === void 0 ? reader.len : reader.pos + length;
157
+ const message = createBaseRowData();
158
+ while (reader.pos < end) {
159
+ const tag = reader.uint32();
160
+ switch (tag >>> 3) {
161
+ case 1: {
162
+ if (tag !== 10) {
163
+ break;
164
+ }
165
+ const entry1 = RowData_FieldsEntry.decode(reader, reader.uint32());
166
+ if (entry1.value !== void 0) {
167
+ message.fields[entry1.key] = entry1.value;
168
+ }
169
+ continue;
170
+ }
171
+ }
172
+ if ((tag & 7) === 4 || tag === 0) {
173
+ break;
174
+ }
175
+ reader.skip(tag & 7);
176
+ }
177
+ return message;
178
+ },
179
+ fromJSON(object) {
180
+ return {
181
+ fields: isObject(object.fields) ? globalThis.Object.entries(object.fields).reduce(
182
+ (acc, [key, value]) => {
183
+ acc[key] = ColumnValue.fromJSON(value);
184
+ return acc;
185
+ },
186
+ {}
187
+ ) : {}
188
+ };
189
+ },
190
+ toJSON(message) {
191
+ const obj = {};
192
+ if (message.fields) {
193
+ const entries = globalThis.Object.entries(message.fields);
194
+ if (entries.length > 0) {
195
+ obj.fields = {};
196
+ entries.forEach(([k, v]) => {
197
+ obj.fields[k] = ColumnValue.toJSON(v);
198
+ });
199
+ }
200
+ }
201
+ return obj;
202
+ },
203
+ create(base) {
204
+ return RowData.fromPartial(base ?? {});
205
+ },
206
+ fromPartial(object) {
207
+ const message = createBaseRowData();
208
+ message.fields = globalThis.Object.entries(object.fields ?? {}).reduce(
209
+ (acc, [key, value]) => {
210
+ if (value !== void 0) {
211
+ acc[key] = ColumnValue.fromPartial(value);
212
+ }
213
+ return acc;
214
+ },
215
+ {}
216
+ );
217
+ return message;
218
+ }
219
+ };
220
+ function createBaseRowData_FieldsEntry() {
221
+ return { key: "", value: void 0 };
222
+ }
223
+ var RowData_FieldsEntry = {
224
+ encode(message, writer = new BinaryWriter()) {
225
+ if (message.key !== "") {
226
+ writer.uint32(10).string(message.key);
227
+ }
228
+ if (message.value !== void 0) {
229
+ ColumnValue.encode(message.value, writer.uint32(18).fork()).join();
230
+ }
231
+ return writer;
232
+ },
233
+ decode(input, length) {
234
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
235
+ const end = length === void 0 ? reader.len : reader.pos + length;
236
+ const message = createBaseRowData_FieldsEntry();
237
+ while (reader.pos < end) {
238
+ const tag = reader.uint32();
239
+ switch (tag >>> 3) {
240
+ case 1: {
241
+ if (tag !== 10) {
242
+ break;
243
+ }
244
+ message.key = reader.string();
245
+ continue;
246
+ }
247
+ case 2: {
248
+ if (tag !== 18) {
249
+ break;
250
+ }
251
+ message.value = ColumnValue.decode(reader, reader.uint32());
252
+ continue;
253
+ }
254
+ }
255
+ if ((tag & 7) === 4 || tag === 0) {
256
+ break;
257
+ }
258
+ reader.skip(tag & 7);
259
+ }
260
+ return message;
261
+ },
262
+ fromJSON(object) {
263
+ return {
264
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
265
+ value: isSet(object.value) ? ColumnValue.fromJSON(object.value) : void 0
266
+ };
267
+ },
268
+ toJSON(message) {
269
+ const obj = {};
270
+ if (message.key !== "") {
271
+ obj.key = message.key;
272
+ }
273
+ if (message.value !== void 0) {
274
+ obj.value = ColumnValue.toJSON(message.value);
275
+ }
276
+ return obj;
277
+ },
278
+ create(base) {
279
+ return RowData_FieldsEntry.fromPartial(base ?? {});
280
+ },
281
+ fromPartial(object) {
282
+ const message = createBaseRowData_FieldsEntry();
283
+ message.key = object.key ?? "";
284
+ message.value = object.value !== void 0 && object.value !== null ? ColumnValue.fromPartial(object.value) : void 0;
285
+ return message;
286
+ }
287
+ };
288
+ function createBaseHlcRange() {
289
+ return { min: "", max: "" };
290
+ }
291
+ var HlcRange = {
292
+ encode(message, writer = new BinaryWriter()) {
293
+ if (message.min !== "") {
294
+ writer.uint32(10).string(message.min);
295
+ }
296
+ if (message.max !== "") {
297
+ writer.uint32(18).string(message.max);
298
+ }
299
+ return writer;
300
+ },
301
+ decode(input, length) {
302
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
303
+ const end = length === void 0 ? reader.len : reader.pos + length;
304
+ const message = createBaseHlcRange();
305
+ while (reader.pos < end) {
306
+ const tag = reader.uint32();
307
+ switch (tag >>> 3) {
308
+ case 1: {
309
+ if (tag !== 10) {
310
+ break;
311
+ }
312
+ message.min = reader.string();
313
+ continue;
314
+ }
315
+ case 2: {
316
+ if (tag !== 18) {
317
+ break;
318
+ }
319
+ message.max = reader.string();
320
+ continue;
321
+ }
322
+ }
323
+ if ((tag & 7) === 4 || tag === 0) {
324
+ break;
325
+ }
326
+ reader.skip(tag & 7);
327
+ }
328
+ return message;
329
+ },
330
+ fromJSON(object) {
331
+ return {
332
+ min: isSet(object.min) ? globalThis.String(object.min) : "",
333
+ max: isSet(object.max) ? globalThis.String(object.max) : ""
334
+ };
335
+ },
336
+ toJSON(message) {
337
+ const obj = {};
338
+ if (message.min !== "") {
339
+ obj.min = message.min;
340
+ }
341
+ if (message.max !== "") {
342
+ obj.max = message.max;
343
+ }
344
+ return obj;
345
+ },
346
+ create(base) {
347
+ return HlcRange.fromPartial(base ?? {});
348
+ },
349
+ fromPartial(object) {
350
+ const message = createBaseHlcRange();
351
+ message.min = object.min ?? "";
352
+ message.max = object.max ?? "";
353
+ return message;
354
+ }
355
+ };
356
+ function createBaseReplicationChange() {
357
+ return {
358
+ table: "",
359
+ operation: "",
360
+ rowId: "",
361
+ primaryKey: void 0,
362
+ hlc: "",
363
+ txId: "",
364
+ nodeId: "",
365
+ newData: void 0,
366
+ oldData: void 0,
367
+ ddlStatement: ""
368
+ };
369
+ }
370
+ var ReplicationChange = {
371
+ encode(message, writer = new BinaryWriter()) {
372
+ if (message.table !== "") {
373
+ writer.uint32(10).string(message.table);
374
+ }
375
+ if (message.operation !== "") {
376
+ writer.uint32(18).string(message.operation);
377
+ }
378
+ if (message.rowId !== "") {
379
+ writer.uint32(26).string(message.rowId);
380
+ }
381
+ if (message.primaryKey !== void 0) {
382
+ RowData.encode(message.primaryKey, writer.uint32(34).fork()).join();
383
+ }
384
+ if (message.hlc !== "") {
385
+ writer.uint32(42).string(message.hlc);
386
+ }
387
+ if (message.txId !== "") {
388
+ writer.uint32(50).string(message.txId);
389
+ }
390
+ if (message.nodeId !== "") {
391
+ writer.uint32(58).string(message.nodeId);
392
+ }
393
+ if (message.newData !== void 0) {
394
+ RowData.encode(message.newData, writer.uint32(66).fork()).join();
395
+ }
396
+ if (message.oldData !== void 0) {
397
+ RowData.encode(message.oldData, writer.uint32(74).fork()).join();
398
+ }
399
+ if (message.ddlStatement !== "") {
400
+ writer.uint32(82).string(message.ddlStatement);
401
+ }
402
+ return writer;
403
+ },
404
+ decode(input, length) {
405
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
406
+ const end = length === void 0 ? reader.len : reader.pos + length;
407
+ const message = createBaseReplicationChange();
408
+ while (reader.pos < end) {
409
+ const tag = reader.uint32();
410
+ switch (tag >>> 3) {
411
+ case 1: {
412
+ if (tag !== 10) {
413
+ break;
414
+ }
415
+ message.table = reader.string();
416
+ continue;
417
+ }
418
+ case 2: {
419
+ if (tag !== 18) {
420
+ break;
421
+ }
422
+ message.operation = reader.string();
423
+ continue;
424
+ }
425
+ case 3: {
426
+ if (tag !== 26) {
427
+ break;
428
+ }
429
+ message.rowId = reader.string();
430
+ continue;
431
+ }
432
+ case 4: {
433
+ if (tag !== 34) {
434
+ break;
435
+ }
436
+ message.primaryKey = RowData.decode(reader, reader.uint32());
437
+ continue;
438
+ }
439
+ case 5: {
440
+ if (tag !== 42) {
441
+ break;
442
+ }
443
+ message.hlc = reader.string();
444
+ continue;
445
+ }
446
+ case 6: {
447
+ if (tag !== 50) {
448
+ break;
449
+ }
450
+ message.txId = reader.string();
451
+ continue;
452
+ }
453
+ case 7: {
454
+ if (tag !== 58) {
455
+ break;
456
+ }
457
+ message.nodeId = reader.string();
458
+ continue;
459
+ }
460
+ case 8: {
461
+ if (tag !== 66) {
462
+ break;
463
+ }
464
+ message.newData = RowData.decode(reader, reader.uint32());
465
+ continue;
466
+ }
467
+ case 9: {
468
+ if (tag !== 74) {
469
+ break;
470
+ }
471
+ message.oldData = RowData.decode(reader, reader.uint32());
472
+ continue;
473
+ }
474
+ case 10: {
475
+ if (tag !== 82) {
476
+ break;
477
+ }
478
+ message.ddlStatement = reader.string();
479
+ continue;
480
+ }
481
+ }
482
+ if ((tag & 7) === 4 || tag === 0) {
483
+ break;
484
+ }
485
+ reader.skip(tag & 7);
486
+ }
487
+ return message;
488
+ },
489
+ fromJSON(object) {
490
+ return {
491
+ table: isSet(object.table) ? globalThis.String(object.table) : "",
492
+ operation: isSet(object.operation) ? globalThis.String(object.operation) : "",
493
+ rowId: isSet(object.rowId) ? globalThis.String(object.rowId) : isSet(object.row_id) ? globalThis.String(object.row_id) : "",
494
+ primaryKey: isSet(object.primaryKey) ? RowData.fromJSON(object.primaryKey) : isSet(object.primary_key) ? RowData.fromJSON(object.primary_key) : void 0,
495
+ hlc: isSet(object.hlc) ? globalThis.String(object.hlc) : "",
496
+ txId: isSet(object.txId) ? globalThis.String(object.txId) : isSet(object.tx_id) ? globalThis.String(object.tx_id) : "",
497
+ nodeId: isSet(object.nodeId) ? globalThis.String(object.nodeId) : isSet(object.node_id) ? globalThis.String(object.node_id) : "",
498
+ newData: isSet(object.newData) ? RowData.fromJSON(object.newData) : isSet(object.new_data) ? RowData.fromJSON(object.new_data) : void 0,
499
+ oldData: isSet(object.oldData) ? RowData.fromJSON(object.oldData) : isSet(object.old_data) ? RowData.fromJSON(object.old_data) : void 0,
500
+ ddlStatement: isSet(object.ddlStatement) ? globalThis.String(object.ddlStatement) : isSet(object.ddl_statement) ? globalThis.String(object.ddl_statement) : ""
501
+ };
502
+ },
503
+ toJSON(message) {
504
+ const obj = {};
505
+ if (message.table !== "") {
506
+ obj.table = message.table;
507
+ }
508
+ if (message.operation !== "") {
509
+ obj.operation = message.operation;
510
+ }
511
+ if (message.rowId !== "") {
512
+ obj.rowId = message.rowId;
513
+ }
514
+ if (message.primaryKey !== void 0) {
515
+ obj.primaryKey = RowData.toJSON(message.primaryKey);
516
+ }
517
+ if (message.hlc !== "") {
518
+ obj.hlc = message.hlc;
519
+ }
520
+ if (message.txId !== "") {
521
+ obj.txId = message.txId;
522
+ }
523
+ if (message.nodeId !== "") {
524
+ obj.nodeId = message.nodeId;
525
+ }
526
+ if (message.newData !== void 0) {
527
+ obj.newData = RowData.toJSON(message.newData);
528
+ }
529
+ if (message.oldData !== void 0) {
530
+ obj.oldData = RowData.toJSON(message.oldData);
531
+ }
532
+ if (message.ddlStatement !== "") {
533
+ obj.ddlStatement = message.ddlStatement;
534
+ }
535
+ return obj;
536
+ },
537
+ create(base) {
538
+ return ReplicationChange.fromPartial(base ?? {});
539
+ },
540
+ fromPartial(object) {
541
+ const message = createBaseReplicationChange();
542
+ message.table = object.table ?? "";
543
+ message.operation = object.operation ?? "";
544
+ message.rowId = object.rowId ?? "";
545
+ message.primaryKey = object.primaryKey !== void 0 && object.primaryKey !== null ? RowData.fromPartial(object.primaryKey) : void 0;
546
+ message.hlc = object.hlc ?? "";
547
+ message.txId = object.txId ?? "";
548
+ message.nodeId = object.nodeId ?? "";
549
+ message.newData = object.newData !== void 0 && object.newData !== null ? RowData.fromPartial(object.newData) : void 0;
550
+ message.oldData = object.oldData !== void 0 && object.oldData !== null ? RowData.fromPartial(object.oldData) : void 0;
551
+ message.ddlStatement = object.ddlStatement ?? "";
552
+ return message;
553
+ }
554
+ };
555
+ function createBaseBatchPayload() {
556
+ return {
557
+ sourceNodeId: "",
558
+ batchId: "",
559
+ fromSeq: 0n,
560
+ toSeq: 0n,
561
+ hlcRange: void 0,
562
+ changes: [],
563
+ checksum: "",
564
+ groupId: "",
565
+ primaryTerm: 0n
566
+ };
567
+ }
568
+ var BatchPayload = {
569
+ encode(message, writer = new BinaryWriter()) {
570
+ if (message.sourceNodeId !== "") {
571
+ writer.uint32(10).string(message.sourceNodeId);
572
+ }
573
+ if (message.batchId !== "") {
574
+ writer.uint32(18).string(message.batchId);
575
+ }
576
+ if (message.fromSeq !== 0n) {
577
+ if (BigInt.asIntN(64, message.fromSeq) !== message.fromSeq) {
578
+ throw new globalThis.Error("value provided for field message.fromSeq of type int64 too large");
579
+ }
580
+ writer.uint32(24).int64(message.fromSeq);
581
+ }
582
+ if (message.toSeq !== 0n) {
583
+ if (BigInt.asIntN(64, message.toSeq) !== message.toSeq) {
584
+ throw new globalThis.Error("value provided for field message.toSeq of type int64 too large");
585
+ }
586
+ writer.uint32(32).int64(message.toSeq);
587
+ }
588
+ if (message.hlcRange !== void 0) {
589
+ HlcRange.encode(message.hlcRange, writer.uint32(42).fork()).join();
590
+ }
591
+ for (const v of message.changes) {
592
+ ReplicationChange.encode(v, writer.uint32(50).fork()).join();
593
+ }
594
+ if (message.checksum !== "") {
595
+ writer.uint32(58).string(message.checksum);
596
+ }
597
+ if (message.groupId !== "") {
598
+ writer.uint32(66).string(message.groupId);
599
+ }
600
+ if (message.primaryTerm !== 0n) {
601
+ if (BigInt.asIntN(64, message.primaryTerm) !== message.primaryTerm) {
602
+ throw new globalThis.Error("value provided for field message.primaryTerm of type int64 too large");
603
+ }
604
+ writer.uint32(72).int64(message.primaryTerm);
605
+ }
606
+ return writer;
607
+ },
608
+ decode(input, length) {
609
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
610
+ const end = length === void 0 ? reader.len : reader.pos + length;
611
+ const message = createBaseBatchPayload();
612
+ while (reader.pos < end) {
613
+ const tag = reader.uint32();
614
+ switch (tag >>> 3) {
615
+ case 1: {
616
+ if (tag !== 10) {
617
+ break;
618
+ }
619
+ message.sourceNodeId = reader.string();
620
+ continue;
621
+ }
622
+ case 2: {
623
+ if (tag !== 18) {
624
+ break;
625
+ }
626
+ message.batchId = reader.string();
627
+ continue;
628
+ }
629
+ case 3: {
630
+ if (tag !== 24) {
631
+ break;
632
+ }
633
+ message.fromSeq = reader.int64();
634
+ continue;
635
+ }
636
+ case 4: {
637
+ if (tag !== 32) {
638
+ break;
639
+ }
640
+ message.toSeq = reader.int64();
641
+ continue;
642
+ }
643
+ case 5: {
644
+ if (tag !== 42) {
645
+ break;
646
+ }
647
+ message.hlcRange = HlcRange.decode(reader, reader.uint32());
648
+ continue;
649
+ }
650
+ case 6: {
651
+ if (tag !== 50) {
652
+ break;
653
+ }
654
+ message.changes.push(ReplicationChange.decode(reader, reader.uint32()));
655
+ continue;
656
+ }
657
+ case 7: {
658
+ if (tag !== 58) {
659
+ break;
660
+ }
661
+ message.checksum = reader.string();
662
+ continue;
663
+ }
664
+ case 8: {
665
+ if (tag !== 66) {
666
+ break;
667
+ }
668
+ message.groupId = reader.string();
669
+ continue;
670
+ }
671
+ case 9: {
672
+ if (tag !== 72) {
673
+ break;
674
+ }
675
+ message.primaryTerm = reader.int64();
676
+ continue;
677
+ }
678
+ }
679
+ if ((tag & 7) === 4 || tag === 0) {
680
+ break;
681
+ }
682
+ reader.skip(tag & 7);
683
+ }
684
+ return message;
685
+ },
686
+ fromJSON(object) {
687
+ return {
688
+ sourceNodeId: isSet(object.sourceNodeId) ? globalThis.String(object.sourceNodeId) : isSet(object.source_node_id) ? globalThis.String(object.source_node_id) : "",
689
+ batchId: isSet(object.batchId) ? globalThis.String(object.batchId) : isSet(object.batch_id) ? globalThis.String(object.batch_id) : "",
690
+ fromSeq: isSet(object.fromSeq) ? BigInt(object.fromSeq) : isSet(object.from_seq) ? BigInt(object.from_seq) : 0n,
691
+ toSeq: isSet(object.toSeq) ? BigInt(object.toSeq) : isSet(object.to_seq) ? BigInt(object.to_seq) : 0n,
692
+ hlcRange: isSet(object.hlcRange) ? HlcRange.fromJSON(object.hlcRange) : isSet(object.hlc_range) ? HlcRange.fromJSON(object.hlc_range) : void 0,
693
+ changes: globalThis.Array.isArray(object?.changes) ? object.changes.map((e) => ReplicationChange.fromJSON(e)) : [],
694
+ checksum: isSet(object.checksum) ? globalThis.String(object.checksum) : "",
695
+ groupId: isSet(object.groupId) ? globalThis.String(object.groupId) : isSet(object.group_id) ? globalThis.String(object.group_id) : "",
696
+ primaryTerm: isSet(object.primaryTerm) ? BigInt(object.primaryTerm) : isSet(object.primary_term) ? BigInt(object.primary_term) : 0n
697
+ };
698
+ },
699
+ toJSON(message) {
700
+ const obj = {};
701
+ if (message.sourceNodeId !== "") {
702
+ obj.sourceNodeId = message.sourceNodeId;
703
+ }
704
+ if (message.batchId !== "") {
705
+ obj.batchId = message.batchId;
706
+ }
707
+ if (message.fromSeq !== 0n) {
708
+ obj.fromSeq = message.fromSeq.toString();
709
+ }
710
+ if (message.toSeq !== 0n) {
711
+ obj.toSeq = message.toSeq.toString();
712
+ }
713
+ if (message.hlcRange !== void 0) {
714
+ obj.hlcRange = HlcRange.toJSON(message.hlcRange);
715
+ }
716
+ if (message.changes?.length) {
717
+ obj.changes = message.changes.map((e) => ReplicationChange.toJSON(e));
718
+ }
719
+ if (message.checksum !== "") {
720
+ obj.checksum = message.checksum;
721
+ }
722
+ if (message.groupId !== "") {
723
+ obj.groupId = message.groupId;
724
+ }
725
+ if (message.primaryTerm !== 0n) {
726
+ obj.primaryTerm = message.primaryTerm.toString();
727
+ }
728
+ return obj;
729
+ },
730
+ create(base) {
731
+ return BatchPayload.fromPartial(base ?? {});
732
+ },
733
+ fromPartial(object) {
734
+ const message = createBaseBatchPayload();
735
+ message.sourceNodeId = object.sourceNodeId ?? "";
736
+ message.batchId = object.batchId ?? "";
737
+ message.fromSeq = object.fromSeq ?? 0n;
738
+ message.toSeq = object.toSeq ?? 0n;
739
+ message.hlcRange = object.hlcRange !== void 0 && object.hlcRange !== null ? HlcRange.fromPartial(object.hlcRange) : void 0;
740
+ message.changes = object.changes?.map((e) => ReplicationChange.fromPartial(e)) || [];
741
+ message.checksum = object.checksum ?? "";
742
+ message.groupId = object.groupId ?? "";
743
+ message.primaryTerm = object.primaryTerm ?? 0n;
744
+ return message;
745
+ }
746
+ };
747
+ function createBaseAckPayload() {
748
+ return { batchId: "", ackedSeq: 0n, nodeId: "", groupId: "", primaryTerm: 0n };
749
+ }
750
+ var AckPayload = {
751
+ encode(message, writer = new BinaryWriter()) {
752
+ if (message.batchId !== "") {
753
+ writer.uint32(10).string(message.batchId);
754
+ }
755
+ if (message.ackedSeq !== 0n) {
756
+ if (BigInt.asIntN(64, message.ackedSeq) !== message.ackedSeq) {
757
+ throw new globalThis.Error("value provided for field message.ackedSeq of type int64 too large");
758
+ }
759
+ writer.uint32(16).int64(message.ackedSeq);
760
+ }
761
+ if (message.nodeId !== "") {
762
+ writer.uint32(26).string(message.nodeId);
763
+ }
764
+ if (message.groupId !== "") {
765
+ writer.uint32(34).string(message.groupId);
766
+ }
767
+ if (message.primaryTerm !== 0n) {
768
+ if (BigInt.asIntN(64, message.primaryTerm) !== message.primaryTerm) {
769
+ throw new globalThis.Error("value provided for field message.primaryTerm of type int64 too large");
770
+ }
771
+ writer.uint32(40).int64(message.primaryTerm);
772
+ }
773
+ return writer;
774
+ },
775
+ decode(input, length) {
776
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
777
+ const end = length === void 0 ? reader.len : reader.pos + length;
778
+ const message = createBaseAckPayload();
779
+ while (reader.pos < end) {
780
+ const tag = reader.uint32();
781
+ switch (tag >>> 3) {
782
+ case 1: {
783
+ if (tag !== 10) {
784
+ break;
785
+ }
786
+ message.batchId = reader.string();
787
+ continue;
788
+ }
789
+ case 2: {
790
+ if (tag !== 16) {
791
+ break;
792
+ }
793
+ message.ackedSeq = reader.int64();
794
+ continue;
795
+ }
796
+ case 3: {
797
+ if (tag !== 26) {
798
+ break;
799
+ }
800
+ message.nodeId = reader.string();
801
+ continue;
802
+ }
803
+ case 4: {
804
+ if (tag !== 34) {
805
+ break;
806
+ }
807
+ message.groupId = reader.string();
808
+ continue;
809
+ }
810
+ case 5: {
811
+ if (tag !== 40) {
812
+ break;
813
+ }
814
+ message.primaryTerm = reader.int64();
815
+ continue;
816
+ }
817
+ }
818
+ if ((tag & 7) === 4 || tag === 0) {
819
+ break;
820
+ }
821
+ reader.skip(tag & 7);
822
+ }
823
+ return message;
824
+ },
825
+ fromJSON(object) {
826
+ return {
827
+ batchId: isSet(object.batchId) ? globalThis.String(object.batchId) : isSet(object.batch_id) ? globalThis.String(object.batch_id) : "",
828
+ ackedSeq: isSet(object.ackedSeq) ? BigInt(object.ackedSeq) : isSet(object.acked_seq) ? BigInt(object.acked_seq) : 0n,
829
+ nodeId: isSet(object.nodeId) ? globalThis.String(object.nodeId) : isSet(object.node_id) ? globalThis.String(object.node_id) : "",
830
+ groupId: isSet(object.groupId) ? globalThis.String(object.groupId) : isSet(object.group_id) ? globalThis.String(object.group_id) : "",
831
+ primaryTerm: isSet(object.primaryTerm) ? BigInt(object.primaryTerm) : isSet(object.primary_term) ? BigInt(object.primary_term) : 0n
832
+ };
833
+ },
834
+ toJSON(message) {
835
+ const obj = {};
836
+ if (message.batchId !== "") {
837
+ obj.batchId = message.batchId;
838
+ }
839
+ if (message.ackedSeq !== 0n) {
840
+ obj.ackedSeq = message.ackedSeq.toString();
841
+ }
842
+ if (message.nodeId !== "") {
843
+ obj.nodeId = message.nodeId;
844
+ }
845
+ if (message.groupId !== "") {
846
+ obj.groupId = message.groupId;
847
+ }
848
+ if (message.primaryTerm !== 0n) {
849
+ obj.primaryTerm = message.primaryTerm.toString();
850
+ }
851
+ return obj;
852
+ },
853
+ create(base) {
854
+ return AckPayload.fromPartial(base ?? {});
855
+ },
856
+ fromPartial(object) {
857
+ const message = createBaseAckPayload();
858
+ message.batchId = object.batchId ?? "";
859
+ message.ackedSeq = object.ackedSeq ?? 0n;
860
+ message.nodeId = object.nodeId ?? "";
861
+ message.groupId = object.groupId ?? "";
862
+ message.primaryTerm = object.primaryTerm ?? 0n;
863
+ return message;
864
+ }
865
+ };
866
+ function createBaseHello() {
867
+ return { nodeId: "", role: "", groupId: "", primaryTerm: 0n, protocolVersion: "" };
868
+ }
869
+ var Hello = {
870
+ encode(message, writer = new BinaryWriter()) {
871
+ if (message.nodeId !== "") {
872
+ writer.uint32(10).string(message.nodeId);
873
+ }
874
+ if (message.role !== "") {
875
+ writer.uint32(18).string(message.role);
876
+ }
877
+ if (message.groupId !== "") {
878
+ writer.uint32(26).string(message.groupId);
879
+ }
880
+ if (message.primaryTerm !== 0n) {
881
+ if (BigInt.asIntN(64, message.primaryTerm) !== message.primaryTerm) {
882
+ throw new globalThis.Error("value provided for field message.primaryTerm of type int64 too large");
883
+ }
884
+ writer.uint32(32).int64(message.primaryTerm);
885
+ }
886
+ if (message.protocolVersion !== "") {
887
+ writer.uint32(42).string(message.protocolVersion);
888
+ }
889
+ return writer;
890
+ },
891
+ decode(input, length) {
892
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
893
+ const end = length === void 0 ? reader.len : reader.pos + length;
894
+ const message = createBaseHello();
895
+ while (reader.pos < end) {
896
+ const tag = reader.uint32();
897
+ switch (tag >>> 3) {
898
+ case 1: {
899
+ if (tag !== 10) {
900
+ break;
901
+ }
902
+ message.nodeId = reader.string();
903
+ continue;
904
+ }
905
+ case 2: {
906
+ if (tag !== 18) {
907
+ break;
908
+ }
909
+ message.role = reader.string();
910
+ continue;
911
+ }
912
+ case 3: {
913
+ if (tag !== 26) {
914
+ break;
915
+ }
916
+ message.groupId = reader.string();
917
+ continue;
918
+ }
919
+ case 4: {
920
+ if (tag !== 32) {
921
+ break;
922
+ }
923
+ message.primaryTerm = reader.int64();
924
+ continue;
925
+ }
926
+ case 5: {
927
+ if (tag !== 42) {
928
+ break;
929
+ }
930
+ message.protocolVersion = reader.string();
931
+ continue;
932
+ }
933
+ }
934
+ if ((tag & 7) === 4 || tag === 0) {
935
+ break;
936
+ }
937
+ reader.skip(tag & 7);
938
+ }
939
+ return message;
940
+ },
941
+ fromJSON(object) {
942
+ return {
943
+ nodeId: isSet(object.nodeId) ? globalThis.String(object.nodeId) : isSet(object.node_id) ? globalThis.String(object.node_id) : "",
944
+ role: isSet(object.role) ? globalThis.String(object.role) : "",
945
+ groupId: isSet(object.groupId) ? globalThis.String(object.groupId) : isSet(object.group_id) ? globalThis.String(object.group_id) : "",
946
+ primaryTerm: isSet(object.primaryTerm) ? BigInt(object.primaryTerm) : isSet(object.primary_term) ? BigInt(object.primary_term) : 0n,
947
+ protocolVersion: isSet(object.protocolVersion) ? globalThis.String(object.protocolVersion) : isSet(object.protocol_version) ? globalThis.String(object.protocol_version) : ""
948
+ };
949
+ },
950
+ toJSON(message) {
951
+ const obj = {};
952
+ if (message.nodeId !== "") {
953
+ obj.nodeId = message.nodeId;
954
+ }
955
+ if (message.role !== "") {
956
+ obj.role = message.role;
957
+ }
958
+ if (message.groupId !== "") {
959
+ obj.groupId = message.groupId;
960
+ }
961
+ if (message.primaryTerm !== 0n) {
962
+ obj.primaryTerm = message.primaryTerm.toString();
963
+ }
964
+ if (message.protocolVersion !== "") {
965
+ obj.protocolVersion = message.protocolVersion;
966
+ }
967
+ return obj;
968
+ },
969
+ create(base) {
970
+ return Hello.fromPartial(base ?? {});
971
+ },
972
+ fromPartial(object) {
973
+ const message = createBaseHello();
974
+ message.nodeId = object.nodeId ?? "";
975
+ message.role = object.role ?? "";
976
+ message.groupId = object.groupId ?? "";
977
+ message.primaryTerm = object.primaryTerm ?? 0n;
978
+ message.protocolVersion = object.protocolVersion ?? "";
979
+ return message;
980
+ }
981
+ };
982
+ function createBaseReplicationMessage() {
983
+ return { hello: void 0, batch: void 0, ack: void 0 };
984
+ }
985
+ var ReplicationMessage = {
986
+ encode(message, writer = new BinaryWriter()) {
987
+ if (message.hello !== void 0) {
988
+ Hello.encode(message.hello, writer.uint32(10).fork()).join();
989
+ }
990
+ if (message.batch !== void 0) {
991
+ BatchPayload.encode(message.batch, writer.uint32(18).fork()).join();
992
+ }
993
+ if (message.ack !== void 0) {
994
+ AckPayload.encode(message.ack, writer.uint32(26).fork()).join();
995
+ }
996
+ return writer;
997
+ },
998
+ decode(input, length) {
999
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1000
+ const end = length === void 0 ? reader.len : reader.pos + length;
1001
+ const message = createBaseReplicationMessage();
1002
+ while (reader.pos < end) {
1003
+ const tag = reader.uint32();
1004
+ switch (tag >>> 3) {
1005
+ case 1: {
1006
+ if (tag !== 10) {
1007
+ break;
1008
+ }
1009
+ message.hello = Hello.decode(reader, reader.uint32());
1010
+ continue;
1011
+ }
1012
+ case 2: {
1013
+ if (tag !== 18) {
1014
+ break;
1015
+ }
1016
+ message.batch = BatchPayload.decode(reader, reader.uint32());
1017
+ continue;
1018
+ }
1019
+ case 3: {
1020
+ if (tag !== 26) {
1021
+ break;
1022
+ }
1023
+ message.ack = AckPayload.decode(reader, reader.uint32());
1024
+ continue;
1025
+ }
1026
+ }
1027
+ if ((tag & 7) === 4 || tag === 0) {
1028
+ break;
1029
+ }
1030
+ reader.skip(tag & 7);
1031
+ }
1032
+ return message;
1033
+ },
1034
+ fromJSON(object) {
1035
+ return {
1036
+ hello: isSet(object.hello) ? Hello.fromJSON(object.hello) : void 0,
1037
+ batch: isSet(object.batch) ? BatchPayload.fromJSON(object.batch) : void 0,
1038
+ ack: isSet(object.ack) ? AckPayload.fromJSON(object.ack) : void 0
1039
+ };
1040
+ },
1041
+ toJSON(message) {
1042
+ const obj = {};
1043
+ if (message.hello !== void 0) {
1044
+ obj.hello = Hello.toJSON(message.hello);
1045
+ }
1046
+ if (message.batch !== void 0) {
1047
+ obj.batch = BatchPayload.toJSON(message.batch);
1048
+ }
1049
+ if (message.ack !== void 0) {
1050
+ obj.ack = AckPayload.toJSON(message.ack);
1051
+ }
1052
+ return obj;
1053
+ },
1054
+ create(base) {
1055
+ return ReplicationMessage.fromPartial(base ?? {});
1056
+ },
1057
+ fromPartial(object) {
1058
+ const message = createBaseReplicationMessage();
1059
+ message.hello = object.hello !== void 0 && object.hello !== null ? Hello.fromPartial(object.hello) : void 0;
1060
+ message.batch = object.batch !== void 0 && object.batch !== null ? BatchPayload.fromPartial(object.batch) : void 0;
1061
+ message.ack = object.ack !== void 0 && object.ack !== null ? AckPayload.fromPartial(object.ack) : void 0;
1062
+ return message;
1063
+ }
1064
+ };
1065
+ function createBaseSyncRequestPayload() {
1066
+ return {
1067
+ requestId: "",
1068
+ joinerNodeId: "",
1069
+ completedTables: [],
1070
+ groupId: "",
1071
+ primaryTerm: 0n,
1072
+ supportsStreamVerification: false
1073
+ };
1074
+ }
1075
+ var SyncRequestPayload = {
1076
+ encode(message, writer = new BinaryWriter()) {
1077
+ if (message.requestId !== "") {
1078
+ writer.uint32(10).string(message.requestId);
1079
+ }
1080
+ if (message.joinerNodeId !== "") {
1081
+ writer.uint32(18).string(message.joinerNodeId);
1082
+ }
1083
+ for (const v of message.completedTables) {
1084
+ writer.uint32(26).string(v);
1085
+ }
1086
+ if (message.groupId !== "") {
1087
+ writer.uint32(34).string(message.groupId);
1088
+ }
1089
+ if (message.primaryTerm !== 0n) {
1090
+ if (BigInt.asIntN(64, message.primaryTerm) !== message.primaryTerm) {
1091
+ throw new globalThis.Error("value provided for field message.primaryTerm of type int64 too large");
1092
+ }
1093
+ writer.uint32(40).int64(message.primaryTerm);
1094
+ }
1095
+ if (message.supportsStreamVerification !== false) {
1096
+ writer.uint32(48).bool(message.supportsStreamVerification);
1097
+ }
1098
+ return writer;
1099
+ },
1100
+ decode(input, length) {
1101
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1102
+ const end = length === void 0 ? reader.len : reader.pos + length;
1103
+ const message = createBaseSyncRequestPayload();
1104
+ while (reader.pos < end) {
1105
+ const tag = reader.uint32();
1106
+ switch (tag >>> 3) {
1107
+ case 1: {
1108
+ if (tag !== 10) {
1109
+ break;
1110
+ }
1111
+ message.requestId = reader.string();
1112
+ continue;
1113
+ }
1114
+ case 2: {
1115
+ if (tag !== 18) {
1116
+ break;
1117
+ }
1118
+ message.joinerNodeId = reader.string();
1119
+ continue;
1120
+ }
1121
+ case 3: {
1122
+ if (tag !== 26) {
1123
+ break;
1124
+ }
1125
+ message.completedTables.push(reader.string());
1126
+ continue;
1127
+ }
1128
+ case 4: {
1129
+ if (tag !== 34) {
1130
+ break;
1131
+ }
1132
+ message.groupId = reader.string();
1133
+ continue;
1134
+ }
1135
+ case 5: {
1136
+ if (tag !== 40) {
1137
+ break;
1138
+ }
1139
+ message.primaryTerm = reader.int64();
1140
+ continue;
1141
+ }
1142
+ case 6: {
1143
+ if (tag !== 48) {
1144
+ break;
1145
+ }
1146
+ message.supportsStreamVerification = reader.bool();
1147
+ continue;
1148
+ }
1149
+ }
1150
+ if ((tag & 7) === 4 || tag === 0) {
1151
+ break;
1152
+ }
1153
+ reader.skip(tag & 7);
1154
+ }
1155
+ return message;
1156
+ },
1157
+ fromJSON(object) {
1158
+ return {
1159
+ requestId: isSet(object.requestId) ? globalThis.String(object.requestId) : isSet(object.request_id) ? globalThis.String(object.request_id) : "",
1160
+ joinerNodeId: isSet(object.joinerNodeId) ? globalThis.String(object.joinerNodeId) : isSet(object.joiner_node_id) ? globalThis.String(object.joiner_node_id) : "",
1161
+ completedTables: globalThis.Array.isArray(object?.completedTables) ? object.completedTables.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.completed_tables) ? object.completed_tables.map((e) => globalThis.String(e)) : [],
1162
+ groupId: isSet(object.groupId) ? globalThis.String(object.groupId) : isSet(object.group_id) ? globalThis.String(object.group_id) : "",
1163
+ primaryTerm: isSet(object.primaryTerm) ? BigInt(object.primaryTerm) : isSet(object.primary_term) ? BigInt(object.primary_term) : 0n,
1164
+ supportsStreamVerification: isSet(object.supportsStreamVerification) ? globalThis.Boolean(object.supportsStreamVerification) : isSet(object.supports_stream_verification) ? globalThis.Boolean(object.supports_stream_verification) : false
1165
+ };
1166
+ },
1167
+ toJSON(message) {
1168
+ const obj = {};
1169
+ if (message.requestId !== "") {
1170
+ obj.requestId = message.requestId;
1171
+ }
1172
+ if (message.joinerNodeId !== "") {
1173
+ obj.joinerNodeId = message.joinerNodeId;
1174
+ }
1175
+ if (message.completedTables?.length) {
1176
+ obj.completedTables = message.completedTables;
1177
+ }
1178
+ if (message.groupId !== "") {
1179
+ obj.groupId = message.groupId;
1180
+ }
1181
+ if (message.primaryTerm !== 0n) {
1182
+ obj.primaryTerm = message.primaryTerm.toString();
1183
+ }
1184
+ if (message.supportsStreamVerification !== false) {
1185
+ obj.supportsStreamVerification = message.supportsStreamVerification;
1186
+ }
1187
+ return obj;
1188
+ },
1189
+ create(base) {
1190
+ return SyncRequestPayload.fromPartial(base ?? {});
1191
+ },
1192
+ fromPartial(object) {
1193
+ const message = createBaseSyncRequestPayload();
1194
+ message.requestId = object.requestId ?? "";
1195
+ message.joinerNodeId = object.joinerNodeId ?? "";
1196
+ message.completedTables = object.completedTables?.map((e) => e) || [];
1197
+ message.groupId = object.groupId ?? "";
1198
+ message.primaryTerm = object.primaryTerm ?? 0n;
1199
+ message.supportsStreamVerification = object.supportsStreamVerification ?? false;
1200
+ return message;
1201
+ }
1202
+ };
1203
+ function createBaseSyncBatchPayload() {
1204
+ return {
1205
+ requestId: "",
1206
+ table: "",
1207
+ batchIndex: 0,
1208
+ rows: [],
1209
+ schema: [],
1210
+ checksum: "",
1211
+ isLastBatchForTable: false,
1212
+ groupId: "",
1213
+ primaryTerm: 0n,
1214
+ totalTables: 0
1215
+ };
1216
+ }
1217
+ var SyncBatchPayload = {
1218
+ encode(message, writer = new BinaryWriter()) {
1219
+ if (message.requestId !== "") {
1220
+ writer.uint32(10).string(message.requestId);
1221
+ }
1222
+ if (message.table !== "") {
1223
+ writer.uint32(18).string(message.table);
1224
+ }
1225
+ if (message.batchIndex !== 0) {
1226
+ writer.uint32(24).int32(message.batchIndex);
1227
+ }
1228
+ for (const v of message.rows) {
1229
+ RowData.encode(v, writer.uint32(34).fork()).join();
1230
+ }
1231
+ for (const v of message.schema) {
1232
+ writer.uint32(42).string(v);
1233
+ }
1234
+ if (message.checksum !== "") {
1235
+ writer.uint32(50).string(message.checksum);
1236
+ }
1237
+ if (message.isLastBatchForTable !== false) {
1238
+ writer.uint32(56).bool(message.isLastBatchForTable);
1239
+ }
1240
+ if (message.groupId !== "") {
1241
+ writer.uint32(66).string(message.groupId);
1242
+ }
1243
+ if (message.primaryTerm !== 0n) {
1244
+ if (BigInt.asIntN(64, message.primaryTerm) !== message.primaryTerm) {
1245
+ throw new globalThis.Error("value provided for field message.primaryTerm of type int64 too large");
1246
+ }
1247
+ writer.uint32(72).int64(message.primaryTerm);
1248
+ }
1249
+ if (message.totalTables !== 0) {
1250
+ writer.uint32(80).int32(message.totalTables);
1251
+ }
1252
+ return writer;
1253
+ },
1254
+ decode(input, length) {
1255
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1256
+ const end = length === void 0 ? reader.len : reader.pos + length;
1257
+ const message = createBaseSyncBatchPayload();
1258
+ while (reader.pos < end) {
1259
+ const tag = reader.uint32();
1260
+ switch (tag >>> 3) {
1261
+ case 1: {
1262
+ if (tag !== 10) {
1263
+ break;
1264
+ }
1265
+ message.requestId = reader.string();
1266
+ continue;
1267
+ }
1268
+ case 2: {
1269
+ if (tag !== 18) {
1270
+ break;
1271
+ }
1272
+ message.table = reader.string();
1273
+ continue;
1274
+ }
1275
+ case 3: {
1276
+ if (tag !== 24) {
1277
+ break;
1278
+ }
1279
+ message.batchIndex = reader.int32();
1280
+ continue;
1281
+ }
1282
+ case 4: {
1283
+ if (tag !== 34) {
1284
+ break;
1285
+ }
1286
+ message.rows.push(RowData.decode(reader, reader.uint32()));
1287
+ continue;
1288
+ }
1289
+ case 5: {
1290
+ if (tag !== 42) {
1291
+ break;
1292
+ }
1293
+ message.schema.push(reader.string());
1294
+ continue;
1295
+ }
1296
+ case 6: {
1297
+ if (tag !== 50) {
1298
+ break;
1299
+ }
1300
+ message.checksum = reader.string();
1301
+ continue;
1302
+ }
1303
+ case 7: {
1304
+ if (tag !== 56) {
1305
+ break;
1306
+ }
1307
+ message.isLastBatchForTable = reader.bool();
1308
+ continue;
1309
+ }
1310
+ case 8: {
1311
+ if (tag !== 66) {
1312
+ break;
1313
+ }
1314
+ message.groupId = reader.string();
1315
+ continue;
1316
+ }
1317
+ case 9: {
1318
+ if (tag !== 72) {
1319
+ break;
1320
+ }
1321
+ message.primaryTerm = reader.int64();
1322
+ continue;
1323
+ }
1324
+ case 10: {
1325
+ if (tag !== 80) {
1326
+ break;
1327
+ }
1328
+ message.totalTables = reader.int32();
1329
+ continue;
1330
+ }
1331
+ }
1332
+ if ((tag & 7) === 4 || tag === 0) {
1333
+ break;
1334
+ }
1335
+ reader.skip(tag & 7);
1336
+ }
1337
+ return message;
1338
+ },
1339
+ fromJSON(object) {
1340
+ return {
1341
+ requestId: isSet(object.requestId) ? globalThis.String(object.requestId) : isSet(object.request_id) ? globalThis.String(object.request_id) : "",
1342
+ table: isSet(object.table) ? globalThis.String(object.table) : "",
1343
+ batchIndex: isSet(object.batchIndex) ? globalThis.Number(object.batchIndex) : isSet(object.batch_index) ? globalThis.Number(object.batch_index) : 0,
1344
+ rows: globalThis.Array.isArray(object?.rows) ? object.rows.map((e) => RowData.fromJSON(e)) : [],
1345
+ schema: globalThis.Array.isArray(object?.schema) ? object.schema.map((e) => globalThis.String(e)) : [],
1346
+ checksum: isSet(object.checksum) ? globalThis.String(object.checksum) : "",
1347
+ isLastBatchForTable: isSet(object.isLastBatchForTable) ? globalThis.Boolean(object.isLastBatchForTable) : isSet(object.is_last_batch_for_table) ? globalThis.Boolean(object.is_last_batch_for_table) : false,
1348
+ groupId: isSet(object.groupId) ? globalThis.String(object.groupId) : isSet(object.group_id) ? globalThis.String(object.group_id) : "",
1349
+ primaryTerm: isSet(object.primaryTerm) ? BigInt(object.primaryTerm) : isSet(object.primary_term) ? BigInt(object.primary_term) : 0n,
1350
+ totalTables: isSet(object.totalTables) ? globalThis.Number(object.totalTables) : isSet(object.total_tables) ? globalThis.Number(object.total_tables) : 0
1351
+ };
1352
+ },
1353
+ toJSON(message) {
1354
+ const obj = {};
1355
+ if (message.requestId !== "") {
1356
+ obj.requestId = message.requestId;
1357
+ }
1358
+ if (message.table !== "") {
1359
+ obj.table = message.table;
1360
+ }
1361
+ if (message.batchIndex !== 0) {
1362
+ obj.batchIndex = Math.round(message.batchIndex);
1363
+ }
1364
+ if (message.rows?.length) {
1365
+ obj.rows = message.rows.map((e) => RowData.toJSON(e));
1366
+ }
1367
+ if (message.schema?.length) {
1368
+ obj.schema = message.schema;
1369
+ }
1370
+ if (message.checksum !== "") {
1371
+ obj.checksum = message.checksum;
1372
+ }
1373
+ if (message.isLastBatchForTable !== false) {
1374
+ obj.isLastBatchForTable = message.isLastBatchForTable;
1375
+ }
1376
+ if (message.groupId !== "") {
1377
+ obj.groupId = message.groupId;
1378
+ }
1379
+ if (message.primaryTerm !== 0n) {
1380
+ obj.primaryTerm = message.primaryTerm.toString();
1381
+ }
1382
+ if (message.totalTables !== 0) {
1383
+ obj.totalTables = Math.round(message.totalTables);
1384
+ }
1385
+ return obj;
1386
+ },
1387
+ create(base) {
1388
+ return SyncBatchPayload.fromPartial(base ?? {});
1389
+ },
1390
+ fromPartial(object) {
1391
+ const message = createBaseSyncBatchPayload();
1392
+ message.requestId = object.requestId ?? "";
1393
+ message.table = object.table ?? "";
1394
+ message.batchIndex = object.batchIndex ?? 0;
1395
+ message.rows = object.rows?.map((e) => RowData.fromPartial(e)) || [];
1396
+ message.schema = object.schema?.map((e) => e) || [];
1397
+ message.checksum = object.checksum ?? "";
1398
+ message.isLastBatchForTable = object.isLastBatchForTable ?? false;
1399
+ message.groupId = object.groupId ?? "";
1400
+ message.primaryTerm = object.primaryTerm ?? 0n;
1401
+ message.totalTables = object.totalTables ?? 0;
1402
+ return message;
1403
+ }
1404
+ };
1405
+ function createBaseSyncCompletePayload() {
1406
+ return { requestId: "", snapshotSeq: 0n, manifests: [], groupId: "", primaryTerm: 0n };
1407
+ }
1408
+ var SyncCompletePayload = {
1409
+ encode(message, writer = new BinaryWriter()) {
1410
+ if (message.requestId !== "") {
1411
+ writer.uint32(10).string(message.requestId);
1412
+ }
1413
+ if (message.snapshotSeq !== 0n) {
1414
+ if (BigInt.asIntN(64, message.snapshotSeq) !== message.snapshotSeq) {
1415
+ throw new globalThis.Error("value provided for field message.snapshotSeq of type int64 too large");
1416
+ }
1417
+ writer.uint32(16).int64(message.snapshotSeq);
1418
+ }
1419
+ for (const v of message.manifests) {
1420
+ SyncTableManifest.encode(v, writer.uint32(26).fork()).join();
1421
+ }
1422
+ if (message.groupId !== "") {
1423
+ writer.uint32(34).string(message.groupId);
1424
+ }
1425
+ if (message.primaryTerm !== 0n) {
1426
+ if (BigInt.asIntN(64, message.primaryTerm) !== message.primaryTerm) {
1427
+ throw new globalThis.Error("value provided for field message.primaryTerm of type int64 too large");
1428
+ }
1429
+ writer.uint32(40).int64(message.primaryTerm);
1430
+ }
1431
+ return writer;
1432
+ },
1433
+ decode(input, length) {
1434
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1435
+ const end = length === void 0 ? reader.len : reader.pos + length;
1436
+ const message = createBaseSyncCompletePayload();
1437
+ while (reader.pos < end) {
1438
+ const tag = reader.uint32();
1439
+ switch (tag >>> 3) {
1440
+ case 1: {
1441
+ if (tag !== 10) {
1442
+ break;
1443
+ }
1444
+ message.requestId = reader.string();
1445
+ continue;
1446
+ }
1447
+ case 2: {
1448
+ if (tag !== 16) {
1449
+ break;
1450
+ }
1451
+ message.snapshotSeq = reader.int64();
1452
+ continue;
1453
+ }
1454
+ case 3: {
1455
+ if (tag !== 26) {
1456
+ break;
1457
+ }
1458
+ message.manifests.push(SyncTableManifest.decode(reader, reader.uint32()));
1459
+ continue;
1460
+ }
1461
+ case 4: {
1462
+ if (tag !== 34) {
1463
+ break;
1464
+ }
1465
+ message.groupId = reader.string();
1466
+ continue;
1467
+ }
1468
+ case 5: {
1469
+ if (tag !== 40) {
1470
+ break;
1471
+ }
1472
+ message.primaryTerm = reader.int64();
1473
+ continue;
1474
+ }
1475
+ }
1476
+ if ((tag & 7) === 4 || tag === 0) {
1477
+ break;
1478
+ }
1479
+ reader.skip(tag & 7);
1480
+ }
1481
+ return message;
1482
+ },
1483
+ fromJSON(object) {
1484
+ return {
1485
+ requestId: isSet(object.requestId) ? globalThis.String(object.requestId) : isSet(object.request_id) ? globalThis.String(object.request_id) : "",
1486
+ snapshotSeq: isSet(object.snapshotSeq) ? BigInt(object.snapshotSeq) : isSet(object.snapshot_seq) ? BigInt(object.snapshot_seq) : 0n,
1487
+ manifests: globalThis.Array.isArray(object?.manifests) ? object.manifests.map((e) => SyncTableManifest.fromJSON(e)) : [],
1488
+ groupId: isSet(object.groupId) ? globalThis.String(object.groupId) : isSet(object.group_id) ? globalThis.String(object.group_id) : "",
1489
+ primaryTerm: isSet(object.primaryTerm) ? BigInt(object.primaryTerm) : isSet(object.primary_term) ? BigInt(object.primary_term) : 0n
1490
+ };
1491
+ },
1492
+ toJSON(message) {
1493
+ const obj = {};
1494
+ if (message.requestId !== "") {
1495
+ obj.requestId = message.requestId;
1496
+ }
1497
+ if (message.snapshotSeq !== 0n) {
1498
+ obj.snapshotSeq = message.snapshotSeq.toString();
1499
+ }
1500
+ if (message.manifests?.length) {
1501
+ obj.manifests = message.manifests.map((e) => SyncTableManifest.toJSON(e));
1502
+ }
1503
+ if (message.groupId !== "") {
1504
+ obj.groupId = message.groupId;
1505
+ }
1506
+ if (message.primaryTerm !== 0n) {
1507
+ obj.primaryTerm = message.primaryTerm.toString();
1508
+ }
1509
+ return obj;
1510
+ },
1511
+ create(base) {
1512
+ return SyncCompletePayload.fromPartial(base ?? {});
1513
+ },
1514
+ fromPartial(object) {
1515
+ const message = createBaseSyncCompletePayload();
1516
+ message.requestId = object.requestId ?? "";
1517
+ message.snapshotSeq = object.snapshotSeq ?? 0n;
1518
+ message.manifests = object.manifests?.map((e) => SyncTableManifest.fromPartial(e)) || [];
1519
+ message.groupId = object.groupId ?? "";
1520
+ message.primaryTerm = object.primaryTerm ?? 0n;
1521
+ return message;
1522
+ }
1523
+ };
1524
+ function createBaseSyncTableManifest() {
1525
+ return { table: "", rowCount: 0, pkHash: "", batchDigest: "" };
1526
+ }
1527
+ var SyncTableManifest = {
1528
+ encode(message, writer = new BinaryWriter()) {
1529
+ if (message.table !== "") {
1530
+ writer.uint32(10).string(message.table);
1531
+ }
1532
+ if (message.rowCount !== 0) {
1533
+ writer.uint32(16).int32(message.rowCount);
1534
+ }
1535
+ if (message.pkHash !== "") {
1536
+ writer.uint32(26).string(message.pkHash);
1537
+ }
1538
+ if (message.batchDigest !== "") {
1539
+ writer.uint32(34).string(message.batchDigest);
1540
+ }
1541
+ return writer;
1542
+ },
1543
+ decode(input, length) {
1544
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1545
+ const end = length === void 0 ? reader.len : reader.pos + length;
1546
+ const message = createBaseSyncTableManifest();
1547
+ while (reader.pos < end) {
1548
+ const tag = reader.uint32();
1549
+ switch (tag >>> 3) {
1550
+ case 1: {
1551
+ if (tag !== 10) {
1552
+ break;
1553
+ }
1554
+ message.table = reader.string();
1555
+ continue;
1556
+ }
1557
+ case 2: {
1558
+ if (tag !== 16) {
1559
+ break;
1560
+ }
1561
+ message.rowCount = reader.int32();
1562
+ continue;
1563
+ }
1564
+ case 3: {
1565
+ if (tag !== 26) {
1566
+ break;
1567
+ }
1568
+ message.pkHash = reader.string();
1569
+ continue;
1570
+ }
1571
+ case 4: {
1572
+ if (tag !== 34) {
1573
+ break;
1574
+ }
1575
+ message.batchDigest = reader.string();
1576
+ continue;
1577
+ }
1578
+ }
1579
+ if ((tag & 7) === 4 || tag === 0) {
1580
+ break;
1581
+ }
1582
+ reader.skip(tag & 7);
1583
+ }
1584
+ return message;
1585
+ },
1586
+ fromJSON(object) {
1587
+ return {
1588
+ table: isSet(object.table) ? globalThis.String(object.table) : "",
1589
+ rowCount: isSet(object.rowCount) ? globalThis.Number(object.rowCount) : isSet(object.row_count) ? globalThis.Number(object.row_count) : 0,
1590
+ pkHash: isSet(object.pkHash) ? globalThis.String(object.pkHash) : isSet(object.pk_hash) ? globalThis.String(object.pk_hash) : "",
1591
+ batchDigest: isSet(object.batchDigest) ? globalThis.String(object.batchDigest) : isSet(object.batch_digest) ? globalThis.String(object.batch_digest) : ""
1592
+ };
1593
+ },
1594
+ toJSON(message) {
1595
+ const obj = {};
1596
+ if (message.table !== "") {
1597
+ obj.table = message.table;
1598
+ }
1599
+ if (message.rowCount !== 0) {
1600
+ obj.rowCount = Math.round(message.rowCount);
1601
+ }
1602
+ if (message.pkHash !== "") {
1603
+ obj.pkHash = message.pkHash;
1604
+ }
1605
+ if (message.batchDigest !== "") {
1606
+ obj.batchDigest = message.batchDigest;
1607
+ }
1608
+ return obj;
1609
+ },
1610
+ create(base) {
1611
+ return SyncTableManifest.fromPartial(base ?? {});
1612
+ },
1613
+ fromPartial(object) {
1614
+ const message = createBaseSyncTableManifest();
1615
+ message.table = object.table ?? "";
1616
+ message.rowCount = object.rowCount ?? 0;
1617
+ message.pkHash = object.pkHash ?? "";
1618
+ message.batchDigest = object.batchDigest ?? "";
1619
+ return message;
1620
+ }
1621
+ };
1622
+ function createBaseSyncAckPayload() {
1623
+ return {
1624
+ requestId: "",
1625
+ joinerNodeId: "",
1626
+ table: "",
1627
+ batchIndex: 0,
1628
+ success: false,
1629
+ error: "",
1630
+ groupId: "",
1631
+ primaryTerm: 0n
1632
+ };
1633
+ }
1634
+ var SyncAckPayload = {
1635
+ encode(message, writer = new BinaryWriter()) {
1636
+ if (message.requestId !== "") {
1637
+ writer.uint32(10).string(message.requestId);
1638
+ }
1639
+ if (message.joinerNodeId !== "") {
1640
+ writer.uint32(18).string(message.joinerNodeId);
1641
+ }
1642
+ if (message.table !== "") {
1643
+ writer.uint32(26).string(message.table);
1644
+ }
1645
+ if (message.batchIndex !== 0) {
1646
+ writer.uint32(32).int32(message.batchIndex);
1647
+ }
1648
+ if (message.success !== false) {
1649
+ writer.uint32(40).bool(message.success);
1650
+ }
1651
+ if (message.error !== "") {
1652
+ writer.uint32(50).string(message.error);
1653
+ }
1654
+ if (message.groupId !== "") {
1655
+ writer.uint32(58).string(message.groupId);
1656
+ }
1657
+ if (message.primaryTerm !== 0n) {
1658
+ if (BigInt.asIntN(64, message.primaryTerm) !== message.primaryTerm) {
1659
+ throw new globalThis.Error("value provided for field message.primaryTerm of type int64 too large");
1660
+ }
1661
+ writer.uint32(64).int64(message.primaryTerm);
1662
+ }
1663
+ return writer;
1664
+ },
1665
+ decode(input, length) {
1666
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1667
+ const end = length === void 0 ? reader.len : reader.pos + length;
1668
+ const message = createBaseSyncAckPayload();
1669
+ while (reader.pos < end) {
1670
+ const tag = reader.uint32();
1671
+ switch (tag >>> 3) {
1672
+ case 1: {
1673
+ if (tag !== 10) {
1674
+ break;
1675
+ }
1676
+ message.requestId = reader.string();
1677
+ continue;
1678
+ }
1679
+ case 2: {
1680
+ if (tag !== 18) {
1681
+ break;
1682
+ }
1683
+ message.joinerNodeId = reader.string();
1684
+ continue;
1685
+ }
1686
+ case 3: {
1687
+ if (tag !== 26) {
1688
+ break;
1689
+ }
1690
+ message.table = reader.string();
1691
+ continue;
1692
+ }
1693
+ case 4: {
1694
+ if (tag !== 32) {
1695
+ break;
1696
+ }
1697
+ message.batchIndex = reader.int32();
1698
+ continue;
1699
+ }
1700
+ case 5: {
1701
+ if (tag !== 40) {
1702
+ break;
1703
+ }
1704
+ message.success = reader.bool();
1705
+ continue;
1706
+ }
1707
+ case 6: {
1708
+ if (tag !== 50) {
1709
+ break;
1710
+ }
1711
+ message.error = reader.string();
1712
+ continue;
1713
+ }
1714
+ case 7: {
1715
+ if (tag !== 58) {
1716
+ break;
1717
+ }
1718
+ message.groupId = reader.string();
1719
+ continue;
1720
+ }
1721
+ case 8: {
1722
+ if (tag !== 64) {
1723
+ break;
1724
+ }
1725
+ message.primaryTerm = reader.int64();
1726
+ continue;
1727
+ }
1728
+ }
1729
+ if ((tag & 7) === 4 || tag === 0) {
1730
+ break;
1731
+ }
1732
+ reader.skip(tag & 7);
1733
+ }
1734
+ return message;
1735
+ },
1736
+ fromJSON(object) {
1737
+ return {
1738
+ requestId: isSet(object.requestId) ? globalThis.String(object.requestId) : isSet(object.request_id) ? globalThis.String(object.request_id) : "",
1739
+ joinerNodeId: isSet(object.joinerNodeId) ? globalThis.String(object.joinerNodeId) : isSet(object.joiner_node_id) ? globalThis.String(object.joiner_node_id) : "",
1740
+ table: isSet(object.table) ? globalThis.String(object.table) : "",
1741
+ batchIndex: isSet(object.batchIndex) ? globalThis.Number(object.batchIndex) : isSet(object.batch_index) ? globalThis.Number(object.batch_index) : 0,
1742
+ success: isSet(object.success) ? globalThis.Boolean(object.success) : false,
1743
+ error: isSet(object.error) ? globalThis.String(object.error) : "",
1744
+ groupId: isSet(object.groupId) ? globalThis.String(object.groupId) : isSet(object.group_id) ? globalThis.String(object.group_id) : "",
1745
+ primaryTerm: isSet(object.primaryTerm) ? BigInt(object.primaryTerm) : isSet(object.primary_term) ? BigInt(object.primary_term) : 0n
1746
+ };
1747
+ },
1748
+ toJSON(message) {
1749
+ const obj = {};
1750
+ if (message.requestId !== "") {
1751
+ obj.requestId = message.requestId;
1752
+ }
1753
+ if (message.joinerNodeId !== "") {
1754
+ obj.joinerNodeId = message.joinerNodeId;
1755
+ }
1756
+ if (message.table !== "") {
1757
+ obj.table = message.table;
1758
+ }
1759
+ if (message.batchIndex !== 0) {
1760
+ obj.batchIndex = Math.round(message.batchIndex);
1761
+ }
1762
+ if (message.success !== false) {
1763
+ obj.success = message.success;
1764
+ }
1765
+ if (message.error !== "") {
1766
+ obj.error = message.error;
1767
+ }
1768
+ if (message.groupId !== "") {
1769
+ obj.groupId = message.groupId;
1770
+ }
1771
+ if (message.primaryTerm !== 0n) {
1772
+ obj.primaryTerm = message.primaryTerm.toString();
1773
+ }
1774
+ return obj;
1775
+ },
1776
+ create(base) {
1777
+ return SyncAckPayload.fromPartial(base ?? {});
1778
+ },
1779
+ fromPartial(object) {
1780
+ const message = createBaseSyncAckPayload();
1781
+ message.requestId = object.requestId ?? "";
1782
+ message.joinerNodeId = object.joinerNodeId ?? "";
1783
+ message.table = object.table ?? "";
1784
+ message.batchIndex = object.batchIndex ?? 0;
1785
+ message.success = object.success ?? false;
1786
+ message.error = object.error ?? "";
1787
+ message.groupId = object.groupId ?? "";
1788
+ message.primaryTerm = object.primaryTerm ?? 0n;
1789
+ return message;
1790
+ }
1791
+ };
1792
+ function createBaseSyncMessage() {
1793
+ return {
1794
+ hello: void 0,
1795
+ syncRequest: void 0,
1796
+ syncBatch: void 0,
1797
+ syncComplete: void 0,
1798
+ syncAck: void 0
1799
+ };
1800
+ }
1801
+ var SyncMessage = {
1802
+ encode(message, writer = new BinaryWriter()) {
1803
+ if (message.hello !== void 0) {
1804
+ Hello.encode(message.hello, writer.uint32(10).fork()).join();
1805
+ }
1806
+ if (message.syncRequest !== void 0) {
1807
+ SyncRequestPayload.encode(message.syncRequest, writer.uint32(18).fork()).join();
1808
+ }
1809
+ if (message.syncBatch !== void 0) {
1810
+ SyncBatchPayload.encode(message.syncBatch, writer.uint32(26).fork()).join();
1811
+ }
1812
+ if (message.syncComplete !== void 0) {
1813
+ SyncCompletePayload.encode(message.syncComplete, writer.uint32(34).fork()).join();
1814
+ }
1815
+ if (message.syncAck !== void 0) {
1816
+ SyncAckPayload.encode(message.syncAck, writer.uint32(42).fork()).join();
1817
+ }
1818
+ return writer;
1819
+ },
1820
+ decode(input, length) {
1821
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1822
+ const end = length === void 0 ? reader.len : reader.pos + length;
1823
+ const message = createBaseSyncMessage();
1824
+ while (reader.pos < end) {
1825
+ const tag = reader.uint32();
1826
+ switch (tag >>> 3) {
1827
+ case 1: {
1828
+ if (tag !== 10) {
1829
+ break;
1830
+ }
1831
+ message.hello = Hello.decode(reader, reader.uint32());
1832
+ continue;
1833
+ }
1834
+ case 2: {
1835
+ if (tag !== 18) {
1836
+ break;
1837
+ }
1838
+ message.syncRequest = SyncRequestPayload.decode(reader, reader.uint32());
1839
+ continue;
1840
+ }
1841
+ case 3: {
1842
+ if (tag !== 26) {
1843
+ break;
1844
+ }
1845
+ message.syncBatch = SyncBatchPayload.decode(reader, reader.uint32());
1846
+ continue;
1847
+ }
1848
+ case 4: {
1849
+ if (tag !== 34) {
1850
+ break;
1851
+ }
1852
+ message.syncComplete = SyncCompletePayload.decode(reader, reader.uint32());
1853
+ continue;
1854
+ }
1855
+ case 5: {
1856
+ if (tag !== 42) {
1857
+ break;
1858
+ }
1859
+ message.syncAck = SyncAckPayload.decode(reader, reader.uint32());
1860
+ continue;
1861
+ }
1862
+ }
1863
+ if ((tag & 7) === 4 || tag === 0) {
1864
+ break;
1865
+ }
1866
+ reader.skip(tag & 7);
1867
+ }
1868
+ return message;
1869
+ },
1870
+ fromJSON(object) {
1871
+ return {
1872
+ hello: isSet(object.hello) ? Hello.fromJSON(object.hello) : void 0,
1873
+ syncRequest: isSet(object.syncRequest) ? SyncRequestPayload.fromJSON(object.syncRequest) : isSet(object.sync_request) ? SyncRequestPayload.fromJSON(object.sync_request) : void 0,
1874
+ syncBatch: isSet(object.syncBatch) ? SyncBatchPayload.fromJSON(object.syncBatch) : isSet(object.sync_batch) ? SyncBatchPayload.fromJSON(object.sync_batch) : void 0,
1875
+ syncComplete: isSet(object.syncComplete) ? SyncCompletePayload.fromJSON(object.syncComplete) : isSet(object.sync_complete) ? SyncCompletePayload.fromJSON(object.sync_complete) : void 0,
1876
+ syncAck: isSet(object.syncAck) ? SyncAckPayload.fromJSON(object.syncAck) : isSet(object.sync_ack) ? SyncAckPayload.fromJSON(object.sync_ack) : void 0
1877
+ };
1878
+ },
1879
+ toJSON(message) {
1880
+ const obj = {};
1881
+ if (message.hello !== void 0) {
1882
+ obj.hello = Hello.toJSON(message.hello);
1883
+ }
1884
+ if (message.syncRequest !== void 0) {
1885
+ obj.syncRequest = SyncRequestPayload.toJSON(message.syncRequest);
1886
+ }
1887
+ if (message.syncBatch !== void 0) {
1888
+ obj.syncBatch = SyncBatchPayload.toJSON(message.syncBatch);
1889
+ }
1890
+ if (message.syncComplete !== void 0) {
1891
+ obj.syncComplete = SyncCompletePayload.toJSON(message.syncComplete);
1892
+ }
1893
+ if (message.syncAck !== void 0) {
1894
+ obj.syncAck = SyncAckPayload.toJSON(message.syncAck);
1895
+ }
1896
+ return obj;
1897
+ },
1898
+ create(base) {
1899
+ return SyncMessage.fromPartial(base ?? {});
1900
+ },
1901
+ fromPartial(object) {
1902
+ const message = createBaseSyncMessage();
1903
+ message.hello = object.hello !== void 0 && object.hello !== null ? Hello.fromPartial(object.hello) : void 0;
1904
+ message.syncRequest = object.syncRequest !== void 0 && object.syncRequest !== null ? SyncRequestPayload.fromPartial(object.syncRequest) : void 0;
1905
+ message.syncBatch = object.syncBatch !== void 0 && object.syncBatch !== null ? SyncBatchPayload.fromPartial(object.syncBatch) : void 0;
1906
+ message.syncComplete = object.syncComplete !== void 0 && object.syncComplete !== null ? SyncCompletePayload.fromPartial(object.syncComplete) : void 0;
1907
+ message.syncAck = object.syncAck !== void 0 && object.syncAck !== null ? SyncAckPayload.fromPartial(object.syncAck) : void 0;
1908
+ return message;
1909
+ }
1910
+ };
1911
+ function createBaseStatement() {
1912
+ return { sql: "", namedParams: {}, positionalParams: [] };
1913
+ }
1914
+ var Statement = {
1915
+ encode(message, writer = new BinaryWriter()) {
1916
+ if (message.sql !== "") {
1917
+ writer.uint32(10).string(message.sql);
1918
+ }
1919
+ globalThis.Object.entries(message.namedParams).forEach(([key, value]) => {
1920
+ Statement_NamedParamsEntry.encode({ key, value }, writer.uint32(18).fork()).join();
1921
+ });
1922
+ for (const v of message.positionalParams) {
1923
+ ColumnValue.encode(v, writer.uint32(26).fork()).join();
1924
+ }
1925
+ return writer;
1926
+ },
1927
+ decode(input, length) {
1928
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1929
+ const end = length === void 0 ? reader.len : reader.pos + length;
1930
+ const message = createBaseStatement();
1931
+ while (reader.pos < end) {
1932
+ const tag = reader.uint32();
1933
+ switch (tag >>> 3) {
1934
+ case 1: {
1935
+ if (tag !== 10) {
1936
+ break;
1937
+ }
1938
+ message.sql = reader.string();
1939
+ continue;
1940
+ }
1941
+ case 2: {
1942
+ if (tag !== 18) {
1943
+ break;
1944
+ }
1945
+ const entry2 = Statement_NamedParamsEntry.decode(reader, reader.uint32());
1946
+ if (entry2.value !== void 0) {
1947
+ message.namedParams[entry2.key] = entry2.value;
1948
+ }
1949
+ continue;
1950
+ }
1951
+ case 3: {
1952
+ if (tag !== 26) {
1953
+ break;
1954
+ }
1955
+ message.positionalParams.push(ColumnValue.decode(reader, reader.uint32()));
1956
+ continue;
1957
+ }
1958
+ }
1959
+ if ((tag & 7) === 4 || tag === 0) {
1960
+ break;
1961
+ }
1962
+ reader.skip(tag & 7);
1963
+ }
1964
+ return message;
1965
+ },
1966
+ fromJSON(object) {
1967
+ return {
1968
+ sql: isSet(object.sql) ? globalThis.String(object.sql) : "",
1969
+ namedParams: isObject(object.namedParams) ? globalThis.Object.entries(object.namedParams).reduce(
1970
+ (acc, [key, value]) => {
1971
+ acc[key] = ColumnValue.fromJSON(value);
1972
+ return acc;
1973
+ },
1974
+ {}
1975
+ ) : isObject(object.named_params) ? globalThis.Object.entries(object.named_params).reduce(
1976
+ (acc, [key, value]) => {
1977
+ acc[key] = ColumnValue.fromJSON(value);
1978
+ return acc;
1979
+ },
1980
+ {}
1981
+ ) : {},
1982
+ positionalParams: globalThis.Array.isArray(object?.positionalParams) ? object.positionalParams.map((e) => ColumnValue.fromJSON(e)) : globalThis.Array.isArray(object?.positional_params) ? object.positional_params.map((e) => ColumnValue.fromJSON(e)) : []
1983
+ };
1984
+ },
1985
+ toJSON(message) {
1986
+ const obj = {};
1987
+ if (message.sql !== "") {
1988
+ obj.sql = message.sql;
1989
+ }
1990
+ if (message.namedParams) {
1991
+ const entries = globalThis.Object.entries(message.namedParams);
1992
+ if (entries.length > 0) {
1993
+ obj.namedParams = {};
1994
+ entries.forEach(([k, v]) => {
1995
+ obj.namedParams[k] = ColumnValue.toJSON(v);
1996
+ });
1997
+ }
1998
+ }
1999
+ if (message.positionalParams?.length) {
2000
+ obj.positionalParams = message.positionalParams.map((e) => ColumnValue.toJSON(e));
2001
+ }
2002
+ return obj;
2003
+ },
2004
+ create(base) {
2005
+ return Statement.fromPartial(base ?? {});
2006
+ },
2007
+ fromPartial(object) {
2008
+ const message = createBaseStatement();
2009
+ message.sql = object.sql ?? "";
2010
+ message.namedParams = globalThis.Object.entries(object.namedParams ?? {}).reduce(
2011
+ (acc, [key, value]) => {
2012
+ if (value !== void 0) {
2013
+ acc[key] = ColumnValue.fromPartial(value);
2014
+ }
2015
+ return acc;
2016
+ },
2017
+ {}
2018
+ );
2019
+ message.positionalParams = object.positionalParams?.map((e) => ColumnValue.fromPartial(e)) || [];
2020
+ return message;
2021
+ }
2022
+ };
2023
+ function createBaseStatement_NamedParamsEntry() {
2024
+ return { key: "", value: void 0 };
2025
+ }
2026
+ var Statement_NamedParamsEntry = {
2027
+ encode(message, writer = new BinaryWriter()) {
2028
+ if (message.key !== "") {
2029
+ writer.uint32(10).string(message.key);
2030
+ }
2031
+ if (message.value !== void 0) {
2032
+ ColumnValue.encode(message.value, writer.uint32(18).fork()).join();
2033
+ }
2034
+ return writer;
2035
+ },
2036
+ decode(input, length) {
2037
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2038
+ const end = length === void 0 ? reader.len : reader.pos + length;
2039
+ const message = createBaseStatement_NamedParamsEntry();
2040
+ while (reader.pos < end) {
2041
+ const tag = reader.uint32();
2042
+ switch (tag >>> 3) {
2043
+ case 1: {
2044
+ if (tag !== 10) {
2045
+ break;
2046
+ }
2047
+ message.key = reader.string();
2048
+ continue;
2049
+ }
2050
+ case 2: {
2051
+ if (tag !== 18) {
2052
+ break;
2053
+ }
2054
+ message.value = ColumnValue.decode(reader, reader.uint32());
2055
+ continue;
2056
+ }
2057
+ }
2058
+ if ((tag & 7) === 4 || tag === 0) {
2059
+ break;
2060
+ }
2061
+ reader.skip(tag & 7);
2062
+ }
2063
+ return message;
2064
+ },
2065
+ fromJSON(object) {
2066
+ return {
2067
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
2068
+ value: isSet(object.value) ? ColumnValue.fromJSON(object.value) : void 0
2069
+ };
2070
+ },
2071
+ toJSON(message) {
2072
+ const obj = {};
2073
+ if (message.key !== "") {
2074
+ obj.key = message.key;
2075
+ }
2076
+ if (message.value !== void 0) {
2077
+ obj.value = ColumnValue.toJSON(message.value);
2078
+ }
2079
+ return obj;
2080
+ },
2081
+ create(base) {
2082
+ return Statement_NamedParamsEntry.fromPartial(base ?? {});
2083
+ },
2084
+ fromPartial(object) {
2085
+ const message = createBaseStatement_NamedParamsEntry();
2086
+ message.key = object.key ?? "";
2087
+ message.value = object.value !== void 0 && object.value !== null ? ColumnValue.fromPartial(object.value) : void 0;
2088
+ return message;
2089
+ }
2090
+ };
2091
+ function createBaseForwardRequest() {
2092
+ return {
2093
+ requestId: "",
2094
+ statements: [],
2095
+ groupId: "",
2096
+ primaryTerm: 0n,
2097
+ writeConcernLevel: "",
2098
+ writeConcernTimeoutMs: 0
2099
+ };
2100
+ }
2101
+ var ForwardRequest = {
2102
+ encode(message, writer = new BinaryWriter()) {
2103
+ if (message.requestId !== "") {
2104
+ writer.uint32(10).string(message.requestId);
2105
+ }
2106
+ for (const v of message.statements) {
2107
+ Statement.encode(v, writer.uint32(18).fork()).join();
2108
+ }
2109
+ if (message.groupId !== "") {
2110
+ writer.uint32(26).string(message.groupId);
2111
+ }
2112
+ if (message.primaryTerm !== 0n) {
2113
+ if (BigInt.asIntN(64, message.primaryTerm) !== message.primaryTerm) {
2114
+ throw new globalThis.Error("value provided for field message.primaryTerm of type int64 too large");
2115
+ }
2116
+ writer.uint32(32).int64(message.primaryTerm);
2117
+ }
2118
+ if (message.writeConcernLevel !== "") {
2119
+ writer.uint32(42).string(message.writeConcernLevel);
2120
+ }
2121
+ if (message.writeConcernTimeoutMs !== 0) {
2122
+ writer.uint32(48).uint32(message.writeConcernTimeoutMs);
2123
+ }
2124
+ return writer;
2125
+ },
2126
+ decode(input, length) {
2127
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2128
+ const end = length === void 0 ? reader.len : reader.pos + length;
2129
+ const message = createBaseForwardRequest();
2130
+ while (reader.pos < end) {
2131
+ const tag = reader.uint32();
2132
+ switch (tag >>> 3) {
2133
+ case 1: {
2134
+ if (tag !== 10) {
2135
+ break;
2136
+ }
2137
+ message.requestId = reader.string();
2138
+ continue;
2139
+ }
2140
+ case 2: {
2141
+ if (tag !== 18) {
2142
+ break;
2143
+ }
2144
+ message.statements.push(Statement.decode(reader, reader.uint32()));
2145
+ continue;
2146
+ }
2147
+ case 3: {
2148
+ if (tag !== 26) {
2149
+ break;
2150
+ }
2151
+ message.groupId = reader.string();
2152
+ continue;
2153
+ }
2154
+ case 4: {
2155
+ if (tag !== 32) {
2156
+ break;
2157
+ }
2158
+ message.primaryTerm = reader.int64();
2159
+ continue;
2160
+ }
2161
+ case 5: {
2162
+ if (tag !== 42) {
2163
+ break;
2164
+ }
2165
+ message.writeConcernLevel = reader.string();
2166
+ continue;
2167
+ }
2168
+ case 6: {
2169
+ if (tag !== 48) {
2170
+ break;
2171
+ }
2172
+ message.writeConcernTimeoutMs = reader.uint32();
2173
+ continue;
2174
+ }
2175
+ }
2176
+ if ((tag & 7) === 4 || tag === 0) {
2177
+ break;
2178
+ }
2179
+ reader.skip(tag & 7);
2180
+ }
2181
+ return message;
2182
+ },
2183
+ fromJSON(object) {
2184
+ return {
2185
+ requestId: isSet(object.requestId) ? globalThis.String(object.requestId) : isSet(object.request_id) ? globalThis.String(object.request_id) : "",
2186
+ statements: globalThis.Array.isArray(object?.statements) ? object.statements.map((e) => Statement.fromJSON(e)) : [],
2187
+ groupId: isSet(object.groupId) ? globalThis.String(object.groupId) : isSet(object.group_id) ? globalThis.String(object.group_id) : "",
2188
+ primaryTerm: isSet(object.primaryTerm) ? BigInt(object.primaryTerm) : isSet(object.primary_term) ? BigInt(object.primary_term) : 0n,
2189
+ writeConcernLevel: isSet(object.writeConcernLevel) ? globalThis.String(object.writeConcernLevel) : isSet(object.write_concern_level) ? globalThis.String(object.write_concern_level) : "",
2190
+ writeConcernTimeoutMs: isSet(object.writeConcernTimeoutMs) ? globalThis.Number(object.writeConcernTimeoutMs) : isSet(object.write_concern_timeout_ms) ? globalThis.Number(object.write_concern_timeout_ms) : 0
2191
+ };
2192
+ },
2193
+ toJSON(message) {
2194
+ const obj = {};
2195
+ if (message.requestId !== "") {
2196
+ obj.requestId = message.requestId;
2197
+ }
2198
+ if (message.statements?.length) {
2199
+ obj.statements = message.statements.map((e) => Statement.toJSON(e));
2200
+ }
2201
+ if (message.groupId !== "") {
2202
+ obj.groupId = message.groupId;
2203
+ }
2204
+ if (message.primaryTerm !== 0n) {
2205
+ obj.primaryTerm = message.primaryTerm.toString();
2206
+ }
2207
+ if (message.writeConcernLevel !== "") {
2208
+ obj.writeConcernLevel = message.writeConcernLevel;
2209
+ }
2210
+ if (message.writeConcernTimeoutMs !== 0) {
2211
+ obj.writeConcernTimeoutMs = Math.round(message.writeConcernTimeoutMs);
2212
+ }
2213
+ return obj;
2214
+ },
2215
+ create(base) {
2216
+ return ForwardRequest.fromPartial(base ?? {});
2217
+ },
2218
+ fromPartial(object) {
2219
+ const message = createBaseForwardRequest();
2220
+ message.requestId = object.requestId ?? "";
2221
+ message.statements = object.statements?.map((e) => Statement.fromPartial(e)) || [];
2222
+ message.groupId = object.groupId ?? "";
2223
+ message.primaryTerm = object.primaryTerm ?? 0n;
2224
+ message.writeConcernLevel = object.writeConcernLevel ?? "";
2225
+ message.writeConcernTimeoutMs = object.writeConcernTimeoutMs ?? 0;
2226
+ return message;
2227
+ }
2228
+ };
2229
+ function createBaseStatementResult() {
2230
+ return { changes: 0, lastInsertRowId: 0n };
2231
+ }
2232
+ var StatementResult = {
2233
+ encode(message, writer = new BinaryWriter()) {
2234
+ if (message.changes !== 0) {
2235
+ writer.uint32(8).int32(message.changes);
2236
+ }
2237
+ if (message.lastInsertRowId !== 0n) {
2238
+ if (BigInt.asIntN(64, message.lastInsertRowId) !== message.lastInsertRowId) {
2239
+ throw new globalThis.Error("value provided for field message.lastInsertRowId of type int64 too large");
2240
+ }
2241
+ writer.uint32(16).int64(message.lastInsertRowId);
2242
+ }
2243
+ return writer;
2244
+ },
2245
+ decode(input, length) {
2246
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2247
+ const end = length === void 0 ? reader.len : reader.pos + length;
2248
+ const message = createBaseStatementResult();
2249
+ while (reader.pos < end) {
2250
+ const tag = reader.uint32();
2251
+ switch (tag >>> 3) {
2252
+ case 1: {
2253
+ if (tag !== 8) {
2254
+ break;
2255
+ }
2256
+ message.changes = reader.int32();
2257
+ continue;
2258
+ }
2259
+ case 2: {
2260
+ if (tag !== 16) {
2261
+ break;
2262
+ }
2263
+ message.lastInsertRowId = reader.int64();
2264
+ continue;
2265
+ }
2266
+ }
2267
+ if ((tag & 7) === 4 || tag === 0) {
2268
+ break;
2269
+ }
2270
+ reader.skip(tag & 7);
2271
+ }
2272
+ return message;
2273
+ },
2274
+ fromJSON(object) {
2275
+ return {
2276
+ changes: isSet(object.changes) ? globalThis.Number(object.changes) : 0,
2277
+ lastInsertRowId: isSet(object.lastInsertRowId) ? BigInt(object.lastInsertRowId) : isSet(object.last_insert_row_id) ? BigInt(object.last_insert_row_id) : 0n
2278
+ };
2279
+ },
2280
+ toJSON(message) {
2281
+ const obj = {};
2282
+ if (message.changes !== 0) {
2283
+ obj.changes = Math.round(message.changes);
2284
+ }
2285
+ if (message.lastInsertRowId !== 0n) {
2286
+ obj.lastInsertRowId = message.lastInsertRowId.toString();
2287
+ }
2288
+ return obj;
2289
+ },
2290
+ create(base) {
2291
+ return StatementResult.fromPartial(base ?? {});
2292
+ },
2293
+ fromPartial(object) {
2294
+ const message = createBaseStatementResult();
2295
+ message.changes = object.changes ?? 0;
2296
+ message.lastInsertRowId = object.lastInsertRowId ?? 0n;
2297
+ return message;
2298
+ }
2299
+ };
2300
+ function createBaseForwardResponse() {
2301
+ return { requestId: "", results: [], error: "", groupId: "", primaryTerm: 0n, errorCode: "" };
2302
+ }
2303
+ var ForwardResponse = {
2304
+ encode(message, writer = new BinaryWriter()) {
2305
+ if (message.requestId !== "") {
2306
+ writer.uint32(10).string(message.requestId);
2307
+ }
2308
+ for (const v of message.results) {
2309
+ StatementResult.encode(v, writer.uint32(18).fork()).join();
2310
+ }
2311
+ if (message.error !== "") {
2312
+ writer.uint32(26).string(message.error);
2313
+ }
2314
+ if (message.groupId !== "") {
2315
+ writer.uint32(34).string(message.groupId);
2316
+ }
2317
+ if (message.primaryTerm !== 0n) {
2318
+ if (BigInt.asIntN(64, message.primaryTerm) !== message.primaryTerm) {
2319
+ throw new globalThis.Error("value provided for field message.primaryTerm of type int64 too large");
2320
+ }
2321
+ writer.uint32(40).int64(message.primaryTerm);
2322
+ }
2323
+ if (message.errorCode !== "") {
2324
+ writer.uint32(50).string(message.errorCode);
2325
+ }
2326
+ return writer;
2327
+ },
2328
+ decode(input, length) {
2329
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2330
+ const end = length === void 0 ? reader.len : reader.pos + length;
2331
+ const message = createBaseForwardResponse();
2332
+ while (reader.pos < end) {
2333
+ const tag = reader.uint32();
2334
+ switch (tag >>> 3) {
2335
+ case 1: {
2336
+ if (tag !== 10) {
2337
+ break;
2338
+ }
2339
+ message.requestId = reader.string();
2340
+ continue;
2341
+ }
2342
+ case 2: {
2343
+ if (tag !== 18) {
2344
+ break;
2345
+ }
2346
+ message.results.push(StatementResult.decode(reader, reader.uint32()));
2347
+ continue;
2348
+ }
2349
+ case 3: {
2350
+ if (tag !== 26) {
2351
+ break;
2352
+ }
2353
+ message.error = reader.string();
2354
+ continue;
2355
+ }
2356
+ case 4: {
2357
+ if (tag !== 34) {
2358
+ break;
2359
+ }
2360
+ message.groupId = reader.string();
2361
+ continue;
2362
+ }
2363
+ case 5: {
2364
+ if (tag !== 40) {
2365
+ break;
2366
+ }
2367
+ message.primaryTerm = reader.int64();
2368
+ continue;
2369
+ }
2370
+ case 6: {
2371
+ if (tag !== 50) {
2372
+ break;
2373
+ }
2374
+ message.errorCode = reader.string();
2375
+ continue;
2376
+ }
2377
+ }
2378
+ if ((tag & 7) === 4 || tag === 0) {
2379
+ break;
2380
+ }
2381
+ reader.skip(tag & 7);
2382
+ }
2383
+ return message;
2384
+ },
2385
+ fromJSON(object) {
2386
+ return {
2387
+ requestId: isSet(object.requestId) ? globalThis.String(object.requestId) : isSet(object.request_id) ? globalThis.String(object.request_id) : "",
2388
+ results: globalThis.Array.isArray(object?.results) ? object.results.map((e) => StatementResult.fromJSON(e)) : [],
2389
+ error: isSet(object.error) ? globalThis.String(object.error) : "",
2390
+ groupId: isSet(object.groupId) ? globalThis.String(object.groupId) : isSet(object.group_id) ? globalThis.String(object.group_id) : "",
2391
+ primaryTerm: isSet(object.primaryTerm) ? BigInt(object.primaryTerm) : isSet(object.primary_term) ? BigInt(object.primary_term) : 0n,
2392
+ errorCode: isSet(object.errorCode) ? globalThis.String(object.errorCode) : isSet(object.error_code) ? globalThis.String(object.error_code) : ""
2393
+ };
2394
+ },
2395
+ toJSON(message) {
2396
+ const obj = {};
2397
+ if (message.requestId !== "") {
2398
+ obj.requestId = message.requestId;
2399
+ }
2400
+ if (message.results?.length) {
2401
+ obj.results = message.results.map((e) => StatementResult.toJSON(e));
2402
+ }
2403
+ if (message.error !== "") {
2404
+ obj.error = message.error;
2405
+ }
2406
+ if (message.groupId !== "") {
2407
+ obj.groupId = message.groupId;
2408
+ }
2409
+ if (message.primaryTerm !== 0n) {
2410
+ obj.primaryTerm = message.primaryTerm.toString();
2411
+ }
2412
+ if (message.errorCode !== "") {
2413
+ obj.errorCode = message.errorCode;
2414
+ }
2415
+ return obj;
2416
+ },
2417
+ create(base) {
2418
+ return ForwardResponse.fromPartial(base ?? {});
2419
+ },
2420
+ fromPartial(object) {
2421
+ const message = createBaseForwardResponse();
2422
+ message.requestId = object.requestId ?? "";
2423
+ message.results = object.results?.map((e) => StatementResult.fromPartial(e)) || [];
2424
+ message.error = object.error ?? "";
2425
+ message.groupId = object.groupId ?? "";
2426
+ message.primaryTerm = object.primaryTerm ?? 0n;
2427
+ message.errorCode = object.errorCode ?? "";
2428
+ return message;
2429
+ }
2430
+ };
2431
+ var ReplicationService = {
2432
+ replicate: {
2433
+ path: "/sirannon.replication.v1.Replication/Replicate",
2434
+ requestStream: true,
2435
+ responseStream: true,
2436
+ requestSerialize: (value) => Buffer.from(ReplicationMessage.encode(value).finish()),
2437
+ requestDeserialize: (value) => ReplicationMessage.decode(value),
2438
+ responseSerialize: (value) => Buffer.from(ReplicationMessage.encode(value).finish()),
2439
+ responseDeserialize: (value) => ReplicationMessage.decode(value)
2440
+ },
2441
+ sync: {
2442
+ path: "/sirannon.replication.v1.Replication/Sync",
2443
+ requestStream: true,
2444
+ responseStream: true,
2445
+ requestSerialize: (value) => Buffer.from(SyncMessage.encode(value).finish()),
2446
+ requestDeserialize: (value) => SyncMessage.decode(value),
2447
+ responseSerialize: (value) => Buffer.from(SyncMessage.encode(value).finish()),
2448
+ responseDeserialize: (value) => SyncMessage.decode(value)
2449
+ },
2450
+ forward: {
2451
+ path: "/sirannon.replication.v1.Replication/Forward",
2452
+ requestStream: false,
2453
+ responseStream: false,
2454
+ requestSerialize: (value) => Buffer.from(ForwardRequest.encode(value).finish()),
2455
+ requestDeserialize: (value) => ForwardRequest.decode(value),
2456
+ responseSerialize: (value) => Buffer.from(ForwardResponse.encode(value).finish()),
2457
+ responseDeserialize: (value) => ForwardResponse.decode(value)
2458
+ }
2459
+ };
2460
+ var ReplicationClient = makeGenericClientConstructor(
2461
+ ReplicationService,
2462
+ "sirannon.replication.v1.Replication"
2463
+ );
2464
+ function bytesFromBase64(b64) {
2465
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
2466
+ }
2467
+ function base64FromBytes(arr) {
2468
+ return globalThis.Buffer.from(arr).toString("base64");
2469
+ }
2470
+ function isObject(value) {
2471
+ return typeof value === "object" && value !== null;
2472
+ }
2473
+ function isSet(value) {
2474
+ return value !== null && value !== void 0;
2475
+ }
2476
+ function buildServerCreds(options) {
2477
+ if (options.insecure) {
2478
+ return ServerCredentials.createInsecure();
2479
+ }
2480
+ if (!options.tlsCert || !options.tlsKey) {
2481
+ throw new TransportError("TLS certificate and key paths are required when insecure mode is disabled");
2482
+ }
2483
+ const cert = readFileSync(options.tlsCert);
2484
+ const key = readFileSync(options.tlsKey);
2485
+ const ca = options.tlsCaCert ? readFileSync(options.tlsCaCert) : null;
2486
+ return ServerCredentials.createSsl(ca, [{ private_key: key, cert_chain: cert }], ca !== null);
2487
+ }
2488
+ function buildChannelCreds(options) {
2489
+ if (options.insecure) {
2490
+ return credentials.createInsecure();
2491
+ }
2492
+ if (!options.tlsCert || !options.tlsKey) {
2493
+ throw new TransportError("TLS certificate and key paths are required when insecure mode is disabled");
2494
+ }
2495
+ const cert = readFileSync(options.tlsCert);
2496
+ const key = readFileSync(options.tlsKey);
2497
+ const ca = options.tlsCaCert ? readFileSync(options.tlsCaCert) : null;
2498
+ return credentials.createSsl(ca, key, cert);
2499
+ }
2500
+
2501
+ export { ReplicationClient, ReplicationService, buildChannelCreds, buildServerCreds };