Skip to content

Conversation

@abnegate
Copy link
Member

@abnegate abnegate commented Nov 3, 2025

This PR contains updates to the Apple SDK for version 13.4.0.

Summary by CodeRabbit

  • New Features

    • Added total parameter to list operations for skipping row counting.
    • Introduced Operator class enabling atomic row modifications including update, bulk update, upsert, and bulk upsert operations.
  • Documentation

    • Updated usage examples across list operations.

@coderabbitai
Copy link

coderabbitai bot commented Nov 3, 2025

Walkthrough

This pull request releases version 13.4.0 with two primary features. First, a total optional parameter is added to list query methods across six service classes (Account, Databases, Functions, Storage, TablesDb, Teams) to enable skipping row counting for performance optimization. Second, a new Operator class is introduced alongside a Condition enum, providing atomic row modification capabilities through static factory methods for increment, decrement, multiply, divide, array operations, string operations, and date manipulations. Additionally, the Query.swift file refactors date-based query builders to use helper constructors, and documentation examples are updated to reflect the new total parameter usage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Sources/Appwrite/Operator.swift: Comprehensive new operator system with extensive public API surface (Condition enum, Operator struct, 20+ static factory methods, custom encoding/decoding logic, and input validation). Requires careful review of serialization logic, null/type handling, and mathematical constraint checks (NaN/Infinity detection, division by zero validation).
  • Service file changes (Account.swift, Databases.swift, Functions.swift, Storage.swift, TablesDb.swift, Teams.swift): While repetitive, each adds the total parameter with consistent patterns. Verify parameter threading is correct across both generic and non-generic method overloads.
  • Query.swift refactoring: Ensure date-based query builders (createdBefore/After/Between, updatedBefore/After/Between) correctly delegate to helper constructors without behavioral changes.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title "feat: Apple SDK update for version 13.4.0" is partially related to the changeset as it correctly identifies the version number being released. However, the title is vague and uses generic terminology ("update") that doesn't meaningfully convey what is actually being changed. The raw summary indicates the PR's substantive changes are: (1) introduction of a new Operator class with Condition enum for atomic row modifications, and (2) addition of a total parameter to multiple list methods across services. Neither of these key features is referenced in the title, leaving a developer scanning history without clear understanding of what was added in this version. Revise the title to be more specific about the main substantive changes. Consider a title like "feat: Add Operator class for atomic row modifications and total parameter to list queries" that captures the actual features introduced, rather than using generic terms like "update" that don't convey meaningful information to reviewers.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 481231c and a1029fd.

