@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 @@
|
|
|
1
|
+
export * from "./RLSEditor";
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React, { lazy, Suspense, useLayoutEffect, useMemo } from "react";
|
|
2
|
+
import { useRebaseRegistryDispatch } from "@rebasepro/core";
|
|
3
|
+
import type { RebaseStudioConfig, AppView } from "@rebasepro/types";
|
|
4
|
+
import { CircularProgressCenter } from "@rebasepro/ui";
|
|
5
|
+
|
|
6
|
+
// Lazy-loaded studio tools — each fetched only when its route is visited.
|
|
7
|
+
// This keeps Monaco, @xyflow/react, dagre, pgsql-ast-parser etc. out of the initial bundle.
|
|
8
|
+
const SQLEditor = lazy(() => import("./SQLEditor/SQLEditor").then(m => ({ default: m.SQLEditor })));
|
|
9
|
+
const JSEditor = lazy(() => import("./JSEditor/JSEditor").then(m => ({ default: m.JSEditor })));
|
|
10
|
+
const RLSEditor = lazy(() => import("./RLSEditor/RLSEditor").then(m => ({ default: m.RLSEditor })));
|
|
11
|
+
const StorageView = lazy(() => import("./StorageView/StorageView").then(m => ({ default: m.StorageView })));
|
|
12
|
+
const CronJobsView = lazy(() => import("./CronJobs/CronJobsView").then(m => ({ default: m.CronJobsView })));
|
|
13
|
+
const SchemaVisualizer = lazy(() => import("./SchemaVisualizer/SchemaVisualizer").then(m => ({ default: m.SchemaVisualizer })));
|
|
14
|
+
const BranchesView = lazy(() => import("./Branches/BranchesView").then(m => ({ default: m.BranchesView })));
|
|
15
|
+
const ApiExplorer = lazy(() => import("./ApiExplorer/ApiExplorer").then(m => ({ default: m.ApiExplorer })));
|
|
16
|
+
|
|
17
|
+
import { StudioHomePage } from "./StudioHomePage";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Declarative component to configure the Studio in Rebase.
|
|
21
|
+
* Renders nothing — purely registers config into the RebaseRegistry.
|
|
22
|
+
*
|
|
23
|
+
* The "schema" tool (collection editor view) is now a built-in CMS feature.
|
|
24
|
+
* When `<RebaseCMS collectionEditor={...}>` is used, the schema view is
|
|
25
|
+
* automatically injected into Studio — no manual wiring needed.
|
|
26
|
+
*/
|
|
27
|
+
const DEFAULT_HOME_PAGE = <StudioHomePage/>;
|
|
28
|
+
|
|
29
|
+
export function RebaseStudio({ tools, homePage }: RebaseStudioConfig) {
|
|
30
|
+
const dispatch = useRebaseRegistryDispatch();
|
|
31
|
+
|
|
32
|
+
const resolvedHomePage = homePage ?? DEFAULT_HOME_PAGE;
|
|
33
|
+
|
|
34
|
+
const devViews: AppView[] = useMemo(() => {
|
|
35
|
+
const views: AppView[] = [];
|
|
36
|
+
const activeTools = tools ?? ["sql", "js", "rls", "storage", "cron", "schema-visualizer", "branches", "api"];
|
|
37
|
+
const suspense = (el: React.ReactNode) => <Suspense fallback={<CircularProgressCenter/>}>{el}</Suspense>;
|
|
38
|
+
|
|
39
|
+
if (activeTools.includes("sql")) {
|
|
40
|
+
views.push({ slug: "sql",
|
|
41
|
+
name: "SQL Console",
|
|
42
|
+
group: "Database",
|
|
43
|
+
icon: "terminal",
|
|
44
|
+
description: "Execute SQL queries",
|
|
45
|
+
view: suspense(<SQLEditor/>) });
|
|
46
|
+
}
|
|
47
|
+
if (activeTools.includes("js")) {
|
|
48
|
+
views.push({ slug: "js",
|
|
49
|
+
name: "JS Console",
|
|
50
|
+
group: "Compute",
|
|
51
|
+
icon: "code",
|
|
52
|
+
description: "Execute JavaScript",
|
|
53
|
+
view: suspense(<JSEditor/>) });
|
|
54
|
+
}
|
|
55
|
+
if (activeTools.includes("rls")) {
|
|
56
|
+
views.push({ slug: "rls",
|
|
57
|
+
name: "RLS Policies",
|
|
58
|
+
group: "Database",
|
|
59
|
+
icon: "ShieldCheck",
|
|
60
|
+
description: "Row Level Security",
|
|
61
|
+
view: suspense(<RLSEditor/>) });
|
|
62
|
+
}
|
|
63
|
+
if (activeTools.includes("storage")) {
|
|
64
|
+
views.push({ slug: "storage",
|
|
65
|
+
name: "Storage",
|
|
66
|
+
group: "Storage",
|
|
67
|
+
icon: "HardDrive",
|
|
68
|
+
description: "Manage storage files",
|
|
69
|
+
view: suspense(<StorageView/>) });
|
|
70
|
+
}
|
|
71
|
+
if (activeTools.includes("cron")) {
|
|
72
|
+
views.push({ slug: "cron",
|
|
73
|
+
name: "Cron Jobs",
|
|
74
|
+
group: "Compute",
|
|
75
|
+
icon: "Clock",
|
|
76
|
+
description: "Manage scheduled tasks",
|
|
77
|
+
view: suspense(<CronJobsView/>) });
|
|
78
|
+
}
|
|
79
|
+
if (activeTools.includes("schema-visualizer")) {
|
|
80
|
+
views.push({ slug: "schema-visualizer",
|
|
81
|
+
name: "Schema Visualizer",
|
|
82
|
+
group: "Database",
|
|
83
|
+
icon: "Network",
|
|
84
|
+
description: "Interactive database ERD",
|
|
85
|
+
view: suspense(<SchemaVisualizer/>) });
|
|
86
|
+
}
|
|
87
|
+
if (activeTools.includes("branches")) {
|
|
88
|
+
views.push({ slug: "branches",
|
|
89
|
+
name: "Branches",
|
|
90
|
+
group: "Database",
|
|
91
|
+
icon: "GitBranch",
|
|
92
|
+
description: "Create and manage database branches",
|
|
93
|
+
view: suspense(<BranchesView/>) });
|
|
94
|
+
}
|
|
95
|
+
if (activeTools.includes("api")) {
|
|
96
|
+
views.push({ slug: "api",
|
|
97
|
+
name: "API Explorer",
|
|
98
|
+
group: "API",
|
|
99
|
+
icon: "BookOpen",
|
|
100
|
+
description: "Interactive API documentation and testing",
|
|
101
|
+
view: suspense(<ApiExplorer/>) });
|
|
102
|
+
}
|
|
103
|
+
// Note: "schema" tool is auto-injected by RebaseShell when collectionEditor is enabled.
|
|
104
|
+
// It is NOT registered here anymore.
|
|
105
|
+
return views;
|
|
106
|
+
}, [tools]);
|
|
107
|
+
|
|
108
|
+
// Use a ref for homePage so it never destabilizes the effect.
|
|
109
|
+
// homePage is a React element — its identity doesn't matter for registration.
|
|
110
|
+
const homePageRef = React.useRef(resolvedHomePage);
|
|
111
|
+
homePageRef.current = resolvedHomePage;
|
|
112
|
+
|
|
113
|
+
useLayoutEffect(() => {
|
|
114
|
+
dispatch.registerStudio({ tools,
|
|
115
|
+
homePage: homePageRef.current,
|
|
116
|
+
devViews });
|
|
117
|
+
return () => dispatch.unregisterStudio();
|
|
118
|
+
}, [dispatch, tools, devViews]);
|
|
119
|
+
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Typography, cls, defaultBorderMixin, Collapse } from "@rebasepro/ui";
|
|
3
|
+
|
|
4
|
+
export interface ExplainPlanNode {
|
|
5
|
+
"Node Type": string;
|
|
6
|
+
"Relation Name"?: string;
|
|
7
|
+
"Alias"?: string;
|
|
8
|
+
"Startup Cost": number;
|
|
9
|
+
"Total Cost": number;
|
|
10
|
+
"Plan Rows": number;
|
|
11
|
+
"Plan Width": number;
|
|
12
|
+
"Actual Startup Time"?: number;
|
|
13
|
+
"Actual Total Time"?: number;
|
|
14
|
+
"Actual Rows"?: number;
|
|
15
|
+
"Actual Loops"?: number;
|
|
16
|
+
"Filter"?: string;
|
|
17
|
+
"Index Cond"?: string;
|
|
18
|
+
"Hash Cond"?: string;
|
|
19
|
+
"Plans"?: ExplainPlanNode[];
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ExplainVisualizerProps {
|
|
24
|
+
plan: ExplainPlanNode;
|
|
25
|
+
isRoot?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const ExplainVisualizer: React.FC<ExplainVisualizerProps> = ({ plan, isRoot = true }) => {
|
|
29
|
+
const [expanded, setExpanded] = useState(true);
|
|
30
|
+
|
|
31
|
+
const hasChildren = plan.Plans && plan.Plans.length > 0;
|
|
32
|
+
|
|
33
|
+
// Determine color based on cost
|
|
34
|
+
const cost = plan["Total Cost"];
|
|
35
|
+
let costColor = "text-green-500 dark:text-green-400";
|
|
36
|
+
if (cost > 1000) costColor = "text-red-500 dark:text-red-400";
|
|
37
|
+
else if (cost > 100) costColor = "text-orange-500 dark:text-orange-400";
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div className={cls("flex flex-col", isRoot ? "p-4" : "pl-6 mt-2 relative")}>
|
|
41
|
+
{/* Tree branch line */}
|
|
42
|
+
{!isRoot && (
|
|
43
|
+
<div className="absolute left-2.5 top-0 bottom-0 w-px bg-surface-200 dark:bg-surface-950 -z-10"></div>
|
|
44
|
+
)}
|
|
45
|
+
{!isRoot && (
|
|
46
|
+
<div className="absolute left-2.5 top-5 w-3 h-px bg-surface-200 dark:bg-surface-950 -z-10"></div>
|
|
47
|
+
)}
|
|
48
|
+
|
|
49
|
+
<div className={cls("border rounded-md bg-white dark:bg-surface-900 text-text-primary dark:text-text-primary-dark shadow-xs relative z-10 w-[420px] max-w-full", defaultBorderMixin)}>
|
|
50
|
+
<div
|
|
51
|
+
className={cls("px-4 py-3 flex justify-between items-center cursor-pointer select-none")}
|
|
52
|
+
onClick={() => setExpanded(!expanded)}
|
|
53
|
+
>
|
|
54
|
+
<div className="flex items-center space-x-2">
|
|
55
|
+
{hasChildren ? (
|
|
56
|
+
<svg className={cls("w-4 h-4 text-text-secondary transition-transform", !expanded ? "-rotate-90" : "")} fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 9l-7 7-7-7"/></svg>
|
|
57
|
+
) : (
|
|
58
|
+
<div className="w-4 h-4"></div>
|
|
59
|
+
)}
|
|
60
|
+
|
|
61
|
+
<Typography variant="body1" className="flex items-center">
|
|
62
|
+
{plan["Node Type"]}
|
|
63
|
+
</Typography>
|
|
64
|
+
|
|
65
|
+
{plan["Relation Name"] && (
|
|
66
|
+
<span className="font-mono text-[11px] text-text-secondary dark:text-text-secondary-dark px-2 py-0.5 rounded bg-surface-200 dark:bg-surface-950 ml-2">
|
|
67
|
+
on {plan["Relation Name"]} {plan.Alias && plan.Alias !== plan["Relation Name"] ? `(${plan.Alias})` : ""}
|
|
68
|
+
</span>
|
|
69
|
+
)}
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<div className="flex space-x-6 items-center">
|
|
73
|
+
<div className="flex flex-col text-right">
|
|
74
|
+
<span className="text-[10px] uppercase text-text-disabled dark:text-text-disabled-dark font-semibold tracking-wide leading-tight mb-0.5">Cost</span>
|
|
75
|
+
<span className={cls("font-mono font-medium text-[13px] leading-none", costColor)}>{cost.toFixed(2)}</span>
|
|
76
|
+
</div>
|
|
77
|
+
<div className="flex flex-col text-right">
|
|
78
|
+
<span className="text-[10px] uppercase text-text-disabled dark:text-text-disabled-dark font-semibold tracking-wide leading-tight mb-0.5">Rows</span>
|
|
79
|
+
<span className="font-mono text-[13px] text-text-secondary dark:text-text-secondary-dark leading-none">{plan["Plan Rows"]}</span>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<Collapse in={expanded}>
|
|
85
|
+
<div className="px-4 py-3 border-t border-surface-200 dark:border-surface-950 text-[13px] flex flex-col gap-2">
|
|
86
|
+
<div className="flex items-center space-x-6">
|
|
87
|
+
<div className="flex items-center space-x-2">
|
|
88
|
+
<span className="text-text-disabled dark:text-text-disabled-dark">Startup Cost:</span>
|
|
89
|
+
<span className="font-mono font-medium">{plan["Startup Cost"].toFixed(2)}</span>
|
|
90
|
+
</div>
|
|
91
|
+
<div className="flex items-center space-x-2">
|
|
92
|
+
<span className="text-text-disabled dark:text-text-disabled-dark">Width:</span>
|
|
93
|
+
<span className="font-mono font-medium">{plan["Plan Width"]} bytes</span>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
{plan.Filter && (
|
|
98
|
+
<div className="mt-1">
|
|
99
|
+
<span className="text-text-disabled dark:text-text-disabled-dark block mb-1">Filter:</span>
|
|
100
|
+
<code className="block w-full p-2 bg-surface-50 dark:bg-surface-950 border dark:border-surface-950 rounded font-mono text-[12px] truncate">{plan.Filter}</code>
|
|
101
|
+
</div>
|
|
102
|
+
)}
|
|
103
|
+
{plan["Index Cond"] && (
|
|
104
|
+
<div className="mt-1">
|
|
105
|
+
<span className="text-text-disabled dark:text-text-disabled-dark block mb-1">Index Cond:</span>
|
|
106
|
+
<code className="block w-full p-2 bg-surface-50 dark:bg-surface-950 border dark:border-surface-950 rounded font-mono text-[12px] truncate">{plan["Index Cond"]}</code>
|
|
107
|
+
</div>
|
|
108
|
+
)}
|
|
109
|
+
{plan["Hash Cond"] && (
|
|
110
|
+
<div className="mt-1">
|
|
111
|
+
<span className="text-text-disabled dark:text-text-disabled-dark block mb-1">Hash Cond:</span>
|
|
112
|
+
<code className="block w-full p-2 bg-surface-50 dark:bg-surface-950 border dark:border-surface-950 rounded font-mono text-[12px] truncate">{plan["Hash Cond"]}</code>
|
|
113
|
+
</div>
|
|
114
|
+
)}
|
|
115
|
+
</div>
|
|
116
|
+
</Collapse>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
{expanded && hasChildren && (
|
|
120
|
+
<div className="flex flex-col space-y-2 mt-[-4px]">
|
|
121
|
+
{plan.Plans!.map((childPlan, idx) => (
|
|
122
|
+
<ExplainVisualizer key={idx} plan={childPlan} isRoot={false}/>
|
|
123
|
+
))}
|
|
124
|
+
</div>
|
|
125
|
+
)}
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
|
+
import Editor, { Monaco, OnMount } from "@monaco-editor/react";
|
|
3
|
+
import type { editor, Position, IRange } from "monaco-editor";
|
|
4
|
+
import { cls, defaultBorderMixin } from "@rebasepro/ui";
|
|
5
|
+
import { useModeController } from "@rebasepro/core";
|
|
6
|
+
|
|
7
|
+
export type MonacoEditorProps = {
|
|
8
|
+
value: string;
|
|
9
|
+
onChange: (value: string | undefined) => void;
|
|
10
|
+
onRun?: (selectedText?: string) => void;
|
|
11
|
+
className?: string;
|
|
12
|
+
readOnly?: boolean;
|
|
13
|
+
autoFocus?: boolean;
|
|
14
|
+
schemas?: Record<string, { schemaName: string, tableName: string, columns: { name: string, dataType: string }[] }[]>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const MonacoEditor = ({
|
|
18
|
+
value,
|
|
19
|
+
onChange,
|
|
20
|
+
onRun,
|
|
21
|
+
className,
|
|
22
|
+
readOnly = false,
|
|
23
|
+
autoFocus = true,
|
|
24
|
+
schemas
|
|
25
|
+
}: MonacoEditorProps) => {
|
|
26
|
+
const { mode } = useModeController();
|
|
27
|
+
const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);
|
|
28
|
+
const monacoRef = useRef<Monaco | null>(null);
|
|
29
|
+
const onRunRef = useRef(onRun);
|
|
30
|
+
onRunRef.current = onRun;
|
|
31
|
+
|
|
32
|
+
const schemasRef = useRef(schemas);
|
|
33
|
+
schemasRef.current = schemas;
|
|
34
|
+
|
|
35
|
+
const handleEditorOnMount: OnMount = (editor, monaco) => {
|
|
36
|
+
editorRef.current = editor;
|
|
37
|
+
monacoRef.current = monaco;
|
|
38
|
+
|
|
39
|
+
editor.addAction({
|
|
40
|
+
id: "run-query",
|
|
41
|
+
label: "Run Query",
|
|
42
|
+
keybindings: [monaco.KeyMod.CtrlCmd + monaco.KeyCode.Enter],
|
|
43
|
+
contextMenuGroupId: "operation",
|
|
44
|
+
contextMenuOrder: 0,
|
|
45
|
+
run: () => {
|
|
46
|
+
if (onRunRef.current) {
|
|
47
|
+
const selection = editor.getSelection();
|
|
48
|
+
let selectedText: string | undefined = undefined;
|
|
49
|
+
if (selection && !selection.isEmpty()) {
|
|
50
|
+
selectedText = editor.getModel()?.getValueInRange(selection)?.trim();
|
|
51
|
+
}
|
|
52
|
+
onRunRef.current(selectedText || undefined);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Register custom autocomplete for tables, columns, and SQL keywords
|
|
58
|
+
const sqlKeywords = [
|
|
59
|
+
"SELECT", "FROM", "WHERE", "INSERT INTO", "VALUES", "UPDATE", "SET",
|
|
60
|
+
"DELETE FROM", "JOIN", "INNER JOIN", "LEFT JOIN", "RIGHT JOIN", "FULL JOIN",
|
|
61
|
+
"ON", "GROUP BY", "HAVING", "ORDER BY", "ASC", "DESC", "LIMIT", "OFFSET",
|
|
62
|
+
"AS", "AND", "OR", "NOT", "IN", "BETWEEN", "LIKE", "IS NULL", "IS NOT NULL",
|
|
63
|
+
"CREATE TABLE", "ALTER TABLE", "DROP TABLE", "PRIMARY KEY", "FOREIGN KEY",
|
|
64
|
+
"COUNT", "SUM", "AVG", "MIN", "MAX", "DISTINCT", "UNION", "ALL", "EXISTS",
|
|
65
|
+
"CASE", "WHEN", "THEN", "ELSE", "END", "CAST", "COALESCE"
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
monaco.languages.registerCompletionItemProvider("pgsql", {
|
|
69
|
+
triggerCharacters: [".", " ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"],
|
|
70
|
+
provideCompletionItems: (model: editor.ITextModel, position: Position) => {
|
|
71
|
+
const word = model.getWordUntilPosition(position);
|
|
72
|
+
const range = {
|
|
73
|
+
startLineNumber: position.lineNumber,
|
|
74
|
+
endLineNumber: position.lineNumber,
|
|
75
|
+
startColumn: word.startColumn,
|
|
76
|
+
endColumn: word.endColumn
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const textUntilPosition = model.getValueInRange({
|
|
80
|
+
startLineNumber: position.lineNumber,
|
|
81
|
+
startColumn: 1,
|
|
82
|
+
endLineNumber: position.lineNumber,
|
|
83
|
+
endColumn: position.column
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Check if user is typing `tableName.`
|
|
87
|
+
const match = textUntilPosition.match(/([a-zA-Z0-9_]+)\.$/);
|
|
88
|
+
const tableNameMatch = match ? match[1] : null;
|
|
89
|
+
|
|
90
|
+
const suggestions: { label: string; kind: number; insertText: string; range: IRange; detail: string; sortText: string }[] = [];
|
|
91
|
+
const allSchemas = schemasRef.current || {};
|
|
92
|
+
|
|
93
|
+
if (tableNameMatch) {
|
|
94
|
+
// Provide columns for the matched table
|
|
95
|
+
for (const [, tables] of Object.entries(allSchemas)) {
|
|
96
|
+
const table = tables.find(t => t.tableName === tableNameMatch);
|
|
97
|
+
if (table) {
|
|
98
|
+
table.columns.forEach(col => {
|
|
99
|
+
suggestions.push({
|
|
100
|
+
label: col.name,
|
|
101
|
+
kind: monaco.languages.CompletionItemKind.Field,
|
|
102
|
+
insertText: col.name,
|
|
103
|
+
range,
|
|
104
|
+
detail: "Column",
|
|
105
|
+
sortText: "1"
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
// Provide table names
|
|
112
|
+
for (const [sName, tables] of Object.entries(allSchemas)) {
|
|
113
|
+
tables.forEach(table => {
|
|
114
|
+
suggestions.push({
|
|
115
|
+
label: table.tableName,
|
|
116
|
+
kind: monaco.languages.CompletionItemKind.Class,
|
|
117
|
+
insertText: table.tableName,
|
|
118
|
+
range,
|
|
119
|
+
detail: `Table (${sName})`,
|
|
120
|
+
sortText: "2"
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Provide SQL keywords
|
|
126
|
+
sqlKeywords.forEach(keyword => {
|
|
127
|
+
suggestions.push({
|
|
128
|
+
label: keyword,
|
|
129
|
+
kind: monaco.languages.CompletionItemKind.Keyword,
|
|
130
|
+
insertText: keyword + " ",
|
|
131
|
+
range,
|
|
132
|
+
detail: "SQL Keyword",
|
|
133
|
+
sortText: "3"
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Heuristic: Suggest columns for tables that are mentioned in the current editor text
|
|
138
|
+
const fullText = model.getValue();
|
|
139
|
+
const activeTables = new Set<string>();
|
|
140
|
+
for (const [, tables] of Object.entries(allSchemas)) {
|
|
141
|
+
tables.forEach(table => {
|
|
142
|
+
const regex = new RegExp(`\\b${table.tableName}\\b`, "i");
|
|
143
|
+
if (regex.test(fullText)) {
|
|
144
|
+
activeTables.add(table.tableName);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const addedColumns = new Set<string>();
|
|
150
|
+
for (const [, tables] of Object.entries(allSchemas)) {
|
|
151
|
+
tables.forEach(table => {
|
|
152
|
+
if (activeTables.has(table.tableName)) {
|
|
153
|
+
table.columns.forEach(col => {
|
|
154
|
+
if (!addedColumns.has(col.name)) {
|
|
155
|
+
addedColumns.add(col.name);
|
|
156
|
+
suggestions.push({
|
|
157
|
+
label: col.name,
|
|
158
|
+
kind: monaco.languages.CompletionItemKind.Field,
|
|
159
|
+
insertText: col.name,
|
|
160
|
+
range,
|
|
161
|
+
detail: `Column (${table.tableName})`,
|
|
162
|
+
sortText: "1" // Prioritize columns from active tables
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return { suggestions };
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
if (autoFocus) {
|
|
177
|
+
editor.focus();
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<div className={cls("relative w-full h-full overflow-hidden", className)}>
|
|
183
|
+
<Editor
|
|
184
|
+
height="100%"
|
|
185
|
+
defaultLanguage="pgsql"
|
|
186
|
+
value={value}
|
|
187
|
+
onChange={onChange}
|
|
188
|
+
onMount={handleEditorOnMount}
|
|
189
|
+
theme={mode === "dark" ? "vs-dark" : "vs"}
|
|
190
|
+
options={{
|
|
191
|
+
minimap: { enabled: false },
|
|
192
|
+
fontSize: 14,
|
|
193
|
+
lineNumbers: "on",
|
|
194
|
+
scrollBeyondLastLine: false,
|
|
195
|
+
automaticLayout: true,
|
|
196
|
+
readOnly,
|
|
197
|
+
tabSize: 2,
|
|
198
|
+
wordWrap: "on"
|
|
199
|
+
}}
|
|
200
|
+
/>
|
|
201
|
+
</div>
|
|
202
|
+
);
|
|
203
|
+
};
|