@fintekkers/ledger-models 0.1.59 → 0.1.61
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 -13
- package/index.js.map +1 -1
- package/index.ts +1 -18
- 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/wrappers/models/security/security.js +21 -18
- package/node/wrappers/models/security/security.js.map +1 -1
- package/node/wrappers/models/security/security.ts +22 -18
- package/node/wrappers/models/transaction/transaction.js +111 -0
- package/node/wrappers/models/transaction/transaction.js.map +1 -0
- 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 +37 -0
- package/node/wrappers/models/transaction/transaction.ts +139 -0
- package/node/wrappers/models/transaction/transaction_type.js +45 -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/serialization.test.js +14 -54
- package/node/wrappers/models/utils/serialization.test.js.map +1 -1
- package/node/wrappers/models/utils/serialization.test.ts +11 -7
- package/node/wrappers/services/portfolio-service/PortfolioService.js +6 -7
- package/node/wrappers/services/portfolio-service/PortfolioService.js.map +1 -1
- package/node/wrappers/services/portfolio-service/PortfolioService.ts +8 -8
- package/node/wrappers/{portfolio.test.js → services/portfolio-service/portfolio.test.js} +10 -9
- package/node/wrappers/services/portfolio-service/portfolio.test.js.map +1 -0
- package/node/wrappers/{portfolio.test.ts → services/portfolio-service/portfolio.test.ts} +15 -11
- package/node/wrappers/services/position-service/PositionService.js +2 -5
- package/node/wrappers/services/position-service/PositionService.js.map +1 -1
- package/node/wrappers/services/position-service/PositionService.ts +4 -7
- package/node/wrappers/{position.test.js → services/position-service/position.test.js} +17 -20
- package/node/wrappers/services/position-service/position.test.js.map +1 -0
- package/node/wrappers/{position.test.ts → services/position-service/position.test.ts} +21 -28
- package/node/wrappers/services/security-service/SecurityService.js +2 -5
- package/node/wrappers/services/security-service/SecurityService.js.map +1 -1
- package/node/wrappers/services/security-service/SecurityService.ts +2 -5
- package/node/wrappers/{security.test.js → services/security-service/security.test.js} +15 -16
- package/node/wrappers/services/security-service/security.test.js.map +1 -0
- package/node/wrappers/{security.test.ts → services/security-service/security.test.ts} +19 -17
- package/node/wrappers/services/transaction-service/TransactionService.js +143 -0
- package/node/wrappers/services/transaction-service/TransactionService.js.map +1 -0
- package/node/wrappers/services/transaction-service/TransactionService.ts +96 -0
- package/node/wrappers/services/transaction-service/transaction.test.js +116 -0
- package/node/wrappers/services/transaction-service/transaction.test.js.map +1 -0
- package/node/wrappers/services/transaction-service/transaction.test.ts +87 -0
- package/package.json +4 -2
- package/node/wrappers/portfolio.test.js.map +0 -1
- package/node/wrappers/position.test.js.map +0 -1
- package/node/wrappers/security.test.js.map +0 -1
|
@@ -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,aAAa,EAAE,CAAC,CAAC;oBAEf,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,aAAa,EAAE,EAAE,qBAAU,CAAC,cAAc,EAAE,+BAA+B,CAAC,EAAA;;oBAAvI,aAAa,GAAG,SAAuH;oBAE3I,sBAAO,IAAI,EAAC;;;;CACb;AApBD,sCAoBC"}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
// Models
|
|
2
2
|
|
|
3
3
|
// Model Utils
|
|
4
|
-
import { FieldProto } from '
|
|
5
|
-
import * as uuid from '
|
|
6
|
-
import * as dt from '
|
|
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
7
|
|
|
8
8
|
//Requests & Services
|
|
9
|
-
import { PortfolioService } from './
|
|
10
|
-
import { PortfolioProto } from '
|
|
11
|
-
import { CreatePortfolioResponseProto } from '
|
|
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
12
|
|
|
13
|
-
|
|
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> {
|
|
14
20
|
const id_proto = uuid.UUID.random().toUUIDProto();
|
|
15
21
|
const now = dt.ZonedDateTime.now();
|
|
16
22
|
|
|
@@ -24,13 +30,11 @@ async function testPortfolio(): Promise<void> {
|
|
|
24
30
|
portfolio.setAsOf(now.to_date_proto());
|
|
25
31
|
|
|
26
32
|
var validationSummary = await portfolioService.validateCreatePortfolio(portfolio);
|
|
27
|
-
console.log(validationSummary);
|
|
28
33
|
|
|
29
34
|
var createPortfolioResponse:CreatePortfolioResponseProto = await portfolioService.createPortfolio(portfolio);
|
|
30
|
-
console.log(createPortfolioResponse);
|
|
31
35
|
|
|
32
36
|
var searchResults = await portfolioService.searchPortfolio(now.to_date_proto(), FieldProto.PORTFOLIO_NAME, 'Federal Reserve SOMA Holdings');
|
|
33
|
-
|
|
37
|
+
|
|
38
|
+
return true;
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
export { testPortfolio };
|
|
@@ -42,8 +42,8 @@ var grpc = require("@grpc/grpc-js");
|
|
|
42
42
|
var position_service_grpc_pb_1 = require("../../../fintekkers/services/position-service/position_service_grpc_pb");
|
|
43
43
|
var PositionService = /** @class */ (function () {
|
|
44
44
|
function PositionService() {
|
|
45
|
-
|
|
46
|
-
this.client = new
|
|
45
|
+
this.client = new position_service_grpc_pb_1.PositionClient('api.fintekkers.org:8082', grpc.credentials.createSsl());
|
|
46
|
+
// this.client = new PositionClient('localhost:8082', grpc.credentials.createInsecure());
|
|
47
47
|
}
|
|
48
48
|
PositionService.prototype.search = function (request) {
|
|
49
49
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -54,14 +54,11 @@ var PositionService = /** @class */ (function () {
|
|
|
54
54
|
stream2 = tmpClient.search(request);
|
|
55
55
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
56
56
|
stream2.on('data', function (response) {
|
|
57
|
-
console.log('Result of the position search call');
|
|
58
|
-
console.log('Response:', response);
|
|
59
57
|
response.getPositionsList().forEach(function (position) {
|
|
60
58
|
listPositions.push(position);
|
|
61
59
|
});
|
|
62
60
|
});
|
|
63
61
|
stream2.on('end', function () {
|
|
64
|
-
console.log('Stream ended.');
|
|
65
62
|
resolve(listPositions);
|
|
66
63
|
});
|
|
67
64
|
stream2.on('error', function (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PositionService.js","sourceRoot":"","sources":["PositionService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAsC;AAgBtC,sBAAsB;AACtB,mHAAwG;AAUxG;IAGE;QACE,
|
|
1
|
+
{"version":3,"file":"PositionService.js","sourceRoot":"","sources":["PositionService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAsC;AAgBtC,sBAAsB;AACtB,mHAAwG;AAUxG;IAGE;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,yCAAc,CAAC,yBAAyB,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC;QAC1F,yFAAyF;IAC3F,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,AAnCD,IAmCC;AAEQ,0CAAe"}
|
|
@@ -7,8 +7,8 @@ import { createFieldMapEntry } from '../../models/utils/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
|
|
|
10
|
-
import { ZonedDateTime } from '
|
|
11
|
-
import { packStringIntoAny } from '
|
|
10
|
+
import { ZonedDateTime } from '../../models/utils/datetime';
|
|
11
|
+
import { packStringIntoAny } from '../../models/utils/util';
|
|
12
12
|
|
|
13
13
|
// Model Utils
|
|
14
14
|
import { PositionFilterProto } from '../../../fintekkers/models/position/position_filter_pb';
|
|
@@ -29,8 +29,8 @@ class PositionService {
|
|
|
29
29
|
private client: PositionClient;
|
|
30
30
|
|
|
31
31
|
constructor() {
|
|
32
|
-
|
|
33
|
-
this.client = new PositionClient('localhost:8082', grpc.credentials.createInsecure());
|
|
32
|
+
this.client = new PositionClient('api.fintekkers.org:8082', grpc.credentials.createSsl());
|
|
33
|
+
// this.client = new PositionClient('localhost:8082', grpc.credentials.createInsecure());
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
async search(request:QueryPositionRequestProto) {
|
|
@@ -42,15 +42,12 @@ class PositionService {
|
|
|
42
42
|
|
|
43
43
|
return new Promise<PositionProto[]>((resolve, reject) => {
|
|
44
44
|
stream2.on('data', (response:QueryPositionResponseProto) => {
|
|
45
|
-
console.log('Result of the position search call');
|
|
46
|
-
console.log('Response:', response);
|
|
47
45
|
response.getPositionsList().forEach((position) => {
|
|
48
46
|
listPositions.push(position);
|
|
49
47
|
});
|
|
50
48
|
});
|
|
51
49
|
|
|
52
50
|
stream2.on('end', () => {
|
|
53
|
-
console.log('Stream ended.');
|
|
54
51
|
resolve(listPositions);
|
|
55
52
|
});
|
|
56
53
|
|
|
@@ -37,23 +37,24 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
|
|
40
|
+
var identifier_pb_1 = require("../../../fintekkers/models/security/identifier/identifier_pb");
|
|
41
|
+
var position_pb_1 = require("../../../fintekkers/models/position/position_pb");
|
|
42
|
+
var measure_pb_1 = require("../../../fintekkers/models/position/measure_pb");
|
|
41
43
|
// Model Utils
|
|
42
|
-
var field_pb_1 = require("
|
|
43
|
-
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
var position_pb_1 = require("../fintekkers/models/position/position_pb");
|
|
48
|
-
var query_position_request_pb_1 = require("../fintekkers/requests/position/query_position_request_pb");
|
|
49
|
-
var identifier_pb_1 = require("../fintekkers/models/security/identifier/identifier_pb");
|
|
44
|
+
var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
|
|
45
|
+
var position_util_pb_1 = require("../../../fintekkers/models/position/position_util_pb");
|
|
46
|
+
var position_filter_pb_1 = require("../../../fintekkers/models/position/position_filter_pb");
|
|
47
|
+
var datetime_1 = require("../../models/utils/datetime");
|
|
48
|
+
var util_1 = require("../../models/utils/util");
|
|
50
49
|
var any_pb_1 = require("google-protobuf/google/protobuf/any_pb");
|
|
51
|
-
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
//Requests & Services
|
|
51
|
+
var PortfolioService_1 = require("../../services/portfolio-service/PortfolioService");
|
|
52
|
+
var PositionService_1 = require("../../services/position-service/PositionService");
|
|
53
|
+
var query_position_request_pb_1 = require("../../../fintekkers/requests/position/query_position_request_pb");
|
|
54
|
+
test('test getting a position against the api.fintekkers.org position service', function () {
|
|
55
|
+
var isTrue = testPosition();
|
|
56
|
+
expect(isTrue).resolves.toBe(true);
|
|
57
|
+
}, 30000);
|
|
57
58
|
function get_position(security, portfolio, measures, position_type, fields, additional_filters, as_of) {
|
|
58
59
|
if (fields === void 0) { fields = [field_pb_1.FieldProto.PORTFOLIO, field_pb_1.FieldProto.SECURITY]; }
|
|
59
60
|
if (additional_filters === void 0) { additional_filters = []; }
|
|
@@ -118,13 +119,9 @@ function testPosition() {
|
|
|
118
119
|
return [4 /*yield*/, get_position(null, fedReservePortfolio, [measure_pb_1.MeasureProto.DIRECTED_QUANTITY], position_pb_1.PositionTypeProto.TRANSACTION, [field_pb_1.FieldProto.PORTFOLIO_NAME, field_pb_1.FieldProto.SECURITY_ID], [], now)];
|
|
119
120
|
case 2:
|
|
120
121
|
positions = _a.sent();
|
|
121
|
-
|
|
122
|
-
positions[0].getMeasuresList().forEach(function (measure) { console.log(measure); });
|
|
123
|
-
console.log(positions);
|
|
124
|
-
return [2 /*return*/];
|
|
122
|
+
return [2 /*return*/, true];
|
|
125
123
|
}
|
|
126
124
|
});
|
|
127
125
|
});
|
|
128
126
|
}
|
|
129
|
-
exports.testPosition = testPosition;
|
|
130
127
|
//# sourceMappingURL=position.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position.test.js","sourceRoot":"","sources":["position.test.ts"],"names":[],"mappings":";AAAA,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAET,8FAA+F;AAC/F,+EAAuG;AAEvG,6EAA8E;AAG9E,cAAc;AACd,yEAA0E;AAC1E,yFAAqF;AACrF,6FAA6F;AAC7F,wDAA4D;AAE5D,gDAA4D;AAC5D,iEAA6D;AAE7D,qBAAqB;AACrB,sFAAqF;AACrF,mFAAkF;AAClF,6GAA4G;AAE5G,IAAI,CAAC,yEAAyE,EAAE;IAC9E,IAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC,EAAE,KAAK,CAAC,CAAC;AAEV,SAAe,YAAY,CAAC,QAAsB,EACtC,SAAwB,EACxB,QAAuB,EACvB,aAA+B,EAC/B,MAAoD,EACpD,kBAAuB,EAAE,KAA2B;IADpD,uBAAA,EAAA,UAAU,qBAAU,CAAC,SAAS,EAAE,qBAAU,CAAC,QAAQ,CAAC;IACpD,mCAAA,EAAA,uBAAuB;IAAE,sBAAA,EAAA,QAAQ,wBAAa,CAAC,GAAG,EAAE;;;;;;oBACtD,OAAO,GAAG,EAAE,CAAC;oBAEnB,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,EAAE;wBACvC,QAAQ,GAAG,IAAI,+BAAe,EAAE,CAAC;wBACvC,QAAQ,CAAC,kBAAkB,CAAC,QAAQ,CAAC,aAAa,E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;oBACxD,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;oBAC9B,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;oBAClC,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;oBACvC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;oBAEzB,gBAAgB,GAAG,IAAI,iCAAe,EAAE,CAAC;oBAE3B,qBAAM,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAA;;oBAAlD,SAAS,GAAG,SAAsC;oBAExD,sBAAO,SAAS,EAAC;;;;CACpB;AAED,SAAe,YAAY;;;;;;oBAEnB,GAAG,GAAG,wBAAa,CAAC,GAAG,EAAE,CAAC;oBAE1B,gBAAgB,GAAG,IAAI,mCAAgB,EAAE,CAAC;oBAE/B,qBAAM,gBAAgB,CAAC,eAAe,CACjD,GAAG,CAAC,aAAa,EAAE,EACnB,qBAAU,CAAC,cAAc,EACzB,+BAA+B,CAAC,EAAA;;oBAHlC,UAAU,GAAG,SAGqB;oBAChC,mBAAmB,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;oBAE1B,qBAAM,YAAY,CAAC,IAAI,EAAE,mBAAmB,EAC1D,CAAC,yBAAY,CAAC,iBAAiB,CAAC,EAChC,+BAAiB,CAAC,WAAW,EAC7B,CAAC,qBAAU,CAAC,cAAc,EAAE,qBAAU,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAA;;oBAH3D,SAAS,GAAG,SAG+C;oBAE/D,sBAAO,IAAI,EAAC;;;;CACb"}
|
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
// Models
|
|
2
2
|
|
|
3
|
+
import { IdentifierProto } from '../../../fintekkers/models/security/identifier/identifier_pb';
|
|
4
|
+
import { PositionTypeProto, PositionViewProto } from '../../../fintekkers/models/position/position_pb';
|
|
5
|
+
import { SecurityProto } from '../../../fintekkers/models/security/security_pb';
|
|
6
|
+
import { MeasureProto } from '../../../fintekkers/models/position/measure_pb';
|
|
7
|
+
import { PortfolioProto } from '../../../fintekkers/models/portfolio/portfolio_pb';
|
|
8
|
+
|
|
3
9
|
// Model Utils
|
|
4
|
-
import { FieldProto } from '
|
|
5
|
-
import
|
|
6
|
-
import
|
|
10
|
+
import { FieldProto } from '../../../fintekkers/models/position/field_pb';
|
|
11
|
+
import { FieldMapEntry } from '../../../fintekkers/models/position/position_util_pb';
|
|
12
|
+
import { PositionFilterProto } from '../../../fintekkers/models/position/position_filter_pb';
|
|
13
|
+
import { ZonedDateTime } from '../../models/utils/datetime';
|
|
7
14
|
|
|
8
|
-
|
|
9
|
-
import { PortfolioService } from './services/portfolio-service/PortfolioService';
|
|
10
|
-
import { PortfolioProto } from '../fintekkers/models/portfolio/portfolio_pb';
|
|
11
|
-
import { QueryPortfolioRequestProto } from '../fintekkers/requests/portfolio/query_portfolio_request_pb';
|
|
12
|
-
|
|
13
|
-
import { packStringIntoAny } from '../wrappers/models/utils/util';
|
|
14
|
-
import { PositionService } from './services/position-service/PositionService';
|
|
15
|
-
import { PositionProto, PositionTypeProto, PositionViewProto } from '../fintekkers/models/position/position_pb';
|
|
16
|
-
import { QueryPositionRequestProto } from '../fintekkers/requests/position/query_position_request_pb';
|
|
17
|
-
import { CreatePortfolioResponseProto } from '../fintekkers/requests/portfolio/create_portfolio_response_pb';
|
|
18
|
-
import { IdentifierProto } from '../fintekkers/models/security/identifier/identifier_pb';
|
|
15
|
+
import { packStringIntoAny } from '../../models/utils/util';
|
|
19
16
|
import { Any } from 'google-protobuf/google/protobuf/any_pb';
|
|
20
|
-
import { FieldMapEntry } from '../fintekkers/models/position/position_util_pb';
|
|
21
|
-
import { PositionFilterProto } from '../fintekkers/models/position/position_filter_pb';
|
|
22
|
-
import { ZonedDateTime } from './models/utils/datetime';
|
|
23
|
-
import { SecurityProto } from '../fintekkers/models/security/security_pb';
|
|
24
|
-
import { MeasureProto } from '../fintekkers/models/position/measure_pb';
|
|
25
|
-
import { SecurityService } from './services/security-service/SecurityService';
|
|
26
17
|
|
|
27
|
-
//
|
|
18
|
+
//Requests & Services
|
|
19
|
+
import { PortfolioService } from '../../services/portfolio-service/PortfolioService';
|
|
20
|
+
import { PositionService } from '../../services/position-service/PositionService';
|
|
21
|
+
import { QueryPositionRequestProto } from '../../../fintekkers/requests/position/query_position_request_pb';
|
|
28
22
|
|
|
29
|
-
|
|
23
|
+
test('test getting a position against the api.fintekkers.org position service', () => {
|
|
24
|
+
const isTrue = testPosition();
|
|
25
|
+
expect(isTrue).resolves.toBe(true);
|
|
26
|
+
}, 30000);
|
|
30
27
|
|
|
31
28
|
async function get_position(security:SecurityProto,
|
|
32
29
|
portfolio:PortfolioProto,
|
|
@@ -83,7 +80,7 @@ async function get_position(security:SecurityProto,
|
|
|
83
80
|
return positions;
|
|
84
81
|
}
|
|
85
82
|
|
|
86
|
-
async function testPosition(): Promise<
|
|
83
|
+
async function testPosition(): Promise<boolean> {
|
|
87
84
|
//Get the Federal Reserve portfolio
|
|
88
85
|
const now = ZonedDateTime.now();
|
|
89
86
|
|
|
@@ -100,10 +97,6 @@ async function testPosition(): Promise<void> {
|
|
|
100
97
|
PositionTypeProto.TRANSACTION,
|
|
101
98
|
[FieldProto.PORTFOLIO_NAME, FieldProto.SECURITY_ID], [], now);
|
|
102
99
|
|
|
103
|
-
|
|
104
|
-
positions[0].getFieldsList().forEach((field) => { console.log(field); });
|
|
105
|
-
positions[0].getMeasuresList().forEach((measure) => { console.log(measure); });
|
|
106
|
-
console.log(positions);
|
|
100
|
+
return true;
|
|
107
101
|
}
|
|
108
102
|
|
|
109
|
-
export { testPosition };
|
|
@@ -49,8 +49,8 @@ var create_security_request_pb_1 = require("../../../fintekkers/requests/securit
|
|
|
49
49
|
var security_1 = require("../../models/security/security");
|
|
50
50
|
var SecurityService = /** @class */ (function () {
|
|
51
51
|
function SecurityService() {
|
|
52
|
-
|
|
53
|
-
this.client = new
|
|
52
|
+
this.client = new security_service_grpc_pb_1.SecurityClient('api.fintekkers.org:8082', grpc.credentials.createSsl());
|
|
53
|
+
// this.client = new SecurityClient('localhost:8082', grpc.credentials.createInsecure());
|
|
54
54
|
}
|
|
55
55
|
SecurityService.prototype.validateCreateSecurity = function (security) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -99,14 +99,11 @@ var SecurityService = /** @class */ (function () {
|
|
|
99
99
|
stream2 = tmpClient.search(searchRequest);
|
|
100
100
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
101
101
|
stream2.on('data', function (response) {
|
|
102
|
-
console.log('Result of the security search call');
|
|
103
|
-
console.log('Response:', response);
|
|
104
102
|
response.getSecurityResponseList().forEach(function (security) {
|
|
105
103
|
listSecurities.push(new security_1.default(security));
|
|
106
104
|
});
|
|
107
105
|
});
|
|
108
106
|
stream2.on('end', function () {
|
|
109
|
-
console.log('Stream ended.');
|
|
110
107
|
resolve(listSecurities);
|
|
111
108
|
});
|
|
112
109
|
stream2.on('error', function (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecurityService.js","sourceRoot":"","sources":["SecurityService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAsC;AACtC,6BAAiC;AAIjC,gDAA8D;AAI9D,cAAc;AACd,6FAA6F;AAG7F,sBAAsB;AACtB,mHAAwG;AACxG,6GAA4G;AAE5G,+GAA8G;AAE9G,2DAAsD;AAEtD;IAGE;QACE,
|
|
1
|
+
{"version":3,"file":"SecurityService.js","sourceRoot":"","sources":["SecurityService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAsC;AACtC,6BAAiC;AAIjC,gDAA8D;AAI9D,cAAc;AACd,6FAA6F;AAG7F,sBAAsB;AACtB,mHAAwG;AACxG,6GAA4G;AAE5G,+GAA8G;AAE9G,2DAAsD;AAEtD;IAGE;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,yC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/B,qBAAM,0BAA0B,EAAE,EAAA;4BAAzC,sBAAO,SAAkC,EAAC;;;;KAC3C;IACH,sBAAC;AAAD,CAAC,AAxED,IAwEC;AAEQ,0CAAe"}
|
|
@@ -23,8 +23,8 @@ class SecurityService {
|
|
|
23
23
|
private client: SecurityClient;
|
|
24
24
|
|
|
25
25
|
constructor() {
|
|
26
|
-
|
|
27
|
-
this.client = new SecurityClient('localhost:8082', grpc.credentials.createInsecure());
|
|
26
|
+
this.client = new SecurityClient('api.fintekkers.org:8082', grpc.credentials.createSsl());
|
|
27
|
+
// this.client = new SecurityClient('localhost:8082', grpc.credentials.createInsecure());
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
async validateCreateSecurity(security: SecurityProto): Promise<SummaryProto> {
|
|
@@ -73,15 +73,12 @@ class SecurityService {
|
|
|
73
73
|
|
|
74
74
|
return new Promise<Security[]>((resolve, reject) => {
|
|
75
75
|
stream2.on('data', (response:QuerySecurityResponseProto) => {
|
|
76
|
-
console.log('Result of the security search call');
|
|
77
|
-
console.log('Response:', response);
|
|
78
76
|
response.getSecurityResponseList().forEach((security) => {
|
|
79
77
|
listSecurities.push(new Security(security));
|
|
80
78
|
});
|
|
81
79
|
});
|
|
82
80
|
|
|
83
81
|
stream2.on('end', () => {
|
|
84
|
-
console.log('Stream ended.');
|
|
85
82
|
resolve(listSecurities);
|
|
86
83
|
});
|
|
87
84
|
|
|
@@ -36,19 +36,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.testSecurity = void 0;
|
|
40
39
|
// Models
|
|
41
|
-
var security_pb_1 = require("
|
|
42
|
-
var coupon_frequency_pb_1 = require("
|
|
43
|
-
var decimal_value_pb_1 = require("
|
|
44
|
-
var coupon_type_pb_1 = require("
|
|
45
|
-
var security_type_pb_1 = require("
|
|
46
|
-
var local_date_pb_1 = require("
|
|
40
|
+
var security_pb_1 = require("../../../fintekkers/models/security/security_pb");
|
|
41
|
+
var coupon_frequency_pb_1 = require("../../../fintekkers/models/security/coupon_frequency_pb");
|
|
42
|
+
var decimal_value_pb_1 = require("../../../fintekkers/models/util/decimal_value_pb");
|
|
43
|
+
var coupon_type_pb_1 = require("../../../fintekkers/models/security/coupon_type_pb");
|
|
44
|
+
var security_type_pb_1 = require("../../../fintekkers/models/security/security_type_pb");
|
|
45
|
+
var local_date_pb_1 = require("../../../fintekkers/models/util/local_date_pb");
|
|
47
46
|
// Model Utils
|
|
48
|
-
var field_pb_1 = require("
|
|
49
|
-
var uuid = require("
|
|
50
|
-
var dt = require("
|
|
51
|
-
var SecurityService_1 = require("./
|
|
47
|
+
var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
|
|
48
|
+
var uuid = require("../../models/utils/uuid");
|
|
49
|
+
var dt = require("../../models/utils/datetime");
|
|
50
|
+
var SecurityService_1 = require("./SecurityService");
|
|
51
|
+
test('test creating a security against the api.fintekkers.org portfolio service', function () {
|
|
52
|
+
var isTrue = testSecurity();
|
|
53
|
+
expect(isTrue).resolves.toBe(true);
|
|
54
|
+
}, 30000);
|
|
52
55
|
function testSecurity() {
|
|
53
56
|
return __awaiter(this, void 0, void 0, function () {
|
|
54
57
|
var id_proto, now, securityService, usd_security, security, faceValue, couponRate, issueDate, maturityDate, validationSummary, createSecurityResponse, searchResults;
|
|
@@ -97,19 +100,15 @@ function testSecurity() {
|
|
|
97
100
|
return [4 /*yield*/, securityService.validateCreateSecurity(security)];
|
|
98
101
|
case 2:
|
|
99
102
|
validationSummary = _a.sent();
|
|
100
|
-
console.log(validationSummary);
|
|
101
103
|
return [4 /*yield*/, securityService.createSecurity(security)];
|
|
102
104
|
case 3:
|
|
103
105
|
createSecurityResponse = _a.sent();
|
|
104
|
-
console.log(createSecurityResponse);
|
|
105
106
|
return [4 /*yield*/, securityService.searchSecurity(now.to_date_proto(), field_pb_1.FieldProto.ASSET_CLASS, 'Fixed Income')];
|
|
106
107
|
case 4:
|
|
107
108
|
searchResults = _a.sent();
|
|
108
|
-
|
|
109
|
-
return [2 /*return*/];
|
|
109
|
+
return [2 /*return*/, true];
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
exports.testSecurity = testSecurity;
|
|
115
114
|
//# sourceMappingURL=security.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.test.js","sourceRoot":"","sources":["security.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS;AACT,+EAAgF;AAChF,+FAA+F;AAC/F,qFAAqF;AACrF,qFAAqF;AACrF,yFAAyF;AACzF,+EAA+E;AAE/E,cAAc;AACd,yEAA0E;AAE1E,8CAAgD;AAChD,gDAAkD;AAGlD,qDAAoD;AAEpD,IAAI,CAAC,2EAA2E,EAAE;IAChF,IAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC,EAAE,KAAK,CAAC,CAAC;AAEV,SAAe,YAAY;;;;;;oBACnB,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;oBAC5C,GAAG,GAAG,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC;oBAE7B,eAAe,GAAG,IAAI,iCAAe,EAAE,CAAC;oBAE3B,qBAAM,eAAe;6BACrC,cAAc,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,qBAAU,CAAC,WAAW,EAAE,MAAM,CAAC;6BACnE,IAAI,CAAC,UAAC,UAAU;4BACf,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;wBACvB,CAAC,CAAC,EAAA;;oBAJA,YAAY,GAAG,SAIf;oBAEE,QAAQ,GAAG,IAAI,2BAAa,EAAE,CAAC;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I,CAAC,CAAC,CAAC,KAAK;oBACjC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;oBACzB,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;oBACvB,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;oBAEvC,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;oBACtC,QAAQ,CAAC,cAAc,CAAC,4BAA4B,CAAC,CAAC;oBAE9B,qBAAM,eAAe,CAAC,sBAAsB,CAAC,QAAQ,CAAC,EAAA;;oBAA1E,iBAAiB,GAAG,SAAsD;oBAErB,qBAAM,eAAe,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAA;;oBAAnG,sBAAsB,GAA+B,SAA8C;oBAEnF,qBAAM,eAAe,CAAC,cAAc,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,qBAAU,CAAC,WAAW,EAAE,cAAc,CAAC,EAAA;;oBAAjH,aAAa,GAAG,SAAiG;oBAErH,sBAAO,IAAI,EAAC;;;;CACb"}
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
// Models
|
|
2
|
-
import { SecurityProto } from '
|
|
3
|
-
import { CouponFrequencyProto } from '
|
|
4
|
-
import { DecimalValueProto } from '
|
|
5
|
-
import { CouponTypeProto } from '
|
|
6
|
-
import { SecurityTypeProto } from '
|
|
7
|
-
import { LocalDateProto } from '
|
|
2
|
+
import { SecurityProto } from '../../../fintekkers/models/security/security_pb';
|
|
3
|
+
import { CouponFrequencyProto } from '../../../fintekkers/models/security/coupon_frequency_pb';
|
|
4
|
+
import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
|
|
5
|
+
import { CouponTypeProto } from '../../../fintekkers/models/security/coupon_type_pb';
|
|
6
|
+
import { SecurityTypeProto } from '../../../fintekkers/models/security/security_type_pb';
|
|
7
|
+
import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
|
|
8
8
|
|
|
9
9
|
// Model Utils
|
|
10
|
-
import { FieldProto } from '
|
|
10
|
+
import { FieldProto } from '../../../fintekkers/models/position/field_pb';
|
|
11
11
|
|
|
12
|
-
import * as uuid from '
|
|
13
|
-
import * as dt from '
|
|
12
|
+
import * as uuid from '../../models/utils/uuid';
|
|
13
|
+
import * as dt from '../../models/utils/datetime';
|
|
14
14
|
|
|
15
|
-
import { CreateSecurityResponseProto } from '
|
|
16
|
-
import { SecurityService } from './
|
|
15
|
+
import { CreateSecurityResponseProto } from '../../../fintekkers/requests/security/create_security_response_pb';
|
|
16
|
+
import { SecurityService } from './SecurityService';
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
test('test creating a security against the api.fintekkers.org portfolio service', () => {
|
|
19
|
+
const isTrue = testSecurity();
|
|
20
|
+
expect(isTrue).resolves.toBe(true);
|
|
21
|
+
}, 30000);
|
|
22
|
+
|
|
23
|
+
async function testSecurity(): Promise<boolean> {
|
|
19
24
|
const id_proto = uuid.UUID.random().toUUIDProto();
|
|
20
25
|
const now = dt.ZonedDateTime.now();
|
|
21
26
|
|
|
@@ -63,13 +68,10 @@ async function testSecurity(): Promise<void> {
|
|
|
63
68
|
security.setDescription('Dummy US Treasury 10Y Bond');
|
|
64
69
|
|
|
65
70
|
var validationSummary = await securityService.validateCreateSecurity(security);
|
|
66
|
-
console.log(validationSummary);
|
|
67
71
|
|
|
68
72
|
var createSecurityResponse:CreateSecurityResponseProto = await securityService.createSecurity(security);
|
|
69
|
-
console.log(createSecurityResponse);
|
|
70
73
|
|
|
71
74
|
var searchResults = await securityService.searchSecurity(now.to_date_proto(), FieldProto.ASSET_CLASS, 'Fixed Income');
|
|
72
|
-
console.log('There are %d securities in this response', searchResults.length);
|
|
73
|
-
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
exports.TransactionService = void 0;
|
|
40
|
+
var grpc = require("@grpc/grpc-js");
|
|
41
|
+
var util_1 = require("util");
|
|
42
|
+
// Models
|
|
43
|
+
var transaction_1 = require("../../models/transaction/transaction");
|
|
44
|
+
var util_2 = require("../../models/utils/util");
|
|
45
|
+
// Model Utils
|
|
46
|
+
var position_filter_pb_1 = require("../../../fintekkers/models/position/position_filter_pb");
|
|
47
|
+
// Requests & Services
|
|
48
|
+
var transaction_service_grpc_pb_1 = require("../../../fintekkers/services/transaction-service/transaction_service_grpc_pb");
|
|
49
|
+
var create_transaction_request_pb_1 = require("../../../fintekkers/requests/transaction/create_transaction_request_pb");
|
|
50
|
+
var query_transaction_request_pb_1 = require("../../../fintekkers/requests/transaction/query_transaction_request_pb");
|
|
51
|
+
var TransactionService = /** @class */ (function () {
|
|
52
|
+
function TransactionService() {
|
|
53
|
+
this.client = new transaction_service_grpc_pb_1.TransactionClient('api.fintekkers.org:8082', grpc.credentials.createSsl());
|
|
54
|
+
// this.client = new TransactionClient('localhost:8082', grpc.credentials.createInsecure());
|
|
55
|
+
}
|
|
56
|
+
TransactionService.prototype.validateCreateTransaction = function (transaction) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
var createRequest, validateCreateOrUpdateAsync, response;
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
switch (_a.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
createRequest = new create_transaction_request_pb_1.CreateTransactionRequestProto();
|
|
63
|
+
createRequest.setObjectClass('TransactionRequest');
|
|
64
|
+
createRequest.setVersion('0.0.1');
|
|
65
|
+
createRequest.setCreateTransactionInput(transaction.proto);
|
|
66
|
+
validateCreateOrUpdateAsync = (0, util_1.promisify)(this.client.validateCreateOrUpdate.bind(this.client));
|
|
67
|
+
return [4 /*yield*/, validateCreateOrUpdateAsync(createRequest)];
|
|
68
|
+
case 1:
|
|
69
|
+
response = _a.sent();
|
|
70
|
+
return [2 /*return*/, response];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
TransactionService.prototype.createTransaction = function (transaction) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
77
|
+
var createRequest, createSecurityAsync, response;
|
|
78
|
+
return __generator(this, function (_a) {
|
|
79
|
+
switch (_a.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
createRequest = new create_transaction_request_pb_1.CreateTransactionRequestProto();
|
|
82
|
+
createRequest.setObjectClass('TransactionRequest');
|
|
83
|
+
createRequest.setVersion('0.0.1');
|
|
84
|
+
createRequest.setCreateTransactionInput(transaction.proto);
|
|
85
|
+
createSecurityAsync = (0, util_1.promisify)(this.client.createOrUpdate.bind(this.client));
|
|
86
|
+
return [4 /*yield*/, createSecurityAsync(createRequest)];
|
|
87
|
+
case 1:
|
|
88
|
+
response = _a.sent();
|
|
89
|
+
return [2 /*return*/, response];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
TransactionService.prototype.searchTransaction = function (asOf, fieldProto, fieldValue) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
+
function processStreamSynchronously() {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
+
var stream2;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
stream2 = tmpClient.search(searchRequest);
|
|
101
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
102
|
+
stream2.on('data', function (response) {
|
|
103
|
+
response.getTransactionResponseList().forEach(function (transaction) {
|
|
104
|
+
listTransactions.push(new transaction_1.default(transaction));
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
stream2.on('end', function () {
|
|
108
|
+
resolve(listTransactions);
|
|
109
|
+
});
|
|
110
|
+
stream2.on('error', function (err) {
|
|
111
|
+
console.error('Error in the stream:', err);
|
|
112
|
+
reject(err);
|
|
113
|
+
});
|
|
114
|
+
})];
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
var searchRequest, positionFilter, fieldMapEntry, tmpClient, listTransactions;
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
switch (_a.label) {
|
|
121
|
+
case 0:
|
|
122
|
+
searchRequest = new query_transaction_request_pb_1.QueryTransactionRequestProto();
|
|
123
|
+
searchRequest.setObjectClass('SecurityRequest');
|
|
124
|
+
searchRequest.setVersion('0.0.1');
|
|
125
|
+
searchRequest.setAsOf(asOf);
|
|
126
|
+
positionFilter = new position_filter_pb_1.PositionFilterProto();
|
|
127
|
+
positionFilter.setObjectClass('PositionFilter');
|
|
128
|
+
positionFilter.setVersion('0.0.1');
|
|
129
|
+
fieldMapEntry = (0, util_2.createFieldMapEntry)(fieldProto, fieldValue);
|
|
130
|
+
positionFilter.setFiltersList([fieldMapEntry]);
|
|
131
|
+
searchRequest.setSearchTransactionInput(positionFilter);
|
|
132
|
+
tmpClient = this.client;
|
|
133
|
+
listTransactions = [];
|
|
134
|
+
return [4 /*yield*/, processStreamSynchronously()];
|
|
135
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
return TransactionService;
|
|
141
|
+
}());
|
|
142
|
+
exports.TransactionService = TransactionService;
|
|
143
|
+
//# sourceMappingURL=TransactionService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionService.js","sourceRoot":"","sources":["TransactionService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAsC;AACtC,6BAAiC;AAEjC,SAAS;AACT,oEAA+D;AAC/D,gDAA8D;AAI9D,cAAc;AACd,6FAA6F;AAG7F,sBAAsB;AACtB,4HAAiH;AACjH,wHAAuH;AAEvH,sHAAqH;AAIrH;IAGE;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,+CAAiB,CAAC,yBAAyB,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC;QAC7F,4FAA4F;IAC9F,CAAC;IAEK,sDAAyB,GAA/B,UAAgC,WAAwB;;;;;;wBAChD,aAAa,GAAG,IAAI,6DAA6B,EAAE,CAAC;wBAC1D,aAAa,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;wBACnD,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;wBAClC,aAAa,CAAC,yBAAyB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;wBAErD,2BAA2B,GAAG,IAAA,gBAAS,EAAC,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;wBACnF,qBAAM,2BAA2B,CAAC,aAAa,CAAC,EAAA;;wBAA3D,QAAQ,GAAG,SAAgD;wBACjE,sBAAO,QAAQ,EAAC;;;;KACjB;IAEK,8CAAiB,GAAvB,UAAwB,WAAwB;;;;;;wBACxC,aAAa,GAAG,IAAI,6DAA6B,EAAE,CAAC;wBAC1D,aAAa,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;wBACnD,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;wBAClC,aAAa,CAAC,yBAAyB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;wBAErD,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