@apibara/protocol 2.1.0-beta.23 → 2.1.0-beta.24

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 (36) hide show
  1. package/dist/codec.cjs +241 -0
  2. package/dist/codec.d.cts +81 -0
  3. package/dist/codec.d.mts +81 -0
  4. package/dist/codec.d.ts +81 -0
  5. package/dist/codec.mjs +223 -0
  6. package/dist/index.cjs +15 -29
  7. package/dist/index.d.cts +3 -4
  8. package/dist/index.d.mts +3 -4
  9. package/dist/index.d.ts +3 -4
  10. package/dist/index.mjs +14 -19
  11. package/dist/shared/{protocol.4b1cfe2c.d.cts → protocol.68a15d69.d.mts} +398 -247
  12. package/dist/shared/{protocol.4b1cfe2c.d.mts → protocol.8b5e318a.d.ts} +398 -247
  13. package/dist/shared/{protocol.991ff9ad.mjs → protocol.a64f7660.mjs} +173 -170
  14. package/dist/shared/{protocol.e39e40d6.cjs → protocol.d8bad371.cjs} +174 -176
  15. package/dist/shared/{protocol.4b1cfe2c.d.ts → protocol.f52df848.d.cts} +398 -247
  16. package/dist/testing/index.cjs +23 -37
  17. package/dist/testing/index.d.cts +107 -54
  18. package/dist/testing/index.d.mts +107 -54
  19. package/dist/testing/index.d.ts +107 -54
  20. package/dist/testing/index.mjs +23 -37
  21. package/package.json +7 -3
  22. package/src/client.ts +7 -12
  23. package/src/codec.ts +662 -0
  24. package/src/common.ts +70 -53
  25. package/src/config.ts +3 -4
  26. package/src/proto/google/protobuf/duration.ts +8 -6
  27. package/src/proto/stream.ts +38 -24
  28. package/src/status.ts +9 -16
  29. package/src/stream.ts +145 -144
  30. package/src/testing/mock.ts +35 -38
  31. package/src/common.test.ts +0 -67
  32. package/src/status.test.ts +0 -51
  33. package/src/stream.test-d.ts +0 -33
  34. package/src/stream.test.ts +0 -254
  35. package/src/testing/client.test.ts +0 -97
  36. package/src/testing/mock.test.ts +0 -35
@@ -1,8 +1,7 @@
1
- import { Schema } from '@effect/schema';
2
- import { DefaultCallOptions, NormalizedServiceDefinition, ChannelCredentials, ChannelOptions } from 'nice-grpc';
1
+ import { Codec, CodecProto, CodecType, MessageCodec } from '../codec.mjs';
3
2
  import { CallContext, CallOptions } from 'nice-grpc-common';
4
3
  import _m0 from 'protobufjs/minimal.js';
5
- import * as _effect_schema_AST from '@effect/schema/AST';
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: bigint;
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: number;
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: bigint;
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: Uint8Array;
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: readonly Uint8Array[];
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: readonly Cursor$1[];
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: DataFinality$1;
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: readonly Uint8Array[];
298
+ readonly data?: readonly Uint8Array[] | undefined;
300
299
  /** The production mode of the block. */
