fix(web): register the drifted document endpoints in the api contract#1283
Open
abhay-codes07 wants to merge 1 commit into
Open
fix(web): register the drifted document endpoints in the api contract#1283abhay-codes07 wants to merge 1 commit into
abhay-codes07 wants to merge 1 commit into
Conversation
The endpoint map and validation schemas have fallen behind what the web app actually exchanges with the API: - the memories grid and the X-bookmarks status query filter @post/documents/documents by `categories`, a field DocumentsWithMemoriesQuerySchema doesn't declare — both smuggle it past client validation with disableValidation, and any future caller that forgets the flag gets the key silently stripped and a filter that no-ops - @post/documents/documents/facets was never registered: DocumentFacetsQuerySchema sits unused in the validation package while the grid calls the endpoint as an untyped raw URL and hand-casts the response - @patch/documents/:id was never registered even though MemoryUpdateSchema exists for exactly this pairing; the document-edit and file-metadata mutations PATCH via template-literal URLs with no request/response typing Add `categories` to the documents query schema, introduce DocumentFacetSchema/DocumentFacetsResponseSchema (total optional — the UI already guards its absence) and register the facets endpoint with the previously-dead query schema, register @patch/documents/:id with MemoryUpdateSchema/MemoryResponseSchema/params, and convert both PATCH call sites to the typed route. The existing disableValidation flags are deliberately left in place: every current caller of @post/documents/documents sets one, so output validation has never been exercised against production responses; removing them is a follow-up that needs verification against the live API. With the schemas now truthful, that cleanup becomes mechanical. Tested: bun test in packages/validation (12 pass, 4 new), tsc --noEmit on packages/validation, bun test + bun run build in apps/web, biome clean on all touched files.
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
The
@repo/libendpoint map and validation schemas have drifted behind what the web app actually exchanges with the API. Three concrete gaps:categoriesis missing fromDocumentsWithMemoriesQuerySchema. The memories grid and the X-bookmarks status query both filter bycategorieson@post/documents/documents— and both smuggle it past client validation withdisableValidation: truebecause the schema doesn't know the field. Any future caller that filters by category without remembering that flag gets the key silently stripped and a filter that no-ops.@post/documents/documents/facetswas never registered.DocumentFacetsQuerySchemaexists in the validation package but is imported nowhere — dead code — while the memories grid calls the endpoint as an untyped raw URL and hand-casts the response to a local type.@patch/documents/:idwas never registered.MemoryUpdateSchemaexists for exactly this (its own comment pairs it withMemoryAddSchema, but only the add path got wired). The document-edit and file-metadata mutations PATCH via template-literal URLs (`@patch/documents/${id}`), bypassing all request/response typing.Changes
DocumentsWithMemoriesQuerySchemagainscategories: z.array(z.string()).optional()DocumentFacetSchema/DocumentFacetsResponseSchema(mirroring the shape the grid already consumes, withtotaloptional since the UI guards it), and@post/documents/documents/facetsregistered with the previously-dead query schema as input@patch/documents/:idregistered withMemoryUpdateSchema/MemoryResponseSchema/params, and both PATCH call sites inuse-document-mutations.tsconverted to the typed route withparams: { id }categoriesfield and the facets response shapeDeliberately out of scope
The existing
disableValidation: trueflags stay put, including on the two calls that motivated thecategoriesfix. Every current caller of@post/documents/documentssets the flag, which means output validation againstDocumentsWithMemoriesResponseSchemahas never been exercised in production — removing the flags safely needs someone to verify the declared response schemas against live responses (I don't have staging access). With the schemas now correct, that cleanup becomes a mechanical follow-up.Testing
bun testinpackages/validation— 12 pass (4 new)tsc --noEmit -p packages/validation— cleanbun test+bun run buildinapps/web— cleanbiome checkon all touched files — cleancc @MaheshtheDev