@rebasepro/types 0.5.0 → 0.6.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.
@@ -0,0 +1,177 @@
1
+ import type React from "react";
2
+
3
+ // ── Scoped component name unions ──────────────────────────────────────
4
+
5
+ /**
6
+ * Components that can only be overridden at the **app level** via the
7
+ * `components` prop on `<Rebase>`.
8
+ *
9
+ * These are shell-level / global components that exist outside of any
10
+ * specific collection context.
11
+ *
12
+ * @group Component Overrides
13
+ */
14
+ export type AppComponentName =
15
+ // ── Shell / Layout ──
16
+ | "Shell.AppBar"
17
+ | "Shell.Drawer"
18
+ | "Shell.DrawerNavigationItem"
19
+ | "Shell.DrawerNavigationGroup"
20
+
21
+ // ── Home Page ──
22
+ | "HomePage"
23
+ | "HomePage.CollectionCard"
24
+
25
+ // ── Auth ──
26
+ | "Auth.LoginView";
27
+
28
+ /**
29
+ * Components that can be overridden at the **collection level**
30
+ * (on an individual collection definition) or at the **app level**
31
+ * (as a default for all collections).
32
+ *
33
+ * When set at the app level, these act as defaults. When set on a
34
+ * specific collection, they override the app-level default for that
35
+ * collection only.
36
+ *
37
+ * @group Component Overrides
38
+ */
39
+ export type CollectionComponentName =
40
+ // ── Collection View ──
41
+ | "Collection.View"
42
+ | "Collection.Table"
43
+ | "Collection.Card"
44
+ | "Collection.EmptyState"
45
+ | "Collection.Actions"
46
+
47
+ // ── Entity / Form ──
48
+ | "Entity.Form"
49
+ | "Entity.FormActions"
50
+ | "Entity.DetailView"
51
+ | "Entity.SidePanel"
52
+ | "Entity.Preview"
53
+ | "Entity.MissingReference";
54
+
55
+ /**
56
+ * All overridable component names across all scopes.
57
+ * @group Component Overrides
58
+ */
59
+ export type OverridableComponentName = AppComponentName | CollectionComponentName;
60
+
61
+ // ── Override entry ────────────────────────────────────────────────────
62
+
63
+ /**
64
+ * A single component override entry.
65
+ *
66
+ * - **Eject mode** (default): Your component fully replaces the built-in one.
67
+ * It receives the same props as the original.
68
+ *
69
+ * - **Wrap mode** (`wrap: true`): Your component wraps the original. The
70
+ * built-in component is passed as `OriginalComponent` in props, so you can
71
+ * render it inside your custom layout/logic.
72
+ *
73
+ * @example
74
+ * ```tsx
75
+ * // Eject — full replacement
76
+ * { Component: MyCustomAppBar }
77
+ *
78
+ * // Wrap — augment the original
79
+ * {
80
+ * Component: ({ OriginalComponent, ...props }) => (
81
+ * <div>
82
+ * <MyBanner />
83
+ * <OriginalComponent {...props} />
84
+ * </div>
85
+ * ),
86
+ * wrap: true
87
+ * }
88
+ * ```
89
+ *
90
+ * @group Component Overrides
91
+ */
92
+ export interface ComponentOverride<P = any> {
93
+ /**
94
+ * The replacement component. Receives the same props as the built-in
95
+ * component it replaces.
96
+ *
97
+ * When `wrap` is true, an additional `OriginalComponent` prop is injected
98
+ * containing the default component, allowing you to render it within
99
+ * your custom wrapper.
100
+ */
101
+ Component: React.ComponentType<P>;
102
+
103
+ /**
104
+ * When true, the original default component is injected as the
105
+ * `OriginalComponent` prop into your Component, enabling the
106
+ * wrapping pattern (similar to Docusaurus's `--wrap` swizzle mode).
107
+ *
108
+ * When false or omitted, your component fully replaces the default
109
+ * (similar to Docusaurus's `--eject` swizzle mode).
110
+ *
111
+ * @default false
112
+ */
113
+ wrap?: boolean;
114
+ }
115
+
116
+ // ── Override maps by scope ────────────────────────────────────────────
117
+
118
+ /**
119
+ * Collection-scoped overrides. Only collection-level components
120
+ * can be overridden here.
121
+ *
122
+ * Set on a collection's `components` field to customize
123
+ * components for that specific collection.
124
+ *
125
+ * @example
126
+ * ```tsx
127
+ * const productsCollection = {
128
+ * name: "Products",
129
+ * slug: "products",
130
+ * components: {
131
+ * "Entity.Form": { Component: ProductForm },
132
+ * "Collection.EmptyState": { Component: ProductsEmptyState },
133
+ * "Collection.Card": { Component: ProductCard },
134
+ * }
135
+ * };
136
+ * ```
137
+ *
138
+ * @group Component Overrides
139
+ */
140
+ export type CollectionComponentOverrideMap = {
141
+ [K in CollectionComponentName]?: ComponentOverride;
142
+ };
143
+
144
+ /**
145
+ * App-level overrides. Includes both app-only components (Shell, HomePage, Auth)
146
+ * and collection-level components (as defaults for all collections).
147
+ *
148
+ * Pass this to the `components` prop on `<Rebase>`.
149
+ *
150
+ * Collection-level components set here act as **defaults** — they apply to all
151
+ * collections unless a specific collection overrides them in its own
152
+ * `components`.
153
+ *
154
+ * @example
155
+ * ```tsx
156
+ * <Rebase
157
+ * client={client}
158
+ * components={{
159
+ * // App-level: only available here
160
+ * "Shell.AppBar": { Component: MyAppBar },
161
+ * "HomePage": { Component: MyDashboard },
162
+ *
163
+ * // Collection defaults: apply to ALL collections
164
+ * "Entity.FormActions": {
165
+ * Component: MyFormActions,
166
+ * wrap: true
167
+ * },
168
+ * "Collection.EmptyState": { Component: MyEmptyState },
169
+ * }}
170
+ * />
171
+ * ```
172
+ *
173
+ * @group Component Overrides
174
+ */
175
+ export type ComponentOverrideMap = {
176
+ [K in OverridableComponentName]?: ComponentOverride;
177
+ };
@@ -27,7 +27,7 @@ import type {
27
27
  DatabaseAdmin,
28
28
  InitializedDriver,
29
29
  RealtimeProvider,
30
- BootstrappedAuth,
30
+ BootstrappedAuth
31
31
  } from "./backend";
