@apibara/protocol 2.1.0-beta.23 → 2.1.0-beta.24
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/codec.cjs +241 -0
- package/dist/codec.d.cts +81 -0
- package/dist/codec.d.mts +81 -0
- package/dist/codec.d.ts +81 -0
- package/dist/codec.mjs +223 -0
- package/dist/index.cjs +15 -29
- package/dist/index.d.cts +3 -4
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.mjs +14 -19
- package/dist/shared/{protocol.4b1cfe2c.d.cts → protocol.68a15d69.d.mts} +398 -247
- package/dist/shared/{protocol.4b1cfe2c.d.mts → protocol.8b5e318a.d.ts} +398 -247
- package/dist/shared/{protocol.991ff9ad.mjs → protocol.a64f7660.mjs} +173 -170
- package/dist/shared/{protocol.e39e40d6.cjs → protocol.d8bad371.cjs} +174 -176
- package/dist/shared/{protocol.4b1cfe2c.d.ts → protocol.f52df848.d.cts} +398 -247
- package/dist/testing/index.cjs +23 -37
- package/dist/testing/index.d.cts +107 -54
- package/dist/testing/index.d.mts +107 -54
- package/dist/testing/index.d.ts +107 -54
- package/dist/testing/index.mjs +23 -37
- package/package.json +7 -3
- package/src/client.ts +7 -12
- package/src/codec.ts +662 -0
- package/src/common.ts +70 -53
- package/src/config.ts +3 -4
- package/src/proto/google/protobuf/duration.ts +8 -6
- package/src/proto/stream.ts +38 -24
- package/src/status.ts +9 -16
- package/src/stream.ts +145 -144
- package/src/testing/mock.ts +35 -38
- package/src/common.test.ts +0 -67
- package/src/status.test.ts +0 -51
- package/src/stream.test-d.ts +0 -33
- package/src/stream.test.ts +0 -254
- package/src/testing/client.test.ts +0 -97
- package/src/testing/mock.test.ts +0 -35
package/dist/codec.mjs
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
function MessageCodec(schema) {
|
|
2
|
+
return {
|
|
3
|
+
encode(app) {
|
|
4
|
+
return new Proxy(app, {
|
|
5
|
+
get(target, property) {
|
|
6
|
+
if (!Object.hasOwn(target, property)) {
|
|
7
|
+
return Reflect.get(target, property);
|
|
8
|
+
}
|
|
9
|
+
const v = Reflect.get(target, property);
|
|
10
|
+
return schema[property].encode(v);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
decode(proto) {
|
|
15
|
+
return new Proxy(proto, {
|
|
16
|
+
get(target, property) {
|
|
17
|
+
if (!Object.hasOwn(target, property)) {
|
|
18
|
+
return Reflect.get(target, property);
|
|
19
|
+
}
|
|
20
|
+
const v = Reflect.get(target, property);
|
|
21
|
+
return schema[property].decode(v);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function ArrayCodec(t) {
|
|
28
|
+
return {
|
|
29
|
+
encode(app) {
|
|
30
|
+
return app.map(t.encode);
|
|
31
|
+
},
|
|
32
|
+
decode(proto) {
|
|
33
|
+
if (proto === void 0)
|
|
34
|
+
return [];
|
|
35
|
+
return proto.map(t.decode);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function MutableArrayCodec(t) {
|
|
40
|
+
return {
|
|
41
|
+
encode(app) {
|
|
42
|
+
return app.map(t.encode);
|
|
43
|
+
},
|
|
44
|
+
decode(proto) {
|
|
45
|
+
if (proto === void 0)
|
|
46
|
+
return [];
|
|
47
|
+
return proto.map(t.decode);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function OptionalCodec(t) {
|
|
52
|
+
return {
|
|
53
|
+
encode(app) {
|
|
54
|
+
if (app === void 0)
|
|
55
|
+
return void 0;
|
|
56
|
+
return t.encode(app);
|
|
57
|
+
},
|
|
58
|
+
decode(proto) {
|
|
59
|
+
if (proto === void 0)
|
|
60
|
+
return void 0;
|
|
61
|
+
return t.decode(proto);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function RequiredCodec(t) {
|
|
66
|
+
return {
|
|
67
|
+
encode(app) {
|
|
68
|
+
if (app === void 0)
|
|
69
|
+
throw new Error("Value is required but undefined");
|
|
70
|
+
return t.encode(app);
|
|
71
|
+
},
|
|
72
|
+
decode(proto) {
|
|
73
|
+
if (proto === void 0)
|
|
74
|
+
throw new Error("Value is required but undefined");
|
|
75
|
+
return t.decode(proto);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function NullOrCodec(t) {
|
|
80
|
+
return {
|
|
81
|
+
encode(app) {
|
|
82
|
+
if (app === null)
|
|
83
|
+
return null;
|
|
84
|
+
return t.encode(app);
|
|
85
|
+
},
|
|
86
|
+
decode(proto) {
|
|
87
|
+
if (proto === null)
|
|
88
|
+
return null;
|
|
89
|
+
return t.decode(proto);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const BigIntCodec = {
|
|
94
|
+
encode(app) {
|
|
95
|
+
return app;
|
|
96
|
+
},
|
|
97
|
+
decode(proto) {
|
|
98
|
+
return proto;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const NumberCodec = {
|
|
102
|
+
encode(app) {
|
|
103
|
+
return app;
|
|
104
|
+
},
|
|
105
|
+
decode(proto) {
|
|
106
|
+
return proto;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const Uint8ArrayCodec = {
|
|
110
|
+
encode(app) {
|
|
111
|
+
return app;
|
|
112
|
+
},
|
|
113
|
+
decode(proto) {
|
|
114
|
+
return proto;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const DateCodec = {
|
|
118
|
+
encode(app) {
|
|
119
|
+
return new Date(app);
|
|
120
|
+
},
|
|
121
|
+
decode(proto) {
|
|
122
|
+
return new Date(proto);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const BooleanCodec = {
|
|
126
|
+
encode(app) {
|
|
127
|
+
return app;
|
|
128
|
+
},
|
|
129
|
+
decode(proto) {
|
|
130
|
+
return proto;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const StringCodec = {
|
|
134
|
+
encode(app) {
|
|
135
|
+
return app;
|
|
136
|
+
},
|
|
137
|
+
decode(proto) {
|
|
138
|
+
return proto;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const UndefinedCodec = {
|
|
142
|
+
encode(app) {
|
|
143
|
+
return void 0;
|
|
144
|
+
},
|
|
145
|
+
decode(proto) {
|
|
146
|
+
return void 0;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const LiteralCodec = (value) => {
|
|
150
|
+
return {
|
|
151
|
+
encode(app) {
|
|
152
|
+
if (app !== value) {
|
|
153
|
+
throw new Error(`Expected ${String(value)}, got ${String(app)}`);
|
|
154
|
+
}
|
|
155
|
+
return app;
|
|
156
|
+
},
|
|
157
|
+
decode(proto) {
|
|
158
|
+
if (proto !== value) {
|
|
159
|
+
throw new Error(`Expected ${String(value)}, got ${String(proto)}`);
|
|
160
|
+
}
|
|
161
|
+
return proto;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
const LiteralUnionCodec = (values) => {
|
|
166
|
+
return {
|
|
167
|
+
encode(app) {
|
|
168
|
+
if (!values.includes(app)) {
|
|
169
|
+
throw new Error(
|
|
170
|
+
`Expected one of [${values.join(", ")}], got ${String(app)}`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
return app;
|
|
174
|
+
},
|
|
175
|
+
decode(proto) {
|
|
176
|
+
if (!values.includes(proto)) {
|
|
177
|
+
throw new Error(
|
|
178
|
+
`Expected one of [${values.join(", ")}], got ${String(proto)}`
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
return proto;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
const VariantCodec = (options) => {
|
|
186
|
+
return {
|
|
187
|
+
encode(app) {
|
|
188
|
+
const tag = app[options.tag];
|
|
189
|
+
const codec = options.variants[tag];
|
|
190
|
+
if (!codec) {
|
|
191
|
+
throw new Error(`Unknown variant: ${String(tag)}`);
|
|
192
|
+
}
|
|
193
|
+
const variantData = app[tag];
|
|
194
|
+
const encodedData = codec.encode(variantData);
|
|
195
|
+
return {
|
|
196
|
+
[options.discriminator]: tag,
|
|
197
|
+
[tag]: encodedData
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
decode(proto) {
|
|
201
|
+
const tag = proto[options.discriminator];
|
|
202
|
+
const codec = options.variants[tag];
|
|
203
|
+
if (!codec) {
|
|
204
|
+
throw new Error(`Unknown variant: ${String(tag)}`);
|
|
205
|
+
}
|
|
206
|
+
const variantData = proto[tag];
|
|
207
|
+
const decodedData = codec.decode(variantData);
|
|
208
|
+
return {
|
|
209
|
+
[options.tag]: tag,
|
|
210
|
+
[tag]: decodedData
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
function OneOfCodec(variants) {
|
|
216
|
+
return VariantCodec({
|
|
217
|
+
tag: "_tag",
|
|
218
|
+
discriminator: "$case",
|
|
219
|
+
variants
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export { ArrayCodec, BigIntCodec, BooleanCodec, DateCodec, LiteralCodec, LiteralUnionCodec, MessageCodec, MutableArrayCodec, NullOrCodec, NumberCodec, OneOfCodec, OptionalCodec, RequiredCodec, StringCodec, Uint8ArrayCodec, UndefinedCodec, VariantCodec };
|
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const config = require('./shared/protocol.
|
|
4
|
-
const
|
|
3
|
+
const config = require('./shared/protocol.d8bad371.cjs');
|
|
4
|
+
const codec = require('./codec.cjs');
|
|
5
5
|
const niceGrpc = require('nice-grpc');
|
|
6
6
|
require('protobufjs/minimal.js');
|
|
7
7
|
const assert = require('node:assert');
|
|
8
|
-
require('effect');
|
|
9
8
|
require('viem');
|
|
10
9
|
require('long');
|
|
11
10
|
|
|
@@ -19,17 +18,13 @@ const index = {
|
|
|
19
18
|
testing: config.testing
|
|
20
19
|
};
|
|
21
20
|
|
|
22
|
-
const StatusRequest =
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
finalized: schema.Schema.optional(config.Cursor),
|
|
29
|
-
starting: schema.Schema.optional(config.Cursor)
|
|
21
|
+
const StatusRequest = codec.MessageCodec({});
|
|
22
|
+
const StatusResponse = codec.MessageCodec({
|
|
23
|
+
currentHead: codec.OptionalCodec(config.Cursor),
|
|
24
|
+
lastIngested: codec.OptionalCodec(config.Cursor),
|
|
25
|
+
finalized: codec.OptionalCodec(config.Cursor),
|
|
26
|
+
starting: codec.OptionalCodec(config.Cursor)
|
|
30
27
|
});
|
|
31
|
-
const statusResponseToProto = schema.Schema.encodeSync(StatusResponse);
|
|
32
|
-
const statusResponseFromProto = schema.Schema.decodeSync(StatusResponse);
|
|
33
28
|
|
|
34
29
|
var __defProp$1 = Object.defineProperty;
|
|
35
30
|
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -62,14 +57,14 @@ class GrpcClient {
|
|
|
62
57
|
this.config = config;
|
|
63
58
|
this.client = client;
|
|
64
59
|
__publicField$1(this, "encodeRequest");
|
|
65
|
-
this.encodeRequest =
|
|
60
|
+
this.encodeRequest = config.Request.encode;
|
|
66
61
|
}
|
|
67
62
|
async status(request, options) {
|
|
68
63
|
const response = await this.client.status(
|
|
69
|
-
|
|
64
|
+
StatusRequest.encode(request ?? {}),
|
|
70
65
|
options
|
|
71
66
|
);
|
|
72
|
-
return
|
|
67
|
+
return StatusResponse.decode(response);
|
|
73
68
|
}
|
|
74
69
|
streamData(request, options) {
|
|
75
70
|
const it = this.client.streamData(this.encodeRequest(request), options);
|
|
@@ -84,8 +79,8 @@ class StreamDataIterable {
|
|
|
84
79
|
}
|
|
85
80
|
[Symbol.asyncIterator]() {
|
|
86
81
|
const inner = this.it[Symbol.asyncIterator]();
|
|
87
|
-
const schema
|
|
88
|
-
const decoder = schema.
|
|
82
|
+
const schema = config.StreamDataResponse(this.schema);
|
|
83
|
+
const decoder = schema.decode;
|
|
89
84
|
const { endingCursor, timeout = DEFAULT_TIMEOUT_MS } = this.options ?? {};
|
|
90
85
|
let shouldStop = false;
|
|
91
86
|
let clock;
|
|
@@ -180,7 +175,6 @@ class RateGauge {
|
|
|
180
175
|
}
|
|
181
176
|
}
|
|
182
177
|
|
|
183
|
-
exports.Bytes = config.Bytes;
|
|
184
178
|
exports.BytesFromUint8Array = config.BytesFromUint8Array;
|
|
185
179
|
exports.Cursor = config.Cursor;
|
|
186
180
|
exports.CursorFromBytes = config.CursorFromBytes;
|
|
@@ -188,22 +182,18 @@ exports.Data = config.Data;
|
|
|
188
182
|
exports.DataFinality = config.DataFinality;
|
|
189
183
|
exports.DataProduction = config.DataProduction;
|
|
190
184
|
exports.DnaStreamDefinition = config.DnaStreamDefinition;
|
|
191
|
-
exports.
|
|
185
|
+
exports.DurationCodec = config.DurationCodec;
|
|
192
186
|
exports.Finalize = config.Finalize;
|
|
193
187
|
exports.Heartbeat = config.Heartbeat;
|
|
194
188
|
exports.Invalidate = config.Invalidate;
|
|
189
|
+
exports.ResponseWithoutData = config.ResponseWithoutData;
|
|
195
190
|
exports.StdErr = config.StdErr;
|
|
196
191
|
exports.StdOut = config.StdOut;
|
|
197
192
|
exports.StreamConfig = config.StreamConfig;
|
|
198
193
|
exports.StreamDataRequest = config.StreamDataRequest;
|
|
199
194
|
exports.StreamDataResponse = config.StreamDataResponse;
|
|
200
195
|
exports.SystemMessage = config.SystemMessage;
|
|
201
|
-
exports._Cursor = config._Cursor;
|
|
202
196
|
exports.createCursor = config.createCursor;
|
|
203
|
-
exports.cursorFromBytes = config.cursorFromBytes;
|
|
204
|
-
exports.cursorFromProto = config.cursorFromProto;
|
|
205
|
-
exports.cursorToBytes = config.cursorToBytes;
|
|
206
|
-
exports.cursorToProto = config.cursorToProto;
|
|
207
197
|
exports.isCursor = config.isCursor;
|
|
208
198
|
exports.normalizeCursor = config.normalizeCursor;
|
|
209
199
|
exports.ClientError = niceGrpc.ClientError;
|
|
@@ -217,7 +207,3 @@ exports.StreamDataIterable = StreamDataIterable;
|
|
|
217
207
|
exports.TimeoutError = TimeoutError;
|
|
218
208
|
exports.createClient = createClient;
|
|
219
209
|
exports.proto = index;
|
|
220
|
-
exports.statusRequestFromProto = statusRequestFromProto;
|
|
221
|
-
exports.statusRequestToProto = statusRequestToProto;
|
|
222
|
-
exports.statusResponseFromProto = statusResponseFromProto;
|
|
223
|
-
exports.statusResponseToProto = statusResponseToProto;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { s as stream } from './shared/protocol.
|
|
2
|
-
export { B as Bytes, b as BytesFromUint8Array,
|
|
1
|
+
import { s as stream } from './shared/protocol.f52df848.cjs';
|
|
2
|
+
export { B as Bytes, b as BytesFromUint8Array, w as Client, u as ClientCallOptions, x as CreateClientOptions, C as Cursor, e as CursorFromBytes, c as CursorProto, q as Data, g as DataFinality, h as DataProduction, D as DnaStreamClient, a as DnaStreamDefinition, k as Duration, j as DurationCodec, F as Finalize, G as GrpcClient, H as Heartbeat, I as Invalidate, R as ResponseWithoutData, S as StatusRequest, f as StatusResponse, o as StdErr, m as StdOut, t as StreamConfig, z as StreamDataIterable, v as StreamDataOptions, l as StreamDataRequest, r as StreamDataResponse, p as SystemMessage, T as TimeoutError, y as createClient, d as createCursor, i as isCursor, n as normalizeCursor } from './shared/protocol.f52df848.cjs';
|
|
3
3
|
import _m0 from 'protobufjs/minimal.js';
|
|
4
4
|
export { ClientError, Metadata, Status } from 'nice-grpc';
|
|
5
|
-
import '
|
|
5
|
+
import './codec.cjs';
|
|
6
6
|
import 'nice-grpc-common';
|
|
7
|
-
import '@effect/schema/AST';
|
|
8
7
|
|
|
9
8
|
declare const protobufPackage = "dna.v2.testing";
|
|
10
9
|
interface MockFilter {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { s as stream } from './shared/protocol.
|
|
2
|
-
export { B as Bytes, b as BytesFromUint8Array,
|
|
1
|
+
import { s as stream } from './shared/protocol.68a15d69.mjs';
|
|
2
|
+
export { B as Bytes, b as BytesFromUint8Array, w as Client, u as ClientCallOptions, x as CreateClientOptions, C as Cursor, e as CursorFromBytes, c as CursorProto, q as Data, g as DataFinality, h as DataProduction, D as DnaStreamClient, a as DnaStreamDefinition, k as Duration, j as DurationCodec, F as Finalize, G as GrpcClient, H as Heartbeat, I as Invalidate, R as ResponseWithoutData, S as StatusRequest, f as StatusResponse, o as StdErr, m as StdOut, t as StreamConfig, z as StreamDataIterable, v as StreamDataOptions, l as StreamDataRequest, r as StreamDataResponse, p as SystemMessage, T as TimeoutError, y as createClient, d as createCursor, i as isCursor, n as normalizeCursor } from './shared/protocol.68a15d69.mjs';
|
|
3
3
|
import _m0 from 'protobufjs/minimal.js';
|
|
4
4
|
export { ClientError, Metadata, Status } from 'nice-grpc';
|
|
5
|
-
import '
|
|
5
|
+
import './codec.mjs';
|
|
6
6
|
import 'nice-grpc-common';
|
|
7
|
-
import '@effect/schema/AST';
|
|
8
7
|
|
|
9
8
|
declare const protobufPackage = "dna.v2.testing";
|
|
10
9
|
interface MockFilter {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { s as stream } from './shared/protocol.
|
|
2
|
-
export { B as Bytes, b as BytesFromUint8Array,
|
|
1
|
+
import { s as stream } from './shared/protocol.8b5e318a.js';
|
|
2
|
+
export { B as Bytes, b as BytesFromUint8Array, w as Client, u as ClientCallOptions, x as CreateClientOptions, C as Cursor, e as CursorFromBytes, c as CursorProto, q as Data, g as DataFinality, h as DataProduction, D as DnaStreamClient, a as DnaStreamDefinition, k as Duration, j as DurationCodec, F as Finalize, G as GrpcClient, H as Heartbeat, I as Invalidate, R as ResponseWithoutData, S as StatusRequest, f as StatusResponse, o as StdErr, m as StdOut, t as StreamConfig, z as StreamDataIterable, v as StreamDataOptions, l as StreamDataRequest, r as StreamDataResponse, p as SystemMessage, T as TimeoutError, y as createClient, d as createCursor, i as isCursor, n as normalizeCursor } from './shared/protocol.8b5e318a.js';
|
|
3
3
|
import _m0 from 'protobufjs/minimal.js';
|
|
4
4
|
export { ClientError, Metadata, Status } from 'nice-grpc';
|
|
5
|
-
import '
|
|
5
|
+
import './codec.js';
|
|
6
6
|
import 'nice-grpc-common';
|
|
7
|
-
import '@effect/schema/AST';
|
|
8
7
|
|
|
9
8
|
declare const protobufPackage = "dna.v2.testing";
|
|
10
9
|
interface MockFilter {
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { s as stream, t as testing, C as Cursor, D as DnaStreamDefinition, S as StreamDataResponse } from './shared/protocol.
|
|
2
|
-
export { B as
|
|
3
|
-
import {
|
|
1
|
+
import { s as stream, t as testing, C as Cursor, D as DnaStreamDefinition, S as StreamDataResponse } from './shared/protocol.a64f7660.mjs';
|
|
2
|
+
export { B as BytesFromUint8Array, a as CursorFromBytes, k as Data, b as DataFinality, d as DataProduction, e as DurationCodec, F as Finalize, H as Heartbeat, I as Invalidate, R as ResponseWithoutData, h as StdErr, g as StdOut, l as StreamConfig, f as StreamDataRequest, j as SystemMessage, c as createCursor, i as isCursor, n as normalizeCursor } from './shared/protocol.a64f7660.mjs';
|
|
3
|
+
import { MessageCodec, OptionalCodec } from './codec.mjs';
|
|
4
4
|
import { createChannel, createClient as createClient$1 } from 'nice-grpc';
|
|
5
5
|
export { ClientError, Metadata, Status } from 'nice-grpc';
|
|
6
6
|
import 'protobufjs/minimal.js';
|
|
7
7
|
import assert from 'node:assert';
|
|
8
|
-
import 'effect';
|
|
9
8
|
import 'viem';
|
|
10
9
|
import 'long';
|
|
11
10
|
|
|
@@ -15,17 +14,13 @@ const index = {
|
|
|
15
14
|
testing: testing
|
|
16
15
|
};
|
|
17
16
|
|
|
18
|
-
const StatusRequest =
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
finalized: Schema.optional(Cursor),
|
|
25
|
-
starting: Schema.optional(Cursor)
|
|
17
|
+
const StatusRequest = MessageCodec({});
|
|
18
|
+
const StatusResponse = MessageCodec({
|
|
19
|
+
currentHead: OptionalCodec(Cursor),
|
|
20
|
+
lastIngested: OptionalCodec(Cursor),
|
|
21
|
+
finalized: OptionalCodec(Cursor),
|
|
22
|
+
starting: OptionalCodec(Cursor)
|
|
26
23
|
});
|
|
27
|
-
const statusResponseToProto = Schema.encodeSync(StatusResponse);
|
|
28
|
-
const statusResponseFromProto = Schema.decodeSync(StatusResponse);
|
|
29
24
|
|
|
30
25
|
var __defProp$1 = Object.defineProperty;
|
|
31
26
|
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -58,14 +53,14 @@ class GrpcClient {
|
|
|
58
53
|
this.config = config;
|
|
59
54
|
this.client = client;
|
|
60
55
|
__publicField$1(this, "encodeRequest");
|
|
61
|
-
this.encodeRequest =
|
|
56
|
+
this.encodeRequest = config.Request.encode;
|
|
62
57
|
}
|
|
63
58
|
async status(request, options) {
|
|
64
59
|
const response = await this.client.status(
|
|
65
|
-
|
|
60
|
+
StatusRequest.encode(request ?? {}),
|
|
66
61
|
options
|
|
67
62
|
);
|
|
68
|
-
return
|
|
63
|
+
return StatusResponse.decode(response);
|
|
69
64
|
}
|
|
70
65
|
streamData(request, options) {
|
|
71
66
|
const it = this.client.streamData(this.encodeRequest(request), options);
|
|
@@ -81,7 +76,7 @@ class StreamDataIterable {
|
|
|
81
76
|
[Symbol.asyncIterator]() {
|
|
82
77
|
const inner = this.it[Symbol.asyncIterator]();
|
|
83
78
|
const schema = StreamDataResponse(this.schema);
|
|
84
|
-
const decoder =
|
|
79
|
+
const decoder = schema.decode;
|
|
85
80
|
const { endingCursor, timeout = DEFAULT_TIMEOUT_MS } = this.options ?? {};
|
|
86
81
|
let shouldStop = false;
|
|
87
82
|
let clock;
|
|
@@ -176,4 +171,4 @@ class RateGauge {
|
|
|
176
171
|
}
|
|
177
172
|
}
|
|
178
173
|
|
|
179
|
-
export { Cursor, DnaStreamDefinition, GrpcClient, RateGauge, StatusRequest, StatusResponse, StreamDataIterable, StreamDataResponse, TimeoutError, createClient, index as proto
|
|
174
|
+
export { Cursor, DnaStreamDefinition, GrpcClient, RateGauge, StatusRequest, StatusResponse, StreamDataIterable, StreamDataResponse, TimeoutError, createClient, index as proto };
|