Skip to content

feat: React Native SDK update for version 0.20.0#82

Merged
abnegate merged 2 commits intomainfrom
dev
Feb 2, 2026
Merged

feat: React Native SDK update for version 0.20.0#82
abnegate merged 2 commits intomainfrom
dev

Conversation

@ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Feb 2, 2026

This PR contains updates to the React Native SDK for version 0.20.0.

Summary by CodeRabbit

  • New Features

    • Channel API for type-safe resource path construction
    • BrowserPermission and Roles enums for typed permissions/roles
    • JSON BigInt support for large-number handling
    • Query enhancements: regex, exists/notExists, elemMatch
    • ImageFormat replaces previous output enum; avatar APIs updated
  • API Changes

    • createJWT accepts optional duration
    • upsert operations accept optional data
    • File metadata includes encryption and compression fields
    • Endpoint validation added
  • Chores

    • CI updated to Node.js 22.x with improved OIDC/npm handling

@coderabbitai
Copy link

coderabbitai bot commented Feb 2, 2026

Walkthrough

Release 0.20.0 introduces a typed Channel class for building hierarchical resource paths; adds enums BrowserPermission and Roles; removes the Output enum; integrates json-bigint and bignumber.js with JSONbig-based parsing/stringifying throughout client and Query code (including WebSocket and HTTP payloads); extends Query types and adds helpers (regex, exists, notExists, elemMatch, bigint support); adjusts Account.createJWT to accept duration overloads; makes upsertDocument data optional; replaces various string[]/Output uses with the new enums across Avatars and Teams; updates rollup, package.json, docs, CI workflow, changelog, and versioning.

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 0.00% 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 PR title accurately describes the main objective of the changeset: a React Native SDK update for version 0.20.0, which is clearly demonstrated by version bumps, CHANGELOG entries, and multiple API enhancements across the codebase.

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

✨ Finishing touches
🧪 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: 4

🤖 Fix all issues with AI agents
In @.github/workflows/publish.yml:
- Around line 42-43: The "Publish" step running `npm publish --provenance
--access public --tag ${{ steps.release_tag.outputs.tag }}` is missing the
NODE_AUTH_TOKEN environment variable so npm cannot authenticate; update the
"Publish" step to set env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} (or
whatever secret holds your npm token) so npm picks up the token at runtime, and
ensure the corresponding repository secret (e.g., NPM_TOKEN) exists in GitHub
Secrets; keep the step name "Publish" and the publish command unchanged.

In `@src/client.ts`:
- Around line 12-25: The reviver currently converts non-integer BigNumber values
to a JavaScript Number via value.toNumber(), which can lose precision for
large-decimal values; change reviver (the function named reviver using
BigNumber.isBigNumber) to avoid calling toNumber() for non-integers when
precision would be lost — either return the original BigNumber instance or
return a string (e.g., value.toFixed()) instead; implement this by checking
magnitude/precision before toNumber() (or simply never call toNumber() for
non-integers) so only safe integer values are converted to Number using the
existing MIN_SAFE/MAX_SAFE logic and non-integers are preserved as BigNumber or
string.

In `@src/services/account.ts`:
- Around line 297-307: The falsy check in createJWT prevents a positional call
createJWT(0) from being treated as a numeric duration; change the conditional
that currently uses !paramsOrFirst to explicitly check for null/undefined (e.g.,
paramsOrFirst == null or paramsOrFirst === undefined || paramsOrFirst === null)
so numeric 0 is accepted, and preserve the existing branch that treats objects
as param maps; update the logic around paramsOrFirst in createJWT to assign
params correctly when a number (including 0) is passed versus when an object is
passed.

In `@src/services/teams.ts`:
- Line 8: Docs for createMembership and updateMembership incorrectly claim "A
role can be any string" despite the parameter type being Roles[]; update the
documentation for the methods createMembership and updateMembership (and similar
doc blocks around the other noted ranges) to list the allowed values from the
Roles enum (admin, developer, owner) or otherwise state that roles must be one
of Roles enum members, ensuring the docs match the Roles enum constraint used in
the method signatures.
🧹 Nitpick comments (4)
src/services/storage.ts (1)

292-295: Minor inconsistency in bucketId parameter description.

The bucketId description was shortened to "Bucket unique ID." while all other methods in this file use the longer format: "Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration."

Consider keeping the description consistent with other methods for a uniform developer experience:

