@fintekkers/ledger-models 0.1.61 → 0.1.63

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.
Files changed (102) hide show
  1. package/.env +3 -0
  2. package/node/fintekkers/models/position/field_pb.d.ts +1 -0
  3. package/node/fintekkers/models/position/field_pb.js +1 -0
  4. package/node/fintekkers/models/security/bond/auction_type_grpc_pb.js +1 -0
  5. package/node/fintekkers/models/security/bond/auction_type_pb.d.ts +12 -0
  6. package/node/fintekkers/models/security/bond/auction_type_pb.js +33 -0
  7. package/node/fintekkers/models/security/bond/issuance_grpc_pb.js +1 -0
  8. package/node/fintekkers/models/security/bond/issuance_pb.d.ts +85 -0
  9. package/node/fintekkers/models/security/bond/issuance_pb.js +652 -0
  10. package/node/fintekkers/models/security/security_pb.d.ts +6 -0
  11. package/node/fintekkers/models/security/security_pb.js +64 -2
  12. package/node/fintekkers/requests/transaction/query_transaction_request_pb.d.ts +3 -0
  13. package/node/fintekkers/requests/transaction/query_transaction_request_pb.js +31 -1
  14. package/node/fintekkers/requests/transaction/query_transaction_response_pb.d.ts +7 -0
  15. package/node/fintekkers/requests/transaction/query_transaction_response_pb.js +54 -1
  16. package/node/wrappers/models/portfolio/portfolio.js +41 -0
  17. package/node/wrappers/models/portfolio/portfolio.js.map +1 -0
  18. package/node/wrappers/models/portfolio/portfolio.ts +49 -0
  19. package/node/wrappers/models/position/position.js +14 -9
  20. package/node/wrappers/models/position/position.js.map +1 -1
  21. package/node/wrappers/models/position/position.test.js +43 -0
  22. package/node/wrappers/models/position/position.test.js.map +1 -0
  23. package/node/wrappers/models/position/position.test.ts +70 -0
  24. package/node/wrappers/models/position/position.ts +17 -10
  25. package/node/wrappers/models/position/positionfilter.js +35 -0
  26. package/node/wrappers/models/position/positionfilter.js.map +1 -0
  27. package/node/wrappers/models/position/positionfilter.ts +38 -0
  28. package/node/wrappers/models/security/security.test.js +33 -0
  29. package/node/wrappers/models/security/security.test.js.map +1 -0
  30. package/node/wrappers/models/security/security.test.ts +41 -0
  31. package/node/wrappers/models/transaction/transaction.js +6 -5
  32. package/node/wrappers/models/transaction/transaction.js.map +1 -1
  33. package/node/wrappers/models/transaction/transaction.test.js.map +1 -1
  34. package/node/wrappers/models/transaction/transaction.test.ts +1 -6
  35. package/node/wrappers/models/transaction/transaction.ts +31 -31
  36. package/node/wrappers/models/transaction/transaction_type.js +0 -1
  37. package/node/wrappers/models/transaction/transaction_type.js.map +1 -1
  38. package/node/wrappers/models/transaction/transaction_type.ts +1 -1
  39. package/node/wrappers/models/utils/datetime.js +9 -0
  40. package/node/wrappers/models/utils/datetime.js.map +1 -1
  41. package/node/wrappers/models/utils/datetime.ts +16 -4
  42. package/node/wrappers/models/utils/requestcontext.js +55 -0
  43. package/node/wrappers/models/utils/requestcontext.js.map +1 -0
  44. package/node/wrappers/models/utils/requestcontext.ts +44 -0
  45. package/node/wrappers/models/utils/requestcontext_d.js +1 -0
  46. package/node/wrappers/models/utils/requestcontext_d.js.map +1 -0
  47. package/node/wrappers/models/utils/requestcontext_d.ts +7 -0
  48. package/node/wrappers/models/utils/serialization.js +14 -4
  49. package/node/wrappers/models/utils/serialization.js.map +1 -1
  50. package/node/wrappers/models/utils/serialization.test.js +8 -9
  51. package/node/wrappers/models/utils/serialization.test.js.map +1 -1
  52. package/node/wrappers/models/utils/serialization.test.ts +8 -10
  53. package/node/wrappers/models/utils/serialization.ts +46 -38
  54. package/node/wrappers/models/utils/serialization.util.js +108 -0
  55. package/node/wrappers/models/utils/serialization.util.js.map +1 -0
  56. package/node/wrappers/models/utils/serialization.util.test.js +36 -0
  57. package/node/wrappers/models/utils/serialization.util.test.js.map +1 -0
  58. package/node/wrappers/models/utils/serialization.util.test.ts +47 -0
  59. package/node/wrappers/models/utils/serialization.util.ts +121 -0
  60. package/node/wrappers/services/portfolio-service/PortfolioService.js +8 -16
  61. package/node/wrappers/services/portfolio-service/PortfolioService.js.map +1 -1
  62. package/node/wrappers/services/portfolio-service/PortfolioService.ts +14 -24
  63. package/node/wrappers/services/portfolio-service/portfolio.test.js +30 -34
  64. package/node/wrappers/services/portfolio-service/portfolio.test.js.map +1 -1
  65. package/node/wrappers/services/portfolio-service/portfolio.test.ts +9 -13
  66. package/node/wrappers/services/position-service/PositionService.js +4 -3
  67. package/node/wrappers/services/position-service/PositionService.js.map +1 -1
  68. package/node/wrappers/services/position-service/PositionService.ts +4 -19
  69. package/node/wrappers/services/position-service/position.test.js +24 -9
  70. package/node/wrappers/services/position-service/position.test.js.map +1 -1
  71. package/node/wrappers/services/position-service/position.test.ts +57 -51
  72. package/node/wrappers/services/security-service/SecurityService.js +16 -15
  73. package/node/wrappers/services/security-service/SecurityService.js.map +1 -1
  74. package/node/wrappers/services/security-service/SecurityService.ts +15 -18
  75. package/node/wrappers/services/security-service/security.maturityLadder.test.js +59 -0
  76. package/node/wrappers/services/security-service/security.maturityLadder.test.js.map +1 -0
  77. package/node/wrappers/services/security-service/security.maturityLadder.test.ts +39 -0
  78. package/node/wrappers/services/security-service/security.test.js +19 -7
  79. package/node/wrappers/services/security-service/security.test.js.map +1 -1
  80. package/node/wrappers/services/security-service/security.test.ts +11 -7
  81. package/node/wrappers/services/transaction-service/TransactionService.js +34 -47
  82. package/node/wrappers/services/transaction-service/TransactionService.js.map +1 -1
  83. package/node/wrappers/services/transaction-service/TransactionService.ts +16 -23
  84. package/node/wrappers/services/transaction-service/transaction.test.js +45 -12
  85. package/node/wrappers/services/transaction-service/transaction.test.js.map +1 -1
  86. package/node/wrappers/services/transaction-service/transaction.test.ts +48 -21
  87. package/package.json +2 -1
  88. package/web/fintekkers/models/position/field_pb.d.ts +1 -0
  89. package/web/fintekkers/models/position/field_pb.js +1 -0
  90. package/web/fintekkers/models/security/bond/auction_type_pb.d.ts +8 -0
  91. package/web/fintekkers/models/security/bond/auction_type_pb.js +27 -0
  92. package/web/fintekkers/models/security/bond/issuance_pb.d.ts +82 -0
  93. package/web/fintekkers/models/security/bond/issuance_pb.js +646 -0
  94. package/web/fintekkers/models/security/security_pb.d.ts +7 -0
  95. package/web/fintekkers/models/security/security_pb.js +64 -2
  96. package/web/fintekkers/requests/transaction/query_transaction_request_pb.d.ts +4 -0
  97. package/web/fintekkers/requests/transaction/query_transaction_request_pb.js +31 -1
  98. package/web/fintekkers/requests/transaction/query_transaction_response_pb.d.ts +7 -0
  99. package/web/fintekkers/requests/transaction/query_transaction_response_pb.js +54 -1
  100. package/node/wrappers/models/utils/util.js +0 -28
  101. package/node/wrappers/models/utils/util.js.map +0 -1
  102. package/node/wrappers/models/utils/util.ts +0 -28
