grpc-code-gen
Advanced tools
Comparing version 3.3.3 to 3.4.0
@@ -281,2 +281,6 @@ "use strict"; | ||
} | ||
let callOptions = {}; | ||
if (fs.existsSync(configFilePath)) { | ||
callOptions = require(configFilePath).callOptions || {}; | ||
} | ||
if (serviceCode) { | ||
@@ -366,3 +370,7 @@ const grpcObjPath = getAbsPath(`grpcObj.${moduleSuffix}`, baseDir); | ||
const responseType = `types.${getTsType(method.responseType, packageName, config).tsType}`; | ||
return ` ${method.name}(request: ${requestType}): Promise<${responseType}>;`; | ||
return ` ${method.name}( | ||
request: ${requestType}, | ||
options?: { deadline?: Date | number; flags?: number; host?: string; }, | ||
callback?: (err: Error, response: ${responseType}), | ||
): Promise<${responseType}>;`; | ||
}); | ||
@@ -388,3 +396,12 @@ if (typescript) { | ||
if (!/^\\$/.test(key)) { | ||
Service.prototype[key] = promisify(Service.prototype[key]); | ||
Service.prototype[key] = promisify(function(request, options, callback){ | ||
if (typeof callback !== 'undefined') { | ||
options = Object.assign(${JSON.stringify(callOptions)}, options); | ||
} else { | ||
callback = options; | ||
options = ${JSON.stringify(callOptions)}; | ||
} | ||
Service.prototype[key](request, options, callback); | ||
}); | ||
} | ||
@@ -391,0 +408,0 @@ });`, |
{ | ||
"name": "grpc-code-gen", | ||
"version": "3.3.3", | ||
"version": "3.4.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/yunkeCN/grpc-code-gen.git", |
@@ -346,2 +346,7 @@ import * as fs from 'fs-extra'; | ||
let callOptions = {}; | ||
if (fs.existsSync(configFilePath)) { | ||
callOptions = require(configFilePath).callOptions || {}; | ||
} | ||
if (serviceCode) { | ||
@@ -438,6 +443,9 @@ const grpcObjPath = getAbsPath(`grpcObj.${moduleSuffix}`, baseDir); | ||
const responseType = `types.${getTsType(method.responseType, packageName, config).tsType}`; | ||
return ` ${method.name}(request: ${requestType}): Promise<${responseType}>;` | ||
return ` ${method.name}( | ||
request: ${requestType}, | ||
options?: { deadline?: Date | number; flags?: number; host?: string; }, | ||
callback?: (err: Error, response: ${responseType}), | ||
): Promise<${responseType}>;` | ||
}); | ||
if (typescript) { | ||
@@ -462,3 +470,12 @@ const typeName = 'I' + service.name; | ||
if (!/^\\$/.test(key)) { | ||
Service.prototype[key] = promisify(Service.prototype[key]); | ||
Service.prototype[key] = promisify(function(request, options, callback){ | ||
if (typeof callback !== 'undefined') { | ||
options = Object.assign(${JSON.stringify(callOptions)}, options); | ||
} else { | ||
callback = options; | ||
options = ${JSON.stringify(callOptions)}; | ||
} | ||
Service.prototype[key](request, options, callback); | ||
}); | ||
} | ||
@@ -465,0 +482,0 @@ });`, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
120889
30
1791
9