Feature: auto-generate a typed TypeScript SDK into packages/shared from the OpenAPI spec
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 18/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- go, openapi, react, typescript
- Ambito
- api, developer-experience
Direzione di ricerca
Start by reading the existing grit generate resource and grit sync command implementations to see where packages/shared types and Zod schemas are emitted. Then inspect packages/shared/types/api.ts and the OpenAPI output mounted at /docs/openapi.json to map the {data, meta, error} envelope. The work is done when grit sync-sdk emits a typed namespaced client at packages/shared/client.ts, existing React Query hooks delegate to it, and generated hooks lose their any payloads.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Context
Grit already emits OpenAPI via gindocs mounted at /docs (great!). And grit generate resource produces TS types + Zod schemas in packages/shared. But the bridge is missing: the frontend still has to hand-write fetch('/api/invoices') and cast the response.
Proposal
Add grit sync-sdk (or extend the existing grit sync) to generate a typed client into packages/shared/client.ts:
import { createClient } from \"@rental-manager/shared\";
const api = createClient({ baseURL: \"http://localhost:8080\", token });
// Fully typed:
const { data: invoices, meta } = await api.invoices.list({
tenant_id: tenantId,
status: \"overdue\",
page: 1,
page_size: 20,
});
const inv = await api.invoices.get(invoiceId);
const created = await api.invoices.create({
tenant_id, items: [...], issue_date, due_date
});
Under the hood: fetch + error envelope matching Grit's existing {data, meta, error} shape + React Query integration (Grit already emits useList, useCreate, etc. hooks — let those delegate to this client).
Why this is a multiplier
- One source of truth: the Go model + gin binding tags already define the contract. OpenAPI already exports it. TS types + Zod already mirror it. A single generator closes the loop.
- Frontend error surface shrinks dramatically — no more
as Invoice[]casts, no stale mocks in tests, compile-time breakage when a backend field renames. - React Query hooks that Grit already scaffolds can inherit proper types — currently they appear to take generic
anypayloads in the samples I generated. - Matches competitors — trpc, Payload, Hono RPC, Encore all do this today; it's becoming table stakes for full-stack TS-adjacent frameworks.
Implementation notes
- openapi-typescript or orval can do the heavy lifting; Grit just has to invoke it against the live
/docs/openapi.jsonor an on-disk snapshot. - Keep the client runtime tiny (no axios dependency); mirror the
ApiResponse/PaginatedResponsetypes already inpackages/shared/types/api.ts. - Emit per-resource namespaces (
api.invoices.*,api.tenants.*) to match the URL hierarchy.
Bonus
This would play nicely with the pagination helper (issue #14) — every List hook gets { data, total, page, page_size, pages } typed once and reused everywhere.
- Lingua principale
- Go
- Stelle
- 152
- Fork
- 20
- Merge medio
- 1g 49m
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MUKE-coder/grit
-
[Plugin] calendarAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
MUKE-coder/grit#228 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 65/100
MUKE-coder/grit#227 ·
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 18/100
MUKE-coder/grit#224 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
MUKE-coder/grit#199 · 4 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
MUKE-coder/grit#179 · 4 commenti ·
Tutte le issue di MUKE-coder/grit
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
karmada-io/karmada#8101 ·
I maintainer di solito rispondono entro 1 giorno
-
product:platform
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
Infisical/infisical#9746 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
CrossEntropyFilter raises on zero probabilities and single-class resultsForse già presa @NopeCharon l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
txn2/mcp-data-platform#2728 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
Windshiftapp/core#542 ·
I maintainer di solito rispondono entro 1 giorno