feat: update CLI to console SDK 9.0.0 with webhook push/pull and protocol status#1445
feat: update CLI to console SDK 9.0.0 with webhook push/pull and protocol status#1445ChiragAgg5k wants to merge 9 commits intomasterfrom
Conversation
Greptile SummaryThis PR updates the CLI to the Confidence Score: 5/5Safe 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
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
Summary
Updates the CLI template to use
@appwrite.io/consoleSDK 9.0.0, adapting to all breaking changes and adding new features exposed by the updated SDK.Console SDK 9.0.0 Migration
~8.3.0to~9.0.0inpackage.json,package-lock.json, andbun.locktemplatesApiServiceenum withServiceId— the oldApiServiceenum was removed from the SDK and split intoServiceIdandProtocolIdupdateServiceStatuscall fromProjectstoProjectservice — the method was moved to the project-scopedProject(singular) service in SDK 9.0.0getProjectServicehelper inservices.tsusingsdkForProject(project-scoped client, not the console client)Go SDK Build Fix
caseSnaketocaseCamelinGo.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 newPlatformAndroid,PlatformWindows, andPlatformLinuxmodels 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 generatesplatformAndroid.goetc.Protocol Status Support (New)
protocolsto project settings schema —rest,graphql,websocketboolean fieldscreateSettingsObject— mapsprotocolStatusForRest/Graphql/Websocketfrom theProjectmodel for pullsettings.protocolsand callsprojectService.updateProtocolStatus()withProtocolIdenumWebhook Push/Pull Support (New)
config.ts(schema): AddedWebhookSchemawith$id,name,url,events,enabled,tls,authUsername,authPasswordfields. Registered inConfigSchema. Exported type and schema.config.ts(Local class): AddedKeysWebhooks,getWebhooks(),getWebhook(),addWebhook()methods following the teams pattern.services.ts: AddedgetWebhooksServicehelper importingWebhooksfrom the console SDK.questions.ts: AddedquestionsPushWebhooksinteractive prompt. Added "Webhooks" to both pull and push resource selection lists.push.ts: AddedpushWebhooks()method (get→update, 404→create pattern). Only sendsauthUsername/authPasswordwhen non-empty to avoid API validation errors. Added dispatch inpushResources()forpush all. AddedpushWebhookCLI handler with change approval. Registeredpush webhook|webhookscommand.pull.ts: AddedpullWebhooks()method with pagination andfilterBySchemato strip read-only fields (secret,logs,attempts, timestamps). Added dispatch inpullResources()forpull all. AddedpullWebhookCLI handler with stale-webhook detection. Registeredpull webhook|webhookscommand.Test Plan
bun run mac-arm64)push webhooks— reads config, shows change diff, pushes to APIpull webhooks— fetches from API, stores filtered fields in configpush all/pull all— webhooks includedauthUsername,authPassword) — create, pull, modify, push, round-trip verifiedsettings.protocols, callsupdateProtocolStatusgo build ./...andgo test ./...pass withcaseCamelmodel filenames