Skip to content

Conversation

@robertoboero
Copy link

Summary

Migrates the extension from the legacy node-appwrite SDK v2.2.3 to v21.1.0, restoring full compatibility with modern Appwrite instances (tested against Appwrite 1.8.1).

The original codebase targeted an Appwrite version from 2021. This PR brings it up to date with the current Appwrite API, including the Databases service (which replaced the single-database model), updated authentication methods, and the new permission system.

Key changes

  • SDK v2.2.3 → v21.1.0: Updated all service modules (Database, Functions, Storage, Health, Users), client initialization, commands, and tree providers to the new API signatures
  • Databases service: Collections now live under named databases; all operations require databaseId
  • Permissions: Migrated from legacy read/write arrays to the new Permission.read() / Permission.create() / Permission.update() / Permission.delete() format
  • Attributes replace Rules: Removed the legacy createRuleWizard and updated all attribute operations to use the SDK v21 API
  • Project config: Added databaseId and bucketId fields to project configuration for SDK v21 requirements

Bug fixes

  • ES5 class inheritance: Fixed a critical issue where VS Code's TreeItem (compiled as an ES2022 class) caused property loss in ES5-compiled subclasses. Added explicit this.label and public readonly parent assignments to ensure properties survive the _super.call(this, ...) || this pattern
  • Empty tree items: Collections now correctly show Attributes, Permissions, and Documents when expanded
  • Project name: Fixed blank project labels in the Projects tab caused by nullish coalescing (??) not catching empty strings
  • Error handling: Made AppwriteCall error handler defensive with unknown typing and try-catch wrapping

New features

  • Expandable documents: Document tree items are now collapsible — expand to see all fields as key-value pairs
  • Richer project display: Projects show the endpoint URL as description and include a detailed tooltip
  • Updated icons: New extension marketplace icon and sidebar SVG

Commits

# Message Scope
1 chore: update node-appwrite SDK from v2.2.3 to v21.1.0 package.json
2 refactor: update type definitions for SDK v21 appwrite.d.ts
3 refactor: update constants for SDK v21 constants.ts
4 feat: add databaseId and bucketId to project configuration settings.ts
5 refactor: update client initialization for SDK v21 client.ts
6 refactor: Update all service modules for SDK v21 appwrite/*.ts
7 refactor: Update tree providers for SDK v21 tree/**/*.ts
8 refactor: Update commands for SDK v21 commands/**/*.ts
9 fix: resolve TypeScript compilation errors and remove legacy code various
10 fix: add defensive guards and improve error handling AppwriteCall, Functions, Users
11 fix: resolve ES5 class inheritance issues with TreeItem properties AppwriteTreeItemBase, ChildTreeItem, tree items
12 feat: make document tree items expandable with field details DocumentTreeItem
13 fix: show project name and endpoint in Projects tab ProjectTreeItem
14 chore: update build config, icons, and remove legacy code webpack, package.json, resources

Test plan

  • npx tsc --noEmit — zero TypeScript errors
  • npx vsce package — VSIX builds successfully
  • Manual testing against Appwrite 1.8.1 instance:
    • Database tree: databases → collections → attributes, permissions, documents
    • Attributes show field names, types, and required status
    • Documents expand to show field-level key-value pairs
    • Permissions show grouped CRUD roles
    • Projects tab shows project name, endpoint, and active status
    • Functions tree: functions → deployments, executions, settings

Breaking changes

  • Requires Appwrite server ≥ 1.4 (Databases service)
  • Project configurations now need a databaseId field (prompted during setup)
  • The legacy Rules API is removed (replaced by Attributes)

🤖 Generated with Claude Code

robertoboero and others added 14 commits January 23, 2026 15:33
This is the first step in migrating the extension to support
the latest Appwrite SDK and API (compatible with Appwrite 1.8.x).

Breaking changes to address in subsequent commits:
- Database API now requires databaseId parameter
- Storage API now requires bucketId parameter
- Functions: Tags renamed to Deployments
- Health: method names updated
- Permission system updated with helper classes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Major type definition changes:
- Add Database entity type (databaseId now required)
- Add Bucket entity type (bucketId now required)
- Rename Tag to Deployment throughout
- Add new health check types (PubSub, Storage, etc.)
- Add helper types (Permission, Role, Query, ID)
- Update User type with new fields (mfa, targets, labels)
- Update Function type (runtime replaces env, deployment replaces tag)
- Update Execution type with new request/response fields
- Deprecate old types with @deprecated annotations
- Add DatabasesClient (replaces DatabaseClient)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Export SDK helper classes (Permission, Role, Query, ID)
- Update system events to new format:
  - databases.*.collections.* (with databaseId)
  - buckets.*.files.* (with bucketId)
  - functions.*.deployments.* (replaces tags)
  - Add messaging events (providers, topics, messages)
