@romedb/studio 0.0.0-stage → 0.1.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.
Files changed (38) hide show
  1. package/LICENSE.md +20 -0
  2. package/README.md +15 -2
  3. package/package.json +36 -4
  4. package/src/components/CodeEditor.ts +298 -0
  5. package/src/components/studio/BrowseTab.ts +457 -0
  6. package/src/components/studio/CellEditorSheet.ts +165 -0
  7. package/src/components/studio/DatabaseTab.ts +148 -0
  8. package/src/components/studio/GraphCanvas.ts +90 -0
  9. package/src/components/studio/GraphTab.ts +110 -0
  10. package/src/components/studio/InsertRowSheet.ts +180 -0
  11. package/src/components/studio/MapCanvas.ts +177 -0
  12. package/src/components/studio/MapTab.ts +121 -0
  13. package/src/components/studio/NewObjectSheet.ts +235 -0
  14. package/src/components/studio/QueryHistorySheet.ts +111 -0
  15. package/src/components/studio/RowSheets.ts +226 -0
  16. package/src/components/studio/SqlConsole.ts +281 -0
  17. package/src/components/studio/StructureTab.ts +209 -0
  18. package/src/components/studio/icon-button.ts +21 -0
  19. package/src/lib/filters.ts +44 -0
  20. package/src/lib/graph.ts +214 -0
  21. package/src/lib/romeql.ts +106 -0
  22. package/src/lib/spatial.ts +518 -0
  23. package/src/lib/sql-text.ts +208 -0
  24. package/src/lib/studio-types.ts +268 -0
  25. package/src/lib/values.ts +305 -0
  26. package/src/monaco-standalone.d.ts +27 -0
  27. package/src/schema-draft.ts +41 -0
  28. package/src/schema-store.ts +8 -0
  29. package/src/server/backend.ts +77 -0
  30. package/src/server/data.ts +142 -0
  31. package/src/server/edits.ts +92 -0
  32. package/src/server/graph.ts +66 -0
  33. package/src/server/queries.ts +108 -0
  34. package/src/server/schema.ts +272 -0
  35. package/src/server/spatial.ts +74 -0
  36. package/src/studio-page.ts +84 -0
  37. package/src/workspace/StudioWorkspace.ts +1984 -0
  38. package/src/workspace/workspace.css +38 -0
@@ -0,0 +1,84 @@
1
+ import type { ValueKind } from './lib/values';
2
+
3
+ export type CellMode = 'null' | 'value';
4
+ export type StudioTab = 'browse' | 'structure' | 'sql' | 'graph' | 'map' | 'database';
5
+ export type InsertMode = 'omit' | 'null' | 'value';
6
+ export type InsertSelection = ValueKind | Exclude<InsertMode, 'value'>;
7
+ export type CellSelection = ValueKind | 'null';
8
+ export type ExportFormat = 'json' | 'csv';
9
+ export type SqlOutput = 'results' | 'graph' | 'map' | 'explain';
10
+
11
+ export interface CellEditor {
12
+ rowIndex: number;
13
+ columnName: string;
14
+ value: string;
15
+ mode: CellMode;
16
+ kind: ValueKind;
17
+ error?: string;
18
+ }
19
+
20
+ export interface RowEditorState {
21
+ rowIndex: number;
22
+ value: string;
23
+ error: string;
24
+ }
25
+
26
+ export interface DeleteTarget {
27
+ table: string;
28
+ rowIndexes: number[];
29
+ }
30
+
31
+ export interface ExportSheetState {
32
+ rowIndexes: number[];
33
+ format: ExportFormat;
34
+ columns: string[];
35
+ collection: boolean;
36
+ }
37
+
38
+ export interface BatchUpdateState {
39
+ column: string;
40
+ mode: CellMode;
41
+ kind: ValueKind;
42
+ value: string;
43
+ error: string;
44
+ }
45
+
46
+ export interface InsertFieldState {
47
+ mode: InsertMode;
48
+ valueKind: ValueKind;
49
+ value: string;
50
+ }
51
+
52
+ export interface QueryHistoryEntry {
53
+ id: string;
54
+ statement: string;
55
+ executedAt: number;
56
+ durationMs: number;
57
+ error: string | null;
58
+ favorite: boolean;
59
+ source: 'browse' | 'sql';
60
+ }
61
+
62
+ /** Pending SQL write awaiting explicit confirmation. */
63
+ export interface WriteConfirmation {
64
+ statements: number;
65
+ source: 'sql' | 'browse' | 'create';
66
+ }
67
+
68
+ export interface NewColumnDraft {
69
+ name: string;
70
+ type: string;
71
+ primary: boolean;
72
+ required: boolean;
73
+ unique: boolean;
74
+ }
75
+
76
+ // A save is sent only if the database is still at the revision the editor
77
+ // loaded. A rejection (validation, constraint) leaves the data unchanged but
78
+ // still records one failure receipt, so the database moves to revision + 1.
79
+ // Only then is it safe to keep editing on the new revision; any other change
80
+ // means someone else wrote and the editor must reload.
81
+ export function revisionAfterRejectedWrite(loaded: number, error: { code: string; outcome: string; sequence?: number }): number | undefined {
82
+ if (error.outcome !== 'rolled-back' || error.code === 'RDB_CONFLICT') return undefined;
83
+ return error.sequence === loaded + 1 ? error.sequence : undefined;
84
+ }