@rebasepro/types 0.2.3 → 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.
- package/dist/controllers/auth.d.ts +4 -26
- package/dist/controllers/client.d.ts +25 -43
- package/dist/controllers/collection_registry.d.ts +1 -1
- package/dist/controllers/data.d.ts +4 -0
- package/dist/controllers/data_driver.d.ts +23 -0
- package/dist/controllers/registry.d.ts +5 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +1 -1
- package/dist/types/auth_adapter.d.ts +5 -60
- package/dist/types/backend.d.ts +2 -2
- package/dist/types/backend_hooks.d.ts +2 -17
- package/dist/types/collections.d.ts +0 -4
- package/dist/types/component_ref.d.ts +1 -1
- package/dist/types/cron.d.ts +1 -1
- package/dist/types/entity_views.d.ts +1 -0
- package/dist/types/export_import.d.ts +1 -1
- package/dist/types/formex.d.ts +2 -2
- package/dist/types/properties.d.ts +9 -7
- package/dist/types/translations.d.ts +28 -12
- package/dist/types/user_management_delegate.d.ts +22 -57
- package/dist/users/index.d.ts +0 -1
- package/dist/users/user.d.ts +0 -1
- package/package.json +1 -1
- package/src/controllers/auth.tsx +4 -32
- package/src/controllers/client.ts +23 -23
- package/src/controllers/collection_registry.ts +1 -1
- package/src/controllers/data.ts +5 -0
- package/src/controllers/data_driver.ts +25 -0
- package/src/controllers/registry.ts +5 -4
- package/src/rebase_context.tsx +1 -1
- package/src/types/auth_adapter.ts +7 -67
- package/src/types/backend.ts +2 -2
- package/src/types/backend_hooks.ts +2 -18
- package/src/types/collections.ts +1 -4
- package/src/types/component_ref.ts +1 -1
- package/src/types/cron.ts +1 -1
- package/src/types/entity_views.tsx +1 -0
- package/src/types/export_import.ts +1 -1
- package/src/types/formex.ts +2 -2
- package/src/types/properties.ts +20 -31
- package/src/types/translations.ts +28 -12
- package/src/types/user_management_delegate.ts +22 -69
- package/src/users/index.ts +1 -1
- package/src/users/user.ts +0 -1
- package/dist/users/roles.d.ts +0 -22
- package/src/users/roles.ts +0 -32
|
@@ -113,7 +113,7 @@ export interface AuthAdapterCapabilities {
|
|
|
113
113
|
registrationEnabled?: boolean;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
// ─── User
|
|
116
|
+
// ─── User Management ────────────────────────────────────────────────────────
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* Options for paginated user listing.
|
|
@@ -149,7 +149,7 @@ export interface AuthUserData {
|
|
|
149
149
|
displayName?: string | null;
|
|
150
150
|
photoUrl?: string | null;
|
|
151
151
|
emailVerified?: boolean;
|
|
152
|
-
metadata?: Record<string,
|
|
152
|
+
metadata?: Record<string, unknown>;
|
|
153
153
|
createdAt?: Date;
|
|
154
154
|
updatedAt?: Date;
|
|
155
155
|
}
|
|
@@ -163,43 +163,7 @@ export interface AuthCreateUserData {
|
|
|
163
163
|
password?: string;
|
|
164
164
|
displayName?: string;
|
|
165
165
|
photoUrl?: string;
|
|
166
|
-
metadata?: Record<string,
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Role data exposed by the auth adapter.
|
|
171
|
-
* @group Auth
|
|
172
|
-
*/
|
|
173
|
-
export interface AuthRoleData {
|
|
174
|
-
id: string;
|
|
175
|
-
name: string;
|
|
176
|
-
isAdmin: boolean;
|
|
177
|
-
defaultPermissions?: {
|
|
178
|
-
read?: boolean;
|
|
179
|
-
create?: boolean;
|
|
180
|
-
edit?: boolean;
|
|
181
|
-
delete?: boolean;
|
|
182
|
-
} | null;
|
|
183
|
-
collectionPermissions?: Record<string, {
|
|
184
|
-
read?: boolean;
|
|
185
|
-
create?: boolean;
|
|
186
|
-
edit?: boolean;
|
|
187
|
-
delete?: boolean;
|
|
188
|
-
}> | null;
|
|
189
|
-
config?: Record<string, unknown> | null;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Data for creating a role.
|
|
194
|
-
* @group Auth
|
|
195
|
-
*/
|
|
196
|
-
export interface AuthCreateRoleData {
|
|
197
|
-
id: string;
|
|
198
|
-
name: string;
|
|
199
|
-
isAdmin?: boolean;
|
|
200
|
-
defaultPermissions?: AuthRoleData["defaultPermissions"];
|
|
201
|
-
collectionPermissions?: AuthRoleData["collectionPermissions"];
|
|
202
|
-
config?: AuthRoleData["config"];
|
|
166
|
+
metadata?: Record<string, unknown>;
|
|
203
167
|
}
|
|
204
168
|
|
|
205
169
|
/**
|
|
@@ -215,25 +179,10 @@ export interface UserManagementAdapter {
|
|
|
215
179
|
createUser(data: AuthCreateUserData): Promise<AuthUserData>;
|
|
216
180
|
updateUser(id: string, data: Partial<AuthCreateUserData>): Promise<AuthUserData | null>;
|
|
217
181
|
deleteUser(id: string): Promise<void>;
|
|
218
|
-
getUserRoles(userId: string): Promise<
|
|
182
|
+
getUserRoles(userId: string): Promise<string[]>;
|
|
219
183
|
setUserRoles(userId: string, roleIds: string[]): Promise<void>;
|
|
220
184
|
}
|
|
221
185
|
|
|
222
|
-
/**
|
|
223
|
-
* Role management operations for the admin panel.
|
|
224
|
-
*
|
|
225
|
-
* Optional — if not provided by the adapter, role management is disabled.
|
|
226
|
-
*
|
|
227
|
-
* @group Auth
|
|
228
|
-
*/
|
|
229
|
-
export interface RoleManagementAdapter {
|
|
230
|
-
listRoles(): Promise<AuthRoleData[]>;
|
|
231
|
-
getRoleById(id: string): Promise<AuthRoleData | null>;
|
|
232
|
-
createRole(data: AuthCreateRoleData): Promise<AuthRoleData>;
|
|
233
|
-
updateRole(id: string, data: Partial<AuthRoleData>): Promise<AuthRoleData | null>;
|
|
234
|
-
deleteRole(id: string): Promise<void>;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
186
|
// ─── Auth Adapter ────────────────────────────────────────────────────────────
|
|
238
187
|
|
|
239
188
|
/**
|
|
@@ -243,7 +192,7 @@ export interface RoleManagementAdapter {
|
|
|
243
192
|
* database layer. Each auth adapter knows how to:
|
|
244
193
|
*
|
|
245
194
|
* 1. Verify incoming HTTP requests (`verifyRequest`)
|
|
246
|
-
* 2. Optionally manage users
|
|
195
|
+
* 2. Optionally manage users (for the admin panel)
|
|
247
196
|
* 3. Optionally mount auth-specific routes (login, register, etc.)
|
|
248
197
|
* 4. Advertise its capabilities so the frontend can adapt
|
|
249
198
|
*
|
|
@@ -295,7 +244,7 @@ export interface AuthAdapter {
|
|
|
295
244
|
*/
|
|
296
245
|
verifyToken?(token: string): Promise<AuthenticatedUser | null>;
|
|
297
246
|
|
|
298
|
-
// ── User
|
|
247
|
+
// ── User Management (for admin panel) ────────────────────────────
|
|
299
248
|
|
|
300
249
|
/**
|
|
301
250
|
* User CRUD for the admin panel's user management UI.
|
|
@@ -303,12 +252,6 @@ export interface AuthAdapter {
|
|
|
303
252
|
*/
|
|
304
253
|
userManagement?: UserManagementAdapter;
|
|
305
254
|
|
|
306
|
-
/**
|
|
307
|
-
* Role CRUD for the admin panel.
|
|
308
|
-
* Optional — if not provided, role management is disabled.
|
|
309
|
-
*/
|
|
310
|
-
roleManagement?: RoleManagementAdapter;
|
|
311
|
-
|
|
312
255
|
// ── Auth Routes ─────────────────────────────────────────────────────
|
|
313
256
|
|
|
314
257
|
/**
|
|
@@ -327,7 +270,7 @@ export interface AuthAdapter {
|
|
|
327
270
|
createAuthRoutes?(): Hono<any, any, any> | undefined;
|
|
328
271
|
|
|
329
272
|
/**
|
|
330
|
-
* Mount admin routes for user
|
|
273
|
+
* Mount admin routes for user management.
|
|
331
274
|
*
|
|
332
275
|
* Same typing rationale as `createAuthRoutes` — the sub-app env is
|
|
333
276
|
* unconstrained to support arbitrary adapter implementations.
|
|
@@ -399,9 +342,6 @@ export interface CustomAuthAdapterOptions {
|
|
|
399
342
|
/** Optional user management for the admin panel. */
|
|
400
343
|
userManagement?: UserManagementAdapter;
|
|
401
344
|
|
|
402
|
-
/** Optional role management for the admin panel. */
|
|
403
|
-
roleManagement?: RoleManagementAdapter;
|
|
404
|
-
|
|
405
345
|
/** Static service key for server-to-server auth. */
|
|
406
346
|
serviceKey?: string;
|
|
407
347
|
|
package/src/types/backend.ts
CHANGED
|
@@ -711,8 +711,8 @@ export interface InitializedDriver {
|
|
|
711
711
|
export interface BootstrappedAuth {
|
|
712
712
|
/** User management service. */
|
|
713
713
|
userService: unknown;
|
|
714
|
-
/** Role management service. */
|
|
715
|
-
roleService
|
|
714
|
+
/** Role management service (optional, roles are now simple strings). */
|
|
715
|
+
roleService?: unknown;
|
|
716
716
|
/** Email service (optional). */
|
|
717
717
|
emailService?: unknown;
|
|
718
718
|
/** Combined Auth Repository for unified token and user management. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AdminUser
|
|
1
|
+
import type { AdminUser } from "../controllers/client";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Context passed to every backend hook.
|
|
@@ -56,20 +56,6 @@ export interface UserHooks {
|
|
|
56
56
|
afterDelete?(userId: string, context: BackendHookContext): void | Promise<void>;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
/**
|
|
60
|
-
* Hooks for intercepting Admin Role data at the API boundary.
|
|
61
|
-
* @group Backend Hooks
|
|
62
|
-
*/
|
|
63
|
-
export interface RoleHooks {
|
|
64
|
-
/**
|
|
65
|
-
* Transform a role record after it's read from the database,
|
|
66
|
-
* before it's returned to the client.
|
|
67
|
-
*
|
|
68
|
-
* Return the modified role, or `null` to filter it out entirely.
|
|
69
|
-
*/
|
|
70
|
-
afterRead?(role: AdminRole, context: BackendHookContext): AdminRole | null | Promise<AdminRole | null>;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
59
|
/**
|
|
74
60
|
* Hooks for intercepting collection entity data at the REST API boundary.
|
|
75
61
|
*
|
|
@@ -144,7 +130,7 @@ export interface DataHooks {
|
|
|
144
130
|
* These hooks run server-side after database operations complete and before
|
|
145
131
|
* API responses are sent.
|
|
146
132
|
*
|
|
147
|
-
* - `users`
|
|
133
|
+
* - `users` — intercept admin user management endpoints
|
|
148
134
|
* - `data` — intercept ALL collection entity data flowing through the REST API
|
|
149
135
|
*
|
|
150
136
|
* `data` hooks complement per-collection `EntityCallbacks`. Entity callbacks
|
|
@@ -178,8 +164,6 @@ export interface DataHooks {
|
|
|
178
164
|
export interface BackendHooks {
|
|
179
165
|
/** Hooks for intercepting user management data */
|
|
180
166
|
users?: UserHooks;
|
|
181
|
-
/** Hooks for intercepting role management data */
|
|
182
|
-
roles?: RoleHooks;
|
|
183
167
|
/** Hooks for intercepting ALL collection entity data via the REST API */
|
|
184
168
|
data?: DataHooks;
|
|
185
169
|
}
|
package/src/types/collections.ts
CHANGED
|
@@ -716,10 +716,7 @@ export interface FilterPreset<Key extends string = string> {
|
|
|
716
716
|
sort?: [Key, "asc" | "desc"];
|
|
717
717
|
}
|
|
718
718
|
|
|
719
|
-
|
|
720
|
-
* @deprecated Use {@link FilterPreset} instead.
|
|
721
|
-
*/
|
|
722
|
-
export type QuickFilter<Key extends string = string> = FilterPreset<Key>;
|
|
719
|
+
|
|
723
720
|
|
|
724
721
|
/**
|
|
725
722
|
* Used to indicate valid filter combinations (e.g. created in Firestore)
|
|
@@ -37,7 +37,7 @@ export interface LazyComponentRef<P = unknown> {
|
|
|
37
37
|
*
|
|
38
38
|
* @group Types
|
|
39
39
|
*/
|
|
40
|
-
export type ComponentRef<P =
|
|
40
|
+
export type ComponentRef<P = any> =
|
|
41
41
|
| React.ComponentType<P>
|
|
42
42
|
| LazyComponentRef<P>
|
|
43
43
|
| (() => Promise<{ default: React.ComponentType<P> }>)
|
package/src/types/cron.ts
CHANGED
|
@@ -61,7 +61,7 @@ export interface CronJobContext {
|
|
|
61
61
|
log: (...args: unknown[]) => void;
|
|
62
62
|
|
|
63
63
|
/** The RebaseClient instance to interact with the database. */
|
|
64
|
-
client: RebaseClient
|
|
64
|
+
client: RebaseClient;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// =============================================================================
|
|
@@ -66,6 +66,7 @@ export interface FormContext<M extends Record<string, unknown> = Record<string,
|
|
|
66
66
|
export type EntityCustomView<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
67
67
|
key: string;
|
|
68
68
|
name: string;
|
|
69
|
+
icon?: string | React.ReactNode;
|
|
69
70
|
tabComponent?: React.ReactNode;
|
|
70
71
|
includeActions?: boolean | "bottom";
|
|
71
72
|
Builder?: ComponentRef<EntityCustomViewParams<M>>;
|
package/src/types/formex.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { FormEvent } from "react";
|
|
2
2
|
|
|
3
|
-
export type FormexController<T =
|
|
3
|
+
export type FormexController<T = unknown> = {
|
|
4
4
|
values: T;
|
|
5
5
|
initialValues: T;
|
|
6
6
|
setValues: (values: T) => void;
|
|
@@ -37,7 +37,7 @@ export type FormexController<T = any> = {
|
|
|
37
37
|
canRedo: boolean;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export type FormexResetProps<T =
|
|
40
|
+
export type FormexResetProps<T = unknown> = {
|
|
41
41
|
values?: T;
|
|
42
42
|
submitCount?: number;
|
|
43
43
|
errors?: Record<string, string>;
|
package/src/types/properties.ts
CHANGED
|
@@ -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,
|
|
6
|
-
import type {
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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;
|
|
152
|
+
Preview?: ComponentRef;
|
|
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.
|
|
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)
|
|
@@ -121,6 +121,12 @@ export interface RebaseTranslations {
|
|
|
121
121
|
navigation_drawer: string;
|
|
122
122
|
collapse: string;
|
|
123
123
|
expand: string;
|
|
124
|
+
/** Tooltip for the language switcher in the drawer footer */
|
|
125
|
+
change_language?: string;
|
|
126
|
+
/** Tooltip for the theme toggle in the drawer footer */
|
|
127
|
+
toggle_theme?: string;
|
|
128
|
+
/** Aria label for the user menu trigger in the drawer footer */
|
|
129
|
+
user_menu?: string;
|
|
124
130
|
|
|
125
131
|
// ─── Error states ─────────────────────────────────────────────
|
|
126
132
|
error: string;
|
|
@@ -486,18 +492,28 @@ export interface RebaseTranslations {
|
|
|
486
492
|
|
|
487
493
|
select_reference: string;
|
|
488
494
|
select_references: string;
|
|
489
|
-
account_settings
|
|
490
|
-
profile
|
|
491
|
-
sessions
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
495
|
+
account_settings?: string;
|
|
496
|
+
profile?: string;
|
|
497
|
+
sessions?: string;
|
|
498
|
+
security?: string;
|
|
499
|
+
change_password?: string;
|
|
500
|
+
current_password?: string;
|
|
501
|
+
new_password?: string;
|
|
502
|
+
confirm_password?: string;
|
|
503
|
+
password_changed?: string;
|
|
504
|
+
passwords_dont_match?: string;
|
|
505
|
+
password_too_short?: string;
|
|
506
|
+
password_change_not_available?: string;
|
|
507
|
+
changing_password?: string;
|
|
508
|
+
display_name?: string;
|
|
509
|
+
photo_url?: string;
|
|
510
|
+
save_profile?: string;
|
|
511
|
+
saving?: string;
|
|
512
|
+
no_active_sessions?: string;
|
|
513
|
+
revoking?: string;
|
|
514
|
+
revoke_all_sessions?: string;
|
|
515
|
+
unknown_device?: string;
|
|
516
|
+
current?: string;
|
|
501
517
|
role_id: string;
|
|
502
518
|
role_name: string;
|
|
503
519
|
add_reference: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
|
22
|
-
*
|
|
23
|
-
*
|
|
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
|
|
33
|
+
* Are auth-related operations currently loading?
|
|
31
34
|
*/
|
|
32
35
|
loading: boolean;
|
|
33
36
|
|
|
34
37
|
/**
|
|
35
|
-
*
|
|
38
|
+
* In-memory list of users (used for client-side filtering fallback).
|
|
36
39
|
*/
|
|
37
|
-
users
|
|
40
|
+
users?: USER[];
|
|
38
41
|
|
|
39
42
|
/**
|
|
40
|
-
*
|
|
43
|
+
* Error from fetching the users list, if any.
|
|
41
44
|
*/
|
|
42
45
|
usersError?: Error;
|
|
43
46
|
|
|
44
47
|
/**
|
|
45
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
67
|
-
* @param user
|
|
53
|
+
* Server-side user search with pagination.
|
|
68
54
|
*/
|
|
69
|
-
|
|
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,55 +67,23 @@ 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
75
|
/**
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
allowDefaultRolesCreation?: boolean;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Should collection config permissions be included?
|
|
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.
|
|
125
78
|
*/
|
|
126
|
-
|
|
127
|
-
|
|
79
|
+
defineRolesFor?: (user: USER) => Promise<string[] | undefined> | string[] | undefined;
|
|
128
80
|
|
|
129
81
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
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.
|
|
132
85
|
*/
|
|
133
|
-
|
|
86
|
+
hasAdminUsers?: boolean;
|
|
134
87
|
|
|
135
88
|
/**
|
|
136
89
|
* Optional function to bootstrap an admin user.
|
package/src/users/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./user";
|
|
2
|
-
|
|
2
|
+
|
package/src/users/user.ts
CHANGED
package/dist/users/roles.d.ts
DELETED
|
@@ -1,22 +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
|
-
/**
|
|
15
|
-
* Permissions related to editing the collections
|
|
16
|
-
*/
|
|
17
|
-
config?: {
|
|
18
|
-
createCollections?: boolean;
|
|
19
|
-
editCollections?: boolean | "own";
|
|
20
|
-
deleteCollections?: boolean | "own";
|
|
21
|
-
};
|
|
22
|
-
};
|
package/src/users/roles.ts
DELETED
|
@@ -1,32 +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
|
-
* Permissions related to editing the collections
|
|
23
|
-
*/
|
|
24
|
-
config?: {
|
|
25
|
-
|
|
26
|
-
createCollections?: boolean;
|
|
27
|
-
|
|
28
|
-
editCollections?: boolean | "own";
|
|
29
|
-
|
|
30
|
-
deleteCollections?: boolean | "own";
|
|
31
|
-
}
|
|
32
|
-
}
|