Skip to content

feat(sdks): ship the generated spec inside the Console web SDK - #14435

Merged
ChiragAgg5k merged 3 commits into
mainfrom
feat/console-sdk-spec
Oct 13, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
feat/console-sdk-spec

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

The Console web SDK (@appwrite.io/console) now ships the spec it was generated from as spec.json, listed in files and 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-ce bump. Because releases push the generated directory to appwrite/sdk-for-console, the file is committed there too.

The second commit updates appwrite/sdk-generator from 5.0.1 to 5.7.1 in the lockfile (the ^5.0 constraint 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, then php app/cli.php sdks --platform=console --sdk=web --version=latest --git=no
    • app/sdks/console-web/spec.json is byte-identical to app/config/specs/open-api3-latest-console.json.
    • package.json differs from the template output only by "spec.json" in files and "./spec.json" in exports.
  • npm install && npm run build in app/sdks/console-web passes with 5.7.1; npm pack --dry-run lists spec.json next to dist and types. The tarball grows by about 0.4 MB compressed.
  • In a scratch project that installs the package, import spec from '@appwrite.io/console/spec.json' with { type: 'json' } and require.resolve('@appwrite.io/console/spec.json') both work, and so does importing Client and Project from the SDK.
  • sdks --platform=client --sdk=web produces no spec.json.
  • composer lint and PHPStan on src/Appwrite/Platform/Tasks/SDKs.php pass.

Overlay feasibility, checked locally ahead of the follow-up:

  • Merging a branch's console spec over the console spec of the SDK the Console pins gives an SDK that is a superset of the base. The Console type-checks with no new errors and bun run build passes.
  • A Console card for a new endpoint, built against that preview, saved its policy against a local server.

Related PRs and Issues

  • Follow-up: a preview workflow that merges a PR's spec over spec.json, publishes to pkg.pr.new, and lets the Console pin it.

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs? (No API changes.)

Closes #14436

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).
@luxor-code-review

luxor-code-review Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review complete. 🟡 2 medium

💬 Inline comments (2)

  • 🟡 Guard package.json read and files/exports in addSpec() — SDKs.php:689
  • 🟡 An addSpec() failure still allows the SDK to be pushed — SDKs.php:490

The change teaches the SDK generation task to ship the API spec alongside each generated package. addSpec() copies spec.json into the package output, then rewrites package.json to include it in files and exports. The call site wraps the new step in try/catch so generation continues if spec embedding fails, though failure does not block publishing.

Files Change
src/Appwrite/Platform/Tasks/SDKs.php Adds addSpec() to copy spec.json into package output and register it in package.json files/exports; called within a try/catch during generation.

Reviewed commit: 62e91f5

@ghost

ghost commented Oct 13, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The scoped generation and package export changes match the requested behavior, and no actionable defects were found.

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.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 2
File Change
src/Appwrite/Platform/Tasks/SDKs.php Adds the generated spec to Console web SDK output and updates its package manifest.
composer.lock Updates the locked SDK generator to 5.7.1.

Reviewed dc1d6d0 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · See the inline comments. Summary

Comment thread src/Appwrite/Platform/Tasks/SDKs.php Resolved

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.json read and files/exports in addSpec() — SDKs.php:689
  • 🟡 An addSpec() failure still allows the SDK to be pushed — SDKs.php:490

Comment thread src/Appwrite/Platform/Tasks/SDKs.php Resolved
Comment thread src/Appwrite/Platform/Tasks/SDKs.php Resolved
@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

19 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (12)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat/console-sdk-spec (after).

Metric Before After Change
🚀 Requests/sec 210.78 218.06 ⚪ +3.5%
⏱️ Latency P50 81.33 ms 80.57 ms ⚪ -0.9%
⏱️ Latency P95 193.23 ms 183.89 ms ⚪ -4.8%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 80.57 183.89 13,680 218.06 -9.34
Account 150.4 272.37 720 12.04 +0.17
TablesDB 76.91 133.6 7,440 120.3 -29.29
Storage 77.32 160.21 3,600 60.39 +6.25
Functions 115.47 233.34 1,920 32.78 +13.91

Top API waits (after)

API request Max wait (ms)
account.name.update 450.58
functions.variables.update 401
functions.variables.create 400.13
functions.create 360.56
tablesdb.rows.increment 325.33

@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@Hansi-bot review

@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@hansi-codes review

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@ChiragAgg5k
ChiragAgg5k merged commit 29840cf into main Oct 13, 2026
64 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the feat/console-sdk-spec branch October 13, 2026 11:33
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.

Ship the generated spec inside the Console web SDK

1 participant