@kronos-ts/kronosdb 0.1.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/dist/connection.d.ts +86 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +133 -0
- package/dist/connection.js.map +1 -0
- package/dist/errors.d.ts +72 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +149 -0
- package/dist/errors.js.map +1 -0
- package/dist/event-processor-info.d.ts +32 -0
- package/dist/event-processor-info.d.ts.map +1 -0
- package/dist/event-processor-info.js +24 -0
- package/dist/event-processor-info.js.map +1 -0
- package/dist/flow-controlled-sender.d.ts +12 -0
- package/dist/flow-controlled-sender.d.ts.map +1 -0
- package/dist/flow-controlled-sender.js +53 -0
- package/dist/flow-controlled-sender.js.map +1 -0
- package/dist/generated/command.d.ts +169 -0
- package/dist/generated/command.d.ts.map +1 -0
- package/dist/generated/command.js +964 -0
- package/dist/generated/command.js.map +1 -0
- package/dist/generated/common.d.ts +76 -0
- package/dist/generated/common.d.ts.map +1 -0
- package/dist/generated/common.js +648 -0
- package/dist/generated/common.js.map +1 -0
- package/dist/generated/eventstore.d.ts +337 -0
- package/dist/generated/eventstore.d.ts.map +1 -0
- package/dist/generated/eventstore.js +1757 -0
- package/dist/generated/eventstore.js.map +1 -0
- package/dist/generated/platform.d.ts +242 -0
- package/dist/generated/platform.d.ts.map +1 -0
- package/dist/generated/platform.js +1525 -0
- package/dist/generated/platform.js.map +1 -0
- package/dist/generated/query.d.ts +265 -0
- package/dist/generated/query.d.ts.map +1 -0
- package/dist/generated/query.js +2114 -0
- package/dist/generated/query.js.map +1 -0
- package/dist/generated/snapshot.d.ts +180 -0
- package/dist/generated/snapshot.d.ts.map +1 -0
- package/dist/generated/snapshot.js +861 -0
- package/dist/generated/snapshot.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/kronosdb-event-store.d.ts +17 -0
- package/dist/kronosdb-event-store.d.ts.map +1 -0
- package/dist/kronosdb-event-store.js +328 -0
- package/dist/kronosdb-event-store.js.map +1 -0
- package/dist/kronosdb-snapshot-store.d.ts +10 -0
- package/dist/kronosdb-snapshot-store.d.ts.map +1 -0
- package/dist/kronosdb-snapshot-store.js +79 -0
- package/dist/kronosdb-snapshot-store.js.map +1 -0
- package/dist/kronosdb.d.ts +53 -0
- package/dist/kronosdb.d.ts.map +1 -0
- package/dist/kronosdb.js +852 -0
- package/dist/kronosdb.js.map +1 -0
- package/dist/metadata-conversion.d.ts +37 -0
- package/dist/metadata-conversion.d.ts.map +1 -0
- package/dist/metadata-conversion.js +75 -0
- package/dist/metadata-conversion.js.map +1 -0
- package/dist/outbound-stream.d.ts +15 -0
- package/dist/outbound-stream.d.ts.map +1 -0
- package/dist/outbound-stream.js +39 -0
- package/dist/outbound-stream.js.map +1 -0
- package/dist/platform-service.d.ts +87 -0
- package/dist/platform-service.d.ts.map +1 -0
- package/dist/platform-service.js +218 -0
- package/dist/platform-service.js.map +1 -0
- package/dist/service-definitions.d.ts +187 -0
- package/dist/service-definitions.d.ts.map +1 -0
- package/dist/service-definitions.js +18 -0
- package/dist/service-definitions.js.map +1 -0
- package/dist/shutdown-latch.d.ts +18 -0
- package/dist/shutdown-latch.d.ts.map +1 -0
- package/dist/shutdown-latch.js +51 -0
- package/dist/shutdown-latch.js.map +1 -0
- package/package.json +69 -0
- package/src/connection.ts +235 -0
- package/src/errors.ts +173 -0
- package/src/event-processor-info.ts +53 -0
- package/src/flow-controlled-sender.ts +73 -0
- package/src/generated/command.ts +1226 -0
- package/src/generated/common.ts +770 -0
- package/src/generated/eventstore.ts +2241 -0
- package/src/generated/platform.ts +1914 -0
- package/src/generated/query.ts +2571 -0
- package/src/generated/snapshot.ts +1110 -0
- package/src/index.ts +87 -0
- package/src/kronosdb-event-store.ts +401 -0
- package/src/kronosdb-snapshot-store.ts +104 -0
- package/src/kronosdb.ts +1000 -0
- package/src/metadata-conversion.ts +85 -0
- package/src/outbound-stream.ts +52 -0
- package/src/platform-service.ts +297 -0
- package/src/service-definitions.ts +25 -0
- package/src/shutdown-latch.ts +74 -0
|
@@ -0,0 +1,1110 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.11.6
|
|
4
|
+
// protoc v3.19.1
|
|
5
|
+
// source: snapshot.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
9
|
+
import type { CallContext, CallOptions } from "nice-grpc-common";
|
|
10
|
+
|
|
11
|
+
export const protobufPackage = "kronosdb.snapshot";
|
|
12
|
+
|
|
13
|
+
/** A snapshot of projection/read model state at a point in the event stream. */
|
|
14
|
+
export interface Snapshot {
|
|
15
|
+
/** The name/type of the snapshot (e.g. "OrderSummaryProjection"). */
|
|
16
|
+
name: string;
|
|
17
|
+
/** The version of the serialized form. */
|
|
18
|
+
version: string;
|
|
19
|
+
/** The serialized payload (opaque bytes). */
|
|
20
|
+
payload: Uint8Array;
|
|
21
|
+
/** Timestamp of snapshot creation (millis since epoch). */
|
|
22
|
+
timestamp: bigint;
|
|
23
|
+
/** Arbitrary key-value metadata. */
|
|
24
|
+
metadata: { [key: string]: string };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface Snapshot_MetadataEntry {
|
|
28
|
+
key: string;
|
|
29
|
+
value: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Request to store a snapshot. */
|
|
33
|
+
export interface AddSnapshotRequest {
|
|
34
|
+
/** The key identifying this snapshot (opaque bytes, typically entity type + NUL + entity ID). */
|
|
35
|
+
key: Uint8Array;
|
|
36
|
+
/** The event store sequence/position up to which this snapshot was taken. */
|
|
37
|
+
sequence: bigint;
|
|
38
|
+
/** If true, older snapshots for the same key are pruned after storing. */
|
|
39
|
+
prune: boolean;
|
|
40
|
+
/** The snapshot data. */
|
|
41
|
+
snapshot: Snapshot | undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Response confirming the snapshot was stored. */
|
|
45
|
+
export interface AddSnapshotResponse {
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Request to delete snapshots for a key.
|
|
50
|
+
* Deletes all snapshots with sequence in [0, to_sequence).
|
|
51
|
+
*/
|
|
52
|
+
export interface DeleteSnapshotsRequest {
|
|
53
|
+
/** The key identifying the snapshots. */
|
|
54
|
+
key: Uint8Array;
|
|
55
|
+
/** Exclusive upper bound sequence for deletion. */
|
|
56
|
+
toSequence: bigint;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Response confirming deletion. */
|
|
60
|
+
export interface DeleteSnapshotsResponse {
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Request to list snapshots for a key within a sequence range. */
|
|
64
|
+
export interface ListSnapshotsRequest {
|
|
65
|
+
/** The key identifying the snapshots. */
|
|
66
|
+
key: Uint8Array;
|
|
67
|
+
/** Inclusive lower bound sequence. */
|
|
68
|
+
fromSequence: bigint;
|
|
69
|
+
/** Exclusive upper bound sequence. */
|
|
70
|
+
toSequence: bigint;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** A snapshot entry in a list response. */
|
|
74
|
+
export interface ListSnapshotsResponse {
|
|
75
|
+
/** The key. */
|
|
76
|
+
key: Uint8Array;
|
|
77
|
+
/** The sequence. */
|
|
78
|
+
sequence: bigint;
|
|
79
|
+
/** The snapshot data. */
|
|
80
|
+
snapshot: Snapshot | undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Request to get the latest snapshot for a key. */
|
|
84
|
+
export interface GetLastSnapshotRequest {
|
|
85
|
+
/** The key identifying the snapshot. */
|
|
86
|
+
key: Uint8Array;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The latest snapshot for a key, or empty fields if none exists. */
|
|
90
|
+
export interface GetLastSnapshotResponse {
|
|
91
|
+
/** The key. */
|
|
92
|
+
key: Uint8Array;
|
|
93
|
+
/** The sequence of the latest snapshot. */
|
|
94
|
+
sequence: bigint;
|
|
95
|
+
/** The snapshot data (absent if no snapshot exists). */
|
|
96
|
+
snapshot: Snapshot | undefined;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function createBaseSnapshot(): Snapshot {
|
|
100
|
+
return { name: "", version: "", payload: new Uint8Array(0), timestamp: 0n, metadata: {} };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const Snapshot: MessageFns<Snapshot> = {
|
|
104
|
+
encode(message: Snapshot, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
105
|
+
if (message.name !== "") {
|
|
106
|
+
writer.uint32(10).string(message.name);
|
|
107
|
+
}
|
|
108
|
+
if (message.version !== "") {
|
|
109
|
+
writer.uint32(18).string(message.version);
|
|
110
|
+
}
|
|
111
|
+
if (message.payload.length !== 0) {
|
|
112
|
+
writer.uint32(26).bytes(message.payload);
|
|
113
|
+
}
|
|
114
|
+
if (message.timestamp !== 0n) {
|
|
115
|
+
if (BigInt.asIntN(64, message.timestamp) !== message.timestamp) {
|
|
116
|
+
throw new globalThis.Error("value provided for field message.timestamp of type int64 too large");
|
|
117
|
+
}
|
|
118
|
+
writer.uint32(32).int64(message.timestamp);
|
|
119
|
+
}
|
|
120
|
+
globalThis.Object.entries(message.metadata).forEach(([key, value]: [string, string]) => {
|
|
121
|
+
Snapshot_MetadataEntry.encode({ key: key as any, value }, writer.uint32(42).fork()).join();
|
|
122
|
+
});
|
|
123
|
+
return writer;
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
decode(input: BinaryReader | Uint8Array, length?: number): Snapshot {
|
|
127
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
128
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
129
|
+
const message = createBaseSnapshot();
|
|
130
|
+
while (reader.pos < end) {
|
|
131
|
+
const tag = reader.uint32();
|
|
132
|
+
switch (tag >>> 3) {
|
|
133
|
+
case 1: {
|
|
134
|
+
if (tag !== 10) {
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
message.name = reader.string();
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
case 2: {
|
|
142
|
+
if (tag !== 18) {
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
message.version = reader.string();
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
case 3: {
|
|
150
|
+
if (tag !== 26) {
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
message.payload = reader.bytes();
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
case 4: {
|
|
158
|
+
if (tag !== 32) {
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
message.timestamp = reader.int64() as bigint;
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
case 5: {
|
|
166
|
+
if (tag !== 42) {
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const entry5 = Snapshot_MetadataEntry.decode(reader, reader.uint32());
|
|
171
|
+
if (entry5.value !== undefined) {
|
|
172
|
+
message.metadata[entry5.key] = entry5.value;
|
|
173
|
+
}
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
reader.skip(tag & 7);
|
|
181
|
+
}
|
|
182
|
+
return message;
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
fromJSON(object: any): Snapshot {
|
|
186
|
+
return {
|
|
187
|
+
name: isSet(object.name) ? globalThis.String(object.name) : "",
|
|
188
|
+
version: isSet(object.version) ? globalThis.String(object.version) : "",
|
|
189
|
+
payload: isSet(object.payload) ? bytesFromBase64(object.payload) : new Uint8Array(0),
|
|
190
|
+
timestamp: isSet(object.timestamp) ? BigInt(object.timestamp) : 0n,
|
|
191
|
+
metadata: isObject(object.metadata)
|
|
192
|
+
? (globalThis.Object.entries(object.metadata) as [string, any][]).reduce(
|
|
193
|
+
(acc: { [key: string]: string }, [key, value]: [string, any]) => {
|
|
194
|
+
acc[key] = globalThis.String(value);
|
|
195
|
+
return acc;
|
|
196
|
+
},
|
|
197
|
+
{},
|
|
198
|
+
)
|
|
199
|
+
: {},
|
|
200
|
+
};
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
toJSON(message: Snapshot): unknown {
|
|
204
|
+
const obj: any = {};
|
|
205
|
+
if (message.name !== "") {
|
|
206
|
+
obj.name = message.name;
|
|
207
|
+
}
|
|
208
|
+
if (message.version !== "") {
|
|
209
|
+
obj.version = message.version;
|
|
210
|
+
}
|
|
211
|
+
if (message.payload.length !== 0) {
|
|
212
|
+
obj.payload = base64FromBytes(message.payload);
|
|
213
|
+
}
|
|
214
|
+
if (message.timestamp !== 0n) {
|
|
215
|
+
obj.timestamp = message.timestamp.toString();
|
|
216
|
+
}
|
|
217
|
+
if (message.metadata) {
|
|
218
|
+
const entries = globalThis.Object.entries(message.metadata) as [string, string][];
|
|
219
|
+
if (entries.length > 0) {
|
|
220
|
+
obj.metadata = {};
|
|
221
|
+
entries.forEach(([k, v]) => {
|
|
222
|
+
obj.metadata[k] = v;
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return obj;
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
create(base?: DeepPartial<Snapshot>): Snapshot {
|
|
230
|
+
return Snapshot.fromPartial(base ?? {});
|
|
231
|
+
},
|
|
232
|
+
fromPartial(object: DeepPartial<Snapshot>): Snapshot {
|
|
233
|
+
const message = createBaseSnapshot();
|
|
234
|
+
message.name = object.name ?? "";
|
|
235
|
+
message.version = object.version ?? "";
|
|
236
|
+
message.payload = object.payload ?? new Uint8Array(0);
|
|
237
|
+
message.timestamp = object.timestamp ?? 0n;
|
|
238
|
+
message.metadata = (globalThis.Object.entries(object.metadata ?? {}) as [string, string][]).reduce(
|
|
239
|
+
(acc: { [key: string]: string }, [key, value]: [string, string]) => {
|
|
240
|
+
if (value !== undefined) {
|
|
241
|
+
acc[key] = globalThis.String(value);
|
|
242
|
+
}
|
|
243
|
+
return acc;
|
|
244
|
+
},
|
|
245
|
+
{},
|
|
246
|
+
);
|
|
247
|
+
return message;
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
function createBaseSnapshot_MetadataEntry(): Snapshot_MetadataEntry {
|
|
252
|
+
return { key: "", value: "" };
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export const Snapshot_MetadataEntry: MessageFns<Snapshot_MetadataEntry> = {
|
|
256
|
+
encode(message: Snapshot_MetadataEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
257
|
+
if (message.key !== "") {
|
|
258
|
+
writer.uint32(10).string(message.key);
|
|
259
|
+
}
|
|
260
|
+
if (message.value !== "") {
|
|
261
|
+
writer.uint32(18).string(message.value);
|
|
262
|
+
}
|
|
263
|
+
return writer;
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
decode(input: BinaryReader | Uint8Array, length?: number): Snapshot_MetadataEntry {
|
|
267
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
268
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
269
|
+
const message = createBaseSnapshot_MetadataEntry();
|
|
270
|
+
while (reader.pos < end) {
|
|
271
|
+
const tag = reader.uint32();
|
|
272
|
+
switch (tag >>> 3) {
|
|
273
|
+
case 1: {
|
|
274
|
+
if (tag !== 10) {
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
message.key = reader.string();
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
case 2: {
|
|
282
|
+
if (tag !== 18) {
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
message.value = reader.string();
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
reader.skip(tag & 7);
|
|
294
|
+
}
|
|
295
|
+
return message;
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
fromJSON(object: any): Snapshot_MetadataEntry {
|
|
299
|
+
return {
|
|
300
|
+
key: isSet(object.key) ? globalThis.String(object.key) : "",
|
|
301
|
+
value: isSet(object.value) ? globalThis.String(object.value) : "",
|
|
302
|
+
};
|
|
303
|
+
},
|
|
304
|
+
|
|
305
|
+
toJSON(message: Snapshot_MetadataEntry): unknown {
|
|
306
|
+
const obj: any = {};
|
|
307
|
+
if (message.key !== "") {
|
|
308
|
+
obj.key = message.key;
|
|
309
|
+
}
|
|
310
|
+
if (message.value !== "") {
|
|
311
|
+
obj.value = message.value;
|
|
312
|
+
}
|
|
313
|
+
return obj;
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
create(base?: DeepPartial<Snapshot_MetadataEntry>): Snapshot_MetadataEntry {
|
|
317
|
+
return Snapshot_MetadataEntry.fromPartial(base ?? {});
|
|
318
|
+
},
|
|
319
|
+
fromPartial(object: DeepPartial<Snapshot_MetadataEntry>): Snapshot_MetadataEntry {
|
|
320
|
+
const message = createBaseSnapshot_MetadataEntry();
|
|
321
|
+
message.key = object.key ?? "";
|
|
322
|
+
message.value = object.value ?? "";
|
|
323
|
+
return message;
|
|
324
|
+
},
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
function createBaseAddSnapshotRequest(): AddSnapshotRequest {
|
|
328
|
+
return { key: new Uint8Array(0), sequence: 0n, prune: false, snapshot: undefined };
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export const AddSnapshotRequest: MessageFns<AddSnapshotRequest> = {
|
|
332
|
+
encode(message: AddSnapshotRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
333
|
+
if (message.key.length !== 0) {
|
|
334
|
+
writer.uint32(10).bytes(message.key);
|
|
335
|
+
}
|
|
336
|
+
if (message.sequence !== 0n) {
|
|
337
|
+
if (BigInt.asIntN(64, message.sequence) !== message.sequence) {
|
|
338
|
+
throw new globalThis.Error("value provided for field message.sequence of type int64 too large");
|
|
339
|
+
}
|
|
340
|
+
writer.uint32(16).int64(message.sequence);
|
|
341
|
+
}
|
|
342
|
+
if (message.prune !== false) {
|
|
343
|
+
writer.uint32(24).bool(message.prune);
|
|
344
|
+
}
|
|
345
|
+
if (message.snapshot !== undefined) {
|
|
346
|
+
Snapshot.encode(message.snapshot, writer.uint32(34).fork()).join();
|
|
347
|
+
}
|
|
348
|
+
return writer;
|
|
349
|
+
},
|
|
350
|
+
|
|
351
|
+
decode(input: BinaryReader | Uint8Array, length?: number): AddSnapshotRequest {
|
|
352
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
353
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
354
|
+
const message = createBaseAddSnapshotRequest();
|
|
355
|
+
while (reader.pos < end) {
|
|
356
|
+
const tag = reader.uint32();
|
|
357
|
+
switch (tag >>> 3) {
|
|
358
|
+
case 1: {
|
|
359
|
+
if (tag !== 10) {
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
message.key = reader.bytes();
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
case 2: {
|
|
367
|
+
if (tag !== 16) {
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
message.sequence = reader.int64() as bigint;
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
case 3: {
|
|
375
|
+
if (tag !== 24) {
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
message.prune = reader.bool();
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
case 4: {
|
|
383
|
+
if (tag !== 34) {
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
message.snapshot = Snapshot.decode(reader, reader.uint32());
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
reader.skip(tag & 7);
|
|
395
|
+
}
|
|
396
|
+
return message;
|
|
397
|
+
},
|
|
398
|
+
|
|
399
|
+
fromJSON(object: any): AddSnapshotRequest {
|
|
400
|
+
return {
|
|
401
|
+
key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(0),
|
|
402
|
+
sequence: isSet(object.sequence) ? BigInt(object.sequence) : 0n,
|
|
403
|
+
prune: isSet(object.prune) ? globalThis.Boolean(object.prune) : false,
|
|
404
|
+
snapshot: isSet(object.snapshot) ? Snapshot.fromJSON(object.snapshot) : undefined,
|
|
405
|
+
};
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
toJSON(message: AddSnapshotRequest): unknown {
|
|
409
|
+
const obj: any = {};
|
|
410
|
+
if (message.key.length !== 0) {
|
|
411
|
+
obj.key = base64FromBytes(message.key);
|
|
412
|
+
}
|
|
413
|
+
if (message.sequence !== 0n) {
|
|
414
|
+
obj.sequence = message.sequence.toString();
|
|
415
|
+
}
|
|
416
|
+
if (message.prune !== false) {
|
|
417
|
+
obj.prune = message.prune;
|
|
418
|
+
}
|
|
419
|
+
if (message.snapshot !== undefined) {
|
|
420
|
+
obj.snapshot = Snapshot.toJSON(message.snapshot);
|
|
421
|
+
}
|
|
422
|
+
return obj;
|
|
423
|
+
},
|
|
424
|
+
|
|
425
|
+
create(base?: DeepPartial<AddSnapshotRequest>): AddSnapshotRequest {
|
|
426
|
+
return AddSnapshotRequest.fromPartial(base ?? {});
|
|
427
|
+
},
|
|
428
|
+
fromPartial(object: DeepPartial<AddSnapshotRequest>): AddSnapshotRequest {
|
|
429
|
+
const message = createBaseAddSnapshotRequest();
|
|
430
|
+
message.key = object.key ?? new Uint8Array(0);
|
|
431
|
+
message.sequence = object.sequence ?? 0n;
|
|
432
|
+
message.prune = object.prune ?? false;
|
|
433
|
+
message.snapshot = (object.snapshot !== undefined && object.snapshot !== null)
|
|
434
|
+
? Snapshot.fromPartial(object.snapshot)
|
|
435
|
+
: undefined;
|
|
436
|
+
return message;
|
|
437
|
+
},
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
function createBaseAddSnapshotResponse(): AddSnapshotResponse {
|
|
441
|
+
return {};
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
export const AddSnapshotResponse: MessageFns<AddSnapshotResponse> = {
|
|
445
|
+
encode(_: AddSnapshotResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
446
|
+
return writer;
|
|
447
|
+
},
|
|
448
|
+
|
|
449
|
+
decode(input: BinaryReader | Uint8Array, length?: number): AddSnapshotResponse {
|
|
450
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
451
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
452
|
+
const message = createBaseAddSnapshotResponse();
|
|
453
|
+
while (reader.pos < end) {
|
|
454
|
+
const tag = reader.uint32();
|
|
455
|
+
switch (tag >>> 3) {
|
|
456
|
+
}
|
|
457
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
reader.skip(tag & 7);
|
|
461
|
+
}
|
|
462
|
+
return message;
|
|
463
|
+
},
|
|
464
|
+
|
|
465
|
+
fromJSON(_: any): AddSnapshotResponse {
|
|
466
|
+
return {};
|
|
467
|
+
},
|
|
468
|
+
|
|
469
|
+
toJSON(_: AddSnapshotResponse): unknown {
|
|
470
|
+
const obj: any = {};
|
|
471
|
+
return obj;
|
|
472
|
+
},
|
|
473
|
+
|
|
474
|
+
create(base?: DeepPartial<AddSnapshotResponse>): AddSnapshotResponse {
|
|
475
|
+
return AddSnapshotResponse.fromPartial(base ?? {});
|
|
476
|
+
},
|
|
477
|
+
fromPartial(_: DeepPartial<AddSnapshotResponse>): AddSnapshotResponse {
|
|
478
|
+
const message = createBaseAddSnapshotResponse();
|
|
479
|
+
return message;
|
|
480
|
+
},
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
function createBaseDeleteSnapshotsRequest(): DeleteSnapshotsRequest {
|
|
484
|
+
return { key: new Uint8Array(0), toSequence: 0n };
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
export const DeleteSnapshotsRequest: MessageFns<DeleteSnapshotsRequest> = {
|
|
488
|
+
encode(message: DeleteSnapshotsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
489
|
+
if (message.key.length !== 0) {
|
|
490
|
+
writer.uint32(10).bytes(message.key);
|
|
491
|
+
}
|
|
492
|
+
if (message.toSequence !== 0n) {
|
|
493
|
+
if (BigInt.asIntN(64, message.toSequence) !== message.toSequence) {
|
|
494
|
+
throw new globalThis.Error("value provided for field message.toSequence of type int64 too large");
|
|
495
|
+
}
|
|
496
|
+
writer.uint32(24).int64(message.toSequence);
|
|
497
|
+
}
|
|
498
|
+
return writer;
|
|
499
|
+
},
|
|
500
|
+
|
|
501
|
+
decode(input: BinaryReader | Uint8Array, length?: number): DeleteSnapshotsRequest {
|
|
502
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
503
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
504
|
+
const message = createBaseDeleteSnapshotsRequest();
|
|
505
|
+
while (reader.pos < end) {
|
|
506
|
+
const tag = reader.uint32();
|
|
507
|
+
switch (tag >>> 3) {
|
|
508
|
+
case 1: {
|
|
509
|
+
if (tag !== 10) {
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
message.key = reader.bytes();
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
case 3: {
|
|
517
|
+
if (tag !== 24) {
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
message.toSequence = reader.int64() as bigint;
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
526
|
+
break;
|
|
527
|
+
}
|
|
528
|
+
reader.skip(tag & 7);
|
|
529
|
+
}
|
|
530
|
+
return message;
|
|
531
|
+
},
|
|
532
|
+
|
|
533
|
+
fromJSON(object: any): DeleteSnapshotsRequest {
|
|
534
|
+
return {
|
|
535
|
+
key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(0),
|
|
536
|
+
toSequence: isSet(object.toSequence)
|
|
537
|
+
? BigInt(object.toSequence)
|
|
538
|
+
: isSet(object.to_sequence)
|
|
539
|
+
? BigInt(object.to_sequence)
|
|
540
|
+
: 0n,
|
|
541
|
+
};
|
|
542
|
+
},
|
|
543
|
+
|
|
544
|
+
toJSON(message: DeleteSnapshotsRequest): unknown {
|
|
545
|
+
const obj: any = {};
|
|
546
|
+
if (message.key.length !== 0) {
|
|
547
|
+
obj.key = base64FromBytes(message.key);
|
|
548
|
+
}
|
|
549
|
+
if (message.toSequence !== 0n) {
|
|
550
|
+
obj.toSequence = message.toSequence.toString();
|
|
551
|
+
}
|
|
552
|
+
return obj;
|
|
553
|
+
},
|
|
554
|
+
|
|
555
|
+
create(base?: DeepPartial<DeleteSnapshotsRequest>): DeleteSnapshotsRequest {
|
|
556
|
+
return DeleteSnapshotsRequest.fromPartial(base ?? {});
|
|
557
|
+
},
|
|
558
|
+
fromPartial(object: DeepPartial<DeleteSnapshotsRequest>): DeleteSnapshotsRequest {
|
|
559
|
+
const message = createBaseDeleteSnapshotsRequest();
|
|
560
|
+
message.key = object.key ?? new Uint8Array(0);
|
|
561
|
+
message.toSequence = object.toSequence ?? 0n;
|
|
562
|
+
return message;
|
|
563
|
+
},
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
function createBaseDeleteSnapshotsResponse(): DeleteSnapshotsResponse {
|
|
567
|
+
return {};
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
export const DeleteSnapshotsResponse: MessageFns<DeleteSnapshotsResponse> = {
|
|
571
|
+
encode(_: DeleteSnapshotsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
572
|
+
return writer;
|
|
573
|
+
},
|
|
574
|
+
|
|
575
|
+
decode(input: BinaryReader | Uint8Array, length?: number): DeleteSnapshotsResponse {
|
|
576
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
577
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
578
|
+
const message = createBaseDeleteSnapshotsResponse();
|
|
579
|
+
while (reader.pos < end) {
|
|
580
|
+
const tag = reader.uint32();
|
|
581
|
+
switch (tag >>> 3) {
|
|
582
|
+
}
|
|
583
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
reader.skip(tag & 7);
|
|
587
|
+
}
|
|
588
|
+
return message;
|
|
589
|
+
},
|
|
590
|
+
|
|
591
|
+
fromJSON(_: any): DeleteSnapshotsResponse {
|
|
592
|
+
return {};
|
|
593
|
+
},
|
|
594
|
+
|
|
595
|
+
toJSON(_: DeleteSnapshotsResponse): unknown {
|
|
596
|
+
const obj: any = {};
|
|
597
|
+
return obj;
|
|
598
|
+
},
|
|
599
|
+
|
|
600
|
+
create(base?: DeepPartial<DeleteSnapshotsResponse>): DeleteSnapshotsResponse {
|
|
601
|
+
return DeleteSnapshotsResponse.fromPartial(base ?? {});
|
|
602
|
+
},
|
|
603
|
+
fromPartial(_: DeepPartial<DeleteSnapshotsResponse>): DeleteSnapshotsResponse {
|
|
604
|
+
const message = createBaseDeleteSnapshotsResponse();
|
|
605
|
+
return message;
|
|
606
|
+
},
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
function createBaseListSnapshotsRequest(): ListSnapshotsRequest {
|
|
610
|
+
return { key: new Uint8Array(0), fromSequence: 0n, toSequence: 0n };
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
export const ListSnapshotsRequest: MessageFns<ListSnapshotsRequest> = {
|
|
614
|
+
encode(message: ListSnapshotsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
615
|
+
if (message.key.length !== 0) {
|
|
616
|
+
writer.uint32(10).bytes(message.key);
|
|
617
|
+
}
|
|
618
|
+
if (message.fromSequence !== 0n) {
|
|
619
|
+
if (BigInt.asIntN(64, message.fromSequence) !== message.fromSequence) {
|
|
620
|
+
throw new globalThis.Error("value provided for field message.fromSequence of type int64 too large");
|
|
621
|
+
}
|
|
622
|
+
writer.uint32(16).int64(message.fromSequence);
|
|
623
|
+
}
|
|
624
|
+
if (message.toSequence !== 0n) {
|
|
625
|
+
if (BigInt.asIntN(64, message.toSequence) !== message.toSequence) {
|
|
626
|
+
throw new globalThis.Error("value provided for field message.toSequence of type int64 too large");
|
|
627
|
+
}
|
|
628
|
+
writer.uint32(24).int64(message.toSequence);
|
|
629
|
+
}
|
|
630
|
+
return writer;
|
|
631
|
+
},
|
|
632
|
+
|
|
633
|
+
decode(input: BinaryReader | Uint8Array, length?: number): ListSnapshotsRequest {
|
|
634
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
635
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
636
|
+
const message = createBaseListSnapshotsRequest();
|
|
637
|
+
while (reader.pos < end) {
|
|
638
|
+
const tag = reader.uint32();
|
|
639
|
+
switch (tag >>> 3) {
|
|
640
|
+
case 1: {
|
|
641
|
+
if (tag !== 10) {
|
|
642
|
+
break;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
message.key = reader.bytes();
|
|
646
|
+
continue;
|
|
647
|
+
}
|
|
648
|
+
case 2: {
|
|
649
|
+
if (tag !== 16) {
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
message.fromSequence = reader.int64() as bigint;
|
|
654
|
+
continue;
|
|
655
|
+
}
|
|
656
|
+
case 3: {
|
|
657
|
+
if (tag !== 24) {
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
message.toSequence = reader.int64() as bigint;
|
|
662
|
+
continue;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
666
|
+
break;
|
|
667
|
+
}
|
|
668
|
+
reader.skip(tag & 7);
|
|
669
|
+
}
|
|
670
|
+
return message;
|
|
671
|
+
},
|
|
672
|
+
|
|
673
|
+
fromJSON(object: any): ListSnapshotsRequest {
|
|
674
|
+
return {
|
|
675
|
+
key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(0),
|
|
676
|
+
fromSequence: isSet(object.fromSequence)
|
|
677
|
+
? BigInt(object.fromSequence)
|
|
678
|
+
: isSet(object.from_sequence)
|
|
679
|
+
? BigInt(object.from_sequence)
|
|
680
|
+
: 0n,
|
|
681
|
+
toSequence: isSet(object.toSequence)
|
|
682
|
+
? BigInt(object.toSequence)
|
|
683
|
+
: isSet(object.to_sequence)
|
|
684
|
+
? BigInt(object.to_sequence)
|
|
685
|
+
: 0n,
|
|
686
|
+
};
|
|
687
|
+
},
|
|
688
|
+
|
|
689
|
+
toJSON(message: ListSnapshotsRequest): unknown {
|
|
690
|
+
const obj: any = {};
|
|
691
|
+
if (message.key.length !== 0) {
|
|
692
|
+
obj.key = base64FromBytes(message.key);
|
|
693
|
+
}
|
|
694
|
+
if (message.fromSequence !== 0n) {
|
|
695
|
+
obj.fromSequence = message.fromSequence.toString();
|
|
696
|
+
}
|
|
697
|
+
if (message.toSequence !== 0n) {
|
|
698
|
+
obj.toSequence = message.toSequence.toString();
|
|
699
|
+
}
|
|
700
|
+
return obj;
|
|
701
|
+
},
|
|
702
|
+
|
|
703
|
+
create(base?: DeepPartial<ListSnapshotsRequest>): ListSnapshotsRequest {
|
|
704
|
+
return ListSnapshotsRequest.fromPartial(base ?? {});
|
|
705
|
+
},
|
|
706
|
+
fromPartial(object: DeepPartial<ListSnapshotsRequest>): ListSnapshotsRequest {
|
|
707
|
+
const message = createBaseListSnapshotsRequest();
|
|
708
|
+
message.key = object.key ?? new Uint8Array(0);
|
|
709
|
+
message.fromSequence = object.fromSequence ?? 0n;
|
|
710
|
+
message.toSequence = object.toSequence ?? 0n;
|
|
711
|
+
return message;
|
|
712
|
+
},
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
function createBaseListSnapshotsResponse(): ListSnapshotsResponse {
|
|
716
|
+
return { key: new Uint8Array(0), sequence: 0n, snapshot: undefined };
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
export const ListSnapshotsResponse: MessageFns<ListSnapshotsResponse> = {
|
|
720
|
+
encode(message: ListSnapshotsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
721
|
+
if (message.key.length !== 0) {
|
|
722
|
+
writer.uint32(10).bytes(message.key);
|
|
723
|
+
}
|
|
724
|
+
if (message.sequence !== 0n) {
|
|
725
|
+
if (BigInt.asIntN(64, message.sequence) !== message.sequence) {
|
|
726
|
+
throw new globalThis.Error("value provided for field message.sequence of type int64 too large");
|
|
727
|
+
}
|
|
728
|
+
writer.uint32(16).int64(message.sequence);
|
|
729
|
+
}
|
|
730
|
+
if (message.snapshot !== undefined) {
|
|
731
|
+
Snapshot.encode(message.snapshot, writer.uint32(26).fork()).join();
|
|
732
|
+
}
|
|
733
|
+
return writer;
|
|
734
|
+
},
|
|
735
|
+
|
|
736
|
+
decode(input: BinaryReader | Uint8Array, length?: number): ListSnapshotsResponse {
|
|
737
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
738
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
739
|
+
const message = createBaseListSnapshotsResponse();
|
|
740
|
+
while (reader.pos < end) {
|
|
741
|
+
const tag = reader.uint32();
|
|
742
|
+
switch (tag >>> 3) {
|
|
743
|
+
case 1: {
|
|
744
|
+
if (tag !== 10) {
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
message.key = reader.bytes();
|
|
749
|
+
continue;
|
|
750
|
+
}
|
|
751
|
+
case 2: {
|
|
752
|
+
if (tag !== 16) {
|
|
753
|
+
break;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
message.sequence = reader.int64() as bigint;
|
|
757
|
+
continue;
|
|
758
|
+
}
|
|
759
|
+
case 3: {
|
|
760
|
+
if (tag !== 26) {
|
|
761
|
+
break;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
message.snapshot = Snapshot.decode(reader, reader.uint32());
|
|
765
|
+
continue;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
769
|
+
break;
|
|
770
|
+
}
|
|
771
|
+
reader.skip(tag & 7);
|
|
772
|
+
}
|
|
773
|
+
return message;
|
|
774
|
+
},
|
|
775
|
+
|
|
776
|
+
fromJSON(object: any): ListSnapshotsResponse {
|
|
777
|
+
return {
|
|
778
|
+
key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(0),
|
|
779
|
+
sequence: isSet(object.sequence) ? BigInt(object.sequence) : 0n,
|
|
780
|
+
snapshot: isSet(object.snapshot) ? Snapshot.fromJSON(object.snapshot) : undefined,
|
|
781
|
+
};
|
|
782
|
+
},
|
|
783
|
+
|
|
784
|
+
toJSON(message: ListSnapshotsResponse): unknown {
|
|
785
|
+
const obj: any = {};
|
|
786
|
+
if (message.key.length !== 0) {
|
|
787
|
+
obj.key = base64FromBytes(message.key);
|
|
788
|
+
}
|
|
789
|
+
if (message.sequence !== 0n) {
|
|
790
|
+
obj.sequence = message.sequence.toString();
|
|
791
|
+
}
|
|
792
|
+
if (message.snapshot !== undefined) {
|
|
793
|
+
obj.snapshot = Snapshot.toJSON(message.snapshot);
|
|
794
|
+
}
|
|
795
|
+
return obj;
|
|
796
|
+
},
|
|
797
|
+
|
|
798
|
+
create(base?: DeepPartial<ListSnapshotsResponse>): ListSnapshotsResponse {
|
|
799
|
+
return ListSnapshotsResponse.fromPartial(base ?? {});
|
|
800
|
+
},
|
|
801
|
+
fromPartial(object: DeepPartial<ListSnapshotsResponse>): ListSnapshotsResponse {
|
|
802
|
+
const message = createBaseListSnapshotsResponse();
|
|
803
|
+
message.key = object.key ?? new Uint8Array(0);
|
|
804
|
+
message.sequence = object.sequence ?? 0n;
|
|
805
|
+
message.snapshot = (object.snapshot !== undefined && object.snapshot !== null)
|
|
806
|
+
? Snapshot.fromPartial(object.snapshot)
|
|
807
|
+
: undefined;
|
|
808
|
+
return message;
|
|
809
|
+
},
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
function createBaseGetLastSnapshotRequest(): GetLastSnapshotRequest {
|
|
813
|
+
return { key: new Uint8Array(0) };
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
export const GetLastSnapshotRequest: MessageFns<GetLastSnapshotRequest> = {
|
|
817
|
+
encode(message: GetLastSnapshotRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
818
|
+
if (message.key.length !== 0) {
|
|
819
|
+
writer.uint32(10).bytes(message.key);
|
|
820
|
+
}
|
|
821
|
+
return writer;
|
|
822
|
+
},
|
|
823
|
+
|
|
824
|
+
decode(input: BinaryReader | Uint8Array, length?: number): GetLastSnapshotRequest {
|
|
825
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
826
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
827
|
+
const message = createBaseGetLastSnapshotRequest();
|
|
828
|
+
while (reader.pos < end) {
|
|
829
|
+
const tag = reader.uint32();
|
|
830
|
+
switch (tag >>> 3) {
|
|
831
|
+
case 1: {
|
|
832
|
+
if (tag !== 10) {
|
|
833
|
+
break;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
message.key = reader.bytes();
|
|
837
|
+
continue;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
841
|
+
break;
|
|
842
|
+
}
|
|
843
|
+
reader.skip(tag & 7);
|
|
844
|
+
}
|
|
845
|
+
return message;
|
|
846
|
+
},
|
|
847
|
+
|
|
848
|
+
fromJSON(object: any): GetLastSnapshotRequest {
|
|
849
|
+
return { key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(0) };
|
|
850
|
+
},
|
|
851
|
+
|
|
852
|
+
toJSON(message: GetLastSnapshotRequest): unknown {
|
|
853
|
+
const obj: any = {};
|
|
854
|
+
if (message.key.length !== 0) {
|
|
855
|
+
obj.key = base64FromBytes(message.key);
|
|
856
|
+
}
|
|
857
|
+
return obj;
|
|
858
|
+
},
|
|
859
|
+
|
|
860
|
+
create(base?: DeepPartial<GetLastSnapshotRequest>): GetLastSnapshotRequest {
|
|
861
|
+
return GetLastSnapshotRequest.fromPartial(base ?? {});
|
|
862
|
+
},
|
|
863
|
+
fromPartial(object: DeepPartial<GetLastSnapshotRequest>): GetLastSnapshotRequest {
|
|
864
|
+
const message = createBaseGetLastSnapshotRequest();
|
|
865
|
+
message.key = object.key ?? new Uint8Array(0);
|
|
866
|
+
return message;
|
|
867
|
+
},
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
function createBaseGetLastSnapshotResponse(): GetLastSnapshotResponse {
|
|
871
|
+
return { key: new Uint8Array(0), sequence: 0n, snapshot: undefined };
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
export const GetLastSnapshotResponse: MessageFns<GetLastSnapshotResponse> = {
|
|
875
|
+
encode(message: GetLastSnapshotResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
876
|
+
if (message.key.length !== 0) {
|
|
877
|
+
writer.uint32(10).bytes(message.key);
|
|
878
|
+
}
|
|
879
|
+
if (message.sequence !== 0n) {
|
|
880
|
+
if (BigInt.asIntN(64, message.sequence) !== message.sequence) {
|
|
881
|
+
throw new globalThis.Error("value provided for field message.sequence of type int64 too large");
|
|
882
|
+
}
|
|
883
|
+
writer.uint32(16).int64(message.sequence);
|
|
884
|
+
}
|
|
885
|
+
if (message.snapshot !== undefined) {
|
|
886
|
+
Snapshot.encode(message.snapshot, writer.uint32(26).fork()).join();
|
|
887
|
+
}
|
|
888
|
+
return writer;
|
|
889
|
+
},
|
|
890
|
+
|
|
891
|
+
decode(input: BinaryReader | Uint8Array, length?: number): GetLastSnapshotResponse {
|
|
892
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
893
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
894
|
+
const message = createBaseGetLastSnapshotResponse();
|
|
895
|
+
while (reader.pos < end) {
|
|
896
|
+
const tag = reader.uint32();
|
|
897
|
+
switch (tag >>> 3) {
|
|
898
|
+
case 1: {
|
|
899
|
+
if (tag !== 10) {
|
|
900
|
+
break;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
message.key = reader.bytes();
|
|
904
|
+
continue;
|
|
905
|
+
}
|
|
906
|
+
case 2: {
|
|
907
|
+
if (tag !== 16) {
|
|
908
|
+
break;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
message.sequence = reader.int64() as bigint;
|
|
912
|
+
continue;
|
|
913
|
+
}
|
|
914
|
+
case 3: {
|
|
915
|
+
if (tag !== 26) {
|
|
916
|
+
break;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
message.snapshot = Snapshot.decode(reader, reader.uint32());
|
|
920
|
+
continue;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
924
|
+
break;
|
|
925
|
+
}
|
|
926
|
+
reader.skip(tag & 7);
|
|
927
|
+
}
|
|
928
|
+
return message;
|
|
929
|
+
},
|
|
930
|
+
|
|
931
|
+
fromJSON(object: any): GetLastSnapshotResponse {
|
|
932
|
+
return {
|
|
933
|
+
key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(0),
|
|
934
|
+
sequence: isSet(object.sequence) ? BigInt(object.sequence) : 0n,
|
|
935
|
+
snapshot: isSet(object.snapshot) ? Snapshot.fromJSON(object.snapshot) : undefined,
|
|
936
|
+
};
|
|
937
|
+
},
|
|
938
|
+
|
|
939
|
+
toJSON(message: GetLastSnapshotResponse): unknown {
|
|
940
|
+
const obj: any = {};
|
|
941
|
+
if (message.key.length !== 0) {
|
|
942
|
+
obj.key = base64FromBytes(message.key);
|
|
943
|
+
}
|
|
944
|
+
if (message.sequence !== 0n) {
|
|
945
|
+
obj.sequence = message.sequence.toString();
|
|
946
|
+
}
|
|
947
|
+
if (message.snapshot !== undefined) {
|
|
948
|
+
obj.snapshot = Snapshot.toJSON(message.snapshot);
|
|
949
|
+
}
|
|
950
|
+
return obj;
|
|
951
|
+
},
|
|
952
|
+
|
|
953
|
+
create(base?: DeepPartial<GetLastSnapshotResponse>): GetLastSnapshotResponse {
|
|
954
|
+
return GetLastSnapshotResponse.fromPartial(base ?? {});
|
|
955
|
+
},
|
|
956
|
+
fromPartial(object: DeepPartial<GetLastSnapshotResponse>): GetLastSnapshotResponse {
|
|
957
|
+
const message = createBaseGetLastSnapshotResponse();
|
|
958
|
+
message.key = object.key ?? new Uint8Array(0);
|
|
959
|
+
message.sequence = object.sequence ?? 0n;
|
|
960
|
+
message.snapshot = (object.snapshot !== undefined && object.snapshot !== null)
|
|
961
|
+
? Snapshot.fromPartial(object.snapshot)
|
|
962
|
+
: undefined;
|
|
963
|
+
return message;
|
|
964
|
+
},
|
|
965
|
+
};
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* Service providing Snapshot Store RPCs.
|
|
969
|
+
*
|
|
970
|
+
* Snapshots are keyed by an opaque binary key (typically entity type + ID)
|
|
971
|
+
* and sequenced by event store position. They cache projection/read model
|
|
972
|
+
* state to avoid replaying the full event stream.
|
|
973
|
+
*
|
|
974
|
+
* Aligned with the Axon Server DcbSnapshotStore API.
|
|
975
|
+
*/
|
|
976
|
+
export type SnapshotStoreDefinition = typeof SnapshotStoreDefinition;
|
|
977
|
+
export const SnapshotStoreDefinition = {
|
|
978
|
+
name: "SnapshotStore",
|
|
979
|
+
fullName: "kronosdb.snapshot.SnapshotStore",
|
|
980
|
+
methods: {
|
|
981
|
+
/** Stores a snapshot. If prune is true, older snapshots for the same key are deleted. */
|
|
982
|
+
add: {
|
|
983
|
+
name: "Add",
|
|
984
|
+
requestType: AddSnapshotRequest as typeof AddSnapshotRequest,
|
|
985
|
+
requestStream: false,
|
|
986
|
+
responseType: AddSnapshotResponse as typeof AddSnapshotResponse,
|
|
987
|
+
responseStream: false,
|
|
988
|
+
options: {},
|
|
989
|
+
},
|
|
990
|
+
/** Deletes snapshots for a key up to (exclusive) a given sequence. */
|
|
991
|
+
delete: {
|
|
992
|
+
name: "Delete",
|
|
993
|
+
requestType: DeleteSnapshotsRequest as typeof DeleteSnapshotsRequest,
|
|
994
|
+
requestStream: false,
|
|
995
|
+
responseType: DeleteSnapshotsResponse as typeof DeleteSnapshotsResponse,
|
|
996
|
+
responseStream: false,
|
|
997
|
+
options: {},
|
|
998
|
+
},
|
|
999
|
+
/** Lists all snapshots for a key within a sequence range. */
|
|
1000
|
+
list: {
|
|
1001
|
+
name: "List",
|
|
1002
|
+
requestType: ListSnapshotsRequest as typeof ListSnapshotsRequest,
|
|
1003
|
+
requestStream: false,
|
|
1004
|
+
responseType: ListSnapshotsResponse as typeof ListSnapshotsResponse,
|
|
1005
|
+
responseStream: true,
|
|
1006
|
+
options: {},
|
|
1007
|
+
},
|
|
1008
|
+
/** Gets the snapshot with the highest sequence for a key. */
|
|
1009
|
+
getLast: {
|
|
1010
|
+
name: "GetLast",
|
|
1011
|
+
requestType: GetLastSnapshotRequest as typeof GetLastSnapshotRequest,
|
|
1012
|
+
requestStream: false,
|
|
1013
|
+
responseType: GetLastSnapshotResponse as typeof GetLastSnapshotResponse,
|
|
1014
|
+
responseStream: false,
|
|
1015
|
+
options: {},
|
|
1016
|
+
},
|
|
1017
|
+
},
|
|
1018
|
+
} as const;
|
|
1019
|
+
|
|
1020
|
+
export interface SnapshotStoreServiceImplementation<CallContextExt = {}> {
|
|
1021
|
+
/** Stores a snapshot. If prune is true, older snapshots for the same key are deleted. */
|
|
1022
|
+
add(request: AddSnapshotRequest, context: CallContext & CallContextExt): Promise<DeepPartial<AddSnapshotResponse>>;
|
|
1023
|
+
/** Deletes snapshots for a key up to (exclusive) a given sequence. */
|
|
1024
|
+
delete(
|
|
1025
|
+
request: DeleteSnapshotsRequest,
|
|
1026
|
+
context: CallContext & CallContextExt,
|
|
1027
|
+
): Promise<DeepPartial<DeleteSnapshotsResponse>>;
|
|
1028
|
+
/** Lists all snapshots for a key within a sequence range. */
|
|
1029
|
+
list(
|
|
1030
|
+
request: ListSnapshotsRequest,
|
|
1031
|
+
context: CallContext & CallContextExt,
|
|
1032
|
+
): ServerStreamingMethodResult<DeepPartial<ListSnapshotsResponse>>;
|
|
1033
|
+
/** Gets the snapshot with the highest sequence for a key. */
|
|
1034
|
+
getLast(
|
|
1035
|
+
request: GetLastSnapshotRequest,
|
|
1036
|
+
context: CallContext & CallContextExt,
|
|
1037
|
+
): Promise<DeepPartial<GetLastSnapshotResponse>>;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
export interface SnapshotStoreClient<CallOptionsExt = {}> {
|
|
1041
|
+
/** Stores a snapshot. If prune is true, older snapshots for the same key are deleted. */
|
|
1042
|
+
add(request: DeepPartial<AddSnapshotRequest>, options?: CallOptions & CallOptionsExt): Promise<AddSnapshotResponse>;
|
|
1043
|
+
/** Deletes snapshots for a key up to (exclusive) a given sequence. */
|
|
1044
|
+
delete(
|
|
1045
|
+
request: DeepPartial<DeleteSnapshotsRequest>,
|
|
1046
|
+
options?: CallOptions & CallOptionsExt,
|
|
1047
|
+
): Promise<DeleteSnapshotsResponse>;
|
|
1048
|
+
/** Lists all snapshots for a key within a sequence range. */
|
|
1049
|
+
list(
|
|
1050
|
+
request: DeepPartial<ListSnapshotsRequest>,
|
|
1051
|
+
options?: CallOptions & CallOptionsExt,
|
|
1052
|
+
): AsyncIterable<ListSnapshotsResponse>;
|
|
1053
|
+
/** Gets the snapshot with the highest sequence for a key. */
|
|
1054
|
+
getLast(
|
|
1055
|
+
request: DeepPartial<GetLastSnapshotRequest>,
|
|
1056
|
+
options?: CallOptions & CallOptionsExt,
|
|
1057
|
+
): Promise<GetLastSnapshotResponse>;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
function bytesFromBase64(b64: string): Uint8Array {
|
|
1061
|
+
if ((globalThis as any).Buffer) {
|
|
1062
|
+
return Uint8Array.from((globalThis as any).Buffer.from(b64, "base64"));
|
|
1063
|
+
} else {
|
|
1064
|
+
const bin = globalThis.atob(b64);
|
|
1065
|
+
const arr = new Uint8Array(bin.length);
|
|
1066
|
+
for (let i = 0; i < bin.length; ++i) {
|
|
1067
|
+
arr[i] = bin.charCodeAt(i);
|
|
1068
|
+
}
|
|
1069
|
+
return arr;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
function base64FromBytes(arr: Uint8Array): string {
|
|
1074
|
+
if ((globalThis as any).Buffer) {
|
|
1075
|
+
return (globalThis as any).Buffer.from(arr).toString("base64");
|
|
1076
|
+
} else {
|
|
1077
|
+
const bin: string[] = [];
|
|
1078
|
+
arr.forEach((byte) => {
|
|
1079
|
+
bin.push(globalThis.String.fromCharCode(byte));
|
|
1080
|
+
});
|
|
1081
|
+
return globalThis.btoa(bin.join(""));
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
|
|
1086
|
+
|
|
1087
|
+
export type DeepPartial<T> = T extends Builtin ? T
|
|
1088
|
+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
|
1089
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
1090
|
+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
1091
|
+
: Partial<T>;
|
|
1092
|
+
|
|
1093
|
+
function isObject(value: any): boolean {
|
|
1094
|
+
return typeof value === "object" && value !== null;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
function isSet(value: any): boolean {
|
|
1098
|
+
return value !== null && value !== undefined;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
export type ServerStreamingMethodResult<Response> = { [Symbol.asyncIterator](): AsyncIterator<Response, void> };
|
|
1102
|
+
|
|
1103
|
+
export interface MessageFns<T> {
|
|
1104
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
1105
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
1106
|
+
fromJSON(object: any): T;
|
|
1107
|
+
toJSON(message: T): unknown;
|
|
1108
|
+
create(base?: DeepPartial<T>): T;
|
|
1109
|
+
fromPartial(object: DeepPartial<T>): T;
|
|
1110
|
+
}
|