Skip to content

feat: replace deprecated methods with object-based syntax and add missing API methods#31

Open
Divyansha23 wants to merge 2 commits intomasterfrom
suc-1877/remove-deprecated-methods
Open

feat: replace deprecated methods with object-based syntax and add missing API methods#31
Divyansha23 wants to merge 2 commits intomasterfrom
suc-1877/remove-deprecated-methods

Conversation

@Divyansha23
Copy link
Contributor

@Divyansha23 Divyansha23 commented Feb 11, 2026

Changes

Replace deprecated methods with new methods

  • All SDK method calls updated from positional parameters to the new object-based syntax
  • Fixed parameter names: default to xdefault, path to xpath
  • Replaced string literals with proper enums: Runtime.Node180, ExecutionMethod.GET, IndexType.Key
  • Added IndexType to imports

Add missing methods

  • Databases: listIndexes
  • Storage: getFileDownload, getFilePreview (with graceful fallback)
  • Users: getUserPrefs, updateUserPrefs
  • Functions: updateFunction, listExecutions, createVariable, listVariables, getVariable, updateVariable, deleteVariable

Summary

Total SDK methods demonstrated: 44 to 56

Summary by CodeRabbit

  • Refactor

    • Moved SDK calls to options-object signatures across databases, storage, users, and functions.
  • New Features

    • Added endpoints for list indexes, file download/preview, variables, executions, and deployments.
    • Function runtime now uses ES module export, includes runtime logging, and updates the greeting message.
  • Bug Fixes

    • Improved error messages and handling for deployment readiness, failures, and timeouts.

…sing API methods

- Update all SDK method calls to use new object-based parameter syntax
- Fix parameter names: default -> xdefault, path -> xpath
- Use proper enums: Runtime.Node180, ExecutionMethod.GET, IndexType.Key
- Add IndexType to imports
- Add missing methods:
  - Databases: listIndexes
  - Storage: getFileDownload, getFilePreview (with graceful fallback)
  - Users: getUserPrefs, updateUserPrefs
  - Functions: updateFunction, listExecutions, createVariable,
    listVariables, getVariable, updateVariable, deleteVariable
@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

Walkthrough

The PR migrates Appwrite SDK calls in src/app.js from positional arguments to options-object signatures across Databases, Storage, Users, and Functions APIs, adds the IndexType import, and introduces new API uses (e.g., listIndexes, getFileDownload, getFilePreview, variable/execution/deployment endpoints). Deployment readiness polling and error messages were extended and multiple flows updated to use explicit named fields (functionId, deploymentId, bucketId, fileId, etc.). resources/index.js was converted to an ES module default export, its handler signature now accepts { req, res, log, error }, adds a log call, and updates the response message. Changes total +334/-112 lines.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: replacing deprecated positional-parameter method calls with new object-based syntax and adding missing API method demonstrations. This matches the primary objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch suc-1877/remove-deprecated-methods

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
src/app.js (2)

696-712: Unnecessary sleep after synchronous execution.

createExecution with async: false blocks until the execution completes — the response already contains the result. The 3-second sleep on lines 708–710 is redundant. Not a bug, but misleading in a playground meant to demonstrate SDK usage.

Proposed cleanup
     let response = await functions.createExecution({
         functionId,
         body: "",
         async: false,
         xpath: "/",
         method: ExecutionMethod.GET,
         headers: {}
     });
 
-    // sleep for 3 seconds
-    console.log("Waiting a little to ensure execution is finished ...");
-    await new Promise((resolve) => setTimeout(resolve, 3000));
-
     console.log(response);
 }

561-576: updateFunction duplicates most of createFunction's parameters.

This is fine for a playground, but note that runtime, execute, entrypoint, enabled, and logging are repeated verbatim from createFunction. If these aren't required fields for update, consider omitting them to better demonstrate a minimal update call (just name and timeout changes).

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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: 3

