@rebasepro/studio 0.34.1 → 0.35.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.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/dist/{ApiExplorer-BhQFd_iR.js → ApiExplorer-C61w8gCc.js} +73 -58
  3. package/dist/ApiExplorer-C61w8gCc.js.map +1 -0
  4. package/dist/{ApiKeysView-CLBXUCgu.js → ApiKeysView-BdqASL_2.js} +33 -32
  5. package/dist/ApiKeysView-BdqASL_2.js.map +1 -0
  6. package/dist/{BranchesView-BKGhk-PC.js → BranchesView-Bh5lq9T_.js} +5 -5
  7. package/dist/BranchesView-Bh5lq9T_.js.map +1 -0
  8. package/dist/{CronJobsView-CwF_m6ZB.js → CronJobsView-DUuyzkJK.js} +392 -8
  9. package/dist/CronJobsView-DUuyzkJK.js.map +1 -0
  10. package/dist/FixedEditorOverlay-DtgPBSjq.js +93 -0
  11. package/dist/FixedEditorOverlay-DtgPBSjq.js.map +1 -0
  12. package/dist/{JSEditor-Br22PfLh.js → JSEditor-Bi2Aol-Y.js} +27 -21
  13. package/dist/JSEditor-Bi2Aol-Y.js.map +1 -0
  14. package/dist/{LogsExplorer-DOLRFQaW.js → LogsExplorer-BA8RfTwd.js} +46 -67
  15. package/dist/LogsExplorer-BA8RfTwd.js.map +1 -0
  16. package/dist/{RLSEditor-RE4YpN_z.js → RLSEditor-CTG3jLE7.js} +478 -224
  17. package/dist/RLSEditor-CTG3jLE7.js.map +1 -0
  18. package/dist/{SQLEditor-Dj5INEUZ.js → SQLEditor-DRo5kW1h.js} +15 -96
  19. package/dist/SQLEditor-DRo5kW1h.js.map +1 -0
  20. package/dist/{SchemaVisualizer-D2_cck4I.js → SchemaVisualizer-Dy4kWKT5.js} +15 -14
  21. package/dist/SchemaVisualizer-Dy4kWKT5.js.map +1 -0
  22. package/dist/{StorageView-DHm22S7y.js → StorageView-D0D8z4lI.js} +497 -4
  23. package/dist/StorageView-D0D8z4lI.js.map +1 -0
  24. package/dist/TableEditorView-BKhSBG-K.js +1694 -0
  25. package/dist/TableEditorView-BKhSBG-K.js.map +1 -0
  26. package/dist/UsersAndRolesView-CKw4SJPj.js +689 -0
  27. package/dist/UsersAndRolesView-CKw4SJPj.js.map +1 -0
  28. package/dist/WebhooksView-CFPY-N9h.js +465 -0
  29. package/dist/WebhooksView-CFPY-N9h.js.map +1 -0
  30. package/dist/adminFetch-BfOnfRgU.js +108 -0
  31. package/dist/adminFetch-BfOnfRgU.js.map +1 -0
  32. package/dist/components/ApiExplorer/TryItPanel.d.ts +6 -0
  33. package/dist/components/ApiKeys/scope-words.d.ts +1 -1
  34. package/dist/components/AuthSimulationSelector.d.ts +9 -1
  35. package/dist/components/CronJobs/DbCronJobsPanel.d.ts +2 -0
  36. package/dist/components/RLSEditor/DirectRlsPoliciesPanel.d.ts +7 -0
  37. package/dist/components/RebaseStudio.d.ts +1 -1
  38. package/dist/components/RebaseStudioApp.d.ts +28 -0
  39. package/dist/components/SQLEditor/FixedEditorOverlay.d.ts +12 -0
  40. package/dist/components/SQLEditor/SQLEditor.d.ts +2 -11
  41. package/dist/components/StorageView/StoragePoliciesPanel.d.ts +2 -0
  42. package/dist/components/StudioHomePage.d.ts +3 -1
  43. package/dist/components/TableEditor/TableEditorView.d.ts +2 -0
  44. package/dist/components/UsersAndRoles/UsersAndRolesView.d.ts +2 -0
  45. package/dist/components/Webhooks/WebhooksView.d.ts +2 -0
  46. package/dist/index.d.ts +1 -0
  47. package/dist/index.es.js +739 -109
  48. package/dist/index.es.js.map +1 -1
  49. package/dist/policy-presets-CJKzAvQp.js +167 -0
  50. package/dist/policy-presets-CJKzAvQp.js.map +1 -0
  51. package/dist/{useRunAsUsers-CLaAtXt6.js → useRunAsUsers-CF7tkGzj.js} +22 -3
  52. package/dist/useRunAsUsers-CF7tkGzj.js.map +1 -0
  53. package/dist/utils/adminFetch.d.ts +25 -0
  54. package/package.json +12 -16
  55. package/dist/ApiExplorer-BhQFd_iR.js.map +0 -1
  56. package/dist/ApiKeysView-CLBXUCgu.js.map +0 -1
  57. package/dist/BranchesView-BKGhk-PC.js.map +0 -1
  58. package/dist/CronJobsView-CwF_m6ZB.js.map +0 -1
  59. package/dist/JSEditor-Br22PfLh.js.map +0 -1
  60. package/dist/LogsExplorer-DOLRFQaW.js.map +0 -1
  61. package/dist/RLSEditor-RE4YpN_z.js.map +0 -1
  62. package/dist/SQLEditor-Dj5INEUZ.js.map +0 -1
  63. package/dist/SchemaVisualizer-D2_cck4I.js.map +0 -1
  64. package/dist/StorageView-DHm22S7y.js.map +0 -1
  65. package/dist/useRunAsUsers-CLaAtXt6.js.map +0 -1
package/dist/index.es.js CHANGED
@@ -1,18 +1,78 @@
1
- import { IconForView, SchemaDriftBanner, StudioBridgeContext, StudioBridgeProvider, useApiConfig, useNavigationGroupLabel, useRebaseContext, useRebaseEmbedHost, useRebaseRegistry, useRebaseRegistryDispatch, useRestoreScroll, useSlot, useStudioBreadcrumbs, useStudioBreadcrumbs as useStudioBreadcrumbs$1, useStudioCollectionRegistry, useStudioNavigationState, useStudioSidePanelController, useStudioUrlController, useTranslation } from "@rebasepro/app";
1
+ import { o as isRecord, s as useAdminFetch } from "./adminFetch-BfOnfRgU.js";
2
+ import { IconForView, Rebase, SchemaDriftBanner, StudioBridgeContext, StudioBridgeProvider, useApiConfig, useModeController, useNavigationGroupLabel, useRebaseAuthController, useRebaseContext, useRebaseEmbedHost, useRebaseRegistry, useRebaseRegistryDispatch, useRestoreScroll, useSlot, useStudioBreadcrumbs, useStudioBreadcrumbs as useStudioBreadcrumbs$1, useStudioCollectionRegistry, useStudioNavigationState, useStudioSidePanelController, useStudioUrlController, useTranslation } from "@rebasepro/app";
2
3
  import React, { Suspense, useEffect, useLayoutEffect, useMemo, useState } from "react";
3
- import { Card, CircularProgressCenter, Container, ExpandablePanel, Typography, cls, lazyChunk } from "@rebasepro/ui";
4
+ import { Alert, ArrowRightIcon, Button, Card, CircularProgressCenter, Container, ExpandablePanel, HomeIcon, IconButton, LogOutIcon, MoonIcon, SearchBar, StatusDot, SunIcon, TextField, Tooltip, Typography, cls, defaultBorderMixin, iconSize, lazyChunk } from "@rebasepro/ui";
4
5
  import { jsx, jsxs } from "react/jsx-runtime";
