feat: Rust SDK update for version 0.2.0#11
Conversation
WalkthroughThis PR bumps the SDK version from 0.1.0 to 0.2.0 across package metadata and documentation. It removes all release-candidate (Rc) build and runtime enum variants, introduces three new database service types (Tablesdb, Documentsdb, Vectorsdb), and renames the IndexType enum to DatabasesIndexType and TablesDBIndexType for clarity. Multiple service methods update parameter types from single values to vectors (permissions, services, scopes, orders). The Health service removes five queue-specific methods, and a new Project service module is added with five environment variable management methods. Model field types change from Vec to Vec<serde_json::Value> for increased flexibility, and the client's file upload logic simplifies by removing conditional URL construction based on upload_id. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Greptile SummaryThis PR updates the Rust SDK to target Appwrite server version 1.9.x, introducing a new Key changes:
Confidence Score: 4/5Safe to merge after fixing the required key parameter in project update_variable One P1 defect: project update_variable accepts key as Option which means callers can omit it and send an incomplete PUT body that the Appwrite API will reject. All other changes are consistent and correctly aligned. src/services/project.rs — update_variable signature needs key to be a required parameter Important Files Changed
Reviews (1): Last reviewed commit: "chore: update Rust SDK to 0.2.0" | Re-trigger Greptile |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/services/databases.rs (1)
1740-1752:⚠️ Potential issue | 🟡 MinorUpdate the
create_indexdocs to includespatial.
DatabasesIndexTypenow exposesSpatial, but the doc comment abovecreate_indexstill advertises onlykey,fulltext, andunique.📝 Suggested doc fix
- /// Attributes can be `key`, `fulltext`, and `unique`. + /// Attributes can be `key`, `fulltext`, `unique`, and `spatial`.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/services/databases.rs` around lines 1740 - 1752, The doc comment for the create_index method is out of date: update the documentation above pub async fn create_index to list the new Spatial option by adding `spatial` to the allowed attribute types (so it reads something like "Attributes can be `key`, `fulltext`, `unique`, and `spatial`"); ensure the comment references the DatabasesIndexType enum (crate::enums::DatabasesIndexType) so future enum additions are obvious.
🧹 Nitpick comments (6)
src/enums/template_reference_type.rs (1)
6-9: Lock the new default (Commit) with regression tests.Line 6 changes the enum default semantics. That’s fine if intentional, but it’s a subtle SDK behavior change; please add unit tests to pin
Default::default()and allas_str()mappings.Proposed test addition
impl std::fmt::Display for TemplateReferenceType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.as_str()) } } + +#[cfg(test)] +mod tests { + use super::TemplateReferenceType; + + #[test] + fn default_is_commit() { + assert_eq!(TemplateReferenceType::default(), TemplateReferenceType::Commit); + } + + #[test] + fn as_str_mappings_are_stable() { + assert_eq!(TemplateReferenceType::Commit.as_str(), "commit"); + assert_eq!(TemplateReferenceType::Branch.as_str(), "branch"); + assert_eq!(TemplateReferenceType::Tag.as_str(), "tag"); + } +}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/enums/template_reference_type.rs` around lines 6 - 9, The change makes Commit the enum default for TemplateReferenceType; add unit tests that pin this behavior and the string mappings: create tests (e.g., test_default_template_reference_type and test_template_reference_type_as_str_and_serde) that assert Default::default() == TemplateReferenceType::Commit, that TemplateReferenceType::Commit.as_str() and TemplateReferenceType::Branch.as_str() return the expected strings, and that serde serializes/deserializes Branch as "branch" (and Commit to its expected value) to prevent regressions in the Default/as_str/serde mappings.src/client.rs (2)
92-96: Derive the SDK version from Cargo metadata.Hard-coding
0.2.0in multiple headers means the next release needs another manual sweep. Read the version once and reuse it here.♻️ Suggested change
+ let sdk_version = env!("CARGO_PKG_VERSION"); headers.insert("X-Appwrite-Response-Format", "1.9.0".parse().unwrap()); - headers.insert("user-agent", format!("AppwriteRustSDK/0.2.0 ({}; {})", std::env::consts::OS, std::env::consts::ARCH).parse().unwrap()); + headers.insert("user-agent", format!("AppwriteRustSDK/{sdk_version} ({}; {})", std::env::consts::OS, std::env::consts::ARCH).parse().unwrap()); headers.insert("x-sdk-name", "Rust".parse().unwrap()); headers.insert("x-sdk-platform", "server".parse().unwrap()); headers.insert("x-sdk-language", "rust".parse().unwrap()); - headers.insert("x-sdk-version", "0.2.0".parse().unwrap()); + headers.insert("x-sdk-version", sdk_version.parse().unwrap());🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/client.rs` around lines 92 - 96, Replace the hard-coded "0.2.0" with the crate version from Cargo metadata and reuse it: create a single SDK version value (e.g., a const or local binding using env!("CARGO_PKG_VERSION")) and use that variable in the headers.insert calls for "user-agent" and "x-sdk-version" (the existing headers variable and the headers.insert(...) calls for "user-agent" and "x-sdk-version" are the exact locations to update).
619-623: Add a regression test for the new single-part upload path.Callers like
src/services/storage.rs:232-243still passupload_id, but this branch now always posts to{endpoint}{path}. Appwrite documentsPOST /storage/buckets/{bucketId}/filesfor file creation and usesx-appwrite-idfor later chunk requests, so this behavior is worth locking down with a request-construction test. (appwrite.io)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/client.rs` around lines 619 - 623, Add a regression test that verifies the single-part upload branch (when file_size <= chunk_size) constructs the HTTP request to POST to "{endpoint}{path}" and not the chunk upload URL even if an upload_id is provided; target the code paths around file_size, chunk_size and the single_file_upload method in client.rs, mocking or intercepting the outgoing request to assert the request method/URL and that headers (including any x-appwrite-id if present) and params are set as expected; place the test alongside existing storage client tests and ensure it covers the case where callers (e.g., storage service code) pass upload_id but the client still performs a single-file POST to the base path.src/services/project.rs (1)
81-104: Avoid sending empty update payloads inupdate_variable.When
key,value, andsecretare allNone, this performs a no-op network call and returns a server-side validation error at best. Add a local precondition check and return a clear SDK error.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/services/project.rs` around lines 81 - 104, In update_variable, add a local precondition that if none of key/value/secret were provided (i.e., params.is_empty()) the function returns an immediate SDK error instead of making the network call; locate the update_variable function and after building params check params.is_empty() and return an appropriate Err(crate::error::Result::Err(...) or a suitable crate::error::Error variant with a clear message like "no fields provided for update") so callers receive a clear, local validation error rather than a server-side validation failure.CHANGELOG.md (1)
8-8: Consider adding a “Changed/Breaking” migration note in this release entry.Since 0.2.0 includes public API surface changes (renamed types/signature shifts), adding a short migration subsection here would make upgrades safer for SDK consumers.
Also applies to: 856-856
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@CHANGELOG.md` at line 8, Under the "## [0.2.0] - TBD" changelog entry add a short "Changed" or "Breaking Changes / Migration" subsection that lists the public API renames and signature changes and gives one-line migration steps (old name → new name or old signature → new signature) for each affected symbol; specifically mention any renamed types or functions and include example mappings so SDK consumers know how to update their code. Ensure the subsection sits directly beneath the 0.2.0 header and uses concise bullet points or short lines for each change.src/services/backups.rs (1)
39-43: Guard against emptyservicesvectors in public methods.These signatures now allow
vec![], which weakens the previous type-level guarantee (at least one service). Add an early validation branch to fail fast with a clear client-side error before making the HTTP call.Also applies to: 100-104, 189-193
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/services/backups.rs` around lines 39 - 43, create_archive currently accepts services: Vec<crate::enums::BackupServices> and allows an empty vector; add an early validation at the top of create_archive that returns a client-side Err when services.is_empty() with a clear message (e.g. "at least one backup service required") before any HTTP calls; apply the same empty-vector guard to the other public methods in this file that take services: Vec<crate::enums::BackupServices> so they likewise fail fast and return the same client error rather than proceeding with an empty services list.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/services/databases.rs`:
- Around line 1740-1752: The doc comment for the create_index method is out of
date: update the documentation above pub async fn create_index to list the new
Spatial option by adding `spatial` to the allowed attribute types (so it reads
something like "Attributes can be `key`, `fulltext`, `unique`, and `spatial`");
ensure the comment references the DatabasesIndexType enum
(crate::enums::DatabasesIndexType) so future enum additions are obvious.
---
Nitpick comments:
In `@CHANGELOG.md`:
- Line 8: Under the "## [0.2.0] - TBD" changelog entry add a short "Changed" or
"Breaking Changes / Migration" subsection that lists the public API renames and
signature changes and gives one-line migration steps (old name → new name or old
signature → new signature) for each affected symbol; specifically mention any
renamed types or functions and include example mappings so SDK consumers know
how to update their code. Ensure the subsection sits directly beneath the 0.2.0
header and uses concise bullet points or short lines for each change.
In `@src/client.rs`:
- Around line 92-96: Replace the hard-coded "0.2.0" with the crate version from
Cargo metadata and reuse it: create a single SDK version value (e.g., a const or
local binding using env!("CARGO_PKG_VERSION")) and use that variable in the
headers.insert calls for "user-agent" and "x-sdk-version" (the existing headers
variable and the headers.insert(...) calls for "user-agent" and "x-sdk-version"
are the exact locations to update).
- Around line 619-623: Add a regression test that verifies the single-part
upload branch (when file_size <= chunk_size) constructs the HTTP request to POST
to "{endpoint}{path}" and not the chunk upload URL even if an upload_id is
provided; target the code paths around file_size, chunk_size and the
single_file_upload method in client.rs, mocking or intercepting the outgoing
request to assert the request method/URL and that headers (including any
x-appwrite-id if present) and params are set as expected; place the test
alongside existing storage client tests and ensure it covers the case where
callers (e.g., storage service code) pass upload_id but the client still
performs a single-file POST to the base path.
In `@src/enums/template_reference_type.rs`:
- Around line 6-9: The change makes Commit the enum default for
TemplateReferenceType; add unit tests that pin this behavior and the string
mappings: create tests (e.g., test_default_template_reference_type and
test_template_reference_type_as_str_and_serde) that assert Default::default() ==
TemplateReferenceType::Commit, that TemplateReferenceType::Commit.as_str() and
TemplateReferenceType::Branch.as_str() return the expected strings, and that
serde serializes/deserializes Branch as "branch" (and Commit to its expected
value) to prevent regressions in the Default/as_str/serde mappings.
In `@src/services/backups.rs`:
- Around line 39-43: create_archive currently accepts services:
Vec<crate::enums::BackupServices> and allows an empty vector; add an early
validation at the top of create_archive that returns a client-side Err when
services.is_empty() with a clear message (e.g. "at least one backup service
required") before any HTTP calls; apply the same empty-vector guard to the other
public methods in this file that take services:
Vec<crate::enums::BackupServices> so they likewise fail fast and return the same
client error rather than proceeding with an empty services list.
In `@src/services/project.rs`:
- Around line 81-104: In update_variable, add a local precondition that if none
of key/value/secret were provided (i.e., params.is_empty()) the function returns
an immediate SDK error instead of making the network call; locate the
update_variable function and after building params check params.is_empty() and
return an appropriate Err(crate::error::Result::Err(...) or a suitable
crate::error::Error variant with a clear message like "no fields provided for
update") so callers receive a clear, local validation error rather than a
server-side validation failure.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 10c8f776-2fc7-4f76-b0de-cb39a113b1e1
📒 Files selected for processing (26)
CHANGELOG.mdCargo.tomlREADME.mdsrc/client.rssrc/enums/backup_services.rssrc/enums/build_runtime.rssrc/enums/database_type.rssrc/enums/databases_index_type.rssrc/enums/mod.rssrc/enums/runtime.rssrc/enums/scopes.rssrc/enums/tables_db_index_type.rssrc/enums/template_reference_type.rssrc/lib.rssrc/models/attribute_list.rssrc/models/collection.rssrc/models/column_list.rssrc/models/table.rssrc/services/avatars.rssrc/services/backups.rssrc/services/databases.rssrc/services/functions.rssrc/services/health.rssrc/services/mod.rssrc/services/project.rssrc/services/tables_db.rs
💤 Files with no reviewable changes (3)
- src/services/health.rs
- src/enums/build_runtime.rs
- src/enums/runtime.rs
This PR contains updates to the Rust SDK for version 0.2.0.
Summary by CodeRabbit
Release Notes - Version 0.2.0
New Features
Updates