@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
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @example Custom auth
|
|
19
19
|
* ```ts
|
|
20
|
-
* import { createCustomAuthAdapter } from "@rebasepro/server
|
|
20
|
+
* import { createCustomAuthAdapter } from "@rebasepro/server";
|
|
21
21
|
*
|
|
22
22
|
* initializeRebaseBackend({
|
|
23
23
|
* auth: createCustomAuthAdapter({
|
|
@@ -85,8 +85,25 @@ export interface AuthAdapterCapabilities {
|
|
|
85
85
|
emailPasswordLogin: boolean;
|
|
86
86
|
/** Supports new user registration. */
|
|
87
87
|
registration: boolean;
|
|
88
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Supports the end-user password reset flow (emailing a reset link).
|
|
90
|
+
*
|
|
91
|
+
* This is about *self-service* reset, so it is typically tied to whether an
|
|
92
|
+
* email service is configured. It says nothing about whether an admin can
|
|
93
|
+
* reset someone else's password — see `adminPasswordReset`.
|
|
94
|
+
*/
|
|
89
95
|
passwordReset: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Whether the adapter exposes `POST /admin/users/:userId/reset-password`,
|
|
98
|
+
* letting an admin reset another user's password.
|
|
99
|
+
*
|
|
100
|
+
* Independent of `passwordReset`: the built-in adapter supports this even
|
|
101
|
+
* with no email service configured (it returns a one-time temporary
|
|
102
|
+
* password instead of sending a link). Adapters that mount their own admin
|
|
103
|
+
* routes must set this to `true` only once that route actually exists —
|
|
104
|
+
* the admin UI hides the "Reset Password" action when it is `false`.
|
|
105
|
+
*/
|
|
106
|
+
adminPasswordReset: boolean;
|
|
90
107
|
/** Supports session listing/revocation. */
|
|
91
108
|
sessionManagement: boolean;
|
|
92
109
|
/** Supports profile updates (display name, photo). */
|
|
@@ -218,6 +235,11 @@ export interface UserCreationFinalizeResult {
|
|
|
218
235
|
temporaryPassword?: string;
|
|
219
236
|
/** Whether an invitation email was sent. */
|
|
220
237
|
invitationSent: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Whether an email service was configured but delivery failed, causing the
|
|
240
|
+
* fallback to `temporaryPassword`. Absent when no email service is configured.
|
|
241
|
+
*/
|
|
242
|
+
emailDeliveryFailed?: boolean;
|
|
221
243
|
}
|
|
222
244
|
|
|
223
245
|
// ─── Auth Response Transform ─────────────────────────────────────────────────
|
|
@@ -237,6 +259,9 @@ export interface AuthResponsePayload {
|
|
|
237
259
|
email: string;
|
|
238
260
|
displayName: string | null;
|
|
239
261
|
photoURL: string | null;
|
|
262
|
+
providerId?: string;
|
|
263
|
+
isAnonymous?: boolean;
|
|
264
|
+
emailVerified?: boolean;
|
|
240
265
|
roles: string[];
|
|
241
266
|
metadata: Record<string, unknown>;
|
|
242
267
|
};
|
|
@@ -295,7 +320,7 @@ export interface AuthAdapter {
|
|
|
295
320
|
/**
|
|
296
321
|
* Verify an incoming request and extract the authenticated user.
|
|
297
322
|
*
|
|
298
|
-
* This replaces the hardcoded JWT verification in server
|
|
323
|
+
* This replaces the hardcoded JWT verification in server's middleware.
|
|
299
324
|
* Each adapter implements its own token verification strategy:
|
|
300
325
|
* - Built-in: verify Rebase JWT
|
|
301
326
|
* - Clerk: call Clerk's `verifyToken()`
|
|
@@ -393,7 +418,7 @@ export interface AuthAdapter {
|
|
|
393
418
|
*
|
|
394
419
|
* @param values - Raw request body from the client.
|
|
395
420
|
* @param collectionAuth - The parsed `AuthCollectionConfig` from the collection (if `auth` is an object).
|
|
396
|
-
* @returns Processed values ready for `driver.
|
|
421
|
+
* @returns Processed values ready for `driver.save()`, plus metadata for the post-save step.
|
|
397
422
|
*/
|
|
398
423
|
prepareUserCreation?(
|
|
399
424
|
values: Record<string, unknown>,
|
package/src/types/backend.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { EntityCollection, FilterValues, WhereFilterOp } from "./collections";
|
|
1
|
+
import type { CollectionConfig, FilterValues, WhereFilterOp } from "./collections";
|
|
3
2
|
import type { AuthAdapter } from "./auth_adapter";
|
|
3
|
+
import type { HistoryConfig } from "../controllers/client";
|
|
4
4
|
|
|
5
5
|
// =============================================================================
|
|
6
6
|
// DATABASE CONNECTION INTERFACES
|
|
@@ -52,7 +52,7 @@ export interface FetchCollectionOptions<M extends Record<string, unknown> = Reco
|
|
|
52
52
|
startAfter?: unknown;
|
|
53
53
|
searchString?: string;
|
|
54
54
|
databaseId?: string;
|
|
55
|
-
collection?:
|
|
55
|
+
collection?: CollectionConfig;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -64,7 +64,7 @@ export interface SearchOptions<M extends Record<string, unknown> = Record<string
|
|
|
64
64
|
order?: "desc" | "asc";
|
|
65
65
|
limit?: number;
|
|
66
66
|
databaseId?: string;
|
|
67
|
-
collection?:
|
|
67
|
+
collection?: CollectionConfig;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -150,15 +150,15 @@ export type ConditionBuilderStatic<T = unknown> = {
|
|
|
150
150
|
* - Relation resolution
|
|
151
151
|
* - ID generation and conversion
|
|
152
152
|
*/
|
|
153
|
-
export interface
|
|
153
|
+
export interface DataRepository {
|
|
154
154
|
/**
|
|
155
155
|
* Fetch a single entity by ID
|
|
156
156
|
*/
|
|
157
|
-
|
|
157
|
+
fetchOne<M extends Record<string, unknown>>(
|
|
158
158
|
collectionPath: string,
|
|
159
|
-
|
|
159
|
+
id: string | number,
|
|
160
160
|
databaseId?: string
|
|
161
|
-
): Promise<
|
|
161
|
+
): Promise<Record<string, unknown> | undefined>;
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
164
|
* Fetch a collection of entities with optional filtering, ordering, and pagination
|
|
@@ -166,41 +166,41 @@ export interface EntityRepository {
|
|
|
166
166
|
fetchCollection<M extends Record<string, unknown>>(
|
|
167
167
|
collectionPath: string,
|
|
168
168
|
options?: FetchCollectionOptions<M>
|
|
169
|
-
): Promise<
|
|
169
|
+
): Promise<Record<string, unknown>[]>;
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
172
|
* Search entities by text
|
|
173
173
|
*/
|
|
174
|
-
|
|
174
|
+
searchRows<M extends Record<string, unknown>>(
|
|
175
175
|
collectionPath: string,
|
|
176
176
|
searchString: string,
|
|
177
177
|
options?: SearchOptions<M>
|
|
178
|
-
): Promise<
|
|
178
|
+
): Promise<Record<string, unknown>[]>;
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
181
|
* Count entities in a collection
|
|
182
182
|
*/
|
|
183
|
-
|
|
183
|
+
count<M extends Record<string, unknown>>(
|
|
184
184
|
collectionPath: string,
|
|
185
185
|
options?: CountOptions<M>
|
|
186
186
|
): Promise<number>;
|
|
187
187
|
|
|
188
188
|
/**
|
|
189
|
-
* Save
|
|
189
|
+
* Save a entity (create or update)
|
|
190
190
|
*/
|
|
191
|
-
|
|
191
|
+
save<M extends Record<string, unknown>>(
|
|
192
192
|
collectionPath: string,
|
|
193
193
|
values: Partial<M>,
|
|
194
|
-
|
|
194
|
+
id?: string | number,
|
|
195
195
|
databaseId?: string
|
|
196
|
-
): Promise<
|
|
196
|
+
): Promise<Record<string, unknown>>;
|
|
197
197
|
|
|
198
198
|
/**
|
|
199
|
-
* Delete
|
|
199
|
+
* Delete a entity by ID
|
|
200
200
|
*/
|
|
201
|
-
|
|
201
|
+
delete(
|
|
202
202
|
collectionPath: string,
|
|
203
|
-
|
|
203
|
+
id: string | number,
|
|
204
204
|
databaseId?: string
|
|
205
205
|
): Promise<void>;
|
|
206
206
|
|
|
@@ -239,10 +239,10 @@ export interface CollectionSubscriptionConfig {
|
|
|
239
239
|
/**
|
|
240
240
|
* Configuration for subscribing to a single entity
|
|
241
241
|
*/
|
|
242
|
-
export interface
|
|
242
|
+
export interface SingleSubscriptionConfig {
|
|
243
243
|
clientId: string;
|
|
244
244
|
path: string;
|
|
245
|
-
|
|
245
|
+
id: string | number;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
/**
|
|
@@ -256,16 +256,16 @@ export interface RealtimeProvider {
|
|
|
256
256
|
subscribeToCollection(
|
|
257
257
|
subscriptionId: string,
|
|
258
258
|
config: CollectionSubscriptionConfig,
|
|
259
|
-
callback?: (
|
|
259
|
+
callback?: (rows: Record<string, unknown>[]) => void
|
|
260
260
|
): void;
|
|
261
261
|
|
|
262
262
|
/**
|
|
263
263
|
* Subscribe to single entity changes
|
|
264
264
|
*/
|
|
265
|
-
|
|
265
|
+
subscribeToOne(
|
|
266
266
|
subscriptionId: string,
|
|
267
|
-
config:
|
|
268
|
-
callback?: (
|
|
267
|
+
config: SingleSubscriptionConfig,
|
|
268
|
+
callback?: (row: Record<string, unknown> | null) => void
|
|
269
269
|
): void;
|
|
270
270
|
|
|
271
271
|
/**
|
|
@@ -274,12 +274,12 @@ export interface RealtimeProvider {
|
|
|
274
274
|
unsubscribe(subscriptionId: string): void;
|
|
275
275
|
|
|
276
276
|
/**
|
|
277
|
-
* Notify all relevant subscribers of
|
|
277
|
+
* Notify all relevant subscribers of a entity update
|
|
278
278
|
*/
|
|
279
|
-
|
|
279
|
+
notifyUpdate(
|
|
280
280
|
path: string,
|
|
281
|
-
|
|
282
|
-
|
|
281
|
+
id: string,
|
|
282
|
+
row: Record<string, unknown> | null,
|
|
283
283
|
databaseId?: string
|
|
284
284
|
): Promise<void>;
|
|
285
285
|
|
|
@@ -314,17 +314,17 @@ export interface CollectionRegistryInterface {
|
|
|
314
314
|
/**
|
|
315
315
|
* Register a collection
|
|
316
316
|
*/
|
|
317
|
-
register(collection:
|
|
317
|
+
register(collection: CollectionConfig): void;
|
|
318
318
|
|
|
319
319
|
/**
|
|
320
320
|
* Get a collection by its path
|
|
321
321
|
*/
|
|
322
|
-
getCollectionByPath(path: string):
|
|
322
|
+
getCollectionByPath(path: string): CollectionConfig | undefined;
|
|
323
323
|
|
|
324
324
|
/**
|
|
325
325
|
* Get all registered collections
|
|
326
326
|
*/
|
|
327
|
-
getCollections():
|
|
327
|
+
getCollections(): CollectionConfig[];
|
|
328
328
|
|
|
329
329
|
/**
|
|
330
330
|
* Get the currently registered global callbacks, if any.
|
|
@@ -346,7 +346,7 @@ export interface DataTransformer {
|
|
|
346
346
|
*/
|
|
347
347
|
serializeToDatabase<M extends Record<string, unknown>>(
|
|
348
348
|
entity: M,
|
|
349
|
-
collection:
|
|
349
|
+
collection: CollectionConfig
|
|
350
350
|
): Record<string, unknown>;
|
|
351
351
|
|
|
352
352
|
/**
|
|
@@ -354,7 +354,7 @@ export interface DataTransformer {
|
|
|
354
354
|
*/
|
|
355
355
|
deserializeFromDatabase<M extends Record<string, unknown>>(
|
|
356
356
|
data: Record<string, unknown>,
|
|
357
|
-
collection:
|
|
357
|
+
collection: CollectionConfig
|
|
358
358
|
): Promise<M>;
|
|
359
359
|
}
|
|
360
360
|
|
|
@@ -589,7 +589,7 @@ export interface BackendInstance extends BackendLifecycle {
|
|
|
589
589
|
/**
|
|
590
590
|
* Entity repository for CRUD operations
|
|
591
591
|
*/
|
|
592
|
-
entityRepository:
|
|
592
|
+
entityRepository: DataRepository;
|
|
593
593
|
|
|
594
594
|
/**
|
|
595
595
|
* Realtime provider for subscriptions
|
|
@@ -697,7 +697,7 @@ export interface BackendBootstrapper {
|
|
|
697
697
|
* Initialize history tables / services if this driver supports them.
|
|
698
698
|
* Return undefined if history is not supported by this backend.
|
|
699
699
|
*/
|
|
700
|
-
initializeHistory?(config:
|
|
700
|
+
initializeHistory?(config: HistoryConfig, driverResult: InitializedDriver): Promise<{ historyService: unknown } | undefined>;
|
|
701
701
|
|
|
702
702
|
/**
|
|
703
703
|
* Create a realtime provider for this driver.
|
|
@@ -736,6 +736,14 @@ export interface InitializedDriver {
|
|
|
736
736
|
/** A collection registry to register schema / tables into. */
|
|
737
737
|
collectionRegistry?: CollectionRegistryInterface;
|
|
738
738
|
|
|
739
|
+
/**
|
|
740
|
+
* Collections the driver derived from the live database schema.
|
|
741
|
+
*
|
|
742
|
+
* Set by drivers that introspect in `baas` mode; the server serves these
|
|
743
|
+
* instead of collections loaded from config files.
|
|
744
|
+
*/
|
|
745
|
+
collections?: import("./collections").CollectionConfig[];
|
|
746
|
+
|
|
739
747
|
/** The underlying database connection (for lifecycle management). */
|
|
740
748
|
connection?: DatabaseConnection;
|
|
741
749
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backup type definitions shared across server, client, and studio.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** Where a backup lives — a local path or an object-storage bucket. */
|
|
6
|
+
export type BackupDestinationKind = "local" | "s3" | "gcs";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A single backup as surfaced by the admin API / Studio Backups panel.
|
|
10
|
+
*/
|
|
11
|
+
export interface BackupInfo {
|
|
12
|
+
/** Storage key (object storage) or absolute file path (local). */
|
|
13
|
+
key: string;
|
|
14
|
+
|
|
15
|
+
/** Display name — the file's basename. */
|
|
16
|
+
name: string;
|
|
17
|
+
|
|
18
|
+
/** Size in bytes, when known. */
|
|
19
|
+
sizeBytes?: number;
|
|
20
|
+
|
|
21
|
+
/** ISO timestamp the backup was created, when recoverable. */
|
|
22
|
+
createdAt?: string;
|
|
23
|
+
|
|
24
|
+
/** The kind of destination this backup was read from. */
|
|
25
|
+
destinationKind: BackupDestinationKind;
|
|
26
|
+
}
|
package/src/types/builders.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AuthController } from "../controllers/auth";
|
|
2
2
|
import type { RebaseData } from "../controllers/data";
|
|
3
3
|
import type { User } from "../users";
|
|
4
|
-
import type {
|
|
4
|
+
import type { CollectionConfig } from "./collections";
|
|
5
5
|
import type { AppView } from "../controllers/navigation";
|
|
6
6
|
|
|
7
|
-
export type
|
|
7
|
+
export type CollectionConfigsBuilder<EC extends CollectionConfig = CollectionConfig> = (params: {
|
|
8
8
|
user: User | null,
|
|
9
9
|
authController: AuthController,
|
|
10
10
|
data: RebaseData
|