5
- import { studioSchemaToolEnabled } from "@rebasepro/cms-types";
6
- import { useNavigate } from "react-router";
6
+ import { BrowserRouter, Navigate, Route, Routes, useLocation, useNavigate } from "react-router";
7
+ import { createRebaseClient } from "@rebasepro/client";
7
8
  //#region src/components/StudioHomePage.tsx
9
+ var TOOL_READOUTS = {
10
+ "/s/tables": {
11
+ label: "ENGINE",
12
+ value: "DDL · ROWS · INDEXES"
13
+ },
14
+ "/s/sql": {
15
+ label: "QUERY",
16
+ value: "SQL · EXPLAIN"
17
+ },
18
+ "/s/rls": {
19
+ label: "ACCESS",
20
+ value: "POLICIES · SIMULATOR"
21
+ },
22
+ "/s/schema": {
23
+ label: "GRAPH",
24
+ value: "ERD · RELATIONS"
25
+ },
26
+ "/s/branches": {
27
+ label: "SCHEMA",
28
+ value: "BRANCH · DIFF"
29
+ },
30
+ "/s/backups": {
31
+ label: "SNAPSHOT",
32
+ value: "DUMP · RESTORE"
33
+ },
34
+ "/s/logs": {
35
+ label: "STREAM",
36
+ value: "LIVE TAIL"
37
+ },
38
+ "/s/js": {
39
+ label: "RUNTIME",
40
+ value: "SDK · REPL"
41
+ },
42
+ "/s/crons": {
43
+ label: "SCHEDULE",
44
+ value: "CRON · JOBS"
45
+ },
46
+ "/s/storage": {
47
+ label: "OBJECTS",
48
+ value: "BUCKETS · RLS"
49
+ },
50
+ "/s/api": {
51
+ label: "SPEC",
52
+ value: "OPENAPI · REST"
53
+ },
54
+ "/s/webhooks": {
55
+ label: "EVENTS",
56
+ value: "DELIVERY · LOGS"
57
+ },
58
+ "/s/users": {
59
+ label: "IDENTITY",
60
+ value: "USERS · ROLES"
61
+ },
62
+ "/s/api-keys": {
63
+ label: "TOKENS",
64
+ value: "SCOPED · KEYS"
65
+ }
66
+ };
8
67
  /** Group order for the home page; unknown groups are appended in view order. */
