Ensure API responses follow established patterns and use proper typing. Always use standardized response types like PaginatedResponse
for paginated endpoints, avoid hardcoded union types for dynamic values that should be strings, and return fresh data from API responses rather than stale local data.
Key practices:
PaginatedResponse<T>
for paginated APIsExample:
// Bad: Hardcoded union types and inline complex types
async recentActivity(): Promise<{
activities: Array<{
type: 'external_data_sync' | 'materialized_view' // Too rigid
}>
}>
// Good: Standardized response with flexible types
type FunctionActionType = 'function' | 'function_email' | 'function_sms' | 'function_slack' | 'function_webhook';
async recentActivity(): Promise<PaginatedResponse<ActivityItem>> {
// Use string for dynamic sync names like "Stripe", "Salesforce"
type: string // More flexible for dynamic values
}
// Always return fresh API data
const updatedSource = await api.externalDataSources.update(source.id, source)
return {
...values.dataWarehouseSources,
results: values.dataWarehouseSources?.results.map((s) =>
s.id === updatedSource.id ? updatedSource : s // Use fresh data
) || []
}
Enter the URL of a public GitHub repository