ts-proto 1.105.0 → 1.105.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.105.1](https://github.com/stephenh/ts-proto/compare/v1.105.0...v1.105.1) (2022-02-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * generate canonical JSON encoding for FieldMasks ([#510](https://github.com/stephenh/ts-proto/issues/510)) ([0ec4e97](https://github.com/stephenh/ts-proto/commit/0ec4e97a2649dc15af1c925f8a2ff6adf1e17d9b))
7
+
1
8
  # [1.105.0](https://github.com/stephenh/ts-proto/compare/v1.104.1...v1.105.0) (2022-02-12)
2
9
 
3
10
 
package/README.markdown CHANGED
@@ -331,7 +331,7 @@ Generated code will be placed in the Gradle build directory.
331
331
 
332
332
  (Note that this only uses the grpc-web runtime, you don't need to use any of their generated code, i.e. the ts-proto output replaces their `ts-protoc-gen` output.)
333
333
 
334
- You'll need to add the `@improbable-eng/grpc-web` and a transport to your project's `package.json`; see the `integration/grpc-web` directory for a working example.
334
+ You'll need to add the `@improbable-eng/grpc-web` and a transport to your project's `package.json`; see the `integration/grpc-web` directory for a working example. Also see [#504](https://github.com/stephenh/ts-proto/issues/504) for integrating with [grpc-web-devtools](https://github.com/SafetyCulture/grpc-web-devtools).
335
335
 
336
336
  - With `--ts_proto_opt=returnObservable=true`, the return type of service methods will be `Observable<T>` instead of `Promise<T>`.
337
337
 
package/build/main.js CHANGED
@@ -934,6 +934,9 @@ function generateFromJson(ctx, fullName, messageDesc) {
934
934
  else if (types_1.isAnyValueType(field) || types_1.isStructType(field)) {
935
935
  return ts_poet_1.code `${from}`;
936
936
  }
937
+ else if (types_1.isFieldMaskType(field)) {
938
+ return ts_poet_1.code `{paths: ${from}.split(",")}`;
939
+ }
937
940
  else if (types_1.isListValueType(field)) {
938
941
  return ts_poet_1.code `[...${from}]`;
939
942
  }
@@ -1151,6 +1154,9 @@ function generateToJson(ctx, fullName, messageDesc) {
1151
1154
  else if (types_1.isAnyValueType(field)) {
1152
1155
  return ts_poet_1.code `${from}`;
1153
1156
  }
1157
+ else if (types_1.isFieldMaskType(field)) {
1158
+ return ts_poet_1.code `${from}.paths.join()`;
1159
+ }
1154
1160
  else if (types_1.isMessage(field) && !types_1.isValueType(ctx, field) && !types_1.isMapType(ctx, messageDesc, field)) {
1155
1161
  const type = types_1.basicTypeName(ctx, field, { keepValueType: true });
1156
1162
  return ts_poet_1.code `${from} ? ${type}.toJSON(${from}) : ${types_1.defaultValue(ctx, field)}`;
@@ -1323,7 +1329,7 @@ function generateFromPartial(ctx, fullName, messageDesc) {
1323
1329
  && object.${oneofName}?.${fieldName} !== null
1324
1330
  ) {
1325
1331
  message.${oneofName} = { $case: '${fieldName}', ${fieldName}: ${v} };
1326
- }
1332
+ }
1327
1333
  `);
1328
1334
  }
1329
1335
  else if (readSnippet(`x`).toCodeString() == 'x') {
@@ -1362,7 +1368,7 @@ function generateWrap(ctx, fullProtoTypeName) {
1362
1368
  if (ctx.options.oneof === options_1.OneofOption.UNIONS) {
1363
1369
  chunks.push(ts_poet_1.code `wrap(value: any): Value {
1364
1370
  const result = createBaseValue();
1365
-
1371
+
1366
1372
  if (value === null) {
1367
1373
  result.kind = {$case: 'nullValue', nullValue: NullValue.NULL_VALUE};
1368
1374
  } else if (typeof value === 'boolean') {
package/build/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.detectBatchMethod = exports.responsePromiseOrObservable = exports.responseObservable = exports.responsePromise = exports.responseType = exports.requestType = exports.rawRequestType = exports.detectMapType = exports.toTypeName = exports.getEnumMethod = exports.messageToTypeName = exports.wrapperTypeName = exports.valueTypeName = exports.isEmptyType = exports.isLongValueType = exports.isStructTypeName = exports.isStructType = exports.isListValueTypeName = exports.isListValueType = exports.isBytesValueType = exports.isAnyValueTypeName = exports.isAnyValueType = exports.isValueType = exports.isTimestamp = exports.isObjectId = exports.isMapType = exports.isWholeNumber = exports.isLong = exports.isRepeated = exports.isWithinOneOfThatShouldBeUnion = exports.isWithinOneOf = exports.isEnum = exports.isMessage = exports.isBytes = exports.isPrimitive = exports.isOptionalProperty = exports.isScalar = exports.createTypeMap = exports.notDefaultCheck = exports.defaultValue = exports.packedType = exports.toReaderCall = exports.basicTypeName = exports.basicLongWireType = exports.basicWireType = void 0;
3
+ exports.detectBatchMethod = exports.responsePromiseOrObservable = exports.responseObservable = exports.responsePromise = exports.responseType = exports.requestType = exports.rawRequestType = exports.detectMapType = exports.toTypeName = exports.getEnumMethod = exports.messageToTypeName = exports.wrapperTypeName = exports.valueTypeName = exports.isEmptyType = exports.isLongValueType = exports.isStructTypeName = exports.isStructType = exports.isListValueTypeName = exports.isListValueType = exports.isFieldMaskTypeName = exports.isFieldMaskType = exports.isBytesValueType = exports.isAnyValueTypeName = exports.isAnyValueType = exports.isValueType = exports.isTimestamp = exports.isObjectId = exports.isMapType = exports.isWholeNumber = exports.isLong = exports.isRepeated = exports.isWithinOneOfThatShouldBeUnion = exports.isWithinOneOf = exports.isEnum = exports.isMessage = exports.isBytes = exports.isPrimitive = exports.isOptionalProperty = exports.isScalar = exports.createTypeMap = exports.notDefaultCheck = exports.defaultValue = exports.packedType = exports.toReaderCall = exports.basicTypeName = exports.basicLongWireType = exports.basicWireType = void 0;
4
4
  const ts_proto_descriptors_1 = require("ts-proto-descriptors");
5
5
  const ts_poet_1 = require("ts-poet");
6
6
  const options_1 = require("./options");
@@ -403,6 +403,14 @@ function isBytesValueType(field) {
403
403
  return field.typeName === '.google.protobuf.BytesValue';
404
404
  }
405
405
  exports.isBytesValueType = isBytesValueType;
406
+ function isFieldMaskType(field) {
407
+ return isFieldMaskTypeName(field.typeName);
408
+ }
409
+ exports.isFieldMaskType = isFieldMaskType;
410
+ function isFieldMaskTypeName(typeName) {
411
+ return typeName === 'google.protobuf.FieldMask' || typeName === '.google.protobuf.FieldMask';
412
+ }
413
+ exports.isFieldMaskTypeName = isFieldMaskTypeName;
406
414
  function isListValueType(field) {
407
415
  return isListValueTypeName(field.typeName);
408
416
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "1.105.0",
3
+ "version": "1.105.1",
4
4
  "description": "",
5
5
  "main": "build/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",