- Update function runtimes list to current versions:
  - Node.js 18-22, Python 3.9-3.12, PHP 8.0-8.3
  - Ruby 3.1-3.3, Dart 2.17-3.3, Deno 1.35-2.0
  - Bun 1.0, .NET 6-8, Java 8-21
  - Swift 5.8-5.9, Kotlin 1.8-1.9, C++ 17/20, Go 1.22-1.23

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
SDK v21 requires databaseId for all database operations and
bucketId for all storage operations. These optional fields
allow users to configure default IDs per project.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Extend clientConfig to include databaseId and bucketId
- Pass default databaseId to Database service
- Pass default bucketId to Storage service
- Fix setSelfSigned to be called conditionally

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Database.ts: Add databaseId parameter to all methods, use Databases (plural),
  add attribute operations (replaces rules), add permission conversion helpers
- Functions.ts: Rename Tags to Deployments, add variable management,
  new method signatures with runtime/scopes/entrypoint/commands
- Storage.ts: Add bucketId parameter to all methods, add bucket operations
- Health.ts: Add new health checks (PubSub, Storage, QueueBuilds, QueueMails,
  QueueMessaging, QueueMigrations, QueueDeletes), update method names
- Users.ts: Update create signature (userId first), add new user management methods

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Database:
- Add DatabaseTreeItem to show databases as root level items
- CollectionTreeItem now requires databaseId parameter
- DocumentsTreeItem uses databaseClient instead of direct SDK
- Replace RulesTreeItem with AttributesTreeItem (Rules → Attributes)
- Update PermissionsTreeItem for new flat permission array format

Functions:
- Add deployments/ folder with DeploymentsTreeItem and DeploymentTreeItem
- FunctionTreeItem uses DeploymentsTreeItem instead of TagsTreeItem
- Update all settings tree items (Name, Schedule, Timeout, Events, Vars)
  to use new update() method signature
- ExecutionsTreeItem uses Query helpers for pagination
- ExecutionTreeItem uses $createdAt and duration instead of old fields

Storage:
- Add BucketTreeItem to show buckets as root level items
- FileTreeItem now requires bucketId parameter and shows file details
- StorageTreeItemProvider shows bucket hierarchy

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Database commands:
- createCollection: Add database selection when no default configured
- deleteCollection: Pass databaseId from CollectionTreeItem
- deleteDocument: Pass databaseId from CollectionTreeItem hierarchy

Function commands:
- Add new deployment commands (createDeployment, deleteDeployment, activateDeployment)
- Keep tag commands as backward compatibility aliases
- createFunction: Add success message and error handling
- createExecution: Use duration instead of time, handle scheduled status
- viewExecutionOutput/Errors: Use logs/errors instead of stdout/stderr
- copyExecutionOutput/Errors: Use logs/errors instead of stdout/stderr

registerCommands:
- Import new deployment commands
- Register both deployment and legacy tag commands

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix Set spread using Array.from() in Database.ts
- Fix LogList→LogsList import typo in Users.ts
- Update AppwriteCall to accept void promises for delete operations
- Update msToDate to handle ISO date strings (SDK v21+)
- Replace Rules with Attributes (createAttribute, deleteAttribute)
- Remove legacy tag files (replaced by deployments in previous commit)
- Update permission commands for new flat array format
- Update variable management in VarTreeItem
- Update UserTreeItemProvider for SDK v21

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Validate queries/search params in Functions.list() and Users.list()
  to avoid passing empty strings to SDK v21 API
- Add null guards for this.parent?.func in DeploymentsTreeItem,
  ExecutionsTreeItem, and VarsTreeItem
- Make AppwriteCall error handler defensive: type errResp as unknown,
  add console.error logging, wrap handler in try-catch

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When TypeScript compiles to ES5, the `_super.call(this, ...) || this`
pattern can lose properties set in parent constructors if VS Code's
TreeItem (an ES2022 class) interferes with the object identity.

This caused two categories of bugs:
1. `this.parent` undefined in tree items missing `public readonly parent`
2. `this.label` empty because TreeItem constructor label assignment was lost

Fixes:
- Add `public readonly parent` to DocumentsTreeItem, AttributesTreeItem,
  and PermissionsTreeItem constructors (generates explicit _this.parent=)
- Add explicit `this.label = label` in AppwriteTreeItemBase after super()
- Add explicit `this.label = item.label` in ChildTreeItem after super()
- Replace Object.assign with explicit property assignments in
  ChildTreeItem and CollapsableTreeItem
- Add explicit label/description in AttributeTreeItem and PermissionTreeItem
- Clean up debug logging in DatabaseTreeItemProvider, add try-catch safety

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rewrite DocumentTreeItem to extend AppwriteTreeItemBase instead of
ChildTreeItem. Documents are now collapsible tree items that expand
to show all non-system fields as key-value pairs.

- Label: document $id
- Description: document name or collection ID
- Tooltip: document ID, created/updated timestamps
- Children: all user-defined fields with symbol-field icons

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use || instead of ?? for nickname fallback so empty strings
  fall through to projectId (previously showed blank label)
- Add endpoint URL as tree item description
- Add tooltip with project name, ID, and endpoint

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add NODE_OPTIONS=--openssl-legacy-provider to webpack scripts
  for compatibility with modern Node.js
- Update webpack config: externalize node-appwrite, add Node.js
  polyfill fallbacks
- Update AddProjectWizard for SDK v21 project setup flow
- Replace extension marketplace icon and sidebar SVG
- Remove legacy createRuleWizard (rules replaced by attributes in v21)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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