@rebasepro/cli 0.6.1 → 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/README.md +0 -1
- package/dist/commands/api-keys.d.ts +1 -0
- package/dist/commands/generate_sdk.d.ts +1 -1
- package/dist/index.es.js +464 -58
- package/dist/index.es.js.map +1 -1
- package/dist/utils/project.d.ts +15 -0
- package/package.json +8 -9
- package/templates/template/backend/Dockerfile +4 -3
- package/templates/template/backend/functions/hello.ts +32 -32
- package/templates/template/backend/package.json +1 -1
- package/templates/template/backend/src/index.ts +1 -2
- package/templates/template/config/collections/posts.ts +4 -4
- package/templates/template/config/collections/presets/ecommerce/categories.ts +3 -1
- package/templates/template/config/collections/presets/ecommerce/orders.ts +3 -1
- package/templates/template/config/collections/presets/ecommerce/products.ts +3 -1
- package/templates/template/config/collections/tags.ts +1 -3
- package/templates/template/config/collections/users.ts +4 -5
- package/templates/template/frontend/Dockerfile +5 -3
- package/templates/template/package.json +3 -2
- package/templates/template/pnpm-workspace.yaml +2 -0
- package/templates/template/scripts/example.ts +5 -2
- package/skills/rebase-admin/SKILL.md +0 -710
- package/skills/rebase-api/SKILL.md +0 -662
- package/skills/rebase-api/references/.gitkeep +0 -3
- package/skills/rebase-auth/SKILL.md +0 -1143
- package/skills/rebase-auth/references/.gitkeep +0 -3
- package/skills/rebase-backend-postgres/SKILL.md +0 -633
- package/skills/rebase-backend-postgres/references/.gitkeep +0 -3
- package/skills/rebase-basics/SKILL.md +0 -749
- package/skills/rebase-basics/references/.gitkeep +0 -3
- package/skills/rebase-collections/SKILL.md +0 -1328
- package/skills/rebase-collections/references/.gitkeep +0 -3
- package/skills/rebase-cron-jobs/SKILL.md +0 -699
- package/skills/rebase-cron-jobs/references/.gitkeep +0 -1
- package/skills/rebase-custom-functions/SKILL.md +0 -233
- package/skills/rebase-deployment/SKILL.md +0 -885
- package/skills/rebase-deployment/references/.gitkeep +0 -3
- package/skills/rebase-design-language/SKILL.md +0 -692
- package/skills/rebase-email/SKILL.md +0 -701
- package/skills/rebase-email/references/.gitkeep +0 -1
- package/skills/rebase-entity-history/SKILL.md +0 -485
- package/skills/rebase-entity-history/references/.gitkeep +0 -1
- package/skills/rebase-local-env-setup/SKILL.md +0 -189
- package/skills/rebase-local-env-setup/references/.gitkeep +0 -3
- package/skills/rebase-realtime/SKILL.md +0 -755
- package/skills/rebase-realtime/references/.gitkeep +0 -3
- package/skills/rebase-sdk/SKILL.md +0 -594
- package/skills/rebase-sdk/references/.gitkeep +0 -0
- package/skills/rebase-storage/SKILL.md +0 -765
- package/skills/rebase-storage/references/.gitkeep +0 -3
- package/skills/rebase-studio/SKILL.md +0 -746
- package/skills/rebase-studio/references/.gitkeep +0 -3
- package/skills/rebase-ui-components/SKILL.md +0 -1488
- package/skills/rebase-ui-components/references/.gitkeep +0 -3
- package/skills/rebase-webhooks/SKILL.md +0 -623
- package/skills/rebase-webhooks/references/.gitkeep +0 -1
- package/templates/template/backend/drizzle.config.ts +0 -51
|
@@ -1,746 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: rebase-studio
|
|
3
|
-
description: Guide for using and customizing the Rebase Studio developer tools layer. Use this skill when the user needs help with Studio dev tools (SQL/JS/RLS/Storage/Cron/Schema Visualizer/Branches/API Explorer/Logs), admin modes (content/studio/settings), Studio home page customization, bridge hooks, or Studio configuration. Studio is NOT the CMS — the CMS lives in @rebasepro/admin.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Rebase Studio
|
|
7
|
-
|
|
8
|
-
Rebase Studio (`@rebasepro/studio`) is the developer tools layer for Rebase. It provides 9 built-in tools — SQL Console, JS Console, RLS Editor, Storage browser, Cron Jobs manager, Schema Visualizer, Branches manager, API Explorer, and Logs Explorer — accessible via the "Studio" mode toggle in the sidebar.
|
|
9
|
-
|
|
10
|
-
## Overview
|
|
11
|
-
|
|
12
|
-
- **9 built-in dev tools** — all lazy-loaded and code-split so they don't impact initial bundle size
|
|
13
|
-
- **StudioHomePage** — customizable landing page with tool cards grouped by section
|
|
14
|
-
- **Studio Bridge** — hooks that connect Studio tools to CMS data (collections, navigation, side panels)
|
|
15
|
-
|
|
16
|
-
## Admin Modes (Tri-State)
|
|
17
|
-
|
|
18
|
-
> **IMPORTANT FOR AGENTS:** The Studio uses a **tri-state** mode system: `"content"` | `"studio"` | `"settings"`. It is NOT `"developer"` / `"editor"`. These are the only valid values.
|
|
19
|
-
|
|
20
|
-
The admin mode is controlled by `AdminModeController` and persisted in `localStorage` under the key `rebase-admin-mode`. Default mode is `"content"`.
|
|
21
|
-
|
|
22
|
-
### Mode Values
|
|
23
|
-
|
|
24
|
-
| Mode | Description | Navigation Shows |
|
|
25
|
-
|------|-------------|------------------|
|
|
26
|
-
| `"content"` | Clean CMS experience for editing data. Default mode. | Collections + admin entries (Users/Roles) |
|
|
27
|
-
| `"studio"` | Developer tools and schema management. | Dev tool views + admin entries (Users/Roles) |
|
|
28
|
-
| `"settings"` | Application settings and configuration. | Settings-related views |
|
|
29
|
-
|
|
30
|
-
### Mode Controller API
|
|
31
|
-
|
|
32
|
-
```typescript
|
|
33
|
-
import { useAdminModeController } from "@rebasepro/core";
|
|
34
|
-
|
|
35
|
-
interface AdminModeController {
|
|
36
|
-
mode: "content" | "studio" | "settings";
|
|
37
|
-
setMode: (mode: "content" | "studio" | "settings") => void;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Usage in a component
|
|
41
|
-
function MyComponent() {
|
|
42
|
-
const adminModeController = useAdminModeController();
|
|
43
|
-
|
|
44
|
-
// Check current mode
|
|
45
|
-
if (adminModeController.mode === "studio") {
|
|
46
|
-
// Show developer UI
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Switch modes
|
|
50
|
-
adminModeController.setMode("content");
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Drawer Mode Switch
|
|
55
|
-
|
|
56
|
-
When `<RebaseStudio>` is registered, the drawer automatically renders a segmented **Content / Studio** toggle. Clicking "Content" sets mode to `"content"` and navigates to the base path. Clicking "Studio" sets mode to `"studio"` and navigates to `/s`.
|
|
57
|
-
|
|
58
|
-
## Effective Role Simulation
|
|
59
|
-
|
|
60
|
-
> **IMPORTANT FOR AGENTS:** The hook is called `useEffectiveRoleController()`, NOT `useEffectiveRole()`.
|
|
61
|
-
|
|
62
|
-
In Studio mode, developers can select an "effective role" to preview the application as a specific role would see it. The role is persisted in `localStorage` under `rebase-effective-role`.
|
|
63
|
-
|
|
64
|
-
```typescript
|
|
65
|
-
import { useEffectiveRoleController } from "@rebasepro/core";
|
|
66
|
-
|
|
67
|
-
interface EffectiveRoleController {
|
|
68
|
-
effectiveRole: string | null;
|
|
69
|
-
setEffectiveRole: (role: string | null) => void;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Usage
|
|
73
|
-
function RoleSimulator() {
|
|
74
|
-
const { effectiveRole, setEffectiveRole } = useEffectiveRoleController();
|
|
75
|
-
|
|
76
|
-
// Set a role to simulate
|
|
77
|
-
setEffectiveRole("editor");
|
|
78
|
-
|
|
79
|
-
// Clear simulation (back to actual role)
|
|
80
|
-
setEffectiveRole(null);
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Studio Dev Tools
|
|
85
|
-
|
|
86
|
-
The Studio ships 9 built-in dev tools, all **lazy-loaded** (code-split) so they don't impact the initial bundle. Heavy dependencies (Monaco, `@xyflow/react`, `dagre`, `pgsql-ast-parser`) are only loaded when a tool is visited.
|
|
87
|
-
|
|
88
|
-
### Tool Reference
|
|
89
|
-
|
|
90
|
-
| Tool Key | Component | Name | Group | Icon | Description |
|
|
91
|
-
|----------|-----------|------|-------|------|-------------|
|
|
92
|
-
| `"sql"` | `SQLEditor` | SQL Console | Database | `terminal` | Execute raw SQL queries against the database |
|
|
93
|
-
| `"js"` | `JSEditor` | JS Console | Compute | `code` | Run JavaScript with the Rebase SDK in a live sandbox |
|
|
94
|
-
| `"rls"` | `RLSEditor` | RLS Policies | Database | `ShieldCheck` | Configure Row Level Security for fine-grained data access |
|
|
95
|
-
| `"storage"` | `StorageView` | Storage | Storage | `HardDrive` | Browse, upload, and manage files in the storage bucket |
|
|
96
|
-
| `"cron"` | `CronJobsView` | Cron Jobs | Compute | `Clock` | Monitor and manage scheduled background tasks |
|
|
97
|
-
| `"schema-visualizer"` | `SchemaVisualizer` | Schema Visualizer | Database | `Network` | Interactive ERD showing tables, columns, and relationships |
|
|
98
|
-
| `"branches"` | `BranchesView` | Branches | Database | `GitBranch` | Create and manage isolated database copies for development |
|
|
99
|
-
| `"api"` | `ApiExplorer` | API Explorer | API | `BookOpen` | Interactive API documentation with live request testing |
|
|
100
|
-
| `"logs"` | `LogsExplorer` | Logs Explorer | Database | `Activity` | Real-time system, query, and authentication logs |
|
|
101
|
-
|
|
102
|
-
> **IMPORTANT FOR AGENTS:** The `"schema"` tool (collection editor) is **NOT** registered by `<RebaseStudio>`. It is auto-injected by `<RebaseShell>` when `collectionEditor` is enabled on `<RebaseCMS>`. Do not try to register it manually.
|
|
103
|
-
|
|
104
|
-
### Enabling/Disabling Tools
|
|
105
|
-
|
|
106
|
-
By default, **all 9 tools** are enabled. Use the `tools` prop on `<RebaseStudio>` to selectively enable a subset:
|
|
107
|
-
|
|
108
|
-
```tsx
|
|
109
|
-
// Enable all tools (default behavior — both are equivalent)
|
|
110
|
-
<RebaseStudio />
|
|
111
|
-
<RebaseStudio tools={undefined} />
|
|
112
|
-
|
|
113
|
-
// Enable only specific tools
|
|
114
|
-
<RebaseStudio tools={["sql", "rls", "storage"]} />
|
|
115
|
-
|
|
116
|
-
// Enable everything except branches
|
|
117
|
-
<RebaseStudio tools={["sql", "js", "rls", "storage", "cron", "schema-visualizer", "api", "logs"]} />
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
The `tools` prop accepts an array of tool key strings:
|
|
121
|
-
|
|
122
|
-
```typescript
|
|
123
|
-
type ToolKey = "sql" | "js" | "rls" | "schema" | "storage" | "cron"
|
|
124
|
-
| "schema-visualizer" | "branches" | "api" | "logs";
|
|
125
|
-
|
|
126
|
-
// Default when tools is undefined:
|
|
127
|
-
const DEFAULT_TOOLS: ToolKey[] = [
|
|
128
|
-
"sql", "js", "rls", "storage", "cron",
|
|
129
|
-
"schema-visualizer", "branches", "api", "logs"
|
|
130
|
-
];
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### Direct Tool Imports (Advanced)
|
|
134
|
-
|
|
135
|
-
For advanced use cases where you need direct access to a tool component (e.g., embedding it outside the Studio), use deep imports:
|
|
136
|
-
|
|
137
|
-
```typescript
|
|
138
|
-
// Deep import — avoids pulling all tools into the bundle
|
|
139
|
-
import { SQLEditor } from "@rebasepro/studio/components/SQLEditor/SQLEditor";
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
> **WARNING FOR AGENTS:** Do NOT import individual tools from `@rebasepro/studio` top-level. The index only exports `RebaseStudio` and `StudioHomePage`. Individual tools are intentionally excluded to preserve code splitting.
|
|
143
|
-
|
|
144
|
-
## Frontend Composition
|
|
145
|
-
|
|
146
|
-
The Studio is mounted using the declarative composition API. All four components (`<Rebase>`, `<RebaseAuth>`, `<RebaseCMS>`, `<RebaseStudio>`, `<RebaseShell>`) are purely declarative — they **render nothing** and only register configuration into the `RebaseRegistry`. `<RebaseShell>` then reads the registry and builds the actual UI.
|
|
147
|
-
|
|
148
|
-
```tsx
|
|
149
|
-
import { useRebaseAuthController, useBackendUserManagement, RebaseAuth } from "@rebasepro/auth";
|
|
150
|
-
import { Rebase } from "@rebasepro/core";
|
|
151
|
-
import { RebaseCMS, RebaseShell } from "@rebasepro/admin";
|
|
152
|
-
import { useDataEnhancementPlugin } from "@rebasepro/plugin-data-enhancement";
|
|
153
|
-
import { RebaseStudio } from "@rebasepro/studio";
|
|
154
|
-
import { createRebaseClient } from "@rebasepro/client";
|
|
155
|
-
import { collections } from "virtual:rebase-collections";
|
|
156
|
-
|
|
157
|
-
const API_URL = import.meta.env.VITE_API_URL || (import.meta.env.DEV ? "http://localhost:3001" : undefined);
|
|
158
|
-
|
|
159
|
-
export function App() {
|
|
160
|
-
const rebaseClient = React.useMemo(() => createRebaseClient({ baseUrl: API_URL }), []);
|
|
161
|
-
const authController = useRebaseAuthController({ client: rebaseClient });
|
|
162
|
-
const userManagement = useBackendUserManagement({ client: rebaseClient, currentUser: authController.user });
|
|
163
|
-
const dataEnhancementPlugin = useDataEnhancementPlugin();
|
|
164
|
-
|
|
165
|
-
return (
|
|
166
|
-
<Rebase client={rebaseClient} authController={authController} userManagement={userManagement} plugins={[dataEnhancementPlugin]}>
|
|
167
|
-
<RebaseAuth/>
|
|
168
|
-
<RebaseCMS collections={collections} collectionEditor={true}/>
|
|
169
|
-
<RebaseStudio tools={undefined} homePage={undefined} />
|
|
170
|
-
<RebaseShell title="My App"/>
|
|
171
|
-
</Rebase>
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### TypeScript Strict Props Warning
|
|
177
|
-
|
|
178
|
-
Under strict TypeScript checks, `<RebaseStudio/>` without props throws:
|
|
179
|
-
`Type '{}' is missing the following properties from type '{ tools: any; homePage: any; }': tools, homePage`
|
|
180
|
-
|
|
181
|
-
Pass `tools={undefined} homePage={undefined}` explicitly:
|
|
182
|
-
```tsx
|
|
183
|
-
<RebaseStudio tools={undefined} homePage={undefined} />
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### Key Components
|
|
187
|
-
|
|
188
|
-
| Component | Package | Purpose | Renders UI? |
|
|
189
|
-
|-----------|---------|---------|-------------|
|
|
190
|
-
| `<Rebase>` | `@rebasepro/core` | Root provider (client, auth, user management, plugins) | Yes (providers) |
|
|
191
|
-
| `<RebaseAuth>` | `@rebasepro/core` | Authentication config (custom login view) | No — registers into registry |
|
|
192
|
-
| `<RebaseCMS>` | `@rebasepro/admin` | CMS config (collections, views, editor) | No — registers into registry |
|
|
193
|
-
| `<RebaseStudio>` | `@rebasepro/studio` | Studio config (tools, home page) | No — registers into registry |
|
|
194
|
-
| `<RebaseShell>` | `@rebasepro/admin` | App shell (drawer, navigation, routes, layout) | Yes — the actual UI |
|
|
195
|
-
|
|
196
|
-
## Global Component Overrides (Swizzling)
|
|
197
|
-
|
|
198
|
-
Rebase allows you to override default UI components globally by passing a `components` prop to the `<Rebase>` provider. This implements Docusaurus-style component swizzling, supporting both **Eject** and **Wrap** patterns.
|
|
199
|
-
|
|
200
|
-
```tsx
|
|
201
|
-
import { Rebase } from "@rebasepro/core";
|
|
202
|
-
import { MyAppBar } from "./MyAppBar";
|
|
203
|
-
|
|
204
|
-
<Rebase
|
|
205
|
-
client={rebaseClient}
|
|
206
|
-
components={{
|
|
207
|
-
// Eject Mode: Replace the built-in AppBar entirely
|
|
208
|
-
"Shell.AppBar": { Component: MyAppBar },
|
|
209
|
-
|
|
210
|
-
// Wrap Mode: Wrap the default LoginView, adding custom branding
|
|
211
|
-
"Auth.LoginView": {
|
|
212
|
-
Component: ({ OriginalComponent, ...props }) => (
|
|
213
|
-
<div className="custom-login-wrapper">
|
|
214
|
-
<div className="branding">Welcome to My Enterprise App</div>
|
|
215
|
-
<OriginalComponent {...props} />
|
|
216
|
-
</div>
|
|
217
|
-
),
|
|
218
|
-
wrap: true
|
|
219
|
-
}
|
|
220
|
-
}}
|
|
221
|
-
>
|
|
222
|
-
{/* ... */}
|
|
223
|
-
</Rebase>
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### Overridable Component Scopes
|
|
227
|
-
|
|
228
|
-
#### App-scoped Components (`AppComponentName`)
|
|
229
|
-
These components can only be overridden at the root `<Rebase>` provider, as they represent global shell or utility structures.
|
|
230
|
-
|
|
231
|
-
- `"Shell.AppBar"` — The header bar at the top of the page.
|
|
232
|
-
- `"Shell.Drawer"` — The collapsible main sidebar drawer.
|
|
233
|
-
- `"Shell.DrawerNavigationItem"` — Sidebar navigation link.
|
|
234
|
-
- `"Shell.DrawerNavigationGroup"` — Sidebar navigation group header.
|
|
235
|
-
- `"HomePage"` — The landing dashboard of the CMS (when in content mode).
|
|
236
|
-
- `"HomePage.CollectionCard"` — Individual collection link card on the home page.
|
|
237
|
-
- `"Auth.LoginView"` — The login screen overlay.
|
|
238
|
-
|
|
239
|
-
#### Collection-scoped Components (`CollectionComponentName`)
|
|
240
|
-
These components can be overridden globally on `<Rebase>` (which acts as a fallback for all collections) or overridden on individual collections inside their definitions.
|
|
241
|
-
|
|
242
|
-
- `"Collection.View"` — The container view for the collection.
|
|
243
|
-
- `"Collection.Table"` — The default tabular data view.
|
|
244
|
-
- `"Collection.Card"` — Individual card wrapper.
|
|
245
|
-
- `"Collection.EmptyState"` — View shown when a collection is empty.
|
|
246
|
-
- `"Collection.Actions"` — Toolbar actions header.
|
|
247
|
-
- `"Entity.Form"` — The detail form view.
|
|
248
|
-
- `"Entity.FormActions"` — Form action button bar.
|
|
249
|
-
- `"Entity.DetailView"` — Read-only detail view.
|
|
250
|
-
- `"Entity.SidePanel"` — Side panel wrapper.
|
|
251
|
-
- `"Entity.Preview"` — Reference / relation preview chip.
|
|
252
|
-
- `"Entity.MissingReference"` — Placeholder view when a relation references a deleted/non-existent entity.
|
|
253
|
-
|
|
254
|
-
## RebaseCMS Configuration
|
|
255
|
-
|
|
256
|
-
`<RebaseCMS>` accepts the full `RebaseCMSConfig`:
|
|
257
|
-
|
|
258
|
-
```typescript
|
|
259
|
-
interface RebaseCMSConfig<EC extends EntityCollection = EntityCollection> {
|
|
260
|
-
collections?: EC[] | EntityCollectionsBuilder<EC>;
|
|
261
|
-
homePage?: ReactNode;
|
|
262
|
-
entityViews?: EntityCustomView[];
|
|
263
|
-
entityActions?: EntityAction[];
|
|
264
|
-
plugins?: RebasePlugin[];
|
|
265
|
-
navigationGroupMappings?: NavigationGroupMapping[];
|
|
266
|
-
collectionEditor?: boolean | CollectionEditorOptions;
|
|
267
|
-
}
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
### Collection Editor Options
|
|
271
|
-
|
|
272
|
-
```typescript
|
|
273
|
-
interface CollectionEditorOptions {
|
|
274
|
-
/** Auth token for schema-editor API calls. Falls back to authController.getAuthToken. */
|
|
275
|
-
getAuthToken?: () => Promise<string | null>;
|
|
276
|
-
/** Mark the editor as read-only (disable mutations). */
|
|
277
|
-
readOnly?: boolean;
|
|
278
|
-
/** Suggested base paths shown when creating new collections. */
|
|
279
|
-
pathSuggestions?: string[];
|
|
280
|
-
}
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
### Navigation Group Mappings
|
|
284
|
-
|
|
285
|
-
Control how collections and views are grouped in the sidebar and home page:
|
|
286
|
-
|
|
287
|
-
```typescript
|
|
288
|
-
interface NavigationGroupMapping {
|
|
289
|
-
name: string; // Group header display name
|
|
290
|
-
entries: string[]; // Collection slugs or view paths
|
|
291
|
-
collapsedByDefault?: boolean | {
|
|
292
|
-
drawer?: boolean; // Collapse in sidebar
|
|
293
|
-
home?: boolean; // Collapse on home page
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// Usage
|
|
298
|
-
<RebaseCMS
|
|
299
|
-
collections={collections}
|
|
300
|
-
navigationGroupMappings={[
|
|
301
|
-
{ name: "Content", entries: ["posts", "pages", "media"] },
|
|
302
|
-
{ name: "Commerce", entries: ["products", "orders"], collapsedByDefault: { drawer: true } },
|
|
303
|
-
]}
|
|
304
|
-
/>
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
## RebaseStudio Configuration
|
|
308
|
-
|
|
309
|
-
`<RebaseStudio>` accepts the full `RebaseStudioConfig`:
|
|
310
|
-
|
|
311
|
-
```typescript
|
|
312
|
-
interface RebaseStudioConfig {
|
|
313
|
-
tools?: ("sql" | "js" | "rls" | "schema" | "storage" | "cron"
|
|
314
|
-
| "schema-visualizer" | "branches" | "api" | "logs")[];
|
|
315
|
-
homePage?: ReactNode;
|
|
316
|
-
devViews?: AppView[]; // Computed internally — not passed by consumers
|
|
317
|
-
}
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
## StudioHomePage Customization
|
|
321
|
-
|
|
322
|
-
The `StudioHomePage` component is the default landing page for Studio mode. It renders tool cards organized by section. It can be customized through props:
|
|
323
|
-
|
|
324
|
-
```typescript
|
|
325
|
-
interface StudioHomePageProps {
|
|
326
|
-
additionalActions?: React.ReactNode; // Toolbar actions at the top
|
|
327
|
-
additionalChildrenStart?: React.ReactNode; // Content before tool sections
|
|
328
|
-
additionalChildrenEnd?: React.ReactNode; // Content after tool sections
|
|
329
|
-
sections?: HomePageSection[]; // Extra sections after tools
|
|
330
|
-
hiddenGroups?: string[]; // Groups to hide (unused by default sections)
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
interface HomePageSection {
|
|
334
|
-
key: string; // Unique key
|
|
335
|
-
title: string; // Section header text
|
|
336
|
-
children: React.ReactNode; // Arbitrary content
|
|
337
|
-
}
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
### Built-in Home Page Sections
|
|
341
|
-
|
|
342
|
-
The default `StudioHomePage` renders tools grouped into these sections:
|
|
343
|
-
|
|
344
|
-
| Section | Dot Color | Tools |
|
|
345
|
-
|---------|-----------|-------|
|
|
346
|
-
| Database | Emerald | Collections, Schema Visualizer, SQL Console, Branches, RLS Policies, Logs Explorer |
|
|
347
|
-
| Compute | Blue | JS Console, Cron Jobs |
|
|
348
|
-
| API | Violet | API Explorer |
|
|
349
|
-
| Storage | Amber | Storage |
|
|
350
|
-
| Access Control | Rose | Users, Roles |
|
|
351
|
-
|
|
352
|
-
### Custom Home Page Examples
|
|
353
|
-
|
|
354
|
-
**Add extra sections:**
|
|
355
|
-
```tsx
|
|
356
|
-
<RebaseStudio
|
|
357
|
-
homePage={
|
|
358
|
-
<StudioHomePage
|
|
359
|
-
sections={[
|
|
360
|
-
{
|
|
361
|
-
key: "analytics",
|
|
362
|
-
title: "Analytics",
|
|
363
|
-
children: <AnalyticsDashboard />,
|
|
364
|
-
},
|
|
365
|
-
]}
|
|
366
|
-
/>
|
|
367
|
-
}
|
|
368
|
-
/>
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
**Add action buttons:**
|
|
372
|
-
```tsx
|
|
373
|
-
<RebaseStudio
|
|
374
|
-
homePage={
|
|
375
|
-
<StudioHomePage
|
|
376
|
-
additionalActions={
|
|
377
|
-
<Button onClick={exportAll}>Export All Data</Button>
|
|
378
|
-
}
|
|
379
|
-
/>
|
|
380
|
-
}
|
|
381
|
-
/>
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
**Completely replace the home page:**
|
|
385
|
-
```tsx
|
|
386
|
-
<RebaseStudio
|
|
387
|
-
homePage={<MyCustomStudioHome />}
|
|
388
|
-
/>
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
## Custom Login View
|
|
392
|
-
|
|
393
|
-
Use `<RebaseAuth>` with the `loginView` prop to replace the default login UI:
|
|
394
|
-
|
|
395
|
-
```tsx
|
|
396
|
-
<Rebase client={rebaseClient} authController={authController}>
|
|
397
|
-
<RebaseAuth loginView={<MyCustomLoginPage />} />
|
|
398
|
-
<RebaseCMS collections={collections} />
|
|
399
|
-
<RebaseStudio />
|
|
400
|
-
<RebaseShell title="My App" />
|
|
401
|
-
</Rebase>
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
The `loginView` is registered into the `RebaseRegistry` via `registerAuth()` and consumed by `<RebaseAuthGate>`.
|
|
405
|
-
|
|
406
|
-
## Custom Views
|
|
407
|
-
|
|
408
|
-
Add custom React views to the Studio navigation using the `AppView` interface:
|
|
409
|
-
|
|
410
|
-
```typescript
|
|
411
|
-
interface AppView {
|
|
412
|
-
slug: string; // URL path segment
|
|
413
|
-
name: string; // Display name
|
|
414
|
-
description?: string; // Optional description (Markdown)
|
|
415
|
-
icon?: string | React.ReactNode; // Lucide icon name or custom element
|
|
416
|
-
hideFromNavigation?: boolean; // Hide from sidebar (still accessible by URL)
|
|
417
|
-
group?: string; // Navigation group name
|
|
418
|
-
view: React.ReactNode; // React component to render
|
|
419
|
-
nestedRoutes?: boolean; // Enable nested routing (slug/*)
|
|
420
|
-
}
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
Custom views are typically added through `entityViews` on `<RebaseCMS>` or through plugins.
|
|
424
|
-
|
|
425
|
-
## CollectionPanel Component
|
|
426
|
-
|
|
427
|
-
`CollectionPanel` is a high-level wrapper for embedding collection views inside custom pages (dashboards, home pages, entity detail views):
|
|
428
|
-
|
|
429
|
-
```typescript
|
|
430
|
-
import { CollectionPanel } from "@rebasepro/admin";
|
|
431
|
-
|
|
432
|
-
type CollectionPanelProps = {
|
|
433
|
-
path: string; // Collection slug (required)
|
|
434
|
-
title?: string | false; // Title above the collection (false = hide)
|
|
435
|
-
viewMode?: ViewMode; // Force view mode (table, card, etc.)
|
|
436
|
-
sort?: [string, "asc" | "desc"]; // Override sort
|
|
437
|
-
limit?: number; // Max entities to display
|
|
438
|
-
updateUrl?: boolean; // Sync filter/sort with URL (default: false)
|
|
439
|
-
openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
|
|
440
|
-
className?: string; // Container CSS class
|
|
441
|
-
collectionOverrides?: Partial<EntityCollection>; // Additional overrides
|
|
442
|
-
};
|
|
443
|
-
```
|
|
444
|
-
|
|
445
|
-
### Usage Examples
|
|
446
|
-
|
|
447
|
-
```tsx
|
|
448
|
-
import { CollectionPanel } from "@rebasepro/admin";
|
|
449
|
-
|
|
450
|
-
function MyDashboard() {
|
|
451
|
-
return (
|
|
452
|
-
<div>
|
|
453
|
-
{/* Simple usage */}
|
|
454
|
-
<CollectionPanel path="tasks" title="Pending Tasks" />
|
|
455
|
-
|
|
456
|
-
{/* With overrides */}
|
|
457
|
-
<CollectionPanel
|
|
458
|
-
path="clients"
|
|
459
|
-
viewMode="table"
|
|
460
|
-
limit={10}
|
|
461
|
-
sort={["createdAt", "desc"]}
|
|
462
|
-
collectionOverrides={{
|
|
463
|
-
defaultFilter: { status: ["!=", "completed"] }
|
|
464
|
-
}}
|
|
465
|
-
/>
|
|
466
|
-
|
|
467
|
-
{/* Hide title, custom open mode */}
|
|
468
|
-
<CollectionPanel
|
|
469
|
-
path="orders"
|
|
470
|
-
title={false}
|
|
471
|
-
openEntityMode="dialog"
|
|
472
|
-
/>
|
|
473
|
-
</div>
|
|
474
|
-
);
|
|
475
|
-
}
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
> **IMPORTANT FOR AGENTS:** `CollectionPanel` defaults `updateUrl` to `false` so embedded panels don't hijack the browser URL. If you need URL sync, explicitly set `updateUrl={true}`.
|
|
479
|
-
|
|
480
|
-
## Studio Bridge Hooks
|
|
481
|
-
|
|
482
|
-
The Studio Bridge provides CMS capabilities to Studio components. When CMS is present, real implementations are injected. When CMS is absent, noop defaults ensure Studio works standalone.
|
|
483
|
-
|
|
484
|
-
### Bridge Interface
|
|
485
|
-
|
|
486
|
-
```typescript
|
|
487
|
-
interface StudioBridge {
|
|
488
|
-
collectionRegistry: CollectionRegistryController;
|
|
489
|
-
sideEntityController: SideEntityController;
|
|
490
|
-
urlController: UrlController;
|
|
491
|
-
navigationState: NavigationStateController;
|
|
492
|
-
breadcrumbs: BreadcrumbsController;
|
|
493
|
-
}
|
|
494
|
-
```
|
|
495
|
-
|
|
496
|
-
### Bridge Hook Reference
|
|
497
|
-
|
|
498
|
-
| Hook | Return Type | Description |
|
|
499
|
-
|------|-------------|-------------|
|
|
500
|
-
| `useStudioCollectionRegistry()` | `CollectionRegistryController` | Access registered collections from Studio |
|
|
501
|
-
| `useStudioSideEntityController()` | `SideEntityController` | Open/close entity side panels from Studio |
|
|
502
|
-
| `useStudioUrlController()` | `UrlController` | Build URLs and navigate from Studio |
|
|
503
|
-
| `useStudioNavigationState()` | `NavigationStateController` | Access navigation state from Studio |
|
|
504
|
-
| `useStudioBreadcrumbs()` | `BreadcrumbsController` | Set breadcrumbs from Studio tools |
|
|
505
|
-
|
|
506
|
-
All bridge hooks are exported from `@rebasepro/studio` (re-exported from `@rebasepro/core`):
|
|
507
|
-
|
|
508
|
-
```typescript
|
|
509
|
-
import {
|
|
510
|
-
useStudioCollectionRegistry,
|
|
511
|
-
useStudioSideEntityController,
|
|
512
|
-
useStudioUrlController,
|
|
513
|
-
useStudioNavigationState,
|
|
514
|
-
useStudioBreadcrumbs
|
|
515
|
-
} from "@rebasepro/studio";
|
|
516
|
-
```
|
|
517
|
-
|
|
518
|
-
### BreadcrumbsController
|
|
519
|
-
|
|
520
|
-
```typescript
|
|
521
|
-
interface BreadcrumbEntry {
|
|
522
|
-
title: string;
|
|
523
|
-
url: string;
|
|
524
|
-
count?: number | null;
|
|
525
|
-
id?: string;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
interface BreadcrumbsController {
|
|
529
|
-
breadcrumbs: BreadcrumbEntry[];
|
|
530
|
-
set: (props: { breadcrumbs: BreadcrumbEntry[] }) => void;
|
|
531
|
-
updateCount: (id: string, count: number | null | undefined) => void;
|
|
532
|
-
}
|
|
533
|
-
```
|
|
534
|
-
|
|
535
|
-
### StudioBridgeProvider (Advanced)
|
|
536
|
-
|
|
537
|
-
For custom wiring, use `StudioBridgeProvider` to inject CMS capabilities:
|
|
538
|
-
|
|
539
|
-
```tsx
|
|
540
|
-
import { StudioBridgeProvider } from "@rebasepro/studio";
|
|
541
|
-
|
|
542
|
-
<StudioBridgeProvider value={{
|
|
543
|
-
collectionRegistry: useCollectionRegistryController(),
|
|
544
|
-
sideEntityController: useSideEntityController(),
|
|
545
|
-
urlController: useUrlController(),
|
|
546
|
-
navigationState: useNavigationStateController(),
|
|
547
|
-
breadcrumbs: useBreadcrumbsController(),
|
|
548
|
-
}}>
|
|
549
|
-
<RebaseStudio />
|
|
550
|
-
</StudioBridgeProvider>
|
|
551
|
-
```
|
|
552
|
-
|
|
553
|
-
## Core Hooks Reference
|
|
554
|
-
|
|
555
|
-
These hooks are exported from `@rebasepro/core` and available inside any `<Rebase>` provider tree:
|
|
556
|
-
|
|
557
|
-
### Primary Hooks
|
|
558
|
-
|
|
559
|
-
| Hook | Return Type | Description |
|
|
560
|
-
|------|-------------|-------------|
|
|
561
|
-
| `useRebaseContext()` | `RebaseContext` | Full Rebase context with all controllers |
|
|
562
|
-
| `useAuthController()` | `AuthController` | Access current user and auth state |
|
|
563
|
-
| `useAdminModeController()` | `AdminModeController` | Read/set admin mode (`content` / `studio` / `settings`) |
|
|
564
|
-
| `useEffectiveRoleController()` | `EffectiveRoleController` | Simulate a role for previewing |
|
|
565
|
-
| `useModeController()` | `ModeController` | Read/set color theme (`light` / `dark`) |
|
|
566
|
-
| `useSnackbarController()` | `SnackbarController` | Show toast notifications |
|
|
567
|
-
| `useStorageSource()` | `StorageSource` | Access file storage |
|
|
568
|
-
| `useData()` | `DataSource` | Access the data source for CRUD ops |
|
|
569
|
-
| `useDialogsController()` | `DialogsController` | Programmatic dialog management |
|
|
570
|
-
| `useCustomizationController()` | `CustomizationController` | Access plugins, slots, property configs |
|
|
571
|
-
| `usePermissions()` | `{ canCreate, canEdit, canDelete, canRead }` | Role-aware permission checks |
|
|
572
|
-
|
|
573
|
-
### UI & Layout Hooks
|
|
574
|
-
|
|
575
|
-
| Hook | Return Type | Description |
|
|
576
|
-
|------|-------------|-------------|
|
|
577
|
-
| `useLargeLayout()` | `boolean` | `true` when viewport ≥ 1025px (lg breakpoint) |
|
|
578
|
-
| `useClipboard(options?)` | `useClipboardReturnType` | Copy/cut to clipboard with `ref` or text |
|
|
579
|
-
| `useSlot(name, props)` | `ReactNode \| null` | Render plugin slot contributions |
|
|
580
|
-
| `useTranslation()` | `{ t }` | Access `t()` for i18n translations |
|
|
581
|
-
| `useCollapsedGroups(groups, namespace, defaults)` | `{ isGroupCollapsed, toggleGroupCollapsed }` | Manage collapsible navigation groups |
|
|
582
|
-
|
|
583
|
-
### Navigation & Data Hooks (from `@rebasepro/admin`)
|
|
584
|
-
|
|
585
|
-
| Hook | Package | Description |
|
|
586
|
-
|------|---------|-------------|
|
|
587
|
-
| `useSideEntityController()` | `@rebasepro/admin` | Open/close entity side panels |
|
|
588
|
-
| `useNavigationStateController()` | `@rebasepro/admin` | Navigate between views |
|
|
589
|
-
| `useUrlController()` | `@rebasepro/admin` | Build URLs and navigate |
|
|
590
|
-
| `useBreadcrumbsController()` | `@rebasepro/admin` | Set breadcrumbs |
|
|
591
|
-
| `useRebaseRegistry()` | `@rebasepro/core` | Access the full registry (CMS + Studio + Auth configs) |
|
|
592
|
-
| `useRebaseClient()` | `@rebasepro/core` | Access the `RebaseClient` instance |
|
|
593
|
-
|
|
594
|
-
### ModeController (Color Theme)
|
|
595
|
-
|
|
596
|
-
```typescript
|
|
597
|
-
interface ModeController {
|
|
598
|
-
mode: "light" | "dark";
|
|
599
|
-
setMode: (mode: "light" | "dark" | "system") => void;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
// Usage
|
|
603
|
-
const { mode, setMode } = useModeController();
|
|
604
|
-
setMode("dark"); // Force dark mode
|
|
605
|
-
setMode("system"); // Follow OS preference
|
|
606
|
-
```
|
|
607
|
-
|
|
608
|
-
### useClipboard
|
|
609
|
-
|
|
610
|
-
```typescript
|
|
611
|
-
interface UseClipboardProps {
|
|
612
|
-
onSuccess?: (text: string) => void;
|
|
613
|
-
onError?: (error: string) => void;
|
|
614
|
-
disableClipboardAPI?: boolean;
|
|
615
|
-
copiedDuration?: number; // ms before isCoppied resets to false
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
const { copy, cut, isCoppied, clipboard, clearClipboard, ref, isSupported } = useClipboard({
|
|
619
|
-
copiedDuration: 2000
|
|
620
|
-
});
|
|
621
|
-
|
|
622
|
-
// Copy text directly
|
|
623
|
-
copy("Hello world");
|
|
624
|
-
|
|
625
|
-
// Copy from a ref
|
|
626
|
-
<input ref={ref} />
|
|
627
|
-
<button onClick={() => copy()}>Copy</button>
|
|
628
|
-
```
|
|
629
|
-
|
|
630
|
-
### usePermissions
|
|
631
|
-
|
|
632
|
-
```typescript
|
|
633
|
-
const { canCreate, canEdit, canDelete, canRead } = usePermissions();
|
|
634
|
-
|
|
635
|
-
// Check if current user can create in a collection
|
|
636
|
-
if (canCreate(myCollection, "products")) { ... }
|
|
637
|
-
|
|
638
|
-
// Check if current user can edit a specific entity
|
|
639
|
-
if (canEdit(myCollection, "products", entity)) { ... }
|
|
640
|
-
```
|
|
641
|
-
|
|
642
|
-
### useRebaseContext
|
|
643
|
-
|
|
644
|
-
Returns the full context object combining all controllers:
|
|
645
|
-
|
|
646
|
-
```typescript
|
|
647
|
-
const context = useRebaseContext();
|
|
648
|
-
|
|
649
|
-
// Access any controller
|
|
650
|
-
context.authController // Auth state
|
|
651
|
-
context.data // Data source
|
|
652
|
-
context.storageSource // File storage
|
|
653
|
-
context.snackbarController // Toast notifications
|
|
654
|
-
context.effectiveRoleController // Role simulation
|
|
655
|
-
context.databaseAdmin // Database admin capabilities
|
|
656
|
-
context.client // RebaseClient instance
|
|
657
|
-
```
|
|
658
|
-
|
|
659
|
-
## RebaseShell Configuration
|
|
660
|
-
|
|
661
|
-
`<RebaseShell>` composes all CMS layers with sensible defaults:
|
|
662
|
-
|
|
663
|
-
```typescript
|
|
664
|
-
interface RebaseShellProps {
|
|
665
|
-
title?: string; // App title (default: "Rebase")
|
|
666
|
-
appBar?: React.ReactNode; // Custom app bar
|
|
667
|
-
drawer?: React.ReactNode; // Custom drawer
|
|
668
|
-
autoOpenDrawer?: boolean; // Auto-open drawer on mount (default: false)
|
|
669
|
-
children?: React.ReactNode; // Additional route content
|
|
670
|
-
}
|
|
671
|
-
```
|
|
672
|
-
|
|
673
|
-
Internally it composes:
|
|
674
|
-
```
|
|
675
|
-
<RebaseAuthGate>
|
|
676
|
-
<RebaseNavigation>
|
|
677
|
-
<RebaseRouteDefs layout={<RebaseLayout>}>
|
|
678
|
-
{children}
|
|
679
|
-
</RebaseRouteDefs>
|
|
680
|
-
</RebaseNavigation>
|
|
681
|
-
</RebaseAuthGate>
|
|
682
|
-
```
|
|
683
|
-
|
|
684
|
-
## Visual Collection Editor
|
|
685
|
-
|
|
686
|
-
The Studio's collection editor allows non-developers to:
|
|
687
|
-
- Add, remove, and reorder fields
|
|
688
|
-
- Configure field types and validation
|
|
689
|
-
- Set up enum values and relations
|
|
690
|
-
- Preview the form layout
|
|
691
|
-
|
|
692
|
-
Under the hood, it uses **AST manipulation** (via `ts-morph`) to modify the TypeScript collection files — preserving all custom callbacks and code.
|
|
693
|
-
|
|
694
|
-
### Enabling the Collection Editor
|
|
695
|
-
|
|
696
|
-
```tsx
|
|
697
|
-
// Simple — uses authController.getAuthToken automatically
|
|
698
|
-
<RebaseCMS collections={collections} collectionEditor={true} />
|
|
699
|
-
|
|
700
|
-
// With options
|
|
701
|
-
<RebaseCMS
|
|
702
|
-
collections={collections}
|
|
703
|
-
collectionEditor={{
|
|
704
|
-
getAuthToken: authController.getAuthToken,
|
|
705
|
-
readOnly: false,
|
|
706
|
-
pathSuggestions: ["config/collections/"]
|
|
707
|
-
}}
|
|
708
|
-
/>
|
|
709
|
-
```
|
|
710
|
-
|
|
711
|
-
## Virtual Collection Import
|
|
712
|
-
|
|
713
|
-
Collections are auto-loaded via a Vite plugin:
|
|
714
|
-
|
|
715
|
-
```typescript
|
|
716
|
-
import { collections } from "virtual:rebase-collections";
|
|
717
|
-
```
|
|
718
|
-
|
|
719
|
-
This reads all collection files from the configured collections directory (e.g., `config/collections/`) and makes them available without manual barrel exports.
|
|
720
|
-
|
|
721
|
-
## Running the Studio
|
|
722
|
-
|
|
723
|
-
```bash
|
|
724
|
-
# From the project root
|
|
725
|
-
pnpm run dev
|
|
726
|
-
```
|
|
727
|
-
|
|
728
|
-
This starts both frontend and backend. The Studio is accessible at `http://localhost:5173` (Vite default).
|
|
729
|
-
|
|
730
|
-
## Key Packages
|
|
731
|
-
|
|
732
|
-
| Package | Description |
|
|
733
|
-
|---------|-------------|
|
|
734
|
-
| `@rebasepro/core` | Core framework, hooks, types, `<Rebase>` provider |
|
|
735
|
-
| `@rebasepro/studio` | Studio admin panel (`<RebaseStudio>`, `StudioHomePage`, bridge hooks) |
|
|
736
|
-
| `@rebasepro/admin` | CMS frontend (`<RebaseCMS>`, `<RebaseShell>`, `CollectionPanel`, collection editor) |
|
|
737
|
-
| `@rebasepro/ui` | Component library (Tailwind v4 + Radix) |
|
|
738
|
-
| `@rebasepro/types` | Shared TypeScript types |
|
|
739
|
-
| `@rebasepro/plugin-data-enhancement` | AI-powered autofill |
|
|
740
|
-
| `@rebasepro/schema-inference` | Auto-infer schema from data |
|
|
741
|
-
|
|
742
|
-
## References
|
|
743
|
-
|
|
744
|
-
- **Documentation:** [rebase.pro/docs](https://rebase.pro/docs)
|
|
745
|
-
- **GitHub:** [github.com/rebasepro/rebase](https://github.com/rebasepro/rebase)
|
|
746
|
-
- **Icons:** [rebase.pro/docs/icons](https://rebase.pro/docs/icons) (Lucide-based)
|