@apibara/protocol 2.1.0-beta.23 → 2.1.0-beta.25
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.
- package/dist/codec.cjs +241 -0
- package/dist/codec.d.cts +81 -0
- package/dist/codec.d.mts +81 -0
- package/dist/codec.d.ts +81 -0
- package/dist/codec.mjs +223 -0
- package/dist/index.cjs +15 -29
- package/dist/index.d.cts +3 -4
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.mjs +14 -19
- package/dist/shared/{protocol.4b1cfe2c.d.cts → protocol.68a15d69.d.mts} +398 -247
- package/dist/shared/{protocol.4b1cfe2c.d.mts → protocol.8b5e318a.d.ts} +398 -247
- package/dist/shared/{protocol.991ff9ad.mjs → protocol.a64f7660.mjs} +173 -170
- package/dist/shared/{protocol.e39e40d6.cjs → protocol.d8bad371.cjs} +174 -176
- package/dist/shared/{protocol.4b1cfe2c.d.ts → protocol.f52df848.d.cts} +398 -247
- package/dist/testing/index.cjs +23 -37
- package/dist/testing/index.d.cts +107 -54
- package/dist/testing/index.d.mts +107 -54
- package/dist/testing/index.d.ts +107 -54
- package/dist/testing/index.mjs +23 -37
- package/package.json +7 -3
- package/src/client.ts +7 -12
- package/src/codec.ts +662 -0
- package/src/common.ts +70 -53
- package/src/config.ts +3 -4
- package/src/proto/google/protobuf/duration.ts +8 -6
- package/src/proto/stream.ts +38 -24
- package/src/status.ts +9 -16
- package/src/stream.ts +145 -144
- package/src/testing/mock.ts +35 -38
- package/src/common.test.ts +0 -67
- package/src/status.test.ts +0 -51
- package/src/stream.test-d.ts +0 -33
- package/src/stream.test.ts +0 -254
- package/src/testing/client.test.ts +0 -97
- package/src/testing/mock.test.ts +0 -35
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DefaultCallOptions, NormalizedServiceDefinition, ChannelCredentials, ChannelOptions } from 'nice-grpc';
|
|
1
|
+
import { Codec, CodecProto, CodecType, MessageCodec } from '../codec.cjs';
|
|
3
2
|
import { CallContext, CallOptions } from 'nice-grpc-common';
|
|
4
3
|
import _m0 from 'protobufjs/minimal.js';
|
|
5
|
-
import
|
|
4
|
+
import { DefaultCallOptions, NormalizedServiceDefinition, ChannelCredentials, ChannelOptions } from 'nice-grpc';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* A Duration represents a signed, fixed-length span of time represented
|
|
@@ -70,7 +69,7 @@ interface Duration$1 {
|
|
|
70
69
|
* to +315,576,000,000 inclusive. Note: these bounds are computed from:
|
|
71
70
|
* 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
|
|
72
71
|
*/
|
|
73
|
-
readonly seconds
|
|
72
|
+
readonly seconds?: bigint | undefined;
|
|
74
73
|
/**
|
|
75
74
|
* Signed fractions of a second at nanosecond resolution of the span
|
|
76
75
|
* of time. Durations less than one second are represented with a 0
|
|
@@ -79,7 +78,7 @@ interface Duration$1 {
|
|
|
79
78
|
* of the same sign as the `seconds` field. Must be from -999,999,999
|
|
80
79
|
* to +999,999,999 inclusive.
|
|
81
80
|
*/
|
|
82
|
-
readonly nanos
|
|
81
|
+
readonly nanos?: number | undefined;
|
|
83
82
|
}
|
|
84
83
|
declare const Duration$1: {
|
|
85
84
|
encode(message: Duration$1, writer?: _m0.Writer): _m0.Writer;
|
|
@@ -133,13 +132,13 @@ interface Cursor$1 {
|
|
|
133
132
|
*
|
|
134
133
|
* This is usually the block or slot number.
|
|
135
134
|
*/
|
|
136
|
-
readonly orderKey
|
|
135
|
+
readonly orderKey?: bigint | undefined;
|
|
137
136
|
/**
|
|
138
137
|
* Key used to discriminate branches in the stream.
|
|
139
138
|
*
|
|
140
139
|
* This is usually the hash of the block.
|
|
141
140
|
*/
|
|
142
|
-
readonly uniqueKey
|
|
141
|
+
readonly uniqueKey?: Uint8Array | undefined;
|
|
143
142
|
}
|
|
144
143
|
declare const Cursor$1: {
|
|
145
144
|
encode(message: Cursor$1, writer?: _m0.Writer): _m0.Writer;
|
|
@@ -195,7 +194,7 @@ interface StreamDataRequest$1 {
|
|
|
195
194
|
*/
|
|
196
195
|
readonly finality?: DataFinality$1 | undefined;
|
|
197
196
|
/** Filters used to generate data. */
|
|
198
|
-
readonly filter
|
|
197
|
+
readonly filter?: readonly Uint8Array[] | undefined;
|
|
199
198
|
/**
|
|
200
199
|
* Heartbeat interval.
|
|
201
200
|
*
|
|
@@ -248,7 +247,7 @@ interface Invalidate$1 {
|
|
|
248
247
|
*/
|
|
249
248
|
readonly cursor?: Cursor$1 | undefined;
|
|
250
249
|
/** List of blocks that were removed from the chain. */
|
|
251
|
-
readonly removed
|
|
250
|
+
readonly removed?: readonly Cursor$1[] | undefined;
|
|
252
251
|
}
|
|
253
252
|
declare const Invalidate$1: {
|
|
254
253
|
encode(message: Invalidate$1, writer?: _m0.Writer): _m0.Writer;
|
|
@@ -290,15 +289,15 @@ interface Data$1 {
|
|
|
290
289
|
/** Block cursor. Use this cursor to resume the stream. */
|
|
291
290
|
readonly endCursor?: Cursor$1 | undefined;
|
|
292
291
|
/** The finality status of the block. */
|
|
293
|
-
readonly finality
|
|
292
|
+
readonly finality?: DataFinality$1 | undefined;
|
|
294
293
|
/**
|
|
295
294
|
* The block data.
|
|
296
295
|
*
|
|
297
296
|
* This message contains chain-specific data serialized using protobuf.
|
|
298
297
|
*/
|
|
299
|
-
readonly data
|
|
298
|
+
readonly data?: readonly Uint8Array[] | undefined;
|
|
300
299
|
/** The production mode of the block. */
|
|
301
|
-
readonly production
|
|
300
|
+
readonly production?: DataProduction$1 | undefined;
|
|
302
301
|
}
|
|
303
302
|
declare const Data$1: {
|
|
304
303
|
encode(message: Data$1, writer?: _m0.Writer): _m0.Writer;
|
|
@@ -431,28 +430,20 @@ declare namespace stream {
|
|
|
431
430
|
}
|
|
432
431
|
|
|
433
432
|
/** Bytes encoded as a 0x-prefixed hex string. */
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
/** The block hash, if any. */
|
|
442
|
-
uniqueKey: Schema.PropertySignature<"?:", `0x${string}`, never, ":", Uint8Array, false, never>;
|
|
443
|
-
}>;
|
|
433
|
+
type Bytes = `0x${string}`;
|
|
434
|
+
declare const BytesFromUint8Array: Codec<`0x${string}` | undefined, Uint8Array | undefined>;
|
|
435
|
+
type _CursorApp = {
|
|
436
|
+
orderKey: bigint;
|
|
437
|
+
uniqueKey?: Bytes | undefined;
|
|
438
|
+
};
|
|
439
|
+
type _CursorProto = Cursor$1;
|
|
444
440
|
/** The Cursor protobuf representation. */
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
declare const
|
|
450
|
-
declare const
|
|
451
|
-
declare const cursorToProto: (a: Cursor, overrideOptions?: _effect_schema_AST.ParseOptions) => CursorProto;
|
|
452
|
-
declare const cursorFromProto: (i: CursorProto, overrideOptions?: _effect_schema_AST.ParseOptions) => Cursor;
|
|
453
|
-
declare const CursorFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8Array, never>, Schema.Schema<Cursor, CursorProto, never>>;
|
|
454
|
-
declare const cursorToBytes: (a: Cursor, overrideOptions?: _effect_schema_AST.ParseOptions) => Uint8Array;
|
|
455
|
-
declare const cursorFromBytes: (i: Uint8Array, overrideOptions?: _effect_schema_AST.ParseOptions) => Cursor;
|
|
441
|
+
type CursorProto = CodecProto<typeof Cursor>;
|
|
442
|
+
/** Represent a position in the stream. */
|
|
443
|
+
declare const Cursor: Codec<_CursorApp, _CursorProto>;
|
|
444
|
+
type Cursor = CodecType<typeof Cursor>;
|
|
445
|
+
declare const createCursor: (props: Cursor) => _CursorApp;
|
|
446
|
+
declare const CursorFromBytes: Codec<Cursor, Uint8Array>;
|
|
456
447
|
declare function isCursor(value: unknown): value is Cursor;
|
|
457
448
|
/** Normalize a cursor.
|
|
458
449
|
*
|
|
@@ -467,185 +458,269 @@ declare function normalizeCursor(cursor: {
|
|
|
467
458
|
}): Cursor;
|
|
468
459
|
|
|
469
460
|
/** The request to the `status` endpoint. */
|
|
470
|
-
declare const StatusRequest:
|
|
471
|
-
type StatusRequest = typeof StatusRequest
|
|
472
|
-
declare const statusRequestToProto: (a: {}, overrideOptions?: _effect_schema_AST.ParseOptions) => {};
|
|
473
|
-
declare const statusRequestFromProto: (i: {}, overrideOptions?: _effect_schema_AST.ParseOptions) => {};
|
|
461
|
+
declare const StatusRequest: MessageCodec<{}>;
|
|
462
|
+
type StatusRequest = CodecType<typeof StatusRequest>;
|
|
474
463
|
/** The response from the `status` endpoint. */
|
|
475
|
-
declare const StatusResponse:
|
|
476
|
-
currentHead:
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
464
|
+
declare const StatusResponse: MessageCodec<{
|
|
465
|
+
currentHead: Codec<{
|
|
466
|
+
orderKey: bigint;
|
|
467
|
+
uniqueKey?: Bytes | undefined;
|
|
468
|
+
} | undefined, Cursor$1 | undefined>;
|
|
469
|
+
lastIngested: Codec<{
|
|
470
|
+
orderKey: bigint;
|
|
471
|
+
uniqueKey?: Bytes | undefined;
|
|
472
|
+
} | undefined, Cursor$1 | undefined>;
|
|
473
|
+
finalized: Codec<{
|
|
474
|
+
orderKey: bigint;
|
|
475
|
+
uniqueKey?: Bytes | undefined;
|
|
476
|
+
} | undefined, Cursor$1 | undefined>;
|
|
477
|
+
starting: Codec<{
|
|
478
|
+
orderKey: bigint;
|
|
479
|
+
uniqueKey?: Bytes | undefined;
|
|
480
|
+
} | undefined, Cursor$1 | undefined>;
|
|
480
481
|
}>;
|
|
481
|
-
type StatusResponse = typeof StatusResponse
|
|
482
|
-
declare const statusResponseToProto: (a: {
|
|
483
|
-
readonly currentHead?: Cursor | undefined;
|
|
484
|
-
readonly lastIngested?: Cursor | undefined;
|
|
485
|
-
readonly finalized?: Cursor | undefined;
|
|
486
|
-
readonly starting?: Cursor | undefined;
|
|
487
|
-
}, overrideOptions?: _effect_schema_AST.ParseOptions) => {
|
|
488
|
-
readonly currentHead?: CursorProto | undefined;
|
|
489
|
-
readonly lastIngested?: CursorProto | undefined;
|
|
490
|
-
readonly finalized?: CursorProto | undefined;
|
|
491
|
-
readonly starting?: CursorProto | undefined;
|
|
492
|
-
};
|
|
493
|
-
declare const statusResponseFromProto: (i: {
|
|
494
|
-
readonly currentHead?: CursorProto | undefined;
|
|
495
|
-
readonly lastIngested?: CursorProto | undefined;
|
|
496
|
-
readonly finalized?: CursorProto | undefined;
|
|
497
|
-
readonly starting?: CursorProto | undefined;
|
|
498
|
-
}, overrideOptions?: _effect_schema_AST.ParseOptions) => {
|
|
499
|
-
readonly currentHead?: Cursor | undefined;
|
|
500
|
-
readonly lastIngested?: Cursor | undefined;
|
|
501
|
-
readonly finalized?: Cursor | undefined;
|
|
502
|
-
readonly starting?: Cursor | undefined;
|
|
503
|
-
};
|
|
482
|
+
type StatusResponse = CodecType<typeof StatusResponse>;
|
|
504
483
|
|
|
505
484
|
/** Data finality. */
|
|
506
|
-
declare const DataFinality:
|
|
507
|
-
type DataFinality = typeof DataFinality
|
|
485
|
+
declare const DataFinality: Codec<"finalized" | "accepted" | "pending" | "unknown", DataFinality$1>;
|
|
486
|
+
type DataFinality = CodecType<typeof DataFinality>;
|
|
508
487
|
/** Data production mode. */
|
|
509
|
-
declare const DataProduction:
|
|
510
|
-
type DataProduction = typeof DataProduction
|
|
511
|
-
declare const
|
|
512
|
-
seconds:
|
|
513
|
-
nanos:
|
|
488
|
+
declare const DataProduction: Codec<"backfill" | "live" | "unknown", DataProduction$1>;
|
|
489
|
+
type DataProduction = CodecType<typeof DataProduction>;
|
|
490
|
+
declare const DurationCodec: MessageCodec<{
|
|
491
|
+
seconds: Codec<bigint, bigint>;
|
|
492
|
+
nanos: Codec<number, number>;
|
|
514
493
|
}>;
|
|
494
|
+
type Duration = CodecType<typeof DurationCodec>;
|
|
515
495
|
/** Create a `StreamDataRequest` with the given filter schema. */
|
|
516
|
-
declare const StreamDataRequest: <TA
|
|
517
|
-
finality:
|
|
518
|
-
startingCursor:
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
}
|
|
530
|
-
declare const Invalidate: Schema.Struct<{
|
|
531
|
-
_tag: Schema.PropertySignature<":", "invalidate", "$case", ":", "invalidate", false, never>;
|
|
532
|
-
invalidate: Schema.Struct<{
|
|
533
|
-
cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
|
|
534
|
-
}>;
|
|
535
|
-
}>;
|
|
536
|
-
type Invalidate = typeof Invalidate.Type;
|
|
537
|
-
declare const Finalize: Schema.Struct<{
|
|
538
|
-
_tag: Schema.PropertySignature<":", "finalize", "$case", ":", "finalize", false, never>;
|
|
539
|
-
finalize: Schema.Struct<{
|
|
540
|
-
cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
|
|
541
|
-
}>;
|
|
496
|
+
declare const StreamDataRequest: <TA>(filter: Codec<TA, Uint8Array>) => MessageCodec<{
|
|
497
|
+
finality: Codec<"finalized" | "accepted" | "pending" | "unknown" | undefined, DataFinality$1 | undefined>;
|
|
498
|
+
startingCursor: Codec<{
|
|
499
|
+
orderKey: bigint;
|
|
500
|
+
uniqueKey?: Bytes | undefined;
|
|
501
|
+
} | undefined, Cursor$1 | undefined>;
|
|
502
|
+
filter: Codec<TA[], Uint8Array[]>;
|
|
503
|
+
heartbeatInterval: Codec<{
|
|
504
|
+
seconds: bigint;
|
|
505
|
+
nanos: number;
|
|
506
|
+
} | undefined, {
|
|
507
|
+
seconds: bigint;
|
|
508
|
+
nanos: number;
|
|
509
|
+
} | undefined>;
|
|
542
510
|
}>;
|
|
543
|
-
type
|
|
544
|
-
declare const
|
|
545
|
-
|
|
511
|
+
type StreamDataRequest<TA> = CodecType<ReturnType<typeof StreamDataRequest<TA>>>;
|
|
512
|
+
declare const Invalidate: MessageCodec<{
|
|
513
|
+
cursor: Codec<{
|
|
514
|
+
orderKey: bigint;
|
|
515
|
+
uniqueKey?: Bytes | undefined;
|
|
516
|
+
} | undefined, Cursor$1 | undefined>;
|
|
546
517
|
}>;
|
|
547
|
-
type
|
|
548
|
-
declare const
|
|
549
|
-
|
|
550
|
-
|
|
518
|
+
type Invalidate = CodecType<typeof Invalidate>;
|
|
519
|
+
declare const Finalize: MessageCodec<{
|
|
520
|
+
cursor: Codec<{
|
|
521
|
+
orderKey: bigint;
|
|
522
|
+
uniqueKey?: Bytes | undefined;
|
|
523
|
+
} | undefined, Cursor$1 | undefined>;
|
|
551
524
|
}>;
|
|
552
|
-
type
|
|
553
|
-
declare const
|
|
554
|
-
|
|
555
|
-
|
|
525
|
+
type Finalize = CodecType<typeof Finalize>;
|
|
526
|
+
declare const Heartbeat: Codec<undefined, undefined>;
|
|
527
|
+
type Heartbeat = CodecType<typeof Heartbeat>;
|
|
528
|
+
declare const StdOut: Codec<string, string>;
|
|
529
|
+
type StdOut = CodecType<typeof StdOut>;
|
|
530
|
+
declare const StdErr: Codec<string, string>;
|
|
531
|
+
type StdErr = CodecType<typeof StdErr>;
|
|
532
|
+
declare const SystemMessage: MessageCodec<{
|
|
533
|
+
output: Codec<({
|
|
534
|
+
_tag: "stdout";
|
|
535
|
+
} & {
|
|
536
|
+
stdout: string;
|
|
537
|
+
}) | ({
|
|
538
|
+
_tag: "stderr";
|
|
539
|
+
} & {
|
|
540
|
+
stderr: string;
|
|
541
|
+
}), ({
|
|
542
|
+
$case: "stdout";
|
|
543
|
+
} & {
|
|
544
|
+
stdout: string;
|
|
545
|
+
}) | ({
|
|
546
|
+
$case: "stderr";
|
|
547
|
+
} & {
|
|
548
|
+
stderr: string;
|
|
549
|
+
})>;
|
|
556
550
|
}>;
|
|
557
|
-
type
|
|
558
|
-
declare const
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
type SystemMessage = typeof SystemMessage.Type;
|
|
571
|
-
declare const Data: <TA, TR>(schema: Schema.Schema<TA | null, Uint8Array, TR>) => Schema.Struct<{
|
|
572
|
-
_tag: Schema.PropertySignature<":", "data", "$case", ":", "data", false, never>;
|
|
573
|
-
data: Schema.Struct<{
|
|
574
|
-
cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
|
|
575
|
-
endCursor: Schema.Schema<Cursor, CursorProto, never>;
|
|
576
|
-
finality: Schema.transform<Schema.Enums<typeof DataFinality$1>, Schema.Literal<["finalized", "accepted", "pending", "unknown"]>>;
|
|
577
|
-
production: Schema.transform<Schema.Enums<typeof DataProduction$1>, Schema.Literal<["backfill", "live", "unknown"]>>;
|
|
578
|
-
data: Schema.Array$<Schema.Schema<TA | null, Uint8Array, TR>>;
|
|
579
|
-
}>;
|
|
551
|
+
type SystemMessage = CodecType<typeof SystemMessage>;
|
|
552
|
+
declare const Data: <TA>(schema: Codec<TA | null, Uint8Array>) => MessageCodec<{
|
|
553
|
+
cursor: Codec<{
|
|
554
|
+
orderKey: bigint;
|
|
555
|
+
uniqueKey?: Bytes | undefined;
|
|
556
|
+
} | undefined, Cursor$1 | undefined>;
|
|
557
|
+
endCursor: Codec<{
|
|
558
|
+
orderKey: bigint;
|
|
559
|
+
uniqueKey?: Bytes | undefined;
|
|
560
|
+
}, Cursor$1>;
|
|
561
|
+
finality: Codec<"finalized" | "accepted" | "pending" | "unknown", DataFinality$1>;
|
|
562
|
+
production: Codec<"unknown" | "backfill" | "live", DataProduction$1>;
|
|
563
|
+
data: Codec<readonly (TA | null)[], readonly Uint8Array[] | undefined>;
|
|
580
564
|
}>;
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
_tag:
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
|
|
565
|
+
type Data<TA> = CodecType<ReturnType<typeof Data<TA>>>;
|
|
566
|
+
declare const ResponseWithoutData: Codec<({
|
|
567
|
+
_tag: "invalidate";
|
|
568
|
+
} & {
|
|
569
|
+
invalidate: {
|
|
570
|
+
cursor?: {
|
|
571
|
+
orderKey: bigint;
|
|
572
|
+
uniqueKey?: Bytes | undefined;
|
|
573
|
+
} | undefined;
|
|
574
|
+
};
|
|
575
|
+
}) | ({
|
|
576
|
+
_tag: "finalize";
|
|
577
|
+
} & {
|
|
578
|
+
finalize: {
|
|
579
|
+
cursor?: {
|
|
580
|
+
orderKey: bigint;
|
|
581
|
+
uniqueKey?: Bytes | undefined;
|
|
582
|
+
} | undefined;
|
|
583
|
+
};
|
|
584
|
+
}) | {
|
|
585
|
+
_tag: "heartbeat";
|
|
586
|
+
} | ({
|
|
587
|
+
_tag: "systemMessage";
|
|
588
|
+
} & {
|
|
589
|
+
systemMessage: {
|
|
590
|
+
output: ({
|
|
591
|
+
_tag: "stdout";
|
|
592
|
+
} & {
|
|
593
|
+
stdout: string;
|
|
594
|
+
}) | ({
|
|
595
|
+
_tag: "stderr";
|
|
596
|
+
} & {
|
|
597
|
+
stderr: string;
|
|
598
|
+
});
|
|
599
|
+
};
|
|
600
|
+
}), ({
|
|
601
|
+
$case: "invalidate";
|
|
602
|
+
} & {
|
|
603
|
+
invalidate: {
|
|
604
|
+
cursor?: Cursor$1 | undefined;
|
|
605
|
+
};
|
|
606
|
+
}) | ({
|
|
607
|
+
$case: "finalize";
|
|
608
|
+
} & {
|
|
609
|
+
finalize: {
|
|
610
|
+
cursor?: Cursor$1 | undefined;
|
|
611
|
+
};
|
|
612
|
+
}) | ({
|
|
613
|
+
$case: "heartbeat";
|
|
614
|
+
} & {
|
|
615
|
+
heartbeat: undefined;
|
|
616
|
+
}) | ({
|
|
617
|
+
$case: "systemMessage";
|
|
618
|
+
} & {
|
|
619
|
+
systemMessage: {
|
|
620
|
+
output: ({
|
|
621
|
+
$case: "stdout";
|
|
622
|
+
} & {
|
|
623
|
+
stdout: string;
|
|
624
|
+
}) | ({
|
|
625
|
+
$case: "stderr";
|
|
626
|
+
} & {
|
|
627
|
+
stderr: string;
|
|
628
|
+
});
|
|
629
|
+
};
|
|
630
|
+
})>;
|
|
631
|
+
type ResponseWithoutData = CodecType<typeof ResponseWithoutData>;
|
|
632
|
+
declare const StreamDataResponse: <TA>(schema: Codec<TA | null, Uint8Array>) => Codec<{
|
|
633
|
+
_tag: "heartbeat";
|
|
634
|
+
} | ({
|
|
640
635
|
_tag: "data";
|
|
636
|
+
} & {
|
|
641
637
|
data: {
|
|
642
|
-
cursor?:
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
638
|
+
cursor?: {
|
|
639
|
+
orderKey: bigint;
|
|
640
|
+
uniqueKey?: Bytes | undefined;
|
|
641
|
+
} | undefined;
|
|
642
|
+
endCursor: {
|
|
643
|
+
orderKey: bigint;
|
|
644
|
+
uniqueKey?: Bytes | undefined;
|
|
645
|
+
};
|
|
646
|
+
finality: "finalized" | "accepted" | "pending" | "unknown";
|
|
647
|
+
production: "unknown" | "backfill" | "live";
|
|
646
648
|
data: readonly (TA | null)[];
|
|
647
649
|
};
|
|
648
|
-
}
|
|
650
|
+
}) | ({
|
|
651
|
+
_tag: "invalidate";
|
|
652
|
+
} & {
|
|
653
|
+
invalidate: {
|
|
654
|
+
cursor?: {
|
|
655
|
+
orderKey: bigint;
|
|
656
|
+
uniqueKey?: Bytes | undefined;
|
|
657
|
+
} | undefined;
|
|
658
|
+
};
|
|
659
|
+
}) | ({
|
|
660
|
+
_tag: "finalize";
|
|
661
|
+
} & {
|
|
662
|
+
finalize: {
|
|
663
|
+
cursor?: {
|
|
664
|
+
orderKey: bigint;
|
|
665
|
+
uniqueKey?: Bytes | undefined;
|
|
666
|
+
} | undefined;
|
|
667
|
+
};
|
|
668
|
+
}) | ({
|
|
669
|
+
_tag: "systemMessage";
|
|
670
|
+
} & {
|
|
671
|
+
systemMessage: {
|
|
672
|
+
output: ({
|
|
673
|
+
_tag: "stdout";
|
|
674
|
+
} & {
|
|
675
|
+
stdout: string;
|
|
676
|
+
}) | ({
|
|
677
|
+
_tag: "stderr";
|
|
678
|
+
} & {
|
|
679
|
+
stderr: string;
|
|
680
|
+
});
|
|
681
|
+
};
|
|
682
|
+
}), ({
|
|
683
|
+
$case: "data";
|
|
684
|
+
} & {
|
|
685
|
+
data: {
|
|
686
|
+
cursor?: Cursor$1 | undefined;
|
|
687
|
+
endCursor: Cursor$1;
|
|
688
|
+
finality: DataFinality$1;
|
|
689
|
+
production: DataProduction$1;
|
|
690
|
+
data?: readonly Uint8Array[] | undefined;
|
|
691
|
+
};
|
|
692
|
+
}) | ({
|
|
693
|
+
$case: "invalidate";
|
|
694
|
+
} & {
|
|
695
|
+
invalidate: {
|
|
696
|
+
cursor?: Cursor$1 | undefined;
|
|
697
|
+
};
|
|
698
|
+
}) | ({
|
|
699
|
+
$case: "finalize";
|
|
700
|
+
} & {
|
|
701
|
+
finalize: {
|
|
702
|
+
cursor?: Cursor$1 | undefined;
|
|
703
|
+
};
|
|
704
|
+
}) | ({
|
|
705
|
+
$case: "heartbeat";
|
|
706
|
+
} & {
|
|
707
|
+
heartbeat: undefined;
|
|
708
|
+
}) | ({
|
|
709
|
+
$case: "systemMessage";
|
|
710
|
+
} & {
|
|
711
|
+
systemMessage: {
|
|
712
|
+
output: ({
|
|
713
|
+
$case: "stdout";
|
|
714
|
+
} & {
|
|
715
|
+
stdout: string;
|
|
716
|
+
}) | ({
|
|
717
|
+
$case: "stderr";
|
|
718
|
+
} & {
|
|
719
|
+
stderr: string;
|
|
720
|
+
});
|
|
721
|
+
};
|
|
722
|
+
})>;
|
|
723
|
+
type StreamDataResponse<TA> = CodecType<ReturnType<typeof StreamDataResponse<TA>>>;
|
|
649
724
|
|
|
650
725
|
/** Configure a DNA stream. */
|
|
651
726
|
declare class StreamConfig<TFilter, TBlock> {
|
|
@@ -654,55 +729,119 @@ declare class StreamConfig<TFilter, TBlock> {
|
|
|
654
729
|
mergeFilter: (a: TFilter, b: TFilter) => TFilter;
|
|
655
730
|
private request;
|
|
656
731
|
private response;
|
|
657
|
-
constructor(filter:
|
|
732
|
+
constructor(filter: Codec<TFilter, Uint8Array>, block: Codec<TBlock | null, Uint8Array>, mergeFilter: (a: TFilter, b: TFilter) => TFilter);
|
|
658
733
|
/** Filter schema. */
|
|
659
|
-
get Filter():
|
|
734
|
+
get Filter(): Codec<TFilter, Uint8Array>;
|
|
660
735
|
/** Block schema. */
|
|
661
|
-
get Block():
|
|
736
|
+
get Block(): Codec<TBlock | null, Uint8Array>;
|
|
662
737
|
/** Stream data request schema. */
|
|
663
|
-
get Request():
|
|
664
|
-
finality:
|
|
665
|
-
startingCursor:
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
738
|
+
get Request(): MessageCodec<{
|
|
739
|
+
finality: Codec<"finalized" | "accepted" | "pending" | "unknown" | undefined, DataFinality$1 | undefined>;
|
|
740
|
+
startingCursor: Codec<{
|
|
741
|
+
orderKey: bigint;
|
|
742
|
+
uniqueKey?: Bytes | undefined;
|
|
743
|
+
} | undefined, Cursor$1 | undefined>;
|
|
744
|
+
filter: Codec<TFilter[], Uint8Array[]>;
|
|
745
|
+
heartbeatInterval: Codec<{
|
|
746
|
+
seconds: bigint;
|
|
747
|
+
nanos: number;
|
|
748
|
+
} | undefined, {
|
|
749
|
+
seconds: bigint;
|
|
750
|
+
nanos: number;
|
|
751
|
+
} | undefined>;
|
|
671
752
|
}>;
|
|
672
753
|
/** Stream data response schema. */
|
|
673
|
-
get Response():
|
|
674
|
-
_tag:
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
754
|
+
get Response(): Codec<{
|
|
755
|
+
_tag: "heartbeat";
|
|
756
|
+
} | ({
|
|
757
|
+
_tag: "data";
|
|
758
|
+
} & {
|
|
759
|
+
data: {
|
|
760
|
+
cursor?: {
|
|
761
|
+
orderKey: bigint;
|
|
762
|
+
uniqueKey?: Bytes | undefined;
|
|
763
|
+
} | undefined;
|
|
764
|
+
endCursor: {
|
|
765
|
+
orderKey: bigint;
|
|
766
|
+
uniqueKey?: Bytes | undefined;
|
|
767
|
+
};
|
|
768
|
+
finality: "finalized" | "accepted" | "pending" | "unknown";
|
|
769
|
+
production: "unknown" | "backfill" | "live";
|
|
770
|
+
data: readonly (TBlock | null)[];
|
|
771
|
+
};
|
|
772
|
+
}) | ({
|
|
773
|
+
_tag: "invalidate";
|
|
774
|
+
} & {
|
|
775
|
+
invalidate: {
|
|
776
|
+
cursor?: {
|
|
777
|
+
orderKey: bigint;
|
|
778
|
+
uniqueKey?: Bytes | undefined;
|
|
779
|
+
} | undefined;
|
|
780
|
+
};
|
|
781
|
+
}) | ({
|
|
782
|
+
_tag: "finalize";
|
|
783
|
+
} & {
|
|
784
|
+
finalize: {
|
|
785
|
+
cursor?: {
|
|
786
|
+
orderKey: bigint;
|
|
787
|
+
uniqueKey?: Bytes | undefined;
|
|
788
|
+
} | undefined;
|
|
789
|
+
};
|
|
790
|
+
}) | ({
|
|
791
|
+
_tag: "systemMessage";
|
|
792
|
+
} & {
|
|
793
|
+
systemMessage: {
|
|
794
|
+
output: ({
|
|
795
|
+
_tag: "stdout";
|
|
796
|
+
} & {
|
|
797
|
+
stdout: string;
|
|
798
|
+
}) | ({
|
|
799
|
+
_tag: "stderr";
|
|
800
|
+
} & {
|
|
801
|
+
stderr: string;
|
|
802
|
+
});
|
|
803
|
+
};
|
|
804
|
+
}), ({
|
|
805
|
+
$case: "data";
|
|
806
|
+
} & {
|
|
807
|
+
data: {
|
|
808
|
+
cursor?: Cursor$1 | undefined;
|
|
809
|
+
endCursor: Cursor$1;
|
|
810
|
+
finality: DataFinality$1;
|
|
811
|
+
production: DataProduction$1;
|
|
812
|
+
data?: readonly Uint8Array[] | undefined;
|
|
813
|
+
};
|
|
814
|
+
}) | ({
|
|
815
|
+
$case: "invalidate";
|
|
816
|
+
} & {
|
|
817
|
+
invalidate: {
|
|
818
|
+
cursor?: Cursor$1 | undefined;
|
|
819
|
+
};
|
|
820
|
+
}) | ({
|
|
821
|
+
$case: "finalize";
|
|
822
|
+
} & {
|
|
823
|
+
finalize: {
|
|
824
|
+
cursor?: Cursor$1 | undefined;
|
|
825
|
+
};
|
|
826
|
+
}) | ({
|
|
827
|
+
$case: "heartbeat";
|
|
828
|
+
} & {
|
|
829
|
+
heartbeat: undefined;
|
|
830
|
+
}) | ({
|
|
831
|
+
$case: "systemMessage";
|
|
832
|
+
} & {
|
|
833
|
+
systemMessage: {
|
|
834
|
+
output: ({
|
|
835
|
+
$case: "stdout";
|
|
836
|
+
} & {
|
|
837
|
+
stdout: string;
|
|
838
|
+
}) | ({
|
|
839
|
+
$case: "stderr";
|
|
840
|
+
} & {
|
|
841
|
+
stderr: string;
|
|
842
|
+
});
|
|
843
|
+
};
|
|
844
|
+
})>;
|
|
706
845
|
}
|
|
707
846
|
|
|
708
847
|
declare class TimeoutError extends Error {
|
|
@@ -738,19 +877,31 @@ declare class GrpcClient<TFilter, TBlock> implements Client<TFilter, TBlock> {
|
|
|
738
877
|
private encodeRequest;
|
|
739
878
|
constructor(config: StreamConfig<TFilter, TBlock>, client: DnaStreamClient);
|
|
740
879
|
status(request?: StatusRequest, options?: ClientCallOptions): Promise<{
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
880
|
+
currentHead?: {
|
|
881
|
+
orderKey: bigint;
|
|
882
|
+
uniqueKey?: Bytes | undefined;
|
|
883
|
+
} | undefined;
|
|
884
|
+
lastIngested?: {
|
|
885
|
+
orderKey: bigint;
|
|
886
|
+
uniqueKey?: Bytes | undefined;
|
|
887
|
+
} | undefined;
|
|
888
|
+
finalized?: {
|
|
889
|
+
orderKey: bigint;
|
|
890
|
+
uniqueKey?: Bytes | undefined;
|
|
891
|
+
} | undefined;
|
|
892
|
+
starting?: {
|
|
893
|
+
orderKey: bigint;
|
|
894
|
+
uniqueKey?: Bytes | undefined;
|
|
895
|
+
} | undefined;
|
|
745
896
|
}>;
|
|
746
|
-
streamData(request: StreamDataRequest<TFilter>, options?: StreamDataOptions): StreamDataIterable<TBlock>;
|
|
897
|
+
streamData(request: StreamDataRequest<TFilter>, options?: StreamDataOptions): StreamDataIterable<TBlock | null>;
|
|
747
898
|
}
|
|
748
899
|
declare class StreamDataIterable<TBlock> {
|
|
749
900
|
private it;
|
|
750
901
|
private schema;
|
|
751
902
|
private options?;
|
|
752
|
-
constructor(it: AsyncIterable<StreamDataResponse$1>, schema:
|
|
903
|
+
constructor(it: AsyncIterable<StreamDataResponse$1>, schema: Codec<TBlock, Uint8Array>, options?: StreamDataOptions | undefined);
|
|
753
904
|
[Symbol.asyncIterator](): AsyncIterator<StreamDataResponse<TBlock>>;
|
|
754
905
|
}
|
|
755
906
|
|
|
756
|
-
export {
|
|
907
|
+
export { Cursor$1 as A, type Bytes as B, Cursor as C, type DnaStreamClient as D, DataFinality$1 as E, Finalize as F, GrpcClient as G, Heartbeat as H, Invalidate as I, DataProduction$1 as J, ResponseWithoutData as R, StatusRequest as S, TimeoutError as T, DnaStreamDefinition as a, BytesFromUint8Array as b, type CursorProto as c, createCursor as d, CursorFromBytes as e, StatusResponse as f, DataFinality as g, DataProduction as h, isCursor as i, DurationCodec as j, type Duration as k, StreamDataRequest as l, StdOut as m, normalizeCursor as n, StdErr as o, SystemMessage as p, Data as q, StreamDataResponse as r, stream as s, StreamConfig as t, type ClientCallOptions as u, type StreamDataOptions as v, type Client as w, type CreateClientOptions as x, createClient as y, StreamDataIterable as z };
|