Comparing version 1.1.2 to 1.1.3
@@ -48,3 +48,5 @@ "use strict"; | ||
}); | ||
file = file.addInterface(generateRpcType()); | ||
if (fileDesc.service.length > 0) { | ||
file = file.addInterface(generateRpcType()); | ||
} | ||
file = addLongUtilityMethod(file); | ||
@@ -346,7 +348,14 @@ return file; | ||
} | ||
/** | ||
* Creates an `Rpc.request(service, method, data)` abstraction. | ||
* | ||
* This lets clients pass in their own request-promise-ish client. | ||
* | ||
* We don't export this because if a project uses multiple `*.proto` files, | ||
* we don't want our the barrel imports in `index.ts` to have multiple `Rpc` | ||
* types. | ||
*/ | ||
function generateRpcType() { | ||
const data = ts_poet_1.TypeNames.anyType('Uint8Array'); | ||
return ts_poet_1.InterfaceSpec.create('Rpc') | ||
.addModifiers(ts_poet_1.Modifier.EXPORT) | ||
.addFunction(ts_poet_1.FunctionSpec.create('request') | ||
return ts_poet_1.InterfaceSpec.create('Rpc').addFunction(ts_poet_1.FunctionSpec.create('request') | ||
.addParameter('service', ts_poet_1.TypeNames.STRING) | ||
@@ -353,0 +362,0 @@ .addParameter('method', ts_poet_1.TypeNames.STRING) |
{ | ||
"name": "ts-proto", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "build/plugin.js", |
@@ -87,4 +87,7 @@ import { | ||
}); | ||
file = file.addInterface(generateRpcType()); | ||
if (fileDesc.service.length > 0) { | ||
file = file.addInterface(generateRpcType()); | ||
} | ||
file = addLongUtilityMethod(file); | ||
@@ -462,13 +465,20 @@ | ||
/** | ||
* Creates an `Rpc.request(service, method, data)` abstraction. | ||
* | ||
* This lets clients pass in their own request-promise-ish client. | ||
* | ||
* We don't export this because if a project uses multiple `*.proto` files, | ||
* we don't want our the barrel imports in `index.ts` to have multiple `Rpc` | ||
* types. | ||
*/ | ||
function generateRpcType(): InterfaceSpec { | ||
const data = TypeNames.anyType('Uint8Array'); | ||
return InterfaceSpec.create('Rpc') | ||
.addModifiers(Modifier.EXPORT) | ||
.addFunction( | ||
FunctionSpec.create('request') | ||
.addParameter('service', TypeNames.STRING) | ||
.addParameter('method', TypeNames.STRING) | ||
.addParameter('data', data) | ||
.returns(TypeNames.PROMISE.param(data)) | ||
); | ||
return InterfaceSpec.create('Rpc').addFunction( | ||
FunctionSpec.create('request') | ||
.addParameter('service', TypeNames.STRING) | ||
.addParameter('method', TypeNames.STRING) | ||
.addParameter('data', data) | ||
.returns(TypeNames.PROMISE.param(data)) | ||
); | ||
} | ||
@@ -475,0 +485,0 @@ |
Sorry, the diff of this file is not supported yet
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
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
782905
11314