@rebasepro/types 0.8.0 → 0.9.1-canary.09aaf62
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/README.md +13 -13
- package/dist/controllers/auth.d.ts +7 -1
- package/dist/controllers/client.d.ts +204 -6
- package/dist/controllers/collection_registry.d.ts +3 -3
- package/dist/controllers/customization_controller.d.ts +1 -1
- package/dist/controllers/data.d.ts +309 -35
- package/dist/controllers/data_driver.d.ts +92 -37
- package/dist/controllers/email.d.ts +2 -2
- package/dist/controllers/index.d.ts +1 -1
- package/dist/controllers/local_config_persistence.d.ts +4 -4
- package/dist/controllers/navigation.d.ts +2 -2
- package/dist/controllers/registry.d.ts +21 -8
- package/dist/controllers/{side_entity_controller.d.ts → side_panel_controller.d.ts} +7 -7
- package/dist/controllers/storage.d.ts +39 -0
- package/dist/errors.d.ts +64 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +160 -15
- package/dist/index.es.js.map +1 -1
- package/dist/rebase_context.d.ts +8 -4
- package/dist/types/auth_adapter.d.ts +29 -4
- package/dist/types/backend.d.ts +33 -26
- package/dist/types/backup.d.ts +20 -0
- package/dist/types/builders.d.ts +2 -2
- package/dist/types/collections.d.ts +84 -75
- package/dist/types/component_overrides.d.ts +61 -3
- package/dist/types/cron.d.ts +11 -2
- package/dist/types/data_source.d.ts +15 -2
- package/dist/types/database_adapter.d.ts +21 -4
- package/dist/types/entities.d.ts +7 -7
- package/dist/types/entity_actions.d.ts +7 -7
- package/dist/types/entity_callbacks.d.ts +39 -39
- package/dist/types/entity_views.d.ts +3 -3
- package/dist/types/filter-operators.d.ts +62 -17
- package/dist/types/index.d.ts +1 -0
- package/dist/types/modify_collections.d.ts +2 -2
- package/dist/types/plugins.d.ts +9 -9
- package/dist/types/policy.d.ts +111 -11
- package/dist/types/properties.d.ts +54 -9
- package/dist/types/relations.d.ts +3 -3
- package/dist/types/slots.d.ts +14 -14
- package/dist/types/translations.d.ts +5 -1
- package/dist/types/user_management_delegate.d.ts +8 -2
- package/dist/types/websockets.d.ts +46 -13
- package/dist/users/user.d.ts +21 -9
- package/package.json +5 -6
- package/src/controllers/auth.tsx +7 -1
- package/src/controllers/client.ts +235 -7
- package/src/controllers/collection_registry.ts +3 -3
- package/src/controllers/customization_controller.tsx +1 -1
- package/src/controllers/data.ts +330 -39
- package/src/controllers/data_driver.ts +93 -40
- package/src/controllers/email.ts +2 -2
- package/src/controllers/index.ts +1 -1
- package/src/controllers/local_config_persistence.tsx +4 -4
- package/src/controllers/navigation.ts +2 -2
- package/src/controllers/registry.ts +22 -8
- package/src/controllers/{side_entity_controller.tsx → side_panel_controller.tsx} +7 -7
- package/src/controllers/storage.ts +60 -1
- package/src/errors.ts +80 -0
- package/src/index.ts +1 -0
- package/src/rebase_context.tsx +8 -4
- package/src/types/auth_adapter.ts +29 -4
- package/src/types/backend.ts +44 -36
- package/src/types/backup.ts +26 -0
- package/src/types/builders.ts +2 -2
- package/src/types/collections.ts +101 -91
- package/src/types/component_overrides.ts +72 -5
- package/src/types/cron.ts +11 -2
- package/src/types/data_source.ts +24 -2
- package/src/types/database_adapter.ts +19 -4
- package/src/types/entities.ts +7 -7
- package/src/types/entity_actions.tsx +7 -7
- package/src/types/entity_callbacks.ts +42 -42
- package/src/types/entity_views.tsx +3 -3
- package/src/types/filter-operators.ts +96 -23
- package/src/types/index.ts +1 -0
- package/src/types/modify_collections.tsx +2 -2
- package/src/types/plugins.tsx +9 -9
- package/src/types/policy.ts +114 -9
- package/src/types/properties.ts +58 -9
- package/src/types/relations.ts +3 -3
- package/src/types/slots.tsx +14 -14
- package/src/types/translations.ts +5 -1
- package/src/types/user_management_delegate.ts +8 -2
- package/src/types/websockets.ts +43 -14
- package/src/users/user.ts +22 -9
- package/dist/index.umd.js +0 -458
- package/dist/index.umd.js.map +0 -1
package/README.md
CHANGED
|
@@ -14,23 +14,23 @@ Provides the canonical type definitions used across all Rebase packages — both
|
|
|
14
14
|
|
|
15
15
|
## Key Exports
|
|
16
16
|
|
|
17
|
-
### Collection &
|
|
17
|
+
### Collection & Snapshot Types
|
|
18
18
|
|
|
19
19
|
| Export | Description |
|
|
20
20
|
|--------|-------------|
|
|
21
|
-
| `
|
|
21
|
+
| `CollectionConfig` | Full collection definition (name, slug, properties, callbacks, security rules, views) |
|
|
22
22
|
| `Property` | Union type for all property configurations (text, number, date, reference, array, map, etc.) |
|
|
23
|
-
| `
|
|
24
|
-
| `
|
|
25
|
-
| `
|
|
23
|
+
| `Snapshot` | Generic snapshot record type |
|
|
24
|
+
| `CollectionCallbacks` | Lifecycle hooks (`onPreSave`, `onSaveSuccess`, `onDelete`, etc.) |
|
|
25
|
+
| `SnapshotValues` | Record of property values for a snapshot |
|
|
26
26
|
| `SecurityRule` | RLS-style access control rule for a collection |
|
|
27
27
|
|
|
28
28
|
### Backend & Driver Interfaces
|
|
29
29
|
|
|
30
30
|
| Export | Description |
|
|
31
31
|
|--------|-------------|
|
|
32
|
-
| `DataDriver` | Abstract interface for database drivers (`fetchCollection`, `
|
|
33
|
-
| `DatabaseAdapter` | Pluggable database adapter interface (used by `server
|
|
32
|
+
| `DataDriver` | Abstract interface for database drivers (`fetchCollection`, `saveSnapshot`, `deleteSnapshot`, etc.) |
|
|
33
|
+
| `DatabaseAdapter` | Pluggable database adapter interface (used by `server`) |
|
|
34
34
|
| `BackendBootstrapper` | Lifecycle interface for initializing database drivers, auth, history, and realtime |
|
|
35
35
|
| `DatabaseAdmin` | Admin operations interface (SQL execution, collection stats, table metadata) |
|
|
36
36
|
| `RealtimeProvider` | Interface for realtime subscription providers |
|
|
@@ -63,7 +63,7 @@ Provides the canonical type definitions used across all Rebase packages — both
|
|
|
63
63
|
| Export | Description |
|
|
64
64
|
|--------|-------------|
|
|
65
65
|
| `CronJobDefinition` | Cron job configuration type |
|
|
66
|
-
| `
|
|
66
|
+
| `CollectionCallbacks` | Lifecycle callbacks for snapshot CRUD operations |
|
|
67
67
|
| `PluginConfig` | Plugin system types |
|
|
68
68
|
| `WebSocketMessage` | WebSocket protocol message types |
|
|
69
69
|
| `Locale` | Localization types |
|
|
@@ -72,7 +72,7 @@ Provides the canonical type definitions used across all Rebase packages — both
|
|
|
72
72
|
|
|
73
73
|
```typescript
|
|
74
74
|
import type {
|
|
75
|
-
|
|
75
|
+
CollectionConfig,
|
|
76
76
|
DataDriver,
|
|
77
77
|
DatabaseAdapter,
|
|
78
78
|
RebaseUser,
|
|
@@ -86,8 +86,8 @@ Every `@rebasepro/*` package depends on this one. Key consumers:
|
|
|
86
86
|
|
|
87
87
|
| Package | Uses |
|
|
88
88
|
|---------|------|
|
|
89
|
-
| `@rebasepro/server
|
|
90
|
-
| `@rebasepro/server-
|
|
91
|
-
| `@rebasepro/server-
|
|
89
|
+
| `@rebasepro/server` | `DataDriver`, `DatabaseAdapter`, `BackendBootstrapper`, `AuthAdapter` |
|
|
90
|
+
| `@rebasepro/server-postgres` | `BackendBootstrapper`, `InitializedDriver`, `RealtimeProvider` |
|
|
91
|
+
| `@rebasepro/server-mongo` | `BackendBootstrapper`, `DataDriver`, `CollectionConfig` |
|
|
92
92
|
| `@rebasepro/client` | `RebaseClient`, `DataSourceDelegate`, `StorageSource` |
|
|
93
|
-
| `@rebasepro/admin` | `
|
|
93
|
+
| `@rebasepro/admin` | `CollectionConfig`, `Property`, `PluginConfig`, controller interfaces |
|
|
@@ -9,7 +9,13 @@ export interface AuthCapabilities {
|
|
|
9
9
|
emailPasswordLogin?: boolean;
|
|
10
10
|
googleLogin?: boolean;
|
|
11
11
|
registration?: boolean;
|
|
12
|
+
/** Self-service password reset (emailing a reset link) is available. */
|
|
12
13
|
passwordReset?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* An admin can reset another user's password. Gates the "Reset Password"
|
|
16
|
+
* entity action in the admin UI. See `AuthAdapterCapabilities`.
|
|
17
|
+
*/
|
|
18
|
+
adminPasswordReset?: boolean;
|
|
13
19
|
sessionManagement?: boolean;
|
|
14
20
|
profileUpdate?: boolean;
|
|
15
21
|
emailVerification?: boolean;
|
|
@@ -71,7 +77,7 @@ export type AuthController<USER extends User = User, ExtraData = unknown> = {
|
|
|
71
77
|
};
|
|
72
78
|
/**
|
|
73
79
|
* Extended auth controller with common optional auth methods.
|
|
74
|
-
* Backend implementations (Rebase backend, Firebase,
|
|
80
|
+
* Backend implementations (Rebase backend, Firebase, etc.)
|
|
75
81
|
* extend this with their own backend-specific extras.
|
|
76
82
|
* @group Hooks and utilities
|
|
77
83
|
*/
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { User } from "../users";
|
|
2
|
-
import type {
|
|
2
|
+
import type { RebaseSdkData } from "./data";
|
|
3
3
|
import type { EmailService } from "./email";
|
|
4
4
|
import type { StorageSource } from "./storage";
|
|
5
5
|
import type { CronJobStatus, CronJobLogEntry } from "../types/cron";
|
|
6
|
+
import type { BackupInfo, BackupDestinationKind } from "../types/backup";
|
|
6
7
|
import type { ApiKeysAPI } from "../types/api_keys";
|
|
7
8
|
import type { StorageSourceDefinition } from "../types/storage_source";
|
|
8
9
|
/**
|
|
@@ -10,7 +11,10 @@ import type { StorageSourceDefinition } from "../types/storage_source";
|
|
|
10
11
|
*/
|
|
11
12
|
export type AuthChangeEvent = "SIGNED_IN" | "SIGNED_OUT" | "TOKEN_REFRESHED" | "USER_UPDATED";
|
|
12
13
|
/**
|
|
13
|
-
* Standard session interface representing an authenticated state
|
|
14
|
+
* Standard session interface representing an authenticated state.
|
|
15
|
+
*
|
|
16
|
+
* There is exactly one canonical definition of this type (here in
|
|
17
|
+
* `@rebasepro/types`). The `@rebasepro/client` package re-exports it.
|
|
14
18
|
*/
|
|
15
19
|
export interface RebaseSession {
|
|
16
20
|
accessToken: string;
|
|
@@ -18,6 +22,36 @@ export interface RebaseSession {
|
|
|
18
22
|
expiresAt: number;
|
|
19
23
|
user: User;
|
|
20
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Access and refresh token pair returned by authentication endpoints.
|
|
27
|
+
*
|
|
28
|
+
* Replaces the former `RebaseTokens` (client) and `AuthTokens` (auth) types,
|
|
29
|
+
* which had identical shapes.
|
|
30
|
+
*
|
|
31
|
+
* @group Auth
|
|
32
|
+
*/
|
|
33
|
+
export interface AuthTokens {
|
|
34
|
+
accessToken: string;
|
|
35
|
+
refreshToken: string;
|
|
36
|
+
/** Unix timestamp (ms) when the access token expires. */
|
|
37
|
+
accessTokenExpiresAt: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A device-level session entry as returned by `GET /auth/sessions`.
|
|
41
|
+
*
|
|
42
|
+
* Represents one refresh-token / device pair. Not to be confused with
|
|
43
|
+
* {@link RebaseSession}, which is the client-side representation of the
|
|
44
|
+
* *current* authenticated state (user + tokens).
|
|
45
|
+
*
|
|
46
|
+
* @group Auth
|
|
47
|
+
*/
|
|
48
|
+
export interface DeviceSession {
|
|
49
|
+
id: string;
|
|
50
|
+
userAgent?: string;
|
|
51
|
+
ipAddress?: string;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
isCurrentSession?: boolean;
|
|
54
|
+
}
|
|
21
55
|
/**
|
|
22
56
|
* Unified Authentication Client Interface
|
|
23
57
|
* Pure functional SDK interface, decoupled from UI and React hooks
|
|
@@ -31,6 +65,12 @@ export interface AuthClient {
|
|
|
31
65
|
* Get the currently active session
|
|
32
66
|
*/
|
|
33
67
|
getSession(): RebaseSession | null;
|
|
68
|
+
/**
|
|
69
|
+
* Get the current user's active sessions
|
|
70
|
+
*/
|
|
71
|
+
getSessions?: () => Promise<DeviceSession[]>;
|
|
72
|
+
revokeSession?: (sessionId: string) => Promise<void>;
|
|
73
|
+
revokeAllSessions?: () => Promise<void>;
|
|
34
74
|
/**
|
|
35
75
|
* Sign out the current user and clear local session
|
|
36
76
|
*/
|
|
@@ -45,7 +85,14 @@ export interface AuthClient {
|
|
|
45
85
|
refreshSession(): Promise<RebaseSession>;
|
|
46
86
|
}
|
|
47
87
|
/**
|
|
48
|
-
* User record as returned by the Admin API.
|
|
88
|
+
* User record as returned by the Admin API (`GET /admin/users`, etc.).
|
|
89
|
+
*
|
|
90
|
+
* This is a dedicated DTO for admin operations and differs from {@link User}:
|
|
91
|
+
* - `roles` is required (always an array), vs optional on `User`
|
|
92
|
+
* - Includes audit timestamps (`createdAt`, `updatedAt`) as ISO strings
|
|
93
|
+
* - `email` is non-nullable (admin users always have an email)
|
|
94
|
+
*
|
|
95
|
+
* @see User — the canonical client-facing user type
|
|
49
96
|
* @group Admin
|
|
50
97
|
*/
|
|
51
98
|
export interface AdminUser {
|
|
@@ -53,7 +100,11 @@ export interface AdminUser {
|
|
|
53
100
|
email: string;
|
|
54
101
|
displayName: string | null;
|
|
55
102
|
photoURL: string | null;
|
|
56
|
-
|
|
103
|
+
/**
|
|
104
|
+
* The provider used to authenticate the user (e.g. `"password"`,
|
|
105
|
+
* `"google"`). Named to match the canonical {@link User.providerId}.
|
|
106
|
+
*/
|
|
107
|
+
providerId: string;
|
|
57
108
|
roles: string[];
|
|
58
109
|
metadata?: Record<string, any>;
|
|
59
110
|
createdAt: string;
|
|
@@ -110,6 +161,7 @@ export interface AdminAPI {
|
|
|
110
161
|
user: AdminUser;
|
|
111
162
|
temporaryPassword?: string;
|
|
112
163
|
invitationSent?: boolean;
|
|
164
|
+
emailDeliveryFailed?: boolean;
|
|
113
165
|
}>;
|
|
114
166
|
listRoles(): Promise<{
|
|
115
167
|
roles: Array<{
|
|
@@ -150,6 +202,20 @@ export interface CronAPI {
|
|
|
150
202
|
job: CronJobStatus;
|
|
151
203
|
}>;
|
|
152
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Client-side database-backup management interface.
|
|
207
|
+
* @group Backups
|
|
208
|
+
*/
|
|
209
|
+
export interface BackupsAPI {
|
|
210
|
+
/** List available backups at the configured destination, newest first. */
|
|
211
|
+
list(): Promise<{
|
|
212
|
+
backups: BackupInfo[];
|
|
213
|
+
destinationKind: BackupDestinationKind;
|
|
214
|
+
configured: boolean;
|
|
215
|
+
}>;
|
|
216
|
+
/** Fetch a backup's bytes for download (authenticated). */
|
|
217
|
+
download(key: string): Promise<Blob>;
|
|
218
|
+
}
|
|
153
219
|
/**
|
|
154
220
|
* Options for invoking a custom backend function.
|
|
155
221
|
* @group Functions
|
|
@@ -177,6 +243,31 @@ export interface FunctionsAPI {
|
|
|
177
243
|
*/
|
|
178
244
|
invoke<T = unknown>(name: string, payload?: unknown, options?: FunctionInvokeOptions): Promise<T>;
|
|
179
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Configuration for entity history / audit-log tracking.
|
|
248
|
+
*
|
|
249
|
+
* - `true` — enable history with default settings
|
|
250
|
+
* - `{ retention?: number }` — enable with optional retention period in days
|
|
251
|
+
*/
|
|
252
|
+
export type HistoryConfig = boolean | {
|
|
253
|
+
retention?: number;
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Minimal WebSocket client contract exposed on {@link RebaseClient}.
|
|
257
|
+
*
|
|
258
|
+
* The full implementation (`RebaseWebSocketClient` in `@rebasepro/client`)
|
|
259
|
+
* adds subscription helpers, CRUD-over-WS, SQL execution, etc.
|
|
260
|
+
*/
|
|
261
|
+
export interface RebaseWebSocket {
|
|
262
|
+
/** Disconnect the WebSocket and stop reconnecting. */
|
|
263
|
+
disconnect(): void;
|
|
264
|
+
/** Send an authentication token to the server. */
|
|
265
|
+
authenticate(token: string): Promise<void>;
|
|
266
|
+
/** Set a function that lazily resolves the auth token for auto-authentication. */
|
|
267
|
+
setAuthTokenGetter(getter: () => Promise<string | null>): void;
|
|
268
|
+
/** Listen for connection lifecycle events. */
|
|
269
|
+
on(event: "connect" | "disconnect" | "reconnect" | "error", cb: (...args: unknown[]) => void): () => void;
|
|
270
|
+
}
|
|
180
271
|
/**
|
|
181
272
|
* The single, canonical Rebase client interface.
|
|
182
273
|
*
|
|
@@ -189,7 +280,24 @@ export interface FunctionsAPI {
|
|
|
189
280
|
*/
|
|
190
281
|
export interface RebaseClient<DB = unknown> {
|
|
191
282
|
/** Unified Data access layer */
|
|
192
|
-
data:
|
|
283
|
+
data: RebaseSdkData<DB>;
|
|
284
|
+
/**
|
|
285
|
+
* Admin-scoped, **RLS-bypassing** data accessor.
|
|
286
|
+
*
|
|
287
|
+
* Present on the **server** singleton only (see {@link RebaseServerClient}).
|
|
288
|
+
* It runs with `{ uid: "service", roles: ["admin"] }` — every read and write
|
|
289
|
+
* bypasses row-level-security policies. This is the correct tool for trusted
|
|
290
|
+
* background work (cron jobs, migrations, service-to-service tasks).
|
|
291
|
+
*
|
|
292
|
+
* ⚠️ **Do NOT use it to serve user-facing data.** Inside a request handler,
|
|
293
|
+
* user-scoped queries must go through the request-scoped driver
|
|
294
|
+
* (`c.var.driver`), which carries the caller's identity so RLS applies.
|
|
295
|
+
* Reaching for `dataAsAdmin` (or its alias {@link data}) in a request handler
|
|
296
|
+
* silently exposes every row to every caller.
|
|
297
|
+
*
|
|
298
|
+
* Undefined in the browser SDK.
|
|
299
|
+
*/
|
|
300
|
+
dataAsAdmin?: RebaseSdkData<DB>;
|
|
193
301
|
/** Unified Authentication layer */
|
|
194
302
|
auth: AuthClient;
|
|
195
303
|
/** Unified Storage layer (default storage source, backward-compatible) */
|
|
@@ -221,6 +329,8 @@ export interface RebaseClient<DB = unknown> {
|
|
|
221
329
|
admin?: AdminAPI;
|
|
222
330
|
/** Cron job management API */
|
|
223
331
|
cron?: CronAPI;
|
|
332
|
+
/** Database backup management API */
|
|
333
|
+
backups?: BackupsAPI;
|
|
224
334
|
/** Custom backend functions API */
|
|
225
335
|
functions?: FunctionsAPI;
|
|
226
336
|
/** Service API keys management API */
|
|
@@ -228,7 +338,7 @@ export interface RebaseClient<DB = unknown> {
|
|
|
228
338
|
/** Base HTTP URL of the backend server */
|
|
229
339
|
baseUrl?: string;
|
|
230
340
|
/** WebSocket client for realtime subscriptions */
|
|
231
|
-
ws?:
|
|
341
|
+
ws?: RebaseWebSocket;
|
|
232
342
|
/** Set the auth token for subsequent requests */
|
|
233
343
|
setToken?(token: string | null): void;
|
|
234
344
|
/** Set a function that lazily resolves the auth token */
|
|
@@ -248,6 +358,94 @@ export interface RebaseClient<DB = unknown> {
|
|
|
248
358
|
role?: string;
|
|
249
359
|
}): Promise<Record<string, unknown>[]>;
|
|
250
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* The server-side Rebase surface — the shape of the `rebase` singleton exported
|
|
363
|
+
* from `@rebasepro/server`.
|
|
364
|
+
*
|
|
365
|
+
* Narrows {@link RebaseClient} to the guarantees that always hold on the server:
|
|
366
|
+
* the admin-scoped {@link dataAsAdmin} accessor, raw {@link sql}, and the
|
|
367
|
+
* {@link email} service are all present (non-optional).
|
|
368
|
+
*
|
|
369
|
+
* **Trust levels.** Both {@link dataAsAdmin} and the deprecated {@link data}
|
|
370
|
+
* alias point at the same admin-scoped, **RLS-bypassing** driver. Prefer
|
|
371
|
+
* `dataAsAdmin` so the privilege is explicit at every call site. For user-scoped
|
|
372
|
+
* queries inside a request handler use the request-scoped driver
|
|
373
|
+
* (`c.var.driver`) instead — never `dataAsAdmin`/`data`.
|
|
374
|
+
*/
|
|
375
|
+
export interface RebaseServerClient<DB = unknown> extends RebaseClient<DB> {
|
|
376
|
+
/**
|
|
377
|
+
* @deprecated On the server, prefer {@link dataAsAdmin} for admin scope or
|
|
378
|
+
* the request-scoped driver (`c.var.driver`) for user scope. This alias
|
|
379
|
+
* points at the same admin-scoped, RLS-bypassing accessor as `dataAsAdmin`.
|
|
380
|
+
*/
|
|
381
|
+
data: RebaseSdkData<DB>;
|
|
382
|
+
/**
|
|
383
|
+
* Admin-scoped, **RLS-bypassing** data accessor. Always present server-side.
|
|
384
|
+
* See {@link RebaseClient.dataAsAdmin} for the full safety contract.
|
|
385
|
+
*/
|
|
386
|
+
dataAsAdmin: RebaseSdkData<DB>;
|
|
387
|
+
/**
|
|
388
|
+
* Server-side email service. Always present server-side (a no-op sender is
|
|
389
|
+
* wired when SMTP is not configured).
|
|
390
|
+
*/
|
|
391
|
+
email: EmailService;
|
|
392
|
+
/**
|
|
393
|
+
* Execute raw SQL against the database. Always present server-side for SQL
|
|
394
|
+
* engines.
|
|
395
|
+
*/
|
|
396
|
+
sql(query: string, options?: {
|
|
397
|
+
database?: string;
|
|
398
|
+
role?: string;
|
|
399
|
+
}): Promise<Record<string, unknown>[]>;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* The browser-side Rebase surface — the shape produced by
|
|
403
|
+
* `createRebaseClient()` in `@rebasepro/client`.
|
|
404
|
+
*
|
|
405
|
+
* Its {@link data} accessor is **user-scoped**: every call carries the signed-in
|
|
406
|
+
* user's token, so backend RLS policies apply. It deliberately omits the
|
|
407
|
+
* server-only members — there is no `sql`, no `email`, and no
|
|
408
|
+
* `dataAsAdmin`, so the RLS-bypassing accessor can never be reached from
|
|
409
|
+
* browser code.
|
|
410
|
+
*/
|
|
411
|
+
export interface RebaseBrowserClient<DB = unknown> {
|
|
412
|
+
/** User-scoped data access layer (carries the signed-in user's token). */
|
|
413
|
+
data: RebaseSdkData<DB>;
|
|
414
|
+
/** Unified Authentication layer */
|
|
415
|
+
auth: AuthClient;
|
|
416
|
+
/** Unified Storage layer (default storage source, backward-compatible) */
|
|
417
|
+
storage?: StorageSource;
|
|
418
|
+
/** Registry of all named storage sources for multi-backend support */
|
|
419
|
+
storageRegistry?: StorageSourceRegistry;
|
|
420
|
+
/** Build a server-backed {@link StorageSource} for a named storage source. */
|
|
421
|
+
createStorageSource?(storageId: string): StorageSource;
|
|
422
|
+
/** Discover the storage sources declared on the backend. */
|
|
423
|
+
fetchStorageSources?(): Promise<StorageSourceDefinition[]>;
|
|
424
|
+
/** Admin API for user management */
|
|
425
|
+
admin?: AdminAPI;
|
|
426
|
+
/** Cron job management API */
|
|
427
|
+
cron?: CronAPI;
|
|
428
|
+
/** Database backup management API */
|
|
429
|
+
backups?: BackupsAPI;
|
|
430
|
+
/** Custom backend functions API */
|
|
431
|
+
functions?: FunctionsAPI;
|
|
432
|
+
/** Service API keys management API */
|
|
433
|
+
apiKeys?: ApiKeysAPI;
|
|
434
|
+
/** Base HTTP URL of the backend server */
|
|
435
|
+
baseUrl?: string;
|
|
436
|
+
/** WebSocket client for realtime subscriptions */
|
|
437
|
+
ws?: RebaseWebSocket;
|
|
438
|
+
/** Set the auth token for subsequent requests */
|
|
439
|
+
setToken?(token: string | null): void;
|
|
440
|
+
/** Set a function that lazily resolves the auth token */
|
|
441
|
+
setAuthTokenGetter?(getter: () => Promise<string | null>): void;
|
|
442
|
+
/** Set handler called when a request returns 401 */
|
|
443
|
+
setOnUnauthorized?(handler: () => Promise<boolean>): void;
|
|
444
|
+
/** Resolve the current auth token */
|
|
445
|
+
resolveToken?(): Promise<string | null>;
|
|
446
|
+
/** Make a raw HTTP call to the backend */
|
|
447
|
+
call?<T = unknown>(endpoint: string, payload?: unknown): Promise<T>;
|
|
448
|
+
}
|
|
251
449
|
/**
|
|
252
450
|
* Client-side registry for managing multiple storage sources.
|
|
253
451
|
*
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CollectionConfig } from "../types/collections";
|
|
2
2
|
import type { EntityReference } from "../types/entities";
|
|
3
3
|
/**
|
|
4
4
|
* Controller that provides access to the registered entity collections.
|
|
5
5
|
* @group Models
|
|
6
6
|
*/
|
|
7
|
-
export type CollectionRegistryController<DB = Record<string, unknown>, EC extends
|
|
7
|
+
export type CollectionRegistryController<DB = Record<string, unknown>, EC extends CollectionConfig = CollectionConfig> = {
|
|
8
8
|
/**
|
|
9
9
|
* List of the mapped collections in the CMS.
|
|
10
10
|
* Each entry relates to a collection in the root database.
|
|
11
11
|
* Each of the navigation entries in this field
|
|
12
12
|
* generates an entry in the main menu.
|
|
13
13
|
*/
|
|
14
|
-
collections?:
|
|
14
|
+
collections?: CollectionConfig[];
|
|
15
15
|
/**
|
|
16
16
|
* Is the registry ready to be used
|
|
17
17
|
*/
|
|
@@ -24,7 +24,7 @@ export type CustomizationController = {
|
|
|
24
24
|
* You can use the key to reference the custom view in
|
|
25
25
|
* the `entityViews` prop of a collection.
|
|
26
26
|
*
|
|
27
|
-
* You can also define
|
|
27
|
+
* You can also define a entity view from the UI.
|
|
28
28
|
*/
|
|
29
29
|
entityViews?: EntityCustomView[];
|
|
30
30
|
/**
|