@bufbuild/protobuf
Advanced tools
Comparing version 2.0.0-alpha.2 to 2.0.0-alpha.3
import type { MessageShape } from "./types.js"; | ||
import type { DescMessage } from "./desc-types.js"; | ||
import { type DescMessage } from "./descriptors.js"; | ||
/** | ||
@@ -4,0 +4,0 @@ * Create a deep copy of a message, including extensions and unknown fields. |
@@ -17,5 +17,5 @@ "use strict"; | ||
exports.clone = void 0; | ||
const descriptors_js_1 = require("./descriptors.js"); | ||
const reflect_js_1 = require("./reflect/reflect.js"); | ||
const guard_js_1 = require("./reflect/guard.js"); | ||
const scalar_js_1 = require("./reflect/scalar.js"); | ||
/** | ||
@@ -73,3 +73,3 @@ * Create a deep copy of a message, including extensions and unknown fields. | ||
} | ||
if (field.scalar == scalar_js_1.ScalarType.BYTES && value instanceof Uint8Array) { | ||
if (field.scalar == descriptors_js_1.ScalarType.BYTES && value instanceof Uint8Array) { | ||
// @ts-expect-error T cannot extend Uint8Array in practice | ||
@@ -76,0 +76,0 @@ return value.slice(); |
import type { DescriptorProto_ExtensionRange, FieldDescriptorProto_Label, FieldDescriptorProto_Type, FieldOptions_OptionRetention, FieldOptions_OptionTargetType, FieldOptions_EditionDefault, EnumValueDescriptorProto, FileDescriptorProto } from "../wkt/gen/google/protobuf/descriptor_pb.js"; | ||
import type { DescFile } from "../desc-types.js"; | ||
import type { DescFile } from "../descriptors.js"; | ||
/** | ||
@@ -4,0 +4,0 @@ * Hydrate a file descriptor for google/protobuf/descriptor.proto from a plain |
@@ -18,4 +18,3 @@ "use strict"; | ||
const restore_json_names_js_1 = require("./restore-json-names.js"); | ||
const registry_js_1 = require("../reflect/registry.js"); | ||
const assert_js_1 = require("../reflect/assert.js"); | ||
const registry_js_1 = require("../registry.js"); | ||
/** | ||
@@ -33,5 +32,4 @@ * Hydrate a file descriptor for google/protobuf/descriptor.proto from a plain | ||
const reg = (0, registry_js_1.createFileRegistry)(root, () => undefined); | ||
const file = reg.getFile(root.name); | ||
(0, assert_js_1.assert)(file); | ||
return file; | ||
// non-null assertion because we just created the registry from the file we look up | ||
return reg.getFile(root.name); | ||
} | ||
@@ -38,0 +36,0 @@ exports.boot = boot; |
@@ -1,2 +0,2 @@ | ||
import type { DescEnum, DescExtension, DescMessage, DescService } from "../desc-types.js"; | ||
import type { DescEnum, DescExtension, DescMessage, DescService } from "../descriptors.js"; | ||
import type { FileDescriptorProto } from "../wkt/gen/google/protobuf/descriptor_pb.js"; | ||
@@ -3,0 +3,0 @@ import type { FileDescriptorProtoBoot } from "./boot.js"; |
@@ -18,3 +18,2 @@ "use strict"; | ||
const names_js_1 = require("../reflect/names.js"); | ||
const assert_js_1 = require("../reflect/assert.js"); | ||
const fields_js_1 = require("../fields.js"); | ||
@@ -122,13 +121,13 @@ const base64_encoding_js_1 = require("../wire/base64-encoding.js"); | ||
var _a; | ||
(0, assert_js_1.assert)(proto.name == "google/protobuf/descriptor.proto"); | ||
(0, assert_js_1.assert)(proto.package == "google.protobuf"); | ||
(0, assert_js_1.assert)(!proto.dependency.length); | ||
(0, assert_js_1.assert)(!proto.publicDependency.length); | ||
(0, assert_js_1.assert)(!proto.weakDependency.length); | ||
(0, assert_js_1.assert)(!proto.service.length); | ||
(0, assert_js_1.assert)(!proto.extension.length); | ||
(0, assert_js_1.assert)(proto.sourceCodeInfo === undefined); | ||
(0, assert_js_1.assert)(proto.syntax == "" || proto.syntax == "proto2"); | ||
(0, assert_js_1.assert)(!((_a = proto.options) === null || _a === void 0 ? void 0 : _a.features)); // we're dropping file options | ||
(0, assert_js_1.assert)(proto.edition === descriptor_pb_js_1.Edition.EDITION_UNKNOWN); | ||
assert(proto.name == "google/protobuf/descriptor.proto"); | ||
assert(proto.package == "google.protobuf"); | ||
assert(!proto.dependency.length); | ||
assert(!proto.publicDependency.length); | ||
assert(!proto.weakDependency.length); | ||
assert(!proto.service.length); | ||
assert(!proto.extension.length); | ||
assert(proto.sourceCodeInfo === undefined); | ||
assert(proto.syntax == "" || proto.syntax == "proto2"); | ||
assert(!((_a = proto.options) === null || _a === void 0 ? void 0 : _a.features)); // we're dropping file options | ||
assert(proto.edition === descriptor_pb_js_1.Edition.EDITION_UNKNOWN); | ||
return { | ||
@@ -143,6 +142,5 @@ name: proto.name, | ||
function createDescriptorBoot(proto) { | ||
(0, assert_js_1.assert)(proto.extension.length == 0); | ||
(0, assert_js_1.assert)(!proto.oneofDecl.length); | ||
(0, assert_js_1.assert)(!proto.options); | ||
(0, assert_js_1.assert)(!proto.reservedName.length); // we're also dropping reserved_range | ||
assert(proto.extension.length == 0); | ||
assert(!proto.oneofDecl.length); | ||
assert(!proto.options); | ||
const b = { | ||
@@ -162,3 +160,3 @@ name: proto.name, | ||
b.extensionRange = proto.extensionRange.map((r) => { | ||
(0, assert_js_1.assert)(!r.options); | ||
assert(!r.options); | ||
return { start: r.start, end: r.end }; | ||
@@ -170,7 +168,7 @@ }); | ||
function createFieldDescriptorBoot(proto) { | ||
(0, assert_js_1.assert)((0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldDescriptorProtoDesc.field.name)); | ||
(0, assert_js_1.assert)((0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldDescriptorProtoDesc.field.number)); | ||
(0, assert_js_1.assert)((0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldDescriptorProtoDesc.field.type)); | ||
(0, assert_js_1.assert)(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldDescriptorProtoDesc.field.oneofIndex)); | ||
(0, assert_js_1.assert)(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldDescriptorProtoDesc.field.jsonName) || | ||
assert((0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldDescriptorProtoDesc.field.name)); | ||
assert((0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldDescriptorProtoDesc.field.number)); | ||
assert((0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldDescriptorProtoDesc.field.type)); | ||
assert(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldDescriptorProtoDesc.field.oneofIndex)); | ||
assert(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldDescriptorProtoDesc.field.jsonName) || | ||
proto.jsonName === (0, names_js_1.protoCamelCase)(proto.name)); | ||
@@ -201,14 +199,14 @@ const b = { | ||
const b = {}; | ||
(0, assert_js_1.assert)(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.ctype)); | ||
assert(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.ctype)); | ||
if ((0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.packed)) { | ||
b.packed = proto.packed; | ||
} | ||
(0, assert_js_1.assert)(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.jstype)); | ||
(0, assert_js_1.assert)(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.lazy)); | ||
(0, assert_js_1.assert)(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.unverifiedLazy)); | ||
assert(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.jstype)); | ||
assert(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.lazy)); | ||
assert(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.unverifiedLazy)); | ||
if ((0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.deprecated)) { | ||
b.deprecated = proto.deprecated; | ||
} | ||
(0, assert_js_1.assert)(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.weak)); | ||
(0, assert_js_1.assert)(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.debugRedact)); | ||
assert(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.weak)); | ||
assert(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.debugRedact)); | ||
if ((0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.retention)) { | ||
@@ -226,14 +224,12 @@ b.retention = proto.retention; | ||
} | ||
(0, assert_js_1.assert)(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.features)); | ||
(0, assert_js_1.assert)(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.uninterpretedOption)); | ||
assert(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.features)); | ||
assert(!(0, fields_js_1.isFieldSet)(proto, descriptor_pb_js_1.FieldOptionsDesc.field.uninterpretedOption)); | ||
return b; | ||
} | ||
function createEnumDescriptorBoot(proto) { | ||
(0, assert_js_1.assert)(!proto.reservedName.length); | ||
(0, assert_js_1.assert)(!proto.reservedRange.length); | ||
(0, assert_js_1.assert)(!proto.options); | ||
assert(!proto.options); | ||
return { | ||
name: proto.name, | ||
value: proto.value.map((v) => { | ||
(0, assert_js_1.assert)(!v.options); | ||
assert(!v.options); | ||
return { | ||
@@ -246,1 +242,10 @@ name: v.name, | ||
} | ||
/** | ||
* Assert that condition is truthy or throw error. | ||
*/ | ||
function assert(condition) { | ||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions -- we want the implicit conversion to boolean | ||
if (!condition) { | ||
throw new Error(); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { DescEnum, DescFile } from "../desc-types.js"; | ||
import type { DescEnum, DescFile } from "../descriptors.js"; | ||
import type { GenDescEnum } from "./types.js"; | ||
@@ -3,0 +3,0 @@ /** |
import type { Message } from "../types.js"; | ||
import type { DescFile } from "../desc-types.js"; | ||
import type { DescFile } from "../descriptors.js"; | ||
import type { GenDescExtension } from "./types.js"; | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import type { DescFile } from "../desc-types.js"; | ||
import type { DescFile } from "../descriptors.js"; | ||
/** | ||
@@ -3,0 +3,0 @@ * Hydrate a file descriptor. |
@@ -17,6 +17,5 @@ "use strict"; | ||
exports.fileDesc = void 0; | ||
const index_js_1 = require("../wire/index.js"); | ||
const base64_encoding_js_1 = require("../wire/base64-encoding.js"); | ||
const descriptor_pb_js_1 = require("../wkt/gen/google/protobuf/descriptor_pb.js"); | ||
const registry_js_1 = require("../reflect/registry.js"); | ||
const assert_js_1 = require("../reflect/assert.js"); | ||
const registry_js_1 = require("../registry.js"); | ||
const restore_json_names_js_1 = require("./restore-json-names.js"); | ||
@@ -31,10 +30,9 @@ const from_binary_js_1 = require("../from-binary.js"); | ||
var _a; | ||
const root = (0, from_binary_js_1.fromBinary)(descriptor_pb_js_1.FileDescriptorProtoDesc, (0, index_js_1.base64Decode)(b64)); | ||
const root = (0, from_binary_js_1.fromBinary)(descriptor_pb_js_1.FileDescriptorProtoDesc, (0, base64_encoding_js_1.base64Decode)(b64)); | ||
root.messageType.forEach(restore_json_names_js_1.restoreJsonNames); | ||
root.dependency = (_a = imports === null || imports === void 0 ? void 0 : imports.map((f) => f.proto.name)) !== null && _a !== void 0 ? _a : []; | ||
const reg = (0, registry_js_1.createFileRegistry)(root, (protoFileName) => imports === null || imports === void 0 ? void 0 : imports.find((f) => f.proto.name === protoFileName)); | ||
const file = reg.getFile(root.name); | ||
(0, assert_js_1.assert)(file); | ||
return file; | ||
// non-null assertion because we just created the registry from the file we look up | ||
return reg.getFile(root.name); | ||
} | ||
exports.fileDesc = fileDesc; |
@@ -9,2 +9,3 @@ export * from "./boot.js"; | ||
export * from "./symbols.js"; | ||
export * from "./scalar.js"; | ||
export * from "./types.js"; |
@@ -38,2 +38,3 @@ "use strict"; | ||
__exportStar(require("./symbols.js"), exports); | ||
__exportStar(require("./scalar.js"), exports); | ||
__exportStar(require("./types.js"), exports); |
import type { Message } from "../types.js"; | ||
import type { DescFile } from "../desc-types.js"; | ||
import type { DescFile } from "../descriptors.js"; | ||
import type { GenDescMessage } from "./types.js"; | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,3 +0,3 @@ | ||
import type { GenDescService, GenDescServiceShape } from "./types.js"; | ||
import type { DescFile } from "../desc-types.js"; | ||
import type { GenDescService, GenDescServiceMethods } from "./types.js"; | ||
import type { DescFile } from "../descriptors.js"; | ||
/** | ||
@@ -8,2 +8,2 @@ * Hydrate a service descriptor. | ||
*/ | ||
export declare function serviceDesc<T extends GenDescServiceShape>(file: DescFile, path: number, ...paths: number[]): GenDescService<T>; | ||
export declare function serviceDesc<T extends GenDescServiceMethods>(file: DescFile, path: number, ...paths: number[]): GenDescService<T>; |
import type { Message } from "../types.js"; | ||
import type { DescEnum, DescExtension, DescField, DescFile, DescMessage, DescService } from "../desc-types.js"; | ||
import type { DescEnum, DescExtension, DescField, DescFile, DescMessage, DescMethod, DescService } from "../descriptors.js"; | ||
/** | ||
@@ -46,13 +46,11 @@ * Describes a protobuf source file. | ||
*/ | ||
export type GenDescService<RuntimeShape extends GenDescServiceShape> = DescService & brand<RuntimeShape>; | ||
export type GenDescService<RuntimeShape extends GenDescServiceMethods> = Omit<DescService, "method"> & { | ||
method: { | ||
[K in keyof RuntimeShape]: RuntimeShape[K] & DescMethod; | ||
}; | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
export type GenDescServiceShape = { | ||
[localName: string]: { | ||
kind: "unary" | "server_streaming" | "client_streaming" | "bidi_streaming"; | ||
I: Message; | ||
O: Message; | ||
}; | ||
}; | ||
export type GenDescServiceMethods = Record<string, Pick<DescMethod, "input" | "output" | "methodKind">>; | ||
declare class brand<A, B = unknown> { | ||
@@ -59,0 +57,0 @@ protected a: A | boolean; |
@@ -1,2 +0,2 @@ | ||
import type { DescMessage } from "./desc-types.js"; | ||
import { type DescMessage } from "./descriptors.js"; | ||
import type { MessageInitShape, MessageShape } from "./types.js"; | ||
@@ -3,0 +3,0 @@ /** |
@@ -18,2 +18,3 @@ "use strict"; | ||
const is_message_js_1 = require("./is-message.js"); | ||
const descriptors_js_1 = require("./descriptors.js"); | ||
const scalar_js_1 = require("./reflect/scalar.js"); | ||
@@ -91,3 +92,3 @@ const guard_js_1 = require("./reflect/guard.js"); | ||
function initScalar(field, value) { | ||
if (field.scalar == scalar_js_1.ScalarType.BYTES) { | ||
if (field.scalar == descriptors_js_1.ScalarType.BYTES) { | ||
return toU8Arr(value); | ||
@@ -99,3 +100,3 @@ } | ||
if ((0, guard_js_1.isObject)(value)) { | ||
if (field.scalar == scalar_js_1.ScalarType.BYTES) { | ||
if (field.scalar == descriptors_js_1.ScalarType.BYTES) { | ||
return convertObjectValues(value, toU8Arr); | ||
@@ -111,3 +112,3 @@ } | ||
if (Array.isArray(value)) { | ||
if (field.scalar == scalar_js_1.ScalarType.BYTES) { | ||
if (field.scalar == descriptors_js_1.ScalarType.BYTES) { | ||
return value.map(toU8Arr); | ||
@@ -228,3 +229,3 @@ } | ||
if (defaultValue !== undefined) { | ||
return field.fieldKind == "scalar" && field.longType == scalar_js_1.LongType.STRING | ||
return field.fieldKind == "scalar" && field.longAsString | ||
? defaultValue.toString() | ||
@@ -234,4 +235,4 @@ : defaultValue; | ||
return field.fieldKind == "scalar" | ||
? (0, scalar_js_1.scalarZeroValue)(field.scalar, field.longType) | ||
? (0, scalar_js_1.scalarZeroValue)(field.scalar, field.longAsString) | ||
: field.enum.values[0].number; | ||
} |
import type { MessageShape } from "./types.js"; | ||
import type { DescMessage } from "./desc-types.js"; | ||
import type { DescMessage } from "./descriptors.js"; | ||
/** | ||
@@ -4,0 +4,0 @@ * Compare two messages of the same type. |
@@ -1,2 +0,2 @@ | ||
import type { AnyDesc, DescEnum, DescEnumValue, DescExtension, DescField, DescFile, DescMessage, DescMethod, DescOneof, DescService } from "./desc-types.js"; | ||
import type { AnyDesc, DescEnum, DescEnumValue, DescExtension, DescField, DescFile, DescMessage, DescMethod, DescOneof, DescService } from "./descriptors.js"; | ||
import type { ReflectMessage } from "./reflect/reflect-types.js"; | ||
@@ -3,0 +3,0 @@ import type { Extendee, ExtensionValueShape } from "./types.js"; |
@@ -17,3 +17,2 @@ "use strict"; | ||
exports.createExtensionContainer = exports.getOption = exports.hasOption = exports.hasExtension = exports.clearExtension = exports.setExtension = exports.getExtension = void 0; | ||
const assert_js_1 = require("./reflect/assert.js"); | ||
const create_js_1 = require("./create.js"); | ||
@@ -159,3 +158,3 @@ const from_binary_js_1 = require("./from-binary.js"); | ||
if ((0, wrappers_js_1.isWrapperDesc)(desc)) { | ||
return (0, scalar_js_1.scalarZeroValue)(desc.fields[0].scalar, desc.fields[0].longType); | ||
return (0, scalar_js_1.scalarZeroValue)(desc.fields[0].scalar, desc.fields[0].longAsString); | ||
} | ||
@@ -170,3 +169,5 @@ return (0, create_js_1.create)(desc); | ||
function assertExtendee(extension, message) { | ||
(0, assert_js_1.assert)(extension.extendee.typeName == message.$typeName, `extension ${extension.typeName} can only be applied to message ${extension.extendee.typeName}`); | ||
if (extension.extendee.typeName != message.$typeName) { | ||
throw new Error(`extension ${extension.typeName} can only be applied to message ${extension.extendee.typeName}`); | ||
} | ||
} |
import type { MessageShape } from "./types.js"; | ||
import type { DescField, DescMessage } from "./desc-types.js"; | ||
import type { DescField, DescMessage } from "./descriptors.js"; | ||
/** | ||
@@ -4,0 +4,0 @@ * Returns true if the field is set. |
@@ -1,2 +0,2 @@ | ||
import type { DescField, DescMessage } from "./desc-types.js"; | ||
import { type DescField, type DescMessage } from "./descriptors.js"; | ||
import type { MessageShape } from "./types.js"; | ||
@@ -30,3 +30,3 @@ import type { ReflectMessage } from "./reflect/index.js"; | ||
*/ | ||
export declare function mergeFromBinary<Desc extends DescMessage>(messageDesc: Desc, target: MessageShape<Desc>, bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MessageShape<Desc>; | ||
export declare function mergeFromBinary<Desc extends DescMessage>(messageDesc: Desc, target: MessageShape<Desc>, bytes: Uint8Array, options?: Partial<BinaryReadOptions>): void; | ||
/** | ||
@@ -33,0 +33,0 @@ * @private |
@@ -17,2 +17,3 @@ "use strict"; | ||
exports.readField = exports.mergeFromBinary = exports.fromBinary = void 0; | ||
const descriptors_js_1 = require("./descriptors.js"); | ||
const scalar_js_1 = require("./reflect/scalar.js"); | ||
@@ -48,3 +49,2 @@ const reflect_js_1 = require("./reflect/reflect.js"); | ||
readMessage((0, reflect_js_1.reflect)(messageDesc, target), new binary_encoding_js_1.BinaryReader(bytes), makeReadOptions(options), false, bytes.byteLength); | ||
return target; | ||
} | ||
@@ -98,3 +98,3 @@ exports.mergeFromBinary = mergeFromBinary; | ||
case "enum": | ||
message.set(field, readScalar(reader, scalar_js_1.ScalarType.INT32)); | ||
message.set(field, readScalar(reader, descriptors_js_1.ScalarType.INT32)); | ||
break; | ||
@@ -139,3 +139,3 @@ case "message": | ||
if (key === undefined) { | ||
key = (0, scalar_js_1.scalarZeroValue)(field.mapKey, scalar_js_1.LongType.BIGINT); | ||
key = (0, scalar_js_1.scalarZeroValue)(field.mapKey, false); | ||
} | ||
@@ -145,3 +145,3 @@ if (val === undefined) { | ||
case "scalar": | ||
val = (0, scalar_js_1.scalarZeroValue)(field.scalar, scalar_js_1.LongType.BIGINT); | ||
val = (0, scalar_js_1.scalarZeroValue)(field.scalar, false); | ||
break; | ||
@@ -164,6 +164,6 @@ case "enum": | ||
} | ||
const scalarType = (_a = field.scalar) !== null && _a !== void 0 ? _a : scalar_js_1.ScalarType.INT32; | ||
const scalarType = (_a = field.scalar) !== null && _a !== void 0 ? _a : descriptors_js_1.ScalarType.INT32; | ||
const packed = wireType == binary_encoding_js_1.WireType.LengthDelimited && | ||
scalarType != scalar_js_1.ScalarType.STRING && | ||
scalarType != scalar_js_1.ScalarType.BYTES; | ||
scalarType != descriptors_js_1.ScalarType.STRING && | ||
scalarType != descriptors_js_1.ScalarType.BYTES; | ||
if (!packed) { | ||
@@ -186,33 +186,33 @@ message.addListItem(field, readScalar(reader, scalarType)); | ||
switch (type) { | ||
case scalar_js_1.ScalarType.STRING: | ||
case descriptors_js_1.ScalarType.STRING: | ||
return reader.string(); | ||
case scalar_js_1.ScalarType.BOOL: | ||
case descriptors_js_1.ScalarType.BOOL: | ||
return reader.bool(); | ||
case scalar_js_1.ScalarType.DOUBLE: | ||
case descriptors_js_1.ScalarType.DOUBLE: | ||
return reader.double(); | ||
case scalar_js_1.ScalarType.FLOAT: | ||
case descriptors_js_1.ScalarType.FLOAT: | ||
return reader.float(); | ||
case scalar_js_1.ScalarType.INT32: | ||
case descriptors_js_1.ScalarType.INT32: | ||
return reader.int32(); | ||
case scalar_js_1.ScalarType.INT64: | ||
case descriptors_js_1.ScalarType.INT64: | ||
return reader.int64(); | ||
case scalar_js_1.ScalarType.UINT64: | ||
case descriptors_js_1.ScalarType.UINT64: | ||
return reader.uint64(); | ||
case scalar_js_1.ScalarType.FIXED64: | ||
case descriptors_js_1.ScalarType.FIXED64: | ||
return reader.fixed64(); | ||
case scalar_js_1.ScalarType.BYTES: | ||
case descriptors_js_1.ScalarType.BYTES: | ||
return reader.bytes(); | ||
case scalar_js_1.ScalarType.FIXED32: | ||
case descriptors_js_1.ScalarType.FIXED32: | ||
return reader.fixed32(); | ||
case scalar_js_1.ScalarType.SFIXED32: | ||
case descriptors_js_1.ScalarType.SFIXED32: | ||
return reader.sfixed32(); | ||
case scalar_js_1.ScalarType.SFIXED64: | ||
case descriptors_js_1.ScalarType.SFIXED64: | ||
return reader.sfixed64(); | ||
case scalar_js_1.ScalarType.SINT64: | ||
case descriptors_js_1.ScalarType.SINT64: | ||
return reader.sint64(); | ||
case scalar_js_1.ScalarType.UINT32: | ||
case descriptors_js_1.ScalarType.UINT32: | ||
return reader.uint32(); | ||
case scalar_js_1.ScalarType.SINT32: | ||
case descriptors_js_1.ScalarType.SINT32: | ||
return reader.sint32(); | ||
} | ||
} |
@@ -1,4 +0,4 @@ | ||
import type { DescMessage } from "./desc-types.js"; | ||
import { type DescMessage } from "./descriptors.js"; | ||
import type { JsonValue } from "./json-value.js"; | ||
import type { Registry } from "./reflect/registry.js"; | ||
import type { Registry } from "./registry.js"; | ||
import type { MessageShape } from "./types.js"; | ||
@@ -34,3 +34,3 @@ /** | ||
*/ | ||
export declare function mergeFromJsonString<Desc extends DescMessage>(messageDesc: Desc, target: MessageShape<Desc>, json: string, options?: Partial<JsonReadOptions>): MessageShape<Desc>; | ||
export declare function mergeFromJsonString<Desc extends DescMessage>(messageDesc: Desc, target: MessageShape<Desc>, json: string, options?: Partial<JsonReadOptions>): void; | ||
/** | ||
@@ -49,2 +49,2 @@ * Parse a message from a JSON value. | ||
*/ | ||
export declare function mergeFromJson<Desc extends DescMessage>(messageDesc: Desc, target: MessageShape<Desc>, json: JsonValue, options?: Partial<JsonReadOptions>): MessageShape<Desc>; | ||
export declare function mergeFromJson<Desc extends DescMessage>(messageDesc: Desc, target: MessageShape<Desc>, json: JsonValue, options?: Partial<JsonReadOptions>): void; |
@@ -17,12 +17,12 @@ "use strict"; | ||
exports.mergeFromJson = exports.fromJson = exports.mergeFromJsonString = exports.fromJsonString = void 0; | ||
const assert_js_1 = require("./reflect/assert.js"); | ||
/* eslint-disable no-case-declarations,@typescript-eslint/restrict-template-expressions */ | ||
const descriptors_js_1 = require("./descriptors.js"); | ||
const proto_int64_js_1 = require("./proto-int64.js"); | ||
const create_js_1 = require("./create.js"); | ||
const reflect_js_1 = require("./reflect/reflect.js"); | ||
const error_js_1 = require("./reflect/error.js"); | ||
const reflect_check_js_1 = require("./reflect/reflect-check.js"); | ||
const scalar_js_1 = require("./reflect/scalar.js"); | ||
const base64_encoding_js_1 = require("./wire/base64-encoding.js"); | ||
const text_encoding_js_1 = require("./wire/text-encoding.js"); | ||
const index_js_1 = require("./wkt/index.js"); | ||
const wrappers_js_1 = require("./wkt/wrappers.js"); | ||
const extensions_js_1 = require("./extensions.js"); | ||
@@ -53,3 +53,3 @@ // Default options for parsing JSON. | ||
function mergeFromJsonString(messageDesc, target, json, options) { | ||
return mergeFromJson(messageDesc, target, parseJsonString(json, messageDesc.typeName), options); | ||
mergeFromJson(messageDesc, target, parseJsonString(json, messageDesc.typeName), options); | ||
} | ||
@@ -62,3 +62,14 @@ exports.mergeFromJsonString = mergeFromJsonString; | ||
const msg = (0, reflect_js_1.reflect)(messageDesc); | ||
readMessage(msg, json, makeReadOptions(options)); | ||
try { | ||
readMessage(msg, json, makeReadOptions(options)); | ||
} | ||
catch (e) { | ||
if ((0, error_js_1.isFieldError)(e)) { | ||
// @ts-expect-error we use the ES2022 error CTOR option "cause" for better stack traces | ||
throw new Error(`cannot decode ${e.field()} from JSON: ${e.message}`, { | ||
cause: e, | ||
}); | ||
} | ||
throw e; | ||
} | ||
return msg.message; | ||
@@ -77,4 +88,14 @@ } | ||
function mergeFromJson(messageDesc, target, json, options) { | ||
readMessage((0, reflect_js_1.reflect)(messageDesc, target), json, makeReadOptions(options)); | ||
return target; | ||
try { | ||
readMessage((0, reflect_js_1.reflect)(messageDesc, target), json, makeReadOptions(options)); | ||
} | ||
catch (e) { | ||
if ((0, error_js_1.isFieldError)(e)) { | ||
// @ts-expect-error we use the ES2022 error CTOR option "cause" for better stack traces | ||
throw new Error(`cannot decode ${e.field()} from JSON: ${e.message}`, { | ||
cause: e, | ||
}); | ||
} | ||
throw e; | ||
} | ||
} | ||
@@ -88,3 +109,3 @@ exports.mergeFromJson = mergeFromJson; | ||
if (json == null || Array.isArray(json) || typeof json != "object") { | ||
throw new Error(`cannot decode message ${msg.desc.typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
throw new Error(`cannot decode ${msg.desc} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
} | ||
@@ -106,5 +127,5 @@ const oneofSeen = new Map(); | ||
if (seen !== undefined) { | ||
throw new Error(`cannot decode message ${msg.desc.typeName} from JSON: multiple keys for oneof "${field.oneof.name}" present: "${seen}", "${jsonKey}"`); | ||
throw new error_js_1.FieldError(field.oneof, `oneof set multiple times by ${seen.name} and ${field.name}`); | ||
} | ||
oneofSeen.set(field.oneof, jsonKey); | ||
oneofSeen.set(field.oneof, field); | ||
} | ||
@@ -124,3 +145,3 @@ readField(msg, field, jsonValue, opts); | ||
if (!extension && !opts.ignoreUnknownFields) { | ||
throw new Error(`cannot decode message ${msg.desc.typeName} from JSON: key "${jsonKey}" is unknown`); | ||
throw new Error(`cannot decode ${msg.desc} from JSON: key "${jsonKey}" is unknown`); | ||
} | ||
@@ -154,19 +175,9 @@ } | ||
if (typeof json != "object" || Array.isArray(json)) { | ||
throw new Error(`cannot decode field ${msg.desc.typeName}.${field.name} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
throw new error_js_1.FieldError(field, "expected object, got " + (0, reflect_check_js_1.formatVal)(json)); | ||
} | ||
for (const [jsonMapKey, jsonMapValue] of Object.entries(json)) { | ||
if (jsonMapValue === null) { | ||
throw new Error(`cannot decode field ${msg.desc.typeName}.${field.name} from JSON: map value null`); | ||
throw new error_js_1.FieldError(field, "map value must not be null"); | ||
} | ||
let key; | ||
try { | ||
key = readMapKey(field.mapKey, jsonMapKey); | ||
} | ||
catch (e) { | ||
let m = `cannot decode map key for field ${msg.desc.typeName}.${field.name} from JSON: ${(0, reflect_check_js_1.formatVal)(jsonMapKey)}`; | ||
if (e instanceof Error && e.message.length > 0) { | ||
m += `: ${e.message}`; | ||
} | ||
throw new Error(m); | ||
} | ||
const key = mapKeyFromJson(field.mapKey, jsonMapKey); | ||
switch (field.mapKind) { | ||
@@ -176,3 +187,8 @@ case "message": | ||
readMessage(msgValue, jsonMapValue, opts); | ||
msg.setMapEntry(field, key, msgValue); | ||
// TODO fix types | ||
// @ts-expect-error TODO | ||
const err = msg.setMapEntry(field, key, msgValue); | ||
if (err) { | ||
throw err; | ||
} | ||
break; | ||
@@ -182,16 +198,18 @@ case "enum": | ||
if (enumValue !== tokenIgnoredUnknownEnum) { | ||
msg.setMapEntry(field, key, enumValue); | ||
// TODO fix types | ||
// @ts-expect-error TODO | ||
const err = msg.setMapEntry(field, key, enumValue); | ||
if (err) { | ||
throw err; | ||
} | ||
} | ||
break; | ||
case "scalar": | ||
try { | ||
msg.setMapEntry(field, key, readScalar(field.scalar, jsonMapValue, true)); | ||
const err2 = msg.setMapEntry(field, | ||
// TODO fix types | ||
// @ts-expect-error TODO | ||
key, scalarFromJson(field, jsonMapValue, true)); | ||
if (err2) { | ||
throw err2; | ||
} | ||
catch (e) { | ||
let m = `cannot decode map value for field ${msg.desc.typeName}.${field.name} from JSON: ${(0, reflect_check_js_1.formatVal)(jsonMapValue)}`; | ||
if (e instanceof Error && e.message.length > 0) { | ||
m += `: ${e.message}`; | ||
} | ||
throw new Error(m); | ||
} | ||
break; | ||
@@ -206,7 +224,7 @@ } | ||
if (!Array.isArray(json)) { | ||
throw new Error(`cannot decode field ${msg.desc.typeName}.${field.name} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
throw new error_js_1.FieldError(field, "expected Array, got " + (0, reflect_check_js_1.formatVal)(json)); | ||
} | ||
for (const jsonItem of json) { | ||
if (jsonItem === null) { | ||
throw new Error(`cannot decode field ${msg.desc.typeName}.${field.name} from JSON: ${(0, reflect_check_js_1.formatVal)(jsonItem)}`); | ||
throw new error_js_1.FieldError(field, "list item must not be null"); | ||
} | ||
@@ -226,12 +244,6 @@ switch (field.listKind) { | ||
case "scalar": | ||
try { | ||
msg.addListItem(field, readScalar(field.scalar, jsonItem, true)); | ||
const err = msg.addListItem(field, scalarFromJson(field, jsonItem, true)); | ||
if (err) { | ||
throw err; | ||
} | ||
catch (e) { | ||
let m = `cannot decode field ${msg.desc.typeName}.${field.name} from JSON: ${(0, reflect_check_js_1.formatVal)(jsonItem)}`; | ||
if (e instanceof Error && e.message.length > 0) { | ||
m += `: ${e.message}`; | ||
} | ||
throw new Error(m); | ||
} | ||
break; | ||
@@ -260,33 +272,15 @@ } | ||
function readScalarField(msg, field, json) { | ||
try { | ||
const scalarValue = readScalar(field.scalar, json, false); | ||
if (scalarValue === tokenNull) { | ||
msg.clear(field); | ||
} | ||
else { | ||
msg.set(field, scalarValue); | ||
} | ||
const scalarValue = scalarFromJson(field, json, false); | ||
if (scalarValue === tokenNull) { | ||
msg.clear(field); | ||
} | ||
catch (e) { | ||
let m = `cannot decode field ${msg.desc.typeName}.${field.name} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`; | ||
if (e instanceof Error && e.message.length > 0) { | ||
m += `: ${e.message}`; | ||
else { | ||
// TODO fix type error | ||
// @ts-expect-error TODO | ||
const err = msg.set(field, scalarValue); | ||
if (err) { | ||
throw err; | ||
} | ||
throw new Error(m); | ||
} | ||
} | ||
function readMapKey(type, json) { | ||
if (type === scalar_js_1.ScalarType.BOOL) { | ||
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check | ||
switch (json) { | ||
case "true": | ||
json = true; | ||
break; | ||
case "false": | ||
json = false; | ||
break; | ||
} | ||
} | ||
return readScalar(type, json, true); | ||
} | ||
const tokenIgnoredUnknownEnum = Symbol(); | ||
@@ -317,21 +311,22 @@ function readEnum(desc, json, ignoreUnknownFields, nullAsZeroValue) { | ||
} | ||
throw new Error(`cannot decode enum ${desc.typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
throw new Error(`cannot decode ${desc} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
} | ||
const tokenNull = Symbol(); | ||
function readScalar(type, json, nullAsZeroValue) { | ||
function scalarFromJson(field, json, nullAsZeroValue) { | ||
if (json === null) { | ||
if (nullAsZeroValue) { | ||
return (0, scalar_js_1.scalarZeroValue)(type, scalar_js_1.LongType.BIGINT); | ||
return (0, scalar_js_1.scalarZeroValue)(field.scalar, false); | ||
} | ||
return tokenNull; | ||
} | ||
// every valid case in the switch below returns, and every fall | ||
// through is regarded as a failure. | ||
switch (type) { | ||
// int64, sfixed64, sint64, fixed64, uint64: Reflect supports string and number. | ||
// string, bool: Supported by reflect. | ||
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check | ||
switch (field.scalar) { | ||
// float, double: JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity". | ||
// Either numbers or strings are accepted. Exponent notation is also accepted. | ||
case scalar_js_1.ScalarType.DOUBLE: | ||
case scalar_js_1.ScalarType.FLOAT: | ||
case descriptors_js_1.ScalarType.DOUBLE: | ||
case descriptors_js_1.ScalarType.FLOAT: | ||
if (json === "NaN") | ||
return Number.NaN; | ||
return NaN; | ||
if (json === "Infinity") | ||
@@ -341,83 +336,106 @@ return Number.POSITIVE_INFINITY; | ||
return Number.NEGATIVE_INFINITY; | ||
if (json === "") { | ||
// empty string is not a number | ||
if (typeof json == "number") { | ||
if (isNaN(json)) { | ||
// NaN must be encoded with string constants | ||
throw new error_js_1.FieldError(field, "unexpected NaN number"); | ||
} | ||
if (!isFinite(json)) { | ||
// Infinity must be encoded with string constants | ||
throw new error_js_1.FieldError(field, "unexpected infinite number"); | ||
} | ||
break; | ||
} | ||
if (typeof json == "string" && json.trim().length !== json.length) { | ||
// extra whitespace | ||
break; | ||
if (typeof json == "string") { | ||
if (json === "") { | ||
// empty string is not a number | ||
break; | ||
} | ||
if (json.trim().length !== json.length) { | ||
// extra whitespace | ||
break; | ||
} | ||
const float = Number(json); | ||
if (!isFinite(float)) { | ||
// Infinity and NaN must be encoded with string constants | ||
break; | ||
} | ||
return float; | ||
} | ||
if (typeof json != "string" && typeof json != "number") { | ||
break; | ||
} | ||
const float = Number(json); | ||
if (Number.isNaN(float)) { | ||
// not a number | ||
break; | ||
} | ||
if (!Number.isFinite(float)) { | ||
// infinity and -infinity are handled by string representation above, so this is an error | ||
break; | ||
} | ||
if (type == scalar_js_1.ScalarType.FLOAT) | ||
(0, assert_js_1.assertFloat32)(float); | ||
return float; | ||
break; | ||
// int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted. | ||
case scalar_js_1.ScalarType.INT32: | ||
case scalar_js_1.ScalarType.FIXED32: | ||
case scalar_js_1.ScalarType.SFIXED32: | ||
case scalar_js_1.ScalarType.SINT32: | ||
case scalar_js_1.ScalarType.UINT32: | ||
let int32; | ||
if (typeof json == "number") | ||
int32 = json; | ||
else if (typeof json == "string" && json.length > 0) { | ||
if (json.trim().length === json.length) | ||
int32 = Number(json); | ||
case descriptors_js_1.ScalarType.INT32: | ||
case descriptors_js_1.ScalarType.FIXED32: | ||
case descriptors_js_1.ScalarType.SFIXED32: | ||
case descriptors_js_1.ScalarType.SINT32: | ||
case descriptors_js_1.ScalarType.UINT32: | ||
return int32FromJson(json); | ||
// bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings. | ||
// Either standard or URL-safe base64 encoding with/without paddings are accepted. | ||
case descriptors_js_1.ScalarType.BYTES: | ||
if (typeof json == "string") { | ||
if (json === "") { | ||
return new Uint8Array(0); | ||
} | ||
try { | ||
return (0, base64_encoding_js_1.base64Decode)(json); | ||
} | ||
catch (e) { | ||
const message = e instanceof Error ? e.message : String(e); | ||
throw new error_js_1.FieldError(field, message); | ||
} | ||
} | ||
if (int32 === undefined) | ||
break; | ||
if (type == scalar_js_1.ScalarType.UINT32 || type == scalar_js_1.ScalarType.FIXED32) | ||
(0, assert_js_1.assertUInt32)(int32); | ||
else | ||
(0, assert_js_1.assertInt32)(int32); | ||
return int32; | ||
// int64, fixed64, uint64: JSON value will be a decimal string. Either numbers or strings are accepted. | ||
case scalar_js_1.ScalarType.INT64: | ||
case scalar_js_1.ScalarType.SFIXED64: | ||
case scalar_js_1.ScalarType.SINT64: | ||
if (typeof json != "number" && typeof json != "string") | ||
break; | ||
return proto_int64_js_1.protoInt64.parse(json); | ||
case scalar_js_1.ScalarType.FIXED64: | ||
case scalar_js_1.ScalarType.UINT64: | ||
if (typeof json != "number" && typeof json != "string") | ||
break; | ||
return proto_int64_js_1.protoInt64.uParse(json); | ||
// bool: | ||
case scalar_js_1.ScalarType.BOOL: | ||
if (typeof json !== "boolean") | ||
break; | ||
return json; | ||
// string: | ||
case scalar_js_1.ScalarType.STRING: | ||
if (typeof json !== "string") { | ||
break; | ||
break; | ||
} | ||
return json; | ||
} | ||
/** | ||
* Try to parse a JSON value to a map key for the reflect API. | ||
* | ||
* Returns the input if the JSON value cannot be converted. | ||
*/ | ||
function mapKeyFromJson(type, json) { | ||
switch (type) { | ||
case descriptors_js_1.ScalarType.BOOL: | ||
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check | ||
switch (json) { | ||
case "true": | ||
return true; | ||
case "false": | ||
return false; | ||
} | ||
// A string must always contain UTF-8 encoded or 7-bit ASCII. | ||
if (!(0, text_encoding_js_1.getTextEncoding)().checkUtf8(json)) { | ||
throw new Error("invalid UTF8"); | ||
} | ||
return json; | ||
// bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings. | ||
// Either standard or URL-safe base64 encoding with/without paddings are accepted. | ||
case scalar_js_1.ScalarType.BYTES: | ||
if (json === "") | ||
return new Uint8Array(0); | ||
if (typeof json !== "string") | ||
break; | ||
return (0, base64_encoding_js_1.base64Decode)(json); | ||
case descriptors_js_1.ScalarType.INT32: | ||
case descriptors_js_1.ScalarType.FIXED32: | ||
case descriptors_js_1.ScalarType.UINT32: | ||
case descriptors_js_1.ScalarType.SFIXED32: | ||
case descriptors_js_1.ScalarType.SINT32: | ||
return int32FromJson(json); | ||
default: | ||
return json; | ||
} | ||
throw new Error(); | ||
} | ||
/** | ||
* Try to parse a JSON value to a 32-bit integer for the reflect API. | ||
* | ||
* Returns the input if the JSON value cannot be converted. | ||
*/ | ||
function int32FromJson(json) { | ||
if (typeof json == "string") { | ||
if (json === "") { | ||
// empty string is not a number | ||
return json; | ||
} | ||
if (json.trim().length !== json.length) { | ||
// extra whitespace | ||
return json; | ||
} | ||
const num = Number(json); | ||
if (Number.isNaN(num)) { | ||
// not a number | ||
return json; | ||
} | ||
return num; | ||
} | ||
return json; | ||
} | ||
function parseJsonString(jsonString, typeName) { | ||
@@ -428,3 +446,6 @@ try { | ||
catch (e) { | ||
throw new Error(`cannot decode ${typeName} from JSON: ${e instanceof Error ? e.message : String(e)}`); | ||
const message = e instanceof Error ? e.message : String(e); | ||
throw new Error(`cannot decode message ${typeName} from JSON: ${message}`, | ||
// @ts-expect-error we use the ES2022 error CTOR option "cause" for better stack traces | ||
{ cause: e }); | ||
} | ||
@@ -459,3 +480,3 @@ } | ||
default: | ||
if ((0, wrappers_js_1.isWrapperDesc)(msg.desc)) { | ||
if ((0, index_js_1.isWrapperDesc)(msg.desc)) { | ||
const valueField = msg.desc.fields[0]; | ||
@@ -466,3 +487,6 @@ if (jsonValue === null) { | ||
else { | ||
msg.set(valueField, readScalar(valueField.scalar, jsonValue, true)); | ||
const err = msg.set(valueField, scalarFromJson(valueField, jsonValue, true)); | ||
if (err) { | ||
throw err; | ||
} | ||
} | ||
@@ -477,3 +501,3 @@ return true; | ||
if (json === null || Array.isArray(json) || typeof json != "object") { | ||
throw new Error(`cannot decode message ${any.$typeName} from JSON: expected object but got ${json === null ? "null" : Array.isArray(json) ? "array" : typeof json}`); | ||
throw new Error(`cannot decode message ${any.$typeName} from JSON: expected object but got ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
} | ||
@@ -487,3 +511,9 @@ if (Object.keys(json).length == 0) { | ||
} | ||
const typeName = typeUrlToName(typeUrl), desc = (_a = opts.registry) === null || _a === void 0 ? void 0 : _a.getMessage(typeName); | ||
const typeName = typeUrl.includes("/") | ||
? typeUrl.substring(typeUrl.lastIndexOf("/") + 1) | ||
: typeUrl; | ||
if (!typeName.length) { | ||
throw new Error(`cannot decode message ${any.$typeName} from JSON: "@type" is invalid`); | ||
} | ||
const desc = (_a = opts.registry) === null || _a === void 0 ? void 0 : _a.getMessage(typeName); | ||
if (!desc) { | ||
@@ -507,7 +537,7 @@ throw new Error(`cannot decode message ${any.$typeName} from JSON: ${typeUrl} is not in the type registry`); | ||
if (typeof json !== "string") { | ||
throw new Error(`cannot decode ${timestamp.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
throw new Error(`cannot decode message ${timestamp.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
} | ||
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]))$/); | ||
if (!matches) { | ||
throw new Error(`cannot decode ${timestamp.$typeName} from JSON: invalid RFC 3339 string`); | ||
throw new Error(`cannot decode message ${timestamp.$typeName} from JSON: invalid RFC 3339 string`); | ||
} | ||
@@ -518,3 +548,3 @@ const ms = Date.parse( | ||
if (Number.isNaN(ms)) { | ||
throw new Error(`cannot decode ${timestamp.$typeName} from JSON: invalid RFC 3339 string`); | ||
throw new Error(`cannot decode message ${timestamp.$typeName} from JSON: invalid RFC 3339 string`); | ||
} | ||
@@ -535,11 +565,11 @@ if (ms < Date.parse("0001-01-01T00:00:00Z") || | ||
if (typeof json !== "string") { | ||
throw new Error(`cannot decode ${duration.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
throw new Error(`cannot decode message ${duration.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
} | ||
const match = json.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/); | ||
if (match === null) { | ||
throw new Error(`cannot decode ${duration.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
throw new Error(`cannot decode message ${duration.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
} | ||
const longSeconds = Number(match[1]); | ||
if (longSeconds > 315576000000 || longSeconds < -315576000000) { | ||
throw new Error(`cannot decode ${duration.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
throw new Error(`cannot decode message ${duration.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
} | ||
@@ -558,3 +588,3 @@ duration.seconds = proto_int64_js_1.protoInt64.parse(longSeconds); | ||
if (typeof json !== "string") { | ||
throw new Error(`cannot decode ${fieldMask.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
throw new Error(`cannot decode message ${fieldMask.$typeName} from JSON: ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
} | ||
@@ -566,3 +596,3 @@ if (json === "") { | ||
if (str.includes("_")) { | ||
throw new Error(`cannot decode ${fieldMask.$typeName} from JSON: path names must be lowerCamelCase`); | ||
throw new Error(`cannot decode message ${fieldMask.$typeName} from JSON: path names must be lowerCamelCase`); | ||
} | ||
@@ -576,3 +606,3 @@ const sc = str.replace(/[A-Z]/g, (letter) => "_" + letter.toLowerCase()); | ||
if (typeof json != "object" || json == null || Array.isArray(json)) { | ||
throw new Error(`cannot decode ${struct.$typeName} from JSON ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
throw new Error(`cannot decode message ${struct.$typeName} from JSON ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
} | ||
@@ -612,3 +642,3 @@ for (const [k, v] of Object.entries(json)) { | ||
default: | ||
throw new Error(`cannot decode ${value.$typeName} from JSON ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
throw new Error(`cannot decode message ${value.$typeName} from JSON ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
} | ||
@@ -619,3 +649,3 @@ return value; | ||
if (!Array.isArray(json)) { | ||
throw new Error(`cannot decode ${listValue.$typeName} from JSON ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
throw new Error(`cannot decode message ${listValue.$typeName} from JSON ${(0, reflect_check_js_1.formatVal)(json)}`); | ||
} | ||
@@ -628,12 +658,1 @@ for (const e of json) { | ||
} | ||
function typeUrlToName(url) { | ||
if (!url.length) { | ||
throw new Error(`invalid type url: ${url}`); | ||
} | ||
const slash = url.lastIndexOf("/"); | ||
const name = slash >= 0 ? url.substring(slash + 1) : url; | ||
if (!name.length) { | ||
throw new Error(`invalid type url: ${url}`); | ||
} | ||
return name; | ||
} |
@@ -5,5 +5,6 @@ export * from "./types.js"; | ||
export * from "./clone.js"; | ||
export * from "./desc-types.js"; | ||
export * from "./descriptors.js"; | ||
export * from "./equals.js"; | ||
export * from "./fields.js"; | ||
export * from "./registry.js"; | ||
export type { JsonValue, JsonObject } from "./json-value.js"; | ||
@@ -10,0 +11,0 @@ export { toBinary } from "./to-binary.js"; |
@@ -35,5 +35,6 @@ "use strict"; | ||
__exportStar(require("./clone.js"), exports); | ||
__exportStar(require("./desc-types.js"), exports); | ||
__exportStar(require("./descriptors.js"), exports); | ||
__exportStar(require("./equals.js"), exports); | ||
__exportStar(require("./fields.js"), exports); | ||
__exportStar(require("./registry.js"), exports); | ||
var to_binary_js_1 = require("./to-binary.js"); | ||
@@ -40,0 +41,0 @@ Object.defineProperty(exports, "toBinary", { enumerable: true, get: function () { return to_binary_js_1.toBinary; } }); |
import type { MessageShape } from "./types.js"; | ||
import type { DescMessage } from "./desc-types.js"; | ||
import type { DescMessage } from "./descriptors.js"; | ||
/** | ||
@@ -4,0 +4,0 @@ * Determine whether the given `arg` is a message. |
/** | ||
* Int64Support for the current environment. | ||
*/ | ||
export declare const protoInt64: Int64Support; | ||
/** | ||
* We use the `bigint` primitive to represent 64-bit integral types. If bigint | ||
@@ -94,3 +98,2 @@ * is unavailable, we fall back to a string representation, which means that | ||
} | ||
export declare const protoInt64: Int64Support; | ||
export {}; |
@@ -17,4 +17,7 @@ "use strict"; | ||
exports.protoInt64 = void 0; | ||
const assert_js_1 = require("./reflect/assert.js"); | ||
const varint_js_1 = require("./wire/varint.js"); | ||
/** | ||
* Int64Support for the current environment. | ||
*/ | ||
exports.protoInt64 = makeInt64Support(); | ||
function makeInt64Support() { | ||
@@ -39,3 +42,3 @@ const dv = new DataView(new ArrayBuffer(8)); | ||
if (bi > MAX || bi < MIN) { | ||
throw new Error(`int64 invalid: ${value}`); | ||
throw new Error(`invalid int64: ${value}`); | ||
} | ||
@@ -47,3 +50,3 @@ return bi; | ||
if (bi > UMAX || bi < UMIN) { | ||
throw new Error(`uint64 invalid: ${value}`); | ||
throw new Error(`invalid uint64: ${value}`); | ||
} | ||
@@ -78,4 +81,2 @@ return bi; | ||
} | ||
const assertInt64String = (value) => (0, assert_js_1.assert)(/^-?[0-9]+$/.test(value), `int64 invalid: ${value}`); | ||
const assertUInt64String = (value) => (0, assert_js_1.assert)(/^[0-9]+$/.test(value), `uint64 invalid: ${value}`); | ||
return { | ||
@@ -120,2 +121,11 @@ zero: "0", | ||
} | ||
exports.protoInt64 = makeInt64Support(); | ||
function assertInt64String(value) { | ||
if (!/^-?[0-9]+$/.test(value)) { | ||
throw new Error("invalid int64: " + value); | ||
} | ||
} | ||
function assertUInt64String(value) { | ||
if (!/^[0-9]+$/.test(value)) { | ||
throw new Error("invalid uint64: " + value); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { DescField, DescOneof } from "../desc-types.js"; | ||
import type { DescField, DescOneof } from "../descriptors.js"; | ||
declare const errorNames: string[]; | ||
@@ -3,0 +3,0 @@ export declare class FieldError extends Error { |
import type { Message } from "../types.js"; | ||
import type { ScalarValue } from "./scalar.js"; | ||
import type { ReflectList, ReflectMap, ReflectMessage } from "./reflect-types.js"; | ||
import type { DescField, DescMessage } from "../desc-types.js"; | ||
import type { DescField, DescMessage } from "../descriptors.js"; | ||
export declare function isObject(arg: unknown): arg is Record<string, unknown>; | ||
@@ -6,0 +6,0 @@ export declare function isOneofADT(arg: unknown): arg is OneofADT; |
@@ -6,4 +6,3 @@ export * from "./error.js"; | ||
export * from "./reflect-types.js"; | ||
export * from "./registry.js"; | ||
export * from "./scalar.js"; | ||
export { isReflectList, isReflectMap, isReflectMessage } from "./guard.js"; |
@@ -36,3 +36,2 @@ "use strict"; | ||
__exportStar(require("./reflect-types.js"), exports); | ||
__exportStar(require("./registry.js"), exports); | ||
__exportStar(require("./scalar.js"), exports); | ||
@@ -39,0 +38,0 @@ var guard_js_1 = require("./guard.js"); |
@@ -9,4 +9,4 @@ /** | ||
* | ||
* Also see safeIdentifier() from @bufbuild/protoplugin/ecmascript. | ||
* Also see safeIdentifier() from @bufbuild/protoplugin. | ||
*/ | ||
export declare function safeObjectProperty(name: string): string; |
@@ -69,3 +69,3 @@ "use strict"; | ||
* | ||
* Also see safeIdentifier() from @bufbuild/protoplugin/ecmascript. | ||
* Also see safeIdentifier() from @bufbuild/protoplugin. | ||
*/ | ||
@@ -72,0 +72,0 @@ function safeObjectProperty(name) { |
@@ -1,2 +0,2 @@ | ||
import type { AnyDesc, DescEnum, DescExtension, DescFile, DescMessage, DescService } from "../desc-types.js"; | ||
import type { AnyDesc, DescEnum, DescExtension, DescFile, DescMessage, DescService } from "../descriptors.js"; | ||
/** | ||
@@ -3,0 +3,0 @@ * Iterate over all types - enumerations, extensions, services, messages - |
@@ -1,7 +0,16 @@ | ||
import type { DescField } from "../desc-types.js"; | ||
import { type DescField } from "../descriptors.js"; | ||
import { FieldError } from "./error.js"; | ||
/** | ||
* Check whether the given field value is valid for the reflect API. | ||
*/ | ||
export declare function checkField(field: DescField, value: unknown): FieldError | undefined; | ||
/** | ||
* Check whether the given list item is valid for the reflect API. | ||
*/ | ||
export declare function checkListItem(field: DescField & { | ||
fieldKind: "list"; | ||
}, index: number, value: unknown): FieldError | undefined; | ||
/** | ||
* Check whether the given map key and value are valid for the reflect API. | ||
*/ | ||
export declare function checkMapEntry(field: DescField & { | ||
@@ -8,0 +17,0 @@ fieldKind: "map"; |
@@ -17,7 +17,12 @@ "use strict"; | ||
exports.formatVal = exports.checkMapEntry = exports.checkListItem = exports.checkField = void 0; | ||
const scalar_js_1 = require("./scalar.js"); | ||
const scalar_js_2 = require("./scalar.js"); | ||
const descriptors_js_1 = require("../descriptors.js"); | ||
const is_message_js_1 = require("../is-message.js"); | ||
const error_js_1 = require("./error.js"); | ||
const guard_js_1 = require("./guard.js"); | ||
const binary_encoding_js_1 = require("../wire/binary-encoding.js"); | ||
const text_encoding_js_1 = require("../wire/text-encoding.js"); | ||
const proto_int64_js_1 = require("../proto-int64.js"); | ||
/** | ||
* Check whether the given field value is valid for the reflect API. | ||
*/ | ||
function checkField(field, value) { | ||
@@ -47,2 +52,5 @@ const check = field.fieldKind == "list" | ||
exports.checkField = checkField; | ||
/** | ||
* Check whether the given list item is valid for the reflect API. | ||
*/ | ||
function checkListItem(field, index, value) { | ||
@@ -56,4 +64,7 @@ const check = checkSingular(field, value); | ||
exports.checkListItem = checkListItem; | ||
/** | ||
* Check whether the given map key and value are valid for the reflect API. | ||
*/ | ||
function checkMapEntry(field, key, value) { | ||
const checkKey = (0, scalar_js_2.checkScalarValue)(key, field.mapKey); | ||
const checkKey = checkScalarValue(key, field.mapKey); | ||
if (checkKey !== true) { | ||
@@ -71,3 +82,3 @@ return new error_js_1.FieldError(field, `invalid map key: ${reasonSingular({ scalar: field.mapKey }, key, checkKey)}`); | ||
if (field.scalar !== undefined) { | ||
return (0, scalar_js_2.checkScalarValue)(value, field.scalar); | ||
return checkScalarValue(value, field.scalar); | ||
} | ||
@@ -82,2 +93,80 @@ if (field.enum !== undefined) { | ||
} | ||
function checkScalarValue(value, scalar) { | ||
switch (scalar) { | ||
case descriptors_js_1.ScalarType.DOUBLE: | ||
return typeof value == "number"; | ||
case descriptors_js_1.ScalarType.FLOAT: | ||
if (typeof value != "number") { | ||
return false; | ||
} | ||
if (Number.isNaN(value) || !Number.isFinite(value)) { | ||
return true; | ||
} | ||
if (value > binary_encoding_js_1.FLOAT32_MAX || value < binary_encoding_js_1.FLOAT32_MIN) { | ||
return `${value.toFixed()} out of range`; | ||
} | ||
return true; | ||
case descriptors_js_1.ScalarType.INT32: | ||
case descriptors_js_1.ScalarType.SFIXED32: | ||
case descriptors_js_1.ScalarType.SINT32: | ||
// signed | ||
if (typeof value !== "number" || !Number.isInteger(value)) { | ||
return false; | ||
} | ||
if (value > binary_encoding_js_1.INT32_MAX || value < binary_encoding_js_1.INT32_MIN) { | ||
return `${value.toFixed()} out of range`; | ||
} | ||
return true; | ||
case descriptors_js_1.ScalarType.FIXED32: | ||
case descriptors_js_1.ScalarType.UINT32: | ||
// unsigned | ||
if (typeof value !== "number" || !Number.isInteger(value)) { | ||
return false; | ||
} | ||
if (value > binary_encoding_js_1.UINT32_MAX || value < 0) { | ||
return `${value.toFixed()} out of range`; | ||
} | ||
return true; | ||
case descriptors_js_1.ScalarType.BOOL: | ||
return typeof value == "boolean"; | ||
case descriptors_js_1.ScalarType.STRING: | ||
if (typeof value != "string") { | ||
return false; | ||
} | ||
return (0, text_encoding_js_1.getTextEncoding)().checkUtf8(value) || "invalid UTF8"; | ||
case descriptors_js_1.ScalarType.BYTES: | ||
return value instanceof Uint8Array; | ||
case descriptors_js_1.ScalarType.INT64: | ||
case descriptors_js_1.ScalarType.SFIXED64: | ||
case descriptors_js_1.ScalarType.SINT64: | ||
// signed | ||
if (typeof value != "string" && | ||
typeof value !== "bigint" && | ||
typeof value !== "number") { | ||
return false; | ||
} | ||
try { | ||
proto_int64_js_1.protoInt64.parse(value); | ||
} | ||
catch (e) { | ||
return `${value} out of range`; | ||
} | ||
return true; | ||
case descriptors_js_1.ScalarType.FIXED64: | ||
case descriptors_js_1.ScalarType.UINT64: | ||
// unsigned | ||
if (typeof value != "string" && | ||
typeof value !== "bigint" && | ||
typeof value !== "number") { | ||
return false; | ||
} | ||
try { | ||
proto_int64_js_1.protoInt64.uParse(value); | ||
} | ||
catch (e) { | ||
return `${value} out of range`; | ||
} | ||
return true; | ||
} | ||
} | ||
function reasonSingular(field, val, details) { | ||
@@ -87,3 +176,3 @@ details = | ||
if (field.scalar !== undefined) { | ||
return `expected ${(0, scalar_js_1.scalarTypeDescription)(field.scalar)}` + details; | ||
return `expected ${scalarTypeDescription(field.scalar)}` + details; | ||
} | ||
@@ -144,3 +233,3 @@ else if (field.enum !== undefined) { | ||
case "scalar": | ||
return `ReflectList (${scalar_js_1.ScalarType[field.scalar]})`; | ||
return `ReflectList (${descriptors_js_1.ScalarType[field.scalar]})`; | ||
} | ||
@@ -151,8 +240,36 @@ } | ||
case "message": | ||
return `ReflectMap (${scalar_js_1.ScalarType[field.mapKey]}, ${field.message.toString()})`; | ||
return `ReflectMap (${descriptors_js_1.ScalarType[field.mapKey]}, ${field.message.toString()})`; | ||
case "enum": | ||
return `ReflectMap (${scalar_js_1.ScalarType[field.mapKey]}, ${field.enum.toString()})`; | ||
return `ReflectMap (${descriptors_js_1.ScalarType[field.mapKey]}, ${field.enum.toString()})`; | ||
case "scalar": | ||
return `ReflectMap (${scalar_js_1.ScalarType[field.mapKey]}, ${scalar_js_1.ScalarType[field.scalar]})`; | ||
return `ReflectMap (${descriptors_js_1.ScalarType[field.mapKey]}, ${descriptors_js_1.ScalarType[field.scalar]})`; | ||
} | ||
} | ||
function scalarTypeDescription(scalar) { | ||
switch (scalar) { | ||
case descriptors_js_1.ScalarType.STRING: | ||
return "string"; | ||
case descriptors_js_1.ScalarType.BOOL: | ||
return "boolean"; | ||
case descriptors_js_1.ScalarType.INT64: | ||
case descriptors_js_1.ScalarType.SINT64: | ||
case descriptors_js_1.ScalarType.SFIXED64: | ||
return "bigint (int64)"; | ||
case descriptors_js_1.ScalarType.UINT64: | ||
case descriptors_js_1.ScalarType.FIXED64: | ||
return "bigint (uint64)"; | ||
case descriptors_js_1.ScalarType.BYTES: | ||
return "Uint8Array"; | ||
case descriptors_js_1.ScalarType.DOUBLE: | ||
return "number (float64)"; | ||
case descriptors_js_1.ScalarType.FLOAT: | ||
return "number (float32)"; | ||
case descriptors_js_1.ScalarType.FIXED32: | ||
case descriptors_js_1.ScalarType.UINT32: | ||
return "number (uint32)"; | ||
case descriptors_js_1.ScalarType.INT32: | ||
case descriptors_js_1.ScalarType.SFIXED32: | ||
case descriptors_js_1.ScalarType.SINT32: | ||
return "number (int32)"; | ||
} | ||
} |
@@ -1,6 +0,6 @@ | ||
import type { DescField, DescMessage, DescOneof } from "../desc-types.js"; | ||
import { type DescField, type DescMessage, type DescOneof } from "../descriptors.js"; | ||
import { FieldError } from "./error.js"; | ||
import { unsafeLocal } from "./unsafe.js"; | ||
import type { Message, UnknownField } from "../types.js"; | ||
import type { LongType, ScalarValue } from "./scalar.js"; | ||
import type { ScalarValue } from "./scalar.js"; | ||
/** | ||
@@ -233,3 +233,3 @@ * ReflectMessage provides dynamic access and manipulation of a message. | ||
scalar: infer T; | ||
} ? ReflectMap<MapEntryKey, ScalarValue<T, LongType.BIGINT>> : never) : Field extends { | ||
} ? ReflectMap<MapEntryKey, ScalarValue<T>> : never) : Field extends { | ||
fieldKind: "list"; | ||
@@ -284,3 +284,3 @@ } ? ReflectList : Field extends { | ||
scalar: infer T; | ||
} ? ScalarValue<T, LongType.BIGINT> : never); | ||
} ? ScalarValue<T> : never); | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import type { DescField, DescMessage } from "../desc-types.js"; | ||
import { type DescField, type DescMessage } from "../descriptors.js"; | ||
import type { MessageShape } from "../types.js"; | ||
@@ -3,0 +3,0 @@ import type { MapEntryKey, ReflectList, ReflectMap, ReflectMessage } from "./reflect-types.js"; |
@@ -17,2 +17,3 @@ "use strict"; | ||
exports.reflectMap = exports.reflectList = exports.reflect = void 0; | ||
const descriptors_js_1 = require("../descriptors.js"); | ||
const reflect_check_js_1 = require("./reflect-check.js"); | ||
@@ -92,3 +93,3 @@ const error_js_1 = require("./error.js"); | ||
return (value === undefined | ||
? (0, scalar_js_1.scalarZeroValue)(field.scalar, scalar_js_1.LongType.BIGINT) | ||
? (0, scalar_js_1.scalarZeroValue)(field.scalar, false) | ||
: longToReflect(field, value)); | ||
@@ -107,3 +108,3 @@ case "enum": | ||
} | ||
let local = value; | ||
let local; | ||
if ((0, guard_js_1.isReflectMap)(value) || (0, guard_js_1.isReflectList)(value)) { | ||
@@ -348,9 +349,9 @@ local = value[unsafe_js_1.unsafeLocal]; | ||
switch (type) { | ||
case scalar_js_1.ScalarType.STRING: | ||
case descriptors_js_1.ScalarType.STRING: | ||
return key; | ||
case scalar_js_1.ScalarType.INT32: | ||
case scalar_js_1.ScalarType.FIXED32: | ||
case scalar_js_1.ScalarType.UINT32: | ||
case scalar_js_1.ScalarType.SFIXED32: | ||
case scalar_js_1.ScalarType.SINT32: { | ||
case descriptors_js_1.ScalarType.INT32: | ||
case descriptors_js_1.ScalarType.FIXED32: | ||
case descriptors_js_1.ScalarType.UINT32: | ||
case descriptors_js_1.ScalarType.SFIXED32: | ||
case descriptors_js_1.ScalarType.SINT32: { | ||
const n = Number.parseInt(key); | ||
@@ -362,3 +363,3 @@ if (Number.isFinite(n)) { | ||
} | ||
case scalar_js_1.ScalarType.BOOL: | ||
case descriptors_js_1.ScalarType.BOOL: | ||
switch (key) { | ||
@@ -371,4 +372,4 @@ case "true": | ||
break; | ||
case scalar_js_1.ScalarType.UINT64: | ||
case scalar_js_1.ScalarType.FIXED64: | ||
case descriptors_js_1.ScalarType.UINT64: | ||
case descriptors_js_1.ScalarType.FIXED64: | ||
try { | ||
@@ -396,7 +397,7 @@ return proto_int64_js_1.protoInt64.uParse(key); | ||
switch (field.scalar) { | ||
case scalar_js_1.ScalarType.INT64: | ||
case scalar_js_1.ScalarType.SFIXED64: | ||
case scalar_js_1.ScalarType.SINT64: | ||
if ("longType" in field && | ||
field.longType == scalar_js_1.LongType.STRING && | ||
case descriptors_js_1.ScalarType.INT64: | ||
case descriptors_js_1.ScalarType.SFIXED64: | ||
case descriptors_js_1.ScalarType.SINT64: | ||
if ("longAsString" in field && | ||
field.longAsString && | ||
typeof value == "string") { | ||
@@ -406,6 +407,6 @@ value = proto_int64_js_1.protoInt64.parse(value); | ||
break; | ||
case scalar_js_1.ScalarType.FIXED64: | ||
case scalar_js_1.ScalarType.UINT64: | ||
if ("longType" in field && | ||
field.longType == scalar_js_1.LongType.STRING && | ||
case descriptors_js_1.ScalarType.FIXED64: | ||
case descriptors_js_1.ScalarType.UINT64: | ||
if ("longAsString" in field && | ||
field.longAsString && | ||
typeof value == "string") { | ||
@@ -421,6 +422,6 @@ value = proto_int64_js_1.protoInt64.uParse(value); | ||
switch (field.scalar) { | ||
case scalar_js_1.ScalarType.INT64: | ||
case scalar_js_1.ScalarType.SFIXED64: | ||
case scalar_js_1.ScalarType.SINT64: | ||
if ("longType" in field && field.longType == scalar_js_1.LongType.STRING) { | ||
case descriptors_js_1.ScalarType.INT64: | ||
case descriptors_js_1.ScalarType.SFIXED64: | ||
case descriptors_js_1.ScalarType.SINT64: | ||
if ("longAsString" in field && field.longAsString) { | ||
value = String(value); | ||
@@ -432,5 +433,5 @@ } | ||
break; | ||
case scalar_js_1.ScalarType.FIXED64: | ||
case scalar_js_1.ScalarType.UINT64: | ||
if ("longType" in field && field.longType == scalar_js_1.LongType.STRING) { | ||
case descriptors_js_1.ScalarType.FIXED64: | ||
case descriptors_js_1.ScalarType.UINT64: | ||
if ("longAsString" in field && field.longAsString) { | ||
value = String(value); | ||
@@ -437,0 +438,0 @@ } |
@@ -0,54 +1,6 @@ | ||
import { ScalarType } from "../descriptors.js"; | ||
/** | ||
* Scalar value types. This is a subset of field types declared by protobuf | ||
* enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE | ||
* are omitted, but the numerical values are identical. | ||
*/ | ||
export declare enum ScalarType { | ||
DOUBLE = 1, | ||
FLOAT = 2, | ||
INT64 = 3, | ||
UINT64 = 4, | ||
INT32 = 5, | ||
FIXED64 = 6, | ||
FIXED32 = 7, | ||
BOOL = 8, | ||
STRING = 9, | ||
BYTES = 12, | ||
UINT32 = 13, | ||
SFIXED32 = 15, | ||
SFIXED64 = 16, | ||
SINT32 = 17,// Uses ZigZag encoding. | ||
SINT64 = 18 | ||
} | ||
/** | ||
* JavaScript representation of fields with 64 bit integral types (int64, uint64, | ||
* sint64, fixed64, sfixed64). | ||
* | ||
* This is a subset of google.protobuf.FieldOptions.JSType, which defines JS_NORMAL, | ||
* JS_STRING, and JS_NUMBER. Protobuf-ES uses BigInt by default, but will use | ||
* String if `[jstype = JS_STRING]` is specified. | ||
* | ||
* ```protobuf | ||
* uint64 field_a = 1; // BigInt | ||
* uint64 field_b = 2 [jstype = JS_NORMAL]; // BigInt | ||
* uint64 field_b = 2 [jstype = JS_NUMBER]; // BigInt | ||
* uint64 field_b = 2 [jstype = JS_STRING]; // String | ||
* ``` | ||
*/ | ||
export declare enum LongType { | ||
/** | ||
* Use JavaScript BigInt. | ||
*/ | ||
BIGINT = 0, | ||
/** | ||
* Use JavaScript String. | ||
* | ||
* Field option `[jstype = JS_STRING]`. | ||
*/ | ||
STRING = 1 | ||
} | ||
/** | ||
* ScalarValue maps from a scalar field type to a TypeScript value type. | ||
*/ | ||
export type ScalarValue<T = ScalarType, L extends LongType = LongType.STRING | LongType.BIGINT> = T extends ScalarType.STRING ? string : T extends ScalarType.INT32 ? number : T extends ScalarType.UINT32 ? number : T extends ScalarType.UINT32 ? number : T extends ScalarType.SINT32 ? number : T extends ScalarType.FIXED32 ? number : T extends ScalarType.SFIXED32 ? number : T extends ScalarType.FLOAT ? number : T extends ScalarType.DOUBLE ? number : T extends ScalarType.INT64 ? L extends LongType.STRING ? string : bigint : T extends ScalarType.SINT64 ? L extends LongType.STRING ? string : bigint : T extends ScalarType.SFIXED64 ? L extends LongType.STRING ? string : bigint : T extends ScalarType.UINT64 ? L extends LongType.STRING ? string : bigint : T extends ScalarType.FIXED64 ? L extends LongType.STRING ? string : bigint : T extends ScalarType.BOOL ? boolean : T extends ScalarType.BYTES ? Uint8Array : never; | ||
export type ScalarValue<T = ScalarType, LongAsString extends boolean = false> = T extends ScalarType.STRING ? string : T extends ScalarType.INT32 ? number : T extends ScalarType.UINT32 ? number : T extends ScalarType.SINT32 ? number : T extends ScalarType.FIXED32 ? number : T extends ScalarType.SFIXED32 ? number : T extends ScalarType.FLOAT ? number : T extends ScalarType.DOUBLE ? number : T extends ScalarType.INT64 ? LongAsString extends true ? string : bigint : T extends ScalarType.SINT64 ? LongAsString extends true ? string : bigint : T extends ScalarType.SFIXED64 ? LongAsString extends true ? string : bigint : T extends ScalarType.UINT64 ? LongAsString extends true ? string : bigint : T extends ScalarType.FIXED64 ? LongAsString extends true ? string : bigint : T extends ScalarType.BOOL ? boolean : T extends ScalarType.BYTES ? Uint8Array : never; | ||
/** | ||
@@ -61,3 +13,3 @@ * Returns true if both scalar values are equal. | ||
*/ | ||
export declare function scalarZeroValue<T extends ScalarType, L extends LongType>(type: T, longType: L): ScalarValue<T, L>; | ||
export declare function scalarZeroValue<T extends ScalarType, LongAsString extends boolean>(type: T, longAsString: LongAsString): ScalarValue<T, LongAsString>; | ||
/** | ||
@@ -71,5 +23,1 @@ * Returns true for a zero-value. For example, an integer has the zero-value `0`, | ||
export declare function isScalarZeroValue(type: ScalarType, value: unknown): boolean; | ||
export type InvalidScalarValueErr = false | "invalid UTF8" | `${string} out of range`; | ||
export declare function checkScalarValue(value: unknown, scalar: ScalarType): true | InvalidScalarValueErr; | ||
export declare function scalarTypeDescription(scalar: ScalarType): string; | ||
export declare function scalarTypeScriptType(scalar: ScalarType, long: LongType): "string" | "boolean" | "bigint" | "bigint | string" | "Uint8Array" | "number"; |
@@ -16,71 +16,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.scalarTypeScriptType = exports.scalarTypeDescription = exports.checkScalarValue = exports.isScalarZeroValue = exports.scalarZeroValue = exports.scalarEquals = exports.LongType = exports.ScalarType = void 0; | ||
exports.isScalarZeroValue = exports.scalarZeroValue = exports.scalarEquals = void 0; | ||
const proto_int64_js_1 = require("../proto-int64.js"); | ||
const text_encoding_js_1 = require("../wire/text-encoding.js"); | ||
const descriptors_js_1 = require("../descriptors.js"); | ||
/** | ||
* Scalar value types. This is a subset of field types declared by protobuf | ||
* enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE | ||
* are omitted, but the numerical values are identical. | ||
*/ | ||
var ScalarType; | ||
(function (ScalarType) { | ||
// 0 is reserved for errors. | ||
// Order is weird for historical reasons. | ||
ScalarType[ScalarType["DOUBLE"] = 1] = "DOUBLE"; | ||
ScalarType[ScalarType["FLOAT"] = 2] = "FLOAT"; | ||
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if | ||
// negative values are likely. | ||
ScalarType[ScalarType["INT64"] = 3] = "INT64"; | ||
ScalarType[ScalarType["UINT64"] = 4] = "UINT64"; | ||
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if | ||
// negative values are likely. | ||
ScalarType[ScalarType["INT32"] = 5] = "INT32"; | ||
ScalarType[ScalarType["FIXED64"] = 6] = "FIXED64"; | ||
ScalarType[ScalarType["FIXED32"] = 7] = "FIXED32"; | ||
ScalarType[ScalarType["BOOL"] = 8] = "BOOL"; | ||
ScalarType[ScalarType["STRING"] = 9] = "STRING"; | ||
// Tag-delimited aggregate. | ||
// Group type is deprecated and not supported in proto3. However, Proto3 | ||
// implementations should still be able to parse the group wire format and | ||
// treat group fields as unknown fields. | ||
// TYPE_GROUP = 10, | ||
// TYPE_MESSAGE = 11, // Length-delimited aggregate. | ||
// New in version 2. | ||
ScalarType[ScalarType["BYTES"] = 12] = "BYTES"; | ||
ScalarType[ScalarType["UINT32"] = 13] = "UINT32"; | ||
// TYPE_ENUM = 14, | ||
ScalarType[ScalarType["SFIXED32"] = 15] = "SFIXED32"; | ||
ScalarType[ScalarType["SFIXED64"] = 16] = "SFIXED64"; | ||
ScalarType[ScalarType["SINT32"] = 17] = "SINT32"; | ||
ScalarType[ScalarType["SINT64"] = 18] = "SINT64"; | ||
})(ScalarType || (exports.ScalarType = ScalarType = {})); | ||
/** | ||
* JavaScript representation of fields with 64 bit integral types (int64, uint64, | ||
* sint64, fixed64, sfixed64). | ||
* | ||
* This is a subset of google.protobuf.FieldOptions.JSType, which defines JS_NORMAL, | ||
* JS_STRING, and JS_NUMBER. Protobuf-ES uses BigInt by default, but will use | ||
* String if `[jstype = JS_STRING]` is specified. | ||
* | ||
* ```protobuf | ||
* uint64 field_a = 1; // BigInt | ||
* uint64 field_b = 2 [jstype = JS_NORMAL]; // BigInt | ||
* uint64 field_b = 2 [jstype = JS_NUMBER]; // BigInt | ||
* uint64 field_b = 2 [jstype = JS_STRING]; // String | ||
* ``` | ||
*/ | ||
var LongType; | ||
(function (LongType) { | ||
/** | ||
* Use JavaScript BigInt. | ||
*/ | ||
LongType[LongType["BIGINT"] = 0] = "BIGINT"; | ||
/** | ||
* Use JavaScript String. | ||
* | ||
* Field option `[jstype = JS_STRING]`. | ||
*/ | ||
LongType[LongType["STRING"] = 1] = "STRING"; | ||
})(LongType || (exports.LongType = LongType = {})); | ||
/** | ||
* Returns true if both scalar values are equal. | ||
@@ -94,3 +29,3 @@ */ | ||
// Special case BYTES - we need to compare each byte individually | ||
if (type == ScalarType.BYTES) { | ||
if (type == descriptors_js_1.ScalarType.BYTES) { | ||
if (!(a instanceof Uint8Array) || !(b instanceof Uint8Array)) { | ||
@@ -112,7 +47,7 @@ return false; | ||
switch (type) { | ||
case ScalarType.UINT64: | ||
case ScalarType.FIXED64: | ||
case ScalarType.INT64: | ||
case ScalarType.SFIXED64: | ||
case ScalarType.SINT64: | ||
case descriptors_js_1.ScalarType.UINT64: | ||
case descriptors_js_1.ScalarType.FIXED64: | ||
case descriptors_js_1.ScalarType.INT64: | ||
case descriptors_js_1.ScalarType.SFIXED64: | ||
case descriptors_js_1.ScalarType.SINT64: | ||
// Loose comparison will match between 0n, 0 and "0". | ||
@@ -129,19 +64,8 @@ return a == b; | ||
*/ | ||
function scalarZeroValue(type, longType) { | ||
function scalarZeroValue(type, longAsString) { | ||
switch (type) { | ||
case ScalarType.BOOL: | ||
case descriptors_js_1.ScalarType.STRING: | ||
return ""; | ||
case descriptors_js_1.ScalarType.BOOL: | ||
return false; | ||
case ScalarType.UINT64: | ||
case ScalarType.FIXED64: | ||
case ScalarType.INT64: | ||
case ScalarType.SFIXED64: | ||
case ScalarType.SINT64: | ||
return (longType == 0 ? proto_int64_js_1.protoInt64.zero : "0"); | ||
case ScalarType.DOUBLE: | ||
case ScalarType.FLOAT: | ||
return 0.0; | ||
case ScalarType.BYTES: | ||
return new Uint8Array(0); | ||
case ScalarType.STRING: | ||
return ""; | ||
default: | ||
@@ -151,2 +75,13 @@ // Handles INT32, UINT32, SINT32, FIXED32, SFIXED32. | ||
return 0; | ||
case descriptors_js_1.ScalarType.DOUBLE: | ||
case descriptors_js_1.ScalarType.FLOAT: | ||
return 0.0; | ||
case descriptors_js_1.ScalarType.INT64: | ||
case descriptors_js_1.ScalarType.UINT64: | ||
case descriptors_js_1.ScalarType.SFIXED64: | ||
case descriptors_js_1.ScalarType.FIXED64: | ||
case descriptors_js_1.ScalarType.SINT64: | ||
return (longAsString ? "0" : proto_int64_js_1.protoInt64.zero); | ||
case descriptors_js_1.ScalarType.BYTES: | ||
return new Uint8Array(0); | ||
} | ||
@@ -164,7 +99,7 @@ } | ||
switch (type) { | ||
case ScalarType.BOOL: | ||
case descriptors_js_1.ScalarType.BOOL: | ||
return value === false; | ||
case ScalarType.STRING: | ||
case descriptors_js_1.ScalarType.STRING: | ||
return value === ""; | ||
case ScalarType.BYTES: | ||
case descriptors_js_1.ScalarType.BYTES: | ||
return value instanceof Uint8Array && !value.byteLength; | ||
@@ -176,130 +111,1 @@ default: | ||
exports.isScalarZeroValue = isScalarZeroValue; | ||
const FLOAT32_MAX = 3.4028234663852886e38, FLOAT32_MIN = -3.4028234663852886e38, UINT32_MAX = 0xffffffff, INT32_MAX = 0x7fffffff, INT32_MIN = -0x80000000; | ||
// TODO this checks UTF-8 validity | ||
function checkScalarValue(value, scalar) { | ||
switch (scalar) { | ||
case ScalarType.DOUBLE: | ||
return typeof value == "number"; | ||
case ScalarType.FLOAT: | ||
if (typeof value != "number") { | ||
return false; | ||
} | ||
if (Number.isNaN(value) || !Number.isFinite(value)) { | ||
return true; | ||
} | ||
if (value > FLOAT32_MAX || value < FLOAT32_MIN) { | ||
return `${value.toFixed()} out of range`; | ||
} | ||
return true; | ||
case ScalarType.INT32: | ||
case ScalarType.SFIXED32: | ||
case ScalarType.SINT32: | ||
// signed | ||
if (typeof value !== "number" || !Number.isInteger(value)) { | ||
return false; | ||
} | ||
if (value > INT32_MAX || value < INT32_MIN) { | ||
return `${value.toFixed()} out of range`; | ||
} | ||
return true; | ||
case ScalarType.FIXED32: | ||
case ScalarType.UINT32: | ||
// unsigned | ||
if (typeof value !== "number" || !Number.isInteger(value)) { | ||
return false; | ||
} | ||
if (value > UINT32_MAX || value < 0) { | ||
return `${value.toFixed()} out of range`; | ||
} | ||
return true; | ||
case ScalarType.BOOL: | ||
return typeof value == "boolean"; | ||
case ScalarType.STRING: | ||
if (typeof value != "string") { | ||
return false; | ||
} | ||
return (0, text_encoding_js_1.getTextEncoding)().checkUtf8(value) || "invalid UTF8"; | ||
case ScalarType.BYTES: | ||
return value instanceof Uint8Array; | ||
case ScalarType.INT64: | ||
case ScalarType.SFIXED64: | ||
case ScalarType.SINT64: | ||
// signed | ||
if (typeof value != "string" && | ||
typeof value !== "bigint" && | ||
typeof value !== "number") { | ||
return false; | ||
} | ||
try { | ||
proto_int64_js_1.protoInt64.parse(value); | ||
} | ||
catch (e) { | ||
return `${value} out of range`; | ||
} | ||
return true; | ||
case ScalarType.FIXED64: | ||
case ScalarType.UINT64: | ||
// unsigned | ||
if (typeof value != "string" && | ||
typeof value !== "bigint" && | ||
typeof value !== "number") { | ||
return false; | ||
} | ||
try { | ||
proto_int64_js_1.protoInt64.uParse(value); | ||
} | ||
catch (e) { | ||
return `${value} out of range`; | ||
} | ||
return true; | ||
} | ||
} | ||
exports.checkScalarValue = checkScalarValue; | ||
function scalarTypeDescription(scalar) { | ||
switch (scalar) { | ||
case ScalarType.STRING: | ||
return "string"; | ||
case ScalarType.BOOL: | ||
return "boolean"; | ||
case ScalarType.INT64: | ||
case ScalarType.SINT64: | ||
case ScalarType.SFIXED64: | ||
return "bigint (int64)"; | ||
case ScalarType.UINT64: | ||
case ScalarType.FIXED64: | ||
return "bigint (uint64)"; | ||
case ScalarType.BYTES: | ||
return "Uint8Array"; | ||
case ScalarType.DOUBLE: | ||
return "number (float64)"; | ||
case ScalarType.FLOAT: | ||
return "number (float32)"; | ||
case ScalarType.FIXED32: | ||
case ScalarType.UINT32: | ||
return "number (uint32)"; | ||
case ScalarType.INT32: | ||
case ScalarType.SFIXED32: | ||
case ScalarType.SINT32: | ||
return "number (int32)"; | ||
} | ||
} | ||
exports.scalarTypeDescription = scalarTypeDescription; | ||
function scalarTypeScriptType(scalar, long) { | ||
switch (scalar) { | ||
case ScalarType.STRING: | ||
return "string"; | ||
case ScalarType.BOOL: | ||
return "boolean"; | ||
case ScalarType.UINT64: | ||
case ScalarType.SFIXED64: | ||
case ScalarType.FIXED64: | ||
case ScalarType.SINT64: | ||
case ScalarType.INT64: | ||
return long == LongType.STRING ? "string" : "bigint"; | ||
case ScalarType.BYTES: | ||
return "Uint8Array"; | ||
default: | ||
return "number"; | ||
} | ||
} | ||
exports.scalarTypeScriptType = scalarTypeScriptType; |
@@ -1,2 +0,2 @@ | ||
import type { DescField, DescOneof } from "../desc-types.js"; | ||
import type { DescField, DescOneof } from "../descriptors.js"; | ||
export declare const unsafeLocal: unique symbol; | ||
@@ -3,0 +3,0 @@ /** |
@@ -143,3 +143,3 @@ "use strict"; | ||
case "scalar": | ||
target[name] = (0, scalar_js_1.scalarZeroValue)(field.scalar, field.longType); | ||
target[name] = (0, scalar_js_1.scalarZeroValue)(field.scalar, field.longAsString); | ||
break; | ||
@@ -146,0 +146,0 @@ } |
import type { MessageShape } from "./types.js"; | ||
import { BinaryWriter } from "./wire/binary-encoding.js"; | ||
import type { DescField, DescMessage } from "./desc-types.js"; | ||
import { type DescField, type DescMessage } from "./descriptors.js"; | ||
import type { ReflectMessage } from "./reflect/index.js"; | ||
@@ -5,0 +5,0 @@ /** |
@@ -19,3 +19,3 @@ "use strict"; | ||
const binary_encoding_js_1 = require("./wire/binary-encoding.js"); | ||
const scalar_js_1 = require("./reflect/scalar.js"); | ||
const descriptors_js_1 = require("./descriptors.js"); | ||
// bootstrap-inject google.protobuf.FeatureSet.FieldPresence.LEGACY_REQUIRED: const $name: FeatureSet_FieldPresence.$localName = $number; | ||
@@ -60,3 +60,3 @@ const LEGACY_REQUIRED = 3; | ||
case "enum": | ||
writeScalar(writer, (_a = field.scalar) !== null && _a !== void 0 ? _a : scalar_js_1.ScalarType.INT32, field.number, msg.get(field)); | ||
writeScalar(writer, (_a = field.scalar) !== null && _a !== void 0 ? _a : descriptors_js_1.ScalarType.INT32, field.number, msg.get(field)); | ||
break; | ||
@@ -96,3 +96,3 @@ case "list": | ||
} | ||
const scalarType = (_a = field.scalar) !== null && _a !== void 0 ? _a : scalar_js_1.ScalarType.INT32; | ||
const scalarType = (_a = field.scalar) !== null && _a !== void 0 ? _a : descriptors_js_1.ScalarType.INT32; | ||
if (field.packed) { | ||
@@ -122,3 +122,3 @@ if (!list.size) { | ||
case "enum": | ||
writeScalar(writer, (_a = field.scalar) !== null && _a !== void 0 ? _a : scalar_js_1.ScalarType.INT32, 2, value); | ||
writeScalar(writer, (_a = field.scalar) !== null && _a !== void 0 ? _a : descriptors_js_1.ScalarType.INT32, 2, value); | ||
break; | ||
@@ -133,45 +133,45 @@ case "message": | ||
switch (type) { | ||
case scalar_js_1.ScalarType.STRING: | ||
case descriptors_js_1.ScalarType.STRING: | ||
writer.string(value); | ||
break; | ||
case scalar_js_1.ScalarType.BOOL: | ||
case descriptors_js_1.ScalarType.BOOL: | ||
writer.bool(value); | ||
break; | ||
case scalar_js_1.ScalarType.DOUBLE: | ||
case descriptors_js_1.ScalarType.DOUBLE: | ||
writer.double(value); | ||
break; | ||
case scalar_js_1.ScalarType.FLOAT: | ||
case descriptors_js_1.ScalarType.FLOAT: | ||
writer.float(value); | ||
break; | ||
case scalar_js_1.ScalarType.INT32: | ||
case descriptors_js_1.ScalarType.INT32: | ||
writer.int32(value); | ||
break; | ||
case scalar_js_1.ScalarType.INT64: | ||
case descriptors_js_1.ScalarType.INT64: | ||
writer.int64(value); | ||
break; | ||
case scalar_js_1.ScalarType.UINT64: | ||
case descriptors_js_1.ScalarType.UINT64: | ||
writer.uint64(value); | ||
break; | ||
case scalar_js_1.ScalarType.FIXED64: | ||
case descriptors_js_1.ScalarType.FIXED64: | ||
writer.fixed64(value); | ||
break; | ||
case scalar_js_1.ScalarType.BYTES: | ||
case descriptors_js_1.ScalarType.BYTES: | ||
writer.bytes(value); | ||
break; | ||
case scalar_js_1.ScalarType.FIXED32: | ||
case descriptors_js_1.ScalarType.FIXED32: | ||
writer.fixed32(value); | ||
break; | ||
case scalar_js_1.ScalarType.SFIXED32: | ||
case descriptors_js_1.ScalarType.SFIXED32: | ||
writer.sfixed32(value); | ||
break; | ||
case scalar_js_1.ScalarType.SFIXED64: | ||
case descriptors_js_1.ScalarType.SFIXED64: | ||
writer.sfixed64(value); | ||
break; | ||
case scalar_js_1.ScalarType.SINT64: | ||
case descriptors_js_1.ScalarType.SINT64: | ||
writer.sint64(value); | ||
break; | ||
case scalar_js_1.ScalarType.UINT32: | ||
case descriptors_js_1.ScalarType.UINT32: | ||
writer.uint32(value); | ||
break; | ||
case scalar_js_1.ScalarType.SINT32: | ||
case descriptors_js_1.ScalarType.SINT32: | ||
writer.sint32(value); | ||
@@ -183,12 +183,12 @@ break; | ||
switch (type) { | ||
case scalar_js_1.ScalarType.BYTES: | ||
case scalar_js_1.ScalarType.STRING: | ||
case descriptors_js_1.ScalarType.BYTES: | ||
case descriptors_js_1.ScalarType.STRING: | ||
return binary_encoding_js_1.WireType.LengthDelimited; | ||
case scalar_js_1.ScalarType.DOUBLE: | ||
case scalar_js_1.ScalarType.FIXED64: | ||
case scalar_js_1.ScalarType.SFIXED64: | ||
case descriptors_js_1.ScalarType.DOUBLE: | ||
case descriptors_js_1.ScalarType.FIXED64: | ||
case descriptors_js_1.ScalarType.SFIXED64: | ||
return binary_encoding_js_1.WireType.Bit64; | ||
case scalar_js_1.ScalarType.FIXED32: | ||
case scalar_js_1.ScalarType.SFIXED32: | ||
case scalar_js_1.ScalarType.FLOAT: | ||
case descriptors_js_1.ScalarType.FIXED32: | ||
case descriptors_js_1.ScalarType.SFIXED32: | ||
case descriptors_js_1.ScalarType.FLOAT: | ||
return binary_encoding_js_1.WireType.Bit32; | ||
@@ -195,0 +195,0 @@ default: |
@@ -1,4 +0,4 @@ | ||
import type { DescMessage } from "./desc-types.js"; | ||
import { type DescMessage } from "./descriptors.js"; | ||
import type { JsonValue } from "./json-value.js"; | ||
import type { Registry } from "./reflect/registry.js"; | ||
import type { Registry } from "./registry.js"; | ||
import type { MessageShape } from "./types.js"; | ||
@@ -10,7 +10,8 @@ /** | ||
/** | ||
* Emit fields with default values: Fields with default values are omitted | ||
* by default in proto3 JSON output. This option overrides this behavior | ||
* and outputs fields with their default values. | ||
* By default, fields with implicit presence are not serialized if they are | ||
* unset. For example, an empty list field or a proto3 int32 field with 0 is | ||
* not serialized. With this option enabled, such fields are included in the | ||
* output. | ||
*/ | ||
emitDefaultValues: boolean; | ||
alwaysEmitImplicit: boolean; | ||
/** | ||
@@ -17,0 +18,0 @@ * Emit enum values as integers instead of strings: The name of an enum |
@@ -17,6 +17,5 @@ "use strict"; | ||
exports.toJsonString = exports.toJson = void 0; | ||
const assert_js_1 = require("./reflect/assert.js"); | ||
const descriptors_js_1 = require("./descriptors.js"); | ||
const names_js_1 = require("./reflect/names.js"); | ||
const reflect_js_1 = require("./reflect/reflect.js"); | ||
const scalar_js_1 = require("./reflect/scalar.js"); | ||
const index_js_1 = require("./wkt/index.js"); | ||
@@ -26,2 +25,4 @@ const wrappers_js_1 = require("./wkt/wrappers.js"); | ||
const extensions_js_1 = require("./extensions.js"); | ||
const reflect_check_js_1 = require("./reflect/reflect-check.js"); | ||
/* eslint-disable @typescript-eslint/restrict-template-expressions */ | ||
// bootstrap-inject google.protobuf.FeatureSet.FieldPresence.LEGACY_REQUIRED: const $name: FeatureSet_FieldPresence.$localName = $number; | ||
@@ -33,3 +34,3 @@ const LEGACY_REQUIRED = 3; | ||
const jsonWriteDefaults = { | ||
emitDefaultValues: false, | ||
alwaysEmitImplicit: false, | ||
enumAsInteger: false, | ||
@@ -67,5 +68,5 @@ useProtoFieldName: false, | ||
if (f.presence == LEGACY_REQUIRED) { | ||
throw new Error(`cannot encode field ${msg.desc.typeName}.${f.name} to binary: required field not set`); | ||
throw new Error(`cannot encode field ${msg.desc.typeName}.${f.name} to JSON: required field not set`); | ||
} | ||
if (!opts.emitDefaultValues || f.presence !== IMPLICIT) { | ||
if (!opts.alwaysEmitImplicit || f.presence !== IMPLICIT) { | ||
// Fields with implicit presence omit zero values (e.g. empty string) by default | ||
@@ -105,3 +106,3 @@ continue; | ||
case "scalar": | ||
return scalarToJson(f.scalar, val); | ||
return scalarToJson(f, val); | ||
case "message": | ||
@@ -123,3 +124,3 @@ return reflectToJson(val, opts); | ||
for (const [entryKey, entryValue] of map) { | ||
jsonObj[entryKey.toString()] = scalarToJson(f.scalar, entryValue); // JSON standard allows only (double quoted) string as property key | ||
jsonObj[entryKey.toString()] = scalarToJson(f, entryValue); // JSON standard allows only (double quoted) string as property key | ||
} | ||
@@ -140,3 +141,3 @@ break; | ||
} | ||
return opts.emitDefaultValues || map.size > 0 ? jsonObj : undefined; | ||
return opts.alwaysEmitImplicit || map.size > 0 ? jsonObj : undefined; | ||
} | ||
@@ -149,3 +150,3 @@ function listToJson(list, opts) { | ||
for (const item of list) { | ||
jsonArr.push(scalarToJson(f.scalar, item)); | ||
jsonArr.push(scalarToJson(f, item)); | ||
} | ||
@@ -164,7 +165,9 @@ break; | ||
} | ||
return opts.emitDefaultValues || jsonArr.length > 0 ? jsonArr : undefined; | ||
return opts.alwaysEmitImplicit || jsonArr.length > 0 ? jsonArr : undefined; | ||
} | ||
function enumToJson(desc, value, enumAsInteger) { | ||
var _a; | ||
(0, assert_js_1.assert)(typeof value == "number"); | ||
if (typeof value != "number") { | ||
throw new Error(`cannot encode ${desc} to JSON: expected number, got ${(0, reflect_check_js_1.formatVal)(value)}`); | ||
} | ||
if (desc.typeName == "google.protobuf.NullValue") { | ||
@@ -179,19 +182,23 @@ return null; | ||
} | ||
function scalarToJson(type, value) { | ||
switch (type) { | ||
function scalarToJson(field, value) { | ||
var _a, _b, _c, _d, _e, _f; | ||
switch (field.scalar) { | ||
// int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted. | ||
case scalar_js_1.ScalarType.INT32: | ||
case scalar_js_1.ScalarType.SFIXED32: | ||
case scalar_js_1.ScalarType.SINT32: | ||
case scalar_js_1.ScalarType.FIXED32: | ||
case scalar_js_1.ScalarType.UINT32: | ||
(0, assert_js_1.assert)(typeof value == "number"); | ||
case descriptors_js_1.ScalarType.INT32: | ||
case descriptors_js_1.ScalarType.SFIXED32: | ||
case descriptors_js_1.ScalarType.SINT32: | ||
case descriptors_js_1.ScalarType.FIXED32: | ||
case descriptors_js_1.ScalarType.UINT32: | ||
if (typeof value != "number") { | ||
throw new Error(`cannot encode ${field} to JSON: ${(_a = (0, reflect_check_js_1.checkField)(field, value)) === null || _a === void 0 ? void 0 : _a.message}`); | ||
} | ||
return value; | ||
// float, double: JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity". | ||
// Either numbers or strings are accepted. Exponent notation is also accepted. | ||
case scalar_js_1.ScalarType.FLOAT: | ||
// assertFloat32(value); | ||
case scalar_js_1.ScalarType.DOUBLE: // eslint-disable-line no-fallthrough | ||
(0, assert_js_1.assert)(typeof value == "number"); | ||
if (Number.isNaN(value)) | ||
case descriptors_js_1.ScalarType.FLOAT: | ||
case descriptors_js_1.ScalarType.DOUBLE: // eslint-disable-line no-fallthrough | ||
if (typeof value != "number") { | ||
throw new Error(`cannot encode ${field} to JSON: ${(_b = (0, reflect_check_js_1.checkField)(field, value)) === null || _b === void 0 ? void 0 : _b.message}`); | ||
} | ||
if (isNaN(value)) | ||
return "NaN"; | ||
@@ -204,24 +211,30 @@ if (value === Number.POSITIVE_INFINITY) | ||
// string: | ||
case scalar_js_1.ScalarType.STRING: | ||
(0, assert_js_1.assert)(typeof value == "string"); | ||
case descriptors_js_1.ScalarType.STRING: | ||
if (typeof value != "string") { | ||
throw new Error(`cannot encode ${field} to JSON: ${(_c = (0, reflect_check_js_1.checkField)(field, value)) === null || _c === void 0 ? void 0 : _c.message}`); | ||
} | ||
return value; | ||
// bool: | ||
case scalar_js_1.ScalarType.BOOL: | ||
(0, assert_js_1.assert)(typeof value == "boolean"); | ||
case descriptors_js_1.ScalarType.BOOL: | ||
if (typeof value != "boolean") { | ||
throw new Error(`cannot encode ${field} to JSON: ${(_d = (0, reflect_check_js_1.checkField)(field, value)) === null || _d === void 0 ? void 0 : _d.message}`); | ||
} | ||
return value; | ||
// JSON value will be a decimal string. Either numbers or strings are accepted. | ||
case scalar_js_1.ScalarType.UINT64: | ||
case scalar_js_1.ScalarType.FIXED64: | ||
case scalar_js_1.ScalarType.INT64: | ||
case scalar_js_1.ScalarType.SFIXED64: | ||
case scalar_js_1.ScalarType.SINT64: | ||
(0, assert_js_1.assert)(typeof value == "bigint" || | ||
typeof value == "string" || | ||
typeof value == "number"); | ||
case descriptors_js_1.ScalarType.UINT64: | ||
case descriptors_js_1.ScalarType.FIXED64: | ||
case descriptors_js_1.ScalarType.INT64: | ||
case descriptors_js_1.ScalarType.SFIXED64: | ||
case descriptors_js_1.ScalarType.SINT64: | ||
if (typeof value != "bigint" && typeof value != "string") { | ||
throw new Error(`cannot encode ${field} to JSON: ${(_e = (0, reflect_check_js_1.checkField)(field, value)) === null || _e === void 0 ? void 0 : _e.message}`); | ||
} | ||
return value.toString(); | ||
// bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings. | ||
// Either standard or URL-safe base64 encoding with/without paddings are accepted. | ||
case scalar_js_1.ScalarType.BYTES: | ||
(0, assert_js_1.assert)(value instanceof Uint8Array); | ||
return (0, index_js_2.base64Encode)(value); | ||
case descriptors_js_1.ScalarType.BYTES: | ||
if (value instanceof Uint8Array) { | ||
return (0, index_js_2.base64Encode)(value); | ||
} | ||
throw new Error(`cannot encode ${field} to JSON: ${(_f = (0, reflect_check_js_1.checkField)(field, value)) === null || _f === void 0 ? void 0 : _f.message}`); | ||
} | ||
@@ -255,3 +268,3 @@ } | ||
const valueField = msg.desc.fields[0]; | ||
return scalarToJson(valueField.scalar, msg.get(valueField)); | ||
return scalarToJson(valueField, msg.get(valueField)); | ||
} | ||
@@ -290,3 +303,3 @@ return undefined; | ||
Number(val.seconds) < -315576000000) { | ||
throw new Error(`cannot encode ${val.$typeName} to JSON: value out of range`); | ||
throw new Error(`cannot encode message ${val.$typeName} to JSON: value out of range`); | ||
} | ||
@@ -315,3 +328,3 @@ let text = val.seconds.toString(); | ||
if (p.match(/_[0-9]?_/g) || p.match(/[A-Z]/g)) { | ||
throw new Error(`cannot encode ${val.$typeName} to JSON: lowerCamelCase of path name "` + | ||
throw new Error(`cannot encode message ${val.$typeName} to JSON: lowerCamelCase of path name "` + | ||
p + | ||
@@ -359,6 +372,6 @@ '" is irreversible'); | ||
ms > Date.parse("9999-12-31T23:59:59Z")) { | ||
throw new Error(`cannot encode ${val.$typeName} to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`); | ||
throw new Error(`cannot encode message ${val.$typeName} to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`); | ||
} | ||
if (val.nanos < 0) { | ||
throw new Error(`cannot encode ${val.$typeName} to JSON: nanos must not be negative`); | ||
throw new Error(`cannot encode message ${val.$typeName} to JSON: nanos must not be negative`); | ||
} | ||
@@ -365,0 +378,0 @@ let z = "Z"; |
import type { GenDescEnum, GenDescExtension, GenDescMessage } from "./codegenv1/types.js"; | ||
import type { DescEnum, DescExtension, DescMessage } from "./desc-types.js"; | ||
import type { DescEnum, DescExtension, DescMessage } from "./descriptors.js"; | ||
import type { OneofADT } from "./reflect/guard.js"; | ||
@@ -4,0 +4,0 @@ import type { WireType } from "./wire/index.js"; |
@@ -55,3 +55,3 @@ "use strict"; | ||
default: | ||
throw Error("invalid base64 string."); | ||
throw Error("invalid base64 string"); | ||
} | ||
@@ -81,3 +81,3 @@ } | ||
if (groupPos == 1) | ||
throw Error("invalid base64 string."); | ||
throw Error("invalid base64 string"); | ||
return bytes.subarray(0, bytePos); | ||
@@ -84,0 +84,0 @@ } |
@@ -42,2 +42,22 @@ /** | ||
} | ||
/** | ||
* Maximum value for a 32-bit floating point value (Protobuf FLOAT). | ||
*/ | ||
export declare const FLOAT32_MAX = 3.4028234663852886e+38; | ||
/** | ||
* Minimum value for a 32-bit floating point value (Protobuf FLOAT). | ||
*/ | ||
export declare const FLOAT32_MIN = -3.4028234663852886e+38; | ||
/** | ||
* Maximum value for an unsigned 32-bit integer (Protobuf UINT32, FIXED32). | ||
*/ | ||
export declare const UINT32_MAX = 4294967295; | ||
/** | ||
* Maximum value for a signed 32-bit integer (Protobuf INT32, SFIXED32, SINT32). | ||
*/ | ||
export declare const INT32_MAX = 2147483647; | ||
/** | ||
* Minimum value for a signed 32-bit integer (Protobuf INT32, SFIXED32, SINT32). | ||
*/ | ||
export declare const INT32_MIN = -2147483648; | ||
export declare class BinaryWriter { | ||
@@ -44,0 +64,0 @@ private readonly encodeUtf8; |
@@ -16,5 +16,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BinaryReader = exports.BinaryWriter = exports.WireType = void 0; | ||
exports.BinaryReader = exports.BinaryWriter = exports.INT32_MIN = exports.INT32_MAX = exports.UINT32_MAX = exports.FLOAT32_MIN = exports.FLOAT32_MAX = exports.WireType = void 0; | ||
const varint_js_1 = require("./varint.js"); | ||
const assert_js_1 = require("../reflect/assert.js"); | ||
const proto_int64_js_1 = require("../proto-int64.js"); | ||
@@ -65,2 +64,22 @@ const text_encoding_js_1 = require("./text-encoding.js"); | ||
})(WireType || (exports.WireType = WireType = {})); | ||
/** | ||
* Maximum value for a 32-bit floating point value (Protobuf FLOAT). | ||
*/ | ||
exports.FLOAT32_MAX = 3.4028234663852886e38; | ||
/** | ||
* Minimum value for a 32-bit floating point value (Protobuf FLOAT). | ||
*/ | ||
exports.FLOAT32_MIN = -3.4028234663852886e38; | ||
/** | ||
* Maximum value for an unsigned 32-bit integer (Protobuf UINT32, FIXED32). | ||
*/ | ||
exports.UINT32_MAX = 0xffffffff; | ||
/** | ||
* Maximum value for a signed 32-bit integer (Protobuf INT32, SFIXED32, SINT32). | ||
*/ | ||
exports.INT32_MAX = 0x7fffffff; | ||
/** | ||
* Minimum value for a signed 32-bit integer (Protobuf INT32, SFIXED32, SINT32). | ||
*/ | ||
exports.INT32_MIN = -0x80000000; | ||
class BinaryWriter { | ||
@@ -147,3 +166,3 @@ constructor(encodeUtf8 = (0, text_encoding_js_1.getTextEncoding)().encodeUtf8) { | ||
uint32(value) { | ||
(0, assert_js_1.assertUInt32)(value); | ||
assertUInt32(value); | ||
// write value as varint 32, inlined for speed | ||
@@ -161,3 +180,3 @@ while (value > 0x7f) { | ||
int32(value) { | ||
(0, assert_js_1.assertInt32)(value); | ||
assertInt32(value); | ||
(0, varint_js_1.varint32write)(value, this.buf); | ||
@@ -192,3 +211,3 @@ return this; | ||
float(value) { | ||
(0, assert_js_1.assertFloat32)(value); | ||
assertFloat32(value); | ||
let chunk = new Uint8Array(4); | ||
@@ -210,3 +229,3 @@ new DataView(chunk.buffer).setFloat32(0, value, true); | ||
fixed32(value) { | ||
(0, assert_js_1.assertUInt32)(value); | ||
assertUInt32(value); | ||
let chunk = new Uint8Array(4); | ||
@@ -220,3 +239,3 @@ new DataView(chunk.buffer).setUint32(0, value, true); | ||
sfixed32(value) { | ||
(0, assert_js_1.assertInt32)(value); | ||
assertInt32(value); | ||
let chunk = new Uint8Array(4); | ||
@@ -230,3 +249,3 @@ new DataView(chunk.buffer).setInt32(0, value, true); | ||
sint32(value) { | ||
(0, assert_js_1.assertInt32)(value); | ||
assertInt32(value); | ||
// zigzag encode | ||
@@ -453,1 +472,28 @@ value = ((value << 1) ^ (value >> 31)) >>> 0; | ||
exports.BinaryReader = BinaryReader; | ||
/** | ||
* Assert a valid signed protobuf 32-bit integer. | ||
*/ | ||
function assertInt32(arg) { | ||
if (typeof arg !== "number") | ||
throw new Error("invalid int32: " + typeof arg); | ||
if (!Number.isInteger(arg) || arg > exports.INT32_MAX || arg < exports.INT32_MIN) | ||
throw new Error("invalid int32: " + arg); | ||
} | ||
/** | ||
* Assert a valid unsigned protobuf 32-bit integer. | ||
*/ | ||
function assertUInt32(arg) { | ||
if (typeof arg !== "number") | ||
throw new Error("invalid uint32: " + typeof arg); | ||
if (!Number.isInteger(arg) || arg > exports.UINT32_MAX || arg < 0) | ||
throw new Error("invalid uint32: " + arg); | ||
} | ||
/** | ||
* Assert a valid protobuf float value. | ||
*/ | ||
function assertFloat32(arg) { | ||
if (typeof arg !== "number") | ||
throw new Error("invalid float32: " + typeof arg); | ||
if (Number.isFinite(arg) && (arg > exports.FLOAT32_MAX || arg < exports.FLOAT32_MIN)) | ||
throw new Error("invalid float32: " + arg); | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { DescMessage } from "../desc-types.js"; | ||
import type { DescMessage } from "../descriptors.js"; | ||
import type { BinaryWriteOptions } from "../to-binary.js"; | ||
@@ -3,0 +3,0 @@ import type { MessageShape } from "../types.js"; |
@@ -1,3 +0,2 @@ | ||
import type { DescEnum } from "../desc-types.js"; | ||
import { ScalarType } from "../reflect/scalar.js"; | ||
import { type DescEnum, ScalarType } from "../descriptors.js"; | ||
/** | ||
@@ -4,0 +3,0 @@ * Parse an enum value from the Protobuf text format. |
@@ -17,5 +17,5 @@ "use strict"; | ||
exports.parseTextFormatScalarValue = exports.parseTextFormatEnumValue = void 0; | ||
const assert_js_1 = require("../reflect/assert.js"); | ||
const descriptors_js_1 = require("../descriptors.js"); | ||
const proto_int64_js_1 = require("../proto-int64.js"); | ||
const scalar_js_1 = require("../reflect/scalar.js"); | ||
/* eslint-disable @typescript-eslint/restrict-template-expressions */ | ||
/** | ||
@@ -28,3 +28,5 @@ * Parse an enum value from the Protobuf text format. | ||
const enumValue = descEnum.values.find((v) => v.name === value); | ||
(0, assert_js_1.assert)(enumValue, `cannot parse ${descEnum.name} default value: ${value}`); | ||
if (!enumValue) { | ||
throw new Error(`cannot parse ${descEnum} default value: ${value}`); | ||
} | ||
return enumValue.number; | ||
@@ -40,20 +42,20 @@ } | ||
switch (type) { | ||
case scalar_js_1.ScalarType.STRING: | ||
case descriptors_js_1.ScalarType.STRING: | ||
return value; | ||
case scalar_js_1.ScalarType.BYTES: { | ||
case descriptors_js_1.ScalarType.BYTES: { | ||
const u = unescapeBytesDefaultValue(value); | ||
if (u === false) { | ||
throw new Error(`cannot parse ${scalar_js_1.ScalarType[type]} default value: ${value}`); | ||
throw new Error(`cannot parse ${descriptors_js_1.ScalarType[type]} default value: ${value}`); | ||
} | ||
return u; | ||
} | ||
case scalar_js_1.ScalarType.INT64: | ||
case scalar_js_1.ScalarType.SFIXED64: | ||
case scalar_js_1.ScalarType.SINT64: | ||
case descriptors_js_1.ScalarType.INT64: | ||
case descriptors_js_1.ScalarType.SFIXED64: | ||
case descriptors_js_1.ScalarType.SINT64: | ||
return proto_int64_js_1.protoInt64.parse(value); | ||
case scalar_js_1.ScalarType.UINT64: | ||
case scalar_js_1.ScalarType.FIXED64: | ||
case descriptors_js_1.ScalarType.UINT64: | ||
case descriptors_js_1.ScalarType.FIXED64: | ||
return proto_int64_js_1.protoInt64.uParse(value); | ||
case scalar_js_1.ScalarType.DOUBLE: | ||
case scalar_js_1.ScalarType.FLOAT: | ||
case descriptors_js_1.ScalarType.DOUBLE: | ||
case descriptors_js_1.ScalarType.FLOAT: | ||
switch (value) { | ||
@@ -69,9 +71,9 @@ case "inf": | ||
} | ||
case scalar_js_1.ScalarType.BOOL: | ||
case descriptors_js_1.ScalarType.BOOL: | ||
return value === "true"; | ||
case scalar_js_1.ScalarType.INT32: | ||
case scalar_js_1.ScalarType.UINT32: | ||
case scalar_js_1.ScalarType.SINT32: | ||
case scalar_js_1.ScalarType.FIXED32: | ||
case scalar_js_1.ScalarType.SFIXED32: | ||
case descriptors_js_1.ScalarType.INT32: | ||
case descriptors_js_1.ScalarType.UINT32: | ||
case descriptors_js_1.ScalarType.SINT32: | ||
case descriptors_js_1.ScalarType.FIXED32: | ||
case descriptors_js_1.ScalarType.SFIXED32: | ||
return parseInt(value, 10); | ||
@@ -78,0 +80,0 @@ } |
import type { Message, MessageShape } from "../types.js"; | ||
import type { Any } from "./gen/google/protobuf/any_pb.js"; | ||
import type { DescMessage } from "../desc-types.js"; | ||
import type { Registry } from "../reflect/index.js"; | ||
import type { DescMessage } from "../descriptors.js"; | ||
import type { Registry } from "../registry.js"; | ||
/** | ||
@@ -38,2 +38,2 @@ * Creates a `google.protobuf.Any` from a message. | ||
*/ | ||
export declare function anyUnpackTo<Desc extends DescMessage>(any: Any, messageDesc: Desc, message: MessageShape<Desc>): MessageShape<Desc> | undefined; | ||
export declare function anyUnpackTo<Desc extends DescMessage>(any: Any, messageDesc: Desc, message: MessageShape<Desc>): void; |
@@ -24,3 +24,3 @@ "use strict"; | ||
*/ | ||
exports.fileDesc_google_protobuf_descriptor = (0, boot_js_1.boot)({ "name": "google/protobuf/descriptor.proto", "package": "google.protobuf", "messageType": [{ "name": "FileDescriptorSet", "field": [{ "name": "file", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.FileDescriptorProto" }] }, { "name": "FileDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "package", "number": 2, "type": 9, "label": 1 }, { "name": "dependency", "number": 3, "type": 9, "label": 3 }, { "name": "public_dependency", "number": 10, "type": 5, "label": 3 }, { "name": "weak_dependency", "number": 11, "type": 5, "label": 3 }, { "name": "message_type", "number": 4, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto" }, { "name": "enum_type", "number": 5, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumDescriptorProto" }, { "name": "service", "number": 6, "type": 11, "label": 3, "typeName": ".google.protobuf.ServiceDescriptorProto" }, { "name": "extension", "number": 7, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldDescriptorProto" }, { "name": "options", "number": 8, "type": 11, "label": 1, "typeName": ".google.protobuf.FileOptions" }, { "name": "source_code_info", "number": 9, "type": 11, "label": 1, "typeName": ".google.protobuf.SourceCodeInfo" }, { "name": "syntax", "number": 12, "type": 9, "label": 1 }, { "name": "edition", "number": 14, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }] }, { "name": "DescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "field", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldDescriptorProto" }, { "name": "extension", "number": 6, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldDescriptorProto" }, { "name": "nested_type", "number": 3, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto" }, { "name": "enum_type", "number": 4, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumDescriptorProto" }, { "name": "extension_range", "number": 5, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto.ExtensionRange" }, { "name": "oneof_decl", "number": 8, "type": 11, "label": 3, "typeName": ".google.protobuf.OneofDescriptorProto" }, { "name": "options", "number": 7, "type": 11, "label": 1, "typeName": ".google.protobuf.MessageOptions" }, { "name": "reserved_range", "number": 9, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto.ReservedRange" }, { "name": "reserved_name", "number": 10, "type": 9, "label": 3 }], "nestedType": [{ "name": "ExtensionRange", "field": [{ "name": "start", "number": 1, "type": 5, "label": 1 }, { "name": "end", "number": 2, "type": 5, "label": 1 }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.ExtensionRangeOptions" }] }, { "name": "ReservedRange", "field": [{ "name": "start", "number": 1, "type": 5, "label": 1 }, { "name": "end", "number": 2, "type": 5, "label": 1 }] }] }, { "name": "ExtensionRangeOptions", "field": [{ "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }, { "name": "declaration", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.ExtensionRangeOptions.Declaration", "options": { "retention": 2 } }, { "name": "features", "number": 50, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "verification", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.ExtensionRangeOptions.VerificationState", "defaultValue": "UNVERIFIED", "options": { "retention": 2 } }], "nestedType": [{ "name": "Declaration", "field": [{ "name": "number", "number": 1, "type": 5, "label": 1 }, { "name": "full_name", "number": 2, "type": 9, "label": 1 }, { "name": "type", "number": 3, "type": 9, "label": 1 }, { "name": "reserved", "number": 5, "type": 8, "label": 1 }, { "name": "repeated", "number": 6, "type": 8, "label": 1 }] }], "enumType": [{ "name": "VerificationState", "value": [{ "name": "DECLARATION", "number": 0 }, { "name": "UNVERIFIED", "number": 1 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "FieldDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "number", "number": 3, "type": 5, "label": 1 }, { "name": "label", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldDescriptorProto.Label" }, { "name": "type", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldDescriptorProto.Type" }, { "name": "type_name", "number": 6, "type": 9, "label": 1 }, { "name": "extendee", "number": 2, "type": 9, "label": 1 }, { "name": "default_value", "number": 7, "type": 9, "label": 1 }, { "name": "oneof_index", "number": 9, "type": 5, "label": 1 }, { "name": "json_name", "number": 10, "type": 9, "label": 1 }, { "name": "options", "number": 8, "type": 11, "label": 1, "typeName": ".google.protobuf.FieldOptions" }, { "name": "proto3_optional", "number": 17, "type": 8, "label": 1 }], "enumType": [{ "name": "Type", "value": [{ "name": "TYPE_DOUBLE", "number": 1 }, { "name": "TYPE_FLOAT", "number": 2 }, { "name": "TYPE_INT64", "number": 3 }, { "name": "TYPE_UINT64", "number": 4 }, { "name": "TYPE_INT32", "number": 5 }, { "name": "TYPE_FIXED64", "number": 6 }, { "name": "TYPE_FIXED32", "number": 7 }, { "name": "TYPE_BOOL", "number": 8 }, { "name": "TYPE_STRING", "number": 9 }, { "name": "TYPE_GROUP", "number": 10 }, { "name": "TYPE_MESSAGE", "number": 11 }, { "name": "TYPE_BYTES", "number": 12 }, { "name": "TYPE_UINT32", "number": 13 }, { "name": "TYPE_ENUM", "number": 14 }, { "name": "TYPE_SFIXED32", "number": 15 }, { "name": "TYPE_SFIXED64", "number": 16 }, { "name": "TYPE_SINT32", "number": 17 }, { "name": "TYPE_SINT64", "number": 18 }] }, { "name": "Label", "value": [{ "name": "LABEL_OPTIONAL", "number": 1 }, { "name": "LABEL_REPEATED", "number": 3 }, { "name": "LABEL_REQUIRED", "number": 2 }] }] }, { "name": "OneofDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "options", "number": 2, "type": 11, "label": 1, "typeName": ".google.protobuf.OneofOptions" }] }, { "name": "EnumDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "value", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumValueDescriptorProto" }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.EnumOptions" }, { "name": "reserved_range", "number": 4, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumDescriptorProto.EnumReservedRange" }, { "name": "reserved_name", "number": 5, "type": 9, "label": 3 }], "nestedType": [{ "name": "EnumReservedRange", "field": [{ "name": "start", "number": 1, "type": 5, "label": 1 }, { "name": "end", "number": 2, "type": 5, "label": 1 }] }] }, { "name": "EnumValueDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "number", "number": 2, "type": 5, "label": 1 }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.EnumValueOptions" }] }, { "name": "ServiceDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "method", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.MethodDescriptorProto" }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.ServiceOptions" }] }, { "name": "MethodDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "input_type", "number": 2, "type": 9, "label": 1 }, { "name": "output_type", "number": 3, "type": 9, "label": 1 }, { "name": "options", "number": 4, "type": 11, "label": 1, "typeName": ".google.protobuf.MethodOptions" }, { "name": "client_streaming", "number": 5, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "server_streaming", "number": 6, "type": 8, "label": 1, "defaultValue": "false" }] }, { "name": "FileOptions", "field": [{ "name": "java_package", "number": 1, "type": 9, "label": 1 }, { "name": "java_outer_classname", "number": 8, "type": 9, "label": 1 }, { "name": "java_multiple_files", "number": 10, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "java_generate_equals_and_hash", "number": 20, "type": 8, "label": 1, "options": { "deprecated": true } }, { "name": "java_string_check_utf8", "number": 27, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "optimize_for", "number": 9, "type": 14, "label": 1, "typeName": ".google.protobuf.FileOptions.OptimizeMode", "defaultValue": "SPEED" }, { "name": "go_package", "number": 11, "type": 9, "label": 1 }, { "name": "cc_generic_services", "number": 16, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "java_generic_services", "number": 17, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "py_generic_services", "number": 18, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated", "number": 23, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "cc_enable_arenas", "number": 31, "type": 8, "label": 1, "defaultValue": "true" }, { "name": "objc_class_prefix", "number": 36, "type": 9, "label": 1 }, { "name": "csharp_namespace", "number": 37, "type": 9, "label": 1 }, { "name": "swift_prefix", "number": 39, "type": 9, "label": 1 }, { "name": "php_class_prefix", "number": 40, "type": 9, "label": 1 }, { "name": "php_namespace", "number": 41, "type": 9, "label": 1 }, { "name": "php_metadata_namespace", "number": 44, "type": 9, "label": 1 }, { "name": "ruby_package", "number": 45, "type": 9, "label": 1 }, { "name": "features", "number": 50, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "enumType": [{ "name": "OptimizeMode", "value": [{ "name": "SPEED", "number": 1 }, { "name": "CODE_SIZE", "number": 2 }, { "name": "LITE_RUNTIME", "number": 3 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "MessageOptions", "field": [{ "name": "message_set_wire_format", "number": 1, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "no_standard_descriptor_accessor", "number": 2, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "map_entry", "number": 7, "type": 8, "label": 1 }, { "name": "deprecated_legacy_json_field_conflicts", "number": 11, "type": 8, "label": 1, "options": { "deprecated": true } }, { "name": "features", "number": 12, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "FieldOptions", "field": [{ "name": "ctype", "number": 1, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldOptions.CType", "defaultValue": "STRING" }, { "name": "packed", "number": 2, "type": 8, "label": 1 }, { "name": "jstype", "number": 6, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldOptions.JSType", "defaultValue": "JS_NORMAL" }, { "name": "lazy", "number": 5, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "unverified_lazy", "number": 15, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "weak", "number": 10, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "debug_redact", "number": 16, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "retention", "number": 17, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldOptions.OptionRetention" }, { "name": "targets", "number": 19, "type": 14, "label": 3, "typeName": ".google.protobuf.FieldOptions.OptionTargetType" }, { "name": "edition_defaults", "number": 20, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldOptions.EditionDefault" }, { "name": "features", "number": 21, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "feature_support", "number": 22, "type": 11, "label": 1, "typeName": ".google.protobuf.FieldOptions.FeatureSupport" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "nestedType": [{ "name": "EditionDefault", "field": [{ "name": "edition", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "value", "number": 2, "type": 9, "label": 1 }] }, { "name": "FeatureSupport", "field": [{ "name": "edition_introduced", "number": 1, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "edition_deprecated", "number": 2, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "deprecation_warning", "number": 3, "type": 9, "label": 1 }, { "name": "edition_removed", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }] }], "enumType": [{ "name": "CType", "value": [{ "name": "STRING", "number": 0 }, { "name": "CORD", "number": 1 }, { "name": "STRING_PIECE", "number": 2 }] }, { "name": "JSType", "value": [{ "name": "JS_NORMAL", "number": 0 }, { "name": "JS_STRING", "number": 1 }, { "name": "JS_NUMBER", "number": 2 }] }, { "name": "OptionRetention", "value": [{ "name": "RETENTION_UNKNOWN", "number": 0 }, { "name": "RETENTION_RUNTIME", "number": 1 }, { "name": "RETENTION_SOURCE", "number": 2 }] }, { "name": "OptionTargetType", "value": [{ "name": "TARGET_TYPE_UNKNOWN", "number": 0 }, { "name": "TARGET_TYPE_FILE", "number": 1 }, { "name": "TARGET_TYPE_EXTENSION_RANGE", "number": 2 }, { "name": "TARGET_TYPE_MESSAGE", "number": 3 }, { "name": "TARGET_TYPE_FIELD", "number": 4 }, { "name": "TARGET_TYPE_ONEOF", "number": 5 }, { "name": "TARGET_TYPE_ENUM", "number": 6 }, { "name": "TARGET_TYPE_ENUM_ENTRY", "number": 7 }, { "name": "TARGET_TYPE_SERVICE", "number": 8 }, { "name": "TARGET_TYPE_METHOD", "number": 9 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "OneofOptions", "field": [{ "name": "features", "number": 1, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "EnumOptions", "field": [{ "name": "allow_alias", "number": 2, "type": 8, "label": 1 }, { "name": "deprecated", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated_legacy_json_field_conflicts", "number": 6, "type": 8, "label": 1, "options": { "deprecated": true } }, { "name": "features", "number": 7, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "EnumValueOptions", "field": [{ "name": "deprecated", "number": 1, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "features", "number": 2, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "debug_redact", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "ServiceOptions", "field": [{ "name": "features", "number": 34, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "deprecated", "number": 33, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "MethodOptions", "field": [{ "name": "deprecated", "number": 33, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "idempotency_level", "number": 34, "type": 14, "label": 1, "typeName": ".google.protobuf.MethodOptions.IdempotencyLevel", "defaultValue": "IDEMPOTENCY_UNKNOWN" }, { "name": "features", "number": 35, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "enumType": [{ "name": "IdempotencyLevel", "value": [{ "name": "IDEMPOTENCY_UNKNOWN", "number": 0 }, { "name": "NO_SIDE_EFFECTS", "number": 1 }, { "name": "IDEMPOTENT", "number": 2 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "UninterpretedOption", "field": [{ "name": "name", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption.NamePart" }, { "name": "identifier_value", "number": 3, "type": 9, "label": 1 }, { "name": "positive_int_value", "number": 4, "type": 4, "label": 1 }, { "name": "negative_int_value", "number": 5, "type": 3, "label": 1 }, { "name": "double_value", "number": 6, "type": 1, "label": 1 }, { "name": "string_value", "number": 7, "type": 12, "label": 1 }, { "name": "aggregate_value", "number": 8, "type": 9, "label": 1 }], "nestedType": [{ "name": "NamePart", "field": [{ "name": "name_part", "number": 1, "type": 9, "label": 2 }, { "name": "is_extension", "number": 2, "type": 8, "label": 2 }] }] }, { "name": "FeatureSet", "field": [{ "name": "field_presence", "number": 1, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.FieldPresence", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "EXPLICIT", "edition": 998 }, { "value": "IMPLICIT", "edition": 999 }, { "value": "EXPLICIT", "edition": 1000 }] } }, { "name": "enum_type", "number": 2, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.EnumType", "options": { "retention": 1, "targets": [6, 1], "editionDefaults": [{ "value": "CLOSED", "edition": 998 }, { "value": "OPEN", "edition": 999 }] } }, { "name": "repeated_field_encoding", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.RepeatedFieldEncoding", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "EXPANDED", "edition": 998 }, { "value": "PACKED", "edition": 999 }] } }, { "name": "utf8_validation", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.Utf8Validation", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "NONE", "edition": 998 }, { "value": "VERIFY", "edition": 999 }] } }, { "name": "message_encoding", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.MessageEncoding", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "LENGTH_PREFIXED", "edition": 998 }] } }, { "name": "json_format", "number": 6, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.JsonFormat", "options": { "retention": 1, "targets": [3, 6, 1], "editionDefaults": [{ "value": "LEGACY_BEST_EFFORT", "edition": 998 }, { "value": "ALLOW", "edition": 999 }] } }], "enumType": [{ "name": "FieldPresence", "value": [{ "name": "FIELD_PRESENCE_UNKNOWN", "number": 0 }, { "name": "EXPLICIT", "number": 1 }, { "name": "IMPLICIT", "number": 2 }, { "name": "LEGACY_REQUIRED", "number": 3 }] }, { "name": "EnumType", "value": [{ "name": "ENUM_TYPE_UNKNOWN", "number": 0 }, { "name": "OPEN", "number": 1 }, { "name": "CLOSED", "number": 2 }] }, { "name": "RepeatedFieldEncoding", "value": [{ "name": "REPEATED_FIELD_ENCODING_UNKNOWN", "number": 0 }, { "name": "PACKED", "number": 1 }, { "name": "EXPANDED", "number": 2 }] }, { "name": "Utf8Validation", "value": [{ "name": "UTF8_VALIDATION_UNKNOWN", "number": 0 }, { "name": "VERIFY", "number": 2 }, { "name": "NONE", "number": 3 }] }, { "name": "MessageEncoding", "value": [{ "name": "MESSAGE_ENCODING_UNKNOWN", "number": 0 }, { "name": "LENGTH_PREFIXED", "number": 1 }, { "name": "DELIMITED", "number": 2 }] }, { "name": "JsonFormat", "value": [{ "name": "JSON_FORMAT_UNKNOWN", "number": 0 }, { "name": "ALLOW", "number": 1 }, { "name": "LEGACY_BEST_EFFORT", "number": 2 }] }], "extensionRange": [{ "start": 1000, "end": 1001 }, { "start": 1001, "end": 1002 }, { "start": 1002, "end": 1003 }, { "start": 9990, "end": 9991 }, { "start": 9995, "end": 10000 }, { "start": 10000, "end": 10001 }] }, { "name": "FeatureSetDefaults", "field": [{ "name": "defaults", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault" }, { "name": "minimum_edition", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "maximum_edition", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }], "nestedType": [{ "name": "FeatureSetEditionDefault", "field": [{ "name": "edition", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "overridable_features", "number": 4, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "fixed_features", "number": 5, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }] }] }, { "name": "SourceCodeInfo", "field": [{ "name": "location", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.SourceCodeInfo.Location" }], "nestedType": [{ "name": "Location", "field": [{ "name": "path", "number": 1, "type": 5, "label": 3, "options": { "packed": true } }, { "name": "span", "number": 2, "type": 5, "label": 3, "options": { "packed": true } }, { "name": "leading_comments", "number": 3, "type": 9, "label": 1 }, { "name": "trailing_comments", "number": 4, "type": 9, "label": 1 }, { "name": "leading_detached_comments", "number": 6, "type": 9, "label": 3 }] }] }, { "name": "GeneratedCodeInfo", "field": [{ "name": "annotation", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.GeneratedCodeInfo.Annotation" }], "nestedType": [{ "name": "Annotation", "field": [{ "name": "path", "number": 1, "type": 5, "label": 3, "options": { "packed": true } }, { "name": "source_file", "number": 2, "type": 9, "label": 1 }, { "name": "begin", "number": 3, "type": 5, "label": 1 }, { "name": "end", "number": 4, "type": 5, "label": 1 }, { "name": "semantic", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.GeneratedCodeInfo.Annotation.Semantic" }], "enumType": [{ "name": "Semantic", "value": [{ "name": "NONE", "number": 0 }, { "name": "SET", "number": 1 }, { "name": "ALIAS", "number": 2 }] }] }] }], "enumType": [{ "name": "Edition", "value": [{ "name": "EDITION_UNKNOWN", "number": 0 }, { "name": "EDITION_LEGACY", "number": 900 }, { "name": "EDITION_PROTO2", "number": 998 }, { "name": "EDITION_PROTO3", "number": 999 }, { "name": "EDITION_2023", "number": 1000 }, { "name": "EDITION_2024", "number": 1001 }, { "name": "EDITION_1_TEST_ONLY", "number": 1 }, { "name": "EDITION_2_TEST_ONLY", "number": 2 }, { "name": "EDITION_99997_TEST_ONLY", "number": 99997 }, { "name": "EDITION_99998_TEST_ONLY", "number": 99998 }, { "name": "EDITION_99999_TEST_ONLY", "number": 99999 }, { "name": "EDITION_MAX", "number": 2147483647 }] }] }); | ||
exports.fileDesc_google_protobuf_descriptor = (0, boot_js_1.boot)({ "name": "google/protobuf/descriptor.proto", "package": "google.protobuf", "messageType": [{ "name": "FileDescriptorSet", "field": [{ "name": "file", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.FileDescriptorProto" }] }, { "name": "FileDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "package", "number": 2, "type": 9, "label": 1 }, { "name": "dependency", "number": 3, "type": 9, "label": 3 }, { "name": "public_dependency", "number": 10, "type": 5, "label": 3 }, { "name": "weak_dependency", "number": 11, "type": 5, "label": 3 }, { "name": "message_type", "number": 4, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto" }, { "name": "enum_type", "number": 5, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumDescriptorProto" }, { "name": "service", "number": 6, "type": 11, "label": 3, "typeName": ".google.protobuf.ServiceDescriptorProto" }, { "name": "extension", "number": 7, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldDescriptorProto" }, { "name": "options", "number": 8, "type": 11, "label": 1, "typeName": ".google.protobuf.FileOptions" }, { "name": "source_code_info", "number": 9, "type": 11, "label": 1, "typeName": ".google.protobuf.SourceCodeInfo" }, { "name": "syntax", "number": 12, "type": 9, "label": 1 }, { "name": "edition", "number": 14, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }] }, { "name": "DescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "field", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldDescriptorProto" }, { "name": "extension", "number": 6, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldDescriptorProto" }, { "name": "nested_type", "number": 3, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto" }, { "name": "enum_type", "number": 4, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumDescriptorProto" }, { "name": "extension_range", "number": 5, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto.ExtensionRange" }, { "name": "oneof_decl", "number": 8, "type": 11, "label": 3, "typeName": ".google.protobuf.OneofDescriptorProto" }, { "name": "options", "number": 7, "type": 11, "label": 1, "typeName": ".google.protobuf.MessageOptions" }, { "name": "reserved_range", "number": 9, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto.ReservedRange" }, { "name": "reserved_name", "number": 10, "type": 9, "label": 3 }], "nestedType": [{ "name": "ExtensionRange", "field": [{ "name": "start", "number": 1, "type": 5, "label": 1 }, { "name": "end", "number": 2, "type": 5, "label": 1 }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.ExtensionRangeOptions" }] }, { "name": "ReservedRange", "field": [{ "name": "start", "number": 1, "type": 5, "label": 1 }, { "name": "end", "number": 2, "type": 5, "label": 1 }] }] }, { "name": "ExtensionRangeOptions", "field": [{ "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }, { "name": "declaration", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.ExtensionRangeOptions.Declaration", "options": { "retention": 2 } }, { "name": "features", "number": 50, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "verification", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.ExtensionRangeOptions.VerificationState", "defaultValue": "UNVERIFIED", "options": { "retention": 2 } }], "nestedType": [{ "name": "Declaration", "field": [{ "name": "number", "number": 1, "type": 5, "label": 1 }, { "name": "full_name", "number": 2, "type": 9, "label": 1 }, { "name": "type", "number": 3, "type": 9, "label": 1 }, { "name": "reserved", "number": 5, "type": 8, "label": 1 }, { "name": "repeated", "number": 6, "type": 8, "label": 1 }] }], "enumType": [{ "name": "VerificationState", "value": [{ "name": "DECLARATION", "number": 0 }, { "name": "UNVERIFIED", "number": 1 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "FieldDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "number", "number": 3, "type": 5, "label": 1 }, { "name": "label", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldDescriptorProto.Label" }, { "name": "type", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldDescriptorProto.Type" }, { "name": "type_name", "number": 6, "type": 9, "label": 1 }, { "name": "extendee", "number": 2, "type": 9, "label": 1 }, { "name": "default_value", "number": 7, "type": 9, "label": 1 }, { "name": "oneof_index", "number": 9, "type": 5, "label": 1 }, { "name": "json_name", "number": 10, "type": 9, "label": 1 }, { "name": "options", "number": 8, "type": 11, "label": 1, "typeName": ".google.protobuf.FieldOptions" }, { "name": "proto3_optional", "number": 17, "type": 8, "label": 1 }], "enumType": [{ "name": "Type", "value": [{ "name": "TYPE_DOUBLE", "number": 1 }, { "name": "TYPE_FLOAT", "number": 2 }, { "name": "TYPE_INT64", "number": 3 }, { "name": "TYPE_UINT64", "number": 4 }, { "name": "TYPE_INT32", "number": 5 }, { "name": "TYPE_FIXED64", "number": 6 }, { "name": "TYPE_FIXED32", "number": 7 }, { "name": "TYPE_BOOL", "number": 8 }, { "name": "TYPE_STRING", "number": 9 }, { "name": "TYPE_GROUP", "number": 10 }, { "name": "TYPE_MESSAGE", "number": 11 }, { "name": "TYPE_BYTES", "number": 12 }, { "name": "TYPE_UINT32", "number": 13 }, { "name": "TYPE_ENUM", "number": 14 }, { "name": "TYPE_SFIXED32", "number": 15 }, { "name": "TYPE_SFIXED64", "number": 16 }, { "name": "TYPE_SINT32", "number": 17 }, { "name": "TYPE_SINT64", "number": 18 }] }, { "name": "Label", "value": [{ "name": "LABEL_OPTIONAL", "number": 1 }, { "name": "LABEL_REPEATED", "number": 3 }, { "name": "LABEL_REQUIRED", "number": 2 }] }] }, { "name": "OneofDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "options", "number": 2, "type": 11, "label": 1, "typeName": ".google.protobuf.OneofOptions" }] }, { "name": "EnumDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "value", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumValueDescriptorProto" }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.EnumOptions" }, { "name": "reserved_range", "number": 4, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumDescriptorProto.EnumReservedRange" }, { "name": "reserved_name", "number": 5, "type": 9, "label": 3 }], "nestedType": [{ "name": "EnumReservedRange", "field": [{ "name": "start", "number": 1, "type": 5, "label": 1 }, { "name": "end", "number": 2, "type": 5, "label": 1 }] }] }, { "name": "EnumValueDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "number", "number": 2, "type": 5, "label": 1 }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.EnumValueOptions" }] }, { "name": "ServiceDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "method", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.MethodDescriptorProto" }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.ServiceOptions" }] }, { "name": "MethodDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "input_type", "number": 2, "type": 9, "label": 1 }, { "name": "output_type", "number": 3, "type": 9, "label": 1 }, { "name": "options", "number": 4, "type": 11, "label": 1, "typeName": ".google.protobuf.MethodOptions" }, { "name": "client_streaming", "number": 5, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "server_streaming", "number": 6, "type": 8, "label": 1, "defaultValue": "false" }] }, { "name": "FileOptions", "field": [{ "name": "java_package", "number": 1, "type": 9, "label": 1 }, { "name": "java_outer_classname", "number": 8, "type": 9, "label": 1 }, { "name": "java_multiple_files", "number": 10, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "java_generate_equals_and_hash", "number": 20, "type": 8, "label": 1, "options": { "deprecated": true } }, { "name": "java_string_check_utf8", "number": 27, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "optimize_for", "number": 9, "type": 14, "label": 1, "typeName": ".google.protobuf.FileOptions.OptimizeMode", "defaultValue": "SPEED" }, { "name": "go_package", "number": 11, "type": 9, "label": 1 }, { "name": "cc_generic_services", "number": 16, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "java_generic_services", "number": 17, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "py_generic_services", "number": 18, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated", "number": 23, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "cc_enable_arenas", "number": 31, "type": 8, "label": 1, "defaultValue": "true" }, { "name": "objc_class_prefix", "number": 36, "type": 9, "label": 1 }, { "name": "csharp_namespace", "number": 37, "type": 9, "label": 1 }, { "name": "swift_prefix", "number": 39, "type": 9, "label": 1 }, { "name": "php_class_prefix", "number": 40, "type": 9, "label": 1 }, { "name": "php_namespace", "number": 41, "type": 9, "label": 1 }, { "name": "php_metadata_namespace", "number": 44, "type": 9, "label": 1 }, { "name": "ruby_package", "number": 45, "type": 9, "label": 1 }, { "name": "features", "number": 50, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "enumType": [{ "name": "OptimizeMode", "value": [{ "name": "SPEED", "number": 1 }, { "name": "CODE_SIZE", "number": 2 }, { "name": "LITE_RUNTIME", "number": 3 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "MessageOptions", "field": [{ "name": "message_set_wire_format", "number": 1, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "no_standard_descriptor_accessor", "number": 2, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "map_entry", "number": 7, "type": 8, "label": 1 }, { "name": "deprecated_legacy_json_field_conflicts", "number": 11, "type": 8, "label": 1, "options": { "deprecated": true } }, { "name": "features", "number": 12, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "FieldOptions", "field": [{ "name": "ctype", "number": 1, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldOptions.CType", "defaultValue": "STRING" }, { "name": "packed", "number": 2, "type": 8, "label": 1 }, { "name": "jstype", "number": 6, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldOptions.JSType", "defaultValue": "JS_NORMAL" }, { "name": "lazy", "number": 5, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "unverified_lazy", "number": 15, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "weak", "number": 10, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "debug_redact", "number": 16, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "retention", "number": 17, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldOptions.OptionRetention" }, { "name": "targets", "number": 19, "type": 14, "label": 3, "typeName": ".google.protobuf.FieldOptions.OptionTargetType" }, { "name": "edition_defaults", "number": 20, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldOptions.EditionDefault" }, { "name": "features", "number": 21, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "feature_support", "number": 22, "type": 11, "label": 1, "typeName": ".google.protobuf.FieldOptions.FeatureSupport" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "nestedType": [{ "name": "EditionDefault", "field": [{ "name": "edition", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "value", "number": 2, "type": 9, "label": 1 }] }, { "name": "FeatureSupport", "field": [{ "name": "edition_introduced", "number": 1, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "edition_deprecated", "number": 2, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "deprecation_warning", "number": 3, "type": 9, "label": 1 }, { "name": "edition_removed", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }] }], "enumType": [{ "name": "CType", "value": [{ "name": "STRING", "number": 0 }, { "name": "CORD", "number": 1 }, { "name": "STRING_PIECE", "number": 2 }] }, { "name": "JSType", "value": [{ "name": "JS_NORMAL", "number": 0 }, { "name": "JS_STRING", "number": 1 }, { "name": "JS_NUMBER", "number": 2 }] }, { "name": "OptionRetention", "value": [{ "name": "RETENTION_UNKNOWN", "number": 0 }, { "name": "RETENTION_RUNTIME", "number": 1 }, { "name": "RETENTION_SOURCE", "number": 2 }] }, { "name": "OptionTargetType", "value": [{ "name": "TARGET_TYPE_UNKNOWN", "number": 0 }, { "name": "TARGET_TYPE_FILE", "number": 1 }, { "name": "TARGET_TYPE_EXTENSION_RANGE", "number": 2 }, { "name": "TARGET_TYPE_MESSAGE", "number": 3 }, { "name": "TARGET_TYPE_FIELD", "number": 4 }, { "name": "TARGET_TYPE_ONEOF", "number": 5 }, { "name": "TARGET_TYPE_ENUM", "number": 6 }, { "name": "TARGET_TYPE_ENUM_ENTRY", "number": 7 }, { "name": "TARGET_TYPE_SERVICE", "number": 8 }, { "name": "TARGET_TYPE_METHOD", "number": 9 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "OneofOptions", "field": [{ "name": "features", "number": 1, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "EnumOptions", "field": [{ "name": "allow_alias", "number": 2, "type": 8, "label": 1 }, { "name": "deprecated", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated_legacy_json_field_conflicts", "number": 6, "type": 8, "label": 1, "options": { "deprecated": true } }, { "name": "features", "number": 7, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "EnumValueOptions", "field": [{ "name": "deprecated", "number": 1, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "features", "number": 2, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "debug_redact", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "feature_support", "number": 4, "type": 11, "label": 1, "typeName": ".google.protobuf.FieldOptions.FeatureSupport" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "ServiceOptions", "field": [{ "name": "features", "number": 34, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "deprecated", "number": 33, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "MethodOptions", "field": [{ "name": "deprecated", "number": 33, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "idempotency_level", "number": 34, "type": 14, "label": 1, "typeName": ".google.protobuf.MethodOptions.IdempotencyLevel", "defaultValue": "IDEMPOTENCY_UNKNOWN" }, { "name": "features", "number": 35, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "enumType": [{ "name": "IdempotencyLevel", "value": [{ "name": "IDEMPOTENCY_UNKNOWN", "number": 0 }, { "name": "NO_SIDE_EFFECTS", "number": 1 }, { "name": "IDEMPOTENT", "number": 2 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "UninterpretedOption", "field": [{ "name": "name", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption.NamePart" }, { "name": "identifier_value", "number": 3, "type": 9, "label": 1 }, { "name": "positive_int_value", "number": 4, "type": 4, "label": 1 }, { "name": "negative_int_value", "number": 5, "type": 3, "label": 1 }, { "name": "double_value", "number": 6, "type": 1, "label": 1 }, { "name": "string_value", "number": 7, "type": 12, "label": 1 }, { "name": "aggregate_value", "number": 8, "type": 9, "label": 1 }], "nestedType": [{ "name": "NamePart", "field": [{ "name": "name_part", "number": 1, "type": 9, "label": 2 }, { "name": "is_extension", "number": 2, "type": 8, "label": 2 }] }] }, { "name": "FeatureSet", "field": [{ "name": "field_presence", "number": 1, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.FieldPresence", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "EXPLICIT", "edition": 998 }, { "value": "IMPLICIT", "edition": 999 }, { "value": "EXPLICIT", "edition": 1000 }] } }, { "name": "enum_type", "number": 2, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.EnumType", "options": { "retention": 1, "targets": [6, 1], "editionDefaults": [{ "value": "CLOSED", "edition": 998 }, { "value": "OPEN", "edition": 999 }] } }, { "name": "repeated_field_encoding", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.RepeatedFieldEncoding", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "EXPANDED", "edition": 998 }, { "value": "PACKED", "edition": 999 }] } }, { "name": "utf8_validation", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.Utf8Validation", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "NONE", "edition": 998 }, { "value": "VERIFY", "edition": 999 }] } }, { "name": "message_encoding", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.MessageEncoding", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "LENGTH_PREFIXED", "edition": 998 }] } }, { "name": "json_format", "number": 6, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.JsonFormat", "options": { "retention": 1, "targets": [3, 6, 1], "editionDefaults": [{ "value": "LEGACY_BEST_EFFORT", "edition": 998 }, { "value": "ALLOW", "edition": 999 }] } }], "enumType": [{ "name": "FieldPresence", "value": [{ "name": "FIELD_PRESENCE_UNKNOWN", "number": 0 }, { "name": "EXPLICIT", "number": 1 }, { "name": "IMPLICIT", "number": 2 }, { "name": "LEGACY_REQUIRED", "number": 3 }] }, { "name": "EnumType", "value": [{ "name": "ENUM_TYPE_UNKNOWN", "number": 0 }, { "name": "OPEN", "number": 1 }, { "name": "CLOSED", "number": 2 }] }, { "name": "RepeatedFieldEncoding", "value": [{ "name": "REPEATED_FIELD_ENCODING_UNKNOWN", "number": 0 }, { "name": "PACKED", "number": 1 }, { "name": "EXPANDED", "number": 2 }] }, { "name": "Utf8Validation", "value": [{ "name": "UTF8_VALIDATION_UNKNOWN", "number": 0 }, { "name": "VERIFY", "number": 2 }, { "name": "NONE", "number": 3 }] }, { "name": "MessageEncoding", "value": [{ "name": "MESSAGE_ENCODING_UNKNOWN", "number": 0 }, { "name": "LENGTH_PREFIXED", "number": 1 }, { "name": "DELIMITED", "number": 2 }] }, { "name": "JsonFormat", "value": [{ "name": "JSON_FORMAT_UNKNOWN", "number": 0 }, { "name": "ALLOW", "number": 1 }, { "name": "LEGACY_BEST_EFFORT", "number": 2 }] }], "extensionRange": [{ "start": 1000, "end": 9995 }, { "start": 9995, "end": 10000 }, { "start": 10000, "end": 10001 }] }, { "name": "FeatureSetDefaults", "field": [{ "name": "defaults", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault" }, { "name": "minimum_edition", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "maximum_edition", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }], "nestedType": [{ "name": "FeatureSetEditionDefault", "field": [{ "name": "edition", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "overridable_features", "number": 4, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "fixed_features", "number": 5, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }] }] }, { "name": "SourceCodeInfo", "field": [{ "name": "location", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.SourceCodeInfo.Location" }], "nestedType": [{ "name": "Location", "field": [{ "name": "path", "number": 1, "type": 5, "label": 3, "options": { "packed": true } }, { "name": "span", "number": 2, "type": 5, "label": 3, "options": { "packed": true } }, { "name": "leading_comments", "number": 3, "type": 9, "label": 1 }, { "name": "trailing_comments", "number": 4, "type": 9, "label": 1 }, { "name": "leading_detached_comments", "number": 6, "type": 9, "label": 3 }] }] }, { "name": "GeneratedCodeInfo", "field": [{ "name": "annotation", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.GeneratedCodeInfo.Annotation" }], "nestedType": [{ "name": "Annotation", "field": [{ "name": "path", "number": 1, "type": 5, "label": 3, "options": { "packed": true } }, { "name": "source_file", "number": 2, "type": 9, "label": 1 }, { "name": "begin", "number": 3, "type": 5, "label": 1 }, { "name": "end", "number": 4, "type": 5, "label": 1 }, { "name": "semantic", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.GeneratedCodeInfo.Annotation.Semantic" }], "enumType": [{ "name": "Semantic", "value": [{ "name": "NONE", "number": 0 }, { "name": "SET", "number": 1 }, { "name": "ALIAS", "number": 2 }] }] }] }], "enumType": [{ "name": "Edition", "value": [{ "name": "EDITION_UNKNOWN", "number": 0 }, { "name": "EDITION_LEGACY", "number": 900 }, { "name": "EDITION_PROTO2", "number": 998 }, { "name": "EDITION_PROTO3", "number": 999 }, { "name": "EDITION_2023", "number": 1000 }, { "name": "EDITION_2024", "number": 1001 }, { "name": "EDITION_1_TEST_ONLY", "number": 1 }, { "name": "EDITION_2_TEST_ONLY", "number": 2 }, { "name": "EDITION_99997_TEST_ONLY", "number": 99997 }, { "name": "EDITION_99998_TEST_ONLY", "number": 99998 }, { "name": "EDITION_99999_TEST_ONLY", "number": 99999 }, { "name": "EDITION_MAX", "number": 2147483647 }] }] }); | ||
/** | ||
@@ -27,0 +27,0 @@ * Describes the message google.protobuf.FileDescriptorSet. |
import type { Message } from "../types.js"; | ||
import type { BoolValue, BytesValue, DoubleValue, FloatValue, Int32Value, Int64Value, StringValue, UInt32Value, UInt64Value } from "./gen/google/protobuf/wrappers_pb.js"; | ||
import type { DescField, DescMessage } from "../desc-types.js"; | ||
import type { DescField, DescMessage } from "../descriptors.js"; | ||
export declare function isWrapper(arg: Message): arg is DoubleValue | FloatValue | Int64Value | UInt64Value | Int32Value | UInt32Value | BoolValue | StringValue | BytesValue; | ||
@@ -5,0 +5,0 @@ export type WktWrapperDesc = DescMessage & { |
import type { MessageShape } from "./types.js"; | ||
import type { DescMessage } from "./desc-types.js"; | ||
import { type DescMessage } from "./descriptors.js"; | ||
/** | ||
@@ -4,0 +4,0 @@ * Create a deep copy of a message, including extensions and unknown fields. |
@@ -14,5 +14,5 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
// limitations under the License. | ||
import { ScalarType } from "./descriptors.js"; | ||
import { reflect } from "./reflect/reflect.js"; | ||
import { isReflectMessage } from "./reflect/guard.js"; | ||
import { ScalarType } from "./reflect/scalar.js"; | ||
/** | ||
@@ -19,0 +19,0 @@ * Create a deep copy of a message, including extensions and unknown fields. |
import type { DescriptorProto_ExtensionRange, FieldDescriptorProto_Label, FieldDescriptorProto_Type, FieldOptions_OptionRetention, FieldOptions_OptionTargetType, FieldOptions_EditionDefault, EnumValueDescriptorProto, FileDescriptorProto } from "../wkt/gen/google/protobuf/descriptor_pb.js"; | ||
import type { DescFile } from "../desc-types.js"; | ||
import type { DescFile } from "../descriptors.js"; | ||
/** | ||
@@ -4,0 +4,0 @@ * Hydrate a file descriptor for google/protobuf/descriptor.proto from a plain |
@@ -15,4 +15,3 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
import { restoreJsonNames } from "./restore-json-names.js"; | ||
import { createFileRegistry } from "../reflect/registry.js"; | ||
import { assert } from "../reflect/assert.js"; | ||
import { createFileRegistry } from "../registry.js"; | ||
/** | ||
@@ -30,5 +29,4 @@ * Hydrate a file descriptor for google/protobuf/descriptor.proto from a plain | ||
const reg = createFileRegistry(root, () => undefined); | ||
const file = reg.getFile(root.name); | ||
assert(file); | ||
return file; | ||
// non-null assertion because we just created the registry from the file we look up | ||
return reg.getFile(root.name); | ||
} | ||
@@ -35,0 +33,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import type { DescEnum, DescExtension, DescMessage, DescService } from "../desc-types.js"; | ||
import type { DescEnum, DescExtension, DescMessage, DescService } from "../descriptors.js"; | ||
import type { FileDescriptorProto } from "../wkt/gen/google/protobuf/descriptor_pb.js"; | ||
@@ -3,0 +3,0 @@ import type { FileDescriptorProtoBoot } from "./boot.js"; |
@@ -15,3 +15,2 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
import { protoCamelCase } from "../reflect/names.js"; | ||
import { assert } from "../reflect/assert.js"; | ||
import { isFieldSet, clearField } from "../fields.js"; | ||
@@ -139,3 +138,2 @@ import { base64Encode } from "../wire/base64-encoding.js"; | ||
assert(!proto.options); | ||
assert(!proto.reservedName.length); // we're also dropping reserved_range | ||
const b = { | ||
@@ -221,4 +219,2 @@ name: proto.name, | ||
function createEnumDescriptorBoot(proto) { | ||
assert(!proto.reservedName.length); | ||
assert(!proto.reservedRange.length); | ||
assert(!proto.options); | ||
@@ -236,1 +232,10 @@ return { | ||
} | ||
/** | ||
* Assert that condition is truthy or throw error. | ||
*/ | ||
function assert(condition) { | ||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions -- we want the implicit conversion to boolean | ||
if (!condition) { | ||
throw new Error(); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { DescEnum, DescFile } from "../desc-types.js"; | ||
import type { DescEnum, DescFile } from "../descriptors.js"; | ||
import type { GenDescEnum } from "./types.js"; | ||
@@ -3,0 +3,0 @@ /** |
import type { Message } from "../types.js"; | ||
import type { DescFile } from "../desc-types.js"; | ||
import type { DescFile } from "../descriptors.js"; | ||
import type { GenDescExtension } from "./types.js"; | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import type { DescFile } from "../desc-types.js"; | ||
import type { DescFile } from "../descriptors.js"; | ||
/** | ||
@@ -3,0 +3,0 @@ * Hydrate a file descriptor. |
@@ -14,6 +14,5 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
// limitations under the License. | ||
import { base64Decode } from "../wire/index.js"; | ||
import { base64Decode } from "../wire/base64-encoding.js"; | ||
import { FileDescriptorProtoDesc } from "../wkt/gen/google/protobuf/descriptor_pb.js"; | ||
import { createFileRegistry } from "../reflect/registry.js"; | ||
import { assert } from "../reflect/assert.js"; | ||
import { createFileRegistry } from "../registry.js"; | ||
import { restoreJsonNames } from "./restore-json-names.js"; | ||
@@ -32,5 +31,4 @@ import { fromBinary } from "../from-binary.js"; | ||
const reg = createFileRegistry(root, (protoFileName) => imports === null || imports === void 0 ? void 0 : imports.find((f) => f.proto.name === protoFileName)); | ||
const file = reg.getFile(root.name); | ||
assert(file); | ||
return file; | ||
// non-null assertion because we just created the registry from the file we look up | ||
return reg.getFile(root.name); | ||
} |
@@ -9,2 +9,3 @@ export * from "./boot.js"; | ||
export * from "./symbols.js"; | ||
export * from "./scalar.js"; | ||
export * from "./types.js"; |
@@ -22,2 +22,3 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
export * from "./symbols.js"; | ||
export * from "./scalar.js"; | ||
export * from "./types.js"; |
import type { Message } from "../types.js"; | ||
import type { DescFile } from "../desc-types.js"; | ||
import type { DescFile } from "../descriptors.js"; | ||
import type { GenDescMessage } from "./types.js"; | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,3 +0,3 @@ | ||
import type { GenDescService, GenDescServiceShape } from "./types.js"; | ||
import type { DescFile } from "../desc-types.js"; | ||
import type { GenDescService, GenDescServiceMethods } from "./types.js"; | ||
import type { DescFile } from "../descriptors.js"; | ||
/** | ||
@@ -8,2 +8,2 @@ * Hydrate a service descriptor. | ||
*/ | ||
export declare function serviceDesc<T extends GenDescServiceShape>(file: DescFile, path: number, ...paths: number[]): GenDescService<T>; | ||
export declare function serviceDesc<T extends GenDescServiceMethods>(file: DescFile, path: number, ...paths: number[]): GenDescService<T>; |
import type { Message } from "../types.js"; | ||
import type { DescEnum, DescExtension, DescField, DescFile, DescMessage, DescService } from "../desc-types.js"; | ||
import type { DescEnum, DescExtension, DescField, DescFile, DescMessage, DescMethod, DescService } from "../descriptors.js"; | ||
/** | ||
@@ -46,13 +46,11 @@ * Describes a protobuf source file. | ||
*/ | ||
export type GenDescService<RuntimeShape extends GenDescServiceShape> = DescService & brand<RuntimeShape>; | ||
export type GenDescService<RuntimeShape extends GenDescServiceMethods> = Omit<DescService, "method"> & { | ||
method: { | ||
[K in keyof RuntimeShape]: RuntimeShape[K] & DescMethod; | ||
}; | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
export type GenDescServiceShape = { | ||
[localName: string]: { | ||
kind: "unary" | "server_streaming" | "client_streaming" | "bidi_streaming"; | ||
I: Message; | ||
O: Message; | ||
}; | ||
}; | ||
export type GenDescServiceMethods = Record<string, Pick<DescMethod, "input" | "output" | "methodKind">>; | ||
declare class brand<A, B = unknown> { | ||
@@ -59,0 +57,0 @@ protected a: A | boolean; |
@@ -1,2 +0,2 @@ | ||
import type { DescMessage } from "./desc-types.js"; | ||
import { type DescMessage } from "./descriptors.js"; | ||
import type { MessageInitShape, MessageShape } from "./types.js"; | ||
@@ -3,0 +3,0 @@ /** |
@@ -15,3 +15,4 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
import { isMessage } from "./is-message.js"; | ||
import { LongType, ScalarType, scalarZeroValue } from "./reflect/scalar.js"; | ||
import { ScalarType, } from "./descriptors.js"; | ||
import { scalarZeroValue } from "./reflect/scalar.js"; | ||
import { FieldError } from "./reflect/error.js"; | ||
@@ -222,3 +223,3 @@ import { isObject } from "./reflect/guard.js"; | ||
if (defaultValue !== undefined) { | ||
return field.fieldKind == "scalar" && field.longType == LongType.STRING | ||
return field.fieldKind == "scalar" && field.longAsString | ||
? defaultValue.toString() | ||
@@ -228,4 +229,4 @@ : defaultValue; | ||
return field.fieldKind == "scalar" | ||
? scalarZeroValue(field.scalar, field.longType) | ||
? scalarZeroValue(field.scalar, field.longAsString) | ||
: field.enum.values[0].number; | ||
} |
import type { MessageShape } from "./types.js"; | ||
import type { DescMessage } from "./desc-types.js"; | ||
import type { DescMessage } from "./descriptors.js"; | ||
/** | ||
@@ -4,0 +4,0 @@ * Compare two messages of the same type. |
@@ -1,2 +0,2 @@ | ||
import type { AnyDesc, DescEnum, DescEnumValue, DescExtension, DescField, DescFile, DescMessage, DescMethod, DescOneof, DescService } from "./desc-types.js"; | ||
import type { AnyDesc, DescEnum, DescEnumValue, DescExtension, DescField, DescFile, DescMessage, DescMethod, DescOneof, DescService } from "./descriptors.js"; | ||
import type { ReflectMessage } from "./reflect/reflect-types.js"; | ||
@@ -3,0 +3,0 @@ import type { Extendee, ExtensionValueShape } from "./types.js"; |
@@ -14,3 +14,2 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
// limitations under the License. | ||
import { assert } from "./reflect/assert.js"; | ||
import { create } from "./create.js"; | ||
@@ -150,3 +149,3 @@ import { readField } from "./from-binary.js"; | ||
if (isWrapperDesc(desc)) { | ||
return scalarZeroValue(desc.fields[0].scalar, desc.fields[0].longType); | ||
return scalarZeroValue(desc.fields[0].scalar, desc.fields[0].longAsString); | ||
} | ||
@@ -160,3 +159,5 @@ return create(desc); | ||
function assertExtendee(extension, message) { | ||
assert(extension.extendee.typeName == message.$typeName, `extension ${extension.typeName} can only be applied to message ${extension.extendee.typeName}`); | ||
if (extension.extendee.typeName != message.$typeName) { | ||
throw new Error(`extension ${extension.typeName} can only be applied to message ${extension.extendee.typeName}`); | ||
} | ||
} |
import type { MessageShape } from "./types.js"; | ||
import type { DescField, DescMessage } from "./desc-types.js"; | ||
import type { DescField, DescMessage } from "./descriptors.js"; | ||
/** | ||
@@ -4,0 +4,0 @@ * Returns true if the field is set. |
@@ -1,2 +0,2 @@ | ||
import type { DescField, DescMessage } from "./desc-types.js"; | ||
import { type DescField, type DescMessage } from "./descriptors.js"; | ||
import type { MessageShape } from "./types.js"; | ||
@@ -30,3 +30,3 @@ import type { ReflectMessage } from "./reflect/index.js"; | ||
*/ | ||
export declare function mergeFromBinary<Desc extends DescMessage>(messageDesc: Desc, target: MessageShape<Desc>, bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MessageShape<Desc>; | ||
export declare function mergeFromBinary<Desc extends DescMessage>(messageDesc: Desc, target: MessageShape<Desc>, bytes: Uint8Array, options?: Partial<BinaryReadOptions>): void; | ||
/** | ||
@@ -33,0 +33,0 @@ * @private |
@@ -14,3 +14,4 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
// limitations under the License. | ||
import { LongType, ScalarType, scalarZeroValue } from "./reflect/scalar.js"; | ||
import { ScalarType } from "./descriptors.js"; | ||
import { scalarZeroValue } from "./reflect/scalar.js"; | ||
import { reflect } from "./reflect/reflect.js"; | ||
@@ -44,3 +45,2 @@ import { BinaryReader, WireType } from "./wire/binary-encoding.js"; | ||
readMessage(reflect(messageDesc, target), new BinaryReader(bytes), makeReadOptions(options), false, bytes.byteLength); | ||
return target; | ||
} | ||
@@ -132,3 +132,3 @@ /** | ||
if (key === undefined) { | ||
key = scalarZeroValue(field.mapKey, LongType.BIGINT); | ||
key = scalarZeroValue(field.mapKey, false); | ||
} | ||
@@ -138,3 +138,3 @@ if (val === undefined) { | ||
case "scalar": | ||
val = scalarZeroValue(field.scalar, LongType.BIGINT); | ||
val = scalarZeroValue(field.scalar, false); | ||
break; | ||
@@ -141,0 +141,0 @@ case "enum": |
@@ -1,4 +0,4 @@ | ||
import type { DescMessage } from "./desc-types.js"; | ||
import { type DescMessage } from "./descriptors.js"; | ||
import type { JsonValue } from "./json-value.js"; | ||
import type { Registry } from "./reflect/registry.js"; | ||
import type { Registry } from "./registry.js"; | ||
import type { MessageShape } from "./types.js"; | ||
@@ -34,3 +34,3 @@ /** | ||
*/ | ||
export declare function mergeFromJsonString<Desc extends DescMessage>(messageDesc: Desc, target: MessageShape<Desc>, json: string, options?: Partial<JsonReadOptions>): MessageShape<Desc>; | ||
export declare function mergeFromJsonString<Desc extends DescMessage>(messageDesc: Desc, target: MessageShape<Desc>, json: string, options?: Partial<JsonReadOptions>): void; | ||
/** | ||
@@ -49,2 +49,2 @@ * Parse a message from a JSON value. | ||
*/ | ||
export declare function mergeFromJson<Desc extends DescMessage>(messageDesc: Desc, target: MessageShape<Desc>, json: JsonValue, options?: Partial<JsonReadOptions>): MessageShape<Desc>; | ||
export declare function mergeFromJson<Desc extends DescMessage>(messageDesc: Desc, target: MessageShape<Desc>, json: JsonValue, options?: Partial<JsonReadOptions>): void; |
@@ -14,12 +14,12 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
// limitations under the License. | ||
import { assertFloat32, assertInt32, assertUInt32 } from "./reflect/assert.js"; | ||
/* eslint-disable no-case-declarations,@typescript-eslint/restrict-template-expressions */ | ||
import { ScalarType, } from "./descriptors.js"; | ||
import { protoInt64 } from "./proto-int64.js"; | ||
import { create } from "./create.js"; | ||
import { reflect } from "./reflect/reflect.js"; | ||
import { FieldError, isFieldError } from "./reflect/error.js"; | ||
import { formatVal } from "./reflect/reflect-check.js"; | ||
import { LongType, ScalarType, scalarZeroValue, } from "./reflect/scalar.js"; | ||
import { scalarZeroValue } from "./reflect/scalar.js"; | ||
import { base64Decode } from "./wire/base64-encoding.js"; | ||
import { getTextEncoding } from "./wire/text-encoding.js"; | ||
import { anyPack, ListValueDesc, NullValue, StructDesc, ValueDesc, } from "./wkt/index.js"; | ||
import { isWrapperDesc } from "./wkt/wrappers.js"; | ||
import { isWrapperDesc, anyPack, ListValueDesc, NullValue, StructDesc, ValueDesc, } from "./wkt/index.js"; | ||
import { createExtensionContainer, setExtension } from "./extensions.js"; | ||
@@ -49,3 +49,3 @@ // Default options for parsing JSON. | ||
export function mergeFromJsonString(messageDesc, target, json, options) { | ||
return mergeFromJson(messageDesc, target, parseJsonString(json, messageDesc.typeName), options); | ||
mergeFromJson(messageDesc, target, parseJsonString(json, messageDesc.typeName), options); | ||
} | ||
@@ -57,3 +57,14 @@ /** | ||
const msg = reflect(messageDesc); | ||
readMessage(msg, json, makeReadOptions(options)); | ||
try { | ||
readMessage(msg, json, makeReadOptions(options)); | ||
} | ||
catch (e) { | ||
if (isFieldError(e)) { | ||
// @ts-expect-error we use the ES2022 error CTOR option "cause" for better stack traces | ||
throw new Error(`cannot decode ${e.field()} from JSON: ${e.message}`, { | ||
cause: e, | ||
}); | ||
} | ||
throw e; | ||
} | ||
return msg.message; | ||
@@ -71,4 +82,14 @@ } | ||
export function mergeFromJson(messageDesc, target, json, options) { | ||
readMessage(reflect(messageDesc, target), json, makeReadOptions(options)); | ||
return target; | ||
try { | ||
readMessage(reflect(messageDesc, target), json, makeReadOptions(options)); | ||
} | ||
catch (e) { | ||
if (isFieldError(e)) { | ||
// @ts-expect-error we use the ES2022 error CTOR option "cause" for better stack traces | ||
throw new Error(`cannot decode ${e.field()} from JSON: ${e.message}`, { | ||
cause: e, | ||
}); | ||
} | ||
throw e; | ||
} | ||
} | ||
@@ -81,3 +102,3 @@ function readMessage(msg, json, opts) { | ||
if (json == null || Array.isArray(json) || typeof json != "object") { | ||
throw new Error(`cannot decode message ${msg.desc.typeName} from JSON: ${formatVal(json)}`); | ||
throw new Error(`cannot decode ${msg.desc} from JSON: ${formatVal(json)}`); | ||
} | ||
@@ -99,5 +120,5 @@ const oneofSeen = new Map(); | ||
if (seen !== undefined) { | ||
throw new Error(`cannot decode message ${msg.desc.typeName} from JSON: multiple keys for oneof "${field.oneof.name}" present: "${seen}", "${jsonKey}"`); | ||
throw new FieldError(field.oneof, `oneof set multiple times by ${seen.name} and ${field.name}`); | ||
} | ||
oneofSeen.set(field.oneof, jsonKey); | ||
oneofSeen.set(field.oneof, field); | ||
} | ||
@@ -117,3 +138,3 @@ readField(msg, field, jsonValue, opts); | ||
if (!extension && !opts.ignoreUnknownFields) { | ||
throw new Error(`cannot decode message ${msg.desc.typeName} from JSON: key "${jsonKey}" is unknown`); | ||
throw new Error(`cannot decode ${msg.desc} from JSON: key "${jsonKey}" is unknown`); | ||
} | ||
@@ -147,19 +168,9 @@ } | ||
if (typeof json != "object" || Array.isArray(json)) { | ||
throw new Error(`cannot decode field ${msg.desc.typeName}.${field.name} from JSON: ${formatVal(json)}`); | ||
throw new FieldError(field, "expected object, got " + formatVal(json)); | ||
} | ||
for (const [jsonMapKey, jsonMapValue] of Object.entries(json)) { | ||
if (jsonMapValue === null) { | ||
throw new Error(`cannot decode field ${msg.desc.typeName}.${field.name} from JSON: map value null`); | ||
throw new FieldError(field, "map value must not be null"); | ||
} | ||
let key; | ||
try { | ||
key = readMapKey(field.mapKey, jsonMapKey); | ||
} | ||
catch (e) { | ||
let m = `cannot decode map key for field ${msg.desc.typeName}.${field.name} from JSON: ${formatVal(jsonMapKey)}`; | ||
if (e instanceof Error && e.message.length > 0) { | ||
m += `: ${e.message}`; | ||
} | ||
throw new Error(m); | ||
} | ||
const key = mapKeyFromJson(field.mapKey, jsonMapKey); | ||
switch (field.mapKind) { | ||
@@ -169,3 +180,8 @@ case "message": | ||
readMessage(msgValue, jsonMapValue, opts); | ||
msg.setMapEntry(field, key, msgValue); | ||
// TODO fix types | ||
// @ts-expect-error TODO | ||
const err = msg.setMapEntry(field, key, msgValue); | ||
if (err) { | ||
throw err; | ||
} | ||
break; | ||
@@ -175,16 +191,18 @@ case "enum": | ||
if (enumValue !== tokenIgnoredUnknownEnum) { | ||
msg.setMapEntry(field, key, enumValue); | ||
// TODO fix types | ||
// @ts-expect-error TODO | ||
const err = msg.setMapEntry(field, key, enumValue); | ||
if (err) { | ||
throw err; | ||
} | ||
} | ||
break; | ||
case "scalar": | ||
try { | ||
msg.setMapEntry(field, key, readScalar(field.scalar, jsonMapValue, true)); | ||
const err2 = msg.setMapEntry(field, | ||
// TODO fix types | ||
// @ts-expect-error TODO | ||
key, scalarFromJson(field, jsonMapValue, true)); | ||
if (err2) { | ||
throw err2; | ||
} | ||
catch (e) { | ||
let m = `cannot decode map value for field ${msg.desc.typeName}.${field.name} from JSON: ${formatVal(jsonMapValue)}`; | ||
if (e instanceof Error && e.message.length > 0) { | ||
m += `: ${e.message}`; | ||
} | ||
throw new Error(m); | ||
} | ||
break; | ||
@@ -199,7 +217,7 @@ } | ||
if (!Array.isArray(json)) { | ||
throw new Error(`cannot decode field ${msg.desc.typeName}.${field.name} from JSON: ${formatVal(json)}`); | ||
throw new FieldError(field, "expected Array, got " + formatVal(json)); | ||
} | ||
for (const jsonItem of json) { | ||
if (jsonItem === null) { | ||
throw new Error(`cannot decode field ${msg.desc.typeName}.${field.name} from JSON: ${formatVal(jsonItem)}`); | ||
throw new FieldError(field, "list item must not be null"); | ||
} | ||
@@ -219,12 +237,6 @@ switch (field.listKind) { | ||
case "scalar": | ||
try { | ||
msg.addListItem(field, readScalar(field.scalar, jsonItem, true)); | ||
const err = msg.addListItem(field, scalarFromJson(field, jsonItem, true)); | ||
if (err) { | ||
throw err; | ||
} | ||
catch (e) { | ||
let m = `cannot decode field ${msg.desc.typeName}.${field.name} from JSON: ${formatVal(jsonItem)}`; | ||
if (e instanceof Error && e.message.length > 0) { | ||
m += `: ${e.message}`; | ||
} | ||
throw new Error(m); | ||
} | ||
break; | ||
@@ -253,33 +265,15 @@ } | ||
function readScalarField(msg, field, json) { | ||
try { | ||
const scalarValue = readScalar(field.scalar, json, false); | ||
if (scalarValue === tokenNull) { | ||
msg.clear(field); | ||
} | ||
else { | ||
msg.set(field, scalarValue); | ||
} | ||
const scalarValue = scalarFromJson(field, json, false); | ||
if (scalarValue === tokenNull) { | ||
msg.clear(field); | ||
} | ||
catch (e) { | ||
let m = `cannot decode field ${msg.desc.typeName}.${field.name} from JSON: ${formatVal(json)}`; | ||
if (e instanceof Error && e.message.length > 0) { | ||
m += `: ${e.message}`; | ||
else { | ||
// TODO fix type error | ||
// @ts-expect-error TODO | ||
const err = msg.set(field, scalarValue); | ||
if (err) { | ||
throw err; | ||
} | ||
throw new Error(m); | ||
} | ||
} | ||
function readMapKey(type, json) { | ||
if (type === ScalarType.BOOL) { | ||
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check | ||
switch (json) { | ||
case "true": | ||
json = true; | ||
break; | ||
case "false": | ||
json = false; | ||
break; | ||
} | ||
} | ||
return readScalar(type, json, true); | ||
} | ||
const tokenIgnoredUnknownEnum = Symbol(); | ||
@@ -310,15 +304,16 @@ function readEnum(desc, json, ignoreUnknownFields, nullAsZeroValue) { | ||
} | ||
throw new Error(`cannot decode enum ${desc.typeName} from JSON: ${formatVal(json)}`); | ||
throw new Error(`cannot decode ${desc} from JSON: ${formatVal(json)}`); | ||
} | ||
const tokenNull = Symbol(); | ||
function readScalar(type, json, nullAsZeroValue) { | ||
function scalarFromJson(field, json, nullAsZeroValue) { | ||
if (json === null) { | ||
if (nullAsZeroValue) { | ||
return scalarZeroValue(type, LongType.BIGINT); | ||
return scalarZeroValue(field.scalar, false); | ||
} | ||
return tokenNull; | ||
} | ||
// every valid case in the switch below returns, and every fall | ||
// through is regarded as a failure. | ||
switch (type) { | ||
// int64, sfixed64, sint64, fixed64, uint64: Reflect supports string and number. | ||
// string, bool: Supported by reflect. | ||
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check | ||
switch (field.scalar) { | ||
// float, double: JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity". | ||
@@ -329,3 +324,3 @@ // Either numbers or strings are accepted. Exponent notation is also accepted. | ||
if (json === "NaN") | ||
return Number.NaN; | ||
return NaN; | ||
if (json === "Infinity") | ||
@@ -335,25 +330,30 @@ return Number.POSITIVE_INFINITY; | ||
return Number.NEGATIVE_INFINITY; | ||
if (json === "") { | ||
// empty string is not a number | ||
if (typeof json == "number") { | ||
if (isNaN(json)) { | ||
// NaN must be encoded with string constants | ||
throw new FieldError(field, "unexpected NaN number"); | ||
} | ||
if (!isFinite(json)) { | ||
// Infinity must be encoded with string constants | ||
throw new FieldError(field, "unexpected infinite number"); | ||
} | ||
break; | ||
} | ||
if (typeof json == "string" && json.trim().length !== json.length) { | ||
// extra whitespace | ||
break; | ||
if (typeof json == "string") { | ||
if (json === "") { | ||
// empty string is not a number | ||
break; | ||
} | ||
if (json.trim().length !== json.length) { | ||
// extra whitespace | ||
break; | ||
} | ||
const float = Number(json); | ||
if (!isFinite(float)) { | ||
// Infinity and NaN must be encoded with string constants | ||
break; | ||
} | ||
return float; | ||
} | ||
if (typeof json != "string" && typeof json != "number") { | ||
break; | ||
} | ||
const float = Number(json); | ||
if (Number.isNaN(float)) { | ||
// not a number | ||
break; | ||
} | ||
if (!Number.isFinite(float)) { | ||
// infinity and -infinity are handled by string representation above, so this is an error | ||
break; | ||
} | ||
if (type == ScalarType.FLOAT) | ||
assertFloat32(float); | ||
return float; | ||
break; | ||
// int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted. | ||
@@ -365,54 +365,72 @@ case ScalarType.INT32: | ||
case ScalarType.UINT32: | ||
let int32; | ||
if (typeof json == "number") | ||
int32 = json; | ||
else if (typeof json == "string" && json.length > 0) { | ||
if (json.trim().length === json.length) | ||
int32 = Number(json); | ||
return int32FromJson(json); | ||
// bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings. | ||
// Either standard or URL-safe base64 encoding with/without paddings are accepted. | ||
case ScalarType.BYTES: | ||
if (typeof json == "string") { | ||
if (json === "") { | ||
return new Uint8Array(0); | ||
} | ||
try { | ||
return base64Decode(json); | ||
} | ||
catch (e) { | ||
const message = e instanceof Error ? e.message : String(e); | ||
throw new FieldError(field, message); | ||
} | ||
} | ||
if (int32 === undefined) | ||
break; | ||
if (type == ScalarType.UINT32 || type == ScalarType.FIXED32) | ||
assertUInt32(int32); | ||
else | ||
assertInt32(int32); | ||
return int32; | ||
// int64, fixed64, uint64: JSON value will be a decimal string. Either numbers or strings are accepted. | ||
case ScalarType.INT64: | ||
case ScalarType.SFIXED64: | ||
case ScalarType.SINT64: | ||
if (typeof json != "number" && typeof json != "string") | ||
break; | ||
return protoInt64.parse(json); | ||
case ScalarType.FIXED64: | ||
case ScalarType.UINT64: | ||
if (typeof json != "number" && typeof json != "string") | ||
break; | ||
return protoInt64.uParse(json); | ||
// bool: | ||
break; | ||
} | ||
return json; | ||
} | ||
/** | ||
* Try to parse a JSON value to a map key for the reflect API. | ||
* | ||
* Returns the input if the JSON value cannot be converted. | ||
*/ | ||
function mapKeyFromJson(type, json) { | ||
switch (type) { | ||
case ScalarType.BOOL: | ||
if (typeof json !== "boolean") | ||
break; | ||
return json; | ||
// string: | ||
case ScalarType.STRING: | ||
if (typeof json !== "string") { | ||
break; | ||
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check | ||
switch (json) { | ||
case "true": | ||
return true; | ||
case "false": | ||
return false; | ||
} | ||
// A string must always contain UTF-8 encoded or 7-bit ASCII. | ||
if (!getTextEncoding().checkUtf8(json)) { | ||
throw new Error("invalid UTF8"); | ||
} | ||
return json; | ||
// bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings. | ||
// Either standard or URL-safe base64 encoding with/without paddings are accepted. | ||
case ScalarType.BYTES: | ||
if (json === "") | ||
return new Uint8Array(0); | ||
if (typeof json !== "string") | ||
break; | ||
return base64Decode(json); | ||
case ScalarType.INT32: | ||
case ScalarType.FIXED32: | ||
case ScalarType.UINT32: | ||
case ScalarType.SFIXED32: | ||
case ScalarType.SINT32: | ||
return int32FromJson(json); | ||
default: | ||
return json; | ||
} | ||
throw new Error(); | ||
} | ||
/** | ||
* Try to parse a JSON value to a 32-bit integer for the reflect API. | ||
* | ||
* Returns the input if the JSON value cannot be converted. | ||
*/ | ||
function int32FromJson(json) { | ||
if (typeof json == "string") { | ||
if (json === "") { | ||
// empty string is not a number | ||
return json; | ||
} | ||
if (json.trim().length !== json.length) { | ||
// extra whitespace | ||
return json; | ||
} | ||
const num = Number(json); | ||
if (Number.isNaN(num)) { | ||
// not a number | ||
return json; | ||
} | ||
return num; | ||
} | ||
return json; | ||
} | ||
function parseJsonString(jsonString, typeName) { | ||
@@ -423,3 +441,6 @@ try { | ||
catch (e) { | ||
throw new Error(`cannot decode ${typeName} from JSON: ${e instanceof Error ? e.message : String(e)}`); | ||
const message = e instanceof Error ? e.message : String(e); | ||
throw new Error(`cannot decode message ${typeName} from JSON: ${message}`, | ||
// @ts-expect-error we use the ES2022 error CTOR option "cause" for better stack traces | ||
{ cause: e }); | ||
} | ||
@@ -460,3 +481,6 @@ } | ||
else { | ||
msg.set(valueField, readScalar(valueField.scalar, jsonValue, true)); | ||
const err = msg.set(valueField, scalarFromJson(valueField, jsonValue, true)); | ||
if (err) { | ||
throw err; | ||
} | ||
} | ||
@@ -471,3 +495,3 @@ return true; | ||
if (json === null || Array.isArray(json) || typeof json != "object") { | ||
throw new Error(`cannot decode message ${any.$typeName} from JSON: expected object but got ${json === null ? "null" : Array.isArray(json) ? "array" : typeof json}`); | ||
throw new Error(`cannot decode message ${any.$typeName} from JSON: expected object but got ${formatVal(json)}`); | ||
} | ||
@@ -481,3 +505,9 @@ if (Object.keys(json).length == 0) { | ||
} | ||
const typeName = typeUrlToName(typeUrl), desc = (_a = opts.registry) === null || _a === void 0 ? void 0 : _a.getMessage(typeName); | ||
const typeName = typeUrl.includes("/") | ||
? typeUrl.substring(typeUrl.lastIndexOf("/") + 1) | ||
: typeUrl; | ||
if (!typeName.length) { | ||
throw new Error(`cannot decode message ${any.$typeName} from JSON: "@type" is invalid`); | ||
} | ||
const desc = (_a = opts.registry) === null || _a === void 0 ? void 0 : _a.getMessage(typeName); | ||
if (!desc) { | ||
@@ -501,7 +531,7 @@ throw new Error(`cannot decode message ${any.$typeName} from JSON: ${typeUrl} is not in the type registry`); | ||
if (typeof json !== "string") { | ||
throw new Error(`cannot decode ${timestamp.$typeName} from JSON: ${formatVal(json)}`); | ||
throw new Error(`cannot decode message ${timestamp.$typeName} from JSON: ${formatVal(json)}`); | ||
} | ||
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]))$/); | ||
if (!matches) { | ||
throw new Error(`cannot decode ${timestamp.$typeName} from JSON: invalid RFC 3339 string`); | ||
throw new Error(`cannot decode message ${timestamp.$typeName} from JSON: invalid RFC 3339 string`); | ||
} | ||
@@ -512,3 +542,3 @@ const ms = Date.parse( | ||
if (Number.isNaN(ms)) { | ||
throw new Error(`cannot decode ${timestamp.$typeName} from JSON: invalid RFC 3339 string`); | ||
throw new Error(`cannot decode message ${timestamp.$typeName} from JSON: invalid RFC 3339 string`); | ||
} | ||
@@ -529,11 +559,11 @@ if (ms < Date.parse("0001-01-01T00:00:00Z") || | ||
if (typeof json !== "string") { | ||
throw new Error(`cannot decode ${duration.$typeName} from JSON: ${formatVal(json)}`); | ||
throw new Error(`cannot decode message ${duration.$typeName} from JSON: ${formatVal(json)}`); | ||
} | ||
const match = json.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/); | ||
if (match === null) { | ||
throw new Error(`cannot decode ${duration.$typeName} from JSON: ${formatVal(json)}`); | ||
throw new Error(`cannot decode message ${duration.$typeName} from JSON: ${formatVal(json)}`); | ||
} | ||
const longSeconds = Number(match[1]); | ||
if (longSeconds > 315576000000 || longSeconds < -315576000000) { | ||
throw new Error(`cannot decode ${duration.$typeName} from JSON: ${formatVal(json)}`); | ||
throw new Error(`cannot decode message ${duration.$typeName} from JSON: ${formatVal(json)}`); | ||
} | ||
@@ -552,3 +582,3 @@ duration.seconds = protoInt64.parse(longSeconds); | ||
if (typeof json !== "string") { | ||
throw new Error(`cannot decode ${fieldMask.$typeName} from JSON: ${formatVal(json)}`); | ||
throw new Error(`cannot decode message ${fieldMask.$typeName} from JSON: ${formatVal(json)}`); | ||
} | ||
@@ -560,3 +590,3 @@ if (json === "") { | ||
if (str.includes("_")) { | ||
throw new Error(`cannot decode ${fieldMask.$typeName} from JSON: path names must be lowerCamelCase`); | ||
throw new Error(`cannot decode message ${fieldMask.$typeName} from JSON: path names must be lowerCamelCase`); | ||
} | ||
@@ -570,3 +600,3 @@ const sc = str.replace(/[A-Z]/g, (letter) => "_" + letter.toLowerCase()); | ||
if (typeof json != "object" || json == null || Array.isArray(json)) { | ||
throw new Error(`cannot decode ${struct.$typeName} from JSON ${formatVal(json)}`); | ||
throw new Error(`cannot decode message ${struct.$typeName} from JSON ${formatVal(json)}`); | ||
} | ||
@@ -606,3 +636,3 @@ for (const [k, v] of Object.entries(json)) { | ||
default: | ||
throw new Error(`cannot decode ${value.$typeName} from JSON ${formatVal(json)}`); | ||
throw new Error(`cannot decode message ${value.$typeName} from JSON ${formatVal(json)}`); | ||
} | ||
@@ -613,3 +643,3 @@ return value; | ||
if (!Array.isArray(json)) { | ||
throw new Error(`cannot decode ${listValue.$typeName} from JSON ${formatVal(json)}`); | ||
throw new Error(`cannot decode message ${listValue.$typeName} from JSON ${formatVal(json)}`); | ||
} | ||
@@ -622,12 +652,1 @@ for (const e of json) { | ||
} | ||
function typeUrlToName(url) { | ||
if (!url.length) { | ||
throw new Error(`invalid type url: ${url}`); | ||
} | ||
const slash = url.lastIndexOf("/"); | ||
const name = slash >= 0 ? url.substring(slash + 1) : url; | ||
if (!name.length) { | ||
throw new Error(`invalid type url: ${url}`); | ||
} | ||
return name; | ||
} |
@@ -5,5 +5,6 @@ export * from "./types.js"; | ||
export * from "./clone.js"; | ||
export * from "./desc-types.js"; | ||
export * from "./descriptors.js"; | ||
export * from "./equals.js"; | ||
export * from "./fields.js"; | ||
export * from "./registry.js"; | ||
export type { JsonValue, JsonObject } from "./json-value.js"; | ||
@@ -10,0 +11,0 @@ export { toBinary } from "./to-binary.js"; |
@@ -18,5 +18,6 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
export * from "./clone.js"; | ||
export * from "./desc-types.js"; | ||
export * from "./descriptors.js"; | ||
export * from "./equals.js"; | ||
export * from "./fields.js"; | ||
export * from "./registry.js"; | ||
export { toBinary } from "./to-binary.js"; | ||
@@ -23,0 +24,0 @@ export { fromBinary, mergeFromBinary } from "./from-binary.js"; |
import type { MessageShape } from "./types.js"; | ||
import type { DescMessage } from "./desc-types.js"; | ||
import type { DescMessage } from "./descriptors.js"; | ||
/** | ||
@@ -4,0 +4,0 @@ * Determine whether the given `arg` is a message. |
/** | ||
* Int64Support for the current environment. | ||
*/ | ||
export declare const protoInt64: Int64Support; | ||
/** | ||
* We use the `bigint` primitive to represent 64-bit integral types. If bigint | ||
@@ -94,3 +98,2 @@ * is unavailable, we fall back to a string representation, which means that | ||
} | ||
export declare const protoInt64: Int64Support; | ||
export {}; |
@@ -14,4 +14,7 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
// limitations under the License. | ||
import { assert } from "./reflect/assert.js"; | ||
import { int64FromString, int64ToString, uInt64ToString, } from "./wire/varint.js"; | ||
/** | ||
* Int64Support for the current environment. | ||
*/ | ||
export const protoInt64 = /*@__PURE__*/ makeInt64Support(); | ||
function makeInt64Support() { | ||
@@ -36,3 +39,3 @@ const dv = new DataView(new ArrayBuffer(8)); | ||
if (bi > MAX || bi < MIN) { | ||
throw new Error(`int64 invalid: ${value}`); | ||
throw new Error(`invalid int64: ${value}`); | ||
} | ||
@@ -44,3 +47,3 @@ return bi; | ||
if (bi > UMAX || bi < UMIN) { | ||
throw new Error(`uint64 invalid: ${value}`); | ||
throw new Error(`invalid uint64: ${value}`); | ||
} | ||
@@ -75,4 +78,2 @@ return bi; | ||
} | ||
const assertInt64String = (value) => assert(/^-?[0-9]+$/.test(value), `int64 invalid: ${value}`); | ||
const assertUInt64String = (value) => assert(/^[0-9]+$/.test(value), `uint64 invalid: ${value}`); | ||
return { | ||
@@ -117,2 +118,11 @@ zero: "0", | ||
} | ||
export const protoInt64 = makeInt64Support(); | ||
function assertInt64String(value) { | ||
if (!/^-?[0-9]+$/.test(value)) { | ||
throw new Error("invalid int64: " + value); | ||
} | ||
} | ||
function assertUInt64String(value) { | ||
if (!/^[0-9]+$/.test(value)) { | ||
throw new Error("invalid uint64: " + value); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { DescField, DescOneof } from "../desc-types.js"; | ||
import type { DescField, DescOneof } from "../descriptors.js"; | ||
declare const errorNames: string[]; | ||
@@ -3,0 +3,0 @@ export declare class FieldError extends Error { |
import type { Message } from "../types.js"; | ||
import type { ScalarValue } from "./scalar.js"; | ||
import type { ReflectList, ReflectMap, ReflectMessage } from "./reflect-types.js"; | ||
import type { DescField, DescMessage } from "../desc-types.js"; | ||
import type { DescField, DescMessage } from "../descriptors.js"; | ||
export declare function isObject(arg: unknown): arg is Record<string, unknown>; | ||
@@ -6,0 +6,0 @@ export declare function isOneofADT(arg: unknown): arg is OneofADT; |
@@ -6,4 +6,3 @@ export * from "./error.js"; | ||
export * from "./reflect-types.js"; | ||
export * from "./registry.js"; | ||
export * from "./scalar.js"; | ||
export { isReflectList, isReflectMap, isReflectMessage } from "./guard.js"; |
@@ -19,4 +19,3 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
export * from "./reflect-types.js"; | ||
export * from "./registry.js"; | ||
export * from "./scalar.js"; | ||
export { isReflectList, isReflectMap, isReflectMessage } from "./guard.js"; |
@@ -9,4 +9,4 @@ /** | ||
* | ||
* Also see safeIdentifier() from @bufbuild/protoplugin/ecmascript. | ||
* Also see safeIdentifier() from @bufbuild/protoplugin. | ||
*/ | ||
export declare function safeObjectProperty(name: string): string; |
@@ -65,3 +65,3 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
* | ||
* Also see safeIdentifier() from @bufbuild/protoplugin/ecmascript. | ||
* Also see safeIdentifier() from @bufbuild/protoplugin. | ||
*/ | ||
@@ -68,0 +68,0 @@ export function safeObjectProperty(name) { |
@@ -1,2 +0,2 @@ | ||
import type { AnyDesc, DescEnum, DescExtension, DescFile, DescMessage, DescService } from "../desc-types.js"; | ||
import type { AnyDesc, DescEnum, DescExtension, DescFile, DescMessage, DescService } from "../descriptors.js"; | ||
/** | ||
@@ -3,0 +3,0 @@ * Iterate over all types - enumerations, extensions, services, messages - |
@@ -1,7 +0,16 @@ | ||
import type { DescField } from "../desc-types.js"; | ||
import { type DescField } from "../descriptors.js"; | ||
import { FieldError } from "./error.js"; | ||
/** | ||
* Check whether the given field value is valid for the reflect API. | ||
*/ | ||
export declare function checkField(field: DescField, value: unknown): FieldError | undefined; | ||
/** | ||
* Check whether the given list item is valid for the reflect API. | ||
*/ | ||
export declare function checkListItem(field: DescField & { | ||
fieldKind: "list"; | ||
}, index: number, value: unknown): FieldError | undefined; | ||
/** | ||
* Check whether the given map key and value are valid for the reflect API. | ||
*/ | ||
export declare function checkMapEntry(field: DescField & { | ||
@@ -8,0 +17,0 @@ fieldKind: "map"; |
@@ -14,7 +14,12 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
// limitations under the License. | ||
import { ScalarType, scalarTypeDescription } from "./scalar.js"; | ||
import { checkScalarValue } from "./scalar.js"; | ||
import { ScalarType, } from "../descriptors.js"; | ||
import { isMessage } from "../is-message.js"; | ||
import { FieldError } from "./error.js"; | ||
import { isReflectList, isReflectMap, isReflectMessage } from "./guard.js"; | ||
import { FLOAT32_MAX, FLOAT32_MIN, INT32_MAX, INT32_MIN, UINT32_MAX, } from "../wire/binary-encoding.js"; | ||
import { getTextEncoding } from "../wire/text-encoding.js"; | ||
import { protoInt64 } from "../proto-int64.js"; | ||
/** | ||
* Check whether the given field value is valid for the reflect API. | ||
*/ | ||
export function checkField(field, value) { | ||
@@ -43,2 +48,5 @@ const check = field.fieldKind == "list" | ||
} | ||
/** | ||
* Check whether the given list item is valid for the reflect API. | ||
*/ | ||
export function checkListItem(field, index, value) { | ||
@@ -51,2 +59,5 @@ const check = checkSingular(field, value); | ||
} | ||
/** | ||
* Check whether the given map key and value are valid for the reflect API. | ||
*/ | ||
export function checkMapEntry(field, key, value) { | ||
@@ -75,2 +86,80 @@ const checkKey = checkScalarValue(key, field.mapKey); | ||
} | ||
function checkScalarValue(value, scalar) { | ||
switch (scalar) { | ||
case ScalarType.DOUBLE: | ||
return typeof value == "number"; | ||
case ScalarType.FLOAT: | ||
if (typeof value != "number") { | ||
return false; | ||
} | ||
if (Number.isNaN(value) || !Number.isFinite(value)) { | ||
return true; | ||
} | ||
if (value > FLOAT32_MAX || value < FLOAT32_MIN) { | ||
return `${value.toFixed()} out of range`; | ||
} | ||
return true; | ||
case ScalarType.INT32: | ||
case ScalarType.SFIXED32: | ||
case ScalarType.SINT32: | ||
// signed | ||
if (typeof value !== "number" || !Number.isInteger(value)) { | ||
return false; | ||
} | ||
if (value > INT32_MAX || value < INT32_MIN) { | ||
return `${value.toFixed()} out of range`; | ||
} | ||
return true; | ||
case ScalarType.FIXED32: | ||
case ScalarType.UINT32: | ||
// unsigned | ||
if (typeof value !== "number" || !Number.isInteger(value)) { | ||
return false; | ||
} | ||
if (value > UINT32_MAX || value < 0) { | ||
return `${value.toFixed()} out of range`; | ||
} | ||
return true; | ||
case ScalarType.BOOL: | ||
return typeof value == "boolean"; | ||
case ScalarType.STRING: | ||
if (typeof value != "string") { | ||
return false; | ||
} | ||
return getTextEncoding().checkUtf8(value) || "invalid UTF8"; | ||
case ScalarType.BYTES: | ||
return value instanceof Uint8Array; | ||
case ScalarType.INT64: | ||
case ScalarType.SFIXED64: | ||
case ScalarType.SINT64: | ||
// signed | ||
if (typeof value != "string" && | ||
typeof value !== "bigint" && | ||
typeof value !== "number") { | ||
return false; | ||
} | ||
try { | ||
protoInt64.parse(value); | ||
} | ||
catch (e) { | ||
return `${value} out of range`; | ||
} | ||
return true; | ||
case ScalarType.FIXED64: | ||
case ScalarType.UINT64: | ||
// unsigned | ||
if (typeof value != "string" && | ||
typeof value !== "bigint" && | ||
typeof value !== "number") { | ||
return false; | ||
} | ||
try { | ||
protoInt64.uParse(value); | ||
} | ||
catch (e) { | ||
return `${value} out of range`; | ||
} | ||
return true; | ||
} | ||
} | ||
function reasonSingular(field, val, details) { | ||
@@ -148,1 +237,29 @@ details = | ||
} | ||
function scalarTypeDescription(scalar) { | ||
switch (scalar) { | ||
case ScalarType.STRING: | ||
return "string"; | ||
case ScalarType.BOOL: | ||
return "boolean"; | ||
case ScalarType.INT64: | ||
case ScalarType.SINT64: | ||
case ScalarType.SFIXED64: | ||
return "bigint (int64)"; | ||
case ScalarType.UINT64: | ||
case ScalarType.FIXED64: | ||
return "bigint (uint64)"; | ||
case ScalarType.BYTES: | ||
return "Uint8Array"; | ||
case ScalarType.DOUBLE: | ||
return "number (float64)"; | ||
case ScalarType.FLOAT: | ||
return "number (float32)"; | ||
case ScalarType.FIXED32: | ||
case ScalarType.UINT32: | ||
return "number (uint32)"; | ||
case ScalarType.INT32: | ||
case ScalarType.SFIXED32: | ||
case ScalarType.SINT32: | ||
return "number (int32)"; | ||
} | ||
} |
@@ -1,6 +0,6 @@ | ||
import type { DescField, DescMessage, DescOneof } from "../desc-types.js"; | ||
import { type DescField, type DescMessage, type DescOneof } from "../descriptors.js"; | ||
import { FieldError } from "./error.js"; | ||
import { unsafeLocal } from "./unsafe.js"; | ||
import type { Message, UnknownField } from "../types.js"; | ||
import type { LongType, ScalarValue } from "./scalar.js"; | ||
import type { ScalarValue } from "./scalar.js"; | ||
/** | ||
@@ -233,3 +233,3 @@ * ReflectMessage provides dynamic access and manipulation of a message. | ||
scalar: infer T; | ||
} ? ReflectMap<MapEntryKey, ScalarValue<T, LongType.BIGINT>> : never) : Field extends { | ||
} ? ReflectMap<MapEntryKey, ScalarValue<T>> : never) : Field extends { | ||
fieldKind: "list"; | ||
@@ -284,3 +284,3 @@ } ? ReflectList : Field extends { | ||
scalar: infer T; | ||
} ? ScalarValue<T, LongType.BIGINT> : never); | ||
} ? ScalarValue<T> : never); | ||
export {}; |
@@ -14,3 +14,4 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
// limitations under the License. | ||
import {} from "../descriptors.js"; | ||
import { FieldError } from "./error.js"; | ||
import { unsafeLocal } from "./unsafe.js"; |
@@ -1,2 +0,2 @@ | ||
import type { DescField, DescMessage } from "../desc-types.js"; | ||
import { type DescField, type DescMessage } from "../descriptors.js"; | ||
import type { MessageShape } from "../types.js"; | ||
@@ -3,0 +3,0 @@ import type { MapEntryKey, ReflectList, ReflectMap, ReflectMessage } from "./reflect-types.js"; |
@@ -14,2 +14,3 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
// limitations under the License. | ||
import { ScalarType, } from "../descriptors.js"; | ||
import { checkField, checkListItem, checkMapEntry } from "./reflect-check.js"; | ||
@@ -20,3 +21,3 @@ import { FieldError } from "./error.js"; | ||
import { isWrapper, isWrapperDesc } from "../wkt/wrappers.js"; | ||
import { LongType, ScalarType, scalarZeroValue } from "./scalar.js"; | ||
import { scalarZeroValue } from "./scalar.js"; | ||
import { protoInt64 } from "../proto-int64.js"; | ||
@@ -89,3 +90,3 @@ import { isReflectList, isReflectMap, isReflectMessage } from "./guard.js"; | ||
return (value === undefined | ||
? scalarZeroValue(field.scalar, LongType.BIGINT) | ||
? scalarZeroValue(field.scalar, false) | ||
: longToReflect(field, value)); | ||
@@ -104,3 +105,3 @@ case "enum": | ||
} | ||
let local = value; | ||
let local; | ||
if (isReflectMap(value) || isReflectList(value)) { | ||
@@ -391,4 +392,4 @@ local = value[unsafeLocal]; | ||
case ScalarType.SINT64: | ||
if ("longType" in field && | ||
field.longType == LongType.STRING && | ||
if ("longAsString" in field && | ||
field.longAsString && | ||
typeof value == "string") { | ||
@@ -400,4 +401,4 @@ value = protoInt64.parse(value); | ||
case ScalarType.UINT64: | ||
if ("longType" in field && | ||
field.longType == LongType.STRING && | ||
if ("longAsString" in field && | ||
field.longAsString && | ||
typeof value == "string") { | ||
@@ -416,3 +417,3 @@ value = protoInt64.uParse(value); | ||
case ScalarType.SINT64: | ||
if ("longType" in field && field.longType == LongType.STRING) { | ||
if ("longAsString" in field && field.longAsString) { | ||
value = String(value); | ||
@@ -426,3 +427,3 @@ } | ||
case ScalarType.UINT64: | ||
if ("longType" in field && field.longType == LongType.STRING) { | ||
if ("longAsString" in field && field.longAsString) { | ||
value = String(value); | ||
@@ -429,0 +430,0 @@ } |
@@ -0,54 +1,6 @@ | ||
import { ScalarType } from "../descriptors.js"; | ||
/** | ||
* Scalar value types. This is a subset of field types declared by protobuf | ||
* enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE | ||
* are omitted, but the numerical values are identical. | ||
*/ | ||
export declare enum ScalarType { | ||
DOUBLE = 1, | ||
FLOAT = 2, | ||
INT64 = 3, | ||
UINT64 = 4, | ||
INT32 = 5, | ||
FIXED64 = 6, | ||
FIXED32 = 7, | ||
BOOL = 8, | ||
STRING = 9, | ||
BYTES = 12, | ||
UINT32 = 13, | ||
SFIXED32 = 15, | ||
SFIXED64 = 16, | ||
SINT32 = 17,// Uses ZigZag encoding. | ||
SINT64 = 18 | ||
} | ||
/** | ||
* JavaScript representation of fields with 64 bit integral types (int64, uint64, | ||
* sint64, fixed64, sfixed64). | ||
* | ||
* This is a subset of google.protobuf.FieldOptions.JSType, which defines JS_NORMAL, | ||
* JS_STRING, and JS_NUMBER. Protobuf-ES uses BigInt by default, but will use | ||
* String if `[jstype = JS_STRING]` is specified. | ||
* | ||
* ```protobuf | ||
* uint64 field_a = 1; // BigInt | ||
* uint64 field_b = 2 [jstype = JS_NORMAL]; // BigInt | ||
* uint64 field_b = 2 [jstype = JS_NUMBER]; // BigInt | ||
* uint64 field_b = 2 [jstype = JS_STRING]; // String | ||
* ``` | ||
*/ | ||
export declare enum LongType { | ||
/** | ||
* Use JavaScript BigInt. | ||
*/ | ||
BIGINT = 0, | ||
/** | ||
* Use JavaScript String. | ||
* | ||
* Field option `[jstype = JS_STRING]`. | ||
*/ | ||
STRING = 1 | ||
} | ||
/** | ||
* ScalarValue maps from a scalar field type to a TypeScript value type. | ||
*/ | ||
export type ScalarValue<T = ScalarType, L extends LongType = LongType.STRING | LongType.BIGINT> = T extends ScalarType.STRING ? string : T extends ScalarType.INT32 ? number : T extends ScalarType.UINT32 ? number : T extends ScalarType.UINT32 ? number : T extends ScalarType.SINT32 ? number : T extends ScalarType.FIXED32 ? number : T extends ScalarType.SFIXED32 ? number : T extends ScalarType.FLOAT ? number : T extends ScalarType.DOUBLE ? number : T extends ScalarType.INT64 ? L extends LongType.STRING ? string : bigint : T extends ScalarType.SINT64 ? L extends LongType.STRING ? string : bigint : T extends ScalarType.SFIXED64 ? L extends LongType.STRING ? string : bigint : T extends ScalarType.UINT64 ? L extends LongType.STRING ? string : bigint : T extends ScalarType.FIXED64 ? L extends LongType.STRING ? string : bigint : T extends ScalarType.BOOL ? boolean : T extends ScalarType.BYTES ? Uint8Array : never; | ||
export type ScalarValue<T = ScalarType, LongAsString extends boolean = false> = T extends ScalarType.STRING ? string : T extends ScalarType.INT32 ? number : T extends ScalarType.UINT32 ? number : T extends ScalarType.SINT32 ? number : T extends ScalarType.FIXED32 ? number : T extends ScalarType.SFIXED32 ? number : T extends ScalarType.FLOAT ? number : T extends ScalarType.DOUBLE ? number : T extends ScalarType.INT64 ? LongAsString extends true ? string : bigint : T extends ScalarType.SINT64 ? LongAsString extends true ? string : bigint : T extends ScalarType.SFIXED64 ? LongAsString extends true ? string : bigint : T extends ScalarType.UINT64 ? LongAsString extends true ? string : bigint : T extends ScalarType.FIXED64 ? LongAsString extends true ? string : bigint : T extends ScalarType.BOOL ? boolean : T extends ScalarType.BYTES ? Uint8Array : never; | ||
/** | ||
@@ -61,3 +13,3 @@ * Returns true if both scalar values are equal. | ||
*/ | ||
export declare function scalarZeroValue<T extends ScalarType, L extends LongType>(type: T, longType: L): ScalarValue<T, L>; | ||
export declare function scalarZeroValue<T extends ScalarType, LongAsString extends boolean>(type: T, longAsString: LongAsString): ScalarValue<T, LongAsString>; | ||
/** | ||
@@ -71,5 +23,1 @@ * Returns true for a zero-value. For example, an integer has the zero-value `0`, | ||
export declare function isScalarZeroValue(type: ScalarType, value: unknown): boolean; | ||
export type InvalidScalarValueErr = false | "invalid UTF8" | `${string} out of range`; | ||
export declare function checkScalarValue(value: unknown, scalar: ScalarType): true | InvalidScalarValueErr; | ||
export declare function scalarTypeDescription(scalar: ScalarType): string; | ||
export declare function scalarTypeScriptType(scalar: ScalarType, long: LongType): "string" | "boolean" | "bigint" | "bigint | string" | "Uint8Array" | "number"; |
@@ -15,69 +15,4 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
import { protoInt64 } from "../proto-int64.js"; | ||
import { getTextEncoding } from "../wire/text-encoding.js"; | ||
import { ScalarType } from "../descriptors.js"; | ||
/** | ||
* Scalar value types. This is a subset of field types declared by protobuf | ||
* enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE | ||
* are omitted, but the numerical values are identical. | ||
*/ | ||
export var ScalarType; | ||
(function (ScalarType) { | ||
// 0 is reserved for errors. | ||
// Order is weird for historical reasons. | ||
ScalarType[ScalarType["DOUBLE"] = 1] = "DOUBLE"; | ||
ScalarType[ScalarType["FLOAT"] = 2] = "FLOAT"; | ||
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if | ||
// negative values are likely. | ||
ScalarType[ScalarType["INT64"] = 3] = "INT64"; | ||
ScalarType[ScalarType["UINT64"] = 4] = "UINT64"; | ||
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if | ||
// negative values are likely. | ||
ScalarType[ScalarType["INT32"] = 5] = "INT32"; | ||
ScalarType[ScalarType["FIXED64"] = 6] = "FIXED64"; | ||
ScalarType[ScalarType["FIXED32"] = 7] = "FIXED32"; | ||
ScalarType[ScalarType["BOOL"] = 8] = "BOOL"; | ||
ScalarType[ScalarType["STRING"] = 9] = "STRING"; | ||
// Tag-delimited aggregate. | ||
// Group type is deprecated and not supported in proto3. However, Proto3 | ||
// implementations should still be able to parse the group wire format and | ||
// treat group fields as unknown fields. | ||
// TYPE_GROUP = 10, | ||
// TYPE_MESSAGE = 11, // Length-delimited aggregate. | ||
// New in version 2. | ||
ScalarType[ScalarType["BYTES"] = 12] = "BYTES"; | ||
ScalarType[ScalarType["UINT32"] = 13] = "UINT32"; | ||
// TYPE_ENUM = 14, | ||
ScalarType[ScalarType["SFIXED32"] = 15] = "SFIXED32"; | ||
ScalarType[ScalarType["SFIXED64"] = 16] = "SFIXED64"; | ||
ScalarType[ScalarType["SINT32"] = 17] = "SINT32"; | ||
ScalarType[ScalarType["SINT64"] = 18] = "SINT64"; | ||
})(ScalarType || (ScalarType = {})); | ||
/** | ||
* JavaScript representation of fields with 64 bit integral types (int64, uint64, | ||
* sint64, fixed64, sfixed64). | ||
* | ||
* This is a subset of google.protobuf.FieldOptions.JSType, which defines JS_NORMAL, | ||
* JS_STRING, and JS_NUMBER. Protobuf-ES uses BigInt by default, but will use | ||
* String if `[jstype = JS_STRING]` is specified. | ||
* | ||
* ```protobuf | ||
* uint64 field_a = 1; // BigInt | ||
* uint64 field_b = 2 [jstype = JS_NORMAL]; // BigInt | ||
* uint64 field_b = 2 [jstype = JS_NUMBER]; // BigInt | ||
* uint64 field_b = 2 [jstype = JS_STRING]; // String | ||
* ``` | ||
*/ | ||
export var LongType; | ||
(function (LongType) { | ||
/** | ||
* Use JavaScript BigInt. | ||
*/ | ||
LongType[LongType["BIGINT"] = 0] = "BIGINT"; | ||
/** | ||
* Use JavaScript String. | ||
* | ||
* Field option `[jstype = JS_STRING]`. | ||
*/ | ||
LongType[LongType["STRING"] = 1] = "STRING"; | ||
})(LongType || (LongType = {})); | ||
/** | ||
* Returns true if both scalar values are equal. | ||
@@ -123,23 +58,23 @@ */ | ||
*/ | ||
export function scalarZeroValue(type, longType) { | ||
export function scalarZeroValue(type, longAsString) { | ||
switch (type) { | ||
case ScalarType.STRING: | ||
return ""; | ||
case ScalarType.BOOL: | ||
return false; | ||
default: | ||
// Handles INT32, UINT32, SINT32, FIXED32, SFIXED32. | ||
// We do not use individual cases to save a few bytes code size. | ||
return 0; | ||
case ScalarType.DOUBLE: | ||
case ScalarType.FLOAT: | ||
return 0.0; | ||
case ScalarType.INT64: | ||
case ScalarType.UINT64: | ||
case ScalarType.SFIXED64: | ||
case ScalarType.FIXED64: | ||
case ScalarType.INT64: | ||
case ScalarType.SFIXED64: | ||
case ScalarType.SINT64: | ||
return (longType == 0 ? protoInt64.zero : "0"); | ||
case ScalarType.DOUBLE: | ||
case ScalarType.FLOAT: | ||
return 0.0; | ||
return (longAsString ? "0" : protoInt64.zero); | ||
case ScalarType.BYTES: | ||
return new Uint8Array(0); | ||
case ScalarType.STRING: | ||
return ""; | ||
default: | ||
// Handles INT32, UINT32, SINT32, FIXED32, SFIXED32. | ||
// We do not use individual cases to save a few bytes code size. | ||
return 0; | ||
} | ||
@@ -166,127 +101,1 @@ } | ||
} | ||
const FLOAT32_MAX = 3.4028234663852886e38, FLOAT32_MIN = -3.4028234663852886e38, UINT32_MAX = 0xffffffff, INT32_MAX = 0x7fffffff, INT32_MIN = -0x80000000; | ||
// TODO this checks UTF-8 validity | ||
export function checkScalarValue(value, scalar) { | ||
switch (scalar) { | ||
case ScalarType.DOUBLE: | ||
return typeof value == "number"; | ||
case ScalarType.FLOAT: | ||
if (typeof value != "number") { | ||
return false; | ||
} | ||
if (Number.isNaN(value) || !Number.isFinite(value)) { | ||
return true; | ||
} | ||
if (value > FLOAT32_MAX || value < FLOAT32_MIN) { | ||
return `${value.toFixed()} out of range`; | ||
} | ||
return true; | ||
case ScalarType.INT32: | ||
case ScalarType.SFIXED32: | ||
case ScalarType.SINT32: | ||
// signed | ||
if (typeof value !== "number" || !Number.isInteger(value)) { | ||
return false; | ||
} | ||
if (value > INT32_MAX || value < INT32_MIN) { | ||
return `${value.toFixed()} out of range`; | ||
} | ||
return true; | ||
case ScalarType.FIXED32: | ||
case ScalarType.UINT32: | ||
// unsigned | ||
if (typeof value !== "number" || !Number.isInteger(value)) { | ||
return false; | ||
} | ||
if (value > UINT32_MAX || value < 0) { | ||
return `${value.toFixed()} out of range`; | ||
} | ||
return true; | ||
case ScalarType.BOOL: | ||
return typeof value == "boolean"; | ||
case ScalarType.STRING: | ||
if (typeof value != "string") { | ||
return false; | ||
} | ||
return getTextEncoding().checkUtf8(value) || "invalid UTF8"; | ||
case ScalarType.BYTES: | ||
return value instanceof Uint8Array; | ||
case ScalarType.INT64: | ||
case ScalarType.SFIXED64: | ||
case ScalarType.SINT64: | ||
// signed | ||
if (typeof value != "string" && | ||
typeof value !== "bigint" && | ||
typeof value !== "number") { | ||
return false; | ||
} | ||
try { | ||
protoInt64.parse(value); | ||
} | ||
catch (e) { | ||
return `${value} out of range`; | ||
} | ||
return true; | ||
case ScalarType.FIXED64: | ||
case ScalarType.UINT64: | ||
// unsigned | ||
if (typeof value != "string" && | ||
typeof value !== "bigint" && | ||
typeof value !== "number") { | ||
return false; | ||
} | ||
try { | ||
protoInt64.uParse(value); | ||
} | ||
catch (e) { | ||
return `${value} out of range`; | ||
} | ||
return true; | ||
} | ||
} | ||
export function scalarTypeDescription(scalar) { | ||
switch (scalar) { | ||
case ScalarType.STRING: | ||
return "string"; | ||
case ScalarType.BOOL: | ||
return "boolean"; | ||
case ScalarType.INT64: | ||
case ScalarType.SINT64: | ||
case ScalarType.SFIXED64: | ||
return "bigint (int64)"; | ||
case ScalarType.UINT64: | ||
case ScalarType.FIXED64: | ||
return "bigint (uint64)"; | ||
case ScalarType.BYTES: | ||
return "Uint8Array"; | ||
case ScalarType.DOUBLE: | ||
return "number (float64)"; | ||
case ScalarType.FLOAT: | ||
return "number (float32)"; | ||
case ScalarType.FIXED32: | ||
case ScalarType.UINT32: | ||
return "number (uint32)"; | ||
case ScalarType.INT32: | ||
case ScalarType.SFIXED32: | ||
case ScalarType.SINT32: | ||
return "number (int32)"; | ||
} | ||
} | ||
export function scalarTypeScriptType(scalar, long) { | ||
switch (scalar) { | ||
case ScalarType.STRING: | ||
return "string"; | ||
case ScalarType.BOOL: | ||
return "boolean"; | ||
case ScalarType.UINT64: | ||
case ScalarType.SFIXED64: | ||
case ScalarType.FIXED64: | ||
case ScalarType.SINT64: | ||
case ScalarType.INT64: | ||
return long == LongType.STRING ? "string" : "bigint"; | ||
case ScalarType.BYTES: | ||
return "Uint8Array"; | ||
default: | ||
return "number"; | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { DescField, DescOneof } from "../desc-types.js"; | ||
import type { DescField, DescOneof } from "../descriptors.js"; | ||
export declare const unsafeLocal: unique symbol; | ||
@@ -3,0 +3,0 @@ /** |
@@ -135,3 +135,3 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
case "scalar": | ||
target[name] = scalarZeroValue(field.scalar, field.longType); | ||
target[name] = scalarZeroValue(field.scalar, field.longAsString); | ||
break; | ||
@@ -138,0 +138,0 @@ } |
import type { MessageShape } from "./types.js"; | ||
import { BinaryWriter } from "./wire/binary-encoding.js"; | ||
import type { DescField, DescMessage } from "./desc-types.js"; | ||
import { type DescField, type DescMessage } from "./descriptors.js"; | ||
import type { ReflectMessage } from "./reflect/index.js"; | ||
@@ -5,0 +5,0 @@ /** |
@@ -16,3 +16,3 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
import { BinaryWriter, WireType } from "./wire/binary-encoding.js"; | ||
import { ScalarType } from "./reflect/scalar.js"; | ||
import { ScalarType } from "./descriptors.js"; | ||
// bootstrap-inject google.protobuf.FeatureSet.FieldPresence.LEGACY_REQUIRED: const $name: FeatureSet_FieldPresence.$localName = $number; | ||
@@ -19,0 +19,0 @@ const LEGACY_REQUIRED = 3; |
@@ -1,4 +0,4 @@ | ||
import type { DescMessage } from "./desc-types.js"; | ||
import { type DescMessage } from "./descriptors.js"; | ||
import type { JsonValue } from "./json-value.js"; | ||
import type { Registry } from "./reflect/registry.js"; | ||
import type { Registry } from "./registry.js"; | ||
import type { MessageShape } from "./types.js"; | ||
@@ -10,7 +10,8 @@ /** | ||
/** | ||
* Emit fields with default values: Fields with default values are omitted | ||
* by default in proto3 JSON output. This option overrides this behavior | ||
* and outputs fields with their default values. | ||
* By default, fields with implicit presence are not serialized if they are | ||
* unset. For example, an empty list field or a proto3 int32 field with 0 is | ||
* not serialized. With this option enabled, such fields are included in the | ||
* output. | ||
*/ | ||
emitDefaultValues: boolean; | ||
alwaysEmitImplicit: boolean; | ||
/** | ||
@@ -17,0 +18,0 @@ * Emit enum values as integers instead of strings: The name of an enum |
@@ -14,6 +14,5 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
// limitations under the License. | ||
import { assert } from "./reflect/assert.js"; | ||
import { ScalarType, } from "./descriptors.js"; | ||
import { protoCamelCase } from "./reflect/names.js"; | ||
import { reflect } from "./reflect/reflect.js"; | ||
import { ScalarType } from "./reflect/scalar.js"; | ||
import { anyUnpack } from "./wkt/index.js"; | ||
@@ -23,2 +22,4 @@ import { isWrapperDesc } from "./wkt/wrappers.js"; | ||
import { createExtensionContainer, getExtension } from "./extensions.js"; | ||
import { checkField, formatVal } from "./reflect/reflect-check.js"; | ||
/* eslint-disable @typescript-eslint/restrict-template-expressions */ | ||
// bootstrap-inject google.protobuf.FeatureSet.FieldPresence.LEGACY_REQUIRED: const $name: FeatureSet_FieldPresence.$localName = $number; | ||
@@ -30,3 +31,3 @@ const LEGACY_REQUIRED = 3; | ||
const jsonWriteDefaults = { | ||
emitDefaultValues: false, | ||
alwaysEmitImplicit: false, | ||
enumAsInteger: false, | ||
@@ -62,5 +63,5 @@ useProtoFieldName: false, | ||
if (f.presence == LEGACY_REQUIRED) { | ||
throw new Error(`cannot encode field ${msg.desc.typeName}.${f.name} to binary: required field not set`); | ||
throw new Error(`cannot encode field ${msg.desc.typeName}.${f.name} to JSON: required field not set`); | ||
} | ||
if (!opts.emitDefaultValues || f.presence !== IMPLICIT) { | ||
if (!opts.alwaysEmitImplicit || f.presence !== IMPLICIT) { | ||
// Fields with implicit presence omit zero values (e.g. empty string) by default | ||
@@ -100,3 +101,3 @@ continue; | ||
case "scalar": | ||
return scalarToJson(f.scalar, val); | ||
return scalarToJson(f, val); | ||
case "message": | ||
@@ -118,3 +119,3 @@ return reflectToJson(val, opts); | ||
for (const [entryKey, entryValue] of map) { | ||
jsonObj[entryKey.toString()] = scalarToJson(f.scalar, entryValue); // JSON standard allows only (double quoted) string as property key | ||
jsonObj[entryKey.toString()] = scalarToJson(f, entryValue); // JSON standard allows only (double quoted) string as property key | ||
} | ||
@@ -135,3 +136,3 @@ break; | ||
} | ||
return opts.emitDefaultValues || map.size > 0 ? jsonObj : undefined; | ||
return opts.alwaysEmitImplicit || map.size > 0 ? jsonObj : undefined; | ||
} | ||
@@ -144,3 +145,3 @@ function listToJson(list, opts) { | ||
for (const item of list) { | ||
jsonArr.push(scalarToJson(f.scalar, item)); | ||
jsonArr.push(scalarToJson(f, item)); | ||
} | ||
@@ -159,7 +160,9 @@ break; | ||
} | ||
return opts.emitDefaultValues || jsonArr.length > 0 ? jsonArr : undefined; | ||
return opts.alwaysEmitImplicit || jsonArr.length > 0 ? jsonArr : undefined; | ||
} | ||
function enumToJson(desc, value, enumAsInteger) { | ||
var _a; | ||
assert(typeof value == "number"); | ||
if (typeof value != "number") { | ||
throw new Error(`cannot encode ${desc} to JSON: expected number, got ${formatVal(value)}`); | ||
} | ||
if (desc.typeName == "google.protobuf.NullValue") { | ||
@@ -174,4 +177,5 @@ return null; | ||
} | ||
function scalarToJson(type, value) { | ||
switch (type) { | ||
function scalarToJson(field, value) { | ||
var _a, _b, _c, _d, _e, _f; | ||
switch (field.scalar) { | ||
// int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted. | ||
@@ -183,3 +187,5 @@ case ScalarType.INT32: | ||
case ScalarType.UINT32: | ||
assert(typeof value == "number"); | ||
if (typeof value != "number") { | ||
throw new Error(`cannot encode ${field} to JSON: ${(_a = checkField(field, value)) === null || _a === void 0 ? void 0 : _a.message}`); | ||
} | ||
return value; | ||
@@ -189,6 +195,7 @@ // float, double: JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity". | ||
case ScalarType.FLOAT: | ||
// assertFloat32(value); | ||
case ScalarType.DOUBLE: // eslint-disable-line no-fallthrough | ||
assert(typeof value == "number"); | ||
if (Number.isNaN(value)) | ||
if (typeof value != "number") { | ||
throw new Error(`cannot encode ${field} to JSON: ${(_b = checkField(field, value)) === null || _b === void 0 ? void 0 : _b.message}`); | ||
} | ||
if (isNaN(value)) | ||
return "NaN"; | ||
@@ -202,7 +209,11 @@ if (value === Number.POSITIVE_INFINITY) | ||
case ScalarType.STRING: | ||
assert(typeof value == "string"); | ||
if (typeof value != "string") { | ||
throw new Error(`cannot encode ${field} to JSON: ${(_c = checkField(field, value)) === null || _c === void 0 ? void 0 : _c.message}`); | ||
} | ||
return value; | ||
// bool: | ||
case ScalarType.BOOL: | ||
assert(typeof value == "boolean"); | ||
if (typeof value != "boolean") { | ||
throw new Error(`cannot encode ${field} to JSON: ${(_d = checkField(field, value)) === null || _d === void 0 ? void 0 : _d.message}`); | ||
} | ||
return value; | ||
@@ -215,5 +226,5 @@ // JSON value will be a decimal string. Either numbers or strings are accepted. | ||
case ScalarType.SINT64: | ||
assert(typeof value == "bigint" || | ||
typeof value == "string" || | ||
typeof value == "number"); | ||
if (typeof value != "bigint" && typeof value != "string") { | ||
throw new Error(`cannot encode ${field} to JSON: ${(_e = checkField(field, value)) === null || _e === void 0 ? void 0 : _e.message}`); | ||
} | ||
return value.toString(); | ||
@@ -223,4 +234,6 @@ // bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings. | ||
case ScalarType.BYTES: | ||
assert(value instanceof Uint8Array); | ||
return base64Encode(value); | ||
if (value instanceof Uint8Array) { | ||
return base64Encode(value); | ||
} | ||
throw new Error(`cannot encode ${field} to JSON: ${(_f = checkField(field, value)) === null || _f === void 0 ? void 0 : _f.message}`); | ||
} | ||
@@ -254,3 +267,3 @@ } | ||
const valueField = msg.desc.fields[0]; | ||
return scalarToJson(valueField.scalar, msg.get(valueField)); | ||
return scalarToJson(valueField, msg.get(valueField)); | ||
} | ||
@@ -289,3 +302,3 @@ return undefined; | ||
Number(val.seconds) < -315576000000) { | ||
throw new Error(`cannot encode ${val.$typeName} to JSON: value out of range`); | ||
throw new Error(`cannot encode message ${val.$typeName} to JSON: value out of range`); | ||
} | ||
@@ -314,3 +327,3 @@ let text = val.seconds.toString(); | ||
if (p.match(/_[0-9]?_/g) || p.match(/[A-Z]/g)) { | ||
throw new Error(`cannot encode ${val.$typeName} to JSON: lowerCamelCase of path name "` + | ||
throw new Error(`cannot encode message ${val.$typeName} to JSON: lowerCamelCase of path name "` + | ||
p + | ||
@@ -358,6 +371,6 @@ '" is irreversible'); | ||
ms > Date.parse("9999-12-31T23:59:59Z")) { | ||
throw new Error(`cannot encode ${val.$typeName} to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`); | ||
throw new Error(`cannot encode message ${val.$typeName} to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`); | ||
} | ||
if (val.nanos < 0) { | ||
throw new Error(`cannot encode ${val.$typeName} to JSON: nanos must not be negative`); | ||
throw new Error(`cannot encode message ${val.$typeName} to JSON: nanos must not be negative`); | ||
} | ||
@@ -364,0 +377,0 @@ let z = "Z"; |
import type { GenDescEnum, GenDescExtension, GenDescMessage } from "./codegenv1/types.js"; | ||
import type { DescEnum, DescExtension, DescMessage } from "./desc-types.js"; | ||
import type { DescEnum, DescExtension, DescMessage } from "./descriptors.js"; | ||
import type { OneofADT } from "./reflect/guard.js"; | ||
@@ -4,0 +4,0 @@ import type { WireType } from "./wire/index.js"; |
@@ -52,3 +52,3 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
default: | ||
throw Error("invalid base64 string."); | ||
throw Error("invalid base64 string"); | ||
} | ||
@@ -78,3 +78,3 @@ } | ||
if (groupPos == 1) | ||
throw Error("invalid base64 string."); | ||
throw Error("invalid base64 string"); | ||
return bytes.subarray(0, bytePos); | ||
@@ -81,0 +81,0 @@ } |
@@ -42,2 +42,22 @@ /** | ||
} | ||
/** | ||
* Maximum value for a 32-bit floating point value (Protobuf FLOAT). | ||
*/ | ||
export declare const FLOAT32_MAX = 3.4028234663852886e+38; | ||
/** | ||
* Minimum value for a 32-bit floating point value (Protobuf FLOAT). | ||
*/ | ||
export declare const FLOAT32_MIN = -3.4028234663852886e+38; | ||
/** | ||
* Maximum value for an unsigned 32-bit integer (Protobuf UINT32, FIXED32). | ||
*/ | ||
export declare const UINT32_MAX = 4294967295; | ||
/** | ||
* Maximum value for a signed 32-bit integer (Protobuf INT32, SFIXED32, SINT32). | ||
*/ | ||
export declare const INT32_MAX = 2147483647; | ||
/** | ||
* Minimum value for a signed 32-bit integer (Protobuf INT32, SFIXED32, SINT32). | ||
*/ | ||
export declare const INT32_MIN = -2147483648; | ||
export declare class BinaryWriter { | ||
@@ -44,0 +64,0 @@ private readonly encodeUtf8; |
@@ -15,3 +15,2 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
import { varint32read, varint32write, varint64read, varint64write, } from "./varint.js"; | ||
import { assertFloat32, assertInt32, assertUInt32 } from "../reflect/assert.js"; | ||
import { protoInt64 } from "../proto-int64.js"; | ||
@@ -62,2 +61,22 @@ import { getTextEncoding } from "./text-encoding.js"; | ||
})(WireType || (WireType = {})); | ||
/** | ||
* Maximum value for a 32-bit floating point value (Protobuf FLOAT). | ||
*/ | ||
export const FLOAT32_MAX = 3.4028234663852886e38; | ||
/** | ||
* Minimum value for a 32-bit floating point value (Protobuf FLOAT). | ||
*/ | ||
export const FLOAT32_MIN = -3.4028234663852886e38; | ||
/** | ||
* Maximum value for an unsigned 32-bit integer (Protobuf UINT32, FIXED32). | ||
*/ | ||
export const UINT32_MAX = 0xffffffff; | ||
/** | ||
* Maximum value for a signed 32-bit integer (Protobuf INT32, SFIXED32, SINT32). | ||
*/ | ||
export const INT32_MAX = 0x7fffffff; | ||
/** | ||
* Minimum value for a signed 32-bit integer (Protobuf INT32, SFIXED32, SINT32). | ||
*/ | ||
export const INT32_MIN = -0x80000000; | ||
export class BinaryWriter { | ||
@@ -442,1 +461,28 @@ constructor(encodeUtf8 = getTextEncoding().encodeUtf8) { | ||
} | ||
/** | ||
* Assert a valid signed protobuf 32-bit integer. | ||
*/ | ||
function assertInt32(arg) { | ||
if (typeof arg !== "number") | ||
throw new Error("invalid int32: " + typeof arg); | ||
if (!Number.isInteger(arg) || arg > INT32_MAX || arg < INT32_MIN) | ||
throw new Error("invalid int32: " + arg); | ||
} | ||
/** | ||
* Assert a valid unsigned protobuf 32-bit integer. | ||
*/ | ||
function assertUInt32(arg) { | ||
if (typeof arg !== "number") | ||
throw new Error("invalid uint32: " + typeof arg); | ||
if (!Number.isInteger(arg) || arg > UINT32_MAX || arg < 0) | ||
throw new Error("invalid uint32: " + arg); | ||
} | ||
/** | ||
* Assert a valid protobuf float value. | ||
*/ | ||
function assertFloat32(arg) { | ||
if (typeof arg !== "number") | ||
throw new Error("invalid float32: " + typeof arg); | ||
if (Number.isFinite(arg) && (arg > FLOAT32_MAX || arg < FLOAT32_MIN)) | ||
throw new Error("invalid float32: " + arg); | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { DescMessage } from "../desc-types.js"; | ||
import type { DescMessage } from "../descriptors.js"; | ||
import type { BinaryWriteOptions } from "../to-binary.js"; | ||
@@ -3,0 +3,0 @@ import type { MessageShape } from "../types.js"; |
@@ -1,3 +0,2 @@ | ||
import type { DescEnum } from "../desc-types.js"; | ||
import { ScalarType } from "../reflect/scalar.js"; | ||
import { type DescEnum, ScalarType } from "../descriptors.js"; | ||
/** | ||
@@ -4,0 +3,0 @@ * Parse an enum value from the Protobuf text format. |
@@ -14,5 +14,5 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
// limitations under the License. | ||
import { assert } from "../reflect/assert.js"; | ||
import { ScalarType } from "../descriptors.js"; | ||
import { protoInt64 } from "../proto-int64.js"; | ||
import { ScalarType } from "../reflect/scalar.js"; | ||
/* eslint-disable @typescript-eslint/restrict-template-expressions */ | ||
/** | ||
@@ -25,3 +25,5 @@ * Parse an enum value from the Protobuf text format. | ||
const enumValue = descEnum.values.find((v) => v.name === value); | ||
assert(enumValue, `cannot parse ${descEnum.name} default value: ${value}`); | ||
if (!enumValue) { | ||
throw new Error(`cannot parse ${descEnum} default value: ${value}`); | ||
} | ||
return enumValue.number; | ||
@@ -28,0 +30,0 @@ } |
import type { Message, MessageShape } from "../types.js"; | ||
import type { Any } from "./gen/google/protobuf/any_pb.js"; | ||
import type { DescMessage } from "../desc-types.js"; | ||
import type { Registry } from "../reflect/index.js"; | ||
import type { DescMessage } from "../descriptors.js"; | ||
import type { Registry } from "../registry.js"; | ||
/** | ||
@@ -38,2 +38,2 @@ * Creates a `google.protobuf.Any` from a message. | ||
*/ | ||
export declare function anyUnpackTo<Desc extends DescMessage>(any: Any, messageDesc: Desc, message: MessageShape<Desc>): MessageShape<Desc> | undefined; | ||
export declare function anyUnpackTo<Desc extends DescMessage>(any: Any, messageDesc: Desc, message: MessageShape<Desc>): void; |
@@ -20,3 +20,3 @@ // Copyright 2021-2024 Buf Technologies, Inc. | ||
*/ | ||
export const fileDesc_google_protobuf_descriptor = /*@__PURE__*/ boot({ "name": "google/protobuf/descriptor.proto", "package": "google.protobuf", "messageType": [{ "name": "FileDescriptorSet", "field": [{ "name": "file", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.FileDescriptorProto" }] }, { "name": "FileDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "package", "number": 2, "type": 9, "label": 1 }, { "name": "dependency", "number": 3, "type": 9, "label": 3 }, { "name": "public_dependency", "number": 10, "type": 5, "label": 3 }, { "name": "weak_dependency", "number": 11, "type": 5, "label": 3 }, { "name": "message_type", "number": 4, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto" }, { "name": "enum_type", "number": 5, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumDescriptorProto" }, { "name": "service", "number": 6, "type": 11, "label": 3, "typeName": ".google.protobuf.ServiceDescriptorProto" }, { "name": "extension", "number": 7, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldDescriptorProto" }, { "name": "options", "number": 8, "type": 11, "label": 1, "typeName": ".google.protobuf.FileOptions" }, { "name": "source_code_info", "number": 9, "type": 11, "label": 1, "typeName": ".google.protobuf.SourceCodeInfo" }, { "name": "syntax", "number": 12, "type": 9, "label": 1 }, { "name": "edition", "number": 14, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }] }, { "name": "DescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "field", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldDescriptorProto" }, { "name": "extension", "number": 6, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldDescriptorProto" }, { "name": "nested_type", "number": 3, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto" }, { "name": "enum_type", "number": 4, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumDescriptorProto" }, { "name": "extension_range", "number": 5, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto.ExtensionRange" }, { "name": "oneof_decl", "number": 8, "type": 11, "label": 3, "typeName": ".google.protobuf.OneofDescriptorProto" }, { "name": "options", "number": 7, "type": 11, "label": 1, "typeName": ".google.protobuf.MessageOptions" }, { "name": "reserved_range", "number": 9, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto.ReservedRange" }, { "name": "reserved_name", "number": 10, "type": 9, "label": 3 }], "nestedType": [{ "name": "ExtensionRange", "field": [{ "name": "start", "number": 1, "type": 5, "label": 1 }, { "name": "end", "number": 2, "type": 5, "label": 1 }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.ExtensionRangeOptions" }] }, { "name": "ReservedRange", "field": [{ "name": "start", "number": 1, "type": 5, "label": 1 }, { "name": "end", "number": 2, "type": 5, "label": 1 }] }] }, { "name": "ExtensionRangeOptions", "field": [{ "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }, { "name": "declaration", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.ExtensionRangeOptions.Declaration", "options": { "retention": 2 } }, { "name": "features", "number": 50, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "verification", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.ExtensionRangeOptions.VerificationState", "defaultValue": "UNVERIFIED", "options": { "retention": 2 } }], "nestedType": [{ "name": "Declaration", "field": [{ "name": "number", "number": 1, "type": 5, "label": 1 }, { "name": "full_name", "number": 2, "type": 9, "label": 1 }, { "name": "type", "number": 3, "type": 9, "label": 1 }, { "name": "reserved", "number": 5, "type": 8, "label": 1 }, { "name": "repeated", "number": 6, "type": 8, "label": 1 }] }], "enumType": [{ "name": "VerificationState", "value": [{ "name": "DECLARATION", "number": 0 }, { "name": "UNVERIFIED", "number": 1 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "FieldDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "number", "number": 3, "type": 5, "label": 1 }, { "name": "label", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldDescriptorProto.Label" }, { "name": "type", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldDescriptorProto.Type" }, { "name": "type_name", "number": 6, "type": 9, "label": 1 }, { "name": "extendee", "number": 2, "type": 9, "label": 1 }, { "name": "default_value", "number": 7, "type": 9, "label": 1 }, { "name": "oneof_index", "number": 9, "type": 5, "label": 1 }, { "name": "json_name", "number": 10, "type": 9, "label": 1 }, { "name": "options", "number": 8, "type": 11, "label": 1, "typeName": ".google.protobuf.FieldOptions" }, { "name": "proto3_optional", "number": 17, "type": 8, "label": 1 }], "enumType": [{ "name": "Type", "value": [{ "name": "TYPE_DOUBLE", "number": 1 }, { "name": "TYPE_FLOAT", "number": 2 }, { "name": "TYPE_INT64", "number": 3 }, { "name": "TYPE_UINT64", "number": 4 }, { "name": "TYPE_INT32", "number": 5 }, { "name": "TYPE_FIXED64", "number": 6 }, { "name": "TYPE_FIXED32", "number": 7 }, { "name": "TYPE_BOOL", "number": 8 }, { "name": "TYPE_STRING", "number": 9 }, { "name": "TYPE_GROUP", "number": 10 }, { "name": "TYPE_MESSAGE", "number": 11 }, { "name": "TYPE_BYTES", "number": 12 }, { "name": "TYPE_UINT32", "number": 13 }, { "name": "TYPE_ENUM", "number": 14 }, { "name": "TYPE_SFIXED32", "number": 15 }, { "name": "TYPE_SFIXED64", "number": 16 }, { "name": "TYPE_SINT32", "number": 17 }, { "name": "TYPE_SINT64", "number": 18 }] }, { "name": "Label", "value": [{ "name": "LABEL_OPTIONAL", "number": 1 }, { "name": "LABEL_REPEATED", "number": 3 }, { "name": "LABEL_REQUIRED", "number": 2 }] }] }, { "name": "OneofDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "options", "number": 2, "type": 11, "label": 1, "typeName": ".google.protobuf.OneofOptions" }] }, { "name": "EnumDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "value", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumValueDescriptorProto" }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.EnumOptions" }, { "name": "reserved_range", "number": 4, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumDescriptorProto.EnumReservedRange" }, { "name": "reserved_name", "number": 5, "type": 9, "label": 3 }], "nestedType": [{ "name": "EnumReservedRange", "field": [{ "name": "start", "number": 1, "type": 5, "label": 1 }, { "name": "end", "number": 2, "type": 5, "label": 1 }] }] }, { "name": "EnumValueDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "number", "number": 2, "type": 5, "label": 1 }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.EnumValueOptions" }] }, { "name": "ServiceDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "method", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.MethodDescriptorProto" }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.ServiceOptions" }] }, { "name": "MethodDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "input_type", "number": 2, "type": 9, "label": 1 }, { "name": "output_type", "number": 3, "type": 9, "label": 1 }, { "name": "options", "number": 4, "type": 11, "label": 1, "typeName": ".google.protobuf.MethodOptions" }, { "name": "client_streaming", "number": 5, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "server_streaming", "number": 6, "type": 8, "label": 1, "defaultValue": "false" }] }, { "name": "FileOptions", "field": [{ "name": "java_package", "number": 1, "type": 9, "label": 1 }, { "name": "java_outer_classname", "number": 8, "type": 9, "label": 1 }, { "name": "java_multiple_files", "number": 10, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "java_generate_equals_and_hash", "number": 20, "type": 8, "label": 1, "options": { "deprecated": true } }, { "name": "java_string_check_utf8", "number": 27, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "optimize_for", "number": 9, "type": 14, "label": 1, "typeName": ".google.protobuf.FileOptions.OptimizeMode", "defaultValue": "SPEED" }, { "name": "go_package", "number": 11, "type": 9, "label": 1 }, { "name": "cc_generic_services", "number": 16, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "java_generic_services", "number": 17, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "py_generic_services", "number": 18, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated", "number": 23, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "cc_enable_arenas", "number": 31, "type": 8, "label": 1, "defaultValue": "true" }, { "name": "objc_class_prefix", "number": 36, "type": 9, "label": 1 }, { "name": "csharp_namespace", "number": 37, "type": 9, "label": 1 }, { "name": "swift_prefix", "number": 39, "type": 9, "label": 1 }, { "name": "php_class_prefix", "number": 40, "type": 9, "label": 1 }, { "name": "php_namespace", "number": 41, "type": 9, "label": 1 }, { "name": "php_metadata_namespace", "number": 44, "type": 9, "label": 1 }, { "name": "ruby_package", "number": 45, "type": 9, "label": 1 }, { "name": "features", "number": 50, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "enumType": [{ "name": "OptimizeMode", "value": [{ "name": "SPEED", "number": 1 }, { "name": "CODE_SIZE", "number": 2 }, { "name": "LITE_RUNTIME", "number": 3 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "MessageOptions", "field": [{ "name": "message_set_wire_format", "number": 1, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "no_standard_descriptor_accessor", "number": 2, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "map_entry", "number": 7, "type": 8, "label": 1 }, { "name": "deprecated_legacy_json_field_conflicts", "number": 11, "type": 8, "label": 1, "options": { "deprecated": true } }, { "name": "features", "number": 12, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "FieldOptions", "field": [{ "name": "ctype", "number": 1, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldOptions.CType", "defaultValue": "STRING" }, { "name": "packed", "number": 2, "type": 8, "label": 1 }, { "name": "jstype", "number": 6, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldOptions.JSType", "defaultValue": "JS_NORMAL" }, { "name": "lazy", "number": 5, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "unverified_lazy", "number": 15, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "weak", "number": 10, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "debug_redact", "number": 16, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "retention", "number": 17, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldOptions.OptionRetention" }, { "name": "targets", "number": 19, "type": 14, "label": 3, "typeName": ".google.protobuf.FieldOptions.OptionTargetType" }, { "name": "edition_defaults", "number": 20, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldOptions.EditionDefault" }, { "name": "features", "number": 21, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "feature_support", "number": 22, "type": 11, "label": 1, "typeName": ".google.protobuf.FieldOptions.FeatureSupport" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "nestedType": [{ "name": "EditionDefault", "field": [{ "name": "edition", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "value", "number": 2, "type": 9, "label": 1 }] }, { "name": "FeatureSupport", "field": [{ "name": "edition_introduced", "number": 1, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "edition_deprecated", "number": 2, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "deprecation_warning", "number": 3, "type": 9, "label": 1 }, { "name": "edition_removed", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }] }], "enumType": [{ "name": "CType", "value": [{ "name": "STRING", "number": 0 }, { "name": "CORD", "number": 1 }, { "name": "STRING_PIECE", "number": 2 }] }, { "name": "JSType", "value": [{ "name": "JS_NORMAL", "number": 0 }, { "name": "JS_STRING", "number": 1 }, { "name": "JS_NUMBER", "number": 2 }] }, { "name": "OptionRetention", "value": [{ "name": "RETENTION_UNKNOWN", "number": 0 }, { "name": "RETENTION_RUNTIME", "number": 1 }, { "name": "RETENTION_SOURCE", "number": 2 }] }, { "name": "OptionTargetType", "value": [{ "name": "TARGET_TYPE_UNKNOWN", "number": 0 }, { "name": "TARGET_TYPE_FILE", "number": 1 }, { "name": "TARGET_TYPE_EXTENSION_RANGE", "number": 2 }, { "name": "TARGET_TYPE_MESSAGE", "number": 3 }, { "name": "TARGET_TYPE_FIELD", "number": 4 }, { "name": "TARGET_TYPE_ONEOF", "number": 5 }, { "name": "TARGET_TYPE_ENUM", "number": 6 }, { "name": "TARGET_TYPE_ENUM_ENTRY", "number": 7 }, { "name": "TARGET_TYPE_SERVICE", "number": 8 }, { "name": "TARGET_TYPE_METHOD", "number": 9 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "OneofOptions", "field": [{ "name": "features", "number": 1, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "EnumOptions", "field": [{ "name": "allow_alias", "number": 2, "type": 8, "label": 1 }, { "name": "deprecated", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated_legacy_json_field_conflicts", "number": 6, "type": 8, "label": 1, "options": { "deprecated": true } }, { "name": "features", "number": 7, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "EnumValueOptions", "field": [{ "name": "deprecated", "number": 1, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "features", "number": 2, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "debug_redact", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "ServiceOptions", "field": [{ "name": "features", "number": 34, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "deprecated", "number": 33, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "MethodOptions", "field": [{ "name": "deprecated", "number": 33, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "idempotency_level", "number": 34, "type": 14, "label": 1, "typeName": ".google.protobuf.MethodOptions.IdempotencyLevel", "defaultValue": "IDEMPOTENCY_UNKNOWN" }, { "name": "features", "number": 35, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "enumType": [{ "name": "IdempotencyLevel", "value": [{ "name": "IDEMPOTENCY_UNKNOWN", "number": 0 }, { "name": "NO_SIDE_EFFECTS", "number": 1 }, { "name": "IDEMPOTENT", "number": 2 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "UninterpretedOption", "field": [{ "name": "name", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption.NamePart" }, { "name": "identifier_value", "number": 3, "type": 9, "label": 1 }, { "name": "positive_int_value", "number": 4, "type": 4, "label": 1 }, { "name": "negative_int_value", "number": 5, "type": 3, "label": 1 }, { "name": "double_value", "number": 6, "type": 1, "label": 1 }, { "name": "string_value", "number": 7, "type": 12, "label": 1 }, { "name": "aggregate_value", "number": 8, "type": 9, "label": 1 }], "nestedType": [{ "name": "NamePart", "field": [{ "name": "name_part", "number": 1, "type": 9, "label": 2 }, { "name": "is_extension", "number": 2, "type": 8, "label": 2 }] }] }, { "name": "FeatureSet", "field": [{ "name": "field_presence", "number": 1, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.FieldPresence", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "EXPLICIT", "edition": 998 }, { "value": "IMPLICIT", "edition": 999 }, { "value": "EXPLICIT", "edition": 1000 }] } }, { "name": "enum_type", "number": 2, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.EnumType", "options": { "retention": 1, "targets": [6, 1], "editionDefaults": [{ "value": "CLOSED", "edition": 998 }, { "value": "OPEN", "edition": 999 }] } }, { "name": "repeated_field_encoding", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.RepeatedFieldEncoding", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "EXPANDED", "edition": 998 }, { "value": "PACKED", "edition": 999 }] } }, { "name": "utf8_validation", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.Utf8Validation", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "NONE", "edition": 998 }, { "value": "VERIFY", "edition": 999 }] } }, { "name": "message_encoding", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.MessageEncoding", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "LENGTH_PREFIXED", "edition": 998 }] } }, { "name": "json_format", "number": 6, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.JsonFormat", "options": { "retention": 1, "targets": [3, 6, 1], "editionDefaults": [{ "value": "LEGACY_BEST_EFFORT", "edition": 998 }, { "value": "ALLOW", "edition": 999 }] } }], "enumType": [{ "name": "FieldPresence", "value": [{ "name": "FIELD_PRESENCE_UNKNOWN", "number": 0 }, { "name": "EXPLICIT", "number": 1 }, { "name": "IMPLICIT", "number": 2 }, { "name": "LEGACY_REQUIRED", "number": 3 }] }, { "name": "EnumType", "value": [{ "name": "ENUM_TYPE_UNKNOWN", "number": 0 }, { "name": "OPEN", "number": 1 }, { "name": "CLOSED", "number": 2 }] }, { "name": "RepeatedFieldEncoding", "value": [{ "name": "REPEATED_FIELD_ENCODING_UNKNOWN", "number": 0 }, { "name": "PACKED", "number": 1 }, { "name": "EXPANDED", "number": 2 }] }, { "name": "Utf8Validation", "value": [{ "name": "UTF8_VALIDATION_UNKNOWN", "number": 0 }, { "name": "VERIFY", "number": 2 }, { "name": "NONE", "number": 3 }] }, { "name": "MessageEncoding", "value": [{ "name": "MESSAGE_ENCODING_UNKNOWN", "number": 0 }, { "name": "LENGTH_PREFIXED", "number": 1 }, { "name": "DELIMITED", "number": 2 }] }, { "name": "JsonFormat", "value": [{ "name": "JSON_FORMAT_UNKNOWN", "number": 0 }, { "name": "ALLOW", "number": 1 }, { "name": "LEGACY_BEST_EFFORT", "number": 2 }] }], "extensionRange": [{ "start": 1000, "end": 1001 }, { "start": 1001, "end": 1002 }, { "start": 1002, "end": 1003 }, { "start": 9990, "end": 9991 }, { "start": 9995, "end": 10000 }, { "start": 10000, "end": 10001 }] }, { "name": "FeatureSetDefaults", "field": [{ "name": "defaults", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault" }, { "name": "minimum_edition", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "maximum_edition", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }], "nestedType": [{ "name": "FeatureSetEditionDefault", "field": [{ "name": "edition", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "overridable_features", "number": 4, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "fixed_features", "number": 5, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }] }] }, { "name": "SourceCodeInfo", "field": [{ "name": "location", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.SourceCodeInfo.Location" }], "nestedType": [{ "name": "Location", "field": [{ "name": "path", "number": 1, "type": 5, "label": 3, "options": { "packed": true } }, { "name": "span", "number": 2, "type": 5, "label": 3, "options": { "packed": true } }, { "name": "leading_comments", "number": 3, "type": 9, "label": 1 }, { "name": "trailing_comments", "number": 4, "type": 9, "label": 1 }, { "name": "leading_detached_comments", "number": 6, "type": 9, "label": 3 }] }] }, { "name": "GeneratedCodeInfo", "field": [{ "name": "annotation", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.GeneratedCodeInfo.Annotation" }], "nestedType": [{ "name": "Annotation", "field": [{ "name": "path", "number": 1, "type": 5, "label": 3, "options": { "packed": true } }, { "name": "source_file", "number": 2, "type": 9, "label": 1 }, { "name": "begin", "number": 3, "type": 5, "label": 1 }, { "name": "end", "number": 4, "type": 5, "label": 1 }, { "name": "semantic", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.GeneratedCodeInfo.Annotation.Semantic" }], "enumType": [{ "name": "Semantic", "value": [{ "name": "NONE", "number": 0 }, { "name": "SET", "number": 1 }, { "name": "ALIAS", "number": 2 }] }] }] }], "enumType": [{ "name": "Edition", "value": [{ "name": "EDITION_UNKNOWN", "number": 0 }, { "name": "EDITION_LEGACY", "number": 900 }, { "name": "EDITION_PROTO2", "number": 998 }, { "name": "EDITION_PROTO3", "number": 999 }, { "name": "EDITION_2023", "number": 1000 }, { "name": "EDITION_2024", "number": 1001 }, { "name": "EDITION_1_TEST_ONLY", "number": 1 }, { "name": "EDITION_2_TEST_ONLY", "number": 2 }, { "name": "EDITION_99997_TEST_ONLY", "number": 99997 }, { "name": "EDITION_99998_TEST_ONLY", "number": 99998 }, { "name": "EDITION_99999_TEST_ONLY", "number": 99999 }, { "name": "EDITION_MAX", "number": 2147483647 }] }] }); | ||
export const fileDesc_google_protobuf_descriptor = /*@__PURE__*/ boot({ "name": "google/protobuf/descriptor.proto", "package": "google.protobuf", "messageType": [{ "name": "FileDescriptorSet", "field": [{ "name": "file", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.FileDescriptorProto" }] }, { "name": "FileDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "package", "number": 2, "type": 9, "label": 1 }, { "name": "dependency", "number": 3, "type": 9, "label": 3 }, { "name": "public_dependency", "number": 10, "type": 5, "label": 3 }, { "name": "weak_dependency", "number": 11, "type": 5, "label": 3 }, { "name": "message_type", "number": 4, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto" }, { "name": "enum_type", "number": 5, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumDescriptorProto" }, { "name": "service", "number": 6, "type": 11, "label": 3, "typeName": ".google.protobuf.ServiceDescriptorProto" }, { "name": "extension", "number": 7, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldDescriptorProto" }, { "name": "options", "number": 8, "type": 11, "label": 1, "typeName": ".google.protobuf.FileOptions" }, { "name": "source_code_info", "number": 9, "type": 11, "label": 1, "typeName": ".google.protobuf.SourceCodeInfo" }, { "name": "syntax", "number": 12, "type": 9, "label": 1 }, { "name": "edition", "number": 14, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }] }, { "name": "DescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "field", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldDescriptorProto" }, { "name": "extension", "number": 6, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldDescriptorProto" }, { "name": "nested_type", "number": 3, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto" }, { "name": "enum_type", "number": 4, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumDescriptorProto" }, { "name": "extension_range", "number": 5, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto.ExtensionRange" }, { "name": "oneof_decl", "number": 8, "type": 11, "label": 3, "typeName": ".google.protobuf.OneofDescriptorProto" }, { "name": "options", "number": 7, "type": 11, "label": 1, "typeName": ".google.protobuf.MessageOptions" }, { "name": "reserved_range", "number": 9, "type": 11, "label": 3, "typeName": ".google.protobuf.DescriptorProto.ReservedRange" }, { "name": "reserved_name", "number": 10, "type": 9, "label": 3 }], "nestedType": [{ "name": "ExtensionRange", "field": [{ "name": "start", "number": 1, "type": 5, "label": 1 }, { "name": "end", "number": 2, "type": 5, "label": 1 }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.ExtensionRangeOptions" }] }, { "name": "ReservedRange", "field": [{ "name": "start", "number": 1, "type": 5, "label": 1 }, { "name": "end", "number": 2, "type": 5, "label": 1 }] }] }, { "name": "ExtensionRangeOptions", "field": [{ "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }, { "name": "declaration", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.ExtensionRangeOptions.Declaration", "options": { "retention": 2 } }, { "name": "features", "number": 50, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "verification", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.ExtensionRangeOptions.VerificationState", "defaultValue": "UNVERIFIED", "options": { "retention": 2 } }], "nestedType": [{ "name": "Declaration", "field": [{ "name": "number", "number": 1, "type": 5, "label": 1 }, { "name": "full_name", "number": 2, "type": 9, "label": 1 }, { "name": "type", "number": 3, "type": 9, "label": 1 }, { "name": "reserved", "number": 5, "type": 8, "label": 1 }, { "name": "repeated", "number": 6, "type": 8, "label": 1 }] }], "enumType": [{ "name": "VerificationState", "value": [{ "name": "DECLARATION", "number": 0 }, { "name": "UNVERIFIED", "number": 1 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "FieldDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "number", "number": 3, "type": 5, "label": 1 }, { "name": "label", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldDescriptorProto.Label" }, { "name": "type", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldDescriptorProto.Type" }, { "name": "type_name", "number": 6, "type": 9, "label": 1 }, { "name": "extendee", "number": 2, "type": 9, "label": 1 }, { "name": "default_value", "number": 7, "type": 9, "label": 1 }, { "name": "oneof_index", "number": 9, "type": 5, "label": 1 }, { "name": "json_name", "number": 10, "type": 9, "label": 1 }, { "name": "options", "number": 8, "type": 11, "label": 1, "typeName": ".google.protobuf.FieldOptions" }, { "name": "proto3_optional", "number": 17, "type": 8, "label": 1 }], "enumType": [{ "name": "Type", "value": [{ "name": "TYPE_DOUBLE", "number": 1 }, { "name": "TYPE_FLOAT", "number": 2 }, { "name": "TYPE_INT64", "number": 3 }, { "name": "TYPE_UINT64", "number": 4 }, { "name": "TYPE_INT32", "number": 5 }, { "name": "TYPE_FIXED64", "number": 6 }, { "name": "TYPE_FIXED32", "number": 7 }, { "name": "TYPE_BOOL", "number": 8 }, { "name": "TYPE_STRING", "number": 9 }, { "name": "TYPE_GROUP", "number": 10 }, { "name": "TYPE_MESSAGE", "number": 11 }, { "name": "TYPE_BYTES", "number": 12 }, { "name": "TYPE_UINT32", "number": 13 }, { "name": "TYPE_ENUM", "number": 14 }, { "name": "TYPE_SFIXED32", "number": 15 }, { "name": "TYPE_SFIXED64", "number": 16 }, { "name": "TYPE_SINT32", "number": 17 }, { "name": "TYPE_SINT64", "number": 18 }] }, { "name": "Label", "value": [{ "name": "LABEL_OPTIONAL", "number": 1 }, { "name": "LABEL_REPEATED", "number": 3 }, { "name": "LABEL_REQUIRED", "number": 2 }] }] }, { "name": "OneofDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "options", "number": 2, "type": 11, "label": 1, "typeName": ".google.protobuf.OneofOptions" }] }, { "name": "EnumDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "value", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumValueDescriptorProto" }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.EnumOptions" }, { "name": "reserved_range", "number": 4, "type": 11, "label": 3, "typeName": ".google.protobuf.EnumDescriptorProto.EnumReservedRange" }, { "name": "reserved_name", "number": 5, "type": 9, "label": 3 }], "nestedType": [{ "name": "EnumReservedRange", "field": [{ "name": "start", "number": 1, "type": 5, "label": 1 }, { "name": "end", "number": 2, "type": 5, "label": 1 }] }] }, { "name": "EnumValueDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "number", "number": 2, "type": 5, "label": 1 }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.EnumValueOptions" }] }, { "name": "ServiceDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "method", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.MethodDescriptorProto" }, { "name": "options", "number": 3, "type": 11, "label": 1, "typeName": ".google.protobuf.ServiceOptions" }] }, { "name": "MethodDescriptorProto", "field": [{ "name": "name", "number": 1, "type": 9, "label": 1 }, { "name": "input_type", "number": 2, "type": 9, "label": 1 }, { "name": "output_type", "number": 3, "type": 9, "label": 1 }, { "name": "options", "number": 4, "type": 11, "label": 1, "typeName": ".google.protobuf.MethodOptions" }, { "name": "client_streaming", "number": 5, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "server_streaming", "number": 6, "type": 8, "label": 1, "defaultValue": "false" }] }, { "name": "FileOptions", "field": [{ "name": "java_package", "number": 1, "type": 9, "label": 1 }, { "name": "java_outer_classname", "number": 8, "type": 9, "label": 1 }, { "name": "java_multiple_files", "number": 10, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "java_generate_equals_and_hash", "number": 20, "type": 8, "label": 1, "options": { "deprecated": true } }, { "name": "java_string_check_utf8", "number": 27, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "optimize_for", "number": 9, "type": 14, "label": 1, "typeName": ".google.protobuf.FileOptions.OptimizeMode", "defaultValue": "SPEED" }, { "name": "go_package", "number": 11, "type": 9, "label": 1 }, { "name": "cc_generic_services", "number": 16, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "java_generic_services", "number": 17, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "py_generic_services", "number": 18, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated", "number": 23, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "cc_enable_arenas", "number": 31, "type": 8, "label": 1, "defaultValue": "true" }, { "name": "objc_class_prefix", "number": 36, "type": 9, "label": 1 }, { "name": "csharp_namespace", "number": 37, "type": 9, "label": 1 }, { "name": "swift_prefix", "number": 39, "type": 9, "label": 1 }, { "name": "php_class_prefix", "number": 40, "type": 9, "label": 1 }, { "name": "php_namespace", "number": 41, "type": 9, "label": 1 }, { "name": "php_metadata_namespace", "number": 44, "type": 9, "label": 1 }, { "name": "ruby_package", "number": 45, "type": 9, "label": 1 }, { "name": "features", "number": 50, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "enumType": [{ "name": "OptimizeMode", "value": [{ "name": "SPEED", "number": 1 }, { "name": "CODE_SIZE", "number": 2 }, { "name": "LITE_RUNTIME", "number": 3 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "MessageOptions", "field": [{ "name": "message_set_wire_format", "number": 1, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "no_standard_descriptor_accessor", "number": 2, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "map_entry", "number": 7, "type": 8, "label": 1 }, { "name": "deprecated_legacy_json_field_conflicts", "number": 11, "type": 8, "label": 1, "options": { "deprecated": true } }, { "name": "features", "number": 12, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "FieldOptions", "field": [{ "name": "ctype", "number": 1, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldOptions.CType", "defaultValue": "STRING" }, { "name": "packed", "number": 2, "type": 8, "label": 1 }, { "name": "jstype", "number": 6, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldOptions.JSType", "defaultValue": "JS_NORMAL" }, { "name": "lazy", "number": 5, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "unverified_lazy", "number": 15, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "weak", "number": 10, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "debug_redact", "number": 16, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "retention", "number": 17, "type": 14, "label": 1, "typeName": ".google.protobuf.FieldOptions.OptionRetention" }, { "name": "targets", "number": 19, "type": 14, "label": 3, "typeName": ".google.protobuf.FieldOptions.OptionTargetType" }, { "name": "edition_defaults", "number": 20, "type": 11, "label": 3, "typeName": ".google.protobuf.FieldOptions.EditionDefault" }, { "name": "features", "number": 21, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "feature_support", "number": 22, "type": 11, "label": 1, "typeName": ".google.protobuf.FieldOptions.FeatureSupport" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "nestedType": [{ "name": "EditionDefault", "field": [{ "name": "edition", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "value", "number": 2, "type": 9, "label": 1 }] }, { "name": "FeatureSupport", "field": [{ "name": "edition_introduced", "number": 1, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "edition_deprecated", "number": 2, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "deprecation_warning", "number": 3, "type": 9, "label": 1 }, { "name": "edition_removed", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }] }], "enumType": [{ "name": "CType", "value": [{ "name": "STRING", "number": 0 }, { "name": "CORD", "number": 1 }, { "name": "STRING_PIECE", "number": 2 }] }, { "name": "JSType", "value": [{ "name": "JS_NORMAL", "number": 0 }, { "name": "JS_STRING", "number": 1 }, { "name": "JS_NUMBER", "number": 2 }] }, { "name": "OptionRetention", "value": [{ "name": "RETENTION_UNKNOWN", "number": 0 }, { "name": "RETENTION_RUNTIME", "number": 1 }, { "name": "RETENTION_SOURCE", "number": 2 }] }, { "name": "OptionTargetType", "value": [{ "name": "TARGET_TYPE_UNKNOWN", "number": 0 }, { "name": "TARGET_TYPE_FILE", "number": 1 }, { "name": "TARGET_TYPE_EXTENSION_RANGE", "number": 2 }, { "name": "TARGET_TYPE_MESSAGE", "number": 3 }, { "name": "TARGET_TYPE_FIELD", "number": 4 }, { "name": "TARGET_TYPE_ONEOF", "number": 5 }, { "name": "TARGET_TYPE_ENUM", "number": 6 }, { "name": "TARGET_TYPE_ENUM_ENTRY", "number": 7 }, { "name": "TARGET_TYPE_SERVICE", "number": 8 }, { "name": "TARGET_TYPE_METHOD", "number": 9 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "OneofOptions", "field": [{ "name": "features", "number": 1, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "EnumOptions", "field": [{ "name": "allow_alias", "number": 2, "type": 8, "label": 1 }, { "name": "deprecated", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "deprecated_legacy_json_field_conflicts", "number": 6, "type": 8, "label": 1, "options": { "deprecated": true } }, { "name": "features", "number": 7, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "EnumValueOptions", "field": [{ "name": "deprecated", "number": 1, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "features", "number": 2, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "debug_redact", "number": 3, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "feature_support", "number": 4, "type": 11, "label": 1, "typeName": ".google.protobuf.FieldOptions.FeatureSupport" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "ServiceOptions", "field": [{ "name": "features", "number": 34, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "deprecated", "number": 33, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "MethodOptions", "field": [{ "name": "deprecated", "number": 33, "type": 8, "label": 1, "defaultValue": "false" }, { "name": "idempotency_level", "number": 34, "type": 14, "label": 1, "typeName": ".google.protobuf.MethodOptions.IdempotencyLevel", "defaultValue": "IDEMPOTENCY_UNKNOWN" }, { "name": "features", "number": 35, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "uninterpreted_option", "number": 999, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption" }], "enumType": [{ "name": "IdempotencyLevel", "value": [{ "name": "IDEMPOTENCY_UNKNOWN", "number": 0 }, { "name": "NO_SIDE_EFFECTS", "number": 1 }, { "name": "IDEMPOTENT", "number": 2 }] }], "extensionRange": [{ "start": 1000, "end": 536870912 }] }, { "name": "UninterpretedOption", "field": [{ "name": "name", "number": 2, "type": 11, "label": 3, "typeName": ".google.protobuf.UninterpretedOption.NamePart" }, { "name": "identifier_value", "number": 3, "type": 9, "label": 1 }, { "name": "positive_int_value", "number": 4, "type": 4, "label": 1 }, { "name": "negative_int_value", "number": 5, "type": 3, "label": 1 }, { "name": "double_value", "number": 6, "type": 1, "label": 1 }, { "name": "string_value", "number": 7, "type": 12, "label": 1 }, { "name": "aggregate_value", "number": 8, "type": 9, "label": 1 }], "nestedType": [{ "name": "NamePart", "field": [{ "name": "name_part", "number": 1, "type": 9, "label": 2 }, { "name": "is_extension", "number": 2, "type": 8, "label": 2 }] }] }, { "name": "FeatureSet", "field": [{ "name": "field_presence", "number": 1, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.FieldPresence", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "EXPLICIT", "edition": 998 }, { "value": "IMPLICIT", "edition": 999 }, { "value": "EXPLICIT", "edition": 1000 }] } }, { "name": "enum_type", "number": 2, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.EnumType", "options": { "retention": 1, "targets": [6, 1], "editionDefaults": [{ "value": "CLOSED", "edition": 998 }, { "value": "OPEN", "edition": 999 }] } }, { "name": "repeated_field_encoding", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.RepeatedFieldEncoding", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "EXPANDED", "edition": 998 }, { "value": "PACKED", "edition": 999 }] } }, { "name": "utf8_validation", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.Utf8Validation", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "NONE", "edition": 998 }, { "value": "VERIFY", "edition": 999 }] } }, { "name": "message_encoding", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.MessageEncoding", "options": { "retention": 1, "targets": [4, 1], "editionDefaults": [{ "value": "LENGTH_PREFIXED", "edition": 998 }] } }, { "name": "json_format", "number": 6, "type": 14, "label": 1, "typeName": ".google.protobuf.FeatureSet.JsonFormat", "options": { "retention": 1, "targets": [3, 6, 1], "editionDefaults": [{ "value": "LEGACY_BEST_EFFORT", "edition": 998 }, { "value": "ALLOW", "edition": 999 }] } }], "enumType": [{ "name": "FieldPresence", "value": [{ "name": "FIELD_PRESENCE_UNKNOWN", "number": 0 }, { "name": "EXPLICIT", "number": 1 }, { "name": "IMPLICIT", "number": 2 }, { "name": "LEGACY_REQUIRED", "number": 3 }] }, { "name": "EnumType", "value": [{ "name": "ENUM_TYPE_UNKNOWN", "number": 0 }, { "name": "OPEN", "number": 1 }, { "name": "CLOSED", "number": 2 }] }, { "name": "RepeatedFieldEncoding", "value": [{ "name": "REPEATED_FIELD_ENCODING_UNKNOWN", "number": 0 }, { "name": "PACKED", "number": 1 }, { "name": "EXPANDED", "number": 2 }] }, { "name": "Utf8Validation", "value": [{ "name": "UTF8_VALIDATION_UNKNOWN", "number": 0 }, { "name": "VERIFY", "number": 2 }, { "name": "NONE", "number": 3 }] }, { "name": "MessageEncoding", "value": [{ "name": "MESSAGE_ENCODING_UNKNOWN", "number": 0 }, { "name": "LENGTH_PREFIXED", "number": 1 }, { "name": "DELIMITED", "number": 2 }] }, { "name": "JsonFormat", "value": [{ "name": "JSON_FORMAT_UNKNOWN", "number": 0 }, { "name": "ALLOW", "number": 1 }, { "name": "LEGACY_BEST_EFFORT", "number": 2 }] }], "extensionRange": [{ "start": 1000, "end": 9995 }, { "start": 9995, "end": 10000 }, { "start": 10000, "end": 10001 }] }, { "name": "FeatureSetDefaults", "field": [{ "name": "defaults", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault" }, { "name": "minimum_edition", "number": 4, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "maximum_edition", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }], "nestedType": [{ "name": "FeatureSetEditionDefault", "field": [{ "name": "edition", "number": 3, "type": 14, "label": 1, "typeName": ".google.protobuf.Edition" }, { "name": "overridable_features", "number": 4, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }, { "name": "fixed_features", "number": 5, "type": 11, "label": 1, "typeName": ".google.protobuf.FeatureSet" }] }] }, { "name": "SourceCodeInfo", "field": [{ "name": "location", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.SourceCodeInfo.Location" }], "nestedType": [{ "name": "Location", "field": [{ "name": "path", "number": 1, "type": 5, "label": 3, "options": { "packed": true } }, { "name": "span", "number": 2, "type": 5, "label": 3, "options": { "packed": true } }, { "name": "leading_comments", "number": 3, "type": 9, "label": 1 }, { "name": "trailing_comments", "number": 4, "type": 9, "label": 1 }, { "name": "leading_detached_comments", "number": 6, "type": 9, "label": 3 }] }] }, { "name": "GeneratedCodeInfo", "field": [{ "name": "annotation", "number": 1, "type": 11, "label": 3, "typeName": ".google.protobuf.GeneratedCodeInfo.Annotation" }], "nestedType": [{ "name": "Annotation", "field": [{ "name": "path", "number": 1, "type": 5, "label": 3, "options": { "packed": true } }, { "name": "source_file", "number": 2, "type": 9, "label": 1 }, { "name": "begin", "number": 3, "type": 5, "label": 1 }, { "name": "end", "number": 4, "type": 5, "label": 1 }, { "name": "semantic", "number": 5, "type": 14, "label": 1, "typeName": ".google.protobuf.GeneratedCodeInfo.Annotation.Semantic" }], "enumType": [{ "name": "Semantic", "value": [{ "name": "NONE", "number": 0 }, { "name": "SET", "number": 1 }, { "name": "ALIAS", "number": 2 }] }] }] }], "enumType": [{ "name": "Edition", "value": [{ "name": "EDITION_UNKNOWN", "number": 0 }, { "name": "EDITION_LEGACY", "number": 900 }, { "name": "EDITION_PROTO2", "number": 998 }, { "name": "EDITION_PROTO3", "number": 999 }, { "name": "EDITION_2023", "number": 1000 }, { "name": "EDITION_2024", "number": 1001 }, { "name": "EDITION_1_TEST_ONLY", "number": 1 }, { "name": "EDITION_2_TEST_ONLY", "number": 2 }, { "name": "EDITION_99997_TEST_ONLY", "number": 99997 }, { "name": "EDITION_99998_TEST_ONLY", "number": 99998 }, { "name": "EDITION_99999_TEST_ONLY", "number": 99999 }, { "name": "EDITION_MAX", "number": 2147483647 }] }] }); | ||
/** | ||
@@ -23,0 +23,0 @@ * Describes the message google.protobuf.FileDescriptorSet. |
import type { Message } from "../types.js"; | ||
import type { BoolValue, BytesValue, DoubleValue, FloatValue, Int32Value, Int64Value, StringValue, UInt32Value, UInt64Value } from "./gen/google/protobuf/wrappers_pb.js"; | ||
import type { DescField, DescMessage } from "../desc-types.js"; | ||
import type { DescField, DescMessage } from "../descriptors.js"; | ||
export declare function isWrapper(arg: Message): arg is DoubleValue | FloatValue | Int64Value | UInt64Value | Int32Value | UInt32Value | BoolValue | StringValue | BytesValue; | ||
@@ -5,0 +5,0 @@ export type WktWrapperDesc = DescMessage & { |
{ | ||
"name": "@bufbuild/protobuf", | ||
"version": "2.0.0-alpha.2", | ||
"version": "2.0.0-alpha.3", | ||
"license": "(Apache-2.0 AND BSD-3-Clause)", | ||
@@ -5,0 +5,0 @@ "description": "A complete implementation of Protocol Buffers in TypeScript, suitable for web browsers and Node.js.", |
@@ -18,3 +18,3 @@ # @bufbuild/protobuf | ||
- Generation of idiomatic JavaScript and TypeScript code. | ||
- Generation of [much smaller bundles](https://github.com/bufbuild/protobuf-es/blob/main/packages/protobuf-bench) | ||
- Generation of [much smaller bundles](https://github.com/bufbuild/protobuf-es/blob/main/packages/bundle-size) | ||
- Implementation of all proto3 features, including the [canonical JSON format](https://developers.google.com/protocol-buffers/docs/proto3#json). | ||
@@ -21,0 +21,0 @@ - Implementation of all proto2 features, except for extensions and the text format. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1155266
29947