@rebasepro/types 0.3.0 → 0.4.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.
@@ -73,43 +73,33 @@ export type EntityCustomView<M extends Record<string, unknown> = Record<string,
73
73
  position?: "start" | "end";
74
74
  };
75
75
 
76
- export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
77
- collection: EntityCollection<M>;
78
- entity?: Entity<M>;
79
- modifiedValues?: EntityValues<M>;
80
- formContext: FormContext<M>;
81
- parentCollectionSlugs?: string[];
82
- parentEntityIds?: string[];
83
- }
84
-
85
76
  /**
86
- * Configuration for customizing the read-only detail view of an entity.
87
- * Only used when `defaultEntityAction` is set to `"view"` on the collection.
77
+ * Configuration to replace the default entity form with a custom component.
78
+ * The Builder receives the same props as entity view tabs (entity, formContext, etc.)
79
+ * and has full control over the UI.
80
+ *
81
+ * The form tab still appears in the tab bar but renders your Builder
82
+ * instead of the auto-generated field form.
83
+ *
88
84
  * @group Models
89
85
  */
90
- export type EntityDetailViewConfig<M extends Record<string, unknown> = Record<string, unknown>> = {
91
- /**
92
- * Custom component rendered above the property display in the detail view.
93
- */
94
- Header?: ComponentRef<EntityDetailViewParams<M>>;
86
+ export type FormViewConfig<M extends Record<string, unknown> = Record<string, unknown>> = {
95
87
  /**
96
- * Custom component rendered below the property display in the detail view.
88
+ * Custom component that replaces the default form.
97
89
  */
98
- Footer?: ComponentRef<EntityDetailViewParams<M>>;
90
+ Builder: ComponentRef<EntityCustomViewParams<M>>;
99
91
  /**
100
- * Completely replace the default detail view with a custom component.
101
- * When set, Header and Footer are ignored.
92
+ * If true, the save/delete action bar is rendered alongside the custom view.
93
+ * Defaults to true.
102
94
  */
103
- Builder?: ComponentRef<EntityDetailViewParams<M>>;
95
+ includeActions?: boolean;
104
96
  };
105
97
 
106
- /**
107
- * Props passed to detail view customization components (Header, Footer, Builder).
108
- * @group Models
109
- */
110
- export interface EntityDetailViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
98
+ export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
111
99
  collection: EntityCollection<M>;
112
- entity: Entity<M>;
113
- path: string;
114
- onEditClick: () => void;
100
+ entity?: Entity<M>;
101
+ modifiedValues?: EntityValues<M>;
102
+ formContext: FormContext<M>;
103
+ parentCollectionSlugs?: string[];
104
+ parentEntityIds?: string[];
115
105
  }
@@ -1,15 +1,12 @@
1
- import React from "react";
2
-
3
1
  import type { ComponentRef } from "./component_ref";
4
2
 
5
- import type { EntityReference, EntityRelation, EntityValues, GeoPoint, Entity, Vector } from "./entities";
6
- import type { Relation, JoinStep, OnAction } from "./relations";
3
+ import type { Entity, EntityReference, EntityRelation, EntityValues, GeoPoint, Vector } from "./entities";
4
+ import type { JoinStep, OnAction, Relation } from "./relations";
7
5
  import type { EntityCollection, FilterValues } from "./collections";
8
6
  import type { ColorKey, ColorScheme } from "./chips";
9
7
  import type { AuthController } from "../controllers/auth";
10
8
  import type { EntityAfterReadProps, EntityBeforeSaveProps } from "./entity_callbacks";
11
9
  import type { User } from "../users";
12
- import type { RebaseContext } from "../rebase_context";
13
10
 
14
11
  /**
15
12
  * Callbacks/Hooks for individual property fields
@@ -24,7 +21,6 @@ export type PropertyCallbacks<T = unknown, M extends Record<string, unknown> = R
24
21
  entity: Entity<M> | undefined;
25
22
  }): Promise<T> | T;
26
23
 
27
-
28
24
  /**
29
25
  * Callback used before saving, after validation.
30
26
  * You can modify the value before it's saved.
@@ -85,17 +81,17 @@ export type FirebaseProperties = {
85
81
  */
86
82
  export type InferPropertyType<P extends Property> =
87
83
  P extends StringProperty ? string :
