Files
purchases-ios/Sources/RulesEngine/CustomOperators/RootVarOperator.swift
T
Antonio PallaresandCursor ad09c032c9 Add rc.rootVar operator for root scope in RulesEngine (#7432)
* Add Scope plumbing and custom operator extension point

Thread evaluation scope through the rules engine and delegate unknown
operators to an empty CustomOperators dispatcher, without changing behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Add rc.rootVar operator for nested predicate root access

Introduce the rc.rootVar custom operator and shared resolveVar lookup,
with fixture coverage including falsy-item empty-path discrimination.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix project.pbxproj: restore RewardedAdTrackingMetadata entries

The RulesEngine registration edit accidentally dropped four
RewardedAdTrackingMetadata.swift entries from the Xcode project.
Restore them and normalize CustomOperators identifiers to 24 hex chars.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Promote firstArgEvaluated to shared Operators helpers

Move the unary-arg helper from LogicOperators to Operators so custom
operators can use the same json-logic-js spread convention.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Address review comments on custom operator extension point

Drop the cross-engine registration note from CustomOperators, and restore
the single-line var extra-args warning that was reflowed without changing
its text.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-19 18:07:53 +02:00

24 lines
500 B
Swift

//
// RootVarOperator.swift
//
// Created by Antonio Pallares.
//
import Foundation
extension RulesEngine {
/// `rc.rootVar` — like `var`, but reads from the root data scope.
enum RootVarOperator {
static func opRootVar(args: Value, vars: Scope) throws -> Value {
try AccessorOperators.resolveVar(
args: args,
target: vars.root,
vars: vars,
operatorName: "rc.rootVar"
)
}
}
}