UNPKG

@moonset/model

Version:
1,114 lines (1,030 loc) 40.3 kB
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ "use strict"; var $protobuf = require("protobufjs/minimal"); // Common aliases var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; // Exported root namespace var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); $root.DataSet = (function() { /** * Properties of a DataSet. * @exports IDataSet * @interface IDataSet */ /** * Constructs a new DataSet. * @exports DataSet * @classdesc Represents a DataSet. * @implements IDataSet * @constructor * @param {IDataSet=} [properties] Properties to set */ function DataSet(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]]; } /** * Creates a new DataSet instance using the specified properties. * @function create * @memberof DataSet * @static * @param {IDataSet=} [properties] Properties to set * @returns {DataSet} DataSet instance */ DataSet.create = function create(properties) { return new DataSet(properties); }; /** * Encodes the specified DataSet message. Does not implicitly {@link DataSet.verify|verify} messages. * @function encode * @memberof DataSet * @static * @param {IDataSet} message DataSet message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ DataSet.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); return writer; }; /** * Encodes the specified DataSet message, length delimited. Does not implicitly {@link DataSet.verify|verify} messages. * @function encodeDelimited * @memberof DataSet * @static * @param {IDataSet} message DataSet message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ DataSet.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a DataSet message from the specified reader or buffer. * @function decode * @memberof DataSet * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {DataSet} DataSet * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ DataSet.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.DataSet(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a DataSet message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof DataSet * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {DataSet} DataSet * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ DataSet.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a DataSet message. * @function verify * @memberof DataSet * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ DataSet.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; return null; }; /** * Creates a DataSet message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof DataSet * @static * @param {Object.<string,*>} object Plain object * @returns {DataSet} DataSet */ DataSet.fromObject = function fromObject(object) { if (object instanceof $root.DataSet) return object; return new $root.DataSet(); }; /** * Creates a plain object from a DataSet message. Also converts values to other types if specified. * @function toObject * @memberof DataSet * @static * @param {DataSet} message DataSet * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ DataSet.toObject = function toObject() { return {}; }; /** * Converts this DataSet to JSON. * @function toJSON * @memberof DataSet * @instance * @returns {Object.<string,*>} JSON object */ DataSet.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return DataSet; })(); $root.Job = (function() { /** * Properties of a Job. * @exports IJob * @interface IJob * @property {Array.<IDataSet>|null} [input] Job input * @property {Array.<IDataSet>|null} [output] Job output * @property {Array.<ITask>|null} [task] Job task * @property {IPlatform|null} [platform] Job platform */ /** * Constructs a new Job. * @exports Job * @classdesc Represents a Job. * @implements IJob * @constructor * @param {IJob=} [properties] Properties to set */ function Job(properties) { this.input = []; this.output = []; this.task = []; 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]]; } /** * Job input. * @member {Array.<IDataSet>} input * @memberof Job * @instance */ Job.prototype.input = $util.emptyArray; /** * Job output. * @member {Array.<IDataSet>} output * @memberof Job * @instance */ Job.prototype.output = $util.emptyArray; /** * Job task. * @member {Array.<ITask>} task * @memberof Job * @instance */ Job.prototype.task = $util.emptyArray; /** * Job platform. * @member {IPlatform|null|undefined} platform * @memberof Job * @instance */ Job.prototype.platform = null; /** * Creates a new Job instance using the specified properties. * @function create * @memberof Job * @static * @param {IJob=} [properties] Properties to set * @returns {Job} Job instance */ Job.create = function create(properties) { return new Job(properties); }; /** * Encodes the specified Job message. Does not implicitly {@link Job.verify|verify} messages. * @function encode * @memberof Job * @static * @param {IJob} message Job message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Job.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.input != null && message.input.length) for (var i = 0; i < message.input.length; ++i) $root.DataSet.encode(message.input[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); if (message.output != null && message.output.length) for (var i = 0; i < message.output.length; ++i) $root.DataSet.encode(message.output[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.task != null && message.task.length) for (var i = 0; i < message.task.length; ++i) $root.Task.encode(message.task[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); if (message.platform != null && Object.hasOwnProperty.call(message, "platform")) $root.Platform.encode(message.platform, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); return writer; }; /** * Encodes the specified Job message, length delimited. Does not implicitly {@link Job.verify|verify} messages. * @function encodeDelimited * @memberof Job * @static * @param {IJob} message Job message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Job.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a Job message from the specified reader or buffer. * @function decode * @memberof Job * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {Job} Job * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Job.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Job(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: if (!(message.input && message.input.length)) message.input = []; message.input.push($root.DataSet.decode(reader, reader.uint32())); break; case 2: if (!(message.output && message.output.length)) message.output = []; message.output.push($root.DataSet.decode(reader, reader.uint32())); break; case 3: if (!(message.task && message.task.length)) message.task = []; message.task.push($root.Task.decode(reader, reader.uint32())); break; case 4: message.platform = $root.Platform.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a Job message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof Job * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {Job} Job * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Job.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a Job message. * @function verify * @memberof Job * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ Job.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.input != null && message.hasOwnProperty("input")) { if (!Array.isArray(message.input)) return "input: array expected"; for (var i = 0; i < message.input.length; ++i) { var error = $root.DataSet.verify(message.input[i]); if (error) return "input." + error; } } if (message.output != null && message.hasOwnProperty("output")) { if (!Array.isArray(message.output)) return "output: array expected"; for (var i = 0; i < message.output.length; ++i) { var error = $root.DataSet.verify(message.output[i]); if (error) return "output." + error; } } if (message.task != null && message.hasOwnProperty("task")) { if (!Array.isArray(message.task)) return "task: array expected"; for (var i = 0; i < message.task.length; ++i) { var error = $root.Task.verify(message.task[i]); if (error) return "task." + error; } } if (message.platform != null && message.hasOwnProperty("platform")) { var error = $root.Platform.verify(message.platform); if (error) return "platform." + error; } return null; }; /** * Creates a Job message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof Job * @static * @param {Object.<string,*>} object Plain object * @returns {Job} Job */ Job.fromObject = function fromObject(object) { if (object instanceof $root.Job) return object; var message = new $root.Job(); if (object.input) { if (!Array.isArray(object.input)) throw TypeError(".Job.input: array expected"); message.input = []; for (var i = 0; i < object.input.length; ++i) { if (typeof object.input[i] !== "object") throw TypeError(".Job.input: object expected"); message.input[i] = $root.DataSet.fromObject(object.input[i]); } } if (object.output) { if (!Array.isArray(object.output)) throw TypeError(".Job.output: array expected"); message.output = []; for (var i = 0; i < object.output.length; ++i) { if (typeof object.output[i] !== "object") throw TypeError(".Job.output: object expected"); message.output[i] = $root.DataSet.fromObject(object.output[i]); } } if (object.task) { if (!Array.isArray(object.task)) throw TypeError(".Job.task: array expected"); message.task = []; for (var i = 0; i < object.task.length; ++i) { if (typeof object.task[i] !== "object") throw TypeError(".Job.task: object expected"); message.task[i] = $root.Task.fromObject(object.task[i]); } } if (object.platform != null) { if (typeof object.platform !== "object") throw TypeError(".Job.platform: object expected"); message.platform = $root.Platform.fromObject(object.platform); } return message; }; /** * Creates a plain object from a Job message. Also converts values to other types if specified. * @function toObject * @memberof Job * @static * @param {Job} message Job * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ Job.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.arrays || options.defaults) { object.input = []; object.output = []; object.task = []; } if (options.defaults) object.platform = null; if (message.input && message.input.length) { object.input = []; for (var j = 0; j < message.input.length; ++j) object.input[j] = $root.DataSet.toObject(message.input[j], options); } if (message.output && message.output.length) { object.output = []; for (var j = 0; j < message.output.length; ++j) object.output[j] = $root.DataSet.toObject(message.output[j], options); } if (message.task && message.task.length) { object.task = []; for (var j = 0; j < message.task.length; ++j) object.task[j] = $root.Task.toObject(message.task[j], options); } if (message.platform != null && message.hasOwnProperty("platform")) object.platform = $root.Platform.toObject(message.platform, options); return object; }; /** * Converts this Job to JSON. * @function toJSON * @memberof Job * @instance * @returns {Object.<string,*>} JSON object */ Job.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return Job; })(); $root.Task = (function() { /** * Properties of a Task. * @exports ITask * @interface ITask */ /** * Constructs a new Task. * @exports Task * @classdesc Represents a Task. * @implements ITask * @constructor * @param {ITask=} [properties] Properties to set */ function Task(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]]; } /** * Creates a new Task instance using the specified properties. * @function create * @memberof Task * @static * @param {ITask=} [properties] Properties to set * @returns {Task} Task instance */ Task.create = function create(properties) { return new Task(properties); }; /** * Encodes the specified Task message. Does not implicitly {@link Task.verify|verify} messages. * @function encode * @memberof Task * @static * @param {ITask} message Task message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Task.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); return writer; }; /** * Encodes the specified Task message, length delimited. Does not implicitly {@link Task.verify|verify} messages. * @function encodeDelimited * @memberof Task * @static * @param {ITask} message Task message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Task.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a Task message from the specified reader or buffer. * @function decode * @memberof Task * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {Task} Task * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Task.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Task(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a Task message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof Task * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {Task} Task * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Task.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a Task message. * @function verify * @memberof Task * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ Task.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; return null; }; /** * Creates a Task message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof Task * @static * @param {Object.<string,*>} object Plain object * @returns {Task} Task */ Task.fromObject = function fromObject(object) { if (object instanceof $root.Task) return object; return new $root.Task(); }; /** * Creates a plain object from a Task message. Also converts values to other types if specified. * @function toObject * @memberof Task * @static * @param {Task} message Task * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ Task.toObject = function toObject() { return {}; }; /** * Converts this Task to JSON. * @function toJSON * @memberof Task * @instance * @returns {Object.<string,*>} JSON object */ Task.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return Task; })(); $root.Platform = (function() { /** * Properties of a Platform. * @exports IPlatform * @interface IPlatform * @property {string|null} [type] Platform type * @property {google.protobuf.IAny|null} [settings] Platform settings */ /** * Constructs a new Platform. * @exports Platform * @classdesc Represents a Platform. * @implements IPlatform * @constructor * @param {IPlatform=} [properties] Properties to set */ function Platform(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]]; } /** * Platform type. * @member {string} type * @memberof Platform * @instance */ Platform.prototype.type = ""; /** * Platform settings. * @member {google.protobuf.IAny|null|undefined} settings * @memberof Platform * @instance */ Platform.prototype.settings = null; /** * Creates a new Platform instance using the specified properties. * @function create * @memberof Platform * @static * @param {IPlatform=} [properties] Properties to set * @returns {Platform} Platform instance */ Platform.create = function create(properties) { return new Platform(properties); }; /** * Encodes the specified Platform message. Does not implicitly {@link Platform.verify|verify} messages. * @function encode * @memberof Platform * @static * @param {IPlatform} message Platform message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Platform.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.type != null && Object.hasOwnProperty.call(message, "type")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.type); if (message.settings != null && Object.hasOwnProperty.call(message, "settings")) $root.google.protobuf.Any.encode(message.settings, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; /** * Encodes the specified Platform message, length delimited. Does not implicitly {@link Platform.verify|verify} messages. * @function encodeDelimited * @memberof Platform * @static * @param {IPlatform} message Platform message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Platform.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a Platform message from the specified reader or buffer. * @function decode * @memberof Platform * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {Platform} Platform * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Platform.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Platform(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.type = reader.string(); break; case 2: message.settings = $root.google.protobuf.Any.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a Platform message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof Platform * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {Platform} Platform * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Platform.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a Platform message. * @function verify * @memberof Platform * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ Platform.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.type != null && message.hasOwnProperty("type")) if (!$util.isString(message.type)) return "type: string expected"; if (message.settings != null && message.hasOwnProperty("settings")) { var error = $root.google.protobuf.Any.verify(message.settings); if (error) return "settings." + error; } return null; }; /** * Creates a Platform message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof Platform * @static * @param {Object.<string,*>} object Plain object * @returns {Platform} Platform */ Platform.fromObject = function fromObject(object) { if (object instanceof $root.Platform) return object; var message = new $root.Platform(); if (object.type != null) message.type = String(object.type); if (object.settings != null) { if (typeof object.settings !== "object") throw TypeError(".Platform.settings: object expected"); message.settings = $root.google.protobuf.Any.fromObject(object.settings); } return message; }; /** * Creates a plain object from a Platform message. Also converts values to other types if specified. * @function toObject * @memberof Platform * @static * @param {Platform} message Platform * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ Platform.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { object.type = ""; object.settings = null; } if (message.type != null && message.hasOwnProperty("type")) object.type = message.type; if (message.settings != null && message.hasOwnProperty("settings")) object.settings = $root.google.protobuf.Any.toObject(message.settings, options); return object; }; /** * Converts this Platform to JSON. * @function toJSON * @memberof Platform * @instance * @returns {Object.<string,*>} JSON object */ Platform.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return Platform; })(); $root.google = (function() { /** * Namespace google. * @exports google * @namespace */ var google = {}; google.protobuf = (function() { /** * Namespace protobuf. * @memberof google * @namespace */ var protobuf = {}; protobuf.Any = (function() { /** * Properties of an Any. * @memberof google.protobuf * @interface IAny * @property {string|null} [type_url] Any type_url * @property {Uint8Array|null} [value] Any value */ /** * Constructs a new Any. * @memberof google.protobuf * @classdesc Represents an Any. * @implements IAny * @constructor * @param {google.protobuf.IAny=} [properties] Properties to set */ function Any(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]]; } /** * Any type_url. * @member {string} type_url * @memberof google.protobuf.Any * @instance */ Any.prototype.type_url = ""; /** * Any value. * @member {Uint8Array} value * @memberof google.protobuf.Any * @instance */ Any.prototype.value = $util.newBuffer([]); /** * Creates a new Any instance using the specified properties. * @function create * @memberof google.protobuf.Any * @static * @param {google.protobuf.IAny=} [properties] Properties to set * @returns {google.protobuf.Any} Any instance */ Any.create = function create(properties) { return new Any(properties); }; /** * Encodes the specified Any message. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. * @function encode * @memberof google.protobuf.Any * @static * @param {google.protobuf.IAny} message Any message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Any.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.type_url != null && Object.hasOwnProperty.call(message, "type_url")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.type_url); if (message.value != null && Object.hasOwnProperty.call(message, "value")) writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.value); return writer; }; /** * Encodes the specified Any message, length delimited. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. * @function encodeDelimited * @memberof google.protobuf.Any * @static * @param {google.protobuf.IAny} message Any message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Any.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes an Any message from the specified reader or buffer. * @function decode * @memberof google.protobuf.Any * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {google.protobuf.Any} Any * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Any.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Any(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.type_url = reader.string(); break; case 2: message.value = reader.bytes(); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes an Any message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof google.protobuf.Any * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {google.protobuf.Any} Any * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Any.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies an Any message. * @function verify * @memberof google.protobuf.Any * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ Any.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.type_url != null && message.hasOwnProperty("type_url")) if (!$util.isString(message.type_url)) return "type_url: string expected"; if (message.value != null && message.hasOwnProperty("value")) if (!(message.value && typeof message.value.length === "number" || $util.isString(message.value))) return "value: buffer expected"; return null; }; /** * Creates an Any message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof google.protobuf.Any * @static * @param {Object.<string,*>} object Plain object * @returns {google.protobuf.Any} Any */ Any.fromObject = function fromObject(object) { if (object instanceof $root.google.protobuf.Any) return object; var message = new $root.google.protobuf.Any(); if (object.type_url != null) message.type_url = String(object.type_url); if (object.value != null) if (typeof object.value === "string") $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); else if (object.value.length) message.value = object.value; return message; }; /** * Creates a plain object from an Any message. Also converts values to other types if specified. * @function toObject * @memberof google.protobuf.Any * @static * @param {google.protobuf.Any} message Any * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ Any.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { object.type_url = ""; if (options.bytes === String) object.value = ""; else { object.value = []; if (options.bytes !== Array) object.value = $util.newBuffer(object.value); } } if (message.type_url != null && message.hasOwnProperty("type_url")) object.type_url = message.type_url; if (message.value != null && message.hasOwnProperty("value")) object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; return object; }; /** * Converts this Any to JSON. * @function toJSON * @memberof google.protobuf.Any * @instance * @returns {Object.<string,*>} JSON object */ Any.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return Any; })(); return protobuf; })(); return google; })(); module.exports = $root;