@objectql/studio 1.7.2 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,14 +18,14 @@ export function useMetadata() {
18
18
  const [error, setError] = useState<Error | null>(null);
19
19
 
20
20
  useEffect(() => {
21
- fetch('/api/metadata')
21
+ fetch('/api/metadata/object')
22
22
  .then(async res => {
23
23
  if (!res.ok) throw new Error('Failed to fetch metadata');
24
24
  // The API might return { objects: [...] } or just [...]
25
25
  // Assuming standard objectql server returns { objects: [...] } or Array
26
26
  const data = await res.json();
27
27
  // Check format
28
- const list = Array.isArray(data) ? data : (data.objects || []);
28
+ const list = Array.isArray(data) ? data : (data.items || []);
29
29
  setObjects(list);
30
30
  })
31
31
  .catch(err => {
@@ -63,7 +63,7 @@ export function MetadataBrowser() {
63
63
  const data = await res.json();
64
64
  // API returns { [type]: [...] } or for object: { object: [...], objects: [...] }
65
65
  // Handle singular/plural mismatch from API response
66
- const list = data[selectedType] || data.objects || data.object || [];
66
+ const list = data[selectedType] || data.items || [];
67
67
  setItems(list);
68
68
  })
69
69
  .catch(err => setError(err.message))
@@ -98,7 +98,8 @@ export function ObjectView({ objectName }: ObjectViewProps) {
98
98
  })
99
99
  });
100
100
  const resJson = await response.json();
101
- const rows = resJson.data || resJson; // normalize
101
+ // Support new format (items) and old format (data)
102
+ const rows = resJson.items || resJson.data || resJson; // normalize
102
103
 
103
104
  // 4. Fetch Count (for total pagination)
104
105
  // Optimization: Only fetch count if we don't know it or filter changed?
@@ -113,11 +114,14 @@ export function ObjectView({ objectName }: ObjectViewProps) {
113
114
  body: JSON.stringify({
114
115
  op: 'count',
115
116
  object: objectName,
116
- args: filters.length > 0 ? filters : {}
117
+ args: {
118
+ filters: filters.length > 0 ? filters : undefined
119
+ }
117
120
  })
118
121
  });
119
122
  const countJson = await countRes.json();
120
- lastRow = typeof countJson === 'number' ? countJson : countJson.data;
123
+ // Count operation returns { count: number, '@type': string }
124
+ lastRow = typeof countJson === 'number' ? countJson : countJson.count;
121
125
  }
122
126
 
123
127
  params.successCallback(rows, lastRow);