/** * Phase 5 ARCH-M6 scaffolding (2026-05-13). * * Orval config for the certctl frontend. Reads ../api/openapi.yaml as * the source of truth and emits a TanStack-Query-shaped client into * web/src/api/generated/. Output is git-tracked; the * scripts/ci-guards/openapi-codegen-drift.sh guard fails the build * when api/openapi.yaml changes but the generated/ tree wasn't * regenerated alongside. * * Pairs with frontend-design-audit Phase 2 (TanStack tier model). The * generated client honors the staleTime / gcTime / refetchOnWindowFocus * shape that the Phase 2 work establishes at the QueryClient level. * * Sub-phase 5b status (2026-05-13): * - This config exists. * - 'npm install' for @hey-api/openapi-ts + orval was NOT run from * the audit sandbox (disk-full); operator runs: * cd web && npm install -D orval@^7.0.0 * cd web && npm run generate * in the first follow-up sprint. The generated tree lands as * web/src/api/generated/{certctl.ts,certctl.msw.ts,model/*.ts}. * - client.ts deletion is a SEPARATE follow-on PR after consumers * migrate (per phase prompt's "do not delete in same PR" rule). * * Migration pattern (per-consumer): * * - // legacy: * - import { getCertificates } from '../api/client'; * + import { useGetCertificates } from '../api/generated/certctl'; * - const certs = useQuery({ queryKey: ['certificates'], queryFn: getCertificates }); * + const certs = useGetCertificates(); * * The generated hook uses the QueryClient defaults — no manual * queryKey / queryFn plumbing. Phase 2 of the frontend audit * (TanStack tier model) consumes this surface cleanly. */ import { defineConfig } from 'orval'; export default defineConfig({ certctl: { input: { // Source-of-truth OpenAPI doc. Co-located one directory up. target: '../api/openapi.yaml', }, output: { // All generated code lives under web/src/api/generated/. // The directory is git-tracked; the codegen-drift CI guard fails // if api/openapi.yaml changes and the generated tree wasn't // regenerated alongside. target: './src/api/generated/certctl.ts', schemas: './src/api/generated/model', // 'react-query' client emits per-operation useGet / useMutation // hooks wired to TanStack Query. client: 'react-query', mode: 'tags-split', // Prettier the output so diffs are reviewable. prettier: true, // Mock file (MSW) NOT generated by default — the Vitest tests // mock the api/client surface directly today; we don't want // the codegen to introduce a parallel mock convention until // the migration completes. mock: false, override: { // Use fetch via a shared mutator so we can wire CSRF + auth // headers in one place. The mutator file lives at // web/src/api/mutator.ts (lands in the same PR that runs // 'npm run generate' the first time). mutator: { path: './src/api/mutator.ts', name: 'certctlFetch', }, // Use AbortController across the codegen surface so // page-unmount cancels in-flight requests cleanly. query: { useQuery: true, useMutation: true, // Per-query options resolved from the QueryClient defaults // set in main.tsx (frontend audit Phase 2 TQ-H2 / TQ-M1 // tier model). }, }, }, }, });