@kronos-ts/kronosdb 0.1.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 (96) hide show
  1. package/dist/connection.d.ts +86 -0
  2. package/dist/connection.d.ts.map +1 -0
  3. package/dist/connection.js +133 -0
  4. package/dist/connection.js.map +1 -0
  5. package/dist/errors.d.ts +72 -0
  6. package/dist/errors.d.ts.map +1 -0
  7. package/dist/errors.js +149 -0
  8. package/dist/errors.js.map +1 -0
  9. package/dist/event-processor-info.d.ts +32 -0
  10. package/dist/event-processor-info.d.ts.map +1 -0
  11. package/dist/event-processor-info.js +24 -0
  12. package/dist/event-processor-info.js.map +1 -0
  13. package/dist/flow-controlled-sender.d.ts +12 -0
  14. package/dist/flow-controlled-sender.d.ts.map +1 -0
  15. package/dist/flow-controlled-sender.js +53 -0
  16. package/dist/flow-controlled-sender.js.map +1 -0
  17. package/dist/generated/command.d.ts +169 -0
  18. package/dist/generated/command.d.ts.map +1 -0
  19. package/dist/generated/command.js +964 -0
  20. package/dist/generated/command.js.map +1 -0
  21. package/dist/generated/common.d.ts +76 -0
  22. package/dist/generated/common.d.ts.map +1 -0
  23. package/dist/generated/common.js +648 -0
  24. package/dist/generated/common.js.map +1 -0
  25. package/dist/generated/eventstore.d.ts +337 -0
  26. package/dist/generated/eventstore.d.ts.map +1 -0
  27. package/dist/generated/eventstore.js +1757 -0
  28. package/dist/generated/eventstore.js.map +1 -0
  29. package/dist/generated/platform.d.ts +242 -0
  30. package/dist/generated/platform.d.ts.map +1 -0
  31. package/dist/generated/platform.js +1525 -0
  32. package/dist/generated/platform.js.map +1 -0
  33. package/dist/generated/query.d.ts +265 -0
  34. package/dist/generated/query.d.ts.map +1 -0
  35. package/dist/generated/query.js +2114 -0
  36. package/dist/generated/query.js.map +1 -0
  37. package/dist/generated/snapshot.d.ts +180 -0
  38. package/dist/generated/snapshot.d.ts.map +1 -0
  39. package/dist/generated/snapshot.js +861 -0
  40. package/dist/generated/snapshot.js.map +1 -0
  41. package/dist/index.d.ts +13 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +13 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/kronosdb-event-store.d.ts +17 -0
  46. package/dist/kronosdb-event-store.d.ts.map +1 -0
  47. package/dist/kronosdb-event-store.js +328 -0
  48. package/dist/kronosdb-event-store.js.map +1 -0
  49. package/dist/kronosdb-snapshot-store.d.ts +10 -0
  50. package/dist/kronosdb-snapshot-store.d.ts.map +1 -0
  51. package/dist/kronosdb-snapshot-store.js +79 -0
  52. package/dist/kronosdb-snapshot-store.js.map +1 -0
  53. package/dist/kronosdb.d.ts +53 -0
  54. package/dist/kronosdb.d.ts.map +1 -0
  55. package/dist/kronosdb.js +852 -0
  56. package/dist/kronosdb.js.map +1 -0
  57. package/dist/metadata-conversion.d.ts +37 -0
  58. package/dist/metadata-conversion.d.ts.map +1 -0
  59. package/dist/metadata-conversion.js +75 -0
  60. package/dist/metadata-conversion.js.map +1 -0
  61. package/dist/outbound-stream.d.ts +15 -0
  62. package/dist/outbound-stream.d.ts.map +1 -0
  63. package/dist/outbound-stream.js +39 -0
  64. package/dist/outbound-stream.js.map +1 -0
  65. package/dist/platform-service.d.ts +87 -0
  66. package/dist/platform-service.d.ts.map +1 -0
  67. package/dist/platform-service.js +218 -0
  68. package/dist/platform-service.js.map +1 -0
  69. package/dist/service-definitions.d.ts +187 -0
  70. package/dist/service-definitions.d.ts.map +1 -0
  71. package/dist/service-definitions.js +18 -0
  72. package/dist/service-definitions.js.map +1 -0
  73. package/dist/shutdown-latch.d.ts +18 -0
  74. package/dist/shutdown-latch.d.ts.map +1 -0
  75. package/dist/shutdown-latch.js +51 -0
  76. package/dist/shutdown-latch.js.map +1 -0
  77. package/package.json +69 -0
  78. package/src/connection.ts +235 -0
  79. package/src/errors.ts +173 -0
  80. package/src/event-processor-info.ts +53 -0
  81. package/src/flow-controlled-sender.ts +73 -0
  82. package/src/generated/command.ts +1226 -0
  83. package/src/generated/common.ts +770 -0
  84. package/src/generated/eventstore.ts +2241 -0
  85. package/src/generated/platform.ts +1914 -0
  86. package/src/generated/query.ts +2571 -0
  87. package/src/generated/snapshot.ts +1110 -0
  88. package/src/index.ts +87 -0
  89. package/src/kronosdb-event-store.ts +401 -0
  90. package/src/kronosdb-snapshot-store.ts +104 -0
  91. package/src/kronosdb.ts +1000 -0
  92. package/src/metadata-conversion.ts +85 -0
  93. package/src/outbound-stream.ts +52 -0
  94. package/src/platform-service.ts +297 -0
  95. package/src/service-definitions.ts +25 -0
  96. package/src/shutdown-latch.ts +74 -0
