@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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/types",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.9.1-canary.09aaf62",
|
|
5
5
|
"description": "Rebase type definitions — shared interfaces and controller types",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/rebaseco"
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"url": "https://github.com/rebasepro/rebase.git",
|
|
14
14
|
"directory": "packages/types"
|
|
15
15
|
},
|
|
16
|
-
"main": "./dist/index.
|
|
16
|
+
"main": "./dist/index.es.js",
|
|
17
17
|
"module": "./dist/index.es.js",
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"source": "src/index.ts",
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">=20"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [
|
|
24
24
|
"rebase",
|
|
@@ -33,8 +33,7 @@
|
|
|
33
33
|
".": {
|
|
34
34
|
"types": "./dist/index.d.ts",
|
|
35
35
|
"development": "./dist/index.es.js",
|
|
36
|
-
"import": "./dist/index.es.js"
|
|
37
|
-
"require": "./dist/index.umd.js"
|
|
36
|
+
"import": "./dist/index.es.js"
|
|
38
37
|
},
|
|
39
38
|
"./package.json": "./package.json"
|
|
40
39
|
},
|
|
@@ -92,7 +91,7 @@
|
|
|
92
91
|
},
|
|
93
92
|
"scripts": {
|
|
94
93
|
"watch": "vite build --watch",
|
|
95
|
-
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
|
|
94
|
+
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json && node ../../scripts/assert-build-output.mjs",
|
|
96
95
|
"test:lint": "eslint \"src/**\" --quiet",
|
|
97
96
|
"test": "jest --passWithNoTests",
|
|
98
97
|
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f"
|
package/src/controllers/auth.tsx
CHANGED
|
@@ -10,7 +10,13 @@ export interface AuthCapabilities {
|
|
|
10
10
|
emailPasswordLogin?: boolean;
|
|
11
11
|
googleLogin?: boolean;
|
|
12
12
|
registration?: boolean;
|
|
13
|
+
/** Self-service password reset (emailing a reset link) is available. */
|
|
13
14
|
passwordReset?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* An admin can reset another user's password. Gates the "Reset Password"
|
|
17
|
+
* entity action in the admin UI. See `AuthAdapterCapabilities`.
|
|
18
|
+
*/
|
|
19
|
+
adminPasswordReset?: boolean;
|
|
14
20
|
sessionManagement?: boolean;
|
|
15
21
|
profileUpdate?: boolean;
|
|
16
22
|
emailVerification?: boolean;
|
|
@@ -89,7 +95,7 @@ export type AuthController<USER extends User = User, ExtraData = unknown> = {
|
|
|
89
95
|
|
|
90
96
|
/**
|
|
91
97
|
* Extended auth controller with common optional auth methods.
|
|
92
|
-
* Backend implementations (Rebase backend, Firebase,
|
|
98
|
+
* Backend implementations (Rebase backend, Firebase, etc.)
|
|
93
99
|
* extend this with their own backend-specific extras.
|
|
94
100
|
* @group Hooks and utilities
|
|
95
101
|
*/
|
|
@@ -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
|
|
|
@@ -13,7 +14,10 @@ import type { StorageSourceDefinition } from "../types/storage_source";
|
|
|
13
14
|
export type AuthChangeEvent = "SIGNED_IN" | "SIGNED_OUT" | "TOKEN_REFRESHED" | "USER_UPDATED";
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
* Standard session interface representing an authenticated state
|
|
17
|
+
* Standard session interface representing an authenticated state.
|
|
18
|
+
*
|
|
19
|
+
* There is exactly one canonical definition of this type (here in
|
|
20
|
+
* `@rebasepro/types`). The `@rebasepro/client` package re-exports it.
|
|
17
21
|
*/
|
|
18
22
|
export interface RebaseSession {
|
|
19
23
|
accessToken: string;
|
|
@@ -22,6 +26,38 @@ export interface RebaseSession {
|
|
|
22
26
|
user: User;
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Access and refresh token pair returned by authentication endpoints.
|
|
31
|
+
*
|
|
32
|
+
* Replaces the former `RebaseTokens` (client) and `AuthTokens` (auth) types,
|
|
33
|
+
* which had identical shapes.
|
|
34
|
+
*
|
|
35
|
+
* @group Auth
|
|
36
|
+
*/
|
|
37
|
+
export interface AuthTokens {
|
|
38
|
+
accessToken: string;
|
|
39
|
+
refreshToken: string;
|
|
40
|
+
/** Unix timestamp (ms) when the access token expires. */
|
|
41
|
+
accessTokenExpiresAt: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A device-level session entry as returned by `GET /auth/sessions`.
|
|
46
|
+
*
|
|
47
|
+
* Represents one refresh-token / device pair. Not to be confused with
|
|
48
|
+
* {@link RebaseSession}, which is the client-side representation of the
|
|
49
|
+
* *current* authenticated state (user + tokens).
|
|
50
|
+
*
|
|
51
|
+
* @group Auth
|
|
52
|
+
*/
|
|
53
|
+
export interface DeviceSession {
|
|
54
|
+
id: string;
|
|
55
|
+
userAgent?: string;
|
|
56
|
+
ipAddress?: string;
|
|
57
|
+
createdAt: string;
|
|
58
|
+
isCurrentSession?: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
25
61
|
/**
|
|
26
62
|
* Unified Authentication Client Interface
|
|
27
63
|
* Pure functional SDK interface, decoupled from UI and React hooks
|
|
@@ -37,6 +73,13 @@ export interface AuthClient {
|
|
|
37
73
|
*/
|
|
38
74
|
getSession(): RebaseSession | null;
|
|
39
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Get the current user's active sessions
|
|
78
|
+
*/
|
|
79
|
+
getSessions?: () => Promise<DeviceSession[]>;
|
|
80
|
+
revokeSession?: (sessionId: string) => Promise<void>;
|
|
81
|
+
revokeAllSessions?: () => Promise<void>;
|
|
82
|
+
|
|
40
83
|
/**
|
|
41
84
|
* Sign out the current user and clear local session
|
|
42
85
|
*/
|
|
@@ -56,7 +99,14 @@ export interface AuthClient {
|
|
|
56
99
|
// ─── Admin API ───────────────────────────────────────────────────────────────
|
|
57
100
|
|
|
58
101
|
/**
|
|
59
|
-
* User record as returned by the Admin API.
|
|
102
|
+
* User record as returned by the Admin API (`GET /admin/users`, etc.).
|
|
103
|
+
*
|
|
104
|
+
* This is a dedicated DTO for admin operations and differs from {@link User}:
|
|
105
|
+
* - `roles` is required (always an array), vs optional on `User`
|
|
106
|
+
* - Includes audit timestamps (`createdAt`, `updatedAt`) as ISO strings
|
|
107
|
+
* - `email` is non-nullable (admin users always have an email)
|
|
108
|
+
*
|
|
109
|
+
* @see User — the canonical client-facing user type
|
|
60
110
|
* @group Admin
|
|
61
111
|
*/
|
|
62
112
|
export interface AdminUser {
|
|
@@ -64,7 +114,11 @@ export interface AdminUser {
|
|
|
64
114
|
email: string;
|
|
65
115
|
displayName: string | null;
|
|
66
116
|
photoURL: string | null;
|
|
67
|
-
|
|
117
|
+
/**
|
|
118
|
+
* The provider used to authenticate the user (e.g. `"password"`,
|
|
119
|
+
* `"google"`). Named to match the canonical {@link User.providerId}.
|
|
120
|
+
*/
|
|
121
|
+
providerId: string;
|
|
68
122
|
roles: string[];
|
|
69
123
|
metadata?: Record<string, any>;
|
|
70
124
|
createdAt: string;
|
|
@@ -89,7 +143,7 @@ export interface AdminAPI {
|
|
|
89
143
|
createUser(data: { email: string; displayName?: string; password?: string; roles?: string[]; metadata?: Record<string, any> }): Promise<{ user: AdminUser }>;
|
|
90
144
|
updateUser(userId: string, data: { email?: string; displayName?: string; password?: string; roles?: string[]; metadata?: Record<string, any> }): Promise<{ user: AdminUser }>;
|
|
91
145
|
deleteUser(userId: string): Promise<{ success: boolean }>;
|
|
92
|
-
resetPassword(userId: string, options?: { password?: string }): Promise<{ user: AdminUser; temporaryPassword?: string; invitationSent?: boolean }>;
|
|
146
|
+
resetPassword(userId: string, options?: { password?: string }): Promise<{ user: AdminUser; temporaryPassword?: string; invitationSent?: boolean; emailDeliveryFailed?: boolean }>;
|
|
93
147
|
listRoles(): Promise<{ roles: Array<{ id: string; name: string }> }>;
|
|
94
148
|
bootstrap(): Promise<{ success: boolean; message: string; user: { uid: string; roles: string[] } }>;
|
|
95
149
|
}
|
|
@@ -108,6 +162,19 @@ export interface CronAPI {
|
|
|
108
162
|
toggleJob(jobId: string, enabled: boolean): Promise<{ job: CronJobStatus }>;
|
|
109
163
|
}
|
|
110
164
|
|
|
165
|
+
// ─── Backups API ─────────────────────────────────────────────────────────────
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Client-side database-backup management interface.
|
|
169
|
+
* @group Backups
|
|
170
|
+
*/
|
|
171
|
+
export interface BackupsAPI {
|
|
172
|
+
/** List available backups at the configured destination, newest first. */
|
|
173
|
+
list(): Promise<{ backups: BackupInfo[]; destinationKind: BackupDestinationKind; configured: boolean }>;
|
|
174
|
+
/** Fetch a backup's bytes for download (authenticated). */
|
|
175
|
+
download(key: string): Promise<Blob>;
|
|
176
|
+
}
|
|
177
|
+
|
|
111
178
|
// ─── Functions API ───────────────────────────────────────────────────────────
|
|
112
179
|
|
|
113
180
|
/**
|
|
@@ -139,6 +206,35 @@ export interface FunctionsAPI {
|
|
|
139
206
|
invoke<T = unknown>(name: string, payload?: unknown, options?: FunctionInvokeOptions): Promise<T>;
|
|
140
207
|
}
|
|
141
208
|
|
|
209
|
+
// ─── HistoryConfig ───────────────────────────────────────────────────────────
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Configuration for entity history / audit-log tracking.
|
|
213
|
+
*
|
|
214
|
+
* - `true` — enable history with default settings
|
|
215
|
+
* - `{ retention?: number }` — enable with optional retention period in days
|
|
216
|
+
*/
|
|
217
|
+
export type HistoryConfig = boolean | { retention?: number };
|
|
218
|
+
|
|
219
|
+
// ─── RebaseWebSocket ─────────────────────────────────────────────────────────
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Minimal WebSocket client contract exposed on {@link RebaseClient}.
|
|
223
|
+
*
|
|
224
|
+
* The full implementation (`RebaseWebSocketClient` in `@rebasepro/client`)
|
|
225
|
+
* adds subscription helpers, CRUD-over-WS, SQL execution, etc.
|
|
226
|
+
*/
|
|
227
|
+
export interface RebaseWebSocket {
|
|
228
|
+
/** Disconnect the WebSocket and stop reconnecting. */
|
|
229
|
+
disconnect(): void;
|
|
230
|
+
/** Send an authentication token to the server. */
|
|
231
|
+
authenticate(token: string): Promise<void>;
|
|
232
|
+
/** Set a function that lazily resolves the auth token for auto-authentication. */
|
|
233
|
+
setAuthTokenGetter(getter: () => Promise<string | null>): void;
|
|
234
|
+
/** Listen for connection lifecycle events. */
|
|
235
|
+
on(event: "connect" | "disconnect" | "reconnect" | "error", cb: (...args: unknown[]) => void): () => void;
|
|
236
|
+
}
|
|
237
|
+
|
|
142
238
|
// ─── RebaseClient ────────────────────────────────────────────────────────────
|
|
143
239
|
|
|
144
240
|
/**
|
|
@@ -153,7 +249,25 @@ export interface FunctionsAPI {
|
|
|
153
249
|
*/
|
|
154
250
|
export interface RebaseClient<DB = unknown> {
|
|
155
251
|
/** Unified Data access layer */
|
|
156
|
-
data:
|
|
252
|
+
data: RebaseSdkData<DB>;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Admin-scoped, **RLS-bypassing** data accessor.
|
|
256
|
+
*
|
|
257
|
+
* Present on the **server** singleton only (see {@link RebaseServerClient}).
|
|
258
|
+
* It runs with `{ uid: "service", roles: ["admin"] }` — every read and write
|
|
259
|
+
* bypasses row-level-security policies. This is the correct tool for trusted
|
|
260
|
+
* background work (cron jobs, migrations, service-to-service tasks).
|
|
261
|
+
*
|
|
262
|
+
* ⚠️ **Do NOT use it to serve user-facing data.** Inside a request handler,
|
|
263
|
+
* user-scoped queries must go through the request-scoped driver
|
|
264
|
+
* (`c.var.driver`), which carries the caller's identity so RLS applies.
|
|
265
|
+
* Reaching for `dataAsAdmin` (or its alias {@link data}) in a request handler
|
|
266
|
+
* silently exposes every row to every caller.
|
|
267
|
+
*
|
|
268
|
+
* Undefined in the browser SDK.
|
|
269
|
+
*/
|
|
270
|
+
dataAsAdmin?: RebaseSdkData<DB>;
|
|
157
271
|
|
|
158
272
|
/** Unified Authentication layer */
|
|
159
273
|
auth: AuthClient;
|
|
@@ -194,6 +308,9 @@ export interface RebaseClient<DB = unknown> {
|
|
|
194
308
|
/** Cron job management API */
|
|
195
309
|
cron?: CronAPI;
|
|
196
310
|
|
|
311
|
+
/** Database backup management API */
|
|
312
|
+
backups?: BackupsAPI;
|
|
313
|
+
|
|
197
314
|
/** Custom backend functions API */
|
|
198
315
|
functions?: FunctionsAPI;
|
|
199
316
|
|
|
@@ -205,7 +322,7 @@ export interface RebaseClient<DB = unknown> {
|
|
|
205
322
|
baseUrl?: string;
|
|
206
323
|
|
|
207
324
|
/** WebSocket client for realtime subscriptions */
|
|
208
|
-
ws?:
|
|
325
|
+
ws?: RebaseWebSocket;
|
|
209
326
|
|
|
210
327
|
/** Set the auth token for subsequent requests */
|
|
211
328
|
setToken?(token: string | null): void;
|
|
@@ -229,6 +346,117 @@ export interface RebaseClient<DB = unknown> {
|
|
|
229
346
|
sql?(query: string, options?: { database?: string; role?: string }): Promise<Record<string, unknown>[]>;
|
|
230
347
|
}
|
|
231
348
|
|
|
349
|
+
// ─── RebaseServerClient ──────────────────────────────────────────────────────
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* The server-side Rebase surface — the shape of the `rebase` singleton exported
|
|
353
|
+
* from `@rebasepro/server`.
|
|
354
|
+
*
|
|
355
|
+
* Narrows {@link RebaseClient} to the guarantees that always hold on the server:
|
|
356
|
+
* the admin-scoped {@link dataAsAdmin} accessor, raw {@link sql}, and the
|
|
357
|
+
* {@link email} service are all present (non-optional).
|
|
358
|
+
*
|
|
359
|
+
* **Trust levels.** Both {@link dataAsAdmin} and the deprecated {@link data}
|
|
360
|
+
* alias point at the same admin-scoped, **RLS-bypassing** driver. Prefer
|
|
361
|
+
* `dataAsAdmin` so the privilege is explicit at every call site. For user-scoped
|
|
362
|
+
* queries inside a request handler use the request-scoped driver
|
|
363
|
+
* (`c.var.driver`) instead — never `dataAsAdmin`/`data`.
|
|
364
|
+
*/
|
|
365
|
+
export interface RebaseServerClient<DB = unknown> extends RebaseClient<DB> {
|
|
366
|
+
/**
|
|
367
|
+
* @deprecated On the server, prefer {@link dataAsAdmin} for admin scope or
|
|
368
|
+
* the request-scoped driver (`c.var.driver`) for user scope. This alias
|
|
369
|
+
* points at the same admin-scoped, RLS-bypassing accessor as `dataAsAdmin`.
|
|
370
|
+
*/
|
|
371
|
+
data: RebaseSdkData<DB>;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Admin-scoped, **RLS-bypassing** data accessor. Always present server-side.
|
|
375
|
+
* See {@link RebaseClient.dataAsAdmin} for the full safety contract.
|
|
376
|
+
*/
|
|
377
|
+
dataAsAdmin: RebaseSdkData<DB>;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Server-side email service. Always present server-side (a no-op sender is
|
|
381
|
+
* wired when SMTP is not configured).
|
|
382
|
+
*/
|
|
383
|
+
email: EmailService;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Execute raw SQL against the database. Always present server-side for SQL
|
|
387
|
+
* engines.
|
|
388
|
+
*/
|
|
389
|
+
sql(query: string, options?: { database?: string; role?: string }): Promise<Record<string, unknown>[]>;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// ─── RebaseBrowserClient ─────────────────────────────────────────────────────
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* The browser-side Rebase surface — the shape produced by
|
|
396
|
+
* `createRebaseClient()` in `@rebasepro/client`.
|
|
397
|
+
*
|
|
398
|
+
* Its {@link data} accessor is **user-scoped**: every call carries the signed-in
|
|
399
|
+
* user's token, so backend RLS policies apply. It deliberately omits the
|
|
400
|
+
* server-only members — there is no `sql`, no `email`, and no
|
|
401
|
+
* `dataAsAdmin`, so the RLS-bypassing accessor can never be reached from
|
|
402
|
+
* browser code.
|
|
403
|
+
*/
|
|
404
|
+
export interface RebaseBrowserClient<DB = unknown> {
|
|
405
|
+
/** User-scoped data access layer (carries the signed-in user's token). */
|
|
406
|
+
data: RebaseSdkData<DB>;
|
|
407
|
+
|
|
408
|
+
/** Unified Authentication layer */
|
|
409
|
+
auth: AuthClient;
|
|
410
|
+
|
|
411
|
+
/** Unified Storage layer (default storage source, backward-compatible) */
|
|
412
|
+
storage?: StorageSource;
|
|
413
|
+
|
|
414
|
+
/** Registry of all named storage sources for multi-backend support */
|
|
415
|
+
storageRegistry?: StorageSourceRegistry;
|
|
416
|
+
|
|
417
|
+
/** Build a server-backed {@link StorageSource} for a named storage source. */
|
|
418
|
+
createStorageSource?(storageId: string): StorageSource;
|
|
419
|
+
|
|
420
|
+
/** Discover the storage sources declared on the backend. */
|
|
421
|
+
fetchStorageSources?(): Promise<StorageSourceDefinition[]>;
|
|
422
|
+
|
|
423
|
+
/** Admin API for user management */
|
|
424
|
+
admin?: AdminAPI;
|
|
425
|
+
|
|
426
|
+
/** Cron job management API */
|
|
427
|
+
cron?: CronAPI;
|
|
428
|
+
|
|
429
|
+
/** Database backup management API */
|
|
430
|
+
backups?: BackupsAPI;
|
|
431
|
+
|
|
432
|
+
/** Custom backend functions API */
|
|
433
|
+
functions?: FunctionsAPI;
|
|
434
|
+
|
|
435
|
+
/** Service API keys management API */
|
|
436
|
+
apiKeys?: ApiKeysAPI;
|
|
437
|
+
|
|
438
|
+
/** Base HTTP URL of the backend server */
|
|
439
|
+
baseUrl?: string;
|
|
440
|
+
|
|
441
|
+
/** WebSocket client for realtime subscriptions */
|
|
442
|
+
ws?: RebaseWebSocket;
|
|
443
|
+
|
|
444
|
+
/** Set the auth token for subsequent requests */
|
|
445
|
+
setToken?(token: string | null): void;
|
|
446
|
+
|
|
447
|
+
/** Set a function that lazily resolves the auth token */
|
|
448
|
+
setAuthTokenGetter?(getter: () => Promise<string | null>): void;
|
|
449
|
+
|
|
450
|
+
/** Set handler called when a request returns 401 */
|
|
451
|
+
setOnUnauthorized?(handler: () => Promise<boolean>): void;
|
|
452
|
+
|
|
453
|
+
/** Resolve the current auth token */
|
|
454
|
+
resolveToken?(): Promise<string | null>;
|
|
455
|
+
|
|
456
|
+
/** Make a raw HTTP call to the backend */
|
|
457
|
+
call?<T = unknown>(endpoint: string, payload?: unknown): Promise<T>;
|
|
458
|
+
}
|
|
459
|
+
|
|
232
460
|
/**
|
|
233
461
|
* Client-side registry for managing multiple storage sources.
|
|
234
462
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CollectionConfig } from "../types/collections";
|
|
2
2
|
import type { EntityReference } from "../types/entities";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -7,7 +7,7 @@ import type { EntityReference } from "../types/entities";
|
|
|
7
7
|
*/
|
|
8
8
|
export type CollectionRegistryController<
|
|
9
9
|
DB = Record<string, unknown>,
|
|
10
|
-
EC extends
|
|
10
|
+
EC extends CollectionConfig = CollectionConfig
|
|
11
11
|
> = {
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -16,7 +16,7 @@ export type CollectionRegistryController<
|
|
|
16
16
|
* Each of the navigation entries in this field
|
|
17
17
|
* generates an entry in the main menu.
|
|
18
18
|
*/
|
|
19
|
-
collections?:
|
|
19
|
+
collections?: CollectionConfig[];
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Is the registry ready to be used
|
|
@@ -30,7 +30,7 @@ export type CustomizationController = {
|
|
|
30
30
|
* You can use the key to reference the custom view in
|
|
31
31
|
* the `entityViews` prop of a collection.
|
|
32
32
|
*
|
|
33
|
-
* You can also define
|
|
33
|
+
* You can also define a entity view from the UI.
|
|
34
34
|
*/
|
|
35
35
|
entityViews?: EntityCustomView[];
|
|
36
36
|
|