@fintekkers/ledger-models 0.1.60 → 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/babel.config.js +3 -1
- package/index.js +1 -15
- package/index.js.map +1 -1
- package/index.ts +1 -19
- package/jest.config.js +4 -0
- package/node/fintekkers/models/security/security_pb.test.js +29 -30
- package/node/fintekkers/models/security/security_pb.test.js.map +1 -0
- package/node/fintekkers/models/security/security_pb.test.ts +33 -0
- 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/security/security.js +1 -1
- package/node/wrappers/models/security/security.js.map +1 -1
- package/node/wrappers/models/security/security.ts +1 -1
- package/node/wrappers/models/transaction/transaction.js +12 -10
- package/node/wrappers/models/transaction/transaction.js.map +1 -1
- package/node/wrappers/models/transaction/transaction.test.js +26 -0
- package/node/wrappers/models/transaction/transaction.test.js.map +1 -0
- package/node/wrappers/models/transaction/transaction.test.ts +36 -0
- package/node/wrappers/models/transaction/transaction.ts +15 -13
- package/node/wrappers/models/transaction/transaction_type.js +44 -0
- package/node/wrappers/models/transaction/transaction_type.js.map +1 -0
- package/node/wrappers/models/transaction/transaction_type.ts +47 -0
- package/node/wrappers/models/utils/date.js +25 -0
- package/node/wrappers/models/utils/date.js.map +1 -0
- package/node/wrappers/models/utils/date.ts +31 -0
- package/node/wrappers/models/utils/datetime.js +4 -4
- package/node/wrappers/models/utils/datetime.js.map +1 -1
- package/node/wrappers/models/utils/datetime.ts +4 -4
- 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 +13 -54
- package/node/wrappers/models/utils/serialization.test.js.map +1 -1
- package/node/wrappers/models/utils/serialization.test.ts +12 -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 -8
- package/node/wrappers/services/portfolio-service/PortfolioService.js.map +1 -1
- package/node/wrappers/services/portfolio-service/PortfolioService.ts +5 -6
- package/node/wrappers/{portfolio.test.js → services/portfolio-service/portfolio.test.js} +12 -11
- package/node/wrappers/services/portfolio-service/portfolio.test.js.map +1 -0
- package/node/wrappers/services/portfolio-service/portfolio.test.ts +40 -0
- package/node/wrappers/services/position-service/PositionService.js +4 -6
- package/node/wrappers/services/position-service/PositionService.js.map +1 -1
- package/node/wrappers/services/position-service/PositionService.ts +4 -22
- package/node/wrappers/{position.test.js → services/position-service/position.test.js} +28 -22
- package/node/wrappers/services/position-service/position.test.js.map +1 -0
- package/node/wrappers/{position.test.ts → services/position-service/position.test.ts} +25 -29
- package/node/wrappers/services/security-service/SecurityService.js +4 -8
- package/node/wrappers/services/security-service/SecurityService.js.map +1 -1
- package/node/wrappers/services/security-service/SecurityService.ts +3 -6
- package/node/wrappers/{security.test.js → services/security-service/security.test.js} +26 -19
- package/node/wrappers/services/security-service/security.test.js.map +1 -0
- package/node/wrappers/{security.test.ts → services/security-service/security.test.ts} +22 -20
- package/node/wrappers/services/transaction-service/TransactionService.js +40 -50
- package/node/wrappers/services/transaction-service/TransactionService.js.map +1 -1
- package/node/wrappers/services/transaction-service/TransactionService.ts +13 -15
- package/node/wrappers/{transaction.test.js → services/transaction-service/transaction.test.js} +41 -25
- package/node/wrappers/services/transaction-service/transaction.test.js.map +1 -0
- package/node/wrappers/services/transaction-service/transaction.test.ts +97 -0
- package/package.json +4 -2
- 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
- package/node/wrappers/portfolio.test.js.map +0 -1
- package/node/wrappers/portfolio.test.ts +0 -36
- package/node/wrappers/position.test.js.map +0 -1
- package/node/wrappers/security.test.js.map +0 -1
- package/node/wrappers/transaction.test.js.map +0 -1
- package/node/wrappers/transaction.test.ts +0 -90
|
@@ -1,28 +1,30 @@
|
|
|
1
|
+
import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
|
|
1
2
|
import { UUIDProto } from '../../../fintekkers/models/util/uuid_pb';
|
|
2
3
|
import { ProtoSerializationUtil } from './serialization';
|
|
3
4
|
import { UUID } from './uuid';
|
|
4
5
|
|
|
5
6
|
import assert = require('assert');
|
|
7
|
+
test('test serialization of key types', () => {
|
|
8
|
+
testSerialization();
|
|
9
|
+
});
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
function testSerialization(): void {
|
|
8
12
|
checkUUID();
|
|
9
13
|
|
|
10
|
-
const
|
|
11
|
-
|
|
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);
|
|
12
17
|
|
|
13
18
|
const deserializedDate: any = ProtoSerializationUtil.deserialize(serializedDate);
|
|
14
|
-
|
|
19
|
+
assert(deserializedDate.toString().indexOf('Mar 05 2023') > -1);
|
|
15
20
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
console.log(serializedTimestamp);
|
|
21
|
+
const serializedTimestamp: any = ProtoSerializationUtil.serialize(march2023);
|
|
22
|
+
assert(serializedTimestamp.toString().indexOf('2023,3,5') > -1);
|
|
19
23
|
|
|
20
24
|
const deserializedTimestamp: any = ProtoSerializationUtil.deserialize(serializedTimestamp);
|
|
21
|
-
|
|
25
|
+
assert(deserializedTimestamp.toString().indexOf('Mar 05 2023') > -1);
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
export { testSerialization };
|
|
25
|
-
|
|
26
28
|
function checkUUID() {
|
|
27
29
|
const uuid: UUID = UUID.random();
|
|
28
30
|
const serializedUUID: UUIDProto = ProtoSerializationUtil.serialize(uuid) as UUIDProto;
|
|
@@ -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;AAC7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|
+
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
|
-
|
|
52
|
-
this.client = new portfolio_service_grpc_pb_1.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 () {
|
|
@@ -98,14 +97,11 @@ var PortfolioService = /** @class */ (function () {
|
|
|
98
97
|
stream2 = tmpClient.search(searchRequest);
|
|
99
98
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
100
99
|
stream2.on('data', function (response) {
|
|
101
|
-
console.log('Result of the portfolio search call');
|
|
102
|
-
console.log('Response:', response);
|
|
103
100
|
response.getPortfolioResponseList().forEach(function (portfolio) {
|
|
104
101
|
listPortfolios.push(portfolio);
|
|
105
102
|
});
|
|
106
103
|
});
|
|
107
104
|
stream2.on('end', function () {
|
|
108
|
-
console.log('Stream ended.');
|
|
109
105
|
resolve(listPortfolios);
|
|
110
106
|
});
|
|
111
107
|
stream2.on('error', function (err) {
|
|
@@ -128,7 +124,7 @@ var PortfolioService = /** @class */ (function () {
|
|
|
128
124
|
positionFilter.setObjectClass('PositionFilter');
|
|
129
125
|
positionFilter.setVersion('0.0.1');
|
|
130
126
|
if (fieldProto && fieldValue) {
|
|
131
|
-
fieldMapEntry = (0,
|
|
127
|
+
fieldMapEntry = (0, serialization_util_1.createFieldMapEntry)(fieldProto, fieldValue);
|
|
132
128
|
positionFilter.setFiltersList([fieldMapEntry]);
|
|
133
129
|
}
|
|
134
130
|
searchRequest.setSearchPortfolioInput(positionFilter);
|
|
@@ -140,6 +136,7 @@ var PortfolioService = /** @class */ (function () {
|
|
|
140
136
|
});
|
|
141
137
|
});
|
|
142
138
|
};
|
|
139
|
+
PortfolioService.url = requestcontext_1.default.apiURL;
|
|
143
140
|
return PortfolioService;
|
|
144
141
|
}());
|
|
145
142
|
exports.PortfolioService = PortfolioService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PortfolioService.js","sourceRoot":"","sources":["PortfolioService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"PortfolioService.js","sourceRoot":"","sources":["PortfolioService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6BAAiC;AAIjC,4EAA4E;AAI5E,cAAc;AACd,6FAA6F;AAG7F,sBAAsB;AACtB,sHAA2G;AAC3G,gHAA+G;AAE/G,kHAAiH;AAEjH,oEAA0D;AAE1D;IAKE;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,2CAAe,CAAC,wBAAS,CAAC,MAAM,EAAE,wBAAS,CAAC,cAAc,CA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3C;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
|
-
|
|
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> {
|
|
@@ -76,15 +78,12 @@ class PortfolioService {
|
|
|
76
78
|
|
|
77
79
|
return new Promise<PortfolioProto[]>((resolve, reject) => {
|
|
78
80
|
stream2.on('data', (response:QueryPortfolioResponseProto) => {
|
|
79
|
-
console.log('Result of the portfolio search call');
|
|
80
|
-
console.log('Response:', response);
|
|
81
81
|
response.getPortfolioResponseList().forEach((portfolio) => {
|
|
82
82
|
listPortfolios.push(portfolio);
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
stream2.on('end', () => {
|
|
87
|
-
console.log('Stream ended.');
|
|
88
87
|
resolve(listPortfolios);
|
|
89
88
|
});
|
|
90
89
|
|
|
@@ -39,12 +39,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
exports.testPortfolio = void 0;
|
|
41
41
|
// Model Utils
|
|
42
|
-
var field_pb_1 = require("
|
|
43
|
-
var uuid = require("
|
|
44
|
-
var dt = require("
|
|
42
|
+
var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
|
|
43
|
+
var uuid = require("../../models/utils/uuid");
|
|
44
|
+
var dt = require("../../models/utils/datetime");
|
|
45
45
|
//Requests & Services
|
|
46
|
-
var PortfolioService_1 = require("./
|
|
47
|
-
var portfolio_pb_1 = require("
|
|
46
|
+
var PortfolioService_1 = require("./PortfolioService");
|
|
47
|
+
var portfolio_pb_1 = require("../../../fintekkers/models/portfolio/portfolio_pb");
|
|
48
|
+
test('test creating a portfolio against the api.fintekkers.org portfolio service', function () {
|
|
49
|
+
var isTrue = testPortfolio();
|
|
50
|
+
expect(isTrue).resolves.toBe(true);
|
|
51
|
+
}, 30000);
|
|
48
52
|
function testPortfolio() {
|
|
49
53
|
return __awaiter(this, void 0, void 0, function () {
|
|
50
54
|
var id_proto, now, portfolioService, portfolio, validationSummary, createPortfolioResponse, searchResults;
|
|
@@ -59,20 +63,17 @@ function testPortfolio() {
|
|
|
59
63
|
portfolio.setVersion('0.0.1');
|
|
60
64
|
portfolio.setUuid(id_proto);
|
|
61
65
|
portfolio.setPortfolioName('TEST PORTFOLIO');
|
|
62
|
-
portfolio.setAsOf(now.
|
|
66
|
+
portfolio.setAsOf(now.toProto());
|
|
63
67
|
return [4 /*yield*/, portfolioService.validateCreatePortfolio(portfolio)];
|
|
64
68
|
case 1:
|
|
65
69
|
validationSummary = _a.sent();
|
|
66
|
-
console.log(validationSummary);
|
|
67
70
|
return [4 /*yield*/, portfolioService.createPortfolio(portfolio)];
|
|
68
71
|
case 2:
|
|
69
72
|
createPortfolioResponse = _a.sent();
|
|
70
|
-
|
|
71
|
-
return [4 /*yield*/, portfolioService.searchPortfolio(now.to_date_proto(), field_pb_1.FieldProto.PORTFOLIO_NAME, 'Federal Reserve SOMA Holdings')];
|
|
73
|
+
return [4 /*yield*/, portfolioService.searchPortfolio(now.toProto(), field_pb_1.FieldProto.PORTFOLIO_NAME, 'Federal Reserve SOMA Holdings')];
|
|
72
74
|
case 3:
|
|
73
75
|
searchResults = _a.sent();
|
|
74
|
-
|
|
75
|
-
return [2 /*return*/];
|
|
76
|
+
return [2 /*return*/, true];
|
|
76
77
|
}
|
|
77
78
|
});
|
|
78
79
|
});
|
|
@@ -0,0 +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,IAAI,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC,EAAE,KAAK,CAAC,CAAC;AAEV,SAAsB,aAAa;;;;;;oBAC3B,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;oBAC5C,GAAG,GAAG,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC;oBAE7B,gBAAgB,GAAG,IAAI,mCAAgB,EAAE,CAAC;oBAE1C,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"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Models
|
|
2
|
+
|
|
3
|
+
// Model Utils
|
|
4
|
+
import { FieldProto } from '../../../fintekkers/models/position/field_pb';
|
|
5
|
+
import * as uuid from '../../models/utils/uuid';
|
|
6
|
+
import * as dt from '../../models/utils/datetime';
|
|
7
|
+
|
|
8
|
+
//Requests & Services
|
|
9
|
+
import { PortfolioService } from './PortfolioService';
|
|
10
|
+
import { PortfolioProto } from '../../../fintekkers/models/portfolio/portfolio_pb';
|
|
11
|
+
import { CreatePortfolioResponseProto } from '../../../fintekkers/requests/portfolio/create_portfolio_response_pb';
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
test('test creating a portfolio against the api.fintekkers.org portfolio service', () => {
|
|
15
|
+
const isTrue = testPortfolio();
|
|
16
|
+
expect(isTrue).resolves.toBe(true);
|
|
17
|
+
}, 30000);
|
|
18
|
+
|
|
19
|
+
export async function testPortfolio(): Promise<boolean> {
|
|
20
|
+
const id_proto = uuid.UUID.random().toUUIDProto();
|
|
21
|
+
const now = dt.ZonedDateTime.now();
|
|
22
|
+
|
|
23
|
+
const portfolioService = new PortfolioService();
|
|
24
|
+
|
|
25
|
+
const portfolio = new PortfolioProto();
|
|
26
|
+
portfolio.setObjectClass('Portfolio');
|
|
27
|
+
portfolio.setVersion('0.0.1');
|
|
28
|
+
portfolio.setUuid(id_proto);
|
|
29
|
+
portfolio.setPortfolioName('TEST PORTFOLIO');
|
|
30
|
+
portfolio.setAsOf(now.toProto());
|
|
31
|
+
|
|
32
|
+
var validationSummary = await portfolioService.validateCreatePortfolio(portfolio);
|
|
33
|
+
|
|
34
|
+
var createPortfolioResponse:CreatePortfolioResponseProto = await portfolioService.createPortfolio(portfolio);
|
|
35
|
+
|
|
36
|
+
var searchResults = await portfolioService.searchPortfolio(now.toProto(), FieldProto.PORTFOLIO_NAME, 'Federal Reserve SOMA Holdings');
|
|
37
|
+
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
@@ -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
|
-
|
|
46
|
-
this.client = new position_service_grpc_pb_1.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 () {
|
|
@@ -54,14 +55,11 @@ var PositionService = /** @class */ (function () {
|
|
|
54
55
|
stream2 = tmpClient.search(request);
|
|
55
56
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
56
57
|
stream2.on('data', function (response) {
|
|
57
|
-
console.log('Result of the position search call');
|
|
58
|
-
console.log('Response:', response);
|
|
59
58
|
response.getPositionsList().forEach(function (position) {
|
|
60
59
|
listPositions.push(position);
|
|
61
60
|
});
|
|
62
61
|
});
|
|
63
62
|
stream2.on('end', function () {
|
|
64
|
-
console.log('Stream ended.');
|
|
65
63
|
resolve(listPositions);
|
|
66
64
|
});
|
|
67
65
|
stream2.on('error', function (err) {
|
|
@@ -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
|
-
|
|
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
|
|
|
@@ -42,15 +27,12 @@ class PositionService {
|
|
|
42
27
|
|
|
43
28
|
return new Promise<PositionProto[]>((resolve, reject) => {
|
|
44
29
|
stream2.on('data', (response:QueryPositionResponseProto) => {
|
|
45
|
-
console.log('Result of the position search call');
|
|
46
|
-
console.log('Response:', response);
|
|
47
30
|
response.getPositionsList().forEach((position) => {
|
|
48
31
|
listPositions.push(position);
|
|
49
32
|
});
|
|
50
33
|
});
|
|
51
34
|
|
|
52
35
|
stream2.on('end', () => {
|
|
53
|
-
console.log('Stream ended.');
|
|
54
36
|
resolve(listPositions);
|
|
55
37
|
});
|
|
56
38
|
|