@fintekkers/ledger-models 0.4.8 → 0.4.10

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 (55) hide show
  1. package/node/wrappers/models/portfolio/portfolio.d.ts +8 -0
  2. package/node/wrappers/models/portfolio/portfolio.js +54 -1
  3. package/node/wrappers/models/portfolio/portfolio.js.map +1 -1
  4. package/node/wrappers/models/portfolio/portfolio.ts +34 -1
  5. package/node/wrappers/models/portfolio-price-transaction.lazy-hydrate.test.d.ts +1 -0
  6. package/node/wrappers/models/portfolio-price-transaction.lazy-hydrate.test.js +158 -0
  7. package/node/wrappers/models/portfolio-price-transaction.lazy-hydrate.test.js.map +1 -0
  8. package/node/wrappers/models/portfolio-price-transaction.lazy-hydrate.test.ts +153 -0
  9. package/node/wrappers/models/price/Price.d.ts +5 -0
  10. package/node/wrappers/models/price/Price.js +48 -0
  11. package/node/wrappers/models/price/Price.js.map +1 -1
  12. package/node/wrappers/models/price/Price.ts +26 -0
  13. package/node/wrappers/models/security/security.d.ts +9 -3
  14. package/node/wrappers/models/security/security.js +57 -15
  15. package/node/wrappers/models/security/security.js.map +1 -1
  16. package/node/wrappers/models/security/security.lazy-hydrate.test.d.ts +1 -0
  17. package/node/wrappers/models/security/security.lazy-hydrate.test.js +127 -0
  18. package/node/wrappers/models/security/security.lazy-hydrate.test.js.map +1 -0
  19. package/node/wrappers/models/security/security.lazy-hydrate.test.ts +123 -0
  20. package/node/wrappers/models/security/security.ts +35 -17
  21. package/node/wrappers/models/transaction/transaction.d.ts +7 -0
  22. package/node/wrappers/models/transaction/transaction.js +61 -0
  23. package/node/wrappers/models/transaction/transaction.js.map +1 -1
  24. package/node/wrappers/models/transaction/transaction.ts +40 -0
  25. package/node/wrappers/services/portfolio-service/PortfolioService.js +35 -0
  26. package/node/wrappers/services/portfolio-service/PortfolioService.js.map +1 -1
  27. package/node/wrappers/services/portfolio-service/PortfolioService.ts +14 -2
  28. package/node/wrappers/services/price-service/PriceService.js +10 -0
  29. package/node/wrappers/services/price-service/PriceService.js.map +1 -1
  30. package/node/wrappers/services/price-service/PriceService.ts +12 -2
  31. package/node/wrappers/services/security-service/SecurityService.js +15 -0
  32. package/node/wrappers/services/security-service/SecurityService.js.map +1 -1
  33. package/node/wrappers/services/security-service/SecurityService.ts +17 -2
  34. package/node/wrappers/services/service-client-writethrough.test.d.ts +1 -0
  35. package/node/wrappers/services/service-client-writethrough.test.js +147 -0
  36. package/node/wrappers/services/service-client-writethrough.test.js.map +1 -0
  37. package/node/wrappers/services/service-client-writethrough.test.ts +141 -0
  38. package/node/wrappers/services/transaction-service/TransactionService.js +36 -0
  39. package/node/wrappers/services/transaction-service/TransactionService.js.map +1 -1
  40. package/node/wrappers/services/transaction-service/TransactionService.ts +13 -0
  41. package/node/wrappers/util/link-cache.d.ts +56 -0
  42. package/node/wrappers/util/link-cache.js +92 -0
  43. package/node/wrappers/util/link-cache.js.map +1 -0
  44. package/node/wrappers/util/link-cache.test.d.ts +1 -0
  45. package/node/wrappers/util/link-cache.test.js +107 -0
  46. package/node/wrappers/util/link-cache.test.js.map +1 -0
  47. package/node/wrappers/util/link-cache.test.ts +112 -0
  48. package/node/wrappers/util/link-cache.ts +110 -0
  49. package/node/wrappers/util/link-resolver.js +52 -0
  50. package/node/wrappers/util/link-resolver.js.map +1 -1
  51. package/node/wrappers/util/link-resolver.test.js +75 -0
  52. package/node/wrappers/util/link-resolver.test.js.map +1 -1
  53. package/node/wrappers/util/link-resolver.test.ts +62 -0
  54. package/node/wrappers/util/link-resolver.ts +29 -0
  55. package/package.json +1 -1
@@ -400,3 +400,65 @@ describe('LinkResolver', () => {
400
400
  expect(callLog.count).toBe(2);
401
401
  });
402
402
  });