📒 Files selected for processing (19)
  • CHANGELOG.md (1 hunks)
  • README.md (1 hunks)
  • Sources/Appwrite/Client.swift (1 hunks)
  • Sources/Appwrite/Operator.swift (1 hunks)
  • Sources/Appwrite/Query.swift (1 hunks)
  • Sources/Appwrite/Services/Account.swift (2 hunks)
  • Sources/Appwrite/Services/Databases.swift (5 hunks)
  • Sources/Appwrite/Services/Functions.swift (1 hunks)
  • Sources/Appwrite/Services/Storage.swift (1 hunks)
  • Sources/Appwrite/Services/TablesDb.swift (4 hunks)
  • Sources/Appwrite/Services/Teams.swift (3 hunks)
  • docs/examples/account/list-identities.md (1 hunks)
  • docs/examples/account/list-logs.md (1 hunks)
  • docs/examples/databases/list-documents.md (1 hunks)
  • docs/examples/functions/list-executions.md (1 hunks)
  • docs/examples/storage/list-files.md (1 hunks)
  • docs/examples/tablesdb/list-rows.md (1 hunks)
  • docs/examples/teams/list-memberships.md (1 hunks)
  • docs/examples/teams/list.md (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
Sources/Appwrite/Operator.swift (1)
Sources/Appwrite/Query.swift (12)
  • equal (152-158)
  • notEqual (160-166)
  • greaterThan (184-190)
  • greaterThanEqual (192-198)
  • lessThan (168-174)
  • lessThanEqual (176-182)
  • contains (317-323)
  • isNull (200-205)
  • isNotNull (207-212)
  • encode (34-50)
  • encode (131-142)
  • search (261-267)
🪛 SwiftLint (0.57.0)
Sources/Appwrite/Operator.swift

[Warning] 4-4: String enum values can be omitted when they are equal to the enumcase name

(redundant_string_enum_value)


[Warning] 5-5: String enum values can be omitted when they are equal to the enumcase name

(redundant_string_enum_value)


[Warning] 6-6: String enum values can be omitted when they are equal to the enumcase name

(redundant_string_enum_value)


[Warning] 7-7: String enum values can be omitted when they are equal to the enumcase name

(redundant_string_enum_value)


[Warning] 8-8: String enum values can be omitted when they are equal to the enumcase name

(redundant_string_enum_value)


[Warning] 9-9: String enum values can be omitted when they are equal to the enumcase name

(redundant_string_enum_value)


[Warning] 10-10: String enum values can be omitted when they are equal to the enumcase name

(redundant_string_enum_value)


[Warning] 11-11: String enum values can be omitted when they are equal to the enumcase name

(redundant_string_enum_value)


[Warning] 12-12: String enum values can be omitted when they are equal to the enumcase name

(redundant_string_enum_value)

🔇 Additional comments (15)
README.md (1)

34-34: LGTM! Version bump is correct.

The package version update to 13.4.0 aligns with the PR objectives and is consistent with the version changes in other files.

docs/examples/account/list-identities.md (1)

10-11: LGTM! Documentation correctly demonstrates the new parameter.

The example properly shows the usage of the new total parameter alongside the existing queries parameter.

Sources/Appwrite/Client.swift (1)

26-26: LGTM! SDK version header correctly updated.

The x-sdk-version header update to 13.4.0 is consistent with the version bump across the SDK.

CHANGELOG.md (1)

3-6: LGTM! Changelog entry is clear and informative.

The changelog accurately documents the new features in version 13.4.0, including the performance-oriented total parameter and the new Operator class.

docs/examples/account/list-logs.md (1)

10-11: LGTM! Documentation example is consistent and correct.

The example properly demonstrates the new total parameter usage in the listLogs method.

Sources/Appwrite/Services/Functions.swift (2)

18-18: LGTM! Documentation updated for new parameter.

The documentation comment correctly includes the new total parameter.


22-33: LGTM! Implementation of total parameter is correct.

The total parameter is properly implemented as an optional Bool? with a nil default, maintaining backward compatibility. The parameter is correctly included in the API request parameters dictionary.

docs/examples/functions/list-executions.md (1)

11-12: LGTM! Documentation example correctly shows the new parameter.

The example properly demonstrates using the total parameter in the listExecutions method.

Sources/Appwrite/Services/Storage.swift (2)

19-19: LGTM! Documentation updated for the new parameter.

The documentation comment correctly includes the new total parameter.


23-36: LGTM! Implementation of total parameter is correct.

The total parameter is properly implemented as an optional Bool? with a nil default value, maintaining backward compatibility. The parameter is correctly included in the API request parameters dictionary alongside existing parameters.

docs/examples/teams/list-memberships.md (1)

9-14: Consistent documentation update for the new total parameter.

The example correctly demonstrates the new optional total parameter being added to the Teams listMemberships method. The formatting with trailing comma and inline comment is consistent with the pattern across other documentation examples.

docs/examples/tablesdb/list-rows.md (1)

9-15: Consistent documentation update for the new total parameter.

The example correctly demonstrates the new optional total parameter being added to the TablesDB listRows method. Formatting and parameter organization are consistent with other examples in the PR.

docs/examples/storage/list-files.md (1)

9-14: Consistent documentation update for the new total parameter.

The example correctly demonstrates the new optional total parameter being added to the Storage listFiles method. The formatting and parameter organization align with other examples in the PR.

docs/examples/databases/list-documents.md (1)

9-15: Consistent documentation update for the new total parameter.

The example correctly demonstrates the new optional total parameter being added to the Databases listDocuments method. Parameter organization and formatting are consistent with the broader documentation updates across the PR.

docs/examples/teams/list.md (1)

9-13: Consistent documentation update for the new total parameter.

The example correctly demonstrates the new optional total parameter being added to the Teams list method. Formatting and structure are consistent with other examples in the PR.

Summary

All five documentation example files follow a consistent and correct pattern for introducing the new optional total parameter to list methods. The examples:

✅ Clearly demonstrate the new optional parameter with inline comments
✅ Maintain consistent formatting with trailing commas
✅ Use total: false as the example value (indicating skipping row counts for performance optimization)
✅ Preserve all other parameters and functionality

Note: The PR mentions updates to 6 service classes (Account, Databases, Functions, Storage, TablesDb, Teams). The provided files show documentation for 4 of these services. The two missing examples (Account and Functions) were not included in this review batch, but based on the consistent pattern across all reviewed files, they should follow the same implementation if included.

Comment on lines +166 to +233
public static func increment(_ value: Double = 1, max: Double? = nil) -> String {
if value.isNaN || value.isInfinite {
fatalError("Value cannot be NaN or Infinity")
}
if let max = max, max.isNaN || max.isInfinite {
fatalError("Max cannot be NaN or Infinity")
}
var values: [Any] = [value]
if let max = max {
values.append(max)
}
return Operator(method: "increment", values: values).description
}

public static func decrement(_ value: Double = 1, min: Double? = nil) -> String {
if value.isNaN || value.isInfinite {
fatalError("Value cannot be NaN or Infinity")
}
if let min = min, min.isNaN || min.isInfinite {
fatalError("Min cannot be NaN or Infinity")
}
var values: [Any] = [value]
if let min = min {
values.append(min)
}
return Operator(method: "decrement", values: values).description
}

public static func multiply(_ factor: Double, max: Double? = nil) -> String {
if factor.isNaN || factor.isInfinite {
fatalError("Factor cannot be NaN or Infinity")
}
if let max = max, max.isNaN || max.isInfinite {
fatalError("Max cannot be NaN or Infinity")
}
var values: [Any] = [factor]
if let max = max {
values.append(max)
}
return Operator(method: "multiply", values: values).description
}

public static func divide(_ divisor: Double, min: Double? = nil) -> String {
if divisor.isNaN || divisor.isInfinite {
fatalError("Divisor cannot be NaN or Infinity")
}
if let min = min, min.isNaN || min.isInfinite {
fatalError("Min cannot be NaN or Infinity")
}
if divisor == 0 {
fatalError("Divisor cannot be zero")
}
var values: [Any] = [divisor]
if let min = min {
values.append(min)
}
return Operator(method: "divide", values: values).description
}

public static func modulo(_ divisor: Double) -> String {
if divisor.isNaN || divisor.isInfinite {
fatalError("Divisor cannot be NaN or Infinity")
}
if divisor == 0 {
fatalError("Divisor cannot be zero")
}
return Operator(method: "modulo", values: [divisor]).description
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Don't crash consumer apps on invalid operator inputs

These helpers currently trap with fatalError whenever callers pass data like Double.nan, Double.infinity, or zero divisors. Because these APIs are public SDK surface, that means a runtime crash in any production app that forwards unvalidated user input—exactly what we’re trying to protect developers from. Apple’s own guidance and community best practices call out fatalError as a tool for unrecoverable programming mistakes, not regular input validation; in SDK code it becomes a foot‑gun for your customers.(compilenrun.com)

Instead of terminating the process, bubble up a normal error so callers can decide how to handle it (show a validation message, log and skip, etc.). One concrete way to achieve that without changing the JSON payload logic is to add a lightweight error enum and make these builders throws, for example:

+enum OperatorBuilderError: Error {
+    case invalidOperand(String)
+}
+
-    public static func increment(_ value: Double = 1, max: Double? = nil) -> String {
-        if value.isNaN || value.isInfinite {
-            fatalError("Value cannot be NaN or Infinity")
-        }
-        if let max = max, max.isNaN || max.isInfinite {
-            fatalError("Max cannot be NaN or Infinity")
-        }
+    public static func increment(_ value: Double = 1, max: Double? = nil) throws -> String {
+        guard !value.isNaN && !value.isInfinite else {
+            throw OperatorBuilderError.invalidOperand("Value cannot be NaN or Infinity")
+        }
+        if let max = max {
+            guard !max.isNaN && !max.isInfinite else {
+                throw OperatorBuilderError.invalidOperand("Max cannot be NaN or Infinity")
+            }
+        }
         var values: [Any] = [value]
         if let max = max {
             values.append(max)
         }
         return Operator(method: "increment", values: values).description
     }

Please apply the same pattern to decrement, multiply, divide, modulo, and power, so none of them can take the entire host app down.(compilenrun.com)

Committable suggestion skipped: line range outside the PR's diff.

@abnegate abnegate merged commit 18b675b into main Nov 3, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants