Repository navigation
feat(sdks): ship the generated spec inside the Console web SDK - #14435
Conversation
A preview Console SDK overlays a branch's own spec on the spec the published SDK was built from. Nothing records that spec today, so a preview drops Cloud APIs that only exist on the branch the pinned SDK came from.
5.0.1 generates a Console web SDK that does not compile against the current spec (avatars.ts references an undefined rest parameter).
|
Review complete. 🟡 2 medium 💬 Inline comments (2)
The change teaches the SDK generation task to ship the API spec alongside each generated package.
Reviewed commit: 62e91f5 |
🟢 Tier S · Ready to merge
The SDK generation task now adds the source spec to generated Console web SDK packages and exposes it through the package exports map. The SDK generator lockfile is also updated from 5.0.1 to 5.7.1.
📂 Walkthrough · 2
Reviewed |
There was a problem hiding this comment.
This PR embeds spec.json into generated SDK packages by writing it into the output directory and adding it to package.json files/exports, with addSpec() guarded by a try/catch.
Key findings
- 🟡 Guard
package.jsonread andfiles/exportsinaddSpec()— SDKs.php:689 - 🟡 An
addSpec()failure still allows the SDK to be pushed — SDKs.php:490
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
|
@Hansi-bot review |
|
@hansi-codes review |
What does this PR do?
The Console web SDK (
@appwrite.io/console) now ships the spec it was generated from asspec.json, listed infilesand exported as@appwrite.io/console/spec.json. Only the Console web SDK gets it; every other SDK is unchanged.This is the first step towards letting a single PR change both the API and the Console. The Console builds against the Cloud SDK, so a PR that adds an endpoint has no SDK method to call until Cloud releases one. The plan is a preview SDK built by laying the PR's own spec over the spec the pinned SDK was built from. That only works when the base is exact: today nothing records which spec a published SDK came from, and approximating it with the public specs drops APIs the Console already uses or changes their types. Shipping the spec inside the package makes the base exact by construction:
node_modules/@appwrite.io/console/spec.json.Cloud builds both its releases and its pkg.vc previews through this task, so they pick this up on the next
appwrite/server-cebump. Because releases push the generated directory toappwrite/sdk-for-console, the file is committed there too.The second commit updates
appwrite/sdk-generatorfrom 5.0.1 to 5.7.1 in the lockfile (the^5.0constraint is unchanged). With 5.0.1, the Console web SDK generated from the current spec does not compile (avatars.ts:Cannot find name 'rest'). 5.3.6, the version Cloud locks, and 5.7.1 both build.Test Plan
php app/cli.php specs --version=latest --git=no, thenphp app/cli.php sdks --platform=console --sdk=web --version=latest --git=noapp/sdks/console-web/spec.jsonis byte-identical toapp/config/specs/open-api3-latest-console.json.package.jsondiffers from the template output only by"spec.json"infilesand"./spec.json"inexports.npm install && npm run buildinapp/sdks/console-webpasses with 5.7.1;npm pack --dry-runlistsspec.jsonnext todistandtypes. The tarball grows by about 0.4 MB compressed.import spec from '@appwrite.io/console/spec.json' with { type: 'json' }andrequire.resolve('@appwrite.io/console/spec.json')both work, and so does importingClientandProjectfrom the SDK.sdks --platform=client --sdk=webproduces nospec.json.composer lintand PHPStan onsrc/Appwrite/Platform/Tasks/SDKs.phppass.Overlay feasibility, checked locally ahead of the follow-up:
bun run buildpasses.Related PRs and Issues
spec.json, publishes to pkg.pr.new, and lets the Console pin it.Checklist
Closes #14436