@apibara/protocol 0.4.8 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +9 -9
- package/dist/client.js +26 -14
- package/dist/client.js.map +1 -1
- package/dist/cursor.d.ts +2 -2
- package/dist/cursor.js +2 -2
- package/dist/cursor.js.map +1 -1
- package/dist/cursor.test.js +6 -6
- package/dist/cursor.test.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js.map +1 -1
- package/dist/proto/apibara/node/v1alpha2/Data.d.ts +3 -3
- package/dist/proto/apibara/node/v1alpha2/DataFinality.d.ts +8 -6
- package/dist/proto/apibara/node/v1alpha2/DataFinality.js +6 -7
- package/dist/proto/apibara/node/v1alpha2/DataFinality.js.map +1 -1
- package/dist/proto/apibara/node/v1alpha2/StreamDataRequest.d.ts +3 -3
- package/dist/proto/index.d.ts +1 -1
- package/dist/proto/index.js.map +1 -1
- package/dist/proto/stream.d.ts +1 -1
- package/dist/proto/testing.d.ts +1 -1
- package/dist/proto/testing.js +4 -2
- package/dist/proto/testing.js.map +1 -1
- package/dist/proto/v1alpha2.d.ts +9 -9
- package/dist/proto/v1alpha2.js +1 -1
- package/dist/proto/v1alpha2.js.map +1 -1
- package/dist/request.d.ts +2 -2
- package/dist/request.js +1 -0
- package/dist/request.js.map +1 -1
- package/dist/request.test.js +9 -10
- package/dist/request.test.js.map +1 -1
- package/package.json +4 -3
- package/src/client.ts +118 -97
- package/src/cursor.test.ts +16 -15
- package/src/cursor.ts +17 -15
- package/src/index.ts +4 -4
- package/src/proto/apibara/node/v1alpha2/Data.ts +3 -3
- package/src/proto/apibara/node/v1alpha2/DataFinality.ts +18 -6
- package/src/proto/apibara/node/v1alpha2/StreamDataRequest.ts +3 -3
- package/src/proto/index.ts +1 -1
- package/src/proto/testing.ts +5 -5
- package/src/proto/v1alpha2.ts +16 -14
- package/src/request.test.ts +19 -20
- package/src/request.ts +16 -16
package/dist/client.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ChannelCredentials, ClientDuplexStream, ClientOptions, StatusObject } from
|
|
2
|
-
import { v1alpha2 } from
|
|
3
|
-
export { ChannelCredentials, StatusObject } from
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
import { ChannelCredentials, ClientDuplexStream, ClientOptions, StatusObject } from "@grpc/grpc-js";
|
|
2
|
+
import { v1alpha2 } from "./proto";
|
|
3
|
+
export { ChannelCredentials, StatusObject } from "@grpc/grpc-js";
|
|
4
|
+
export type DataStream = ClientDuplexStream<v1alpha2.IStreamDataRequest, v1alpha2.IStreamDataResponse>;
|
|
5
|
+
export type ConfigureArgs = {
|
|
6
6
|
/**
|
|
7
7
|
* Stream filter, encoded.
|
|
8
8
|
*/
|
|
@@ -23,7 +23,7 @@ export declare type ConfigureArgs = {
|
|
|
23
23
|
/**
|
|
24
24
|
* Reconnect callback return value.
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
26
|
+
export type OnReconnectResult = {
|
|
27
27
|
/**
|
|
28
28
|
* If `true`, reconnects to the stream.
|
|
29
29
|
*/
|
|
@@ -39,8 +39,8 @@ export declare type OnReconnectResult = {
|
|
|
39
39
|
/**
|
|
40
40
|
* Reconnect callback.
|
|
41
41
|
*/
|
|
42
|
-
export
|
|
43
|
-
export
|
|
42
|
+
export type OnReconnect = (err: StatusObject, retryCount: number) => Promise<OnReconnectResult> | OnReconnectResult;
|
|
43
|
+
export type StreamClientArgs = {
|
|
44
44
|
/**
|
|
45
45
|
* The stream url.
|
|
46
46
|
*/
|
|
@@ -101,7 +101,7 @@ export declare class StreamClient {
|
|
|
101
101
|
* }
|
|
102
102
|
* ```
|
|
103
103
|
*/
|
|
104
|
-
constructor({ url, credentials, clientOptions, token, onReconnect, timeout }: StreamClientArgs);
|
|
104
|
+
constructor({ url, credentials, clientOptions, token, onReconnect, timeout, }: StreamClientArgs);
|
|
105
105
|
/**
|
|
106
106
|
* Async iterator over messages in the stream.
|
|
107
107
|
*/
|
package/dist/client.js
CHANGED
|
@@ -15,6 +15,12 @@ const DEFAULT_MESSAGE_LENGTH = 128 * 1048576; // 128 MiB
|
|
|
15
15
|
* A client to configure and stream data.
|
|
16
16
|
*/
|
|
17
17
|
class StreamClient {
|
|
18
|
+
inner;
|
|
19
|
+
stream;
|
|
20
|
+
stream_id;
|
|
21
|
+
onReconnect;
|
|
22
|
+
configuration;
|
|
23
|
+
timeout;
|
|
18
24
|
/**
|
|
19
25
|
* Create a new `StreamClient`.
|
|
20
26
|
*
|
|
@@ -34,15 +40,15 @@ class StreamClient {
|
|
|
34
40
|
* }
|
|
35
41
|
* ```
|
|
36
42
|
*/
|
|
37
|
-
constructor({ url, credentials, clientOptions, token, onReconnect, timeout }) {
|
|
43
|
+
constructor({ url, credentials, clientOptions, token, onReconnect, timeout, }) {
|
|
38
44
|
const baseCredentials = credentials ?? grpc_js_1.ChannelCredentials.createSsl();
|
|
39
45
|
// only secure credentials can be composed with metadata generators.
|
|
40
46
|
const credentialsWithMetadata = baseCredentials._isSecure()
|
|
41
47
|
? baseCredentials.compose(grpc_js_1.CallCredentials.createFromMetadataGenerator(createMetadataGenerator(token)))
|
|
42
48
|
: baseCredentials;
|
|
43
49
|
this.inner = new StreamService(url, credentialsWithMetadata, {
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
"grpc.keepalive_timeout_ms": 3600000,
|
|
51
|
+
"grpc.max_receive_message_length": DEFAULT_MESSAGE_LENGTH,
|
|
46
52
|
...clientOptions,
|
|
47
53
|
});
|
|
48
54
|
this.stream_id = 0;
|
|
@@ -54,7 +60,7 @@ class StreamClient {
|
|
|
54
60
|
*/
|
|
55
61
|
async *[Symbol.asyncIterator]() {
|
|
56
62
|
if (!this.configuration) {
|
|
57
|
-
throw new Error(
|
|
63
|
+
throw new Error("StreamClient must be configured");
|
|
58
64
|
}
|
|
59
65
|
// connect if not connected.
|
|
60
66
|
if (!this.stream) {
|
|
@@ -68,20 +74,23 @@ class StreamClient {
|
|
|
68
74
|
try {
|
|
69
75
|
// this check is to make ts happy
|
|
70
76
|
if (!this.stream) {
|
|
71
|
-
throw new Error(
|
|
77
|
+
throw new Error("Stream disconnected unexpectedly");
|
|
72
78
|
}
|
|
73
79
|
const streamIter = this.stream[Symbol.asyncIterator]();
|
|
74
80
|
while (true) {
|
|
75
81
|
const timeout = new Promise((_, reject) => {
|
|
76
82
|
clock = setTimeout(() => {
|
|
77
|
-
reject(new Error(
|
|
83
|
+
reject(new Error("Stream timed out"));
|
|
78
84
|
}, this.timeout);
|
|
79
85
|
});
|
|
80
86
|
const message = (await Promise.race([streamIter.next(), timeout]));
|
|
81
87
|
const messageTyped = message.value;
|
|
82
88
|
clearTimeout(clock);
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
if (messageTyped.message === "heartbeat") {
|
|
90
|
+
yield messageTyped;
|
|
91
|
+
}
|
|
92
|
+
else if (messageTyped.streamId?.toString() === this.stream_id.toString()) {
|
|
93
|
+
// only return messages if they are with the most recently configured stream
|
|
85
94
|
// reset retry count on new message
|
|
86
95
|
retryCount = 1;
|
|
87
96
|
// keep cursor updated for use when reconnecting
|
|
@@ -94,12 +103,13 @@ class StreamClient {
|
|
|
94
103
|
yield messageTyped;
|
|
95
104
|
}
|
|
96
105
|
}
|
|
106
|
+
// rome-ignore lint: any is needed for catch
|
|
97
107
|
}
|
|
98
108
|
catch (err) {
|
|
99
109
|
clearTimeout(clock);
|
|
100
|
-
const isGrpcError =
|
|
101
|
-
|
|
102
|
-
|
|
110
|
+
const isGrpcError = Object.hasOwn(err, "code") &&
|
|
111
|
+
Object.hasOwn(err, "details") &&
|
|
112
|
+
Object.hasOwn(err, "metadata");
|
|
103
113
|
// non-grpc error, so just bubble it up
|
|
104
114
|
if (!isGrpcError) {
|
|
105
115
|
throw err;
|
|
@@ -141,7 +151,9 @@ class StreamClient {
|
|
|
141
151
|
this.stream_id++;
|
|
142
152
|
// only send configuration if connected
|
|
143
153
|
if (this.stream) {
|
|
144
|
-
const builder = request_1.StreamDataRequest.create()
|
|
154
|
+
const builder = request_1.StreamDataRequest.create()
|
|
155
|
+
.withStreamId(this.stream_id)
|
|
156
|
+
.withFilter(filter);
|
|
145
157
|
if (batchSize) {
|
|
146
158
|
builder.withBatchSize(batchSize);
|
|
147
159
|
}
|
|
@@ -177,7 +189,7 @@ exports.neverReconnect = neverReconnect;
|
|
|
177
189
|
* This callback awaits for `1s * retryCount` before returning.
|
|
178
190
|
*/
|
|
179
191
|
async function defaultOnReconnect(err, retryCount) {
|
|
180
|
-
if (err.code
|
|
192
|
+
if (err.code !== 13) {
|
|
181
193
|
return {
|
|
182
194
|
reconnect: false,
|
|
183
195
|
};
|
|
@@ -194,7 +206,7 @@ exports.defaultOnReconnect = defaultOnReconnect;
|
|
|
194
206
|
function createMetadataGenerator(token) {
|
|
195
207
|
const metadata = new grpc_js_1.Metadata();
|
|
196
208
|
if (token) {
|
|
197
|
-
metadata.add(
|
|
209
|
+
metadata.add("authorization", `bearer ${token}`);
|
|
198
210
|
}
|
|
199
211
|
return (_options, cb) => {
|
|
200
212
|
cb(null, metadata);
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,2CAOuB;AAEvB,mCAAmC;AACnC,uCAA8C;AAE9C,yCAAiE;AAAxD,6GAAA,kBAAkB,OAAA;AAE3B,MAAM,aAAa,GAAG,gBAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AAE5E,oFAAoF;AACpF,MAAM,kBAAkB,GAAG,KAAM,CAAC;AAElC,kDAAkD;AAClD,MAAM,sBAAsB,GAAG,GAAG,GAAG,OAAS,CAAC,CAAC,UAAU;AA6F1D;;GAEG;AACH,M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gDAcC;AAED;;GAEG;AACH,SAAS,uBAAuB,CAAC,KAAc;IAC7C,MAAM,QAAQ,GAAG,IAAI,kBAAQ,EAAE,CAAC;IAChC,IAAI,KAAK,EAAE;QACT,QAAQ,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,KAAK,EAAE,CAAC,CAAC;KAClD;IAED,OAAO,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE;QACtB,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/cursor.d.ts
CHANGED
package/dist/cursor.js
CHANGED
|
@@ -36,7 +36,7 @@ exports.Cursor = {
|
|
|
36
36
|
fromObject({ orderKey, uniqueKey }) {
|
|
37
37
|
return {
|
|
38
38
|
orderKey: long_1.default.fromString(orderKey),
|
|
39
|
-
uniqueKey: Buffer.from(uniqueKey.slice(2),
|
|
39
|
+
uniqueKey: Buffer.from(uniqueKey.slice(2), "hex"),
|
|
40
40
|
};
|
|
41
41
|
},
|
|
42
42
|
/**
|
|
@@ -58,7 +58,7 @@ exports.Cursor = {
|
|
|
58
58
|
},
|
|
59
59
|
};
|
|
60
60
|
function _toObject(cursor) {
|
|
61
|
-
|
|
61
|
+
const hash = Buffer.from(cursor.uniqueKey).toString("hex");
|
|
62
62
|
return {
|
|
63
63
|
orderKey: cursor.orderKey.toString(),
|
|
64
64
|
uniqueKey: `0x${hash}`,
|
package/dist/cursor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.js","sourceRoot":"","sources":["../src/cursor.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"cursor.js","sourceRoot":"","sources":["../src/cursor.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAGX,QAAA,MAAM,GAAG;IACpB;;;;;OAKG;IACH,kBAAkB,EAAE,CAAC,KAA6B,EAAW,EAAE;QAC7D,OAAO;YACL,QAAQ,EAAE,cAAI,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,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const long_1 = __importDefault(require("long"));
|
|
7
7
|
const cursor_1 = require("./cursor");
|
|
8
|
-
describe(
|
|
9
|
-
it(
|
|
8
|
+
describe("Cursor", () => {
|
|
9
|
+
it("can be converted to and from javascript objects", () => {
|
|
10
10
|
const cursorObject = {
|
|
11
|
-
orderKey:
|
|
12
|
-
uniqueKey:
|
|
11
|
+
orderKey: "1234",
|
|
12
|
+
uniqueKey: "0x05dd5e4f023a81a8daaf86b8bf3967b04276a89c81b840e8e55d658323854ad7",
|
|
13
13
|
};
|
|
14
14
|
const cursor = cursor_1.Cursor.fromObject(cursorObject);
|
|
15
15
|
expect(cursor.orderKey).toEqual(long_1.default.fromNumber(1234));
|
|
16
16
|
expect(cursor.uniqueKey).toHaveLength(32);
|
|
17
17
|
const back = cursor_1.Cursor.toObject(cursor);
|
|
18
|
-
expect(back
|
|
19
|
-
expect(back
|
|
18
|
+
expect(back?.orderKey).toEqual(cursorObject.orderKey);
|
|
19
|
+
expect(back?.uniqueKey).toEqual(cursorObject.uniqueKey);
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
22
|
//# sourceMappingURL=cursor.test.js.map
|
package/dist/cursor.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.test.js","sourceRoot":"","sources":["../src/cursor.test.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"cursor.test.js","sourceRoot":"","sources":["../src/cursor.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AACxB,qCAAkC;AAElC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,YAAY,GAAG;YACnB,QAAQ,EAAE,MAAM;YAChB,SAAS,EACP,oEAAoE;SACvE,CAAC;QAEF,MAAM,MAAM,GAAG,eAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QAC/C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,cAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QAE1C,MAAM,IAAI,GAAG,eAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAErC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./proto";
|
|
2
|
+
export * from "./client";
|
|
3
|
+
export * from "./request";
|
|
4
|
+
export * from "./cursor";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB;AACzB,4CAA0B;AAC1B,2CAAyB"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Cursor as _apibara_node_v1alpha2_Cursor, Cursor__Output as _apibara_node_v1alpha2_Cursor__Output } from '../../../apibara/node/v1alpha2/Cursor';
|
|
3
|
-
import type { DataFinality as _apibara_node_v1alpha2_DataFinality } from '../../../apibara/node/v1alpha2/DataFinality';
|
|
3
|
+
import type { DataFinality as _apibara_node_v1alpha2_DataFinality, DataFinality__Output as _apibara_node_v1alpha2_DataFinality__Output } from '../../../apibara/node/v1alpha2/DataFinality';
|
|
4
4
|
export interface Data {
|
|
5
5
|
'endCursor'?: (_apibara_node_v1alpha2_Cursor | null);
|
|
6
|
-
'finality'?: (_apibara_node_v1alpha2_DataFinality
|
|
6
|
+
'finality'?: (_apibara_node_v1alpha2_DataFinality);
|
|
7
7
|
'data'?: (Buffer | Uint8Array | string)[];
|
|
8
8
|
'cursor'?: (_apibara_node_v1alpha2_Cursor | null);
|
|
9
9
|
}
|
|
10
10
|
export interface Data__Output {
|
|
11
11
|
'endCursor': (_apibara_node_v1alpha2_Cursor__Output | null);
|
|
12
|
-
'finality': (
|
|
12
|
+
'finality': (_apibara_node_v1alpha2_DataFinality__Output);
|
|
13
13
|
'data': (Uint8Array)[];
|
|
14
14
|
'cursor': (_apibara_node_v1alpha2_Cursor__Output | null);
|
|
15
15
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
DATA_STATUS_UNKNOWN
|
|
3
|
-
DATA_STATUS_PENDING
|
|
4
|
-
DATA_STATUS_ACCEPTED
|
|
5
|
-
DATA_STATUS_FINALIZED
|
|
6
|
-
}
|
|
1
|
+
export declare const DataFinality: {
|
|
2
|
+
readonly DATA_STATUS_UNKNOWN: "DATA_STATUS_UNKNOWN";
|
|
3
|
+
readonly DATA_STATUS_PENDING: "DATA_STATUS_PENDING";
|
|
4
|
+
readonly DATA_STATUS_ACCEPTED: "DATA_STATUS_ACCEPTED";
|
|
5
|
+
readonly DATA_STATUS_FINALIZED: "DATA_STATUS_FINALIZED";
|
|
6
|
+
};
|
|
7
|
+
export type DataFinality = 'DATA_STATUS_UNKNOWN' | 0 | 'DATA_STATUS_PENDING' | 1 | 'DATA_STATUS_ACCEPTED' | 2 | 'DATA_STATUS_FINALIZED' | 3;
|
|
8
|
+
export type DataFinality__Output = typeof DataFinality[keyof typeof DataFinality];
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
// Original file: src/proto/stream.proto
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.DataFinality = void 0;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
})(DataFinality = exports.DataFinality || (exports.DataFinality = {}));
|
|
5
|
+
exports.DataFinality = {
|
|
6
|
+
DATA_STATUS_UNKNOWN: 'DATA_STATUS_UNKNOWN',
|
|
7
|
+
DATA_STATUS_PENDING: 'DATA_STATUS_PENDING',
|
|
8
|
+
DATA_STATUS_ACCEPTED: 'DATA_STATUS_ACCEPTED',
|
|
9
|
+
DATA_STATUS_FINALIZED: 'DATA_STATUS_FINALIZED',
|
|
10
|
+
};
|
|
12
11
|
//# sourceMappingURL=DataFinality.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataFinality.js","sourceRoot":"","sources":["../../../../../src/proto/apibara/node/v1alpha2/DataFinality.ts"],"names":[],"mappings":";AAAA,wCAAwC;;;
|
|
1
|
+
{"version":3,"file":"DataFinality.js","sourceRoot":"","sources":["../../../../../src/proto/apibara/node/v1alpha2/DataFinality.ts"],"names":[],"mappings":";AAAA,wCAAwC;;;AAE3B,QAAA,YAAY,GAAG;IAC1B,mBAAmB,EAAE,qBAAqB;IAC1C,mBAAmB,EAAE,qBAAqB;IAC1C,oBAAoB,EAAE,sBAAsB;IAC5C,qBAAqB,EAAE,uBAAuB;CACtC,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Cursor as _apibara_node_v1alpha2_Cursor, Cursor__Output as _apibara_node_v1alpha2_Cursor__Output } from '../../../apibara/node/v1alpha2/Cursor';
|
|
3
|
-
import type { DataFinality as _apibara_node_v1alpha2_DataFinality } from '../../../apibara/node/v1alpha2/DataFinality';
|
|
3
|
+
import type { DataFinality as _apibara_node_v1alpha2_DataFinality, DataFinality__Output as _apibara_node_v1alpha2_DataFinality__Output } from '../../../apibara/node/v1alpha2/DataFinality';
|
|
4
4
|
import type { Long } from '@grpc/proto-loader';
|
|
5
5
|
export interface StreamDataRequest {
|
|
6
6
|
'streamId'?: (number | string | Long);
|
|
7
7
|
'batchSize'?: (number | string | Long);
|
|
8
8
|
'startingCursor'?: (_apibara_node_v1alpha2_Cursor | null);
|
|
9
|
-
'finality'?: (_apibara_node_v1alpha2_DataFinality
|
|
9
|
+
'finality'?: (_apibara_node_v1alpha2_DataFinality);
|
|
10
10
|
'filter'?: (Buffer | Uint8Array | string);
|
|
11
11
|
'_streamId'?: "streamId";
|
|
12
12
|
'_batchSize'?: "batchSize";
|
|
@@ -16,7 +16,7 @@ export interface StreamDataRequest__Output {
|
|
|
16
16
|
'streamId'?: (Long);
|
|
17
17
|
'batchSize'?: (Long);
|
|
18
18
|
'startingCursor': (_apibara_node_v1alpha2_Cursor__Output | null);
|
|
19
|
-
'finality'?: (
|
|
19
|
+
'finality'?: (_apibara_node_v1alpha2_DataFinality__Output);
|
|
20
20
|
'filter': (Uint8Array);
|
|
21
21
|
'_streamId': "streamId";
|
|
22
22
|
'_batchSize': "batchSize";
|
package/dist/proto/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * as v1alpha2 from
|
|
1
|
+
export * as v1alpha2 from "./v1alpha2";
|
package/dist/proto/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/proto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/proto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAuC"}
|
package/dist/proto/stream.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as grpc from '@grpc/grpc-js';
|
|
2
2
|
import type { EnumTypeDefinition, MessageTypeDefinition } from '@grpc/proto-loader';
|
|
3
3
|
import type { StreamClient as _apibara_node_v1alpha2_StreamClient, StreamDefinition as _apibara_node_v1alpha2_StreamDefinition } from './apibara/node/v1alpha2/Stream';
|
|
4
|
-
|
|
4
|
+
type SubtypeConstructor<Constructor extends new (...args: any) => any, Subtype> = {
|
|
5
5
|
new (...args: ConstructorParameters<Constructor>): Subtype;
|
|
6
6
|
};
|
|
7
7
|
export interface ProtoGrpcType {
|
package/dist/proto/testing.d.ts
CHANGED
package/dist/proto/testing.js
CHANGED
|
@@ -9,13 +9,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.TestFilter = void 0;
|
|
10
10
|
const light_1 = require("protobufjs/light");
|
|
11
11
|
class TestFilter extends light_1.Message {
|
|
12
|
+
num;
|
|
13
|
+
text;
|
|
12
14
|
}
|
|
13
15
|
__decorate([
|
|
14
|
-
light_1.Field.d(1,
|
|
16
|
+
light_1.Field.d(1, "uint64")
|
|
15
17
|
// @ts-ignore
|
|
16
18
|
], TestFilter.prototype, "num", void 0);
|
|
17
19
|
__decorate([
|
|
18
|
-
light_1.Field.d(2,
|
|
20
|
+
light_1.Field.d(2, "string")
|
|
19
21
|
// @ts-ignore
|
|
20
22
|
], TestFilter.prototype, "text", void 0);
|
|
21
23
|
exports.TestFilter = TestFilter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../../src/proto/testing.ts"],"names":[],"mappings":";;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../../src/proto/testing.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4CAAkD;AAElD,MAAa,UAAW,SAAQ,eAAmB;IAG1C,GAAG,CAAS;IAIZ,IAAI,CAAS;CACrB;AALC;IAFC,aAAK,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC;IACrB,aAAa;uCACM;AAInB;IAFC,aAAK,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC;IACrB,aAAa;wCACO;AAPtB,gCAQC"}
|
package/dist/proto/v1alpha2.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ProtoGrpcType } from
|
|
1
|
+
import { ProtoGrpcType } from "./stream";
|
|
2
2
|
export declare const packageDefinition: import("@grpc/proto-loader").PackageDefinition;
|
|
3
3
|
export declare const protoDescriptor: ProtoGrpcType;
|
|
4
|
-
export { Cursor__Output as ICursor } from
|
|
5
|
-
export { Data__Output as IData } from
|
|
6
|
-
export { DataFinality } from
|
|
7
|
-
export { Heartbeat__Output as IHeartbeat } from
|
|
8
|
-
export { Invalidate__Output as IInvalidate } from
|
|
9
|
-
export { StreamClient } from
|
|
10
|
-
export { StreamDataRequest as IStreamDataRequest } from
|
|
11
|
-
export { StreamDataResponse__Output as IStreamDataResponse } from
|
|
4
|
+
export { Cursor__Output as ICursor } from "./apibara/node/v1alpha2/Cursor";
|
|
5
|
+
export { Data__Output as IData } from "./apibara/node/v1alpha2/Data";
|
|
6
|
+
export { DataFinality } from "./apibara/node/v1alpha2/DataFinality";
|
|
7
|
+
export { Heartbeat__Output as IHeartbeat } from "./apibara/node/v1alpha2/Heartbeat";
|
|
8
|
+
export { Invalidate__Output as IInvalidate } from "./apibara/node/v1alpha2/Invalidate";
|
|
9
|
+
export { StreamClient } from "./apibara/node/v1alpha2/Stream";
|
|
10
|
+
export { StreamDataRequest as IStreamDataRequest } from "./apibara/node/v1alpha2/StreamDataRequest";
|
|
11
|
+
export { StreamDataResponse__Output as IStreamDataResponse } from "./apibara/node/v1alpha2/StreamDataResponse";
|
package/dist/proto/v1alpha2.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DataFinality = exports.protoDescriptor = exports.packageDefinition = void 0;
|
|
4
4
|
const grpc_js_1 = require("@grpc/grpc-js");
|
|
5
5
|
const proto_loader_1 = require("@grpc/proto-loader");
|
|
6
|
-
const __NODE_PROTO_PATH = __dirname +
|
|
6
|
+
const __NODE_PROTO_PATH = __dirname + "/stream.proto";
|
|
7
7
|
// export definitions
|
|
8
8
|
exports.packageDefinition = (0, proto_loader_1.loadSync)(__NODE_PROTO_PATH, {
|
|
9
9
|
oneofs: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1alpha2.js","sourceRoot":"","sources":["../../src/proto/v1alpha2.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"v1alpha2.js","sourceRoot":"","sources":["../../src/proto/v1alpha2.ts"],"names":[],"mappings":";;;AAAA,2CAAsD;AACtD,qDAA8C;AAG9C,MAAM,iBAAiB,GAAG,SAAS,GAAG,eAAe,CAAC;AAEtD,qBAAqB;AACR,QAAA,iBAAiB,GAAG,IAAA,uBAAQ,EAAC,iBAAiB,EAAE;IAC3D,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC;AACU,QAAA,eAAe,GAAG,IAAA,+BAAqB,EAClD,yBAAiB,CACU,CAAC;AAK9B,qEAAoE;AAA3D,4GAAA,YAAY,OAAA"}
|
package/dist/request.d.ts
CHANGED
package/dist/request.js
CHANGED
package/dist/request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":";;;AAGa,QAAA,iBAAiB,GAAG;IAC/B;;OAEG;IACH,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,wBAAwB,EAAE;CAC7C,
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":";;;AAGa,QAAA,iBAAiB,GAAG;IAC/B;;OAEG;IACH,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,wBAAwB,EAAE;CAC7C,CAAC;AAEF,MAAa,wBAAwB;IAC3B,OAAO,CAA8B;IAE7C;QACE,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,QAAuB;QAClC,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,IAAmB;QAC/B,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,MAAwB;QACzC,IAAI,CAAC,OAAO,CAAC,cAAc,GAAG,MAAM,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,QAA+B;QAC1C,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,MAAkB;QAC3B,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AArDD,4DAqDC"}
|
package/dist/request.test.js
CHANGED
|
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const proto_1 = require("./proto");
|
|
4
4
|
const testing_1 = require("./proto/testing");
|
|
5
5
|
const request_1 = require("./request");
|
|
6
|
-
describe(
|
|
7
|
-
it(
|
|
8
|
-
const filter = new testing_1.TestFilter(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
6
|
+
describe("RequestBuilder", () => {
|
|
7
|
+
it("returns the final request", () => {
|
|
8
|
+
const filter = new testing_1.TestFilter();
|
|
9
|
+
filter.num = 123;
|
|
10
|
+
filter.text = "abcdef";
|
|
12
11
|
const request = request_1.StreamDataRequest.create()
|
|
13
12
|
.withBatchSize(10)
|
|
14
13
|
.withFilter(testing_1.TestFilter.encode(filter).finish())
|
|
@@ -18,12 +17,12 @@ describe('RequestBuilder', () => {
|
|
|
18
17
|
expect(request.filter).toBeInstanceOf(Buffer);
|
|
19
18
|
expect(request.filter?.length).toEqual(10);
|
|
20
19
|
// make ts happy
|
|
21
|
-
if (!request.filter || typeof request.filter
|
|
22
|
-
throw new Error(
|
|
20
|
+
if (!request.filter || typeof request.filter === "string") {
|
|
21
|
+
throw new Error("undefined filter");
|
|
23
22
|
}
|
|
24
23
|
const back = testing_1.TestFilter.decode(request.filter);
|
|
25
|
-
expect(back.num.toString()).toEqual(
|
|
26
|
-
expect(back.text).toEqual(
|
|
24
|
+
expect(back.num.toString()).toEqual("123");
|
|
25
|
+
expect(back.text).toEqual("abcdef");
|
|
27
26
|
});
|
|
28
27
|
});
|
|
29
28
|
//# sourceMappingURL=request.test.js.map
|
package/dist/request.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.test.js","sourceRoot":"","sources":["../src/request.test.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"request.test.js","sourceRoot":"","sources":["../src/request.test.ts"],"names":[],"mappings":";;AAAA,mCAAmC;AACnC,6CAA6C;AAC7C,uCAA8C;AAE9C,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACnC,MAAM,MAAM,GAAG,IAAI,oBAAU,EAAE,CAAC;QAChC,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;QACjB,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;QAEvB,MAAM,OAAO,GAAG,2BAAiB,CAAC,MAAM,EAAE;aACvC,aAAa,CAAC,EAAE,CAAC;aACjB,UAAU,CAAC,oBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;aAC9C,YAAY,CAAC,gBAAQ,CAAC,YAAY,CAAC,qBAAqB,CAAC;aACzD,MAAM,EAAE,CAAC;QAEZ,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACtC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC9C,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAE3C,gBAAgB;QAChB,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE;YACzD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACrC;QAED,MAAM,IAAI,GAAG,oBAAU,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC/C,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apibara/protocol",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
"prebuild": "pnpm run protobuf && pnpm run gen-types",
|
|
25
25
|
"build": "tsc",
|
|
26
26
|
"test": "jest src/",
|
|
27
|
-
"lint": "
|
|
28
|
-
"lint:fix": "
|
|
27
|
+
"lint": "biome check .",
|
|
28
|
+
"lint:fix": "pnpm lint --apply",
|
|
29
|
+
"format": "biome format . --write",
|
|
29
30
|
"protobuf": "mkdir -p dist/proto && cp src/proto/*.proto dist/proto",
|
|
30
31
|
"gen-types": "proto-loader-gen-types --bytes=Array --longs=Long --enums=String --defaults --oneofs --grpcLib=@grpc/grpc-js --outDir=src/proto src/proto/*.proto"
|
|
31
32
|
}
|