Skip to content

feat: Apple SDK update for version 16.0.0#108

Merged
abnegate merged 6 commits into
mainfrom
dev
Mar 26, 2026
Merged

feat: Apple SDK update for version 16.0.0#108
abnegate merged 6 commits into
mainfrom
dev

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

@ChiragAgg5k ChiragAgg5k commented Mar 24, 2026

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

Summary by CodeRabbit

  • Breaking Changes

    • sequence field changed from Int to String in Row and Document models.
  • New Features

    • Added client impersonation configuration methods for user ID, email, and phone.
    • Added impersonation tracking fields to User model.
  • Documentation

    • Enhanced Log model documentation to clarify field behavior during impersonation.

* Added impersonation helpers to set impersonation headers.
* Added `DocumentsDB` service with documents and transactions APIs.
* Added `upsertDocuments` overloads supporting generic document types.
* Deprecated old `upsertDocuments` in favor of generic variant.
* Updated API version badge to 1.9.0 in README.
* Updated compatibility note to server version 1.9.x in README.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e184ddb0-775d-484b-9873-c74f1b01c03d

📥 Commits

Reviewing files that changed from the base of the PR and between 4d6b85a and cf788ff.

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

Walkthrough

This pull request introduces version 16.0.0 of the Appwrite Swift SDK with breaking changes and new features. The sequence field type is changed from Int to String in both Document and Row models. Three new client methods are added for user impersonation: setImpersonateUserId(), setImpersonateUserEmail(), and setImpersonateUserPhone(). The User model gains two new optional impersonation-related fields: impersonator and impersonatorUserId. Multiple files are updated to use Data(readableBytesView) instead of direct ByteBuffer handling, with conditional imports added for NIOFoundationCompat. Client metadata headers are updated to version 16.0.0 and response format to 1.9.0. Documentation in the Log model clarifies impersonation field behavior. Version references in README and changelog are updated accordingly.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 79.66% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 accurately summarizes the main change: updating the Apple SDK to version 16.0.0, which is reflected across all modified files including version bumps, new features, and breaking changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 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.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Mar 24, 2026

Greptile Summary

This PR updates the Apple SDK to version 14.2.0, adding two new database services (DocumentsDB and VectorsDB), user impersonation helpers, generic upsertDocuments overloads in Databases, model changes to reflect server-side updates (sequence now a String, new User impersonation fields), and conditional NIOFoundationCompat imports for broader platform compatibility.

Key issues found:

  • Server version mismatch in README: The compatibility note was set to 1.8.x instead of 1.9.x, contradicting the updated API badge (1.9.0), the x-appwrite-response-format header (1.9.0), and the PR description itself.
  • Incorrect deprecation messages: Both upsertDocuments overloads in Databases.swift reference TablesDB.upsertRows, a service that does not exist in this SDK; the correct target should be DocumentsDB.upsertDocuments. The version cited in the message (1.8.0) also appears to be wrong.
  • Runtime crash risk in Row.swift: The from(map:) factory uses a force-cast (as! String) for the $sequence field, which will crash if the field is absent. The equivalent change in Document.swift correctly uses a safe optional cast (as? String ?? "").
  • Formatting artifacts: Several DELETE call sites in DocumentsDB and VectorsDB have params: apiParams ) on one line (likely a codegen artifact), and both new service files are missing a trailing newline.

Confidence Score: 2/5

  • Not safe to merge as-is — contains a user-facing documentation error, broken deprecation guidance, and a potential runtime crash.
  • Three P1 issues exist: the README server version mismatch will mislead users about compatibility, the deprecation messages point to a non-existent service (TablesDB), and the force-cast in Row.swift can crash at runtime if $sequence is absent. None of these require large structural changes to fix, but they should be resolved before shipping.
  • README.md (server version), Sources/Appwrite/Services/Databases.swift (deprecation messages), and Sources/AppwriteModels/Row.swift (force-cast crash risk) require attention before merging.

Important Files Changed

Filename Overview
README.md API version badge correctly updated to 1.9.0, but the server compatibility note was set to 1.8.x instead of 1.9.x — contradicts the badge, the response format header, and the PR description.
Sources/Appwrite/Client.swift SDK version and response-format headers updated to 14.2.0/1.9.0; impersonation helpers added; NIOFoundationCompat imports made conditional and ByteBuffer conversions updated to avoid the dependency — changes are correct.
Sources/Appwrite/Services/Databases.swift Two new upsertDocuments overloads added but both carry incorrect deprecation messages referencing the non-existent TablesDB service and an incorrect version (1.8.0 instead of 1.9.0).
Sources/Appwrite/Services/DocumentsDB.swift New DocumentsDB service with full document/transaction CRUD; overall well-structured but deleteTransaction and deleteDocument have formatting issues (params on same line as closing paren) and file is missing trailing newline.
Sources/Appwrite/Services/VectorsDB.swift New VectorsDB service mirroring DocumentsDB structure; same formatting issue with deleteTransaction/deleteDocument and missing trailing newline.
Sources/AppwriteModels/Document.swift sequence field type changed from Int to String; uses safe optional cast (as? String ?? "") consistently — correct change.
Sources/AppwriteModels/Row.swift sequence field type changed from Int to String, but from(map:) uses a force-cast (as! String) that will crash at runtime if $sequence is absent, unlike Document.swift which safely uses as? String ?? "".
Sources/AppwriteModels/User.swift Two new optional impersonation fields added (impersonator: Bool?, impersonatorUserId: String?) with correct decodeIfPresent/encodeIfPresent usage — well implemented.

