HarshvardhanCn01/Voice-Assistant
0
1"use strict";2module.exports = common;3 4var commonRe = /\/|\./;5 6/**7 * Provides common type definitions.8 * Can also be used to provide additional google types or your own custom types.9 * @param {string} name Short name as in `google/protobuf/[name].proto` or full file name10 * @param {Object.<string,*>} json JSON definition within `google.protobuf` if a short name, otherwise the file's root definition11 * @returns {undefined}12 * @property {INamespace} google/protobuf/any.proto Any13 * @property {INamespace} google/protobuf/duration.proto Duration14 * @property {INamespace} google/protobuf/empty.proto Empty15 * @property {INamespace} google/protobuf/field_mask.proto FieldMask16 * @property {INamespace} google/protobuf/struct.proto Struct, Value, NullValue and ListValue17 * @property {INamespace} google/protobuf/timestamp.proto Timestamp18 * @property {INamespace} google/protobuf/wrappers.proto Wrappers19 * @example20 * // manually provides descriptor.proto (assumes google/protobuf/ namespace and .proto extension)21 * protobuf.common("descriptor", descriptorJson);22 *23 * // manually provides a custom definition (uses my.foo namespace)24 * protobuf.common("my/foo/bar.proto", myFooBarJson);25 */26function common(name, json) {27 if (!commonRe.test(name)) {28 name = "google/protobuf/" + name + ".proto";29 json = { nested: { google: { nested: { protobuf: { nested: json } } } } };30 }31 common[name] = json;32}33 34// Not provided because of limited use (feel free to discuss or to provide yourself):35//36// google/protobuf/descriptor.proto37// google/protobuf/source_context.proto38// google/protobuf/type.proto39//40// Stripped and pre-parsed versions of these non-bundled files are instead available as part of41// the repository or package within the google/protobuf directory.42 43common("any", {44 45 /**46 * Properties of a google.protobuf.Any message.47 * @interface IAny48 * @type {Object}49 * @property {string} [typeUrl]50 * @property {Uint8Array} [bytes]51 * @memberof common52 */53 Any: {54 fields: {55 type_url: {56 type: "string",57 id: 158 },59 value: {60 type: "bytes",61 id: 262 }63 }64 }65});66 67var timeType;68 69common("duration", {70 71 /**72 * Properties of a google.protobuf.Duration message.73 * @interface IDuration74 * @type {Object}75 * @property {number|Long} [seconds]76 * @property {number} [nanos]77 * @memberof common78 */79 Duration: timeType = {80 fields: {81 seconds: {82 type: "int64",83 id: 184 },85 nanos: {86 type: "int32",87 id: 288 }89 }90 }91});92 93common("timestamp", {94 95 /**96 * Properties of a google.protobuf.Timestamp message.97 * @interface ITimestamp98 * @type {Object}99 * @property {number|Long} [seconds]100 * @property {number} [nanos]101 * @memberof common102 */103 Timestamp: timeType104});105 106common("empty", {107 108 /**109 * Properties of a google.protobuf.Empty message.110 * @interface IEmpty111 * @memberof common112 */113 Empty: {114 fields: {}115 }116});117 118common("struct", {119 120 /**121 * Properties of a google.protobuf.Struct message.122 * @interface IStruct123 * @type {Object}124 * @property {Object.<string,IValue>} [fields]125 * @memberof common126 */127 Struct: {128 fields: {129 fields: {130 keyType: "string",131 type: "Value",132 id: 1133 }134 }135 },136 137 /**138 * Properties of a google.protobuf.Value message.139 * @interface IValue140 * @type {Object}141 * @property {string} [kind]142 * @property {0} [nullValue]143 * @property {number} [numberValue]144 * @property {string} [stringValue]145 * @property {boolean} [boolValue]146 * @property {IStruct} [structValue]147 * @property {IListValue} [listValue]148 * @memberof common149 */150 Value: {151 oneofs: {152 kind: {153 oneof: [154 "nullValue",155 "numberValue",156 "stringValue",157 "boolValue",158 "structValue",159 "listValue"160 ]161 }162 },163 fields: {164 nullValue: {165 type: "NullValue",166 id: 1167 },168 numberValue: {169 type: "double",170 id: 2171 },172 stringValue: {173 type: "string",174 id: 3175 },176 boolValue: {177 type: "bool",178 id: 4179 },180 structValue: {181 type: "Struct",182 id: 5183 },184 listValue: {185 type: "ListValue",186 id: 6187 }188 }189 },190 191 NullValue: {192 values: {193 NULL_VALUE: 0194 }195 },196 197 /**198 * Properties of a google.protobuf.ListValue message.199 * @interface IListValue200 * @type {Object}201 * @property {Array.<IValue>} [values]202 * @memberof common203 */204 ListValue: {205 fields: {206 values: {207 rule: "repeated",208 type: "Value",209 id: 1210 }211 }212 }213});214 215common("wrappers", {216 217 /**218 * Properties of a google.protobuf.DoubleValue message.219 * @interface IDoubleValue220 * @type {Object}221 * @property {number} [value]222 * @memberof common223 */224 DoubleValue: {225 fields: {226 value: {227 type: "double",228 id: 1229 }230 }231 },232 233 /**234 * Properties of a google.protobuf.FloatValue message.235 * @interface IFloatValue236 * @type {Object}237 * @property {number} [value]238 * @memberof common239 */240 FloatValue: {241 fields: {242 value: {243 type: "float",244 id: 1245 }246 }247 },248 249 /**250 * Properties of a google.protobuf.Int64Value message.251 * @interface IInt64Value252 * @type {Object}253 * @property {number|Long} [value]254 * @memberof common255 */256 Int64Value: {257 fields: {258 value: {259 type: "int64",260 id: 1261 }262 }263 },264 265 /**266 * Properties of a google.protobuf.UInt64Value message.267 * @interface IUInt64Value268 * @type {Object}269 * @property {number|Long} [value]270 * @memberof common271 */272 UInt64Value: {273 fields: {274 value: {275 type: "uint64",276 id: 1277 }278 }279 },280 281 /**282 * Properties of a google.protobuf.Int32Value message.283 * @interface IInt32Value284 * @type {Object}285 * @property {number} [value]286 * @memberof common287 */288 Int32Value: {289 fields: {290 value: {291 type: "int32",292 id: 1293 }294 }295 },296 297 /**298 * Properties of a google.protobuf.UInt32Value message.299 * @interface IUInt32Value300 * @type {Object}301 * @property {number} [value]302 * @memberof common303 */304 UInt32Value: {305 fields: {306 value: {307 type: "uint32",308 id: 1309 }310 }311 },312 313 /**314 * Properties of a google.protobuf.BoolValue message.315 * @interface IBoolValue316 * @type {Object}317 * @property {boolean} [value]318 * @memberof common319 */320 BoolValue: {321 fields: {322 value: {323 type: "bool",324 id: 1325 }326 }327 },328 329 /**330 * Properties of a google.protobuf.StringValue message.331 * @interface IStringValue332 * @type {Object}333 * @property {string} [value]334 * @memberof common335 */336 StringValue: {337 fields: {338 value: {339 type: "string",340 id: 1341 }342 }343 },344 345 /**346 * Properties of a google.protobuf.BytesValue message.347 * @interface IBytesValue348 * @type {Object}349 * @property {Uint8Array} [value]350 * @memberof common351 */352 BytesValue: {353 fields: {354 value: {355 type: "bytes",356 id: 1357 }358 }359 }360});361 362common("field_mask", {363 364 /**365 * Properties of a google.protobuf.FieldMask message.366 * @interface IDoubleValue367 * @type {Object}368 * @property {number} [value]369 * @memberof common370 */371 FieldMask: {372 fields: {373 paths: {374 rule: "repeated",375 type: "string",376 id: 1377 }378 }379 }380});381 382/**383 * Gets the root definition of the specified common proto file.384 *385 * Bundled definitions are:386 * - google/protobuf/any.proto387 * - google/protobuf/duration.proto388 * - google/protobuf/empty.proto389 * - google/protobuf/field_mask.proto390 * - google/protobuf/struct.proto391 * - google/protobuf/timestamp.proto392 * - google/protobuf/wrappers.proto393 *394 * @param {string} file Proto file name395 * @returns {INamespace|null} Root definition or `null` if not defined396 */397common.get = function get(file) {398 return common[file] || null;399};400 