@fintekkers/ledger-models 0.4.3 → 0.4.4

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.
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ // Regression guard for the v4-runtime decode path on packed-enum fields.
3
+ //
4
+ // google-protobuf v4 removed `BinaryReader.prototype.readPackedEnum`. The
5
+ // bundled protoc 3.19.1 generator emits decode code that calls it on every
6
+ // `repeated <enum>` field. compile.sh substitutes the call with the v4
7
+ // `readPackableEnumInto(arr)` equivalent. This test exercises that path
8
+ // end-to-end so a regen-without-patch (or a sed-rule drift) trips CI before
9
+ // shipping.
10
+ //
11
+ // Repro: positions UI hit "reader.readPackedEnum is not a function" on every
12
+ // `/data/positions` request because the QueryPositionRequestProto encode/decode
13
+ // round-trip needed the packed-enum decoder. (second-brain#292)
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const google_protobuf_1 = require("google-protobuf");
16
+ const query_position_request_pb_1 = require("../../../fintekkers/requests/position/query_position_request_pb");
17
+ const field_pb_1 = require("../../../fintekkers/models/position/field_pb");
18
+ const measure_pb_1 = require("../../../fintekkers/models/position/measure_pb");
19
+ describe("packed-enum decode under google-protobuf v4 (second-brain#292)", () => {
20
+ test("v4 BinaryReader does NOT expose readPackedEnum (sentinel for the bug)", () => {
21
+ // If a future google-protobuf release re-adds readPackedEnum, this
22
+ // assertion flips and the regen can drop the post-process patch.
23
+ expect(typeof google_protobuf_1.BinaryReader.prototype.readPackedEnum).toBe("undefined");
24
+ });
25
+ test("v4 BinaryReader exposes readPackableEnumInto (the replacement target)", () => {
26
+ expect(typeof google_protobuf_1.BinaryReader.prototype.readPackableEnumInto).toBe("function");
27
+ });
28
+ test("QueryPositionRequestProto round-trips packed repeated FieldProto + MeasureProto", () => {
29
+ const req = new query_position_request_pb_1.QueryPositionRequestProto();
30
+ req.setFieldsList([
31
+ field_pb_1.FieldProto.SECURITY,
32
+ field_pb_1.FieldProto.PORTFOLIO,
33
+ field_pb_1.FieldProto.AS_OF,
34
+ ]);
35
+ req.setMeasuresList([
36
+ measure_pb_1.MeasureProto.MARKET_VALUE,
37
+ measure_pb_1.MeasureProto.DIRECTED_QUANTITY,
38
+ ]);
39
+ // Encode → bytes → decode. Without the v4-compat substitution this
40
+ // throws `reader.readPackedEnum is not a function`.
41
+ const bytes = req.serializeBinary();
42
+ const decoded = query_position_request_pb_1.QueryPositionRequestProto.deserializeBinary(bytes);
43
+ expect(decoded.getFieldsList()).toEqual([
44
+ field_pb_1.FieldProto.SECURITY,
45
+ field_pb_1.FieldProto.PORTFOLIO,
46
+ field_pb_1.FieldProto.AS_OF,
47
+ ]);
48
+ expect(decoded.getMeasuresList()).toEqual([
49
+ measure_pb_1.MeasureProto.MARKET_VALUE,
50
+ measure_pb_1.MeasureProto.DIRECTED_QUANTITY,
51
+ ]);
52
+ });
53
+ test("empty repeated enum lists round-trip cleanly", () => {
54
+ const req = new query_position_request_pb_1.QueryPositionRequestProto();
55
+ const bytes = req.serializeBinary();
56
+ const decoded = query_position_request_pb_1.QueryPositionRequestProto.deserializeBinary(bytes);
57
+ expect(decoded.getFieldsList()).toEqual([]);
58
+ expect(decoded.getMeasuresList()).toEqual([]);
59
+ });
60
+ });
61
+ //# sourceMappingURL=query_position_request.packed_enum_v4.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query_position_request.packed_enum_v4.test.js","sourceRoot":"","sources":["query_position_request.packed_enum_v4.test.ts"],"names":[],"mappings":";AAAA,yEAAyE;AACzE,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,uEAAuE;AACvE,wEAAwE;AACxE,4EAA4E;AAC5E,YAAY;AACZ,EAAE;AACF,6EAA6E;AAC7E,gFAAgF;AAChF,gEAAgE;;AAEhE,qDAA+C;AAC/C,+GAA4G;AAC5G,2EAA0E;AAC1E,+EAA8E;AAE9E,QAAQ,CAAC,gEAAgE,EAAE,GAAG,EAAE;IAC5E,IAAI,CAAC,uEAA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CAAC;QAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,eAAe,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,qDAAyB,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACnE,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,65 @@
1
+ // Regression guard for the v4-runtime decode path on packed-enum fields.
2
+ //
3
+ // google-protobuf v4 removed `BinaryReader.prototype.readPackedEnum`. The
4
+ // bundled protoc 3.19.1 generator emits decode code that calls it on every
5
+ // `repeated <enum>` field. compile.sh substitutes the call with the v4
6
+ // `readPackableEnumInto(arr)` equivalent. This test exercises that path
7
+ // end-to-end so a regen-without-patch (or a sed-rule drift) trips CI before
8
+ // shipping.
9
+ //
10
+ // Repro: positions UI hit "reader.readPackedEnum is not a function" on every
11
+ // `/data/positions` request because the QueryPositionRequestProto encode/decode
12
+ // round-trip needed the packed-enum decoder. (second-brain#292)
13
+
14
+ import { BinaryReader } from "google-protobuf";
15
+ import { QueryPositionRequestProto } from "../../../fintekkers/requests/position/query_position_request_pb";
16
+ import { FieldProto } from "../../../fintekkers/models/position/field_pb";
17
+ import { MeasureProto } from "../../../fintekkers/models/position/measure_pb";
18
+
19
+ describe("packed-enum decode under google-protobuf v4 (second-brain#292)", () => {
20
+ test("v4 BinaryReader does NOT expose readPackedEnum (sentinel for the bug)", () => {
21
+ // If a future google-protobuf release re-adds readPackedEnum, this
22
+ // assertion flips and the regen can drop the post-process patch.
23
+ expect(typeof (BinaryReader.prototype as any).readPackedEnum).toBe("undefined");
24
+ });
25
+
26
+ test("v4 BinaryReader exposes readPackableEnumInto (the replacement target)", () => {
27
+ expect(typeof (BinaryReader.prototype as any).readPackableEnumInto).toBe("function");
28
+ });
29
+
30
+ test("QueryPositionRequestProto round-trips packed repeated FieldProto + MeasureProto", () => {
31
+ const req = new QueryPositionRequestProto();
32
+ req.setFieldsList([
33
+ FieldProto.SECURITY,
34
+ FieldProto.PORTFOLIO,
35
+ FieldProto.AS_OF,
36
+ ]);
37
+ req.setMeasuresList([
38
+ MeasureProto.MARKET_VALUE,
39
+ MeasureProto.DIRECTED_QUANTITY,
40
+ ]);
41
+
42
+ // Encode → bytes → decode. Without the v4-compat substitution this
43
+ // throws `reader.readPackedEnum is not a function`.
44
+ const bytes = req.serializeBinary();
45
+ const decoded = QueryPositionRequestProto.deserializeBinary(bytes);
46
+
47
+ expect(decoded.getFieldsList()).toEqual([
48
+ FieldProto.SECURITY,
49
+ FieldProto.PORTFOLIO,
50
+ FieldProto.AS_OF,
51
+ ]);
52
+ expect(decoded.getMeasuresList()).toEqual([
53
+ MeasureProto.MARKET_VALUE,
54
+ MeasureProto.DIRECTED_QUANTITY,
55
+ ]);
56
+ });
57
+
58
+ test("empty repeated enum lists round-trip cleanly", () => {
59
+ const req = new QueryPositionRequestProto();
60
+ const bytes = req.serializeBinary();
61
+ const decoded = QueryPositionRequestProto.deserializeBinary(bytes);
62
+ expect(decoded.getFieldsList()).toEqual([]);
63
+ expect(decoded.getMeasuresList()).toEqual([]);
64
+ });
65
+ });
@@ -160,13 +160,13 @@ proto.fintekkers.requests.position.QueryPositionRequestProto.deserializeBinaryFr
160
160
  msg.setPositionView(value);
