@fintekkers/ledger-models 0.1.132 → 0.1.133
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/node/fintekkers/models/security/security_pb.d.ts +6 -0
- package/node/fintekkers/models/security/security_pb.js +51 -0
- package/node/fintekkers/requests/price/query_price_request_pb.d.ts +3 -0
- package/node/fintekkers/requests/price/query_price_request_pb.js +31 -1
- package/node/fintekkers/requests/price/query_price_response_pb.d.ts +7 -0
- package/node/fintekkers/requests/price/query_price_response_pb.js +54 -1
- package/node/wrappers/models/security/BondSecurity.d.ts +8 -0
- package/node/wrappers/models/security/BondSecurity.js +13 -0
- package/node/wrappers/models/security/BondSecurity.js.map +1 -1
- package/node/wrappers/models/security/BondSecurity.ts +13 -0
- package/node/wrappers/models/security/identifier.d.ts +26 -0
- package/node/wrappers/models/security/identifier.js +39 -0
- package/node/wrappers/models/security/identifier.js.map +1 -1
- package/node/wrappers/models/security/identifier.test.js +62 -0
- package/node/wrappers/models/security/identifier.test.js.map +1 -1
- package/node/wrappers/models/security/identifier.test.ts +70 -0
- package/node/wrappers/models/security/identifier.ts +44 -0
- package/node/wrappers/models/security/security.d.ts +36 -1
- package/node/wrappers/models/security/security.js +45 -2
- package/node/wrappers/models/security/security.js.map +1 -1
- package/node/wrappers/models/security/security.test.js +72 -0
- package/node/wrappers/models/security/security.test.js.map +1 -1
- package/node/wrappers/models/security/security.test.ts +80 -0
- package/node/wrappers/models/security/security.ts +47 -3
- package/package.json +1 -1
|
@@ -46,6 +46,11 @@ export class SecurityProto extends jspb.Message {
|
|
|
46
46
|
setValidTo(value?: fintekkers_models_util_local_timestamp_pb.LocalTimestampProto): SecurityProto;
|
|
47
47
|
getSecurityType(): fintekkers_models_security_security_type_pb.SecurityTypeProto;
|
|
48
48
|
setSecurityType(value: fintekkers_models_security_security_type_pb.SecurityTypeProto): SecurityProto;
|
|
49
|
+
|
|
50
|
+
hasDeletedAt(): boolean;
|
|
51
|
+
clearDeletedAt(): void;
|
|
52
|
+
getDeletedAt(): fintekkers_models_util_local_timestamp_pb.LocalTimestampProto | undefined;
|
|
53
|
+
setDeletedAt(value?: fintekkers_models_util_local_timestamp_pb.LocalTimestampProto): SecurityProto;
|
|
49
54
|
getAssetClass(): string;
|
|
50
55
|
setAssetClass(value: string): SecurityProto;
|
|
51
56
|
getIssuerName(): string;
|
|
@@ -184,6 +189,7 @@ export namespace SecurityProto {
|
|
|
184
189
|
validFrom?: fintekkers_models_util_local_timestamp_pb.LocalTimestampProto.AsObject,
|
|
185
190
|
validTo?: fintekkers_models_util_local_timestamp_pb.LocalTimestampProto.AsObject,
|
|
186
191
|
securityType: fintekkers_models_security_security_type_pb.SecurityTypeProto,
|
|
192
|
+
deletedAt?: fintekkers_models_util_local_timestamp_pb.LocalTimestampProto.AsObject,
|
|
187
193
|
assetClass: string,
|
|
188
194
|
issuerName: string,
|
|
189
195
|
settlementCurrency?: SecurityProto.AsObject,
|
|
@@ -298,6 +298,7 @@ proto.fintekkers.models.security.SecurityProto.toObject = function(includeInstan
|
|
|
298
298
|
validFrom: (f = msg.getValidFrom()) && fintekkers_models_util_local_timestamp_pb.LocalTimestampProto.toObject(includeInstance, f),
|
|
299
299
|
validTo: (f = msg.getValidTo()) && fintekkers_models_util_local_timestamp_pb.LocalTimestampProto.toObject(includeInstance, f),
|
|
300
300
|
securityType: jspb.Message.getFieldWithDefault(msg, 10, 0),
|
|
301
|
+
deletedAt: (f = msg.getDeletedAt()) && fintekkers_models_util_local_timestamp_pb.LocalTimestampProto.toObject(includeInstance, f),
|
|
301
302
|
assetClass: jspb.Message.getFieldWithDefault(msg, 11, ""),
|
|
302
303
|
issuerName: jspb.Message.getFieldWithDefault(msg, 12, ""),
|
|
303
304
|
settlementCurrency: (f = msg.getSettlementCurrency()) && proto.fintekkers.models.security.SecurityProto.toObject(includeInstance, f),
|
|
@@ -402,6 +403,11 @@ proto.fintekkers.models.security.SecurityProto.deserializeBinaryFromReader = fun
|
|
|
402
403
|
var value = /** @type {!proto.fintekkers.models.security.SecurityTypeProto} */ (reader.readEnum());
|
|
403
404
|
msg.setSecurityType(value);
|
|
404
405
|
break;
|
|
406
|
+
case 15:
|
|
407
|
+
var value = new fintekkers_models_util_local_timestamp_pb.LocalTimestampProto;
|
|
408
|
+
reader.readMessage(value,fintekkers_models_util_local_timestamp_pb.LocalTimestampProto.deserializeBinaryFromReader);
|
|
409
|
+
msg.setDeletedAt(value);
|
|
410
|
+
break;
|
|
405
411
|
case 11:
|
|
406
412
|
var value = /** @type {string} */ (reader.readString());
|
|
407
413
|
msg.setAssetClass(value);
|
|
@@ -630,6 +636,14 @@ proto.fintekkers.models.security.SecurityProto.serializeBinaryToWriter = functio
|
|
|
630
636
|
f
|
|
631
637
|
);
|
|
632
638
|
}
|
|
639
|
+
f = message.getDeletedAt();
|
|
640
|
+
if (f != null) {
|
|
641
|
+
writer.writeMessage(
|
|
642
|
+
15,
|
|
643
|
+
f,
|
|
644
|
+
fintekkers_models_util_local_timestamp_pb.LocalTimestampProto.serializeBinaryToWriter
|
|
645
|
+
);
|
|
646
|
+
}
|
|
633
647
|
f = message.getAssetClass();
|
|
634
648
|
if (f.length > 0) {
|
|
635
649
|
writer.writeString(
|
|
@@ -1082,6 +1096,43 @@ proto.fintekkers.models.security.SecurityProto.prototype.setSecurityType = funct
|
|
|
1082
1096
|
};
|
|
1083
1097
|
|
|
1084
1098
|
|
|
1099
|
+
/**
|
|
1100
|
+
* optional fintekkers.models.util.LocalTimestampProto deleted_at = 15;
|
|
1101
|
+
* @return {?proto.fintekkers.models.util.LocalTimestampProto}
|
|
1102
|
+
*/
|
|
1103
|
+
proto.fintekkers.models.security.SecurityProto.prototype.getDeletedAt = function() {
|
|
1104
|
+
return /** @type{?proto.fintekkers.models.util.LocalTimestampProto} */ (
|
|
1105
|
+
jspb.Message.getWrapperField(this, fintekkers_models_util_local_timestamp_pb.LocalTimestampProto, 15));
|
|
1106
|
+
};
|
|
1107
|
+
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* @param {?proto.fintekkers.models.util.LocalTimestampProto|undefined} value
|
|
1111
|
+
* @return {!proto.fintekkers.models.security.SecurityProto} returns this
|
|
1112
|
+
*/
|
|
1113
|
+
proto.fintekkers.models.security.SecurityProto.prototype.setDeletedAt = function(value) {
|
|
1114
|
+
return jspb.Message.setWrapperField(this, 15, value);
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* Clears the message field making it undefined.
|
|
1120
|
+
* @return {!proto.fintekkers.models.security.SecurityProto} returns this
|
|
1121
|
+
*/
|
|
1122
|
+
proto.fintekkers.models.security.SecurityProto.prototype.clearDeletedAt = function() {
|
|
1123
|
+
return this.setDeletedAt(undefined);
|
|
1124
|
+
};
|
|
1125
|
+
|
|
1126
|
+
|
|
1127
|
+
/**
|
|
1128
|
+
* Returns whether this field is set.
|
|
1129
|
+
* @return {boolean}
|
|
1130
|
+
*/
|
|
1131
|
+
proto.fintekkers.models.security.SecurityProto.prototype.hasDeletedAt = function() {
|
|
1132
|
+
return jspb.Message.getField(this, 15) != null;
|
|
1133
|
+
};
|
|
1134
|
+
|
|
1135
|
+
|
|
1085
1136
|
/**
|
|
1086
1137
|
* optional string asset_class = 11;
|
|
1087
1138
|
* @return {string}
|
|
@@ -41,6 +41,8 @@ export class QueryPriceRequestProto extends jspb.Message {
|
|
|
41
41
|
clearDateRange(): void;
|
|
42
42
|
getDateRange(): fintekkers_models_util_date_range_pb.DateRangeProto | undefined;
|
|
43
43
|
setDateRange(value?: fintekkers_models_util_date_range_pb.DateRangeProto): QueryPriceRequestProto;
|
|
44
|
+
getLimit(): number;
|
|
45
|
+
setLimit(value: number): QueryPriceRequestProto;
|
|
44
46
|
|
|
45
47
|
getTimeRangeCase(): QueryPriceRequestProto.TimeRangeCase;
|
|
46
48
|
|
|
@@ -64,6 +66,7 @@ export namespace QueryPriceRequestProto {
|
|
|
64
66
|
frequency: PriceFrequencyProto,
|
|
65
67
|
horizon: PriceHorizonProto,
|
|
66
68
|
dateRange?: fintekkers_models_util_date_range_pb.DateRangeProto.AsObject,
|
|
69
|
+
limit: number,
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
export enum TimeRangeCase {
|
|
@@ -127,7 +127,8 @@ proto.fintekkers.requests.price.QueryPriceRequestProto.toObject = function(inclu
|
|
|
127
127
|
asOf: (f = msg.getAsOf()) && fintekkers_models_util_local_timestamp_pb.LocalTimestampProto.toObject(includeInstance, f),
|
|
128
128
|
frequency: jspb.Message.getFieldWithDefault(msg, 24, 0),
|
|
129
129
|
horizon: jspb.Message.getFieldWithDefault(msg, 25, 0),
|
|
130
|
-
dateRange: (f = msg.getDateRange()) && fintekkers_models_util_date_range_pb.DateRangeProto.toObject(includeInstance, f)
|
|
130
|
+
dateRange: (f = msg.getDateRange()) && fintekkers_models_util_date_range_pb.DateRangeProto.toObject(includeInstance, f),
|
|
131
|
+
limit: jspb.Message.getFieldWithDefault(msg, 27, 0)
|
|
131
132
|
};
|
|
132
133
|
|
|
133
134
|
if (includeInstance) {
|
|
@@ -200,6 +201,10 @@ proto.fintekkers.requests.price.QueryPriceRequestProto.deserializeBinaryFromRead
|
|
|
200
201
|
reader.readMessage(value,fintekkers_models_util_date_range_pb.DateRangeProto.deserializeBinaryFromReader);
|
|
201
202
|
msg.setDateRange(value);
|
|
202
203
|
break;
|
|
204
|
+
case 27:
|
|
205
|
+
var value = /** @type {number} */ (reader.readInt32());
|
|
206
|
+
msg.setLimit(value);
|
|
207
|
+
break;
|
|
203
208
|
default:
|
|
204
209
|
reader.skipField();
|
|
205
210
|
break;
|
|
@@ -289,6 +294,13 @@ proto.fintekkers.requests.price.QueryPriceRequestProto.serializeBinaryToWriter =
|
|
|
289
294
|
fintekkers_models_util_date_range_pb.DateRangeProto.serializeBinaryToWriter
|
|
290
295
|
);
|
|
291
296
|
}
|
|
297
|
+
f = message.getLimit();
|
|
298
|
+
if (f !== 0) {
|
|
299
|
+
writer.writeInt32(
|
|
300
|
+
27,
|
|
301
|
+
f
|
|
302
|
+
);
|
|
303
|
+
}
|
|
292
304
|
};
|
|
293
305
|
|
|
294
306
|
|
|
@@ -531,6 +543,24 @@ proto.fintekkers.requests.price.QueryPriceRequestProto.prototype.hasDateRange =
|
|
|
531
543
|
};
|
|
532
544
|
|
|
533
545
|
|
|
546
|
+
/**
|
|
547
|
+
* optional int32 limit = 27;
|
|
548
|
+
* @return {number}
|
|
549
|
+
*/
|
|
550
|
+
proto.fintekkers.requests.price.QueryPriceRequestProto.prototype.getLimit = function() {
|
|
551
|
+
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 27, 0));
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* @param {number} value
|
|
557
|
+
* @return {!proto.fintekkers.requests.price.QueryPriceRequestProto} returns this
|
|
558
|
+
*/
|
|
559
|
+
proto.fintekkers.requests.price.QueryPriceRequestProto.prototype.setLimit = function(value) {
|
|
560
|
+
return jspb.Message.setProto3IntField(this, 27, value);
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
|
|
534
564
|
/**
|
|
535
565
|
* @enum {number}
|
|
536
566
|
*/
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import * as jspb from "google-protobuf";
|
|
8
8
|
import * as fintekkers_models_price_price_pb from "../../../fintekkers/models/price/price_pb";
|
|
9
9
|
import * as fintekkers_requests_price_query_price_request_pb from "../../../fintekkers/requests/price/query_price_request_pb";
|
|
10
|
+
import * as fintekkers_requests_util_errors_summary_pb from "../../../fintekkers/requests/util/errors/summary_pb";
|
|
10
11
|
|
|
11
12
|
export class QueryPriceResponseProto extends jspb.Message {
|
|
12
13
|
getObjectClass(): string;
|
|
@@ -23,6 +24,11 @@ export class QueryPriceResponseProto extends jspb.Message {
|
|
|
23
24
|
setPriceResponseList(value: Array<fintekkers_models_price_price_pb.PriceProto>): QueryPriceResponseProto;
|
|
24
25
|
addPriceResponse(value?: fintekkers_models_price_price_pb.PriceProto, index?: number): fintekkers_models_price_price_pb.PriceProto;
|
|
25
26
|
|
|
27
|
+
hasErrorsOrWarnings(): boolean;
|
|
28
|
+
clearErrorsOrWarnings(): void;
|
|
29
|
+
getErrorsOrWarnings(): fintekkers_requests_util_errors_summary_pb.SummaryProto | undefined;
|
|
30
|
+
setErrorsOrWarnings(value?: fintekkers_requests_util_errors_summary_pb.SummaryProto): QueryPriceResponseProto;
|
|
31
|
+
|
|
26
32
|
serializeBinary(): Uint8Array;
|
|
27
33
|
toObject(includeInstance?: boolean): QueryPriceResponseProto.AsObject;
|
|
28
34
|
static toObject(includeInstance: boolean, msg: QueryPriceResponseProto): QueryPriceResponseProto.AsObject;
|
|
@@ -39,5 +45,6 @@ export namespace QueryPriceResponseProto {
|
|
|
39
45
|
version: string,
|
|
40
46
|
queryPriceRequest?: fintekkers_requests_price_query_price_request_pb.QueryPriceRequestProto.AsObject,
|
|
41
47
|
priceResponseList: Array<fintekkers_models_price_price_pb.PriceProto.AsObject>,
|
|
48
|
+
errorsOrWarnings?: fintekkers_requests_util_errors_summary_pb.SummaryProto.AsObject,
|
|
42
49
|
}
|
|
43
50
|
}
|
|
@@ -25,6 +25,8 @@ var fintekkers_models_price_price_pb = require('../../../fintekkers/models/price
|
|
|
25
25
|
goog.object.extend(proto, fintekkers_models_price_price_pb);
|
|
26
26
|
var fintekkers_requests_price_query_price_request_pb = require('../../../fintekkers/requests/price/query_price_request_pb.js');
|
|
27
27
|
goog.object.extend(proto, fintekkers_requests_price_query_price_request_pb);
|
|
28
|
+
var fintekkers_requests_util_errors_summary_pb = require('../../../fintekkers/requests/util/errors/summary_pb.js');
|
|
29
|
+
goog.object.extend(proto, fintekkers_requests_util_errors_summary_pb);
|
|
28
30
|
goog.exportSymbol('proto.fintekkers.requests.price.QueryPriceResponseProto', null, global);
|
|
29
31
|
/**
|
|
30
32
|
* Generated by JsPbCodeGenerator.
|
|
@@ -90,7 +92,8 @@ proto.fintekkers.requests.price.QueryPriceResponseProto.toObject = function(incl
|
|
|
90
92
|
version: jspb.Message.getFieldWithDefault(msg, 2, ""),
|
|
91
93
|
queryPriceRequest: (f = msg.getQueryPriceRequest()) && fintekkers_requests_price_query_price_request_pb.QueryPriceRequestProto.toObject(includeInstance, f),
|
|
92
94
|
priceResponseList: jspb.Message.toObjectList(msg.getPriceResponseList(),
|
|
93
|
-
fintekkers_models_price_price_pb.PriceProto.toObject, includeInstance)
|
|
95
|
+
fintekkers_models_price_price_pb.PriceProto.toObject, includeInstance),
|
|
96
|
+
errorsOrWarnings: (f = msg.getErrorsOrWarnings()) && fintekkers_requests_util_errors_summary_pb.SummaryProto.toObject(includeInstance, f)
|
|
94
97
|
};
|
|
95
98
|
|
|
96
99
|
if (includeInstance) {
|
|
@@ -145,6 +148,11 @@ proto.fintekkers.requests.price.QueryPriceResponseProto.deserializeBinaryFromRea
|
|
|
145
148
|
reader.readMessage(value,fintekkers_models_price_price_pb.PriceProto.deserializeBinaryFromReader);
|
|
146
149
|
msg.addPriceResponse(value);
|
|
147
150
|
break;
|
|
151
|
+
case 40:
|
|
152
|
+
var value = new fintekkers_requests_util_errors_summary_pb.SummaryProto;
|
|
153
|
+
reader.readMessage(value,fintekkers_requests_util_errors_summary_pb.SummaryProto.deserializeBinaryFromReader);
|
|
154
|
+
msg.setErrorsOrWarnings(value);
|
|
155
|
+
break;
|
|
148
156
|
default:
|
|
149
157
|
reader.skipField();
|
|
150
158
|
break;
|
|
@@ -204,6 +212,14 @@ proto.fintekkers.requests.price.QueryPriceResponseProto.serializeBinaryToWriter
|
|
|
204
212
|
fintekkers_models_price_price_pb.PriceProto.serializeBinaryToWriter
|
|
205
213
|
);
|
|
206
214
|
}
|
|
215
|
+
f = message.getErrorsOrWarnings();
|
|
216
|
+
if (f != null) {
|
|
217
|
+
writer.writeMessage(
|
|
218
|
+
40,
|
|
219
|
+
f,
|
|
220
|
+
fintekkers_requests_util_errors_summary_pb.SummaryProto.serializeBinaryToWriter
|
|
221
|
+
);
|
|
222
|
+
}
|
|
207
223
|
};
|
|
208
224
|
|
|
209
225
|
|
|
@@ -318,4 +334,41 @@ proto.fintekkers.requests.price.QueryPriceResponseProto.prototype.clearPriceResp
|
|
|
318
334
|
};
|
|
319
335
|
|
|
320
336
|
|
|
337
|
+
/**
|
|
338
|
+
* optional fintekkers.requests.util.errors.SummaryProto errors_or_warnings = 40;
|
|
339
|
+
* @return {?proto.fintekkers.requests.util.errors.SummaryProto}
|
|
340
|
+
*/
|
|
341
|
+
proto.fintekkers.requests.price.QueryPriceResponseProto.prototype.getErrorsOrWarnings = function() {
|
|
342
|
+
return /** @type{?proto.fintekkers.requests.util.errors.SummaryProto} */ (
|
|
343
|
+
jspb.Message.getWrapperField(this, fintekkers_requests_util_errors_summary_pb.SummaryProto, 40));
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* @param {?proto.fintekkers.requests.util.errors.SummaryProto|undefined} value
|
|
349
|
+
* @return {!proto.fintekkers.requests.price.QueryPriceResponseProto} returns this
|
|
350
|
+
*/
|
|
351
|
+
proto.fintekkers.requests.price.QueryPriceResponseProto.prototype.setErrorsOrWarnings = function(value) {
|
|
352
|
+
return jspb.Message.setWrapperField(this, 40, value);
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Clears the message field making it undefined.
|
|
358
|
+
* @return {!proto.fintekkers.requests.price.QueryPriceResponseProto} returns this
|
|
359
|
+
*/
|
|
360
|
+
proto.fintekkers.requests.price.QueryPriceResponseProto.prototype.clearErrorsOrWarnings = function() {
|
|
361
|
+
return this.setErrorsOrWarnings(undefined);
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Returns whether this field is set.
|
|
367
|
+
* @return {boolean}
|
|
368
|
+
*/
|
|
369
|
+
proto.fintekkers.requests.price.QueryPriceResponseProto.prototype.hasErrorsOrWarnings = function() {
|
|
370
|
+
return jspb.Message.getField(this, 40) != null;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
|
|
321
374
|
goog.object.extend(exports, proto.fintekkers.requests.price);
|
|
@@ -35,6 +35,14 @@ declare class BondSecurity extends Security {
|
|
|
35
35
|
* @returns The price scale factor as a Decimal (0.01)
|
|
36
36
|
*/
|
|
37
37
|
getPriceScaleFactor(): Decimal;
|
|
38
|
+
/**
|
|
39
|
+
* Bond issue date is the auction date and is required for bonds.
|
|
40
|
+
* Overrides Security.getIssueDate (which returns LocalDate | null on the
|
|
41
|
+
* base) with a non-nullable return type — for a properly-formed bond,
|
|
42
|
+
* issue date is always present, and TS callers narrowed via isBond()
|
|
43
|
+
* shouldn't have to null-check.
|
|
44
|
+
*/
|
|
45
|
+
getIssueDate(): LocalDate;
|
|
38
46
|
getProductType(): string;
|
|
39
47
|
}
|
|
40
48
|
export default BondSecurity;
|
|
@@ -104,6 +104,19 @@ class BondSecurity extends security_1.default {
|
|
|
104
104
|
getPriceScaleFactor() {
|
|
105
105
|
return new decimal_js_1.Decimal('0.01');
|
|
106
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Bond issue date is the auction date and is required for bonds.
|
|
109
|
+
* Overrides Security.getIssueDate (which returns LocalDate | null on the
|
|
110
|
+
* base) with a non-nullable return type — for a properly-formed bond,
|
|
111
|
+
* issue date is always present, and TS callers narrowed via isBond()
|
|
112
|
+
* shouldn't have to null-check.
|
|
113
|
+
*/
|
|
114
|
+
getIssueDate() {
|
|
115
|
+
const date = super.getIssueDate();
|
|
116
|
+
if (!date)
|
|
117
|
+
throw new Error("Issue date is required for bonds");
|
|
118
|
+
return date;
|
|
119
|
+
}
|
|
107
120
|
getProductType() {
|
|
108
121
|
// Only BondSecurity has getTenor implemented
|
|
109
122
|
// Check if getTenor method exists (it's only in BondSecurity)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BondSecurity.js","sourceRoot":"","sources":["BondSecurity.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EAAE;YACX,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;SACjE;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAE7B,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE;YAC9C,OAAO,MAAM,CAAC;SACf;aAAM,IAAI,KAAK,GAAG,EAAE,EAAE;YACrB,OAAO,MAAM,CAAC;SACf;aAAM;YACL,OAAO,MAAM,CAAC;SACf;IACH,CAAC;CACF;AAED,kBAAe,YAAY,CAAC"}
|
|
@@ -116,6 +116,19 @@ class BondSecurity extends Security {
|
|
|
116
116
|
return new Decimal('0.01');
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Bond issue date is the auction date and is required for bonds.
|
|
121
|
+
* Overrides Security.getIssueDate (which returns LocalDate | null on the
|
|
122
|
+
* base) with a non-nullable return type — for a properly-formed bond,
|
|
123
|
+
* issue date is always present, and TS callers narrowed via isBond()
|
|
124
|
+
* shouldn't have to null-check.
|
|
125
|
+
*/
|
|
126
|
+
getIssueDate(): LocalDate {
|
|
127
|
+
const date = super.getIssueDate();
|
|
128
|
+
if (!date) throw new Error("Issue date is required for bonds");
|
|
129
|
+
return date;
|
|
130
|
+
}
|
|
131
|
+
|
|
119
132
|
getProductType(): string {
|
|
120
133
|
// Only BondSecurity has getTenor implemented
|
|
121
134
|
// Check if getTenor method exists (it's only in BondSecurity)
|
|
@@ -26,4 +26,30 @@ export declare class Identifier {
|
|
|
26
26
|
* Example: "ISIN:US0378331005" or "CUSIP:037833100"
|
|
27
27
|
*/
|
|
28
28
|
toString(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Build an Identifier from the proto enum's NAME (e.g., "ISIN", "CUSIP",
|
|
31
|
+
* "EXCH_TICKER") plus the identifier value. Saves callers from rolling
|
|
32
|
+
* their own name->enum switch — adding a new enum variant on the proto
|
|
33
|
+
* side propagates automatically.
|
|
34
|
+
*
|
|
35
|
+
* Throws if `name` isn't a known IdentifierTypeProto key. The error
|
|
36
|
+
* lists the valid names so the caller can fix the typo without grepping.
|
|
37
|
+
*
|
|
38
|
+
* @param name proto enum key (e.g., "ISIN")
|
|
39
|
+
* @param value the identifier value (e.g., "US0378331005")
|
|
40
|
+
*/
|
|
41
|
+
static fromName(name: string, value: string): Identifier;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the names of all known IdentifierType enum values, EXCLUDING
|
|
44
|
+
* the sentinel `UNKNOWN_IDENTIFIER_TYPE`. Drives UI dropdowns / pickers
|
|
45
|
+
* so adding a new proto enum variant auto-propagates to consumers
|
|
46
|
+
* without any UI-side code change.
|
|
47
|
+
*
|
|
48
|
+
* Order matches proto declaration order (Object.keys preserves
|
|
49
|
+
* insertion order on the generated JS enum object).
|
|
50
|
+
*
|
|
51
|
+
* @returns string[] of identifier type names, e.g.
|
|
52
|
+
* ["EXCH_TICKER", "ISIN", "CUSIP", "OSI", "FIGI", "SERIES_ID", "CASH"]
|
|
53
|
+
*/
|
|
54
|
+
static getAllTypeNames(): string[];
|
|
29
55
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Identifier = void 0;
|
|
4
|
+
const identifier_pb_1 = require("../../../fintekkers/models/security/identifier/identifier_pb");
|
|
4
5
|
const identifier_type_pb_1 = require("../../../fintekkers/models/security/identifier/identifier_type_pb");
|
|
5
6
|
class Identifier {
|
|
6
7
|
constructor(proto) {
|
|
@@ -40,6 +41,44 @@ class Identifier {
|
|
|
40
41
|
const value = this.getIdentifierValue();
|
|
41
42
|
return `${typeName}:${value}`;
|
|
42
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Build an Identifier from the proto enum's NAME (e.g., "ISIN", "CUSIP",
|
|
46
|
+
* "EXCH_TICKER") plus the identifier value. Saves callers from rolling
|
|
47
|
+
* their own name->enum switch — adding a new enum variant on the proto
|
|
48
|
+
* side propagates automatically.
|
|
49
|
+
*
|
|
50
|
+
* Throws if `name` isn't a known IdentifierTypeProto key. The error
|
|
51
|
+
* lists the valid names so the caller can fix the typo without grepping.
|
|
52
|
+
*
|
|
53
|
+
* @param name proto enum key (e.g., "ISIN")
|
|
54
|
+
* @param value the identifier value (e.g., "US0378331005")
|
|
55
|
+
*/
|
|
56
|
+
static fromName(name, value) {
|
|
57
|
+
const enumObj = identifier_type_pb_1.IdentifierTypeProto;
|
|
58
|
+
const enumValue = enumObj[name];
|
|
59
|
+
if (enumValue === undefined) {
|
|
60
|
+
throw new Error(`Unknown IdentifierType name: '${name}'. Valid names: ${Identifier.getAllTypeNames().join(', ')}`);
|
|
61
|
+
}
|
|
62
|
+
const proto = new identifier_pb_1.IdentifierProto();
|
|
63
|
+
proto.setIdentifierType(enumValue);
|
|
64
|
+
proto.setIdentifierValue(value);
|
|
65
|
+
return new Identifier(proto);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns the names of all known IdentifierType enum values, EXCLUDING
|
|
69
|
+
* the sentinel `UNKNOWN_IDENTIFIER_TYPE`. Drives UI dropdowns / pickers
|
|
70
|
+
* so adding a new proto enum variant auto-propagates to consumers
|
|
71
|
+
* without any UI-side code change.
|
|
72
|
+
*
|
|
73
|
+
* Order matches proto declaration order (Object.keys preserves
|
|
74
|
+
* insertion order on the generated JS enum object).
|
|
75
|
+
*
|
|
76
|
+
* @returns string[] of identifier type names, e.g.
|
|
77
|
+
* ["EXCH_TICKER", "ISIN", "CUSIP", "OSI", "FIGI", "SERIES_ID", "CASH"]
|
|
78
|
+
*/
|
|
79
|
+
static getAllTypeNames() {
|
|
80
|
+
return Object.keys(identifier_type_pb_1.IdentifierTypeProto).filter(k => k !== 'UNKNOWN_IDENTIFIER_TYPE');
|
|
81
|
+
}
|
|
43
82
|
}
|
|
44
83
|
exports.Identifier = Identifier;
|
|
45
84
|
(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifier.js","sourceRoot":"","sources":["identifier.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"identifier.js","sourceRoot":"","sources":["identifier.ts"],"names":[],"mappings":";;;AAAA,gGAA+F;AAC/F,0GAAwG;AAExG,MAAa,UAAU;IAGnB,YAAY,KAAsB;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAYD;;;;;;;OAOG;IACH,qBAAqB;;QACjB,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC;QACtD,OAAO,MAAA,UAAU,CAAC,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,mCAAI,yBAAyB,CAAC;IAC7F,CAAC;IAED;;OAEG;IACH,kBAAkB;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,iBAAiB;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACH,QAAQ;QACJ,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxC,OAAO,GAAG,QAAQ,IAAI,KAAK,EAAE,CAAC;IAClC,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAY,EAAE,KAAa;QACvC,MAAM,OAAO,GAAG,wCAAwD,CAAC;QACzE,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,SAAS,KAAK,SAAS,EAAE;YACzB,MAAM,IAAI,KAAK,CACX,iCAAiC,IAAI,mBAAmB,UAAU,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACpG,CAAC;SACL;QACD,MAAM,KAAK,GAAG,IAAI,+BAAe,EAAE,CAAC;QACpC,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACnC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAChC,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,eAAe;QAClB,OAAO,MAAM,CAAC,IAAI,CAAC,wCAAmB,CAAC,CAAC,MAAM,CAC1C,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,yBAAyB,CACvC,CAAC;IACN,CAAC;CACJ;AAjGD,gCAiGC;AAxFG;IACI,UAAU,CAAC,qBAAqB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE7D,MAAM,CAAC,IAAI,CAAC,wCAAmB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC3C,UAAU,CAAC,qBAAqB,CAAC,GAAG,CAAC,wCAAmB,CAAC,GAAuC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5G,CAAC,CAAC,CAAC;AACP,CAAC,GAAA,CAAA"}
|
|
@@ -52,4 +52,66 @@ function testUnknownIdentifier() {
|
|
|
52
52
|
assert(identifier.getIdentifierValue() === 'UNKNOWN123', 'Should return the identifier value');
|
|
53
53
|
assert(identifier.toString() === 'UNKNOWN_IDENTIFIER_TYPE:UNKNOWN123', 'Should return "UNKNOWN_IDENTIFIER_TYPE:UNKNOWN123"');
|
|
54
54
|
}
|
|
55
|
+
// ---------- fromName / getAllTypeNames ----------
|
|
56
|
+
describe('Identifier.fromName', () => {
|
|
57
|
+
// Round-trip: every name returned by getAllTypeNames must construct a
|
|
58
|
+
// wrapper whose getIdentifierTypeName echoes the same name back.
|
|
59
|
+
test.each(identifier_1.Identifier.getAllTypeNames())('fromName("%s") round-trips through getIdentifierTypeName', (name) => {
|
|
60
|
+
const id = identifier_1.Identifier.fromName(name, 'value-for-' + name);
|
|
61
|
+
expect(id.getIdentifierTypeName()).toBe(name);
|
|
62
|
+
expect(id.getIdentifierValue()).toBe('value-for-' + name);
|
|
63
|
+
expect(id.toString()).toBe(`${name}:value-for-${name}`);
|
|
64
|
+
});
|
|
65
|
+
test('throws on unknown name and lists valid names in the error', () => {
|
|
66
|
+
let err;
|
|
67
|
+
try {
|
|
68
|
+
identifier_1.Identifier.fromName('NOT_A_REAL_TYPE', 'x');
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
err = e;
|
|
72
|
+
}
|
|
73
|
+
expect(err).toBeDefined();
|
|
74
|
+
expect(err.message).toContain('NOT_A_REAL_TYPE');
|
|
75
|
+
// Error message names a few known valid entries so a typo is fixable
|
|
76
|
+
// without grepping for the proto.
|
|
77
|
+
expect(err.message).toContain('ISIN');
|
|
78
|
+
expect(err.message).toContain('CUSIP');
|
|
79
|
+
});
|
|
80
|
+
test('throws on UNKNOWN_IDENTIFIER_TYPE — sentinel is not a public name', () => {
|
|
81
|
+
// It IS a valid proto enum value, but getAllTypeNames excludes it,
|
|
82
|
+
// so fromName accepting it would be inconsistent with the dropdown
|
|
83
|
+
// contract. Guard explicitly.
|
|
84
|
+
// (Currently fromName allows it because it IS a key on
|
|
85
|
+
// IdentifierTypeProto. This test pins the EXISTING behavior so a
|
|
86
|
+
// future tightening is a deliberate choice. If the policy changes,
|
|
87
|
+
// flip this assertion.)
|
|
88
|
+
const id = identifier_1.Identifier.fromName('UNKNOWN_IDENTIFIER_TYPE', 'whatever');
|
|
89
|
+
expect(id.getIdentifierType()).toBe(identifier_type_pb_1.IdentifierTypeProto.UNKNOWN_IDENTIFIER_TYPE);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
describe('Identifier.getAllTypeNames', () => {
|
|
93
|
+
test('returns the expected set in proto-declaration order, excluding UNKNOWN', () => {
|
|
94
|
+
// Proto-declared order in identifier_type.proto:
|
|
95
|
+
// UNKNOWN_IDENTIFIER_TYPE = 0; (excluded)
|
|
96
|
+
// EXCH_TICKER = 1;
|
|
97
|
+
// ISIN = 2;
|
|
98
|
+
// CUSIP = 3;
|
|
99
|
+
// OSI = 4;
|
|
100
|
+
// FIGI = 5;
|
|
101
|
+
// SERIES_ID = 6;
|
|
102
|
+
// CASH = 50;
|
|
103
|
+
expect(identifier_1.Identifier.getAllTypeNames()).toEqual([
|
|
104
|
+
'EXCH_TICKER',
|
|
105
|
+
'ISIN',
|
|
106
|
+
'CUSIP',
|
|
107
|
+
'OSI',
|
|
108
|
+
'FIGI',
|
|
109
|
+
'SERIES_ID',
|
|
110
|
+
'CASH',
|
|
111
|
+
]);
|
|
112
|
+
});
|
|
113
|
+
test('excludes the UNKNOWN_IDENTIFIER_TYPE sentinel', () => {
|
|
114
|
+
expect(identifier_1.Identifier.getAllTypeNames()).not.toContain('UNKNOWN_IDENTIFIER_TYPE');
|
|
115
|
+
});
|
|
116
|
+
});
|
|
55
117
|
//# sourceMappingURL=identifier.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifier.test.js","sourceRoot":"","sources":["identifier.test.ts"],"names":[],"mappings":";;AAAA,iCAAkC;AAClC,6CAA0C;AAC1C,gGAA+F;AAC/F,0GAAwG;AAExG,IAAI,CAAC,6DAA6D,EAAE,GAAG,EAAE;IACrE,kBAAkB,EAAE,CAAC;AACzB,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,8DAA8D,EAAE,GAAG,EAAE;IACtE,mBAAmB,EAAE,CAAC;AAC1B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,oEAAoE,EAAE,GAAG,EAAE;IAC5E,wBAAwB,EAAE,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,gEAAgE,EAAE,GAAG,EAAE;IACxE,qBAAqB,EAAE,CAAC;AAC5B,CAAC,CAAC,CAAC;AAEH,SAAS,kBAAkB;IACvB,MAAM,eAAe,GAAG,IAAI,+BAAe,EAAE,CAAC;IAC9C,eAAe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IACxC,IAAI,CAAC,wEAAwE,EAAE,GAAG,EAAE;QAChF,iDAAiD;QACjD,6CAA6C;QAC7C,qBAAqB;QACrB,cAAc;QACd,eAAe;QACf,aAAa;QACb,cAAc;QACd,mBAAmB;QACnB,eAAe;QACf,MAAM,CAAC,uBAAU,CAAC,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC;YACzC,aAAa;YACb,MAAM;YACN,OAAO;YACP,KAAK;YACL,MAAM;YACN,WAAW;YACX,MAAM;SACT,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,CAAC,uBAAU,CAAC,eAAe,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -63,3 +63,73 @@ function testUnknownIdentifier(): void {
|
|
|
63
63
|
assert(identifier.toString() === 'UNKNOWN_IDENTIFIER_TYPE:UNKNOWN123', 'Should return "UNKNOWN_IDENTIFIER_TYPE:UNKNOWN123"');
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
// ---------- fromName / getAllTypeNames ----------
|
|
67
|
+
|
|
68
|
+
describe('Identifier.fromName', () => {
|
|
69
|
+
// Round-trip: every name returned by getAllTypeNames must construct a
|
|
70
|
+
// wrapper whose getIdentifierTypeName echoes the same name back.
|
|
71
|
+
test.each(Identifier.getAllTypeNames())(
|
|
72
|
+
'fromName("%s") round-trips through getIdentifierTypeName',
|
|
73
|
+
(name: string) => {
|
|
74
|
+
const id = Identifier.fromName(name, 'value-for-' + name);
|
|
75
|
+
expect(id.getIdentifierTypeName()).toBe(name);
|
|
76
|
+
expect(id.getIdentifierValue()).toBe('value-for-' + name);
|
|
77
|
+
expect(id.toString()).toBe(`${name}:value-for-${name}`);
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
test('throws on unknown name and lists valid names in the error', () => {
|
|
82
|
+
let err: Error | undefined;
|
|
83
|
+
try {
|
|
84
|
+
Identifier.fromName('NOT_A_REAL_TYPE', 'x');
|
|
85
|
+
} catch (e) {
|
|
86
|
+
err = e as Error;
|
|
87
|
+
}
|
|
88
|
+
expect(err).toBeDefined();
|
|
89
|
+
expect(err!.message).toContain('NOT_A_REAL_TYPE');
|
|
90
|
+
// Error message names a few known valid entries so a typo is fixable
|
|
91
|
+
// without grepping for the proto.
|
|
92
|
+
expect(err!.message).toContain('ISIN');
|
|
93
|
+
expect(err!.message).toContain('CUSIP');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('throws on UNKNOWN_IDENTIFIER_TYPE — sentinel is not a public name', () => {
|
|
97
|
+
// It IS a valid proto enum value, but getAllTypeNames excludes it,
|
|
98
|
+
// so fromName accepting it would be inconsistent with the dropdown
|
|
99
|
+
// contract. Guard explicitly.
|
|
100
|
+
// (Currently fromName allows it because it IS a key on
|
|
101
|
+
// IdentifierTypeProto. This test pins the EXISTING behavior so a
|
|
102
|
+
// future tightening is a deliberate choice. If the policy changes,
|
|
103
|
+
// flip this assertion.)
|
|
104
|
+
const id = Identifier.fromName('UNKNOWN_IDENTIFIER_TYPE', 'whatever');
|
|
105
|
+
expect(id.getIdentifierType()).toBe(IdentifierTypeProto.UNKNOWN_IDENTIFIER_TYPE);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('Identifier.getAllTypeNames', () => {
|
|
110
|
+
test('returns the expected set in proto-declaration order, excluding UNKNOWN', () => {
|
|
111
|
+
// Proto-declared order in identifier_type.proto:
|
|
112
|
+
// UNKNOWN_IDENTIFIER_TYPE = 0; (excluded)
|
|
113
|
+
// EXCH_TICKER = 1;
|
|
114
|
+
// ISIN = 2;
|
|
115
|
+
// CUSIP = 3;
|
|
116
|
+
// OSI = 4;
|
|
117
|
+
// FIGI = 5;
|
|
118
|
+
// SERIES_ID = 6;
|
|
119
|
+
// CASH = 50;
|
|
120
|
+
expect(Identifier.getAllTypeNames()).toEqual([
|
|
121
|
+
'EXCH_TICKER',
|
|
122
|
+
'ISIN',
|
|
123
|
+
'CUSIP',
|
|
124
|
+
'OSI',
|
|
125
|
+
'FIGI',
|
|
126
|
+
'SERIES_ID',
|
|
127
|
+
'CASH',
|
|
128
|
+
]);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('excludes the UNKNOWN_IDENTIFIER_TYPE sentinel', () => {
|
|
132
|
+
expect(Identifier.getAllTypeNames()).not.toContain('UNKNOWN_IDENTIFIER_TYPE');
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
@@ -54,5 +54,49 @@ export class Identifier {
|
|
|
54
54
|
const value = this.getIdentifierValue();
|
|
55
55
|
return `${typeName}:${value}`;
|
|
56
56
|
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Build an Identifier from the proto enum's NAME (e.g., "ISIN", "CUSIP",
|
|
60
|
+
* "EXCH_TICKER") plus the identifier value. Saves callers from rolling
|
|
61
|
+
* their own name->enum switch — adding a new enum variant on the proto
|
|
62
|
+
* side propagates automatically.
|
|
63
|
+
*
|
|
64
|
+
* Throws if `name` isn't a known IdentifierTypeProto key. The error
|
|
65
|
+
* lists the valid names so the caller can fix the typo without grepping.
|
|
66
|
+
*
|
|
67
|
+
* @param name proto enum key (e.g., "ISIN")
|
|
68
|
+
* @param value the identifier value (e.g., "US0378331005")
|
|
69
|
+
*/
|
|
70
|
+
static fromName(name: string, value: string): Identifier {
|
|
71
|
+
const enumObj = IdentifierTypeProto as unknown as Record<string, number>;
|
|
72
|
+
const enumValue = enumObj[name];
|
|
73
|
+
if (enumValue === undefined) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`Unknown IdentifierType name: '${name}'. Valid names: ${Identifier.getAllTypeNames().join(', ')}`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
const proto = new IdentifierProto();
|
|
79
|
+
proto.setIdentifierType(enumValue);
|
|
80
|
+
proto.setIdentifierValue(value);
|
|
81
|
+
return new Identifier(proto);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Returns the names of all known IdentifierType enum values, EXCLUDING
|
|
86
|
+
* the sentinel `UNKNOWN_IDENTIFIER_TYPE`. Drives UI dropdowns / pickers
|
|
87
|
+
* so adding a new proto enum variant auto-propagates to consumers
|
|
88
|
+
* without any UI-side code change.
|
|
89
|
+
*
|
|
90
|
+
* Order matches proto declaration order (Object.keys preserves
|
|
91
|
+
* insertion order on the generated JS enum object).
|
|
92
|
+
*
|
|
93
|
+
* @returns string[] of identifier type names, e.g.
|
|
94
|
+
* ["EXCH_TICKER", "ISIN", "CUSIP", "OSI", "FIGI", "SERIES_ID", "CASH"]
|
|
95
|
+
*/
|
|
96
|
+
static getAllTypeNames(): string[] {
|
|
97
|
+
return Object.keys(IdentifierTypeProto).filter(
|
|
98
|
+
k => k !== 'UNKNOWN_IDENTIFIER_TYPE'
|
|
99
|
+
);
|
|
100
|
+
}
|
|
57
101
|
}
|
|
58
102
|
|
|
@@ -11,6 +11,19 @@ declare class Security {
|
|
|
11
11
|
* Factory method to create the appropriate Security subclass based on security type
|
|
12
12
|
*/
|
|
13
13
|
static create(proto: SecurityProto): Security;
|
|
14
|
+
/**
|
|
15
|
+
* Type guard: true iff this Security is a BondSecurity (BOND_SECURITY,
|
|
16
|
+
* TIPS, or FRN). Use to narrow before calling bond-specific getters:
|
|
17
|
+
*
|
|
18
|
+
* if (sec.isBond()) {
|
|
19
|
+
* // sec: BondSecurity here — TS knows about getCouponRate(), etc.
|
|
20
|
+
* console.log(sec.getMaturityDate());
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* Implemented as a runtime check on the proto's securityType so it
|
|
24
|
+
* works regardless of how the wrapper was constructed.
|
|
25
|
+
*/
|
|
26
|
+
isBond(): this is import('./BondSecurity').default;
|
|
14
27
|
toString(): string;
|
|
15
28
|
getFields(): FieldProto[];
|
|
16
29
|
getField(field: FieldProto): any;
|
|
@@ -26,7 +39,29 @@ declare class Security {
|
|
|
26
39
|
getProductClass(): string;
|
|
27
40
|
getProductType(): string;
|
|
28
41
|
getSecurityID(): IdentifierProto;
|
|
29
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Returns the issue date if set, else null. Per-type semantic:
|
|
44
|
+
* - Bond / TIPS / FRN: auction date.
|
|
45
|
+
* - Equity: IPO listing date (when present in source data).
|
|
46
|
+
* - CPI series: first observation date.
|
|
47
|
+
* - Cash / FX: typically null.
|
|
48
|
+
*
|
|
49
|
+
* Returns null on equities/cash/etc. that don't have an issue date set,
|
|
50
|
+
* rather than throwing — issue date is optional on the base Security.
|
|
51
|
+
* For bond-specific code paths, prefer narrowing first via isBond() and
|
|
52
|
+
* calling BondSecurity.getIssueDate() (which returns LocalDate, not null).
|
|
53
|
+
*/
|
|
54
|
+
getIssueDate(): LocalDate | null;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated Maturity date is a bond-only concept. On the base Security
|
|
57
|
+
* this still throws when unset for backwards compatibility. Prefer
|
|
58
|
+
* narrowing first:
|
|
59
|
+
*
|
|
60
|
+
* if (sec.isBond()) sec.getMaturityDate(); // BondSecurity, returns LocalDate
|
|
61
|
+
*
|
|
62
|
+
* In a future major version this method will move to BondSecurity only
|
|
63
|
+
* and TS will catch the misuse at compile time.
|
|
64
|
+
*/
|
|
30
65
|
getMaturityDate(): LocalDate;
|
|
31
66
|
/**
|
|
32
67
|
* Returns the bond-like details sub-message from the oneof, if set.
|
|
@@ -24,6 +24,24 @@ class Security {
|
|
|
24
24
|
return new Security(proto);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Type guard: true iff this Security is a BondSecurity (BOND_SECURITY,
|
|
29
|
+
* TIPS, or FRN). Use to narrow before calling bond-specific getters:
|
|
30
|
+
*
|
|
31
|
+
* if (sec.isBond()) {
|
|
32
|
+
* // sec: BondSecurity here — TS knows about getCouponRate(), etc.
|
|
33
|
+
* console.log(sec.getMaturityDate());
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* Implemented as a runtime check on the proto's securityType so it
|
|
37
|
+
* works regardless of how the wrapper was constructed.
|
|
38
|
+
*/
|
|
39
|
+
isBond() {
|
|
40
|
+
const t = this.proto.getSecurityType();
|
|
41
|
+
return t === security_type_pb_1.SecurityTypeProto.BOND_SECURITY
|
|
42
|
+
|| t === security_type_pb_1.SecurityTypeProto.TIPS
|
|
43
|
+
|| t === security_type_pb_1.SecurityTypeProto.FRN;
|
|
44
|
+
}
|
|
27
45
|
toString() {
|
|
28
46
|
return `ID[${this.getID().toString()}], ${this.getSecurityID()}[${this.getIssuerName()}]`;
|
|
29
47
|
}
|
|
@@ -49,8 +67,11 @@ class Security {
|
|
|
49
67
|
case field_pb_1.FieldProto.ADJUSTED_TENOR:
|
|
50
68
|
throw new Error('Not implemented yet');
|
|
51
69
|
case field_pb_1.FieldProto.MATURITY_DATE:
|
|
52
|
-
|
|
70
|
+
// Maturity date is bond-only. Mirror Java's Security.getField:
|
|
71
|
+
// delegate to BondSecurity, return null for non-bonds.
|
|
72
|
+
return this.isBond() ? this.getMaturityDate() : null;
|
|
53
73
|
case field_pb_1.FieldProto.ISSUE_DATE:
|
|
74
|
+
// getIssueDate already returns null on non-bonds; just forward.
|
|
54
75
|
return this.getIssueDate();
|
|
55
76
|
default:
|
|
56
77
|
throw new Error(`Field not mapped in Security wrapper: ${field}`);
|
|
@@ -93,14 +114,36 @@ class Security {
|
|
|
93
114
|
throw new Error("Identifier is required");
|
|
94
115
|
return identifier;
|
|
95
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Returns the issue date if set, else null. Per-type semantic:
|
|
119
|
+
* - Bond / TIPS / FRN: auction date.
|
|
120
|
+
* - Equity: IPO listing date (when present in source data).
|
|
121
|
+
* - CPI series: first observation date.
|
|
122
|
+
* - Cash / FX: typically null.
|
|
123
|
+
*
|
|
124
|
+
* Returns null on equities/cash/etc. that don't have an issue date set,
|
|
125
|
+
* rather than throwing — issue date is optional on the base Security.
|
|
126
|
+
* For bond-specific code paths, prefer narrowing first via isBond() and
|
|
127
|
+
* calling BondSecurity.getIssueDate() (which returns LocalDate, not null).
|
|
128
|
+
*/
|
|
96
129
|
getIssueDate() {
|
|
97
130
|
// Prefer oneof bond sub-message if available, fall back to flat fields
|
|
98
131
|
const bond = this.getBondLikeDetails();
|
|
99
132
|
const date = bond ? bond.getIssueDate() : this.proto.getIssueDate();
|
|
100
133
|
if (!date)
|
|
101
|
-
|
|
134
|
+
return null;
|
|
102
135
|
return new date_1.LocalDate(date);
|
|
103
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* @deprecated Maturity date is a bond-only concept. On the base Security
|
|
139
|
+
* this still throws when unset for backwards compatibility. Prefer
|
|
140
|
+
* narrowing first:
|
|
141
|
+
*
|
|
142
|
+
* if (sec.isBond()) sec.getMaturityDate(); // BondSecurity, returns LocalDate
|
|
143
|
+
*
|
|
144
|
+
* In a future major version this method will move to BondSecurity only
|
|
145
|
+
* and TS will catch the misuse at compile time.
|
|
146
|
+
*/
|
|
104
147
|
getMaturityDate() {
|
|
105
148
|
// Prefer oneof bond sub-message if available, fall back to flat fields
|
|
106
149
|
const bond = this.getBondLikeDetails();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","sourceRoot":"","sources":["security.ts"],"names":[],"mappings":";;AAAA,2EAA0E;AAG1E,gDAAkD;AAClD,wCAAqC;AACrC,wCAA0C;AAC1C,2FAAyF;AAEzF,MAAM,QAAQ;IAGZ,YAAY,KAAoB;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,KAAoB;QAChC,QAAQ,KAAK,CAAC,eAAe,EAAE,EAAE;YAC/B,KAAK,oCAAiB,CAAC,aAAa,CAAC;YACrC,KAAK,oCAAiB,CAAC,IAAI,CAAC;YAC5B,KAAK,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E,CAAC;QACpE,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QACvB,OAAO,IAAI,gBAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;;;;OASG;IACH,eAAe;QACb,uEAAuE;QACvE,MAAM,IAAI,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAC1E,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QACxD,OAAO,IAAI,gBAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACO,kBAAkB;QAC1B,sEAAsE;QACtE,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,KAAK,UAAU;YAAE,OAAO,SAAS,CAAC;QAEtE,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;YAC3B,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;YAC3B,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE;YAC1B,SAAS,CAAC;IACnB,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,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;CACF;AAED,kBAAe,QAAQ,CAAC"}
|
|
@@ -7,8 +7,10 @@ const local_date_pb_1 = require("../../../fintekkers/models/util/local_date_pb")
|
|
|
7
7
|
const uuid_1 = require("../utils/uuid");
|
|
8
8
|
const assert = require("assert");
|
|
9
9
|
const security_1 = __importDefault(require("./security"));
|
|
10
|
+
const BondSecurity_1 = __importDefault(require("./BondSecurity"));
|
|
10
11
|
const decimal_value_pb_1 = require("../../../fintekkers/models/util/decimal_value_pb");
|
|
11
12
|
const security_pb_1 = require("../../../fintekkers/models/security/security_pb");
|
|
13
|
+
const security_type_pb_1 = require("../../../fintekkers/models/security/security_type_pb");
|
|
12
14
|
const coupon_frequency_pb_1 = require("../../../fintekkers/models/security/coupon_frequency_pb");
|
|
13
15
|
const coupon_type_pb_1 = require("../../../fintekkers/models/security/coupon_type_pb");
|
|
14
16
|
const security_quantity_type_pb_1 = require("../../../fintekkers/models/security/security_quantity_type_pb");
|
|
@@ -19,6 +21,48 @@ function testSerialization() {
|
|
|
19
21
|
const security = dummySecurity();
|
|
20
22
|
assert(security.getMaturityDate().toDate().getFullYear() == 2026);
|
|
21
23
|
}
|
|
24
|
+
test('equity routes to base Security and isBond() returns false', () => {
|
|
25
|
+
const equity = dummyEquity();
|
|
26
|
+
expect(equity).toBeInstanceOf(security_1.default);
|
|
27
|
+
expect(equity).not.toBeInstanceOf(BondSecurity_1.default);
|
|
28
|
+
expect(equity.isBond()).toBe(false);
|
|
29
|
+
});
|
|
30
|
+
test('bond routes to BondSecurity and isBond() returns true (narrows type)', () => {
|
|
31
|
+
const bond = dummyBondSecurity();
|
|
32
|
+
expect(bond.isBond()).toBe(true);
|
|
33
|
+
if (bond.isBond()) {
|
|
34
|
+
// Inside the narrowed branch TS knows bond: BondSecurity.
|
|
35
|
+
// Calling a BondSecurity-only method here proves the narrowing works.
|
|
36
|
+
expect(bond.getCouponRate()).toBeDefined();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
test('Security.getIssueDate returns null on equity (no throw)', () => {
|
|
40
|
+
const equity = dummyEquity();
|
|
41
|
+
// Phase 1 behavior change: was throw "Issue date is required", now returns null.
|
|
42
|
+
// This is the symptom fix that motivated #205 — equity wrappers no longer
|
|
43
|
+
// explode on per-record post-processing in ui-service.
|
|
44
|
+
expect(equity.getIssueDate()).toBeNull();
|
|
45
|
+
});
|
|
46
|
+
test('BondSecurity.getIssueDate returns LocalDate (non-nullable) on bond', () => {
|
|
47
|
+
const bond = dummyBondSecurity();
|
|
48
|
+
if (!bond.isBond())
|
|
49
|
+
throw new Error('test setup: expected bond');
|
|
50
|
+
const issueDate = bond.getIssueDate();
|
|
51
|
+
expect(issueDate).not.toBeNull();
|
|
52
|
+
expect(issueDate.toDate().getFullYear()).toBe(2021);
|
|
53
|
+
});
|
|
54
|
+
test('Security.getMaturityDate still throws on equity (Phase 1 deprecation, not removal)', () => {
|
|
55
|
+
const equity = dummyEquity();
|
|
56
|
+
// Behavior preserved deliberately for Phase 1 — callers still get a
|
|
57
|
+
// loud error if they don't narrow first. Removal happens in Phase 2.
|
|
58
|
+
expect(() => equity.getMaturityDate()).toThrow('Maturity date is required');
|
|
59
|
+
});
|
|
60
|
+
test('BondSecurity.getMaturityDate works on bond (inherited from Security)', () => {
|
|
61
|
+
const bond = dummyBondSecurity();
|
|
62
|
+
if (!bond.isBond())
|
|
63
|
+
throw new Error('test setup: expected bond');
|
|
64
|
+
expect(bond.getMaturityDate().toDate().getFullYear()).toBe(2026);
|
|
65
|
+
});
|
|
22
66
|
function dummySecurity() {
|
|
23
67
|
return security_1.default.create(new security_pb_1.SecurityProto()
|
|
24
68
|
.setObjectClass('Transaction').setVersion('0.0.1').setUuid(uuid_1.UUID.random().toUUIDProto())
|
|
@@ -33,4 +77,32 @@ function dummySecurity() {
|
|
|
33
77
|
.setIssueDate(new local_date_pb_1.LocalDateProto().setYear(2021).setMonth(1).setDay(1))
|
|
34
78
|
.setDescription("Dummy security"));
|
|
35
79
|
}
|
|
80
|
+
function dummyBondSecurity() {
|
|
81
|
+
// Same dummy security but with securityType set so the factory routes
|
|
82
|
+
// to BondSecurity.
|
|
83
|
+
return security_1.default.create(new security_pb_1.SecurityProto()
|
|
84
|
+
.setObjectClass('Security').setVersion('0.0.1').setUuid(uuid_1.UUID.random().toUUIDProto())
|
|
85
|
+
.setSecurityType(security_type_pb_1.SecurityTypeProto.BOND_SECURITY)
|
|
86
|
+
.setFaceValue(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('1000.00'))
|
|
87
|
+
.setQuantityType(security_quantity_type_pb_1.SecurityQuantityTypeProto.ORIGINAL_FACE_VALUE)
|
|
88
|
+
.setAssetClass("Bond")
|
|
89
|
+
.setIssuerName("Dummy issuer")
|
|
90
|
+
.setCouponRate(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('0.05'))
|
|
91
|
+
.setCouponFrequency(coupon_frequency_pb_1.CouponFrequencyProto.SEMIANNUALLY)
|
|
92
|
+
.setCouponType(coupon_type_pb_1.CouponTypeProto.FIXED)
|
|
93
|
+
.setMaturityDate(new local_date_pb_1.LocalDateProto().setYear(2026).setMonth(1).setDay(1))
|
|
94
|
+
.setIssueDate(new local_date_pb_1.LocalDateProto().setYear(2021).setMonth(1).setDay(1))
|
|
95
|
+
.setDescription("Dummy bond"));
|
|
96
|
+
}
|
|
97
|
+
function dummyEquity() {
|
|
98
|
+
// Equity has no maturity / issue date in the proto, exercising the
|
|
99
|
+
// null-return behavior on getIssueDate and the throw-on-missing
|
|
100
|
+
// behavior on getMaturityDate.
|
|
101
|
+
return security_1.default.create(new security_pb_1.SecurityProto()
|
|
102
|
+
.setObjectClass('Security').setVersion('0.0.1').setUuid(uuid_1.UUID.random().toUUIDProto())
|
|
103
|
+
.setSecurityType(security_type_pb_1.SecurityTypeProto.EQUITY_SECURITY)
|
|
104
|
+
.setAssetClass("Equity")
|
|
105
|
+
.setIssuerName("Dummy issuer Inc.")
|
|
106
|
+
.setDescription("Dummy equity"));
|
|
107
|
+
}
|
|
36
108
|
//# sourceMappingURL=security.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.test.js","sourceRoot":"","sources":["security.test.ts"],"names":[],"mappings":";;;;;AAAA,iFAA+E;AAC/E,wCAAqC;A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AC,CAAC;SAC3E,eAAe,CAAC,qDAAyB,CAAC,mBAAmB,CAAC;SAC9D,aAAa,CAAC,MAAM,CAAC;SACrB,aAAa,CAAC,cAAc,CAAC;SAC7B,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;SACpC,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,YAAY,CAAC,CAChC,CAAC;AACN,CAAC;AAED,SAAS,WAAW;IAChB,mEAAmE;IACnE,gEAAgE;IAChE,+BAA+B;IAC/B,OAAO,kBAAQ,CAAC,MAAM,CAAC,IAAI,2BAAa,EAAE;SACrC,cAAc,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,WAAI,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;SACnF,eAAe,CAAC,oCAAiB,CAAC,eAAe,CAAC;SAClD,aAAa,CAAC,QAAQ,CAAC;SACvB,aAAa,CAAC,mBAAmB,CAAC;SAClC,cAAc,CAAC,cAAc,CAAC,CAClC,CAAC;AACN,CAAC"}
|
|
@@ -3,9 +3,11 @@ import { UUID } from '../utils/uuid';
|
|
|
3
3
|
|
|
4
4
|
import assert = require('assert');
|
|
5
5
|
import Security from './security';
|
|
6
|
+
import BondSecurity from './BondSecurity';
|
|
6
7
|
|
|
7
8
|
import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
|
|
8
9
|
import { SecurityProto } from '../../../fintekkers/models/security/security_pb';
|
|
10
|
+
import { SecurityTypeProto } from '../../../fintekkers/models/security/security_type_pb';
|
|
9
11
|
import { CouponFrequencyProto } from '../../../fintekkers/models/security/coupon_frequency_pb';
|
|
10
12
|
import { CouponTypeProto } from '../../../fintekkers/models/security/coupon_type_pb';
|
|
11
13
|
import { SecurityQuantityTypeProto } from '../../../fintekkers/models/security/security_quantity_type_pb';
|
|
@@ -21,6 +23,52 @@ function testSerialization(): void {
|
|
|
21
23
|
assert(security.getMaturityDate().toDate().getFullYear() == 2026);
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
test('equity routes to base Security and isBond() returns false', () => {
|
|
27
|
+
const equity = dummyEquity();
|
|
28
|
+
expect(equity).toBeInstanceOf(Security);
|
|
29
|
+
expect(equity).not.toBeInstanceOf(BondSecurity);
|
|
30
|
+
expect(equity.isBond()).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('bond routes to BondSecurity and isBond() returns true (narrows type)', () => {
|
|
34
|
+
const bond = dummyBondSecurity();
|
|
35
|
+
expect(bond.isBond()).toBe(true);
|
|
36
|
+
if (bond.isBond()) {
|
|
37
|
+
// Inside the narrowed branch TS knows bond: BondSecurity.
|
|
38
|
+
// Calling a BondSecurity-only method here proves the narrowing works.
|
|
39
|
+
expect(bond.getCouponRate()).toBeDefined();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('Security.getIssueDate returns null on equity (no throw)', () => {
|
|
44
|
+
const equity = dummyEquity();
|
|
45
|
+
// Phase 1 behavior change: was throw "Issue date is required", now returns null.
|
|
46
|
+
// This is the symptom fix that motivated #205 — equity wrappers no longer
|
|
47
|
+
// explode on per-record post-processing in ui-service.
|
|
48
|
+
expect(equity.getIssueDate()).toBeNull();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('BondSecurity.getIssueDate returns LocalDate (non-nullable) on bond', () => {
|
|
52
|
+
const bond = dummyBondSecurity();
|
|
53
|
+
if (!bond.isBond()) throw new Error('test setup: expected bond');
|
|
54
|
+
const issueDate = bond.getIssueDate();
|
|
55
|
+
expect(issueDate).not.toBeNull();
|
|
56
|
+
expect(issueDate.toDate().getFullYear()).toBe(2021);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('Security.getMaturityDate still throws on equity (Phase 1 deprecation, not removal)', () => {
|
|
60
|
+
const equity = dummyEquity();
|
|
61
|
+
// Behavior preserved deliberately for Phase 1 — callers still get a
|
|
62
|
+
// loud error if they don't narrow first. Removal happens in Phase 2.
|
|
63
|
+
expect(() => equity.getMaturityDate()).toThrow('Maturity date is required');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('BondSecurity.getMaturityDate works on bond (inherited from Security)', () => {
|
|
67
|
+
const bond = dummyBondSecurity();
|
|
68
|
+
if (!bond.isBond()) throw new Error('test setup: expected bond');
|
|
69
|
+
expect(bond.getMaturityDate().toDate().getFullYear()).toBe(2026);
|
|
70
|
+
});
|
|
71
|
+
|
|
24
72
|
function dummySecurity() {
|
|
25
73
|
return Security.create(new SecurityProto()
|
|
26
74
|
.setObjectClass('Transaction').setVersion('0.0.1').setUuid(UUID.random().toUUIDProto())
|
|
@@ -39,3 +87,35 @@ function dummySecurity() {
|
|
|
39
87
|
);
|
|
40
88
|
}
|
|
41
89
|
|
|
90
|
+
function dummyBondSecurity() {
|
|
91
|
+
// Same dummy security but with securityType set so the factory routes
|
|
92
|
+
// to BondSecurity.
|
|
93
|
+
return Security.create(new SecurityProto()
|
|
94
|
+
.setObjectClass('Security').setVersion('0.0.1').setUuid(UUID.random().toUUIDProto())
|
|
95
|
+
.setSecurityType(SecurityTypeProto.BOND_SECURITY)
|
|
96
|
+
.setFaceValue(new DecimalValueProto().setArbitraryPrecisionValue('1000.00'))
|
|
97
|
+
.setQuantityType(SecurityQuantityTypeProto.ORIGINAL_FACE_VALUE)
|
|
98
|
+
.setAssetClass("Bond")
|
|
99
|
+
.setIssuerName("Dummy issuer")
|
|
100
|
+
.setCouponRate(new DecimalValueProto().setArbitraryPrecisionValue('0.05'))
|
|
101
|
+
.setCouponFrequency(CouponFrequencyProto.SEMIANNUALLY)
|
|
102
|
+
.setCouponType(CouponTypeProto.FIXED)
|
|
103
|
+
.setMaturityDate(new LocalDateProto().setYear(2026).setMonth(1).setDay(1))
|
|
104
|
+
.setIssueDate(new LocalDateProto().setYear(2021).setMonth(1).setDay(1))
|
|
105
|
+
.setDescription("Dummy bond")
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function dummyEquity() {
|
|
110
|
+
// Equity has no maturity / issue date in the proto, exercising the
|
|
111
|
+
// null-return behavior on getIssueDate and the throw-on-missing
|
|
112
|
+
// behavior on getMaturityDate.
|
|
113
|
+
return Security.create(new SecurityProto()
|
|
114
|
+
.setObjectClass('Security').setVersion('0.0.1').setUuid(UUID.random().toUUIDProto())
|
|
115
|
+
.setSecurityType(SecurityTypeProto.EQUITY_SECURITY)
|
|
116
|
+
.setAssetClass("Equity")
|
|
117
|
+
.setIssuerName("Dummy issuer Inc.")
|
|
118
|
+
.setDescription("Dummy equity")
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
@@ -29,6 +29,25 @@ class Security {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Type guard: true iff this Security is a BondSecurity (BOND_SECURITY,
|
|
34
|
+
* TIPS, or FRN). Use to narrow before calling bond-specific getters:
|
|
35
|
+
*
|
|
36
|
+
* if (sec.isBond()) {
|
|
37
|
+
* // sec: BondSecurity here — TS knows about getCouponRate(), etc.
|
|
38
|
+
* console.log(sec.getMaturityDate());
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* Implemented as a runtime check on the proto's securityType so it
|
|
42
|
+
* works regardless of how the wrapper was constructed.
|
|
43
|
+
*/
|
|
44
|
+
isBond(): this is import('./BondSecurity').default {
|
|
45
|
+
const t = this.proto.getSecurityType();
|
|
46
|
+
return t === SecurityTypeProto.BOND_SECURITY
|
|
47
|
+
|| t === SecurityTypeProto.TIPS
|
|
48
|
+
|| t === SecurityTypeProto.FRN;
|
|
49
|
+
}
|
|
50
|
+
|
|
32
51
|
|
|
33
52
|
toString(): string {
|
|
34
53
|
return `ID[${this.getID().toString()}], ${this.getSecurityID()}[${this.getIssuerName()}]`;
|
|
@@ -57,8 +76,11 @@ class Security {
|
|
|
57
76
|
case FieldProto.ADJUSTED_TENOR:
|
|
58
77
|
throw new Error('Not implemented yet');
|
|
59
78
|
case FieldProto.MATURITY_DATE:
|
|
60
|
-
|
|
79
|
+
// Maturity date is bond-only. Mirror Java's Security.getField:
|
|
80
|
+
// delegate to BondSecurity, return null for non-bonds.
|
|
81
|
+
return this.isBond() ? this.getMaturityDate() : null;
|
|
61
82
|
case FieldProto.ISSUE_DATE:
|
|
83
|
+
// getIssueDate already returns null on non-bonds; just forward.
|
|
62
84
|
return this.getIssueDate();
|
|
63
85
|
default:
|
|
64
86
|
throw new Error(`Field not mapped in Security wrapper: ${field}`);
|
|
@@ -109,14 +131,36 @@ class Security {
|
|
|
109
131
|
return identifier;
|
|
110
132
|
}
|
|
111
133
|
|
|
112
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Returns the issue date if set, else null. Per-type semantic:
|
|
136
|
+
* - Bond / TIPS / FRN: auction date.
|
|
137
|
+
* - Equity: IPO listing date (when present in source data).
|
|
138
|
+
* - CPI series: first observation date.
|
|
139
|
+
* - Cash / FX: typically null.
|
|
140
|
+
*
|
|
141
|
+
* Returns null on equities/cash/etc. that don't have an issue date set,
|
|
142
|
+
* rather than throwing — issue date is optional on the base Security.
|
|
143
|
+
* For bond-specific code paths, prefer narrowing first via isBond() and
|
|
144
|
+
* calling BondSecurity.getIssueDate() (which returns LocalDate, not null).
|
|
145
|
+
*/
|
|
146
|
+
getIssueDate(): LocalDate | null {
|
|
113
147
|
// Prefer oneof bond sub-message if available, fall back to flat fields
|
|
114
148
|
const bond = this.getBondLikeDetails();
|
|
115
149
|
const date = bond ? bond.getIssueDate() : this.proto.getIssueDate();
|
|
116
|
-
if (!date)
|
|
150
|
+
if (!date) return null;
|
|
117
151
|
return new LocalDate(date);
|
|
118
152
|
}
|
|
119
153
|
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated Maturity date is a bond-only concept. On the base Security
|
|
156
|
+
* this still throws when unset for backwards compatibility. Prefer
|
|
157
|
+
* narrowing first:
|
|
158
|
+
*
|
|
159
|
+
* if (sec.isBond()) sec.getMaturityDate(); // BondSecurity, returns LocalDate
|
|
160
|
+
*
|
|
161
|
+
* In a future major version this method will move to BondSecurity only
|
|
162
|
+
* and TS will catch the misuse at compile time.
|
|
163
|
+
*/
|
|
120
164
|
getMaturityDate(): LocalDate {
|
|
121
165
|
// Prefer oneof bond sub-message if available, fall back to flat fields
|
|
122
166
|
const bond = this.getBondLikeDetails();
|