@@ -1 +1 @@
1
- {"version":3,"file":"serialization.test.js","sourceRoot":"","sources":["serialization.test.ts"],"names":[],"mappings":";;AAEA,iDAAyD;AACzD,+BAA8B;AAE9B,+BAAkC;AAClC,IAAI,CAAC,2EAA2E,EAAE;IAC9E,iBAAiB,EAAE,CAAC;AACtB,CAAC,CAAC,CAAC;AAEL,SAAS,iBAAiB;IACtB,SAAS,EAAE,CAAC;IAEZ,oCAAoC;IAEpC,IAAM,cAAc,GAAQ,sCAAsB,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACzE,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAEvD,IAAM,gBAAgB,GAAQ,sCAAsB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IACjF,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAEzD,IAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,IAAM,mBAAmB,GAAQ,sCAAsB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACvE,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAE5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AsB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IACjF,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAEhE,IAAM,mBAAmB,GAAQ,sCAAsB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7E,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAEhE,IAAM,qBAAqB,GAAQ,sCAAsB,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAC3F,MAAM,CAAC,qBAAqB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,SAAS;IACd,IAAM,IAAI,GAAS,WAAI,CAAC,MAAM,EAAE,CAAC;IACjC,IAAM,cAAc,GAAc,sCAAsB,CAAC,SAAS,CAAC,IAAI,CAAc,CAAC;IACtF,IAAM,QAAQ,GAAS,sCAAsB,CAAC,WAAW,CAAC,cAAc,CAAS,CAAC;IAElF,IAAM,UAAU,GAAW,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3C,IAAM,cAAc,GAAW,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAEnD,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IACzC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;AACzD,CAAC"}
@@ -4,27 +4,25 @@ import { ProtoSerializationUtil } from './serialization';
4
4
  import { UUID } from './uuid';
5
5
 
6
6
  import assert = require('assert');