32
32
 
33
33
  /**
@@ -21,10 +21,19 @@ export interface FormContext<M extends Record<string, unknown> = Record<string,
21
21
  setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
22
22
 
23
23
  /**
24
- * Save the entity.
24
+ * Quietly persist the entity to the database without any UI feedback
25
+ * (no validation, no snackbar, no form reset).
26
+ * Use this for programmatic/background saves from custom views.
25
27
  */
26
28
  save: (values: M) => void;
27
29
 
30
+ /**
31
+ * Submit the form — validates, saves, resets the form, and shows
32
+ * a success snackbar. This is what the Save button calls.
33
+ * Use this from custom views when you want the full "user saved" experience.
34
+ */
35
+ submit: () => void;
36
+
28
37
  /**
29
38
  * Collection of the entity being modified
30
39
  */
@@ -28,3 +28,5 @@ export * from "./backend_hooks";
28
28
  export * from "./component_ref";
29
29
  export * from "./auth_adapter";
30
30
  export * from "./database_adapter";
31
+ export * from "./breadcrumbs";
32
+ export * from "./component_overrides";
@@ -6,7 +6,7 @@ import type { InferPropertyType, Property } from "./properties";
6
6
  import type { FormContext } from "./entity_views";
7
7
  import type { RebaseContext } from "../rebase_context";
