@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,1053 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useMemo, useEffect, useCallback } from "react";
|
|
3
|
+
import { useRebaseContext, useApiConfig, useAuthController } from "@rebasepro/core";
|
|
4
|
+
import { Typography, iconSize, cls, defaultBorderMixin, Chip, Button, Alert, CircularProgress, SearchBar } from "@rebasepro/ui";
|
|
5
|
+
import { SlidersHorizontalIcon, UploadIcon, ArrowRightFromLineIcon, LoaderIcon, SendIcon, PlusIcon, XIcon, BookOpenIcon, PlayIcon } from "lucide-react";
|
|
6
|
+
import { c } from "react-compiler-runtime";
|
|
7
|
+
import { A as AuthSimulationSelector } from "./AuthSimulationSelector-BF4rkRGp.js";
|
|
8
|
+
function parseOpenApiSpec(spec) {
|
|
9
|
+
const allEndpoints = [];
|
|
10
|
+
const tagMap = /* @__PURE__ */ new Map();
|
|
11
|
+
const tagDescriptions = /* @__PURE__ */ new Map();
|
|
12
|
+
for (const t of spec.tags ?? []) {
|
|
13
|
+
tagDescriptions.set(t.name, t.description ?? "");
|
|
14
|
+
}
|
|
15
|
+
for (const [path, methods] of Object.entries(spec.paths ?? {})) {
|
|
16
|
+
for (const [method, op] of Object.entries(methods)) {
|
|
17
|
+
if (["get", "post", "put", "patch", "delete"].indexOf(method) === -1) continue;
|
|
18
|
+
const tags = op.tags?.length ? op.tags : ["Other"];
|
|
19
|
+
const shortPath = path.replace(/^\/api\/data/, "");
|
|
20
|
+
const endpoint = {
|
|
21
|
+
id: `${method}:${path}`,
|
|
22
|
+
method,
|
|
23
|
+
path,
|
|
24
|
+
shortPath: shortPath || "/",
|
|
25
|
+
summary: op.summary ?? "",
|
|
26
|
+
description: op.description ?? "",
|
|
27
|
+
tags,
|
|
28
|
+
parameters: op.parameters ?? [],
|
|
29
|
+
requestBody: op.requestBody,
|
|
30
|
+
responses: op.responses ?? {},
|
|
31
|
+
security: op.security,
|
|
32
|
+
operationId: op.operationId
|
|
33
|
+
};
|
|
34
|
+
allEndpoints.push(endpoint);
|
|
35
|
+
for (const tag of tags) {
|
|
36
|
+
if (!tagMap.has(tag)) tagMap.set(tag, []);
|
|
37
|
+
tagMap.get(tag).push(endpoint);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const ORDER = {
|
|
42
|
+
get: 0,
|
|
43
|
+
post: 1,
|
|
44
|
+
put: 2,
|
|
45
|
+
patch: 3,
|
|
46
|
+
delete: 4
|
|
47
|
+
};
|
|
48
|
+
const groups = [];
|
|
49
|
+
const tagOrder = (spec.tags ?? []).map((t) => t.name);
|
|
50
|
+
const sortedTags = [...tagMap.keys()].sort((a, b) => {
|
|
51
|
+
const ai = tagOrder.indexOf(a);
|
|
52
|
+
const bi = tagOrder.indexOf(b);
|
|
53
|
+
if (ai !== -1 && bi !== -1) return ai - bi;
|
|
54
|
+
if (ai !== -1) return -1;
|
|
55
|
+
if (bi !== -1) return 1;
|
|
56
|
+
return a.localeCompare(b);
|
|
57
|
+
});
|
|
58
|
+
for (const tag of sortedTags) {
|
|
59
|
+
const endpoints = tagMap.get(tag);
|
|
60
|
+
endpoints.sort((a, b) => {
|
|
61
|
+
const pa = a.path.localeCompare(b.path);
|
|
62
|
+
if (pa !== 0) return pa;
|
|
63
|
+
return (ORDER[a.method] ?? 99) - (ORDER[b.method] ?? 99);
|
|
64
|
+
});
|
|
65
|
+
groups.push({
|
|
66
|
+
tag,
|
|
67
|
+
description: tagDescriptions.get(tag),
|
|
68
|
+
endpoints
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
groups,
|
|
73
|
+
allEndpoints
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function resolveRefName(ref) {
|
|
77
|
+
const parts = ref.split("/");
|
|
78
|
+
return parts[parts.length - 1];
|
|
79
|
+
}
|
|
80
|
+
function resolveRef(spec, ref) {
|
|
81
|
+
const parts = ref.replace("#/", "").split("/");
|
|
82
|
+
let current = spec;
|
|
83
|
+
for (const part of parts) {
|
|
84
|
+
current = current?.[part];
|
|
85
|
+
}
|
|
86
|
+
return current ?? {};
|
|
87
|
+
}
|
|
88
|
+
function EndpointDetail(t0) {
|
|
89
|
+
const $ = c(21);
|
|
90
|
+
const {
|
|
91
|
+
endpoint,
|
|
92
|
+
spec
|
|
93
|
+
} = t0;
|
|
94
|
+
let t1;
|
|
95
|
+
if ($[0] !== endpoint.description || $[1] !== endpoint.summary) {
|
|
96
|
+
t1 = (endpoint.summary || endpoint.description) && /* @__PURE__ */ jsxs("div", { children: [
|
|
97
|
+
endpoint.summary && /* @__PURE__ */ jsx(Typography, { variant: "h6", className: "font-semibold mb-1", children: endpoint.summary }),
|
|
98
|
+
endpoint.description && /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-text-secondary dark:text-text-secondary-dark", children: endpoint.description })
|
|
99
|
+
] });
|
|
100
|
+
$[0] = endpoint.description;
|
|
101
|
+
$[1] = endpoint.summary;
|
|
102
|
+
$[2] = t1;
|
|
103
|
+
} else {
|
|
104
|
+
t1 = $[2];
|
|
105
|
+
}
|
|
106
|
+
let t2;
|
|
107
|
+
if ($[3] !== endpoint.parameters) {
|
|
108
|
+
t2 = endpoint.parameters.length > 0 && /* @__PURE__ */ jsxs("section", { children: [
|
|
109
|
+
/* @__PURE__ */ jsx(SectionHeading, { icon: /* @__PURE__ */ jsx(SlidersHorizontalIcon, { size: iconSize.small, className: "text-text-secondary dark:text-text-secondary-dark" }), title: "Parameters" }),
|
|
110
|
+
/* @__PURE__ */ jsx("div", { className: cls("rounded-lg border overflow-hidden", defaultBorderMixin), children: /* @__PURE__ */ jsxs("table", { className: "w-full text-sm", children: [
|
|
111
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "bg-surface-100 dark:bg-surface-900 text-left", children: [
|
|
112
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-2 font-medium text-text-secondary dark:text-text-secondary-dark", children: "Name" }),
|
|
113
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-2 font-medium text-text-secondary dark:text-text-secondary-dark", children: "In" }),
|
|
114
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-2 font-medium text-text-secondary dark:text-text-secondary-dark", children: "Type" }),
|
|
115
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-2 font-medium text-text-secondary dark:text-text-secondary-dark", children: "Description" })
|
|
116
|
+
] }) }),
|
|
117
|
+
/* @__PURE__ */ jsx("tbody", { children: endpoint.parameters.map(_temp) })
|
|
118
|
+
] }) })
|
|
119
|
+
] });
|
|
120
|
+
$[3] = endpoint.parameters;
|
|
121
|
+
$[4] = t2;
|
|
122
|
+
} else {
|
|
123
|
+
t2 = $[4];
|
|
124
|
+
}
|
|
125
|
+
let t3;
|
|
126
|
+
if ($[5] !== endpoint.requestBody || $[6] !== spec) {
|
|
127
|
+
t3 = endpoint.requestBody && /* @__PURE__ */ jsxs("section", { children: [
|
|
128
|
+
/* @__PURE__ */ jsx(SectionHeading, { icon: /* @__PURE__ */ jsx(UploadIcon, { size: iconSize.small, className: "text-text-secondary dark:text-text-secondary-dark" }), title: "Request Body" }),
|
|
129
|
+
Object.entries(endpoint.requestBody.content ?? {}).map((t42) => {
|
|
130
|
+
const [contentType, media] = t42;
|
|
131
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
132
|
+
/* @__PURE__ */ jsx(Chip, { size: "smallest", colorScheme: "blueDarker", className: "mb-3", children: contentType }),
|
|
133
|
+
media.schema && /* @__PURE__ */ jsx(SchemaBlock, { schema: media.schema, spec, depth: 0 })
|
|
134
|
+
] }, contentType);
|
|
135
|
+
})
|
|
136
|
+
] });
|
|
137
|
+
$[5] = endpoint.requestBody;
|
|
138
|
+
$[6] = spec;
|
|
139
|
+
$[7] = t3;
|
|
140
|
+
} else {
|
|
141
|
+
t3 = $[7];
|
|
142
|
+
}
|
|
143
|
+
let t4;
|
|
144
|
+
if ($[8] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
145
|
+
t4 = /* @__PURE__ */ jsx(SectionHeading, { icon: /* @__PURE__ */ jsx(ArrowRightFromLineIcon, { size: iconSize.small, className: "text-text-secondary dark:text-text-secondary-dark" }), title: "Responses" });
|
|
146
|
+
$[8] = t4;
|
|
147
|
+
} else {
|
|
148
|
+
t4 = $[8];
|
|
149
|
+
}
|
|
150
|
+
let t5;
|
|
151
|
+
if ($[9] !== endpoint.responses || $[10] !== spec) {
|
|
152
|
+
let t62;
|
|
153
|
+
if ($[12] !== spec) {
|
|
154
|
+
t62 = (t72) => {
|
|
155
|
+
const [code, res] = t72;
|
|
156
|
+
return /* @__PURE__ */ jsxs("div", { className: cls("rounded-lg border overflow-hidden", defaultBorderMixin), children: [
|
|
157
|
+
/* @__PURE__ */ jsxs("div", { className: cls("flex items-center gap-3 px-4 py-2.5", "bg-surface-50 dark:bg-surface-900/50"), children: [
|
|
158
|
+
/* @__PURE__ */ jsx(StatusBadge, { code }),
|
|
159
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-text-secondary dark:text-text-secondary-dark text-xs", children: res.description })
|
|
160
|
+
] }),
|
|
161
|
+
res.content && Object.entries(res.content).map((t8) => {
|
|
162
|
+
const [ct, media_0] = t8;
|
|
163
|
+
return media_0.schema && /* @__PURE__ */ jsx("div", { className: cls("px-4 py-3 border-t", defaultBorderMixin), children: /* @__PURE__ */ jsx(SchemaBlock, { schema: media_0.schema, spec, depth: 0 }) }, ct);
|
|
164
|
+
})
|
|
165
|
+
] }, code);
|
|
166
|
+
};
|
|
167
|
+
$[12] = spec;
|
|
168
|
+
$[13] = t62;
|
|
169
|
+
} else {
|
|
170
|
+
t62 = $[13];
|
|
171
|
+
}
|
|
172
|
+
t5 = Object.entries(endpoint.responses).map(t62);
|
|
173
|
+
$[9] = endpoint.responses;
|
|
174
|
+
$[10] = spec;
|
|
175
|
+
$[11] = t5;
|
|
176
|
+
} else {
|
|
177
|
+
t5 = $[11];
|
|
178
|
+
}
|
|
179
|
+
let t6;
|
|
180
|
+
if ($[14] !== t5) {
|
|
181
|
+
t6 = /* @__PURE__ */ jsxs("section", { children: [
|
|
182
|
+
t4,
|
|
183
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-3", children: t5 })
|
|
184
|
+
] });
|
|
185
|
+
$[14] = t5;
|
|
186
|
+
$[15] = t6;
|
|
187
|
+
} else {
|
|
188
|
+
t6 = $[15];
|
|
189
|
+
}
|
|
190
|
+
let t7;
|
|
191
|
+
if ($[16] !== t1 || $[17] !== t2 || $[18] !== t3 || $[19] !== t6) {
|
|
192
|
+
t7 = /* @__PURE__ */ jsxs("div", { className: "p-6 space-y-8 max-w-4xl", children: [
|
|
193
|
+
t1,
|
|
194
|
+
t2,
|
|
195
|
+
t3,
|
|
196
|
+
t6
|
|
197
|
+
] });
|
|
198
|
+
$[16] = t1;
|
|
199
|
+
$[17] = t2;
|
|
200
|
+
$[18] = t3;
|
|
201
|
+
$[19] = t6;
|
|
202
|
+
$[20] = t7;
|
|
203
|
+
} else {
|
|
204
|
+
t7 = $[20];
|
|
205
|
+
}
|
|
206
|
+
return t7;
|
|
207
|
+
}
|
|
208
|
+
function _temp(p, i) {
|
|
209
|
+
return /* @__PURE__ */ jsxs("tr", { className: cls("border-t", defaultBorderMixin), children: [
|
|
210
|
+
/* @__PURE__ */ jsxs("td", { className: "px-4 py-2.5", children: [
|
|
211
|
+
/* @__PURE__ */ jsx("code", { className: "text-xs font-mono font-semibold", children: p.name }),
|
|
212
|
+
p.required && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-1 text-xs", children: "*" })
|
|
213
|
+
] }),
|
|
214
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-2.5", children: /* @__PURE__ */ jsx(Chip, { size: "smallest", colorScheme: p.in === "path" ? "orangeDarker" : "cyanDarker", children: p.in }) }),
|
|
215
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-2.5 text-xs font-mono text-text-secondary dark:text-text-secondary-dark", children: schemaTypeLabel(p.schema) }),
|
|
216
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-2.5 text-xs text-text-secondary dark:text-text-secondary-dark", children: p.description ?? "—" })
|
|
217
|
+
] }, p.name + i);
|
|
218
|
+
}
|
|
219
|
+
function SchemaBlock(t0) {
|
|
220
|
+
const $ = c(43);
|
|
221
|
+
const {
|
|
222
|
+
schema,
|
|
223
|
+
spec,
|
|
224
|
+
depth
|
|
225
|
+
} = t0;
|
|
226
|
+
if (schema.$ref) {
|
|
227
|
+
let t12;
|
|
228
|
+
if ($[0] !== schema.$ref) {
|
|
229
|
+
t12 = resolveRefName(schema.$ref);
|
|
230
|
+
$[0] = schema.$ref;
|
|
231
|
+
$[1] = t12;
|
|
232
|
+
} else {
|
|
233
|
+
t12 = $[1];
|
|
234
|
+
}
|
|
235
|
+
const name = t12;
|
|
236
|
+
let t22;
|
|
237
|
+
if ($[2] !== schema.$ref || $[3] !== spec) {
|
|
238
|
+
t22 = resolveRef(spec, schema.$ref);
|
|
239
|
+
$[2] = schema.$ref;
|
|
240
|
+
$[3] = spec;
|
|
241
|
+
$[4] = t22;
|
|
242
|
+
} else {
|
|
243
|
+
t22 = $[4];
|
|
244
|
+
}
|
|
245
|
+
const resolved = t22;
|
|
246
|
+
let t3;
|
|
247
|
+
if ($[5] !== name) {
|
|
248
|
+
t3 = /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-primary dark:text-primary-dark font-mono text-xs mb-2 block", children: name });
|
|
249
|
+
$[5] = name;
|
|
250
|
+
$[6] = t3;
|
|
251
|
+
} else {
|
|
252
|
+
t3 = $[6];
|
|
253
|
+
}
|
|
254
|
+
let t4;
|
|
255
|
+
if ($[7] !== depth || $[8] !== resolved || $[9] !== spec) {
|
|
256
|
+
t4 = /* @__PURE__ */ jsx(SchemaBlock, { schema: resolved, spec, depth });
|
|
257
|
+
$[7] = depth;
|
|
258
|
+
$[8] = resolved;
|
|
259
|
+
$[9] = spec;
|
|
260
|
+
$[10] = t4;
|
|
261
|
+
} else {
|
|
262
|
+
t4 = $[10];
|
|
263
|
+
}
|
|
264
|
+
let t5;
|
|
265
|
+
if ($[11] !== t3 || $[12] !== t4) {
|
|
266
|
+
t5 = /* @__PURE__ */ jsxs("div", { children: [
|
|
267
|
+
t3,
|
|
268
|
+
t4
|
|
269
|
+
] });
|
|
270
|
+
$[11] = t3;
|
|
271
|
+
$[12] = t4;
|
|
272
|
+
$[13] = t5;
|
|
273
|
+
} else {
|
|
274
|
+
t5 = $[13];
|
|
275
|
+
}
|
|
276
|
+
return t5;
|
|
277
|
+
}
|
|
278
|
+
if (schema.properties) {
|
|
279
|
+
let t12;
|
|
280
|
+
if ($[14] !== schema.required) {
|
|
281
|
+
t12 = schema.required ?? [];
|
|
282
|
+
$[14] = schema.required;
|
|
283
|
+
$[15] = t12;
|
|
284
|
+
} else {
|
|
285
|
+
t12 = $[15];
|
|
286
|
+
}
|
|
287
|
+
let t22;
|
|
288
|
+
if ($[16] !== t12) {
|
|
289
|
+
t22 = new Set(t12);
|
|
290
|
+
$[16] = t12;
|
|
291
|
+
$[17] = t22;
|
|
292
|
+
} else {
|
|
293
|
+
t22 = $[17];
|
|
294
|
+
}
|
|
295
|
+
const required = t22;
|
|
296
|
+
const t3 = depth > 0 && `border ml-4 mt-1 ${defaultBorderMixin}`;
|
|
297
|
+
let t4;
|
|
298
|
+
if ($[18] !== t3) {
|
|
299
|
+
t4 = cls("rounded-lg overflow-hidden", t3);
|
|
300
|
+
$[18] = t3;
|
|
301
|
+
$[19] = t4;
|
|
302
|
+
} else {
|
|
303
|
+
t4 = $[19];
|
|
304
|
+
}
|
|
305
|
+
let t5;
|
|
306
|
+
if ($[20] !== depth || $[21] !== required || $[22] !== schema.properties || $[23] !== spec) {
|
|
307
|
+
let t62;
|
|
308
|
+
if ($[25] !== depth || $[26] !== required || $[27] !== spec) {
|
|
309
|
+
t62 = (t72) => {
|
|
310
|
+
const [key, prop] = t72;
|
|
311
|
+
return /* @__PURE__ */ jsxs("tr", { className: cls("border-t first:border-t-0", defaultBorderMixin), children: [
|
|
312
|
+
/* @__PURE__ */ jsxs("td", { className: "px-3 py-2 align-top w-36", children: [
|
|
313
|
+
/* @__PURE__ */ jsx("code", { className: "font-mono font-semibold text-text-primary dark:text-text-primary-dark", children: key }),
|
|
314
|
+
required.has(key) && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" }),
|
|
315
|
+
prop.readOnly && /* @__PURE__ */ jsx("span", { className: "ml-1.5 text-[9px] text-text-secondary dark:text-text-secondary-dark italic", children: "read-only" })
|
|
316
|
+
] }),
|
|
317
|
+
/* @__PURE__ */ jsx("td", { className: "px-3 py-2 align-top w-28", children: /* @__PURE__ */ jsx("span", { className: "font-mono text-text-secondary dark:text-text-secondary-dark", children: schemaTypeLabel(prop) }) }),
|
|
318
|
+
/* @__PURE__ */ jsxs("td", { className: "px-3 py-2 align-top text-text-secondary dark:text-text-secondary-dark", children: [
|
|
319
|
+
prop.description ?? "",
|
|
320
|
+
prop.enum && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1 mt-1", children: prop.enum.map(_temp2) }),
|
|
321
|
+
prop.properties && /* @__PURE__ */ jsx(SchemaBlock, { schema: prop, spec, depth: depth + 1 }),
|
|
322
|
+
prop.$ref && /* @__PURE__ */ jsx(SchemaBlock, { schema: prop, spec, depth: depth + 1 })
|
|
323
|
+
] })
|
|
324
|
+
] }, key);
|
|
325
|
+
};
|
|
326
|
+
$[25] = depth;
|
|
327
|
+
$[26] = required;
|
|
328
|
+
$[27] = spec;
|
|
329
|
+
$[28] = t62;
|
|
330
|
+
} else {
|
|
331
|
+
t62 = $[28];
|
|
332
|
+
}
|
|
333
|
+
t5 = Object.entries(schema.properties).map(t62);
|
|
334
|
+
$[20] = depth;
|
|
335
|
+
$[21] = required;
|
|
336
|
+
$[22] = schema.properties;
|
|
337
|
+
$[23] = spec;
|
|
338
|
+
$[24] = t5;
|
|
339
|
+
} else {
|
|
340
|
+
t5 = $[24];
|
|
341
|
+
}
|
|
342
|
+
let t6;
|
|
343
|
+
if ($[29] !== t5) {
|
|
344
|
+
t6 = /* @__PURE__ */ jsx("table", { className: "w-full text-xs", children: /* @__PURE__ */ jsx("tbody", { children: t5 }) });
|
|
345
|
+
$[29] = t5;
|
|
346
|
+
$[30] = t6;
|
|
347
|
+
} else {
|
|
348
|
+
t6 = $[30];
|
|
349
|
+
}
|
|
350
|
+
let t7;
|
|
351
|
+
if ($[31] !== t4 || $[32] !== t6) {
|
|
352
|
+
t7 = /* @__PURE__ */ jsx("div", { className: t4, children: t6 });
|
|
353
|
+
$[31] = t4;
|
|
354
|
+
$[32] = t6;
|
|
355
|
+
$[33] = t7;
|
|
356
|
+
} else {
|
|
357
|
+
t7 = $[33];
|
|
358
|
+
}
|
|
359
|
+
return t7;
|
|
360
|
+
}
|
|
361
|
+
if (schema.type === "array" && schema.items) {
|
|
362
|
+
let t12;
|
|
363
|
+
if ($[34] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
364
|
+
t12 = /* @__PURE__ */ jsx("span", { className: "font-mono text-xs text-text-secondary dark:text-text-secondary-dark", children: "Array of:" });
|
|
365
|
+
$[34] = t12;
|
|
366
|
+
} else {
|
|
367
|
+
t12 = $[34];
|
|
368
|
+
}
|
|
369
|
+
const t22 = depth + 1;
|
|
370
|
+
let t3;
|
|
371
|
+
if ($[35] !== schema.items || $[36] !== spec || $[37] !== t22) {
|
|
372
|
+
t3 = /* @__PURE__ */ jsxs("div", { children: [
|
|
373
|
+
t12,
|
|
374
|
+
/* @__PURE__ */ jsx(SchemaBlock, { schema: schema.items, spec, depth: t22 })
|
|
375
|
+
] });
|
|
376
|
+
$[35] = schema.items;
|
|
377
|
+
$[36] = spec;
|
|
378
|
+
$[37] = t22;
|
|
379
|
+
$[38] = t3;
|
|
380
|
+
} else {
|
|
381
|
+
t3 = $[38];
|
|
382
|
+
}
|
|
383
|
+
return t3;
|
|
384
|
+
}
|
|
385
|
+
let t1;
|
|
386
|
+
if ($[39] !== schema) {
|
|
387
|
+
t1 = schemaTypeLabel(schema);
|
|
388
|
+
$[39] = schema;
|
|
389
|
+
$[40] = t1;
|
|
390
|
+
} else {
|
|
391
|
+
t1 = $[40];
|
|
392
|
+
}
|
|
393
|
+
let t2;
|
|
394
|
+
if ($[41] !== t1) {
|
|
395
|
+
t2 = /* @__PURE__ */ jsx("span", { className: "font-mono text-xs text-text-secondary dark:text-text-secondary-dark", children: t1 });
|
|
396
|
+
$[41] = t1;
|
|
397
|
+
$[42] = t2;
|
|
398
|
+
} else {
|
|
399
|
+
t2 = $[42];
|
|
400
|
+
}
|
|
401
|
+
return t2;
|
|
402
|
+
}
|
|
403
|
+
function _temp2(v) {
|
|
404
|
+
return /* @__PURE__ */ jsx("span", { className: "px-1.5 py-0.5 rounded bg-surface-200 dark:bg-surface-800 text-[10px] font-mono", children: String(v) }, String(v));
|
|
405
|
+
}
|
|
406
|
+
function schemaTypeLabel(schema) {
|
|
407
|
+
if (!schema) return "any";
|
|
408
|
+
if (schema.$ref) return resolveRefName(schema.$ref);
|
|
409
|
+
if (schema.type === "array") return `${schemaTypeLabel(schema.items)}[]`;
|
|
410
|
+
if (schema.format) return `${schema.type} (${schema.format})`;
|
|
411
|
+
return schema.type ?? "object";
|
|
412
|
+
}
|
|
413
|
+
function SectionHeading(t0) {
|
|
414
|
+
const $ = c(5);
|
|
415
|
+
const {
|
|
416
|
+
icon,
|
|
417
|
+
title
|
|
418
|
+
} = t0;
|
|
419
|
+
let t1;
|
|
420
|
+
if ($[0] !== title) {
|
|
421
|
+
t1 = /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "font-semibold text-sm", children: title });
|
|
422
|
+
$[0] = title;
|
|
423
|
+
$[1] = t1;
|
|
424
|
+
} else {
|
|
425
|
+
t1 = $[1];
|
|
426
|
+
}
|
|
427
|
+
let t2;
|
|
428
|
+
if ($[2] !== icon || $[3] !== t1) {
|
|
429
|
+
t2 = /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-3", children: [
|
|
430
|
+
icon,
|
|
431
|
+
t1
|
|
432
|
+
] });
|
|
433
|
+
$[2] = icon;
|
|
434
|
+
$[3] = t1;
|
|
435
|
+
$[4] = t2;
|
|
436
|
+
} else {
|
|
437
|
+
t2 = $[4];
|
|
438
|
+
}
|
|
439
|
+
return t2;
|
|
440
|
+
}
|
|
441
|
+
function StatusBadge(t0) {
|
|
442
|
+
const $ = c(5);
|
|
443
|
+
const {
|
|
444
|
+
code
|
|
445
|
+
} = t0;
|
|
446
|
+
const n = parseInt(code, 10);
|
|
447
|
+
const color = n < 300 ? "text-emerald-600 dark:text-emerald-400" : n < 400 ? "text-blue-600 dark:text-blue-400" : n < 500 ? "text-amber-600 dark:text-amber-400" : "text-red-600 dark:text-red-400";
|
|
448
|
+
let t1;
|
|
449
|
+
if ($[0] !== color) {
|
|
450
|
+
t1 = cls("text-xs font-bold font-mono", color);
|
|
451
|
+
$[0] = color;
|
|
452
|
+
$[1] = t1;
|
|
453
|
+
} else {
|
|
454
|
+
t1 = $[1];
|
|
455
|
+
}
|
|
456
|
+
let t2;
|
|
457
|
+
if ($[2] !== code || $[3] !== t1) {
|
|
458
|
+
t2 = /* @__PURE__ */ jsx("span", { className: t1, children: code });
|
|
459
|
+
$[2] = code;
|
|
460
|
+
$[3] = t1;
|
|
461
|
+
$[4] = t2;
|
|
462
|
+
} else {
|
|
463
|
+
t2 = $[4];
|
|
464
|
+
}
|
|
465
|
+
return t2;
|
|
466
|
+
}
|
|
467
|
+
function TryItPanel({
|
|
468
|
+
endpoint,
|
|
469
|
+
apiUrl,
|
|
470
|
+
getAuthToken,
|
|
471
|
+
user,
|
|
472
|
+
basePath = ""
|
|
473
|
+
}) {
|
|
474
|
+
const storageKey = `rebase_apiexplorer_${endpoint.method}_${endpoint.path}`;
|
|
475
|
+
const [pathParams, setPathParams] = useState(() => {
|
|
476
|
+
try {
|
|
477
|
+
const v = localStorage.getItem(`${storageKey}_path`);
|
|
478
|
+
if (v) return JSON.parse(v);
|
|
479
|
+
} catch {
|
|
480
|
+
}
|
|
481
|
+
return {};
|
|
482
|
+
});
|
|
483
|
+
const [queryParams, setQueryParams] = useState(() => {
|
|
484
|
+
try {
|
|
485
|
+
const v_0 = localStorage.getItem(`${storageKey}_query`);
|
|
486
|
+
if (v_0) return JSON.parse(v_0);
|
|
487
|
+
} catch {
|
|
488
|
+
}
|
|
489
|
+
return {};
|
|
490
|
+
});
|
|
491
|
+
const [customHeaders, setCustomHeaders] = useState(() => {
|
|
492
|
+
try {
|
|
493
|
+
const v_1 = localStorage.getItem(`${storageKey}_headers`);
|
|
494
|
+
if (v_1) return JSON.parse(v_1);
|
|
495
|
+
} catch {
|
|
496
|
+
}
|
|
497
|
+
return [{
|
|
498
|
+
key: "rebase-branch",
|
|
499
|
+
value: ""
|
|
500
|
+
}];
|
|
501
|
+
});
|
|
502
|
+
const [body, setBody] = useState(() => {
|
|
503
|
+
try {
|
|
504
|
+
const v_2 = localStorage.getItem(`${storageKey}_body`);
|
|
505
|
+
if (v_2) return JSON.parse(v_2);
|
|
506
|
+
} catch {
|
|
507
|
+
}
|
|
508
|
+
return buildBodyTemplate(endpoint);
|
|
509
|
+
});
|
|
510
|
+
const [response, setResponse] = useState(null);
|
|
511
|
+
const [loading, setLoading] = useState(false);
|
|
512
|
+
const [authMode, setAuthMode] = useState("jwt");
|
|
513
|
+
const [validationError, setValidationError] = useState(null);
|
|
514
|
+
const rebaseContext = useRebaseContext();
|
|
515
|
+
const userManagement = rebaseContext.userManagement;
|
|
516
|
+
const currentUser = rebaseContext.authController?.user;
|
|
517
|
+
const users = useMemo(() => {
|
|
518
|
+
const managed = (userManagement?.users ?? []).map((u) => ({
|
|
519
|
+
uid: u.uid,
|
|
520
|
+
displayName: u.displayName,
|
|
521
|
+
email: u.email,
|
|
522
|
+
photoURL: u.photoURL,
|
|
523
|
+
roles: u.roles
|
|
524
|
+
}));
|
|
525
|
+
if (currentUser && !managed.some((u_0) => u_0.uid === currentUser.uid)) {
|
|
526
|
+
managed.unshift({
|
|
527
|
+
uid: currentUser.uid,
|
|
528
|
+
displayName: currentUser.displayName,
|
|
529
|
+
email: currentUser.email,
|
|
530
|
+
photoURL: currentUser.photoURL,
|
|
531
|
+
roles: currentUser.roles
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
return managed;
|
|
535
|
+
}, [userManagement?.users, currentUser]);
|
|
536
|
+
const currentSelectableUser = useMemo(() => {
|
|
537
|
+
if (!currentUser) return null;
|
|
538
|
+
return {
|
|
539
|
+
uid: currentUser.uid,
|
|
540
|
+
displayName: currentUser.displayName,
|
|
541
|
+
email: currentUser.email,
|
|
542
|
+
photoURL: currentUser.photoURL,
|
|
543
|
+
roles: currentUser.roles
|
|
544
|
+
};
|
|
545
|
+
}, [currentUser]);
|
|
546
|
+
const [selectedUser, setSelectedUser] = useState(null);
|
|
547
|
+
useEffect(() => {
|
|
548
|
+
localStorage.setItem(`${storageKey}_path`, JSON.stringify(pathParams));
|
|
549
|
+
localStorage.setItem(`${storageKey}_query`, JSON.stringify(queryParams));
|
|
550
|
+
localStorage.setItem(`${storageKey}_headers`, JSON.stringify(customHeaders));
|
|
551
|
+
localStorage.setItem(`${storageKey}_body`, JSON.stringify(body));
|
|
552
|
+
}, [storageKey, pathParams, queryParams, customHeaders, body]);
|
|
553
|
+
const resolvedUrl = useMemo(() => {
|
|
554
|
+
const base = basePath.startsWith("/") ? basePath : `/${basePath}`;
|
|
555
|
+
const cleanBase = base === "/" ? "" : base;
|
|
556
|
+
let url = `${apiUrl.replace(/\/+$/, "")}${cleanBase}${endpoint.path}`;
|
|
557
|
+
for (const [key, val] of Object.entries(pathParams)) {
|
|
558
|
+
url = url.replace(`{${key}}`, encodeURIComponent(val));
|
|
559
|
+
}
|
|
560
|
+
const qp = Object.entries(queryParams).filter(([, v_3]) => v_3.trim() !== "");
|
|
561
|
+
if (qp.length > 0) {
|
|
562
|
+
url += "?" + qp.map(([k, v_4]) => `${encodeURIComponent(k)}=${encodeURIComponent(v_4)}`).join("&");
|
|
563
|
+
}
|
|
564
|
+
return url;
|
|
565
|
+
}, [apiUrl, basePath, endpoint.path, pathParams, queryParams]);
|
|
566
|
+
const pathParamDefs = endpoint.parameters.filter((p) => p.in === "path");
|
|
567
|
+
const queryParamDefs = endpoint.parameters.filter((p_0) => p_0.in === "query");
|
|
568
|
+
const hasBody = ["post", "put", "patch"].includes(endpoint.method);
|
|
569
|
+
const execute = useCallback(async () => {
|
|
570
|
+
setValidationError(null);
|
|
571
|
+
if (hasBody && body.trim()) {
|
|
572
|
+
try {
|
|
573
|
+
JSON.parse(body);
|
|
574
|
+
} catch (err) {
|
|
575
|
+
setValidationError(`Invalid JSON: ${err.message}`);
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
setLoading(true);
|
|
580
|
+
setResponse(null);
|
|
581
|
+
const start = performance.now();
|
|
582
|
+
try {
|
|
583
|
+
const headers = {
|
|
584
|
+
"Content-Type": "application/json"
|
|
585
|
+
};
|
|
586
|
+
for (const h of customHeaders) {
|
|
587
|
+
if (h.key.trim()) headers[h.key.trim()] = h.value;
|
|
588
|
+
}
|
|
589
|
+
if (authMode === "jwt") {
|
|
590
|
+
const token = await getAuthToken();
|
|
591
|
+
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
592
|
+
if (selectedUser && selectedUser.uid !== currentUser?.uid) {
|
|
593
|
+
headers["x-rebase-impersonate"] = selectedUser.uid;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
const res = await fetch(resolvedUrl, {
|
|
597
|
+
method: endpoint.method.toUpperCase(),
|
|
598
|
+
headers,
|
|
599
|
+
body: hasBody && body.trim() ? body : void 0
|
|
600
|
+
});
|
|
601
|
+
const elapsed = Math.round(performance.now() - start);
|
|
602
|
+
let text;
|
|
603
|
+
const rawText = await res.text();
|
|
604
|
+
try {
|
|
605
|
+
const json = JSON.parse(rawText);
|
|
606
|
+
text = JSON.stringify(json, null, 2);
|
|
607
|
+
} catch {
|
|
608
|
+
text = rawText;
|
|
609
|
+
}
|
|
610
|
+
setResponse({
|
|
611
|
+
status: res.status,
|
|
612
|
+
statusText: res.statusText,
|
|
613
|
+
body: text,
|
|
614
|
+
time: elapsed
|
|
615
|
+
});
|
|
616
|
+
} catch (err_0) {
|
|
617
|
+
setResponse({
|
|
618
|
+
status: 0,
|
|
619
|
+
statusText: "Network Error",
|
|
620
|
+
body: err_0.message ?? "Request failed",
|
|
621
|
+
time: Math.round(performance.now() - start)
|
|
622
|
+
});
|
|
623
|
+
} finally {
|
|
624
|
+
setLoading(false);
|
|
625
|
+
}
|
|
626
|
+
}, [resolvedUrl, endpoint.method, hasBody, body, authMode, getAuthToken, customHeaders, selectedUser, currentUser?.uid]);
|
|
627
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col h-full", children: /* @__PURE__ */ jsxs("div", { className: "p-5 space-y-5 overflow-y-auto flex-1", children: [
|
|
628
|
+
/* @__PURE__ */ jsx(AuthSimulationSelector, { authMode, setAuthMode, selectedUser, setSelectedUser, users, loading: userManagement?.loading, currentUser: currentSelectableUser }),
|
|
629
|
+
pathParamDefs.length > 0 && /* @__PURE__ */ jsx(ParamSection, { title: "Path Parameters", params: pathParamDefs, values: pathParams, onChange: (k_0, v_5) => setPathParams((prev) => ({
|
|
630
|
+
...prev,
|
|
631
|
+
[k_0]: v_5
|
|
632
|
+
})) }),
|
|
633
|
+
queryParamDefs.length > 0 && /* @__PURE__ */ jsx(ParamSection, { title: "Query Parameters", params: queryParamDefs, values: queryParams, onChange: (k_1, v_6) => setQueryParams((prev_0) => ({
|
|
634
|
+
...prev_0,
|
|
635
|
+
[k_1]: v_6
|
|
636
|
+
})) }),
|
|
637
|
+
/* @__PURE__ */ jsx(CustomKeyValueSection, { title: "Custom Headers", values: customHeaders, onChange: (i, k_2, v_7) => {
|
|
638
|
+
const next = [...customHeaders];
|
|
639
|
+
next[i] = {
|
|
640
|
+
key: k_2,
|
|
641
|
+
value: v_7
|
|
642
|
+
};
|
|
643
|
+
setCustomHeaders(next);
|
|
644
|
+
}, onAdd: () => setCustomHeaders((prev_1) => [...prev_1, {
|
|
645
|
+
key: "",
|
|
646
|
+
value: ""
|
|
647
|
+
}]), onRemove: (i_0) => {
|
|
648
|
+
const next_0 = [...customHeaders];
|
|
649
|
+
next_0.splice(i_0, 1);
|
|
650
|
+
setCustomHeaders(next_0);
|
|
651
|
+
} }),
|
|
652
|
+
hasBody && /* @__PURE__ */ jsxs("div", { children: [
|
|
653
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark text-xs font-semibold uppercase tracking-wider mb-2 block", children: "Request Body" }),
|
|
654
|
+
/* @__PURE__ */ jsx("textarea", { value: body, onChange: (e) => {
|
|
655
|
+
setBody(e.target.value);
|
|
656
|
+
setValidationError(null);
|
|
657
|
+
}, rows: 10, spellCheck: false, className: cls("w-full font-mono text-xs p-3 rounded-lg resize-y", "bg-surface-50 dark:bg-surface-900", validationError ? "border-red-500 focus:ring-red-500/30" : cls("border focus:ring-primary/30 dark:focus:ring-primary-dark/30", defaultBorderMixin), "text-text-primary dark:text-text-primary-dark", "focus:outline-none focus:ring-2", "transition-all") }),
|
|
658
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-red-500 mt-1 block text-xs", children: validationError })
|
|
659
|
+
] }),
|
|
660
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg bg-surface-100 dark:bg-surface-900 p-3", children: [
|
|
661
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark text-[10px] uppercase tracking-wider block mb-1", children: "Request URL" }),
|
|
662
|
+
/* @__PURE__ */ jsx("code", { className: "text-xs font-mono text-text-primary dark:text-text-primary-dark break-all", children: resolvedUrl })
|
|
663
|
+
] }),
|
|
664
|
+
/* @__PURE__ */ jsx(Button, { variant: "filled", onClick: execute, disabled: loading, className: "w-full", children: loading ? /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
665
|
+
/* @__PURE__ */ jsx(LoaderIcon, { size: iconSize.small, className: "animate-spin" }),
|
|
666
|
+
"Sending…"
|
|
667
|
+
] }) : /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
668
|
+
/* @__PURE__ */ jsx(SendIcon, { size: iconSize.small }),
|
|
669
|
+
"Send Request"
|
|
670
|
+
] }) }),
|
|
671
|
+
response && /* @__PURE__ */ jsxs("div", { className: cls("rounded-lg border overflow-hidden", defaultBorderMixin), children: [
|
|
672
|
+
/* @__PURE__ */ jsxs("div", { className: cls("flex items-center justify-between px-4 py-2.5", "bg-surface-50 dark:bg-surface-900/50"), children: [
|
|
673
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
674
|
+
/* @__PURE__ */ jsx(ResponseBadge, { status: response.status }),
|
|
675
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark text-xs", children: response.statusText })
|
|
676
|
+
] }),
|
|
677
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark text-xs font-mono", children: [
|
|
678
|
+
response.time,
|
|
679
|
+
"ms"
|
|
680
|
+
] })
|
|
681
|
+
] }),
|
|
682
|
+
/* @__PURE__ */ jsx("pre", { className: cls("p-4 text-xs font-mono overflow-auto max-h-96", "bg-surface-950 text-emerald-400", "dark:bg-surface-900 dark:text-emerald-400"), children: response.body })
|
|
683
|
+
] })
|
|
684
|
+
] }) });
|
|
685
|
+
}
|
|
686
|
+
function ParamSection(t0) {
|
|
687
|
+
const $ = c(14);
|
|
688
|
+
const {
|
|
689
|
+
title,
|
|
690
|
+
params,
|
|
691
|
+
values,
|
|
692
|
+
onChange
|
|
693
|
+
} = t0;
|
|
694
|
+
let t1;
|
|
695
|
+
if ($[0] !== title) {
|
|
696
|
+
t1 = /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark text-xs font-semibold uppercase tracking-wider mb-2 block", children: title });
|
|
697
|
+
$[0] = title;
|
|
698
|
+
$[1] = t1;
|
|
699
|
+
} else {
|
|
700
|
+
t1 = $[1];
|
|
701
|
+
}
|
|
702
|
+
let t2;
|
|
703
|
+
if ($[2] !== onChange || $[3] !== params || $[4] !== values) {
|
|
704
|
+
let t32;
|
|
705
|
+
if ($[6] !== onChange || $[7] !== values) {
|
|
706
|
+
t32 = (p) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
707
|
+
/* @__PURE__ */ jsxs("label", { className: "w-32 shrink-0", children: [
|
|
708
|
+
/* @__PURE__ */ jsx("code", { className: "text-xs font-mono font-semibold", children: p.name }),
|
|
709
|
+
p.required && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5 text-xs", children: "*" })
|
|
710
|
+
] }),
|
|
711
|
+
/* @__PURE__ */ jsx("input", { type: "text", placeholder: p.description ?? p.name, value: values[p.name] ?? "", onChange: (e) => onChange(p.name, e.target.value), className: cls("flex-1 px-3 py-1.5 text-xs rounded-lg font-mono", "bg-surface-50 dark:bg-surface-900", "border", defaultBorderMixin, "text-text-primary dark:text-text-primary-dark", "placeholder:text-text-secondary/50", "focus:outline-none focus:ring-2 focus:ring-primary/30", "transition-all") })
|
|
712
|
+
] }, p.name);
|
|
713
|
+
$[6] = onChange;
|
|
714
|
+
$[7] = values;
|
|
715
|
+
$[8] = t32;
|
|
716
|
+
} else {
|
|
717
|
+
t32 = $[8];
|
|
718
|
+
}
|
|
719
|
+
t2 = params.map(t32);
|
|
720
|
+
$[2] = onChange;
|
|
721
|
+
$[3] = params;
|
|
722
|
+
$[4] = values;
|
|
723
|
+
$[5] = t2;
|
|
724
|
+
} else {
|
|
725
|
+
t2 = $[5];
|
|
726
|
+
}
|
|
727
|
+
let t3;
|
|
728
|
+
if ($[9] !== t2) {
|
|
729
|
+
t3 = /* @__PURE__ */ jsx("div", { className: "space-y-2", children: t2 });
|
|
730
|
+
$[9] = t2;
|
|
731
|
+
$[10] = t3;
|
|
732
|
+
} else {
|
|
733
|
+
t3 = $[10];
|
|
734
|
+
}
|
|
735
|
+
let t4;
|
|
736
|
+
if ($[11] !== t1 || $[12] !== t3) {
|
|
737
|
+
t4 = /* @__PURE__ */ jsxs("div", { children: [
|
|
738
|
+
t1,
|
|
739
|
+
t3
|
|
740
|
+
] });
|
|
741
|
+
$[11] = t1;
|
|
742
|
+
$[12] = t3;
|
|
743
|
+
$[13] = t4;
|
|
744
|
+
} else {
|
|
745
|
+
t4 = $[13];
|
|
746
|
+
}
|
|
747
|
+
return t4;
|
|
748
|
+
}
|
|
749
|
+
function CustomKeyValueSection(t0) {
|
|
750
|
+
const $ = c(23);
|
|
751
|
+
const {
|
|
752
|
+
title,
|
|
753
|
+
values,
|
|
754
|
+
onChange,
|
|
755
|
+
onAdd,
|
|
756
|
+
onRemove
|
|
757
|
+
} = t0;
|
|
758
|
+
let t1;
|
|
759
|
+
if ($[0] !== title) {
|
|
760
|
+
t1 = /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary dark:text-text-secondary-dark text-xs font-semibold uppercase tracking-wider block", children: title });
|
|
761
|
+
$[0] = title;
|
|
762
|
+
$[1] = t1;
|
|
763
|
+
} else {
|
|
764
|
+
t1 = $[1];
|
|
765
|
+
}
|
|
766
|
+
let t2;
|
|
767
|
+
if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
768
|
+
t2 = /* @__PURE__ */ jsx(PlusIcon, { size: iconSize.small, className: "mr-1" });
|
|
769
|
+
$[2] = t2;
|
|
770
|
+
} else {
|
|
771
|
+
t2 = $[2];
|
|
772
|
+
}
|
|
773
|
+
let t3;
|
|
774
|
+
if ($[3] !== onAdd) {
|
|
775
|
+
t3 = /* @__PURE__ */ jsxs("button", { onClick: onAdd, className: "text-xs text-primary dark:text-primary-dark hover:underline flex items-center gap-1 font-medium", children: [
|
|
776
|
+
t2,
|
|
777
|
+
" Add Header"
|
|
778
|
+
] });
|
|
779
|
+
$[3] = onAdd;
|
|
780
|
+
$[4] = t3;
|
|
781
|
+
} else {
|
|
782
|
+
t3 = $[4];
|
|
783
|
+
}
|
|
784
|
+
let t4;
|
|
785
|
+
if ($[5] !== t1 || $[6] !== t3) {
|
|
786
|
+
t4 = /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-2", children: [
|
|
787
|
+
t1,
|
|
788
|
+
t3
|
|
789
|
+
] });
|
|
790
|
+
$[5] = t1;
|
|
791
|
+
$[6] = t3;
|
|
792
|
+
$[7] = t4;
|
|
793
|
+
} else {
|
|
794
|
+
t4 = $[7];
|
|
795
|
+
}
|
|
796
|
+
let t5;
|
|
797
|
+
if ($[8] !== onChange || $[9] !== onRemove || $[10] !== values) {
|
|
798
|
+
let t62;
|
|
799
|
+
if ($[12] !== onChange || $[13] !== onRemove) {
|
|
800
|
+
t62 = (v, i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
801
|
+
/* @__PURE__ */ jsx("input", { type: "text", placeholder: "Header name", value: v.key, onChange: (e) => onChange(i, e.target.value, v.value), className: cls("w-1/3 px-3 py-1.5 text-xs rounded-lg font-mono", "bg-surface-50 dark:bg-surface-900", "border", defaultBorderMixin, "text-text-primary dark:text-text-primary-dark", "placeholder:text-text-secondary/50", "focus:outline-none focus:ring-2 focus:ring-primary/30", "transition-all") }),
|
|
802
|
+
/* @__PURE__ */ jsx("input", { type: "text", placeholder: "Value", value: v.value, onChange: (e_0) => onChange(i, v.key, e_0.target.value), className: cls("flex-1 px-3 py-1.5 text-xs rounded-lg font-mono", "bg-surface-50 dark:bg-surface-900", "border", defaultBorderMixin, "text-text-primary dark:text-text-primary-dark", "placeholder:text-text-secondary/50", "focus:outline-none focus:ring-2 focus:ring-primary/30", "transition-all") }),
|
|
803
|
+
/* @__PURE__ */ jsx("button", { onClick: () => onRemove(i), className: "p-1.5 text-text-secondary hover:text-red-500 rounded transition-colors flex items-center justify-center shrink-0", title: "Remove", children: /* @__PURE__ */ jsx(XIcon, { size: iconSize.small }) })
|
|
804
|
+
] }, i);
|
|
805
|
+
$[12] = onChange;
|
|
806
|
+
$[13] = onRemove;
|
|
807
|
+
$[14] = t62;
|
|
808
|
+
} else {
|
|
809
|
+
t62 = $[14];
|
|
810
|
+
}
|
|
811
|
+
t5 = values.map(t62);
|
|
812
|
+
$[8] = onChange;
|
|
813
|
+
$[9] = onRemove;
|
|
814
|
+
$[10] = values;
|
|
815
|
+
$[11] = t5;
|
|
816
|
+
} else {
|
|
817
|
+
t5 = $[11];
|
|
818
|
+
}
|
|
819
|
+
let t6;
|
|
820
|
+
if ($[15] !== values.length) {
|
|
821
|
+
t6 = values.length === 0 && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-text-secondary/50 italic text-xs", children: "No custom headers added." });
|
|
822
|
+
$[15] = values.length;
|
|
823
|
+
$[16] = t6;
|
|
824
|
+
} else {
|
|
825
|
+
t6 = $[16];
|
|
826
|
+
}
|
|
827
|
+
let t7;
|
|
828
|
+
if ($[17] !== t5 || $[18] !== t6) {
|
|
829
|
+
t7 = /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
830
|
+
t5,
|
|
831
|
+
t6
|
|
832
|
+
] });
|
|
833
|
+
$[17] = t5;
|
|
834
|
+
$[18] = t6;
|
|
835
|
+
$[19] = t7;
|
|
836
|
+
} else {
|
|
837
|
+
t7 = $[19];
|
|
838
|
+
}
|
|
839
|
+
let t8;
|
|
840
|
+
if ($[20] !== t4 || $[21] !== t7) {
|
|
841
|
+
t8 = /* @__PURE__ */ jsxs("div", { children: [
|
|
842
|
+
t4,
|
|
843
|
+
t7
|
|
844
|
+
] });
|
|
845
|
+
$[20] = t4;
|
|
846
|
+
$[21] = t7;
|
|
847
|
+
$[22] = t8;
|
|
848
|
+
} else {
|
|
849
|
+
t8 = $[22];
|
|
850
|
+
}
|
|
851
|
+
return t8;
|
|
852
|
+
}
|
|
853
|
+
function ResponseBadge(t0) {
|
|
854
|
+
const $ = c(5);
|
|
855
|
+
const {
|
|
856
|
+
status
|
|
857
|
+
} = t0;
|
|
858
|
+
let colorClass = "text-red-500";
|
|
859
|
+
if (status >= 200 && status < 300) {
|
|
860
|
+
colorClass = "text-emerald-500";
|
|
861
|
+
} else {
|
|
862
|
+
if (status >= 300 && status < 400) {
|
|
863
|
+
colorClass = "text-blue-500";
|
|
864
|
+
} else {
|
|
865
|
+
if (status >= 400 && status < 500) {
|
|
866
|
+
colorClass = "text-amber-500";
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
let t1;
|
|
871
|
+
if ($[0] !== colorClass) {
|
|
872
|
+
t1 = cls("text-xs font-bold font-mono", colorClass);
|
|
873
|
+
$[0] = colorClass;
|
|
874
|
+
$[1] = t1;
|
|
875
|
+
} else {
|
|
876
|
+
t1 = $[1];
|
|
877
|
+
}
|
|
878
|
+
const t2 = status || "ERR";
|
|
879
|
+
let t3;
|
|
880
|
+
if ($[2] !== t1 || $[3] !== t2) {
|
|
881
|
+
t3 = /* @__PURE__ */ jsx("span", { className: t1, children: t2 });
|
|
882
|
+
$[2] = t1;
|
|
883
|
+
$[3] = t2;
|
|
884
|
+
$[4] = t3;
|
|
885
|
+
} else {
|
|
886
|
+
t3 = $[4];
|
|
887
|
+
}
|
|
888
|
+
return t3;
|
|
889
|
+
}
|
|
890
|
+
function buildBodyTemplate(endpoint) {
|
|
891
|
+
if (!endpoint.requestBody?.content) return "{\n \n}";
|
|
892
|
+
const json = endpoint.requestBody.content["application/json"];
|
|
893
|
+
if (!json?.schema?.properties) return "{\n \n}";
|
|
894
|
+
const props = json.schema.properties;
|
|
895
|
+
const lines = ["{"];
|
|
896
|
+
const keys = Object.keys(props);
|
|
897
|
+
keys.forEach((key, i) => {
|
|
898
|
+
const prop = props[key];
|
|
899
|
+
if (prop.readOnly) return;
|
|
900
|
+
const comma = i < keys.length - 1 ? "," : "";
|
|
901
|
+
const val = defaultValue(prop);
|
|
902
|
+
lines.push(` "${key}": ${val}${comma}`);
|
|
903
|
+
});
|
|
904
|
+
lines.push("}");
|
|
905
|
+
return lines.join("\n");
|
|
906
|
+
}
|
|
907
|
+
function defaultValue(schema) {
|
|
908
|
+
if (schema.enum) return JSON.stringify(schema.enum[0]);
|
|
909
|
+
switch (schema.type) {
|
|
910
|
+
case "string":
|
|
911
|
+
return schema.format === "date-time" ? `"${(/* @__PURE__ */ new Date()).toISOString()}"` : '""';
|
|
912
|
+
case "number":
|
|
913
|
+
case "integer":
|
|
914
|
+
return "0";
|
|
915
|
+
case "boolean":
|
|
916
|
+
return "false";
|
|
917
|
+
case "array":
|
|
918
|
+
return "[]";
|
|
919
|
+
default:
|
|
920
|
+
return "null";
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
function ApiExplorer() {
|
|
924
|
+
const apiConfig = useApiConfig();
|
|
925
|
+
const authController = useAuthController();
|
|
926
|
+
const apiUrl = apiConfig?.apiUrl;
|
|
927
|
+
const [spec, setSpec] = useState(null);
|
|
928
|
+
const [loading, setLoading] = useState(true);
|
|
929
|
+
const [error, setError] = useState(null);
|
|
930
|
+
const [selectedEndpoint, setSelectedEndpoint] = useState(null);
|
|
931
|
+
const [sidebarFilter, setSidebarFilter] = useState("");
|
|
932
|
+
const [tryItOpen, setTryItOpen] = useState(false);
|
|
933
|
+
useEffect(() => {
|
|
934
|
+
if (!apiUrl) return;
|
|
935
|
+
let cancelled = false;
|
|
936
|
+
const specUrl = `${apiUrl.replace(/\/+$/, "")}/api/docs`;
|
|
937
|
+
(async () => {
|
|
938
|
+
try {
|
|
939
|
+
const res = await fetch(specUrl);
|
|
940
|
+
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
|
|
941
|
+
const data = await res.json();
|
|
942
|
+
if (!cancelled) {
|
|
943
|
+
setSpec(data);
|
|
944
|
+
setLoading(false);
|
|
945
|
+
}
|
|
946
|
+
} catch (err) {
|
|
947
|
+
if (!cancelled) {
|
|
948
|
+
setError(err.message ?? "Failed to load API spec");
|
|
949
|
+
setLoading(false);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
})();
|
|
953
|
+
return () => {
|
|
954
|
+
cancelled = true;
|
|
955
|
+
};
|
|
956
|
+
}, [apiUrl]);
|
|
957
|
+
const {
|
|
958
|
+
groups,
|
|
959
|
+
allEndpoints
|
|
960
|
+
} = useMemo(() => {
|
|
961
|
+
if (!spec) return {
|
|
962
|
+
groups: [],
|
|
963
|
+
allEndpoints: []
|
|
964
|
+
};
|
|
965
|
+
return parseOpenApiSpec(spec);
|
|
966
|
+
}, [spec]);
|
|
967
|
+
const filteredGroups = useMemo(() => {
|
|
968
|
+
if (!sidebarFilter.trim()) return groups;
|
|
969
|
+
const q = sidebarFilter.toLowerCase();
|
|
970
|
+
return groups.map((g) => ({
|
|
971
|
+
...g,
|
|
972
|
+
endpoints: g.endpoints.filter((e) => e.path.toLowerCase().includes(q) || e.summary.toLowerCase().includes(q) || e.method.toLowerCase().includes(q))
|
|
973
|
+
})).filter((g_0) => g_0.endpoints.length > 0);
|
|
974
|
+
}, [groups, sidebarFilter]);
|
|
975
|
+
useEffect(() => {
|
|
976
|
+
if (!selectedEndpoint && allEndpoints.length > 0) {
|
|
977
|
+
setSelectedEndpoint(allEndpoints[0]);
|
|
978
|
+
}
|
|
979
|
+
}, [allEndpoints, selectedEndpoint]);
|
|
980
|
+
if (!apiUrl) {
|
|
981
|
+
return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full w-full p-8", children: /* @__PURE__ */ jsx(Alert, { color: "warning", children: /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
|
|
982
|
+
"No API URL configured. Ensure your app provides an",
|
|
983
|
+
" ",
|
|
984
|
+
/* @__PURE__ */ jsx("code", { className: "font-mono text-xs", children: "apiUrl" }),
|
|
985
|
+
"."
|
|
986
|
+
] }) }) });
|
|
987
|
+
}
|
|
988
|
+
if (loading) {
|
|
989
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center h-full w-full gap-4", children: [
|
|
990
|
+
/* @__PURE__ */ jsx(CircularProgress, { size: "medium" }),
|
|
991
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-text-secondary dark:text-text-secondary-dark animate-pulse", children: "Loading API specification…" })
|
|
992
|
+
] });
|
|
993
|
+
}
|
|
994
|
+
if (error || !spec) {
|
|
995
|
+
return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full w-full p-8", children: /* @__PURE__ */ jsx(Alert, { color: "error", children: /* @__PURE__ */ jsx(Typography, { variant: "body2", children: error ?? "Unknown error" }) }) });
|
|
996
|
+
}
|
|
997
|
+
const METHOD_COLORS = {
|
|
998
|
+
get: "text-blue-600 dark:text-blue-400",
|
|
999
|
+
post: "text-emerald-600 dark:text-emerald-400",
|
|
1000
|
+
put: "text-amber-600 dark:text-amber-400",
|
|
1001
|
+
patch: "text-orange-600 dark:text-orange-400",
|
|
1002
|
+
delete: "text-red-600 dark:text-red-400"
|
|
1003
|
+
};
|
|
1004
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full overflow-hidden", children: [
|
|
1005
|
+
/* @__PURE__ */ jsxs("div", { className: cls("w-72 min-w-[272px] flex flex-col h-full overflow-hidden border-r", defaultBorderMixin, "bg-surface-50 dark:bg-surface-900"), children: [
|
|
1006
|
+
/* @__PURE__ */ jsxs("div", { className: "p-4 space-y-3", children: [
|
|
1007
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1008
|
+
/* @__PURE__ */ jsx(BookOpenIcon, { size: iconSize.medium, className: "text-primary dark:text-primary-dark" }),
|
|
1009
|
+
/* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "font-semibold", children: spec.info?.title ?? "API Reference" })
|
|
1010
|
+
] }),
|
|
1011
|
+
spec.info?.version && /* @__PURE__ */ jsxs(Chip, { size: "smallest", colorScheme: "cyanDarker", children: [
|
|
1012
|
+
"v",
|
|
1013
|
+
spec.info.version
|
|
1014
|
+
] }),
|
|
1015
|
+
/* @__PURE__ */ jsx("div", { className: "mb-2", children: /* @__PURE__ */ jsx(SearchBar, { placeholder: "Filter endpoints…", size: "small", onTextSearch: (val) => setSidebarFilter(val || "") }) })
|
|
1016
|
+
] }),
|
|
1017
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 overflow-y-auto px-2 pb-4", children: [
|
|
1018
|
+
filteredGroups.map((group) => /* @__PURE__ */ jsxs("div", { className: "mb-3", children: [
|
|
1019
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "px-2 py-1.5 text-text-secondary dark:text-text-secondary-dark uppercase tracking-wider font-semibold text-[10px]", children: group.tag }),
|
|
1020
|
+
group.endpoints.map((ep) => {
|
|
1021
|
+
const isSelected = selectedEndpoint?.id === ep.id;
|
|
1022
|
+
return /* @__PURE__ */ jsxs("button", { onClick: () => {
|
|
1023
|
+
setSelectedEndpoint(ep);
|
|
1024
|
+
setTryItOpen(false);
|
|
1025
|
+
}, className: cls("w-full flex items-center justify-between gap-2 px-2.5 py-1.5 rounded-lg text-left text-sm transition-all", "hover:bg-surface-200 dark:hover:bg-surface-800", isSelected ? "bg-surface-200 dark:bg-surface-800 font-medium" : "text-text-primary dark:text-text-primary-dark"), children: [
|
|
1026
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-[13px] opacity-90", children: ep.summary || ep.shortPath }),
|
|
1027
|
+
/* @__PURE__ */ jsx("span", { className: cls("text-[10px] font-bold uppercase shrink-0", METHOD_COLORS[ep.method] ?? "text-text-secondary"), children: ep.method })
|
|
1028
|
+
] }, ep.id);
|
|
1029
|
+
})
|
|
1030
|
+
] }, group.tag)),
|
|
1031
|
+
filteredGroups.length === 0 && /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-center text-text-secondary dark:text-text-secondary-dark py-8", children: "No endpoints match" })
|
|
1032
|
+
] })
|
|
1033
|
+
] }),
|
|
1034
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 flex flex-col h-full overflow-hidden", children: selectedEndpoint ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1035
|
+
/* @__PURE__ */ jsxs("div", { className: cls("flex items-center justify-between px-5 py-3 gap-4 shrink-0 border-b z-10", defaultBorderMixin, "bg-surface-50/80 dark:bg-surface-950/80 backdrop-blur-md sticky top-0"), children: [
|
|
1036
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 min-w-0", children: [
|
|
1037
|
+
/* @__PURE__ */ jsx("span", { className: cls("text-xs font-bold uppercase", METHOD_COLORS[selectedEndpoint.method] ?? ""), children: selectedEndpoint.method }),
|
|
1038
|
+
/* @__PURE__ */ jsx("code", { className: "text-sm font-mono text-text-primary dark:text-text-primary-dark truncate", children: selectedEndpoint.path })
|
|
1039
|
+
] }),
|
|
1040
|
+
/* @__PURE__ */ jsxs(Button, { variant: tryItOpen ? "filled" : "outlined", size: "small", onClick: () => setTryItOpen((v) => !v), children: [
|
|
1041
|
+
/* @__PURE__ */ jsx(PlayIcon, { size: iconSize.small, className: "mr-1" }),
|
|
1042
|
+
"Try It"
|
|
1043
|
+
] })
|
|
1044
|
+
] }),
|
|
1045
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto", children: tryItOpen ? /* @__PURE__ */ jsx(TryItPanel, { endpoint: selectedEndpoint, apiUrl, getAuthToken: apiConfig?.getAuthToken ?? authController.getAuthToken, user: authController.user, basePath: spec?.servers?.[0]?.url || "" }, selectedEndpoint.operationId || selectedEndpoint.path) : /* @__PURE__ */ jsx(EndpointDetail, { endpoint: selectedEndpoint, spec }) })
|
|
1046
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-text-secondary dark:text-text-secondary-dark", children: "Select an endpoint from the sidebar" }) }) })
|
|
1047
|
+
] });
|
|
1048
|
+
}
|
|
1049
|
+
ApiExplorer.displayName = "ApiExplorer";
|
|
1050
|
+
export {
|
|
1051
|
+
ApiExplorer
|
|
1052
|
+
};
|
|
1053
|
+
//# sourceMappingURL=ApiExplorer-gMJt5JrS.js.map
|