@apibara/protocol 0.4.9 → 2.0.0-beta.0
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/CHANGELOG.md +103 -0
- package/buf.gen.yaml +14 -0
- package/build.config.ts +8 -0
- package/dist/index.d.mts +610 -0
- package/dist/index.d.ts +610 -4
- package/dist/index.mjs +1172 -0
- package/package.json +44 -24
- package/proto/common.proto +22 -0
- package/proto/stream.proto +83 -0
- package/proto/testing.proto +11 -0
- package/src/client.ts +113 -333
- package/src/common.test.ts +67 -0
- package/src/common.ts +65 -0
- package/src/config.ts +38 -0
- package/src/index.ts +10 -3
- package/src/proto/common.ts +279 -0
- package/src/proto/index.ts +3 -1
- package/src/proto/stream.ts +728 -17
- package/src/proto/testing.ts +143 -8
- package/src/rate.ts +54 -0
- package/src/status.test.ts +51 -0
- package/src/status.ts +22 -0
- package/src/stream.test-d.ts +33 -0
- package/src/stream.test.ts +238 -0
- package/src/stream.ts +128 -0
- package/src/testing/client.test.ts +71 -0
- package/src/testing/client.ts +49 -0
- package/src/testing/index.ts +2 -0
- package/src/testing/mock.test.ts +35 -0
- package/src/testing/mock.ts +71 -0
- package/tsconfig.json +12 -0
- package/dist/client.d.ts +0 -130
- package/dist/client.js +0 -215
- package/dist/client.js.map +0 -1
- package/dist/cursor.d.ts +0 -35
- package/dist/cursor.js +0 -67
- package/dist/cursor.js.map +0 -1
- package/dist/cursor.test.d.ts +0 -1
- package/dist/cursor.test.js +0 -22
- package/dist/cursor.test.js.map +0 -1
- package/dist/index.js +0 -21
- package/dist/index.js.map +0 -1
- package/dist/proto/apibara/node/v1alpha2/Cursor.d.ts +0 -10
- package/dist/proto/apibara/node/v1alpha2/Cursor.js +0 -4
- package/dist/proto/apibara/node/v1alpha2/Cursor.js.map +0 -1
- package/dist/proto/apibara/node/v1alpha2/Data.d.ts +0 -15
- package/dist/proto/apibara/node/v1alpha2/Data.js +0 -4
- package/dist/proto/apibara/node/v1alpha2/Data.js.map +0 -1
- package/dist/proto/apibara/node/v1alpha2/DataFinality.d.ts +0 -8
- package/dist/proto/apibara/node/v1alpha2/DataFinality.js +0 -11
- package/dist/proto/apibara/node/v1alpha2/DataFinality.js.map +0 -1
- package/dist/proto/apibara/node/v1alpha2/Heartbeat.d.ts +0 -4
- package/dist/proto/apibara/node/v1alpha2/Heartbeat.js +0 -4
- package/dist/proto/apibara/node/v1alpha2/Heartbeat.js.map +0 -1
- package/dist/proto/apibara/node/v1alpha2/Invalidate.d.ts +0 -7
- package/dist/proto/apibara/node/v1alpha2/Invalidate.js +0 -4
- package/dist/proto/apibara/node/v1alpha2/Invalidate.js.map +0 -1
- package/dist/proto/apibara/node/v1alpha2/Stream.d.ts +0 -16
- package/dist/proto/apibara/node/v1alpha2/Stream.js +0 -4
- package/dist/proto/apibara/node/v1alpha2/Stream.js.map +0 -1
- package/dist/proto/apibara/node/v1alpha2/StreamDataRequest.d.ts +0 -24
- package/dist/proto/apibara/node/v1alpha2/StreamDataRequest.js +0 -4
- package/dist/proto/apibara/node/v1alpha2/StreamDataRequest.js.map +0 -1
- package/dist/proto/apibara/node/v1alpha2/StreamDataResponse.d.ts +0 -18
- package/dist/proto/apibara/node/v1alpha2/StreamDataResponse.js +0 -4
- package/dist/proto/apibara/node/v1alpha2/StreamDataResponse.js.map +0 -1
- package/dist/proto/index.d.ts +0 -1
- package/dist/proto/index.js +0 -28
- package/dist/proto/index.js.map +0 -1
- package/dist/proto/stream.d.ts +0 -25
- package/dist/proto/stream.js +0 -3
- package/dist/proto/stream.js.map +0 -1
- package/dist/proto/stream.proto +0 -76
- package/dist/proto/testing.d.ts +0 -5
- package/dist/proto/testing.js +0 -24
- package/dist/proto/testing.js.map +0 -1
- package/dist/proto/v1alpha2.d.ts +0 -11
- package/dist/proto/v1alpha2.js +0 -15
- package/dist/proto/v1alpha2.js.map +0 -1
- package/dist/request.d.ts +0 -36
- package/dist/request.js +0 -58
- package/dist/request.js.map +0 -1
- package/dist/request.test.d.ts +0 -1
- package/dist/request.test.js +0 -28
- package/dist/request.test.js.map +0 -1
- package/src/cursor.test.ts +0 -21
- package/src/cursor.ts +0 -67
- package/src/proto/apibara/node/v1alpha2/Cursor.ts +0 -13
- package/src/proto/apibara/node/v1alpha2/Data.ts +0 -18
- package/src/proto/apibara/node/v1alpha2/DataFinality.ts +0 -20
- package/src/proto/apibara/node/v1alpha2/Heartbeat.ts +0 -8
- package/src/proto/apibara/node/v1alpha2/Invalidate.ts +0 -11
- package/src/proto/apibara/node/v1alpha2/Stream.ts +0 -23
- package/src/proto/apibara/node/v1alpha2/StreamDataRequest.ts +0 -27
- package/src/proto/apibara/node/v1alpha2/StreamDataResponse.ts +0 -22
- package/src/proto/stream.proto +0 -76
- package/src/proto/v1alpha2.ts +0 -24
- package/src/request.test.ts +0 -30
- package/src/request.ts +0 -64
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { createCursor, cursorFromProto, cursorToProto } from "./common";
|
|
3
|
+
|
|
4
|
+
describe("Cursor", () => {
|
|
5
|
+
describe("proto", () => {
|
|
6
|
+
it("should encode and decode (with uniqueKey)", () => {
|
|
7
|
+
const cursor = createCursor({
|
|
8
|
+
orderKey: 123n,
|
|
9
|
+
uniqueKey: "0xcafecafe",
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const proto = cursorToProto(cursor);
|
|
13
|
+
expect(proto).toMatchInlineSnapshot(`
|
|
14
|
+
{
|
|
15
|
+
"orderKey": 123n,
|
|
16
|
+
"uniqueKey": Uint8Array [
|
|
17
|
+
202,
|
|
18
|
+
254,
|
|
19
|
+
202,
|
|
20
|
+
254,
|
|
21
|
+
],
|
|
22
|
+
}
|
|
23
|
+
`);
|
|
24
|
+
const back = cursorFromProto(proto);
|
|
25
|
+
expect(back).toEqual(cursor);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should encode and decode (without uniqueKey)", () => {
|
|
29
|
+
const cursor = createCursor({
|
|
30
|
+
orderKey: 123n,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const proto = cursorToProto(cursor);
|
|
34
|
+
expect(proto).toMatchInlineSnapshot(`
|
|
35
|
+
{
|
|
36
|
+
"orderKey": 123n,
|
|
37
|
+
"uniqueKey": Uint8Array [],
|
|
38
|
+
}
|
|
39
|
+
`);
|
|
40
|
+
const back = cursorFromProto(proto);
|
|
41
|
+
expect(back).toEqual(cursor);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("bytes", () => {
|
|
46
|
+
it("should encode and decode (with uniqueKey)", () => {
|
|
47
|
+
const cursor = createCursor({
|
|
48
|
+
orderKey: 123n,
|
|
49
|
+
uniqueKey: "0xcafecafe",
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const proto = cursorToProto(cursor);
|
|
53
|
+
const back = cursorFromProto(proto);
|
|
54
|
+
expect(back).toEqual(cursor);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("should encode and decode (without uniqueKey)", () => {
|
|
58
|
+
const cursor = createCursor({
|
|
59
|
+
orderKey: 123n,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const proto = cursorToProto(cursor);
|
|
63
|
+
const back = cursorFromProto(proto);
|
|
64
|
+
expect(back).toEqual(cursor);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
package/src/common.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Schema } from "@effect/schema";
|
|
2
|
+
import { Option } from "effect";
|
|
3
|
+
import { hexToBytes, toHex } from "viem";
|
|
4
|
+
|
|
5
|
+
import * as proto from "./proto";
|
|
6
|
+
|
|
7
|
+
/** Bytes encoded as a 0x-prefixed hex string. */
|
|
8
|
+
export const Bytes = Schema.TemplateLiteral(
|
|
9
|
+
Schema.Literal("0x"),
|
|
10
|
+
Schema.String,
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export type Bytes = typeof Bytes.Type;
|
|
14
|
+
|
|
15
|
+
export const BytesFromUint8Array = Schema.requiredToOptional(
|
|
16
|
+
Schema.Uint8ArrayFromSelf,
|
|
17
|
+
Bytes,
|
|
18
|
+
{
|
|
19
|
+
decode(value) {
|
|
20
|
+
if (value.length === 0) {
|
|
21
|
+
return Option.none();
|
|
22
|
+
}
|
|
23
|
+
return Option.some(toHex(value));
|
|
24
|
+
},
|
|
25
|
+
encode(value) {
|
|
26
|
+
return value.pipe(
|
|
27
|
+
Option.map(hexToBytes),
|
|
28
|
+
Option.getOrElse(() => new Uint8Array(0)),
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
/** Represent a position in the stream. */
|
|
35
|
+
export const _Cursor = Schema.Struct({
|
|
36
|
+
/** The block number. */
|
|
37
|
+
orderKey: Schema.BigIntFromSelf,
|
|
38
|
+
/** The block hash, if any. */
|
|
39
|
+
uniqueKey: BytesFromUint8Array,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/** The Cursor protobuf representation. */
|
|
43
|
+
export interface CursorProto extends Schema.Schema.Encoded<typeof _Cursor> {}
|
|
44
|
+
export interface Cursor extends Schema.Schema.Type<typeof _Cursor> {}
|
|
45
|
+
export const Cursor: Schema.Schema<Cursor, CursorProto> = _Cursor;
|
|
46
|
+
export const createCursor = (props: Cursor) => props;
|
|
47
|
+
|
|
48
|
+
export const cursorToProto = Schema.encodeSync(Cursor);
|
|
49
|
+
export const cursorFromProto = Schema.decodeSync(Cursor);
|
|
50
|
+
|
|
51
|
+
export const CursorFromBytes = Schema.transform(
|
|
52
|
+
Schema.Uint8ArrayFromSelf,
|
|
53
|
+
Cursor,
|
|
54
|
+
{
|
|
55
|
+
decode(value) {
|
|
56
|
+
return proto.common.Cursor.decode(value);
|
|
57
|
+
},
|
|
58
|
+
encode(value) {
|
|
59
|
+
return proto.common.Cursor.encode(value).finish();
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
export const cursorToBytes = Schema.encodeSync(CursorFromBytes);
|
|
65
|
+
export const cursorFromBytes = Schema.decodeSync(CursorFromBytes);
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Schema } from "@effect/schema";
|
|
2
|
+
|
|
3
|
+
import { StreamDataRequest, StreamDataResponse } from "./stream";
|
|
4
|
+
|
|
5
|
+
/** Configure a DNA stream. */
|
|
6
|
+
export class StreamConfig<TFilter, TBlock> {
|
|
7
|
+
private request;
|
|
8
|
+
private response;
|
|
9
|
+
|
|
10
|
+
constructor(
|
|
11
|
+
private filter: Schema.Schema<TFilter, Uint8Array, never>,
|
|
12
|
+
private block: Schema.Schema<TBlock | null, Uint8Array, never>,
|
|
13
|
+
public mergeFilter: (a: TFilter, b: TFilter) => TFilter,
|
|
14
|
+
) {
|
|
15
|
+
this.request = StreamDataRequest(this.filter);
|
|
16
|
+
this.response = StreamDataResponse(this.block);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Filter schema. */
|
|
20
|
+
get Filter() {
|
|
21
|
+
return this.filter;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Block schema. */
|
|
25
|
+
get Block() {
|
|
26
|
+
return this.block;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Stream data request schema. */
|
|
30
|
+
get Request() {
|
|
31
|
+
return this.request;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Stream data response schema. */
|
|
35
|
+
get Response() {
|
|
36
|
+
return this.response;
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
export * from "./proto";
|
|
1
|
+
export * as proto from "./proto";
|
|
2
|
+
export { type DnaStreamClient, DnaStreamDefinition } from "./proto/stream";
|
|
3
|
+
|
|
4
|
+
export * from "./common";
|
|
5
|
+
export * from "./status";
|
|
6
|
+
export * from "./stream";
|
|
7
|
+
|
|
8
|
+
export * from "./config";
|
|
2
9
|
export * from "./client";
|
|
3
|
-
|
|
4
|
-
export * from "./
|
|
10
|
+
|
|
11
|
+
export * from "./rate";
|
|
@@ -0,0 +1,279 @@
|
|
|
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: common.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import Long from "long";
|
|
9
|
+
import _m0 from "protobufjs/minimal";
|
|
10
|
+
|
|
11
|
+
export const protobufPackage = "dna.v2.common";
|
|
12
|
+
|
|
13
|
+
/** A cursor over the stream content. */
|
|
14
|
+
export interface Cursor {
|
|
15
|
+
/** Key used for ordering messages in the stream. */
|
|
16
|
+
readonly orderKey: bigint;
|
|
17
|
+
/** Key used to discriminate branches in the stream. */
|
|
18
|
+
readonly uniqueKey: Uint8Array;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Request for the `Status` method. */
|
|
22
|
+
export interface StatusRequest {
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Response for the `Status` method. */
|
|
26
|
+
export interface StatusResponse {
|
|
27
|
+
/** The current head of the chain. */
|
|
28
|
+
readonly currentHead?:
|
|
29
|
+
| Cursor
|
|
30
|
+
| undefined;
|
|
31
|
+
/** The last cursor that was ingested by the node. */
|
|
32
|
+
readonly lastIngested?: Cursor | undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function createBaseCursor(): Cursor {
|
|
36
|
+
return { orderKey: BigInt("0"), uniqueKey: new Uint8Array(0) };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const Cursor = {
|
|
40
|
+
encode(message: Cursor, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
41
|
+
if (message.orderKey !== BigInt("0")) {
|
|
42
|
+
if (BigInt.asUintN(64, message.orderKey) !== message.orderKey) {
|
|
43
|
+
throw new globalThis.Error("value provided for field message.orderKey of type uint64 too large");
|
|
44
|
+
}
|
|
45
|
+
writer.uint32(8).uint64(message.orderKey.toString());
|
|
46
|
+
}
|
|
47
|
+
if (message.uniqueKey.length !== 0) {
|
|
48
|
+
writer.uint32(18).bytes(message.uniqueKey);
|
|
49
|
+
}
|
|
50
|
+
return writer;
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): Cursor {
|
|
54
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
55
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
56
|
+
const message = createBaseCursor() as any;
|
|
57
|
+
while (reader.pos < end) {
|
|
58
|
+
const tag = reader.uint32();
|
|
59
|
+
switch (tag >>> 3) {
|
|
60
|
+
case 1:
|
|
61
|
+
if (tag !== 8) {
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
message.orderKey = longToBigint(reader.uint64() as Long);
|
|
66
|
+
continue;
|
|
67
|
+
case 2:
|
|
68
|
+
if (tag !== 18) {
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
message.uniqueKey = reader.bytes();
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
reader.skipType(tag & 7);
|
|
79
|
+
}
|
|
80
|
+
return message;
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
fromJSON(object: any): Cursor {
|
|
84
|
+
return {
|
|
85
|
+
orderKey: isSet(object.orderKey) ? BigInt(object.orderKey) : BigInt("0"),
|
|
86
|
+
uniqueKey: isSet(object.uniqueKey) ? bytesFromBase64(object.uniqueKey) : new Uint8Array(0),
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
toJSON(message: Cursor): unknown {
|
|
91
|
+
const obj: any = {};
|
|
92
|
+
if (message.orderKey !== BigInt("0")) {
|
|
93
|
+
obj.orderKey = message.orderKey.toString();
|
|
94
|
+
}
|
|
95
|
+
if (message.uniqueKey.length !== 0) {
|
|
96
|
+
obj.uniqueKey = base64FromBytes(message.uniqueKey);
|
|
97
|
+
}
|
|
98
|
+
return obj;
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
create(base?: DeepPartial<Cursor>): Cursor {
|
|
102
|
+
return Cursor.fromPartial(base ?? {});
|
|
103
|
+
},
|
|
104
|
+
fromPartial(object: DeepPartial<Cursor>): Cursor {
|
|
105
|
+
const message = createBaseCursor() as any;
|
|
106
|
+
message.orderKey = object.orderKey ?? BigInt("0");
|
|
107
|
+
message.uniqueKey = object.uniqueKey ?? new Uint8Array(0);
|
|
108
|
+
return message;
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
function createBaseStatusRequest(): StatusRequest {
|
|
113
|
+
return {};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const StatusRequest = {
|
|
117
|
+
encode(_: StatusRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
118
|
+
return writer;
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): StatusRequest {
|
|
122
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
123
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
124
|
+
const message = createBaseStatusRequest() as any;
|
|
125
|
+
while (reader.pos < end) {
|
|
126
|
+
const tag = reader.uint32();
|
|
127
|
+
switch (tag >>> 3) {
|
|
128
|
+
}
|
|
129
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
reader.skipType(tag & 7);
|
|
133
|
+
}
|
|
134
|
+
return message;
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
fromJSON(_: any): StatusRequest {
|
|
138
|
+
return {};
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
toJSON(_: StatusRequest): unknown {
|
|
142
|
+
const obj: any = {};
|
|
143
|
+
return obj;
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
create(base?: DeepPartial<StatusRequest>): StatusRequest {
|
|
147
|
+
return StatusRequest.fromPartial(base ?? {});
|
|
148
|
+
},
|
|
149
|
+
fromPartial(_: DeepPartial<StatusRequest>): StatusRequest {
|
|
150
|
+
const message = createBaseStatusRequest() as any;
|
|
151
|
+
return message;
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
function createBaseStatusResponse(): StatusResponse {
|
|
156
|
+
return { currentHead: undefined, lastIngested: undefined };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export const StatusResponse = {
|
|
160
|
+
encode(message: StatusResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
161
|
+
if (message.currentHead !== undefined) {
|
|
162
|
+
Cursor.encode(message.currentHead, writer.uint32(10).fork()).ldelim();
|
|
163
|
+
}
|
|
164
|
+
if (message.lastIngested !== undefined) {
|
|
165
|
+
Cursor.encode(message.lastIngested, writer.uint32(18).fork()).ldelim();
|
|
166
|
+
}
|
|
167
|
+
return writer;
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): StatusResponse {
|
|
171
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
172
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
173
|
+
const message = createBaseStatusResponse() as any;
|
|
174
|
+
while (reader.pos < end) {
|
|
175
|
+
const tag = reader.uint32();
|
|
176
|
+
switch (tag >>> 3) {
|
|
177
|
+
case 1:
|
|
178
|
+
if (tag !== 10) {
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
message.currentHead = Cursor.decode(reader, reader.uint32());
|
|
183
|
+
continue;
|
|
184
|
+
case 2:
|
|
185
|
+
if (tag !== 18) {
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
message.lastIngested = Cursor.decode(reader, reader.uint32());
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
reader.skipType(tag & 7);
|
|
196
|
+
}
|
|
197
|
+
return message;
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
fromJSON(object: any): StatusResponse {
|
|
201
|
+
return {
|
|
202
|
+
currentHead: isSet(object.currentHead) ? Cursor.fromJSON(object.currentHead) : undefined,
|
|
203
|
+
lastIngested: isSet(object.lastIngested) ? Cursor.fromJSON(object.lastIngested) : undefined,
|
|
204
|
+
};
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
toJSON(message: StatusResponse): unknown {
|
|
208
|
+
const obj: any = {};
|
|
209
|
+
if (message.currentHead !== undefined) {
|
|
210
|
+
obj.currentHead = Cursor.toJSON(message.currentHead);
|
|
211
|
+
}
|
|
212
|
+
if (message.lastIngested !== undefined) {
|
|
213
|
+
obj.lastIngested = Cursor.toJSON(message.lastIngested);
|
|
214
|
+
}
|
|
215
|
+
return obj;
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
create(base?: DeepPartial<StatusResponse>): StatusResponse {
|
|
219
|
+
return StatusResponse.fromPartial(base ?? {});
|
|
220
|
+
},
|
|
221
|
+
fromPartial(object: DeepPartial<StatusResponse>): StatusResponse {
|
|
222
|
+
const message = createBaseStatusResponse() as any;
|
|
223
|
+
message.currentHead = (object.currentHead !== undefined && object.currentHead !== null)
|
|
224
|
+
? Cursor.fromPartial(object.currentHead)
|
|
225
|
+
: undefined;
|
|
226
|
+
message.lastIngested = (object.lastIngested !== undefined && object.lastIngested !== null)
|
|
227
|
+
? Cursor.fromPartial(object.lastIngested)
|
|
228
|
+
: undefined;
|
|
229
|
+
return message;
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
function bytesFromBase64(b64: string): Uint8Array {
|
|
234
|
+
if ((globalThis as any).Buffer) {
|
|
235
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
236
|
+
} else {
|
|
237
|
+
const bin = globalThis.atob(b64);
|
|
238
|
+
const arr = new Uint8Array(bin.length);
|
|
239
|
+
for (let i = 0; i < bin.length; ++i) {
|
|
240
|
+
arr[i] = bin.charCodeAt(i);
|
|
241
|
+
}
|
|
242
|
+
return arr;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function base64FromBytes(arr: Uint8Array): string {
|
|
247
|
+
if ((globalThis as any).Buffer) {
|
|
248
|
+
return globalThis.Buffer.from(arr).toString("base64");
|
|
249
|
+
} else {
|
|
250
|
+
const bin: string[] = [];
|
|
251
|
+
arr.forEach((byte) => {
|
|
252
|
+
bin.push(globalThis.String.fromCharCode(byte));
|
|
253
|
+
});
|
|
254
|
+
return globalThis.btoa(bin.join(""));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
|
|
259
|
+
|
|
260
|
+
export type DeepPartial<T> = T extends Builtin ? T
|
|
261
|
+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
|
262
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
263
|
+
: T extends { readonly $case: string }
|
|
264
|
+
? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { readonly $case: T["$case"] }
|
|
265
|
+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
266
|
+
: Partial<T>;
|
|
267
|
+
|
|
268
|
+
function longToBigint(long: Long) {
|
|
269
|
+
return BigInt(long.toString());
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (_m0.util.Long !== Long) {
|
|
273
|
+
_m0.util.Long = Long as any;
|
|
274
|
+
_m0.configure();
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function isSet(value: any): boolean {
|
|
278
|
+
return value !== null && value !== undefined;
|
|
279
|
+
}
|
package/src/proto/index.ts
CHANGED