@apibara/protocol 2.0.0-beta.2 → 2.0.0-beta.4
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/package.json +33 -45
- package/src/common.ts +2 -2
- package/src/proto/google/protobuf/duration.ts +189 -0
- package/src/proto/index.ts +1 -2
- package/src/proto/stream.ts +441 -10
- package/src/status.ts +2 -0
- package/src/stream.ts +22 -2
- package/CHANGELOG.md +0 -103
- package/LICENSE.txt +0 -202
- package/buf.gen.yaml +0 -14
- package/build.config.ts +0 -11
- package/dist/index.cjs +0 -189
- package/dist/index.d.cts +0 -72
- package/dist/index.d.mts +0 -72
- package/dist/index.d.ts +0 -72
- package/dist/index.mjs +0 -153
- package/dist/shared/protocol.6b1bdade.cjs +0 -1060
- package/dist/shared/protocol.a07a51b5.mjs +0 -1028
- package/dist/shared/protocol.e9aed6a3.d.cts +0 -549
- package/dist/shared/protocol.e9aed6a3.d.mts +0 -549
- package/dist/shared/protocol.e9aed6a3.d.ts +0 -549
- package/dist/testing/index.cjs +0 -105
- package/dist/testing/index.d.cts +0 -70
- package/dist/testing/index.d.mts +0 -70
- package/dist/testing/index.d.ts +0 -70
- package/dist/testing/index.mjs +0 -97
- package/proto/common.proto +0 -22
- package/proto/stream.proto +0 -83
- package/proto/testing.proto +0 -11
- package/src/proto/common.ts +0 -279
- package/tsconfig.json +0 -12
package/package.json
CHANGED
|
@@ -1,57 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apibara/protocol",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
4
|
-
"
|
|
5
|
-
"repository": "apibara/typescript-sdk",
|
|
6
|
-
"license": "Apache-2.0",
|
|
7
|
-
"sideEffects": false,
|
|
3
|
+
"version": "2.0.0-beta.4",
|
|
4
|
+
"type": "module",
|
|
8
5
|
"source": "./src/index.ts",
|
|
9
6
|
"main": "./dist/index.mjs",
|
|
10
7
|
"exports": {
|
|
11
8
|
".": {
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"require": {
|
|
17
|
-
"types": "./dist/index.d.cts",
|
|
18
|
-
"default": "./dist/index.cjs"
|
|
19
|
-
}
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
20
13
|
},
|
|
21
14
|
"./testing": {
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"require": {
|
|
27
|
-
"types": "./dist/testing/index.d.cts",
|
|
28
|
-
"default": "./dist/testing/index.cjs"
|
|
29
|
-
}
|
|
15
|
+
"types": "./dist/testing/index.d.ts",
|
|
16
|
+
"import": "./dist/testing/index.mjs",
|
|
17
|
+
"require": "./dist/testing/index.cjs",
|
|
18
|
+
"default": "./dist/testing/index.mjs"
|
|
30
19
|
}
|
|
31
20
|
},
|
|
32
|
-
"publishConfig": {
|
|
33
|
-
"files": [
|
|
34
|
-
"dist",
|
|
35
|
-
"src",
|
|
36
|
-
"README.md"
|
|
37
|
-
]
|
|
38
|
-
},
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"@effect/schema": "^0.67.15",
|
|
41
|
-
"effect": "^3.2.6",
|
|
42
|
-
"long": "^5.2.3",
|
|
43
|
-
"nice-grpc": "^2.1.8",
|
|
44
|
-
"nice-grpc-common": "^2.0.2",
|
|
45
|
-
"protobufjs": "^7.3.0",
|
|
46
|
-
"viem": "^2.13.2"
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@bufbuild/buf": "^1.32.2",
|
|
50
|
-
"@types/long": "^5.0.0",
|
|
51
|
-
"@types/node": "^20.12.13",
|
|
52
|
-
"unbuild": "^2.0.0",
|
|
53
|
-
"vitest": "^1.6.0"
|
|
54
|
-
},
|
|
21
|
+
"publishConfig": {},
|
|
55
22
|
"scripts": {
|
|
56
23
|
"build": "pnpm build:proto && unbuild",
|
|
57
24
|
"build:proto": "buf generate proto",
|
|
@@ -62,5 +29,26 @@
|
|
|
62
29
|
"lint:fix": "pnpm lint --write",
|
|
63
30
|
"format": "biome format . --write"
|
|
64
31
|
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@bufbuild/buf": "^1.32.2",
|
|
34
|
+
"@types/long": "^5.0.0",
|
|
35
|
+
"@types/node": "^20.12.13",
|
|
36
|
+
"unbuild": "^2.0.0",
|
|
37
|
+
"vitest": "^1.6.0"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@effect/schema": "^0.67.15",
|
|
41
|
+
"effect": "^3.2.6",
|
|
42
|
+
"long": "^5.2.3",
|
|
43
|
+
"nice-grpc": "^2.1.8",
|
|
44
|
+
"nice-grpc-common": "^2.0.2",
|
|
45
|
+
"protobufjs": "^7.3.0",
|
|
46
|
+
"viem": "^2.13.2"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"src",
|
|
51
|
+
"README.md"
|
|
52
|
+
],
|
|
65
53
|
"types": "./dist/index.d.ts"
|
|
66
|
-
}
|
|
54
|
+
}
|
package/src/common.ts
CHANGED
|
@@ -53,10 +53,10 @@ export const CursorFromBytes = Schema.transform(
|
|
|
53
53
|
Cursor,
|
|
54
54
|
{
|
|
55
55
|
decode(value) {
|
|
56
|
-
return proto.
|
|
56
|
+
return proto.stream.Cursor.decode(value);
|
|
57
57
|
},
|
|
58
58
|
encode(value) {
|
|
59
|
-
return proto.
|
|
59
|
+
return proto.stream.Cursor.encode(value).finish();
|
|
60
60
|
},
|
|
61
61
|
},
|
|
62
62
|
);
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v1.176.0
|
|
4
|
+
// protoc unknown
|
|
5
|
+
// source: google/protobuf/duration.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import Long from "long";
|
|
9
|
+
import _m0 from "protobufjs/minimal";
|
|
10
|
+
|
|
11
|
+
export const protobufPackage = "google.protobuf";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A Duration represents a signed, fixed-length span of time represented
|
|
15
|
+
* as a count of seconds and fractions of seconds at nanosecond
|
|
16
|
+
* resolution. It is independent of any calendar and concepts like "day"
|
|
17
|
+
* or "month". It is related to Timestamp in that the difference between
|
|
18
|
+
* two Timestamp values is a Duration and it can be added or subtracted
|
|
19
|
+
* from a Timestamp. Range is approximately +-10,000 years.
|
|
20
|
+
*
|
|
21
|
+
* # Examples
|
|
22
|
+
*
|
|
23
|
+
* Example 1: Compute Duration from two Timestamps in pseudo code.
|
|
24
|
+
*
|
|
25
|
+
* Timestamp start = ...;
|
|
26
|
+
* Timestamp end = ...;
|
|
27
|
+
* Duration duration = ...;
|
|
28
|
+
*
|
|
29
|
+
* duration.seconds = end.seconds - start.seconds;
|
|
30
|
+
* duration.nanos = end.nanos - start.nanos;
|
|
31
|
+
*
|
|
32
|
+
* if (duration.seconds < 0 && duration.nanos > 0) {
|
|
33
|
+
* duration.seconds += 1;
|
|
34
|
+
* duration.nanos -= 1000000000;
|
|
35
|
+
* } else if (duration.seconds > 0 && duration.nanos < 0) {
|
|
36
|
+
* duration.seconds -= 1;
|
|
37
|
+
* duration.nanos += 1000000000;
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
|
|
41
|
+
*
|
|
42
|
+
* Timestamp start = ...;
|
|
43
|
+
* Duration duration = ...;
|
|
44
|
+
* Timestamp end = ...;
|
|
45
|
+
*
|
|
46
|
+
* end.seconds = start.seconds + duration.seconds;
|
|
47
|
+
* end.nanos = start.nanos + duration.nanos;
|
|
48
|
+
*
|
|
49
|
+
* if (end.nanos < 0) {
|
|
50
|
+
* end.seconds -= 1;
|
|
51
|
+
* end.nanos += 1000000000;
|
|
52
|
+
* } else if (end.nanos >= 1000000000) {
|
|
53
|
+
* end.seconds += 1;
|
|
54
|
+
* end.nanos -= 1000000000;
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* Example 3: Compute Duration from datetime.timedelta in Python.
|
|
58
|
+
*
|
|
59
|
+
* td = datetime.timedelta(days=3, minutes=10)
|
|
60
|
+
* duration = Duration()
|
|
61
|
+
* duration.FromTimedelta(td)
|
|
62
|
+
*
|
|
63
|
+
* # JSON Mapping
|
|
64
|
+
*
|
|
65
|
+
* In JSON format, the Duration type is encoded as a string rather than an
|
|
66
|
+
* object, where the string ends in the suffix "s" (indicating seconds) and
|
|
67
|
+
* is preceded by the number of seconds, with nanoseconds expressed as
|
|
68
|
+
* fractional seconds. For example, 3 seconds with 0 nanoseconds should be
|
|
69
|
+
* encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
|
|
70
|
+
* be expressed in JSON format as "3.000000001s", and 3 seconds and 1
|
|
71
|
+
* microsecond should be expressed in JSON format as "3.000001s".
|
|
72
|
+
*/
|
|
73
|
+
export interface Duration {
|
|
74
|
+
/**
|
|
75
|
+
* Signed seconds of the span of time. Must be from -315,576,000,000
|
|
76
|
+
* to +315,576,000,000 inclusive. Note: these bounds are computed from:
|
|
77
|
+
* 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
|
|
78
|
+
*/
|
|
79
|
+
readonly seconds: bigint;
|
|
80
|
+
/**
|
|
81
|
+
* Signed fractions of a second at nanosecond resolution of the span
|
|
82
|
+
* of time. Durations less than one second are represented with a 0
|
|
83
|
+
* `seconds` field and a positive or negative `nanos` field. For durations
|
|
84
|
+
* of one second or more, a non-zero value for the `nanos` field must be
|
|
85
|
+
* of the same sign as the `seconds` field. Must be from -999,999,999
|
|
86
|
+
* to +999,999,999 inclusive.
|
|
87
|
+
*/
|
|
88
|
+
readonly nanos: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function createBaseDuration(): Duration {
|
|
92
|
+
return { seconds: BigInt("0"), nanos: 0 };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const Duration = {
|
|
96
|
+
encode(message: Duration, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
97
|
+
if (message.seconds !== BigInt("0")) {
|
|
98
|
+
if (BigInt.asIntN(64, message.seconds) !== message.seconds) {
|
|
99
|
+
throw new globalThis.Error("value provided for field message.seconds of type int64 too large");
|
|
100
|
+
}
|
|
101
|
+
writer.uint32(8).int64(message.seconds.toString());
|
|
102
|
+
}
|
|
103
|
+
if (message.nanos !== 0) {
|
|
104
|
+
writer.uint32(16).int32(message.nanos);
|
|
105
|
+
}
|
|
106
|
+
return writer;
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): Duration {
|
|
110
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
111
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
112
|
+
const message = createBaseDuration() as any;
|
|
113
|
+
while (reader.pos < end) {
|
|
114
|
+
const tag = reader.uint32();
|
|
115
|
+
switch (tag >>> 3) {
|
|
116
|
+
case 1:
|
|
117
|
+
if (tag !== 8) {
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
message.seconds = longToBigint(reader.int64() as Long);
|
|
122
|
+
continue;
|
|
123
|
+
case 2:
|
|
124
|
+
if (tag !== 16) {
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
message.nanos = reader.int32();
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
reader.skipType(tag & 7);
|
|
135
|
+
}
|
|
136
|
+
return message;
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
fromJSON(object: any): Duration {
|
|
140
|
+
return {
|
|
141
|
+
seconds: isSet(object.seconds) ? BigInt(object.seconds) : BigInt("0"),
|
|
142
|
+
nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0,
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
toJSON(message: Duration): unknown {
|
|
147
|
+
const obj: any = {};
|
|
148
|
+
if (message.seconds !== BigInt("0")) {
|
|
149
|
+
obj.seconds = message.seconds.toString();
|
|
150
|
+
}
|
|
151
|
+
if (message.nanos !== 0) {
|
|
152
|
+
obj.nanos = Math.round(message.nanos);
|
|
153
|
+
}
|
|
154
|
+
return obj;
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
create(base?: DeepPartial<Duration>): Duration {
|
|
158
|
+
return Duration.fromPartial(base ?? {});
|
|
159
|
+
},
|
|
160
|
+
fromPartial(object: DeepPartial<Duration>): Duration {
|
|
161
|
+
const message = createBaseDuration() as any;
|
|
162
|
+
message.seconds = object.seconds ?? BigInt("0");
|
|
163
|
+
message.nanos = object.nanos ?? 0;
|
|
164
|
+
return message;
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
|
|
169
|
+
|
|
170
|
+
export type DeepPartial<T> = T extends Builtin ? T
|
|
171
|
+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
|
172
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
173
|
+
: T extends { readonly $case: string }
|
|
174
|
+
? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { readonly $case: T["$case"] }
|
|
175
|
+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
176
|
+
: Partial<T>;
|
|
177
|
+
|
|
178
|
+
function longToBigint(long: Long) {
|
|
179
|
+
return BigInt(long.toString());
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (_m0.util.Long !== Long) {
|
|
183
|
+
_m0.util.Long = Long as any;
|
|
184
|
+
_m0.configure();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function isSet(value: any): boolean {
|
|
188
|
+
return value !== null && value !== undefined;
|
|
189
|
+
}
|
package/src/proto/index.ts
CHANGED