@apibara/protocol 2.1.0-beta.5 → 2.1.0-beta.51

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 (65) hide show
  1. package/dist/codec.cjs +242 -0
  2. package/dist/codec.cjs.map +1 -0
  3. package/dist/codec.d.cts +81 -0
  4. package/dist/codec.d.mts +81 -0
  5. package/dist/codec.d.ts +81 -0
  6. package/dist/codec.mjs +224 -0
  7. package/dist/codec.mjs.map +1 -0
  8. package/dist/index.cjs +45 -30
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.cts +5 -5
  11. package/dist/index.d.mts +5 -5
  12. package/dist/index.d.ts +5 -5
  13. package/dist/index.mjs +41 -22
  14. package/dist/index.mjs.map +1 -0
  15. package/dist/rpc/index.cjs +12 -0
  16. package/dist/rpc/index.cjs.map +1 -0
  17. package/dist/rpc/index.d.cts +6 -0
  18. package/dist/rpc/index.d.mts +6 -0
  19. package/dist/rpc/index.d.ts +6 -0
  20. package/dist/rpc/index.mjs +3 -0
  21. package/dist/rpc/index.mjs.map +1 -0
  22. package/dist/shared/{protocol.4b1cfe2c.d.cts → protocol.0e734e33.d.cts} +400 -247
  23. package/dist/shared/{protocol.4b1cfe2c.d.mts → protocol.21e66b9e.d.mts} +400 -247
  24. package/dist/shared/{protocol.e39e40d6.cjs → protocol.53f81a1e.cjs} +177 -177
  25. package/dist/shared/protocol.53f81a1e.cjs.map +1 -0
  26. package/dist/shared/protocol.54f17699.cjs +536 -0
  27. package/dist/shared/protocol.54f17699.cjs.map +1 -0
  28. package/dist/shared/{protocol.991ff9ad.mjs → protocol.68fdd897.mjs} +176 -171
  29. package/dist/shared/protocol.68fdd897.mjs.map +1 -0
  30. package/dist/shared/protocol.6ab8d6dd.d.mts +104 -0
  31. package/dist/shared/protocol.7aa4aab6.d.cts +104 -0
  32. package/dist/shared/protocol.8407f25e.d.ts +104 -0
  33. package/dist/shared/{protocol.4b1cfe2c.d.ts → protocol.8fb09325.d.ts} +400 -247
  34. package/dist/shared/protocol.bde61588.mjs +530 -0
  35. package/dist/shared/protocol.bde61588.mjs.map +1 -0
  36. package/dist/testing/index.cjs +26 -38
  37. package/dist/testing/index.cjs.map +1 -0
  38. package/dist/testing/index.d.cts +107 -54
  39. package/dist/testing/index.d.mts +107 -54
  40. package/dist/testing/index.d.ts +107 -54
  41. package/dist/testing/index.mjs +26 -38
  42. package/dist/testing/index.mjs.map +1 -0
  43. package/package.json +14 -3
  44. package/src/client.ts +39 -14
  45. package/src/codec.ts +662 -0
  46. package/src/common.ts +70 -53
  47. package/src/config.ts +4 -4
  48. package/src/index.ts +2 -0
  49. package/src/proto/google/protobuf/duration.ts +8 -6
  50. package/src/proto/stream.ts +38 -24
  51. package/src/rpc/chain-tracker.ts +327 -0
  52. package/src/rpc/client.ts +51 -0
  53. package/src/rpc/config.ts +88 -0
  54. package/src/rpc/data-stream.ts +366 -0
  55. package/src/rpc/helpers.ts +9 -0
  56. package/src/rpc/index.ts +13 -0
  57. package/src/status.ts +9 -16
  58. package/src/stream.ts +145 -144
  59. package/src/testing/mock.ts +36 -38
  60. package/src/common.test.ts +0 -67
  61. package/src/status.test.ts +0 -51
  62. package/src/stream.test-d.ts +0 -33
  63. package/src/stream.test.ts +0 -254
  64. package/src/testing/client.test.ts +0 -97
  65. package/src/testing/mock.test.ts +0 -35
@@ -1,9 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const schema = require('@effect/schema');
4
- const config = require('../shared/protocol.e39e40d6.cjs');
3
+ const codec = require('../codec.cjs');
4
+ const config = require('../shared/protocol.53f81a1e.cjs');
5
5
  require('protobufjs/minimal.js');
