@apibara/protocol 2.1.0-beta.3 → 2.1.0-beta.31
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 +242 -0
- package/dist/codec.cjs.map +1 -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 +224 -0
- package/dist/codec.mjs.map +1 -0
- package/dist/index.cjs +18 -29
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -5
- package/dist/index.d.mts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.mjs +16 -20
- package/dist/index.mjs.map +1 -0
- package/dist/shared/{protocol.4b1cfe2c.d.cts → protocol.21b07506.d.mts} +399 -247
- package/dist/shared/{protocol.4b1cfe2c.d.mts → protocol.526c6532.d.ts} +399 -247
- package/dist/shared/{protocol.e39e40d6.cjs → protocol.53f81a1e.cjs} +177 -177
- package/dist/shared/protocol.53f81a1e.cjs.map +1 -0
- package/dist/shared/{protocol.991ff9ad.mjs → protocol.68fdd897.mjs} +176 -171
- package/dist/shared/protocol.68fdd897.mjs.map +1 -0
- package/dist/shared/{protocol.4b1cfe2c.d.ts → protocol.a5762a90.d.cts} +399 -247
- package/dist/testing/index.cjs +26 -38
- package/dist/testing/index.cjs.map +1 -0
- 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 +26 -38
- package/dist/testing/index.mjs.map +1 -0
- package/package.json +7 -3
- package/src/client.ts +8 -13
- package/src/codec.ts +662 -0
- package/src/common.ts +70 -53
- package/src/config.ts +4 -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 +36 -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,224 @@
|
|
|
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 };
|
|
224
|
+
//# sourceMappingURL=codec.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.mjs","sources":["../src/codec.ts"],"sourcesContent":["/*\n\n █████████ █████ \n ███░░░░░███ ░░███ \n ███ ░░░ ██████ ███████ ██████ ██████ \n░███ ███░░███ ███░░███ ███░░███ ███░░███\n░███ ░███ ░███░███ ░███ ░███████ ░███ ░░░ \n░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ███\n ░░█████████ ░░██████ ░░████████░░██████ ░░██████ \n ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░ \n \n*/\n\n/** Codec to encode and decode protobuf messages */\nexport type Codec<TApp = unknown, TProto = unknown> = {\n encode(app: TApp): TProto;\n decode(proto: TProto): TApp;\n};\n\n/* Helper to get the high-level type of a codec */\nexport type CodecType<C extends Codec> = ReturnType<C[\"decode\"]>;\n\n/* Helper to get the protobuf type of a codec */\nexport type CodecProto<C extends Codec> = ReturnType<C[\"encode\"]>;\n\n/*\n \n ██████ ██████ \n░░██████ ██████ \n ░███░█████░███ ██████ █████ █████ ██████ ███████ ██████ \n ░███░░███ ░███ ███░░███ ███░░ ███░░ ░░░░░███ ███░░███ ███░░███\n ░███ ░░░ ░███ ░███████ ░░█████ ░░█████ ███████ ░███ ░███░███████ \n ░███ ░███ ░███░░░ ░░░░███ ░░░░███ ███░░███ ░███ ░███░███░░░ \n █████ █████░░██████ ██████ ██████ ░░████████░░███████░░██████ \n░░░░░ ░░░░░ ░░░░░░ ░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░███ ░░░░░░ \n ███ ░███ \n ░░██████ \n ░░░░░░ \n*/\n\nexport type Evaluate<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;\n\ntype TPropertyKey = string | symbol;\n// Message properties as codec.\ntype TProperties = Record<TPropertyKey, Codec>;\n\n// Optional properties in an object.\n// Properties are optional when they have the `undefined` type.\ntype OptionalPropertyKeys<T> = {\n [K in keyof T]: undefined extends T[K] ? K : never;\n}[keyof T];\n\n// Properties that are not optional are required.\ntype RequiredPropertyKeys<T> = keyof Omit<T, OptionalPropertyKeys<T>>;\n\n// Helper to get the app type of a message codec.\ntype _MessageCodecType<T extends TProperties> = {\n [K in keyof T]: CodecType<T[K]>;\n};\n\n// Helper to get the protobuf type of a message codec.\ntype _MessageCodecProto<T extends TProperties> = {\n [K in keyof T]: CodecProto<T[K]>;\n};\n\n// Adjust the app type of the codec so that optional properties are optional.\ntype MessageCodecType<T extends TProperties> =\n _MessageCodecType<T> extends infer R\n ? Evaluate<Partial<R> & Required<Pick<R, RequiredPropertyKeys<R>>>>\n : never;\n\n// Adjust the protobuf type of the codec so that optional properties are optional.\ntype MessageCodecProto<T extends TProperties> =\n _MessageCodecProto<T> extends infer R\n ? Evaluate<Partial<R> & Required<Pick<R, RequiredPropertyKeys<R>>>>\n : never;\n\nexport type MessageCodec<T extends TProperties = TProperties> = Codec<\n MessageCodecType<T>,\n MessageCodecProto<T>\n>;\n\nexport function MessageCodec<T extends TProperties>(\n schema: T,\n): MessageCodec<T> {\n return {\n encode(app) {\n return new Proxy(app, {\n get(target, property) {\n if (!Object.hasOwn(target, property)) {\n return Reflect.get(target, property);\n }\n\n const v = Reflect.get(target, property);\n return schema[property].encode(v);\n },\n });\n },\n decode(proto) {\n return new Proxy(proto, {\n get(target, property) {\n if (!Object.hasOwn(target, property)) {\n return Reflect.get(target, property);\n }\n\n const v = Reflect.get(target, property);\n return schema[property].decode(v);\n },\n });\n },\n };\n}\n\n/*\n █████████ \n ███░░░░░███ \n ░███ ░███ ████████ ████████ ██████ █████ ████\n ░███████████ ░░███░░███░░███░░███ ░░░░░███ ░░███ ░███ \n ░███░░░░░███ ░███ ░░░ ░███ ░░░ ███████ ░███ ░███ \n ░███ ░███ ░███ ░███ ███░░███ ░███ ░███ \n █████ █████ █████ █████ ░░████████ ░░███████ \n░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░ ░░░░░███ \n ███ ░███ \n ░░██████ \n ░░░░░░ \n \n*/\n\nexport type ArrayCodec<T extends Codec> = T extends Codec<\n infer TApp,\n infer TProto\n>\n ? Codec<readonly TApp[], readonly TProto[] | undefined>\n : never;\n\nexport function ArrayCodec<T extends Codec<TApp, TProto>, TApp, TProto>(\n t: T,\n): ArrayCodec<T> {\n return {\n encode(app) {\n return app.map(t.encode) as readonly TProto[];\n },\n decode(proto) {\n if (proto === undefined) return [];\n return proto.map(t.decode) as readonly TApp[];\n },\n } as ArrayCodec<T>;\n}\n\n/*\n ██████ ██████ █████ █████ ████ █████████ █████ \n░░██████ ██████ ░░███ ░░███ ░░███ ███░░░░░███ ░░███ \n ░███░█████░███ █████ ████ ███████ ██████ ░███████ ░███ ██████ ███ ░░░ ██████ ███████ ██████ ██████ \n ░███░░███ ░███ ░░███ ░███ ░░░███░ ░░░░░███ ░███░░███ ░███ ███░░███░███ ███░░███ ███░░███ ███░░███ ███░░███\n ░███ ░░░ ░███ ░███ ░███ ░███ ███████ ░███ ░███ ░███ ░███████ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░░░ \n ░███ ░███ ░███ ░███ ░███ ███ ███░░███ ░███ ░███ ░███ ░███░░░ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ███\n █████ █████ ░░████████ ░░█████ ░░████████ ████████ █████░░██████ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ \n░░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░░░░░░ ░░░░░░░░ ░░░░░ ░░░░░░ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░ \n*/\nexport type MutableArrayCodec<\n T extends Codec<TApp, TProto>,\n TApp,\n TProto,\n> = T extends Codec<infer TApp, infer TProto> ? Codec<TApp[], TProto[]> : never;\n\nexport function MutableArrayCodec<T extends Codec<TApp, TProto>, TApp, TProto>(\n t: T,\n): MutableArrayCodec<T, TApp, TProto> {\n return {\n encode(app) {\n return app.map(t.encode) as TProto[];\n },\n decode(proto) {\n if (proto === undefined) return [];\n return proto.map(t.decode) as TApp[];\n },\n } as MutableArrayCodec<T, TApp, TProto>;\n}\n\n/*\n ███████ █████ ███ ████ \n ███░░░░░███ ░░███ ░░░ ░░███ \n ███ ░░███ ████████ ███████ ████ ██████ ████████ ██████ ░███ \n░███ ░███░░███░░███░░░███░ ░░███ ███░░███░░███░░███ ░░░░░███ ░███ \n░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ███████ ░███ \n░░███ ███ ░███ ░███ ░███ ███ ░███ ░███ ░███ ░███ ░███ ███░░███ ░███ \n ░░░███████░ ░███████ ░░█████ █████░░██████ ████ █████░░████████ █████\n ░░░░░░░ ░███░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░ ░░░░░ ░░░░░░░░ ░░░░░ \n ░███ \n █████ \n ░░░░░ \n*/\n\nexport type OptionalCodec<T extends Codec> = T extends Codec<\n infer TApp,\n infer TProto\n>\n ? Codec<TApp | undefined, TProto | undefined>\n : never;\n\nexport function OptionalCodec<T extends Codec>(t: T): OptionalCodec<T> {\n return {\n encode(app) {\n if (app === undefined) return undefined;\n return t.encode(app);\n },\n decode(proto) {\n if (proto === undefined) return undefined;\n return t.decode(proto);\n },\n } as OptionalCodec<T>;\n}\n\n/*\n ███████████ ███ █████\n░░███░░░░░███ ░░░ ░░███ \n ░███ ░███ ██████ ████████ █████ ████ ████ ████████ ██████ ███████ \n ░██████████ ███░░███ ███░░███ ░░███ ░███ ░░███ ░░███░░███ ███░░███ ███░░███ \n ░███░░░░░███ ░███████ ░███ ░███ ░███ ░███ ░███ ░███ ░░░ ░███████ ░███ ░███ \n ░███ ░███ ░███░░░ ░███ ░███ ░███ ░███ ░███ ░███ ░███░░░ ░███ ░███ \n █████ █████░░██████ ░░███████ ░░████████ █████ █████ ░░██████ ░░████████\n░░░░░ ░░░░░ ░░░░░░ ░░░░░███ ░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░░░░░ \n ░███ \n █████ \n ░░░░░ \n*/\n\nexport type RequiredCodec<T extends Codec> = T extends Codec<\n infer TApp,\n infer TProto\n>\n ? TApp extends undefined\n ? never\n : Codec<TApp, TProto | undefined>\n : never;\n\nexport function RequiredCodec<T extends Codec>(t: T): RequiredCodec<T> {\n return {\n encode(app) {\n if (app === undefined) throw new Error(\"Value is required but undefined\");\n return t.encode(app);\n },\n decode(proto) {\n if (proto === undefined)\n throw new Error(\"Value is required but undefined\");\n return t.decode(proto);\n },\n } as RequiredCodec<T>;\n}\n\n/*\n ██████ █████ ████ ████ ███████ \n░░██████ ░░███ ░░███ ░░███ ███░░░░░███ \n ░███░███ ░███ █████ ████ ░███ ░███ ███ ░░███ ████████ \n ░███░░███░███ ░░███ ░███ ░███ ░███ ░███ ░███░░███░░███\n ░███ ░░██████ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░░░ \n ░███ ░░█████ ░███ ░███ ░███ ░███ ░░███ ███ ░███ \n █████ ░░█████ ░░████████ █████ █████ ░░░███████░ █████ \n░░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░░ ░░░░░ \n*/\n\nexport type NullOrCodec<T extends Codec> = T extends Codec<\n infer TApp,\n infer TProto\n>\n ? Codec<TApp | null, TProto | null>\n : never;\n\nexport function NullOrCodec<T extends Codec>(t: T): NullOrCodec<T> {\n return {\n encode(app) {\n if (app === null) return null;\n return t.encode(app);\n },\n decode(proto) {\n if (proto === null) return null;\n return t.decode(proto);\n },\n } as NullOrCodec<T>;\n}\n\n/*\n\n ███████████ ███ █████ █████ \n░░███░░░░░███ ░░░ ░░███ ░░███ \n ░███ ░███ ████ ███████ ░███ ████████ ███████ \n ░██████████ ░░███ ███░░███ ░███ ░░███░░███ ░░░███░ \n ░███░░░░░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ \n ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ███\n ███████████ █████░░███████ █████ ████ █████ ░░█████ \n░░░░░░░░░░░ ░░░░░ ░░░░░███░░░░░ ░░░░ ░░░░░ ░░░░░ \n ███ ░███ \n ░░██████ \n ░░░░░░ \n*/\n\nexport type BigIntCodec = CodecType<typeof BigIntCodec>;\n\nexport const BigIntCodec: Codec<bigint, bigint> = {\n encode(app) {\n return app;\n },\n decode(proto) {\n return proto;\n },\n};\n\n/*\n\n ██████ █████ █████ \n░░██████ ░░███ ░░███ \n ░███░███ ░███ █████ ████ █████████████ ░███████ ██████ ████████ \n ░███░░███░███ ░░███ ░███ ░░███░░███░░███ ░███░░███ ███░░███░░███░░███\n ░███ ░░██████ ░███ ░███ ░███ ░███ ░███ ░███ ░███░███████ ░███ ░░░ \n ░███ ░░█████ ░███ ░███ ░███ ░███ ░███ ░███ ░███░███░░░ ░███ \n █████ ░░█████ ░░████████ █████░███ █████ ████████ ░░██████ █████ \n░░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░ ░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░ \n \n*/\n\nexport type NumberCodec = CodecType<typeof NumberCodec>;\n\nexport const NumberCodec: Codec<number, number> = {\n encode(app) {\n return app;\n },\n decode(proto) {\n return proto;\n },\n};\n\n/*\n █████ █████ ███ █████ ████████ █████████ \n░░███ ░░███ ░░░ ░░███ ███░░░░███ ███░░░░░███ \n ░███ ░███ ████ ████████ ███████ ░███ ░███ ░███ ░███ ████████ ████████ ██████ █████ ████\n ░███ ░███ ░░███ ░░███░░███ ░░░███░ ░░████████ ░███████████ ░░███░░███░░███░░███ ░░░░░███ ░░███ ░███ \n ░███ ░███ ░███ ░███ ░███ ░███ ███░░░░███ ░███░░░░░███ ░███ ░░░ ░███ ░░░ ███████ ░███ ░███ \n ░███ ░███ ░███ ░███ ░███ ░███ ███░███ ░███ ░███ ░███ ░███ ░███ ███░░███ ░███ ░███ \n ░░████████ █████ ████ █████ ░░█████ ░░████████ █████ █████ █████ █████ ░░████████ ░░███████ \n ░░░░░░░░ ░░░░░ ░░░░ ░░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░ ░░░░░███ \n ███ ░███ \n ░░██████ \n ░░░░░░ \n*/\n\nexport type Uint8ArrayCodec = CodecType<typeof Uint8ArrayCodec>;\n\nexport const Uint8ArrayCodec: Codec<Uint8Array, Uint8Array> = {\n encode(app) {\n return app;\n },\n decode(proto) {\n return proto;\n },\n};\n\n/*\n\n ██████████ █████ \n░░███░░░░███ ░░███ \n ░███ ░░███ ██████ ███████ ██████ \n ░███ ░███ ░░░░░███ ░░░███░ ███░░███\n ░███ ░███ ███████ ░███ ░███████ \n ░███ ███ ███░░███ ░███ ███░███░░░ \n ██████████ ░░████████ ░░█████ ░░██████ \n░░░░░░░░░░ ░░░░░░░░ ░░░░░ ░░░░░░ \n \n*/\n\nexport type DateCodec = CodecType<typeof DateCodec>;\n\nexport const DateCodec: Codec<Date, Date> = {\n encode(app) {\n return new Date(app);\n },\n decode(proto) {\n return new Date(proto);\n },\n};\n\n/*\n\n ███████████ ████ \n░░███░░░░░███ ░░███ \n ░███ ░███ ██████ ██████ ░███ ██████ ██████ ████████ \n ░██████████ ███░░███ ███░░███ ░███ ███░░███ ░░░░░███ ░░███░░███ \n ░███░░░░░███░███ ░███░███ ░███ ░███ ░███████ ███████ ░███ ░███ \n ░███ ░███░███ ░███░███ ░███ ░███ ░███░░░ ███░░███ ░███ ░███ \n ███████████ ░░██████ ░░██████ █████░░██████ ░░████████ ████ █████\n░░░░░░░░░░░ ░░░░░░ ░░░░░░ ░░░░░ ░░░░░░ ░░░░░░░░ ░░░░ ░░░░░ \n \n*/\n\nexport type BooleanCodec = CodecType<typeof BooleanCodec>;\n\nexport const BooleanCodec: Codec<boolean, boolean> = {\n encode(app) {\n return app;\n },\n decode(proto) {\n return proto;\n },\n};\n\n/*\n\n █████████ █████ ███ \n ███░░░░░███ ░░███ ░░░ \n░███ ░░░ ███████ ████████ ████ ████████ ███████\n░░█████████ ░░░███░ ░░███░░███░░███ ░░███░░███ ███░░███\n ░░░░░░░░███ ░███ ░███ ░░░ ░███ ░███ ░███ ░███ ░███\n ███ ░███ ░███ ███ ░███ ░███ ░███ ░███ ░███ ░███\n░░█████████ ░░█████ █████ █████ ████ █████░░███████\n ░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░ ░░░░░ ░░░░░███\n ███ ░███\n ░░██████ \n ░░░░░░ \n*/\n\nexport type StringCodec = CodecType<typeof StringCodec>;\n\nexport const StringCodec: Codec<string, string> = {\n encode(app) {\n return app;\n },\n decode(proto) {\n return proto;\n },\n};\n\n/*\n\n █████ █████ █████ ██████ ███ █████\n░░███ ░░███ ░░███ ███░░███ ░░░ ░░███ \n ░███ ░███ ████████ ███████ ██████ ░███ ░░░ ████ ████████ ██████ ███████ \n ░███ ░███ ░░███░░███ ███░░███ ███░░███ ███████ ░░███ ░░███░░███ ███░░███ ███░░███ \n ░███ ░███ ░███ ░███ ░███ ░███ ░███████ ░░░███░ ░███ ░███ ░███ ░███████ ░███ ░███ \n ░███ ░███ ░███ ░███ ░███ ░███ ░███░░░ ░███ ░███ ░███ ░███ ░███░░░ ░███ ░███ \n ░░████████ ████ █████░░████████░░██████ █████ █████ ████ █████░░██████ ░░████████\n ░░░░░░░░ ░░░░ ░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░ ░░░░░ ░░░░ ░░░░░ ░░░░░░ ░░░░░░░░ \n \n*/\n\nexport type UndefinedCodec = CodecType<typeof UndefinedCodec>;\n\nexport const UndefinedCodec: Codec<undefined, undefined> = {\n encode(app) {\n return undefined;\n },\n decode(proto) {\n return undefined;\n },\n};\n\n/*\n █████ ███ █████ ████ \n░░███ ░░░ ░░███ ░░███ \n ░███ ████ ███████ ██████ ████████ ██████ ░███ \n ░███ ░░███ ░░░███░ ███░░███░░███░░███ ░░░░░███ ░███ \n ░███ ░███ ░███ ░███████ ░███ ░░░ ███████ ░███ \n ░███ █ ░███ ░███ ███░███░░░ ░███ ███░░███ ░███ \n ███████████ █████ ░░█████ ░░██████ █████ ░░████████ █████\n░░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░░ ░░░░░░░░ ░░░░░ \n \n*/\n\ntype Literal = string | number | boolean | null | undefined;\n\nexport type LiteralCodec<T extends Codec, L extends Literal> = T extends Codec<\n infer TApp,\n infer TProto\n>\n ? Codec<TApp, TProto>\n : never;\n\nexport const LiteralCodec = <const L extends Literal>(\n value: L,\n): LiteralCodec<Codec<L, L>, L> => {\n return {\n encode(app) {\n if (app !== value) {\n throw new Error(`Expected ${String(value)}, got ${String(app)}`);\n }\n return app;\n },\n decode(proto) {\n if (proto !== value) {\n throw new Error(`Expected ${String(value)}, got ${String(proto)}`);\n }\n return proto;\n },\n } as LiteralCodec<Codec<L, L>, L>;\n};\n\n/*\n █████ ███ █████ ████ █████ █████ ███ \n░░███ ░░░ ░░███ ░░███ ░░███ ░░███ ░░░ \n ░███ ████ ███████ ██████ ████████ ██████ ░███ ░███ ░███ ████████ ████ ██████ ████████ \n ░███ ░░███ ░░░███░ ███░░███░░███░░███ ░░░░░███ ░███ ░███ ░███ ░░███░░███ ░░███ ███░░███░░███░░███ \n ░███ ░███ ░███ ░███████ ░███ ░░░ ███████ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ \n ░███ █ ░███ ░███ ███░███░░░ ░███ ███░░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ \n ███████████ █████ ░░█████ ░░██████ █████ ░░████████ █████ ░░████████ ████ █████ █████░░██████ ████ █████\n░░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░░░░░░ ░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░ ░░░░░ \n*/\n\nexport type LiteralUnionCodec<\n T extends Codec,\n L extends readonly Literal[],\n> = T extends Codec<infer TApp, infer TProto> ? Codec<TApp, TProto> : never;\n\nexport const LiteralUnionCodec = <const L extends readonly Literal[]>(\n values: L,\n): LiteralUnionCodec<Codec<L[number], L[number]>, L> => {\n return {\n encode(app) {\n if (!values.includes(app as L[number])) {\n throw new Error(\n `Expected one of [${values.join(\", \")}], got ${String(app)}`,\n );\n }\n return app;\n },\n decode(proto) {\n if (!values.includes(proto as L[number])) {\n throw new Error(\n `Expected one of [${values.join(\", \")}], got ${String(proto)}`,\n );\n }\n return proto;\n },\n } as LiteralUnionCodec<Codec<L[number], L[number]>, L>;\n};\n\n/*\n █████ █████ ███ █████ \n░░███ ░░███ ░░░ ░░███ \n ░███ ░███ ██████ ████████ ████ ██████ ████████ ███████ \n ░███ ░███ ░░░░░███ ░░███░░███░░███ ░░░░░███ ░░███░░███ ░░░███░ \n ░░███ ███ ███████ ░███ ░░░ ░███ ███████ ░███ ░███ ░███ \n ░░░█████░ ███░░███ ░███ ░███ ███░░███ ░███ ░███ ░███ ███\n ░░███ ░░████████ █████ █████░░████████ ████ █████ ░░█████ \n ░░░ ░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░░░ ░░░░ ░░░░░ ░░░░░ \n*/\n\n// Maps variant keys to their corresponding decoded types, adding a tag field\n// For example: { _tag: \"declareV1\", declareV1: { data: string } }\n// if the variant is undefined type, it will be just the tag - { _tag: \"heartbeat\" }\ntype AppVariantMap<TTag extends TPropertyKey, TVariants extends TProperties> = {\n [K in keyof TVariants]: {\n [P in TTag]: K;\n } & (CodecType<TVariants[K]> extends UndefinedCodec\n ? // biome-ignore lint/complexity/noBannedTypes: had to return empty object to satisfy type\n {}\n : { [P in K & TPropertyKey]: CodecType<TVariants[K]> });\n};\ntype VariantCodecType<\n TTag extends TPropertyKey,\n TVariants extends TProperties,\n> = AppVariantMap<TTag, TVariants>[keyof TVariants];\n\n// Maps variant keys to their corresponding encoded types, adding a discriminator field\n// For example: { $case: \"declareV1\", declareV1: { data: string } }\ntype ProtoVariantMap<\n TDiscriminator extends TPropertyKey,\n TVariants extends TProperties,\n> = {\n [K in keyof TVariants]: {\n [P in TDiscriminator]: K;\n } & {\n [P in K & TPropertyKey]: CodecProto<TVariants[K]>;\n };\n};\n\ntype VariantCodecProto<\n TDiscriminator extends TPropertyKey,\n TVariants extends TProperties,\n> = ProtoVariantMap<TDiscriminator, TVariants>[keyof TVariants];\n\n// Type helper for VariantCodec that preserves the input/output types\nexport type VariantCodec<\n T extends Codec,\n TTag extends TPropertyKey,\n TDiscriminator extends TPropertyKey,\n> = T extends Codec<infer TApp, infer TProto> ? Codec<TApp, TProto> : never;\n\nexport const VariantCodec = <\n TTag extends TPropertyKey,\n TDiscriminator extends TPropertyKey,\n TVariants extends TProperties,\n TCodec extends Codec<\n VariantCodecType<TTag, TVariants>,\n VariantCodecProto<TDiscriminator, TVariants>\n >,\n>(options: {\n tag: TTag;\n discriminator: TDiscriminator;\n variants: TVariants;\n}): VariantCodec<TCodec, TTag, TDiscriminator> => {\n return {\n encode(app) {\n const tag = app[options.tag];\n const codec = options.variants[tag];\n if (!codec) {\n throw new Error(`Unknown variant: ${String(tag)}`);\n }\n\n const variantData = app[tag as keyof typeof app];\n const encodedData = codec.encode(variantData);\n\n return {\n [options.discriminator]: tag,\n [tag]: encodedData,\n };\n },\n decode(proto) {\n const tag = proto[options.discriminator];\n const codec = options.variants[tag];\n if (!codec) {\n throw new Error(`Unknown variant: ${String(tag)}`);\n }\n\n const variantData = proto[tag as keyof typeof proto];\n const decodedData = codec.decode(variantData);\n\n return {\n [options.tag]: tag,\n [tag]: decodedData,\n };\n },\n } as VariantCodec<TCodec, TTag, TDiscriminator>;\n};\n\n/*\n ███████ ███████ ██████ \n ███░░░░░███ ███░░░░░███ ███░░███\n ███ ░░███ ████████ ██████ ███ ░░███ ░███ ░░░ \n░███ ░███░░███░░███ ███░░███░███ ░███ ███████ \n░███ ░███ ░███ ░███ ░███████ ░███ ░███░░░███░ \n░░███ ███ ░███ ░███ ░███░░░ ░░███ ███ ░███ \n ░░░███████░ ████ █████░░██████ ░░░███████░ █████ \n ░░░░░░░ ░░░░ ░░░░░ ░░░░░░ ░░░░░░░ ░░░░░ \n \n*/\n\nexport type OneOfCodec<TVariants extends TProperties> = VariantCodec<\n Codec<\n VariantCodecType<\"_tag\", TVariants>,\n VariantCodecProto<\"$case\", TVariants>\n >,\n \"_tag\",\n \"$case\"\n>;\n\nexport function OneOfCodec<TVariants extends TProperties>(\n variants: TVariants,\n): OneOfCodec<TVariants> {\n return VariantCodec({\n tag: \"_tag\",\n discriminator: \"$case\",\n variants,\n });\n}\n"],"names":[],"mappings":"AAkFO,SAAS,aACd,MACiB,EAAA;AACjB,EAAO,OAAA;AAAA,IACL,OAAO,GAAK,EAAA;AACV,MAAO,OAAA,IAAI,MAAM,GAAK,EAAA;AAAA,QACpB,GAAA,CAAI,QAAQ,QAAU,EAAA;AACpB,UAAA,IAAI,CAAC,MAAA,CAAO,MAAO,CAAA,MAAA,EAAQ,QAAQ,CAAG,EAAA;AACpC,YAAO,OAAA,OAAA,CAAQ,GAAI,CAAA,MAAA,EAAQ,QAAQ,CAAA,CAAA;AAAA,WACrC;AAEA,UAAA,MAAM,CAAI,GAAA,OAAA,CAAQ,GAAI,CAAA,MAAA,EAAQ,QAAQ,CAAA,CAAA;AACtC,UAAA,OAAO,MAAO,CAAA,QAAQ,CAAE,CAAA,MAAA,CAAO,CAAC,CAAA,CAAA;AAAA,SAClC;AAAA,OACD,CAAA,CAAA;AAAA,KACH;AAAA,IACA,OAAO,KAAO,EAAA;AACZ,MAAO,OAAA,IAAI,MAAM,KAAO,EAAA;AAAA,QACtB,GAAA,CAAI,QAAQ,QAAU,EAAA;AACpB,UAAA,IAAI,CAAC,MAAA,CAAO,MAAO,CAAA,MAAA,EAAQ,QAAQ,CAAG,EAAA;AACpC,YAAO,OAAA,OAAA,CAAQ,GAAI,CAAA,MAAA,EAAQ,QAAQ,CAAA,CAAA;AAAA,WACrC;AAEA,UAAA,MAAM,CAAI,GAAA,OAAA,CAAQ,GAAI,CAAA,MAAA,EAAQ,QAAQ,CAAA,CAAA;AACtC,UAAA,OAAO,MAAO,CAAA,QAAQ,CAAE,CAAA,MAAA,CAAO,CAAC,CAAA,CAAA;AAAA,SAClC;AAAA,OACD,CAAA,CAA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,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const config = require('./shared/protocol.
|
|
4
|
-
const
|
|
3
|
+
const config = require('./shared/protocol.53f81a1e.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,25 +182,23 @@ 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;
|
|
200
|
+
exports.Metadata = niceGrpc.Metadata;
|
|
201
|
+
exports.ServerError = niceGrpc.ServerError;
|
|
210
202
|
exports.Status = niceGrpc.Status;
|
|
211
203
|
exports.GrpcClient = GrpcClient;
|
|
212
204
|
exports.RateGauge = RateGauge;
|
|
@@ -216,7 +208,4 @@ exports.StreamDataIterable = StreamDataIterable;
|
|
|
216
208
|
exports.TimeoutError = TimeoutError;
|
|
217
209
|
exports.createClient = createClient;
|
|
218
210
|
exports.proto = index;
|
|
219
|
-
|
|
220
|
-
exports.statusRequestToProto = statusRequestToProto;
|
|
221
|
-
exports.statusResponseFromProto = statusResponseFromProto;
|
|
222
|
-
exports.statusResponseToProto = statusResponseToProto;
|
|
211
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/status.ts","../src/client.ts","../src/rate.ts"],"sourcesContent":["import { type CodecType, MessageCodec, OptionalCodec } from \"./codec\";\nimport { Cursor } from \"./common\";\n\n/** The request to the `status` endpoint. */\nexport const StatusRequest = MessageCodec({});\n\nexport type StatusRequest = CodecType<typeof StatusRequest>;\n\n/** The response from the `status` endpoint. */\nexport const StatusResponse = MessageCodec({\n currentHead: OptionalCodec(Cursor),\n lastIngested: OptionalCodec(Cursor),\n finalized: OptionalCodec(Cursor),\n starting: OptionalCodec(Cursor),\n});\n\nexport type StatusResponse = CodecType<typeof StatusResponse>;\n","import {\n type ChannelCredentials,\n type ChannelOptions,\n type DefaultCallOptions,\n type NormalizedServiceDefinition,\n createChannel,\n createClient as grpcCreateClient,\n} from \"nice-grpc\";\n\nimport * as proto from \"./proto\";\n\nimport assert from \"node:assert\";\nimport type { Codec } from \"./codec\";\nimport type { Cursor } from \"./common\";\nimport type { StreamConfig } from \"./config\";\nimport { StatusRequest, StatusResponse } from \"./status\";\nimport { type StreamDataRequest, StreamDataResponse } from \"./stream\";\n\nexport { ClientError, ServerError, Status, Metadata } from \"nice-grpc\";\n\nconst DEFAULT_TIMEOUT_MS = 45_000;\n\nexport class TimeoutError extends Error {\n constructor(timeout: number) {\n super(`No message received in ${timeout}ms`);\n this.name = \"TimeoutError\";\n }\n}\n\n/** Client call options. */\nexport interface ClientCallOptions {\n signal?: AbortSignal;\n}\n\nexport interface StreamDataOptions extends ClientCallOptions {\n /** Stop at the specified cursor (inclusive). */\n endingCursor?: Cursor;\n /** Timeout between messages, in milliseconds. */\n timeout?: number;\n}\n\n/** DNA client. */\nexport interface Client<TFilter, TBlock> {\n /** Fetch the DNA stream status. */\n status(\n request?: StatusRequest,\n options?: ClientCallOptions,\n ): Promise<StatusResponse>;\n\n /** Start streaming data from the DNA server. */\n streamData(\n request: StreamDataRequest<TFilter>,\n options?: StreamDataOptions,\n ): AsyncIterable<StreamDataResponse<TBlock>>;\n}\n\nexport type CreateClientOptions = {\n defaultCallOptions?: DefaultCallOptions<\n NormalizedServiceDefinition<proto.stream.DnaStreamDefinition>\n >;\n credentials?: ChannelCredentials;\n channelOptions?: ChannelOptions;\n};\n\n/** Create a client connecting to the DNA grpc service. */\nexport function createClient<TFilter, TBlock>(\n config: StreamConfig<TFilter, TBlock>,\n streamUrl: string,\n options: CreateClientOptions = {},\n) {\n const channel = createChannel(\n streamUrl,\n options?.credentials,\n options?.channelOptions,\n );\n\n const client: proto.stream.DnaStreamClient = grpcCreateClient(\n proto.stream.DnaStreamDefinition,\n channel,\n options?.defaultCallOptions,\n );\n\n return new GrpcClient(config, client);\n}\n\nexport class GrpcClient<TFilter, TBlock> implements Client<TFilter, TBlock> {\n private encodeRequest;\n\n constructor(\n private config: StreamConfig<TFilter, TBlock>,\n private client: proto.stream.DnaStreamClient,\n ) {\n this.encodeRequest = config.Request.encode;\n }\n\n async status(request?: StatusRequest, options?: ClientCallOptions) {\n const response = await this.client.status(\n StatusRequest.encode(request ?? {}),\n options,\n );\n return StatusResponse.decode(response);\n }\n\n streamData(request: StreamDataRequest<TFilter>, options?: StreamDataOptions) {\n const it = this.client.streamData(this.encodeRequest(request), options);\n return new StreamDataIterable(it, this.config.Block, options);\n }\n}\n\nexport class StreamDataIterable<TBlock> {\n constructor(\n private it: AsyncIterable<proto.stream.StreamDataResponse>,\n private schema: Codec<TBlock, Uint8Array>,\n private options?: StreamDataOptions,\n ) {}\n\n [Symbol.asyncIterator](): AsyncIterator<StreamDataResponse<TBlock>> {\n const inner = this.it[Symbol.asyncIterator]();\n const schema = StreamDataResponse(this.schema);\n const decoder = schema.decode;\n const { endingCursor, timeout = DEFAULT_TIMEOUT_MS } = this.options ?? {};\n let shouldStop = false;\n\n let clock: string | number | NodeJS.Timeout | undefined;\n\n return {\n async next() {\n if (shouldStop) {\n return { done: true, value: undefined };\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: any is ok\n const t: Promise<{ done: boolean; value: any }> = new Promise(\n (_, reject) => {\n clock = setTimeout(() => {\n reject(new TimeoutError(timeout));\n }, timeout);\n },\n );\n\n try {\n const { done, value } = await Promise.race([inner.next(), t]);\n\n clearTimeout(clock);\n\n if (done || value.message === undefined) {\n return { done: true, value: undefined };\n }\n\n const decodedMessage = decoder(value.message);\n\n if (endingCursor) {\n assert(value.message.$case === \"data\");\n assert(decodedMessage._tag === \"data\");\n\n const { orderKey, uniqueKey } = endingCursor;\n const endCursor = decodedMessage.data.endCursor;\n\n // Check if the orderKey matches\n if (orderKey === endCursor?.orderKey) {\n // If a uniqueKey is specified, it must also match\n if (!uniqueKey || uniqueKey === endCursor.uniqueKey) {\n shouldStop = true;\n return { done: false, value: decodedMessage };\n }\n }\n }\n\n return {\n done: false,\n value: decodedMessage,\n };\n } finally {\n clearTimeout(clock);\n }\n },\n };\n }\n}\n","/** Track data rate using high precision timers. */\nexport class RateGauge {\n private interval: number;\n private prev?: bigint;\n private rateMs?: number;\n private var: number;\n\n constructor(intervalSeconds: number) {\n // Convert seconds to milliseconds.\n this.interval = intervalSeconds * 1_000;\n this.var = 0;\n }\n\n public record(items: number) {\n // Compute the exponential moving average of the rate.\n const prev = this.prev;\n const now = process.hrtime.bigint();\n this.prev = now;\n\n if (!prev) {\n return;\n }\n\n const deltaMs = Number(now - prev) / 1_000_000;\n // rate in items/ms.\n const rateMs = items / deltaMs;\n\n if (this.rateMs === undefined) {\n this.rateMs = rateMs;\n this.var = 0;\n return;\n }\n\n const alpha = 1 - Math.exp(-deltaMs / this.interval);\n this.rateMs = alpha * rateMs + (1 - alpha) * this.rateMs;\n\n const diff = rateMs - this.rateMs;\n const incr = alpha * diff;\n this.var = (1 - alpha) * (this.var + incr * diff);\n }\n\n /** Returns the average rate per second. */\n public average() {\n if (this.rateMs === undefined) {\n return undefined;\n }\n return this.rateMs * 1_000;\n }\n\n /** Returns the variance. */\n public variance() {\n return this.var;\n }\n}\n"],"names":["MessageCodec","OptionalCodec","Cursor","config","createChannel","grpcCreateClient","proto.stream.DnaStreamDefinition","__publicField","StreamDataResponse","assert"],"mappings":";;;;;;;;;;;;;;;;;;;;AAIa,MAAA,aAAA,GAAgBA,kBAAa,CAAA,EAAE,EAAA;AAKrC,MAAM,iBAAiBA,kBAAa,CAAA;AAAA,EACzC,WAAA,EAAaC,oBAAcC,aAAM,CAAA;AAAA,EACjC,YAAA,EAAcD,oBAAcC,aAAM,CAAA;AAAA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M,QAAQ,CAAI,GAAA,IAAA,CAAK,IAAI,CAAC,OAAA,GAAU,KAAK,QAAQ,CAAA,CAAA;AACnD,IAAA,IAAA,CAAK,MAAS,GAAA,KAAA,GAAQ,MAAU,GAAA,CAAA,CAAA,GAAI,SAAS,IAAK,CAAA,MAAA,CAAA;AAElD,IAAM,MAAA,IAAA,GAAO,SAAS,IAAK,CAAA,MAAA,CAAA;AAC3B,IAAA,MAAM,OAAO,KAAQ,GAAA,IAAA,CAAA;AACrB,IAAA,IAAA,CAAK,GAAO,GAAA,CAAA,CAAA,GAAI,KAAU,KAAA,IAAA,CAAK,MAAM,IAAO,GAAA,IAAA,CAAA,CAAA;AAAA,GAC9C;AAAA;AAAA,EAGO,OAAU,GAAA;AACf,IAAI,IAAA,IAAA,CAAK,WAAW,KAAW,CAAA,EAAA;AAC7B,MAAO,OAAA,KAAA,CAAA,CAAA;AAAA,KACT;AACA,IAAA,OAAO,KAAK,MAAS,GAAA,GAAA,CAAA;AAAA,GACvB;AAAA;AAAA,EAGO,QAAW,GAAA;AAChB,IAAA,OAAO,IAAK,CAAA,GAAA,CAAA;AAAA,GACd;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
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.a5762a90.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.a5762a90.cjs';
|
|
3
3
|
import _m0 from 'protobufjs/minimal.js';
|
|
4
|
-
export { ClientError, Status } from 'nice-grpc';
|
|
5
|
-
import '
|
|
4
|
+
export { ClientError, Metadata, ServerError, Status } from 'nice-grpc';
|
|
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.21b07506.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.21b07506.mjs';
|
|
3
3
|
import _m0 from 'protobufjs/minimal.js';
|
|
4
|
-
export { ClientError, Status } from 'nice-grpc';
|
|
5
|
-
import '
|
|
4
|
+
export { ClientError, Metadata, ServerError, Status } from 'nice-grpc';
|
|
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.526c6532.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.526c6532.js';
|
|
3
3
|
import _m0 from 'protobufjs/minimal.js';
|
|
4
|
-
export { ClientError, Status } from 'nice-grpc';
|
|
5
|
-
import '
|
|
4
|
+
export { ClientError, Metadata, ServerError, Status } from 'nice-grpc';
|
|
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.68fdd897.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.68fdd897.mjs';
|
|
3
|
+
import { MessageCodec, OptionalCodec } from './codec.mjs';
|
|
4
4
|
import { createChannel, createClient as createClient$1 } from 'nice-grpc';
|
|
5
|
-
export { ClientError, Status } from 'nice-grpc';
|
|
5
|
+
export { ClientError, Metadata, ServerError, 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,5 @@ 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 };
|
|
175
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/status.ts","../src/client.ts","../src/rate.ts"],"sourcesContent":["import { type CodecType, MessageCodec, OptionalCodec } from \"./codec\";\nimport { Cursor } from \"./common\";\n\n/** The request to the `status` endpoint. */\nexport const StatusRequest = MessageCodec({});\n\nexport type StatusRequest = CodecType<typeof StatusRequest>;\n\n/** The response from the `status` endpoint. */\nexport const StatusResponse = MessageCodec({\n currentHead: OptionalCodec(Cursor),\n lastIngested: OptionalCodec(Cursor),\n finalized: OptionalCodec(Cursor),\n starting: OptionalCodec(Cursor),\n});\n\nexport type StatusResponse = CodecType<typeof StatusResponse>;\n","import {\n type ChannelCredentials,\n type ChannelOptions,\n type DefaultCallOptions,\n type NormalizedServiceDefinition,\n createChannel,\n createClient as grpcCreateClient,\n} from \"nice-grpc\";\n\nimport * as proto from \"./proto\";\n\nimport assert from \"node:assert\";\nimport type { Codec } from \"./codec\";\nimport type { Cursor } from \"./common\";\nimport type { StreamConfig } from \"./config\";\nimport { StatusRequest, StatusResponse } from \"./status\";\nimport { type StreamDataRequest, StreamDataResponse } from \"./stream\";\n\nexport { ClientError, ServerError, Status, Metadata } from \"nice-grpc\";\n\nconst DEFAULT_TIMEOUT_MS = 45_000;\n\nexport class TimeoutError extends Error {\n constructor(timeout: number) {\n super(`No message received in ${timeout}ms`);\n this.name = \"TimeoutError\";\n }\n}\n\n/** Client call options. */\nexport interface ClientCallOptions {\n signal?: AbortSignal;\n}\n\nexport interface StreamDataOptions extends ClientCallOptions {\n /** Stop at the specified cursor (inclusive). */\n endingCursor?: Cursor;\n /** Timeout between messages, in milliseconds. */\n timeout?: number;\n}\n\n/** DNA client. */\nexport interface Client<TFilter, TBlock> {\n /** Fetch the DNA stream status. */\n status(\n request?: StatusRequest,\n options?: ClientCallOptions,\n ): Promise<StatusResponse>;\n\n /** Start streaming data from the DNA server. */\n streamData(\n request: StreamDataRequest<TFilter>,\n options?: StreamDataOptions,\n ): AsyncIterable<StreamDataResponse<TBlock>>;\n}\n\nexport type CreateClientOptions = {\n defaultCallOptions?: DefaultCallOptions<\n NormalizedServiceDefinition<proto.stream.DnaStreamDefinition>\n >;\n credentials?: ChannelCredentials;\n channelOptions?: ChannelOptions;\n};\n\n/** Create a client connecting to the DNA grpc service. */\nexport function createClient<TFilter, TBlock>(\n config: StreamConfig<TFilter, TBlock>,\n streamUrl: string,\n options: CreateClientOptions = {},\n) {\n const channel = createChannel(\n streamUrl,\n options?.credentials,\n options?.channelOptions,\n );\n\n const client: proto.stream.DnaStreamClient = grpcCreateClient(\n proto.stream.DnaStreamDefinition,\n channel,\n options?.defaultCallOptions,\n );\n\n return new GrpcClient(config, client);\n}\n\nexport class GrpcClient<TFilter, TBlock> implements Client<TFilter, TBlock> {\n private encodeRequest;\n\n constructor(\n private config: StreamConfig<TFilter, TBlock>,\n private client: proto.stream.DnaStreamClient,\n ) {\n this.encodeRequest = config.Request.encode;\n }\n\n async status(request?: StatusRequest, options?: ClientCallOptions) {\n const response = await this.client.status(\n StatusRequest.encode(request ?? {}),\n options,\n );\n return StatusResponse.decode(response);\n }\n\n streamData(request: StreamDataRequest<TFilter>, options?: StreamDataOptions) {\n const it = this.client.streamData(this.encodeRequest(request), options);\n return new StreamDataIterable(it, this.config.Block, options);\n }\n}\n\nexport class StreamDataIterable<TBlock> {\n constructor(\n private it: AsyncIterable<proto.stream.StreamDataResponse>,\n private schema: Codec<TBlock, Uint8Array>,\n private options?: StreamDataOptions,\n ) {}\n\n [Symbol.asyncIterator](): AsyncIterator<StreamDataResponse<TBlock>> {\n const inner = this.it[Symbol.asyncIterator]();\n const schema = StreamDataResponse(this.schema);\n const decoder = schema.decode;\n const { endingCursor, timeout = DEFAULT_TIMEOUT_MS } = this.options ?? {};\n let shouldStop = false;\n\n let clock: string | number | NodeJS.Timeout | undefined;\n\n return {\n async next() {\n if (shouldStop) {\n return { done: true, value: undefined };\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: any is ok\n const t: Promise<{ done: boolean; value: any }> = new Promise(\n (_, reject) => {\n clock = setTimeout(() => {\n reject(new TimeoutError(timeout));\n }, timeout);\n },\n );\n\n try {\n const { done, value } = await Promise.race([inner.next(), t]);\n\n clearTimeout(clock);\n\n if (done || value.message === undefined) {\n return { done: true, value: undefined };\n }\n\n const decodedMessage = decoder(value.message);\n\n if (endingCursor) {\n assert(value.message.$case === \"data\");\n assert(decodedMessage._tag === \"data\");\n\n const { orderKey, uniqueKey } = endingCursor;\n const endCursor = decodedMessage.data.endCursor;\n\n // Check if the orderKey matches\n if (orderKey === endCursor?.orderKey) {\n // If a uniqueKey is specified, it must also match\n if (!uniqueKey || uniqueKey === endCursor.uniqueKey) {\n shouldStop = true;\n return { done: false, value: decodedMessage };\n }\n }\n }\n\n return {\n done: false,\n value: decodedMessage,\n };\n } finally {\n clearTimeout(clock);\n }\n },\n };\n }\n}\n","/** Track data rate using high precision timers. */\nexport class RateGauge {\n private interval: number;\n private prev?: bigint;\n private rateMs?: number;\n private var: number;\n\n constructor(intervalSeconds: number) {\n // Convert seconds to milliseconds.\n this.interval = intervalSeconds * 1_000;\n this.var = 0;\n }\n\n public record(items: number) {\n // Compute the exponential moving average of the rate.\n const prev = this.prev;\n const now = process.hrtime.bigint();\n this.prev = now;\n\n if (!prev) {\n return;\n }\n\n const deltaMs = Number(now - prev) / 1_000_000;\n // rate in items/ms.\n const rateMs = items / deltaMs;\n\n if (this.rateMs === undefined) {\n this.rateMs = rateMs;\n this.var = 0;\n return;\n }\n\n const alpha = 1 - Math.exp(-deltaMs / this.interval);\n this.rateMs = alpha * rateMs + (1 - alpha) * this.rateMs;\n\n const diff = rateMs - this.rateMs;\n const incr = alpha * diff;\n this.var = (1 - alpha) * (this.var + incr * diff);\n }\n\n /** Returns the average rate per second. */\n public average() {\n if (this.rateMs === undefined) {\n return undefined;\n }\n return this.rateMs * 1_000;\n }\n\n /** Returns the variance. */\n public variance() {\n return this.var;\n }\n}\n"],"names":["grpcCreateClient","proto.stream.DnaStreamDefinition","__publicField"],"mappings":";;;;;;;;;;;;;;;;AAIa,MAAA,aAAA,GAAgB,YAAa,CAAA,EAAE,EAAA;AAKrC,MAAM,iBAAiB,YAAa,CAAA;AAAA,EACzC,WAAA,EAAa,cAAc,MAAM,CAAA;AAAA,EACjC,YAAA,EAAc,cAAc,MAAM,CAAA;AAAA,EAClC,SAAA,EAAW,cAAc,MAAM,CAAA;AAAA,EAC/B,QAAA,EAAU,cAAc,MAAM,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