Add rc.entries and rc.fromEntries custom operators (#4062)
### Checklist - [x] If applicable, unit tests - [ ] If applicable, create follow-up issues for `purchases-ios` and hybrids ### Motivation Port of RevenueCat/purchases-ios#7435. JSON Logic iteration operators only accept arrays, so there is no way to filter or rebuild a keyed object — subscriptions or entitlements maps — inside a predicate. ### Description - Add `rc.entries`: objects become `[key, value]` pairs sorted lexicographically by key, arrays become string-index pairs. Every other type, strings included, throws a type mismatch, so a rule aimed at the wrong field fails loudly instead of iterating characters. - Add `rc.fromEntries`: the inverse, last-wins on duplicate keys. Non-array arguments and entries that are not two-element pairs throw rather than producing a partial object. - Eighteen fixtures copied byte-for-byte from iOS (415 total). ### Notes The iOS PR is still in review, so its fixtures could still change; this file must be re-synced if they do. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > New rule-evaluation operators can change which server-side predicates match on keyed customer data; behavior is cross-SDK aligned and heavily fixture-tested, with explicit type errors to avoid silent wrong matches. > > **Overview** > Adds **`rc.entries`** and **`rc.fromEntries`** to the JSON Logic rules engine so predicates can turn keyed maps (e.g. subscriptions) into `[key, value]` pair arrays for `filter` / `some` / `reduce`, then rebuild objects afterward. > > **`rc.entries`** emits lexicographically sorted pairs for objects and string-index pairs for arrays; scalars (including strings) raise **`TypeMismatch`** instead of behaving like JS `Object.entries`. **`rc.fromEntries`** reverses valid two-element pair lists with last-wins duplicate keys and strict validation—malformed or partial entries throw rather than producing a trimmed object. > > Dispatch is registered in **`CustomOperators`**, with **18** conformance fixtures in **`rc_entries.json`** and the global fixture count bumped to **519**. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 499f18d02b393ddc10d8072b1e3eb18e0bbb705e. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Cursor <cursoragent@cursor.com>
A
Antonio Pallares committed
43797e5ce2f012ab6273a5e806361faa5f8ebbd8
Parent: da629da
Committed by GitHub <noreply@github.com>
on 8/26/2026, 10:38:08 AM