@rebasepro/types 0.7.0 → 0.9.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/README.md +10 -10
- package/dist/controllers/auth.d.ts +1 -1
- package/dist/controllers/client.d.ts +237 -7
- package/dist/controllers/collection_registry.d.ts +3 -3
- package/dist/controllers/customization_controller.d.ts +1 -1
- package/dist/controllers/data.d.ts +285 -81
- package/dist/controllers/data_driver.d.ts +50 -37
- 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 +17 -6
- 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 +290 -16
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +305 -18
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +8 -4
- package/dist/types/auth_adapter.d.ts +9 -6
- package/dist/types/backend.d.ts +30 -26
- package/dist/types/builders.d.ts +2 -2
- package/dist/types/collections.d.ts +211 -136
- package/dist/types/component_overrides.d.ts +61 -3
- package/dist/types/cron.d.ts +10 -1
- package/dist/types/data_source.d.ts +18 -5
- package/dist/types/database_adapter.d.ts +4 -3
- package/dist/types/entities.d.ts +7 -7
- package/dist/types/entity_actions.d.ts +7 -7
- package/dist/types/entity_callbacks.d.ts +55 -43
- package/dist/types/entity_views.d.ts +3 -3
- package/dist/types/filter-operators.d.ts +153 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/modify_collections.d.ts +2 -2
- package/dist/types/plugins.d.ts +9 -9
- package/dist/types/policy.d.ts +191 -0
- package/dist/types/properties.d.ts +153 -43
- package/dist/types/property_config.d.ts +1 -1
- package/dist/types/relations.d.ts +3 -3
- package/dist/types/slots.d.ts +14 -14
- package/dist/types/storage_source.d.ts +83 -0
- package/dist/types/websockets.d.ts +12 -13
- package/dist/users/user.d.ts +21 -9
- package/package.json +1 -1
- package/src/controllers/auth.tsx +1 -1
- package/src/controllers/client.ts +275 -7
- package/src/controllers/collection_registry.ts +3 -3
- package/src/controllers/customization_controller.tsx +1 -1
- package/src/controllers/data.ts +309 -97
- package/src/controllers/data_driver.ts +49 -40
- 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 +18 -6
- 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 +9 -6
- package/src/types/backend.ts +41 -36
- package/src/types/builders.ts +2 -2
- package/src/types/collections.ts +256 -172
- package/src/types/component_overrides.ts +72 -5
- package/src/types/cron.ts +10 -1
- package/src/types/data_source.ts +29 -7
- package/src/types/database_adapter.ts +4 -3
- package/src/types/entities.ts +7 -7
- package/src/types/entity_actions.tsx +7 -7
- package/src/types/entity_callbacks.ts +58 -47
- package/src/types/entity_views.tsx +3 -3
- package/src/types/filter-operators.ts +240 -0
- package/src/types/index.ts +3 -2
- package/src/types/modify_collections.tsx +2 -2
- package/src/types/plugins.tsx +9 -9
- package/src/types/policy.ts +229 -0
- package/src/types/properties.ts +164 -44
- package/src/types/property_config.tsx +0 -1
- package/src/types/relations.ts +3 -3
- package/src/types/slots.tsx +14 -14
- package/src/types/storage_source.ts +90 -0
- package/src/types/websockets.ts +12 -14
- package/src/users/user.ts +22 -9
- package/dist/types/backend_hooks.d.ts +0 -109
- package/dist/types/entity_overrides.d.ts +0 -10
- package/src/types/backend_hooks.ts +0 -114
- package/src/types/entity_overrides.tsx +0 -11
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Pluggable authentication abstraction for Rebase.
|
|
5
5
|
*
|
|
6
6
|
* An `AuthAdapter` decouples authentication from the database layer,
|
|
7
|
-
* allowing users to bring their own auth system (Clerk, Auth0,
|
|
8
|
-
*
|
|
7
|
+
* allowing users to bring their own auth system (Clerk, Auth0, or other
|
|
8
|
+
* external providers) while keeping the Rebase admin frontend fully functional.
|
|
9
9
|
*
|
|
10
10
|
* @example Built-in auth (default — zero config change)
|
|
11
11
|
* ```ts
|
|
@@ -212,6 +212,9 @@ export interface AuthResponsePayload {
|
|
|
212
212
|
email: string;
|
|
213
213
|
displayName: string | null;
|
|
214
214
|
photoURL: string | null;
|
|
215
|
+
providerId?: string;
|
|
216
|
+
isAnonymous?: boolean;
|
|
217
|
+
emailVerified?: boolean;
|
|
215
218
|
roles: string[];
|
|
216
219
|
metadata: Record<string, unknown>;
|
|
217
220
|
};
|
|
@@ -248,7 +251,7 @@ export interface TransformAuthResponseContext {
|
|
|
248
251
|
* 4. Advertise its capabilities so the frontend can adapt
|
|
249
252
|
*
|
|
250
253
|
* The built-in Rebase auth implements this interface internally.
|
|
251
|
-
* External providers (Clerk, Auth0,
|
|
254
|
+
* External providers (Clerk, Auth0, or others) provide their own adapters.
|
|
252
255
|
* Users with custom auth can use `createCustomAuthAdapter()` for a minimal setup.
|
|
253
256
|
*
|
|
254
257
|
* @group Auth
|
|
@@ -257,7 +260,7 @@ export interface AuthAdapter {
|
|
|
257
260
|
/**
|
|
258
261
|
* Unique identifier for this auth adapter.
|
|
259
262
|
*
|
|
260
|
-
* @example "rebase-builtin", "clerk", "auth0", "
|
|
263
|
+
* @example "rebase-builtin", "clerk", "auth0", "external-provider", "custom"
|
|
261
264
|
*/
|
|
262
265
|
readonly id: string;
|
|
263
266
|
/**
|
|
@@ -343,7 +346,7 @@ export interface AuthAdapter {
|
|
|
343
346
|
*
|
|
344
347
|
* @param values - Raw request body from the client.
|
|
345
348
|
* @param collectionAuth - The parsed `AuthCollectionConfig` from the collection (if `auth` is an object).
|
|
346
|
-
* @returns Processed values ready for `driver.
|
|
349
|
+
* @returns Processed values ready for `driver.save()`, plus metadata for the post-save step.
|
|
347
350
|
*/
|
|
348
351
|
prepareUserCreation?(values: Record<string, unknown>, collectionAuth?: unknown): Promise<UserCreationPrepareResult>;
|
|
349
352
|
/**
|
|
@@ -375,7 +378,7 @@ export interface AuthAdapter {
|
|
|
375
378
|
* response and returns a (potentially enriched) response.
|
|
376
379
|
*
|
|
377
380
|
* Use cases:
|
|
378
|
-
* - Inject tokens from external auth systems (
|
|
381
|
+
* - Inject tokens from external auth systems (custom provider tokens, etc.)
|
|
379
382
|
* - Add project-specific metadata to the response
|
|
380
383
|
* - Enrich the user object with data from external sources
|
|
381
384
|
*
|
package/dist/types/backend.d.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
|
* Abstract database connection interface.
|
|
6
6
|
* Represents a connection to any database system.
|
|
@@ -39,7 +39,7 @@ export interface FetchCollectionOptions<M extends Record<string, unknown> = Reco
|
|
|
39
39
|
startAfter?: unknown;
|
|
40
40
|
searchString?: string;
|
|
41
41
|
databaseId?: string;
|
|
42
|
-
collection?:
|
|
42
|
+
collection?: CollectionConfig;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Options for searching entities
|
|
@@ -50,7 +50,7 @@ export interface SearchOptions<M extends Record<string, unknown> = Record<string
|
|
|
50
50
|
order?: "desc" | "asc";
|
|
51
51
|
limit?: number;
|
|
52
52
|
databaseId?: string;
|
|
53
|
-
collection?:
|
|
53
|
+
collection?: CollectionConfig;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Options for counting entities
|
|
@@ -110,31 +110,31 @@ export type ConditionBuilderStatic<T = unknown> = {
|
|
|
110
110
|
* - Relation resolution
|
|
111
111
|
* - ID generation and conversion
|
|
112
112
|
*/
|
|
113
|
-
export interface
|
|
113
|
+
export interface DataRepository {
|
|
114
114
|
/**
|
|
115
115
|
* Fetch a single entity by ID
|
|
116
116
|
*/
|
|
117
|
-
|
|
117
|
+
fetchOne<M extends Record<string, unknown>>(collectionPath: string, id: string | number, databaseId?: string): Promise<Record<string, unknown> | undefined>;
|
|
118
118
|
/**
|
|
119
119
|
* Fetch a collection of entities with optional filtering, ordering, and pagination
|
|
120
120
|
*/
|
|
121
|
-
fetchCollection<M extends Record<string, unknown>>(collectionPath: string, options?: FetchCollectionOptions<M>): Promise<
|
|
121
|
+
fetchCollection<M extends Record<string, unknown>>(collectionPath: string, options?: FetchCollectionOptions<M>): Promise<Record<string, unknown>[]>;
|
|
122
122
|
/**
|
|
123
123
|
* Search entities by text
|
|
124
124
|
*/
|
|
125
|
-
|
|
125
|
+
searchRows<M extends Record<string, unknown>>(collectionPath: string, searchString: string, options?: SearchOptions<M>): Promise<Record<string, unknown>[]>;
|
|
126
126
|
/**
|
|
127
127
|
* Count entities in a collection
|
|
128
128
|
*/
|
|
129
|
-
|
|
129
|
+
count<M extends Record<string, unknown>>(collectionPath: string, options?: CountOptions<M>): Promise<number>;
|
|
130
130
|
/**
|
|
131
|
-
* Save
|
|
131
|
+
* Save a entity (create or update)
|
|
132
132
|
*/
|
|
133
|
-
|
|
133
|
+
save<M extends Record<string, unknown>>(collectionPath: string, values: Partial<M>, id?: string | number, databaseId?: string): Promise<Record<string, unknown>>;
|
|
134
134
|
/**
|
|
135
|
-
* Delete
|
|
135
|
+
* Delete a entity by ID
|
|
136
136
|
*/
|
|
137
|
-
|
|
137
|
+
delete(collectionPath: string, id: string | number, databaseId?: string): Promise<void>;
|
|
138
138
|
/**
|
|
139
139
|
* Check if a field value is unique in a collection
|
|
140
140
|
*/
|
|
@@ -157,10 +157,10 @@ export interface CollectionSubscriptionConfig {
|
|
|
157
157
|
/**
|
|
158
158
|
* Configuration for subscribing to a single entity
|
|
159
159
|
*/
|
|
160
|
-
export interface
|
|
160
|
+
export interface SingleSubscriptionConfig {
|
|
161
161
|
clientId: string;
|
|
162
162
|
path: string;
|
|
163
|
-
|
|
163
|
+
id: string | number;
|
|
164
164
|
}
|
|
165
165
|
/**
|
|
166
166
|
* Abstract realtime provider interface.
|
|
@@ -170,19 +170,19 @@ export interface RealtimeProvider {
|
|
|
170
170
|
/**
|
|
171
171
|
* Subscribe to collection changes
|
|
172
172
|
*/
|
|
173
|
-
subscribeToCollection(subscriptionId: string, config: CollectionSubscriptionConfig, callback?: (
|
|
173
|
+
subscribeToCollection(subscriptionId: string, config: CollectionSubscriptionConfig, callback?: (rows: Record<string, unknown>[]) => void): void;
|
|
174
174
|
/**
|
|
175
175
|
* Subscribe to single entity changes
|
|
176
176
|
*/
|
|
177
|
-
|
|
177
|
+
subscribeToOne(subscriptionId: string, config: SingleSubscriptionConfig, callback?: (row: Record<string, unknown> | null) => void): void;
|
|
178
178
|
/**
|
|
179
179
|
* Unsubscribe from a subscription
|
|
180
180
|
*/
|
|
181
181
|
unsubscribe(subscriptionId: string): void;
|
|
182
182
|
/**
|
|
183
|
-
* Notify all relevant subscribers of
|
|
183
|
+
* Notify all relevant subscribers of a entity update
|
|
184
184
|
*/
|
|
185
|
-
|
|
185
|
+
notifyUpdate(path: string, id: string, row: Record<string, unknown> | null, databaseId?: string): Promise<void>;
|
|
186
186
|
/**
|
|
187
187
|
* Called when the HTTP server is ready and listening.
|
|
188
188
|
* Useful for providers that need the server address for callbacks.
|
|
@@ -210,15 +210,19 @@ export interface CollectionRegistryInterface {
|
|
|
210
210
|
/**
|
|
211
211
|
* Register a collection
|
|
212
212
|
*/
|
|
213
|
-
register(collection:
|
|
213
|
+
register(collection: CollectionConfig): void;
|
|
214
214
|
/**
|
|
215
215
|
* Get a collection by its path
|
|
216
216
|
*/
|
|
217
|
-
getCollectionByPath(path: string):
|
|
217
|
+
getCollectionByPath(path: string): CollectionConfig | undefined;
|
|
218
218
|
/**
|
|
219
219
|
* Get all registered collections
|
|
220
220
|
*/
|
|
221
|
-
getCollections():
|
|
221
|
+
getCollections(): CollectionConfig[];
|
|
222
|
+
/**
|
|
223
|
+
* Get the currently registered global callbacks, if any.
|
|
224
|
+
*/
|
|
225
|
+
getGlobalCallbacks(): any | undefined;
|
|
222
226
|
}
|
|
223
227
|
/**
|
|
224
228
|
* Abstract data transformer interface.
|
|
@@ -228,11 +232,11 @@ export interface DataTransformer {
|
|
|
228
232
|
/**
|
|
229
233
|
* Transform entity data for storage in the database
|
|
230
234
|
*/
|
|
231
|
-
serializeToDatabase<M extends Record<string, unknown>>(entity: M, collection:
|
|
235
|
+
serializeToDatabase<M extends Record<string, unknown>>(entity: M, collection: CollectionConfig): Record<string, unknown>;
|
|
232
236
|
/**
|
|
233
237
|
* Transform database data back to entity format
|
|
234
238
|
*/
|
|
235
|
-
deserializeFromDatabase<M extends Record<string, unknown>>(data: Record<string, unknown>, collection:
|
|
239
|
+
deserializeFromDatabase<M extends Record<string, unknown>>(data: Record<string, unknown>, collection: CollectionConfig): Promise<M>;
|
|
236
240
|
}
|
|
237
241
|
/**
|
|
238
242
|
* Administrative operations for SQL-based databases (PostgreSQL, MySQL, etc.).
|
|
@@ -423,7 +427,7 @@ export interface BackendInstance extends BackendLifecycle {
|
|
|
423
427
|
/**
|
|
424
428
|
* Entity repository for CRUD operations
|
|
425
429
|
*/
|
|
426
|
-
entityRepository:
|
|
430
|
+
entityRepository: DataRepository;
|
|
427
431
|
/**
|
|
428
432
|
* Realtime provider for subscriptions
|
|
429
433
|
*/
|
|
@@ -514,7 +518,7 @@ export interface BackendBootstrapper {
|
|
|
514
518
|
* Initialize history tables / services if this driver supports them.
|
|
515
519
|
* Return undefined if history is not supported by this backend.
|
|
516
520
|
*/
|
|
517
|
-
initializeHistory?(config:
|
|
521
|
+
initializeHistory?(config: HistoryConfig, driverResult: InitializedDriver): Promise<{
|
|
518
522
|
historyService: unknown;
|
|
519
523
|
} | undefined>;
|
|
520
524
|
/**
|
package/dist/types/builders.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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
|
-
export type
|
|
6
|
+
export type CollectionConfigsBuilder<EC extends CollectionConfig = CollectionConfig> = (params: {
|
|
7
7
|
user: User | null;
|
|
8
8
|
authController: AuthController;
|
|
9
9
|
data: RebaseData;
|