@bufbuild/protobuf 1.7.2 → 1.9.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/cjs/binary-encoding.d.ts +2 -2
- package/dist/cjs/codegen-info.d.ts +6 -1
- package/dist/cjs/codegen-info.js +4 -3
- package/dist/cjs/create-descriptor-set.js +45 -33
- package/dist/cjs/create-registry-from-desc.js +60 -110
- package/dist/cjs/descriptor-set.d.ts +13 -9
- package/dist/cjs/field.d.ts +25 -51
- package/dist/cjs/field.js +0 -66
- package/dist/cjs/google/protobuf/compiler/plugin_pb.d.ts +18 -0
- package/dist/cjs/google/protobuf/compiler/plugin_pb.js +2 -0
- package/dist/cjs/google/protobuf/descriptor_pb.d.ts +33 -33
- package/dist/cjs/google/protobuf/descriptor_pb.js +23 -10
- package/dist/cjs/google/protobuf/struct_pb.js +1 -1
- package/dist/cjs/google/protobuf/type_pb.js +1 -1
- package/dist/cjs/google/protobuf/wrappers_pb.js +19 -19
- package/dist/cjs/index.d.ts +4 -2
- package/dist/cjs/index.js +6 -4
- package/dist/cjs/is-message.d.ts +22 -0
- package/dist/cjs/is-message.js +52 -0
- package/dist/cjs/json-format.d.ts +1 -2
- package/dist/cjs/message.d.ts +1 -0
- package/dist/cjs/message.js +1 -0
- package/dist/cjs/private/binary-format.d.ts +7 -0
- package/dist/cjs/private/{binary-format-common.js → binary-format.js} +150 -53
- package/dist/cjs/private/extensions.js +1 -1
- package/dist/cjs/private/feature-set.js +1 -1
- package/dist/cjs/private/field-normalize.d.ts +9 -0
- package/dist/cjs/private/field-normalize.js +69 -0
- package/dist/cjs/private/field-wrapper.d.ts +1 -1
- package/dist/cjs/private/field-wrapper.js +12 -12
- package/dist/cjs/private/field.d.ts +1 -0
- package/dist/cjs/private/field.js +1 -0
- package/dist/cjs/private/json-format.d.ts +2 -0
- package/dist/cjs/private/{json-format-common.js → json-format.js} +261 -170
- package/dist/cjs/private/names.js +3 -3
- package/dist/cjs/private/proto-runtime.d.ts +1 -1
- package/dist/cjs/private/proto-runtime.js +8 -4
- package/dist/cjs/private/reflect.d.ts +9 -0
- package/dist/cjs/private/reflect.js +79 -0
- package/dist/cjs/private/reify-wkt.js +11 -11
- package/dist/cjs/private/scalars.d.ts +9 -18
- package/dist/cjs/private/scalars.js +36 -80
- package/dist/cjs/private/text-format.d.ts +1 -1
- package/dist/cjs/private/text-format.js +17 -17
- package/dist/cjs/private/util-common.js +20 -14
- package/dist/cjs/proto-delimited.js +2 -3
- package/dist/cjs/proto2.js +29 -68
- package/dist/cjs/proto3.js +30 -77
- package/dist/cjs/scalar.d.ts +53 -0
- package/dist/cjs/scalar.js +81 -0
- package/dist/cjs/to-plain-message.js +3 -4
- package/dist/esm/binary-encoding.d.ts +2 -2
- package/dist/esm/codegen-info.d.ts +6 -1
- package/dist/esm/codegen-info.js +6 -5
- package/dist/esm/create-descriptor-set.js +22 -10
- package/dist/esm/create-registry-from-desc.js +62 -111
- package/dist/esm/descriptor-set.d.ts +13 -9
- package/dist/esm/descriptor-set.js +1 -1
- package/dist/esm/field.d.ts +25 -51
- package/dist/esm/field.js +1 -65
- package/dist/esm/google/protobuf/compiler/plugin_pb.d.ts +18 -0
- package/dist/esm/google/protobuf/compiler/plugin_pb.js +2 -0
- package/dist/esm/google/protobuf/descriptor_pb.d.ts +33 -33
- package/dist/esm/google/protobuf/descriptor_pb.js +23 -10
- package/dist/esm/google/protobuf/struct_pb.js +1 -1
- package/dist/esm/google/protobuf/type_pb.js +1 -1
- package/dist/esm/google/protobuf/wrappers_pb.js +1 -1
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +2 -1
- package/dist/esm/is-message.d.ts +22 -0
- package/dist/esm/is-message.js +48 -0
- package/dist/esm/json-format.d.ts +1 -2
- package/dist/esm/json-format.js +1 -1
- package/dist/esm/message.d.ts +1 -0
- package/dist/esm/message.js +1 -0
- package/dist/esm/private/binary-format.d.ts +7 -0
- package/dist/esm/private/{binary-format-common.js → binary-format.js} +126 -25
- package/dist/esm/private/extensions.js +2 -2
- package/dist/esm/private/feature-set.js +1 -1
- package/dist/esm/private/field-normalize.d.ts +9 -0
- package/dist/esm/private/field-normalize.js +65 -0
- package/dist/esm/private/field-wrapper.d.ts +1 -1
- package/dist/esm/private/field-wrapper.js +3 -2
- package/dist/esm/private/field.d.ts +1 -0
- package/dist/esm/private/field.js +1 -0
- package/dist/esm/private/json-format.d.ts +2 -0
- package/dist/esm/private/{json-format-common.js → json-format.js} +228 -136
- package/dist/esm/private/names.js +3 -3
- package/dist/esm/private/proto-runtime.d.ts +1 -1
- package/dist/esm/private/proto-runtime.js +8 -4
- package/dist/esm/private/reflect.d.ts +9 -0
- package/dist/esm/private/reflect.js +74 -0
- package/dist/esm/private/reify-wkt.js +1 -1
- package/dist/esm/private/scalars.d.ts +9 -18
- package/dist/esm/private/scalars.js +15 -59
- package/dist/esm/private/text-format.d.ts +1 -1
- package/dist/esm/private/text-format.js +1 -1
- package/dist/esm/private/util-common.js +13 -6
- package/dist/esm/proto-delimited.js +2 -3
- package/dist/esm/proto2.js +29 -68
- package/dist/esm/proto3.js +31 -78
- package/dist/esm/scalar.d.ts +53 -0
- package/dist/esm/scalar.js +78 -0
- package/dist/esm/to-plain-message.js +3 -2
- package/package.json +4 -10
- package/dist/cjs/private/binary-format-common.d.ts +0 -13
- package/dist/cjs/private/binary-format-proto2.d.ts +0 -2
- package/dist/cjs/private/binary-format-proto2.js +0 -91
- package/dist/cjs/private/binary-format-proto3.d.ts +0 -2
- package/dist/cjs/private/binary-format-proto3.js +0 -83
- package/dist/cjs/private/json-format-common.d.ts +0 -9
- package/dist/cjs/private/json-format-proto2.d.ts +0 -2
- package/dist/cjs/private/json-format-proto2.js +0 -103
- package/dist/cjs/private/json-format-proto3.d.ts +0 -2
- package/dist/cjs/private/json-format-proto3.js +0 -94
- package/dist/esm/private/binary-format-common.d.ts +0 -13
- package/dist/esm/private/binary-format-proto2.d.ts +0 -2
- package/dist/esm/private/binary-format-proto2.js +0 -87
- package/dist/esm/private/binary-format-proto3.d.ts +0 -2
- package/dist/esm/private/binary-format-proto3.js +0 -79
- package/dist/esm/private/json-format-common.d.ts +0 -9
- package/dist/esm/private/json-format-proto2.d.ts +0 -2
- package/dist/esm/private/json-format-proto2.js +0 -99
- package/dist/esm/private/json-format-proto3.d.ts +0 -2
- package/dist/esm/private/json-format-proto3.js +0 -90
- package/dist/proxy/index.d.ts +0 -1
- package/dist/proxy/index.js +0 -1
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import { assert } from "./private/assert.js";
|
|
15
15
|
import { proto3 } from "./proto3.js";
|
|
16
16
|
import { proto2 } from "./proto2.js";
|
|
17
|
-
import {
|
|
17
|
+
import { ScalarType } from "./scalar.js";
|
|
18
18
|
import { localName } from "./private/names.js";
|
|
19
19
|
import { Timestamp } from "./google/protobuf/timestamp_pb.js";
|
|
20
20
|
import { Duration } from "./google/protobuf/duration_pb.js";
|
|
@@ -24,8 +24,9 @@ import { FieldMask } from "./google/protobuf/field_mask_pb.js";
|
|
|
24
24
|
import { ListValue, NullValue, Struct, Value, } from "./google/protobuf/struct_pb.js";
|
|
25
25
|
import { getEnumType } from "./private/enum.js";
|
|
26
26
|
import { BoolValue, BytesValue, DoubleValue, FloatValue, Int32Value, Int64Value, StringValue, UInt32Value, UInt64Value, } from "./google/protobuf/wrappers_pb.js";
|
|
27
|
-
import { FieldDescriptorProto_Type, FileDescriptorSet, } from "./google/protobuf/descriptor_pb.js";
|
|
27
|
+
import { FieldDescriptorProto_Label, FieldDescriptorProto_Type, FileDescriptorSet, } from "./google/protobuf/descriptor_pb.js";
|
|
28
28
|
import { createDescriptorSet } from "./create-descriptor-set.js";
|
|
29
|
+
import { isMessage } from "./is-message.js";
|
|
29
30
|
// well-known message types with specialized JSON representation
|
|
30
31
|
const wkMessages = [
|
|
31
32
|
Any,
|
|
@@ -61,7 +62,7 @@ const wkEnums = [getEnumType(NullValue)];
|
|
|
61
62
|
* are replaced with their generated counterpart in this package.
|
|
62
63
|
*/
|
|
63
64
|
export function createRegistryFromDescriptors(input, replaceWkt = true) {
|
|
64
|
-
const set = input instanceof Uint8Array || input
|
|
65
|
+
const set = input instanceof Uint8Array || isMessage(input, FileDescriptorSet)
|
|
65
66
|
? createDescriptorSet(input)
|
|
66
67
|
: input;
|
|
67
68
|
const enums = new Map();
|
|
@@ -118,8 +119,7 @@ export function createRegistryFromDescriptors(input, replaceWkt = true) {
|
|
|
118
119
|
});
|
|
119
120
|
messages.set(typeName, type);
|
|
120
121
|
for (const field of desc.fields) {
|
|
121
|
-
|
|
122
|
-
fields.push(fieldInfo);
|
|
122
|
+
fields.push(makeFieldInfo(field, this));
|
|
123
123
|
}
|
|
124
124
|
return type;
|
|
125
125
|
},
|
|
@@ -137,10 +137,8 @@ export function createRegistryFromDescriptors(input, replaceWkt = true) {
|
|
|
137
137
|
}
|
|
138
138
|
const methods = {};
|
|
139
139
|
for (const method of desc.methods) {
|
|
140
|
-
const I =
|
|
141
|
-
const O =
|
|
142
|
-
assert(I, `message "${method.input.typeName}" for ${method.toString()} not found`);
|
|
143
|
-
assert(O, `output message "${method.output.typeName}" for ${method.toString()} not found`);
|
|
140
|
+
const I = resolve(method.input, this, method);
|
|
141
|
+
const O = resolve(method.output, this, method);
|
|
144
142
|
methods[localName(method)] = {
|
|
145
143
|
name: method.name,
|
|
146
144
|
I,
|
|
@@ -190,8 +188,7 @@ export function createRegistryFromDescriptors(input, replaceWkt = true) {
|
|
|
190
188
|
if (!desc) {
|
|
191
189
|
return undefined;
|
|
192
190
|
}
|
|
193
|
-
const extendee =
|
|
194
|
-
assert(extendee, `message "${desc.extendee.typeName}" for ${desc.toString()} not found`);
|
|
191
|
+
const extendee = resolve(desc.extendee, this, desc);
|
|
195
192
|
const runtime = desc.file.syntax == "proto3" ? proto3 : proto2;
|
|
196
193
|
const ext = runtime.makeExtension(typeName, extendee, makeFieldInfo(desc, this));
|
|
197
194
|
extensions.set(typeName, ext);
|
|
@@ -199,112 +196,66 @@ export function createRegistryFromDescriptors(input, replaceWkt = true) {
|
|
|
199
196
|
},
|
|
200
197
|
};
|
|
201
198
|
}
|
|
202
|
-
function makeFieldInfo(desc,
|
|
199
|
+
function makeFieldInfo(desc, registry) {
|
|
200
|
+
var _a;
|
|
201
|
+
const f = {
|
|
202
|
+
kind: desc.fieldKind,
|
|
203
|
+
no: desc.number,
|
|
204
|
+
name: desc.name,
|
|
205
|
+
jsonName: desc.jsonName,
|
|
206
|
+
delimited: desc.proto.type == FieldDescriptorProto_Type.GROUP,
|
|
207
|
+
repeated: desc.repeated,
|
|
208
|
+
packed: desc.packed,
|
|
209
|
+
oneof: (_a = desc.oneof) === null || _a === void 0 ? void 0 : _a.name,
|
|
210
|
+
opt: desc.optional,
|
|
211
|
+
req: desc.proto.label === FieldDescriptorProto_Label.REQUIRED,
|
|
212
|
+
};
|
|
203
213
|
switch (desc.fieldKind) {
|
|
204
|
-
case "map":
|
|
214
|
+
case "map": {
|
|
205
215
|
assert(desc.kind == "field"); // maps are not allowed for extensions
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
216
|
+
let T;
|
|
217
|
+
switch (desc.mapValue.kind) {
|
|
218
|
+
case "scalar":
|
|
219
|
+
T = desc.mapValue.scalar;
|
|
220
|
+
break;
|
|
221
|
+
case "enum": {
|
|
222
|
+
T = resolve(desc.mapValue.enum, registry, desc);
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
case "message": {
|
|
226
|
+
T = resolve(desc.mapValue.message, registry, desc);
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
f.K = desc.mapKey;
|
|
231
|
+
f.V = {
|
|
232
|
+
kind: desc.mapValue.kind,
|
|
233
|
+
T,
|
|
234
|
+
};
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
case "message": {
|
|
238
|
+
f.T = resolve(desc.message, registry, desc);
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
209
241
|
case "enum": {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
242
|
+
f.T = resolve(desc.enum, registry, desc);
|
|
243
|
+
f.default = desc.getDefaultValue();
|
|
244
|
+
break;
|
|
213
245
|
}
|
|
214
246
|
case "scalar": {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
247
|
+
f.L = desc.longType;
|
|
248
|
+
f.T = desc.scalar;
|
|
249
|
+
f.default = desc.getDefaultValue();
|
|
250
|
+
break;
|
|
218
251
|
}
|
|
219
252
|
}
|
|
253
|
+
return f;
|
|
220
254
|
}
|
|
221
|
-
function
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
K: field.mapKey,
|
|
228
|
-
};
|
|
229
|
-
if (field.mapValue.message) {
|
|
230
|
-
const messageType = resolver.findMessage(field.mapValue.message.typeName);
|
|
231
|
-
assert(messageType, `message "${field.mapValue.message.typeName}" for ${field.toString()} not found`);
|
|
232
|
-
return Object.assign(Object.assign({}, base), { V: {
|
|
233
|
-
kind: "message",
|
|
234
|
-
T: messageType,
|
|
235
|
-
} });
|
|
236
|
-
}
|
|
237
|
-
if (field.mapValue.enum) {
|
|
238
|
-
const enumType = resolver.findEnum(field.mapValue.enum.typeName);
|
|
239
|
-
assert(enumType, `enum "${field.mapValue.enum.typeName}" for ${field.toString()} not found`);
|
|
240
|
-
return Object.assign(Object.assign({}, base), { V: {
|
|
241
|
-
kind: "enum",
|
|
242
|
-
T: enumType,
|
|
243
|
-
} });
|
|
244
|
-
}
|
|
245
|
-
return Object.assign(Object.assign({}, base), { V: {
|
|
246
|
-
kind: "scalar",
|
|
247
|
-
T: field.mapValue.scalar,
|
|
248
|
-
} });
|
|
249
|
-
}
|
|
250
|
-
function makeScalarFieldInfo(field) {
|
|
251
|
-
// We are creating _partial_ field info here, so we omit long type bigint,
|
|
252
|
-
// which is the default.
|
|
253
|
-
const longType = field.longType == LongType.STRING
|
|
254
|
-
? { L: LongType.STRING }
|
|
255
|
-
: {};
|
|
256
|
-
const base = Object.assign({ kind: "scalar", no: field.number, name: field.name, jsonName: field.jsonName, T: field.scalar }, longType);
|
|
257
|
-
if (field.repeated) {
|
|
258
|
-
return Object.assign(Object.assign({}, base), { repeated: true, packed: field.packed, oneof: undefined, T: field.scalar });
|
|
259
|
-
}
|
|
260
|
-
if (field.oneof) {
|
|
261
|
-
return Object.assign(Object.assign({}, base), { oneof: field.oneof.name });
|
|
262
|
-
}
|
|
263
|
-
if (field.optional) {
|
|
264
|
-
return Object.assign(Object.assign({}, base), { opt: true });
|
|
265
|
-
}
|
|
266
|
-
return base;
|
|
267
|
-
}
|
|
268
|
-
function makeMessageFieldInfo(field, resolver) {
|
|
269
|
-
const messageType = resolver.findMessage(field.message.typeName);
|
|
270
|
-
assert(messageType, `message "${field.message.typeName}" for ${field.toString()} not found`);
|
|
271
|
-
const base = {
|
|
272
|
-
kind: "message",
|
|
273
|
-
no: field.number,
|
|
274
|
-
name: field.name,
|
|
275
|
-
jsonName: field.jsonName,
|
|
276
|
-
T: messageType,
|
|
277
|
-
delimited: field.proto.type == FieldDescriptorProto_Type.GROUP,
|
|
278
|
-
};
|
|
279
|
-
if (field.repeated) {
|
|
280
|
-
return Object.assign(Object.assign({}, base), { repeated: true, packed: field.packed, oneof: undefined });
|
|
281
|
-
}
|
|
282
|
-
if (field.oneof) {
|
|
283
|
-
return Object.assign(Object.assign({}, base), { oneof: field.oneof.name });
|
|
284
|
-
}
|
|
285
|
-
if (field.optional) {
|
|
286
|
-
return Object.assign(Object.assign({}, base), { opt: true });
|
|
287
|
-
}
|
|
288
|
-
return base;
|
|
289
|
-
}
|
|
290
|
-
function makeEnumFieldInfo(field, resolver) {
|
|
291
|
-
const enumType = resolver.findEnum(field.enum.typeName);
|
|
292
|
-
assert(enumType, `enum "${field.enum.typeName}" for ${field.toString()} not found`);
|
|
293
|
-
const base = {
|
|
294
|
-
kind: "enum",
|
|
295
|
-
no: field.number,
|
|
296
|
-
name: field.name,
|
|
297
|
-
jsonName: field.jsonName,
|
|
298
|
-
T: enumType,
|
|
299
|
-
};
|
|
300
|
-
if (field.repeated) {
|
|
301
|
-
return Object.assign(Object.assign({}, base), { repeated: true, packed: field.packed, oneof: undefined });
|
|
302
|
-
}
|
|
303
|
-
if (field.oneof) {
|
|
304
|
-
return Object.assign(Object.assign({}, base), { oneof: field.oneof.name });
|
|
305
|
-
}
|
|
306
|
-
if (field.optional) {
|
|
307
|
-
return Object.assign(Object.assign({}, base), { opt: true });
|
|
308
|
-
}
|
|
309
|
-
return base;
|
|
255
|
+
function resolve(desc, registry, context) {
|
|
256
|
+
const type = desc.kind == "message"
|
|
257
|
+
? registry.findMessage(desc.typeName)
|
|
258
|
+
: registry.findEnum(desc.typeName);
|
|
259
|
+
assert(type, `${desc.toString()}" for ${context.toString()} not found`);
|
|
260
|
+
return type;
|
|
310
261
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DescriptorProto, Edition, EnumDescriptorProto, EnumValueDescriptorProto, FieldDescriptorProto, FileDescriptorProto, MethodDescriptorProto, OneofDescriptorProto, ServiceDescriptorProto } from "./google/protobuf/descriptor_pb.js";
|
|
2
|
-
import
|
|
2
|
+
import { LongType, ScalarType } from "./scalar.js";
|
|
3
3
|
import type { MethodIdempotency, MethodKind } from "./service-type.js";
|
|
4
4
|
import type { MergedFeatureSet } from "./private/feature-set.js";
|
|
5
5
|
/**
|
|
@@ -47,7 +47,7 @@ export type AnyDesc = DescFile | DescEnum | DescEnumValue | DescMessage | DescFi
|
|
|
47
47
|
* Describes a protobuf source file.
|
|
48
48
|
*/
|
|
49
49
|
export interface DescFile {
|
|
50
|
-
kind: "file";
|
|
50
|
+
readonly kind: "file";
|
|
51
51
|
/**
|
|
52
52
|
* The syntax specified in the protobuf source.
|
|
53
53
|
*/
|
|
@@ -62,6 +62,10 @@ export interface DescFile {
|
|
|
62
62
|
* For a protobuf file `foo/bar.proto`, this is `foo/bar`.
|
|
63
63
|
*/
|
|
64
64
|
readonly name: string;
|
|
65
|
+
/**
|
|
66
|
+
* Files imported by this file.
|
|
67
|
+
*/
|
|
68
|
+
readonly dependencies: DescFile[];
|
|
65
69
|
/**
|
|
66
70
|
* Top-level enumerations declared in this file.
|
|
67
71
|
* Note that more enumerations might be declared within message declarations.
|
|
@@ -107,7 +111,7 @@ export interface DescFile {
|
|
|
107
111
|
* Describes an enumeration in a protobuf source file.
|
|
108
112
|
*/
|
|
109
113
|
export interface DescEnum {
|
|
110
|
-
kind: "enum";
|
|
114
|
+
readonly kind: "enum";
|
|
111
115
|
/**
|
|
112
116
|
* The fully qualified name of the enumeration. (We omit the leading dot.)
|
|
113
117
|
*/
|
|
@@ -195,7 +199,7 @@ export interface DescEnumValue {
|
|
|
195
199
|
* Describes a message declaration in a protobuf source file.
|
|
196
200
|
*/
|
|
197
201
|
export interface DescMessage {
|
|
198
|
-
kind: "message";
|
|
202
|
+
readonly kind: "message";
|
|
199
203
|
/**
|
|
200
204
|
* The fully qualified name of the message. (We omit the leading dot.)
|
|
201
205
|
*/
|
|
@@ -262,7 +266,7 @@ export interface DescMessage {
|
|
|
262
266
|
* Describes a field declaration in a protobuf source file.
|
|
263
267
|
*/
|
|
264
268
|
export type DescField = DescFieldCommon & (DescFieldScalar | DescFieldMessage | DescFieldEnum | DescFieldMap) & {
|
|
265
|
-
kind: "field";
|
|
269
|
+
readonly kind: "field";
|
|
266
270
|
/**
|
|
267
271
|
* The message this field is declared on.
|
|
268
272
|
*/
|
|
@@ -272,7 +276,7 @@ export type DescField = DescFieldCommon & (DescFieldScalar | DescFieldMessage |
|
|
|
272
276
|
* Describes an extension in a protobuf source file.
|
|
273
277
|
*/
|
|
274
278
|
export type DescExtension = DescFieldCommon & (DescFieldScalar | DescFieldMessage | DescFieldEnum | DescFieldMap) & {
|
|
275
|
-
kind: "extension";
|
|
279
|
+
readonly kind: "extension";
|
|
276
280
|
/**
|
|
277
281
|
* The fully qualified name of the extension.
|
|
278
282
|
*/
|
|
@@ -537,7 +541,7 @@ interface DescFieldMapValueScalar {
|
|
|
537
541
|
* Describes a oneof group in a protobuf source file.
|
|
538
542
|
*/
|
|
539
543
|
export interface DescOneof {
|
|
540
|
-
kind: "oneof";
|
|
544
|
+
readonly kind: "oneof";
|
|
541
545
|
/**
|
|
542
546
|
* The name of the oneof group, as specified in the protobuf source.
|
|
543
547
|
*/
|
|
@@ -574,7 +578,7 @@ export interface DescOneof {
|
|
|
574
578
|
* Describes a service declaration in a protobuf source file.
|
|
575
579
|
*/
|
|
576
580
|
export interface DescService {
|
|
577
|
-
kind: "service";
|
|
581
|
+
readonly kind: "service";
|
|
578
582
|
/**
|
|
579
583
|
* The fully qualified name of the service. (We omit the leading dot.)
|
|
580
584
|
*/
|
|
@@ -613,7 +617,7 @@ export interface DescService {
|
|
|
613
617
|
* Describes an RPC declaration in a protobuf source file.
|
|
614
618
|
*/
|
|
615
619
|
export interface DescMethod {
|
|
616
|
-
kind: "rpc";
|
|
620
|
+
readonly kind: "rpc";
|
|
617
621
|
/**
|
|
618
622
|
* The name of the RPC, as specified in the protobuf source.
|
|
619
623
|
*/
|
package/dist/esm/field.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EnumType } from "./enum.js";
|
|
2
2
|
import type { MessageType } from "./message-type.js";
|
|
3
|
+
import type { LongType, ScalarType } from "./scalar.js";
|
|
3
4
|
/**
|
|
4
5
|
* FieldInfo describes a field of a protobuf message for runtime reflection. We
|
|
5
6
|
* distinguish between the following kinds of fields:
|
|
@@ -16,6 +17,7 @@ import type { MessageType } from "./message-type.js";
|
|
|
16
17
|
* - "localName": The name of the field as used in generated code.
|
|
17
18
|
* - "jsonName": The name for JSON serialization / deserialization.
|
|
18
19
|
* - "opt": Whether the field is optional.
|
|
20
|
+
* - "req": Whether the field is required (a legacy proto2 feature).
|
|
19
21
|
* - "repeated": Whether the field is repeated.
|
|
20
22
|
* - "packed": Whether the repeated field is packed.
|
|
21
23
|
*
|
|
@@ -46,6 +48,7 @@ export interface OneofInfo {
|
|
|
46
48
|
readonly repeated: false;
|
|
47
49
|
readonly packed: false;
|
|
48
50
|
readonly opt: false;
|
|
51
|
+
readonly req: false;
|
|
49
52
|
readonly default: undefined;
|
|
50
53
|
readonly delimited?: undefined;
|
|
51
54
|
readonly fields: readonly FieldInfo[];
|
|
@@ -117,6 +120,10 @@ interface fiScalar extends fiShared {
|
|
|
117
120
|
* Is the field optional?
|
|
118
121
|
*/
|
|
119
122
|
readonly opt: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Is the field required? A legacy proto2 feature.
|
|
125
|
+
*/
|
|
126
|
+
readonly req: boolean;
|
|
120
127
|
/**
|
|
121
128
|
* Only proto2: An explicit default value.
|
|
122
129
|
*/
|
|
@@ -143,6 +150,10 @@ interface fiMessage extends fiShared {
|
|
|
143
150
|
* Is this repeated field packed? Never true for messages.
|
|
144
151
|
*/
|
|
145
152
|
readonly packed: false;
|
|
153
|
+
/**
|
|
154
|
+
* Is the field required? A legacy proto2 feature.
|
|
155
|
+
*/
|
|
156
|
+
readonly req: boolean;
|
|
146
157
|
/**
|
|
147
158
|
* An explicit default value (only proto2). Never set for messages.
|
|
148
159
|
*/
|
|
@@ -175,6 +186,10 @@ interface fiEnum extends fiShared {
|
|
|
175
186
|
* Is the field optional?
|
|
176
187
|
*/
|
|
177
188
|
readonly opt: boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Is the field required? A legacy proto2 feature.
|
|
191
|
+
*/
|
|
192
|
+
readonly req: boolean;
|
|
178
193
|
/**
|
|
179
194
|
* Only proto2: An explicit default value.
|
|
180
195
|
*/
|
|
@@ -230,32 +245,37 @@ interface fiMap extends fiShared {
|
|
|
230
245
|
*/
|
|
231
246
|
readonly delimited?: undefined;
|
|
232
247
|
}
|
|
233
|
-
type fiRules<T> = Omit<T, "oneof" | "repeat" | "repeated" | "packed" | "opt"> & ({
|
|
248
|
+
type fiRules<T> = Omit<T, "oneof" | "repeat" | "repeated" | "packed" | "opt" | "req"> & ({
|
|
234
249
|
readonly repeated: false;
|
|
235
250
|
readonly packed: false;
|
|
236
251
|
readonly opt: false;
|
|
252
|
+
readonly req: boolean;
|
|
237
253
|
readonly oneof: undefined;
|
|
238
254
|
} | {
|
|
239
255
|
readonly repeated: false;
|
|
240
256
|
readonly packed: false;
|
|
241
257
|
readonly opt: true;
|
|
258
|
+
readonly req: false;
|
|
242
259
|
readonly oneof: undefined;
|
|
243
260
|
} | {
|
|
244
261
|
readonly repeated: boolean;
|
|
245
262
|
readonly packed: boolean;
|
|
246
263
|
readonly opt: false;
|
|
264
|
+
readonly req: boolean;
|
|
247
265
|
readonly oneof: undefined;
|
|
248
266
|
} | {
|
|
249
267
|
readonly repeated: false;
|
|
250
268
|
readonly packed: false;
|
|
251
269
|
readonly opt: false;
|
|
270
|
+
readonly req: false;
|
|
252
271
|
readonly oneof: OneofInfo;
|
|
253
272
|
});
|
|
254
|
-
type fiPartialRules<T extends fiScalar | fiMap | fiEnum | fiMessage> = Omit<T, "jsonName" | "localName" | "oneof" | "repeat" | "repeated" | "packed" | "opt" | "default" | "L" | "delimited"> & ({
|
|
273
|
+
type fiPartialRules<T extends fiScalar | fiMap | fiEnum | fiMessage> = Omit<T, "jsonName" | "localName" | "oneof" | "repeat" | "repeated" | "packed" | "opt" | "req" | "default" | "L" | "delimited"> & ({
|
|
255
274
|
readonly jsonName?: string;
|
|
256
275
|
readonly repeated?: false;
|
|
257
276
|
readonly packed?: false;
|
|
258
277
|
readonly opt?: false;
|
|
278
|
+
readonly req?: boolean;
|
|
259
279
|
readonly oneof?: undefined;
|
|
260
280
|
default?: T["default"];
|
|
261
281
|
L?: LongType;
|
|
@@ -265,6 +285,7 @@ type fiPartialRules<T extends fiScalar | fiMap | fiEnum | fiMessage> = Omit<T, "
|
|
|
265
285
|
readonly repeated?: false;
|
|
266
286
|
readonly packed?: false;
|
|
267
287
|
readonly opt: true;
|
|
288
|
+
readonly req?: false;
|
|
268
289
|
readonly oneof?: undefined;
|
|
269
290
|
default?: T["default"];
|
|
270
291
|
L?: LongType;
|
|
@@ -274,6 +295,7 @@ type fiPartialRules<T extends fiScalar | fiMap | fiEnum | fiMessage> = Omit<T, "
|
|
|
274
295
|
readonly repeated?: boolean;
|
|
275
296
|
readonly packed?: boolean;
|
|
276
297
|
readonly opt?: false;
|
|
298
|
+
readonly req?: boolean;
|
|
277
299
|
readonly oneof?: undefined;
|
|
278
300
|
default?: T["default"];
|
|
279
301
|
L?: LongType;
|
|
@@ -283,58 +305,10 @@ type fiPartialRules<T extends fiScalar | fiMap | fiEnum | fiMessage> = Omit<T, "
|
|
|
283
305
|
readonly repeated?: false;
|
|
284
306
|
readonly packed?: false;
|
|
285
307
|
readonly opt?: false;
|
|
308
|
+
readonly req?: false;
|
|
286
309
|
readonly oneof: string;
|
|
287
310
|
default?: T["default"];
|
|
288
311
|
L?: LongType;
|
|
289
312
|
delimited?: boolean;
|
|
290
313
|
});
|
|
291
|
-
/**
|
|
292
|
-
* Scalar value types. This is a subset of field types declared by protobuf
|
|
293
|
-
* enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE
|
|
294
|
-
* are omitted, but the numerical values are identical.
|
|
295
|
-
*/
|
|
296
|
-
export declare enum ScalarType {
|
|
297
|
-
DOUBLE = 1,
|
|
298
|
-
FLOAT = 2,
|
|
299
|
-
INT64 = 3,
|
|
300
|
-
UINT64 = 4,
|
|
301
|
-
INT32 = 5,
|
|
302
|
-
FIXED64 = 6,
|
|
303
|
-
FIXED32 = 7,
|
|
304
|
-
BOOL = 8,
|
|
305
|
-
STRING = 9,
|
|
306
|
-
BYTES = 12,
|
|
307
|
-
UINT32 = 13,
|
|
308
|
-
SFIXED32 = 15,
|
|
309
|
-
SFIXED64 = 16,
|
|
310
|
-
SINT32 = 17,// Uses ZigZag encoding.
|
|
311
|
-
SINT64 = 18
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* JavaScript representation of fields with 64 bit integral types (int64, uint64,
|
|
315
|
-
* sint64, fixed64, sfixed64).
|
|
316
|
-
*
|
|
317
|
-
* This is a subset of google.protobuf.FieldOptions.JSType, which defines JS_NORMAL,
|
|
318
|
-
* JS_STRING, and JS_NUMBER. Protobuf-ES uses BigInt by default, but will use
|
|
319
|
-
* String if `[jstype = JS_STRING]` is specified.
|
|
320
|
-
*
|
|
321
|
-
* ```protobuf
|
|
322
|
-
* uint64 field_a = 1; // BigInt
|
|
323
|
-
* uint64 field_b = 2 [jstype = JS_NORMAL]; // BigInt
|
|
324
|
-
* uint64 field_b = 2 [jstype = JS_NUMBER]; // BigInt
|
|
325
|
-
* uint64 field_b = 2 [jstype = JS_STRING]; // String
|
|
326
|
-
* ```
|
|
327
|
-
*/
|
|
328
|
-
export declare enum LongType {
|
|
329
|
-
/**
|
|
330
|
-
* Use JavaScript BigInt.
|
|
331
|
-
*/
|
|
332
|
-
BIGINT = 0,
|
|
333
|
-
/**
|
|
334
|
-
* Use JavaScript String.
|
|
335
|
-
*
|
|
336
|
-
* Field option `[jstype = JS_STRING]`.
|
|
337
|
-
*/
|
|
338
|
-
STRING = 1
|
|
339
|
-
}
|
|
340
314
|
export {};
|
package/dist/esm/field.js
CHANGED
|
@@ -11,68 +11,4 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
* Scalar value types. This is a subset of field types declared by protobuf
|
|
16
|
-
* enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE
|
|
17
|
-
* are omitted, but the numerical values are identical.
|
|
18
|
-
*/
|
|
19
|
-
export var ScalarType;
|
|
20
|
-
(function (ScalarType) {
|
|
21
|
-
// 0 is reserved for errors.
|
|
22
|
-
// Order is weird for historical reasons.
|
|
23
|
-
ScalarType[ScalarType["DOUBLE"] = 1] = "DOUBLE";
|
|
24
|
-
ScalarType[ScalarType["FLOAT"] = 2] = "FLOAT";
|
|
25
|
-
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
|
|
26
|
-
// negative values are likely.
|
|
27
|
-
ScalarType[ScalarType["INT64"] = 3] = "INT64";
|
|
28
|
-
ScalarType[ScalarType["UINT64"] = 4] = "UINT64";
|
|
29
|
-
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
|
|
30
|
-
// negative values are likely.
|
|
31
|
-
ScalarType[ScalarType["INT32"] = 5] = "INT32";
|
|
32
|
-
ScalarType[ScalarType["FIXED64"] = 6] = "FIXED64";
|
|
33
|
-
ScalarType[ScalarType["FIXED32"] = 7] = "FIXED32";
|
|
34
|
-
ScalarType[ScalarType["BOOL"] = 8] = "BOOL";
|
|
35
|
-
ScalarType[ScalarType["STRING"] = 9] = "STRING";
|
|
36
|
-
// Tag-delimited aggregate.
|
|
37
|
-
// Group type is deprecated and not supported in proto3. However, Proto3
|
|
38
|
-
// implementations should still be able to parse the group wire format and
|
|
39
|
-
// treat group fields as unknown fields.
|
|
40
|
-
// TYPE_GROUP = 10,
|
|
41
|
-
// TYPE_MESSAGE = 11, // Length-delimited aggregate.
|
|
42
|
-
// New in version 2.
|
|
43
|
-
ScalarType[ScalarType["BYTES"] = 12] = "BYTES";
|
|
44
|
-
ScalarType[ScalarType["UINT32"] = 13] = "UINT32";
|
|
45
|
-
// TYPE_ENUM = 14,
|
|
46
|
-
ScalarType[ScalarType["SFIXED32"] = 15] = "SFIXED32";
|
|
47
|
-
ScalarType[ScalarType["SFIXED64"] = 16] = "SFIXED64";
|
|
48
|
-
ScalarType[ScalarType["SINT32"] = 17] = "SINT32";
|
|
49
|
-
ScalarType[ScalarType["SINT64"] = 18] = "SINT64";
|
|
50
|
-
})(ScalarType || (ScalarType = {}));
|
|
51
|
-
/**
|
|
52
|
-
* JavaScript representation of fields with 64 bit integral types (int64, uint64,
|
|
53
|
-
* sint64, fixed64, sfixed64).
|
|
54
|
-
*
|
|
55
|
-
* This is a subset of google.protobuf.FieldOptions.JSType, which defines JS_NORMAL,
|
|
56
|
-
* JS_STRING, and JS_NUMBER. Protobuf-ES uses BigInt by default, but will use
|
|
57
|
-
* String if `[jstype = JS_STRING]` is specified.
|
|
58
|
-
*
|
|
59
|
-
* ```protobuf
|
|
60
|
-
* uint64 field_a = 1; // BigInt
|
|
61
|
-
* uint64 field_b = 2 [jstype = JS_NORMAL]; // BigInt
|
|
62
|
-
* uint64 field_b = 2 [jstype = JS_NUMBER]; // BigInt
|
|
63
|
-
* uint64 field_b = 2 [jstype = JS_STRING]; // String
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
export var LongType;
|
|
67
|
-
(function (LongType) {
|
|
68
|
-
/**
|
|
69
|
-
* Use JavaScript BigInt.
|
|
70
|
-
*/
|
|
71
|
-
LongType[LongType["BIGINT"] = 0] = "BIGINT";
|
|
72
|
-
/**
|
|
73
|
-
* Use JavaScript String.
|
|
74
|
-
*
|
|
75
|
-
* Field option `[jstype = JS_STRING]`.
|
|
76
|
-
*/
|
|
77
|
-
LongType[LongType["STRING"] = 1] = "STRING";
|
|
78
|
-
})(LongType || (LongType = {}));
|
|
14
|
+
export {};
|
|
@@ -132,6 +132,24 @@ export declare class CodeGeneratorResponse extends Message<CodeGeneratorResponse
|
|
|
132
132
|
* @generated from field: optional uint64 supported_features = 2;
|
|
133
133
|
*/
|
|
134
134
|
supportedFeatures?: bigint;
|
|
135
|
+
/**
|
|
136
|
+
* The minimum edition this plugin supports. This will be treated as an
|
|
137
|
+
* Edition enum, but we want to allow unknown values. It should be specified
|
|
138
|
+
* according the edition enum value, *not* the edition number. Only takes
|
|
139
|
+
* effect for plugins that have FEATURE_SUPPORTS_EDITIONS set.
|
|
140
|
+
*
|
|
141
|
+
* @generated from field: optional int32 minimum_edition = 3;
|
|
142
|
+
*/
|
|
143
|
+
minimumEdition?: number;
|
|
144
|
+
/**
|
|
145
|
+
* The maximum edition this plugin supports. This will be treated as an
|
|
146
|
+
* Edition enum, but we want to allow unknown values. It should be specified
|
|
147
|
+
* according the edition enum value, *not* the edition number. Only takes
|
|
148
|
+
* effect for plugins that have FEATURE_SUPPORTS_EDITIONS set.
|
|
149
|
+
*
|
|
150
|
+
* @generated from field: optional int32 maximum_edition = 4;
|
|
151
|
+
*/
|
|
152
|
+
maximumEdition?: number;
|
|
135
153
|
/**
|
|
136
154
|
* @generated from field: repeated google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
|
|
137
155
|
*/
|
|
@@ -149,6 +149,8 @@ CodeGeneratorResponse.typeName = "google.protobuf.compiler.CodeGeneratorResponse
|
|
|
149
149
|
CodeGeneratorResponse.fields = proto2.util.newFieldList(() => [
|
|
150
150
|
{ no: 1, name: "error", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
|
|
151
151
|
{ no: 2, name: "supported_features", kind: "scalar", T: 4 /* ScalarType.UINT64 */, opt: true },
|
|
152
|
+
{ no: 3, name: "minimum_edition", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
|
|
153
|
+
{ no: 4, name: "maximum_edition", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
|
|
152
154
|
{ no: 15, name: "file", kind: "message", T: CodeGeneratorResponse_File, repeated: true },
|
|
153
155
|
]);
|
|
154
156
|
/**
|