@rebasepro/studio 0.21.2-canary.g1ea48be → 0.23.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/dist/{ApiExplorer-D-jLWAaY.js → ApiExplorer-pYMZflL3.js} +2 -5
- package/dist/ApiExplorer-pYMZflL3.js.map +1 -0
- package/dist/{ApiKeysView-OfJLH2x7.js → ApiKeysView-qLSs47tw.js} +3 -3
- package/dist/{ApiKeysView-OfJLH2x7.js.map → ApiKeysView-qLSs47tw.js.map} +1 -1
- package/dist/{CronJobsView-JwRjQCde.js → CronJobsView-7hjgSYId.js} +18 -9
- package/dist/CronJobsView-7hjgSYId.js.map +1 -0
- package/dist/{MonacoEditor-D0_QljcX.js → MonacoEditor-CUxy5_k5.js} +11 -9
- package/dist/MonacoEditor-CUxy5_k5.js.map +1 -0
- package/dist/{RLSEditor-B-qrgdHy.js → RLSEditor-Djh43lBE.js} +118 -26
- package/dist/RLSEditor-Djh43lBE.js.map +1 -0
- package/dist/{SQLEditor-sdtoZv5F.js → SQLEditor-TBw_K6CW.js} +259 -62
- package/dist/SQLEditor-TBw_K6CW.js.map +1 -0
- package/dist/{StorageView-C52dSZNf.js → StorageView-CMG1DOVX.js} +40 -16
- package/dist/StorageView-CMG1DOVX.js.map +1 -0
- package/dist/components/RLSEditor/policyRules.d.ts +49 -0
- package/dist/components/SQLEditor/MonacoEditor.d.ts +13 -1
- package/dist/index.es.js +6 -6
- package/dist/utils/sql_utils.d.ts +49 -0
- package/package.json +9 -9
- package/dist/ApiExplorer-D-jLWAaY.js.map +0 -1
- package/dist/CronJobsView-JwRjQCde.js.map +0 -1
- package/dist/MonacoEditor-D0_QljcX.js.map +0 -1
- package/dist/RLSEditor-B-qrgdHy.js.map +0 -1
- package/dist/SQLEditor-sdtoZv5F.js.map +0 -1
- package/dist/StorageView-C52dSZNf.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageView-CMG1DOVX.js","names":[],"sources":["../src/components/StorageView/StorageView.tsx"],"sourcesContent":["\nimport React, { useState, useEffect, useCallback, useMemo, useRef } from \"react\";\nimport {\n ArrowLeftIcon,\n Button,\n Checkbox,\n CheckIcon,\n Chip,\n CircularProgress,\n cls,\n CopyIcon,\n defaultBorderMixin,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n DownloadIcon,\n FileIcon,\n FileTextIcon,\n FileUpload,\n FolderIcon,\n FolderPlusIcon,\n HomeIcon,\n IconButton,\n iconSize,\n ImageIcon,\n LayoutGridIcon,\n ListIcon,\n LoadingButton,\n Music2Icon,\n PlusIcon,\n RefreshCwIcon,\n ResizablePanels,\n Select,\n SelectItem,\n TextField,\n Tooltip,\n Trash2Icon,\n Typography,\n UploadCloudIcon,\n VideoIcon,\n XIcon\n} from \"@rebasepro/ui\";\nimport { useStorageSource, useStorageSources, useSnackbarController, ErrorView, useApiBase, useApiConfig } from \"@rebasepro/app\";\nimport { DEFAULT_STORAGE_SOURCE_KEY, type StorageListResult } from \"@rebasepro/types\";\nimport { classifyLoadFailure, type LoadFailure } from \"../load-failure\";\nimport { useSearchParams } from \"react-router\";\nimport { useDropzone } from \"react-dropzone\";\n\n// ──────────────────────────────────────────────\n// Types\n// ──────────────────────────────────────────────\n\ninterface StorageFile {\n name: string;\n fullPath: string;\n isFolder: boolean;\n /** Only populated when metadata is fetched */\n size?: number;\n contentType?: string;\n downloadUrl?: string;\n}\n\n// ──────────────────────────────────────────────\n// Helpers\n// ──────────────────────────────────────────────\n\n/**\n * The query parameter holding the folder being browsed.\n *\n * Namespaced because Studio does not always own the URL it renders under: the\n * SaaS console embeds this view in a page that keeps its own state in `?tab=`\n * and `?sub=`, and a bare `path` is a name any host app might already be using.\n */\nconst STORAGE_PATH_PARAM = \"storagePath\";\n\nfunction formatFileSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;\n}\n\nfunction getFileIcon(contentType?: string) {\n if (!contentType) return FileTextIcon;\n if (contentType.startsWith(\"image/\")) return ImageIcon;\n if (contentType.startsWith(\"video/\")) return VideoIcon;\n if (contentType.startsWith(\"audio/\")) return Music2Icon;\n return FileTextIcon;\n}\n\nfunction getExtension(name: string): string {\n const parts = name.split(\".\");\n return parts.length > 1 ? parts[parts.length - 1].toUpperCase() : \"\";\n}\n\nfunction breadcrumbSegments(path: string): { label: string; path: string }[] {\n if (!path || path === \"/\") return [{ label: \"Root\",\npath: \"\" }];\n const parts = path.split(\"/\").filter(Boolean);\n const segments = [{ label: \"Root\",\npath: \"\" }];\n let accumulated = \"\";\n for (const part of parts) {\n accumulated = accumulated ? `${accumulated}/${part}` : part;\n segments.push({ label: part,\npath: accumulated });\n }\n return segments;\n}\n\n// ──────────────────────────────────────────────\n// Upload Dialog\n// ──────────────────────────────────────────────\n\nfunction UploadDialog({\n open,\n currentPath,\n onClose,\n onUpload\n}: {\n open: boolean;\n currentPath: string;\n onClose: () => void;\n onUpload: (files: File[]) => Promise<void>;\n}) {\n const [uploading, setUploading] = useState(false);\n const [selectedFiles, setSelectedFiles] = useState<File[]>([]);\n const [error, setError] = useState<string | null>(null);\n\n const handleFilesAdded = useCallback((files: File[]) => {\n setSelectedFiles(prev => [...prev, ...files]);\n }, []);\n\n const handleRemoveFile = useCallback((index: number) => {\n setSelectedFiles(prev => prev.filter((_, i) => i !== index));\n }, []);\n\n const handleUpload = useCallback(async () => {\n if (selectedFiles.length === 0) return;\n setUploading(true);\n setError(null);\n try {\n await onUpload(selectedFiles);\n setSelectedFiles([]);\n onClose();\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Upload failed\");\n } finally {\n setUploading(false);\n }\n }, [selectedFiles, onUpload, onClose]);\n\n const handleClose = useCallback(() => {\n if (!uploading) {\n setSelectedFiles([]);\n setError(null);\n onClose();\n }\n }, [uploading, onClose]);\n\n return (\n <Dialog open={open} onOpenChange={(o) => !o && handleClose()} maxWidth=\"md\">\n <DialogTitle>\n Upload Files\n <Typography variant=\"caption\" className=\"text-text-secondary dark:text-text-secondary-dark mt-0.5 block\">\n to <span className=\"font-mono text-primary\">/{currentPath || \"root\"}</span>\n </Typography>\n </DialogTitle>\n <DialogContent className=\"space-y-4\">\n <FileUpload\n onFilesAdded={handleFilesAdded}\n size=\"large\"\n uploadDescription={\n <div className=\"flex flex-col items-center justify-center pointer-events-none\">\n <UploadCloudIcon className=\"text-surface-accent-400 mb-2 w-8 h-8\"/>\n <Typography variant=\"label\">\n Drop files here or click to browse\n </Typography>\n <Typography variant=\"caption\" color=\"secondary\">\n Any file type supported\n </Typography>\n </div>\n }\n />\n\n {error && (\n <Typography variant=\"caption\" className=\"text-red-500 block whitespace-pre-line\">\n {error}\n </Typography>\n )}\n\n {selectedFiles.length > 0 && (\n <div className=\"space-y-2\">\n <Typography variant=\"caption\" color=\"secondary\">\n Selected files ({selectedFiles.length})\n </Typography>\n <div className=\"max-h-40 overflow-auto space-y-1\">\n {selectedFiles.map((file, index) => (\n <div\n key={`${file.name}-${index}`}\n className=\"flex items-center justify-between p-2 rounded bg-surface-raised\"\n >\n <div className=\"flex-1 min-w-0 mr-2\">\n <Typography variant=\"body2\" className=\"truncate\">\n {file.name}\n </Typography>\n <Typography variant=\"caption\" color=\"secondary\">\n {formatFileSize(file.size)}\n </Typography>\n </div>\n <IconButton\n size=\"small\"\n onClick={(e) => {\n e.stopPropagation();\n handleRemoveFile(index);\n }}\n disabled={uploading}\n >\n <XIcon size={14}/>\n </IconButton>\n </div>\n ))}\n </div>\n </div>\n )}\n </DialogContent>\n\n <DialogActions>\n <Button variant=\"text\" onClick={handleClose} disabled={uploading}>\n Cancel\n </Button>\n <Button\n variant=\"filled\"\n onClick={handleUpload}\n disabled={selectedFiles.length === 0 || uploading}\n startIcon={uploading ? <CircularProgress size=\"smallest\"/> : <UploadCloudIcon size={14}/>}\n >\n {uploading ? \"Uploading...\" : `Upload${selectedFiles.length > 0 ? ` (${selectedFiles.length})` : \"\"}`}\n </Button>\n </DialogActions>\n </Dialog>\n );\n}\n\n// ──────────────────────────────────────────────\n// FileIcon preview panel\n// ──────────────────────────────────────────────\n\nfunction FilePreviewPanel({\n file,\n onClose,\n onDelete,\n downloadUrl\n}: {\n file: StorageFile;\n onClose: () => void;\n onDelete: () => void;\n downloadUrl: string | null;\n}) {\n const isImage = file.contentType?.startsWith(\"image/\");\n const isVideo = file.contentType?.startsWith(\"video/\");\n const isAudio = file.contentType?.startsWith(\"audio/\");\n const FileIconComponent = getFileIcon(file.contentType);\n const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);\n const [urlCopied, setUrlCopied] = useState(false);\n\n return (\n <>\n <div className={cls(\n \"flex flex-col h-full border-l\",\n defaultBorderMixin,\n \"bg-surface-card\"\n )}>\n {/* Header */}\n <div className={cls(\"flex items-center justify-between p-3 border-b shrink-0\", defaultBorderMixin)}>\n <Typography variant=\"body2\" className=\"font-medium truncate flex-1 mr-2\">\n {file.name}\n </Typography>\n <div className=\"flex items-center gap-0.5\">\n {downloadUrl && (\n <Tooltip title=\"Download\">\n <IconButton\n size=\"small\"\n onClick={() => window.open(downloadUrl, \"_blank\")}\n >\n <DownloadIcon size={iconSize.smallest}/>\n </IconButton>\n </Tooltip>\n )}\n <Tooltip title=\"Delete\">\n <IconButton\n size=\"small\"\n onClick={() => setDeleteDialogOpen(true)}\n className=\"text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20\"\n >\n <Trash2Icon size={iconSize.smallest}/>\n </IconButton>\n </Tooltip>\n <IconButton size=\"small\" onClick={onClose}>\n <XIcon size={iconSize.smallest}/>\n </IconButton>\n </div>\n </div>\n\n {/* Preview */}\n <div className=\"flex-1 overflow-auto\">\n <div className={cls(\"flex flex-col items-center justify-center min-h-[200px] p-4 bg-surface-sheet border-b\", defaultBorderMixin)}>\n {(() => {\n const ext = getExtension(file.name)?.toLowerCase() || \"\";\n const isImage = file.contentType?.startsWith(\"image/\") || [\"jpg\", \"jpeg\", \"png\", \"gif\", \"webp\", \"svg\"].includes(ext);\n const isVideo = file.contentType?.startsWith(\"video/\") || [\"mp4\", \"webm\", \"ogg\", \"mov\"].includes(ext);\n const isAudio = file.contentType?.startsWith(\"audio/\") || [\"mp3\", \"wav\", \"ogg\", \"m4a\"].includes(ext);\n const downloadUrl = file.downloadUrl;\n\n if (isImage && downloadUrl) {\n return (\n <img\n src={downloadUrl}\n alt={file.name}\n className=\"max-w-full max-h-[400px] object-contain rounded-md shadow-sm\"\n />\n );\n } else if (isVideo && downloadUrl) {\n return (\n <video\n src={downloadUrl}\n className=\"max-w-full max-h-[400px] rounded-md\"\n controls\n />\n );\n } else if (isAudio && downloadUrl) {\n return (\n <div className=\"flex flex-col items-center gap-4\">\n <Music2Icon className=\"text-surface-accent-400 w-10 h-10\"/>\n <audio src={downloadUrl} controls className=\"w-full max-w-xs\"/>\n </div>\n );\n } else {\n return (\n <div className=\"flex flex-col items-center gap-3 text-surface-accent-400\">\n <FileIconComponent className=\"w-10 h-10\"/>\n <Typography variant=\"caption\" className=\"text-text-disabled dark:text-text-disabled-dark\">\n No preview available\n </Typography>\n </div>\n );\n }\n })()}\n </div>\n </div>\n\n {/* Metadata */}\n <div className=\"p-4 space-y-3\">\n <div>\n <Typography variant=\"caption\" className=\"text-text-disabled dark:text-text-disabled-dark text-[10px] uppercase tracking-wider font-semibold mb-1 block\">\n File Info\n </Typography>\n </div>\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <Typography variant=\"caption\" className=\"text-surface-accent-500 text-[11px]\">\n Name\n </Typography>\n <Typography variant=\"body2\" className=\"text-[13px] break-all\">\n {file.name}\n </Typography>\n </div>\n <div>\n <Typography variant=\"caption\" className=\"text-surface-accent-500 text-[11px]\">\n Type\n </Typography>\n <Typography variant=\"body2\" className=\"text-[13px]\">\n {file.contentType || \"Unknown\"}\n </Typography>\n </div>\n {file.size !== undefined && (\n <div>\n <Typography variant=\"caption\" className=\"text-surface-accent-500 text-[11px]\">\n Size\n </Typography>\n <Typography variant=\"body2\" className=\"text-[13px]\">\n {formatFileSize(file.size)}\n </Typography>\n </div>\n )}\n <div>\n <Typography variant=\"caption\" className=\"text-surface-accent-500 text-[11px]\">\n Extension\n </Typography>\n <Typography variant=\"body2\" className=\"text-[13px] font-mono\">\n {getExtension(file.name) || \"—\"}\n </Typography>\n </div>\n <div className=\"col-span-2\">\n <Typography variant=\"caption\" className=\"text-surface-accent-500 text-[11px]\">\n Path\n </Typography>\n <Typography variant=\"body2\" className=\"text-[13px] font-mono break-all\">\n {file.fullPath}\n </Typography>\n </div>\n </div>\n\n {downloadUrl && (\n <div className=\"pt-2\">\n <Typography variant=\"caption\" className=\"text-surface-accent-500 text-[11px] block mb-1\">\n URL\n </Typography>\n <div\n className={cls(\n \"flex items-center gap-2 p-2 rounded cursor-pointer transition-colors\",\n \"bg-surface-raised hover:bg-surface-raised-hover\"\n )}\n onClick={() => {\n const fullUrl = downloadUrl.startsWith(\"http\")\n ? downloadUrl\n : `${window.location.origin}${downloadUrl.startsWith(\"/\") ? \"\" : \"/\"}${downloadUrl}`;\n navigator.clipboard.writeText(fullUrl).then(() => {\n setUrlCopied(true);\n setTimeout(() => setUrlCopied(false), 2000);\n });\n }}\n >\n <Typography variant=\"caption\" className=\"font-mono text-[11px] truncate flex-1 min-w-0 text-primary\">\n {(() => {\n const fullUrl = downloadUrl.startsWith(\"http\")\n ? downloadUrl\n : `${window.location.origin}${downloadUrl.startsWith(\"/\") ? \"\" : \"/\"}${downloadUrl}`;\n return fullUrl;\n })()}\n </Typography>\n <Tooltip title={urlCopied ? \"Copied!\" : \"Copy URL\"}>\n <div className=\"shrink-0\">\n {urlCopied\n ? <CheckIcon size={14} className=\"text-green-500\"/>\n : <CopyIcon size={14} className=\"text-surface-accent-400\"/>\n }\n </div>\n </Tooltip>\n </div>\n </div>\n )}\n </div>\n </div>\n\n {/* Delete Confirmation */}\n <Dialog open={deleteDialogOpen} onOpenChange={setDeleteDialogOpen}>\n <DialogTitle hidden>Delete File</DialogTitle>\n <DialogContent>\n <Typography variant=\"subtitle1\" className=\"mb-2\">\n Delete File?\n </Typography>\n <Typography className=\"text-surface-accent-600 dark:text-surface-accent-400\">\n Are you sure you want to delete "{file.name}"?\n This action cannot be undone.\n </Typography>\n </DialogContent>\n <DialogActions>\n <Button variant=\"text\" onClick={() => setDeleteDialogOpen(false)}>\n Cancel\n </Button>\n <Button\n variant=\"filled\"\n color=\"error\"\n onClick={() => {\n setDeleteDialogOpen(false);\n onDelete();\n }}\n >\n Delete\n </Button>\n </DialogActions>\n </Dialog>\n </>\n );\n}\n\n// ──────────────────────────────────────────────\n// Main StorageView Export\n// ──────────────────────────────────────────────\n\nexport const StorageView = () => {\n const defaultStorageSource = useStorageSource();\n const storageSources = useStorageSources();\n const snackbarController = useSnackbarController();\n\n // Available backends to browse. Always includes the default; named\n // sources come from `<Rebase storageSources={...}>`.\n const sourceKeys = useMemo(() => {\n const keys = Object.keys(storageSources.sources);\n if (!keys.includes(DEFAULT_STORAGE_SOURCE_KEY)) keys.unshift(DEFAULT_STORAGE_SOURCE_KEY);\n return keys;\n }, [storageSources.sources]);\n\n const [selectedSourceKey, setSelectedSourceKey] = useState<string>(DEFAULT_STORAGE_SOURCE_KEY);\n\n const storageSource = storageSources.sources[selectedSourceKey] ?? defaultStorageSource;\n\n // Navigation\n const [searchParams, setSearchParams] = useSearchParams();\n // Accepts the historical unqualified `path` so links already shared keep\n // working; only the namespaced one is ever written.\n const currentPath = searchParams.get(STORAGE_PATH_PARAM) ?? searchParams.get(\"path\") ?? \"\";\n const [loading, setLoading] = useState(true);\n /** Why the listing failed, classified — see `load-failure.ts`. */\n const [failure, setFailure] = useState<LoadFailure | null>(null);\n\n // Contents\n const [folders, setFolders] = useState<StorageFile[]>([]);\n const [files, setFiles] = useState<StorageFile[]>([]);\n\n // Selection and preview\n const [selectedFile, setSelectedFile] = useState<StorageFile | null>(null);\n const [selectedDownloadUrl, setSelectedDownloadUrl] = useState<string | null>(null);\n\n // Upload\n const [uploadDialogOpen, setUploadDialogOpen] = useState(false);\n\n // View mode\n const [viewMode, setViewMode] = useState<\"grid\" | \"list\">(\"grid\");\n\n // Multi-selection\n const [selectedPaths, setSelectedPaths] = useState<Set<string>>(new Set());\n const lastClickedRef = useRef<string | null>(null);\n\n // Bulk / folder delete\n const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);\n const [deleteDialogTarget, setDeleteDialogTarget] = useState<\"selection\" | StorageFile | null>(null);\n const [deleting, setDeleting] = useState(false);\n\n // New folder\n const [newFolderDialogOpen, setNewFolderDialogOpen] = useState(false);\n const [newFolderName, setNewFolderName] = useState(\"\");\n const [creatingFolder, setCreatingFolder] = useState(false);\n const apiConfig = useApiConfig();\n const apiBase = useApiBase();\n\n const storageSourceRef = React.useRef(storageSource);\n useEffect(() => {\n storageSourceRef.current = storageSource;\n }, [storageSource]);\n\n // ── Fetch directory contents ──\n const fetchContents = useCallback(async (path: string) => {\n setLoading(true);\n setFailure(null);\n try {\n const result: StorageListResult = await storageSourceRef.current.listObjects(path);\n\n const folderItems: StorageFile[] = (result.prefixes ?? []).map(ref => ({\n name: ref.name,\n fullPath: ref.fullPath,\n isFolder: true\n }));\n\n // Build file items and fetch metadata for each\n const fileItems: StorageFile[] = await Promise.all(\n (result.items ?? []).map(async (ref) => {\n try {\n const downloadConfig = await storageSourceRef.current.getSignedUrl(ref.fullPath);\n return {\n name: ref.name,\n fullPath: ref.fullPath,\n isFolder: false,\n size: downloadConfig.metadata?.size,\n contentType: downloadConfig.metadata?.contentType,\n downloadUrl: downloadConfig.url ?? undefined\n };\n } catch {\n return {\n name: ref.name,\n fullPath: ref.fullPath,\n isFolder: false\n };\n }\n })\n );\n\n setFolders(folderItems);\n setFiles(fileItems);\n } catch (e) {\n console.error(\"Storage list error:\", e);\n // A refusal from the project's own `storageAuthorize` hook is not a\n // fault — see `load-failure.ts`. Rendering both the same way told\n // a customer with a working project that their storage was broken.\n setFailure(classifyLoadFailure(e));\n } finally {\n setLoading(false);\n }\n }, []);\n\n useEffect(() => {\n // `selectedSourceKey` is a dep so switching backend re-lists; the\n // ref-sync effect above runs first, so `storageSourceRef` is current.\n fetchContents(currentPath);\n }, [currentPath, fetchContents, selectedSourceKey]);\n\n // What was previewed and selected belongs to the listing it was picked in.\n const clearSelection = useCallback(() => {\n setSelectedFile(null);\n setSelectedDownloadUrl(null);\n setSelectedPaths(new Set());\n lastClickedRef.current = null;\n }, []);\n\n // Navigate to path\n //\n // Updates only this view's own parameter and leaves the rest of the query\n // string alone. It used to assign the whole thing (`setSearchParams({})`),\n // which is fine when Studio owns the URL but destructive when it is\n // embedded: the SaaS console keeps the open tab in `?tab=`, so opening a\n // folder erased it and bounced the user out of Storage entirely. The key is\n // namespaced for the same reason — a bare `path` is a name a host app can\n // easily be using for something else.\n const handleNavigate = useCallback((path: string) => {\n setSearchParams(prev => {\n const next = new URLSearchParams(prev);\n if (path) next.set(STORAGE_PATH_PARAM, path);\n else next.delete(STORAGE_PATH_PARAM);\n return next;\n }, { replace: true });\n clearSelection();\n }, [setSearchParams, clearSelection]);\n\n // Switching source keeps the folder path, not the files picked in it: the\n // preview's and the selection's actions run through the selected source,\n // so a file opened in one would be deleted, by its path, from the other.\n const handleSourceChange = useCallback((key: string) => {\n setSelectedSourceKey(key);\n clearSelection();\n }, [clearSelection]);\n\n // Navigate up one level\n const handleNavigateUp = useCallback(() => {\n const parts = currentPath.split(\"/\").filter(Boolean);\n parts.pop();\n handleNavigate(parts.join(\"/\"));\n }, [currentPath, handleNavigate]);\n\n // All items (folders + files) in display order, for shift-range select\n const allItems = useMemo(() => [...folders, ...files], [folders, files]);\n\n // ── Multi-select click handler ──\n const handleItemClick = useCallback((item: StorageFile, e: React.MouseEvent) => {\n const path = item.fullPath;\n if (e.metaKey || e.ctrlKey) {\n // Toggle individual item\n setSelectedPaths(prev => {\n const next = new Set(prev);\n if (next.has(path)) next.delete(path);\n else next.add(path);\n return next;\n });\n lastClickedRef.current = path;\n } else if (e.shiftKey && lastClickedRef.current) {\n // Range select\n const allPaths = allItems.map(i => i.fullPath);\n const anchorIdx = allPaths.indexOf(lastClickedRef.current);\n const currentIdx = allPaths.indexOf(path);\n if (anchorIdx >= 0 && currentIdx >= 0) {\n const [start, end] = anchorIdx < currentIdx ? [anchorIdx, currentIdx] : [currentIdx, anchorIdx];\n setSelectedPaths(prev => {\n const next = new Set(prev);\n for (let i = start; i <= end; i++) next.add(allPaths[i]);\n return next;\n });\n }\n } else {\n // Exclusive select\n setSelectedPaths(new Set([path]));\n lastClickedRef.current = path;\n // Also open preview if it's a file\n if (!item.isFolder) {\n setSelectedFile(item);\n if (item.downloadUrl) {\n setSelectedDownloadUrl(item.downloadUrl);\n } else {\n storageSourceRef.current.getSignedUrl(item.fullPath)\n .then(config => setSelectedDownloadUrl(config.url))\n .catch(() => setSelectedDownloadUrl(null));\n }\n } else {\n setSelectedFile(null);\n setSelectedDownloadUrl(null);\n }\n }\n }, [allItems]);\n\n // Double-click: open folder or preview file\n const handleItemDoubleClick = useCallback((item: StorageFile) => {\n if (item.isFolder) {\n handleNavigate(item.fullPath);\n } else {\n setSelectedFile(item);\n if (item.downloadUrl) {\n setSelectedDownloadUrl(item.downloadUrl);\n } else {\n storageSourceRef.current.getSignedUrl(item.fullPath)\n .then(config => setSelectedDownloadUrl(config.url))\n .catch(() => setSelectedDownloadUrl(null));\n }\n }\n }, [handleNavigate]);\n\n // Upload files\n const handleUpload = useCallback(async (uploadFiles: File[]) => {\n for (const file of uploadFiles) {\n const key = currentPath ? `${currentPath}/${file.name}` : file.name;\n await storageSourceRef.current.putObject({\n file,\n key\n });\n }\n snackbarController.open({\n type: \"success\",\n message: `${uploadFiles.length} file${uploadFiles.length > 1 ? \"s\" : \"\"} uploaded successfully`\n });\n await fetchContents(currentPath);\n }, [currentPath, snackbarController, fetchContents]);\n\n // Create new folder\n const handleCreateFolder = useCallback(async () => {\n if (!newFolderName.trim() || !apiConfig?.apiUrl) return;\n\n // Validate folder name\n const name = newFolderName.trim();\n if (name.includes(\"/\") || name.includes(\"\\\\\")) {\n snackbarController.open({ type: \"error\",\nmessage: \"Folder name cannot contain slashes\" });\n return;\n }\n\n // Check if folder already exists\n const existingFolder = folders.find(f => f.name === name);\n if (existingFolder) {\n snackbarController.open({ type: \"error\",\nmessage: `Folder \"${name}\" already exists` });\n return;\n }\n\n setCreatingFolder(true);\n try {\n const folderPath = currentPath ? `default/${currentPath}/${name}` : `default/${name}`;\n const token = apiConfig.getAuthToken ? await apiConfig.getAuthToken() : null;\n const response = await fetch(`${apiBase}/storage/folder`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(token ? { \"Authorization\": `Bearer ${token}` } : {})\n },\n // The selected source, as every other action here routes by\n // it: without `storageId` the folder went to the default\n // backend whichever one was being browsed.\n body: JSON.stringify({\n path: folderPath,\n ...(selectedSourceKey !== DEFAULT_STORAGE_SOURCE_KEY ? { storageId: selectedSourceKey } : {})\n })\n });\n\n if (!response.ok) {\n const err = await response.json().catch(() => ({ error: \"Failed to create folder\" }));\n throw new Error(err.error || \"Failed to create folder\");\n }\n\n snackbarController.open({ type: \"success\",\nmessage: `Folder \"${name}\" created` });\n setNewFolderDialogOpen(false);\n setNewFolderName(\"\");\n await fetchContents(currentPath);\n } catch (e) {\n snackbarController.open({ type: \"error\",\nmessage: e instanceof Error ? e.message : String(e) });\n } finally {\n setCreatingFolder(false);\n }\n }, [newFolderName, currentPath, apiConfig, apiBase, snackbarController, fetchContents, folders, selectedSourceKey]);\n\n // Drag-and-drop on main view\n const handleDropFiles = useCallback(async (droppedFiles: File[]) => {\n if (droppedFiles.length === 0) return;\n try {\n for (const file of droppedFiles) {\n const key = currentPath ? `${currentPath}/${file.name}` : file.name;\n await storageSourceRef.current.putObject({ file,\nkey });\n }\n snackbarController.open({\n type: \"success\",\n message: `${droppedFiles.length} file${droppedFiles.length > 1 ? \"s\" : \"\"} uploaded successfully`\n });\n await fetchContents(currentPath);\n } catch (e) {\n snackbarController.open({\n type: \"error\",\n message: e instanceof Error ? e.message : String(e)\n });\n }\n }, [currentPath, snackbarController, fetchContents]);\n\n const {\n getRootProps: getDropRootProps,\n getInputProps: getDropInputProps,\n isDragActive\n } = useDropzone({\n onDrop: handleDropFiles,\n noClick: true,\n noKeyboard: true,\n noDragEventsBubbling: true\n });\n\n // ── Recursive folder delete helper ──\n const deleteFolderRecursive = useCallback(async (prefix: string) => {\n const result = await storageSourceRef.current.listObjects(prefix);\n // Delete all files in this level\n for (const item of result.items ?? []) {\n await storageSourceRef.current.deleteObject(item.fullPath);\n }\n // Recurse into sub-folders\n for (const sub of result.prefixes ?? []) {\n await deleteFolderRecursive(sub.fullPath);\n }\n // Delete the folder entry itself (needed for local filesystem)\n try {\n await storageSourceRef.current.deleteObject(prefix);\n } catch {\n // Ignore — S3 folders are virtual and may not exist as objects\n }\n }, []);\n\n // Delete a single file\n const handleDeleteFile = useCallback(async (file: StorageFile) => {\n try {\n if (file.isFolder) {\n await deleteFolderRecursive(file.fullPath);\n } else {\n await storageSourceRef.current.deleteObject(file.fullPath);\n }\n snackbarController.open({ type: \"success\",\nmessage: `\"${file.name}\" deleted` });\n setSelectedFile(null);\n setSelectedDownloadUrl(null);\n setSelectedPaths(prev => {\n const next = new Set(prev);\n next.delete(file.fullPath);\n return next;\n });\n fetchContents(currentPath);\n } catch (e) {\n snackbarController.open({ type: \"error\",\nmessage: e instanceof Error ? e.message : String(e) });\n }\n }, [currentPath, snackbarController, fetchContents, deleteFolderRecursive]);\n\n // Bulk delete (selected items)\n const handleBulkDelete = useCallback(async () => {\n setDeleting(true);\n try {\n const items = allItems.filter(i => selectedPaths.has(i.fullPath));\n for (const item of items) {\n if (item.isFolder) {\n await deleteFolderRecursive(item.fullPath);\n } else {\n await storageSourceRef.current.deleteObject(item.fullPath);\n }\n }\n snackbarController.open({ type: \"success\",\nmessage: `${items.length} item${items.length !== 1 ? \"s\" : \"\"} deleted` });\n setSelectedPaths(new Set());\n setSelectedFile(null);\n setSelectedDownloadUrl(null);\n await fetchContents(currentPath);\n } catch (e) {\n snackbarController.open({ type: \"error\",\nmessage: e instanceof Error ? e.message : String(e) });\n } finally {\n setDeleting(false);\n setDeleteDialogOpen(false);\n setDeleteDialogTarget(null);\n }\n }, [allItems, selectedPaths, currentPath, snackbarController, fetchContents, deleteFolderRecursive]);\n\n // Confirm delete for a single file or folder\n const handleConfirmDeleteItem = useCallback(async () => {\n if (!deleteDialogTarget || deleteDialogTarget === \"selection\") return;\n setDeleting(true);\n try {\n if (deleteDialogTarget.isFolder) {\n await deleteFolderRecursive(deleteDialogTarget.fullPath);\n } else {\n await storageSourceRef.current.deleteObject(deleteDialogTarget.fullPath);\n }\n snackbarController.open({ type: \"success\",\nmessage: deleteDialogTarget.isFolder ? `Folder \"${deleteDialogTarget.name}\" deleted` : `\"${deleteDialogTarget.name}\" deleted` });\n if (!deleteDialogTarget.isFolder && selectedFile?.fullPath === deleteDialogTarget.fullPath) {\n setSelectedFile(null);\n setSelectedDownloadUrl(null);\n }\n setSelectedPaths(prev => {\n const next = new Set(prev);\n next.delete(deleteDialogTarget.fullPath);\n return next;\n });\n await fetchContents(currentPath);\n } catch (e) {\n snackbarController.open({ type: \"error\",\nmessage: e instanceof Error ? e.message : String(e) });\n } finally {\n setDeleting(false);\n setDeleteDialogOpen(false);\n setDeleteDialogTarget(null);\n }\n }, [deleteDialogTarget, selectedFile, currentPath, snackbarController, fetchContents, deleteFolderRecursive]);\n\n // Select all / deselect\n const handleSelectAll = useCallback(() => {\n if (selectedPaths.size === allItems.length) {\n setSelectedPaths(new Set());\n } else {\n setSelectedPaths(new Set(allItems.map(i => i.fullPath)));\n }\n }, [allItems, selectedPaths]);\n\n // ── Keyboard shortcuts ──\n useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n // Don't handle shortcuts when a dialog is open\n if (deleteDialogOpen || uploadDialogOpen || newFolderDialogOpen) return;\n // Cmd/Ctrl+A: select all\n if ((e.metaKey || e.ctrlKey) && e.key === \"a\") {\n e.preventDefault();\n handleSelectAll();\n }\n // Escape: deselect\n if (e.key === \"Escape\") {\n setSelectedPaths(new Set());\n setSelectedFile(null);\n setSelectedDownloadUrl(null);\n }\n // Delete / Backspace: delete selected\n if ((e.key === \"Delete\" || e.key === \"Backspace\") && selectedPaths.size > 0 && !e.metaKey && !e.ctrlKey) {\n // Don't trigger if user is typing in an input\n if ((e.target as HTMLElement)?.tagName === \"INPUT\" || (e.target as HTMLElement)?.tagName === \"TEXTAREA\") return;\n e.preventDefault();\n setDeleteDialogTarget(\"selection\");\n setDeleteDialogOpen(true);\n }\n };\n window.addEventListener(\"keydown\", handler);\n return () => window.removeEventListener(\"keydown\", handler);\n }, [handleSelectAll, selectedPaths, deleteDialogOpen, uploadDialogOpen, newFolderDialogOpen]);\n\n // Handle refresh\n const handleRefresh = useCallback(() => {\n fetchContents(currentPath);\n }, [currentPath, fetchContents]);\n\n const segments = breadcrumbSegments(currentPath);\n\n\n // ── Render file grid/list ──\n const renderContents = () => {\n if (loading) {\n return (\n <div className=\"flex-grow flex items-center justify-center\">\n <div className=\"text-center\">\n <CircularProgress size=\"medium\"/>\n <Typography variant=\"body2\" className=\"mt-4 text-text-secondary dark:text-text-secondary-dark font-mono tracking-tight animate-pulse\">\n Loading...\n </Typography>\n </div>\n </div>\n );\n }\n\n if (failure?.kind === \"denied\") {\n return (\n <div className=\"flex-grow flex items-center justify-center p-6 overflow-auto\">\n <div className=\"max-w-md text-center\">\n <Typography variant=\"subtitle2\" className=\"block\">\n This project's storage rules refused this listing\n </Typography>\n <Typography variant=\"body2\" className=\"text-text-secondary dark:text-text-secondary-dark block mt-2\">\n Nothing is wrong with the project. Its <code>storageAuthorize</code> hook\n decides who may read which keys, and it declined this path for the\n signed-in account — commonly because a listing must name a prefix the\n rule recognises rather than the bucket root.\n </Typography>\n <Typography variant=\"caption\" className=\"text-text-disabled dark:text-text-disabled-dark block mt-3 font-mono break-all\">\n {failure.detail}\n </Typography>\n </div>\n </div>\n );\n }\n\n if (failure) {\n return (\n <div className=\"flex-grow flex items-center justify-center p-6 overflow-auto\">\n <ErrorView\n title=\"Could not read this project's storage\"\n error={failure.detail}\n onRetry={failure.retryable ? handleRefresh : undefined}\n />\n </div>\n );\n }\n\n\n if (allItems.length === 0) {\n return (\n <div className=\"flex-grow flex items-center justify-center text-text-disabled dark:text-text-disabled-dark\">\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\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={1} d=\"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z\"/>\n </svg>\n <Typography variant=\"body2\">\n This folder is empty\n </Typography>\n <div className=\"flex items-center gap-2 mt-3\">\n <Button variant=\"text\" onClick={() => {\n setNewFolderName(\"\");\n setNewFolderDialogOpen(true);\n }}>\n <FolderPlusIcon size={iconSize.smallest}/>\n New folder\n </Button>\n <Button onClick={() => setUploadDialogOpen(true)}>\n <PlusIcon size={iconSize.smallest}/>\n Upload files\n </Button>\n </div>\n </div>\n </div>\n );\n }\n\n if (viewMode === \"list\") {\n return (\n <div className=\"flex-grow overflow-auto\">\n <table className=\"w-full\">\n <thead>\n <tr className={cls(\"border-b text-left text-[10px] uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark\", defaultBorderMixin)}>\n <th className=\"pl-3 pr-0 py-2 w-8\">\n <Checkbox\n size=\"small\"\n checked={allItems.length > 0 && selectedPaths.size === allItems.length}\n indeterminate={selectedPaths.size > 0 && selectedPaths.size < allItems.length}\n onCheckedChange={handleSelectAll}\n />\n </th>\n <th className=\"px-2 py-2 font-semibold\">Name</th>\n <th className=\"px-4 py-2 font-semibold w-24\">Type</th>\n <th className=\"px-4 py-2 font-semibold w-24 text-right\">Size</th>\n <th className=\"px-2 py-2 w-10\"/>\n </tr>\n </thead>\n <tbody>\n {folders.map(folder => {\n const isChecked = selectedPaths.has(folder.fullPath);\n return (\n <tr\n key={folder.fullPath}\n data-storage-item\n className={cls(\n \"cursor-pointer transition-colors border-b group\",\n defaultBorderMixin,\n isChecked\n ? \"bg-primary/5 dark:bg-primary/10\"\n : \"hover:bg-surface-hover\"\n )}\n onClick={(e) => handleItemClick(folder, e)}\n onDoubleClick={() => handleItemDoubleClick(folder)}\n >\n <td className=\"pl-3 pr-0 py-2.5\" onClick={(e) => e.stopPropagation()}>\n <Checkbox\n size=\"small\"\n checked={isChecked}\n onCheckedChange={() => {\n setSelectedPaths(prev => {\n const next = new Set(prev);\n if (next.has(folder.fullPath)) next.delete(folder.fullPath);\n else next.add(folder.fullPath);\n return next;\n });\n }}\n />\n </td>\n <td className=\"px-2 py-2.5\">\n <div className=\"flex items-center gap-2\">\n <FolderIcon size={iconSize.smallest} className=\"text-amber-500 dark:text-amber-400 shrink-0\"/>\n <Typography variant=\"body2\" className=\"text-[13px] font-medium truncate\">\n {folder.name}\n </Typography>\n </div>\n </td>\n <td className=\"px-4 py-2.5\">\n <Typography variant=\"caption\" className=\"text-text-secondary dark:text-text-secondary-dark\">\n Folder\n </Typography>\n </td>\n <td className=\"px-4 py-2.5 text-right\">\n <Typography variant=\"caption\" className=\"text-text-disabled dark:text-text-disabled-dark\">\n —\n </Typography>\n </td>\n <td className=\"px-2 py-2.5\"/>\n </tr>\n );\n })}\n {files.map(file => {\n const FileIconComp = getFileIcon(file.contentType);\n const isChecked = selectedPaths.has(file.fullPath);\n return (\n <tr\n key={file.fullPath}\n data-storage-item\n className={cls(\n \"cursor-pointer transition-colors border-b group\",\n defaultBorderMixin,\n isChecked\n ? \"bg-primary/5 dark:bg-primary/10\"\n : \"hover:bg-surface-hover\"\n )}\n onClick={(e) => handleItemClick(file, e)}\n onDoubleClick={() => handleItemDoubleClick(file)}\n >\n <td className=\"pl-3 pr-0 py-2.5\" onClick={(e) => e.stopPropagation()}>\n <Checkbox\n size=\"small\"\n checked={isChecked}\n onCheckedChange={() => {\n setSelectedPaths(prev => {\n const next = new Set(prev);\n if (next.has(file.fullPath)) next.delete(file.fullPath);\n else next.add(file.fullPath);\n return next;\n });\n }}\n />\n </td>\n <td className=\"px-2 py-2.5\">\n <div className=\"flex items-center gap-2\">\n <FileIconComp size={iconSize.smallest} className=\"text-surface-accent-400 shrink-0\"/>\n <Typography variant=\"body2\" className=\"text-[13px] truncate\">\n {file.name}\n </Typography>\n </div>\n </td>\n <td className=\"px-4 py-2.5\">\n <Typography variant=\"caption\" className=\"text-text-secondary dark:text-text-secondary-dark\">\n {getExtension(file.name) || file.contentType?.split(\"/\")[1]?.toUpperCase() || \"—\"}\n </Typography>\n </td>\n <td className=\"px-4 py-2.5 text-right\">\n <Typography variant=\"caption\" className=\"text-text-secondary dark:text-text-secondary-dark font-mono text-[11px]\">\n {file.size !== undefined ? formatFileSize(file.size) : \"—\"}\n </Typography>\n </td>\n <td className=\"px-2 py-2.5\" onClick={(e) => e.stopPropagation()}>\n <IconButton\n size=\"smallest\"\n className=\"opacity-0 group-hover:opacity-100 transition-opacity\"\n onClick={() => {\n setDeleteDialogTarget(file);\n setDeleteDialogOpen(true);\n }}\n >\n <Trash2Icon size={14}/>\n </IconButton>\n </td>\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n }\n\n // Grid view\n return (\n <div className=\"flex-grow overflow-auto p-4\">\n {/* Folder cards */}\n {folders.length > 0 && (\n <div className=\"mb-4\">\n <Typography variant=\"caption\" className=\"text-[10px] uppercase tracking-wider font-semibold text-text-disabled dark:text-text-disabled-dark mb-2 block\">\n Folders\n </Typography>\n <div className=\"grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]\">\n {folders.map(folder => {\n const isChecked = selectedPaths.has(folder.fullPath);\n return (\n <div\n key={folder.fullPath}\n data-storage-item\n className={cls(\n \"rounded-lg p-3 cursor-pointer border\",\n \"transition-colors duration-150\",\n defaultBorderMixin,\n \"hover:bg-surface-hover hover:shadow-sm\",\n \"flex items-center gap-2\",\n isChecked && \"ring-2 ring-primary bg-primary/5 dark:bg-primary/10\"\n )}\n onClick={(e) => handleItemClick(folder, e)}\n onDoubleClick={() => handleItemDoubleClick(folder)}\n >\n <FolderIcon size={iconSize.smallest} className=\"text-amber-500 dark:text-amber-400 shrink-0\"/>\n <Typography variant=\"body2\" className=\"text-[13px] font-medium truncate\">\n {folder.name}\n </Typography>\n </div>\n );\n })}\n </div>\n </div>\n )}\n\n {/* FileIcon cards */}\n {files.length > 0 && (\n <div>\n <Typography variant=\"caption\" className=\"text-[10px] uppercase tracking-wider font-semibold text-text-disabled dark:text-text-disabled-dark mb-2 block\">\n Files ({files.length})\n </Typography>\n <div className=\"grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]\">\n {files.map(file => {\n const FileIconComp = getFileIcon(file.contentType);\n const ext = getExtension(file.name)?.toLowerCase() || \"\";\n const isImage = file.contentType?.startsWith(\"image/\") || [\"jpg\", \"jpeg\", \"png\", \"gif\", \"webp\", \"svg\"].includes(ext);\n const isChecked = selectedPaths.has(file.fullPath);\n\n return (\n <div\n key={file.fullPath}\n data-storage-item\n className={cls(\n \"rounded-lg overflow-hidden cursor-pointer border\",\n \"transition-shadow duration-150\",\n defaultBorderMixin,\n \"hover:shadow-md\",\n isChecked && \"ring-2 ring-primary\"\n )}\n onClick={(e) => handleItemClick(file, e)}\n onDoubleClick={() => handleItemDoubleClick(file)}\n >\n {/* Thumbnail or icon */}\n <div className=\"aspect-square relative overflow-hidden bg-surface-raised flex items-center justify-center\">\n {isImage && file.downloadUrl ? (\n <img\n src={file.downloadUrl}\n alt={file.name}\n className=\"w-full h-full object-cover\"\n loading=\"lazy\"\n />\n ) : (\n <FileIconComp className=\"text-surface-accent-400 dark:text-surface-accent-500 w-8 h-8\"/>\n )}\n\n {/* Extension badge */}\n {getExtension(file.name) && (\n <div className=\"absolute bottom-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase bg-black/50 text-white backdrop-blur-sm\">\n {getExtension(file.name)}\n </div>\n )}\n </div>\n\n {/* Name & size */}\n <div className=\"p-2.5\">\n <Typography variant=\"body2\" className=\"text-[12px] font-medium truncate text-surface-900 dark:text-white\">\n {file.name}\n </Typography>\n <Typography variant=\"caption\" color=\"secondary\" className=\"truncate block mt-0.5 text-[11px]\">\n {file.size !== undefined ? formatFileSize(file.size) : \"—\"}\n </Typography>\n </div>\n </div>\n );\n })}\n </div>\n </div>\n )}\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 <div className=\"flex h-full w-full\">\n {/* Main content */}\n <div className=\"flex-grow flex flex-col min-w-0 h-full\">\n {/* Toolbar */}\n <div className={cls(\"flex items-center justify-between pr-2 border-b bg-surface-card shrink-0 h-10\", defaultBorderMixin)}>\n <div className=\"flex items-center gap-1.5 flex-grow overflow-hidden px-3 py-2\">\n {/* Breadcrumbs — always visible */}\n {currentPath && (\n <Tooltip title=\"Go up\">\n <IconButton size=\"small\" onClick={handleNavigateUp}>\n <ArrowLeftIcon size={iconSize.smallest}/>\n </IconButton>\n </Tooltip>\n )}\n <div className=\"flex items-center gap-0.5 overflow-x-auto no-scrollbar\">\n {segments.map((seg, i) => (\n <React.Fragment key={seg.path}>\n {i > 0 && (\n <Typography variant=\"caption\" className=\"text-text-disabled dark:text-text-disabled-dark mx-0.5\">/</Typography>\n )}\n <Button\n variant=\"text\"\n size=\"small\"\n className={cls(\n \"px-1.5 py-0.5 min-h-0 min-w-0 h-6 text-xs whitespace-nowrap normal-case font-normal\",\n i === segments.length - 1\n ? \"text-text-primary dark:text-text-primary-dark font-medium\"\n : \"text-text-secondary dark:text-text-secondary-dark\"\n )}\n onClick={() => handleNavigate(seg.path)}\n >\n {seg.label}\n </Button>\n </React.Fragment>\n ))}\n </div>\n\n <div className=\"flex-1\"/>\n\n {/* Selection actions or file count */}\n {selectedPaths.size > 0 ? (\n <div className=\"flex items-center gap-1.5 shrink-0\">\n <Typography variant=\"body2\" className=\"text-[13px] font-medium whitespace-nowrap\">\n {selectedPaths.size} selected\n </Typography>\n <Button\n size=\"small\"\n variant=\"text\"\n onClick={() => {\n setDeleteDialogTarget(\"selection\");\n setDeleteDialogOpen(true);\n }}\n >\n <Trash2Icon size={14} className=\"mr-1\"/>\n Delete\n </Button>\n <Button\n size=\"small\"\n variant=\"text\"\n onClick={() => {\n setSelectedPaths(new Set());\n setSelectedFile(null);\n setSelectedDownloadUrl(null);\n }}\n >\n <XIcon size={14} className=\"mr-1\"/>\n Deselect\n </Button>\n </div>\n ) : !loading ? (\n <Chip size=\"small\" className=\"shrink-0 text-[10px]\">\n {files.length} file{files.length !== 1 ? \"s\" : \"\"}\n {folders.length > 0 ? `, ${folders.length} folder${folders.length !== 1 ? \"s\" : \"\"}` : \"\"}\n </Chip>\n ) : null}\n </div>\n\n <div className=\"flex shrink-0 items-center justify-end gap-1.5 pr-1\">\n\n {/* Backend picker — only shown when more than one storage source is available */}\n {sourceKeys.length > 1 && (\n <Select\n size=\"small\"\n position=\"item-aligned\"\n value={selectedSourceKey}\n onValueChange={(value) => {\n if (value && value !== selectedSourceKey) handleSourceChange(value);\n }}\n renderValue={(key) => {\n const label = storageSources.registry[key]?.label;\n return label ?? (key === DEFAULT_STORAGE_SOURCE_KEY ? \"Default\" : key);\n }}>\n {sourceKeys.map((key) => (\n <SelectItem key={key} value={key}>\n {storageSources.registry[key]?.label\n ?? (key === DEFAULT_STORAGE_SOURCE_KEY ? \"Default\" : key)}\n </SelectItem>\n ))}\n </Select>\n )}\n\n <Tooltip title=\"Grid view\">\n <IconButton\n size=\"small\"\n onClick={() => setViewMode(\"grid\")}\n className={cls(viewMode === \"grid\" && \"bg-surface-raised\")}\n >\n <LayoutGridIcon size={iconSize.smallest}/>\n </IconButton>\n </Tooltip>\n <Tooltip title=\"List view\">\n <IconButton\n size=\"small\"\n onClick={() => setViewMode(\"list\")}\n className={cls(viewMode === \"list\" && \"bg-surface-raised\")}\n >\n <ListIcon size={iconSize.smallest}/>\n </IconButton>\n </Tooltip>\n\n <div className={cls(\"h-4 w-px mx-0.5\", defaultBorderMixin, \"bg-surface-raised\")}/>\n\n <Tooltip title=\"Refresh\">\n <IconButton size=\"small\" onClick={handleRefresh} disabled={loading}>\n <RefreshCwIcon size={iconSize.smallest}/>\n </IconButton>\n </Tooltip>\n\n <Tooltip title=\"New folder\">\n <IconButton\n size=\"small\"\n onClick={() => {\n setNewFolderName(\"\");\n setNewFolderDialogOpen(true);\n }}\n >\n <FolderPlusIcon size={iconSize.smallest}/>\n </IconButton>\n </Tooltip>\n <Button\n size=\"small\"\n color=\"primary\"\n onClick={() => setUploadDialogOpen(true)}\n >\n <UploadCloudIcon size={iconSize.smallest} className=\"mr-1\"/>\n Upload\n </Button>\n </div>\n </div>\n\n {/* File grid / list — drop zone */}\n <div {...getDropRootProps()}\n className=\"flex-grow flex flex-col overflow-hidden min-h-0 relative\"\n onClick={(e) => {\n const target = e.target as HTMLElement;\n if (!target.closest(\"[data-storage-item]\") && selectedPaths.size > 0) {\n setSelectedPaths(new Set());\n setSelectedFile(null);\n setSelectedDownloadUrl(null);\n }\n }}\n >\n <input {...getDropInputProps()} />\n {renderContents()}\n {/* Drag overlay */}\n {isDragActive && (\n <div className=\"absolute inset-0 z-10 flex items-center justify-center bg-primary/5 dark:bg-primary/10 backdrop-blur-[2px]\">\n <div className=\"flex flex-col items-center gap-2 p-6 rounded-xl border-2 border-dashed border-primary bg-surface-scrim\">\n <UploadCloudIcon className=\"w-10 h-10 text-primary\"/>\n <Typography variant=\"subtitle2\" className=\"text-primary font-semibold\">\n Drop files to upload\n </Typography>\n <Typography variant=\"caption\" color=\"secondary\">\n to /{currentPath || \"root\"}\n </Typography>\n </div>\n </div>\n )}\n </div>\n\n {/* Status bar */}\n <div className={cls(\"px-4 py-1.5 border-t bg-surface-sheet flex items-center justify-between shrink-0\", defaultBorderMixin)}>\n <div className=\"flex items-center gap-4 text-[11px]\">\n <span className=\"text-text-disabled dark:text-text-disabled-dark font-semibold uppercase tracking-tighter\">\n Path\n </span>\n <span className=\"font-mono text-text-secondary dark:text-text-secondary-dark\">\n /{currentPath || \"\"}\n </span>\n </div>\n {selectedPaths.size > 0 ? (\n <div className=\"text-[11px] text-text-secondary dark:text-text-secondary-dark\">\n {selectedPaths.size} item{selectedPaths.size !== 1 ? \"s\" : \"\"} selected\n </div>\n ) : selectedFile ? (\n <div className=\"text-[11px] text-text-secondary dark:text-text-secondary-dark\">\n Selected: <span className=\"font-mono\">{selectedFile.name}</span>\n </div>\n ) : null}\n </div>\n </div>\n\n {/* Preview panel */}\n {selectedFile && (\n <div className=\"w-80 lg:w-96 shrink-0\">\n <FilePreviewPanel\n file={selectedFile}\n downloadUrl={selectedDownloadUrl}\n onClose={() => {\n setSelectedFile(null);\n setSelectedDownloadUrl(null);\n }}\n onDelete={() => handleDeleteFile(selectedFile)}\n />\n </div>\n )}\n </div>\n\n {/* Upload Dialog */}\n <UploadDialog\n open={uploadDialogOpen}\n currentPath={currentPath}\n onClose={() => setUploadDialogOpen(false)}\n onUpload={handleUpload}\n />\n\n {/* Delete confirmation dialog */}\n <Dialog\n open={deleteDialogOpen}\n onOpenChange={(open) => {\n if (!open && !deleting) {\n setDeleteDialogOpen(false);\n setDeleteDialogTarget(null);\n }\n }}\n >\n <DialogTitle hidden>Delete Confirmation</DialogTitle>\n <DialogContent>\n <Typography variant=\"subtitle1\" className=\"font-semibold mb-2\">\n {deleteDialogTarget === \"selection\"\n ? `Delete ${selectedPaths.size} item${selectedPaths.size !== 1 ? \"s\" : \"\"}?`\n : deleteDialogTarget?.isFolder\n ? `Delete folder \"${deleteDialogTarget.name}\"?`\n : deleteDialogTarget\n ? \"Delete File?\"\n : \"Delete?\"}\n </Typography>\n <Typography variant=\"body2\" color=\"secondary\">\n {deleteDialogTarget === \"selection\"\n ? \"This will permanently delete all selected files and folders, including their contents. This action cannot be undone.\"\n : deleteDialogTarget && !deleteDialogTarget.isFolder\n ? <>Are you sure you want to delete "{deleteDialogTarget.name}"? This action cannot be undone.</>\n : \"This will permanently delete the folder and all of its contents. This action cannot be undone.\"}\n </Typography>\n </DialogContent>\n <DialogActions>\n <Button\n variant=\"text\"\n onClick={() => {\n setDeleteDialogOpen(false);\n setDeleteDialogTarget(null);\n }}\n disabled={deleting}\n >\n Cancel\n </Button>\n <LoadingButton\n color=\"error\"\n loading={deleting}\n onClick={deleteDialogTarget === \"selection\" ? handleBulkDelete : handleConfirmDeleteItem}\n >\n <Trash2Icon size={14} className=\"mr-1\"/>\n Delete\n </LoadingButton>\n </DialogActions>\n </Dialog>\n\n {/* New Folder Dialog */}\n <Dialog\n open={newFolderDialogOpen}\n onOpenChange={(open) => {\n if (!open && !creatingFolder) {\n setNewFolderDialogOpen(false);\n setNewFolderName(\"\");\n }\n }}\n >\n <DialogTitle hidden>New Folder</DialogTitle>\n <DialogContent>\n <TextField\n autoFocus\n size=\"small\"\n label=\"Folder name\"\n value={newFolderName}\n onChange={(e) => setNewFolderName(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && newFolderName.trim()) {\n e.preventDefault();\n handleCreateFolder();\n }\n }}\n disabled={creatingFolder}\n placeholder=\"Enter folder name\"\n />\n {currentPath && (\n <Typography variant=\"caption\" color=\"secondary\" className=\"mt-2\">\n Will be created in <span className=\"font-mono\">/{currentPath}/</span>\n </Typography>\n )}\n </DialogContent>\n <DialogActions>\n <Button\n variant=\"text\"\n onClick={() => {\n setNewFolderDialogOpen(false);\n setNewFolderName(\"\");\n }}\n disabled={creatingFolder}\n >\n Cancel\n </Button>\n <LoadingButton\n color=\"primary\"\n loading={creatingFolder}\n disabled={!newFolderName.trim()}\n onClick={handleCreateFolder}\n >\n <FolderPlusIcon size={14} className=\"mr-1\"/>\n Create\n </LoadingButton>\n </DialogActions>\n </Dialog>\n </div>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U;iBAAhB;QAA4B;QAAE;QAAY;OAAO;QAC5D;OAEL,EAAA,CAAA;KACf,qBAAC,eAAD,EAAA,UAAA,CACI,oBAAC,QAAD;MACI,SAAQ;MACR,eAAe;OACX,uBAAuB,KAAK;OAC5B,iBAAiB,EAAE;MACvB;MACA,UAAU;gBACb;KAEO,CAAA,GACR,qBAAC,eAAD;MACI,OAAM;MACN,SAAS;MACT,UAAU,CAAC,cAAc,KAAK;MAC9B,SAAS;gBAJb,CAMI,oBAAC,gBAAD;OAAgB,MAAM;OAAI,WAAU;MAAO,CAAA,GAAC,QAEjC;OACJ,EAAA,CAAA;IACX;;EACP;;AAEb"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PolicyExpression, PostgresPolicy, SecurityRule, SecurityRuleBase } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* The security-rule fields a {@link PostgresPolicy} describes, and the ones an
|
|
4
|
+
* edit carries over from the rule it changes.
|
|
5
|
+
*
|
|
6
|
+
* Wider than any one `SecurityRule` variant on purpose: an edit starts from the
|
|
7
|
+
* rule as written and deletes and assigns the fields that changed one at a
|
|
8
|
+
* time, and the variants are exclusive about which fields go together.
|
|
9
|
+
*/
|
|
10
|
+
export type PolicyRule = SecurityRuleBase & {
|
|
11
|
+
using?: string;
|
|
12
|
+
withCheck?: string;
|
|
13
|
+
ownerField?: string;
|
|
14
|
+
access?: "public";
|
|
15
|
+
condition?: PolicyExpression;
|
|
16
|
+
check?: PolicyExpression;
|
|
17
|
+
};
|
|
18
|
+
/** Why an edited policy could not be written back to a rule. */
|
|
19
|
+
export type PolicyEditRefusal =
|
|
20
|
+
/** Rebase adds it (the admin baseline, tenancy); no declared rule holds it. */
|
|
21
|
+
"generated"
|
|
22
|
+
/** It exists only in the database. */
|
|
23
|
+
| "not_declared"
|
|
24
|
+
/** Its rule covers several operations, and the policy is one of them. */
|
|
25
|
+
| "several_operations";
|
|
26
|
+
export type PolicyEdit = {
|
|
27
|
+
ok: true;
|
|
28
|
+
rules: PolicyRule[];
|
|
29
|
+
} | {
|
|
30
|
+
ok: false;
|
|
31
|
+
reason: PolicyEditRefusal;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Write an edit of one policy back to the declared rule it compiles from.
|
|
35
|
+
*
|
|
36
|
+
* The rule is found by the policy names it compiles to, not by `rule.name`:
|
|
37
|
+
* an unnamed rule's policy is `<table>_<op>_<hash>`, and a rule over several
|
|
38
|
+
* operations names each `<name>_<op>`. Matching on `name` missed both, saved
|
|
39
|
+
* the rules unchanged and reported success.
|
|
40
|
+
*
|
|
41
|
+
* A rule over several operations is refused rather than split: taking one
|
|
42
|
+
* operation out renames every policy the rule compiles to.
|
|
43
|
+
*
|
|
44
|
+
* @param declared The collection's `securityRules`, as written.
|
|
45
|
+
* @param effective Every rule the generator compiles for the table — the
|
|
46
|
+
* declared ones plus what Rebase adds — to tell a generated
|
|
47
|
+
* policy from one that exists only in the database.
|
|
48
|
+
*/
|
|
49
|
+
export declare function applyPolicyEdit(declared: readonly SecurityRule[], effective: readonly SecurityRule[], tableName: string, original: PostgresPolicy, edited: Partial<PostgresPolicy>): PolicyEdit;
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* What a host can ask of the editor outside its own key bindings.
|
|
4
|
+
*
|
|
5
|
+
* The toolbar's buttons need the selection that Cmd+Enter already reads: a
|
|
6
|
+
* button that runs the whole buffer while the shortcut beside it runs only the
|
|
7
|
+
* highlighted statement is two answers to one question.
|
|
8
|
+
*/
|
|
9
|
+
export interface MonacoEditorHandle {
|
|
10
|
+
/** The selected text, trimmed — `undefined` when nothing is selected. */
|
|
11
|
+
getSelectedText: () => string | undefined;
|
|
12
|
+
}
|
|
2
13
|
export type MonacoEditorProps = {
|
|
14
|
+
ref?: React.Ref<MonacoEditorHandle>;
|
|
3
15
|
value: string;
|
|
4
16
|
onChange: (value: string | undefined) => void;
|
|
5
17
|
onRun?: (selectedText?: string) => void;
|
|
@@ -15,4 +27,4 @@ export type MonacoEditorProps = {
|
|
|
15
27
|
}[];
|
|
16
28
|
}[]>;
|
|
17
29
|
};
|
|
18
|
-
export declare const MonacoEditor: ({ value, onChange, onRun, className, readOnly, autoFocus, schemas }: MonacoEditorProps) => React.JSX.Element;
|
|
30
|
+
export declare const MonacoEditor: ({ ref, value, onChange, onRun, className, readOnly, autoFocus, schemas }: MonacoEditorProps) => React.JSX.Element;
|
package/dist/index.es.js
CHANGED
|
@@ -550,17 +550,17 @@ function SyntaxHighlightedSnippet() {
|
|
|
550
550
|
}
|
|
551
551
|
//#endregion
|
|
552
552
|
//#region src/components/RebaseStudio.tsx
|
|
553
|
-
var SQLEditor = lazyChunk(() => import("./SQLEditor-
|
|
553
|
+
var SQLEditor = lazyChunk(() => import("./SQLEditor-TBw_K6CW.js").then((m) => ({ default: m.SQLEditor })));
|
|
554
554
|
var JSEditor = lazyChunk(() => import("./JSEditor-qiuwmcvk.js").then((m) => ({ default: m.JSEditor })));
|
|
555
|
-
var RLSEditor = lazyChunk(() => import("./RLSEditor-
|
|
556
|
-
var StorageView = lazyChunk(() => import("./StorageView-
|
|
557
|
-
var CronJobsView = lazyChunk(() => import("./CronJobsView-
|
|
555
|
+
var RLSEditor = lazyChunk(() => import("./RLSEditor-Djh43lBE.js").then((m) => ({ default: m.RLSEditor })));
|
|
556
|
+
var StorageView = lazyChunk(() => import("./StorageView-CMG1DOVX.js").then((m) => ({ default: m.StorageView })));
|
|
557
|
+
var CronJobsView = lazyChunk(() => import("./CronJobsView-7hjgSYId.js").then((m) => ({ default: m.CronJobsView })));
|
|
558
558
|
var SchemaVisualizer = lazyChunk(() => import("./SchemaVisualizer-DtDzIUNy.js").then((m) => ({ default: m.SchemaVisualizer })));
|
|
559
559
|
var BranchesView = lazyChunk(() => import("./BranchesView-D6Sz1a5f.js").then((m) => ({ default: m.BranchesView })));
|
|
560
560
|
var BackupsView = lazyChunk(() => import("./BackupsView-DYTAD6aW.js").then((m) => ({ default: m.BackupsView })));
|
|
561
|
-
var ApiExplorer = lazyChunk(() => import("./ApiExplorer-
|
|
561
|
+
var ApiExplorer = lazyChunk(() => import("./ApiExplorer-pYMZflL3.js").then((m) => ({ default: m.ApiExplorer })));
|
|
562
562
|
var LogsExplorer = lazyChunk(() => import("./LogsExplorer-Xq8K4oo6.js").then((m) => ({ default: m.LogsExplorer })));
|
|
563
|
-
var ApiKeysView = lazyChunk(() => import("./ApiKeysView-
|
|
563
|
+
var ApiKeysView = lazyChunk(() => import("./ApiKeysView-qLSs47tw.js").then((m) => ({ default: m.ApiKeysView })));
|
|
564
564
|
/**
|
|
565
565
|
* Declarative component to configure the Studio in Rebase.
|
|
566
566
|
* Renders nothing — purely registers config into the RebaseRegistry.
|
|
@@ -1,11 +1,53 @@
|
|
|
1
1
|
import type { TableInfo } from "../components/SQLEditor/sql_editor_types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The `EXPLAIN` for one statement, or `null` when `sqlText` is not exactly one.
|
|
4
|
+
*
|
|
5
|
+
* Never `ANALYZE`: that executes the statement to time it, so explaining a
|
|
6
|
+
* `DELETE` deleted the rows — without the confirmation "Run" asks for.
|
|
7
|
+
*
|
|
8
|
+
* And never more than one statement. Sent as one simple query, `EXPLAIN (…)
|
|
9
|
+
* SELECT 1; DELETE …` explains the SELECT and *runs* the DELETE. Text the
|
|
10
|
+
* parser cannot read is still explained, as long as no `;` could be hiding a
|
|
11
|
+
* second statement in it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildExplainSql(sqlText: string): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the console's automatic `LIMIT` may be appended to `sqlText`: one
|
|
16
|
+
* top-level SELECT that has no limit of its own.
|
|
17
|
+
*
|
|
18
|
+
* Decided on the parsed statement, not the text. A search for the word SELECT
|
|
19
|
+
* also found it inside `INSERT INTO … SELECT` and `CREATE TABLE … AS SELECT`,
|
|
20
|
+
* which then copied a thousand rows and reported success, and at the start of
|
|
21
|
+
* a script whose last statement the appended `LIMIT` turned into a syntax
|
|
22
|
+
* error. Text the parser cannot read is left as written.
|
|
23
|
+
*/
|
|
24
|
+
export declare function acceptsAutoLimit(sqlText: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether "Run" asks before running `sqlText`: a statement in it deletes or
|
|
27
|
+
* updates without a WHERE of its own, drops or truncates.
|
|
28
|
+
*
|
|
29
|
+
* Decided per parsed statement, not on the text. A search of the text for the
|
|
30
|
+
* word WHERE found it in another statement or in a comment, so `DELETE FROM
|
|
31
|
+
* posts; SELECT * FROM posts WHERE id = 1` deleted every post without asking.
|
|
32
|
+
* Text the parser cannot read is confirmed whenever it names a destructive
|
|
33
|
+
* command.
|
|
34
|
+
*/
|
|
35
|
+
export declare function needsDestructiveConfirmation(sqlText: string): boolean;
|
|
2
36
|
/**
|
|
3
37
|
* A table extracted from a SQL query's FROM/JOIN clauses.
|
|
4
38
|
*/
|
|
5
39
|
export interface ExtractedTable {
|
|
6
40
|
name: string;
|
|
41
|
+
/** The schema the query named, if it named one. */
|
|
42
|
+
schema?: string;
|
|
7
43
|
alias?: string;
|
|
8
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* A table as SQL: `"schema"."table"` when the query named its schema, and a
|
|
47
|
+
* bare `"table"` when it left it to the search path — which then resolves it
|
|
48
|
+
* the same way it resolved the query.
|
|
49
|
+
*/
|
|
50
|
+
export declare function quoteTableName(tableName: string, schemaName?: string): string;
|
|
9
51
|
/**
|
|
10
52
|
* A collection matched to a table in a SQL query.
|
|
11
53
|
*/
|
|
@@ -46,6 +88,13 @@ export interface PKMapping {
|
|
|
46
88
|
}
|
|
47
89
|
export interface TableAndPKResult {
|
|
48
90
|
tableName?: string;
|
|
91
|
+
/**
|
|
92
|
+
* The schema the query named for that table — `undefined` when it named
|
|
93
|
+
* none. Build the UPDATE with {@link quoteTableName}: a bare table name
|
|
94
|
+
* resolves through the search path, which is how editing a row of
|
|
95
|
+
* `archive.orders` used to update `public.orders`.
|
|
96
|
+
*/
|
|
97
|
+
schemaName?: string;
|
|
49
98
|
primaryKeys?: PKMapping[];
|
|
50
99
|
error?: string;
|
|
51
100
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/studio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Rebase Studio — the SQL editor, schema visualiser, RLS policy editor and API explorer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rebase",
|
|
@@ -35,19 +35,19 @@
|
|
|
35
35
|
"pgsql-ast-parser": "12.0.2",
|
|
36
36
|
"prism-react-renderer": "^2.4.1",
|
|
37
37
|
"react-dropzone": "^19.1.1",
|
|
38
|
-
"@rebasepro/
|
|
39
|
-
"@rebasepro/client": "0.
|
|
40
|
-
"@rebasepro/
|
|
41
|
-
"@rebasepro/common": "0.
|
|
42
|
-
"@rebasepro/
|
|
43
|
-
"@rebasepro/
|
|
44
|
-
"@rebasepro/utils": "0.
|
|
38
|
+
"@rebasepro/app": "0.23.0",
|
|
39
|
+
"@rebasepro/client": "0.23.0",
|
|
40
|
+
"@rebasepro/cms-types": "0.23.0",
|
|
41
|
+
"@rebasepro/common": "0.23.0",
|
|
42
|
+
"@rebasepro/types": "0.23.0",
|
|
43
|
+
"@rebasepro/ui": "0.23.0",
|
|
44
|
+
"@rebasepro/utils": "0.23.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^19.2.7",
|
|
48
48
|
"react-dom": "^19.2.7",
|
|
49
49
|
"react-router": "^8.3.0",
|
|
50
|
-
"@rebasepro/cms": "0.
|
|
50
|
+
"@rebasepro/cms": "0.23.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
|
53
53
|
"@rebasepro/cms": {
|