@rebasepro/studio 0.0.1-canary.09e5ec5
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/LICENSE +114 -0
- package/README.md +159 -0
- package/dist/ApiExplorer-gMJt5JrS.js +1053 -0
- package/dist/ApiExplorer-gMJt5JrS.js.map +1 -0
- package/dist/AuthSimulationSelector-BF4rkRGp.js +118 -0
- package/dist/AuthSimulationSelector-BF4rkRGp.js.map +1 -0
- package/dist/BranchesView-DcHZtvXo.js +292 -0
- package/dist/BranchesView-DcHZtvXo.js.map +1 -0
- package/dist/CronJobsView-CijCToeK.js +456 -0
- package/dist/CronJobsView-CijCToeK.js.map +1 -0
- package/dist/JSEditor-D8nVp3Lp.js +1308 -0
- package/dist/JSEditor-D8nVp3Lp.js.map +1 -0
- package/dist/MonacoEditor-CMYEjiRf.js +161 -0
- package/dist/MonacoEditor-CMYEjiRf.js.map +1 -0
- package/dist/RLSEditor-DBH09u9v.js +1831 -0
- package/dist/RLSEditor-DBH09u9v.js.map +1 -0
- package/dist/SQLEditor-CkVx9vgr.js +1792 -0
- package/dist/SQLEditor-CkVx9vgr.js.map +1 -0
- package/dist/SchemaVisualizer-BgD5Zb77.js +1069 -0
- package/dist/SchemaVisualizer-BgD5Zb77.js.map +1 -0
- package/dist/StorageView-CTqGFhY9.js +907 -0
- package/dist/StorageView-CTqGFhY9.js.map +1 -0
- package/dist/common/src/collections/CollectionRegistry.d.ts +56 -0
- package/dist/common/src/collections/index.d.ts +1 -0
- package/dist/common/src/data/buildRebaseData.d.ts +14 -0
- package/dist/common/src/index.d.ts +3 -0
- package/dist/common/src/util/builders.d.ts +57 -0
- package/dist/common/src/util/callbacks.d.ts +6 -0
- package/dist/common/src/util/collections.d.ts +11 -0
- package/dist/common/src/util/common.d.ts +2 -0
- package/dist/common/src/util/conditions.d.ts +26 -0
- package/dist/common/src/util/entities.d.ts +58 -0
- package/dist/common/src/util/enums.d.ts +3 -0
- package/dist/common/src/util/index.d.ts +16 -0
- package/dist/common/src/util/navigation_from_path.d.ts +34 -0
- package/dist/common/src/util/navigation_utils.d.ts +20 -0
- package/dist/common/src/util/parent_references_from_path.d.ts +6 -0
- package/dist/common/src/util/paths.d.ts +14 -0
- package/dist/common/src/util/permissions.d.ts +5 -0
- package/dist/common/src/util/references.d.ts +2 -0
- package/dist/common/src/util/relations.d.ts +22 -0
- package/dist/common/src/util/resolutions.d.ts +72 -0
- package/dist/common/src/util/storage.d.ts +24 -0
- package/dist/core/src/components/AIIcon.d.ts +16 -0
- package/dist/core/src/components/ConfirmationDialog.d.ts +9 -0
- package/dist/core/src/components/Debug/UIReferenceView.d.ts +1 -0
- package/dist/core/src/components/Debug/UIStyleGuide.d.ts +1 -0
- package/dist/core/src/components/ErrorTooltip.d.ts +2 -0
- package/dist/core/src/components/ErrorView.d.ts +21 -0
- package/dist/core/src/components/LanguageToggle.d.ts +1 -0
- package/dist/core/src/components/LoginView/LoginView.d.ts +68 -0
- package/dist/core/src/components/LoginView/index.d.ts +2 -0
- package/dist/core/src/components/NotFoundPage.d.ts +1 -0
- package/dist/core/src/components/RebaseAuth.d.ts +10 -0
- package/dist/core/src/components/RebaseLogo.d.ts +7 -0
- package/dist/core/src/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/core/src/components/UserDisplay.d.ts +7 -0
- package/dist/core/src/components/UserSelectPopover.d.ts +62 -0
- package/dist/core/src/components/UserSettingsView.d.ts +1 -0
- package/dist/core/src/components/common/index.d.ts +6 -0
- package/dist/core/src/components/common/table_height.d.ts +5 -0
- package/dist/core/src/components/common/types.d.ts +63 -0
- package/dist/core/src/components/common/useColumnsIds.d.ts +9 -0
- package/dist/core/src/components/common/useDataTableController.d.ts +45 -0
- package/dist/core/src/components/common/useDebouncedData.d.ts +9 -0
- package/dist/core/src/components/common/useScrollRestoration.d.ts +14 -0
- package/dist/core/src/components/index.d.ts +16 -0
- package/dist/core/src/contexts/AdminModeController.d.ts +4 -0
- package/dist/core/src/contexts/AnalyticsContext.d.ts +3 -0
- package/dist/core/src/contexts/AuthControllerContext.d.ts +3 -0
- package/dist/core/src/contexts/CustomizationControllerContext.d.ts +3 -0
- package/dist/core/src/contexts/DataDriverContext.d.ts +3 -0
- package/dist/core/src/contexts/DatabaseAdminContext.d.ts +3 -0
- package/dist/core/src/contexts/DialogsProvider.d.ts +4 -0
- package/dist/core/src/contexts/EffectiveRoleController.d.ts +4 -0
- package/dist/core/src/contexts/InternalUserManagementContext.d.ts +3 -0
- package/dist/core/src/contexts/ModeController.d.ts +4 -0
- package/dist/core/src/contexts/RebaseClientInstanceContext.d.ts +6 -0
- package/dist/core/src/contexts/RebaseDataContext.d.ts +3 -0
- package/dist/core/src/contexts/SnackbarProvider.d.ts +2 -0
- package/dist/core/src/contexts/StorageSourceContext.d.ts +3 -0
- package/dist/core/src/contexts/UserConfigurationPersistenceContext.d.ts +3 -0
- package/dist/core/src/contexts/index.d.ts +13 -0
- package/dist/core/src/core/PluginLifecycleManager.d.ts +17 -0
- package/dist/core/src/core/PluginProviderStack.d.ts +21 -0
- package/dist/core/src/core/Rebase.d.ts +14 -0
- package/dist/core/src/core/RebaseProps.d.ts +136 -0
- package/dist/core/src/core/RebaseRouter.d.ts +4 -0
- package/dist/core/src/core/RebaseRoutes.d.ts +17 -0
- package/dist/core/src/core/index.d.ts +4 -0
- package/dist/core/src/hooks/ApiConfigContext.d.ts +24 -0
- package/dist/core/src/hooks/data/delete.d.ts +31 -0
- package/dist/core/src/hooks/data/save.d.ts +34 -0
- package/dist/core/src/hooks/data/useCollectionFetch.d.ts +51 -0
- package/dist/core/src/hooks/data/useData.d.ts +13 -0
- package/dist/core/src/hooks/data/useDataOrder.d.ts +12 -0
- package/dist/core/src/hooks/data/useEntityFetch.d.ts +38 -0
- package/dist/core/src/hooks/data/useRelationSelector.d.ts +52 -0
- package/dist/core/src/hooks/data/useUserSelector.d.ts +31 -0
- package/dist/core/src/hooks/index.d.ts +37 -0
- package/dist/core/src/hooks/useAdminModeController.d.ts +19 -0
- package/dist/core/src/hooks/useAnalyticsController.d.ts +5 -0
- package/dist/core/src/hooks/useAuthController.d.ts +11 -0
- package/dist/core/src/hooks/useAuthSubscription.d.ts +2 -0
- package/dist/core/src/hooks/useBackendStorageSource.d.ts +30 -0
- package/dist/core/src/hooks/useBridgeRegistration.d.ts +18 -0
- package/dist/core/src/hooks/useBrowserTitleAndIcon.d.ts +6 -0
- package/dist/core/src/hooks/useBuildAdminModeController.d.ts +6 -0
- package/dist/core/src/hooks/useBuildEffectiveRoleController.d.ts +8 -0
- package/dist/core/src/hooks/useBuildLocalConfigurationPersistence.d.ts +2 -0
- package/dist/core/src/hooks/useBuildModeController.d.ts +6 -0
- package/dist/core/src/hooks/useClipboard.d.ts +57 -0
- package/dist/core/src/hooks/useCollapsedGroups.d.ts +12 -0
- package/dist/core/src/hooks/useCustomizationController.d.ts +11 -0
- package/dist/core/src/hooks/useDialogsController.d.ts +11 -0
- package/dist/core/src/hooks/useEffectiveRoleController.d.ts +7 -0
- package/dist/core/src/hooks/useInternalUserManagementController.d.ts +12 -0
- package/dist/core/src/hooks/useLargeLayout.d.ts +1 -0
- package/dist/core/src/hooks/useModeController.d.ts +19 -0
- package/dist/core/src/hooks/usePermissions.d.ts +12 -0
- package/dist/core/src/hooks/useRebaseClient.d.ts +5 -0
- package/dist/core/src/hooks/useRebaseContext.d.ts +11 -0
- package/dist/core/src/hooks/useRebaseRegistry.d.ts +34 -0
- package/dist/core/src/hooks/useSlot.d.ts +18 -0
- package/dist/core/src/hooks/useSnackbarController.d.ts +20 -0
- package/dist/core/src/hooks/useStorageSource.d.ts +7 -0
- package/dist/core/src/hooks/useStudioBridge.d.ts +91 -0
- package/dist/core/src/hooks/useTranslation.d.ts +17 -0
- package/dist/core/src/hooks/useUnsavedChangesDialog.d.ts +12 -0
- package/dist/core/src/hooks/useUserConfigurationPersistence.d.ts +8 -0
- package/dist/core/src/hooks/useValidateAuthenticator.d.ts +21 -0
- package/dist/core/src/i18n/RebaseI18nProvider.d.ts +33 -0
- package/dist/core/src/index.d.ts +15 -0
- package/dist/core/src/internal/common.d.ts +3 -0
- package/dist/core/src/internal/useRestoreScroll.d.ts +6 -0
- package/dist/core/src/locales/de.d.ts +2 -0
- package/dist/core/src/locales/en.d.ts +10 -0
- package/dist/core/src/locales/es.d.ts +10 -0
- package/dist/core/src/locales/fr.d.ts +2 -0
- package/dist/core/src/locales/hi.d.ts +2 -0
- package/dist/core/src/locales/it.d.ts +2 -0
- package/dist/core/src/locales/pt.d.ts +7 -0
- package/dist/core/src/util/constants.d.ts +1 -0
- package/dist/core/src/util/createFormexStub.d.ts +2 -0
- package/dist/core/src/util/entity_cache.d.ts +27 -0
- package/dist/core/src/util/enums.d.ts +5 -0
- package/dist/core/src/util/icon_list.d.ts +5 -0
- package/dist/core/src/util/icon_synonyms.d.ts +1 -0
- package/dist/core/src/util/icons.d.ts +20 -0
- package/dist/core/src/util/index.d.ts +10 -0
- package/dist/core/src/util/previews.d.ts +4 -0
- package/dist/core/src/util/useStorageUploadController.d.ts +38 -0
- package/dist/core/src/util/useTraceUpdate.d.ts +2 -0
- package/dist/formex/src/Field.d.ts +52 -0
- package/dist/formex/src/Formex.d.ts +7 -0
- package/dist/formex/src/index.d.ts +5 -0
- package/dist/formex/src/types.d.ts +40 -0
- package/dist/formex/src/useCreateFormex.d.ts +14 -0
- package/dist/formex/src/utils.d.ts +16 -0
- package/dist/index.es.js +726 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +9647 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/studio/src/components/ApiExplorer/ApiExplorer.d.ts +9 -0
- package/dist/studio/src/components/ApiExplorer/EndpointDetail.d.ts +9 -0
- package/dist/studio/src/components/ApiExplorer/TryItPanel.d.ts +15 -0
- package/dist/studio/src/components/ApiExplorer/parseSpec.d.ts +16 -0
- package/dist/studio/src/components/ApiExplorer/types.d.ts +90 -0
- package/dist/studio/src/components/AuthSimulationSelector.d.ts +11 -0
- package/dist/studio/src/components/Branches/BranchesView.d.ts +1 -0
- package/dist/studio/src/components/CronJobs/CronJobsView.d.ts +1 -0
- package/dist/studio/src/components/JSEditor/JSEditor.d.ts +1 -0
- package/dist/studio/src/components/JSEditor/JSEditorSidebar.d.ts +21 -0
- package/dist/studio/src/components/JSEditor/JSMonacoEditor.d.ts +18 -0
- package/dist/studio/src/components/RLSEditor/PolicyEditor.d.ts +9 -0
- package/dist/studio/src/components/RLSEditor/RLSEditor.d.ts +19 -0
- package/dist/studio/src/components/RLSEditor/index.d.ts +1 -0
- package/dist/studio/src/components/RebaseStudio.d.ts +2 -0
- package/dist/studio/src/components/SQLEditor/ExplainVisualizer.d.ts +24 -0
- package/dist/studio/src/components/SQLEditor/MonacoEditor.d.ts +17 -0
- package/dist/studio/src/components/SQLEditor/SQLEditor.d.ts +11 -0
- package/dist/studio/src/components/SQLEditor/SQLEditorSidebar.d.ts +21 -0
- package/dist/studio/src/components/SQLEditor/SchemaBrowser.d.ts +8 -0
- package/dist/studio/src/components/SchemaVisualizer/RelationEdge.d.ts +3 -0
- package/dist/studio/src/components/SchemaVisualizer/SchemaVisualizer.d.ts +2 -0
- package/dist/studio/src/components/SchemaVisualizer/TableNode.d.ts +3 -0
- package/dist/studio/src/components/SchemaVisualizer/index.d.ts +5 -0
- package/dist/studio/src/components/SchemaVisualizer/schema-visualizer.utils.d.ts +42 -0
- package/dist/studio/src/components/SchemaVisualizer/useSchemaGraph.d.ts +37 -0
- package/dist/studio/src/components/StorageView/StorageView.d.ts +1 -0
- package/dist/studio/src/components/StudioHomePage.d.ts +9 -0
- package/dist/studio/src/index.d.ts +4 -0
- package/dist/studio/src/utils/entities.d.ts +0 -0
- package/dist/studio/src/utils/pgColumnToProperty.d.ts +6 -0
- package/dist/studio/src/utils/sql_utils.d.ts +52 -0
- package/dist/types/src/controllers/analytics_controller.d.ts +7 -0
- package/dist/types/src/controllers/auth.d.ts +119 -0
- package/dist/types/src/controllers/client.d.ts +170 -0
- package/dist/types/src/controllers/collection_registry.d.ts +45 -0
- package/dist/types/src/controllers/customization_controller.d.ts +60 -0
- package/dist/types/src/controllers/data.d.ts +168 -0
- package/dist/types/src/controllers/data_driver.d.ts +160 -0
- package/dist/types/src/controllers/database_admin.d.ts +11 -0
- package/dist/types/src/controllers/dialogs_controller.d.ts +36 -0
- package/dist/types/src/controllers/effective_role.d.ts +4 -0
- package/dist/types/src/controllers/email.d.ts +34 -0
- package/dist/types/src/controllers/index.d.ts +18 -0
- package/dist/types/src/controllers/local_config_persistence.d.ts +20 -0
- package/dist/types/src/controllers/navigation.d.ts +213 -0
- package/dist/types/src/controllers/registry.d.ts +54 -0
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/types/src/controllers/side_entity_controller.d.ts +90 -0
- package/dist/types/src/controllers/snackbar.d.ts +24 -0
- package/dist/types/src/controllers/storage.d.ts +171 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/rebase_context.d.ts +105 -0
- package/dist/types/src/types/backend.d.ts +536 -0
- package/dist/types/src/types/builders.d.ts +15 -0
- package/dist/types/src/types/chips.d.ts +5 -0
- package/dist/types/src/types/collections.d.ts +856 -0
- package/dist/types/src/types/cron.d.ts +102 -0
- package/dist/types/src/types/data_source.d.ts +64 -0
- package/dist/types/src/types/entities.d.ts +145 -0
- package/dist/types/src/types/entity_actions.d.ts +98 -0
- package/dist/types/src/types/entity_callbacks.d.ts +173 -0
- package/dist/types/src/types/entity_link_builder.d.ts +7 -0
- package/dist/types/src/types/entity_overrides.d.ts +10 -0
- package/dist/types/src/types/entity_views.d.ts +61 -0
- package/dist/types/src/types/export_import.d.ts +21 -0
- package/dist/types/src/types/index.d.ts +23 -0
- package/dist/types/src/types/locales.d.ts +4 -0
- package/dist/types/src/types/modify_collections.d.ts +5 -0
- package/dist/types/src/types/plugins.d.ts +279 -0
- package/dist/types/src/types/properties.d.ts +1176 -0
- package/dist/types/src/types/property_config.d.ts +70 -0
- package/dist/types/src/types/relations.d.ts +336 -0
- package/dist/types/src/types/slots.d.ts +252 -0
- package/dist/types/src/types/translations.d.ts +870 -0
- package/dist/types/src/types/user_management_delegate.d.ts +121 -0
- package/dist/types/src/types/websockets.d.ts +78 -0
- package/dist/types/src/users/index.d.ts +2 -0
- package/dist/types/src/users/roles.d.ts +22 -0
- package/dist/types/src/users/user.d.ts +46 -0
- package/dist/ui/src/components/Alert.d.ts +12 -0
- package/dist/ui/src/components/Autocomplete.d.ts +21 -0
- package/dist/ui/src/components/Avatar.d.ts +11 -0
- package/dist/ui/src/components/Badge.d.ts +8 -0
- package/dist/ui/src/components/BooleanSwitch.d.ts +14 -0
- package/dist/ui/src/components/BooleanSwitchWithLabel.d.ts +17 -0
- package/dist/ui/src/components/Button.d.ts +14 -0
- package/dist/ui/src/components/Card.d.ts +9 -0
- package/dist/ui/src/components/CenteredView.d.ts +9 -0
- package/dist/ui/src/components/Checkbox.d.ts +13 -0
- package/dist/ui/src/components/Chip.d.ts +26 -0
- package/dist/ui/src/components/CircularProgress.d.ts +5 -0
- package/dist/ui/src/components/CircularProgressCenter.d.ts +11 -0
- package/dist/ui/src/components/Collapse.d.ts +9 -0
- package/dist/ui/src/components/ColorPicker.d.ts +30 -0
- package/dist/ui/src/components/Container.d.ts +8 -0
- package/dist/ui/src/components/DateTimeField.d.ts +24 -0
- package/dist/ui/src/components/DebouncedTextField.d.ts +2 -0
- package/dist/ui/src/components/Dialog.d.ts +39 -0
- package/dist/ui/src/components/DialogActions.d.ts +7 -0
- package/dist/ui/src/components/DialogContent.d.ts +7 -0
- package/dist/ui/src/components/DialogTitle.d.ts +10 -0
- package/dist/ui/src/components/ErrorBoundary.d.ts +11 -0
- package/dist/ui/src/components/ExpandablePanel.d.ts +12 -0
- package/dist/ui/src/components/FileUpload.d.ts +23 -0
- package/dist/ui/src/components/IconButton.d.ts +12 -0
- package/dist/ui/src/components/InfoLabel.d.ts +5 -0
- package/dist/ui/src/components/InputLabel.d.ts +11 -0
- package/dist/ui/src/components/Label.d.ts +7 -0
- package/dist/ui/src/components/LoadingButton.d.ts +7 -0
- package/dist/ui/src/components/Markdown.d.ts +10 -0
- package/dist/ui/src/components/Menu.d.ts +23 -0
- package/dist/ui/src/components/Menubar.d.ts +80 -0
- package/dist/ui/src/components/MultiSelect.d.ts +48 -0
- package/dist/ui/src/components/Paper.d.ts +6 -0
- package/dist/ui/src/components/Popover.d.ts +24 -0
- package/dist/ui/src/components/RadioGroup.d.ts +28 -0
- package/dist/ui/src/components/ResizablePanels.d.ts +18 -0
- package/dist/ui/src/components/SearchBar.d.ts +22 -0
- package/dist/ui/src/components/Select.d.ts +43 -0
- package/dist/ui/src/components/Separator.d.ts +5 -0
- package/dist/ui/src/components/Sheet.d.ts +22 -0
- package/dist/ui/src/components/Skeleton.d.ts +6 -0
- package/dist/ui/src/components/Slider.d.ts +21 -0
- package/dist/ui/src/components/Table.d.ts +34 -0
- package/dist/ui/src/components/Tabs.d.ts +19 -0
- package/dist/ui/src/components/TextField.d.ts +58 -0
- package/dist/ui/src/components/TextareaAutosize.d.ts +43 -0
- package/dist/ui/src/components/ToggleButtonGroup.d.ts +30 -0
- package/dist/ui/src/components/Tooltip.d.ts +19 -0
- package/dist/ui/src/components/Typography.d.ts +36 -0
- package/dist/ui/src/components/VirtualTable/VirtualTable.d.ts +11 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableCell.d.ts +21 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableHeader.d.ts +29 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableHeaderRow.d.ts +2 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableProps.d.ts +243 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableRow.d.ts +3 -0
- package/dist/ui/src/components/VirtualTable/index.d.ts +3 -0
- package/dist/ui/src/components/VirtualTable/types.d.ts +38 -0
- package/dist/ui/src/components/common/SelectInputLabel.d.ts +5 -0
- package/dist/ui/src/components/index.d.ts +53 -0
- package/dist/ui/src/hooks/PortalContainerContext.d.ts +31 -0
- package/dist/ui/src/hooks/index.d.ts +6 -0
- package/dist/ui/src/hooks/useDebounceCallback.d.ts +1 -0
- package/dist/ui/src/hooks/useDebounceValue.d.ts +1 -0
- package/dist/ui/src/hooks/useDebouncedCallback.d.ts +1 -0
- package/dist/ui/src/hooks/useInjectStyles.d.ts +7 -0
- package/dist/ui/src/hooks/useOutsideAlerter.d.ts +5 -0
- package/dist/ui/src/icons/GitHubIcon.d.ts +2 -0
- package/dist/ui/src/icons/HandleIcon.d.ts +1 -0
- package/dist/ui/src/icons/Icon.d.ts +20 -0
- package/dist/ui/src/icons/cool_icon_keys.d.ts +1 -0
- package/dist/ui/src/icons/icon_keys.d.ts +1 -0
- package/dist/ui/src/icons/index.d.ts +6 -0
- package/dist/ui/src/index.d.ts +5 -0
- package/dist/ui/src/styles.d.ts +12 -0
- package/dist/ui/src/util/chip_colors.d.ts +4 -0
- package/dist/ui/src/util/cls.d.ts +2 -0
- package/dist/ui/src/util/debounce.d.ts +10 -0
- package/dist/ui/src/util/hash.d.ts +1 -0
- package/dist/ui/src/util/index.d.ts +4 -0
- package/dist/ui/src/util/key_to_icon_component.d.ts +1 -0
- package/package.json +84 -0
- package/src/components/ApiExplorer/ApiExplorer.tsx +290 -0
- package/src/components/ApiExplorer/EndpointDetail.tsx +271 -0
- package/src/components/ApiExplorer/TryItPanel.tsx +510 -0
- package/src/components/ApiExplorer/parseSpec.ts +104 -0
- package/src/components/ApiExplorer/types.ts +84 -0
- package/src/components/AuthSimulationSelector.tsx +77 -0
- package/src/components/Branches/BranchesView.tsx +370 -0
- package/src/components/CronJobs/CronJobsView.tsx +346 -0
- package/src/components/JSEditor/JSEditor.tsx +1033 -0
- package/src/components/JSEditor/JSEditorSidebar.tsx +340 -0
- package/src/components/JSEditor/JSMonacoEditor.tsx +390 -0
- package/src/components/RLSEditor/PolicyEditor.tsx +444 -0
- package/src/components/RLSEditor/RLSEditor.tsx +692 -0
- package/src/components/RLSEditor/index.ts +1 -0
- package/src/components/RebaseStudio.tsx +121 -0
- package/src/components/SQLEditor/ExplainVisualizer.tsx +128 -0
- package/src/components/SQLEditor/MonacoEditor.tsx +203 -0
- package/src/components/SQLEditor/SQLEditor.tsx +1419 -0
- package/src/components/SQLEditor/SQLEditorSidebar.tsx +174 -0
- package/src/components/SQLEditor/SchemaBrowser.tsx +158 -0
- package/src/components/SchemaVisualizer/RelationEdge.tsx +102 -0
- package/src/components/SchemaVisualizer/SchemaVisualizer.tsx +665 -0
- package/src/components/SchemaVisualizer/TableNode.tsx +257 -0
- package/src/components/SchemaVisualizer/index.ts +5 -0
- package/src/components/SchemaVisualizer/schema-visualizer.utils.ts +140 -0
- package/src/components/SchemaVisualizer/useSchemaGraph.ts +397 -0
- package/src/components/StorageView/StorageView.tsx +1035 -0
- package/src/components/StudioHomePage.tsx +357 -0
- package/src/index.ts +31 -0
- package/src/utils/entities.ts +2 -0
- package/src/utils/pgColumnToProperty.test.ts +401 -0
- package/src/utils/pgColumnToProperty.ts +275 -0
- package/src/utils/sql_utils.test.ts +265 -0
- package/src/utils/sql_utils.ts +291 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
import React, { useState, useCallback, useMemo, useEffect, useRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
ReactFlow,
|
|
4
|
+
Controls,
|
|
5
|
+
MiniMap,
|
|
6
|
+
Background,
|
|
7
|
+
BackgroundVariant,
|
|
8
|
+
useReactFlow,
|
|
9
|
+
ReactFlowProvider,
|
|
10
|
+
applyNodeChanges,
|
|
11
|
+
applyEdgeChanges
|
|
12
|
+
} from "@xyflow/react";
|
|
13
|
+
import type { Node, Edge, NodeChange, EdgeChange } from "@xyflow/react";
|
|
14
|
+
import "@xyflow/react/dist/style.css";
|
|
15
|
+
import {
|
|
16
|
+
Typography,
|
|
17
|
+
TextField,
|
|
18
|
+
cls,
|
|
19
|
+
defaultBorderMixin,
|
|
20
|
+
CircularProgress,
|
|
21
|
+
ResizablePanels,
|
|
22
|
+
Tooltip,
|
|
23
|
+
IconButton
|
|
24
|
+
} from "@rebasepro/ui";
|
|
25
|
+
import {
|
|
26
|
+
useStudioCollectionRegistry,
|
|
27
|
+
IconForView
|
|
28
|
+
} from "@rebasepro/core";
|
|
29
|
+
import type { EntityCollection } from "@rebasepro/types";
|
|
30
|
+
import { isPostgresCollection } from "@rebasepro/types";
|
|
31
|
+
import { useSchemaGraph } from "./useSchemaGraph";
|
|
32
|
+
import type { TableNodeData } from "./useSchemaGraph";
|
|
33
|
+
import { TableNode } from "./TableNode";
|
|
34
|
+
import { RelationEdge } from "./RelationEdge";
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// βββ Custom node / edge type registrations ββββββββββββββββββββββββββββ
|
|
38
|
+
|
|
39
|
+
const nodeTypes = {
|
|
40
|
+
tableNode: TableNode
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const edgeTypes = {
|
|
44
|
+
relationEdge: RelationEdge
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// βββ Inner component (needs ReactFlowProvider) βββββββββββββββββββββββββ
|
|
48
|
+
|
|
49
|
+
function SchemaVisualizerCanvas({
|
|
50
|
+
collections
|
|
51
|
+
}: {
|
|
52
|
+
collections: EntityCollection[];
|
|
53
|
+
}) {
|
|
54
|
+
const reactFlowInstance = useReactFlow();
|
|
55
|
+
const {
|
|
56
|
+
nodes: layoutedNodes,
|
|
57
|
+
edges: layoutedEdges,
|
|
58
|
+
direction,
|
|
59
|
+
setDirection,
|
|
60
|
+
relayout,
|
|
61
|
+
tableCount,
|
|
62
|
+
relationCount
|
|
63
|
+
} = useSchemaGraph(collections);
|
|
64
|
+
|
|
65
|
+
const [nodes, setNodes] = useState<Node[]>([]);
|
|
66
|
+
const [edges, setEdges] = useState<Edge[]>([]);
|
|
67
|
+
const [selectedTable, setSelectedTable] = useState<string | null>(null);
|
|
68
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
69
|
+
const initialFitDone = useRef(false);
|
|
70
|
+
|
|
71
|
+
// Sync layouted data into state
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
setNodes(layoutedNodes);
|
|
74
|
+
setEdges(layoutedEdges);
|
|
75
|
+
}, [layoutedNodes, layoutedEdges]);
|
|
76
|
+
|
|
77
|
+
const onNodesChange = useCallback(
|
|
78
|
+
(changes: NodeChange[]) => setNodes((nds) => applyNodeChanges(changes, nds)),
|
|
79
|
+
[]
|
|
80
|
+
);
|
|
81
|
+
const onEdgesChange = useCallback(
|
|
82
|
+
(changes: EdgeChange[]) => setEdges((eds) => applyEdgeChanges(changes, eds)),
|
|
83
|
+
[]
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
// Fit view on first load
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (nodes.length > 0 && !initialFitDone.current) {
|
|
89
|
+
const timer = setTimeout(() => {
|
|
90
|
+
reactFlowInstance.fitView({ padding: 0.15,
|
|
91
|
+
duration: 400 });
|
|
92
|
+
initialFitDone.current = true;
|
|
93
|
+
}, 200);
|
|
94
|
+
return () => clearTimeout(timer);
|
|
95
|
+
}
|
|
96
|
+
return undefined;
|
|
97
|
+
}, [nodes.length, reactFlowInstance]);
|
|
98
|
+
|
|
99
|
+
const handleFitView = useCallback(() => {
|
|
100
|
+
reactFlowInstance.fitView({ padding: 0.15,
|
|
101
|
+
duration: 400 });
|
|
102
|
+
}, [reactFlowInstance]);
|
|
103
|
+
|
|
104
|
+
const handleNodeClick = useCallback((_: React.MouseEvent, node: Node) => {
|
|
105
|
+
setSelectedTable(node.id);
|
|
106
|
+
}, []);
|
|
107
|
+
|
|
108
|
+
const handlePaneClick = useCallback(() => {
|
|
109
|
+
setSelectedTable(null);
|
|
110
|
+
}, []);
|
|
111
|
+
|
|
112
|
+
// Focus on a table from the sidebar
|
|
113
|
+
const handleTableSelect = useCallback(
|
|
114
|
+
(nodeId: string) => {
|
|
115
|
+
setSelectedTable(nodeId);
|
|
116
|
+
const node = nodes.find((n) => n.id === nodeId);
|
|
117
|
+
if (node) {
|
|
118
|
+
reactFlowInstance.setCenter(
|
|
119
|
+
node.position.x + 140,
|
|
120
|
+
node.position.y + 60,
|
|
121
|
+
{ zoom: 1.2,
|
|
122
|
+
duration: 400 }
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
[nodes, reactFlowInstance]
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
// Sidebar panel size
|
|
130
|
+
const [sidebarSize, setSidebarSize] = useState(() => {
|
|
131
|
+
try {
|
|
132
|
+
const saved = localStorage.getItem("rebase_schema_viz_sidebar_size");
|
|
133
|
+
return saved !== null ? parseFloat(saved) : 20;
|
|
134
|
+
} catch {
|
|
135
|
+
return 20;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
try {
|
|
141
|
+
localStorage.setItem(
|
|
142
|
+
"rebase_schema_viz_sidebar_size",
|
|
143
|
+
sidebarSize.toString()
|
|
144
|
+
);
|
|
145
|
+
} catch {
|
|
146
|
+
// Ignore
|
|
147
|
+
}
|
|
148
|
+
}, [sidebarSize]);
|
|
149
|
+
|
|
150
|
+
// Group collections for sidebar
|
|
151
|
+
const postgresCollections = useMemo(
|
|
152
|
+
() => collections.filter(isPostgresCollection),
|
|
153
|
+
[collections]
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const filteredCollections = useMemo(() => {
|
|
157
|
+
if (!searchQuery.trim()) return postgresCollections;
|
|
158
|
+
const q = searchQuery.toLowerCase();
|
|
159
|
+
return postgresCollections.filter(
|
|
160
|
+
(c) =>
|
|
161
|
+
c.name.toLowerCase().includes(q) ||
|
|
162
|
+
c.table?.toLowerCase().includes(q) ||
|
|
163
|
+
c.slug?.toLowerCase().includes(q)
|
|
164
|
+
);
|
|
165
|
+
}, [postgresCollections, searchQuery]);
|
|
166
|
+
|
|
167
|
+
// Junction table nodes
|
|
168
|
+
const junctionNodes = useMemo(
|
|
169
|
+
() =>
|
|
170
|
+
nodes.filter(
|
|
171
|
+
(n) => (n.data as TableNodeData).isJunction
|
|
172
|
+
),
|
|
173
|
+
[nodes]
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
// Stats
|
|
177
|
+
const stats = useMemo(
|
|
178
|
+
() => ({
|
|
179
|
+
tables: tableCount,
|
|
180
|
+
relations: relationCount,
|
|
181
|
+
junctions: junctionNodes.length,
|
|
182
|
+
withRls: postgresCollections.filter(
|
|
183
|
+
(c) =>
|
|
184
|
+
isPostgresCollection(c) &&
|
|
185
|
+
c.securityRules &&
|
|
186
|
+
c.securityRules.length > 0
|
|
187
|
+
).length
|
|
188
|
+
}),
|
|
189
|
+
[
|
|
190
|
+
tableCount,
|
|
191
|
+
relationCount,
|
|
192
|
+
junctionNodes.length,
|
|
193
|
+
postgresCollections
|
|
194
|
+
]
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
<ResizablePanels
|
|
199
|
+
orientation="horizontal"
|
|
200
|
+
panelSizePercent={sidebarSize}
|
|
201
|
+
onPanelSizeChange={setSidebarSize}
|
|
202
|
+
minPanelSizePx={220}
|
|
203
|
+
firstPanel={
|
|
204
|
+
<div
|
|
205
|
+
className={cls(
|
|
206
|
+
"flex flex-col h-full w-full bg-white dark:bg-surface-950 border-r",
|
|
207
|
+
defaultBorderMixin
|
|
208
|
+
)}
|
|
209
|
+
>
|
|
210
|
+
{/* Sidebar header */}
|
|
211
|
+
<div
|
|
212
|
+
className={cls(
|
|
213
|
+
"flex items-center justify-between px-3 py-2 border-b bg-surface-50 dark:bg-surface-900 min-h-[48px]",
|
|
214
|
+
defaultBorderMixin
|
|
215
|
+
)}
|
|
216
|
+
>
|
|
217
|
+
<Typography
|
|
218
|
+
variant="caption"
|
|
219
|
+
className="font-bold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark"
|
|
220
|
+
>
|
|
221
|
+
Tables
|
|
222
|
+
</Typography>
|
|
223
|
+
<Typography
|
|
224
|
+
variant="caption"
|
|
225
|
+
className="text-[10px] text-text-disabled dark:text-text-disabled-dark font-mono"
|
|
226
|
+
>
|
|
227
|
+
{stats.tables}
|
|
228
|
+
</Typography>
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
{/* Search */}
|
|
232
|
+
<div className="px-2 py-1.5 border-b border-surface-200/40 dark:border-surface-700/40">
|
|
233
|
+
<TextField
|
|
234
|
+
size="smallest"
|
|
235
|
+
placeholder="Filter tablesβ¦"
|
|
236
|
+
value={searchQuery}
|
|
237
|
+
onChange={(e) => setSearchQuery(e.target.value)}
|
|
238
|
+
inputClassName="text-xs"
|
|
239
|
+
/>
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
{/* Table list */}
|
|
243
|
+
<div className="flex-grow overflow-y-auto no-scrollbar p-1">
|
|
244
|
+
{/* Regular collections */}
|
|
245
|
+
<div className="space-y-0.5">
|
|
246
|
+
{filteredCollections.map((collection) => {
|
|
247
|
+
const table = collection.table ?? collection.slug;
|
|
248
|
+
const nodeId = `table-${table}`;
|
|
249
|
+
const isSelected = selectedTable === nodeId;
|
|
250
|
+
return (
|
|
251
|
+
<div
|
|
252
|
+
key={nodeId}
|
|
253
|
+
onClick={() =>
|
|
254
|
+
handleTableSelect(nodeId)
|
|
255
|
+
}
|
|
256
|
+
className={cls(
|
|
257
|
+
"flex items-center p-1.5 cursor-pointer rounded transition-colors group",
|
|
258
|
+
isSelected
|
|
259
|
+
? "bg-primary/10 text-primary dark:bg-primary/20 dark:text-primary-light"
|
|
260
|
+
: "hover:bg-surface-100 dark:hover:bg-surface-950 text-text-secondary dark:text-text-secondary-dark"
|
|
261
|
+
)}
|
|
262
|
+
>
|
|
263
|
+
<div className="shrink-0 mr-1.5 text-text-disabled dark:text-text-disabled-dark">
|
|
264
|
+
<IconForView
|
|
265
|
+
collectionOrView={{
|
|
266
|
+
slug: collection.slug,
|
|
267
|
+
name: collection.name,
|
|
268
|
+
icon:
|
|
269
|
+
typeof collection.icon ===
|
|
270
|
+
"string"
|
|
271
|
+
? collection.icon
|
|
272
|
+
: undefined
|
|
273
|
+
}}
|
|
274
|
+
size="smallest"
|
|
275
|
+
/>
|
|
276
|
+
</div>
|
|
277
|
+
<div className="flex flex-col min-w-0 flex-1">
|
|
278
|
+
<Typography
|
|
279
|
+
variant="caption"
|
|
280
|
+
className="text-xs truncate font-medium"
|
|
281
|
+
>
|
|
282
|
+
{collection.name}
|
|
283
|
+
</Typography>
|
|
284
|
+
{table !== collection.name && (
|
|
285
|
+
<Typography
|
|
286
|
+
variant="caption"
|
|
287
|
+
className="text-[10px] text-text-disabled dark:text-text-disabled-dark font-mono truncate"
|
|
288
|
+
>
|
|
289
|
+
{table}
|
|
290
|
+
</Typography>
|
|
291
|
+
)}
|
|
292
|
+
</div>
|
|
293
|
+
<div className="flex items-center gap-1 shrink-0 ml-1">
|
|
294
|
+
{isPostgresCollection(collection) &&
|
|
295
|
+
collection.securityRules &&
|
|
296
|
+
collection.securityRules
|
|
297
|
+
.length > 0 && (
|
|
298
|
+
<Tooltip title="RLS enabled">
|
|
299
|
+
<div className="w-1.5 h-1.5 rounded-full bg-green-500"/>
|
|
300
|
+
</Tooltip>
|
|
301
|
+
)}
|
|
302
|
+
{collection.history && (
|
|
303
|
+
<Tooltip title="History enabled">
|
|
304
|
+
<div className="w-1.5 h-1.5 rounded-full bg-blue-400"/>
|
|
305
|
+
</Tooltip>
|
|
306
|
+
)}
|
|
307
|
+
</div>
|
|
308
|
+
</div>
|
|
309
|
+
);
|
|
310
|
+
})}
|
|
311
|
+
</div>
|
|
312
|
+
|
|
313
|
+
{/* Junction tables */}
|
|
314
|
+
{junctionNodes.length > 0 && (
|
|
315
|
+
<div className="mt-3">
|
|
316
|
+
<Typography
|
|
317
|
+
variant="caption"
|
|
318
|
+
className="px-1.5 text-[10px] uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark font-medium"
|
|
319
|
+
>
|
|
320
|
+
Junction Tables
|
|
321
|
+
</Typography>
|
|
322
|
+
<div className="mt-1 space-y-0.5">
|
|
323
|
+
{junctionNodes.map((node) => {
|
|
324
|
+
const d =
|
|
325
|
+
node.data as TableNodeData;
|
|
326
|
+
const isSelected =
|
|
327
|
+
selectedTable === node.id;
|
|
328
|
+
return (
|
|
329
|
+
<div
|
|
330
|
+
key={node.id}
|
|
331
|
+
onClick={() =>
|
|
332
|
+
handleTableSelect(
|
|
333
|
+
node.id
|
|
334
|
+
)
|
|
335
|
+
}
|
|
336
|
+
className={cls(
|
|
337
|
+
"flex items-center p-1.5 cursor-pointer rounded transition-colors",
|
|
338
|
+
isSelected
|
|
339
|
+
? "bg-primary/10 text-primary dark:bg-primary/20"
|
|
340
|
+
: "hover:bg-surface-100 dark:hover:bg-surface-950 text-text-disabled dark:text-text-disabled-dark"
|
|
341
|
+
)}
|
|
342
|
+
>
|
|
343
|
+
<svg
|
|
344
|
+
className="w-3.5 h-3.5 mr-1.5 shrink-0"
|
|
345
|
+
fill="none"
|
|
346
|
+
stroke="currentColor"
|
|
347
|
+
viewBox="0 0 24 24"
|
|
348
|
+
>
|
|
349
|
+
<path
|
|
350
|
+
strokeLinecap="round"
|
|
351
|
+
strokeLinejoin="round"
|
|
352
|
+
strokeWidth={2}
|
|
353
|
+
d="M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"
|
|
354
|
+
/>
|
|
355
|
+
</svg>
|
|
356
|
+
<Typography
|
|
357
|
+
variant="caption"
|
|
358
|
+
className="text-xs font-mono truncate"
|
|
359
|
+
>
|
|
360
|
+
{d.tableName}
|
|
361
|
+
</Typography>
|
|
362
|
+
</div>
|
|
363
|
+
);
|
|
364
|
+
})}
|
|
365
|
+
</div>
|
|
366
|
+
</div>
|
|
367
|
+
)}
|
|
368
|
+
</div>
|
|
369
|
+
|
|
370
|
+
{/* Stats footer */}
|
|
371
|
+
<div
|
|
372
|
+
className={cls(
|
|
373
|
+
"px-3 py-2 border-t bg-surface-50 dark:bg-surface-900 space-y-1",
|
|
374
|
+
defaultBorderMixin
|
|
375
|
+
)}
|
|
376
|
+
>
|
|
377
|
+
<div className="flex items-center justify-between">
|
|
378
|
+
<Typography
|
|
379
|
+
variant="caption"
|
|
380
|
+
className="text-[10px] text-text-disabled dark:text-text-disabled-dark"
|
|
381
|
+
>
|
|
382
|
+
Tables
|
|
383
|
+
</Typography>
|
|
384
|
+
<Typography
|
|
385
|
+
variant="caption"
|
|
386
|
+
className="text-[10px] font-mono font-medium"
|
|
387
|
+
>
|
|
388
|
+
{stats.tables}
|
|
389
|
+
</Typography>
|
|
390
|
+
</div>
|
|
391
|
+
<div className="flex items-center justify-between">
|
|
392
|
+
<Typography
|
|
393
|
+
variant="caption"
|
|
394
|
+
className="text-[10px] text-text-disabled dark:text-text-disabled-dark"
|
|
395
|
+
>
|
|
396
|
+
Relations
|
|
397
|
+
</Typography>
|
|
398
|
+
<Typography
|
|
399
|
+
variant="caption"
|
|
400
|
+
className="text-[10px] font-mono font-medium"
|
|
401
|
+
>
|
|
402
|
+
{stats.relations}
|
|
403
|
+
</Typography>
|
|
404
|
+
</div>
|
|
405
|
+
<div className="flex items-center justify-between">
|
|
406
|
+
<Typography
|
|
407
|
+
variant="caption"
|
|
408
|
+
className="text-[10px] text-text-disabled dark:text-text-disabled-dark"
|
|
409
|
+
>
|
|
410
|
+
RLS protected
|
|
411
|
+
</Typography>
|
|
412
|
+
<div className="flex items-center gap-1">
|
|
413
|
+
<div className="w-1.5 h-1.5 rounded-full bg-green-500"/>
|
|
414
|
+
<Typography
|
|
415
|
+
variant="caption"
|
|
416
|
+
className="text-[10px] font-mono font-medium"
|
|
417
|
+
>
|
|
418
|
+
{stats.withRls}
|
|
419
|
+
</Typography>
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
422
|
+
</div>
|
|
423
|
+
</div>
|
|
424
|
+
}
|
|
425
|
+
secondPanel={
|
|
426
|
+
<div className="flex-grow flex flex-col min-w-0 h-full w-full bg-white dark:bg-surface-950">
|
|
427
|
+
{/* Toolbar */}
|
|
428
|
+
<div
|
|
429
|
+
className={cls(
|
|
430
|
+
"flex items-center justify-between pr-2 border-b bg-white dark:bg-surface-950 min-h-[46px]",
|
|
431
|
+
defaultBorderMixin
|
|
432
|
+
)}
|
|
433
|
+
>
|
|
434
|
+
<div className="flex items-center gap-2 px-4">
|
|
435
|
+
<Typography
|
|
436
|
+
variant="subtitle2"
|
|
437
|
+
className="font-mono text-text-secondary dark:text-text-secondary-dark"
|
|
438
|
+
>
|
|
439
|
+
Schema Visualizer
|
|
440
|
+
</Typography>
|
|
441
|
+
</div>
|
|
442
|
+
<div className="flex shrink-0 items-center gap-1.5">
|
|
443
|
+
{/* Direction toggle */}
|
|
444
|
+
<div className="flex items-center bg-surface-100 dark:bg-surface-950 rounded-md border border-surface-200/40 dark:border-surface-700/40">
|
|
445
|
+
<Tooltip title="Left to right layout">
|
|
446
|
+
<button
|
|
447
|
+
onClick={() => setDirection("LR")}
|
|
448
|
+
className={cls(
|
|
449
|
+
"px-2 py-1 text-[10px] font-mono rounded-l-md transition-colors",
|
|
450
|
+
direction === "LR"
|
|
451
|
+
? "bg-primary text-white"
|
|
452
|
+
: "text-text-secondary dark:text-text-secondary-dark hover:bg-surface-200 dark:hover:bg-surface-700"
|
|
453
|
+
)}
|
|
454
|
+
>
|
|
455
|
+
LR
|
|
456
|
+
</button>
|
|
457
|
+
</Tooltip>
|
|
458
|
+
<Tooltip title="Top to bottom layout">
|
|
459
|
+
<button
|
|
460
|
+
onClick={() => setDirection("TB")}
|
|
461
|
+
className={cls(
|
|
462
|
+
"px-2 py-1 text-[10px] font-mono rounded-r-md transition-colors",
|
|
463
|
+
direction === "TB"
|
|
464
|
+
? "bg-primary text-white"
|
|
465
|
+
: "text-text-secondary dark:text-text-secondary-dark hover:bg-surface-200 dark:hover:bg-surface-700"
|
|
466
|
+
)}
|
|
467
|
+
>
|
|
468
|
+
TB
|
|
469
|
+
</button>
|
|
470
|
+
</Tooltip>
|
|
471
|
+
</div>
|
|
472
|
+
|
|
473
|
+
<div className="h-4 w-px bg-surface-200 dark:bg-surface-950 mx-0.5"/>
|
|
474
|
+
|
|
475
|
+
{/* Fit view */}
|
|
476
|
+
<Tooltip title="Fit to view">
|
|
477
|
+
<IconButton
|
|
478
|
+
size="small"
|
|
479
|
+
onClick={handleFitView}
|
|
480
|
+
>
|
|
481
|
+
<svg
|
|
482
|
+
className="w-4 h-4"
|
|
483
|
+
fill="none"
|
|
484
|
+
stroke="currentColor"
|
|
485
|
+
viewBox="0 0 24 24"
|
|
486
|
+
>
|
|
487
|
+
<path
|
|
488
|
+
strokeLinecap="round"
|
|
489
|
+
strokeLinejoin="round"
|
|
490
|
+
strokeWidth={2}
|
|
491
|
+
d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"
|
|
492
|
+
/>
|
|
493
|
+
</svg>
|
|
494
|
+
</IconButton>
|
|
495
|
+
</Tooltip>
|
|
496
|
+
|
|
497
|
+
{/* Re-layout */}
|
|
498
|
+
<Tooltip title="Re-layout">
|
|
499
|
+
<IconButton
|
|
500
|
+
size="small"
|
|
501
|
+
onClick={relayout}
|
|
502
|
+
>
|
|
503
|
+
<svg
|
|
504
|
+
className="w-4 h-4"
|
|
505
|
+
fill="none"
|
|
506
|
+
stroke="currentColor"
|
|
507
|
+
viewBox="0 0 24 24"
|
|
508
|
+
>
|
|
509
|
+
<path
|
|
510
|
+
strokeLinecap="round"
|
|
511
|
+
strokeLinejoin="round"
|
|
512
|
+
strokeWidth={2}
|
|
513
|
+
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
|
|
514
|
+
/>
|
|
515
|
+
</svg>
|
|
516
|
+
</IconButton>
|
|
517
|
+
</Tooltip>
|
|
518
|
+
</div>
|
|
519
|
+
</div>
|
|
520
|
+
|
|
521
|
+
{/* Canvas */}
|
|
522
|
+
<div className="flex-grow relative">
|
|
523
|
+
<ReactFlow
|
|
524
|
+
nodes={nodes}
|
|
525
|
+
edges={edges}
|
|
526
|
+
onNodesChange={onNodesChange}
|
|
527
|
+
onEdgesChange={onEdgesChange}
|
|
528
|
+
onNodeClick={handleNodeClick}
|
|
529
|
+
onPaneClick={handlePaneClick}
|
|
530
|
+
nodeTypes={nodeTypes}
|
|
531
|
+
edgeTypes={edgeTypes}
|
|
532
|
+
fitView
|
|
533
|
+
fitViewOptions={{ padding: 0.15 }}
|
|
534
|
+
minZoom={0.1}
|
|
535
|
+
maxZoom={2}
|
|
536
|
+
proOptions={{ hideAttribution: true }}
|
|
537
|
+
className="bg-surface-50 dark:bg-surface-950"
|
|
538
|
+
>
|
|
539
|
+
<Background
|
|
540
|
+
variant={BackgroundVariant.Dots}
|
|
541
|
+
gap={20}
|
|
542
|
+
size={1}
|
|
543
|
+
className="!bg-surface-50 dark:!bg-surface-950"
|
|
544
|
+
color="var(--rf-bg-dot, #d4d4d8)"
|
|
545
|
+
/>
|
|
546
|
+
<Controls
|
|
547
|
+
showInteractive={false}
|
|
548
|
+
className="!bg-white dark:!bg-surface-900 !border !border-surface-200/40 dark:!border-surface-700/40 !shadow-sm !rounded-lg"
|
|
549
|
+
/>
|
|
550
|
+
<MiniMap
|
|
551
|
+
nodeStrokeColor={(n) => {
|
|
552
|
+
const d = n.data as TableNodeData;
|
|
553
|
+
if (d.isJunction) return "#a78bfa";
|
|
554
|
+
if (d.rlsEnabled) return "#22c55e";
|
|
555
|
+
return "#6366f1";
|
|
556
|
+
}}
|
|
557
|
+
nodeColor={(n) => {
|
|
558
|
+
const d = n.data as TableNodeData;
|
|
559
|
+
if (d.isJunction) return "#ede9fe";
|
|
560
|
+
return "#eef2ff";
|
|
561
|
+
}}
|
|
562
|
+
maskColor="rgba(0,0,0,0.08)"
|
|
563
|
+
className="!bg-white dark:!bg-surface-900 !border !border-surface-200/40 dark:!border-surface-700/40 !shadow-sm !rounded-lg"
|
|
564
|
+
/>
|
|
565
|
+
</ReactFlow>
|
|
566
|
+
|
|
567
|
+
{/* Legend overlay */}
|
|
568
|
+
<div className="absolute bottom-4 left-4 flex items-center gap-3 px-3 py-2 bg-white/90 dark:bg-surface-900/90 backdrop-blur-sm rounded-lg border border-surface-200/40 dark:border-surface-700/40 shadow-sm">
|
|
569
|
+
<div className="flex items-center gap-1.5">
|
|
570
|
+
<div className="w-6 h-0.5 bg-indigo-500 rounded"/>
|
|
571
|
+
<Typography
|
|
572
|
+
variant="caption"
|
|
573
|
+
className="text-[10px] text-text-disabled dark:text-text-disabled-dark"
|
|
574
|
+
>
|
|
575
|
+
Owning
|
|
576
|
+
</Typography>
|
|
577
|
+
</div>
|
|
578
|
+
<div className="flex items-center gap-1.5">
|
|
579
|
+
<div className="w-6 h-0.5 bg-violet-500 rounded"/>
|
|
580
|
+
<Typography
|
|
581
|
+
variant="caption"
|
|
582
|
+
className="text-[10px] text-text-disabled dark:text-text-disabled-dark"
|
|
583
|
+
>
|
|
584
|
+
M:N
|
|
585
|
+
</Typography>
|
|
586
|
+
</div>
|
|
587
|
+
<div className="flex items-center gap-1.5">
|
|
588
|
+
<div
|
|
589
|
+
className="w-6 h-0.5 rounded"
|
|
590
|
+
style={{
|
|
591
|
+
backgroundImage:
|
|
592
|
+
"repeating-linear-gradient(90deg, #94a3b8, #94a3b8 4px, transparent 4px, transparent 7px)"
|
|
593
|
+
}}
|
|
594
|
+
/>
|
|
595
|
+
<Typography
|
|
596
|
+
variant="caption"
|
|
597
|
+
className="text-[10px] text-text-disabled dark:text-text-disabled-dark"
|
|
598
|
+
>
|
|
599
|
+
Inverse
|
|
600
|
+
</Typography>
|
|
601
|
+
</div>
|
|
602
|
+
<div className="h-3 w-px bg-surface-200 dark:bg-surface-700"/>
|
|
603
|
+
<div className="flex items-center gap-1">
|
|
604
|
+
<span className="text-[9px]">π</span>
|
|
605
|
+
<Typography
|
|
606
|
+
variant="caption"
|
|
607
|
+
className="text-[10px] text-text-disabled dark:text-text-disabled-dark"
|
|
608
|
+
>
|
|
609
|
+
PK
|
|
610
|
+
</Typography>
|
|
611
|
+
</div>
|
|
612
|
+
<div className="flex items-center gap-1">
|
|
613
|
+
<span className="text-[9px]">π</span>
|
|
614
|
+
<Typography
|
|
615
|
+
variant="caption"
|
|
616
|
+
className="text-[10px] text-text-disabled dark:text-text-disabled-dark"
|
|
617
|
+
>
|
|
618
|
+
FK
|
|
619
|
+
</Typography>
|
|
620
|
+
</div>
|
|
621
|
+
</div>
|
|
622
|
+
</div>
|
|
623
|
+
</div>
|
|
624
|
+
}
|
|
625
|
+
/>
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// βββ Outer wrapper (provides ReactFlowProvider) ββββββββββββββββββββββββ
|
|
630
|
+
|
|
631
|
+
export const SchemaVisualizer = () => {
|
|
632
|
+
const { collections: registryCollections } =
|
|
633
|
+
useStudioCollectionRegistry() as {
|
|
634
|
+
collections?: EntityCollection[];
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
// Merge registry collections with any passed collections
|
|
638
|
+
const collections = useMemo(() => {
|
|
639
|
+
return registryCollections ?? [];
|
|
640
|
+
}, [registryCollections]);
|
|
641
|
+
|
|
642
|
+
if (!collections || collections.length === 0) {
|
|
643
|
+
return (
|
|
644
|
+
<div className="flex items-center justify-center h-full w-full">
|
|
645
|
+
<div className="text-center space-y-3">
|
|
646
|
+
<CircularProgress size="small"/>
|
|
647
|
+
<Typography
|
|
648
|
+
variant="body2"
|
|
649
|
+
color="secondary"
|
|
650
|
+
>
|
|
651
|
+
Loading schemaβ¦
|
|
652
|
+
</Typography>
|
|
653
|
+
</div>
|
|
654
|
+
</div>
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
return (
|
|
659
|
+
<div className="flex h-full w-full bg-white dark:bg-surface-950 overflow-hidden text-text-primary dark:text-text-primary-dark">
|
|
660
|
+
<ReactFlowProvider>
|
|
661
|
+
<SchemaVisualizerCanvas collections={collections}/>
|
|
662
|
+
</ReactFlowProvider>
|
|
663
|
+
</div>
|
|
664
|
+
);
|
|
665
|
+
};
|