feat: React Native SDK update for version 0.20.0#83
Conversation
WalkthroughThis pull request applies consistent formatting updates across 70+ documentation examples by wrapping code snippets in JavaScript code fences and enhancing examples with client configuration (setEndpoint and setProject calls). Additionally, the IIFE (immediately-invoked function expression) build output format is removed from the Rollup configuration, leaving only CommonJS and ES module formats. Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (7)
docs/examples/databases/increment-document-attribute.md (1)
10-18:⚠️ Potential issue | 🟡 MinorUse a concrete placeholder for
attributeinstead of an empty string.An empty string is ambiguous in docs and can confuse readers. Consider using a placeholder like
<ATTRIBUTE>to make the example actionable.✏️ Suggested doc tweak
- attribute: '', + attribute: '<ATTRIBUTE>',docs/examples/account/update-push-target.md (1)
1-15:⚠️ Potential issue | 🟡 MinorWrap the example in an async function to avoid top‑level await pitfalls.
Some environments won’t allow top‑level
await, and docs should be copy‑paste safe. Consider an async IIFE wrapper for this snippet.✅ Suggested doc-safe wrapper
-const result = await account.updatePushTarget({ - targetId: '<TARGET_ID>', - identifier: '<IDENTIFIER>' -}); - -console.log(result); +(async () => { + const result = await account.updatePushTarget({ + targetId: '<TARGET_ID>', + identifier: '<IDENTIFIER>' + }); + + console.log(result); +})();docs/examples/account/get-mfa-recovery-codes.md (1)
4-12:⚠️ Potential issue | 🟡 MinorWrap the
awaitcall in an async context (Line 10).
Top‑levelawaitisn’t valid in many JS runtimes and may confuse copy‑paste usage.✅ Suggested doc-safe wrapper
-const result = await account.getMFARecoveryCodes(); - -console.log(result); +;(async () => { + const result = await account.getMFARecoveryCodes(); + console.log(result); +})();docs/examples/account/create.md (1)
10-15:⚠️ Potential issue | 🟡 MinorUse a non-empty password placeholder in the example.
The
passwordfield requires 8–256 characters and cannot be an empty string. Replacepassword: ''with a placeholder like'<PASSWORD>'to prevent validation errors on copy-paste.docs/examples/tablesdb/upsert-row.md (1)
21-21:⚠️ Potential issue | 🔴 CriticalCritical syntax error in permissions parameter.
The permissions array contains a syntax error with unescaped quotes. The string
"read("any")"inside the double-quoted context will cause a JavaScript syntax error because the inner double quotes prematurely terminate the string.🐛 Proposed fix for the syntax error
- permissions: ["read("any")"], // optional + permissions: ['read("any")'], // optionaldocs/examples/account/update-phone.md (1)
10-15:⚠️ Potential issue | 🔴 CriticalWrap top-level
awaitin async function—code will not execute as written.The
awaitkeyword on line 10 requires an async function context. This example usesawaitwithout wrapping, which will throw a syntax error. Out of 108 documentation examples (89% of all examples), this pattern is applied consistently without async context or explanation.🔧 Proposed fix
const account = new Account(client); -const result = await account.updatePhone({ - phone: '+12065550100', - password: 'password' -}); - -console.log(result); +(async () => { + const result = await account.updatePhone({ + phone: '+12065550100', + password: 'password' + }); + + console.log(result); +})();Alternatively, revert to promise chains (
.then()) which don't require async context and are already shown in the README examples.docs/examples/storage/update-file.md (1)
10-15:⚠️ Potential issue | 🟠 MajorFix invalid permissions string literal (syntax error).
["read("any")"]is invalid JavaScript and will break the example. Use the importedPermissionandRolehelpers instead.✅ Proposed fix
- permissions: ["read("any")"] // optional + permissions: [Permission.read(Role.any())] // optional
🧹 Nitpick comments (5)
docs/examples/messaging/delete-subscriber.md (1)
2-16: Clear example with proper formatting.The code example clearly demonstrates the
deleteSubscriberAPI usage with all required parameters. The closing code fence completes the proper Markdown formatting.Optional: Consider adding async context note.
The example uses
awaitwithout showing the async function wrapper. While this is common in SDK documentation, you might consider adding a brief note or wrapping the example in an async function to make it immediately runnable:💡 Optional enhancement for clarity
```javascript import { Client, Messaging } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint .setProject('<YOUR_PROJECT_ID>'); // Your project ID const messaging = new Messaging(client); -const result = await messaging.deleteSubscriber({ - topicId: '<TOPIC_ID>', - subscriberId: '<SUBSCRIBER_ID>' -}); - -console.log(result); +async function deleteSubscriber() { + const result = await messaging.deleteSubscriber({ + topicId: '<TOPIC_ID>', + subscriberId: '<SUBSCRIBER_ID>' + }); + + console.log(result); +} ```docs/examples/account/create-email-token.md (1)
2-16: Consider showing async context and error handling.The example uses
awaitbut doesn't show it within an async function, which might confuse developers copying the code. Additionally, demonstrating error handling would make this a more complete example.📚 Suggested enhancement for the example
import { Client, Account } from "react-native-appwrite"; -const client = new Client() - .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('<YOUR_PROJECT_ID>'); // Your project ID - -const account = new Account(client); - -const result = await account.createEmailToken({ - userId: '<USER_ID>', - email: 'email@example.com', - phrase: false // optional -}); - -console.log(result); +const createToken = async () => { + const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + + const account = new Account(client); + + try { + const result = await account.createEmailToken({ + userId: '<USER_ID>', + email: 'email@example.com', + phrase: false // optional + }); + + console.log(result); + } catch (error) { + console.error('Error creating email token:', error); + } +}; + +createToken();docs/examples/account/list-mfa-factors.md (1)
10-10: Consider clarifying the async context.The example uses
awaitat the top level. In React Native, developers would typically need to wrap this in an async function. Consider adding a brief note or wrapping the example in an async function to make it immediately runnable.📝 Example with async function wrapper
```javascript import { Client, Account } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint .setProject('<YOUR_PROJECT_ID>'); // Your project ID const account = new Account(client); -const result = await account.listMFAFactors(); - -console.log(result); +const listFactors = async () => { + const result = await account.listMFAFactors(); + console.log(result); +}; + +listFactors(); ```docs/examples/tablesdb/decrement-row-column.md (1)
14-15: Consider improving example values for better clarity.The example uses an empty string for
columnand0forvalue, which are not meaningful for demonstrating the decrement functionality. Consider using more realistic placeholder values:
column: '<COLUMN_NAME>'orcolumn: 'count'value: 1(or any non-zero integer)This would make the example more helpful for developers learning the API.
docs/examples/account/create-email-verification.md (1)
1-15: Consider adding async context to the example.The example uses
await(line 10) without showing the surrounding async function or indicating that top-level await is required. Developers copying this code directly will encounter a syntax error.💡 Suggested enhancement for clarity
Wrap the example in an async function or add a comment indicating the async context:
```javascript import { Client, Account } from "react-native-appwrite"; +async function createEmailVerification() { const client = new Client() .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint .setProject('<YOUR_PROJECT_ID>'); // Your project ID const account = new Account(client); const result = await account.createEmailVerification({ url: 'https://example.com' }); console.log(result); +}Alternatively, add a note that the code assumes an async context. </details> **Note:** This comment applies to all documentation examples in this PR that use `await` without visible async wrapping. </blockquote></details> </blockquote></details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
This PR contains updates to the React Native SDK for version 0.20.0.
Summary by CodeRabbit
Documentation
Chores