@happyvertical/smrt-users 0.57.22 → 0.57.24

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/README.md CHANGED
@@ -1563,6 +1563,57 @@ exports. A policy that requires shares or dues evidence fails closed unless the
1563
1563
  register has an explicitly authoritative reference for every required kind; the
1564
1564
  snapshot names that missing evidence rather than inferring payment status.
1565
1565
 
1566
+ For GET-style capabilities, use the member-scoped read API instead:
1567
+
1568
+ ```typescript
1569
+ const register = new MemberRegisterService(db, { tenantId });
1570
+ const decision = await register.eligibilityFor(
1571
+ { userId: signedInUser.id }, // or { memberId: legalMemberId }
1572
+ '2026-06-01',
1573
+ { memberClassKeys: ['worker'], requireAuthoritativeKinds: ['dues'] },
1574
+ );
1575
+ ```
1576
+
1577
+ `eligibilityFor(identity, recordDate, policy)` performs only reads on the supplied
1578
+ executor. It opens no transaction, persists no snapshot and never lists the
1579
+ register. Its query count is independent of unrelated members; history and
1580
+ references are loaded only for the selected member. Exactly one nonempty selector
1581
+ is required. A user identity must resolve to exactly one member in this tenant;
1582
+ missing, foreign and ambiguous identities throw `MEMBER_REGISTER_NOT_FOUND`.
1583
+ Malformed dates/selectors/policy values throw `MEMBER_REGISTER_INVALID`; an active
1584
+ foreign tenant context throws `MEMBER_REGISTER_TENANT_MISMATCH`. Database failures
1585
+ propagate. Hosts map these failures to denied capabilities and must derive tenant
1586
+ and identity from an authorized session, never trust submitted identity fields.
1587
+ This is legal-register eligibility: host-level suspension/bans and operation
1588
+ permissions still require their own checks. Individual reads do not promise a
1589
+ transactionally stable multi-query snapshot; an accepted command re-evaluates on
1590
+ its own transaction.
1591
+
1592
+ Persist immutable evidence explicitly when accepting a command:
1593
+
1594
+ ```typescript
1595
+ await register.withTransaction(async (bound, executor) => {
1596
+ const snapshot = await bound.captureEligibility(
1597
+ { memberId: legalMemberId }, '2026-06-01', policy,
1598
+ );
1599
+ if (!snapshot.eligible) throw new Error('Participation denied');
1600
+ // Persist the accepted command with executor, referencing snapshot.id.
1601
+ // Throwing rolls back both command and evidence.
1602
+ });
1603
+ ```
1604
+
1605
+ `withTransaction` supplies a bound service and the exact database executor used
1606
+ by its reads and writes; callbacks must use that executor for their command and
1607
+ must not retain either value after completion. Nested calls through the bound
1608
+ service reuse the transaction. `captureEligibility` re-evaluates authoritative
1609
+ records and creates one immutable `MemberEligibilitySnapshot`, including the
1610
+ policy inputs. Called alone, it opens its own transaction. It does not accept a
1611
+ caller-authored decision or grant host authorization. Each successful call is a
1612
+ new evidence event; hosts implement command idempotency in the same transaction,
1613
+ and skip capture for an already accepted command. A refused or failed transaction
1614
+ leaves no snapshot. The existing `asOf` remains the explicit whole-register
1615
+ snapshot/export operation and is unsuitable for ordinary capability GETs.
1616
+
1566
1617
  An omitted `memberClassKeys` policy allows every class; an explicit empty list
1567
1618
  allows none. `statuses` defaults to `['active']`, and an empty status list also
1568
1619
  allows none. Snapshots preserve normalized class keys (`null` means unrestricted),
@@ -1579,7 +1630,8 @@ all of their writes together. History and references are append-only, and
1579
1630
  snapshots reject updates and deletes. Same-day history corrections use persisted
1580
1631
  sequence order. Eligibility uses effective history; `LegalMember.status` and
1581
1632
  `leftOn` are display caches refreshed by `setStatus`, so scheduled changes may
1582
- make those caches stale until another write. Use `asOf` for record-date decisions.
1633
+ make those caches stale until another write. Use `eligibilityFor` for read-only
1634
+ record-date decisions, or `captureEligibility` for accepted-command evidence.
1583
1635
 
1584
1636
  Use `revokeReference(referenceId, { effectiveOn })` when previously authoritative
1585
1637
  evidence is withdrawn. It appends a dated record targeting the original reference;