@rebasepro/studio 0.34.1 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RLSEditor-RE4YpN_z.js","names":[],"sources":["../src/components/RLSEditor/policy-presets.ts","../src/components/RLSEditor/PolicyEditor.tsx","../src/components/RLSEditor/saveSecurityRules.ts","../src/components/RLSEditor/saveRules.ts","../src/components/RLSEditor/policyRules.ts","../src/components/RLSEditor/policyListing.ts","../src/components/RLSEditor/RLSEditor.tsx"],"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 }\n];\n","import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n Button,\n cls,\n defaultBorderMixin,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n HelpCircleIcon,\n IconButton,\n iconSize,\n MultiSelect,\n MultiSelectItem,\n Paper,\n Select,\n SelectItem,\n TextField,\n Typography\n} from \"@rebasepro/ui\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { RLS_JWT_SQL, RLS_ROLES_SQL, RLS_UID_SQL } from \"@rebasepro/types\";\nimport { REBASE_USER_ROLE } from \"@rebasepro/common\";\nimport {\n COMMAND_OPTIONS,\n POLICY_PRESETS,\n roleOptionsFor,\n type PolicyCommand\n} from \"./policy-presets\";\nimport { MonacoEditor, type MonacoEditorHandle } from \"../SQLEditor/MonacoEditor\";\nimport type { PostgresPolicy } from \"./RLSEditor\";\n\nexport interface PolicyEditorProps {\n policy?: PostgresPolicy;\n schema: string;\n table: string;\n /**\n * Native PostgreSQL roles this database actually has, for the `TO` list.\n *\n * Supplied by the caller from `fetchAvailableRoles()`. Merged with the\n * always-offered defaults by `roleOptionsFor`, never used in place of them:\n * `public` is a keyword and never comes back from that query.\n */\n roleOptions?: readonly string[];\n onSave: (policyData: Partial<PostgresPolicy>) => void;\n onCancel: () => void;\n}\n\nexport const PolicyEditor = ({\n policy,\n schema,\n table,\n roleOptions,\n onSave,\n onCancel\n}: PolicyEditorProps) => {\n\n const { t } = useTranslation();\n const [name, setName] = useState(\"\");\n const [helpOpen, setHelpOpen] = useState(false);\n const [behavior, setBehavior] = useState<\"PERMISSIVE\" | \"RESTRICTIVE\">(\"PERMISSIVE\");\n const [command, setCommand] = useState<PolicyCommand>(\"ALL\");\n const [roles, setRoles] = useState<string[]>([\"public\"]);\n const [usingExpr, setUsingExpr] = useState<string>(\"\");\n const [checkExpr, setCheckExpr] = useState<string>(\"\");\n\n const [selectedPreset, setSelectedPreset] = useState<string>(\"\");\n\n const availableRoles = useMemo(\n () => roleOptionsFor(roleOptions, policy?.roles),\n [roleOptions, policy]\n );\n\n useEffect(() => {\n if (policy) {\n setName(policy.policyname || \"\");\n setBehavior(policy.permissive || \"PERMISSIVE\");\n setCommand((policy.cmd as PolicyCommand) || \"ALL\");\n\n const initialRoles = policy.roles\n ? (Array.isArray(policy.roles) ? policy.roles : [policy.roles])\n : [\"public\"];\n setRoles(initialRoles as string[]);\n\n setUsingExpr(policy.qual || \"\");\n setCheckExpr(policy.with_check || \"\");\n } else {\n setName(\"\");\n setBehavior(\"PERMISSIVE\");\n setCommand(\"ALL\");\n setRoles([\"public\"]);\n setUsingExpr(\"\");\n setCheckExpr(\"\");\n setSelectedPreset(\"\");\n }\n }, [policy]);\n\n const handlePresetChange = (presetId: string) => {\n const preset = POLICY_PRESETS.find(p => p.id === presetId);\n if (!preset) return;\n\n setSelectedPreset(presetId);\n setName(preset.policyname);\n setBehavior(preset.permissive);\n setCommand(preset.cmd);\n setRoles(preset.roles);\n setUsingExpr(preset.qual);\n setCheckExpr(preset.with_check);\n };\n\n const showCheck = command === \"ALL\" || command === \"INSERT\" || command === \"UPDATE\";\n\n /**\n * The two expression editors. Save reads what they hold now: an edit\n * reaches `usingExpr` and `checkExpr` only when this re-renders, so a Save\n * right after a paste wrote the expression from before it.\n */\n const usingEditor = useRef<MonacoEditorHandle>(null);\n const checkEditor = useRef<MonacoEditorHandle>(null);\n\n const handleSave = () => {\n onSave({\n policyname: name,\n permissive: behavior,\n cmd: command,\n roles: roles,\n qual: usingEditor.current?.getValue() ?? usingExpr,\n with_check: showCheck ? checkEditor.current?.getValue() ?? checkExpr : null\n });\n };\n\n return (\n <>\n {/* Inline header: this editor renders as a full pane, not inside a Dialog,\n so DialogTitle (Radix-bound) cannot be used here. */}\n <Typography variant=\"h6\" gutterBottom className=\"mt-8 mx-8 flex justify-between items-center w-full\">\n <div>\n <div>{policy ? t(\"studio_policy_edit\") : t(\"studio_policy_create\")}</div>\n <div className=\"text-sm font-normal text-text-secondary dark:text-text-secondary-dark tracking-wide mt-1\">\n {t(\"studio_policy_defining_rules\")} <span className=\"font-mono text-primary bg-primary-bg px-1 py-0.5 rounded\">{schema}.{table}</span>\n </div>\n </div>\n <IconButton aria-label={t(\"help\")} size=\"small\" onClick={() => setHelpOpen(true)}>\n <HelpCircleIcon size={iconSize.smallest}/>\n </IconButton>\n </Typography>\n\n <DialogContent className=\"p-4 md:p-6 border-t border-hairline bg-surface-well\" includeMargin={false}>\n <div className=\"max-w-4xl mx-auto\">\n <Paper className={cls(\"p-4 md:p-6 flex flex-col gap-6 bg-surface-card border-none sm:border-solid rounded-none sm:rounded-xl\", defaultBorderMixin)}>\n\n {/* Presets - only for new policies */}\n {!policy && (\n <div className=\"flex flex-col gap-1.5 bg-primary/5 p-3 sm:p-4 rounded-lg border border-primary/10 dark:border-primary/20\">\n <Typography variant=\"caption\" className=\"text-primary dark:text-primary-light uppercase tracking-wider\">{t(\"studio_policy_template\")}</Typography>\n <Select\n size=\"small\"\n value={selectedPreset}\n onValueChange={handlePresetChange}\n position=\"item-aligned\"\n placeholder={t(\"studio_policy_select_template\")}\n className=\"bg-surface-card\"\n >\n {POLICY_PRESETS.map((preset) => (\n <SelectItem key={preset.id} value={preset.id}>\n <div className=\"flex flex-col text-left\">\n <span className=\"text-sm\">{preset.label}</span>\n <span className=\"text-xs text-text-secondary dark:text-text-secondary-dark\">{preset.description}</span>\n </div>\n </SelectItem>\n ))}\n </Select>\n </div>\n )}\n\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-4 sm:gap-6\">\n {/* Policy Name */}\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">{t(\"studio_policy_name\")}</Typography>\n <TextField\n value={name}\n aria-label={t(\"studio_policy_name\")}\n onChange={(e) => setName(e.target.value)}\n placeholder={t(\"studio_policy_name_placeholder\")}\n className=\"w-full\"\n />\n </div>\n\n {/* Behavior */}\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">\n {t(\"studio_policy_behavior\")} <code className=\"text-xs bg-hairline text-text-secondary dark:text-text-secondary-dark px-1 py-0.5 rounded ml-1\">AS</code>\n </Typography>\n <Select\n value={behavior}\n onValueChange={(val) => setBehavior(val as \"PERMISSIVE\" | \"RESTRICTIVE\")}\n position=\"item-aligned\"\n >\n <SelectItem value=\"PERMISSIVE\">\n <div className=\"flex flex-col text-left\">\n <span className=\"\">{t(\"studio_policy_permissive\")}</span>\n <span className=\"text-xs text-text-secondary dark:text-text-secondary-dark\">{t(\"studio_policy_permissive_desc\")}</span>\n </div>\n </SelectItem>\n <SelectItem value=\"RESTRICTIVE\">\n <div className=\"flex flex-col text-left\">\n <span className=\"\">{t(\"studio_policy_restrictive\")}</span>\n <span className=\"text-xs text-text-secondary dark:text-text-secondary-dark\">{t(\"studio_policy_restrictive_desc\")}</span>\n </div>\n </SelectItem>\n </Select>\n </div>\n </div>\n\n {/* Command */}\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">\n {t(\"studio_policy_command\")} <code className=\"text-xs bg-hairline text-text-secondary dark:text-text-secondary-dark px-1 py-0.5 rounded ml-1\">FOR</code>\n </Typography>\n <div className=\"flex flex-wrap gap-1.5\">\n {COMMAND_OPTIONS.map(cmd => (\n <Button\n key={cmd}\n size=\"small\"\n variant={command === cmd ? \"filled\" : \"text\"}\n color=\"neutral\"\n onClick={() => setCommand(cmd)}\n className=\"min-w-[80px]\"\n >\n {cmd}\n </Button>\n ))}\n </div>\n </div>\n\n {/* Roles */}\n <div className=\"flex flex-col gap-1.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">\n {t(\"studio_policy_target_roles\")} <code className=\"text-xs bg-hairline text-text-secondary dark:text-text-secondary-dark px-1 py-0.5 rounded ml-1\">TO</code>\n </Typography>\n <MultiSelect\n size=\"small\"\n value={roles}\n onValueChange={setRoles}\n placeholder={t(\"studio_policy_roles_placeholder\")}\n >\n {availableRoles.map(role => (\n <MultiSelectItem key={role} value={role}>\n {role}\n </MultiSelectItem>\n ))}\n </MultiSelect>\n </div>\n\n </Paper>\n\n <div className=\"mt-8 flex flex-col gap-4\">\n {/* USING Expression */}\n {command !== \"INSERT\" && (\n <div className=\"flex flex-col gap-1.5\">\n <div className=\"flex flex-col gap-0.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">{t(\"studio_policy_using_expr\")}</Typography>\n <Typography variant=\"caption\" className=\"text-text-secondary opacity-70\">{t(\"studio_policy_using_expr_desc\")}</Typography>\n </div>\n <div className={cls(\"h-32 border rounded-md overflow-hidden bg-surface-card\", defaultBorderMixin)}>\n <MonacoEditor\n ref={usingEditor}\n value={usingExpr}\n onChange={(v) => setUsingExpr(v || \"\")}\n readOnly={false}\n autoFocus={true}\n />\n </div>\n </div>\n )}\n\n {/* WITH CHECK Expression */}\n {showCheck && (\n <div className=\"flex flex-col gap-1.5 mt-2\">\n <div className=\"flex flex-col gap-0.5\">\n <Typography variant=\"caption\" className=\"uppercase tracking-wider text-text-secondary\">{t(\"studio_policy_check_expr\")}</Typography>\n <Typography variant=\"caption\" className=\"text-text-secondary opacity-70\">{t(\"studio_policy_check_expr_desc\")}</Typography>\n </div>\n <div className={cls(\"h-32 border rounded-md overflow-hidden bg-surface-card\", defaultBorderMixin)}>\n <MonacoEditor\n ref={checkEditor}\n value={checkExpr}\n onChange={(v) => setCheckExpr(v || \"\")}\n readOnly={false}\n autoFocus={command === \"INSERT\"}\n />\n </div>\n </div>\n )}\n </div>\n\n </div>\n </DialogContent>\n\n <DialogActions>\n <Button size=\"small\" variant=\"text\" color=\"neutral\" onClick={onCancel}>\n {t(\"studio_policy_cancel\")}\n </Button>\n <Button size=\"small\" variant=\"filled\" color=\"primary\" onClick={handleSave} disabled={!name}>\n {t(\"studio_policy_save\")}\n </Button>\n </DialogActions>\n\n <Dialog open={helpOpen} onOpenChange={setHelpOpen} maxWidth=\"3xl\">\n <DialogTitle hidden>{t(\"studio_policy_help_title\")}</DialogTitle>\n <DialogContent className=\"p-4 sm:p-6 lg:p-8 flex flex-col gap-6\">\n <div>\n <Typography variant=\"h5\" className=\"mb-2\">{t(\"studio_policy_help_title\")}</Typography>\n <Typography className=\"text-text-secondary dark:text-text-secondary-dark\">\n {t(\"studio_policy_help_intro\")}\n </Typography>\n </div>\n\n <div className=\"flex flex-col gap-4\">\n <Paper className={cls(\"p-4 sm:p-5 flex flex-col gap-1\", defaultBorderMixin)}>\n <Typography variant=\"subtitle2\" className=\"text-primary dark:text-primary-light font-medium\">{t(\"studio_policy_help_step1_title\")}</Typography>\n <Typography variant=\"body2\" className=\"text-text-secondary dark:text-text-secondary-dark\">\n {t(\"studio_policy_help_step1_desc\")}\n </Typography>\n </Paper>\n\n <Paper className={cls(\"p-4 sm:p-5 flex flex-col gap-1\", defaultBorderMixin)}>\n <Typography variant=\"subtitle2\" className=\"text-primary dark:text-primary-light font-medium\">{t(\"studio_policy_help_step2_title\")}</Typography>\n <Typography variant=\"body2\" className=\"text-text-secondary dark:text-text-secondary-dark mb-1\">\n {t(\"studio_policy_help_step2_desc\")}\n </Typography>\n {/* Database roles, which is all a `TO` list can name. Every\n API request runs as REBASE_USER_ROLE, so \"signed-in users\"\n and \"anonymous visitors\" are not roles a policy can target\n — they are conditions, and the templates write them as such. */}\n <ul className=\"list-disc pl-5 space-y-1 text-sm text-text-secondary dark:text-text-secondary-dark\">\n <li><strong>public</strong>: {t(\"studio_policy_help_role_public\")}</li>\n <li><strong>{REBASE_USER_ROLE}</strong>: {t(\"studio_policy_help_role_rebase_user\")}</li>\n </ul>\n <Typography variant=\"body2\" className=\"text-text-secondary dark:text-text-secondary-dark mt-1\">\n {t(\"studio_policy_help_roles_not_users\")}\n </Typography>\n </Paper>\n\n <Paper className={cls(\"p-4 sm:p-5 flex flex-col gap-1\", defaultBorderMixin)}>\n <Typography variant=\"subtitle2\" className=\"text-primary dark:text-primary-light font-medium\">{t(\"studio_policy_help_step3_title\")}</Typography>\n <Typography variant=\"body2\" className=\"text-text-secondary dark:text-text-secondary-dark mb-1\">\n {t(\"studio_policy_help_step3_desc\")}\n </Typography>\n <div className={cls(\"bg-surface-well px-3 py-2 rounded-md font-mono text-sm my-2\", defaultBorderMixin)}>\n {t(\"studio_policy_help_example\")} {RLS_UID_SQL} = uid\n </div>\n <Typography variant=\"caption\" className=\"text-text-secondary dark:text-text-secondary-dark\">\n {t(\"studio_policy_help_step3_example\")}\n </Typography>\n </Paper>\n\n <Paper className={cls(\"p-4 sm:p-5 flex flex-col gap-1\", defaultBorderMixin)}>\n <Typography variant=\"subtitle2\" className=\"text-primary dark:text-primary-light font-medium\">{t(\"studio_policy_help_step4_title\")}</Typography>\n <Typography variant=\"body2\" className=\"text-text-secondary dark:text-text-secondary-dark mb-1\">\n {t(\"studio_policy_help_step4_desc\")}\n </Typography>\n <div className={cls(\"bg-surface-well px-3 py-2 rounded-md font-mono text-sm my-2\", defaultBorderMixin)}>\n {t(\"studio_policy_help_example\")} {RLS_UID_SQL} = uid\n </div>\n <Typography variant=\"caption\" className=\"text-text-secondary dark:text-text-secondary-dark\">\n {t(\"studio_policy_help_step4_example\")}\n </Typography>\n </Paper>\n\n <Paper className={cls(\"p-4 sm:p-5 flex flex-col gap-2 bg-primary/5\", defaultBorderMixin)}>\n <Typography variant=\"subtitle2\" className=\"text-primary dark:text-primary-light font-medium\">{t(\"studio_policy_help_auth_vars_title\")}</Typography>\n <Typography variant=\"body2\" className=\"text-text-secondary dark:text-text-secondary-dark\">\n {t(\"studio_policy_help_auth_vars_desc\")}\n </Typography>\n <ul className=\"list-disc pl-5 space-y-2 text-sm text-text-secondary dark:text-text-secondary-dark font-normal\">\n <li>\n <code className=\"bg-surface-well px-1.5 py-0.5 rounded mr-1 whitespace-nowrap\">{RLS_UID_SQL}</code>\n <span className=\"block mt-0.5\">{t(\"studio_policy_help_auth_uid\")} <code className=\"bg-surface-well px-1 py-0.5 rounded text-xs\">{RLS_UID_SQL} = uid</code></span>\n </li>\n <li>\n <code className=\"bg-surface-well px-1.5 py-0.5 rounded mr-1 whitespace-nowrap\">{RLS_JWT_SQL}</code>\n <span className=\"block mt-0.5\">{t(\"studio_policy_help_auth_jwt\")} <code className=\"bg-surface-well px-1 py-0.5 rounded text-xs\">{RLS_JWT_SQL} ->> 'email' = 'admin@example.com'</code></span>\n </li>\n <li>\n <code className=\"bg-surface-well px-1.5 py-0.5 rounded mr-1 whitespace-nowrap\">{RLS_ROLES_SQL}</code>\n <span className=\"block mt-0.5\">{t(\"studio_policy_help_auth_roles\")} <code className=\"bg-surface-well px-1 py-0.5 rounded text-xs\">string_to_array({RLS_ROLES_SQL}, ',') @> ARRAY['admin']</code></span>\n </li>\n </ul>\n </Paper>\n </div>\n\n <div className={cls(\"mt-2 flex flex-col sm:flex-row justify-between items-start sm:items-center bg-primary/5 p-4 rounded-xl border border-primary/10 dark:border-primary/20\", defaultBorderMixin)}>\n <Typography variant=\"body2\" className=\"text-primary dark:text-primary-light mb-4 sm:mb-0 max-w-md\">\n {t(\"studio_policy_help_docs_cta\")}\n </Typography>\n <Button\n component=\"a\"\n href=\"https://www.postgresql.org/docs/current/sql-createpolicy.html\"\n target=\"_blank\"\n variant=\"outlined\"\n color=\"primary\"\n size=\"small\"\n className=\"whitespace-nowrap flex-shrink-0\"\n >\n {t(\"studio_policy_help_read_docs\")}\n </Button>\n </div>\n </DialogContent>\n <DialogActions className=\"p-4 sm:px-6 sm:pb-6 pt-0 border-t-0\">\n <Button onClick={() => setHelpOpen(false)} variant=\"filled\" color=\"primary\">{t(\"studio_policy_help_got_it\")}</Button>\n </DialogActions>\n </Dialog>\n </>\n );\n};\n","import type { TablePatch } from \"@rebasepro/types\";\n\n/**\n * Write a table's rule edits to its source file: `{ patches }` to the\n * source-only schema editor (`/admin/schema-editor/apply`).\n *\n * The schema-editor routes sit behind an admin gate that accepts a bearer token\n * and nothing else — there is no cookie fallback — so a request without an\n * `Authorization` header is a 401 every time. The RLS editor's two write paths\n * (\"Create policy\" on a mapped table, and \"Import to codebase\") both sent none,\n * and both reported the failure as a constant \"Failed to save policy\", which is\n * also what a 501 and a parse error looked like.\n *\n * It lives in its own module rather than inline in the component so that the\n * header can be asserted without rendering the whole RLS editor.\n */\nexport async function postTablePatches(options: {\n apiBase: string;\n patches: TablePatch[];\n getAuthToken?: () => Promise<string | null | undefined>;\n}): Promise<void> {\n const { apiBase, patches, getAuthToken } = options;\n\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n const token = getAuthToken ? await getAuthToken() : null;\n if (token) headers[\"Authorization\"] = `Bearer ${token}`;\n\n const response = await fetch(`${apiBase}/admin/schema-editor/apply`, {\n method: \"POST\",\n headers,\n // Only the operations: each names the table and the rule it changes,\n // and whatever it does not name stays as written.\n body: JSON.stringify({ patches })\n });\n\n if (response.ok) return;\n\n const body = await response.text().catch(() => \"\");\n let message: string | undefined;\n try {\n const parsed: unknown = JSON.parse(body);\n const error = typeof parsed === \"object\" && parsed !== null && \"error\" in parsed ? parsed.error : undefined;\n message = typeof error === \"object\" && error !== null && \"message\" in error && typeof error.message === \"string\"\n ? error.message\n : undefined;\n } catch {\n message = body.trim() || undefined;\n }\n throw new Error(message ?? `Failed to save policy (HTTP ${response.status}).`);\n}\n","import type { StudioSchemaEditing } from \"@rebasepro/app\";\nimport type { RlsDescriptor, SecurityRule, SecurityRuleBase, TablePatch } from \"@rebasepro/types\";\nimport { rulePatches } from \"@rebasepro/types\";\n\nimport { postTablePatches } from \"./saveSecurityRules\";\nimport type { PolicyRule } from \"./policyRules\";\n\n/**\n * Where a table's security rules go when the RLS editor saves them — the one\n * function every RLS-editor write to the source goes through.\n *\n * The edit is sent as the rule operations it is (`TablePatch`): the rules the\n * table declares, compared with the rules it should declare, by\n * {@link rulePatches} — one `replaceRule` for an edited rule, one `addRule`\n * for an imported one. A policy's name is a hash of its rule as written, so a\n * rule the edit did not touch is never rewritten. A posture is `setRls`:\n * removing the last rule is `\"admin-only\"`, never an empty list.\n *\n * A table whose rules are inherited from `defaultRls` keeps `\"inherit\"`\n * unless the person deliberately detaches it: `confirmDetach` asks (naming\n * what happens), and saying no writes nothing.\n *\n * There are two doors onto one file. With a collection editor mounted, the\n * write goes through its plan/apply flow — planned, shown as SQL, confirmed,\n * applied to the database — arriving over the Studio bridge as\n * {@link StudioSchemaEditing} (`@rebasepro/cms` is a *peer* of\n * `@rebasepro/studio`, which has to run without it). Without one, it goes to\n * the source-only schema editor directly.\n *\n * A separate module from the component so the decision can be asserted\n * without a database and a rendered editor.\n */\nexport async function saveRules(\n schemaEditing: StudioSchemaEditing,\n transport: { apiBase: string; getAuthToken?: () => Promise<string | null | undefined> },\n table: { slug: string; rls: RlsDescriptor },\n rules: readonly PolicyRule[],\n options: {\n /** Asked before a table on `defaultRls` gets rules of its own; `false` keeps `\"inherit\"`. */\n confirmDetach: (slug: string) => Promise<boolean>;\n }\n): Promise<void> {\n const patches = await rlsEdit(table, rules.map(asSecurityRule), options.confirmDetach);\n if (patches.length === 0) return;\n if (schemaEditing.available) {\n await schemaEditing.applyTablePatches(table.slug, patches);\n return;\n }\n await postTablePatches({ apiBase: transport.apiBase, patches, getAuthToken: transport.getAuthToken });\n}\n\n/**\n * A rule the policy editor built — its fields assigned one at a time, so\n * wider than any one variant — as the `SecurityRule` variant its fields make\n * it. Which fields go together is the variants' rule; the editor never sets\n * two that exclude each other ({@link PolicyRule}).\n */\nexport function asSecurityRule(rule: PolicyRule): SecurityRule {\n const { using, withCheck, ownerField, access, condition, check, redacted, ...rest } = rule;\n const base: SecurityRuleBase = rest;\n if (redacted) return { ...base, redacted, ...(access !== undefined ? { access } : {}) };\n if (using !== undefined) return { ...base, using, ...(withCheck !== undefined ? { withCheck } : {}) };\n if (withCheck !== undefined) return { ...base, withCheck };\n if (ownerField !== undefined) return { ...base, ownerField };\n if (access !== undefined) {\n if (condition !== undefined) return { ...base, access, condition, ...(check !== undefined ? { check } : {}) };\n if (check !== undefined) return { ...base, access, check };\n switch (access) {\n case \"public\": return { ...base, access: \"public\" };\n case \"authenticated\": return { ...base, access: \"authenticated\" };\n case \"registered\": return { ...base, access: \"registered\" };\n }\n }\n if (condition !== undefined) return { ...base, condition, ...(check !== undefined ? { check } : {}) };\n return base;\n}\n\n/** The person kept `\"inherit\"`: an answer, matched like the plan dialog's cancellation. */\nclass DetachDeclined extends Error {\n constructor() {\n super(\"The table keeps its inherited rules.\");\n this.name = \"SchemaChangeCancelled\";\n }\n}\n\n/**\n * The operations that make `table` declare `rules`.\n *\n * Exported for the tests: the decision is the whole of what this module adds.\n */\nexport async function rlsEdit(\n table: { slug: string; rls: RlsDescriptor },\n rules: readonly SecurityRule[],\n confirmDetach: (slug: string) => Promise<boolean>\n): Promise<TablePatch[]> {\n const declared = table.rls.posture === \"rules\" ? table.rls.rules : [];\n if (table.rls.inherited) {\n if (rules.length === 0 || JSON.stringify(rules) === JSON.stringify(declared)) return [];\n if (!await confirmDetach(table.slug)) throw new DetachDeclined();\n return [{ op: \"setRls\", table: table.slug, rls: [rules[0], ...rules.slice(1)] }];\n }\n if (rules.length === 0) {\n return declared.length === 0 ? [] : [{ op: \"setRls\", table: table.slug, rls: \"admin-only\" }];\n }\n if (declared.length === 0) return [{ op: \"setRls\", table: table.slug, rls: [rules[0], ...rules.slice(1)] }];\n return rulePatches(table.slug, declared, rules);\n}\n\n/**\n * Was this rejection the person closing the plan dialog, or keeping a table's\n * inherited rules?\n *\n * Either is an answer, not a failure, and a caller that treats every\n * rejection as an error reports someone's own choice back to them in red — as\n * the collection editor once did, with \"Error persisting collection: The schema\n * change was not applied.\"\n *\n * Matched by name rather than `instanceof`: `SchemaChangeCancelled` is declared\n * in `@rebasepro/cms`, which this package cannot import, and two copies of a\n * class in one bundle make `instanceof` silently false anyway.\n */\nexport function isCancellation(err: unknown): boolean {\n return err instanceof Error && err.name === \"SchemaChangeCancelled\";\n}\n","import { isRedactedSecurityRule } from \"@rebasepro/types\";\nimport type {\n AuthenticatedSecurityRule,\n CheckedAccessSecurityRule,\n ConditionalAccessSecurityRule,\n OwnerSecurityRule,\n PolicyCondition,\n PostgresPolicy,\n PublicSecurityRule,\n RawSQLCheckOnlySecurityRule,\n RawSQLSecurityRule,\n RedactedSecurityRule,\n RegisteredSecurityRule,\n RolesOnlySecurityRule,\n SecurityRule,\n SecurityRuleAccess,\n SecurityRuleBase,\n StructuredSecurityRule\n} from \"@rebasepro/types\";\nimport { policyToSecurityRule } from \"@rebasepro/common\";\nimport { getPolicyOperations } from \"@rebasepro/utils\";\nimport type { ListedPolicy } from \"./policyListing\";\n\n/**\n * The security-rule fields a {@link PostgresPolicy} describes, and the ones an\n * edit carries over from the rule it changes.\n *\n * Wider than any one `SecurityRule` variant on purpose: an edit starts from the\n * rule as written and deletes and assigns the fields that changed one at a\n * time, and the variants are exclusive about which fields go together.\n */\nexport type PolicyRule = SecurityRuleBase & {\n using?: string;\n withCheck?: string;\n ownerField?: string;\n access?: SecurityRuleAccess;\n condition?: PolicyCondition;\n check?: PolicyCondition;\n /** Carried through untouched; a redacted rule is never edited ({@link ruleForm}). */\n redacted?: true;\n};\n\n/**\n * Which form a declared rule is written in — what the editor can do with it.\n *\n * Every rule form but one is editable as SQL: the editor shows the policy the\n * rule compiles to, and a field is only rewritten when the form changed it\n * ({@link applyPolicyEdit}), so an untouched rule — a `PolicyShorthand`\n * condition, `access` with a condition — is saved exactly as written, and\n * its policy keeps its name. The exception is `redacted`: the server withheld\n * the rule's clauses from this caller, so there is nothing to show or edit;\n * it is defined on the server.\n */\nexport type PolicyRuleForm =\n | \"owner\" | \"access\" | \"conditional_access\" | \"structured\" | \"raw\" | \"roles_only\" | \"redacted\";\n\n/**\n * Every `SecurityRule` member {@link ruleForm} classifies. A member added to\n * the union and not listed here fails to compile at {@link RULE_FORMS_COVER_THE_UNION}\n * — the one place to decide how the editor treats it.\n */\ntype ClassifiedRule =\n | OwnerSecurityRule | PublicSecurityRule | AuthenticatedSecurityRule | RegisteredSecurityRule\n | ConditionalAccessSecurityRule | CheckedAccessSecurityRule | StructuredSecurityRule\n | RawSQLSecurityRule | RawSQLCheckOnlySecurityRule | RolesOnlySecurityRule | RedactedSecurityRule;\nconst RULE_FORMS_COVER_THE_UNION: [Exclude<SecurityRule, ClassifiedRule>] extends [never] ? true : false = true;\nvoid RULE_FORMS_COVER_THE_UNION;\n\n/** The {@link PolicyRuleForm} of a declared rule. */\nexport function ruleForm(rule: SecurityRule): PolicyRuleForm {\n if (isRedactedSecurityRule(rule)) return \"redacted\";\n if (rule.using != null || rule.withCheck != null) return \"raw\";\n if (rule.ownerField != null) return \"owner\";\n if (rule.access !== undefined) return rule.condition != null || rule.check != null ? \"conditional_access\" : \"access\";\n if (rule.condition != null || rule.check != null) return \"structured\";\n return \"roles_only\";\n}\n\n/** Why an edited policy could not be written back to a rule. */\nexport type PolicyEditRefusal =\n /** Rebase adds it (the admin baseline, tenancy); no declared rule holds it. */\n | \"generated\"\n /** It exists only in the database. */\n | \"not_declared\"\n /** Its rule covers several operations, and the policy is one of them. */\n | \"several_operations\"\n /** Its rule was served redacted: the clauses are defined on the server. */\n | \"redacted\";\n\nexport type PolicyEdit =\n | { ok: true; rules: PolicyRule[] }\n | { ok: false; reason: PolicyEditRefusal };\n\n/**\n * Write an edit of one policy back to the declared rule it compiles from.\n *\n * The rule is the one the server says the policy was compiled from (the\n * served policy's `rule` index, carried on the listed row) — the server is the\n * one compiler, so the editor never guesses it from names. A policy with no\n * rule is Rebase's own (`generated`: the admin baseline, tenancy, a junction's\n * derived policies) or exists only in the database.\n *\n * A rule over several operations is refused rather than split: taking one\n * operation out renames every policy the rule compiles to.\n *\n * @param declared The table's declared rules (`rls.rules`), as written.\n * @param original The listed policy the editor was opened with.\n */\nexport function applyPolicyEdit(\n declared: readonly SecurityRule[],\n original: ListedPolicy,\n edited: Partial<PostgresPolicy>\n): PolicyEdit {\n const index = original.rule;\n if (index === undefined || declared[index] === undefined) {\n return { ok: false, reason: original.generated ? \"generated\" : \"not_declared\" };\n }\n const rule = declared[index];\n if (ruleForm(rule) === \"redacted\") return { ok: false, reason: \"redacted\" };\n if (getPolicyOperations(rule).length > 1) return { ok: false, reason: \"several_operations\" };\n\n return {\n ok: true,\n rules: declared.map((r, i) => (i === index ? editedRule(r, original, edited) : r))\n };\n}\n\n/**\n * The rule with what the editor changed, and nothing else.\n *\n * The editor shows a rule as a policy — name, command, mode, `TO` list and raw\n * USING / WITH CHECK — and an `ownerField` or `access` rule has no raw clause\n * to show. So a field is only written when it differs from what the editor was\n * opened with: renaming an `access: \"public\"` rule keeps it public, and an\n * unnamed rule stays unnamed unless the name was changed. A condition typed in\n * replaces the rule's condition whole — the forms are exclusive.\n */\nfunction editedRule(rule: SecurityRule, original: PostgresPolicy, edited: Partial<PostgresPolicy>): PolicyRule {\n const next = policyToSecurityRule(edited);\n const result: PolicyRule = { ...rule };\n\n if ((edited.policyname ?? \"\") !== original.policyname) {\n if (next.name) result.name = next.name;\n else delete result.name;\n }\n if (edited.cmd !== original.cmd) {\n delete result.operations;\n result.operation = next.operation;\n }\n if (edited.permissive !== original.permissive) {\n result.mode = next.mode;\n }\n if (!sameRoles(edited.roles, original.roles)) {\n if (next.pgRoles) result.pgRoles = next.pgRoles;\n else delete result.pgRoles;\n }\n if ((edited.qual || null) !== (original.qual || null) || (edited.with_check || null) !== (original.with_check || null)) {\n delete result.ownerField;\n delete result.access;\n delete result.condition;\n delete result.check;\n delete result.using;\n delete result.withCheck;\n if (next.using) result.using = next.using;\n if (next.withCheck) result.withCheck = next.withCheck;\n }\n return result;\n}\n\nfunction sameRoles(a: readonly string[] | undefined, b: readonly string[] | undefined): boolean {\n const left = [...(a ?? [])].sort();\n const right = [...(b ?? [])].sort();\n return left.length === right.length && left.every((role, i) => role === right[i]);\n}\n","import { isRedactedSecurityRule, REBASE_ADMIN_REQUEST_ROLE, REBASE_ADMIN_ROLE } from \"@rebasepro/types\";\nimport type { PolicyDescriptor, PostgresPolicy, RlsDescriptor, SecurityOperation, SecurityRule } from \"@rebasepro/types\";\nimport { getPolicyNamesForRule, getPolicyOperations } from \"@rebasepro/utils\";\n\n/** A part of a policy the database can hold differently from its declaration. */\nexport type PolicyDriftField = \"roles\" | \"command\" | \"mode\" | \"USING\" | \"WITH CHECK\";\n\n/** A row of the RLS editor's policy list. */\nexport interface ListedPolicy extends PostgresPolicy {\n /**\n * What the server compiles this policy to, when the table declares one by\n * this name. For a policy the database also has, the row's own fields are\n * the database's and this is what they are compared against.\n */\n declared?: PostgresPolicy;\n /** Where the database's policy differs from {@link declared}. Empty when it does not. */\n drift?: PolicyDriftField[];\n /**\n * Rebase adds this policy itself — the admin baseline, a tenancy or\n * auth-write gate, a junction's derived policies, an admin-request\n * companion — so no rule of the author's holds it, and the next server\n * start re-creates it.\n */\n generated?: boolean;\n /** The index in the table's declared `rls.rules` of the rule this policy compiles from. */\n rule?: number;\n}\n\n/**\n * The roles of a `pg_policies` row, from its `roles` column.\n *\n * A driver hands a `name[]` back as an array or as Postgres's text for one:\n * `{public}`, `{anon,authenticated}`, and with an element quoted — a `\"` or\n * `\\` in it escaped by a backslash — when it holds a comma, a brace, a quote,\n * a backslash or a space: `{\"my role\",anon}`. Split on commas, that last one\n * reads as the role `\"my role\"`, quotes and all: the policy shows drift that\n * is not there, and an edit of it names a role that does not exist.\n */\nexport function readPolicyRoles(value: unknown): string[] {\n if (Array.isArray(value)) return value.filter((role): role is string => typeof role === \"string\");\n if (typeof value !== \"string\") return [];\n const body = value.trim().replace(/^\\{/, \"\").replace(/\\}$/, \"\");\n const roles: string[] = [];\n let i = 0;\n while (i < body.length) {\n if (body[i] === \"\\\"\") {\n let role = \"\";\n i++;\n while (i < body.length && body[i] !== \"\\\"\") {\n if (body[i] === \"\\\\\") i++;\n role += body[i] ?? \"\";\n i++;\n }\n roles.push(role);\n i++;\n } else {\n const comma = body.indexOf(\",\", i);\n const end = comma === -1 ? body.length : comma;\n const role = body.slice(i, end).trim();\n if (role) roles.push(role);\n i = end;\n }\n // Past the comma that ends this element, if there is one.\n while (i < body.length && body[i] !== \",\") i++;\n i++;\n }\n return roles;\n}\n\nconst COMMANDS: Record<SecurityOperation, PostgresPolicy[\"cmd\"]> = {\n select: \"SELECT\",\n insert: \"INSERT\",\n update: \"UPDATE\",\n delete: \"DELETE\",\n all: \"ALL\"\n};\n\nfunction commandOf(operation: string): PostgresPolicy[\"cmd\"] {\n return operation in COMMANDS ? COMMANDS[operation as SecurityOperation] : \"ALL\";\n}\n\n/** A policy the server compiled, in the shape `pg_policies` describes one. */\nexport function servedAsPostgresPolicy(served: PolicyDescriptor, tableName: string): PostgresPolicy {\n return {\n policyname: served.name,\n tablename: tableName,\n permissive: served.mode === \"restrictive\" ? \"RESTRICTIVE\" : \"PERMISSIVE\",\n cmd: commandOf(served.operation),\n roles: [...served.roles],\n qual: served.using,\n with_check: served.withCheck\n };\n}\n\n/**\n * The rule's own clauses, for a declared rule the server compiled no policy\n * from — an `existsIn` naming a table the backend does not hold, say. Only\n * ever a `code_only` row's content: nothing is compared against it.\n */\nfunction uncompiledPolicy(rule: SecurityRule, operation: SecurityOperation, name: string, tableName: string): PostgresPolicy {\n return {\n policyname: name,\n tablename: tableName,\n permissive: rule.mode === \"restrictive\" ? \"RESTRICTIVE\" : \"PERMISSIVE\",\n cmd: COMMANDS[operation],\n roles: [...(rule.pgRoles ?? [\"public\"])],\n qual: rule.using || null,\n with_check: rule.withCheck || null\n };\n}\n\nfunction sameRoles(a: readonly string[], b: readonly string[]): boolean {\n const left = [...a].sort();\n const right = [...b].sort();\n return left.length === right.length && left.every((role, i) => role === right[i]);\n}\n\n/**\n * Where a live policy differs from the one the code compiles to.\n *\n * The same comparison `rebase doctor` makes: the `TO` list, the command, the\n * mode, and whether each clause is there at all. Never the clause text —\n * Postgres rewrites an expression when it stores it, so the text of a policy\n * that matches its declaration exactly still differs from the declaration's.\n * A clause that is missing is not a rewrite, though: a `USING` that is gone\n * changes who the policy admits.\n */\nexport function policyDrift(declared: PostgresPolicy, live: PostgresPolicy): PolicyDriftField[] {\n const drift: PolicyDriftField[] = [];\n if (!sameRoles(declared.roles, live.roles)) drift.push(\"roles\");\n if (declared.cmd !== live.cmd) drift.push(\"command\");\n if (declared.permissive !== live.permissive) drift.push(\"mode\");\n if ((declared.qual != null) !== (live.qual != null)) drift.push(\"USING\");\n if ((declared.with_check != null) !== (live.with_check != null)) drift.push(\"WITH CHECK\");\n return drift;\n}\n\n/**\n * What the server says a table's policies are: its declared rules and the\n * policies it compiled from them, or — for a junction — the derived policies\n * alone. `undefined` when the table is not one the server declares, or when it\n * withheld the compiled policies from this caller (no `schema:read`).\n */\nexport interface DeclaredPolicies {\n /** The declared rules, as written; empty for a junction. */\n rules: readonly SecurityRule[];\n /** Every policy the server compiles for the table. */\n policies: readonly PolicyDescriptor[];\n}\n\n/** The {@link DeclaredPolicies} of a served table, when the server included its compiled policies. */\nexport function declaredPoliciesOf(rls: RlsDescriptor): DeclaredPolicies | undefined {\n return rls.policies ? { rules: rls.rules, policies: rls.policies } : undefined;\n}\n\n/**\n * The policies of one table: every policy the database has, as the database\n * has it, and every policy the server compiles for the table that it does not.\n *\n * The server is the one compiler: what it serves in `rls.policies` (and\n * `rls.junctions`) is exactly what `db push` and every server start write.\n * This only compares it with `pg_policies`. A policy in both keeps the\n * database's fields — this list is what Postgres enforces — and carries the\n * declaration beside them, with where the two differ.\n *\n * @param live The table's `pg_policies` rows.\n * @param declared What the server serves for the table, if anything.\n */\nexport function listPolicies(\n live: readonly PostgresPolicy[],\n declared: DeclaredPolicies | undefined,\n tableName: string\n): ListedPolicy[] {\n const listed = new Map<string, ListedPolicy>();\n for (const policy of live) listed.set(policy.policyname, { ...policy, status: \"live\" });\n if (!declared) return [...listed.values()];\n\n const livePolicies = new Map(live.map(policy => [policy.policyname, policy]));\n const compiledRules = new Set<number>();\n\n for (const served of declared.policies) {\n if (served.rule !== undefined) compiledRules.add(served.rule);\n const existing = livePolicies.get(served.name);\n // The `TO rebase_admin_request USING (true)` companion a server writes\n // beside an admin-only policy where it made that role safe: Rebase's,\n // and compared like any declared policy when it is there. Not listed\n // when absent — a server that cannot make the role safe writes none.\n if (served.roles.includes(REBASE_ADMIN_REQUEST_ROLE) && !existing) continue;\n const compiled = servedAsPostgresPolicy(served, tableName);\n // A policy compiled TO rebase_admin is written TO public by a server\n // whose admin switch is not live — its documented fallback, not drift.\n // Only that one form is accepted.\n const fellBack = existing !== undefined && sameRoles(compiled.roles, [REBASE_ADMIN_ROLE]) && sameRoles(existing.roles, [\"public\"]);\n const declaredPolicy = fellBack ? { ...compiled, roles: [\"public\"] } : compiled;\n const rule = served.rule !== undefined ? { rule: served.rule } : {};\n if (existing) {\n listed.set(served.name, {\n ...existing,\n status: \"both\",\n declared: declaredPolicy,\n drift: policyDrift(declaredPolicy, existing),\n generated: served.injected,\n ...rule\n });\n } else {\n listed.set(served.name, { ...declaredPolicy, status: \"code_only\", generated: served.injected, ...rule });\n }\n }\n\n // A declared rule the server compiled nothing from still belongs in the\n // list: the code declares it, and the database cannot have it.\n declared.rules.forEach((rule, index) => {\n if (compiledRules.has(index) || isRedactedSecurityRule(rule)) return;\n const operations = getPolicyOperations(rule);\n getPolicyNamesForRule(rule, tableName).forEach((name: string, position: number) => {\n const existing = listed.get(name);\n if (existing) {\n // In the database under its name: nothing compiled to compare it with.\n if (existing.status === \"live\") listed.set(name, { ...existing, status: \"both\", generated: false, rule: index });\n return;\n }\n listed.set(name, {\n ...uncompiledPolicy(rule, operations[position] ?? \"all\", name, tableName),\n status: \"code_only\",\n generated: false,\n rule: index\n });\n });\n });\n\n return [...listed.values()];\n}\n","import { useStudioCapabilities, useStudioSchemaEditing, useTableDescriptors } from \"@rebasepro/app\";\nimport { useApiBase, useApiConfig } from \"@rebasepro/app\";\nimport React, { useState, useEffect, useCallback, useMemo, useRef } from \"react\";\nimport {\n Alert,\n AlertTriangleIcon,\n Button,\n Chip,\n CircularProgress,\n cls,\n DatabaseIcon,\n defaultBorderMixin,\n IconButton,\n iconSize,\n KeyIcon,\n LockIcon,\n Paper,\n RefreshCwIcon,\n ResizablePanels,\n ShieldIcon,\n Tab,\n Tabs,\n Tooltip,\n Trash2Icon,\n Typography\n} from \"@rebasepro/ui\";\nimport { useRebaseContext, useSnackbarController, ErrorView, useTranslation, ConfirmationDialog } from \"@rebasepro/app\";\nimport { REBASE_INTERNAL_SCHEMAS, REBASE_INTERNAL_PREFIXES, JUNCTION_TABLES_SQL, policyToSecurityRule } from \"@rebasepro/common\";\nimport { adminRequestPolicyName } from \"@rebasepro/utils\";\nimport { PolicyEditor } from \"./PolicyEditor\";\nimport { saveRules, isCancellation } from \"./saveRules\";\nimport { applyPolicyEdit, type PolicyEditRefusal, type PolicyRule } from \"./policyRules\";\nimport { declaredPoliciesOf, listPolicies, readPolicyRoles, type DeclaredPolicies, type ListedPolicy } from \"./policyListing\";\nimport { quoteIdentifier } from \"../../utils/sql_utils\";\nimport { schemaSourceProblem, SchemaSourceProblemAlert } from \"../schema-source\";\n\ntype TableCategory = \"collection\" | \"junction\" | \"internal\" | \"other\";\n\n/**\n * Whether `descriptor` is the table the server declares for a live table: the\n * same SQL table in the same schema, as the server resolved both.\n *\n * Matched once by name, a table was taken for any collection whose `id`,\n * `path`, `table`, `slug` or `collectionId` equalled its name, in any schema.\n * So an unmapped table named like another table's slug, or a same-named table\n * in another schema, was taken for that table: it listed the declared\n * policies as missing from the table, and offered to import the table's own\n * policies into the declaration. A view is never a `pg_tables` row.\n */\nfunction mapsTable(descriptor: TableDescriptor, table: { schemaName: string; tableName: string }): boolean {\n return descriptor.kind === \"table\" && descriptor.table === table.tableName && descriptor.schema === table.schemaName;\n}\n\n/** What the editor says when an edit has no declared rule to go back to. */\nconst POLICY_EDIT_REFUSALS: Record<PolicyEditRefusal, string> = {\n generated: \"studio_rls_edit_generated\",\n not_declared: \"studio_rls_edit_not_declared\",\n several_operations: \"studio_rls_edit_several_operations\",\n redacted: \"studio_rls_edit_redacted\"\n};\n\nfunction classifyTableClient(\n tableName: string,\n schemaName: string,\n isJunction: boolean,\n isMappedToCollection: boolean\n): TableCategory {\n // A table the project's own schema maps is the CUSTOMER'S, whatever schema\n // Postgres put it in. This test used to come second, behind a rule that\n // claims the whole `rebase` schema as platform plumbing — and Rebase\n // creates a tenant's collection tables in exactly that schema. So every\n // table a customer owns was filed under a dimmed, collapsed \"Rebase\n // Internal\" section beside `refresh_tokens` and `mfa_factors`, the\n // \"Schema Tables\" section rendered empty and disappeared, and the\n // console's answer to \"what am I securing\" was four unmapped tables the\n // project barely uses.\n //\n // The schema can never decide this on its own: `users` and `branches` are\n // both platform tables AND, on a project that defines them, collections\n // the customer writes policies for. The mapping is the only thing that\n // knows, so it is asked first.\n if (isMappedToCollection) return \"collection\";\n if (\n REBASE_INTERNAL_SCHEMAS.includes(schemaName) ||\n REBASE_INTERNAL_PREFIXES.some((prefix) => tableName.startsWith(prefix))\n ) {\n return \"internal\";\n }\n if (isJunction) return \"junction\";\n return \"other\";\n}\n\n// Re-exported for the components that used to import it from here.\nexport type { PostgresPolicy } from \"@rebasepro/types\";\nimport type { JunctionPolicyDescriptor, PostgresPolicy, SecurityRule, TableDescriptor } from \"@rebasepro/types\";\n\ninterface TableRLSStatus {\n schemaName: string;\n tableName: string;\n rlsEnabled: boolean;\n policies: PostgresPolicy[];\n}\n\n// ─── Sidebar helper components ──────────────────────────────────────\n\nfunction SidebarSection({ title, icon, expanded, onToggle, count, children }: {\n title: string;\n icon: React.ReactNode;\n expanded: boolean;\n onToggle: () => void;\n count?: number;\n children: React.ReactNode;\n}) {\n return (\n <div className=\"mb-2\">\n <div\n className=\"flex items-center p-1.5 cursor-pointer hover:bg-surface-hover rounded transition-colors\"\n onClick={onToggle}\n >\n <svg className={cls(\"w-3 h-3 mr-1.5 transition-transform text-text-disabled dark:text-text-disabled-dark\", expanded ? \"rotate-90\" : \"\")} fill=\"currentColor\" viewBox=\"0 0 20 20\"><path d=\"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z\"/></svg>\n {icon}\n <Typography variant=\"body2\" className=\"text-text-primary dark:text-text-primary-dark font-medium text-xs truncate flex-grow ml-1.5\">{title}</Typography>\n {count !== undefined && (\n <span className=\"text-[10px] text-text-disabled dark:text-text-disabled-dark font-medium tabular-nums mr-1\">{count}</span>\n )}\n </div>\n {expanded && (\n <div className=\"ml-3 mt-0.5 space-y-0.5\">\n {children}\n </div>\n )}\n </div>\n );\n}\n\nfunction SidebarTableRow({ table, isSelected, onSelect, badge, dimmed, t }: {\n table: TableRLSStatus;\n isSelected: boolean;\n onSelect: () => void;\n badge?: string;\n dimmed?: boolean;\n t: (key: string) => string;\n}) {\n return (\n <div\n onClick={onSelect}\n className={cls(\n \"flex items-center p-1 cursor-pointer rounded transition-colors group relative\",\n isSelected\n ? \"bg-primary/10 text-primary dark:bg-primary/20 dark:text-primary-light\"\n : \"hover:bg-surface-hover text-text-secondary dark:text-text-secondary-dark\",\n dimmed && !isSelected && \"opacity-60\"\n )}\n >\n <svg className=\"w-3.5 h-3.5 mr-1 shrink-0 text-text-disabled dark:text-text-disabled-dark\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M3 10h18M3 14h18m-9-4v8m-7 0h14a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z\"/></svg>\n <Typography variant=\"body2\" className=\"text-xs truncate flex-1 min-w-0\">{table.tableName}</Typography>\n <div className=\"flex items-center gap-1.5 shrink-0 ml-2\">\n {badge && (\n <span className=\"text-[9px] uppercase tracking-wider font-semibold text-text-disabled dark:text-text-disabled-dark bg-surface-raised rounded px-1 py-px\">\n {badge}\n </span>\n )}\n {table.rlsEnabled ? (\n <Tooltip title={t(\"studio_rls_enabled\")}>\n <div className=\"w-1.5 h-1.5 rounded-full bg-green-500\"/>\n </Tooltip>\n ) : (\n <Tooltip title={t(\"studio_rls_disabled\")}>\n <div className=\"w-1.5 h-1.5 rounded-full bg-orange-400 opacity-50\"/>\n </Tooltip>\n )}\n <span className=\"text-[10px] opacity-40 group-hover:opacity-100 min-w-[1.2rem] text-right font-medium\">\n {table.policies.length}\n </span>\n </div>\n </div>\n );\n}\n\nexport const RLSEditor = ({ apiUrl = \"\" }: { apiUrl?: string }) => {\n const { databaseAdmin } = useRebaseContext();\n const snackbarController = useSnackbarController();\n // The tables the server declares, with the policies it compiles for each:\n // the server is the one compiler, this editor only compares its answer\n // with what Postgres holds.\n const descriptors = useTableDescriptors();\n const schemaProblem = schemaSourceProblem(descriptors);\n const declaredTables = descriptors.tables;\n const { codebase: hasCodebase } = useStudioCapabilities();\n const apiConfig = useApiConfig();\n /* `apiUrl` is a bare origin; the routes live under the backend's\n `basePath`, which is `/api` only by default. */\n const apiBase = useApiBase() ?? `${apiUrl.replace(/\\/+$/, \"\")}/api`;\n\n const schemaEditing = useStudioSchemaEditing();\n\n /**\n * Through the plan/apply dialog when there is one — see `saveRules`. A\n * save changes the source the served tables come from, so they are asked\n * for again: the declared side of the list follows the edit.\n */\n const reloadDeclared = descriptors.reload;\n\n /**\n * Saving rules on a table that inherits them from `defaultRls` detaches it\n * into rules of its own: asked here, never done silently. Settled by the\n * dialog below — \"OK\" detaches, \"Cancel\" keeps `\"inherit\"`.\n */\n const [detaching, setDetaching] = useState<string | null>(null);\n const settleDetach = useRef<((detach: boolean) => void) | null>(null);\n const confirmDetach = useCallback((slug: string) => new Promise<boolean>(resolve => {\n settleDetach.current?.(false);\n settleDetach.current = resolve;\n setDetaching(slug);\n }), []);\n const answerDetach = useCallback((detach: boolean) => {\n settleDetach.current?.(detach);\n settleDetach.current = null;\n setDetaching(null);\n }, []);\n\n const saveSecurityRules = useCallback(\n async (table: TableDescriptor, securityRules: readonly PolicyRule[]) => {\n await saveRules(\n schemaEditing,\n { apiBase, getAuthToken: apiConfig?.getAuthToken },\n table,\n securityRules,\n { confirmDetach }\n );\n reloadDeclared();\n },\n [apiBase, apiConfig, schemaEditing, reloadDeclared, confirmDetach]);\n\n /** Closing the plan dialog is an answer, not a failure — see `saveRules`. */\n const reportSaveFailure = useCallback((e: unknown) => {\n if (isCancellation(e)) return;\n snackbarController.open({ type: \"error\",\n message: e instanceof Error ? e.message : String(e) });\n }, [snackbarController]);\n\n const [editingPolicy, setEditingPolicy] = useState<ListedPolicy | \"new\" | null>(null);\n\n /**\n * The two destructive actions used `window.confirm`, which is the browser's\n * dialog and not this app's: it cannot be styled, cannot be translated, and\n * is suppressed outright in a sandboxed iframe — where the click then did\n * the thing silently, with no confirmation at all.\n */\n const [confirmToggleRls, setConfirmToggleRls] = useState<{\n table: string;\n schema: string;\n enabled: boolean;\n /** The server re-asserts this table's RLS on every start, so a disable here does not last. */\n managed: boolean;\n } | null>(null);\n const [confirmDropPolicy, setConfirmDropPolicy] = useState<{ policyName: string; table: string; schema: string } | null>(null);\n const [confirming, setConfirming] = useState(false);\n\n const applyToggleRls = useCallback(async () => {\n if (!confirmToggleRls) return;\n const { table, schema, enabled } = confirmToggleRls;\n const action = enabled ? \"DISABLE\" : \"ENABLE\";\n setConfirming(true);\n try {\n await databaseAdmin!.executeSql!(\n `ALTER TABLE ${quoteIdentifier(schema)}.${quoteIdentifier(table)} ${action} ROW LEVEL SECURITY`\n );\n snackbarController.open({ type: \"success\",\n message: `RLS ${action.toLowerCase()}d on ${table}` });\n setConfirmToggleRls(null);\n fetchRLSData();\n } catch (e: unknown) {\n snackbarController.open({ type: \"error\",\n message: e instanceof Error ? e.message : String(e) });\n } finally {\n setConfirming(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [confirmToggleRls, databaseAdmin, snackbarController]);\n\n const applyDropPolicy = useCallback(async () => {\n if (!confirmDropPolicy) return;\n const { policyName, table, schema } = confirmDropPolicy;\n setConfirming(true);\n try {\n // Its admin-request companion (`USING (true)` for every admin) goes\n // with it, in the same implicit transaction: left behind, it would\n // keep admitting every admin to every row the dropped policy did.\n const target = `${quoteIdentifier(schema)}.${quoteIdentifier(table)}`;\n await databaseAdmin!.executeSql!(\n `DROP POLICY ${quoteIdentifier(policyName)} ON ${target}; ` +\n `DROP POLICY IF EXISTS ${quoteIdentifier(adminRequestPolicyName(policyName))} ON ${target}`\n );\n snackbarController.open({ type: \"success\",\n message: `Policy \"${policyName}\" dropped` });\n setConfirmDropPolicy(null);\n fetchRLSData();\n } catch (e: unknown) {\n snackbarController.open({ type: \"error\",\n message: e instanceof Error ? e.message : String(e) });\n } finally {\n setConfirming(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [confirmDropPolicy, databaseAdmin, snackbarController]);\n\n const { t } = useTranslation();\n\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [tables, setTables] = useState<TableRLSStatus[]>([]);\n const [selectedTable, setSelectedTable] = useState<string | null>(null);\n const [activeTab, setActiveTab] = useState(0);\n const [junctionTableNames, setJunctionTableNames] = useState<Set<string>>(new Set());\n\n /**\n * Native PostgreSQL roles, for the policy editor's `TO` list.\n *\n * `fetchAvailableRoles` and not `fetchApplicationRoles`: a policy's `TO`\n * clause names database roles, and an application role put there produces a\n * policy that either fails to create or matches nothing. The editor falls\n * back to a static pair when the driver cannot answer.\n */\n const [pgRoleOptions, setPgRoleOptions] = useState<string[]>([]);\n\n useEffect(() => {\n let mounted = true;\n if (!databaseAdmin?.fetchAvailableRoles) return;\n databaseAdmin.fetchAvailableRoles()\n .then((roles) => { if (mounted) setPgRoleOptions(roles); })\n .catch((e) => console.error(\"Failed to fetch database roles\", e));\n return () => { mounted = false; };\n }, [databaseAdmin]);\n\n const [sidebarSize, setSidebarSize] = useState(() => {\n try {\n const saved = localStorage.getItem(\"rebase_rls_editor_sidebar_size\");\n return saved !== null ? parseFloat(saved) : 20;\n } catch (e) {\n return 20;\n }\n });\n\n const [expandedSections, setExpandedSections] = useState<Record<string, boolean>>({\n collection: true,\n other: true,\n internal: false\n });\n\n // Sidebar tab: \"tables\" or \"info\"\n const [sidebarTab, setSidebarTab] = useState<\"tables\" | \"info\">(\"tables\");\n\n useEffect(() => {\n try {\n localStorage.setItem(\"rebase_rls_editor_sidebar_size\", sidebarSize.toString());\n } catch (e) { /* ignore */ }\n }, [sidebarSize]);\n\n const fetchRLSData = useCallback(async () => {\n if (!databaseAdmin?.executeSql) {\n setError(t(\"studio_sql_sql_not_supported\"));\n setIsLoading(false);\n return;\n }\n\n setIsLoading(true);\n setError(null);\n try {\n // 1. Fetch tables and whether RLS is enabled\n const tablesSql = `\n SELECT \n schemaname, \n tablename, \n rowsecurity \n FROM pg_tables \n WHERE schemaname NOT IN ('information_schema', 'pg_catalog')\n ORDER BY schemaname, tablename;\n `;\n const tablesResult = await databaseAdmin!.executeSql!(tablesSql);\n\n // 2. Fetch all policies\n const policiesSql = `\n SELECT \n schemaname,\n tablename,\n policyname,\n permissive,\n roles,\n cmd,\n qual,\n with_check\n FROM pg_policies\n WHERE schemaname NOT IN ('information_schema', 'pg_catalog');\n `;\n const policiesResult = await databaseAdmin!.executeSql!(policiesSql);\n\n const extractRows = (result: unknown): Record<string, unknown>[] => {\n if (result && typeof result === \"object\" && \"rows\" in result && Array.isArray((result as { rows: Record<string, unknown>[] }).rows)) {\n return (result as { rows: Record<string, unknown>[] }).rows;\n }\n if (Array.isArray(result)) return result as Record<string, unknown>[];\n return [];\n };\n\n const tRows = extractRows(tablesResult);\n const pRows = extractRows(policiesResult);\n\n const tableMap: Record<string, TableRLSStatus> = {};\n\n tRows.forEach((tRow: Record<string, unknown>) => {\n const t = tRow as { schemaname?: string, SCHEMANAME?: string, tablename?: string, TABLENAME?: string, rowsecurity?: boolean, ROWSECURITY?: boolean };\n const schema = t.schemaname || t.SCHEMANAME || \"public\";\n const table = t.tablename || t.TABLENAME || \"\";\n const rlsEnabled = t.rowsecurity || t.ROWSECURITY || false;\n\n const key = `${schema}.${table}`;\n tableMap[key] = {\n schemaName: schema,\n tableName: table,\n rlsEnabled: rlsEnabled,\n policies: []\n };\n });\n\n pRows.forEach((pRow: Record<string, unknown>) => {\n const p = pRow as { schemaname?: string, SCHEMANAME?: string, tablename?: string, TABLENAME?: string, roles?: string | string[], ROLES?: string | string[], policyname?: string, POLICYNAME?: string, permissive?: \"PERMISSIVE\" | \"RESTRICTIVE\", PERMISSIVE?: \"PERMISSIVE\" | \"RESTRICTIVE\", cmd?: \"SELECT\" | \"INSERT\" | \"UPDATE\" | \"DELETE\" | \"ALL\", CMD?: \"SELECT\" | \"INSERT\" | \"UPDATE\" | \"DELETE\" | \"ALL\", qual?: string | null, QUAL?: string | null, with_check?: string | null, WITH_CHECK?: string | null };\n const schema = p.schemaname || p.SCHEMANAME || \"public\";\n const table = p.tablename || p.TABLENAME || \"\";\n const key = `${schema}.${table}`;\n\n if (tableMap[key]) {\n const parsedRoles = readPolicyRoles(p.roles || p.ROLES);\n\n tableMap[key].policies.push({\n policyname: p.policyname || p.POLICYNAME || \"\",\n tablename: table,\n permissive: p.permissive || p.PERMISSIVE || \"PERMISSIVE\",\n roles: parsedRoles,\n cmd: p.cmd || p.CMD || \"ALL\",\n qual: p.qual || p.QUAL || null,\n with_check: p.with_check || p.WITH_CHECK || null\n });\n }\n });\n\n const sortedTables = Object.values(tableMap).sort((a, b) => a.tableName.localeCompare(b.tableName));\n setTables(sortedTables);\n\n // Detect junction tables (where all columns are FKs)\n try {\n const junctionResult = await databaseAdmin!.executeSql!(JUNCTION_TABLES_SQL);\n const jRows = extractRows(junctionResult);\n setJunctionTableNames(new Set(\n jRows.map((r: Record<string, unknown>) => r.table_name as string).filter(Boolean)\n ));\n } catch {\n // Junction detection is best-effort\n }\n\n if (sortedTables.length > 0) {\n // Auto-select first public/collection table, skip internal —\n // when nothing is selected yet. Read through the updater, not\n // a dependency: depending on the selection made picking a\n // table re-read the whole catalogue, and the first load (which\n // picks one) run twice.\n const firstUserTable = sortedTables.find(t => !REBASE_INTERNAL_SCHEMAS.includes(t.schemaName)) ?? sortedTables[0];\n setSelectedTable(previous => previous ?? `${firstUserTable.schemaName}.${firstUserTable.tableName}`);\n }\n\n } catch (e: unknown) {\n console.error(\"RLS fetch error:\", e);\n setError(\"Failed to fetch RLS policies: \" + (e instanceof Error ? e.message : String(e)));\n } finally {\n setIsLoading(false);\n }\n }, [databaseAdmin]);\n\n useEffect(() => {\n setEditingPolicy(null);\n }, [selectedTable]);\n\n useEffect(() => {\n fetchRLSData();\n }, [fetchRLSData]);\n\n const activeTableData = useMemo(() => {\n if (!selectedTable) return null;\n return tables.find(t => `${t.schemaName}.${t.tableName}` === selectedTable) || null;\n }, [selectedTable, tables]);\n\n /**\n * Every junction the server derives, with its policies, by\n * `schema.table`. A junction has no descriptor of its own: it is listed\n * under each table that declares a relation through it.\n */\n const servedJunctions = useMemo(() => {\n const junctions = new Map<string, JunctionPolicyDescriptor>();\n for (const table of declaredTables) {\n for (const junction of table.rls.junctions ?? []) {\n junctions.set(`${junction.schema}.${junction.table}`, junction);\n }\n // Without the compiled policies (no `schema:read`) the relation\n // still names its junction: it is still the platform's table.\n for (const relation of table.relations) {\n if (relation.kind !== \"manyToMany\") continue;\n const key = `${table.schema}.${relation.through.table}`;\n if (!junctions.has(key)) junctions.set(key, { table: relation.through.table, schema: table.schema, policies: [] });\n }\n }\n return junctions;\n }, [declaredTables]);\n\n /** Categorize tables into 4 buckets for the sidebar. */\n const categorizedTables = useMemo(() => {\n const groups: Record<TableCategory, TableRLSStatus[]> = {\n collection: [],\n junction: [],\n internal: [],\n other: []\n };\n\n tables.forEach(table => {\n const isMapped = declaredTables.some(descriptor => mapsTable(descriptor, table));\n const isJunction = junctionTableNames.has(table.tableName) || servedJunctions.has(`${table.schemaName}.${table.tableName}`);\n const cat = classifyTableClient(table.tableName, table.schemaName, isJunction, isMapped);\n groups[cat].push(table);\n });\n\n return groups;\n }, [tables, junctionTableNames, servedJunctions, declaredTables]);\n\n /** The table the server declares for the selected one, if any. */\n const activeDescriptor = useMemo(() => {\n if (!activeTableData) return null;\n return declaredTables.find(descriptor => mapsTable(descriptor, activeTableData)) ?? null;\n }, [activeTableData, declaredTables]);\n\n /**\n * The junction a relation derives this table as, when it is one. Its\n * policies are Rebase's — derived from the endpoints' relations — and the\n * server re-creates them on every start, like a declared table's.\n */\n const activeJunction = useMemo(() => {\n if (!activeTableData || activeDescriptor) return null;\n return servedJunctions.get(`${activeTableData.schemaName}.${activeTableData.tableName}`) ?? null;\n }, [activeTableData, activeDescriptor, servedJunctions]);\n\n /** The category of the currently selected table. */\n const activeTableCategory = useMemo((): TableCategory | null => {\n if (!activeTableData) return null;\n const isJunction = Boolean(activeJunction) || junctionTableNames.has(activeTableData.tableName);\n return classifyTableClient(activeTableData.tableName, activeTableData.schemaName, isJunction, Boolean(activeDescriptor));\n }, [activeTableData, activeDescriptor, activeJunction, junctionTableNames]);\n\n /**\n * Whether the server re-asserts this table's RLS on every start: it switches\n * RLS back on and re-creates every policy the project declares for it.\n */\n const activeTableManaged = Boolean(activeDescriptor || activeJunction);\n\n /**\n * What the server says the selected table's policies are — `undefined`\n * when it declares none, or withheld them from this caller.\n */\n const activeDeclared = useMemo((): DeclaredPolicies | undefined => {\n if (activeDescriptor) return declaredPoliciesOf(activeDescriptor.rls);\n // Only from the compiled answer: a junction listed from a relation\n // alone (policies withheld) has nothing to compare against.\n if (activeJunction && activeJunction.policies.length > 0) return { rules: [], policies: activeJunction.policies };\n return undefined;\n }, [activeDescriptor, activeJunction]);\n\n /**\n * The table is declared, but this caller is not shown what it compiles to\n * (no `schema:read`): the list is what the database holds, and nothing is\n * written to the declaration — its raw rules may be redacted.\n */\n const declaredWithheld = activeDescriptor !== null && activeDeclared === undefined;\n\n /** A save to the declaration needs the declaration, and a codebase to write it into. */\n const savesToCodebase = activeDescriptor !== null && hasCodebase;\n\n /**\n * What Postgres enforces on the selected table, and what the code declares\n * that it does not have yet.\n *\n * A policy in both is listed with the *database's* fields, and the\n * declaration rides beside it with where the two differ (`listPolicies`).\n * The declaration's fields in their place would make a policy changed in\n * SQL look exactly like its declaration, and would show every rule written\n * as a structured condition — all of Rebase's own policies — with no USING.\n */\n const mergedPolicies = useMemo((): ListedPolicy[] => {\n if (!activeTableData) return [];\n return listPolicies(activeTableData.policies || [], activeDeclared, activeTableData.tableName)\n .sort((a, b) => a.policyname.localeCompare(b.policyname));\n }, [activeTableData, activeDeclared]);\n\n // Stats for the info tab\n const rlsStats = useMemo(() => {\n const total = tables.length;\n const enabled = tables.filter(t => t.rlsEnabled).length;\n const withPolicies = tables.filter(t => t.policies.length > 0).length;\n const totalPolicies = tables.reduce((sum, t) => sum + t.policies.length, 0);\n return { total,\nenabled,\nwithPolicies,\ntotalPolicies };\n }, [tables]);\n\n const renderPolicyTag = (label: string, value: string) => {\n return (\n <div className=\"flex items-center gap-1.5 px-2 py-1 rounded-md bg-surface-well border border-hairline\">\n <span className=\"text-[10px] uppercase text-text-secondary dark:text-text-secondary-dark font-medium tracking-wider\">\n {label}:\n </span>\n <span className=\"font-mono text-xs text-text-primary dark:text-text-primary-dark break-all\">\n {value}\n </span>\n </div>\n );\n };\n\n return (\n <div className=\"flex h-full w-full bg-surface-card overflow-hidden text-text-primary dark:text-text-primary-dark\">\n <ResizablePanels\n dividerAriaLabel={t(\"resize_sidebar\")}\n orientation=\"horizontal\"\n panelSizePercent={sidebarSize}\n onPanelSizeChange={setSidebarSize}\n minPanelSizePx={220}\n firstPanel={\n <div className={cls(\"flex flex-col h-full w-full bg-surface-card border-r\", defaultBorderMixin)}>\n <Tabs value={sidebarTab} onValueChange={(v) => setSidebarTab(v as \"tables\" | \"info\")} variant=\"boxy\" className=\"border-b border-hairline\">\n <Tab value=\"tables\">Tables</Tab>\n <Tab value=\"info\">Info</Tab>\n </Tabs>\n\n <div className=\"flex-grow overflow-hidden relative\">\n {sidebarTab === \"tables\" && (\n <div className=\"flex flex-col h-full\">\n <div className={cls(\"flex items-center justify-between px-3 py-2 border-b bg-surface-sheet min-h-[48px]\", defaultBorderMixin)}>\n <Typography variant=\"caption\" className=\"font-semibold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark\">\n {t(\"studio_schema_tables\")}\n </Typography>\n <IconButton aria-label={t(\"refresh\")} size=\"small\" onClick={fetchRLSData} title={t(\"refresh\")}>\n <RefreshCwIcon size={iconSize.smallest}/>\n </IconButton>\n </div>\n <div className=\"flex-grow overflow-y-auto no-scrollbar p-1\">\n {isLoading && tables.length === 0 ? (\n <div className=\"flex justify-center p-4\"><CircularProgress size=\"small\"/></div>\n ) : tables.length === 0 ? (\n <div className=\"p-4 text-center\">\n <Typography variant=\"caption\" className=\"text-text-disabled dark:text-text-disabled-dark italic\">{t(\"studio_rls_no_tables\")}</Typography>\n </div>\n ) : (\n <>\n {/* ── Schema Tables ── */}\n {categorizedTables.collection.length > 0 && (\n <SidebarSection\n title=\"Schema Tables\"\n icon={<DatabaseIcon size={12} className=\"text-primary dark:text-primary-light\"/>}\n expanded={expandedSections.collection ?? true}\n onToggle={() => setExpandedSections(prev => ({ ...prev, collection: !(prev.collection ?? true) }))}\n >\n {categorizedTables.collection.map(table => (\n <SidebarTableRow\n key={`${table.schemaName}.${table.tableName}`}\n table={table}\n isSelected={selectedTable === `${table.schemaName}.${table.tableName}`}\n onSelect={() => setSelectedTable(`${table.schemaName}.${table.tableName}`)}\n t={t}\n />\n ))}\n </SidebarSection>\n )}\n\n {/* ── Other Tables (unmapped + junction) ── */}\n {(categorizedTables.other.length > 0 || categorizedTables.junction.length > 0) && (\n <SidebarSection\n title=\"Other Tables\"\n icon={<AlertTriangleIcon size={12} className=\"text-yellow-500 dark:text-yellow-400\"/>}\n expanded={expandedSections.other ?? true}\n onToggle={() => setExpandedSections(prev => ({ ...prev, other: !(prev.other ?? true) }))}\n >\n {categorizedTables.other.map(table => (\n <SidebarTableRow\n key={`${table.schemaName}.${table.tableName}`}\n table={table}\n isSelected={selectedTable === `${table.schemaName}.${table.tableName}`}\n onSelect={() => setSelectedTable(`${table.schemaName}.${table.tableName}`)}\n t={t}\n />\n ))}\n {categorizedTables.junction.map(table => (\n <SidebarTableRow\n key={`${table.schemaName}.${table.tableName}`}\n table={table}\n isSelected={selectedTable === `${table.schemaName}.${table.tableName}`}\n onSelect={() => setSelectedTable(`${table.schemaName}.${table.tableName}`)}\n badge=\"Junction\"\n dimmed\n t={t}\n />\n ))}\n </SidebarSection>\n )}\n\n {/* ── Rebase Internal ── */}\n {categorizedTables.internal.length > 0 && (\n <SidebarSection\n title=\"Rebase Internal\"\n icon={<LockIcon size={12} className=\"text-text-disabled dark:text-text-disabled-dark\"/>}\n expanded={expandedSections.internal ?? false}\n onToggle={() => setExpandedSections(prev => ({ ...prev, internal: !(prev.internal ?? false) }))}\n count={categorizedTables.internal.length}\n >\n {categorizedTables.internal.map(table => (\n <SidebarTableRow\n key={`${table.schemaName}.${table.tableName}`}\n table={table}\n isSelected={selectedTable === `${table.schemaName}.${table.tableName}`}\n onSelect={() => setSelectedTable(`${table.schemaName}.${table.tableName}`)}\n dimmed\n t={t}\n />\n ))}\n </SidebarSection>\n )}\n </>\n )}\n </div>\n </div>\n )}\n\n {sidebarTab === \"info\" && (\n <div className=\"flex flex-col h-full\">\n <div className={cls(\"flex items-center justify-between px-3 py-2 border-b bg-surface-sheet min-h-[48px]\", defaultBorderMixin)}>\n <Typography variant=\"caption\" className=\"font-semibold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark\">\n Overview\n </Typography>\n </div>\n <div className=\"flex-grow overflow-y-auto p-3 space-y-3 no-scrollbar\">\n <div className={cls(\"p-3 rounded-lg border bg-surface-card\", defaultBorderMixin)}>\n <div className=\"flex items-center gap-2 mb-2\">\n <ShieldIcon size={iconSize.smallest} className=\"text-primary\"/>\n <Typography variant=\"body2\" className=\"font-semibold text-[13px]\">RLS Studio</Typography>\n </div>\n <Typography variant=\"caption\" className=\"text-text-secondary dark:text-text-secondary-dark text-xs leading-relaxed block\">\n Manage Row Level Security policies for your PostgreSQL tables. Enable RLS and create fine-grained access policies.\n </Typography>\n </div>\n\n <div className=\"space-y-2\">\n <div className={cls(\"p-2.5 rounded border bg-surface-card flex items-center justify-between\", defaultBorderMixin)}>\n <Typography variant=\"caption\" className=\"text-text-secondary dark:text-text-secondary-dark text-xs\">Total tables</Typography>\n <Typography variant=\"body2\" className=\"font-mono text-[13px] font-medium\">{rlsStats.total}</Typography>\n </div>\n <div className={cls(\"p-2.5 rounded border bg-surface-card flex items-center justify-between\", defaultBorderMixin)}>\n <Typography variant=\"caption\" className=\"text-text-secondary dark:text-text-secondary-dark text-xs\">RLS enabled</Typography>\n <div className=\"flex items-center gap-1.5\">\n <div className=\"w-1.5 h-1.5 rounded-full bg-green-500\"/>\n <Typography variant=\"body2\" className=\"font-mono text-[13px] font-medium\">{rlsStats.enabled}</Typography>\n </div>\n </div>\n <div className={cls(\"p-2.5 rounded border bg-surface-card flex items-center justify-between\", defaultBorderMixin)}>\n <Typography variant=\"caption\" className=\"text-text-secondary dark:text-text-secondary-dark text-xs\">Tables with policies</Typography>\n <Typography variant=\"body2\" className=\"font-mono text-[13px] font-medium\">{rlsStats.withPolicies}</Typography>\n </div>\n <div className={cls(\"p-2.5 rounded border bg-surface-card flex items-center justify-between\", defaultBorderMixin)}>\n <Typography variant=\"caption\" className=\"text-text-secondary dark:text-text-secondary-dark text-xs\">Total policies</Typography>\n <Typography variant=\"body2\" className=\"font-mono text-[13px] font-medium\">{rlsStats.totalPolicies}</Typography>\n </div>\n </div>\n\n {/* Security health indicators */}\n {rlsStats.total - rlsStats.enabled > 0 && (\n <div className={cls(\"p-2.5 rounded border border-yellow-200 dark:border-yellow-900/50 bg-yellow-50 dark:bg-yellow-900/20 flex items-start gap-2\", defaultBorderMixin)}>\n <AlertTriangleIcon size={14} className=\"text-yellow-600 dark:text-yellow-500 mt-0.5 shrink-0\"/>\n <div>\n <Typography variant=\"caption\" className=\"text-yellow-800 dark:text-yellow-400 text-xs font-semibold block\">\n {rlsStats.total - rlsStats.enabled} table{rlsStats.total - rlsStats.enabled > 1 ? \"s\" : \"\"} without RLS\n </Typography>\n <Typography variant=\"caption\" className=\"text-yellow-700 dark:text-yellow-600 text-xs block mt-0.5\">\n These tables have no row-level access control. If auth enforcement is disabled, data may be publicly accessible.\n </Typography>\n </div>\n </div>\n )}\n\n {rlsStats.enabled > 0 && rlsStats.enabled - rlsStats.withPolicies > 0 && (\n <div className={cls(\"p-2.5 rounded border border-blue-200 dark:border-blue-900/50 bg-blue-50 dark:bg-blue-900/20 flex items-start gap-2\", defaultBorderMixin)}>\n <ShieldIcon size={14} className=\"text-blue-600 dark:text-blue-400 mt-0.5 shrink-0\"/>\n <div>\n <Typography variant=\"caption\" className=\"text-blue-800 dark:text-blue-300 text-xs font-semibold block\">\n {rlsStats.enabled - rlsStats.withPolicies} table{rlsStats.enabled - rlsStats.withPolicies > 1 ? \"s\" : \"\"} with RLS but no policies\n </Typography>\n <Typography variant=\"caption\" className=\"text-blue-700 dark:text-blue-500 text-xs block mt-0.5\">\n RLS is enabled but no permissive policies exist. All access is denied by default (Postgres deny-all).\n </Typography>\n </div>\n </div>\n )}\n </div>\n </div>\n )}\n </div>\n </div>\n }\n secondPanel={\n <div className=\"flex-grow flex flex-col min-w-0 h-full w-full bg-surface-card\">\n {/* Toolbar Header matching SQL/JS Editor style */}\n <div className={cls(\"flex items-center justify-between pr-2 border-b bg-surface-card min-h-[46px]\", defaultBorderMixin)}>\n <div className=\"flex items-center flex-grow overflow-hidden px-4\">\n <Typography variant=\"subtitle2\" className=\"font-mono text-text-secondary dark:text-text-secondary-dark truncate\">\n {activeTableData ? `${activeTableData.schemaName}.${activeTableData.tableName}` : t(\"studio_rls_select_table\")}\n </Typography>\n {activeTableData && (\n <div className=\"ml-3\">\n {activeTableData.rlsEnabled ? (\n <Chip size=\"smallest\" className=\"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400 border-green-200 dark:border-green-800\">{t(\"studio_rls_enabled\")}</Chip>\n ) : (\n <Chip size=\"smallest\" className=\"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400 border-yellow-200 dark:border-yellow-800\">{t(\"studio_rls_disabled\")}</Chip>\n )}\n </div>\n )}\n </div>\n <div className=\"flex shrink-0 items-center justify-end gap-1.5\">\n {activeTableData && (\n <>\n <Button\n variant=\"text\"\n size=\"small\"\n onClick={() => setConfirmToggleRls({\n table: activeTableData.tableName,\n schema: activeTableData.schemaName,\n enabled: activeTableData.rlsEnabled,\n managed: activeTableManaged\n })}\n >\n {activeTableData.rlsEnabled ? t(\"studio_rls_disable_rls\") : t(\"studio_rls_enable_rls\")}\n </Button>\n\n <div className=\"h-4 w-px bg-hairline mx-1\"/>\n\n <Button\n variant=\"text\"\n size=\"small\"\n onClick={fetchRLSData}\n startIcon={<RefreshCwIcon size={iconSize.smallest}/>}\n >\n Refresh\n </Button>\n\n <div className=\"h-4 w-px bg-hairline mx-1\"/>\n\n <Button\n size=\"small\"\n color=\"primary\"\n onClick={() => setEditingPolicy(\"new\")}\n >\n {t(\"studio_rls_create_policy\")}\n </Button>\n </>\n )}\n </div>\n </div>\n\n {isLoading && !activeTableData ? (\n <div className=\"flex-grow flex items-center justify-center h-full\">\n <CircularProgress size=\"small\"/>\n </div>\n ) : error ? (\n <div className=\"p-6 h-full flex items-center justify-center\">\n <ErrorView title={t(\"studio_rls_error\")} error={error} onRetry={fetchRLSData}/>\n </div>\n ) : !activeTableData ? (\n <div className=\"flex-grow flex items-center justify-center text-text-disabled h-full\">\n <div className=\"text-center\">\n <svg className=\"w-12 h-12 mx-auto mb-4 opacity-50\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={1} d=\"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z\"/></svg>\n <Typography variant=\"body2\">{t(\"studio_rls_select_table\")}</Typography>\n </div>\n </div>\n ) : editingPolicy ? (\n <PolicyEditor\n policy={editingPolicy === \"new\" ? undefined : editingPolicy}\n schema={activeTableData.schemaName}\n table={activeTableData.tableName}\n roleOptions={pgRoleOptions}\n onSave={async (newPolicy) => {\n /*\n * Where a policy for a *mapped* table belongs depends\n * on the host, not on the table.\n *\n * Beside its own source, the collection file is the\n * right home: the rule is checked in, and the next\n * migration applies it. The hosted console has no\n * source — the container is rebuilt from the\n * customer's repository on every deploy — and the\n * schema-editor routes it would POST to are not even\n * mounted, because the framework switches them off\n * under NODE_ENV=production, which every tenant runs.\n * So this branch used to make \"Create Policy\" and\n * \"Edit\" fail with \"Failed to save policy\" on every\n * mapped table in the console, which is most of them.\n * There, the database is the only place a policy can\n * live, so write it there — the same path unmapped\n * tables have always used.\n */\n if (savesToCodebase && activeDescriptor) {\n // A declared table: save its rules to the source.\n // The editor edits a `PostgresPolicy`, whose `roles`\n // is the `TO` list — `policyToSecurityRule` files it\n // under `pgRoles`, never `roles`.\n if (declaredWithheld) {\n snackbarController.open({ type: \"error\",\n message: t(\"studio_rls_save_needs_schema_read\", { table: activeTableData.tableName }) });\n return;\n }\n // The rules as written. A table on the project's\n // `defaultRls` serves those rules, and saving one\n // edit writes them into the table as its own.\n const existingRules: readonly SecurityRule[] = activeDescriptor.rls.rules;\n let newRules: PolicyRule[];\n if (editingPolicy === \"new\") {\n newRules = [...existingRules, policyToSecurityRule(newPolicy)];\n } else {\n // Back to the rule the policy compiles from, or\n // a refusal that says why there is none — never\n // the unchanged rules reported as saved.\n const edit = applyPolicyEdit(existingRules, editingPolicy, newPolicy);\n if (!edit.ok) {\n snackbarController.open({ type: \"error\",\n message: t(POLICY_EDIT_REFUSALS[edit.reason], { policy: editingPolicy.policyname }) });\n return;\n }\n newRules = edit.rules;\n // Nothing the form changed reaches the rule. Saving\n // it would plan an empty change, apply nothing, and\n // still report \"saved\".\n if (JSON.stringify(newRules) === JSON.stringify(existingRules)) {\n snackbarController.open({ type: \"info\",\n message: t(\"studio_rls_nothing_changed\") });\n return;\n }\n }\n\n try {\n await saveSecurityRules(\n // Addressed by its slug: the schema editor\n // finds tables by it, never by the SQL name.\n activeDescriptor,\n newRules\n );\n\n snackbarController.open({ type: \"success\",\nmessage: \"Policy saved successfully\" });\n setEditingPolicy(null);\n fetchRLSData();\n } catch (e: unknown) {\n reportSaveFailure(e);\n }\n } else {\n // No codebase to write to (hosted console), or an\n // unmapped table (internal/junction/other): apply\n // the policy to the database directly.\n //\n // Except a policy Rebase generates. The server\n // re-creates it on its next start, and what the\n // database holds for it is a compiled condition\n // the form only shows as text: rewriting it here\n // is a change that cannot last, and one slip in\n // that text drops the condition — on a restrictive\n // tenancy or auth-write gate, every restriction.\n // The source path refuses the same edit.\n if (editingPolicy !== \"new\" && editingPolicy.generated) {\n snackbarController.open({ type: \"error\",\n message: t(POLICY_EDIT_REFUSALS.generated, { policy: editingPolicy.policyname }) });\n return;\n }\n try {\n const qualifiedTable = `${quoteIdentifier(activeTableData.schemaName)}.${quoteIdentifier(activeTableData.tableName)}`;\n const policyName = quoteIdentifier(newPolicy.policyname || \"unnamed_policy\");\n const cmd = newPolicy.cmd || \"ALL\";\n const permissive = (newPolicy.permissive || \"PERMISSIVE\") === \"PERMISSIVE\" ? \"PERMISSIVE\" : \"RESTRICTIVE\";\n const roles = newPolicy.roles && newPolicy.roles.length > 0\n ? newPolicy.roles.map(r => quoteIdentifier(r)).join(\", \")\n : \"public\";\n\n let sql = `CREATE POLICY ${policyName} ON ${qualifiedTable}`;\n sql += ` AS ${permissive}`;\n sql += ` FOR ${cmd}`;\n sql += ` TO ${roles}`;\n if (newPolicy.qual) sql += ` USING (${newPolicy.qual})`;\n if (newPolicy.with_check) sql += ` WITH CHECK (${newPolicy.with_check})`;\n\n // An edit replaces the policy under the name it\n // *had* — the new one, when it was renamed, drops\n // nothing and leaves the old policy granting\n // beside its replacement.\n //\n // And in the same statement as the CREATE: Postgres\n // runs a multi-statement simple query as one\n // implicit transaction, so a CREATE that fails\n // (a typo in USING) takes the DROP back with it\n // instead of leaving the table without the policy.\n // No explicit BEGIN/COMMIT — on a failure the\n // COMMIT is skipped and the pooled connection is\n // returned inside an aborted transaction.\n if (editingPolicy !== \"new\") {\n const previousName = quoteIdentifier(editingPolicy.policyname);\n // And its admin-request companion: the edit may have\n // narrowed what every admin passes. A server that\n // provisions writes it again if it still applies.\n const companion = quoteIdentifier(adminRequestPolicyName(editingPolicy.policyname));\n sql = `DROP POLICY IF EXISTS ${previousName} ON ${qualifiedTable}; DROP POLICY IF EXISTS ${companion} ON ${qualifiedTable}; ${sql}`;\n }\n\n await databaseAdmin!.executeSql!(sql);\n\n snackbarController.open({ type: \"success\",\nmessage: `Policy \"${newPolicy.policyname}\" applied to the database` });\n setEditingPolicy(null);\n fetchRLSData();\n } catch (e: unknown) {\n snackbarController.open({ type: \"error\",\nmessage: e instanceof Error ? e.message : String(e) });\n }\n }\n }}\n onCancel={() => setEditingPolicy(null)}\n />\n ) : (\n <div className=\"flex-grow flex flex-col overflow-hidden\">\n <div className=\"p-6 pt-4 flex-grow overflow-auto bg-surface-sheet\">\n <div className=\"max-w-4xl mx-auto flex flex-col gap-6\">\n {/* Without the served tables the list is only what the\n database holds: say why, rather than file every table\n under \"Other Tables\" as if the project declared none. */}\n {schemaProblem && <SchemaSourceProblemAlert problem={schemaProblem}/>}\n {activeTableData && declaredWithheld && (\n <Alert color=\"info\">\n <Typography variant=\"caption\">\n {t(\"studio_rls_declared_withheld\", { table: activeTableData.tableName })}\n </Typography>\n </Alert>\n )}\n {/* A table the server re-asserts on every start, where\n this editor writes straight to the database: what is\n changed here does not outlive the next start. Where\n saves go to the source instead, the source is what\n the next start applies. */}\n {activeTableData && activeTableManaged && !savesToCodebase && (\n <Alert color=\"info\">\n <div className=\"flex items-start gap-2\">\n <Typography variant=\"caption\">\n {t(\"studio_rls_reapplied_on_start\", { table: activeTableData.tableName })}\n </Typography>\n </div>\n </Alert>\n )}\n {/* Context-aware banner based on table category */}\n {activeTableData && activeTableCategory === \"internal\" && (\n <Alert color=\"info\">\n <div className=\"flex items-start gap-2\">\n <div>\n <Typography variant=\"body2\" className=\"mb-1 font-semibold\">\n Rebase System Table\n </Typography>\n <Typography variant=\"caption\" className=\"opacity-80\">\n This table is managed internally by Rebase. Its security policies are configured automatically.\n Editing policies on system tables is an advanced operation.\n </Typography>\n </div>\n </div>\n </Alert>\n )}\n {activeTableData && activeTableCategory === \"junction\" && (\n <Alert color=\"info\">\n <div className=\"flex items-start gap-2\">\n <div>\n <Typography variant=\"body2\" className=\"mb-1 font-semibold\">\n Junction Table\n </Typography>\n <Typography variant=\"caption\" className=\"opacity-80\">\n This is an auto-generated junction table for a many-to-many relation.\n Rebase derives its policies: rows are readable when both related rows\n are, and writable following the declaring collection's update rules\n (plus the server/admin baseline). You can still add RLS policies\n directly to broaden access.\n </Typography>\n </div>\n </div>\n </Alert>\n )}\n\n {activeTableData && !activeTableData.rlsEnabled && (\n <div className={cls(\"p-4 sm:p-5 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-900/50 rounded-lg flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between\", defaultBorderMixin)}>\n <div className=\"flex gap-3 items-start\">\n <div className=\"mt-1 bg-yellow-100 dark:bg-yellow-900/50 p-1.5 rounded-md shrink-0 flex items-center justify-center\">\n <AlertTriangleIcon size={iconSize.smallest}/>\n </div>\n <div>\n <Typography variant=\"subtitle2\" className=\"text-yellow-800 dark:text-yellow-500\">\n Row Level Security (RLS) is disabled\n </Typography>\n <Typography variant=\"body2\" className=\"text-yellow-700 dark:text-yellow-600/90 mt-1 max-w-2xl\">\n Your table is completely readable and writable by anyone with access privileges. Enable RLS to create policies that restrict access to specific rows.\n </Typography>\n </div>\n </div>\n <Button\n size=\"medium\"\n variant=\"filled\"\n color=\"neutral\"\n onClick={() => setEditingPolicy(\"new\")}\n className=\"shrink-0 whitespace-nowrap\"\n disabled={!activeDescriptor}\n >\n {t(\"studio_rls_create_policy\")}\n </Button>\n </div>\n )}\n\n {activeTableData && mergedPolicies && mergedPolicies.length > 0 && (\n <div className=\"flex flex-col gap-3\">\n <Typography variant=\"subtitle2\" className=\"text-text-secondary dark:text-text-secondary-dark uppercase tracking-wider mb-1\">{t(\"studio_rls_policies\")}</Typography>\n {mergedPolicies.map(policy => (\n <Paper key={policy.policyname} className={cls(\"p-3 sm:px-4 sm:py-3 flex flex-col sm:flex-row sm:items-center justify-between gap-4 border rounded-lg\", defaultBorderMixin)}>\n <div className=\"flex flex-col gap-2 min-w-0\">\n <div className=\"flex items-center gap-2\">\n <KeyIcon size={iconSize.smallest} className=\"text-text-secondary dark:text-text-secondary-dark shrink-0\"/>\n <Typography variant=\"body2\" className=\"truncate\">{policy.policyname}</Typography>\n {policy.status === \"code_only\" && (\n <Tooltip title={t(\"studio_rls_unapplied_tooltip\")}>\n <div className=\"px-1.5 py-0.5 rounded text-[10px] uppercase bg-primary/10 text-primary border border-primary/20 shrink-0\">\n {t(\"studio_rls_unapplied\")}\n </div>\n </Tooltip>\n )}\n {/* The database holds this policy differently from\n its declaration. Compared as `rebase doctor`\n compares: TO list, command, mode, and whether\n each clause is there — never the clause text,\n which Postgres rewrites. */}\n {policy.drift && policy.drift.length > 0 && (\n <Tooltip title={t(\"studio_rls_drift_tooltip\", { fields: policy.drift.join(\", \") })}>\n <div className=\"px-1.5 py-0.5 rounded text-xs bg-orange-500/10 text-orange-600 border border-orange-500/20 shrink-0\">\n {`${t(\"studio_rls_drift\")}: ${policy.drift.join(\", \")}`}\n </div>\n </Tooltip>\n )}\n {/* \"DB Only\" is a *drift* signal — it means the\n codebase does not declare this policy. Where\n there is no codebase to compare against, every\n policy trivially qualifies, so the badge said\n nothing and said it about everything. */}\n {policy.status === \"live\" && hasCodebase && (\n <Tooltip title=\"This policy is live in the database but missing from your codebase schema.\">\n <div className=\"px-1.5 py-0.5 rounded text-[10px] uppercase bg-orange-500/10 text-orange-600 border border-orange-500/20 shrink-0\">\n DB Only\n </div>\n </Tooltip>\n )}\n </div>\n <div className=\"flex flex-wrap gap-1.5 text-sm\">\n {renderPolicyTag(\"Action\", policy.cmd)}\n {renderPolicyTag(\"Roles\", Array.isArray(policy.roles) ? policy.roles.join(\", \") : policy.roles)}\n </div>\n </div>\n <div className=\"flex gap-2 shrink-0 items-center\">\n {/* Writes a collection source file, so it needs a\n codebase on the other end. In the console the\n endpoint is not mounted and the button 404'd. */}\n {policy.status === \"live\" && savesToCodebase && activeDescriptor && !declaredWithheld && (\n <Button\n size=\"small\"\n variant=\"outlined\"\n color=\"primary\"\n onClick={async () => {\n // A live policy's `roles` is its `TO` list:\n // database roles, so `pgRoles`. Copied into\n // `roles`, `TO public` became an application-role\n // check nobody passes — and on a restrictive\n // policy, which compiles to `NOT (roles) OR …`,\n // a gate everybody passes.\n const rule = policyToSecurityRule(policy);\n\n const newRules: PolicyRule[] = [...activeDescriptor.rls.rules, rule];\n\n try {\n await saveSecurityRules(\n activeDescriptor,\n newRules\n );\n\n snackbarController.open({ type: \"success\",\nmessage: \"Policy imported successfully\" });\n fetchRLSData();\n } catch (e: unknown) {\n reportSaveFailure(e);\n }\n }}\n >\n Import to codebase\n </Button>\n )}\n <Button size=\"small\" variant=\"text\" color=\"primary\" onClick={() => setEditingPolicy(policy)}>\n {t(\"studio_rls_edit\")}\n </Button>\n {policy.status !== \"code_only\" && (\n <Tooltip title={t(\"studio_rls_delete\")} asChild={true}>\n <IconButton aria-label={t(\"studio_rls_delete\")}\n size=\"small\"\n onClick={() => setConfirmDropPolicy({\n policyName: policy.policyname,\n table: activeTableData!.tableName,\n schema: activeTableData!.schemaName\n })}\n >\n <Trash2Icon size={iconSize.smallest}/>\n </IconButton>\n </Tooltip>\n )}\n </div>\n </Paper>\n ))}\n </div>\n )}\n\n {activeTableData && mergedPolicies.length === 0 && activeTableData.rlsEnabled && (\n <div className=\"flex flex-col items-center justify-center py-12 text-center\">\n <ShieldIcon size={40} className=\"text-surface-300 dark:text-surface-600 mb-4\"/>\n <Typography variant=\"subtitle2\" className=\"text-text-secondary dark:text-text-secondary-dark mb-2\">\n No policies defined\n </Typography>\n <Typography variant=\"caption\" className=\"text-text-disabled dark:text-text-disabled-dark max-w-sm mb-4\">\n RLS is enabled on this table but no policies exist. All access is denied by default (Postgres deny-all). Create a policy to allow specific access.\n </Typography>\n <Button\n size=\"small\"\n variant=\"filled\"\n color=\"primary\"\n onClick={() => setEditingPolicy(\"new\")}\n >\n {t(\"studio_rls_create_policy\")}\n </Button>\n </div>\n )}\n\n {activeTableData && mergedPolicies.length === 0 && !activeTableData.rlsEnabled && activeDescriptor && (\n <div className=\"flex flex-col items-center justify-center py-12 text-center\">\n <AlertTriangleIcon size={40} className=\"text-yellow-400 dark:text-yellow-600 mb-4\"/>\n <Typography variant=\"subtitle2\" className=\"text-text-secondary dark:text-text-secondary-dark mb-2\">\n No access control\n </Typography>\n <Typography variant=\"caption\" className=\"text-text-disabled dark:text-text-disabled-dark max-w-sm\">\n This table has neither RLS nor policies. Enable RLS and create policies to restrict row-level access.\n </Typography>\n </div>\n )}\n\n </div>\n </div>\n </div>\n )}\n </div>\n }\n />\n\n <ConfirmationDialog\n open={confirmToggleRls !== null}\n loading={confirming}\n onAccept={applyToggleRls}\n onCancel={() => setConfirmToggleRls(null)}\n title={confirmToggleRls?.enabled\n ? t(\"studio_rls_disable_confirm_title\")\n : t(\"studio_rls_enable_confirm_title\")}\n body={confirmToggleRls?.enabled\n ? [\n t(\"studio_rls_disable_confirm_body\", { table: confirmToggleRls.table }),\n // The server switches a managed table's RLS back on at\n // its next start, so a disable here is temporary.\n confirmToggleRls.managed ? t(\"studio_rls_disable_reapplied\", { table: confirmToggleRls.table }) : \"\"\n ].filter(Boolean).join(\" \")\n : t(\"studio_rls_enable_confirm_body\", { table: confirmToggleRls?.table ?? \"\" })}\n />\n\n <ConfirmationDialog\n open={detaching !== null}\n onAccept={() => answerDetach(true)}\n onCancel={() => answerDetach(false)}\n title={t(\"schema_rules_detach_title\")}\n body={t(\"schema_rules_detach_body\", { table: detaching ?? \"\" })}\n />\n <ConfirmationDialog\n open={confirmDropPolicy !== null}\n loading={confirming}\n onAccept={applyDropPolicy}\n onCancel={() => setConfirmDropPolicy(null)}\n title={t(\"studio_rls_drop_policy_title\")}\n body={t(\"studio_rls_drop_policy_body\", {\n policy: confirmDropPolicy?.policyName ?? \"\",\n table: confirmDropPolicy?.table ?? \"\"\n })}\n />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAaA,IAAa,kBAAmC;CAAC;CAAO;CAAU;CAAU;CAAU;AAAQ;;;;;;;;;;;;;;;;;;;;;;;AAwB9F,IAAa,wBAAwB,CAAC,UAAU,gBAAgB;;;;;;;;;;;;;;;;;;AAmBhE,SAAgB,eACZ,SACA,aACQ;CACR,OAAO,CAAC,mBAAG,IAAI,IAAI;EAAC,GAAG;EAAuB,GAAI,WAAW,CAAC;EAAI,GAAI,eAAe,CAAC;CAAE,CAAC,CAAC;AAC9F;;;;;;;;;;;AAYA,IAAa,gBAAgB,wBAAwB,OAAW,cAAc,CAAC;AAC/E,IAAa,eAAe,wBAAwB,OAAW,aAAa,CAAC,OAAO,CAAC,CAAC;AACtF,IAAa,eAAe,wBACxB,OAAW,QAAQ,OAAW,QAAQ,GAAG,MAAM,OAAW,MAAM,KAAK,CAAC,CAC1E;;;;;;;AAoBA,IAAa,iBAAiC;CAC1C;EACI,IAAI;EACJ,OAA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