@apibara/protocol 2.0.0-beta.9 → 2.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +53 -23
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +50 -25
- package/dist/shared/{protocol.8c2a685d.d.cts → protocol.4b1cfe2c.d.cts} +61 -17
- package/dist/shared/{protocol.8c2a685d.d.mts → protocol.4b1cfe2c.d.mts} +61 -17
- package/dist/shared/{protocol.8c2a685d.d.ts → protocol.4b1cfe2c.d.ts} +61 -17
- package/dist/shared/{protocol.d9596779.mjs → protocol.991ff9ad.mjs} +98 -5
- package/dist/shared/{protocol.e1dec68a.cjs → protocol.e39e40d6.cjs} +100 -4
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.d.cts +5 -4
- package/dist/testing/index.d.mts +5 -4
- package/dist/testing/index.d.ts +5 -4
- package/dist/testing/index.mjs +1 -1
- package/package.json +1 -1
- package/src/client.ts +72 -28
- package/src/common.ts +28 -0
- package/src/proto/stream.ts +60 -1
- package/src/stream.test.ts +16 -0
- package/src/stream.ts +34 -3
- package/src/testing/client.test.ts +28 -2
package/src/stream.ts
CHANGED
|
@@ -34,6 +34,35 @@ export const DataFinality = Schema.transform(
|
|
|
34
34
|
|
|
35
35
|
export type DataFinality = typeof DataFinality.Type;
|
|
36
36
|
|
|
37
|
+
/** Data production mode. */
|
|
38
|
+
export const DataProduction = Schema.transform(
|
|
39
|
+
Schema.Enums(proto.stream.DataProduction),
|
|
40
|
+
Schema.Literal("backfill", "live", "unknown"),
|
|
41
|
+
{
|
|
42
|
+
decode(value) {
|
|
43
|
+
const enumMap = {
|
|
44
|
+
[proto.stream.DataProduction.BACKFILL]: "backfill",
|
|
45
|
+
[proto.stream.DataProduction.LIVE]: "live",
|
|
46
|
+
[proto.stream.DataProduction.UNKNOWN]: "unknown",
|
|
47
|
+
[proto.stream.DataProduction.UNRECOGNIZED]: "unknown",
|
|
48
|
+
} as const;
|
|
49
|
+
|
|
50
|
+
return enumMap[value] ?? "unknown";
|
|
51
|
+
},
|
|
52
|
+
encode(value) {
|
|
53
|
+
const enumMap = {
|
|
54
|
+
backfill: proto.stream.DataProduction.BACKFILL,
|
|
55
|
+
live: proto.stream.DataProduction.LIVE,
|
|
56
|
+
unknown: proto.stream.DataProduction.UNKNOWN,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return enumMap[value] ?? proto.stream.DataProduction.UNKNOWN;
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
export type DataProduction = typeof DataProduction.Type;
|
|
65
|
+
|
|
37
66
|
export const Duration = Schema.Struct({
|
|
38
67
|
seconds: Schema.BigIntFromSelf,
|
|
39
68
|
nanos: Schema.Number,
|
|
@@ -97,7 +126,7 @@ export type StdErr = typeof StdErr.Type;
|
|
|
97
126
|
export const SystemMessage = Schema.Struct({
|
|
98
127
|
_tag: tag("systemMessage"),
|
|
99
128
|
systemMessage: Schema.Struct({
|
|
100
|
-
output: Schema.
|
|
129
|
+
output: Schema.Union(StdOut, StdErr),
|
|
101
130
|
}),
|
|
102
131
|
});
|
|
103
132
|
|
|
@@ -110,8 +139,9 @@ export const Data = <TA, TR>(
|
|
|
110
139
|
_tag: tag("data"),
|
|
111
140
|
data: Schema.Struct({
|
|
112
141
|
cursor: Schema.optional(Cursor),
|
|
113
|
-
endCursor:
|
|
142
|
+
endCursor: Cursor,
|
|
114
143
|
finality: DataFinality,
|
|
144
|
+
production: DataProduction,
|
|
115
145
|
data: Schema.Array(schema),
|
|
116
146
|
}),
|
|
117
147
|
});
|
|
@@ -134,8 +164,9 @@ export type StreamDataResponse<TA> =
|
|
|
134
164
|
_tag: "data";
|
|
135
165
|
data: {
|
|
136
166
|
cursor?: Cursor | undefined;
|
|
137
|
-
endCursor
|
|
167
|
+
endCursor: Cursor;
|
|
138
168
|
finality: DataFinality;
|
|
169
|
+
production: DataProduction;
|
|
139
170
|
data: readonly (TA | null)[];
|
|
140
171
|
};
|
|
141
172
|
};
|
|
@@ -9,7 +9,15 @@ describe("MockClient", () => {
|
|
|
9
9
|
return [
|
|
10
10
|
{
|
|
11
11
|
_tag: "data",
|
|
12
|
-
data: {
|
|
12
|
+
data: {
|
|
13
|
+
finality: "finalized",
|
|
14
|
+
data: [{ data: "hello" }],
|
|
15
|
+
production: "backfill",
|
|
16
|
+
endCursor: {
|
|
17
|
+
orderKey: 5_000_000n,
|
|
18
|
+
uniqueKey: "0x1234567890",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
13
21
|
},
|
|
14
22
|
];
|
|
15
23
|
});
|
|
@@ -29,7 +37,12 @@ describe("MockClient", () => {
|
|
|
29
37
|
"data": "hello",
|
|
30
38
|
},
|
|
31
39
|
],
|
|
40
|
+
"endCursor": {
|
|
41
|
+
"orderKey": 5000000n,
|
|
42
|
+
"uniqueKey": "0x1234567890",
|
|
43
|
+
},
|
|
32
44
|
"finality": "finalized",
|
|
45
|
+
"production": "backfill",
|
|
33
46
|
},
|
|
34
47
|
},
|
|
35
48
|
]
|
|
@@ -41,7 +54,15 @@ describe("MockClient", () => {
|
|
|
41
54
|
return [
|
|
42
55
|
{
|
|
43
56
|
_tag: "data",
|
|
44
|
-
data: {
|
|
57
|
+
data: {
|
|
58
|
+
finality: "finalized",
|
|
59
|
+
data: [{ data: "hello" }, null],
|
|
60
|
+
production: "backfill",
|
|
61
|
+
endCursor: {
|
|
62
|
+
orderKey: 5_000_000n,
|
|
63
|
+
uniqueKey: "0x1234567890",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
45
66
|
},
|
|
46
67
|
];
|
|
47
68
|
});
|
|
@@ -62,7 +83,12 @@ describe("MockClient", () => {
|
|
|
62
83
|
},
|
|
63
84
|
null,
|
|
64
85
|
],
|
|
86
|
+
"endCursor": {
|
|
87
|
+
"orderKey": 5000000n,
|
|
88
|
+
"uniqueKey": "0x1234567890",
|
|
89
|
+
},
|
|
65
90
|
"finality": "finalized",
|
|
91
|
+
"production": "backfill",
|
|
66
92
|
},
|
|
67
93
|
},
|
|
68
94
|
]
|