161
161
  break;
162
162
  case 30:
163
- var values = /** @type {!Array<!proto.fintekkers.models.position.FieldProto>} */ (reader.isDelimited() ? reader.readPackedEnum() : [reader.readEnum()]);
163
+ var values = /** @type {!Array<!proto.fintekkers.models.position.FieldProto>} */ (reader.isDelimited() ? (function(){var arr=[];reader.readPackableEnumInto(arr);return arr;})() : [reader.readEnum()]);
164
164
  for (var i = 0; i < values.length; i++) {
165
165
  msg.addFields(values[i]);
166
166
  }
167
167
  break;
168
168
  case 31:
169
- var values = /** @type {!Array<!proto.fintekkers.models.position.MeasureProto>} */ (reader.isDelimited() ? reader.readPackedEnum() : [reader.readEnum()]);
169
+ var values = /** @type {!Array<!proto.fintekkers.models.position.MeasureProto>} */ (reader.isDelimited() ? (function(){var arr=[];reader.readPackableEnumInto(arr);return arr;})() : [reader.readEnum()]);
170
170
  for (var i = 0; i < values.length; i++) {
171
171
  msg.addMeasures(values[i]);
172
172
  }
@@ -132,7 +132,7 @@ proto.fintekkers.requests.security.GetFieldsResponseProto.deserializeBinaryFromR
132
132
  msg.setVersion(value);
