@bufbuild/protobuf 1.2.0 → 1.3.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.js +1 -1
- package/dist/cjs/codegen-info.js +1 -0
- package/dist/cjs/field.js +1 -1
- package/dist/cjs/google/protobuf/any_pb.js +3 -3
- package/dist/cjs/google/protobuf/api_pb.js +1 -1
- package/dist/cjs/google/protobuf/compiler/plugin_pb.js +1 -1
- package/dist/cjs/google/protobuf/descriptor_pb.js +88 -10
- package/dist/cjs/google/protobuf/field_mask_pb.js +1 -1
- package/dist/cjs/google/protobuf/struct_pb.js +3 -3
- package/dist/cjs/google/protobuf/timestamp_pb.js +1 -1
- package/dist/cjs/google/protobuf/type_pb.js +25 -4
- package/dist/cjs/index.js +5 -4
- package/dist/cjs/private/binary-format-common.js +44 -6
- package/dist/cjs/proto-base64.js +2 -10
- package/dist/cjs/proto-delimited.js +14 -19
- package/dist/cjs/proto-double.js +29 -0
- package/dist/cjs/proto-int64.js +1 -1
- package/dist/cjs/service-type.js +2 -2
- package/dist/cjs/to-plain-message.js +67 -0
- package/dist/esm/codegen-info.js +1 -0
- package/dist/esm/create-descriptor-set.js +1 -1
- package/dist/esm/google/protobuf/any_pb.js +3 -3
- package/dist/esm/google/protobuf/api_pb.js +1 -1
- package/dist/esm/google/protobuf/descriptor_pb.js +77 -0
- package/dist/esm/google/protobuf/field_mask_pb.js +1 -1
- package/dist/esm/google/protobuf/struct_pb.js +2 -2
- package/dist/esm/google/protobuf/timestamp_pb.js +1 -1
- package/dist/esm/google/protobuf/type_pb.js +22 -1
- package/dist/esm/index.js +3 -4
- package/dist/esm/private/binary-format-common.js +45 -7
- package/dist/esm/private/message-type.js +1 -1
- package/dist/esm/private/util-common.js +1 -1
- package/dist/esm/proto-base64.js +2 -10
- package/dist/esm/proto-delimited.js +14 -19
- package/dist/esm/proto-double.js +26 -0
- package/dist/esm/proto-int64.js +1 -1
- package/dist/esm/to-plain-message.js +63 -0
- package/dist/types/codegen-info.d.ts +1 -1
- package/dist/types/google/protobuf/any_pb.d.ts +3 -3
- package/dist/types/google/protobuf/api_pb.d.ts +1 -1
- package/dist/types/google/protobuf/descriptor_pb.d.ts +107 -3
- package/dist/types/google/protobuf/struct_pb.d.ts +1 -1
- package/dist/types/google/protobuf/timestamp_pb.d.ts +1 -1
- package/dist/types/google/protobuf/type_pb.d.ts +19 -1
- package/dist/types/index.d.ts +7 -4
- package/dist/types/private/binary-format-common.d.ts +3 -2
- package/dist/types/private/json-format-common.d.ts +2 -1
- package/dist/types/private/message-type.d.ts +2 -1
- package/dist/types/private/scalars.d.ts +2 -1
- package/dist/types/proto-base64.d.ts +1 -9
- package/dist/types/proto-double.d.ts +5 -0
- package/dist/types/to-plain-message.d.ts +9 -0
- package/package.json +2 -2
package/dist/cjs/service-type.js
CHANGED
|
@@ -29,7 +29,7 @@ var MethodKind;
|
|
|
29
29
|
MethodKind[MethodKind["ServerStreaming"] = 1] = "ServerStreaming";
|
|
30
30
|
MethodKind[MethodKind["ClientStreaming"] = 2] = "ClientStreaming";
|
|
31
31
|
MethodKind[MethodKind["BiDiStreaming"] = 3] = "BiDiStreaming";
|
|
32
|
-
})(MethodKind
|
|
32
|
+
})(MethodKind || (exports.MethodKind = MethodKind = {}));
|
|
33
33
|
/**
|
|
34
34
|
* Is this method side-effect-free (or safe in HTTP parlance), or just
|
|
35
35
|
* idempotent, or neither? HTTP based RPC implementation may choose GET verb
|
|
@@ -50,4 +50,4 @@ var MethodIdempotency;
|
|
|
50
50
|
* Idempotent, but may have side effects.
|
|
51
51
|
*/
|
|
52
52
|
MethodIdempotency[MethodIdempotency["Idempotent"] = 2] = "Idempotent";
|
|
53
|
-
})(MethodIdempotency
|
|
53
|
+
})(MethodIdempotency || (exports.MethodIdempotency = MethodIdempotency = {}));
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021-2023 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.toPlainMessage = void 0;
|
|
17
|
+
/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-argument,no-case-declarations */
|
|
18
|
+
const message_js_1 = require("./message.js");
|
|
19
|
+
/**
|
|
20
|
+
* toPlainMessage returns a new object by striping
|
|
21
|
+
* all methods from a message, leaving only fields and
|
|
22
|
+
* oneof groups. It is recursive, meaning it applies this
|
|
23
|
+
* same logic to all nested message fields as well.
|
|
24
|
+
*/
|
|
25
|
+
function toPlainMessage(message) {
|
|
26
|
+
const type = message.getType();
|
|
27
|
+
const target = {};
|
|
28
|
+
for (const member of type.fields.byMember()) {
|
|
29
|
+
const source = message[member.localName];
|
|
30
|
+
let copy;
|
|
31
|
+
if (member.repeated) {
|
|
32
|
+
copy = source.map((e) => toPlainValue(e));
|
|
33
|
+
}
|
|
34
|
+
else if (member.kind == "map") {
|
|
35
|
+
copy = {};
|
|
36
|
+
for (const [key, v] of Object.entries(source)) {
|
|
37
|
+
copy[key] = toPlainValue(v);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else if (member.kind == "oneof") {
|
|
41
|
+
const f = member.findField(source.case);
|
|
42
|
+
copy = f
|
|
43
|
+
? { case: source.case, value: toPlainValue(source.value) }
|
|
44
|
+
: { case: undefined };
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
copy = toPlainValue(source);
|
|
48
|
+
}
|
|
49
|
+
target[member.localName] = copy;
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
exports.toPlainMessage = toPlainMessage;
|
|
54
|
+
function toPlainValue(value) {
|
|
55
|
+
if (value === undefined) {
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
if (value instanceof message_js_1.Message) {
|
|
59
|
+
return toPlainMessage(value);
|
|
60
|
+
}
|
|
61
|
+
if (value instanceof Uint8Array) {
|
|
62
|
+
const c = new Uint8Array(value.byteLength);
|
|
63
|
+
c.set(value);
|
|
64
|
+
return c;
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
package/dist/esm/codegen-info.js
CHANGED
|
@@ -39,6 +39,7 @@ export const codegenInfo = {
|
|
|
39
39
|
JsonWriteOptions: { typeOnly: true, privateImportPath: "./json-format.js", publicImportPath: packageName },
|
|
40
40
|
JsonValue: { typeOnly: true, privateImportPath: "./json-format.js", publicImportPath: packageName },
|
|
41
41
|
JsonObject: { typeOnly: true, privateImportPath: "./json-format.js", publicImportPath: packageName },
|
|
42
|
+
protoDouble: { typeOnly: false, privateImportPath: "./proto-double.js", publicImportPath: packageName },
|
|
42
43
|
protoInt64: { typeOnly: false, privateImportPath: "./proto-int64.js", publicImportPath: packageName },
|
|
43
44
|
ScalarType: { typeOnly: false, privateImportPath: "./field.js", publicImportPath: packageName },
|
|
44
45
|
MethodKind: { typeOnly: false, privateImportPath: "./service-type.js", publicImportPath: packageName },
|
|
@@ -11,7 +11,7 @@
|
|
|
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
|
-
import { FieldDescriptorProto_Label, FieldDescriptorProto_Type, FileDescriptorSet, MethodOptions_IdempotencyLevel, } from "./google/protobuf/descriptor_pb.js";
|
|
14
|
+
import { FieldDescriptorProto_Label, FieldDescriptorProto_Type, FileDescriptorProto, FileDescriptorSet, MethodDescriptorProto, MethodOptions_IdempotencyLevel, ServiceDescriptorProto, SourceCodeInfo, } from "./google/protobuf/descriptor_pb.js";
|
|
15
15
|
import { assert } from "./private/assert.js";
|
|
16
16
|
import { ScalarType } from "./field.js";
|
|
17
17
|
import { MethodIdempotency, MethodKind } from "./service-type.js";
|
|
@@ -43,7 +43,7 @@ import { proto3 } from "../../proto3.js";
|
|
|
43
43
|
* foo = any.unpack(Foo.getDefaultInstance());
|
|
44
44
|
* }
|
|
45
45
|
*
|
|
46
|
-
*
|
|
46
|
+
* Example 3: Pack and unpack a message in Python.
|
|
47
47
|
*
|
|
48
48
|
* foo = Foo(...)
|
|
49
49
|
* any = Any()
|
|
@@ -53,7 +53,7 @@ import { proto3 } from "../../proto3.js";
|
|
|
53
53
|
* any.Unpack(foo)
|
|
54
54
|
* ...
|
|
55
55
|
*
|
|
56
|
-
*
|
|
56
|
+
* Example 4: Pack and unpack a message in Go
|
|
57
57
|
*
|
|
58
58
|
* foo := &pb.Foo{...}
|
|
59
59
|
* any, err := anypb.New(foo)
|
|
@@ -73,7 +73,7 @@ import { proto3 } from "../../proto3.js";
|
|
|
73
73
|
* name "y.z".
|
|
74
74
|
*
|
|
75
75
|
* JSON
|
|
76
|
-
*
|
|
76
|
+
* ====
|
|
77
77
|
* The JSON representation of an `Any` value uses the regular
|
|
78
78
|
* representation of the deserialized, embedded message, with an
|
|
79
79
|
* additional field `@type` which contains the type URL. Example:
|
|
@@ -237,7 +237,7 @@ Method.fields = proto3.util.newFieldList(() => [
|
|
|
237
237
|
* The mixin construct implies that all methods in `AccessControl` are
|
|
238
238
|
* also declared with same name and request/response types in
|
|
239
239
|
* `Storage`. A documentation generator or annotation processor will
|
|
240
|
-
* see the effective `Storage.GetAcl` method after
|
|
240
|
+
* see the effective `Storage.GetAcl` method after inherting
|
|
241
241
|
* documentation and annotations as follows:
|
|
242
242
|
*
|
|
243
243
|
* service Storage {
|
|
@@ -266,6 +266,15 @@ export class ExtensionRangeOptions extends Message {
|
|
|
266
266
|
* @generated from field: repeated google.protobuf.UninterpretedOption uninterpreted_option = 999;
|
|
267
267
|
*/
|
|
268
268
|
this.uninterpretedOption = [];
|
|
269
|
+
/**
|
|
270
|
+
* go/protobuf-stripping-extension-declarations
|
|
271
|
+
* Like Metadata, but we use a repeated field to hold all extension
|
|
272
|
+
* declarations. This should avoid the size increases of transforming a large
|
|
273
|
+
* extension range into small ranges in generated binaries.
|
|
274
|
+
*
|
|
275
|
+
* @generated from field: repeated google.protobuf.ExtensionRangeOptions.Declaration declaration = 2;
|
|
276
|
+
*/
|
|
277
|
+
this.declaration = [];
|
|
269
278
|
proto2.util.initPartial(data, this);
|
|
270
279
|
}
|
|
271
280
|
static fromBinary(bytes, options) {
|
|
@@ -285,6 +294,62 @@ ExtensionRangeOptions.runtime = proto2;
|
|
|
285
294
|
ExtensionRangeOptions.typeName = "google.protobuf.ExtensionRangeOptions";
|
|
286
295
|
ExtensionRangeOptions.fields = proto2.util.newFieldList(() => [
|
|
287
296
|
{ no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
|
|
297
|
+
{ no: 2, name: "declaration", kind: "message", T: ExtensionRangeOptions_Declaration, repeated: true },
|
|
298
|
+
{ no: 3, name: "verification", kind: "enum", T: proto2.getEnumType(ExtensionRangeOptions_VerificationState), opt: true, default: ExtensionRangeOptions_VerificationState.UNVERIFIED },
|
|
299
|
+
]);
|
|
300
|
+
/**
|
|
301
|
+
* The verification state of the extension range.
|
|
302
|
+
*
|
|
303
|
+
* @generated from enum google.protobuf.ExtensionRangeOptions.VerificationState
|
|
304
|
+
*/
|
|
305
|
+
export var ExtensionRangeOptions_VerificationState;
|
|
306
|
+
(function (ExtensionRangeOptions_VerificationState) {
|
|
307
|
+
/**
|
|
308
|
+
* All the extensions of the range must be declared.
|
|
309
|
+
*
|
|
310
|
+
* @generated from enum value: DECLARATION = 0;
|
|
311
|
+
*/
|
|
312
|
+
ExtensionRangeOptions_VerificationState[ExtensionRangeOptions_VerificationState["DECLARATION"] = 0] = "DECLARATION";
|
|
313
|
+
/**
|
|
314
|
+
* @generated from enum value: UNVERIFIED = 1;
|
|
315
|
+
*/
|
|
316
|
+
ExtensionRangeOptions_VerificationState[ExtensionRangeOptions_VerificationState["UNVERIFIED"] = 1] = "UNVERIFIED";
|
|
317
|
+
})(ExtensionRangeOptions_VerificationState || (ExtensionRangeOptions_VerificationState = {}));
|
|
318
|
+
// Retrieve enum metadata with: proto2.getEnumType(ExtensionRangeOptions_VerificationState)
|
|
319
|
+
proto2.util.setEnumType(ExtensionRangeOptions_VerificationState, "google.protobuf.ExtensionRangeOptions.VerificationState", [
|
|
320
|
+
{ no: 0, name: "DECLARATION" },
|
|
321
|
+
{ no: 1, name: "UNVERIFIED" },
|
|
322
|
+
]);
|
|
323
|
+
/**
|
|
324
|
+
* @generated from message google.protobuf.ExtensionRangeOptions.Declaration
|
|
325
|
+
*/
|
|
326
|
+
export class ExtensionRangeOptions_Declaration extends Message {
|
|
327
|
+
constructor(data) {
|
|
328
|
+
super();
|
|
329
|
+
proto2.util.initPartial(data, this);
|
|
330
|
+
}
|
|
331
|
+
static fromBinary(bytes, options) {
|
|
332
|
+
return new ExtensionRangeOptions_Declaration().fromBinary(bytes, options);
|
|
333
|
+
}
|
|
334
|
+
static fromJson(jsonValue, options) {
|
|
335
|
+
return new ExtensionRangeOptions_Declaration().fromJson(jsonValue, options);
|
|
336
|
+
}
|
|
337
|
+
static fromJsonString(jsonString, options) {
|
|
338
|
+
return new ExtensionRangeOptions_Declaration().fromJsonString(jsonString, options);
|
|
339
|
+
}
|
|
340
|
+
static equals(a, b) {
|
|
341
|
+
return proto2.util.equals(ExtensionRangeOptions_Declaration, a, b);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
ExtensionRangeOptions_Declaration.runtime = proto2;
|
|
345
|
+
ExtensionRangeOptions_Declaration.typeName = "google.protobuf.ExtensionRangeOptions.Declaration";
|
|
346
|
+
ExtensionRangeOptions_Declaration.fields = proto2.util.newFieldList(() => [
|
|
347
|
+
{ no: 1, name: "number", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
|
|
348
|
+
{ no: 2, name: "full_name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
|
|
349
|
+
{ no: 3, name: "type", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
|
|
350
|
+
{ no: 4, name: "is_repeated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
|
|
351
|
+
{ no: 5, name: "reserved", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
|
|
352
|
+
{ no: 6, name: "repeated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
|
|
288
353
|
]);
|
|
289
354
|
/**
|
|
290
355
|
* Describes a field within a message.
|
|
@@ -812,6 +877,10 @@ MessageOptions.fields = proto2.util.newFieldList(() => [
|
|
|
812
877
|
export class FieldOptions extends Message {
|
|
813
878
|
constructor(data) {
|
|
814
879
|
super();
|
|
880
|
+
/**
|
|
881
|
+
* @generated from field: repeated google.protobuf.FieldOptions.OptionTargetType targets = 19;
|
|
882
|
+
*/
|
|
883
|
+
this.targets = [];
|
|
815
884
|
/**
|
|
816
885
|
* The parser stores options it doesn't recognize here. See above.
|
|
817
886
|
*
|
|
@@ -846,6 +915,7 @@ FieldOptions.fields = proto2.util.newFieldList(() => [
|
|
|
846
915
|
{ no: 16, name: "debug_redact", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
|
|
847
916
|
{ no: 17, name: "retention", kind: "enum", T: proto2.getEnumType(FieldOptions_OptionRetention), opt: true },
|
|
848
917
|
{ no: 18, name: "target", kind: "enum", T: proto2.getEnumType(FieldOptions_OptionTargetType), opt: true },
|
|
918
|
+
{ no: 19, name: "targets", kind: "enum", T: proto2.getEnumType(FieldOptions_OptionTargetType), repeated: true },
|
|
849
919
|
{ no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
|
|
850
920
|
]);
|
|
851
921
|
/**
|
|
@@ -860,6 +930,13 @@ export var FieldOptions_CType;
|
|
|
860
930
|
*/
|
|
861
931
|
FieldOptions_CType[FieldOptions_CType["STRING"] = 0] = "STRING";
|
|
862
932
|
/**
|
|
933
|
+
* The option [ctype=CORD] may be applied to a non-repeated field of type
|
|
934
|
+
* "bytes". It indicates that in C++, the data should be stored in a Cord
|
|
935
|
+
* instead of a string. For very large strings, this may reduce memory
|
|
936
|
+
* fragmentation. It may also allow better performance when parsing from a
|
|
937
|
+
* Cord, or when parsing with aliasing enabled, as the parsed Cord may then
|
|
938
|
+
* alias the original buffer.
|
|
939
|
+
*
|
|
863
940
|
* @generated from enum value: CORD = 1;
|
|
864
941
|
*/
|
|
865
942
|
FieldOptions_CType[FieldOptions_CType["CORD"] = 1] = "CORD";
|
|
@@ -265,7 +265,7 @@ export class FieldMask extends Message {
|
|
|
265
265
|
}
|
|
266
266
|
return this.paths.map(p => {
|
|
267
267
|
if (p.match(/_[0-9]?_/g) || p.match(/[A-Z]/g)) {
|
|
268
|
-
throw new Error("cannot
|
|
268
|
+
throw new Error("cannot encode google.protobuf.FieldMask to JSON: lowerCamelCase of path name \"" + p + "\" is irreversible");
|
|
269
269
|
}
|
|
270
270
|
return protoCamelCase(p);
|
|
271
271
|
}).join(",");
|
|
@@ -11,7 +11,7 @@
|
|
|
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
|
-
// @generated by protoc-gen-es v1.
|
|
14
|
+
// @generated by protoc-gen-es v1.3.0 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
|
|
15
15
|
// @generated from file google/protobuf/struct.proto (package google.protobuf, syntax proto3)
|
|
16
16
|
/* eslint-disable */
|
|
17
17
|
import { proto3 } from "../../proto3.js";
|
|
@@ -20,7 +20,7 @@ import { Message } from "../../message.js";
|
|
|
20
20
|
* `NullValue` is a singleton enumeration to represent the null value for the
|
|
21
21
|
* `Value` type union.
|
|
22
22
|
*
|
|
23
|
-
*
|
|
23
|
+
* The JSON representation for `NullValue` is JSON `null`.
|
|
24
24
|
*
|
|
25
25
|
* @generated from enum google.protobuf.NullValue
|
|
26
26
|
*/
|
|
@@ -102,7 +102,7 @@ import { proto3 } from "../../proto3.js";
|
|
|
102
102
|
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
|
103
103
|
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
|
104
104
|
* the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
|
105
|
-
* http://
|
|
105
|
+
* http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
|
|
106
106
|
* ) to obtain a formatter capable of generating timestamps in this format.
|
|
107
107
|
*
|
|
108
108
|
*
|
|
@@ -11,7 +11,7 @@
|
|
|
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
|
-
// @generated by protoc-gen-es v1.
|
|
14
|
+
// @generated by protoc-gen-es v1.3.0 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
|
|
15
15
|
// @generated from file google/protobuf/type.proto (package google.protobuf, syntax proto3)
|
|
16
16
|
/* eslint-disable */
|
|
17
17
|
import { proto3 } from "../../proto3.js";
|
|
@@ -37,11 +37,18 @@ export var Syntax;
|
|
|
37
37
|
* @generated from enum value: SYNTAX_PROTO3 = 1;
|
|
38
38
|
*/
|
|
39
39
|
Syntax[Syntax["PROTO3"] = 1] = "PROTO3";
|
|
40
|
+
/**
|
|
41
|
+
* Syntax `editions`.
|
|
42
|
+
*
|
|
43
|
+
* @generated from enum value: SYNTAX_EDITIONS = 2;
|
|
44
|
+
*/
|
|
45
|
+
Syntax[Syntax["EDITIONS"] = 2] = "EDITIONS";
|
|
40
46
|
})(Syntax || (Syntax = {}));
|
|
41
47
|
// Retrieve enum metadata with: proto3.getEnumType(Syntax)
|
|
42
48
|
proto3.util.setEnumType(Syntax, "google.protobuf.Syntax", [
|
|
43
49
|
{ no: 0, name: "SYNTAX_PROTO2" },
|
|
44
50
|
{ no: 1, name: "SYNTAX_PROTO3" },
|
|
51
|
+
{ no: 2, name: "SYNTAX_EDITIONS" },
|
|
45
52
|
]);
|
|
46
53
|
/**
|
|
47
54
|
* A protocol buffer message type.
|
|
@@ -81,6 +88,12 @@ export class Type extends Message {
|
|
|
81
88
|
* @generated from field: google.protobuf.Syntax syntax = 6;
|
|
82
89
|
*/
|
|
83
90
|
this.syntax = Syntax.PROTO2;
|
|
91
|
+
/**
|
|
92
|
+
* The source edition string, only valid when syntax is SYNTAX_EDITIONS.
|
|
93
|
+
*
|
|
94
|
+
* @generated from field: string edition = 7;
|
|
95
|
+
*/
|
|
96
|
+
this.edition = "";
|
|
84
97
|
proto3.util.initPartial(data, this);
|
|
85
98
|
}
|
|
86
99
|
static fromBinary(bytes, options) {
|
|
@@ -105,6 +118,7 @@ Type.fields = proto3.util.newFieldList(() => [
|
|
|
105
118
|
{ no: 4, name: "options", kind: "message", T: Option, repeated: true },
|
|
106
119
|
{ no: 5, name: "source_context", kind: "message", T: SourceContext },
|
|
107
120
|
{ no: 6, name: "syntax", kind: "enum", T: proto3.getEnumType(Syntax) },
|
|
121
|
+
{ no: 7, name: "edition", kind: "scalar", T: 9 /* ScalarType.STRING */ },
|
|
108
122
|
]);
|
|
109
123
|
/**
|
|
110
124
|
* A single field of a message type.
|
|
@@ -420,6 +434,12 @@ export class Enum extends Message {
|
|
|
420
434
|
* @generated from field: google.protobuf.Syntax syntax = 5;
|
|
421
435
|
*/
|
|
422
436
|
this.syntax = Syntax.PROTO2;
|
|
437
|
+
/**
|
|
438
|
+
* The source edition string, only valid when syntax is SYNTAX_EDITIONS.
|
|
439
|
+
*
|
|
440
|
+
* @generated from field: string edition = 6;
|
|
441
|
+
*/
|
|
442
|
+
this.edition = "";
|
|
423
443
|
proto3.util.initPartial(data, this);
|
|
424
444
|
}
|
|
425
445
|
static fromBinary(bytes, options) {
|
|
@@ -443,6 +463,7 @@ Enum.fields = proto3.util.newFieldList(() => [
|
|
|
443
463
|
{ no: 3, name: "options", kind: "message", T: Option, repeated: true },
|
|
444
464
|
{ no: 4, name: "source_context", kind: "message", T: SourceContext },
|
|
445
465
|
{ no: 5, name: "syntax", kind: "enum", T: proto3.getEnumType(Syntax) },
|
|
466
|
+
{ no: 6, name: "edition", kind: "scalar", T: 9 /* ScalarType.STRING */ },
|
|
446
467
|
]);
|
|
447
468
|
/**
|
|
448
469
|
* Enum value definition.
|
package/dist/esm/index.js
CHANGED
|
@@ -13,20 +13,19 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
export { proto3 } from "./proto3.js";
|
|
15
15
|
export { proto2 } from "./proto2.js";
|
|
16
|
+
export { protoDouble } from "./proto-double.js";
|
|
16
17
|
export { protoInt64 } from "./proto-int64.js";
|
|
17
18
|
export { protoBase64 } from "./proto-base64.js";
|
|
18
19
|
export { protoDelimited } from "./proto-delimited.js";
|
|
19
20
|
export { codegenInfo } from "./codegen-info.js";
|
|
20
|
-
export { Message
|
|
21
|
+
export { Message } from "./message.js";
|
|
21
22
|
export { ScalarType } from "./field.js";
|
|
22
23
|
export { MethodKind, MethodIdempotency } from "./service-type.js";
|
|
23
24
|
export { WireType, BinaryWriter, BinaryReader } from "./binary-encoding.js";
|
|
24
|
-
export {} from "./json-format.js";
|
|
25
|
-
export {} from "./descriptor-set.js";
|
|
26
25
|
export { createDescriptorSet } from "./create-descriptor-set.js";
|
|
27
|
-
export {} from "./type-registry.js";
|
|
28
26
|
export { createRegistry } from "./create-registry.js";
|
|
29
27
|
export { createRegistryFromDescriptors } from "./create-registry-from-desc.js";
|
|
28
|
+
export { toPlainMessage } from "./to-plain-message.js";
|
|
30
29
|
// ideally, we would export these types with sub-path exports:
|
|
31
30
|
export * from "./google/protobuf/compiler/plugin_pb.js";
|
|
32
31
|
export * from "./google/protobuf/api_pb.js";
|
|
@@ -11,7 +11,7 @@
|
|
|
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
|
-
import { BinaryReader, BinaryWriter, WireType
|
|
14
|
+
import { BinaryReader, BinaryWriter, WireType } from "../binary-encoding.js";
|
|
15
15
|
import { Message } from "../message.js";
|
|
16
16
|
import { ScalarType } from "../field.js";
|
|
17
17
|
import { wrapField } from "./field-wrapper.js";
|
|
@@ -109,14 +109,14 @@ export function makeBinaryFormatCommon() {
|
|
|
109
109
|
const messageType = field.T;
|
|
110
110
|
if (repeated) {
|
|
111
111
|
// safe to assume presence of array, oneof cannot contain repeated values
|
|
112
|
-
target[localName].push(
|
|
112
|
+
target[localName].push(readMessageField(reader, new messageType(), options));
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
115
115
|
if (target[localName] instanceof Message) {
|
|
116
|
-
target[localName]
|
|
116
|
+
readMessageField(reader, target[localName], options);
|
|
117
117
|
}
|
|
118
118
|
else {
|
|
119
|
-
target[localName] =
|
|
119
|
+
target[localName] = readMessageField(reader, new messageType(), options);
|
|
120
120
|
if (messageType.fieldWrapper &&
|
|
121
121
|
!field.oneof &&
|
|
122
122
|
!field.repeated) {
|
|
@@ -135,6 +135,13 @@ export function makeBinaryFormatCommon() {
|
|
|
135
135
|
},
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
|
+
// Read a message, avoiding MessageType.fromBinary() to re-use the
|
|
139
|
+
// BinaryReadOptions and the IBinaryReader.
|
|
140
|
+
function readMessageField(reader, message, options) {
|
|
141
|
+
const format = message.getType().runtime.bin;
|
|
142
|
+
format.readMessage(message, reader, reader.uint32(), options);
|
|
143
|
+
return message;
|
|
144
|
+
}
|
|
138
145
|
// Read a map field, expecting key field = 1, value field = 2
|
|
139
146
|
function readMapEntry(field, reader, options) {
|
|
140
147
|
const length = reader.uint32(), end = reader.pos + length;
|
|
@@ -154,7 +161,7 @@ function readMapEntry(field, reader, options) {
|
|
|
154
161
|
val = reader.int32();
|
|
155
162
|
break;
|
|
156
163
|
case "message":
|
|
157
|
-
val = field.V.T
|
|
164
|
+
val = readMessageField(reader, new field.V.T(), options);
|
|
158
165
|
break;
|
|
159
166
|
}
|
|
160
167
|
break;
|
|
@@ -185,9 +192,40 @@ function readMapEntry(field, reader, options) {
|
|
|
185
192
|
}
|
|
186
193
|
return [key, val];
|
|
187
194
|
}
|
|
195
|
+
// Does not use scalarTypeInfo() for better performance.
|
|
188
196
|
function readScalar(reader, type) {
|
|
189
|
-
|
|
190
|
-
|
|
197
|
+
switch (type) {
|
|
198
|
+
case ScalarType.STRING:
|
|
199
|
+
return reader.string();
|
|
200
|
+
case ScalarType.BOOL:
|
|
201
|
+
return reader.bool();
|
|
202
|
+
case ScalarType.DOUBLE:
|
|
203
|
+
return reader.double();
|
|
204
|
+
case ScalarType.FLOAT:
|
|
205
|
+
return reader.float();
|
|
206
|
+
case ScalarType.INT32:
|
|
207
|
+
return reader.int32();
|
|
208
|
+
case ScalarType.INT64:
|
|
209
|
+
return reader.int64();
|
|
210
|
+
case ScalarType.UINT64:
|
|
211
|
+
return reader.uint64();
|
|
212
|
+
case ScalarType.FIXED64:
|
|
213
|
+
return reader.fixed64();
|
|
214
|
+
case ScalarType.BYTES:
|
|
215
|
+
return reader.bytes();
|
|
216
|
+
case ScalarType.FIXED32:
|
|
217
|
+
return reader.fixed32();
|
|
218
|
+
case ScalarType.SFIXED32:
|
|
219
|
+
return reader.sfixed32();
|
|
220
|
+
case ScalarType.SFIXED64:
|
|
221
|
+
return reader.sfixed64();
|
|
222
|
+
case ScalarType.SINT64:
|
|
223
|
+
return reader.sint64();
|
|
224
|
+
case ScalarType.UINT32:
|
|
225
|
+
return reader.uint32();
|
|
226
|
+
case ScalarType.SINT32:
|
|
227
|
+
return reader.sint32();
|
|
228
|
+
}
|
|
191
229
|
}
|
|
192
230
|
export function writeMapEntry(writer, options, field, key, value) {
|
|
193
231
|
writer.tag(field.no, WireType.LengthDelimited);
|
|
@@ -11,7 +11,7 @@
|
|
|
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
|
-
import { Message
|
|
14
|
+
import { Message } from "../message.js";
|
|
15
15
|
/**
|
|
16
16
|
* Create a new message type using the given runtime.
|
|
17
17
|
*/
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
import { setEnumType } from "./enum.js";
|
|
15
|
-
import { Message
|
|
15
|
+
import { Message } from "../message.js";
|
|
16
16
|
import { ScalarType } from "../field.js";
|
|
17
17
|
import { scalarEquals } from "./scalars.js";
|
|
18
18
|
/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-argument,no-case-declarations */
|
package/dist/esm/proto-base64.js
CHANGED
|
@@ -87,15 +87,7 @@ export const protoBase64 = {
|
|
|
87
87
|
return bytes.subarray(0, bytePos);
|
|
88
88
|
},
|
|
89
89
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* - ignores white-space, including line breaks and tabs
|
|
93
|
-
* - allows inner padding (can decode concatenated base64 strings)
|
|
94
|
-
* - does not require padding
|
|
95
|
-
* - understands base64url encoding:
|
|
96
|
-
* "-" instead of "+",
|
|
97
|
-
* "_" instead of "/",
|
|
98
|
-
* no padding
|
|
90
|
+
* Encode a byte array to a base64 string.
|
|
99
91
|
*/
|
|
100
92
|
enc(bytes) {
|
|
101
93
|
let base64 = "", groupPos = 0, // position in base64 group
|
|
@@ -121,7 +113,7 @@ export const protoBase64 = {
|
|
|
121
113
|
break;
|
|
122
114
|
}
|
|
123
115
|
}
|
|
124
|
-
// padding
|
|
116
|
+
// add output padding
|
|
125
117
|
if (groupPos) {
|
|
126
118
|
base64 += encTable[p];
|
|
127
119
|
base64 += "=";
|
|
@@ -72,28 +72,23 @@ export const protoDelimited = {
|
|
|
72
72
|
}
|
|
73
73
|
let buffer = new Uint8Array(0);
|
|
74
74
|
try {
|
|
75
|
-
for (var _d = true, iterable_1 = __asyncValues(iterable), iterable_1_1; iterable_1_1 = yield __await(iterable_1.next()), _a = iterable_1_1.done, !_a;) {
|
|
75
|
+
for (var _d = true, iterable_1 = __asyncValues(iterable), iterable_1_1; iterable_1_1 = yield __await(iterable_1.next()), _a = iterable_1_1.done, !_a; _d = true) {
|
|
76
76
|
_c = iterable_1_1.value;
|
|
77
77
|
_d = false;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
if (size.offset + size.size > buffer.byteLength) {
|
|
88
|
-
// message is incomplete, buffer more data
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
yield yield __await(protoDelimited.dec(type, buffer));
|
|
92
|
-
buffer = buffer.subarray(size.offset + size.size);
|
|
78
|
+
const chunk = _c;
|
|
79
|
+
buffer = append(buffer, chunk);
|
|
80
|
+
for (;;) {
|
|
81
|
+
const size = protoDelimited.peekSize(buffer);
|
|
82
|
+
if (size.eof) {
|
|
83
|
+
// size is incomplete, buffer more data
|
|
84
|
+
break;
|
|
93
85
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
if (size.offset + size.size > buffer.byteLength) {
|
|
87
|
+
// message is incomplete, buffer more data
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
yield yield __await(protoDelimited.dec(type, buffer));
|
|
91
|
+
buffer = buffer.subarray(size.offset + size.size);
|
|
97
92
|
}
|
|
98
93
|
}
|
|
99
94
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright 2021-2023 Buf Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
// Export global Number constants. This is done so that we can safely use
|
|
15
|
+
// these global constants when generating code and be assured we're using
|
|
16
|
+
// the correct values. We cannot rely on globalThis since we support ES2017
|
|
17
|
+
// and globalThis was introduced in ES2020. We also don't want to explicitly
|
|
18
|
+
// generate code using, for example, Number.NaN, since this could clash with
|
|
19
|
+
// a message name of Number. Instead we can export them here since this will
|
|
20
|
+
// be in a different scope as the generated code and we are guaranteed to use
|
|
21
|
+
// the intended global values.
|
|
22
|
+
export const protoDouble = {
|
|
23
|
+
NaN: Number.NaN,
|
|
24
|
+
POSITIVE_INFINITY: Number.POSITIVE_INFINITY,
|
|
25
|
+
NEGATIVE_INFINITY: Number.NEGATIVE_INFINITY,
|
|
26
|
+
};
|
package/dist/esm/proto-int64.js
CHANGED
|
@@ -16,7 +16,7 @@ import { int64FromString, int64ToString, uInt64ToString, } from "./google/varint
|
|
|
16
16
|
function makeInt64Support() {
|
|
17
17
|
const dv = new DataView(new ArrayBuffer(8));
|
|
18
18
|
// note that Safari 14 implements BigInt, but not the DataView methods
|
|
19
|
-
const ok =
|
|
19
|
+
const ok = typeof BigInt === "function" &&
|
|
20
20
|
typeof dv.getBigInt64 === "function" &&
|
|
21
21
|
typeof dv.getBigUint64 === "function" &&
|
|
22
22
|
typeof dv.setBigInt64 === "function" &&
|