@apibara/protocol 2.0.0-beta.2 → 2.0.0-beta.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.
@@ -5,9 +5,10 @@
5
5
  // source: stream.proto
6
6
 
7
7
  /* eslint-disable */
8
+ import Long from "long";
8
9
  import { type CallContext, type CallOptions } from "nice-grpc-common";
9
10
  import _m0 from "protobufjs/minimal";
10
- import { Cursor, StatusRequest, StatusResponse } from "./common";
11
+ import { Duration } from "./google/protobuf/duration";
11
12
 
12
13
  export const protobufPackage = "dna.v2.stream";
13
14
 
@@ -62,14 +63,58 @@ export function dataFinalityToJSON(object: DataFinality): string {
62
63
  }
63
64
  }
64
65
 
66
+ /** A cursor over the stream content. */
67
+ export interface Cursor {
68
+ /**
69
+ * Key used for ordering messages in the stream.
70
+ *
71
+ * This is usually the block or slot number.
72
+ */
73
+ readonly orderKey: bigint;
74
+ /**
75
+ * Key used to discriminate branches in the stream.
76
+ *
77
+ * This is usually the hash of the block.
78
+ */
79
+ readonly uniqueKey: Uint8Array;
80
+ }
81
+
82
+ /** Request for the `Status` method. */
83
+ export interface StatusRequest {
84
+ }
85
+
86
+ /** Response for the `Status` method. */
87
+ export interface StatusResponse {
88
+ /** The current head of the chain. */
89
+ readonly currentHead?:
90
+ | Cursor
91
+ | undefined;
92
+ /** The last cursor that was ingested by the node. */
93
+ readonly lastIngested?:
94
+ | Cursor
95
+ | undefined;
96
+ /** The finalized block. */
97
+ readonly finalized?:
98
+ | Cursor
99
+ | undefined;
100
+ /** The first block available. */
101
+ readonly starting?: Cursor | undefined;
102
+ }
103
+
65
104
  /** Request data to be streamed. */
