Skip to content

Conversation

ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Sep 26, 2025

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

Summary by CodeRabbit

  • New Features

    • Added type-safe enums for execution status and trigger.
  • Refactor

    • Execution model now uses enums instead of strings (may require code updates).
  • Bug Fixes

    • Model decoding now prefers nested "data" payloads for documents, preferences, and rows.
  • Chores

    • Updated SDK/version references and Swift Package Manager example to 13.0.0.
    • Warnings now emit to stderr rather than stdout.

Copy link

coderabbitai bot commented Sep 26, 2025

Walkthrough

  • README: Update Swift Package Manager example from version "12.1.0" to "13.0.0".
  • Client.swift: Update default header x-sdk-version to "13.0.0" and change warning output from stdout (print) to stderr (fputs).
  • Add public enums: AppwriteEnums.ExecutionStatus and AppwriteEnums.ExecutionTrigger (String raw values, CustomStringConvertible).
  • Execution model: Change trigger and status from String to the new enums; update initializer, Codable implementation, toMap(), and from(map:) to use enum raw values; add import AppwriteEnums.
  • Document, Preferences, Row models: In from(map:), decode generic/data payloads from map["data"] as [String: Any] with fallback to the entire map.

Possibly related PRs

  • Add time between queries #85: Also updates Client.swift default x-sdk-version header for an SDK version bump, touching the same initialization/header logic.

Suggested reviewers

  • ItzNotABug

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run `@coderabbitai generate docstrings` to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit's high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely describes the primary change—updating the Apple SDK to version 13.0.0—which aligns with the version bump in both the README and code headers, making it a precise summary of the main update.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 966fb33 and a32b4e5.

📒 Files selected for processing (2)
  • README.md (1 hunks)
  • Sources/Appwrite/Client.swift (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • README.md
  • Sources/Appwrite/Client.swift

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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Sources/AppwriteModels/Execution.swift (1)

133-139: Avoid force-unwrapping enum(rawValue:) to prevent crashes on unknown values.

When the backend introduces a new trigger/status string, ExecutionTrigger(rawValue:)! or ExecutionStatus(rawValue:)! will trap, taking down clients—a regression from the old String-based model. We need to fail gracefully during decoding and provide a safe fallback when mapping dictionaries.

-        self.trigger = AppwriteEnums.ExecutionTrigger(rawValue: try container.decode(String.self, forKey: .trigger))!
-        self.status = AppwriteEnums.ExecutionStatus(rawValue: try container.decode(String.self, forKey: .status))!
+        let triggerValue = try container.decode(String.self, forKey: .trigger)
+        guard let trigger = AppwriteEnums.ExecutionTrigger(rawValue: triggerValue) else {
+            throw DecodingError.dataCorruptedError(
+                forKey: .trigger,
+                in: container,
+                debugDescription: "Unsupported trigger value: \(triggerValue)"
+            )
+        }
+        self.trigger = trigger
+
+        let statusValue = try container.decode(String.self, forKey: .status)
+        guard let status = AppwriteEnums.ExecutionStatus(rawValue: statusValue) else {
+            throw DecodingError.dataCorruptedError(
+                forKey: .status,
+                in: container,
+                debugDescription: "Unsupported status value: \(statusValue)"
+            )
+        }
+        self.status = status
@@
-            trigger: ExecutionTrigger(rawValue: map["trigger"] as! String)!,
-            status: ExecutionStatus(rawValue: map["status"] as! String)!,
+            trigger: ExecutionTrigger(rawValue: map["trigger"] as? String ?? "") ?? .http,
+            status: ExecutionStatus(rawValue: map["status"] as? String ?? "") ?? .waiting,

Also applies to: 201-203

🧹 Nitpick comments (2)
Sources/AppwriteEnums/ExecutionTrigger.swift (1)

4-6: Remove redundant raw-value assignments to satisfy SwiftLint.

The explicit = "http" / = "schedule" / = "event" assignments duplicate the case names and trigger SwiftLint’s redundant_string_enum_value warning. Dropping the raw-value literals keeps the enum cleaner and avoids the warning.

-    case http = "http"
-    case schedule = "schedule"
-    case event = "event"
+    case http
+    case schedule
+    case event
Sources/AppwriteEnums/ExecutionStatus.swift (1)

4-7: Drop redundant raw values to silence SwiftLint.

These raw-value literals match the case identifiers exactly, so SwiftLint flags them as redundant. Letting Swift infer the String raw values keeps the enum tidy and resolves the warning.

-    case waiting = "waiting"
-    case processing = "processing"
-    case completed = "completed"
-    case failed = "failed"
+    case waiting
+    case processing
+    case completed
+    case failed
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between add7882 and 966fb33.

📒 Files selected for processing (8)
  • README.md (1 hunks)
  • Sources/Appwrite/Client.swift (2 hunks)
  • Sources/AppwriteEnums/ExecutionStatus.swift (1 hunks)
  • Sources/AppwriteEnums/ExecutionTrigger.swift (1 hunks)
  • Sources/AppwriteModels/Document.swift (1 hunks)
  • Sources/AppwriteModels/Execution.swift (7 hunks)
  • Sources/AppwriteModels/Preferences.swift (1 hunks)
  • Sources/AppwriteModels/Row.swift (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
Sources/AppwriteModels/Document.swift (2)
Sources/AppwriteModels/Preferences.swift (1)
  • from (38-42)
Sources/AppwriteModels/DocumentList.swift (1)
  • from (48-53)
Sources/AppwriteModels/Row.swift (2)
Sources/AppwriteModels/Document.swift (1)
  • from (101-112)
Sources/AppwriteModels/Preferences.swift (1)
  • from (38-42)
Sources/AppwriteModels/Preferences.swift (1)
Sources/AppwriteModels/Document.swift (1)
  • from (101-112)
🪛 SwiftLint (0.57.0)
Sources/AppwriteEnums/ExecutionTrigger.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)

Sources/AppwriteModels/Execution.swift

[Error] 201-201: Force casts should be avoided

(force_cast)


[Error] 202-202: Force casts should be avoided

(force_cast)

Sources/AppwriteModels/Document.swift

[Error] 110-110: Force tries should be avoided

(force_try)

Sources/AppwriteModels/Row.swift

[Error] 110-110: Force tries should be avoided

(force_try)

Sources/AppwriteEnums/ExecutionStatus.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)

