@fintekkers/ledger-models 0.1.61 → 0.1.62
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/node/fintekkers/requests/transaction/query_transaction_request_pb.d.ts +3 -0
- package/node/fintekkers/requests/transaction/query_transaction_request_pb.js +31 -1
- package/node/fintekkers/requests/transaction/query_transaction_response_pb.d.ts +7 -0
- package/node/fintekkers/requests/transaction/query_transaction_response_pb.js +54 -1
- package/node/wrappers/models/position/position.js +14 -9
- package/node/wrappers/models/position/position.js.map +1 -1
- package/node/wrappers/models/position/position.test.js +43 -0
- package/node/wrappers/models/position/position.test.js.map +1 -0
- package/node/wrappers/models/position/position.test.ts +70 -0
- package/node/wrappers/models/position/position.ts +17 -10
- package/node/wrappers/models/transaction/transaction.js +2 -2
- package/node/wrappers/models/transaction/transaction.js.map +1 -1
- package/node/wrappers/models/transaction/transaction.test.js.map +1 -1
- package/node/wrappers/models/transaction/transaction.test.ts +0 -1
- package/node/wrappers/models/transaction/transaction.ts +2 -2
- package/node/wrappers/models/transaction/transaction_type.js +0 -1
- package/node/wrappers/models/transaction/transaction_type.js.map +1 -1
- package/node/wrappers/models/transaction/transaction_type.ts +1 -1
- package/node/wrappers/models/utils/requestcontext.js +55 -0
- package/node/wrappers/models/utils/requestcontext.js.map +1 -0
- package/node/wrappers/models/utils/requestcontext.ts +44 -0
- package/node/wrappers/models/utils/requestcontext_d.js +1 -0
- package/node/wrappers/models/utils/requestcontext_d.js.map +1 -0
- package/node/wrappers/models/utils/requestcontext_d.ts +7 -0
- package/node/wrappers/models/utils/serialization.js +6 -4
- package/node/wrappers/models/utils/serialization.js.map +1 -1
- package/node/wrappers/models/utils/serialization.test.js +8 -9
- package/node/wrappers/models/utils/serialization.test.js.map +1 -1
- package/node/wrappers/models/utils/serialization.test.ts +8 -10
- package/node/wrappers/models/utils/serialization.ts +8 -8
- package/node/wrappers/models/utils/serialization.util.js +76 -0
- package/node/wrappers/models/utils/serialization.util.js.map +1 -0
- package/node/wrappers/models/utils/serialization.util.test.js +24 -0
- package/node/wrappers/models/utils/serialization.util.test.js.map +1 -0
- package/node/wrappers/models/utils/serialization.util.test.ts +29 -0
- package/node/wrappers/models/utils/serialization.util.ts +85 -0
- package/node/wrappers/services/portfolio-service/PortfolioService.js +5 -5
- package/node/wrappers/services/portfolio-service/PortfolioService.js.map +1 -1
- package/node/wrappers/services/portfolio-service/PortfolioService.ts +5 -3
- package/node/wrappers/services/portfolio-service/portfolio.test.js +2 -2
- package/node/wrappers/services/portfolio-service/portfolio.test.js.map +1 -1
- package/node/wrappers/services/portfolio-service/portfolio.test.ts +2 -2
- package/node/wrappers/services/position-service/PositionService.js +4 -3
- package/node/wrappers/services/position-service/PositionService.js.map +1 -1
- package/node/wrappers/services/position-service/PositionService.ts +4 -19
- package/node/wrappers/services/position-service/position.test.js +17 -8
- package/node/wrappers/services/position-service/position.test.js.map +1 -1
- package/node/wrappers/services/position-service/position.test.ts +10 -7
- package/node/wrappers/services/security-service/SecurityService.js +4 -5
- package/node/wrappers/services/security-service/SecurityService.js.map +1 -1
- package/node/wrappers/services/security-service/SecurityService.ts +3 -3
- package/node/wrappers/services/security-service/security.test.js +15 -7
- package/node/wrappers/services/security-service/security.test.js.map +1 -1
- package/node/wrappers/services/security-service/security.test.ts +6 -6
- package/node/wrappers/services/transaction-service/TransactionService.js +40 -46
- package/node/wrappers/services/transaction-service/TransactionService.js.map +1 -1
- package/node/wrappers/services/transaction-service/TransactionService.ts +13 -10
- package/node/wrappers/services/transaction-service/transaction.test.js +28 -11
- package/node/wrappers/services/transaction-service/transaction.test.js.map +1 -1
- package/node/wrappers/services/transaction-service/transaction.test.ts +23 -13
- package/package.json +2 -1
- package/web/fintekkers/requests/transaction/query_transaction_request_pb.d.ts +4 -0
- package/web/fintekkers/requests/transaction/query_transaction_request_pb.js +31 -1
- package/web/fintekkers/requests/transaction/query_transaction_response_pb.d.ts +7 -0
- package/web/fintekkers/requests/transaction/query_transaction_response_pb.js +54 -1
- package/node/wrappers/models/utils/util.js +0 -28
- package/node/wrappers/models/utils/util.js.map +0 -1
- package/node/wrappers/models/utils/util.ts +0 -28
|
@@ -3,21 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var serialization_1 = require("./serialization");
|
|
4
4
|
var uuid_1 = require("./uuid");
|
|
5
5
|
var assert = require("assert");
|
|
6
|
-
test('test
|
|
6
|
+
test('test serialization of key types', function () {
|
|
7
7
|
testSerialization();
|
|
8
8
|
});
|
|
9
9
|
function testSerialization() {
|
|
10
10
|
checkUUID();
|
|
11
|
-
//
|
|
12
|
-
var serializedDate = serialization_1.ProtoSerializationUtil.serialize(
|
|
13
|
-
assert(serializedDate.toString().indexOf('2023') > -1);
|
|
11
|
+
var march2023 = new Date(2023, 2, 5); //Month is zero-indexed, so 2 == March.
|
|
12
|
+
var serializedDate = serialization_1.ProtoSerializationUtil.serialize(march2023);
|
|
13
|
+
assert(serializedDate.toString().indexOf('2023,3,5') > -1);
|
|
14
14
|
var deserializedDate = serialization_1.ProtoSerializationUtil.deserialize(serializedDate);
|
|
15
|
-
assert(deserializedDate.toString().indexOf('2023') > -1);
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
assert(serializedTimestamp.toString().indexOf('2023') > -1);
|
|
15
|
+
assert(deserializedDate.toString().indexOf('Mar 05 2023') > -1);
|
|
16
|
+
var serializedTimestamp = serialization_1.ProtoSerializationUtil.serialize(march2023);
|
|
17
|
+
assert(serializedTimestamp.toString().indexOf('2023,3,5') > -1);
|
|
19
18
|
var deserializedTimestamp = serialization_1.ProtoSerializationUtil.deserialize(serializedTimestamp);
|
|
20
|
-
assert(deserializedTimestamp.toString().indexOf('2023') > -1);
|
|
19
|
+
assert(deserializedTimestamp.toString().indexOf('Mar 05 2023') > -1);
|
|
21
20
|
}
|
|
22
21
|
function checkUUID() {
|
|
23
22
|
var uuid = uuid_1.UUID.random();
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"serialization.test.js","sourceRoot":"","sources":["serialization.test.ts"],"names":[],"mappings":";;AAEA,iDAAyD;AACzD,+BAA8B;AAE9B,+BAAkC;AAClC,IAAI,CAAC,iCAAiC,EAAE;IACpC,iBAAiB,EAAE,CAAC;AACtB,CAAC,CAAC,CAAC;AAEL,SAAS,iBAAiB;IACtB,SAAS,EAAE,CAAC;IAEZ,IAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,uCAAuC;IAC/E,IAAM,cAAc,GAAQ,sCAAsB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACxE,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAE3D,IAAM,gBAAgB,GAAQ,sCAAsB,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
|
|
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
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
23
|
-
|
|
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() {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { DecimalValueProto } from "../../../fintekkers/models/util/decimal_value_pb";
|
|
2
2
|
import { LocalDateProto } from "../../../fintekkers/models/util/local_date_pb";
|
|
3
|
-
import { LocalTimestampProto } from "../../../fintekkers/models/util/local_timestamp_pb";
|
|
4
3
|
import { UUIDProto } from "../../../fintekkers/models/util/uuid_pb";
|
|
5
4
|
import { UUID } from "./uuid";
|
|
6
|
-
|
|
7
5
|
|
|
8
6
|
interface EnumValueDescriptor {
|
|
9
7
|
name: string;
|
|
@@ -11,15 +9,15 @@ import { UUID } from "./uuid";
|
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
export class ProtoSerializationUtil {
|
|
14
|
-
static serialize(obj: any) {
|
|
12
|
+
static serialize(obj: any): any {
|
|
15
13
|
if (obj instanceof UUID) {
|
|
16
14
|
return obj.toUUIDProto();
|
|
17
15
|
}
|
|
18
16
|
if (obj instanceof Date) {
|
|
19
17
|
return new LocalDateProto()
|
|
20
|
-
.setYear(obj.
|
|
21
|
-
.setMonth(obj.
|
|
22
|
-
.setDay(obj.
|
|
18
|
+
.setYear(obj.getFullYear())
|
|
19
|
+
.setMonth(obj.getMonth() + 1)
|
|
20
|
+
.setDay(obj.getDate());
|
|
23
21
|
}
|
|
24
22
|
if (typeof obj === "number") {
|
|
25
23
|
return new DecimalValueProto().setArbitraryPrecisionValue(obj.toString());
|
|
@@ -28,12 +26,14 @@ import { UUID } from "./uuid";
|
|
|
28
26
|
throw new Error(`Could not serialize object of type ${typeof obj}. Value: ${obj}`);
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
static deserialize(obj: any) {
|
|
29
|
+
static deserialize(obj: any): any {
|
|
32
30
|
if (obj instanceof UUIDProto) {
|
|
33
31
|
return UUID.fromU8Array(obj.getRawUuid_asU8());
|
|
34
32
|
}
|
|
35
33
|
if (obj instanceof LocalDateProto) {
|
|
36
|
-
|
|
34
|
+
const date = new Date(obj.getYear(), obj.getMonth() - 1, obj.getDay());
|
|
35
|
+
date.setHours(0,0,0,0);
|
|
36
|
+
return date;
|
|
37
37
|
}
|
|
38
38
|
if (obj.enum_name && obj.enum_name === "TRANSACTION_TYPE") {
|
|
39
39
|
return null;// new TransactionType(obj.enum_value);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFieldMapEntry = exports.unpack = exports.pack = void 0;
|
|
4
|
+
var position_util_pb_1 = require("../../../fintekkers/models/position/position_util_pb");
|
|
5
|
+
var any_pb_1 = require("google-protobuf/google/protobuf/any_pb");
|
|
6
|
+
var wrappers_pb_1 = require("google-protobuf/google/protobuf/wrappers_pb");
|
|
7
|
+
var serialization_1 = require("./serialization");
|
|
8
|
+
var local_date_pb_1 = require("../../../fintekkers/models/util/local_date_pb");
|
|
9
|
+
function pack(value) {
|
|
10
|
+
if (typeof value === 'string') {
|
|
11
|
+
return packStringIntoAny(value);
|
|
12
|
+
}
|
|
13
|
+
else if (value instanceof Date) {
|
|
14
|
+
var localDateProto = serialization_1.ProtoSerializationUtil.serialize(value);
|
|
15
|
+
return packDateIntoAny(localDateProto);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
throw new Error("Unrecognized type cannot be unpacked: " + typeof value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.pack = pack;
|
|
22
|
+
function unpack(value) {
|
|
23
|
+
var typeUrl = value.getTypeUrl();
|
|
24
|
+
if (typeUrl === 'type.googleapis.com/google.protobuf.StringValue') {
|
|
25
|
+
return unpackStringFromAny(value);
|
|
26
|
+
}
|
|
27
|
+
if (typeUrl === 'type.googleapis.com/fintekkers.models.util.LocalDateProto') {
|
|
28
|
+
return unpackDateFromAny(value);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new Error("Unrecognized Any type: " + typeUrl);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.unpack = unpack;
|
|
35
|
+
function packDateIntoAny(inputDate) {
|
|
36
|
+
var anyMessage = new any_pb_1.Any();
|
|
37
|
+
anyMessage.pack(inputDate.serializeBinary(), 'fintekkers.models.util.LocalDateProto');
|
|
38
|
+
return anyMessage;
|
|
39
|
+
}
|
|
40
|
+
function unpackDateFromAny(anyMessage) {
|
|
41
|
+
var typeUrl = anyMessage.getTypeUrl();
|
|
42
|
+
if (typeUrl !== 'type.googleapis.com/fintekkers.models.util.LocalDateProto') {
|
|
43
|
+
throw new Error('Unexpected type URL for a date: ' + typeUrl);
|
|
44
|
+
}
|
|
45
|
+
var dateProto = local_date_pb_1.LocalDateProto.deserializeBinary(anyMessage.getValue_asU8());
|
|
46
|
+
return serialization_1.ProtoSerializationUtil.deserialize(dateProto);
|
|
47
|
+
}
|
|
48
|
+
function packStringIntoAny(inputString) {
|
|
49
|
+
var stringValue = new wrappers_pb_1.StringValue();
|
|
50
|
+
stringValue.setValue(inputString);
|
|
51
|
+
var anyMessage = new any_pb_1.Any();
|
|
52
|
+
anyMessage.pack(stringValue.serializeBinary(), 'google.protobuf.StringValue');
|
|
53
|
+
return anyMessage;
|
|
54
|
+
}
|
|
55
|
+
function unpackStringFromAny(anyMessage) {
|
|
56
|
+
var typeUrl = anyMessage.getTypeUrl();
|
|
57
|
+
if (typeUrl !== 'type.googleapis.com/google.protobuf.StringValue') {
|
|
58
|
+
throw new Error('Unexpected type URL: ' + typeUrl);
|
|
59
|
+
}
|
|
60
|
+
var packedData = wrappers_pb_1.StringValue.deserializeBinary(anyMessage.getValue_asU8());
|
|
61
|
+
var stringValue = packedData.getValue();
|
|
62
|
+
return stringValue;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @param {*} field FieldProto.ASSET_CLASS, as an example
|
|
66
|
+
* @param {*} fieldValue The appropriate value for the FieldProto, e.g. FieldProto.ASSET_CLASS would have a string fieldValue
|
|
67
|
+
*/
|
|
68
|
+
function createFieldMapEntry(field, fieldValue) {
|
|
69
|
+
var fieldMapEntry = new position_util_pb_1.FieldMapEntry();
|
|
70
|
+
fieldMapEntry.setField(field); //FieldProto.ASSET_CLASS);
|
|
71
|
+
if (typeof fieldValue === "string")
|
|
72
|
+
fieldMapEntry.setFieldValuePacked(packStringIntoAny(fieldValue)); //"Cash"));
|
|
73
|
+
return fieldMapEntry;
|
|
74
|
+
}
|
|
75
|
+
exports.createFieldMapEntry = createFieldMapEntry;
|
|
76
|
+
//# sourceMappingURL=serialization.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization.util.js","sourceRoot":"","sources":["serialization.util.ts"],"names":[],"mappings":";;;AAAA,yFAAqF;AACrF,iEAA6D;AAC7D,2EAA0E;AAC1E,iDAAyD;AACzD,+EAA+E;AAE/E,SAAS,IAAI,CAAC,KAAS;IACrB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;KACjC;SAAM,IAAG,KAAK,YAAY,IAAI,EAAE;QAC/B,IAAM,cAAc,GAAkB,sCAAsB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC9E,OAAO,eAAe,CAAC,cAAc,CAAC,CAAC;KACxC;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,wCAAwC,GAAE,OAAO,KAAK,CAAC,CAAC;KACzE;AACH,CAAC;AAqEQ,oBAAI;AAnEb,SAAS,MAAM,CAAC,KAAS;IACvB,IAAM,OAAO,GA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,UAAU,EAAE,CAAC;IAExC,IAAI,OAAO,KAAK,iDAAiD,EAAE;QACjE,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAE,OAAO,CAAC,CAAC;KACnD;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;AAGD;;;GAGG;AACH,SAAS,mBAAmB,CAAC,KAAa,EAAE,UAAe;IACzD,IAAM,aAAa,GAAG,IAAI,gCAAa,EAAE,CAAC;IAC1C,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,0BAA0B;IAEzD,IAAG,OAAO,UAAU,KAAK,QAAQ;QAC/B,aAAa,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,WAAW;IAE/E,OAAO,aAAa,CAAC;AACvB,CAAC;AAEsB,kDAAmB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var serialization_util_1 = require("./serialization.util");
|
|
4
|
+
var assert = require("assert");
|
|
5
|
+
test('test packing/unpacking string', function () {
|
|
6
|
+
testString();
|
|
7
|
+
});
|
|
8
|
+
test('test packing/unpacking date', function () {
|
|
9
|
+
testDate();
|
|
10
|
+
});
|
|
11
|
+
function testDate() {
|
|
12
|
+
var testDate = new Date();
|
|
13
|
+
testDate.setHours(0, 0, 0, 0);
|
|
14
|
+
var packedDate = (0, serialization_util_1.pack)(testDate);
|
|
15
|
+
var unpackedDate = (0, serialization_util_1.unpack)(packedDate);
|
|
16
|
+
assert.equal(unpackedDate.getTime(), testDate.getTime(), "Date packing/unpacking failed");
|
|
17
|
+
}
|
|
18
|
+
function testString() {
|
|
19
|
+
var testString = "Hello";
|
|
20
|
+
var packedString = (0, serialization_util_1.pack)(testString);
|
|
21
|
+
var unpackedString = (0, serialization_util_1.unpack)(packedString);
|
|
22
|
+
assert.equal(unpackedString, testString, "String packing/unpacking failed");
|
|
23
|
+
}
|
|
24
|
+
//# 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":";;AACA,2DAAoD;AAEpD,+BAAkC;AAClC,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,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,29 @@
|
|
|
1
|
+
import { Any } from 'google-protobuf/google/protobuf/any_pb';
|
|
2
|
+
import { pack, unpack } from './serialization.util';
|
|
3
|
+
|
|
4
|
+
import assert = require('assert');
|
|
5
|
+
test('test packing/unpacking string', () => {
|
|
6
|
+
testString();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('test packing/unpacking date', () => {
|
|
10
|
+
testDate();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
function testDate() {
|
|
14
|
+
const testDate = new Date()
|
|
15
|
+
testDate.setHours(0, 0, 0, 0);
|
|
16
|
+
|
|
17
|
+
const packedDate: Any = pack(testDate);
|
|
18
|
+
const unpackedDate: Date = unpack(packedDate);
|
|
19
|
+
assert.equal(unpackedDate.getTime(), testDate.getTime(), "Date packing/unpacking failed");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function testString() {
|
|
23
|
+
const testString = "Hello";
|
|
24
|
+
|
|
25
|
+
const packedString: Any = pack(testString);
|
|
26
|
+
const unpackedString: String = unpack(packedString);
|
|
27
|
+
assert.equal(unpackedString, testString, "String packing/unpacking failed");
|
|
28
|
+
}
|
|
29
|
+
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { FieldMapEntry } from '../../../fintekkers/models/position/position_util_pb';
|
|
2
|
+
import { Any } from 'google-protobuf/google/protobuf/any_pb';
|
|
3
|
+
import { StringValue } from 'google-protobuf/google/protobuf/wrappers_pb';
|
|
4
|
+
import { ProtoSerializationUtil } from './serialization';
|
|
5
|
+
import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
|
|
6
|
+
|
|
7
|
+
function pack(value:any) {
|
|
8
|
+
if (typeof value === 'string') {
|
|
9
|
+
return packStringIntoAny(value);
|
|
10
|
+
} else if(value instanceof Date) {
|
|
11
|
+
const localDateProto:LocalDateProto = ProtoSerializationUtil.serialize(value);
|
|
12
|
+
return packDateIntoAny(localDateProto);
|
|
13
|
+
} else {
|
|
14
|
+
throw new Error("Unrecognized type cannot be unpacked: "+ typeof value);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function unpack(value:Any) : any {
|
|
19
|
+
const typeUrl = value.getTypeUrl();
|
|
20
|
+
if (typeUrl === 'type.googleapis.com/google.protobuf.StringValue') {
|
|
21
|
+
return unpackStringFromAny(value);
|
|
22
|
+
} if (typeUrl === 'type.googleapis.com/fintekkers.models.util.LocalDateProto') {
|
|
23
|
+
return unpackDateFromAny(value);
|
|
24
|
+
} else {
|
|
25
|
+
throw new Error("Unrecognized Any type: "+ typeUrl);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function packDateIntoAny(inputDate: LocalDateProto): Any {
|
|
30
|
+
const anyMessage = new Any();
|
|
31
|
+
|
|
32
|
+
anyMessage.pack(inputDate.serializeBinary(), 'fintekkers.models.util.LocalDateProto');
|
|
33
|
+
return anyMessage;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function unpackDateFromAny(anyMessage: Any): LocalDateProto {
|
|
37
|
+
const typeUrl = anyMessage.getTypeUrl();
|
|
38
|
+
|
|
39
|
+
if (typeUrl !== 'type.googleapis.com/fintekkers.models.util.LocalDateProto') {
|
|
40
|
+
throw new Error('Unexpected type URL for a date: '+ typeUrl);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const dateProto: LocalDateProto = LocalDateProto.deserializeBinary(anyMessage.getValue_asU8());
|
|
44
|
+
return ProtoSerializationUtil.deserialize(dateProto);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function packStringIntoAny(inputString: string): Any {
|
|
48
|
+
const stringValue = new StringValue();
|
|
49
|
+
stringValue.setValue(inputString);
|
|
50
|
+
|
|
51
|
+
const anyMessage = new Any();
|
|
52
|
+
anyMessage.pack(stringValue.serializeBinary(), 'google.protobuf.StringValue');
|
|
53
|
+
|
|
54
|
+
return anyMessage;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function unpackStringFromAny(anyMessage: Any): string | null {
|
|
58
|
+
const typeUrl = anyMessage.getTypeUrl();
|
|
59
|
+
|
|
60
|
+
if (typeUrl !== 'type.googleapis.com/google.protobuf.StringValue') {
|
|
61
|
+
throw new Error('Unexpected type URL: '+ typeUrl);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const packedData = StringValue.deserializeBinary(anyMessage.getValue_asU8());
|
|
65
|
+
const stringValue = packedData.getValue();
|
|
66
|
+
|
|
67
|
+
return stringValue;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @param {*} field FieldProto.ASSET_CLASS, as an example
|
|
73
|
+
* @param {*} fieldValue The appropriate value for the FieldProto, e.g. FieldProto.ASSET_CLASS would have a string fieldValue
|
|
74
|
+
*/
|
|
75
|
+
function createFieldMapEntry(field: number, fieldValue: any): FieldMapEntry {
|
|
76
|
+
const fieldMapEntry = new FieldMapEntry();
|
|
77
|
+
fieldMapEntry.setField(field); //FieldProto.ASSET_CLASS);
|
|
78
|
+
|
|
79
|
+
if(typeof fieldValue === "string" )
|
|
80
|
+
fieldMapEntry.setFieldValuePacked(packStringIntoAny(fieldValue)); //"Cash"));
|
|
81
|
+
|
|
82
|
+
return fieldMapEntry;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { pack, unpack, createFieldMapEntry };
|
|
@@ -37,19 +37,18 @@ 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
|
|
41
|
+
var serialization_util_1 = require("../../models/utils/serialization.util");
|
|
43
42
|
// Model Utils
|
|
44
43
|
var position_filter_pb_1 = require("../../../fintekkers/models/position/position_filter_pb");
|
|
45
44
|
// Requests & Services
|
|
46
45
|
var portfolio_service_grpc_pb_1 = require("../../../fintekkers/services/portfolio-service/portfolio_service_grpc_pb");
|
|
47
46
|
var query_portfolio_request_pb_1 = require("../../../fintekkers/requests/portfolio/query_portfolio_request_pb");
|
|
48
47
|
var create_portfolio_request_pb_1 = require("../../../fintekkers/requests/portfolio/create_portfolio_request_pb");
|
|
48
|
+
var requestcontext_1 = require("../../models/utils/requestcontext");
|
|
49
49
|
var PortfolioService = /** @class */ (function () {
|
|
50
50
|
function PortfolioService() {
|
|
51
|
-
this.client = new portfolio_service_grpc_pb_1.PortfolioClient(
|
|
52
|
-
// this.client = new PortfolioClient('localhost:8082', grpc.credentials.createInsecure());
|
|
51
|
+
this.client = new portfolio_service_grpc_pb_1.PortfolioClient(requestcontext_1.default.apiURL, requestcontext_1.default.apiCredentials);
|
|
53
52
|
}
|
|
54
53
|
PortfolioService.prototype.validateCreatePortfolio = function (portfolio) {
|
|
55
54
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -125,7 +124,7 @@ var PortfolioService = /** @class */ (function () {
|
|
|
125
124
|
positionFilter.setObjectClass('PositionFilter');
|
|
126
125
|
positionFilter.setVersion('0.0.1');
|
|
127
126
|
if (fieldProto && fieldValue) {
|
|
128
|
-
fieldMapEntry = (0,
|
|
127
|
+
fieldMapEntry = (0, serialization_util_1.createFieldMapEntry)(fieldProto, fieldValue);
|
|
129
128
|
positionFilter.setFiltersList([fieldMapEntry]);
|
|
130
129
|
}
|
|
131
130
|
searchRequest.setSearchPortfolioInput(positionFilter);
|
|
@@ -137,6 +136,7 @@ var PortfolioService = /** @class */ (function () {
|
|
|
137
136
|
});
|
|
138
137
|
});
|
|
139
138
|
};
|
|
139
|
+
PortfolioService.url = requestcontext_1.default.apiURL;
|
|
140
140
|
return PortfolioService;
|
|
141
141
|
}());
|
|
142
142
|
exports.PortfolioService = PortfolioService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PortfolioService.js","sourceRoot":"","sources":["PortfolioService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"PortfolioService.js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Aa,GAAG,IAAA,wCAAmB,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;4BAClE,cAAc,CAAC,cAAc,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;yBAChD;wBAED,aAAa,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC;wBAEhD,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC;wBAExB,cAAc,GAAqB,EAAE,CAAC;wBAuBrC,qBAAM,0BAA0B,EAAE,EAAA;4BAAzC,sBAAO,SAAkC,EAAC;;;;KAC3C;IAzEM,oBAAG,GAAU,wBAAS,CAAC,MAAM,CAAC;IA0EvC,uBAAC;CAAA,AA7ED,IA6EC;AAEQ,4CAAgB"}
|
|
@@ -3,7 +3,7 @@ import { promisify } from 'util';
|
|
|
3
3
|
|
|
4
4
|
// Models
|
|
5
5
|
import { PortfolioProto } from '../../../fintekkers/models/portfolio/portfolio_pb';
|
|
6
|
-
import { createFieldMapEntry } from '../../models/utils/util';
|
|
6
|
+
import { createFieldMapEntry } from '../../models/utils/serialization.util';
|
|
7
7
|
import { LocalTimestampProto } from '../../../fintekkers/models/util/local_timestamp_pb';
|
|
8
8
|
import { SummaryProto } from '../../../fintekkers/requests/util/errors/summary_pb';
|
|
9
9
|
|
|
@@ -17,13 +17,15 @@ import { QueryPortfolioRequestProto } from '../../../fintekkers/requests/portfol
|
|
|
17
17
|
import { QueryPortfolioResponseProto } from '../../../fintekkers/requests/portfolio/query_portfolio_response_pb';
|
|
18
18
|
import { CreatePortfolioRequestProto } from '../../../fintekkers/requests/portfolio/create_portfolio_request_pb';
|
|
19
19
|
import { CreatePortfolioResponseProto } from '../../../fintekkers/requests/portfolio/create_portfolio_response_pb';
|
|
20
|
+
import EnvConfig from '../../models/utils/requestcontext';
|
|
20
21
|
|
|
21
22
|
class PortfolioService {
|
|
22
23
|
private client: PortfolioClient;
|
|
23
24
|
|
|
25
|
+
static url:string = EnvConfig.apiURL;
|
|
26
|
+
|
|
24
27
|
constructor() {
|
|
25
|
-
this.client = new PortfolioClient(
|
|
26
|
-
// this.client = new PortfolioClient('localhost:8082', grpc.credentials.createInsecure());
|
|
28
|
+
this.client = new PortfolioClient(EnvConfig.apiURL, EnvConfig.apiCredentials);
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
async validateCreatePortfolio(portfolio: PortfolioProto): Promise<SummaryProto> {
|
|
@@ -63,14 +63,14 @@ function testPortfolio() {
|
|
|
63
63
|
portfolio.setVersion('0.0.1');
|
|
64
64
|
portfolio.setUuid(id_proto);
|
|
65
65
|
portfolio.setPortfolioName('TEST PORTFOLIO');
|
|
66
|
-
portfolio.setAsOf(now.
|
|
66
|
+
portfolio.setAsOf(now.toProto());
|
|
67
67
|
return [4 /*yield*/, portfolioService.validateCreatePortfolio(portfolio)];
|
|
68
68
|
case 1:
|
|
69
69
|
validationSummary = _a.sent();
|
|
70
70
|
return [4 /*yield*/, portfolioService.createPortfolio(portfolio)];
|
|
71
71
|
case 2:
|
|
72
72
|
createPortfolioResponse = _a.sent();
|
|
73
|
-
return [4 /*yield*/, portfolioService.searchPortfolio(now.
|
|
73
|
+
return [4 /*yield*/, portfolioService.searchPortfolio(now.toProto(), field_pb_1.FieldProto.PORTFOLIO_NAME, 'Federal Reserve SOMA Holdings')];
|
|
74
74
|
case 3:
|
|
75
75
|
searchResults = _a.sent();
|
|
76
76
|
return [2 /*return*/, true];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio.test.js","sourceRoot":"","sources":["portfolio.test.ts"],"names":[],"mappings":";AAAA,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAET,cAAc;AACd,yEAA0E;AAC1E,8CAAgD;AAChD,gDAAkD;AAElD,qBAAqB;AACrB,uDAAsD;AACtD,kFAAmF;AAInF,IAAI,CAAC,4EAA4E,EAAE;IACjF,IAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,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,SAAS,GAAG,IAAI,6BAAc,EAAE,CAAC;oBACvC,SAAS,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;oBACtC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBAC9B,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;oBAC5B,SAAS,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;oBAC7C,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;oBAET,qBAAM,gBAAgB,CAAC,uBAAuB,CAAC,SAAS,CAAC,EAAA;;oBAA7E,iBAAiB,GAAG,SAAyD;oBAEtB,qBAAM,gBAAgB,CAAC,eAAe,CAAC,SAAS,CAAC,EAAA;;oBAAxG,uBAAuB,GAAgC,SAAiD;oBAExF,qBAAM,gBAAgB,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,qBAAU,CAAC,cAAc,EAAE,+BAA+B,CAAC,EAAA;;oBAAjI,aAAa,GAAG,SAAiH;oBAErI,sBAAO,IAAI,EAAC;;;;CACb;AApBD,sCAoBC"}
|
|
@@ -27,13 +27,13 @@ export async function testPortfolio(): Promise<boolean> {
|
|
|
27
27
|
portfolio.setVersion('0.0.1');
|
|
28
28
|
portfolio.setUuid(id_proto);
|
|
29
29
|
portfolio.setPortfolioName('TEST PORTFOLIO');
|
|
30
|
-
portfolio.setAsOf(now.
|
|
30
|
+
portfolio.setAsOf(now.toProto());
|
|
31
31
|
|
|
32
32
|
var validationSummary = await portfolioService.validateCreatePortfolio(portfolio);
|
|
33
33
|
|
|
34
34
|
var createPortfolioResponse:CreatePortfolioResponseProto = await portfolioService.createPortfolio(portfolio);
|
|
35
35
|
|
|
36
|
-
var searchResults = await portfolioService.searchPortfolio(now.
|
|
36
|
+
var searchResults = await portfolioService.searchPortfolio(now.toProto(), FieldProto.PORTFOLIO_NAME, 'Federal Reserve SOMA Holdings');
|
|
37
37
|
|
|
38
38
|
return true;
|
|
39
39
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Models
|
|
2
3
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
4
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
5
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -37,13 +38,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
38
|
};
|
|
38
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
40
|
exports.PositionService = void 0;
|
|
40
|
-
|
|
41
|
+
// Model Utils
|
|
41
42
|
// Requests & Services
|
|
42
43
|
var position_service_grpc_pb_1 = require("../../../fintekkers/services/position-service/position_service_grpc_pb");
|
|
44
|
+
var requestcontext_1 = require("../../models/utils/requestcontext");
|
|
43
45
|
var PositionService = /** @class */ (function () {
|
|
44
46
|
function PositionService() {
|
|
45
|
-
this.client = new position_service_grpc_pb_1.PositionClient(
|
|
46
|
-
// this.client = new PositionClient('localhost:8082', grpc.credentials.createInsecure());
|
|
47
|
+
this.client = new position_service_grpc_pb_1.PositionClient(requestcontext_1.default.apiURL, requestcontext_1.default.apiCredentials);
|
|
47
48
|
}
|
|
48
49
|
PositionService.prototype.search = function (request) {
|
|
49
50
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PositionService.js","sourceRoot":"","sources":["PositionService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PositionService.js","sourceRoot":"","sources":["PositionService.ts"],"names":[],"mappings":";AAAA,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAET,cAAc;AAEd,sBAAsB;AACtB,mHAAwG;AAKxG,oEAA0D;AAG1D;IAGE;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,yCAAc,CAAC,wBAAS,CAAC,MAAM,EAAE,wBAAS,CAAC,cAAc,CAAC,CAAC;IAC/E,CAAC;IAEK,gCAAM,GAAZ,UAAa,OAAiC;;YAI5C,SAAe,0BAA0B;;;;wBACjC,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;wBAE1C,sBAAO,IAAI,OAAO,CAAkB,UAAC,OAAO,EAAE,MAAM;gCAClD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,UAAC,QAAmC;oCACrD,QAAQ,CAAC,gBAAgB,EAAE,CAAC,OAAO,CAAC,UAAC,QAAQ;wCAC3C,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;oCAC/B,CAAC,CAAC,CAAC;gCACL,CAAC,CAAC,CAAC;gCAEH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE;oCAChB,OAAO,CAAC,aAAa,CAAC,CAAC;gCACzB,CAAC,CAAC,CAAC;gCAEH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,UAAC,GAAG;oCACtB,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC;oCAC3C,MAAM,CAAC,GAAG,CAAC,CAAC;gCACd,CAAC,CAAC,CAAC;4BACL,CAAC,CAAC,EAAC;;;aACJ;;;;;wBAtBK,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC;wBACxB,aAAa,GAAoB,EAAE,CAAC;wBAuBnC,qBAAM,0BAA0B,EAAE,EAAA;4BAAzC,sBAAO,SAAkC,EAAC;;;;KAC3C;IACH,sBAAC;AAAD,CAAC,AAlCD,IAkCC;AAEQ,0CAAe"}
|
|
@@ -1,39 +1,24 @@
|
|
|
1
|
-
import * as grpc from '@grpc/grpc-js';
|
|
2
|
-
import { promisify } from 'util';
|
|
3
|
-
|
|
4
1
|
// Models
|
|
5
|
-
import { PortfolioProto } from '../../../fintekkers/models/portfolio/portfolio_pb';
|
|
6
|
-
import { createFieldMapEntry } from '../../models/utils/util';
|
|
7
|
-
import { LocalTimestampProto } from '../../../fintekkers/models/util/local_timestamp_pb';
|
|
8
|
-
import { SummaryProto } from '../../../fintekkers/requests/util/errors/summary_pb';
|
|
9
|
-
|
|
10
|
-
import { ZonedDateTime } from '../../models/utils/datetime';
|
|
11
|
-
import { packStringIntoAny } from '../../models/utils/util';
|
|
12
2
|
|
|
13
3
|
// Model Utils
|
|
14
|
-
import { PositionFilterProto } from '../../../fintekkers/models/position/position_filter_pb';
|
|
15
|
-
import { FieldProto } from '../../../fintekkers/models/position/field_pb';
|
|
16
4
|
|
|
17
5
|
// Requests & Services
|
|
18
6
|
import { PositionClient } from '../../../fintekkers/services/position-service/position_service_grpc_pb';
|
|
19
7
|
import { QueryPositionRequestProto } from '../../../fintekkers/requests/position/query_position_request_pb';
|
|
20
8
|
import { QueryPositionResponseProto } from '../../../fintekkers/requests/position/query_position_response_pb';
|
|
21
9
|
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
24
|
-
import { FieldMapEntry } from '../../../fintekkers/models/position/position_util_pb';
|
|
25
|
-
import { PositionProto, PositionViewProto } from '../../../fintekkers/models/position/position_pb';
|
|
10
|
+
import { PositionProto } from '../../../fintekkers/models/position/position_pb';
|
|
11
|
+
import EnvConfig from '../../models/utils/requestcontext';
|
|
26
12
|
|
|
27
13
|
|
|
28
14
|
class PositionService {
|
|
29
15
|
private client: PositionClient;
|
|
30
16
|
|
|
31
17
|
constructor() {
|
|
32
|
-
this.client = new PositionClient(
|
|
33
|
-
// this.client = new PositionClient('localhost:8082', grpc.credentials.createInsecure());
|
|
18
|
+
this.client = new PositionClient(EnvConfig.apiURL, EnvConfig.apiCredentials);
|
|
34
19
|
}
|
|
35
20
|
|
|
36
|
-
async search(request:QueryPositionRequestProto) {
|
|
21
|
+
async search(request:QueryPositionRequestProto): Promise<PositionProto[]> {
|
|
37
22
|
const tmpClient = this.client;
|
|
38
23
|
const listPositions: PositionProto[] = [];
|
|
39
24
|
|
|
@@ -45,16 +45,24 @@ var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
|
|
|
45
45
|
var position_util_pb_1 = require("../../../fintekkers/models/position/position_util_pb");
|
|
46
46
|
var position_filter_pb_1 = require("../../../fintekkers/models/position/position_filter_pb");
|
|
47
47
|
var datetime_1 = require("../../models/utils/datetime");
|
|
48
|
-
var
|
|
48
|
+
var serialization_util_1 = require("../../models/utils/serialization.util");
|
|
49
49
|
var any_pb_1 = require("google-protobuf/google/protobuf/any_pb");
|
|
50
50
|
//Requests & Services
|
|
51
51
|
var PortfolioService_1 = require("../../services/portfolio-service/PortfolioService");
|
|
52
52
|
var PositionService_1 = require("../../services/position-service/PositionService");
|
|
53
53
|
var query_position_request_pb_1 = require("../../../fintekkers/requests/position/query_position_request_pb");
|
|
54
|
-
test('test getting a position against the api.fintekkers.org position service', function () {
|
|
55
|
-
var isTrue
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
test('test getting a position against the api.fintekkers.org position service', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
|
+
var isTrue;
|
|
56
|
+
return __generator(this, function (_a) {
|
|
57
|
+
switch (_a.label) {
|
|
58
|
+
case 0: return [4 /*yield*/, testPosition()];
|
|
59
|
+
case 1:
|
|
60
|
+
isTrue = _a.sent();
|
|
61
|
+
expect(isTrue).toBe(true);
|
|
62
|
+
return [2 /*return*/];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}); }, 30000);
|
|
58
66
|
function get_position(security, portfolio, measures, position_type, fields, additional_filters, as_of) {
|
|
59
67
|
if (fields === void 0) { fields = [field_pb_1.FieldProto.PORTFOLIO, field_pb_1.FieldProto.SECURITY]; }
|
|
60
68
|
if (additional_filters === void 0) { additional_filters = []; }
|
|
@@ -79,7 +87,7 @@ function get_position(security, portfolio, measures, position_type, fields, addi
|
|
|
79
87
|
if (portfolio !== null && portfolio !== undefined) {
|
|
80
88
|
fieldMapEntry = new position_util_pb_1.FieldMapEntry();
|
|
81
89
|
fieldMapEntry.setField(field_pb_1.FieldProto.PORTFOLIO_NAME);
|
|
82
|
-
fieldMapEntry.setFieldValuePacked((0,
|
|
90
|
+
fieldMapEntry.setFieldValuePacked((0, serialization_util_1.pack)(portfolio.getPortfolioName()));
|
|
83
91
|
filters.push(fieldMapEntry);
|
|
84
92
|
}
|
|
85
93
|
if (additional_filters !== null && additional_filters.length > 0) {
|
|
@@ -87,7 +95,7 @@ function get_position(security, portfolio, measures, position_type, fields, addi
|
|
|
87
95
|
}
|
|
88
96
|
filter_fields = new position_filter_pb_1.PositionFilterProto();
|
|
89
97
|
filter_fields.setFiltersList(filters);
|
|
90
|
-
as_of_proto = as_of.
|
|
98
|
+
as_of_proto = as_of.toProto();
|
|
91
99
|
request = new query_position_request_pb_1.QueryPositionRequestProto();
|
|
92
100
|
request.setPositionType(position_type);
|
|
93
101
|
request.setPositionView(position_pb_1.PositionViewProto.DEFAULT_VIEW);
|
|
@@ -112,13 +120,14 @@ function testPosition() {
|
|
|
112
120
|
case 0:
|
|
113
121
|
now = datetime_1.ZonedDateTime.now();
|
|
114
122
|
portfolioService = new PortfolioService_1.PortfolioService();
|
|
115
|
-
return [4 /*yield*/, portfolioService.searchPortfolio(now.
|
|
123
|
+
return [4 /*yield*/, portfolioService.searchPortfolio(now.toProto(), field_pb_1.FieldProto.PORTFOLIO_NAME, "Federal Reserve SOMA Holdings")];
|
|
116
124
|
case 1:
|
|
117
125
|
portfolios = _a.sent();
|
|
118
126
|
fedReservePortfolio = portfolios[0];
|
|
119
127
|
return [4 /*yield*/, get_position(null, fedReservePortfolio, [measure_pb_1.MeasureProto.DIRECTED_QUANTITY], position_pb_1.PositionTypeProto.TRANSACTION, [field_pb_1.FieldProto.PORTFOLIO_NAME, field_pb_1.FieldProto.SECURITY_ID], [], now)];
|
|
120
128
|
case 2:
|
|
121
129
|
positions = _a.sent();
|
|
130
|
+
console.log(positions);
|
|
122
131
|
return [2 /*return*/, true];
|
|
123
132
|
}
|
|
124
133
|
});
|