88
- P extends NumberProperty ? number :
89
- P extends BooleanProperty ? boolean :
90
- P extends DateProperty ? Date :
91
- P extends GeopointProperty ? GeoPoint :
92
- P extends ReferenceProperty ? EntityReference :
93
- P extends RelationProperty ? EntityRelation | EntityRelation[] :
94
- P extends ArrayProperty ? (P["of"] extends Property ? InferPropertyType<P["of"]>[] : unknown[]) :
95
- P extends MapProperty ? (P["properties"] extends Properties ? InferEntityType<P["properties"]> : Record<string, unknown>) :
96
- P extends VectorProperty ? Vector :
97
- P extends BinaryProperty ? string :
98
- never;
84
+ P extends NumberProperty ? number :
85
+ P extends BooleanProperty ? boolean :
86
+ P extends DateProperty ? Date :
87
+ P extends GeopointProperty ? GeoPoint :
88
+ P extends ReferenceProperty ? EntityReference :
89
+ P extends RelationProperty ? EntityRelation | EntityRelation[] :
90
+ P extends ArrayProperty ? (P["of"] extends Property ? InferPropertyType<P["of"]>[] : unknown[]) :
91
+ P extends MapProperty ? (P["properties"] extends Properties ? InferEntityType<P["properties"]> : Record<string, unknown>) :
92
+ P extends VectorProperty ? Vector :
93
+ P extends BinaryProperty ? string :
94
+ never;
99
95
 
100
96
  /**
101
97
  * Helper type that determines whether a property is required.
@@ -152,8 +148,8 @@ export interface BaseUIConfig<CustomProps = unknown> {
152
148
  disabled?: boolean | PropertyDisabledConfig;
153
149
  widthPercentage?: number;
154
150
  customProps?: CustomProps;
155
- Field?: ComponentRef;
156
- Preview?: ComponentRef;
151
+ Field?: ComponentRef<any>;
152
+ Preview?: ComponentRef<any>;
157
153
  }
158
154
 
159
155
  export interface BaseProperty<CustomProps = unknown> {
@@ -189,10 +185,6 @@ export interface BaseProperty<CustomProps = unknown> {
189
185
  */
190
186
  columnName?: string;
191
187
 
192
-
193
-
194
-
195
-
196
188
  /**
197
189
  * Rules for validating this property
198
190
  */
@@ -203,9 +195,6 @@ export interface BaseProperty<CustomProps = unknown> {
203
195
  */
204
196
  defaultValue?: unknown;
205
197
 
206
-
207
-
208
-
209
198
  /**
210
199
  * Use this to define dynamic properties that change based on certain conditions
211
200
  * or on the entity's values. For example, you can make a field read-only if
@@ -232,7 +221,6 @@ export interface BaseProperty<CustomProps = unknown> {
232
221
  */
233
222
  callbacks?: PropertyCallbacks;
234
223
 
235
-
236
224
  }
237
225
 
238
226
  /**
@@ -253,7 +241,7 @@ export interface StringProperty extends BaseProperty {
253
241
  * Optional database column type. If not set, it defaults to `varchar` or `uuid` depending on `isId` configuration.
254
242
  * Use `text` for strings with unbound length, `char` for fixed-length strings, or `varchar` for variable-length strings with a limit.
255
243
  */
256
- columnType?: "varchar" | "text" | "char";
244
+ columnType?: "varchar" | "text" | "char" | "uuid";
257
245
  /**
258
246
  * Rules for validating this property
259
247
  */
