Last active
February 6, 2018 07:48
-
-
Save agreatfool/5c49dad4f3360d4b49895232c8a24347 to your computer and use it in GitHub Desktop.
Static codes generated by protobuf.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as $protobuf from "protobufjs"; | |
/** Namespace com. */ | |
export namespace com { | |
/** Namespace book. */ | |
namespace book { | |
/** Properties of a Book. */ | |
interface IBook { | |
/** Book isbn */ | |
isbn?: (number|Long|null); | |
/** Book title */ | |
title?: (string|null); | |
/** Book author */ | |
author?: (string|null); | |
} | |
/** Represents a Book. */ | |
class Book implements IBook { | |
/** | |
* Constructs a new Book. | |
* @param [properties] Properties to set | |
*/ | |
constructor(properties?: com.book.IBook); | |
/** Book isbn. */ | |
public isbn: (number|Long); | |
/** Book title. */ | |
public title: string; | |
/** Book author. */ | |
public author: string; | |
/** | |
* Creates a new Book instance using the specified properties. | |
* @param [properties] Properties to set | |
* @returns Book instance | |
*/ | |
public static create(properties?: com.book.IBook): com.book.Book; | |
/** | |
* Encodes the specified Book message. Does not implicitly {@link com.book.Book.verify|verify} messages. | |
* @param message Book message or plain object to encode | |
* @param [writer] Writer to encode to | |
* @returns Writer | |
*/ | |
public static encode(message: com.book.IBook, writer?: $protobuf.Writer): $protobuf.Writer; | |
/** | |
* Encodes the specified Book message, length delimited. Does not implicitly {@link com.book.Book.verify|verify} messages. | |
* @param message Book message or plain object to encode | |
* @param [writer] Writer to encode to | |
* @returns Writer | |
*/ | |
public static encodeDelimited(message: com.book.IBook, writer?: $protobuf.Writer): $protobuf.Writer; | |
/** | |
* Decodes a Book message from the specified reader or buffer. | |
* @param reader Reader or buffer to decode from | |
* @param [length] Message length if known beforehand | |
* @returns Book | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): com.book.Book; | |
/** | |
* Decodes a Book message from the specified reader or buffer, length delimited. | |
* @param reader Reader or buffer to decode from | |
* @returns Book | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): com.book.Book; | |
/** | |
* Verifies a Book message. | |
* @param message Plain object to verify | |
* @returns `null` if valid, otherwise the reason why it is not | |
*/ | |
public static verify(message: { [k: string]: any }): (string|null); | |
/** | |
* Creates a Book message from a plain object. Also converts values to their respective internal types. | |
* @param object Plain object | |
* @returns Book | |
*/ | |
public static fromObject(object: { [k: string]: any }): com.book.Book; | |
/** | |
* Creates a plain object from a Book message. Also converts values to other types if specified. | |
* @param message Book | |
* @param [options] Conversion options | |
* @returns Plain object | |
*/ | |
public static toObject(message: com.book.Book, options?: $protobuf.IConversionOptions): { [k: string]: any }; | |
/** | |
* Converts this Book to JSON. | |
* @returns JSON object | |
*/ | |
public toJSON(): { [k: string]: any }; | |
} | |
/** Properties of a GetBookRequest. */ | |
interface IGetBookRequest { | |
/** GetBookRequest isbn */ | |
isbn?: (number|Long|null); | |
} | |
/** Represents a GetBookRequest. */ | |
class GetBookRequest implements IGetBookRequest { | |
/** | |
* Constructs a new GetBookRequest. | |
* @param [properties] Properties to set | |
*/ | |
constructor(properties?: com.book.IGetBookRequest); | |
/** GetBookRequest isbn. */ | |
public isbn: (number|Long); | |
/** | |
* Creates a new GetBookRequest instance using the specified properties. | |
* @param [properties] Properties to set | |
* @returns GetBookRequest instance | |
*/ | |
public static create(properties?: com.book.IGetBookRequest): com.book.GetBookRequest; | |
/** | |
* Encodes the specified GetBookRequest message. Does not implicitly {@link com.book.GetBookRequest.verify|verify} messages. | |
* @param message GetBookRequest message or plain object to encode | |
* @param [writer] Writer to encode to | |
* @returns Writer | |
*/ | |
public static encode(message: com.book.IGetBookRequest, writer?: $protobuf.Writer): $protobuf.Writer; | |
/** | |
* Encodes the specified GetBookRequest message, length delimited. Does not implicitly {@link com.book.GetBookRequest.verify|verify} messages. | |
* @param message GetBookRequest message or plain object to encode | |
* @param [writer] Writer to encode to | |
* @returns Writer | |
*/ | |
public static encodeDelimited(message: com.book.IGetBookRequest, writer?: $protobuf.Writer): $protobuf.Writer; | |
/** | |
* Decodes a GetBookRequest message from the specified reader or buffer. | |
* @param reader Reader or buffer to decode from | |
* @param [length] Message length if known beforehand | |
* @returns GetBookRequest | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): com.book.GetBookRequest; | |
/** | |
* Decodes a GetBookRequest message from the specified reader or buffer, length delimited. | |
* @param reader Reader or buffer to decode from | |
* @returns GetBookRequest | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): com.book.GetBookRequest; | |
/** | |
* Verifies a GetBookRequest message. | |
* @param message Plain object to verify | |
* @returns `null` if valid, otherwise the reason why it is not | |
*/ | |
public static verify(message: { [k: string]: any }): (string|null); | |
/** | |
* Creates a GetBookRequest message from a plain object. Also converts values to their respective internal types. | |
* @param object Plain object | |
* @returns GetBookRequest | |
*/ | |
public static fromObject(object: { [k: string]: any }): com.book.GetBookRequest; | |
/** | |
* Creates a plain object from a GetBookRequest message. Also converts values to other types if specified. | |
* @param message GetBookRequest | |
* @param [options] Conversion options | |
* @returns Plain object | |
*/ | |
public static toObject(message: com.book.GetBookRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; | |
/** | |
* Converts this GetBookRequest to JSON. | |
* @returns JSON object | |
*/ | |
public toJSON(): { [k: string]: any }; | |
} | |
/** Properties of a GetBookViaAuthor. */ | |
interface IGetBookViaAuthor { | |
/** GetBookViaAuthor author */ | |
author?: (string|null); | |
} | |
/** Represents a GetBookViaAuthor. */ | |
class GetBookViaAuthor implements IGetBookViaAuthor { | |
/** | |
* Constructs a new GetBookViaAuthor. | |
* @param [properties] Properties to set | |
*/ | |
constructor(properties?: com.book.IGetBookViaAuthor); | |
/** GetBookViaAuthor author. */ | |
public author: string; | |
/** | |
* Creates a new GetBookViaAuthor instance using the specified properties. | |
* @param [properties] Properties to set | |
* @returns GetBookViaAuthor instance | |
*/ | |
public static create(properties?: com.book.IGetBookViaAuthor): com.book.GetBookViaAuthor; | |
/** | |
* Encodes the specified GetBookViaAuthor message. Does not implicitly {@link com.book.GetBookViaAuthor.verify|verify} messages. | |
* @param message GetBookViaAuthor message or plain object to encode | |
* @param [writer] Writer to encode to | |
* @returns Writer | |
*/ | |
public static encode(message: com.book.IGetBookViaAuthor, writer?: $protobuf.Writer): $protobuf.Writer; | |
/** | |
* Encodes the specified GetBookViaAuthor message, length delimited. Does not implicitly {@link com.book.GetBookViaAuthor.verify|verify} messages. | |
* @param message GetBookViaAuthor message or plain object to encode | |
* @param [writer] Writer to encode to | |
* @returns Writer | |
*/ | |
public static encodeDelimited(message: com.book.IGetBookViaAuthor, writer?: $protobuf.Writer): $protobuf.Writer; | |
/** | |
* Decodes a GetBookViaAuthor message from the specified reader or buffer. | |
* @param reader Reader or buffer to decode from | |
* @param [length] Message length if known beforehand | |
* @returns GetBookViaAuthor | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): com.book.GetBookViaAuthor; | |
/** | |
* Decodes a GetBookViaAuthor message from the specified reader or buffer, length delimited. | |
* @param reader Reader or buffer to decode from | |
* @returns GetBookViaAuthor | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): com.book.GetBookViaAuthor; | |
/** | |
* Verifies a GetBookViaAuthor message. | |
* @param message Plain object to verify | |
* @returns `null` if valid, otherwise the reason why it is not | |
*/ | |
public static verify(message: { [k: string]: any }): (string|null); | |
/** | |
* Creates a GetBookViaAuthor message from a plain object. Also converts values to their respective internal types. | |
* @param object Plain object | |
* @returns GetBookViaAuthor | |
*/ | |
public static fromObject(object: { [k: string]: any }): com.book.GetBookViaAuthor; | |
/** | |
* Creates a plain object from a GetBookViaAuthor message. Also converts values to other types if specified. | |
* @param message GetBookViaAuthor | |
* @param [options] Conversion options | |
* @returns Plain object | |
*/ | |
public static toObject(message: com.book.GetBookViaAuthor, options?: $protobuf.IConversionOptions): { [k: string]: any }; | |
/** | |
* Converts this GetBookViaAuthor to JSON. | |
* @returns JSON object | |
*/ | |
public toJSON(): { [k: string]: any }; | |
} | |
/** Represents a BookService */ | |
class BookService extends $protobuf.rpc.Service { | |
/** | |
* Constructs a new BookService service. | |
* @param rpcImpl RPC implementation | |
* @param [requestDelimited=false] Whether requests are length-delimited | |
* @param [responseDelimited=false] Whether responses are length-delimited | |
*/ | |
constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); | |
/** | |
* Creates new BookService service using the specified rpc implementation. | |
* @param rpcImpl RPC implementation | |
* @param [requestDelimited=false] Whether requests are length-delimited | |
* @param [responseDelimited=false] Whether responses are length-delimited | |
* @returns RPC service. Useful where requests and/or responses are streamed. | |
*/ | |
public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): BookService; | |
/** | |
* Calls GetBook. | |
* @param request GetBookRequest message or plain object | |
* @param callback Node-style callback called with the error, if any, and Book | |
*/ | |
public getBook(request: com.book.IGetBookRequest, callback: com.book.BookService.GetBookCallback): void; | |
/** | |
* Calls GetBook. | |
* @param request GetBookRequest message or plain object | |
* @returns Promise | |
*/ | |
public getBook(request: com.book.IGetBookRequest): Promise<com.book.Book>; | |
/** | |
* Calls GetBooksViaAuthor. | |
* @param request GetBookViaAuthor message or plain object | |
* @param callback Node-style callback called with the error, if any, and Book | |
*/ | |
public getBooksViaAuthor(request: com.book.IGetBookViaAuthor, callback: com.book.BookService.GetBooksViaAuthorCallback): void; | |
/** | |
* Calls GetBooksViaAuthor. | |
* @param request GetBookViaAuthor message or plain object | |
* @returns Promise | |
*/ | |
public getBooksViaAuthor(request: com.book.IGetBookViaAuthor): Promise<com.book.Book>; | |
/** | |
* Calls GetGreatestBook. | |
* @param request GetBookRequest message or plain object | |
* @param callback Node-style callback called with the error, if any, and Book | |
*/ | |
public getGreatestBook(request: com.book.IGetBookRequest, callback: com.book.BookService.GetGreatestBookCallback): void; | |
/** | |
* Calls GetGreatestBook. | |
* @param request GetBookRequest message or plain object | |
* @returns Promise | |
*/ | |
public getGreatestBook(request: com.book.IGetBookRequest): Promise<com.book.Book>; | |
/** | |
* Calls GetBooks. | |
* @param request GetBookRequest message or plain object | |
* @param callback Node-style callback called with the error, if any, and Book | |
*/ | |
public getBooks(request: com.book.IGetBookRequest, callback: com.book.BookService.GetBooksCallback): void; | |
/** | |
* Calls GetBooks. | |
* @param request GetBookRequest message or plain object | |
* @returns Promise | |
*/ | |
public getBooks(request: com.book.IGetBookRequest): Promise<com.book.Book>; | |
} | |
namespace BookService { | |
/** | |
* Callback as used by {@link com.book.BookService#getBook}. | |
* @param error Error, if any | |
* @param [response] Book | |
*/ | |
type GetBookCallback = (error: (Error|null), response?: com.book.Book) => void; | |
/** | |
* Callback as used by {@link com.book.BookService#getBooksViaAuthor}. | |
* @param error Error, if any | |
* @param [response] Book | |
*/ | |
type GetBooksViaAuthorCallback = (error: (Error|null), response?: com.book.Book) => void; | |
/** | |
* Callback as used by {@link com.book.BookService#getGreatestBook}. | |
* @param error Error, if any | |
* @param [response] Book | |
*/ | |
type GetGreatestBookCallback = (error: (Error|null), response?: com.book.Book) => void; | |
/** | |
* Callback as used by {@link com.book.BookService#getBooks}. | |
* @param error Error, if any | |
* @param [response] Book | |
*/ | |
type GetBooksCallback = (error: (Error|null), response?: com.book.Book) => void; | |
} | |
/** Properties of a BookStore. */ | |
interface IBookStore { | |
/** BookStore name */ | |
name?: (string|null); | |
/** BookStore books */ | |
books?: ({ [k: string]: string }|null); | |
} | |
/** Represents a BookStore. */ | |
class BookStore implements IBookStore { | |
/** | |
* Constructs a new BookStore. | |
* @param [properties] Properties to set | |
*/ | |
constructor(properties?: com.book.IBookStore); | |
/** BookStore name. */ | |
public name: string; | |
/** BookStore books. */ | |
public books: { [k: string]: string }; | |
/** | |
* Creates a new BookStore instance using the specified properties. | |
* @param [properties] Properties to set | |
* @returns BookStore instance | |
*/ | |
public static create(properties?: com.book.IBookStore): com.book.BookStore; | |
/** | |
* Encodes the specified BookStore message. Does not implicitly {@link com.book.BookStore.verify|verify} messages. | |
* @param message BookStore message or plain object to encode | |
* @param [writer] Writer to encode to | |
* @returns Writer | |
*/ | |
public static encode(message: com.book.IBookStore, writer?: $protobuf.Writer): $protobuf.Writer; | |
/** | |
* Encodes the specified BookStore message, length delimited. Does not implicitly {@link com.book.BookStore.verify|verify} messages. | |
* @param message BookStore message or plain object to encode | |
* @param [writer] Writer to encode to | |
* @returns Writer | |
*/ | |
public static encodeDelimited(message: com.book.IBookStore, writer?: $protobuf.Writer): $protobuf.Writer; | |
/** | |
* Decodes a BookStore message from the specified reader or buffer. | |
* @param reader Reader or buffer to decode from | |
* @param [length] Message length if known beforehand | |
* @returns BookStore | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): com.book.BookStore; | |
/** | |
* Decodes a BookStore message from the specified reader or buffer, length delimited. | |
* @param reader Reader or buffer to decode from | |
* @returns BookStore | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): com.book.BookStore; | |
/** | |
* Verifies a BookStore message. | |
* @param message Plain object to verify | |
* @returns `null` if valid, otherwise the reason why it is not | |
*/ | |
public static verify(message: { [k: string]: any }): (string|null); | |
/** | |
* Creates a BookStore message from a plain object. Also converts values to their respective internal types. | |
* @param object Plain object | |
* @returns BookStore | |
*/ | |
public static fromObject(object: { [k: string]: any }): com.book.BookStore; | |
/** | |
* Creates a plain object from a BookStore message. Also converts values to other types if specified. | |
* @param message BookStore | |
* @param [options] Conversion options | |
* @returns Plain object | |
*/ | |
public static toObject(message: com.book.BookStore, options?: $protobuf.IConversionOptions): { [k: string]: any }; | |
/** | |
* Converts this BookStore to JSON. | |
* @returns JSON object | |
*/ | |
public toJSON(): { [k: string]: any }; | |
} | |
/** EnumSample enum. */ | |
enum EnumSample { | |
UNKNOWN = 0, | |
STARTED = 1, | |
RUNNING = 1 | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins*/ | |
"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.com = (function() { | |
/** | |
* Namespace com. | |
* @exports com | |
* @namespace | |
*/ | |
var com = {}; | |
com.book = (function() { | |
/** | |
* Namespace book. | |
* @memberof com | |
* @namespace | |
*/ | |
var book = {}; | |
book.Book = (function() { | |
/** | |
* Properties of a Book. | |
* @memberof com.book | |
* @interface IBook | |
* @property {number|Long|null} [isbn] Book isbn | |
* @property {string|null} [title] Book title | |
* @property {string|null} [author] Book author | |
*/ | |
/** | |
* Constructs a new Book. | |
* @memberof com.book | |
* @classdesc Represents a Book. | |
* @implements IBook | |
* @constructor | |
* @param {com.book.IBook=} [properties] Properties to set | |
*/ | |
function Book(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]]; | |
} | |
/** | |
* Book isbn. | |
* @member {number|Long} isbn | |
* @memberof com.book.Book | |
* @instance | |
*/ | |
Book.prototype.isbn = $util.Long ? $util.Long.fromBits(0,0,false) : 0; | |
/** | |
* Book title. | |
* @member {string} title | |
* @memberof com.book.Book | |
* @instance | |
*/ | |
Book.prototype.title = ""; | |
/** | |
* Book author. | |
* @member {string} author | |
* @memberof com.book.Book | |
* @instance | |
*/ | |
Book.prototype.author = ""; | |
/** | |
* Creates a new Book instance using the specified properties. | |
* @function create | |
* @memberof com.book.Book | |
* @static | |
* @param {com.book.IBook=} [properties] Properties to set | |
* @returns {com.book.Book} Book instance | |
*/ | |
Book.create = function create(properties) { | |
return new Book(properties); | |
}; | |
/** | |
* Encodes the specified Book message. Does not implicitly {@link com.book.Book.verify|verify} messages. | |
* @function encode | |
* @memberof com.book.Book | |
* @static | |
* @param {com.book.IBook} message Book message or plain object to encode | |
* @param {$protobuf.Writer} [writer] Writer to encode to | |
* @returns {$protobuf.Writer} Writer | |
*/ | |
Book.encode = function encode(message, writer) { | |
if (!writer) | |
writer = $Writer.create(); | |
if (message.isbn != null && message.hasOwnProperty("isbn")) | |
writer.uint32(/* id 1, wireType 0 =*/8).int64(message.isbn); | |
if (message.title != null && message.hasOwnProperty("title")) | |
writer.uint32(/* id 2, wireType 2 =*/18).string(message.title); | |
if (message.author != null && message.hasOwnProperty("author")) | |
writer.uint32(/* id 3, wireType 2 =*/26).string(message.author); | |
return writer; | |
}; | |
/** | |
* Encodes the specified Book message, length delimited. Does not implicitly {@link com.book.Book.verify|verify} messages. | |
* @function encodeDelimited | |
* @memberof com.book.Book | |
* @static | |
* @param {com.book.IBook} message Book message or plain object to encode | |
* @param {$protobuf.Writer} [writer] Writer to encode to | |
* @returns {$protobuf.Writer} Writer | |
*/ | |
Book.encodeDelimited = function encodeDelimited(message, writer) { | |
return this.encode(message, writer).ldelim(); | |
}; | |
/** | |
* Decodes a Book message from the specified reader or buffer. | |
* @function decode | |
* @memberof com.book.Book | |
* @static | |
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from | |
* @param {number} [length] Message length if known beforehand | |
* @returns {com.book.Book} Book | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
Book.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.com.book.Book(); | |
while (reader.pos < end) { | |
var tag = reader.uint32(); | |
switch (tag >>> 3) { | |
case 1: | |
message.isbn = reader.int64(); | |
break; | |
case 2: | |
message.title = reader.string(); | |
break; | |
case 3: | |
message.author = reader.string(); | |
break; | |
default: | |
reader.skipType(tag & 7); | |
break; | |
} | |
} | |
return message; | |
}; | |
/** | |
* Decodes a Book message from the specified reader or buffer, length delimited. | |
* @function decodeDelimited | |
* @memberof com.book.Book | |
* @static | |
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from | |
* @returns {com.book.Book} Book | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
Book.decodeDelimited = function decodeDelimited(reader) { | |
if (!(reader instanceof $Reader)) | |
reader = new $Reader(reader); | |
return this.decode(reader, reader.uint32()); | |
}; | |
/** | |
* Verifies a Book message. | |
* @function verify | |
* @memberof com.book.Book | |
* @static | |
* @param {Object.<string,*>} message Plain object to verify | |
* @returns {string|null} `null` if valid, otherwise the reason why it is not | |
*/ | |
Book.verify = function verify(message) { | |
if (typeof message !== "object" || message === null) | |
return "object expected"; | |
if (message.isbn != null && message.hasOwnProperty("isbn")) | |
if (!$util.isInteger(message.isbn) && !(message.isbn && $util.isInteger(message.isbn.low) && $util.isInteger(message.isbn.high))) | |
return "isbn: integer|Long expected"; | |
if (message.title != null && message.hasOwnProperty("title")) | |
if (!$util.isString(message.title)) | |
return "title: string expected"; | |
if (message.author != null && message.hasOwnProperty("author")) | |
if (!$util.isString(message.author)) | |
return "author: string expected"; | |
return null; | |
}; | |
/** | |
* Creates a Book message from a plain object. Also converts values to their respective internal types. | |
* @function fromObject | |
* @memberof com.book.Book | |
* @static | |
* @param {Object.<string,*>} object Plain object | |
* @returns {com.book.Book} Book | |
*/ | |
Book.fromObject = function fromObject(object) { | |
if (object instanceof $root.com.book.Book) | |
return object; | |
var message = new $root.com.book.Book(); | |
if (object.isbn != null) | |
if ($util.Long) | |
(message.isbn = $util.Long.fromValue(object.isbn)).unsigned = false; | |
else if (typeof object.isbn === "string") | |
message.isbn = parseInt(object.isbn, 10); | |
else if (typeof object.isbn === "number") | |
message.isbn = object.isbn; | |
else if (typeof object.isbn === "object") | |
message.isbn = new $util.LongBits(object.isbn.low >>> 0, object.isbn.high >>> 0).toNumber(); | |
if (object.title != null) | |
message.title = String(object.title); | |
if (object.author != null) | |
message.author = String(object.author); | |
return message; | |
}; | |
/** | |
* Creates a plain object from a Book message. Also converts values to other types if specified. | |
* @function toObject | |
* @memberof com.book.Book | |
* @static | |
* @param {com.book.Book} message Book | |
* @param {$protobuf.IConversionOptions} [options] Conversion options | |
* @returns {Object.<string,*>} Plain object | |
*/ | |
Book.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.isbn = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; | |
} else | |
object.isbn = options.longs === String ? "0" : 0; | |
object.title = ""; | |
object.author = ""; | |
} | |
if (message.isbn != null && message.hasOwnProperty("isbn")) | |
if (typeof message.isbn === "number") | |
object.isbn = options.longs === String ? String(message.isbn) : message.isbn; | |
else | |
object.isbn = options.longs === String ? $util.Long.prototype.toString.call(message.isbn) : options.longs === Number ? new $util.LongBits(message.isbn.low >>> 0, message.isbn.high >>> 0).toNumber() : message.isbn; | |
if (message.title != null && message.hasOwnProperty("title")) | |
object.title = message.title; | |
if (message.author != null && message.hasOwnProperty("author")) | |
object.author = message.author; | |
return object; | |
}; | |
/** | |
* Converts this Book to JSON. | |
* @function toJSON | |
* @memberof com.book.Book | |
* @instance | |
* @returns {Object.<string,*>} JSON object | |
*/ | |
Book.prototype.toJSON = function toJSON() { | |
return this.constructor.toObject(this, $protobuf.util.toJSONOptions); | |
}; | |
return Book; | |
})(); | |
book.GetBookRequest = (function() { | |
/** | |
* Properties of a GetBookRequest. | |
* @memberof com.book | |
* @interface IGetBookRequest | |
* @property {number|Long|null} [isbn] GetBookRequest isbn | |
*/ | |
/** | |
* Constructs a new GetBookRequest. | |
* @memberof com.book | |
* @classdesc Represents a GetBookRequest. | |
* @implements IGetBookRequest | |
* @constructor | |
* @param {com.book.IGetBookRequest=} [properties] Properties to set | |
*/ | |
function GetBookRequest(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]]; | |
} | |
/** | |
* GetBookRequest isbn. | |
* @member {number|Long} isbn | |
* @memberof com.book.GetBookRequest | |
* @instance | |
*/ | |
GetBookRequest.prototype.isbn = $util.Long ? $util.Long.fromBits(0,0,false) : 0; | |
/** | |
* Creates a new GetBookRequest instance using the specified properties. | |
* @function create | |
* @memberof com.book.GetBookRequest | |
* @static | |
* @param {com.book.IGetBookRequest=} [properties] Properties to set | |
* @returns {com.book.GetBookRequest} GetBookRequest instance | |
*/ | |
GetBookRequest.create = function create(properties) { | |
return new GetBookRequest(properties); | |
}; | |
/** | |
* Encodes the specified GetBookRequest message. Does not implicitly {@link com.book.GetBookRequest.verify|verify} messages. | |
* @function encode | |
* @memberof com.book.GetBookRequest | |
* @static | |
* @param {com.book.IGetBookRequest} message GetBookRequest message or plain object to encode | |
* @param {$protobuf.Writer} [writer] Writer to encode to | |
* @returns {$protobuf.Writer} Writer | |
*/ | |
GetBookRequest.encode = function encode(message, writer) { | |
if (!writer) | |
writer = $Writer.create(); | |
if (message.isbn != null && message.hasOwnProperty("isbn")) | |
writer.uint32(/* id 1, wireType 0 =*/8).int64(message.isbn); | |
return writer; | |
}; | |
/** | |
* Encodes the specified GetBookRequest message, length delimited. Does not implicitly {@link com.book.GetBookRequest.verify|verify} messages. | |
* @function encodeDelimited | |
* @memberof com.book.GetBookRequest | |
* @static | |
* @param {com.book.IGetBookRequest} message GetBookRequest message or plain object to encode | |
* @param {$protobuf.Writer} [writer] Writer to encode to | |
* @returns {$protobuf.Writer} Writer | |
*/ | |
GetBookRequest.encodeDelimited = function encodeDelimited(message, writer) { | |
return this.encode(message, writer).ldelim(); | |
}; | |
/** | |
* Decodes a GetBookRequest message from the specified reader or buffer. | |
* @function decode | |
* @memberof com.book.GetBookRequest | |
* @static | |
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from | |
* @param {number} [length] Message length if known beforehand | |
* @returns {com.book.GetBookRequest} GetBookRequest | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
GetBookRequest.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.com.book.GetBookRequest(); | |
while (reader.pos < end) { | |
var tag = reader.uint32(); | |
switch (tag >>> 3) { | |
case 1: | |
message.isbn = reader.int64(); | |
break; | |
default: | |
reader.skipType(tag & 7); | |
break; | |
} | |
} | |
return message; | |
}; | |
/** | |
* Decodes a GetBookRequest message from the specified reader or buffer, length delimited. | |
* @function decodeDelimited | |
* @memberof com.book.GetBookRequest | |
* @static | |
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from | |
* @returns {com.book.GetBookRequest} GetBookRequest | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
GetBookRequest.decodeDelimited = function decodeDelimited(reader) { | |
if (!(reader instanceof $Reader)) | |
reader = new $Reader(reader); | |
return this.decode(reader, reader.uint32()); | |
}; | |
/** | |
* Verifies a GetBookRequest message. | |
* @function verify | |
* @memberof com.book.GetBookRequest | |
* @static | |
* @param {Object.<string,*>} message Plain object to verify | |
* @returns {string|null} `null` if valid, otherwise the reason why it is not | |
*/ | |
GetBookRequest.verify = function verify(message) { | |
if (typeof message !== "object" || message === null) | |
return "object expected"; | |
if (message.isbn != null && message.hasOwnProperty("isbn")) | |
if (!$util.isInteger(message.isbn) && !(message.isbn && $util.isInteger(message.isbn.low) && $util.isInteger(message.isbn.high))) | |
return "isbn: integer|Long expected"; | |
return null; | |
}; | |
/** | |
* Creates a GetBookRequest message from a plain object. Also converts values to their respective internal types. | |
* @function fromObject | |
* @memberof com.book.GetBookRequest | |
* @static | |
* @param {Object.<string,*>} object Plain object | |
* @returns {com.book.GetBookRequest} GetBookRequest | |
*/ | |
GetBookRequest.fromObject = function fromObject(object) { | |
if (object instanceof $root.com.book.GetBookRequest) | |
return object; | |
var message = new $root.com.book.GetBookRequest(); | |
if (object.isbn != null) | |
if ($util.Long) | |
(message.isbn = $util.Long.fromValue(object.isbn)).unsigned = false; | |
else if (typeof object.isbn === "string") | |
message.isbn = parseInt(object.isbn, 10); | |
else if (typeof object.isbn === "number") | |
message.isbn = object.isbn; | |
else if (typeof object.isbn === "object") | |
message.isbn = new $util.LongBits(object.isbn.low >>> 0, object.isbn.high >>> 0).toNumber(); | |
return message; | |
}; | |
/** | |
* Creates a plain object from a GetBookRequest message. Also converts values to other types if specified. | |
* @function toObject | |
* @memberof com.book.GetBookRequest | |
* @static | |
* @param {com.book.GetBookRequest} message GetBookRequest | |
* @param {$protobuf.IConversionOptions} [options] Conversion options | |
* @returns {Object.<string,*>} Plain object | |
*/ | |
GetBookRequest.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.isbn = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; | |
} else | |
object.isbn = options.longs === String ? "0" : 0; | |
if (message.isbn != null && message.hasOwnProperty("isbn")) | |
if (typeof message.isbn === "number") | |
object.isbn = options.longs === String ? String(message.isbn) : message.isbn; | |
else | |
object.isbn = options.longs === String ? $util.Long.prototype.toString.call(message.isbn) : options.longs === Number ? new $util.LongBits(message.isbn.low >>> 0, message.isbn.high >>> 0).toNumber() : message.isbn; | |
return object; | |
}; | |
/** | |
* Converts this GetBookRequest to JSON. | |
* @function toJSON | |
* @memberof com.book.GetBookRequest | |
* @instance | |
* @returns {Object.<string,*>} JSON object | |
*/ | |
GetBookRequest.prototype.toJSON = function toJSON() { | |
return this.constructor.toObject(this, $protobuf.util.toJSONOptions); | |
}; | |
return GetBookRequest; | |
})(); | |
book.GetBookViaAuthor = (function() { | |
/** | |
* Properties of a GetBookViaAuthor. | |
* @memberof com.book | |
* @interface IGetBookViaAuthor | |
* @property {string|null} [author] GetBookViaAuthor author | |
*/ | |
/** | |
* Constructs a new GetBookViaAuthor. | |
* @memberof com.book | |
* @classdesc Represents a GetBookViaAuthor. | |
* @implements IGetBookViaAuthor | |
* @constructor | |
* @param {com.book.IGetBookViaAuthor=} [properties] Properties to set | |
*/ | |
function GetBookViaAuthor(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]]; | |
} | |
/** | |
* GetBookViaAuthor author. | |
* @member {string} author | |
* @memberof com.book.GetBookViaAuthor | |
* @instance | |
*/ | |
GetBookViaAuthor.prototype.author = ""; | |
/** | |
* Creates a new GetBookViaAuthor instance using the specified properties. | |
* @function create | |
* @memberof com.book.GetBookViaAuthor | |
* @static | |
* @param {com.book.IGetBookViaAuthor=} [properties] Properties to set | |
* @returns {com.book.GetBookViaAuthor} GetBookViaAuthor instance | |
*/ | |
GetBookViaAuthor.create = function create(properties) { | |
return new GetBookViaAuthor(properties); | |
}; | |
/** | |
* Encodes the specified GetBookViaAuthor message. Does not implicitly {@link com.book.GetBookViaAuthor.verify|verify} messages. | |
* @function encode | |
* @memberof com.book.GetBookViaAuthor | |
* @static | |
* @param {com.book.IGetBookViaAuthor} message GetBookViaAuthor message or plain object to encode | |
* @param {$protobuf.Writer} [writer] Writer to encode to | |
* @returns {$protobuf.Writer} Writer | |
*/ | |
GetBookViaAuthor.encode = function encode(message, writer) { | |
if (!writer) | |
writer = $Writer.create(); | |
if (message.author != null && message.hasOwnProperty("author")) | |
writer.uint32(/* id 1, wireType 2 =*/10).string(message.author); | |
return writer; | |
}; | |
/** | |
* Encodes the specified GetBookViaAuthor message, length delimited. Does not implicitly {@link com.book.GetBookViaAuthor.verify|verify} messages. | |
* @function encodeDelimited | |
* @memberof com.book.GetBookViaAuthor | |
* @static | |
* @param {com.book.IGetBookViaAuthor} message GetBookViaAuthor message or plain object to encode | |
* @param {$protobuf.Writer} [writer] Writer to encode to | |
* @returns {$protobuf.Writer} Writer | |
*/ | |
GetBookViaAuthor.encodeDelimited = function encodeDelimited(message, writer) { | |
return this.encode(message, writer).ldelim(); | |
}; | |
/** | |
* Decodes a GetBookViaAuthor message from the specified reader or buffer. | |
* @function decode | |
* @memberof com.book.GetBookViaAuthor | |
* @static | |
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from | |
* @param {number} [length] Message length if known beforehand | |
* @returns {com.book.GetBookViaAuthor} GetBookViaAuthor | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
GetBookViaAuthor.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.com.book.GetBookViaAuthor(); | |
while (reader.pos < end) { | |
var tag = reader.uint32(); | |
switch (tag >>> 3) { | |
case 1: | |
message.author = reader.string(); | |
break; | |
default: | |
reader.skipType(tag & 7); | |
break; | |
} | |
} | |
return message; | |
}; | |
/** | |
* Decodes a GetBookViaAuthor message from the specified reader or buffer, length delimited. | |
* @function decodeDelimited | |
* @memberof com.book.GetBookViaAuthor | |
* @static | |
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from | |
* @returns {com.book.GetBookViaAuthor} GetBookViaAuthor | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
GetBookViaAuthor.decodeDelimited = function decodeDelimited(reader) { | |
if (!(reader instanceof $Reader)) | |
reader = new $Reader(reader); | |
return this.decode(reader, reader.uint32()); | |
}; | |
/** | |
* Verifies a GetBookViaAuthor message. | |
* @function verify | |
* @memberof com.book.GetBookViaAuthor | |
* @static | |
* @param {Object.<string,*>} message Plain object to verify | |
* @returns {string|null} `null` if valid, otherwise the reason why it is not | |
*/ | |
GetBookViaAuthor.verify = function verify(message) { | |
if (typeof message !== "object" || message === null) | |
return "object expected"; | |
if (message.author != null && message.hasOwnProperty("author")) | |
if (!$util.isString(message.author)) | |
return "author: string expected"; | |
return null; | |
}; | |
/** | |
* Creates a GetBookViaAuthor message from a plain object. Also converts values to their respective internal types. | |
* @function fromObject | |
* @memberof com.book.GetBookViaAuthor | |
* @static | |
* @param {Object.<string,*>} object Plain object | |
* @returns {com.book.GetBookViaAuthor} GetBookViaAuthor | |
*/ | |
GetBookViaAuthor.fromObject = function fromObject(object) { | |
if (object instanceof $root.com.book.GetBookViaAuthor) | |
return object; | |
var message = new $root.com.book.GetBookViaAuthor(); | |
if (object.author != null) | |
message.author = String(object.author); | |
return message; | |
}; | |
/** | |
* Creates a plain object from a GetBookViaAuthor message. Also converts values to other types if specified. | |
* @function toObject | |
* @memberof com.book.GetBookViaAuthor | |
* @static | |
* @param {com.book.GetBookViaAuthor} message GetBookViaAuthor | |
* @param {$protobuf.IConversionOptions} [options] Conversion options | |
* @returns {Object.<string,*>} Plain object | |
*/ | |
GetBookViaAuthor.toObject = function toObject(message, options) { | |
if (!options) | |
options = {}; | |
var object = {}; | |
if (options.defaults) | |
object.author = ""; | |
if (message.author != null && message.hasOwnProperty("author")) | |
object.author = message.author; | |
return object; | |
}; | |
/** | |
* Converts this GetBookViaAuthor to JSON. | |
* @function toJSON | |
* @memberof com.book.GetBookViaAuthor | |
* @instance | |
* @returns {Object.<string,*>} JSON object | |
*/ | |
GetBookViaAuthor.prototype.toJSON = function toJSON() { | |
return this.constructor.toObject(this, $protobuf.util.toJSONOptions); | |
}; | |
return GetBookViaAuthor; | |
})(); | |
book.BookService = (function() { | |
/** | |
* Constructs a new BookService service. | |
* @memberof com.book | |
* @classdesc Represents a BookService | |
* @extends $protobuf.rpc.Service | |
* @constructor | |
* @param {$protobuf.RPCImpl} rpcImpl RPC implementation | |
* @param {boolean} [requestDelimited=false] Whether requests are length-delimited | |
* @param {boolean} [responseDelimited=false] Whether responses are length-delimited | |
*/ | |
function BookService(rpcImpl, requestDelimited, responseDelimited) { | |
$protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); | |
} | |
(BookService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = BookService; | |
/** | |
* Creates new BookService service using the specified rpc implementation. | |
* @function create | |
* @memberof com.book.BookService | |
* @static | |
* @param {$protobuf.RPCImpl} rpcImpl RPC implementation | |
* @param {boolean} [requestDelimited=false] Whether requests are length-delimited | |
* @param {boolean} [responseDelimited=false] Whether responses are length-delimited | |
* @returns {BookService} RPC service. Useful where requests and/or responses are streamed. | |
*/ | |
BookService.create = function create(rpcImpl, requestDelimited, responseDelimited) { | |
return new this(rpcImpl, requestDelimited, responseDelimited); | |
}; | |
/** | |
* Callback as used by {@link com.book.BookService#getBook}. | |
* @memberof com.book.BookService | |
* @typedef GetBookCallback | |
* @type {function} | |
* @param {Error|null} error Error, if any | |
* @param {com.book.Book} [response] Book | |
*/ | |
/** | |
* Calls GetBook. | |
* @function getBook | |
* @memberof com.book.BookService | |
* @instance | |
* @param {com.book.IGetBookRequest} request GetBookRequest message or plain object | |
* @param {com.book.BookService.GetBookCallback} callback Node-style callback called with the error, if any, and Book | |
* @returns {undefined} | |
* @variation 1 | |
*/ | |
BookService.prototype.getBook = function getBook(request, callback) { | |
return this.rpcCall(getBook, $root.com.book.GetBookRequest, $root.com.book.Book, request, callback); | |
}; | |
/** | |
* Calls GetBook. | |
* @function getBook | |
* @memberof com.book.BookService | |
* @instance | |
* @param {com.book.IGetBookRequest} request GetBookRequest message or plain object | |
* @returns {Promise<com.book.Book>} Promise | |
* @variation 2 | |
*/ | |
/** | |
* Callback as used by {@link com.book.BookService#getBooksViaAuthor}. | |
* @memberof com.book.BookService | |
* @typedef GetBooksViaAuthorCallback | |
* @type {function} | |
* @param {Error|null} error Error, if any | |
* @param {com.book.Book} [response] Book | |
*/ | |
/** | |
* Calls GetBooksViaAuthor. | |
* @function getBooksViaAuthor | |
* @memberof com.book.BookService | |
* @instance | |
* @param {com.book.IGetBookViaAuthor} request GetBookViaAuthor message or plain object | |
* @param {com.book.BookService.GetBooksViaAuthorCallback} callback Node-style callback called with the error, if any, and Book | |
* @returns {undefined} | |
* @variation 1 | |
*/ | |
BookService.prototype.getBooksViaAuthor = function getBooksViaAuthor(request, callback) { | |
return this.rpcCall(getBooksViaAuthor, $root.com.book.GetBookViaAuthor, $root.com.book.Book, request, callback); | |
}; | |
/** | |
* Calls GetBooksViaAuthor. | |
* @function getBooksViaAuthor | |
* @memberof com.book.BookService | |
* @instance | |
* @param {com.book.IGetBookViaAuthor} request GetBookViaAuthor message or plain object | |
* @returns {Promise<com.book.Book>} Promise | |
* @variation 2 | |
*/ | |
/** | |
* Callback as used by {@link com.book.BookService#getGreatestBook}. | |
* @memberof com.book.BookService | |
* @typedef GetGreatestBookCallback | |
* @type {function} | |
* @param {Error|null} error Error, if any | |
* @param {com.book.Book} [response] Book | |
*/ | |
/** | |
* Calls GetGreatestBook. | |
* @function getGreatestBook | |
* @memberof com.book.BookService | |
* @instance | |
* @param {com.book.IGetBookRequest} request GetBookRequest message or plain object | |
* @param {com.book.BookService.GetGreatestBookCallback} callback Node-style callback called with the error, if any, and Book | |
* @returns {undefined} | |
* @variation 1 | |
*/ | |
BookService.prototype.getGreatestBook = function getGreatestBook(request, callback) { | |
return this.rpcCall(getGreatestBook, $root.com.book.GetBookRequest, $root.com.book.Book, request, callback); | |
}; | |
/** | |
* Calls GetGreatestBook. | |
* @function getGreatestBook | |
* @memberof com.book.BookService | |
* @instance | |
* @param {com.book.IGetBookRequest} request GetBookRequest message or plain object | |
* @returns {Promise<com.book.Book>} Promise | |
* @variation 2 | |
*/ | |
/** | |
* Callback as used by {@link com.book.BookService#getBooks}. | |
* @memberof com.book.BookService | |
* @typedef GetBooksCallback | |
* @type {function} | |
* @param {Error|null} error Error, if any | |
* @param {com.book.Book} [response] Book | |
*/ | |
/** | |
* Calls GetBooks. | |
* @function getBooks | |
* @memberof com.book.BookService | |
* @instance | |
* @param {com.book.IGetBookRequest} request GetBookRequest message or plain object | |
* @param {com.book.BookService.GetBooksCallback} callback Node-style callback called with the error, if any, and Book | |
* @returns {undefined} | |
* @variation 1 | |
*/ | |
BookService.prototype.getBooks = function getBooks(request, callback) { | |
return this.rpcCall(getBooks, $root.com.book.GetBookRequest, $root.com.book.Book, request, callback); | |
}; | |
/** | |
* Calls GetBooks. | |
* @function getBooks | |
* @memberof com.book.BookService | |
* @instance | |
* @param {com.book.IGetBookRequest} request GetBookRequest message or plain object | |
* @returns {Promise<com.book.Book>} Promise | |
* @variation 2 | |
*/ | |
return BookService; | |
})(); | |
book.BookStore = (function() { | |
/** | |
* Properties of a BookStore. | |
* @memberof com.book | |
* @interface IBookStore | |
* @property {string|null} [name] BookStore name | |
* @property {Object.<string,string>|null} [books] BookStore books | |
*/ | |
/** | |
* Constructs a new BookStore. | |
* @memberof com.book | |
* @classdesc Represents a BookStore. | |
* @implements IBookStore | |
* @constructor | |
* @param {com.book.IBookStore=} [properties] Properties to set | |
*/ | |
function BookStore(properties) { | |
this.books = {}; | |
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]]; | |
} | |
/** | |
* BookStore name. | |
* @member {string} name | |
* @memberof com.book.BookStore | |
* @instance | |
*/ | |
BookStore.prototype.name = ""; | |
/** | |
* BookStore books. | |
* @member {Object.<string,string>} books | |
* @memberof com.book.BookStore | |
* @instance | |
*/ | |
BookStore.prototype.books = $util.emptyObject; | |
/** | |
* Creates a new BookStore instance using the specified properties. | |
* @function create | |
* @memberof com.book.BookStore | |
* @static | |
* @param {com.book.IBookStore=} [properties] Properties to set | |
* @returns {com.book.BookStore} BookStore instance | |
*/ | |
BookStore.create = function create(properties) { | |
return new BookStore(properties); | |
}; | |
/** | |
* Encodes the specified BookStore message. Does not implicitly {@link com.book.BookStore.verify|verify} messages. | |
* @function encode | |
* @memberof com.book.BookStore | |
* @static | |
* @param {com.book.IBookStore} message BookStore message or plain object to encode | |
* @param {$protobuf.Writer} [writer] Writer to encode to | |
* @returns {$protobuf.Writer} Writer | |
*/ | |
BookStore.encode = function encode(message, writer) { | |
if (!writer) | |
writer = $Writer.create(); | |
if (message.name != null && message.hasOwnProperty("name")) | |
writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); | |
if (message.books != null && message.hasOwnProperty("books")) | |
for (var keys = Object.keys(message.books), i = 0; i < keys.length; ++i) | |
writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 0 =*/8).int64(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.books[keys[i]]).ldelim(); | |
return writer; | |
}; | |
/** | |
* Encodes the specified BookStore message, length delimited. Does not implicitly {@link com.book.BookStore.verify|verify} messages. | |
* @function encodeDelimited | |
* @memberof com.book.BookStore | |
* @static | |
* @param {com.book.IBookStore} message BookStore message or plain object to encode | |
* @param {$protobuf.Writer} [writer] Writer to encode to | |
* @returns {$protobuf.Writer} Writer | |
*/ | |
BookStore.encodeDelimited = function encodeDelimited(message, writer) { | |
return this.encode(message, writer).ldelim(); | |
}; | |
/** | |
* Decodes a BookStore message from the specified reader or buffer. | |
* @function decode | |
* @memberof com.book.BookStore | |
* @static | |
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from | |
* @param {number} [length] Message length if known beforehand | |
* @returns {com.book.BookStore} BookStore | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
BookStore.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.com.book.BookStore(), key; | |
while (reader.pos < end) { | |
var tag = reader.uint32(); | |
switch (tag >>> 3) { | |
case 1: | |
message.name = reader.string(); | |
break; | |
case 2: | |
reader.skip().pos++; | |
if (message.books === $util.emptyObject) | |
message.books = {}; | |
key = reader.int64(); | |
reader.pos++; | |
message.books[typeof key === "object" ? $util.longToHash(key) : key] = reader.string(); | |
break; | |
default: | |
reader.skipType(tag & 7); | |
break; | |
} | |
} | |
return message; | |
}; | |
/** | |
* Decodes a BookStore message from the specified reader or buffer, length delimited. | |
* @function decodeDelimited | |
* @memberof com.book.BookStore | |
* @static | |
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from | |
* @returns {com.book.BookStore} BookStore | |
* @throws {Error} If the payload is not a reader or valid buffer | |
* @throws {$protobuf.util.ProtocolError} If required fields are missing | |
*/ | |
BookStore.decodeDelimited = function decodeDelimited(reader) { | |
if (!(reader instanceof $Reader)) | |
reader = new $Reader(reader); | |
return this.decode(reader, reader.uint32()); | |
}; | |
/** | |
* Verifies a BookStore message. | |
* @function verify | |
* @memberof com.book.BookStore | |
* @static | |
* @param {Object.<string,*>} message Plain object to verify | |
* @returns {string|null} `null` if valid, otherwise the reason why it is not | |
*/ | |
BookStore.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.books != null && message.hasOwnProperty("books")) { | |
if (!$util.isObject(message.books)) | |
return "books: object expected"; | |
var key = Object.keys(message.books); | |
for (var i = 0; i < key.length; ++i) { | |
if (!$util.key64Re.test(key[i])) | |
return "books: integer|Long key{k:int64} expected"; | |
if (!$util.isString(message.books[key[i]])) | |
return "books: string{k:int64} expected"; | |
} | |
} | |
return null; | |
}; | |
/** | |
* Creates a BookStore message from a plain object. Also converts values to their respective internal types. | |
* @function fromObject | |
* @memberof com.book.BookStore | |
* @static | |
* @param {Object.<string,*>} object Plain object | |
* @returns {com.book.BookStore} BookStore | |
*/ | |
BookStore.fromObject = function fromObject(object) { | |
if (object instanceof $root.com.book.BookStore) | |
return object; | |
var message = new $root.com.book.BookStore(); | |
if (object.name != null) | |
message.name = String(object.name); | |
if (object.books) { | |
if (typeof object.books !== "object") | |
throw TypeError(".com.book.BookStore.books: object expected"); | |
message.books = {}; | |
for (var keys = Object.keys(object.books), i = 0; i < keys.length; ++i) | |
message.books[keys[i]] = String(object.books[keys[i]]); | |
} | |
return message; | |
}; | |
/** | |
* Creates a plain object from a BookStore message. Also converts values to other types if specified. | |
* @function toObject | |
* @memberof com.book.BookStore | |
* @static | |
* @param {com.book.BookStore} message BookStore | |
* @param {$protobuf.IConversionOptions} [options] Conversion options | |
* @returns {Object.<string,*>} Plain object | |
*/ | |
BookStore.toObject = function toObject(message, options) { | |
if (!options) | |
options = {}; | |
var object = {}; | |
if (options.objects || options.defaults) | |
object.books = {}; | |
if (options.defaults) | |
object.name = ""; | |
if (message.name != null && message.hasOwnProperty("name")) | |
object.name = message.name; | |
var keys2; | |
if (message.books && (keys2 = Object.keys(message.books)).length) { | |
object.books = {}; | |
for (var j = 0; j < keys2.length; ++j) | |
object.books[keys2[j]] = message.books[keys2[j]]; | |
} | |
return object; | |
}; | |
/** | |
* Converts this BookStore to JSON. | |
* @function toJSON | |
* @memberof com.book.BookStore | |
* @instance | |
* @returns {Object.<string,*>} JSON object | |
*/ | |
BookStore.prototype.toJSON = function toJSON() { | |
return this.constructor.toObject(this, $protobuf.util.toJSONOptions); | |
}; | |
return BookStore; | |
})(); | |
/** | |
* EnumSample enum. | |
* @name com.book.EnumSample | |
* @enum {string} | |
* @property {number} UNKNOWN=0 UNKNOWN value | |
* @property {number} STARTED=1 STARTED value | |
* @property {number} RUNNING=1 RUNNING value | |
*/ | |
book.EnumSample = (function() { | |
var valuesById = {}, values = Object.create(valuesById); | |
values[valuesById[0] = "UNKNOWN"] = 0; | |
values[valuesById[1] = "STARTED"] = 1; | |
values["RUNNING"] = 1; | |
return values; | |
})(); | |
return book; | |
})(); | |
return com; | |
})(); | |
module.exports = $root; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment