@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.
Files changed (81) hide show
  1. package/LICENSE +0 -1
  2. package/README.md +12 -4
  3. package/dist/{ApiKeysView-DiCurTEU.js → ApiKeysView-EIvegrUk.js} +54 -39
  4. package/dist/ApiKeysView-EIvegrUk.js.map +1 -0
  5. package/dist/{BackupsView-DNS6LdVg.js → BackupsView-DVkKzaPR.js} +29 -31
  6. package/dist/BackupsView-DVkKzaPR.js.map +1 -0
  7. package/dist/{BranchesView-CM3B-ER3.js → BranchesView-Df8hQ8wE.js} +85 -24
  8. package/dist/BranchesView-Df8hQ8wE.js.map +1 -0
  9. package/dist/{CronJobsView-BHtJZeJZ.js → CronJobsView-CLOGjb-L.js} +32 -27
  10. package/dist/CronJobsView-CLOGjb-L.js.map +1 -0
  11. package/dist/{RLSEditor-CBX4uD66.js → RLSEditor-Sa1D34ny.js} +724 -615
  12. package/dist/RLSEditor-Sa1D34ny.js.map +1 -0
  13. package/dist/{SQLEditor-ByecwX8B.js → SQLEditor-BfNA8xM3.js} +9 -4
  14. package/dist/{SQLEditor-ByecwX8B.js.map → SQLEditor-BfNA8xM3.js.map} +1 -1
  15. package/dist/{SchemaVisualizer-D6tMZgeC.js → SchemaVisualizer-DTDMYL6o.js} +84 -110
  16. package/dist/SchemaVisualizer-DTDMYL6o.js.map +1 -0
  17. package/dist/{StorageView-BGDeC5GI.js → StorageView-Ed9Q_VlB.js} +5 -32
  18. package/dist/StorageView-Ed9Q_VlB.js.map +1 -0
  19. package/dist/components/RLSEditor/saveRules.d.ts +38 -0
  20. package/dist/components/RebaseStudio.d.ts +1 -1
  21. package/dist/components/SchemaVisualizer/schema-visualizer.utils.d.ts +5 -2
  22. package/dist/components/SchemaVisualizer/useSchemaGraph.d.ts +0 -4
  23. package/dist/components/load-failure-view.d.ts +17 -0
  24. package/dist/components/load-failure.d.ts +47 -0
  25. package/dist/index.es.js +56 -36
  26. package/dist/index.es.js.map +1 -1
  27. package/dist/load-failure-C6OMJSGC.js +31 -0
  28. package/dist/load-failure-C6OMJSGC.js.map +1 -0
  29. package/dist/load-failure-view-CBTB_h-h.js +48 -0
  30. package/dist/load-failure-view-CBTB_h-h.js.map +1 -0
  31. package/package.json +36 -21
  32. package/dist/ApiKeysView-DiCurTEU.js.map +0 -1
  33. package/dist/BackupsView-DNS6LdVg.js.map +0 -1
  34. package/dist/BranchesView-CM3B-ER3.js.map +0 -1
  35. package/dist/CronJobsView-BHtJZeJZ.js.map +0 -1
  36. package/dist/RLSEditor-CBX4uD66.js.map +0 -1
  37. package/dist/SchemaVisualizer-D6tMZgeC.js.map +0 -1
  38. package/dist/StorageView-BGDeC5GI.js.map +0 -1
  39. package/dist/components/StorageView/storage-failure.d.ts +0 -34
  40. package/src/components/ApiExplorer/ApiExplorer.tsx +0 -299
  41. package/src/components/ApiExplorer/EndpointDetail.tsx +0 -279
  42. package/src/components/ApiExplorer/TryItPanel.tsx +0 -499
  43. package/src/components/ApiExplorer/parseSpec.ts +0 -104
  44. package/src/components/ApiExplorer/types.ts +0 -84
  45. package/src/components/ApiKeys/ApiKeysView.tsx +0 -479
  46. package/src/components/ApiKeys/CreateApiKeyDialog.tsx +0 -711
  47. package/src/components/ApiKeys/permissions.ts +0 -145
  48. package/src/components/AuthSimulationSelector.tsx +0 -72
  49. package/src/components/Backups/BackupsView.tsx +0 -185
  50. package/src/components/Branches/BranchesView.tsx +0 -386
  51. package/src/components/CronJobs/CronJobsView.tsx +0 -413
  52. package/src/components/JSEditor/JSEditor.tsx +0 -1100
  53. package/src/components/JSEditor/JSEditorSidebar.tsx +0 -350
  54. package/src/components/JSEditor/JSMonacoEditor.tsx +0 -410
  55. package/src/components/LogsExplorer/LogsExplorer.tsx +0 -273
  56. package/src/components/LogsExplorer/useLogTail.ts +0 -356
  57. package/src/components/RLSEditor/PolicyEditor.tsx +0 -399
  58. package/src/components/RLSEditor/RLSEditor.tsx +0 -1128
  59. package/src/components/RLSEditor/index.ts +0 -1
  60. package/src/components/RLSEditor/policy-presets.ts +0 -176
  61. package/src/components/RLSEditor/saveSecurityRules.ts +0 -48
  62. package/src/components/RebaseStudio.tsx +0 -174
  63. package/src/components/SQLEditor/ExplainVisualizer.tsx +0 -128
  64. package/src/components/SQLEditor/MonacoEditor.tsx +0 -203
  65. package/src/components/SQLEditor/SQLEditor.tsx +0 -1518
  66. package/src/components/SQLEditor/SQLEditorSidebar.tsx +0 -173
  67. package/src/components/SQLEditor/SchemaBrowser.tsx +0 -168
  68. package/src/components/SQLEditor/sql_editor_types.ts +0 -18
  69. package/src/components/SchemaVisualizer/RelationEdge.tsx +0 -102
  70. package/src/components/SchemaVisualizer/SchemaVisualizer.tsx +0 -710
  71. package/src/components/SchemaVisualizer/TableNode.tsx +0 -257
  72. package/src/components/SchemaVisualizer/schema-visualizer.utils.ts +0 -140
  73. package/src/components/SchemaVisualizer/useLiveRls.ts +0 -86
  74. package/src/components/SchemaVisualizer/useSchemaGraph.ts +0 -426
  75. package/src/components/StorageView/StorageView.tsx +0 -1588
  76. package/src/components/StorageView/storage-failure.ts +0 -63
  77. package/src/components/StudioHomePage.tsx +0 -430
  78. package/src/index.ts +0 -31
  79. package/src/utils/parseSpec.test.ts +0 -309
  80. package/src/utils/sql_utils.test.ts +0 -265
  81. 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
- };