@rebasepro/app 0.0.1-canary.4829d6e

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 (268) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +174 -0
  3. package/dist/auth/api.d.ts +66 -0
  4. package/dist/auth/index.d.ts +13 -0
  5. package/dist/auth/types.d.ts +127 -0
  6. package/dist/auth/useRebaseAuthController.d.ts +13 -0
  7. package/dist/components/AIIcon.d.ts +17 -0
  8. package/dist/components/AuthSimulationMenu.d.ts +0 -0
  9. package/dist/components/ConfirmationDialog.d.ts +9 -0
  10. package/dist/components/Debug/UIReferenceView.d.ts +13 -0
  11. package/dist/components/Debug/UIStyleGuide.d.ts +2 -0
  12. package/dist/components/Debug/collection-views/CardViewDemo.d.ts +2 -0
  13. package/dist/components/Debug/collection-views/CollectionTableDemo.d.ts +2 -0
  14. package/dist/components/Debug/collection-views/KanbanBoardDemo.d.ts +2 -0
  15. package/dist/components/Debug/collection-views/index.d.ts +3 -0
  16. package/dist/components/Debug/collection-views/sample_data.d.ts +23 -0
  17. package/dist/components/Debug/crm-dashboard/CalendarWidget.d.ts +22 -0
  18. package/dist/components/Debug/crm-dashboard/CrmDashboardDemo.d.ts +2 -0
  19. package/dist/components/Debug/crm-dashboard/DashboardMetrics.d.ts +15 -0
  20. package/dist/components/Debug/crm-dashboard/PipelineOverview.d.ts +34 -0
  21. package/dist/components/Debug/crm-dashboard/RecentActivity.d.ts +19 -0
  22. package/dist/components/Debug/crm-dashboard/TaskFilters.d.ts +30 -0
  23. package/dist/components/Debug/crm-dashboard/TaskTable.d.ts +50 -0
  24. package/dist/components/Debug/crm-dashboard/TasksView.d.ts +41 -0
  25. package/dist/components/ErrorTooltip.d.ts +3 -0
  26. package/dist/components/ErrorView.d.ts +21 -0
  27. package/dist/components/LanguageToggle.d.ts +2 -0
  28. package/dist/components/LoginView/LoginView.d.ts +113 -0
  29. package/dist/components/LoginView/index.d.ts +2 -0
  30. package/dist/components/NotFoundPage.d.ts +2 -0
  31. package/dist/components/RebaseAuth.d.ts +10 -0
  32. package/dist/components/RebaseLogo.d.ts +7 -0
  33. package/dist/components/SchemaDriftBanner.d.ts +27 -0
  34. package/dist/components/UnsavedChangesDialog.d.ts +9 -0
  35. package/dist/components/UserDisplay.d.ts +7 -0
  36. package/dist/components/UserSelectPopover.d.ts +63 -0
  37. package/dist/components/UserSettingsView.d.ts +2 -0
  38. package/dist/components/common/index.d.ts +6 -0
  39. package/dist/components/common/table_height.d.ts +5 -0
  40. package/dist/components/common/types.d.ts +66 -0
  41. package/dist/components/common/useColumnsIds.d.ts +9 -0
  42. package/dist/components/common/useDataTableController.d.ts +45 -0
  43. package/dist/components/common/useDebouncedData.d.ts +9 -0
  44. package/dist/components/common/useScrollRestoration.d.ts +14 -0
  45. package/dist/components/index.d.ts +18 -0
  46. package/dist/contexts/AdminModeController.d.ts +4 -0
  47. package/dist/contexts/AnalyticsContext.d.ts +3 -0
  48. package/dist/contexts/AuthControllerContext.d.ts +3 -0
  49. package/dist/contexts/CollectionScopeContext.d.ts +50 -0
  50. package/dist/contexts/ComponentOverrideContext.d.ts +42 -0
  51. package/dist/contexts/CustomizationControllerContext.d.ts +3 -0
  52. package/dist/contexts/DataDriverContext.d.ts +3 -0
  53. package/dist/contexts/DataSourcesContext.d.ts +31 -0
  54. package/dist/contexts/DatabaseAdminContext.d.ts +3 -0
  55. package/dist/contexts/DialogsProvider.d.ts +4 -0
  56. package/dist/contexts/EffectiveRoleController.d.ts +4 -0
  57. package/dist/contexts/ModeController.d.ts +4 -0
  58. package/dist/contexts/RebaseClientInstanceContext.d.ts +6 -0
  59. package/dist/contexts/RebaseDataContext.d.ts +3 -0
  60. package/dist/contexts/SnackbarProvider.d.ts +2 -0
  61. package/dist/contexts/StorageSourceContext.d.ts +3 -0
  62. package/dist/contexts/StorageSourcesContext.d.ts +25 -0
  63. package/dist/contexts/UserConfigurationPersistenceContext.d.ts +3 -0
  64. package/dist/contexts/index.d.ts +17 -0
  65. package/dist/core/PluginLifecycleManager.d.ts +17 -0
  66. package/dist/core/PluginProviderStack.d.ts +21 -0
  67. package/dist/core/Rebase.d.ts +15 -0
  68. package/dist/core/RebaseProps.d.ts +291 -0
  69. package/dist/core/RebaseRouter.d.ts +4 -0
  70. package/dist/core/RebaseRoutes.d.ts +17 -0
  71. package/dist/core/index.d.ts +4 -0
  72. package/dist/hooks/ApiConfigContext.d.ts +24 -0
  73. package/dist/hooks/data/delete.d.ts +33 -0
  74. package/dist/hooks/data/save.d.ts +40 -0
  75. package/dist/hooks/data/useCollection.d.ts +62 -0
  76. package/dist/hooks/data/useData.d.ts +13 -0
  77. package/dist/hooks/data/useDataOrder.d.ts +12 -0
  78. package/dist/hooks/data/useFetch.d.ts +43 -0
  79. package/dist/hooks/data/useRelationSelector.d.ts +52 -0
  80. package/dist/hooks/index.d.ts +36 -0
  81. package/dist/hooks/useAdminModeController.d.ts +19 -0
  82. package/dist/hooks/useAnalyticsController.d.ts +5 -0
  83. package/dist/hooks/useAuthController.d.ts +11 -0
  84. package/dist/hooks/useAuthSubscription.d.ts +2 -0
  85. package/dist/hooks/useBackendStorageSource.d.ts +30 -0
  86. package/dist/hooks/useBridgeRegistration.d.ts +18 -0
  87. package/dist/hooks/useBrowserTitleAndIcon.d.ts +6 -0
  88. package/dist/hooks/useBuildAdminModeController.d.ts +6 -0
  89. package/dist/hooks/useBuildEffectiveRoleController.d.ts +8 -0
  90. package/dist/hooks/useBuildLocalConfigurationPersistence.d.ts +2 -0
  91. package/dist/hooks/useBuildModeController.d.ts +6 -0
  92. package/dist/hooks/useClipboard.d.ts +57 -0
  93. package/dist/hooks/useCollapsedGroups.d.ts +27 -0
  94. package/dist/hooks/useComponentOverride.d.ts +32 -0
  95. package/dist/hooks/useCustomizationController.d.ts +11 -0
  96. package/dist/hooks/useDialogsController.d.ts +11 -0
  97. package/dist/hooks/useEffectiveRoleController.d.ts +7 -0
  98. package/dist/hooks/useLargeLayout.d.ts +1 -0
  99. package/dist/hooks/useModeController.d.ts +19 -0
  100. package/dist/hooks/usePermissions.d.ts +12 -0
  101. package/dist/hooks/useRebaseClient.d.ts +5 -0
  102. package/dist/hooks/useRebaseContext.d.ts +11 -0
  103. package/dist/hooks/useRebaseRegistry.d.ts +34 -0
  104. package/dist/hooks/useResolvedComponent.d.ts +47 -0
  105. package/dist/hooks/useSlot.d.ts +18 -0
  106. package/dist/hooks/useSnackbarController.d.ts +20 -0
  107. package/dist/hooks/useStorageSource.d.ts +6 -0
  108. package/dist/hooks/useStudioBridge.d.ts +79 -0
  109. package/dist/hooks/useTranslation.d.ts +17 -0
  110. package/dist/hooks/useUnsavedChangesDialog.d.ts +12 -0
  111. package/dist/hooks/useUserConfigurationPersistence.d.ts +8 -0
  112. package/dist/i18n/RebaseI18nProvider.d.ts +33 -0
  113. package/dist/index.d.ts +16 -0
  114. package/dist/index.es.js +16843 -0
  115. package/dist/index.es.js.map +1 -0
  116. package/dist/index.umd.js +17021 -0
  117. package/dist/index.umd.js.map +1 -0
  118. package/dist/internal/common.d.ts +14 -0
  119. package/dist/internal/useRestoreScroll.d.ts +15 -0
  120. package/dist/locales/de.d.ts +2 -0
  121. package/dist/locales/en.d.ts +10 -0
  122. package/dist/locales/es.d.ts +10 -0
  123. package/dist/locales/fr.d.ts +2 -0
  124. package/dist/locales/hi.d.ts +2 -0
  125. package/dist/locales/it.d.ts +2 -0
  126. package/dist/locales/pt.d.ts +7 -0
  127. package/dist/util/constants.d.ts +1 -0
  128. package/dist/util/createFormexStub.d.ts +2 -0
  129. package/dist/util/entity_cache.d.ts +22 -0
  130. package/dist/util/enums.d.ts +5 -0
  131. package/dist/util/icon_list.d.ts +5 -0
  132. package/dist/util/icons.d.ts +20 -0
  133. package/dist/util/index.d.ts +8 -0
  134. package/dist/util/previews.d.ts +4 -0
  135. package/dist/util/useStorageUploadController.d.ts +44 -0
  136. package/dist/vitePlugin.d.ts +60 -0
  137. package/dist/vitePlugin.js +113 -0
  138. package/package.json +145 -0
  139. package/src/auth/api.ts +148 -0
  140. package/src/auth/index.ts +25 -0
  141. package/src/auth/types.ts +115 -0
  142. package/src/auth/useRebaseAuthController.ts +328 -0
  143. package/src/components/AIIcon.tsx +47 -0
  144. package/src/components/AuthSimulationMenu.tsx +0 -0
  145. package/src/components/ConfirmationDialog.tsx +48 -0
  146. package/src/components/Debug/UIReferenceView.tsx +958 -0
  147. package/src/components/Debug/UIStyleGuide.tsx +156 -0
  148. package/src/components/Debug/collection-views/CardViewDemo.tsx +85 -0
  149. package/src/components/Debug/collection-views/CollectionTableDemo.tsx +107 -0
  150. package/src/components/Debug/collection-views/KanbanBoardDemo.tsx +90 -0
  151. package/src/components/Debug/collection-views/index.ts +3 -0
  152. package/src/components/Debug/collection-views/sample_data.ts +42 -0
  153. package/src/components/Debug/crm-dashboard/CalendarWidget.tsx +389 -0
  154. package/src/components/Debug/crm-dashboard/CrmDashboardDemo.tsx +1102 -0
  155. package/src/components/Debug/crm-dashboard/DashboardMetrics.tsx +133 -0
  156. package/src/components/Debug/crm-dashboard/PipelineOverview.tsx +290 -0
  157. package/src/components/Debug/crm-dashboard/RecentActivity.tsx +215 -0
  158. package/src/components/Debug/crm-dashboard/TaskFilters.tsx +184 -0
  159. package/src/components/Debug/crm-dashboard/TaskTable.tsx +427 -0
  160. package/src/components/Debug/crm-dashboard/TasksView.tsx +234 -0
  161. package/src/components/ErrorTooltip.tsx +12 -0
  162. package/src/components/ErrorView.tsx +94 -0
  163. package/src/components/LanguageToggle.tsx +59 -0
  164. package/src/components/LoginView/LoginView.tsx +932 -0
  165. package/src/components/LoginView/index.ts +2 -0
  166. package/src/components/NotFoundPage.tsx +27 -0
  167. package/src/components/RebaseAuth.tsx +27 -0
  168. package/src/components/RebaseLogo.tsx +29 -0
  169. package/src/components/SchemaDriftBanner.tsx +102 -0
  170. package/src/components/UnsavedChangesDialog.tsx +46 -0
  171. package/src/components/UserDisplay.tsx +54 -0
  172. package/src/components/UserSelectPopover.tsx +399 -0
  173. package/src/components/UserSettingsView.tsx +318 -0
  174. package/src/components/common/index.ts +6 -0
  175. package/src/components/common/table_height.tsx +21 -0
  176. package/src/components/common/types.tsx +66 -0
  177. package/src/components/common/useColumnsIds.tsx +222 -0
  178. package/src/components/common/useDataTableController.tsx +514 -0
  179. package/src/components/common/useDebouncedData.ts +49 -0
  180. package/src/components/common/useScrollRestoration.tsx +68 -0
  181. package/src/components/index.tsx +26 -0
  182. package/src/contexts/AdminModeController.tsx +11 -0
  183. package/src/contexts/AnalyticsContext.tsx +4 -0
  184. package/src/contexts/AuthControllerContext.tsx +4 -0
  185. package/src/contexts/CollectionScopeContext.tsx +67 -0
  186. package/src/contexts/ComponentOverrideContext.tsx +81 -0
  187. package/src/contexts/CustomizationControllerContext.tsx +4 -0
  188. package/src/contexts/DataDriverContext.tsx +4 -0
  189. package/src/contexts/DataSourcesContext.tsx +36 -0
  190. package/src/contexts/DatabaseAdminContext.tsx +4 -0
  191. package/src/contexts/DialogsProvider.tsx +56 -0
  192. package/src/contexts/EffectiveRoleController.tsx +12 -0
  193. package/src/contexts/ModeController.tsx +11 -0
  194. package/src/contexts/RebaseClientInstanceContext.tsx +7 -0
  195. package/src/contexts/RebaseDataContext.tsx +4 -0
  196. package/src/contexts/SnackbarProvider.tsx +15 -0
  197. package/src/contexts/StorageSourceContext.tsx +4 -0
  198. package/src/contexts/StorageSourcesContext.tsx +30 -0
  199. package/src/contexts/UserConfigurationPersistenceContext.tsx +4 -0
  200. package/src/contexts/index.ts +17 -0
  201. package/src/core/PluginLifecycleManager.tsx +95 -0
  202. package/src/core/PluginProviderStack.tsx +40 -0
  203. package/src/core/Rebase.tsx +439 -0
  204. package/src/core/RebaseProps.tsx +320 -0
  205. package/src/core/RebaseRouter.tsx +17 -0
  206. package/src/core/RebaseRoutes.tsx +24 -0
  207. package/src/core/index.tsx +5 -0
  208. package/src/hooks/ApiConfigContext.tsx +41 -0
  209. package/src/hooks/data/delete.ts +55 -0
  210. package/src/hooks/data/save.ts +77 -0
  211. package/src/hooks/data/useCollection.tsx +176 -0
  212. package/src/hooks/data/useData.tsx +18 -0
  213. package/src/hooks/data/useDataOrder.ts +26 -0
  214. package/src/hooks/data/useFetch.tsx +140 -0
  215. package/src/hooks/data/useRelationSelector.tsx +234 -0
  216. package/src/hooks/index.tsx +45 -0
  217. package/src/hooks/useAdminModeController.tsx +23 -0
  218. package/src/hooks/useAnalyticsController.tsx +8 -0
  219. package/src/hooks/useAuthController.tsx +14 -0
  220. package/src/hooks/useAuthSubscription.ts +87 -0
  221. package/src/hooks/useBackendStorageSource.ts +288 -0
  222. package/src/hooks/useBridgeRegistration.tsx +32 -0
  223. package/src/hooks/useBrowserTitleAndIcon.tsx +23 -0
  224. package/src/hooks/useBuildAdminModeController.tsx +24 -0
  225. package/src/hooks/useBuildEffectiveRoleController.tsx +31 -0
  226. package/src/hooks/useBuildLocalConfigurationPersistence.tsx +75 -0
  227. package/src/hooks/useBuildModeController.tsx +71 -0
  228. package/src/hooks/useClipboard.tsx +158 -0
  229. package/src/hooks/useCollapsedGroups.ts +116 -0
  230. package/src/hooks/useComponentOverride.tsx +59 -0
  231. package/src/hooks/useCustomizationController.tsx +14 -0
  232. package/src/hooks/useDialogsController.tsx +15 -0
  233. package/src/hooks/useEffectiveRoleController.tsx +10 -0
  234. package/src/hooks/useLargeLayout.tsx +65 -0
  235. package/src/hooks/useModeController.tsx +23 -0
  236. package/src/hooks/usePermissions.ts +44 -0
  237. package/src/hooks/useRebaseClient.tsx +10 -0
  238. package/src/hooks/useRebaseContext.tsx +83 -0
  239. package/src/hooks/useRebaseRegistry.tsx +91 -0
  240. package/src/hooks/useResolvedComponent.tsx +159 -0
  241. package/src/hooks/useSlot.tsx +64 -0
  242. package/src/hooks/useSnackbarController.tsx +52 -0
  243. package/src/hooks/useStorageSource.tsx +11 -0
  244. package/src/hooks/useStudioBridge.tsx +209 -0
  245. package/src/hooks/useTranslation.ts +33 -0
  246. package/src/hooks/useUnsavedChangesDialog.tsx +64 -0
  247. package/src/hooks/useUserConfigurationPersistence.tsx +11 -0
  248. package/src/i18n/RebaseI18nProvider.tsx +160 -0
  249. package/src/index.ts +25 -0
  250. package/src/internal/common.tsx +16 -0
  251. package/src/internal/useRestoreScroll.tsx +69 -0
  252. package/src/locales/de.ts +902 -0
  253. package/src/locales/en.ts +980 -0
  254. package/src/locales/es.ts +922 -0
  255. package/src/locales/fr.ts +901 -0
  256. package/src/locales/hi.ts +901 -0
  257. package/src/locales/it.ts +901 -0
  258. package/src/locales/pt.ts +909 -0
  259. package/src/util/constants.ts +7 -0
  260. package/src/util/createFormexStub.tsx +66 -0
  261. package/src/util/entity_cache.ts +239 -0
  262. package/src/util/enums.ts +32 -0
  263. package/src/util/icon_list.ts +22 -0
  264. package/src/util/icons.tsx +149 -0
  265. package/src/util/index.ts +12 -0
  266. package/src/util/previews.ts +105 -0
  267. package/src/util/useStorageUploadController.tsx +350 -0
  268. package/src/vitePlugin.ts +196 -0