403
+
404
+ import * as LinkCacheModule from './link-cache';
405
+ import { ZonedDateTime } from '../models/utils/datetime';
406
+
407
+ describe('LinkResolver write-through to LinkCache', () => {
408
+ beforeEach(() => {
409
+ LinkCacheModule.SECURITY.clear();
410
+ LinkCacheModule.PORTFOLIO.clear();
411
+ });
412
+
413
+ function fullSecurityWithAsOf(uuid: UUID, issuer: string, asOf: LocalTimestampProto): SecurityProto {
414
+ const proto = fullSecurity(uuid, issuer);
415
+ proto.setAsOf(asOf);
416
+ return proto;
417
+ }
418
+
419
+ test('getSecurity populates LinkCache.SECURITY', async () => {
420
+ const uuid = UUID.random();
421
+ const asOf = makeAsOf(1_700_000_010);
422
+ const store = new Map<string, SecurityProto>([
423
+ [uuid.toString(), fullSecurityWithAsOf(uuid, 'ACME', asOf)],
424
+ ]);
425
+ const resolver = new LinkResolver({
426
+ securityClient: mockSecurityClient(store, newCallLog()),
427
+ portfolioClient: mockPortfolioClient(new Map(), newCallLog()),
428
+ });
429
+
430
+ const out = await resolver.getSecurity(uuid, asOf);
431
+ expect(out.getIssuerName()).toBe('ACME');
432
+
433
+ const cached = LinkCacheModule.SECURITY.get(uuid.toString(), new ZonedDateTime(asOf));
434
+ expect(cached).toBeDefined();
435
+ expect(cached!.getIssuerName()).toBe('ACME');
436
+ });
437
+
438
+ test('resolveSecurities populates LinkCache.SECURITY', async () => {
439
+ const uuid = UUID.random();
440
+ const asOf = makeAsOf(1_700_000_011);
441
+ const store = new Map<string, SecurityProto>([
442
+ [uuid.toString(), fullSecurityWithAsOf(uuid, 'BULK', asOf)],
443
+ ]);
444
+ const resolver = new LinkResolver({
445
+ securityClient: mockSecurityClient(store, newCallLog()),
446
+ portfolioClient: mockPortfolioClient(new Map(), newCallLog()),
447
+ });
448
+
449
+ const linkSec = new SecurityProto();
450
+ linkSec.setUuid(uuid.toUUIDProto());
451
+ linkSec.setIsLink(true);
452
+ linkSec.setAsOf(asOf);
453
+ const priceProto = new PriceProto();
454
+ priceProto.setUuid(UUID.random().toUUIDProto());
455
+ priceProto.setSecurity(linkSec);
456
+ const price = new Price(priceProto);
457
+
458
+ await resolver.resolveSecurities([price]);
459
+
460
+ const cached = LinkCacheModule.SECURITY.get(uuid.toString(), new ZonedDateTime(asOf));
461
+ expect(cached).toBeDefined();
462
+ expect(cached!.getIssuerName()).toBe('BULK');
463
+ });
464
+ });
@@ -16,6 +16,31 @@ import Security from '../models/security/security';
16
16
  import Portfolio from '../models/portfolio/portfolio';
17
17
  import { UUID } from '../models/utils/uuid';
18
18
  import EnvConfig from '../models/utils/requestcontext';
19
+ import { ZonedDateTime } from '../models/utils/datetime';
20
+ import * as LinkCacheModule from './link-cache';
21
+
22
+ /**
23
+ * Mirror a freshly-fetched SecurityProto into the process-wide
24
+ * `LinkCache.SECURITY`. The lazy-hydrate `SecurityWrapper.ensureHydrated()`
25
+ * reads from this cache, so pre-warming via LinkResolver immediately
26
+ * benefits accessor reads. Skips silently when the resolved proto lacks
27
+ * uuid or as_of — `LinkCache.put` requires both.
28
+ */
29
+ function populateSecurityLinkCache(proto: SecurityProto): void {
30
+ const uuidProto = proto.getUuid();
31
+ const asOfProto = proto.getAsOf();
32
+ if (!uuidProto || !asOfProto) return;
33
+ const uuidKey = UUID.fromU8Array(uuidProto.getRawUuid_asU8()).toString();
34
+ LinkCacheModule.SECURITY.put(uuidKey, proto, new ZonedDateTime(asOfProto));
35
+ }
36
+
37
+ function populatePortfolioLinkCache(proto: PortfolioProto): void {
38
+ const uuidProto = proto.getUuid();
39
+ const asOfProto = proto.getAsOf();
40
+ if (!uuidProto || !asOfProto) return;
41
+ const uuidKey = UUID.fromU8Array(uuidProto.getRawUuid_asU8()).toString();
42
+ LinkCacheModule.PORTFOLIO.put(uuidKey, proto, new ZonedDateTime(asOfProto));
43
+ }
19
44
 
20
45
  /**
21
46
  * LinkResolver — bulk hydration of `is_link=true` entity references into
@@ -249,6 +274,7 @@ class LinkResolver {
249
274
  if (!uuidProto) continue;
250
275
  const uuidStr = UUID.fromU8Array(uuidProto.getRawUuid_asU8()).toString();
251
276
  this.securityCache.set(`${uuidStr}@${bucketKey}`, proto);
277
+ populateSecurityLinkCache(proto);
252
278
  }
253
279
  }),
254
280
  );
@@ -303,6 +329,7 @@ class LinkResolver {
303
329
  if (!uuidProto) continue;
304
330
  const uuidStr = UUID.fromU8Array(uuidProto.getRawUuid_asU8()).toString();
305
331
  this.portfolioCache.set(`${uuidStr}@${bucketKey}`, proto);
332
+ populatePortfolioLinkCache(proto);
306
333
  }
307
334
  }),
308
335
  );
@@ -346,6 +373,7 @@ class LinkResolver {
346
373
  }
347
374
  const proto = protos[0];
348
375
  this.securityCache.set(key, proto);
376
+ populateSecurityLinkCache(proto);
349
377
  return proto;
350
378
  }).finally(() => {
351
379
  this.securityInFlight.delete(key);
@@ -370,6 +398,7 @@ class LinkResolver {
370
398
  }
371
399
  const proto = protos[0];
372
400
  this.portfolioCache.set(key, proto);
401
+ populatePortfolioLinkCache(proto);
373
402
  return proto;
374
403
  }).finally(() => {
375
404
  this.portfolioInFlight.delete(key);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fintekkers/ledger-models",
3
3
  "todo": "Replace the version with build script version number",
4
- "version": "0.4.8",
4
+ "version": "0.4.10",
5
5
  "description": "ledger model protos ",
6
6
  "authors": [
7
7
  "David Doherty",