@bufbuild/protobuf 2.0.0-alpha.1 → 2.0.0-alpha.3
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/README.md +1 -1
- package/dist/cjs/clone.d.ts +1 -1
- package/dist/cjs/clone.js +2 -2
- package/dist/cjs/codegenv1/boot.d.ts +1 -1
- package/dist/cjs/codegenv1/boot.js +3 -5
- package/dist/cjs/codegenv1/embed.d.ts +2 -2
- package/dist/cjs/codegenv1/embed.js +51 -46
- package/dist/cjs/codegenv1/enum.d.ts +1 -1
- package/dist/cjs/codegenv1/enum.js +2 -4
- package/dist/cjs/codegenv1/extension.d.ts +1 -1
- package/dist/cjs/codegenv1/file.d.ts +1 -1
- package/dist/cjs/codegenv1/file.js +5 -7
- package/dist/cjs/codegenv1/index.d.ts +1 -0
- package/dist/cjs/codegenv1/index.js +1 -0
- package/dist/cjs/codegenv1/message.d.ts +1 -1
- package/dist/cjs/codegenv1/restore-json-names.d.ts +3 -0
- package/dist/cjs/codegenv1/restore-json-names.js +3 -0
- package/dist/cjs/codegenv1/scalar.d.ts +5 -0
- package/dist/cjs/codegenv1/scalar.js +39 -0
- package/dist/cjs/codegenv1/service.d.ts +3 -3
- package/dist/cjs/codegenv1/symbols.d.ts +9 -0
- package/dist/cjs/codegenv1/symbols.js +9 -0
- package/dist/cjs/codegenv1/types.d.ts +59 -8
- package/dist/cjs/create.d.ts +1 -1
- package/dist/cjs/create.js +13 -23
- package/dist/cjs/{desc-types.d.ts → descriptors.d.ts} +66 -17
- package/dist/cjs/descriptors.js +53 -0
- package/dist/cjs/equals.d.ts +1 -1
- package/dist/cjs/extensions.d.ts +21 -1
- package/dist/cjs/extensions.js +42 -10
- package/dist/cjs/fields.d.ts +17 -16
- package/dist/cjs/fields.js +17 -10
- package/dist/cjs/from-binary.d.ts +2 -2
- package/dist/cjs/from-binary.js +31 -41
- package/dist/cjs/from-json.d.ts +4 -4
- package/dist/cjs/from-json.js +200 -185
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.js +5 -2
- package/dist/cjs/is-message.d.ts +1 -1
- package/dist/cjs/proto-int64.d.ts +4 -1
- package/dist/cjs/proto-int64.js +16 -6
- package/dist/cjs/reflect/error.d.ts +1 -1
- package/dist/cjs/reflect/guard.d.ts +1 -1
- package/dist/cjs/reflect/index.d.ts +0 -1
- package/dist/cjs/reflect/index.js +0 -1
- package/dist/cjs/reflect/names.d.ts +1 -13
- package/dist/cjs/reflect/names.js +2 -40
- package/dist/cjs/reflect/nested-types.d.ts +11 -1
- package/dist/cjs/reflect/nested-types.js +34 -1
- package/dist/cjs/reflect/reflect-check.d.ts +10 -1
- package/dist/cjs/reflect/reflect-check.js +126 -9
- package/dist/cjs/reflect/reflect-types.d.ts +162 -14
- package/dist/cjs/reflect/reflect.d.ts +12 -3
- package/dist/cjs/reflect/reflect.js +316 -290
- package/dist/cjs/reflect/scalar.d.ts +3 -55
- package/dist/cjs/reflect/scalar.js +26 -220
- package/dist/cjs/reflect/unsafe.d.ts +1 -1
- package/dist/cjs/reflect/unsafe.js +38 -43
- package/dist/cjs/{reflect/registry.d.ts → registry.d.ts} +2 -2
- package/dist/cjs/{reflect/registry.js → registry.js} +100 -73
- package/dist/cjs/to-binary.d.ts +1 -1
- package/dist/cjs/to-binary.js +28 -30
- package/dist/cjs/to-json.d.ts +7 -6
- package/dist/cjs/to-json.js +63 -70
- package/dist/cjs/types.d.ts +1 -1
- package/dist/cjs/wire/base64-encoding.js +4 -4
- package/dist/cjs/wire/binary-encoding.d.ts +25 -3
- package/dist/cjs/wire/binary-encoding.js +70 -18
- package/dist/cjs/wire/size-delimited.d.ts +1 -1
- package/dist/cjs/wire/text-format.d.ts +1 -2
- package/dist/cjs/wire/text-format.js +21 -19
- package/dist/cjs/wkt/any.d.ts +3 -3
- package/dist/cjs/wkt/gen/google/protobuf/any_pb.d.ts +7 -0
- package/dist/cjs/wkt/gen/google/protobuf/any_pb.js +7 -2
- package/dist/cjs/wkt/gen/google/protobuf/api_pb.d.ts +15 -0
- package/dist/cjs/wkt/gen/google/protobuf/api_pb.js +15 -6
- package/dist/cjs/wkt/gen/google/protobuf/compiler/plugin_pb.d.ts +22 -0
- package/dist/cjs/wkt/gen/google/protobuf/compiler/plugin_pb.js +22 -9
- package/dist/cjs/wkt/gen/google/protobuf/descriptor_pb.d.ts +192 -0
- package/dist/cjs/wkt/gen/google/protobuf/descriptor_pb.js +187 -84
- package/dist/cjs/wkt/gen/google/protobuf/duration_pb.d.ts +7 -0
- package/dist/cjs/wkt/gen/google/protobuf/duration_pb.js +7 -2
- package/dist/cjs/wkt/gen/google/protobuf/empty_pb.d.ts +7 -0
- package/dist/cjs/wkt/gen/google/protobuf/empty_pb.js +7 -2
- package/dist/cjs/wkt/gen/google/protobuf/field_mask_pb.d.ts +7 -0
- package/dist/cjs/wkt/gen/google/protobuf/field_mask_pb.js +7 -2
- package/dist/cjs/wkt/gen/google/protobuf/source_context_pb.d.ts +7 -0
- package/dist/cjs/wkt/gen/google/protobuf/source_context_pb.js +7 -2
- package/dist/cjs/wkt/gen/google/protobuf/struct_pb.d.ts +18 -0
- package/dist/cjs/wkt/gen/google/protobuf/struct_pb.js +18 -7
- package/dist/cjs/wkt/gen/google/protobuf/timestamp_pb.d.ts +7 -0
- package/dist/cjs/wkt/gen/google/protobuf/timestamp_pb.js +7 -2
- package/dist/cjs/wkt/gen/google/protobuf/type_pb.d.ts +32 -0
- package/dist/cjs/wkt/gen/google/protobuf/type_pb.js +32 -13
- package/dist/cjs/wkt/gen/google/protobuf/wrappers_pb.d.ts +39 -0
- package/dist/cjs/wkt/gen/google/protobuf/wrappers_pb.js +39 -18
- package/dist/cjs/wkt/wrappers.d.ts +1 -1
- package/dist/esm/clone.d.ts +1 -1
- package/dist/esm/clone.js +1 -1
- package/dist/esm/codegenv1/boot.d.ts +1 -1
- package/dist/esm/codegenv1/boot.js +3 -5
- package/dist/esm/codegenv1/embed.d.ts +2 -2
- package/dist/esm/codegenv1/embed.js +34 -29
- package/dist/esm/codegenv1/enum.d.ts +1 -1
- package/dist/esm/codegenv1/enum.js +2 -4
- package/dist/esm/codegenv1/extension.d.ts +1 -1
- package/dist/esm/codegenv1/file.d.ts +1 -1
- package/dist/esm/codegenv1/file.js +4 -6
- package/dist/esm/codegenv1/index.d.ts +1 -0
- package/dist/esm/codegenv1/index.js +1 -0
- package/dist/esm/codegenv1/message.d.ts +1 -1
- package/dist/esm/codegenv1/restore-json-names.d.ts +3 -0
- package/dist/esm/codegenv1/restore-json-names.js +3 -0
- package/dist/esm/codegenv1/scalar.d.ts +5 -0
- package/dist/esm/codegenv1/scalar.js +35 -0
- package/dist/esm/codegenv1/service.d.ts +3 -3
- package/dist/esm/codegenv1/symbols.d.ts +9 -0
- package/dist/esm/codegenv1/symbols.js +9 -0
- package/dist/esm/codegenv1/types.d.ts +59 -8
- package/dist/esm/create.d.ts +1 -1
- package/dist/esm/create.js +11 -21
- package/dist/esm/{desc-types.d.ts → descriptors.d.ts} +66 -17
- package/dist/esm/descriptors.js +50 -0
- package/dist/esm/equals.d.ts +1 -1
- package/dist/esm/extensions.d.ts +21 -1
- package/dist/esm/extensions.js +39 -9
- package/dist/esm/fields.d.ts +17 -16
- package/dist/esm/fields.js +17 -10
- package/dist/esm/from-binary.d.ts +2 -2
- package/dist/esm/from-binary.js +13 -23
- package/dist/esm/from-json.d.ts +4 -4
- package/dist/esm/from-json.js +193 -178
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.js +3 -2
- package/dist/esm/is-message.d.ts +1 -1
- package/dist/esm/proto-int64.d.ts +4 -1
- package/dist/esm/proto-int64.js +16 -6
- package/dist/esm/reflect/error.d.ts +1 -1
- package/dist/esm/reflect/guard.d.ts +1 -1
- package/dist/esm/reflect/index.d.ts +0 -1
- package/dist/esm/reflect/index.js +0 -1
- package/dist/esm/reflect/names.d.ts +1 -13
- package/dist/esm/reflect/names.js +1 -38
- package/dist/esm/reflect/nested-types.d.ts +11 -1
- package/dist/esm/reflect/nested-types.js +32 -0
- package/dist/esm/reflect/reflect-check.d.ts +10 -1
- package/dist/esm/reflect/reflect-check.js +119 -2
- package/dist/esm/reflect/reflect-types.d.ts +162 -14
- package/dist/esm/reflect/reflect-types.js +1 -0
- package/dist/esm/reflect/reflect.d.ts +12 -3
- package/dist/esm/reflect/reflect.js +305 -279
- package/dist/esm/reflect/scalar.d.ts +3 -55
- package/dist/esm/reflect/scalar.js +14 -205
- package/dist/esm/reflect/unsafe.d.ts +1 -1
- package/dist/esm/reflect/unsafe.js +38 -43
- package/dist/esm/{reflect/registry.d.ts → registry.d.ts} +2 -2
- package/dist/esm/{reflect/registry.js → registry.js} +90 -63
- package/dist/esm/to-binary.d.ts +1 -1
- package/dist/esm/to-binary.js +2 -4
- package/dist/esm/to-json.d.ts +7 -6
- package/dist/esm/to-json.js +48 -55
- package/dist/esm/types.d.ts +1 -1
- package/dist/esm/wire/base64-encoding.js +4 -4
- package/dist/esm/wire/binary-encoding.d.ts +25 -3
- package/dist/esm/wire/binary-encoding.js +63 -11
- package/dist/esm/wire/size-delimited.d.ts +1 -1
- package/dist/esm/wire/text-format.d.ts +1 -2
- package/dist/esm/wire/text-format.js +5 -3
- package/dist/esm/wkt/any.d.ts +3 -3
- package/dist/esm/wkt/gen/google/protobuf/any_pb.d.ts +7 -0
- package/dist/esm/wkt/gen/google/protobuf/any_pb.js +7 -2
- package/dist/esm/wkt/gen/google/protobuf/api_pb.d.ts +15 -0
- package/dist/esm/wkt/gen/google/protobuf/api_pb.js +15 -6
- package/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.d.ts +22 -0
- package/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.js +22 -9
- package/dist/esm/wkt/gen/google/protobuf/descriptor_pb.d.ts +192 -0
- package/dist/esm/wkt/gen/google/protobuf/descriptor_pb.js +187 -84
- package/dist/esm/wkt/gen/google/protobuf/duration_pb.d.ts +7 -0
- package/dist/esm/wkt/gen/google/protobuf/duration_pb.js +7 -2
- package/dist/esm/wkt/gen/google/protobuf/empty_pb.d.ts +7 -0
- package/dist/esm/wkt/gen/google/protobuf/empty_pb.js +7 -2
- package/dist/esm/wkt/gen/google/protobuf/field_mask_pb.d.ts +7 -0
- package/dist/esm/wkt/gen/google/protobuf/field_mask_pb.js +7 -2
- package/dist/esm/wkt/gen/google/protobuf/source_context_pb.d.ts +7 -0
- package/dist/esm/wkt/gen/google/protobuf/source_context_pb.js +7 -2
- package/dist/esm/wkt/gen/google/protobuf/struct_pb.d.ts +18 -0
- package/dist/esm/wkt/gen/google/protobuf/struct_pb.js +18 -7
- package/dist/esm/wkt/gen/google/protobuf/timestamp_pb.d.ts +7 -0
- package/dist/esm/wkt/gen/google/protobuf/timestamp_pb.js +7 -2
- package/dist/esm/wkt/gen/google/protobuf/type_pb.d.ts +32 -0
- package/dist/esm/wkt/gen/google/protobuf/type_pb.js +32 -13
- package/dist/esm/wkt/gen/google/protobuf/wrappers_pb.d.ts +39 -0
- package/dist/esm/wkt/gen/google/protobuf/wrappers_pb.js +39 -18
- package/dist/esm/wkt/wrappers.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/desc-types.js +0 -15
- package/dist/cjs/reflect/assert.d.ts +0 -16
- package/dist/cjs/reflect/assert.js +0 -59
- package/dist/esm/desc-types.js +0 -14
- package/dist/esm/reflect/assert.d.ts +0 -16
- package/dist/esm/reflect/assert.js +0 -52
package/dist/cjs/from-json.js
CHANGED
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.mergeFromJson = exports.fromJson = exports.mergeFromJsonString = exports.fromJsonString = void 0;
|
|
17
|
-
|
|
17
|
+
/* eslint-disable no-case-declarations,@typescript-eslint/restrict-template-expressions */
|
|
18
|
+
const descriptors_js_1 = require("./descriptors.js");
|
|
18
19
|
const proto_int64_js_1 = require("./proto-int64.js");
|
|
19
20
|
const create_js_1 = require("./create.js");
|
|
20
21
|
const reflect_js_1 = require("./reflect/reflect.js");
|
|
22
|
+
const error_js_1 = require("./reflect/error.js");
|
|
21
23
|
const reflect_check_js_1 = require("./reflect/reflect-check.js");
|
|
22
24
|
const scalar_js_1 = require("./reflect/scalar.js");
|
|
23
25
|
const base64_encoding_js_1 = require("./wire/base64-encoding.js");
|
|
24
|
-
const text_encoding_js_1 = require("./wire/text-encoding.js");
|
|
25
26
|
const index_js_1 = require("./wkt/index.js");
|
|
26
|
-
const wrappers_js_1 = require("./wkt/wrappers.js");
|
|
27
27
|
const extensions_js_1 = require("./extensions.js");
|
|
28
28
|
// Default options for parsing JSON.
|
|
29
29
|
const jsonReadDefaults = {
|
|
@@ -49,7 +49,7 @@ exports.fromJsonString = fromJsonString;
|
|
|
49
49
|
* new data.
|
|
50
50
|
*/
|
|
51
51
|
function mergeFromJsonString(messageDesc, target, json, options) {
|
|
52
|
-
|
|
52
|
+
mergeFromJson(messageDesc, target, parseJsonString(json, messageDesc.typeName), options);
|
|
53
53
|
}
|
|
54
54
|
exports.mergeFromJsonString = mergeFromJsonString;
|
|
55
55
|
/**
|
|
@@ -57,7 +57,18 @@ exports.mergeFromJsonString = mergeFromJsonString;
|
|
|
57
57
|
*/
|
|
58
58
|
function fromJson(messageDesc, json, options) {
|
|
59
59
|
const msg = (0, reflect_js_1.reflect)(messageDesc);
|
|
60
|
-
|
|
60
|
+
try {
|
|
61
|
+
readMessage(msg, json, makeReadOptions(options));
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
if ((0, error_js_1.isFieldError)(e)) {
|
|
65
|
+
// @ts-expect-error we use the ES2022 error CTOR option "cause" for better stack traces
|
|
66
|
+
throw new Error(`cannot decode ${e.field()} from JSON: ${e.message}`, {
|
|
67
|
+
cause: e,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
throw e;
|
|
71
|
+
}
|
|
61
72
|
return msg.message;
|
|
62
73
|
}
|
|
63
74
|
exports.fromJson = fromJson;
|
|
@@ -71,8 +82,18 @@ exports.fromJson = fromJson;
|
|
|
71
82
|
* new data.
|
|
72
83
|
*/
|
|
73
84
|
function mergeFromJson(messageDesc, target, json, options) {
|
|
74
|
-
|
|
75
|
-
|
|
85
|
+
try {
|
|
86
|
+
readMessage((0, reflect_js_1.reflect)(messageDesc, target), json, makeReadOptions(options));
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
if ((0, error_js_1.isFieldError)(e)) {
|
|
90
|
+
// @ts-expect-error we use the ES2022 error CTOR option "cause" for better stack traces
|
|
91
|
+
throw new Error(`cannot decode ${e.field()} from JSON: ${e.message}`, {
|
|
92
|
+
cause: e,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
throw e;
|
|
96
|
+
}
|
|
76
97
|
}
|
|
77
98
|
exports.mergeFromJson = mergeFromJson;
|
|
78
99
|
function readMessage(msg, json, opts) {
|
|
@@ -81,7 +102,7 @@ function readMessage(msg, json, opts) {
|
|
|
81
102
|
return;
|
|
82
103
|
}
|
|
83
104
|
if (json == null || Array.isArray(json) || typeof json != "object") {
|
|
84
|
-
throw new Error(`cannot decode
|
|
105
|
+
throw new Error(`cannot decode ${msg.desc} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
85
106
|
}
|
|
86
107
|
const oneofSeen = new Map();
|
|
87
108
|
const jsonNames = new Map();
|
|
@@ -98,9 +119,9 @@ function readMessage(msg, json, opts) {
|
|
|
98
119
|
}
|
|
99
120
|
const seen = oneofSeen.get(field.oneof);
|
|
100
121
|
if (seen !== undefined) {
|
|
101
|
-
throw new
|
|
122
|
+
throw new error_js_1.FieldError(field.oneof, `oneof set multiple times by ${seen.name} and ${field.name}`);
|
|
102
123
|
}
|
|
103
|
-
oneofSeen.set(field.oneof,
|
|
124
|
+
oneofSeen.set(field.oneof, field);
|
|
104
125
|
}
|
|
105
126
|
readField(msg, field, jsonValue, opts);
|
|
106
127
|
}
|
|
@@ -115,7 +136,7 @@ function readMessage(msg, json, opts) {
|
|
|
115
136
|
(0, extensions_js_1.setExtension)(msg.message, extension, get());
|
|
116
137
|
}
|
|
117
138
|
if (!extension && !opts.ignoreUnknownFields) {
|
|
118
|
-
throw new Error(`cannot decode
|
|
139
|
+
throw new Error(`cannot decode ${msg.desc} from JSON: key "${jsonKey}" is unknown`);
|
|
119
140
|
}
|
|
120
141
|
}
|
|
121
142
|
}
|
|
@@ -144,45 +165,42 @@ function readMapField(msg, field, json, opts) {
|
|
|
144
165
|
return;
|
|
145
166
|
}
|
|
146
167
|
if (typeof json != "object" || Array.isArray(json)) {
|
|
147
|
-
throw new
|
|
168
|
+
throw new error_js_1.FieldError(field, "expected object, got " + (0, reflect_check_js_1.formatVal)(json));
|
|
148
169
|
}
|
|
149
170
|
for (const [jsonMapKey, jsonMapValue] of Object.entries(json)) {
|
|
150
171
|
if (jsonMapValue === null) {
|
|
151
|
-
throw new
|
|
152
|
-
}
|
|
153
|
-
let key;
|
|
154
|
-
try {
|
|
155
|
-
key = readMapKey(field.mapKey, jsonMapKey);
|
|
156
|
-
}
|
|
157
|
-
catch (e) {
|
|
158
|
-
let m = `cannot decode map key for field ${msg.desc.typeName}.${field.name} from JSON: ${(0, reflect_check_js_1.formatVal)(jsonMapKey)}`;
|
|
159
|
-
if (e instanceof Error && e.message.length > 0) {
|
|
160
|
-
m += `: ${e.message}`;
|
|
161
|
-
}
|
|
162
|
-
throw new Error(m);
|
|
172
|
+
throw new error_js_1.FieldError(field, "map value must not be null");
|
|
163
173
|
}
|
|
174
|
+
const key = mapKeyFromJson(field.mapKey, jsonMapKey);
|
|
164
175
|
switch (field.mapKind) {
|
|
165
176
|
case "message":
|
|
166
177
|
const msgValue = (0, reflect_js_1.reflect)(field.message);
|
|
167
178
|
readMessage(msgValue, jsonMapValue, opts);
|
|
168
|
-
|
|
179
|
+
// TODO fix types
|
|
180
|
+
// @ts-expect-error TODO
|
|
181
|
+
const err = msg.setMapEntry(field, key, msgValue);
|
|
182
|
+
if (err) {
|
|
183
|
+
throw err;
|
|
184
|
+
}
|
|
169
185
|
break;
|
|
170
186
|
case "enum":
|
|
171
187
|
const enumValue = readEnum(field.enum, jsonMapValue, opts.ignoreUnknownFields, true);
|
|
172
188
|
if (enumValue !== tokenIgnoredUnknownEnum) {
|
|
173
|
-
|
|
189
|
+
// TODO fix types
|
|
190
|
+
// @ts-expect-error TODO
|
|
191
|
+
const err = msg.setMapEntry(field, key, enumValue);
|
|
192
|
+
if (err) {
|
|
193
|
+
throw err;
|
|
194
|
+
}
|
|
174
195
|
}
|
|
175
196
|
break;
|
|
176
197
|
case "scalar":
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
m += `: ${e.message}`;
|
|
184
|
-
}
|
|
185
|
-
throw new Error(m);
|
|
198
|
+
const err2 = msg.setMapEntry(field,
|
|
199
|
+
// TODO fix types
|
|
200
|
+
// @ts-expect-error TODO
|
|
201
|
+
key, scalarFromJson(field, jsonMapValue, true));
|
|
202
|
+
if (err2) {
|
|
203
|
+
throw err2;
|
|
186
204
|
}
|
|
187
205
|
break;
|
|
188
206
|
}
|
|
@@ -193,11 +211,11 @@ function readListField(msg, field, json, opts) {
|
|
|
193
211
|
return;
|
|
194
212
|
}
|
|
195
213
|
if (!Array.isArray(json)) {
|
|
196
|
-
throw new
|
|
214
|
+
throw new error_js_1.FieldError(field, "expected Array, got " + (0, reflect_check_js_1.formatVal)(json));
|
|
197
215
|
}
|
|
198
216
|
for (const jsonItem of json) {
|
|
199
217
|
if (jsonItem === null) {
|
|
200
|
-
throw new
|
|
218
|
+
throw new error_js_1.FieldError(field, "list item must not be null");
|
|
201
219
|
}
|
|
202
220
|
switch (field.listKind) {
|
|
203
221
|
case "message":
|
|
@@ -212,15 +230,9 @@ function readListField(msg, field, json, opts) {
|
|
|
212
230
|
}
|
|
213
231
|
break;
|
|
214
232
|
case "scalar":
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
catch (e) {
|
|
219
|
-
let m = `cannot decode field ${msg.desc.typeName}.${field.name} from JSON: ${(0, reflect_check_js_1.formatVal)(jsonItem)}`;
|
|
220
|
-
if (e instanceof Error && e.message.length > 0) {
|
|
221
|
-
m += `: ${e.message}`;
|
|
222
|
-
}
|
|
223
|
-
throw new Error(m);
|
|
233
|
+
const err = msg.addListItem(field, scalarFromJson(field, jsonItem, true));
|
|
234
|
+
if (err) {
|
|
235
|
+
throw err;
|
|
224
236
|
}
|
|
225
237
|
break;
|
|
226
238
|
}
|
|
@@ -245,36 +257,18 @@ function readEnumField(msg, field, json, opts) {
|
|
|
245
257
|
}
|
|
246
258
|
}
|
|
247
259
|
function readScalarField(msg, field, json) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
msg.clear(field);
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
msg.set(field, scalarValue);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
catch (e) {
|
|
258
|
-
let m = `cannot decode field ${msg.desc.typeName}.${field.name} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`;
|
|
259
|
-
if (e instanceof Error && e.message.length > 0) {
|
|
260
|
-
m += `: ${e.message}`;
|
|
261
|
-
}
|
|
262
|
-
throw new Error(m);
|
|
260
|
+
const scalarValue = scalarFromJson(field, json, false);
|
|
261
|
+
if (scalarValue === tokenNull) {
|
|
262
|
+
msg.clear(field);
|
|
263
263
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
json = true;
|
|
271
|
-
break;
|
|
272
|
-
case "false":
|
|
273
|
-
json = false;
|
|
274
|
-
break;
|
|
264
|
+
else {
|
|
265
|
+
// TODO fix type error
|
|
266
|
+
// @ts-expect-error TODO
|
|
267
|
+
const err = msg.set(field, scalarValue);
|
|
268
|
+
if (err) {
|
|
269
|
+
throw err;
|
|
275
270
|
}
|
|
276
271
|
}
|
|
277
|
-
return readScalar(type, json, scalar_js_1.LongType.BIGINT, true);
|
|
278
272
|
}
|
|
279
273
|
const tokenIgnoredUnknownEnum = Symbol();
|
|
280
274
|
function readEnum(desc, json, ignoreUnknownFields, nullAsZeroValue) {
|
|
@@ -301,120 +295,143 @@ function readEnum(desc, json, ignoreUnknownFields, nullAsZeroValue) {
|
|
|
301
295
|
}
|
|
302
296
|
break;
|
|
303
297
|
}
|
|
304
|
-
throw new Error(`cannot decode
|
|
298
|
+
throw new Error(`cannot decode ${desc} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
305
299
|
}
|
|
306
300
|
const tokenNull = Symbol();
|
|
307
|
-
function
|
|
301
|
+
function scalarFromJson(field, json, nullAsZeroValue) {
|
|
308
302
|
if (json === null) {
|
|
309
303
|
if (nullAsZeroValue) {
|
|
310
|
-
return (0, scalar_js_1.scalarZeroValue)(
|
|
304
|
+
return (0, scalar_js_1.scalarZeroValue)(field.scalar, false);
|
|
311
305
|
}
|
|
312
306
|
return tokenNull;
|
|
313
307
|
}
|
|
314
|
-
//
|
|
315
|
-
//
|
|
316
|
-
|
|
308
|
+
// int64, sfixed64, sint64, fixed64, uint64: Reflect supports string and number.
|
|
309
|
+
// string, bool: Supported by reflect.
|
|
310
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
311
|
+
switch (field.scalar) {
|
|
317
312
|
// float, double: JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity".
|
|
318
313
|
// Either numbers or strings are accepted. Exponent notation is also accepted.
|
|
319
|
-
case
|
|
320
|
-
case
|
|
314
|
+
case descriptors_js_1.ScalarType.DOUBLE:
|
|
315
|
+
case descriptors_js_1.ScalarType.FLOAT:
|
|
321
316
|
if (json === "NaN")
|
|
322
|
-
return
|
|
317
|
+
return NaN;
|
|
323
318
|
if (json === "Infinity")
|
|
324
319
|
return Number.POSITIVE_INFINITY;
|
|
325
320
|
if (json === "-Infinity")
|
|
326
321
|
return Number.NEGATIVE_INFINITY;
|
|
327
|
-
if (json
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
break;
|
|
337
|
-
}
|
|
338
|
-
const float = Number(json);
|
|
339
|
-
if (Number.isNaN(float)) {
|
|
340
|
-
// not a number
|
|
322
|
+
if (typeof json == "number") {
|
|
323
|
+
if (isNaN(json)) {
|
|
324
|
+
// NaN must be encoded with string constants
|
|
325
|
+
throw new error_js_1.FieldError(field, "unexpected NaN number");
|
|
326
|
+
}
|
|
327
|
+
if (!isFinite(json)) {
|
|
328
|
+
// Infinity must be encoded with string constants
|
|
329
|
+
throw new error_js_1.FieldError(field, "unexpected infinite number");
|
|
330
|
+
}
|
|
341
331
|
break;
|
|
342
332
|
}
|
|
343
|
-
if (
|
|
344
|
-
|
|
345
|
-
|
|
333
|
+
if (typeof json == "string") {
|
|
334
|
+
if (json === "") {
|
|
335
|
+
// empty string is not a number
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
if (json.trim().length !== json.length) {
|
|
339
|
+
// extra whitespace
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
const float = Number(json);
|
|
343
|
+
if (!isFinite(float)) {
|
|
344
|
+
// Infinity and NaN must be encoded with string constants
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
return float;
|
|
346
348
|
}
|
|
347
|
-
|
|
348
|
-
(0, assert_js_1.assertFloat32)(float);
|
|
349
|
-
return float;
|
|
349
|
+
break;
|
|
350
350
|
// int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted.
|
|
351
|
-
case
|
|
352
|
-
case
|
|
353
|
-
case
|
|
354
|
-
case
|
|
355
|
-
case
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
case scalar_js_1.ScalarType.INT64:
|
|
372
|
-
case scalar_js_1.ScalarType.SFIXED64:
|
|
373
|
-
case scalar_js_1.ScalarType.SINT64:
|
|
374
|
-
if (typeof json != "number" && typeof json != "string")
|
|
375
|
-
break;
|
|
376
|
-
const long = proto_int64_js_1.protoInt64.parse(json);
|
|
377
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
378
|
-
return longType ? long.toString() : long;
|
|
379
|
-
case scalar_js_1.ScalarType.FIXED64:
|
|
380
|
-
case scalar_js_1.ScalarType.UINT64:
|
|
381
|
-
if (typeof json != "number" && typeof json != "string")
|
|
382
|
-
break;
|
|
383
|
-
const uLong = proto_int64_js_1.protoInt64.uParse(json);
|
|
384
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
385
|
-
return longType ? uLong.toString() : uLong;
|
|
386
|
-
// bool:
|
|
387
|
-
case scalar_js_1.ScalarType.BOOL:
|
|
388
|
-
if (typeof json !== "boolean")
|
|
389
|
-
break;
|
|
390
|
-
return json;
|
|
391
|
-
// string:
|
|
392
|
-
case scalar_js_1.ScalarType.STRING:
|
|
393
|
-
if (typeof json !== "string") {
|
|
394
|
-
break;
|
|
351
|
+
case descriptors_js_1.ScalarType.INT32:
|
|
352
|
+
case descriptors_js_1.ScalarType.FIXED32:
|
|
353
|
+
case descriptors_js_1.ScalarType.SFIXED32:
|
|
354
|
+
case descriptors_js_1.ScalarType.SINT32:
|
|
355
|
+
case descriptors_js_1.ScalarType.UINT32:
|
|
356
|
+
return int32FromJson(json);
|
|
357
|
+
// bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings.
|
|
358
|
+
// Either standard or URL-safe base64 encoding with/without paddings are accepted.
|
|
359
|
+
case descriptors_js_1.ScalarType.BYTES:
|
|
360
|
+
if (typeof json == "string") {
|
|
361
|
+
if (json === "") {
|
|
362
|
+
return new Uint8Array(0);
|
|
363
|
+
}
|
|
364
|
+
try {
|
|
365
|
+
return (0, base64_encoding_js_1.base64Decode)(json);
|
|
366
|
+
}
|
|
367
|
+
catch (e) {
|
|
368
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
369
|
+
throw new error_js_1.FieldError(field, message);
|
|
370
|
+
}
|
|
395
371
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
return json;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Try to parse a JSON value to a map key for the reflect API.
|
|
378
|
+
*
|
|
379
|
+
* Returns the input if the JSON value cannot be converted.
|
|
380
|
+
*/
|
|
381
|
+
function mapKeyFromJson(type, json) {
|
|
382
|
+
switch (type) {
|
|
383
|
+
case descriptors_js_1.ScalarType.BOOL:
|
|
384
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
385
|
+
switch (json) {
|
|
386
|
+
case "true":
|
|
387
|
+
return true;
|
|
388
|
+
case "false":
|
|
389
|
+
return false;
|
|
399
390
|
}
|
|
400
391
|
return json;
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
case
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
return
|
|
392
|
+
case descriptors_js_1.ScalarType.INT32:
|
|
393
|
+
case descriptors_js_1.ScalarType.FIXED32:
|
|
394
|
+
case descriptors_js_1.ScalarType.UINT32:
|
|
395
|
+
case descriptors_js_1.ScalarType.SFIXED32:
|
|
396
|
+
case descriptors_js_1.ScalarType.SINT32:
|
|
397
|
+
return int32FromJson(json);
|
|
398
|
+
default:
|
|
399
|
+
return json;
|
|
409
400
|
}
|
|
410
|
-
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Try to parse a JSON value to a 32-bit integer for the reflect API.
|
|
404
|
+
*
|
|
405
|
+
* Returns the input if the JSON value cannot be converted.
|
|
406
|
+
*/
|
|
407
|
+
function int32FromJson(json) {
|
|
408
|
+
if (typeof json == "string") {
|
|
409
|
+
if (json === "") {
|
|
410
|
+
// empty string is not a number
|
|
411
|
+
return json;
|
|
412
|
+
}
|
|
413
|
+
if (json.trim().length !== json.length) {
|
|
414
|
+
// extra whitespace
|
|
415
|
+
return json;
|
|
416
|
+
}
|
|
417
|
+
const num = Number(json);
|
|
418
|
+
if (Number.isNaN(num)) {
|
|
419
|
+
// not a number
|
|
420
|
+
return json;
|
|
421
|
+
}
|
|
422
|
+
return num;
|
|
423
|
+
}
|
|
424
|
+
return json;
|
|
411
425
|
}
|
|
412
426
|
function parseJsonString(jsonString, typeName) {
|
|
413
427
|
try {
|
|
414
428
|
return JSON.parse(jsonString);
|
|
415
429
|
}
|
|
416
430
|
catch (e) {
|
|
417
|
-
|
|
431
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
432
|
+
throw new Error(`cannot decode message ${typeName} from JSON: ${message}`,
|
|
433
|
+
// @ts-expect-error we use the ES2022 error CTOR option "cause" for better stack traces
|
|
434
|
+
{ cause: e });
|
|
418
435
|
}
|
|
419
436
|
}
|
|
420
437
|
function tryWktFromJson(msg, jsonValue, opts) {
|
|
@@ -444,13 +461,16 @@ function tryWktFromJson(msg, jsonValue, opts) {
|
|
|
444
461
|
listValueFromJson(msg.message, jsonValue);
|
|
445
462
|
return true;
|
|
446
463
|
default:
|
|
447
|
-
if ((0,
|
|
464
|
+
if ((0, index_js_1.isWrapperDesc)(msg.desc)) {
|
|
448
465
|
const valueField = msg.desc.fields[0];
|
|
449
466
|
if (jsonValue === null) {
|
|
450
467
|
msg.clear(valueField);
|
|
451
468
|
}
|
|
452
469
|
else {
|
|
453
|
-
msg.set(valueField,
|
|
470
|
+
const err = msg.set(valueField, scalarFromJson(valueField, jsonValue, true));
|
|
471
|
+
if (err) {
|
|
472
|
+
throw err;
|
|
473
|
+
}
|
|
454
474
|
}
|
|
455
475
|
return true;
|
|
456
476
|
}
|
|
@@ -460,7 +480,7 @@ function tryWktFromJson(msg, jsonValue, opts) {
|
|
|
460
480
|
function anyFromJson(any, json, opts) {
|
|
461
481
|
var _a;
|
|
462
482
|
if (json === null || Array.isArray(json) || typeof json != "object") {
|
|
463
|
-
throw new Error(`cannot decode message ${any.$typeName} from JSON: expected object but got ${
|
|
483
|
+
throw new Error(`cannot decode message ${any.$typeName} from JSON: expected object but got ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
464
484
|
}
|
|
465
485
|
if (Object.keys(json).length == 0) {
|
|
466
486
|
return;
|
|
@@ -469,7 +489,13 @@ function anyFromJson(any, json, opts) {
|
|
|
469
489
|
if (typeof typeUrl != "string" || typeUrl == "") {
|
|
470
490
|
throw new Error(`cannot decode message ${any.$typeName} from JSON: "@type" is empty`);
|
|
471
491
|
}
|
|
472
|
-
const typeName =
|
|
492
|
+
const typeName = typeUrl.includes("/")
|
|
493
|
+
? typeUrl.substring(typeUrl.lastIndexOf("/") + 1)
|
|
494
|
+
: typeUrl;
|
|
495
|
+
if (!typeName.length) {
|
|
496
|
+
throw new Error(`cannot decode message ${any.$typeName} from JSON: "@type" is invalid`);
|
|
497
|
+
}
|
|
498
|
+
const desc = (_a = opts.registry) === null || _a === void 0 ? void 0 : _a.getMessage(typeName);
|
|
473
499
|
if (!desc) {
|
|
474
500
|
throw new Error(`cannot decode message ${any.$typeName} from JSON: ${typeUrl} is not in the type registry`);
|
|
475
501
|
}
|
|
@@ -488,17 +514,17 @@ function anyFromJson(any, json, opts) {
|
|
|
488
514
|
}
|
|
489
515
|
function timestampFromJson(timestamp, json) {
|
|
490
516
|
if (typeof json !== "string") {
|
|
491
|
-
throw new Error(`cannot decode ${timestamp.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
517
|
+
throw new Error(`cannot decode message ${timestamp.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
492
518
|
}
|
|
493
519
|
const matches = json.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);
|
|
494
520
|
if (!matches) {
|
|
495
|
-
throw new Error(`cannot decode ${timestamp.$typeName} from JSON: invalid RFC 3339 string`);
|
|
521
|
+
throw new Error(`cannot decode message ${timestamp.$typeName} from JSON: invalid RFC 3339 string`);
|
|
496
522
|
}
|
|
497
523
|
const ms = Date.parse(
|
|
498
524
|
//prettier-ignore
|
|
499
525
|
matches[1] + "-" + matches[2] + "-" + matches[3] + "T" + matches[4] + ":" + matches[5] + ":" + matches[6] + (matches[8] ? matches[8] : "Z"));
|
|
500
526
|
if (Number.isNaN(ms)) {
|
|
501
|
-
throw new Error(`cannot decode ${timestamp.$typeName} from JSON: invalid RFC 3339 string`);
|
|
527
|
+
throw new Error(`cannot decode message ${timestamp.$typeName} from JSON: invalid RFC 3339 string`);
|
|
502
528
|
}
|
|
503
529
|
if (ms < Date.parse("0001-01-01T00:00:00Z") ||
|
|
504
530
|
ms > Date.parse("9999-12-31T23:59:59Z")) {
|
|
@@ -514,15 +540,15 @@ function timestampFromJson(timestamp, json) {
|
|
|
514
540
|
}
|
|
515
541
|
function durationFromJson(duration, json) {
|
|
516
542
|
if (typeof json !== "string") {
|
|
517
|
-
throw new Error(`cannot decode ${duration.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
543
|
+
throw new Error(`cannot decode message ${duration.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
518
544
|
}
|
|
519
545
|
const match = json.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);
|
|
520
546
|
if (match === null) {
|
|
521
|
-
throw new Error(`cannot decode ${duration.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
547
|
+
throw new Error(`cannot decode message ${duration.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
522
548
|
}
|
|
523
549
|
const longSeconds = Number(match[1]);
|
|
524
550
|
if (longSeconds > 315576000000 || longSeconds < -315576000000) {
|
|
525
|
-
throw new Error(`cannot decode ${duration.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
551
|
+
throw new Error(`cannot decode message ${duration.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
526
552
|
}
|
|
527
553
|
duration.seconds = proto_int64_js_1.protoInt64.parse(longSeconds);
|
|
528
554
|
if (typeof match[2] !== "string") {
|
|
@@ -536,14 +562,14 @@ function durationFromJson(duration, json) {
|
|
|
536
562
|
}
|
|
537
563
|
function fieldMaskFromJson(fieldMask, json) {
|
|
538
564
|
if (typeof json !== "string") {
|
|
539
|
-
throw new Error(`cannot decode ${fieldMask.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
565
|
+
throw new Error(`cannot decode message ${fieldMask.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
540
566
|
}
|
|
541
567
|
if (json === "") {
|
|
542
568
|
return;
|
|
543
569
|
}
|
|
544
570
|
function camelToSnake(str) {
|
|
545
571
|
if (str.includes("_")) {
|
|
546
|
-
throw new Error(`cannot decode ${fieldMask.$typeName} from JSON: path names must be lowerCamelCase`);
|
|
572
|
+
throw new Error(`cannot decode message ${fieldMask.$typeName} from JSON: path names must be lowerCamelCase`);
|
|
547
573
|
}
|
|
548
574
|
const sc = str.replace(/[A-Z]/g, (letter) => "_" + letter.toLowerCase());
|
|
549
575
|
return sc[0] === "_" ? sc.substring(1) : sc;
|
|
@@ -552,7 +578,7 @@ function fieldMaskFromJson(fieldMask, json) {
|
|
|
552
578
|
}
|
|
553
579
|
function structFromJson(struct, json) {
|
|
554
580
|
if (typeof json != "object" || json == null || Array.isArray(json)) {
|
|
555
|
-
throw new Error(`cannot decode ${struct.$typeName} from JSON ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
581
|
+
throw new Error(`cannot decode message ${struct.$typeName} from JSON ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
556
582
|
}
|
|
557
583
|
for (const [k, v] of Object.entries(json)) {
|
|
558
584
|
const parsedV = (0, create_js_1.create)(index_js_1.ValueDesc);
|
|
@@ -587,13 +613,13 @@ function valueFromJson(value, json) {
|
|
|
587
613
|
}
|
|
588
614
|
break;
|
|
589
615
|
default:
|
|
590
|
-
throw new Error(`cannot decode ${value.$typeName} from JSON ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
616
|
+
throw new Error(`cannot decode message ${value.$typeName} from JSON ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
591
617
|
}
|
|
592
618
|
return value;
|
|
593
619
|
}
|
|
594
620
|
function listValueFromJson(listValue, json) {
|
|
595
621
|
if (!Array.isArray(json)) {
|
|
596
|
-
throw new Error(`cannot decode ${listValue.$typeName} from JSON ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
622
|
+
throw new Error(`cannot decode message ${listValue.$typeName} from JSON ${(0, reflect_check_js_1.formatVal)(json)}`);
|
|
597
623
|
}
|
|
598
624
|
for (const e of json) {
|
|
599
625
|
const value = (0, create_js_1.create)(index_js_1.ValueDesc);
|
|
@@ -601,14 +627,3 @@ function listValueFromJson(listValue, json) {
|
|
|
601
627
|
listValue.values.push(value);
|
|
602
628
|
}
|
|
603
629
|
}
|
|
604
|
-
function typeUrlToName(url) {
|
|
605
|
-
if (!url.length) {
|
|
606
|
-
throw new Error(`invalid type url: ${url}`);
|
|
607
|
-
}
|
|
608
|
-
const slash = url.lastIndexOf("/");
|
|
609
|
-
const name = slash >= 0 ? url.substring(slash + 1) : url;
|
|
610
|
-
if (!name.length) {
|
|
611
|
-
throw new Error(`invalid type url: ${url}`);
|
|
612
|
-
}
|
|
613
|
-
return name;
|
|
614
|
-
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ export * from "./types.js";
|
|
|
2
2
|
export * from "./is-message.js";
|
|
3
3
|
export * from "./create.js";
|
|
4
4
|
export * from "./clone.js";
|
|
5
|
-
export * from "./
|
|
5
|
+
export * from "./descriptors.js";
|
|
6
6
|
export * from "./equals.js";
|
|
7
7
|
export * from "./fields.js";
|
|
8
|
+
export * from "./registry.js";
|
|
8
9
|
export type { JsonValue, JsonObject } from "./json-value.js";
|
|
9
10
|
export { toBinary } from "./to-binary.js";
|
|
10
11
|
export type { BinaryWriteOptions } from "./to-binary.js";
|
|
@@ -12,5 +13,5 @@ export { fromBinary, mergeFromBinary } from "./from-binary.js";
|
|
|
12
13
|
export type { BinaryReadOptions } from "./from-binary.js";
|
|
13
14
|
export * from "./to-json.js";
|
|
14
15
|
export * from "./from-json.js";
|
|
15
|
-
export { hasExtension, getExtension, setExtension, clearExtension, } from "./extensions.js";
|
|
16
|
+
export { hasExtension, getExtension, setExtension, clearExtension, hasOption, getOption, } from "./extensions.js";
|
|
16
17
|
export * from "./proto-int64.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -27,14 +27,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
27
27
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.clearExtension = exports.setExtension = exports.getExtension = exports.hasExtension = exports.mergeFromBinary = exports.fromBinary = exports.toBinary = void 0;
|
|
30
|
+
exports.getOption = exports.hasOption = exports.clearExtension = exports.setExtension = exports.getExtension = exports.hasExtension = exports.mergeFromBinary = exports.fromBinary = exports.toBinary = void 0;
|
|
31
31
|
__exportStar(require("./types.js"), exports);
|
|
32
32
|
__exportStar(require("./is-message.js"), exports);
|
|
33
33
|
__exportStar(require("./create.js"), exports);
|
|
34
34
|
__exportStar(require("./clone.js"), exports);
|
|
35
|
-
__exportStar(require("./
|
|
35
|
+
__exportStar(require("./descriptors.js"), exports);
|
|
36
36
|
__exportStar(require("./equals.js"), exports);
|
|
37
37
|
__exportStar(require("./fields.js"), exports);
|
|
38
|
+
__exportStar(require("./registry.js"), exports);
|
|
38
39
|
var to_binary_js_1 = require("./to-binary.js");
|
|
39
40
|
Object.defineProperty(exports, "toBinary", { enumerable: true, get: function () { return to_binary_js_1.toBinary; } });
|
|
40
41
|
var from_binary_js_1 = require("./from-binary.js");
|
|
@@ -47,4 +48,6 @@ Object.defineProperty(exports, "hasExtension", { enumerable: true, get: function
|
|
|
47
48
|
Object.defineProperty(exports, "getExtension", { enumerable: true, get: function () { return extensions_js_1.getExtension; } });
|
|
48
49
|
Object.defineProperty(exports, "setExtension", { enumerable: true, get: function () { return extensions_js_1.setExtension; } });
|
|
49
50
|
Object.defineProperty(exports, "clearExtension", { enumerable: true, get: function () { return extensions_js_1.clearExtension; } });
|
|
51
|
+
Object.defineProperty(exports, "hasOption", { enumerable: true, get: function () { return extensions_js_1.hasOption; } });
|
|
52
|
+
Object.defineProperty(exports, "getOption", { enumerable: true, get: function () { return extensions_js_1.getOption; } });
|
|
50
53
|
__exportStar(require("./proto-int64.js"), exports);
|