Skip to content

Conversation

@abnegate
Copy link
Member

@abnegate abnegate commented Dec 17, 2025

This PR contains updates to the Dart SDK for version 20.0.0.

Summary by CodeRabbit

  • New Features

    • Set a client session during initialization to streamline session-based auth.
    • Create collections with optional attributes and indexes.
    • Create tables with optional columns and indexes.
    • OAuth2 token requests now include session information.
  • Documentation

    • Examples updated to show session configuration in client setup.
  • Chores

    • Package and SDK version bumped to 20.1.0.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 17, 2025

Walkthrough

This pull request updates many Dart example docs to initialize Client with a chained .setSession('') call and adds a new Client.setSession(String) usage. Account.createOAuth2Token now includes a 'session' param from client.config. Databases.createCollection gained optional parameters attributes and indexes and serializes them into the request body. TablesDB.createTable gained optional parameters enabled, columns, and indexes and includes columns/indexes in the request payload. SDK package version, telemetry/user-agent headers, CHANGELOG, README, and pubspec.yaml were bumped to 20.1.0. Several examples were edited to reflect the new Client chaining.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • lib/services/databases.dart: verify new parameters (attributes, indexes) are serialized correctly, types nullable/optional handling, and backward compatibility.
  • lib/services/tables_db.dart: verify columns/indexes serialization and enabled handling.
  • lib/services/account.dart: confirm adding 'session': client.config['session'] handles null/empty safely and matches expected query behavior.
  • lib/src/client_io.dart and lib/src/client_browser.dart: check telemetry/user-agent header updates.
  • Public API surface: review addition/usage of Client.setSession(String) and examples for consistency with client implementation.
  • Docs/CHANGELOG/README/pubspec.yaml: confirm examples and version bump are consistent.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title claims version 20.0.0 but the actual changes update the SDK to version 20.1.0, making the title inaccurate. Update the title to reflect the correct version number: 'feat: Dart SDK update for version 20.1.0' or similar.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 72ece9a and 33df2db.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
🔇 Additional comments (2)
CHANGELOG.md (2)

3-5: Verify version consistency: PR mentions 20.0.0 but CHANGELOG shows 20.1.0.

The PR title references version 20.0.0, but this CHANGELOG section is titled 20.1.0. Ensure that all version references across the repository (pubspec.yaml, lib/src/client_browser.dart, lib/src/client_io.dart, README.md) consistently use the intended version number.


5-5: CHANGELOG entry may be incomplete.

Based on the AI summary, this PR includes multiple features: Client.setSession() capability, Account.createOAuth2Token session parameter, and Databases.createCollection optional parameters. The CHANGELOG currently only documents the TablesDB.createTable feature. Consider adding entries for the other notable changes to give users a complete picture of what's new in 20.1.0.


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

♻️ Duplicate comments (8)
docs/examples/account/update-phone-session.md (1)

5-6: Verify empty string semantics for setSession.

This example follows the same pattern as other account examples in this PR, adding .setSession('') to the Client initialization chain. The concern about empty string semantics applies here as well.

See the verification request in docs/examples/account/create-mfa-challenge.md for details on confirming the intended usage pattern.

docs/examples/account/create-anonymous-session.md (1)

5-6: Verify empty string semantics for setSession.

This example demonstrates the same Client initialization pattern with .setSession('') that appears consistently across all account examples in this PR.

The same verification applies: confirm whether an empty string is the correct way to indicate no session, or if the call should be omitted when no session is available. See verification request in docs/examples/account/create-mfa-challenge.md.

docs/examples/account/create-email-token.md (1)

5-6: Consistent pattern across documentation examples.

This file follows the same changes as the other account examples (adding .setSession('')). The same documentation clarity recommendation applies here.

docs/examples/account/update-magic-url-session.md (1)

5-6: Consistent with other documentation updates in this PR.

This file applies the same .setSession('') pattern. The documentation clarity recommendations from earlier comments apply here as well.

docs/examples/account/create-jwt.md (1)

5-6: Consistent with other documentation updates in this PR.

This file applies the same .setSession('') pattern. The documentation clarity recommendations from earlier comments apply here as well.

docs/examples/account/create-o-auth-2-token.md (1)

5-6: Consistent with other documentation updates in this PR.

This file applies the same .setSession('') pattern. The documentation clarity recommendations from earlier comments apply here as well.

docs/examples/account/create.md (1)

5-6: Consistent with other documentation updates in this PR.

This file applies the same .setSession('') pattern. The documentation clarity recommendations from earlier comments apply here as well.

docs/examples/account/create-email-password-session.md (1)

5-6: Consistent with other documentation updates in this PR.

This file applies the same .setSession('') pattern. The documentation clarity recommendations from earlier comments apply here as well.

🧹 Nitpick comments (2)
docs/examples/account/create-magic-url-token.md (1)

5-6: Consider clarifying empty session usage in documentation example.

