mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-09 22:35:56 +05:45
* 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> * 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>
28 lines
897 B
Swift
28 lines
897 B
Swift
//
|
|
// MiscOperators.swift
|
|
//
|
|
// Created by Antonio Pallares.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
extension RulesEngine {
|
|
|
|
/// Miscellaneous operators: `log`.
|
|
enum MiscOperators {
|
|
|
|
/// `{"log": value}` — evaluates its single argument, emits it through the
|
|
/// dedicated `log` channel of `RulesEngine.logger`, and returns it unchanged
|
|
/// (identity passthrough).
|
|
/// Mirrors json-logic-js `function(a){ console.log(a); return a; }`: a
|
|
/// debug aid that never affects a rule's outcome. A missing argument is
|
|
/// `undefined` (logged as `"undefined"`); operands beyond the first are
|
|
/// ignored.
|
|
static func opLog(args: Value, vars: Scope) throws -> Value {
|
|
let value = try Operators.evalArgs(args, vars: vars).first ?? .undefined
|
|
RulesEngine.logger.log(jsString(value))
|
|
return value
|
|
}
|
|
}
|
|
}
|