@rebasepro/studio 0.17.3 → 0.18.1
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.
- package/LICENSE +0 -1
- package/README.md +12 -4
- package/dist/{ApiKeysView-DiCurTEU.js → ApiKeysView-EIvegrUk.js} +54 -39
- package/dist/ApiKeysView-EIvegrUk.js.map +1 -0
- package/dist/{BackupsView-DNS6LdVg.js → BackupsView-DVkKzaPR.js} +29 -31
- package/dist/BackupsView-DVkKzaPR.js.map +1 -0
- package/dist/{BranchesView-CM3B-ER3.js → BranchesView-Df8hQ8wE.js} +85 -24
- package/dist/BranchesView-Df8hQ8wE.js.map +1 -0
- package/dist/{CronJobsView-BHtJZeJZ.js → CronJobsView-CLOGjb-L.js} +32 -27
- package/dist/CronJobsView-CLOGjb-L.js.map +1 -0
- package/dist/{RLSEditor-CBX4uD66.js → RLSEditor-Sa1D34ny.js} +724 -615
- package/dist/RLSEditor-Sa1D34ny.js.map +1 -0
- package/dist/{SQLEditor-ByecwX8B.js → SQLEditor-BfNA8xM3.js} +9 -4
- package/dist/{SQLEditor-ByecwX8B.js.map → SQLEditor-BfNA8xM3.js.map} +1 -1
- package/dist/{SchemaVisualizer-D6tMZgeC.js → SchemaVisualizer-DTDMYL6o.js} +84 -110
- package/dist/SchemaVisualizer-DTDMYL6o.js.map +1 -0
- package/dist/{StorageView-BGDeC5GI.js → StorageView-Ed9Q_VlB.js} +5 -32
- package/dist/StorageView-Ed9Q_VlB.js.map +1 -0
- package/dist/components/RLSEditor/saveRules.d.ts +38 -0
- package/dist/components/RebaseStudio.d.ts +1 -1
- package/dist/components/SchemaVisualizer/schema-visualizer.utils.d.ts +5 -2
- package/dist/components/SchemaVisualizer/useSchemaGraph.d.ts +0 -4
- package/dist/components/load-failure-view.d.ts +17 -0
- package/dist/components/load-failure.d.ts +47 -0
- package/dist/index.es.js +56 -36
- package/dist/index.es.js.map +1 -1
- package/dist/load-failure-C6OMJSGC.js +31 -0
- package/dist/load-failure-C6OMJSGC.js.map +1 -0
- package/dist/load-failure-view-CBTB_h-h.js +48 -0
- package/dist/load-failure-view-CBTB_h-h.js.map +1 -0
- package/package.json +36 -21
- package/dist/ApiKeysView-DiCurTEU.js.map +0 -1
- package/dist/BackupsView-DNS6LdVg.js.map +0 -1
- package/dist/BranchesView-CM3B-ER3.js.map +0 -1
- package/dist/CronJobsView-BHtJZeJZ.js.map +0 -1
- package/dist/RLSEditor-CBX4uD66.js.map +0 -1
- package/dist/SchemaVisualizer-D6tMZgeC.js.map +0 -1
- package/dist/StorageView-BGDeC5GI.js.map +0 -1
- package/dist/components/StorageView/storage-failure.d.ts +0 -34
- package/src/components/ApiExplorer/ApiExplorer.tsx +0 -299
- package/src/components/ApiExplorer/EndpointDetail.tsx +0 -279
- package/src/components/ApiExplorer/TryItPanel.tsx +0 -499
- package/src/components/ApiExplorer/parseSpec.ts +0 -104
- package/src/components/ApiExplorer/types.ts +0 -84
- package/src/components/ApiKeys/ApiKeysView.tsx +0 -479
- package/src/components/ApiKeys/CreateApiKeyDialog.tsx +0 -711
- package/src/components/ApiKeys/permissions.ts +0 -145
- package/src/components/AuthSimulationSelector.tsx +0 -72
- package/src/components/Backups/BackupsView.tsx +0 -185
- package/src/components/Branches/BranchesView.tsx +0 -386
- package/src/components/CronJobs/CronJobsView.tsx +0 -413
- package/src/components/JSEditor/JSEditor.tsx +0 -1100
- package/src/components/JSEditor/JSEditorSidebar.tsx +0 -350
- package/src/components/JSEditor/JSMonacoEditor.tsx +0 -410
- package/src/components/LogsExplorer/LogsExplorer.tsx +0 -273
- package/src/components/LogsExplorer/useLogTail.ts +0 -356
- package/src/components/RLSEditor/PolicyEditor.tsx +0 -399
- package/src/components/RLSEditor/RLSEditor.tsx +0 -1128
- package/src/components/RLSEditor/index.ts +0 -1
- package/src/components/RLSEditor/policy-presets.ts +0 -176
- package/src/components/RLSEditor/saveSecurityRules.ts +0 -48
- package/src/components/RebaseStudio.tsx +0 -174
- package/src/components/SQLEditor/ExplainVisualizer.tsx +0 -128
- package/src/components/SQLEditor/MonacoEditor.tsx +0 -203
- package/src/components/SQLEditor/SQLEditor.tsx +0 -1518
- package/src/components/SQLEditor/SQLEditorSidebar.tsx +0 -173
- package/src/components/SQLEditor/SchemaBrowser.tsx +0 -168
- package/src/components/SQLEditor/sql_editor_types.ts +0 -18
- package/src/components/SchemaVisualizer/RelationEdge.tsx +0 -102
- package/src/components/SchemaVisualizer/SchemaVisualizer.tsx +0 -710
- package/src/components/SchemaVisualizer/TableNode.tsx +0 -257
- package/src/components/SchemaVisualizer/schema-visualizer.utils.ts +0 -140
- package/src/components/SchemaVisualizer/useLiveRls.ts +0 -86
- package/src/components/SchemaVisualizer/useSchemaGraph.ts +0 -426
- package/src/components/StorageView/StorageView.tsx +0 -1588
- package/src/components/StorageView/storage-failure.ts +0 -63
- package/src/components/StudioHomePage.tsx +0 -430
- package/src/index.ts +0 -31
- package/src/utils/parseSpec.test.ts +0 -309
- package/src/utils/sql_utils.test.ts +0 -265
- package/src/utils/sql_utils.ts +0 -291
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from "react";
|
|
2
|
-
import Editor, { Monaco, OnMount } from "@monaco-editor/react";
|
|
3
|
-
import type { editor, Position, IRange } from "monaco-editor";
|
|
4
|
-
import { cls, defaultBorderMixin } from "@rebasepro/ui";
|
|
5
|
-
import { useModeController } from "@rebasepro/app";
|
|
6
|
-
|
|
7
|
-
export type MonacoEditorProps = {
|
|
8
|
-
value: string;
|
|
9
|
-
onChange: (value: string | undefined) => void;
|
|
10
|
-
onRun?: (selectedText?: string) => void;
|
|
11
|
-
className?: string;
|
|
12
|
-
readOnly?: boolean;
|
|
13
|
-
autoFocus?: boolean;
|
|
14
|
-
schemas?: Record<string, { schemaName: string, tableName: string, columns: { name: string, dataType: string }[] }[]>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const MonacoEditor = ({
|
|
18
|
-
value,
|
|
19
|
-
onChange,
|
|
20
|
-
onRun,
|
|
21
|
-
className,
|
|
22
|
-
readOnly = false,
|
|
23
|
-
autoFocus = true,
|
|
24
|
-
schemas
|
|
25
|
-
}: MonacoEditorProps) => {
|
|
26
|
-
const { mode } = useModeController();
|
|
27
|
-
const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);
|
|
28
|
-
const monacoRef = useRef<Monaco | null>(null);
|
|
29
|
-
const onRunRef = useRef(onRun);
|
|
30
|
-
onRunRef.current = onRun;
|
|
31
|
-
|
|
32
|
-
const schemasRef = useRef(schemas);
|
|
33
|
-
schemasRef.current = schemas;
|
|
34
|
-
|
|
35
|
-
const handleEditorOnMount: OnMount = (editor, monaco) => {
|
|
36
|
-
editorRef.current = editor;
|
|
37
|
-
monacoRef.current = monaco;
|
|
38
|
-
|
|
39
|
-
editor.addAction({
|
|
40
|
-
id: "run-query",
|
|
41
|
-
label: "Run Query",
|
|
42
|
-
keybindings: [monaco.KeyMod.CtrlCmd + monaco.KeyCode.Enter],
|
|
43
|
-
contextMenuGroupId: "operation",
|
|
44
|
-
contextMenuOrder: 0,
|
|
45
|
-
run: () => {
|
|
46
|
-
if (onRunRef.current) {
|
|
47
|
-
const selection = editor.getSelection();
|
|
48
|
-
let selectedText: string | undefined = undefined;
|
|
49
|
-
if (selection && !selection.isEmpty()) {
|
|
50
|
-
selectedText = editor.getModel()?.getValueInRange(selection)?.trim();
|
|
51
|
-
}
|
|
52
|
-
onRunRef.current(selectedText || undefined);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// Register custom autocomplete for tables, columns, and SQL keywords
|
|
58
|
-
const sqlKeywords = [
|
|
59
|
-
"SELECT", "FROM", "WHERE", "INSERT INTO", "VALUES", "UPDATE", "SET",
|
|
60
|
-
"DELETE FROM", "JOIN", "INNER JOIN", "LEFT JOIN", "RIGHT JOIN", "FULL JOIN",
|
|
61
|
-
"ON", "GROUP BY", "HAVING", "ORDER BY", "ASC", "DESC", "LIMIT", "OFFSET",
|
|
62
|
-
"AS", "AND", "OR", "NOT", "IN", "BETWEEN", "LIKE", "IS NULL", "IS NOT NULL",
|
|
63
|
-
"CREATE TABLE", "ALTER TABLE", "DROP TABLE", "PRIMARY KEY", "FOREIGN KEY",
|
|
64
|
-
"COUNT", "SUM", "AVG", "MIN", "MAX", "DISTINCT", "UNION", "ALL", "EXISTS",
|
|
65
|
-
"CASE", "WHEN", "THEN", "ELSE", "END", "CAST", "COALESCE"
|
|
66
|
-
];
|
|
67
|
-
|
|
68
|
-
monaco.languages.registerCompletionItemProvider("pgsql", {
|
|
69
|
-
triggerCharacters: [".", " ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"],
|
|
70
|
-
provideCompletionItems: (model: editor.ITextModel, position: Position) => {
|
|
71
|
-
const word = model.getWordUntilPosition(position);
|
|
72
|
-
const range = {
|
|
73
|
-
startLineNumber: position.lineNumber,
|
|
74
|
-
endLineNumber: position.lineNumber,
|
|
75
|
-
startColumn: word.startColumn,
|
|
76
|
-
endColumn: word.endColumn
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const textUntilPosition = model.getValueInRange({
|
|
80
|
-
startLineNumber: position.lineNumber,
|
|
81
|
-
startColumn: 1,
|
|
82
|
-
endLineNumber: position.lineNumber,
|
|
83
|
-
endColumn: position.column
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
// Check if user is typing `tableName.`
|
|
87
|
-
const match = textUntilPosition.match(/([a-zA-Z0-9_]+)\.$/);
|
|
88
|
-
const tableNameMatch = match ? match[1] : null;
|
|
89
|
-
|
|
90
|
-
const suggestions: { label: string; kind: number; insertText: string; range: IRange; detail: string; sortText: string }[] = [];
|
|
91
|
-
const allSchemas = schemasRef.current || {};
|
|
92
|
-
|
|
93
|
-
if (tableNameMatch) {
|
|
94
|
-
// Provide columns for the matched table
|
|
95
|
-
for (const [, tables] of Object.entries(allSchemas)) {
|
|
96
|
-
const table = tables.find(t => t.tableName === tableNameMatch);
|
|
97
|
-
if (table) {
|
|
98
|
-
table.columns.forEach(col => {
|
|
99
|
-
suggestions.push({
|
|
100
|
-
label: col.name,
|
|
101
|
-
kind: monaco.languages.CompletionItemKind.Field,
|
|
102
|
-
insertText: col.name,
|
|
103
|
-
range,
|
|
104
|
-
detail: "Column",
|
|
105
|
-
sortText: "1"
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
// Provide table names
|
|
112
|
-
for (const [sName, tables] of Object.entries(allSchemas)) {
|
|
113
|
-
tables.forEach(table => {
|
|
114
|
-
suggestions.push({
|
|
115
|
-
label: table.tableName,
|
|
116
|
-
kind: monaco.languages.CompletionItemKind.Class,
|
|
117
|
-
insertText: table.tableName,
|
|
118
|
-
range,
|
|
119
|
-
detail: `Table (${sName})`,
|
|
120
|
-
sortText: "2"
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Provide SQL keywords
|
|
126
|
-
sqlKeywords.forEach(keyword => {
|
|
127
|
-
suggestions.push({
|
|
128
|
-
label: keyword,
|
|
129
|
-
kind: monaco.languages.CompletionItemKind.Keyword,
|
|
130
|
-
insertText: keyword + " ",
|
|
131
|
-
range,
|
|
132
|
-
detail: "SQL Keyword",
|
|
133
|
-
sortText: "3"
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// Heuristic: Suggest columns for tables that are mentioned in the current editor text
|
|
138
|
-
const fullText = model.getValue();
|
|
139
|
-
const activeTables = new Set<string>();
|
|
140
|
-
for (const [, tables] of Object.entries(allSchemas)) {
|
|
141
|
-
tables.forEach(table => {
|
|
142
|
-
const regex = new RegExp(`\\b${table.tableName}\\b`, "i");
|
|
143
|
-
if (regex.test(fullText)) {
|
|
144
|
-
activeTables.add(table.tableName);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const addedColumns = new Set<string>();
|
|
150
|
-
for (const [, tables] of Object.entries(allSchemas)) {
|
|
151
|
-
tables.forEach(table => {
|
|
152
|
-
if (activeTables.has(table.tableName)) {
|
|
153
|
-
table.columns.forEach(col => {
|
|
154
|
-
if (!addedColumns.has(col.name)) {
|
|
155
|
-
addedColumns.add(col.name);
|
|
156
|
-
suggestions.push({
|
|
157
|
-
label: col.name,
|
|
158
|
-
kind: monaco.languages.CompletionItemKind.Field,
|
|
159
|
-
insertText: col.name,
|
|
160
|
-
range,
|
|
161
|
-
detail: `Column (${table.tableName})`,
|
|
162
|
-
sortText: "1" // Prioritize columns from active tables
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return { suggestions };
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
if (autoFocus) {
|
|
177
|
-
editor.focus();
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
return (
|
|
182
|
-
<div className={cls("relative w-full h-full overflow-hidden", className)}>
|
|
183
|
-
<Editor
|
|
184
|
-
height="100%"
|
|
185
|
-
defaultLanguage="pgsql"
|
|
186
|
-
value={value}
|
|
187
|
-
onChange={onChange}
|
|
188
|
-
onMount={handleEditorOnMount}
|
|
189
|
-
theme={mode === "dark" ? "vs-dark" : "vs"}
|
|
190
|
-
options={{
|
|
191
|
-
minimap: { enabled: false },
|
|
192
|
-
fontSize: 14,
|
|
193
|
-
lineNumbers: "on",
|
|
194
|
-
scrollBeyondLastLine: false,
|
|
195
|
-
automaticLayout: true,
|
|
196
|
-
readOnly,
|
|
197
|
-
tabSize: 2,
|
|
198
|
-
wordWrap: "on"
|
|
199
|
-
}}
|
|
200
|
-
/>
|
|
201
|
-
</div>
|
|
202
|
-
);
|
|
203
|
-
};
|