Comments Outside Diff (2)

  1. Sources/Appwrite/Services/Databases.swift, line 182 (link)

    P1 Deprecation message references non-existent TablesDB

    Both upsertDocuments overloads are deprecated with the message "Please use \TablesDB.upsertRows` instead.", but this SDK does not contain a TablesDBservice. The new services introduced in this PR areDocumentsDBandVectorsDB`. Additionally, the deprecation says "since 1.8.0" whereas this SDK update is for 1.9.0. The deprecation message is likely incorrect and will mislead callers.

  2. Sources/Appwrite/Services/Databases.swift, line 231 (link)

    P1 Deprecation message on second overload also needs correction

    The non-generic upsertDocuments overload carries the same incorrect deprecation message referencing the non-existent TablesDB.upsertRows. This should be updated consistently with the generic overload above.

Reviews (1): Last reviewed commit: "feat: update Apple SDK to 14.2.0" | Re-trigger Greptile

Comment thread README.md
@@ -94,7 +94,7 @@ open class Row<T : Codable>: Codable {
public static func from(map: [String: Any] ) -> Row {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Force unwrap will crash if $sequence is absent

The from(map:) factory uses a force-cast as! String for $sequence. If the server response ever omits this field (e.g. for an older server version), the app will crash at runtime. The parallel change in Document.swift correctly uses a safe optional cast with a default value (as? String ?? ""). This inconsistency should be resolved.

Suggested change
public static func from(map: [String: Any] ) -> Row {
sequence: map["$sequence"] as? String ?? "",

Comment on lines +416 to +418
/// - collectionId: String
/// - documents: [Any]
/// - Throws: Exception if the request fails
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Formatting issue: missing trailing newline before closing parenthesis

The closing ) of client.call(...) is on the same line as params: apiParams with extra spaces, likely a codegen artifact. The same pattern also appears in deleteDocument (line 971) and in VectorsDB.deleteTransaction / VectorsDB.deleteDocument. While Swift accepts this syntactically, it is inconsistent with all other methods in the file.

Suggested change
/// - collectionId: String
/// - documents: [Any]
/// - Throws: Exception if the request fails
params: apiParams
)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown

@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: 10

🧹 Nitpick comments (5)
Sources/AppwriteModels/Row.swift (1)

97-97: Inconsistent optional handling compared to Document.swift.

Row.from(map:) uses a force cast (as! String) for sequence, while Document.from(map:) uses a safer optional cast with fallback (as? String ?? ""). This inconsistency could cause a runtime crash if the server response doesn't include $sequence or returns an unexpected type.

Consider aligning with the safer pattern used in Document.swift:

♻️ Proposed fix for safer optional handling
-            sequence: map["$sequence"] as! String,
+            sequence: map["$sequence"] as? String ?? "",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Sources/AppwriteModels/Row.swift` at line 97, The Row.from(map:) initializer
is force-casting sequence using "sequence: map[\"$sequence\"] as! String" which
can crash; change it to the same safe pattern used in Document.from(map:) by
using an optional cast with a fallback (e.g., map["$sequence"] as? String ?? "")
for the sequence field in Row.from(map:) to avoid runtime crashes when the key
is missing or has an unexpected type.
docs/examples/databases/upsert-documents.md (1)

1-15: Show the new typed overload here.

This snippet resolves to the [String: AnyCodable] convenience overload, so it does not actually demonstrate the new generic API introduced in this PR. If the goal is to steer users toward typed documents, add nestedType: with a small model.

Proposed fix
+struct Book: Codable {
+    let title: String
+}
+
 let documentList = try await databases.upsertDocuments(
     databaseId: "<DATABASE_ID>",
     collectionId: "<COLLECTION_ID>",
     documents: [],
-    transactionId: "<TRANSACTION_ID>" // optional
+    transactionId: "<TRANSACTION_ID>", // optional
+    nestedType: Book.self
 )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/examples/databases/upsert-documents.md` around lines 1 - 15, The example
currently calls Databases.upsertDocuments and resolves to the untyped [String:
AnyCodable] overload; update the snippet to demonstrate the new generic API by
adding the nestedType: parameter and a small typed model (e.g., a struct) so the
call uses the typed overload of upsertDocuments; reference the Databases type,
the upsertDocuments function, and the nestedType argument name when making the
change.
docs/examples/vectorsdb/delete-transaction.md (1)

10-12: Optional clarity tweak: avoid implying a typed response payload for delete.

Since this method returns Any, using _ communicates intent better in docs.

Proposed doc tweak
-let result = try await vectorsDB.deleteTransaction(
+try await vectorsDB.deleteTransaction(
     transactionId: "<TRANSACTION_ID>"
 )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/examples/vectorsdb/delete-transaction.md` around lines 10 - 12, The