@@ -0,0 +1,320 @@
1
+ import React from "react";
2
+ import { Locale, User, AuthController, AnalyticsEvent, DataDriver, DataSourceDefinition, StorageSource, StorageSourceDefinition, UserConfigurationPersistence, CollectionRegistryController, DatabaseAdmin, UrlController, NavigationStateController, RebaseClient, RebaseContext, EntityLinkBuilder, RebasePlugin, SlotContribution, PropertyConfig, EntityCustomView, EntityAction, RebaseTranslations, ComponentOverrideMap } from "@rebasepro/types";
3
+
4
+ /**
5
+ * A data source registered on `<Rebase>`. Extends the shared
6
+ * {@link DataSourceDefinition} with the frontend {@link DataDriver} used for
7
+ * `direct`/`custom` transports. Server-mediated sources omit `driver` — they
8
+ * are reached through the `client`.
9
+ *
10
+ * @group Models
11
+ */
12
+ export type RebaseDataSource = DataSourceDefinition & {
13
+ /**
14
+ * The client-side driver for this source. Required for `direct`/`custom`
15
+ * transports; omit for `server` transport (handled by the `client`).
16
+ *
17
+ * When `transport` is not stated it is inferred from this field:
18
+ * driver present → `"direct"`, absent → `"server"`.
19
+ */
20
+ driver?: DataDriver;
21
+ };
22
+
23
+ /**
24
+ * A storage source registered on `<Rebase>`. Extends the shared
25
+ * {@link StorageSourceDefinition} with an optional frontend
26
+ * {@link StorageSource} for `direct` transports. Server-mediated sources
27
+ * omit `source` — they are reached through the `client`.
28
+ *
29
+ * @group Models
30
+ */
31
+ export type RebaseStorageSource = StorageSourceDefinition & {
32
+ /**
33
+ * The client-side StorageSource for this backend. Required for `direct`
34
+ * transport (e.g. Firebase Storage via `@firebase/storage`); omit for
35
+ * `server` transport (proxied by the Rebase backend).
36
+ */
37
+ source?: StorageSource;
38
+ };
39
+
40
+ /** DeepPartial helper — allows partial overrides at any nesting level */
41
+ type DeepPartial<T> = T extends object
42
+ ? { [K in keyof T]?: DeepPartial<T[K]> }
43
+ : T;
44
+
45
+ /**
46
+ * Controller to simulate different roles when dev mode is active.
47
+ * @group Models
48
+ */
49
+ export interface EffectiveRoleController {
50
+ effectiveRole: string | null;
51
+ setEffectiveRole: (role: string | null) => void;
52
+ }
53
+
54
+
55
+ /**
56
+ * Props for the main {@link Rebase} component.
57
+ *
58
+ * ## Data
59
+ *
60
+ * Everything is a data source, and there is one list: {@link dataSources}.
61
+ * The **default** source (serving every collection without a `dataSource`
62
+ * key) resolves with three rules:
63
+ *
64
+ * 1. A `dataSources` entry keyed `"(default)"` (`DEFAULT_DATA_SOURCE_KEY`)
65
+ * *with a driver* is the default source.
66
+ * 2. Otherwise `client.data` is the default.
67
+ * 3. Otherwise, if exactly one source is registered, it is the default.
68
+ * Zero sources, or several without a `"(default)"` key, **throw**.
69
+ *
70
+ * A `"(default)"` entry *without* a driver never provides data — it only
71
+ * declares the default source's `engine`/`label` (capabilities) when the
72
+ * client is the default.
73
+ *
74
+ * All other `dataSources` entries are routed non-default sources:
75
+ * collections opt in via `collection.dataSource`.
76
+ *
77
+ * ### Auth
78
+ *
79
+ * - `authController` prop → completely disables the `client.auth`
80
+ * subscription (an override, not a merge). The recommended pattern is to
81
+ * pass both `client` and an `authController` built from that client via
82
+ * `useRebaseAuthController({ client })`.
83
+ * - Otherwise, `client.auth` is subscribed to via `useAuthSubscription`.
84
+ *
85
+ * ### Storage (default source)
86
+ *
87
+ * Default: `storageSource` prop ?? `client.storage`.
88
+ *
89
+ * Named sources are merged in priority order (later entries with the same
90
+ * key overwrite earlier ones):
91
+ * 1. Backend-discovered remote definitions (`client.fetchStorageSources()`,
92
+ * fetched after auth/login-skip).
93
+ * 2. Client `storageRegistry` entries.
94
+ * 3. `storageSources` prop entries (live `direct` instances; `server`-
95
+ * transport keys are materialized via `client.createStorageSource`).
96
+ * 4. Default storage (keyed `DEFAULT_STORAGE_SOURCE_KEY`) as fallback.
97
+ *
98
+ * ## Decision Ladder
99
+ *
100
+ * | Scenario | Props to use |
101
+ * |---|---|
102
+ * | Standard app | `client` (+ `authController` built from it) |
103
+ * | Multi-backend data | add `dataSources` |
104
+ * | Multi-backend storage | add `storageSources` |
105
+ * | Fully headless / custom | `dataSources` with a `"(default)"`-keyed driver entry + `storageSource` |
106
+ *
107
+ * @group Models
108
+ */
109
+ export type RebaseProps<USER extends User> = {
110
+
111
+ /**
112
+ * The root components of your application. Use RebaseAdmin, RebaseStudio, and RebaseShell.
113
+ * Alternatively, pass a render function that receives { context, loading }.
114
+ */
115
+ children: React.ReactNode | ((props: { context: RebaseContext; loading: boolean }) => React.ReactNode);
116
+
117
+ /**
118
+ * Optional base path for the entire Rebase app.
119
+ * Defaults to "/"
120
+ */
121
+ basePath?: string;
122
+
123
+ /**
124
+ * Optional base path for the CMS collections.
125
+ * Defaults to "/c"
126
+ */
127
+ baseCollectionPath?: string;
128
+
129
+ /**
130
+ * Base URL for the backend API (e.g. "http://localhost:3001").
131
+ * When provided, this is available via `useApiConfig()` to any hook
132
+ * in the tree, reducing repetitive `apiUrl` threading.
133
+ */
134
+ apiUrl?: string;
135
+
136
+
137
+ /**
138
+ * Format of the dates in the CMS.
139
+ * Defaults to 'MMMM dd, yyyy, HH:mm:ss'
140
+ */
141
+ dateTimeFormat?: string;
142
+
143
+ /**
144
+ * Locale of the CMS, currently only affecting dates
145
+ */
146
+ locale?: Locale;
147
+
148
+ /**
149
+ * Unified RebaseClient for data, auth, and storage.
150
+ *
151
+ * `client.data` is the default data source unless a {@link dataSources}
152
+ * entry keyed `"(default)"` carries a driver.
153
+ * `client.auth` is subscribed unless `authController` is provided.
154
+ * `client.storage` is used unless `storageSource` is provided.
155
+ */
156
+ client?: RebaseClient;
157
+
158
+ /**
159
+ * The data sources of the app. Each entry pairs a
160
+ * {@link DataSourceDefinition} (key, engine, transport) with an optional
161
+ * client-side {@link DataDriver}.
162
+ *
163
+ * Register the **direct** (e.g. Firestore, talking straight to its backend)
164
+ * and **custom** sources here. Server-mediated sources (Postgres, MongoDB,
165
+ * …) do *not* need an entry — they ride the `client` and are routed by the
166
+ * Rebase backend.
167
+ *
168
+ * An entry keyed `"(default)"` with a driver **replaces** `client.data`
169
+ * as the default data source (this is how a fully client-side app, e.g.
170
+ * Firestore-only, is wired). Without a driver, a `"(default)"` entry just
171
+ * declares the default source's engine/capabilities.
172
+ *
173
+ * Collections are routed automatically by their `dataSource` key (resolved
174
+ * by collection path against the registry), so routing works transparently
175
+ * for list/entity views, references, the board view, import/export, and
176
+ * programmatic `context.data` access — no per-collection wiring.
177
+ *
178
+ * @example
179
+ * ```tsx
180
+ * // Postgres via the Rebase client (default) + a direct Firestore source.
181
+ * <Rebase
182
+ * client={rebaseClient}
183
+ * dataSources={[
184
+ * { key: "analytics", engine: "firestore", driver: firestoreDriver }
185
+ * ]}
186
+ * >
187
+ * // Collections opt in with `{ ..., dataSource: "analytics" }`.
188
+ * ```
189
+ */
190
+ dataSources?: RebaseDataSource[];
191
+
192
+ /**
193
+ * Custom auth controller. When provided, the `client.auth` subscription
194
+ * is **completely disabled** (not merged).
195
+ *
196
+ * The recommended pattern is to pass both `client` and an
197
+ * `authController` built from that client:
198
+ * ```tsx
199
+ * const authController = useRebaseAuthController({ client });
200
+ * <Rebase client={client} authController={authController} />
201
+ * ```
202
+ * This lets the `authController` own the auth lifecycle while `client`
203
+ * still provides data and storage.
204
+ */
205
+ authController?: AuthController<USER>;
206
+
207
+ /**
208
+ * Default storage source. Overrides `client.storage` when provided.
209
+ * Named sources in {@link storageSources} are unaffected.
210
+ */
211
+ storageSource?: StorageSource;
212
+
213
+ /**
214
+ * Additional storage sources beyond the default `client.storage`.
215
+ *
216
+ * Register **direct** (e.g. Firebase Storage, talking straight to the
217
+ * cloud) sources here. Server-mediated sources (S3, GCS proxied by the
218
+ * Rebase backend) do *not* need an entry — they are routed by
219
+ * `storageId` query parameter on the REST API.
220
+ *
221
+ * Collection properties opt in via `storage.storageSource: "key"`.
222
+ *
223
+ * @example
224
+ * ```tsx
225
+ * <Rebase
226
+ * client={rebaseClient}
227
+ * storageSources={[
228
+ * { key: "firebase", engine: "firebase", transport: "direct", source: firebaseStorageSource }
229
+ * ]}
230
+ * >
231
+ * ```
232
+ */
233
+ storageSources?: RebaseStorageSource[];
234
+
235
+ /**
236
+ * Administrative database operations (SQL, schema discovery).
237
+ * Only needed when the studio/admin features are enabled.
238
+ */
239
+ databaseAdmin?: DatabaseAdmin;
240
+
241
+ /**
242
+ * Use this controller to access the configuration that is stored locally,
243
+ * and not defined in code
244
+ */
245
+ userConfigPersistence?: UserConfigurationPersistence;
246
+
247
+ /**
248
+ * Callback used to get analytics events from the CMS
249
+ */
250
+ onAnalyticsEvent?: (event: AnalyticsEvent, data?: object) => void;
251
+
252
+ /**
253
+ * Optional link builder you can add to generate a button in your entity forms.
254
+ * The function must return a URL that gets opened when the button is clicked
255
+ */
256
+ entityLinkBuilder?: EntityLinkBuilder;
257
+
258
+
259
+ /**
260
+ * Plugins loaded in the CMS
261
+ */
262
+ plugins?: RebasePlugin[];
263
+
264
+ /**
265
+ * Extra slots for the CMS
266
+ */
267
+ slots?: SlotContribution[];
268
+
269
+ /**
270
+ * Property configs (widgets)
271
+ */
272
+ propertyConfigs?: Record<string, PropertyConfig>;
273
+
274
+ /**
275
+ * Entity Views
276
+ */
277
+ entityViews?: EntityCustomView[];
278
+
279
+ /**
280
+ * Entity Actions
281
+ */
282
+ entityActions?: EntityAction[];
283
+
284
+ /**
285
+ * Controller to simulate different roles when dev mode is active.
286
+ */
287
+ effectiveRoleController?: EffectiveRoleController;
288
+
289
+ /**
290
+ * Override or extend any Rebase UI string, keyed by locale.
291
+ */
292
+ translations?: {
293
+ [locale: string]: DeepPartial<RebaseTranslations>;
294
+ };
295
+
296
+ /**
297
+ * Override built-in UI components with custom implementations.
298
+ *
299
+ * Keys are component names from {@link OverridableComponentName}.
300
+ * Values specify the replacement component and an optional `wrap`
301
+ * flag for the wrapping pattern.
302
+ *
303
+ * @example
304
+ * ```tsx
305
+ * <Rebase
306
+ * client={client}
307
+ * components={{
308
+ * "Shell.AppBar": { Component: MyCustomAppBar },
309
+ * "EditView.FormActions": {
310
+ * Component: MyFormActions,
311
+ * wrap: true
312
+ * }
313
+ * }}
314
+ * >
315
+ * ```
316
+ */
317
+ components?: ComponentOverrideMap;
318
+
319
+ };
320
+
@@ -0,0 +1,17 @@
1
+ import { createBrowserRouter, RouterProvider } from "react-router-dom"
2
+ import { removeInitialAndTrailingSlashes } from "@rebasepro/common";
3
+
4
+ export function RebaseRouter({
5
+ children,
6
+ basePath
7
+ }: {
8
+ children: React.ReactNode,
9
+ basePath?: string;
10
+ }) {
11
+ return <RouterProvider router={createBrowserRouter([
12
+ {
13
+ path: basePath ? `${removeInitialAndTrailingSlashes(basePath)}/*` : "/*",
14
+ element: children
15
+ }
16
+ ])}/>;
17
+ }
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import { Route, Routes, useLocation } from "react-router-dom";
3
+
4
+
5
+ /**
6
+ * A drop-in replacement for react-router's `<Routes>` that preserves the
7
+ * underlying view when a side dialog navigates the URL to a different path.
8
+ *
9
+ * When opening a side dialog from e.g. `/posts` to `authors/123#side`,
10
+ * the `base_location` stored in router state is used so the route tree
11
+ * keeps rendering the original `/posts` view underneath the dialog overlay.
12
+ *
13
+ * Additionally, registered views from `useNavigationStateController()` are
14
+ * automatically routed — no need to manually map them to `<Route>` elements.
15
+ * Views with `nestedRoutes: true` get a wildcard route (slug/*) as well.
16
+ * Explicitly declared `children` routes take priority.
17
+ */
18
+ export function RebaseRoutes({ children }: { children?: React.ReactNode }) {
19
+ const location = useLocation();
20
+ const state = location.state as Record<string, unknown> | null;
21
+ const baseLocation = state?.base_location ?? location;
22
+
23
+ return <Routes location={baseLocation}>{children}</Routes>;
24
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./Rebase";
2
+ export * from "./PluginProviderStack";
3
+
4
+ export * from "./RebaseRouter";
5
+ export * from "./RebaseRoutes";
@@ -0,0 +1,41 @@
1
+ import React, { useContext } from "react";
2
+
3
+ /**
4
+ * Configuration for API connectivity. Passed once at the top level
5
+ * and available to any hook that needs `apiUrl` or `getAuthToken`.
6
+ *
7
+ * Individual hooks can still accept explicit overrides — this context
8
+ * serves as a fallback to eliminate repetitive threading.
9
+ */
10
+ export interface ApiConfig {
11
+ apiUrl: string;
12
+ getAuthToken?: () => Promise<string | null>;
13
+ }
14
+
15
+ const ApiConfigContext = React.createContext<ApiConfig | undefined>(undefined);
16
+
17
+ /**
18
+ * Read the API config from context. Returns `undefined` if no provider is present,
19
+ * allowing hooks to fall back to their own props.
20
+ */
21
+ export function useApiConfig(): ApiConfig | undefined {
22
+ return useContext(ApiConfigContext);
23
+ }
24
+
25
+ /**
26
+ * Provide API configuration (apiUrl, getAuthToken) to the entire subtree.
27
+ * Typically rendered inside `<Rebase>` or at the app root.
28
+ */
29
+ export function ApiConfigProvider({
30
+ apiUrl,
31
+ getAuthToken,
32
+ children
33
+ }: ApiConfig & { children: React.ReactNode }) {
34
+ const value = React.useMemo(() => ({ apiUrl,
35
+ getAuthToken }), [apiUrl, getAuthToken]);
36
+ return (
37
+ <ApiConfigContext.Provider value={value}>
38
+ {children}
39
+ </ApiConfigContext.Provider>
40
+ );
41
+ }
@@ -0,0 +1,55 @@
1
+ import type { CollectionConfig } from "@rebasepro/types";
2
+ import { Entity, CollectionCallbacks, RebaseContext, User } from "@rebasepro/types";
3
+ import { RebaseData } from "@rebasepro/types";
4
+
5
+ /**
6
+ * @group Hooks and utilities
7
+ */
8
+ export type DeleteEntityWithCallbacksProps<M extends Record<string, any>, USER extends User = User> = {
9
+ entity: Entity<M>;
10
+ collection?: CollectionConfig<M>;
11
+ callbacks?: CollectionCallbacks<M, USER>;
12
+ onDeleteSuccess?: (entity: Entity<M>) => void;
13
+ onDeleteFailure?: (entity: Entity<M>, e: Error) => void;
14
+ }
15
+
16
+ /**
17
+ * This function is in charge of deleting a entity.
18
+ * It will run all the delete callbacks specified in the collection.
19
+ * It is also possible to attach callbacks on save success or error, and callback
20
+ * errors.
21
+ *
22
+ * @param data
23
+ * @param entity
24
+ * @param collection
25
+ * @param callbacks
26
+ * @param onDeleteSuccess
27
+ * @param onDeleteFailure
28
+ * @param context
29
+ * @group Hooks and utilities
30
+ */
31
+ export async function deleteEntityWithCallbacks<M extends Record<string, any>, USER extends User>({
32
+ data,
33
+ entity,
34
+ collection,
35
+ callbacks,
36
+ onDeleteSuccess,
37
+ onDeleteFailure,
38
+ context
39
+ }: DeleteEntityWithCallbacksProps<M> & {
40
+ collection: CollectionConfig<M>,
41
+ data: RebaseData,
42
+ context: RebaseContext<USER>
43
+ }
44
+ ): Promise<boolean> {
45
+
46
+ console.debug("Deleting entity", entity.path, entity.id);
47
+
48
+ return data.collection(entity.path).delete(entity.id).then(() => {
49
+ if (onDeleteSuccess) onDeleteSuccess(entity);
50
+ return true;
51
+ }).catch((e) => {
52
+ if (onDeleteFailure) onDeleteFailure(entity, e);
53
+ return false;
54
+ });
55
+ }
@@ -0,0 +1,77 @@
1
+ import type { CollectionConfig } from "@rebasepro/types";
2
+ import { Entity, EntityStatus, EntityValues, RebaseContext } from "@rebasepro/types";
3
+ import { RebaseData } from "@rebasepro/types";
4
+
5
+ /**
6
+ * @group Hooks and utilities
7
+ */
8
+ export type SaveEntityWithCallbacksProps<M extends Record<string, unknown>> = {
9
+ path: string;
10
+ values: Partial<EntityValues<M>>;
11
+ entityId?: string | number;
12
+ previousValues?: Partial<EntityValues<M>>;
13
+ collection?: CollectionConfig<M>;
14
+ status: EntityStatus;
15
+ afterSave?: (updatedEntity: Entity<M>) => void,
16
+ afterSaveError?: (e: Error) => void
17
+ }
18
+
19
+ /**
20
+ * This function is in charge of saving a entity.
21
+ * It will run all the save callbacks specified in the collection.
22
+ * It is also possible to attach callbacks on save success or error, and callback
23
+ * errors.
24
+ *
25
+ * @param collection
26
+ * @param path
27
+ * @param entityId
28
+ * @param callbacks
29
+ * @param values
30
+ * @param previousValues
31
+ * @param status
32
+ * @param data
33
+ * @param context
34
+ * @param afterSave
35
+ * @param afterSaveError
36
+ * @group Hooks and utilities
37
+ */
38
+ export async function saveEntityWithCallbacks<M extends Record<string, unknown>>({
39
+ collection,
40
+ path,
41
+ entityId,
42
+ values,
43
+ previousValues,
44
+ status,
45
+ data,
46
+ context,
47
+ afterSave,
48
+ afterSaveError
49
+ }: SaveEntityWithCallbacksProps<M> & {
50
+ collection: CollectionConfig,
51
+ data: RebaseData,
52
+ context: RebaseContext,
53
+ }
54
+ ): Promise<Entity<M>> {
55
+
56
+ if (status !== "new" && status !== "copy" && !entityId) {
57
+ throw new Error("Entity id must be specified when updating an existing entity");
58
+ }
59
+
60
+ const accessor = data.collection(path);
61
+
62
+ let savePromise: Promise<Entity<M>>;
63
+ if (status === "new" || status === "copy") {
64
+ savePromise = accessor.create(values, entityId) as Promise<Entity<M>>;
65
+ } else {
66
+ savePromise = accessor.update(entityId!, values) as Promise<Entity<M>>;
67
+ }
68
+
69
+ return savePromise.then((entity) => {
70
+ if (afterSave)
71
+ afterSave(entity);
72
+ return entity as Entity<M>;
73
+ }).catch((e) => {
74
+ if (afterSaveError) afterSaveError(e);
75
+ throw e;
76
+ });
77
+ }