@fintekkers/ledger-models 0.4.42 → 0.4.44

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 (254) hide show
  1. package/node/fintekkers/models/portfolio/portfolio_pb.d.ts +7 -15
  2. package/node/fintekkers/models/portfolio/portfolio_pb.js +35 -132
  3. package/node/fintekkers/models/position/position_filter_pb.d.ts +7 -15
  4. package/node/fintekkers/models/position/position_filter_pb.js +35 -132
  5. package/node/fintekkers/models/position/position_pb.d.ts +7 -15
  6. package/node/fintekkers/models/position/position_pb.js +35 -132
  7. package/node/fintekkers/models/price/price_pb.d.ts +7 -15
  8. package/node/fintekkers/models/price/price_pb.js +35 -132
  9. package/node/fintekkers/models/security/bond/issuance_pb.d.ts +7 -15
  10. package/node/fintekkers/models/security/bond/issuance_pb.js +35 -132
  11. package/node/fintekkers/models/security/identifier/identifier_pb.d.ts +7 -15
  12. package/node/fintekkers/models/security/identifier/identifier_pb.js +35 -132
  13. package/node/fintekkers/models/security/index_composition_pb.d.ts +7 -15
  14. package/node/fintekkers/models/security/index_composition_pb.js +35 -132
  15. package/node/fintekkers/models/security/security_pb.d.ts +7 -15
  16. package/node/fintekkers/models/security/security_pb.js +35 -132
  17. package/node/fintekkers/models/security/security_pb.test.js +4 -8
  18. package/node/fintekkers/models/security/security_pb.test.js.map +1 -1
  19. package/node/fintekkers/models/security/security_pb.test.ts +4 -5
  20. package/node/fintekkers/models/security/tenor_pb.d.ts +7 -15
  21. package/node/fintekkers/models/security/tenor_pb.js +35 -132
  22. package/node/fintekkers/models/strategy/strategy_allocation_pb.d.ts +7 -15
  23. package/node/fintekkers/models/strategy/strategy_allocation_pb.js +35 -132
  24. package/node/fintekkers/models/strategy/strategy_pb.d.ts +7 -15
  25. package/node/fintekkers/models/strategy/strategy_pb.js +35 -132
  26. package/node/fintekkers/models/transaction/transaction_pb.d.ts +7 -15
  27. package/node/fintekkers/models/transaction/transaction_pb.js +35 -132
  28. package/node/fintekkers/models/util/api/api_key_pb.d.ts +7 -15
  29. package/node/fintekkers/models/util/api/api_key_pb.js +35 -132
  30. package/node/fintekkers/models/util/date_range_pb.d.ts +7 -15
  31. package/node/fintekkers/models/util/date_range_pb.js +35 -132
  32. package/node/fintekkers/models/util/decimal_value_pb.d.ts +0 -5
  33. package/node/fintekkers/models/util/decimal_value_pb.js +0 -30
  34. package/node/fintekkers/models/util/lock/node_partition_pb.d.ts +7 -15
  35. package/node/fintekkers/models/util/lock/node_partition_pb.js +35 -132
  36. package/node/fintekkers/models/util/lock/node_state_pb.d.ts +7 -15
  37. package/node/fintekkers/models/util/lock/node_state_pb.js +35 -132
  38. package/node/fintekkers/models/util/object_type_pb.d.ts +0 -3
  39. package/node/fintekkers/models/util/object_type_pb.js +0 -28
  40. package/node/fintekkers/models/util/version_grpc_pb.js +1 -0
  41. package/node/fintekkers/models/util/version_pb.d.ts +33 -0
  42. package/node/fintekkers/models/util/version_pb.js +236 -0
  43. package/node/fintekkers/requests/index_composition/create_index_composition_request_pb.d.ts +13 -30
  44. package/node/fintekkers/requests/index_composition/create_index_composition_request_pb.js +68 -264
  45. package/node/fintekkers/requests/index_composition/get_index_composition_request_pb.d.ts +13 -30
  46. package/node/fintekkers/requests/index_composition/get_index_composition_request_pb.js +68 -264
  47. package/node/fintekkers/requests/portfolio/create_portfolio_request_pb.d.ts +7 -15
  48. package/node/fintekkers/requests/portfolio/create_portfolio_request_pb.js +35 -132
  49. package/node/fintekkers/requests/portfolio/create_portfolio_response_pb.d.ts +7 -15
  50. package/node/fintekkers/requests/portfolio/create_portfolio_response_pb.js +35 -132
  51. package/node/fintekkers/requests/portfolio/query_portfolio_request_pb.d.ts +7 -15
  52. package/node/fintekkers/requests/portfolio/query_portfolio_request_pb.js +35 -132
  53. package/node/fintekkers/requests/portfolio/query_portfolio_response_pb.d.ts +7 -15
  54. package/node/fintekkers/requests/portfolio/query_portfolio_response_pb.js +35 -132
  55. package/node/fintekkers/requests/position/query_position_request_pb.d.ts +7 -15
  56. package/node/fintekkers/requests/position/query_position_request_pb.js +35 -132
  57. package/node/fintekkers/requests/position/query_position_response_pb.d.ts +7 -15
  58. package/node/fintekkers/requests/position/query_position_response_pb.js +35 -132
  59. package/node/fintekkers/requests/price/create_price_request_pb.d.ts +7 -15
  60. package/node/fintekkers/requests/price/create_price_request_pb.js +35 -132
  61. package/node/fintekkers/requests/price/create_price_response_pb.d.ts +7 -15
  62. package/node/fintekkers/requests/price/create_price_response_pb.js +35 -132
  63. package/node/fintekkers/requests/price/query_price_request_pb.d.ts +7 -15
  64. package/node/fintekkers/requests/price/query_price_request_pb.js +35 -132
  65. package/node/fintekkers/requests/price/query_price_response_pb.d.ts +7 -15
  66. package/node/fintekkers/requests/price/query_price_response_pb.js +35 -132
  67. package/node/fintekkers/requests/security/create_security_request_pb.d.ts +7 -15
  68. package/node/fintekkers/requests/security/create_security_request_pb.js +35 -132
  69. package/node/fintekkers/requests/security/create_security_response_pb.d.ts +7 -15
  70. package/node/fintekkers/requests/security/create_security_response_pb.js +35 -132
  71. package/node/fintekkers/requests/security/get_field_values_request_pb.d.ts +7 -15
  72. package/node/fintekkers/requests/security/get_field_values_request_pb.js +35 -132
  73. package/node/fintekkers/requests/security/get_field_values_response_pb.d.ts +7 -15
  74. package/node/fintekkers/requests/security/get_field_values_response_pb.js +35 -132
  75. package/node/fintekkers/requests/security/get_fields_response_pb.d.ts +7 -15
  76. package/node/fintekkers/requests/security/get_fields_response_pb.js +35 -132
  77. package/node/fintekkers/requests/security/query_security_request_pb.d.ts +7 -15
  78. package/node/fintekkers/requests/security/query_security_request_pb.js +35 -132
  79. package/node/fintekkers/requests/security/query_security_response_pb.d.ts +7 -15
  80. package/node/fintekkers/requests/security/query_security_response_pb.js +35 -132
  81. package/node/fintekkers/requests/transaction/create_transaction_request_pb.d.ts +7 -15
  82. package/node/fintekkers/requests/transaction/create_transaction_request_pb.js +35 -132
  83. package/node/fintekkers/requests/transaction/create_transaction_response_pb.d.ts +7 -15
  84. package/node/fintekkers/requests/transaction/create_transaction_response_pb.js +35 -132
  85. package/node/fintekkers/requests/transaction/query_transaction_request_pb.d.ts +7 -15
  86. package/node/fintekkers/requests/transaction/query_transaction_request_pb.js +35 -132
  87. package/node/fintekkers/requests/transaction/query_transaction_response_pb.d.ts +7 -15
  88. package/node/fintekkers/requests/transaction/query_transaction_response_pb.js +35 -132
  89. package/node/fintekkers/requests/util/delete_request_pb.d.ts +13 -30
  90. package/node/fintekkers/requests/util/delete_request_pb.js +68 -264
  91. package/node/fintekkers/requests/util/lock/lock_request_pb.d.ts +7 -15
  92. package/node/fintekkers/requests/util/lock/lock_request_pb.js +35 -132
  93. package/node/fintekkers/requests/util/lock/lock_response_pb.d.ts +7 -15
  94. package/node/fintekkers/requests/util/lock/lock_response_pb.js +35 -132
  95. package/node/fintekkers/requests/valuation/curve_request_pb.d.ts +7 -15
  96. package/node/fintekkers/requests/valuation/curve_request_pb.js +35 -132
  97. package/node/fintekkers/requests/valuation/curve_response_pb.d.ts +19 -15
  98. package/node/fintekkers/requests/valuation/curve_response_pb.js +138 -133
  99. package/node/fintekkers/requests/valuation/product_inputs.test.js +10 -17
  100. package/node/fintekkers/requests/valuation/product_inputs.test.js.map +1 -1
  101. package/node/fintekkers/requests/valuation/product_inputs.test.ts +10 -16
  102. package/node/fintekkers/requests/valuation/valuation_request_pb.d.ts +7 -15
  103. package/node/fintekkers/requests/valuation/valuation_request_pb.js +35 -132
  104. package/node/fintekkers/requests/valuation/valuation_response_pb.d.ts +7 -15
  105. package/node/fintekkers/requests/valuation/valuation_response_pb.js +35 -132
  106. package/node/wrappers/models/portfolio/portfolio.test.js +0 -2
  107. package/node/wrappers/models/portfolio/portfolio.test.js.map +1 -1
  108. package/node/wrappers/models/portfolio/portfolio.test.ts +0 -2
  109. package/node/wrappers/models/portfolio-price-transaction.lazy-hydrate.test.js +2 -3
  110. package/node/wrappers/models/portfolio-price-transaction.lazy-hydrate.test.js.map +1 -1
  111. package/node/wrappers/models/portfolio-price-transaction.lazy-hydrate.test.ts +2 -2
  112. package/node/wrappers/models/position/position.test.js +5 -6
  113. package/node/wrappers/models/position/position.test.js.map +1 -1
  114. package/node/wrappers/models/position/position.test.ts +5 -4
  115. package/node/wrappers/models/position/positionfilter.js +1 -1
  116. package/node/wrappers/models/position/positionfilter.js.map +1 -1
  117. package/node/wrappers/models/position/positionfilter.test.js +4 -2
  118. package/node/wrappers/models/position/positionfilter.test.js.map +1 -1
  119. package/node/wrappers/models/position/positionfilter.test.ts +3 -2
  120. package/node/wrappers/models/position/positionfilter.ts +1 -1
  121. package/node/wrappers/models/price/Price.cash.test.js +4 -5
  122. package/node/wrappers/models/price/Price.cash.test.js.map +1 -1
  123. package/node/wrappers/models/price/Price.cash.test.ts +2 -3
  124. package/node/wrappers/models/price/Price.js +2 -2
  125. package/node/wrappers/models/price/Price.js.map +1 -1
  126. package/node/wrappers/models/price/Price.test.js +4 -2
  127. package/node/wrappers/models/price/Price.test.js.map +1 -1
  128. package/node/wrappers/models/price/Price.test.ts +4 -2
  129. package/node/wrappers/models/price/Price.ts +2 -2
  130. package/node/wrappers/models/price/price_rules.test.js +9 -4
  131. package/node/wrappers/models/price/price_rules.test.js.map +1 -1
  132. package/node/wrappers/models/price/price_rules.test.ts +9 -4
  133. package/node/wrappers/models/security/BondSecurity.priceScale.test.js +2 -4
  134. package/node/wrappers/models/security/BondSecurity.priceScale.test.js.map +1 -1
  135. package/node/wrappers/models/security/BondSecurity.priceScale.test.ts +2 -3
  136. package/node/wrappers/models/security/BondSecurity.test.js +7 -13
  137. package/node/wrappers/models/security/BondSecurity.test.js.map +1 -1
  138. package/node/wrappers/models/security/BondSecurity.test.ts +7 -12
  139. package/node/wrappers/models/security/IndexSecurity.test.js +0 -8
  140. package/node/wrappers/models/security/IndexSecurity.test.js.map +1 -1
  141. package/node/wrappers/models/security/IndexSecurity.test.ts +0 -8
  142. package/node/wrappers/models/security/Issuance.test.js +6 -6
  143. package/node/wrappers/models/security/Issuance.test.js.map +1 -1
  144. package/node/wrappers/models/security/Issuance.test.ts +6 -5
  145. package/node/wrappers/models/security/MortgageBackedSecurity.fromPricerInputs.test.js +13 -14
  146. package/node/wrappers/models/security/MortgageBackedSecurity.fromPricerInputs.test.js.map +1 -1
  147. package/node/wrappers/models/security/MortgageBackedSecurity.fromPricerInputs.test.ts +13 -12
  148. package/node/wrappers/models/security/security-roundtrip.test.js +9 -21
  149. package/node/wrappers/models/security/security-roundtrip.test.js.map +1 -1
  150. package/node/wrappers/models/security/security-roundtrip.test.ts +9 -20
  151. package/node/wrappers/models/security/security.identifiers.test.js +0 -2
  152. package/node/wrappers/models/security/security.identifiers.test.js.map +1 -1
  153. package/node/wrappers/models/security/security.identifiers.test.ts +0 -2
  154. package/node/wrappers/models/security/security.tbillCoupon.test.js +3 -2
  155. package/node/wrappers/models/security/security.tbillCoupon.test.js.map +1 -1
  156. package/node/wrappers/models/security/security.tbillCoupon.test.ts +3 -2
  157. package/node/wrappers/models/security/security.test.js +14 -14
  158. package/node/wrappers/models/security/security.test.js.map +1 -1
  159. package/node/wrappers/models/security/security.test.ts +14 -13
  160. package/node/wrappers/models/transaction/transaction.derived.test.js +3 -9
  161. package/node/wrappers/models/transaction/transaction.derived.test.js.map +1 -1
  162. package/node/wrappers/models/transaction/transaction.derived.test.ts +3 -8
  163. package/node/wrappers/models/transaction/transaction.js +2 -2
  164. package/node/wrappers/models/transaction/transaction.js.map +1 -1
  165. package/node/wrappers/models/transaction/transaction.test.js +3 -3
  166. package/node/wrappers/models/transaction/transaction.test.js.map +1 -1
  167. package/node/wrappers/models/transaction/transaction.test.ts +3 -2
  168. package/node/wrappers/models/transaction/transaction.ts +2 -2
  169. package/node/wrappers/models/transaction/transaction_constructor.test.js +6 -9
  170. package/node/wrappers/models/transaction/transaction_constructor.test.js.map +1 -1
  171. package/node/wrappers/models/transaction/transaction_constructor.test.ts +6 -7
  172. package/node/wrappers/models/transaction/transaction_price_defaults.test.js +2 -10
  173. package/node/wrappers/models/transaction/transaction_price_defaults.test.js.map +1 -1
  174. package/node/wrappers/models/transaction/transaction_price_defaults.test.ts +2 -9
  175. package/node/wrappers/models/transaction/transaction_security_defaults.test.js +0 -6
  176. package/node/wrappers/models/transaction/transaction_security_defaults.test.js.map +1 -1
  177. package/node/wrappers/models/transaction/transaction_security_defaults.test.ts +0 -6
  178. package/node/wrappers/models/utils/date.test.js +0 -2
  179. package/node/wrappers/models/utils/date.test.js.map +1 -1
  180. package/node/wrappers/models/utils/date.test.ts +0 -2
  181. package/node/wrappers/models/utils/datetime.test.js +0 -2
  182. package/node/wrappers/models/utils/datetime.test.js.map +1 -1
  183. package/node/wrappers/models/utils/datetime.test.ts +0 -2
  184. package/node/wrappers/models/utils/decimal.d.ts +9 -28
  185. package/node/wrappers/models/utils/decimal.js +13 -52
  186. package/node/wrappers/models/utils/decimal.js.map +1 -1
  187. package/node/wrappers/models/utils/decimal.test.js +12 -68
  188. package/node/wrappers/models/utils/decimal.test.js.map +1 -1
  189. package/node/wrappers/models/utils/decimal.test.ts +14 -76
  190. package/node/wrappers/models/utils/decimal.ts +12 -60
  191. package/node/wrappers/models/utils/serialization.test.js +0 -4
  192. package/node/wrappers/models/utils/serialization.test.js.map +1 -1
  193. package/node/wrappers/models/utils/serialization.test.ts +0 -4
  194. package/node/wrappers/requests/position/QueryPositionRequest.js +1 -1
  195. package/node/wrappers/requests/position/QueryPositionRequest.js.map +1 -1
  196. package/node/wrappers/requests/position/QueryPositionRequest.ts +1 -1
  197. package/node/wrappers/requests/query-paging.test.js +4 -28
  198. package/node/wrappers/requests/query-paging.test.js.map +1 -1
  199. package/node/wrappers/requests/query-paging.test.ts +3 -36
  200. package/node/wrappers/services/portfolio-service/PortfolioService.js +3 -3
  201. package/node/wrappers/services/portfolio-service/PortfolioService.js.map +1 -1
  202. package/node/wrappers/services/portfolio-service/PortfolioService.ts +3 -3
  203. package/node/wrappers/services/portfolio-service/portfolioService.test.js +0 -2
  204. package/node/wrappers/services/portfolio-service/portfolioService.test.js.map +1 -1
  205. package/node/wrappers/services/portfolio-service/portfolioService.test.ts +0 -2
  206. package/node/wrappers/services/price-service/PriceService.js +3 -3
  207. package/node/wrappers/services/price-service/PriceService.js.map +1 -1
  208. package/node/wrappers/services/price-service/PriceService.ts +3 -3
  209. package/node/wrappers/services/price-service/price-wrapper.test.js +2 -6
  210. package/node/wrappers/services/price-service/price-wrapper.test.js.map +1 -1
  211. package/node/wrappers/services/price-service/price-wrapper.test.ts +2 -6
  212. package/node/wrappers/services/price-service/price.test.js +8 -17
  213. package/node/wrappers/services/price-service/price.test.js.map +1 -1
  214. package/node/wrappers/services/price-service/price.test.ts +8 -14
  215. package/node/wrappers/services/searchWithSecurities.test.js +2 -7
  216. package/node/wrappers/services/searchWithSecurities.test.js.map +1 -1
  217. package/node/wrappers/services/searchWithSecurities.test.ts +2 -6
  218. package/node/wrappers/services/security-service/SecurityService.js +3 -3
  219. package/node/wrappers/services/security-service/SecurityService.js.map +1 -1
  220. package/node/wrappers/services/security-service/SecurityService.ts +3 -3
  221. package/node/wrappers/services/security-service/security.test.js +3 -7
  222. package/node/wrappers/services/security-service/security.test.js.map +1 -1
  223. package/node/wrappers/services/security-service/security.test.ts +3 -6
  224. package/node/wrappers/services/transaction-service/TransactionService.js +3 -3
  225. package/node/wrappers/services/transaction-service/TransactionService.js.map +1 -1
  226. package/node/wrappers/services/transaction-service/TransactionService.ts +3 -3
  227. package/node/wrappers/services/transaction-service/transaction.test.js +3 -8
  228. package/node/wrappers/services/transaction-service/transaction.test.js.map +1 -1
  229. package/node/wrappers/services/transaction-service/transaction.test.ts +3 -6
  230. package/node/wrappers/util/link-resolver.js +3 -3
  231. package/node/wrappers/util/link-resolver.js.map +1 -1
  232. package/node/wrappers/util/link-resolver.test.js +4 -13
  233. package/node/wrappers/util/link-resolver.test.js.map +1 -1
  234. package/node/wrappers/util/link-resolver.test.ts +4 -12
  235. package/node/wrappers/util/link-resolver.ts +3 -3
  236. package/node/wrappers/util/object-types.d.ts +21 -47
  237. package/node/wrappers/util/object-types.js +19 -178
  238. package/node/wrappers/util/object-types.js.map +1 -1
  239. package/node/wrappers/util/object-types.test.js +50 -151
  240. package/node/wrappers/util/object-types.test.js.map +1 -1
  241. package/node/wrappers/util/object-types.test.ts +55 -170
  242. package/node/wrappers/util/object-types.ts +28 -182
  243. package/package.json +1 -1
  244. package/node/wrappers/models/position/position.test copy.js +0 -107
  245. package/node/wrappers/models/position/position.test copy.js.map +0 -1
  246. package/node/wrappers/models/utils/decimal.legacy.test.d.ts +0 -1
  247. package/node/wrappers/models/utils/decimal.legacy.test.js +0 -174
  248. package/node/wrappers/models/utils/decimal.legacy.test.js.map +0 -1
  249. package/node/wrappers/models/utils/decimal.legacy.test.ts +0 -158
  250. package/node/wrappers/models/utils/decimal.typings.test.d.ts +0 -1
  251. package/node/wrappers/models/utils/decimal.typings.test.js +0 -39
  252. package/node/wrappers/models/utils/decimal.typings.test.js.map +0 -1
  253. package/node/wrappers/models/utils/decimal.typings.test.ts +0 -16
  254. package/node/wrappers/util/object-type-legacy.json +0 -21
