@fintekkers/ledger-models 0.1.61 → 0.1.63
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 +3 -0
- package/node/fintekkers/models/position/field_pb.d.ts +1 -0
- package/node/fintekkers/models/position/field_pb.js +1 -0
- package/node/fintekkers/models/security/bond/auction_type_grpc_pb.js +1 -0
- package/node/fintekkers/models/security/bond/auction_type_pb.d.ts +12 -0
- package/node/fintekkers/models/security/bond/auction_type_pb.js +33 -0
- package/node/fintekkers/models/security/bond/issuance_grpc_pb.js +1 -0
- package/node/fintekkers/models/security/bond/issuance_pb.d.ts +85 -0
- package/node/fintekkers/models/security/bond/issuance_pb.js +652 -0
- package/node/fintekkers/models/security/security_pb.d.ts +6 -0
- package/node/fintekkers/models/security/security_pb.js +64 -2
- package/node/fintekkers/requests/transaction/query_transaction_request_pb.d.ts +3 -0
- package/node/fintekkers/requests/transaction/query_transaction_request_pb.js +31 -1
- package/node/fintekkers/requests/transaction/query_transaction_response_pb.d.ts +7 -0
- package/node/fintekkers/requests/transaction/query_transaction_response_pb.js +54 -1
- package/node/wrappers/models/portfolio/portfolio.js +41 -0
- package/node/wrappers/models/portfolio/portfolio.js.map +1 -0
- package/node/wrappers/models/portfolio/portfolio.ts +49 -0
- package/node/wrappers/models/position/position.js +14 -9
- package/node/wrappers/models/position/position.js.map +1 -1
- package/node/wrappers/models/position/position.test.js +43 -0
- package/node/wrappers/models/position/position.test.js.map +1 -0
- package/node/wrappers/models/position/position.test.ts +70 -0
- package/node/wrappers/models/position/position.ts +17 -10
- package/node/wrappers/models/position/positionfilter.js +35 -0
- package/node/wrappers/models/position/positionfilter.js.map +1 -0
- package/node/wrappers/models/position/positionfilter.ts +38 -0
- package/node/wrappers/models/security/security.test.js +33 -0
- package/node/wrappers/models/security/security.test.js.map +1 -0
- package/node/wrappers/models/security/security.test.ts +41 -0
- package/node/wrappers/models/transaction/transaction.js +6 -5
- package/node/wrappers/models/transaction/transaction.js.map +1 -1
- package/node/wrappers/models/transaction/transaction.test.js.map +1 -1
- package/node/wrappers/models/transaction/transaction.test.ts +1 -6
- package/node/wrappers/models/transaction/transaction.ts +31 -31
- package/node/wrappers/models/transaction/transaction_type.js +0 -1
- package/node/wrappers/models/transaction/transaction_type.js.map +1 -1
- package/node/wrappers/models/transaction/transaction_type.ts +1 -1
- package/node/wrappers/models/utils/datetime.js +9 -0
- package/node/wrappers/models/utils/datetime.js.map +1 -1
- package/node/wrappers/models/utils/datetime.ts +16 -4
- package/node/wrappers/models/utils/requestcontext.js +55 -0
- package/node/wrappers/models/utils/requestcontext.js.map +1 -0
- package/node/wrappers/models/utils/requestcontext.ts +44 -0
- package/node/wrappers/models/utils/requestcontext_d.js +1 -0
- package/node/wrappers/models/utils/requestcontext_d.js.map +1 -0
- package/node/wrappers/models/utils/requestcontext_d.ts +7 -0
- package/node/wrappers/models/utils/serialization.js +14 -4
- package/node/wrappers/models/utils/serialization.js.map +1 -1
- package/node/wrappers/models/utils/serialization.test.js +8 -9
- package/node/wrappers/models/utils/serialization.test.js.map +1 -1
- package/node/wrappers/models/utils/serialization.test.ts +8 -10
- package/node/wrappers/models/utils/serialization.ts +46 -38
- package/node/wrappers/models/utils/serialization.util.js +108 -0
- package/node/wrappers/models/utils/serialization.util.js.map +1 -0
- package/node/wrappers/models/utils/serialization.util.test.js +36 -0
- package/node/wrappers/models/utils/serialization.util.test.js.map +1 -0
- package/node/wrappers/models/utils/serialization.util.test.ts +47 -0
- package/node/wrappers/models/utils/serialization.util.ts +121 -0
- package/node/wrappers/services/portfolio-service/PortfolioService.js +8 -16
- package/node/wrappers/services/portfolio-service/PortfolioService.js.map +1 -1
- package/node/wrappers/services/portfolio-service/PortfolioService.ts +14 -24
- package/node/wrappers/services/portfolio-service/portfolio.test.js +30 -34
- package/node/wrappers/services/portfolio-service/portfolio.test.js.map +1 -1
- package/node/wrappers/services/portfolio-service/portfolio.test.ts +9 -13
- package/node/wrappers/services/position-service/PositionService.js +4 -3
- package/node/wrappers/services/position-service/PositionService.js.map +1 -1
- package/node/wrappers/services/position-service/PositionService.ts +4 -19
- package/node/wrappers/services/position-service/position.test.js +24 -9
- package/node/wrappers/services/position-service/position.test.js.map +1 -1
- package/node/wrappers/services/position-service/position.test.ts +57 -51
- package/node/wrappers/services/security-service/SecurityService.js +16 -15
- package/node/wrappers/services/security-service/SecurityService.js.map +1 -1
- package/node/wrappers/services/security-service/SecurityService.ts +15 -18
- package/node/wrappers/services/security-service/security.maturityLadder.test.js +59 -0
- package/node/wrappers/services/security-service/security.maturityLadder.test.js.map +1 -0
- package/node/wrappers/services/security-service/security.maturityLadder.test.ts +39 -0
- package/node/wrappers/services/security-service/security.test.js +19 -7
- package/node/wrappers/services/security-service/security.test.js.map +1 -1
- package/node/wrappers/services/security-service/security.test.ts +11 -7
- package/node/wrappers/services/transaction-service/TransactionService.js +34 -47
- package/node/wrappers/services/transaction-service/TransactionService.js.map +1 -1
- package/node/wrappers/services/transaction-service/TransactionService.ts +16 -23
- package/node/wrappers/services/transaction-service/transaction.test.js +45 -12
- package/node/wrappers/services/transaction-service/transaction.test.js.map +1 -1
- package/node/wrappers/services/transaction-service/transaction.test.ts +48 -21
- package/package.json +2 -1
- package/web/fintekkers/models/position/field_pb.d.ts +1 -0
- package/web/fintekkers/models/position/field_pb.js +1 -0
- package/web/fintekkers/models/security/bond/auction_type_pb.d.ts +8 -0
- package/web/fintekkers/models/security/bond/auction_type_pb.js +27 -0
- package/web/fintekkers/models/security/bond/issuance_pb.d.ts +82 -0
- package/web/fintekkers/models/security/bond/issuance_pb.js +646 -0
- package/web/fintekkers/models/security/security_pb.d.ts +7 -0
- package/web/fintekkers/models/security/security_pb.js +64 -2
- package/web/fintekkers/requests/transaction/query_transaction_request_pb.d.ts +4 -0
- package/web/fintekkers/requests/transaction/query_transaction_request_pb.js +31 -1
- package/web/fintekkers/requests/transaction/query_transaction_response_pb.d.ts +7 -0
- package/web/fintekkers/requests/transaction/query_transaction_response_pb.js +54 -1
- package/node/wrappers/models/utils/util.js +0 -28
- package/node/wrappers/models/utils/util.js.map +0 -1
- package/node/wrappers/models/utils/util.ts +0 -28
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FieldMapEntry } from '../../../fintekkers/models/position/position_util_pb';
|
|
2
|
+
import { FieldProto } from '../../../fintekkers/models/position/field_pb';
|
|
3
|
+
import { pack } from '../utils/serialization.util';
|
|
4
|
+
import { PositionFilterProto } from '../../../fintekkers/models/position/position_filter_pb';
|
|
5
|
+
|
|
6
|
+
export class PositionFilter {
|
|
7
|
+
filters: FieldMapEntry[];
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
this.filters = [];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {*} field FieldProto.ASSET_CLASS, as an example
|
|
15
|
+
* @param {*} fieldValue The appropriate value for the FieldProto, e.g. FieldProto.ASSET_CLASS would have a string fieldValue
|
|
16
|
+
*/
|
|
17
|
+
addFilter(field: FieldProto, fieldValue: any): PositionFilter {
|
|
18
|
+
const fieldMapEntry = new FieldMapEntry();
|
|
19
|
+
fieldMapEntry.setField(field); //FieldProto.ASSET_CLASS);
|
|
20
|
+
fieldMapEntry.setFieldValuePacked(pack(fieldValue));
|
|
21
|
+
|
|
22
|
+
this.filters.push(fieldMapEntry);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getFilters(): Array<FieldMapEntry> {
|
|
27
|
+
return this.filters;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
toProto(): PositionFilterProto {
|
|
31
|
+
const positionFilterProto = new PositionFilterProto();
|
|
32
|
+
positionFilterProto.setObjectClass('PositionFilter');
|
|
33
|
+
positionFilterProto.setVersion('0.0.1');
|
|
34
|
+
positionFilterProto.setFiltersList(this.filters);
|
|
35
|
+
|
|
36
|
+
return positionFilterProto;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var local_date_pb_1 = require("../../../fintekkers/models/util/local_date_pb");
|
|
4
|
+
var uuid_1 = require("../utils/uuid");
|
|
5
|
+
var assert = require("assert");
|
|
6
|
+
var security_1 = require("./security");
|
|
7
|
+
var decimal_value_pb_1 = require("../../../fintekkers/models/util/decimal_value_pb");
|
|
8
|
+
var security_pb_1 = require("../../../fintekkers/models/security/security_pb");
|
|
9
|
+
var coupon_frequency_pb_1 = require("../../../fintekkers/models/security/coupon_frequency_pb");
|
|
10
|
+
var coupon_type_pb_1 = require("../../../fintekkers/models/security/coupon_type_pb");
|
|
11
|
+
var security_quantity_type_pb_1 = require("../../../fintekkers/models/security/security_quantity_type_pb");
|
|
12
|
+
test('test the security wrapper', function () {
|
|
13
|
+
testSerialization();
|
|
14
|
+
});
|
|
15
|
+
function testSerialization() {
|
|
16
|
+
var security = dummySecurity();
|
|
17
|
+
assert(security.getMaturityDate().getFullYear() == 2026);
|
|
18
|
+
}
|
|
19
|
+
function dummySecurity() {
|
|
20
|
+
return new security_1.default(new security_pb_1.SecurityProto()
|
|
21
|
+
.setObjectClass('Transaction').setVersion('0.0.1').setUuid(uuid_1.UUID.random().toUUIDProto())
|
|
22
|
+
.setFaceValue(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('1000.00'))
|
|
23
|
+
.setQuantityType(security_quantity_type_pb_1.SecurityQuantityTypeProto.ORIGINAL_FACE_VALUE)
|
|
24
|
+
.setAssetClass("Bond")
|
|
25
|
+
.setIssuerName("Dummy issuer")
|
|
26
|
+
.setCouponRate(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('0.05'))
|
|
27
|
+
.setCouponFrequency(coupon_frequency_pb_1.CouponFrequencyProto.SEMIANNUALLY)
|
|
28
|
+
.setCouponType(coupon_type_pb_1.CouponTypeProto.FIXED)
|
|
29
|
+
.setMaturityDate(new local_date_pb_1.LocalDateProto().setYear(2026).setMonth(1).setDay(1))
|
|
30
|
+
.setIssueDate(new local_date_pb_1.LocalDateProto().setYear(2021).setMonth(1).setDay(1))
|
|
31
|
+
.setDescription("Dummy security"));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=security.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.test.js","sourceRoot":"","sources":["security.test.ts"],"names":[],"mappings":";;AAAA,+EAA+E;AAC/E,sCAAqC;AAErC,+BAAkC;AAClC,uCAAkC;AAElC,qFAAqF;AACrF,+EAAgF;AAChF,+FAA+F;AAC/F,qFAAqF;AACrF,2GAA0G;AAG1G,IAAI,CAAC,2BAA2B,EAAE;IAC9B,iBAAiB,EAAE,CAAC;AACxB,CAAC,CAAC,CAAC;AAEH,SAAS,iBAAiB;IACtB,IAAM,QAAQ,GAAG,aAAa,EAAE,CAAC;IAEjC,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,aAAa;IAClB,OAAO,IAAI,kBAAQ,CAAC,IAAI,2BAAa,EAAE;SAClC,cAAc,CAAC,aAAa,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,WAAI,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;SACtF,YAAY,CAAC,IAAI,oCAAiB,EAAE,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC;SAC3E,eAAe,CAAC,qDAAyB,CAAC,mBAAmB,CAAC;SAC9D,aAAa,CAAC,MAAM,CAAC;SACrB,aAAa,CAAC,cAAc,CAAC;SAE7B,aAAa,CAAC,IAAI,oCAAiB,EAAE,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC;SACzE,kBAAkB,CAAC,0CAAoB,CAAC,YAAY,CAAC;SACrD,aAAa,CAAC,gCAAe,CAAC,KAAK,CAAC;SAEpC,eAAe,CAAC,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACzE,YAAY,CAAC,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACtE,cAAc,CAAC,gBAAgB,CAAC,CACpC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
|
|
2
|
+
import { UUID } from '../utils/uuid';
|
|
3
|
+
|
|
4
|
+
import assert = require('assert');
|
|
5
|
+
import Security from './security';
|
|
6
|
+
|
|
7
|
+
import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
|
|
8
|
+
import { SecurityProto } from '../../../fintekkers/models/security/security_pb';
|
|
9
|
+
import { CouponFrequencyProto } from '../../../fintekkers/models/security/coupon_frequency_pb';
|
|
10
|
+
import { CouponTypeProto } from '../../../fintekkers/models/security/coupon_type_pb';
|
|
11
|
+
import { SecurityQuantityTypeProto } from '../../../fintekkers/models/security/security_quantity_type_pb';
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
test('test the security wrapper', () => {
|
|
15
|
+
testSerialization();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
function testSerialization(): void {
|
|
19
|
+
const security = dummySecurity();
|
|
20
|
+
|
|
21
|
+
assert(security.getMaturityDate().getFullYear() == 2026);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function dummySecurity() {
|
|
25
|
+
return new Security(new SecurityProto()
|
|
26
|
+
.setObjectClass('Transaction').setVersion('0.0.1').setUuid(UUID.random().toUUIDProto())
|
|
27
|
+
.setFaceValue(new DecimalValueProto().setArbitraryPrecisionValue('1000.00'))
|
|
28
|
+
.setQuantityType(SecurityQuantityTypeProto.ORIGINAL_FACE_VALUE)
|
|
29
|
+
.setAssetClass("Bond")
|
|
30
|
+
.setIssuerName("Dummy issuer")
|
|
31
|
+
|
|
32
|
+
.setCouponRate(new DecimalValueProto().setArbitraryPrecisionValue('0.05'))
|
|
33
|
+
.setCouponFrequency(CouponFrequencyProto.SEMIANNUALLY)
|
|
34
|
+
.setCouponType(CouponTypeProto.FIXED)
|
|
35
|
+
|
|
36
|
+
.setMaturityDate(new LocalDateProto().setYear(2026).setMonth(1).setDay(1))
|
|
37
|
+
.setIssueDate(new LocalDateProto().setYear(2021).setMonth(1).setDay(1))
|
|
38
|
+
.setDescription("Dummy security")
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
|
|
4
3
|
var transaction_type_1 = require("./transaction_type");
|
|
4
|
+
var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
|
|
5
5
|
var security_1 = require("../security/security");
|
|
6
|
+
var portfolio_1 = require("../portfolio/portfolio");
|
|
7
|
+
//Model Utils
|
|
6
8
|
var datetime_1 = require("../utils/datetime");
|
|
7
9
|
var uuid_1 = require("../utils/uuid");
|
|
8
10
|
var date_1 = require("../utils/date");
|
|
@@ -24,10 +26,10 @@ var Transaction = /** @class */ (function () {
|
|
|
24
26
|
return "WHOOPS";
|
|
25
27
|
}
|
|
26
28
|
};
|
|
27
|
-
Transaction.prototype.
|
|
29
|
+
Transaction.prototype.getFields = function () {
|
|
28
30
|
return [field_pb_1.FieldProto.ID, field_pb_1.FieldProto.SECURITY_ID, field_pb_1.FieldProto.AS_OF, field_pb_1.FieldProto.ASSET_CLASS, field_pb_1.FieldProto.IDENTIFIER];
|
|
29
31
|
};
|
|
30
|
-
Transaction.prototype.
|
|
32
|
+
Transaction.prototype.getField = function (field) {
|
|
31
33
|
switch (field) {
|
|
32
34
|
case field_pb_1.FieldProto.ID:
|
|
33
35
|
case field_pb_1.FieldProto.SECURITY_ID:
|
|
@@ -57,9 +59,8 @@ var Transaction = /** @class */ (function () {
|
|
|
57
59
|
Transaction.prototype.getAsOf = function () {
|
|
58
60
|
return new datetime_1.ZonedDateTime(this.proto.getAsOf());
|
|
59
61
|
};
|
|
60
|
-
//TODO: Create Portfolio wrapper
|
|
61
62
|
Transaction.prototype.getPortfolio = function () {
|
|
62
|
-
return this.proto.getPortfolio();
|
|
63
|
+
return new portfolio_1.default(this.proto.getPortfolio());
|
|
63
64
|
};
|
|
64
65
|
Transaction.prototype.getSecurity = function () {
|
|
65
66
|
return new security_1.default(this.proto.getSecurity());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["transaction.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["transaction.ts"],"names":[],"mappings":";;AAEA,uDAAqD;AAGrD,yEAA0E;AAG1E,iDAA4C;AAC5C,oDAA+C;AAE/C,aAAa;AACb,8CAAkD;AAClD,sCAAqC;AACrC,sCAA0C;AAC1C,yCAAqC;AAErC;IAGE,qBAAY,KAAuB;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,8BAAQ,GAAR;QACE,IAAI;YACF,IAAM,OAAO,GACX,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;YAEnF,OAAO,UAAG,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,iBAAO,IAAI,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAK;gBACpG,oBAAa,IAAI,CAAC,YAAY,EAAE,CAAC,QAAQ,EAAE,wBAAc,IAAI,CAAC,kBAA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yCAAmB,GAAnB;QACE,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,sBAAsB,EAAE,CAAC,CAAC;IACpF,CAAC;IAED,kCAAY,GAAZ;QACE,OAAO,IAAI,gBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,uCAAiB,GAAjB;QACE,OAAO,IAAI,gBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,wCAAkB,GAAlB;QACE,OAAO,IAAI,kCAAe,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,kCAAY,GAAZ;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;IACnC,CAAC;IAED,uCAAiB,GAAjB;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC;IACxC,CAAC;IAED,6CAAuB,GAAvB;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC;IAC/C,CAAC;IAGD,4BAAM,GAAN,UAAO,KAAkB;QACvB,IAAI,KAAK,YAAY,WAAW,EAAE;YAChC,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;SAC3C;aAAM;YACL,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IACH,kBAAC;AAAD,CAAC,AAvHD,IAuHC;AAED,kBAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.test.js","sourceRoot":"","sources":["transaction.test.ts"],"names":[],"mappings":";;AAAA,+EAA+E;
|
|
1
|
+
{"version":3,"file":"transaction.test.js","sourceRoot":"","sources":["transaction.test.ts"],"names":[],"mappings":";;AAAA,+EAA+E;AAC/E,sCAAqC;AAErC,+BAAkC;AAClC,6CAAwC;AACxC,wFAAyF;AACzF,kGAAkG;AAElG,qFAAqF;AAGrF,IAAI,CAAC,8BAA8B,EAAE;IACjC,iBAAiB,EAAE,CAAC;AACtB,CAAC,CAAC,CAAC;AAEL,SAAS,iBAAiB;IACtB,IAAM,WAAW,GAAG,gBAAgB,EAAE,CAAC;IAEvC,MAAM,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,CAAC;IAC9D,MAAM,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,gBAAgB;IAErB,OAAO,IAAI,qBAAW,CAAC,IAAI,iCAAgB,EAAE;SAC5C,cAAc,CAAC,aAAa,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,WAAI,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;SACtF,YAAY,CAAC,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACtE,kBAAkB,CAAC,0CAAoB,CAAC,GAAG,CAAC;SAC5C,WAAW,CAAC,IAAI,oCAAiB,EAAE,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC;SAC1E,iBAAiB,CAAC,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
|
|
2
|
-
import { UUIDProto } from '../../../fintekkers/models/util/uuid_pb';
|
|
3
|
-
import { ProtoSerializationUtil } from '../utils/serialization';
|
|
4
2
|
import { UUID } from '../utils/uuid';
|
|
5
3
|
|
|
6
4
|
import assert = require('assert');
|
|
7
5
|
import Transaction from './transaction';
|
|
8
6
|
import { TransactionProto } from '../../../fintekkers/models/transaction/transaction_pb';
|
|
9
7
|
import { TransactionTypeProto } from '../../../fintekkers/models/transaction/transaction_type_pb';
|
|
10
|
-
import { LocalTimestampProto } from '../../../fintekkers/models/util/local_timestamp_pb';
|
|
11
8
|
|
|
12
|
-
import { Timestamp } from '@grpc/grpc-js/build/src/generated/google/protobuf/Timestamp';
|
|
13
9
|
import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
|
|
14
|
-
|
|
10
|
+
|
|
15
11
|
|
|
16
12
|
test('test the transaction wrapper', () => {
|
|
17
13
|
testSerialization();
|
|
@@ -21,7 +17,6 @@ function testSerialization(): void {
|
|
|
21
17
|
const transaction = dummyTransaction();
|
|
22
18
|
|
|
23
19
|
assert(transaction.getTransactionType().toString() === 'BUY');
|
|
24
|
-
|
|
25
20
|
assert(transaction.getDirectedQuantity().toNumber() > 0);
|
|
26
21
|
}
|
|
27
22
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import { FieldProto } from "../../../fintekkers/models/position/field_pb";
|
|
3
|
-
import { PositionStatusProto } from "../../../fintekkers/models/position/position_status_pb";
|
|
1
|
+
//Models
|
|
4
2
|
import { PriceProto } from "../../../fintekkers/models/price/price_pb";
|
|
5
|
-
import { IdentifierProto } from "../../../fintekkers/models/security/identifier/identifier_pb";
|
|
6
3
|
import { TransactionType } from "./transaction_type";
|
|
7
4
|
import { StrategyAllocationProto } from "../../../fintekkers/models/strategy/strategy_allocation_pb";
|
|
8
5
|
import { TransactionProto } from "../../../fintekkers/models/transaction/transaction_pb";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
6
|
+
import { FieldProto } from "../../../fintekkers/models/position/field_pb";
|
|
7
|
+
import { PositionStatusProto } from "../../../fintekkers/models/position/position_status_pb";
|
|
8
|
+
|
|
11
9
|
import Security from "../security/security";
|
|
10
|
+
import Portfolio from "../portfolio/portfolio";
|
|
11
|
+
|
|
12
|
+
//Model Utils
|
|
12
13
|
import { ZonedDateTime } from "../utils/datetime";
|
|
13
14
|
import { UUID } from "../utils/uuid";
|
|
14
15
|
import { LocalDate } from "../utils/date";
|
|
@@ -23,24 +24,24 @@ class Transaction {
|
|
|
23
24
|
|
|
24
25
|
toString(): string {
|
|
25
26
|
try {
|
|
26
|
-
|
|
27
|
+
const validTo: string =
|
|
27
28
|
this.proto.getValidFrom() !== null ? this.proto.getValidTo().toString() : "NULL";
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
return `${/*this.proto.isCancelled()*/ false ? "INVALIDATED: " : ""}TXN[${this.getID().toString()}], ` +
|
|
30
31
|
`TradeDate[${this.getTradeDate().toString()}], TxnType[${this.getTransactionType()}], Price[${this.getPrice()}], Quantity[${this.getQuantity()}], ` +
|
|
31
32
|
`AsOf[${this.getAsOf().toString()}], Portfolio[${this.getPortfolio().getPortfolioName()}], Issuer[${this.getSecurity().getIssuerName()}], ` +
|
|
32
33
|
`ValidFrom[${this.proto.getValidFrom().toString()}], ValidTo[${validTo}], Strategy[${this.getStrategyAllocation().toString()}]`;
|
|
33
34
|
} catch (e) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
35
|
+
console.error(e);
|
|
36
|
+
return "WHOOPS";
|
|
37
|
+
}
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
getFields(): FieldProto[] {
|
|
40
41
|
return [FieldProto.ID, FieldProto.SECURITY_ID, FieldProto.AS_OF, FieldProto.ASSET_CLASS, FieldProto.IDENTIFIER];
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
getField(field: FieldProto): any {
|
|
44
45
|
switch (field) {
|
|
45
46
|
case FieldProto.ID:
|
|
46
47
|
case FieldProto.SECURITY_ID:
|
|
@@ -73,9 +74,8 @@ class Transaction {
|
|
|
73
74
|
return new ZonedDateTime(this.proto.getAsOf());
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return this.proto.getPortfolio();
|
|
77
|
+
getPortfolio(): Portfolio {
|
|
78
|
+
return new Portfolio(this.proto.getPortfolio());
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
getSecurity(): Security {
|
|
@@ -100,31 +100,31 @@ class Transaction {
|
|
|
100
100
|
|
|
101
101
|
getDirectedQuantity(): Decimal {
|
|
102
102
|
return this.getQuantity().mul(this.getTransactionType().getDirectionMultiplier());
|
|
103
|
-
}
|
|
103
|
+
}
|
|
104
104
|
|
|
105
105
|
getTradeDate(): LocalDate {
|
|
106
106
|
return new LocalDate(this.proto.getTradeDate());
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
getSettlementDate()
|
|
109
|
+
getSettlementDate(): LocalDate {
|
|
110
110
|
return new LocalDate(this.proto.getSettlementDate());
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
getTransactionType(): TransactionType {
|
|
114
|
+
return new TransactionType(this.proto.getTransactionType());
|
|
115
|
+
}
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
getTradeName(): string {
|
|
118
|
+
return this.proto.getTradeName();
|
|
119
|
+
}
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
getPositionStatus(): PositionStatusProto {
|
|
122
|
+
return this.proto.getPositionStatus();
|
|
123
|
+
}
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
getChildrenTransactions(): TransactionProto[] {
|
|
126
|
+
return this.proto.getChildtransactionsList();
|
|
127
|
+
}
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
equals(other: Transaction): boolean {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction_type.js","sourceRoot":"","sources":["transaction_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IACH,kCAAQ,GAAR;QACE,OAAO,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;IACL,sBAAC;AAAD,CAAC,AA5CD,IA4CC;AA5CY,0CAAe;AASxB;IACI,eAAe,CAAC,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEtD,MAAM,CAAC,IAAI,CAAC,0CAAoB,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;QACzC,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,0CAAoB,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACP,CAAC,GAAA,CAAA"}
|
|
@@ -28,7 +28,7 @@ export class TransactionType {
|
|
|
28
28
|
case TransactionTypeProto.MATURATION:
|
|
29
29
|
return -1;
|
|
30
30
|
case TransactionTypeProto.UNKNOWN:
|
|
31
|
-
throw new Error('Unknown transaction type: '+this.toString());
|
|
31
|
+
throw new Error('Unknown transaction type: '+this.toString());
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -9,6 +9,15 @@ var ZonedDateTime = /** @class */ (function () {
|
|
|
9
9
|
function ZonedDateTime(proto) {
|
|
10
10
|
this.proto = proto;
|
|
11
11
|
}
|
|
12
|
+
ZonedDateTime.prototype.getTimezone = function () {
|
|
13
|
+
return this.proto.getTimeZone();
|
|
14
|
+
};
|
|
15
|
+
ZonedDateTime.prototype.getSeconds = function () {
|
|
16
|
+
return this.proto.getTimestamp().getSeconds();
|
|
17
|
+
};
|
|
18
|
+
ZonedDateTime.prototype.getNanoSeconds = function () {
|
|
19
|
+
return this.proto.getTimestamp().getNanos();
|
|
20
|
+
};
|
|
12
21
|
ZonedDateTime.prototype.toDateTime = function () {
|
|
13
22
|
// Creating a DateTime object with the current date and time in a specific time zone (e.g., 'America/New_York')
|
|
14
23
|
var unixTimestampSeconds = this.proto.getTimestamp().getSeconds();
|
|
@@ -1 +1 @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,sDAAsD;AACtD,IAAM,GAAG,GAAG,aAAa,CAAC,GAAG,EAAE,CAAC;AAChC,IAAA,gBAAM,EAAC,GAAG,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC"}
|
|
@@ -10,6 +10,18 @@ class ZonedDateTime {
|
|
|
10
10
|
this.proto = proto;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
getTimezone(): string {
|
|
14
|
+
return this.proto.getTimeZone();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getSeconds(): number {
|
|
18
|
+
return this.proto.getTimestamp().getSeconds();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getNanoSeconds(): number {
|
|
22
|
+
return this.proto.getTimestamp().getNanos();
|
|
23
|
+
}
|
|
24
|
+
|
|
13
25
|
toDateTime(): DateTime {
|
|
14
26
|
// Creating a DateTime object with the current date and time in a specific time zone (e.g., 'America/New_York')
|
|
15
27
|
const unixTimestampSeconds = this.proto.getTimestamp().getSeconds();
|
|
@@ -33,20 +45,20 @@ class ZonedDateTime {
|
|
|
33
45
|
static now(): ZonedDateTime {
|
|
34
46
|
// Get the current time in milliseconds since January 1, 1970 (Unix timestamp)
|
|
35
47
|
const currentTimeMillis = Date.now();
|
|
36
|
-
|
|
48
|
+
|
|
37
49
|
// Convert milliseconds to seconds and nanoseconds
|
|
38
50
|
const seconds = Math.floor(currentTimeMillis / 1000);
|
|
39
51
|
const nanos = (currentTimeMillis % 1000) * 1e6; // 1 millisecond = 1e6 nanoseconds
|
|
40
|
-
|
|
52
|
+
|
|
41
53
|
// Create a new Timestamp object with the current time
|
|
42
54
|
const timestamp = new Timestamp();
|
|
43
55
|
timestamp.setSeconds(seconds);
|
|
44
56
|
timestamp.setNanos(nanos);
|
|
45
|
-
|
|
57
|
+
|
|
46
58
|
const localTimestamp = new LocalTimestampProto();
|
|
47
59
|
localTimestamp.setTimeZone('America/New_York');
|
|
48
60
|
localTimestamp.setTimestamp(timestamp);
|
|
49
|
-
|
|
61
|
+
|
|
50
62
|
return new ZonedDateTime(localTimestamp);
|
|
51
63
|
}
|
|
52
64
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var dotenv = require("dotenv");
|
|
4
|
+
dotenv.config();
|
|
5
|
+
var grpc = require("@grpc/grpc-js");
|
|
6
|
+
var EnvConfig = /** @class */ (function () {
|
|
7
|
+
function EnvConfig() {
|
|
8
|
+
}
|
|
9
|
+
EnvConfig.getEnvVar = function (key, defaultValue) {
|
|
10
|
+
var value = process.env[key];
|
|
11
|
+
if (value === undefined) {
|
|
12
|
+
if (defaultValue === undefined) {
|
|
13
|
+
throw new Error("Environment variable ".concat(key, " is not set."));
|
|
14
|
+
}
|
|
15
|
+
return defaultValue;
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(EnvConfig, "apiKey", {
|
|
20
|
+
get: function () {
|
|
21
|
+
throw new Error("API keys not supported currently.");
|
|
22
|
+
// return EnvConfig.getEnvVar('API_KEY');
|
|
23
|
+
},
|
|
24
|
+
enumerable: false,
|
|
25
|
+
configurable: true
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(EnvConfig, "apiURL", {
|
|
28
|
+
/**
|
|
29
|
+
* Returns the URL for the backend GRPC service. It will default to
|
|
30
|
+
* api.fintekkers.org if the environment variable is not set. You
|
|
31
|
+
* cann set the environment variable by adding API_URL to your .env file.
|
|
32
|
+
*/
|
|
33
|
+
get: function () {
|
|
34
|
+
var url = EnvConfig.getEnvVar('API_URL', "api.fintekkers.org") + ":8082";
|
|
35
|
+
return url;
|
|
36
|
+
},
|
|
37
|
+
enumerable: false,
|
|
38
|
+
configurable: true
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(EnvConfig, "apiCredentials", {
|
|
41
|
+
get: function () {
|
|
42
|
+
if (this.apiURL === "localhost:8082") {
|
|
43
|
+
return grpc.credentials.createInsecure();
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return grpc.credentials.createSsl();
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
enumerable: false,
|
|
50
|
+
configurable: true
|
|
51
|
+
});
|
|
52
|
+
return EnvConfig;
|
|
53
|
+
}());
|
|
54
|
+
exports.default = EnvConfig;
|
|
55
|
+
//# sourceMappingURL=requestcontext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestcontext.js","sourceRoot":"","sources":["requestcontext.ts"],"names":[],"mappings":";;AAAA,+BAAiC;AACjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,oCAAsC;AAEtC;IAAA;IAoCA,CAAC;IAnCkB,mBAAS,GAAxB,UAAyB,GAAW,EAAE,YAAqB;QACvD,IAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,IAAI,YAAY,KAAK,SAAS,EAAE;gBAC9B,MAAM,IAAI,KAAK,CAAC,+BAAwB,GAAG,iBAAc,CAAC,CAAC;aAC5D;YACD,OAAO,YAAY,CAAC;SACrB;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEL,sBAAW,mBAAM;aAAjB;YACE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;YACpD,yCAAyC;QAC3C,CAAC;;;OAAA;IAOD,sBAAW,mBAAM;QALjB;;;;WAIG;aACH;YACE,IAAM,GAAG,GAAU,SAAS,CAAC,SAAS,CAAC,SAAS,EAAE,oBAAoB,CAAC,GAAG,OAAO,CAAC;YAClF,OAAO,GAAG,CAAC;QACb,CAAC;;;OAAA;IAED,sBAAW,2BAAc;aAAzB;YACE,IAAG,IAAI,CAAC,MAAM,KAAK,gBAAgB,EAAC;gBAChC,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC;aAC5C;iBACI;gBACD,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;aACvC;QACH,CAAC;;;OAAA;IAEH,gBAAC;AAAD,CAAC,AApCD,IAoCC;AAED,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as dotenv from 'dotenv';
|
|
2
|
+
dotenv.config();
|
|
3
|
+
|
|
4
|
+
import * as grpc from '@grpc/grpc-js';
|
|
5
|
+
|
|
6
|
+
class EnvConfig {
|
|
7
|
+
private static getEnvVar(key: string, defaultValue?: string): string {
|
|
8
|
+
const value = process.env[key];
|
|
9
|
+
if (value === undefined) {
|
|
10
|
+
if (defaultValue === undefined) {
|
|
11
|
+
throw new Error(`Environment variable ${key} is not set.`);
|
|
12
|
+
}
|
|
13
|
+
return defaultValue;
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static get apiKey(): string {
|
|
19
|
+
throw new Error("API keys not supported currently.")
|
|
20
|
+
// return EnvConfig.getEnvVar('API_KEY');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Returns the URL for the backend GRPC service. It will default to
|
|
25
|
+
* api.fintekkers.org if the environment variable is not set. You
|
|
26
|
+
* cann set the environment variable by adding API_URL to your .env file.
|
|
27
|
+
*/
|
|
28
|
+
static get apiURL(): string {
|
|
29
|
+
const url:string = EnvConfig.getEnvVar('API_URL', "api.fintekkers.org") + ":8082";
|
|
30
|
+
return url;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static get apiCredentials(): grpc.ChannelCredentials {
|
|
34
|
+
if(this.apiURL === "localhost:8082"){
|
|
35
|
+
return grpc.credentials.createInsecure();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return grpc.credentials.createSsl();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default EnvConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=requestcontext_d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestcontext_d.js","sourceRoot":"","sources":["requestcontext_d.ts"],"names":[],"mappings":""}
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ProtoSerializationUtil = void 0;
|
|
4
4
|
var decimal_value_pb_1 = require("../../../fintekkers/models/util/decimal_value_pb");
|
|
5
5
|
var local_date_pb_1 = require("../../../fintekkers/models/util/local_date_pb");
|
|
6
|
+
var local_timestamp_pb_1 = require("../../../fintekkers/models/util/local_timestamp_pb");
|
|
6
7
|
var uuid_pb_1 = require("../../../fintekkers/models/util/uuid_pb");
|
|
8
|
+
var datetime_1 = require("./datetime");
|
|
7
9
|
var uuid_1 = require("./uuid");
|
|
8
10
|
var ProtoSerializationUtil = /** @class */ (function () {
|
|
9
11
|
function ProtoSerializationUtil() {
|
|
@@ -14,9 +16,12 @@ var ProtoSerializationUtil = /** @class */ (function () {
|
|
|
14
16
|
}
|
|
15
17
|
if (obj instanceof Date) {
|
|
16
18
|
return new local_date_pb_1.LocalDateProto()
|
|
17
|
-
.setYear(obj.
|
|
18
|
-
.setMonth(obj.
|
|
19
|
-
.setDay(obj.
|
|
19
|
+
.setYear(obj.getFullYear())
|
|
20
|
+
.setMonth(obj.getMonth() + 1)
|
|
21
|
+
.setDay(obj.getDate());
|
|
22
|
+
}
|
|
23
|
+
if (obj instanceof datetime_1.ZonedDateTime) {
|
|
24
|
+
return obj.toProto();
|
|
20
25
|
}
|
|
21
26
|
if (typeof obj === "number") {
|
|
22
27
|
return new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue(obj.toString());
|
|
@@ -28,7 +33,12 @@ var ProtoSerializationUtil = /** @class */ (function () {
|
|
|
28
33
|
return uuid_1.UUID.fromU8Array(obj.getRawUuid_asU8());
|
|
29
34
|
}
|
|
30
35
|
if (obj instanceof local_date_pb_1.LocalDateProto) {
|
|
31
|
-
|
|
36
|
+
var date = new Date(obj.getYear(), obj.getMonth() - 1, obj.getDay());
|
|
37
|
+
date.setHours(0, 0, 0, 0);
|
|
38
|
+
return date;
|
|
39
|
+
}
|
|
40
|
+
if (obj instanceof local_timestamp_pb_1.LocalTimestampProto) {
|
|
41
|
+
return new datetime_1.ZonedDateTime(obj);
|
|
32
42
|
}
|
|
33
43
|
if (obj.enum_name && obj.enum_name === "TRANSACTION_TYPE") {
|
|
34
44
|
return null; // new TransactionType(obj.enum_value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["serialization.ts"],"names":[],"mappings":";;;AAAA,qFAAqF;AACrF,+EAA+E;
|
|
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;AAO9B;IAAA;IA0CA,CAAC;IAzCQ,gCAAS,GAAhB,UAAiB,GAAQ;QACvB,IAAI,GAAG,YAAY,WAAI,EAAE;YACvB,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;SAC1B;QACD,IAAI,GAAG,YAAY,IAAI,EAAE;YACvB,OAAO,IAAI,8BAAc,EAAE;iBACxB,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;iBAC1B,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;iBAC5B,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;SAC1B;QACD,IAAI,GAAG,YAAY,wBAAa,EAAE;YAChC,OAAO,GAAG,CAAC,OAAO,EAAE,CAAC;SACtB;QACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,OAAO,IAAI,oCAAiB,EAAE,CAAC,0BAA0B,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;SAC3E;QAED,MAAM,IAAI,KAAK,CAAC,6CAAsC,OAAO,GAAG,sBAAY,GAAG,CAAE,CAAC,CAAC;IACrF,CAAC;IAEM,kCAAW,GAAlB,UAAmB,GAAQ;QACzB,IAAI,GAAG,YAAY,mBAAS,EAAE;YAC5B,OAAO,WAAI,CAAC,WAAW,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC;SAChD;QACD,IAAI,GAAG,YAAY,8BAAc,EAAE;YACjC,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;SACb;QACD,IAAI,GAAG,YAAY,wCAAmB,EAAE;YACtC,OAAO,IAAI,wBAAa,CAAC,GAAG,CAAC,CAAC;SAC/B;QACD,IAAI,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,SAAS,KAAK,kBAAkB,EAAE;YACzD,OAAO,IAAI,CAAC,CAAA,uCAAuC;SACpD;QACD,IAAI,GAAG,YAAY,oCAAiB,EAAE;YACpC,OAAO,UAAU,CAAC,GAAG,CAAC,0BAA0B,EAAE,CAAC,CAAC;SACrD;QAED,MAAM,IAAI,KAAK,CAAC,+CAAwC,OAAO,GAAG,sBAAY,GAAG,CAAE,CAAC,CAAC;IACvF,CAAC;IACH,6BAAC;AAAD,CAAC,AA1CD,IA0CC;AA1CY,wDAAsB"}
|
|
@@ -3,21 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var serialization_1 = require("./serialization");
|
|
4
4
|
var uuid_1 = require("./uuid");
|
|
5
5
|
var assert = require("assert");
|
|
6
|
-
test('test
|
|
6
|
+
test('test serialization of key types', function () {
|
|
7
7
|
testSerialization();
|
|
8
8
|
});
|
|
9
9
|
function testSerialization() {
|
|
10
10
|
checkUUID();
|
|
11
|
-
//
|
|
12
|
-
var serializedDate = serialization_1.ProtoSerializationUtil.serialize(
|
|
13
|
-
assert(serializedDate.toString().indexOf('2023') > -1);
|
|
11
|
+
var march2023 = new Date(2023, 2, 5); //Month is zero-indexed, so 2 == March.
|
|
12
|
+
var serializedDate = serialization_1.ProtoSerializationUtil.serialize(march2023);
|
|
13
|
+
assert(serializedDate.toString().indexOf('2023,3,5') > -1);
|
|
14
14
|
var deserializedDate = serialization_1.ProtoSerializationUtil.deserialize(serializedDate);
|
|
15
|
-
assert(deserializedDate.toString().indexOf('2023') > -1);
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
assert(serializedTimestamp.toString().indexOf('2023') > -1);
|
|
15
|
+
assert(deserializedDate.toString().indexOf('Mar 05 2023') > -1);
|
|
16
|
+
var serializedTimestamp = serialization_1.ProtoSerializationUtil.serialize(march2023);
|
|
17
|
+
assert(serializedTimestamp.toString().indexOf('2023,3,5') > -1);
|
|
19
18
|
var deserializedTimestamp = serialization_1.ProtoSerializationUtil.deserialize(serializedTimestamp);
|
|
20
|
-
assert(deserializedTimestamp.toString().indexOf('2023') > -1);
|
|
19
|
+
assert(deserializedTimestamp.toString().indexOf('Mar 05 2023') > -1);
|
|
21
20
|
}
|
|
22
21
|
function checkUUID() {
|
|
23
22
|
var uuid = uuid_1.UUID.random();
|