@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.
Files changed (304) hide show
  1. package/README.md +115 -0
  2. package/dist/{plugin-insights/src/components → components}/CollectionInsightsInline.d.ts +2 -1
  3. package/dist/{plugin-insights/src/components → components}/HomeCardInsightSlot.d.ts +3 -2
  4. package/dist/{plugin-insights/src/components → components}/HomeInsightsSlot.d.ts +3 -2
  5. package/dist/{plugin-insights/src/components → components}/InsightWidget.d.ts +3 -2
  6. package/dist/{plugin-insights/src/components → components}/InsightWidgetSkeleton.d.ts +3 -2
  7. package/dist/{plugin-insights/src/components → components}/InsightsScorecardView.d.ts +3 -2
  8. package/dist/{plugin-insights/src/engine → engine}/InsightsProvider.d.ts +2 -2
  9. package/dist/{plugin-insights/src/index.d.ts → index.d.ts} +1 -1
  10. package/dist/index.es.js +583 -1072
  11. package/dist/index.es.js.map +1 -1
  12. package/dist/index.umd.js +645 -1096
  13. package/dist/index.umd.js.map +1 -1
  14. package/package.json +19 -14
  15. package/src/components/CollectionInsightsInline.tsx +3 -3
  16. package/src/components/HomeCardInsightSlot.tsx +1 -1
  17. package/src/components/HomeInsightsSlot.tsx +1 -1
  18. package/src/components/InsightWidget.tsx +4 -2
  19. package/src/components/InsightWidgetSkeleton.tsx +21 -13
  20. package/src/components/InsightsScorecardView.tsx +2 -2
  21. package/src/engine/InsightsCache.test.ts +5 -3
  22. package/src/engine/InsightsCache.ts +3 -2
  23. package/src/engine/useInsightsData.ts +3 -1
  24. package/src/index.ts +1 -1
  25. package/src/useInsightsPlugin.tsx +68 -65
  26. package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
  27. package/dist/common/src/collections/default-collections.d.ts +0 -9
  28. package/dist/common/src/collections/index.d.ts +0 -2
  29. package/dist/common/src/data/buildRebaseData.d.ts +0 -14
  30. package/dist/common/src/data/query_builder.d.ts +0 -55
  31. package/dist/common/src/index.d.ts +0 -4
  32. package/dist/common/src/util/builders.d.ts +0 -57
  33. package/dist/common/src/util/callbacks.d.ts +0 -6
  34. package/dist/common/src/util/collections.d.ts +0 -11
  35. package/dist/common/src/util/common.d.ts +0 -2
  36. package/dist/common/src/util/conditions.d.ts +0 -26
  37. package/dist/common/src/util/entities.d.ts +0 -58
  38. package/dist/common/src/util/enums.d.ts +0 -3
  39. package/dist/common/src/util/index.d.ts +0 -16
  40. package/dist/common/src/util/navigation_from_path.d.ts +0 -34
  41. package/dist/common/src/util/navigation_utils.d.ts +0 -20
  42. package/dist/common/src/util/parent_references_from_path.d.ts +0 -6
  43. package/dist/common/src/util/paths.d.ts +0 -14
  44. package/dist/common/src/util/permissions.d.ts +0 -6
  45. package/dist/common/src/util/references.d.ts +0 -2
  46. package/dist/common/src/util/relations.d.ts +0 -22
  47. package/dist/common/src/util/resolutions.d.ts +0 -72
  48. package/dist/common/src/util/storage.d.ts +0 -24
  49. package/dist/core/src/components/AIIcon.d.ts +0 -16
  50. package/dist/core/src/components/BootstrapAdminBanner.d.ts +0 -4
  51. package/dist/core/src/components/ConfirmationDialog.d.ts +0 -9
  52. package/dist/core/src/components/Debug/UIReferenceView.d.ts +0 -1
  53. package/dist/core/src/components/Debug/UIStyleGuide.d.ts +0 -1
  54. package/dist/core/src/components/ErrorTooltip.d.ts +0 -2
  55. package/dist/core/src/components/ErrorView.d.ts +0 -21
  56. package/dist/core/src/components/LanguageToggle.d.ts +0 -1
  57. package/dist/core/src/components/LoginView/LoginView.d.ts +0 -109
  58. package/dist/core/src/components/LoginView/index.d.ts +0 -2
  59. package/dist/core/src/components/NotFoundPage.d.ts +0 -1
  60. package/dist/core/src/components/RebaseAuth.d.ts +0 -10
  61. package/dist/core/src/components/RebaseLogo.d.ts +0 -7
  62. package/dist/core/src/components/UnsavedChangesDialog.d.ts +0 -9
  63. package/dist/core/src/components/UserDisplay.d.ts +0 -7
  64. package/dist/core/src/components/UserSelectPopover.d.ts +0 -62
  65. package/dist/core/src/components/UserSettingsView.d.ts +0 -1
  66. package/dist/core/src/components/common/index.d.ts +0 -6
  67. package/dist/core/src/components/common/table_height.d.ts +0 -5
  68. package/dist/core/src/components/common/types.d.ts +0 -66
  69. package/dist/core/src/components/common/useColumnsIds.d.ts +0 -9
  70. package/dist/core/src/components/common/useDataTableController.d.ts +0 -45
  71. package/dist/core/src/components/common/useDebouncedData.d.ts +0 -9
  72. package/dist/core/src/components/common/useScrollRestoration.d.ts +0 -14
  73. package/dist/core/src/components/index.d.ts +0 -17
  74. package/dist/core/src/contexts/AdminModeController.d.ts +0 -4
  75. package/dist/core/src/contexts/AnalyticsContext.d.ts +0 -3
  76. package/dist/core/src/contexts/AuthControllerContext.d.ts +0 -3
  77. package/dist/core/src/contexts/CustomizationControllerContext.d.ts +0 -3
  78. package/dist/core/src/contexts/DataDriverContext.d.ts +0 -3
  79. package/dist/core/src/contexts/DatabaseAdminContext.d.ts +0 -3
  80. package/dist/core/src/contexts/DialogsProvider.d.ts +0 -4
  81. package/dist/core/src/contexts/EffectiveRoleController.d.ts +0 -4
  82. package/dist/core/src/contexts/InternalUserManagementContext.d.ts +0 -3
  83. package/dist/core/src/contexts/ModeController.d.ts +0 -4
  84. package/dist/core/src/contexts/RebaseClientInstanceContext.d.ts +0 -6
  85. package/dist/core/src/contexts/RebaseDataContext.d.ts +0 -3
  86. package/dist/core/src/contexts/SnackbarProvider.d.ts +0 -2
  87. package/dist/core/src/contexts/StorageSourceContext.d.ts +0 -3
  88. package/dist/core/src/contexts/UserConfigurationPersistenceContext.d.ts +0 -3
  89. package/dist/core/src/contexts/index.d.ts +0 -13
  90. package/dist/core/src/core/PluginLifecycleManager.d.ts +0 -17
  91. package/dist/core/src/core/PluginProviderStack.d.ts +0 -21
  92. package/dist/core/src/core/Rebase.d.ts +0 -14
  93. package/dist/core/src/core/RebaseProps.d.ts +0 -147
  94. package/dist/core/src/core/RebaseRouter.d.ts +0 -4
  95. package/dist/core/src/core/RebaseRoutes.d.ts +0 -17
  96. package/dist/core/src/core/index.d.ts +0 -4
  97. package/dist/core/src/hooks/ApiConfigContext.d.ts +0 -24
  98. package/dist/core/src/hooks/data/delete.d.ts +0 -31
  99. package/dist/core/src/hooks/data/save.d.ts +0 -34
  100. package/dist/core/src/hooks/data/useCollectionFetch.d.ts +0 -62
  101. package/dist/core/src/hooks/data/useData.d.ts +0 -13
  102. package/dist/core/src/hooks/data/useDataOrder.d.ts +0 -12
  103. package/dist/core/src/hooks/data/useEntityFetch.d.ts +0 -43
  104. package/dist/core/src/hooks/data/useRelationSelector.d.ts +0 -52
  105. package/dist/core/src/hooks/data/useUserSelector.d.ts +0 -31
  106. package/dist/core/src/hooks/index.d.ts +0 -37
  107. package/dist/core/src/hooks/useAdminModeController.d.ts +0 -19
  108. package/dist/core/src/hooks/useAnalyticsController.d.ts +0 -5
  109. package/dist/core/src/hooks/useAuthController.d.ts +0 -11
  110. package/dist/core/src/hooks/useAuthSubscription.d.ts +0 -2
  111. package/dist/core/src/hooks/useBackendStorageSource.d.ts +0 -30
  112. package/dist/core/src/hooks/useBridgeRegistration.d.ts +0 -18
  113. package/dist/core/src/hooks/useBrowserTitleAndIcon.d.ts +0 -6
  114. package/dist/core/src/hooks/useBuildAdminModeController.d.ts +0 -6
  115. package/dist/core/src/hooks/useBuildEffectiveRoleController.d.ts +0 -8
  116. package/dist/core/src/hooks/useBuildLocalConfigurationPersistence.d.ts +0 -2
  117. package/dist/core/src/hooks/useBuildModeController.d.ts +0 -6
  118. package/dist/core/src/hooks/useClipboard.d.ts +0 -57
  119. package/dist/core/src/hooks/useCollapsedGroups.d.ts +0 -27
  120. package/dist/core/src/hooks/useCustomizationController.d.ts +0 -11
  121. package/dist/core/src/hooks/useDialogsController.d.ts +0 -11
  122. package/dist/core/src/hooks/useEffectiveRoleController.d.ts +0 -7
  123. package/dist/core/src/hooks/useInternalUserManagementController.d.ts +0 -12
  124. package/dist/core/src/hooks/useLargeLayout.d.ts +0 -1
  125. package/dist/core/src/hooks/useModeController.d.ts +0 -19
  126. package/dist/core/src/hooks/usePermissions.d.ts +0 -12
  127. package/dist/core/src/hooks/useRebaseClient.d.ts +0 -5
  128. package/dist/core/src/hooks/useRebaseContext.d.ts +0 -11
  129. package/dist/core/src/hooks/useRebaseRegistry.d.ts +0 -34
  130. package/dist/core/src/hooks/useResolvedComponent.d.ts +0 -47
  131. package/dist/core/src/hooks/useSlot.d.ts +0 -18
  132. package/dist/core/src/hooks/useSnackbarController.d.ts +0 -20
  133. package/dist/core/src/hooks/useStorageSource.d.ts +0 -7
  134. package/dist/core/src/hooks/useStudioBridge.d.ts +0 -91
  135. package/dist/core/src/hooks/useTranslation.d.ts +0 -17
  136. package/dist/core/src/hooks/useUnsavedChangesDialog.d.ts +0 -12
  137. package/dist/core/src/hooks/useUserConfigurationPersistence.d.ts +0 -8
  138. package/dist/core/src/i18n/RebaseI18nProvider.d.ts +0 -33
  139. package/dist/core/src/index.d.ts +0 -15
  140. package/dist/core/src/internal/common.d.ts +0 -3
  141. package/dist/core/src/internal/useRestoreScroll.d.ts +0 -6
  142. package/dist/core/src/locales/de.d.ts +0 -2
  143. package/dist/core/src/locales/en.d.ts +0 -10
  144. package/dist/core/src/locales/es.d.ts +0 -10
  145. package/dist/core/src/locales/fr.d.ts +0 -2
  146. package/dist/core/src/locales/hi.d.ts +0 -2
  147. package/dist/core/src/locales/it.d.ts +0 -2
  148. package/dist/core/src/locales/pt.d.ts +0 -7
  149. package/dist/core/src/util/constants.d.ts +0 -1
  150. package/dist/core/src/util/createFormexStub.d.ts +0 -2
  151. package/dist/core/src/util/entity_cache.d.ts +0 -22
  152. package/dist/core/src/util/enums.d.ts +0 -5
  153. package/dist/core/src/util/icon_list.d.ts +0 -5
  154. package/dist/core/src/util/icons.d.ts +0 -20
  155. package/dist/core/src/util/index.d.ts +0 -8
  156. package/dist/core/src/util/previews.d.ts +0 -4
  157. package/dist/core/src/util/useStorageUploadController.d.ts +0 -38
  158. package/dist/formex/src/Field.d.ts +0 -52
  159. package/dist/formex/src/Formex.d.ts +0 -7
  160. package/dist/formex/src/index.d.ts +0 -5
  161. package/dist/formex/src/types.d.ts +0 -40
  162. package/dist/formex/src/useCreateFormex.d.ts +0 -14
  163. package/dist/formex/src/utils.d.ts +0 -16
  164. package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
  165. package/dist/types/src/controllers/auth.d.ts +0 -104
  166. package/dist/types/src/controllers/client.d.ts +0 -168
  167. package/dist/types/src/controllers/collection_registry.d.ts +0 -46
  168. package/dist/types/src/controllers/customization_controller.d.ts +0 -60
  169. package/dist/types/src/controllers/data.d.ts +0 -207
  170. package/dist/types/src/controllers/data_driver.d.ts +0 -218
  171. package/dist/types/src/controllers/database_admin.d.ts +0 -11
  172. package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
  173. package/dist/types/src/controllers/effective_role.d.ts +0 -4
  174. package/dist/types/src/controllers/email.d.ts +0 -36
  175. package/dist/types/src/controllers/index.d.ts +0 -18
  176. package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
  177. package/dist/types/src/controllers/navigation.d.ts +0 -225
  178. package/dist/types/src/controllers/registry.d.ts +0 -63
  179. package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
  180. package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
  181. package/dist/types/src/controllers/snackbar.d.ts +0 -24
  182. package/dist/types/src/controllers/storage.d.ts +0 -171
  183. package/dist/types/src/index.d.ts +0 -4
  184. package/dist/types/src/rebase_context.d.ts +0 -122
  185. package/dist/types/src/types/auth_adapter.d.ts +0 -301
  186. package/dist/types/src/types/backend.d.ts +0 -536
  187. package/dist/types/src/types/backend_hooks.d.ts +0 -172
  188. package/dist/types/src/types/builders.d.ts +0 -15
  189. package/dist/types/src/types/chips.d.ts +0 -5
  190. package/dist/types/src/types/collections.d.ts +0 -941
  191. package/dist/types/src/types/component_ref.d.ts +0 -47
  192. package/dist/types/src/types/cron.d.ts +0 -102
  193. package/dist/types/src/types/data_source.d.ts +0 -64
  194. package/dist/types/src/types/database_adapter.d.ts +0 -94
  195. package/dist/types/src/types/entities.d.ts +0 -145
  196. package/dist/types/src/types/entity_actions.d.ts +0 -104
  197. package/dist/types/src/types/entity_callbacks.d.ts +0 -173
  198. package/dist/types/src/types/entity_link_builder.d.ts +0 -7
  199. package/dist/types/src/types/entity_overrides.d.ts +0 -10
  200. package/dist/types/src/types/entity_views.d.ts +0 -87
  201. package/dist/types/src/types/export_import.d.ts +0 -21
  202. package/dist/types/src/types/formex.d.ts +0 -40
  203. package/dist/types/src/types/index.d.ts +0 -28
  204. package/dist/types/src/types/locales.d.ts +0 -4
  205. package/dist/types/src/types/modify_collections.d.ts +0 -5
  206. package/dist/types/src/types/plugins.d.ts +0 -282
  207. package/dist/types/src/types/properties.d.ts +0 -1181
  208. package/dist/types/src/types/property_config.d.ts +0 -74
  209. package/dist/types/src/types/relations.d.ts +0 -336
  210. package/dist/types/src/types/slots.d.ts +0 -262
  211. package/dist/types/src/types/translations.d.ts +0 -900
  212. package/dist/types/src/types/user_management_delegate.d.ts +0 -86
  213. package/dist/types/src/types/websockets.d.ts +0 -78
  214. package/dist/types/src/users/index.d.ts +0 -1
  215. package/dist/types/src/users/user.d.ts +0 -50
  216. package/dist/ui/src/components/Alert.d.ts +0 -12
  217. package/dist/ui/src/components/Autocomplete.d.ts +0 -21
  218. package/dist/ui/src/components/Avatar.d.ts +0 -11
  219. package/dist/ui/src/components/Badge.d.ts +0 -8
  220. package/dist/ui/src/components/BooleanSwitch.d.ts +0 -14
  221. package/dist/ui/src/components/BooleanSwitchWithLabel.d.ts +0 -17
  222. package/dist/ui/src/components/Button.d.ts +0 -14
  223. package/dist/ui/src/components/Card.d.ts +0 -8
  224. package/dist/ui/src/components/CenteredView.d.ts +0 -9
  225. package/dist/ui/src/components/Checkbox.d.ts +0 -13
  226. package/dist/ui/src/components/Chip.d.ts +0 -26
  227. package/dist/ui/src/components/CircularProgress.d.ts +0 -5
  228. package/dist/ui/src/components/CircularProgressCenter.d.ts +0 -11
  229. package/dist/ui/src/components/Collapse.d.ts +0 -9
  230. package/dist/ui/src/components/ColorPicker.d.ts +0 -30
  231. package/dist/ui/src/components/Container.d.ts +0 -8
  232. package/dist/ui/src/components/DateTimeField.d.ts +0 -24
  233. package/dist/ui/src/components/DebouncedTextField.d.ts +0 -2
  234. package/dist/ui/src/components/Dialog.d.ts +0 -39
  235. package/dist/ui/src/components/DialogActions.d.ts +0 -7
  236. package/dist/ui/src/components/DialogContent.d.ts +0 -7
  237. package/dist/ui/src/components/DialogTitle.d.ts +0 -10
  238. package/dist/ui/src/components/ErrorBoundary.d.ts +0 -33
  239. package/dist/ui/src/components/ExpandablePanel.d.ts +0 -12
  240. package/dist/ui/src/components/FileUpload.d.ts +0 -23
  241. package/dist/ui/src/components/FilterChip.d.ts +0 -34
  242. package/dist/ui/src/components/IconButton.d.ts +0 -12
  243. package/dist/ui/src/components/InfoLabel.d.ts +0 -5
  244. package/dist/ui/src/components/InputLabel.d.ts +0 -11
  245. package/dist/ui/src/components/Label.d.ts +0 -7
  246. package/dist/ui/src/components/LoadingButton.d.ts +0 -7
  247. package/dist/ui/src/components/Markdown.d.ts +0 -10
  248. package/dist/ui/src/components/Menu.d.ts +0 -23
  249. package/dist/ui/src/components/Menubar.d.ts +0 -80
  250. package/dist/ui/src/components/MultiSelect.d.ts +0 -48
  251. package/dist/ui/src/components/Paper.d.ts +0 -6
  252. package/dist/ui/src/components/Popover.d.ts +0 -24
  253. package/dist/ui/src/components/RadioGroup.d.ts +0 -28
  254. package/dist/ui/src/components/ResizablePanels.d.ts +0 -18
  255. package/dist/ui/src/components/SearchBar.d.ts +0 -26
  256. package/dist/ui/src/components/Select.d.ts +0 -43
  257. package/dist/ui/src/components/Separator.d.ts +0 -5
  258. package/dist/ui/src/components/Sheet.d.ts +0 -22
  259. package/dist/ui/src/components/Skeleton.d.ts +0 -6
  260. package/dist/ui/src/components/Slider.d.ts +0 -21
  261. package/dist/ui/src/components/Table.d.ts +0 -34
  262. package/dist/ui/src/components/Tabs.d.ts +0 -19
  263. package/dist/ui/src/components/TextField.d.ts +0 -58
  264. package/dist/ui/src/components/TextareaAutosize.d.ts +0 -43
  265. package/dist/ui/src/components/ToggleButtonGroup.d.ts +0 -30
  266. package/dist/ui/src/components/Tooltip.d.ts +0 -19
  267. package/dist/ui/src/components/Typography.d.ts +0 -36
  268. package/dist/ui/src/components/VirtualTable/VirtualTable.d.ts +0 -11
  269. package/dist/ui/src/components/VirtualTable/VirtualTableCell.d.ts +0 -21
  270. package/dist/ui/src/components/VirtualTable/VirtualTableHeader.d.ts +0 -29
  271. package/dist/ui/src/components/VirtualTable/VirtualTableHeaderRow.d.ts +0 -2
  272. package/dist/ui/src/components/VirtualTable/VirtualTableProps.d.ts +0 -249
  273. package/dist/ui/src/components/VirtualTable/VirtualTableRow.d.ts +0 -3
  274. package/dist/ui/src/components/VirtualTable/index.d.ts +0 -3
  275. package/dist/ui/src/components/VirtualTable/types.d.ts +0 -38
  276. package/dist/ui/src/components/common/SelectInputLabel.d.ts +0 -5
  277. package/dist/ui/src/components/index.d.ts +0 -58
  278. package/dist/ui/src/hooks/PortalContainerContext.d.ts +0 -31
  279. package/dist/ui/src/hooks/index.d.ts +0 -6
  280. package/dist/ui/src/hooks/useDebounceCallback.d.ts +0 -1
  281. package/dist/ui/src/hooks/useDebounceValue.d.ts +0 -1
  282. package/dist/ui/src/hooks/useDebouncedCallback.d.ts +0 -1
  283. package/dist/ui/src/hooks/useInjectStyles.d.ts +0 -7
  284. package/dist/ui/src/hooks/useOutsideAlerter.d.ts +0 -5
  285. package/dist/ui/src/icons/GitHubIcon.d.ts +0 -2
  286. package/dist/ui/src/icons/HandleIcon.d.ts +0 -1
  287. package/dist/ui/src/icons/Icon.d.ts +0 -20
  288. package/dist/ui/src/icons/cool_icon_keys.d.ts +0 -1
  289. package/dist/ui/src/icons/icon_keys.d.ts +0 -1
  290. package/dist/ui/src/icons/index.d.ts +0 -8
  291. package/dist/ui/src/index.d.ts +0 -5
  292. package/dist/ui/src/styles.d.ts +0 -12
  293. package/dist/ui/src/util/chip_colors.d.ts +0 -4
  294. package/dist/ui/src/util/cls.d.ts +0 -2
  295. package/dist/ui/src/util/debounce.d.ts +0 -10
  296. package/dist/ui/src/util/hash.d.ts +0 -1
  297. package/dist/ui/src/util/index.d.ts +0 -4
  298. package/dist/ui/src/util/key_to_icon_component.d.ts +0 -1
  299. /package/dist/{plugin-insights/src/engine → engine}/InsightsCache.d.ts +0 -0
  300. /package/dist/{plugin-insights/src/engine → engine}/useInsightsData.d.ts +0 -0
  301. /package/dist/{plugin-insights/src/types → types}/engine.d.ts +0 -0
  302. /package/dist/{plugin-insights/src/types → types}/index.d.ts +0 -0
  303. /package/dist/{plugin-insights/src/types → types}/widgets.d.ts +0 -0
  304. /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
- }): import("react/jsx-runtime").JSX.Element | null;
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
- }): import("react/jsx-runtime").JSX.Element | null;
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
- }): import("react/jsx-runtime").JSX.Element | null;
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
- }): import("react/jsx-runtime").JSX.Element;
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
- }): import("react/jsx-runtime").JSX.Element;
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
- }): import("react/jsx-runtime").JSX.Element;
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
- }>): import("react/jsx-runtime").JSX.Element;
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, } from "./types";
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";