@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.
@@ -1,70 +0,0 @@
1
- import { A as Client, q as StreamDataRequest, z as StreamDataOptions, w as StreamDataResponse, S as StatusRequest, y as ClientCallOptions, m as StatusResponse, x as StreamConfig, d as Cursor, C as CursorProto, J as DataFinality } from '../shared/protocol.e9aed6a3.cjs';
2
- import { Schema } from '@effect/schema';
3
- import 'nice-grpc';
4
- import 'nice-grpc-common';
5
- import 'protobufjs/minimal';
6
- import '@effect/schema/AST';
7
-
8
- declare class MockClient<TFilter, TBlock> implements Client<TFilter, TBlock> {
9
- private messageFactory;
10
- constructor(messageFactory: (request: StreamDataRequest<TFilter>, options?: StreamDataOptions) => (StreamDataResponse<TBlock> | Error)[]);
11
- status(request?: StatusRequest, options?: ClientCallOptions): Promise<StatusResponse>;
12
- streamData(request: StreamDataRequest<TFilter>, options?: StreamDataOptions): StreamDataIterable<TBlock>;
13
- }
14
- declare class StreamDataIterable<TBlock> {
15
- private messages;
16
- constructor(messages: (StreamDataResponse<TBlock> | Error)[]);
17
- [Symbol.asyncIterator](): AsyncIterator<StreamDataResponse<TBlock>>;
18
- }
19
-
20
- declare const MockFilter: Schema.Struct<{
21
- filter: Schema.optional<typeof Schema.String>;
22
- }>;
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>;
29
- }>;
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
- }>>>;
34
- declare const MockStream: StreamConfig<{
35
- readonly filter?: string | undefined;
36
- }, {
37
- readonly data?: string | undefined;
38
- }>;
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.optional<Schema.Schema<Cursor, CursorProto, never>>;
44
- finality: Schema.transform<Schema.Enums<typeof DataFinality>, Schema.Literal<["finalized", "accepted", "pending", "unknown"]>>;
45
- data: Schema.Array$<Schema.Schema<{
46
- readonly data?: string | undefined;
47
- } | null, Uint8Array, never>>;
48
- }>;
49
- }>, Schema.Struct<{
50
- _tag: Schema.PropertySignature<":", "invalidate", "$case", ":", "invalidate", false, never>;
51
- invalidate: Schema.Struct<{
52
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
53
- }>;
54
- }>, Schema.Struct<{
55
- _tag: Schema.PropertySignature<":", "heartbeat", "$case", ":", "heartbeat", false, never>;
56
- }>, Schema.Struct<{
57
- _tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
58
- systemMessage: Schema.Struct<{
59
- output: Schema.optional<Schema.Union<[Schema.Struct<{
60
- _tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
61
- stdout: typeof Schema.String;
62
- }>, Schema.Struct<{
63
- _tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
64
- stderr: typeof Schema.String;
65
- }>]>>;
66
- }>;
67
- }>]>;
68
- type MockStreamResponse = typeof MockStreamResponse.Type;
69
-
70
- export { MockBlock, MockBlockFromBytes, MockClient, MockFilter, MockFilterFromBytes, MockStream, MockStreamResponse, StreamDataIterable };
@@ -1,70 +0,0 @@
1
- import { A as Client, q as StreamDataRequest, z as StreamDataOptions, w as StreamDataResponse, S as StatusRequest, y as ClientCallOptions, m as StatusResponse, x as StreamConfig, d as Cursor, C as CursorProto, J as DataFinality } from '../shared/protocol.e9aed6a3.mjs';
2
- import { Schema } from '@effect/schema';
3
- import 'nice-grpc';
4
- import 'nice-grpc-common';
5
- import 'protobufjs/minimal';
6
- import '@effect/schema/AST';
7
-
8
- declare class MockClient<TFilter, TBlock> implements Client<TFilter, TBlock> {
9
- private messageFactory;
10
- constructor(messageFactory: (request: StreamDataRequest<TFilter>, options?: StreamDataOptions) => (StreamDataResponse<TBlock> | Error)[]);
11
- status(request?: StatusRequest, options?: ClientCallOptions): Promise<StatusResponse>;
12
- streamData(request: StreamDataRequest<TFilter>, options?: StreamDataOptions): StreamDataIterable<TBlock>;
13
- }
14
- declare class StreamDataIterable<TBlock> {
15
- private messages;
16
- constructor(messages: (StreamDataResponse<TBlock> | Error)[]);
17
- [Symbol.asyncIterator](): AsyncIterator<StreamDataResponse<TBlock>>;
18
- }
19
-
20
- declare const MockFilter: Schema.Struct<{
21
- filter: Schema.optional<typeof Schema.String>;
22
- }>;
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>;
29
- }>;
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
- }>>>;
34
- declare const MockStream: StreamConfig<{
35
- readonly filter?: string | undefined;
36
- }, {
37
- readonly data?: string | undefined;
38
- }>;
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.optional<Schema.Schema<Cursor, CursorProto, never>>;
44
- finality: Schema.transform<Schema.Enums<typeof DataFinality>, Schema.Literal<["finalized", "accepted", "pending", "unknown"]>>;
45
- data: Schema.Array$<Schema.Schema<{
46
- readonly data?: string | undefined;
47
- } | null, Uint8Array, never>>;
48
- }>;
49
- }>, Schema.Struct<{
50
- _tag: Schema.PropertySignature<":", "invalidate", "$case", ":", "invalidate", false, never>;
51
- invalidate: Schema.Struct<{
52
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
53
- }>;
54
- }>, Schema.Struct<{
55
- _tag: Schema.PropertySignature<":", "heartbeat", "$case", ":", "heartbeat", false, never>;
56
- }>, Schema.Struct<{
57
- _tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
58
- systemMessage: Schema.Struct<{
59
- output: Schema.optional<Schema.Union<[Schema.Struct<{
60
- _tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
61
- stdout: typeof Schema.String;
62
- }>, Schema.Struct<{
63
- _tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
64
- stderr: typeof Schema.String;
65
- }>]>>;
66
- }>;
67
- }>]>;
68
- type MockStreamResponse = typeof MockStreamResponse.Type;
69
-
70
- export { MockBlock, MockBlockFromBytes, MockClient, MockFilter, MockFilterFromBytes, MockStream, MockStreamResponse, StreamDataIterable };
@@ -1,70 +0,0 @@
1
- import { A as Client, q as StreamDataRequest, z as StreamDataOptions, w as StreamDataResponse, S as StatusRequest, y as ClientCallOptions, m as StatusResponse, x as StreamConfig, d as Cursor, C as CursorProto, J as DataFinality } from '../shared/protocol.e9aed6a3.js';
2
- import { Schema } from '@effect/schema';
3
- import 'nice-grpc';
4
- import 'nice-grpc-common';
5
- import 'protobufjs/minimal';
6
- import '@effect/schema/AST';
7
-
8
- declare class MockClient<TFilter, TBlock> implements Client<TFilter, TBlock> {
9
- private messageFactory;
10
- constructor(messageFactory: (request: StreamDataRequest<TFilter>, options?: StreamDataOptions) => (StreamDataResponse<TBlock> | Error)[]);
11
- status(request?: StatusRequest, options?: ClientCallOptions): Promise<StatusResponse>;
12
- streamData(request: StreamDataRequest<TFilter>, options?: StreamDataOptions): StreamDataIterable<TBlock>;
13
- }
14
- declare class StreamDataIterable<TBlock> {
15
- private messages;
16
- constructor(messages: (StreamDataResponse<TBlock> | Error)[]);
17
- [Symbol.asyncIterator](): AsyncIterator<StreamDataResponse<TBlock>>;
18
- }
19
-
20
- declare const MockFilter: Schema.Struct<{
21
- filter: Schema.optional<typeof Schema.String>;
22
- }>;
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>;
29
- }>;
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
- }>>>;
34
- declare const MockStream: StreamConfig<{
35
- readonly filter?: string | undefined;
36
- }, {
37
- readonly data?: string | undefined;
38
- }>;
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.optional<Schema.Schema<Cursor, CursorProto, never>>;
44
- finality: Schema.transform<Schema.Enums<typeof DataFinality>, Schema.Literal<["finalized", "accepted", "pending", "unknown"]>>;
45
- data: Schema.Array$<Schema.Schema<{
46
- readonly data?: string | undefined;
47
- } | null, Uint8Array, never>>;
48
- }>;
49
- }>, Schema.Struct<{
50
- _tag: Schema.PropertySignature<":", "invalidate", "$case", ":", "invalidate", false, never>;
51
- invalidate: Schema.Struct<{
52
- cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
53
- }>;
54
- }>, Schema.Struct<{
55
- _tag: Schema.PropertySignature<":", "heartbeat", "$case", ":", "heartbeat", false, never>;
56
- }>, Schema.Struct<{
57
- _tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
58
- systemMessage: Schema.Struct<{
59
- output: Schema.optional<Schema.Union<[Schema.Struct<{
60
- _tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
61
- stdout: typeof Schema.String;
62
- }>, Schema.Struct<{
63
- _tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
64
- stderr: typeof Schema.String;
65
- }>]>>;
66
- }>;
67
- }>]>;
68
- type MockStreamResponse = typeof MockStreamResponse.Type;
69
-
70
- export { MockBlock, MockBlockFromBytes, MockClient, MockFilter, MockFilterFromBytes, MockStream, MockStreamResponse, StreamDataIterable };
@@ -1,97 +0,0 @@
1
- import { Schema } from '@effect/schema';
2
- import { M as MockFilter$1, p as MockBlock$1, o as StreamConfig, S as StreamDataResponse } from '../shared/protocol.a07a51b5.mjs';
3
- import 'protobufjs/minimal';
4
- import 'effect';
5
- import 'viem';
6
- import 'long';
7
-
8
- class MockClient {
9
- constructor(messageFactory) {
10
- this.messageFactory = messageFactory;
11
- }
12
- async status(request, options) {
13
- throw new Error("Client.status is not implemented for VcrClient");
14
- }
15
- streamData(request, options) {
16
- const messages = this.messageFactory(request, options);
17
- return new StreamDataIterable(messages);
18
- }
19
- }
20
- class StreamDataIterable {
21
- constructor(messages) {
22
- this.messages = messages;
23
- }
24
- [Symbol.asyncIterator]() {
25
- let index = 0;
26
- const messages = this.messages;
27
- return {
28
- async next() {
29
- if (index >= messages.length) {
30
- return { done: true, value: void 0 };
31
- }
32
- const message = messages[index++];
33
- if (message instanceof Error) {
34
- throw message;
35
- }
36
- return { done: false, value: message };
37
- }
38
- };
39
- }
40
- }
41
-
42
- const MockFilter = Schema.Struct({
43
- filter: Schema.optional(Schema.String)
44
- });
45
- const MockFilterFromBytes = Schema.transform(
46
- Schema.Uint8ArrayFromSelf,
47
- MockFilter,
48
- {
49
- strict: false,
50
- decode(value) {
51
- return MockFilter$1.decode(value);
52
- },
53
- encode(value) {
54
- return MockFilter$1.encode(value).finish();
55
- }
56
- }
57
- );
58
- const MockBlock = Schema.Struct({
59
- data: Schema.optional(Schema.String)
60
- });
61
- const MockBlockFromBytes = Schema.transform(
62
- Schema.Uint8ArrayFromSelf,
63
- Schema.NullOr(MockBlock),
64
- {
65
- strict: false,
66
- decode(value) {
67
- if (value.length === 0) {
68
- return null;
69
- }
70
- return MockBlock$1.decode(value);
71
- },
72
- encode(value) {
73
- if (value === null) {
74
- return new Uint8Array();
75
- }
76
- return MockBlock$1.encode(value).finish();
77
- }
78
- }
79
- );
80
- function mergeMockFilter(a, b) {
81
- let filter = "";
82
- if (a.filter) {
83
- filter += a.filter;
84
- }
85
- if (b.filter) {
86
- filter += b.filter;
87
- }
88
- return { filter };
89
- }
90
- const MockStream = new StreamConfig(
91
- MockFilterFromBytes,
92
- MockBlockFromBytes,
93
- mergeMockFilter
94
- );
95
- const MockStreamResponse = StreamDataResponse(MockBlockFromBytes);
96
-
97
- export { MockBlockFromBytes, MockClient, MockFilter, MockFilterFromBytes, MockStream, MockStreamResponse, StreamDataIterable };
@@ -1,22 +0,0 @@
1
- syntax = "proto3";
2
-
3
- package dna.v2.common;
4
-
5
- // A cursor over the stream content.
6
- message Cursor {
7
- // Key used for ordering messages in the stream.
8
- uint64 order_key = 1;
9
- // Key used to discriminate branches in the stream.
10
- bytes unique_key = 2;
11
- }
12
-
13
- // Request for the `Status` method.
14
- message StatusRequest {}
15
-
16
- // Response for the `Status` method.
17
- message StatusResponse {
18
- // The current head of the chain.
19
- Cursor current_head = 1;
20
- // The last cursor that was ingested by the node.
21
- Cursor last_ingested = 2;
22
- }
@@ -1,83 +0,0 @@
1
- // Apibara DNA server V2
2
- syntax = "proto3";
3
-
4
- package dna.v2.stream;
5
-
6
- import "common.proto";
7
-
8
- service DnaStream {
9
- // Stream data from the server.
10
- rpc StreamData(StreamDataRequest) returns (stream StreamDataResponse);
11
- // Get DNA server status.
12
- rpc Status(dna.v2.common.StatusRequest)
13
- returns (dna.v2.common.StatusResponse);
14
- }
15
-
16
- // Request data to be streamed.
17
- message StreamDataRequest {
18
- // Cursor to start streaming from.
19
- dna.v2.common.Cursor starting_cursor = 1;
20
- // Return data with the specified finality.
21
- // If not specified, defaults to `DATA_FINALITY_ACCEPTED`.
22
- optional DataFinality finality = 2;
23
- // Filters used to generate data.
24
- repeated bytes filter = 3;
25
- }
26
-
27
- // Contains a piece of streamed data.
28
- message StreamDataResponse {
29
- oneof message {
30
- Data data = 1;
31
- Invalidate invalidate = 2;
32
- Heartbeat heartbeat = 3;
33
- SystemMessage system_message = 4;
34
- }
35
- }
36
-
37
- // Invalidate data after the given cursor.
38
- message Invalidate {
39
- // The cursor of the message before the now invalid data.
40
- dna.v2.common.Cursor cursor = 1;
41
- }
42
-
43
- // A single block of data.
44
- //
45
- // If the request specified multiple filters, the `data` field will contain the
46
- // data for each filter in the same order as the filters were specified in the
47
- // request.
48
- // If no data is available for a filter, the corresponding data field will be
49
- // empty.
50
- message Data {
51
- // Cursor that generated this block of data.
52
- dna.v2.common.Cursor cursor = 1;
53
- // Block cursor. Use this cursor to resume the stream.
54
- dna.v2.common.Cursor end_cursor = 2;
55
- // The finality status of the block.
56
- DataFinality finality = 3;
57
- // The block data.
58
- repeated bytes data = 4;
59
- }
60
-
61
- // Sent to clients to check if stream is still connected.
62
- message Heartbeat {}
63
-
64
- // Message from the server to the client.
65
- message SystemMessage {
66
- oneof output {
67
- // Output to stdout.
68
- string stdout = 1;
69
- // Output to stderr.
70
- string stderr = 2;
71
- }
72
- }
73
-
74
- // Data finality.
75
- enum DataFinality {
76
- DATA_FINALITY_UNKNOWN = 0;
77
- // Data was received, but is not part of the canonical chain yet.
78
- DATA_FINALITY_PENDING = 1;
79
- // Data is now part of the canonical chain, but could still be invalidated.
80
- DATA_FINALITY_ACCEPTED = 2;
81
- // Data is finalized and cannot be invalidated.
82
- DATA_FINALITY_FINALIZED = 3;
83
- }
@@ -1,11 +0,0 @@
1
- syntax = "proto3";
2
-
3
- package dna.v2.testing;
4
-
5
- message MockFilter {
6
- optional string filter = 1;
7
- }
8
-
9
- message MockBlock {
10
- optional string data = 1;
11
- }