@apibara/protocol 2.1.0-beta.4 → 2.1.0-beta.41
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 +43 -30
- 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 +40 -22
- package/dist/index.mjs.map +1 -0
- package/dist/shared/{protocol.4b1cfe2c.d.cts → protocol.0e734e33.d.cts} +400 -247
- package/dist/shared/{protocol.4b1cfe2c.d.mts → protocol.21e66b9e.d.mts} +400 -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.8fb09325.d.ts} +400 -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 +8 -3
- package/src/client.ts +39 -14
- 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,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 -1,17 +1,18 @@
|
|
|
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
|
+
const assert = require('node:assert');
|
|
6
|
+
const consola = require('consola');
|
|
5
7
|
const niceGrpc = require('nice-grpc');
|
|
6
8
|
require('protobufjs/minimal.js');
|
|
7
|
-
const assert = require('node:assert');
|
|
8
|
-
require('effect');
|
|
9
9
|
require('viem');
|
|
10
10
|
require('long');
|
|
11
11
|
|
|
12
12
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
13
13
|
|
|
14
14
|
const assert__default = /*#__PURE__*/_interopDefaultCompat(assert);
|
|
15
|
+
const consola__default = /*#__PURE__*/_interopDefaultCompat(consola);
|
|
15
16
|
|
|
16
17
|
const index = {
|
|
17
18
|
__proto__: null,
|
|
@@ -19,17 +20,13 @@ const index = {
|
|
|
19
20
|
testing: config.testing
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
const StatusRequest =
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
finalized: schema.Schema.optional(config.Cursor),
|
|
29
|
-
starting: schema.Schema.optional(config.Cursor)
|
|
23
|
+
const StatusRequest = codec.MessageCodec({});
|
|
24
|
+
const StatusResponse = codec.MessageCodec({
|
|
25
|
+
currentHead: codec.OptionalCodec(config.Cursor),
|
|
26
|
+
lastIngested: codec.OptionalCodec(config.Cursor),
|
|
27
|
+
finalized: codec.OptionalCodec(config.Cursor),
|
|
28
|
+
starting: codec.OptionalCodec(config.Cursor)
|
|
30
29
|
});
|
|
31
|
-
const statusResponseToProto = schema.Schema.encodeSync(StatusResponse);
|
|
32
|
-
const statusResponseFromProto = schema.Schema.decodeSync(StatusResponse);
|
|
33
30
|
|
|
34
31
|
var __defProp$1 = Object.defineProperty;
|
|
35
32
|
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -57,19 +54,40 @@ function createClient(config$1, streamUrl, options = {}) {
|
|
|
57
54
|
);
|
|
58
55
|
return new GrpcClient(config$1, client);
|
|
59
56
|
}
|
|
57
|
+
function createAuthenticatedClient(config, streamUrl, options) {
|
|
58
|
+
const dnaToken = process.env.DNA_TOKEN;
|
|
59
|
+
if (!dnaToken) {
|
|
60
|
+
consola__default.warn(
|
|
61
|
+
"DNA_TOKEN environment variable is not set. Trying to connect without authentication."
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return createClient(config, streamUrl, {
|
|
65
|
+
...options,
|
|
66
|
+
defaultCallOptions: {
|
|
67
|
+
...options?.defaultCallOptions ?? {},
|
|
68
|
+
"*": {
|
|
69
|
+
metadata: niceGrpc.Metadata({
|
|
70
|
+
Authorization: `Bearer ${dnaToken}`
|
|
71
|
+
}),
|
|
72
|
+
// metadata cant be overrided with spread as its a class so we override it fully if user provided it.
|
|
73
|
+
...options?.defaultCallOptions?.["*"] ?? {}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
60
78
|
class GrpcClient {
|
|
61
79
|
constructor(config, client) {
|
|
62
80
|
this.config = config;
|
|
63
81
|
this.client = client;
|
|
64
82
|
__publicField$1(this, "encodeRequest");
|
|
65
|
-
this.encodeRequest =
|
|
83
|
+
this.encodeRequest = config.Request.encode;
|
|
66
84
|
}
|
|
67
85
|
async status(request, options) {
|
|
68
86
|
const response = await this.client.status(
|
|
69
|
-
|
|
87
|
+
StatusRequest.encode(request ?? {}),
|
|
70
88
|
options
|
|
71
89
|
);
|
|
72
|
-
return
|
|
90
|
+
return StatusResponse.decode(response);
|
|
73
91
|
}
|
|
74
92
|
streamData(request, options) {
|
|
75
93
|
const it = this.client.streamData(this.encodeRequest(request), options);
|
|
@@ -84,8 +102,8 @@ class StreamDataIterable {
|
|
|
84
102
|
}
|
|
85
103
|
[Symbol.asyncIterator]() {
|
|
86
104
|
const inner = this.it[Symbol.asyncIterator]();
|
|
87
|
-
const schema
|
|
88
|
-
const decoder = schema.
|
|
105
|
+
const schema = config.StreamDataResponse(this.schema);
|
|
106
|
+
const decoder = schema.decode;
|
|
89
107
|
const { endingCursor, timeout = DEFAULT_TIMEOUT_MS } = this.options ?? {};
|
|
90
108
|
let shouldStop = false;
|
|
91
109
|
let clock;
|
|
@@ -180,7 +198,6 @@ class RateGauge {
|
|
|
180
198
|
}
|
|
181
199
|
}
|
|
182
200
|
|
|
183
|
-
exports.Bytes = config.Bytes;
|
|
184
201
|
exports.BytesFromUint8Array = config.BytesFromUint8Array;
|
|
185
202
|
exports.Cursor = config.Cursor;
|
|
186
203
|
exports.CursorFromBytes = config.CursorFromBytes;
|
|
@@ -188,25 +205,23 @@ exports.Data = config.Data;
|
|
|
188
205
|
exports.DataFinality = config.DataFinality;
|
|
189
206
|
exports.DataProduction = config.DataProduction;
|
|
190
207
|
exports.DnaStreamDefinition = config.DnaStreamDefinition;
|
|
191
|
-
exports.
|
|
208
|
+
exports.DurationCodec = config.DurationCodec;
|
|
192
209
|
exports.Finalize = config.Finalize;
|
|
193
210
|
exports.Heartbeat = config.Heartbeat;
|
|
194
211
|
exports.Invalidate = config.Invalidate;
|
|
212
|
+
exports.ResponseWithoutData = config.ResponseWithoutData;
|
|
195
213
|
exports.StdErr = config.StdErr;
|
|
196
214
|
exports.StdOut = config.StdOut;
|
|
197
215
|
exports.StreamConfig = config.StreamConfig;
|
|
198
216
|
exports.StreamDataRequest = config.StreamDataRequest;
|
|
199
217
|
exports.StreamDataResponse = config.StreamDataResponse;
|
|
200
218
|
exports.SystemMessage = config.SystemMessage;
|
|
201
|
-
exports._Cursor = config._Cursor;
|
|
202
219
|
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
220
|
exports.isCursor = config.isCursor;
|
|
208
221
|
exports.normalizeCursor = config.normalizeCursor;
|
|
209
222
|
exports.ClientError = niceGrpc.ClientError;
|
|
223
|
+
exports.Metadata = niceGrpc.Metadata;
|
|
224
|
+
exports.ServerError = niceGrpc.ServerError;
|
|
210
225
|
exports.Status = niceGrpc.Status;
|
|
211
226
|
exports.GrpcClient = GrpcClient;
|
|
212
227
|
exports.RateGauge = RateGauge;
|
|
@@ -214,9 +229,7 @@ exports.StatusRequest = StatusRequest;
|
|
|
214
229
|
exports.StatusResponse = StatusResponse;
|
|
215
230
|
exports.StreamDataIterable = StreamDataIterable;
|
|
216
231
|
exports.TimeoutError = TimeoutError;
|
|
232
|
+
exports.createAuthenticatedClient = createAuthenticatedClient;
|
|
217
233
|
exports.createClient = createClient;
|
|
218
234
|
exports.proto = index;
|
|
219
|
-
|
|
220
|
-
exports.statusRequestToProto = statusRequestToProto;
|
|
221
|
-
exports.statusResponseFromProto = statusResponseFromProto;
|
|
222
|
-
exports.statusResponseToProto = statusResponseToProto;
|
|
235
|
+
//# 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 assert from \"node:assert\";\n\nimport consola from \"consola\";\nimport {\n type ChannelCredentials,\n type ChannelOptions,\n type DefaultCallOptions,\n Metadata,\n type NormalizedServiceDefinition,\n createChannel,\n createClient as grpcCreateClient,\n} from \"nice-grpc\";\n\nimport * as proto from \"./proto\";\n\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 function createAuthenticatedClient<TFilter, TBlock>(\n config: StreamConfig<TFilter, TBlock>,\n streamUrl: string,\n options?: CreateClientOptions,\n) {\n const dnaToken = process.env.DNA_TOKEN;\n if (!dnaToken) {\n consola.warn(\n \"DNA_TOKEN environment variable is not set. Trying to connect without authentication.\",\n );\n }\n\n return createClient(config, streamUrl, {\n ...options,\n defaultCallOptions: {\n ...(options?.defaultCallOptions ?? {}),\n \"*\": {\n metadata: Metadata({\n Authorization: `Bearer ${dnaToken}`,\n }),\n // metadata cant be overrided with spread as its a class so we override it fully if user provided it.\n ...(options?.defaultCallOptions?.[\"*\"] ?? {}),\n },\n },\n });\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","consola","Metadata","__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,EAClC,SAAA,EAAWD,oBAAcC,aAAM,CAAA;AAAA,EAC/B,QAAA,EAAUD,oBAAcC,aAAM,CAAA;AAChC,CAAC;;;;;;;;ACSD,MAAM,kBAAqB,GAAA,IAAA,CAAA;AAEpB,MAAM,qBAAqB,KAAM,CAAA;AAAA,EACtC,YAAY,OAAiB,EAAA;AAC3B,IAAM,KAAA,CAAA,CAAA,uBAAA,EAA0B,OAAO,CAAI,EAAA,CAAA,CAAA,CAAA;AAC3C,IAAA,IAAA,CAAK,IAAO,GAAA,cAAA,CAAA;AAAA,GACd;AACF,CAAA;AAsCO,SAAS,YACd,CAAAC,QAAA,EACA,SACA,EAAA,OAAA,GAA+B,EAC/B,EAAA;AACA,EAAA,MAAM,OAAU,GAAAC,sBAAA;AAAA,IACd,SAAA;AAAA,IACA,OAAS,EAAA,WAAA;AAAA,IACT,OAAS,EAAA,cAAA;AAAA,GACX,CAAA;AAEA,EAAA,MAAM,MAAuC,GAAAC,qBAAA;AAAA,IAC3CC,0BAAa;AAAA,IACb,OAAA;AAAA,IACA,OAAS,EAAA,kBAAA;AAAA,GACX,CAAA;AAEA,EAAO,OAAA,IAAI,UAAW,CAAAH,QAAA,EAAQ,MAAM,CAAA,CAAA;AACtC,CAAA;AAEgB,SAAA,yBAAA,CACd,MACA,EAAA,SAAA,EACA,OACA,EAAA;AACA,EAAM,MAAA,QAAA,GAAW,QAAQ,GAAI,CAAA,SAAA,CAAA;AAC7B,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAQI,gBA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,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.0e734e33.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, A as StreamDataIterable, v as StreamDataOptions, l as StreamDataRequest, r as StreamDataResponse, p as SystemMessage, T as TimeoutError, z as createAuthenticatedClient, y as createClient, d as createCursor, i as isCursor, n as normalizeCursor } from './shared/protocol.0e734e33.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.21e66b9e.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, A as StreamDataIterable, v as StreamDataOptions, l as StreamDataRequest, r as StreamDataResponse, p as SystemMessage, T as TimeoutError, z as createAuthenticatedClient, y as createClient, d as createCursor, i as isCursor, n as normalizeCursor } from './shared/protocol.21e66b9e.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.8fb09325.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, A as StreamDataIterable, v as StreamDataOptions, l as StreamDataRequest, r as StreamDataResponse, p as SystemMessage, T as TimeoutError, z as createAuthenticatedClient, y as createClient, d as createCursor, i as isCursor, n as normalizeCursor } from './shared/protocol.8fb09325.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 {
|