Skip to content

feat: update CLI to console SDK 9.0.0 with webhook push/pull and protocol status#1445

Open
ChiragAgg5k wants to merge 9 commits intomasterfrom
chore/update-console-sdk-9.0.0
Open

feat: update CLI to console SDK 9.0.0 with webhook push/pull and protocol status#1445
ChiragAgg5k wants to merge 9 commits intomasterfrom
chore/update-console-sdk-9.0.0

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

@ChiragAgg5k ChiragAgg5k commented Apr 13, 2026

Summary

Updates the CLI template to use @appwrite.io/console SDK 9.0.0, adapting to all breaking changes and adding new features exposed by the updated SDK.

Console SDK 9.0.0 Migration

  • Updated dependency from ~8.3.0 to ~9.0.0 in package.json, package-lock.json, and bun.lock templates
  • Replaced ApiService enum with ServiceId — the old ApiService enum was removed from the SDK and split into ServiceId and ProtocolId
  • Moved updateServiceStatus call from Projects to Project service — the method was moved to the project-scoped Project (singular) service in SDK 9.0.0
  • Added getProjectService helper in services.ts using sdkForProject (project-scoped client, not the console client)

Go SDK Build Fix

  • Changed Go model filenames from caseSnake to caseCamel in Go.php — Go treats files ending with _<GOOS>.go (e.g., platform_android.go, platform_windows.go, platform_linux.go) as OS-specific build constraints. The new PlatformAndroid, PlatformWindows, and PlatformLinux models from SDK 9.0.0 generated filenames that matched this pattern, causing them to be silently excluded from builds on non-matching operating systems. Now generates platformAndroid.go etc.

Protocol Status Support (New)

  • Added protocols to project settings schemarest, graphql, websocket boolean fields
  • Added protocol status to createSettingsObject — maps protocolStatusForRest/Graphql/Websocket from the Project model for pull
  • Added push handler — iterates settings.protocols and calls projectService.updateProtocolStatus() with ProtocolId enum

Webhook Push/Pull Support (New)

  • config.ts (schema): Added WebhookSchema with $id, name, url, events, enabled, tls, authUsername, authPassword fields. Registered in ConfigSchema. Exported type and schema.
  • config.ts (Local class): Added KeysWebhooks, getWebhooks(), getWebhook(), addWebhook() methods following the teams pattern.
  • services.ts: Added getWebhooksService helper importing Webhooks from the console SDK.
  • questions.ts: Added questionsPushWebhooks interactive prompt. Added "Webhooks" to both pull and push resource selection lists.
  • push.ts: Added pushWebhooks() method (get→update, 404→create pattern). Only sends authUsername/authPassword when non-empty to avoid API validation errors. Added dispatch in pushResources() for push all. Added pushWebhook CLI handler with change approval. Registered push webhook|webhooks command.
  • pull.ts: Added pullWebhooks() method with pagination and filterBySchema to strip read-only fields (secret, logs, attempts, timestamps). Added dispatch in pullResources() for pull all. Added pullWebhook CLI handler with stale-webhook detection. Registered pull webhook|webhooks command.

Test Plan

  • CLI builds successfully (bun run mac-arm64)
  • push webhooks — reads config, shows change diff, pushes to API
  • pull webhooks — fetches from API, stores filtered fields in config
  • push all / pull all — webhooks included
  • Auth credentials (authUsername, authPassword) — create, pull, modify, push, round-trip verified
  • Empty auth credentials — not sent to API (avoids validation error)
  • Empty/missing webhooks — correctly skipped
  • Protocol status push — reads settings.protocols, calls updateProtocolStatus
  • Go SDK — go build ./... and go test ./... pass with caseCamel model filenames
  • No new TypeScript errors introduced (only pre-existing deprecation warnings)

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 13, 2026

Greptile Summary

This PR updates the CLI to the @appwrite.io/console SDK 9.0.0, adds webhook push/pull support, adds protocol status configuration, and fixes a Go model filename issue that caused build-constraint mismatches on Linux/Android/Windows targets. The implementation is thorough, follows existing code patterns closely, and the previously-flagged projectService scoping issue has been correctly addressed by using sdkForProject().