8
8
  import type { NavigationGroupMapping, AppView } from "../controllers/navigation";
9
- import type { UserManagementDelegate } from "./user_management_delegate";
9
+
10
10
  import type { User } from "../users";
11
11
  import type { SlotContribution } from "./slots";
12
12
 
@@ -136,10 +136,6 @@ export interface RebasePlugin {
136
136
  */
137
137
  views?: AppView[];
138
138
 
139
- /**
140
- * User management delegate from this plugin.
141
- */
142
- userManagement?: UserManagementDelegate;
143
139
 
144
140
  /**
145
141
  * Optional lifecycle hooks. Called by the Rebase runtime
@@ -130,6 +130,9 @@ export interface RebaseTranslations {
130
130
 
131
131
  // ─── Error states ─────────────────────────────────────────────
132
132
  error: string;
133
+ error_loading_data?: string;
134
+ error_check_server_logs?: string;
135
+ error_technical_details?: string;
133
136
  error_uploading_file: string;
134
137
  error_deleting: string;
135
138
  error_before_delete: string;
@@ -15,80 +15,3 @@ export interface UserCreationResult<USER extends User = User> {
15
15
  */
16
16
  temporaryPassword?: string;
17
17
  }
18
-
19
-
20
- /**
21
- * Delegate to manage auth-specific user operations.
22
- *
23
- * This interface allows the CMS to be agnostic of the underlying
24
- * authentication provider or backend. User/role CRUD is now handled
25
- * by the collection system; this delegate only exposes auth-specific
26
- * operations (password hashing, invitations, bootstrap).
27
- *
28
- * @group Models
29
- */
30
- export interface UserManagementDelegate<USER extends User = User> {
31
-
32
- /**
33
- * Are auth-related operations currently loading?
34
- */
35
- loading: boolean;
36
-
37
- /**
38
- * In-memory list of users (used for client-side filtering fallback).
39
- */
40
- users?: USER[];
41
-
42
- /**
43
- * Error from fetching the users list, if any.
44
- */
45
- usersError?: Error;
46
-
47
- /**
48
- * Look up a single user by UID from the in-memory cache.
49
- */
50
- getUser?: (uid: string) => USER | null;
51
-
52
- /**
53
- * Server-side user search with pagination.
54
- */
55
- searchUsers?: (params: { search?: string; limit?: number; offset?: number }) => Promise<{ users: USER[]; total: number }>;
56
-
57
- /**
58
- * Create a new user with invitation/password generation support.
59
- * Returns additional info about how the credentials were delivered.
60
- */
61
- createUser?: (user: USER) => Promise<UserCreationResult<USER>>;
62
-
63
- /**
64
- * Reset the password for an existing user.
65
- * Returns a temporary password if no email service is configured,
66
- * or a flag indicating an email invitation was sent.
67
- */
68
- resetPassword?: (user: USER) => Promise<UserCreationResult<USER>>;
69
-
70
- /**
71
- * Is the currently logged in user an admin?
72
- */
73
- isAdmin?: boolean;
74
-
75
- /**
76
- * Optionally define roles for a given user. This is useful when the roles
77
- * are coming from a separate provider than the one issuing the tokens.
78
- */
79
- defineRolesFor?: (user: USER) => Promise<string[] | undefined> | string[] | undefined;
80
-
81
- /**
82
- * Whether any admin users exist. Used by the bootstrap banner to decide
83
- * whether to prompt. Populated via a lightweight check (e.g. `limit=1`
84
- * query) instead of loading all users.
85
- */
86
- hasAdminUsers?: boolean;
87
-
88
- /**
89
- * Optional function to bootstrap an admin user.
90
- * Often used when the database is empty.
91
- */
92
- bootstrapAdmin?: () => Promise<void>;
93
-
94
- }