@rebasepro/studio 0.34.2 → 0.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{ApiExplorer-BhQFd_iR.js → ApiExplorer-C61w8gCc.js} +73 -58
- package/dist/ApiExplorer-C61w8gCc.js.map +1 -0
- package/dist/{ApiKeysView-CLBXUCgu.js → ApiKeysView-BdqASL_2.js} +33 -32
- package/dist/ApiKeysView-BdqASL_2.js.map +1 -0
- package/dist/{BranchesView-BKGhk-PC.js → BranchesView-Bh5lq9T_.js} +5 -5
- package/dist/BranchesView-Bh5lq9T_.js.map +1 -0
- package/dist/{CronJobsView-CwF_m6ZB.js → CronJobsView-DUuyzkJK.js} +392 -8
- package/dist/CronJobsView-DUuyzkJK.js.map +1 -0
- package/dist/FixedEditorOverlay-DtgPBSjq.js +93 -0
- package/dist/FixedEditorOverlay-DtgPBSjq.js.map +1 -0
- package/dist/{JSEditor-Br22PfLh.js → JSEditor-Bi2Aol-Y.js} +27 -21
- package/dist/JSEditor-Bi2Aol-Y.js.map +1 -0
- package/dist/{LogsExplorer-DOLRFQaW.js → LogsExplorer-BA8RfTwd.js} +46 -67
- package/dist/LogsExplorer-BA8RfTwd.js.map +1 -0
- package/dist/{RLSEditor-RE4YpN_z.js → RLSEditor-CTG3jLE7.js} +478 -224
- package/dist/RLSEditor-CTG3jLE7.js.map +1 -0
- package/dist/{SQLEditor-Dj5INEUZ.js → SQLEditor-DRo5kW1h.js} +15 -96
- package/dist/SQLEditor-DRo5kW1h.js.map +1 -0
- package/dist/{SchemaVisualizer-D2_cck4I.js → SchemaVisualizer-Dy4kWKT5.js} +15 -14
- package/dist/SchemaVisualizer-Dy4kWKT5.js.map +1 -0
- package/dist/{StorageView-DHm22S7y.js → StorageView-D0D8z4lI.js} +497 -4
- package/dist/StorageView-D0D8z4lI.js.map +1 -0
- package/dist/TableEditorView-BKhSBG-K.js +1694 -0
- package/dist/TableEditorView-BKhSBG-K.js.map +1 -0
- package/dist/UsersAndRolesView-CKw4SJPj.js +689 -0
- package/dist/UsersAndRolesView-CKw4SJPj.js.map +1 -0
- package/dist/WebhooksView-CFPY-N9h.js +465 -0
- package/dist/WebhooksView-CFPY-N9h.js.map +1 -0
- package/dist/adminFetch-BfOnfRgU.js +108 -0
- package/dist/adminFetch-BfOnfRgU.js.map +1 -0
- package/dist/components/ApiExplorer/TryItPanel.d.ts +6 -0
- package/dist/components/ApiKeys/scope-words.d.ts +1 -1
- package/dist/components/AuthSimulationSelector.d.ts +9 -1
- package/dist/components/CronJobs/DbCronJobsPanel.d.ts +2 -0
- package/dist/components/RLSEditor/DirectRlsPoliciesPanel.d.ts +7 -0
- package/dist/components/RebaseStudio.d.ts +1 -1
- package/dist/components/RebaseStudioApp.d.ts +28 -0
- package/dist/components/SQLEditor/FixedEditorOverlay.d.ts +12 -0
- package/dist/components/SQLEditor/SQLEditor.d.ts +2 -11
- package/dist/components/StorageView/StoragePoliciesPanel.d.ts +2 -0
- package/dist/components/StudioHomePage.d.ts +3 -1
- package/dist/components/TableEditor/TableEditorView.d.ts +2 -0
- package/dist/components/UsersAndRoles/UsersAndRolesView.d.ts +2 -0
- package/dist/components/Webhooks/WebhooksView.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +739 -109
- package/dist/index.es.js.map +1 -1
- package/dist/policy-presets-CJKzAvQp.js +167 -0
- package/dist/policy-presets-CJKzAvQp.js.map +1 -0
- package/dist/{useRunAsUsers-CLaAtXt6.js → useRunAsUsers-CF7tkGzj.js} +22 -3
- package/dist/useRunAsUsers-CF7tkGzj.js.map +1 -0
- package/dist/utils/adminFetch.d.ts +25 -0
- package/package.json +12 -16
- package/dist/ApiExplorer-BhQFd_iR.js.map +0 -1
- package/dist/ApiKeysView-CLBXUCgu.js.map +0 -1
- package/dist/BranchesView-BKGhk-PC.js.map +0 -1
- package/dist/CronJobsView-CwF_m6ZB.js.map +0 -1
- package/dist/JSEditor-Br22PfLh.js.map +0 -1
- package/dist/LogsExplorer-DOLRFQaW.js.map +0 -1
- package/dist/RLSEditor-RE4YpN_z.js.map +0 -1
- package/dist/SQLEditor-Dj5INEUZ.js.map +0 -1
- package/dist/SchemaVisualizer-D2_cck4I.js.map +0 -1
- package/dist/StorageView-DHm22S7y.js.map +0 -1
- package/dist/useRunAsUsers-CLaAtXt6.js.map +0 -1
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","names":[],"sources":["../src/components/StudioHomePage.tsx","../src/components/RebaseStudio.tsx"],"sourcesContent":["import type { AppView, HomePageSection, PluginGenericProps } from \"@rebasepro/cms-types\";\nimport { studioSchemaToolEnabled } from \"@rebasepro/cms-types\";\nimport React, { useEffect, useMemo, useState } from \"react\";\nimport { Card, cls, Container, ExpandablePanel, Typography } from \"@rebasepro/ui\";\nimport { IconForView, useApiConfig, useNavigationGroupLabel, useRebaseContext, useRebaseRegistry, useRestoreScroll, useSlot, useTranslation } from \"@rebasepro/app\";\nimport { useNavigate } from \"react-router\";\nimport { useStudioBreadcrumbs, SchemaDriftBanner } from \"@rebasepro/app\";\n\n/* ═══════════════════════════════════════════════════════════════\n Studio tool sections, derived from the registered Studio views\n ═══════════════════════════════════════════════════════════════ */\n\ninterface StudioTool {\n path: string;\n name: string;\n description: string;\n icon?: string | React.ReactNode;\n}\n\ninterface StudioSection {\n label: string;\n tools: StudioTool[];\n}\n\n/** The view metadata the cards need — not the rendered `view` itself. */\ntype StudioViewMeta = Pick<AppView, \"slug\" | \"name\" | \"group\" | \"description\" | \"icon\" | \"hideFromNavigation\">;\n\n/** Group order for the home page; unknown groups are appended in view order. */\nconst GROUP_ORDER = [\"Database\", \"Compute\", \"Storage\", \"API\", \"Access Control\"];\n\nconst UNGROUPED_LABEL = \"Tools\";\n\n/**\n * Build the home page sections from the Studio views that are actually\n * registered, so a card exists if and only if its route does. A hand-written\n * list drifts: it used to advertise Users and Roles pages that 404, while\n * omitting the Backups view that does exist.\n */\nfunction buildSections(views: StudioViewMeta[]): StudioSection[] {\n const byGroup = new Map<string, StudioTool[]>();\n\n for (const view of views) {\n if (view.hideFromNavigation) continue;\n const label = view.group ?? UNGROUPED_LABEL;\n const tools = byGroup.get(label) ?? [];\n tools.push({\n path: `/${view.slug}`,\n name: view.name,\n description: view.description ?? \"\",\n icon: view.icon\n });\n byGroup.set(label, tools);\n }\n\n const ordered = [\n ...GROUP_ORDER.filter(g => byGroup.has(g)),\n ...[...byGroup.keys()].filter(g => !GROUP_ORDER.includes(g))\n ];\n\n return ordered.map(label => ({ label,\ntools: byGroup.get(label)! }));\n}\n\n/* ═══════════════════════════════════════════════════════════════ */\n\nconst COLLAPSED_STORAGE_KEY = \"rebase-studio-home-collapsed\";\n\nfunction useStudioCollapsedGroups(groupNames: string[]) {\n const [collapsed, setCollapsed] = useState<Set<string>>(() => {\n try {\n const stored = localStorage.getItem(COLLAPSED_STORAGE_KEY);\n return stored ? new Set(JSON.parse(stored)) : new Set<string>();\n } catch {\n return new Set<string>();\n }\n });\n\n const isGroupCollapsed = (name: string) => collapsed.has(name);\n\n const toggleGroupCollapsed = (name: string) => {\n setCollapsed(prev => {\n const next = new Set(prev);\n if (next.has(name)) {\n next.delete(name);\n } else {\n next.add(name);\n }\n try {\n localStorage.setItem(COLLAPSED_STORAGE_KEY, JSON.stringify([...next]));\n } catch { /* noop */ }\n return next;\n });\n };\n\n return { isGroupCollapsed, toggleGroupCollapsed };\n}\n\nexport function StudioHomePage({\n additionalActions,\n additionalChildrenStart,\n additionalChildrenEnd,\n sections,\n hiddenGroups\n}: {\n additionalActions?: React.ReactNode;\n additionalChildrenStart?: React.ReactNode;\n additionalChildrenEnd?: React.ReactNode;\n sections?: HomePageSection[];\n hiddenGroups?: string[];\n}) {\n const context = useRebaseContext();\n const breadcrumbs = useStudioBreadcrumbs();\n const navigate = useNavigate();\n const registry = useRebaseRegistry();\n const { t } = useTranslation();\n const apiConfig = useApiConfig();\n const apiUrl = absoluteApiUrl(apiConfig?.apiUrl);\n\n useEffect(() => {\n breadcrumbs.set({ breadcrumbs: [] });\n }, [breadcrumbs.set]);\n\n const { containerRef } = useRestoreScroll();\n\n const sectionProps: PluginGenericProps = { context };\n\n const pluginActions = useSlot(\"home.actions\", sectionProps);\n\n // The collection editor (\"schema\") is not part of `devViews` — RebaseNavigation\n // injects it when the admin enables a collection editor and the Studio's\n // tools include it. The same predicate, so the card tracks the route.\n const schemaEnabled = studioSchemaToolEnabled(registry);\n\n const filteredSections = useMemo(() => {\n const views: StudioViewMeta[] = [];\n if (schemaEnabled) {\n views.push({\n slug: \"schema\",\n name: t(\"studio_tool_schema\"),\n group: \"Database\",\n icon: \"LayoutList\",\n description: t(\"studio_tool_schema_description\")\n });\n }\n views.push(...(registry.studioConfig?.devViews ?? []));\n return buildSections(views).filter(s => !hiddenGroups?.includes(s.label));\n }, [registry.studioConfig?.devViews, schemaEnabled, hiddenGroups, t]);\n\n const groupNames = useMemo(\n () => filteredSections.map(s => s.label),\n [filteredSections]\n );\n\n const { isGroupCollapsed, toggleGroupCollapsed } = useStudioCollapsedGroups(groupNames);\n // The group name is the identifier this page orders and collapses by;\n // only what the reader sees is translated.\n const groupLabel = useNavigationGroupLabel();\n\n return (\n <div ref={containerRef} className=\"py-2 overflow-auto h-full w-full bg-surface-sheet\">\n <Container maxWidth=\"6xl\">\n <div className=\"mb-4 flex flex-col gap-2\">\n <SchemaDriftBanner />\n </div>\n\n {(additionalActions || pluginActions) && (\n <div className=\"w-full sticky py-4 transition-all duration-400 ease-in-out top-0 z-10 flex flex-row gap-4 justify-end\">\n {additionalActions}\n {pluginActions}\n </div>\n )}\n\n {additionalChildrenStart}\n\n {/* ── Tool sections ── */}\n {filteredSections.map((section) => {\n const sectionCollapsed = isGroupCollapsed(section.label);\n\n return (\n <div key={section.label} className=\"my-10\">\n <ExpandablePanel\n invisible\n expanded={!sectionCollapsed}\n onExpandedChange={(open) => {\n if (open !== !sectionCollapsed) {\n toggleGroupCollapsed(section.label);\n }\n }}\n className=\"mt-6\"\n titleClassName={cls(\n \"min-h-0 p-0 border-none\",\n \"rounded flex items-center justify-between w-full\",\n \"hover:bg-transparent\",\n \"cursor-pointer select-none\",\n sectionCollapsed && \"bg-surface-field\"\n )}\n innerClassName=\"mt-4 pt-0\"\n title={\n <Typography\n variant=\"caption\"\n component=\"h2\"\n color=\"secondary\"\n className={cls(\n \"px-4 py-1 rounded\",\n \"font-medium text-2xs uppercase tracking-[0.08em] text-surface-400 dark:text-surface-400\"\n )}\n >\n {groupLabel(section.label)}\n </Typography>\n }\n >\n <div className=\"mt-4 pt-0\">\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4\">\n {section.tools.map((tool) => (\n <Card\n key={tool.path}\n onClick={() => {\n navigate(tool.path);\n context.analyticsController?.onAnalyticsEvent?.(\n \"home_navigate_to_view\",\n { path: tool.path }\n );\n }}\n className={cls(\n \"group h-full p-4 cursor-pointer transition-colors duration-150 ease-in-out\",\n \"hover:bg-surface-card-hover\"\n )}\n >\n <div className=\"flex flex-col h-full\">\n {/* Header: icon + title */}\n <div className=\"flex items-center w-full justify-between mb-1\">\n <div className=\"flex items-center gap-3\">\n <div className=\"flex items-center justify-center w-5 h-5 text-surface-400 dark:text-surface-500 transition-colors duration-150 group-hover:text-primary dark:group-hover:text-primary\">\n <IconForView\n collectionOrView={{ slug: tool.path, name: tool.name, icon: tool.icon }}\n size=\"small\"\n />\n </div>\n <Typography variant=\"subtitle1\" component=\"h2\">\n {tool.name}\n </Typography>\n </div>\n </div>\n\n {/* Description indented to align with title */}\n <div className=\"pl-8\">\n {tool.description && (\n <Typography variant=\"caption\" color=\"secondary\" component=\"div\">\n {tool.description}\n </Typography>\n )}\n </div>\n\n {/* Spacer */}\n <div className=\"grow\"/>\n </div>\n </Card>\n ))}\n </div>\n </div>\n </ExpandablePanel>\n </div>\n );\n })}\n\n {/* ── SDK Quick Start ── */}\n <div className=\"mt-10 mb-6\">\n <div className=\"flex items-center mb-1\">\n <Typography\n variant=\"caption\"\n component=\"h2\"\n color=\"secondary\"\n className={cls(\n \"px-4 py-1 rounded\",\n \"font-medium text-2xs uppercase tracking-[0.08em] text-surface-400 dark:text-surface-400\"\n )}\n >\n Quick Start\n </Typography>\n </div>\n\n <Typography variant=\"body2\" color=\"secondary\" className=\"mb-4 max-w-2xl\">\n Generate a fully-typed SDK from your tables with{\" \"}\n <code className=\"text-emerald-400 font-mono text-xs bg-emerald-400/10 px-1.5 py-0.5 rounded\">\n npx rebase generate-sdk\n </code>\n {\" \"}and start querying your data with full TypeScript autocompletion.\n </Typography>\n\n <div className=\"rounded-lg border border-hairline bg-surface-card overflow-hidden\">\n {/* Title bar */}\n <div className=\"flex items-center justify-between px-4 py-2.5 border-b border-hairline bg-surface-sheet\">\n <div className=\"flex items-center gap-2.5\">\n <div className=\"flex gap-1.5\">\n <span className=\"w-2.5 h-2.5 rounded-full bg-red-400/60\"/>\n <span className=\"w-2.5 h-2.5 rounded-full bg-amber-400/60\"/>\n <span className=\"w-2.5 h-2.5 rounded-full bg-emerald-400/60\"/>\n </div>\n <span className=\"text-xs font-mono text-surface-400 dark:text-surface-500 ml-1\">\n app.ts\n </span>\n </div>\n <span className=\"text-xs font-mono text-surface-400 dark:text-surface-500\">\n TypeScript\n </span>\n </div>\n\n {/* Syntax-highlighted code */}\n <div className=\"px-5 py-4 overflow-x-auto text-[13px] leading-6 font-mono\">\n <SyntaxHighlightedSnippet baseUrl={apiUrl}/>\n </div>\n </div>\n </div>\n\n {/* ── Extra sections from props ── */}\n {sections?.map((s) => (\n <div key={s.key} className=\"my-10\">\n <Typography\n variant=\"caption\"\n component=\"h2\"\n color=\"secondary\"\n className={cls(\n \"px-4 py-1 rounded\",\n \"font-medium text-2xs uppercase tracking-[0.08em] text-surface-400 dark:text-surface-400\"\n )}\n >\n {s.title}\n </Typography>\n <div className=\"mt-4\">{s.children}</div>\n </div>\n ))}\n\n {additionalChildrenEnd}\n </Container>\n </div>\n );\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Hand-crafted syntax-highlighted code snippet.\n Uses inline spans with Tailwind color classes to avoid\n pulling in a syntax highlighting library.\n ═══════════════════════════════════════════════════════════════ */\n\n/**\n * The address the panel's API answers on, as a script would write it: absolute\n * (a same-origin panel is configured with a relative one) and without a\n * trailing slash. It is what `baseUrl` takes — the API's path is the client's.\n */\nfunction absoluteApiUrl(apiUrl: string | undefined): string {\n const page = typeof window !== \"undefined\" ? window.location.href : undefined;\n try {\n return new URL(apiUrl || \"/\", page).href.replace(/\\/+$/, \"\");\n } catch {\n return apiUrl ?? \"\";\n }\n}\n\n/** The quick-start client, pointed at `baseUrl`. */\nfunction SyntaxHighlightedSnippet({ baseUrl }: { baseUrl: string }) {\n const kw = \"text-violet-600 dark:text-violet-400\"; // keywords\n const str = \"text-emerald-600 dark:text-emerald-400\"; // strings\n const typ = \"text-amber-600 dark:text-amber-300\"; // types\n const fn = \"text-blue-600 dark:text-blue-400\"; // functions\n const cm = \"text-surface-500 dark:text-surface-400 italic\"; // comments\n const op = \"text-surface-500 dark:text-surface-400\"; // operators / punctuation\n const tx = \"text-surface-950 dark:text-surface-200\"; // plain text\n\n return (\n <pre className=\"m-0 whitespace-pre\">\n <span className={kw}>import</span>\n <span className={tx}>{\" { \"}</span>\n <span className={fn}>createRebaseClient</span>\n <span className={tx}>{\" } \"}</span>\n <span className={kw}>from</span>\n <span className={tx}> </span>\n <span className={str}>'@rebasepro/client'</span>\n <span className={op}>;</span>\n {\"\\n\"}\n\n <span className={kw}>import</span>\n <span className={tx}>{\" { tablesDictionary, \"}</span>\n <span className={kw}>type</span>\n <span className={tx}> </span>\n <span className={typ}>Database</span>\n <span className={tx}>{\" } \"}</span>\n <span className={kw}>from</span>\n <span className={tx}> </span>\n <span className={str}>'./database.types'</span>\n <span className={op}>;</span>\n {\"\\n\\n\"}\n\n <span className={kw}>const</span>\n <span className={tx}> rebase </span>\n <span className={op}>= </span>\n <span className={fn}>createRebaseClient</span>\n <span className={op}>{\"<\"}</span>\n <span className={typ}>Database</span>\n <span className={op}>{\">(\"}</span>\n <span className={tx}>{\"{\"}</span>\n {\"\\n\"}\n <span className={tx}>{\" baseUrl\"}</span>\n <span className={op}>: </span>\n <span className={str}>'{baseUrl}'</span>\n <span className={op}>,</span>\n {\"\\n\"}\n {/* Maps each accessor back to its slug: without it a hyphenated\n slug is not reachable from the property name, and the copied\n client 404s on that table. */}\n <span className={tx}>{\" tables\"}</span>\n <span className={op}>: </span>\n <span className={tx}>tablesDictionary</span>\n <span className={op}>,</span>\n {\"\\n\"}\n <span className={tx}>{\"}\"}</span>\n <span className={op}>);</span>\n {\"\\n\\n\"}\n\n <span className={cm}>{\"// Fully typed — autocompletion for tables and columns\"}</span>\n {\"\\n\"}\n <span className={kw}>const</span>\n <span className={tx}>{\" { \"}</span>\n <span className={tx}>data</span>\n <span className={op}>: </span>\n <span className={tx}>users</span>\n <span className={tx}>{\" } \"}</span>\n <span className={op}>= </span>\n <span className={kw}>await</span>\n <span className={tx}> rebase</span>\n <span className={op}>.</span>\n <span className={tx}>data</span>\n <span className={op}>.</span>\n <span className={tx}>users</span>\n <span className={op}>.</span>\n <span className={fn}>find</span>\n <span className={op}>();</span>\n {\"\\n\"}\n\n <span className={kw}>const</span>\n <span className={tx}>{\" { \"}</span>\n <span className={tx}>data</span>\n <span className={op}>: </span>\n <span className={tx}>posts</span>\n <span className={tx}>{\" } \"}</span>\n <span className={op}>= </span>\n <span className={kw}>await</span>\n <span className={tx}> rebase</span>\n <span className={op}>.</span>\n <span className={tx}>data</span>\n <span className={op}>.</span>\n <span className={fn}>collection</span>\n <span className={op}>(</span>\n <span className={str}>'posts'</span>\n <span className={op}>)</span>\n <span className={op}>.</span>\n <span className={fn}>find</span>\n <span className={op}>();</span>\n </pre>\n );\n}\n","import React, { Suspense, useLayoutEffect, useMemo } from \"react\";\nimport { useRebaseEmbedHost, useRebaseRegistryDispatch, useTranslation } from \"@rebasepro/app\";\nimport type { RebaseStudioConfig, AppView } from \"@rebasepro/cms-types\";\nimport { CircularProgressCenter, lazyChunk } from \"@rebasepro/ui\";\n\n// Lazy-loaded studio tools — each fetched only when its route is visited.\n// This keeps Monaco, @xyflow/react, dagre, pgsql-ast-parser etc. out of the initial bundle.\nconst SQLEditor = lazyChunk(() => import(\"./SQLEditor/SQLEditor\").then(m => ({ default: m.SQLEditor })));\nconst JSEditor = lazyChunk(() => import(\"./JSEditor/JSEditor\").then(m => ({ default: m.JSEditor })));\nconst RLSEditor = lazyChunk(() => import(\"./RLSEditor/RLSEditor\").then(m => ({ default: m.RLSEditor })));\nconst StorageView = lazyChunk(() => import(\"./StorageView/StorageView\").then(m => ({ default: m.StorageView })));\nconst CronJobsView = lazyChunk(() => import(\"./CronJobs/CronJobsView\").then(m => ({ default: m.CronJobsView })));\nconst SchemaVisualizer = lazyChunk(() => import(\"./SchemaVisualizer/SchemaVisualizer\").then(m => ({ default: m.SchemaVisualizer })));\nconst BranchesView = lazyChunk(() => import(\"./Branches/BranchesView\").then(m => ({ default: m.BranchesView })));\nconst BackupsView = lazyChunk(() => import(\"./Backups/BackupsView\").then(m => ({ default: m.BackupsView })));\nconst ApiExplorer = lazyChunk(() => import(\"./ApiExplorer/ApiExplorer\").then(m => ({ default: m.ApiExplorer })));\nconst LogsExplorer = lazyChunk(() => import(\"./LogsExplorer/LogsExplorer\").then(m => ({ default: m.LogsExplorer })));\nconst ApiKeysView = lazyChunk(() => import(\"./ApiKeys/ApiKeysView\").then(m => ({ default: m.ApiKeysView })));\n\nimport { StudioHomePage } from \"./StudioHomePage\";\n\n/**\n * Declarative component to configure the Studio in Rebase.\n * Renders nothing — purely registers config into the RebaseRegistry.\n *\n * The \"schema\" tool (collection editor view) is a Studio tool, but it is not\n * registered here: it ships from the panel package because it needs the project's\n * collection source to write back to. When `<RebaseCMS collectionEditor={...}>`\n * is used, the schema view is automatically injected into Studio — no manual\n * wiring needed. Where it is mounted from is an implementation detail; it is a\n * schema-editing tool and belongs beside SQL and RLS.\n */\nconst DEFAULT_HOME_PAGE = <StudioHomePage/>;\n\n/**\n * Studio: the developer tools, registered beside the admin.\n *\n * Not in an embedding (an MCP App view, `embed_host.ts` in `@rebasepro/app`):\n * there the app is shown to the person it runs as, and Studio's tools change\n * the project.\n */\nexport function RebaseStudio(props: RebaseStudioConfig) {\n const embed = useRebaseEmbedHost();\n return embed ? null : <RebaseStudioRegistration {...props}/>;\n}\n\nfunction RebaseStudioRegistration({ tools, homePage, devViews: extraViews }: RebaseStudioConfig) {\n const dispatch = useRebaseRegistryDispatch();\n const { t, i18n } = useTranslation();\n\n const resolvedHomePage = homePage ?? DEFAULT_HOME_PAGE;\n\n /**\n * The tool list reduced to a value, so that re-rendering the host does not\n * republish the registry.\n *\n * `tools` is an array, and callers write it inline — `tools={[...TOOLS]}`\n * in the hosted console. A fresh array every render meant a fresh\n * `devViews` every render, which meant the effect below unregistered and\n * re-registered on every render. Because each registration builds *new*\n * `<Suspense><SQLEditor/></Suspense>` elements, whatever view was on screen\n * was torn down and remounted each time: a half-typed SQL query, a storage\n * folder you had navigated into, an open policy editor — all discarded, and\n * every mount reissued the view's initial requests.\n */\n const toolsKey = tools ? tools.join(\",\") : \"\";\n\n const devViews: AppView[] = useMemo(() => {\n const views: AppView[] = [];\n const activeTools = tools ?? [\"sql\", \"js\", \"rls\", \"storage\", \"cron\", \"schema-visualizer\", \"branches\", \"backups\", \"api\", \"logs\", \"api-keys\"];\n const suspense = (el: React.ReactNode) => <Suspense fallback={<CircularProgressCenter/>}>{el}</Suspense>;\n\n if (activeTools.includes(\"sql\")) {\n views.push({ slug: \"sql\",\nname: t(\"studio_tool_sql\"),\ngroup: \"Database\",\nicon: \"terminal\",\ndescription: t(\"studio_tool_sql_description\"),\nview: suspense(<SQLEditor/>) });\n }\n if (activeTools.includes(\"js\")) {\n views.push({ slug: \"js\",\nname: t(\"studio_tool_js\"),\ngroup: \"Compute\",\nicon: \"code\",\ndescription: t(\"studio_tool_js_description\"),\nview: suspense(<JSEditor/>) });\n }\n if (activeTools.includes(\"rls\")) {\n views.push({ slug: \"rls\",\nname: t(\"studio_tool_rls\"),\ngroup: \"Database\",\nicon: \"ShieldCheck\",\ndescription: t(\"studio_tool_rls_description\"),\nview: suspense(<RLSEditor/>) });\n }\n if (activeTools.includes(\"storage\")) {\n views.push({ slug: \"storage\",\nname: t(\"studio_tool_storage\"),\ngroup: \"Storage\",\nicon: \"HardDrive\",\ndescription: t(\"studio_tool_storage_description\"),\nview: suspense(<StorageView/>) });\n }\n if (activeTools.includes(\"cron\")) {\n views.push({ slug: \"cron\",\nname: t(\"studio_tool_cron\"),\ngroup: \"Compute\",\nicon: \"Clock\",\ndescription: t(\"studio_tool_cron_description\"),\nview: suspense(<CronJobsView/>) });\n }\n if (activeTools.includes(\"schema-visualizer\")) {\n views.push({ slug: \"schema-visualizer\",\nname: t(\"studio_tool_schema_visualizer\"),\ngroup: \"Database\",\nicon: \"Network\",\ndescription: t(\"studio_tool_schema_visualizer_description\"),\nview: suspense(<SchemaVisualizer/>) });\n }\n if (activeTools.includes(\"branches\")) {\n views.push({ slug: \"branches\",\nname: t(\"studio_tool_branches\"),\ngroup: \"Database\",\nicon: \"GitBranch\",\ndescription: t(\"studio_tool_branches_description\"),\nview: suspense(<BranchesView/>) });\n }\n if (activeTools.includes(\"backups\")) {\n views.push({ slug: \"backups\",\nname: t(\"studio_tool_backups\"),\ngroup: \"Database\",\nicon: \"Database\",\ndescription: t(\"studio_tool_backups_description\"),\nview: suspense(<BackupsView/>) });\n }\n if (activeTools.includes(\"api\")) {\n views.push({ slug: \"api\",\nname: t(\"studio_tool_api\"),\ngroup: \"API\",\nicon: \"BookOpen\",\ndescription: t(\"studio_tool_api_description\"),\nview: suspense(<ApiExplorer/>) });\n }\n if (activeTools.includes(\"logs\")) {\n views.push({ slug: \"logs\",\nname: t(\"studio_tool_logs\"),\ngroup: \"Database\",\nicon: \"Activity\",\ndescription: t(\"studio_tool_logs_description\"),\nview: suspense(<LogsExplorer/>) });\n }\n if (activeTools.includes(\"api-keys\")) {\n views.push({ slug: \"api-keys\",\nname: t(\"studio_tool_api_keys\"),\ngroup: \"Access Control\",\nicon: \"KeyRound\",\ndescription: t(\"studio_tool_api_keys_description\"),\nview: suspense(<ApiKeysView/>) });\n }\n // Note: \"schema\" tool is auto-injected by RebaseShell when collectionEditor is enabled.\n // It is NOT registered here anymore.\n return views;\n // Keyed by the tool list's *contents*; see `toolsKey`. `tools` itself is\n // read inside, and is exactly determined by the key.\n // The strings are now translated, so the active language is part of\n // what this list is.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [toolsKey, t, i18n.language]);\n\n /**\n * Your own tools, keyed the same way `tools` is and for the same reason:\n * callers write `devViews={[…]}` inline, so the array is new on every\n * render. Re-registering would tear down and remount whichever Studio view\n * was on screen — a half-typed SQL query, an open policy editor.\n *\n * The key is the identity of each view, not its element: a view's `view` is\n * resolved by the router at render time, so a fresh element for the same\n * slug is not a configuration change.\n */\n const extraViewsKey = (extraViews ?? [])\n .map((v) => `${v.slug}|${v.name}|${v.group ?? \"\"}|${v.hideFromNavigation ?? false}`)\n .join(\",\");\n const extraViewsRef = React.useRef(extraViews);\n extraViewsRef.current = extraViews;\n\n const allDevViews: AppView[] = useMemo(\n () => [...devViews, ...(extraViewsRef.current ?? [])],\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [devViews, extraViewsKey]\n );\n\n // Use a ref for homePage so it never destabilizes the effect.\n // homePage is a React element — its identity doesn't matter for registration.\n const homePageRef = React.useRef(resolvedHomePage);\n homePageRef.current = resolvedHomePage;\n\n // Same reasoning for `tools`: it is registered as config, but a new array\n // with the same contents must not count as a change.\n const toolsRef = React.useRef(tools);\n toolsRef.current = tools;\n\n useLayoutEffect(() => {\n dispatch.registerStudio({ tools: toolsRef.current,\nhomePage: homePageRef.current,\ndevViews: allDevViews });\n return () => dispatch.unregisterStudio();\n }, [dispatch, allDevViews]);\n\n return null;\n}\n"],"mappings":";;;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ClB,SAAS,eAAe;GAAE,OAAO,SAAS;GAClD,UAAU,YAAY;GACtB,UAAU;EAAY,CAAC;EACf,aAAa,SAAS,iBAAiB;CAC3C,GAAG,CAAC,UAAU,WAAW,CAAC;CAE1B,OAAO;AACX"}
|
|
1
|
+
{"version":3,"file":"index.es.js","names":[],"sources":["../src/components/StudioHomePage.tsx","../src/components/RebaseStudio.tsx","../src/components/RebaseStudioApp.tsx"],"sourcesContent":["import type { AppView, HomePageSection, PluginGenericProps } from \"@rebasepro/app\";\nimport React, { useEffect, useMemo, useState } from \"react\";\nimport { ArrowRightIcon, Card, cls, Container, ExpandablePanel, SearchBar, StatusDot, Typography } from \"@rebasepro/ui\";\nimport { IconForView, useApiConfig, useNavigationGroupLabel, useRebaseContext, useRebaseRegistry, useRestoreScroll, useSlot, useTranslation } from \"@rebasepro/app\";\nimport { useNavigate } from \"react-router\";\nimport { useStudioBreadcrumbs, SchemaDriftBanner } from \"@rebasepro/app\";\nimport { isRecord, useAdminFetch } from \"../utils/adminFetch\";\n\ninterface LiveSchemaStats {\n tables: number;\n columns: number;\n relations: number;\n rlsProtected: number;\n tableNames: string[];\n}\n\nconst TOOL_READOUTS: Record<string, { label: string; value: string }> = {\n \"/s/tables\": { label: \"ENGINE\", value: \"DDL · ROWS · INDEXES\" },\n \"/s/sql\": { label: \"QUERY\", value: \"SQL · EXPLAIN\" },\n \"/s/rls\": { label: \"ACCESS\", value: \"POLICIES · SIMULATOR\" },\n \"/s/schema\": { label: \"GRAPH\", value: \"ERD · RELATIONS\" },\n \"/s/branches\": { label: \"SCHEMA\", value: \"BRANCH · DIFF\" },\n \"/s/backups\": { label: \"SNAPSHOT\", value: \"DUMP · RESTORE\" },\n \"/s/logs\": { label: \"STREAM\", value: \"LIVE TAIL\" },\n \"/s/js\": { label: \"RUNTIME\", value: \"SDK · REPL\" },\n \"/s/crons\": { label: \"SCHEDULE\", value: \"CRON · JOBS\" },\n \"/s/storage\": { label: \"OBJECTS\", value: \"BUCKETS · RLS\" },\n \"/s/api\": { label: \"SPEC\", value: \"OPENAPI · REST\" },\n \"/s/webhooks\": { label: \"EVENTS\", value: \"DELIVERY · LOGS\" },\n \"/s/users\": { label: \"IDENTITY\", value: \"USERS · ROLES\" },\n \"/s/api-keys\": { label: \"TOKENS\", value: \"SCOPED · KEYS\" }\n};\n\n/* ═══════════════════════════════════════════════════════════════\n Studio tool sections, derived from the registered Studio views\n ═══════════════════════════════════════════════════════════════ */\n\ninterface StudioTool {\n path: string;\n name: string;\n description: string;\n icon?: string | React.ReactNode;\n}\n\ninterface StudioSection {\n label: string;\n tools: StudioTool[];\n}\n\n/** The view metadata the cards need — not the rendered `view` itself. */\ntype StudioViewMeta = Pick<AppView, \"slug\" | \"name\" | \"group\" | \"description\" | \"icon\" | \"hideFromNavigation\">;\n\n/** Group order for the home page; unknown groups are appended in view order. */\nexport const STUDIO_GROUP_ORDER = [\"Database\", \"Compute\", \"Storage\", \"API\", \"Access Control\"];\nconst GROUP_ORDER = STUDIO_GROUP_ORDER;\n\nconst UNGROUPED_LABEL = \"Tools\";\n\n/**\n * Build the home page sections from the Studio views that are actually\n * registered, so a card exists if and only if its route does. A hand-written\n * list drifts: it used to advertise Users and Roles pages that 404, while\n * omitting the Backups view that does exist.\n */\nfunction buildSections(views: StudioViewMeta[]): StudioSection[] {\n const byGroup = new Map<string, StudioTool[]>();\n\n for (const view of views) {\n if (view.hideFromNavigation) continue;\n const label = view.group ?? UNGROUPED_LABEL;\n const tools = byGroup.get(label) ?? [];\n tools.push({\n path: `/${view.slug}`,\n name: view.name,\n description: view.description ?? \"\",\n icon: view.icon\n });\n byGroup.set(label, tools);\n }\n\n const ordered = [\n ...GROUP_ORDER.filter(g => byGroup.has(g)),\n ...[...byGroup.keys()].filter(g => !GROUP_ORDER.includes(g))\n ];\n\n return ordered.map(label => ({ label,\ntools: byGroup.get(label)! }));\n}\n\n/* ═══════════════════════════════════════════════════════════════ */\n\nconst COLLAPSED_STORAGE_KEY = \"rebase-studio-home-collapsed\";\n\nfunction useStudioCollapsedGroups(groupNames: string[]) {\n const [collapsed, setCollapsed] = useState<Set<string>>(() => {\n try {\n const stored = localStorage.getItem(COLLAPSED_STORAGE_KEY);\n return stored ? new Set(JSON.parse(stored)) : new Set<string>();\n } catch {\n return new Set<string>();\n }\n });\n\n const isGroupCollapsed = (name: string) => collapsed.has(name);\n\n const toggleGroupCollapsed = (name: string) => {\n setCollapsed(prev => {\n const next = new Set(prev);\n if (next.has(name)) {\n next.delete(name);\n } else {\n next.add(name);\n }\n try {\n localStorage.setItem(COLLAPSED_STORAGE_KEY, JSON.stringify([...next]));\n } catch { /* noop */ }\n return next;\n });\n };\n\n return { isGroupCollapsed, toggleGroupCollapsed };\n}\n\nexport function StudioHomePage({\n additionalActions,\n additionalChildrenStart,\n additionalChildrenEnd,\n sections,\n hiddenGroups\n}: {\n additionalActions?: React.ReactNode;\n additionalChildrenStart?: React.ReactNode;\n additionalChildrenEnd?: React.ReactNode;\n sections?: HomePageSection[];\n hiddenGroups?: string[];\n}) {\n const context = useRebaseContext();\n const breadcrumbs = useStudioBreadcrumbs();\n const navigate = useNavigate();\n const registry = useRebaseRegistry();\n const apiConfig = useApiConfig();\n const apiUrl = absoluteApiUrl(apiConfig?.apiUrl);\n const { t } = useTranslation();\n\n useEffect(() => {\n breadcrumbs.set({ breadcrumbs: [] });\n }, [breadcrumbs.set]);\n\n const { containerRef } = useRestoreScroll();\n const [searchQuery, setSearchQuery] = useState(\"\");\n const [schemaStats, setSchemaStats] = useState<LiveSchemaStats | null>(null);\n\n // Through the admin client, which sends the session's token: a bare\n // `fetch` with cookies answered 401 wherever the session is a bearer\n // token, and the card sat on dashes.\n const { requestJson } = useAdminFetch();\n useEffect(() => {\n if (typeof fetch !== \"function\") return;\n let cancelled = false;\n requestJson(\"/schema/tables\")\n .then((body: unknown) => {\n if (cancelled || !body || typeof body !== \"object\") return;\n const list = isRecord(body) && Array.isArray(body.tables)\n ? body.tables\n : (Array.isArray(body) ? body : null);\n if (!list) return;\n let tables = 0;\n let columns = 0;\n let relations = 0;\n let rlsProtected = 0;\n const tableNames: string[] = [];\n for (const item of list) {\n if (!isRecord(item)) continue;\n if (item.kind && item.kind !== \"table\") continue;\n tables++;\n if (typeof item.table === \"string\") tableNames.push(item.table);\n else if (typeof item.name === \"string\") tableNames.push(item.name);\n // A `TableDescriptor`: columns and relations are arrays,\n // and a served table's policies are its `rls` posture —\n // \"rules\" or \"admin-only\", never off.\n columns += countOf(item.columns);\n relations += countOf(item.relations);\n const rls = isRecord(item.rls) ? item.rls : undefined;\n if (rls?.posture === \"rules\" || rls?.posture === \"admin-only\") {\n rlsProtected++;\n }\n }\n if (tables > 0) {\n setSchemaStats({ tables, columns, relations, rlsProtected, tableNames });\n }\n })\n .catch(() => { /* ignore background overview fetch errors */ });\n return () => {\n cancelled = true;\n };\n }, [requestJson, apiConfig?.apiUrl, apiConfig?.apiPath]);\n\n const sectionProps: PluginGenericProps = { context };\n\n const pluginActions = useSlot(\"home.actions\", sectionProps);\n\n const allSections = useMemo(\n () => buildSections([...(registry.studioConfig?.devViews ?? [])]).filter(s => !hiddenGroups?.includes(s.label)),\n [registry.studioConfig?.devViews, hiddenGroups]\n );\n\n const filteredSections = useMemo(() => {\n const q = searchQuery.trim().toLowerCase();\n if (!q) return allSections;\n return allSections\n .map((section) => ({\n ...section,\n tools: section.tools.filter(\n (tool) =>\n tool.name.toLowerCase().includes(q) ||\n tool.description.toLowerCase().includes(q) ||\n section.label.toLowerCase().includes(q)\n )\n }))\n .filter((section) => section.tools.length > 0);\n }, [allSections, searchQuery]);\n\n const totalToolsCount = useMemo(\n () => allSections.reduce((acc, s) => acc + s.tools.length, 0),\n [allSections]\n );\n\n const groupNames = useMemo(\n () => filteredSections.map(s => s.label),\n [filteredSections]\n );\n\n const { isGroupCollapsed, toggleGroupCollapsed } = useStudioCollapsedGroups(groupNames);\n // The group name is the identifier this page orders and collapses by;\n // only what the reader sees is translated.\n const groupLabel = useNavigationGroupLabel();\n\n const tableCount = schemaStats?.tables ?? 0;\n const apiHostLabel = useMemo(() => {\n try {\n return new URL(apiUrl).host;\n } catch {\n return apiUrl || \"same-origin\";\n }\n }, [apiUrl]);\n\n return (\n <div ref={containerRef} className=\"py-2 overflow-auto h-full w-full bg-surface-sheet\">\n <Container maxWidth=\"6xl\">\n <div className=\"mb-4 flex flex-col gap-2\">\n <SchemaDriftBanner />\n </div>\n\n {/* Top search bar — matches CMS Home rhythm */}\n <div className=\"w-full py-3 sticky top-0 z-10 bg-surface-sheet/90 backdrop-blur-md flex flex-row gap-3 items-center\">\n <div className=\"flex-1\">\n <SearchBar\n onTextSearch={(v) => setSearchQuery(v ?? \"\")}\n placeholder=\"Search Studio tools…\"\n innerClassName=\"w-full\"\n />\n </div>\n {additionalActions}\n {pluginActions}\n </div>\n\n {additionalChildrenStart}\n\n {/* ── Live Workspace Overview Strip ── */}\n {!searchQuery && (\n <div className=\"mt-4 mb-8\">\n <Typography\n variant=\"micro\"\n component=\"h2\"\n color=\"secondary\"\n className=\"py-1 mb-3 block\"\n >\n {t(\"studio_home_overview\")}\n </Typography>\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3.5\">\n <Card className=\"p-4 flex flex-col justify-between gap-2.5\">\n <div className=\"flex items-center justify-between\">\n <Typography variant=\"micro\" color=\"secondary\">{t(\"studio_home_backend_runtime\")}</Typography>\n <StatusDot tone=\"ok\" size=\"small\">{t(\"studio_home_online\")}</StatusDot>\n </div>\n <Typography variant=\"h5\" className=\"font-semibold tracking-tight\">\n REST · WS · MCP\n </Typography>\n <Typography variant=\"mono\" color=\"secondary\" className=\"text-xs truncate\">\n {apiHostLabel}\n </Typography>\n </Card>\n\n <Card className=\"p-4 flex flex-col justify-between gap-2.5\">\n <div className=\"flex items-center justify-between\">\n <Typography variant=\"micro\" color=\"secondary\">{t(\"studio_home_postgres_schema\")}</Typography>\n <Typography variant=\"mono\" color=\"secondary\" className=\"text-xs\">public</Typography>\n </div>\n <Typography variant=\"h4\" className=\"font-mono tabular-nums font-semibold\">\n {tableCount > 0 ? tableCount : \"—\"}\n <span className=\"text-sm font-sans font-normal text-text-secondary dark:text-text-secondary-dark ml-1.5\">\n {t(\"studio_home_tables_unit\", { count: tableCount })}\n </span>\n </Typography>\n <Typography variant=\"mono\" color=\"secondary\" className=\"text-xs flex items-center gap-3\">\n <span>{t(\"studio_home_cols\")} <strong className=\"text-text-primary dark:text-text-primary-dark font-medium\">{schemaStats ? schemaStats.columns : \"—\"}</strong></span>\n <span>{t(\"studio_home_rels\")} <strong className=\"text-text-primary dark:text-text-primary-dark font-medium\">{schemaStats ? schemaStats.relations : \"—\"}</strong></span>\n </Typography>\n </Card>\n\n <Card className=\"p-4 flex flex-col justify-between gap-2.5\">\n <div className=\"flex items-center justify-between\">\n <Typography variant=\"micro\" color=\"secondary\">{t(\"studio_home_security_rls\")}</Typography>\n <StatusDot tone={schemaStats && schemaStats.rlsProtected < schemaStats.tables ? \"busy\" : \"ok\"} size=\"small\">\n {schemaStats ? t(\"studio_home_enforced\", { protected: schemaStats.rlsProtected, total: schemaStats.tables }) : t(\"studio_api_keys_status_active\")}\n </StatusDot>\n </div>\n <Typography variant=\"h4\" className=\"font-mono tabular-nums font-semibold\">\n {schemaStats && schemaStats.tables > 0\n ? `${Math.round((schemaStats.rlsProtected / schemaStats.tables) * 100)}%`\n : \"RLS\"}\n <span className=\"text-sm font-sans font-normal text-text-secondary dark:text-text-secondary-dark ml-1.5\">\n {t(\"studio_home_protected\")}\n </span>\n </Typography>\n <Typography variant=\"mono\" color=\"secondary\" className=\"text-xs\">\n {t(\"studio_home_default_deny\")}\n </Typography>\n </Card>\n\n <Card className=\"p-4 flex flex-col justify-between gap-2.5\">\n <div className=\"flex items-center justify-between\">\n <Typography variant=\"micro\" color=\"secondary\">{t(\"studio_home_workbench\")}</Typography>\n <Typography variant=\"mono\" color=\"secondary\" className=\"text-xs\">{t(\"studio_home_groups\", { count: filteredSections.length })}</Typography>\n </div>\n <Typography variant=\"h4\" className=\"font-mono tabular-nums font-semibold\">\n {totalToolsCount}\n <span className=\"text-sm font-sans font-normal text-text-secondary dark:text-text-secondary-dark ml-1.5\">\n {t(\"studio_home_tools_unit\")}\n </span>\n </Typography>\n <Typography variant=\"mono\" color=\"secondary\" className=\"text-xs truncate\">\n {schemaStats && schemaStats.tableNames.length > 0\n ? schemaStats.tableNames.slice(0, 4).join(\" · \")\n : \"SQL · RLS · STORAGE · API\"}\n </Typography>\n </Card>\n </div>\n </div>\n )}\n\n {/* ── Tool sections ── */}\n {filteredSections.map((section) => {\n const sectionCollapsed = isGroupCollapsed(section.label);\n\n return (\n <div key={section.label} className=\"my-8\">\n <ExpandablePanel\n invisible\n expanded={!sectionCollapsed}\n onExpandedChange={(open) => {\n if (open !== !sectionCollapsed) {\n toggleGroupCollapsed(section.label);\n }\n }}\n className=\"mt-4\"\n titleClassName={cls(\n \"min-h-0 p-0 px-3 -mx-3 w-auto border-none\",\n \"rounded flex items-center justify-between w-full\",\n \"hover:bg-transparent\",\n \"cursor-pointer select-none\",\n sectionCollapsed && \"bg-surface-field\"\n )}\n innerClassName=\"mt-3 pt-0\"\n title={\n <Typography\n variant=\"micro\"\n component=\"h2\"\n color=\"secondary\"\n className=\"py-1 rounded\"\n >\n {groupLabel(section.label)}\n </Typography>\n }\n >\n <div className=\"mt-3 pt-0\">\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3.5\">\n {section.tools.map((tool) => {\n const staticReadout = TOOL_READOUTS[tool.path];\n const dynamicValue =\n tool.path === \"/s/tables\" && schemaStats\n ? `${schemaStats.tables} TABLES · ${schemaStats.columns} COLS`\n : tool.path === \"/s/rls\" && schemaStats\n ? `${schemaStats.rlsProtected}/${schemaStats.tables} PROTECTED`\n : tool.path === \"/s/schema\" && schemaStats\n ? `${schemaStats.tables} NODES · ${schemaStats.relations} EDGES`\n : staticReadout?.value;\n\n return (\n <Card\n key={tool.path}\n onClick={() => {\n navigate(tool.path);\n context.analyticsController?.onAnalyticsEvent?.(\n \"home_navigate_to_view\",\n { path: tool.path }\n );\n }}\n className={cls(\n \"group h-full p-4 cursor-pointer transition-colors duration-150 ease-in-out\",\n \"hover:bg-surface-card-hover\"\n )}\n >\n <div className=\"flex items-start gap-3.5 h-full\">\n {/* 36x36 raised icon well */}\n <div 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\">\n <IconForView\n collectionOrView={{ slug: tool.path, name: tool.name, icon: tool.icon }}\n size=\"small\"\n />\n </div>\n\n <div className=\"flex flex-col min-w-0 flex-1 h-full\">\n <div className=\"flex items-center justify-between gap-2\">\n <Typography variant=\"subtitle1\" component=\"h2\" className=\"truncate\">\n {tool.name}\n </Typography>\n <ArrowRightIcon\n size={14}\n 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\"\n />\n </div>\n\n {tool.description && (\n <Typography variant=\"caption\" color=\"secondary\" component=\"div\" className=\"mt-0.5 line-clamp-2\">\n {tool.description}\n </Typography>\n )}\n\n <div className=\"grow\"/>\n\n {dynamicValue && (\n <div className=\"mt-3 pt-2.5 border-t border-hairline flex items-center justify-between gap-2\">\n <Typography variant=\"micro\" color=\"disabled\">\n {staticReadout?.label ?? \"MODULE\"}\n </Typography>\n <Typography variant=\"mono\" color=\"secondary\" className=\"text-xs truncate\">\n {dynamicValue}\n </Typography>\n </div>\n )}\n </div>\n </div>\n </Card>\n );\n })}\n </div>\n </div>\n </ExpandablePanel>\n </div>\n );\n })}\n\n {/* ── SDK Quick Start ── */}\n <div className=\"mt-10 mb-6\">\n <div className=\"flex items-center mb-1\">\n <Typography\n variant=\"micro\"\n component=\"h2\"\n color=\"secondary\"\n className=\"py-1 rounded\"\n >\n {t(\"studio_home_quick_start\")}\n </Typography>\n </div>\n\n {/* `rebase dev` writes the typed SDK to generated/sdk on every\n schema change, so a scaffold never needs to run the\n generator by hand; `generate-sdk` is for outside dev. */}\n <Typography variant=\"body2\" color=\"secondary\" className=\"mb-4 max-w-2xl\">\n {t(\"studio_home_quick_start_dev\")}{\" \"}\n <code className=\"text-emerald-400 font-mono text-xs bg-emerald-400/10 px-1.5 py-0.5 rounded\">\n rebase dev\n </code>\n {\". \"}\n {t(\"studio_home_quick_start_outside_dev\")}{\" \"}\n <code className=\"text-emerald-400 font-mono text-xs bg-emerald-400/10 px-1.5 py-0.5 rounded\">\n rebase generate-sdk\n </code>\n {\".\"}\n </Typography>\n\n <div className=\"rounded-lg border border-hairline bg-surface-card overflow-hidden\">\n {/* Title bar */}\n <div className=\"flex items-center justify-between px-4 py-2.5 border-b border-hairline bg-surface-sheet\">\n <div className=\"flex items-center gap-2.5\">\n <div className=\"flex gap-1.5\">\n <span className=\"w-2.5 h-2.5 rounded-full bg-red-400/60\"/>\n <span className=\"w-2.5 h-2.5 rounded-full bg-amber-400/60\"/>\n <span className=\"w-2.5 h-2.5 rounded-full bg-emerald-400/60\"/>\n </div>\n <span className=\"text-xs font-mono text-surface-400 dark:text-surface-500 ml-1\">\n app.ts\n </span>\n </div>\n <span className=\"text-xs font-mono text-surface-400 dark:text-surface-500\">\n TypeScript\n </span>\n </div>\n\n {/* Syntax-highlighted code */}\n <div className=\"px-5 py-4 overflow-x-auto text-[13px] leading-6 font-mono\">\n <SyntaxHighlightedSnippet baseUrl={apiUrl}/>\n </div>\n </div>\n </div>\n\n {/* ── Extra sections from props ── */}\n {sections?.map((s) => (\n <div key={s.key} className=\"my-10\">\n <Typography\n variant=\"micro\"\n component=\"h2\"\n color=\"secondary\"\n className=\"py-1 rounded\"\n >\n {s.title}\n </Typography>\n <div className=\"mt-4\">{s.children}</div>\n </div>\n ))}\n\n {additionalChildrenEnd}\n </Container>\n </div>\n );\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Hand-crafted syntax-highlighted code snippet.\n Uses inline spans with Tailwind color classes to avoid\n pulling in a syntax highlighting library.\n ═══════════════════════════════════════════════════════════════ */\n\n/**\n * The address the panel's API answers on, as a script would write it: absolute\n * (a same-origin panel is configured with a relative one) and without a\n * trailing slash. It is what `baseUrl` takes — the API's path is the client's.\n */\n/** How many entries a descriptor's list holds: an array's length, or an object's keys. */\nfunction countOf(value: unknown): number {\n if (Array.isArray(value)) return value.length;\n return isRecord(value) ? Object.keys(value).length : 0;\n}\n\nfunction absoluteApiUrl(apiUrl: string | undefined): string {\n const page = typeof window !== \"undefined\" ? window.location.href : undefined;\n try {\n return new URL(apiUrl || \"/\", page).href.replace(/\\/+$/, \"\");\n } catch {\n return apiUrl ?? \"\";\n }\n}\n\n/** The quick-start client, pointed at `baseUrl`. */\nfunction SyntaxHighlightedSnippet({ baseUrl }: { baseUrl: string }) {\n const kw = \"text-violet-600 dark:text-violet-400\"; // keywords\n const str = \"text-emerald-600 dark:text-emerald-400\"; // strings\n const typ = \"text-amber-600 dark:text-amber-300\"; // types\n const fn = \"text-blue-600 dark:text-blue-400\"; // functions\n const cm = \"text-surface-500 dark:text-surface-400 italic\"; // comments\n const op = \"text-surface-500 dark:text-surface-400\"; // operators / punctuation\n const tx = \"text-surface-950 dark:text-surface-200\"; // plain text\n\n return (\n <pre className=\"m-0 whitespace-pre\">\n <span className={kw}>import</span>\n <span className={tx}>{\" { \"}</span>\n <span className={fn}>createRebaseClient</span>\n <span className={tx}>{\" } \"}</span>\n <span className={kw}>from</span>\n <span className={tx}> </span>\n <span className={str}>'@rebasepro/client'</span>\n <span className={op}>;</span>\n {\"\\n\"}\n\n <span className={kw}>import</span>\n <span className={tx}>{\" { tablesDictionary, \"}</span>\n <span className={kw}>type</span>\n <span className={tx}> </span>\n <span className={typ}>Database</span>\n <span className={tx}>{\" } \"}</span>\n <span className={kw}>from</span>\n <span className={tx}> </span>\n {/* A script in the project root; scripts/example.ts, one level\n down, imports \"../generated/sdk/database.types\". */}\n <span className={str}>'./generated/sdk/database.types'</span>\n <span className={op}>;</span>\n {\"\\n\\n\"}\n\n <span className={kw}>const</span>\n <span className={tx}> rebase </span>\n <span className={op}>= </span>\n <span className={fn}>createRebaseClient</span>\n <span className={op}>{\"<\"}</span>\n <span className={typ}>Database</span>\n <span className={op}>{\">(\"}</span>\n <span className={tx}>{\"{\"}</span>\n {\"\\n\"}\n <span className={tx}>{\" baseUrl\"}</span>\n <span className={op}>: </span>\n <span className={str}>'{baseUrl}'</span>\n <span className={op}>,</span>\n {\"\\n\"}\n {/* Maps each accessor back to its slug: without it a hyphenated\n slug is not reachable from the property name, and the copied\n client 404s on that table. */}\n <span className={tx}>{\" tables\"}</span>\n <span className={op}>: </span>\n <span className={tx}>tablesDictionary</span>\n <span className={op}>,</span>\n {\"\\n\"}\n <span className={tx}>{\"}\"}</span>\n <span className={op}>);</span>\n {\"\\n\\n\"}\n\n <span className={cm}>{\"// Every table is a typed property: rebase.data.<table>\"}</span>\n {\"\\n\"}\n <span className={kw}>const</span>\n <span className={tx}>{\" { \"}</span>\n <span className={tx}>data</span>\n <span className={op}>: </span>\n <span className={tx}>users</span>\n <span className={tx}>{\" } \"}</span>\n <span className={op}>= </span>\n <span className={kw}>await</span>\n <span className={tx}> rebase</span>\n <span className={op}>.</span>\n <span className={tx}>data</span>\n <span className={op}>.</span>\n <span className={tx}>users</span>\n <span className={op}>.</span>\n <span className={fn}>find</span>\n <span className={op}>();</span>\n {\"\\n\"}\n\n <span className={kw}>const</span>\n <span className={tx}>{\" { \"}</span>\n <span className={tx}>data</span>\n <span className={op}>: </span>\n <span className={tx}>admins</span>\n <span className={tx}>{\" } \"}</span>\n <span className={op}>= </span>\n <span className={kw}>await</span>\n <span className={tx}> rebase</span>\n <span className={op}>.</span>\n <span className={tx}>data</span>\n <span className={op}>.</span>\n <span className={tx}>users</span>\n {\"\\n\"}\n <span className={tx}>{\" \"}</span>\n <span className={op}>.</span>\n <span className={fn}>where</span>\n <span className={op}>(</span>\n <span className={str}>'roles'</span>\n <span className={op}>, </span>\n <span className={str}>'array-contains'</span>\n <span className={op}>, </span>\n <span className={str}>'admin'</span>\n <span className={op}>)</span>\n {\"\\n\"}\n <span className={tx}>{\" \"}</span>\n <span className={op}>.</span>\n <span className={fn}>find</span>\n <span className={op}>();</span>\n </pre>\n );\n}\n","import React, { Suspense, useLayoutEffect, useMemo } from \"react\";\nimport { useRebaseEmbedHost, useRebaseRegistryDispatch, useTranslation, type AppView, type RebaseStudioConfig } from \"@rebasepro/app\";\nimport { CircularProgressCenter, lazyChunk } from \"@rebasepro/ui\";\n\n// Lazy-loaded studio tools — each fetched only when its route is visited.\n// This keeps Monaco, @xyflow/react, dagre, pgsql-ast-parser etc. out of the initial bundle.\nconst TableEditorView = lazyChunk(() => import(\"./TableEditor/TableEditorView\").then(m => ({ default: m.TableEditorView })));\nconst SQLEditor = lazyChunk(() => import(\"./SQLEditor/SQLEditor\").then(m => ({ default: m.SQLEditor })));\nconst JSEditor = lazyChunk(() => import(\"./JSEditor/JSEditor\").then(m => ({ default: m.JSEditor })));\nconst RLSEditor = lazyChunk(() => import(\"./RLSEditor/RLSEditor\").then(m => ({ default: m.RLSEditor })));\nconst StorageView = lazyChunk(() => import(\"./StorageView/StorageView\").then(m => ({ default: m.StorageView })));\nconst CronJobsView = lazyChunk(() => import(\"./CronJobs/CronJobsView\").then(m => ({ default: m.CronJobsView })));\nconst SchemaVisualizer = lazyChunk(() => import(\"./SchemaVisualizer/SchemaVisualizer\").then(m => ({ default: m.SchemaVisualizer })));\nconst BranchesView = lazyChunk(() => import(\"./Branches/BranchesView\").then(m => ({ default: m.BranchesView })));\nconst BackupsView = lazyChunk(() => import(\"./Backups/BackupsView\").then(m => ({ default: m.BackupsView })));\nconst ApiExplorer = lazyChunk(() => import(\"./ApiExplorer/ApiExplorer\").then(m => ({ default: m.ApiExplorer })));\nconst WebhooksView = lazyChunk(() => import(\"./Webhooks/WebhooksView\").then(m => ({ default: m.WebhooksView })));\nconst LogsExplorer = lazyChunk(() => import(\"./LogsExplorer/LogsExplorer\").then(m => ({ default: m.LogsExplorer })));\nconst UsersAndRolesView = lazyChunk(() => import(\"./UsersAndRoles/UsersAndRolesView\").then(m => ({ default: m.UsersAndRolesView })));\nconst ApiKeysView = lazyChunk(() => import(\"./ApiKeys/ApiKeysView\").then(m => ({ default: m.ApiKeysView })));\n\nimport { StudioHomePage } from \"./StudioHomePage\";\n\n/**\n * Declarative component to configure the Studio in Rebase.\n * Renders nothing — purely registers config into the RebaseRegistry.\n */\nconst DEFAULT_HOME_PAGE = <StudioHomePage/>;\n\n/**\n * Studio: the developer tools, registered beside the admin.\n *\n * Not in an embedding (an MCP App view, `embed_host.ts` in `@rebasepro/app`):\n * there the app is shown to the person it runs as, and Studio's tools change\n * the project.\n */\nexport function RebaseStudio(props: RebaseStudioConfig) {\n const embed = useRebaseEmbedHost();\n return embed ? null : <RebaseStudioRegistration {...props}/>;\n}\n\nfunction RebaseStudioRegistration({ tools, homePage, devViews: extraViews }: RebaseStudioConfig) {\n const dispatch = useRebaseRegistryDispatch();\n const { t, i18n } = useTranslation();\n\n const resolvedHomePage = homePage ?? DEFAULT_HOME_PAGE;\n\n /**\n * The tool list reduced to a value, so that re-rendering the host does not\n * republish the registry.\n *\n * `tools` is an array, and callers write it inline — `tools={[...TOOLS]}`\n * in the hosted console. A fresh array every render meant a fresh\n * `devViews` every render, which meant the effect below unregistered and\n * re-registered on every render. Because each registration builds *new*\n * `<Suspense><SQLEditor/></Suspense>` elements, whatever view was on screen\n * was torn down and remounted each time: a half-typed SQL query, a storage\n * folder you had navigated into, an open policy editor — all discarded, and\n * every mount reissued the view's initial requests.\n */\n const toolsKey = tools ? tools.join(\",\") : \"\";\n\n const devViews: AppView[] = useMemo(() => {\n const views: AppView[] = [];\n const activeTools = tools ?? [\"tables\", \"sql\", \"js\", \"rls\", \"storage\", \"cron\", \"schema-visualizer\", \"branches\", \"backups\", \"api\", \"webhooks\", \"logs\", \"users\", \"api-keys\"];\n const suspense = (el: React.ReactNode) => <Suspense fallback={<CircularProgressCenter/>}>{el}</Suspense>;\n\n if (activeTools.includes(\"tables\")) {\n views.push({ slug: \"tables\",\nname: t(\"studio_tool_tables\"),\ngroup: \"Database\",\nicon: \"Table\",\ndescription: t(\"studio_tool_tables_description\"),\nview: suspense(<TableEditorView/>) });\n }\n if (activeTools.includes(\"sql\")) {\n views.push({ slug: \"sql\",\nname: t(\"studio_tool_sql\"),\ngroup: \"Database\",\nicon: \"terminal\",\ndescription: t(\"studio_tool_sql_description\"),\nview: suspense(<SQLEditor/>) });\n }\n if (activeTools.includes(\"js\")) {\n views.push({ slug: \"js\",\nname: t(\"studio_tool_js\"),\ngroup: \"Compute\",\nicon: \"code\",\ndescription: t(\"studio_tool_js_description\"),\nview: suspense(<JSEditor/>) });\n }\n if (activeTools.includes(\"rls\")) {\n views.push({ slug: \"rls\",\nname: t(\"studio_tool_rls\"),\ngroup: \"Database\",\nicon: \"ShieldCheck\",\ndescription: t(\"studio_tool_rls_description\"),\nview: suspense(<RLSEditor/>) });\n }\n if (activeTools.includes(\"storage\")) {\n views.push({ slug: \"storage\",\nname: t(\"studio_tool_storage\"),\ngroup: \"Storage\",\nicon: \"HardDrive\",\ndescription: t(\"studio_tool_storage_description\"),\nview: suspense(<StorageView/>) });\n }\n if (activeTools.includes(\"cron\")) {\n views.push({ slug: \"cron\",\nname: t(\"studio_tool_cron\"),\ngroup: \"Compute\",\nicon: \"Clock\",\ndescription: t(\"studio_tool_cron_description\"),\nview: suspense(<CronJobsView/>) });\n }\n if (activeTools.includes(\"schema-visualizer\")) {\n views.push({ slug: \"schema-visualizer\",\nname: t(\"studio_tool_schema_visualizer\"),\ngroup: \"Database\",\nicon: \"Network\",\ndescription: t(\"studio_tool_schema_visualizer_description\"),\nview: suspense(<SchemaVisualizer/>) });\n }\n if (activeTools.includes(\"branches\")) {\n views.push({ slug: \"branches\",\nname: t(\"studio_tool_branches\"),\ngroup: \"Database\",\nicon: \"GitBranch\",\ndescription: t(\"studio_tool_branches_description\"),\nview: suspense(<BranchesView/>) });\n }\n if (activeTools.includes(\"backups\")) {\n views.push({ slug: \"backups\",\nname: t(\"studio_tool_backups\"),\ngroup: \"Database\",\nicon: \"Database\",\ndescription: t(\"studio_tool_backups_description\"),\nview: suspense(<BackupsView/>) });\n }\n if (activeTools.includes(\"api\")) {\n views.push({ slug: \"api\",\nname: t(\"studio_tool_api\"),\ngroup: \"API\",\nicon: \"BookOpen\",\ndescription: t(\"studio_tool_api_description\"),\nview: suspense(<ApiExplorer/>) });\n }\n if (activeTools.includes(\"webhooks\")) {\n views.push({ slug: \"webhooks\",\nname: t(\"studio_tool_webhooks\"),\ngroup: \"API\",\nicon: \"Webhook\",\ndescription: t(\"studio_tool_webhooks_description\"),\nview: suspense(<WebhooksView/>) });\n }\n // Filed under API, not Database: the server's log carries every source\n // it serves (api, auth, storage, realtime, system), not only queries.\n if (activeTools.includes(\"logs\")) {\n views.push({ slug: \"logs\",\nname: t(\"studio_tool_logs\"),\ngroup: \"API\",\nicon: \"Activity\",\ndescription: t(\"studio_tool_logs_description\"),\nview: suspense(<LogsExplorer/>) });\n }\n if (activeTools.includes(\"users\")) {\n views.push({ slug: \"users\",\nname: t(\"studio_tool_users\"),\ngroup: \"Access Control\",\nicon: \"Users\",\ndescription: t(\"studio_tool_users_description\"),\nview: suspense(<UsersAndRolesView/>) });\n }\n if (activeTools.includes(\"api-keys\")) {\n views.push({ slug: \"api-keys\",\nname: t(\"studio_tool_api_keys\"),\ngroup: \"Access Control\",\nicon: \"KeyRound\",\ndescription: t(\"studio_tool_api_keys_description\"),\nview: suspense(<ApiKeysView/>) });\n }\n // It is NOT registered here anymore.\n return views;\n // Keyed by the tool list's *contents*; see `toolsKey`. `tools` itself is\n // read inside, and is exactly determined by the key.\n // The strings are now translated, so the active language is part of\n // what this list is.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [toolsKey, t, i18n.language]);\n\n /**\n * Your own tools, keyed the same way `tools` is and for the same reason:\n * callers write `devViews={[…]}` inline, so the array is new on every\n * render. Re-registering would tear down and remount whichever Studio view\n * was on screen — a half-typed SQL query, an open policy editor.\n *\n * The key is the identity of each view, not its element: a view's `view` is\n * resolved by the router at render time, so a fresh element for the same\n * slug is not a configuration change.\n */\n const extraViewsKey = (extraViews ?? [])\n .map((v) => `${v.slug}|${v.name}|${v.group ?? \"\"}|${v.hideFromNavigation ?? false}`)\n .join(\",\");\n const extraViewsRef = React.useRef(extraViews);\n extraViewsRef.current = extraViews;\n\n const allDevViews: AppView[] = useMemo(\n () => [...devViews, ...(extraViewsRef.current ?? [])],\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [devViews, extraViewsKey]\n );\n\n // Use a ref for homePage so it never destabilizes the effect.\n // homePage is a React element — its identity doesn't matter for registration.\n const homePageRef = React.useRef(resolvedHomePage);\n homePageRef.current = resolvedHomePage;\n\n // Same reasoning for `tools`: it is registered as config, but a new array\n // with the same contents must not count as a change.\n const toolsRef = React.useRef(tools);\n toolsRef.current = tools;\n\n useLayoutEffect(() => {\n dispatch.registerStudio({ tools: toolsRef.current,\nhomePage: homePageRef.current,\ndevViews: allDevViews });\n return () => dispatch.unregisterStudio();\n }, [dispatch, allDevViews]);\n\n return null;\n}\n","import React, { useMemo, useState } from \"react\";\nimport { BrowserRouter, Navigate, Route, Routes, useLocation, useNavigate } from \"react-router\";\nimport { createRebaseClient, type CreateRebaseClientResult } from \"@rebasepro/client\";\nimport {\n IconForView,\n Rebase,\n useModeController,\n useNavigationGroupLabel,\n useRebaseAuthController,\n useRebaseRegistry,\n useTranslation,\n type RebaseAuthController,\n type RebaseStudioConfig\n} from \"@rebasepro/app\";\nimport {\n Alert,\n Button,\n Card,\n CircularProgressCenter,\n cls,\n defaultBorderMixin,\n HomeIcon,\n IconButton,\n iconSize,\n LogOutIcon,\n MoonIcon,\n SunIcon,\n TextField,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { RebaseStudio } from \"./RebaseStudio\";\nimport { STUDIO_GROUP_ORDER, StudioHomePage } from \"./StudioHomePage\";\n\nexport interface RebaseStudioAppProps {\n /** Base URL of the Rebase API (e.g. `\"\"` for same-origin, or `\"http://localhost:3000\"`). */\n apiUrl?: string;\n /** Optional pre-created RebaseClient instance. */\n client?: CreateRebaseClientResult<Record<string, unknown>>;\n /** Router basename when mounted under a sub-path (e.g. `\"/_studio\"`). */\n basename?: string;\n /** Display name shown in the Studio header. */\n name?: string;\n /** Restrict the built-in Studio tools shown in the sidebar. */\n tools?: RebaseStudioConfig[\"tools\"];\n /** Custom views added alongside the built-in Studio tools. */\n devViews?: RebaseStudioConfig[\"devViews\"];\n /** When true, do not wrap in a `<BrowserRouter>` (caller already provides one). */\n withoutRouter?: boolean;\n}\n\nconst GROUP_ORDER = STUDIO_GROUP_ORDER;\n\nfunction StudioSignInScreen({\n name,\n auth\n}: {\n name: string;\n auth: RebaseAuthController;\n}) {\n const { t } = useTranslation();\n const [mode, setMode] = useState<\"signin\" | \"register\">(auth.needsSetup ? \"register\" : \"signin\");\n const [email, setEmail] = useState(\"\");\n const [password, setPassword] = useState(\"\");\n const [displayName, setDisplayName] = useState(\"\");\n const [submitting, setSubmitting] = useState(false);\n const [localError, setLocalError] = useState<string | null>(null);\n\n const isRegister = auth.needsSetup || mode === \"register\";\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setLocalError(null);\n setSubmitting(true);\n try {\n if (isRegister) {\n await auth.register(email.trim(), password, displayName.trim() || undefined);\n } else {\n await auth.emailPasswordLogin(email.trim(), password);\n }\n } catch (err: unknown) {\n setLocalError(err instanceof Error ? err.message : t(\"studio_app_auth_failed\"));\n } finally {\n setSubmitting(false);\n }\n };\n\n const errorMessage = localError ?? auth.authProviderError?.message ?? null;\n\n return (\n <div className=\"min-h-screen w-full flex items-center justify-center bg-surface-frame p-6\">\n <Card className=\"w-full max-w-md p-6 flex flex-col gap-5\">\n <div className=\"flex flex-col gap-1\">\n <Typography variant=\"h5\" className=\"font-semibold\">\n {name}\n </Typography>\n <Typography variant=\"body2\" color=\"secondary\">\n {auth.needsSetup\n ? t(\"studio_app_setup_subtitle\")\n : (isRegister ? t(\"studio_app_register_subtitle\") : t(\"studio_app_signin_subtitle\"))}\n </Typography>\n </div>\n\n {errorMessage && <Alert color=\"error\">{errorMessage}</Alert>}\n\n <form onSubmit={(e) => void handleSubmit(e)} className=\"flex flex-col gap-3\">\n {isRegister && (\n <TextField\n label={t(\"studio_app_display_name_optional\")}\n value={displayName}\n onChange={(e) => setDisplayName(e.target.value)}\n placeholder=\"Admin\"\n />\n )}\n <TextField\n label={t(\"email\")}\n type=\"email\"\n value={email}\n onChange={(e) => setEmail(e.target.value)}\n placeholder=\"admin@example.com\"\n required\n />\n <TextField\n label={t(\"auth_password\")}\n type=\"password\"\n value={password}\n onChange={(e) => setPassword(e.target.value)}\n required\n />\n <Button\n type=\"submit\"\n variant=\"filled\"\n disabled={submitting || !email.trim() || !password}\n className=\"mt-1\"\n >\n {submitting\n ? t(\"studio_app_please_wait\")\n : (auth.needsSetup ? t(\"studio_app_create_admin\") : (isRegister ? t(\"studio_app_create_account\") : t(\"auth_sign_in\")))}\n </Button>\n </form>\n\n {!auth.needsSetup && auth.registrationEnabled && (\n <div className=\"flex justify-center\">\n <Button\n size=\"small\"\n variant=\"text\"\n onClick={() => setMode((m) => m === \"signin\" ? \"register\" : \"signin\")}\n >\n {isRegister ? t(\"studio_app_have_account\") : t(\"studio_app_need_account\")}\n </Button>\n </div>\n )}\n </Card>\n </div>\n );\n}\n\nfunction StudioStandaloneShell({\n name,\n auth\n}: {\n name: string;\n auth: RebaseAuthController;\n}) {\n const registry = useRebaseRegistry();\n const navigate = useNavigate();\n const location = useLocation();\n const modeController = useModeController();\n const labelGroup = useNavigationGroupLabel();\n const { t } = useTranslation();\n\n const views = useMemo(\n () => (registry.studioConfig?.devViews ?? []).filter((v) => !v.hideFromNavigation),\n [registry.studioConfig?.devViews]\n );\n\n const groupedViews = useMemo(() => {\n const map = new Map<string, typeof views>();\n for (const v of views) {\n const g = v.group || \"Tools\";\n const arr = map.get(g) ?? [];\n arr.push(v);\n map.set(g, arr);\n }\n const ordered: Array<{ group: string; items: typeof views }> = [];\n for (const g of GROUP_ORDER) {\n const items = map.get(g);\n if (items && items.length > 0) {\n ordered.push({ group: g, items });\n map.delete(g);\n }\n }\n for (const [g, items] of map.entries()) {\n ordered.push({ group: g, items });\n }\n return ordered;\n }, [views]);\n\n if (auth.initialLoading) {\n return <CircularProgressCenter />;\n }\n\n if (!auth.user && !auth.loginSkipped) {\n return <StudioSignInScreen name={name} auth={auth} />;\n }\n\n const currentSlug = location.pathname.replace(/^\\/+/, \"\").split(\"/\")[0] || \"\";\n const isDark = modeController.mode === \"dark\";\n\n return (\n <div className=\"flex h-screen w-screen overflow-hidden bg-surface-frame text-text-primary dark:text-text-primary-dark\">\n {/* Standalone Studio Sidebar */}\n <aside className={cls(\"w-60 shrink-0 flex flex-col border-r bg-surface-frame\", defaultBorderMixin)}>\n <div className={cls(\"h-12 px-4 border-b flex items-center justify-between gap-2 shrink-0\", defaultBorderMixin)}>\n <button\n type=\"button\"\n onClick={() => navigate(\"/\")}\n className=\"flex items-center gap-2 min-w-0 text-left\"\n >\n <Typography variant=\"subtitle1\" className=\"font-semibold truncate\">\n {name}\n </Typography>\n </button>\n <Tooltip title={isDark ? t(\"studio_app_light_mode\") : t(\"studio_app_dark_mode\")}>\n <IconButton\n size=\"small\"\n aria-label={t(\"toggle_theme\")}\n onClick={() => modeController.setMode(isDark ? \"light\" : \"dark\")}\n >\n {isDark ? <SunIcon size={iconSize.small} /> : <MoonIcon size={iconSize.small} />}\n </IconButton>\n </Tooltip>\n </div>\n\n <nav className=\"flex-1 overflow-y-auto p-2 flex flex-col gap-3\">\n <button\n type=\"button\"\n onClick={() => navigate(\"/\")}\n className={cls(\n \"w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-[13px] transition-colors\",\n currentSlug === \"\"\n ? \"bg-surface-active text-text-primary dark:text-text-primary-dark font-medium\"\n : \"text-text-secondary dark:text-text-secondary-dark hover:bg-surface-hover hover:text-text-primary dark:hover:text-text-primary-dark\"\n )}\n >\n <HomeIcon size={iconSize.small} />\n <span>{t(\"home\")}</span>\n </button>\n\n {groupedViews.map(({ group, items }) => (\n <div key={group} className=\"flex flex-col gap-0.5\">\n <Typography\n variant=\"caption\"\n color=\"secondary\"\n className=\"px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wider\"\n >\n {labelGroup(group)}\n </Typography>\n {items.map((view) => {\n const active = currentSlug === view.slug;\n return (\n <button\n key={view.slug}\n type=\"button\"\n onClick={() => navigate(`/${view.slug}`)}\n className={cls(\n \"w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-[13px] transition-colors text-left\",\n active\n ? \"bg-surface-active text-text-primary dark:text-text-primary-dark font-medium\"\n : \"text-text-secondary dark:text-text-secondary-dark hover:bg-surface-hover hover:text-text-primary dark:hover:text-text-primary-dark\"\n )}\n >\n <IconForView collectionOrView={view} className=\"w-4 h-4 shrink-0\" />\n <span className=\"truncate\">{view.name}</span>\n </button>\n );\n })}\n </div>\n ))}\n </nav>\n\n {auth.user && (\n <div className={cls(\"p-3 border-t flex items-center justify-between gap-2 shrink-0\", defaultBorderMixin)}>\n <div className=\"min-w-0\">\n <Typography variant=\"caption\" className=\"block truncate font-medium\">\n {auth.user.displayName || auth.user.email || auth.user.uid}\n </Typography>\n {auth.user.email && (\n <Typography variant=\"caption\" color=\"secondary\" className=\"block truncate text-[11px]\">\n {auth.user.email}\n </Typography>\n )}\n </div>\n <Tooltip title={t(\"studio_app_sign_out\")}>\n <IconButton size=\"small\" aria-label={t(\"studio_app_sign_out\")} onClick={() => void auth.signOut()}>\n <LogOutIcon size={iconSize.small} />\n </IconButton>\n </Tooltip>\n </div>\n )}\n </aside>\n\n {/* Active Studio Tool Content */}\n <div className=\"flex-1 min-w-0 h-full overflow-hidden bg-surface-sheet\">\n <Routes>\n <Route path=\"/\" element={registry.studioConfig?.homePage ?? <StudioHomePage />} />\n {views.map((view) => {\n const ViewEl = view.view;\n const element = typeof ViewEl === \"function\" ? <ViewEl /> : ViewEl;\n return <Route key={view.slug} path={`/${view.slug}/*`} element={element} />;\n })}\n <Route path=\"*\" element={<Navigate to=\"/\" replace />} />\n </Routes>\n </div>\n </div>\n );\n}\n\n/**\n * Standalone Rebase Studio application shell.\n *\n * Mounts the full developer & zero-code BaaS console (Tables, SQL, RLS,\n * Schema Visualizer, Storage & Policies, Users & Roles, Webhooks, Cron,\n * API Explorer, Logs, Branches, Backups, API Keys) with ZERO dependency on\n * `@rebasepro/cms`.\n */\nexport function RebaseStudioApp({\n apiUrl,\n client: providedClient,\n basename,\n name = \"Rebase Studio\",\n tools,\n devViews,\n withoutRouter = false\n}: RebaseStudioAppProps) {\n const resolvedBaseUrl = useMemo(() => {\n if (apiUrl !== undefined) return apiUrl;\n if (typeof window !== \"undefined\") return window.location.origin;\n return \"\";\n }, [apiUrl]);\n\n const client = useMemo(\n () => providedClient ?? createRebaseClient({ baseUrl: resolvedBaseUrl }),\n [providedClient, resolvedBaseUrl]\n );\n\n const authController = useRebaseAuthController({ client });\n\n const content = (\n <Rebase\n client={client}\n authController={authController}\n apiUrl={resolvedBaseUrl}\n >\n <RebaseStudio tools={tools} devViews={devViews} />\n <StudioStandaloneShell name={name} auth={authController} />\n </Rebase>\n );\n\n if (withoutRouter) return content;\n\n return (\n <BrowserRouter basename={basename}>\n {content}\n </BrowserRouter>\n );\n}\n"],"mappings":";;;;;;;;AAgBA,IAAM,gBAAkE;CACpE,aAAa;EAAE,OAAO;EAAU,OAAO;CAAuB;CAC9D,UAAU;EAAE,OAAO;EAAS,OAAO;CAAgB;CACnD,UAAU;EAAE,OAAO;EAAU,OAAO;CAAuB;CAC3D,aAAa;EAAE,OAAO;EAAS,OAAO;CAAkB;CACxD,eAAe;EAAE,OAAO;EAAU,OAAO;CAAgB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YAAY,oBAAC,gBAAD,CAAiB,CAAA;IAAI,CAAA;IAChF,MAAM,KAAK,SAAS;KACjB,MAAM,SAAS,KAAK;KACpB,MAAM,UAAU,OAAO,WAAW,aAAa,oBAAC,QAAD,CAAS,CAAA,IAAI;KAC5D,OAAO,oBAAC,OAAD;MAAuB,MAAM,IAAI,KAAK,KAAK;MAAc;KAAU,GAAvD,KAAK,IAAkD;IAC9E,CAAC;IACD,oBAAC,OAAD;KAAO,MAAK;KAAI,SAAS,oBAAC,UAAD;MAAU,IAAG;MAAI,SAAA;KAAS,CAAA;IAAI,CAAA;GACnD,EAAA,CAAA;EACP,CAAA,CACJ;;AAEb;;;;;;;;;AAUA,SAAgB,gBAAgB,EAC5B,QACA,QAAQ,gBACR,UACA,OAAO,iBACP,OACA,UACA,gBAAgB,SACK;CACrB,MAAM,kBAAkB,cAAc;EAClC,IAAI,WAAW,KAAA,GAAW,OAAO;EACjC,IAAI,OAAO,WAAW,aAAa,OAAO,OAAO,SAAS;EAC1D,OAAO;CACX,GAAG,CAAC,MAAM,CAAC;CAEX,MAAM,SAAS,cACL,kBAAkB,mBAAmB,EAAE,SAAS,gBAAgB,CAAC,GACvE,CAAC,gBAAgB,eAAe,CACpC;CAEA,MAAM,iBAAiB,wBAAwB,EAAE,OAAO,CAAC;CAEzD,MAAM,UACF,qBAAC,QAAD;EACY;EACQ;EAChB,QAAQ;YAHZ,CAKI,oBAAC,cAAD;GAAqB;GAAiB;EAAW,CAAA,GACjD,oBAAC,uBAAD;GAA6B;GAAM,MAAM;EAAiB,CAAA,CACtD;;CAGZ,IAAI,eAAe,OAAO;CAE1B,OACI,oBAAC,eAAD;EAAyB;YACpB;CACU,CAAA;AAEvB"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { policy } from "@rebasepro/types";
|
|
2
|
+
import { REBASE_USER_ROLE, compilePolicyExpression } from "@rebasepro/common";
|
|
3
|
+
//#region src/components/RLSEditor/policy-presets.ts
|
|
4
|
+
/**
|
|
5
|
+
* What the RLS editor offers before the user types anything: the roles a `TO`
|
|
6
|
+
* list may name, and the ready-made policies.
|
|
7
|
+
*
|
|
8
|
+
* Separated from the component because these are the parts that have to agree
|
|
9
|
+
* with the *server*, not with the UI — and the ways they can silently disagree
|
|
10
|
+
* are the reason this file has tests.
|
|
11
|
+
*/
|
|
12
|
+
var COMMAND_OPTIONS = [
|
|
13
|
+
"ALL",
|
|
14
|
+
"SELECT",
|
|
15
|
+
"INSERT",
|
|
16
|
+
"UPDATE",
|
|
17
|
+
"DELETE"
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* The roles a policy's `TO` list can name when nothing better is known.
|
|
21
|
+
*
|
|
22
|
+
* Not `authenticated` / `anon` / `admin`, which is what this list used to be.
|
|
23
|
+
* The first two are Supabase's role names and Rebase never creates them, so
|
|
24
|
+
* `CREATE POLICY ... TO authenticated` — which is literally what the editor
|
|
25
|
+
* builds and executes — fails with `role "authenticated" does not exist`. The
|
|
26
|
+
* driver's `validatePolicyPgRoles` rejects the same three names in
|
|
27
|
+
* `SecurityRule.pgRoles` and says why: they are another platform's convention,
|
|
28
|
+
* and application roles belong in a condition, not in the `TO` list.
|
|
29
|
+
*
|
|
30
|
+
* `admin` was the more dangerous entry, because it is a plausible *application*
|
|
31
|
+
* role. Had one existed as a database role too, the policy would have been
|
|
32
|
+
* created successfully and then matched nothing at all: requests run as
|
|
33
|
+
* {@link REBASE_USER_ROLE} after a `SET LOCAL ROLE`, and a `TO` list naming a
|
|
34
|
+
* role the request never assumes filters every row without erroring.
|
|
35
|
+
*
|
|
36
|
+
* So: `public` (what the framework's own generator emits) and the role requests
|
|
37
|
+
* actually arrive as. "Signed-in users" and "admins" are not roles here — they
|
|
38
|
+
* are conditions over `rebase.uid()` and `rebase.roles()`, which is what the
|
|
39
|
+
* presets below now compile to.
|
|
40
|
+
*/
|
|
41
|
+
var FALLBACK_ROLE_OPTIONS = ["public", REBASE_USER_ROLE];
|
|
42
|
+
/**
|
|
43
|
+
* The `TO` list the editor offers, given what the database reported and what
|
|
44
|
+
* the policy being edited already targets.
|
|
45
|
+
*
|
|
46
|
+
* Three sources, and each is there for a reason the others do not cover:
|
|
47
|
+
*
|
|
48
|
+
* - {@link FALLBACK_ROLE_OPTIONS} always, because `public` is a **keyword, not
|
|
49
|
+
* a row in `pg_roles`** — `fetchAvailableRoles` cannot return it, so seeding
|
|
50
|
+
* from the live fetch alone would drop the one role every generated policy
|
|
51
|
+
* targets.
|
|
52
|
+
* - the live roles, so an operator's own `app_read` is reachable without
|
|
53
|
+
* hand-editing SQL.
|
|
54
|
+
* - the edited policy's own roles, because a `MultiSelect` silently drops a
|
|
55
|
+
* value with no matching item. That value is the `TO` list of a policy
|
|
56
|
+
* already enforcing something, so opening an unrelated policy for a one-word
|
|
57
|
+
* rename would have quietly rewritten who it applies to.
|
|
58
|
+
*/
|
|
59
|
+
function roleOptionsFor(fetched, policyRoles) {
|
|
60
|
+
return [.../* @__PURE__ */ new Set([
|
|
61
|
+
...FALLBACK_ROLE_OPTIONS,
|
|
62
|
+
...fetched ?? [],
|
|
63
|
+
...policyRoles ?? []
|
|
64
|
+
])];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Preset conditions, compiled by the framework's own policy compiler rather
|
|
68
|
+
* than written out here.
|
|
69
|
+
*
|
|
70
|
+
* `compilePolicyExpression` is the function `db push` generates policies with, so a
|
|
71
|
+
* preset cannot drift from what the framework emits — and the one that matters
|
|
72
|
+
* has drifted before: `authenticated()` used to compile to a bare
|
|
73
|
+
* `IS NOT NULL`, which is true for anonymous visitors, and any copy of that
|
|
74
|
+
* string sitting in a preset would still be handing out the old grant today.
|
|
75
|
+
*/
|
|
76
|
+
var SIGNED_IN_SQL = compilePolicyExpression(policy.authenticated());
|
|
77
|
+
var IS_ADMIN_SQL = compilePolicyExpression(policy.rolesOverlap(["admin"]));
|
|
78
|
+
var OWNS_ROW_SQL = compilePolicyExpression(policy.compare(policy.authUid(), "eq", policy.field("uid")));
|
|
79
|
+
/**
|
|
80
|
+
* Every preset targets `TO public`, which is what the framework's generator
|
|
81
|
+
* emits and what actually reaches a request running as `rebase_user`. The part
|
|
82
|
+
* that used to be expressed as a role — "authenticated", "admin" — is a
|
|
83
|
+
* condition now, so it is enforced where Postgres will actually evaluate it.
|
|
84
|
+
*/
|
|
85
|
+
var POLICY_PRESETS = [
|
|
86
|
+
{
|
|
87
|
+
id: "public_read",
|
|
88
|
+
label: "Enable read access to everyone",
|
|
89
|
+
description: "Anyone can read data, regardless of authentication status.",
|
|
90
|
+
policyname: "Enable read access for all users",
|
|
91
|
+
cmd: "SELECT",
|
|
92
|
+
permissive: "PERMISSIVE",
|
|
93
|
+
roles: ["public"],
|
|
94
|
+
qual: "true",
|
|
95
|
+
with_check: ""
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: "auth_read",
|
|
99
|
+
label: "Enable read access for signed-in users only",
|
|
100
|
+
description: "Only signed-in users are allowed to read data. Anonymous requests carry a sentinel uid, so the condition excludes them explicitly.",
|
|
101
|
+
policyname: "Enable read access for signed-in users",
|
|
102
|
+
cmd: "SELECT",
|
|
103
|
+
permissive: "PERMISSIVE",
|
|
104
|
+
roles: ["public"],
|
|
105
|
+
qual: SIGNED_IN_SQL,
|
|
106
|
+
with_check: ""
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: "auth_insert",
|
|
110
|
+
label: "Enable insert for signed-in users only",
|
|
111
|
+
description: "Only signed-in users are allowed to insert new data.",
|
|
112
|
+
policyname: "Enable insert for signed-in users only",
|
|
113
|
+
cmd: "INSERT",
|
|
114
|
+
permissive: "PERMISSIVE",
|
|
115
|
+
roles: ["public"],
|
|
116
|
+
qual: "",
|
|
117
|
+
with_check: SIGNED_IN_SQL
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: "admin_all",
|
|
121
|
+
label: "Admins can do anything",
|
|
122
|
+
description: "Restricted to users holding the `admin` application role, matched inside the policy via rebase.roles().",
|
|
123
|
+
policyname: "Admins have full access",
|
|
124
|
+
cmd: "ALL",
|
|
125
|
+
permissive: "PERMISSIVE",
|
|
126
|
+
roles: ["public"],
|
|
127
|
+
qual: IS_ADMIN_SQL,
|
|
128
|
+
with_check: IS_ADMIN_SQL
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: "user_select_own",
|
|
132
|
+
label: "Users can read their own rows",
|
|
133
|
+
description: "Users can only read rows whose uid column matches their rebase.uid()",
|
|
134
|
+
policyname: "Users can select their own data",
|
|
135
|
+
cmd: "SELECT",
|
|
136
|
+
permissive: "PERMISSIVE",
|
|
137
|
+
roles: ["public"],
|
|
138
|
+
qual: OWNS_ROW_SQL,
|
|
139
|
+
with_check: ""
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
id: "user_update_own",
|
|
143
|
+
label: "Users can update their own rows",
|
|
144
|
+
description: "Users can only update rows whose uid column matches their rebase.uid()",
|
|
145
|
+
policyname: "Users can update their own data",
|
|
146
|
+
cmd: "UPDATE",
|
|
147
|
+
permissive: "PERMISSIVE",
|
|
148
|
+
roles: ["public"],
|
|
149
|
+
qual: OWNS_ROW_SQL,
|
|
150
|
+
with_check: OWNS_ROW_SQL
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
id: "user_delete_own",
|
|
154
|
+
label: "Users can delete their own rows",
|
|
155
|
+
description: "Users can only delete rows whose uid column matches their rebase.uid()",
|
|
156
|
+
policyname: "Users can delete their own data",
|
|
157
|
+
cmd: "DELETE",
|
|
158
|
+
permissive: "PERMISSIVE",
|
|
159
|
+
roles: ["public"],
|
|
160
|
+
qual: OWNS_ROW_SQL,
|
|
161
|
+
with_check: ""
|
|
162
|
+
}
|
|
163
|
+
];
|
|
164
|
+
//#endregion
|
|
165
|
+
export { roleOptionsFor as i, POLICY_PRESETS as n, SIGNED_IN_SQL as r, COMMAND_OPTIONS as t };
|
|
166
|
+
|
|
167
|
+
//# sourceMappingURL=policy-presets-CJKzAvQp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-presets-CJKzAvQp.js","names":[],"sources":["../src/components/RLSEditor/policy-presets.ts"],"sourcesContent":["/**\n * What the RLS editor offers before the user types anything: the roles a `TO`\n * list may name, and the ready-made policies.\n *\n * Separated from the component because these are the parts that have to agree\n * with the *server*, not with the UI — and the ways they can silently disagree\n * are the reason this file has tests.\n */\nimport { policy as policyExpr } from \"@rebasepro/types\";\nimport { compilePolicyExpression, REBASE_USER_ROLE } from \"@rebasepro/common\";\n\nexport type PolicyCommand = \"ALL\" | \"SELECT\" | \"INSERT\" | \"UPDATE\" | \"DELETE\";\n\nexport const COMMAND_OPTIONS: PolicyCommand[] = [\"ALL\", \"SELECT\", \"INSERT\", \"UPDATE\", \"DELETE\"];\n\n/**\n * The roles a policy's `TO` list can name when nothing better is known.\n *\n * Not `authenticated` / `anon` / `admin`, which is what this list used to be.\n * The first two are Supabase's role names and Rebase never creates them, so\n * `CREATE POLICY ... TO authenticated` — which is literally what the editor\n * builds and executes — fails with `role \"authenticated\" does not exist`. The\n * driver's `validatePolicyPgRoles` rejects the same three names in\n * `SecurityRule.pgRoles` and says why: they are another platform's convention,\n * and application roles belong in a condition, not in the `TO` list.\n *\n * `admin` was the more dangerous entry, because it is a plausible *application*\n * role. Had one existed as a database role too, the policy would have been\n * created successfully and then matched nothing at all: requests run as\n * {@link REBASE_USER_ROLE} after a `SET LOCAL ROLE`, and a `TO` list naming a\n * role the request never assumes filters every row without erroring.\n *\n * So: `public` (what the framework's own generator emits) and the role requests\n * actually arrive as. \"Signed-in users\" and \"admins\" are not roles here — they\n * are conditions over `rebase.uid()` and `rebase.roles()`, which is what the\n * presets below now compile to.\n */\nexport const FALLBACK_ROLE_OPTIONS = [\"public\", REBASE_USER_ROLE];\n\n/**\n * The `TO` list the editor offers, given what the database reported and what\n * the policy being edited already targets.\n *\n * Three sources, and each is there for a reason the others do not cover:\n *\n * - {@link FALLBACK_ROLE_OPTIONS} always, because `public` is a **keyword, not\n * a row in `pg_roles`** — `fetchAvailableRoles` cannot return it, so seeding\n * from the live fetch alone would drop the one role every generated policy\n * targets.\n * - the live roles, so an operator's own `app_read` is reachable without\n * hand-editing SQL.\n * - the edited policy's own roles, because a `MultiSelect` silently drops a\n * value with no matching item. That value is the `TO` list of a policy\n * already enforcing something, so opening an unrelated policy for a one-word\n * rename would have quietly rewritten who it applies to.\n */\nexport function roleOptionsFor(\n fetched: readonly string[] | undefined,\n policyRoles: readonly string[] | undefined\n): string[] {\n return [...new Set([...FALLBACK_ROLE_OPTIONS, ...(fetched ?? []), ...(policyRoles ?? [])])];\n}\n\n/**\n * Preset conditions, compiled by the framework's own policy compiler rather\n * than written out here.\n *\n * `compilePolicyExpression` is the function `db push` generates policies with, so a\n * preset cannot drift from what the framework emits — and the one that matters\n * has drifted before: `authenticated()` used to compile to a bare\n * `IS NOT NULL`, which is true for anonymous visitors, and any copy of that\n * string sitting in a preset would still be handing out the old grant today.\n */\nexport const SIGNED_IN_SQL = compilePolicyExpression(policyExpr.authenticated());\nexport const IS_ADMIN_SQL = compilePolicyExpression(policyExpr.rolesOverlap([\"admin\"]));\nexport const OWNS_ROW_SQL = compilePolicyExpression(\n policyExpr.compare(policyExpr.authUid(), \"eq\", policyExpr.field(\"uid\"))\n);\n\nexport interface PolicyPreset {\n id: string;\n label: string;\n description: string;\n policyname: string;\n cmd: PolicyCommand;\n permissive: \"PERMISSIVE\" | \"RESTRICTIVE\";\n roles: string[];\n qual: string;\n with_check: string;\n}\n\n/**\n * Every preset targets `TO public`, which is what the framework's generator\n * emits and what actually reaches a request running as `rebase_user`. The part\n * that used to be expressed as a role — \"authenticated\", \"admin\" — is a\n * condition now, so it is enforced where Postgres will actually evaluate it.\n */\nexport const POLICY_PRESETS: PolicyPreset[] = [\n {\n id: \"public_read\",\n label: \"Enable read access to everyone\",\n description: \"Anyone can read data, regardless of authentication status.\",\n policyname: \"Enable read access for all users\",\n cmd: \"SELECT\",\n permissive: \"PERMISSIVE\",\n roles: [\"public\"],\n qual: \"true\",\n with_check: \"\"\n },\n {\n id: \"auth_read\",\n label: \"Enable read access for signed-in users only\",\n description: \"Only signed-in users are allowed to read data. Anonymous requests carry a sentinel uid, so the condition excludes them explicitly.\",\n policyname: \"Enable read access for signed-in users\",\n cmd: \"SELECT\",\n permissive: \"PERMISSIVE\",\n roles: [\"public\"],\n qual: SIGNED_IN_SQL,\n with_check: \"\"\n },\n {\n id: \"auth_insert\",\n label: \"Enable insert for signed-in users only\",\n description: \"Only signed-in users are allowed to insert new data.\",\n policyname: \"Enable insert for signed-in users only\",\n cmd: \"INSERT\",\n permissive: \"PERMISSIVE\",\n roles: [\"public\"],\n qual: \"\",\n with_check: SIGNED_IN_SQL\n },\n {\n id: \"admin_all\",\n label: \"Admins can do anything\",\n description: \"Restricted to users holding the `admin` application role, matched inside the policy via rebase.roles().\",\n policyname: \"Admins have full access\",\n cmd: \"ALL\",\n permissive: \"PERMISSIVE\",\n roles: [\"public\"],\n qual: IS_ADMIN_SQL,\n with_check: IS_ADMIN_SQL\n },\n {\n id: \"user_select_own\",\n label: \"Users can read their own rows\",\n description: \"Users can only read rows whose uid column matches their rebase.uid()\",\n policyname: \"Users can select their own data\",\n cmd: \"SELECT\",\n permissive: \"PERMISSIVE\",\n roles: [\"public\"],\n qual: OWNS_ROW_SQL,\n with_check: \"\"\n },\n {\n id: \"user_update_own\",\n label: \"Users can update their own rows\",\n description: \"Users can only update rows whose uid column matches their rebase.uid()\",\n policyname: \"Users can update their own data\",\n cmd: \"UPDATE\",\n permissive: \"PERMISSIVE\",\n roles: [\"public\"],\n qual: OWNS_ROW_SQL,\n with_check: OWNS_ROW_SQL\n },\n {\n id: \"user_delete_own\",\n label: \"Users can delete their own rows\",\n description: \"Users can only delete rows whose uid column matches their rebase.uid()\",\n policyname: \"Users can delete their own data\",\n cmd: \"DELETE\",\n permissive: \"PERMISSIVE\",\n roles: [\"public\"],\n qual: OWNS_ROW_SQL,\n with_check: \"\"\n }\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OAAO;EACP,aAAa;EACb,YAAY;EACZ,KAAK;EACL,YAAY;EACZ,OAAO,CAAC,QAAQ;EAChB,MAAM;EACN,YAAY;CAChB;CACA;EACI,IAAI;EACJ,OAAO;EACP,aAAa;EACb,YAAY;EACZ,KAAK;EACL,YAAY;EACZ,OAAO,CAAC,QAAQ;EAChB,MAAM;EACN,YAAY;CAChB;AACJ"}
|
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import { UserSelectPopover, useRebaseClient, useRebaseContext } from "@rebasepro/app";
|
|
2
2
|
import { useEffect, useMemo, useState } from "react";
|
|
3
|
-
import { Button, KeyRoundIcon, Typography, iconSize } from "@rebasepro/ui";
|
|
3
|
+
import { Button, Chip, KeyRoundIcon, Typography, iconSize } from "@rebasepro/ui";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { hasAdminRole } from "@rebasepro/types";
|
|
6
6
|
//#region src/components/AuthSimulationSelector.tsx
|
|
7
|
-
function AuthSimulationSelector({ authMode, setAuthMode, selectedUser, setSelectedUser, users, loading, onUserSearchTextChange, userTotalCount, currentUser }) {
|
|
7
|
+
function AuthSimulationSelector({ authMode, setAuthMode, selectedUser, setSelectedUser, users, loading, onUserSearchTextChange, userTotalCount, currentUser, fixedIdentityLabel, fixedIdentityHint }) {
|
|
8
|
+
if (fixedIdentityLabel !== void 0) return /* @__PURE__ */ jsxs("div", {
|
|
9
|
+
className: "flex flex-wrap items-center gap-3",
|
|
10
|
+
title: fixedIdentityHint,
|
|
11
|
+
children: [
|
|
12
|
+
/* @__PURE__ */ jsx(KeyRoundIcon, {
|
|
13
|
+
size: iconSize.small,
|
|
14
|
+
className: "text-text-secondary dark:text-text-secondary-dark"
|
|
15
|
+
}),
|
|
16
|
+
/* @__PURE__ */ jsx(Typography, {
|
|
17
|
+
variant: "caption",
|
|
18
|
+
className: "text-text-secondary dark:text-text-secondary-dark text-xs font-medium",
|
|
19
|
+
children: "Auth:"
|
|
20
|
+
}),
|
|
21
|
+
/* @__PURE__ */ jsx(Chip, {
|
|
22
|
+
size: "smallest",
|
|
23
|
+
children: fixedIdentityLabel
|
|
24
|
+
})
|
|
25
|
+
]
|
|
26
|
+
});
|
|
8
27
|
return /* @__PURE__ */ jsxs("div", {
|
|
9
28
|
className: "flex flex-wrap items-center gap-3",
|
|
10
29
|
children: [
|
|
@@ -119,4 +138,4 @@ function useRunAsUsers() {
|
|
|
119
138
|
//#endregion
|
|
120
139
|
export { AuthSimulationSelector as n, useRunAsUsers as t };
|
|
121
140
|
|
|
122
|
-
//# sourceMappingURL=useRunAsUsers-
|
|
141
|
+
//# sourceMappingURL=useRunAsUsers-CF7tkGzj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRunAsUsers-CF7tkGzj.js","names":[],"sources":["../src/components/AuthSimulationSelector.tsx","../src/components/useRunAsUsers.ts"],"sourcesContent":["import React from \"react\";\nimport { Button, Chip, iconSize, KeyRoundIcon, Typography } from \"@rebasepro/ui\";\nimport { UserSelectPopover, SelectableUser } from \"@rebasepro/app\";\n\nexport interface AuthSimulationSelectorProps {\n authMode: \"jwt\" | \"none\";\n setAuthMode: (mode: \"jwt\" | \"none\") => void;\n selectedUser: SelectableUser | null;\n setSelectedUser: (user: SelectableUser | null) => void;\n users: SelectableUser[];\n loading?: boolean;\n /** For a caller that searches `users` on the server — see `UserSelectPopover`. */\n onUserSearchTextChange?: (searchText: string) => void;\n /** How many users that search matched, when `users` is only its first page — see `UserSelectPopover`. */\n userTotalCount?: number;\n currentUser: SelectableUser | null;\n /**\n * What every request runs as, when the host fixes it (a service key, in\n * the hosted console). Set, the selector shows this instead of the auth\n * modes and the \"Run as\" picker: neither choice exists there.\n */\n fixedIdentityLabel?: string;\n /** Why the identity is fixed, shown on hover over {@link fixedIdentityLabel}. */\n fixedIdentityHint?: string;\n}\n\nexport function AuthSimulationSelector({\n authMode,\n setAuthMode,\n selectedUser,\n setSelectedUser,\n users,\n loading,\n onUserSearchTextChange,\n userTotalCount,\n currentUser,\n fixedIdentityLabel,\n fixedIdentityHint\n}: AuthSimulationSelectorProps) {\n if (fixedIdentityLabel !== undefined) {\n return (\n <div className=\"flex flex-wrap items-center gap-3\" title={fixedIdentityHint}>\n <KeyRoundIcon size={iconSize.small} className=\"text-text-secondary dark:text-text-secondary-dark\" />\n <Typography\n variant=\"caption\"\n className=\"text-text-secondary dark:text-text-secondary-dark text-xs font-medium\"\n >\n Auth:\n </Typography>\n <Chip size=\"smallest\">{fixedIdentityLabel}</Chip>\n </div>\n );\n }\n return (\n <div className=\"flex flex-wrap items-center gap-3\">\n <KeyRoundIcon size={iconSize.small} className=\"text-text-secondary dark:text-text-secondary-dark\" />\n <Typography\n variant=\"caption\"\n className=\"text-text-secondary dark:text-text-secondary-dark text-xs font-medium\"\n >\n Auth:\n </Typography>\n <Button\n size=\"small\"\n variant={authMode === \"jwt\" ? \"outlined\" : \"outlined\"}\n color={authMode === \"jwt\" ? \"primary\" : \"neutral\"}\n onClick={() => setAuthMode(\"jwt\")}\n className=\"rounded-full !px-3 !py-1 !text-xs\"\n >\n JWT Token\n </Button>\n <Button\n size=\"small\"\n variant={authMode === \"none\" ? \"outlined\" : \"outlined\"}\n color={authMode === \"none\" ? \"error\" : \"neutral\"}\n onClick={() => setAuthMode(\"none\")}\n className=\"rounded-full !px-3 !py-1 !text-xs\"\n >\n No Auth\n </Button>\n\n {authMode === \"jwt\" && (\n <>\n <div className=\"w-px h-4 bg-hairline-strong mx-1\" />\n <Typography\n variant=\"caption\"\n className=\"text-text-secondary dark:text-text-secondary-dark text-xs font-medium\"\n >\n Run as:\n </Typography>\n <UserSelectPopover\n selectedUser={selectedUser}\n onUserSelected={setSelectedUser}\n users={users}\n loading={loading}\n onSearchTextChange={onUserSearchTextChange}\n totalCount={userTotalCount}\n currentUser={currentUser}\n />\n </>\n )}\n </div>\n );\n}\n","import { useEffect, useMemo, useState } from \"react\";\nimport { useRebaseClient, useRebaseContext, type SelectableUser } from \"@rebasepro/app\";\nimport { hasAdminRole, type RebaseClient } from \"@rebasepro/types\";\n\n/** How many users one search of a \"Run as\" picker lists. */\nconst USER_PAGE_SIZE = 50;\n\n/** The fields a picker row shows, copied off an account or the signed-in user. */\nfunction toSelectableUser(user: SelectableUser): SelectableUser {\n return {\n uid: user.uid,\n displayName: user.displayName,\n email: user.email,\n photoURL: user.photoURL,\n roles: user.roles\n };\n}\n\nexport interface RunAsUsers {\n /** The signed-in user first, then the users the latest search found. */\n users: SelectableUser[];\n /** The signed-in user, the picker's \"self\" row. */\n currentUser: SelectableUser | null;\n loading: boolean;\n /** Search the project's users on the server. */\n onSearchTextChange: (searchText: string) => void;\n /**\n * How many users the latest search matched on the server, set only when\n * that is more than the one page listed — so the picker can say so rather\n * than present the page as everyone.\n */\n totalCount?: number;\n}\n\n/**\n * The users a \"Run as\" picker offers.\n *\n * The signed-in user, and — for an administrator, the only caller the server\n * lets run a request as someone else — the project's users, searched on the\n * server. Disabled accounts are left out: nothing can run as them, and the\n * server refuses them.\n */\nexport function useRunAsUsers(): RunAsUsers {\n const signedIn = useRebaseContext().authController?.user;\n const client = useRebaseClient<RebaseClient>();\n const adminApi = hasAdminRole(signedIn?.roles) ? client?.admin : undefined;\n\n const [search, setSearch] = useState(\"\");\n const [listed, setListed] = useState<SelectableUser[]>([]);\n const [totalCount, setTotalCount] = useState<number | undefined>(undefined);\n const [loading, setLoading] = useState(false);\n\n useEffect(() => {\n if (!adminApi) return;\n let cancelled = false;\n setLoading(true);\n adminApi.listUsersPaginated({ search: search || undefined, limit: USER_PAGE_SIZE })\n .then(({ users, total }) => {\n if (cancelled) return;\n setListed(users.filter((u) => !u.disabled).map(toSelectableUser));\n setTotalCount(total > users.length ? total : undefined);\n })\n .catch((err: unknown) => {\n console.warn(\"Could not list users for the \\\"Run as\\\" picker\", err);\n if (!cancelled) {\n setListed([]);\n setTotalCount(undefined);\n }\n })\n .finally(() => {\n if (!cancelled) setLoading(false);\n });\n return () => {\n cancelled = true;\n };\n }, [adminApi, search]);\n\n const currentUser = useMemo((): SelectableUser | null => (signedIn ? toSelectableUser(signedIn) : null), [signedIn]);\n\n const users = useMemo(\n () => [...(currentUser ? [currentUser] : []), ...listed.filter((u) => u.uid !== currentUser?.uid)],\n [currentUser, listed]\n );\n\n return { users, currentUser, loading, onSearchTextChange: setSearch, totalCount };\n}\n"],"mappings":";;;;;;AA0BA,SAAgB,uBAAuB,EACnC,UACA,aACA,cACA,iBACA,OACA,SACA,wBACA,gBACA,aACA,oBACA,qBAC4B;CAC5B,IAAI,uBAAuB,KAAA,GACvB,OACI,qBAAC,OAAD;EAAK,WAAU;EAAoC,OAAO;YAA1D;GACI,oBAAC,cAAD;IAAc,MAAM,SAAS;IAAO,WAAU;GAAqD,CAAA;GACnG,oBAAC,YAAD;IACI,SAAQ;IACR,WAAU;cACb;GAEW,CAAA;GACZ,oBAAC,MAAD;IAAM,MAAK;cAAY;GAAyB,CAAA;EAC/C;;CAGb,OACI,qBAAC,OAAD;EAAK,WAAU;YAAf;GACI,oBAAC,cAAD;IAAc,MAAM,SAAS;IAAO,WAAU;GAAqD,CAAA;GACnG,oBAAC,YAAD;IACI,SAAQ;IACR,WAAU;cACb;GAEW,CAAA;GACZ,oBAAC,QAAD;IACI,MAAK;IACL,SAAS,aAAa,QAAQ,aAAa;IAC3C,OAAO,aAAa,QAAQ,YAAY;IACxC,eAAe,YAAY,KAAK;IAChC,WAAU;cACb;GAEO,CAAA;GACR,oBAAC,QAAD;IACI,MAAK;IACL,SAAS,aAAa,SAAS,aAAa;IAC5C,OAAO,aAAa,SAAS,UAAU;IACvC,eAAe,YAAY,MAAM;IACjC,WAAU;cACb;GAEO,CAAA;GAEP,aAAa,SACV,qBAAA,UAAA,EAAA,UAAA;IACI,oBAAC,OAAD,EAAK,WAAU,mCAAoC,CAAA;IACnD,oBAAC,YAAD;KACI,SAAQ;KACR,WAAU;eACb;IAEW,CAAA;IACZ,oBAAC,mBAAD;KACkB;KACd,gBAAgB;K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,MAAM,cAAc,cAAsC,WAAW,iBAAiB,QAAQ,IAAI,MAAO,CAAC,QAAQ,CAAC;CAOnH,OAAO;EAAE,OALK,cACJ,CAAC,GAAI,cAAc,CAAC,WAAW,IAAI,CAAC,GAAI,GAAG,OAAO,QAAQ,MAAM,EAAE,QAAQ,aAAa,GAAG,CAAC,GACjG,CAAC,aAAa,MAAM,CAGf;EAAO;EAAa;EAAS,oBAAoB;EAAW;CAAW;AACpF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare class AdminRequestError extends Error {
|
|
2
|
+
readonly status: number;
|
|
3
|
+
readonly code?: string;
|
|
4
|
+
constructor(message: string, status: number, code?: string);
|
|
5
|
+
}
|
|
6
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
7
|
+
export declare function asString(value: unknown, fallback?: string): string;
|
|
8
|
+
export declare function asNullableString(value: unknown): string | null;
|
|
9
|
+
export declare function asBoolean(value: unknown, fallback?: boolean): boolean;
|
|
10
|
+
export declare function asNumber(value: unknown, fallback?: number): number;
|
|
11
|
+
export declare function asStringArray(value: unknown): string[];
|
|
12
|
+
export interface AdminFetchOptions {
|
|
13
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
14
|
+
body?: unknown;
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Authenticated JSON client for Rebase's `/api/*` admin and data endpoints.
|
|
20
|
+
* Carries the active session or proxy token automatically.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useAdminFetch(): {
|
|
23
|
+
apiBase: string | undefined;
|
|
24
|
+
requestJson: (path: string, options?: AdminFetchOptions) => Promise<unknown>;
|
|
25
|
+
};
|