133
133
  break;
134
134
  case 10:
135
- var values = /** @type {!Array<!proto.fintekkers.models.position.FieldProto>} */ (reader.isDelimited() ? reader.readPackedEnum() : [reader.readEnum()]);
135
+ var values = /** @type {!Array<!proto.fintekkers.models.position.FieldProto>} */ (reader.isDelimited() ? (function(){var arr=[];reader.readPackableEnumInto(arr);return arr;})() : [reader.readEnum()]);
136
136
  for (var i = 0; i < values.length; i++) {
137
137
  msg.addFields(values[i]);
138
138
  }
@@ -477,7 +477,7 @@ proto.fintekkers.requests.valuation.CurveRequestProto.deserializeBinaryFromReade
477
477
  msg.setAsofDatetime(value);
478
478
  break;
479
479
  case 20:
480
- var values = /** @type {!Array<!proto.fintekkers.models.position.MeasureProto>} */ (reader.isDelimited() ? reader.readPackedEnum() : [reader.readEnum()]);
480
+ var values = /** @type {!Array<!proto.fintekkers.models.position.MeasureProto>} */ (reader.isDelimited() ? (function(){var arr=[];reader.readPackableEnumInto(arr);return arr;})() : [reader.readEnum()]);
481
481
  for (var i = 0; i < values.length; i++) {
482
482
  msg.addCurveTypes(values[i]);
483
483
  }
@@ -156,7 +156,7 @@ proto.fintekkers.requests.valuation.ValuationRequestProto.deserializeBinaryFromR
156
156
  msg.setOperationType(value);
157
157
  break;
158
158
  case 30:
159
- var values = /** @type {!Array<!proto.fintekkers.models.position.MeasureProto>} */ (reader.isDelimited() ? reader.readPackedEnum() : [reader.readEnum()]);
159
+ var values = /** @type {!Array<!proto.fintekkers.models.position.MeasureProto>} */ (reader.isDelimited() ? (function(){var arr=[];reader.readPackableEnumInto(arr);return arr;})() : [reader.readEnum()]);
160
160
  for (var i = 0; i < values.length; i++) {
161
161
  msg.addMeasures(values[i]);
162
162
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fintekkers/ledger-models",
3
3
  "todo": "Replace the version with build script version number",
4
- "version": "0.4.3",
4
+ "version": "0.4.4",
5
5
  "description": "ledger model protos ",
6
6
  "authors": [
7
7
  "David Doherty",