@rebasepro/plugin-insights 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 +115 -0
- package/dist/{plugin-insights/src/components → components}/CollectionInsightsInline.d.ts +2 -1
- package/dist/{plugin-insights/src/components → components}/HomeCardInsightSlot.d.ts +3 -2
- package/dist/{plugin-insights/src/components → components}/HomeInsightsSlot.d.ts +3 -2
- package/dist/{plugin-insights/src/components → components}/InsightWidget.d.ts +3 -2
- package/dist/{plugin-insights/src/components → components}/InsightWidgetSkeleton.d.ts +3 -2
- package/dist/{plugin-insights/src/components → components}/InsightsScorecardView.d.ts +3 -2
- package/dist/{plugin-insights/src/engine → engine}/InsightsProvider.d.ts +2 -2
- package/dist/{plugin-insights/src/index.d.ts → index.d.ts} +1 -1
- package/dist/index.es.js +583 -1072
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +645 -1096
- package/dist/index.umd.js.map +1 -1
- package/package.json +19 -14
- package/src/components/CollectionInsightsInline.tsx +3 -3
- package/src/components/HomeCardInsightSlot.tsx +1 -1
- package/src/components/HomeInsightsSlot.tsx +1 -1
- package/src/components/InsightWidget.tsx +4 -2
- package/src/components/InsightWidgetSkeleton.tsx +21 -13
- package/src/components/InsightsScorecardView.tsx +2 -2
- package/src/engine/InsightsCache.test.ts +5 -3
- package/src/engine/InsightsCache.ts +3 -2
- package/src/engine/useInsightsData.ts +3 -1
- package/src/index.ts +1 -1
- package/src/useInsightsPlugin.tsx +68 -65
- 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/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/dist/{plugin-insights/src/engine → engine}/InsightsCache.d.ts +0 -0
- /package/dist/{plugin-insights/src/engine → engine}/useInsightsData.d.ts +0 -0
- /package/dist/{plugin-insights/src/types → types}/engine.d.ts +0 -0
- /package/dist/{plugin-insights/src/types → types}/index.d.ts +0 -0
- /package/dist/{plugin-insights/src/types → types}/widgets.d.ts +0 -0
- /package/dist/{plugin-insights/src/useInsightsPlugin.d.ts → useInsightsPlugin.d.ts} +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# @rebasepro/plugin-insights
|
|
2
|
+
|
|
3
|
+
Scorecard and KPI widget plugin for the Rebase admin panel.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @rebasepro/plugin-insights
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Peer dependencies:** `react >= 19.0.0`, `react-dom >= 19.0.0`
|
|
12
|
+
|
|
13
|
+
## What This Package Does
|
|
14
|
+
|
|
15
|
+
This plugin injects data-driven scorecard widgets into the Rebase admin UI. You define insight definitions with custom `data()` callbacks — use the Rebase SDK, call a custom function, or hit any external API. The plugin handles caching, rendering, and slot injection.
|
|
16
|
+
|
|
17
|
+
Widgets appear in three locations automatically:
|
|
18
|
+
|
|
19
|
+
- **Home page header** — KPI overview cards via the `home.children.start` slot
|
|
20
|
+
- **Collection list view** — Inline scorecards below the title, above the data list via `collection.insights`
|
|
21
|
+
- **Home page cards** — Compact metrics auto-extracted from collection insights via `home.card.insight`
|
|
22
|
+
|
|
23
|
+
Collection-level insights are the single source of truth: define once under `collections.<slug>`, and they render both in the collection view and on the home card.
|
|
24
|
+
|
|
25
|
+
## Key Exports
|
|
26
|
+
|
|
27
|
+
| Export | Type | Description |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| `useInsightsPlugin` | Hook | Creates the plugin from an `InsightsPluginConfig`. Returns a `RebasePlugin` |
|
|
30
|
+
| `InsightsPluginConfig` | Type | Top-level config: `insights` (home + collections) and optional `cacheTTL` |
|
|
31
|
+
| `InsightDefinition` | Type | Single insight: `id`, `title`, `data()` callback, `scorecard` config |
|
|
32
|
+
| `InsightDataResult` | Type | Return type of `data()`: `{ rows: DataRow[] }` |
|
|
33
|
+
| `DataRow` | Type | `Record<string, string \| number \| boolean \| null>` |
|
|
34
|
+
| `ScorecardConfig` | Type | Field mapping for value, comparison, icon, dateRange |
|
|
35
|
+
| `ScorecardFormat` | Type | Number formatting: style (decimal/currency/percent), notation, currency, decimals, showSign |
|
|
36
|
+
| `InsightsProvider` | Component | React context provider (injected automatically by the plugin) |
|
|
37
|
+
| `useInsightsEngine` | Hook | Access the insights engine from context (advanced) |
|
|
38
|
+
| `InsightsCache` | Class | TTL-based cache for insight data (advanced) |
|
|
39
|
+
| `useInsightsData` | Hook | Fetch and cache data for a specific insight (advanced) |
|
|
40
|
+
| `InsightsScorecardView` | Component | Renders a scorecard from data + config (custom layouts) |
|
|
41
|
+
| `InsightWidget` | Component | Single insight widget container (custom layouts) |
|
|
42
|
+
| `InsightWidgetSkeleton` | Component | Loading placeholder for insight widgets |
|
|
43
|
+
|
|
44
|
+
### `InsightsPluginConfig`
|
|
45
|
+
|
|
46
|
+
| Prop | Type | Default | Description |
|
|
47
|
+
|---|---|---|---|
|
|
48
|
+
| `insights.home` | `InsightDefinition[]` | — | Insights shown at the top of the home page |
|
|
49
|
+
| `insights.collections` | `Record<string, InsightDefinition[]>` | — | Insights per collection slug |
|
|
50
|
+
| `cacheTTL` | `number` | `60_000` | Cache TTL in milliseconds |
|
|
51
|
+
|
|
52
|
+
### `ScorecardConfig`
|
|
53
|
+
|
|
54
|
+
| Prop | Type | Description |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| `value.field` | `string` | Column name from data rows for the main value |
|
|
57
|
+
| `value.format` | `ScorecardFormat` | Number formatting options |
|
|
58
|
+
| `comparison.field` | `string` | Column name for comparison/delta value |
|
|
59
|
+
| `comparison.format` | `ScorecardFormat` | Formatting for comparison |
|
|
60
|
+
| `comparison.intent` | `"increase_is_good" \| "decrease_is_good"` | Controls green/red coloring |
|
|
61
|
+
| `icon` | `string` | Icon key (e.g., `"shopping_cart"`) |
|
|
62
|
+
| `dateRange` | `string` | Label text (e.g., `"Last 30 days"`) |
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { useInsightsPlugin } from "@rebasepro/plugin-insights";
|
|
68
|
+
|
|
69
|
+
const insightsPlugin = useInsightsPlugin({
|
|
70
|
+
cacheTTL: 120_000,
|
|
71
|
+
insights: {
|
|
72
|
+
home: [
|
|
73
|
+
{
|
|
74
|
+
id: "revenue",
|
|
75
|
+
title: "Revenue",
|
|
76
|
+
data: async () => {
|
|
77
|
+
const res = await fetch("/api/analytics/revenue");
|
|
78
|
+
return { rows: [await res.json()] };
|
|
79
|
+
},
|
|
80
|
+
scorecard: {
|
|
81
|
+
value: { field: "total", format: { style: "currency", currency: "USD", notation: "compact" } },
|
|
82
|
+
comparison: { field: "delta_pct", format: { style: "percent", decimals: 1 }, intent: "increase_is_good" },
|
|
83
|
+
icon: "attach_money",
|
|
84
|
+
dateRange: "Last 30 days"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
collections: {
|
|
89
|
+
orders: [
|
|
90
|
+
{
|
|
91
|
+
id: "total_orders",
|
|
92
|
+
title: "Total Orders",
|
|
93
|
+
data: async () => {
|
|
94
|
+
const count = await rebaseClient.data.orders.count();
|
|
95
|
+
return { rows: [{ total: count }] };
|
|
96
|
+
},
|
|
97
|
+
scorecard: {
|
|
98
|
+
value: { field: "total", format: { style: "decimal", notation: "compact" } },
|
|
99
|
+
icon: "shopping_cart"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Pass to your Rebase app:
|
|
108
|
+
<RebaseFirebaseApp plugins={[insightsPlugin]} />
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Related Packages
|
|
112
|
+
|
|
113
|
+
- `@rebasepro/core` — Core framework providing the plugin system
|
|
114
|
+
- `@rebasepro/types` — Shared types (`RebasePlugin`, `SlotContribution`)
|
|
115
|
+
- `@rebasepro/ui` — UI components used by insight widgets
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import type { InsightDefinition } from "../types";
|
|
2
3
|
/**
|
|
3
4
|
* Renders scorecard insight widgets inline within a collection's list view,
|
|
@@ -11,7 +12,7 @@ export declare function CollectionInsightsInline({ insights, path, parentCollect
|
|
|
11
12
|
parentCollectionSlugs: string[];
|
|
12
13
|
parentEntityIds: string[];
|
|
13
14
|
insights: InsightDefinition[];
|
|
14
|
-
}):
|
|
15
|
+
}): React.JSX.Element | null;
|
|
15
16
|
export declare namespace CollectionInsightsInline {
|
|
16
17
|
var displayName: string;
|
|
17
18
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import type { InsightDefinition } from "../types";
|
|
2
3
|
/**
|
|
3
4
|
* Renders compact insight widgets inline within a home page collection card.
|
|
@@ -5,12 +6,12 @@ import type { InsightDefinition } from "../types";
|
|
|
5
6
|
*
|
|
6
7
|
* Uses a horizontal flex layout so multiple cards sit side by side.
|
|
7
8
|
*/
|
|
8
|
-
export declare function HomeCardInsightSlot({ slug, insights
|
|
9
|
+
export declare function HomeCardInsightSlot({ slug, insights }: {
|
|
9
10
|
slug: string;
|
|
10
11
|
collection: unknown;
|
|
11
12
|
context: unknown;
|
|
12
13
|
insights: InsightDefinition[];
|
|
13
|
-
}):
|
|
14
|
+
}): React.JSX.Element | null;
|
|
14
15
|
export declare namespace HomeCardInsightSlot {
|
|
15
16
|
var displayName: string;
|
|
16
17
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import type { InsightDefinition } from "../types";
|
|
2
3
|
/**
|
|
3
4
|
* Scorecard insights panel rendered at the top of the home page.
|
|
@@ -5,9 +6,9 @@ import type { InsightDefinition } from "../types";
|
|
|
5
6
|
*
|
|
6
7
|
* Renders scorecards in a responsive grid (up to 4 columns).
|
|
7
8
|
*/
|
|
8
|
-
export declare function HomeInsightsSlot({ insights
|
|
9
|
+
export declare function HomeInsightsSlot({ insights }: {
|
|
9
10
|
insights: InsightDefinition[];
|
|
10
|
-
}):
|
|
11
|
+
}): React.JSX.Element | null;
|
|
11
12
|
export declare namespace HomeInsightsSlot {
|
|
12
13
|
var displayName: string;
|
|
13
14
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import type { InsightDefinition } from "../types";
|
|
2
3
|
/**
|
|
3
4
|
* Single insight widget orchestrator.
|
|
@@ -7,7 +8,7 @@ import type { InsightDefinition } from "../types";
|
|
|
7
8
|
*
|
|
8
9
|
* All theme-awareness is handled via Tailwind `dark:` classes.
|
|
9
10
|
*/
|
|
10
|
-
export declare function InsightWidget({ definition, collectionSlug, path, parentCollectionSlugs, parentEntityIds, compact, embedded
|
|
11
|
+
export declare function InsightWidget({ definition, collectionSlug, path, parentCollectionSlugs, parentEntityIds, compact, embedded }: {
|
|
11
12
|
definition: InsightDefinition;
|
|
12
13
|
collectionSlug?: string;
|
|
13
14
|
path?: string;
|
|
@@ -16,7 +17,7 @@ export declare function InsightWidget({ definition, collectionSlug, path, parent
|
|
|
16
17
|
compact?: boolean;
|
|
17
18
|
/** When true, inner views skip their own borders since the parent card provides them. */
|
|
18
19
|
embedded?: boolean;
|
|
19
|
-
}):
|
|
20
|
+
}): React.JSX.Element;
|
|
20
21
|
export declare namespace InsightWidget {
|
|
21
22
|
var displayName: string;
|
|
22
23
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import type { ScorecardConfig } from "../types";
|
|
2
3
|
/**
|
|
3
4
|
* Skeleton loader for scorecard insight widgets — displays animated
|
|
@@ -14,7 +15,7 @@ import type { ScorecardConfig } from "../types";
|
|
|
14
15
|
* Tailwind line-heights (accounting for `leading-*` overrides).
|
|
15
16
|
* This guarantees a pixel-perfect skeleton → loaded transition.
|
|
16
17
|
*/
|
|
17
|
-
export declare function InsightWidgetSkeleton({ config, compact, embedded, fixedHeight
|
|
18
|
+
export declare function InsightWidgetSkeleton({ config, compact, embedded, fixedHeight }: {
|
|
18
19
|
/** Scorecard config — used to match optional elements (comparison, dateRange, icon). */
|
|
19
20
|
config: ScorecardConfig;
|
|
20
21
|
compact?: boolean;
|
|
@@ -22,7 +23,7 @@ export declare function InsightWidgetSkeleton({ config, compact, embedded, fixed
|
|
|
22
23
|
embedded?: boolean;
|
|
23
24
|
/** Explicit height to prevent layout shift between skeleton → loaded. */
|
|
24
25
|
fixedHeight?: number;
|
|
25
|
-
}):
|
|
26
|
+
}): React.JSX.Element;
|
|
26
27
|
export declare namespace InsightWidgetSkeleton {
|
|
27
28
|
var displayName: string;
|
|
28
29
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import type { DataRow, ScorecardConfig } from "../types";
|
|
2
3
|
/**
|
|
3
4
|
* Scorecard widget for the Rebase design system.
|
|
@@ -6,7 +7,7 @@ import type { DataRow, ScorecardConfig } from "../types";
|
|
|
6
7
|
* Uses Tailwind `dark:` classes — no JS dark mode detection.
|
|
7
8
|
* Icons are resolved via `getIcon` from `@rebasepro/core`.
|
|
8
9
|
*/
|
|
9
|
-
export declare function InsightsScorecardView({ config, data, title, compact, embedded, fixedHeight
|
|
10
|
+
export declare function InsightsScorecardView({ config, data, title, compact, embedded, fixedHeight }: {
|
|
10
11
|
config: ScorecardConfig;
|
|
11
12
|
data: DataRow;
|
|
12
13
|
title: string;
|
|
@@ -15,7 +16,7 @@ export declare function InsightsScorecardView({ config, data, title, compact, em
|
|
|
15
16
|
embedded?: boolean;
|
|
16
17
|
/** Explicit height to prevent layout shift between skeleton → loaded. */
|
|
17
18
|
fixedHeight?: number;
|
|
18
|
-
}):
|
|
19
|
+
}): React.JSX.Element;
|
|
19
20
|
export declare namespace InsightsScorecardView {
|
|
20
21
|
var displayName: string;
|
|
21
22
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PropsWithChildren } from "react";
|
|
1
|
+
import React, { type PropsWithChildren } from "react";
|
|
2
2
|
import { InsightsCache } from "./InsightsCache";
|
|
3
3
|
interface InsightsContextValue {
|
|
4
4
|
cache: InsightsCache;
|
|
@@ -12,7 +12,7 @@ interface InsightsContextValue {
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function InsightsProvider({ cacheTTL, children }: PropsWithChildren<{
|
|
14
14
|
cacheTTL?: number;
|
|
15
|
-
}>):
|
|
15
|
+
}>): React.JSX.Element;
|
|
16
16
|
/**
|
|
17
17
|
* Access the insights cache (for advanced usage).
|
|
18
18
|
* Returns null when called outside of an `InsightsProvider`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { DataRow, ScorecardFormat, ScorecardConfig, InsightDataResult, InsightDefinition, InsightsPluginConfig
|
|
1
|
+
export type { DataRow, ScorecardFormat, ScorecardConfig, InsightDataResult, InsightDefinition, InsightsPluginConfig } from "./types";
|
|
2
2
|
export { useInsightsPlugin } from "./useInsightsPlugin";
|
|
3
3
|
export { InsightsProvider, useInsightsEngine } from "./engine/InsightsProvider";
|
|
4
4
|
export { InsightsCache } from "./engine/InsightsCache";
|