@@ -325,7 +313,6 @@ export interface StringProperty extends BaseProperty {
325
313
  */
326
314
  previewAsTag?: boolean;
327
315
 
328
-
329
316
  /**
330
317
  * You can use this property (a string) to behave as a reference to another
331
318
  * collection. The stored value is the ID of the entity in the
@@ -655,9 +642,11 @@ export interface ArrayProperty extends BaseProperty {
655
642
  ui?: ArrayUIConfig;
656
643
  type: "array";
657
644
  /**
658
- * Optional database column type. Defaults to `jsonb`.
645
+ * Optional database column type. By default, maps to a native Postgres array
646
+ * (e.g. `text[]`, `integer[]`/`numeric[]`, `boolean[]`) if the element type
647
+ * is a primitive, otherwise defaults to `jsonb`.
659
648
  */
660
- columnType?: "json" | "jsonb";
649
+ columnType?: "json" | "jsonb" | "text[]" | "integer[]" | "boolean[]" | "numeric[]";
661
650
  /**
662
651
  * The property of this array.
663
652
  * You can specify any property (except another Array property)
@@ -1,4 +1,4 @@
1
- import { Role, User } from "../users";
1
+ import type { User } from "../users";
2
2
 
3
3
  /**
4
4
  * Result of creating a new user via admin flow.
@@ -18,60 +18,45 @@ export interface UserCreationResult<USER extends User = User> {
18
18
 
19
19
 
20
20
  /**
21
- * Delegate to manage users, roles, and their permissions.
22
- * This interface allows the CMS to be completely agnostic of the underlying
23
- * authentication provider or backend.
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).
24
27
  *
25
28
  * @group Models
26
29
  */
27
30
  export interface UserManagementDelegate<USER extends User = User> {
28
31
 
29
32
  /**
30
- * Are the users and roles currently being fetched?
33
+ * Are auth-related operations currently loading?
31
34
  */
32
35
  loading: boolean;
33
36
 
34
37
  /**
35
- * List of users managed by the CMS.
38
+ * In-memory list of users (used for client-side filtering fallback).
36
39
  */
37
- users: USER[];
40
+ users?: USER[];
38
41
 
39
42
  /**
40
- * Optional error if users failed to load.
43
+ * Error from fetching the users list, if any.
41
44
  */
42
45
  usersError?: Error;
43
46
 
44
47
  /**
45
- * Function to get a user by its uid. This is used to show
46
- * user information when assigning ownership of an entity.
47
- * @param uid
48
- */
49
- getUser: (uid: string) => USER | null;
50
-
51
- /**
52
- * Search users with server-side pagination.
53
- * When provided, the CMS will use this for the users table
54
- * instead of loading all users into memory.
48
+ * Look up a single user by UID from the in-memory cache.
55
49
  */
56
- searchUsers?: (options: {
57
- search?: string;
58
- limit?: number;
59
- offset?: number;
60
- orderBy?: string;
61
- orderDir?: "asc" | "desc";
62
- roleId?: string;
63
- }) => Promise<{ users: USER[]; total: number }>;
50
+ getUser?: (uid: string) => USER | null;
64
51
 
65
52
  /**
66
- * Save a user (create or update)
67
- * @param user
53
+ * Server-side user search with pagination.
68
54
  */
69
- saveUser?: (user: USER) => Promise<USER>;
55
+ searchUsers?: (params: { search?: string; limit?: number; offset?: number }) => Promise<{ users: USER[]; total: number }>;
70
56
 
71
57
  /**
72
58
  * Create a new user with invitation/password generation support.
73
59
  * Returns additional info about how the credentials were delivered.
74
- * Falls back to saveUser if not provided.
75
60
  */
76
61
  createUser?: (user: USER) => Promise<UserCreationResult<USER>>;
77
62
 
@@ -82,52 +67,16 @@ export interface UserManagementDelegate<USER extends User = User> {
82
67
  */
83
68
  resetPassword?: (user: USER) => Promise<UserCreationResult<USER>>;
84
69
 
85
- /**
86
- * Delete a user
87
- * @param user
88
- */
89
- deleteUser?: (user: USER) => Promise<void>;
90
-
91
- /**
92
- * List of roles defined in the CMS.
93
- */
94
- roles?: Role[];
95
-
96
- /**
97
- * Optional error if roles failed to load.
98
- */
99
- rolesError?: Error;
100
-
101
- /**
102
- * Save a role (create or update)
103
- * @param role
104
- */
105
- saveRole?: (role: Role) => Promise<void>;
106
-
107
- /**
108
- * Delete a role
109
- * @param role
110
- */
111
- deleteRole?: (role: Role) => Promise<void>;
112
-
113
70
  /**
114
71
  * Is the currently logged in user an admin?
115
72
  */
116
73
  isAdmin?: boolean;
117
74
 
118
- /**
119
- * If true, the UI will allow the user to create the default roles (admin, editor, viewer).
120
- */
121
- allowDefaultRolesCreation?: boolean;
122
-
123
-
124
-
125
-
126
75
  /**
127
76
  * Optionally define roles for a given user. This is useful when the roles
128
77
  * are coming from a separate provider than the one issuing the tokens.
129
78
  */
130
- defineRolesFor?: (user: USER) => Promise<Role[] | undefined> | Role[] | undefined;
79
+ defineRolesFor?: (user: USER) => Promise<string[] | undefined> | string[] | undefined;
131
80
 
132
81
  /**
133
82
  * Whether any admin users exist. Used by the bootstrap banner to decide
@@ -1,2 +1,2 @@
1
1
  export * from "./user";
2
- export * from "./roles";
2
+
package/src/users/user.ts CHANGED
@@ -37,7 +37,6 @@ export type User = {
37
37
 
38
38
  /**
39
39
  * Role IDs assigned to this user (e.g. ["admin", "editor"]).
40
- * These are plain string IDs — use the UserManagementDelegate to look up full Role objects.
41
40
  */
42
41
  roles?: string[];
43
42
 
@@ -1,14 +0,0 @@
1
- export type Role = {
2
- /**
3
- * ID of the role
4
- */
5
- id: string;
6
- /**
7
- * Name of the role
8
- */
9
- name: string;
10
- /**
11
- * If this flag is true, the user can perform any action
12
- */
13
- isAdmin?: boolean;
14
- };
@@ -1,22 +0,0 @@
1
-
2
-
3
- export type Role = {
4
-
5
- /**
6
- * ID of the role
7
- */
8
- id: string;
9
-
10
- /**
11
- * Name of the role
12
- */
13
- name: string;
14
-
15
- /**
16
- * If this flag is true, the user can perform any action
17
- */
18
- isAdmin?: boolean;
19
-
20
-
21
-
22
- }