@apibara/protocol 2.0.0-beta.9 → 2.1.0-beta.2
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/index.cjs +53 -23
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +50 -25
- package/dist/shared/{protocol.8c2a685d.d.cts → protocol.4b1cfe2c.d.cts} +61 -17
- package/dist/shared/{protocol.8c2a685d.d.mts → protocol.4b1cfe2c.d.mts} +61 -17
- package/dist/shared/{protocol.8c2a685d.d.ts → protocol.4b1cfe2c.d.ts} +61 -17
- package/dist/shared/{protocol.d9596779.mjs → protocol.991ff9ad.mjs} +98 -5
- package/dist/shared/{protocol.e1dec68a.cjs → protocol.e39e40d6.cjs} +100 -4
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.d.cts +5 -4
- package/dist/testing/index.d.mts +5 -4
- package/dist/testing/index.d.ts +5 -4
- package/dist/testing/index.mjs +1 -1
- package/package.json +1 -1
- package/src/client.ts +72 -28
- package/src/common.ts +28 -0
- package/src/proto/stream.ts +60 -1
- package/src/stream.test.ts +16 -0
- package/src/stream.ts +34 -3
- package/src/testing/client.test.ts +28 -2
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const config = require('./shared/protocol.
|
|
3
|
+
const config = require('./shared/protocol.e39e40d6.cjs');
|
|
4
4
|
const schema = require('@effect/schema');
|
|
5
5
|
const niceGrpc = require('nice-grpc');
|
|
6
6
|
require('protobufjs/minimal.js');
|
|
@@ -37,12 +37,23 @@ var __publicField$1 = (obj, key, value) => {
|
|
|
37
37
|
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
38
38
|
return value;
|
|
39
39
|
};
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const DEFAULT_TIMEOUT_MS = 45e3;
|
|
41
|
+
class TimeoutError extends Error {
|
|
42
|
+
constructor(timeout) {
|
|
43
|
+
super(`No message received in ${timeout}ms`);
|
|
44
|
+
this.name = "TimeoutError";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function createClient(config$1, streamUrl, options = {}) {
|
|
48
|
+
const channel = niceGrpc.createChannel(
|
|
49
|
+
streamUrl,
|
|
50
|
+
options?.credentials,
|
|
51
|
+
options?.channelOptions
|
|
52
|
+
);
|
|
42
53
|
const client = niceGrpc.createClient(
|
|
43
54
|
config.DnaStreamDefinition,
|
|
44
55
|
channel,
|
|
45
|
-
defaultCallOptions
|
|
56
|
+
options?.defaultCallOptions
|
|
46
57
|
);
|
|
47
58
|
return new GrpcClient(config$1, client);
|
|
48
59
|
}
|
|
@@ -75,34 +86,47 @@ class StreamDataIterable {
|
|
|
75
86
|
const inner = this.it[Symbol.asyncIterator]();
|
|
76
87
|
const schema$1 = config.StreamDataResponse(this.schema);
|
|
77
88
|
const decoder = schema.Schema.decodeSync(schema$1);
|
|
78
|
-
const { endingCursor } = this.options ?? {};
|
|
89
|
+
const { endingCursor, timeout = DEFAULT_TIMEOUT_MS } = this.options ?? {};
|
|
79
90
|
let shouldStop = false;
|
|
91
|
+
let clock;
|
|
80
92
|
return {
|
|
81
93
|
async next() {
|
|
82
94
|
if (shouldStop) {
|
|
83
95
|
return { done: true, value: void 0 };
|
|
84
96
|
}
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const {
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
const t = new Promise(
|
|
98
|
+
(_, reject) => {
|
|
99
|
+
clock = setTimeout(() => {
|
|
100
|
+
reject(new TimeoutError(timeout));
|
|
101
|
+
}, timeout);
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
try {
|
|
105
|
+
const { done, value } = await Promise.race([inner.next(), t]);
|
|
106
|
+
clearTimeout(clock);
|
|
107
|
+
if (done || value.message === void 0) {
|
|
108
|
+
return { done: true, value: void 0 };
|
|
109
|
+
}
|
|
110
|
+
const decodedMessage = decoder(value.message);
|
|
111
|
+
if (endingCursor) {
|
|
112
|
+
assert__default(value.message.$case === "data");
|
|
113
|
+
assert__default(decodedMessage._tag === "data");
|
|
114
|
+
const { orderKey, uniqueKey } = endingCursor;
|
|
115
|
+
const endCursor = decodedMessage.data.endCursor;
|
|
116
|
+
if (orderKey === endCursor?.orderKey) {
|
|
117
|
+
if (!uniqueKey || uniqueKey === endCursor.uniqueKey) {
|
|
118
|
+
shouldStop = true;
|
|
119
|
+
return { done: false, value: decodedMessage };
|
|
120
|
+
}
|
|
99
121
|
}
|
|
100
122
|
}
|
|
123
|
+
return {
|
|
124
|
+
done: false,
|
|
125
|
+
value: decodedMessage
|
|
126
|
+
};
|
|
127
|
+
} finally {
|
|
128
|
+
clearTimeout(clock);
|
|
101
129
|
}
|
|
102
|
-
return {
|
|
103
|
-
done: false,
|
|
104
|
-
value: decodedMessage
|
|
105
|
-
};
|
|
106
130
|
}
|
|
107
131
|
};
|
|
108
132
|
}
|
|
@@ -162,6 +186,7 @@ exports.Cursor = config.Cursor;
|
|
|
162
186
|
exports.CursorFromBytes = config.CursorFromBytes;
|
|
163
187
|
exports.Data = config.Data;
|
|
164
188
|
exports.DataFinality = config.DataFinality;
|
|
189
|
+
exports.DataProduction = config.DataProduction;
|
|
165
190
|
exports.DnaStreamDefinition = config.DnaStreamDefinition;
|
|
166
191
|
exports.Duration = config.Duration;
|
|
167
192
|
exports.Finalize = config.Finalize;
|
|
@@ -179,11 +204,16 @@ exports.cursorFromBytes = config.cursorFromBytes;
|
|
|
179
204
|
exports.cursorFromProto = config.cursorFromProto;
|
|
180
205
|
exports.cursorToBytes = config.cursorToBytes;
|
|
181
206
|
exports.cursorToProto = config.cursorToProto;
|
|
207
|
+
exports.isCursor = config.isCursor;
|
|
208
|
+
exports.normalizeCursor = config.normalizeCursor;
|
|
209
|
+
exports.ClientError = niceGrpc.ClientError;
|
|
210
|
+
exports.Status = niceGrpc.Status;
|
|
182
211
|
exports.GrpcClient = GrpcClient;
|
|
183
212
|
exports.RateGauge = RateGauge;
|
|
184
213
|
exports.StatusRequest = StatusRequest;
|
|
185
214
|
exports.StatusResponse = StatusResponse;
|
|
186
215
|
exports.StreamDataIterable = StreamDataIterable;
|
|
216
|
+
exports.TimeoutError = TimeoutError;
|
|
187
217
|
exports.createClient = createClient;
|
|
188
218
|
exports.proto = index;
|
|
189
219
|
exports.statusRequestFromProto = statusRequestFromProto;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { s as stream } from './shared/protocol.
|
|
2
|
-
export { B as Bytes, b as BytesFromUint8Array,
|
|
1
|
+
import { s as stream } from './shared/protocol.4b1cfe2c.cjs';
|
|
2
|
+
export { B as Bytes, b as BytesFromUint8Array, J as Client, E as ClientCallOptions, K as CreateClientOptions, c as Cursor, g as CursorFromBytes, C as CursorProto, y as Data, q as DataFinality, r as DataProduction, D as DnaStreamClient, a as DnaStreamDefinition, t as Duration, F as Finalize, M as GrpcClient, H as Heartbeat, I as Invalidate, S as StatusRequest, m as StatusResponse, w as StdErr, v as StdOut, A as StreamConfig, N as StreamDataIterable, G as StreamDataOptions, u as StreamDataRequest, z as StreamDataResponse, x as SystemMessage, T as TimeoutError, _ as _Cursor, L as createClient, d as createCursor, i as cursorFromBytes, f as cursorFromProto, h as cursorToBytes, e as cursorToProto, j as isCursor, n as normalizeCursor, l as statusRequestFromProto, k as statusRequestToProto, p as statusResponseFromProto, o as statusResponseToProto } from './shared/protocol.4b1cfe2c.cjs';
|
|
3
3
|
import _m0 from 'protobufjs/minimal.js';
|
|
4
|
+
export { ClientError, Status } from 'nice-grpc';
|
|
4
5
|
import '@effect/schema';
|
|
5
|
-
import 'nice-grpc';
|
|
6
6
|
import 'nice-grpc-common';
|
|
7
7
|
import '@effect/schema/AST';
|
|
8
8
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { s as stream } from './shared/protocol.
|
|
2
|
-
export { B as Bytes, b as BytesFromUint8Array,
|
|
1
|
+
import { s as stream } from './shared/protocol.4b1cfe2c.mjs';
|
|
2
|
+
export { B as Bytes, b as BytesFromUint8Array, J as Client, E as ClientCallOptions, K as CreateClientOptions, c as Cursor, g as CursorFromBytes, C as CursorProto, y as Data, q as DataFinality, r as DataProduction, D as DnaStreamClient, a as DnaStreamDefinition, t as Duration, F as Finalize, M as GrpcClient, H as Heartbeat, I as Invalidate, S as StatusRequest, m as StatusResponse, w as StdErr, v as StdOut, A as StreamConfig, N as StreamDataIterable, G as StreamDataOptions, u as StreamDataRequest, z as StreamDataResponse, x as SystemMessage, T as TimeoutError, _ as _Cursor, L as createClient, d as createCursor, i as cursorFromBytes, f as cursorFromProto, h as cursorToBytes, e as cursorToProto, j as isCursor, n as normalizeCursor, l as statusRequestFromProto, k as statusRequestToProto, p as statusResponseFromProto, o as statusResponseToProto } from './shared/protocol.4b1cfe2c.mjs';
|
|
3
3
|
import _m0 from 'protobufjs/minimal.js';
|
|
4
|
+
export { ClientError, Status } from 'nice-grpc';
|
|
4
5
|
import '@effect/schema';
|
|
5
|
-
import 'nice-grpc';
|
|
6
6
|
import 'nice-grpc-common';
|
|
7
7
|
import '@effect/schema/AST';
|
|
8
8
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { s as stream } from './shared/protocol.
|
|
2
|
-
export { B as Bytes, b as BytesFromUint8Array,
|
|
1
|
+
import { s as stream } from './shared/protocol.4b1cfe2c.js';
|
|
2
|
+
export { B as Bytes, b as BytesFromUint8Array, J as Client, E as ClientCallOptions, K as CreateClientOptions, c as Cursor, g as CursorFromBytes, C as CursorProto, y as Data, q as DataFinality, r as DataProduction, D as DnaStreamClient, a as DnaStreamDefinition, t as Duration, F as Finalize, M as GrpcClient, H as Heartbeat, I as Invalidate, S as StatusRequest, m as StatusResponse, w as StdErr, v as StdOut, A as StreamConfig, N as StreamDataIterable, G as StreamDataOptions, u as StreamDataRequest, z as StreamDataResponse, x as SystemMessage, T as TimeoutError, _ as _Cursor, L as createClient, d as createCursor, i as cursorFromBytes, f as cursorFromProto, h as cursorToBytes, e as cursorToProto, j as isCursor, n as normalizeCursor, l as statusRequestFromProto, k as statusRequestToProto, p as statusResponseFromProto, o as statusResponseToProto } from './shared/protocol.4b1cfe2c.js';
|
|
3
3
|
import _m0 from 'protobufjs/minimal.js';
|
|
4
|
+
export { ClientError, Status } from 'nice-grpc';
|
|
4
5
|
import '@effect/schema';
|
|
5
|
-
import 'nice-grpc';
|
|
6
6
|
import 'nice-grpc-common';
|
|
7
7
|
import '@effect/schema/AST';
|
|
8
8
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { s as stream, t as testing, C as Cursor, D as DnaStreamDefinition, S as StreamDataResponse } from './shared/protocol.
|
|
2
|
-
export { B as Bytes, a as BytesFromUint8Array, e as CursorFromBytes,
|
|
1
|
+
import { s as stream, t as testing, C as Cursor, D as DnaStreamDefinition, S as StreamDataResponse } from './shared/protocol.991ff9ad.mjs';
|
|
2
|
+
export { B as Bytes, a as BytesFromUint8Array, e as CursorFromBytes, q as Data, h as DataFinality, j as DataProduction, k as Duration, F as Finalize, H as Heartbeat, I as Invalidate, o as StdErr, m as StdOut, r as StreamConfig, l as StreamDataRequest, p as SystemMessage, _ as _Cursor, c as createCursor, g as cursorFromBytes, d as cursorFromProto, f as cursorToBytes, b as cursorToProto, i as isCursor, n as normalizeCursor } from './shared/protocol.991ff9ad.mjs';
|
|
3
3
|
import { Schema } from '@effect/schema';
|
|
4
4
|
import { createChannel, createClient as createClient$1 } from 'nice-grpc';
|
|
5
|
+
export { ClientError, Status } from 'nice-grpc';
|
|
5
6
|
import 'protobufjs/minimal.js';
|
|
6
7
|
import assert from 'node:assert';
|
|
7
8
|
import 'effect';
|
|
@@ -32,12 +33,23 @@ var __publicField$1 = (obj, key, value) => {
|
|
|
32
33
|
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
33
34
|
return value;
|
|
34
35
|
};
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
const DEFAULT_TIMEOUT_MS = 45e3;
|
|
37
|
+
class TimeoutError extends Error {
|
|
38
|
+
constructor(timeout) {
|
|
39
|
+
super(`No message received in ${timeout}ms`);
|
|
40
|
+
this.name = "TimeoutError";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function createClient(config, streamUrl, options = {}) {
|
|
44
|
+
const channel = createChannel(
|
|
45
|
+
streamUrl,
|
|
46
|
+
options?.credentials,
|
|
47
|
+
options?.channelOptions
|
|
48
|
+
);
|
|
37
49
|
const client = createClient$1(
|
|
38
50
|
DnaStreamDefinition,
|
|
39
51
|
channel,
|
|
40
|
-
defaultCallOptions
|
|
52
|
+
options?.defaultCallOptions
|
|
41
53
|
);
|
|
42
54
|
return new GrpcClient(config, client);
|
|
43
55
|
}
|
|
@@ -70,34 +82,47 @@ class StreamDataIterable {
|
|
|
70
82
|
const inner = this.it[Symbol.asyncIterator]();
|
|
71
83
|
const schema = StreamDataResponse(this.schema);
|
|
72
84
|
const decoder = Schema.decodeSync(schema);
|
|
73
|
-
const { endingCursor } = this.options ?? {};
|
|
85
|
+
const { endingCursor, timeout = DEFAULT_TIMEOUT_MS } = this.options ?? {};
|
|
74
86
|
let shouldStop = false;
|
|
87
|
+
let clock;
|
|
75
88
|
return {
|
|
76
89
|
async next() {
|
|
77
90
|
if (shouldStop) {
|
|
78
91
|
return { done: true, value: void 0 };
|
|
79
92
|
}
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const {
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
const t = new Promise(
|
|
94
|
+
(_, reject) => {
|
|
95
|
+
clock = setTimeout(() => {
|
|
96
|
+
reject(new TimeoutError(timeout));
|
|
97
|
+
}, timeout);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
try {
|
|
101
|
+
const { done, value } = await Promise.race([inner.next(), t]);
|
|
102
|
+
clearTimeout(clock);
|
|
103
|
+
if (done || value.message === void 0) {
|
|
104
|
+
return { done: true, value: void 0 };
|
|
105
|
+
}
|
|
106
|
+
const decodedMessage = decoder(value.message);
|
|
107
|
+
if (endingCursor) {
|
|
108
|
+
assert(value.message.$case === "data");
|
|
109
|
+
assert(decodedMessage._tag === "data");
|
|
110
|
+
const { orderKey, uniqueKey } = endingCursor;
|
|
111
|
+
const endCursor = decodedMessage.data.endCursor;
|
|
112
|
+
if (orderKey === endCursor?.orderKey) {
|
|
113
|
+
if (!uniqueKey || uniqueKey === endCursor.uniqueKey) {
|
|
114
|
+
shouldStop = true;
|
|
115
|
+
return { done: false, value: decodedMessage };
|
|
116
|
+
}
|
|
94
117
|
}
|
|
95
118
|
}
|
|
119
|
+
return {
|
|
120
|
+
done: false,
|
|
121
|
+
value: decodedMessage
|
|
122
|
+
};
|
|
123
|
+
} finally {
|
|
124
|
+
clearTimeout(clock);
|
|
96
125
|
}
|
|
97
|
-
return {
|
|
98
|
-
done: false,
|
|
99
|
-
value: decodedMessage
|
|
100
|
-
};
|
|
101
126
|
}
|
|
102
127
|
};
|
|
103
128
|
}
|
|
@@ -151,4 +176,4 @@ class RateGauge {
|
|
|
151
176
|
}
|
|
152
177
|
}
|
|
153
178
|
|
|
154
|
-
export { Cursor, DnaStreamDefinition, GrpcClient, RateGauge, StatusRequest, StatusResponse, StreamDataIterable, StreamDataResponse, createClient, index as proto, statusRequestFromProto, statusRequestToProto, statusResponseFromProto, statusResponseToProto };
|
|
179
|
+
export { Cursor, DnaStreamDefinition, GrpcClient, RateGauge, StatusRequest, StatusResponse, StreamDataIterable, StreamDataResponse, TimeoutError, createClient, index as proto, statusRequestFromProto, statusRequestToProto, statusResponseFromProto, statusResponseToProto };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from '@effect/schema';
|
|
2
|
-
import { DefaultCallOptions, NormalizedServiceDefinition } from 'nice-grpc';
|
|
2
|
+
import { DefaultCallOptions, NormalizedServiceDefinition, ChannelCredentials, ChannelOptions } from 'nice-grpc';
|
|
3
3
|
import { CallContext, CallOptions } from 'nice-grpc-common';
|
|
4
4
|
import _m0 from 'protobufjs/minimal.js';
|
|
5
5
|
import * as _effect_schema_AST from '@effect/schema/AST';
|
|
@@ -115,6 +115,17 @@ declare enum DataFinality$1 {
|
|
|
115
115
|
}
|
|
116
116
|
declare function dataFinalityFromJSON(object: any): DataFinality$1;
|
|
117
117
|
declare function dataFinalityToJSON(object: DataFinality$1): string;
|
|
118
|
+
/** Data production mode. */
|
|
119
|
+
declare enum DataProduction$1 {
|
|
120
|
+
UNKNOWN = 0,
|
|
121
|
+
/** BACKFILL - Data is for a backfilled block. */
|
|
122
|
+
BACKFILL = 1,
|
|
123
|
+
/** LIVE - Data is for a live block. */
|
|
124
|
+
LIVE = 2,
|
|
125
|
+
UNRECOGNIZED = -1
|
|
126
|
+
}
|
|
127
|
+
declare function dataProductionFromJSON(object: any): DataProduction$1;
|
|
128
|
+
declare function dataProductionToJSON(object: DataProduction$1): string;
|
|
118
129
|
/** A cursor over the stream content. */
|
|
119
130
|
interface Cursor$1 {
|
|
120
131
|
/**
|
|
@@ -286,6 +297,8 @@ interface Data$1 {
|
|
|
286
297
|
* This message contains chain-specific data serialized using protobuf.
|
|
287
298
|
*/
|
|
288
299
|
readonly data: readonly Uint8Array[];
|
|
300
|
+
/** The production mode of the block. */
|
|
301
|
+
readonly production: DataProduction$1;
|
|
289
302
|
}
|
|
290
303
|
declare const Data$1: {
|
|
291
304
|
encode(message: Data$1, writer?: _m0.Writer): _m0.Writer;
|
|
@@ -410,9 +423,11 @@ type stream_DnaStreamServiceImplementation<CallContextExt = {}> = DnaStreamServi
|
|
|
410
423
|
type stream_ServerStreamingMethodResult<Response> = ServerStreamingMethodResult<Response>;
|
|
411
424
|
declare const stream_dataFinalityFromJSON: typeof dataFinalityFromJSON;
|
|
412
425
|
declare const stream_dataFinalityToJSON: typeof dataFinalityToJSON;
|
|
426
|
+
declare const stream_dataProductionFromJSON: typeof dataProductionFromJSON;
|
|
427
|
+
declare const stream_dataProductionToJSON: typeof dataProductionToJSON;
|
|
413
428
|
declare const stream_protobufPackage: typeof protobufPackage;
|
|
414
429
|
declare namespace stream {
|
|
415
|
-
export { Cursor$1 as Cursor, Data$1 as Data, DataFinality$1 as DataFinality, type stream_DeepPartial as DeepPartial, type stream_DnaStreamClient as DnaStreamClient, stream_DnaStreamDefinition as DnaStreamDefinition, type stream_DnaStreamServiceImplementation as DnaStreamServiceImplementation, Finalize$1 as Finalize, Heartbeat$1 as Heartbeat, Invalidate$1 as Invalidate, type stream_ServerStreamingMethodResult as ServerStreamingMethodResult, StatusRequest$1 as StatusRequest, StatusResponse$1 as StatusResponse, StreamDataRequest$1 as StreamDataRequest, StreamDataResponse$1 as StreamDataResponse, SystemMessage$1 as SystemMessage, stream_dataFinalityFromJSON as dataFinalityFromJSON, stream_dataFinalityToJSON as dataFinalityToJSON, stream_protobufPackage as protobufPackage };
|
|
430
|
+
export { Cursor$1 as Cursor, Data$1 as Data, DataFinality$1 as DataFinality, DataProduction$1 as DataProduction, type stream_DeepPartial as DeepPartial, type stream_DnaStreamClient as DnaStreamClient, stream_DnaStreamDefinition as DnaStreamDefinition, type stream_DnaStreamServiceImplementation as DnaStreamServiceImplementation, Finalize$1 as Finalize, Heartbeat$1 as Heartbeat, Invalidate$1 as Invalidate, type stream_ServerStreamingMethodResult as ServerStreamingMethodResult, StatusRequest$1 as StatusRequest, StatusResponse$1 as StatusResponse, StreamDataRequest$1 as StreamDataRequest, StreamDataResponse$1 as StreamDataResponse, SystemMessage$1 as SystemMessage, stream_dataFinalityFromJSON as dataFinalityFromJSON, stream_dataFinalityToJSON as dataFinalityToJSON, stream_dataProductionFromJSON as dataProductionFromJSON, stream_dataProductionToJSON as dataProductionToJSON, stream_protobufPackage as protobufPackage };
|
|
416
431
|
}
|
|
417
432
|
|
|
418
433
|
/** Bytes encoded as a 0x-prefixed hex string. */
|
|
@@ -438,6 +453,18 @@ declare const cursorFromProto: (i: CursorProto, overrideOptions?: _effect_schema
|
|
|
438
453
|
declare const CursorFromBytes: Schema.transform<Schema.Schema<Uint8Array, Uint8Array, never>, Schema.Schema<Cursor, CursorProto, never>>;
|
|
439
454
|
declare const cursorToBytes: (a: Cursor, overrideOptions?: _effect_schema_AST.ParseOptions) => Uint8Array;
|
|
440
455
|
declare const cursorFromBytes: (i: Uint8Array, overrideOptions?: _effect_schema_AST.ParseOptions) => Cursor;
|
|
456
|
+
declare function isCursor(value: unknown): value is Cursor;
|
|
457
|
+
/** Normalize a cursor.
|
|
458
|
+
*
|
|
459
|
+
* The challenge is that the `Cursor` validator expects `uniqueKey` to be either a `0x${string}`
|
|
460
|
+
* or not present at all. Setting the field to `undefined` will result in a validation error.
|
|
461
|
+
*
|
|
462
|
+
* @param cursor The cursor to normalize
|
|
463
|
+
*/
|
|
464
|
+
declare function normalizeCursor(cursor: {
|
|
465
|
+
orderKey: bigint;
|
|
466
|
+
uniqueKey: string | null;
|
|
467
|
+
}): Cursor;
|
|
441
468
|
|
|
442
469
|
/** The request to the `status` endpoint. */
|
|
443
470
|
declare const StatusRequest: Schema.Struct<{}>;
|
|
@@ -478,6 +505,9 @@ declare const statusResponseFromProto: (i: {
|
|
|
478
505
|
/** Data finality. */
|
|
479
506
|
declare const DataFinality: Schema.transform<Schema.Enums<typeof DataFinality$1>, Schema.Literal<["finalized", "accepted", "pending", "unknown"]>>;
|
|
480
507
|
type DataFinality = typeof DataFinality.Type;
|
|
508
|
+
/** 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;
|
|
481
511
|
declare const Duration: Schema.Struct<{
|
|
482
512
|
seconds: typeof Schema.BigIntFromSelf;
|
|
483
513
|
nanos: typeof Schema.Number;
|
|
@@ -528,13 +558,13 @@ type StdErr = typeof StdErr.Type;
|
|
|
528
558
|
declare const SystemMessage: Schema.Struct<{
|
|
529
559
|
_tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
|
|
530
560
|
systemMessage: Schema.Struct<{
|
|
531
|
-
output: Schema.
|
|
561
|
+
output: Schema.Union<[Schema.Struct<{
|
|
532
562
|
_tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
|
|
533
563
|
stdout: typeof Schema.String;
|
|
534
564
|
}>, Schema.Struct<{
|
|
535
565
|
_tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
|
|
536
566
|
stderr: typeof Schema.String;
|
|
537
|
-
}>]
|
|
567
|
+
}>]>;
|
|
538
568
|
}>;
|
|
539
569
|
}>;
|
|
540
570
|
type SystemMessage = typeof SystemMessage.Type;
|
|
@@ -542,8 +572,9 @@ declare const Data: <TA, TR>(schema: Schema.Schema<TA | null, Uint8Array, TR>) =
|
|
|
542
572
|
_tag: Schema.PropertySignature<":", "data", "$case", ":", "data", false, never>;
|
|
543
573
|
data: Schema.Struct<{
|
|
544
574
|
cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
|
|
545
|
-
endCursor: Schema.
|
|
575
|
+
endCursor: Schema.Schema<Cursor, CursorProto, never>;
|
|
546
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"]>>;
|
|
547
578
|
data: Schema.Array$<Schema.Schema<TA | null, Uint8Array, TR>>;
|
|
548
579
|
}>;
|
|
549
580
|
}>;
|
|
@@ -562,13 +593,13 @@ declare const ResponseWithoutData: Schema.Union<[Schema.Struct<{
|
|
|
562
593
|
}>, Schema.Struct<{
|
|
563
594
|
_tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
|
|
564
595
|
systemMessage: Schema.Struct<{
|
|
565
|
-
output: Schema.
|
|
596
|
+
output: Schema.Union<[Schema.Struct<{
|
|
566
597
|
_tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
|
|
567
598
|
stdout: typeof Schema.String;
|
|
568
599
|
}>, Schema.Struct<{
|
|
569
600
|
_tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
|
|
570
601
|
stderr: typeof Schema.String;
|
|
571
|
-
}>]
|
|
602
|
+
}>]>;
|
|
572
603
|
}>;
|
|
573
604
|
}>]>;
|
|
574
605
|
type ResponseWithoutData = typeof ResponseWithoutData.Type;
|
|
@@ -576,8 +607,9 @@ declare const StreamDataResponse: <TA, TR>(data: Schema.Schema<TA | null, Uint8A
|
|
|
576
607
|
_tag: Schema.PropertySignature<":", "data", "$case", ":", "data", false, never>;
|
|
577
608
|
data: Schema.Struct<{
|
|
578
609
|
cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
|
|
579
|
-
endCursor: Schema.
|
|
610
|
+
endCursor: Schema.Schema<Cursor, CursorProto, never>;
|
|
580
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"]>>;
|
|
581
613
|
data: Schema.Array$<Schema.Schema<TA | null, Uint8Array, TR>>;
|
|
582
614
|
}>;
|
|
583
615
|
}>, Schema.Struct<{
|
|
@@ -595,21 +627,22 @@ declare const StreamDataResponse: <TA, TR>(data: Schema.Schema<TA | null, Uint8A
|
|
|
595
627
|
}>, Schema.Struct<{
|
|
596
628
|
_tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
|
|
597
629
|
systemMessage: Schema.Struct<{
|
|
598
|
-
output: Schema.
|
|
630
|
+
output: Schema.Union<[Schema.Struct<{
|
|
599
631
|
_tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
|
|
600
632
|
stdout: typeof Schema.String;
|
|
601
633
|
}>, Schema.Struct<{
|
|
602
634
|
_tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
|
|
603
635
|
stderr: typeof Schema.String;
|
|
604
|
-
}>]
|
|
636
|
+
}>]>;
|
|
605
637
|
}>;
|
|
606
638
|
}>]>;
|
|
607
639
|
type StreamDataResponse<TA> = ResponseWithoutData | {
|
|
608
640
|
_tag: "data";
|
|
609
641
|
data: {
|
|
610
642
|
cursor?: Cursor | undefined;
|
|
611
|
-
endCursor
|
|
643
|
+
endCursor: Cursor;
|
|
612
644
|
finality: DataFinality;
|
|
645
|
+
production: DataProduction;
|
|
613
646
|
data: readonly (TA | null)[];
|
|
614
647
|
};
|
|
615
648
|
};
|
|
@@ -641,8 +674,9 @@ declare class StreamConfig<TFilter, TBlock> {
|
|
|
641
674
|
_tag: Schema.PropertySignature<":", "data", "$case", ":", "data", false, never>;
|
|
642
675
|
data: Schema.Struct<{
|
|
643
676
|
cursor: Schema.optional<Schema.Schema<Cursor, CursorProto, never>>;
|
|
644
|
-
endCursor: Schema.
|
|
677
|
+
endCursor: Schema.Schema<Cursor, CursorProto, never>;
|
|
645
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"]>>;
|
|
646
680
|
data: Schema.Array$<Schema.Schema<TBlock | null, Uint8Array, never>>;
|
|
647
681
|
}>;
|
|
648
682
|
}>, Schema.Struct<{
|
|
@@ -660,24 +694,29 @@ declare class StreamConfig<TFilter, TBlock> {
|
|
|
660
694
|
}>, Schema.Struct<{
|
|
661
695
|
_tag: Schema.PropertySignature<":", "systemMessage", "$case", ":", "systemMessage", false, never>;
|
|
662
696
|
systemMessage: Schema.Struct<{
|
|
663
|
-
output: Schema.
|
|
697
|
+
output: Schema.Union<[Schema.Struct<{
|
|
664
698
|
_tag: Schema.PropertySignature<":", "stdout", "$case", ":", "stdout", false, never>;
|
|
665
699
|
stdout: typeof Schema.String;
|
|
666
700
|
}>, Schema.Struct<{
|
|
667
701
|
_tag: Schema.PropertySignature<":", "stderr", "$case", ":", "stderr", false, never>;
|
|
668
702
|
stderr: typeof Schema.String;
|
|
669
|
-
}>]
|
|
703
|
+
}>]>;
|
|
670
704
|
}>;
|
|
671
705
|
}>]>;
|
|
672
706
|
}
|
|
673
707
|
|
|
708
|
+
declare class TimeoutError extends Error {
|
|
709
|
+
constructor(timeout: number);
|
|
710
|
+
}
|
|
674
711
|
/** Client call options. */
|
|
675
712
|
interface ClientCallOptions {
|
|
676
713
|
signal?: AbortSignal;
|
|
677
714
|
}
|
|
678
715
|
interface StreamDataOptions extends ClientCallOptions {
|
|
679
|
-
/** Stop at the specified cursor (inclusive) */
|
|
716
|
+
/** Stop at the specified cursor (inclusive). */
|
|
680
717
|
endingCursor?: Cursor;
|
|
718
|
+
/** Timeout between messages, in milliseconds. */
|
|
719
|
+
timeout?: number;
|
|
681
720
|
}
|
|
682
721
|
/** DNA client. */
|
|
683
722
|
interface Client<TFilter, TBlock> {
|
|
@@ -686,8 +725,13 @@ interface Client<TFilter, TBlock> {
|
|
|
686
725
|
/** Start streaming data from the DNA server. */
|
|
687
726
|
streamData(request: StreamDataRequest<TFilter>, options?: StreamDataOptions): AsyncIterable<StreamDataResponse<TBlock>>;
|
|
688
727
|
}
|
|
728
|
+
type CreateClientOptions = {
|
|
729
|
+
defaultCallOptions?: DefaultCallOptions<NormalizedServiceDefinition<DnaStreamDefinition>>;
|
|
730
|
+
credentials?: ChannelCredentials;
|
|
731
|
+
channelOptions?: ChannelOptions;
|
|
732
|
+
};
|
|
689
733
|
/** Create a client connecting to the DNA grpc service. */
|
|
690
|
-
declare function createClient<TFilter, TBlock>(config: StreamConfig<TFilter, TBlock>, streamUrl: string,
|
|
734
|
+
declare function createClient<TFilter, TBlock>(config: StreamConfig<TFilter, TBlock>, streamUrl: string, options?: CreateClientOptions): GrpcClient<TFilter, TBlock>;
|
|
691
735
|
declare class GrpcClient<TFilter, TBlock> implements Client<TFilter, TBlock> {
|
|
692
736
|
private config;
|
|
693
737
|
private client;
|
|
@@ -709,4 +753,4 @@ declare class StreamDataIterable<TBlock> {
|
|
|
709
753
|
[Symbol.asyncIterator](): AsyncIterator<StreamDataResponse<TBlock>>;
|
|
710
754
|
}
|
|
711
755
|
|
|
712
|
-
export {
|
|
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 };
|