@object-ui/app-shell 6.2.3 → 7.1.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/CHANGELOG.md +1229 -0
- package/README.md +292 -0
- package/dist/assistant/assistantBus.d.ts +72 -0
- package/dist/assistant/assistantBus.js +133 -0
- package/dist/chrome/CommandPalette.d.ts +1 -1
- package/dist/chrome/CommandPalette.js +26 -22
- package/dist/chrome/ConditionalAuthWrapper.d.ts +1 -1
- package/dist/chrome/ConsoleToaster.d.ts +1 -1
- package/dist/chrome/ConsoleToaster.js +3 -1
- package/dist/chrome/ErrorBoundary.d.ts +1 -1
- package/dist/chrome/KeyboardShortcutsDialog.d.ts +1 -1
- package/dist/chrome/KeyboardShortcutsDialog.js +16 -5
- package/dist/chrome/LoadingScreen.d.ts +1 -1
- package/dist/chrome/LoadingScreen.js +22 -26
- package/dist/chrome/RouteFader.d.ts +1 -1
- package/dist/chrome/ThemeProvider.d.ts +1 -1
- package/dist/components/ManagedByBadge.d.ts +1 -1
- package/dist/console/AppContent.d.ts +1 -1
- package/dist/console/AppContent.js +184 -39
- package/dist/console/ConsoleShell.d.ts +7 -7
- package/dist/console/ConsoleShell.js +32 -3
- package/dist/console/ai/AiChatPage.d.ts +88 -1
- package/dist/console/ai/AiChatPage.js +747 -66
- package/dist/console/ai/ConversationsSidebar.d.ts +26 -1
- package/dist/console/ai/ConversationsSidebar.js +149 -34
- package/dist/console/ai/LiveCanvas.d.ts +28 -0
- package/dist/console/ai/LiveCanvas.js +80 -0
- package/dist/console/ai/reconcileTurn.d.ts +8 -0
- package/dist/console/ai/reconcileTurn.js +20 -0
- package/dist/console/auth/AuthPageLayout.d.ts +1 -1
- package/dist/console/auth/ForgotPasswordPage.d.ts +1 -1
- package/dist/console/auth/LoginPage.d.ts +1 -1
- package/dist/console/auth/RegisterPage.d.ts +1 -1
- package/dist/console/auth/RegisterPage.js +23 -3
- package/dist/console/cloud-connection/CloudConnectionPanel.d.ts +1 -0
- package/dist/console/cloud-connection/CloudConnectionPanel.js +169 -0
- package/dist/console/home/AppCard.d.ts +1 -1
- package/dist/console/home/AppCard.js +6 -12
- package/dist/console/home/HomeAppsStrip.d.ts +8 -0
- package/dist/console/home/HomeAppsStrip.js +61 -0
- package/dist/console/home/HomeLayout.d.ts +1 -1
- package/dist/console/home/HomeLayout.js +3 -1
- package/dist/console/home/HomePage.d.ts +1 -2
- package/dist/console/home/HomePage.js +149 -21
- package/dist/console/home/HomeRail.d.ts +22 -0
- package/dist/console/home/HomeRail.js +62 -0
- package/dist/console/home/QuickActions.d.ts +1 -1
- package/dist/console/home/QuickActions.js +3 -11
- package/dist/console/home/RecentApps.d.ts +1 -1
- package/dist/console/home/RecentApps.js +2 -2
- package/dist/console/home/StarredApps.d.ts +1 -1
- package/dist/console/home/StarredApps.js +2 -2
- package/dist/console/marketplace/InstalledListWidget.d.ts +1 -0
- package/dist/console/marketplace/InstalledListWidget.js +93 -0
- package/dist/console/marketplace/MarkdownText.d.ts +1 -1
- package/dist/console/marketplace/MarketplaceAccessDenied.d.ts +1 -1
- package/dist/console/marketplace/MarketplaceInstalledPage.d.ts +8 -14
- package/dist/console/marketplace/MarketplaceInstalledPage.js +14 -66
- package/dist/console/marketplace/MarketplacePackagePage.d.ts +1 -1
- package/dist/console/marketplace/MarketplacePackagePage.js +249 -8
- package/dist/console/marketplace/MarketplacePage.d.ts +1 -1
- package/dist/console/marketplace/MarketplacePage.js +60 -3
- package/dist/console/marketplace/PackageIcon.d.ts +1 -1
- package/dist/console/marketplace/PluginDisclosure.d.ts +14 -0
- package/dist/console/marketplace/PluginDisclosure.js +38 -0
- package/dist/console/marketplace/marketplaceApi.d.ts +123 -0
- package/dist/console/marketplace/marketplaceApi.js +254 -1
- package/dist/console/organizations/CreateWorkspaceDialog.d.ts +1 -1
- package/dist/console/organizations/OrganizationsLayout.d.ts +1 -1
- package/dist/console/organizations/OrganizationsPage.d.ts +1 -1
- package/dist/console/organizations/manage/AcceptInvitationPage.d.ts +1 -1
- package/dist/console/organizations/manage/InvitationsPage.d.ts +1 -1
- package/dist/console/organizations/manage/InviteMemberDialog.d.ts +1 -1
- package/dist/console/organizations/manage/MembersPage.d.ts +1 -1
- package/dist/console/organizations/manage/OrganizationLayout.d.ts +1 -1
- package/dist/console/organizations/manage/SettingsPage.d.ts +1 -1
- package/dist/context/CommandPaletteProvider.d.ts +44 -0
- package/dist/context/CommandPaletteProvider.js +71 -0
- package/dist/context/FavoritesProvider.d.ts +1 -1
- package/dist/context/NavigationContext.d.ts +1 -1
- package/dist/context/RecentItemsProvider.d.ts +2 -2
- package/dist/context/UserStateAdapters.d.ts +1 -1
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.js +1 -0
- package/dist/hooks/index.d.ts +5 -2
- package/dist/hooks/index.js +4 -1
- package/dist/hooks/useActionModal.d.ts +53 -0
- package/dist/hooks/useActionModal.js +111 -0
- package/dist/hooks/useChatConversation.d.ts +137 -4
- package/dist/hooks/useChatConversation.js +316 -25
- package/dist/hooks/useConsoleActionRuntime.d.ts +70 -0
- package/dist/hooks/useConsoleActionRuntime.js +564 -0
- package/dist/hooks/useConversationList.js +61 -3
- package/dist/hooks/useHomeInbox.d.ts +13 -0
- package/dist/hooks/useHomeInbox.js +142 -0
- package/dist/hooks/useNavPins.js +17 -23
- package/dist/hooks/useNavigationSync.d.ts +33 -0
- package/dist/hooks/useNavigationSync.js +98 -12
- package/dist/hooks/useReconcileOnError.d.ts +40 -0
- package/dist/hooks/useReconcileOnError.js +37 -0
- package/dist/hooks/useRecordApprovals.d.ts +18 -19
- package/dist/hooks/useRecordApprovals.js +24 -40
- package/dist/hooks/useResponsiveSidebar.js +14 -5
- package/dist/hooks/useSettleSignal.d.ts +19 -0
- package/dist/hooks/useSettleSignal.js +20 -0
- package/dist/hooks/useTrackRouteAsRecent.js +35 -0
- package/dist/hooks/useUrlOverlay.d.ts +62 -0
- package/dist/hooks/useUrlOverlay.js +88 -0
- package/dist/index.d.ts +18 -8
- package/dist/index.js +17 -5
- package/dist/layout/ActivityFeed.d.ts +1 -1
- package/dist/layout/AppHeader.d.ts +3 -2
- package/dist/layout/AppHeader.js +237 -72
- package/dist/layout/AppSidebar.d.ts +2 -1
- package/dist/layout/AppSidebar.js +26 -46
- package/dist/layout/AppSwitcher.d.ts +2 -1
- package/dist/layout/AppSwitcher.js +9 -5
- package/dist/layout/AuthPageLayout.d.ts +1 -1
- package/dist/layout/ConnectionStatus.d.ts +1 -1
- package/dist/layout/ConnectionStatus.js +9 -6
- package/dist/layout/ConsoleChatbotFab.d.ts +19 -1
- package/dist/layout/ConsoleChatbotFab.js +16 -2
- package/dist/layout/ConsoleFloatingChatbot.d.ts +34 -2
- package/dist/layout/ConsoleFloatingChatbot.js +391 -41
- package/dist/layout/ConsoleLayout.d.ts +1 -1
- package/dist/layout/ConsoleLayout.js +27 -11
- package/dist/layout/ContextSelectors.d.ts +44 -0
- package/dist/layout/ContextSelectors.js +242 -0
- package/dist/layout/InboxPopover.d.ts +6 -1
- package/dist/layout/InboxPopover.js +25 -6
- package/dist/layout/LocaleSwitcher.d.ts +1 -1
- package/dist/layout/LocalizedSidebarTrigger.d.ts +2 -0
- package/dist/layout/LocalizedSidebarTrigger.js +15 -0
- package/dist/layout/MobileViewSwitcherContext.d.ts +1 -1
- package/dist/layout/ModeToggle.d.ts +1 -1
- package/dist/layout/PageHeader.d.ts +1 -1
- package/dist/layout/UnifiedSidebar.d.ts +2 -1
- package/dist/layout/UnifiedSidebar.js +116 -15
- package/dist/layout/agentPicker.d.ts +56 -0
- package/dist/layout/agentPicker.js +40 -0
- package/dist/observability/index.d.ts +1 -0
- package/dist/observability/index.js +1 -0
- package/dist/observability/settleSignal.d.ts +64 -0
- package/dist/observability/settleSignal.js +131 -0
- package/dist/preview/CommitTimeline.d.ts +15 -0
- package/dist/preview/CommitTimeline.js +82 -0
- package/dist/preview/DraftChangesPanel.d.ts +19 -0
- package/dist/preview/DraftChangesPanel.js +114 -0
- package/dist/preview/DraftPreviewBar.d.ts +8 -0
- package/dist/preview/DraftPreviewBar.js +86 -0
- package/dist/preview/PreviewDraftEmptyState.d.ts +16 -0
- package/dist/preview/PreviewDraftEmptyState.js +47 -0
- package/dist/preview/PreviewModeContext.d.ts +57 -0
- package/dist/preview/PreviewModeContext.js +99 -0
- package/dist/preview/UnpublishedAppBar.d.ts +8 -0
- package/dist/preview/UnpublishedAppBar.js +83 -0
- package/dist/preview/commitHistory.d.ts +28 -0
- package/dist/preview/commitHistory.js +48 -0
- package/dist/preview/draftStatus.d.ts +20 -0
- package/dist/preview/draftStatus.js +27 -0
- package/dist/preview/usePublishAllDrafts.d.ts +18 -0
- package/dist/preview/usePublishAllDrafts.js +106 -0
- package/dist/providers/AdapterProvider.d.ts +1 -1
- package/dist/providers/AdapterProvider.js +6 -1
- package/dist/providers/ExpressionProvider.d.ts +1 -1
- package/dist/providers/MetadataProvider.d.ts +17 -2
- package/dist/providers/MetadataProvider.js +192 -12
- package/dist/runtime-config.d.ts +46 -2
- package/dist/runtime-config.js +39 -2
- package/dist/services/builtinComponents.js +68 -59
- package/dist/skeletons/SkeletonDashboard.d.ts +1 -1
- package/dist/skeletons/SkeletonDetail.d.ts +1 -1
- package/dist/skeletons/SkeletonGrid.d.ts +1 -1
- package/dist/utils/appRoute.d.ts +21 -0
- package/dist/utils/appRoute.js +25 -0
- package/dist/utils/deriveRelatedLists.d.ts +54 -0
- package/dist/utils/deriveRelatedLists.js +91 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/managedByEmptyState.d.ts +8 -1
- package/dist/utils/managedByEmptyState.js +13 -7
- package/dist/utils/preferLocal.d.ts +18 -0
- package/dist/utils/preferLocal.js +24 -0
- package/dist/views/ActionConfirmDialog.d.ts +1 -1
- package/dist/views/ActionConfirmDialog.js +3 -1
- package/dist/views/ActionParamDialog.d.ts +6 -1
- package/dist/views/ActionParamDialog.js +9 -3
- package/dist/views/ActionResultDialog.d.ts +13 -0
- package/dist/views/ActionResultDialog.js +134 -0
- package/dist/views/ComponentNavView.d.ts +14 -1
- package/dist/views/CreateViewDialog.d.ts +1 -1
- package/dist/views/DashboardConfigPanel.d.ts +28 -0
- package/dist/views/DashboardConfigPanel.js +81 -0
- package/dist/views/DashboardView.d.ts +4 -3
- package/dist/views/DashboardView.js +38 -239
- package/dist/views/FlowRunner.d.ts +31 -0
- package/dist/views/FlowRunner.js +121 -0
- package/dist/views/InterfaceListPage.d.ts +49 -0
- package/dist/views/InterfaceListPage.js +347 -0
- package/dist/views/MetadataInspector.d.ts +2 -2
- package/dist/views/ObjectView.d.ts +1 -1
- package/dist/views/ObjectView.js +209 -532
- package/dist/views/PageView.d.ts +8 -3
- package/dist/views/PageView.js +45 -32
- package/dist/views/RecordDetailView.d.ts +1 -1
- package/dist/views/RecordDetailView.js +363 -148
- package/dist/views/RecordFormPage.d.ts +1 -1
- package/dist/views/RecordFormPage.js +26 -1
- package/dist/views/ReportConfigPanel.d.ts +37 -0
- package/dist/views/ReportConfigPanel.js +85 -0
- package/dist/views/ReportView.d.ts +1 -1
- package/dist/views/ReportView.js +116 -7
- package/dist/views/RuntimeDraftBar.d.ts +30 -0
- package/dist/views/RuntimeDraftBar.js +112 -0
- package/dist/views/ScreenView.d.ts +70 -0
- package/dist/views/ScreenView.js +73 -0
- package/dist/views/SearchResultsPage.d.ts +1 -1
- package/dist/views/SearchResultsPage.js +8 -18
- package/dist/views/ViewConfigPanel.d.ts +24 -17
- package/dist/views/ViewConfigPanel.js +121 -77
- package/dist/views/index.d.ts +1 -1
- package/dist/views/index.js +1 -1
- package/dist/views/metadata-admin/AuditPanel.d.ts +28 -0
- package/dist/views/metadata-admin/AuditPanel.js +79 -0
- package/dist/views/metadata-admin/DiagnosticsPage.d.ts +20 -0
- package/dist/views/metadata-admin/DiagnosticsPage.js +69 -0
- package/dist/views/metadata-admin/DirectoryPage.d.ts +16 -1
- package/dist/views/metadata-admin/DirectoryPage.js +101 -24
- package/dist/views/metadata-admin/DraftReviewPanel.d.ts +33 -0
- package/dist/views/metadata-admin/DraftReviewPanel.js +77 -0
- package/dist/views/metadata-admin/EmbeddedItemEditor.d.ts +17 -1
- package/dist/views/metadata-admin/EmbeddedItemEditor.js +15 -8
- package/dist/views/metadata-admin/JsonSourceEditor.d.ts +39 -0
- package/dist/views/metadata-admin/JsonSourceEditor.js +196 -0
- package/dist/views/metadata-admin/LayeredDiff.d.ts +39 -1
- package/dist/views/metadata-admin/LayeredDiff.js +171 -5
- package/dist/views/metadata-admin/MetadataDetailDrawer.d.ts +15 -1
- package/dist/views/metadata-admin/MetadataTypeActions.d.ts +48 -0
- package/dist/views/metadata-admin/MetadataTypeActions.js +165 -0
- package/dist/views/metadata-admin/PackagesPage.d.ts +18 -0
- package/dist/views/metadata-admin/PackagesPage.js +403 -0
- package/dist/views/metadata-admin/PageShell.d.ts +1 -1
- package/dist/views/metadata-admin/PageShell.js +9 -4
- package/dist/views/metadata-admin/PermissionMatrixEditor.d.ts +35 -1
- package/dist/views/metadata-admin/QuickFind.d.ts +21 -1
- package/dist/views/metadata-admin/QuickFind.js +6 -3
- package/dist/views/metadata-admin/RelatedPanel.d.ts +24 -1
- package/dist/views/metadata-admin/RelatedPanel.js +20 -18
- package/dist/views/metadata-admin/ResourceEditPage.d.ts +40 -1
- package/dist/views/metadata-admin/ResourceEditPage.js +1250 -60
- package/dist/views/metadata-admin/ResourceHistoryPage.d.ts +39 -1
- package/dist/views/metadata-admin/ResourceHistoryPage.js +66 -16
- package/dist/views/metadata-admin/ResourceListPage.d.ts +13 -1
- package/dist/views/metadata-admin/ResourceListPage.js +258 -30
- package/dist/views/metadata-admin/ResourceRouter.d.ts +23 -1
- package/dist/views/metadata-admin/SchemaForm.d.ts +34 -1
- package/dist/views/metadata-admin/SchemaForm.js +559 -49
- package/dist/views/metadata-admin/StudioHomePage.d.ts +22 -0
- package/dist/views/metadata-admin/StudioHomePage.js +205 -0
- package/dist/views/metadata-admin/anchors.js +255 -24
- package/dist/views/metadata-admin/clientValidation.d.ts +50 -0
- package/dist/views/metadata-admin/clientValidation.js +169 -0
- package/dist/views/metadata-admin/color-variant-field.d.ts +30 -0
- package/dist/views/metadata-admin/color-variant-field.js +38 -0
- package/dist/views/metadata-admin/createDerive.d.ts +75 -0
- package/dist/views/metadata-admin/createDerive.js +179 -0
- package/dist/views/metadata-admin/dashboard-schema.d.ts +12 -0
- package/dist/views/metadata-admin/dashboard-schema.js +80 -0
- package/dist/views/metadata-admin/datasource/DatasourceResourcePage.d.ts +35 -0
- package/dist/views/metadata-admin/datasource/DatasourceResourcePage.js +327 -0
- package/dist/views/metadata-admin/datasource/register.d.ts +1 -0
- package/dist/views/metadata-admin/datasource/register.js +24 -0
- package/dist/views/metadata-admin/default-inspector-registry.d.ts +49 -0
- package/dist/views/metadata-admin/default-inspector-registry.js +8 -0
- package/dist/views/metadata-admin/default-schemas.js +115 -10
- package/dist/views/metadata-admin/external/ExternalDatasourcePanel.d.ts +27 -0
- package/dist/views/metadata-admin/external/ExternalDatasourcePanel.js +69 -0
- package/dist/views/metadata-admin/external/ImportObjectDialog.d.ts +27 -0
- package/dist/views/metadata-admin/external/ImportObjectDialog.js +77 -0
- package/dist/views/metadata-admin/external/SchemaBrowser.d.ts +16 -0
- package/dist/views/metadata-admin/external/SchemaBrowser.js +74 -0
- package/dist/views/metadata-admin/external/ValidationPanel.d.ts +16 -0
- package/dist/views/metadata-admin/external/ValidationPanel.js +68 -0
- package/dist/views/metadata-admin/external/api.d.ts +100 -0
- package/dist/views/metadata-admin/external/api.js +124 -0
- package/dist/views/metadata-admin/i18n.d.ts +1 -0
- package/dist/views/metadata-admin/i18n.js +1252 -2
- package/dist/views/metadata-admin/index.d.ts +8 -5
- package/dist/views/metadata-admin/index.js +12 -2
- package/dist/views/metadata-admin/inspector-registry.d.ts +51 -0
- package/dist/views/metadata-admin/inspector-registry.js +11 -0
- package/dist/views/metadata-admin/inspectors/ActionDefaultInspector.d.ts +30 -0
- package/dist/views/metadata-admin/inspectors/ActionDefaultInspector.js +180 -0
- package/dist/views/metadata-admin/inspectors/AppNavInspector.d.ts +16 -0
- package/dist/views/metadata-admin/inspectors/AppNavInspector.js +110 -0
- package/dist/views/metadata-admin/inspectors/ConditionBuilder.d.ts +29 -0
- package/dist/views/metadata-admin/inspectors/ConditionBuilder.js +154 -0
- package/dist/views/metadata-admin/inspectors/DashboardDefaultInspector.d.ts +28 -0
- package/dist/views/metadata-admin/inspectors/DashboardDefaultInspector.js +110 -0
- package/dist/views/metadata-admin/inspectors/DashboardWidgetInspector.d.ts +18 -0
- package/dist/views/metadata-admin/inspectors/DashboardWidgetInspector.js +139 -0
- package/dist/views/metadata-admin/inspectors/DatasetDefaultInspector.d.ts +21 -0
- package/dist/views/metadata-admin/inspectors/DatasetDefaultInspector.js +221 -0
- package/dist/views/metadata-admin/inspectors/FlowEdgeInspector.d.ts +16 -0
- package/dist/views/metadata-admin/inspectors/FlowEdgeInspector.js +126 -0
- package/dist/views/metadata-admin/inspectors/FlowInspector.d.ts +12 -0
- package/dist/views/metadata-admin/inspectors/FlowInspector.js +9 -0
- package/dist/views/metadata-admin/inspectors/FlowKeyValueField.d.ts +30 -0
- package/dist/views/metadata-admin/inspectors/FlowKeyValueField.js +125 -0
- package/dist/views/metadata-admin/inspectors/FlowNodeConfigField.d.ts +18 -0
- package/dist/views/metadata-admin/inspectors/FlowNodeConfigField.js +40 -0
- package/dist/views/metadata-admin/inspectors/FlowNodeInspector.d.ts +14 -0
- package/dist/views/metadata-admin/inspectors/FlowNodeInspector.js +205 -0
- package/dist/views/metadata-admin/inspectors/FlowObjectListField.d.ts +26 -0
- package/dist/views/metadata-admin/inspectors/FlowObjectListField.js +105 -0
- package/dist/views/metadata-admin/inspectors/FlowReferenceField.d.ts +83 -0
- package/dist/views/metadata-admin/inspectors/FlowReferenceField.js +181 -0
- package/dist/views/metadata-admin/inspectors/FlowStringListField.d.ts +21 -0
- package/dist/views/metadata-admin/inspectors/FlowStringListField.js +60 -0
- package/dist/views/metadata-admin/inspectors/InspectorComboField.d.ts +40 -0
- package/dist/views/metadata-admin/inspectors/InspectorComboField.js +61 -0
- package/dist/views/metadata-admin/inspectors/ObjectDefaultInspector.d.ts +21 -0
- package/dist/views/metadata-admin/inspectors/ObjectDefaultInspector.js +55 -0
- package/dist/views/metadata-admin/inspectors/ObjectFieldInspector.d.ts +23 -0
- package/dist/views/metadata-admin/inspectors/ObjectFieldInspector.js +365 -0
- package/dist/views/metadata-admin/inspectors/PageBlockInspector.d.ts +48 -0
- package/dist/views/metadata-admin/inspectors/PageBlockInspector.js +332 -0
- package/dist/views/metadata-admin/inspectors/ReportDefaultInspector.d.ts +58 -0
- package/dist/views/metadata-admin/inspectors/ReportDefaultInspector.js +218 -0
- package/dist/views/metadata-admin/inspectors/ViewColumnInspector.d.ts +19 -0
- package/dist/views/metadata-admin/inspectors/ViewColumnInspector.js +144 -0
- package/dist/views/metadata-admin/inspectors/ViewInspector.d.ts +19 -0
- package/dist/views/metadata-admin/inspectors/ViewInspector.js +21 -0
- package/dist/views/metadata-admin/inspectors/ViewVariantInspector.d.ts +54 -0
- package/dist/views/metadata-admin/inspectors/ViewVariantInspector.js +191 -0
- package/dist/views/metadata-admin/inspectors/_shared.d.ts +128 -0
- package/dist/views/metadata-admin/inspectors/_shared.js +113 -0
- package/dist/views/metadata-admin/inspectors/datasetFilterCondition.d.ts +24 -0
- package/dist/views/metadata-admin/inspectors/datasetFilterCondition.js +97 -0
- package/dist/views/metadata-admin/inspectors/expression-validate.d.ts +26 -0
- package/dist/views/metadata-admin/inspectors/expression-validate.js +66 -0
- package/dist/views/metadata-admin/inspectors/flow-node-config.d.ts +143 -0
- package/dist/views/metadata-admin/inspectors/flow-node-config.js +506 -0
- package/dist/views/metadata-admin/inspectors/index.d.ts +1 -0
- package/dist/views/metadata-admin/inspectors/index.js +45 -0
- package/dist/views/metadata-admin/inspectors/json-schema-to-fields.d.ts +40 -0
- package/dist/views/metadata-admin/inspectors/json-schema-to-fields.js +227 -0
- package/dist/views/metadata-admin/inspectors/useDatasetFields.d.ts +72 -0
- package/dist/views/metadata-admin/inspectors/useDatasetFields.js +0 -0
- package/dist/views/metadata-admin/issuePath.d.ts +22 -0
- package/dist/views/metadata-admin/issuePath.js +65 -0
- package/dist/views/metadata-admin/mergeServerFields.d.ts +65 -0
- package/dist/views/metadata-admin/mergeServerFields.js +56 -0
- package/dist/views/metadata-admin/package-scope.d.ts +26 -0
- package/dist/views/metadata-admin/package-scope.js +43 -0
- package/dist/views/metadata-admin/preview-registry.d.ts +55 -0
- package/dist/views/metadata-admin/previews/ActionPreview.d.ts +25 -0
- package/dist/views/metadata-admin/previews/ActionPreview.js +238 -0
- package/dist/views/metadata-admin/previews/AddWidgetPicker.d.ts +12 -0
- package/dist/views/metadata-admin/previews/AddWidgetPicker.js +56 -0
- package/dist/views/metadata-admin/previews/AgentPreview.d.ts +24 -0
- package/dist/views/metadata-admin/previews/AgentPreview.js +100 -0
- package/dist/views/metadata-admin/previews/AppNavCanvas.d.ts +31 -0
- package/dist/views/metadata-admin/previews/AppNavCanvas.js +260 -0
- package/dist/views/metadata-admin/previews/AppPreview.d.ts +16 -1
- package/dist/views/metadata-admin/previews/AppPreview.js +23 -14
- package/dist/views/metadata-admin/previews/BookPreview.d.ts +20 -0
- package/dist/views/metadata-admin/previews/BookPreview.js +132 -0
- package/dist/views/metadata-admin/previews/DashboardPreview.d.ts +16 -1
- package/dist/views/metadata-admin/previews/DashboardPreview.js +110 -8
- package/dist/views/metadata-admin/previews/DatasetPreview.d.ts +18 -0
- package/dist/views/metadata-admin/previews/DatasetPreview.js +105 -0
- package/dist/views/metadata-admin/previews/DatasourcePreview.d.ts +23 -0
- package/dist/views/metadata-admin/previews/DatasourcePreview.js +68 -0
- package/dist/views/metadata-admin/previews/EmailTemplatePreview.d.ts +14 -1
- package/dist/views/metadata-admin/previews/FieldStub.d.ts +30 -0
- package/dist/views/metadata-admin/previews/FieldStub.js +104 -0
- package/dist/views/metadata-admin/previews/FieldsListEditor.d.ts +50 -0
- package/dist/views/metadata-admin/previews/FieldsListEditor.js +97 -0
- package/dist/views/metadata-admin/previews/FlowCanvas.d.ts +49 -0
- package/dist/views/metadata-admin/previews/FlowCanvas.js +416 -0
- package/dist/views/metadata-admin/previews/FlowPreview.d.ts +20 -0
- package/dist/views/metadata-admin/previews/FlowPreview.js +120 -0
- package/dist/views/metadata-admin/previews/FlowRunsPanel.d.ts +46 -0
- package/dist/views/metadata-admin/previews/FlowRunsPanel.js +97 -0
- package/dist/views/metadata-admin/previews/FlowSimulatorPanel.d.ts +25 -0
- package/dist/views/metadata-admin/previews/FlowSimulatorPanel.js +204 -0
- package/dist/views/metadata-admin/previews/JobPreview.d.ts +28 -0
- package/dist/views/metadata-admin/previews/JobPreview.js +290 -0
- package/dist/views/metadata-admin/previews/ObjectFormCanvas.d.ts +30 -0
- package/dist/views/metadata-admin/previews/ObjectFormCanvas.js +547 -0
- package/dist/views/metadata-admin/previews/ObjectPreview.d.ts +14 -1
- package/dist/views/metadata-admin/previews/ObjectPreview.js +5 -30
- package/dist/views/metadata-admin/previews/OutlineStrip.d.ts +32 -0
- package/dist/views/metadata-admin/previews/OutlineStrip.js +8 -0
- package/dist/views/metadata-admin/previews/PageBlockCanvas.d.ts +49 -0
- package/dist/views/metadata-admin/previews/PageBlockCanvas.js +510 -0
- package/dist/views/metadata-admin/previews/PagePreview.d.ts +10 -1
- package/dist/views/metadata-admin/previews/PagePreview.js +200 -5
- package/dist/views/metadata-admin/previews/PermissionPreview.d.ts +27 -0
- package/dist/views/metadata-admin/previews/PermissionPreview.js +115 -0
- package/dist/views/metadata-admin/previews/PreviewShell.d.ts +29 -6
- package/dist/views/metadata-admin/previews/PreviewShell.js +16 -3
- package/dist/views/metadata-admin/previews/ReportPreview.d.ts +18 -1
- package/dist/views/metadata-admin/previews/ReportPreview.js +23 -15
- package/dist/views/metadata-admin/previews/RolePreview.d.ts +19 -0
- package/dist/views/metadata-admin/previews/RolePreview.js +14 -0
- package/dist/views/metadata-admin/previews/ScreenPreview.d.ts +38 -0
- package/dist/views/metadata-admin/previews/ScreenPreview.js +61 -0
- package/dist/views/metadata-admin/previews/SkillPreview.d.ts +22 -0
- package/dist/views/metadata-admin/previews/SkillPreview.js +34 -0
- package/dist/views/metadata-admin/previews/ToolPreview.d.ts +25 -0
- package/dist/views/metadata-admin/previews/ToolPreview.js +122 -0
- package/dist/views/metadata-admin/previews/TranslationPreview.d.ts +25 -0
- package/dist/views/metadata-admin/previews/TranslationPreview.js +52 -0
- package/dist/views/metadata-admin/previews/ValidationPreview.d.ts +27 -0
- package/dist/views/metadata-admin/previews/ValidationPreview.js +110 -0
- package/dist/views/metadata-admin/previews/ViewColumnPanes.d.ts +62 -0
- package/dist/views/metadata-admin/previews/ViewColumnPanes.js +140 -0
- package/dist/views/metadata-admin/previews/ViewPreview.d.ts +23 -1
- package/dist/views/metadata-admin/previews/ViewPreview.js +101 -73
- package/dist/views/metadata-admin/previews/block-config.d.ts +82 -0
- package/dist/views/metadata-admin/previews/block-config.js +324 -0
- package/dist/views/metadata-admin/previews/block-types.d.ts +40 -0
- package/dist/views/metadata-admin/previews/block-types.js +110 -0
- package/dist/views/metadata-admin/previews/field-types.d.ts +53 -0
- package/dist/views/metadata-admin/previews/field-types.js +97 -0
- package/dist/views/metadata-admin/previews/flow-canvas-layout.d.ts +102 -0
- package/dist/views/metadata-admin/previews/flow-canvas-layout.js +227 -0
- package/dist/views/metadata-admin/previews/flow-canvas-parts.d.ts +96 -0
- package/dist/views/metadata-admin/previews/flow-canvas-parts.js +373 -0
- package/dist/views/metadata-admin/previews/form-preview.d.ts +24 -0
- package/dist/views/metadata-admin/previews/form-preview.js +29 -0
- package/dist/views/metadata-admin/previews/index.js +43 -0
- package/dist/views/metadata-admin/previews/object-fields-bridge.d.ts +66 -0
- package/dist/views/metadata-admin/previews/object-fields-bridge.js +171 -0
- package/dist/views/metadata-admin/previews/object-fields-io.d.ts +130 -0
- package/dist/views/metadata-admin/previews/object-fields-io.js +243 -0
- package/dist/views/metadata-admin/previews/screen-spec.d.ts +43 -0
- package/dist/views/metadata-admin/previews/screen-spec.js +108 -0
- package/dist/views/metadata-admin/previews/simulator/flow-sim-types.d.ts +102 -0
- package/dist/views/metadata-admin/previews/simulator/flow-sim-types.js +2 -0
- package/dist/views/metadata-admin/previews/simulator/flow-sim-validate.d.ts +15 -0
- package/dist/views/metadata-admin/previews/simulator/flow-sim-validate.js +185 -0
- package/dist/views/metadata-admin/previews/simulator/flow-simulator.d.ts +73 -0
- package/dist/views/metadata-admin/previews/simulator/flow-simulator.js +426 -0
- package/dist/views/metadata-admin/previews/useDatasetCatalog.d.ts +47 -0
- package/dist/views/metadata-admin/previews/useDatasetCatalog.js +133 -0
- package/dist/views/metadata-admin/previews/useFlowNodePalette.d.ts +44 -0
- package/dist/views/metadata-admin/previews/useFlowNodePalette.js +124 -0
- package/dist/views/metadata-admin/previews/useMetaOptions.d.ts +8 -0
- package/dist/views/metadata-admin/previews/useMetaOptions.js +50 -0
- package/dist/views/metadata-admin/previews/useObjectFields.d.ts +23 -0
- package/dist/views/metadata-admin/previews/useObjectFields.js +79 -0
- package/dist/views/metadata-admin/previews/useObjectOptions.d.ts +8 -0
- package/dist/views/metadata-admin/previews/useObjectOptions.js +43 -0
- package/dist/views/metadata-admin/previews/view-column-io.d.ts +42 -0
- package/dist/views/metadata-admin/previews/view-column-io.js +73 -0
- package/dist/views/metadata-admin/previews/widget-types.d.ts +24 -0
- package/dist/views/metadata-admin/previews/widget-types.js +40 -0
- package/dist/views/metadata-admin/registry.d.ts +140 -19
- package/dist/views/metadata-admin/report-schema.d.ts +26 -0
- package/dist/views/metadata-admin/report-schema.js +121 -0
- package/dist/views/metadata-admin/useMetadata.d.ts +100 -2
- package/dist/views/metadata-admin/useMetadata.js +155 -4
- package/dist/views/metadata-admin/view-item-normalize.d.ts +20 -0
- package/dist/views/metadata-admin/view-item-normalize.js +68 -0
- package/dist/views/metadata-admin/view-schema.d.ts +16 -0
- package/dist/views/metadata-admin/view-schema.js +107 -0
- package/dist/views/metadata-admin/view-variant-model.d.ts +23 -0
- package/dist/views/metadata-admin/view-variant-model.js +64 -0
- package/dist/views/metadata-admin/widgets.d.ts +89 -1
- package/dist/views/metadata-admin/widgets.js +491 -17
- package/dist/views/runtime-metadata-persistence.d.ts +78 -0
- package/dist/views/runtime-metadata-persistence.js +89 -0
- package/dist/views/useOpenRecordList.d.ts +18 -0
- package/dist/views/useOpenRecordList.js +36 -0
- package/dist/views/userFilterUrlState.d.ts +15 -0
- package/dist/views/userFilterUrlState.js +53 -0
- package/dist/views/view-config-adapter.d.ts +38 -0
- package/dist/views/view-config-adapter.js +80 -0
- package/package.json +52 -34
- package/dist/views/DesignDrawer.d.ts +0 -28
- package/dist/views/DesignDrawer.js +0 -51
- package/dist/views/metadata-admin/DesignerEditorWrapper.d.ts +0 -68
- package/dist/views/metadata-admin/DesignerEditorWrapper.js +0 -158
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
3
|
+
/**
|
|
4
|
+
* `MetadataTypeActions` — renders the declarative, **type-level** actions a
|
|
5
|
+
* metadata type carries (GAP-1) using the same button affordance business
|
|
6
|
+
* objects use for their `actions`.
|
|
7
|
+
*
|
|
8
|
+
* The framework's `/meta/types` endpoint emits these on each rich entry as
|
|
9
|
+
* spec `ActionSchema` objects (see `MetadataTypeAction` in `useMetadata`).
|
|
10
|
+
* The canonical first consumer is the `datasource` type, which declares a
|
|
11
|
+
* "Test connection" action (`type:'api'`, `POST
|
|
12
|
+
* /api/v1/datasources/${ctx.recordId}/test`). Rendering happens in two
|
|
13
|
+
* chrome slots:
|
|
14
|
+
*
|
|
15
|
+
* • ResourceEditPage → `location='record_header'`, `recordId` = item name.
|
|
16
|
+
* • ResourceListPage → `location='list_toolbar'` (no recordId).
|
|
17
|
+
*
|
|
18
|
+
* Execution path mirrors ObjectView's auth-aware `apiHandler` rather than the
|
|
19
|
+
* core ActionRunner's bare `fetch`: the metadata API endpoints require the
|
|
20
|
+
* better-auth session cookie + bearer token, which only ride along through
|
|
21
|
+
* `createAuthenticatedFetch` (and matter in split-origin dev where the SPA is
|
|
22
|
+
* on :5180 and the backend on :3000). `${ctx.recordId}` / `${param.X}` tokens
|
|
23
|
+
* in `target` are resolved here, exactly as the spec mandates renderers do.
|
|
24
|
+
*
|
|
25
|
+
* Dialogs: actions that declare an array of `params` collect them from the
|
|
26
|
+
* user in the shared {@link ActionParamDialog} before running (same UX as
|
|
27
|
+
* business-object actions); actions that declare a `resultDialog` render the
|
|
28
|
+
* API response in {@link ActionResultDialog}. `confirmText` still gates the run.
|
|
29
|
+
*
|
|
30
|
+
* Only `type:'api'` is wired today; other types surface a toast so a
|
|
31
|
+
* misconfigured action fails loud instead of silent.
|
|
32
|
+
*/
|
|
33
|
+
import * as React from 'react';
|
|
34
|
+
import { toast } from 'sonner';
|
|
35
|
+
import { Loader2 } from 'lucide-react';
|
|
36
|
+
import { Button } from '@object-ui/components';
|
|
37
|
+
import { createAuthenticatedFetch } from '@object-ui/auth';
|
|
38
|
+
import { getIcon } from '../../utils/getIcon';
|
|
39
|
+
import { ActionParamDialog } from '../ActionParamDialog';
|
|
40
|
+
import { ActionResultDialog } from '../ActionResultDialog';
|
|
41
|
+
/** Map the spec's action variants onto the Shadcn Button variants. */
|
|
42
|
+
const VARIANT_MAP = {
|
|
43
|
+
primary: 'default',
|
|
44
|
+
secondary: 'secondary',
|
|
45
|
+
danger: 'destructive',
|
|
46
|
+
ghost: 'ghost',
|
|
47
|
+
link: 'link',
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Substitute `${ctx.X}` / `${param.X}` tokens in an action target. Values are
|
|
51
|
+
* `encodeURIComponent`'d — opaque ids in a path segment (datasource name) are
|
|
52
|
+
* the only use today, and encoding is the correct behaviour for those.
|
|
53
|
+
*/
|
|
54
|
+
function interpolateTarget(target, ctx, params) {
|
|
55
|
+
if (target.indexOf('${') === -1)
|
|
56
|
+
return target;
|
|
57
|
+
return target.replace(/\$\{(param|ctx)\.([\w.]+)\}/g, (_m, scope, path) => {
|
|
58
|
+
const root = scope === 'param' ? params : ctx;
|
|
59
|
+
const value = path
|
|
60
|
+
.split('.')
|
|
61
|
+
.reduce((o, k) => (o == null ? undefined : o[k]), root);
|
|
62
|
+
return value == null ? '' : encodeURIComponent(String(value));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Render the location-filtered type-level actions. Returns `null` when the
|
|
67
|
+
* type declares none for this slot, so callers can drop it straight into an
|
|
68
|
+
* existing toolbar `<>…</>` without conditionals.
|
|
69
|
+
*/
|
|
70
|
+
export function MetadataTypeActions({ entry, location, recordId, onAfter }) {
|
|
71
|
+
const [busy, setBusy] = React.useState(null);
|
|
72
|
+
const [paramState, setParamState] = React.useState({ open: false, params: [] });
|
|
73
|
+
const [resultState, setResultState] = React.useState({ open: false });
|
|
74
|
+
const authFetch = React.useMemo(() => createAuthenticatedFetch(), []);
|
|
75
|
+
const actions = React.useMemo(() => (entry?.actions ?? []).filter((a) => !a.locations || a.locations.length === 0 || a.locations.includes(location)), [entry?.actions, location]);
|
|
76
|
+
if (actions.length === 0)
|
|
77
|
+
return null;
|
|
78
|
+
/** Open the param dialog and resolve with the collected values (or null on cancel). */
|
|
79
|
+
const collectParams = (params, title) => new Promise((resolve) => {
|
|
80
|
+
setParamState({ open: true, params, title, resolve });
|
|
81
|
+
});
|
|
82
|
+
const run = async (action) => {
|
|
83
|
+
const title = action.label ?? action.name;
|
|
84
|
+
// Only `type:'api'` is wired today. Default (`undefined`) is treated as
|
|
85
|
+
// `script` by the spec, which the engine cannot execute — fail loud.
|
|
86
|
+
if (action.type !== 'api') {
|
|
87
|
+
toast.error(`Action “${title}”: type "${action.type ?? 'script'}" is not supported here yet.`);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (action.confirmText && !window.confirm(action.confirmText))
|
|
91
|
+
return;
|
|
92
|
+
// Inputs: an array of param descriptors → collect in a dialog; a static
|
|
93
|
+
// object → forward as-is.
|
|
94
|
+
let params;
|
|
95
|
+
if (Array.isArray(action.params) && action.params.length > 0) {
|
|
96
|
+
const collected = await collectParams(action.params, title);
|
|
97
|
+
if (collected == null)
|
|
98
|
+
return; // user cancelled
|
|
99
|
+
params = collected;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
params = action.params ?? {};
|
|
103
|
+
}
|
|
104
|
+
const ctx = { recordId, origin: window.location.origin };
|
|
105
|
+
const resolved = interpolateTarget(action.target ?? '', ctx, params);
|
|
106
|
+
if (!resolved) {
|
|
107
|
+
toast.error(`Action “${title}” has no target.`);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
// Split SPA + backend dev: promote same-origin `/api/...` paths to the
|
|
111
|
+
// backend origin so the request (and its auth cookie) reaches :3000.
|
|
112
|
+
const apiBase = (import.meta.env?.VITE_SERVER_URL || '').replace(/\/+$/, '');
|
|
113
|
+
const url = /^https?:\/\//i.test(resolved) ? resolved : `${apiBase}${resolved}`;
|
|
114
|
+
const method = (action.method || 'POST').toUpperCase();
|
|
115
|
+
setBusy(action.name);
|
|
116
|
+
try {
|
|
117
|
+
const init = {
|
|
118
|
+
method,
|
|
119
|
+
headers: { 'Content-Type': 'application/json' },
|
|
120
|
+
credentials: 'include',
|
|
121
|
+
};
|
|
122
|
+
if (method !== 'GET' && method !== 'DELETE')
|
|
123
|
+
init.body = JSON.stringify(params);
|
|
124
|
+
const res = await authFetch(url, init);
|
|
125
|
+
let data = null;
|
|
126
|
+
try {
|
|
127
|
+
data = (await res.json());
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
/* non-JSON / empty body — fall back to status text */
|
|
131
|
+
}
|
|
132
|
+
if (!res.ok || (data && data.success === false)) {
|
|
133
|
+
const detail = data?.error || data?.message || `HTTP ${res.status} ${res.statusText}`.trim();
|
|
134
|
+
toast.error(`${action.errorMessage ? `${action.errorMessage}: ` : ''}${title}: ${detail}`);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
// Rich result reveal when declared, else a success toast.
|
|
138
|
+
if (action.resultDialog) {
|
|
139
|
+
setResultState({ open: true, spec: action.resultDialog, data: data ?? {} });
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
const msg = action.successMessage || (typeof data?.message === 'string' ? data.message : `${title} ✓`);
|
|
143
|
+
toast.success(msg);
|
|
144
|
+
}
|
|
145
|
+
if (action.refreshAfter)
|
|
146
|
+
onAfter?.();
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
toast.error(`${title}: ${err?.message ?? String(err)}`);
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
setBusy(null);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
return (_jsxs(_Fragment, { children: [actions.map((action) => {
|
|
156
|
+
const Icon = action.icon ? getIcon(action.icon) : null;
|
|
157
|
+
const isBusy = busy === action.name;
|
|
158
|
+
return (_jsxs(Button, { size: "sm", variant: VARIANT_MAP[action.variant ?? 'secondary'] ?? 'secondary', disabled: isBusy, onClick: () => run(action), title: action.label ?? action.name, children: [isBusy ? (_jsx(Loader2, { className: "h-4 w-4 mr-1 animate-spin" })) : Icon ? (_jsx(Icon, { className: "h-4 w-4 mr-1" })) : null, action.label ?? action.name] }, action.name));
|
|
159
|
+
}), _jsx(ActionParamDialog, { state: paramState, onOpenChange: (open) => {
|
|
160
|
+
if (!open) {
|
|
161
|
+
paramState.resolve?.(null);
|
|
162
|
+
setParamState({ open: false, params: [] });
|
|
163
|
+
}
|
|
164
|
+
} }), _jsx(ActionResultDialog, { state: resultState, onAcknowledge: () => setResultState({ open: false }) })] }));
|
|
165
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PackagesPage — the package management entry point for Studio.
|
|
3
|
+
*
|
|
4
|
+
* Studio previously exposed packages only through the sidebar `active_package`
|
|
5
|
+
* *filter* dropdown; there was no surface to see all packages, create one, or
|
|
6
|
+
* act on one (publish / revert / enable / disable). This page fills that gap.
|
|
7
|
+
*
|
|
8
|
+
* It is the authoring home for the Studio → package → publish workflow:
|
|
9
|
+
* 1. Create a package (POST /api/v1/packages with a minimal manifest).
|
|
10
|
+
* 2. Author metadata bound to it (via the sidebar scope + ResourceEditPage).
|
|
11
|
+
* 3. Publish it (POST /api/v1/packages/:id/publish).
|
|
12
|
+
*
|
|
13
|
+
* Backed entirely by the existing `/api/v1/packages` REST surface
|
|
14
|
+
* (see framework `http-dispatcher.handlePackages`).
|
|
15
|
+
*/
|
|
16
|
+
import * as React from 'react';
|
|
17
|
+
export declare function PackagesPage(): React.JSX.Element;
|
|
18
|
+
export default PackagesPage;
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
3
|
+
/**
|
|
4
|
+
* PackagesPage — the package management entry point for Studio.
|
|
5
|
+
*
|
|
6
|
+
* Studio previously exposed packages only through the sidebar `active_package`
|
|
7
|
+
* *filter* dropdown; there was no surface to see all packages, create one, or
|
|
8
|
+
* act on one (publish / revert / enable / disable). This page fills that gap.
|
|
9
|
+
*
|
|
10
|
+
* It is the authoring home for the Studio → package → publish workflow:
|
|
11
|
+
* 1. Create a package (POST /api/v1/packages with a minimal manifest).
|
|
12
|
+
* 2. Author metadata bound to it (via the sidebar scope + ResourceEditPage).
|
|
13
|
+
* 3. Publish it (POST /api/v1/packages/:id/publish).
|
|
14
|
+
*
|
|
15
|
+
* Backed entirely by the existing `/api/v1/packages` REST surface
|
|
16
|
+
* (see framework `http-dispatcher.handlePackages`).
|
|
17
|
+
*/
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
import { Link, useLocation } from 'react-router-dom';
|
|
20
|
+
import { Package as PackageIcon, Plus, RefreshCw, Search, Upload, Download, FileUp, Undo2, Power, PowerOff, ExternalLink, AlertTriangle, Trash2, } from 'lucide-react';
|
|
21
|
+
import { Button, Input, Badge, Switch, Label, Separator, Skeleton, Empty, EmptyTitle, EmptyDescription, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, } from '@object-ui/components';
|
|
22
|
+
import { detectLocale, t, tFormat } from './i18n';
|
|
23
|
+
const API = '/api/v1/packages';
|
|
24
|
+
async function apiJson(path, init) {
|
|
25
|
+
const res = await fetch(path, {
|
|
26
|
+
credentials: 'include',
|
|
27
|
+
headers: { Accept: 'application/json', ...(init?.headers || {}) },
|
|
28
|
+
...init,
|
|
29
|
+
});
|
|
30
|
+
const text = await res.text();
|
|
31
|
+
const payload = text ? JSON.parse(text) : null;
|
|
32
|
+
if (!res.ok || payload?.success === false) {
|
|
33
|
+
const msg = payload?.error?.message ||
|
|
34
|
+
payload?.error ||
|
|
35
|
+
payload?.message ||
|
|
36
|
+
`Request failed (${res.status})`;
|
|
37
|
+
throw new Error(typeof msg === 'string' ? msg : `Request failed (${res.status})`);
|
|
38
|
+
}
|
|
39
|
+
// Runtime wraps successful payloads in { data, ... } or returns the object directly.
|
|
40
|
+
return (payload?.data ?? payload);
|
|
41
|
+
}
|
|
42
|
+
/* -------------------------------------------------------------------------- */
|
|
43
|
+
/* Scope badge */
|
|
44
|
+
/* -------------------------------------------------------------------------- */
|
|
45
|
+
function ScopeBadge({ scope }) {
|
|
46
|
+
const locale = React.useMemo(() => detectLocale(), []);
|
|
47
|
+
const s = scope ?? 'project';
|
|
48
|
+
const variant = s === 'project' ? 'default' : s === 'system' ? 'secondary' : 'outline';
|
|
49
|
+
const labelKey = s === 'project'
|
|
50
|
+
? 'engine.packages.scope.project'
|
|
51
|
+
: s === 'system'
|
|
52
|
+
? 'engine.packages.scope.system'
|
|
53
|
+
: s === 'cloud'
|
|
54
|
+
? 'engine.packages.scope.cloud'
|
|
55
|
+
: '';
|
|
56
|
+
return _jsx(Badge, { variant: variant, children: labelKey ? t(labelKey, locale) : s });
|
|
57
|
+
}
|
|
58
|
+
function StatusBadge({ pkg }) {
|
|
59
|
+
const locale = React.useMemo(() => detectLocale(), []);
|
|
60
|
+
const enabled = pkg.enabled !== false && pkg.status !== 'disabled';
|
|
61
|
+
return (_jsx(Badge, { variant: enabled ? 'default' : 'outline', children: enabled ? t('engine.packages.status.enabled', locale) : t('engine.packages.status.disabled', locale) }));
|
|
62
|
+
}
|
|
63
|
+
/* -------------------------------------------------------------------------- */
|
|
64
|
+
/* Create-package dialog */
|
|
65
|
+
/* -------------------------------------------------------------------------- */
|
|
66
|
+
const ID_RE = /^[a-z0-9][a-z0-9._-]{1,254}$/i;
|
|
67
|
+
const VERSION_RE = /^\d+\.\d+\.\d+$/;
|
|
68
|
+
function CreatePackageDialog({ open, onOpenChange, onCreated, }) {
|
|
69
|
+
const locale = React.useMemo(() => detectLocale(), []);
|
|
70
|
+
const [id, setId] = React.useState('');
|
|
71
|
+
const [name, setName] = React.useState('');
|
|
72
|
+
const [version, setVersion] = React.useState('0.1.0');
|
|
73
|
+
const [busy, setBusy] = React.useState(false);
|
|
74
|
+
const [error, setError] = React.useState(null);
|
|
75
|
+
React.useEffect(() => {
|
|
76
|
+
if (open) {
|
|
77
|
+
setId('');
|
|
78
|
+
setName('');
|
|
79
|
+
setVersion('0.1.0');
|
|
80
|
+
setError(null);
|
|
81
|
+
setBusy(false);
|
|
82
|
+
}
|
|
83
|
+
}, [open]);
|
|
84
|
+
const idValid = ID_RE.test(id);
|
|
85
|
+
const versionValid = VERSION_RE.test(version);
|
|
86
|
+
const canSubmit = idValid && versionValid && !!name.trim() && !busy;
|
|
87
|
+
async function submit() {
|
|
88
|
+
if (!canSubmit)
|
|
89
|
+
return;
|
|
90
|
+
setBusy(true);
|
|
91
|
+
setError(null);
|
|
92
|
+
try {
|
|
93
|
+
await apiJson(API, {
|
|
94
|
+
method: 'POST',
|
|
95
|
+
headers: { 'Content-Type': 'application/json' },
|
|
96
|
+
body: JSON.stringify({
|
|
97
|
+
manifest: {
|
|
98
|
+
id: id.trim(),
|
|
99
|
+
name: name.trim(),
|
|
100
|
+
version: version.trim(),
|
|
101
|
+
type: 'app',
|
|
102
|
+
scope: 'project',
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
});
|
|
106
|
+
onCreated(id.trim());
|
|
107
|
+
// Let context selectors (e.g. the sidebar package switcher) pick up the
|
|
108
|
+
// new package without a full page reload.
|
|
109
|
+
try {
|
|
110
|
+
window.dispatchEvent(new CustomEvent('objectui:packages-changed'));
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
/* non-DOM env */
|
|
114
|
+
}
|
|
115
|
+
onOpenChange(false);
|
|
116
|
+
}
|
|
117
|
+
catch (e) {
|
|
118
|
+
setError(e?.message ?? t('engine.packages.create.failed', locale));
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
setBusy(false);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: t('engine.packages.create.title', locale) }), _jsx(DialogDescription, { children: tFormat('engine.packages.create.description', locale, { example: 'com.acme.crm' }) })] }), _jsxs("div", { className: "space-y-4 py-2", children: [_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "pkg-id", children: t('engine.packages.create.id', locale) }), _jsx(Input, { id: "pkg-id", "data-testid": "package-id-input", placeholder: "com.acme.crm", value: id, onChange: (e) => setId(e.target.value), "aria-invalid": !!id && !idValid }), !!id && !idValid && (_jsx("p", { className: "text-xs text-destructive", children: t('engine.packages.create.idInvalid', locale) }))] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "pkg-name", children: t('engine.packages.create.name', locale) }), _jsx(Input, { id: "pkg-name", "data-testid": "package-name-input", placeholder: "Acme CRM", value: name, onChange: (e) => setName(e.target.value) })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "pkg-version", children: t('engine.packages.create.version', locale) }), _jsx(Input, { id: "pkg-version", placeholder: "0.1.0", value: version, onChange: (e) => setVersion(e.target.value), "aria-invalid": !!version && !versionValid }), !!version && !versionValid && (_jsx("p", { className: "text-xs text-destructive", children: t('engine.packages.create.versionInvalid', locale) }))] }), error && (_jsxs("div", { className: "flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-2 text-sm text-destructive", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-4 w-4 shrink-0" }), _jsx("span", { children: error })] }))] }), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), disabled: busy, children: t('engine.cancel', locale) }), _jsx(Button, { onClick: submit, disabled: !canSubmit, children: busy ? t('engine.packages.create.creating', locale) : t('engine.packages.create.submit', locale) })] })] }) }));
|
|
125
|
+
}
|
|
126
|
+
/* -------------------------------------------------------------------------- */
|
|
127
|
+
/* Detail sheet — manifest + lifecycle actions */
|
|
128
|
+
/* -------------------------------------------------------------------------- */
|
|
129
|
+
function DetailRow({ label, children }) {
|
|
130
|
+
return (_jsxs("div", { className: "flex items-baseline justify-between gap-4 py-1.5", children: [_jsx("span", { className: "text-sm text-muted-foreground", children: label }), _jsx("span", { className: "text-sm font-medium text-right break-all", children: children })] }));
|
|
131
|
+
}
|
|
132
|
+
function PackageDetailSheet({ pkg, appBase, open, onOpenChange, onChanged, }) {
|
|
133
|
+
const locale = React.useMemo(() => detectLocale(), []);
|
|
134
|
+
const [busy, setBusy] = React.useState(null);
|
|
135
|
+
const [msg, setMsg] = React.useState(null);
|
|
136
|
+
// ADR-0033 — pending DRAFT items bound to this package. AI-authored metadata
|
|
137
|
+
// lands as drafts that the active-only browsers hide, so without this the
|
|
138
|
+
// package looks empty right after a build. We list them here with a link to
|
|
139
|
+
// the existing per-item review/diff (?review=1) so the user can publish them.
|
|
140
|
+
const [drafts, setDrafts] = React.useState(null);
|
|
141
|
+
React.useEffect(() => {
|
|
142
|
+
setMsg(null);
|
|
143
|
+
setBusy(null);
|
|
144
|
+
}, [pkg?.manifest.id]);
|
|
145
|
+
React.useEffect(() => {
|
|
146
|
+
const pid = pkg?.manifest.id;
|
|
147
|
+
if (!open || !pid) {
|
|
148
|
+
setDrafts(null);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
let cancelled = false;
|
|
152
|
+
apiJson(`/api/v1/meta/_drafts?packageId=${encodeURIComponent(pid)}`)
|
|
153
|
+
.then((r) => {
|
|
154
|
+
if (!cancelled)
|
|
155
|
+
setDrafts(r?.drafts ?? []);
|
|
156
|
+
})
|
|
157
|
+
.catch(() => {
|
|
158
|
+
if (!cancelled)
|
|
159
|
+
setDrafts([]);
|
|
160
|
+
});
|
|
161
|
+
return () => {
|
|
162
|
+
cancelled = true;
|
|
163
|
+
};
|
|
164
|
+
}, [open, pkg?.manifest.id]);
|
|
165
|
+
if (!pkg)
|
|
166
|
+
return null;
|
|
167
|
+
const id = pkg.manifest.id;
|
|
168
|
+
const enabled = pkg.enabled !== false && pkg.status !== 'disabled';
|
|
169
|
+
const isKernel = pkg.manifest.scope === 'system' || pkg.manifest.scope === 'cloud';
|
|
170
|
+
async function run(action, fn, okText) {
|
|
171
|
+
setBusy(action);
|
|
172
|
+
setMsg(null);
|
|
173
|
+
try {
|
|
174
|
+
await fn();
|
|
175
|
+
setMsg({ kind: 'ok', text: okText });
|
|
176
|
+
onChanged();
|
|
177
|
+
}
|
|
178
|
+
catch (e) {
|
|
179
|
+
setMsg({ kind: 'err', text: e?.message ?? t('engine.packages.detail.actionFailed', locale) });
|
|
180
|
+
}
|
|
181
|
+
finally {
|
|
182
|
+
setBusy(null);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const publish = () => run('publish', () => apiJson(`${API}/${encodeURIComponent(id)}/publish`, {
|
|
186
|
+
method: 'POST',
|
|
187
|
+
headers: { 'Content-Type': 'application/json' },
|
|
188
|
+
body: JSON.stringify({}),
|
|
189
|
+
}).then((r) => {
|
|
190
|
+
if (r && r.success === false) {
|
|
191
|
+
const n = r.validationErrors?.length ?? 0;
|
|
192
|
+
throw new Error(n
|
|
193
|
+
? tFormat('engine.packages.detail.publishBlocked', locale, { count: n })
|
|
194
|
+
: r.validationErrors?.[0]?.message || t('engine.packages.detail.nothingToPublish', locale));
|
|
195
|
+
}
|
|
196
|
+
return r;
|
|
197
|
+
}), t('engine.packages.detail.published', locale));
|
|
198
|
+
// ADR-0033 — publish every pending draft of this app in one shot, then
|
|
199
|
+
// refresh the pending list (it should now be empty). Distinct from the
|
|
200
|
+
// registry-based `publish` above; this hits `/publish-drafts`.
|
|
201
|
+
const publishDrafts = () => run('publish-drafts', () => apiJson(`${API}/${encodeURIComponent(id)}/publish-drafts`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({}) }).then(async (r) => {
|
|
202
|
+
try {
|
|
203
|
+
const fresh = await apiJson(`/api/v1/meta/_drafts?packageId=${encodeURIComponent(id)}`);
|
|
204
|
+
setDrafts(fresh?.drafts ?? []);
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
setDrafts([]);
|
|
208
|
+
}
|
|
209
|
+
if (r?.failedCount) {
|
|
210
|
+
throw new Error(tFormat('engine.packages.detail.publishDraftsPartial', locale, {
|
|
211
|
+
published: r.publishedCount ?? 0,
|
|
212
|
+
failed: r.failedCount,
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
return r;
|
|
216
|
+
}), t('engine.packages.detail.publishDraftsOk', locale));
|
|
217
|
+
const revert = () => run('revert', () => apiJson(`${API}/${encodeURIComponent(id)}/revert`, { method: 'POST' }), t('engine.packages.detail.reverted', locale));
|
|
218
|
+
// ADR-0033 — discard every pending draft of this app in one shot, reverting
|
|
219
|
+
// it to the last published baseline. NON-destructive: published metadata and
|
|
220
|
+
// data are untouched. Distinct from the metadata-service `/revert` above —
|
|
221
|
+
// this hits the robust `/discard-drafts` (sys_metadata) path.
|
|
222
|
+
const discardDrafts = () => run('discard-drafts', () => apiJson(`${API}/${encodeURIComponent(id)}/discard-drafts`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({}) }).then(async (r) => {
|
|
223
|
+
try {
|
|
224
|
+
const fresh = await apiJson(`/api/v1/meta/_drafts?packageId=${encodeURIComponent(id)}`);
|
|
225
|
+
setDrafts(fresh?.drafts ?? []);
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
setDrafts([]);
|
|
229
|
+
}
|
|
230
|
+
if (r?.failedCount) {
|
|
231
|
+
throw new Error(tFormat('engine.packages.detail.discardDraftsPartial', locale, {
|
|
232
|
+
discarded: r.discardedCount ?? 0,
|
|
233
|
+
failed: r.failedCount,
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
236
|
+
return r;
|
|
237
|
+
}), t('engine.packages.detail.discardDraftsOk', locale));
|
|
238
|
+
// ADR-0033 — delete the WHOLE package: every metadata row (active + draft)
|
|
239
|
+
// plus each object's physical table (DESTRUCTIVE). Confirmed, then closes the
|
|
240
|
+
// sheet on success. Errors stay visible (sheet kept open).
|
|
241
|
+
const deleteApp = async () => {
|
|
242
|
+
const ok = window.confirm(tFormat('engine.packages.detail.deleteConfirm', locale, { name: pkg?.manifest.name || id }));
|
|
243
|
+
if (!ok)
|
|
244
|
+
return;
|
|
245
|
+
setBusy('delete');
|
|
246
|
+
setMsg(null);
|
|
247
|
+
try {
|
|
248
|
+
await apiJson(`${API}/${encodeURIComponent(id)}`, { method: 'DELETE' });
|
|
249
|
+
onChanged();
|
|
250
|
+
onOpenChange(false);
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
setMsg({ kind: 'err', text: e?.message ?? t('engine.packages.detail.deleteFailed', locale) });
|
|
254
|
+
}
|
|
255
|
+
finally {
|
|
256
|
+
setBusy(null);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
const toggleEnable = () => run('toggle', () => apiJson(`${API}/${encodeURIComponent(id)}/${enabled ? 'disable' : 'enable'}`, {
|
|
260
|
+
method: 'PATCH',
|
|
261
|
+
}), enabled ? t('engine.packages.detail.disabled', locale) : t('engine.packages.detail.enabled', locale));
|
|
262
|
+
const exportPkg = () => run('export', async () => {
|
|
263
|
+
const manifest = await apiJson(`${API}/${encodeURIComponent(id)}/export`);
|
|
264
|
+
const blob = new Blob([JSON.stringify(manifest, null, 2)], {
|
|
265
|
+
type: 'application/json',
|
|
266
|
+
});
|
|
267
|
+
const url = URL.createObjectURL(blob);
|
|
268
|
+
const a = document.createElement('a');
|
|
269
|
+
a.href = url;
|
|
270
|
+
a.download = `${id}.package.json`;
|
|
271
|
+
document.body.appendChild(a);
|
|
272
|
+
a.click();
|
|
273
|
+
a.remove();
|
|
274
|
+
URL.revokeObjectURL(url);
|
|
275
|
+
}, t('engine.packages.detail.exported', locale));
|
|
276
|
+
return (_jsx(Sheet, { open: open, onOpenChange: onOpenChange, children: _jsxs(SheetContent, { className: "w-full sm:max-w-md overflow-y-auto", children: [_jsxs(SheetHeader, { children: [_jsxs(SheetTitle, { className: "flex items-center gap-2", children: [_jsx(PackageIcon, { className: "h-4 w-4" }), pkg.manifest.name || id] }), _jsx(SheetDescription, { className: "font-mono text-xs", children: id })] }), _jsxs("div", { className: "mt-4", children: [_jsx(DetailRow, { label: t('engine.packages.col.version', locale), children: pkg.manifest.version || '—' }), _jsx(DetailRow, { label: t('engine.packages.detail.type', locale), children: pkg.manifest.type || '—' }), _jsx(DetailRow, { label: t('engine.packages.col.scope', locale), children: _jsx(ScopeBadge, { scope: pkg.manifest.scope }) }), _jsx(DetailRow, { label: t('engine.packages.col.status', locale), children: _jsx(StatusBadge, { pkg: pkg }) }), pkg.manifest.description && (_jsx(DetailRow, { label: t('engine.packages.detail.description', locale), children: pkg.manifest.description }))] }), _jsx(Separator, { className: "my-4" }), _jsxs(Link, { to: `${appBase}/metadata/object?package=${encodeURIComponent(id)}`, className: "inline-flex items-center gap-1.5 text-sm text-primary hover:underline", onClick: () => onOpenChange(false), children: [_jsx(ExternalLink, { className: "h-3.5 w-3.5" }), t('engine.packages.detail.browseMetadata', locale)] }), drafts && drafts.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Separator, { className: "my-4" }), _jsxs("div", { className: "space-y-2", children: [_jsxs("p", { className: "flex items-center gap-2 text-xs font-medium uppercase tracking-wide text-muted-foreground", children: [t('engine.packages.detail.pendingChanges', locale), _jsx(Badge, { variant: "secondary", children: drafts.length })] }), _jsx("p", { className: "text-xs text-muted-foreground", children: t('engine.packages.detail.pendingHint', locale) }), !isKernel && (_jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsxs(Button, { size: "sm", onClick: publishDrafts, disabled: !!busy, children: [_jsx(Upload, { className: "mr-1.5 h-3.5 w-3.5" }), busy === 'publish-drafts'
|
|
277
|
+
? t('engine.packages.detail.publishing', locale)
|
|
278
|
+
: tFormat('engine.packages.detail.publishApp', locale, { count: drafts.length })] }), _jsxs(Button, { size: "sm", variant: "outline", onClick: discardDrafts, disabled: !!busy, children: [_jsx(Undo2, { className: "mr-1.5 h-3.5 w-3.5" }), busy === 'discard-drafts'
|
|
279
|
+
? t('engine.packages.detail.discarding', locale)
|
|
280
|
+
: tFormat('engine.packages.detail.discardChanges', locale, { count: drafts.length })] })] })), _jsx("ul", { className: "space-y-1", children: drafts.map((d) => (_jsx("li", { children: _jsxs(Link, { to: `${appBase}/metadata/${encodeURIComponent(d.type)}/${encodeURIComponent(d.name)}?review=1`, className: "inline-flex items-center gap-1.5 text-sm text-primary hover:underline", onClick: () => onOpenChange(false), children: [_jsx(FileUp, { className: "h-3.5 w-3.5" }), _jsx("span", { className: "font-mono text-xs", children: d.type }), _jsx("span", { className: "text-muted-foreground", children: "\u00B7" }), d.name] }) }, `${d.type}/${d.name}`))) })] })] })), _jsx(Separator, { className: "my-4" }), isKernel ? (_jsx("p", { className: "text-sm text-muted-foreground", children: t('engine.packages.detail.kernelReadOnly', locale) })) : (_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: t('engine.packages.detail.actions', locale) }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsxs(Button, { size: "sm", onClick: publish, disabled: !!busy, children: [_jsx(Upload, { className: "mr-1.5 h-3.5 w-3.5" }), busy === 'publish' ? t('engine.packages.detail.publishing', locale) : t('engine.packages.detail.publish', locale)] }), _jsxs(Button, { size: "sm", variant: "outline", onClick: revert, disabled: !!busy, children: [_jsx(Undo2, { className: "mr-1.5 h-3.5 w-3.5" }), t('engine.packages.detail.revert', locale)] }), _jsxs(Button, { size: "sm", variant: "outline", onClick: toggleEnable, disabled: !!busy, children: [enabled ? (_jsx(PowerOff, { className: "mr-1.5 h-3.5 w-3.5" })) : (_jsx(Power, { className: "mr-1.5 h-3.5 w-3.5" })), enabled ? t('engine.packages.detail.disable', locale) : t('engine.packages.detail.enable', locale)] }), _jsxs(Button, { size: "sm", variant: "outline", onClick: exportPkg, disabled: !!busy, children: [_jsx(Download, { className: "mr-1.5 h-3.5 w-3.5" }), busy === 'export' ? t('engine.packages.detail.exporting', locale) : t('engine.packages.detail.export', locale)] }), _jsxs(Button, { size: "sm", variant: "outline", onClick: deleteApp, disabled: !!busy, className: "text-destructive hover:bg-destructive/10 hover:text-destructive", children: [_jsx(Trash2, { className: "mr-1.5 h-3.5 w-3.5" }), busy === 'delete' ? t('engine.packages.detail.deleting', locale) : t('engine.packages.detail.deleteApp', locale)] })] })] })), msg && (_jsx("div", { className: `mt-4 rounded-md border p-2 text-sm ${msg.kind === 'ok'
|
|
281
|
+
? 'border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400'
|
|
282
|
+
: 'border-destructive/40 bg-destructive/10 text-destructive'}`, children: msg.text }))] }) }));
|
|
283
|
+
}
|
|
284
|
+
/* -------------------------------------------------------------------------- */
|
|
285
|
+
/* Main page */
|
|
286
|
+
/* -------------------------------------------------------------------------- */
|
|
287
|
+
export function PackagesPage() {
|
|
288
|
+
const locale = React.useMemo(() => detectLocale(), []);
|
|
289
|
+
const { pathname } = useLocation();
|
|
290
|
+
// App base = path up to (and excluding) `/component/...`, so links to
|
|
291
|
+
// `/apps/:app/metadata/...` work regardless of nesting.
|
|
292
|
+
const appBase = React.useMemo(() => {
|
|
293
|
+
const idx = pathname.indexOf('/component');
|
|
294
|
+
return idx >= 0 ? pathname.slice(0, idx) : pathname;
|
|
295
|
+
}, [pathname]);
|
|
296
|
+
const [packages, setPackages] = React.useState([]);
|
|
297
|
+
const [loading, setLoading] = React.useState(true);
|
|
298
|
+
const [error, setError] = React.useState(null);
|
|
299
|
+
const [query, setQuery] = React.useState('');
|
|
300
|
+
const [showKernel, setShowKernel] = React.useState(false);
|
|
301
|
+
const [createOpen, setCreateOpen] = React.useState(false);
|
|
302
|
+
const [selected, setSelected] = React.useState(null);
|
|
303
|
+
const [detailOpen, setDetailOpen] = React.useState(false);
|
|
304
|
+
const fileRef = React.useRef(null);
|
|
305
|
+
const [importing, setImporting] = React.useState(false);
|
|
306
|
+
const [importMsg, setImportMsg] = React.useState(null);
|
|
307
|
+
const load = React.useCallback(async () => {
|
|
308
|
+
setLoading(true);
|
|
309
|
+
setError(null);
|
|
310
|
+
try {
|
|
311
|
+
const data = await apiJson(API);
|
|
312
|
+
const list = Array.isArray(data?.packages) ? data.packages : [];
|
|
313
|
+
list.sort((a, b) => {
|
|
314
|
+
// User (project) packages first, then by name.
|
|
315
|
+
const sa = a.manifest.scope === 'project' ? 0 : 1;
|
|
316
|
+
const sb = b.manifest.scope === 'project' ? 0 : 1;
|
|
317
|
+
if (sa !== sb)
|
|
318
|
+
return sa - sb;
|
|
319
|
+
return (a.manifest.name || a.manifest.id).localeCompare(b.manifest.name || b.manifest.id);
|
|
320
|
+
});
|
|
321
|
+
setPackages(list);
|
|
322
|
+
}
|
|
323
|
+
catch (e) {
|
|
324
|
+
setError(e?.message ?? t('engine.packages.loadFailed', locale));
|
|
325
|
+
}
|
|
326
|
+
finally {
|
|
327
|
+
setLoading(false);
|
|
328
|
+
}
|
|
329
|
+
}, [locale]);
|
|
330
|
+
React.useEffect(() => {
|
|
331
|
+
void load();
|
|
332
|
+
}, [load]);
|
|
333
|
+
// Keep the open detail sheet in sync with refreshed data.
|
|
334
|
+
React.useEffect(() => {
|
|
335
|
+
if (!selected)
|
|
336
|
+
return;
|
|
337
|
+
const fresh = packages.find((p) => p.manifest.id === selected.manifest.id);
|
|
338
|
+
if (fresh && fresh !== selected)
|
|
339
|
+
setSelected(fresh);
|
|
340
|
+
}, [packages, selected]);
|
|
341
|
+
const filtered = React.useMemo(() => {
|
|
342
|
+
const q = query.trim().toLowerCase();
|
|
343
|
+
return packages.filter((p) => {
|
|
344
|
+
const kernel = p.manifest.scope === 'system' || p.manifest.scope === 'cloud';
|
|
345
|
+
if (kernel && !showKernel)
|
|
346
|
+
return false;
|
|
347
|
+
if (!q)
|
|
348
|
+
return true;
|
|
349
|
+
return (p.manifest.id.toLowerCase().includes(q) ||
|
|
350
|
+
(p.manifest.name || '').toLowerCase().includes(q));
|
|
351
|
+
});
|
|
352
|
+
}, [packages, query, showKernel]);
|
|
353
|
+
const openDetail = (pkg) => {
|
|
354
|
+
setSelected(pkg);
|
|
355
|
+
setDetailOpen(true);
|
|
356
|
+
};
|
|
357
|
+
const onImportFile = async (e) => {
|
|
358
|
+
const file = e.target.files?.[0];
|
|
359
|
+
e.target.value = ''; // allow re-selecting the same file
|
|
360
|
+
if (!file)
|
|
361
|
+
return;
|
|
362
|
+
setImporting(true);
|
|
363
|
+
setImportMsg(null);
|
|
364
|
+
try {
|
|
365
|
+
const text = await file.text();
|
|
366
|
+
let manifest;
|
|
367
|
+
try {
|
|
368
|
+
manifest = JSON.parse(text);
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
throw new Error(t('engine.packages.import.invalidJson', locale));
|
|
372
|
+
}
|
|
373
|
+
if (!manifest || typeof manifest !== 'object' || (!manifest.id && !manifest.name)) {
|
|
374
|
+
throw new Error(t('engine.packages.import.invalidPackage', locale));
|
|
375
|
+
}
|
|
376
|
+
const res = await apiJson('/api/v1/marketplace/install-local', {
|
|
377
|
+
method: 'POST',
|
|
378
|
+
headers: { 'Content-Type': 'application/json' },
|
|
379
|
+
body: JSON.stringify({ manifest }),
|
|
380
|
+
});
|
|
381
|
+
setImportMsg({
|
|
382
|
+
kind: 'ok',
|
|
383
|
+
text: tFormat('engine.packages.import.success', locale, { id: res?.manifestId ?? manifest.id }),
|
|
384
|
+
});
|
|
385
|
+
await load();
|
|
386
|
+
}
|
|
387
|
+
catch (err) {
|
|
388
|
+
setImportMsg({ kind: 'err', text: err?.message ?? t('engine.packages.import.failed', locale) });
|
|
389
|
+
}
|
|
390
|
+
finally {
|
|
391
|
+
setImporting(false);
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
const kernelCount = packages.filter((p) => p.manifest.scope === 'system' || p.manifest.scope === 'cloud').length;
|
|
395
|
+
return (_jsxs("div", { className: "mx-auto w-full max-w-5xl px-6 py-6", children: [_jsxs("div", { className: "flex items-start justify-between gap-4", children: [_jsxs("div", { className: "flex items-start gap-3", children: [_jsx("div", { className: "rounded-lg bg-primary/10 p-2 text-primary", children: _jsx(PackageIcon, { className: "h-5 w-5" }) }), _jsxs("div", { children: [_jsx("h1", { className: "text-xl font-semibold tracking-tight", children: t('engine.packages.title', locale) }), _jsx("p", { className: "text-sm text-muted-foreground", children: t('engine.packages.description', locale) })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: () => void load(), disabled: loading, children: [_jsx(RefreshCw, { className: `mr-1.5 h-3.5 w-3.5 ${loading ? 'animate-spin' : ''}` }), t('engine.packages.refresh', locale)] }), _jsx("input", { ref: fileRef, type: "file", accept: "application/json,.json", className: "hidden", onChange: onImportFile }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => fileRef.current?.click(), disabled: importing, children: [_jsx(FileUp, { className: "mr-1.5 h-3.5 w-3.5" }), importing ? t('engine.packages.importing', locale) : t('engine.packages.import', locale)] }), _jsxs(Button, { size: "sm", onClick: () => setCreateOpen(true), children: [_jsx(Plus, { className: "mr-1.5 h-3.5 w-3.5" }), t('engine.packages.new', locale)] })] })] }), importMsg && (_jsx("div", { className: `mt-4 rounded-md border p-2 text-sm ${importMsg.kind === 'ok'
|
|
396
|
+
? 'border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400'
|
|
397
|
+
: 'border-destructive/40 bg-destructive/10 text-destructive'}`, children: importMsg.text })), _jsxs("div", { className: "mt-5 flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "relative w-full max-w-xs", children: [_jsx(Search, { className: "absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }), _jsx(Input, { className: "pl-8", placeholder: t('engine.packages.search', locale), value: query, onChange: (e) => setQuery(e.target.value) })] }), kernelCount > 0 && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Switch, { id: "show-kernel", checked: showKernel, onCheckedChange: setShowKernel }), _jsx(Label, { htmlFor: "show-kernel", className: "text-sm text-muted-foreground", children: tFormat('engine.packages.showPlatform', locale, { count: kernelCount }) })] }))] }), _jsx("div", { className: "mt-4 rounded-lg border", children: loading ? (_jsx("div", { className: "space-y-2 p-4", children: [0, 1, 2].map((i) => (_jsx(Skeleton, { className: "h-10 w-full" }, i))) })) : error ? (_jsxs("div", { className: "flex items-start gap-2 p-4 text-sm text-destructive", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-4 w-4 shrink-0" }), _jsx("span", { children: error })] })) : filtered.length === 0 ? (_jsx("div", { className: "p-8", children: _jsxs(Empty, { children: [_jsx(EmptyTitle, { children: t('engine.packages.empty', locale) }), _jsx(EmptyDescription, { children: packages.length === 0
|
|
398
|
+
? t('engine.packages.emptyCreate', locale)
|
|
399
|
+
: t('engine.packages.emptyFiltered', locale) })] }) })) : (_jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: t('engine.packages.col.name', locale) }), _jsx(TableHead, { children: "ID" }), _jsx(TableHead, { className: "w-24", children: t('engine.packages.col.version', locale) }), _jsx(TableHead, { className: "w-24", children: t('engine.packages.col.scope', locale) }), _jsx(TableHead, { className: "w-24", children: t('engine.packages.col.status', locale) })] }) }), _jsx(TableBody, { children: filtered.map((p) => (_jsxs(TableRow, { className: "cursor-pointer", onClick: () => openDetail(p), children: [_jsx(TableCell, { className: "font-medium", children: p.manifest.name || p.manifest.id }), _jsx(TableCell, { className: "font-mono text-xs text-muted-foreground", children: p.manifest.id }), _jsx(TableCell, { children: p.manifest.version || '—' }), _jsx(TableCell, { children: _jsx(ScopeBadge, { scope: p.manifest.scope }) }), _jsx(TableCell, { children: _jsx(StatusBadge, { pkg: p }) })] }, p.manifest.id))) })] })) }), _jsx(CreatePackageDialog, { open: createOpen, onOpenChange: setCreateOpen, onCreated: async () => {
|
|
400
|
+
await load();
|
|
401
|
+
} }), _jsx(PackageDetailSheet, { pkg: selected, appBase: appBase, open: detailOpen, onOpenChange: setDetailOpen, onChanged: () => void load() })] }));
|
|
402
|
+
}
|
|
403
|
+
export default PackagesPage;
|
|
@@ -31,4 +31,4 @@ export interface PageShellProps {
|
|
|
31
31
|
/** Page body. */
|
|
32
32
|
children: React.ReactNode;
|
|
33
33
|
}
|
|
34
|
-
export declare function PageShell({ entry, itemName, subtitle, stats, actions, children, }: PageShellProps):
|
|
34
|
+
export declare function PageShell({ entry, itemName, subtitle, stats, actions, children, }: PageShellProps): React.JSX.Element;
|