@@ -1 +0,0 @@
1
- export {};
@@ -1,174 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const fs = __importStar(require("fs"));
30
- const path = __importStar(require("path"));
31
- const decimal_js_1 = require("decimal.js");
32
- const price_pb_1 = require("../../../fintekkers/models/price/price_pb");
33
- const security_pb_1 = require("../../../fintekkers/models/security/security_pb");
34
- const transaction_pb_1 = require("../../../fintekkers/models/transaction/transaction_pb");
35
- const decimal_value_pb_1 = require("../../../fintekkers/models/util/decimal_value_pb");
36
- const Price_1 = __importDefault(require("../price/Price"));
37
- const security_1 = __importDefault(require("../security/security"));
38
- const MortgageBackedSecurity_1 = __importDefault(require("../security/MortgageBackedSecurity"));
39
- const transaction_1 = __importDefault(require("../transaction/transaction"));
40
- const serialization_1 = require("./serialization");
41
- const uuid_1 = require("./uuid");
42
- const portfolio_1 = __importDefault(require("../portfolio/portfolio"));
43
- const portfolio_pb_1 = require("../../../fintekkers/models/portfolio/portfolio_pb");
44
- const decimal_1 = require("./decimal");
45
- /**
46
- * Metric 2 (LM-306): bytes written by ledger-models v0.4.33 carry only the
47
- * string form. They load through the wrappers to the same value and scale,
48
- * and re-saving them writes both forms.
49
- */
50
- const LEGACY = path.join(__dirname, '../../../../../ledger-models-protos/fixtures/legacy_v0433');
51
- const DESERIALIZERS = {
52
- PriceProto: b => price_pb_1.PriceProto.deserializeBinary(b),
53
- SecurityProto: b => security_pb_1.SecurityProto.deserializeBinary(b),
54
- TransactionProto: b => transaction_pb_1.TransactionProto.deserializeBinary(b),
55
- };
56
- function load(name) {
57
- const fixture = JSON.parse(fs.readFileSync(path.join(LEGACY, `${name}.json`), 'utf8'));
58
- const deserialize = DESERIALIZERS[fixture.message];
59
- if (!deserialize)
60
- throw new Error(`no deserializer for ${fixture.message}`);
61
- return { fixture, message: deserialize(new Uint8Array(fs.readFileSync(path.join(LEGACY, fixture.bin)))) };
62
- }
63
- const pascal = (segment) => segment.split('_').map(w => w[0].toUpperCase() + w.slice(1)).join('');
64
- /** Walks `a.b_c` with getA().getBC(). */
65
- function walk(message, dotted) {
66
- return dotted.split('.').reduce((m, segment) => {
67
- const value = m[`get${pascal(segment)}`]();
68
- if (value === undefined)
69
- throw new Error(`${dotted}: ${segment} is unset`);
70
- return value;
71
- }, message);
72
- }
73
- /** The wrapper getter that reads each path, as Rust's `read_by` names it. */
74
- function readByWrapper(message, dotted) {
75
- const mbs = (security) => {
76
- const wrapped = security_1.default.create(security);
77
- expect(wrapped).toBeInstanceOf(MortgageBackedSecurity_1.default);
78
- return wrapped;
79
- };
80
- const parts = dotted.split('.');
81
- const field = parts[parts.length - 1];
82
- if (dotted === 'price')
83
- return new Price_1.default(message).getPrice();
84
- if (dotted === 'quantity')
85
- return new transaction_1.default(message).getQuantity();
86
- if (dotted === 'price.price')
87
- return new Price_1.default(new transaction_1.default(message).getPrice()).getPrice();
88
- const security = parts[0] === 'security' ? walk(message, 'security') : message;
89
- const getter = `get${pascal(field)}`;
90
- const value = mbs(security)[getter]();
91
- if (!(value instanceof decimal_js_1.Decimal))
92
- throw new Error(`${dotted}: ${getter} did not return a Decimal`);
93
- return value;
94
- }
95
- beforeAll(() => {
96
- (0, decimal_1.setDecimalLogger)({ warn: jest.fn() });
97
- });
98
- describe.each(['price', 'security', 'transaction'])('legacy_v0433/%s', (name) => {
99
- const { fixture } = load(name);
100
- test.each(fixture.decimals.map(d => [d.path, d]))('%s reads through the wrapper', (_p, d) => {
101
- const { message } = load(name);
102
- const proto = walk(message, d.path);
103
- // Really string-only bytes.
104
- expect(proto.getUnscaledValue_asU8().length).toBe(0);
105
- expect(proto.getArbitraryPrecisionValue()).toBe(d.stored_string);
106
- // Same value and scale as the fixture.
107
- expect((0, decimal_1.decodeDecimal)(proto)).toEqual({ unscaled: BigInt(d.unscaled), scale: d.scale });
108
- // The wrapper getter returns that exact value.
109
- const expected = new decimal_js_1.Decimal(d.unscaled).div(new decimal_js_1.Decimal(10).pow(d.scale));
110
- expect(readByWrapper(message, d.path).equals(expected)).toBe(true);
111
- if (d.read_by.startsWith('ProtoSerializationUtil')) {
112
- expect(serialization_1.ProtoSerializationUtil.deserialize(proto).equals(expected)).toBe(true);
113
- }
114
- });
115
- test('re-saving writes both forms with the same value and scale', () => {
116
- const { message } = load(name);
117
- for (const d of fixture.decimals) {
118
- const parentPath = d.path.split('.').slice(0, -1).join('.');
119
- const parent = parentPath ? walk(message, parentPath) : message;
120
- const field = d.path.split('.').pop();
121
- const setter = `set${pascal(field)}`;
122
- parent[setter]((0, decimal_1.reencodeDecimal)(walk(message, d.path)));
123
- }
124
- const reread = DESERIALIZERS[fixture.message](message.serializeBinary());
125
- for (const d of fixture.decimals) {
126
- const proto = walk(reread, d.path);
127
- expect(proto.getUnscaledValue_asU8().length).toBeGreaterThan(0);
128
- expect(proto.getArbitraryPrecisionValue()).not.toBe('');
129
- const expected = { unscaled: BigInt(d.unscaled), scale: d.scale };
130
- const stringOnly = new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue(proto.getArbitraryPrecisionValue());
131
- const compactOnly = new decimal_value_pb_1.DecimalValueProto().setUnscaledValue(proto.getUnscaledValue_asU8()).setScale(proto.getScale());
132
- expect((0, decimal_1.decodeDecimal)(compactOnly)).toEqual(expected);
133
- expect((0, decimal_1.decodeDecimal)(stringOnly)).toEqual(expected);
134
- }
135
- });
136
- });
137
- describe('wrapper writers set both forms (metrics 2 and 5)', () => {
138
- const bothForms = (proto, expected) => {
139
- expect(proto).toBeDefined();
140
- const p = proto;
141
- const stringOnly = new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue(p.getArbitraryPrecisionValue());
142
- const compactOnly = new decimal_value_pb_1.DecimalValueProto().setUnscaledValue(p.getUnscaledValue_asU8()).setScale(p.getScale());
143
- expect(p.getUnscaledValue_asU8().length).toBeGreaterThan(0);
144
- expect((0, decimal_1.decodeDecimal)(compactOnly)).toEqual((0, decimal_1.decodeDecimal)(stringOnly));
145
- expect(new decimal_js_1.Decimal(p.getArbitraryPrecisionValue()).equals(expected)).toBe(true);
146
- };
147
- test('a legacy Price re-created through Price.create', () => {
148
- const legacy = new Price_1.default(load('price').message);
149
- const saved = Price_1.default.create(legacy.getPrice(), legacy.getSecurity(), legacy.getAsOf());
150
- const reread = price_pb_1.PriceProto.deserializeBinary(saved.proto.serializeBinary());
151
- bothForms(reread.getPrice(), new decimal_js_1.Decimal('100.25'));
152
- });
153
- test('a legacy Transaction re-created through the Transaction constructor', () => {
154
- var _a;
155
- const legacy = new transaction_1.default(load('transaction').message);
156
- const legacyPrice = new Price_1.default(legacy.getPrice());
157
- const saved = new transaction_1.default({
158
- tradeDate: new Date(2026, 0, 2),
159
- settlementDate: new Date(2026, 0, 4),
160
- security: legacy.getSecurity(),
161
- transactionType: legacy.getTransactionType(),
162
- portfolio: new portfolio_1.default(new portfolio_pb_1.PortfolioProto()
163
- .setObjectClass('Portfolio').setVersion('0.0.1')
164
- .setUuid(uuid_1.UUID.random().toUUIDProto()).setPortfolioName('LM-306')),
165
- quantity: legacy.getQuantity(),
166
- price: legacyPrice.getPrice(),
167
- asOfDate: new Date(2026, 0, 2),
168
- });
169
- const reread = transaction_pb_1.TransactionProto.deserializeBinary(saved.proto.serializeBinary());
170
- bothForms(reread.getQuantity(), new decimal_js_1.Decimal(1000));
171
- bothForms((_a = reread.getPrice()) === null || _a === void 0 ? void 0 : _a.getPrice(), new decimal_js_1.Decimal('-0.50'));
172
- });
173
- });
174
- //# sourceMappingURL=decimal.legacy.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decimal.legacy.test.js","sourceRoot":"","sources":["decimal.legacy.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,2CAAqC;AAErC,wEAAuE;AACvE,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AAQ,EAAE;YAC7B,QAAQ,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;SACjC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,iCAAgB,CAAC,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;QACjF,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,IAAI,oBAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACnD,SAAS,CAAC,MAAA,MAAM,CAAC,QAAQ,EAAE,0CAAE,QAAQ,EAAE,EAAE,IAAI,oBAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,158 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { Decimal } from 'decimal.js';
4
- import { Message } from 'google-protobuf';
5
- import { PriceProto } from '../../../fintekkers/models/price/price_pb';
6
- import { SecurityProto } from '../../../fintekkers/models/security/security_pb';
7
- import { TransactionProto } from '../../../fintekkers/models/transaction/transaction_pb';
8
- import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
9
- import Price from '../price/Price';
10
- import Security from '../security/security';
11
- import MortgageBackedSecurity from '../security/MortgageBackedSecurity';
12
- import Transaction from '../transaction/transaction';
13
- import { ProtoSerializationUtil } from './serialization';
14
- import { UUID } from './uuid';
15
- import Portfolio from '../portfolio/portfolio';
16
- import { PortfolioProto } from '../../../fintekkers/models/portfolio/portfolio_pb';
17
- import { decodeDecimal, reencodeDecimal, setDecimalLogger } from './decimal';
18
-
19
- /**
20
- * Metric 2 (LM-306): bytes written by ledger-models v0.4.33 carry only the
21
- * string form. They load through the wrappers to the same value and scale,
22
- * and re-saving them writes both forms.
23
- */
24
-
25
- const LEGACY = path.join(__dirname, '../../../../../ledger-models-protos/fixtures/legacy_v0433');
26
-
27
- interface LegacyDecimal { path: string; stored_string: string; unscaled: string; scale: number; read_by: string }
28
- interface LegacyFixture { bin: string; message: string; decimals: LegacyDecimal[] }
29
-
30
- const DESERIALIZERS: Record<string, (b: Uint8Array) => Message> = {
31
- PriceProto: b => PriceProto.deserializeBinary(b),
32
- SecurityProto: b => SecurityProto.deserializeBinary(b),
33
- TransactionProto: b => TransactionProto.deserializeBinary(b),
34
- };
35
-
36
- function load(name: string): { fixture: LegacyFixture; message: Message } {
37
- const fixture: LegacyFixture = JSON.parse(fs.readFileSync(path.join(LEGACY, `${name}.json`), 'utf8'));
38
- const deserialize = DESERIALIZERS[fixture.message];
39
- if (!deserialize) throw new Error(`no deserializer for ${fixture.message}`);
40
- return { fixture, message: deserialize(new Uint8Array(fs.readFileSync(path.join(LEGACY, fixture.bin)))) };
41
- }
42
-
43
- const pascal = (segment: string) => segment.split('_').map(w => w[0].toUpperCase() + w.slice(1)).join('');
44
-
45
- /** Walks `a.b_c` with getA().getBC(). */
46
- function walk(message: Message, dotted: string): any {
47
- return dotted.split('.').reduce((m: any, segment) => {
48
- const value = m[`get${pascal(segment)}`]();
49
- if (value === undefined) throw new Error(`${dotted}: ${segment} is unset`);
50
- return value;
51
- }, message);
52
- }
53
-
54
- /** The wrapper getter that reads each path, as Rust's `read_by` names it. */
55
- function readByWrapper(message: Message, dotted: string): Decimal {
56
- const mbs = (security: SecurityProto) => {
57
- const wrapped = Security.create(security);
58
- expect(wrapped).toBeInstanceOf(MortgageBackedSecurity);
59
- return wrapped as MortgageBackedSecurity;
60
- };
61
- const parts = dotted.split('.');
62
- const field = parts[parts.length - 1];
63
- if (dotted === 'price') return new Price(message as PriceProto).getPrice();
64
- if (dotted === 'quantity') return new Transaction(message as TransactionProto).getQuantity();
65
- if (dotted === 'price.price') return new Price(new Transaction(message as TransactionProto).getPrice()).getPrice();
66
- const security = parts[0] === 'security' ? walk(message, 'security') as SecurityProto : message as SecurityProto;
67
- const getter = `get${pascal(field)}`;
68
- const value = (mbs(security) as any)[getter]();
69
- if (!(value instanceof Decimal)) throw new Error(`${dotted}: ${getter} did not return a Decimal`);
70
- return value;
71
- }
72
-
73
- beforeAll(() => {
74
- setDecimalLogger({ warn: jest.fn() });
75
- });
76
-
77
- describe.each(['price', 'security', 'transaction'])('legacy_v0433/%s', (name) => {
78
- const { fixture } = load(name);
79
-
80
- test.each(fixture.decimals.map(d => [d.path, d] as [string, LegacyDecimal]))('%s reads through the wrapper', (_p, d) => {
81
- const { message } = load(name);
82
- const proto = walk(message, d.path) as DecimalValueProto;
83
- // Really string-only bytes.
84
- expect(proto.getUnscaledValue_asU8().length).toBe(0);
85
- expect(proto.getArbitraryPrecisionValue()).toBe(d.stored_string);
86
-
87
- // Same value and scale as the fixture.
88
- expect(decodeDecimal(proto)).toEqual({ unscaled: BigInt(d.unscaled), scale: d.scale });
89
-
90
- // The wrapper getter returns that exact value.
91
- const expected = new Decimal(d.unscaled).div(new Decimal(10).pow(d.scale));
92
- expect(readByWrapper(message, d.path).equals(expected)).toBe(true);
93
- if (d.read_by.startsWith('ProtoSerializationUtil')) {
94
- expect((ProtoSerializationUtil.deserialize(proto) as Decimal).equals(expected)).toBe(true);
95
- }
96
- });
97
-
98
- test('re-saving writes both forms with the same value and scale', () => {
99
- const { message } = load(name);
100
- for (const d of fixture.decimals) {
101
- const parentPath = d.path.split('.').slice(0, -1).join('.');
102
- const parent = parentPath ? walk(message, parentPath) : message;
103
- const field = d.path.split('.').pop()!;
104
- const setter = `set${pascal(field)}`;
105
- (parent as any)[setter](reencodeDecimal(walk(message, d.path)));
106
- }
107
- const reread = DESERIALIZERS[fixture.message](message.serializeBinary());
108
- for (const d of fixture.decimals) {
109
- const proto = walk(reread, d.path) as DecimalValueProto;
110
- expect(proto.getUnscaledValue_asU8().length).toBeGreaterThan(0);
111
- expect(proto.getArbitraryPrecisionValue()).not.toBe('');
112
- const expected = { unscaled: BigInt(d.unscaled), scale: d.scale };
113
- const stringOnly = new DecimalValueProto().setArbitraryPrecisionValue(proto.getArbitraryPrecisionValue());
114
- const compactOnly = new DecimalValueProto().setUnscaledValue(proto.getUnscaledValue_asU8()).setScale(proto.getScale());
115
- expect(decodeDecimal(compactOnly)).toEqual(expected);
116
- expect(decodeDecimal(stringOnly)).toEqual(expected);
117
- }
118
- });
119
- });
120
-
121
- describe('wrapper writers set both forms (metrics 2 and 5)', () => {
122
- const bothForms = (proto: DecimalValueProto | undefined, expected: Decimal) => {
123
- expect(proto).toBeDefined();
124
- const p = proto as DecimalValueProto;
125
- const stringOnly = new DecimalValueProto().setArbitraryPrecisionValue(p.getArbitraryPrecisionValue());
126
- const compactOnly = new DecimalValueProto().setUnscaledValue(p.getUnscaledValue_asU8()).setScale(p.getScale());
127
- expect(p.getUnscaledValue_asU8().length).toBeGreaterThan(0);
128
- expect(decodeDecimal(compactOnly)).toEqual(decodeDecimal(stringOnly));
129
- expect(new Decimal(p.getArbitraryPrecisionValue()).equals(expected)).toBe(true);
130
- };
131
-
132
- test('a legacy Price re-created through Price.create', () => {
133
- const legacy = new Price(load('price').message as PriceProto);
134
- const saved = Price.create(legacy.getPrice(), legacy.getSecurity(), legacy.getAsOf());
135
- const reread = PriceProto.deserializeBinary(saved.proto.serializeBinary());
136
- bothForms(reread.getPrice(), new Decimal('100.25'));
137
- });
138
-
139
- test('a legacy Transaction re-created through the Transaction constructor', () => {
140
- const legacy = new Transaction(load('transaction').message as TransactionProto);
141
- const legacyPrice = new Price(legacy.getPrice());
142
- const saved = new Transaction({
143
- tradeDate: new Date(2026, 0, 2),
144
- settlementDate: new Date(2026, 0, 4),
145
- security: legacy.getSecurity(),
146
- transactionType: legacy.getTransactionType(),
147
- portfolio: new Portfolio(new PortfolioProto()
148
- .setObjectClass('Portfolio').setVersion('0.0.1')
149
- .setUuid(UUID.random().toUUIDProto()).setPortfolioName('LM-306')),
150
- quantity: legacy.getQuantity(),
151
- price: legacyPrice.getPrice(),
152
- asOfDate: new Date(2026, 0, 2),
153
- });
154
- const reread = TransactionProto.deserializeBinary(saved.proto.serializeBinary());
155
- bothForms(reread.getQuantity(), new Decimal(1000));
156
- bothForms(reread.getPrice()?.getPrice(), new Decimal('-0.50'));
157
- });
158
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,39 +0,0 @@
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
- const fs = __importStar(require("fs"));
27
- const path = __importStar(require("path"));
28
- /**
29
- * Metric 4 (LM-306): the published typings mark the deprecated string
30
- * accessors. compile.sh adds the tags after protoc-gen-ts runs.
31
- */
32
- const TYPINGS = path.join(__dirname, '../../../fintekkers/models/util/decimal_value_pb.d.ts');
33
- test.each(['getArbitraryPrecisionValue', 'setArbitraryPrecisionValue'])('%s is @deprecated', (accessor) => {
34
- const lines = fs.readFileSync(TYPINGS, 'utf8').split('\n');
35
- const at = lines.findIndex(l => l.trim().startsWith(`${accessor}(`));
36
- expect(at).toBeGreaterThan(0);
37
- expect(lines[at - 1].trim()).toMatch(/^\/\*\* @deprecated .*\*\/$/);
38
- });
39
- //# sourceMappingURL=decimal.typings.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decimal.typings.test.js","sourceRoot":"","sources":["decimal.typings.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B;;;GAGG;AAEH,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,uDAAuD,CAAC,CAAC;AAE9F,IAAI,CAAC,IAAI,CAAC,CAAC,4BAA4B,EAAE,4BAA4B,CAAC,CAAC,CAAC,mBAAmB,EAAE,CAAC,QAAQ,EAAE,EAAE;IACtG,MAAM,KAAK,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3D,MAAM,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC;IACrE,MAAM,CAAC,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;AACxE,CAAC,CAAC,CAAC"}
@@ -1,16 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
-
4
- /**
5
- * Metric 4 (LM-306): the published typings mark the deprecated string
6
- * accessors. compile.sh adds the tags after protoc-gen-ts runs.
7
- */
8
-
9
- const TYPINGS = path.join(__dirname, '../../../fintekkers/models/util/decimal_value_pb.d.ts');
10
-
11
- test.each(['getArbitraryPrecisionValue', 'setArbitraryPrecisionValue'])('%s is @deprecated', (accessor) => {
12
- const lines = fs.readFileSync(TYPINGS, 'utf8').split('\n');
13
- const at = lines.findIndex(l => l.trim().startsWith(`${accessor}(`));
14
- expect(at).toBeGreaterThan(0);
15
- expect(lines[at - 1].trim()).toMatch(/^\/\*\* @deprecated .*\*\/$/);
16
- });
@@ -1,21 +0,0 @@
1
- {
2
- "_comment": "Generated by scripts/gen-object-type-legacy-map.py from the (legacy_object_class) options in fintekkers/models/util/object_type.proto. Do not edit.",
3
- "legacy_object_class": {
4
- "CreatePriceRequestProto": "OBJECT_TYPE_CREATE_PRICE_REQUEST",
5
- "Identifier": "OBJECT_TYPE_IDENTIFIER",
6
- "Portfolio": "OBJECT_TYPE_PORTFOLIO",
7
- "PortfolioRequest": "OBJECT_TYPE_QUERY_PORTFOLIO_REQUEST",
8
- "Position": "OBJECT_TYPE_POSITION",
9
- "PositionFilter": "OBJECT_TYPE_POSITION_FILTER",
10
- "Price": "OBJECT_TYPE_PRICE",
11
- "PriceProto": "OBJECT_TYPE_PRICE",
12
- "PriceRequest": "OBJECT_TYPE_QUERY_PRICE_REQUEST",
13
- "Security": "OBJECT_TYPE_SECURITY",
14
- "SecurityRequest": "OBJECT_TYPE_QUERY_SECURITY_REQUEST",
15
- "Strategy": "OBJECT_TYPE_STRATEGY",
16
- "StrategyAllocation": "OBJECT_TYPE_STRATEGY_ALLOCATION",
17
- "Tenor": "OBJECT_TYPE_TENOR",
18
- "Transaction": "OBJECT_TYPE_TRANSACTION",
19
- "TransactionRequest": "OBJECT_TYPE_QUERY_TRANSACTION_REQUEST"
20
- }
21
- }