🤖 Fix all issues with AI agents
In `@src/app.js`:
- Around line 379-405: getFileDownload currently calls storage.getFileDownload
without error handling which can throw and abort the run; wrap the body of
getFileDownload in a try/catch like getFilePreview does, calling
storage.getFileDownload inside the try and logging success as before, and in the
catch log a warning (e.g., console.log(chalk.yellow(`Skipped: ${err.message}`)))
so failures are handled consistently between getFileDownload and getFilePreview.
- Around line 695-702: The call to functions.createExecution uses the deprecated
parameter name `xpath`; update the argument object to use `path` instead (keep
the same value "/" and other fields unchanged). Locate the createExecution
invocation (the object with functionId, body, async, xpath, method:
ExecutionMethod.GET, headers) and rename the `xpath` property to `path` so it
matches the node-appwrite v21 signature expected by createExecution.
- Around line 523-532: The code is using the deprecated Runtime.Node180 in the
functions.create call (functionId/ name "Node Hello World"); update the runtime
to a supported newer Node version by replacing Runtime.Node180 with
Runtime.Node200 (Node 20 LTS) or Runtime.Node210 (Node 21) depending on your
environment, and ensure your deployment supports that runtime variant before
changing it.
🧹 Nitpick comments (2)
src/app.js (2)

692-709: Unnecessary sleep after synchronous execution.

The async: false flag means createExecution should block until execution completes and return the full result. The 3-second sleep on line 706 is likely redundant. While this appears to be pre-existing behavior, it adds unnecessary latency to the playground run.

Suggested cleanup
     let response = await functions.createExecution({
         functionId,
         body: "",
         async: false,
         xpath: "/",
         method: ExecutionMethod.GET,
         headers: {}
     });
 
-    // sleep for 3 seconds
-    console.log("Waiting a little to ensure execution is finished ...");
-    await new Promise((resolve) => setTimeout(resolve, 3000));
-
     console.log(response);
 }

791-804: Variable CRUD runs before function execution — intentional?

Variables are created and then fully deleted (lines 797–801) before executeSync / executeAsync (lines 802–803). If the function code ever reads MY_VAR, it won't be available at execution time. For a pure API demonstration this is fine, but reordering to delete the variable after executions would be a more realistic workflow.

Suggested reorder
     await createVariable();
     await listVariables();
     await getVariable();
     await updateVariable();
-    await deleteVariable();
     await executeSync();
     await executeAsync();
     await listExecutions();
+    await deleteVariable();
     await deleteFunction();

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the Appwrite Node.js Playground by upgrading from SDK version 14.0.0 to 21.1.0, replacing the deprecated positional parameter syntax with the new object-based syntax across all API calls, and adding demonstrations of previously missing API methods.

Changes:

  • Upgraded node-appwrite from 14.0.0 to 21.1.0 in package.json and package-lock.json
  • Migrated all SDK method calls from positional parameters to object-based syntax throughout src/app.js
  • Added demonstrations for 12 new API methods: listIndexes, getFileDownload, getFilePreview, getUserPrefs, updateUserPrefs, updateFunction, listExecutions, createVariable, listVariables, getVariable, updateVariable, and deleteVariable
  • Updated function runtime to use ES module syntax (export default) and newer runtime features (log, error parameters) in resources/index.js
  • Fixed parameter names to avoid JavaScript reserved keywords (default → xdefault, path → xpath)
  • Replaced string literals with proper enum constants (IndexType.Key, ExecutionMethod.GET, Runtime.Node200)

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/app.js Migrated all Appwrite SDK calls to object-based syntax, added IndexType import, and added 12 new API method demonstrations including database indexes, file download/preview, user preferences, function updates, executions listing, and complete variable CRUD operations
resources/index.js Updated function runtime code to use ES module export syntax and added log/error parameters for compatibility with newer Node runtimes
package.json Updated node-appwrite dependency from 14.0.0 to ^21.1.0
package-lock.json Updated lock file to reflect node-appwrite 21.1.0 with updated integrity hash and added license field

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const response = await functions.create({
functionId: ID.unique(),
name: "Node Hello World",
runtime: Runtime.Node200,
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The PR description mentions using "Runtime.Node180" but the code uses "Runtime.Node200" on lines 530 and 567. This discrepancy should be clarified - either update the PR description to reflect the actual runtime being used (Node200), or if Node180 was intended, update the code to use the correct runtime constant.

Copilot uses AI. Check for mistakes.
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.

1 participant