Skip to content

feat(quickstart): prune build file to subscription before generating#294

Merged
sohail2721 merged 19 commits into
devfrom
feat/prune-build-file-for-subscription
Jul 14, 2026
Merged

feat(quickstart): prune build file to subscription before generating#294
sohail2721 merged 19 commits into
devfrom
feat/prune-build-file-for-subscription

Conversation

@sohail2721

Copy link
Copy Markdown
Contributor

What

Fixes apimatic quickstart (portal flow) failing for Starter/Basic plans. The scaffolded APIMATIC-BUILD.json enables AI features (API Copilot + AI context plugins) and all SDK languages, so codegen rejects the whole build for plans that don't include them.

This is the CLI half of a cross-repo effort (apimatic-io exposes POST /api/build-features/prune, delegating to a codegen pruner; the platform onboarding app calls the same endpoint). Tracking plan: apimatic-platform-app issue #471.

Changes (src/actions/portal/quickstart.ts, validation-service.ts, prompts/portal/quickstart.ts)

  • Fail fast on an off-plan SDK language: after language selection, compares the chosen languages against the account's allowedLanguages; if any isn't on the plan, prints a clear message (with an upgrade hint) and aborts before scaffolding.
  • Prune the build file before serving: after the build file is written, POSTs it to the platform's /build-features/prune endpoint (same auth + base-URL pattern as stripUnallowedFeatures), overwrites it with the pruned result, and reports what was removed (SDK languages / API Copilot / AI context plugins). Fail closed — a prune failure aborts rather than serving a build the plan can't generate.
  • Types the pre-existing parseErrorResponse param (was any) to keep the file lint-clean.

Verification

  • pnpm build (tsc -b): clean.
  • pnpm eslint on changed files: clean.

Rollout

Depends on the apimatic-io /build-features/prune endpoint being deployed (fail-closed), which in turn depends on the codegen pruner. Coordinate deploy order: codegen → io → CLI.

🤖 Generated with Claude Code

…erating

Fixes portal quickstart failing for Starter/Basic plans, whose scaffolded
APIMATIC-BUILD.json enables AI features (API Copilot + AI context plugins) and
SDK languages the plan doesn't include, causing codegen to reject the build.

- Fail fast when a selected SDK language isn't on the plan (from the account's
  allowedLanguages), with an upgrade hint.
- After writing the build file, POST it to the platform's /build-features/prune
  endpoint, overwrite it with the pruned result, and report what was removed.
  Fail closed: a prune failure aborts rather than serving an ungenerable build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sohail2721
sohail2721 force-pushed the feat/prune-build-file-for-subscription branch from 4ce5be6 to 8736057 Compare July 8, 2026 10:47
The quickstart language prompts now list only the SDK languages the
account's subscription includes. Languages not on the plan are omitted
from the choices, and a note listing them with an upgrade link is shown
before the language selection — instead of failing after the fact. Both
the portal (multi-select) and SDK (single-select) flows fetch account
info before the language step and share a LANGUAGE_CHOICES list.

Also defer the 'API Copilot is enabled' caution until after the build
file is pruned, and only print it when Copilot survived the prune, so
it is no longer shown for accounts whose plan doesn't include Copilot.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sohail2721
sohail2721 force-pushed the feat/prune-build-file-for-subscription branch from b1911c4 to eaed4de Compare July 8, 2026 11:19
sohail2721 and others added 7 commits July 8, 2026 16:36
Change the second example prompt in the default API Copilot welcome
message from 'What endpoints are available in this API?' to the more
approachable 'What is this API about?'.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ilable

When the account's plan includes no SDK languages (e.g. the Free plan),
both quickstart flows now stop before the language step with a clear
upgrade message instead of rendering an empty selection prompt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move the account-info fetch and free-plan guard to the start of both
quickstart flows, before the spec import/validation/prune steps. A
free-plan user is now stopped up front instead of first being told
components will be removed 'before proceeding' and then cancelled.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ation

Both quickstart flows repeated the same account-info fetch and free-plan
guard. Extract it into resolveQuickstartPlan, which returns the resolved
plan or the ActionResult to return, cutting the duplicated block from the
portal and SDK actions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-for-subscription

# Conflicts:
#	src/infrastructure/services/validation-service.ts
@sohail2721
sohail2721 changed the base branch from beta to main July 10, 2026 06:53
@saeedjamshaid
saeedjamshaid changed the base branch from main to dev July 10, 2026 06:54
sohail2721 and others added 10 commits July 10, 2026 12:17
The prune endpoint response was typed unknown and written back with a raw
JSON.stringify. Convert it to BuildConfig at the service boundary via a new
BuildConfig.from factory and persist it through
BuildContext.updateBuildFileContents. The Copilot caution now checks
hasApiCopilot() on the pruned config instead of the prune report.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pruneBuildFile reads the endpoint's zip (APIMATIC-BUILD.json + report.json) via
adm-zip instead of a JSON body, keeping the same PruneBuildFileResponse shape.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add an in-memory readEntry to ZipService so adm-zip stays encapsulated
there, and drop the direct adm-zip usage from ValidationService.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Reuse BuildContext.buildFilePath() instead of reconstructing the
APIMATIC-BUILD.json FilePath in the action, removing the duplicated
filename literal and leaked path knowledge.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Portal quickstart now exits early when the plan doesn't allow on-prem
generation (isOnPremGenerationAllowed from /account/profile) instead of
when the plan has no SDK languages. With zero SDK languages the language
menu is skipped and the portal is generated with HTTP documentation only.
SDK quickstart keeps its allowed-languages gate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…in-memory

Stream the /build-features/prune response straight to a temp zip, extract it
via ZipService.unArchive, then read APIMATIC-BUILD.json and report.json back
off disk. Drops the in-memory Buffer/AdmZip handling and lets ZipService.readEntry
go away entirely. The prune error parser now consumes the streamed body, matching
the sibling strip flow.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
6.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@sohail2721
sohail2721 merged commit 5d50968 into dev Jul 14, 2026
3 of 4 checks passed
sohail2721 added a commit that referenced this pull request Jul 14, 2026
…294) (#296)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
github-actions Bot pushed a commit that referenced this pull request Jul 14, 2026
# [1.2.0](v1.1.0...v1.2.0) (2026-07-14)

### Features

* **quickstart:** prune build file to subscription before generating ([#294](#294)) ([#296](#296)) ([5f90b2a](5f90b2a))
@saeedjamshaid
saeedjamshaid deleted the feat/prune-build-file-for-subscription branch July 14, 2026 07: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.

2 participants