@rebasepro/app 0.17.3 → 0.18.0
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/dist/vitePlugin.d.ts
CHANGED
|
@@ -58,3 +58,25 @@ export declare function rebaseCollectionsPlugin(options: RebaseCollectionsPlugin
|
|
|
58
58
|
map: ReturnType<MagicString["generateMap"]>;
|
|
59
59
|
} | null;
|
|
60
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* How the admin's dependencies are split into cached chunks.
|
|
63
|
+
*
|
|
64
|
+
* This was sixty-five lines copied verbatim into every scaffold's
|
|
65
|
+
* `vite.config.ts`, comments and all — which meant every project got a frozen
|
|
66
|
+
* snapshot of a decision that keeps being revised. When we learned that naming
|
|
67
|
+
* `lucide-react` welded 822 kB of icons into the preload set, the fix landed
|
|
68
|
+
* in the template and in nothing already generated.
|
|
69
|
+
*
|
|
70
|
+
* A name here says these modules travel TOGETHER. It does not say they travel
|
|
71
|
+
* late: a chunk becomes a static dependency of the entry — and so a
|
|
72
|
+
* `modulepreload` in index.html — the moment any one module in it is
|
|
73
|
+
* statically reachable. Naming a library that is only partly lazy therefore
|
|
74
|
+
* drags the lazy part onto the critical path. Read the two exceptions below
|
|
75
|
+
* before adding a line.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* build: { rollupOptions: { output: { manualChunks: rebaseManualChunks } } }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare function rebaseManualChunks(id: string): string | undefined;
|
package/dist/vitePlugin.js
CHANGED
|
@@ -2,6 +2,13 @@ import path from "path";
|
|
|
2
2
|
import ts from "typescript";
|
|
3
3
|
import MagicString from "magic-string";
|
|
4
4
|
const LAZY_COMPONENT_KEYS = /* @__PURE__ */ new Set(["Field", "Preview", "Builder", "Filter"]);
|
|
5
|
+
function isInsideCallbacksBlock(node) {
|
|
6
|
+
const objectLiteral = node.parent;
|
|
7
|
+
if (!objectLiteral || !ts.isObjectLiteralExpression(objectLiteral)) return false;
|
|
8
|
+
const owner = objectLiteral.parent;
|
|
9
|
+
if (!owner || !ts.isPropertyAssignment(owner)) return false;
|
|
10
|
+
return getPropertyName(owner) === "callbacks";
|
|
11
|
+
}
|
|
5
12
|
function walkAST(node, visitor) {
|
|
6
13
|
visitor(node);
|
|
7
14
|
node.forEachChild((child) => walkAST(child, visitor));
|
|
@@ -25,7 +32,14 @@ function transformCollectionSource(code, id) {
|
|
|
25
32
|
let replaced = false;
|
|
26
33
|
walkAST(sourceFile, (node) => {
|
|
27
34
|
if (!ts.isPropertyAssignment(node)) return;
|
|
28
|
-
const
|
|
35
|
+
const name = getPropertyName(node);
|
|
36
|
+
if (name && isInsideCallbacksBlock(node)) {
|
|
37
|
+
const value = node.initializer;
|
|
38
|
+
ms.overwrite(value.getStart(sourceFile), value.getEnd(), "undefined");
|
|
39
|
+
replaced = true;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const propName = name;
|
|
29
43
|
if (!propName || !LAZY_COMPONENT_KEYS.has(propName)) return;
|
|
30
44
|
const init = node.initializer;
|
|
31
45
|
if (!ts.isStringLiteral(init)) return;
|
|
@@ -122,7 +136,32 @@ function rebaseCollectionsPlugin(options) {
|
|
|
122
136
|
}
|
|
123
137
|
};
|
|
124
138
|
}
|
|
139
|
+
function rebaseManualChunks(id) {
|
|
140
|
+
if (id.includes("commonjsHelpers") || id.includes("commonjs-dynamic-modules")) return "vendor-commonjs-helpers";
|
|
141
|
+
if (id.includes("exceljs")) return "vendor-exceljs";
|
|
142
|
+
if (id.includes("prosemirror")) return "vendor-prosemirror";
|
|
143
|
+
if (id.includes("monaco-editor") || id.includes("@monaco-editor")) return "vendor-monaco";
|
|
144
|
+
if (id.includes("@xyflow") || id.includes("dagre")) return "vendor-xyflow";
|
|
145
|
+
if (id.includes("@dnd-kit")) return "vendor-dnd";
|
|
146
|
+
if (id.includes("prism-react-renderer")) return "vendor-prism";
|
|
147
|
+
if (id.includes("markdown-it")) return "vendor-markdown";
|
|
148
|
+
if (id.includes("react-dropzone")) return "vendor-dropzone";
|
|
149
|
+
if (id.includes("date-fns/locale")) return void 0;
|
|
150
|
+
if (id.includes("date-fns")) return "vendor-datefns";
|
|
151
|
+
if (id.includes("fuse.js")) return "vendor-fuse";
|
|
152
|
+
if (id.includes("node_modules/react-dom/")) return "vendor-react-dom";
|
|
153
|
+
if (id.includes("node_modules/react-router") || id.includes("node_modules/@remix-run")) return "vendor-react-router";
|
|
154
|
+
if (id.includes("node_modules/@radix-ui/")) return "vendor-radix";
|
|
155
|
+
if (id.includes("node_modules/framer-motion/")) return "vendor-framer-motion";
|
|
156
|
+
if (id.includes("node_modules/zod/")) return "vendor-zod";
|
|
157
|
+
if (id.includes("node_modules/i18next") || id.includes("node_modules/react-i18next")) return "vendor-i18next";
|
|
158
|
+
if (id.includes("node_modules/@floating-ui/")) return "vendor-floating-ui";
|
|
159
|
+
if (id.includes("node_modules/tailwind-merge/")) return "vendor-tailwind-merge";
|
|
160
|
+
if (id.includes("node_modules/notistack/")) return "vendor-notistack";
|
|
161
|
+
return void 0;
|
|
162
|
+
}
|
|
125
163
|
export {
|
|
126
164
|
rebaseCollectionsPlugin,
|
|
165
|
+
rebaseManualChunks,
|
|
127
166
|
transformCollectionSource
|
|
128
167
|
};
|
package/package.json
CHANGED
|
@@ -1,45 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/app",
|
|
3
|
-
"
|
|
4
|
-
"version": "0.17.3",
|
|
3
|
+
"version": "0.18.0",
|
|
5
4
|
"description": "Rebase core — framework-agnostic runtime for data-driven admin panels",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"rebase",
|
|
7
|
+
"cms",
|
|
8
|
+
"admin",
|
|
9
|
+
"admin panel",
|
|
10
|
+
"typescript",
|
|
11
|
+
"headless",
|
|
12
|
+
"headless cms",
|
|
13
|
+
"content manager"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://rebase.pro",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/rebasepro/rebase/issues"
|
|
8
18
|
},
|
|
9
|
-
"author": "Rebase",
|
|
10
|
-
"license": "MIT",
|
|
11
19
|
"repository": {
|
|
12
20
|
"type": "git",
|
|
13
21
|
"url": "https://github.com/rebasepro/rebase.git",
|
|
14
22
|
"directory": "packages/app"
|
|
15
23
|
},
|
|
24
|
+
"funding": {
|
|
25
|
+
"url": "https://github.com/sponsors/rebasepro"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"author": "Rebase",
|
|
29
|
+
"type": "module",
|
|
16
30
|
"main": "./dist/index.es.js",
|
|
17
31
|
"module": "./dist/index.es.js",
|
|
18
32
|
"types": "./dist/index.d.ts",
|
|
19
|
-
"source": "src/index.ts",
|
|
20
33
|
"engines": {
|
|
21
34
|
"node": ">=22.22.0"
|
|
22
35
|
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"rebase",
|
|
25
|
-
"cms",
|
|
26
|
-
"admin",
|
|
27
|
-
"admin panel",
|
|
28
|
-
"typescript",
|
|
29
|
-
"headless",
|
|
30
|
-
"headless cms",
|
|
31
|
-
"content manager"
|
|
32
|
-
],
|
|
33
36
|
"exports": {
|
|
34
37
|
".": {
|
|
35
38
|
"types": "./dist/index.d.ts",
|
|
36
39
|
"development": "./dist/index.es.js",
|
|
37
|
-
"import": "./dist/index.es.js"
|
|
40
|
+
"import": "./dist/index.es.js",
|
|
41
|
+
"default": "./dist/index.es.js"
|
|
42
|
+
},
|
|
43
|
+
"./debug": {
|
|
44
|
+
"types": "./dist/debug/index.d.ts",
|
|
45
|
+
"development": "./dist/debug.js",
|
|
46
|
+
"import": "./dist/debug.js",
|
|
47
|
+
"default": "./dist/debug.js"
|
|
38
48
|
},
|
|
39
49
|
"./vitePlugin": {
|
|
40
50
|
"types": "./dist/vitePlugin.d.ts",
|
|
41
51
|
"development": "./dist/vitePlugin.js",
|
|
42
|
-
"import": "./dist/vitePlugin.js"
|
|
52
|
+
"import": "./dist/vitePlugin.js",
|
|
53
|
+
"default": "./dist/vitePlugin.js"
|
|
43
54
|
},
|
|
44
55
|
"./package.json": "./package.json"
|
|
45
56
|
},
|
|
@@ -52,18 +63,18 @@
|
|
|
52
63
|
"magic-string": "^0.30.0",
|
|
53
64
|
"notistack": "^3.0.2",
|
|
54
65
|
"react-i18next": "^17.0.11",
|
|
55
|
-
"@rebasepro/cms-types": "0.
|
|
56
|
-
"@rebasepro/
|
|
57
|
-
"@rebasepro/
|
|
58
|
-
"@rebasepro/types": "0.
|
|
59
|
-
"@rebasepro/ui": "0.
|
|
60
|
-
"@rebasepro/utils": "0.
|
|
66
|
+
"@rebasepro/cms-types": "0.18.0",
|
|
67
|
+
"@rebasepro/forms": "0.18.0",
|
|
68
|
+
"@rebasepro/common": "0.18.0",
|
|
69
|
+
"@rebasepro/types": "0.18.0",
|
|
70
|
+
"@rebasepro/ui": "0.18.0",
|
|
71
|
+
"@rebasepro/utils": "0.18.0"
|
|
61
72
|
},
|
|
62
73
|
"peerDependencies": {
|
|
63
|
-
"react": "
|
|
64
|
-
"react-dom": "
|
|
74
|
+
"react": "^19.2.7",
|
|
75
|
+
"react-dom": "^19.2.7",
|
|
65
76
|
"react-router": "^8.3.0",
|
|
66
|
-
"typescript": "
|
|
77
|
+
"typescript": "^6.0.0"
|
|
67
78
|
},
|
|
68
79
|
"devDependencies": {
|
|
69
80
|
"@jest/globals": "^30.4.1",
|
|
@@ -88,8 +99,7 @@
|
|
|
88
99
|
"vite": "^8.1.5"
|
|
89
100
|
},
|
|
90
101
|
"files": [
|
|
91
|
-
"dist"
|
|
92
|
-
"src"
|
|
102
|
+
"dist"
|
|
93
103
|
],
|
|
94
104
|
"gitHead": "d935eefa5aa8d1009a2398cfac2c1e4ee9aeb6b6",
|
|
95
105
|
"publishConfig": {
|
|
@@ -135,9 +145,10 @@
|
|
|
135
145
|
},
|
|
136
146
|
"scripts": {
|
|
137
147
|
"watch": "vite build --watch",
|
|
138
|
-
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json && node ../../tooling/scripts/add-dts-extensions.mjs dist && pnpm exec esbuild src/vitePlugin.ts --platform=node --format=esm --outfile=dist/vitePlugin.js && node ../../tooling/scripts/assert-build-output.mjs",
|
|
148
|
+
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json && node ../../tooling/scripts/add-dts-extensions.mjs dist && pnpm exec esbuild src/vitePlugin.ts --platform=node --format=esm --outfile=dist/vitePlugin.js && pnpm exec esbuild src/debug/index.ts --bundle --format=esm --jsx=automatic --external:react --external:react-dom --external:react/jsx-runtime --external:@rebasepro/* --outfile=dist/debug.js && node ../../tooling/scripts/assert-build-output.mjs",
|
|
139
149
|
"test:lint": "eslint \"src/**\" --quiet",
|
|
140
150
|
"test": "jest --passWithNoTests",
|
|
151
|
+
"test:watch": "jest --watch",
|
|
141
152
|
"clean": "rm -rf dist && find ./src \\( -name '*.js' -o -name '*.d.ts' \\) -type f | xargs rm -f",
|
|
142
153
|
"generateIcons": "ts-node --esm src/icons/generateIcons.ts"
|
|
143
154
|
}
|
package/src/auth/api.ts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auth-config fetch helper for the Rebase React frontend.
|
|
3
|
-
*
|
|
4
|
-
* The former per-endpoint auth client (login, register, refresh, OAuth,
|
|
5
|
-
* sessions, …) has been removed: `useRebaseAuthController` now delegates to
|
|
6
|
-
* the headless SDK's `client.auth` (from `@rebasepro/client`), which is the
|
|
7
|
-
* single source of truth for the auth session. The only piece that remains
|
|
8
|
-
* here is the unauthenticated `/api/auth/config` probe used to detect
|
|
9
|
-
* bootstrap mode and enabled providers before a session exists.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { RebaseApiError } from "@rebasepro/types";
|
|
13
|
-
import type { AuthAdapterCapabilities } from "@rebasepro/types";
|
|
14
|
-
import { DEFAULT_API_PATH } from "../hooks/ApiConfigContext";
|
|
15
|
-
|
|
16
|
-
async function handleResponse<T>(response: Response): Promise<T> {
|
|
17
|
-
let data: Record<string, unknown>;
|
|
18
|
-
try {
|
|
19
|
-
data = await response.json();
|
|
20
|
-
} catch (parseError) {
|
|
21
|
-
// Response wasn't JSON - could be network error or server issue
|
|
22
|
-
throw new RebaseApiError(
|
|
23
|
-
`Server returned non-JSON response (status: ${response.status})`,
|
|
24
|
-
{ status: response.status, code: "PARSE_ERROR" }
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (!response.ok) {
|
|
29
|
-
throw new RebaseApiError(
|
|
30
|
-
(data as Record<string, Record<string, string>>).error?.message || "Request failed",
|
|
31
|
-
{
|
|
32
|
-
status: response.status,
|
|
33
|
-
code: (data as Record<string, Record<string, string>>).error?.code || "UNKNOWN_ERROR"
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return data as T;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Wrapper for fetch that catches generic network failures (like server down)
|
|
43
|
-
* and translates them to a {@link RebaseApiError} with code `NETWORK_ERROR`.
|
|
44
|
-
*/
|
|
45
|
-
async function fetchWithHandling(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
|
|
46
|
-
try {
|
|
47
|
-
return await fetch(input, init);
|
|
48
|
-
} catch (error: unknown) {
|
|
49
|
-
if (error instanceof TypeError && error.message.includes("Failed to fetch")) {
|
|
50
|
-
throw new RebaseApiError(
|
|
51
|
-
"Failed to connect to the backend server. The backend might be down or failed to initialize (e.g., database connection timeout).",
|
|
52
|
-
{ code: "NETWORK_ERROR", cause: error }
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
throw new RebaseApiError(
|
|
56
|
-
"Network error: " + (error instanceof Error ? error.message : String(error)),
|
|
57
|
-
{ code: "NETWORK_ERROR", cause: error }
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* What `GET /api/auth/config` answers.
|
|
64
|
-
*
|
|
65
|
-
* The wire contract is declared once, in `@rebasepro/types`, and re-exported
|
|
66
|
-
* here under the name this module uses. Three near-copies of it used to exist —
|
|
67
|
-
* this one listed an `emailServiceEnabled` flag no backend sends, and marked as
|
|
68
|
-
* optional fields every backend always returns.
|
|
69
|
-
*/
|
|
70
|
-
export type AuthConfigResponse = AuthAdapterCapabilities;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Cache container for `fetchAuthConfig` — holds both the inflight promise
|
|
74
|
-
* (to deduplicate concurrent calls) and the cached result.
|
|
75
|
-
*/
|
|
76
|
-
export interface AuthConfigCache {
|
|
77
|
-
cached: AuthConfigResponse | null;
|
|
78
|
-
inflight: Promise<AuthConfigResponse> | null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Create a fresh `AuthConfigCache` instance.
|
|
83
|
-
* Callers own the cache object and pass it into `fetchAuthConfig` / `clearAuthConfigCache`.
|
|
84
|
-
*/
|
|
85
|
-
export function createAuthConfigCache(): AuthConfigCache {
|
|
86
|
-
return { cached: null, inflight: null };
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Fetch auth configuration / status from the backend
|
|
91
|
-
* This is an unauthenticated endpoint used to detect bootstrap mode.
|
|
92
|
-
*
|
|
93
|
-
* Results are cached for the session lifetime.
|
|
94
|
-
* Concurrent calls are deduplicated: only one network request is made
|
|
95
|
-
* and all callers share the same promise.
|
|
96
|
-
*/
|
|
97
|
-
export async function fetchAuthConfig(
|
|
98
|
-
apiUrl: string,
|
|
99
|
-
cache: AuthConfigCache,
|
|
100
|
-
/** The backend's `basePath`; only needed if it is not the default. */
|
|
101
|
-
apiPath: string = DEFAULT_API_PATH
|
|
102
|
-
): Promise<AuthConfigResponse> {
|
|
103
|
-
if (cache.cached) {
|
|
104
|
-
return cache.cached;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (cache.inflight) {
|
|
108
|
-
return cache.inflight;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
cache.inflight = (async () => {
|
|
112
|
-
const response = await fetchWithHandling(`${apiUrl.replace(/\/+$/, "")}${apiPath}/auth/config`, {
|
|
113
|
-
method: "GET",
|
|
114
|
-
headers: { "Content-Type": "application/json" }
|
|
115
|
-
});
|
|
116
|
-
return handleResponse<AuthConfigResponse>(response);
|
|
117
|
-
})();
|
|
118
|
-
|
|
119
|
-
try {
|
|
120
|
-
const result = await cache.inflight;
|
|
121
|
-
cache.cached = result;
|
|
122
|
-
return result;
|
|
123
|
-
} finally {
|
|
124
|
-
cache.inflight = null;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Clear the cached auth config (e.g. on logout or for testing).
|
|
130
|
-
*/
|
|
131
|
-
export function clearAuthConfigCache(cache: AuthConfigCache): void {
|
|
132
|
-
cache.cached = null;
|
|
133
|
-
cache.inflight = null;
|
|
134
|
-
}
|
package/src/auth/index.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authentication controller for Rebase frontends.
|
|
3
|
-
*
|
|
4
|
-
* Provides the `useRebaseAuthController` hook and API utilities for
|
|
5
|
-
* communicating with a Rebase backend's JWT auth endpoints.
|
|
6
|
-
*
|
|
7
|
-
* The generic LoginView and RebaseAuth components that render on top of this
|
|
8
|
-
* controller are in `../components`. Both are re-exported from the package
|
|
9
|
-
* root, which is where applications should import them from.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
// Types
|
|
13
|
-
export type {
|
|
14
|
-
RebaseAuthController,
|
|
15
|
-
RebaseAuthControllerProps,
|
|
16
|
-
User,
|
|
17
|
-
AuthTokens,
|
|
18
|
-
DeviceSession,
|
|
19
|
-
AuthResponse,
|
|
20
|
-
RefreshResponse
|
|
21
|
-
} from "./types";
|
|
22
|
-
|
|
23
|
-
export { useRebaseAuthController } from "./useRebaseAuthController";
|
|
24
|
-
// API utilities
|
|
25
|
-
export { fetchAuthConfig, clearAuthConfigCache, createAuthConfigCache } from "./api";
|
|
26
|
-
export type { AuthConfigResponse, AuthConfigCache } from "./api";
|
package/src/auth/types.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { User, AuthTokens, DeviceSession, RebaseSession, AuthChangeEvent } from "@rebasepro/types";
|
|
2
|
-
import { AuthController } from "@rebasepro/cms-types";
|
|
3
|
-
import type { AuthConfigResponse } from "./api";
|
|
4
|
-
|
|
5
|
-
// Re-export canonical types so the auth entry point stays self-contained. `User`
|
|
6
|
-
// joins them because the controller hands one back and a consumer installs
|
|
7
|
-
// `@rebasepro/app` alone — `@rebasepro/types` is this package's dependency, not
|
|
8
|
-
// theirs, so it is not a specifier they can import from.
|
|
9
|
-
export type { User, AuthTokens, DeviceSession };
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Auth controller that extends the base AuthController
|
|
13
|
-
* with additional methods for email/password and Google login
|
|
14
|
-
*/
|
|
15
|
-
export type RebaseAuthController = AuthController & {
|
|
16
|
-
/** Login with Google — accepts an ID token, access token, or authorization code payload */
|
|
17
|
-
googleLogin: (payload: { idToken: string } | { accessToken: string } | { code: string; redirectUri: string }) => Promise<void>;
|
|
18
|
-
/** Generic OAuth login — works with any provider. Posts payload to /auth/{providerId}. */
|
|
19
|
-
oauthLogin: (providerId: string, payload: Record<string, unknown>) => Promise<void>;
|
|
20
|
-
/** Login with email and password */
|
|
21
|
-
emailPasswordLogin: (email: string, password: string) => Promise<void>;
|
|
22
|
-
/** Register a new user */
|
|
23
|
-
register: (email: string, password: string, displayName?: string) => Promise<void>;
|
|
24
|
-
/** Skip login (for anonymous access if enabled) */
|
|
25
|
-
skipLogin: () => void;
|
|
26
|
-
/** Whether login was skipped */
|
|
27
|
-
loginSkipped: boolean;
|
|
28
|
-
/** Error from auth provider (login failure details) */
|
|
29
|
-
authProviderError: Error | null;
|
|
30
|
-
/** True when there are no users in the system — first-user bootstrap mode */
|
|
31
|
-
needsSetup: boolean;
|
|
32
|
-
/** Whether new user registration is enabled (always true during setup) */
|
|
33
|
-
registrationEnabled: boolean;
|
|
34
|
-
/** Request password reset email */
|
|
35
|
-
forgotPassword: (email: string) => Promise<void>;
|
|
36
|
-
/** Reset password using token from email */
|
|
37
|
-
resetPassword: (token: string, password: string) => Promise<void>;
|
|
38
|
-
/** Change password for authenticated user */
|
|
39
|
-
changePassword: (oldPassword: string, newPassword: string) => Promise<void>;
|
|
40
|
-
/** Update user profile */
|
|
41
|
-
updateProfile: (displayName?: string, photoURL?: string) => Promise<User>;
|
|
42
|
-
/** Fetch active sessions */
|
|
43
|
-
fetchSessions: () => Promise<DeviceSession[]>;
|
|
44
|
-
/** Revoke a session */
|
|
45
|
-
revokeSession: (sessionId: string) => Promise<void>;
|
|
46
|
-
/** Revoke all active sessions */
|
|
47
|
-
revokeAllSessions: () => Promise<void>;
|
|
48
|
-
/** Get internal API URL */
|
|
49
|
-
getApiUrl?: () => string | undefined;
|
|
50
|
-
/** Clear the current auth provider error */
|
|
51
|
-
clearError: () => void;
|
|
52
|
-
/** Set or clear the auth provider error */
|
|
53
|
-
setAuthProviderError: (error: Error | null) => void;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Structural type for the subset of `client.auth` (from `@rebasepro/client`)
|
|
58
|
-
* that the React hook delegates to. Avoids a hard dependency on
|
|
59
|
-
* `@rebasepro/client` while remaining fully type-safe.
|
|
60
|
-
*/
|
|
61
|
-
export interface ClientAuth {
|
|
62
|
-
getSession(): RebaseSession | null;
|
|
63
|
-
onAuthStateChange(callback: (event: AuthChangeEvent, session: RebaseSession | null) => void): () => void;
|
|
64
|
-
isInitialized(): Promise<void>;
|
|
65
|
-
getAuthConfig(): Promise<AuthConfigResponse>;
|
|
66
|
-
signInWithEmail(email: string, password: string): Promise<unknown>;
|
|
67
|
-
signOut(): Promise<void>;
|
|
68
|
-
refreshSession(): Promise<RebaseSession>;
|
|
69
|
-
signUp(email: string, password: string, displayName?: string): Promise<unknown>;
|
|
70
|
-
signInWithGoogle(payload: { idToken: string } | { accessToken: string } | { code: string; redirectUri: string }): Promise<unknown>;
|
|
71
|
-
signInWithOAuth(providerId: string, payload: Record<string, unknown>): Promise<unknown>;
|
|
72
|
-
resetPasswordForEmail(email: string): Promise<unknown>;
|
|
73
|
-
resetPassword(token: string, password: string): Promise<unknown>;
|
|
74
|
-
changePassword(oldPassword: string, newPassword: string): Promise<unknown>;
|
|
75
|
-
updateUser(updates: { displayName?: string; photoURL?: string }): Promise<User>;
|
|
76
|
-
getSessions(): Promise<DeviceSession[]>;
|
|
77
|
-
revokeSession(sessionId: string): Promise<unknown>;
|
|
78
|
-
revokeAllSessions(): Promise<unknown>;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Props for useRebaseAuthController hook
|
|
83
|
-
*/
|
|
84
|
-
export interface RebaseAuthControllerProps {
|
|
85
|
-
/** The Rebase Client instance */
|
|
86
|
-
client?: {
|
|
87
|
-
baseUrl?: string;
|
|
88
|
-
resolveToken?: () => Promise<string | null>;
|
|
89
|
-
setAuthTokenGetter?: (getter: () => Promise<string | null>) => void;
|
|
90
|
-
setOnUnauthorized?: (handler: () => Promise<boolean>) => void;
|
|
91
|
-
ws?: { setAuthTokenGetter: (getter: () => Promise<string | null>) => void };
|
|
92
|
-
auth?: ClientAuth;
|
|
93
|
-
};
|
|
94
|
-
/** Google OAuth client ID (optional, enables Google login) */
|
|
95
|
-
googleClientId?: string;
|
|
96
|
-
/** Callback when user signs out */
|
|
97
|
-
onSignOut?: () => void;
|
|
98
|
-
/** Define roles for a user after login */
|
|
99
|
-
defineRolesFor?: (user: User) => Promise<string[] | undefined> | string[] | undefined;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Auth response from backend login/register endpoints
|
|
104
|
-
*/
|
|
105
|
-
export interface AuthResponse {
|
|
106
|
-
user: User;
|
|
107
|
-
tokens: AuthTokens;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Response from token refresh endpoint
|
|
112
|
-
*/
|
|
113
|
-
export interface RefreshResponse {
|
|
114
|
-
tokens: AuthTokens;
|
|
115
|
-
}
|