2026-08-19 10:04:21 +02:00
|
|
|
//
|
|
|
|
|
// CustomOperators.swift
|
|
|
|
|
//
|
|
|
|
|
// Created by Antonio Pallares.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
|
|
extension RulesEngine {
|
|
|
|
|
|
|
|
|
|
/// RevenueCat-specific JSON Logic operators.
|
|
|
|
|
///
|
|
|
|
|
/// Operators here are namespaced under `rc.` so they cannot collide with a
|
|
|
|
|
/// future standard JSON Logic operator.
|
|
|
|
|
enum CustomOperators {
|
|
|
|
|
|
|
|
|
|
static func dispatch(
|
|
|
|
|
op operatorName: String,
|
|
|
|
|
args: Value,
|
|
|
|
|
vars: Scope
|
|
|
|
|
) throws -> Value {
|
|
|
|
|
switch operatorName {
|
2026-08-24 12:57:04 +02:00
|
|
|
case "rc.entries":
|
|
|
|
|
return try EntriesOperators.opEntries(args: args, vars: vars)
|
|
|
|
|
case "rc.fromEntries":
|
|
|
|
|
return try EntriesOperators.opFromEntries(args: args, vars: vars)
|
|
|
|
|
|
2026-08-20 09:10:49 +02:00
|
|
|
case "rc.length":
|
|
|
|
|
return try LengthOperator.opLength(args: args, vars: vars)
|
|
|
|
|
|
2026-08-21 07:41:56 +02:00
|
|
|
case "rc.lower":
|
|
|
|
|
return try CaseOperators.opLower(args: args, vars: vars)
|
|
|
|
|
case "rc.upper":
|
|
|
|
|
return try CaseOperators.opUpper(args: args, vars: vars)
|
|
|
|
|
|
2026-08-19 18:07:53 +02:00
|
|
|
case "rc.rootVar":
|
|
|
|
|
return try RootVarOperator.opRootVar(args: args, vars: vars)
|
|
|
|
|
|
2026-08-25 11:26:54 +02:00
|
|
|
case "rc.semverCompare":
|
|
|
|
|
return try SemverOperator.opSemverCompare(args: args, vars: vars)
|
|
|
|
|
|
2026-08-24 09:47:39 +02:00
|
|
|
case "rc.split":
|
|
|
|
|
return try SplitOperator.opSplit(args: args, vars: vars)
|
|
|
|
|
|
2026-08-19 10:04:21 +02:00
|
|
|
default:
|
|
|
|
|
throw EvaluationError.unsupportedOperator(name: operatorName)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|