@apibara/protocol 2.0.0-beta.5 → 2.0.0-beta.6

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.
@@ -0,0 +1,105 @@
1
+ 'use strict';
2
+
3
+ const schema = require('@effect/schema');
4
+ const config = require('../shared/protocol.474b6107.cjs');
5
+ require('protobufjs/minimal');
6
+ require('effect');
7
+ require('viem');
8
+ require('long');
9
+
10
+ class MockClient {
11
+ constructor(messageFactory) {
12
+ this.messageFactory = messageFactory;
13
+ }
14
+ async status(request, options) {
15
+ throw new Error("Client.status is not implemented for VcrClient");
16
+ }
17
+ streamData(request, options) {
18
+ const messages = this.messageFactory(request, options);
19
+ return new StreamDataIterable(messages);
20
+ }
21
+ }
22
+ class StreamDataIterable {
23
+ constructor(messages) {
24
+ this.messages = messages;
25
+ }
26
+ [Symbol.asyncIterator]() {
27
+ let index = 0;
28
+ const messages = this.messages;
29
+ return {
30
+ async next() {
31
+ if (index >= messages.length) {
32
+ return { done: true, value: void 0 };
33
+ }
34
+ const message = messages[index++];
35
+ if (message instanceof Error) {
36
+ throw message;
37
+ }
38
+ return { done: false, value: message };
39
+ }
40
+ };
41
+ }
42
+ }
43
+
44
+ const MockFilter = schema.Schema.Struct({
45
+ filter: schema.Schema.optional(schema.Schema.String)
46
+ });
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
+ }
58
+ }
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();
79
+ }
80
+ }
81
+ );
82
+ function mergeMockFilter(a, b) {
83
+ let filter = "";
84
+ if (a.filter) {
85
+ filter += a.filter;
86
+ }
87
+ if (b.filter) {
88
+ filter += b.filter;
89
+ }
90
+ return { filter };
91
+ }
92
+ const MockStream = new config.StreamConfig(
93
+ MockFilterFromBytes,
94
+ MockBlockFromBytes,
95
+ mergeMockFilter
96
+ );
97
+ const MockStreamResponse = config.StreamDataResponse(MockBlockFromBytes);
98
+
99
+ exports.MockBlockFromBytes = MockBlockFromBytes;
100
+ exports.MockClient = MockClient;
101
+ exports.MockFilter = MockFilter;
102
+ exports.MockFilterFromBytes = MockFilterFromBytes;
103
+ exports.MockStream = MockStream;
104
+ exports.MockStreamResponse = MockStreamResponse;
105
+ exports.StreamDataIterable = StreamDataIterable;
@@ -0,0 +1,75 @@
1
+ import { A as Client, q as StreamDataRequest, z as StreamDataOptions, w as StreamDataResponse, S as StatusRequest, y as ClientCallOptions, l as StatusResponse, x as StreamConfig, c as Cursor, C as CursorProto, K as DataFinality } from '../shared/protocol.42d7ad57.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<":", "finalize", "$case", ":", "finalize", false, never>;
56
+ finalize: Schema.Struct<{
57
+ cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
58
+ }>;
59
+ }>, Schema.Struct<{
60
+ _tag: Schema.PropertySignature<":", "heartbeat", "$case", ":", "heartbeat", false, never>;
61
+ }>, Schema.Struct<{
62
+ _tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
63
+ systemMessage: Schema.Struct<{
64
+ output: Schema.optional<Schema.Union<[Schema.Struct<{
65
+ _tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
66
+ stdout: typeof Schema.String;
67
+ }>, Schema.Struct<{
68
+ _tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
69
+ stderr: typeof Schema.String;
70
+ }>]>>;
71
+ }>;
72
+ }>]>;
73
+ type MockStreamResponse = typeof MockStreamResponse.Type;
74
+
75
+ export { MockBlock, MockBlockFromBytes, MockClient, MockFilter, MockFilterFromBytes, MockStream, MockStreamResponse, StreamDataIterable };
@@ -0,0 +1,75 @@
1
+ import { A as Client, q as StreamDataRequest, z as StreamDataOptions, w as StreamDataResponse, S as StatusRequest, y as ClientCallOptions, l as StatusResponse, x as StreamConfig, c as Cursor, C as CursorProto, K as DataFinality } from '../shared/protocol.42d7ad57.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<":", "finalize", "$case", ":", "finalize", false, never>;
56
+ finalize: Schema.Struct<{
57
+ cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
58
+ }>;
59
+ }>, Schema.Struct<{
60
+ _tag: Schema.PropertySignature<":", "heartbeat", "$case", ":", "heartbeat", false, never>;
61
+ }>, Schema.Struct<{
62
+ _tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
63
+ systemMessage: Schema.Struct<{
64
+ output: Schema.optional<Schema.Union<[Schema.Struct<{
65
+ _tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
66
+ stdout: typeof Schema.String;
67
+ }>, Schema.Struct<{
68
+ _tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
69
+ stderr: typeof Schema.String;
70
+ }>]>>;
71
+ }>;
72
+ }>]>;
73
+ type MockStreamResponse = typeof MockStreamResponse.Type;
74
+
75
+ export { MockBlock, MockBlockFromBytes, MockClient, MockFilter, MockFilterFromBytes, MockStream, MockStreamResponse, StreamDataIterable };
@@ -0,0 +1,75 @@
1
+ import { A as Client, q as StreamDataRequest, z as StreamDataOptions, w as StreamDataResponse, S as StatusRequest, y as ClientCallOptions, l as StatusResponse, x as StreamConfig, c as Cursor, C as CursorProto, K as DataFinality } from '../shared/protocol.42d7ad57.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<":", "finalize", "$case", ":", "finalize", false, never>;
56
+ finalize: Schema.Struct<{
57
+ cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
58
+ }>;
59
+ }>, Schema.Struct<{
60
+ _tag: Schema.PropertySignature<":", "heartbeat", "$case", ":", "heartbeat", false, never>;
61
+ }>, Schema.Struct<{
62
+ _tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
63
+ systemMessage: Schema.Struct<{
64
+ output: Schema.optional<Schema.Union<[Schema.Struct<{
65
+ _tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
66
+ stdout: typeof Schema.String;
67
+ }>, Schema.Struct<{
68
+ _tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
69
+ stderr: typeof Schema.String;
70
+ }>]>>;
71
+ }>;
72
+ }>]>;
73
+ type MockStreamResponse = typeof MockStreamResponse.Type;
74
+
75
+ export { MockBlock, MockBlockFromBytes, MockClient, MockFilter, MockFilterFromBytes, MockStream, MockStreamResponse, StreamDataIterable };
@@ -0,0 +1,97 @@
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.ff7dfded.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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apibara/protocol",
3
- "version": "2.0.0-beta.5",
3
+ "version": "2.0.0-beta.6",
4
4
  "type": "module",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./dist/index.mjs",