9
- var GROUP_ORDER = [
68
+ var STUDIO_GROUP_ORDER = [
10
69
  "Database",
11
70
  "Compute",
12
71
  "Storage",
13
72
  "API",
14
73
  "Access Control"
15
74
  ];
75
+ var GROUP_ORDER$1 = STUDIO_GROUP_ORDER;
16
76
  var UNGROUPED_LABEL = "Tools";
17
77
  /**
18
78
  * Build the home page sections from the Studio views that are actually
@@ -34,7 +94,7 @@ function buildSections(views) {
34
94
  });
35
95
  byGroup.set(label, tools);
36
96
  }
37
- return [...GROUP_ORDER.filter((g) => byGroup.has(g)), ...[...byGroup.keys()].filter((g) => !GROUP_ORDER.includes(g))].map((label) => ({
97
+ return [...GROUP_ORDER$1.filter((g) => byGroup.has(g)), ...[...byGroup.keys()].filter((g) => !GROUP_ORDER$1.includes(g))].map((label) => ({
38
98
  label,
39
99
  tools: byGroup.get(label)
40
100
  }));
@@ -71,33 +131,76 @@ function StudioHomePage({ additionalActions, additionalChildrenStart, additional
71
131
  const breadcrumbs = useStudioBreadcrumbs$1();
72
132
  const navigate = useNavigate();
73
133
  const registry = useRebaseRegistry();
134
+ const apiConfig = useApiConfig();
135
+ const apiUrl = absoluteApiUrl(apiConfig?.apiUrl);
74
136
  const { t } = useTranslation();
75
- const apiUrl = absoluteApiUrl(useApiConfig()?.apiUrl);
76
137
  useEffect(() => {
77
138
  breadcrumbs.set({ breadcrumbs: [] });
78
139
  }, [breadcrumbs.set]);
79
140
  const { containerRef } = useRestoreScroll();
80
- const pluginActions = useSlot("home.actions", { context });
81
- const schemaEnabled = studioSchemaToolEnabled(registry);
82
- const filteredSections = useMemo(() => {
83
- const views = [];
84
- if (schemaEnabled) views.push({
85
- slug: "schema",
86
- name: t("studio_tool_schema"),
87
- group: "Database",
88
- icon: "LayoutList",
89
- description: t("studio_tool_schema_description")
90
- });
91
- views.push(...registry.studioConfig?.devViews ?? []);
92
- return buildSections(views).filter((s) => !hiddenGroups?.includes(s.label));
141
+ const [searchQuery, setSearchQuery] = useState("");
142
+ const [schemaStats, setSchemaStats] = useState(null);
143
+ const { requestJson } = useAdminFetch();
144
+ useEffect(() => {
145
+ if (typeof fetch !== "function") return;
146
+ let cancelled = false;
147
+ requestJson("/schema/tables").then((body) => {
148
+ if (cancelled || !body || typeof body !== "object") return;
149
+ const list = isRecord(body) && Array.isArray(body.tables) ? body.tables : Array.isArray(body) ? body : null;
150
+ if (!list) return;
151
+ let tables = 0;
152
+ let columns = 0;
153
+ let relations = 0;
154
+ let rlsProtected = 0;
155
+ const tableNames = [];
156
+ for (const item of list) {
157
+ if (!isRecord(item)) continue;
158
+ if (item.kind && item.kind !== "table") continue;
159
+ tables++;
160
+ if (typeof item.table === "string") tableNames.push(item.table);
161
+ else if (typeof item.name === "string") tableNames.push(item.name);
162
+ columns += countOf(item.columns);
163
+ relations += countOf(item.relations);
164
+ const rls = isRecord(item.rls) ? item.rls : void 0;
165
+ if (rls?.posture === "rules" || rls?.posture === "admin-only") rlsProtected++;
166
+ }
167
+ if (tables > 0) setSchemaStats({
168
+ tables,
169
+ columns,
170
+ relations,
171
+ rlsProtected,
172
+ tableNames
173
+ });
174
+ }).catch(() => {});
175
+ return () => {
176
+ cancelled = true;
177
+ };
93
178
  }, [
94
- registry.studioConfig?.devViews,
95
- schemaEnabled,
96
- hiddenGroups,
97
- t
179
+ requestJson,
180
+ apiConfig?.apiUrl,
181
+ apiConfig?.apiPath
98
182
  ]);
183
+ const pluginActions = useSlot("home.actions", { context });
184
+ const allSections = useMemo(() => buildSections([...registry.studioConfig?.devViews ?? []]).filter((s) => !hiddenGroups?.includes(s.label)), [registry.studioConfig?.devViews, hiddenGroups]);
185
+ const filteredSections = useMemo(() => {
186
+ const q = searchQuery.trim().toLowerCase();
187
+ if (!q) return allSections;
188
+ return allSections.map((section) => ({
189
+ ...section,
190
+ tools: section.tools.filter((tool) => tool.name.toLowerCase().includes(q) || tool.description.toLowerCase().includes(q) || section.label.toLowerCase().includes(q))
191
+ })).filter((section) => section.tools.length > 0);
192
+ }, [allSections, searchQuery]);
193
+ const totalToolsCount = useMemo(() => allSections.reduce((acc, s) => acc + s.tools.length, 0), [allSections]);
99
194
  const { isGroupCollapsed, toggleGroupCollapsed } = useStudioCollapsedGroups(useMemo(() => filteredSections.map((s) => s.label), [filteredSections]));
100
195
  const groupLabel = useNavigationGroupLabel();
196
+ const tableCount = schemaStats?.tables ?? 0;
197
+ const apiHostLabel = useMemo(() => {
198
+ try {
199
+ return new URL(apiUrl).host;
200
+ } catch {
201
+ return apiUrl || "same-origin";
202
+ }
203
+ }, [apiUrl]);
101
204
  return /* @__PURE__ */ jsx("div", {
102
205
  ref: containerRef,
103
206
  className: "py-2 overflow-auto h-full w-full bg-surface-sheet",
@@ -108,78 +211,262 @@ function StudioHomePage({ additionalActions, additionalChildrenStart, additional
108
211
  className: "mb-4 flex flex-col gap-2",
109
212
  children: /* @__PURE__ */ jsx(SchemaDriftBanner, {})
110
213
  }),
111
- (additionalActions || pluginActions) && /* @__PURE__ */ jsxs("div", {
112
- className: "w-full sticky py-4 transition-all duration-400 ease-in-out top-0 z-10 flex flex-row gap-4 justify-end",
113
- children: [additionalActions, pluginActions]
214
+ /* @__PURE__ */ jsxs("div", {
215
+ className: "w-full py-3 sticky top-0 z-10 bg-surface-sheet/90 backdrop-blur-md flex flex-row gap-3 items-center",
216
+ children: [
217
+ /* @__PURE__ */ jsx("div", {
218
+ className: "flex-1",
219
+ children: /* @__PURE__ */ jsx(SearchBar, {
220
+ onTextSearch: (v) => setSearchQuery(v ?? ""),
221
+ placeholder: "Search Studio tools…",
222
+ innerClassName: "w-full"
223
+ })
224
+ }),
225
+ additionalActions,
226
+ pluginActions
227
+ ]
114
228
  }),
115
229
  additionalChildrenStart,
230
+ !searchQuery && /* @__PURE__ */ jsxs("div", {
231
+ className: "mt-4 mb-8",
232
+ children: [/* @__PURE__ */ jsx(Typography, {
233
+ variant: "micro",
234
+ component: "h2",
235
+ color: "secondary",
236
+ className: "py-1 mb-3 block",
237
+ children: t("studio_home_overview")
238
+ }), /* @__PURE__ */ jsxs("div", {
239
+ className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3.5",
240
+ children: [
241
+ /* @__PURE__ */ jsxs(Card, {
242
+ className: "p-4 flex flex-col justify-between gap-2.5",
243
+ children: [
244
+ /* @__PURE__ */ jsxs("div", {
245
+ className: "flex items-center justify-between",
246
+ children: [/* @__PURE__ */ jsx(Typography, {
247
+ variant: "micro",
248
+ color: "secondary",
249
+ children: t("studio_home_backend_runtime")
250
+ }), /* @__PURE__ */ jsx(StatusDot, {
251
+ tone: "ok",
252
+ size: "small",
253
+ children: t("studio_home_online")
254
+ })]
255
+ }),
256
+ /* @__PURE__ */ jsx(Typography, {
257
+ variant: "h5",
258
+ className: "font-semibold tracking-tight",
259
+ children: "REST · WS · MCP"
260
+ }),
261
+ /* @__PURE__ */ jsx(Typography, {
262
+ variant: "mono",
263
+ color: "secondary",
264
+ className: "text-xs truncate",
265
+ children: apiHostLabel
266
+ })
267
+ ]
268
+ }),
269
+ /* @__PURE__ */ jsxs(Card, {
270
+ className: "p-4 flex flex-col justify-between gap-2.5",
271
+ children: [
272
+ /* @__PURE__ */ jsxs("div", {
273
+ className: "flex items-center justify-between",
274
+ children: [/* @__PURE__ */ jsx(Typography, {
275
+ variant: "micro",
276
+ color: "secondary",
277
+ children: t("studio_home_postgres_schema")
278
+ }), /* @__PURE__ */ jsx(Typography, {
279
+ variant: "mono",
280
+ color: "secondary",
281
+ className: "text-xs",
282
+ children: "public"
283
+ })]
284
+ }),
285
+ /* @__PURE__ */ jsxs(Typography, {
286
+ variant: "h4",
287
+ className: "font-mono tabular-nums font-semibold",
288
+ children: [tableCount > 0 ? tableCount : "—", /* @__PURE__ */ jsx("span", {
289
+ className: "text-sm font-sans font-normal text-text-secondary dark:text-text-secondary-dark ml-1.5",
290
+ children: t("studio_home_tables_unit", { count: tableCount })
291
+ })]
292
+ }),
293
+ /* @__PURE__ */ jsxs(Typography, {
294
+ variant: "mono",
295
+ color: "secondary",
296
+ className: "text-xs flex items-center gap-3",
297
+ children: [/* @__PURE__ */ jsxs("span", { children: [
298
+ t("studio_home_cols"),
299
+ " ",
300
+ /* @__PURE__ */ jsx("strong", {
301
+ className: "text-text-primary dark:text-text-primary-dark font-medium",
302
+ children: schemaStats ? schemaStats.columns : "—"
303
+ })
304
+ ] }), /* @__PURE__ */ jsxs("span", { children: [
305
+ t("studio_home_rels"),
306
+ " ",
307
+ /* @__PURE__ */ jsx("strong", {
308
+ className: "text-text-primary dark:text-text-primary-dark font-medium",
309
+ children: schemaStats ? schemaStats.relations : "—"
310
+ })
311
+ ] })]
312
+ })
313
+ ]
314
+ }),
315
+ /* @__PURE__ */ jsxs(Card, {
316
+ className: "p-4 flex flex-col justify-between gap-2.5",
317
+ children: [
318
+ /* @__PURE__ */ jsxs("div", {
319
+ className: "flex items-center justify-between",
320
+ children: [/* @__PURE__ */ jsx(Typography, {
321
+ variant: "micro",
322
+ color: "secondary",
323
+ children: t("studio_home_security_rls")
324
+ }), /* @__PURE__ */ jsx(StatusDot, {
325
+ tone: schemaStats && schemaStats.rlsProtected < schemaStats.tables ? "busy" : "ok",
326
+ size: "small",
327
+ children: schemaStats ? t("studio_home_enforced", {
328
+ protected: schemaStats.rlsProtected,
329
+ total: schemaStats.tables
330
+ }) : t("studio_api_keys_status_active")
331
+ })]
332
+ }),
333
+ /* @__PURE__ */ jsxs(Typography, {
334
+ variant: "h4",
335
+ className: "font-mono tabular-nums font-semibold",
336
+ children: [schemaStats && schemaStats.tables > 0 ? `${Math.round(schemaStats.rlsProtected / schemaStats.tables * 100)}%` : "RLS", /* @__PURE__ */ jsx("span", {
337
+ className: "text-sm font-sans font-normal text-text-secondary dark:text-text-secondary-dark ml-1.5",
338
+ children: t("studio_home_protected")
339
+ })]
340
+ }),
341
+ /* @__PURE__ */ jsx(Typography, {
342
+ variant: "mono",
343
+ color: "secondary",
344
+ className: "text-xs",
345
+ children: t("studio_home_default_deny")
346
+ })
347
+ ]
348
+ }),
349
+ /* @__PURE__ */ jsxs(Card, {
350
+ className: "p-4 flex flex-col justify-between gap-2.5",
351
+ children: [
352
+ /* @__PURE__ */ jsxs("div", {
353
+ className: "flex items-center justify-between",
354
+ children: [/* @__PURE__ */ jsx(Typography, {
355
+ variant: "micro",
356
+ color: "secondary",
357
+ children: t("studio_home_workbench")
358
+ }), /* @__PURE__ */ jsx(Typography, {
359
+ variant: "mono",
360
+ color: "secondary",
361
+ className: "text-xs",
362
+ children: t("studio_home_groups", { count: filteredSections.length })
363
+ })]
364
+ }),
365
+ /* @__PURE__ */ jsxs(Typography, {
366
+ variant: "h4",
367
+ className: "font-mono tabular-nums font-semibold",
368
+ children: [totalToolsCount, /* @__PURE__ */ jsx("span", {
369
+ className: "text-sm font-sans font-normal text-text-secondary dark:text-text-secondary-dark ml-1.5",
370
+ children: t("studio_home_tools_unit")
371
+ })]
372
+ }),
373
+ /* @__PURE__ */ jsx(Typography, {
374
+ variant: "mono",
375
+ color: "secondary",
376
+ className: "text-xs truncate",
377
+ children: schemaStats && schemaStats.tableNames.length > 0 ? schemaStats.tableNames.slice(0, 4).join(" · ") : "SQL · RLS · STORAGE · API"
378
+ })
379
+ ]
380
+ })
381
+ ]
382
+ })]
383
+ }),
116
384
  filteredSections.map((section) => {
117
385
  const sectionCollapsed = isGroupCollapsed(section.label);
118
386
  return /* @__PURE__ */ jsx("div", {
119
- className: "my-10",
387
+ className: "my-8",
120
388
  children: /* @__PURE__ */ jsx(ExpandablePanel, {
121
389
  invisible: true,
122
390
  expanded: !sectionCollapsed,
123
391
  onExpandedChange: (open) => {
124
392
  if (open !== !sectionCollapsed) toggleGroupCollapsed(section.label);
125
393
  },
126
- className: "mt-6",
127
- titleClassName: cls("min-h-0 p-0 border-none", "rounded flex items-center justify-between w-full", "hover:bg-transparent", "cursor-pointer select-none", sectionCollapsed && "bg-surface-field"),
128
- innerClassName: "mt-4 pt-0",
394
+ className: "mt-4",
395
+ titleClassName: cls("min-h-0 p-0 px-3 -mx-3 w-auto border-none", "rounded flex items-center justify-between w-full", "hover:bg-transparent", "cursor-pointer select-none", sectionCollapsed && "bg-surface-field"),
396
+ innerClassName: "mt-3 pt-0",
129
397
  title: /* @__PURE__ */ jsx(Typography, {
130
- variant: "caption",
398
+ variant: "micro",
131
399
  component: "h2",
132
400
  color: "secondary",
133
- className: cls("px-4 py-1 rounded", "font-medium text-2xs uppercase tracking-[0.08em] text-surface-400 dark:text-surface-400"),
401
+ className: "py-1 rounded",
134
402
  children: groupLabel(section.label)
135
403
  }),
136
404
  children: /* @__PURE__ */ jsx("div", {
137
- className: "mt-4 pt-0",
405
+ className: "mt-3 pt-0",
138
406
  children: /* @__PURE__ */ jsx("div", {
139
- className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",
140
- children: section.tools.map((tool) => /* @__PURE__ */ jsx(Card, {
141
- onClick: () => {
142
- navigate(tool.path);
143
- context.analyticsController?.onAnalyticsEvent?.("home_navigate_to_view", { path: tool.path });
144
- },
145
- className: cls("group h-full p-4 cursor-pointer transition-colors duration-150 ease-in-out", "hover:bg-surface-card-hover"),
146
- children: /* @__PURE__ */ jsxs("div", {
147
- className: "flex flex-col h-full",
148
- children: [
149
- /* @__PURE__ */ jsx("div", {
150
- className: "flex items-center w-full justify-between mb-1",
151
- children: /* @__PURE__ */ jsxs("div", {
152
- className: "flex items-center gap-3",
153
- children: [/* @__PURE__ */ jsx("div", {
154
- 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",
155
- children: /* @__PURE__ */ jsx(IconForView, {
156
- collectionOrView: {
157
- slug: tool.path,
158
- name: tool.name,
159
- icon: tool.icon
160
- },
161
- size: "small"
162
- })
163
- }), /* @__PURE__ */ jsx(Typography, {
164
- variant: "subtitle1",
165
- component: "h2",
166
- children: tool.name
167
- })]
168
- })
169
- }),
170
- /* @__PURE__ */ jsx("div", {
171
- className: "pl-8",
172
- children: tool.description && /* @__PURE__ */ jsx(Typography, {
173
- variant: "caption",
174
- color: "secondary",
175
- component: "div",
176
- children: tool.description
407
+ className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3.5",
408
+ children: section.tools.map((tool) => {
409
+ const staticReadout = TOOL_READOUTS[tool.path];
410
+ const dynamicValue = tool.path === "/s/tables" && schemaStats ? `${schemaStats.tables} TABLES · ${schemaStats.columns} COLS` : tool.path === "/s/rls" && schemaStats ? `${schemaStats.rlsProtected}/${schemaStats.tables} PROTECTED` : tool.path === "/s/schema" && schemaStats ? `${schemaStats.tables} NODES · ${schemaStats.relations} EDGES` : staticReadout?.value;
411
+ return /* @__PURE__ */ jsx(Card, {
412
+ onClick: () => {
413
+ navigate(tool.path);
414
+ context.analyticsController?.onAnalyticsEvent?.("home_navigate_to_view", { path: tool.path });
415
+ },
416
+ className: cls("group h-full p-4 cursor-pointer transition-colors duration-150 ease-in-out", "hover:bg-surface-card-hover"),
417
+ children: /* @__PURE__ */ jsxs("div", {
418
+ className: "flex items-start gap-3.5 h-full",
419
+ children: [/* @__PURE__ */ jsx("div", {
420
+ className: "shrink-0 flex items-center justify-center w-9 h-9 rounded-lg bg-surface-raised text-text-secondary dark:text-text-secondary-dark transition-colors duration-150 group-hover:bg-surface-raised-hover group-hover:text-text-primary dark:group-hover:text-text-primary-dark",
421
+ children: /* @__PURE__ */ jsx(IconForView, {
422
+ collectionOrView: {
423
+ slug: tool.path,
424
+ name: tool.name,
425
+ icon: tool.icon
426
+ },
427
+ size: "small"
177
428
  })
178
- }),
179
- /* @__PURE__ */ jsx("div", { className: "grow" })
180
- ]
181
- })
182
- }, tool.path))
429
+ }), /* @__PURE__ */ jsxs("div", {
430
+ className: "flex flex-col min-w-0 flex-1 h-full",
431
+ children: [
432
+ /* @__PURE__ */ jsxs("div", {
433
+ className: "flex items-center justify-between gap-2",
434
+ children: [/* @__PURE__ */ jsx(Typography, {
435
+ variant: "subtitle1",
436
+ component: "h2",
437
+ className: "truncate",
438
+ children: tool.name
439
+ }), /* @__PURE__ */ jsx(ArrowRightIcon, {
440
+ size: 14,
441
+ className: "shrink-0 text-text-disabled dark:text-text-disabled-dark opacity-0 -translate-x-1 group-hover:opacity-100 group-hover:translate-x-0 group-hover:text-text-secondary dark:group-hover:text-text-secondary-dark transition-all duration-150"
442
+ })]
443
+ }),
444
+ tool.description && /* @__PURE__ */ jsx(Typography, {
445
+ variant: "caption",
446
+ color: "secondary",
447
+ component: "div",
448
+ className: "mt-0.5 line-clamp-2",
449
+ children: tool.description
450
+ }),
451
+ /* @__PURE__ */ jsx("div", { className: "grow" }),
452
+ dynamicValue && /* @__PURE__ */ jsxs("div", {
453
+ className: "mt-3 pt-2.5 border-t border-hairline flex items-center justify-between gap-2",
454
+ children: [/* @__PURE__ */ jsx(Typography, {
455
+ variant: "micro",
456
+ color: "disabled",
457
+ children: staticReadout?.label ?? "MODULE"
458
+ }), /* @__PURE__ */ jsx(Typography, {
459
+ variant: "mono",
460
+ color: "secondary",
461
+ className: "text-xs truncate",
462
+ children: dynamicValue
463
+ })]
464
+ })
465
+ ]
466
+ })]
467
+ })
468
+ }, tool.path);
469
+ })
183
470
  })
184
471
  })
185
472
  })
@@ -191,11 +478,11 @@ function StudioHomePage({ additionalActions, additionalChildrenStart, additional
191
478
  /* @__PURE__ */ jsx("div", {
192
479
  className: "flex items-center mb-1",
193
480
  children: /* @__PURE__ */ jsx(Typography, {
194
- variant: "caption",
481
+ variant: "micro",
195
482
  component: "h2",
196
483
  color: "secondary",
197
- className: cls("px-4 py-1 rounded", "font-medium text-2xs uppercase tracking-[0.08em] text-surface-400 dark:text-surface-400"),
198
- children: "Quick Start"
484
+ className: "py-1 rounded",
485
+ children: t("studio_home_quick_start")
199
486
  })
200
487
  }),
201
488
  /* @__PURE__ */ jsxs(Typography, {
@@ -203,14 +490,20 @@ function StudioHomePage({ additionalActions, additionalChildrenStart, additional
203
490
  color: "secondary",
204
491
  className: "mb-4 max-w-2xl",
205
492
  children: [
206
- "Generate a fully-typed SDK from your tables with",
493
+ t("studio_home_quick_start_dev"),
207
494
  " ",
208
495
  /* @__PURE__ */ jsx("code", {
209
496
  className: "text-emerald-400 font-mono text-xs bg-emerald-400/10 px-1.5 py-0.5 rounded",
210
- children: "npx rebase generate-sdk"
497
+ children: "rebase dev"
211
498
  }),
499
+ ". ",
500
+ t("studio_home_quick_start_outside_dev"),
212
501
  " ",
213
- "and start querying your data with full TypeScript autocompletion."
502
+ /* @__PURE__ */ jsx("code", {
503
+ className: "text-emerald-400 font-mono text-xs bg-emerald-400/10 px-1.5 py-0.5 rounded",
504
+ children: "rebase generate-sdk"
505
+ }),
506
+ "."
214
507
  ]
215
508
  }),
216
509
  /* @__PURE__ */ jsxs("div", {
@@ -244,10 +537,10 @@ function StudioHomePage({ additionalActions, additionalChildrenStart, additional
244
537
  sections?.map((s) => /* @__PURE__ */ jsxs("div", {
245
538
  className: "my-10",
246
539
  children: [/* @__PURE__ */ jsx(Typography, {
247
- variant: "caption",
540
+ variant: "micro",
248
541
  component: "h2",
249
542
  color: "secondary",
250
- className: cls("px-4 py-1 rounded", "font-medium text-2xs uppercase tracking-[0.08em] text-surface-400 dark:text-surface-400"),
543
+ className: "py-1 rounded",
251
544
  children: s.title
252
545
  }), /* @__PURE__ */ jsx("div", {
253
546
  className: "mt-4",
@@ -264,6 +557,11 @@ function StudioHomePage({ additionalActions, additionalChildrenStart, additional
264
557
  * (a same-origin panel is configured with a relative one) and without a
265
558
  * trailing slash. It is what `baseUrl` takes — the API's path is the client's.
266
559
  */
560
+ /** How many entries a descriptor's list holds: an array's length, or an object's keys. */
561
+ function countOf(value) {
562
+ if (Array.isArray(value)) return value.length;
563
+ return isRecord(value) ? Object.keys(value).length : 0;
564
+ }
267
565
  function absoluteApiUrl(apiUrl) {
268
566
  const page = typeof window !== "undefined" ? window.location.href : void 0;
269
567
  try {
@@ -351,7 +649,7 @@ function SyntaxHighlightedSnippet({ baseUrl }) {
351
649
  }),
352
650
  /* @__PURE__ */ jsx("span", {
353
651
  className: str,
354
- children: "'./database.types'"
652
+ children: "'./generated/sdk/database.types'"
355
653
  }),
356
654
  /* @__PURE__ */ jsx("span", {
357
655
  className: op,
@@ -440,7 +738,7 @@ function SyntaxHighlightedSnippet({ baseUrl }) {
440
738
  "\n\n",
441
739
  /* @__PURE__ */ jsx("span", {
442
740
  className: cm,
443
- children: "// Fully typed — autocompletion for tables and columns"
741
+ children: "// Every table is a typed property: rebase.data.<table>"
444
742
  }),
445
743
  "\n",
446
744
  /* @__PURE__ */ jsx("span", {
@@ -526,7 +824,7 @@ function SyntaxHighlightedSnippet({ baseUrl }) {
526
824
  }),
527
825
  /* @__PURE__ */ jsx("span", {
528
826
  className: tx,
529
- children: "posts"
827
+ children: "admins"
530
828
  }),
531
829
  /* @__PURE__ */ jsx("span", {
532
830
  className: tx,
@@ -556,9 +854,22 @@ function SyntaxHighlightedSnippet({ baseUrl }) {
556
854
  className: op,
557
855
  children: "."
558
856
  }),
857
+ /* @__PURE__ */ jsx("span", {
858
+ className: tx,
859
+ children: "users"
860
+ }),
861
+ "\n",
862
+ /* @__PURE__ */ jsx("span", {
863
+ className: tx,
864
+ children: " "
865
+ }),
866
+ /* @__PURE__ */ jsx("span", {
867
+ className: op,
868
+ children: "."
869
+ }),
559
870
  /* @__PURE__ */ jsx("span", {
560
871
  className: fn,
561
- children: "collection"
872
+ children: "where"
562
873
  }),
563
874
  /* @__PURE__ */ jsx("span", {
564
875
  className: op,
@@ -566,12 +877,33 @@ function SyntaxHighlightedSnippet({ baseUrl }) {
566
877
  }),
567
878
  /* @__PURE__ */ jsx("span", {
568
879
  className: str,
569
- children: "'posts'"
880
+ children: "'roles'"
881
+ }),
882
+ /* @__PURE__ */ jsx("span", {
883
+ className: op,
884
+ children: ", "
885
+ }),
886
+ /* @__PURE__ */ jsx("span", {
887
+ className: str,
888
+ children: "'array-contains'"
889
+ }),
890
+ /* @__PURE__ */ jsx("span", {
891
+ className: op,
892
+ children: ", "
893
+ }),
894
+ /* @__PURE__ */ jsx("span", {
895
+ className: str,
896
+ children: "'admin'"
570
897
  }),
571
898
  /* @__PURE__ */ jsx("span", {
572
899
  className: op,
573
900
  children: ")"
574
901
  }),
902
+ "\n",
903
+ /* @__PURE__ */ jsx("span", {
904
+ className: tx,
905
+ children: " "
906
+ }),
575
907
  /* @__PURE__ */ jsx("span", {
576
908
  className: op,
577
909
  children: "."
@@ -589,27 +921,23 @@ function SyntaxHighlightedSnippet({ baseUrl }) {
589
921
  }
590
922
  //#endregion
591
923
  //#region src/components/RebaseStudio.tsx
592
- var SQLEditor = lazyChunk(() => import("./SQLEditor-Dj5INEUZ.js").then((m) => ({ default: m.SQLEditor })));
593
- var JSEditor = lazyChunk(() => import("./JSEditor-Br22PfLh.js").then((m) => ({ default: m.JSEditor })));
594
- var RLSEditor = lazyChunk(() => import("./RLSEditor-RE4YpN_z.js").then((m) => ({ default: m.RLSEditor })));
595
- var StorageView = lazyChunk(() => import("./StorageView-DHm22S7y.js").then((m) => ({ default: m.StorageView })));
596
- var CronJobsView = lazyChunk(() => import("./CronJobsView-CwF_m6ZB.js").then((m) => ({ default: m.CronJobsView })));
597
- var SchemaVisualizer = lazyChunk(() => import("./SchemaVisualizer-D2_cck4I.js").then((m) => ({ default: m.SchemaVisualizer })));
598
- var BranchesView = lazyChunk(() => import("./BranchesView-BKGhk-PC.js").then((m) => ({ default: m.BranchesView })));
924
+ var TableEditorView = lazyChunk(() => import("./TableEditorView-BKhSBG-K.js").then((m) => ({ default: m.TableEditorView })));
925
+ var SQLEditor = lazyChunk(() => import("./SQLEditor-DRo5kW1h.js").then((m) => ({ default: m.SQLEditor })));
926
+ var JSEditor = lazyChunk(() => import("./JSEditor-Bi2Aol-Y.js").then((m) => ({ default: m.JSEditor })));
927
+ var RLSEditor = lazyChunk(() => import("./RLSEditor-CTG3jLE7.js").then((m) => ({ default: m.RLSEditor })));
928
+ var StorageView = lazyChunk(() => import("./StorageView-D0D8z4lI.js").then((m) => ({ default: m.StorageView })));
929
+ var CronJobsView = lazyChunk(() => import("./CronJobsView-DUuyzkJK.js").then((m) => ({ default: m.CronJobsView })));
930
+ var SchemaVisualizer = lazyChunk(() => import("./SchemaVisualizer-Dy4kWKT5.js").then((m) => ({ default: m.SchemaVisualizer })));
931
+ var BranchesView = lazyChunk(() => import("./BranchesView-Bh5lq9T_.js").then((m) => ({ default: m.BranchesView })));
599
932
  var BackupsView = lazyChunk(() => import("./BackupsView-DJlYhWBy.js").then((m) => ({ default: m.BackupsView })));
600
- var ApiExplorer = lazyChunk(() => import("./ApiExplorer-BhQFd_iR.js").then((m) => ({ default: m.ApiExplorer })));
601
- var LogsExplorer = lazyChunk(() => import("./LogsExplorer-DOLRFQaW.js").then((m) => ({ default: m.LogsExplorer })));
602
- var ApiKeysView = lazyChunk(() => import("./ApiKeysView-CLBXUCgu.js").then((m) => ({ default: m.ApiKeysView })));
933
+ var ApiExplorer = lazyChunk(() => import("./ApiExplorer-C61w8gCc.js").then((m) => ({ default: m.ApiExplorer })));
934
+ var WebhooksView = lazyChunk(() => import("./WebhooksView-CFPY-N9h.js").then((m) => ({ default: m.WebhooksView })));
935
+ var LogsExplorer = lazyChunk(() => import("./LogsExplorer-BA8RfTwd.js").then((m) => ({ default: m.LogsExplorer })));
936
+ var UsersAndRolesView = lazyChunk(() => import("./UsersAndRolesView-CKw4SJPj.js").then((m) => ({ default: m.UsersAndRolesView })));
937
+ var ApiKeysView = lazyChunk(() => import("./ApiKeysView-BdqASL_2.js").then((m) => ({ default: m.ApiKeysView })));
603
938
  /**
604
939
  * Declarative component to configure the Studio in Rebase.
605
940
  * Renders nothing — purely registers config into the RebaseRegistry.
606
- *
607
- * The "schema" tool (collection editor view) is a Studio tool, but it is not
608
- * registered here: it ships from the panel package because it needs the project's
609
- * collection source to write back to. When `<RebaseCMS collectionEditor={...}>`
610
- * is used, the schema view is automatically injected into Studio — no manual
611
- * wiring needed. Where it is mounted from is an implementation detail; it is a
612
- * schema-editing tool and belongs beside SQL and RLS.
613
941
  */
614
942
  var DEFAULT_HOME_PAGE = /* @__PURE__ */ jsx(StudioHomePage, {});
615
943
  /**
@@ -629,6 +957,7 @@ function RebaseStudioRegistration({ tools, homePage, devViews: extraViews }) {
629
957
  const devViews = useMemo(() => {
630
958
  const views = [];
631
959
  const activeTools = tools ?? [
960
+ "tables",
632
961
  "sql",
633
962
  "js",
634
963
  "rls",
@@ -638,13 +967,23 @@ function RebaseStudioRegistration({ tools, homePage, devViews: extraViews }) {
638
967
  "branches",
639
968
  "backups",
640
969
  "api",
970
+ "webhooks",
641
971
  "logs",
972
+ "users",
642
973
  "api-keys"
643
974
  ];
644
975
  const suspense = (el) => /* @__PURE__ */ jsx(Suspense, {
645
976
  fallback: /* @__PURE__ */ jsx(CircularProgressCenter, {}),
646
977
  children: el
647
978
  });
979
+ if (activeTools.includes("tables")) views.push({
980
+ slug: "tables",
981
+ name: t("studio_tool_tables"),
982
+ group: "Database",
983
+ icon: "Table",
984
+ description: t("studio_tool_tables_description"),
985
+ view: suspense(/* @__PURE__ */ jsx(TableEditorView, {}))
986
+ });
648
987
  if (activeTools.includes("sql")) views.push({
649
988
  slug: "sql",
650
989
  name: t("studio_tool_sql"),
@@ -717,14 +1056,30 @@ function RebaseStudioRegistration({ tools, homePage, devViews: extraViews }) {
717
1056
  description: t("studio_tool_api_description"),
718
1057
  view: suspense(/* @__PURE__ */ jsx(ApiExplorer, {}))
719
1058
  });
1059
+ if (activeTools.includes("webhooks")) views.push({
1060
+ slug: "webhooks",
1061
+ name: t("studio_tool_webhooks"),
1062
+ group: "API",
1063
+ icon: "Webhook",
1064
+ description: t("studio_tool_webhooks_description"),
1065
+ view: suspense(/* @__PURE__ */ jsx(WebhooksView, {}))
1066
+ });
720
1067
  if (activeTools.includes("logs")) views.push({
721
1068
  slug: "logs",
722
1069
  name: t("studio_tool_logs"),
723
- group: "Database",
1070
+ group: "API",
724
1071
  icon: "Activity",
725
1072
  description: t("studio_tool_logs_description"),
726
1073
  view: suspense(/* @__PURE__ */ jsx(LogsExplorer, {}))
727
1074
  });
1075
+ if (activeTools.includes("users")) views.push({
1076
+ slug: "users",
1077
+ name: t("studio_tool_users"),
1078
+ group: "Access Control",
1079
+ icon: "Users",
1080
+ description: t("studio_tool_users_description"),
1081
+ view: suspense(/* @__PURE__ */ jsx(UsersAndRolesView, {}))
1082
+ });
728
1083
  if (activeTools.includes("api-keys")) views.push({
729
1084
  slug: "api-keys",
730
1085
  name: t("studio_tool_api_keys"),
@@ -768,6 +1123,281 @@ function RebaseStudioRegistration({ tools, homePage, devViews: extraViews }) {
768
1123
  return null;
769
1124
  }
770
1125
  //#endregion
771
- export { RebaseStudio, StudioBridgeContext, StudioBridgeProvider, StudioHomePage, useStudioBreadcrumbs, useStudioCollectionRegistry, useStudioNavigationState, useStudioSidePanelController, useStudioUrlController };
1126
+ //#region src/components/RebaseStudioApp.tsx
1127
+ var GROUP_ORDER = STUDIO_GROUP_ORDER;
1128
+ function StudioSignInScreen({ name, auth }) {
1129
+ const { t } = useTranslation();
1130
+ const [mode, setMode] = useState(auth.needsSetup ? "register" : "signin");
1131
+ const [email, setEmail] = useState("");
1132
+ const [password, setPassword] = useState("");
1133
+ const [displayName, setDisplayName] = useState("");
1134
+ const [submitting, setSubmitting] = useState(false);
1135
+ const [localError, setLocalError] = useState(null);
1136
+ const isRegister = auth.needsSetup || mode === "register";
1137
+ const handleSubmit = async (e) => {
1138
+ e.preventDefault();
1139
+ setLocalError(null);
1140
+ setSubmitting(true);
1141
+ try {
1142
+ if (isRegister) await auth.register(email.trim(), password, displayName.trim() || void 0);
1143
+ else await auth.emailPasswordLogin(email.trim(), password);
1144
+ } catch (err) {
1145
+ setLocalError(err instanceof Error ? err.message : t("studio_app_auth_failed"));
1146
+ } finally {
1147
+ setSubmitting(false);
1148
+ }
1149
+ };
1150
+ const errorMessage = localError ?? auth.authProviderError?.message ?? null;
1151
+ return /* @__PURE__ */ jsx("div", {
1152
+ className: "min-h-screen w-full flex items-center justify-center bg-surface-frame p-6",
1153
+ children: /* @__PURE__ */ jsxs(Card, {
1154
+ className: "w-full max-w-md p-6 flex flex-col gap-5",
1155
+ children: [
1156
+ /* @__PURE__ */ jsxs("div", {
1157
+ className: "flex flex-col gap-1",
1158
+ children: [/* @__PURE__ */ jsx(Typography, {
1159
+ variant: "h5",
1160
+ className: "font-semibold",
1161
+ children: name
1162
+ }), /* @__PURE__ */ jsx(Typography, {
1163
+ variant: "body2",
1164
+ color: "secondary",
1165
+ children: auth.needsSetup ? t("studio_app_setup_subtitle") : isRegister ? t("studio_app_register_subtitle") : t("studio_app_signin_subtitle")
1166
+ })]
1167
+ }),
1168
+ errorMessage && /* @__PURE__ */ jsx(Alert, {
1169
+ color: "error",
1170
+ children: errorMessage
1171
+ }),
1172
+ /* @__PURE__ */ jsxs("form", {
1173
+ onSubmit: (e) => void handleSubmit(e),
1174
+ className: "flex flex-col gap-3",
1175
+ children: [
1176
+ isRegister && /* @__PURE__ */ jsx(TextField, {
1177
+ label: t("studio_app_display_name_optional"),
1178
+ value: displayName,
1179
+ onChange: (e) => setDisplayName(e.target.value),
1180
+ placeholder: "Admin"
1181
+ }),
1182
+ /* @__PURE__ */ jsx(TextField, {
1183
+ label: t("email"),
1184
+ type: "email",
1185
+ value: email,
1186
+ onChange: (e) => setEmail(e.target.value),
1187
+ placeholder: "admin@example.com",
1188
+ required: true
1189
+ }),
1190
+ /* @__PURE__ */ jsx(TextField, {
1191
+ label: t("auth_password"),
1192
+ type: "password",
1193
+ value: password,
1194
+ onChange: (e) => setPassword(e.target.value),
1195
+ required: true
1196
+ }),
1197
+ /* @__PURE__ */ jsx(Button, {
1198
+ type: "submit",
1199
+ variant: "filled",
1200
+ disabled: submitting || !email.trim() || !password,
1201
+ className: "mt-1",
1202
+ children: submitting ? t("studio_app_please_wait") : auth.needsSetup ? t("studio_app_create_admin") : isRegister ? t("studio_app_create_account") : t("auth_sign_in")
1203
+ })
1204
+ ]
1205
+ }),
1206
+ !auth.needsSetup && auth.registrationEnabled && /* @__PURE__ */ jsx("div", {
1207
+ className: "flex justify-center",
1208
+ children: /* @__PURE__ */ jsx(Button, {
1209
+ size: "small",
1210
+ variant: "text",
1211
+ onClick: () => setMode((m) => m === "signin" ? "register" : "signin"),
1212
+ children: isRegister ? t("studio_app_have_account") : t("studio_app_need_account")
1213
+ })
1214
+ })
1215
+ ]
1216
+ })
1217
+ });
1218
+ }
1219
+ function StudioStandaloneShell({ name, auth }) {
1220
+ const registry = useRebaseRegistry();
1221
+ const navigate = useNavigate();
1222
+ const location = useLocation();
1223
+ const modeController = useModeController();
1224
+ const labelGroup = useNavigationGroupLabel();
1225
+ const { t } = useTranslation();
1226
+ const views = useMemo(() => (registry.studioConfig?.devViews ?? []).filter((v) => !v.hideFromNavigation), [registry.studioConfig?.devViews]);
1227
+ const groupedViews = useMemo(() => {
1228
+ const map = /* @__PURE__ */ new Map();
1229
+ for (const v of views) {
1230
+ const g = v.group || "Tools";
1231
+ const arr = map.get(g) ?? [];
1232
+ arr.push(v);
1233
+ map.set(g, arr);
1234
+ }
1235
+ const ordered = [];
1236
+ for (const g of GROUP_ORDER) {
1237
+ const items = map.get(g);
1238
+ if (items && items.length > 0) {
1239
+ ordered.push({
1240
+ group: g,
1241
+ items
1242
+ });
1243
+ map.delete(g);
1244
+ }
1245
+ }
1246
+ for (const [g, items] of map.entries()) ordered.push({
1247
+ group: g,
1248
+ items
1249
+ });
1250
+ return ordered;
1251
+ }, [views]);
1252
+ if (auth.initialLoading) return /* @__PURE__ */ jsx(CircularProgressCenter, {});
1253
+ if (!auth.user && !auth.loginSkipped) return /* @__PURE__ */ jsx(StudioSignInScreen, {
1254
+ name,
1255
+ auth
1256
+ });
1257
+ const currentSlug = location.pathname.replace(/^\/+/, "").split("/")[0] || "";
1258
+ const isDark = modeController.mode === "dark";
1259
+ return /* @__PURE__ */ jsxs("div", {
1260
+ className: "flex h-screen w-screen overflow-hidden bg-surface-frame text-text-primary dark:text-text-primary-dark",
1261
+ children: [/* @__PURE__ */ jsxs("aside", {
1262
+ className: cls("w-60 shrink-0 flex flex-col border-r bg-surface-frame", defaultBorderMixin),
1263
+ children: [
1264
+ /* @__PURE__ */ jsxs("div", {
1265
+ className: cls("h-12 px-4 border-b flex items-center justify-between gap-2 shrink-0", defaultBorderMixin),
1266
+ children: [/* @__PURE__ */ jsx("button", {
1267
+ type: "button",
1268
+ onClick: () => navigate("/"),
1269
+ className: "flex items-center gap-2 min-w-0 text-left",
1270
+ children: /* @__PURE__ */ jsx(Typography, {
1271
+ variant: "subtitle1",
1272
+ className: "font-semibold truncate",
1273
+ children: name
1274
+ })
1275
+ }), /* @__PURE__ */ jsx(Tooltip, {
1276
+ title: isDark ? t("studio_app_light_mode") : t("studio_app_dark_mode"),
1277
+ children: /* @__PURE__ */ jsx(IconButton, {
1278
+ size: "small",
1279
+ "aria-label": t("toggle_theme"),
1280
+ onClick: () => modeController.setMode(isDark ? "light" : "dark"),
1281
+ children: isDark ? /* @__PURE__ */ jsx(SunIcon, { size: iconSize.small }) : /* @__PURE__ */ jsx(MoonIcon, { size: iconSize.small })
1282
+ })
1283
+ })]
1284
+ }),
1285
+ /* @__PURE__ */ jsxs("nav", {
1286
+ className: "flex-1 overflow-y-auto p-2 flex flex-col gap-3",
1287
+ children: [/* @__PURE__ */ jsxs("button", {
1288
+ type: "button",
1289
+ onClick: () => navigate("/"),
1290
+ className: cls("w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-[13px] transition-colors", currentSlug === "" ? "bg-surface-active text-text-primary dark:text-text-primary-dark font-medium" : "text-text-secondary dark:text-text-secondary-dark hover:bg-surface-hover hover:text-text-primary dark:hover:text-text-primary-dark"),
1291
+ children: [/* @__PURE__ */ jsx(HomeIcon, { size: iconSize.small }), /* @__PURE__ */ jsx("span", { children: t("home") })]
1292
+ }), groupedViews.map(({ group, items }) => /* @__PURE__ */ jsxs("div", {
1293
+ className: "flex flex-col gap-0.5",
1294
+ children: [/* @__PURE__ */ jsx(Typography, {
1295
+ variant: "caption",
1296
+ color: "secondary",
1297
+ className: "px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wider",
1298
+ children: labelGroup(group)
1299
+ }), items.map((view) => {
1300
+ return /* @__PURE__ */ jsxs("button", {
1301
+ type: "button",
1302
+ onClick: () => navigate(`/${view.slug}`),
1303
+ className: cls("w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-[13px] transition-colors text-left", currentSlug === view.slug ? "bg-surface-active text-text-primary dark:text-text-primary-dark font-medium" : "text-text-secondary dark:text-text-secondary-dark hover:bg-surface-hover hover:text-text-primary dark:hover:text-text-primary-dark"),
1304
+ children: [/* @__PURE__ */ jsx(IconForView, {
1305
+ collectionOrView: view,
1306
+ className: "w-4 h-4 shrink-0"
1307
+ }), /* @__PURE__ */ jsx("span", {
1308
+ className: "truncate",
1309
+ children: view.name
1310
+ })]
1311
+ }, view.slug);
1312
+ })]
1313
+ }, group))]
1314
+ }),
1315
+ auth.user && /* @__PURE__ */ jsxs("div", {
1316
+ className: cls("p-3 border-t flex items-center justify-between gap-2 shrink-0", defaultBorderMixin),
1317
+ children: [/* @__PURE__ */ jsxs("div", {
1318
+ className: "min-w-0",
1319
+ children: [/* @__PURE__ */ jsx(Typography, {
1320
+ variant: "caption",
1321
+ className: "block truncate font-medium",
1322
+ children: auth.user.displayName || auth.user.email || auth.user.uid
1323
+ }), auth.user.email && /* @__PURE__ */ jsx(Typography, {
1324
+ variant: "caption",
1325
+ color: "secondary",
1326
+ className: "block truncate text-[11px]",
1327
+ children: auth.user.email
1328
+ })]
1329
+ }), /* @__PURE__ */ jsx(Tooltip, {
1330
+ title: t("studio_app_sign_out"),
1331
+ children: /* @__PURE__ */ jsx(IconButton, {
1332
+ size: "small",
1333
+ "aria-label": t("studio_app_sign_out"),
1334
+ onClick: () => void auth.signOut(),
1335
+ children: /* @__PURE__ */ jsx(LogOutIcon, { size: iconSize.small })
1336
+ })
1337
+ })]
1338
+ })
1339
+ ]
1340
+ }), /* @__PURE__ */ jsx("div", {
1341
+ className: "flex-1 min-w-0 h-full overflow-hidden bg-surface-sheet",
1342
+ children: /* @__PURE__ */ jsxs(Routes, { children: [
1343
+ /* @__PURE__ */ jsx(Route, {
1344
+ path: "/",
1345
+ element: registry.studioConfig?.homePage ?? /* @__PURE__ */ jsx(StudioHomePage, {})
1346
+ }),
1347
+ views.map((view) => {
1348
+ const ViewEl = view.view;
1349
+ const element = typeof ViewEl === "function" ? /* @__PURE__ */ jsx(ViewEl, {}) : ViewEl;
1350
+ return /* @__PURE__ */ jsx(Route, {
1351
+ path: `/${view.slug}/*`,
1352
+ element
1353
+ }, view.slug);
1354
+ }),
1355
+ /* @__PURE__ */ jsx(Route, {
1356
+ path: "*",
1357
+ element: /* @__PURE__ */ jsx(Navigate, {
1358
+ to: "/",
1359
+ replace: true
1360
+ })
1361
+ })
1362
+ ] })
1363
+ })]
1364
+ });
1365
+ }
1366
+ /**
1367
+ * Standalone Rebase Studio application shell.
1368
+ *
1369
+ * Mounts the full developer & zero-code BaaS console (Tables, SQL, RLS,
1370
+ * Schema Visualizer, Storage & Policies, Users & Roles, Webhooks, Cron,
1371
+ * API Explorer, Logs, Branches, Backups, API Keys) with ZERO dependency on
1372
+ * `@rebasepro/cms`.
1373
+ */
1374
+ function RebaseStudioApp({ apiUrl, client: providedClient, basename, name = "Rebase Studio", tools, devViews, withoutRouter = false }) {
1375
+ const resolvedBaseUrl = useMemo(() => {
1376
+ if (apiUrl !== void 0) return apiUrl;
1377
+ if (typeof window !== "undefined") return window.location.origin;
1378
+ return "";
1379
+ }, [apiUrl]);
1380
+ const client = useMemo(() => providedClient ?? createRebaseClient({ baseUrl: resolvedBaseUrl }), [providedClient, resolvedBaseUrl]);
1381
+ const authController = useRebaseAuthController({ client });
1382
+ const content = /* @__PURE__ */ jsxs(Rebase, {
1383
+ client,
1384
+ authController,
1385
+ apiUrl: resolvedBaseUrl,
1386
+ children: [/* @__PURE__ */ jsx(RebaseStudio, {
1387
+ tools,
1388
+ devViews
1389
+ }), /* @__PURE__ */ jsx(StudioStandaloneShell, {
1390
+ name,
1391
+ auth: authController
1392
+ })]
1393
+ });
1394
+ if (withoutRouter) return content;
1395
+ return /* @__PURE__ */ jsx(BrowserRouter, {
1396
+ basename,
1397
+ children: content
1398
+ });
1399
+ }
1400
+ //#endregion
1401
+ export { RebaseStudio, RebaseStudioApp, STUDIO_GROUP_ORDER, StudioBridgeContext, StudioBridgeProvider, StudioHomePage, useStudioBreadcrumbs, useStudioCollectionRegistry, useStudioNavigationState, useStudioSidePanelController, useStudioUrlController };
772
1402
 
773
1403
  //# sourceMappingURL=index.es.js.map