The .setSession('') pattern appears throughout official Appwrite Dart SDK documentation, but for better clarity in end-user documentation, the comment could explicitly indicate this is a placeholder:

- .setSession(''); // The user session to authenticate with
+ .setSession(''); // Replace with actual user session ID

This would help developers understand that the empty string is a template placeholder, not the intended runtime value.

docs/examples/account/create-phone-token.md (1)

5-6: Clarify the session placeholder in the example.

The .setSession('') method is shown with an empty string, which may confuse developers about the intended usage. The inline comment suggests it should contain "The user session to authenticate with", yet the example demonstrates an empty value.

Consider one of the following approaches:

  • Replace the empty string with a more realistic placeholder like '<USER_SESSION>' to make the intent clearer.
  • Add an explanatory comment explaining that this is a placeholder and developers should substitute their actual session token.

Applied change example:

 Client client = Client()
     .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
     .setProject('<YOUR_PROJECT_ID>') // Your project ID
-    .setSession(''); // The user session to authenticate with
+    .setSession('<USER_SESSION>'); // Replace with actual user session

Alternatively, if empty session is the intended initialization pattern:

     .setSession(''); // Initialize with session support (replace '' with actual session token when available)
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0692d2 and 6caad4c.

📒 Files selected for processing (17)
  • docs/examples/account/create-anonymous-session.md (1 hunks)
  • docs/examples/account/create-email-password-session.md (1 hunks)
  • docs/examples/account/create-email-token.md (1 hunks)
  • docs/examples/account/create-jwt.md (1 hunks)
  • docs/examples/account/create-magic-url-token.md (1 hunks)
  • docs/examples/account/create-mfa-challenge.md (1 hunks)
  • docs/examples/account/create-o-auth-2-token.md (1 hunks)
  • docs/examples/account/create-phone-token.md (1 hunks)
  • docs/examples/account/create-session.md (1 hunks)
  • docs/examples/account/create.md (1 hunks)
  • docs/examples/account/update-magic-url-session.md (1 hunks)
  • docs/examples/account/update-phone-session.md (1 hunks)
  • docs/examples/databases/create-collection.md (1 hunks)
  • docs/examples/tablesdb/create-table.md (1 hunks)
  • lib/services/account.dart (1 hunks)
  • lib/services/databases.dart (2 hunks)
  • lib/services/tables_db.dart (2 hunks)
🔇 Additional comments (9)
docs/examples/tablesdb/create-table.md (1)

19-20: LGTM! New optional parameters for table creation.

The addition of columns and indexes parameters allows defining table schema at creation time, reducing the need for subsequent API calls. The empty array defaults are appropriate for demonstration purposes.

lib/services/databases.dart (2)

262-264: LGTM! API extended to support schema definition at creation.

The method signature correctly adds attributes and indexes as optional parameters.


274-275: LGTM! Parameters conditionally included in request payload.

The implementation properly checks for null values before including attributes and indexes in the API request.

docs/examples/databases/create-collection.md (1)

19-20: LGTM! Documentation updated to reflect new API parameters.

The example correctly demonstrates the new optional attributes and indexes parameters. The empty arrays serve as placeholders; developers should populate these with actual attribute and index definitions when needed.

lib/services/tables_db.dart (2)

246-248: LGTM! Method signature extended with schema definition parameters.

The addition of enabled, columns, and indexes as optional parameters allows defining table structure at creation time, consistent with the createCollection pattern in databases.dart.


257-259: LGTM! Parameters properly conditionally included.

The implementation correctly adds the new parameters to the request payload only when they are provided.

docs/examples/account/create-mfa-challenge.md (1)

5-6: The .setSession('') pattern is correct per Appwrite SDK documentation.

The .setSession('') empty string is the standard Appwrite pattern shown in official API examples, used when initializing the client without an active session. This is intentional—the SDK's setSession method authenticates a user when a session exists, or can be initialized without one. The example code is accurate as written.

lib/services/account.dart (1)

1017-1017: Session parameter addition is safe and properly filtered.

The implementation correctly adds the session parameter to OAuth2 token requests. Null values are safely filtered from the query string before transmission (line 79), so if the session is not configured, it won't be included in the request to the backend.

docs/examples/account/create-session.md (1)

5-6: Contextually consistent, but documentation clarity recommendation applies here too.

Like the previous file, the .setSession('') usage follows the same pattern. In this specific example (creating a session), the empty string is semantically sensible—no session exists before creation. However, the documentation should still clarify this relationship.

The pattern is consistent with the rest of the PR. If the same empty-string pattern is used across all examples, ensure the documentation or inline comments make it clear to users whether they should:

  1. Use empty string when no session exists (pre-authentication flow)
  2. Pass their actual session ID when using authenticated endpoints

@abnegate abnegate merged commit ca7fbf9 into main Dec 18, 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.

3 participants