Scaffold a new metric in the PropertyIQ data layer (registry, fetcher, types)
Scaffolds a new metric following PropertyIQ's data layer patterns.
packages/frontend/lib/data/registry.ts):${metricId}: {
id: '${metricId}',
title: '${title}',
format: '${format}',
dataSource: '${dataSource}',
apiEndpoint: '/api/${dataSource}/{geo}', // Adjust based on actual endpoint
keyField: 'auto',
supportedGeos: [${geos.split(',').map(g => `'${g.trim()}'`).join(', ')}],
},
Verify API Endpoint Exists:
packages/backend/src/${dataSource}/ for the controllerregion_namecbsa_codecounty_fipspostal_codeTest the Metric:
import { useSnapshotData } from '@/lib/data';
const { value, isLoading } = useSnapshotData('${metricId}', 'metro', '35620');
| Geo Level | Key Field | Example |
|---|---|---|
| state | region_name | "California" |
| metro | cbsa_code | "35620" |
| county | county_fips | "06001" |
| zip | postal_code | "90210" |
supportedGeos - metrics without it won't renderasPercent: trueMETRO_ONLY_METRICS set