Sources/AppwriteModels/Preferences.swift

[Error] 40-40: Force tries should be avoided

(force_try)

🔇 Additional comments (6)
Sources/Appwrite/Client.swift (2)

26-26: LGTM! Version header updated correctly.

The SDK version header has been updated to reflect the 12.2.0 release, consistent with the PR objectives and the version bump in README.md.


357-357: Excellent improvement: warnings now properly logged to stderr.

Redirecting warnings from stdout to stderr is the correct approach, ensuring warnings don't interfere with regular output and follow standard Unix conventions.

Sources/AppwriteModels/Row.swift (1)

110-110: LGTM! Data decoding updated with proper fallback.

The change to decode from map["data"] with a fallback to the entire map provides flexibility for different response structures. This pattern is consistently applied across Row, Document, and Preferences models.

Note: The force_try flagged by static analysis appears to be part of the existing SDK pattern for these generated models, where decoding failures would indicate a critical SDK-server contract violation.

README.md (1)

34-34: LGTM! Documentation updated to reflect the new SDK version.

The Swift Package Manager example now correctly references version 12.2.0, ensuring users will pull the updated SDK.

Sources/AppwriteModels/Document.swift (1)

110-110: LGTM! Consistent data decoding pattern applied.

The data decoding logic matches the pattern used in Row and Preferences models, ensuring consistent behavior across the SDK when handling nested data structures.

Sources/AppwriteModels/Preferences.swift (1)

40-40: LGTM! Final model updated with consistent data decoding.

This completes the consistent application of the nested data decoding pattern across Preferences, Document, and Row models, ensuring uniform handling of API responses throughout the SDK.

@ChiragAgg5k ChiragAgg5k changed the title feat: Apple SDK update for version 12.2.0 feat: Apple SDK update for version 13.0.0 Oct 3, 2025
@abnegate abnegate merged commit 8f79e67 into main Oct 3, 2025
1 check 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.

2 participants