Overview
Generate type-safe TypeScript client SDK from OpenAPI specs and gRPC protos, with React hooks for seamless frontend integration.
🎯 Goals
- Type Safety: Full TypeScript support from API specs
- React Integration: Custom hooks for data fetching and state management
- Auto-Generation: Automated client generation from specs
- Developer Experience: IntelliSense and error checking
- Real-time: WebSocket/gRPC streaming support
📋 Implementation Tasks
Code Generation Setup
React Hooks Package
// packages/api-client/src/hooks/useEnvironments.ts
export function useEnvironments() {
const [environments, setEnvironments] = useState<Environment[]>([])
const [loading, setLoading] = useState(true)
const [error, setError] = useState<Error | null>(null)
const { data, error: fetchError, mutate } = useSWR(
'/api/v1/environments',
apiClient.environments.listEnvironments
)
const createEnvironment = useCallback(async (request: CreateEnvironmentRequest) => {
try {
const environment = await apiClient.environments.createEnvironment(request)
mutate() // Revalidate cache
return environment
} catch (err) {
throw new APIError(err)
}
}, [mutate])
return {
environments: data?.environments || [],
error: fetchError,
createEnvironment,
refreshEnvironments: mutate
}
}
Real-time Integration
🏗️ Package Structure
packages/api-client/
├── src/
│ ├── generated/ # Auto-generated clients
│ │ ├── rest/ # OpenAPI generated
│ │ └── grpc/ # gRPC generated
│ ├── hooks/ # React hooks
│ │ ├── environments.ts
│ │ ├── templates.ts
│ │ └── users.ts
│ ├── providers/ # React context providers
│ │ ├── APIProvider.tsx
│ │ └── StreamProvider.tsx
│ ├── types/ # Custom types
│ └── utils/ # Utilities
├── scripts/
│ ├── generate-rest.sh # OpenAPI generation
│ └── generate-grpc.sh # gRPC generation
└── package.json
Time Estimate: 4-6 hours
Overview
Generate type-safe TypeScript client SDK from OpenAPI specs and gRPC protos, with React hooks for seamless frontend integration.
🎯 Goals
📋 Implementation Tasks
Code Generation Setup
OpenAPI Client Generation
gRPC Client Generation
React Hooks Package
Real-time Integration
Environment Status Streaming
Event-driven Updates
🏗️ Package Structure
Time Estimate: 4-6 hours