@fintekkers/ledger-models 1.1.20 → 1.1.22

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.
Files changed (28) hide show
  1. package/hierarchy.json +19 -2
  2. package/node/wrappers/models/errors.d.ts +30 -0
  3. package/node/wrappers/models/errors.js +39 -1
  4. package/node/wrappers/models/errors.js.map +1 -1
  5. package/node/wrappers/models/errors.ts +44 -0
  6. package/node/wrappers/models/security/TreasuryFrnFixings.js +5 -0
  7. package/node/wrappers/models/security/TreasuryFrnFixings.js.map +1 -1
  8. package/node/wrappers/models/security/TreasuryFrnFixings.ts +5 -0
  9. package/node/wrappers/models/security/product_input_builders.test.d.ts +1 -0
  10. package/node/wrappers/models/security/product_input_builders.test.js +192 -0
  11. package/node/wrappers/models/security/product_input_builders.test.js.map +1 -0
  12. package/node/wrappers/models/security/product_input_builders.test.ts +192 -0
  13. package/node/wrappers/models/security/product_inputs.d.ts +79 -0
  14. package/node/wrappers/models/security/product_inputs.js +290 -0
  15. package/node/wrappers/models/security/product_inputs.js.map +1 -0
  16. package/node/wrappers/models/security/product_inputs.test.d.ts +1 -0
  17. package/node/wrappers/models/security/product_inputs.test.js +144 -0
  18. package/node/wrappers/models/security/product_inputs.test.js.map +1 -0
  19. package/node/wrappers/models/security/product_inputs.test.ts +141 -0
  20. package/node/wrappers/models/security/product_inputs.ts +308 -0
  21. package/node/wrappers/requests/valuation/ValuationRequests.d.ts +21 -0
  22. package/node/wrappers/requests/valuation/ValuationRequests.js +33 -0
  23. package/node/wrappers/requests/valuation/ValuationRequests.js.map +1 -0
  24. package/node/wrappers/requests/valuation/ValuationRequests.ts +37 -0
  25. package/node/wrappers/util/object-types.test.js +6 -1
  26. package/node/wrappers/util/object-types.test.js.map +1 -1
  27. package/node/wrappers/util/object-types.test.ts +9 -1
  28. package/package.json +1 -1
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Which ProductInput arm values a security, and which market data that arm
3
+ * needs. Backed by the valuation_arms section of
4
+ * ledger-models-protos/hierarchy.json; there is no mapping table in code.
5
+ * Same rule in Java / Rust / Python / JS-TS. See docs/adr/valuation_arms.md.
6
+ *
7
+ * Resolution walks from the security's product_type up its parent chain. At
8
+ * each node a coupon_types entry matching bond_details.coupon_type wins, then
9
+ * the node's plain entry, then an unpriced listing. The first node with any
10
+ * match decides. No match, or an unpriced match, throws
11
+ * UnmappedProductTypeError: there is no default arm. A broken section throws
12
+ * a plain Error at load, like product_hierarchy.
13
+ *
14
+ * forSecurity builds the ProductInput for that arm from a security, its price
15
+ * and its market data; checkProductInput checks a ProductInput against the
16
+ * same rule (LM-410). See docs/adr/product_input_builders.md.
17
+ */
18
+ import { PriceProto } from '../../../fintekkers/models/price/price_pb';
19
+ import { SecurityProto } from '../../../fintekkers/models/security/security_pb';
20
+ import { InflationIndexInput, ProductInput, ReferenceRateFixingProto, YieldCurveInput } from '../../../fintekkers/requests/valuation/product_inputs_pb';
21
+ /** The closed requires vocabulary: market data an arm needs beyond the price. */
22
+ export type MarketDataKind = 'CPI_U' | 'FRN_FIXINGS' | 'FRN_CURVE';
23
+ interface Arm {
24
+ arm: string;
25
+ requires: ReadonlyArray<MarketDataKind>;
26
+ }
27
+ /** A parsed, checked valuation_arms section. */
28
+ export declare class ValuationArms {
29
+ private readonly entries;
30
+ private readonly unpriced;
31
+ /** @param entries node -> coupon type name (or '' for the plain entry) -> arm */
32
+ constructor(entries: Map<string, Map<string, Arm>>, unpriced: ReadonlySet<string>);
33
+ /** The deepest matching node's arm, or null when unmapped or unpriced. */
34
+ resolve(productType: string, couponType: string): Arm | null;
35
+ require(productType: string, couponType: string): Arm;
36
+ /** Leaf product types (active and planned) with neither an entry nor an unpriced listing. */
37
+ uncoveredLeaves(): string[];
38
+ private covers;
39
+ }
40
+ /**
41
+ * Parses and checks a valuation_arms section against the shipped
42
+ * product_types tree, the ProductInput oneof and the CouponTypeProto /
43
+ * MarketDataKind vocabularies. Throws on any failure. Exported for tests.
44
+ */
45
+ export declare function parseValuationArms(section: unknown): ValuationArms;
46
+ /** The shipped valuation_arms section, parsed and checked on first use. Exported for tests. */
47
+ export declare function shippedValuationArms(): ValuationArms;
48
+ /** Name of the ProductInput.input oneof field that values `security`, e.g. 'tips'. */
49
+ export declare function armFor(security: SecurityProto): string;
50
+ /** Market data the security's arm needs, in file order. A fresh array; empty when none. */
51
+ export declare function requiredMarketData(security: SecurityProto): MarketDataKind[];
52
+ /**
53
+ * Market data for forSecurity, one field per MarketDataKind: CPI_U is `cpi`,
54
+ * FRN_FIXINGS is `fixings`, FRN_CURVE is `curve`. Each is copied to the arm
55
+ * field of the same name (TipsInput.cpi, FrnInput.fixings, FrnInput.curve)
56
+ * when the arm has one; the others are ignored.
57
+ */
58
+ export interface MarketData {
59
+ cpi?: InflationIndexInput;
60
+ fixings?: ReferenceRateFixingProto[];
61
+ curve?: YieldCurveInput;
62
+ }
63
+ /**
64
+ * The ProductInput for `security`, in the arm armFor picks.
65
+ *
66
+ * Sets the arm's security and copies price.price as is into clean_price
67
+ * (bond, tips, frn, mbs) or unit_price (equity, cash). Never sets
68
+ * cost_basis. Throws UnmappedProductTypeError when the type has no arm and
69
+ * MissingMarketDataError when `marketData` lacks a kind the arm requires.
70
+ * The caller's protos are set as they are, not copied or stamped (LM-322).
71
+ */
72
+ export declare function forSecurity(security: SecurityProto, price: PriceProto, marketData?: MarketData | null): ProductInput;
73
+ /**
74
+ * Checks `productInput` is the arm armFor picks for its security, and holds
75
+ * every market-data kind that arm requires. Throws ModelValidationError (no
76
+ * arm, or the wrong arm), UnmappedProductTypeError or MissingMarketDataError.
77
+ */
78
+ export declare function checkProductInput(productInput: ProductInput): void;
79
+ export {};
@@ -0,0 +1,290 @@
1
+ "use strict";
2
+ /**
3
+ * Which ProductInput arm values a security, and which market data that arm
4
+ * needs. Backed by the valuation_arms section of
5
+ * ledger-models-protos/hierarchy.json; there is no mapping table in code.
6
+ * Same rule in Java / Rust / Python / JS-TS. See docs/adr/valuation_arms.md.
7
+ *
8
+ * Resolution walks from the security's product_type up its parent chain. At
9
+ * each node a coupon_types entry matching bond_details.coupon_type wins, then
10
+ * the node's plain entry, then an unpriced listing. The first node with any
11
+ * match decides. No match, or an unpriced match, throws
12
+ * UnmappedProductTypeError: there is no default arm. A broken section throws
13
+ * a plain Error at load, like product_hierarchy.
14
+ *
15
+ * forSecurity builds the ProductInput for that arm from a security, its price
16
+ * and its market data; checkProductInput checks a ProductInput against the
17
+ * same rule (LM-410). See docs/adr/product_input_builders.md.
18
+ */
19
+ var __importDefault = (this && this.__importDefault) || function (mod) {
20
+ return (mod && mod.__esModule) ? mod : { "default": mod };
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.checkProductInput = exports.forSecurity = exports.requiredMarketData = exports.armFor = exports.shippedValuationArms = exports.parseValuationArms = exports.ValuationArms = void 0;
24
+ const hierarchy_json_1 = __importDefault(require("../../../../hierarchy.json"));
25
+ const coupon_type_pb_1 = require("../../../fintekkers/models/security/coupon_type_pb");
26
+ const product_type_pb_1 = require("../../../fintekkers/models/security/product_type_pb");
27
+ const security_pb_1 = require("../../../fintekkers/models/security/security_pb");
28
+ const product_inputs_pb_1 = require("../../../fintekkers/requests/valuation/product_inputs_pb");
29
+ const errors_1 = require("../errors");
30
+ const uuid_1 = require("../utils/uuid");
31
+ const product_hierarchy_1 = require("./product_hierarchy");
32
+ const MARKET_DATA_KINDS = ['CPI_U', 'FRN_FIXINGS', 'FRN_CURVE'];
33
+ /** Map key for a node's entry with no coupon_types. */
34
+ const ANY_COUPON = '';
35
+ function hasOwn(o, key) {
36
+ return Object.prototype.hasOwnProperty.call(o, key);
37
+ }
38
+ function enumName(e, value) {
39
+ for (const [k, v] of Object.entries(e)) {
40
+ if (v === value)
41
+ return k;
42
+ }
43
+ return String(value);
44
+ }
45
+ /** A parsed, checked valuation_arms section. */
46
+ class ValuationArms {
47
+ /** @param entries node -> coupon type name (or '' for the plain entry) -> arm */
48
+ constructor(entries, unpriced) {
49
+ this.entries = entries;
50
+ this.unpriced = unpriced;
51
+ }
52
+ /** The deepest matching node's arm, or null when unmapped or unpriced. */
53
+ resolve(productType, couponType) {
54
+ var _a;
55
+ for (let node = productType; node !== null; node = (0, product_hierarchy_1.parentOf)(node)) {
56
+ const byCoupon = this.entries.get(node);
57
+ const arm = (_a = byCoupon === null || byCoupon === void 0 ? void 0 : byCoupon.get(couponType)) !== null && _a !== void 0 ? _a : byCoupon === null || byCoupon === void 0 ? void 0 : byCoupon.get(ANY_COUPON);
58
+ if (arm)
59
+ return arm;
60
+ if (this.unpriced.has(node))
61
+ return null;
62
+ }
63
+ return null;
64
+ }
65
+ require(productType, couponType) {
66
+ const arm = this.resolve(productType, couponType);
67
+ if (!arm)
68
+ throw new errors_1.UnmappedProductTypeError(productType, couponType);
69
+ return arm;
70
+ }
71
+ /** Leaf product types (active and planned) with neither an entry nor an unpriced listing. */
72
+ uncoveredLeaves() {
73
+ return (0, product_hierarchy_1.allProductTypes)().filter(n => (0, product_hierarchy_1.descendantsOf)(n).length === 0 && !this.covers(n));
74
+ }
75
+ covers(productType) {
76
+ for (let node = productType; node !== null; node = (0, product_hierarchy_1.parentOf)(node)) {
77
+ if (this.entries.has(node) || this.unpriced.has(node))
78
+ return true;
79
+ }
80
+ return false;
81
+ }
82
+ }
83
+ exports.ValuationArms = ValuationArms;
84
+ function bad(detail) {
85
+ return new Error(`hierarchy.json valuation_arms: ${detail}`);
86
+ }
87
+ function stringOf(body, key) {
88
+ const v = body[key];
89
+ if (typeof v !== 'string')
90
+ throw bad(`'${key}' must be a string in ${JSON.stringify(body)}`);
91
+ return v;
92
+ }
93
+ function stringsOf(body, key) {
94
+ const v = body[key];
95
+ if (!Array.isArray(v) || !v.every(x => typeof x === 'string')) {
96
+ throw bad(`'${key}' must be a list of strings in ${JSON.stringify(body)}`);
97
+ }
98
+ return v;
99
+ }
100
+ /**
101
+ * Parses and checks a valuation_arms section against the shipped
102
+ * product_types tree, the ProductInput oneof and the CouponTypeProto /
103
+ * MarketDataKind vocabularies. Throws on any failure. Exported for tests.
104
+ */
105
+ function parseValuationArms(section) {
106
+ if (typeof section !== 'object' || section === null || Array.isArray(section)) {
107
+ throw bad('section must be an object');
108
+ }
109
+ const s = section;
110
+ const productTypes = new Set((0, product_hierarchy_1.allProductTypes)());
111
+ const arms = new Set(Object.keys(product_inputs_pb_1.ProductInput.InputCase)
112
+ .filter(k => k !== 'INPUT_NOT_SET')
113
+ .map(k => k.toLowerCase()));
114
+ if (!Array.isArray(s.entries))
115
+ throw bad("'entries' must be a list");
116
+ const entries = new Map();
117
+ for (const raw of s.entries) {
118
+ if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
119
+ throw bad(`entry must be an object, got ${JSON.stringify(raw)}`);
120
+ }
121
+ const body = raw;
122
+ const node = stringOf(body, 'node');
123
+ if (!productTypes.has(node))
124
+ throw bad(`node '${node}' is not in product_types`);
125
+ const arm = stringOf(body, 'arm');
126
+ if (!arms.has(arm))
127
+ throw bad(`arm '${arm}' is not a ProductInput.input field`);
128
+ const requires = stringsOf(body, 'requires').map(r => {
129
+ if (!MARKET_DATA_KINDS.includes(r)) {
130
+ throw bad(`requires value '${r}' is not one of CPI_U, FRN_FIXINGS, FRN_CURVE`);
131
+ }
132
+ return r;
133
+ });
134
+ let coupons = [ANY_COUPON];
135
+ if (hasOwn(body, 'coupon_types')) {
136
+ coupons = stringsOf(body, 'coupon_types');
137
+ for (const c of coupons) {
138
+ if (!hasOwn(coupon_type_pb_1.CouponTypeProto, c))
139
+ throw bad(`coupon_types value '${c}' is not a CouponTypeProto name`);
140
+ }
141
+ }
142
+ let byCoupon = entries.get(node);
143
+ if (!byCoupon) {
144
+ byCoupon = new Map();
145
+ entries.set(node, byCoupon);
146
+ }
147
+ const value = Object.freeze({ arm, requires: Object.freeze(requires) });
148
+ for (const c of coupons) {
149
+ if (byCoupon.has(c))
150
+ throw bad(`duplicate entry for node ${node}${c ? `, coupon_type ${c}` : ''}`);
151
+ byCoupon.set(c, value);
152
+ }
153
+ }
154
+ const unpriced = new Set();
155
+ for (const node of stringsOf(s, 'unpriced')) {
156
+ if (!productTypes.has(node))
157
+ throw bad(`node '${node}' is not in product_types`);
158
+ if (entries.has(node))
159
+ throw bad(`node ${node} is both mapped and unpriced`);
160
+ unpriced.add(node);
161
+ }
162
+ return new ValuationArms(entries, unpriced);
163
+ }
164
+ exports.parseValuationArms = parseValuationArms;
165
+ let shippedArms;
166
+ /** The shipped valuation_arms section, parsed and checked on first use. Exported for tests. */
167
+ function shippedValuationArms() {
168
+ if (!shippedArms) {
169
+ const section = hierarchy_json_1.default.valuation_arms;
170
+ if (section === undefined)
171
+ throw bad('section missing from hierarchy.json');
172
+ shippedArms = parseValuationArms(section);
173
+ }
174
+ return shippedArms;
175
+ }
176
+ exports.shippedValuationArms = shippedValuationArms;
177
+ function productTypeOf(security) {
178
+ return enumName(product_type_pb_1.ProductTypeProto, security.getProductType());
179
+ }
180
+ /** Read from the proto field only; unset bond_details reads as UNKNOWN_COUPON_TYPE. */
181
+ function couponTypeOf(security) {
182
+ const details = security.getBondDetails();
183
+ return details ? enumName(coupon_type_pb_1.CouponTypeProto, details.getCouponType()) : 'UNKNOWN_COUPON_TYPE';
184
+ }
185
+ /** Name of the ProductInput.input oneof field that values `security`, e.g. 'tips'. */
186
+ function armFor(security) {
187
+ return shippedValuationArms().require(productTypeOf(security), couponTypeOf(security)).arm;
188
+ }
189
+ exports.armFor = armFor;
190
+ /** Market data the security's arm needs, in file order. A fresh array; empty when none. */
191
+ function requiredMarketData(security) {
192
+ return [...shippedValuationArms().require(productTypeOf(security), couponTypeOf(security)).requires];
193
+ }
194
+ exports.requiredMarketData = requiredMarketData;
195
+ /**
196
+ * The ProductInput for `security`, in the arm armFor picks.
197
+ *
198
+ * Sets the arm's security and copies price.price as is into clean_price
199
+ * (bond, tips, frn, mbs) or unit_price (equity, cash). Never sets
200
+ * cost_basis. Throws UnmappedProductTypeError when the type has no arm and
201
+ * MissingMarketDataError when `marketData` lacks a kind the arm requires.
202
+ * The caller's protos are set as they are, not copied or stamped (LM-322).
203
+ */
204
+ function forSecurity(security, price, marketData) {
205
+ var _a;
206
+ const md = marketData !== null && marketData !== void 0 ? marketData : {};
207
+ const arm = armFor(security);
208
+ const p = price.getPrice();
209
+ const out = new product_inputs_pb_1.ProductInput();
210
+ switch (arm) {
211
+ case 'bond':
212
+ out.setBond(new product_inputs_pb_1.BondInput().setSecurity(security).setCleanPrice(p));
213
+ break;
214
+ case 'tips':
215
+ out.setTips(new product_inputs_pb_1.TipsInput().setSecurity(security).setCleanPrice(p).setCpi(md.cpi));
216
+ break;
217
+ case 'frn':
218
+ out.setFrn(new product_inputs_pb_1.FrnInput().setSecurity(security).setCleanPrice(p).setCurve(md.curve)
219
+ .setFixingsList([...((_a = md.fixings) !== null && _a !== void 0 ? _a : [])]));
220
+ break;
221
+ case 'mbs':
222
+ out.setMbs(new product_inputs_pb_1.MbsInput().setSecurity(security).setCleanPrice(p));
223
+ break;
224
+ case 'equity':
225
+ out.setEquity(new product_inputs_pb_1.EquityInput().setSecurity(security).setUnitPrice(p));
226
+ break;
227
+ case 'cash':
228
+ out.setCash(new product_inputs_pb_1.CashInput().setSecurity(security).setUnitPrice(p));
229
+ break;
230
+ default:
231
+ throw new Error(`forSecurity has no builder for arm ${arm}`);
232
+ }
233
+ checkProductInput(out);
234
+ return out;
235
+ }
236
+ exports.forSecurity = forSecurity;
237
+ /**
238
+ * Checks `productInput` is the arm armFor picks for its security, and holds
239
+ * every market-data kind that arm requires. Throws ModelValidationError (no
240
+ * arm, or the wrong arm), UnmappedProductTypeError or MissingMarketDataError.
241
+ */
242
+ function checkProductInput(productInput) {
243
+ var _a;
244
+ const [arm, body] = armOf(productInput);
245
+ if (!body)
246
+ throw new errors_1.ModelValidationError([(0, errors_1.violation)('product_input', undefined, 'no ProductInput arm is set')]);
247
+ const security = (_a = body.getSecurity()) !== null && _a !== void 0 ? _a : new security_pb_1.SecurityProto();
248
+ const productType = productTypeOf(security);
249
+ const resolved = shippedValuationArms().require(productType, couponTypeOf(security));
250
+ if (resolved.arm !== arm) {
251
+ throw new errors_1.ModelValidationError([(0, errors_1.violation)(`product_input.${arm}`, uuidOf(security), `arm ${arm} does not match arm ${resolved.arm} for product_type ${productType}`)]);
252
+ }
253
+ for (const kind of resolved.requires) {
254
+ if (!has(productInput, kind))
255
+ throw new errors_1.MissingMarketDataError(arm, kind, `${arm}.${FIELD_OF[kind]}`, uuidOf(security));
256
+ }
257
+ }
258
+ exports.checkProductInput = checkProductInput;
259
+ /** The set arm's name and message, or [undefined, undefined] when none is set. */
260
+ function armOf(input) {
261
+ switch (input.getInputCase()) {
262
+ case product_inputs_pb_1.ProductInput.InputCase.BOND: return ['bond', input.getBond()];
263
+ case product_inputs_pb_1.ProductInput.InputCase.TIPS: return ['tips', input.getTips()];
264
+ case product_inputs_pb_1.ProductInput.InputCase.FRN: return ['frn', input.getFrn()];
265
+ case product_inputs_pb_1.ProductInput.InputCase.MBS: return ['mbs', input.getMbs()];
266
+ case product_inputs_pb_1.ProductInput.InputCase.EQUITY: return ['equity', input.getEquity()];
267
+ case product_inputs_pb_1.ProductInput.InputCase.CASH: return ['cash', input.getCash()];
268
+ default: return [undefined, undefined];
269
+ }
270
+ }
271
+ /** The ProductInput arm field (and MarketData field) that holds each kind. */
272
+ const FIELD_OF = { CPI_U: 'cpi', FRN_FIXINGS: 'fixings', FRN_CURVE: 'curve' };
273
+ /** Whether `input` holds `kind`. A cpi with neither readings nor reference_cpi does not count. */
274
+ function has(input, kind) {
275
+ var _a, _b, _c, _d, _e;
276
+ switch (kind) {
277
+ case 'CPI_U': {
278
+ const cpi = (_a = input.getTips()) === null || _a === void 0 ? void 0 : _a.getCpi();
279
+ return cpi !== undefined && cpi.getCpiCase() !== product_inputs_pb_1.InflationIndexInput.CpiCase.CPI_NOT_SET;
280
+ }
281
+ case 'FRN_FIXINGS': return ((_c = (_b = input.getFrn()) === null || _b === void 0 ? void 0 : _b.getFixingsList().length) !== null && _c !== void 0 ? _c : 0) > 0;
282
+ case 'FRN_CURVE': return (_e = (_d = input.getFrn()) === null || _d === void 0 ? void 0 : _d.hasCurve()) !== null && _e !== void 0 ? _e : false;
283
+ }
284
+ }
285
+ function uuidOf(security) {
286
+ var _a;
287
+ const raw = (_a = security.getUuid()) === null || _a === void 0 ? void 0 : _a.getRawUuid_asU8();
288
+ return raw && raw.length === 16 ? uuid_1.UUID.fromU8Array(raw) : undefined;
289
+ }
290
+ //# sourceMappingURL=product_inputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product_inputs.js","sourceRoot":"","sources":["product_inputs.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;AAEH,gFAAmD;AACnD,uFAAqF;AACrF,yFAAuF;AAEvF,iFAAgF;AAChF,gGAGkE;AAClE,sCAA8G;AAC9G,wCAAqC;AACrC,2DAA+E;AAK/E,MAAM,iBAAiB,GAA0B,CAAC,OAAO,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;AAEvF,uDAAuD;AACvD,MAAM,UAAU,GAAG,EAAE,CAAC;AAOtB,SAAS,MAAM,CAAC,CAAS,EAAE,GAAW;IACpC,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS,EAAE,KAAa;IACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QACtC,IAAI,CAAC,KAAK,KAAK;YAAE,OAAO,CAAC,CAAC;KAC3B;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,gDAAgD;AAChD,MAAa,aAAa;IACxB,iFAAiF;IACjF,YACmB,OAAsC,EACtC,QAA6B;QAD7B,YAAO,GAAP,OAAO,CAA+B;QACtC,aAAQ,GAAR,QAAQ,C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C,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;KACxC;AACH,CAAC;AAED,8EAA8E;AAC9E,MAAM,QAAQ,GAA6C,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAExH,kGAAkG;AAClG,SAAS,GAAG,CAAC,KAAmB,EAAE,IAAoB;;IACpD,QAAQ,IAAI,EAAE;QACZ,KAAK,OAAO,CAAC,CAAC;YACZ,MAAM,GAAG,GAAG,MAAA,KAAK,CAAC,OAAO,EAAE,0CAAE,MAAM,EAAE,CAAC;YACtC,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,UAAU,EAAE,KAAK,uCAAmB,CAAC,OAAO,CAAC,WAAW,CAAC;SAC1F;QACD,KAAK,aAAa,CAAC,CAAC,OAAO,CAAC,MAAA,MAAA,KAAK,CAAC,MAAM,EAAE,0CAAE,cAAc,GAAG,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAC9E,KAAK,WAAW,CAAC,CAAC,OAAO,MAAA,MAAA,KAAK,CAAC,MAAM,EAAE,0CAAE,QAAQ,EAAE,mCAAI,KAAK,CAAC;KAC9D;AACH,CAAC;AAED,SAAS,MAAM,CAAC,QAAuB;;IACrC,MAAM,GAAG,GAAG,MAAA,QAAQ,CAAC,OAAO,EAAE,0CAAE,eAAe,EAAE,CAAC;IAClD,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,WAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtE,CAAC"}
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ /**
27
+ * LM-409: valuation_arms in hierarchy.json, resolved by armFor /
28
+ * requiredMarketData.
29
+ *
30
+ * The shared cases live in ledger-models-protos/fixtures/valuation_arms_cases.json,
31
+ * read by the Java, Python and Rust tests too.
32
+ */
33
+ const fs = __importStar(require("fs"));
34
+ const path = __importStar(require("path"));
35
+ const product_inputs_1 = require("./product_inputs");
36
+ const product_hierarchy_1 = require("./product_hierarchy");
37
+ const errors_1 = require("../errors");
38
+ const coupon_type_pb_1 = require("../../../fintekkers/models/security/coupon_type_pb");
39
+ const product_type_pb_1 = require("../../../fintekkers/models/security/product_type_pb");
40
+ const security_pb_1 = require("../../../fintekkers/models/security/security_pb");
41
+ const PROTOS = path.resolve(__dirname, '../../../../../ledger-models-protos');
42
+ const BUNDLED = path.resolve(__dirname, '../../../../hierarchy.json');
43
+ const cases = JSON.parse(fs.readFileSync(path.join(PROTOS, 'fixtures/valuation_arms_cases.json'), 'utf-8')).cases;
44
+ function sourceSection() {
45
+ return JSON.parse(fs.readFileSync(path.join(PROTOS, 'hierarchy.json'), 'utf-8')).valuation_arms;
46
+ }
47
+ function hasEnumValue(productType) {
48
+ return Object.prototype.hasOwnProperty.call(product_type_pb_1.ProductTypeProto, productType);
49
+ }
50
+ function security(productType, couponType) {
51
+ const details = new security_pb_1.BondDetailsProto();
52
+ details.setCouponType(coupon_type_pb_1.CouponTypeProto[couponType]);
53
+ const s = new security_pb_1.SecurityProto();
54
+ s.setProductType(product_type_pb_1.ProductTypeProto[productType]);
55
+ s.setBondDetails(details);
56
+ return s;
57
+ }
58
+ /** [arm, requires] through a real proto when the type has an enum value; planned leaves by name. */
59
+ function resolve(productType, couponType) {
60
+ if (!hasEnumValue(productType)) {
61
+ const a = (0, product_inputs_1.shippedValuationArms)().require(productType, couponType);
62
+ return [a.arm, [...a.requires]];
63
+ }
64
+ const s = security(productType, couponType);
65
+ return [(0, product_inputs_1.armFor)(s), (0, product_inputs_1.requiredMarketData)(s)];
66
+ }
67
+ function catchUnmapped(fn) {
68
+ try {
69
+ fn();
70
+ }
71
+ catch (e) {
72
+ if (e instanceof errors_1.UnmappedProductTypeError)
73
+ return e;
74
+ throw e;
75
+ }
76
+ throw new Error('expected UnmappedProductTypeError');
77
+ }
78
+ describe('valuation_arms shared fixture (metric 1)', () => {
79
+ test('has the required cases', () => {
80
+ expect(cases.length).toBeGreaterThanOrEqual(5);
81
+ const seen = cases.map(c => `${c.product_type}/${c.coupon_type}`);
82
+ expect(seen).toEqual(expect.arrayContaining([
83
+ 'TBILL/ZERO', 'TIPS/FIXED', 'CORP_BOND/FLOAT', 'TREASURY_NOTE/FLOAT', 'FX_SPOT/UNKNOWN_COUPON_TYPE',
84
+ ]));
85
+ });
86
+ test.each(cases.map(c => [`${c.product_type}/${c.coupon_type}`, c]))('%s', (_, c) => {
87
+ if (c.error !== undefined) {
88
+ expect(c.error).toBe('UnmappedProductTypeError');
89
+ const e = catchUnmapped(() => resolve(c.product_type, c.coupon_type));
90
+ expect([e.productType, e.couponType]).toEqual([c.product_type, c.coupon_type]);
91
+ }
92
+ else {
93
+ expect(resolve(c.product_type, c.coupon_type)).toEqual([c.arm, c.requires]);
94
+ }
95
+ });
96
+ });
97
+ describe('unmapped types raise (metric 2)', () => {
98
+ const unmapped = new Set(['FX_SPOT']);
99
+ for (const root of ['INDEX', 'CRYPTO', 'COMMODITY_SPOT']) {
100
+ for (const n of (0, product_hierarchy_1.descendantsOf)(root))
101
+ if ((0, product_hierarchy_1.descendantsOf)(n).length === 0)
102
+ unmapped.add(n);
103
+ }
104
+ test('the set comes from the registry', () => {
105
+ expect([...unmapped]).toEqual(expect.arrayContaining([
106
+ 'FX_SPOT', 'COMMODITY_INDEX', 'PLATINUM', 'PALLADIUM', 'CRYPTOCURRENCY', 'GOLD',
107
+ ]));
108
+ });
109
+ test.each([...unmapped].sort())('%s', pt => {
110
+ const e = catchUnmapped(() => resolve(pt, 'UNKNOWN_COUPON_TYPE'));
111
+ expect(e.message).toContain(pt);
112
+ expect(e.message).toContain('UNKNOWN_COUPON_TYPE');
113
+ });
114
+ test('message names product and coupon type', () => {
115
+ const gold = security('GOLD', 'FLOAT');
116
+ const e = catchUnmapped(() => (0, product_inputs_1.armFor)(gold));
117
+ expect(e.message).toContain('GOLD');
118
+ expect(e.message).toContain('FLOAT');
119
+ expect(() => (0, product_inputs_1.requiredMarketData)(gold)).toThrow(errors_1.UnmappedProductTypeError);
120
+ });
121
+ test('unset bond_details reads as UNKNOWN_COUPON_TYPE', () => {
122
+ const corp = new security_pb_1.SecurityProto();
123
+ corp.setProductType(product_type_pb_1.ProductTypeProto.CORP_BOND);
124
+ expect((0, product_inputs_1.armFor)(corp)).toBe('bond');
125
+ const fx = new security_pb_1.SecurityProto();
126
+ fx.setProductType(product_type_pb_1.ProductTypeProto.FX_SPOT);
127
+ expect(catchUnmapped(() => (0, product_inputs_1.armFor)(fx)).couponType).toBe('UNKNOWN_COUPON_TYPE');
128
+ });
129
+ });
130
+ test('bundled valuation_arms equals the source (metric 4)', () => {
131
+ expect(fs.existsSync(BUNDLED)).toBe(true);
132
+ const bundled = JSON.parse(fs.readFileSync(BUNDLED, 'utf-8'));
133
+ expect(bundled.valuation_arms).toBeDefined();
134
+ expect(bundled.valuation_arms).toEqual(sourceSection());
135
+ });
136
+ test('parse rejects a requires value outside the vocabulary (metric 5)', () => {
137
+ const section = sourceSection();
138
+ section.entries[0].requires.push('FX_RATE');
139
+ expect(() => (0, product_inputs_1.parseValuationArms)(section)).toThrow(/FX_RATE/);
140
+ });
141
+ test('every leaf is covered (metric 3)', () => {
142
+ expect((0, product_inputs_1.shippedValuationArms)().uncoveredLeaves()).toEqual([]);
143
+ });
144
+ //# sourceMappingURL=product_inputs.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product_inputs.test.js","sourceRoot":"","sources":["product_inputs.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,uCAAyB;AACzB,2CAA6B;AAE7B,qDAAwG;AACxG,2DAAoD;AACpD,sCAAqD;AACrD,uFAAqF;AACrF,yFAAuF;AACvF,iFAAkG;AAElG,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,qCAAqC,CAAC,CAAC;AAC9E,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,4BAA4B,CAAC,CAAC;AAUtE,MAAM,KAAK,GAAW,IAAI,CAAC,KAAK,CAC9B,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,oCAAoC,CAAC,EAAE,OAAO,CAAC,CAClF,CAAC,KAAK,CAAC;AAER,SAAS,aAAa;IACpB,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC;AAClG,CAAC;AAED,SAAS,YAAY,CAAC,WAAmB;IACvC,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,kCAAgB,EAAE,WAAW,CAAC,CAAC;AAC7E,CAAC;AA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