@fintekkers/ledger-models 0.1.60 → 0.1.62
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/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/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/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 +12 -10
- 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 +36 -0
- package/node/wrappers/models/transaction/transaction.ts +15 -13
- package/node/wrappers/models/transaction/transaction_type.js +44 -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/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 +6 -4
- package/node/wrappers/models/utils/serialization.js.map +1 -1
- package/node/wrappers/models/utils/serialization.test.js +13 -54
- package/node/wrappers/models/utils/serialization.test.js.map +1 -1
- package/node/wrappers/models/utils/serialization.test.ts +12 -10
- package/node/wrappers/models/utils/serialization.ts +8 -8
- package/node/wrappers/models/utils/serialization.util.js +76 -0
- package/node/wrappers/models/utils/serialization.util.js.map +1 -0
- package/node/wrappers/models/utils/serialization.util.test.js +24 -0
- package/node/wrappers/models/utils/serialization.util.test.js.map +1 -0
- package/node/wrappers/models/utils/serialization.util.test.ts +29 -0
- package/node/wrappers/models/utils/serialization.util.ts +85 -0
- package/node/wrappers/services/portfolio-service/PortfolioService.js +5 -8
- package/node/wrappers/services/portfolio-service/PortfolioService.js.map +1 -1
- package/node/wrappers/services/portfolio-service/PortfolioService.ts +5 -6
- package/node/wrappers/{portfolio.test.js → services/portfolio-service/portfolio.test.js} +12 -11
- package/node/wrappers/services/portfolio-service/portfolio.test.js.map +1 -0
- package/node/wrappers/services/portfolio-service/portfolio.test.ts +40 -0
- package/node/wrappers/services/position-service/PositionService.js +4 -6
- package/node/wrappers/services/position-service/PositionService.js.map +1 -1
- package/node/wrappers/services/position-service/PositionService.ts +4 -22
- package/node/wrappers/{position.test.js → services/position-service/position.test.js} +28 -22
- package/node/wrappers/services/position-service/position.test.js.map +1 -0
- package/node/wrappers/{position.test.ts → services/position-service/position.test.ts} +25 -29
- package/node/wrappers/services/security-service/SecurityService.js +4 -8
- package/node/wrappers/services/security-service/SecurityService.js.map +1 -1
- package/node/wrappers/services/security-service/SecurityService.ts +3 -6
- package/node/wrappers/{security.test.js → services/security-service/security.test.js} +26 -19
- package/node/wrappers/services/security-service/security.test.js.map +1 -0
- package/node/wrappers/{security.test.ts → services/security-service/security.test.ts} +22 -20
- package/node/wrappers/services/transaction-service/TransactionService.js +40 -50
- package/node/wrappers/services/transaction-service/TransactionService.js.map +1 -1
- package/node/wrappers/services/transaction-service/TransactionService.ts +13 -15
- package/node/wrappers/{transaction.test.js → services/transaction-service/transaction.test.js} +41 -25
- package/node/wrappers/services/transaction-service/transaction.test.js.map +1 -0
- package/node/wrappers/services/transaction-service/transaction.test.ts +97 -0
- package/package.json +4 -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
- package/node/wrappers/portfolio.test.js.map +0 -1
- package/node/wrappers/portfolio.test.ts +0 -36
- 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/node/wrappers/transaction.test.ts +0 -90
|
@@ -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;QAC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K,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
|
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
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
|
+
assert(transaction.getDirectedQuantity().toNumber() > 0);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function dummyTransaction() {
|
|
28
|
+
|
|
29
|
+
return new Transaction(new TransactionProto()
|
|
30
|
+
.setObjectClass('Transaction').setVersion('0.0.1').setUuid(UUID.random().toUUIDProto())
|
|
31
|
+
.setTradeDate(new LocalDateProto().setYear(2021).setMonth(1).setDay(1))
|
|
32
|
+
.setTransactionType(TransactionTypeProto.BUY)
|
|
33
|
+
.setQuantity(new DecimalValueProto().setArbitraryPrecisionValue('1000.00'))
|
|
34
|
+
.setSettlementDate(new LocalDateProto().setYear(2021).setMonth(1).setDay(1)));
|
|
35
|
+
}
|
|
36
|
+
|
|
@@ -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 {
|
|
@@ -34,11 +36,11 @@ class Transaction {
|
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
getFields(): FieldProto[] {
|
|
38
40
|
return [FieldProto.ID, FieldProto.SECURITY_ID, FieldProto.AS_OF, FieldProto.ASSET_CLASS, FieldProto.IDENTIFIER];
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
getField(field: FieldProto): any {
|
|
42
44
|
switch (field) {
|
|
43
45
|
case FieldProto.ID:
|
|
44
46
|
case FieldProto.SECURITY_ID:
|
|
@@ -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,44 @@
|
|
|
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
|
+
* NOTE that this method is not performant and should only be used for debugging purposes,
|
|
25
|
+
* or infrequently. If this is required for a high performance use case, please create a
|
|
26
|
+
* reverse map with the enum ID as the key and the enum desriptor as the value. There is
|
|
27
|
+
* nothing stopping this code from returning a value that does not map exactly to the enum
|
|
28
|
+
* value. E.g. rather than BUY, you could return Buy.
|
|
29
|
+
*
|
|
30
|
+
* @returns TransactionType as a string
|
|
31
|
+
*/
|
|
32
|
+
TransactionType.prototype.toString = function () {
|
|
33
|
+
return TransactionType.ttEnumMap.get(this.proto);
|
|
34
|
+
};
|
|
35
|
+
return TransactionType;
|
|
36
|
+
}());
|
|
37
|
+
exports.TransactionType = TransactionType;
|
|
38
|
+
(function () {
|
|
39
|
+
TransactionType.ttEnumMap = new Map();
|
|
40
|
+
Object.keys(transaction_type_pb_1.TransactionTypeProto).forEach(function (key) {
|
|
41
|
+
TransactionType.ttEnumMap.set(transaction_type_pb_1.TransactionTypeProto[key], key);
|
|
42
|
+
});
|
|
43
|
+
})();
|
|
44
|
+
//# 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;SACrE;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,K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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 };
|
|
@@ -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":""}
|
|
@@ -14,9 +14,9 @@ var ProtoSerializationUtil = /** @class */ (function () {
|
|
|
14
14
|
}
|
|
15
15
|
if (obj instanceof Date) {
|
|
16
16
|
return new local_date_pb_1.LocalDateProto()
|
|
17
|
-
.setYear(obj.
|
|
18
|
-
.setMonth(obj.
|
|
19
|
-
.setDay(obj.
|
|
17
|
+
.setYear(obj.getFullYear())
|
|
18
|
+
.setMonth(obj.getMonth() + 1)
|
|
19
|
+
.setDay(obj.getDate());
|
|
20
20
|
}
|
|
21
21
|
if (typeof obj === "number") {
|
|
22
22
|
return new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue(obj.toString());
|
|
@@ -28,7 +28,9 @@ var ProtoSerializationUtil = /** @class */ (function () {
|
|
|
28
28
|
return uuid_1.UUID.fromU8Array(obj.getRawUuid_asU8());
|
|
29
29
|
}
|
|
30
30
|
if (obj instanceof local_date_pb_1.LocalDateProto) {
|
|
31
|
-
|
|
31
|
+
var date = new Date(obj.getYear(), obj.getMonth() - 1, obj.getDay());
|
|
32
|
+
date.setHours(0, 0, 0, 0);
|
|
33
|
+
return date;
|
|
32
34
|
}
|
|
33
35
|
if (obj.enum_name && obj.enum_name === "TRANSACTION_TYPE") {
|
|
34
36
|
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,mEAAoE;AACpE,+BAA8B;AAO5B;IAAA;IAoCA,CAAC;IAnCQ,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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IAoCC;AApCY,wDAAsB"}
|
|
@@ -1,64 +1,23 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.testSerialization = void 0;
|
|
40
3
|
var serialization_1 = require("./serialization");
|
|
41
4
|
var uuid_1 = require("./uuid");
|
|
42
5
|
var assert = require("assert");
|
|
6
|
+
test('test serialization of key types', function () {
|
|
7
|
+
testSerialization();
|
|
8
|
+
});
|
|
43
9
|
function testSerialization() {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
console.log(serializedTimestamp);
|
|
55
|
-
deserializedTimestamp = serialization_1.ProtoSerializationUtil.deserialize(serializedTimestamp);
|
|
56
|
-
console.log(deserializedTimestamp);
|
|
57
|
-
return [2 /*return*/];
|
|
58
|
-
});
|
|
59
|
-
});
|
|
10
|
+
checkUUID();
|
|
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
|
+
var deserializedDate = serialization_1.ProtoSerializationUtil.deserialize(serializedDate);
|
|
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);
|
|
18
|
+
var deserializedTimestamp = serialization_1.ProtoSerializationUtil.deserialize(serializedTimestamp);
|
|
19
|
+
assert(deserializedTimestamp.toString().indexOf('Mar 05 2023') > -1);
|
|
60
20
|
}
|
|
61
|
-
exports.testSerialization = testSerialization;
|
|
62
21
|
function checkUUID() {
|
|
63
22
|
var uuid = uuid_1.UUID.random();
|
|
64
23
|
var serializedUUID = serialization_1.ProtoSerializationUtil.serialize(uuid);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.test.js","sourceRoot":"","sources":["serialization.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serialization.test.js","sourceRoot":"","sources":["serialization.test.ts"],"names":[],"mappings":";;AAEA,iDAAyD;AACzD,+BAA8B;AAE9B,+BAAkC;AAClC,IAAI,CAAC,iCAAiC,EAAE;IACpC,iBAAiB,EAAE,CAAC;AACtB,CAAC,CAAC,CAAC;AAEL,SAAS,iBAAiB;IACtB,SAAS,EAAE,CAAC;IAEZ,IAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,uCAAuC;IAC/E,IAAM,cAAc,GAAQ,sCAAsB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACxE,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAE3D,IAAM,gBAAgB,GAAQ,sCAAsB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IACjF,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,aAAa,CAA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