📝 Suggested fix for consistency
-     * `@param` {string} params.bucketId - Bucket unique ID.
+     * `@param` {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).

(Apply similarly to the deprecated overload at line 303.)

Also applies to: 303-306

rollup.config.js (1)

22-31: Consider adding sourcemap: true for consistency with other output formats.

The CJS and ES module outputs both include sourcemap: true, but the IIFE output does not. Adding sourcemaps would help with debugging in browser environments.

♻️ Proposed fix
         {
             format: "iife",
             file: pkg.jsdelivr,
             name: "Appwrite",
             extend: true,
             globals: {
                 "json-bigint": "JSONbig",
                 "bignumber.js": "BigNumber",
             },
+            sourcemap: true,
         },
docs/examples/account/create-jwt.md (1)

9-11: Consider using a more practical example value for duration.

A duration of 0 may confuse users as it implies immediate expiration. Consider using a more realistic value (e.g., 3600 for 1 hour) or omitting the optional parameter entirely to show the default behavior.

package.json (1)

36-41: Consider using a consistent version pinning strategy.

json-bigint is pinned to an exact version (1.0.0, which is its only available version), while bignumber.js uses a caret range (^9.0.0, allowing updates up to the latest 9.3.1). To ensure consistent and predictable builds, decide whether to use exact pinning for all dependencies or allow version ranges consistently.

Comment on lines 42 to +43
- name: Publish
run: npm publish --tag ${{ steps.release_tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_NO_ORG }}
run: npm publish --provenance --access public --tag ${{ steps.release_tag.outputs.tag }}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Missing NODE_AUTH_TOKEN environment variable for npm authentication.

The publish step requires the NODE_AUTH_TOKEN environment variable to authenticate with the npm registry. Without it, the publish will fail with an authentication error.

🐛 Proposed fix
     - name: Publish
       run: npm publish --provenance --access public --tag ${{ steps.release_tag.outputs.tag }}