66
105
  export interface StreamDataRequest {
67
- /** Cursor to start streaming from. */
106
+ /**
107
+ * Cursor to start streaming from.
108
+ *
109
+ * If not specified, starts from the genesis block.
110
+ * Use the data's message `end_cursor` field to resume streaming.
111
+ */
68
112
  readonly startingCursor?:
69
113
  | Cursor
70
114
  | undefined;
71
115
  /**
72
116
  * Return data with the specified finality.
117
+ *
73
118
  * If not specified, defaults to `DATA_FINALITY_ACCEPTED`.
74
119
  */
75
120
  readonly finality?:
@@ -77,6 +122,13 @@ export interface StreamDataRequest {
77
122
  | undefined;
78
123
  /** Filters used to generate data. */
79
124
  readonly filter: readonly Uint8Array[];
125
+ /**
126
+ * Heartbeat interval.
127
+ *
128
+ * Value must be between 10 and 60 seconds.
129
+ * If not specified, defaults to 30 seconds.
130
+ */
131
+ readonly heartbeatInterval?: Duration | undefined;
80
132
  }
81
133
 
82
134
  /** Contains a piece of streamed data. */
@@ -84,6 +136,7 @@ export interface StreamDataResponse {
84
136
  readonly message?:
85
137
  | { readonly $case: "data"; readonly data: Data }
86
138
  | { readonly $case: "invalidate"; readonly invalidate: Invalidate }
139
+ | { readonly $case: "finalize"; readonly finalize: Finalize }
87
140
  | { readonly $case: "heartbeat"; readonly heartbeat: Heartbeat }
88
141
  | { readonly $case: "systemMessage"; readonly systemMessage: SystemMessage }
89
142
  | undefined;
@@ -91,7 +144,25 @@ export interface StreamDataResponse {
91
144
 
92
145
  /** Invalidate data after the given cursor. */
93
146
  export interface Invalidate {
94
- /** The cursor of the message before the now invalid data. */
147
+ /**
148
+ * The cursor of the new chain's head.
149
+ *
150
+ * All data after this cursor should be considered invalid.
151
+ */
152
+ readonly cursor?:
153
+ | Cursor
154
+ | undefined;
155
+ /** List of blocks that were removed from the chain. */
156
+ readonly removed: readonly Cursor[];
157
+ }
158
+
159
+ /** Move the finalized block forward. */
160
+ export interface Finalize {
161
+ /**
162
+ * The cursor of the new finalized block.
163
+ *
164
+ * All data before this cursor cannot be invalidated.
165
+ */
95
166
  readonly cursor?: Cursor | undefined;
96
167
  }
97
168
 
@@ -115,7 +186,11 @@ export interface Data {
115
186
  | undefined;
116
187
  /** The finality status of the block. */
117
188
  readonly finality: DataFinality;
118
- /** The block data. */
189
+ /**
190
+ * The block data.
191
+ *
192
+ * This message contains chain-specific data serialized using protobuf.
193
+ */
119
194
  readonly data: readonly Uint8Array[];
120
195
  }
121
196
 
@@ -131,8 +206,240 @@ export interface SystemMessage {
131
206
  } | undefined;
132
207
  }
133
208
 
209
+ function createBaseCursor(): Cursor {
210
+ return { orderKey: BigInt("0"), uniqueKey: new Uint8Array(0) };
211
+ }
212
+
213
+ export const Cursor = {
214
+ encode(message: Cursor, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
215
+ if (message.orderKey !== BigInt("0")) {
216
+ if (BigInt.asUintN(64, message.orderKey) !== message.orderKey) {
217
+ throw new globalThis.Error("value provided for field message.orderKey of type uint64 too large");
218
+ }
219
+ writer.uint32(8).uint64(message.orderKey.toString());
220
+ }
221
+ if (message.uniqueKey.length !== 0) {
222
+ writer.uint32(18).bytes(message.uniqueKey);
223
+ }
224
+ return writer;
225
+ },
226
+
227
+ decode(input: _m0.Reader | Uint8Array, length?: number): Cursor {
228
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
229
+ let end = length === undefined ? reader.len : reader.pos + length;
230
+ const message = createBaseCursor() as any;
231
+ while (reader.pos < end) {
232
+ const tag = reader.uint32();
233
+ switch (tag >>> 3) {
234
+ case 1:
235
+ if (tag !== 8) {
236
+ break;
237
+ }
238
+
239
+ message.orderKey = longToBigint(reader.uint64() as Long);
240
+ continue;
241
+ case 2:
242
+ if (tag !== 18) {
243
+ break;
244
+ }
245
+
246
+ message.uniqueKey = reader.bytes();
247
+ continue;
248
+ }
249
+ if ((tag & 7) === 4 || tag === 0) {
250
+ break;
251
+ }
252
+ reader.skipType(tag & 7);
253
+ }
254
+ return message;
255
+ },
256
+
257
+ fromJSON(object: any): Cursor {
258
+ return {
259
+ orderKey: isSet(object.orderKey) ? BigInt(object.orderKey) : BigInt("0"),
260
+ uniqueKey: isSet(object.uniqueKey) ? bytesFromBase64(object.uniqueKey) : new Uint8Array(0),
261
+ };
262
+ },
263
+
264
+ toJSON(message: Cursor): unknown {
265
+ const obj: any = {};
266
+ if (message.orderKey !== BigInt("0")) {
267
+ obj.orderKey = message.orderKey.toString();
268
+ }
269
+ if (message.uniqueKey.length !== 0) {
270
+ obj.uniqueKey = base64FromBytes(message.uniqueKey);
271
+ }
272
+ return obj;
273
+ },
274
+
275
+ create(base?: DeepPartial<Cursor>): Cursor {
276
+ return Cursor.fromPartial(base ?? {});
277
+ },
278
+ fromPartial(object: DeepPartial<Cursor>): Cursor {
279
+ const message = createBaseCursor() as any;
280
+ message.orderKey = object.orderKey ?? BigInt("0");
281
+ message.uniqueKey = object.uniqueKey ?? new Uint8Array(0);
282
+ return message;
283
+ },
284
+ };
285
+
286
+ function createBaseStatusRequest(): StatusRequest {
287
+ return {};
288
+ }
289
+
290
+ export const StatusRequest = {
291
+ encode(_: StatusRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
292
+ return writer;
293
+ },
294
+
295
+ decode(input: _m0.Reader | Uint8Array, length?: number): StatusRequest {
296
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
297
+ let end = length === undefined ? reader.len : reader.pos + length;
298
+ const message = createBaseStatusRequest() as any;
299
+ while (reader.pos < end) {
300
+ const tag = reader.uint32();
301
+ switch (tag >>> 3) {
302
+ }
303
+ if ((tag & 7) === 4 || tag === 0) {
304
+ break;
305
+ }
306
+ reader.skipType(tag & 7);
307
+ }
308
+ return message;
309
+ },
310
+
311
+ fromJSON(_: any): StatusRequest {
312
+ return {};
313
+ },
314
+
315
+ toJSON(_: StatusRequest): unknown {
316
+ const obj: any = {};
317
+ return obj;
318
+ },
319
+
320
+ create(base?: DeepPartial<StatusRequest>): StatusRequest {
321
+ return StatusRequest.fromPartial(base ?? {});
322
+ },
323
+ fromPartial(_: DeepPartial<StatusRequest>): StatusRequest {
324
+ const message = createBaseStatusRequest() as any;
325
+ return message;
326
+ },
327
+ };
328
+
329
+ function createBaseStatusResponse(): StatusResponse {
330
+ return { currentHead: undefined, lastIngested: undefined, finalized: undefined, starting: undefined };
331
+ }
332
+
333
+ export const StatusResponse = {
334
+ encode(message: StatusResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
335
+ if (message.currentHead !== undefined) {
336
+ Cursor.encode(message.currentHead, writer.uint32(10).fork()).ldelim();
337
+ }
338
+ if (message.lastIngested !== undefined) {
339
+ Cursor.encode(message.lastIngested, writer.uint32(18).fork()).ldelim();
340
+ }
341
+ if (message.finalized !== undefined) {
342
+ Cursor.encode(message.finalized, writer.uint32(26).fork()).ldelim();
343
+ }
344
+ if (message.starting !== undefined) {
345
+ Cursor.encode(message.starting, writer.uint32(34).fork()).ldelim();
346
+ }
347
+ return writer;
348
+ },
349
+
350
+ decode(input: _m0.Reader | Uint8Array, length?: number): StatusResponse {
351
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
352
+ let end = length === undefined ? reader.len : reader.pos + length;
353
+ const message = createBaseStatusResponse() as any;
354
+ while (reader.pos < end) {
355
+ const tag = reader.uint32();
356
+ switch (tag >>> 3) {
357
+ case 1:
358
+ if (tag !== 10) {
359
+ break;
360
+ }
361
+
362
+ message.currentHead = Cursor.decode(reader, reader.uint32());
363
+ continue;
364
+ case 2:
365
+ if (tag !== 18) {
366
+ break;
367
+ }
368
+
369
+ message.lastIngested = Cursor.decode(reader, reader.uint32());
370
+ continue;
371
+ case 3:
372
+ if (tag !== 26) {
373
+ break;
374
+ }
375
+
376
+ message.finalized = Cursor.decode(reader, reader.uint32());
377
+ continue;
378
+ case 4:
379
+ if (tag !== 34) {
380
+ break;
381
+ }
382
+
383
+ message.starting = Cursor.decode(reader, reader.uint32());
384
+ continue;
385
+ }
386
+ if ((tag & 7) === 4 || tag === 0) {
387
+ break;
388
+ }
389
+ reader.skipType(tag & 7);
390
+ }
391
+ return message;
392
+ },
393
+
394
+ fromJSON(object: any): StatusResponse {
395
+ return {
396
+ currentHead: isSet(object.currentHead) ? Cursor.fromJSON(object.currentHead) : undefined,
397
+ lastIngested: isSet(object.lastIngested) ? Cursor.fromJSON(object.lastIngested) : undefined,
398
+ finalized: isSet(object.finalized) ? Cursor.fromJSON(object.finalized) : undefined,
399
+ starting: isSet(object.starting) ? Cursor.fromJSON(object.starting) : undefined,
400
+ };
401
+ },
402
+
403
+ toJSON(message: StatusResponse): unknown {
404
+ const obj: any = {};
405
+ if (message.currentHead !== undefined) {
406
+ obj.currentHead = Cursor.toJSON(message.currentHead);
407
+ }
408
+ if (message.lastIngested !== undefined) {
409
+ obj.lastIngested = Cursor.toJSON(message.lastIngested);
410
+ }
411
+ if (message.finalized !== undefined) {
412
+ obj.finalized = Cursor.toJSON(message.finalized);
413
+ }
414
+ if (message.starting !== undefined) {
415
+ obj.starting = Cursor.toJSON(message.starting);
416
+ }
417
+ return obj;
418
+ },
419
+
420
+ create(base?: DeepPartial<StatusResponse>): StatusResponse {
421
+ return StatusResponse.fromPartial(base ?? {});
422
+ },
423
+ fromPartial(object: DeepPartial<StatusResponse>): StatusResponse {
424
+ const message = createBaseStatusResponse() as any;
425
+ message.currentHead = (object.currentHead !== undefined && object.currentHead !== null)
426
+ ? Cursor.fromPartial(object.currentHead)
427
+ : undefined;
428
+ message.lastIngested = (object.lastIngested !== undefined && object.lastIngested !== null)
429
+ ? Cursor.fromPartial(object.lastIngested)
430
+ : undefined;
431
+ message.finalized = (object.finalized !== undefined && object.finalized !== null)
432
+ ? Cursor.fromPartial(object.finalized)
433
+ : undefined;
434
+ message.starting = (object.starting !== undefined && object.starting !== null)
435
+ ? Cursor.fromPartial(object.starting)
436
+ : undefined;
437
+ return message;
438
+ },
439
+ };
440
+
134
441
  function createBaseStreamDataRequest(): StreamDataRequest {
135
- return { startingCursor: undefined, finality: undefined, filter: [] };
442
+ return { startingCursor: undefined, finality: undefined, filter: [], heartbeatInterval: undefined };
136
443
  }
137
444
 
138
445
  export const StreamDataRequest = {
@@ -146,6 +453,9 @@ export const StreamDataRequest = {
146
453
  for (const v of message.filter) {
147
454
  writer.uint32(26).bytes(v!);
148
455
  }
456
+ if (message.heartbeatInterval !== undefined) {
457
+ Duration.encode(message.heartbeatInterval, writer.uint32(34).fork()).ldelim();
458
+ }
149
459
  return writer;
150
460
  },
151
461
 
@@ -177,6 +487,13 @@ export const StreamDataRequest = {
177
487
 
178
488
  message.filter.push(reader.bytes());
179
489
  continue;
490
+ case 4:
491
+ if (tag !== 34) {
492
+ break;
493
+ }
494
+
495
+ message.heartbeatInterval = Duration.decode(reader, reader.uint32());
496
+ continue;
180
497
  }
181
498
  if ((tag & 7) === 4 || tag === 0) {
182
499
  break;
@@ -191,6 +508,7 @@ export const StreamDataRequest = {
191
508
  startingCursor: isSet(object.startingCursor) ? Cursor.fromJSON(object.startingCursor) : undefined,
192
509
  finality: isSet(object.finality) ? dataFinalityFromJSON(object.finality) : undefined,
193
510
  filter: globalThis.Array.isArray(object?.filter) ? object.filter.map((e: any) => bytesFromBase64(e)) : [],
511
+ heartbeatInterval: isSet(object.heartbeatInterval) ? Duration.fromJSON(object.heartbeatInterval) : undefined,
194
512
  };
195
513
  },
196
514
 
@@ -205,6 +523,9 @@ export const StreamDataRequest = {
205
523
  if (message.filter?.length) {
206
524
  obj.filter = message.filter.map((e) => base64FromBytes(e));
207
525
  }
526
+ if (message.heartbeatInterval !== undefined) {
527
+ obj.heartbeatInterval = Duration.toJSON(message.heartbeatInterval);
528
+ }
208
529
  return obj;
209
530
  },
210
531
 
@@ -218,6 +539,9 @@ export const StreamDataRequest = {
218
539
  : undefined;
219
540
  message.finality = object.finality ?? undefined;
220
541
  message.filter = object.filter?.map((e) => e) || [];
542
+ message.heartbeatInterval = (object.heartbeatInterval !== undefined && object.heartbeatInterval !== null)
543
+ ? Duration.fromPartial(object.heartbeatInterval)
544
+ : undefined;
221
545
  return message;
222
546
  },
223
547
  };
@@ -235,11 +559,14 @@ export const StreamDataResponse = {
235
559
  case "invalidate":
236
560
  Invalidate.encode(message.message.invalidate, writer.uint32(18).fork()).ldelim();
237
561
  break;
562
+ case "finalize":
563
+ Finalize.encode(message.message.finalize, writer.uint32(26).fork()).ldelim();
564
+ break;
238
565
  case "heartbeat":
239
- Heartbeat.encode(message.message.heartbeat, writer.uint32(26).fork()).ldelim();
566
+ Heartbeat.encode(message.message.heartbeat, writer.uint32(34).fork()).ldelim();
240
567
  break;
241
568
  case "systemMessage":
242
- SystemMessage.encode(message.message.systemMessage, writer.uint32(34).fork()).ldelim();
569
+ SystemMessage.encode(message.message.systemMessage, writer.uint32(42).fork()).ldelim();
243
570
  break;
244
571
  }
245
572
  return writer;
@@ -271,13 +598,20 @@ export const StreamDataResponse = {
271
598
  break;
272
599
  }
273
600
 
274
- message.message = { $case: "heartbeat", heartbeat: Heartbeat.decode(reader, reader.uint32()) };
601
+ message.message = { $case: "finalize", finalize: Finalize.decode(reader, reader.uint32()) };
275
602
  continue;
276
603
  case 4:
277
604
  if (tag !== 34) {
278
605
  break;
279
606
  }
280
607
 
608
+ message.message = { $case: "heartbeat", heartbeat: Heartbeat.decode(reader, reader.uint32()) };
609
+ continue;
610
+ case 5:
611
+ if (tag !== 42) {
612
+ break;
613
+ }
614
+
281
615
  message.message = { $case: "systemMessage", systemMessage: SystemMessage.decode(reader, reader.uint32()) };
282
616
  continue;
283
617
  }
@@ -295,6 +629,8 @@ export const StreamDataResponse = {
295
629
  ? { $case: "data", data: Data.fromJSON(object.data) }
296
630
  : isSet(object.invalidate)
297
631
  ? { $case: "invalidate", invalidate: Invalidate.fromJSON(object.invalidate) }
632
+ : isSet(object.finalize)
633
+ ? { $case: "finalize", finalize: Finalize.fromJSON(object.finalize) }
298
634
  : isSet(object.heartbeat)
299
635
  ? { $case: "heartbeat", heartbeat: Heartbeat.fromJSON(object.heartbeat) }
300
636
  : isSet(object.systemMessage)
@@ -311,6 +647,9 @@ export const StreamDataResponse = {
311
647
  if (message.message?.$case === "invalidate") {
312
648
  obj.invalidate = Invalidate.toJSON(message.message.invalidate);
313
649
  }
650
+ if (message.message?.$case === "finalize") {
651
+ obj.finalize = Finalize.toJSON(message.message.finalize);
652
+ }
314
653
  if (message.message?.$case === "heartbeat") {
315
654
  obj.heartbeat = Heartbeat.toJSON(message.message.heartbeat);
316
655
  }
@@ -335,6 +674,13 @@ export const StreamDataResponse = {
335
674
  ) {
336
675
  message.message = { $case: "invalidate", invalidate: Invalidate.fromPartial(object.message.invalidate) };
337
676
  }
677
+ if (
678
+ object.message?.$case === "finalize" &&
679
+ object.message?.finalize !== undefined &&
680
+ object.message?.finalize !== null
681
+ ) {
682
+ message.message = { $case: "finalize", finalize: Finalize.fromPartial(object.message.finalize) };
683
+ }
338
684
  if (
339
685
  object.message?.$case === "heartbeat" &&
340
686
  object.message?.heartbeat !== undefined &&
@@ -357,7 +703,7 @@ export const StreamDataResponse = {
357
703
  };
358
704
 
359
705
  function createBaseInvalidate(): Invalidate {
360
- return { cursor: undefined };
706
+ return { cursor: undefined, removed: [] };
361
707
  }
362
708
 
363
709
  export const Invalidate = {
@@ -365,6 +711,9 @@ export const Invalidate = {
365
711
  if (message.cursor !== undefined) {
366
712
  Cursor.encode(message.cursor, writer.uint32(10).fork()).ldelim();
367
713
  }
714
+ for (const v of message.removed) {
715
+ Cursor.encode(v!, writer.uint32(18).fork()).ldelim();
716
+ }
368
717
  return writer;
369
718
  },
370
719
 
@@ -382,6 +731,13 @@ export const Invalidate = {
382
731
 
383
732
  message.cursor = Cursor.decode(reader, reader.uint32());
384
733
  continue;
734
+ case 2:
735
+ if (tag !== 18) {
736
+ break;
737
+ }
738
+
739
+ message.removed.push(Cursor.decode(reader, reader.uint32()));
740
+ continue;
385
741
  }
386
742
  if ((tag & 7) === 4 || tag === 0) {
387
743
  break;
@@ -392,7 +748,10 @@ export const Invalidate = {
392
748
  },
393
749
 
394
750
  fromJSON(object: any): Invalidate {
395
- return { cursor: isSet(object.cursor) ? Cursor.fromJSON(object.cursor) : undefined };
751
+ return {
752
+ cursor: isSet(object.cursor) ? Cursor.fromJSON(object.cursor) : undefined,
753
+ removed: globalThis.Array.isArray(object?.removed) ? object.removed.map((e: any) => Cursor.fromJSON(e)) : [],
754
+ };
396
755
  },
397
756
 
398
757
  toJSON(message: Invalidate): unknown {
@@ -400,6 +759,9 @@ export const Invalidate = {
400
759
  if (message.cursor !== undefined) {
401
760
  obj.cursor = Cursor.toJSON(message.cursor);
402
761
  }
762
+ if (message.removed?.length) {
763
+ obj.removed = message.removed.map((e) => Cursor.toJSON(e));
764
+ }
403
765
  return obj;
404
766
  },
405
767
 
@@ -408,6 +770,66 @@ export const Invalidate = {
408
770
  },
409
771
  fromPartial(object: DeepPartial<Invalidate>): Invalidate {
410
772
  const message = createBaseInvalidate() as any;
773
+ message.cursor = (object.cursor !== undefined && object.cursor !== null)
774
+ ? Cursor.fromPartial(object.cursor)
775
+ : undefined;
776
+ message.removed = object.removed?.map((e) => Cursor.fromPartial(e)) || [];
777
+ return message;
778
+ },
779
+ };
780
+
781
+ function createBaseFinalize(): Finalize {
782
+ return { cursor: undefined };
783
+ }
784
+
785
+ export const Finalize = {
786
+ encode(message: Finalize, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
787
+ if (message.cursor !== undefined) {
788
+ Cursor.encode(message.cursor, writer.uint32(10).fork()).ldelim();
789
+ }
790
+ return writer;
791
+ },
792
+
793
+ decode(input: _m0.Reader | Uint8Array, length?: number): Finalize {
794
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
795
+ let end = length === undefined ? reader.len : reader.pos + length;
796
+ const message = createBaseFinalize() as any;
797
+ while (reader.pos < end) {
798
+ const tag = reader.uint32();
799
+ switch (tag >>> 3) {
800
+ case 1:
801
+ if (tag !== 10) {
802
+ break;
803
+ }
804
+
805
+ message.cursor = Cursor.decode(reader, reader.uint32());
806
+ continue;
807
+ }
808
+ if ((tag & 7) === 4 || tag === 0) {
809
+ break;
810
+ }
811
+ reader.skipType(tag & 7);
812
+ }
813
+ return message;
814
+ },
815
+
816
+ fromJSON(object: any): Finalize {
817
+ return { cursor: isSet(object.cursor) ? Cursor.fromJSON(object.cursor) : undefined };
818
+ },
819
+
820
+ toJSON(message: Finalize): unknown {
821
+ const obj: any = {};
822
+ if (message.cursor !== undefined) {
823
+ obj.cursor = Cursor.toJSON(message.cursor);
824
+ }
825
+ return obj;
826
+ },
827
+
828
+ create(base?: DeepPartial<Finalize>): Finalize {
829
+ return Finalize.fromPartial(base ?? {});
830
+ },
831
+ fromPartial(object: DeepPartial<Finalize>): Finalize {
832
+ const message = createBaseFinalize() as any;
411
833
  message.cursor = (object.cursor !== undefined && object.cursor !== null)
412
834
  ? Cursor.fromPartial(object.cursor)
413
835
  : undefined;
@@ -730,6 +1152,15 @@ export type DeepPartial<T> = T extends Builtin ? T
730
1152
  : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
731
1153
  : Partial<T>;
732
1154
 
1155
+ function longToBigint(long: Long) {
1156
+ return BigInt(long.toString());
1157
+ }
1158
+
1159
+ if (_m0.util.Long !== Long) {
1160
+ _m0.util.Long = Long as any;
1161
+ _m0.configure();
1162
+ }
1163
+
733
1164
  function isSet(value: any): boolean {
734
1165
  return value !== null && value !== undefined;
735
1166
  }
package/src/status.ts CHANGED
@@ -14,6 +14,8 @@ export const statusRequestFromProto = Schema.decodeSync(StatusRequest);
14
14
  export const StatusResponse = Schema.Struct({
15
15
  currentHead: Schema.optional(Cursor),
16
16
  lastIngested: Schema.optional(Cursor),
17
+ finalized: Schema.optional(Cursor),
18
+ starting: Schema.optional(Cursor),
17
19
  });
18
20
 
19
21
  export type StatusResponse = typeof StatusResponse.Type;
package/src/stream.ts CHANGED
@@ -34,6 +34,11 @@ export const DataFinality = Schema.transform(
34
34
 
35
35
  export type DataFinality = typeof DataFinality.Type;
36
36
 
37
+ export const Duration = Schema.Struct({
38
+ seconds: Schema.BigIntFromSelf,
39
+ nanos: Schema.Number,
40
+ });
41
+
37
42
  /** Create a `StreamDataRequest` with the given filter schema. */
38
43
  export const StreamDataRequest = <TA, TR>(
39
44
  filter: Schema.Schema<TA, Uint8Array, TR>,
@@ -42,6 +47,7 @@ export const StreamDataRequest = <TA, TR>(
42
47
  finality: Schema.optional(DataFinality),
43
48
  startingCursor: Schema.optional(Cursor),
44
49
  filter: Schema.mutable(Schema.Array(filter)),
50
+ heartbeatInterval: Schema.optional(Duration),
45
51
  });
46
52
 
47
53
  export type StreamDataRequest<TA> = {
@@ -59,6 +65,15 @@ export const Invalidate = Schema.Struct({
59
65
 
60
66
  export type Invalidate = typeof Invalidate.Type;
61
67
 
68
+ export const Finalize = Schema.Struct({
69
+ _tag: tag("finalize"),
70
+ finalize: Schema.Struct({
71
+ cursor: Schema.optional(Cursor),
72
+ }),
73
+ });
74
+
75
+ export type Finalize = typeof Finalize.Type;
76
+
62
77
  export const Heartbeat = Schema.Struct({
63
78
  _tag: tag("heartbeat"),
64
79
  });
@@ -103,9 +118,14 @@ export const Data = <TA, TR>(
103
118
 
104
119
  export const StreamDataResponse = <TA, TR>(
105
120
  data: Schema.Schema<TA | null, Uint8Array, TR>,
106
- ) => Schema.Union(Data(data), Invalidate, Heartbeat, SystemMessage);
121
+ ) => Schema.Union(Data(data), Invalidate, Finalize, Heartbeat, SystemMessage);
107
122
 
108
- const ResponseWithoutData = Schema.Union(Invalidate, Heartbeat, SystemMessage);
123
+ const ResponseWithoutData = Schema.Union(
124
+ Invalidate,
125
+ Finalize,
126
+ Heartbeat,
127
+ SystemMessage,
128
+ );
109
129
  type ResponseWithoutData = typeof ResponseWithoutData.Type;
110
130
 
111
131
  export type StreamDataResponse<TA> =