@grpc/proto-loader
Advanced tools
Comparing version 0.7.9 to 0.7.10
@@ -625,3 +625,8 @@ #!/usr/bin/env node | ||
const { inputName, outputName } = useNameFmter(options); | ||
formatter.writeLine(`export interface ${serviceType.name}Definition extends grpc.ServiceDefinition {`); | ||
if (options.grpcLib) { | ||
formatter.writeLine(`export interface ${serviceType.name}Definition extends grpc.ServiceDefinition {`); | ||
} | ||
else { | ||
formatter.writeLine(`export interface ${serviceType.name}Definition {`); | ||
} | ||
formatter.indent(); | ||
@@ -641,4 +646,6 @@ for (const methodName of Object.keys(serviceType.methods).sort()) { | ||
formatter.writeLine(''); | ||
const grpcImportPath = options.grpcLib.startsWith('.') ? getPathToRoot(serviceType) + options.grpcLib : options.grpcLib; | ||
formatter.writeLine(`import type * as grpc from '${grpcImportPath}'`); | ||
if (options.grpcLib) { | ||
const grpcImportPath = options.grpcLib.startsWith('.') ? getPathToRoot(serviceType) + options.grpcLib : options.grpcLib; | ||
formatter.writeLine(`import type * as grpc from '${grpcImportPath}'`); | ||
} | ||
formatter.writeLine(`import type { MethodDefinition } from '@grpc/proto-loader'`); | ||
@@ -654,6 +661,8 @@ const dependencies = new Set(); | ||
formatter.writeLine(''); | ||
generateServiceClientInterface(formatter, serviceType, options); | ||
formatter.writeLine(''); | ||
generateServiceHandlerInterface(formatter, serviceType, options); | ||
formatter.writeLine(''); | ||
if (options.grpcLib) { | ||
generateServiceClientInterface(formatter, serviceType, options); | ||
formatter.writeLine(''); | ||
generateServiceHandlerInterface(formatter, serviceType, options); | ||
formatter.writeLine(''); | ||
} | ||
generateServiceDefinitionInterface(formatter, serviceType, options); | ||
@@ -722,2 +731,5 @@ } | ||
function generateRootFile(formatter, root, options) { | ||
if (!options.grpcLib) { | ||
return; | ||
} | ||
formatter.writeLine(`import type * as grpc from '${options.grpcLib}';`); | ||
@@ -779,7 +791,9 @@ generateDefinitionImports(formatter, root, options); | ||
const masterFileFormatter = new TextFormatter(); | ||
generateRootFile(masterFileFormatter, root, options); | ||
if (options.verbose) { | ||
console.log(`Writing ${options.outDir}/${masterFileName}`); | ||
if (options.grpcLib) { | ||
generateRootFile(masterFileFormatter, root, options); | ||
if (options.verbose) { | ||
console.log(`Writing ${options.outDir}/${masterFileName}`); | ||
} | ||
filePromises.push(writeFile(`${options.outDir}/${masterFileName}`, masterFileFormatter.getFullText())); | ||
} | ||
filePromises.push(writeFile(`${options.outDir}/${masterFileName}`, masterFileFormatter.getFullText())); | ||
filePromises.push(...generateFilesForNamespace(root, options)); | ||
@@ -874,3 +888,3 @@ return filePromises; | ||
outDir: 'Directory in which to output files', | ||
grpcLib: 'The gRPC implementation library that these types will be used with', | ||
grpcLib: 'The gRPC implementation library that these types will be used with. If not provided, some types will not be generated', | ||
inputTemplate: 'Template for mapping input or "permissive" type names', | ||
@@ -880,3 +894,3 @@ outputTemplate: 'Template for mapping output or "restricted" type names', | ||
outputBranded: 'Output property for branded type for "restricted" types with fullName of the Message as its value', | ||
}).demandOption(['outDir', 'grpcLib']) | ||
}).demandOption(['outDir']) | ||
.demand(1) | ||
@@ -883,0 +897,0 @@ .usage('$0 [options] filenames...') |
{ | ||
"name": "@grpc/proto-loader", | ||
"version": "0.7.9", | ||
"version": "0.7.10", | ||
"author": "Google Inc.", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -90,3 +90,4 @@ # gRPC Protobuf Loader | ||
--grpcLib The gRPC implementation library that these types will | ||
be used with [string] [required] | ||
be used with. If not provided, some types will not be | ||
generated [string] | ||
--inputTemplate Template for mapping input or "permissive" type names | ||
@@ -93,0 +94,0 @@ [string] [default: "%s"] |
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
117528
1376
132