Update frontend/dist/assets/api.js

#5
Files changed (1) hide show
  1. frontend/dist/assets/api.js +12 -44
frontend/dist/assets/api.js CHANGED
@@ -1,53 +1,21 @@
1
- /* ============================================================
2
- Elysium API client talks to FastAPI routes on gr.Server.
3
- - Sends multipart/form-data with optional attachments
4
- - Hard-caps at 2 files (server also enforces)
5
- - Surfaces friendly errors so boot.js can toast them
6
- ============================================================ */
7
  window.ElysiumAPI = {
8
  async turn(text, files) {
9
  const fd = new FormData();
10
  fd.append('user_text', text || '');
11
- (files || []).slice(0, 2).forEach(f => fd.append('attachments', f, f.name));
12
  const r = await fetch('/api/turn', { method: 'POST', body: fd });
13
- if (!r.ok) {
14
- let detail = '';
15
- try { detail = (await r.text()).slice(0, 200); } catch {}
16
- throw new Error(`HTTP ${r.status}${detail ? ': ' + detail : ''}`);
17
- }
18
  return r.json();
19
  },
20
-
21
- async health() {
22
- try {
23
- const r = await fetch('/api/health');
24
- if (!r.ok) return { status: 'error' };
25
- return r.json();
26
- } catch { return { status: 'offline' }; }
27
- },
28
-
29
- async hypergraph() {
30
- try {
31
- const r = await fetch('/api/hypergraph');
32
- if (!r.ok) return { nodes: [], edges: [], node_count: 0, edge_count: 0 };
33
- return r.json();
34
- } catch {
35
- return { nodes: [], edges: [], node_count: 0, edge_count: 0 };
36
- }
37
- },
38
-
39
- async nodeDetail(id) {
40
- try {
41
- const r = await fetch('/api/node/' + encodeURIComponent(id));
42
- if (!r.ok) return null;
43
- return r.json();
44
- } catch { return null; }
45
- },
46
-
47
- async reset() {
48
- try {
49
- const r = await fetch('/api/reset', { method: 'POST' });
50
- return r.ok ? r.json() : { status: 'error' };
51
- } catch { return { status: 'offline' }; }
52
  },
 
53
  };
 
1
+ /* Tiny client for /api/* endpoints.
2
+ Supports multiple attachments (max 2 enforced on UI side too). */
 
 
 
 
3
  window.ElysiumAPI = {
4
  async turn(text, files) {
5
  const fd = new FormData();
6
  fd.append('user_text', text || '');
7
+ (files || []).slice(0, 2).forEach(f => fd.append('attachments', f));
8
  const r = await fetch('/api/turn', { method: 'POST', body: fd });
9
+ if (!r.ok) throw new Error('HTTP ' + r.status);
 
 
 
 
10
  return r.json();
11
  },
12
+ async health() { return (await fetch('/api/health')).json(); },
13
+ async hypergraph() { return (await fetch('/api/hypergraph')).json(); },
14
+ async civilizationMap() { return (await fetch('/api/civilization_map')).json(); },
15
+ async nodeDetail(id){
16
+ const r = await fetch('/api/node/' + encodeURIComponent(id));
17
+ if (!r.ok) return null;
18
+ return r.json();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  },
20
+ async reset() { return (await fetch('/api/reset',{method:'POST'})).json(); },
21
  };