ts-proto 1.175.0 → 1.176.0
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/schema.js +18 -1
- package/package.json +2 -2
package/build/schema.js
CHANGED
|
@@ -188,13 +188,30 @@ function encodedOptionsToOptions(ctx, extendee, encodedOptions) {
|
|
|
188
188
|
for (const key in encodedOptions) {
|
|
189
189
|
const value = encodedOptions[key];
|
|
190
190
|
const extension = extensionCache[extendee][parseInt(key, 10) >>> 3];
|
|
191
|
-
|
|
191
|
+
if (shouldAddOptionDefinition(ctx, extension)) {
|
|
192
|
+
// todo: we should be able to create an option definition ALWAYS, however,
|
|
193
|
+
// we currently cannot do that because the if the extension is a sub-message
|
|
194
|
+
// (and thus, not just a straightforward value), we don't have an JSON object
|
|
195
|
+
// representation of the option - just it's encoded value. Our approach in
|
|
196
|
+
// getExtensionValue is to decode the encoded value into a message, but this
|
|
197
|
+
// Message.decode(...) method is not always included in the generated code.
|
|
198
|
+
// We should fix this so that we can always create an option definition by
|
|
199
|
+
// somehow premptively decoding the encoded value and then inserting it into
|
|
200
|
+
// the option defintion.
|
|
201
|
+
// please refer to inteegration/options-types-only to see this in action
|
|
202
|
+
resultOptions.push(getExtensionValue(ctx, extension, value));
|
|
203
|
+
}
|
|
192
204
|
}
|
|
193
205
|
if (resultOptions.length == 0) {
|
|
194
206
|
return undefined;
|
|
195
207
|
}
|
|
196
208
|
return (0, ts_poet_1.code) `{${(0, ts_poet_1.joinCode)(resultOptions, { on: "," })}}`;
|
|
197
209
|
}
|
|
210
|
+
function shouldAddOptionDefinition(ctx, extension) {
|
|
211
|
+
return (extension.type !== ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_MESSAGE ||
|
|
212
|
+
ctx.options.outputEncodeMethods === true ||
|
|
213
|
+
ctx.options.outputEncodeMethods == "decode-only");
|
|
214
|
+
}
|
|
198
215
|
function resolveMessageOptions(ctx, message) {
|
|
199
216
|
const fieldsOptions = [];
|
|
200
217
|
message.field.forEach((field) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-proto",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.176.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/plugin.js",
|
|
6
6
|
"repository": "github:stephenh/ts-proto",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"case-anything": "^2.1.13",
|
|
71
71
|
"protobufjs": "^7.2.4",
|
|
72
72
|
"ts-poet": "^6.7.0",
|
|
73
|
-
"ts-proto-descriptors": "1.
|
|
73
|
+
"ts-proto-descriptors": "1.16.0"
|
|
74
74
|
},
|
|
75
75
|
"packageManager": "yarn@3.6.0"
|
|
76
76
|
}
|