diff --git a/cli/targets/static.js b/cli/targets/static.js index 3e983e00a..c130d9026 100644 --- a/cli/targets/static.js +++ b/cli/targets/static.js @@ -597,11 +597,17 @@ function buildType(ref, type) { "@function getTypeUrl", "@memberof " + exportName(type), "@static", + "@param {string} [typeUrlPrefix] your custom typeUrlPrefix(default \"type.googleapis.com\")", "@returns {string} The default type url" ]); - push(escapeName(type.name) + ".getTypeUrl = function getTypeUrl() {"); + push(escapeName(type.name) + ".getTypeUrl = function getTypeUrl(typeUrlPrefix) {"); ++indent; - push("return \"type.googleapis.com/" + exportName(type) + "\";"); + push("if (typeUrlPrefix === undefined) {"); + ++indent; + push("typeUrlPrefix = \"type.googleapis.com\";"); + --indent; + push("}"); + push("return typeUrlPrefix + \"/" + exportName(type) + "\";"); --indent; push("};"); } diff --git a/tests/cli.js b/tests/cli.js index 177d721ae..c74c549de 100644 --- a/tests/cli.js +++ b/tests/cli.js @@ -44,11 +44,12 @@ tape.test("pbjs generates static code", function(test) { decode: true, encode: true, convert: true, + typeurl: true, }, function(err, jsCode) { test.error(err, 'static code generation worked'); // jsCode is the generated code; we'll eval it - // (since this is what we normally does with the code, right?) + // (since this is what we normally do with the code, right?) // This is a test code. Do not use this in production. var $protobuf = protobuf; eval(jsCode); @@ -78,6 +79,12 @@ tape.test("pbjs generates static code", function(test) { var instance1 = OneofContainerDynamic.toObject(OneofContainerDynamic.fromObject(instance)); test.deepEqual(instance, instance1, "fromObject and toObject work for instance of the static type"); + // Check that getTypeUrl works + var defaultTypeUrl = Message.getTypeUrl(); + var customTypeUrl = Message.getTypeUrl("example.com"); + test.equal(defaultTypeUrl, "type.googleapis.com/Message", "getTypeUrl returns expected url"); + test.equal(customTypeUrl, "example.com/Message", "getTypeUrl returns custom url"); + test.end(); }); }); diff --git a/tests/data/comments.d.ts b/tests/data/comments.d.ts index 5f1d2883c..1a49e9eb5 100644 --- a/tests/data/comments.d.ts +++ b/tests/data/comments.d.ts @@ -19,7 +19,7 @@ export class Test1 implements ITest1 { public static fromObject(object: { [k: string]: any }): Test1; public static toObject(message: Test1, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } export interface ITest2 { @@ -36,12 +36,13 @@ export class Test2 implements ITest2 { public static fromObject(object: { [k: string]: any }): Test2; public static toObject(message: Test2, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } export enum Test3 { ONE = 1, TWO = 2, THREE = 3, - FOUR = 4 + FOUR = 4, + FIVE = 5 } diff --git a/tests/data/comments.js b/tests/data/comments.js index b405386db..706ae29d9 100644 --- a/tests/data/comments.js +++ b/tests/data/comments.js @@ -246,10 +246,14 @@ $root.Test1 = (function() { * @function getTypeUrl * @memberof Test1 * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Test1.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/Test1"; + Test1.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/Test1"; }; return Test1; @@ -417,10 +421,14 @@ $root.Test2 = (function() { * @function getTypeUrl * @memberof Test2 * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Test2.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/Test2"; + Test2.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/Test2"; }; return Test2; @@ -434,6 +442,7 @@ $root.Test2 = (function() { * @property {number} TWO=2 TWO value * @property {number} THREE=3 Preferred value with a comment. * @property {number} FOUR=4 Other value with a comment. + * @property {number} FIVE=5 Leading comment for value with both types of comments after field with trailing comment. */ $root.Test3 = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -441,6 +450,7 @@ $root.Test3 = (function() { values[valuesById[2] = "TWO"] = 2; values[valuesById[3] = "THREE"] = 3; values[valuesById[4] = "FOUR"] = 4; + values[valuesById[5] = "FIVE"] = 5; return values; })(); diff --git a/tests/data/convert.d.ts b/tests/data/convert.d.ts index dd5ef3839..17383732c 100644 --- a/tests/data/convert.d.ts +++ b/tests/data/convert.d.ts @@ -31,7 +31,7 @@ export class Message implements IMessage { public static fromObject(object: { [k: string]: any }): Message; public static toObject(message: Message, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } export namespace Message { diff --git a/tests/data/convert.js b/tests/data/convert.js index fd3a5aacb..34f252808 100644 --- a/tests/data/convert.js +++ b/tests/data/convert.js @@ -567,10 +567,14 @@ $root.Message = (function() { * @function getTypeUrl * @memberof Message * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Message.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/Message"; + Message.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/Message"; }; /** diff --git a/tests/data/mapbox/vector_tile.d.ts b/tests/data/mapbox/vector_tile.d.ts index 5af943b20..382277350 100644 --- a/tests/data/mapbox/vector_tile.d.ts +++ b/tests/data/mapbox/vector_tile.d.ts @@ -17,7 +17,7 @@ export namespace vector_tile { public static fromObject(object: { [k: string]: any }): vector_tile.Tile; public static toObject(message: vector_tile.Tile, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace Tile { @@ -57,7 +57,7 @@ export namespace vector_tile { public static fromObject(object: { [k: string]: any }): vector_tile.Tile.Value; public static toObject(message: vector_tile.Tile.Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IFeature { @@ -82,7 +82,7 @@ export namespace vector_tile { public static fromObject(object: { [k: string]: any }): vector_tile.Tile.Feature; public static toObject(message: vector_tile.Tile.Feature, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface ILayer { @@ -111,7 +111,7 @@ export namespace vector_tile { public static fromObject(object: { [k: string]: any }): vector_tile.Tile.Layer; public static toObject(message: vector_tile.Tile.Layer, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } } } diff --git a/tests/data/mapbox/vector_tile.js b/tests/data/mapbox/vector_tile.js index 001815d56..134aaae85 100644 --- a/tests/data/mapbox/vector_tile.js +++ b/tests/data/mapbox/vector_tile.js @@ -228,10 +228,14 @@ $root.vector_tile = (function() { * @function getTypeUrl * @memberof vector_tile.Tile * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Tile.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/vector_tile.Tile"; + Tile.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/vector_tile.Tile"; }; /** @@ -616,10 +620,14 @@ $root.vector_tile = (function() { * @function getTypeUrl * @memberof vector_tile.Tile.Value * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Value.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/vector_tile.Tile.Value"; + Value.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/vector_tile.Tile.Value"; }; return Value; @@ -968,10 +976,14 @@ $root.vector_tile = (function() { * @function getTypeUrl * @memberof vector_tile.Tile.Feature * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Feature.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/vector_tile.Tile.Feature"; + Feature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/vector_tile.Tile.Feature"; }; return Feature; @@ -1337,10 +1349,14 @@ $root.vector_tile = (function() { * @function getTypeUrl * @memberof vector_tile.Tile.Layer * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Layer.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/vector_tile.Tile.Layer"; + Layer.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/vector_tile.Tile.Layer"; }; return Layer; diff --git a/tests/data/package.d.ts b/tests/data/package.d.ts index d18b917f8..d4807baab 100644 --- a/tests/data/package.d.ts +++ b/tests/data/package.d.ts @@ -47,7 +47,7 @@ export class Package implements IPackage { public static fromObject(object: { [k: string]: any }): Package; public static toObject(message: Package, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } export namespace Package { @@ -70,6 +70,6 @@ export namespace Package { public static fromObject(object: { [k: string]: any }): Package.Repository; public static toObject(message: Package.Repository, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } } diff --git a/tests/data/package.js b/tests/data/package.js index 3ec5e7da0..7a3a1db43 100644 --- a/tests/data/package.js +++ b/tests/data/package.js @@ -729,10 +729,14 @@ $root.Package = (function() { * @function getTypeUrl * @memberof Package * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Package.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/Package"; + Package.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/Package"; }; Package.Repository = (function() { @@ -947,10 +951,14 @@ $root.Package = (function() { * @function getTypeUrl * @memberof Package.Repository * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Repository.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/Package.Repository"; + Repository.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/Package.Repository"; }; return Repository; diff --git a/tests/data/rpc-es6.d.ts b/tests/data/rpc-es6.d.ts index c327bbdd1..5cebb4c3a 100644 --- a/tests/data/rpc-es6.d.ts +++ b/tests/data/rpc-es6.d.ts @@ -27,7 +27,7 @@ export class MyRequest implements IMyRequest { public static fromObject(object: { [k: string]: any }): MyRequest; public static toObject(message: MyRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } export interface IMyResponse { @@ -46,5 +46,5 @@ export class MyResponse implements IMyResponse { public static fromObject(object: { [k: string]: any }): MyResponse; public static toObject(message: MyResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } diff --git a/tests/data/rpc-es6.js b/tests/data/rpc-es6.js index 4799711fb..71f4ac630 100644 --- a/tests/data/rpc-es6.js +++ b/tests/data/rpc-es6.js @@ -1,7 +1,5 @@ /*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("../../minimal"); +import * as $protobuf from "../../minimal"; // Common aliases const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; @@ -266,10 +264,14 @@ export const MyRequest = $root.MyRequest = (() => { * @function getTypeUrl * @memberof MyRequest * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - MyRequest.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/MyRequest"; + MyRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/MyRequest"; }; return MyRequest; @@ -464,13 +466,17 @@ export const MyResponse = $root.MyResponse = (() => { * @function getTypeUrl * @memberof MyResponse * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - MyResponse.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/MyResponse"; + MyResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/MyResponse"; }; return MyResponse; })(); -module.exports = $root; +export { $root as default }; diff --git a/tests/data/rpc-reserved.d.ts b/tests/data/rpc-reserved.d.ts index c8e9138bd..cf2455b59 100644 --- a/tests/data/rpc-reserved.d.ts +++ b/tests/data/rpc-reserved.d.ts @@ -27,7 +27,7 @@ export class MyRequest implements IMyRequest { public static fromObject(object: { [k: string]: any }): MyRequest; public static toObject(message: MyRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } export interface IMyResponse { @@ -46,5 +46,5 @@ export class MyResponse implements IMyResponse { public static fromObject(object: { [k: string]: any }): MyResponse; public static toObject(message: MyResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } diff --git a/tests/data/rpc-reserved.js b/tests/data/rpc-reserved.js index 15365c02b..d3f76837c 100644 --- a/tests/data/rpc-reserved.js +++ b/tests/data/rpc-reserved.js @@ -266,10 +266,14 @@ $root.MyRequest = (function() { * @function getTypeUrl * @memberof MyRequest * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - MyRequest.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/MyRequest"; + MyRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/MyRequest"; }; return MyRequest; @@ -464,10 +468,14 @@ $root.MyResponse = (function() { * @function getTypeUrl * @memberof MyResponse * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - MyResponse.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/MyResponse"; + MyResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/MyResponse"; }; return MyResponse; diff --git a/tests/data/rpc.d.ts b/tests/data/rpc.d.ts index c327bbdd1..5cebb4c3a 100644 --- a/tests/data/rpc.d.ts +++ b/tests/data/rpc.d.ts @@ -27,7 +27,7 @@ export class MyRequest implements IMyRequest { public static fromObject(object: { [k: string]: any }): MyRequest; public static toObject(message: MyRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } export interface IMyResponse { @@ -46,5 +46,5 @@ export class MyResponse implements IMyResponse { public static fromObject(object: { [k: string]: any }): MyResponse; public static toObject(message: MyResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } diff --git a/tests/data/rpc.js b/tests/data/rpc.js index 11c0a919b..c102c1aa8 100644 --- a/tests/data/rpc.js +++ b/tests/data/rpc.js @@ -266,10 +266,14 @@ $root.MyRequest = (function() { * @function getTypeUrl * @memberof MyRequest * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - MyRequest.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/MyRequest"; + MyRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/MyRequest"; }; return MyRequest; @@ -464,10 +468,14 @@ $root.MyResponse = (function() { * @function getTypeUrl * @memberof MyResponse * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - MyResponse.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/MyResponse"; + MyResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/MyResponse"; }; return MyResponse; diff --git a/tests/data/test.d.ts b/tests/data/test.d.ts index f2b920406..c4bf3a71b 100644 --- a/tests/data/test.d.ts +++ b/tests/data/test.d.ts @@ -17,7 +17,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.Empty; public static toObject(message: jspb.test.Empty, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } enum OuterEnum { @@ -41,7 +41,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.EnumContainer; public static toObject(message: jspb.test.EnumContainer, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface ISimple1 { @@ -64,7 +64,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.Simple1; public static toObject(message: jspb.test.Simple1, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface ISimple2 { @@ -85,7 +85,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.Simple2; public static toObject(message: jspb.test.Simple2, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface ISpecialCases { @@ -110,7 +110,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.SpecialCases; public static toObject(message: jspb.test.SpecialCases, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IOptionalFields { @@ -137,7 +137,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.OptionalFields; public static toObject(message: jspb.test.OptionalFields, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace OptionalFields { @@ -158,7 +158,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.OptionalFields.Nested; public static toObject(message: jspb.test.OptionalFields.Nested, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -188,7 +188,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.HasExtensions; public static toObject(message: jspb.test.HasExtensions, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IComplex { @@ -215,7 +215,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.Complex; public static toObject(message: jspb.test.Complex, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace Complex { @@ -236,7 +236,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.Complex.Nested; public static toObject(message: jspb.test.Complex.Nested, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -254,7 +254,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.OuterMessage; public static toObject(message: jspb.test.OuterMessage, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace OuterMessage { @@ -275,7 +275,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.OuterMessage.Complex; public static toObject(message: jspb.test.OuterMessage.Complex, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -295,7 +295,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.IsExtension; public static toObject(message: jspb.test.IsExtension, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IIndirectExtension { @@ -312,7 +312,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.IndirectExtension; public static toObject(message: jspb.test.IndirectExtension, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IDefaultValues { @@ -341,7 +341,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.DefaultValues; public static toObject(message: jspb.test.DefaultValues, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace DefaultValues { @@ -382,7 +382,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.FloatingPointFields; public static toObject(message: jspb.test.FloatingPointFields, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface ITestClone { @@ -410,7 +410,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.TestClone; public static toObject(message: jspb.test.TestClone, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface ICloneExtension { @@ -429,7 +429,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.CloneExtension; public static toObject(message: jspb.test.CloneExtension, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface ITestGroup { @@ -458,7 +458,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.TestGroup; public static toObject(message: jspb.test.TestGroup, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace TestGroup { @@ -481,7 +481,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.TestGroup.RepeatedGroup; public static toObject(message: jspb.test.TestGroup.RepeatedGroup, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IRequiredGroup { @@ -500,7 +500,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.TestGroup.RequiredGroup; public static toObject(message: jspb.test.TestGroup.RequiredGroup, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IOptionalGroup { @@ -519,7 +519,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.TestGroup.OptionalGroup; public static toObject(message: jspb.test.TestGroup.OptionalGroup, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -539,7 +539,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.TestGroup1; public static toObject(message: jspb.test.TestGroup1, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface ITestReservedNames { @@ -559,7 +559,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.TestReservedNames; public static toObject(message: jspb.test.TestReservedNames, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface ITestReservedNamesExtension { @@ -576,7 +576,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.TestReservedNamesExtension; public static toObject(message: jspb.test.TestReservedNamesExtension, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface ITestMessageWithOneof { @@ -594,16 +594,16 @@ export namespace jspb { class TestMessageWithOneof implements ITestMessageWithOneof { constructor(properties?: jspb.test.ITestMessageWithOneof); - public pone: string; - public pthree: string; + public pone?: (string|null); + public pthree?: (string|null); public rone?: (jspb.test.ITestMessageWithOneof|null); - public rtwo: string; + public rtwo?: (string|null); public normalField: boolean; public repeatedField: string[]; - public aone: number; - public atwo: number; - public bone: number; - public btwo: number; + public aone?: (number|null); + public atwo?: (number|null); + public bone?: (number|null); + public btwo?: (number|null); public partialOneof?: ("pone"|"pthree"); public recursiveOneof?: ("rone"|"rtwo"); public defaultOneofA?: ("aone"|"atwo"); @@ -617,7 +617,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.TestMessageWithOneof; public static toObject(message: jspb.test.TestMessageWithOneof, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface ITestEndsWithBytes { @@ -638,7 +638,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.TestEndsWithBytes; public static toObject(message: jspb.test.TestEndsWithBytes, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface ITestMapFieldsNoBinary { @@ -679,7 +679,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.TestMapFieldsNoBinary; public static toObject(message: jspb.test.TestMapFieldsNoBinary, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } enum MapValueEnumNoBinary { @@ -704,7 +704,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.MapValueMessageNoBinary; public static toObject(message: jspb.test.MapValueMessageNoBinary, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IDeeply { @@ -721,7 +721,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.Deeply; public static toObject(message: jspb.test.Deeply, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace Deeply { @@ -740,7 +740,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.Deeply.Nested; public static toObject(message: jspb.test.Deeply.Nested, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace Nested { @@ -761,7 +761,7 @@ export namespace jspb { public static fromObject(object: { [k: string]: any }): jspb.test.Deeply.Nested.Message; public static toObject(message: jspb.test.Deeply.Nested.Message, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } } } @@ -788,7 +788,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorSet; public static toObject(message: google.protobuf.FileDescriptorSet, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IFileDescriptorProto { @@ -829,7 +829,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorProto; public static toObject(message: google.protobuf.FileDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IDescriptorProto { @@ -866,7 +866,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto; public static toObject(message: google.protobuf.DescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace DescriptorProto { @@ -889,7 +889,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ExtensionRange; public static toObject(message: google.protobuf.DescriptorProto.ExtensionRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IReservedRange { @@ -910,7 +910,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ReservedRange; public static toObject(message: google.protobuf.DescriptorProto.ReservedRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -948,7 +948,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.FieldDescriptorProto; public static toObject(message: google.protobuf.FieldDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace FieldDescriptorProto { @@ -999,7 +999,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.OneofDescriptorProto; public static toObject(message: google.protobuf.OneofDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IEnumDescriptorProto { @@ -1022,7 +1022,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.EnumDescriptorProto; public static toObject(message: google.protobuf.EnumDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IEnumValueDescriptorProto { @@ -1045,7 +1045,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueDescriptorProto; public static toObject(message: google.protobuf.EnumValueDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IServiceDescriptorProto { @@ -1068,7 +1068,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceDescriptorProto; public static toObject(message: google.protobuf.ServiceDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IMethodDescriptorProto { @@ -1097,7 +1097,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.MethodDescriptorProto; public static toObject(message: google.protobuf.MethodDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IFileOptions { @@ -1144,7 +1144,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.FileOptions; public static toObject(message: google.protobuf.FileOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace FileOptions { @@ -1180,7 +1180,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.MessageOptions; public static toObject(message: google.protobuf.MessageOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IFieldOptions { @@ -1211,7 +1211,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions; public static toObject(message: google.protobuf.FieldOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace FieldOptions { @@ -1245,7 +1245,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.OneofOptions; public static toObject(message: google.protobuf.OneofOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IEnumOptions { @@ -1269,7 +1269,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.EnumOptions; public static toObject(message: google.protobuf.EnumOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IEnumValueOptions { @@ -1290,7 +1290,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueOptions; public static toObject(message: google.protobuf.EnumValueOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IServiceOptions { @@ -1311,7 +1311,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceOptions; public static toObject(message: google.protobuf.ServiceOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } interface IMethodOptions { @@ -1334,7 +1334,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.MethodOptions; public static toObject(message: google.protobuf.MethodOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace MethodOptions { @@ -1374,7 +1374,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption; public static toObject(message: google.protobuf.UninterpretedOption, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace UninterpretedOption { @@ -1397,7 +1397,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption.NamePart; public static toObject(message: google.protobuf.UninterpretedOption.NamePart, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -1417,7 +1417,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo; public static toObject(message: google.protobuf.SourceCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace SourceCodeInfo { @@ -1446,7 +1446,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo.Location; public static toObject(message: google.protobuf.SourceCodeInfo.Location, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } } @@ -1466,7 +1466,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo; public static toObject(message: google.protobuf.GeneratedCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } namespace GeneratedCodeInfo { @@ -1493,7 +1493,7 @@ export namespace google { public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo.Annotation; public static toObject(message: google.protobuf.GeneratedCodeInfo.Annotation, options?: $protobuf.IConversionOptions): { [k: string]: any }; public toJSON(): { [k: string]: any }; - public static getTypeUrl(): string; + public static getTypeUrl(typeUrlPrefix?: string): string; } } } diff --git a/tests/data/test.js b/tests/data/test.js index e0a794641..5e014f072 100644 --- a/tests/data/test.js +++ b/tests/data/test.js @@ -189,10 +189,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.Empty * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Empty.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.Empty"; + Empty.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.Empty"; }; return Empty; @@ -414,10 +418,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.EnumContainer * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EnumContainer.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.EnumContainer"; + EnumContainer.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.EnumContainer"; }; return EnumContainer; @@ -674,10 +682,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.Simple1 * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Simple1.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.Simple1"; + Simple1.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.Simple1"; }; return Simple1; @@ -911,10 +923,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.Simple2 * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Simple2.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.Simple2"; + Simple2.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.Simple2"; }; return Simple2; @@ -1176,10 +1192,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.SpecialCases * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - SpecialCases.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.SpecialCases"; + SpecialCases.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.SpecialCases"; }; return SpecialCases; @@ -1507,10 +1527,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.OptionalFields * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - OptionalFields.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.OptionalFields"; + OptionalFields.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.OptionalFields"; }; OptionalFields.Nested = (function() { @@ -1702,10 +1726,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.OptionalFields.Nested * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Nested.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.OptionalFields.Nested"; + Nested.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.OptionalFields.Nested"; }; return Nested; @@ -2134,10 +2162,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.HasExtensions * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - HasExtensions.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.HasExtensions"; + HasExtensions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.HasExtensions"; }; return HasExtensions; @@ -2465,10 +2497,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.Complex * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Complex.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.Complex"; + Complex.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.Complex"; }; Complex.Nested = (function() { @@ -2660,10 +2696,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.Complex.Nested * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Nested.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.Complex.Nested"; + Nested.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.Complex.Nested"; }; return Nested; @@ -2834,10 +2874,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.OuterMessage * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - OuterMessage.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.OuterMessage"; + OuterMessage.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.OuterMessage"; }; OuterMessage.Complex = (function() { @@ -3029,10 +3073,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.OuterMessage.Complex * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Complex.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.OuterMessage.Complex"; + Complex.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.OuterMessage.Complex"; }; return Complex; @@ -3230,10 +3278,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.IsExtension * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - IsExtension.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.IsExtension"; + IsExtension.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.IsExtension"; }; return IsExtension; @@ -3401,10 +3453,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.IndirectExtension * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - IndirectExtension.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.IndirectExtension"; + IndirectExtension.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.IndirectExtension"; }; return IndirectExtension; @@ -3750,10 +3806,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.DefaultValues * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - DefaultValues.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.DefaultValues"; + DefaultValues.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.DefaultValues"; }; /** @@ -4161,10 +4221,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.FloatingPointFields * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - FloatingPointFields.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.FloatingPointFields"; + FloatingPointFields.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.FloatingPointFields"; }; return FloatingPointFields; @@ -4511,10 +4575,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.TestClone * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - TestClone.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.TestClone"; + TestClone.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.TestClone"; }; return TestClone; @@ -4709,10 +4777,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.CloneExtension * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - CloneExtension.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.CloneExtension"; + CloneExtension.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.CloneExtension"; }; return CloneExtension; @@ -5062,10 +5134,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.TestGroup * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - TestGroup.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.TestGroup"; + TestGroup.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.TestGroup"; }; TestGroup.RepeatedGroup = (function() { @@ -5303,10 +5379,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.TestGroup.RepeatedGroup * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - RepeatedGroup.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.TestGroup.RepeatedGroup"; + RepeatedGroup.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.TestGroup.RepeatedGroup"; }; return RepeatedGroup; @@ -5503,10 +5583,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.TestGroup.RequiredGroup * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - RequiredGroup.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.TestGroup.RequiredGroup"; + RequiredGroup.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.TestGroup.RequiredGroup"; }; return RequiredGroup; @@ -5703,10 +5787,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.TestGroup.OptionalGroup * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - OptionalGroup.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.TestGroup.OptionalGroup"; + OptionalGroup.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.TestGroup.OptionalGroup"; }; return OptionalGroup; @@ -5909,10 +5997,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.TestGroup1 * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - TestGroup1.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.TestGroup1"; + TestGroup1.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.TestGroup1"; }; return TestGroup1; @@ -6130,10 +6222,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.TestReservedNames * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - TestReservedNames.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.TestReservedNames"; + TestReservedNames.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.TestReservedNames"; }; return TestReservedNames; @@ -6301,10 +6397,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.TestReservedNamesExtension * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - TestReservedNamesExtension.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.TestReservedNamesExtension"; + TestReservedNamesExtension.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.TestReservedNamesExtension"; }; return TestReservedNamesExtension; @@ -6346,19 +6446,19 @@ $root.jspb = (function() { /** * TestMessageWithOneof pone. - * @member {string} pone + * @member {string|null|undefined} pone * @memberof jspb.test.TestMessageWithOneof * @instance */ - TestMessageWithOneof.prototype.pone = ""; + TestMessageWithOneof.prototype.pone = null; /** * TestMessageWithOneof pthree. - * @member {string} pthree + * @member {string|null|undefined} pthree * @memberof jspb.test.TestMessageWithOneof * @instance */ - TestMessageWithOneof.prototype.pthree = ""; + TestMessageWithOneof.prototype.pthree = null; /** * TestMessageWithOneof rone. @@ -6370,11 +6470,11 @@ $root.jspb = (function() { /** * TestMessageWithOneof rtwo. - * @member {string} rtwo + * @member {string|null|undefined} rtwo * @memberof jspb.test.TestMessageWithOneof * @instance */ - TestMessageWithOneof.prototype.rtwo = ""; + TestMessageWithOneof.prototype.rtwo = null; /** * TestMessageWithOneof normalField. @@ -6394,35 +6494,35 @@ $root.jspb = (function() { /** * TestMessageWithOneof aone. - * @member {number} aone + * @member {number|null|undefined} aone * @memberof jspb.test.TestMessageWithOneof * @instance */ - TestMessageWithOneof.prototype.aone = 1234; + TestMessageWithOneof.prototype.aone = null; /** * TestMessageWithOneof atwo. - * @member {number} atwo + * @member {number|null|undefined} atwo * @memberof jspb.test.TestMessageWithOneof * @instance */ - TestMessageWithOneof.prototype.atwo = 0; + TestMessageWithOneof.prototype.atwo = null; /** * TestMessageWithOneof bone. - * @member {number} bone + * @member {number|null|undefined} bone * @memberof jspb.test.TestMessageWithOneof * @instance */ - TestMessageWithOneof.prototype.bone = 0; + TestMessageWithOneof.prototype.bone = null; /** * TestMessageWithOneof btwo. - * @member {number} btwo + * @member {number|null|undefined} btwo * @memberof jspb.test.TestMessageWithOneof * @instance */ - TestMessageWithOneof.prototype.btwo = 1234; + TestMessageWithOneof.prototype.btwo = null; // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -6808,10 +6908,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.TestMessageWithOneof * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - TestMessageWithOneof.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.TestMessageWithOneof"; + TestMessageWithOneof.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.TestMessageWithOneof"; }; return TestMessageWithOneof; @@ -7038,10 +7142,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.TestEndsWithBytes * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - TestEndsWithBytes.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.TestEndsWithBytes"; + TestEndsWithBytes.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.TestEndsWithBytes"; }; return TestEndsWithBytes; @@ -7912,10 +8020,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.TestMapFieldsNoBinary * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - TestMapFieldsNoBinary.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.TestMapFieldsNoBinary"; + TestMapFieldsNoBinary.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.TestMapFieldsNoBinary"; }; return TestMapFieldsNoBinary; @@ -8126,10 +8238,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.MapValueMessageNoBinary * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - MapValueMessageNoBinary.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.MapValueMessageNoBinary"; + MapValueMessageNoBinary.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.MapValueMessageNoBinary"; }; return MapValueMessageNoBinary; @@ -8297,10 +8413,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.Deeply * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Deeply.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.Deeply"; + Deeply.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.Deeply"; }; Deeply.Nested = (function() { @@ -8465,10 +8585,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.Deeply.Nested * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Nested.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.Deeply.Nested"; + Nested.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.Deeply.Nested"; }; Nested.Message = (function() { @@ -8660,10 +8784,14 @@ $root.jspb = (function() { * @function getTypeUrl * @memberof jspb.test.Deeply.Nested.Message * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Message.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/jspb.test.Deeply.Nested.Message"; + Message.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/jspb.test.Deeply.Nested.Message"; }; return Message; @@ -8909,10 +9037,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.FileDescriptorSet * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - FileDescriptorSet.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.FileDescriptorSet"; + FileDescriptorSet.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FileDescriptorSet"; }; return FileDescriptorSet; @@ -9504,10 +9636,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.FileDescriptorProto * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - FileDescriptorProto.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.FileDescriptorProto"; + FileDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FileDescriptorProto"; }; return FileDescriptorProto; @@ -10071,10 +10207,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.DescriptorProto * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - DescriptorProto.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.DescriptorProto"; + DescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.DescriptorProto"; }; DescriptorProto.ExtensionRange = (function() { @@ -10289,10 +10429,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.DescriptorProto.ExtensionRange * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - ExtensionRange.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.DescriptorProto.ExtensionRange"; + ExtensionRange.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.DescriptorProto.ExtensionRange"; }; return ExtensionRange; @@ -10510,10 +10654,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.DescriptorProto.ReservedRange * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - ReservedRange.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.DescriptorProto.ReservedRange"; + ReservedRange.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.DescriptorProto.ReservedRange"; }; return ReservedRange; @@ -11026,10 +11174,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.FieldDescriptorProto * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - FieldDescriptorProto.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.FieldDescriptorProto"; + FieldDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldDescriptorProto"; }; /** @@ -11314,10 +11466,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.OneofDescriptorProto * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - OneofDescriptorProto.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.OneofDescriptorProto"; + OneofDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.OneofDescriptorProto"; }; return OneofDescriptorProto; @@ -11584,10 +11740,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.EnumDescriptorProto * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EnumDescriptorProto.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.EnumDescriptorProto"; + EnumDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.EnumDescriptorProto"; }; return EnumDescriptorProto; @@ -11832,10 +11992,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.EnumValueDescriptorProto * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EnumValueDescriptorProto.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.EnumValueDescriptorProto"; + EnumValueDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.EnumValueDescriptorProto"; }; return EnumValueDescriptorProto; @@ -12102,10 +12266,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.ServiceDescriptorProto * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - ServiceDescriptorProto.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.ServiceDescriptorProto"; + ServiceDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.ServiceDescriptorProto"; }; return ServiceDescriptorProto; @@ -12416,10 +12584,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.MethodDescriptorProto * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - MethodDescriptorProto.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.MethodDescriptorProto"; + MethodDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.MethodDescriptorProto"; }; return MethodDescriptorProto; @@ -12963,10 +13135,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.FileOptions * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - FileOptions.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.FileOptions"; + FileOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FileOptions"; }; /** @@ -13288,10 +13464,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.MessageOptions * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - MessageOptions.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.MessageOptions"; + MessageOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.MessageOptions"; }; return MessageOptions; @@ -13677,10 +13857,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.FieldOptions * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - FieldOptions.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.FieldOptions"; + FieldOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions"; }; /** @@ -13928,10 +14112,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.OneofOptions * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - OneofOptions.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.OneofOptions"; + OneofOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.OneofOptions"; }; return OneofOptions; @@ -14215,10 +14403,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.EnumOptions * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EnumOptions.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.EnumOptions"; + EnumOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.EnumOptions"; }; return EnumOptions; @@ -14457,10 +14649,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.EnumValueOptions * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EnumValueOptions.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.EnumValueOptions"; + EnumValueOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.EnumValueOptions"; }; return EnumValueOptions; @@ -14699,10 +14895,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.ServiceOptions * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - ServiceOptions.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.ServiceOptions"; + ServiceOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.ServiceOptions"; }; return ServiceOptions; @@ -14982,10 +15182,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.MethodOptions * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - MethodOptions.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.MethodOptions"; + MethodOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.MethodOptions"; }; /** @@ -15388,10 +15592,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.UninterpretedOption * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - UninterpretedOption.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.UninterpretedOption"; + UninterpretedOption.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.UninterpretedOption"; }; UninterpretedOption.NamePart = (function() { @@ -15606,10 +15814,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.UninterpretedOption.NamePart * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - NamePart.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.UninterpretedOption.NamePart"; + NamePart.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.UninterpretedOption.NamePart"; }; return NamePart; @@ -15828,10 +16040,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.SourceCodeInfo * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - SourceCodeInfo.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.SourceCodeInfo"; + SourceCodeInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.SourceCodeInfo"; }; SourceCodeInfo.Location = (function() { @@ -16178,10 +16394,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.SourceCodeInfo.Location * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Location.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.SourceCodeInfo.Location"; + Location.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.SourceCodeInfo.Location"; }; return Location; @@ -16400,10 +16620,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.GeneratedCodeInfo * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - GeneratedCodeInfo.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.GeneratedCodeInfo"; + GeneratedCodeInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.GeneratedCodeInfo"; }; GeneratedCodeInfo.Annotation = (function() { @@ -16687,10 +16911,14 @@ $root.google = (function() { * @function getTypeUrl * @memberof google.protobuf.GeneratedCodeInfo.Annotation * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Annotation.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/google.protobuf.GeneratedCodeInfo.Annotation"; + Annotation.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.GeneratedCodeInfo.Annotation"; }; return Annotation; diff --git a/tests/data/type_url.js b/tests/data/type_url.js index 901657966..3cf7daf35 100644 --- a/tests/data/type_url.js +++ b/tests/data/type_url.js @@ -203,10 +203,14 @@ $root.TypeUrlTest = (function() { * @function getTypeUrl * @memberof TypeUrlTest * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - TypeUrlTest.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/TypeUrlTest"; + TypeUrlTest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/TypeUrlTest"; }; TypeUrlTest.Nested = (function() { @@ -398,10 +402,14 @@ $root.TypeUrlTest = (function() { * @function getTypeUrl * @memberof TypeUrlTest.Nested * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Nested.getTypeUrl = function getTypeUrl() { - return "type.googleapis.com/TypeUrlTest.Nested"; + Nested.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/TypeUrlTest.Nested"; }; return Nested; diff --git a/tests/gen_type_url.js b/tests/gen_type_url.js index da9bc3169..863bacfca 100644 --- a/tests/gen_type_url.js +++ b/tests/gen_type_url.js @@ -5,5 +5,7 @@ var TypeUrlTest = require("./data/type_url").TypeUrlTest; tape.test("getTypeUrl method", function(test) { test.equal(TypeUrlTest.getTypeUrl(), "type.googleapis.com/TypeUrlTest", "should have a valid type url"); test.equal(TypeUrlTest.Nested.getTypeUrl(), "type.googleapis.com/TypeUrlTest.Nested", "nested messages should have a valid type url"); + test.equal(TypeUrlTest.getTypeUrl("example.com"), "example.com/TypeUrlTest", "should have a valid type url override"); + test.equal(TypeUrlTest.Nested.getTypeUrl("example.com"), "example.com/TypeUrlTest.Nested", "nested messages should have a valid type url override"); test.end(); });