6
- require('effect');
7
6
  require('viem');
8
7
  require('long');
9
8
 
@@ -41,44 +40,31 @@ class StreamDataIterable {
41
40
  }
42
41
  }
43
42
 
44
- const MockFilter = schema.Schema.Struct({
45
- filter: schema.Schema.optional(schema.Schema.String)
43
+ const MockFilter = codec.MessageCodec({
44
+ filter: codec.OptionalCodec(codec.StringCodec)
46
45
  });
47
- const MockFilterFromBytes = schema.Schema.transform(
48
- schema.Schema.Uint8ArrayFromSelf,
49
- MockFilter,
50
- {
51
- strict: false,
52
- decode(value) {
53
- return config.MockFilter.decode(value);
54
- },
55
- encode(value) {
56
- return config.MockFilter.encode(value).finish();
57
- }
46
+ const MockFilterFromBytes = {
47
+ decode(value) {
48
+ return config.MockFilter.decode(value);
49
+ },
50
+ encode(value) {
51
+ return config.MockFilter.encode(value).finish();
58
52
  }
59
- );
60
- const MockBlock = schema.Schema.Struct({
61
- data: schema.Schema.optional(schema.Schema.String)
62
- });
63
- const MockBlockFromBytes = schema.Schema.transform(
64
- schema.Schema.Uint8ArrayFromSelf,
65
- schema.Schema.NullOr(MockBlock),
66
- {
67
- strict: false,
68
- decode(value) {
69
- if (value.length === 0) {
70
- return null;
71
- }
72
- return config.MockBlock.decode(value);
73
- },
74
- encode(value) {
75
- if (value === null) {
76
- return new Uint8Array();
77
- }
78
- return config.MockBlock.encode(value).finish();
53
+ };
54
+ const MockBlockFromBytes = {
55
+ decode(value) {
56
+ if (value.length === 0) {
57
+ return null;
58
+ }
59
+ return config.MockBlock.decode(value);
60
+ },
61
+ encode(value) {
62
+ if (value === null) {
63
+ return new Uint8Array();
79
64
  }
65
+ return config.MockBlock.encode(value).finish();
80
66
  }
81
- );
67
+ };
82
68
  function mergeMockFilter(a, b) {
83
69
  let filter = "";
84
70
  if (a.filter) {
@@ -92,7 +78,8 @@ function mergeMockFilter(a, b) {
92
78
  const MockStream = new config.StreamConfig(
93
79
  MockFilterFromBytes,
94
80
  MockBlockFromBytes,
95
- mergeMockFilter
81
+ mergeMockFilter,
82
+ "mock"
96
83
  );
97
84
  const MockStreamResponse = config.StreamDataResponse(MockBlockFromBytes);
98
85
 
@@ -103,3 +90,4 @@ exports.MockFilterFromBytes = MockFilterFromBytes;
103
90
  exports.MockStream = MockStream;
104
91
  exports.MockStreamResponse = MockStreamResponse;
105
92
  exports.StreamDataIterable = StreamDataIterable;
93
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/testing/client.ts","../../src/testing/mock.ts"],"sourcesContent":["import type { Client, ClientCallOptions, StreamDataOptions } from \"../client\";\nimport type { StatusRequest, StatusResponse } from \"../status\";\nimport type { StreamDataRequest, StreamDataResponse } from \"../stream\";\n\nexport class MockClient<TFilter, TBlock> implements Client<TFilter, TBlock> {\n constructor(\n private messageFactory: (\n request: StreamDataRequest<TFilter>,\n options?: StreamDataOptions,\n ) => (StreamDataResponse<TBlock> | Error)[],\n ) {}\n\n async status(\n request?: StatusRequest,\n options?: ClientCallOptions,\n ): Promise<StatusResponse> {\n throw new Error(\"Client.status is not implemented for VcrClient\");\n }\n\n streamData(request: StreamDataRequest<TFilter>, options?: StreamDataOptions) {\n const messages = this.messageFactory(request, options);\n\n return new StreamDataIterable(messages);\n }\n}\n\nexport class StreamDataIterable<TBlock> {\n constructor(private messages: (StreamDataResponse<TBlock> | Error)[]) {}\n\n [Symbol.asyncIterator](): AsyncIterator<StreamDataResponse<TBlock>> {\n let index = 0;\n const messages = this.messages;\n\n return {\n async next() {\n if (index >= messages.length) {\n return { done: true, value: undefined };\n }\n\n const message = messages[index++];\n if (message instanceof Error) {\n throw message;\n }\n\n return { done: false, value: message };\n },\n };\n }\n}\n","import {\n type Codec,\n type CodecType,\n MessageCodec,\n OptionalCodec,\n StringCodec,\n} from \"../codec\";\nimport { StreamConfig } from \"../config\";\nimport * as proto from \"../proto\";\nimport { StreamDataResponse } from \"../stream\";\n\nexport const MockFilter = MessageCodec({\n filter: OptionalCodec(StringCodec),\n});\n\nexport type MockFilter = CodecType<typeof MockFilter>;\n\nexport const MockFilterFromBytes: Codec<MockFilter, Uint8Array> = {\n decode(value) {\n return proto.testing.MockFilter.decode(value);\n },\n encode(value) {\n return proto.testing.MockFilter.encode(value).finish();\n },\n};\n\nconst MockBlock = MessageCodec({\n data: OptionalCodec(StringCodec),\n});\n\nexport type MockBlock = CodecType<typeof MockBlock>;\n\nexport const MockBlockFromBytes: Codec<MockBlock | null, Uint8Array> = {\n decode(value) {\n if (value.length === 0) {\n return null;\n }\n return proto.testing.MockBlock.decode(value);\n },\n encode(value) {\n if (value === null) {\n return new Uint8Array();\n }\n return proto.testing.MockBlock.encode(value).finish();\n },\n};\n\n/** For testing, simply concatenate the values of `.filter` */\nfunction mergeMockFilter(a: MockFilter, b: MockFilter): MockFilter {\n let filter = \"\";\n if (a.filter) {\n filter += a.filter;\n }\n if (b.filter) {\n filter += b.filter;\n }\n return { filter };\n}\n\nexport const MockStream = new StreamConfig(\n MockFilterFromBytes,\n MockBlockFromBytes,\n mergeMockFilter,\n \"mock\",\n);\n\nexport const MockStreamResponse = StreamDataResponse(MockBlockFromBytes);\n\nexport type MockStreamResponse = CodecType<typeof MockStreamResponse>;\n"],"names":["MessageCodec","OptionalCodec","StringCodec","proto.testing.MockFilter","proto.testing.MockBlock","StreamConfig","StreamDataResponse"],"mappings":"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"}
@@ -1,9 +1,8 @@
1
- import { J as Client, u as StreamDataRequest, G as StreamDataOptions, z as StreamDataResponse, S as StatusRequest, E as ClientCallOptions, m as StatusResponse, A as StreamConfig, c as Cursor, C as CursorProto, O as DataFinality, P as DataProduction } from '../shared/protocol.4b1cfe2c.cjs';
2
- import { Schema } from '@effect/schema';
3
- import 'nice-grpc';
1
+ import { w as Client, l as StreamDataRequest, v as StreamDataOptions, r as StreamDataResponse, S as StatusRequest, u as ClientCallOptions, f as StatusResponse, t as StreamConfig, B as Bytes, E as Cursor, J as DataFinality, K as DataProduction } from '../shared/protocol.0e734e33.cjs';
2
+ import { MessageCodec, Codec, CodecType } from '../codec.cjs';
4
3
  import 'nice-grpc-common';
5
4
  import 'protobufjs/minimal.js';
6
- import '@effect/schema/AST';
5
+ import 'nice-grpc';
7
6
 
8
7
  declare class MockClient<TFilter, TBlock> implements Client<TFilter, TBlock> {
9
8
  private messageFactory;
@@ -17,60 +16,114 @@ declare class StreamDataIterable<TBlock> {
17
16
  [Symbol.asyncIterator](): AsyncIterator<StreamDataResponse<TBlock>>;
18
17
  }
19
18
 
20
- declare const MockFilter: Schema.Struct<{
21
- filter: Schema.optional<typeof Schema.String>;
19
+ declare const MockFilter: MessageCodec<{
20
+ filter: Codec<string | undefined, string | undefined>;
22
21
  }>;
23
- type MockFilter = typeof MockFilter.Type;
24
- declare const MockFilterFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8Array, never>, Schema.Struct<{
25
- filter: Schema.optional<typeof Schema.String>;
26
- }>>;
27
- declare const MockBlock: Schema.Struct<{
28
- data: Schema.optional<typeof Schema.String>;
22
+ type MockFilter = CodecType<typeof MockFilter>;
23
+ declare const MockFilterFromBytes: Codec<MockFilter, Uint8Array>;
24
+ declare const MockBlock: MessageCodec<{
25
+ data: Codec<string | undefined, string | undefined>;
29
26
  }>;
30
- type MockBlock = typeof MockBlock.Type;
31
- declare const MockBlockFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8Array, never>, Schema.NullOr<Schema.Struct<{
32
- data: Schema.optional<typeof Schema.String>;
33
- }>>>;
27
+ type MockBlock = CodecType<typeof MockBlock>;
28
+ declare const MockBlockFromBytes: Codec<MockBlock | null, Uint8Array>;
34
29
  declare const MockStream: StreamConfig<{
35
- readonly filter?: string | undefined;
30
+ filter?: string | undefined;
36
31
  }, {
37
- readonly data?: string | undefined;
32
+ data?: string | undefined;
38
33
  }>;
39
- declare const MockStreamResponse: Schema.Union<[Schema.Struct<{
40
- _tag: Schema.PropertySignature<":", "data", "$case", ":", "data", false, never>;
41
- data: Schema.Struct<{
42
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
43
- endCursor: Schema.Schema<Cursor, CursorProto, never>;
44
- finality: Schema.transform<Schema.Enums<typeof DataFinality>, Schema.Literal<["finalized", "accepted", "pending", "unknown"]>>;
45
- production: Schema.transform<Schema.Enums<typeof DataProduction>, Schema.Literal<["backfill", "live", "unknown"]>>;
46
- data: Schema.Array$<Schema.Schema<{
47
- readonly data?: string | undefined;
48
- } | null, Uint8Array, never>>;
49
- }>;
50
- }>, Schema.Struct<{
51
- _tag: Schema.PropertySignature<":", "invalidate", "$case", ":", "invalidate", false, never>;
52
- invalidate: Schema.Struct<{
53
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
54
- }>;
55
- }>, Schema.Struct<{
56
- _tag: Schema.PropertySignature<":", "finalize", "$case", ":", "finalize", false, never>;
57
- finalize: Schema.Struct<{
58
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
59
- }>;
60
- }>, Schema.Struct<{
61
- _tag: Schema.PropertySignature<":", "heartbeat", "$case", ":", "heartbeat", false, never>;
62
- }>, Schema.Struct<{
63
- _tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
64
- systemMessage: Schema.Struct<{
65
- output: Schema.Union<[Schema.Struct<{
66
- _tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
67
- stdout: typeof Schema.String;
68
- }>, Schema.Struct<{
69
- _tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
70
- stderr: typeof Schema.String;
71
- }>]>;
72
- }>;
73
- }>]>;
74
- type MockStreamResponse = typeof MockStreamResponse.Type;
34
+ declare const MockStreamResponse: Codec<{
35
+ _tag: "heartbeat";
36
+ } | ({
37
+ _tag: "data";
38
+ } & {
39
+ data: {
40
+ cursor?: {
41
+ orderKey: bigint;
42
+ uniqueKey?: Bytes | undefined;
43
+ } | undefined;
44
+ endCursor: {
45
+ orderKey: bigint;
46
+ uniqueKey?: Bytes | undefined;
47
+ };
48
+ finality: "finalized" | "accepted" | "pending" | "unknown";
49
+ production: "unknown" | "backfill" | "live";
50
+ data: readonly ({
51
+ data?: string | undefined;
52
+ } | null)[];
53
+ };
54
+ }) | ({
55
+ _tag: "invalidate";
56
+ } & {
57
+ invalidate: {
58
+ cursor?: {
59
+ orderKey: bigint;
60
+ uniqueKey?: Bytes | undefined;
61
+ } | undefined;
62
+ };
63
+ }) | ({
64
+ _tag: "finalize";
65
+ } & {
66
+ finalize: {
67
+ cursor?: {
68
+ orderKey: bigint;
69
+ uniqueKey?: Bytes | undefined;
70
+ } | undefined;
71
+ };
72
+ }) | ({
73
+ _tag: "systemMessage";
74
+ } & {
75
+ systemMessage: {
76
+ output: ({
77
+ _tag: "stdout";
78
+ } & {
79
+ stdout: string;
80
+ }) | ({
81
+ _tag: "stderr";
82
+ } & {
83
+ stderr: string;
84
+ });
85
+ };
86
+ }), ({
87
+ $case: "data";
88
+ } & {
89
+ data: {
90
+ cursor?: Cursor | undefined;
91
+ endCursor: Cursor;
92
+ finality: DataFinality;
93
+ production: DataProduction;
94
+ data?: readonly Uint8Array[] | undefined;
95
+ };
96
+ }) | ({
97
+ $case: "invalidate";
98
+ } & {
99
+ invalidate: {
100
+ cursor?: Cursor | undefined;
101
+ };
102
+ }) | ({
103
+ $case: "finalize";
104
+ } & {
105
+ finalize: {
106
+ cursor?: Cursor | undefined;
107
+ };
108
+ }) | ({
109
+ $case: "heartbeat";
110
+ } & {
111
+ heartbeat: undefined;
112
+ }) | ({
113
+ $case: "systemMessage";
114
+ } & {
115
+ systemMessage: {
116
+ output: ({
117
+ $case: "stdout";
118
+ } & {
119
+ stdout: string;
120
+ }) | ({
121
+ $case: "stderr";
122
+ } & {
123
+ stderr: string;
124
+ });
125
+ };
126
+ })>;
127
+ type MockStreamResponse = CodecType<typeof MockStreamResponse>;
75
128
 
76
129
  export { MockBlock, MockBlockFromBytes, MockClient, MockFilter, MockFilterFromBytes, MockStream, MockStreamResponse, StreamDataIterable };
@@ -1,9 +1,8 @@
1
- import { J as Client, u as StreamDataRequest, G as StreamDataOptions, z as StreamDataResponse, S as StatusRequest, E as ClientCallOptions, m as StatusResponse, A as StreamConfig, c as Cursor, C as CursorProto, O as DataFinality, P as DataProduction } from '../shared/protocol.4b1cfe2c.mjs';
2
- import { Schema } from '@effect/schema';
3
- import 'nice-grpc';
1
+ import { w as Client, l as StreamDataRequest, v as StreamDataOptions, r as StreamDataResponse, S as StatusRequest, u as ClientCallOptions, f as StatusResponse, t as StreamConfig, B as Bytes, E as Cursor, J as DataFinality, K as DataProduction } from '../shared/protocol.21e66b9e.mjs';
2
+ import { MessageCodec, Codec, CodecType } from '../codec.mjs';
4
3
  import 'nice-grpc-common';
5
4
  import 'protobufjs/minimal.js';
6
- import '@effect/schema/AST';
5
+ import 'nice-grpc';
7
6
 
8
7
  declare class MockClient<TFilter, TBlock> implements Client<TFilter, TBlock> {
9
8
  private messageFactory;
@@ -17,60 +16,114 @@ declare class StreamDataIterable<TBlock> {
17
16
  [Symbol.asyncIterator](): AsyncIterator<StreamDataResponse<TBlock>>;
18
17
  }
19
18
 
20
- declare const MockFilter: Schema.Struct<{
21
- filter: Schema.optional<typeof Schema.String>;
19
+ declare const MockFilter: MessageCodec<{
20
+ filter: Codec<string | undefined, string | undefined>;
22
21
  }>;
23
- type MockFilter = typeof MockFilter.Type;
24
- declare const MockFilterFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8Array, never>, Schema.Struct<{
25
- filter: Schema.optional<typeof Schema.String>;
26
- }>>;
27
- declare const MockBlock: Schema.Struct<{
28
- data: Schema.optional<typeof Schema.String>;
22
+ type MockFilter = CodecType<typeof MockFilter>;
23
+ declare const MockFilterFromBytes: Codec<MockFilter, Uint8Array>;
24
+ declare const MockBlock: MessageCodec<{
25
+ data: Codec<string | undefined, string | undefined>;
29
26
  }>;
30
- type MockBlock = typeof MockBlock.Type;
31
- declare const MockBlockFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8Array, never>, Schema.NullOr<Schema.Struct<{
32
- data: Schema.optional<typeof Schema.String>;
33
- }>>>;
27
+ type MockBlock = CodecType<typeof MockBlock>;
28
+ declare const MockBlockFromBytes: Codec<MockBlock | null, Uint8Array>;
34
29
  declare const MockStream: StreamConfig<{
35
- readonly filter?: string | undefined;
30
+ filter?: string | undefined;
36
31
  }, {
37
- readonly data?: string | undefined;
32
+ data?: string | undefined;
38
33
  }>;
39
- declare const MockStreamResponse: Schema.Union<[Schema.Struct<{
40
- _tag: Schema.PropertySignature<":", "data", "$case", ":", "data", false, never>;
41
- data: Schema.Struct<{
42
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
43
- endCursor: Schema.Schema<Cursor, CursorProto, never>;
44
- finality: Schema.transform<Schema.Enums<typeof DataFinality>, Schema.Literal<["finalized", "accepted", "pending", "unknown"]>>;
45
- production: Schema.transform<Schema.Enums<typeof DataProduction>, Schema.Literal<["backfill", "live", "unknown"]>>;
46
- data: Schema.Array$<Schema.Schema<{
47
- readonly data?: string | undefined;
48
- } | null, Uint8Array, never>>;
49
- }>;
50
- }>, Schema.Struct<{
51
- _tag: Schema.PropertySignature<":", "invalidate", "$case", ":", "invalidate", false, never>;
52
- invalidate: Schema.Struct<{
53
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
54
- }>;
55
- }>, Schema.Struct<{
56
- _tag: Schema.PropertySignature<":", "finalize", "$case", ":", "finalize", false, never>;
57
- finalize: Schema.Struct<{
58
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
59
- }>;
60
- }>, Schema.Struct<{
61
- _tag: Schema.PropertySignature<":", "heartbeat", "$case", ":", "heartbeat", false, never>;
62
- }>, Schema.Struct<{
63
- _tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
64
- systemMessage: Schema.Struct<{
65
- output: Schema.Union<[Schema.Struct<{
66
- _tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
67
- stdout: typeof Schema.String;
68
- }>, Schema.Struct<{
69
- _tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
70
- stderr: typeof Schema.String;
71
- }>]>;
72
- }>;
73
- }>]>;
74
- type MockStreamResponse = typeof MockStreamResponse.Type;
34
+ declare const MockStreamResponse: Codec<{
35
+ _tag: "heartbeat";
36
+ } | ({
37
+ _tag: "data";
38
+ } & {
39
+ data: {
40
+ cursor?: {
41
+ orderKey: bigint;
42
+ uniqueKey?: Bytes | undefined;
43
+ } | undefined;
44
+ endCursor: {
45
+ orderKey: bigint;
46
+ uniqueKey?: Bytes | undefined;
47
+ };
48
+ finality: "finalized" | "accepted" | "pending" | "unknown";
49
+ production: "unknown" | "backfill" | "live";
50
+ data: readonly ({
51
+ data?: string | undefined;
52
+ } | null)[];
53
+ };
54
+ }) | ({
55
+ _tag: "invalidate";
56
+ } & {
57
+ invalidate: {
58
+ cursor?: {
59
+ orderKey: bigint;
60
+ uniqueKey?: Bytes | undefined;
61
+ } | undefined;
62
+ };
63
+ }) | ({
64
+ _tag: "finalize";
65
+ } & {
66
+ finalize: {
67
+ cursor?: {
68
+ orderKey: bigint;
69
+ uniqueKey?: Bytes | undefined;
70
+ } | undefined;
71
+ };
72
+ }) | ({
73
+ _tag: "systemMessage";
74
+ } & {
75
+ systemMessage: {
76
+ output: ({
77
+ _tag: "stdout";
78
+ } & {
79
+ stdout: string;
80
+ }) | ({
81
+ _tag: "stderr";
82
+ } & {
83
+ stderr: string;
84
+ });
85
+ };
86
+ }), ({
87
+ $case: "data";
88
+ } & {
89
+ data: {
90
+ cursor?: Cursor | undefined;
91
+ endCursor: Cursor;
92
+ finality: DataFinality;
93
+ production: DataProduction;
94
+ data?: readonly Uint8Array[] | undefined;
95
+ };
96
+ }) | ({
97
+ $case: "invalidate";
98
+ } & {
99
+ invalidate: {
100
+ cursor?: Cursor | undefined;
101
+ };
102
+ }) | ({
103
+ $case: "finalize";
104
+ } & {
105
+ finalize: {
106
+ cursor?: Cursor | undefined;
107
+ };
108
+ }) | ({
109
+ $case: "heartbeat";
110
+ } & {
111
+ heartbeat: undefined;
112
+ }) | ({
113
+ $case: "systemMessage";
114
+ } & {
115
+ systemMessage: {
116
+ output: ({
117
+ $case: "stdout";
118
+ } & {
119
+ stdout: string;
120
+ }) | ({
121
+ $case: "stderr";
122
+ } & {
123
+ stderr: string;
124
+ });
125
+ };
126
+ })>;
127
+ type MockStreamResponse = CodecType<typeof MockStreamResponse>;
75
128
 
76
129
  export { MockBlock, MockBlockFromBytes, MockClient, MockFilter, MockFilterFromBytes, MockStream, MockStreamResponse, StreamDataIterable };
@@ -1,9 +1,8 @@
1
- import { J as Client, u as StreamDataRequest, G as StreamDataOptions, z as StreamDataResponse, S as StatusRequest, E as ClientCallOptions, m as StatusResponse, A as StreamConfig, c as Cursor, C as CursorProto, O as DataFinality, P as DataProduction } from '../shared/protocol.4b1cfe2c.js';
2
- import { Schema } from '@effect/schema';
3
- import 'nice-grpc';
1
+ import { w as Client, l as StreamDataRequest, v as StreamDataOptions, r as StreamDataResponse, S as StatusRequest, u as ClientCallOptions, f as StatusResponse, t as StreamConfig, B as Bytes, E as Cursor, J as DataFinality, K as DataProduction } from '../shared/protocol.8fb09325.js';
2
+ import { MessageCodec, Codec, CodecType } from '../codec.js';
4
3
  import 'nice-grpc-common';
5
4
  import 'protobufjs/minimal.js';
6
- import '@effect/schema/AST';
5
+ import 'nice-grpc';
7
6
 
8
7
  declare class MockClient<TFilter, TBlock> implements Client<TFilter, TBlock> {
9
8
  private messageFactory;
@@ -17,60 +16,114 @@ declare class StreamDataIterable<TBlock> {
17
16
  [Symbol.asyncIterator](): AsyncIterator<StreamDataResponse<TBlock>>;
18
17
  }
19
18
 
20
- declare const MockFilter: Schema.Struct<{
21
- filter: Schema.optional<typeof Schema.String>;
19
+ declare const MockFilter: MessageCodec<{
20
+ filter: Codec<string | undefined, string | undefined>;
22
21
  }>;
23
- type MockFilter = typeof MockFilter.Type;
24
- declare const MockFilterFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8Array, never>, Schema.Struct<{
25
- filter: Schema.optional<typeof Schema.String>;
26
- }>>;
27
- declare const MockBlock: Schema.Struct<{
28
- data: Schema.optional<typeof Schema.String>;
22
+ type MockFilter = CodecType<typeof MockFilter>;
23
+ declare const MockFilterFromBytes: Codec<MockFilter, Uint8Array>;
24
+ declare const MockBlock: MessageCodec<{
25
+ data: Codec<string | undefined, string | undefined>;
29
26
  }>;
30
- type MockBlock = typeof MockBlock.Type;
31
- declare const MockBlockFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8Array, never>, Schema.NullOr<Schema.Struct<{
32
- data: Schema.optional<typeof Schema.String>;
33
- }>>>;
27
+ type MockBlock = CodecType<typeof MockBlock>;
28
+ declare const MockBlockFromBytes: Codec<MockBlock | null, Uint8Array>;
34
29
  declare const MockStream: StreamConfig<{
35
- readonly filter?: string | undefined;
30
+ filter?: string | undefined;
36
31
  }, {
37
- readonly data?: string | undefined;
32
+ data?: string | undefined;
38
33
  }>;
39
- declare const MockStreamResponse: Schema.Union<[Schema.Struct<{
40
- _tag: Schema.PropertySignature<":", "data", "$case", ":", "data", false, never>;
41
- data: Schema.Struct<{
42
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
43
- endCursor: Schema.Schema<Cursor, CursorProto, never>;
44
- finality: Schema.transform<Schema.Enums<typeof DataFinality>, Schema.Literal<["finalized", "accepted", "pending", "unknown"]>>;
45
- production: Schema.transform<Schema.Enums<typeof DataProduction>, Schema.Literal<["backfill", "live", "unknown"]>>;
46
- data: Schema.Array$<Schema.Schema<{
47
- readonly data?: string | undefined;
48
- } | null, Uint8Array, never>>;
49
- }>;
50
- }>, Schema.Struct<{
51
- _tag: Schema.PropertySignature<":", "invalidate", "$case", ":", "invalidate", false, never>;
52
- invalidate: Schema.Struct<{
53
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
54
- }>;
55
- }>, Schema.Struct<{
56
- _tag: Schema.PropertySignature<":", "finalize", "$case", ":", "finalize", false, never>;
57
- finalize: Schema.Struct<{
58
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
59
- }>;
60
- }>, Schema.Struct<{
61
- _tag: Schema.PropertySignature<":", "heartbeat", "$case", ":", "heartbeat", false, never>;
62
- }>, Schema.Struct<{
63
- _tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
64
- systemMessage: Schema.Struct<{
65
- output: Schema.Union<[Schema.Struct<{
66
- _tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
67
- stdout: typeof Schema.String;
68
- }>, Schema.Struct<{
69
- _tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
70
- stderr: typeof Schema.String;
71
- }>]>;
72
- }>;
73
- }>]>;
74
- type MockStreamResponse = typeof MockStreamResponse.Type;
34
+ declare const MockStreamResponse: Codec<{
35
+ _tag: "heartbeat";
36
+ } | ({
37
+ _tag: "data";
38
+ } & {
39
+ data: {
40
+ cursor?: {
41
+ orderKey: bigint;
42
+ uniqueKey?: Bytes | undefined;
43
+ } | undefined;
44
+ endCursor: {
45
+ orderKey: bigint;
46
+ uniqueKey?: Bytes | undefined;
47
+ };
48
+ finality: "finalized" | "accepted" | "pending" | "unknown";
49
+ production: "unknown" | "backfill" | "live";
50
+ data: readonly ({
51
+ data?: string | undefined;
52
+ } | null)[];
53
+ };
54
+ }) | ({
55
+ _tag: "invalidate";
56
+ } & {
57
+ invalidate: {
58
+ cursor?: {
59
+ orderKey: bigint;
60
+ uniqueKey?: Bytes | undefined;
61
+ } | undefined;
62
+ };
63
+ }) | ({
64
+ _tag: "finalize";
65
+ } & {
66
+ finalize: {
67
+ cursor?: {
68
+ orderKey: bigint;
69
+ uniqueKey?: Bytes | undefined;
70
+ } | undefined;
71
+ };
72
+ }) | ({
73
+ _tag: "systemMessage";
74
+ } & {
75
+ systemMessage: {
76
+ output: ({
77
+ _tag: "stdout";
78
+ } & {
79
+ stdout: string;
80
+ }) | ({
81
+ _tag: "stderr";
82
+ } & {
83
+ stderr: string;
84
+ });
85
+ };
86
+ }), ({
87
+ $case: "data";
88
+ } & {
89
+ data: {
90
+ cursor?: Cursor | undefined;
91
+ endCursor: Cursor;
92
+ finality: DataFinality;
93
+ production: DataProduction;
94
+ data?: readonly Uint8Array[] | undefined;
95
+ };
96
+ }) | ({
97
+ $case: "invalidate";
98
+ } & {
99
+ invalidate: {
100
+ cursor?: Cursor | undefined;
101
+ };
102
+ }) | ({
103
+ $case: "finalize";
104
+ } & {
105
+ finalize: {
106
+ cursor?: Cursor | undefined;
107
+ };
108
+ }) | ({
109
+ $case: "heartbeat";
110
+ } & {
111
+ heartbeat: undefined;
112
+ }) | ({
113
+ $case: "systemMessage";
114
+ } & {
115
+ systemMessage: {
116
+ output: ({
117
+ $case: "stdout";
118
+ } & {
119
+ stdout: string;
120
+ }) | ({
121
+ $case: "stderr";
122
+ } & {
123
+ stderr: string;
124
+ });
125
+ };
126
+ })>;
127
+ type MockStreamResponse = CodecType<typeof MockStreamResponse>;
75
128
 
76
129
  export { MockBlock, MockBlockFromBytes, MockClient, MockFilter, MockFilterFromBytes, MockStream, MockStreamResponse, StreamDataIterable };