@fintekkers/ledger-models 0.1.60 → 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 -15
- package/index.js.map +1 -1
- package/index.ts +1 -19
- package/jest.config.js +4 -0
- package/node/fintekkers/models/security/security_pb.test.js +29 -30
- package/node/fintekkers/models/security/security_pb.test.js.map +1 -0
- package/node/fintekkers/models/security/security_pb.test.ts +33 -0
- package/node/wrappers/models/security/security.js +1 -1
- package/node/wrappers/models/security/security.js.map +1 -1
- package/node/wrappers/models/security/security.ts +1 -1
- package/node/wrappers/models/transaction/transaction.js +10 -8
- package/node/wrappers/models/transaction/transaction.js.map +1 -1
- package/node/wrappers/models/transaction/transaction.test.js +26 -0
- package/node/wrappers/models/transaction/transaction.test.js.map +1 -0
- package/node/wrappers/models/transaction/transaction.test.ts +37 -0
- package/node/wrappers/models/transaction/transaction.ts +13 -11
- 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 +2 -5
- package/node/wrappers/services/portfolio-service/PortfolioService.js.map +1 -1
- package/node/wrappers/services/portfolio-service/PortfolioService.ts +2 -5
- 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 +2 -5
- 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 +2 -6
- package/node/wrappers/services/transaction-service/TransactionService.js.map +1 -1
- package/node/wrappers/services/transaction-service/TransactionService.ts +2 -7
- package/node/wrappers/{transaction.test.js → services/transaction-service/transaction.test.js} +17 -18
- package/node/wrappers/services/transaction-service/transaction.test.js.map +1 -0
- package/node/wrappers/{transaction.test.ts → services/transaction-service/transaction.test.ts} +22 -25
- package/package.json +3 -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
- package/node/wrappers/transaction.test.js.map +0 -1
package/babel.config.js
CHANGED
package/index.js
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
// import { testPortfolio } from './node/wrappers/portfolio.test';
|
|
3
|
-
// testPortfolio();
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
// import { testSecurity } from './node/wrappers/security.test';
|
|
6
|
-
// testSecurity();
|
|
7
|
-
// //TODO: Add position convenience wrapper
|
|
8
|
-
// import { testPosition } from './node/wrappers/position.test';
|
|
9
|
-
// testPosition();
|
|
10
|
-
// import { testSerialization } from './node/wrappers/models/utils/serialization.test';
|
|
11
|
-
// testSerialization();
|
|
12
|
-
// TODO - Transactions
|
|
13
|
-
var transaction_test_1 = require("./node/wrappers/transaction.test");
|
|
14
|
-
(0, transaction_test_1.testTransaction)();
|
|
15
|
-
// TODO - Positions
|
|
1
|
+
console.log('Done');
|
|
16
2
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC"}
|
package/index.ts
CHANGED
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// testPortfolio();
|
|
3
|
-
|
|
4
|
-
// import { testSecurity } from './node/wrappers/security.test';
|
|
5
|
-
// testSecurity();
|
|
6
|
-
|
|
7
|
-
// //TODO: Add position convenience wrapper
|
|
8
|
-
// import { testPosition } from './node/wrappers/position.test';
|
|
9
|
-
// testPosition();
|
|
10
|
-
|
|
11
|
-
// import { testSerialization } from './node/wrappers/models/utils/serialization.test';
|
|
12
|
-
// testSerialization();
|
|
13
|
-
|
|
14
|
-
// TODO - Transactions
|
|
15
|
-
|
|
16
|
-
import { testTransaction } from './node/wrappers/transaction.test';
|
|
17
|
-
testTransaction();
|
|
18
|
-
// TODO - Positions
|
|
19
|
-
|
|
1
|
+
console.log('Done');
|
package/jest.config.js
ADDED
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import fintekkers_models_util_local_date_pb from '../util/local_date_pb';
|
|
4
|
-
import fintekkers_models_util_local_timestamp_pb from '../util/local_timestamp_pb';
|
|
5
|
-
import fintekkers_models_util_uuid_pb from '../util/uuid_pb';
|
|
6
|
-
import fintekkers_models_security_identifier_identifier_pb from './identifier/identifier_pb';
|
|
7
|
-
import fintekkers_models_security_security_type_pb from './security_type_pb';
|
|
8
|
-
import fintekkers_models_security_security_pb from './security_pb';
|
|
9
|
-
import fintekkers_models_security_security_quantity_type_pb from './security_quantity_type_pb';
|
|
10
|
-
import fintekkers_models_security_coupon_frequency_pb from './coupon_frequency_pb';
|
|
11
|
-
import fintekkers_models_security_coupon_type_pb from './coupon_type_pb';
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
3
|
// Import or define the SecurityProto class
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
4
|
+
var decimal_value_pb_1 = require("../util/decimal_value_pb");
|
|
5
|
+
var local_date_pb_1 = require("../util/local_date_pb");
|
|
6
|
+
var coupon_frequency_pb_1 = require("./coupon_frequency_pb");
|
|
7
|
+
var coupon_type_pb_1 = require("./coupon_type_pb");
|
|
8
|
+
var security_pb_1 = require("./security_pb");
|
|
9
|
+
var security_type_pb_1 = require("./security_type_pb");
|
|
10
|
+
test('create a security proto (from sue) object and test it can be read', function () {
|
|
11
|
+
// Usage example
|
|
12
|
+
var security = new security_pb_1.SecurityProto();
|
|
13
|
+
security.setObjectClass('SomeObjectClass');
|
|
14
|
+
security.setVersion('1.0');
|
|
15
|
+
security.setAssetClass('FixedIncome');
|
|
16
|
+
security.setCouponFrequency(coupon_frequency_pb_1.CouponFrequencyProto.ANNUALLY);
|
|
17
|
+
security.setCouponRate(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('0.05'));
|
|
18
|
+
security.setFaceValue(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('1000.00'));
|
|
19
|
+
security.setIssueDate(new local_date_pb_1.LocalDateProto().setYear(2023).setMonth(1).setDay(1));
|
|
20
|
+
security.setDatedDate(new local_date_pb_1.LocalDateProto().setYear(2023).setMonth(1).setDay(1));
|
|
21
|
+
security.setMaturityDate(new local_date_pb_1.LocalDateProto().setYear(2023).setMonth(1).setDay(1));
|
|
22
|
+
security.setSecurityType(security_type_pb_1.SecurityTypeProto.BOND_SECURITY);
|
|
23
|
+
security.setCouponType(coupon_type_pb_1.CouponTypeProto.FIXED);
|
|
24
|
+
// Serialize the object to a binary representation
|
|
25
|
+
var binaryData = security.serializeBinary();
|
|
26
|
+
// Deserialize the binary data back to a SecurityProto object
|
|
27
|
+
var deserializedSecurity = security_pb_1.SecurityProto.deserializeBinary(binaryData);
|
|
28
|
+
// Test that the deserialized object is the same as the original
|
|
29
|
+
expect(deserializedSecurity.toObject()).toEqual(security.toObject());
|
|
32
30
|
});
|
|
31
|
+
//# sourceMappingURL=security_pb.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security_pb.test.js","sourceRoot":"","sources":["security_pb.test.ts"],"names":[],"mappings":";;AAAA,2CAA2C;AAC3C,6DAA6D;AAC7D,uDAAuD;AACvD,6DAA6D;AAC7D,mDAAmD;AACnD,6CAA8C;AAC9C,uDAAuD;AAEvD,IAAI,CAAC,mEAAmE,EAAE;IACxE,gBAAgB;IAChB,IAAM,QAAQ,GAAG,IAAI,2BAAa,EAAE,CAAC;IAErC,QAAQ,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;IAC3C,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3B,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IACtC,QAAQ,CAAC,kBAAkB,CAAC,0CAAoB,CAAC,QAAQ,CAAC,CAAC;IAC3D,QAAQ,CAAC,aAAa,CAAC,IAAI,oCAAiB,EAAE,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC;IACnF,QAAQ,CAAC,YAAY,CAAC,IAAI,oCAAiB,EAAE,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC,CAAC;IACrF,QAAQ,CAAC,YAAY,CAAC,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAChF,QAAQ,CAAC,YAAY,CAAC,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAChF,QAAQ,CAAC,eAAe,CAAC,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACnF,QAAQ,CAAC,eAAe,CAAC,oCAAiB,CAAC,aAAa,CAAC,CAAC;IAC1D,QAAQ,CAAC,aAAa,CAAC,gCAAe,CAAC,KAAK,CAAC,CAAA;IAE7C,kDAAkD;IAClD,IAAM,UAAU,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC;IAE9C,6DAA6D;IAC7D,IAAM,oBAAoB,GAAG,2BAAa,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAEzE,gEAAgE;IAChE,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;AACvE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Import or define the SecurityProto class
|
|
2
|
+
import { DecimalValueProto } from '../util/decimal_value_pb';
|
|
3
|
+
import { LocalDateProto } from '../util/local_date_pb';
|
|
4
|
+
import { CouponFrequencyProto } from './coupon_frequency_pb';
|
|
5
|
+
import { CouponTypeProto } from './coupon_type_pb';
|
|
6
|
+
import { SecurityProto } from './security_pb';
|
|
7
|
+
import { SecurityTypeProto } from './security_type_pb';
|
|
8
|
+
|
|
9
|
+
test('create a security proto (from sue) object and test it can be read', () => {
|
|
10
|
+
// Usage example
|
|
11
|
+
const security = new SecurityProto();
|
|
12
|
+
|
|
13
|
+
security.setObjectClass('SomeObjectClass');
|
|
14
|
+
security.setVersion('1.0');
|
|
15
|
+
security.setAssetClass('FixedIncome');
|
|
16
|
+
security.setCouponFrequency(CouponFrequencyProto.ANNUALLY);
|
|
17
|
+
security.setCouponRate(new DecimalValueProto().setArbitraryPrecisionValue('0.05'));
|
|
18
|
+
security.setFaceValue(new DecimalValueProto().setArbitraryPrecisionValue('1000.00'));
|
|
19
|
+
security.setIssueDate(new LocalDateProto().setYear(2023).setMonth(1).setDay(1));
|
|
20
|
+
security.setDatedDate(new LocalDateProto().setYear(2023).setMonth(1).setDay(1));
|
|
21
|
+
security.setMaturityDate(new LocalDateProto().setYear(2023).setMonth(1).setDay(1));
|
|
22
|
+
security.setSecurityType(SecurityTypeProto.BOND_SECURITY);
|
|
23
|
+
security.setCouponType(CouponTypeProto.FIXED)
|
|
24
|
+
|
|
25
|
+
// Serialize the object to a binary representation
|
|
26
|
+
const binaryData = security.serializeBinary();
|
|
27
|
+
|
|
28
|
+
// Deserialize the binary data back to a SecurityProto object
|
|
29
|
+
const deserializedSecurity = SecurityProto.deserializeBinary(binaryData);
|
|
30
|
+
|
|
31
|
+
// Test that the deserialized object is the same as the original
|
|
32
|
+
expect(deserializedSecurity.toObject()).toEqual(security.toObject());
|
|
33
|
+
});
|
|
@@ -69,7 +69,7 @@ var Security = /** @class */ (function () {
|
|
|
69
69
|
};
|
|
70
70
|
Security.prototype.equals = function (other) {
|
|
71
71
|
if (other instanceof Security) {
|
|
72
|
-
return this.
|
|
72
|
+
return this.getID().equals(other.getID());
|
|
73
73
|
}
|
|
74
74
|
else {
|
|
75
75
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","sourceRoot":"","sources":["security.ts"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M,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,gCAAa,GAAb;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;IACpC,CAAC;IAED,yBAAM,GAAN,UAAO,KAAe;QACpB,IAAI,KAAK,YAAY,QAAQ,EAAE;YAC7B,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;SAC3C;aAAM;YACL,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IACH,eAAC;AAAD,CAAC,AAtFD,IAsFC;AAED,kBAAe,QAAQ,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
|
|
4
|
+
var transaction_type_1 = require("./transaction_type");
|
|
4
5
|
var security_1 = require("../security/security");
|
|
5
6
|
var datetime_1 = require("../utils/datetime");
|
|
6
7
|
var uuid_1 = require("../utils/uuid");
|
|
8
|
+
var date_1 = require("../utils/date");
|
|
7
9
|
var decimal_js_1 = require("decimal.js");
|
|
8
10
|
var Transaction = /** @class */ (function () {
|
|
9
11
|
function Transaction(proto) {
|
|
@@ -68,23 +70,23 @@ var Transaction = /** @class */ (function () {
|
|
|
68
70
|
Transaction.prototype.getPrice = function () {
|
|
69
71
|
return this.proto.getPrice();
|
|
70
72
|
};
|
|
71
|
-
Transaction.prototype.getSettlementDate = function () {
|
|
72
|
-
return this.proto.getSettlementDate();
|
|
73
|
-
};
|
|
74
73
|
Transaction.prototype.getQuantity = function () {
|
|
75
74
|
return new decimal_js_1.Decimal(this.proto.getQuantity().getArbitraryPrecisionValue());
|
|
76
75
|
};
|
|
77
76
|
Transaction.prototype.getIssuerName = function () {
|
|
78
77
|
return this.getSecurity().getIssuerName();
|
|
79
78
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
Transaction.prototype.getDirectedQuantity = function () {
|
|
80
|
+
return this.getQuantity().mul(this.getTransactionType().getDirectionMultiplier());
|
|
81
|
+
};
|
|
83
82
|
Transaction.prototype.getTradeDate = function () {
|
|
84
|
-
return this.proto.getTradeDate();
|
|
83
|
+
return new date_1.LocalDate(this.proto.getTradeDate());
|
|
84
|
+
};
|
|
85
|
+
Transaction.prototype.getSettlementDate = function () {
|
|
86
|
+
return new date_1.LocalDate(this.proto.getSettlementDate());
|
|
85
87
|
};
|
|
86
88
|
Transaction.prototype.getTransactionType = function () {
|
|
87
|
-
return this.getTransactionType();
|
|
89
|
+
return new transaction_type_1.TransactionType(this.proto.getTransactionType());
|
|
88
90
|
};
|
|
89
91
|
Transaction.prototype.getTradeName = function () {
|
|
90
92
|
return this.proto.getTradeName();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["transaction.ts"],"names":[],"mappings":";;AACA,yEAA0E;
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["transaction.ts"],"names":[],"mappings":";;AACA,yEAA0E;AAI1E,uDAAqD;AAKrD,iDAA4C;AAC5C,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;YACA,IAAM,OAAO,GACb,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;YAEjF,OAAO,UAAG,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,iBAAO,IAAI,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAK;gBACtG,oBAAa,IAAI,CAAC,YA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AAC,aAAa,EAAE,CAAC;IAC5C,CAAC;IAED,yCAAmB,GAAnB;QACE,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,sBAAsB,EAAE,CAAC,CAAC;IACtF,CAAC;IAEC,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;IAEC,wCAAkB,GAAlB;QACI,OAAO,IAAI,kCAAe,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,kCAAY,GAAZ;QACI,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;IACrC,CAAC;IAED,uCAAiB,GAAjB;QACI,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAC1C,CAAC;IAED,6CAAuB,GAAvB;QACI,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC;IACjD,CAAC;IAGH,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,AAxHD,IAwHC;AAED,kBAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 transaction_1 = require("./transaction");
|
|
7
|
+
var transaction_pb_1 = require("../../../fintekkers/models/transaction/transaction_pb");
|
|
8
|
+
var transaction_type_pb_1 = require("../../../fintekkers/models/transaction/transaction_type_pb");
|
|
9
|
+
var decimal_value_pb_1 = require("../../../fintekkers/models/util/decimal_value_pb");
|
|
10
|
+
test('test the transaction wrapper', function () {
|
|
11
|
+
testSerialization();
|
|
12
|
+
});
|
|
13
|
+
function testSerialization() {
|
|
14
|
+
var transaction = dummyTransaction();
|
|
15
|
+
assert(transaction.getTransactionType().toString() === 'BUY');
|
|
16
|
+
assert(transaction.getDirectedQuantity().toNumber() > 0);
|
|
17
|
+
}
|
|
18
|
+
function dummyTransaction() {
|
|
19
|
+
return new transaction_1.default(new transaction_pb_1.TransactionProto()
|
|
20
|
+
.setObjectClass('Transaction').setVersion('0.0.1').setUuid(uuid_1.UUID.random().toUUIDProto())
|
|
21
|
+
.setTradeDate(new local_date_pb_1.LocalDateProto().setYear(2021).setMonth(1).setDay(1))
|
|
22
|
+
.setTransactionType(transaction_type_pb_1.TransactionTypeProto.BUY)
|
|
23
|
+
.setQuantity(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('1000.00'))
|
|
24
|
+
.setSettlementDate(new local_date_pb_1.LocalDateProto().setYear(2021).setMonth(1).setDay(1)));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=transaction.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.test.js","sourceRoot":"","sources":["transaction.test.ts"],"names":[],"mappings":";;AAAA,+EAA+E;AAG/E,sCAAqC;AAErC,+BAAkC;AAClC,6CAAwC;AACxC,wFAAyF;AACzF,kGAAkG;AAIlG,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;IAE9D,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"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
import { UUID } from '../utils/uuid';
|
|
5
|
+
|
|
6
|
+
import assert = require('assert');
|
|
7
|
+
import Transaction from './transaction';
|
|
8
|
+
import { TransactionProto } from '../../../fintekkers/models/transaction/transaction_pb';
|
|
9
|
+
import { TransactionTypeProto } from '../../../fintekkers/models/transaction/transaction_type_pb';
|
|
10
|
+
import { LocalTimestampProto } from '../../../fintekkers/models/util/local_timestamp_pb';
|
|
11
|
+
|
|
12
|
+
import { Timestamp } from '@grpc/grpc-js/build/src/generated/google/protobuf/Timestamp';
|
|
13
|
+
import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
|
|
14
|
+
import { PriceProto } from '../../../fintekkers/models/price/price_pb';
|
|
15
|
+
|
|
16
|
+
test('test the transaction wrapper', () => {
|
|
17
|
+
testSerialization();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function testSerialization(): void {
|
|
21
|
+
const transaction = dummyTransaction();
|
|
22
|
+
|
|
23
|
+
assert(transaction.getTransactionType().toString() === 'BUY');
|
|
24
|
+
|
|
25
|
+
assert(transaction.getDirectedQuantity().toNumber() > 0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function dummyTransaction() {
|
|
29
|
+
|
|
30
|
+
return new Transaction(new TransactionProto()
|
|
31
|
+
.setObjectClass('Transaction').setVersion('0.0.1').setUuid(UUID.random().toUUIDProto())
|
|
32
|
+
.setTradeDate(new LocalDateProto().setYear(2021).setMonth(1).setDay(1))
|
|
33
|
+
.setTransactionType(TransactionTypeProto.BUY)
|
|
34
|
+
.setQuantity(new DecimalValueProto().setArbitraryPrecisionValue('1000.00'))
|
|
35
|
+
.setSettlementDate(new LocalDateProto().setYear(2021).setMonth(1).setDay(1)));
|
|
36
|
+
}
|
|
37
|
+
|
|
@@ -3,6 +3,7 @@ import { FieldProto } from "../../../fintekkers/models/position/field_pb";
|
|
|
3
3
|
import { PositionStatusProto } from "../../../fintekkers/models/position/position_status_pb";
|
|
4
4
|
import { PriceProto } from "../../../fintekkers/models/price/price_pb";
|
|
5
5
|
import { IdentifierProto } from "../../../fintekkers/models/security/identifier/identifier_pb";
|
|
6
|
+
import { TransactionType } from "./transaction_type";
|
|
6
7
|
import { StrategyAllocationProto } from "../../../fintekkers/models/strategy/strategy_allocation_pb";
|
|
7
8
|
import { TransactionProto } from "../../../fintekkers/models/transaction/transaction_pb";
|
|
8
9
|
import { TransactionTypeProto } from "../../../fintekkers/models/transaction/transaction_type_pb";
|
|
@@ -10,6 +11,7 @@ import { LocalDateProto } from "../../../fintekkers/models/util/local_date_pb";
|
|
|
10
11
|
import Security from "../security/security";
|
|
11
12
|
import { ZonedDateTime } from "../utils/datetime";
|
|
12
13
|
import { UUID } from "../utils/uuid";
|
|
14
|
+
import { LocalDate } from "../utils/date";
|
|
13
15
|
import { Decimal } from "decimal.js";
|
|
14
16
|
|
|
15
17
|
class Transaction {
|
|
@@ -88,10 +90,6 @@ class Transaction {
|
|
|
88
90
|
return this.proto.getPrice();
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
getSettlementDate(): LocalDateProto {
|
|
92
|
-
return this.proto.getSettlementDate();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
93
|
getQuantity(): Decimal {
|
|
96
94
|
return new Decimal(this.proto.getQuantity().getArbitraryPrecisionValue());
|
|
97
95
|
}
|
|
@@ -100,16 +98,20 @@ class Transaction {
|
|
|
100
98
|
return this.getSecurity().getIssuerName();
|
|
101
99
|
}
|
|
102
100
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
getDirectedQuantity(): Decimal {
|
|
102
|
+
return this.getQuantity().mul(this.getTransactionType().getDirectionMultiplier());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
getTradeDate(): LocalDate {
|
|
106
|
+
return new LocalDate(this.proto.getTradeDate());
|
|
107
|
+
}
|
|
106
108
|
|
|
107
|
-
|
|
108
|
-
return this.proto.
|
|
109
|
+
getSettlementDate() : LocalDate {
|
|
110
|
+
return new LocalDate(this.proto.getSettlementDate());
|
|
109
111
|
}
|
|
110
112
|
|
|
111
|
-
getTransactionType() :
|
|
112
|
-
return this.getTransactionType();
|
|
113
|
+
getTransactionType() : TransactionType {
|
|
114
|
+
return new TransactionType(this.proto.getTransactionType());
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
getTradeName(): string {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionType = void 0;
|
|
4
|
+
var transaction_type_pb_1 = require("../../../fintekkers/models/transaction/transaction_type_pb");
|
|
5
|
+
var TransactionType = /** @class */ (function () {
|
|
6
|
+
function TransactionType(proto) {
|
|
7
|
+
this.proto = proto;
|
|
8
|
+
}
|
|
9
|
+
TransactionType.prototype.getDirectionMultiplier = function () {
|
|
10
|
+
switch (this.proto) {
|
|
11
|
+
case transaction_type_pb_1.TransactionTypeProto.BUY:
|
|
12
|
+
case transaction_type_pb_1.TransactionTypeProto.DEPOSIT:
|
|
13
|
+
case transaction_type_pb_1.TransactionTypeProto.MATURATION_OFFSET:
|
|
14
|
+
return 1;
|
|
15
|
+
case transaction_type_pb_1.TransactionTypeProto.SELL:
|
|
16
|
+
case transaction_type_pb_1.TransactionTypeProto.WITHDRAWAL:
|
|
17
|
+
case transaction_type_pb_1.TransactionTypeProto.MATURATION:
|
|
18
|
+
return -1;
|
|
19
|
+
case transaction_type_pb_1.TransactionTypeProto.UNKNOWN:
|
|
20
|
+
throw new Error('Unknown transaction type: ' + this.toString());
|
|
21
|
+
;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* NOTE that this method is not performant and should only be used for debugging purposes,
|
|
26
|
+
* or infrequently. If this is required for a high performance use case, please create a
|
|
27
|
+
* reverse map with the enum ID as the key and the enum desriptor as the value. There is
|
|
28
|
+
* nothing stopping this code from returning a value that does not map exactly to the enum
|
|
29
|
+
* value. E.g. rather than BUY, you could return Buy.
|
|
30
|
+
*
|
|
31
|
+
* @returns TransactionType as a string
|
|
32
|
+
*/
|
|
33
|
+
TransactionType.prototype.toString = function () {
|
|
34
|
+
return TransactionType.ttEnumMap.get(this.proto);
|
|
35
|
+
};
|
|
36
|
+
return TransactionType;
|
|
37
|
+
}());
|
|
38
|
+
exports.TransactionType = TransactionType;
|
|
39
|
+
(function () {
|
|
40
|
+
TransactionType.ttEnumMap = new Map();
|
|
41
|
+
Object.keys(transaction_type_pb_1.TransactionTypeProto).forEach(function (key) {
|
|
42
|
+
TransactionType.ttEnumMap.set(transaction_type_pb_1.TransactionTypeProto[key], key);
|
|
43
|
+
});
|
|
44
|
+
})();
|
|
45
|
+
//# sourceMappingURL=transaction_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction_type.js","sourceRoot":"","sources":["transaction_type.ts"],"names":[],"mappings":";;;AAAA,kGAAkG;AAElG;IAGI,yBAAY,KAA2B;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAYH,gDAAsB,GAAtB;QACI,QAAQ,IAAI,CAAC,KAAK,EAAE;YAChB,KAAK,0CAAoB,CAAC,GAAG,CAAC;YAC9B,KAAK,0CAAoB,CAAC,OAAO,CAAC;YAClC,KAAK,0CAAoB,CAAC,iBAAiB;gBACvC,OAAO,CAAC,CAAC;YACb,KAAK,0CAAoB,CAAC,IAAI,CAAC;YAC/B,KAAK,0CAAoB,CAAC,UAAU,CAAC;YACrC,KAAK,0CAAoB,CAAC,UAAU;gBAChC,OAAO,CAAC,CAAC,CAAC;YACd,KAAK,0CAAoB,CAAC,OAAO;gBAC7B,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAAE,CAAC;SACxE;IACL,CAAC;IAED;;;;;;;;OAQG;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"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TransactionTypeProto } from "../../../fintekkers/models/transaction/transaction_type_pb";
|
|
2
|
+
|
|
3
|
+
export class TransactionType {
|
|
4
|
+
proto: TransactionTypeProto;
|
|
5
|
+
|
|
6
|
+
constructor(proto: TransactionTypeProto) {
|
|
7
|
+
this.proto = proto;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static ttEnumMap: Map<number, string>;
|
|
11
|
+
|
|
12
|
+
static {
|
|
13
|
+
TransactionType.ttEnumMap = new Map<number, string>();
|
|
14
|
+
|
|
15
|
+
Object.keys(TransactionTypeProto).forEach(key => {
|
|
16
|
+
TransactionType.ttEnumMap.set(TransactionTypeProto[key], key);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getDirectionMultiplier(): number {
|
|
21
|
+
switch (this.proto) {
|
|
22
|
+
case TransactionTypeProto.BUY:
|
|
23
|
+
case TransactionTypeProto.DEPOSIT:
|
|
24
|
+
case TransactionTypeProto.MATURATION_OFFSET:
|
|
25
|
+
return 1;
|
|
26
|
+
case TransactionTypeProto.SELL:
|
|
27
|
+
case TransactionTypeProto.WITHDRAWAL:
|
|
28
|
+
case TransactionTypeProto.MATURATION:
|
|
29
|
+
return -1;
|
|
30
|
+
case TransactionTypeProto.UNKNOWN:
|
|
31
|
+
throw new Error('Unknown transaction type: '+this.toString()); );
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* NOTE that this method is not performant and should only be used for debugging purposes,
|
|
37
|
+
* or infrequently. If this is required for a high performance use case, please create a
|
|
38
|
+
* reverse map with the enum ID as the key and the enum desriptor as the value. There is
|
|
39
|
+
* nothing stopping this code from returning a value that does not map exactly to the enum
|
|
40
|
+
* value. E.g. rather than BUY, you could return Buy.
|
|
41
|
+
*
|
|
42
|
+
* @returns TransactionType as a string
|
|
43
|
+
*/
|
|
44
|
+
toString() : string {
|
|
45
|
+
return TransactionType.ttEnumMap.get(this.proto);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalDate = void 0;
|
|
4
|
+
var local_date_pb_1 = require("../../../fintekkers/models/util/local_date_pb");
|
|
5
|
+
var LocalDate = /** @class */ (function () {
|
|
6
|
+
function LocalDate(proto) {
|
|
7
|
+
this.proto = proto;
|
|
8
|
+
}
|
|
9
|
+
LocalDate.prototype.toDate = function () {
|
|
10
|
+
return new Date(this.proto.getYear(), this.proto.getMonth(), this.proto.getDay());
|
|
11
|
+
};
|
|
12
|
+
LocalDate.prototype.toString = function () {
|
|
13
|
+
return this.proto.getYear() + '-' + this.proto.getMonth() + '-' + this.proto.getDay();
|
|
14
|
+
};
|
|
15
|
+
LocalDate.prototype.toProto = function () {
|
|
16
|
+
return this.proto;
|
|
17
|
+
};
|
|
18
|
+
LocalDate.today = function () {
|
|
19
|
+
var today = new Date();
|
|
20
|
+
return new LocalDate(new local_date_pb_1.LocalDateProto().setYear(today.getFullYear()).setMonth(today.getMonth()).setDay(today.getDate()));
|
|
21
|
+
};
|
|
22
|
+
return LocalDate;
|
|
23
|
+
}());
|
|
24
|
+
exports.LocalDate = LocalDate;
|
|
25
|
+
//# sourceMappingURL=date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["date.ts"],"names":[],"mappings":";;;AACA,+EAA+E;AAE/E;IAGE,mBAAY,KAAqB;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,0BAAM,GAAN;QACE,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACpF,CAAC;IAED,4BAAQ,GAAR;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IACxF,CAAC;IAED,2BAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEM,eAAK,GAAZ;QACE,IAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;QACzB,OAAO,IAAI,SAAS,CAClB,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CACrG,CAAC;IACJ,CAAC;IACH,gBAAC;AAAD,CAAC,AAzBD,IAyBC;AAEQ,8BAAS"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { assert } from 'console';
|
|
2
|
+
import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
|
|
3
|
+
|
|
4
|
+
class LocalDate {
|
|
5
|
+
private proto: LocalDateProto;
|
|
6
|
+
|
|
7
|
+
constructor(proto: LocalDateProto) {
|
|
8
|
+
this.proto = proto;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
toDate(): Date {
|
|
12
|
+
return new Date(this.proto.getYear(), this.proto.getMonth(), this.proto.getDay());
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
toString(): string {
|
|
16
|
+
return this.proto.getYear() + '-' + this.proto.getMonth() + '-' + this.proto.getDay();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
toProto(): LocalDateProto {
|
|
20
|
+
return this.proto;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static today(): LocalDate {
|
|
24
|
+
const today = new Date();
|
|
25
|
+
return new LocalDate(
|
|
26
|
+
new LocalDateProto().setYear(today.getFullYear()).setMonth(today.getMonth()).setDay(today.getDate())
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { LocalDate };
|
|
@@ -9,7 +9,7 @@ var ZonedDateTime = /** @class */ (function () {
|
|
|
9
9
|
function ZonedDateTime(proto) {
|
|
10
10
|
this.proto = proto;
|
|
11
11
|
}
|
|
12
|
-
ZonedDateTime.prototype.
|
|
12
|
+
ZonedDateTime.prototype.toDateTime = function () {
|
|
13
13
|
// Creating a DateTime object with the current date and time in a specific time zone (e.g., 'America/New_York')
|
|
14
14
|
var unixTimestampSeconds = this.proto.getTimestamp().getSeconds();
|
|
15
15
|
var nanoseconds = this.proto.getTimestamp().getNanos();
|
|
@@ -19,9 +19,9 @@ var ZonedDateTime = /** @class */ (function () {
|
|
|
19
19
|
return dateTime;
|
|
20
20
|
};
|
|
21
21
|
ZonedDateTime.prototype.toString = function () {
|
|
22
|
-
return this.
|
|
22
|
+
return this.toDateTime().toString();
|
|
23
23
|
};
|
|
24
|
-
ZonedDateTime.prototype.
|
|
24
|
+
ZonedDateTime.prototype.toProto = function () {
|
|
25
25
|
return this.proto;
|
|
26
26
|
};
|
|
27
27
|
ZonedDateTime.now = function () {
|
|
@@ -59,5 +59,5 @@ exports.ZonedDateTime = ZonedDateTime;
|
|
|
59
59
|
// }
|
|
60
60
|
// ZonedDateTime.now = createTimestampWithCurrentTime;
|
|
61
61
|
var now = ZonedDateTime.now();
|
|
62
|
-
(0, console_1.assert)(now.
|
|
62
|
+
(0, console_1.assert)(now.toDateTime().toString() === now.toString());
|
|
63
63
|
//# sourceMappingURL=datetime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datetime.js","sourceRoot":"","sources":["datetime.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AACjC,yFAAyF;AACzF,6EAAyE;AACzE,+BAAiC;AAEjC;IAGE,uBAAY,KAA0B;QACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,
|
|
1
|
+
{"version":3,"file":"datetime.js","sourceRoot":"","sources":["datetime.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AACjC,yFAAyF;AACzF,6EAAyE;AACzE,+BAAiC;AAEjC;IAGE,uBAAY,KAA0B;QACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,kCAAU,GAAV;QACE,+GAA+G;QAC/G,IAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpE,IAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,QAAQ,EAAE,CAAC;QAEzD,IAAI,QAAQ,GAAG,gBAAQ,CAAC,WAAW,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAE9F,gDAAgD;QAChD,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;QAC5E,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,gCAAQ,GAAR;QACE,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IAED,+BAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEM,iBAAG,GAAV;QACE,8EAA8E;QAC9E,IAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAErC,kDAAkD;QAClD,IAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;QACrD,IAAM,KAAK,GAAG,CAAC,iBAAiB,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,kCAAkC;QAElF,sDAAsD;QACtD,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,AA9CD,IA8CC;AA0BQ,sCAAa;AAxBtB,6DAA6D;AAC7D,mFAAmF;AACnF,0CAA0C;AAE1C,uDAAuD;AACvD,0DAA0D;AAC1D,uFAAuF;AAEvF,2DAA2D;AAC3D,uCAAuC;AACvC,mCAAmC;AACnC,+BAA+B;AAE/B,sDAAsD;AACtD,oDAAoD;AACpD,4CAA4C;AAE5C,8CAA8C;AAC9C,IAAI;AAEJ,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,7 +10,7 @@ class ZonedDateTime {
|
|
|
10
10
|
this.proto = proto;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
toDateTime(): DateTime {
|
|
14
14
|
// Creating a DateTime object with the current date and time in a specific time zone (e.g., 'America/New_York')
|
|
15
15
|
const unixTimestampSeconds = this.proto.getTimestamp().getSeconds();
|
|
16
16
|
const nanoseconds = this.proto.getTimestamp().getNanos();
|
|
@@ -23,10 +23,10 @@ class ZonedDateTime {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
toString(): string {
|
|
26
|
-
return this.
|
|
26
|
+
return this.toDateTime().toString();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
toProto(): LocalTimestampProto {
|
|
30
30
|
return this.proto;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -73,6 +73,6 @@ class ZonedDateTime {
|
|
|
73
73
|
|
|
74
74
|
// ZonedDateTime.now = createTimestampWithCurrentTime;
|
|
75
75
|
const now = ZonedDateTime.now();
|
|
76
|
-
assert(now.
|
|
76
|
+
assert(now.toDateTime().toString() === now.toString());
|
|
77
77
|
|
|
78
78
|
export { ZonedDateTime };
|