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