@rebasepro/app 0.10.0 → 0.10.1-canary.0a881d4
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/dist/auth/types.d.ts +2 -1
- package/dist/collections/collection_view_config.d.ts +32 -0
- package/dist/collections/entity_image_preview.d.ts +2 -0
- package/dist/collections/filter-operator-resolution.d.ts +32 -0
- package/dist/collections/index.d.ts +8 -0
- package/dist/collections/navigation_from_path.d.ts +34 -0
- package/dist/collections/navigation_utils.d.ts +20 -0
- package/dist/collections/parent_references_from_path.d.ts +7 -0
- package/dist/collections/property_presentation.d.ts +20 -0
- package/dist/collections/title-property.d.ts +43 -0
- package/dist/components/Debug/UIReferenceView.d.ts +10 -3
- package/dist/components/LoginView/LoginView.d.ts +1 -1
- package/dist/components/RebaseAuth.d.ts +1 -1
- package/dist/components/common/types.d.ts +1 -1
- package/dist/components/common/useColumnsIds.d.ts +5 -4
- package/dist/components/common/useDataTableController.d.ts +3 -3
- package/dist/contexts/AnalyticsContext.d.ts +1 -1
- package/dist/contexts/AuthControllerContext.d.ts +1 -1
- package/dist/contexts/CollectionScopeContext.d.ts +4 -4
- package/dist/contexts/ComponentOverrideContext.d.ts +1 -1
- package/dist/contexts/CustomizationControllerContext.d.ts +1 -1
- package/dist/contexts/DialogsProvider.d.ts +1 -1
- package/dist/contexts/UserConfigurationPersistenceContext.d.ts +1 -1
- package/dist/core/PluginLifecycleManager.d.ts +1 -1
- package/dist/core/PluginProviderStack.d.ts +1 -1
- package/dist/core/RebaseProps.d.ts +2 -1
- package/dist/hooks/data/delete.d.ts +4 -4
- package/dist/hooks/data/save.d.ts +5 -5
- package/dist/hooks/data/useCollection.d.ts +2 -2
- package/dist/hooks/data/useFetch.d.ts +2 -2
- package/dist/hooks/data/useRelationSelector.d.ts +2 -2
- package/dist/hooks/useAnalyticsController.d.ts +1 -1
- package/dist/hooks/useAuthController.d.ts +2 -1
- package/dist/hooks/useAuthSubscription.d.ts +2 -1
- package/dist/hooks/useBuildLocalConfigurationPersistence.d.ts +1 -1
- package/dist/hooks/useComponentOverride.d.ts +1 -1
- package/dist/hooks/useCustomizationController.d.ts +1 -1
- package/dist/hooks/useDialogsController.d.ts +1 -1
- package/dist/hooks/usePermissions.d.ts +5 -5
- package/dist/hooks/useRebaseContext.d.ts +2 -1
- package/dist/hooks/useRebaseRegistry.d.ts +1 -1
- package/dist/hooks/useSlot.d.ts +1 -1
- package/dist/hooks/useSnackbarController.d.ts +1 -1
- package/dist/hooks/useStudioBridge.d.ts +2 -1
- package/dist/hooks/useUserConfigurationPersistence.d.ts +1 -1
- package/dist/i18n/RebaseI18nProvider.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +799 -121
- package/dist/index.es.js.map +1 -1
- package/dist/locales/de.d.ts +1 -1
- package/dist/locales/en.d.ts +1 -1
- package/dist/locales/es.d.ts +1 -1
- package/dist/locales/fr.d.ts +1 -1
- package/dist/locales/hi.d.ts +1 -1
- package/dist/locales/it.d.ts +1 -1
- package/dist/locales/pt.d.ts +1 -1
- package/dist/util/previews.d.ts +10 -5
- package/dist/vitePlugin.js +1 -1
- package/package.json +9 -7
- package/src/auth/types.ts +2 -1
- package/src/collections/collection_view_config.ts +57 -0
- package/src/collections/entity_image_preview.ts +48 -0
- package/src/collections/filter-operator-resolution.ts +81 -0
- package/src/collections/index.ts +8 -0
- package/src/collections/navigation_from_path.ts +123 -0
- package/src/collections/navigation_utils.ts +171 -0
- package/src/collections/parent_references_from_path.ts +59 -0
- package/src/collections/property_presentation.ts +224 -0
- package/src/collections/title-property.ts +264 -0
- package/src/components/Debug/UIReferenceView.tsx +31 -27
- package/src/components/Debug/collection-views/CardViewDemo.tsx +4 -2
- package/src/components/Debug/collection-views/CollectionTableDemo.tsx +2 -2
- package/src/components/Debug/collection-views/KanbanBoardDemo.tsx +1 -2
- package/src/components/Debug/crm-dashboard/CalendarWidget.tsx +5 -7
- package/src/components/Debug/crm-dashboard/CrmDashboardDemo.tsx +14 -20
- package/src/components/Debug/crm-dashboard/DashboardMetrics.tsx +7 -9
- package/src/components/Debug/crm-dashboard/PipelineOverview.tsx +8 -10
- package/src/components/Debug/crm-dashboard/RecentActivity.tsx +25 -27
- package/src/components/Debug/crm-dashboard/TaskFilters.tsx +7 -9
- package/src/components/Debug/crm-dashboard/TaskTable.tsx +8 -10
- package/src/components/LoginView/LoginView.tsx +55 -4
- package/src/components/RebaseAuth.tsx +1 -1
- package/src/components/common/types.tsx +1 -1
- package/src/components/common/useColumnsIds.tsx +24 -23
- package/src/components/common/useDataTableController.tsx +4 -4
- package/src/contexts/AnalyticsContext.tsx +1 -1
- package/src/contexts/AuthControllerContext.tsx +1 -1
- package/src/contexts/CollectionScopeContext.tsx +6 -5
- package/src/contexts/ComponentOverrideContext.tsx +1 -1
- package/src/contexts/CustomizationControllerContext.tsx +1 -1
- package/src/contexts/DialogsProvider.tsx +1 -1
- package/src/contexts/UserConfigurationPersistenceContext.tsx +1 -1
- package/src/core/PluginLifecycleManager.tsx +2 -1
- package/src/core/PluginProviderStack.tsx +1 -1
- package/src/core/Rebase.tsx +4 -3
- package/src/core/RebaseProps.tsx +2 -1
- package/src/core/RebaseRouter.tsx +1 -1
- package/src/hooks/data/delete.ts +5 -4
- package/src/hooks/data/save.ts +6 -5
- package/src/hooks/data/useCollection.tsx +3 -2
- package/src/hooks/data/useFetch.tsx +4 -3
- package/src/hooks/data/useRelationSelector.tsx +3 -2
- package/src/hooks/useAnalyticsController.tsx +1 -1
- package/src/hooks/useAuthController.tsx +2 -1
- package/src/hooks/useAuthSubscription.ts +2 -1
- package/src/hooks/useBuildLocalConfigurationPersistence.tsx +1 -1
- package/src/hooks/useComponentOverride.tsx +1 -1
- package/src/hooks/useCustomizationController.tsx +1 -1
- package/src/hooks/useDialogsController.tsx +1 -1
- package/src/hooks/usePermissions.ts +6 -5
- package/src/hooks/useRebaseContext.tsx +2 -1
- package/src/hooks/useRebaseRegistry.tsx +1 -1
- package/src/hooks/useResolvedComponent.tsx +44 -11
- package/src/hooks/useSlot.tsx +1 -1
- package/src/hooks/useSnackbarController.tsx +1 -1
- package/src/hooks/useStudioBridge.tsx +4 -2
- package/src/hooks/useUserConfigurationPersistence.tsx +1 -1
- package/src/i18n/RebaseI18nProvider.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/locales/de.ts +1 -1
- package/src/locales/en.ts +1 -1
- package/src/locales/es.ts +1 -1
- package/src/locales/fr.ts +1 -1
- package/src/locales/hi.ts +1 -1
- package/src/locales/it.ts +1 -1
- package/src/locales/pt.ts +1 -1
- package/src/util/previews.ts +16 -34
- package/src/vitePlugin.ts +5 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Property, MapProperty, Properties } from "@rebasepro/types";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
;
|
|
4
4
|
import { getSubcollections } from "@rebasepro/common";
|
|
5
|
+
import type { AdminCollection } from "@rebasepro/admin-types";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Get a property in a property tree from a dot-path like `address.street`.
|
|
@@ -28,10 +29,10 @@ export type PropertyColumnConfig = {
|
|
|
28
29
|
disabled: boolean;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
|
-
export function getSubcollectionColumnId(collection:
|
|
32
|
+
export function getSubcollectionColumnId(collection: AdminCollection<any>) {
|
|
32
33
|
return `subcollection:${collection.slug}`;
|
|
33
34
|
}
|
|
34
|
-
export function useColumnIds<M extends Record<string, any>>(collection:
|
|
35
|
+
export function useColumnIds<M extends Record<string, any>>(collection: AdminCollection<M>, includeSubcollections: boolean): PropertyColumnConfig[] {
|
|
35
36
|
return useMemo(() => {
|
|
36
37
|
if (collection.propertiesOrder) {
|
|
37
38
|
return hideAndExpandKeys(collection, collection.propertiesOrder);
|
|
@@ -40,7 +41,7 @@ export function useColumnIds<M extends Record<string, any>>(collection: Collecti
|
|
|
40
41
|
}, [collection, includeSubcollections]);
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
function hideAndExpandKeys<M extends Record<string, any>>(collection:
|
|
44
|
+
function hideAndExpandKeys<M extends Record<string, any>>(collection: AdminCollection<M>, keys: string[]): PropertyColumnConfig[] {
|
|
44
45
|
|
|
45
46
|
// First, figure out which spread map roots have individual child keys in the order
|
|
46
47
|
// If so, we should NOT auto-expand them - just use the explicit child keys
|
|
@@ -49,7 +50,7 @@ function hideAndExpandKeys<M extends Record<string, any>>(collection: Collection
|
|
|
49
50
|
if (key.includes(".")) {
|
|
50
51
|
const rootKey = key.split(".")[0];
|
|
51
52
|
const rootProperty = collection.properties[rootKey];
|
|
52
|
-
if (rootProperty && rootProperty.type === "map" && rootProperty.
|
|
53
|
+
if (rootProperty && rootProperty.type === "map" && rootProperty.admin?.spreadChildren && rootProperty.properties) {
|
|
53
54
|
rootsWithExplicitChildren.add(rootKey);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
@@ -66,12 +67,12 @@ function hideAndExpandKeys<M extends Record<string, any>>(collection: Collection
|
|
|
66
67
|
const property = collection.properties[key];
|
|
67
68
|
if (property) {
|
|
68
69
|
processedPropertyKeys.add(key);
|
|
69
|
-
if (property.
|
|
70
|
+
if (property.admin?.hideFromCollection)
|
|
70
71
|
return [null];
|
|
71
|
-
if (property.
|
|
72
|
+
if (property.admin?.disabled && typeof property.admin?.disabled === "object" && property.admin?.disabled.hidden)
|
|
72
73
|
return [null];
|
|
73
74
|
|
|
74
|
-
if (property.type === "map" && property.
|
|
75
|
+
if (property.type === "map" && property.admin?.spreadChildren && property.properties) {
|
|
75
76
|
// Check if this spread map has explicit child keys in propertiesOrder
|
|
76
77
|
if (rootsWithExplicitChildren.has(key)) {
|
|
77
78
|
// DON'T auto-expand - the children are explicitly listed elsewhere
|
|
@@ -84,7 +85,7 @@ function hideAndExpandKeys<M extends Record<string, any>>(collection: Collection
|
|
|
84
85
|
}
|
|
85
86
|
return [{
|
|
86
87
|
key,
|
|
87
|
-
disabled: Boolean(property.
|
|
88
|
+
disabled: Boolean(property.admin?.disabled) || Boolean(property.admin?.readOnly)
|
|
88
89
|
}];
|
|
89
90
|
}
|
|
90
91
|
|
|
@@ -100,15 +101,15 @@ function hideAndExpandKeys<M extends Record<string, any>>(collection: Collection
|
|
|
100
101
|
// Mark root as seen
|
|
101
102
|
processedPropertyKeys.add(rootKey);
|
|
102
103
|
|
|
103
|
-
if (nestedProperty.
|
|
104
|
+
if (nestedProperty.admin?.hideFromCollection)
|
|
104
105
|
return [null];
|
|
105
|
-
if (nestedProperty.
|
|
106
|
+
if (nestedProperty.admin?.disabled && typeof nestedProperty.admin?.disabled === "object" && nestedProperty.admin?.disabled.hidden)
|
|
106
107
|
return [null];
|
|
107
108
|
|
|
108
109
|
return [{
|
|
109
110
|
key,
|
|
110
|
-
disabled: Boolean(rootProperty.
|
|
111
|
-
Boolean(nestedProperty.
|
|
111
|
+
disabled: Boolean(rootProperty.admin?.disabled) || Boolean(rootProperty.admin?.readOnly) ||
|
|
112
|
+
Boolean(nestedProperty.admin?.disabled) || Boolean(nestedProperty.admin?.readOnly)
|
|
112
113
|
}];
|
|
113
114
|
}
|
|
114
115
|
}
|
|
@@ -147,10 +148,10 @@ function hideAndExpandKeys<M extends Record<string, any>>(collection: Collection
|
|
|
147
148
|
|
|
148
149
|
const property = collection.properties[propKey];
|
|
149
150
|
if (!property) continue;
|
|
150
|
-
if (property.
|
|
151
|
-
if (property.
|
|
151
|
+
if (property.admin?.hideFromCollection) continue;
|
|
152
|
+
if (property.admin?.disabled && typeof property.admin?.disabled === "object" && property.admin?.disabled.hidden) continue;
|
|
152
153
|
|
|
153
|
-
if (property.type === "map" && property.
|
|
154
|
+
if (property.type === "map" && property.admin?.spreadChildren && property.properties) {
|
|
154
155
|
// For spread maps, add all children that weren't already added
|
|
155
156
|
const allChildConfigs = getColumnKeysForProperty(property as MapProperty, propKey);
|
|
156
157
|
for (const childConfig of allChildConfigs) {
|
|
@@ -162,7 +163,7 @@ function hideAndExpandKeys<M extends Record<string, any>>(collection: Collection
|
|
|
162
163
|
} else {
|
|
163
164
|
result.push({
|
|
164
165
|
key: propKey,
|
|
165
|
-
disabled: Boolean(property.
|
|
166
|
+
disabled: Boolean(property.admin?.disabled) || Boolean(property.admin?.readOnly)
|
|
166
167
|
});
|
|
167
168
|
processedPropertyKeys.add(propKey);
|
|
168
169
|
}
|
|
@@ -171,11 +172,11 @@ function hideAndExpandKeys<M extends Record<string, any>>(collection: Collection
|
|
|
171
172
|
return result;
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
function getDefaultColumnKeys<M extends Record<string, any> = any>(collection:
|
|
175
|
+
function getDefaultColumnKeys<M extends Record<string, any> = any>(collection: AdminCollection<M>, includeSubCollections: boolean) {
|
|
175
176
|
const propertyKeys = Object.keys(collection.properties);
|
|
176
177
|
|
|
177
178
|
const additionalFields = collection.additionalFields ?? [];
|
|
178
|
-
const subCollections:
|
|
179
|
+
const subCollections: AdminCollection[] = getSubcollections(collection) ?? [];
|
|
179
180
|
|
|
180
181
|
const columnIds: string[] = [
|
|
181
182
|
...propertyKeys,
|
|
@@ -193,21 +194,21 @@ function getDefaultColumnKeys<M extends Record<string, any> = any>(collection: C
|
|
|
193
194
|
}
|
|
194
195
|
|
|
195
196
|
export function getColumnKeysForProperty(property: Property, key: string, disabled?: boolean): PropertyColumnConfig[] {
|
|
196
|
-
if (property.type === "map" && property.
|
|
197
|
+
if (property.type === "map" && property.admin?.spreadChildren && property.properties) {
|
|
197
198
|
return Object.entries(property.properties)
|
|
198
199
|
.flatMap(([childKey, childProperty]) => getColumnKeysForProperty(
|
|
199
200
|
childProperty as Readonly<Property>,
|
|
200
201
|
`${key}.${childKey}`,
|
|
201
|
-
disabled || Boolean(property.
|
|
202
|
+
disabled || Boolean(property.admin?.disabled) || Boolean(property.admin?.readOnly))
|
|
202
203
|
);
|
|
203
204
|
}
|
|
204
205
|
return [{
|
|
205
206
|
key,
|
|
206
|
-
disabled: disabled || Boolean(property.
|
|
207
|
+
disabled: disabled || Boolean(property.admin?.disabled) || Boolean(property.admin?.readOnly)
|
|
207
208
|
}];
|
|
208
209
|
}
|
|
209
210
|
|
|
210
|
-
export function getFormFieldKeys(collection:
|
|
211
|
+
export function getFormFieldKeys(collection: AdminCollection): string[] {
|
|
211
212
|
const propertyKeys = collection.properties ? Object.keys(collection.properties) : [];
|
|
212
213
|
const additionalFields = collection.additionalFields ?? [];
|
|
213
214
|
const allKeys = [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { useLocation } from "react-router-dom";
|
|
4
4
|
|
|
@@ -6,7 +6,8 @@ import { useData, useRebaseContext } from "../../hooks";
|
|
|
6
6
|
import { useDataOrder } from "../../hooks/data/useDataOrder";
|
|
7
7
|
import { populateFetchCache } from "../../hooks/data/useFetch";
|
|
8
8
|
import { getRelationIncludeParams } from "../../util/previews";
|
|
9
|
-
import { Entity, EntityReference, EntityRelation,
|
|
9
|
+
import { Entity, EntityReference, EntityRelation, FilterValues, User, WhereFilterOp, FindResponse } from "@rebasepro/types";
|
|
10
|
+
import { EntityTableController, RebaseContext, SelectedCellProps, AdminCollection } from "@rebasepro/admin-types";
|
|
10
11
|
import { ScrollRestorationController } from "./useScrollRestoration";
|
|
11
12
|
|
|
12
13
|
export const DEFAULT_PAGE_SIZE = 50;
|
|
@@ -19,7 +20,7 @@ export type DataTableControllerProps<M extends Record<string, any> = any> = {
|
|
|
19
20
|
/**
|
|
20
21
|
* The collection that is represented by this config.
|
|
21
22
|
*/
|
|
22
|
-
collection:
|
|
23
|
+
collection: AdminCollection<M>;
|
|
23
24
|
/**
|
|
24
25
|
* List of entities that will be displayed on top, no matter the ordering.
|
|
25
26
|
* This is used for reference fields selection
|
|
@@ -282,7 +283,6 @@ export function useDataTableController<M extends Record<string, any> = any, USER
|
|
|
282
283
|
return unsubscribe;
|
|
283
284
|
}, [dataClient, path, itemCount, currentSort, sortByProperty, filterValues, searchString]);
|
|
284
285
|
|
|
285
|
-
|
|
286
286
|
const orderedData = useDataOrder({
|
|
287
287
|
data: rawData,
|
|
288
288
|
entitiesDisplayedFirst
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { createContext, useContext } from "react";
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { CollectionComponentOverrideProvider } from "./ComponentOverrideContext";
|
|
4
|
+
import type { AdminCollection } from "@rebasepro/admin-types";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Carries the collection a UI subtree is currently bound to.
|
|
@@ -15,7 +16,7 @@ import { CollectionComponentOverrideProvider } from "./ComponentOverrideContext"
|
|
|
15
16
|
*
|
|
16
17
|
* @internal
|
|
17
18
|
*/
|
|
18
|
-
export const CollectionScopeContext = createContext<
|
|
19
|
+
export const CollectionScopeContext = createContext<AdminCollection | undefined>(undefined);
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Read the collection the current subtree is bound to, or `undefined` when
|
|
@@ -23,7 +24,7 @@ export const CollectionScopeContext = createContext<CollectionConfig | undefined
|
|
|
23
24
|
*
|
|
24
25
|
* @group Hooks
|
|
25
26
|
*/
|
|
26
|
-
export function useCollectionScope():
|
|
27
|
+
export function useCollectionScope(): AdminCollection | undefined {
|
|
27
28
|
return useContext(CollectionScopeContext);
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -54,11 +55,11 @@ export function CollectionScopeProvider({
|
|
|
54
55
|
collection,
|
|
55
56
|
children
|
|
56
57
|
}: {
|
|
57
|
-
collection:
|
|
58
|
+
collection: AdminCollection<any> | undefined;
|
|
58
59
|
children: React.ReactNode;
|
|
59
60
|
}) {
|
|
60
61
|
return (
|
|
61
|
-
<CollectionScopeContext.Provider value={collection as
|
|
62
|
+
<CollectionScopeContext.Provider value={collection as AdminCollection | undefined}>
|
|
62
63
|
<CollectionComponentOverrideProvider overrides={collection?.components}>
|
|
63
64
|
{children}
|
|
64
65
|
</CollectionComponentOverrideProvider>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { createContext, useContext, useMemo } from "react";
|
|
2
|
-
import type { ComponentOverrideMap } from "@rebasepro/types";
|
|
2
|
+
import type { ComponentOverrideMap } from "@rebasepro/admin-types";
|
|
3
3
|
|
|
4
4
|
/** Stable empty reference to avoid re-creating context values on every render. */
|
|
5
5
|
const EMPTY_OVERRIDES: ComponentOverrideMap = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CustomizationController } from "@rebasepro/types";
|
|
1
|
+
import type { CustomizationController } from "@rebasepro/admin-types";
|
|
2
2
|
import React from "react";
|
|
3
3
|
|
|
4
4
|
export const CustomizationControllerContext = React.createContext<CustomizationController>({} as CustomizationController);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DialogControllerEntryProps, DialogsController } from "@rebasepro/types";
|
|
1
|
+
import type { DialogControllerEntryProps, DialogsController } from "@rebasepro/admin-types";
|
|
2
2
|
import React, { PropsWithChildren, useCallback, useRef, useState, useMemo } from "react";
|
|
3
3
|
;
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { UserConfigurationPersistence } from "@rebasepro/types";
|
|
2
|
+
import { UserConfigurationPersistence } from "@rebasepro/admin-types";
|
|
3
3
|
|
|
4
4
|
export const UserConfigurationPersistenceContext = React.createContext<UserConfigurationPersistence | undefined>(undefined);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { useEffect, useRef } from "react";
|
|
3
|
-
import type {
|
|
3
|
+
import type { User } from "@rebasepro/types";
|
|
4
|
+
import type { RebasePlugin, RebaseContext } from "@rebasepro/admin-types";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Render-less component that manages plugin lifecycle hooks.
|
package/src/core/Rebase.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import type { RebaseProps } from "./RebaseProps";
|
|
3
|
-
import type { CustomizationController, RebasePlugin, SlotContribution } from "@rebasepro/types";
|
|
4
|
-
import type { ComponentOverrideMap } from "@rebasepro/types";
|
|
3
|
+
import type { CustomizationController, RebasePlugin, SlotContribution } from "@rebasepro/admin-types";
|
|
4
|
+
import type { ComponentOverrideMap } from "@rebasepro/admin-types";
|
|
5
5
|
|
|
6
6
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
7
7
|
import { CenteredView, Typography } from "@rebasepro/ui";
|
|
8
|
-
import {
|
|
8
|
+
import { User, CollectionRegistryController, DataDriver, DataSourceDefinition, RebaseData, DEFAULT_DATA_SOURCE_KEY, StorageSource, StorageSourceDefinition, DEFAULT_STORAGE_SOURCE_KEY } from "@rebasepro/types";
|
|
9
|
+
import { RebaseContext } from "@rebasepro/admin-types";
|
|
9
10
|
import { PluginProviderStack } from "./PluginProviderStack";
|
|
10
11
|
import { PluginLifecycleManager } from "./PluginLifecycleManager";
|
|
11
12
|
import { AuthControllerContext, CollectionResolverRegistrationContext, CollectionResolver } from "../contexts";
|
package/src/core/RebaseProps.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
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, EntityAction, RebaseTranslations, ComponentOverrideMap } from "@rebasepro/admin-types";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* A data source registered on `<Rebase>`. Extends the shared
|
package/src/hooks/data/delete.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { Entity, CollectionCallbacks,
|
|
1
|
+
|
|
2
|
+
import { Entity, CollectionCallbacks, User } from "@rebasepro/types";
|
|
3
|
+
import { RebaseContext, AdminCollection } from "@rebasepro/admin-types";
|
|
3
4
|
import { RebaseData } from "@rebasepro/types";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -7,7 +8,7 @@ import { RebaseData } from "@rebasepro/types";
|
|
|
7
8
|
*/
|
|
8
9
|
export type DeleteEntityWithCallbacksProps<M extends Record<string, any>, USER extends User = User> = {
|
|
9
10
|
entity: Entity<M>;
|
|
10
|
-
collection?:
|
|
11
|
+
collection?: AdminCollection<M>;
|
|
11
12
|
callbacks?: CollectionCallbacks<M, USER>;
|
|
12
13
|
onDeleteSuccess?: (entity: Entity<M>) => void;
|
|
13
14
|
onDeleteFailure?: (entity: Entity<M>, e: Error) => void;
|
|
@@ -37,7 +38,7 @@ export async function deleteEntityWithCallbacks<M extends Record<string, any>, U
|
|
|
37
38
|
onDeleteFailure,
|
|
38
39
|
context
|
|
39
40
|
}: DeleteEntityWithCallbacksProps<M> & {
|
|
40
|
-
collection:
|
|
41
|
+
collection: AdminCollection<M>,
|
|
41
42
|
data: RebaseData,
|
|
42
43
|
context: RebaseContext<USER>
|
|
43
44
|
}
|
package/src/hooks/data/save.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { Entity, EntityStatus, EntityValues
|
|
1
|
+
|
|
2
|
+
import { Entity, EntityStatus, EntityValues } from "@rebasepro/types";
|
|
3
|
+
import { RebaseContext, AdminCollection } from "@rebasepro/admin-types";
|
|
3
4
|
import { RebaseData } from "@rebasepro/types";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -10,7 +11,7 @@ export type SaveEntityWithCallbacksProps<M extends Record<string, unknown>> = {
|
|
|
10
11
|
values: Partial<EntityValues<M>>;
|
|
11
12
|
entityId?: string | number;
|
|
12
13
|
previousValues?: Partial<EntityValues<M>>;
|
|
13
|
-
collection?:
|
|
14
|
+
collection?: AdminCollection<M>;
|
|
14
15
|
status: EntityStatus;
|
|
15
16
|
afterSave?: (updatedEntity: Entity<M>) => void,
|
|
16
17
|
afterSaveError?: (e: Error) => void
|
|
@@ -46,8 +47,8 @@ export async function saveEntityWithCallbacks<M extends Record<string, unknown>>
|
|
|
46
47
|
context,
|
|
47
48
|
afterSave,
|
|
48
49
|
afterSaveError
|
|
49
|
-
}: SaveEntityWithCallbacksProps<M> & {
|
|
50
|
-
collection:
|
|
50
|
+
}: Omit<SaveEntityWithCallbacksProps<M>, "collection"> & {
|
|
51
|
+
collection: AdminCollection<M>,
|
|
51
52
|
data: RebaseData,
|
|
52
53
|
context: RebaseContext,
|
|
53
54
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import { useEffect, useState, useMemo } from "react";
|
|
3
3
|
import { Entity, FilterValues, User } from "@rebasepro/types";
|
|
4
4
|
import { useData } from "./useData";
|
|
5
5
|
import { isSchemaDriftError, useSchemaDriftContext } from "../../components/SchemaDriftBanner";
|
|
6
6
|
import { getRelationIncludeParams } from "../../util/previews";
|
|
7
|
+
import type { AdminCollection } from "@rebasepro/admin-types";
|
|
7
8
|
/**
|
|
8
9
|
* @group Hooks and utilities
|
|
9
10
|
*/
|
|
@@ -17,7 +18,7 @@ export interface CollectionProps<M extends Record<string, any>> {
|
|
|
17
18
|
/**
|
|
18
19
|
* collection of the entity displayed by this collection
|
|
19
20
|
*/
|
|
20
|
-
collection:
|
|
21
|
+
collection: AdminCollection<M>
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Number of entities to fetch
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import { useEffect, useState, useMemo } from "react";
|
|
3
|
-
import { Entity,
|
|
3
|
+
import { Entity, User } from "@rebasepro/types";
|
|
4
|
+
import { RebaseContext, AdminCollection } from "@rebasepro/admin-types";
|
|
4
5
|
import { useData } from "./useData";
|
|
5
6
|
import { useRebaseContext } from "../useRebaseContext";
|
|
6
7
|
|
|
@@ -11,7 +12,7 @@ export interface FetchProps<M extends Record<string, any>, USER extends User = U
|
|
|
11
12
|
path: string;
|
|
12
13
|
entityId?: string | number;
|
|
13
14
|
databaseId?: string;
|
|
14
|
-
collection:
|
|
15
|
+
collection: AdminCollection<M, USER>;
|
|
15
16
|
useCache?: boolean;
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import { useCallback, useEffect, useRef, useState, useMemo } from "react";
|
|
3
3
|
import { useData } from "./useData";
|
|
4
4
|
import { Entity, EntityRelation, FilterValues } from "@rebasepro/types";
|
|
5
5
|
import { getRelationIncludeParams } from "../../util/previews";
|
|
6
|
+
import type { AdminCollection } from "@rebasepro/admin-types";
|
|
6
7
|
export interface RelationItem {
|
|
7
8
|
id: string | number;
|
|
8
9
|
label: string;
|
|
@@ -19,7 +20,7 @@ export interface UseRelationSelectorProps<M extends Record<string, any> = any> {
|
|
|
19
20
|
/**
|
|
20
21
|
* The collection that represents the relation entities
|
|
21
22
|
*/
|
|
22
|
-
collection:
|
|
23
|
+
collection: AdminCollection<M>;
|
|
23
24
|
/**
|
|
24
25
|
* Force filter to be applied to the relation search
|
|
25
26
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { User } from "@rebasepro/types";
|
|
2
|
+
import { AuthController } from "@rebasepro/admin-types";
|
|
2
3
|
import { useContext } from "react";
|
|
3
4
|
import { AuthControllerContext } from "../contexts/AuthControllerContext";
|
|
4
5
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useState, useEffect, useMemo, useCallback } from "react";
|
|
2
|
-
import { AuthClient,
|
|
2
|
+
import { AuthClient, User } from "@rebasepro/types";
|
|
3
|
+
import { AuthController } from "@rebasepro/admin-types";
|
|
3
4
|
|
|
4
5
|
export function useAuthSubscription(authClient?: AuthClient): AuthController {
|
|
5
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState, useMemo } from "react";
|
|
2
|
-
import { PartialCollectionConfig, UserConfigurationPersistence } from "@rebasepro/types";
|
|
2
|
+
import { PartialCollectionConfig, UserConfigurationPersistence } from "@rebasepro/admin-types";
|
|
3
3
|
import { stripCollectionPath } from "@rebasepro/common";
|
|
4
4
|
import { mergeDeep } from "@rebasepro/utils";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useContext, useMemo } from "react";
|
|
2
|
-
import type { OverridableComponentName } from "@rebasepro/types";
|
|
2
|
+
import type { OverridableComponentName } from "@rebasepro/admin-types";
|
|
3
3
|
import { ComponentOverrideContext } from "../contexts/ComponentOverrideContext";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CustomizationController } from "@rebasepro/types";
|
|
1
|
+
import type { CustomizationController } from "@rebasepro/admin-types";
|
|
2
2
|
import { useContext } from "react";
|
|
3
3
|
import { CustomizationControllerContext } from "../contexts/CustomizationControllerContext";
|
|
4
4
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import { useAuthController } from "./useAuthController";
|
|
3
3
|
import { Entity } from "@rebasepro/types";
|
|
4
4
|
import { canCreateEntity, canEditEntity, canDeleteEntity, canReadCollection } from "@rebasepro/common";
|
|
5
5
|
import { useCallback, useMemo } from "react";
|
|
6
|
+
import type { AdminCollection } from "@rebasepro/admin-types";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Hook to evaluate roles and permissions for the current user.
|
|
@@ -12,25 +13,25 @@ export function usePermissions() {
|
|
|
12
13
|
const authController = useAuthController();
|
|
13
14
|
|
|
14
15
|
const canCreate = useCallback(
|
|
15
|
-
(collection:
|
|
16
|
+
(collection: AdminCollection<any>, path: string) =>
|
|
16
17
|
canCreateEntity(collection, authController, path, null),
|
|
17
18
|
[authController]
|
|
18
19
|
);
|
|
19
20
|
|
|
20
21
|
const canEdit = useCallback(
|
|
21
|
-
(collection:
|
|
22
|
+
(collection: AdminCollection<any>, path: string, entity: Entity<any> | null) =>
|
|
22
23
|
canEditEntity(collection, authController, path, entity),
|
|
23
24
|
[authController]
|
|
24
25
|
);
|
|
25
26
|
|
|
26
27
|
const canDelete = useCallback(
|
|
27
|
-
(collection:
|
|
28
|
+
(collection: AdminCollection<any>, path: string, entity: Entity<any> | null) =>
|
|
28
29
|
canDeleteEntity(collection, authController, path, entity),
|
|
29
30
|
[authController]
|
|
30
31
|
);
|
|
31
32
|
|
|
32
33
|
const canRead = useCallback(
|
|
33
|
-
(collection:
|
|
34
|
+
(collection: AdminCollection<any>) =>
|
|
34
35
|
canReadCollection(collection, authController),
|
|
35
36
|
[authController]
|
|
36
37
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { User } from "@rebasepro/types";
|
|
2
|
+
import { AuthController, RebaseContext } from "@rebasepro/admin-types";
|
|
2
3
|
import { wrapAsSdkData } from "@rebasepro/common";
|
|
3
4
|
import { useAuthController } from "./useAuthController";
|
|
4
5
|
import { useRebaseClient } from "./useRebaseClient";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { createContext, useContext, useState, useCallback, useMemo, useRef } from "react";
|
|
2
|
-
import type { RebaseRegistryController, RebaseAdminConfig, RebaseStudioConfig, RebaseAuthConfig } from "@rebasepro/types";
|
|
2
|
+
import type { RebaseRegistryController, RebaseAdminConfig, RebaseStudioConfig, RebaseAuthConfig } from "@rebasepro/admin-types";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Split into two contexts to prevent infinite re-render loops:
|
|
@@ -103,7 +103,14 @@ export function resolveComponentRef<P = unknown>(
|
|
|
103
103
|
if (isLazyComponentRef(ref)) {
|
|
104
104
|
return getOrCreateLazy<P>(
|
|
105
105
|
ref as object,
|
|
106
|
-
()
|
|
106
|
+
// `load()` resolves to `ComponentLike<P>` — the structural stand-in
|
|
107
|
+
// that lets `ComponentRef` live in the React-free core. This function
|
|
108
|
+
// is the one place that boundary is crossed, so it is the one place
|
|
109
|
+
// the widening is asserted: `ComponentLike` accepts a return type of
|
|
110
|
+
// `unknown` where React wants `ReactNode`. What actually arrives is
|
|
111
|
+
// whatever the collection file pointed at, and rendering it is
|
|
112
|
+
// React's problem either way.
|
|
113
|
+
() => (ref as LazyComponentRef<P>).load() as Promise<{ default: React.ComponentType<P> }>
|
|
107
114
|
);
|
|
108
115
|
}
|
|
109
116
|
|
|
@@ -127,17 +134,43 @@ export function resolveComponentRef<P = unknown>(
|
|
|
127
134
|
return ref as React.ComponentType<P>;
|
|
128
135
|
}
|
|
129
136
|
|
|
130
|
-
// Zero-parameter function —
|
|
131
|
-
//
|
|
132
|
-
// if `fn.name` looks like a component (starts with uppercase) or is
|
|
133
|
-
// an anonymous arrow.
|
|
137
|
+
// Zero-parameter function — either a React component that takes no props,
|
|
138
|
+
// or a lazy loader `() => import(...)`.
|
|
134
139
|
//
|
|
135
|
-
//
|
|
136
|
-
//
|
|
137
|
-
//
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
// Nothing here can be decided with certainty from the outside, so the
|
|
141
|
+
// signals are ordered by how much they can be trusted, and the strongest
|
|
142
|
+
// one is what the function *does*, not what it is called.
|
|
143
|
+
//
|
|
144
|
+
// The name alone is not usable evidence, which is what this used to rely on.
|
|
145
|
+
// `admin: { Preview: () => import("./BodyPartsPreview") }` gives the arrow
|
|
146
|
+
// the *inferred* name "Preview" — JS names an anonymous function after the
|
|
147
|
+
// property key it is assigned to — so the "starts with an uppercase letter,
|
|
148
|
+
// therefore a component" rule matched every lazy loader written in the
|
|
149
|
+
// documented way. The thunk was then handed to React as a component, React
|
|
150
|
+
// called it, got a Promise back, and rendered nothing. That is what a blank
|
|
151
|
+
// custom preview column in the demo was.
|
|
152
|
+
const source = (() => {
|
|
153
|
+
try {
|
|
154
|
+
return Function.prototype.toString.call(fn);
|
|
155
|
+
} catch {
|
|
156
|
+
return "";
|
|
157
|
+
}
|
|
158
|
+
})();
|
|
159
|
+
|
|
160
|
+
// A dynamic module load in the body is the strongest signal, and it outranks
|
|
161
|
+
// the name: a toolchain cannot rename it away without breaking the fetch,
|
|
162
|
+
// whereas the name is often not the author's at all.
|
|
163
|
+
//
|
|
164
|
+
// Both spellings are checked because the body reaching us depends on the
|
|
165
|
+
// transform. Vite and any ESM build keep `import(...)`; ts-jest and other
|
|
166
|
+
// CommonJS transforms rewrite it to `require(...)`. Matching only the first
|
|
167
|
+
// passes in the browser and fails in the test suite, which is precisely how
|
|
168
|
+
// this went unnoticed. A zero-argument *component* containing either call is
|
|
169
|
+
// not a thing — components import at module scope.
|
|
170
|
+
const loadsAChunk = /\b(?:import|require)\s*\(/.test(source);
|
|
171
|
+
|
|
172
|
+
if (!loadsAChunk && fn.name && /^[A-Z]/.test(fn.name)) {
|
|
173
|
+
// Named like a component and does not load a chunk: a component.
|
|
141
174
|
return ref as React.ComponentType<P>;
|
|
142
175
|
}
|
|
143
176
|
|
package/src/hooks/useSlot.tsx
CHANGED