@rebasepro/studio 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -140
- package/dist/ApiExplorer-CdIwR9Ga.js +963 -0
- package/dist/ApiExplorer-CdIwR9Ga.js.map +1 -0
- package/dist/AuthSimulationSelector-iEZ-Or_1.js +56 -0
- package/dist/AuthSimulationSelector-iEZ-Or_1.js.map +1 -0
- package/dist/BranchesView-DncIRcZt.js +461 -0
- package/dist/BranchesView-DncIRcZt.js.map +1 -0
- package/dist/CronJobsView-4gdtJvoe.js +500 -0
- package/dist/CronJobsView-4gdtJvoe.js.map +1 -0
- package/dist/JSEditor-BhAbEjCP.js +1573 -0
- package/dist/JSEditor-BhAbEjCP.js.map +1 -0
- package/dist/LogsExplorer-CqtKILj8.js +240 -0
- package/dist/LogsExplorer-CqtKILj8.js.map +1 -0
- package/dist/MonacoEditor-COZqrIJ1.js +246 -0
- package/dist/MonacoEditor-COZqrIJ1.js.map +1 -0
- package/dist/RLSEditor-CTxYbBdW.js +1362 -0
- package/dist/RLSEditor-CTxYbBdW.js.map +1 -0
- package/dist/SQLEditor-BLuq_zDM.js +1964 -0
- package/dist/SQLEditor-BLuq_zDM.js.map +1 -0
- package/dist/SchemaVisualizer-BJK2u3C0.js +1068 -0
- package/dist/SchemaVisualizer-BJK2u3C0.js.map +1 -0
- package/dist/StorageView-nDaC2foF.js +1382 -0
- package/dist/StorageView-nDaC2foF.js.map +1 -0
- package/dist/{studio/src/components → components}/ApiExplorer/ApiExplorer.d.ts +2 -1
- package/dist/{studio/src/components → components}/ApiExplorer/EndpointDetail.d.ts +2 -1
- package/dist/{studio/src/components → components}/ApiExplorer/TryItPanel.d.ts +2 -1
- package/dist/{studio/src/components → components}/AuthSimulationSelector.d.ts +2 -1
- package/dist/components/Branches/BranchesView.d.ts +2 -0
- package/dist/components/CronJobs/CronJobsView.d.ts +2 -0
- package/dist/components/JSEditor/JSEditor.d.ts +2 -0
- package/dist/{studio/src/components → components}/JSEditor/JSEditorSidebar.d.ts +2 -1
- package/dist/{studio/src/components → components}/JSEditor/JSMonacoEditor.d.ts +2 -1
- package/dist/components/LogsExplorer/LogsExplorer.d.ts +2 -0
- package/dist/{studio/src/components → components}/RLSEditor/PolicyEditor.d.ts +2 -1
- package/dist/{studio/src/components → components}/RLSEditor/RLSEditor.d.ts +2 -7
- package/dist/{studio/src/components → components}/SQLEditor/MonacoEditor.d.ts +2 -1
- package/dist/{studio/src/components → components}/SQLEditor/SQLEditor.d.ts +2 -1
- package/dist/{studio/src/components → components}/SQLEditor/SQLEditorSidebar.d.ts +2 -1
- package/dist/{studio/src/components → components}/SQLEditor/SchemaBrowser.d.ts +2 -1
- package/dist/{studio/src/components → components}/SchemaVisualizer/RelationEdge.d.ts +1 -1
- package/dist/components/SchemaVisualizer/SchemaVisualizer.d.ts +3 -0
- package/dist/{studio/src/components → components}/SchemaVisualizer/TableNode.d.ts +1 -1
- package/dist/{studio/src/components → components}/SchemaVisualizer/schema-visualizer.utils.d.ts +0 -8
- package/dist/components/StorageView/StorageView.d.ts +2 -0
- package/dist/{studio/src/components → components}/StudioHomePage.d.ts +1 -1
- package/dist/index.es.js +688 -746
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +10303 -9572
- package/dist/index.umd.js.map +1 -1
- package/dist/{studio/src/utils → utils}/pgColumnToProperty.d.ts +1 -1
- package/package.json +22 -22
- package/src/components/ApiExplorer/TryItPanel.tsx +15 -18
- package/src/components/CronJobs/CronJobsView.tsx +1 -1
- package/src/components/JSEditor/JSEditor.tsx +10 -15
- package/src/components/LogsExplorer/LogsExplorer.tsx +6 -3
- package/src/components/RLSEditor/PolicyEditor.tsx +0 -1
- package/src/components/RLSEditor/RLSEditor.tsx +1 -1
- package/src/components/SQLEditor/SQLEditor.tsx +40 -30
- package/src/components/SchemaVisualizer/schema-visualizer.utils.ts +3 -3
- package/src/components/SchemaVisualizer/useSchemaGraph.ts +2 -2
- package/src/components/StorageView/StorageView.tsx +22 -11
- package/src/components/StudioHomePage.tsx +51 -15
- package/src/utils/parseSpec.test.ts +41 -20
- package/src/utils/pgColumnToProperty.ts +23 -20
- package/src/utils/sql_utils.ts +1 -1
- package/dist/ApiExplorer-CGHEF1uL.js +0 -1052
- package/dist/ApiExplorer-CGHEF1uL.js.map +0 -1
- package/dist/AuthSimulationSelector-DGoXkWSg.js +0 -105
- package/dist/AuthSimulationSelector-DGoXkWSg.js.map +0 -1
- package/dist/BranchesView-BiTEwIhd.js +0 -291
- package/dist/BranchesView-BiTEwIhd.js.map +0 -1
- package/dist/CronJobsView-3PM_qR8v.js +0 -472
- package/dist/CronJobsView-3PM_qR8v.js.map +0 -1
- package/dist/JSEditor-BCSoElPg.js +0 -1297
- package/dist/JSEditor-BCSoElPg.js.map +0 -1
- package/dist/LogsExplorer-_4sZadKn.js +0 -162
- package/dist/LogsExplorer-_4sZadKn.js.map +0 -1
- package/dist/MonacoEditor-CMYEjiRf.js +0 -161
- package/dist/MonacoEditor-CMYEjiRf.js.map +0 -1
- package/dist/RLSEditor-CHEExeSB.js +0 -1871
- package/dist/RLSEditor-CHEExeSB.js.map +0 -1
- package/dist/SQLEditor-BC0IOUQu.js +0 -1797
- package/dist/SQLEditor-BC0IOUQu.js.map +0 -1
- package/dist/SchemaVisualizer-BGpmzyXT.js +0 -1069
- package/dist/SchemaVisualizer-BGpmzyXT.js.map +0 -1
- package/dist/StorageView-B7AsN2qX.js +0 -869
- package/dist/StorageView-B7AsN2qX.js.map +0 -1
- package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
- package/dist/common/src/collections/default-collections.d.ts +0 -9
- package/dist/common/src/collections/index.d.ts +0 -2
- package/dist/common/src/data/buildRebaseData.d.ts +0 -14
- package/dist/common/src/data/query_builder.d.ts +0 -55
- package/dist/common/src/index.d.ts +0 -4
- package/dist/common/src/util/builders.d.ts +0 -57
- package/dist/common/src/util/callbacks.d.ts +0 -6
- package/dist/common/src/util/collections.d.ts +0 -11
- package/dist/common/src/util/common.d.ts +0 -2
- package/dist/common/src/util/conditions.d.ts +0 -26
- package/dist/common/src/util/entities.d.ts +0 -58
- package/dist/common/src/util/enums.d.ts +0 -3
- package/dist/common/src/util/index.d.ts +0 -16
- package/dist/common/src/util/navigation_from_path.d.ts +0 -34
- package/dist/common/src/util/navigation_utils.d.ts +0 -20
- package/dist/common/src/util/parent_references_from_path.d.ts +0 -6
- package/dist/common/src/util/paths.d.ts +0 -14
- package/dist/common/src/util/permissions.d.ts +0 -6
- package/dist/common/src/util/references.d.ts +0 -2
- package/dist/common/src/util/relations.d.ts +0 -22
- package/dist/common/src/util/resolutions.d.ts +0 -72
- package/dist/common/src/util/storage.d.ts +0 -24
- package/dist/core/src/components/AIIcon.d.ts +0 -16
- package/dist/core/src/components/BootstrapAdminBanner.d.ts +0 -4
- package/dist/core/src/components/ConfirmationDialog.d.ts +0 -9
- package/dist/core/src/components/Debug/UIReferenceView.d.ts +0 -1
- package/dist/core/src/components/Debug/UIStyleGuide.d.ts +0 -1
- package/dist/core/src/components/ErrorTooltip.d.ts +0 -2
- package/dist/core/src/components/ErrorView.d.ts +0 -21
- package/dist/core/src/components/LanguageToggle.d.ts +0 -1
- package/dist/core/src/components/LoginView/LoginView.d.ts +0 -109
- package/dist/core/src/components/LoginView/index.d.ts +0 -2
- package/dist/core/src/components/NotFoundPage.d.ts +0 -1
- package/dist/core/src/components/RebaseAuth.d.ts +0 -10
- package/dist/core/src/components/RebaseLogo.d.ts +0 -7
- package/dist/core/src/components/UnsavedChangesDialog.d.ts +0 -9
- package/dist/core/src/components/UserDisplay.d.ts +0 -7
- package/dist/core/src/components/UserSelectPopover.d.ts +0 -62
- package/dist/core/src/components/UserSettingsView.d.ts +0 -1
- package/dist/core/src/components/common/index.d.ts +0 -6
- package/dist/core/src/components/common/table_height.d.ts +0 -5
- package/dist/core/src/components/common/types.d.ts +0 -66
- package/dist/core/src/components/common/useColumnsIds.d.ts +0 -9
- package/dist/core/src/components/common/useDataTableController.d.ts +0 -45
- package/dist/core/src/components/common/useDebouncedData.d.ts +0 -9
- package/dist/core/src/components/common/useScrollRestoration.d.ts +0 -14
- package/dist/core/src/components/index.d.ts +0 -17
- package/dist/core/src/contexts/AdminModeController.d.ts +0 -4
- package/dist/core/src/contexts/AnalyticsContext.d.ts +0 -3
- package/dist/core/src/contexts/AuthControllerContext.d.ts +0 -3
- package/dist/core/src/contexts/CustomizationControllerContext.d.ts +0 -3
- package/dist/core/src/contexts/DataDriverContext.d.ts +0 -3
- package/dist/core/src/contexts/DatabaseAdminContext.d.ts +0 -3
- package/dist/core/src/contexts/DialogsProvider.d.ts +0 -4
- package/dist/core/src/contexts/EffectiveRoleController.d.ts +0 -4
- package/dist/core/src/contexts/InternalUserManagementContext.d.ts +0 -3
- package/dist/core/src/contexts/ModeController.d.ts +0 -4
- package/dist/core/src/contexts/RebaseClientInstanceContext.d.ts +0 -6
- package/dist/core/src/contexts/RebaseDataContext.d.ts +0 -3
- package/dist/core/src/contexts/SnackbarProvider.d.ts +0 -2
- package/dist/core/src/contexts/StorageSourceContext.d.ts +0 -3
- package/dist/core/src/contexts/UserConfigurationPersistenceContext.d.ts +0 -3
- package/dist/core/src/contexts/index.d.ts +0 -13
- package/dist/core/src/core/PluginLifecycleManager.d.ts +0 -17
- package/dist/core/src/core/PluginProviderStack.d.ts +0 -21
- package/dist/core/src/core/Rebase.d.ts +0 -14
- package/dist/core/src/core/RebaseProps.d.ts +0 -147
- package/dist/core/src/core/RebaseRouter.d.ts +0 -4
- package/dist/core/src/core/RebaseRoutes.d.ts +0 -17
- package/dist/core/src/core/index.d.ts +0 -4
- package/dist/core/src/hooks/ApiConfigContext.d.ts +0 -24
- package/dist/core/src/hooks/data/delete.d.ts +0 -31
- package/dist/core/src/hooks/data/save.d.ts +0 -34
- package/dist/core/src/hooks/data/useCollectionFetch.d.ts +0 -62
- package/dist/core/src/hooks/data/useData.d.ts +0 -13
- package/dist/core/src/hooks/data/useDataOrder.d.ts +0 -12
- package/dist/core/src/hooks/data/useEntityFetch.d.ts +0 -43
- package/dist/core/src/hooks/data/useRelationSelector.d.ts +0 -52
- package/dist/core/src/hooks/data/useUserSelector.d.ts +0 -31
- package/dist/core/src/hooks/index.d.ts +0 -37
- package/dist/core/src/hooks/useAdminModeController.d.ts +0 -19
- package/dist/core/src/hooks/useAnalyticsController.d.ts +0 -5
- package/dist/core/src/hooks/useAuthController.d.ts +0 -11
- package/dist/core/src/hooks/useAuthSubscription.d.ts +0 -2
- package/dist/core/src/hooks/useBackendStorageSource.d.ts +0 -30
- package/dist/core/src/hooks/useBridgeRegistration.d.ts +0 -18
- package/dist/core/src/hooks/useBrowserTitleAndIcon.d.ts +0 -6
- package/dist/core/src/hooks/useBuildAdminModeController.d.ts +0 -6
- package/dist/core/src/hooks/useBuildEffectiveRoleController.d.ts +0 -8
- package/dist/core/src/hooks/useBuildLocalConfigurationPersistence.d.ts +0 -2
- package/dist/core/src/hooks/useBuildModeController.d.ts +0 -6
- package/dist/core/src/hooks/useClipboard.d.ts +0 -57
- package/dist/core/src/hooks/useCollapsedGroups.d.ts +0 -27
- package/dist/core/src/hooks/useCustomizationController.d.ts +0 -11
- package/dist/core/src/hooks/useDialogsController.d.ts +0 -11
- package/dist/core/src/hooks/useEffectiveRoleController.d.ts +0 -7
- package/dist/core/src/hooks/useInternalUserManagementController.d.ts +0 -12
- package/dist/core/src/hooks/useLargeLayout.d.ts +0 -1
- package/dist/core/src/hooks/useModeController.d.ts +0 -19
- package/dist/core/src/hooks/usePermissions.d.ts +0 -12
- package/dist/core/src/hooks/useRebaseClient.d.ts +0 -5
- package/dist/core/src/hooks/useRebaseContext.d.ts +0 -11
- package/dist/core/src/hooks/useRebaseRegistry.d.ts +0 -34
- package/dist/core/src/hooks/useResolvedComponent.d.ts +0 -47
- package/dist/core/src/hooks/useSlot.d.ts +0 -18
- package/dist/core/src/hooks/useSnackbarController.d.ts +0 -20
- package/dist/core/src/hooks/useStorageSource.d.ts +0 -7
- package/dist/core/src/hooks/useStudioBridge.d.ts +0 -91
- package/dist/core/src/hooks/useTranslation.d.ts +0 -17
- package/dist/core/src/hooks/useUnsavedChangesDialog.d.ts +0 -12
- package/dist/core/src/hooks/useUserConfigurationPersistence.d.ts +0 -8
- package/dist/core/src/i18n/RebaseI18nProvider.d.ts +0 -33
- package/dist/core/src/index.d.ts +0 -15
- package/dist/core/src/internal/common.d.ts +0 -3
- package/dist/core/src/internal/useRestoreScroll.d.ts +0 -6
- package/dist/core/src/locales/de.d.ts +0 -2
- package/dist/core/src/locales/en.d.ts +0 -10
- package/dist/core/src/locales/es.d.ts +0 -10
- package/dist/core/src/locales/fr.d.ts +0 -2
- package/dist/core/src/locales/hi.d.ts +0 -2
- package/dist/core/src/locales/it.d.ts +0 -2
- package/dist/core/src/locales/pt.d.ts +0 -7
- package/dist/core/src/util/constants.d.ts +0 -1
- package/dist/core/src/util/createFormexStub.d.ts +0 -2
- package/dist/core/src/util/entity_cache.d.ts +0 -22
- package/dist/core/src/util/enums.d.ts +0 -5
- package/dist/core/src/util/icon_list.d.ts +0 -5
- package/dist/core/src/util/icons.d.ts +0 -20
- package/dist/core/src/util/index.d.ts +0 -8
- package/dist/core/src/util/previews.d.ts +0 -4
- package/dist/core/src/util/useStorageUploadController.d.ts +0 -38
- package/dist/formex/src/Field.d.ts +0 -52
- package/dist/formex/src/Formex.d.ts +0 -7
- package/dist/formex/src/index.d.ts +0 -5
- package/dist/formex/src/types.d.ts +0 -40
- package/dist/formex/src/useCreateFormex.d.ts +0 -14
- package/dist/formex/src/utils.d.ts +0 -16
- package/dist/studio/src/components/Branches/BranchesView.d.ts +0 -1
- package/dist/studio/src/components/CronJobs/CronJobsView.d.ts +0 -1
- package/dist/studio/src/components/JSEditor/JSEditor.d.ts +0 -1
- package/dist/studio/src/components/LogsExplorer/LogsExplorer.d.ts +0 -1
- package/dist/studio/src/components/SchemaVisualizer/SchemaVisualizer.d.ts +0 -2
- package/dist/studio/src/components/SchemaVisualizer/index.d.ts +0 -5
- package/dist/studio/src/components/StorageView/StorageView.d.ts +0 -1
- package/dist/studio/src/utils/entities.d.ts +0 -0
- package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
- package/dist/types/src/controllers/auth.d.ts +0 -104
- package/dist/types/src/controllers/client.d.ts +0 -168
- package/dist/types/src/controllers/collection_registry.d.ts +0 -46
- package/dist/types/src/controllers/customization_controller.d.ts +0 -60
- package/dist/types/src/controllers/data.d.ts +0 -207
- package/dist/types/src/controllers/data_driver.d.ts +0 -218
- package/dist/types/src/controllers/database_admin.d.ts +0 -11
- package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
- package/dist/types/src/controllers/effective_role.d.ts +0 -4
- package/dist/types/src/controllers/email.d.ts +0 -36
- package/dist/types/src/controllers/index.d.ts +0 -18
- package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
- package/dist/types/src/controllers/navigation.d.ts +0 -225
- package/dist/types/src/controllers/registry.d.ts +0 -63
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
- package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
- package/dist/types/src/controllers/snackbar.d.ts +0 -24
- package/dist/types/src/controllers/storage.d.ts +0 -171
- package/dist/types/src/index.d.ts +0 -4
- package/dist/types/src/rebase_context.d.ts +0 -122
- package/dist/types/src/types/auth_adapter.d.ts +0 -301
- package/dist/types/src/types/backend.d.ts +0 -536
- package/dist/types/src/types/backend_hooks.d.ts +0 -172
- package/dist/types/src/types/builders.d.ts +0 -15
- package/dist/types/src/types/chips.d.ts +0 -5
- package/dist/types/src/types/collections.d.ts +0 -941
- package/dist/types/src/types/component_ref.d.ts +0 -47
- package/dist/types/src/types/cron.d.ts +0 -102
- package/dist/types/src/types/data_source.d.ts +0 -64
- package/dist/types/src/types/database_adapter.d.ts +0 -94
- package/dist/types/src/types/entities.d.ts +0 -145
- package/dist/types/src/types/entity_actions.d.ts +0 -104
- package/dist/types/src/types/entity_callbacks.d.ts +0 -173
- package/dist/types/src/types/entity_link_builder.d.ts +0 -7
- package/dist/types/src/types/entity_overrides.d.ts +0 -10
- package/dist/types/src/types/entity_views.d.ts +0 -87
- package/dist/types/src/types/export_import.d.ts +0 -21
- package/dist/types/src/types/formex.d.ts +0 -40
- package/dist/types/src/types/index.d.ts +0 -28
- package/dist/types/src/types/locales.d.ts +0 -4
- package/dist/types/src/types/modify_collections.d.ts +0 -5
- package/dist/types/src/types/plugins.d.ts +0 -282
- package/dist/types/src/types/properties.d.ts +0 -1181
- package/dist/types/src/types/property_config.d.ts +0 -74
- package/dist/types/src/types/relations.d.ts +0 -336
- package/dist/types/src/types/slots.d.ts +0 -262
- package/dist/types/src/types/translations.d.ts +0 -900
- package/dist/types/src/types/user_management_delegate.d.ts +0 -86
- package/dist/types/src/types/websockets.d.ts +0 -78
- package/dist/types/src/users/index.d.ts +0 -1
- package/dist/types/src/users/user.d.ts +0 -50
- package/dist/ui/src/components/Alert.d.ts +0 -12
- package/dist/ui/src/components/Autocomplete.d.ts +0 -21
- package/dist/ui/src/components/Avatar.d.ts +0 -11
- package/dist/ui/src/components/Badge.d.ts +0 -8
- package/dist/ui/src/components/BooleanSwitch.d.ts +0 -14
- package/dist/ui/src/components/BooleanSwitchWithLabel.d.ts +0 -17
- package/dist/ui/src/components/Button.d.ts +0 -14
- package/dist/ui/src/components/Card.d.ts +0 -8
- package/dist/ui/src/components/CenteredView.d.ts +0 -9
- package/dist/ui/src/components/Checkbox.d.ts +0 -13
- package/dist/ui/src/components/Chip.d.ts +0 -26
- package/dist/ui/src/components/CircularProgress.d.ts +0 -5
- package/dist/ui/src/components/CircularProgressCenter.d.ts +0 -11
- package/dist/ui/src/components/Collapse.d.ts +0 -9
- package/dist/ui/src/components/ColorPicker.d.ts +0 -30
- package/dist/ui/src/components/Container.d.ts +0 -8
- package/dist/ui/src/components/DateTimeField.d.ts +0 -24
- package/dist/ui/src/components/DebouncedTextField.d.ts +0 -2
- package/dist/ui/src/components/Dialog.d.ts +0 -39
- package/dist/ui/src/components/DialogActions.d.ts +0 -7
- package/dist/ui/src/components/DialogContent.d.ts +0 -7
- package/dist/ui/src/components/DialogTitle.d.ts +0 -10
- package/dist/ui/src/components/ErrorBoundary.d.ts +0 -33
- package/dist/ui/src/components/ExpandablePanel.d.ts +0 -12
- package/dist/ui/src/components/FileUpload.d.ts +0 -23
- package/dist/ui/src/components/FilterChip.d.ts +0 -34
- package/dist/ui/src/components/IconButton.d.ts +0 -12
- package/dist/ui/src/components/InfoLabel.d.ts +0 -5
- package/dist/ui/src/components/InputLabel.d.ts +0 -11
- package/dist/ui/src/components/Label.d.ts +0 -7
- package/dist/ui/src/components/LoadingButton.d.ts +0 -7
- package/dist/ui/src/components/Markdown.d.ts +0 -10
- package/dist/ui/src/components/Menu.d.ts +0 -23
- package/dist/ui/src/components/Menubar.d.ts +0 -80
- package/dist/ui/src/components/MultiSelect.d.ts +0 -48
- package/dist/ui/src/components/Paper.d.ts +0 -6
- package/dist/ui/src/components/Popover.d.ts +0 -24
- package/dist/ui/src/components/RadioGroup.d.ts +0 -28
- package/dist/ui/src/components/ResizablePanels.d.ts +0 -18
- package/dist/ui/src/components/SearchBar.d.ts +0 -26
- package/dist/ui/src/components/Select.d.ts +0 -43
- package/dist/ui/src/components/Separator.d.ts +0 -5
- package/dist/ui/src/components/Sheet.d.ts +0 -22
- package/dist/ui/src/components/Skeleton.d.ts +0 -6
- package/dist/ui/src/components/Slider.d.ts +0 -21
- package/dist/ui/src/components/Table.d.ts +0 -34
- package/dist/ui/src/components/Tabs.d.ts +0 -19
- package/dist/ui/src/components/TextField.d.ts +0 -58
- package/dist/ui/src/components/TextareaAutosize.d.ts +0 -43
- package/dist/ui/src/components/ToggleButtonGroup.d.ts +0 -30
- package/dist/ui/src/components/Tooltip.d.ts +0 -19
- package/dist/ui/src/components/Typography.d.ts +0 -36
- package/dist/ui/src/components/VirtualTable/VirtualTable.d.ts +0 -11
- package/dist/ui/src/components/VirtualTable/VirtualTableCell.d.ts +0 -21
- package/dist/ui/src/components/VirtualTable/VirtualTableHeader.d.ts +0 -29
- package/dist/ui/src/components/VirtualTable/VirtualTableHeaderRow.d.ts +0 -2
- package/dist/ui/src/components/VirtualTable/VirtualTableProps.d.ts +0 -249
- package/dist/ui/src/components/VirtualTable/VirtualTableRow.d.ts +0 -3
- package/dist/ui/src/components/VirtualTable/index.d.ts +0 -3
- package/dist/ui/src/components/VirtualTable/types.d.ts +0 -38
- package/dist/ui/src/components/common/SelectInputLabel.d.ts +0 -5
- package/dist/ui/src/components/index.d.ts +0 -58
- package/dist/ui/src/hooks/PortalContainerContext.d.ts +0 -31
- package/dist/ui/src/hooks/index.d.ts +0 -6
- package/dist/ui/src/hooks/useDebounceCallback.d.ts +0 -1
- package/dist/ui/src/hooks/useDebounceValue.d.ts +0 -1
- package/dist/ui/src/hooks/useDebouncedCallback.d.ts +0 -1
- package/dist/ui/src/hooks/useInjectStyles.d.ts +0 -7
- package/dist/ui/src/hooks/useOutsideAlerter.d.ts +0 -5
- package/dist/ui/src/icons/GitHubIcon.d.ts +0 -2
- package/dist/ui/src/icons/HandleIcon.d.ts +0 -1
- package/dist/ui/src/icons/Icon.d.ts +0 -20
- package/dist/ui/src/icons/cool_icon_keys.d.ts +0 -1
- package/dist/ui/src/icons/icon_keys.d.ts +0 -1
- package/dist/ui/src/icons/index.d.ts +0 -8
- package/dist/ui/src/index.d.ts +0 -5
- package/dist/ui/src/styles.d.ts +0 -12
- package/dist/ui/src/util/chip_colors.d.ts +0 -4
- package/dist/ui/src/util/cls.d.ts +0 -2
- package/dist/ui/src/util/debounce.d.ts +0 -10
- package/dist/ui/src/util/hash.d.ts +0 -1
- package/dist/ui/src/util/index.d.ts +0 -4
- package/dist/ui/src/util/key_to_icon_component.d.ts +0 -1
- package/src/components/SchemaVisualizer/index.ts +0 -5
- package/src/utils/entities.ts +0 -2
- /package/dist/{studio/src/components → components}/ApiExplorer/parseSpec.d.ts +0 -0
- /package/dist/{studio/src/components → components}/ApiExplorer/types.d.ts +0 -0
- /package/dist/{studio/src/components → components}/RLSEditor/index.d.ts +0 -0
- /package/dist/{studio/src/components → components}/RebaseStudio.d.ts +0 -0
- /package/dist/{studio/src/components → components}/SQLEditor/ExplainVisualizer.d.ts +0 -0
- /package/dist/{studio/src/components → components}/SchemaVisualizer/useSchemaGraph.d.ts +0 -0
- /package/dist/{studio/src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{studio/src/utils → utils}/sql_utils.d.ts +0 -0
|
@@ -0,0 +1,963 @@
|
|
|
1
|
+
import { t as AuthSimulationSelector } from "./AuthSimulationSelector-iEZ-Or_1.js";
|
|
2
|
+
import { useApiConfig, useAuthController, useRebaseContext } from "@rebasepro/core";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
4
|
+
import { Alert, ArrowRightFromLineIcon, BookOpenIcon, Button, Chip, CircularProgress, IconButton, LoaderIcon, PlayIcon, PlusIcon, SearchBar, SendIcon, SlidersHorizontalIcon, TextField, Typography, UploadIcon, XIcon, cls, defaultBorderMixin, iconSize } from "@rebasepro/ui";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/ApiExplorer/parseSpec.ts
|
|
7
|
+
/**
|
|
8
|
+
* Parse an OpenAPI 3.x spec into grouped, sorted endpoints for the sidebar.
|
|
9
|
+
*/
|
|
10
|
+
function parseOpenApiSpec(spec) {
|
|
11
|
+
const allEndpoints = [];
|
|
12
|
+
const tagMap = /* @__PURE__ */ new Map();
|
|
13
|
+
const tagDescriptions = /* @__PURE__ */ new Map();
|
|
14
|
+
for (const t of spec.tags ?? []) tagDescriptions.set(t.name, t.description ?? "");
|
|
15
|
+
for (const [path, methods] of Object.entries(spec.paths ?? {})) for (const [method, op] of Object.entries(methods)) {
|
|
16
|
+
if ([
|
|
17
|
+
"get",
|
|
18
|
+
"post",
|
|
19
|
+
"put",
|
|
20
|
+
"patch",
|
|
21
|
+
"delete"
|
|
22
|
+
].indexOf(method) === -1) continue;
|
|
23
|
+
const tags = op.tags?.length ? op.tags : ["Other"];
|
|
24
|
+
const shortPath = path.replace(/^\/api\/data/, "");
|
|
25
|
+
const endpoint = {
|
|
26
|
+
id: `${method}:${path}`,
|
|
27
|
+
method,
|
|
28
|
+
path,
|
|
29
|
+
shortPath: shortPath || "/",
|
|
30
|
+
summary: op.summary ?? "",
|
|
31
|
+
description: op.description ?? "",
|
|
32
|
+
tags,
|
|
33
|
+
parameters: op.parameters ?? [],
|
|
34
|
+
requestBody: op.requestBody,
|
|
35
|
+
responses: op.responses ?? {},
|
|
36
|
+
security: op.security,
|
|
37
|
+
operationId: op.operationId
|
|
38
|
+
};
|
|
39
|
+
allEndpoints.push(endpoint);
|
|
40
|
+
for (const tag of tags) {
|
|
41
|
+
if (!tagMap.has(tag)) tagMap.set(tag, []);
|
|
42
|
+
tagMap.get(tag).push(endpoint);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const ORDER = {
|
|
46
|
+
get: 0,
|
|
47
|
+
post: 1,
|
|
48
|
+
put: 2,
|
|
49
|
+
patch: 3,
|
|
50
|
+
delete: 4
|
|
51
|
+
};
|
|
52
|
+
const groups = [];
|
|
53
|
+
const tagOrder = (spec.tags ?? []).map((t) => t.name);
|
|
54
|
+
const sortedTags = [...tagMap.keys()].sort((a, b) => {
|
|
55
|
+
const ai = tagOrder.indexOf(a);
|
|
56
|
+
const bi = tagOrder.indexOf(b);
|
|
57
|
+
if (ai !== -1 && bi !== -1) return ai - bi;
|
|
58
|
+
if (ai !== -1) return -1;
|
|
59
|
+
if (bi !== -1) return 1;
|
|
60
|
+
return a.localeCompare(b);
|
|
61
|
+
});
|
|
62
|
+
for (const tag of sortedTags) {
|
|
63
|
+
const endpoints = tagMap.get(tag);
|
|
64
|
+
endpoints.sort((a, b) => {
|
|
65
|
+
const pa = a.path.localeCompare(b.path);
|
|
66
|
+
if (pa !== 0) return pa;
|
|
67
|
+
return (ORDER[a.method] ?? 99) - (ORDER[b.method] ?? 99);
|
|
68
|
+
});
|
|
69
|
+
groups.push({
|
|
70
|
+
tag,
|
|
71
|
+
description: tagDescriptions.get(tag),
|
|
72
|
+
endpoints
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
groups,
|
|
77
|
+
allEndpoints
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Resolve a $ref string (e.g. "#/components/schemas/Author") to a schema name.
|
|
82
|
+
*/
|
|
83
|
+
function resolveRefName(ref) {
|
|
84
|
+
const parts = ref.split("/");
|
|
85
|
+
return parts[parts.length - 1];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Resolve a $ref to its actual schema from the spec.
|
|
89
|
+
*/
|
|
90
|
+
function resolveRef(spec, ref) {
|
|
91
|
+
const parts = ref.replace("#/", "").split("/");
|
|
92
|
+
let current = spec;
|
|
93
|
+
for (const part of parts) current = current?.[part];
|
|
94
|
+
return current ?? {};
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/components/ApiExplorer/EndpointDetail.tsx
|
|
98
|
+
/**
|
|
99
|
+
* Renders the documentation view for a single API endpoint:
|
|
100
|
+
* parameters, request body schema, response schemas.
|
|
101
|
+
*/
|
|
102
|
+
function EndpointDetail({ endpoint, spec }) {
|
|
103
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
104
|
+
className: "p-6 space-y-8 max-w-4xl",
|
|
105
|
+
children: [
|
|
106
|
+
(endpoint.summary || endpoint.description) && /* @__PURE__ */ jsxs("div", { children: [endpoint.summary && /* @__PURE__ */ jsx(Typography, {
|
|
107
|
+
variant: "h6",
|
|
108
|
+
className: "font-semibold mb-1",
|
|
109
|
+
children: endpoint.summary
|
|
110
|
+
}), endpoint.description && /* @__PURE__ */ jsx(Typography, {
|
|
111
|
+
variant: "body2",
|
|
112
|
+
className: "text-text-secondary dark:text-text-secondary-dark",
|
|
113
|
+
children: endpoint.description
|
|
114
|
+
})] }),
|
|
115
|
+
endpoint.parameters.length > 0 && /* @__PURE__ */ jsxs("section", { children: [/* @__PURE__ */ jsx(SectionHeading, {
|
|
116
|
+
icon: /* @__PURE__ */ jsx(SlidersHorizontalIcon, {
|
|
117
|
+
size: iconSize.small,
|
|
118
|
+
className: "text-text-secondary dark:text-text-secondary-dark"
|
|
119
|
+
}),
|
|
120
|
+
title: "Parameters"
|
|
121
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
122
|
+
className: cls("rounded-lg border overflow-hidden", defaultBorderMixin),
|
|
123
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
124
|
+
className: "w-full text-sm",
|
|
125
|
+
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", {
|
|
126
|
+
className: "bg-surface-100 dark:bg-surface-900 text-left",
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ jsx("th", {
|
|
129
|
+
className: "px-4 py-2 font-medium text-text-secondary dark:text-text-secondary-dark",
|
|
130
|
+
children: "Name"
|
|
131
|
+
}),
|
|
132
|
+
/* @__PURE__ */ jsx("th", {
|
|
133
|
+
className: "px-4 py-2 font-medium text-text-secondary dark:text-text-secondary-dark",
|
|
134
|
+
children: "In"
|
|
135
|
+
}),
|
|
136
|
+
/* @__PURE__ */ jsx("th", {
|
|
137
|
+
className: "px-4 py-2 font-medium text-text-secondary dark:text-text-secondary-dark",
|
|
138
|
+
children: "Type"
|
|
139
|
+
}),
|
|
140
|
+
/* @__PURE__ */ jsx("th", {
|
|
141
|
+
className: "px-4 py-2 font-medium text-text-secondary dark:text-text-secondary-dark",
|
|
142
|
+
children: "Description"
|
|
143
|
+
})
|
|
144
|
+
]
|
|
145
|
+
}) }), /* @__PURE__ */ jsx("tbody", { children: endpoint.parameters.map((p, i) => /* @__PURE__ */ jsxs("tr", {
|
|
146
|
+
className: cls("border-t", defaultBorderMixin),
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ jsxs("td", {
|
|
149
|
+
className: "px-4 py-2.5",
|
|
150
|
+
children: [/* @__PURE__ */ jsx("code", {
|
|
151
|
+
className: "text-xs font-mono font-semibold",
|
|
152
|
+
children: p.name
|
|
153
|
+
}), p.required && /* @__PURE__ */ jsx("span", {
|
|
154
|
+
className: "text-red-500 ml-1 text-xs",
|
|
155
|
+
children: "*"
|
|
156
|
+
})]
|
|
157
|
+
}),
|
|
158
|
+
/* @__PURE__ */ jsx("td", {
|
|
159
|
+
className: "px-4 py-2.5",
|
|
160
|
+
children: /* @__PURE__ */ jsx(Chip, {
|
|
161
|
+
size: "smallest",
|
|
162
|
+
colorScheme: p.in === "path" ? "orangeDarker" : "cyanDarker",
|
|
163
|
+
children: p.in
|
|
164
|
+
})
|
|
165
|
+
}),
|
|
166
|
+
/* @__PURE__ */ jsx("td", {
|
|
167
|
+
className: "px-4 py-2.5 text-xs font-mono text-text-secondary dark:text-text-secondary-dark",
|
|
168
|
+
children: schemaTypeLabel(p.schema)
|
|
169
|
+
}),
|
|
170
|
+
/* @__PURE__ */ jsx("td", {
|
|
171
|
+
className: "px-4 py-2.5 text-xs text-text-secondary dark:text-text-secondary-dark",
|
|
172
|
+
children: p.description ?? "—"
|
|
173
|
+
})
|
|
174
|
+
]
|
|
175
|
+
}, p.name + i)) })]
|
|
176
|
+
})
|
|
177
|
+
})] }),
|
|
178
|
+
endpoint.requestBody && /* @__PURE__ */ jsxs("section", { children: [/* @__PURE__ */ jsx(SectionHeading, {
|
|
179
|
+
icon: /* @__PURE__ */ jsx(UploadIcon, {
|
|
180
|
+
size: iconSize.small,
|
|
181
|
+
className: "text-text-secondary dark:text-text-secondary-dark"
|
|
182
|
+
}),
|
|
183
|
+
title: "Request Body"
|
|
184
|
+
}), Object.entries(endpoint.requestBody.content ?? {}).map(([contentType, media]) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Chip, {
|
|
185
|
+
size: "smallest",
|
|
186
|
+
colorScheme: "blueDarker",
|
|
187
|
+
className: "mb-3",
|
|
188
|
+
children: contentType
|
|
189
|
+
}), media.schema && /* @__PURE__ */ jsx(SchemaBlock, {
|
|
190
|
+
schema: media.schema,
|
|
191
|
+
spec,
|
|
192
|
+
depth: 0
|
|
193
|
+
})] }, contentType))] }),
|
|
194
|
+
/* @__PURE__ */ jsxs("section", { children: [/* @__PURE__ */ jsx(SectionHeading, {
|
|
195
|
+
icon: /* @__PURE__ */ jsx(ArrowRightFromLineIcon, {
|
|
196
|
+
size: iconSize.small,
|
|
197
|
+
className: "text-text-secondary dark:text-text-secondary-dark"
|
|
198
|
+
}),
|
|
199
|
+
title: "Responses"
|
|
200
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
201
|
+
className: "space-y-3",
|
|
202
|
+
children: Object.entries(endpoint.responses).map(([code, res]) => /* @__PURE__ */ jsxs("div", {
|
|
203
|
+
className: cls("rounded-lg border overflow-hidden", defaultBorderMixin),
|
|
204
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
205
|
+
className: cls("flex items-center gap-3 px-4 py-2.5", "bg-surface-50 dark:bg-surface-900/50"),
|
|
206
|
+
children: [/* @__PURE__ */ jsx(StatusBadge, { code }), /* @__PURE__ */ jsx(Typography, {
|
|
207
|
+
variant: "body2",
|
|
208
|
+
className: "text-text-secondary dark:text-text-secondary-dark text-xs",
|
|
209
|
+
children: res.description
|
|
210
|
+
})]
|
|
211
|
+
}), res.content && Object.entries(res.content).map(([ct, media]) => media.schema && /* @__PURE__ */ jsx("div", {
|
|
212
|
+
className: cls("px-4 py-3 border-t", defaultBorderMixin),
|
|
213
|
+
children: /* @__PURE__ */ jsx(SchemaBlock, {
|
|
214
|
+
schema: media.schema,
|
|
215
|
+
spec,
|
|
216
|
+
depth: 0
|
|
217
|
+
})
|
|
218
|
+
}, ct))]
|
|
219
|
+
}, code))
|
|
220
|
+
})] })
|
|
221
|
+
]
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
function SchemaBlock({ schema, spec, depth }) {
|
|
225
|
+
if (schema.$ref) {
|
|
226
|
+
const name = resolveRefName(schema.$ref);
|
|
227
|
+
const resolved = resolveRef(spec, schema.$ref);
|
|
228
|
+
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
|
|
229
|
+
variant: "caption",
|
|
230
|
+
className: "text-primary dark:text-primary-dark font-mono text-xs mb-2 block",
|
|
231
|
+
children: name
|
|
232
|
+
}), /* @__PURE__ */ jsx(SchemaBlock, {
|
|
233
|
+
schema: resolved,
|
|
234
|
+
spec,
|
|
235
|
+
depth
|
|
236
|
+
})] });
|
|
237
|
+
}
|
|
238
|
+
if (schema.properties) {
|
|
239
|
+
const required = new Set(schema.required ?? []);
|
|
240
|
+
return /* @__PURE__ */ jsx("div", {
|
|
241
|
+
className: cls("rounded-lg overflow-hidden", depth > 0 && `border ml-4 mt-1 ${defaultBorderMixin}`),
|
|
242
|
+
children: /* @__PURE__ */ jsx("table", {
|
|
243
|
+
className: "w-full text-xs",
|
|
244
|
+
children: /* @__PURE__ */ jsx("tbody", { children: Object.entries(schema.properties).map(([key, prop]) => /* @__PURE__ */ jsxs("tr", {
|
|
245
|
+
className: cls("border-t first:border-t-0", defaultBorderMixin),
|
|
246
|
+
children: [
|
|
247
|
+
/* @__PURE__ */ jsxs("td", {
|
|
248
|
+
className: "px-3 py-2 align-top w-36",
|
|
249
|
+
children: [
|
|
250
|
+
/* @__PURE__ */ jsx("code", {
|
|
251
|
+
className: "font-mono font-semibold text-text-primary dark:text-text-primary-dark",
|
|
252
|
+
children: key
|
|
253
|
+
}),
|
|
254
|
+
required.has(key) && /* @__PURE__ */ jsx("span", {
|
|
255
|
+
className: "text-red-500 ml-0.5",
|
|
256
|
+
children: "*"
|
|
257
|
+
}),
|
|
258
|
+
prop.readOnly && /* @__PURE__ */ jsx("span", {
|
|
259
|
+
className: "ml-1.5 text-[9px] text-text-secondary dark:text-text-secondary-dark italic",
|
|
260
|
+
children: "read-only"
|
|
261
|
+
})
|
|
262
|
+
]
|
|
263
|
+
}),
|
|
264
|
+
/* @__PURE__ */ jsx("td", {
|
|
265
|
+
className: "px-3 py-2 align-top w-28",
|
|
266
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
267
|
+
className: "font-mono text-text-secondary dark:text-text-secondary-dark",
|
|
268
|
+
children: schemaTypeLabel(prop)
|
|
269
|
+
})
|
|
270
|
+
}),
|
|
271
|
+
/* @__PURE__ */ jsxs("td", {
|
|
272
|
+
className: "px-3 py-2 align-top text-text-secondary dark:text-text-secondary-dark",
|
|
273
|
+
children: [
|
|
274
|
+
prop.description ?? "",
|
|
275
|
+
prop.enum && /* @__PURE__ */ jsx("div", {
|
|
276
|
+
className: "flex flex-wrap gap-1 mt-1",
|
|
277
|
+
children: prop.enum.map((v) => /* @__PURE__ */ jsx("span", {
|
|
278
|
+
className: "px-1.5 py-0.5 rounded bg-surface-200 dark:bg-surface-800 text-[10px] font-mono",
|
|
279
|
+
children: String(v)
|
|
280
|
+
}, String(v)))
|
|
281
|
+
}),
|
|
282
|
+
prop.properties && /* @__PURE__ */ jsx(SchemaBlock, {
|
|
283
|
+
schema: prop,
|
|
284
|
+
spec,
|
|
285
|
+
depth: depth + 1
|
|
286
|
+
}),
|
|
287
|
+
prop.$ref && /* @__PURE__ */ jsx(SchemaBlock, {
|
|
288
|
+
schema: prop,
|
|
289
|
+
spec,
|
|
290
|
+
depth: depth + 1
|
|
291
|
+
})
|
|
292
|
+
]
|
|
293
|
+
})
|
|
294
|
+
]
|
|
295
|
+
}, key)) })
|
|
296
|
+
})
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
if (schema.type === "array" && schema.items) return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
|
|
300
|
+
className: "font-mono text-xs text-text-secondary dark:text-text-secondary-dark",
|
|
301
|
+
children: "Array of:"
|
|
302
|
+
}), /* @__PURE__ */ jsx(SchemaBlock, {
|
|
303
|
+
schema: schema.items,
|
|
304
|
+
spec,
|
|
305
|
+
depth: depth + 1
|
|
306
|
+
})] });
|
|
307
|
+
return /* @__PURE__ */ jsx("span", {
|
|
308
|
+
className: "font-mono text-xs text-text-secondary dark:text-text-secondary-dark",
|
|
309
|
+
children: schemaTypeLabel(schema)
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
function schemaTypeLabel(schema) {
|
|
313
|
+
if (!schema) return "any";
|
|
314
|
+
if (schema.$ref) return resolveRefName(schema.$ref);
|
|
315
|
+
if (schema.type === "array") return `${schemaTypeLabel(schema.items)}[]`;
|
|
316
|
+
if (schema.format) return `${schema.type} (${schema.format})`;
|
|
317
|
+
return schema.type ?? "object";
|
|
318
|
+
}
|
|
319
|
+
function SectionHeading({ icon, title }) {
|
|
320
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
321
|
+
className: "flex items-center gap-2 mb-3",
|
|
322
|
+
children: [icon, /* @__PURE__ */ jsx(Typography, {
|
|
323
|
+
variant: "subtitle2",
|
|
324
|
+
className: "font-semibold text-sm",
|
|
325
|
+
children: title
|
|
326
|
+
})]
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
function StatusBadge({ code }) {
|
|
330
|
+
const n = parseInt(code, 10);
|
|
331
|
+
return /* @__PURE__ */ jsx("span", {
|
|
332
|
+
className: cls("text-xs font-bold font-mono", 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"),
|
|
333
|
+
children: code
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/components/ApiExplorer/TryItPanel.tsx
|
|
338
|
+
/**
|
|
339
|
+
* Interactive "Try It" panel that lets the user execute API requests
|
|
340
|
+
* using their current JWT token directly from the Studio.
|
|
341
|
+
*/
|
|
342
|
+
function TryItPanel({ endpoint, apiUrl, getAuthToken, user, basePath = "" }) {
|
|
343
|
+
const storageKey = `rebase_apiexplorer_${endpoint.method}_${endpoint.path}`;
|
|
344
|
+
const [pathParams, setPathParams] = useState(() => {
|
|
345
|
+
try {
|
|
346
|
+
const v = localStorage.getItem(`${storageKey}_path`);
|
|
347
|
+
if (v) return JSON.parse(v);
|
|
348
|
+
} catch {}
|
|
349
|
+
return {};
|
|
350
|
+
});
|
|
351
|
+
const [queryParams, setQueryParams] = useState(() => {
|
|
352
|
+
try {
|
|
353
|
+
const v = localStorage.getItem(`${storageKey}_query`);
|
|
354
|
+
if (v) return JSON.parse(v);
|
|
355
|
+
} catch {}
|
|
356
|
+
return {};
|
|
357
|
+
});
|
|
358
|
+
const [customHeaders, setCustomHeaders] = useState(() => {
|
|
359
|
+
try {
|
|
360
|
+
const v = localStorage.getItem(`${storageKey}_headers`);
|
|
361
|
+
if (v) return JSON.parse(v);
|
|
362
|
+
} catch {}
|
|
363
|
+
return [{
|
|
364
|
+
key: "rebase-branch",
|
|
365
|
+
value: ""
|
|
366
|
+
}];
|
|
367
|
+
});
|
|
368
|
+
const [body, setBody] = useState(() => {
|
|
369
|
+
try {
|
|
370
|
+
const v = localStorage.getItem(`${storageKey}_body`);
|
|
371
|
+
if (v) return JSON.parse(v);
|
|
372
|
+
} catch {}
|
|
373
|
+
return buildBodyTemplate(endpoint);
|
|
374
|
+
});
|
|
375
|
+
const [response, setResponse] = useState(null);
|
|
376
|
+
const [loading, setLoading] = useState(false);
|
|
377
|
+
const [authMode, setAuthMode] = useState("jwt");
|
|
378
|
+
const [validationError, setValidationError] = useState(null);
|
|
379
|
+
const currentUser = useRebaseContext().authController?.user;
|
|
380
|
+
const users = useMemo(() => {
|
|
381
|
+
const managed = [];
|
|
382
|
+
if (currentUser) managed.push({
|
|
383
|
+
uid: currentUser.uid,
|
|
384
|
+
displayName: currentUser.displayName,
|
|
385
|
+
email: currentUser.email,
|
|
386
|
+
photoURL: currentUser.photoURL,
|
|
387
|
+
roles: currentUser.roles
|
|
388
|
+
});
|
|
389
|
+
return managed;
|
|
390
|
+
}, [currentUser]);
|
|
391
|
+
const currentSelectableUser = useMemo(() => {
|
|
392
|
+
if (!currentUser) return null;
|
|
393
|
+
return {
|
|
394
|
+
uid: currentUser.uid,
|
|
395
|
+
displayName: currentUser.displayName,
|
|
396
|
+
email: currentUser.email,
|
|
397
|
+
photoURL: currentUser.photoURL,
|
|
398
|
+
roles: currentUser.roles
|
|
399
|
+
};
|
|
400
|
+
}, [currentUser]);
|
|
401
|
+
const [selectedUser, setSelectedUser] = useState(null);
|
|
402
|
+
useEffect(() => {
|
|
403
|
+
localStorage.setItem(`${storageKey}_path`, JSON.stringify(pathParams));
|
|
404
|
+
localStorage.setItem(`${storageKey}_query`, JSON.stringify(queryParams));
|
|
405
|
+
localStorage.setItem(`${storageKey}_headers`, JSON.stringify(customHeaders));
|
|
406
|
+
localStorage.setItem(`${storageKey}_body`, JSON.stringify(body));
|
|
407
|
+
}, [
|
|
408
|
+
storageKey,
|
|
409
|
+
pathParams,
|
|
410
|
+
queryParams,
|
|
411
|
+
customHeaders,
|
|
412
|
+
body
|
|
413
|
+
]);
|
|
414
|
+
const resolvedUrl = useMemo(() => {
|
|
415
|
+
const base = basePath.startsWith("/") ? basePath : `/${basePath}`;
|
|
416
|
+
const cleanBase = base === "/" ? "" : base;
|
|
417
|
+
let url = `${apiUrl.replace(/\/+$/, "")}${cleanBase}${endpoint.path}`;
|
|
418
|
+
for (const [key, val] of Object.entries(pathParams)) url = url.replace(`{${key}}`, encodeURIComponent(val));
|
|
419
|
+
const qp = Object.entries(queryParams).filter(([, v]) => v.trim() !== "");
|
|
420
|
+
if (qp.length > 0) url += "?" + qp.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join("&");
|
|
421
|
+
return url;
|
|
422
|
+
}, [
|
|
423
|
+
apiUrl,
|
|
424
|
+
basePath,
|
|
425
|
+
endpoint.path,
|
|
426
|
+
pathParams,
|
|
427
|
+
queryParams
|
|
428
|
+
]);
|
|
429
|
+
const pathParamDefs = endpoint.parameters.filter((p) => p.in === "path");
|
|
430
|
+
const queryParamDefs = endpoint.parameters.filter((p) => p.in === "query");
|
|
431
|
+
const hasBody = [
|
|
432
|
+
"post",
|
|
433
|
+
"put",
|
|
434
|
+
"patch"
|
|
435
|
+
].includes(endpoint.method);
|
|
436
|
+
const execute = useCallback(async () => {
|
|
437
|
+
setValidationError(null);
|
|
438
|
+
if (hasBody && body.trim()) try {
|
|
439
|
+
JSON.parse(body);
|
|
440
|
+
} catch (err) {
|
|
441
|
+
setValidationError(`Invalid JSON: ${err instanceof Error ? err.message : String(err)}`);
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
setLoading(true);
|
|
445
|
+
setResponse(null);
|
|
446
|
+
const start = performance.now();
|
|
447
|
+
try {
|
|
448
|
+
const headers = { "Content-Type": "application/json" };
|
|
449
|
+
for (const h of customHeaders) if (h.key.trim()) headers[h.key.trim()] = h.value;
|
|
450
|
+
if (authMode === "jwt") {
|
|
451
|
+
const token = await getAuthToken();
|
|
452
|
+
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
453
|
+
if (selectedUser && selectedUser.uid !== currentUser?.uid) headers["x-rebase-impersonate"] = selectedUser.uid;
|
|
454
|
+
}
|
|
455
|
+
const res = await fetch(resolvedUrl, {
|
|
456
|
+
method: endpoint.method.toUpperCase(),
|
|
457
|
+
headers,
|
|
458
|
+
body: hasBody && body.trim() ? body : void 0
|
|
459
|
+
});
|
|
460
|
+
const elapsed = Math.round(performance.now() - start);
|
|
461
|
+
let text;
|
|
462
|
+
const rawText = await res.text();
|
|
463
|
+
try {
|
|
464
|
+
const json = JSON.parse(rawText);
|
|
465
|
+
text = JSON.stringify(json, null, 2);
|
|
466
|
+
} catch {
|
|
467
|
+
text = rawText;
|
|
468
|
+
}
|
|
469
|
+
setResponse({
|
|
470
|
+
status: res.status,
|
|
471
|
+
statusText: res.statusText,
|
|
472
|
+
body: text,
|
|
473
|
+
time: elapsed
|
|
474
|
+
});
|
|
475
|
+
} catch (err) {
|
|
476
|
+
setResponse({
|
|
477
|
+
status: 0,
|
|
478
|
+
statusText: "Network Error",
|
|
479
|
+
body: err instanceof Error ? err.message : "Request failed",
|
|
480
|
+
time: Math.round(performance.now() - start)
|
|
481
|
+
});
|
|
482
|
+
} finally {
|
|
483
|
+
setLoading(false);
|
|
484
|
+
}
|
|
485
|
+
}, [
|
|
486
|
+
resolvedUrl,
|
|
487
|
+
endpoint.method,
|
|
488
|
+
hasBody,
|
|
489
|
+
body,
|
|
490
|
+
authMode,
|
|
491
|
+
getAuthToken,
|
|
492
|
+
customHeaders,
|
|
493
|
+
selectedUser,
|
|
494
|
+
currentUser?.uid
|
|
495
|
+
]);
|
|
496
|
+
return /* @__PURE__ */ jsx("div", {
|
|
497
|
+
className: "flex flex-col h-full",
|
|
498
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
499
|
+
className: "p-5 space-y-5 overflow-y-auto flex-1",
|
|
500
|
+
children: [
|
|
501
|
+
/* @__PURE__ */ jsx(AuthSimulationSelector, {
|
|
502
|
+
authMode,
|
|
503
|
+
setAuthMode,
|
|
504
|
+
selectedUser,
|
|
505
|
+
setSelectedUser,
|
|
506
|
+
users,
|
|
507
|
+
loading: false,
|
|
508
|
+
currentUser: currentSelectableUser
|
|
509
|
+
}),
|
|
510
|
+
pathParamDefs.length > 0 && /* @__PURE__ */ jsx(ParamSection, {
|
|
511
|
+
title: "Path Parameters",
|
|
512
|
+
params: pathParamDefs,
|
|
513
|
+
values: pathParams,
|
|
514
|
+
onChange: (k, v) => setPathParams((prev) => ({
|
|
515
|
+
...prev,
|
|
516
|
+
[k]: v
|
|
517
|
+
}))
|
|
518
|
+
}),
|
|
519
|
+
queryParamDefs.length > 0 && /* @__PURE__ */ jsx(ParamSection, {
|
|
520
|
+
title: "Query Parameters",
|
|
521
|
+
params: queryParamDefs,
|
|
522
|
+
values: queryParams,
|
|
523
|
+
onChange: (k, v) => setQueryParams((prev) => ({
|
|
524
|
+
...prev,
|
|
525
|
+
[k]: v
|
|
526
|
+
}))
|
|
527
|
+
}),
|
|
528
|
+
/* @__PURE__ */ jsx(CustomKeyValueSection, {
|
|
529
|
+
title: "Custom Headers",
|
|
530
|
+
values: customHeaders,
|
|
531
|
+
onChange: (i, k, v) => {
|
|
532
|
+
const next = [...customHeaders];
|
|
533
|
+
next[i] = {
|
|
534
|
+
key: k,
|
|
535
|
+
value: v
|
|
536
|
+
};
|
|
537
|
+
setCustomHeaders(next);
|
|
538
|
+
},
|
|
539
|
+
onAdd: () => setCustomHeaders((prev) => [...prev, {
|
|
540
|
+
key: "",
|
|
541
|
+
value: ""
|
|
542
|
+
}]),
|
|
543
|
+
onRemove: (i) => {
|
|
544
|
+
const next = [...customHeaders];
|
|
545
|
+
next.splice(i, 1);
|
|
546
|
+
setCustomHeaders(next);
|
|
547
|
+
}
|
|
548
|
+
}),
|
|
549
|
+
hasBody && /* @__PURE__ */ jsxs("div", { children: [
|
|
550
|
+
/* @__PURE__ */ jsx(Typography, {
|
|
551
|
+
variant: "caption",
|
|
552
|
+
className: "text-text-secondary dark:text-text-secondary-dark text-xs font-semibold uppercase tracking-wider mb-2 block",
|
|
553
|
+
children: "Request Body"
|
|
554
|
+
}),
|
|
555
|
+
/* @__PURE__ */ jsx(TextField, {
|
|
556
|
+
multiline: true,
|
|
557
|
+
minRows: 10,
|
|
558
|
+
value: body,
|
|
559
|
+
onChange: (e) => {
|
|
560
|
+
setBody(e.target.value);
|
|
561
|
+
setValidationError(null);
|
|
562
|
+
},
|
|
563
|
+
spellCheck: false,
|
|
564
|
+
error: !!validationError,
|
|
565
|
+
className: "w-full",
|
|
566
|
+
inputClassName: "font-mono text-xs p-3 resize-y"
|
|
567
|
+
}),
|
|
568
|
+
validationError && /* @__PURE__ */ jsx(Typography, {
|
|
569
|
+
variant: "caption",
|
|
570
|
+
className: "text-red-500 mt-1 block text-xs",
|
|
571
|
+
children: validationError
|
|
572
|
+
})
|
|
573
|
+
] }),
|
|
574
|
+
/* @__PURE__ */ jsxs("div", {
|
|
575
|
+
className: "rounded-lg bg-surface-100 dark:bg-surface-900 p-3",
|
|
576
|
+
children: [/* @__PURE__ */ jsx(Typography, {
|
|
577
|
+
variant: "caption",
|
|
578
|
+
className: "text-text-secondary dark:text-text-secondary-dark text-[10px] uppercase tracking-wider block mb-1",
|
|
579
|
+
children: "Request URL"
|
|
580
|
+
}), /* @__PURE__ */ jsx("code", {
|
|
581
|
+
className: "text-xs font-mono text-text-primary dark:text-text-primary-dark break-all",
|
|
582
|
+
children: resolvedUrl
|
|
583
|
+
})]
|
|
584
|
+
}),
|
|
585
|
+
/* @__PURE__ */ jsx(Button, {
|
|
586
|
+
variant: "filled",
|
|
587
|
+
onClick: execute,
|
|
588
|
+
disabled: loading,
|
|
589
|
+
className: "w-full",
|
|
590
|
+
children: loading ? /* @__PURE__ */ jsxs("span", {
|
|
591
|
+
className: "flex items-center gap-2",
|
|
592
|
+
children: [/* @__PURE__ */ jsx(LoaderIcon, {
|
|
593
|
+
size: iconSize.small,
|
|
594
|
+
className: "animate-spin"
|
|
595
|
+
}), "Sending…"]
|
|
596
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
597
|
+
className: "flex items-center gap-2",
|
|
598
|
+
children: [/* @__PURE__ */ jsx(SendIcon, { size: iconSize.small }), "Send Request"]
|
|
599
|
+
})
|
|
600
|
+
}),
|
|
601
|
+
response && /* @__PURE__ */ jsxs("div", {
|
|
602
|
+
className: cls("rounded-lg border overflow-hidden", defaultBorderMixin),
|
|
603
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
604
|
+
className: cls("flex items-center justify-between px-4 py-2.5", "bg-surface-50 dark:bg-surface-900/50"),
|
|
605
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
606
|
+
className: "flex items-center gap-3",
|
|
607
|
+
children: [/* @__PURE__ */ jsx(ResponseBadge, { status: response.status }), /* @__PURE__ */ jsx(Typography, {
|
|
608
|
+
variant: "caption",
|
|
609
|
+
className: "text-text-secondary dark:text-text-secondary-dark text-xs",
|
|
610
|
+
children: response.statusText
|
|
611
|
+
})]
|
|
612
|
+
}), /* @__PURE__ */ jsxs(Typography, {
|
|
613
|
+
variant: "caption",
|
|
614
|
+
className: "text-text-secondary dark:text-text-secondary-dark text-xs font-mono",
|
|
615
|
+
children: [response.time, "ms"]
|
|
616
|
+
})]
|
|
617
|
+
}), /* @__PURE__ */ jsx("pre", {
|
|
618
|
+
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"),
|
|
619
|
+
children: response.body
|
|
620
|
+
})]
|
|
621
|
+
})
|
|
622
|
+
]
|
|
623
|
+
})
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
function ParamSection({ title, params, values, onChange }) {
|
|
627
|
+
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
|
|
628
|
+
variant: "caption",
|
|
629
|
+
className: "text-text-secondary dark:text-text-secondary-dark text-xs font-semibold uppercase tracking-wider mb-2 block",
|
|
630
|
+
children: title
|
|
631
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
632
|
+
className: "space-y-2",
|
|
633
|
+
children: params.map((p) => /* @__PURE__ */ jsxs("div", {
|
|
634
|
+
className: "flex items-center gap-3",
|
|
635
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
636
|
+
className: "w-32 shrink-0",
|
|
637
|
+
children: [/* @__PURE__ */ jsx("code", {
|
|
638
|
+
className: "text-xs font-mono font-semibold",
|
|
639
|
+
children: p.name
|
|
640
|
+
}), p.required && /* @__PURE__ */ jsx("span", {
|
|
641
|
+
className: "text-red-500 ml-0.5 text-xs",
|
|
642
|
+
children: "*"
|
|
643
|
+
})]
|
|
644
|
+
}), /* @__PURE__ */ jsx(TextField, {
|
|
645
|
+
size: "small",
|
|
646
|
+
placeholder: p.description ?? p.name,
|
|
647
|
+
value: values[p.name] ?? "",
|
|
648
|
+
onChange: (e) => onChange(p.name, e.target.value),
|
|
649
|
+
className: "flex-1",
|
|
650
|
+
inputClassName: "font-mono text-xs"
|
|
651
|
+
})]
|
|
652
|
+
}, p.name))
|
|
653
|
+
})] });
|
|
654
|
+
}
|
|
655
|
+
function CustomKeyValueSection({ title, values, onChange, onAdd, onRemove }) {
|
|
656
|
+
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
657
|
+
className: "flex items-center justify-between mb-2",
|
|
658
|
+
children: [/* @__PURE__ */ jsx(Typography, {
|
|
659
|
+
variant: "caption",
|
|
660
|
+
className: "text-text-secondary dark:text-text-secondary-dark text-xs font-semibold uppercase tracking-wider block",
|
|
661
|
+
children: title
|
|
662
|
+
}), /* @__PURE__ */ jsxs(Button, {
|
|
663
|
+
variant: "text",
|
|
664
|
+
size: "small",
|
|
665
|
+
color: "primary",
|
|
666
|
+
onClick: onAdd,
|
|
667
|
+
className: "text-xs p-0 min-h-0",
|
|
668
|
+
children: [/* @__PURE__ */ jsx(PlusIcon, {
|
|
669
|
+
size: iconSize.small,
|
|
670
|
+
className: "mr-1"
|
|
671
|
+
}), " Add Header"]
|
|
672
|
+
})]
|
|
673
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
674
|
+
className: "space-y-2",
|
|
675
|
+
children: [values.map((v, i) => /* @__PURE__ */ jsxs("div", {
|
|
676
|
+
className: "flex items-center gap-2",
|
|
677
|
+
children: [
|
|
678
|
+
/* @__PURE__ */ jsx(TextField, {
|
|
679
|
+
size: "small",
|
|
680
|
+
placeholder: "Header name",
|
|
681
|
+
value: v.key,
|
|
682
|
+
onChange: (e) => onChange(i, e.target.value, v.value),
|
|
683
|
+
className: "w-1/3",
|
|
684
|
+
inputClassName: "font-mono text-xs"
|
|
685
|
+
}),
|
|
686
|
+
/* @__PURE__ */ jsx(TextField, {
|
|
687
|
+
size: "small",
|
|
688
|
+
placeholder: "Value",
|
|
689
|
+
value: v.value,
|
|
690
|
+
onChange: (e) => onChange(i, v.key, e.target.value),
|
|
691
|
+
className: "flex-1",
|
|
692
|
+
inputClassName: "font-mono text-xs"
|
|
693
|
+
}),
|
|
694
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
695
|
+
size: "small",
|
|
696
|
+
onClick: () => onRemove(i),
|
|
697
|
+
className: "text-text-secondary hover:text-red-500 shrink-0",
|
|
698
|
+
title: "Remove",
|
|
699
|
+
children: /* @__PURE__ */ jsx(XIcon, { size: iconSize.small })
|
|
700
|
+
})
|
|
701
|
+
]
|
|
702
|
+
}, i)), values.length === 0 && /* @__PURE__ */ jsx(Typography, {
|
|
703
|
+
variant: "caption",
|
|
704
|
+
className: "text-text-secondary/50 italic text-xs",
|
|
705
|
+
children: "No custom headers added."
|
|
706
|
+
})]
|
|
707
|
+
})] });
|
|
708
|
+
}
|
|
709
|
+
function ResponseBadge({ status }) {
|
|
710
|
+
let colorClass = "text-red-500";
|
|
711
|
+
if (status >= 200 && status < 300) colorClass = "text-emerald-500";
|
|
712
|
+
else if (status >= 300 && status < 400) colorClass = "text-blue-500";
|
|
713
|
+
else if (status >= 400 && status < 500) colorClass = "text-amber-500";
|
|
714
|
+
return /* @__PURE__ */ jsx("span", {
|
|
715
|
+
className: cls("text-xs font-bold font-mono", colorClass),
|
|
716
|
+
children: status || "ERR"
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
function buildBodyTemplate(endpoint) {
|
|
720
|
+
if (!endpoint.requestBody?.content) return "{\n \n}";
|
|
721
|
+
const json = endpoint.requestBody.content["application/json"];
|
|
722
|
+
if (!json?.schema?.properties) return "{\n \n}";
|
|
723
|
+
const props = json.schema.properties;
|
|
724
|
+
const lines = ["{"];
|
|
725
|
+
const keys = Object.keys(props);
|
|
726
|
+
keys.forEach((key, i) => {
|
|
727
|
+
const prop = props[key];
|
|
728
|
+
if (prop.readOnly) return;
|
|
729
|
+
const comma = i < keys.length - 1 ? "," : "";
|
|
730
|
+
const val = defaultValue(prop);
|
|
731
|
+
lines.push(` "${key}": ${val}${comma}`);
|
|
732
|
+
});
|
|
733
|
+
lines.push("}");
|
|
734
|
+
return lines.join("\n");
|
|
735
|
+
}
|
|
736
|
+
function defaultValue(schema) {
|
|
737
|
+
if (schema.enum) return JSON.stringify(schema.enum[0]);
|
|
738
|
+
switch (schema.type) {
|
|
739
|
+
case "string": return schema.format === "date-time" ? `"${(/* @__PURE__ */ new Date()).toISOString()}"` : "\"\"";
|
|
740
|
+
case "number":
|
|
741
|
+
case "integer": return "0";
|
|
742
|
+
case "boolean": return "false";
|
|
743
|
+
case "array": return "[]";
|
|
744
|
+
default: return "null";
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
//#endregion
|
|
748
|
+
//#region src/components/ApiExplorer/ApiExplorer.tsx
|
|
749
|
+
/**
|
|
750
|
+
* Custom-built API Explorer for Rebase Studio.
|
|
751
|
+
* No external dependencies — renders the OpenAPI spec natively
|
|
752
|
+
* with deep integration into the Rebase auth system.
|
|
753
|
+
*/
|
|
754
|
+
function ApiExplorer() {
|
|
755
|
+
const apiConfig = useApiConfig();
|
|
756
|
+
const authController = useAuthController();
|
|
757
|
+
const apiUrl = apiConfig?.apiUrl;
|
|
758
|
+
const [spec, setSpec] = useState(null);
|
|
759
|
+
const [loading, setLoading] = useState(true);
|
|
760
|
+
const [error, setError] = useState(null);
|
|
761
|
+
const [selectedEndpoint, setSelectedEndpoint] = useState(null);
|
|
762
|
+
const [sidebarFilter, setSidebarFilter] = useState("");
|
|
763
|
+
const [tryItOpen, setTryItOpen] = useState(false);
|
|
764
|
+
useEffect(() => {
|
|
765
|
+
if (!apiUrl) return;
|
|
766
|
+
let cancelled = false;
|
|
767
|
+
const specUrl = `${apiUrl.replace(/\/+$/, "")}/api/docs`;
|
|
768
|
+
(async () => {
|
|
769
|
+
try {
|
|
770
|
+
const res = await fetch(specUrl);
|
|
771
|
+
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
|
|
772
|
+
const data = await res.json();
|
|
773
|
+
if (!cancelled) {
|
|
774
|
+
setSpec(data);
|
|
775
|
+
setLoading(false);
|
|
776
|
+
}
|
|
777
|
+
} catch (err) {
|
|
778
|
+
if (!cancelled) {
|
|
779
|
+
setError(err instanceof Error ? err.message : "Failed to load API spec");
|
|
780
|
+
setLoading(false);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
})();
|
|
784
|
+
return () => {
|
|
785
|
+
cancelled = true;
|
|
786
|
+
};
|
|
787
|
+
}, [apiUrl]);
|
|
788
|
+
const { groups, allEndpoints } = useMemo(() => {
|
|
789
|
+
if (!spec) return {
|
|
790
|
+
groups: [],
|
|
791
|
+
allEndpoints: []
|
|
792
|
+
};
|
|
793
|
+
return parseOpenApiSpec(spec);
|
|
794
|
+
}, [spec]);
|
|
795
|
+
const filteredGroups = useMemo(() => {
|
|
796
|
+
if (!sidebarFilter.trim()) return groups;
|
|
797
|
+
const q = sidebarFilter.toLowerCase();
|
|
798
|
+
return groups.map((g) => ({
|
|
799
|
+
...g,
|
|
800
|
+
endpoints: g.endpoints.filter((e) => e.path.toLowerCase().includes(q) || e.summary.toLowerCase().includes(q) || e.method.toLowerCase().includes(q))
|
|
801
|
+
})).filter((g) => g.endpoints.length > 0);
|
|
802
|
+
}, [groups, sidebarFilter]);
|
|
803
|
+
useEffect(() => {
|
|
804
|
+
if (!selectedEndpoint && allEndpoints.length > 0) setSelectedEndpoint(allEndpoints[0]);
|
|
805
|
+
}, [allEndpoints, selectedEndpoint]);
|
|
806
|
+
if (!apiUrl) return /* @__PURE__ */ jsx("div", {
|
|
807
|
+
className: "flex items-center justify-center h-full w-full p-8",
|
|
808
|
+
children: /* @__PURE__ */ jsx(Alert, {
|
|
809
|
+
color: "warning",
|
|
810
|
+
children: /* @__PURE__ */ jsxs(Typography, {
|
|
811
|
+
variant: "body2",
|
|
812
|
+
children: [
|
|
813
|
+
"No API URL configured. Ensure your app provides an",
|
|
814
|
+
" ",
|
|
815
|
+
/* @__PURE__ */ jsx("code", {
|
|
816
|
+
className: "font-mono text-xs",
|
|
817
|
+
children: "apiUrl"
|
|
818
|
+
}),
|
|
819
|
+
"."
|
|
820
|
+
]
|
|
821
|
+
})
|
|
822
|
+
})
|
|
823
|
+
});
|
|
824
|
+
if (loading) return /* @__PURE__ */ jsxs("div", {
|
|
825
|
+
className: "flex flex-col items-center justify-center h-full w-full gap-4",
|
|
826
|
+
children: [/* @__PURE__ */ jsx(CircularProgress, { size: "medium" }), /* @__PURE__ */ jsx(Typography, {
|
|
827
|
+
variant: "body2",
|
|
828
|
+
className: "text-text-secondary dark:text-text-secondary-dark animate-pulse",
|
|
829
|
+
children: "Loading API specification…"
|
|
830
|
+
})]
|
|
831
|
+
});
|
|
832
|
+
if (error || !spec) return /* @__PURE__ */ jsx("div", {
|
|
833
|
+
className: "flex items-center justify-center h-full w-full p-8",
|
|
834
|
+
children: /* @__PURE__ */ jsx(Alert, {
|
|
835
|
+
color: "error",
|
|
836
|
+
children: /* @__PURE__ */ jsx(Typography, {
|
|
837
|
+
variant: "body2",
|
|
838
|
+
children: error ?? "Unknown error"
|
|
839
|
+
})
|
|
840
|
+
})
|
|
841
|
+
});
|
|
842
|
+
const METHOD_COLORS = {
|
|
843
|
+
get: "text-blue-600 dark:text-blue-400",
|
|
844
|
+
post: "text-emerald-600 dark:text-emerald-400",
|
|
845
|
+
put: "text-amber-600 dark:text-amber-400",
|
|
846
|
+
patch: "text-orange-600 dark:text-orange-400",
|
|
847
|
+
delete: "text-red-600 dark:text-red-400"
|
|
848
|
+
};
|
|
849
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
850
|
+
className: "flex h-full w-full overflow-hidden",
|
|
851
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
852
|
+
className: cls("w-72 min-w-[272px] flex flex-col h-full overflow-hidden border-r", defaultBorderMixin, "bg-surface-50 dark:bg-surface-900"),
|
|
853
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
854
|
+
className: "p-4 space-y-3",
|
|
855
|
+
children: [
|
|
856
|
+
/* @__PURE__ */ jsxs("div", {
|
|
857
|
+
className: "flex items-center gap-2",
|
|
858
|
+
children: [/* @__PURE__ */ jsx(BookOpenIcon, {
|
|
859
|
+
size: iconSize.medium,
|
|
860
|
+
className: "text-primary dark:text-primary-dark"
|
|
861
|
+
}), /* @__PURE__ */ jsx(Typography, {
|
|
862
|
+
variant: "subtitle2",
|
|
863
|
+
className: "font-semibold",
|
|
864
|
+
children: spec.info?.title ?? "API Reference"
|
|
865
|
+
})]
|
|
866
|
+
}),
|
|
867
|
+
spec.info?.version && /* @__PURE__ */ jsxs(Chip, {
|
|
868
|
+
size: "smallest",
|
|
869
|
+
colorScheme: "cyanDarker",
|
|
870
|
+
children: ["v", spec.info.version]
|
|
871
|
+
}),
|
|
872
|
+
/* @__PURE__ */ jsx("div", {
|
|
873
|
+
className: "mb-2",
|
|
874
|
+
children: /* @__PURE__ */ jsx(SearchBar, {
|
|
875
|
+
placeholder: "Filter endpoints…",
|
|
876
|
+
size: "small",
|
|
877
|
+
onTextSearch: (val) => setSidebarFilter(val ?? "")
|
|
878
|
+
})
|
|
879
|
+
})
|
|
880
|
+
]
|
|
881
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
882
|
+
className: "flex-1 overflow-y-auto px-2 pb-4",
|
|
883
|
+
children: [filteredGroups.map((group) => /* @__PURE__ */ jsxs("div", {
|
|
884
|
+
className: "mb-3",
|
|
885
|
+
children: [/* @__PURE__ */ jsx(Typography, {
|
|
886
|
+
variant: "caption",
|
|
887
|
+
className: "px-2 py-1.5 text-text-secondary dark:text-text-secondary-dark uppercase tracking-wider font-semibold text-[10px]",
|
|
888
|
+
children: group.tag
|
|
889
|
+
}), group.endpoints.map((ep) => {
|
|
890
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
891
|
+
variant: "text",
|
|
892
|
+
color: "neutral",
|
|
893
|
+
fullWidth: true,
|
|
894
|
+
onClick: () => {
|
|
895
|
+
setSelectedEndpoint(ep);
|
|
896
|
+
setTryItOpen(false);
|
|
897
|
+
},
|
|
898
|
+
className: cls("!justify-between !px-2.5 !py-1.5 !text-left !text-sm", selectedEndpoint?.id === ep.id ? "bg-surface-200 dark:bg-surface-800 font-medium" : "text-text-primary dark:text-text-primary-dark"),
|
|
899
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
900
|
+
className: "truncate text-[13px] opacity-90",
|
|
901
|
+
children: ep.summary || ep.shortPath
|
|
902
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
903
|
+
className: cls("text-[10px] font-bold uppercase shrink-0", METHOD_COLORS[ep.method] ?? "text-text-secondary"),
|
|
904
|
+
children: ep.method
|
|
905
|
+
})]
|
|
906
|
+
}, ep.id);
|
|
907
|
+
})]
|
|
908
|
+
}, group.tag)), filteredGroups.length === 0 && /* @__PURE__ */ jsx(Typography, {
|
|
909
|
+
variant: "body2",
|
|
910
|
+
className: "text-center text-text-secondary dark:text-text-secondary-dark py-8",
|
|
911
|
+
children: "No endpoints match"
|
|
912
|
+
})]
|
|
913
|
+
})]
|
|
914
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
915
|
+
className: "flex-1 flex flex-col h-full overflow-hidden",
|
|
916
|
+
children: selectedEndpoint ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
917
|
+
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"),
|
|
918
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
919
|
+
className: "flex items-center gap-3 min-w-0",
|
|
920
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
921
|
+
className: cls("text-xs font-bold uppercase", METHOD_COLORS[selectedEndpoint.method] ?? ""),
|
|
922
|
+
children: selectedEndpoint.method
|
|
923
|
+
}), /* @__PURE__ */ jsx("code", {
|
|
924
|
+
className: "text-sm font-mono text-text-primary dark:text-text-primary-dark truncate",
|
|
925
|
+
children: selectedEndpoint.path
|
|
926
|
+
})]
|
|
927
|
+
}), /* @__PURE__ */ jsxs(Button, {
|
|
928
|
+
variant: tryItOpen ? "filled" : "outlined",
|
|
929
|
+
size: "small",
|
|
930
|
+
onClick: () => setTryItOpen((v) => !v),
|
|
931
|
+
children: [/* @__PURE__ */ jsx(PlayIcon, {
|
|
932
|
+
size: iconSize.small,
|
|
933
|
+
className: "mr-1"
|
|
934
|
+
}), "Try It"]
|
|
935
|
+
})]
|
|
936
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
937
|
+
className: "flex-1 overflow-y-auto",
|
|
938
|
+
children: tryItOpen ? /* @__PURE__ */ jsx(TryItPanel, {
|
|
939
|
+
endpoint: selectedEndpoint,
|
|
940
|
+
apiUrl,
|
|
941
|
+
getAuthToken: apiConfig?.getAuthToken ?? authController.getAuthToken,
|
|
942
|
+
user: authController.user,
|
|
943
|
+
basePath: spec?.servers?.[0]?.url || ""
|
|
944
|
+
}, selectedEndpoint.operationId || selectedEndpoint.path) : /* @__PURE__ */ jsx(EndpointDetail, {
|
|
945
|
+
endpoint: selectedEndpoint,
|
|
946
|
+
spec
|
|
947
|
+
})
|
|
948
|
+
})] }) : /* @__PURE__ */ jsx("div", {
|
|
949
|
+
className: "flex items-center justify-center h-full",
|
|
950
|
+
children: /* @__PURE__ */ jsx(Typography, {
|
|
951
|
+
variant: "body2",
|
|
952
|
+
className: "text-text-secondary dark:text-text-secondary-dark",
|
|
953
|
+
children: "Select an endpoint from the sidebar"
|
|
954
|
+
})
|
|
955
|
+
})
|
|
956
|
+
})]
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
ApiExplorer.displayName = "ApiExplorer";
|
|
960
|
+
//#endregion
|
|
961
|
+
export { ApiExplorer };
|
|
962
|
+
|
|
963
|
+
//# sourceMappingURL=ApiExplorer-CdIwR9Ga.js.map
|