301
- readonly production: DataProduction$1;
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
- declare const Bytes: Schema.SchemaClass<`0x${string}`, `0x${string}`, never>;
435
- type Bytes = typeof Bytes.Type;
436
- declare const BytesFromUint8Array: Schema.PropertySignature<"?:", `0x${string}`, never, ":", Uint8Array, false, never>;
437
- /** Represent a position in the stream. */
438
- declare const _Cursor: Schema.Struct<{
439
- /** The block number. */
440
- orderKey: typeof Schema.BigIntFromSelf;
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
- interface CursorProto extends Schema.Schema.Encoded<typeof _Cursor> {
446
- }
447
- interface Cursor extends Schema.Schema.Type<typeof _Cursor> {
448
- }
449
- declare const Cursor: Schema.Schema<Cursor, CursorProto>;
450
- declare const createCursor: (props: Cursor) => Cursor;
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: Schema.Struct<{}>;
471
- type StatusRequest = typeof StatusRequest.Type;
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: Schema.Struct<{
476
- currentHead: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
477
- lastIngested: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
478
- finalized: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
479
- starting: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
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.Type;
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: Schema.transform<Schema.Enums<typeof DataFinality$1>, Schema.Literal<["finalized", "accepted", "pending", "unknown"]>>;
507
- type DataFinality = typeof DataFinality.Type;
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: Schema.transform<Schema.Enums<typeof DataProduction$1>, Schema.Literal<["backfill", "live", "unknown"]>>;
510
- type DataProduction = typeof DataProduction.Type;
511
- declare const Duration: Schema.Struct<{
512
- seconds: typeof Schema.BigIntFromSelf;
513
- nanos: typeof Schema.Number;
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, TR>(filter: Schema.Schema<TA, Uint8Array, TR>) => Schema.Struct<{
517
- finality: Schema.optional<Schema.transform<Schema.Enums<typeof DataFinality$1>, Schema.Literal<["finalized", "accepted", "pending", "unknown"]>>>;
518
- startingCursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
519
- filter: Schema.mutable<Schema.Array$<Schema.Schema<TA, Uint8Array, TR>>>;
520
- heartbeatInterval: Schema.optional<Schema.Struct<{
521
- seconds: typeof Schema.BigIntFromSelf;
522
- nanos: typeof Schema.Number;
523
- }>>;
524
- }>;
525
- type StreamDataRequest<TA> = {
526
- finality?: DataFinality | undefined;
527
- startingCursor?: Cursor | undefined;
528
- filter: TA[];
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 Finalize = typeof Finalize.Type;
544
- declare const Heartbeat: Schema.Struct<{
545
- _tag: Schema.PropertySignature<":", "heartbeat", "$case", ":", "heartbeat", false, never>;
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 Heartbeat = typeof Heartbeat.Type;
548
- declare const StdOut: Schema.Struct<{
549
- _tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
550
- stdout: typeof Schema.String;
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 StdOut = typeof StdOut.Type;
553
- declare const StdErr: Schema.Struct<{
554
- _tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
555
- stderr: typeof Schema.String;
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 StdErr = typeof StdErr.Type;
558
- declare const SystemMessage: Schema.Struct<{
559
- _tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
560
- systemMessage: Schema.Struct<{
561
- output: Schema.Union<[Schema.Struct<{
562
- _tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
563
- stdout: typeof Schema.String;
564
- }>, Schema.Struct<{
565
- _tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
566
- stderr: typeof Schema.String;
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
- declare const ResponseWithoutData: Schema.Union<[Schema.Struct<{
582
- _tag: Schema.PropertySignature<":", "invalidate", "$case", ":", "invalidate", false, never>;
583
- invalidate: Schema.Struct<{
584
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
585
- }>;
586
- }>, Schema.Struct<{
587
- _tag: Schema.PropertySignature<":", "finalize", "$case", ":", "finalize", false, never>;
588
- finalize: Schema.Struct<{
589
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
590
- }>;
591
- }>, Schema.Struct<{
592
- _tag: Schema.PropertySignature<":", "heartbeat", "$case", ":", "heartbeat", false, never>;
593
- }>, Schema.Struct<{
594
- _tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
595
- systemMessage: Schema.Struct<{
596
- output: Schema.Union<[Schema.Struct<{
597
- _tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
598
- stdout: typeof Schema.String;
599
- }>, Schema.Struct<{
600
- _tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
601
- stderr: typeof Schema.String;
602
- }>]>;
603
- }>;
604
- }>]>;
605
- type ResponseWithoutData = typeof ResponseWithoutData.Type;
606
- declare const StreamDataResponse: <TA, TR>(data: Schema.Schema<TA | null, Uint8Array, TR>) => Schema.Union<[Schema.Struct<{
607
- _tag: Schema.PropertySignature<":", "data", "$case", ":", "data", false, never>;
608
- data: Schema.Struct<{
609
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
610
- endCursor: Schema.Schema<Cursor, CursorProto, never>;
611
- finality: Schema.transform<Schema.Enums<typeof DataFinality$1>, Schema.Literal<["finalized", "accepted", "pending", "unknown"]>>;
612
- production: Schema.transform<Schema.Enums<typeof DataProduction$1>, Schema.Literal<["backfill", "live", "unknown"]>>;
613
- data: Schema.Array$<Schema.Schema<TA | null, Uint8Array, TR>>;
614
- }>;
615
- }>, Schema.Struct<{
616
- _tag: Schema.PropertySignature<":", "invalidate", "$case", ":", "invalidate", false, never>;
617
- invalidate: Schema.Struct<{
618
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
619
- }>;
620
- }>, Schema.Struct<{
621
- _tag: Schema.PropertySignature<":", "finalize", "$case", ":", "finalize", false, never>;
622
- finalize: Schema.Struct<{
623
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
624
- }>;
625
- }>, Schema.Struct<{
626
- _tag: Schema.PropertySignature<":", "heartbeat", "$case", ":", "heartbeat", false, never>;
627
- }>, Schema.Struct<{
628
- _tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
629
- systemMessage: Schema.Struct<{
630
- output: Schema.Union<[Schema.Struct<{
631
- _tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
632
- stdout: typeof Schema.String;
633
- }>, Schema.Struct<{
634
- _tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
635
- stderr: typeof Schema.String;
636
- }>]>;
637
- }>;
638
- }>]>;
639
- type StreamDataResponse<TA> = ResponseWithoutData | {
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?: Cursor | undefined;
643
- endCursor: Cursor;
644
- finality: DataFinality;
645
- production: DataProduction;
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: Schema.Schema<TFilter, Uint8Array, never>, block: Schema.Schema<TBlock | null, Uint8Array, never>, mergeFilter: (a: TFilter, b: TFilter) => TFilter);
732
+ constructor(filter: Codec<TFilter, Uint8Array>, block: Codec<TBlock | null, Uint8Array>, mergeFilter: (a: TFilter, b: TFilter) => TFilter);
658
733
  /** Filter schema. */
659
- get Filter(): Schema.Schema<TFilter, Uint8Array, never>;
734
+ get Filter(): Codec<TFilter, Uint8Array>;
660
735
  /** Block schema. */
661
- get Block(): Schema.Schema<TBlock | null, Uint8Array, never>;
736
+ get Block(): Codec<TBlock | null, Uint8Array>;
662
737
  /** Stream data request schema. */
663
- get Request(): Schema.Struct<{
664
- finality: Schema.optional<Schema.transform<Schema.Enums<typeof DataFinality$1>, Schema.Literal<["finalized", "accepted", "pending", "unknown"]>>>;
665
- startingCursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
666
- filter: Schema.mutable<Schema.Array$<Schema.Schema<TFilter, Uint8Array, never>>>;
667
- heartbeatInterval: Schema.optional<Schema.Struct<{
668
- seconds: typeof Schema.BigIntFromSelf;
669
- nanos: typeof Schema.Number;
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(): Schema.Union<[Schema.Struct<{
674
- _tag: Schema.PropertySignature<":", "data", "$case", ":", "data", false, never>;
675
- data: Schema.Struct<{
676
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
677
- endCursor: Schema.Schema<Cursor, CursorProto, never>;
678
- finality: Schema.transform<Schema.Enums<typeof DataFinality$1>, Schema.Literal<["finalized", "accepted", "pending", "unknown"]>>;
679
- production: Schema.transform<Schema.Enums<typeof DataProduction$1>, Schema.Literal<["backfill", "live", "unknown"]>>;
680
- data: Schema.Array$<Schema.Schema<TBlock | null, Uint8Array, never>>;
681
- }>;
682
- }>, Schema.Struct<{
683
- _tag: Schema.PropertySignature<":", "invalidate", "$case", ":", "invalidate", false, never>;
684
- invalidate: Schema.Struct<{
685
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
686
- }>;
687
- }>, Schema.Struct<{
688
- _tag: Schema.PropertySignature<":", "finalize", "$case", ":", "finalize", false, never>;
689
- finalize: Schema.Struct<{
690
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
691
- }>;
692
- }>, Schema.Struct<{
693
- _tag: Schema.PropertySignature<":", "heartbeat", "$case", ":", "heartbeat", false, never>;
694
- }>, Schema.Struct<{
695
- _tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
696
- systemMessage: Schema.Struct<{
697
- output: Schema.Union<[Schema.Struct<{
698
- _tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
699
- stdout: typeof Schema.String;
700
- }>, Schema.Struct<{
701
- _tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
702
- stderr: typeof Schema.String;
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
- readonly currentHead?: Cursor | undefined;
742
- readonly lastIngested?: Cursor | undefined;
743
- readonly finalized?: Cursor | undefined;
744
- readonly starting?: Cursor | undefined;
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: Schema.Schema<TBlock | null, Uint8Array, never>, options?: StreamDataOptions | undefined);
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 { StreamConfig as A, Bytes as B, type CursorProto as C, type DnaStreamClient as D, type ClientCallOptions as E, Finalize as F, type StreamDataOptions as G, Heartbeat as H, Invalidate as I, type Client as J, type CreateClientOptions as K, createClient as L, GrpcClient as M, StreamDataIterable as N, DataFinality$1 as O, DataProduction$1 as P, StatusRequest as S, TimeoutError as T, _Cursor as _, DnaStreamDefinition as a, BytesFromUint8Array as b, Cursor as c, createCursor as d, cursorToProto as e, cursorFromProto as f, CursorFromBytes as g, cursorToBytes as h, cursorFromBytes as i, isCursor as j, statusRequestToProto as k, statusRequestFromProto as l, StatusResponse as m, normalizeCursor as n, statusResponseToProto as o, statusResponseFromProto as p, DataFinality as q, DataProduction as r, stream as s, Duration as t, StreamDataRequest as u, StdOut as v, StdErr as w, SystemMessage as x, Data as y, StreamDataResponse as z };
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 };