7
- test('test creating a security against the api.fintekkers.org portfolio service', () => {
7
+ test('test serialization of key types', () => {
8
8
  testSerialization();
9
9
  });
10
10
 
11
11
  function testSerialization(): void {
12
12
  checkUUID();
13
13
 
14
- //TODO: Make these tests more robust
15
-
16
- const serializedDate: any = ProtoSerializationUtil.serialize(new Date());
17
- assert(serializedDate.toString().indexOf('2023') > -1);
14
+ const march2023 = new Date(2023, 2, 5); //Month is zero-indexed, so 2 == March.
15
+ const serializedDate: any = ProtoSerializationUtil.serialize(march2023);
16
+ assert(serializedDate.toString().indexOf('2023,3,5') > -1);
18
17
 
19
18
  const deserializedDate: any = ProtoSerializationUtil.deserialize(serializedDate);
20
- assert(deserializedDate.toString().indexOf('2023') > -1);
19
+ assert(deserializedDate.toString().indexOf('Mar 05 2023') > -1);
21
20
 
22
- const obj = new Date();
23
- const serializedTimestamp: any = ProtoSerializationUtil.serialize(obj);
24
- assert(serializedTimestamp.toString().indexOf('2023') > -1);
21
+ const serializedTimestamp: any = ProtoSerializationUtil.serialize(march2023);
22
+ assert(serializedTimestamp.toString().indexOf('2023,3,5') > -1);
25
23
 
26
24
  const deserializedTimestamp: any = ProtoSerializationUtil.deserialize(serializedTimestamp);
27
- assert(deserializedTimestamp.toString().indexOf('2023') > -1);
25
+ assert(deserializedTimestamp.toString().indexOf('Mar 05 2023') > -1);
28
26
  }
29
27
 
30
28
  function checkUUID() {
@@ -2,46 +2,54 @@ import { DecimalValueProto } from "../../../fintekkers/models/util/decimal_value
2
2
  import { LocalDateProto } from "../../../fintekkers/models/util/local_date_pb";
3
3
  import { LocalTimestampProto } from "../../../fintekkers/models/util/local_timestamp_pb";
4
4
  import { UUIDProto } from "../../../fintekkers/models/util/uuid_pb";
5
+ import { ZonedDateTime } from "./datetime";
5
6
  import { UUID } from "./uuid";
6
7
 
7
-
8
- interface EnumValueDescriptor {
9
- name: string;
10
- values_by_number: { [key: number]: { name: string } };
8
+ interface EnumValueDescriptor {
9
+ name: string;
10
+ values_by_number: { [key: number]: { name: string } };
11
+ }
12
+
13
+ export class ProtoSerializationUtil {
14
+ static serialize(obj: any): any {
15
+ if (obj instanceof UUID) {
16
+ return obj.toUUIDProto();
17
+ }
18
+ if (obj instanceof Date) {
19
+ return new LocalDateProto()
20
+ .setYear(obj.getFullYear())
21
+ .setMonth(obj.getMonth() + 1)
22
+ .setDay(obj.getDate());
23
+ }
24
+ if (obj instanceof ZonedDateTime) {
25
+ return obj.toProto();
26
+ }
27
+ if (typeof obj === "number") {
28
+ return new DecimalValueProto().setArbitraryPrecisionValue(obj.toString());
29
+ }
30
+
31
+ throw new Error(`Could not serialize object of type ${typeof obj}. Value: ${obj}`);
11
32
  }
12
-
13
- export class ProtoSerializationUtil {
14
- static serialize(obj: any) {
15
- if (obj instanceof UUID) {
16
- return obj.toUUIDProto();
17
- }
18
- if (obj instanceof Date) {
19
- return new LocalDateProto()
20
- .setYear(obj.getUTCFullYear())
21
- .setMonth(obj.getUTCMonth() + 1)
22
- .setDay(obj.getUTCDate());
23
- }
24
- if (typeof obj === "number") {
25
- return new DecimalValueProto().setArbitraryPrecisionValue(obj.toString());
26
- }
27
-
28
- throw new Error(`Could not serialize object of type ${typeof obj}. Value: ${obj}`);
29
- }
30
-
31
- static deserialize(obj: any) {
32
- if (obj instanceof UUIDProto) {
33
- return UUID.fromU8Array(obj.getRawUuid_asU8());
34
- }
35
- if (obj instanceof LocalDateProto) {
36
- return new Date(Date.UTC(obj.getYear(), obj.getMonth() - 1, obj.getDay()));
37
- }
38
- if (obj.enum_name && obj.enum_name === "TRANSACTION_TYPE") {
39
- return null;// new TransactionType(obj.enum_value);
40
- }
41
- if (obj instanceof DecimalValueProto) {
42
- return parseFloat(obj.getArbitraryPrecisionValue());
43
- }
44
-
45
- throw new Error(`Could not deserialize object of type ${typeof obj}. Value: ${obj}`);
33
+
34
+ static deserialize(obj: any): any {
35
+ if (obj instanceof UUIDProto) {
36
+ return UUID.fromU8Array(obj.getRawUuid_asU8());
37
+ }
38
+ if (obj instanceof LocalDateProto) {
39
+ const date = new Date(obj.getYear(), obj.getMonth() - 1, obj.getDay());
40
+ date.setHours(0, 0, 0, 0);
41
+ return date;
42
+ }
43
+ if (obj instanceof LocalTimestampProto) {
44
+ return new ZonedDateTime(obj);
46
45
  }
46
+ if (obj.enum_name && obj.enum_name === "TRANSACTION_TYPE") {
47
+ return null;// new TransactionType(obj.enum_value);
48
+ }
49
+ if (obj instanceof DecimalValueProto) {
50
+ return parseFloat(obj.getArbitraryPrecisionValue());
51
+ }
52
+
53
+ throw new Error(`Could not deserialize object of type ${typeof obj}. Value: ${obj}`);
47
54
  }
55
+ }
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unpack = exports.pack = void 0;
4
+ var any_pb_1 = require("google-protobuf/google/protobuf/any_pb");
5
+ var wrappers_pb_1 = require("google-protobuf/google/protobuf/wrappers_pb");
6
+ var serialization_1 = require("./serialization");
7
+ var local_date_pb_1 = require("../../../fintekkers/models/util/local_date_pb");
8
+ var datetime_1 = require("./datetime");
9
+ var local_timestamp_pb_1 = require("../../../fintekkers/models/util/local_timestamp_pb");
10
+ var uuid_1 = require("./uuid");
11
+ var uuid_pb_1 = require("../../../fintekkers/models/util/uuid_pb");
12
+ function pack(value) {
13
+ if (typeof value === 'string') {
14
+ return packStringIntoAny(value);
15
+ }
16
+ else if (value instanceof Date) {
17
+ var localDateProto = serialization_1.ProtoSerializationUtil.serialize(value);
18
+ return packDateIntoAny(localDateProto);
19
+ }
20
+ else if (value instanceof datetime_1.ZonedDateTime) {
21
+ var localDateProto = serialization_1.ProtoSerializationUtil.serialize(value);
22
+ return packTimestampIntoAny(localDateProto);
23
+ }
24
+ else if (value instanceof uuid_1.UUID) {
25
+ // const uuid: UUIDProto = ProtoSerializationUtil.serialize(value);
26
+ return packIDIntoAny(value.toUUIDProto());
27
+ }
28
+ else {
29
+ throw new Error("Unrecognized type cannot be packed: " + typeof value);
30
+ }
31
+ }
32
+ exports.pack = pack;
33
+ function unpack(value) {
34
+ var typeUrl = value.getTypeUrl();
35
+ if (typeUrl === 'type.googleapis.com/google.protobuf.StringValue') {
36
+ return unpackStringFromAny(value);
37
+ }
38
+ else if (typeUrl === 'type.googleapis.com/fintekkers.models.util.LocalDateProto') {
39
+ return unpackDateFromAny(value);
40
+ }
41
+ else if (typeUrl === 'type.googleapis.com/fintekkers.models.util.LocalTimestampProto') {
42
+ return unpackTimestampFromAny(value);
43
+ }
44
+ else if (typeUrl === 'type.googleapis.com/fintekkers.models.util.UUIDProto') {
45
+ return unpackIDIntoAny(value);
46
+ }
47
+ else {
48
+ console.log(value);
49
+ throw new Error("Unrecognized Any type cannot be unpacked: " + typeUrl);
50
+ }
51
+ }
52
+ exports.unpack = unpack;
53
+ function packIDIntoAny(uuid) {
54
+ var anyMessage = new any_pb_1.Any();
55
+ anyMessage.pack(uuid.serializeBinary(), 'fintekkers.models.util.UUIDProto');
56
+ return anyMessage;
57
+ }
58
+ function unpackIDIntoAny(anyMessage) {
59
+ var typeUrl = anyMessage.getTypeUrl();
60
+ if (typeUrl !== 'type.googleapis.com/fintekkers.models.util.UUIDProto') {
61
+ throw new Error('Unexpected type URL for a date: ' + typeUrl);
62
+ }
63
+ var uuidProto = uuid_pb_1.UUIDProto.deserializeBinary(anyMessage.getValue_asU8());
64
+ return serialization_1.ProtoSerializationUtil.deserialize(uuidProto);
65
+ }
66
+ function packTimestampIntoAny(inputDate) {
67
+ var anyMessage = new any_pb_1.Any();
68
+ anyMessage.pack(inputDate.serializeBinary(), 'fintekkers.models.util.LocalTimestampProto');
69
+ return anyMessage;
70
+ }
71
+ function unpackTimestampFromAny(anyMessage) {
72
+ var typeUrl = anyMessage.getTypeUrl();
73
+ if (typeUrl !== 'type.googleapis.com/fintekkers.models.util.LocalTimestampProto') {
74
+ throw new Error('Unexpected type URL for a timestamp: ' + typeUrl);
75
+ }
76
+ var dateProto = local_timestamp_pb_1.LocalTimestampProto.deserializeBinary(anyMessage.getValue_asU8());
77
+ return serialization_1.ProtoSerializationUtil.deserialize(dateProto);
78
+ }
79
+ function packDateIntoAny(inputDate) {
80
+ var anyMessage = new any_pb_1.Any();
81
+ anyMessage.pack(inputDate.serializeBinary(), 'fintekkers.models.util.LocalDateProto');
82
+ return anyMessage;
83
+ }
84
+ function unpackDateFromAny(anyMessage) {
85
+ var typeUrl = anyMessage.getTypeUrl();
86
+ if (typeUrl !== 'type.googleapis.com/fintekkers.models.util.LocalDateProto') {
87
+ throw new Error('Unexpected type URL for a date: ' + typeUrl);
88
+ }
89
+ var dateProto = local_date_pb_1.LocalDateProto.deserializeBinary(anyMessage.getValue_asU8());
90
+ return serialization_1.ProtoSerializationUtil.deserialize(dateProto);
91
+ }
92
+ function packStringIntoAny(inputString) {
93
+ var stringValue = new wrappers_pb_1.StringValue();
94
+ stringValue.setValue(inputString);
95
+ var anyMessage = new any_pb_1.Any();
96
+ anyMessage.pack(stringValue.serializeBinary(), 'google.protobuf.StringValue');
97
+ return anyMessage;
98
+ }
99
+ function unpackStringFromAny(anyMessage) {
100
+ var typeUrl = anyMessage.getTypeUrl();
101
+ if (typeUrl !== 'type.googleapis.com/google.protobuf.StringValue') {
102
+ throw new Error('Unexpected type URL: ' + typeUrl);
103
+ }
104
+ var packedData = wrappers_pb_1.StringValue.deserializeBinary(anyMessage.getValue_asU8());
105
+ var stringValue = packedData.getValue();
106
+ return stringValue;
107
+ }
108
+ //# sourceMappingURL=serialization.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialization.util.js","sourceRoot":"","sources":["serialization.util.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAC7D,2EAA0E;AAC1E,iDAAyD;AACzD,+EAA+E;AAC/E,uCAA2C;AAC3C,yFAAyF;AACzF,+BAA8B;AAC9B,mEAAoE;AAEpE,SAAS,IAAI,CAAC,KAAU;IACtB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;KACjC;SAAM,IAAI,KAAK,YAAY,IAAI,EAAE;QAChC,IAAM,cAAc,GAAmB,sCAAsB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC/E,OA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AAkC,GAAG,OAAO,CAAC,CAAC;KAC/D;IAED,IAAM,SAAS,GAAmB,8BAAc,CAAC,iBAAiB,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,CAAC;IAC/F,OAAO,sCAAsB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,iBAAiB,CAAC,WAAmB;IAC5C,IAAM,WAAW,GAAG,IAAI,yBAAW,EAAE,CAAC;IACtC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAElC,IAAM,UAAU,GAAG,IAAI,YAAG,EAAE,CAAC;IAC7B,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,EAAE,6BAA6B,CAAC,CAAC;IAE9E,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,mBAAmB,CAAC,UAAe;IAC1C,IAAM,OAAO,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC;IAExC,IAAI,OAAO,KAAK,iDAAiD,EAAE;QACjE,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,OAAO,CAAC,CAAC;KACpD;IAED,IAAM,UAAU,GAAG,yBAAW,CAAC,iBAAiB,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,CAAC;IAC7E,IAAM,WAAW,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;IAE1C,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var serialization_util_1 = require("./serialization.util");
4
+ var datetime_1 = require("./datetime");
5
+ var assert = require("assert");
6
+ test('test packing/unpacking string', function () {
7
+ testString();
8
+ });
9
+ test('test packing/unpacking date', function () {
10
+ testDate();
11
+ });
12
+ test('test packing/unpacking timestamp', function () {
13
+ testTimestamp();
14
+ });
15
+ function testTimestamp() {
16
+ var now = datetime_1.ZonedDateTime.now();
17
+ var packedNow = (0, serialization_util_1.pack)(now);
18
+ var unpackedNow = (0, serialization_util_1.unpack)(packedNow);
19
+ assert.equal(now.getTimezone(), unpackedNow.getTimezone(), "Timezone doesn't match");
20
+ assert.equal(now.getSeconds(), unpackedNow.getSeconds(), "Seconds do not match");
21
+ assert.equal(now.getNanoSeconds(), unpackedNow.getNanoSeconds(), "Nanoseconds do not match");
22
+ }
23
+ function testDate() {
24
+ var testDate = new Date();
25
+ testDate.setHours(0, 0, 0, 0);
26
+ var packedDate = (0, serialization_util_1.pack)(testDate);
27
+ var unpackedDate = (0, serialization_util_1.unpack)(packedDate);
28
+ assert.equal(unpackedDate.getTime(), testDate.getTime(), "Date packing/unpacking failed");
29
+ }
30
+ function testString() {
31
+ var testString = "Hello";
32
+ var packedString = (0, serialization_util_1.pack)(testString);
33
+ var unpackedString = (0, serialization_util_1.unpack)(packedString);
34
+ assert.equal(unpackedString, testString, "String packing/unpacking failed");
35
+ }
36
+ //# sourceMappingURL=serialization.util.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialization.util.test.js","sourceRoot":"","sources":["serialization.util.test.ts"],"names":[],"mappings":";;AAEA,2DAAoD;AACpD,uCAA2C;AAE3C,+BAAkC;AAElC,IAAI,CAAC,+BAA+B,EAAE;IACpC,UAAU,EAAE,CAAC;AACf,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,6BAA6B,EAAE;IAClC,QAAQ,EAAE,CAAC;AACb,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,kCAAkC,EAAE;IACvC,aAAa,EAAE,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,SAAS,aAAa;IACpB,IAAM,GAAG,GAAG,wBAAa,CAAC,GAAG,EAAE,CAAC;IAEhC,IAAM,SAAS,GAAQ,IAAA,yBAAI,EAAC,GAAG,CAAC,CAAC;IACjC,IAAM,WAAW,GAAkB,IAAA,2BAAM,EAAC,SAAS,CAAC,CAAC;IAErD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,WAAW,EAAE,EAAE,wBAAwB,CAAC,CAAC;IACrF,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,WAAW,CAAC,UAAU,EAAE,EAAE,sBAAsB,CAAC,CAAC;IACjF,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,WAAW,CAAC,cAAc,EAAE,EAAE,0BAA0B,CAAC,CAAC;AAC/F,CAAC;AAED,SAAS,QAAQ;IACf,IAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAA;IAC3B,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAE9B,IAAM,UAAU,GAAQ,IAAA,yBAAI,EAAC,QAAQ,CAAC,CAAC;IACvC,IAAM,YAAY,GAAS,IAAA,2BAAM,EAAC,UAAU,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,OAAO,EAAE,EAAE,+BAA+B,CAAC,CAAC;AAC5F,CAAC;AAED,SAAS,UAAU;IACjB,IAAM,UAAU,GAAG,OAAO,CAAC;IAE3B,IAAM,YAAY,GAAQ,IAAA,yBAAI,EAAC,UAAU,CAAC,CAAC;IAC3C,IAAM,cAAc,GAAW,IAAA,2BAAM,EAAC,YAAY,CAAC,CAAC;IACpD,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,UAAU,EAAE,iCAAiC,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { Any } from 'google-protobuf/google/protobuf/any_pb';
2
+
3
+ import { pack, unpack } from './serialization.util';
4
+ import { ZonedDateTime } from './datetime';
5
+
6
+ import assert = require('assert');
7
+
8
+ test('test packing/unpacking string', () => {
9
+ testString();
10
+ });
11
+
12
+ test('test packing/unpacking date', () => {
13
+ testDate();
14
+ });
15
+
16
+ test('test packing/unpacking timestamp', () => {
17
+ testTimestamp();
18
+ });
19
+
20
+ function testTimestamp() {
21
+ const now = ZonedDateTime.now();
22
+
23
+ const packedNow: Any = pack(now);
24
+ const unpackedNow: ZonedDateTime = unpack(packedNow);
25
+
26
+ assert.equal(now.getTimezone(), unpackedNow.getTimezone(), "Timezone doesn't match");
27
+ assert.equal(now.getSeconds(), unpackedNow.getSeconds(), "Seconds do not match");
28
+ assert.equal(now.getNanoSeconds(), unpackedNow.getNanoSeconds(), "Nanoseconds do not match");
29
+ }
30
+
31
+ function testDate() {
32
+ const testDate = new Date()
33
+ testDate.setHours(0, 0, 0, 0);
34
+
35
+ const packedDate: Any = pack(testDate);
36
+ const unpackedDate: Date = unpack(packedDate);
37
+ assert.equal(unpackedDate.getTime(), testDate.getTime(), "Date packing/unpacking failed");
38
+ }
39
+
40
+ function testString() {
41
+ const testString = "Hello";
42
+
43
+ const packedString: Any = pack(testString);
44
+ const unpackedString: String = unpack(packedString);
45
+ assert.equal(unpackedString, testString, "String packing/unpacking failed");
46
+ }
47
+
@@ -0,0 +1,121 @@
1
+ import { Any } from 'google-protobuf/google/protobuf/any_pb';
2
+ import { StringValue } from 'google-protobuf/google/protobuf/wrappers_pb';
3
+ import { ProtoSerializationUtil } from './serialization';
4
+ import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
5
+ import { ZonedDateTime } from './datetime';
6
+ import { LocalTimestampProto } from '../../../fintekkers/models/util/local_timestamp_pb';
7
+ import { UUID } from './uuid';
8
+ import { UUIDProto } from '../../../fintekkers/models/util/uuid_pb';
9
+
10
+ function pack(value: any) {
11
+ if (typeof value === 'string') {
12
+ return packStringIntoAny(value);
13
+ } else if (value instanceof Date) {
14
+ const localDateProto: LocalDateProto = ProtoSerializationUtil.serialize(value);
15
+ return packDateIntoAny(localDateProto);
16
+ } else if (value instanceof ZonedDateTime) {
17
+ const localDateProto: LocalTimestampProto = ProtoSerializationUtil.serialize(value);
18
+ return packTimestampIntoAny(localDateProto);
19
+ } else if (value instanceof UUID) {
20
+ // const uuid: UUIDProto = ProtoSerializationUtil.serialize(value);
21
+ return packIDIntoAny(value.toUUIDProto());
22
+ } else {
23
+ throw new Error("Unrecognized type cannot be packed: " + typeof value);
24
+ }
25
+ }
26
+
27
+ function unpack(value: Any): any {
28
+ const typeUrl = value.getTypeUrl();
29
+ if (typeUrl === 'type.googleapis.com/google.protobuf.StringValue') {
30
+ return unpackStringFromAny(value);
31
+ } else if (typeUrl === 'type.googleapis.com/fintekkers.models.util.LocalDateProto') {
32
+ return unpackDateFromAny(value);
33
+ } else if (typeUrl === 'type.googleapis.com/fintekkers.models.util.LocalTimestampProto') {
34
+ return unpackTimestampFromAny(value);
35
+ } else if (typeUrl === 'type.googleapis.com/fintekkers.models.util.UUIDProto') {
36
+ return unpackIDIntoAny(value);
37
+ } else {
38
+ console.log(value);
39
+ throw new Error("Unrecognized Any type cannot be unpacked: " + typeUrl);
40
+ }
41
+ }
42
+
43
+
44
+ function packIDIntoAny(uuid: UUIDProto): Any {
45
+ const anyMessage = new Any();
46
+
47
+ anyMessage.pack(uuid.serializeBinary(), 'fintekkers.models.util.UUIDProto');
48
+ return anyMessage;
49
+ }
50
+
51
+ function unpackIDIntoAny(anyMessage: Any): UUIDProto {
52
+ const typeUrl = anyMessage.getTypeUrl();
53
+
54
+ if (typeUrl !== 'type.googleapis.com/fintekkers.models.util.UUIDProto') {
55
+ throw new Error('Unexpected type URL for a date: ' + typeUrl);
56
+ }
57
+
58
+ const uuidProto: UUIDProto = UUIDProto.deserializeBinary(anyMessage.getValue_asU8());
59
+ return ProtoSerializationUtil.deserialize(uuidProto);
60
+ }
61
+
62
+ function packTimestampIntoAny(inputDate: LocalTimestampProto): Any {
63
+ const anyMessage = new Any();
64
+
65
+ anyMessage.pack(inputDate.serializeBinary(), 'fintekkers.models.util.LocalTimestampProto');
66
+ return anyMessage;
67
+ }
68
+
69
+ function unpackTimestampFromAny(anyMessage: Any): LocalTimestampProto {
70
+ const typeUrl = anyMessage.getTypeUrl();
71
+
72
+ if (typeUrl !== 'type.googleapis.com/fintekkers.models.util.LocalTimestampProto') {
73
+ throw new Error('Unexpected type URL for a timestamp: ' + typeUrl);
74
+ }
75
+
76
+ const dateProto: LocalTimestampProto = LocalTimestampProto.deserializeBinary(anyMessage.getValue_asU8());
77
+ return ProtoSerializationUtil.deserialize(dateProto);
78
+ }
79
+
80
+ function packDateIntoAny(inputDate: LocalDateProto): Any {
81
+ const anyMessage = new Any();
82
+
83
+ anyMessage.pack(inputDate.serializeBinary(), 'fintekkers.models.util.LocalDateProto');
84
+ return anyMessage;
85
+ }
86
+
87
+ function unpackDateFromAny(anyMessage: Any): LocalDateProto {
88
+ const typeUrl = anyMessage.getTypeUrl();
89
+
90
+ if (typeUrl !== 'type.googleapis.com/fintekkers.models.util.LocalDateProto') {
91
+ throw new Error('Unexpected type URL for a date: ' + typeUrl);
92
+ }
93
+
94
+ const dateProto: LocalDateProto = LocalDateProto.deserializeBinary(anyMessage.getValue_asU8());
95
+ return ProtoSerializationUtil.deserialize(dateProto);
96
+ }
97
+
98
+ function packStringIntoAny(inputString: string): Any {
99
+ const stringValue = new StringValue();
100
+ stringValue.setValue(inputString);
101
+
102
+ const anyMessage = new Any();
103
+ anyMessage.pack(stringValue.serializeBinary(), 'google.protobuf.StringValue');
104
+
105
+ return anyMessage;
106
+ }
107
+
108
+ function unpackStringFromAny(anyMessage: Any): string | null {
109
+ const typeUrl = anyMessage.getTypeUrl();
110
+
111
+ if (typeUrl !== 'type.googleapis.com/google.protobuf.StringValue') {
112
+ throw new Error('Unexpected type URL: ' + typeUrl);
113
+ }
114
+
115
+ const packedData = StringValue.deserializeBinary(anyMessage.getValue_asU8());
116
+ const stringValue = packedData.getValue();
117
+
118
+ return stringValue;
119
+ }
120
+
121
+ export { pack, unpack };
@@ -37,19 +37,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.PortfolioService = void 0;
40
- var grpc = require("@grpc/grpc-js");
41
40
  var util_1 = require("util");
42
- var util_2 = require("../../models/utils/util");
43
41
  // Model Utils
44
- var position_filter_pb_1 = require("../../../fintekkers/models/position/position_filter_pb");
45
42
  // Requests & Services
46
43
  var portfolio_service_grpc_pb_1 = require("../../../fintekkers/services/portfolio-service/portfolio_service_grpc_pb");
47
44
  var query_portfolio_request_pb_1 = require("../../../fintekkers/requests/portfolio/query_portfolio_request_pb");
48
45
  var create_portfolio_request_pb_1 = require("../../../fintekkers/requests/portfolio/create_portfolio_request_pb");
46
+ var requestcontext_1 = require("../../models/utils/requestcontext");
47
+ var portfolio_1 = require("../../models/portfolio/portfolio");
49
48
  var PortfolioService = /** @class */ (function () {
50
49
  function PortfolioService() {
51
- this.client = new portfolio_service_grpc_pb_1.PortfolioClient('api.fintekkers.org:8082', grpc.credentials.createSsl());
52
- // this.client = new PortfolioClient('localhost:8082', grpc.credentials.createInsecure());
50
+ this.client = new portfolio_service_grpc_pb_1.PortfolioClient(requestcontext_1.default.apiURL, requestcontext_1.default.apiCredentials);
53
51
  }
54
52
  PortfolioService.prototype.validateCreatePortfolio = function (portfolio) {
55
53
  return __awaiter(this, void 0, void 0, function () {
@@ -89,7 +87,7 @@ var PortfolioService = /** @class */ (function () {
89
87
  });
90
88
  });
91
89
  };
92
- PortfolioService.prototype.searchPortfolio = function (asOf, fieldProto, fieldValue) {
90
+ PortfolioService.prototype.searchPortfolio = function (asOf, positionFilter) {
93
91
  return __awaiter(this, void 0, void 0, function () {
94
92
  function processStreamSynchronously() {
95
93
  return __awaiter(this, void 0, void 0, function () {
@@ -99,7 +97,7 @@ var PortfolioService = /** @class */ (function () {
99
97
  return [2 /*return*/, new Promise(function (resolve, reject) {
100
98
  stream2.on('data', function (response) {
101
99
  response.getPortfolioResponseList().forEach(function (portfolio) {
102
- listPortfolios.push(portfolio);
100
+ listPortfolios.push(new portfolio_1.default(portfolio));
103
101
  });
104
102
  });
105
103
  stream2.on('end', function () {
@@ -113,7 +111,7 @@ var PortfolioService = /** @class */ (function () {
113
111
  });
114
112
  });
115
113
  }
116
- var searchRequest, positionFilter, fieldMapEntry, tmpClient, listPortfolios;
114
+ var searchRequest, tmpClient, listPortfolios;
117
115
  return __generator(this, function (_a) {
118
116
  switch (_a.label) {
119
117
  case 0:
@@ -121,14 +119,7 @@ var PortfolioService = /** @class */ (function () {
121
119
  searchRequest.setObjectClass('PortfolioRequest');
122
120
  searchRequest.setVersion('0.0.1');
123
121
  searchRequest.setAsOf(asOf);
124
- positionFilter = new position_filter_pb_1.PositionFilterProto();
125
- positionFilter.setObjectClass('PositionFilter');
126
- positionFilter.setVersion('0.0.1');
127
- if (fieldProto && fieldValue) {
128
- fieldMapEntry = (0, util_2.createFieldMapEntry)(fieldProto, fieldValue);
129
- positionFilter.setFiltersList([fieldMapEntry]);
130
- }
131
- searchRequest.setSearchPortfolioInput(positionFilter);
122
+ searchRequest.setSearchPortfolioInput(positionFilter.toProto());
132
123
  tmpClient = this.client;
133
124
  listPortfolios = [];
134
125
  return [4 /*yield*/, processStreamSynchronously()];
@@ -137,6 +128,7 @@ var PortfolioService = /** @class */ (function () {
137
128
  });
138
129
  });
139
130
  };
131
+ PortfolioService.url = requestcontext_1.default.apiURL;
140
132
  return PortfolioService;
141
133
  }());
142
134
  exports.PortfolioService = PortfolioService;
@@ -1 +1 @@
1
- {"version":3,"file":"PortfolioService.js","sourceRoot":"","sources":["PortfolioService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAsC;AACtC,6BAAiC;AAIjC,gDAA8D;AAI9D,cAAc;AACd,6FAA6F;AAG7F,sBAAsB;AACtB,sHAA2G;AAC3G,gHAA+G;AAE/G,kHAAiH;AAGjH;IAGE;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,2CAAe,CAAC,yBAAyB,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC;QAC3F,0FAA0F;IAC5F,CAAC;IAEK,kDAAuB,GAA7B,UAA8B,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M,0BAA0B,EAAE,EAAA;4BAAzC,sBAAO,SAAkC,EAAC;;;;KAC3C;IA/DM,oBAAG,GAAW,wBAAS,CAAC,MAAM,CAAC;IAgExC,uBAAC;CAAA,AAnED,IAmEC;AAEQ,4CAAgB"}
@@ -1,15 +1,11 @@
1
- import * as grpc from '@grpc/grpc-js';
2
1
  import { promisify } from 'util';
3
2
 
4
3
  // Models
5
4
  import { PortfolioProto } from '../../../fintekkers/models/portfolio/portfolio_pb';
6
- import { createFieldMapEntry } from '../../models/utils/util';
7
5
  import { LocalTimestampProto } from '../../../fintekkers/models/util/local_timestamp_pb';
8
6
  import { SummaryProto } from '../../../fintekkers/requests/util/errors/summary_pb';
9
7
 
10
8
  // Model Utils
11
- import { PositionFilterProto } from '../../../fintekkers/models/position/position_filter_pb';
12
- import { FieldProto } from '../../../fintekkers/models/position/field_pb';
13
9
 
14
10
  // Requests & Services
15
11
  import { PortfolioClient } from '../../../fintekkers/services/portfolio-service/portfolio_service_grpc_pb';
@@ -17,13 +13,17 @@ import { QueryPortfolioRequestProto } from '../../../fintekkers/requests/portfol
17
13
  import { QueryPortfolioResponseProto } from '../../../fintekkers/requests/portfolio/query_portfolio_response_pb';
18
14
  import { CreatePortfolioRequestProto } from '../../../fintekkers/requests/portfolio/create_portfolio_request_pb';
19
15
  import { CreatePortfolioResponseProto } from '../../../fintekkers/requests/portfolio/create_portfolio_response_pb';
16
+ import EnvConfig from '../../models/utils/requestcontext';
17
+ import { PositionFilter } from '../../models/position/positionfilter';
18
+ import Portfolio from '../../models/portfolio/portfolio';
20
19
 
21
20
  class PortfolioService {
22
21
  private client: PortfolioClient;
23
22
 
23
+ static url: string = EnvConfig.apiURL;
24
+
24
25
  constructor() {
25
- this.client = new PortfolioClient('api.fintekkers.org:8082', grpc.credentials.createSsl());
26
- // this.client = new PortfolioClient('localhost:8082', grpc.credentials.createInsecure());
26
+ this.client = new PortfolioClient(EnvConfig.apiURL, EnvConfig.apiCredentials);
27
27
  }
28
28
 
29
29
  async validateCreatePortfolio(portfolio: PortfolioProto): Promise<SummaryProto> {
@@ -48,36 +48,26 @@ class PortfolioService {
48
48
  return response;
49
49
  }
50
50
 
51
- async searchPortfolio(asOf: LocalTimestampProto,
52
- fieldProto?: FieldProto, fieldValue?: string): Promise<PortfolioProto[]> {
51
+ async searchPortfolio(asOf: LocalTimestampProto,
52
+ positionFilter: PositionFilter): Promise<Portfolio[]> {
53
53
  const searchRequest = new QueryPortfolioRequestProto();
54
54
  searchRequest.setObjectClass('PortfolioRequest');
55
55
  searchRequest.setVersion('0.0.1');
56
56
  searchRequest.setAsOf(asOf);
57
57
 
58
- // Need to improve validation logic, uncommenting this code will cause an error of 2:UNKNOWN
59
- const positionFilter = new PositionFilterProto();
60
- positionFilter.setObjectClass('PositionFilter');
61
- positionFilter.setVersion('0.0.1');
62
-
63
- if (fieldProto && fieldValue) {
64
- const fieldMapEntry = createFieldMapEntry(fieldProto, fieldValue);
65
- positionFilter.setFiltersList([fieldMapEntry]);
66
- }
67
-
68
- searchRequest.setSearchPortfolioInput(positionFilter);
58
+ searchRequest.setSearchPortfolioInput(positionFilter.toProto());
69
59
 
70
60
  const tmpClient = this.client;
71
61
 
72
- const listPortfolios: PortfolioProto[] = [];
62
+ const listPortfolios: Portfolio[] = [];
73
63
 
74
- async function processStreamSynchronously(): Promise<PortfolioProto[]> {
64
+ async function processStreamSynchronously(): Promise<Portfolio[]> {
75
65
  const stream2 = tmpClient.search(searchRequest);
76
66
 
77
- return new Promise<PortfolioProto[]>((resolve, reject) => {
78
- stream2.on('data', (response:QueryPortfolioResponseProto) => {
67
+ return new Promise<Portfolio[]>((resolve, reject) => {
68
+ stream2.on('data', (response: QueryPortfolioResponseProto) => {
79
69
  response.getPortfolioResponseList().forEach((portfolio) => {
80
- listPortfolios.push(portfolio);
70
+ listPortfolios.push(new Portfolio(portfolio));
81
71
  });
82
72
  });
83
73