Socket
Socket
Sign inDemoInstall

grpc_tools_node_protoc_ts

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc_tools_node_protoc_ts - npm Package Compare versions

Comparing version 2.2.4 to 2.2.5

5

build/lib/format/partial/MessageFormatter.js

@@ -74,2 +74,7 @@ "use strict";

fieldData.camelUpperName = Utility_1.Utility.uppercaseFirst(fieldData.camelCaseName);
// handle reserved keywords in field names like Javascript generator
// see: https://github.com/google/protobuf/blob/ed4321d1cb33199984118d801956822842771e7e/src/google/protobuf/compiler/js/js_generator.cc#L508-L510
if (Utility_1.Utility.isReserved(fieldData.camelCaseName)) {
fieldData.camelCaseName = `pb_${fieldData.camelCaseName}`;
}
fieldData.type = field.getType();

@@ -76,0 +81,0 @@ fieldData.isMapField = false;

@@ -72,3 +72,74 @@ "use strict";

Utility.withAllStdIn = withAllStdIn;
function isReserved(name) {
for (const keyword of reservedKeywords) {
if (name === keyword) {
return true;
}
}
return false;
}
Utility.isReserved = isReserved;
// reserved Javascript keywords used by the Javascript generator
// src: https://github.com/google/protobuf/blob/ed4321d1cb33199984118d801956822842771e7e/src/google/protobuf/compiler/js/js_generator.cc#L60-L119
const reservedKeywords = [
"abstract",
"boolean",
"break",
"byte",
"case",
"catch",
"char",
"class",
"const",
"continue",
"debugger",
"default",
"delete",
"do",
"double",
"else",
"enum",
"export",
"extends",
"false",
"final",
"finally",
"float",
"for",
"function",
"goto",
"if",
"implements",
"import",
"in",
"instanceof",
"int",
"interface",
"long",
"native",
"new",
"null",
"package",
"private",
"protected",
"public",
"return",
"short",
"static",
"super",
"switch",
"synchronized",
"this",
"throw",
"throws",
"transient",
"try",
"typeof",
"var",
"void",
"volatile",
"while",
"with",
];
})(Utility = exports.Utility || (exports.Utility = {}));
//# sourceMappingURL=Utility.js.map

@@ -106,2 +106,35 @@ // package: com.book

export class SpecialCases extends jspb.Message {
getNormal(): string;
setNormal(value: string): void;
getDefault(): string;
setDefault(value: string): void;
getFunction(): string;
setFunction(value: string): void;
getVar(): string;
setVar(value: string): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): SpecialCases.AsObject;
static toObject(includeInstance: boolean, msg: SpecialCases): SpecialCases.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: SpecialCases, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): SpecialCases;
static deserializeBinaryFromReader(message: SpecialCases, reader: jspb.BinaryReader): SpecialCases;
}
export namespace SpecialCases {
export type AsObject = {
normal: string,
pb_default: string,
pb_function: string,
pb_var: string,
}
}
export enum EnumSample {

@@ -108,0 +141,0 @@ UNKNOWN = 0,

@@ -19,2 +19,3 @@ /**

goog.exportSymbol('proto.com.book.GetBookViaAuthor', null, global);
goog.exportSymbol('proto.com.book.SpecialCases', null, global);

@@ -671,3 +672,226 @@ /**

/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.com.book.SpecialCases = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.com.book.SpecialCases, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.com.book.SpecialCases.displayName = 'proto.com.book.SpecialCases';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.com.book.SpecialCases.prototype.toObject = function(opt_includeInstance) {
return proto.com.book.SpecialCases.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.com.book.SpecialCases} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.com.book.SpecialCases.toObject = function(includeInstance, msg) {
var f, obj = {
normal: jspb.Message.getFieldWithDefault(msg, 1, ""),
pb_default: jspb.Message.getFieldWithDefault(msg, 2, ""),
pb_function: jspb.Message.getFieldWithDefault(msg, 3, ""),
pb_var: jspb.Message.getFieldWithDefault(msg, 4, "")
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.com.book.SpecialCases}
*/
proto.com.book.SpecialCases.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.com.book.SpecialCases;
return proto.com.book.SpecialCases.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.com.book.SpecialCases} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.com.book.SpecialCases}
*/
proto.com.book.SpecialCases.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString());
msg.setNormal(value);
break;
case 2:
var value = /** @type {string} */ (reader.readString());
msg.setDefault(value);
break;
case 3:
var value = /** @type {string} */ (reader.readString());
msg.setFunction(value);
break;
case 4:
var value = /** @type {string} */ (reader.readString());
msg.setVar(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.com.book.SpecialCases.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.com.book.SpecialCases.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.com.book.SpecialCases} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.com.book.SpecialCases.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getNormal();
if (f.length > 0) {
writer.writeString(
1,
f
);
}
f = message.getDefault();
if (f.length > 0) {
writer.writeString(
2,
f
);
}
f = message.getFunction();
if (f.length > 0) {
writer.writeString(
3,
f
);
}
f = message.getVar();
if (f.length > 0) {
writer.writeString(
4,
f
);
}
};
/**
* optional string normal = 1;
* @return {string}
*/
proto.com.book.SpecialCases.prototype.getNormal = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/** @param {string} value */
proto.com.book.SpecialCases.prototype.setNormal = function(value) {
jspb.Message.setField(this, 1, value);
};
/**
* optional string default = 2;
* @return {string}
*/
proto.com.book.SpecialCases.prototype.getDefault = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};
/** @param {string} value */
proto.com.book.SpecialCases.prototype.setDefault = function(value) {
jspb.Message.setField(this, 2, value);
};
/**
* optional string function = 3;
* @return {string}
*/
proto.com.book.SpecialCases.prototype.getFunction = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};
/** @param {string} value */
proto.com.book.SpecialCases.prototype.setFunction = function(value) {
jspb.Message.setField(this, 3, value);
};
/**
* optional string var = 4;
* @return {string}
*/
proto.com.book.SpecialCases.prototype.getVar = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, ""));
};
/** @param {string} value */
proto.com.book.SpecialCases.prototype.setVar = function(value) {
jspb.Message.setField(this, 4, value);
};
/**
* @enum {number}

@@ -674,0 +898,0 @@ */

