@rebasepro/studio 0.7.0 → 0.8.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.
package/package.json CHANGED
@@ -1,33 +1,33 @@
1
1
  {
2
2
  "name": "@rebasepro/studio",
3
3
  "type": "module",
4
- "version": "0.7.0",
4
+ "version": "0.8.0",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "source": "src/index.ts",
9
9
  "dependencies": {
10
10
  "@monaco-editor/react": "^4.7.0",
11
- "@rebasepro/client": "workspace:*",
12
- "@rebasepro/common": "workspace:*",
13
- "@rebasepro/core": "workspace:*",
14
- "@rebasepro/types": "workspace:*",
15
- "@rebasepro/ui": "workspace:*",
16
- "@rebasepro/utils": "workspace:*",
17
11
  "@types/dagre": "0.7.54",
18
12
  "@xyflow/react": "12.11.0",
19
13
  "dagre": "0.8.5",
20
14
  "monaco-editor": "^0.55.1",
21
15
  "pgsql-ast-parser": "12.0.2",
22
16
  "prism-react-renderer": "^2.4.1",
23
- "react-dropzone": "^15.0.0"
17
+ "react-dropzone": "^15.0.0",
18
+ "@rebasepro/common": "0.8.0",
19
+ "@rebasepro/types": "0.8.0",
20
+ "@rebasepro/core": "0.8.0",
21
+ "@rebasepro/ui": "0.8.0",
22
+ "@rebasepro/client": "0.8.0",
23
+ "@rebasepro/utils": "0.8.0"
24
24
  },
25
25
  "peerDependencies": {
26
- "@rebasepro/admin": "workspace:*",
27
26
  "react": ">=19.0.0",
28
27
  "react-dom": ">=19.0.0",
29
28
  "react-router": "^7.0.0",
30
- "react-router-dom": "^7.0.0"
29
+ "react-router-dom": "^7.0.0",
30
+ "@rebasepro/admin": "0.8.0"
31
31
  },
32
32
  "peerDependenciesMeta": {
33
33
  "@rebasepro/admin": {
@@ -43,12 +43,6 @@
43
43
  },
44
44
  "./package.json": "./package.json"
45
45
  },
46
- "scripts": {
47
- "dev": "vite",
48
- "test": "jest --passWithNoTests",
49
- "build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
50
- "clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f"
51
- },
52
46
  "browserslist": {
53
47
  "production": [
54
48
  ">0.2%",
@@ -88,5 +82,11 @@
88
82
  "type": "git",
89
83
  "url": "https://github.com/rebasepro/rebase.git",
90
84
  "directory": "packages/studio"
85
+ },
86
+ "scripts": {
87
+ "dev": "vite",
88
+ "test": "jest --passWithNoTests",
89
+ "build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
90
+ "clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f"
91
91
  }
92
- }
92
+ }
@@ -49,10 +49,10 @@ interface FindResponse<M extends Record<string, any> = any> {
49
49
  };
50
50
  }
51
51
 
52
- type FilterOperator = "=" | "!=" | ">" | ">=" | "<" | "<=" | "in" | "not-in" | "array-contains" | "array-contains-any" | "is" | "is_not" | "like" | "ilike";
52
+ type WhereFilterOp = "<" | "<=" | "==" | "!=" | ">=" | ">" | "in" | "not-in" | "array-contains" | "array-contains-any";
53
53
 