+      env:
+        NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
📝 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
- name: Publish
run: npm publish --tag ${{ steps.release_tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_NO_ORG }}
run: npm publish --provenance --access public --tag ${{ steps.release_tag.outputs.tag }}
- name: Publish
run: npm publish --provenance --access public --tag ${{ steps.release_tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
🤖 Prompt for AI Agents
In @.github/workflows/publish.yml around lines 42 - 43, The "Publish" step
running `npm publish --provenance --access public --tag ${{
steps.release_tag.outputs.tag }}` is missing the NODE_AUTH_TOKEN environment
variable so npm cannot authenticate; update the "Publish" step to set env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} (or whatever secret holds your npm
token) so npm picks up the token at runtime, and ensure the corresponding
repository secret (e.g., NPM_TOKEN) exists in GitHub Secrets; keep the step name
"Publish" and the publish command unchanged.

Comment on lines +12 to +25
function reviver(_key: string, value: any): any {
if (BigNumber.isBigNumber(value)) {
if (value.isInteger()) {
const str = value.toFixed();
const bi = BigInt(str);
if (bi >= MIN_SAFE && bi <= MAX_SAFE) {
return Number(str);
}
return bi;
}
return value.toNumber();
}
return value;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Potential precision loss for large non-integer values.

The reviver converts non-integer BigNumber values to Number via toNumber() (line 22). For decimal values exceeding JavaScript's Number precision (~15-17 significant digits), this could silently lose precision. Consider whether this is acceptable for your use case, or if such values should remain as BigNumber instances.

🤖 Prompt for AI Agents
In `@src/client.ts` around lines 12 - 25, The reviver currently converts
non-integer BigNumber values to a JavaScript Number via value.toNumber(), which
can lose precision for large-decimal values; change reviver (the function named
reviver using BigNumber.isBigNumber) to avoid calling toNumber() for
non-integers when precision would be lost — either return the original BigNumber
instance or return a string (e.g., value.toFixed()) instead; implement this by
checking magnitude/precision before toNumber() (or simply never call toNumber()
for non-integers) so only safe integer values are converted to Number using the
existing MIN_SAFE/MAX_SAFE logic and non-integers are preserved as BigNumber or
string.

Comment on lines +297 to +307
createJWT(
paramsOrFirst?: { duration?: number } | number
): Promise<Models.Jwt> {
let params: { duration?: number };

if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
params = (paramsOrFirst || {}) as { duration?: number };
} else {
params = {
duration: paramsOrFirst as number
};
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

Fix falsy check so positional createJWT(0) is honored.

!paramsOrFirst treats 0 as “no params,” so duration never reaches the payload. Use an undefined/null check instead.

✅ Suggested fix
-        if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
+        if (typeof paramsOrFirst === 'undefined' || paramsOrFirst === null || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
             params = (paramsOrFirst || {}) as { duration?: number };
         } else {
📝 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
createJWT(
paramsOrFirst?: { duration?: number } | number
): Promise<Models.Jwt> {
let params: { duration?: number };
if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
params = (paramsOrFirst || {}) as { duration?: number };
} else {
params = {
duration: paramsOrFirst as number
};
createJWT(
paramsOrFirst?: { duration?: number } | number
): Promise<Models.Jwt> {
let params: { duration?: number };
if (typeof paramsOrFirst === 'undefined' || paramsOrFirst === null || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
params = (paramsOrFirst || {}) as { duration?: number };
} else {
params = {
duration: paramsOrFirst as number
};
🤖 Prompt for AI Agents
In `@src/services/account.ts` around lines 297 - 307, The falsy check in createJWT
prevents a positional call createJWT(0) from being treated as a numeric
duration; change the conditional that currently uses !paramsOrFirst to
explicitly check for null/undefined (e.g., paramsOrFirst == null or
paramsOrFirst === undefined || paramsOrFirst === null) so numeric 0 is accepted,
and preserve the existing branch that treats objects as param maps; update the
logic around paramsOrFirst in createJWT to assign params correctly when a number
(including 0) is passed versus when an object is passed.

import * as FileSystem from 'expo-file-system';
import { Platform } from 'react-native';

import { Roles } from '../enums/roles';
Copy link

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

🏁 Script executed:

cat -n src/enums/roles.ts

Repository: appwrite/sdk-for-react-native

Length of output: 200


🏁 Script executed:

sed -n '1,30p' src/services/teams.ts

Repository: appwrite/sdk-for-react-native

Length of output: 1879


🏁 Script executed:

sed -n '370,425p' src/services/teams.ts

Repository: appwrite/sdk-for-react-native

Length of output: 5430


🏁 Script executed:

sed -n '530,570p' src/services/teams.ts

Repository: appwrite/sdk-for-react-native

Length of output: 2528


🏁 Script executed:

rg -i "dynamic.*role|custom.*role|role.*string" --type ts -A 2 -B 2

Repository: appwrite/sdk-for-react-native

Length of output: 9609


🏁 Script executed:

grep -r "Roles\." src/ --include="*.ts" | head -20

Repository: appwrite/sdk-for-react-native

Length of output: 55


Update docs to match Roles enum constraint: membership roles are limited to 'admin', 'developer', 'owner'.

The createMembership and updateMembership methods have conflicting documentation. The parameter type is Roles[] (a fixed enum with only three values), but the docs state "A role can be any string." Either update the docs to list the valid enum values, or widen the type to string[] for consistency with the create() method.

The original suggestion to use "Roles helpers for dynamic role strings" is inaccurate—Roles is an enum with fixed values, not a dynamic helper.

✏️ Suggested doc correction (assumes enum is intentional)
-     * `@param` {Roles[]} params.roles - Array of strings. Use this param to set the user roles in the team. A role can be any string.
+     * `@param` {Roles[]} params.roles - Array of Roles. Valid values: 'admin', 'developer', 'owner'.
...
-     * `@param` {Roles[]} roles - Array of strings. Use this param to set the user roles in the team. A role can be any string.
+     * `@param` {Roles[]} roles - Array of Roles. Valid values: 'admin', 'developer', 'owner'.
...
-     * `@param` {Roles[]} params.roles - An array of strings. Use this param to set the user's roles in the team. A role can be any string.
+     * `@param` {Roles[]} params.roles - An array of Roles. Valid values: 'admin', 'developer', 'owner'.
...
-     * `@param` {Roles[]} roles - An array of strings. Use this param to set the user's roles in the team. A role can be any string.
+     * `@param` {Roles[]} roles - An array of Roles. Valid values: 'admin', 'developer', 'owner'.

Also applies to: 374-419, 533-565

🤖 Prompt for AI Agents
In `@src/services/teams.ts` at line 8, Docs for createMembership and
updateMembership incorrectly claim "A role can be any string" despite the
parameter type being Roles[]; update the documentation for the methods
createMembership and updateMembership (and similar doc blocks around the other
noted ranges) to list the allowed values from the Roles enum (admin, developer,
owner) or otherwise state that roles must be one of Roles enum members, ensuring
the docs match the Roles enum constraint used in the method signatures.

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

🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Around line 3-8: Update the changelog to include all missing breaking changes
and new features: add a note that JSON parsing was switched to json-bigint with
bignumber.js and describe impact on WebSocket/HTTP/Query payloads; list added
Query helpers and bigint support (regex, exists, notExists, elemMatch); document
API signature changes for Account.createJWT (duration overloads) and that
upsertDocument's data parameter is now optional; add the new Roles enum to the
enums section and clarify that Output was removed in favor of ImageFormat (in
addition to the existing BrowserPermission mention). Ensure each item references
the exact symbols (json-bigint, bignumber.js, regex, exists, notExists,
elemMatch, Account.createJWT, upsertDocument, Roles, BrowserPermission, Output
-> ImageFormat) so users can find related code and migration steps.

Comment on lines +3 to +8
## 0.20.0

* Add array-based enum parameters (e.g., `permissions: BrowserPermission[]`).
* Breaking change: `Output` enum has been removed; use `ImageFormat` instead.
* Add `Channel` helpers for Realtime.

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

Changelog is incomplete—several significant changes are missing.

The AI summary indicates this release includes multiple important changes not documented in the changelog:

  1. JSON parsing changes: Integration of json-bigint and bignumber.js affects how JSON payloads are parsed/stringified throughout the SDK (WebSocket, HTTP, Query).
  2. Query enhancements: New helper methods (regex, exists, notExists, elemMatch) and bigint support.
  3. API signature changes:
    • Account.createJWT now accepts duration overloads
    • upsertDocument data parameter is now optional
  4. Additional enum: Roles enum was added but only BrowserPermission is mentioned.

Users upgrading need complete documentation of all features and breaking changes to understand the full scope of changes and migration requirements.

📝 Suggested additions to the changelog
 ## 0.20.0
 
 * Add array-based enum parameters (e.g., `permissions: BrowserPermission[]`).
+* Add `Roles` enum for role-based permissions.
 * Breaking change: `Output` enum has been removed; use `ImageFormat` instead.
 * Add `Channel` helpers for Realtime.
+* Add `Query` helper methods: `regex`, `exists`, `notExists`, `elemMatch` with bigint support.
+* Update `Account.createJWT` to accept duration parameter.
+* Update `upsertDocument` to make data parameter optional.
+* Integrate `json-bigint` and `bignumber.js` for handling large integers in JSON payloads.
📝 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
## 0.20.0
* Add array-based enum parameters (e.g., `permissions: BrowserPermission[]`).
* Breaking change: `Output` enum has been removed; use `ImageFormat` instead.
* Add `Channel` helpers for Realtime.
## 0.20.0
* Add array-based enum parameters (e.g., `permissions: BrowserPermission[]`).
* Add `Roles` enum for role-based permissions.
* Breaking change: `Output` enum has been removed; use `ImageFormat` instead.
* Add `Channel` helpers for Realtime.
* Add `Query` helper methods: `regex`, `exists`, `notExists`, `elemMatch` with bigint support.
* Update `Account.createJWT` to accept duration parameter.
* Update `upsertDocument` to make data parameter optional.
* Integrate `json-bigint` and `bignumber.js` for handling large integers in JSON payloads.
🤖 Prompt for AI Agents
In `@CHANGELOG.md` around lines 3 - 8, Update the changelog to include all missing
breaking changes and new features: add a note that JSON parsing was switched to
json-bigint with bignumber.js and describe impact on WebSocket/HTTP/Query
payloads; list added Query helpers and bigint support (regex, exists, notExists,
elemMatch); document API signature changes for Account.createJWT (duration
overloads) and that upsertDocument's data parameter is now optional; add the new
Roles enum to the enums section and clarify that Output was removed in favor of
ImageFormat (in addition to the existing BrowserPermission mention). Ensure each
item references the exact symbols (json-bigint, bignumber.js, regex, exists,
notExists, elemMatch, Account.createJWT, upsertDocument, Roles,
BrowserPermission, Output -> ImageFormat) so users can find related code and
migration steps.

@abnegate abnegate merged commit d2a9159 into main Feb 2, 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