refactor(frontend): derive PaginatedResponse from the generated schema - #573
Open
hamza-56 wants to merge 2 commits into
Open
refactor(frontend): derive PaginatedResponse from the generated schema#573hamza-56 wants to merge 2 commits into
hamza-56 wants to merge 2 commits into
Conversation
The hand-written generic duplicated the envelope of the generated PaginatedResponse_* schemas field for field, the same latent-drift pattern UserPluginState had. Map it off the generated schema (only the item type is swapped back in, since openapi-typescript emits one monomorphic schema per item type) and add a compile-time gate in drive.test.ts checking the generic against both generated schemas, so a backend change to the envelope fails tsc after regeneration.
The mapped generic still reconstructed the envelope; PaginatedFolders and PaginatedFiles now alias the generated schemas exactly like every other type in the module, so nothing is left to drift and the type-level gate test is unnecessary. fetchAllPages keeps its generic via a structural parameter (just the items/total fields the loop reads).
Contributor
Author
|
@claude-review |
Contributor
|
Claude finished @hamza-56's task in 1m 3s —— View job Review:
|
abdulrafey1
approved these changes
Aug 6, 2026
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.
What
PaginatedResponse<T>infrontend/lib/drive.tshand-duplicated the envelope of the generatedPaginatedResponse_*schemas field for field, the same latent-drift patternUserPluginStatehad before #567; the page shapes are now direct aliases of the generated schemas.Changes
PaginatedResponse<T>withPaginatedFolders/PaginatedFiles, directSchema<...>aliases like every other type in the module (openapi-typescript emits one monomorphic paginated schema per item type, so there is no generic to preserve)fetchAllPages's fetcher parameter structural (just theitems/totalfields the loop reads), keeping it polymorphic without a named envelope typeHow to Test
cd frontend && bun run typecheckpasses.make test.frontendpasses (25 files, 212 tests).listFolders/listFilesreturn types are now exactly the generated schemas, so any backend change to the pagination envelope failstscaftermake frontend.build.apiwith no extra gate needed.Notes
Type-level only, no runtime change. No migration, no env vars, no dependencies.
This description was written with the assistance of an LLM (Claude).