Skip to content

Commit d475c8a

Browse files
committed
fix: sync generated protobuf ts files with the datapath schema
Regenerated with pbkit from proto/schema/datapath.proto. The generated TypeScript was missing the M_SET_SUFFIX_VERSIONSTAMPED_KEY mutation type and the sum_min / sum_max / sum_clamp fields on Mutation. The Mutation message construction in proto_based.ts gains the new fields with proto3 default values, leaving the wire encoding of existing mutation types unchanged. Fixes #87.
1 parent b63cfd9 commit d475c8a

3 files changed

Lines changed: 58 additions & 1 deletion

File tree

npm/src/proto/messages/com/deno/kv/datapath/Mutation.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export declare namespace $.com.deno.kv.datapath {
3939
value?: KvValue;
4040
mutationType: MutationType;
4141
expireAtMs: string;
42+
sumMin: Uint8Array;
43+
sumMax: Uint8Array;
44+
sumClamp: boolean;
4245
}
4346
}
4447

@@ -50,6 +53,9 @@ export function getDefaultValue(): $.com.deno.kv.datapath.Mutation {
5053
value: undefined,
5154
mutationType: "M_UNSPECIFIED",
5255
expireAtMs: "0",
56+
sumMin: new Uint8Array(),
57+
sumMax: new Uint8Array(),
58+
sumClamp: false,
5359
};
5460
}
5561

@@ -66,6 +72,9 @@ export function encodeJson(value: $.com.deno.kv.datapath.Mutation): unknown {
6672
if (value.value !== undefined) result.value = encodeJson_1(value.value);
6773
if (value.mutationType !== undefined) result.mutationType = tsValueToJsonValueFns.enum(value.mutationType);
6874
if (value.expireAtMs !== undefined) result.expireAtMs = tsValueToJsonValueFns.int64(value.expireAtMs);
75+
if (value.sumMin !== undefined) result.sumMin = tsValueToJsonValueFns.bytes(value.sumMin);
76+
if (value.sumMax !== undefined) result.sumMax = tsValueToJsonValueFns.bytes(value.sumMax);
77+
if (value.sumClamp !== undefined) result.sumClamp = tsValueToJsonValueFns.bool(value.sumClamp);
6978
return result;
7079
}
7180

@@ -75,6 +84,9 @@ export function decodeJson(value: any): $.com.deno.kv.datapath.Mutation {
7584
if (value.value !== undefined) result.value = decodeJson_1(value.value);
7685
if (value.mutationType !== undefined) result.mutationType = jsonValueToTsValueFns.enum(value.mutationType) as MutationType;
7786
if (value.expireAtMs !== undefined) result.expireAtMs = jsonValueToTsValueFns.int64(value.expireAtMs);
87+
if (value.sumMin !== undefined) result.sumMin = jsonValueToTsValueFns.bytes(value.sumMin);
88+
if (value.sumMax !== undefined) result.sumMax = jsonValueToTsValueFns.bytes(value.sumMax);
89+
if (value.sumClamp !== undefined) result.sumClamp = jsonValueToTsValueFns.bool(value.sumClamp);
7890
return result;
7991
}
8092

@@ -104,6 +116,24 @@ export function encodeBinary(value: $.com.deno.kv.datapath.Mutation): Uint8Array
104116
[4, tsValueToWireValueFns.int64(tsValue)],
105117
);
106118
}
119+
if (value.sumMin !== undefined) {
120+
const tsValue = value.sumMin;
121+
result.push(
122+
[5, tsValueToWireValueFns.bytes(tsValue)],
123+
);
124+
}
125+
if (value.sumMax !== undefined) {
126+
const tsValue = value.sumMax;
127+
result.push(
128+
[6, tsValueToWireValueFns.bytes(tsValue)],
129+
);
130+
}
131+
if (value.sumClamp !== undefined) {
132+
const tsValue = value.sumClamp;
133+
result.push(
134+
[7, tsValueToWireValueFns.bool(tsValue)],
135+
);
136+
}
107137
return serialize(result);
108138
}
109139

@@ -139,5 +169,26 @@ export function decodeBinary(binary: Uint8Array): $.com.deno.kv.datapath.Mutatio
139169
if (value === undefined) break field;
140170
result.expireAtMs = value;
141171
}
172+
field: {
173+
const wireValue = wireFields.get(5);
174+
if (wireValue === undefined) break field;
175+
const value = wireValueToTsValueFns.bytes(wireValue);
176+
if (value === undefined) break field;
177+
result.sumMin = value;
178+
}
179+
field: {
180+
const wireValue = wireFields.get(6);
181+
if (wireValue === undefined) break field;
182+
const value = wireValueToTsValueFns.bytes(wireValue);
183+
if (value === undefined) break field;
184+
result.sumMax = value;
185+
}
186+
field: {
187+
const wireValue = wireFields.get(7);
188+
if (wireValue === undefined) break field;
189+
const value = wireValueToTsValueFns.bool(wireValue);
190+
if (value === undefined) break field;
191+
result.sumClamp = value;
192+
}
142193
return result;
143194
}

npm/src/proto/messages/com/deno/kv/datapath/MutationType.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export declare namespace $.com.deno.kv.datapath {
66
| "M_DELETE"
77
| "M_SUM"
88
| "M_MAX"
9-
| "M_MIN";
9+
| "M_MIN"
10+
| "M_SET_SUFFIX_VERSIONSTAMPED_KEY";
1011
}
1112

1213
export type Type = $.com.deno.kv.datapath.MutationType;
@@ -18,6 +19,7 @@ export const num2name = {
1819
3: "M_SUM",
1920
4: "M_MAX",
2021
5: "M_MIN",
22+
9: "M_SET_SUFFIX_VERSIONSTAMPED_KEY",
2123
} as const;
2224

2325
export const name2num = {
@@ -27,4 +29,5 @@ export const name2num = {
2729
M_SUM: 3,
2830
M_MAX: 4,
2931
M_MIN: 5,
32+
M_SET_SUFFIX_VERSIONSTAMPED_KEY: 9,
3033
} as const;

npm/src/proto_based.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ function computeKvMutationMessage(
289289
expireAtMs: mut.type === "set" && typeof mut.expireIn === "number"
290290
? (Date.now() + mut.expireIn).toString()
291291
: "0",
292+
sumMin: new Uint8Array(),
293+
sumMax: new Uint8Array(),
294+
sumClamp: false,
292295
};
293296
}
294297

0 commit comments

Comments
 (0)