example assigns the Any return from vectorsDB.deleteTransaction to a typed
variable `result`, implying a structured payload; change the example to discard
the return value using `_` when calling
vectorsDB.deleteTransaction(transactionId: "<TRANSACTION_ID>") so the docs
communicate that the method returns an opaque Any and the response is
intentionally ignored; update the snippet around the call to use `_ = try await
vectorsDB.deleteTransaction(...)` or simply `try await
vectorsDB.deleteTransaction(...)` referencing the `vectorsDB.deleteTransaction`
call and `transactionId` parameter.
docs/examples/documentsdb/delete-document.md (1)

10-15: Optional clarity tweak: drop result binding for delete response.

For delete examples, direct try await is less misleading than binding an untyped return.

Proposed doc tweak
-let result = try await documentsDB.deleteDocument(
+try await documentsDB.deleteDocument(
     databaseId: "<DATABASE_ID>",
     collectionId: "<COLLECTION_ID>",
     documentId: "<DOCUMENT_ID>",
     transactionId: "<TRANSACTION_ID>" // optional
 )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/examples/documentsdb/delete-document.md` around lines 10 - 15, Drop the
unused `result` binding in the delete example to avoid implying a meaningful
return value; replace the bound call with a direct call to
documentsDB.deleteDocument using `try await
documentsDB.deleteDocument(databaseId: "<DATABASE_ID>", collectionId:
"<COLLECTION_ID>", documentId: "<DOCUMENT_ID>", transactionId:
"<TRANSACTION_ID>")` so the example shows the correct, unambiguous usage of the
deleteDocument API.
docs/examples/documentsdb/delete-transaction.md (1)

10-12: Optional clarity tweak: don’t bind delete response unless you use it.

Using direct try await is clearer for this delete example.

Proposed doc tweak
-let result = try await documentsDB.deleteTransaction(
+try await documentsDB.deleteTransaction(
     transactionId: "<TRANSACTION_ID>"
 )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/examples/documentsdb/delete-transaction.md` around lines 10 - 12, The
example currently assigns the delete result to a variable (`let result = try
await documentsDB.deleteTransaction(transactionId: "<TRANSACTION_ID>")`) even
though the response isn't used; replace that line to call the function without
binding (use `try await documentsDB.deleteTransaction(transactionId:
"<TRANSACTION_ID>")`) so the example is clearer and avoids unused variable
warnings—locate the call to documentsDB.deleteTransaction in the example and
remove the `let result =` binding.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGELOG.md`:
- Around line 5-10: The 14.2.0 changelog entry documents DocumentsDB but omits
the new public VectorsDB service; update CHANGELOG.md under the 14.2.0 notes to
add a line like "Added VectorsDB service
(Sources/Appwrite/Services/VectorsDB.swift) exposing the VectorsDB public
service" so consumers see the new VectorsDB addition alongside
DocumentsDB—mention the VectorsDB symbol/class name and a brief one-line
description of what it provides.

In `@docs/examples/documentsdb/increment-document-attribute.md`:
- Line 14: The example uses an empty attribute value (attribute: "") which is
invalid and likely to be copied by users; update the example to use a clear
placeholder token such as attribute: "<ATTRIBUTE_NAME>" (or attribute:
"myAttribute") so readers replace it with a real attribute name—locate the
attribute field in the example and replace the empty string with a non-empty
placeholder.

In `@docs/examples/documentsdb/upsert-document.md`:
- Line 14: The example uses an untyped empty Swift dictionary literal `data:
[:]` which can break type inference; update the snippet where `data:` appears by
providing a concrete payload (e.g., a small key/value example) or an explicitly
typed empty dictionary (e.g., `data: [String: Any]()`) so the example compiles
when copied into Swift projects; ensure the change is made in the
upsert-document example where `data:` is set.

In `@docs/examples/vectorsdb/create-document.md`:
- Around line 14-20: The example under data/embeddings currently shows
embeddings as an object with numeric string keys ("0", "1", "2", "3"); change it
to an ordered array of numbers so consumers and vector DBs can parse it
correctly — replace the object value for the embeddings field with an ordered
array (e.g., embeddings: [0.12, -0.55, 0.88, 1.02]) wherever the "data" ->
"embeddings" example appears.

In `@README.md`:
- Around line 5-10: Update the compatibility statement text to match the API
version badge: replace the string "This SDK is compatible with Appwrite server
version 1.8.x." with "This SDK is compatible with Appwrite server version
1.9.x." so the README's compatibility statement aligns with the Version badge
(1.9.0) and the PR description; ensure the exact phrase change is applied
wherever the 1.8.x compatibility sentence appears.

In `@Sources/Appwrite/Client.swift`:
- Around line 470-472: The ByteBuffer initialization is using a non-existent
initializer (ByteBuffer(bytes:)) in the switch handling for the upload input;
update the cases that set input.data to use the NIOFoundationCompat API
ByteBuffer(data: Data) instead: in the "path" branch create Data from URL and
pass it to ByteBuffer(data:) and in the "data" branch cast input.data to Data
and wrap it with ByteBuffer(data:), locating the changes around the switch cases
"path" and "data" where input.data is assigned in Sources/Appwrite/Client.swift.

In `@Sources/Appwrite/Services/DocumentsDB.swift`:
- Around line 719-720: The doc summaries mistakenly use "column of a row"
(copied from TablesDB); update the comments to say "attribute of a document"
instead — e.g., change "Decrement a specific column of a row by a given value."
to "Decrement a specific attribute of a document by a given value." and make the
same replacement for the related summary at the other occurrence (the duplicate
comment around lines 807-808) and any other similar summaries in
DocumentsDB.swift (look for the increment/decrement method summaries or
functions handling document attribute updates) so public docs refer to document
attributes, not table columns/rows.
- Around line 297-362: Add an optional transactionId: String? = nil parameter to
both createDocument<T>(...) and the non-generic createDocument(...) overload
(and to the createDocuments<T>/createDocuments overloads) and include
"transactionId": transactionId in their apiParams dictionaries so create
operations can participate in Appwrite transactions; update the method
signatures in DocumentsDB.swift (look for createDocument<T>, createDocument,
createDocuments<T>, createDocuments) and pass transactionId through to
client.call. Also correct the documentation strings for
decrementDocumentAttribute and incrementDocumentAttribute by replacing "column
of a row" with "attribute of a document".

In `@Sources/Appwrite/Services/VectorsDB.swift`:
- Around line 286-345: Add an optional transactionId: String? parameter (default
nil) to both createDocument<T>(...) and the non-generic createDocument(...)
overloads in VectorsDB.swift, include "transactionId": transactionId in the
apiParams dictionary used by createDocument<T>, and update the non-generic
createDocument to forward the new transactionId when calling the generic
createDocument (keep nestedType forwarding as-is). Reference the
createDocument<T>(databaseId:collectionId:documentId:data:permissions:nestedType:)
function and the
createDocument(databaseId:collectionId:documentId:data:permissions:) overload to
locate where to add the parameter and apiParams entry.

In `@Sources/AppwriteModels/Document.swift`:
- Line 21: The Document model's public property sequence was changed from Int to
String (public let sequence: String), which is an API-breaking change; update
the project's CHANGELOG/migration notes to document this breaking change and
provide migration guidance (e.g., treat Document.sequence as String or convert
with Int(Document.sequence) where numeric semantics are required), then search
for and update all code paths, tests, and Codable decoding logic that expect
Document.sequence as Int (and any references in Row.swift comparisons) to either
accept String or explicitly convert/parse it to Int, ensuring compile-time fixes
and adding a note about server API alignment.

---

Nitpick comments:
In `@docs/examples/databases/upsert-documents.md`:
- Around line 1-15: The example currently calls Databases.upsertDocuments and
resolves to the untyped [String: AnyCodable] overload; update the snippet to
demonstrate the new generic API by adding the nestedType: parameter and a small
typed model (e.g., a struct) so the call uses the typed overload of
upsertDocuments; reference the Databases type, the upsertDocuments function, and
the nestedType argument name when making the change.

In `@docs/examples/documentsdb/delete-document.md`:
- Around line 10-15: Drop the unused `result` binding in the delete example to
avoid implying a meaningful return value; replace the bound call with a direct
call to documentsDB.deleteDocument using `try await
documentsDB.deleteDocument(databaseId: "<DATABASE_ID>", collectionId:
"<COLLECTION_ID>", documentId: "<DOCUMENT_ID>", transactionId:
"<TRANSACTION_ID>")` so the example shows the correct, unambiguous usage of the
deleteDocument API.

In `@docs/examples/documentsdb/delete-transaction.md`:
- Around line 10-12: The example currently assigns the delete result to a
variable (`let result = try await documentsDB.deleteTransaction(transactionId:
"<TRANSACTION_ID>")`) even though the response isn't used; replace that line to
call the function without binding (use `try await
documentsDB.deleteTransaction(transactionId: "<TRANSACTION_ID>")`) so the
example is clearer and avoids unused variable warnings—locate the call to
documentsDB.deleteTransaction in the example and remove the `let result =`
binding.

In `@docs/examples/vectorsdb/delete-transaction.md`:
- Around line 10-12: The example assigns the Any return from
vectorsDB.deleteTransaction to a typed variable `result`, implying a structured
payload; change the example to discard the return value using `_` when calling
vectorsDB.deleteTransaction(transactionId: "<TRANSACTION_ID>") so the docs
communicate that the method returns an opaque Any and the response is
intentionally ignored; update the snippet around the call to use `_ = try await
vectorsDB.deleteTransaction(...)` or simply `try await
vectorsDB.deleteTransaction(...)` referencing the `vectorsDB.deleteTransaction`
call and `transactionId` parameter.

In `@Sources/AppwriteModels/Row.swift`:
- Line 97: The Row.from(map:) initializer is force-casting sequence using
"sequence: map[\"$sequence\"] as! String" which can crash; change it to the same
safe pattern used in Document.from(map:) by using an optional cast with a
fallback (e.g., map["$sequence"] as? String ?? "") for the sequence field in
Row.from(map:) to avoid runtime crashes when the key is missing or has an
unexpected type.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4b83461e-e037-4557-a408-eb7389f1f376

📥 Commits

Reviewing files that changed from the base of the PR and between e2ba30c and 184e784.

📒 Files selected for processing (42)
  • CHANGELOG.md
  • README.md
  • Sources/Appwrite/Client.swift
  • Sources/Appwrite/Services/Databases.swift
  • Sources/Appwrite/Services/DocumentsDB.swift
  • Sources/Appwrite/Services/VectorsDB.swift
  • Sources/Appwrite/WebSockets/MessageHandler.swift
  • Sources/Appwrite/WebSockets/WebSocketClient.swift
  • Sources/AppwriteModels/Document.swift
  • Sources/AppwriteModels/Log.swift
  • Sources/AppwriteModels/Row.swift
  • Sources/AppwriteModels/User.swift
  • docs/examples/databases/upsert-documents.md
  • docs/examples/documentsdb/create-document.md
  • docs/examples/documentsdb/create-documents.md
  • docs/examples/documentsdb/create-operations.md
  • docs/examples/documentsdb/create-transaction.md
  • docs/examples/documentsdb/decrement-document-attribute.md
  • docs/examples/documentsdb/delete-document.md
  • docs/examples/documentsdb/delete-transaction.md
  • docs/examples/documentsdb/get-document.md
  • docs/examples/documentsdb/get-transaction.md
  • docs/examples/documentsdb/increment-document-attribute.md
  • docs/examples/documentsdb/list-documents.md
  • docs/examples/documentsdb/list-transactions.md
  • docs/examples/documentsdb/update-document.md
  • docs/examples/documentsdb/update-transaction.md
  • docs/examples/documentsdb/upsert-document.md
  • docs/examples/vectorsdb/create-document.md
  • docs/examples/vectorsdb/create-operations.md
  • docs/examples/vectorsdb/create-transaction.md
  • docs/examples/vectorsdb/delete-document.md
  • docs/examples/vectorsdb/delete-transaction.md
  • docs/examples/vectorsdb/get-document.md
  • docs/examples/vectorsdb/get-transaction.md
  • docs/examples/vectorsdb/list-documents.md
  • docs/examples/vectorsdb/list-transactions.md
  • docs/examples/vectorsdb/update-document.md
  • docs/examples/vectorsdb/update-transaction.md
  • docs/examples/vectorsdb/upsert-document.md
  • example-swiftui/Shared/ExampleViewModel.swift
  • example-uikit/UIKitExample/ViewController.swift

Comment thread CHANGELOG.md Outdated
Comment on lines +5 to +10
* Added impersonation helpers to set impersonation headers.
* Added `DocumentsDB` service with documents and transactions APIs.
* Added `upsertDocuments` overloads supporting generic document types.
* Deprecated old `upsertDocuments` in favor of generic variant.
* Updated API version badge to 1.9.0 in README.
* Updated compatibility note to server version 1.9.x in README.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Document VectorsDB in the 14.2.0 notes.

Sources/Appwrite/Services/VectorsDB.swift adds a new public service, but the release notes only call out DocumentsDB. That leaves the changelog incomplete for consumers scanning what's new.

Proposed fix
 * Added impersonation helpers to set impersonation headers.
 * Added `DocumentsDB` service with documents and transactions APIs.
+* Added `VectorsDB` service with documents and transactions APIs.
 * Added `upsertDocuments` overloads supporting generic document types.
🧰 Tools
🪛 LanguageTool

[style] ~7-~7: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...with documents and transactions APIs. * Added upsertDocuments overloads supporting ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CHANGELOG.md` around lines 5 - 10, The 14.2.0 changelog entry documents
DocumentsDB but omits the new public VectorsDB service; update CHANGELOG.md
under the 14.2.0 notes to add a line like "Added VectorsDB service
(Sources/Appwrite/Services/VectorsDB.swift) exposing the VectorsDB public
service" so consumers see the new VectorsDB addition alongside
DocumentsDB—mention the VectorsDB symbol/class name and a brief one-line
description of what it provides.

databaseId: "<DATABASE_ID>",
collectionId: "<COLLECTION_ID>",
documentId: "<DOCUMENT_ID>",
attribute: "",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use a non-empty attribute placeholder

attribute: "" suggests an invalid value. Prefer a placeholder token to avoid users copying a failing request. Line 14 should be updated.

Proposed docs fix
-    attribute: "",
+    attribute: "<ATTRIBUTE_KEY>",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
attribute: "",
attribute: "<ATTRIBUTE_KEY>",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/examples/documentsdb/increment-document-attribute.md` at line 14, The
example uses an empty attribute value (attribute: "") which is invalid and
likely to be copied by users; update the example to use a clear placeholder
token such as attribute: "<ATTRIBUTE_NAME>" (or attribute: "myAttribute") so
readers replace it with a real attribute name—locate the attribute field in the
example and replace the empty string with a non-empty placeholder.

Comment thread docs/examples/documentsdb/upsert-document.md Outdated
Comment on lines +14 to +20
data: [
"embeddings": [
"0": 0.12,
"1": -0.55,
"2": 0.88,
"3": 1.02
],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

In Appwrite Server 1.9.x / Apple SDK 14.2.0, what JSON shape should a VectorsDB document's embedding field use in createDocument examples: an ordered array of numbers or an object keyed by indices?

💡 Result:

In Appwrite Server 1.9.x with Apple SDK 14.2.0, VectorsDB appears to be an experimental or upcoming feature referred to as "documentsdb" in development (PR #10518), likely for vector embeddings storage. No official documentation or examples for VectorsDB createDocument were found in current sources. Standard Appwrite Databases documents use JSON objects for data, and arrays of numbers are supported as attribute values when the attribute is configured as an array type (e.g., float array). For embedding fields, use an ordered array of numbers [0.1, 0.2, ...], as this is the conventional format for vector embeddings across vector databases (e.g., Supabase vectors use float32 arrays). An object keyed by indices is not standard and unsupported. Configure the embedding attribute as a required float array in the VectorsDB collection.

Citations:


Fix the VectorsDB embedding format to use an ordered array.

The current example encodes embeddings as an object with indexed keys ("0", "1", etc.), which is not the standard format for vector embeddings. Vector databases expect embeddings as ordered arrays of numbers. The sample as written will fail when readers copy it.

✏️ Suggested doc fix
     data: [
-        "embeddings": [
-            "0": 0.12,
-            "1": -0.55,
-            "2": 0.88,
-            "3": 1.02
-        ],
+        "embeddings": [0.12, -0.55, 0.88, 1.02],
         "metadata": [
             "key": "value"
         ]
     ],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
data: [
"embeddings": [
"0": 0.12,
"1": -0.55,
"2": 0.88,
"3": 1.02
],
data: [
"embeddings": [0.12, -0.55, 0.88, 1.02],
"metadata": [
"key": "value"
]
],
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/examples/vectorsdb/create-document.md` around lines 14 - 20, The example
under data/embeddings currently shows embeddings as an object with numeric
string keys ("0", "1", "2", "3"); change it to an ordered array of numbers so
consumers and vector DBs can parse it correctly — replace the object value for
the embeddings field with an ordered array (e.g., embeddings: [0.12, -0.55,
0.88, 1.02]) wherever the "data" -> "embeddings" example appears.

Comment thread README.md Outdated
Comment thread Sources/Appwrite/Client.swift
Comment on lines +297 to +362
open func createDocument<T>(
databaseId: String,
collectionId: String,
documentId: String,
data: Any,
permissions: [String]? = nil,
nestedType: T.Type
) async throws -> AppwriteModels.Document<T> {
let apiPath: String = "/documentsdb/{databaseId}/collections/{collectionId}/documents"
.replacingOccurrences(of: "{databaseId}", with: databaseId)
.replacingOccurrences(of: "{collectionId}", with: collectionId)

let apiParams: [String: Any?] = [
"documentId": documentId,
"data": data,
"permissions": permissions
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]

let converter: (Any) -> AppwriteModels.Document<T> = { response in
return AppwriteModels.Document.from(map: response as! [String: Any])
}

return try await client.call(
method: "POST",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}

///
/// Create a new Document. Before using this route, you should create a new
/// collection resource using either a [server
/// integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection)
/// API or directly from your database console.
///
/// - Parameters:
/// - databaseId: String
/// - collectionId: String
/// - documentId: String
/// - data: Any
/// - permissions: [String] (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Document<T>
///
open func createDocument(
databaseId: String,
collectionId: String,
documentId: String,
data: Any,
permissions: [String]? = nil
) async throws -> AppwriteModels.Document<[String: AnyCodable]> {
return try await createDocument(
databaseId: databaseId,
collectionId: collectionId,
documentId: documentId,
data: data,
permissions: permissions,
nestedType: [String: AnyCodable].self
)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the DocumentsDB.swift file to see the method signatures
git ls-files | grep -i "DocumentsDB.swift"

Repository: appwrite/sdk-for-apple

Length of output: 109


🏁 Script executed:

# Get the file and check its size
wc -l Sources/Appwrite/Services/DocumentsDB.swift

Repository: appwrite/sdk-for-apple

Length of output: 113


🏁 Script executed:

# Extract the method signatures for create, upsert, update, delete methods
rg -A 8 "open func (createDocument|createDocuments|upsertDocument|updateDocument|deleteDocument)" Sources/Appwrite/Services/DocumentsDB.swift -B 0

Repository: appwrite/sdk-for-apple

Length of output: 3231


🏁 Script executed:

# Check the documentation at lines 719-720 and 807-808
sed -n '715,725p; 803,813p' Sources/Appwrite/Services/DocumentsDB.swift

Repository: appwrite/sdk-for-apple

Length of output: 603


🏁 Script executed:

# Get full context of the numeric attribute helper methods
sed -n '716,740p; 804,828p' Sources/Appwrite/Services/DocumentsDB.swift

Repository: appwrite/sdk-for-apple

Length of output: 1528


🌐 Web query:

Appwrite transaction API stageable create operation documentation

💡 Result:

Appwrite's Transactions API allows staging create operations (and other operations) for atomic execution across databases and tables. Official documentation is at https://appwrite.io/docs/products/databases/transactions. ## Workflow 1. Create a transaction: tablesDB.createTransaction returns a transaction object with $id. 2. Stage create operations using transactionId: - Single: tablesDB.createRow({ ..., transactionId: tx.$id }) - Multiple: tablesDB.createOperations({ transactionId: tx.$id, operations: [{ action: 'create', databaseId: '...', tableId: '...', data: { ... } }] }) 3. Commit: tablesDB.updateTransaction({ transactionId: tx.$id, action: 'commit' }) or rollback. Staged operations are not persisted until commit. Supports create, update, upsert, delete, increment/decrement, and bulk variants. Limits apply based on plan (e.g., max operations per transaction). Example (Web SDK): const tx = await tablesDB.createTransaction; await tablesDB.createRow({ databaseId: '<DATABASE_ID>', tableId: '<TABLE_ID>', data: { name: 'Walter' }, transactionId: tx.$id }); await tablesDB.updateTransaction({ transactionId: tx.$id, action: 'commit' }); For full API reference, see https://appwrite.io/docs/references/cloud/databases#databasesCreateTransaction, #databasesCreateRow (with transactionId), etc.

Citations:


🏁 Script executed:

# Let's also check if there's a TablesDB.swift to confirm copy-paste source
fd "TablesDB.swift"

Repository: appwrite/sdk-for-apple

Length of output: 106


Add transactionId parameter to createDocument and createDocuments methods.

createDocument and createDocuments are the only mutating document methods in this service that cannot participate in transactions. Appwrite's transaction API supports staging create operations via transactionId, and the other mutating methods (upsertDocument, updateDocument, deleteDocument) already expose this parameter. Without it, callers cannot create documents inside a transaction through DocumentsDB.

Also fix documentation for decrementDocumentAttribute and incrementDocumentAttribute (lines ~719 and ~807): change "column of a row" to "attribute of a document" to correct copy-paste terminology from TablesDB.swift.

Proposed changes

Add transactionId: String? = nil parameter to:

  • createDocument<T> and createDocument method signatures
  • createDocuments<T> and createDocuments method signatures
  • Include in apiParams dictionary for each method

Update documentation strings:

  • Line ~719: "Decrement a specific column of a row" → "Decrement a specific attribute of a document"
  • Line ~807: "Increment a specific column of a row" → "Increment a specific attribute of a document"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Sources/Appwrite/Services/DocumentsDB.swift` around lines 297 - 362, Add an
optional transactionId: String? = nil parameter to both createDocument<T>(...)
and the non-generic createDocument(...) overload (and to the
createDocuments<T>/createDocuments overloads) and include "transactionId":
transactionId in their apiParams dictionaries so create operations can
participate in Appwrite transactions; update the method signatures in
DocumentsDB.swift (look for createDocument<T>, createDocument,
createDocuments<T>, createDocuments) and pass transactionId through to
client.call. Also correct the documentation strings for
decrementDocumentAttribute and incrementDocumentAttribute by replacing "column
of a row" with "attribute of a document".

Comment on lines +719 to +720
///
/// Decrement a specific column of a row by a given value.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix the copied TablesDB wording.

These summaries say "column of a row", but this API operates on document attributes. The current text will confuse readers of the public docs.

Proposed fix
-    /// Decrement a specific column of a row by a given value.
+    /// Decrement a specific attribute of a document by a given value.
@@
-    /// Increment a specific column of a row by a given value.
+    /// Increment a specific attribute of a document by a given value.

Also applies to: 807-808

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Sources/Appwrite/Services/DocumentsDB.swift` around lines 719 - 720, The doc
summaries mistakenly use "column of a row" (copied from TablesDB); update the
comments to say "attribute of a document" instead — e.g., change "Decrement a
specific column of a row by a given value." to "Decrement a specific attribute
of a document by a given value." and make the same replacement for the related
summary at the other occurrence (the duplicate comment around lines 807-808) and
any other similar summaries in DocumentsDB.swift (look for the
increment/decrement method summaries or functions handling document attribute
updates) so public docs refer to document attributes, not table columns/rows.

Comment on lines +286 to +345
open func createDocument<T>(
databaseId: String,
collectionId: String,
documentId: String,
data: Any,
permissions: [String]? = nil,
nestedType: T.Type
) async throws -> AppwriteModels.Document<T> {
let apiPath: String = "/vectorsdb/{databaseId}/collections/{collectionId}/documents"
.replacingOccurrences(of: "{databaseId}", with: databaseId)
.replacingOccurrences(of: "{collectionId}", with: collectionId)

let apiParams: [String: Any?] = [
"documentId": documentId,
"data": data,
"permissions": permissions
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]

let converter: (Any) -> AppwriteModels.Document<T> = { response in
return AppwriteModels.Document.from(map: response as! [String: Any])
}

return try await client.call(
method: "POST",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}

///
/// - Parameters:
/// - databaseId: String
/// - collectionId: String
/// - documentId: String
/// - data: Any
/// - permissions: [String] (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Document<T>
///
open func createDocument(
databaseId: String,
collectionId: String,
documentId: String,
data: Any,
permissions: [String]? = nil
) async throws -> AppwriteModels.Document<[String: AnyCodable]> {
return try await createDocument(
databaseId: databaseId,
collectionId: collectionId,
documentId: documentId,
data: data,
permissions: permissions,
nestedType: [String: AnyCodable].self
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -name "VectorsDB.swift" -type f

Repository: appwrite/sdk-for-apple

Length of output: 109


🏁 Script executed:

wc -l Sources/Appwrite/Services/VectorsDB.swift

Repository: appwrite/sdk-for-apple

Length of output: 111


🏁 Script executed:

# Get method signatures for the mentioned methods
sed -n '1,500p' Sources/Appwrite/Services/VectorsDB.swift | grep -A 8 "func createDocument\|func upsertDocument\|func updateDocument\|func deleteDocument"

Repository: appwrite/sdk-for-apple

Length of output: 1367


🏁 Script executed:

sed -n '400,609p' Sources/Appwrite/Services/VectorsDB.swift | grep -A 8 "func updateDocument\|func deleteDocument"

Repository: appwrite/sdk-for-apple

Length of output: 1133


🏁 Script executed:

# Also search for transactionId usage across the entire file
grep -n "transactionId" Sources/Appwrite/Services/VectorsDB.swift

Repository: appwrite/sdk-for-apple

Length of output: 2229


🏁 Script executed:

find . -name "Databases.swift" -path "*/Services/*" -type f

Repository: appwrite/sdk-for-apple

Length of output: 109


🏁 Script executed:

# Check createDocument signature in Databases.swift
grep -A 8 "func createDocument<T>" Sources/Appwrite/Services/Databases.swift | head -20

Repository: appwrite/sdk-for-apple

Length of output: 357


🏁 Script executed:

# Also check other document methods in Databases.swift
grep -A 6 "func upsertDocument\|func updateDocument\|func deleteDocument" Sources/Appwrite/Services/Databases.swift | grep -A 6 "transactionId" | head -30

Repository: appwrite/sdk-for-apple

Length of output: 875


Add transactionId parameter to createDocument methods.

In VectorsDB.swift, createDocument is the only document mutation method without transactionId support. The standard Databases.swift service includes it on createDocument, and upsertDocument, updateDocument, and deleteDocument in VectorsDB.swift already have it. This gap prevents creating vector documents within transactions.

Proposed fix
 open func createDocument<T>(
     databaseId: String,
     collectionId: String,
     documentId: String,
     data: Any,
     permissions: [String]? = nil,
+    transactionId: String? = nil,
     nestedType: T.Type
 ) async throws -> AppwriteModels.Document<T> {
@@
         let apiParams: [String: Any?] = [
             "documentId": documentId,
             "data": data,
-            "permissions": permissions
+            "permissions": permissions,
+            "transactionId": transactionId
         ]
@@
 open func createDocument(
     databaseId: String,
     collectionId: String,
     documentId: String,
     data: Any,
-    permissions: [String]? = nil
+    permissions: [String]? = nil,
+    transactionId: String? = nil
 ) async throws -> AppwriteModels.Document<[String: AnyCodable]> {
     return try await createDocument(
         databaseId: databaseId,
         collectionId: collectionId,
         documentId: documentId,
         data: data,
         permissions: permissions,
+        transactionId: transactionId,
         nestedType: [String: AnyCodable].self
     )
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Sources/Appwrite/Services/VectorsDB.swift` around lines 286 - 345, Add an
optional transactionId: String? parameter (default nil) to both
createDocument<T>(...) and the non-generic createDocument(...) overloads in
VectorsDB.swift, include "transactionId": transactionId in the apiParams
dictionary used by createDocument<T>, and update the non-generic createDocument
to forward the new transactionId when calling the generic createDocument (keep
nestedType forwarding as-is). Reference the
createDocument<T>(databaseId:collectionId:documentId:data:permissions:nestedType:)
function and the
createDocument(databaseId:collectionId:documentId:data:permissions:) overload to
locate where to add the parameter and apiParams entry.

public let id: String
/// Document sequence ID.
public let sequence: Int
public let sequence: String
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Breaking change: sequence type changed from Int to String.

This is an API-breaking change. Existing code that accesses document.sequence as an Int will fail to compile. The change is consistent with Row.swift which also uses String for sequence, indicating an intentional alignment with server API changes.

Ensure this breaking change is documented in the CHANGELOG or migration notes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Sources/AppwriteModels/Document.swift` at line 21, The Document model's
public property sequence was changed from Int to String (public let sequence:
String), which is an API-breaking change; update the project's
CHANGELOG/migration notes to document this breaking change and provide migration
guidance (e.g., treat Document.sequence as String or convert with
Int(Document.sequence) where numeric semantics are required), then search for
and update all code paths, tests, and Codable decoding logic that expect
Document.sequence as Int (and any references in Row.swift comparisons) to either
accept String or explicitly convert/parse it to Int, ensuring compile-time fixes
and adding a note about server API alignment.

@ChiragAgg5k ChiragAgg5k changed the title feat: Apple SDK update for version 14.2.0 feat: Apple SDK update for version 15.0.0 Mar 25, 2026
Comment thread CHANGELOG.md
Comment thread CHANGELOG.md Outdated
@ChiragAgg5k ChiragAgg5k changed the title feat: Apple SDK update for version 15.0.0 feat: Apple SDK update for version 16.0.0 Mar 26, 2026
@abnegate abnegate merged commit b3f994f into main Mar 26, 2026
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