@fintekkers/ledger-models 0.1.73 → 0.1.76
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/models/util/api/api_key_grpc_pb.js +1 -0
- package/node/fintekkers/models/util/api/api_key_pb.d.ts +36 -0
- package/node/fintekkers/models/util/api/api_key_pb.js +266 -0
- package/node/wrappers/models/position/position.js +21 -14
- package/node/wrappers/models/position/position.js.map +1 -1
- package/node/wrappers/models/position/position.test.js +79 -10
- package/node/wrappers/models/position/position.test.js.map +1 -1
- package/node/wrappers/models/position/position.test.ts +86 -10
- package/node/wrappers/models/position/position.ts +26 -27
- package/node/wrappers/models/utils/datetime.js +0 -19
- package/node/wrappers/models/utils/datetime.js.map +1 -1
- package/node/wrappers/models/utils/datetime.test.js +48 -0
- package/node/wrappers/models/utils/datetime.test.js.map +1 -0
- package/node/wrappers/models/utils/datetime.test.ts +8 -0
- package/node/wrappers/models/utils/datetime.ts +0 -24
- package/node/wrappers/models/utils/protoEnum.js +5 -1
- package/node/wrappers/models/utils/protoEnum.js.map +1 -1
- package/node/wrappers/models/utils/protoEnum.test.js +4 -0
- package/node/wrappers/models/utils/protoEnum.test.js.map +1 -1
- package/node/wrappers/models/utils/protoEnum.test.ts +5 -0
- package/node/wrappers/models/utils/protoEnum.ts +7 -2
- package/node/wrappers/models/utils/serialization.js.map +1 -1
- package/node/wrappers/models/utils/serialization.ts +2 -7
- package/node/wrappers/requests/position/QueryPositionRequest.js +44 -0
- package/node/wrappers/requests/position/QueryPositionRequest.js.map +1 -0
- package/node/wrappers/requests/position/QueryPositionRequest.ts +64 -0
- package/node/wrappers/services/portfolio-service/portfolio.test.js +1 -1
- package/node/wrappers/services/portfolio-service/portfolio.test.js.map +1 -1
- package/node/wrappers/services/portfolio-service/portfolio.test.ts +1 -1
- package/node/wrappers/services/position-service/PositionService.js +3 -2
- package/node/wrappers/services/position-service/PositionService.js.map +1 -1
- package/node/wrappers/services/position-service/PositionService.ts +3 -1
- package/node/wrappers/services/position-service/position.test.js +2 -9
- package/node/wrappers/services/position-service/position.test.js.map +1 -1
- package/node/wrappers/services/position-service/position.test.ts +2 -10
- package/package.json +1 -1
- package/tsconfig.json +27 -25
- package/web/fintekkers/models/util/api/api_key_pb.d.ts +34 -0
- package/web/fintekkers/models/util/api/api_key_pb.js +260 -0
|
@@ -5,7 +5,7 @@ import assert = require('assert');
|
|
|
5
5
|
|
|
6
6
|
import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
|
|
7
7
|
import { PositionProto } from '../../../fintekkers/models/position/position_pb';
|
|
8
|
-
import { FieldMapEntry } from '../../../fintekkers/models/position/position_util_pb';
|
|
8
|
+
import { FieldMapEntry, MeasureMapEntry } from '../../../fintekkers/models/position/position_util_pb';
|
|
9
9
|
import { FieldProto } from '../../../fintekkers/models/position/field_pb';
|
|
10
10
|
import { MeasureProto } from '../../../fintekkers/models/position/measure_pb';
|
|
11
11
|
import { SecurityProto } from '../../../fintekkers/models/security/security_pb';
|
|
@@ -13,24 +13,54 @@ import { PortfolioProto } from '../../../fintekkers/models/portfolio/portfolio_p
|
|
|
13
13
|
import { Position } from './position';
|
|
14
14
|
import { LocalDate } from '../utils/date';
|
|
15
15
|
import { PositionStatusProto } from '../../../fintekkers/models/position/position_status_pb';
|
|
16
|
+
import { ProtoEnum } from '../utils/protoEnum';
|
|
16
17
|
|
|
17
18
|
test('test the position wrapper', async () => {
|
|
18
|
-
|
|
19
|
+
let isTrue = await testEnumSerialization();
|
|
19
20
|
expect(isTrue).toBe(true);
|
|
21
|
+
|
|
22
|
+
isTrue = await testSerialization();
|
|
23
|
+
expect(isTrue).toBe(true);
|
|
24
|
+
|
|
25
|
+
isTrue = await testJsonSerialization();
|
|
26
|
+
expect(isTrue).toBe(true);
|
|
27
|
+
|
|
20
28
|
});
|
|
21
29
|
|
|
22
|
-
async function
|
|
23
|
-
let
|
|
30
|
+
async function testEnumSerialization(): Promise<boolean> {
|
|
31
|
+
let positionProto = new PositionProto();
|
|
32
|
+
positionProto.setFieldsList([
|
|
33
|
+
new FieldMapEntry().setField(FieldProto.POSITION_STATUS).setEnumValue(PositionStatusProto.EXECUTED)
|
|
34
|
+
]);
|
|
24
35
|
|
|
36
|
+
let measureValue = new DecimalValueProto().setArbitraryPrecisionValue("1.55");
|
|
37
|
+
positionProto.setMeasuresList([
|
|
38
|
+
new MeasureMapEntry().setMeasure(MeasureProto.DIRECTED_QUANTITY).setMeasureDecimalValue(measureValue)
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
let position = new Position(positionProto);
|
|
42
|
+
|
|
43
|
+
let status: ProtoEnum = position.getFieldValue(FieldProto.POSITION_STATUS);
|
|
44
|
+
expect(status.getEnumValueName()).toBe("EXECUTED");
|
|
45
|
+
expect(status.getEnumValue()).toBe(PositionStatusProto.EXECUTED);
|
|
46
|
+
expect(status.getEnumDescriptor()).toBe(PositionStatusProto);
|
|
47
|
+
|
|
48
|
+
position.getMeasures().forEach(measureMapEntry => {
|
|
49
|
+
measureMapEntry.getMeasure().toString();
|
|
50
|
+
});
|
|
51
|
+
expect(position.getMeasureValue(MeasureProto.DIRECTED_QUANTITY)).toBe(1.55);
|
|
52
|
+
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
async function testJsonSerialization(): Promise<boolean> {
|
|
25
58
|
let security = new SecurityProto().setAssetClass("Test");
|
|
26
59
|
let portfolio = new PortfolioProto().setPortfolioName("Test portfolio");
|
|
27
60
|
let tradeDate = LocalDate.today().toDate();
|
|
28
61
|
let productType = "Test product type";
|
|
29
62
|
let id = new UUID(UUID.random().toBytes());
|
|
30
63
|
|
|
31
|
-
let measure = MeasureProto.DIRECTED_QUANTITY;
|
|
32
|
-
let measureValue = new DecimalValueProto().setArbitraryPrecisionValue("1.0");
|
|
33
|
-
|
|
34
64
|
const tradeDatePacked = new Any();
|
|
35
65
|
tradeDatePacked.setTypeUrl(`Doesn't matter`);
|
|
36
66
|
tradeDatePacked.setValue(LocalDate.from(tradeDate).toProto().serializeBinary());
|
|
@@ -41,15 +71,30 @@ async function testSerialization(): Promise<boolean> {
|
|
|
41
71
|
|
|
42
72
|
let positionProto = new PositionProto();
|
|
43
73
|
positionProto.setFieldsList([
|
|
74
|
+
// new FieldMapEntry().setField(FieldProto.SECURITY).setFieldValuePacked(security),
|
|
44
75
|
new FieldMapEntry().setField(FieldProto.TRADE_DATE).setFieldValuePacked(tradeDatePacked),
|
|
45
|
-
new FieldMapEntry().setField(FieldProto.SECURITY).setFieldValuePacked(security),
|
|
46
|
-
new FieldMapEntry().setField(FieldProto.PORTFOLIO).setFieldValuePacked(portfolio),
|
|
47
76
|
new FieldMapEntry().setField(FieldProto.POSITION_STATUS).setEnumValue(PositionStatusProto.EXECUTED),
|
|
48
77
|
new FieldMapEntry().setField(FieldProto.PRODUCT_TYPE).setStringValue(productType),
|
|
49
78
|
new FieldMapEntry().setField(FieldProto.ID).setFieldValuePacked(idPacked),
|
|
50
79
|
]);
|
|
51
80
|
let position = new Position(positionProto);
|
|
52
81
|
|
|
82
|
+
let position2 = Position.fromJSON(position.toJSON());
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
let tradeDatePosition = position2.getFieldValue(FieldProto.TRADE_DATE);
|
|
86
|
+
expect(tradeDate.getFullYear()).toBe(tradeDatePosition.getFullYear());
|
|
87
|
+
expect(tradeDate.getMonth()).toBe(tradeDatePosition.getMonth());
|
|
88
|
+
expect(tradeDate.getDay()).toBe(tradeDatePosition.getDay());
|
|
89
|
+
expect(tradeDate.getMonth()).toBe(tradeDatePosition.getMonth());
|
|
90
|
+
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
async function testSerialization(): Promise<boolean> {
|
|
96
|
+
let { position, tradeDate, security, portfolio, productType, id } = getPosition();
|
|
97
|
+
|
|
53
98
|
let tradeDatePosition = position.getFieldValue(FieldProto.TRADE_DATE);
|
|
54
99
|
expect(tradeDate.getFullYear()).toBe(tradeDatePosition.getFullYear());
|
|
55
100
|
expect(tradeDate.getMonth()).toBe(tradeDatePosition.getMonth());
|
|
@@ -66,7 +111,38 @@ async function testSerialization(): Promise<boolean> {
|
|
|
66
111
|
let positionID = position.getFieldValue(FieldProto.ID);
|
|
67
112
|
expect(positionID.toString()).toBe(id.toString());
|
|
68
113
|
|
|
69
|
-
expect(position.getFieldValue(FieldProto.POSITION_STATUS)).toBe(
|
|
114
|
+
expect(position.getFieldValue(FieldProto.POSITION_STATUS).toString()).toBe("EXECUTED");
|
|
70
115
|
|
|
71
116
|
return true;
|
|
72
117
|
}
|
|
118
|
+
|
|
119
|
+
function getPosition() {
|
|
120
|
+
let security = new SecurityProto().setAssetClass("Test");
|
|
121
|
+
let portfolio = new PortfolioProto().setPortfolioName("Test portfolio");
|
|
122
|
+
let tradeDate = LocalDate.today().toDate();
|
|
123
|
+
let productType = "Test product type";
|
|
124
|
+
let id = new UUID(UUID.random().toBytes());
|
|
125
|
+
|
|
126
|
+
let measure = MeasureProto.DIRECTED_QUANTITY;
|
|
127
|
+
let measureValue = new DecimalValueProto().setArbitraryPrecisionValue("1.0");
|
|
128
|
+
|
|
129
|
+
const tradeDatePacked = new Any();
|
|
130
|
+
tradeDatePacked.setTypeUrl(`Doesn't matter`);
|
|
131
|
+
tradeDatePacked.setValue(LocalDate.from(tradeDate).toProto().serializeBinary());
|
|
132
|
+
|
|
133
|
+
const idPacked = new Any();
|
|
134
|
+
idPacked.setTypeUrl(`Doesn't matter`);
|
|
135
|
+
idPacked.setValue(id.toUUIDProto().serializeBinary());
|
|
136
|
+
|
|
137
|
+
let positionProto = new PositionProto();
|
|
138
|
+
positionProto.setFieldsList([
|
|
139
|
+
new FieldMapEntry().setField(FieldProto.SECURITY).setFieldValuePacked(security),
|
|
140
|
+
new FieldMapEntry().setField(FieldProto.PORTFOLIO).setFieldValuePacked(portfolio),
|
|
141
|
+
new FieldMapEntry().setField(FieldProto.TRADE_DATE).setFieldValuePacked(tradeDatePacked),
|
|
142
|
+
new FieldMapEntry().setField(FieldProto.POSITION_STATUS).setEnumValue(PositionStatusProto.EXECUTED),
|
|
143
|
+
new FieldMapEntry().setField(FieldProto.PRODUCT_TYPE).setStringValue(productType),
|
|
144
|
+
new FieldMapEntry().setField(FieldProto.ID).setFieldValuePacked(idPacked),
|
|
145
|
+
]);
|
|
146
|
+
let position = new Position(positionProto);
|
|
147
|
+
return { position, tradeDate, security, portfolio, productType, id };
|
|
148
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
1
|
+
//Models
|
|
3
2
|
import { FieldProto } from "../../../fintekkers/models/position/field_pb";
|
|
4
3
|
import { PositionProto } from "../../../fintekkers/models/position/position_pb";
|
|
5
4
|
import { FieldMapEntry, MeasureMapEntry } from "../../../fintekkers/models/position/position_util_pb";
|
|
@@ -13,6 +12,10 @@ import { MeasureProto } from "../../../fintekkers/models/position/measure_pb";
|
|
|
13
12
|
import Decimal from "decimal.js";
|
|
14
13
|
import { ProtoSerializationUtil } from "../utils/serialization";
|
|
15
14
|
import { StringValue } from 'google-protobuf/google/protobuf/wrappers_pb';
|
|
15
|
+
import { ProtoEnum } from "../utils/protoEnum";
|
|
16
|
+
import { Field } from "./field";
|
|
17
|
+
import { UUID } from "../utils/uuid";
|
|
18
|
+
import { ZonedDateTime } from "../utils/datetime";
|
|
16
19
|
|
|
17
20
|
export class Position {
|
|
18
21
|
proto: PositionProto;
|
|
@@ -21,11 +24,27 @@ export class Position {
|
|
|
21
24
|
this.proto = positionProto;
|
|
22
25
|
}
|
|
23
26
|
|
|
27
|
+
/*** */
|
|
28
|
+
toJSON(): any {
|
|
29
|
+
return {
|
|
30
|
+
proto: this.proto.serializeBinary(), // Serialize Age object to binary buffer
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Experimental impelementaiton
|
|
36
|
+
* @param binary An array which is the raw binary of the proto object
|
|
37
|
+
* @returns A Position object with the deserialized binary inside it
|
|
38
|
+
*/
|
|
39
|
+
static fromJSON(json: any): Position {
|
|
40
|
+
return new Position(PositionProto.deserializeBinary(json['proto']));
|
|
41
|
+
}
|
|
42
|
+
|
|
24
43
|
public getFieldValue(field: FieldProto): any {
|
|
25
44
|
return this.getField(new FieldMapEntry().setField(field));
|
|
26
45
|
}
|
|
27
46
|
|
|
28
|
-
public getField(fieldToGet: FieldMapEntry):
|
|
47
|
+
public getField(fieldToGet: FieldMapEntry): string | ProtoEnum | Security | Portfolio | UUID | Date | ZonedDateTime | number {
|
|
29
48
|
for (const tmpField of this.proto.getFieldsList()) {
|
|
30
49
|
if (tmpField.getField() === fieldToGet.getField()) {
|
|
31
50
|
|
|
@@ -34,9 +53,9 @@ export class Position {
|
|
|
34
53
|
}
|
|
35
54
|
|
|
36
55
|
if (tmpField.getEnumValue() > 0) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return
|
|
56
|
+
let fieldName: string = new Field(fieldToGet.getField()).getName();
|
|
57
|
+
let proto: ProtoEnum = ProtoEnum.fromEnumName(fieldName, tmpField.getEnumValue());
|
|
58
|
+
return proto;
|
|
40
59
|
}
|
|
41
60
|
|
|
42
61
|
const unpackedValue = Position.unpackField(tmpField);
|
|
@@ -63,7 +82,7 @@ export class Position {
|
|
|
63
82
|
private getMeasure(measureToGet: MeasureMapEntry): Decimal {
|
|
64
83
|
for (const tmpMeasure of this.proto.getMeasuresList()) {
|
|
65
84
|
if (tmpMeasure.getMeasure() === measureToGet.getMeasure()) {
|
|
66
|
-
return ProtoSerializationUtil.deserialize(tmpMeasure.getMeasureDecimalValue());
|
|
85
|
+
return ProtoSerializationUtil.deserialize(tmpMeasure.getMeasureDecimalValue()) as unknown as Decimal;
|
|
67
86
|
}
|
|
68
87
|
}
|
|
69
88
|
|
|
@@ -100,18 +119,6 @@ export class Position {
|
|
|
100
119
|
return output;
|
|
101
120
|
}
|
|
102
121
|
|
|
103
|
-
// private static wrapStringToAny(myString: string): Any {
|
|
104
|
-
// const myAny = new Any();
|
|
105
|
-
// myAny.pack(wrappers.StringValue.create({ value: myString }));
|
|
106
|
-
// return myAny;
|
|
107
|
-
// }
|
|
108
|
-
|
|
109
|
-
// private static packField(fieldToPack: any): Any {
|
|
110
|
-
// const myAny = new Any();
|
|
111
|
-
// myAny.pack(fieldToPack);
|
|
112
|
-
// return myAny;
|
|
113
|
-
// }
|
|
114
|
-
|
|
115
122
|
public static unpackField(fieldToUnpack: FieldMapEntry): any {
|
|
116
123
|
switch (fieldToUnpack.getField()) {
|
|
117
124
|
case FieldProto.PORTFOLIO_ID:
|
|
@@ -147,12 +154,4 @@ export class Position {
|
|
|
147
154
|
throw new Error(`Field not found. Could not unpack ${FieldProto[fieldToUnpack.getField()]}`);
|
|
148
155
|
}
|
|
149
156
|
}
|
|
150
|
-
|
|
151
|
-
// public static unpackMeasure(measureToUnpack: MeasureProto): DecimalValueProto {
|
|
152
|
-
// if (measureToUnpack === MeasureProto.DIRECTED_QUANTITY) {
|
|
153
|
-
// return measureToUnpack.g;
|
|
154
|
-
// } else {
|
|
155
|
-
// throw new Error(`Field not found. Could not unpack ${MeasureProto.Name[measureToUnpack.measure]}`);
|
|
156
|
-
// }
|
|
157
|
-
// }
|
|
158
157
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZonedDateTime = void 0;
|
|
4
|
-
var console_1 = require("console");
|
|
5
4
|
var local_timestamp_pb_1 = require("../../../fintekkers/models/util/local_timestamp_pb");
|
|
6
5
|
var timestamp_pb_1 = require("google-protobuf/google/protobuf/timestamp_pb");
|
|
7
6
|
var luxon_1 = require("luxon");
|
|
@@ -51,22 +50,4 @@ var ZonedDateTime = /** @class */ (function () {
|
|
|
51
50
|
return ZonedDateTime;
|
|
52
51
|
}());
|
|
53
52
|
exports.ZonedDateTime = ZonedDateTime;
|
|
54
|
-
// function createTimestampWithCurrentTime(): ZonedDateTime {
|
|
55
|
-
// // Get the current time in milliseconds since January 1, 1970 (Unix timestamp)
|
|
56
|
-
// const currentTimeMillis = Date.now();
|
|
57
|
-
// // Convert milliseconds to seconds and nanoseconds
|
|
58
|
-
// const seconds = Math.floor(currentTimeMillis / 1000);
|
|
59
|
-
// const nanos = (currentTimeMillis % 1000) * 1e6; // 1 millisecond = 1e6 nanoseconds
|
|
60
|
-
// // Create a new Timestamp object with the current time
|
|
61
|
-
// const timestamp = new Timestamp();
|
|
62
|
-
// timestamp.setSeconds(seconds);
|
|
63
|
-
// timestamp.setNanos(nanos);
|
|
64
|
-
// const localTimestamp = new LocalTimestampProto();
|
|
65
|
-
// localTimestamp.setTimeZone('America/New_York');
|
|
66
|
-
// localTimestamp.setTimestamp(timestamp);
|
|
67
|
-
// return new ZonedDateTime(localTimestamp);
|
|
68
|
-
// }
|
|
69
|
-
// ZonedDateTime.now = createTimestampWithCurrentTime;
|
|
70
|
-
var now = ZonedDateTime.now();
|
|
71
|
-
(0, console_1.assert)(now.toDateTime().toString() === now.toString());
|
|
72
53
|
//# sourceMappingURL=datetime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datetime.js","sourceRoot":"","sources":["datetime.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"datetime.js","sourceRoot":"","sources":["datetime.ts"],"names":[],"mappings":";;;AACA,yFAAyF;AACzF,6EAAyE;AACzE,+BAAiC;AAEjC;IAGE,uBAAY,KAA0B;QACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,mCAAW,GAAX;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;IAClC,CAAC;IAED,kCAAU,GAAV;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,CAAC;IAED,sCAAc,GAAd;QACE,OAAO,I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,EAAE,CAAC;QACjD,cAAc,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;QAC/C,cAAc,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAEvC,OAAO,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC;IAC3C,CAAC;IACH,oBAAC;AAAD,CAAC,AA1DD,IA0DC;AAEQ,sCAAa"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var datetime_1 = require("./datetime");
|
|
40
|
+
test('test the position wrapper', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
|
+
var now;
|
|
42
|
+
return __generator(this, function (_a) {
|
|
43
|
+
now = datetime_1.ZonedDateTime.now();
|
|
44
|
+
expect(now.toDateTime().toString()).toBe(now.toString());
|
|
45
|
+
return [2 /*return*/];
|
|
46
|
+
});
|
|
47
|
+
}); });
|
|
48
|
+
//# sourceMappingURL=datetime.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime.test.js","sourceRoot":"","sources":["datetime.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uCAA2C;AAE3C,IAAI,CAAC,2BAA2B,EAAE;;;QAExB,GAAG,GAAG,wBAAa,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;;;KAC5D,CAAC,CAAC"}
|
|
@@ -63,28 +63,4 @@ class ZonedDateTime {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
// function createTimestampWithCurrentTime(): ZonedDateTime {
|
|
67
|
-
// // Get the current time in milliseconds since January 1, 1970 (Unix timestamp)
|
|
68
|
-
// const currentTimeMillis = Date.now();
|
|
69
|
-
|
|
70
|
-
// // Convert milliseconds to seconds and nanoseconds
|
|
71
|
-
// const seconds = Math.floor(currentTimeMillis / 1000);
|
|
72
|
-
// const nanos = (currentTimeMillis % 1000) * 1e6; // 1 millisecond = 1e6 nanoseconds
|
|
73
|
-
|
|
74
|
-
// // Create a new Timestamp object with the current time
|
|
75
|
-
// const timestamp = new Timestamp();
|
|
76
|
-
// timestamp.setSeconds(seconds);
|
|
77
|
-
// timestamp.setNanos(nanos);
|
|
78
|
-
|
|
79
|
-
// const localTimestamp = new LocalTimestampProto();
|
|
80
|
-
// localTimestamp.setTimeZone('America/New_York');
|
|
81
|
-
// localTimestamp.setTimestamp(timestamp);
|
|
82
|
-
|
|
83
|
-
// return new ZonedDateTime(localTimestamp);
|
|
84
|
-
// }
|
|
85
|
-
|
|
86
|
-
// ZonedDateTime.now = createTimestampWithCurrentTime;
|
|
87
|
-
const now = ZonedDateTime.now();
|
|
88
|
-
assert(now.toDateTime().toString() === now.toString());
|
|
89
|
-
|
|
90
66
|
export { ZonedDateTime };
|
|
@@ -24,9 +24,13 @@ var ProtoEnum = /** @class */ (function () {
|
|
|
24
24
|
}
|
|
25
25
|
throw new Error("Enum has not been mapped: ".concat(enumName));
|
|
26
26
|
};
|
|
27
|
+
ProtoEnum.prototype.getEnumDescriptor = function () {
|
|
28
|
+
return this.enumDescriptor;
|
|
29
|
+
};
|
|
27
30
|
ProtoEnum.prototype.getEnumName = function () {
|
|
28
31
|
// Assuming your enumDescriptor has a name property or similar
|
|
29
|
-
|
|
32
|
+
throw new Error("Not supported currently");
|
|
33
|
+
// return this.enumDescriptor.name;
|
|
30
34
|
};
|
|
31
35
|
ProtoEnum.prototype.getEnumValue = function () {
|
|
32
36
|
return this.enumValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protoEnum.js","sourceRoot":"","sources":["protoEnum.ts"],"names":[],"mappings":";;;AACA,kGAAkG;AAClG,6FAA6F;AAC7F,yEAA0E;AAE1E;IAII,mBAAY,cAAmB,EAAE,SAAiB;QAC9C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACzC,CAAC;IAEM,sBAAY,GAAnB,UAAoB,QAAgB,EAAE,SAAiB;QACnD,OAAO,IAAI,SAAS,CAAC,SAAS,CAAC,0BAA0B,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC;IACpF,CAAC;IAEc,oCAA0B,GAAzC,UAA0C,QAAgB;QACtD,IAAI,QAAQ,KAAK,kBAAkB,EAAE,CAAC;YAClC,OAAO,0CAAoB,CAAC;QAChC,CAAC;QACD,IAAI,QAAQ,KAAK,iBAAiB,EAAE,CAAC;YACjC,OAAO,wCAAmB,CAAC;QAC/B,CAAC;QACD,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;YACvB,OAAO,qBAAU,CAAC;QACtB,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,oCAA6B,QAAQ,CAAE,CAAC,CAAC;IAC7D,CAAC;IAED,+BAAW,GAAX;QACI,8DAA8D;QAC9D,
|
|
1
|
+
{"version":3,"file":"protoEnum.js","sourceRoot":"","sources":["protoEnum.ts"],"names":[],"mappings":";;;AACA,kGAAkG;AAClG,6FAA6F;AAC7F,yEAA0E;AAE1E;IAII,mBAAY,cA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,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,4BAAQ,GAAR;QACI,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACnC,CAAC;IACL,gBAAC;AAAD,CAAC,AArDD,IAqDC;AArDY,8BAAS"}
|
|
@@ -13,6 +13,10 @@ describe('ProtoEnum', function () {
|
|
|
13
13
|
var protoEnum = new protoEnum_1.ProtoEnum(position_status_pb_1.PositionStatusProto.INTENDED, 2);
|
|
14
14
|
expect(protoEnum.getEnumValue()).toEqual(2);
|
|
15
15
|
});
|
|
16
|
+
it('should correctly return the enum name for PositionStatusProto', function () {
|
|
17
|
+
var protoEnum = new protoEnum_1.ProtoEnum(position_status_pb_1.PositionStatusProto.INTENDED, 2);
|
|
18
|
+
expect(function () { return protoEnum.getEnumName(); }).toThrow(Error);
|
|
19
|
+
});
|
|
16
20
|
it('should throw an error for an unmapped enum name', function () {
|
|
17
21
|
expect(function () { return protoEnum_1.ProtoEnum.fromEnumName('UNMAPPED_ENUM', 0); }).toThrow('Enum has not been mapped: UNMAPPED_ENUM');
|
|
18
22
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protoEnum.test.js","sourceRoot":"","sources":["protoEnum.test.ts"],"names":[],"mappings":";AAAA,oBAAoB;;AAEpB,6FAA6F;AAC7F,kGAAkG;AAClG,yCAAwC;AAExC,QAAQ,CAAC,WAAW,EAAE;IAClB,EAAE,CAAC,+EAA+E,EAAE;QAChF,IAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,0CAAoB,EAAE,CAAC,CAAC,CAAC;QACzD,MAAM,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gEAAgE,EAAE;QACjE,IAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,wCAAmB,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACjE,MAAM,CAAC,SAAS,CA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D,MAAM,CAAC,cAAM,OAAA,qBAAS,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC,CAAC,EAA1C,CAA0C,CAAC,CAAC,OAAO,CAAC,yCAAyC,CAAC,CAAC;IAChH,CAAC,CAAC,CAAC;IAEH,sDAAsD;AAC1D,CAAC,CAAC,CAAC"}
|
|
@@ -15,6 +15,11 @@ describe('ProtoEnum', () => {
|
|
|
15
15
|
expect(protoEnum.getEnumValue()).toEqual(2);
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
it('should correctly return the enum name for PositionStatusProto', () => {
|
|
19
|
+
const protoEnum = new ProtoEnum(PositionStatusProto.INTENDED, 2);
|
|
20
|
+
expect(() => protoEnum.getEnumName()).toThrow(Error);
|
|
21
|
+
});
|
|
22
|
+
|
|
18
23
|
it('should throw an error for an unmapped enum name', () => {
|
|
19
24
|
expect(() => ProtoEnum.fromEnumName('UNMAPPED_ENUM', 0)).toThrow('Enum has not been mapped: UNMAPPED_ENUM');
|
|
20
25
|
});
|
|
@@ -29,9 +29,14 @@ export class ProtoEnum {
|
|
|
29
29
|
throw new Error(`Enum has not been mapped: ${enumName}`);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
getEnumDescriptor(): string {
|
|
33
|
+
return this.enumDescriptor;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getEnumName(): Error {
|
|
33
37
|
// Assuming your enumDescriptor has a name property or similar
|
|
34
|
-
|
|
38
|
+
throw new Error("Not supported currently");
|
|
39
|
+
// return this.enumDescriptor.name;
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
getEnumValue(): number {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["serialization.ts"],"names":[],"mappings":";;;AAAA,qFAAqF;AACrF,+EAA+E;AAC/E,yFAAyF;AACzF,mEAAoE;AACpE,uCAA2C;AAC3C,+BAA8B;AAC9B,2EAA0E;
|
|
1
|
+
{"version":3,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;YAClC,IAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;YACvE,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,GAAG,YAAY,wCAAmB,EAAE,CAAC;YACvC,OAAO,IAAI,wBAAa,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,SAAS,KAAK,kBAAkB,EAAE,CAAC;YAC1D,OAAO,IAAI,CAAC,CAAA,uCAAuC;QACrD,CAAC;QACD,IAAI,GAAG,YAAY,oCAAiB,EAAE,CAAC;YACrC,OAAO,UAAU,CAAC,GAAG,CAAC,0BAA0B,EAAE,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,GAAG,YAAY,yBAAW,EAAE,CAAC;YAC/B,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;QACxB,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,+CAAwC,OAAO,GAAG,sBAAY,GAAG,CAAE,CAAC,CAAC;IACvF,CAAC;IACH,6BAAC;AAAD,CAAC,AAhDD,IAgDC;AAhDY,wDAAsB"}
|
|
@@ -6,13 +6,8 @@ import { ZonedDateTime } from "./datetime";
|
|
|
6
6
|
import { UUID } from "./uuid";
|
|
7
7
|
import { StringValue } from 'google-protobuf/google/protobuf/wrappers_pb';
|
|
8
8
|
|
|
9
|
-
interface EnumValueDescriptor {
|
|
10
|
-
name: string;
|
|
11
|
-
values_by_number: { [key: number]: { name: string } };
|
|
12
|
-
}
|
|
13
|
-
|
|
14
9
|
export class ProtoSerializationUtil {
|
|
15
|
-
static serialize(obj: any):
|
|
10
|
+
static serialize(obj: any) { //}: UUIDProto | LocalDateProto | LocalTimestampProto | DecimalValueProto | StringValue {
|
|
16
11
|
if (obj instanceof UUID) {
|
|
17
12
|
return obj.toUUIDProto();
|
|
18
13
|
}
|
|
@@ -35,7 +30,7 @@ export class ProtoSerializationUtil {
|
|
|
35
30
|
throw new Error(`Could not serialize object of type ${typeof obj}. Value: ${obj}`);
|
|
36
31
|
}
|
|
37
32
|
|
|
38
|
-
static deserialize(obj: any):
|
|
33
|
+
static deserialize(obj: any) { //}: UUID | Date | ZonedDateTime | number | string {
|
|
39
34
|
if (obj instanceof UUIDProto) {
|
|
40
35
|
return UUID.fromU8Array(obj.getRawUuid_asU8());
|
|
41
36
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryPositionRequest = void 0;
|
|
4
|
+
var position_pb_1 = require("../../../fintekkers/models/position/position_pb");
|
|
5
|
+
var datetime_1 = require("../../models/utils/datetime");
|
|
6
|
+
var positionfilter_1 = require("../../models/position/positionfilter");
|
|
7
|
+
var operation_pb_1 = require("../../../fintekkers/requests/util/operation_pb");
|
|
8
|
+
//Requests
|
|
9
|
+
var query_position_request_pb_1 = require("../../../fintekkers/requests/position/query_position_request_pb");
|
|
10
|
+
var QueryPositionRequest = /** @class */ (function () {
|
|
11
|
+
function QueryPositionRequest(filter, positionType, positionView, fields, measures, asOf) {
|
|
12
|
+
this.filter = filter;
|
|
13
|
+
this.positionType = positionType;
|
|
14
|
+
this.positionView = positionView;
|
|
15
|
+
this.fields = fields;
|
|
16
|
+
this.measures = measures;
|
|
17
|
+
this.asOf = asOf;
|
|
18
|
+
}
|
|
19
|
+
QueryPositionRequest.fromAsOf = function (fields, measures, asOf) {
|
|
20
|
+
return new QueryPositionRequest(new positionfilter_1.PositionFilter(), position_pb_1.PositionTypeProto.TRANSACTION, position_pb_1.PositionViewProto.DEFAULT_VIEW, fields, measures, asOf);
|
|
21
|
+
};
|
|
22
|
+
QueryPositionRequest.from = function (fields, measures) {
|
|
23
|
+
return QueryPositionRequest.fromAsOf(fields, measures, datetime_1.ZonedDateTime.now());
|
|
24
|
+
};
|
|
25
|
+
QueryPositionRequest.prototype.toProto = function () {
|
|
26
|
+
var proto = new query_position_request_pb_1.QueryPositionRequestProto()
|
|
27
|
+
.setAsOf(this.asOf.toProto())
|
|
28
|
+
.setVersion("1.0.0")
|
|
29
|
+
.setPositionType(this.positionType)
|
|
30
|
+
.setPositionView(this.positionView)
|
|
31
|
+
.setFieldsList(this.fields)
|
|
32
|
+
.setMeasuresList(this.measures)
|
|
33
|
+
.setOperationType(operation_pb_1.RequestOperationTypeProto.SEARCH);
|
|
34
|
+
if (this.filter && this.filter.getFilters().length > 0)
|
|
35
|
+
proto.setFilterFields(this.filter.toProto());
|
|
36
|
+
return proto;
|
|
37
|
+
};
|
|
38
|
+
QueryPositionRequest.prototype.getFilter = function () {
|
|
39
|
+
return this.filter;
|
|
40
|
+
};
|
|
41
|
+
return QueryPositionRequest;
|
|
42
|
+
}());
|
|
43
|
+
exports.QueryPositionRequest = QueryPositionRequest;
|
|
44
|
+
//# sourceMappingURL=QueryPositionRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryPositionRequest.js","sourceRoot":"","sources":["QueryPositionRequest.ts"],"names":[],"mappings":";;;AAEA,+EAAuG;AAEvG,wDAA4D;AAC5D,uEAAsE;AACtE,+EAA2F;AAE3F,UAAU;AACV,6GAA4G;AAE5G;IAsBI,8BAAY,MAAsB,EAAE,YAA+B,EAAE,YAA+B,EAChG,MAAyB,EAAE,QAA6B,EAAE,IAAmB;QAC7E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,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field_pb";
|
|
3
|
+
import { PositionTypeProto, PositionViewProto } from "../../../fintekkers/models/position/position_pb";
|
|
4
|
+
import { MeasureProto } from "../../../fintekkers/models/position/measure_pb";
|
|
5
|
+
import { ZonedDateTime } from "../../models/utils/datetime";
|
|
6
|
+
import { PositionFilter } from "../../models/position/positionfilter";
|
|
7
|
+
import { RequestOperationTypeProto } from "../../../fintekkers/requests/util/operation_pb";
|
|
8
|
+
|
|
9
|
+
//Requests
|
|
10
|
+
import { QueryPositionRequestProto } from "../../../fintekkers/requests/position/query_position_request_pb";
|
|
11
|
+
|
|
12
|
+
export class QueryPositionRequest {
|
|
13
|
+
private filter: PositionFilter;
|
|
14
|
+
private positionType: PositionTypeProto;
|
|
15
|
+
private positionView: PositionViewProto;
|
|
16
|
+
private fields: Array<FieldProto>;
|
|
17
|
+
private measures: Array<MeasureProto>;
|
|
18
|
+
private asOf: ZonedDateTime;
|
|
19
|
+
|
|
20
|
+
static fromAsOf(fields: Array<FieldProto>, measures: Array<MeasureProto>, asOf: ZonedDateTime): QueryPositionRequest {
|
|
21
|
+
return new QueryPositionRequest(
|
|
22
|
+
new PositionFilter(),
|
|
23
|
+
PositionTypeProto.TRANSACTION,
|
|
24
|
+
PositionViewProto.DEFAULT_VIEW,
|
|
25
|
+
fields,
|
|
26
|
+
measures,
|
|
27
|
+
asOf);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static from(fields: Array<FieldProto>, measures: Array<MeasureProto>): QueryPositionRequest {
|
|
31
|
+
return QueryPositionRequest.fromAsOf(fields, measures, ZonedDateTime.now());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
constructor(filter: PositionFilter, positionType: PositionTypeProto, positionView: PositionViewProto,
|
|
35
|
+
fields: Array<FieldProto>, measures: Array<MeasureProto>, asOf: ZonedDateTime) {
|
|
36
|
+
this.filter = filter;
|
|
37
|
+
|
|
38
|
+
this.positionType = positionType;
|
|
39
|
+
this.positionView = positionView;
|
|
40
|
+
this.fields = fields;
|
|
41
|
+
this.measures = measures;
|
|
42
|
+
this.asOf = asOf;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public toProto(): QueryPositionRequestProto {
|
|
46
|
+
const proto = new QueryPositionRequestProto()
|
|
47
|
+
.setAsOf(this.asOf.toProto())
|
|
48
|
+
.setVersion("1.0.0")
|
|
49
|
+
.setPositionType(this.positionType)
|
|
50
|
+
.setPositionView(this.positionView)
|
|
51
|
+
.setFieldsList(this.fields)
|
|
52
|
+
.setMeasuresList(this.measures)
|
|
53
|
+
.setOperationType(RequestOperationTypeProto.SEARCH);
|
|
54
|
+
|
|
55
|
+
if (this.filter && this.filter.getFilters().length > 0)
|
|
56
|
+
proto.setFilterFields(this.filter.toProto())
|
|
57
|
+
|
|
58
|
+
return proto;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public getFilter(): PositionFilter {
|
|
62
|
+
return this.filter;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -67,7 +67,7 @@ test('test creating a portfolio against the api.fintekkers.org portfolio service
|
|
|
67
67
|
case 2:
|
|
68
68
|
createPortfolioResponse = _a.sent();
|
|
69
69
|
expect(createPortfolioResponse.getPortfolioResponseList().length).toBe(1);
|
|
70
|
-
return [4 /*yield*/, portfolioService.searchPortfolio(now.toProto(), new positionfilter_1.PositionFilter().addEqualsFilter(field_pb_1.FieldProto.PORTFOLIO_NAME, '
|
|
70
|
+
return [4 /*yield*/, portfolioService.searchPortfolio(now.toProto(), new positionfilter_1.PositionFilter().addEqualsFilter(field_pb_1.FieldProto.PORTFOLIO_NAME, 'TEST PORTFOLIO'))];
|
|
71
71
|
case 3:
|
|
72
72
|
searchResults = _a.sent();
|
|
73
73
|
expect(searchResults.length > 0).toBe(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio.test.js","sourceRoot":"","sources":["portfolio.test.ts"],"names":[],"mappings":";AAAA,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAC,eAAe,CAAC,qBAAU,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC,EAAA;;gBAAxJ,aAAa,GAAG,SAAwI;gBAC5J,MAAM,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;;;KAC7C,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -31,6 +31,6 @@ test('test creating a portfolio against the api.fintekkers.org portfolio service
|
|
|
31
31
|
var createPortfolioResponse: CreatePortfolioResponseProto = await portfolioService.createPortfolio(portfolio);
|
|
32
32
|
expect(createPortfolioResponse.getPortfolioResponseList().length).toBe(1);
|
|
33
33
|
|
|
34
|
-
var searchResults = await portfolioService.searchPortfolio(now.toProto(), new PositionFilter().addEqualsFilter(FieldProto.PORTFOLIO_NAME, '
|
|
34
|
+
var searchResults = await portfolioService.searchPortfolio(now.toProto(), new PositionFilter().addEqualsFilter(FieldProto.PORTFOLIO_NAME, 'TEST PORTFOLIO'));
|
|
35
35
|
expect(searchResults.length > 0).toBe(true);
|
|
36
36
|
}, 30000);
|