@rebasepro/server-postgresql 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/common/src/collections/default-collections.d.ts +5 -8
- package/dist/common/src/data/query_builder.d.ts +6 -2
- package/dist/index.es.js +301 -500
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +297 -496
- package/dist/index.umd.js.map +1 -1
- package/dist/server-postgresql/src/PostgresBackendDriver.d.ts +2 -0
- package/dist/server-postgresql/src/auth/ensure-tables.d.ts +7 -4
- package/dist/server-postgresql/src/auth/services.d.ts +6 -31
- package/dist/server-postgresql/src/schema/auth-schema.d.ts +87 -340
- package/dist/server-postgresql/src/services/EntityFetchService.d.ts +2 -1
- package/dist/server-postgresql/src/services/EntityPersistService.d.ts +4 -0
- package/dist/server-postgresql/src/services/entityService.d.ts +4 -0
- package/dist/server-postgresql/src/utils/drizzle-conditions.d.ts +5 -1
- package/dist/types/src/controllers/auth.d.ts +2 -2
- package/dist/types/src/controllers/client.d.ts +25 -40
- package/dist/types/src/controllers/data.d.ts +21 -3
- package/dist/types/src/controllers/data_driver.d.ts +5 -0
- package/dist/types/src/controllers/email.d.ts +2 -0
- package/dist/types/src/types/auth_adapter.d.ts +3 -56
- package/dist/types/src/types/backend.d.ts +2 -2
- package/dist/types/src/types/backend_hooks.d.ts +2 -17
- package/dist/types/src/types/collections.d.ts +9 -5
- package/dist/types/src/types/entity_views.d.ts +19 -28
- package/dist/types/src/types/properties.d.ts +9 -7
- package/dist/types/src/types/user_management_delegate.d.ts +16 -53
- package/dist/types/src/users/index.d.ts +0 -1
- package/dist/types/src/users/user.d.ts +0 -1
- package/package.json +6 -6
- package/src/PostgresBackendDriver.ts +10 -0
- package/src/PostgresBootstrapper.ts +25 -21
- package/src/auth/ensure-tables.ts +82 -129
- package/src/auth/services.ts +71 -170
- package/src/schema/auth-schema.ts +13 -69
- package/src/schema/doctor.ts +44 -3
- package/src/schema/generate-drizzle-schema-logic.ts +33 -3
- package/src/schema/generate-drizzle-schema.ts +2 -6
- package/src/schema/introspect-db-logic.ts +7 -0
- package/src/services/EntityFetchService.ts +13 -1
- package/src/services/EntityPersistService.ts +9 -0
- package/src/services/entityService.ts +7 -0
- package/src/utils/drizzle-conditions.ts +40 -5
- package/src/websocket.ts +1 -3
- package/test/auth-services.test.ts +7 -150
- package/test/doctor.test.ts +6 -2
- package/test/relation-pipeline-gaps.test.ts +315 -0
- package/dist/server-postgresql/src/schema/default-collections.d.ts +0 -2
- package/dist/types/src/users/roles.d.ts +0 -14
- package/src/schema/default-collections.ts +0 -69
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { User } from "../users";
|
|
2
2
|
/**
|
|
3
3
|
* Capabilities advertised by an auth provider.
|
|
4
4
|
* UI components use this to show/hide features dynamically
|
|
@@ -62,7 +62,7 @@ export type AuthController<USER extends User = User, ExtraData = unknown> = {
|
|
|
62
62
|
extra: ExtraData;
|
|
63
63
|
setExtra: (extra: ExtraData) => void;
|
|
64
64
|
setUser?(user: USER | null): void;
|
|
65
|
-
setUserRoles?(roles:
|
|
65
|
+
setUserRoles?(roles: string[]): void;
|
|
66
66
|
/**
|
|
67
67
|
* Capabilities advertised by the auth provider.
|
|
68
68
|
* UI components use this to feature-detect what the backend supports.
|
|
@@ -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
|
* Event type for authentication state changes
|
|
6
6
|
*/
|
|
@@ -14,7 +14,7 @@ export interface RebaseSession {
|
|
|
14
14
|
expiresAt: number;
|
|
15
15
|
user: User;
|
|
16
16
|
}
|
|
17
|
-
import { StorageSource } from "./storage";
|
|
17
|
+
import type { StorageSource } from "./storage";
|
|
18
18
|
/**
|
|
19
19
|
* Unified Authentication Client Interface
|
|
20
20
|
* Pure functional SDK interface, decoupled from UI and React hooks
|
|
@@ -56,19 +56,9 @@ export interface AdminUser {
|
|
|
56
56
|
createdAt: string;
|
|
57
57
|
updatedAt: string;
|
|
58
58
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Role record as returned by the Admin API.
|
|
61
|
-
* @group Admin
|
|
62
|
-
*/
|
|
63
|
-
export interface AdminRole {
|
|
64
|
-
id: string;
|
|
65
|
-
name: string;
|
|
66
|
-
isAdmin: boolean;
|
|
67
|
-
defaultPermissions: Record<string, unknown> | null;
|
|
68
|
-
}
|
|
69
59
|
/**
|
|
70
60
|
* Client-side Admin API interface.
|
|
71
|
-
* Provides user
|
|
61
|
+
* Provides user management operations.
|
|
72
62
|
* @group Admin
|
|
73
63
|
*/
|
|
74
64
|
export interface AdminAPI {
|
|
@@ -111,30 +101,6 @@ export interface AdminAPI {
|
|
|
111
101
|
deleteUser(userId: string): Promise<{
|
|
112
102
|
success: boolean;
|
|
113
103
|
}>;
|
|
114
|
-
listRoles(): Promise<{
|
|
115
|
-
roles: AdminRole[];
|
|
116
|
-
}>;
|
|
117
|
-
getRole(roleId: string): Promise<{
|
|
118
|
-
role: AdminRole;
|
|
119
|
-
}>;
|
|
120
|
-
createRole(data: {
|
|
121
|
-
id: string;
|
|
122
|
-
name: string;
|
|
123
|
-
isAdmin?: boolean;
|
|
124
|
-
defaultPermissions?: Record<string, unknown>;
|
|
125
|
-
}): Promise<{
|
|
126
|
-
role: AdminRole;
|
|
127
|
-
}>;
|
|
128
|
-
updateRole(roleId: string, data: {
|
|
129
|
-
name?: string;
|
|
130
|
-
isAdmin?: boolean;
|
|
131
|
-
defaultPermissions?: Record<string, unknown>;
|
|
132
|
-
}): Promise<{
|
|
133
|
-
role: AdminRole;
|
|
134
|
-
}>;
|
|
135
|
-
deleteRole(roleId: string): Promise<{
|
|
136
|
-
success: boolean;
|
|
137
|
-
}>;
|
|
138
104
|
bootstrap(): Promise<{
|
|
139
105
|
success: boolean;
|
|
140
106
|
message: string;
|
|
@@ -165,7 +131,7 @@ export interface RebaseClient<DB = unknown> {
|
|
|
165
131
|
* > The client-side SDK does not include an email service.
|
|
166
132
|
*/
|
|
167
133
|
email?: EmailService;
|
|
168
|
-
/** Admin API for user
|
|
134
|
+
/** Admin API for user management */
|
|
169
135
|
admin?: AdminAPI;
|
|
170
136
|
/**
|
|
171
137
|
* The base HTTP URL of the backend server.
|
|
@@ -180,4 +146,23 @@ export interface RebaseClient<DB = unknown> {
|
|
|
180
146
|
* detection (e.g. `typeof ws.executeSql === "function"`).
|
|
181
147
|
*/
|
|
182
148
|
ws?: unknown;
|
|
149
|
+
/**
|
|
150
|
+
* Execute raw SQL against the database.
|
|
151
|
+
*
|
|
152
|
+
* Only available server-side when the backend uses a SQL database
|
|
153
|
+
* (PostgreSQL, MySQL, etc.). `undefined` for document databases
|
|
154
|
+
* (MongoDB, Firestore) and on the client-side SDK.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* // In a cron job or custom function:
|
|
159
|
+
* if (ctx.client.sql) {
|
|
160
|
+
* const rows = await ctx.client.sql("SELECT count(*) FROM orders");
|
|
161
|
+
* }
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
sql?(query: string, options?: {
|
|
165
|
+
database?: string;
|
|
166
|
+
role?: string;
|
|
167
|
+
}): Promise<Record<string, unknown>[]>;
|
|
183
168
|
}
|
|
@@ -16,7 +16,17 @@ import { Entity, EntityValues } from "../types/entities";
|
|
|
16
16
|
*
|
|
17
17
|
* @group Data
|
|
18
18
|
*/
|
|
19
|
-
export type WhereFieldValue = string | number | boolean | null | [WhereFilterOpShort, any];
|
|
19
|
+
export type WhereFieldValue = string | number | boolean | null | [WhereFilterOpShort, any] | [WhereFilterOpShort, any][];
|
|
20
|
+
export type WhereValue<T> = T | T[] | null;
|
|
21
|
+
export interface LogicalCondition {
|
|
22
|
+
type: "and" | "or";
|
|
23
|
+
conditions: (FilterCondition | LogicalCondition)[];
|
|
24
|
+
}
|
|
25
|
+
export interface FilterCondition {
|
|
26
|
+
column: string;
|
|
27
|
+
operator: FilterOperator;
|
|
28
|
+
value: unknown;
|
|
29
|
+
}
|
|
20
30
|
/** Short operator strings accepted in the tuple syntax. */
|
|
21
31
|
export type WhereFilterOpShort = "==" | "!=" | ">" | ">=" | "<" | "<=" | "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" | "not-in" | "array-contains" | "array-contains-any" | "cs" | "csa";
|
|
22
32
|
export interface FindParams {
|
|
@@ -51,6 +61,8 @@ export interface FindParams {
|
|
|
51
61
|
* ```
|
|
52
62
|
*/
|
|
53
63
|
where?: Record<string, WhereFieldValue>;
|
|
64
|
+
/** Logical grouping conditions (AND/OR) */
|
|
65
|
+
logical?: LogicalCondition;
|
|
54
66
|
/**
|
|
55
67
|
* Sort order. Format: "field:direction".
|
|
56
68
|
* @example "created_at:desc", "name:asc"
|
|
@@ -82,7 +94,8 @@ export type FilterOperator = WhereFilterOpShort;
|
|
|
82
94
|
* @group Data
|
|
83
95
|
*/
|
|
84
96
|
export interface QueryBuilderInterface<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
85
|
-
where
|
|
97
|
+
where<K extends keyof M & string>(column: K, operator: FilterOperator, value: WhereValue<M[K]>): this;
|
|
98
|
+
where(logicalCondition: LogicalCondition): this;
|
|
86
99
|
orderBy(column: keyof M & string, ascending?: "asc" | "desc"): this;
|
|
87
100
|
limit(count: number): this;
|
|
88
101
|
offset(count: number): this;
|
|
@@ -125,6 +138,10 @@ export interface CollectionAccessor<M extends Record<string, unknown> = Record<s
|
|
|
125
138
|
* Delete a record by ID.
|
|
126
139
|
*/
|
|
127
140
|
delete(id: string | number): Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Delete all records in this collection.
|
|
143
|
+
*/
|
|
144
|
+
deleteAll?(): Promise<void>;
|
|
128
145
|
/**
|
|
129
146
|
* Subscribe to a collection for real-time updates.
|
|
130
147
|
* Optional method, may not be supported by all implementations (like stateless HTTP clients).
|
|
@@ -139,7 +156,8 @@ export interface CollectionAccessor<M extends Record<string, unknown> = Record<s
|
|
|
139
156
|
* Count the number of records matching the given filter.
|
|
140
157
|
*/
|
|
141
158
|
count?(params?: FindParams): Promise<number>;
|
|
142
|
-
where
|
|
159
|
+
where<K extends keyof M & string>(column: K, operator: FilterOperator, value: WhereValue<M[K]>): QueryBuilderInterface<M>;
|
|
160
|
+
where(logicalCondition: LogicalCondition): QueryBuilderInterface<M>;
|
|
143
161
|
orderBy(column: keyof M & string, ascending?: "asc" | "desc"): QueryBuilderInterface<M>;
|
|
144
162
|
limit(count: number): QueryBuilderInterface<M>;
|
|
145
163
|
offset(count: number): QueryBuilderInterface<M>;
|
|
@@ -129,6 +129,11 @@ export interface DataDriver {
|
|
|
129
129
|
* @return was the whole deletion flow successful
|
|
130
130
|
*/
|
|
131
131
|
deleteEntity<M extends Record<string, unknown> = Record<string, unknown>>(props: DeleteEntityProps<M>): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Delete all entities from a collection.
|
|
134
|
+
* @param path Collection path
|
|
135
|
+
*/
|
|
136
|
+
deleteAll?(path: string): Promise<void>;
|
|
132
137
|
/**
|
|
133
138
|
* Check if the given property is unique in the given collection
|
|
134
139
|
* @param path Collection path
|
|
@@ -31,4 +31,6 @@ export interface EmailService {
|
|
|
31
31
|
send(options: EmailSendOptions): Promise<void>;
|
|
32
32
|
/** Returns `true` when the service has valid credentials / is ready to send. */
|
|
33
33
|
isConfigured(): boolean;
|
|
34
|
+
/** Verify connection/credentials with the email provider. */
|
|
35
|
+
verifyConnection?(): Promise<boolean>;
|
|
34
36
|
}
|
|
@@ -148,38 +148,6 @@ export interface AuthCreateUserData {
|
|
|
148
148
|
photoUrl?: string;
|
|
149
149
|
metadata?: Record<string, unknown>;
|
|
150
150
|
}
|
|
151
|
-
/**
|
|
152
|
-
* Role data exposed by the auth adapter.
|
|
153
|
-
* @group Auth
|
|
154
|
-
*/
|
|
155
|
-
export interface AuthRoleData {
|
|
156
|
-
id: string;
|
|
157
|
-
name: string;
|
|
158
|
-
isAdmin: boolean;
|
|
159
|
-
defaultPermissions?: {
|
|
160
|
-
read?: boolean;
|
|
161
|
-
create?: boolean;
|
|
162
|
-
edit?: boolean;
|
|
163
|
-
delete?: boolean;
|
|
164
|
-
} | null;
|
|
165
|
-
collectionPermissions?: Record<string, {
|
|
166
|
-
read?: boolean;
|
|
167
|
-
create?: boolean;
|
|
168
|
-
edit?: boolean;
|
|
169
|
-
delete?: boolean;
|
|
170
|
-
}> | null;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Data for creating a role.
|
|
174
|
-
* @group Auth
|
|
175
|
-
*/
|
|
176
|
-
export interface AuthCreateRoleData {
|
|
177
|
-
id: string;
|
|
178
|
-
name: string;
|
|
179
|
-
isAdmin?: boolean;
|
|
180
|
-
defaultPermissions?: AuthRoleData["defaultPermissions"];
|
|
181
|
-
collectionPermissions?: AuthRoleData["collectionPermissions"];
|
|
182
|
-
}
|
|
183
151
|
/**
|
|
184
152
|
* User management operations for the admin panel.
|
|
185
153
|
*
|
|
@@ -193,23 +161,9 @@ export interface UserManagementAdapter {
|
|
|
193
161
|
createUser(data: AuthCreateUserData): Promise<AuthUserData>;
|
|
194
162
|
updateUser(id: string, data: Partial<AuthCreateUserData>): Promise<AuthUserData | null>;
|
|
195
163
|
deleteUser(id: string): Promise<void>;
|
|
196
|
-
getUserRoles(userId: string): Promise<
|
|
164
|
+
getUserRoles(userId: string): Promise<string[]>;
|
|
197
165
|
setUserRoles(userId: string, roleIds: string[]): Promise<void>;
|
|
198
166
|
}
|
|
199
|
-
/**
|
|
200
|
-
* Role management operations for the admin panel.
|
|
201
|
-
*
|
|
202
|
-
* Optional — if not provided by the adapter, role management is disabled.
|
|
203
|
-
*
|
|
204
|
-
* @group Auth
|
|
205
|
-
*/
|
|
206
|
-
export interface RoleManagementAdapter {
|
|
207
|
-
listRoles(): Promise<AuthRoleData[]>;
|
|
208
|
-
getRoleById(id: string): Promise<AuthRoleData | null>;
|
|
209
|
-
createRole(data: AuthCreateRoleData): Promise<AuthRoleData>;
|
|
210
|
-
updateRole(id: string, data: Partial<AuthRoleData>): Promise<AuthRoleData | null>;
|
|
211
|
-
deleteRole(id: string): Promise<void>;
|
|
212
|
-
}
|
|
213
167
|
/**
|
|
214
168
|
* Pluggable authentication adapter for Rebase.
|
|
215
169
|
*
|
|
@@ -217,7 +171,7 @@ export interface RoleManagementAdapter {
|
|
|
217
171
|
* database layer. Each auth adapter knows how to:
|
|
218
172
|
*
|
|
219
173
|
* 1. Verify incoming HTTP requests (`verifyRequest`)
|
|
220
|
-
* 2. Optionally manage users
|
|
174
|
+
* 2. Optionally manage users (for the admin panel)
|
|
221
175
|
* 3. Optionally mount auth-specific routes (login, register, etc.)
|
|
222
176
|
* 4. Advertise its capabilities so the frontend can adapt
|
|
223
177
|
*
|
|
@@ -269,11 +223,6 @@ export interface AuthAdapter {
|
|
|
269
223
|
* Optional — if not provided, user management UI is hidden.
|
|
270
224
|
*/
|
|
271
225
|
userManagement?: UserManagementAdapter;
|
|
272
|
-
/**
|
|
273
|
-
* Role CRUD for the admin panel.
|
|
274
|
-
* Optional — if not provided, role management is disabled.
|
|
275
|
-
*/
|
|
276
|
-
roleManagement?: RoleManagementAdapter;
|
|
277
226
|
/**
|
|
278
227
|
* Mount adapter-specific auth routes (login, register, refresh, etc.).
|
|
279
228
|
*
|
|
@@ -289,7 +238,7 @@ export interface AuthAdapter {
|
|
|
289
238
|
*/
|
|
290
239
|
createAuthRoutes?(): Hono<any, any, any> | undefined;
|
|
291
240
|
/**
|
|
292
|
-
* Mount admin routes for user
|
|
241
|
+
* Mount admin routes for user management.
|
|
293
242
|
*
|
|
294
243
|
* Same typing rationale as `createAuthRoutes` — the sub-app env is
|
|
295
244
|
* unconstrained to support arbitrary adapter implementations.
|
|
@@ -345,8 +294,6 @@ export interface CustomAuthAdapterOptions {
|
|
|
345
294
|
verifyToken?: (token: string) => Promise<AuthenticatedUser | null>;
|
|
346
295
|
/** Optional user management for the admin panel. */
|
|
347
296
|
userManagement?: UserManagementAdapter;
|
|
348
|
-
/** Optional role management for the admin panel. */
|
|
349
|
-
roleManagement?: RoleManagementAdapter;
|
|
350
297
|
/** Static service key for server-to-server auth. */
|
|
351
298
|
serviceKey?: string;
|
|
352
299
|
/** Override default capabilities. */
|
|
@@ -527,8 +527,8 @@ export interface InitializedDriver {
|
|
|
527
527
|
export interface BootstrappedAuth {
|
|
528
528
|
/** User management service. */
|
|
529
529
|
userService: unknown;
|
|
530
|
-
/** Role management service. */
|
|
531
|
-
roleService
|
|
530
|
+
/** Role management service (optional, roles are now simple strings). */
|
|
531
|
+
roleService?: unknown;
|
|
532
532
|
/** Email service (optional). */
|
|
533
533
|
emailService?: unknown;
|
|
534
534
|
/** 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
|
* Context passed to every backend hook.
|
|
4
4
|
* Provides information about the request that triggered the hook.
|
|
@@ -64,19 +64,6 @@ export interface UserHooks {
|
|
|
64
64
|
*/
|
|
65
65
|
afterDelete?(userId: string, context: BackendHookContext): void | Promise<void>;
|
|
66
66
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Hooks for intercepting Admin Role data at the API boundary.
|
|
69
|
-
* @group Backend Hooks
|
|
70
|
-
*/
|
|
71
|
-
export interface RoleHooks {
|
|
72
|
-
/**
|
|
73
|
-
* Transform a role record after it's read from the database,
|
|
74
|
-
* before it's returned to the client.
|
|
75
|
-
*
|
|
76
|
-
* Return the modified role, or `null` to filter it out entirely.
|
|
77
|
-
*/
|
|
78
|
-
afterRead?(role: AdminRole, context: BackendHookContext): AdminRole | null | Promise<AdminRole | null>;
|
|
79
|
-
}
|
|
80
67
|
/**
|
|
81
68
|
* Hooks for intercepting collection entity data at the REST API boundary.
|
|
82
69
|
*
|
|
@@ -146,7 +133,7 @@ export interface DataHooks {
|
|
|
146
133
|
* These hooks run server-side after database operations complete and before
|
|
147
134
|
* API responses are sent.
|
|
148
135
|
*
|
|
149
|
-
* - `users`
|
|
136
|
+
* - `users` — intercept admin user management endpoints
|
|
150
137
|
* - `data` — intercept ALL collection entity data flowing through the REST API
|
|
151
138
|
*
|
|
152
139
|
* `data` hooks complement per-collection `EntityCallbacks`. Entity callbacks
|
|
@@ -180,8 +167,6 @@ export interface DataHooks {
|
|
|
180
167
|
export interface BackendHooks {
|
|
181
168
|
/** Hooks for intercepting user management data */
|
|
182
169
|
users?: UserHooks;
|
|
183
|
-
/** Hooks for intercepting role management data */
|
|
184
|
-
roles?: RoleHooks;
|
|
185
170
|
/** Hooks for intercepting ALL collection entity data via the REST API */
|
|
186
171
|
data?: DataHooks;
|
|
187
172
|
}
|
|
@@ -7,7 +7,7 @@ import type { EntityOverrides } from "./entity_overrides";
|
|
|
7
7
|
import type { User } from "../users";
|
|
8
8
|
import type { RebaseContext } from "../rebase_context";
|
|
9
9
|
import type { Relation } from "./relations";
|
|
10
|
-
import type { EntityCustomView,
|
|
10
|
+
import type { EntityCustomView, FormViewConfig } from "./entity_views";
|
|
11
11
|
import type { EntityAction } from "./entity_actions";
|
|
12
12
|
import type { ComponentRef } from "./component_ref";
|
|
13
13
|
/**
|
|
@@ -124,10 +124,14 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
124
124
|
*/
|
|
125
125
|
defaultEntityAction?: "view" | "edit";
|
|
126
126
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
127
|
+
* Replace the default entity form with a custom component.
|
|
128
|
+
* The Builder receives the same props as entity view tabs
|
|
129
|
+
* (entity, formContext, collection, etc.) and has full control over the UI.
|
|
130
|
+
*
|
|
131
|
+
* Works in both edit mode and read-only mode (when `defaultEntityAction`
|
|
132
|
+
* is `"view"`). In read-only mode, `formContext.readOnly` will be `true`.
|
|
129
133
|
*/
|
|
130
|
-
|
|
134
|
+
formView?: FormViewConfig;
|
|
131
135
|
/**
|
|
132
136
|
* Prevent default actions from being displayed or executed on this collection.
|
|
133
137
|
*/
|
|
@@ -566,7 +570,7 @@ export type WhereFilterOp = "<" | "<=" | "==" | "!=" | ">=" | ">" | "array-conta
|
|
|
566
570
|
*
|
|
567
571
|
* @group Models
|
|
568
572
|
*/
|
|
569
|
-
export type FilterValues<Key extends string> = Partial<Record<Key, [WhereFilterOp, unknown]>>;
|
|
573
|
+
export type FilterValues<Key extends string> = Partial<Record<Key, [WhereFilterOp, unknown] | [WhereFilterOp, unknown][]>>;
|
|
570
574
|
/**
|
|
571
575
|
* A pre-defined filter preset for quick access in the collection toolbar.
|
|
572
576
|
* Users can select a preset to instantly apply a set of filters and
|
|
@@ -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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/server-postgresql",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"description": "PostgreSQL data source backend implementation for Rebase with Drizzle ORM",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/rebaseco"
|
|
@@ -68,11 +68,11 @@
|
|
|
68
68
|
"hono": "^4.12.21",
|
|
69
69
|
"pg": "^8.21.0",
|
|
70
70
|
"ws": "^8.20.1",
|
|
71
|
-
"@rebasepro/
|
|
72
|
-
"@rebasepro/
|
|
73
|
-
"@rebasepro/
|
|
74
|
-
"@rebasepro/
|
|
75
|
-
"@rebasepro/
|
|
71
|
+
"@rebasepro/sdk-generator": "0.4.0",
|
|
72
|
+
"@rebasepro/server-core": "0.4.0",
|
|
73
|
+
"@rebasepro/types": "0.4.0",
|
|
74
|
+
"@rebasepro/common": "0.4.0",
|
|
75
|
+
"@rebasepro/utils": "0.4.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@types/jest": "^29.5.14",
|