mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
Brings in: - The `RulesEngine` → `RulesEngineInternal` module rename from #6787. - The `no_leaking_rules_engine_internal_import` SwiftLint rule update from #6788. - Plus the `main`-merge cascade carried by #6788. Conflicts resolved: - `RulesEngineInternal/RulesEngineInternal.swift`: kept this branch's `Rules.logger` / `LoggerStorage` storage, dropped the `@_spi(Internal)` marker on `public enum Rules` (since #6787 dropped those markers; the new SwiftLint rule replaces that gate). - `RevenueCat.xcodeproj/project.pbxproj`: kept this branch's full file list (Evaluator, Logger, Value, RuleError, Operators/*, plus the new test files and helpers), then applied the producer-side rename to every `RulesEngine\b` / `RulesEngineTests\b` token (target name, group name, path, productName, bundle IDs `com.revenuecat.RulesEngineInternal[Tests]`, framework / xctest output names, and the `RulesEngine.swift` → `RulesEngineInternal.swift` file ref). Other rename follow-ups in this branch's added files: - `Tests/RulesEngineInternalTests/*.swift` (8 files) — every `[@_spi(Internal) ]@testable import RulesEngine` updated to `@testable import RulesEngineInternal`. The `@_spi(Internal)` attribute is no longer needed because the producer no longer uses SPI markers. - `Projects/RulesEngineInternal/`, `RulesEngineInternal/`, and `Tests/RulesEngineInternalTests/` directories were moved automatically by git's directory-rename detection (15 file renames). Left intentionally unchanged: - `RulesEngineInternal/Logger.swift` — the development-only `PrintLogger` keeps its `[RulesEngine]` log prefix because that string identifies the subsystem (the rules engine) for log readers, not the producer-side module name. The injected production logger replaces this struct entirely once the engine is wired into the SDK, so the prefix is throwaway. - `RulesEngineLogger` protocol name — internal type name within the module, not part of the import-site signal that motivated the module rename. - The `Rules` namespace name — separate identifier from the module name, kept stable so call sites still write `Rules.something`. Verified locally: - `swift build --target RulesEngineInternal` ✔ - `swift test --filter RulesEngineInternalTests` ✔ — 75 tests passed - `xcodebuild -scheme RulesEngineInternal -destination 'generic/platform=iOS' build` ✔ - `swiftlint --no-cache` ✔ — 0 violations across 1332 files - `git ls-files | xargs perl -ne 'if (/\bRulesEngine\b/ && !/RulesEngineInternal/) { ... }'` returns only the `[RulesEngine]` log prefix mentioned above. Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
1.3 KiB
Swift
43 lines
1.3 KiB
Swift
//
|
|
// RuleError.swift
|
|
//
|
|
// Created by Antonio Pallares.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
/// Errors surfaced by the rules engine.
|
|
///
|
|
/// Note on missing variables: the v1 evaluator does **not** raise an error
|
|
/// for them — per the JSON Logic spec, they resolve to `null` and a warning
|
|
/// is logged instead. If a strict mode is ever needed, we'd add a
|
|
/// `missingVariable` case.
|
|
enum RuleError: Error, Equatable {
|
|
|
|
/// The predicate JSON could not be parsed.
|
|
case parse(message: String)
|
|
|
|
/// An operator was given arguments of the wrong shape (e.g. wrong arity)
|
|
/// or types that cannot be reconciled.
|
|
case typeMismatch(message: String)
|
|
|
|
/// The predicate references a JSON Logic operator the engine does not
|
|
/// implement. Carries the operator name so callers can decide policy
|
|
/// (default-deny, log, etc.).
|
|
case unsupportedOperator(name: String)
|
|
}
|
|
|
|
extension RuleError: CustomStringConvertible {
|
|
|
|
var description: String {
|
|
switch self {
|
|
case .parse(let message):
|
|
return "failed to parse predicate JSON: \(message)"
|
|
case .typeMismatch(let message):
|
|
return "type mismatch: \(message)"
|
|
case .unsupportedOperator(let name):
|
|
return "unsupported operator: \(name)"
|
|
}
|
|
}
|
|
}
|