@fintekkers/ledger-models 0.1.72 → 0.1.75
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/.env +1 -1
- package/node/wrappers/models/position/field.js +27 -0
- package/node/wrappers/models/position/field.js.map +1 -0
- package/node/wrappers/models/position/field.test.js +63 -0
- package/node/wrappers/models/position/field.test.js.map +1 -0
- package/node/wrappers/models/position/field.test.ts +13 -0
- package/node/wrappers/models/position/field.ts +25 -0
- package/node/wrappers/models/position/position.js +7 -19
- package/node/wrappers/models/position/position.js.map +1 -1
- package/node/wrappers/models/position/position.test copy.js +107 -0
- package/node/wrappers/models/position/position.test copy.js.map +1 -0
- package/node/wrappers/models/position/position.test.js +32 -4
- package/node/wrappers/models/position/position.test.js.map +1 -1
- package/node/wrappers/models/position/position.test.ts +34 -19
- package/node/wrappers/models/position/position.ts +11 -38
- package/node/wrappers/models/utils/date.js +2 -2
- package/node/wrappers/models/utils/date.js.map +1 -1
- package/node/wrappers/models/utils/date.ts +2 -4
- 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 +54 -0
- package/node/wrappers/models/utils/protoEnum.js.map +1 -0
- package/node/wrappers/models/utils/protoEnum.test.js +25 -0
- package/node/wrappers/models/utils/protoEnum.test.js.map +1 -0
- package/node/wrappers/models/utils/protoEnum.test.ts +28 -0
- package/node/wrappers/models/utils/protoEnum.ts +59 -0
- package/node/wrappers/models/utils/serialization.js +9 -2
- package/node/wrappers/models/utils/serialization.js.map +1 -1
- package/node/wrappers/models/utils/serialization.ts +11 -9
- package/node/wrappers/services/portfolio-service/portfolio.test.js +0 -1
- package/node/wrappers/services/portfolio-service/portfolio.test.js.map +1 -1
- package/node/wrappers/services/portfolio-service/portfolio.test.ts +0 -1
- package/node/wrappers/services/position-service/PositionService.js +2 -2
- package/node/wrappers/services/position-service/PositionService.js.map +1 -1
- package/node/wrappers/services/position-service/PositionService.ts +1 -1
- package/node/wrappers/services/position-service/position.test.js +18 -63
- package/node/wrappers/services/position-service/position.test.js.map +1 -1
- package/node/wrappers/services/position-service/position.test.ts +8 -73
- package/node/wrappers/services/security-service/security.maturityLadder.test.js +0 -1
- package/node/wrappers/services/security-service/security.maturityLadder.test.js.map +1 -1
- package/node/wrappers/services/security-service/security.maturityLadder.test.ts +0 -2
- package/node/wrappers/services/transaction-service/transaction.search.test.js +0 -1
- package/node/wrappers/services/transaction-service/transaction.search.test.js.map +1 -1
- package/node/wrappers/services/transaction-service/transaction.search.test.ts +0 -2
- package/package.json +1 -1
|
@@ -26,14 +26,12 @@ class LocalDate {
|
|
|
26
26
|
|
|
27
27
|
static today(): LocalDate {
|
|
28
28
|
const today = new Date();
|
|
29
|
-
return
|
|
30
|
-
new LocalDateProto().setYear(today.getFullYear()).setMonth(today.getMonth()).setDay(today.getDate())
|
|
31
|
-
);
|
|
29
|
+
return this.from(today);
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
static from(date: Date): LocalDate {
|
|
35
33
|
return new LocalDate(
|
|
36
|
-
new LocalDateProto().setYear(date.getFullYear()).setMonth(date.getMonth()).setDay(date.getDate())
|
|
34
|
+
new LocalDateProto().setYear(date.getFullYear()).setMonth(date.getMonth() + 1).setDay(date.getDate())
|
|
37
35
|
);
|
|
38
36
|
}
|
|
39
37
|
}
|
|
@@ -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,I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tD,IAAM,SAAS,GAAG,IAAI,wBAAS,EAAE,CAAC;QAClC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC9B,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE1B,IAAM,cAAc,GAAG,IAAI,wCAAmB,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 };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProtoEnum = void 0;
|
|
4
|
+
var transaction_type_pb_1 = require("../../../fintekkers/models/transaction/transaction_type_pb");
|
|
5
|
+
var position_status_pb_1 = require("../../../fintekkers/models/position/position_status_pb");
|
|
6
|
+
var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
|
|
7
|
+
var ProtoEnum = /** @class */ (function () {
|
|
8
|
+
function ProtoEnum(enumDescriptor, enumValue) {
|
|
9
|
+
this.enumValue = enumValue;
|
|
10
|
+
this.enumDescriptor = enumDescriptor;
|
|
11
|
+
}
|
|
12
|
+
ProtoEnum.fromEnumName = function (enumName, enumValue) {
|
|
13
|
+
return new ProtoEnum(ProtoEnum.getFieldDescriptorFromName(enumName), enumValue);
|
|
14
|
+
};
|
|
15
|
+
ProtoEnum.getFieldDescriptorFromName = function (enumName) {
|
|
16
|
+
if (enumName === "TRANSACTION_TYPE") {
|
|
17
|
+
return transaction_type_pb_1.TransactionTypeProto;
|
|
18
|
+
}
|
|
19
|
+
if (enumName === "POSITION_STATUS") {
|
|
20
|
+
return position_status_pb_1.PositionStatusProto;
|
|
21
|
+
}
|
|
22
|
+
if (enumName === "FIELD") {
|
|
23
|
+
return field_pb_1.FieldProto;
|
|
24
|
+
}
|
|
25
|
+
throw new Error("Enum has not been mapped: ".concat(enumName));
|
|
26
|
+
};
|
|
27
|
+
ProtoEnum.prototype.getEnumDescriptor = function () {
|
|
28
|
+
return this.enumDescriptor;
|
|
29
|
+
};
|
|
30
|
+
ProtoEnum.prototype.getEnumName = function () {
|
|
31
|
+
// Assuming your enumDescriptor has a name property or similar
|
|
32
|
+
throw new Error("Not supported currently");
|
|
33
|
+
// return this.enumDescriptor.name;
|
|
34
|
+
};
|
|
35
|
+
ProtoEnum.prototype.getEnumValue = function () {
|
|
36
|
+
return this.enumValue;
|
|
37
|
+
};
|
|
38
|
+
ProtoEnum.prototype.getEnumValueName = function () {
|
|
39
|
+
var _this = this;
|
|
40
|
+
// In TypeScript/JS, enum values can be accessed directly if you know the value
|
|
41
|
+
// Assuming your enums are simple objects or as generated by protobuf ts
|
|
42
|
+
var enumKey = Object.keys(this.enumDescriptor).find(function (key) { return _this.enumDescriptor[key] === _this.enumValue; });
|
|
43
|
+
if (!enumKey) {
|
|
44
|
+
return 'UNKNOWN'; // Or handle as appropriate
|
|
45
|
+
}
|
|
46
|
+
return enumKey;
|
|
47
|
+
};
|
|
48
|
+
ProtoEnum.prototype.toString = function () {
|
|
49
|
+
return this.getEnumValueName();
|
|
50
|
+
};
|
|
51
|
+
return ProtoEnum;
|
|
52
|
+
}());
|
|
53
|
+
exports.ProtoEnum = ProtoEnum;
|
|
54
|
+
//# sourceMappingURL=protoEnum.js.map
|
|
@@ -0,0 +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,qCAAiB,GAAjB;QACI,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED,+BAAW,GAAX;QACI,8DAA8D;QAC9D,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC3C,oCAAoC;IACxC,CAAC;IAED,gCAAY,GAAZ;QACI,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,oCAAgB,GAAhB;QAAA,iBAQC;QAPG,+EAA+E;QAC/E,wEAAwE;QACxE,IAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,KAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,KAAI,CAAC,SAAS,EAA3C,CAA2C,CAAC,CAAC;QAC1G,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,SAAS,CAAC,CAAC,2BAA2B;QACjD,CAAC;QACD,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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ProtoEnum.test.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
var position_status_pb_1 = require("../../../fintekkers/models/position/position_status_pb");
|
|
5
|
+
var transaction_type_pb_1 = require("../../../fintekkers/models/transaction/transaction_type_pb");
|
|
6
|
+
var protoEnum_1 = require("./protoEnum");
|
|
7
|
+
describe('ProtoEnum', function () {
|
|
8
|
+
it('should correctly identify the name of the enum value for TransactionTypeProto', function () {
|
|
9
|
+
var protoEnum = new protoEnum_1.ProtoEnum(transaction_type_pb_1.TransactionTypeProto, 1);
|
|
10
|
+
expect(protoEnum.getEnumValueName()).toEqual('BUY');
|
|
11
|
+
});
|
|
12
|
+
it('should correctly return the enum value for PositionStatusProto', function () {
|
|
13
|
+
var protoEnum = new protoEnum_1.ProtoEnum(position_status_pb_1.PositionStatusProto.INTENDED, 2);
|
|
14
|
+
expect(protoEnum.getEnumValue()).toEqual(2);
|
|
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
|
+
});
|
|
20
|
+
it('should throw an error for an unmapped enum name', function () {
|
|
21
|
+
expect(function () { return protoEnum_1.ProtoEnum.fromEnumName('UNMAPPED_ENUM', 0); }).toThrow('Enum has not been mapped: UNMAPPED_ENUM');
|
|
22
|
+
});
|
|
23
|
+
// Add more tests as necessary to cover your use cases
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=protoEnum.test.js.map
|
|
@@ -0,0 +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,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+DAA+D,EAAE;QAChE,IAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,wCAAmB,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACjE,MAAM,CAAC,cAAM,OAAA,SAAS,CAAC,WAAW,EAAE,EAAvB,CAAuB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE;QAClD,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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// ProtoEnum.test.ts
|
|
2
|
+
|
|
3
|
+
import { PositionStatusProto } from '../../../fintekkers/models/position/position_status_pb';
|
|
4
|
+
import { TransactionTypeProto } from '../../../fintekkers/models/transaction/transaction_type_pb';
|
|
5
|
+
import { ProtoEnum } from './protoEnum';
|
|
6
|
+
|
|
7
|
+
describe('ProtoEnum', () => {
|
|
8
|
+
it('should correctly identify the name of the enum value for TransactionTypeProto', () => {
|
|
9
|
+
const protoEnum = new ProtoEnum(TransactionTypeProto, 1);
|
|
10
|
+
expect(protoEnum.getEnumValueName()).toEqual('BUY');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should correctly return the enum value for PositionStatusProto', () => {
|
|
14
|
+
const protoEnum = new ProtoEnum(PositionStatusProto.INTENDED, 2);
|
|
15
|
+
expect(protoEnum.getEnumValue()).toEqual(2);
|
|
16
|
+
});
|
|
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
|
+
|
|
23
|
+
it('should throw an error for an unmapped enum name', () => {
|
|
24
|
+
expect(() => ProtoEnum.fromEnumName('UNMAPPED_ENUM', 0)).toThrow('Enum has not been mapped: UNMAPPED_ENUM');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Add more tests as necessary to cover your use cases
|
|
28
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
import { TransactionTypeProto } from '../../../fintekkers/models/transaction/transaction_type_pb';
|
|
3
|
+
import { PositionStatusProto } from '../../../fintekkers/models/position/position_status_pb';
|
|
4
|
+
import { FieldProto } from '../../../fintekkers/models/position/field_pb';
|
|
5
|
+
|
|
6
|
+
export class ProtoEnum {
|
|
7
|
+
private enumValue: number;
|
|
8
|
+
private enumDescriptor: any; // Use appropriate type for enum descriptor
|
|
9
|
+
|
|
10
|
+
constructor(enumDescriptor: any, enumValue: number) {
|
|
11
|
+
this.enumValue = enumValue;
|
|
12
|
+
this.enumDescriptor = enumDescriptor;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static fromEnumName(enumName: string, enumValue: number): ProtoEnum {
|
|
16
|
+
return new ProtoEnum(ProtoEnum.getFieldDescriptorFromName(enumName), enumValue);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
private static getFieldDescriptorFromName(enumName: string): any {
|
|
20
|
+
if (enumName === "TRANSACTION_TYPE") {
|
|
21
|
+
return TransactionTypeProto;
|
|
22
|
+
}
|
|
23
|
+
if (enumName === "POSITION_STATUS") {
|
|
24
|
+
return PositionStatusProto;
|
|
25
|
+
}
|
|
26
|
+
if (enumName === "FIELD") {
|
|
27
|
+
return FieldProto;
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`Enum has not been mapped: ${enumName}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getEnumDescriptor(): string {
|
|
33
|
+
return this.enumDescriptor;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getEnumName(): Error {
|
|
37
|
+
// Assuming your enumDescriptor has a name property or similar
|
|
38
|
+
throw new Error("Not supported currently");
|
|
39
|
+
// return this.enumDescriptor.name;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getEnumValue(): number {
|
|
43
|
+
return this.enumValue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
getEnumValueName(): string {
|
|
47
|
+
// In TypeScript/JS, enum values can be accessed directly if you know the value
|
|
48
|
+
// Assuming your enums are simple objects or as generated by protobuf ts
|
|
49
|
+
const enumKey = Object.keys(this.enumDescriptor).find(key => this.enumDescriptor[key] === this.enumValue);
|
|
50
|
+
if (!enumKey) {
|
|
51
|
+
return 'UNKNOWN'; // Or handle as appropriate
|
|
52
|
+
}
|
|
53
|
+
return enumKey;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
toString(): string {
|
|
57
|
+
return this.getEnumValueName();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -7,6 +7,7 @@ var local_timestamp_pb_1 = require("../../../fintekkers/models/util/local_timest
|
|
|
7
7
|
var uuid_pb_1 = require("../../../fintekkers/models/util/uuid_pb");
|
|
8
8
|
var datetime_1 = require("./datetime");
|
|
9
9
|
var uuid_1 = require("./uuid");
|
|
10
|
+
var wrappers_pb_1 = require("google-protobuf/google/protobuf/wrappers_pb");
|
|
10
11
|
var ProtoSerializationUtil = /** @class */ (function () {
|
|
11
12
|
function ProtoSerializationUtil() {
|
|
12
13
|
}
|
|
@@ -17,7 +18,7 @@ var ProtoSerializationUtil = /** @class */ (function () {
|
|
|
17
18
|
if (obj instanceof Date) {
|
|
18
19
|
return new local_date_pb_1.LocalDateProto()
|
|
19
20
|
.setYear(obj.getFullYear())
|
|
20
|
-
.setMonth(obj.getMonth())
|
|
21
|
+
.setMonth(obj.getMonth() + 1)
|
|
21
22
|
.setDay(obj.getDate());
|
|
22
23
|
}
|
|
23
24
|
if (obj instanceof datetime_1.ZonedDateTime) {
|
|
@@ -26,6 +27,9 @@ var ProtoSerializationUtil = /** @class */ (function () {
|
|
|
26
27
|
if (typeof obj === "number") {
|
|
27
28
|
return new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue(obj.toString());
|
|
28
29
|
}
|
|
30
|
+
if (obj instanceof String) {
|
|
31
|
+
return wrappers_pb_1.StringValue.of(obj);
|
|
32
|
+
}
|
|
29
33
|
throw new Error("Could not serialize object of type ".concat(typeof obj, ". Value: ").concat(obj));
|
|
30
34
|
};
|
|
31
35
|
ProtoSerializationUtil.deserialize = function (obj) {
|
|
@@ -33,7 +37,7 @@ var ProtoSerializationUtil = /** @class */ (function () {
|
|
|
33
37
|
return uuid_1.UUID.fromU8Array(obj.getRawUuid_asU8());
|
|
34
38
|
}
|
|
35
39
|
if (obj instanceof local_date_pb_1.LocalDateProto) {
|
|
36
|
-
var date = new Date(obj.getYear(), obj.getMonth(), obj.getDay());
|
|
40
|
+
var date = new Date(obj.getYear(), obj.getMonth() - 1, obj.getDay());
|
|
37
41
|
date.setHours(0, 0, 0, 0);
|
|
38
42
|
return date;
|
|
39
43
|
}
|
|
@@ -46,6 +50,9 @@ var ProtoSerializationUtil = /** @class */ (function () {
|
|
|
46
50
|
if (obj instanceof decimal_value_pb_1.DecimalValueProto) {
|
|
47
51
|
return parseFloat(obj.getArbitraryPrecisionValue());
|
|
48
52
|
}
|
|
53
|
+
if (obj instanceof wrappers_pb_1.StringValue) {
|
|
54
|
+
return obj.toString();
|
|
55
|
+
}
|
|
49
56
|
throw new Error("Could not deserialize object of type ".concat(typeof obj, ". Value: ").concat(obj));
|
|
50
57
|
};
|
|
51
58
|
return ProtoSerializationUtil;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["serialization.ts"],"names":[],"mappings":";;;AAAA,qFAAqF;AACrF,+EA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G,CAAC,eAAe,EAAE,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,GAAG,YAAY,8BAAc,EAAE,CAAC;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"}
|
|
@@ -4,21 +4,17 @@ import { LocalTimestampProto } from "../../../fintekkers/models/util/local_times
|
|
|
4
4
|
import { UUIDProto } from "../../../fintekkers/models/util/uuid_pb";
|
|
5
5
|
import { ZonedDateTime } from "./datetime";
|
|
6
6
|
import { UUID } from "./uuid";
|
|
7
|
-
|
|
8
|
-
interface EnumValueDescriptor {
|
|
9
|
-
name: string;
|
|
10
|
-
values_by_number: { [key: number]: { name: string } };
|
|
11
|
-
}
|
|
7
|
+
import { StringValue } from 'google-protobuf/google/protobuf/wrappers_pb';
|
|
12
8
|
|
|
13
9
|
export class ProtoSerializationUtil {
|
|
14
|
-
static serialize(obj: any):
|
|
10
|
+
static serialize(obj: any) { //}: UUIDProto | LocalDateProto | LocalTimestampProto | DecimalValueProto | StringValue {
|
|
15
11
|
if (obj instanceof UUID) {
|
|
16
12
|
return obj.toUUIDProto();
|
|
17
13
|
}
|
|
18
14
|
if (obj instanceof Date) {
|
|
19
15
|
return new LocalDateProto()
|
|
20
16
|
.setYear(obj.getFullYear())
|
|
21
|
-
.setMonth(obj.getMonth())
|
|
17
|
+
.setMonth(obj.getMonth() + 1)
|
|
22
18
|
.setDay(obj.getDate());
|
|
23
19
|
}
|
|
24
20
|
if (obj instanceof ZonedDateTime) {
|
|
@@ -27,16 +23,19 @@ export class ProtoSerializationUtil {
|
|
|
27
23
|
if (typeof obj === "number") {
|
|
28
24
|
return new DecimalValueProto().setArbitraryPrecisionValue(obj.toString());
|
|
29
25
|
}
|
|
26
|
+
if (obj instanceof String) {
|
|
27
|
+
return StringValue.of(obj);
|
|
28
|
+
}
|
|
30
29
|
|
|
31
30
|
throw new Error(`Could not serialize object of type ${typeof obj}. Value: ${obj}`);
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
static deserialize(obj: any):
|
|
33
|
+
static deserialize(obj: any) { //}: UUID | Date | ZonedDateTime | number | string {
|
|
35
34
|
if (obj instanceof UUIDProto) {
|
|
36
35
|
return UUID.fromU8Array(obj.getRawUuid_asU8());
|
|
37
36
|
}
|
|
38
37
|
if (obj instanceof LocalDateProto) {
|
|
39
|
-
const date = new Date(obj.getYear(), obj.getMonth(), obj.getDay());
|
|
38
|
+
const date = new Date(obj.getYear(), obj.getMonth() - 1, obj.getDay());
|
|
40
39
|
date.setHours(0, 0, 0, 0);
|
|
41
40
|
return date;
|
|
42
41
|
}
|
|
@@ -49,6 +48,9 @@ export class ProtoSerializationUtil {
|
|
|
49
48
|
if (obj instanceof DecimalValueProto) {
|
|
50
49
|
return parseFloat(obj.getArbitraryPrecisionValue());
|
|
51
50
|
}
|
|
51
|
+
if (obj instanceof StringValue) {
|
|
52
|
+
return obj.toString();
|
|
53
|
+
}
|
|
52
54
|
|
|
53
55
|
throw new Error(`Could not deserialize object of type ${typeof obj}. Value: ${obj}`);
|
|
54
56
|
}
|
|
@@ -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;AAEnF,uEAAsE;AAGtE,IAAI,CAAC,4EAA4E,EAAE;;;;;gBAC3E,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;gBAC5C,GAAG,GAAG,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC;gBAE7B,gBAAgB,GAAG,IAAI,mCAAgB,EAAE,CAAC;gBAE1C,SAAS,GAAG,IAAI,6BAAc,EAAE,CAAC;gBACvC,SAAS,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;gBACtC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBAC9B,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC5B,SAAS,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;gBAC7C,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;gBAET,qBAAM,gBAAgB,CAAC,uBAAuB,CAAC,SAAS,CAAC,EAAA;;gBAA7E,iBAAiB,GAAG,SAAyD;gBACjF,MAAM,CAAC,iBAAiB,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,C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C,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;gBAET,qBAAM,gBAAgB,CAAC,uBAAuB,CAAC,SAAS,CAAC,EAAA;;gBAA7E,iBAAiB,GAAG,SAAyD;gBACjF,MAAM,CAAC,iBAAiB,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAEG,qBAAM,gBAAgB,CAAC,eAAe,CAAC,SAAS,CAAC,EAAA;;gBAAzG,uBAAuB,GAAiC,SAAiD;gBAC7G,MAAM,CAAC,uBAAuB,CAAC,wBAAwB,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAEtD,qBAAM,gBAAgB,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,IAAI,+BAAc,EAAE,CAAC,eAAe,CAAC,qBAAU,CAAC,cAAc,EAAE,+BAA+B,CAAC,CAAC,EAAA;;gBAAvK,aAAa,GAAG,SAAuJ;gBAC3K,MAAM,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;;;KAC7C,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -33,5 +33,4 @@ test('test creating a portfolio against the api.fintekkers.org portfolio service
|
|
|
33
33
|
|
|
34
34
|
var searchResults = await portfolioService.searchPortfolio(now.toProto(), new PositionFilter().addEqualsFilter(FieldProto.PORTFOLIO_NAME, 'Federal Reserve SOMA Holdings'));
|
|
35
35
|
expect(searchResults.length > 0).toBe(true);
|
|
36
|
-
console.log(searchResults[0].getPortfolioName());
|
|
37
36
|
}, 30000);
|
|
@@ -38,7 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.PositionService = void 0;
|
|
40
40
|
// Models
|
|
41
|
-
var
|
|
41
|
+
var position_1 = require("../../models/position/position");
|
|
42
42
|
// Requests & Services
|
|
43
43
|
var position_service_grpc_pb_1 = require("../../../fintekkers/services/position-service/position_service_grpc_pb");
|
|
44
44
|
//Utils
|
|
@@ -57,7 +57,7 @@ var PositionService = /** @class */ (function () {
|
|
|
57
57
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
58
58
|
stream2.on('data', function (response) {
|
|
59
59
|
response.getPositionsList().forEach(function (position) {
|
|
60
|
-
listPositions.push(new
|
|
60
|
+
listPositions.push(new position_1.Position(position));
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
63
|
stream2.on('end', function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PositionService.js","sourceRoot":"","sources":["PositionService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS;AACT
|
|
1
|
+
{"version":3,"file":"PositionService.js","sourceRoot":"","sources":["PositionService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS;AACT,2DAA0D;AAM1D,sBAAsB;AACtB,mHAAwG;AAExG,OAAO;AACP,oEAA0D;AAE1D;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,OAAkC;;YAI7C,SAAe,0BAA0B;;;;wBACjC,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;wBAE1C,sBAAO,IAAI,OAAO,CAAa,UAAC,OAAO,EAAE,MAAM;gCAC7C,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,UAAC,QAAoC;oCACtD,QAAQ,CAAC,gBAAgB,EAAE,CAAC,OAAO,CAAC,UAAC,QAAQ;wCAC3C,aAAa,CAAC,IAAI,CAAC,IAAI,mBAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;oCAC7C,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,GAAe,EAAE,CAAC;wBAuB9B,qBAAM,0BAA0B,EAAE,EAAA;4BAAzC,sBAAO,SAAkC,EAAC;;;;KAC3C;IACH,sBAAC;AAAD,CAAC,AAlCD,IAkCC;AAEQ,0CAAe"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Models
|
|
3
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -37,76 +36,30 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
36
|
}
|
|
38
37
|
};
|
|
39
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
|
|
39
|
+
// Models
|
|
41
40
|
var position_pb_1 = require("../../../fintekkers/models/position/position_pb");
|
|
42
41
|
var measure_pb_1 = require("../../../fintekkers/models/position/measure_pb");
|
|
43
|
-
var position_filter_pb_1 = require("../../../fintekkers/models/position/position_filter_pb");
|
|
44
42
|
// Model Utils
|
|
45
43
|
var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
|
|
46
|
-
var position_util_pb_1 = require("../../../fintekkers/models/position/position_util_pb");
|
|
47
44
|
var datetime_1 = require("../../models/utils/datetime");
|
|
48
|
-
var serialization_util_1 = require("../../models/utils/serialization.util");
|
|
49
|
-
var any_pb_1 = require("google-protobuf/google/protobuf/any_pb");
|
|
50
45
|
//Requests & Services
|
|
51
46
|
var PositionService_1 = require("../../services/position-service/PositionService");
|
|
52
47
|
var query_position_request_pb_1 = require("../../../fintekkers/requests/position/query_position_request_pb");
|
|
53
48
|
test('test getting a position against the api.fintekkers.org position service', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
+
var isTrue;
|
|
54
50
|
return __generator(this, function (_a) {
|
|
55
|
-
|
|
51
|
+
switch (_a.label) {
|
|
52
|
+
case 0: return [4 /*yield*/, testPosition()];
|
|
53
|
+
case 1:
|
|
54
|
+
isTrue = _a.sent();
|
|
55
|
+
expect(isTrue).toBe(true);
|
|
56
|
+
return [2 /*return*/];
|
|
57
|
+
}
|
|
56
58
|
});
|
|
57
59
|
}); }, 30000);
|
|
58
|
-
function get_position(security, portfolio, measures, position_type, fields, additional_filters, as_of) {
|
|
59
|
-
if (fields === void 0) { fields = [field_pb_1.FieldProto.PORTFOLIO, field_pb_1.FieldProto.SECURITY]; }
|
|
60
|
-
if (additional_filters === void 0) { additional_filters = []; }
|
|
61
|
-
if (as_of === void 0) { as_of = datetime_1.ZonedDateTime.now(); }
|
|
62
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
-
var filters, id_proto, security_id_packed, fieldMapEntry, fieldMapEntry, filter_fields, as_of_proto, request, position_service, positions;
|
|
64
|
-
return __generator(this, function (_a) {
|
|
65
|
-
switch (_a.label) {
|
|
66
|
-
case 0:
|
|
67
|
-
filters = [];
|
|
68
|
-
if (security !== null && security !== undefined) {
|
|
69
|
-
id_proto = new identifier_pb_1.IdentifierProto();
|
|
70
|
-
id_proto.setIdentifierValue(security.getIdentifier().getIdentifierValue());
|
|
71
|
-
id_proto.setIdentifierType(security.getIdentifier().getIdentifierType());
|
|
72
|
-
security_id_packed = new any_pb_1.Any();
|
|
73
|
-
security_id_packed.pack(id_proto);
|
|
74
|
-
fieldMapEntry = new position_util_pb_1.FieldMapEntry();
|
|
75
|
-
fieldMapEntry.setField(field_pb_1.FieldProto.IDENTIFIER);
|
|
76
|
-
fieldMapEntry.setFieldValuePacked(security_id_packed);
|
|
77
|
-
filters.push(fieldMapEntry);
|
|
78
|
-
}
|
|
79
|
-
if (portfolio !== null && portfolio !== undefined) {
|
|
80
|
-
fieldMapEntry = new position_util_pb_1.FieldMapEntry();
|
|
81
|
-
fieldMapEntry.setField(field_pb_1.FieldProto.PORTFOLIO_NAME);
|
|
82
|
-
fieldMapEntry.setFieldValuePacked((0, serialization_util_1.pack)(portfolio.getPortfolioName()));
|
|
83
|
-
filters.push(fieldMapEntry);
|
|
84
|
-
}
|
|
85
|
-
if (additional_filters !== null && additional_filters.length > 0) {
|
|
86
|
-
filters.push.apply(filters, additional_filters);
|
|
87
|
-
}
|
|
88
|
-
filter_fields = new position_filter_pb_1.PositionFilterProto();
|
|
89
|
-
filter_fields.setFiltersList(filters);
|
|
90
|
-
as_of_proto = as_of.toProto();
|
|
91
|
-
request = new query_position_request_pb_1.QueryPositionRequestProto();
|
|
92
|
-
request.setPositionType(position_type);
|
|
93
|
-
request.setPositionView(position_pb_1.PositionViewProto.DEFAULT_VIEW);
|
|
94
|
-
request.setFieldsList(fields);
|
|
95
|
-
request.setMeasuresList(measures);
|
|
96
|
-
request.setFilterFields(filter_fields);
|
|
97
|
-
request.setAsOf(as_of_proto);
|
|
98
|
-
position_service = new PositionService_1.PositionService();
|
|
99
|
-
return [4 /*yield*/, position_service.search(request)];
|
|
100
|
-
case 1:
|
|
101
|
-
positions = _a.sent();
|
|
102
|
-
return [2 /*return*/, positions];
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
60
|
function testPosition() {
|
|
108
61
|
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
-
var fields, measures, request, positions,
|
|
62
|
+
var fields, measures, request, positions, position_1;
|
|
110
63
|
return __generator(this, function (_a) {
|
|
111
64
|
switch (_a.label) {
|
|
112
65
|
case 0:
|
|
@@ -121,16 +74,18 @@ function testPosition() {
|
|
|
121
74
|
return [4 /*yield*/, new PositionService_1.PositionService().search(request)];
|
|
122
75
|
case 1:
|
|
123
76
|
positions = _a.sent();
|
|
124
|
-
if (positions) {
|
|
77
|
+
if (positions && positions.length > 0) {
|
|
125
78
|
console.log(positions.length + " positions returned");
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
79
|
+
position_1 = positions[0];
|
|
80
|
+
fields.forEach(function (field) {
|
|
81
|
+
position_1.getFieldValue(field);
|
|
82
|
+
});
|
|
83
|
+
return [2 /*return*/, true];
|
|
129
84
|
}
|
|
130
85
|
else {
|
|
131
|
-
|
|
86
|
+
return [2 /*return*/, false];
|
|
132
87
|
}
|
|
133
|
-
return [2 /*return
|
|
88
|
+
return [2 /*return*/];
|
|
134
89
|
}
|
|
135
90
|
});
|
|
136
91
|
});
|