ts-proto 1.166.0 → 1.166.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/main.js +31 -33
- package/build/options.js +7 -1
- package/package.json +1 -1
package/build/main.js
CHANGED
|
@@ -181,7 +181,7 @@ function generateFile(ctx, fileDesc) {
|
|
|
181
181
|
let hasStreamingMethods = false;
|
|
182
182
|
(0, visit_1.visitServices)(fileDesc, sourceInfo, (serviceDesc, sInfo) => {
|
|
183
183
|
if (options.nestJs) {
|
|
184
|
-
// NestJS is sufficiently different that we special case
|
|
184
|
+
// NestJS is sufficiently different that we special case the client/server interfaces
|
|
185
185
|
// generate nestjs grpc client interface
|
|
186
186
|
chunks.push((0, generate_nestjs_1.generateNestjsServiceClient)(ctx, fileDesc, sInfo, serviceDesc));
|
|
187
187
|
// and the service controller interface
|
|
@@ -194,40 +194,38 @@ function generateFile(ctx, fileDesc) {
|
|
|
194
194
|
}
|
|
195
195
|
chunks.push((0, ts_poet_1.code) `export const ${serviceConstName} = "${serviceDesc.name}";`);
|
|
196
196
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
197
|
+
const uniqueServices = [...new Set(options.outputServices)].sort();
|
|
198
|
+
uniqueServices.forEach((outputService) => {
|
|
199
|
+
if (outputService === options_1.ServiceOption.GRPC) {
|
|
200
|
+
chunks.push((0, generate_grpc_js_1.generateGrpcJsService)(ctx, fileDesc, sInfo, serviceDesc));
|
|
201
|
+
}
|
|
202
|
+
else if (outputService === options_1.ServiceOption.NICE_GRPC) {
|
|
203
|
+
chunks.push((0, generate_nice_grpc_1.generateNiceGrpcService)(ctx, fileDesc, sInfo, serviceDesc));
|
|
204
|
+
}
|
|
205
|
+
else if (outputService === options_1.ServiceOption.GENERIC) {
|
|
206
|
+
chunks.push((0, generate_generic_service_definition_1.generateGenericServiceDefinition)(ctx, fileDesc, sInfo, serviceDesc));
|
|
207
|
+
}
|
|
208
|
+
else if (outputService === options_1.ServiceOption.DEFAULT) {
|
|
209
|
+
// This service could be Twirp or grpc-web or JSON (maybe). So far all of their
|
|
210
|
+
// interfaces are fairly similar so we share the same service interface.
|
|
211
|
+
chunks.push((0, generate_services_1.generateService)(ctx, fileDesc, sInfo, serviceDesc));
|
|
212
|
+
if (options.outputClientImpl === true) {
|
|
213
|
+
chunks.push((0, generate_services_1.generateServiceClientImpl)(ctx, fileDesc, serviceDesc));
|
|
208
214
|
}
|
|
209
|
-
else if (
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (!method.clientStreaming) {
|
|
221
|
-
chunks.push((0, generate_grpc_web_1.generateGrpcMethodDesc)(ctx, serviceDesc, method));
|
|
222
|
-
}
|
|
223
|
-
if (method.serverStreaming) {
|
|
224
|
-
hasServerStreamingMethods = true;
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
}
|
|
215
|
+
else if (options.outputClientImpl === "grpc-web") {
|
|
216
|
+
chunks.push((0, generate_grpc_web_1.generateGrpcClientImpl)(ctx, fileDesc, serviceDesc));
|
|
217
|
+
chunks.push((0, generate_grpc_web_1.generateGrpcServiceDesc)(fileDesc, serviceDesc));
|
|
218
|
+
serviceDesc.method.forEach((method) => {
|
|
219
|
+
if (!method.clientStreaming) {
|
|
220
|
+
chunks.push((0, generate_grpc_web_1.generateGrpcMethodDesc)(ctx, serviceDesc, method));
|
|
221
|
+
}
|
|
222
|
+
if (method.serverStreaming) {
|
|
223
|
+
hasServerStreamingMethods = true;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
228
226
|
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
231
229
|
serviceDesc.method.forEach((methodDesc, _index) => {
|
|
232
230
|
if (methodDesc.serverStreaming || methodDesc.clientStreaming) {
|
|
233
231
|
hasStreamingMethods = true;
|
package/build/options.js
CHANGED
|
@@ -142,9 +142,15 @@ function optionsFromParameter(parameter) {
|
|
|
142
142
|
if (typeof options.outputServices == "string") {
|
|
143
143
|
options.outputServices = [options.outputServices];
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
// Assume the user wants the default service output, unless they're using nestJs, which has
|
|
146
|
+
// its own controllers output (although nestjs users can ask for other services too).
|
|
147
|
+
if (options.outputServices.length == 0 && !options.nestJs) {
|
|
146
148
|
options.outputServices = [ServiceOption.DEFAULT];
|
|
147
149
|
}
|
|
150
|
+
// If using nestJs + other services, add the encode methods back
|
|
151
|
+
if (options.nestJs && options.outputServices.length > 0) {
|
|
152
|
+
options.outputEncodeMethods = true;
|
|
153
|
+
}
|
|
148
154
|
if (options.useDate === true) {
|
|
149
155
|
// Treat useDate=true as DATE
|
|
150
156
|
options.useDate = DateOption.DATE;
|