Repository navigation
Expand file tree
/
Copy pathapp.html
More file actions
1414 lines (1257 loc) · 52.9 KB
/
Copy pathapp.html
File metadata and controls
1414 lines (1257 loc) · 52.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ColtaneDB Console — Multi-Model Studio & Dashboard</title>
<meta name="description" content="Official ColtaneDB Web Console. Execute Colt queries, architect multi-model schemas, inspect live records, and manage tenant API keys.">
<meta name="theme-color" content="#08090c">
<!-- Favicons -->
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/svg+xml" href="/coltanedb-logo.svg">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="manifest" href="/site.webmanifest">
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--bg: #08090c;
--surface: #0e1117;
--card-bg: rgba(18, 22, 31, 0.75);
--border: rgba(255, 255, 255, 0.08);
--border-glow: rgba(56, 189, 248, 0.3);
--text: #f1f5f9;
--text-muted: #94a3b8;
--text-dim: #64748b;
--accent: #38bdf8;
--accent-soft: rgba(56, 189, 248, 0.12);
--emerald: #34d399;
--emerald-soft: rgba(52, 211, 153, 0.12);
--rose: #f43f5e;
--rose-soft: rgba(244, 63, 94, 0.12);
--code-bg: #07090e;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-color: var(--bg);
color: var(--text);
font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
min-height: 100vh;
display: flex;
flex-direction: column;
background-image:
radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.08), transparent 50%),
radial-gradient(circle at 100% 100%, rgba(52, 211, 153, 0.05), transparent 40%);
background-attachment: fixed;
}
a {
color: var(--accent);
text-decoration: none;
transition: color 0.15s ease;
}
a:hover {
color: #7dd3fc;
text-decoration: underline;
}
/* Top App Bar */
.app-header {
position: sticky;
top: 0;
z-index: 100;
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
background: rgba(8, 9, 12, 0.9);
border-bottom: 1px solid var(--border);
padding: 0.65rem 1.5rem;
display: flex;
align-items: center;
justify-content: space-between;
}
.header-left {
display: flex;
align-items: center;
gap: 1.5rem;
}
.brand {
display: flex;
align-items: center;
gap: 0.65rem;
color: var(--text);
text-decoration: none;
}
.brand strong {
font-family: 'Space Grotesk', sans-serif;
font-size: 17px;
font-weight: 700;
letter-spacing: -0.02em;
}
.project-badge {
display: inline-flex;
align-items: center;
gap: 0.4rem;
padding: 0.25rem 0.6rem;
background: rgba(255, 255, 255, 0.04);
border: 1px solid var(--border);
border-radius: 6px;
font-size: 12px;
color: var(--text-muted);
font-family: 'JetBrains Mono', monospace;
}
.project-badge-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--emerald);
box-shadow: 0 0 8px var(--emerald);
}
.header-right {
display: flex;
align-items: center;
gap: 1rem;
}
.user-pill {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.3rem 0.75rem;
background: rgba(255, 255, 255, 0.05);
border: 1px solid var(--border);
border-radius: 9999px;
font-size: 12.5px;
color: var(--text);
}
.btn {
display: inline-flex;
align-items: center;
gap: 0.45rem;
padding: 0.45rem 0.85rem;
border-radius: 8px;
font-size: 13px;
font-weight: 600;
cursor: pointer;
border: 1px solid var(--border);
background: rgba(255, 255, 255, 0.05);
color: var(--text);
transition: all 0.2s ease;
text-decoration: none;
min-height: 36px;
}
.btn:hover {
background: rgba(255, 255, 255, 0.1);
border-color: rgba(255, 255, 255, 0.2);
text-decoration: none;
}
.btn-sm {
padding: 0.35rem 0.65rem;
font-size: 12px;
min-height: 30px;
}
.btn-primary {
background: linear-gradient(135deg, #0284c7, #0ea5e9);
border-color: #38bdf8;
color: #ffffff;
box-shadow: 0 0 12px rgba(14, 165, 233, 0.3);
}
.btn-primary:hover {
background: linear-gradient(135deg, #0369a1, #0284c7);
box-shadow: 0 0 18px rgba(14, 165, 233, 0.5);
}
/* Sub-nav Tabs */
.app-tabs {
background: rgba(14, 17, 23, 0.75);
border-bottom: 1px solid var(--border);
padding: 0 1.5rem;
display: flex;
gap: 0.25rem;
overflow-x: auto;
}
.tab-btn {
background: transparent;
border: none;
border-bottom: 2px solid transparent;
padding: 0.75rem 1rem;
font-size: 13.5px;
font-weight: 600;
color: var(--text-muted);
cursor: pointer;
display: flex;
align-items: center;
gap: 0.45rem;
transition: all 0.15s ease;
white-space: nowrap;
}
.tab-btn:hover {
color: var(--text);
}
.tab-btn.active {
color: var(--accent);
border-bottom-color: var(--accent);
background: rgba(56, 189, 248, 0.04);
}
/* Main Workspace Views */
.app-viewport {
flex: 1;
padding: 1.5rem;
max-width: 1400px;
margin: 0 auto;
width: 100%;
}
.view-panel {
display: none;
}
.view-panel.active {
display: block;
animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(4px); }
to { opacity: 1; transform: translateY(0); }
}
/* Cards & Grids */
.card {
background: var(--card-bg);
border: 1px solid var(--border);
border-radius: 12px;
padding: 1.25rem;
backdrop-filter: blur(12px);
margin-bottom: 1.25rem;
}
.grid-metrics {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 1rem;
margin-bottom: 1.5rem;
}
.metric-card {
background: rgba(255, 255, 255, 0.03);
border: 1px solid var(--border);
border-radius: 10px;
padding: 1.15rem;
}
.metric-label {
font-size: 12px;
font-weight: 600;
color: var(--text-dim);
text-transform: uppercase;
letter-spacing: 0.05em;
margin-bottom: 0.4rem;
}
.metric-value {
font-family: 'Space Grotesk', sans-serif;
font-size: 26px;
font-weight: 700;
color: var(--text);
}
.metric-sub {
font-size: 12px;
color: var(--emerald);
margin-top: 0.35rem;
}
/* Studio / Editor Layout */
.studio-layout {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1.25rem;
min-height: 600px;
}
@media (max-width: 960px) {
.studio-layout {
grid-template-columns: 1fr;
}
}
.editor-pane, .output-pane {
display: flex;
flex-direction: column;
background: var(--code-bg);
border: 1px solid var(--border);
border-radius: 12px;
overflow: hidden;
}
.pane-toolbar {
background: rgba(255, 255, 255, 0.03);
border-bottom: 1px solid var(--border);
padding: 0.6rem 1rem;
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
flex-wrap: wrap;
}
.code-textarea {
flex: 1;
width: 100%;
min-height: 480px;
background: transparent;
border: none;
color: #93c5fd;
font-family: 'JetBrains Mono', monospace;
font-size: 13.5px;
line-height: 1.6;
padding: 1rem;
resize: vertical;
outline: none;
}
.output-tabs {
display: flex;
gap: 0.25rem;
}
.output-tab-btn {
background: transparent;
border: none;
color: var(--text-dim);
padding: 0.3rem 0.65rem;
font-size: 12px;
font-weight: 600;
cursor: pointer;
border-radius: 4px;
}
.output-tab-btn.active {
background: rgba(255, 255, 255, 0.1);
color: var(--text);
}
.output-content {
flex: 1;
padding: 1rem;
font-family: 'JetBrains Mono', monospace;
font-size: 12.5px;
overflow: auto;
color: #e2e8f0;
max-height: 520px;
}
/* Table Explorer */
.table-explorer-layout {
display: grid;
grid-template-columns: 240px 1fr;
gap: 1.25rem;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
overflow: hidden;
min-height: 550px;
}
@media (max-width: 768px) {
.table-explorer-layout {
grid-template-columns: 1fr;
}
}
.collection-sidebar {
background: rgba(0, 0, 0, 0.25);
border-right: 1px solid var(--border);
padding: 1rem;
display: flex;
flex-direction: column;
gap: 0.35rem;
}
.collection-item {
padding: 0.6rem 0.85rem;
border-radius: 8px;
font-size: 13px;
font-weight: 600;
color: var(--text-muted);
cursor: pointer;
display: flex;
align-items: center;
justify-content: space-between;
transition: all 0.15s ease;
}
.collection-item:hover {
background: rgba(255, 255, 255, 0.05);
color: var(--text);
}
.collection-item.active {
background: var(--accent-soft);
border: 1px solid var(--border-glow);
color: var(--accent);
}
.table-view-area {
display: flex;
flex-direction: column;
}
.table-view-toolbar {
padding: 0.75rem 1.25rem;
border-bottom: 1px solid var(--border);
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
flex-wrap: wrap;
}
.data-table-wrap {
flex: 1;
overflow: auto;
padding: 1rem;
}
.data-table {
width: 100%;
border-collapse: collapse;
font-size: 13px;
text-align: left;
}
.data-table th {
background: rgba(255, 255, 255, 0.03);
padding: 0.65rem 0.85rem;
border-bottom: 1px solid var(--border);
color: var(--text-dim);
font-size: 11.5px;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.data-table td {
padding: 0.75rem 0.85rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
color: var(--text);
font-family: 'JetBrains Mono', monospace;
font-size: 12.5px;
}
.data-table tr:hover {
background: rgba(255, 255, 255, 0.02);
}
/* Modal */
.modal-backdrop {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.75);
backdrop-filter: blur(8px);
z-index: 200;
display: none;
align-items: center;
justify-content: center;
padding: 1rem;
}
.modal-box {
width: 100%;
max-width: 520px;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 14px;
padding: 1.5rem;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}
.form-input {
width: 100%;
background: var(--code-bg);
border: 1px solid var(--border);
border-radius: 8px;
padding: 0.6rem 0.85rem;
color: var(--text);
font-size: 13px;
outline: none;
min-height: 40px;
}
.form-input:focus {
border-color: var(--accent);
}
/* Toast Notification */
#toast-container {
position: fixed;
bottom: 1.5rem;
right: 1.5rem;
z-index: 300;
display: flex;
flex-direction: column;
</style>
<!-- Firebase Web SDK Modular (v10) -->
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.0/firebase-app.js";
import {
getAuth,
onAuthStateChanged,
signOut
} from "https://www.gstatic.com/firebasejs/10.12.0/firebase-auth.js";
import {
getFirestore,
collection,
doc,
getDocs,
setDoc,
deleteDoc
} from "https://www.gstatic.com/firebasejs/10.12.0/firebase-firestore.js";
// Public Firebase Web Client Config for coltanedb
const firebaseConfig = {
apiKey: "AIzaSyColtaneDBProductionKeyPlaceholder",
projectId: "coltanedb",
appId: "1:573404384111:web:9add23b082210d273b769a",
authDomain: "coltanedb.firebaseapp.com",
storageBucket: "coltanedb.firebasestorage.app",
messagingSenderId: "573404384111"
};
try {
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const db = getFirestore(app);
window._firebaseApp = app;
window._firebaseAuth = auth;
window._firestoreDb = db;
// Monitor Auth State
onAuthStateChanged(auth, (user) => {
if (user) {
console.log("Console active user:", user.email, user.uid);
const emailDisplay = document.getElementById('user-email-display');
const emailInput = document.getElementById('settings-user-email');
if (emailDisplay && user.email) emailDisplay.textContent = user.email;
if (emailInput && user.email) emailInput.value = user.email;
}
});
} catch (e) {
console.warn("Firebase client init notice in app:", e);
}
</script>
</head>
<body>
<!-- Top App Navigation -->
<header class="app-header">
<div class="header-left">
<a href="/app" class="brand" aria-label="ColtaneDB Console">
<svg style="width:24px; height:24px;" viewBox="0 0 100 100" fill="none">
<polygon points="50,15 82,33 50,51 18,33" fill="#38bdf8"/>
<polygon points="18,33 50,51 50,85 18,67" fill="#131c2e" stroke="#38bdf8" stroke-width="2"/>
<polygon points="50,51 82,33 82,67 50,85" fill="#0d1420" stroke="#3ecf8e" stroke-width="2"/>
</svg>
<strong>ColtaneDB Console</strong>
</a>
<div class="project-badge" title="Active Isolated Workspace">
<span class="project-badge-dot"></span>
<span id="header-tenant-display">Tenant: tnt_••••••••</span>
</div>
</div>
<div class="header-right">
<a href="/docs" class="btn btn-sm">📖 Docs</a>
<div class="user-pill" id="user-pill">
<span style="font-size:14px;">👤</span>
<span id="user-email-display">developer@coltanedb.dev</span>
</div>
<button class="btn btn-sm" onclick="handleSignOut()">Sign Out</button>
</div>
</header>
<!-- Navigation Tabs -->
<nav class="app-tabs" aria-label="Console Views">
<button class="tab-btn active" data-tab="dashboard" onclick="switchConsoleTab('dashboard')">📊 Dashboard</button>
<button class="tab-btn" data-tab="studio" onclick="switchConsoleTab('studio')">⚡ Colt Editor (Studio)</button>
<button class="tab-btn" data-tab="builder" onclick="switchConsoleTab('builder')">🎨 Schema Designer</button>
<button class="tab-btn" data-tab="table" onclick="switchConsoleTab('table')">📋 Table Explorer</button>
<button class="tab-btn" data-tab="settings" onclick="switchConsoleTab('settings')">⚙️ Settings & Keys</button>
</nav>
<!-- Main Viewport -->
<main class="app-viewport">
<!-- ══════════════════════════════════════════════════════
TAB 1: DASHBOARD OVERVIEW
══════════════════════════════════════════════════════ -->
<section class="view-panel active" id="panel-dashboard">
<div class="grid-metrics">
<div class="metric-card">
<div class="metric-label">Active Storage Engines</div>
<div class="metric-value">4 Online</div>
<div class="metric-sub">Upstash Redis, Postgres, Supabase, Firestore</div>
</div>
<div class="metric-card">
<div class="metric-label">Daily Queries Executed</div>
<div class="metric-value" id="metric-queries">28</div>
<div class="metric-sub">Under TenantGuard Isolation</div>
</div>
<div class="metric-card">
<div class="metric-label">Active Collections</div>
<div class="metric-value" id="metric-collections">4</div>
<div class="metric-sub">books, authors, users, metrics</div>
</div>
<div class="metric-card">
<div class="metric-label">Average Compiler Latency</div>
<div class="metric-value">1.2 ms</div>
<div class="metric-sub">JIT AST & Plan Optimizer</div>
</div>
</div>
<!-- Live API Key & Tenant Card -->
<div class="card">
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:1rem;">
<h3 style="font-family:'Space Grotesk', sans-serif; font-size:16px;">Production Tenant & API Key</h3>
<button class="btn btn-sm btn-primary" onclick="generateNewApiKey()">+ Generate New Key</button>
</div>
<p style="font-size:13px; color:var(--text-muted); margin-bottom:1rem;">
Your tenant ID and API key isolate all queries, collections, and execution steps. Use this key in client SDKs or curl commands.
</p>
<div style="display:grid; grid-template-columns:repeat(auto-fit, minmax(300px, 1fr)); gap:1rem;">
<div style="background:var(--code-bg); border:1px solid var(--border); border-radius:8px; padding:0.85rem 1rem;">
<div style="font-size:11px; color:var(--text-dim); text-transform:uppercase; margin-bottom:0.25rem;">Tenant ID</div>
<div style="display:flex; justify-content:space-between; align-items:center;">
<code id="card-tenant-id" style="color:var(--emerald);">tnt_loading...</code>
<button class="btn btn-sm" onclick="copyTenantId()">Copy</button>
</div>
</div>
<div style="background:var(--code-bg); border:1px solid var(--border); border-radius:8px; padding:0.85rem 1rem;">
<div style="font-size:11px; color:var(--text-dim); text-transform:uppercase; margin-bottom:0.25rem;">Live API Token</div>
<div style="display:flex; justify-content:space-between; align-items:center;">
<code id="card-api-key" style="color:var(--accent);">clt_live_loading...</code>
<button class="btn btn-sm" onclick="copyApiKey()">Copy</button>
</div>
</div>
</div>
</div>
<!-- Quickstart Code Snippet -->
<div class="card">
<h3 style="font-family:'Space Grotesk', sans-serif; font-size:16px; margin-bottom:0.75rem;">Programmatic Integration (Python & REST)</h3>
<p style="font-size:13px; color:var(--text-muted); margin-bottom:0.75rem;">
Query your multi-model backend directly from Python or any standard HTTP client:
</p>
<pre style="background:var(--code-bg); border:1px solid var(--border); border-radius:8px; padding:1rem; font-family:'JetBrains Mono', monospace; font-size:12.5px; color:#93c5fd; overflow:auto;">
from coltanedb import ColtaneClient
client = ColtaneClient(
api_key="<span id="snippet-api-key">clt_live_your_key_here</span>",
base_url="https://coltanedb.vercel.app"
)
# Run raw Colt queries with TenantGuard
res = client.query("""
FIND books SELECT id, title, rating
WHERE rating >= 4.5
LIMIT 10
""")
print(res.data)
</pre>
</div>
</section>
<!-- ══════════════════════════════════════════════════════
TAB 2: COLT EDITOR (STUDIO)
══════════════════════════════════════════════════════ -->
<section class="view-panel" id="panel-studio">
<div class="studio-layout">
<!-- Left: Code Editor -->
<div class="editor-pane">
<div class="pane-toolbar">
<div style="display:flex; align-items:center; gap:0.5rem;">
<select id="template-select" class="form-input" style="min-height:32px; padding:0.2rem 0.5rem; font-size:12px;" onchange="loadEditorTemplate(this.value)">
<option value="define">Template: Define Collection</option>
<option value="insert">Template: Insert Record (PUT)</option>
<option value="find" selected>Template: Query / Filter (FIND)</option>
<option value="firestore">Template: Firebase Firestore Documents</option>
<option value="redis">Template: Upstash Redis KV Read</option>
</select>
</div>
<div style="display:flex; align-items:center; gap:0.4rem;">
<!-- Working Import & Export Buttons -->
<button class="btn btn-sm" id="btn-export-colt" onclick="exportColtFile()">Export .colt</button>
<button class="btn btn-sm" id="btn-import-colt" onclick="triggerColtImport()">Import .colt</button>
<input type="file" id="file-import-input" accept=".colt,.txt" style="display:none;" onchange="handleColtFileSelected(event)">
<button class="btn btn-sm" id="studio-plan-btn" onclick="runStudioPlan()">Compile Plan</button>
<button class="btn btn-sm btn-primary" id="studio-run-btn" onclick="runLiveExecution()">⚡ Run Query</button>
</div>
</div>
<textarea id="studio-editor" class="code-textarea" spellcheck="false" placeholder="Write Colt code here..."></textarea>
</div>
<!-- Right: Execution & Output Panel -->
<div class="output-pane">
<div class="pane-toolbar">
<div class="output-tabs">
<button class="output-tab-btn active" data-output-tab="results" onclick="setStudioOutputTab('results')">Results</button>
<button class="output-tab-btn" data-output-tab="plan" onclick="setStudioOutputTab('plan')">Plan Steps</button>
<button class="output-tab-btn" data-output-tab="diagnostics" onclick="setStudioOutputTab('diagnostics')">Diagnostics & AST</button>
</div>
<span id="exec-status-badge" style="font-size:11px; padding:2px 8px; border-radius:4px; background:var(--emerald-soft); color:var(--emerald); font-family:'JetBrains Mono', monospace;">Ready</span>
</div>
<pre class="output-content" id="studio-output-area"></pre>
</div>
</div>
</section>
<!-- ══════════════════════════════════════════════════════
TAB 3: SCHEMA DESIGNER (GUI BUILDER)
══════════════════════════════════════════════════════ -->
<section class="view-panel" id="panel-builder">
<div class="card" style="display:grid; grid-template-columns:1fr 1fr; gap:1.5rem;">
<!-- Left: Visual Designer Controls -->
<div>
<h3 style="font-family:'Space Grotesk', sans-serif; font-size:18px; margin-bottom:1rem;">Visual Collection Architect</h3>
<div style="display:grid; grid-template-columns:1fr 1fr; gap:0.75rem; margin-bottom:1rem;">
<div>
<label style="font-size:12px; font-weight:600; color:var(--text-muted); display:block; margin-bottom:0.25rem;">Collection Name</label>
<input type="text" id="builder-col-name" class="form-input" value="products" oninput="updateSchemaPreview()">
</div>
<div>
<label style="font-size:12px; font-weight:600; color:var(--text-muted); display:block; margin-bottom:0.25rem;">Backend Placement</label>
<select id="builder-col-backend" class="form-input" onchange="updateSchemaPreview()">
<option value="neon" selected>Neon Postgres (@backend(neon))</option>
<option value="supabase">Supabase Postgres (@backend(supabase))</option>
<option value="redis">Upstash Redis (@backend(redis))</option>
<option value="firestore">Firebase Firestore (@backend(firestore))</option>
<option value="turso">Turso SQLite (@backend(turso))</option>
</select>
</div>
</div>
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:0.5rem;">
<strong style="font-size:13px;">Fields & Directives</strong>
<button class="btn btn-sm" onclick="addBuilderField()">+ Add Field</button>
</div>
<div id="builder-fields-container" style="display:flex; flex-direction:column; gap:0.5rem; max-height:320px; overflow:auto; margin-bottom:1rem;">
<!-- Fields generated dynamically -->
</div>
</div>
<!-- Right: Generated Code & Export -->
<div style="display:flex; flex-direction:column;">
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:0.5rem;">
<strong style="font-size:13px;">Generated .colt Declaration</strong>
<div style="display:flex; gap:0.4rem;">
<button class="btn btn-sm" id="gui-download-btn" onclick="downloadSchemaColt()">Download .colt</button>
<button class="btn btn-sm btn-primary" onclick="copySchemaToEditor()">Send to Editor</button>
</div>
</div>
<pre id="gui-code-preview" style="flex:1; background:var(--code-bg); border:1px solid var(--border); border-radius:8px; padding:1rem; font-family:'JetBrains Mono', monospace; font-size:13px; color:#93c5fd; overflow:auto;"></pre>
</div>
</div>
</section>
<!-- ══════════════════════════════════════════════════════
TAB 4: TABLE EXPLORER (LIVE DATA)
══════════════════════════════════════════════════════ -->
<section class="view-panel" id="panel-table">
<div class="table-explorer-layout">
<!-- Sidebar: Collections -->
<div class="collection-sidebar">
<div style="font-size:11px; font-weight:700; color:var(--text-dim); text-transform:uppercase; margin-bottom:0.5rem;">Collections</div>
<div class="collection-item active" data-table="books" onclick="selectCollection('books')">📚 books</div>
<div class="collection-item" data-table="authors" onclick="selectCollection('authors')">✍️ authors</div>
<div class="collection-item" data-table="users" onclick="selectCollection('users')">👥 users</div>
<div class="collection-item" data-table="firestore_docs" onclick="selectCollection('firestore_docs')">🔥 firestore_docs</div>
<div class="collection-item" data-table="metrics" onclick="selectCollection('metrics')">📈 metrics</div>
<div class="collection-item" data-table="inventory" onclick="selectCollection('inventory')">📦 inventory</div>
</div>
<!-- Main Data View -->
<div class="table-view-area">
<div class="table-view-toolbar">
<div style="display:flex; align-items:center; gap:0.75rem;">
<strong id="table-collection-title" style="font-family:'Space Grotesk', sans-serif; font-size:16px;">books</strong>
<span style="font-size:11px; padding:2px 6px; background:var(--accent-soft); color:var(--accent); border-radius:4px; font-family:'JetBrains Mono', monospace;">TENANT ISOLATED</span>
</div>
<div style="display:flex; align-items:center; gap:0.5rem;">
<input type="text" id="table-search-input" class="form-input" style="min-height:34px; padding:0.2rem 0.6rem; font-size:12.5px;" placeholder="Filter rows..." oninput="filterTableRows(this.value)">
<button class="btn btn-sm" onclick="exportTableData()">Export JSON</button>
<button class="btn btn-sm btn-primary" id="btn-open-insert-row" onclick="openInsertModal()">+ Insert Record</button>
</div>
</div>
<div class="data-table-wrap" id="data-table-mount">
<!-- Rendered Table -->
</div>
</div>
</div>
</section>
<!-- ══════════════════════════════════════════════════════
TAB 5: SETTINGS & TENANT MANAGEMENT
══════════════════════════════════════════════════════ -->
<section class="view-panel" id="panel-settings">
<div class="card">
<h3 style="font-family:'Space Grotesk', sans-serif; font-size:18px; margin-bottom:1rem;">Workspace & Tenant Configuration</h3>
<div class="form-group" style="margin-bottom:1rem;">
<label style="font-size:12px; font-weight:600; color:var(--text-muted); display:block; margin-bottom:0.25rem;">Active Tenant ID</label>
<div style="display:flex; gap:0.5rem; max-width:480px;">
<input type="text" id="settings-tenant-input" class="form-input" readonly value="tnt_..." style="font-family:'JetBrains Mono', monospace;">
<button class="btn btn-sm" onclick="copyTenantId()">Copy</button>
</div>
</div>
<div class="form-group" style="margin-bottom:1.5rem;">
<label style="font-size:12px; font-weight:600; color:var(--text-muted); display:block; margin-bottom:0.25rem;">Owner Account</label>
<input type="text" id="settings-user-email" class="form-input" readonly value="developer@coltanedb.dev" style="max-width:480px;">
</div>
<h4 style="font-size:14px; color:var(--rose); margin-bottom:0.5rem;">Danger Zone</h4>
<p style="font-size:12.5px; color:var(--text-muted); margin-bottom:0.75rem;">
Purging this tenant will delete all isolated collections and reset stored tables.
</p>
<button class="btn btn-sm" style="border-color:rgba(244,63,94,0.4); color:var(--rose);" onclick="purgeTenantData()">Purge Workspace Records</button>
</div>
</section>
</main>
<!-- Insert Record Modal -->
<div class="modal-backdrop" id="insert-row-modal">
<div class="modal-box">
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:1rem;">
<h3 style="font-family:'Space Grotesk', sans-serif; font-size:16px;">Insert New Record</h3>
<button class="btn btn-sm" onclick="closeInsertModal()">✕</button>
</div>
<div class="form-group" style="margin-bottom:0.75rem;">
<label style="font-size:12px; font-weight:600; color:var(--text-muted); display:block; margin-bottom:0.25rem;">Record Key / ID</label>
<input type="text" id="insert-row-key" class="form-input" placeholder="rec_101">
</div>
<div class="form-group" style="margin-bottom:1rem;">
<label style="font-size:12px; font-weight:600; color:var(--text-muted); display:block; margin-bottom:0.25rem;">JSON Data Payload</label>
<textarea id="insert-row-json" class="form-input" style="min-height:110px; font-family:'JetBrains Mono', monospace; font-size:12.5px;" placeholder='{"title": "The Art of Multi-Model", "rating": 4.9}'></textarea>
</div>
<div style="display:flex; justify-content:flex-end; gap:0.5rem;">
<button class="btn btn-sm" onclick="closeInsertModal()">Cancel</button>
<button class="btn btn-sm btn-primary" id="btn-confirm-insert" onclick="confirmInsertRecord()">Insert Record</button>
</div>
</div>
</div>
<!-- Toast Container -->
<div id="toast-container"></div>
<script>
// Session State Management
let session = {
tenantId: 'tnt_default',
apiKey: 'clt_live_demo',
email: 'developer@coltanedb.dev'
};
try {
const stored = localStorage.getItem('coltane_session');
if (stored) {
session = JSON.parse(stored);
} else {
session.tenantId = localStorage.getItem('coltane_tenant_v1') || 'tnt_prod_' + Math.random().toString(36).substring(2, 9);
session.apiKey = localStorage.getItem('coltane_apikey_v1') || 'clt_live_' + Math.random().toString(36).substring(2, 14);
session.email = localStorage.getItem('coltane_user_v1') || 'developer@coltanedb.dev';
localStorage.setItem('coltane_session', JSON.stringify(session));
}
} catch (e) {
console.warn("Session read notice:", e);
}
// Populate displays
document.getElementById('header-tenant-display').textContent = 'Tenant: ' + session.tenantId.substring(0, 8) + '••••';
document.getElementById('card-tenant-id').textContent = session.tenantId;
document.getElementById('card-api-key').textContent = session.apiKey;
document.getElementById('snippet-api-key').textContent = session.apiKey;
document.getElementById('user-email-display').textContent = session.email;
document.getElementById('settings-tenant-input').value = session.tenantId;
document.getElementById('settings-user-email').value = session.email;
// Tab Navigation
function switchConsoleTab(tabName) {
document.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('active'));
document.querySelectorAll('.view-panel').forEach(p => p.classList.remove('active'));
const activeBtn = document.querySelector(`.tab-btn[data-tab="${tabName}"]`);
const activePanel = document.getElementById(`panel-${tabName}`);
if (activeBtn) activeBtn.classList.add('active');
if (activePanel) activePanel.classList.add('active');
if (tabName === 'table') renderTable();
if (tabName === 'builder') updateSchemaPreview();
}
// Toast Notification Helper
function showToast(msg) {
const c = document.getElementById('toast-container');
const t = document.createElement('div');
t.style.cssText = 'background:var(--surface); border:1px solid var(--border-glow); padding:0.6rem 1rem; border-radius:8px; font-size:12.5px; box-shadow:0 10px 25px rgba(0,0,0,0.5); color:var(--text);';
t.textContent = msg;
c.appendChild(t);
setTimeout(() => {
t.style.opacity = '0';
t.style.transition = 'opacity 0.25s ease';
setTimeout(() => t.remove(), 250);
}, 3000);
}
// Copy Helpers
function copyTenantId() {
navigator.clipboard.writeText(session.tenantId);
showToast('Tenant ID copied to clipboard!');
}
function copyApiKey() {
navigator.clipboard.writeText(session.apiKey);
showToast('API Key copied to clipboard!');
}
function generateNewApiKey() {
session.apiKey = 'clt_live_' + Math.random().toString(36).substring(2, 14);
localStorage.setItem('coltane_session', JSON.stringify(session));
localStorage.setItem('coltane_apikey_v1', session.apiKey);
document.getElementById('card-api-key').textContent = session.apiKey;
document.getElementById('snippet-api-key').textContent = session.apiKey;
showToast('New live API Key generated!');
}
async function handleSignOut() {
if (window._firebaseAuth) {
try {
const { signOut } = await import("https://www.gstatic.com/firebasejs/10.12.0/firebase-auth.js");
await signOut(window._firebaseAuth);
} catch (_) {}
}
localStorage.removeItem('coltane_session');
window.location.href = '/login';
}
// ══════════════════════════════════════════════════════
// STUDIO & COMPILER LOGIC
// ══════════════════════════════════════════════════════
const studioEditor = document.getElementById('studio-editor');
const outputArea = document.getElementById('studio-output-area');
let currentOutputTab = 'results';
let lastExecResult = null;
const templates = {
find: `// Multi-Model Query under TenantGuard
DEFINE COLLECTION books STRICT @backend(neon) {
id: text @key,
title: text,
author: text,
rating: float @default(4.0)
}
FIND books SELECT id, title, author, rating
WHERE rating >= 4.0
ORDER BY rating DESC
LIMIT 5`,
define: `DEFINE COLLECTION inventory STRICT @backend(neon) {
sku: text @key,