54
54
  interface QueryBuilder<M extends Record<string, any> = any> {
55
- where(column: keyof M & string, operator: FilterOperator, value: any): QueryBuilder<M>;
55
+ where(column: keyof M & string, operator: WhereFilterOp, value: any): QueryBuilder<M>;
56
56
  orderBy(column: keyof M & string, direction?: "asc" | "desc"): QueryBuilder<M>;
57
57
  limit(count: number): QueryBuilder<M>;
58
58
  offset(count: number): QueryBuilder<M>;
@@ -68,7 +68,7 @@ interface CollectionClient<M extends Record<string, any> = any> {
68
68
  create(data: Partial<M>, id?: string | number): Promise<Entity<M>>;
69
69
  update(id: string | number, data: Partial<M>): Promise<Entity<M>>;
70
70
  delete(id: string | number): Promise<void>;
71
- where(column: keyof M & string, operator: FilterOperator, value: any): QueryBuilder<M>;
71
+ where(column: keyof M & string, operator: WhereFilterOp, value: any): QueryBuilder<M>;
72
72
  orderBy(column: keyof M & string, direction?: "asc" | "desc"): QueryBuilder<M>;
73
73
  limit(count: number): QueryBuilder<M>;
74
74
  offset(count: number): QueryBuilder<M>;
@@ -31,6 +31,8 @@ import {
31
31
  PlusIcon,
32
32
  RefreshCwIcon,
33
33
  ResizablePanels,
34
+ Select,
35
+ SelectItem,
34
36
  TextField,
35
37
  Tooltip,
36
38
  Trash2Icon,
@@ -39,8 +41,8 @@ import {
39
41
  VideoIcon,
40
42
  XIcon
41
43
  } from "@rebasepro/ui";
42
- import { useStorageSource, useSnackbarController, ErrorView, useApiConfig } from "@rebasepro/core";
43
- import type { StorageListResult } from "@rebasepro/types";
44
+ import { useStorageSource, useStorageSources, useSnackbarController, ErrorView, useApiConfig } from "@rebasepro/core";
45
+ import { DEFAULT_STORAGE_SOURCE_KEY, type StorageListResult } from "@rebasepro/types";
44
46
  import { useSearchParams } from "react-router-dom";
45
47
  import { useDropzone } from "react-dropzone";
46
48
 
@@ -469,9 +471,22 @@ function FilePreviewPanel({
469
471
  // ──────────────────────────────────────────────
470
472
 
471
473
  export const StorageView = () => {
472
- const storageSource = useStorageSource();
474
+ const defaultStorageSource = useStorageSource();
475
+ const storageSources = useStorageSources();
473
476
  const snackbarController = useSnackbarController();
474
477
 
478
+ // Available backends to browse. Always includes the default; named
479
+ // sources come from `<Rebase storageSources={...}>`.
480
+ const sourceKeys = useMemo(() => {
481
+ const keys = Object.keys(storageSources.sources);
482
+ if (!keys.includes(DEFAULT_STORAGE_SOURCE_KEY)) keys.unshift(DEFAULT_STORAGE_SOURCE_KEY);
483
+ return keys;
484
+ }, [storageSources.sources]);
485
+
486
+ const [selectedSourceKey, setSelectedSourceKey] = useState<string>(DEFAULT_STORAGE_SOURCE_KEY);
487
+
488
+ const storageSource = storageSources.sources[selectedSourceKey] ?? defaultStorageSource;
489
+
475
490
  // Navigation
476
491
  const [searchParams, setSearchParams] = useSearchParams();
477
492
  const currentPath = searchParams.get("path") || "";
@@ -559,8 +574,10 @@ export const StorageView = () => {
559
574
  }, []);
560
575
 
561
576
  useEffect(() => {
577
+ // `selectedSourceKey` is a dep so switching backend re-lists; the
578
+ // ref-sync effect above runs first, so `storageSourceRef` is current.
562
579
  fetchContents(currentPath);
563
- }, [currentPath, fetchContents]);
580
+ }, [currentPath, fetchContents, selectedSourceKey]);
564
581
 
565
582
  // Navigate to path
566
583
  const handleNavigate = useCallback((path: string) => {
@@ -1266,6 +1283,28 @@ message: e instanceof Error ? e.message : String(e) });
1266
1283
 
1267
1284
  <div className="flex shrink-0 items-center justify-end gap-1.5 pr-1">
1268
1285
 
1286
+ {/* Backend picker — only shown when more than one storage source is available */}
1287
+ {sourceKeys.length > 1 && (
1288
+ <Select
1289
+ size="small"
1290
+ position="item-aligned"
1291
+ value={selectedSourceKey}
1292
+ onValueChange={(value) => {
1293
+ if (value) setSelectedSourceKey(value);
1294
+ }}
1295
+ renderValue={(key) => {
1296
+ const label = storageSources.registry[key]?.label;
1297
+ return label ?? (key === DEFAULT_STORAGE_SOURCE_KEY ? "Default" : key);
1298
+ }}>
1299
+ {sourceKeys.map((key) => (
1300
+ <SelectItem key={key} value={key}>
1301
+ {storageSources.registry[key]?.label
1302
+ ?? (key === DEFAULT_STORAGE_SOURCE_KEY ? "Default" : key)}
1303
+ </SelectItem>
1304
+ ))}
1305
+ </Select>
1306
+ )}
1307
+
1269
1308
  <Tooltip title="Grid view">
1270
1309
  <IconButton
1271
1310
  size="small"
@@ -1,7 +1,6 @@
1
1
  import type { HomePageSection, PluginGenericProps } from "@rebasepro/types";
2
- import React, { useEffect } from "react";
3
- import { Card, cls, Container, Typography } from "@rebasepro/ui";
4
- import { ArrowRightIcon, iconSize } from "@rebasepro/ui";
2
+ import React, { useEffect, useMemo, useState } from "react";
3
+ import { Card, cls, Container, ExpandablePanel, Typography } from "@rebasepro/ui";
5
4
  import { IconForView, useRebaseContext, useRestoreScroll, useSlot } from "@rebasepro/core";
6
5
  import { useNavigate } from "react-router-dom";
7
6
  import { useStudioBreadcrumbs, SchemaDriftBanner } from "@rebasepro/core";
@@ -19,16 +18,12 @@ interface StudioTool {
19
18
 
20
19
  interface StudioSection {
21
20
  label: string;
22
- dotColor: string;
23
- iconColor: string;
24
21
  tools: StudioTool[];
25
22
  }
26
23
 
27
24
  const SECTIONS: StudioSection[] = [
28
25
  {
29
26
  label: "Database",
30
- dotColor: "bg-emerald-400",
31
- iconColor: "text-emerald-400",
32
27
  tools: [
33
28
  { path: "/schema",
34
29
  name: "Collections",
@@ -58,8 +53,6 @@ icon: "Activity" }
58
53
  },
59
54
  {
60
55
  label: "Compute",
61
- dotColor: "bg-blue-400",
62
- iconColor: "text-blue-400",
63
56
  tools: [
64
57
  { path: "/js",
65
58
  name: "JS Console",
@@ -73,8 +66,6 @@ icon: "Clock" }
73
66
  },
74
67
  {
75
68
  label: "API",
76
- dotColor: "bg-violet-400",
77
- iconColor: "text-violet-400",
78
69
  tools: [
79
70
  { path: "/api",
80
71
  name: "API Explorer",
@@ -84,8 +75,6 @@ icon: "BookOpen" }
84
75
  },
85
76
  {
86
77
  label: "Storage",
87
- dotColor: "bg-amber-400",
88
- iconColor: "text-amber-400",
89
78
  tools: [
90
79
  { path: "/storage",
91
80
  name: "Storage",
@@ -95,8 +84,6 @@ icon: "HardDrive" }
95
84
  },
96
85
  {
97
86
  label: "Access Control",
98
- dotColor: "bg-rose-400",
99
- iconColor: "text-rose-400",
100
87
  tools: [
101
88
  { path: "/users",
102
89
  name: "Users",
@@ -116,6 +103,38 @@ icon: "KeyRound" }
116
103
 
117
104
  /* ═══════════════════════════════════════════════════════════════ */
118
105
 
106
+ const COLLAPSED_STORAGE_KEY = "rebase-studio-home-collapsed";
107
+
108
+ function useStudioCollapsedGroups(groupNames: string[]) {
109
+ const [collapsed, setCollapsed] = useState<Set<string>>(() => {
110
+ try {
111
+ const stored = localStorage.getItem(COLLAPSED_STORAGE_KEY);
112
+ return stored ? new Set(JSON.parse(stored)) : new Set<string>();
113
+ } catch {
114
+ return new Set<string>();
115
+ }
116
+ });
117
+
118
+ const isGroupCollapsed = (name: string) => collapsed.has(name);
119
+
120
+ const toggleGroupCollapsed = (name: string) => {
121
+ setCollapsed(prev => {
122
+ const next = new Set(prev);
123
+ if (next.has(name)) {
124
+ next.delete(name);
125
+ } else {
126
+ next.add(name);
127
+ }
128
+ try {
129
+ localStorage.setItem(COLLAPSED_STORAGE_KEY, JSON.stringify([...next]));
130
+ } catch { /* noop */ }
131
+ return next;
132
+ });
133
+ };
134
+
135
+ return { isGroupCollapsed, toggleGroupCollapsed };
136
+ }
137
+
119
138
  export function StudioHomePage({
120
139
  additionalActions,
121
140
  additionalChildrenStart,
@@ -143,8 +162,20 @@ export function StudioHomePage({
143
162
 
144
163
  const pluginActions = useSlot("home.actions", sectionProps);
145
164
 
165
+ const filteredSections = useMemo(
166
+ () => SECTIONS.filter(s => !hiddenGroups?.includes(s.label)),
167
+ [hiddenGroups]
168
+ );
169
+
170
+ const groupNames = useMemo(
171
+ () => filteredSections.map(s => s.label),
172
+ [filteredSections]
173
+ );
174
+
175
+ const { isGroupCollapsed, toggleGroupCollapsed } = useStudioCollapsedGroups(groupNames);
176
+
146
177
  return (
147
- <div ref={containerRef} className="py-2 overflow-auto h-full w-full">
178
+ <div ref={containerRef} className="py-2 overflow-auto h-full w-full bg-surface-50 dark:bg-surface-800">
148
179
  <Container maxWidth="6xl">
149
180
  <div className="mb-4 flex flex-col gap-2">
150
181
  <SchemaDriftBanner />
@@ -160,77 +191,95 @@ export function StudioHomePage({
160
191
  {additionalChildrenStart}
161
192
 
162
193
  {/* ── Tool sections ── */}
163
- <div className="flex flex-col gap-8 pt-2">
164
- {SECTIONS.map((section) => (
165
- <section key={section.label} aria-label={section.label}>
166
- {/* Section header */}
167
- <Typography
168
- variant="caption"
169
- component="h2"
170
- color="secondary"
171
- className="py-2 font-medium uppercase text-sm text-surface-600 dark:text-surface-400"
172
- >
173
- {section.label}
174
- </Typography>
175
-
176
- {/* Card grid */}
177
- <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3 mt-2">
178
- {section.tools.map((tool) => (
179
- <Card
180
- key={tool.path}
181
- onClick={() => {
182
- navigate(tool.path);
183
- context.analyticsController?.onAnalyticsEvent?.(
184
- "home_navigate_to_view",
185
- { path: tool.path }
186
- );
187
- }}
194
+ {filteredSections.map((section) => {
195
+ const sectionCollapsed = isGroupCollapsed(section.label);
196
+
197
+ return (
198
+ <div key={section.label} className="my-10">
199
+ <ExpandablePanel
200
+ invisible
201
+ expanded={!sectionCollapsed}
202
+ onExpandedChange={(open) => {
203
+ if (open !== !sectionCollapsed) {
204
+ toggleGroupCollapsed(section.label);
205
+ }
206
+ }}
207
+ className="mt-6"
208
+ titleClassName={cls(
209
+ "min-h-0 p-0 border-none",
210
+ "rounded flex items-center justify-between w-full",
211
+ "hover:bg-transparent",
212
+ "cursor-pointer select-none",
213
+ sectionCollapsed && "bg-surface-100 dark:bg-surface-900/50"
214
+ )}
215
+ innerClassName="mt-4 pt-0"
216
+ title={
217
+ <Typography
218
+ variant="caption"
219
+ component="h2"
220
+ color="secondary"
188
221
  className={cls(
189
- "h-full px-4 py-2.5 cursor-pointer transition-all duration-200 ease-in-out",
190
- "hover:-translate-y-0.5 hover:shadow-md hover:shadow-primary/5"
222
+ "px-4 py-1 rounded",
223
+ "font-medium text-[10px] uppercase tracking-[0.08em] text-primary/50 dark:text-primary/70"
191
224
  )}
192
225
  >
193
- <div className="flex flex-col items-start h-full">
194
- <div className="grow w-full">
195
- {/* Icon */}
196
- <div className={cls("h-6 flex items-center", section.iconColor)}>
197
- <IconForView
198
- collectionOrView={{ slug: tool.path,
199
- name: tool.name,
200
- icon: tool.icon }}
201
- size="small"
202
- />
203
- </div>
226
+ {section.label}
227
+ </Typography>
228
+ }
229
+ >
230
+ <div className="mt-4 pt-0">
231
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
232
+ {section.tools.map((tool) => (
233
+ <Card
234
+ key={tool.path}
235
+ onClick={() => {
236
+ navigate(tool.path);
237
+ context.analyticsController?.onAnalyticsEvent?.(
238
+ "home_navigate_to_view",
239
+ { path: tool.path }
240
+ );
241
+ }}
242
+ className={cls(
243
+ "group h-full p-4 cursor-pointer transition-colors duration-150 ease-in-out",
244
+ "hover:bg-primary/5 dark:hover:bg-primary/5"
245
+ )}
246
+ >
247
+ <div className="flex flex-col h-full">
248
+ {/* Header: icon + title */}
249
+ <div className="flex items-center w-full justify-between mb-1">
250
+ <div className="flex items-center gap-3">
251
+ <div className="flex items-center justify-center w-5 h-5 text-surface-400 dark:text-surface-500 transition-colors duration-150 group-hover:text-primary dark:group-hover:text-primary">
252
+ <IconForView
253
+ collectionOrView={{ slug: tool.path, name: tool.name, icon: tool.icon }}
254
+ size="small"
255
+ />
256
+ </div>
257
+ <Typography variant="subtitle1" component="h2">
258
+ {tool.name}
259
+ </Typography>
260
+ </div>
261
+ </div>
204
262
 
205
- {/* Title */}
206
- <Typography
207
- gutterBottom
208
- variant="subtitle1"
209
- className="mt-1 font-semibold"
210
- component="h2"
211
- >
212
- {tool.name}
213
- </Typography>
214
-
215
- {/* Description */}
216
- <Typography variant="caption" color="secondary" component="div">
217
- {tool.description}
218
- </Typography>
219
- </div>
220
-
221
- {/* Arrow */}
222
- <div style={{ alignSelf: "flex-end" }}>
223
- <div className="p-2">
224
- <ArrowRightIcon className="text-primary" size={iconSize.small}/>
263
+ {/* Description indented to align with title */}
264
+ <div className="pl-8">
265
+ {tool.description && (
266
+ <Typography variant="caption" color="secondary" component="div">
267
+ {tool.description}
268
+ </Typography>
269
+ )}
270
+ </div>
271
+
272
+ {/* Spacer */}
273
+ <div className="grow"/>
225
274
  </div>
226
- </div>
227
- </div>
228
- </Card>
229
- ))}
230
- </div>
231
- </section>
232
- ))}
233
- </div>
275
+ </Card>
276
+ ))}
277
+ </div>
278
+ </div>
279
+ </ExpandablePanel>
280
+ </div>
281
+ );
282
+ })}
234
283
 
235
284
  {/* ── SDK Quick Start ── */}
236
285
  <div className="mt-10 mb-6">
@@ -239,7 +288,10 @@ icon: tool.icon }}
239
288
  variant="caption"
240
289
  component="h2"
241
290
  color="secondary"
242
- className="py-2 font-medium uppercase text-sm text-surface-600 dark:text-surface-400"
291
+ className={cls(
292
+ "px-4 py-1 rounded",
293
+ "font-medium text-[10px] uppercase tracking-[0.08em] text-primary/50 dark:text-primary/70"
294
+ )}
243
295
  >
244
296
  Quick Start
245
297
  </Typography>
@@ -285,7 +337,10 @@ icon: tool.icon }}
285
337
  variant="caption"
286
338
  component="h2"
287
339
  color="secondary"
288
- className="p-4 py-2 rounded font-medium uppercase text-sm text-surface-600 dark:text-surface-400"
340
+ className={cls(
341
+ "px-4 py-1 rounded",
342
+ "font-medium text-[10px] uppercase tracking-[0.08em] text-primary/50 dark:text-primary/70"
343
+ )}
289
344
  >
290
345
  {s.title}
291
346
  </Typography>
@@ -1,4 +1,4 @@
1
- import type { EntityCollection, Property, StringProperty, NumberProperty, ArrayProperty, TableColumnInfo, TableMetadata, SecurityOperation, SecurityRule } from "@rebasepro/types";
1
+ import type { EntityCollection, PostgresProperties, Property, StringProperty, NumberProperty, ArrayProperty, TableColumnInfo, TableMetadata, SecurityOperation, SecurityRule } from "@rebasepro/types";
2
2
 
3
3
  /**
4
4
  * Maps a PostgreSQL column data type to a Rebase property type.
@@ -301,7 +301,7 @@ export function buildCollectionFromTableMetadata(
301
301
  name: prettifiedName,
302
302
  slug: tableName,
303
303
  table: tableName,
304
- properties,
304
+ properties: properties as PostgresProperties,
305
305
  propertiesOrder,
306
306
  ...(relations.length > 0 ? { relations } : {}),
307
307
  ...(securityRules.length > 0 ? { securityRules } : {})