@google-cloud/spanner
Version:
Cloud Spanner Client Library for Node.js
936 lines (872 loc) • 6.31 MB
JavaScript
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
(function(global, factory) { /* global define, require, module */
/* AMD */ if (typeof define === 'function' && define.amd)
define(["protobufjs/minimal"], factory);
/* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports)
module.exports = factory(require("google-gax/build/src/protobuf").protobufMinimal);
})(this, function($protobuf) {
"use strict";
// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
// Exported root namespace
var $root = $protobuf.roots._google_cloud_spanner_protos || ($protobuf.roots._google_cloud_spanner_protos = {});
$root.google = (function() {
/**
* Namespace google.
* @exports google
* @namespace
*/
var google = {};
google.protobuf = (function() {
/**
* Namespace protobuf.
* @memberof google
* @namespace
*/
var protobuf = {};
protobuf.Duration = (function() {
/**
* Properties of a Duration.
* @memberof google.protobuf
* @interface IDuration
* @property {number|Long|null} [seconds] Duration seconds
* @property {number|null} [nanos] Duration nanos
*/
/**
* Constructs a new Duration.
* @memberof google.protobuf
* @classdesc Represents a Duration.
* @implements IDuration
* @constructor
* @param {google.protobuf.IDuration=} [properties] Properties to set
*/
function Duration(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* Duration seconds.
* @member {number|Long} seconds
* @memberof google.protobuf.Duration
* @instance
*/
Duration.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
/**
* Duration nanos.
* @member {number} nanos
* @memberof google.protobuf.Duration
* @instance
*/
Duration.prototype.nanos = 0;
/**
* Creates a new Duration instance using the specified properties.
* @function create
* @memberof google.protobuf.Duration
* @static
* @param {google.protobuf.IDuration=} [properties] Properties to set
* @returns {google.protobuf.Duration} Duration instance
*/
Duration.create = function create(properties) {
return new Duration(properties);
};
/**
* Encodes the specified Duration message. Does not implicitly {@link google.protobuf.Duration.verify|verify} messages.
* @function encode
* @memberof google.protobuf.Duration
* @static
* @param {google.protobuf.IDuration} message Duration message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Duration.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.seconds != null && Object.hasOwnProperty.call(message, "seconds"))
writer.uint32(/* id 1, wireType 0 =*/8).int64(message.seconds);
if (message.nanos != null && Object.hasOwnProperty.call(message, "nanos"))
writer.uint32(/* id 2, wireType 0 =*/16).int32(message.nanos);
return writer;
};
/**
* Encodes the specified Duration message, length delimited. Does not implicitly {@link google.protobuf.Duration.verify|verify} messages.
* @function encodeDelimited
* @memberof google.protobuf.Duration
* @static
* @param {google.protobuf.IDuration} message Duration message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Duration.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a Duration message from the specified reader or buffer.
* @function decode
* @memberof google.protobuf.Duration
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {google.protobuf.Duration} Duration
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
Duration.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Duration();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.seconds = reader.int64();
break;
}
case 2: {
message.nanos = reader.int32();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a Duration message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof google.protobuf.Duration
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {google.protobuf.Duration} Duration
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
Duration.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a Duration message.
* @function verify
* @memberof google.protobuf.Duration
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
Duration.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.seconds != null && message.hasOwnProperty("seconds"))
if (!$util.isInteger(message.seconds) && !(message.seconds && $util.isInteger(message.seconds.low) && $util.isInteger(message.seconds.high)))
return "seconds: integer|Long expected";
if (message.nanos != null && message.hasOwnProperty("nanos"))
if (!$util.isInteger(message.nanos))
return "nanos: integer expected";
return null;
};
/**
* Creates a Duration message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof google.protobuf.Duration
* @static
* @param {Object.<string,*>} object Plain object
* @returns {google.protobuf.Duration} Duration
*/
Duration.fromObject = function fromObject(object) {
if (object instanceof $root.google.protobuf.Duration)
return object;
var message = new $root.google.protobuf.Duration();
if (object.seconds != null)
if ($util.Long)
(message.seconds = $util.Long.fromValue(object.seconds)).unsigned = false;
else if (typeof object.seconds === "string")
message.seconds = parseInt(object.seconds, 10);
else if (typeof object.seconds === "number")
message.seconds = object.seconds;
else if (typeof object.seconds === "object")
message.seconds = new $util.LongBits(object.seconds.low >>> 0, object.seconds.high >>> 0).toNumber();
if (object.nanos != null)
message.nanos = object.nanos | 0;
return message;
};
/**
* Creates a plain object from a Duration message. Also converts values to other types if specified.
* @function toObject
* @memberof google.protobuf.Duration
* @static
* @param {google.protobuf.Duration} message Duration
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
Duration.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.defaults) {
if ($util.Long) {
var long = new $util.Long(0, 0, false);
object.seconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
} else
object.seconds = options.longs === String ? "0" : 0;
object.nanos = 0;
}
if (message.seconds != null && message.hasOwnProperty("seconds"))
if (typeof message.seconds === "number")
object.seconds = options.longs === String ? String(message.seconds) : message.seconds;
else
object.seconds = options.longs === String ? $util.Long.prototype.toString.call(message.seconds) : options.longs === Number ? new $util.LongBits(message.seconds.low >>> 0, message.seconds.high >>> 0).toNumber() : message.seconds;
if (message.nanos != null && message.hasOwnProperty("nanos"))
object.nanos = message.nanos;
return object;
};
/**
* Converts this Duration to JSON.
* @function toJSON
* @memberof google.protobuf.Duration
* @instance
* @returns {Object.<string,*>} JSON object
*/
Duration.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for Duration
* @function getTypeUrl
* @memberof google.protobuf.Duration
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
Duration.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/google.protobuf.Duration";
};
return Duration;
})();
protobuf.FileDescriptorSet = (function() {
/**
* Properties of a FileDescriptorSet.
* @memberof google.protobuf
* @interface IFileDescriptorSet
* @property {Array.<google.protobuf.IFileDescriptorProto>|null} [file] FileDescriptorSet file
*/
/**
* Constructs a new FileDescriptorSet.
* @memberof google.protobuf
* @classdesc Represents a FileDescriptorSet.
* @implements IFileDescriptorSet
* @constructor
* @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set
*/
function FileDescriptorSet(properties) {
this.file = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* FileDescriptorSet file.
* @member {Array.<google.protobuf.IFileDescriptorProto>} file
* @memberof google.protobuf.FileDescriptorSet
* @instance
*/
FileDescriptorSet.prototype.file = $util.emptyArray;
/**
* Creates a new FileDescriptorSet instance using the specified properties.
* @function create
* @memberof google.protobuf.FileDescriptorSet
* @static
* @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set
* @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet instance
*/
FileDescriptorSet.create = function create(properties) {
return new FileDescriptorSet(properties);
};
/**
* Encodes the specified FileDescriptorSet message. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages.
* @function encode
* @memberof google.protobuf.FileDescriptorSet
* @static
* @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
FileDescriptorSet.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.file != null && message.file.length)
for (var i = 0; i < message.file.length; ++i)
$root.google.protobuf.FileDescriptorProto.encode(message.file[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
return writer;
};
/**
* Encodes the specified FileDescriptorSet message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages.
* @function encodeDelimited
* @memberof google.protobuf.FileDescriptorSet
* @static
* @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
FileDescriptorSet.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a FileDescriptorSet message from the specified reader or buffer.
* @function decode
* @memberof google.protobuf.FileDescriptorSet
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
FileDescriptorSet.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FileDescriptorSet();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
if (!(message.file && message.file.length))
message.file = [];
message.file.push($root.google.protobuf.FileDescriptorProto.decode(reader, reader.uint32()));
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a FileDescriptorSet message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof google.protobuf.FileDescriptorSet
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
FileDescriptorSet.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a FileDescriptorSet message.
* @function verify
* @memberof google.protobuf.FileDescriptorSet
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
FileDescriptorSet.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.file != null && message.hasOwnProperty("file")) {
if (!Array.isArray(message.file))
return "file: array expected";
for (var i = 0; i < message.file.length; ++i) {
var error = $root.google.protobuf.FileDescriptorProto.verify(message.file[i]);
if (error)
return "file." + error;
}
}
return null;
};
/**
* Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof google.protobuf.FileDescriptorSet
* @static
* @param {Object.<string,*>} object Plain object
* @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet
*/
FileDescriptorSet.fromObject = function fromObject(object) {
if (object instanceof $root.google.protobuf.FileDescriptorSet)
return object;
var message = new $root.google.protobuf.FileDescriptorSet();
if (object.file) {
if (!Array.isArray(object.file))
throw TypeError(".google.protobuf.FileDescriptorSet.file: array expected");
message.file = [];
for (var i = 0; i < object.file.length; ++i) {
if (typeof object.file[i] !== "object")
throw TypeError(".google.protobuf.FileDescriptorSet.file: object expected");
message.file[i] = $root.google.protobuf.FileDescriptorProto.fromObject(object.file[i]);
}
}
return message;
};
/**
* Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified.
* @function toObject
* @memberof google.protobuf.FileDescriptorSet
* @static
* @param {google.protobuf.FileDescriptorSet} message FileDescriptorSet
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
FileDescriptorSet.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.arrays || options.defaults)
object.file = [];
if (message.file && message.file.length) {
object.file = [];
for (var j = 0; j < message.file.length; ++j)
object.file[j] = $root.google.protobuf.FileDescriptorProto.toObject(message.file[j], options);
}
return object;
};
/**
* Converts this FileDescriptorSet to JSON.
* @function toJSON
* @memberof google.protobuf.FileDescriptorSet
* @instance
* @returns {Object.<string,*>} JSON object
*/
FileDescriptorSet.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for FileDescriptorSet
* @function getTypeUrl
* @memberof google.protobuf.FileDescriptorSet
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
FileDescriptorSet.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/google.protobuf.FileDescriptorSet";
};
return FileDescriptorSet;
})();
/**
* Edition enum.
* @name google.protobuf.Edition
* @enum {number}
* @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value
* @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value
* @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value
* @property {number} EDITION_2023=1000 EDITION_2023 value
* @property {number} EDITION_2024=1001 EDITION_2024 value
* @property {number} EDITION_1_TEST_ONLY=1 EDITION_1_TEST_ONLY value
* @property {number} EDITION_2_TEST_ONLY=2 EDITION_2_TEST_ONLY value
* @property {number} EDITION_99997_TEST_ONLY=99997 EDITION_99997_TEST_ONLY value
* @property {number} EDITION_99998_TEST_ONLY=99998 EDITION_99998_TEST_ONLY value
* @property {number} EDITION_99999_TEST_ONLY=99999 EDITION_99999_TEST_ONLY value
* @property {number} EDITION_MAX=2147483647 EDITION_MAX value
*/
protobuf.Edition = (function() {
var valuesById = {}, values = Object.create(valuesById);
values[valuesById[0] = "EDITION_UNKNOWN"] = 0;
values[valuesById[998] = "EDITION_PROTO2"] = 998;
values[valuesById[999] = "EDITION_PROTO3"] = 999;
values[valuesById[1000] = "EDITION_2023"] = 1000;
values[valuesById[1001] = "EDITION_2024"] = 1001;
values[valuesById[1] = "EDITION_1_TEST_ONLY"] = 1;
values[valuesById[2] = "EDITION_2_TEST_ONLY"] = 2;
values[valuesById[99997] = "EDITION_99997_TEST_ONLY"] = 99997;
values[valuesById[99998] = "EDITION_99998_TEST_ONLY"] = 99998;
values[valuesById[99999] = "EDITION_99999_TEST_ONLY"] = 99999;
values[valuesById[2147483647] = "EDITION_MAX"] = 2147483647;
return values;
})();
protobuf.FileDescriptorProto = (function() {
/**
* Properties of a FileDescriptorProto.
* @memberof google.protobuf
* @interface IFileDescriptorProto
* @property {string|null} [name] FileDescriptorProto name
* @property {string|null} ["package"] FileDescriptorProto package
* @property {Array.<string>|null} [dependency] FileDescriptorProto dependency
* @property {Array.<number>|null} [publicDependency] FileDescriptorProto publicDependency
* @property {Array.<number>|null} [weakDependency] FileDescriptorProto weakDependency
* @property {Array.<google.protobuf.IDescriptorProto>|null} [messageType] FileDescriptorProto messageType
* @property {Array.<google.protobuf.IEnumDescriptorProto>|null} [enumType] FileDescriptorProto enumType
* @property {Array.<google.protobuf.IServiceDescriptorProto>|null} [service] FileDescriptorProto service
* @property {Array.<google.protobuf.IFieldDescriptorProto>|null} [extension] FileDescriptorProto extension
* @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options
* @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo
* @property {string|null} [syntax] FileDescriptorProto syntax
* @property {google.protobuf.Edition|null} [edition] FileDescriptorProto edition
*/
/**
* Constructs a new FileDescriptorProto.
* @memberof google.protobuf
* @classdesc Represents a FileDescriptorProto.
* @implements IFileDescriptorProto
* @constructor
* @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set
*/
function FileDescriptorProto(properties) {
this.dependency = [];
this.publicDependency = [];
this.weakDependency = [];
this.messageType = [];
this.enumType = [];
this.service = [];
this.extension = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* FileDescriptorProto name.
* @member {string} name
* @memberof google.protobuf.FileDescriptorProto
* @instance
*/
FileDescriptorProto.prototype.name = "";
/**
* FileDescriptorProto package.
* @member {string} package
* @memberof google.protobuf.FileDescriptorProto
* @instance
*/
FileDescriptorProto.prototype["package"] = "";
/**
* FileDescriptorProto dependency.
* @member {Array.<string>} dependency
* @memberof google.protobuf.FileDescriptorProto
* @instance
*/
FileDescriptorProto.prototype.dependency = $util.emptyArray;
/**
* FileDescriptorProto publicDependency.
* @member {Array.<number>} publicDependency
* @memberof google.protobuf.FileDescriptorProto
* @instance
*/
FileDescriptorProto.prototype.publicDependency = $util.emptyArray;
/**
* FileDescriptorProto weakDependency.
* @member {Array.<number>} weakDependency
* @memberof google.protobuf.FileDescriptorProto
* @instance
*/
FileDescriptorProto.prototype.weakDependency = $util.emptyArray;
/**
* FileDescriptorProto messageType.
* @member {Array.<google.protobuf.IDescriptorProto>} messageType
* @memberof google.protobuf.FileDescriptorProto
* @instance
*/
FileDescriptorProto.prototype.messageType = $util.emptyArray;
/**
* FileDescriptorProto enumType.
* @member {Array.<google.protobuf.IEnumDescriptorProto>} enumType
* @memberof google.protobuf.FileDescriptorProto
* @instance
*/
FileDescriptorProto.prototype.enumType = $util.emptyArray;
/**
* FileDescriptorProto service.
* @member {Array.<google.protobuf.IServiceDescriptorProto>} service
* @memberof google.protobuf.FileDescriptorProto
* @instance
*/
FileDescriptorProto.prototype.service = $util.emptyArray;
/**
* FileDescriptorProto extension.
* @member {Array.<google.protobuf.IFieldDescriptorProto>} extension
* @memberof google.protobuf.FileDescriptorProto
* @instance
*/
FileDescriptorProto.prototype.extension = $util.emptyArray;
/**
* FileDescriptorProto options.
* @member {google.protobuf.IFileOptions|null|undefined} options
* @memberof google.protobuf.FileDescriptorProto
* @instance
*/
FileDescriptorProto.prototype.options = null;
/**
* FileDescriptorProto sourceCodeInfo.
* @member {google.protobuf.ISourceCodeInfo|null|undefined} sourceCodeInfo
* @memberof google.protobuf.FileDescriptorProto
* @instance
*/
FileDescriptorProto.prototype.sourceCodeInfo = null;
/**
* FileDescriptorProto syntax.
* @member {string} syntax
* @memberof google.protobuf.FileDescriptorProto
* @instance
*/
FileDescriptorProto.prototype.syntax = "";
/**
* FileDescriptorProto edition.
* @member {google.protobuf.Edition} edition
* @memberof google.protobuf.FileDescriptorProto
* @instance
*/
FileDescriptorProto.prototype.edition = 0;
/**
* Creates a new FileDescriptorProto instance using the specified properties.
* @function create
* @memberof google.protobuf.FileDescriptorProto
* @static
* @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set
* @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto instance
*/
FileDescriptorProto.create = function create(properties) {
return new FileDescriptorProto(properties);
};
/**
* Encodes the specified FileDescriptorProto message. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages.
* @function encode
* @memberof google.protobuf.FileDescriptorProto
* @static
* @param {google.protobuf.IFileDescriptorProto} message FileDescriptorProto message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
FileDescriptorProto.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.name != null && Object.hasOwnProperty.call(message, "name"))
writer.uint32(/* id 1, wireType 2 =*/10).string(message.name);
if (message["package"] != null && Object.hasOwnProperty.call(message, "package"))
writer.uint32(/* id 2, wireType 2 =*/18).string(message["package"]);
if (message.dependency != null && message.dependency.length)
for (var i = 0; i < message.dependency.length; ++i)
writer.uint32(/* id 3, wireType 2 =*/26).string(message.dependency[i]);
if (message.messageType != null && message.messageType.length)
for (var i = 0; i < message.messageType.length; ++i)
$root.google.protobuf.DescriptorProto.encode(message.messageType[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
if (message.enumType != null && message.enumType.length)
for (var i = 0; i < message.enumType.length; ++i)
$root.google.protobuf.EnumDescriptorProto.encode(message.enumType[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim();
if (message.service != null && message.service.length)
for (var i = 0; i < message.service.length; ++i)
$root.google.protobuf.ServiceDescriptorProto.encode(message.service[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim();
if (message.extension != null && message.extension.length)
for (var i = 0; i < message.extension.length; ++i)
$root.google.protobuf.FieldDescriptorProto.encode(message.extension[i], writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim();
if (message.options != null && Object.hasOwnProperty.call(message, "options"))
$root.google.protobuf.FileOptions.encode(message.options, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim();
if (message.sourceCodeInfo != null && Object.hasOwnProperty.call(message, "sourceCodeInfo"))
$root.google.protobuf.SourceCodeInfo.encode(message.sourceCodeInfo, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim();
if (message.publicDependency != null && message.publicDependency.length)
for (var i = 0; i < message.publicDependency.length; ++i)
writer.uint32(/* id 10, wireType 0 =*/80).int32(message.publicDependency[i]);
if (message.weakDependency != null && message.weakDependency.length)
for (var i = 0; i < message.weakDependency.length; ++i)
writer.uint32(/* id 11, wireType 0 =*/88).int32(message.weakDependency[i]);
if (message.syntax != null && Object.hasOwnProperty.call(message, "syntax"))
writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax);
if (message.edition != null && Object.hasOwnProperty.call(message, "edition"))
writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition);
return writer;
};
/**
* Encodes the specified FileDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages.
* @function encodeDelimited
* @memberof google.protobuf.FileDescriptorProto
* @static
* @param {google.protobuf.IFileDescriptorProto} message FileDescriptorProto message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
FileDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a FileDescriptorProto message from the specified reader or buffer.
* @function decode
* @memberof google.protobuf.FileDescriptorProto
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
FileDescriptorProto.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FileDescriptorProto();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.name = reader.string();
break;
}
case 2: {
message["package"] = reader.string();
break;
}
case 3: {
if (!(message.dependency && message.dependency.length))
message.dependency = [];
message.dependency.push(reader.string());
break;
}
case 10: {
if (!(message.publicDependency && message.publicDependency.length))
message.publicDependency = [];
if ((tag & 7) === 2) {
var end2 = reader.uint32() + reader.pos;
while (reader.pos < end2)
message.publicDependency.push(reader.int32());
} else
message.publicDependency.push(reader.int32());
break;
}
case 11: {
if (!(message.weakDependency && message.weakDependency.length))
message.weakDependency = [];
if ((tag & 7) === 2) {
var end2 = reader.uint32() + reader.pos;
while (reader.pos < end2)
message.weakDependency.push(reader.int32());
} else
message.weakDependency.push(reader.int32());
break;
}
case 4: {
if (!(message.messageType && message.messageType.length))
message.messageType = [];
message.messageType.push($root.google.protobuf.DescriptorProto.decode(reader, reader.uint32()));
break;
}
case 5: {
if (!(message.enumType && message.enumType.length))
message.enumType = [];
message.enumType.push($root.google.protobuf.EnumDescriptorProto.decode(reader, reader.uint32()));
break;
}
case 6: {
if (!(message.service && message.service.length))
message.service = [];
message.service.push($root.google.protobuf.ServiceDescriptorProto.decode(reader, reader.uint32()));
break;
}
case 7: {
if (!(message.extension && message.extension.length))
message.extension = [];
message.extension.push($root.google.protobuf.FieldDescriptorProto.decode(reader, reader.uint32()));
break;
}
case 8: {
message.options = $root.google.protobuf.FileOptions.decode(reader, reader.uint32());
break;
}
case 9: {
message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.decode(reader, reader.uint32());
break;
}
case 12: {
message.syntax = reader.string();
break;
}
case 14: {
message.edition = reader.int32();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a FileDescriptorProto message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof google.protobuf.FileDescriptorProto
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
FileDescriptorProto.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a FileDescriptorProto message.
* @function verify
* @memberof google.protobuf.FileDescriptorProto
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
FileDescriptorProto.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.name != null && message.hasOwnProperty("name"))
if (!$util.isString(message.name))
return "name: string expected";
if (message["package"] != null && message.hasOwnProperty("package"))
if (!$util.isString(message["package"]))
return "package: string expected";
if (message.dependency != null && message.hasOwnProperty("dependency")) {
if (!Array.isArray(message.dependency))
return "dependency: array expected";
for (var i = 0; i < message.dependency.length; ++i)
if (!$util.isString(message.dependency[i]))
return "dependency: string[] expected";
}
if (message.publicDependency != null && message.hasOwnProperty("publicDependency")) {
if (!Array.isArray(message.publicDependency))
return "publicDependency: array expected";
for (var i = 0; i < message.publicDependency.length; ++i)
if (!$util.isInteger(message.publicDependency[i]))
return "publicDependency: integer[] expected";
}
if (message.weakDependency != null && message.hasOwnProperty("weakDependency")) {
if (!Array.isArray(message.weakDependency))
return "weakDependency: array expected";
for (var i = 0; i < message.weakDependency.length; ++i)
if (!$util.isInteger(message.weakDependency[i]))
return "weakDependency: integer[] expected";
}
if (message.messageType != null && message.hasOwnProperty("messageType")) {
if (!Array.isArray(message.messageType))
return "messageType: array expected";
for (var i = 0; i < message.messageType.length; ++i) {
var error = $root.google.protobuf.DescriptorProto.verify(message.messageType[i]);
if (error)
return "messag