@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.
- package/LICENSE +21 -0
- package/README.md +174 -0
- package/dist/auth/api.d.ts +66 -0
- package/dist/auth/index.d.ts +13 -0
- package/dist/auth/types.d.ts +127 -0
- package/dist/auth/useRebaseAuthController.d.ts +13 -0
- package/dist/components/AIIcon.d.ts +17 -0
- package/dist/components/AuthSimulationMenu.d.ts +0 -0
- package/dist/components/ConfirmationDialog.d.ts +9 -0
- package/dist/components/Debug/UIReferenceView.d.ts +13 -0
- package/dist/components/Debug/UIStyleGuide.d.ts +2 -0
- package/dist/components/Debug/collection-views/CardViewDemo.d.ts +2 -0
- package/dist/components/Debug/collection-views/CollectionTableDemo.d.ts +2 -0
- package/dist/components/Debug/collection-views/KanbanBoardDemo.d.ts +2 -0
- package/dist/components/Debug/collection-views/index.d.ts +3 -0
- package/dist/components/Debug/collection-views/sample_data.d.ts +23 -0
- package/dist/components/Debug/crm-dashboard/CalendarWidget.d.ts +22 -0
- package/dist/components/Debug/crm-dashboard/CrmDashboardDemo.d.ts +2 -0
- package/dist/components/Debug/crm-dashboard/DashboardMetrics.d.ts +15 -0
- package/dist/components/Debug/crm-dashboard/PipelineOverview.d.ts +34 -0
- package/dist/components/Debug/crm-dashboard/RecentActivity.d.ts +19 -0
- package/dist/components/Debug/crm-dashboard/TaskFilters.d.ts +30 -0
- package/dist/components/Debug/crm-dashboard/TaskTable.d.ts +50 -0
- package/dist/components/Debug/crm-dashboard/TasksView.d.ts +41 -0
- package/dist/components/ErrorTooltip.d.ts +3 -0
- package/dist/components/ErrorView.d.ts +21 -0
- package/dist/components/LanguageToggle.d.ts +2 -0
- package/dist/components/LoginView/LoginView.d.ts +113 -0
- package/dist/components/LoginView/index.d.ts +2 -0
- package/dist/components/NotFoundPage.d.ts +2 -0
- package/dist/components/RebaseAuth.d.ts +10 -0
- package/dist/components/RebaseLogo.d.ts +7 -0
- package/dist/components/SchemaDriftBanner.d.ts +27 -0
- package/dist/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/components/UserDisplay.d.ts +7 -0
- package/dist/components/UserSelectPopover.d.ts +63 -0
- package/dist/components/UserSettingsView.d.ts +2 -0
- package/dist/components/common/index.d.ts +6 -0
- package/dist/components/common/table_height.d.ts +5 -0
- package/dist/components/common/types.d.ts +66 -0
- package/dist/components/common/useColumnsIds.d.ts +9 -0
- package/dist/components/common/useDataTableController.d.ts +45 -0
- package/dist/components/common/useDebouncedData.d.ts +9 -0
- package/dist/components/common/useScrollRestoration.d.ts +14 -0
- package/dist/components/index.d.ts +18 -0
- package/dist/contexts/AdminModeController.d.ts +4 -0
- package/dist/contexts/AnalyticsContext.d.ts +3 -0
- package/dist/contexts/AuthControllerContext.d.ts +3 -0
- package/dist/contexts/CollectionScopeContext.d.ts +50 -0
- package/dist/contexts/ComponentOverrideContext.d.ts +42 -0
- package/dist/contexts/CustomizationControllerContext.d.ts +3 -0
- package/dist/contexts/DataDriverContext.d.ts +3 -0
- package/dist/contexts/DataSourcesContext.d.ts +31 -0
- package/dist/contexts/DatabaseAdminContext.d.ts +3 -0
- package/dist/contexts/DialogsProvider.d.ts +4 -0
- package/dist/contexts/EffectiveRoleController.d.ts +4 -0
- package/dist/contexts/ModeController.d.ts +4 -0
- package/dist/contexts/RebaseClientInstanceContext.d.ts +6 -0
- package/dist/contexts/RebaseDataContext.d.ts +3 -0
- package/dist/contexts/SnackbarProvider.d.ts +2 -0
- package/dist/contexts/StorageSourceContext.d.ts +3 -0
- package/dist/contexts/StorageSourcesContext.d.ts +25 -0
- package/dist/contexts/UserConfigurationPersistenceContext.d.ts +3 -0
- package/dist/contexts/index.d.ts +17 -0
- package/dist/core/PluginLifecycleManager.d.ts +17 -0
- package/dist/core/PluginProviderStack.d.ts +21 -0
- package/dist/core/Rebase.d.ts +15 -0
- package/dist/core/RebaseProps.d.ts +291 -0
- package/dist/core/RebaseRouter.d.ts +4 -0
- package/dist/core/RebaseRoutes.d.ts +17 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/hooks/ApiConfigContext.d.ts +24 -0
- package/dist/hooks/data/delete.d.ts +33 -0
- package/dist/hooks/data/save.d.ts +40 -0
- package/dist/hooks/data/useCollection.d.ts +62 -0
- package/dist/hooks/data/useData.d.ts +13 -0
- package/dist/hooks/data/useDataOrder.d.ts +12 -0
- package/dist/hooks/data/useFetch.d.ts +43 -0
- package/dist/hooks/data/useRelationSelector.d.ts +52 -0
- package/dist/hooks/index.d.ts +36 -0
- package/dist/hooks/useAdminModeController.d.ts +19 -0
- package/dist/hooks/useAnalyticsController.d.ts +5 -0
- package/dist/hooks/useAuthController.d.ts +11 -0
- package/dist/hooks/useAuthSubscription.d.ts +2 -0
- package/dist/hooks/useBackendStorageSource.d.ts +30 -0
- package/dist/hooks/useBridgeRegistration.d.ts +18 -0
- package/dist/hooks/useBrowserTitleAndIcon.d.ts +6 -0
- package/dist/hooks/useBuildAdminModeController.d.ts +6 -0
- package/dist/hooks/useBuildEffectiveRoleController.d.ts +8 -0
- package/dist/hooks/useBuildLocalConfigurationPersistence.d.ts +2 -0
- package/dist/hooks/useBuildModeController.d.ts +6 -0
- package/dist/hooks/useClipboard.d.ts +57 -0
- package/dist/hooks/useCollapsedGroups.d.ts +27 -0
- package/dist/hooks/useComponentOverride.d.ts +32 -0
- package/dist/hooks/useCustomizationController.d.ts +11 -0
- package/dist/hooks/useDialogsController.d.ts +11 -0
- package/dist/hooks/useEffectiveRoleController.d.ts +7 -0
- package/dist/hooks/useLargeLayout.d.ts +1 -0
- package/dist/hooks/useModeController.d.ts +19 -0
- package/dist/hooks/usePermissions.d.ts +12 -0
- package/dist/hooks/useRebaseClient.d.ts +5 -0
- package/dist/hooks/useRebaseContext.d.ts +11 -0
- package/dist/hooks/useRebaseRegistry.d.ts +34 -0
- package/dist/hooks/useResolvedComponent.d.ts +47 -0
- package/dist/hooks/useSlot.d.ts +18 -0
- package/dist/hooks/useSnackbarController.d.ts +20 -0
- package/dist/hooks/useStorageSource.d.ts +6 -0
- package/dist/hooks/useStudioBridge.d.ts +79 -0
- package/dist/hooks/useTranslation.d.ts +17 -0
- package/dist/hooks/useUnsavedChangesDialog.d.ts +12 -0
- package/dist/hooks/useUserConfigurationPersistence.d.ts +8 -0
- package/dist/i18n/RebaseI18nProvider.d.ts +33 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.es.js +16843 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +17021 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/internal/common.d.ts +14 -0
- package/dist/internal/useRestoreScroll.d.ts +15 -0
- package/dist/locales/de.d.ts +2 -0
- package/dist/locales/en.d.ts +10 -0
- package/dist/locales/es.d.ts +10 -0
- package/dist/locales/fr.d.ts +2 -0
- package/dist/locales/hi.d.ts +2 -0
- package/dist/locales/it.d.ts +2 -0
- package/dist/locales/pt.d.ts +7 -0
- package/dist/util/constants.d.ts +1 -0
- package/dist/util/createFormexStub.d.ts +2 -0
- package/dist/util/entity_cache.d.ts +22 -0
- package/dist/util/enums.d.ts +5 -0
- package/dist/util/icon_list.d.ts +5 -0
- package/dist/util/icons.d.ts +20 -0
- package/dist/util/index.d.ts +8 -0
- package/dist/util/previews.d.ts +4 -0
- package/dist/util/useStorageUploadController.d.ts +44 -0
- package/dist/vitePlugin.d.ts +60 -0
- package/dist/vitePlugin.js +113 -0
- package/package.json +145 -0
- package/src/auth/api.ts +148 -0
- package/src/auth/index.ts +25 -0
- package/src/auth/types.ts +115 -0
- package/src/auth/useRebaseAuthController.ts +328 -0
- package/src/components/AIIcon.tsx +47 -0
- package/src/components/AuthSimulationMenu.tsx +0 -0
- package/src/components/ConfirmationDialog.tsx +48 -0
- package/src/components/Debug/UIReferenceView.tsx +958 -0
- package/src/components/Debug/UIStyleGuide.tsx +156 -0
- package/src/components/Debug/collection-views/CardViewDemo.tsx +85 -0
- package/src/components/Debug/collection-views/CollectionTableDemo.tsx +107 -0
- package/src/components/Debug/collection-views/KanbanBoardDemo.tsx +90 -0
- package/src/components/Debug/collection-views/index.ts +3 -0
- package/src/components/Debug/collection-views/sample_data.ts +42 -0
- package/src/components/Debug/crm-dashboard/CalendarWidget.tsx +389 -0
- package/src/components/Debug/crm-dashboard/CrmDashboardDemo.tsx +1102 -0
- package/src/components/Debug/crm-dashboard/DashboardMetrics.tsx +133 -0
- package/src/components/Debug/crm-dashboard/PipelineOverview.tsx +290 -0
- package/src/components/Debug/crm-dashboard/RecentActivity.tsx +215 -0
- package/src/components/Debug/crm-dashboard/TaskFilters.tsx +184 -0
- package/src/components/Debug/crm-dashboard/TaskTable.tsx +427 -0
- package/src/components/Debug/crm-dashboard/TasksView.tsx +234 -0
- package/src/components/ErrorTooltip.tsx +12 -0
- package/src/components/ErrorView.tsx +94 -0
- package/src/components/LanguageToggle.tsx +59 -0
- package/src/components/LoginView/LoginView.tsx +932 -0
- package/src/components/LoginView/index.ts +2 -0
- package/src/components/NotFoundPage.tsx +27 -0
- package/src/components/RebaseAuth.tsx +27 -0
- package/src/components/RebaseLogo.tsx +29 -0
- package/src/components/SchemaDriftBanner.tsx +102 -0
- package/src/components/UnsavedChangesDialog.tsx +46 -0
- package/src/components/UserDisplay.tsx +54 -0
- package/src/components/UserSelectPopover.tsx +399 -0
- package/src/components/UserSettingsView.tsx +318 -0
- package/src/components/common/index.ts +6 -0
- package/src/components/common/table_height.tsx +21 -0
- package/src/components/common/types.tsx +66 -0
- package/src/components/common/useColumnsIds.tsx +222 -0
- package/src/components/common/useDataTableController.tsx +514 -0
- package/src/components/common/useDebouncedData.ts +49 -0
- package/src/components/common/useScrollRestoration.tsx +68 -0
- package/src/components/index.tsx +26 -0
- package/src/contexts/AdminModeController.tsx +11 -0
- package/src/contexts/AnalyticsContext.tsx +4 -0
- package/src/contexts/AuthControllerContext.tsx +4 -0
- package/src/contexts/CollectionScopeContext.tsx +67 -0
- package/src/contexts/ComponentOverrideContext.tsx +81 -0
- package/src/contexts/CustomizationControllerContext.tsx +4 -0
- package/src/contexts/DataDriverContext.tsx +4 -0
- package/src/contexts/DataSourcesContext.tsx +36 -0
- package/src/contexts/DatabaseAdminContext.tsx +4 -0
- package/src/contexts/DialogsProvider.tsx +56 -0
- package/src/contexts/EffectiveRoleController.tsx +12 -0
- package/src/contexts/ModeController.tsx +11 -0
- package/src/contexts/RebaseClientInstanceContext.tsx +7 -0
- package/src/contexts/RebaseDataContext.tsx +4 -0
- package/src/contexts/SnackbarProvider.tsx +15 -0
- package/src/contexts/StorageSourceContext.tsx +4 -0
- package/src/contexts/StorageSourcesContext.tsx +30 -0
- package/src/contexts/UserConfigurationPersistenceContext.tsx +4 -0
- package/src/contexts/index.ts +17 -0
- package/src/core/PluginLifecycleManager.tsx +95 -0
- package/src/core/PluginProviderStack.tsx +40 -0
- package/src/core/Rebase.tsx +439 -0
- package/src/core/RebaseProps.tsx +320 -0
- package/src/core/RebaseRouter.tsx +17 -0
- package/src/core/RebaseRoutes.tsx +24 -0
- package/src/core/index.tsx +5 -0
- package/src/hooks/ApiConfigContext.tsx +41 -0
- package/src/hooks/data/delete.ts +55 -0
- package/src/hooks/data/save.ts +77 -0
- package/src/hooks/data/useCollection.tsx +176 -0
- package/src/hooks/data/useData.tsx +18 -0
- package/src/hooks/data/useDataOrder.ts +26 -0
- package/src/hooks/data/useFetch.tsx +140 -0
- package/src/hooks/data/useRelationSelector.tsx +234 -0
- package/src/hooks/index.tsx +45 -0
- package/src/hooks/useAdminModeController.tsx +23 -0
- package/src/hooks/useAnalyticsController.tsx +8 -0
- package/src/hooks/useAuthController.tsx +14 -0
- package/src/hooks/useAuthSubscription.ts +87 -0
- package/src/hooks/useBackendStorageSource.ts +288 -0
- package/src/hooks/useBridgeRegistration.tsx +32 -0
- package/src/hooks/useBrowserTitleAndIcon.tsx +23 -0
- package/src/hooks/useBuildAdminModeController.tsx +24 -0
- package/src/hooks/useBuildEffectiveRoleController.tsx +31 -0
- package/src/hooks/useBuildLocalConfigurationPersistence.tsx +75 -0
- package/src/hooks/useBuildModeController.tsx +71 -0
- package/src/hooks/useClipboard.tsx +158 -0
- package/src/hooks/useCollapsedGroups.ts +116 -0
- package/src/hooks/useComponentOverride.tsx +59 -0
- package/src/hooks/useCustomizationController.tsx +14 -0
- package/src/hooks/useDialogsController.tsx +15 -0
- package/src/hooks/useEffectiveRoleController.tsx +10 -0
- package/src/hooks/useLargeLayout.tsx +65 -0
- package/src/hooks/useModeController.tsx +23 -0
- package/src/hooks/usePermissions.ts +44 -0
- package/src/hooks/useRebaseClient.tsx +10 -0
- package/src/hooks/useRebaseContext.tsx +83 -0
- package/src/hooks/useRebaseRegistry.tsx +91 -0
- package/src/hooks/useResolvedComponent.tsx +159 -0
- package/src/hooks/useSlot.tsx +64 -0
- package/src/hooks/useSnackbarController.tsx +52 -0
- package/src/hooks/useStorageSource.tsx +11 -0
- package/src/hooks/useStudioBridge.tsx +209 -0
- package/src/hooks/useTranslation.ts +33 -0
- package/src/hooks/useUnsavedChangesDialog.tsx +64 -0
- package/src/hooks/useUserConfigurationPersistence.tsx +11 -0
- package/src/i18n/RebaseI18nProvider.tsx +160 -0
- package/src/index.ts +25 -0
- package/src/internal/common.tsx +16 -0
- package/src/internal/useRestoreScroll.tsx +69 -0
- package/src/locales/de.ts +902 -0
- package/src/locales/en.ts +980 -0
- package/src/locales/es.ts +922 -0
- package/src/locales/fr.ts +901 -0
- package/src/locales/hi.ts +901 -0
- package/src/locales/it.ts +901 -0
- package/src/locales/pt.ts +909 -0
- package/src/util/constants.ts +7 -0
- package/src/util/createFormexStub.tsx +66 -0
- package/src/util/entity_cache.ts +239 -0
- package/src/util/enums.ts +32 -0
- package/src/util/icon_list.ts +22 -0
- package/src/util/icons.tsx +149 -0
- package/src/util/index.ts +12 -0
- package/src/util/previews.ts +105 -0
- package/src/util/useStorageUploadController.tsx +350 -0
- package/src/vitePlugin.ts +196 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout width primitives used by the framework's own side-panel and form
|
|
3
|
+
* dialog sizing logic.
|
|
4
|
+
*
|
|
5
|
+
* @internal Not part of the stable public API — exported only because
|
|
6
|
+
* `@rebasepro/admin` and `@rebasepro/studio` need them to compute the same
|
|
7
|
+
* dialog widths as the framework. Do not depend on these for app code; they
|
|
8
|
+
* may change shape or be removed without a major version bump.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CONTAINER_FULL_WIDTH = "100vw";
|
|
11
|
+
/** @internal See {@link CONTAINER_FULL_WIDTH}. */
|
|
12
|
+
export declare const ADDITIONAL_TAB_WIDTH = "55vw";
|
|
13
|
+
/** @internal See {@link CONTAINER_FULL_WIDTH}. */
|
|
14
|
+
export declare const FORM_CONTAINER_WIDTH = "768px";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Restores per-route scroll position on a scrollable container, keyed by
|
|
4
|
+
* router location. Used by the framework's own home page implementations.
|
|
5
|
+
*
|
|
6
|
+
* @internal Not part of the stable public API — exported only because
|
|
7
|
+
* `@rebasepro/admin` and `@rebasepro/studio` reuse it in their home page
|
|
8
|
+
* components. Its behavior (module-level scroll cache, router coupling) is
|
|
9
|
+
* an implementation detail and may change without a major version bump.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useRestoreScroll(): {
|
|
12
|
+
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
13
|
+
scroll: number;
|
|
14
|
+
direction: "up" | "down";
|
|
15
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RebaseTranslations } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* English baseline translations for @rebasepro/app.
|
|
4
|
+
*
|
|
5
|
+
* This is the single source of truth for all default UI strings.
|
|
6
|
+
* Override any key via the `translations` prop on Rebase entry-point components.
|
|
7
|
+
*
|
|
8
|
+
* @group Core
|
|
9
|
+
*/
|
|
10
|
+
export declare const en: RebaseTranslations;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RebaseTranslations } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Spanish baseline translations for @rebasepro/app.
|
|
4
|
+
*
|
|
5
|
+
* This is the single source of truth for all default UI strings in Spanish.
|
|
6
|
+
* Override any key via the `translations` prop on Rebase entry-point components.
|
|
7
|
+
*
|
|
8
|
+
* @group Core
|
|
9
|
+
*/
|
|
10
|
+
export declare const es: RebaseTranslations;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const STUDIO_NAVIGATION_GROUPS: string[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saves data to the in-memory cache and persists it individually in `sessionStorage`.
|
|
3
|
+
* @param path - The unique path/key for the data.
|
|
4
|
+
* @param data - The data to cache and persist.
|
|
5
|
+
*/
|
|
6
|
+
export declare function saveEntityToCache(path: string, data: object): void;
|
|
7
|
+
export declare function removeEntityFromMemoryCache(path: string): void;
|
|
8
|
+
export declare function saveEntityToMemoryCache(path: string, data: object): void;
|
|
9
|
+
export declare function getEntityFromMemoryCache(path: string): object | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves a entity from the in-memory cache or `sessionStorage`.
|
|
12
|
+
* If the entity is not in the cache but exists in `sessionStorage`, it loads it into the cache.
|
|
13
|
+
* @param path - The unique path/key for the entity.
|
|
14
|
+
* @returns The cached entity or `undefined` if not found.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getEntityFromCache(path: string): object | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Removes a entity from both the in-memory cache and `sessionStorage`.
|
|
19
|
+
* @param path - The unique path/key for the entity to remove.
|
|
20
|
+
*/
|
|
21
|
+
export declare function removeEntityFromCache(path: string): void;
|
|
22
|
+
export declare function flattenKeys(obj: Record<string, unknown> | unknown[], prefix?: string, result?: string[]): string[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EnumValueConfig } from "@rebasepro/types";
|
|
2
|
+
import { ChipColorScheme } from "@rebasepro/ui";
|
|
3
|
+
export declare function getColorScheme(enumValues: EnumValueConfig[], key: string | number): ChipColorScheme | undefined;
|
|
4
|
+
export declare function isEnumValueDisabled(labelOrConfig?: string | EnumValueConfig): boolean | undefined;
|
|
5
|
+
export declare function buildEnumLabel(labelOrConfig?: string | EnumValueConfig): string | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { IconColor } from "@rebasepro/ui";
|
|
3
|
+
/**
|
|
4
|
+
* Render an icon element from a string key or existing React element.
|
|
5
|
+
* This resolves the icon from the lucide-react icons map directly.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getIcon(iconKey?: string | React.ReactNode, className?: string, color?: IconColor, size?: "smallest" | "small" | "medium" | "large" | number): React.ReactElement | undefined;
|
|
8
|
+
export type IconViewProps = {
|
|
9
|
+
slug: string;
|
|
10
|
+
name: string;
|
|
11
|
+
singularName?: string;
|
|
12
|
+
group?: string;
|
|
13
|
+
icon?: string | React.ReactNode;
|
|
14
|
+
};
|
|
15
|
+
export declare const IconForView: React.MemoExoticComponent<({ collectionOrView, className, color, size }: {
|
|
16
|
+
collectionOrView?: IconViewProps;
|
|
17
|
+
color?: IconColor;
|
|
18
|
+
className?: string;
|
|
19
|
+
size?: "smallest" | "small" | "medium" | "large" | number;
|
|
20
|
+
}) => React.ReactElement>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CollectionConfig, PropertyConfig } from "@rebasepro/types";
|
|
2
|
+
import { AuthController } from "@rebasepro/types";
|
|
3
|
+
export declare function getEntityPreviewKeys(authController: AuthController, targetCollection: CollectionConfig<any>, fields: Record<string, PropertyConfig>, previewProperties?: string[], limit?: number): string[];
|
|
4
|
+
export declare function getEntityTitlePropertyKey<M extends Record<string, any>>(collection: CollectionConfig<M>, propertyConfigs: Record<string, PropertyConfig>): string | undefined;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ArrayProperty, StringProperty } from "@rebasepro/types";
|
|
2
|
+
import { EntityValues, StorageConfig, StorageSource, StorageSourceRegistry } from "@rebasepro/types";
|
|
3
|
+
export type StorageFieldSize = "smallest" | "small" | "medium" | "large" | number;
|
|
4
|
+
/**
|
|
5
|
+
* Internal representation of an item in the storage
|
|
6
|
+
* It can have two states, having a storagePathOrDownloadUrl set,
|
|
7
|
+
* which means the file has been uploaded, and it is rendered as a preview
|
|
8
|
+
* Or have a pending file being uploaded.
|
|
9
|
+
*/
|
|
10
|
+
export interface StorageFieldItem {
|
|
11
|
+
id: number;
|
|
12
|
+
storagePathOrDownloadUrl?: string;
|
|
13
|
+
file?: File;
|
|
14
|
+
fileName?: string;
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
size: StorageFieldSize;
|
|
17
|
+
}
|
|
18
|
+
export declare function useStorageUploadController<M extends Record<string, unknown>>({ entityId, entityValues, path, value, property, propertyKey, storageSource, storageSourceRegistry, disabled, onChange }: {
|
|
19
|
+
entityId?: string | number;
|
|
20
|
+
entityValues: EntityValues<M>;
|
|
21
|
+
value: string | string[] | null;
|
|
22
|
+
path?: string;
|
|
23
|
+
propertyKey: string;
|
|
24
|
+
property: StringProperty | ArrayProperty | StringProperty | ArrayProperty;
|
|
25
|
+
storageSource: StorageSource;
|
|
26
|
+
/** Optional explicit registry. When omitted, the hook reads from the
|
|
27
|
+
* `StorageSourcesContext` provided by `<Rebase storageSources={...}>`. */
|
|
28
|
+
storageSourceRegistry?: StorageSourceRegistry;
|
|
29
|
+
disabled: boolean;
|
|
30
|
+
onChange: (value: string | string[] | null) => void;
|
|
31
|
+
}): {
|
|
32
|
+
internalValue: StorageFieldItem[];
|
|
33
|
+
setInternalValue: import("react").Dispatch<import("react").SetStateAction<StorageFieldItem[]>>;
|
|
34
|
+
storage: StorageConfig;
|
|
35
|
+
fileNameBuilder: (file: File) => Promise<string>;
|
|
36
|
+
storagePathBuilder: (file: File) => string;
|
|
37
|
+
onFileUploadComplete: (uploadedPath: string, entry: StorageFieldItem, metadata?: Record<string, unknown>, uploadedUrl?: string) => Promise<void>;
|
|
38
|
+
onFileUploadError: (entry: StorageFieldItem) => void;
|
|
39
|
+
onFilesAdded: (acceptedFiles: File[]) => Promise<void>;
|
|
40
|
+
multipleFilesSupported: boolean;
|
|
41
|
+
/** The resolved StorageSource for this property — may differ from the
|
|
42
|
+
* default context source when `StorageConfig.storageSource` is set. */
|
|
43
|
+
resolvedStorageSource: StorageSource;
|
|
44
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import MagicString from "magic-string";
|
|
2
|
+
export interface RebaseCollectionsPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The path to the collections directory containing the schema definitions.
|
|
5
|
+
* Use a relative or absolute path from the root of your frontend workspace.
|
|
6
|
+
*/
|
|
7
|
+
collectionsDir: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Perform the AST-based transform on `code`.
|
|
11
|
+
*
|
|
12
|
+
* Parses the source with the TypeScript compiler API, walks the tree for
|
|
13
|
+
* `PropertyAssignment` nodes whose name matches one of `LAZY_COMPONENT_KEYS`
|
|
14
|
+
* and whose initializer is a string literal starting with `./` or `../`.
|
|
15
|
+
*
|
|
16
|
+
* Each match is rewritten in-place via `magic-string` so that source-maps
|
|
17
|
+
* remain correct.
|
|
18
|
+
*
|
|
19
|
+
* @returns `{ code, map }` if at least one replacement was made; `null` otherwise.
|
|
20
|
+
*/
|
|
21
|
+
export declare function transformCollectionSource(code: string, id: string): {
|
|
22
|
+
code: string;
|
|
23
|
+
map: ReturnType<MagicString["generateMap"]>;
|
|
24
|
+
} | null;
|
|
25
|
+
/**
|
|
26
|
+
* A Vite plugin that dynamically loads and automatically wires Rebase collections.
|
|
27
|
+
*
|
|
28
|
+
* It provides two capabilities:
|
|
29
|
+
* 1. A **virtual module** `"virtual:rebase-collections"` that statically exports
|
|
30
|
+
* the resolved collections array.
|
|
31
|
+
* 2. A **transform hook** that converts string-based component references
|
|
32
|
+
* (e.g. `Field: "../../components/MyField"`) into `LazyComponentRef` objects
|
|
33
|
+
* (`{ __rebaseLazy: true, load: () => import(...) }`), enabling code-splitting
|
|
34
|
+
* and preventing the backend from loading React-dependent modules.
|
|
35
|
+
*/
|
|
36
|
+
export declare function rebaseCollectionsPlugin(options: RebaseCollectionsPluginOptions): {
|
|
37
|
+
name: string;
|
|
38
|
+
configResolved(config: {
|
|
39
|
+
root: string;
|
|
40
|
+
}): void;
|
|
41
|
+
resolveId(id: string): string | null;
|
|
42
|
+
load(id: string): string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Transform collection files to convert string component references
|
|
45
|
+
* into lazy-loading `LazyComponentRef` objects.
|
|
46
|
+
*
|
|
47
|
+
* Example transform:
|
|
48
|
+
* ```
|
|
49
|
+
* // Input
|
|
50
|
+
* Field: "../../frontend/src/components/MyField"
|
|
51
|
+
*
|
|
52
|
+
* // Output
|
|
53
|
+
* Field: { __rebaseLazy: true, load: () => import("../../frontend/src/components/MyField") }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
transform(code: string, id: string): {
|
|
57
|
+
code: string;
|
|
58
|
+
map: ReturnType<MagicString["generateMap"]>;
|
|
59
|
+
} | null;
|
|
60
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import MagicString from "magic-string";
|
|
4
|
+
const LAZY_COMPONENT_KEYS = /* @__PURE__ */ new Set(["Field", "Preview", "Builder"]);
|
|
5
|
+
function walkAST(node, visitor) {
|
|
6
|
+
visitor(node);
|
|
7
|
+
node.forEachChild((child) => walkAST(child, visitor));
|
|
8
|
+
}
|
|
9
|
+
function getPropertyName(node) {
|
|
10
|
+
const { name } = node;
|
|
11
|
+
if (ts.isIdentifier(name)) return name.text;
|
|
12
|
+
if (ts.isStringLiteral(name)) return name.text;
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
function transformCollectionSource(code, id) {
|
|
16
|
+
const sourceFile = ts.createSourceFile(
|
|
17
|
+
id,
|
|
18
|
+
code,
|
|
19
|
+
ts.ScriptTarget.Latest,
|
|
20
|
+
/* setParentNodes */
|
|
21
|
+
true,
|
|
22
|
+
ts.ScriptKind.TSX
|
|
23
|
+
);
|
|
24
|
+
const ms = new MagicString(code);
|
|
25
|
+
let replaced = false;
|
|
26
|
+
walkAST(sourceFile, (node) => {
|
|
27
|
+
if (!ts.isPropertyAssignment(node)) return;
|
|
28
|
+
const propName = getPropertyName(node);
|
|
29
|
+
if (!propName || !LAZY_COMPONENT_KEYS.has(propName)) return;
|
|
30
|
+
const init = node.initializer;
|
|
31
|
+
if (!ts.isStringLiteral(init)) return;
|
|
32
|
+
const importPath = init.text;
|
|
33
|
+
if (!importPath.startsWith("./") && !importPath.startsWith("../")) return;
|
|
34
|
+
const initStart = init.getStart(sourceFile);
|
|
35
|
+
const quoteChar = code.charAt(initStart);
|
|
36
|
+
const replacement = `{ __rebaseLazy: true, load: () => import(${quoteChar}${importPath}${quoteChar}) }`;
|
|
37
|
+
ms.overwrite(initStart, init.getEnd(), replacement);
|
|
38
|
+
replaced = true;
|
|
39
|
+
});
|
|
40
|
+
if (!replaced) return null;
|
|
41
|
+
return {
|
|
42
|
+
code: ms.toString(),
|
|
43
|
+
map: ms.generateMap({ hires: true })
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function rebaseCollectionsPlugin(options) {
|
|
47
|
+
const virtualModuleId = "virtual:rebase-collections";
|
|
48
|
+
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
49
|
+
let resolvedCollectionsDir;
|
|
50
|
+
return {
|
|
51
|
+
name: "rebase-collections-plugin",
|
|
52
|
+
configResolved(config) {
|
|
53
|
+
resolvedCollectionsDir = path.isAbsolute(options.collectionsDir) ? options.collectionsDir : path.resolve(config.root, options.collectionsDir);
|
|
54
|
+
},
|
|
55
|
+
resolveId(id) {
|
|
56
|
+
if (id === virtualModuleId) {
|
|
57
|
+
return resolvedVirtualModuleId;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
},
|
|
61
|
+
load(id) {
|
|
62
|
+
if (id === resolvedVirtualModuleId) {
|
|
63
|
+
const globPath = options.collectionsDir.startsWith("/") ? `${options.collectionsDir}/*.ts` : `/${options.collectionsDir}/*.ts`;
|
|
64
|
+
return `
|
|
65
|
+
// GENERATED BY @rebasepro/app Vite Plugin
|
|
66
|
+
const collectionModules = import.meta.glob('${globPath}', { eager: true });
|
|
67
|
+
|
|
68
|
+
// index exports the directory's defaults, not a collection \u2014
|
|
69
|
+
// it has no default export, so it drops out of the list below.
|
|
70
|
+
// Mirrors loadCollectionsFromDirectory in @rebasepro/server:
|
|
71
|
+
// the admin would otherwise show a collection as having no
|
|
72
|
+
// rules while the database enforces the inherited ones.
|
|
73
|
+
const indexEntry = Object.entries(collectionModules)
|
|
74
|
+
.find(([path]) => path.endsWith("/index.ts") || path.endsWith("/index.js"));
|
|
75
|
+
const defaultSecurityRules = indexEntry?.[1]?.defaultSecurityRules;
|
|
76
|
+
|
|
77
|
+
export const collections = Object.values(collectionModules)
|
|
78
|
+
.map((module) => module.default)
|
|
79
|
+
.filter(Boolean)
|
|
80
|
+
.map((collection) =>
|
|
81
|
+
defaultSecurityRules?.length && !collection.securityRules?.length
|
|
82
|
+
? { ...collection, securityRules: defaultSecurityRules }
|
|
83
|
+
: collection
|
|
84
|
+
);
|
|
85
|
+
`;
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Transform collection files to convert string component references
|
|
91
|
+
* into lazy-loading `LazyComponentRef` objects.
|
|
92
|
+
*
|
|
93
|
+
* Example transform:
|
|
94
|
+
* ```
|
|
95
|
+
* // Input
|
|
96
|
+
* Field: "../../frontend/src/components/MyField"
|
|
97
|
+
*
|
|
98
|
+
* // Output
|
|
99
|
+
* Field: { __rebaseLazy: true, load: () => import("../../frontend/src/components/MyField") }
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
transform(code, id) {
|
|
103
|
+
if (!resolvedCollectionsDir) return null;
|
|
104
|
+
if (!id.startsWith(resolvedCollectionsDir)) return null;
|
|
105
|
+
if (!/\.tsx?$/.test(id)) return null;
|
|
106
|
+
return transformCollectionSource(code, id);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
rebaseCollectionsPlugin,
|
|
112
|
+
transformCollectionSource
|
|
113
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rebasepro/app",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1-canary.4829d6e",
|
|
5
|
+
"description": "Rebase core — framework-agnostic runtime for data-driven admin panels",
|
|
6
|
+
"funding": {
|
|
7
|
+
"url": "https://github.com/sponsors/rebaseco"
|
|
8
|
+
},
|
|
9
|
+
"author": "Rebase",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/rebasepro/rebase.git",
|
|
14
|
+
"directory": "packages/app"
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/index.umd.js",
|
|
17
|
+
"module": "./dist/index.es.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"source": "src/index.ts",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=14"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"rebase",
|
|
25
|
+
"cms",
|
|
26
|
+
"admin",
|
|
27
|
+
"admin panel",
|
|
28
|
+
"typescript",
|
|
29
|
+
"headless",
|
|
30
|
+
"headless cms",
|
|
31
|
+
"content manager"
|
|
32
|
+
],
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"development": "./dist/index.es.js",
|
|
37
|
+
"import": "./dist/index.es.js",
|
|
38
|
+
"require": "./dist/index.umd.js"
|
|
39
|
+
},
|
|
40
|
+
"./vitePlugin": {
|
|
41
|
+
"types": "./dist/vitePlugin.d.ts",
|
|
42
|
+
"development": "./dist/vitePlugin.js",
|
|
43
|
+
"import": "./dist/vitePlugin.js",
|
|
44
|
+
"require": "./dist/vitePlugin.js"
|
|
45
|
+
},
|
|
46
|
+
"./package.json": "./package.json"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"compressorjs": "^1.3.0",
|
|
50
|
+
"fast-equals": "6.0.0",
|
|
51
|
+
"fuse.js": "^7.4.2",
|
|
52
|
+
"i18next": "^26.3.1",
|
|
53
|
+
"lucide-react": "1.18.0",
|
|
54
|
+
"magic-string": "^0.30.0",
|
|
55
|
+
"notistack": "^3.0.2",
|
|
56
|
+
"react-i18next": "^17.0.8",
|
|
57
|
+
"@rebasepro/common": "0.0.1-canary.4829d6e",
|
|
58
|
+
"@rebasepro/forms": "0.0.1-canary.4829d6e",
|
|
59
|
+
"@rebasepro/types": "0.0.1-canary.4829d6e",
|
|
60
|
+
"@rebasepro/ui": "0.0.1-canary.4829d6e",
|
|
61
|
+
"@rebasepro/utils": "0.0.1-canary.4829d6e"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"react": ">=19.0.0",
|
|
65
|
+
"react-dom": ">=19.0.0",
|
|
66
|
+
"react-router": "^7.0.0",
|
|
67
|
+
"react-router-dom": "^7.0.0",
|
|
68
|
+
"typescript": ">=5.0.0"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@jest/globals": "^30.4.1",
|
|
72
|
+
"@testing-library/react": "^16.3.2",
|
|
73
|
+
"@testing-library/user-event": "^14.6.1",
|
|
74
|
+
"@types/jest": "^30.0.0",
|
|
75
|
+
"@types/node": "^25.9.3",
|
|
76
|
+
"@types/react": "^19.2.17",
|
|
77
|
+
"@types/react-dom": "^19.2.3",
|
|
78
|
+
"@types/react-measure": "^2.0.12",
|
|
79
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
80
|
+
"babel-plugin-react-compiler": "beta",
|
|
81
|
+
"cross-env": "^10.1.0",
|
|
82
|
+
"esbuild": "^0.28.1",
|
|
83
|
+
"jest": "^30.4.2",
|
|
84
|
+
"jest-environment-jsdom": "^30.4.1",
|
|
85
|
+
"react-router-dom": "^7.17.0",
|
|
86
|
+
"ts-jest": "^29.4.11",
|
|
87
|
+
"tsd": "^0.33.0",
|
|
88
|
+
"typescript": "^6.0.3",
|
|
89
|
+
"vite": "^8.0.16"
|
|
90
|
+
},
|
|
91
|
+
"files": [
|
|
92
|
+
"dist",
|
|
93
|
+
"src"
|
|
94
|
+
],
|
|
95
|
+
"gitHead": "d935eefa5aa8d1009a2398cfac2c1e4ee9aeb6b6",
|
|
96
|
+
"publishConfig": {
|
|
97
|
+
"access": "public"
|
|
98
|
+
},
|
|
99
|
+
"eslintConfig": {
|
|
100
|
+
"extends": [
|
|
101
|
+
"react-app",
|
|
102
|
+
"react-app/jest"
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
"jest": {
|
|
106
|
+
"transform": {
|
|
107
|
+
"^.+\\.tsx?$": "ts-jest"
|
|
108
|
+
},
|
|
109
|
+
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
|
|
110
|
+
"moduleFileExtensions": [
|
|
111
|
+
"ts",
|
|
112
|
+
"tsx",
|
|
113
|
+
"js",
|
|
114
|
+
"jsx",
|
|
115
|
+
"json",
|
|
116
|
+
"node"
|
|
117
|
+
],
|
|
118
|
+
"testEnvironment": "jsdom",
|
|
119
|
+
"testPathIgnorePatterns": [
|
|
120
|
+
"/node_modules/",
|
|
121
|
+
"/src/components/",
|
|
122
|
+
"objects.test.ts",
|
|
123
|
+
"navigation.test.ts",
|
|
124
|
+
"resolutions.test.ts"
|
|
125
|
+
],
|
|
126
|
+
"setupFilesAfterEnv": [
|
|
127
|
+
"<rootDir>/test/setupTests.ts"
|
|
128
|
+
],
|
|
129
|
+
"moduleNameMapper": {
|
|
130
|
+
"\\.(css|less)$": "<rootDir>/test/__mocks__/styleMock.js",
|
|
131
|
+
"^@rebasepro/ui$": "<rootDir>/../ui/src/index.ts",
|
|
132
|
+
"^@rebasepro/common$": "<rootDir>/../common/src/index.ts",
|
|
133
|
+
"^@rebasepro/types$": "<rootDir>/../types/src/index.ts",
|
|
134
|
+
"^@rebasepro/forms$": "<rootDir>/../forms/src/index.ts"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"scripts": {
|
|
138
|
+
"watch": "vite build --watch",
|
|
139
|
+
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json && pnpm exec esbuild src/vitePlugin.ts --platform=node --format=esm --outfile=dist/vitePlugin.js",
|
|
140
|
+
"test:lint": "eslint \"src/**\" --quiet",
|
|
141
|
+
"test": "jest --passWithNoTests",
|
|
142
|
+
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f",
|
|
143
|
+
"generateIcons": "ts-node --esm src/icons/generateIcons.ts"
|
|
144
|
+
}
|
|
145
|
+
}
|