feat: add all missing SDK methods for full API coverage#33
feat: add all missing SDK methods for full API coverage#33Divyansha23 wants to merge 3 commits intomasterfrom
Conversation
- Modernized all API calls to use latest object-based parameter syntax - Refactored config to use environment variables (APPWRITE_ENDPOINT, APPWRITE_PROJECT_ID, APPWRITE_API_KEY) Databases: - Added all attribute types: boolean, float, datetime, email, enum, IP, URL, point, line, polygon - Added getAttribute, update/delete for all attribute types (including geo/spatial) - Added getIndex, deleteIndex - Added bulk operations: createDocuments, upsertDocument, upsertDocuments, updateDocuments, deleteDocuments - Added atomic operations: incrementDocumentAttribute, decrementDocumentAttribute - Added relationship attributes: createRelationshipAttribute, updateRelationshipAttribute - Added transactions API: createTransaction, getTransaction, listTransactions, createOperations, updateTransaction (commit/rollback), deleteTransaction TablesDB: - Added full CRUD: create/list/get/update databases, tables, columns, indexes, rows - Added all column types: string, integer, float, boolean, datetime, email, enum, IP, URL, point, line, polygon - Added update methods for all column types - Added bulk row operations: createRows, upsertRow, upsertRows, updateRows, deleteRows - Added atomic row operations: incrementRowColumn, decrementRowColumn - Added TablesDB transactions: createTransaction, getTransaction, listTransactions, createOperations, updateTransaction (commit/rollback), deleteTransaction - Added deleteColumn, deleteIndex, deleteTable, deleteDatabase Storage: - Added getFileDownload, getFilePreview, getFileView Functions: - Added listRuntimes, listSpecifications - Added deleteDeployment, deleteExecution, getDeploymentDownload - Added updateFunctionDeployment, updateDeploymentStatus - Added createDuplicateDeployment, createTemplateDeployment, createVcsDeployment Users: - Added updateEmail, updatePassword, updatePhone, updateStatus, updateLabels - Added listLogs, listMemberships, listSessions, createSession, deleteSessions - Added updateEmailVerification, updatePhoneVerification - Added listIdentities, deleteIdentity - Added MFA methods: updateMFA, listMFAFactors, createMFARecoveryCodes, getMFARecoveryCodes, updateMFARecoveryCodes, deleteMFAAuthenticator - Added legacy MFA aliases (lowercase variants) - Added targets: createTarget, getTarget, listTargets, updateTarget, deleteTarget - Added createJWT, createToken - Added hash-based user creation: createArgon2User, createBcryptUser, createMD5User, createSHAUser, createPHPassUser, createScryptUser, createScryptModifiedUser Bug fixes: - Fixed updateDatetimeAttribute/Column requiring xdefault parameter - Fixed bulk document structure (fields at top level, not nested in data) - Fixed createOperations using documentId instead of $id - Fixed user labels to use alphanumeric-only values - Wrapped scope-restricted APIs (listRuntimes, listSpecifications, account.get) in try/catch
WalkthroughThe PR significantly expands the Playground: it adds three imports (RelationshipType, RelationMutate, MessagingProviderType), introduces four new globals (secondCollectionId, secondDocumentId, identityId, targetId), and injects a large suite of API handlers across Databases, TablesDB, Storage, Users, and Functions (CRUD, bulk operations, transactions, relationships, targets/JWTs, bucket/file lifecycle, runtimes/specs/deployments). The runAllTasks orchestration is updated to sequence these new calls into comprehensive end-to-end flows. Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 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 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: 1
🧹 Nitpick comments (1)
src/app.js (1)
37-37: Unused variableidentityId.This variable is declared but never assigned or used anywhere in the file. Consider removing it to avoid confusion.
🧹 Proposed fix
let secondCollectionId; let secondDocumentId; -let identityId; let targetId;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app.js` at line 37, Remove the unused variable declaration identityId from the top-level of src/app.js; locate the standalone declaration "let identityId;" (no other references) and delete it so there is no unused variable left declared but never assigned or used.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/app.js`:
- Around line 1102-1108: The log message inside getAccount() is incorrect (it
says "Running List Users API")—update the console.log to a correct, descriptive
message for this function (e.g., "Running Get Account API" or "Running
account.get()") so it matches the operation performed by account.get(); locate
the getAccount function and replace the incorrect string in the console.log
call.
---
Nitpick comments:
In `@src/app.js`:
- Line 37: Remove the unused variable declaration identityId from the top-level
of src/app.js; locate the standalone declaration "let identityId;" (no other
references) and delete it so there is no unused variable left declared but never
assigned or used.
changed log message Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/app.js (1)
35-38:identityIdis declared but never assigned.The global variable
identityIdis declared on line 37 but is never assigned a value anywhere in the code. ThelistUserIdentitiesanddeleteUserIdentityfunctions (lines 1297-1326) don't use this global variable - they fetch identities directly within the function scope.Consider either:
- Removing the unused declaration
- Using it in
listUserIdentitiesto store an identity ID for later use♻️ Proposed fix to remove unused variable
let secondCollectionId; let secondDocumentId; -let identityId; let targetId;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app.js` around lines 35 - 38, Remove the unused top-level variable identityId (declared alongside secondCollectionId/secondDocumentId) or, if it was intended to persist a selected identity, assign it inside listUserIdentities by setting identityId = <the chosen identity id> after fetching identities and then use that global in deleteUserIdentity; update references in listUserIdentities and deleteUserIdentity accordingly so the variable is either removed or actually assigned and consumed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/app.js`:
- Line 593: The assignment to documentId from response.documents[0].$id is
unsafe if the bulk create returns an empty or undefined documents array; update
the code that sets documentId to first verify response &&
Array.isArray(response.documents) && response.documents.length > 0 before
accessing [0].$id, and in the empty/invalid case handle it explicitly (e.g., log
an error via your logger, throw a descriptive error, or return an early failure
response) so downstream code doesn't hit a null reference; look for the
documentId assignment and surrounding response handling to implement this guard.
---
Nitpick comments:
In `@src/app.js`:
- Around line 35-38: Remove the unused top-level variable identityId (declared
alongside secondCollectionId/secondDocumentId) or, if it was intended to persist
a selected identity, assign it inside listUserIdentities by setting identityId =
<the chosen identity id> after fetching identities and then use that global in
deleteUserIdentity; update references in listUserIdentities and
deleteUserIdentity accordingly so the variable is either removed or actually
assigned and consumed.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/app.js (1)
1637-1711: Static analysis false positives - example password hashes, not secrets.Gitleaks flagged lines 1644, 1678, 1700, and 1703 as "Generic API Key" detections. These are actually well-known example password hashes used to demonstrate hash-based user creation APIs:
- Line 1644: SHA1 hash of "hello"
- Line 1678: Example Scrypt hash
- Lines 1700, 1703: Example Scrypt Modified parameters
Since this is a playground/demo repository, these hardcoded examples are intentional for illustrating the SDK's hash import capabilities. Consider adding a brief comment to clarify these are demo values, which may help suppress future static analysis warnings.
📝 Optional: Add clarifying comment
+// Note: The password hashes below are well-known example hashes used for demonstration purposes only. +// They are NOT real secrets - e.g., the SHA1 hash is the hash of "hello". const createSHAUser = async () => { console.log(chalk.greenBright('Running Create SHA User API'));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app.js` around lines 1637 - 1711, These hardcoded password/hash strings in createSHAUser, createPHPassUser, createScryptUser, and createScryptModifiedUser are intentional demo/example values causing static analysis false positives; add a short clarifying comment immediately above each password/passwordSalt/passwordSignerKey property (or above the call in each function) stating these are non-sensitive example hashes used for playground/demo purposes (optionally include a gitleaks suppression tag if your linter supports it) so future reviewers and automated scanners understand they are safe.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/app.js`:
- Around line 1637-1711: These hardcoded password/hash strings in createSHAUser,
createPHPassUser, createScryptUser, and createScryptModifiedUser are intentional
demo/example values causing static analysis false positives; add a short
clarifying comment immediately above each
password/passwordSalt/passwordSignerKey property (or above the call in each
function) stating these are non-sensitive example hashes used for
playground/demo purposes (optionally include a gitleaks suppression tag if your
linter supports it) so future reviewers and automated scanners understand they
are safe.
Databases:
TablesDB:
Storage:
Functions:
Users:
Bug fixes:
What does this PR do?
(Provide a description of what this PR does.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)
Related PRs and Issues
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
Have you read the Contributing Guidelines on issues?
(Write your answer here.)
Summary by CodeRabbit