@@ -0,0 +1,964 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.6
4
+ // protoc v3.19.1
5
+ // source: command.proto
6
+ /* eslint-disable */
7
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
8
+ import { ErrorMessage, FlowControl, InstructionAck, MetadataValue, ProcessingInstruction, SerializedObject, } from "./common.js";
9
+ export const protobufPackage = "kronosdb.command";
10
+ function createBaseCommandHandlerOutbound() {
11
+ return {
12
+ subscribe: undefined,
13
+ unsubscribe: undefined,
14
+ flowControl: undefined,
15
+ commandResponse: undefined,
16
+ ack: undefined,
17
+ instructionId: "",
18
+ };
19
+ }
20
+ export const CommandHandlerOutbound = {
21
+ encode(message, writer = new BinaryWriter()) {
22
+ if (message.subscribe !== undefined) {
23
+ CommandSubscription.encode(message.subscribe, writer.uint32(10).fork()).join();
24
+ }
25
+ if (message.unsubscribe !== undefined) {
26
+ CommandSubscription.encode(message.unsubscribe, writer.uint32(18).fork()).join();
27
+ }
28
+ if (message.flowControl !== undefined) {
29
+ FlowControl.encode(message.flowControl, writer.uint32(26).fork()).join();
30
+ }
31
+ if (message.commandResponse !== undefined) {
32
+ CommandResponse.encode(message.commandResponse, writer.uint32(34).fork()).join();
33
+ }
34
+ if (message.ack !== undefined) {
35
+ InstructionAck.encode(message.ack, writer.uint32(42).fork()).join();
36
+ }
37
+ if (message.instructionId !== "") {
38
+ writer.uint32(50).string(message.instructionId);
39
+ }
40
+ return writer;
41
+ },
42
+ decode(input, length) {
43
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
44
+ const end = length === undefined ? reader.len : reader.pos + length;
45
+ const message = createBaseCommandHandlerOutbound();
46
+ while (reader.pos < end) {
47
+ const tag = reader.uint32();
48
+ switch (tag >>> 3) {
49
+ case 1: {
50
+ if (tag !== 10) {
51
+ break;
52
+ }
53
+ message.subscribe = CommandSubscription.decode(reader, reader.uint32());
54
+ continue;
55
+ }
56
+ case 2: {
57
+ if (tag !== 18) {
58
+ break;
59
+ }
60
+ message.unsubscribe = CommandSubscription.decode(reader, reader.uint32());
61
+ continue;
62
+ }
63
+ case 3: {
64
+ if (tag !== 26) {
65
+ break;
66
+ }
67
+ message.flowControl = FlowControl.decode(reader, reader.uint32());
68
+ continue;
69
+ }
70
+ case 4: {
71
+ if (tag !== 34) {
72
+ break;
73
+ }
74
+ message.commandResponse = CommandResponse.decode(reader, reader.uint32());
75
+ continue;
76
+ }
77
+ case 5: {
78
+ if (tag !== 42) {
79
+ break;
80
+ }
81
+ message.ack = InstructionAck.decode(reader, reader.uint32());
82
+ continue;
83
+ }
84
+ case 6: {
85
+ if (tag !== 50) {
86
+ break;
87
+ }
88
+ message.instructionId = reader.string();
89
+ continue;
90
+ }
91
+ }
92
+ if ((tag & 7) === 4 || tag === 0) {
93
+ break;
94
+ }
95
+ reader.skip(tag & 7);
96
+ }
97
+ return message;
98
+ },
99
+ fromJSON(object) {
100
+ return {
101
+ subscribe: isSet(object.subscribe) ? CommandSubscription.fromJSON(object.subscribe) : undefined,
102
+ unsubscribe: isSet(object.unsubscribe) ? CommandSubscription.fromJSON(object.unsubscribe) : undefined,
103
+ flowControl: isSet(object.flowControl)
104
+ ? FlowControl.fromJSON(object.flowControl)
105
+ : isSet(object.flow_control)
106
+ ? FlowControl.fromJSON(object.flow_control)
107
+ : undefined,
108
+ commandResponse: isSet(object.commandResponse)
109
+ ? CommandResponse.fromJSON(object.commandResponse)
110
+ : isSet(object.command_response)
111
+ ? CommandResponse.fromJSON(object.command_response)
112
+ : undefined,
113
+ ack: isSet(object.ack) ? InstructionAck.fromJSON(object.ack) : undefined,
114
+ instructionId: isSet(object.instructionId)
115
+ ? globalThis.String(object.instructionId)
116
+ : isSet(object.instruction_id)
117
+ ? globalThis.String(object.instruction_id)
118
+ : "",
119
+ };
120
+ },
121
+ toJSON(message) {
122
+ const obj = {};
123
+ if (message.subscribe !== undefined) {
124
+ obj.subscribe = CommandSubscription.toJSON(message.subscribe);
125
+ }
126
+ if (message.unsubscribe !== undefined) {
127
+ obj.unsubscribe = CommandSubscription.toJSON(message.unsubscribe);
128
+ }
129
+ if (message.flowControl !== undefined) {
130
+ obj.flowControl = FlowControl.toJSON(message.flowControl);
131
+ }
132
+ if (message.commandResponse !== undefined) {
133
+ obj.commandResponse = CommandResponse.toJSON(message.commandResponse);
134
+ }
135
+ if (message.ack !== undefined) {
136
+ obj.ack = InstructionAck.toJSON(message.ack);
137
+ }
138
+ if (message.instructionId !== "") {
139
+ obj.instructionId = message.instructionId;
140
+ }
141
+ return obj;
142
+ },
143
+ create(base) {
144
+ return CommandHandlerOutbound.fromPartial(base ?? {});
145
+ },
146
+ fromPartial(object) {
147
+ const message = createBaseCommandHandlerOutbound();
148
+ message.subscribe = (object.subscribe !== undefined && object.subscribe !== null)
149
+ ? CommandSubscription.fromPartial(object.subscribe)
150
+ : undefined;
151
+ message.unsubscribe = (object.unsubscribe !== undefined && object.unsubscribe !== null)
152
+ ? CommandSubscription.fromPartial(object.unsubscribe)
153
+ : undefined;
154
+ message.flowControl = (object.flowControl !== undefined && object.flowControl !== null)
155
+ ? FlowControl.fromPartial(object.flowControl)
156
+ : undefined;
157
+ message.commandResponse = (object.commandResponse !== undefined && object.commandResponse !== null)
158
+ ? CommandResponse.fromPartial(object.commandResponse)
159
+ : undefined;
160
+ message.ack = (object.ack !== undefined && object.ack !== null)
161
+ ? InstructionAck.fromPartial(object.ack)
162
+ : undefined;
163
+ message.instructionId = object.instructionId ?? "";
164
+ return message;
165
+ },
166
+ };
167
+ function createBaseCommandHandlerInbound() {
168
+ return { ack: undefined, command: undefined, instructionId: "" };
169
+ }
170
+ export const CommandHandlerInbound = {
171
+ encode(message, writer = new BinaryWriter()) {
172
+ if (message.ack !== undefined) {
173
+ InstructionAck.encode(message.ack, writer.uint32(10).fork()).join();
174
+ }
175
+ if (message.command !== undefined) {
176
+ Command.encode(message.command, writer.uint32(18).fork()).join();
177
+ }
178
+ if (message.instructionId !== "") {
179
+ writer.uint32(26).string(message.instructionId);
180
+ }
181
+ return writer;
182
+ },
183
+ decode(input, length) {
184
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
185
+ const end = length === undefined ? reader.len : reader.pos + length;
186
+ const message = createBaseCommandHandlerInbound();
187
+ while (reader.pos < end) {
188
+ const tag = reader.uint32();
189
+ switch (tag >>> 3) {
190
+ case 1: {
191
+ if (tag !== 10) {
192
+ break;
193
+ }
194
+ message.ack = InstructionAck.decode(reader, reader.uint32());
195
+ continue;
196
+ }
197
+ case 2: {
198
+ if (tag !== 18) {
199
+ break;
200
+ }
201
+ message.command = Command.decode(reader, reader.uint32());
202
+ continue;
203
+ }
204
+ case 3: {
205
+ if (tag !== 26) {
206
+ break;
207
+ }
208
+ message.instructionId = reader.string();
209
+ continue;
210
+ }
211
+ }
212
+ if ((tag & 7) === 4 || tag === 0) {
213
+ break;
214
+ }
215
+ reader.skip(tag & 7);
216
+ }
217
+ return message;
218
+ },
219
+ fromJSON(object) {
220
+ return {
221
+ ack: isSet(object.ack) ? InstructionAck.fromJSON(object.ack) : undefined,
222
+ command: isSet(object.command) ? Command.fromJSON(object.command) : undefined,
223
+ instructionId: isSet(object.instructionId)
224
+ ? globalThis.String(object.instructionId)
225
+ : isSet(object.instruction_id)
226
+ ? globalThis.String(object.instruction_id)
227
+ : "",
228
+ };
229
+ },
230
+ toJSON(message) {
231
+ const obj = {};
232
+ if (message.ack !== undefined) {
233
+ obj.ack = InstructionAck.toJSON(message.ack);
234
+ }
235
+ if (message.command !== undefined) {
236
+ obj.command = Command.toJSON(message.command);
237
+ }
238
+ if (message.instructionId !== "") {
239
+ obj.instructionId = message.instructionId;
240
+ }
241
+ return obj;
242
+ },
243
+ create(base) {
244
+ return CommandHandlerInbound.fromPartial(base ?? {});
245
+ },
246
+ fromPartial(object) {
247
+ const message = createBaseCommandHandlerInbound();
248
+ message.ack = (object.ack !== undefined && object.ack !== null)
249
+ ? InstructionAck.fromPartial(object.ack)
250
+ : undefined;
251
+ message.command = (object.command !== undefined && object.command !== null)
252
+ ? Command.fromPartial(object.command)
253
+ : undefined;
254
+ message.instructionId = object.instructionId ?? "";
255
+ return message;
256
+ },
257
+ };
258
+ function createBaseCommand() {
259
+ return {
260
+ messageIdentifier: "",
261
+ name: "",
262
+ timestamp: 0n,
263
+ payload: undefined,
264
+ metadata: {},
265
+ processingInstructions: [],
266
+ clientId: "",
267
+ componentName: "",
268
+ };
269
+ }
270
+ export const Command = {
271
+ encode(message, writer = new BinaryWriter()) {
272
+ if (message.messageIdentifier !== "") {
273
+ writer.uint32(10).string(message.messageIdentifier);
274
+ }
275
+ if (message.name !== "") {
276
+ writer.uint32(18).string(message.name);
277
+ }
278
+ if (message.timestamp !== 0n) {
279
+ if (BigInt.asIntN(64, message.timestamp) !== message.timestamp) {
280
+ throw new globalThis.Error("value provided for field message.timestamp of type int64 too large");
281
+ }
282
+ writer.uint32(24).int64(message.timestamp);
283
+ }
284
+ if (message.payload !== undefined) {
285
+ SerializedObject.encode(message.payload, writer.uint32(34).fork()).join();
286
+ }
287
+ globalThis.Object.entries(message.metadata).forEach(([key, value]) => {
288
+ Command_MetadataEntry.encode({ key: key, value }, writer.uint32(42).fork()).join();
289
+ });
290
+ for (const v of message.processingInstructions) {
291
+ ProcessingInstruction.encode(v, writer.uint32(50).fork()).join();
292
+ }
293
+ if (message.clientId !== "") {
294
+ writer.uint32(58).string(message.clientId);
295
+ }
296
+ if (message.componentName !== "") {
297
+ writer.uint32(66).string(message.componentName);
298
+ }
299
+ return writer;
300
+ },
301
+ decode(input, length) {
302
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
303
+ const end = length === undefined ? reader.len : reader.pos + length;
304
+ const message = createBaseCommand();
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.messageIdentifier = reader.string();
313
+ continue;
314
+ }
315
+ case 2: {
316
+ if (tag !== 18) {
317
+ break;
318
+ }
319
+ message.name = reader.string();
320
+ continue;
321
+ }
322
+ case 3: {
323
+ if (tag !== 24) {
324
+ break;
325
+ }
326
+ message.timestamp = reader.int64();
327
+ continue;
328
+ }
329
+ case 4: {
330
+ if (tag !== 34) {
331
+ break;
332
+ }
333
+ message.payload = SerializedObject.decode(reader, reader.uint32());
334
+ continue;
335
+ }
336
+ case 5: {
337
+ if (tag !== 42) {
338
+ break;
339
+ }
340
+ const entry5 = Command_MetadataEntry.decode(reader, reader.uint32());
341
+ if (entry5.value !== undefined) {
342
+ message.metadata[entry5.key] = entry5.value;
343
+ }
344
+ continue;
345
+ }
346
+ case 6: {
347
+ if (tag !== 50) {
348
+ break;
349
+ }
350
+ message.processingInstructions.push(ProcessingInstruction.decode(reader, reader.uint32()));
351
+ continue;
352
+ }
353
+ case 7: {
354
+ if (tag !== 58) {
355
+ break;
356
+ }
357
+ message.clientId = reader.string();
358
+ continue;
359
+ }
360
+ case 8: {
361
+ if (tag !== 66) {
362
+ break;
363
+ }
364
+ message.componentName = reader.string();
365
+ continue;
366
+ }
367
+ }
368
+ if ((tag & 7) === 4 || tag === 0) {
369
+ break;
370
+ }
371
+ reader.skip(tag & 7);
372
+ }
373
+ return message;
374
+ },
375
+ fromJSON(object) {
376
+ return {
377
+ messageIdentifier: isSet(object.messageIdentifier)
378
+ ? globalThis.String(object.messageIdentifier)
379
+ : isSet(object.message_identifier)
380
+ ? globalThis.String(object.message_identifier)
381
+ : "",
382
+ name: isSet(object.name) ? globalThis.String(object.name) : "",
383
+ timestamp: isSet(object.timestamp) ? BigInt(object.timestamp) : 0n,
384
+ payload: isSet(object.payload) ? SerializedObject.fromJSON(object.payload) : undefined,
385
+ metadata: isObject(object.metadata)
386
+ ? globalThis.Object.entries(object.metadata).reduce((acc, [key, value]) => {
387
+ acc[key] = MetadataValue.fromJSON(value);
388
+ return acc;
389
+ }, {})
390
+ : {},
391
+ processingInstructions: globalThis.Array.isArray(object?.processingInstructions)
392
+ ? object.processingInstructions.map((e) => ProcessingInstruction.fromJSON(e))
393
+ : globalThis.Array.isArray(object?.processing_instructions)
394
+ ? object.processing_instructions.map((e) => ProcessingInstruction.fromJSON(e))
395
+ : [],
396
+ clientId: isSet(object.clientId)
397
+ ? globalThis.String(object.clientId)
398
+ : isSet(object.client_id)
399
+ ? globalThis.String(object.client_id)
400
+ : "",
401
+ componentName: isSet(object.componentName)
402
+ ? globalThis.String(object.componentName)
403
+ : isSet(object.component_name)
404
+ ? globalThis.String(object.component_name)
405
+ : "",
406
+ };
407
+ },
408
+ toJSON(message) {
409
+ const obj = {};
410
+ if (message.messageIdentifier !== "") {
411
+ obj.messageIdentifier = message.messageIdentifier;
412
+ }
413
+ if (message.name !== "") {
414
+ obj.name = message.name;
415
+ }
416
+ if (message.timestamp !== 0n) {
417
+ obj.timestamp = message.timestamp.toString();
418
+ }
419
+ if (message.payload !== undefined) {
420
+ obj.payload = SerializedObject.toJSON(message.payload);
421
+ }
422
+ if (message.metadata) {
423
+ const entries = globalThis.Object.entries(message.metadata);
424
+ if (entries.length > 0) {
425
+ obj.metadata = {};
426
+ entries.forEach(([k, v]) => {
427
+ obj.metadata[k] = MetadataValue.toJSON(v);
428
+ });
429
+ }
430
+ }
431
+ if (message.processingInstructions?.length) {
432
+ obj.processingInstructions = message.processingInstructions.map((e) => ProcessingInstruction.toJSON(e));
433
+ }
434
+ if (message.clientId !== "") {
435
+ obj.clientId = message.clientId;
436
+ }
437
+ if (message.componentName !== "") {
438
+ obj.componentName = message.componentName;
439
+ }
440
+ return obj;
441
+ },
442
+ create(base) {
443
+ return Command.fromPartial(base ?? {});
444
+ },
445
+ fromPartial(object) {
446
+ const message = createBaseCommand();
447
+ message.messageIdentifier = object.messageIdentifier ?? "";
448
+ message.name = object.name ?? "";
449
+ message.timestamp = object.timestamp ?? 0n;
450
+ message.payload = (object.payload !== undefined && object.payload !== null)
451
+ ? SerializedObject.fromPartial(object.payload)
452
+ : undefined;
453
+ message.metadata = globalThis.Object.entries(object.metadata ?? {}).reduce((acc, [key, value]) => {
454
+ if (value !== undefined) {
455
+ acc[key] = MetadataValue.fromPartial(value);
456
+ }
457
+ return acc;
458
+ }, {});
459
+ message.processingInstructions = object.processingInstructions?.map((e) => ProcessingInstruction.fromPartial(e)) ||
460
+ [];
461
+ message.clientId = object.clientId ?? "";
462
+ message.componentName = object.componentName ?? "";
463
+ return message;
464
+ },
465
+ };
466
+ function createBaseCommand_MetadataEntry() {
467
+ return { key: "", value: undefined };
468
+ }
469
+ export const Command_MetadataEntry = {
470
+ encode(message, writer = new BinaryWriter()) {
471
+ if (message.key !== "") {
472
+ writer.uint32(10).string(message.key);
473
+ }
474
+ if (message.value !== undefined) {
475
+ MetadataValue.encode(message.value, writer.uint32(18).fork()).join();
476
+ }
477
+ return writer;
478
+ },
479
+ decode(input, length) {
480
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
481
+ const end = length === undefined ? reader.len : reader.pos + length;
482
+ const message = createBaseCommand_MetadataEntry();
483
+ while (reader.pos < end) {
484
+ const tag = reader.uint32();
485
+ switch (tag >>> 3) {
486
+ case 1: {
487
+ if (tag !== 10) {
488
+ break;
489
+ }
490
+ message.key = reader.string();
491
+ continue;
492
+ }
493
+ case 2: {
494
+ if (tag !== 18) {
495
+ break;
496
+ }
497
+ message.value = MetadataValue.decode(reader, reader.uint32());
498
+ continue;
499
+ }
500
+ }
501
+ if ((tag & 7) === 4 || tag === 0) {
502
+ break;
503
+ }
504
+ reader.skip(tag & 7);
505
+ }
506
+ return message;
507
+ },
508
+ fromJSON(object) {
509
+ return {
510
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
511
+ value: isSet(object.value) ? MetadataValue.fromJSON(object.value) : undefined,
512
+ };
513
+ },
514
+ toJSON(message) {
515
+ const obj = {};
516
+ if (message.key !== "") {
517
+ obj.key = message.key;
518
+ }
519
+ if (message.value !== undefined) {
520
+ obj.value = MetadataValue.toJSON(message.value);
521
+ }
522
+ return obj;
523
+ },
524
+ create(base) {
525
+ return Command_MetadataEntry.fromPartial(base ?? {});
526
+ },
527
+ fromPartial(object) {
528
+ const message = createBaseCommand_MetadataEntry();
529
+ message.key = object.key ?? "";
530
+ message.value = (object.value !== undefined && object.value !== null)
531
+ ? MetadataValue.fromPartial(object.value)
532
+ : undefined;
533
+ return message;
534
+ },
535
+ };
536
+ function createBaseCommandResponse() {
537
+ return {
538
+ messageIdentifier: "",
539
+ errorCode: "",
540
+ errorMessage: undefined,
541
+ payload: undefined,
542
+ metadata: {},
543
+ processingInstructions: [],
544
+ requestIdentifier: "",
545
+ };
546
+ }
547
+ export const CommandResponse = {
548
+ encode(message, writer = new BinaryWriter()) {
549
+ if (message.messageIdentifier !== "") {
550
+ writer.uint32(10).string(message.messageIdentifier);
551
+ }
552
+ if (message.errorCode !== "") {
553
+ writer.uint32(18).string(message.errorCode);
554
+ }
555
+ if (message.errorMessage !== undefined) {
556
+ ErrorMessage.encode(message.errorMessage, writer.uint32(26).fork()).join();
557
+ }
558
+ if (message.payload !== undefined) {
559
+ SerializedObject.encode(message.payload, writer.uint32(34).fork()).join();
560
+ }
561
+ globalThis.Object.entries(message.metadata).forEach(([key, value]) => {
562
+ CommandResponse_MetadataEntry.encode({ key: key, value }, writer.uint32(42).fork()).join();
563
+ });
564
+ for (const v of message.processingInstructions) {
565
+ ProcessingInstruction.encode(v, writer.uint32(50).fork()).join();
566
+ }
567
+ if (message.requestIdentifier !== "") {
568
+ writer.uint32(58).string(message.requestIdentifier);
569
+ }
570
+ return writer;
571
+ },
572
+ decode(input, length) {
573
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
574
+ const end = length === undefined ? reader.len : reader.pos + length;
575
+ const message = createBaseCommandResponse();
576
+ while (reader.pos < end) {
577
+ const tag = reader.uint32();
578
+ switch (tag >>> 3) {
579
+ case 1: {
580
+ if (tag !== 10) {
581
+ break;
582
+ }
583
+ message.messageIdentifier = reader.string();
584
+ continue;
585
+ }
586
+ case 2: {
587
+ if (tag !== 18) {
588
+ break;
589
+ }
590
+ message.errorCode = reader.string();
591
+ continue;
592
+ }
593
+ case 3: {
594
+ if (tag !== 26) {
595
+ break;
596
+ }
597
+ message.errorMessage = ErrorMessage.decode(reader, reader.uint32());
598
+ continue;
599
+ }
600
+ case 4: {
601
+ if (tag !== 34) {
602
+ break;
603
+ }
604
+ message.payload = SerializedObject.decode(reader, reader.uint32());
605
+ continue;
606
+ }
607
+ case 5: {
608
+ if (tag !== 42) {
609
+ break;
610
+ }
611
+ const entry5 = CommandResponse_MetadataEntry.decode(reader, reader.uint32());
612
+ if (entry5.value !== undefined) {
613
+ message.metadata[entry5.key] = entry5.value;
614
+ }
615
+ continue;
616
+ }
617
+ case 6: {
618
+ if (tag !== 50) {
619
+ break;
620
+ }
621
+ message.processingInstructions.push(ProcessingInstruction.decode(reader, reader.uint32()));
622
+ continue;
623
+ }
624
+ case 7: {
625
+ if (tag !== 58) {
626
+ break;
627
+ }
628
+ message.requestIdentifier = reader.string();
629
+ continue;
630
+ }
631
+ }
632
+ if ((tag & 7) === 4 || tag === 0) {
633
+ break;
634
+ }
635
+ reader.skip(tag & 7);
636
+ }
637
+ return message;
638
+ },
639
+ fromJSON(object) {
640
+ return {
641
+ messageIdentifier: isSet(object.messageIdentifier)
642
+ ? globalThis.String(object.messageIdentifier)
643
+ : isSet(object.message_identifier)
644
+ ? globalThis.String(object.message_identifier)
645
+ : "",
646
+ errorCode: isSet(object.errorCode)
647
+ ? globalThis.String(object.errorCode)
648
+ : isSet(object.error_code)
649
+ ? globalThis.String(object.error_code)
650
+ : "",
651
+ errorMessage: isSet(object.errorMessage)
652
+ ? ErrorMessage.fromJSON(object.errorMessage)
653
+ : isSet(object.error_message)
654
+ ? ErrorMessage.fromJSON(object.error_message)
655
+ : undefined,
656
+ payload: isSet(object.payload) ? SerializedObject.fromJSON(object.payload) : undefined,
657
+ metadata: isObject(object.metadata)
658
+ ? globalThis.Object.entries(object.metadata).reduce((acc, [key, value]) => {
659
+ acc[key] = MetadataValue.fromJSON(value);
660
+ return acc;
661
+ }, {})
662
+ : {},
663
+ processingInstructions: globalThis.Array.isArray(object?.processingInstructions)
664
+ ? object.processingInstructions.map((e) => ProcessingInstruction.fromJSON(e))
665
+ : globalThis.Array.isArray(object?.processing_instructions)
666
+ ? object.processing_instructions.map((e) => ProcessingInstruction.fromJSON(e))
667
+ : [],
668
+ requestIdentifier: isSet(object.requestIdentifier)
669
+ ? globalThis.String(object.requestIdentifier)
670
+ : isSet(object.request_identifier)
671
+ ? globalThis.String(object.request_identifier)
672
+ : "",
673
+ };
674
+ },
675
+ toJSON(message) {
676
+ const obj = {};
677
+ if (message.messageIdentifier !== "") {
678
+ obj.messageIdentifier = message.messageIdentifier;
679
+ }
680
+ if (message.errorCode !== "") {
681
+ obj.errorCode = message.errorCode;
682
+ }
683
+ if (message.errorMessage !== undefined) {
684
+ obj.errorMessage = ErrorMessage.toJSON(message.errorMessage);
685
+ }
686
+ if (message.payload !== undefined) {
687
+ obj.payload = SerializedObject.toJSON(message.payload);
688
+ }
689
+ if (message.metadata) {
690
+ const entries = globalThis.Object.entries(message.metadata);
691
+ if (entries.length > 0) {
692
+ obj.metadata = {};
693
+ entries.forEach(([k, v]) => {
694
+ obj.metadata[k] = MetadataValue.toJSON(v);
695
+ });
696
+ }
697
+ }
698
+ if (message.processingInstructions?.length) {
699
+ obj.processingInstructions = message.processingInstructions.map((e) => ProcessingInstruction.toJSON(e));
700
+ }
701
+ if (message.requestIdentifier !== "") {
702
+ obj.requestIdentifier = message.requestIdentifier;
703
+ }
704
+ return obj;
705
+ },
706
+ create(base) {
707
+ return CommandResponse.fromPartial(base ?? {});
708
+ },
709
+ fromPartial(object) {
710
+ const message = createBaseCommandResponse();
711
+ message.messageIdentifier = object.messageIdentifier ?? "";
712
+ message.errorCode = object.errorCode ?? "";
713
+ message.errorMessage = (object.errorMessage !== undefined && object.errorMessage !== null)
714
+ ? ErrorMessage.fromPartial(object.errorMessage)
715
+ : undefined;
716
+ message.payload = (object.payload !== undefined && object.payload !== null)
717
+ ? SerializedObject.fromPartial(object.payload)
718
+ : undefined;
719
+ message.metadata = globalThis.Object.entries(object.metadata ?? {}).reduce((acc, [key, value]) => {
720
+ if (value !== undefined) {
721
+ acc[key] = MetadataValue.fromPartial(value);
722
+ }
723
+ return acc;
724
+ }, {});
725
+ message.processingInstructions = object.processingInstructions?.map((e) => ProcessingInstruction.fromPartial(e)) ||
726
+ [];
727
+ message.requestIdentifier = object.requestIdentifier ?? "";
728
+ return message;
729
+ },
730
+ };
731
+ function createBaseCommandResponse_MetadataEntry() {
732
+ return { key: "", value: undefined };
733
+ }
734
+ export const CommandResponse_MetadataEntry = {
735
+ encode(message, writer = new BinaryWriter()) {
736
+ if (message.key !== "") {
737
+ writer.uint32(10).string(message.key);
738
+ }
739
+ if (message.value !== undefined) {
740
+ MetadataValue.encode(message.value, writer.uint32(18).fork()).join();
741
+ }
742
+ return writer;
743
+ },
744
+ decode(input, length) {
745
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
746
+ const end = length === undefined ? reader.len : reader.pos + length;
747
+ const message = createBaseCommandResponse_MetadataEntry();
748
+ while (reader.pos < end) {
749
+ const tag = reader.uint32();
750
+ switch (tag >>> 3) {
751
+ case 1: {
752
+ if (tag !== 10) {
753
+ break;
754
+ }
755
+ message.key = reader.string();
756
+ continue;
757
+ }
758
+ case 2: {
759
+ if (tag !== 18) {
760
+ break;
761
+ }
762
+ message.value = MetadataValue.decode(reader, reader.uint32());
763
+ continue;
764
+ }
765
+ }
766
+ if ((tag & 7) === 4 || tag === 0) {
767
+ break;
768
+ }
769
+ reader.skip(tag & 7);
770
+ }
771
+ return message;
772
+ },
773
+ fromJSON(object) {
774
+ return {
775
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
776
+ value: isSet(object.value) ? MetadataValue.fromJSON(object.value) : undefined,
777
+ };
778
+ },
779
+ toJSON(message) {
780
+ const obj = {};
781
+ if (message.key !== "") {
782
+ obj.key = message.key;
783
+ }
784
+ if (message.value !== undefined) {
785
+ obj.value = MetadataValue.toJSON(message.value);
786
+ }
787
+ return obj;
788
+ },
789
+ create(base) {
790
+ return CommandResponse_MetadataEntry.fromPartial(base ?? {});
791
+ },
792
+ fromPartial(object) {
793
+ const message = createBaseCommandResponse_MetadataEntry();
794
+ message.key = object.key ?? "";
795
+ message.value = (object.value !== undefined && object.value !== null)
796
+ ? MetadataValue.fromPartial(object.value)
797
+ : undefined;
798
+ return message;
799
+ },
800
+ };
801
+ function createBaseCommandSubscription() {
802
+ return { messageId: "", command: "", componentName: "", clientId: "", loadFactor: 0 };
803
+ }
804
+ export const CommandSubscription = {
805
+ encode(message, writer = new BinaryWriter()) {
806
+ if (message.messageId !== "") {
807
+ writer.uint32(10).string(message.messageId);
808
+ }
809
+ if (message.command !== "") {
810
+ writer.uint32(18).string(message.command);
811
+ }
812
+ if (message.componentName !== "") {
813
+ writer.uint32(26).string(message.componentName);
814
+ }
815
+ if (message.clientId !== "") {
816
+ writer.uint32(34).string(message.clientId);
817
+ }
818
+ if (message.loadFactor !== 0) {
819
+ writer.uint32(40).int32(message.loadFactor);
820
+ }
821
+ return writer;
822
+ },
823
+ decode(input, length) {
824
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
825
+ const end = length === undefined ? reader.len : reader.pos + length;
826
+ const message = createBaseCommandSubscription();
827
+ while (reader.pos < end) {
828
+ const tag = reader.uint32();
829
+ switch (tag >>> 3) {
830
+ case 1: {
831
+ if (tag !== 10) {
832
+ break;
833
+ }
834
+ message.messageId = reader.string();
835
+ continue;
836
+ }
837
+ case 2: {
838
+ if (tag !== 18) {
839
+ break;
840
+ }
841
+ message.command = reader.string();
842
+ continue;
843
+ }
844
+ case 3: {
845
+ if (tag !== 26) {
846
+ break;
847
+ }
848
+ message.componentName = reader.string();
849
+ continue;
850
+ }
851
+ case 4: {
852
+ if (tag !== 34) {
853
+ break;
854
+ }
855
+ message.clientId = reader.string();
856
+ continue;
857
+ }
858
+ case 5: {
859
+ if (tag !== 40) {
860
+ break;
861
+ }
862
+ message.loadFactor = reader.int32();
863
+ continue;
864
+ }
865
+ }
866
+ if ((tag & 7) === 4 || tag === 0) {
867
+ break;
868
+ }
869
+ reader.skip(tag & 7);
870
+ }
871
+ return message;
872
+ },
873
+ fromJSON(object) {
874
+ return {
875
+ messageId: isSet(object.messageId)
876
+ ? globalThis.String(object.messageId)
877
+ : isSet(object.message_id)
878
+ ? globalThis.String(object.message_id)
879
+ : "",
880
+ command: isSet(object.command) ? globalThis.String(object.command) : "",
881
+ componentName: isSet(object.componentName)
882
+ ? globalThis.String(object.componentName)
883
+ : isSet(object.component_name)
884
+ ? globalThis.String(object.component_name)
885
+ : "",
886
+ clientId: isSet(object.clientId)
887
+ ? globalThis.String(object.clientId)
888
+ : isSet(object.client_id)
889
+ ? globalThis.String(object.client_id)
890
+ : "",
891
+ loadFactor: isSet(object.loadFactor)
892
+ ? globalThis.Number(object.loadFactor)
893
+ : isSet(object.load_factor)
894
+ ? globalThis.Number(object.load_factor)
895
+ : 0,
896
+ };
897
+ },
898
+ toJSON(message) {
899
+ const obj = {};
900
+ if (message.messageId !== "") {
901
+ obj.messageId = message.messageId;
902
+ }
903
+ if (message.command !== "") {
904
+ obj.command = message.command;
905
+ }
906
+ if (message.componentName !== "") {
907
+ obj.componentName = message.componentName;
908
+ }
909
+ if (message.clientId !== "") {
910
+ obj.clientId = message.clientId;
911
+ }
912
+ if (message.loadFactor !== 0) {
913
+ obj.loadFactor = Math.round(message.loadFactor);
914
+ }
915
+ return obj;
916
+ },
917
+ create(base) {
918
+ return CommandSubscription.fromPartial(base ?? {});
919
+ },
920
+ fromPartial(object) {
921
+ const message = createBaseCommandSubscription();
922
+ message.messageId = object.messageId ?? "";
923
+ message.command = object.command ?? "";
924
+ message.componentName = object.componentName ?? "";
925
+ message.clientId = object.clientId ?? "";
926
+ message.loadFactor = object.loadFactor ?? 0;
927
+ return message;
928
+ },
929
+ };
930
+ export const CommandServiceDefinition = {
931
+ name: "CommandService",
932
+ fullName: "kronosdb.command.CommandService",
933
+ methods: {
934
+ /**
935
+ * Opens a bidirectional stream for a command handler.
936
+ * The client registers which command types it handles and receives
937
+ * commands to process. Responses are sent back on the same stream.
938
+ */
939
+ openStream: {
940
+ name: "OpenStream",
941
+ requestType: CommandHandlerOutbound,
942
+ requestStream: true,
943
+ responseType: CommandHandlerInbound,
944
+ responseStream: true,
945
+ options: {},
946
+ },
947
+ /** Dispatches a command to a registered handler and returns the result. */
948
+ dispatch: {
949
+ name: "Dispatch",
950
+ requestType: Command,
951
+ requestStream: false,
952
+ responseType: CommandResponse,
953
+ responseStream: false,
954
+ options: {},
955
+ },
956
+ },
957
+ };
958
+ function isObject(value) {
959
+ return typeof value === "object" && value !== null;
960
+ }
961
+ function isSet(value) {
962
+ return value !== null && value !== undefined;
963
+ }
964
+ //# sourceMappingURL=command.js.map