@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.
- package/dist/controllers/auth.d.ts +2 -2
- package/dist/controllers/client.d.ts +25 -40
- package/dist/controllers/data.d.ts +21 -3
- package/dist/controllers/data_driver.d.ts +5 -0
- package/dist/controllers/email.d.ts +2 -0
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/auth_adapter.d.ts +3 -56
- package/dist/types/backend.d.ts +2 -2
- package/dist/types/backend_hooks.d.ts +2 -17
- package/dist/types/collections.d.ts +9 -5
- package/dist/types/entity_views.d.ts +19 -28
- package/dist/types/properties.d.ts +9 -7
- package/dist/types/user_management_delegate.d.ts +16 -53
- 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 +2 -2
- package/src/controllers/client.ts +23 -22
- package/src/controllers/data.ts +26 -3
- package/src/controllers/data_driver.ts +6 -0
- package/src/controllers/email.ts +2 -0
- package/src/types/auth_adapter.ts +5 -63
- package/src/types/backend.ts +2 -2
- package/src/types/backend_hooks.ts +2 -18
- package/src/types/collections.ts +9 -5
- package/src/types/entity_views.tsx +19 -29
- package/src/types/properties.ts +20 -31
- package/src/types/user_management_delegate.ts +16 -67
- package/src/users/index.ts +1 -1
- package/src/users/user.ts +0 -1
- package/dist/users/roles.d.ts +0 -14
- package/src/users/roles.ts +0 -22
|
@@ -56,41 +56,32 @@ export type EntityCustomView<M extends Record<string, unknown> = Record<string,
|
|
|
56
56
|
Builder?: ComponentRef<EntityCustomViewParams<M>>;
|
|
57
57
|
position?: "start" | "end";
|
|
58
58
|
};
|
|
59
|
-
export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
60
|
-
collection: EntityCollection<M>;
|
|
61
|
-
entity?: Entity<M>;
|
|
62
|
-
modifiedValues?: EntityValues<M>;
|
|
63
|
-
formContext: FormContext<M>;
|
|
64
|
-
parentCollectionSlugs?: string[];
|
|
65
|
-
parentEntityIds?: string[];
|
|
66
|
-
}
|
|
67
59
|
/**
|
|
68
|
-
* Configuration
|
|
69
|
-
*
|
|
60
|
+
* Configuration to replace the default entity form with a custom component.
|
|
61
|
+
* The Builder receives the same props as entity view tabs (entity, formContext, etc.)
|
|
62
|
+
* and has full control over the UI.
|
|
63
|
+
*
|
|
64
|
+
* The form tab still appears in the tab bar but renders your Builder
|
|
65
|
+
* instead of the auto-generated field form.
|
|
66
|
+
*
|
|
70
67
|
* @group Models
|
|
71
68
|
*/
|
|
72
|
-
export type
|
|
73
|
-
/**
|
|
74
|
-
* Custom component rendered above the property display in the detail view.
|
|
75
|
-
*/
|
|
76
|
-
Header?: ComponentRef<EntityDetailViewParams<M>>;
|
|
69
|
+
export type FormViewConfig<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
77
70
|
/**
|
|
78
|
-
* Custom component
|
|
71
|
+
* Custom component that replaces the default form.
|
|
79
72
|
*/
|
|
80
|
-
|
|
73
|
+
Builder: ComponentRef<EntityCustomViewParams<M>>;
|
|
81
74
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
75
|
+
* If true, the save/delete action bar is rendered alongside the custom view.
|
|
76
|
+
* Defaults to true.
|
|
84
77
|
*/
|
|
85
|
-
|
|
78
|
+
includeActions?: boolean;
|
|
86
79
|
};
|
|
87
|
-
|
|
88
|
-
* Props passed to detail view customization components (Header, Footer, Builder).
|
|
89
|
-
* @group Models
|
|
90
|
-
*/
|
|
91
|
-
export interface EntityDetailViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
80
|
+
export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
92
81
|
collection: EntityCollection<M>;
|
|
93
|
-
entity
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
entity?: Entity<M>;
|
|
83
|
+
modifiedValues?: EntityValues<M>;
|
|
84
|
+
formContext: FormContext<M>;
|
|
85
|
+
parentCollectionSlugs?: string[];
|
|
86
|
+
parentEntityIds?: string[];
|
|
96
87
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ComponentRef } from "./component_ref";
|
|
2
|
-
import type { EntityReference, EntityRelation, EntityValues, GeoPoint,
|
|
3
|
-
import type {
|
|
2
|
+
import type { Entity, EntityReference, EntityRelation, EntityValues, GeoPoint, Vector } from "./entities";
|
|
3
|
+
import type { JoinStep, OnAction, Relation } from "./relations";
|
|
4
4
|
import type { EntityCollection, FilterValues } from "./collections";
|
|
5
5
|
import type { ColorKey, ColorScheme } from "./chips";
|
|
6
6
|
import type { AuthController } from "../controllers/auth";
|
|
@@ -104,8 +104,8 @@ export interface BaseUIConfig<CustomProps = unknown> {
|
|
|
104
104
|
disabled?: boolean | PropertyDisabledConfig;
|
|
105
105
|
widthPercentage?: number;
|
|
106
106
|
customProps?: CustomProps;
|
|
107
|
-
Field?: ComponentRef
|
|
108
|
-
Preview?: ComponentRef
|
|
107
|
+
Field?: ComponentRef<any>;
|
|
108
|
+
Preview?: ComponentRef<any>;
|
|
109
109
|
}
|
|
110
110
|
export interface BaseProperty<CustomProps = unknown> {
|
|
111
111
|
ui?: BaseUIConfig<CustomProps>;
|
|
@@ -185,7 +185,7 @@ export interface StringProperty extends BaseProperty {
|
|
|
185
185
|
* Optional database column type. If not set, it defaults to `varchar` or `uuid` depending on `isId` configuration.
|
|
186
186
|
* Use `text` for strings with unbound length, `char` for fixed-length strings, or `varchar` for variable-length strings with a limit.
|
|
187
187
|
*/
|
|
188
|
-
columnType?: "varchar" | "text" | "char";
|
|
188
|
+
columnType?: "varchar" | "text" | "char" | "uuid";
|
|
189
189
|
/**
|
|
190
190
|
* Rules for validating this property
|
|
191
191
|
*/
|
|
@@ -541,9 +541,11 @@ export interface ArrayProperty extends BaseProperty {
|
|
|
541
541
|
ui?: ArrayUIConfig;
|
|
542
542
|
type: "array";
|
|
543
543
|
/**
|
|
544
|
-
* Optional database column type.
|
|
544
|
+
* Optional database column type. By default, maps to a native Postgres array
|
|
545
|
+
* (e.g. `text[]`, `integer[]`/`numeric[]`, `boolean[]`) if the element type
|
|
546
|
+
* is a primitive, otherwise defaults to `jsonb`.
|
|
545
547
|
*/
|
|
546
|
-
columnType?: "json" | "jsonb";
|
|
548
|
+
columnType?: "json" | "jsonb" | "text[]" | "integer[]" | "boolean[]" | "numeric[]";
|
|
547
549
|
/**
|
|
548
550
|
* The property of this array.
|
|
549
551
|
* You can specify any property (except another Array property)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { User } from "../users";
|
|
2
2
|
/**
|
|
3
3
|
* Result of creating a new user via admin flow.
|
|
4
4
|
* Contains the created user plus information about how credentials were delivered.
|
|
@@ -15,56 +15,46 @@ export interface UserCreationResult<USER extends User = User> {
|
|
|
15
15
|
temporaryPassword?: string;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Delegate to manage
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* Delegate to manage auth-specific user operations.
|
|
19
|
+
*
|
|
20
|
+
* This interface allows the CMS to be agnostic of the underlying
|
|
21
|
+
* authentication provider or backend. User/role CRUD is now handled
|
|
22
|
+
* by the collection system; this delegate only exposes auth-specific
|
|
23
|
+
* operations (password hashing, invitations, bootstrap).
|
|
21
24
|
*
|
|
22
25
|
* @group Models
|
|
23
26
|
*/
|
|
24
27
|
export interface UserManagementDelegate<USER extends User = User> {
|
|
25
28
|
/**
|
|
26
|
-
* Are
|
|
29
|
+
* Are auth-related operations currently loading?
|
|
27
30
|
*/
|
|
28
31
|
loading: boolean;
|
|
29
32
|
/**
|
|
30
|
-
*
|
|
33
|
+
* In-memory list of users (used for client-side filtering fallback).
|
|
31
34
|
*/
|
|
32
|
-
users
|
|
35
|
+
users?: USER[];
|
|
33
36
|
/**
|
|
34
|
-
*
|
|
37
|
+
* Error from fetching the users list, if any.
|
|
35
38
|
*/
|
|
36
39
|
usersError?: Error;
|
|
37
40
|
/**
|
|
38
|
-
*
|
|
39
|
-
* user information when assigning ownership of an entity.
|
|
40
|
-
* @param uid
|
|
41
|
+
* Look up a single user by UID from the in-memory cache.
|
|
41
42
|
*/
|
|
42
|
-
getUser
|
|
43
|
+
getUser?: (uid: string) => USER | null;
|
|
43
44
|
/**
|
|
44
|
-
*
|
|
45
|
-
* When provided, the CMS will use this for the users table
|
|
46
|
-
* instead of loading all users into memory.
|
|
45
|
+
* Server-side user search with pagination.
|
|
47
46
|
*/
|
|
48
|
-
searchUsers?: (
|
|
47
|
+
searchUsers?: (params: {
|
|
49
48
|
search?: string;
|
|
50
49
|
limit?: number;
|
|
51
50
|
offset?: number;
|
|
52
|
-
orderBy?: string;
|
|
53
|
-
orderDir?: "asc" | "desc";
|
|
54
|
-
roleId?: string;
|
|
55
51
|
}) => Promise<{
|
|
56
52
|
users: USER[];
|
|
57
53
|
total: number;
|
|
58
54
|
}>;
|
|
59
|
-
/**
|
|
60
|
-
* Save a user (create or update)
|
|
61
|
-
* @param user
|
|
62
|
-
*/
|
|
63
|
-
saveUser?: (user: USER) => Promise<USER>;
|
|
64
55
|
/**
|
|
65
56
|
* Create a new user with invitation/password generation support.
|
|
66
57
|
* Returns additional info about how the credentials were delivered.
|
|
67
|
-
* Falls back to saveUser if not provided.
|
|
68
58
|
*/
|
|
69
59
|
createUser?: (user: USER) => Promise<UserCreationResult<USER>>;
|
|
70
60
|
/**
|
|
@@ -73,42 +63,15 @@ export interface UserManagementDelegate<USER extends User = User> {
|
|
|
73
63
|
* or a flag indicating an email invitation was sent.
|
|
74
64
|
*/
|
|
75
65
|
resetPassword?: (user: USER) => Promise<UserCreationResult<USER>>;
|
|
76
|
-
/**
|
|
77
|
-
* Delete a user
|
|
78
|
-
* @param user
|
|
79
|
-
*/
|
|
80
|
-
deleteUser?: (user: USER) => Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
* List of roles defined in the CMS.
|
|
83
|
-
*/
|
|
84
|
-
roles?: Role[];
|
|
85
|
-
/**
|
|
86
|
-
* Optional error if roles failed to load.
|
|
87
|
-
*/
|
|
88
|
-
rolesError?: Error;
|
|
89
|
-
/**
|
|
90
|
-
* Save a role (create or update)
|
|
91
|
-
* @param role
|
|
92
|
-
*/
|
|
93
|
-
saveRole?: (role: Role) => Promise<void>;
|
|
94
|
-
/**
|
|
95
|
-
* Delete a role
|
|
96
|
-
* @param role
|
|
97
|
-
*/
|
|
98
|
-
deleteRole?: (role: Role) => Promise<void>;
|
|
99
66
|
/**
|
|
100
67
|
* Is the currently logged in user an admin?
|
|
101
68
|
*/
|
|
102
69
|
isAdmin?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* If true, the UI will allow the user to create the default roles (admin, editor, viewer).
|
|
105
|
-
*/
|
|
106
|
-
allowDefaultRolesCreation?: boolean;
|
|
107
70
|
/**
|
|
108
71
|
* Optionally define roles for a given user. This is useful when the roles
|
|
109
72
|
* are coming from a separate provider than the one issuing the tokens.
|
|
110
73
|
*/
|
|
111
|
-
defineRolesFor?: (user: USER) => Promise<
|
|
74
|
+
defineRolesFor?: (user: USER) => Promise<string[] | undefined> | string[] | undefined;
|
|
112
75
|
/**
|
|
113
76
|
* Whether any admin users exist. Used by the bootstrap banner to decide
|
|
114
77
|
* whether to prompt. Populated via a lightweight check (e.g. `limit=1`
|
package/dist/users/index.d.ts
CHANGED
package/dist/users/user.d.ts
CHANGED
package/package.json
CHANGED
package/src/controllers/auth.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { User } from "../users";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Capabilities advertised by an auth provider.
|
|
@@ -77,7 +77,7 @@ export type AuthController<USER extends User = User, ExtraData = unknown> = {
|
|
|
77
77
|
|
|
78
78
|
setUser?(user: USER | null): void;
|
|
79
79
|
|
|
80
|
-
setUserRoles?(roles:
|
|
80
|
+
setUserRoles?(roles: string[]): void;
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* Capabilities advertised by the auth provider.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { User } from "../users";
|
|
2
|
-
import { RebaseData } from "./data";
|
|
3
|
-
import { EmailService } from "./email";
|
|
1
|
+
import type { User } from "../users";
|
|
2
|
+
import type { RebaseData } from "./data";
|
|
3
|
+
import type { EmailService } from "./email";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Event type for authentication state changes
|
|
@@ -17,7 +17,7 @@ export interface RebaseSession {
|
|
|
17
17
|
user: User;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
import { StorageSource } from "./storage";
|
|
20
|
+
import type { StorageSource } from "./storage";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Unified Authentication Client Interface
|
|
@@ -66,20 +66,9 @@ export interface AdminUser {
|
|
|
66
66
|
updatedAt: string;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
/**
|
|
70
|
-
* Role record as returned by the Admin API.
|
|
71
|
-
* @group Admin
|
|
72
|
-
*/
|
|
73
|
-
export interface AdminRole {
|
|
74
|
-
id: string;
|
|
75
|
-
name: string;
|
|
76
|
-
isAdmin: boolean;
|
|
77
|
-
defaultPermissions: Record<string, unknown> | null;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
69
|
/**
|
|
81
70
|
* Client-side Admin API interface.
|
|
82
|
-
* Provides user
|
|
71
|
+
* Provides user management operations.
|
|
83
72
|
* @group Admin
|
|
84
73
|
*/
|
|
85
74
|
export interface AdminAPI {
|
|
@@ -95,11 +84,6 @@ export interface AdminAPI {
|
|
|
95
84
|
createUser(data: { email: string; displayName?: string; password?: string; roles?: string[]; metadata?: Record<string, any> }): Promise<{ user: AdminUser }>;
|
|
96
85
|
updateUser(userId: string, data: { email?: string; displayName?: string; password?: string; roles?: string[]; metadata?: Record<string, any> }): Promise<{ user: AdminUser }>;
|
|
97
86
|
deleteUser(userId: string): Promise<{ success: boolean }>;
|
|
98
|
-
listRoles(): Promise<{ roles: AdminRole[] }>;
|
|
99
|
-
getRole(roleId: string): Promise<{ role: AdminRole }>;
|
|
100
|
-
createRole(data: { id: string; name: string; isAdmin?: boolean; defaultPermissions?: Record<string, unknown> }): Promise<{ role: AdminRole }>;
|
|
101
|
-
updateRole(roleId: string, data: { name?: string; isAdmin?: boolean; defaultPermissions?: Record<string, unknown> }): Promise<{ role: AdminRole }>;
|
|
102
|
-
deleteRole(roleId: string): Promise<{ success: boolean }>;
|
|
103
87
|
bootstrap(): Promise<{ success: boolean; message: string; user: { uid: string; roles: string[] } }>;
|
|
104
88
|
}
|
|
105
89
|
|
|
@@ -128,7 +112,7 @@ export interface RebaseClient<DB = unknown> {
|
|
|
128
112
|
*/
|
|
129
113
|
email?: EmailService;
|
|
130
114
|
|
|
131
|
-
/** Admin API for user
|
|
115
|
+
/** Admin API for user management */
|
|
132
116
|
admin?: AdminAPI;
|
|
133
117
|
|
|
134
118
|
/**
|
|
@@ -145,4 +129,21 @@ export interface RebaseClient<DB = unknown> {
|
|
|
145
129
|
* detection (e.g. `typeof ws.executeSql === "function"`).
|
|
146
130
|
*/
|
|
147
131
|
ws?: unknown;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Execute raw SQL against the database.
|
|
135
|
+
*
|
|
136
|
+
* Only available server-side when the backend uses a SQL database
|
|
137
|
+
* (PostgreSQL, MySQL, etc.). `undefined` for document databases
|
|
138
|
+
* (MongoDB, Firestore) and on the client-side SDK.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* // In a cron job or custom function:
|
|
143
|
+
* if (ctx.client.sql) {
|
|
144
|
+
* const rows = await ctx.client.sql("SELECT count(*) FROM orders");
|
|
145
|
+
* }
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
sql?(query: string, options?: { database?: string; role?: string }): Promise<Record<string, unknown>[]>;
|
|
148
149
|
}
|
package/src/controllers/data.ts
CHANGED
|
@@ -22,7 +22,21 @@ export type WhereFieldValue =
|
|
|
22
22
|
| number
|
|
23
23
|
| boolean
|
|
24
24
|
| null
|
|
25
|
-
| [WhereFilterOpShort, any]
|
|
25
|
+
| [WhereFilterOpShort, any]
|
|
26
|
+
| [WhereFilterOpShort, any][];
|
|
27
|
+
|
|
28
|
+
export type WhereValue<T> = T | T[] | null;
|
|
29
|
+
|
|
30
|
+
export interface LogicalCondition {
|
|
31
|
+
type: "and" | "or";
|
|
32
|
+
conditions: (FilterCondition | LogicalCondition)[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface FilterCondition {
|
|
36
|
+
column: string;
|
|
37
|
+
operator: FilterOperator;
|
|
38
|
+
value: unknown;
|
|
39
|
+
}
|
|
26
40
|
|
|
27
41
|
/** Short operator strings accepted in the tuple syntax. */
|
|
28
42
|
export type WhereFilterOpShort =
|
|
@@ -63,6 +77,8 @@ export interface FindParams {
|
|
|
63
77
|
* ```
|
|
64
78
|
*/
|
|
65
79
|
where?: Record<string, WhereFieldValue>;
|
|
80
|
+
/** Logical grouping conditions (AND/OR) */
|
|
81
|
+
logical?: LogicalCondition;
|
|
66
82
|
/**
|
|
67
83
|
* Sort order. Format: "field:direction".
|
|
68
84
|
* @example "created_at:desc", "name:asc"
|
|
@@ -97,7 +113,8 @@ export type FilterOperator = WhereFilterOpShort;
|
|
|
97
113
|
* @group Data
|
|
98
114
|
*/
|
|
99
115
|
export interface QueryBuilderInterface<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
100
|
-
where
|
|
116
|
+
where<K extends keyof M & string>(column: K, operator: FilterOperator, value: WhereValue<M[K]>): this;
|
|
117
|
+
where(logicalCondition: LogicalCondition): this;
|
|
101
118
|
orderBy(column: keyof M & string, ascending?: "asc" | "desc"): this;
|
|
102
119
|
limit(count: number): this;
|
|
103
120
|
offset(count: number): this;
|
|
@@ -146,6 +163,11 @@ export interface CollectionAccessor<M extends Record<string, unknown> = Record<s
|
|
|
146
163
|
*/
|
|
147
164
|
delete(id: string | number): Promise<void>;
|
|
148
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Delete all records in this collection.
|
|
168
|
+
*/
|
|
169
|
+
deleteAll?(): Promise<void>;
|
|
170
|
+
|
|
149
171
|
/**
|
|
150
172
|
* Subscribe to a collection for real-time updates.
|
|
151
173
|
* Optional method, may not be supported by all implementations (like stateless HTTP clients).
|
|
@@ -164,7 +186,8 @@ export interface CollectionAccessor<M extends Record<string, unknown> = Record<s
|
|
|
164
186
|
count?(params?: FindParams): Promise<number>;
|
|
165
187
|
|
|
166
188
|
// Fluent Query Builder
|
|
167
|
-
where
|
|
189
|
+
where<K extends keyof M & string>(column: K, operator: FilterOperator, value: WhereValue<M[K]>): QueryBuilderInterface<M>;
|
|
190
|
+
where(logicalCondition: LogicalCondition): QueryBuilderInterface<M>;
|
|
168
191
|
orderBy(column: keyof M & string, ascending?: "asc" | "desc"): QueryBuilderInterface<M>;
|
|
169
192
|
limit(count: number): QueryBuilderInterface<M>;
|
|
170
193
|
offset(count: number): QueryBuilderInterface<M>;
|
|
@@ -153,6 +153,12 @@ export interface DataDriver {
|
|
|
153
153
|
*/
|
|
154
154
|
deleteEntity<M extends Record<string, unknown> = Record<string, unknown>>(props: DeleteEntityProps<M>): Promise<void>;
|
|
155
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Delete all entities from a collection.
|
|
158
|
+
* @param path Collection path
|
|
159
|
+
*/
|
|
160
|
+
deleteAll?(path: string): Promise<void>;
|
|
161
|
+
|
|
156
162
|
/**
|
|
157
163
|
* Check if the given property is unique in the given collection
|
|
158
164
|
* @param path Collection path
|
package/src/controllers/email.ts
CHANGED
|
@@ -33,4 +33,6 @@ export interface EmailService {
|
|
|
33
33
|
send(options: EmailSendOptions): Promise<void>;
|
|
34
34
|
/** Returns `true` when the service has valid credentials / is ready to send. */
|
|
35
35
|
isConfigured(): boolean;
|
|
36
|
+
/** Verify connection/credentials with the email provider. */
|
|
37
|
+
verifyConnection?(): Promise<boolean>;
|
|
36
38
|
}
|
|
@@ -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.
|
|
@@ -166,40 +166,6 @@ export interface AuthCreateUserData {
|
|
|
166
166
|
metadata?: Record<string, unknown>;
|
|
167
167
|
}
|
|
168
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
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Data for creating a role.
|
|
193
|
-
* @group Auth
|
|
194
|
-
*/
|
|
195
|
-
export interface AuthCreateRoleData {
|
|
196
|
-
id: string;
|
|
197
|
-
name: string;
|
|
198
|
-
isAdmin?: boolean;
|
|
199
|
-
defaultPermissions?: AuthRoleData["defaultPermissions"];
|
|
200
|
-
collectionPermissions?: AuthRoleData["collectionPermissions"];
|
|
201
|
-
}
|
|
202
|
-
|
|
203
169
|
/**
|
|
204
170
|
* User management operations for the admin panel.
|
|
205
171
|
*
|
|
@@ -213,25 +179,10 @@ export interface UserManagementAdapter {
|
|
|
213
179
|
createUser(data: AuthCreateUserData): Promise<AuthUserData>;
|
|
214
180
|
updateUser(id: string, data: Partial<AuthCreateUserData>): Promise<AuthUserData | null>;
|
|
215
181
|
deleteUser(id: string): Promise<void>;
|
|
216
|
-
getUserRoles(userId: string): Promise<
|
|
182
|
+
getUserRoles(userId: string): Promise<string[]>;
|
|
217
183
|
setUserRoles(userId: string, roleIds: string[]): Promise<void>;
|
|
218
184
|
}
|
|
219
185
|
|
|
220
|
-
/**
|
|
221
|
-
* Role management operations for the admin panel.
|
|
222
|
-
*
|
|
223
|
-
* Optional — if not provided by the adapter, role management is disabled.
|
|
224
|
-
*
|
|
225
|
-
* @group Auth
|
|
226
|
-
*/
|
|
227
|
-
export interface RoleManagementAdapter {
|
|
228
|
-
listRoles(): Promise<AuthRoleData[]>;
|
|
229
|
-
getRoleById(id: string): Promise<AuthRoleData | null>;
|
|
230
|
-
createRole(data: AuthCreateRoleData): Promise<AuthRoleData>;
|
|
231
|
-
updateRole(id: string, data: Partial<AuthRoleData>): Promise<AuthRoleData | null>;
|
|
232
|
-
deleteRole(id: string): Promise<void>;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
186
|
// ─── Auth Adapter ────────────────────────────────────────────────────────────
|
|
236
187
|
|
|
237
188
|
/**
|
|
@@ -241,7 +192,7 @@ export interface RoleManagementAdapter {
|
|
|
241
192
|
* database layer. Each auth adapter knows how to:
|
|
242
193
|
*
|
|
243
194
|
* 1. Verify incoming HTTP requests (`verifyRequest`)
|
|
244
|
-
* 2. Optionally manage users
|
|
195
|
+
* 2. Optionally manage users (for the admin panel)
|
|
245
196
|
* 3. Optionally mount auth-specific routes (login, register, etc.)
|
|
246
197
|
* 4. Advertise its capabilities so the frontend can adapt
|
|
247
198
|
*
|
|
@@ -293,7 +244,7 @@ export interface AuthAdapter {
|
|
|
293
244
|
*/
|
|
294
245
|
verifyToken?(token: string): Promise<AuthenticatedUser | null>;
|
|
295
246
|
|
|
296
|
-
// ── User
|
|
247
|
+
// ── User Management (for admin panel) ────────────────────────────
|
|
297
248
|
|
|
298
249
|
/**
|
|
299
250
|
* User CRUD for the admin panel's user management UI.
|
|
@@ -301,12 +252,6 @@ export interface AuthAdapter {
|
|
|
301
252
|
*/
|
|
302
253
|
userManagement?: UserManagementAdapter;
|
|
303
254
|
|
|
304
|
-
/**
|
|
305
|
-
* Role CRUD for the admin panel.
|
|
306
|
-
* Optional — if not provided, role management is disabled.
|
|
307
|
-
*/
|
|
308
|
-
roleManagement?: RoleManagementAdapter;
|
|
309
|
-
|
|
310
255
|
// ── Auth Routes ─────────────────────────────────────────────────────
|
|
311
256
|
|
|
312
257
|
/**
|
|
@@ -325,7 +270,7 @@ export interface AuthAdapter {
|
|
|
325
270
|
createAuthRoutes?(): Hono<any, any, any> | undefined;
|
|
326
271
|
|
|
327
272
|
/**
|
|
328
|
-
* Mount admin routes for user
|
|
273
|
+
* Mount admin routes for user management.
|
|
329
274
|
*
|
|
330
275
|
* Same typing rationale as `createAuthRoutes` — the sub-app env is
|
|
331
276
|
* unconstrained to support arbitrary adapter implementations.
|
|
@@ -397,9 +342,6 @@ export interface CustomAuthAdapterOptions {
|
|
|
397
342
|
/** Optional user management for the admin panel. */
|
|
398
343
|
userManagement?: UserManagementAdapter;
|
|
399
344
|
|
|
400
|
-
/** Optional role management for the admin panel. */
|
|
401
|
-
roleManagement?: RoleManagementAdapter;
|
|
402
|
-
|
|
403
345
|
/** Static service key for server-to-server auth. */
|
|
404
346
|
serviceKey?: string;
|
|
405
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
|
@@ -8,7 +8,7 @@ import type { EntityOverrides } from "./entity_overrides";
|
|
|
8
8
|
import type { User } from "../users";
|
|
9
9
|
import type { RebaseContext } from "../rebase_context";
|
|
10
10
|
import type { Relation } from "./relations";
|
|
11
|
-
import type { EntityCustomView,
|
|
11
|
+
import type { EntityCustomView, FormViewConfig } from "./entity_views";
|
|
12
12
|
import type { EntityAction } from "./entity_actions";
|
|
13
13
|
import type { ComponentRef } from "./component_ref";
|
|
14
14
|
|
|
@@ -144,10 +144,14 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
144
144
|
defaultEntityAction?: "view" | "edit";
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
147
|
+
* Replace the default entity form with a custom component.
|
|
148
|
+
* The Builder receives the same props as entity view tabs
|
|
149
|
+
* (entity, formContext, collection, etc.) and has full control over the UI.
|
|
150
|
+
*
|
|
151
|
+
* Works in both edit mode and read-only mode (when `defaultEntityAction`
|
|
152
|
+
* is `"view"`). In read-only mode, `formContext.readOnly` will be `true`.
|
|
149
153
|
*/
|
|
150
|
-
|
|
154
|
+
formView?: FormViewConfig;
|
|
151
155
|
|
|
152
156
|
/**
|
|
153
157
|
* Prevent default actions from being displayed or executed on this collection.
|
|
@@ -689,7 +693,7 @@ export type WhereFilterOp =
|
|
|
689
693
|
* @group Models
|
|
690
694
|
*/
|
|
691
695
|
export type FilterValues<Key extends string> =
|
|
692
|
-
Partial<Record<Key, [WhereFilterOp, unknown]>>;
|
|
696
|
+
Partial<Record<Key, [WhereFilterOp, unknown] | [WhereFilterOp, unknown][]>>;
|
|
693
697
|
|
|
694
698
|
/**
|
|
695
699
|
* A pre-defined filter preset for quick access in the collection toolbar.
|