@rebasepro/studio 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ApiExplorer-CdIwR9Ga.js +963 -0
- package/dist/ApiExplorer-CdIwR9Ga.js.map +1 -0
- package/dist/AuthSimulationSelector-iEZ-Or_1.js +56 -0
- package/dist/AuthSimulationSelector-iEZ-Or_1.js.map +1 -0
- package/dist/BranchesView-DncIRcZt.js +461 -0
- package/dist/BranchesView-DncIRcZt.js.map +1 -0
- package/dist/CronJobsView-4gdtJvoe.js +500 -0
- package/dist/CronJobsView-4gdtJvoe.js.map +1 -0
- package/dist/JSEditor-BhAbEjCP.js +1573 -0
- package/dist/JSEditor-BhAbEjCP.js.map +1 -0
- package/dist/LogsExplorer-CqtKILj8.js +240 -0
- package/dist/LogsExplorer-CqtKILj8.js.map +1 -0
- package/dist/MonacoEditor-COZqrIJ1.js +246 -0
- package/dist/MonacoEditor-COZqrIJ1.js.map +1 -0
- package/dist/RLSEditor-DpF1u9EC.js +1369 -0
- package/dist/RLSEditor-DpF1u9EC.js.map +1 -0
- package/dist/SQLEditor-BLuq_zDM.js +1964 -0
- package/dist/SQLEditor-BLuq_zDM.js.map +1 -0
- package/dist/SchemaVisualizer-BJK2u3C0.js +1068 -0
- package/dist/SchemaVisualizer-BJK2u3C0.js.map +1 -0
- package/dist/StorageView-CvrnHmDG.js +1395 -0
- package/dist/StorageView-CvrnHmDG.js.map +1 -0
- package/dist/{studio/src/components → components}/ApiExplorer/ApiExplorer.d.ts +2 -1
- package/dist/{studio/src/components → components}/ApiExplorer/EndpointDetail.d.ts +2 -1
- package/dist/{studio/src/components → components}/ApiExplorer/TryItPanel.d.ts +2 -1
- package/dist/{studio/src/components → components}/AuthSimulationSelector.d.ts +2 -1
- package/dist/components/Branches/BranchesView.d.ts +2 -0
- package/dist/components/CronJobs/CronJobsView.d.ts +2 -0
- package/dist/components/JSEditor/JSEditor.d.ts +2 -0
- package/dist/{studio/src/components → components}/JSEditor/JSEditorSidebar.d.ts +2 -1
- package/dist/{studio/src/components → components}/JSEditor/JSMonacoEditor.d.ts +2 -1
- package/dist/components/LogsExplorer/LogsExplorer.d.ts +2 -0
- package/dist/{studio/src/components → components}/RLSEditor/PolicyEditor.d.ts +2 -1
- package/dist/{studio/src/components → components}/RLSEditor/RLSEditor.d.ts +2 -1
- package/dist/{studio/src/components → components}/SQLEditor/MonacoEditor.d.ts +2 -1
- package/dist/{studio/src/components → components}/SQLEditor/SQLEditor.d.ts +2 -1
- package/dist/{studio/src/components → components}/SQLEditor/SQLEditorSidebar.d.ts +2 -1
- package/dist/{studio/src/components → components}/SQLEditor/SchemaBrowser.d.ts +2 -1
- package/dist/{studio/src/components → components}/SchemaVisualizer/RelationEdge.d.ts +1 -1
- package/dist/components/SchemaVisualizer/SchemaVisualizer.d.ts +3 -0
- package/dist/{studio/src/components → components}/SchemaVisualizer/TableNode.d.ts +1 -1
- package/dist/components/StorageView/StorageView.d.ts +2 -0
- package/dist/{studio/src/components → components}/StudioHomePage.d.ts +1 -1
- package/dist/index.es.js +688 -746
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +10323 -9572
- package/dist/index.umd.js.map +1 -1
- package/package.json +22 -22
- package/src/components/ApiExplorer/TryItPanel.tsx +15 -18
- package/src/components/CronJobs/CronJobsView.tsx +1 -1
- package/src/components/JSEditor/JSEditor.tsx +9 -14
- package/src/components/LogsExplorer/LogsExplorer.tsx +6 -3
- package/src/components/RLSEditor/PolicyEditor.tsx +1 -1
- package/src/components/SQLEditor/SQLEditor.tsx +40 -30
- package/src/components/StorageView/StorageView.tsx +25 -14
- package/src/components/StudioHomePage.tsx +51 -15
- package/src/utils/parseSpec.test.ts +41 -20
- package/src/utils/pgColumnToProperty.ts +1 -1
- package/dist/ApiExplorer-CGHEF1uL.js +0 -1052
- package/dist/ApiExplorer-CGHEF1uL.js.map +0 -1
- package/dist/AuthSimulationSelector-DGoXkWSg.js +0 -105
- package/dist/AuthSimulationSelector-DGoXkWSg.js.map +0 -1
- package/dist/BranchesView-BiTEwIhd.js +0 -291
- package/dist/BranchesView-BiTEwIhd.js.map +0 -1
- package/dist/CronJobsView-3PM_qR8v.js +0 -472
- package/dist/CronJobsView-3PM_qR8v.js.map +0 -1
- package/dist/JSEditor-DfwRLBZg.js +0 -1297
- package/dist/JSEditor-DfwRLBZg.js.map +0 -1
- package/dist/LogsExplorer-_4sZadKn.js +0 -162
- package/dist/LogsExplorer-_4sZadKn.js.map +0 -1
- package/dist/MonacoEditor-CMYEjiRf.js +0 -161
- package/dist/MonacoEditor-CMYEjiRf.js.map +0 -1
- package/dist/RLSEditor-CHEExeSB.js +0 -1871
- package/dist/RLSEditor-CHEExeSB.js.map +0 -1
- package/dist/SQLEditor-CQXaI0iU.js +0 -1797
- package/dist/SQLEditor-CQXaI0iU.js.map +0 -1
- package/dist/SchemaVisualizer-BGpmzyXT.js +0 -1069
- package/dist/SchemaVisualizer-BGpmzyXT.js.map +0 -1
- package/dist/StorageView-B7AsN2qX.js +0 -869
- package/dist/StorageView-B7AsN2qX.js.map +0 -1
- package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
- package/dist/common/src/collections/default-collections.d.ts +0 -9
- package/dist/common/src/collections/index.d.ts +0 -2
- package/dist/common/src/data/buildRebaseData.d.ts +0 -14
- package/dist/common/src/data/query_builder.d.ts +0 -55
- package/dist/common/src/index.d.ts +0 -4
- package/dist/common/src/util/builders.d.ts +0 -57
- package/dist/common/src/util/callbacks.d.ts +0 -6
- package/dist/common/src/util/collections.d.ts +0 -11
- package/dist/common/src/util/common.d.ts +0 -2
- package/dist/common/src/util/conditions.d.ts +0 -26
- package/dist/common/src/util/entities.d.ts +0 -58
- package/dist/common/src/util/enums.d.ts +0 -3
- package/dist/common/src/util/index.d.ts +0 -16
- package/dist/common/src/util/navigation_from_path.d.ts +0 -34
- package/dist/common/src/util/navigation_utils.d.ts +0 -20
- package/dist/common/src/util/parent_references_from_path.d.ts +0 -6
- package/dist/common/src/util/paths.d.ts +0 -14
- package/dist/common/src/util/permissions.d.ts +0 -14
- package/dist/common/src/util/references.d.ts +0 -2
- package/dist/common/src/util/relations.d.ts +0 -22
- package/dist/common/src/util/resolutions.d.ts +0 -72
- package/dist/common/src/util/storage.d.ts +0 -24
- package/dist/core/src/components/AIIcon.d.ts +0 -16
- package/dist/core/src/components/BootstrapAdminBanner.d.ts +0 -4
- package/dist/core/src/components/ConfirmationDialog.d.ts +0 -9
- package/dist/core/src/components/Debug/UIReferenceView.d.ts +0 -1
- package/dist/core/src/components/Debug/UIStyleGuide.d.ts +0 -1
- package/dist/core/src/components/ErrorTooltip.d.ts +0 -2
- package/dist/core/src/components/ErrorView.d.ts +0 -21
- package/dist/core/src/components/LanguageToggle.d.ts +0 -1
- package/dist/core/src/components/LoginView/LoginView.d.ts +0 -109
- package/dist/core/src/components/LoginView/index.d.ts +0 -2
- package/dist/core/src/components/NotFoundPage.d.ts +0 -1
- package/dist/core/src/components/RebaseAuth.d.ts +0 -10
- package/dist/core/src/components/RebaseLogo.d.ts +0 -7
- package/dist/core/src/components/UnsavedChangesDialog.d.ts +0 -9
- package/dist/core/src/components/UserDisplay.d.ts +0 -7
- package/dist/core/src/components/UserSelectPopover.d.ts +0 -62
- package/dist/core/src/components/UserSettingsView.d.ts +0 -1
- package/dist/core/src/components/common/index.d.ts +0 -6
- package/dist/core/src/components/common/table_height.d.ts +0 -5
- package/dist/core/src/components/common/types.d.ts +0 -66
- package/dist/core/src/components/common/useColumnsIds.d.ts +0 -9
- package/dist/core/src/components/common/useDataTableController.d.ts +0 -45
- package/dist/core/src/components/common/useDebouncedData.d.ts +0 -9
- package/dist/core/src/components/common/useScrollRestoration.d.ts +0 -14
- package/dist/core/src/components/index.d.ts +0 -17
- package/dist/core/src/contexts/AdminModeController.d.ts +0 -4
- package/dist/core/src/contexts/AnalyticsContext.d.ts +0 -3
- package/dist/core/src/contexts/AuthControllerContext.d.ts +0 -3
- package/dist/core/src/contexts/CustomizationControllerContext.d.ts +0 -3
- package/dist/core/src/contexts/DataDriverContext.d.ts +0 -3
- package/dist/core/src/contexts/DatabaseAdminContext.d.ts +0 -3
- package/dist/core/src/contexts/DialogsProvider.d.ts +0 -4
- package/dist/core/src/contexts/EffectiveRoleController.d.ts +0 -4
- package/dist/core/src/contexts/InternalUserManagementContext.d.ts +0 -3
- package/dist/core/src/contexts/ModeController.d.ts +0 -4
- package/dist/core/src/contexts/RebaseClientInstanceContext.d.ts +0 -6
- package/dist/core/src/contexts/RebaseDataContext.d.ts +0 -3
- package/dist/core/src/contexts/SnackbarProvider.d.ts +0 -2
- package/dist/core/src/contexts/StorageSourceContext.d.ts +0 -3
- package/dist/core/src/contexts/UserConfigurationPersistenceContext.d.ts +0 -3
- package/dist/core/src/contexts/index.d.ts +0 -13
- package/dist/core/src/core/PluginLifecycleManager.d.ts +0 -17
- package/dist/core/src/core/PluginProviderStack.d.ts +0 -21
- package/dist/core/src/core/Rebase.d.ts +0 -14
- package/dist/core/src/core/RebaseProps.d.ts +0 -147
- package/dist/core/src/core/RebaseRouter.d.ts +0 -4
- package/dist/core/src/core/RebaseRoutes.d.ts +0 -17
- package/dist/core/src/core/index.d.ts +0 -4
- package/dist/core/src/hooks/ApiConfigContext.d.ts +0 -24
- package/dist/core/src/hooks/data/delete.d.ts +0 -31
- package/dist/core/src/hooks/data/save.d.ts +0 -34
- package/dist/core/src/hooks/data/useCollectionFetch.d.ts +0 -62
- package/dist/core/src/hooks/data/useData.d.ts +0 -13
- package/dist/core/src/hooks/data/useDataOrder.d.ts +0 -12
- package/dist/core/src/hooks/data/useEntityFetch.d.ts +0 -43
- package/dist/core/src/hooks/data/useRelationSelector.d.ts +0 -52
- package/dist/core/src/hooks/data/useUserSelector.d.ts +0 -31
- package/dist/core/src/hooks/index.d.ts +0 -37
- package/dist/core/src/hooks/useAdminModeController.d.ts +0 -19
- package/dist/core/src/hooks/useAnalyticsController.d.ts +0 -5
- package/dist/core/src/hooks/useAuthController.d.ts +0 -11
- package/dist/core/src/hooks/useAuthSubscription.d.ts +0 -2
- package/dist/core/src/hooks/useBackendStorageSource.d.ts +0 -30
- package/dist/core/src/hooks/useBridgeRegistration.d.ts +0 -18
- package/dist/core/src/hooks/useBrowserTitleAndIcon.d.ts +0 -6
- package/dist/core/src/hooks/useBuildAdminModeController.d.ts +0 -6
- package/dist/core/src/hooks/useBuildEffectiveRoleController.d.ts +0 -8
- package/dist/core/src/hooks/useBuildLocalConfigurationPersistence.d.ts +0 -2
- package/dist/core/src/hooks/useBuildModeController.d.ts +0 -6
- package/dist/core/src/hooks/useClipboard.d.ts +0 -57
- package/dist/core/src/hooks/useCollapsedGroups.d.ts +0 -27
- package/dist/core/src/hooks/useCustomizationController.d.ts +0 -11
- package/dist/core/src/hooks/useDialogsController.d.ts +0 -11
- package/dist/core/src/hooks/useEffectiveRoleController.d.ts +0 -7
- package/dist/core/src/hooks/useInternalUserManagementController.d.ts +0 -12
- package/dist/core/src/hooks/useLargeLayout.d.ts +0 -1
- package/dist/core/src/hooks/useModeController.d.ts +0 -19
- package/dist/core/src/hooks/usePermissions.d.ts +0 -12
- package/dist/core/src/hooks/useRebaseClient.d.ts +0 -5
- package/dist/core/src/hooks/useRebaseContext.d.ts +0 -11
- package/dist/core/src/hooks/useRebaseRegistry.d.ts +0 -34
- package/dist/core/src/hooks/useResolvedComponent.d.ts +0 -47
- package/dist/core/src/hooks/useSlot.d.ts +0 -18
- package/dist/core/src/hooks/useSnackbarController.d.ts +0 -20
- package/dist/core/src/hooks/useStorageSource.d.ts +0 -7
- package/dist/core/src/hooks/useStudioBridge.d.ts +0 -91
- package/dist/core/src/hooks/useTranslation.d.ts +0 -17
- package/dist/core/src/hooks/useUnsavedChangesDialog.d.ts +0 -12
- package/dist/core/src/hooks/useUserConfigurationPersistence.d.ts +0 -8
- package/dist/core/src/i18n/RebaseI18nProvider.d.ts +0 -33
- package/dist/core/src/index.d.ts +0 -15
- package/dist/core/src/internal/common.d.ts +0 -3
- package/dist/core/src/internal/useRestoreScroll.d.ts +0 -6
- package/dist/core/src/locales/de.d.ts +0 -2
- package/dist/core/src/locales/en.d.ts +0 -10
- package/dist/core/src/locales/es.d.ts +0 -10
- package/dist/core/src/locales/fr.d.ts +0 -2
- package/dist/core/src/locales/hi.d.ts +0 -2
- package/dist/core/src/locales/it.d.ts +0 -2
- package/dist/core/src/locales/pt.d.ts +0 -7
- package/dist/core/src/util/constants.d.ts +0 -1
- package/dist/core/src/util/createFormexStub.d.ts +0 -2
- package/dist/core/src/util/entity_cache.d.ts +0 -22
- package/dist/core/src/util/enums.d.ts +0 -5
- package/dist/core/src/util/icon_list.d.ts +0 -5
- package/dist/core/src/util/icons.d.ts +0 -20
- package/dist/core/src/util/index.d.ts +0 -8
- package/dist/core/src/util/previews.d.ts +0 -4
- package/dist/core/src/util/useStorageUploadController.d.ts +0 -38
- package/dist/formex/src/Field.d.ts +0 -52
- package/dist/formex/src/Formex.d.ts +0 -7
- package/dist/formex/src/index.d.ts +0 -5
- package/dist/formex/src/types.d.ts +0 -40
- package/dist/formex/src/useCreateFormex.d.ts +0 -14
- package/dist/formex/src/utils.d.ts +0 -16
- package/dist/studio/src/components/Branches/BranchesView.d.ts +0 -1
- package/dist/studio/src/components/CronJobs/CronJobsView.d.ts +0 -1
- package/dist/studio/src/components/JSEditor/JSEditor.d.ts +0 -1
- package/dist/studio/src/components/LogsExplorer/LogsExplorer.d.ts +0 -1
- package/dist/studio/src/components/SchemaVisualizer/SchemaVisualizer.d.ts +0 -2
- package/dist/studio/src/components/StorageView/StorageView.d.ts +0 -1
- package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
- package/dist/types/src/controllers/auth.d.ts +0 -104
- package/dist/types/src/controllers/client.d.ts +0 -168
- package/dist/types/src/controllers/collection_registry.d.ts +0 -46
- package/dist/types/src/controllers/customization_controller.d.ts +0 -60
- package/dist/types/src/controllers/data.d.ts +0 -207
- package/dist/types/src/controllers/data_driver.d.ts +0 -218
- package/dist/types/src/controllers/database_admin.d.ts +0 -11
- package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
- package/dist/types/src/controllers/effective_role.d.ts +0 -4
- package/dist/types/src/controllers/email.d.ts +0 -36
- package/dist/types/src/controllers/index.d.ts +0 -18
- package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
- package/dist/types/src/controllers/navigation.d.ts +0 -225
- package/dist/types/src/controllers/registry.d.ts +0 -63
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
- package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
- package/dist/types/src/controllers/snackbar.d.ts +0 -24
- package/dist/types/src/controllers/storage.d.ts +0 -171
- package/dist/types/src/index.d.ts +0 -4
- package/dist/types/src/rebase_context.d.ts +0 -122
- package/dist/types/src/types/auth_adapter.d.ts +0 -301
- package/dist/types/src/types/backend.d.ts +0 -571
- package/dist/types/src/types/backend_hooks.d.ts +0 -172
- package/dist/types/src/types/builders.d.ts +0 -15
- package/dist/types/src/types/chips.d.ts +0 -5
- package/dist/types/src/types/collections.d.ts +0 -961
- package/dist/types/src/types/component_ref.d.ts +0 -47
- package/dist/types/src/types/cron.d.ts +0 -102
- package/dist/types/src/types/data_source.d.ts +0 -64
- package/dist/types/src/types/database_adapter.d.ts +0 -94
- package/dist/types/src/types/entities.d.ts +0 -145
- package/dist/types/src/types/entity_actions.d.ts +0 -104
- package/dist/types/src/types/entity_callbacks.d.ts +0 -173
- package/dist/types/src/types/entity_link_builder.d.ts +0 -7
- package/dist/types/src/types/entity_overrides.d.ts +0 -10
- package/dist/types/src/types/entity_views.d.ts +0 -87
- package/dist/types/src/types/export_import.d.ts +0 -21
- package/dist/types/src/types/formex.d.ts +0 -40
- package/dist/types/src/types/index.d.ts +0 -28
- package/dist/types/src/types/locales.d.ts +0 -4
- package/dist/types/src/types/modify_collections.d.ts +0 -5
- package/dist/types/src/types/plugins.d.ts +0 -282
- package/dist/types/src/types/properties.d.ts +0 -1173
- package/dist/types/src/types/property_config.d.ts +0 -74
- package/dist/types/src/types/relations.d.ts +0 -336
- package/dist/types/src/types/slots.d.ts +0 -262
- package/dist/types/src/types/translations.d.ts +0 -900
- package/dist/types/src/types/user_management_delegate.d.ts +0 -86
- package/dist/types/src/types/websockets.d.ts +0 -78
- package/dist/types/src/users/index.d.ts +0 -1
- package/dist/types/src/users/user.d.ts +0 -50
- package/dist/ui/src/components/Alert.d.ts +0 -12
- package/dist/ui/src/components/Autocomplete.d.ts +0 -21
- package/dist/ui/src/components/Avatar.d.ts +0 -11
- package/dist/ui/src/components/Badge.d.ts +0 -8
- package/dist/ui/src/components/BooleanSwitch.d.ts +0 -14
- package/dist/ui/src/components/BooleanSwitchWithLabel.d.ts +0 -17
- package/dist/ui/src/components/Button.d.ts +0 -14
- package/dist/ui/src/components/Card.d.ts +0 -8
- package/dist/ui/src/components/CenteredView.d.ts +0 -9
- package/dist/ui/src/components/Checkbox.d.ts +0 -13
- package/dist/ui/src/components/Chip.d.ts +0 -26
- package/dist/ui/src/components/CircularProgress.d.ts +0 -5
- package/dist/ui/src/components/CircularProgressCenter.d.ts +0 -11
- package/dist/ui/src/components/Collapse.d.ts +0 -9
- package/dist/ui/src/components/ColorPicker.d.ts +0 -30
- package/dist/ui/src/components/Container.d.ts +0 -8
- package/dist/ui/src/components/DateTimeField.d.ts +0 -24
- package/dist/ui/src/components/DebouncedTextField.d.ts +0 -2
- package/dist/ui/src/components/Dialog.d.ts +0 -39
- package/dist/ui/src/components/DialogActions.d.ts +0 -7
- package/dist/ui/src/components/DialogContent.d.ts +0 -7
- package/dist/ui/src/components/DialogTitle.d.ts +0 -10
- package/dist/ui/src/components/ErrorBoundary.d.ts +0 -33
- package/dist/ui/src/components/ExpandablePanel.d.ts +0 -12
- package/dist/ui/src/components/FileUpload.d.ts +0 -23
- package/dist/ui/src/components/FilterChip.d.ts +0 -34
- package/dist/ui/src/components/IconButton.d.ts +0 -12
- package/dist/ui/src/components/InfoLabel.d.ts +0 -5
- package/dist/ui/src/components/InputLabel.d.ts +0 -11
- package/dist/ui/src/components/Label.d.ts +0 -7
- package/dist/ui/src/components/LoadingButton.d.ts +0 -7
- package/dist/ui/src/components/Markdown.d.ts +0 -10
- package/dist/ui/src/components/Menu.d.ts +0 -23
- package/dist/ui/src/components/Menubar.d.ts +0 -80
- package/dist/ui/src/components/MultiSelect.d.ts +0 -48
- package/dist/ui/src/components/Paper.d.ts +0 -6
- package/dist/ui/src/components/Popover.d.ts +0 -24
- package/dist/ui/src/components/RadioGroup.d.ts +0 -28
- package/dist/ui/src/components/ResizablePanels.d.ts +0 -18
- package/dist/ui/src/components/SearchBar.d.ts +0 -26
- package/dist/ui/src/components/Select.d.ts +0 -43
- package/dist/ui/src/components/Separator.d.ts +0 -5
- package/dist/ui/src/components/Sheet.d.ts +0 -22
- package/dist/ui/src/components/Skeleton.d.ts +0 -6
- package/dist/ui/src/components/Slider.d.ts +0 -21
- package/dist/ui/src/components/Table.d.ts +0 -34
- package/dist/ui/src/components/Tabs.d.ts +0 -19
- package/dist/ui/src/components/TextField.d.ts +0 -58
- package/dist/ui/src/components/TextareaAutosize.d.ts +0 -43
- package/dist/ui/src/components/ToggleButtonGroup.d.ts +0 -30
- package/dist/ui/src/components/Tooltip.d.ts +0 -19
- package/dist/ui/src/components/Typography.d.ts +0 -36
- package/dist/ui/src/components/VirtualTable/VirtualTable.d.ts +0 -11
- package/dist/ui/src/components/VirtualTable/VirtualTableCell.d.ts +0 -21
- package/dist/ui/src/components/VirtualTable/VirtualTableHeader.d.ts +0 -29
- package/dist/ui/src/components/VirtualTable/VirtualTableHeaderRow.d.ts +0 -2
- package/dist/ui/src/components/VirtualTable/VirtualTableProps.d.ts +0 -249
- package/dist/ui/src/components/VirtualTable/VirtualTableRow.d.ts +0 -3
- package/dist/ui/src/components/VirtualTable/index.d.ts +0 -3
- package/dist/ui/src/components/VirtualTable/types.d.ts +0 -38
- package/dist/ui/src/components/common/SelectInputLabel.d.ts +0 -5
- package/dist/ui/src/components/index.d.ts +0 -58
- package/dist/ui/src/hooks/PortalContainerContext.d.ts +0 -31
- package/dist/ui/src/hooks/index.d.ts +0 -6
- package/dist/ui/src/hooks/useDebounceCallback.d.ts +0 -1
- package/dist/ui/src/hooks/useDebounceValue.d.ts +0 -1
- package/dist/ui/src/hooks/useDebouncedCallback.d.ts +0 -1
- package/dist/ui/src/hooks/useInjectStyles.d.ts +0 -7
- package/dist/ui/src/hooks/useOutsideAlerter.d.ts +0 -5
- package/dist/ui/src/icons/GitHubIcon.d.ts +0 -2
- package/dist/ui/src/icons/HandleIcon.d.ts +0 -1
- package/dist/ui/src/icons/Icon.d.ts +0 -20
- package/dist/ui/src/icons/cool_icon_keys.d.ts +0 -1
- package/dist/ui/src/icons/icon_keys.d.ts +0 -1
- package/dist/ui/src/icons/index.d.ts +0 -8
- package/dist/ui/src/index.d.ts +0 -5
- package/dist/ui/src/styles.d.ts +0 -12
- package/dist/ui/src/util/chip_colors.d.ts +0 -4
- package/dist/ui/src/util/cls.d.ts +0 -2
- package/dist/ui/src/util/debounce.d.ts +0 -10
- package/dist/ui/src/util/hash.d.ts +0 -1
- package/dist/ui/src/util/index.d.ts +0 -4
- package/dist/ui/src/util/key_to_icon_component.d.ts +0 -1
- /package/dist/{studio/src/components → components}/ApiExplorer/parseSpec.d.ts +0 -0
- /package/dist/{studio/src/components → components}/ApiExplorer/types.d.ts +0 -0
- /package/dist/{studio/src/components → components}/RLSEditor/index.d.ts +0 -0
- /package/dist/{studio/src/components → components}/RebaseStudio.d.ts +0 -0
- /package/dist/{studio/src/components → components}/SQLEditor/ExplainVisualizer.d.ts +0 -0
- /package/dist/{studio/src/components → components}/SchemaVisualizer/schema-visualizer.utils.d.ts +0 -0
- /package/dist/{studio/src/components → components}/SchemaVisualizer/useSchemaGraph.d.ts +0 -0
- /package/dist/{studio/src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{studio/src/utils → utils}/pgColumnToProperty.d.ts +0 -0
- /package/dist/{studio/src/utils → utils}/sql_utils.d.ts +0 -0
|
@@ -1,1069 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { c } from "react-compiler-runtime";
|
|
3
|
-
import { useState, useCallback, useEffect, useMemo, memo, useRef } from "react";
|
|
4
|
-
import { MarkerType, Position, Handle, getSmoothStepPath, EdgeLabelRenderer, BaseEdge, ReactFlowProvider, useReactFlow, applyNodeChanges, applyEdgeChanges, ReactFlow, Background, BackgroundVariant, Controls, MiniMap } from "@xyflow/react";
|
|
5
|
-
import "@xyflow/react/dist/style.css";
|
|
6
|
-
import { cls, Tooltip, Typography, Chip, CircularProgress, ResizablePanels, Button, IconButton, defaultBorderMixin, SearchBar } from "@rebasepro/ui";
|
|
7
|
-
import { IconForView, useStudioCollectionRegistry } from "@rebasepro/core";
|
|
8
|
-
import { isPostgresCollection } from "@rebasepro/types";
|
|
9
|
-
import { resolveCollectionRelations } from "@rebasepro/common";
|
|
10
|
-
import dagre from "dagre";
|
|
11
|
-
const NODE_WIDTH = 280;
|
|
12
|
-
const HEADER_HEIGHT_SINGLE = 33;
|
|
13
|
-
const HEADER_HEIGHT_DOUBLE = 47;
|
|
14
|
-
const ROW_HEIGHT = 28;
|
|
15
|
-
const getHeaderHeight = (opts) => {
|
|
16
|
-
if (opts.isJunction) return HEADER_HEIGHT_SINGLE;
|
|
17
|
-
return opts.collectionName !== opts.tableName ? HEADER_HEIGHT_DOUBLE : HEADER_HEIGHT_SINGLE;
|
|
18
|
-
};
|
|
19
|
-
const estimateNodeHeight = (columnCount, headerHeight = HEADER_HEIGHT_DOUBLE) => headerHeight + Math.max(columnCount, 1) * ROW_HEIGHT + 4;
|
|
20
|
-
const getColumnRowY = (rowIndex, headerHeight = HEADER_HEIGHT_DOUBLE) => headerHeight + rowIndex * ROW_HEIGHT + ROW_HEIGHT / 2;
|
|
21
|
-
const getLayoutedElements = (nodes, edges, direction = "LR") => {
|
|
22
|
-
const g = new dagre.graphlib.Graph();
|
|
23
|
-
g.setGraph({
|
|
24
|
-
rankdir: direction,
|
|
25
|
-
nodesep: 100,
|
|
26
|
-
ranksep: 180,
|
|
27
|
-
edgesep: 60,
|
|
28
|
-
marginx: 60,
|
|
29
|
-
marginy: 60
|
|
30
|
-
});
|
|
31
|
-
g.setDefaultEdgeLabel(() => ({}));
|
|
32
|
-
const nodeHeights = /* @__PURE__ */ new Map();
|
|
33
|
-
nodes.forEach((node) => {
|
|
34
|
-
const data = node.data;
|
|
35
|
-
const columnCount = data.columns?.length ?? 3;
|
|
36
|
-
const headerH = getHeaderHeight({
|
|
37
|
-
isJunction: Boolean(data.isJunction),
|
|
38
|
-
collectionName: data.collectionName ?? "",
|
|
39
|
-
tableName: data.tableName ?? ""
|
|
40
|
-
});
|
|
41
|
-
const h = estimateNodeHeight(columnCount, headerH);
|
|
42
|
-
nodeHeights.set(node.id, h);
|
|
43
|
-
g.setNode(node.id, {
|
|
44
|
-
width: NODE_WIDTH,
|
|
45
|
-
height: h
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
edges.forEach((edge) => {
|
|
49
|
-
g.setEdge(edge.source, edge.target);
|
|
50
|
-
});
|
|
51
|
-
dagre.layout(g);
|
|
52
|
-
const layoutedNodes = nodes.map((node) => {
|
|
53
|
-
const nodeWithPosition = g.node(node.id);
|
|
54
|
-
const h = nodeHeights.get(node.id) ?? estimateNodeHeight(3);
|
|
55
|
-
return {
|
|
56
|
-
...node,
|
|
57
|
-
data: {
|
|
58
|
-
...node.data,
|
|
59
|
-
layoutDirection: direction
|
|
60
|
-
},
|
|
61
|
-
position: {
|
|
62
|
-
x: nodeWithPosition.x - NODE_WIDTH / 2,
|
|
63
|
-
y: nodeWithPosition.y - h / 2
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
return {
|
|
68
|
-
nodes: layoutedNodes,
|
|
69
|
-
edges
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
const TYPE_LABELS = {
|
|
73
|
-
string: "varchar",
|
|
74
|
-
number: "integer",
|
|
75
|
-
boolean: "boolean",
|
|
76
|
-
date: "timestamp",
|
|
77
|
-
map: "jsonb",
|
|
78
|
-
array: "jsonb",
|
|
79
|
-
relation: "FK"
|
|
80
|
-
};
|
|
81
|
-
const getTypeLabel = (type) => TYPE_LABELS[type] ?? type;
|
|
82
|
-
const getCardinalityLabel = (cardinality, direction) => {
|
|
83
|
-
if (cardinality === "many") return "M:N";
|
|
84
|
-
if (direction === "inverse") return "1:1 ←";
|
|
85
|
-
return "N:1";
|
|
86
|
-
};
|
|
87
|
-
const extractColumns = (collection) => {
|
|
88
|
-
const columns = [];
|
|
89
|
-
const properties = collection.properties ?? {};
|
|
90
|
-
for (const [propName, prop] of Object.entries(properties)) {
|
|
91
|
-
if (prop.type === "relation") continue;
|
|
92
|
-
const isPk = "isId" in prop && Boolean(prop.isId) || !Object.values(properties).some((p) => "isId" in p && Boolean(p.isId)) && propName === "id";
|
|
93
|
-
const isEnum = prop.type === "string" && "enum" in prop && Boolean(prop.enum);
|
|
94
|
-
let enumValues;
|
|
95
|
-
if (isEnum && "enum" in prop && prop.enum) {
|
|
96
|
-
const enumProp = prop.enum;
|
|
97
|
-
if (Array.isArray(enumProp)) {
|
|
98
|
-
enumValues = enumProp.map((v) => typeof v === "string" ? v : String(v?.id ?? v));
|
|
99
|
-
} else if (typeof enumProp === "object" && enumProp !== null) {
|
|
100
|
-
enumValues = Object.keys(enumProp);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
columns.push({
|
|
104
|
-
name: propName,
|
|
105
|
-
type: prop.type,
|
|
106
|
-
typeLabel: getTypeLabel(prop.type),
|
|
107
|
-
isPrimaryKey: isPk,
|
|
108
|
-
isForeignKey: false,
|
|
109
|
-
isRequired: Boolean(prop.validation?.required),
|
|
110
|
-
isEnum,
|
|
111
|
-
enumValues
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
if (isPostgresCollection(collection)) {
|
|
115
|
-
try {
|
|
116
|
-
const resolvedRelations = resolveCollectionRelations(collection);
|
|
117
|
-
for (const rel of Object.values(resolvedRelations)) {
|
|
118
|
-
if (rel.direction === "owning" && rel.cardinality === "one" && rel.localKey) {
|
|
119
|
-
if (!columns.some((c2) => c2.name === rel.localKey)) {
|
|
120
|
-
columns.push({
|
|
121
|
-
name: rel.localKey,
|
|
122
|
-
type: "number",
|
|
123
|
-
typeLabel: "FK",
|
|
124
|
-
isPrimaryKey: false,
|
|
125
|
-
isForeignKey: true,
|
|
126
|
-
isRequired: false,
|
|
127
|
-
isEnum: false,
|
|
128
|
-
relationName: rel.relationName
|
|
129
|
-
});
|
|
130
|
-
} else {
|
|
131
|
-
const existing = columns.find((c2) => c2.name === rel.localKey);
|
|
132
|
-
if (existing) {
|
|
133
|
-
existing.isForeignKey = true;
|
|
134
|
-
existing.relationName = rel.relationName;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
} catch {
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return columns;
|
|
143
|
-
};
|
|
144
|
-
const buildGraph = (collections, direction) => {
|
|
145
|
-
const nodes = [];
|
|
146
|
-
const edges = [];
|
|
147
|
-
const tableToNodeId = /* @__PURE__ */ new Map();
|
|
148
|
-
const nodeColumns = /* @__PURE__ */ new Map();
|
|
149
|
-
const getPkHandle = (nodeId) => {
|
|
150
|
-
const cols = nodeColumns.get(nodeId);
|
|
151
|
-
const pk = cols?.find((c2) => c2.isPrimaryKey);
|
|
152
|
-
return pk ? `target-${pk.name}` : "target-default";
|
|
153
|
-
};
|
|
154
|
-
const getFkHandle = (nodeId, localKey) => {
|
|
155
|
-
if (!localKey) return "source-default";
|
|
156
|
-
const cols = nodeColumns.get(nodeId);
|
|
157
|
-
const fk = cols?.find((c2) => c2.name === localKey);
|
|
158
|
-
return fk ? `source-${fk.name}` : "source-default";
|
|
159
|
-
};
|
|
160
|
-
for (const collection of collections) {
|
|
161
|
-
if (!isPostgresCollection(collection)) continue;
|
|
162
|
-
const tableName = collection.table ?? collection.slug;
|
|
163
|
-
const nodeId = `table-${tableName}`;
|
|
164
|
-
tableToNodeId.set(tableName, nodeId);
|
|
165
|
-
const columns = extractColumns(collection);
|
|
166
|
-
nodeColumns.set(nodeId, columns);
|
|
167
|
-
const nodeData = {
|
|
168
|
-
tableName,
|
|
169
|
-
collectionName: collection.name,
|
|
170
|
-
slug: collection.slug,
|
|
171
|
-
columns,
|
|
172
|
-
isJunction: false,
|
|
173
|
-
isUnmanaged: false,
|
|
174
|
-
rlsEnabled: Boolean(collection.securityRules && collection.securityRules.length > 0),
|
|
175
|
-
historyEnabled: Boolean(collection.history),
|
|
176
|
-
icon: typeof collection.icon === "string" ? collection.icon : void 0
|
|
177
|
-
};
|
|
178
|
-
nodes.push({
|
|
179
|
-
id: nodeId,
|
|
180
|
-
type: "tableNode",
|
|
181
|
-
position: {
|
|
182
|
-
x: 0,
|
|
183
|
-
y: 0
|
|
184
|
-
},
|
|
185
|
-
data: nodeData
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
const processedJunctions = /* @__PURE__ */ new Set();
|
|
189
|
-
for (const collection of collections) {
|
|
190
|
-
if (!isPostgresCollection(collection)) continue;
|
|
191
|
-
const tableName = collection.table ?? collection.slug;
|
|
192
|
-
const sourceNodeId = tableToNodeId.get(tableName);
|
|
193
|
-
if (!sourceNodeId) continue;
|
|
194
|
-
let resolvedRelations;
|
|
195
|
-
try {
|
|
196
|
-
resolvedRelations = resolveCollectionRelations(collection);
|
|
197
|
-
} catch {
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
for (const [relationKey, rel] of Object.entries(resolvedRelations)) {
|
|
201
|
-
let targetCollection;
|
|
202
|
-
try {
|
|
203
|
-
targetCollection = rel.target();
|
|
204
|
-
} catch {
|
|
205
|
-
continue;
|
|
206
|
-
}
|
|
207
|
-
if (!isPostgresCollection(targetCollection)) continue;
|
|
208
|
-
const targetTable = targetCollection.table ?? targetCollection.slug;
|
|
209
|
-
const targetNodeId = tableToNodeId.get(targetTable);
|
|
210
|
-
if (!targetNodeId) continue;
|
|
211
|
-
if (rel.direction === "inverse") continue;
|
|
212
|
-
const edgeData = {
|
|
213
|
-
cardinality: rel.cardinality,
|
|
214
|
-
direction: rel.direction ?? "owning",
|
|
215
|
-
relationName: rel.relationName ?? relationKey,
|
|
216
|
-
hasJunction: Boolean(rel.through),
|
|
217
|
-
hasJoinPath: Boolean(rel.joinPath),
|
|
218
|
-
label: getCardinalityLabel(rel.cardinality, rel.direction ?? "owning")
|
|
219
|
-
};
|
|
220
|
-
if (rel.through && !processedJunctions.has(rel.through.table)) {
|
|
221
|
-
processedJunctions.add(rel.through.table);
|
|
222
|
-
const junctionNodeId = `junction-${rel.through.table}`;
|
|
223
|
-
const junctionColumns = [{
|
|
224
|
-
name: rel.through.sourceColumn,
|
|
225
|
-
type: "number",
|
|
226
|
-
typeLabel: "FK",
|
|
227
|
-
isPrimaryKey: true,
|
|
228
|
-
isForeignKey: true,
|
|
229
|
-
isRequired: true,
|
|
230
|
-
isEnum: false
|
|
231
|
-
}, {
|
|
232
|
-
name: rel.through.targetColumn,
|
|
233
|
-
type: "number",
|
|
234
|
-
typeLabel: "FK",
|
|
235
|
-
isPrimaryKey: true,
|
|
236
|
-
isForeignKey: true,
|
|
237
|
-
isRequired: true,
|
|
238
|
-
isEnum: false
|
|
239
|
-
}];
|
|
240
|
-
nodeColumns.set(junctionNodeId, junctionColumns);
|
|
241
|
-
nodes.push({
|
|
242
|
-
id: junctionNodeId,
|
|
243
|
-
type: "tableNode",
|
|
244
|
-
position: {
|
|
245
|
-
x: 0,
|
|
246
|
-
y: 0
|
|
247
|
-
},
|
|
248
|
-
data: {
|
|
249
|
-
tableName: rel.through.table,
|
|
250
|
-
collectionName: rel.through.table,
|
|
251
|
-
slug: rel.through.table,
|
|
252
|
-
columns: junctionColumns,
|
|
253
|
-
isJunction: true,
|
|
254
|
-
isUnmanaged: false,
|
|
255
|
-
rlsEnabled: false,
|
|
256
|
-
historyEnabled: false
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
const sourcePk = nodeColumns.get(sourceNodeId)?.find((c2) => c2.isPrimaryKey);
|
|
260
|
-
edges.push({
|
|
261
|
-
id: `edge-${sourceNodeId}-${junctionNodeId}`,
|
|
262
|
-
source: sourceNodeId,
|
|
263
|
-
target: junctionNodeId,
|
|
264
|
-
sourceHandle: sourcePk ? `source-${sourcePk.name}` : "source-default",
|
|
265
|
-
targetHandle: `target-${rel.through.sourceColumn}`,
|
|
266
|
-
type: "relationEdge",
|
|
267
|
-
data: {
|
|
268
|
-
...edgeData,
|
|
269
|
-
label: "1:N"
|
|
270
|
-
},
|
|
271
|
-
markerEnd: {
|
|
272
|
-
type: MarkerType.ArrowClosed,
|
|
273
|
-
width: 16,
|
|
274
|
-
height: 16
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
edges.push({
|
|
278
|
-
id: `edge-${junctionNodeId}-${targetNodeId}`,
|
|
279
|
-
source: junctionNodeId,
|
|
280
|
-
target: targetNodeId,
|
|
281
|
-
sourceHandle: `source-${rel.through.targetColumn}`,
|
|
282
|
-
targetHandle: getPkHandle(targetNodeId),
|
|
283
|
-
type: "relationEdge",
|
|
284
|
-
data: {
|
|
285
|
-
...edgeData,
|
|
286
|
-
label: "N:1"
|
|
287
|
-
},
|
|
288
|
-
markerEnd: {
|
|
289
|
-
type: MarkerType.ArrowClosed,
|
|
290
|
-
width: 16,
|
|
291
|
-
height: 16
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
} else if (!rel.through) {
|
|
295
|
-
edges.push({
|
|
296
|
-
id: `edge-${sourceNodeId}-${targetNodeId}-${relationKey}`,
|
|
297
|
-
source: sourceNodeId,
|
|
298
|
-
target: targetNodeId,
|
|
299
|
-
sourceHandle: getFkHandle(sourceNodeId, rel.localKey),
|
|
300
|
-
targetHandle: getPkHandle(targetNodeId),
|
|
301
|
-
type: "relationEdge",
|
|
302
|
-
data: {
|
|
303
|
-
...edgeData
|
|
304
|
-
},
|
|
305
|
-
markerEnd: {
|
|
306
|
-
type: MarkerType.ArrowClosed,
|
|
307
|
-
width: 16,
|
|
308
|
-
height: 16
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
const layoutResult = getLayoutedElements(nodes, edges, direction);
|
|
315
|
-
const nodePositions = /* @__PURE__ */ new Map();
|
|
316
|
-
for (const node of layoutResult.nodes) {
|
|
317
|
-
nodePositions.set(node.id, {
|
|
318
|
-
x: node.position.x
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
for (const edge of layoutResult.edges) {
|
|
322
|
-
const srcPos = nodePositions.get(edge.source);
|
|
323
|
-
const tgtPos = nodePositions.get(edge.target);
|
|
324
|
-
const srcBaseHandle = edge.sourceHandle ?? "source-default";
|
|
325
|
-
const tgtBaseHandle = edge.targetHandle ?? "target-default";
|
|
326
|
-
if (srcPos && tgtPos) {
|
|
327
|
-
const srcCenterX = srcPos.x + NODE_WIDTH / 2;
|
|
328
|
-
const tgtCenterX = tgtPos.x + NODE_WIDTH / 2;
|
|
329
|
-
const sourceIsLeft = srcCenterX <= tgtCenterX;
|
|
330
|
-
edge.sourceHandle = `${srcBaseHandle}-${sourceIsLeft ? "right" : "left"}`;
|
|
331
|
-
edge.targetHandle = `${tgtBaseHandle}-${sourceIsLeft ? "left" : "right"}`;
|
|
332
|
-
} else {
|
|
333
|
-
edge.sourceHandle = `${srcBaseHandle}-right`;
|
|
334
|
-
edge.targetHandle = `${tgtBaseHandle}-left`;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
return layoutResult;
|
|
338
|
-
};
|
|
339
|
-
const useSchemaGraph = (collections) => {
|
|
340
|
-
const [direction, setDirection] = useState("LR");
|
|
341
|
-
const [version, setVersion] = useState(0);
|
|
342
|
-
const relayout = useCallback(() => setVersion((v) => v + 1), []);
|
|
343
|
-
useEffect(() => {
|
|
344
|
-
setVersion((v) => v + 1);
|
|
345
|
-
}, [direction]);
|
|
346
|
-
const {
|
|
347
|
-
nodes,
|
|
348
|
-
edges,
|
|
349
|
-
tableCount,
|
|
350
|
-
relationCount
|
|
351
|
-
} = useMemo(() => {
|
|
352
|
-
if (!collections || collections.length === 0) {
|
|
353
|
-
return {
|
|
354
|
-
nodes: [],
|
|
355
|
-
edges: [],
|
|
356
|
-
tableCount: 0,
|
|
357
|
-
relationCount: 0
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
const result = buildGraph(collections, direction);
|
|
361
|
-
return {
|
|
362
|
-
...result,
|
|
363
|
-
tableCount: result.nodes.length,
|
|
364
|
-
relationCount: result.edges.length
|
|
365
|
-
};
|
|
366
|
-
}, [collections, direction, version]);
|
|
367
|
-
return {
|
|
368
|
-
nodes,
|
|
369
|
-
edges,
|
|
370
|
-
direction,
|
|
371
|
-
setDirection,
|
|
372
|
-
relayout,
|
|
373
|
-
isLoading: !collections,
|
|
374
|
-
tableCount,
|
|
375
|
-
relationCount
|
|
376
|
-
};
|
|
377
|
-
};
|
|
378
|
-
const TableNodeInner = (t0) => {
|
|
379
|
-
const $ = c(61);
|
|
380
|
-
const {
|
|
381
|
-
data,
|
|
382
|
-
selected
|
|
383
|
-
} = t0;
|
|
384
|
-
const {
|
|
385
|
-
tableName,
|
|
386
|
-
collectionName,
|
|
387
|
-
columns,
|
|
388
|
-
isJunction,
|
|
389
|
-
rlsEnabled,
|
|
390
|
-
historyEnabled,
|
|
391
|
-
icon
|
|
392
|
-
} = data;
|
|
393
|
-
let t1;
|
|
394
|
-
let result;
|
|
395
|
-
if ($[0] !== collectionName || $[1] !== columns || $[2] !== isJunction || $[3] !== tableName) {
|
|
396
|
-
result = [];
|
|
397
|
-
const cols = columns;
|
|
398
|
-
const headerH = getHeaderHeight({
|
|
399
|
-
isJunction: Boolean(isJunction),
|
|
400
|
-
collectionName,
|
|
401
|
-
tableName
|
|
402
|
-
});
|
|
403
|
-
const midY = cols.length > 0 ? getColumnRowY(Math.floor(cols.length / 2), headerH) : 30;
|
|
404
|
-
cols.forEach((col, idx) => {
|
|
405
|
-
const y = getColumnRowY(idx, headerH);
|
|
406
|
-
if (col.isForeignKey && !col.isPrimaryKey) {
|
|
407
|
-
result.push({
|
|
408
|
-
id: `source-${col.name}-right`,
|
|
409
|
-
type: "source",
|
|
410
|
-
position: Position.Right,
|
|
411
|
-
top: y
|
|
412
|
-
});
|
|
413
|
-
result.push({
|
|
414
|
-
id: `source-${col.name}-left`,
|
|
415
|
-
type: "source",
|
|
416
|
-
position: Position.Left,
|
|
417
|
-
top: y
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
if (col.isPrimaryKey) {
|
|
421
|
-
result.push({
|
|
422
|
-
id: `target-${col.name}-right`,
|
|
423
|
-
type: "target",
|
|
424
|
-
position: Position.Right,
|
|
425
|
-
top: y
|
|
426
|
-
});
|
|
427
|
-
result.push({
|
|
428
|
-
id: `target-${col.name}-left`,
|
|
429
|
-
type: "target",
|
|
430
|
-
position: Position.Left,
|
|
431
|
-
top: y
|
|
432
|
-
});
|
|
433
|
-
result.push({
|
|
434
|
-
id: `source-${col.name}-right`,
|
|
435
|
-
type: "source",
|
|
436
|
-
position: Position.Right,
|
|
437
|
-
top: y
|
|
438
|
-
});
|
|
439
|
-
result.push({
|
|
440
|
-
id: `source-${col.name}-left`,
|
|
441
|
-
type: "source",
|
|
442
|
-
position: Position.Left,
|
|
443
|
-
top: y
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
});
|
|
447
|
-
let t23;
|
|
448
|
-
if ($[5] !== midY) {
|
|
449
|
-
t23 = {
|
|
450
|
-
id: "target-default-right",
|
|
451
|
-
type: "target",
|
|
452
|
-
position: Position.Right,
|
|
453
|
-
top: midY
|
|
454
|
-
};
|
|
455
|
-
$[5] = midY;
|
|
456
|
-
$[6] = t23;
|
|
457
|
-
} else {
|
|
458
|
-
t23 = $[6];
|
|
459
|
-
}
|
|
460
|
-
result.push(t23);
|
|
461
|
-
let t32;
|
|
462
|
-
if ($[7] !== midY) {
|
|
463
|
-
t32 = {
|
|
464
|
-
id: "target-default-left",
|
|
465
|
-
type: "target",
|
|
466
|
-
position: Position.Left,
|
|
467
|
-
top: midY
|
|
468
|
-
};
|
|
469
|
-
$[7] = midY;
|
|
470
|
-
$[8] = t32;
|
|
471
|
-
} else {
|
|
472
|
-
t32 = $[8];
|
|
473
|
-
}
|
|
474
|
-
result.push(t32);
|
|
475
|
-
let t42;
|
|
476
|
-
if ($[9] !== midY) {
|
|
477
|
-
t42 = {
|
|
478
|
-
id: "source-default-right",
|
|
479
|
-
type: "source",
|
|
480
|
-
position: Position.Right,
|
|
481
|
-
top: midY
|
|
482
|
-
};
|
|
483
|
-
$[9] = midY;
|
|
484
|
-
$[10] = t42;
|
|
485
|
-
} else {
|
|
486
|
-
t42 = $[10];
|
|
487
|
-
}
|
|
488
|
-
result.push(t42);
|
|
489
|
-
let t52;
|
|
490
|
-
if ($[11] !== midY) {
|
|
491
|
-
t52 = {
|
|
492
|
-
id: "source-default-left",
|
|
493
|
-
type: "source",
|
|
494
|
-
position: Position.Left,
|
|
495
|
-
top: midY
|
|
496
|
-
};
|
|
497
|
-
$[11] = midY;
|
|
498
|
-
$[12] = t52;
|
|
499
|
-
} else {
|
|
500
|
-
t52 = $[12];
|
|
501
|
-
}
|
|
502
|
-
result.push(t52);
|
|
503
|
-
$[0] = collectionName;
|
|
504
|
-
$[1] = columns;
|
|
505
|
-
$[2] = isJunction;
|
|
506
|
-
$[3] = tableName;
|
|
507
|
-
$[4] = result;
|
|
508
|
-
} else {
|
|
509
|
-
result = $[4];
|
|
510
|
-
}
|
|
511
|
-
t1 = result;
|
|
512
|
-
const handles = t1;
|
|
513
|
-
const t2 = selected ? "border-primary ring-2 ring-primary/20 shadow-md" : "border-surface-200/40 dark:border-surface-700/40 hover:shadow-md hover:border-surface-300 dark:hover:border-surface-600";
|
|
514
|
-
const t3 = isJunction && "border-dashed";
|
|
515
|
-
let t4;
|
|
516
|
-
if ($[13] !== t2 || $[14] !== t3) {
|
|
517
|
-
t4 = cls("relative rounded-lg border bg-white dark:bg-surface-900 shadow-sm transition-all duration-200 min-w-[240px] max-w-[320px]", t2, t3);
|
|
518
|
-
$[13] = t2;
|
|
519
|
-
$[14] = t3;
|
|
520
|
-
$[15] = t4;
|
|
521
|
-
} else {
|
|
522
|
-
t4 = $[15];
|
|
523
|
-
}
|
|
524
|
-
const t5 = isJunction ? "bg-surface-50 dark:bg-surface-950/50 border-surface-200/30 dark:border-surface-700/30" : "bg-surface-50 dark:bg-surface-950 border-surface-200/40 dark:border-surface-700/40";
|
|
525
|
-
let t6;
|
|
526
|
-
if ($[16] !== t5) {
|
|
527
|
-
t6 = cls("flex items-center gap-2 px-3 py-2 border-b rounded-t-lg", t5);
|
|
528
|
-
$[16] = t5;
|
|
529
|
-
$[17] = t6;
|
|
530
|
-
} else {
|
|
531
|
-
t6 = $[17];
|
|
532
|
-
}
|
|
533
|
-
let t7;
|
|
534
|
-
if ($[18] !== collectionName || $[19] !== icon || $[20] !== isJunction || $[21] !== tableName) {
|
|
535
|
-
t7 = icon && !isJunction && /* @__PURE__ */ jsx("div", { className: "text-primary shrink-0", children: /* @__PURE__ */ jsx(IconForView, { collectionOrView: {
|
|
536
|
-
slug: tableName,
|
|
537
|
-
name: collectionName,
|
|
538
|
-
icon
|
|
539
|
-
}, size: "smallest" }) });
|
|
540
|
-
$[18] = collectionName;
|
|
541
|
-
$[19] = icon;
|
|
542
|
-
$[20] = isJunction;
|
|
543
|
-
$[21] = tableName;
|
|
544
|
-
$[22] = t7;
|
|
545
|
-
} else {
|
|
546
|
-
t7 = $[22];
|
|
547
|
-
}
|
|
548
|
-
let t8;
|
|
549
|
-
if ($[23] !== isJunction) {
|
|
550
|
-
t8 = isJunction && /* @__PURE__ */ jsx("svg", { className: "w-3.5 h-3.5 text-text-disabled dark:text-text-disabled-dark shrink-0", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4" }) });
|
|
551
|
-
$[23] = isJunction;
|
|
552
|
-
$[24] = t8;
|
|
553
|
-
} else {
|
|
554
|
-
t8 = $[24];
|
|
555
|
-
}
|
|
556
|
-
const t9 = isJunction ? "text-text-secondary dark:text-text-secondary-dark" : "text-text-primary dark:text-text-primary-dark";
|
|
557
|
-
let t10;
|
|
558
|
-
if ($[25] !== t9) {
|
|
559
|
-
t10 = cls("font-semibold truncate text-[12px]", t9);
|
|
560
|
-
$[25] = t9;
|
|
561
|
-
$[26] = t10;
|
|
562
|
-
} else {
|
|
563
|
-
t10 = $[26];
|
|
564
|
-
}
|
|
565
|
-
let t11;
|
|
566
|
-
if ($[27] !== t10 || $[28] !== tableName) {
|
|
567
|
-
t11 = /* @__PURE__ */ jsx(Typography, { variant: "caption", className: t10, children: tableName });
|
|
568
|
-
$[27] = t10;
|
|
569
|
-
$[28] = tableName;
|
|
570
|
-
$[29] = t11;
|
|
571
|
-
} else {
|
|
572
|
-
t11 = $[29];
|
|
573
|
-
}
|
|
574
|
-
let t12;
|
|
575
|
-
if ($[30] !== collectionName || $[31] !== isJunction || $[32] !== tableName) {
|
|
576
|
-
t12 = collectionName !== tableName && !isJunction && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] text-text-disabled dark:text-text-disabled-dark truncate", children: collectionName });
|
|
577
|
-
$[30] = collectionName;
|
|
578
|
-
$[31] = isJunction;
|
|
579
|
-
$[32] = tableName;
|
|
580
|
-
$[33] = t12;
|
|
581
|
-
} else {
|
|
582
|
-
t12 = $[33];
|
|
583
|
-
}
|
|
584
|
-
let t13;
|
|
585
|
-
if ($[34] !== t11 || $[35] !== t12) {
|
|
586
|
-
t13 = /* @__PURE__ */ jsxs("div", { className: "flex flex-col min-w-0", children: [
|
|
587
|
-
t11,
|
|
588
|
-
t12
|
|
589
|
-
] });
|
|
590
|
-
$[34] = t11;
|
|
591
|
-
$[35] = t12;
|
|
592
|
-
$[36] = t13;
|
|
593
|
-
} else {
|
|
594
|
-
t13 = $[36];
|
|
595
|
-
}
|
|
596
|
-
let t14;
|
|
597
|
-
if ($[37] !== rlsEnabled) {
|
|
598
|
-
t14 = rlsEnabled && /* @__PURE__ */ jsx(Tooltip, { title: "RLS enabled", children: /* @__PURE__ */ jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-green-500" }) });
|
|
599
|
-
$[37] = rlsEnabled;
|
|
600
|
-
$[38] = t14;
|
|
601
|
-
} else {
|
|
602
|
-
t14 = $[38];
|
|
603
|
-
}
|
|
604
|
-
let t15;
|
|
605
|
-
if ($[39] !== historyEnabled) {
|
|
606
|
-
t15 = historyEnabled && /* @__PURE__ */ jsx(Tooltip, { title: "History enabled", children: /* @__PURE__ */ jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-blue-400" }) });
|
|
607
|
-
$[39] = historyEnabled;
|
|
608
|
-
$[40] = t15;
|
|
609
|
-
} else {
|
|
610
|
-
t15 = $[40];
|
|
611
|
-
}
|
|
612
|
-
let t16;
|
|
613
|
-
if ($[41] !== t14 || $[42] !== t15) {
|
|
614
|
-
t16 = /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-1 shrink-0", children: [
|
|
615
|
-
t14,
|
|
616
|
-
t15
|
|
617
|
-
] });
|
|
618
|
-
$[41] = t14;
|
|
619
|
-
$[42] = t15;
|
|
620
|
-
$[43] = t16;
|
|
621
|
-
} else {
|
|
622
|
-
t16 = $[43];
|
|
623
|
-
}
|
|
624
|
-
let t17;
|
|
625
|
-
if ($[44] !== t13 || $[45] !== t16 || $[46] !== t6 || $[47] !== t7 || $[48] !== t8) {
|
|
626
|
-
t17 = /* @__PURE__ */ jsxs("div", { className: t6, children: [
|
|
627
|
-
t7,
|
|
628
|
-
t8,
|
|
629
|
-
t13,
|
|
630
|
-
t16
|
|
631
|
-
] });
|
|
632
|
-
$[44] = t13;
|
|
633
|
-
$[45] = t16;
|
|
634
|
-
$[46] = t6;
|
|
635
|
-
$[47] = t7;
|
|
636
|
-
$[48] = t8;
|
|
637
|
-
$[49] = t17;
|
|
638
|
-
} else {
|
|
639
|
-
t17 = $[49];
|
|
640
|
-
}
|
|
641
|
-
const t18 = columns;
|
|
642
|
-
let t19;
|
|
643
|
-
if ($[50] !== t18) {
|
|
644
|
-
t19 = t18.map(_temp);
|
|
645
|
-
$[50] = t18;
|
|
646
|
-
$[51] = t19;
|
|
647
|
-
} else {
|
|
648
|
-
t19 = $[51];
|
|
649
|
-
}
|
|
650
|
-
let t20;
|
|
651
|
-
if ($[52] !== t19) {
|
|
652
|
-
t20 = /* @__PURE__ */ jsx("div", { className: "divide-y divide-surface-100 dark:divide-surface-950/60", children: t19 });
|
|
653
|
-
$[52] = t19;
|
|
654
|
-
$[53] = t20;
|
|
655
|
-
} else {
|
|
656
|
-
t20 = $[53];
|
|
657
|
-
}
|
|
658
|
-
let t21;
|
|
659
|
-
if ($[54] !== handles) {
|
|
660
|
-
t21 = handles.map(_temp2);
|
|
661
|
-
$[54] = handles;
|
|
662
|
-
$[55] = t21;
|
|
663
|
-
} else {
|
|
664
|
-
t21 = $[55];
|
|
665
|
-
}
|
|
666
|
-
let t22;
|
|
667
|
-
if ($[56] !== t17 || $[57] !== t20 || $[58] !== t21 || $[59] !== t4) {
|
|
668
|
-
t22 = /* @__PURE__ */ jsxs("div", { className: t4, children: [
|
|
669
|
-
t17,
|
|
670
|
-
t20,
|
|
671
|
-
t21
|
|
672
|
-
] });
|
|
673
|
-
$[56] = t17;
|
|
674
|
-
$[57] = t20;
|
|
675
|
-
$[58] = t21;
|
|
676
|
-
$[59] = t4;
|
|
677
|
-
$[60] = t22;
|
|
678
|
-
} else {
|
|
679
|
-
t22 = $[60];
|
|
680
|
-
}
|
|
681
|
-
return t22;
|
|
682
|
-
};
|
|
683
|
-
const TableNode = memo(TableNodeInner);
|
|
684
|
-
function _temp(col_0) {
|
|
685
|
-
return /* @__PURE__ */ jsxs("div", { className: cls("flex items-center gap-2 px-3 py-1.5 text-xs transition-colors", col_0.isPrimaryKey && "bg-amber-50/50 dark:bg-amber-950/10", col_0.isForeignKey && !col_0.isPrimaryKey && "bg-blue-50/40 dark:bg-blue-950/10"), children: [
|
|
686
|
-
/* @__PURE__ */ jsxs("span", { className: "w-3 shrink-0 text-center", children: [
|
|
687
|
-
col_0.isPrimaryKey && /* @__PURE__ */ jsx(Tooltip, { title: "Primary Key", children: /* @__PURE__ */ jsx("span", { className: "text-amber-500 text-[10px] font-bold", children: "🔑" }) }),
|
|
688
|
-
col_0.isForeignKey && !col_0.isPrimaryKey && /* @__PURE__ */ jsx(Tooltip, { title: `FK → ${col_0.relationName ?? "?"}`, children: /* @__PURE__ */ jsx("span", { className: "text-blue-400 text-[10px] font-bold", children: "🔗" }) })
|
|
689
|
-
] }),
|
|
690
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: cls("font-mono text-[11px] truncate flex-1 min-w-0", col_0.isPrimaryKey ? "font-semibold text-amber-700 dark:text-amber-400" : col_0.isForeignKey ? "text-blue-600 dark:text-blue-400" : "text-text-primary dark:text-text-primary-dark"), children: col_0.name }),
|
|
691
|
-
col_0.isEnum ? /* @__PURE__ */ jsx(Chip, { size: "smallest", className: "bg-violet-100 text-violet-700 dark:bg-violet-900/30 dark:text-violet-400 border-violet-200 dark:border-violet-800 text-[9px] py-0", children: "enum" }) : /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] text-text-disabled dark:text-text-disabled-dark font-mono shrink-0", children: col_0.typeLabel }),
|
|
692
|
-
col_0.isRequired && !col_0.isPrimaryKey && /* @__PURE__ */ jsx(Tooltip, { title: "Required", children: /* @__PURE__ */ jsx("span", { className: "text-red-400 text-[9px]", children: "•" }) })
|
|
693
|
-
] }, col_0.name);
|
|
694
|
-
}
|
|
695
|
-
function _temp2(h) {
|
|
696
|
-
return /* @__PURE__ */ jsx(Handle, { id: h.id, type: h.type, position: h.position, style: {
|
|
697
|
-
top: h.top
|
|
698
|
-
}, className: cls("!w-2 !h-2 !border-2 !border-white dark:!border-surface-900", h.type === "source" ? "!bg-blue-400" : "!bg-amber-400") }, h.id);
|
|
699
|
-
}
|
|
700
|
-
const RelationEdgeInner = (t0) => {
|
|
701
|
-
const $ = c(26);
|
|
702
|
-
const {
|
|
703
|
-
id,
|
|
704
|
-
sourceX,
|
|
705
|
-
sourceY,
|
|
706
|
-
targetX,
|
|
707
|
-
targetY,
|
|
708
|
-
sourcePosition,
|
|
709
|
-
targetPosition,
|
|
710
|
-
data,
|
|
711
|
-
selected
|
|
712
|
-
} = t0;
|
|
713
|
-
const edgeData = data;
|
|
714
|
-
let t1;
|
|
715
|
-
if ($[0] !== sourcePosition || $[1] !== sourceX || $[2] !== sourceY || $[3] !== targetPosition || $[4] !== targetX || $[5] !== targetY) {
|
|
716
|
-
t1 = getSmoothStepPath({
|
|
717
|
-
sourceX,
|
|
718
|
-
sourceY,
|
|
719
|
-
sourcePosition,
|
|
720
|
-
targetX,
|
|
721
|
-
targetY,
|
|
722
|
-
targetPosition,
|
|
723
|
-
borderRadius: 8
|
|
724
|
-
});
|
|
725
|
-
$[0] = sourcePosition;
|
|
726
|
-
$[1] = sourceX;
|
|
727
|
-
$[2] = sourceY;
|
|
728
|
-
$[3] = targetPosition;
|
|
729
|
-
$[4] = targetX;
|
|
730
|
-
$[5] = targetY;
|
|
731
|
-
$[6] = t1;
|
|
732
|
-
} else {
|
|
733
|
-
t1 = $[6];
|
|
734
|
-
}
|
|
735
|
-
const [edgePath, labelX, labelY] = t1;
|
|
736
|
-
const isInverse = edgeData?.direction === "inverse";
|
|
737
|
-
const isJoinPath = edgeData?.hasJoinPath;
|
|
738
|
-
const isJunction = edgeData?.hasJunction;
|
|
739
|
-
let strokeColor;
|
|
740
|
-
let strokeDasharray;
|
|
741
|
-
let strokeWidth = 1.5;
|
|
742
|
-
if (selected) {
|
|
743
|
-
strokeColor = "var(--rf-edge-stroke-selected, #6366f1)";
|
|
744
|
-
strokeWidth = 2.5;
|
|
745
|
-
} else {
|
|
746
|
-
if (isJunction) {
|
|
747
|
-
strokeColor = "#8b5cf6";
|
|
748
|
-
} else {
|
|
749
|
-
if (isInverse) {
|
|
750
|
-
strokeDasharray = "6 3";
|
|
751
|
-
strokeColor = "#94a3b8";
|
|
752
|
-
} else {
|
|
753
|
-
if (isJoinPath) {
|
|
754
|
-
strokeDasharray = "3 3";
|
|
755
|
-
strokeColor = "#94a3b8";
|
|
756
|
-
} else {
|
|
757
|
-
strokeColor = "#6366f1";
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
let t2;
|
|
763
|
-
if ($[7] !== strokeColor || $[8] !== strokeDasharray || $[9] !== strokeWidth) {
|
|
764
|
-
t2 = {
|
|
765
|
-
stroke: strokeColor,
|
|
766
|
-
strokeWidth,
|
|
767
|
-
strokeDasharray
|
|
768
|
-
};
|
|
769
|
-
$[7] = strokeColor;
|
|
770
|
-
$[8] = strokeDasharray;
|
|
771
|
-
$[9] = strokeWidth;
|
|
772
|
-
$[10] = t2;
|
|
773
|
-
} else {
|
|
774
|
-
t2 = $[10];
|
|
775
|
-
}
|
|
776
|
-
let t3;
|
|
777
|
-
if ($[11] !== edgePath || $[12] !== id || $[13] !== t2) {
|
|
778
|
-
t3 = /* @__PURE__ */ jsx(BaseEdge, { id, path: edgePath, style: t2 });
|
|
779
|
-
$[11] = edgePath;
|
|
780
|
-
$[12] = id;
|
|
781
|
-
$[13] = t2;
|
|
782
|
-
$[14] = t3;
|
|
783
|
-
} else {
|
|
784
|
-
t3 = $[14];
|
|
785
|
-
}
|
|
786
|
-
let t4;
|
|
787
|
-
if ($[15] !== edgeData || $[16] !== isInverse || $[17] !== isJoinPath || $[18] !== isJunction || $[19] !== labelX || $[20] !== labelY || $[21] !== selected) {
|
|
788
|
-
t4 = edgeData?.label && /* @__PURE__ */ jsx(EdgeLabelRenderer, { children: /* @__PURE__ */ jsx("div", { style: {
|
|
789
|
-
position: "absolute",
|
|
790
|
-
transform: `translate(-50%, -50%) translate(${labelX}px,${labelY}px)`,
|
|
791
|
-
pointerEvents: "all"
|
|
792
|
-
}, className: cls("px-1.5 py-0.5 rounded text-[9px] font-mono font-semibold leading-none", "bg-white dark:bg-surface-900 border", selected ? "border-primary text-primary" : isJunction ? "border-violet-200 dark:border-violet-800 text-violet-600 dark:text-violet-400" : isInverse || isJoinPath ? "border-surface-200 dark:border-surface-700 text-text-disabled dark:text-text-disabled-dark" : "border-primary/30 dark:border-primary/30 text-primary"), children: edgeData.label }) });
|
|
793
|
-
$[15] = edgeData;
|
|
794
|
-
$[16] = isInverse;
|
|
795
|
-
$[17] = isJoinPath;
|
|
796
|
-
$[18] = isJunction;
|
|
797
|
-
$[19] = labelX;
|
|
798
|
-
$[20] = labelY;
|
|
799
|
-
$[21] = selected;
|
|
800
|
-
$[22] = t4;
|
|
801
|
-
} else {
|
|
802
|
-
t4 = $[22];
|
|
803
|
-
}
|
|
804
|
-
let t5;
|
|
805
|
-
if ($[23] !== t3 || $[24] !== t4) {
|
|
806
|
-
t5 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
807
|
-
t3,
|
|
808
|
-
t4
|
|
809
|
-
] });
|
|
810
|
-
$[23] = t3;
|
|
811
|
-
$[24] = t4;
|
|
812
|
-
$[25] = t5;
|
|
813
|
-
} else {
|
|
814
|
-
t5 = $[25];
|
|
815
|
-
}
|
|
816
|
-
return t5;
|
|
817
|
-
};
|
|
818
|
-
const RelationEdge = memo(RelationEdgeInner);
|
|
819
|
-
const nodeTypes = {
|
|
820
|
-
tableNode: TableNode
|
|
821
|
-
};
|
|
822
|
-
const edgeTypes = {
|
|
823
|
-
relationEdge: RelationEdge
|
|
824
|
-
};
|
|
825
|
-
function SchemaVisualizerCanvas({
|
|
826
|
-
collections
|
|
827
|
-
}) {
|
|
828
|
-
const reactFlowInstance = useReactFlow();
|
|
829
|
-
const {
|
|
830
|
-
nodes: layoutedNodes,
|
|
831
|
-
edges: layoutedEdges,
|
|
832
|
-
direction,
|
|
833
|
-
setDirection,
|
|
834
|
-
relayout,
|
|
835
|
-
tableCount,
|
|
836
|
-
relationCount
|
|
837
|
-
} = useSchemaGraph(collections);
|
|
838
|
-
const [nodes, setNodes] = useState([]);
|
|
839
|
-
const [edges, setEdges] = useState([]);
|
|
840
|
-
const [selectedTable, setSelectedTable] = useState(null);
|
|
841
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
842
|
-
const initialFitDone = useRef(false);
|
|
843
|
-
useEffect(() => {
|
|
844
|
-
setNodes(layoutedNodes);
|
|
845
|
-
setEdges(layoutedEdges);
|
|
846
|
-
}, [layoutedNodes, layoutedEdges]);
|
|
847
|
-
const onNodesChange = useCallback((changes) => setNodes((nds) => applyNodeChanges(changes, nds)), []);
|
|
848
|
-
const onEdgesChange = useCallback((changes_0) => setEdges((eds) => applyEdgeChanges(changes_0, eds)), []);
|
|
849
|
-
useEffect(() => {
|
|
850
|
-
if (nodes.length > 0 && !initialFitDone.current) {
|
|
851
|
-
const timer = setTimeout(() => {
|
|
852
|
-
reactFlowInstance.fitView({
|
|
853
|
-
padding: 0.15,
|
|
854
|
-
duration: 400
|
|
855
|
-
});
|
|
856
|
-
initialFitDone.current = true;
|
|
857
|
-
}, 200);
|
|
858
|
-
return () => clearTimeout(timer);
|
|
859
|
-
}
|
|
860
|
-
return void 0;
|
|
861
|
-
}, [nodes.length, reactFlowInstance]);
|
|
862
|
-
const handleFitView = useCallback(() => {
|
|
863
|
-
reactFlowInstance.fitView({
|
|
864
|
-
padding: 0.15,
|
|
865
|
-
duration: 400
|
|
866
|
-
});
|
|
867
|
-
}, [reactFlowInstance]);
|
|
868
|
-
const handleNodeClick = useCallback((_, node) => {
|
|
869
|
-
setSelectedTable(node.id);
|
|
870
|
-
}, []);
|
|
871
|
-
const handlePaneClick = useCallback(() => {
|
|
872
|
-
setSelectedTable(null);
|
|
873
|
-
}, []);
|
|
874
|
-
const handleTableSelect = useCallback((nodeId) => {
|
|
875
|
-
setSelectedTable(nodeId);
|
|
876
|
-
const node_0 = nodes.find((n) => n.id === nodeId);
|
|
877
|
-
if (node_0) {
|
|
878
|
-
reactFlowInstance.setCenter(node_0.position.x + 140, node_0.position.y + 60, {
|
|
879
|
-
zoom: 1.2,
|
|
880
|
-
duration: 400
|
|
881
|
-
});
|
|
882
|
-
}
|
|
883
|
-
}, [nodes, reactFlowInstance]);
|
|
884
|
-
const [sidebarSize, setSidebarSize] = useState(() => {
|
|
885
|
-
try {
|
|
886
|
-
const saved = localStorage.getItem("rebase_schema_viz_sidebar_size");
|
|
887
|
-
return saved !== null ? parseFloat(saved) : 20;
|
|
888
|
-
} catch {
|
|
889
|
-
return 20;
|
|
890
|
-
}
|
|
891
|
-
});
|
|
892
|
-
useEffect(() => {
|
|
893
|
-
try {
|
|
894
|
-
localStorage.setItem("rebase_schema_viz_sidebar_size", sidebarSize.toString());
|
|
895
|
-
} catch {
|
|
896
|
-
}
|
|
897
|
-
}, [sidebarSize]);
|
|
898
|
-
const postgresCollections = useMemo(() => collections.filter(isPostgresCollection), [collections]);
|
|
899
|
-
const filteredCollections = useMemo(() => {
|
|
900
|
-
if (!searchQuery.trim()) return postgresCollections;
|
|
901
|
-
const q = searchQuery.toLowerCase();
|
|
902
|
-
return postgresCollections.filter((c2) => c2.name.toLowerCase().includes(q) || c2.table?.toLowerCase().includes(q) || c2.slug?.toLowerCase().includes(q));
|
|
903
|
-
}, [postgresCollections, searchQuery]);
|
|
904
|
-
const junctionNodes = useMemo(() => nodes.filter((n_0) => n_0.data.isJunction), [nodes]);
|
|
905
|
-
const stats = useMemo(() => ({
|
|
906
|
-
tables: tableCount,
|
|
907
|
-
relations: relationCount,
|
|
908
|
-
junctions: junctionNodes.length,
|
|
909
|
-
withRls: postgresCollections.filter((c_0) => isPostgresCollection(c_0) && c_0.securityRules && c_0.securityRules.length > 0).length
|
|
910
|
-
}), [tableCount, relationCount, junctionNodes.length, postgresCollections]);
|
|
911
|
-
return /* @__PURE__ */ jsx(ResizablePanels, { orientation: "horizontal", panelSizePercent: sidebarSize, onPanelSizeChange: setSidebarSize, minPanelSizePx: 220, firstPanel: /* @__PURE__ */ jsxs("div", { className: cls("flex flex-col h-full w-full bg-white dark:bg-surface-950 border-r", defaultBorderMixin), children: [
|
|
912
|
-
/* @__PURE__ */ jsxs("div", { className: cls("flex items-center justify-between px-3 py-2 border-b bg-surface-50 dark:bg-surface-900 min-h-[48px]", defaultBorderMixin), children: [
|
|
913
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "font-bold uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark", children: "Tables" }),
|
|
914
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] text-text-disabled dark:text-text-disabled-dark font-mono", children: stats.tables })
|
|
915
|
-
] }),
|
|
916
|
-
/* @__PURE__ */ jsx("div", { className: "px-2 py-1.5 border-b border-surface-200/40 dark:border-surface-700/40", children: /* @__PURE__ */ jsx(SearchBar, { size: "smallest", placeholder: "Filter tables…", onTextSearch: (val) => setSearchQuery(val ?? ""), innerClassName: "text-xs" }) }),
|
|
917
|
-
/* @__PURE__ */ jsxs("div", { className: "flex-grow overflow-y-auto no-scrollbar p-1", children: [
|
|
918
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-0.5", children: filteredCollections.map((collection) => {
|
|
919
|
-
const table = collection.table ?? collection.slug;
|
|
920
|
-
const nodeId_0 = `table-${table}`;
|
|
921
|
-
const isSelected = selectedTable === nodeId_0;
|
|
922
|
-
return /* @__PURE__ */ jsxs("div", { onClick: () => handleTableSelect(nodeId_0), className: cls("flex items-center p-1.5 cursor-pointer rounded transition-colors group", isSelected ? "bg-primary/10 text-primary dark:bg-primary/20 dark:text-primary-light" : "hover:bg-surface-100 dark:hover:bg-surface-950 text-text-secondary dark:text-text-secondary-dark"), children: [
|
|
923
|
-
/* @__PURE__ */ jsx("div", { className: "shrink-0 mr-1.5 text-text-disabled dark:text-text-disabled-dark", children: /* @__PURE__ */ jsx(IconForView, { collectionOrView: {
|
|
924
|
-
slug: collection.slug,
|
|
925
|
-
name: collection.name,
|
|
926
|
-
icon: typeof collection.icon === "string" ? collection.icon : void 0
|
|
927
|
-
}, size: "smallest" }) }),
|
|
928
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col min-w-0 flex-1", children: [
|
|
929
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-xs truncate font-medium", children: collection.name }),
|
|
930
|
-
table !== collection.name && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] text-text-disabled dark:text-text-disabled-dark font-mono truncate", children: table })
|
|
931
|
-
] }),
|
|
932
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 shrink-0 ml-1", children: [
|
|
933
|
-
isPostgresCollection(collection) && collection.securityRules && collection.securityRules.length > 0 && /* @__PURE__ */ jsx(Tooltip, { title: "RLS enabled", children: /* @__PURE__ */ jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-green-500" }) }),
|
|
934
|
-
collection.history && /* @__PURE__ */ jsx(Tooltip, { title: "History enabled", children: /* @__PURE__ */ jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-blue-400" }) })
|
|
935
|
-
] })
|
|
936
|
-
] }, nodeId_0);
|
|
937
|
-
}) }),
|
|
938
|
-
junctionNodes.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-3", children: [
|
|
939
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "px-1.5 text-[10px] uppercase tracking-wider text-text-disabled dark:text-text-disabled-dark font-medium", children: "Junction Tables" }),
|
|
940
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1 space-y-0.5", children: junctionNodes.map((node_1) => {
|
|
941
|
-
const d = node_1.data;
|
|
942
|
-
const isSelected_0 = selectedTable === node_1.id;
|
|
943
|
-
return /* @__PURE__ */ jsxs("div", { onClick: () => handleTableSelect(node_1.id), className: cls("flex items-center p-1.5 cursor-pointer rounded transition-colors", isSelected_0 ? "bg-primary/10 text-primary dark:bg-primary/20" : "hover:bg-surface-100 dark:hover:bg-surface-950 text-text-disabled dark:text-text-disabled-dark"), children: [
|
|
944
|
-
/* @__PURE__ */ jsx("svg", { className: "w-3.5 h-3.5 mr-1.5 shrink-0", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4" }) }),
|
|
945
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-xs font-mono truncate", children: d.tableName })
|
|
946
|
-
] }, node_1.id);
|
|
947
|
-
}) })
|
|
948
|
-
] })
|
|
949
|
-
] }),
|
|
950
|
-
/* @__PURE__ */ jsxs("div", { className: cls("px-3 py-2 border-t bg-surface-50 dark:bg-surface-900 space-y-1", defaultBorderMixin), children: [
|
|
951
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
952
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] text-text-disabled dark:text-text-disabled-dark", children: "Tables" }),
|
|
953
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] font-mono font-medium", children: stats.tables })
|
|
954
|
-
] }),
|
|
955
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
956
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] text-text-disabled dark:text-text-disabled-dark", children: "Relations" }),
|
|
957
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] font-mono font-medium", children: stats.relations })
|
|
958
|
-
] }),
|
|
959
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
960
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] text-text-disabled dark:text-text-disabled-dark", children: "RLS protected" }),
|
|
961
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
962
|
-
/* @__PURE__ */ jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-green-500" }),
|
|
963
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] font-mono font-medium", children: stats.withRls })
|
|
964
|
-
] })
|
|
965
|
-
] })
|
|
966
|
-
] })
|
|
967
|
-
] }), secondPanel: /* @__PURE__ */ jsxs("div", { className: "flex-grow flex flex-col min-w-0 h-full w-full bg-white dark:bg-surface-950", children: [
|
|
968
|
-
/* @__PURE__ */ jsxs("div", { className: cls("flex items-center justify-between pr-2 border-b bg-white dark:bg-surface-950 min-h-[46px]", defaultBorderMixin), children: [
|
|
969
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 px-4", children: /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "font-mono text-text-secondary dark:text-text-secondary-dark", children: "Schema Visualizer" }) }),
|
|
970
|
-
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [
|
|
971
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center bg-surface-100 dark:bg-surface-950 rounded-md border border-surface-200/40 dark:border-surface-700/40", children: [
|
|
972
|
-
/* @__PURE__ */ jsx(Tooltip, { title: "Left to right layout", children: /* @__PURE__ */ jsx(Button, { size: "small", variant: direction === "LR" ? "filled" : "text", color: direction === "LR" ? "primary" : "neutral", onClick: () => setDirection("LR"), className: "!rounded-r-none !px-2 !py-1 !text-[10px] !font-mono", children: "LR" }) }),
|
|
973
|
-
/* @__PURE__ */ jsx(Tooltip, { title: "Top to bottom layout", children: /* @__PURE__ */ jsx(Button, { size: "small", variant: direction === "TB" ? "filled" : "text", color: direction === "TB" ? "primary" : "neutral", onClick: () => setDirection("TB"), className: "!rounded-l-none !px-2 !py-1 !text-[10px] !font-mono", children: "TB" }) })
|
|
974
|
-
] }),
|
|
975
|
-
/* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-surface-200 dark:bg-surface-950 mx-0.5" }),
|
|
976
|
-
/* @__PURE__ */ jsx(Tooltip, { title: "Fit to view", children: /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: handleFitView, children: /* @__PURE__ */ jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" }) }) }) }),
|
|
977
|
-
/* @__PURE__ */ jsx(Tooltip, { title: "Re-layout", children: /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: relayout, children: /* @__PURE__ */ jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, 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" }) }) }) })
|
|
978
|
-
] })
|
|
979
|
-
] }),
|
|
980
|
-
/* @__PURE__ */ jsxs("div", { className: "flex-grow relative", children: [
|
|
981
|
-
/* @__PURE__ */ jsxs(ReactFlow, { nodes, edges, onNodesChange, onEdgesChange, onNodeClick: handleNodeClick, onPaneClick: handlePaneClick, nodeTypes, edgeTypes, fitView: true, fitViewOptions: {
|
|
982
|
-
padding: 0.15
|
|
983
|
-
}, minZoom: 0.1, maxZoom: 2, proOptions: {
|
|
984
|
-
hideAttribution: true
|
|
985
|
-
}, className: "bg-surface-50 dark:bg-surface-950", children: [
|
|
986
|
-
/* @__PURE__ */ jsx(Background, { variant: BackgroundVariant.Dots, gap: 20, size: 1, className: "!bg-surface-50 dark:!bg-surface-950", color: "var(--rf-bg-dot, #d4d4d8)" }),
|
|
987
|
-
/* @__PURE__ */ jsx(Controls, { showInteractive: false, className: "!bg-white dark:!bg-surface-900 !border !border-surface-200/40 dark:!border-surface-700/40 !shadow-sm !rounded-lg" }),
|
|
988
|
-
/* @__PURE__ */ jsx(MiniMap, { nodeStrokeColor: (n_1) => {
|
|
989
|
-
const d_0 = n_1.data;
|
|
990
|
-
if (d_0.isJunction) return "#a78bfa";
|
|
991
|
-
if (d_0.rlsEnabled) return "#22c55e";
|
|
992
|
-
return "#6366f1";
|
|
993
|
-
}, nodeColor: (n_2) => {
|
|
994
|
-
const d_1 = n_2.data;
|
|
995
|
-
if (d_1.isJunction) return "#ede9fe";
|
|
996
|
-
return "#eef2ff";
|
|
997
|
-
}, maskColor: "rgba(0,0,0,0.08)", className: "!bg-white dark:!bg-surface-900 !border !border-surface-200/40 dark:!border-surface-700/40 !shadow-sm !rounded-lg" })
|
|
998
|
-
] }),
|
|
999
|
-
/* @__PURE__ */ jsxs("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", children: [
|
|
1000
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
1001
|
-
/* @__PURE__ */ jsx("div", { className: "w-6 h-0.5 bg-indigo-500 rounded" }),
|
|
1002
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] text-text-disabled dark:text-text-disabled-dark", children: "Owning" })
|
|
1003
|
-
] }),
|
|
1004
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
1005
|
-
/* @__PURE__ */ jsx("div", { className: "w-6 h-0.5 bg-violet-500 rounded" }),
|
|
1006
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] text-text-disabled dark:text-text-disabled-dark", children: "M:N" })
|
|
1007
|
-
] }),
|
|
1008
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
1009
|
-
/* @__PURE__ */ jsx("div", { className: "w-6 h-0.5 rounded", style: {
|
|
1010
|
-
backgroundImage: "repeating-linear-gradient(90deg, #94a3b8, #94a3b8 4px, transparent 4px, transparent 7px)"
|
|
1011
|
-
} }),
|
|
1012
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] text-text-disabled dark:text-text-disabled-dark", children: "Inverse" })
|
|
1013
|
-
] }),
|
|
1014
|
-
/* @__PURE__ */ jsx("div", { className: "h-3 w-px bg-surface-200 dark:bg-surface-700" }),
|
|
1015
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
1016
|
-
/* @__PURE__ */ jsx("span", { className: "text-[9px]", children: "🔑" }),
|
|
1017
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] text-text-disabled dark:text-text-disabled-dark", children: "PK" })
|
|
1018
|
-
] }),
|
|
1019
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
1020
|
-
/* @__PURE__ */ jsx("span", { className: "text-[9px]", children: "🔗" }),
|
|
1021
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-[10px] text-text-disabled dark:text-text-disabled-dark", children: "FK" })
|
|
1022
|
-
] })
|
|
1023
|
-
] })
|
|
1024
|
-
] })
|
|
1025
|
-
] }) });
|
|
1026
|
-
}
|
|
1027
|
-
const SchemaVisualizer = () => {
|
|
1028
|
-
const $ = c(5);
|
|
1029
|
-
const {
|
|
1030
|
-
collections: registryCollections
|
|
1031
|
-
} = useStudioCollectionRegistry();
|
|
1032
|
-
let t0;
|
|
1033
|
-
let t1;
|
|
1034
|
-
if ($[0] !== registryCollections) {
|
|
1035
|
-
t1 = registryCollections ?? [];
|
|
1036
|
-
$[0] = registryCollections;
|
|
1037
|
-
$[1] = t1;
|
|
1038
|
-
} else {
|
|
1039
|
-
t1 = $[1];
|
|
1040
|
-
}
|
|
1041
|
-
t0 = t1;
|
|
1042
|
-
const collections = t0;
|
|
1043
|
-
if (!collections || collections.length === 0) {
|
|
1044
|
-
let t22;
|
|
1045
|
-
if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
1046
|
-
t22 = /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full w-full", children: /* @__PURE__ */ jsxs("div", { className: "text-center space-y-3", children: [
|
|
1047
|
-
/* @__PURE__ */ jsx(CircularProgress, { size: "small" }),
|
|
1048
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body2", color: "secondary", children: "Loading schema…" })
|
|
1049
|
-
] }) });
|
|
1050
|
-
$[2] = t22;
|
|
1051
|
-
} else {
|
|
1052
|
-
t22 = $[2];
|
|
1053
|
-
}
|
|
1054
|
-
return t22;
|
|
1055
|
-
}
|
|
1056
|
-
let t2;
|
|
1057
|
-
if ($[3] !== collections) {
|
|
1058
|
-
t2 = /* @__PURE__ */ jsx("div", { className: "flex h-full w-full bg-white dark:bg-surface-950 overflow-hidden text-text-primary dark:text-text-primary-dark", children: /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(SchemaVisualizerCanvas, { collections }) }) });
|
|
1059
|
-
$[3] = collections;
|
|
1060
|
-
$[4] = t2;
|
|
1061
|
-
} else {
|
|
1062
|
-
t2 = $[4];
|
|
1063
|
-
}
|
|
1064
|
-
return t2;
|
|
1065
|
-
};
|
|
1066
|
-
export {
|
|
1067
|
-
SchemaVisualizer
|
|
1068
|
-
};
|
|
1069
|
-
//# sourceMappingURL=SchemaVisualizer-BGpmzyXT.js.map
|