@rebasepro/types 0.2.4 → 0.2.5

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.
@@ -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
- }