Confidence Score: 5/5

Safe to merge — all changes follow established patterns, the prior projectService scoping concern is resolved, and no new bugs were identified.

No P0 or P1 findings. The webhook push/pull implementation mirrors the Teams pattern exactly (including probe fetch, paginate call, filterBySchema, stale-detection, and approveChanges). The Go filename fix is justified by the Go build-constraint spec. The SDK 9.0.0 migration (ApiService→ServiceId/ProtocolId, Projects→Project for updateServiceStatus) is correctly applied throughout.

No files require special attention.

Important Files Changed

Filename Overview
src/SDK/Language/Go.php Changes model/requestModel filename destinations from caseSnake to caseCamel to avoid Go OS-specific build constraint matching (e.g., platform_android.go being excluded on non-Android builds). Well-justified fix.
templates/cli/lib/commands/push.ts Adds pushWebhooks() following the same get→update / 404→create pattern as teams/buckets; migrates updateServiceStatus from Projects to Project service; adds updateProtocolStatus support. projectService now correctly uses sdkForProject() per prior review feedback.
templates/cli/lib/commands/pull.ts Adds pullWebhooks() with pagination and filterBySchema to strip read-only fields. Stale-webhook detection and user confirmation in the standalone handler. Follows Teams pattern exactly.
templates/cli/lib/commands/config.ts Adds WebhookSchema (with all read-only fields excluded), WebhookType, and protocols to SettingsSchema. Schema is strict and all optional fields are correctly marked.
templates/cli/lib/config.ts Adds KeysWebhooks, getWebhooks(), getWebhook(), and addWebhook() following the Teams pattern. Correct use of whitelistKeys in addWebhook.
templates/cli/lib/services.ts Adds getProjectService (uses sdkForProject) and getWebhooksService (uses sdkForProject). Both follow the same pattern as other service helpers.
templates/cli/lib/utils.ts Adds protocols block to createSettingsObject mapping protocolStatusFor{Rest,Graphql,Websocket} from the project model. Consistent with how services is handled.
templates/cli/lib/questions.ts Adds questionsPushWebhooks prompt and inserts Webhooks into both pull and push resource selection menus. Correct use of when guard and validation.

Reviews (6): Last reviewed commit: "fix: add webhooks to PushOptions interfa..." | Re-trigger Greptile

Update push.ts to use the renamed console SDK exports:
- ApiService → ProtocolService
- updateServiceStatus → updateProtocolStatus
Console SDK 9.0.0 moved updateServiceStatus from Projects to Project
service and replaced ApiService enum with ServiceId. Also add
getProjectService helper to services.ts.
Go treats files ending with _<GOOS>.go (e.g., _android.go, _windows.go,
_linux.go) as OS-specific build constraints. The new PlatformAndroid,
PlatformWindows, and PlatformLinux models generated snake_case filenames
that matched this pattern, causing them to be excluded from builds on
other operating systems. Switch to caseCamel naming (platformAndroid.go)
to avoid the constraint.
The Project (singular) service is scoped to the client's configured
project. Create a project-scoped client with the target projectId
instead of using the console client which is hardcoded to "console".
The Project (singular) service is project-scoped. Use the existing
sdkForProject helper which already resolves the correct project ID
from local/global config with proper auth.
Add ability to store and push protocol statuses (rest, graphql,
websocket) alongside service statuses. Uses the new Project service
updateProtocolStatus method with ProtocolId enum from console SDK 9.0.0.
Add full CRUD support for webhooks in the CLI push/pull workflow:
- WebhookSchema with validation for name, url, events, enabled, tls,
  authUsername, authPassword
- getWebhooks/getWebhook/addWebhook config methods
- getWebhooksService helper
- pushWebhooks method with get→update / 404→create pattern
- pullWebhooks method with pagination and schema filtering
- Interactive prompts for webhook selection
- Webhooks included in push all / pull all flows
- Only send authUsername/authPassword when non-empty
@ChiragAgg5k ChiragAgg5k changed the title chore: update CLI console SDK dependency to 9.0.0 feat: update CLI to console SDK 9.0.0 with webhook push/pull and protocol status Apr 13, 2026
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