Skip to content

Commit 6ef0da7

Browse files
Copilothotlong
andcommitted
refactor: address code review feedback - extract constants, improve naming
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent bb58f4d commit 6ef0da7

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

ROADMAP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ Final polish and advanced features.
759759
- [ ] Page Builder — drag-and-drop page designer with element palette (see [Gap Analysis](docs/design/airtable-interface-gap-analysis.md))
760760
- [x] Flow Builder Protocol — canvas node shapes, edge styles, BPMN node descriptors (parallel_gateway, join_gateway, boundary_event, wait), layout algorithms, palette categories (`studio/flow-builder.zod.ts`)
761761
- [ ] Flow Builder Runtime — visual automation flow editor with drag-and-drop canvas, node palette, property panel, minimap
762+
- [x] Global REST API Console — auto-discover all registered REST APIs, grouped endpoint tree with search/filter, request/response panel with history and replay (`ApiConsolePage`, `useApiDiscovery`)
762763
- [ ] Security Console — permission matrix, RLS policy editor
763764
- [ ] AI Playground — agent testing, NLQ sandbox
764765
- [ ] Code Editor — Monaco-based TypeScript editing with live preview

apps/studio/src/hooks/use-api-discovery.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export interface EndpointGroup {
2323

2424
// ─── Static system endpoints ────────────────────────────────────────
2525

26+
/** Metadata types that should be excluded from the endpoint tree */
27+
const EXCLUDED_META_TYPES = ['plugin', 'plugins', 'kind', 'package'];
28+
2629
const SYSTEM_ENDPOINTS: EndpointDef[] = [
2730
{ method: 'GET', path: '/api/v1/discovery', desc: 'API Discovery', group: 'System' },
2831
{ method: 'GET', path: '/api/v1/meta/types', desc: 'List metadata types', group: 'Metadata' },
@@ -91,7 +94,7 @@ export function useApiDiscovery() {
9194

9295
// 4. Build metadata endpoints for each type
9396
const metaEndpoints: EndpointDef[] = metaTypes
94-
.filter(t => !['plugin', 'plugins', 'kind', 'package'].includes(t))
97+
.filter(t => !EXCLUDED_META_TYPES.includes(t))
9598
.map(type => ({
9699
method: 'GET' as HttpMethod,
97100
path: `/api/v1/meta/${type}`,
@@ -124,12 +127,12 @@ export function useApiDiscovery() {
124127
groupMap.set(ep.group, existing);
125128
}
126129

127-
// Sort groups: System, Auth, Metadata, then Data groups alphabetically
128-
const ORDER = ['System', 'Auth', 'Metadata'];
130+
// Sort groups: System, Auth, Metadata first, then Data groups alphabetically
131+
const GROUP_SORT_ORDER = ['System', 'Auth', 'Metadata'];
129132
const grouped = Array.from(groupMap.entries())
130133
.sort(([a], [b]) => {
131-
const aIdx = ORDER.indexOf(a);
132-
const bIdx = ORDER.indexOf(b);
134+
const aIdx = GROUP_SORT_ORDER.indexOf(a);
135+
const bIdx = GROUP_SORT_ORDER.indexOf(b);
133136
if (aIdx !== -1 && bIdx !== -1) return aIdx - bIdx;
134137
if (aIdx !== -1) return -1;
135138
if (bIdx !== -1) return 1;

0 commit comments

Comments
 (0)