@@ -106,2 +106,35 @@ // package: com.book

export class SpecialCases extends jspb.Message {
getNormal(): string;
setNormal(value: string): void;
getDefault(): string;
setDefault(value: string): void;
getFunction(): string;
setFunction(value: string): void;
getVar(): string;
setVar(value: string): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): SpecialCases.AsObject;
static toObject(includeInstance: boolean, msg: SpecialCases): SpecialCases.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: SpecialCases, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): SpecialCases;
static deserializeBinaryFromReader(message: SpecialCases, reader: jspb.BinaryReader): SpecialCases;
}
export namespace SpecialCases {
export type AsObject = {
normal: string,
pb_default: string,
pb_function: string,
pb_var: string,
}
}
export enum EnumSample {

@@ -108,0 +141,0 @@ UNKNOWN = 0,

@@ -19,2 +19,3 @@ /**

goog.exportSymbol('proto.com.book.GetBookViaAuthor', null, global);
goog.exportSymbol('proto.com.book.SpecialCases', null, global);

@@ -671,3 +672,226 @@ /**

/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.com.book.SpecialCases = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.com.book.SpecialCases, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.com.book.SpecialCases.displayName = 'proto.com.book.SpecialCases';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.com.book.SpecialCases.prototype.toObject = function(opt_includeInstance) {
return proto.com.book.SpecialCases.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.com.book.SpecialCases} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.com.book.SpecialCases.toObject = function(includeInstance, msg) {
var f, obj = {
normal: jspb.Message.getFieldWithDefault(msg, 1, ""),
pb_default: jspb.Message.getFieldWithDefault(msg, 2, ""),
pb_function: jspb.Message.getFieldWithDefault(msg, 3, ""),
pb_var: jspb.Message.getFieldWithDefault(msg, 4, "")
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.com.book.SpecialCases}
*/
proto.com.book.SpecialCases.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.com.book.SpecialCases;
return proto.com.book.SpecialCases.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.com.book.SpecialCases} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.com.book.SpecialCases}
*/
proto.com.book.SpecialCases.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString());
msg.setNormal(value);
break;
case 2:
var value = /** @type {string} */ (reader.readString());
msg.setDefault(value);
break;
case 3:
var value = /** @type {string} */ (reader.readString());
msg.setFunction(value);
break;
case 4:
var value = /** @type {string} */ (reader.readString());
msg.setVar(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.com.book.SpecialCases.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.com.book.SpecialCases.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.com.book.SpecialCases} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.com.book.SpecialCases.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getNormal();
if (f.length > 0) {
writer.writeString(
1,
f
);
}
f = message.getDefault();
if (f.length > 0) {
writer.writeString(
2,
f
);
}
f = message.getFunction();
if (f.length > 0) {
writer.writeString(
3,
f
);
}
f = message.getVar();
if (f.length > 0) {
writer.writeString(
4,
f
);
}
};
/**
* optional string normal = 1;
* @return {string}
*/
proto.com.book.SpecialCases.prototype.getNormal = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/** @param {string} value */
proto.com.book.SpecialCases.prototype.setNormal = function(value) {
jspb.Message.setField(this, 1, value);
};
/**
* optional string default = 2;
* @return {string}
*/
proto.com.book.SpecialCases.prototype.getDefault = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};
/** @param {string} value */
proto.com.book.SpecialCases.prototype.setDefault = function(value) {
jspb.Message.setField(this, 2, value);
};
/**
* optional string function = 3;
* @return {string}
*/
proto.com.book.SpecialCases.prototype.getFunction = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};
/** @param {string} value */
proto.com.book.SpecialCases.prototype.setFunction = function(value) {
jspb.Message.setField(this, 3, value);
};
/**
* optional string var = 4;
* @return {string}
*/
proto.com.book.SpecialCases.prototype.getVar = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, ""));
};
/** @param {string} value */
proto.com.book.SpecialCases.prototype.setVar = function(value) {
jspb.Message.setField(this, 4, value);
};
/**
* @enum {number}

@@ -674,0 +898,0 @@ */

