Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #124 +/- ##
==========================================
- Coverage 94.58% 94.39% -0.19%
==========================================
Files 11 14 +3
Lines 517 678 +161
Branches 143 175 +32
==========================================
+ Hits 489 640 +151
- Misses 28 38 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
pan-kot
force-pushed
the
api-gen
branch
13 times, most recently
from
August 31, 2026 09:59
14571cd to
279100f
Compare
pan-kot
marked this pull request as ready for review
September 1, 2026 08:45
pan-kot
requested
a balanced review from Copilot
and removed request for
a team
September 1, 2026 08:45
There was a problem hiding this comment.
Pull request overview
Adds an internal API generator for creating self-contained, patched Cloudscape proxy interfaces.
Changes:
- Implements patch parsing, declaration transformation, dependency traversal, and removal markers.
- Exposes API-gen package subpaths and adds
ts-morph. - Adds comprehensive fixtures, snapshots, and tests.
Reviewed changes
Copilot reviewed 15 out of 46 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
vite.config.ts |
Narrows coverage to source files. |
tsconfig.test.json |
Sets the test root directory. |
test/tsconfig.json |
Reuses shared test configuration. |
test/api-gen/to-proxy-source.test.ts |
Tests source cleanup transformations. |
test/api-gen/test-helpers.ts |
Provides API-gen fixture helpers. |
test/api-gen/generate-proxy-interfaces.test.ts |
Tests generation and validation behavior. |
test/api-gen/__snapshots__/generate-proxy-interfaces.test.ts.snap |
Captures generated interface output. |
src/api-gen/to-proxy-source.ts |
Transforms upstream declaration source. |
src/api-gen/resolve-package.ts |
Resolves packages and relative imports. |
src/api-gen/parse-patch.ts |
Parses augmentation patches and markers. |
src/api-gen/markers.ts |
Defines the removal marker. |
src/api-gen/index.ts |
Exposes the generator API. |
src/api-gen/generate-proxy-interfaces.ts |
Generates the proxy declaration tree. |
src/api-gen/apply-patch.ts |
Applies interface and namespace patches. |
package.json |
Adds exports and runtime dependency. |
package-lock.json |
Locks API-gen dependencies. |
fixtures/api-gen/valid/checkbox/override-props.patch.d.ts |
Tests checkbox overrides. |
fixtures/api-gen/valid/button/remove-property.patch.d.ts |
Tests property removal. |
fixtures/api-gen/valid/button/remove-member.patch.d.ts |
Tests member removal. |
fixtures/api-gen/valid/button/marker-imports.patch.d.ts |
Tests marker import forms. |
fixtures/api-gen/valid/button/empty.patch.d.ts |
Tests an empty button patch. |
fixtures/api-gen/valid/button/carry-imports.patch.d.ts |
Tests carried imports. |
fixtures/api-gen/valid/button/add-props.patch.d.ts |
Tests added properties. |
fixtures/api-gen/valid/button-alpha/interfaces.patch.d.ts |
Tests alternate proxy placement. |
fixtures/api-gen/valid/box/remove-nested-ns.patch.d.ts |
Tests nested namespace removal. |
fixtures/api-gen/valid/box/override-nested-ns.patch.d.ts |
Tests nested namespace replacement. |
fixtures/api-gen/valid/box/empty.patch.d.ts |
Tests an empty box patch. |
fixtures/api-gen/valid/box/carry-imports.patch.d.ts |
Tests imported box types. |
fixtures/api-gen/node_modules/@fixtures/upstream/types/events.d.ts |
Provides event type fixtures. |
fixtures/api-gen/node_modules/@fixtures/upstream/types/base-component.d.ts |
Provides base component fixtures. |
fixtures/api-gen/node_modules/@fixtures/upstream/internal/README.md |
Represents a missing declaration fixture. |
fixtures/api-gen/node_modules/@fixtures/upstream/icon/interfaces.d.ts |
Provides upstream icon declarations. |
fixtures/api-gen/node_modules/@fixtures/upstream/checkbox/interfaces.d.ts |
Provides upstream checkbox declarations. |
fixtures/api-gen/node_modules/@fixtures/upstream/button/interfaces.d.ts |
Provides upstream button declarations. |
fixtures/api-gen/node_modules/@fixtures/upstream/box/interfaces.d.ts |
Provides upstream box declarations. |
fixtures/api-gen/error/icon/place-taken-by-upstream.patch.d.ts |
Tests output-path collisions. |
fixtures/api-gen/error/demo/no-upstream.patch.d.ts |
Tests unresolved packages. |
fixtures/api-gen/error/demo/no-upstream-dts.patch.d.ts |
Tests missing declaration files. |
fixtures/api-gen/error/demo/no-augmentation.patch.d.ts |
Tests missing augmentations. |
fixtures/api-gen/error/button/remove-missing-property.patch.d.ts |
Tests invalid property removal. |
fixtures/api-gen/error/button/remove-missing-member.patch.d.ts |
Tests invalid member removal. |
fixtures/api-gen/error/button/no-upstream-namespace.patch.d.ts |
Tests unknown namespaces. |
fixtures/api-gen/error/button/no-upstream-interface.patch.d.ts |
Tests unknown interfaces. |
fixtures/api-gen/error/button/add-ns-value.patch.d.ts |
Tests rejected namespace values. |
fixtures/api-gen/error/button/add-ns-ns.patch.d.ts |
Tests rejected nested namespaces. |
fixtures/api-gen/error/button/add-ns-enum.patch.d.ts |
Tests rejected namespace enums. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+69
to
+88
| const pending = entryPoints.map(entryPath => readPatch(project, entryPath)); | ||
| const emitted = new Map<string, ProxyFile>(); | ||
| const queued = new Set(pending.map(file => file.upstreamPath)); | ||
|
|
||
| while (pending.length > 0) { | ||
| const file = pending.shift()!; | ||
| if (emitted.has(file.emittedPath)) { | ||
| throw new Error(`Two declarations claim the place "${file.emittedPath}" in the proxy tree.`); | ||
| } | ||
|
|
||
| // Transform upstream interfaces that correspond to the given file path. | ||
| const out = toProxySource(project, file.emittedPath, readFileSync(file.upstreamPath, 'utf-8')); | ||
|
|
||
| // Follow file's relative imports to pull its dependencies, such as other components or shared types. | ||
| for (const reached of followImports(out, file, resolveImport)) { | ||
| if (!queued.has(reached.upstreamPath)) { | ||
| queued.add(reached.upstreamPath); | ||
| pending.push(reached); | ||
| } | ||
| } |
Comment on lines
+94
to
+96
| function carryOverImports(out: ts.SourceFile, patch: Patch) { | ||
| out.addImportDeclarations(patch.imports); | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Internal util to generate interfaces for proxy Cloudscape components.
Proposal: 92DfrTApyLG2
The new API is represented with
generateProxyInterfaces, which takes paths to patch files, and outputs a list of transformed files to write on the disk.A patch is a
.d.tsmodule augmentation next to the proxied component. Members are added orreplaced by declaring them, and removed by typing them with the
Removemarker:The build script points the generator at the patches and writes what it returns:
For the patch above that emits
button/interfaces.tswith variant narrowed and iconName gone, plus everything those interfaces reach — other components and shared types — so the generated tree resolves within itself. Along the way license headers and@awsuiSystemannotations are stripped and ambient namespaces are made real. An optionalresolveImporthook rewrites the specifiers of emitted imports, for consumers that re-export the shared types from their own paths.Patches that name something upstream does not declare fail the build instead of silently doing nothing, so an upstream rename surfaces as an error rather than a missing override.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.