A CLI for publishing standard.site documents to ATProto
at main 88 lines 2.2 kB view raw
1import schema from "../../../sequoia.schema.json" with { type: "json" }; 2 3type PropertyInfo = { 4 path: string; 5 type: string; 6 required: boolean; 7 default?: string | number | boolean; 8 description?: string; 9}; 10 11function extractProperties( 12 properties: Record<string, unknown>, 13 required: string[], 14 parentPath: string, 15 result: PropertyInfo[], 16): void { 17 for (const [key, value] of Object.entries(properties)) { 18 const prop = value as Record<string, unknown>; 19 const fullPath = parentPath ? `${parentPath}.${key}` : key; 20 const isRequired = required.includes(key); 21 22 if (prop.properties) { 23 extractProperties( 24 prop.properties as Record<string, unknown>, 25 (prop.required as string[]) || [], 26 fullPath, 27 result, 28 ); 29 } else { 30 result.push({ 31 path: fullPath, 32 type: prop.type, 33 required: isRequired, 34 default: prop.default, 35 description: prop.description, 36 } as PropertyInfo); 37 } 38 } 39} 40 41export default function ConfigTable() { 42 const rows: PropertyInfo[] = []; 43 extractProperties( 44 schema.properties as Record<string, unknown>, 45 schema.required as string[], 46 "", 47 rows, 48 ); 49 50 return ( 51 <table className="vocs_Table"> 52 <thead> 53 <tr className="vocs_TableRow"> 54 <th className="vocs_TableHeader">Field</th> 55 <th className="vocs_TableHeader">Type</th> 56 <th className="vocs_TableHeader">Required</th> 57 <th className="vocs_TableHeader">Default</th> 58 <th className="vocs_TableHeader">Description</th> 59 </tr> 60 </thead> 61 <tbody> 62 {rows.map((row) => ( 63 <tr key={row.path} className="vocs_TableRow"> 64 <td className="vocs_TableCell"> 65 <code className="vocs_Code">{row.path}</code> 66 </td> 67 <td className="vocs_TableCell"> 68 <code className="vocs_Code">{row.type}</code> 69 </td> 70 <td className="vocs_TableCell">{row.required ? "Yes" : ""}</td> 71 <td className="vocs_TableCell"> 72 {row.default === undefined ? ( 73 "-" 74 ) : ( 75 <code className="vocs_Code"> 76 {typeof row.default === "string" 77 ? `"${row.default}"` 78 : `${row.default}`} 79 </code> 80 )} 81 </td> 82 <td className="vocs_TableCell">{row.description || "—"}</td> 83 </tr> 84 ))} 85 </tbody> 86 </table> 87 ); 88}