ts-proto 2.15.1 → 2.15.2
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/src/generate-services.js +2 -2
- package/build/src/main.d.ts +1 -1
- package/build/src/main.js +16 -8
- package/package.json +1 -1
|
@@ -339,10 +339,10 @@ function generateCachingRpcMethod(ctx, fileDesc, serviceDesc, methodDesc) {
|
|
|
339
339
|
function generateRpcType(ctx, hasStreamingMethods) {
|
|
340
340
|
const { options } = ctx;
|
|
341
341
|
const metadata = options.metadataType ? (0, ts_poet_1.imp)(options.metadataType) : (0, ts_poet_1.imp)("t:Metadata@@grpc/grpc-js");
|
|
342
|
-
const metadataType = metadata.symbol;
|
|
343
342
|
const maybeContext = options.context ? "<Context>" : "";
|
|
344
343
|
const maybeContextParam = options.context ? "ctx: Context," : "";
|
|
345
|
-
|
|
344
|
+
// Use the import itself, so it is added even if no method of the service refers to it.
|
|
345
|
+
const maybeMetadataParam = options.metadataType || options.addGrpcMetadata ? (0, ts_poet_1.code) `metadata?: ${metadata},` : "";
|
|
346
346
|
const maybeAbortSignalParam = options.useAbortSignal ? "abortSignal?: AbortSignal," : "";
|
|
347
347
|
const methods = [[(0, ts_poet_1.code) `request`, (0, ts_poet_1.code) `Uint8Array`, (0, ts_poet_1.code) `Promise<Uint8Array>`]];
|
|
348
348
|
const additionalMethods = [];
|
package/build/src/main.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ declare function makeDeepPartial(options: Options, longs: ReturnType<typeof make
|
|
|
24
24
|
Exact: ConditionalOutput;
|
|
25
25
|
};
|
|
26
26
|
declare function makeMessageFns(options: Options, deepPartial: ReturnType<typeof makeDeepPartial>, extension: ReturnType<typeof makeExtensionClass>): {
|
|
27
|
-
MessageFns: ConditionalOutput;
|
|
27
|
+
MessageFns: ConditionalOutput | undefined;
|
|
28
28
|
ExtensionFns: ConditionalOutput;
|
|
29
29
|
ExtensionHolder: ConditionalOutput;
|
|
30
30
|
StructWrapperFns: ConditionalOutput;
|
package/build/src/main.js
CHANGED
|
@@ -88,14 +88,15 @@ function generateFile(ctx, fileDesc) {
|
|
|
88
88
|
(0, visit_1.visit)(fileDesc, sourceInfo, (fullName, message, _sInfo, fullProtoTypeName) => {
|
|
89
89
|
const fullTypeName = (0, utils_1.maybePrefixPackage)(fileDesc, fullProtoTypeName);
|
|
90
90
|
const outputWrapAndUnwrap = (0, generate_struct_wrappers_1.isWrapperType)(fullTypeName);
|
|
91
|
-
// Only decode, fromPartial, and wrap use the createBase method
|
|
91
|
+
// Only decode, fromPartial, and wrap use the createBase method. The deep `Value.wrap`
|
|
92
|
+
// generated for NestJS builds its result without it.
|
|
92
93
|
if ((options.outputEncodeMethods &&
|
|
93
94
|
options.outputEncodeMethods !== "encode-no-creation" &&
|
|
94
95
|
options.outputEncodeMethods !== "encode-only" &&
|
|
95
96
|
(options.outputDecodeIncludeTypes === "" ||
|
|
96
97
|
new RegExp(options.outputDecodeIncludeTypes).test(fullTypeName))) ||
|
|
97
98
|
options.outputPartialMethods ||
|
|
98
|
-
outputWrapAndUnwrap) {
|
|
99
|
+
(outputWrapAndUnwrap && !(options.nestJs && (0, types_1.isAnyValueTypeName)(fullTypeName)))) {
|
|
99
100
|
chunks.push(generateBaseInstanceFactory(ctx, fullName, message, fullTypeName));
|
|
100
101
|
}
|
|
101
102
|
const staticMembers = [];
|
|
@@ -172,7 +173,10 @@ function generateFile(ctx, fileDesc) {
|
|
|
172
173
|
const messageFnsTypeParameters = [fullName, hasTypeMember && `'${fullTypeName}'`]
|
|
173
174
|
.filter((p) => !!p)
|
|
174
175
|
.join(", ");
|
|
175
|
-
const interfaces = [
|
|
176
|
+
const interfaces = [];
|
|
177
|
+
if (utils.MessageFns) {
|
|
178
|
+
interfaces.push((0, ts_poet_1.code) `${utils.MessageFns}<${messageFnsTypeParameters}>`);
|
|
179
|
+
}
|
|
176
180
|
if (options.outputEncodeMethods &&
|
|
177
181
|
options.outputExtensions &&
|
|
178
182
|
options.unknownFields &&
|
|
@@ -601,11 +605,15 @@ function makeMessageFns(options, deepPartial, extension) {
|
|
|
601
605
|
}
|
|
602
606
|
}
|
|
603
607
|
const maybeExport = options.exportCommonSymbols ? "export" : "";
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
608
|
+
// Without any common members, e.g. with only the NestJS wrappers, the interface
|
|
609
|
+
// would be empty and its type parameter unused, so it is not generated at all.
|
|
610
|
+
const MessageFns = commonStaticMembers.length > 0
|
|
611
|
+
? (0, ts_poet_1.conditionalOutput)("MessageFns", (0, ts_poet_1.code) `
|
|
612
|
+
${maybeExport} interface MessageFns<T${hasTypeMember ? ", V extends string" : ""}> {
|
|
613
|
+
${(0, ts_poet_1.joinCode)(commonStaticMembers, { on: "\n" })}
|
|
614
|
+
}
|
|
615
|
+
`)
|
|
616
|
+
: undefined;
|
|
609
617
|
const ExtensionFns = (0, ts_poet_1.conditionalOutput)("ExtensionFns", (0, ts_poet_1.code) `
|
|
610
618
|
${maybeExport} interface ExtensionFns<T> {
|
|
611
619
|
${(0, ts_poet_1.joinCode)(extensionStaticMembers, { on: "\n" })}
|