@rebasepro/agent-skills 0.0.1-canary.4829d6e

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 (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +96 -0
  3. package/package.json +21 -0
  4. package/skills/rebase-admin/SKILL.md +816 -0
  5. package/skills/rebase-api/SKILL.md +673 -0
  6. package/skills/rebase-api/references/.gitkeep +3 -0
  7. package/skills/rebase-auth/SKILL.md +1323 -0
  8. package/skills/rebase-auth/references/.gitkeep +3 -0
  9. package/skills/rebase-backend-postgres/SKILL.md +633 -0
  10. package/skills/rebase-backend-postgres/references/.gitkeep +3 -0
  11. package/skills/rebase-basics/SKILL.md +757 -0
  12. package/skills/rebase-basics/references/.gitkeep +3 -0
  13. package/skills/rebase-collections/SKILL.md +1421 -0
  14. package/skills/rebase-collections/references/.gitkeep +3 -0
  15. package/skills/rebase-cron-jobs/SKILL.md +704 -0
  16. package/skills/rebase-cron-jobs/references/.gitkeep +1 -0
  17. package/skills/rebase-custom-functions/SKILL.md +281 -0
  18. package/skills/rebase-deployment/SKILL.md +894 -0
  19. package/skills/rebase-deployment/references/.gitkeep +3 -0
  20. package/skills/rebase-design-language/SKILL.md +692 -0
  21. package/skills/rebase-email/SKILL.md +701 -0
  22. package/skills/rebase-email/references/.gitkeep +1 -0
  23. package/skills/rebase-entity-history/SKILL.md +485 -0
  24. package/skills/rebase-entity-history/references/.gitkeep +1 -0
  25. package/skills/rebase-local-env-setup/SKILL.md +189 -0
  26. package/skills/rebase-local-env-setup/references/.gitkeep +3 -0
  27. package/skills/rebase-realtime/SKILL.md +759 -0
  28. package/skills/rebase-realtime/references/.gitkeep +3 -0
  29. package/skills/rebase-sdk/SKILL.md +617 -0
  30. package/skills/rebase-sdk/references/.gitkeep +0 -0
  31. package/skills/rebase-security/SKILL.md +646 -0
  32. package/skills/rebase-storage/SKILL.md +989 -0
  33. package/skills/rebase-storage/references/.gitkeep +3 -0
  34. package/skills/rebase-studio/SKILL.md +772 -0
  35. package/skills/rebase-studio/references/.gitkeep +3 -0
  36. package/skills/rebase-ui-components/SKILL.md +1579 -0
  37. package/skills/rebase-ui-components/references/.gitkeep +3 -0
  38. package/skills/rebase-webhooks/SKILL.md +618 -0
  39. package/skills/rebase-webhooks/references/.gitkeep +1 -0
@@ -0,0 +1,772 @@
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/app";
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/app";
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 `<RebaseAdmin>`. 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>`, `<RebaseAdmin>`, `<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/app";
150
+ import { Rebase } from "@rebasepro/app";
151
+ import { RebaseAdmin, RebaseShell } from "@rebasepro/admin";
152
+ import { useDataEnhancementPlugin } from "@rebasepro/plugin-ai";
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
+ <RebaseAdmin 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/app` | Root provider (client, auth, user management, plugins) | Yes (providers) |
191
+ | `<RebaseAuth>` | `@rebasepro/app` | Authentication config (custom login view) | No — registers into registry |
192
+ | `<RebaseAdmin>` | `@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/app";
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
+ ## RebaseAdmin Configuration
255
+
256
+ `<RebaseAdmin>` accepts the full `RebaseAdminConfig`:
257
+
258
+ ```typescript
259
+ interface RebaseAdminConfig<EC extends CollectionConfig = CollectionConfig> {
260
+ collections?: EC[] | CollectionConfigsBuilder<EC>;
261
+ views?: AppView[] | AppViewsBuilder;
262
+ homePage?: ReactNode;
263
+ entityViews?: EntityCustomView[];
264
+ entityActions?: EntityAction[];
265
+ plugins?: RebasePlugin[];
266
+ navigationGroupMappings?: NavigationGroupMapping[];
267
+ collectionEditor?: boolean | CollectionEditorOptions;
268
+ }
269
+ ```
270
+
271
+ ### Collection Editor Options
272
+
273
+ ```typescript
274
+ interface CollectionEditorOptions {
275
+ /** Auth token for schema-editor API calls. Falls back to authController.getAuthToken. */
276
+ getAuthToken?: () => Promise<string | null>;
277
+ /** Mark the editor as read-only (disable mutations). */
278
+ readOnly?: boolean;
279
+ /** Suggested base paths shown when creating new collections. */
280
+ pathSuggestions?: string[];
281
+ }
282
+ ```
283
+
284
+ ### Navigation Group Mappings
285
+
286
+ Control how collections and views are grouped in the sidebar and home page:
287
+
288
+ ```typescript
289
+ interface NavigationGroupMapping {
290
+ name: string; // Group header display name
291
+ entries: string[]; // Collection slugs or view paths
292
+ collapsedByDefault?: boolean | {
293
+ drawer?: boolean; // Collapse in sidebar
294
+ home?: boolean; // Collapse on home page
295
+ };
296
+ }
297
+
298
+ // Usage
299
+ <RebaseAdmin
300
+ collections={collections}
301
+ navigationGroupMappings={[
302
+ { name: "Content", entries: ["posts", "pages", "media"] },
303
+ { name: "Commerce", entries: ["products", "orders"], collapsedByDefault: { drawer: true } },
304
+ ]}
305
+ />
306
+ ```
307
+
308
+ ## RebaseStudio Configuration
309
+
310
+ `<RebaseStudio>` accepts the full `RebaseStudioConfig`:
311
+
312
+ ```typescript
313
+ interface RebaseStudioConfig {
314
+ tools?: ("sql" | "js" | "rls" | "schema" | "storage" | "cron"
315
+ | "schema-visualizer" | "branches" | "api" | "logs")[];
316
+ homePage?: ReactNode;
317
+ devViews?: AppView[]; // Computed internally — not passed by consumers
318
+ }
319
+ ```
320
+
321
+ ## StudioHomePage Customization
322
+
323
+ The `StudioHomePage` component is the default landing page for Studio mode. It renders tool cards organized by section. It can be customized through props:
324
+
325
+ ```typescript
326
+ interface StudioHomePageProps {
327
+ additionalActions?: React.ReactNode; // Toolbar actions at the top
328
+ additionalChildrenStart?: React.ReactNode; // Content before tool sections
329
+ additionalChildrenEnd?: React.ReactNode; // Content after tool sections
330
+ sections?: HomePageSection[]; // Extra sections after tools
331
+ hiddenGroups?: string[]; // Groups to hide (unused by default sections)
332
+ }
333
+
334
+ interface HomePageSection {
335
+ key: string; // Unique key
336
+ title: string; // Section header text
337
+ children: React.ReactNode; // Arbitrary content
338
+ }
339
+ ```
340
+
341
+ ### Built-in Home Page Sections
342
+
343
+ The default `StudioHomePage` renders tools grouped into these sections:
344
+
345
+ | Section | Dot Color | Tools |
346
+ |---------|-----------|-------|
347
+ | Database | Emerald | Collections, Schema Visualizer, SQL Console, Branches, RLS Policies, Logs Explorer |
348
+ | Compute | Blue | JS Console, Cron Jobs |
349
+ | API | Violet | API Explorer |
350
+ | Storage | Amber | Storage |
351
+ | Access Control | Rose | Users, Roles |
352
+
353
+ ### Custom Home Page Examples
354
+
355
+ **Add extra sections:**
356
+ ```tsx
357
+ <RebaseStudio
358
+ homePage={
359
+ <StudioHomePage
360
+ sections={[
361
+ {
362
+ key: "analytics",
363
+ title: "Analytics",
364
+ children: <AnalyticsDashboard />,
365
+ },
366
+ ]}
367
+ />
368
+ }
369
+ />
370
+ ```
371
+
372
+ **Add action buttons:**
373
+ ```tsx
374
+ <RebaseStudio
375
+ homePage={
376
+ <StudioHomePage
377
+ additionalActions={
378
+ <Button onClick={exportAll}>Export All Data</Button>
379
+ }
380
+ />
381
+ }
382
+ />
383
+ ```
384
+
385
+ **Completely replace the home page:**
386
+ ```tsx
387
+ <RebaseStudio
388
+ homePage={<MyCustomStudioHome />}
389
+ />
390
+ ```
391
+
392
+ ## Custom Login View
393
+
394
+ Use `<RebaseAuth>` with the `loginView` prop to replace the default login UI:
395
+
396
+ ```tsx
397
+ <Rebase client={rebaseClient} authController={authController}>
398
+ <RebaseAuth loginView={<MyCustomLoginPage />} />
399
+ <RebaseAdmin collections={collections} />
400
+ <RebaseStudio />
401
+ <RebaseShell title="My App" />
402
+ </Rebase>
403
+ ```
404
+
405
+ The `loginView` is registered into the `RebaseRegistry` via `registerAuth()` and consumed by `<RebaseAuthGate>`.
406
+
407
+ ## Custom Views
408
+
409
+ Add custom React views to the Studio navigation using the `AppView` interface:
410
+
411
+ ```typescript
412
+ interface AppView {
413
+ slug: string; // URL path segment
414
+ name: string; // Display name
415
+ description?: string; // Optional description (Markdown)
416
+ icon?: string | React.ReactNode; // Lucide icon name or custom element
417
+ hideFromNavigation?: boolean; // Hide from sidebar (still accessible by URL)
418
+ group?: string; // Navigation group name
419
+ view: React.ReactNode; // React component to render
420
+ nestedRoutes?: boolean; // Enable nested routing (slug/*)
421
+ roles?: string[]; // Only show to users with at least one matching role
422
+ }
423
+ ```
424
+
425
+ Custom top-level views are added through the `views` prop on `<RebaseAdmin>`. They can also be contributed by plugins via `plugin.views`.
426
+
427
+ ```tsx
428
+ // Static array
429
+ <RebaseAdmin
430
+ collections={collections}
431
+ views={[
432
+ { slug: "dashboard", name: "Dashboard", icon: "LayoutDashboard", view: <Dashboard /> },
433
+ { slug: "audit-log", name: "Audit Log", icon: "ScrollText", view: <AuditLog />, roles: ["admin"] },
434
+ ]}
435
+ />
436
+
437
+ // Builder function (role-aware, async-capable)
438
+ <RebaseAdmin
439
+ collections={collections}
440
+ views={({ user, authController, data }) => [
441
+ { slug: "dashboard", name: "Dashboard", icon: "LayoutDashboard", view: <Dashboard /> },
442
+ ...(user?.roles?.includes("analyst")
443
+ ? [{ slug: "reports", name: "Reports", icon: "FileText", view: <Reports /> }]
444
+ : []),
445
+ ]}
446
+ />
447
+ ```
448
+
449
+ > **IMPORTANT FOR AGENTS:** The `roles` field on `AppView` provides declarative role filtering — the view is excluded entirely (not just hidden from nav) if the user lacks a matching role. Use `roles` for simple access control and the builder function for dynamic/async cases. Both approaches compose.
450
+
451
+ ## CollectionPanel Component
452
+
453
+ `CollectionPanel` is a high-level wrapper for embedding collection views inside custom pages (dashboards, home pages, entity detail views):
454
+
455
+ ```typescript
456
+ import { CollectionPanel } from "@rebasepro/admin";
457
+
458
+ type CollectionPanelProps = {
459
+ path: string; // Collection slug (required)
460
+ title?: string | false; // Title above the collection (false = hide)
461
+ viewMode?: ViewMode; // Force view mode (table, card, etc.)
462
+ sort?: [string, "asc" | "desc"]; // Override sort
463
+ limit?: number; // Max entities to display
464
+ updateUrl?: boolean; // Sync filter/sort with URL (default: false)
465
+ openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
466
+ className?: string; // Container CSS class
467
+ collectionOverrides?: Partial<CollectionConfig>; // Additional overrides
468
+ };
469
+ ```
470
+
471
+ ### Usage Examples
472
+
473
+ ```tsx
474
+ import { CollectionPanel } from "@rebasepro/admin";
475
+
476
+ function MyDashboard() {
477
+ return (
478
+ <div>
479
+ {/* Simple usage */}
480
+ <CollectionPanel path="tasks" title="Pending Tasks" />
481
+
482
+ {/* With overrides */}
483
+ <CollectionPanel
484
+ path="clients"
485
+ viewMode="table"
486
+ limit={10}
487
+ sort={["createdAt", "desc"]}
488
+ collectionOverrides={{
489
+ defaultFilter: { status: ["!=", "completed"] }
490
+ }}
491
+ />
492
+
493
+ {/* Hide title, custom open mode */}
494
+ <CollectionPanel
495
+ path="orders"
496
+ title={false}
497
+ openEntityMode="dialog"
498
+ />
499
+ </div>
500
+ );
501
+ }
502
+ ```
503
+
504
+ > **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}`.
505
+
506
+ ## Studio Bridge Hooks
507
+
508
+ 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.
509
+
510
+ ### Bridge Interface
511
+
512
+ ```typescript
513
+ interface StudioBridge {
514
+ collectionRegistry: CollectionRegistryController;
515
+ sideEntityController: SidePanelController;
516
+ urlController: UrlController;
517
+ navigationState: NavigationStateController;
518
+ breadcrumbs: BreadcrumbsController;
519
+ }
520
+ ```
521
+
522
+ ### Bridge Hook Reference
523
+
524
+ | Hook | Return Type | Description |
525
+ |------|-------------|-------------|
526
+ | `useStudioCollectionRegistry()` | `CollectionRegistryController` | Access registered collections from Studio |
527
+ | `useStudioSidePanelController()` | `SidePanelController` | Open/close entity side panels from Studio |
528
+ | `useStudioUrlController()` | `UrlController` | Build URLs and navigate from Studio |
529
+ | `useStudioNavigationState()` | `NavigationStateController` | Access navigation state from Studio |
530
+ | `useStudioBreadcrumbs()` | `BreadcrumbsController` | Set breadcrumbs from Studio tools |
531
+
532
+ All bridge hooks are exported from `@rebasepro/studio` (re-exported from `@rebasepro/app`):
533
+
534
+ ```typescript
535
+ import {
536
+ useStudioCollectionRegistry,
537
+ useStudioSidePanelController,
538
+ useStudioUrlController,
539
+ useStudioNavigationState,
540
+ useStudioBreadcrumbs
541
+ } from "@rebasepro/studio";
542
+ ```
543
+
544
+ ### BreadcrumbsController
545
+
546
+ ```typescript
547
+ interface BreadcrumbEntry {
548
+ title: string;
549
+ url: string;
550
+ count?: number | null;
551
+ id?: string;
552
+ }
553
+
554
+ interface BreadcrumbsController {
555
+ breadcrumbs: BreadcrumbEntry[];
556
+ set: (props: { breadcrumbs: BreadcrumbEntry[] }) => void;
557
+ updateCount: (id: string, count: number | null | undefined) => void;
558
+ }
559
+ ```
560
+
561
+ ### StudioBridgeProvider (Advanced)
562
+
563
+ For custom wiring, use `StudioBridgeProvider` to inject CMS capabilities:
564
+
565
+ ```tsx
566
+ import { StudioBridgeProvider } from "@rebasepro/studio";
567
+
568
+ <StudioBridgeProvider value={{
569
+ collectionRegistry: useCollectionRegistryController(),
570
+ sideEntityController: useSidePanel(),
571
+ urlController: useUrlController(),
572
+ navigationState: useNavigationStateController(),
573
+ breadcrumbs: useBreadcrumbsController(),
574
+ }}>
575
+ <RebaseStudio />
576
+ </StudioBridgeProvider>
577
+ ```
578
+
579
+ ## Core Hooks Reference
580
+
581
+ These hooks are exported from `@rebasepro/app` and available inside any `<Rebase>` provider tree:
582
+
583
+ ### Primary Hooks
584
+
585
+ | Hook | Return Type | Description |
586
+ |------|-------------|-------------|
587
+ | `useRebaseContext()` | `RebaseContext` | Full Rebase context with all controllers |
588
+ | `useAuthController()` | `AuthController` | Access current user and auth state |
589
+ | `useAdminModeController()` | `AdminModeController` | Read/set admin mode (`content` / `studio` / `settings`) |
590
+ | `useEffectiveRoleController()` | `EffectiveRoleController` | Simulate a role for previewing |
591
+ | `useModeController()` | `ModeController` | Read/set color theme (`light` / `dark`) |
592
+ | `useSnackbarController()` | `SnackbarController` | Show toast notifications |
593
+ | `useStorageSource()` | `StorageSource` | Access file storage |
594
+ | `useData()` | `DataSource` | Access the data source for CRUD ops |
595
+ | `useDialogsController()` | `DialogsController` | Programmatic dialog management |
596
+ | `useCustomizationController()` | `CustomizationController` | Access plugins, slots, property configs |
597
+ | `usePermissions()` | `{ canCreate, canEdit, canDelete, canRead }` | Role-aware permission checks |
598
+
599
+ ### UI & Layout Hooks
600
+
601
+ | Hook | Return Type | Description |
602
+ |------|-------------|-------------|
603
+ | `useLargeLayout()` | `boolean` | `true` when viewport ≥ 1025px (lg breakpoint) |
604
+ | `useClipboard(options?)` | `useClipboardReturnType` | Copy/cut to clipboard with `ref` or text |
605
+ | `useSlot(name, props)` | `ReactNode \| null` | Render plugin slot contributions |
606
+ | `useTranslation()` | `{ t }` | Access `t()` for i18n translations |
607
+ | `useCollapsedGroups(groups, namespace, defaults)` | `{ isGroupCollapsed, toggleGroupCollapsed }` | Manage collapsible navigation groups |
608
+
609
+ ### Navigation & Data Hooks (from `@rebasepro/admin`)
610
+
611
+ | Hook | Package | Description |
612
+ |------|---------|-------------|
613
+ | `useSidePanel()` | `@rebasepro/admin` | Open/close entity side panels |
614
+ | `useNavigationStateController()` | `@rebasepro/admin` | Navigate between views |
615
+ | `useUrlController()` | `@rebasepro/admin` | Build URLs and navigate |
616
+ | `useBreadcrumbsController()` | `@rebasepro/admin` | Set breadcrumbs |
617
+ | `useRebaseRegistry()` | `@rebasepro/app` | Access the full registry (CMS + Studio + Auth configs) |
618
+ | `useRebaseClient()` | `@rebasepro/app` | Access the `RebaseClient` instance |
619
+
620
+ ### ModeController (Color Theme)
621
+
622
+ ```typescript
623
+ interface ModeController {
624
+ mode: "light" | "dark";
625
+ setMode: (mode: "light" | "dark" | "system") => void;
626
+ }
627
+
628
+ // Usage
629
+ const { mode, setMode } = useModeController();
630
+ setMode("dark"); // Force dark mode
631
+ setMode("system"); // Follow OS preference
632
+ ```
633
+
634
+ ### useClipboard
635
+
636
+ ```typescript
637
+ interface UseClipboardProps {
638
+ onSuccess?: (text: string) => void;
639
+ onError?: (error: string) => void;
640
+ disableClipboardAPI?: boolean;
641
+ copiedDuration?: number; // ms before isCoppied resets to false
642
+ }
643
+
644
+ const { copy, cut, isCoppied, clipboard, clearClipboard, ref, isSupported } = useClipboard({
645
+ copiedDuration: 2000
646
+ });
647
+
648
+ // Copy text directly
649
+ copy("Hello world");
650
+
651
+ // Copy from a ref
652
+ <input ref={ref} />
653
+ <button onClick={() => copy()}>Copy</button>
654
+ ```
655
+
656
+ ### usePermissions
657
+
658
+ ```typescript
659
+ const { canCreate, canEdit, canDelete, canRead } = usePermissions();
660
+
661
+ // Check if current user can create in a collection
662
+ if (canCreate(myCollection, "products")) { ... }
663
+
664
+ // Check if current user can edit a specific entity
665
+ if (canEdit(myCollection, "products", entity)) { ... }
666
+ ```
667
+
668
+ ### useRebaseContext
669
+
670
+ Returns the full context object combining all controllers:
671
+
672
+ ```typescript
673
+ const context = useRebaseContext();
674
+
675
+ // Access any controller
676
+ context.authController // Auth state
677
+ context.data // Data source
678
+ context.storageSource // File storage
679
+ context.snackbarController // Toast notifications
680
+ context.effectiveRoleController // Role simulation
681
+ context.databaseAdmin // Database admin capabilities
682
+ context.client // RebaseClient instance
683
+ ```
684
+
685
+ ## RebaseShell Configuration
686
+
687
+ `<RebaseShell>` composes all CMS layers with sensible defaults:
688
+
689
+ ```typescript
690
+ interface RebaseShellProps {
691
+ title?: string; // App title (default: "Rebase")
692
+ appBar?: React.ReactNode; // Custom app bar
693
+ drawer?: React.ReactNode; // Custom drawer
694
+ autoOpenDrawer?: boolean; // Auto-open drawer on mount (default: false)
695
+ children?: React.ReactNode; // Additional route content
696
+ }
697
+ ```
698
+
699
+ Internally it composes:
700
+ ```
701
+ <RebaseAuthGate>
702
+ <RebaseNavigation>
703
+ <RebaseRouteDefs layout={<RebaseLayout>}>
704
+ {children}
705
+ </RebaseRouteDefs>
706
+ </RebaseNavigation>
707
+ </RebaseAuthGate>
708
+ ```
709
+
710
+ ## Visual Collection Editor
711
+
712
+ The Studio's collection editor allows non-developers to:
713
+ - Add, remove, and reorder fields
714
+ - Configure field types and validation
715
+ - Set up enum values and relations
716
+ - Preview the form layout
717
+
718
+ Under the hood, it uses **AST manipulation** (via `ts-morph`) to modify the TypeScript collection files — preserving all custom callbacks and code.
719
+
720
+ ### Enabling the Collection Editor
721
+
722
+ ```tsx
723
+ // Simple — uses authController.getAuthToken automatically
724
+ <RebaseAdmin collections={collections} collectionEditor={true} />
725
+
726
+ // With options
727
+ <RebaseAdmin
728
+ collections={collections}
729
+ collectionEditor={{
730
+ getAuthToken: authController.getAuthToken,
731
+ readOnly: false,
732
+ pathSuggestions: ["config/collections/"]
733
+ }}
734
+ />
735
+ ```
736
+
737
+ ## Virtual Collection Import
738
+
739
+ Collections are auto-loaded via a Vite plugin:
740
+
741
+ ```typescript
742
+ import { collections } from "virtual:rebase-collections";
743
+ ```
744
+
745
+ This reads all collection files from the configured collections directory (e.g., `config/collections/`) and makes them available without manual barrel exports.
746
+
747
+ ## Running the Studio
748
+
749
+ ```bash
750
+ # From the project root
751
+ pnpm run dev
752
+ ```
753
+
754
+ This starts both frontend and backend. The Studio is accessible at `http://localhost:5173` (Vite default).
755
+
756
+ ## Key Packages
757
+
758
+ | Package | Description |
759
+ |---------|-------------|
760
+ | `@rebasepro/app` | Core framework, hooks, types, `<Rebase>` provider |
761
+ | `@rebasepro/studio` | Studio admin panel (`<RebaseStudio>`, `StudioHomePage`, bridge hooks) |
762
+ | `@rebasepro/admin` | CMS frontend (`<RebaseAdmin>`, `<RebaseShell>`, `CollectionPanel`, collection editor) |
763
+ | `@rebasepro/ui` | Component library (Tailwind v4 + Radix) |
764
+ | `@rebasepro/types` | Shared TypeScript types |
765
+ | `@rebasepro/plugin-ai` | AI-powered autofill |
766
+ | `@rebasepro/inference` | Auto-infer schema from data |
767
+
768
+ ## References
769
+
770
+ - **Documentation:** [rebase.pro/docs](https://rebase.pro/docs)
771
+ - **GitHub:** [github.com/rebasepro/rebase](https://github.com/rebasepro/rebase)
772
+ - **Icons:** [rebase.pro/docs/icons](https://rebase.pro/docs/icons) (Lucide-based)