@rebasepro/app 0.17.3 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/components/index.d.ts +0 -3
- package/dist/contexts/AuthControllerContext.d.ts +2 -1
- package/dist/contexts/CustomizationControllerContext.d.ts +2 -1
- package/dist/contexts/DialogsProvider.d.ts +2 -1
- package/dist/contexts/RebaseDataContext.d.ts +10 -1
- package/dist/contexts/StorageSourceContext.d.ts +11 -1
- package/dist/core/RebaseProps.d.ts +2 -12
- package/dist/debug/index.d.ts +19 -0
- package/dist/debug.js +3631 -0
- package/dist/hooks/data/delete.d.ts +16 -7
- package/dist/hooks/data/save.d.ts +18 -4
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useAdminModeController.d.ts +5 -4
- package/dist/hooks/useNavigationGroupLabel.d.ts +17 -0
- package/dist/hooks/useStudioBridge.d.ts +33 -0
- package/dist/index.es.js +2599 -6980
- package/dist/index.es.js.map +1 -1
- package/dist/vitePlugin.d.ts +22 -0
- package/dist/vitePlugin.js +40 -1
- package/package.json +42 -31
- package/src/auth/api.ts +0 -134
- package/src/auth/index.ts +0 -26
- package/src/auth/types.ts +0 -115
- package/src/auth/useRebaseAuthController.ts +0 -345
- package/src/collections/collection_view_config.ts +0 -76
- package/src/collections/entity-display-cache.ts +0 -195
- package/src/collections/entity-display.ts +0 -77
- package/src/collections/entity_image_preview.ts +0 -61
- package/src/collections/filter-operator-resolution.ts +0 -119
- package/src/collections/form-layout.ts +0 -394
- package/src/collections/index.ts +0 -13
- package/src/collections/navigation_from_path.ts +0 -123
- package/src/collections/navigation_utils.ts +0 -171
- package/src/collections/parent_references_from_path.ts +0 -59
- package/src/collections/property-path.ts +0 -30
- package/src/collections/property_presentation.ts +0 -264
- package/src/collections/summary-property.ts +0 -114
- package/src/collections/title-property.ts +0 -312
- package/src/components/AIIcon.tsx +0 -47
- package/src/components/AuthSimulationMenu.tsx +0 -0
- package/src/components/ConfirmationDialog.tsx +0 -48
- package/src/components/Debug/UIReferenceView.tsx +0 -1053
- package/src/components/Debug/UIStyleGuide.tsx +0 -159
- package/src/components/Debug/collection-views/CardViewDemo.tsx +0 -87
- package/src/components/Debug/collection-views/CollectionTableDemo.tsx +0 -107
- package/src/components/Debug/collection-views/KanbanBoardDemo.tsx +0 -89
- package/src/components/Debug/collection-views/index.ts +0 -3
- package/src/components/Debug/collection-views/sample_data.ts +0 -44
- package/src/components/Debug/crm-dashboard/CalendarWidget.tsx +0 -387
- package/src/components/Debug/crm-dashboard/CrmDashboardDemo.tsx +0 -1100
- package/src/components/Debug/crm-dashboard/DashboardMetrics.tsx +0 -131
- package/src/components/Debug/crm-dashboard/PipelineOverview.tsx +0 -288
- package/src/components/Debug/crm-dashboard/RecentActivity.tsx +0 -213
- package/src/components/Debug/crm-dashboard/TaskFilters.tsx +0 -182
- package/src/components/Debug/crm-dashboard/TaskTable.tsx +0 -425
- package/src/components/Debug/crm-dashboard/TasksView.tsx +0 -234
- package/src/components/ErrorTooltip.tsx +0 -12
- package/src/components/ErrorView.tsx +0 -94
- package/src/components/LanguageToggle.tsx +0 -59
- package/src/components/LoginView/LoginView.tsx +0 -1235
- package/src/components/LoginView/index.ts +0 -2
- package/src/components/LoginView/oauth-redirect-flow.ts +0 -184
- package/src/components/NotFoundPage.tsx +0 -27
- package/src/components/RebaseAuth.tsx +0 -27
- package/src/components/RebaseLogo.tsx +0 -88
- package/src/components/SchemaDriftBanner.tsx +0 -102
- package/src/components/UnsavedChangesDialog.tsx +0 -46
- package/src/components/UserDisplay.tsx +0 -54
- package/src/components/UserSelectPopover.tsx +0 -399
- package/src/components/UserSettingsView.tsx +0 -318
- package/src/components/common/index.ts +0 -6
- package/src/components/common/table_height.tsx +0 -21
- package/src/components/common/types.tsx +0 -66
- package/src/components/common/useColumnsIds.tsx +0 -261
- package/src/components/common/useDataTableController.tsx +0 -571
- package/src/components/common/useDebouncedData.ts +0 -49
- package/src/components/common/useScrollRestoration.tsx +0 -68
- package/src/components/index.tsx +0 -26
- package/src/contexts/AdminModeController.tsx +0 -11
- package/src/contexts/AnalyticsContext.tsx +0 -4
- package/src/contexts/AuthControllerContext.tsx +0 -4
- package/src/contexts/CollectionResolverContext.tsx +0 -24
- package/src/contexts/CollectionScopeContext.tsx +0 -68
- package/src/contexts/ComponentOverrideContext.tsx +0 -81
- package/src/contexts/CustomizationControllerContext.tsx +0 -4
- package/src/contexts/DataDriverContext.tsx +0 -4
- package/src/contexts/DataSourcesContext.tsx +0 -36
- package/src/contexts/DatabaseAdminContext.tsx +0 -4
- package/src/contexts/DialogsProvider.tsx +0 -56
- package/src/contexts/EffectiveRoleController.tsx +0 -12
- package/src/contexts/ModeController.tsx +0 -11
- package/src/contexts/RebaseClientInstanceContext.tsx +0 -7
- package/src/contexts/RebaseDataContext.tsx +0 -4
- package/src/contexts/SnackbarProvider.tsx +0 -15
- package/src/contexts/StorageSourceContext.tsx +0 -4
- package/src/contexts/StorageSourcesContext.tsx +0 -30
- package/src/contexts/UserConfigurationPersistenceContext.tsx +0 -4
- package/src/contexts/index.ts +0 -18
- package/src/core/PluginLifecycleManager.tsx +0 -96
- package/src/core/PluginProviderStack.tsx +0 -40
- package/src/core/Rebase.tsx +0 -488
- package/src/core/RebaseProps.tsx +0 -333
- package/src/core/RebaseRouter.tsx +0 -18
- package/src/core/RebaseRoutes.tsx +0 -24
- package/src/core/index.tsx +0 -5
- package/src/hooks/ApiConfigContext.tsx +0 -83
- package/src/hooks/data/collectionQuery.ts +0 -55
- package/src/hooks/data/delete.ts +0 -56
- package/src/hooks/data/save.ts +0 -78
- package/src/hooks/data/useCollection.tsx +0 -183
- package/src/hooks/data/useData.tsx +0 -18
- package/src/hooks/data/useDataOrder.ts +0 -26
- package/src/hooks/data/useFetch.tsx +0 -156
- package/src/hooks/data/useRelationSelector.tsx +0 -280
- package/src/hooks/index.tsx +0 -45
- package/src/hooks/useAdminModeController.tsx +0 -23
- package/src/hooks/useAnalyticsController.tsx +0 -8
- package/src/hooks/useAuthController.tsx +0 -15
- package/src/hooks/useAuthSubscription.ts +0 -130
- package/src/hooks/useBackendStorageSource.ts +0 -295
- package/src/hooks/useBridgeRegistration.tsx +0 -32
- package/src/hooks/useBrowserTitleAndIcon.tsx +0 -23
- package/src/hooks/useBuildAdminModeController.tsx +0 -29
- package/src/hooks/useBuildEffectiveRoleController.tsx +0 -30
- package/src/hooks/useBuildLocalConfigurationPersistence.tsx +0 -83
- package/src/hooks/useBuildModeController.tsx +0 -73
- package/src/hooks/useClipboard.tsx +0 -158
- package/src/hooks/useCollapsedGroups.ts +0 -116
- package/src/hooks/useComponentOverride.tsx +0 -59
- package/src/hooks/useCustomizationController.tsx +0 -14
- package/src/hooks/useDialogsController.tsx +0 -15
- package/src/hooks/useEffectiveRoleController.tsx +0 -10
- package/src/hooks/useLargeLayout.tsx +0 -65
- package/src/hooks/useModeController.tsx +0 -23
- package/src/hooks/useNavigationBlocker.tsx +0 -108
- package/src/hooks/usePermissions.ts +0 -45
- package/src/hooks/useRebaseClient.tsx +0 -10
- package/src/hooks/useRebaseContext.tsx +0 -84
- package/src/hooks/useRebaseRegistry.tsx +0 -91
- package/src/hooks/useResolvedComponent.tsx +0 -195
- package/src/hooks/useSlot.tsx +0 -64
- package/src/hooks/useSnackbarController.tsx +0 -80
- package/src/hooks/useStorageSource.tsx +0 -11
- package/src/hooks/useStudioBridge.tsx +0 -258
- package/src/hooks/useTranslation.ts +0 -38
- package/src/hooks/useUnsavedChangesDialog.tsx +0 -67
- package/src/hooks/useUserConfigurationPersistence.tsx +0 -11
- package/src/i18n/RebaseI18nProvider.tsx +0 -159
- package/src/index.ts +0 -32
- package/src/internal/common.tsx +0 -28
- package/src/internal/useRestoreScroll.tsx +0 -69
- package/src/locales/de.ts +0 -941
- package/src/locales/en.ts +0 -1021
- package/src/locales/es.ts +0 -962
- package/src/locales/fr.ts +0 -941
- package/src/locales/hi.ts +0 -941
- package/src/locales/it.ts +0 -941
- package/src/locales/pt.ts +0 -949
- package/src/util/constants.ts +0 -7
- package/src/util/createFormexStub.tsx +0 -66
- package/src/util/entity_cache.ts +0 -242
- package/src/util/enums.ts +0 -34
- package/src/util/icon_list.ts +0 -22
- package/src/util/icons.tsx +0 -129
- package/src/util/index.ts +0 -13
- package/src/util/local_storage.ts +0 -66
- package/src/util/previews.ts +0 -127
- package/src/util/useStorageUploadController.tsx +0 -354
- package/src/vitePlugin.ts +0 -215
- /package/dist/{components/Debug → debug}/UIReferenceView.d.ts +0 -0
- /package/dist/{components/Debug → debug}/UIStyleGuide.d.ts +0 -0
- /package/dist/{components/Debug → debug}/collection-views/CardViewDemo.d.ts +0 -0
- /package/dist/{components/Debug → debug}/collection-views/CollectionTableDemo.d.ts +0 -0
- /package/dist/{components/Debug → debug}/collection-views/KanbanBoardDemo.d.ts +0 -0
- /package/dist/{components/Debug → debug}/collection-views/index.d.ts +0 -0
- /package/dist/{components/Debug → debug}/collection-views/sample_data.d.ts +0 -0
- /package/dist/{components/Debug → debug}/crm-dashboard/CalendarWidget.d.ts +0 -0
- /package/dist/{components/Debug → debug}/crm-dashboard/CrmDashboardDemo.d.ts +0 -0
- /package/dist/{components/Debug → debug}/crm-dashboard/DashboardMetrics.d.ts +0 -0
- /package/dist/{components/Debug → debug}/crm-dashboard/PipelineOverview.d.ts +0 -0
- /package/dist/{components/Debug → debug}/crm-dashboard/RecentActivity.d.ts +0 -0
- /package/dist/{components/Debug → debug}/crm-dashboard/TaskFilters.d.ts +0 -0
- /package/dist/{components/Debug → debug}/crm-dashboard/TaskTable.d.ts +0 -0
- /package/dist/{components/Debug → debug}/crm-dashboard/TasksView.d.ts +0 -0
package/src/core/RebaseProps.tsx
DELETED
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { User, DataDriver, DataSourceDefinition, StorageSource, StorageSourceDefinition, CollectionRegistryController, DatabaseAdmin, RebaseClient } from "@rebasepro/types";
|
|
3
|
-
import { Locale, AuthController, AnalyticsEvent, UserConfigurationPersistence, UrlController, NavigationStateController, RebaseContext, EntityLinkBuilder, RebasePlugin, SlotContribution, PropertyConfig, EntityCustomView, CollectionCustomView, EntityAction, RebaseTranslations, ComponentOverrideMap } from "@rebasepro/cms-types";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A data source registered on `<Rebase>`. Extends the shared
|
|
7
|
-
* {@link DataSourceDefinition} with the frontend {@link DataDriver} used for
|
|
8
|
-
* `direct`/`custom` transports. Server-mediated sources omit `driver` — they
|
|
9
|
-
* are reached through the `client`.
|
|
10
|
-
*
|
|
11
|
-
* @group Models
|
|
12
|
-
*/
|
|
13
|
-
export type RebaseDataSource = DataSourceDefinition & {
|
|
14
|
-
/**
|
|
15
|
-
* The client-side driver for this source. Required for `direct`/`custom`
|
|
16
|
-
* transports; omit for `server` transport (handled by the `client`).
|
|
17
|
-
*
|
|
18
|
-
* When `transport` is not stated it is inferred from this field:
|
|
19
|
-
* driver present → `"direct"`, absent → `"server"`.
|
|
20
|
-
*/
|
|
21
|
-
driver?: DataDriver;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A storage source registered on `<Rebase>`. Extends the shared
|
|
26
|
-
* {@link StorageSourceDefinition} with an optional frontend
|
|
27
|
-
* {@link StorageSource} for `direct` transports. Server-mediated sources
|
|
28
|
-
* omit `source` — they are reached through the `client`.
|
|
29
|
-
*
|
|
30
|
-
* @group Models
|
|
31
|
-
*/
|
|
32
|
-
export type RebaseStorageSource = StorageSourceDefinition & {
|
|
33
|
-
/**
|
|
34
|
-
* The client-side StorageSource for this backend. Required for `direct`
|
|
35
|
-
* transport (e.g. Firebase Storage via `@firebase/storage`); omit for
|
|
36
|
-
* `server` transport (proxied by the Rebase backend).
|
|
37
|
-
*/
|
|
38
|
-
source?: StorageSource;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/** DeepPartial helper — allows partial overrides at any nesting level */
|
|
42
|
-
type DeepPartial<T> = T extends object
|
|
43
|
-
? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
44
|
-
: T;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Controller to simulate different roles when dev mode is active.
|
|
48
|
-
* @group Models
|
|
49
|
-
*/
|
|
50
|
-
export type { EffectiveRoleController } from "@rebasepro/types";
|
|
51
|
-
import type { EffectiveRoleController } from "@rebasepro/types";
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Props for the main {@link Rebase} component.
|
|
56
|
-
*
|
|
57
|
-
* ## Data
|
|
58
|
-
*
|
|
59
|
-
* Everything is a data source, and there is one list: {@link dataSources}.
|
|
60
|
-
* The **default** source (serving every collection without a `dataSource`
|
|
61
|
-
* key) resolves with three rules:
|
|
62
|
-
*
|
|
63
|
-
* 1. A `dataSources` entry keyed `"(default)"` (`DEFAULT_DATA_SOURCE_KEY`)
|
|
64
|
-
* *with a driver* is the default source.
|
|
65
|
-
* 2. Otherwise `client.data` is the default.
|
|
66
|
-
* 3. Otherwise, if exactly one source is registered, it is the default.
|
|
67
|
-
* Zero sources, or several without a `"(default)"` key, **throw**.
|
|
68
|
-
*
|
|
69
|
-
* A `"(default)"` entry *without* a driver never provides data — it only
|
|
70
|
-
* declares the default source's `engine`/`label` (capabilities) when the
|
|
71
|
-
* client is the default.
|
|
72
|
-
*
|
|
73
|
-
* All other `dataSources` entries are routed non-default sources:
|
|
74
|
-
* collections opt in via `collection.dataSource`.
|
|
75
|
-
*
|
|
76
|
-
* ### Auth
|
|
77
|
-
*
|
|
78
|
-
* - `authController` prop → completely disables the `client.auth`
|
|
79
|
-
* subscription (an override, not a merge). The recommended pattern is to
|
|
80
|
-
* pass both `client` and an `authController` built from that client via
|
|
81
|
-
* `useRebaseAuthController({ client })`.
|
|
82
|
-
* - Otherwise, `client.auth` is subscribed to via `useAuthSubscription`.
|
|
83
|
-
*
|
|
84
|
-
* ### Storage (default source)
|
|
85
|
-
*
|
|
86
|
-
* Default: `storageSource` prop ?? `client.storage`.
|
|
87
|
-
*
|
|
88
|
-
* Named sources are merged in priority order (later entries with the same
|
|
89
|
-
* key overwrite earlier ones):
|
|
90
|
-
* 1. Backend-discovered remote definitions (`client.fetchStorageSources()`,
|
|
91
|
-
* fetched after auth/login-skip).
|
|
92
|
-
* 2. Client `storageRegistry` entries.
|
|
93
|
-
* 3. `storageSources` prop entries (live `direct` instances; `server`-
|
|
94
|
-
* transport keys are materialized via `client.createStorageSource`).
|
|
95
|
-
* 4. Default storage (keyed `DEFAULT_STORAGE_SOURCE_KEY`) as fallback.
|
|
96
|
-
*
|
|
97
|
-
* ## Decision Ladder
|
|
98
|
-
*
|
|
99
|
-
* | Scenario | Props to use |
|
|
100
|
-
* |---|---|
|
|
101
|
-
* | Standard app | `client` (+ `authController` built from it) |
|
|
102
|
-
* | Multi-backend data | add `dataSources` |
|
|
103
|
-
* | Multi-backend storage | add `storageSources` |
|
|
104
|
-
* | Fully headless / custom | `dataSources` with a `"(default)"`-keyed driver entry + `storageSource` |
|
|
105
|
-
*
|
|
106
|
-
* @group Models
|
|
107
|
-
*/
|
|
108
|
-
export type RebaseProps<USER extends User, DB = unknown> = {
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* The root components of your application. Use RebaseCMS, RebaseStudio, and RebaseShell.
|
|
112
|
-
* Alternatively, pass a render function that receives { context, loading }.
|
|
113
|
-
*/
|
|
114
|
-
children: React.ReactNode | ((props: { context: RebaseContext; loading: boolean }) => React.ReactNode);
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Optional base path for the entire Rebase app.
|
|
118
|
-
* Defaults to "/"
|
|
119
|
-
*/
|
|
120
|
-
basePath?: string;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Optional base path for the admin collections.
|
|
124
|
-
* Defaults to "/c"
|
|
125
|
-
*/
|
|
126
|
-
baseCollectionPath?: string;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Base URL for the backend API (e.g. "http://localhost:3001").
|
|
130
|
-
* When provided, this is available via `useApiConfig()` to any hook
|
|
131
|
-
* in the tree, reducing repetitive `apiUrl` threading.
|
|
132
|
-
*/
|
|
133
|
-
apiUrl?: string;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Format of the dates in the admin.
|
|
138
|
-
* Defaults to 'MMMM dd, yyyy, HH:mm:ss'
|
|
139
|
-
*/
|
|
140
|
-
dateTimeFormat?: string;
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Locale of the admin, currently only affecting dates
|
|
144
|
-
*/
|
|
145
|
-
locale?: Locale;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Unified RebaseClient for data, auth, and storage.
|
|
149
|
-
*
|
|
150
|
-
* `client.data` is the default data source unless a {@link dataSources}
|
|
151
|
-
* entry keyed `"(default)"` carries a driver.
|
|
152
|
-
* `client.auth` is subscribed unless `authController` is provided.
|
|
153
|
-
* `client.storage` is used unless `storageSource` is provided.
|
|
154
|
-
*
|
|
155
|
-
* `DB` is inferred from whatever is passed, and defaults to `unknown` for
|
|
156
|
-
* an untyped client. It has to be a parameter rather than a fixed
|
|
157
|
-
* `RebaseClient`: `RebaseClient<unknown>` is not a supertype of
|
|
158
|
-
* `RebaseClient<Database>` — the dynamic branch of `RebaseSdkData` is an
|
|
159
|
-
* index signature that no concrete instantiation satisfies — so pinning it
|
|
160
|
-
* here rejected the client of every project that generates a `Database`
|
|
161
|
-
* type, which is the whole typed-SDK path.
|
|
162
|
-
*/
|
|
163
|
-
client?: RebaseClient<DB>;
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* The data sources of the app. Each entry pairs a
|
|
167
|
-
* {@link DataSourceDefinition} (key, engine, transport) with an optional
|
|
168
|
-
* client-side {@link DataDriver}.
|
|
169
|
-
*
|
|
170
|
-
* Register the **direct** (e.g. Firestore, talking straight to its backend)
|
|
171
|
-
* and **custom** sources here. Server-mediated sources (Postgres, MongoDB,
|
|
172
|
-
* …) do *not* need an entry — they ride the `client` and are routed by the
|
|
173
|
-
* Rebase backend.
|
|
174
|
-
*
|
|
175
|
-
* An entry keyed `"(default)"` with a driver **replaces** `client.data`
|
|
176
|
-
* as the default data source (this is how a fully client-side app, e.g.
|
|
177
|
-
* Firestore-only, is wired). Without a driver, a `"(default)"` entry just
|
|
178
|
-
* declares the default source's engine/capabilities.
|
|
179
|
-
*
|
|
180
|
-
* Collections are routed automatically by their `dataSource` key (resolved
|
|
181
|
-
* by collection path against the registry), so routing works transparently
|
|
182
|
-
* for list/entity views, references, the board view, import/export, and
|
|
183
|
-
* programmatic `context.data` access — no per-collection wiring.
|
|
184
|
-
*
|
|
185
|
-
* @example
|
|
186
|
-
* ```tsx
|
|
187
|
-
* // Postgres via the Rebase client (default) + a direct Firestore source.
|
|
188
|
-
* <Rebase
|
|
189
|
-
* client={rebaseClient}
|
|
190
|
-
* dataSources={[
|
|
191
|
-
* { key: "analytics", engine: "firestore", driver: firestoreDriver }
|
|
192
|
-
* ]}
|
|
193
|
-
* >
|
|
194
|
-
* // Collections opt in with `{ ..., dataSource: "analytics" }`.
|
|
195
|
-
* ```
|
|
196
|
-
*/
|
|
197
|
-
dataSources?: RebaseDataSource[];
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Custom auth controller. When provided, the `client.auth` subscription
|
|
201
|
-
* is **completely disabled** (not merged).
|
|
202
|
-
*
|
|
203
|
-
* The recommended pattern is to pass both `client` and an
|
|
204
|
-
* `authController` built from that client:
|
|
205
|
-
* ```tsx
|
|
206
|
-
* const authController = useRebaseAuthController({ client });
|
|
207
|
-
* <Rebase client={client} authController={authController} />
|
|
208
|
-
* ```
|
|
209
|
-
* This lets the `authController` own the auth lifecycle while `client`
|
|
210
|
-
* still provides data and storage.
|
|
211
|
-
*/
|
|
212
|
-
authController?: AuthController<USER>;
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Default storage source. Overrides `client.storage` when provided.
|
|
216
|
-
* Named sources in {@link storageSources} are unaffected.
|
|
217
|
-
*/
|
|
218
|
-
storageSource?: StorageSource;
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Additional storage sources beyond the default `client.storage`.
|
|
222
|
-
*
|
|
223
|
-
* Register **direct** (e.g. Firebase Storage, talking straight to the
|
|
224
|
-
* cloud) sources here. Server-mediated sources (S3, GCS proxied by the
|
|
225
|
-
* Rebase backend) do *not* need an entry — they are routed by
|
|
226
|
-
* `storageId` query parameter on the REST API.
|
|
227
|
-
*
|
|
228
|
-
* Collection properties opt in via `storage.storageSource: "key"`.
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* ```tsx
|
|
232
|
-
* <Rebase
|
|
233
|
-
* client={rebaseClient}
|
|
234
|
-
* storageSources={[
|
|
235
|
-
* { key: "firebase", engine: "firebase", transport: "direct", source: firebaseStorageSource }
|
|
236
|
-
* ]}
|
|
237
|
-
* >
|
|
238
|
-
* ```
|
|
239
|
-
*/
|
|
240
|
-
storageSources?: RebaseStorageSource[];
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Administrative database operations (SQL, schema discovery).
|
|
244
|
-
* Only needed when the studio/admin features are enabled.
|
|
245
|
-
*/
|
|
246
|
-
databaseAdmin?: DatabaseAdmin;
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Use this controller to access the configuration that is stored locally,
|
|
250
|
-
* and not defined in code
|
|
251
|
-
*/
|
|
252
|
-
userConfigPersistence?: UserConfigurationPersistence;
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Callback used to get analytics events from the admin
|
|
256
|
-
*/
|
|
257
|
-
onAnalyticsEvent?: (event: AnalyticsEvent, data?: object) => void;
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Optional link builder you can add to generate a button in your entity forms.
|
|
261
|
-
* The function must return a URL that gets opened when the button is clicked
|
|
262
|
-
*/
|
|
263
|
-
entityLinkBuilder?: EntityLinkBuilder;
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Plugins loaded in the admin
|
|
268
|
-
*/
|
|
269
|
-
plugins?: RebasePlugin[];
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Extra slots for the admin
|
|
273
|
-
*/
|
|
274
|
-
slots?: SlotContribution[];
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Property configs (widgets)
|
|
278
|
-
*/
|
|
279
|
-
propertyConfigs?: Record<string, PropertyConfig>;
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Entity Views
|
|
283
|
-
*/
|
|
284
|
-
entityViews?: EntityCustomView[];
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Custom collection view modes, available to every collection by `key`.
|
|
288
|
-
* A collection opts into one by naming that key in `admin.customViews`.
|
|
289
|
-
*/
|
|
290
|
-
collectionViews?: CollectionCustomView[];
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Entity Actions
|
|
294
|
-
*/
|
|
295
|
-
entityActions?: EntityAction[];
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Controller to simulate different roles when dev mode is active.
|
|
299
|
-
*/
|
|
300
|
-
effectiveRoleController?: EffectiveRoleController;
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Override or extend any Rebase UI string, keyed by locale.
|
|
304
|
-
*/
|
|
305
|
-
translations?: {
|
|
306
|
-
[locale: string]: DeepPartial<RebaseTranslations>;
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Override built-in UI components with custom implementations.
|
|
311
|
-
*
|
|
312
|
-
* Keys are component names from {@link OverridableComponentName}.
|
|
313
|
-
* Values specify the replacement component and an optional `wrap`
|
|
314
|
-
* flag for the wrapping pattern.
|
|
315
|
-
*
|
|
316
|
-
* @example
|
|
317
|
-
* ```tsx
|
|
318
|
-
* <Rebase
|
|
319
|
-
* client={client}
|
|
320
|
-
* components={{
|
|
321
|
-
* "Shell.AppBar": { Component: MyCustomAppBar },
|
|
322
|
-
* "EditView.FormActions": {
|
|
323
|
-
* Component: MyFormActions,
|
|
324
|
-
* wrap: true
|
|
325
|
-
* }
|
|
326
|
-
* }}
|
|
327
|
-
* >
|
|
328
|
-
* ```
|
|
329
|
-
*/
|
|
330
|
-
components?: ComponentOverrideMap;
|
|
331
|
-
|
|
332
|
-
};
|
|
333
|
-
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createBrowserRouter } from "react-router"
|
|
2
|
-
import { RouterProvider } from "react-router/dom"
|
|
3
|
-
import { removeInitialAndTrailingSlashes } from "@rebasepro/app";
|
|
4
|
-
|
|
5
|
-
export function RebaseRouter({
|
|
6
|
-
children,
|
|
7
|
-
basePath
|
|
8
|
-
}: {
|
|
9
|
-
children: React.ReactNode,
|
|
10
|
-
basePath?: string;
|
|
11
|
-
}) {
|
|
12
|
-
return <RouterProvider router={createBrowserRouter([
|
|
13
|
-
{
|
|
14
|
-
path: basePath ? `${removeInitialAndTrailingSlashes(basePath)}/*` : "/*",
|
|
15
|
-
element: children
|
|
16
|
-
}
|
|
17
|
-
])}/>;
|
|
18
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Route, Routes, useLocation } from "react-router";
|
|
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
|
-
}
|
package/src/core/index.tsx
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
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
|
-
/**
|
|
13
|
-
* The path the backend mounts its API under, appended to {@link apiUrl}.
|
|
14
|
-
*
|
|
15
|
-
* `"/api"` by default, which is the server's default `basePath`. It is
|
|
16
|
-
* carried here because a good deal of UI builds request URLs by hand
|
|
17
|
-
* instead of going through the client's typed methods, and every one of
|
|
18
|
-
* those sites used to write `/api` as a literal — so a backend configured
|
|
19
|
-
* with any other `basePath` served an admin panel whose auth-provider
|
|
20
|
-
* discovery, storage browser, history panel, user picker and Studio tools
|
|
21
|
-
* all requested paths that did not exist.
|
|
22
|
-
*/
|
|
23
|
-
apiPath: string;
|
|
24
|
-
getAuthToken?: () => Promise<string | null>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** What the server uses when `basePath` is not configured. */
|
|
28
|
-
export const DEFAULT_API_PATH = "/api";
|
|
29
|
-
|
|
30
|
-
const ApiConfigContext = React.createContext<ApiConfig | undefined>(undefined);
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Read the API config from context. Returns `undefined` if no provider is present,
|
|
34
|
-
* allowing hooks to fall back to their own props.
|
|
35
|
-
*/
|
|
36
|
-
export function useApiConfig(): ApiConfig | undefined {
|
|
37
|
-
return useContext(ApiConfigContext);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* `apiUrl` and `apiPath` joined, with no trailing slash — the prefix to build a
|
|
42
|
-
* request URL from.
|
|
43
|
-
*
|
|
44
|
-
* Returns `undefined` when there is no provider, so a caller can keep its own
|
|
45
|
-
* fallback rather than silently requesting a relative path.
|
|
46
|
-
*/
|
|
47
|
-
export function useApiBase(): string | undefined {
|
|
48
|
-
const config = useApiConfig();
|
|
49
|
-
if (!config?.apiUrl) return undefined;
|
|
50
|
-
return config.apiUrl.replace(/\/+$/, "") + (config.apiPath || DEFAULT_API_PATH);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* The same prefix, derived from a client rather than from context.
|
|
55
|
-
*
|
|
56
|
-
* For the code that holds a `RebaseClient` but sits outside (or above) an
|
|
57
|
-
* `ApiConfigProvider`. Returns `undefined` when the client has no base URL,
|
|
58
|
-
* which is the signal every caller already treats as "cannot build a request".
|
|
59
|
-
*/
|
|
60
|
-
export function apiBaseOf(client?: { baseUrl?: string; apiPath?: string }): string | undefined {
|
|
61
|
-
if (!client?.baseUrl) return undefined;
|
|
62
|
-
return client.baseUrl.replace(/\/+$/, "") + (client.apiPath || DEFAULT_API_PATH);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Provide API configuration (apiUrl, apiPath, getAuthToken) to the entire subtree.
|
|
67
|
-
* Typically rendered inside `<Rebase>` or at the app root.
|
|
68
|
-
*/
|
|
69
|
-
export function ApiConfigProvider({
|
|
70
|
-
apiUrl,
|
|
71
|
-
apiPath = DEFAULT_API_PATH,
|
|
72
|
-
getAuthToken,
|
|
73
|
-
children
|
|
74
|
-
}: Omit<ApiConfig, "apiPath"> & { apiPath?: string; children: React.ReactNode }) {
|
|
75
|
-
const value = React.useMemo(() => ({ apiUrl,
|
|
76
|
-
apiPath,
|
|
77
|
-
getAuthToken }), [apiUrl, apiPath, getAuthToken]);
|
|
78
|
-
return (
|
|
79
|
-
<ApiConfigContext.Provider value={value}>
|
|
80
|
-
{children}
|
|
81
|
-
</ApiConfigContext.Provider>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { FindParams, FilterValues, LogicalCondition, OrderBySpec } from "@rebasepro/types";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The one place a collection read's parameters are assembled.
|
|
5
|
-
*
|
|
6
|
-
* ## Why this exists
|
|
7
|
-
*
|
|
8
|
-
* Four call sites used to build this object by hand — `useCollection` and
|
|
9
|
-
* `useDataTableController`, each in both their `listen` and `find` branches.
|
|
10
|
-
* Every one of them listed the fields it forwarded, so adding an option to
|
|
11
|
-
* `FindParams` meant remembering four places, and forgetting one failed
|
|
12
|
-
* silently: the option simply never reached the server, and the feature it
|
|
13
|
-
* enabled looked broken for reasons nowhere near the code that dropped it.
|
|
14
|
-
*
|
|
15
|
-
* That is not hypothetical. `searchExplain` was added to three of the four and
|
|
16
|
-
* the miss was found by intercepting a WebSocket frame, because nothing else
|
|
17
|
-
* could see it.
|
|
18
|
-
*
|
|
19
|
-
* A field added here reaches every read. `toFindParams` returns `FindParams`
|
|
20
|
-
* itself, so the compiler checks the shape rather than a hand-copied list.
|
|
21
|
-
*/
|
|
22
|
-
export interface CollectionQueryInput<M extends Record<string, unknown>> {
|
|
23
|
-
where?: FilterValues<Extract<keyof M, string>>;
|
|
24
|
-
logical?: LogicalCondition;
|
|
25
|
-
/**
|
|
26
|
-
* Loosened from `FindParams["orderBy"]` on purpose: callers hold the sort
|
|
27
|
-
* as plain `[string, direction]` pairs read off user config or a URL, where
|
|
28
|
-
* the columns are not statically known. Narrowing it here would push a cast
|
|
29
|
-
* onto every call site, which is the kind of friction that sends people back
|
|
30
|
-
* to hand-building the object this exists to replace.
|
|
31
|
-
*/
|
|
32
|
-
orderBy?: OrderBySpec;
|
|
33
|
-
limit?: number;
|
|
34
|
-
offset?: number;
|
|
35
|
-
page?: number;
|
|
36
|
-
searchString?: string;
|
|
37
|
-
include?: string[];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Build the parameters for one collection read.
|
|
42
|
-
*
|
|
43
|
-
* Derived options live here rather than at the call sites, so they cannot
|
|
44
|
-
* disagree: `searchExplain` rides along exactly when there is a search string
|
|
45
|
-
* to explain, which is also the only time it costs anything.
|
|
46
|
-
*/
|
|
47
|
-
export function toFindParams<M extends Record<string, unknown>>(
|
|
48
|
-
input: CollectionQueryInput<M>
|
|
49
|
-
): FindParams<M> {
|
|
50
|
-
const { searchString, ...rest } = input;
|
|
51
|
-
return {
|
|
52
|
-
...rest,
|
|
53
|
-
...(searchString ? { searchString, searchExplain: true } : {})
|
|
54
|
-
} as FindParams<M>;
|
|
55
|
-
}
|
package/src/hooks/data/delete.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Entity, CollectionCallbacks, User } from "@rebasepro/types";
|
|
3
|
-
import { RebaseContext, AdminCollection } from "@rebasepro/cms-types";
|
|
4
|
-
import { RebaseData } from "@rebasepro/types";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @group Hooks and utilities
|
|
8
|
-
*/
|
|
9
|
-
export type DeleteEntityWithCallbacksProps<M extends Record<string, any>, USER extends User = User> = {
|
|
10
|
-
entity: Entity<M>;
|
|
11
|
-
collection?: AdminCollection<M>;
|
|
12
|
-
callbacks?: CollectionCallbacks<M, USER>;
|
|
13
|
-
onDeleteSuccess?: (entity: Entity<M>) => void;
|
|
14
|
-
onDeleteFailure?: (entity: Entity<M>, e: Error) => void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* This function is in charge of deleting a entity.
|
|
19
|
-
* It will run all the delete callbacks specified in the collection.
|
|
20
|
-
* It is also possible to attach callbacks on save success or error, and callback
|
|
21
|
-
* errors.
|
|
22
|
-
*
|
|
23
|
-
* @param data
|
|
24
|
-
* @param entity
|
|
25
|
-
* @param collection
|
|
26
|
-
* @param callbacks
|
|
27
|
-
* @param onDeleteSuccess
|
|
28
|
-
* @param onDeleteFailure
|
|
29
|
-
* @param context
|
|
30
|
-
* @group Hooks and utilities
|
|
31
|
-
*/
|
|
32
|
-
export async function deleteEntityWithCallbacks<M extends Record<string, any>, USER extends User>({
|
|
33
|
-
data,
|
|
34
|
-
entity,
|
|
35
|
-
collection,
|
|
36
|
-
callbacks,
|
|
37
|
-
onDeleteSuccess,
|
|
38
|
-
onDeleteFailure,
|
|
39
|
-
context
|
|
40
|
-
}: DeleteEntityWithCallbacksProps<M> & {
|
|
41
|
-
collection: AdminCollection<M>,
|
|
42
|
-
data: RebaseData,
|
|
43
|
-
context: RebaseContext<USER>
|
|
44
|
-
}
|
|
45
|
-
): Promise<boolean> {
|
|
46
|
-
|
|
47
|
-
console.debug("Deleting entity", entity.path, entity.id);
|
|
48
|
-
|
|
49
|
-
return data.collection(entity.path).delete(entity.id).then(() => {
|
|
50
|
-
if (onDeleteSuccess) onDeleteSuccess(entity);
|
|
51
|
-
return true;
|
|
52
|
-
}).catch((e) => {
|
|
53
|
-
if (onDeleteFailure) onDeleteFailure(entity, e);
|
|
54
|
-
return false;
|
|
55
|
-
});
|
|
56
|
-
}
|
package/src/hooks/data/save.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Entity, EntityStatus, EntityValues } from "@rebasepro/types";
|
|
3
|
-
import { RebaseContext, AdminCollection } from "@rebasepro/cms-types";
|
|
4
|
-
import { RebaseData } from "@rebasepro/types";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @group Hooks and utilities
|
|
8
|
-
*/
|
|
9
|
-
export type SaveEntityWithCallbacksProps<M extends Record<string, unknown>> = {
|
|
10
|
-
path: string;
|
|
11
|
-
values: Partial<EntityValues<M>>;
|
|
12
|
-
entityId?: string | number;
|
|
13
|
-
previousValues?: Partial<EntityValues<M>>;
|
|
14
|
-
collection?: AdminCollection<M>;
|
|
15
|
-
status: EntityStatus;
|
|
16
|
-
afterSave?: (updatedEntity: Entity<M>) => void,
|
|
17
|
-
afterSaveError?: (e: Error) => void
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* This function is in charge of saving a entity.
|
|
22
|
-
* It will run all the save callbacks specified in the collection.
|
|
23
|
-
* It is also possible to attach callbacks on save success or error, and callback
|
|
24
|
-
* errors.
|
|
25
|
-
*
|
|
26
|
-
* @param collection
|
|
27
|
-
* @param path
|
|
28
|
-
* @param entityId
|
|
29
|
-
* @param callbacks
|
|
30
|
-
* @param values
|
|
31
|
-
* @param previousValues
|
|
32
|
-
* @param status
|
|
33
|
-
* @param data
|
|
34
|
-
* @param context
|
|
35
|
-
* @param afterSave
|
|
36
|
-
* @param afterSaveError
|
|
37
|
-
* @group Hooks and utilities
|
|
38
|
-
*/
|
|
39
|
-
export async function saveEntityWithCallbacks<M extends Record<string, unknown>>({
|
|
40
|
-
collection,
|
|
41
|
-
path,
|
|
42
|
-
entityId,
|
|
43
|
-
values,
|
|
44
|
-
previousValues,
|
|
45
|
-
status,
|
|
46
|
-
data,
|
|
47
|
-
context,
|
|
48
|
-
afterSave,
|
|
49
|
-
afterSaveError
|
|
50
|
-
}: Omit<SaveEntityWithCallbacksProps<M>, "collection"> & {
|
|
51
|
-
collection: AdminCollection<M>,
|
|
52
|
-
data: RebaseData,
|
|
53
|
-
context: RebaseContext,
|
|
54
|
-
}
|
|
55
|
-
): Promise<Entity<M>> {
|
|
56
|
-
|
|
57
|
-
if (status !== "new" && status !== "copy" && !entityId) {
|
|
58
|
-
throw new Error("Entity id must be specified when updating an existing entity");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const accessor = data.collection(path);
|
|
62
|
-
|
|
63
|
-
let savePromise: Promise<Entity<M>>;
|
|
64
|
-
if (status === "new" || status === "copy") {
|
|
65
|
-
savePromise = accessor.create(values, entityId) as Promise<Entity<M>>;
|
|
66
|
-
} else {
|
|
67
|
-
savePromise = accessor.update(entityId!, values) as Promise<Entity<M>>;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return savePromise.then((entity) => {
|
|
71
|
-
if (afterSave)
|
|
72
|
-
afterSave(entity);
|
|
73
|
-
return entity as Entity<M>;
|
|
74
|
-
}).catch((e) => {
|
|
75
|
-
if (afterSaveError) afterSaveError(e);
|
|
76
|
-
throw e;
|
|
77
|
-
});
|
|
78
|
-
}
|