@rebasepro/plugin-insights 0.0.1-canary.e259309 → 0.0.1-canary.eb08332
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -6
- package/README.md +115 -0
- package/dist/{plugin-insights/src/components → components}/CollectionInsightsInline.d.ts +5 -3
- 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 +8 -4
- package/dist/{plugin-insights/src/components → components}/InsightWidgetSkeleton.d.ts +11 -2
- package/dist/{plugin-insights/src/components → components}/InsightsScorecardView.d.ts +6 -3
- package/dist/{plugin-insights/src/engine → engine}/InsightsProvider.d.ts +2 -2
- package/dist/{plugin-insights/src/engine → engine}/useInsightsData.d.ts +2 -2
- package/dist/{plugin-insights/src/index.d.ts → index.d.ts} +1 -1
- package/dist/index.es.js +587 -923
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +645 -943
- package/dist/index.umd.js.map +1 -1
- package/dist/{plugin-insights/src/types → types}/engine.d.ts +10 -1
- package/package.json +27 -18
- package/src/components/CollectionInsightsInline.tsx +10 -2
- package/src/components/HomeCardInsightSlot.tsx +6 -2
- package/src/components/HomeInsightsSlot.tsx +1 -1
- package/src/components/InsightWidget.tsx +41 -6
- package/src/components/InsightWidgetSkeleton.tsx +134 -38
- package/src/components/InsightsScorecardView.tsx +7 -4
- package/src/engine/InsightsCache.test.ts +58 -0
- package/src/engine/InsightsCache.ts +3 -2
- package/src/engine/useInsightsData.ts +10 -7
- package/src/index.ts +1 -1
- package/src/types/engine.ts +11 -1
- package/src/useInsightsPlugin.tsx +68 -65
- package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
- package/dist/common/src/collections/index.d.ts +0 -1
- package/dist/common/src/data/buildRebaseData.d.ts +0 -14
- package/dist/common/src/index.d.ts +0 -3
- 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 -5
- 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/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 -68
- 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 -63
- 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 -16
- 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 -136
- 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 -51
- 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 -38
- 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 -12
- 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/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/hooks/useValidateAuthenticator.d.ts +0 -21
- 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 -27
- 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/icon_synonyms.d.ts +0 -1
- package/dist/core/src/util/icons.d.ts +0 -20
- package/dist/core/src/util/index.d.ts +0 -10
- package/dist/core/src/util/previews.d.ts +0 -4
- package/dist/core/src/util/useStorageUploadController.d.ts +0 -38
- package/dist/core/src/util/useTraceUpdate.d.ts +0 -2
- 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 -119
- package/dist/types/src/controllers/client.d.ts +0 -170
- package/dist/types/src/controllers/collection_registry.d.ts +0 -45
- package/dist/types/src/controllers/customization_controller.d.ts +0 -60
- package/dist/types/src/controllers/data.d.ts +0 -168
- package/dist/types/src/controllers/data_driver.d.ts +0 -160
- 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 -34
- 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 -213
- package/dist/types/src/controllers/registry.d.ts +0 -54
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
- package/dist/types/src/controllers/side_entity_controller.d.ts +0 -90
- 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 -105
- package/dist/types/src/types/backend.d.ts +0 -536
- 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 -856
- 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/entities.d.ts +0 -145
- package/dist/types/src/types/entity_actions.d.ts +0 -98
- 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 -61
- package/dist/types/src/types/export_import.d.ts +0 -21
- package/dist/types/src/types/index.d.ts +0 -23
- 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 -279
- package/dist/types/src/types/properties.d.ts +0 -1176
- package/dist/types/src/types/property_config.d.ts +0 -70
- package/dist/types/src/types/relations.d.ts +0 -336
- package/dist/types/src/types/slots.d.ts +0 -252
- package/dist/types/src/types/translations.d.ts +0 -870
- package/dist/types/src/types/user_management_delegate.d.ts +0 -121
- package/dist/types/src/types/websockets.d.ts +0 -78
- package/dist/types/src/users/index.d.ts +0 -2
- package/dist/types/src/users/roles.d.ts +0 -22
- package/dist/types/src/users/user.d.ts +0 -46
- 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 -9
- 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 -11
- 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/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 -22
- 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 -243
- 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 -53
- 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 -6
- 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/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/LICENSE
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rebase
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
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/app` — 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,
|
|
@@ -5,12 +6,13 @@ import type { InsightDefinition } from "../types";
|
|
|
5
6
|
*
|
|
6
7
|
* Injected via the `collection.insights` slot.
|
|
7
8
|
*/
|
|
8
|
-
export declare function CollectionInsightsInline({ insights, }: {
|
|
9
|
+
export declare function CollectionInsightsInline({ insights, path, parentCollectionSlugs, parentEntityIds }: {
|
|
9
10
|
path: string;
|
|
10
11
|
collection: unknown;
|
|
11
|
-
|
|
12
|
+
parentCollectionSlugs: string[];
|
|
13
|
+
parentEntityIds: string[];
|
|
12
14
|
insights: InsightDefinition[];
|
|
13
|
-
}):
|
|
15
|
+
}): React.JSX.Element | null;
|
|
14
16
|
export declare namespace CollectionInsightsInline {
|
|
15
17
|
var displayName: string;
|
|
16
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,19 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import type { InsightDefinition } from "../types";
|
|
2
3
|
/**
|
|
3
4
|
* Single insight widget orchestrator.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* Wraps skeleton and loaded states in a fixed-height container
|
|
7
|
+
* (computed from the scorecard config) to prevent layout shift.
|
|
7
8
|
*
|
|
8
9
|
* All theme-awareness is handled via Tailwind `dark:` classes.
|
|
9
10
|
*/
|
|
10
|
-
export declare function InsightWidget({ definition, collectionSlug, compact, embedded
|
|
11
|
+
export declare function InsightWidget({ definition, collectionSlug, path, parentCollectionSlugs, parentEntityIds, compact, embedded }: {
|
|
11
12
|
definition: InsightDefinition;
|
|
12
13
|
collectionSlug?: string;
|
|
14
|
+
path?: string;
|
|
15
|
+
parentCollectionSlugs?: string[];
|
|
16
|
+
parentEntityIds?: string[];
|
|
13
17
|
compact?: boolean;
|
|
14
18
|
/** When true, inner views skip their own borders since the parent card provides them. */
|
|
15
19
|
embedded?: boolean;
|
|
16
|
-
}):
|
|
20
|
+
}): React.JSX.Element;
|
|
17
21
|
export declare namespace InsightWidget {
|
|
18
22
|
var displayName: string;
|
|
19
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
|
|
@@ -7,14 +8,22 @@ import type { ScorecardConfig } from "../types";
|
|
|
7
8
|
* The skeleton receives the scorecard config so it can conditionally
|
|
8
9
|
* render placeholder lines for comparison, dateRange, and icon —
|
|
9
10
|
* only when the loaded view will also render them.
|
|
11
|
+
*
|
|
12
|
+
* The standard skeleton mirrors InsightsScorecardView's responsive
|
|
13
|
+
* container-width breakpoints (ResizeObserver → isSmall / isMedium)
|
|
14
|
+
* and uses placeholder heights that exactly match the **computed**
|
|
15
|
+
* Tailwind line-heights (accounting for `leading-*` overrides).
|
|
16
|
+
* This guarantees a pixel-perfect skeleton → loaded transition.
|
|
10
17
|
*/
|
|
11
|
-
export declare function InsightWidgetSkeleton({ config, compact, embedded, }: {
|
|
18
|
+
export declare function InsightWidgetSkeleton({ config, compact, embedded, fixedHeight }: {
|
|
12
19
|
/** Scorecard config — used to match optional elements (comparison, dateRange, icon). */
|
|
13
20
|
config: ScorecardConfig;
|
|
14
21
|
compact?: boolean;
|
|
15
22
|
/** When true, skip own border since the parent card provides it. */
|
|
16
23
|
embedded?: boolean;
|
|
17
|
-
|
|
24
|
+
/** Explicit height to prevent layout shift between skeleton → loaded. */
|
|
25
|
+
fixedHeight?: number;
|
|
26
|
+
}): React.JSX.Element;
|
|
18
27
|
export declare namespace InsightWidgetSkeleton {
|
|
19
28
|
var displayName: string;
|
|
20
29
|
}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import type { DataRow, ScorecardConfig } from "../types";
|
|
2
3
|
/**
|
|
3
4
|
* Scorecard widget for the Rebase design system.
|
|
4
5
|
*
|
|
5
6
|
* Renders a single KPI metric with optional comparison value and icon.
|
|
6
7
|
* Uses Tailwind `dark:` classes — no JS dark mode detection.
|
|
7
|
-
* Icons are resolved via `getIcon` from `@rebasepro/
|
|
8
|
+
* Icons are resolved via `getIcon` from `@rebasepro/app`.
|
|
8
9
|
*/
|
|
9
|
-
export declare function InsightsScorecardView({ config, data, title, compact, embedded, }: {
|
|
10
|
+
export declare function InsightsScorecardView({ config, data, title, compact, embedded, fixedHeight }: {
|
|
10
11
|
config: ScorecardConfig;
|
|
11
12
|
data: DataRow;
|
|
12
13
|
title: string;
|
|
13
14
|
compact?: boolean;
|
|
14
15
|
/** When true, skip own border/bg since the parent card provides them. */
|
|
15
16
|
embedded?: boolean;
|
|
16
|
-
|
|
17
|
+
/** Explicit height to prevent layout shift between skeleton → loaded. */
|
|
18
|
+
fixedHeight?: number;
|
|
19
|
+
}): React.JSX.Element;
|
|
17
20
|
export declare namespace InsightsScorecardView {
|
|
18
21
|
var displayName: string;
|
|
19
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
|
-
import type { InsightDefinition, InsightDataResult } from "../types";
|
|
1
|
+
import type { InsightDefinition, InsightDataResult, InsightContext } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Hook that fetches and caches data for a single insight definition.
|
|
4
4
|
*
|
|
@@ -10,7 +10,7 @@ import type { InsightDefinition, InsightDataResult } from "../types";
|
|
|
10
10
|
* @param definition - The insight to fetch data for
|
|
11
11
|
* @param collectionSlug - Optional collection context for cache key scoping
|
|
12
12
|
*/
|
|
13
|
-
export declare function useInsightsData(definition: InsightDefinition,
|
|
13
|
+
export declare function useInsightsData(definition: InsightDefinition, context: InsightContext): {
|
|
14
14
|
data: InsightDataResult | null;
|
|
15
15
|
loading: boolean;
|
|
16
16
|
error: Error | null;
|
|
@@ -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";
|