2

package.json
{
"name": "grpc_tools_node_protoc_ts",
"version": "2.2.4",
"version": "2.2.5",
"description": "Generate d.ts definitions for generated js files from grpc_tools_node_protoc",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -97,2 +97,12 @@ grpc_tools_node_protoc_ts

}
// Message with reserved keywords
// see: https://github.com/google/protobuf/blob/cc3fa2ec80d196e045ae05797799f079188106f3/js/compatibility_tests/v3.0.0/test.proto#L66-L72
message SpecialCases {
string normal = 1;
// Examples of Js reserved names that are converted to pb_<name>.
string default = 2;
string function = 3;
string var = 4;
}
```

@@ -207,2 +217,35 @@

export class SpecialCases extends jspb.Message {
getNormal(): string;
setNormal(value: string): void;
getDefault(): string;
setDefault(value: string): void;
getFunction(): string;
setFunction(value: string): void;
getVar(): string;
setVar(value: string): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): SpecialCases.AsObject;
static toObject(includeInstance: boolean, msg: SpecialCases): SpecialCases.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: SpecialCases, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): SpecialCases;
static deserializeBinaryFromReader(message: SpecialCases, reader: jspb.BinaryReader): SpecialCases;
}
export namespace SpecialCases {
export type AsObject = {
normal: string,
pb_default: string,
pb_function: string,
pb_var: string,
}
}
export enum EnumSample {

@@ -302,2 +345,5 @@ UNKNOWN = 0,

## Changes
### 2.2.5
Fix issue of reversed JavaScript keyword code generation. See: [Issue#20](https://github.com/agreatfool/grpc_tools_node_protoc_ts/issues/20) & [PR#21](https://github.com/agreatfool/grpc_tools_node_protoc_ts/pull/21).
### 2.2.4

@@ -304,0 +350,0 @@ Fix issue of conflicted I{$MethodName} name, see: [Issue#19](https://github.com/agreatfool/grpc_tools_node_protoc_ts/issues/19).

@@ -131,2 +131,7 @@ import {

fieldData.camelUpperName = Utility.uppercaseFirst(fieldData.camelCaseName);
// handle reserved keywords in field names like Javascript generator
// see: https://github.com/google/protobuf/blob/ed4321d1cb33199984118d801956822842771e7e/src/google/protobuf/compiler/js/js_generator.cc#L508-L510
if (Utility.isReserved(fieldData.camelCaseName)) {
fieldData.camelCaseName = `pb_${fieldData.camelCaseName}`;
}
fieldData.type = field.getType();

@@ -259,2 +264,2 @@ fieldData.isMapField = false;

}
}

@@ -76,2 +76,73 @@ import {FileDescriptorProto} from "google-protobuf/google/protobuf/descriptor_pb";

export function isReserved(name: string): boolean {
for (const keyword of reservedKeywords) {
if (name === keyword) {
return true;
}
}
return false;
}
// reserved Javascript keywords used by the Javascript generator
// src: https://github.com/google/protobuf/blob/ed4321d1cb33199984118d801956822842771e7e/src/google/protobuf/compiler/js/js_generator.cc#L60-L119
const reservedKeywords = [
"abstract",
"boolean",
"break",
"byte",
"case",
"catch",
"char",
"class",
"const",
"continue",
"debugger",
"default",
"delete",
"do",
"double",
"else",
"enum",
"export",
"extends",
"false",
"final",
"finally",
"float",
"for",
"function",
"goto",
"if",
"implements",
"import",
"in",
"instanceof",
"int",
"interface",
"long",
"native",
"new",
"null",
"package",
"private",
"protected",
"public",
"return",
"short",
"static",
"super",
"switch",
"synchronized",
"this",
"throw",
"throws",
"transient",
"try",
"typeof",
"var",
"void",
"volatile",
"while",
"with",
];
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc