@rebasepro/types 0.0.1-canary.0 → 0.0.1-canary.0e2f892
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 +1 -1
- package/dist/controllers/analytics_controller.d.ts +2 -2
- package/dist/controllers/auth.d.ts +52 -6
- package/dist/controllers/client.d.ts +170 -0
- package/dist/controllers/collection_registry.d.ts +45 -0
- package/dist/controllers/customization_controller.d.ts +11 -1
- package/dist/controllers/data.d.ts +168 -0
- package/dist/controllers/data_driver.d.ts +160 -0
- package/dist/controllers/database_admin.d.ts +11 -0
- package/dist/controllers/effective_role.d.ts +4 -0
- package/dist/controllers/email.d.ts +34 -0
- package/dist/controllers/index.d.ts +12 -5
- package/dist/controllers/local_config_persistence.d.ts +4 -4
- package/dist/controllers/navigation.d.ts +12 -61
- package/dist/controllers/registry.d.ts +54 -0
- package/dist/controllers/side_entity_controller.d.ts +7 -7
- package/dist/controllers/storage.d.ts +24 -26
- package/dist/index.d.ts +0 -1
- package/dist/index.es.js +119 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +118 -13
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +40 -26
- package/dist/types/backend.d.ts +300 -18
- package/dist/types/builders.d.ts +15 -0
- package/dist/types/chips.d.ts +1 -1
- package/dist/types/collections.d.ts +324 -355
- package/dist/types/cron.d.ts +102 -0
- package/dist/types/data_source.d.ts +64 -0
- package/dist/types/entities.d.ts +29 -24
- package/dist/types/entity_actions.d.ts +12 -12
- package/dist/types/entity_callbacks.d.ts +12 -12
- package/dist/types/entity_link_builder.d.ts +1 -1
- package/dist/types/entity_overrides.d.ts +7 -2
- package/dist/types/entity_views.d.ts +61 -0
- package/dist/types/export_import.d.ts +3 -3
- package/dist/types/index.d.ts +9 -5
- package/dist/types/plugins.d.ts +228 -225
- package/dist/types/properties.d.ts +135 -62
- package/dist/types/property_config.d.ts +13 -11
- package/dist/types/relations.d.ts +1 -1
- package/dist/types/slots.d.ts +252 -0
- package/dist/types/translations.d.ts +870 -0
- package/dist/types/user_management_delegate.d.ts +43 -0
- package/dist/types/websockets.d.ts +45 -0
- package/dist/users/user.d.ts +4 -0
- package/package.json +99 -131
- package/src/controllers/analytics_controller.tsx +2 -2
- package/src/controllers/auth.tsx +55 -6
- package/src/controllers/client.ts +133 -0
- package/src/controllers/collection_registry.ts +57 -0
- package/src/controllers/customization_controller.tsx +12 -1
- package/src/controllers/data.ts +191 -0
- package/src/controllers/{datasource.ts → data_driver.ts} +50 -61
- package/src/controllers/database_admin.ts +22 -0
- package/src/controllers/effective_role.ts +4 -0
- package/src/controllers/email.ts +36 -0
- package/src/controllers/index.ts +15 -5
- package/src/controllers/local_config_persistence.tsx +4 -4
- package/src/controllers/navigation.ts +13 -76
- package/src/controllers/registry.ts +65 -0
- package/src/controllers/side_entity_controller.tsx +7 -7
- package/src/controllers/storage.ts +25 -28
- package/src/index.ts +0 -1
- package/src/rebase_context.tsx +41 -39
- package/src/types/backend.ts +359 -24
- package/src/types/builders.ts +17 -0
- package/src/types/chips.ts +15 -40
- package/src/types/collections.ts +375 -383
- package/src/types/cron.ts +149 -0
- package/src/types/data_source.ts +145 -0
- package/src/types/entities.ts +40 -33
- package/src/types/entity_actions.tsx +11 -11
- package/src/types/entity_callbacks.ts +12 -12
- package/src/types/entity_link_builder.ts +1 -1
- package/src/types/entity_overrides.tsx +7 -2
- package/src/types/entity_views.tsx +77 -0
- package/src/types/export_import.ts +3 -3
- package/src/types/index.ts +10 -5
- package/src/types/plugins.tsx +280 -261
- package/src/types/properties.ts +163 -61
- package/src/types/property_config.tsx +11 -11
- package/src/types/relations.ts +1 -1
- package/src/types/slots.tsx +297 -0
- package/src/types/translations.ts +977 -0
- package/src/types/user_management_delegate.ts +50 -7
- package/src/types/websockets.ts +48 -0
- package/src/users/roles.ts +0 -1
- package/src/users/user.ts +5 -0
- package/dist/components/EntityFormActionsProps.d.ts +0 -17
- package/dist/components/EntityFormProps.d.ts +0 -46
- package/dist/components/PropertyPreviewProps.d.ts +0 -50
- package/dist/components/formex.d.ts +0 -40
- package/dist/components/index.d.ts +0 -3
- package/dist/controllers/datasource.d.ts +0 -179
- package/dist/types/fields.d.ts +0 -221
- package/dist/types/rebase.d.ts +0 -180
- package/src/components/EntityFormActionsProps.tsx +0 -18
- package/src/components/EntityFormProps.tsx +0 -52
- package/src/components/PropertyPreviewProps.tsx +0 -61
- package/src/components/formex.tsx +0 -46
- package/src/components/index.ts +0 -3
- package/src/types/fields.tsx +0 -298
- package/src/types/rebase.tsx +0 -211
package/dist/rebase_context.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { AnalyticsController
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { AnalyticsController } from "./controllers/analytics_controller";
|
|
2
|
+
import type { AuthController } from "./controllers/auth";
|
|
3
|
+
import type { StorageSource } from "./controllers/storage";
|
|
4
|
+
import type { UserConfigurationPersistence } from "./controllers/local_config_persistence";
|
|
5
|
+
import type { DatabaseAdmin } from "./types/backend";
|
|
6
|
+
import type { RebaseData } from "./controllers/data";
|
|
7
|
+
import type { User } from "./users";
|
|
8
|
+
import type { UserManagementDelegate } from "./types/user_management_delegate";
|
|
4
9
|
/**
|
|
5
10
|
* Context that is provided to entity callbacks (hooks).
|
|
6
11
|
* It contains only the dependencies that are available in both the frontend and the backend.
|
|
@@ -8,9 +13,10 @@ import { UserManagementDelegate, EffectiveRoleController } from "./types";
|
|
|
8
13
|
*/
|
|
9
14
|
export type RebaseCallContext<USER extends User = User> = {
|
|
10
15
|
/**
|
|
11
|
-
*
|
|
16
|
+
* Unified data access — `context.data.products.create(...)`.
|
|
17
|
+
* Access any collection as a dynamic property.
|
|
12
18
|
*/
|
|
13
|
-
|
|
19
|
+
data: RebaseData;
|
|
14
20
|
/**
|
|
15
21
|
* Used storage implementation
|
|
16
22
|
*/
|
|
@@ -28,39 +34,42 @@ export type RebaseCallContext<USER extends User = User> = {
|
|
|
28
34
|
* @see useRebaseContext
|
|
29
35
|
*/
|
|
30
36
|
export type RebaseContext<USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>> = RebaseCallContext<USER> & {
|
|
37
|
+
authController: AuthControllerType;
|
|
31
38
|
/**
|
|
32
|
-
*
|
|
33
|
-
* attributes.
|
|
34
|
-
* @see useNavigation
|
|
39
|
+
* Controller mapping strings to collections
|
|
35
40
|
*/
|
|
36
|
-
|
|
41
|
+
collectionRegistryController?: import("./controllers/collection_registry").CollectionRegistryController;
|
|
37
42
|
/**
|
|
38
|
-
* Controller
|
|
39
|
-
|
|
43
|
+
* Controller for navigation state
|
|
44
|
+
*/
|
|
45
|
+
navigationStateController?: import("./controllers/navigation").NavigationStateController;
|
|
46
|
+
/**
|
|
47
|
+
* Controller for side dialogs (side sheets)
|
|
40
48
|
*/
|
|
41
|
-
|
|
49
|
+
sideDialogsController?: import("./controllers/side_dialogs_controller").SideDialogsController;
|
|
42
50
|
/**
|
|
43
|
-
* Controller
|
|
44
|
-
* This is the controller used internally by side entity dialogs
|
|
45
|
-
* or reference dialogs.
|
|
51
|
+
* Controller to open the side dialog displaying entity forms
|
|
46
52
|
*/
|
|
47
|
-
|
|
53
|
+
sideEntityController?: import("./controllers/side_entity_controller").SideEntityController;
|
|
48
54
|
/**
|
|
49
|
-
* Controller
|
|
55
|
+
* Controller resolving URLs in the CMS
|
|
50
56
|
*/
|
|
51
|
-
|
|
57
|
+
urlController?: import("./controllers/navigation").UrlController;
|
|
52
58
|
/**
|
|
53
|
-
*
|
|
59
|
+
* Controller to handle simple confirmation and alert dialogs
|
|
54
60
|
*/
|
|
55
|
-
|
|
61
|
+
dialogsController?: import("./controllers/dialogs_controller").DialogsController;
|
|
56
62
|
/**
|
|
57
|
-
*
|
|
63
|
+
* Controller for CMS customization
|
|
58
64
|
*/
|
|
59
|
-
customizationController?: CustomizationController;
|
|
65
|
+
customizationController?: import("./controllers/customization_controller").CustomizationController;
|
|
60
66
|
/**
|
|
61
|
-
*
|
|
67
|
+
* Controller for effective role
|
|
62
68
|
*/
|
|
63
|
-
|
|
69
|
+
effectiveRoleController?: {
|
|
70
|
+
effectiveRole: string | null;
|
|
71
|
+
setEffectiveRole: (role: string | null) => void;
|
|
72
|
+
};
|
|
64
73
|
/**
|
|
65
74
|
* Use this controller to access data stored in the browser for the user
|
|
66
75
|
*/
|
|
@@ -85,7 +94,12 @@ export type RebaseContext<USER extends User = User, AuthControllerType extends A
|
|
|
85
94
|
*/
|
|
86
95
|
userManagement?: UserManagementDelegate<USER>;
|
|
87
96
|
/**
|
|
88
|
-
*
|
|
97
|
+
* Administrative database operations (SQL, schema discovery).
|
|
98
|
+
* Only available in developer/admin contexts.
|
|
99
|
+
*/
|
|
100
|
+
databaseAdmin?: DatabaseAdmin;
|
|
101
|
+
/**
|
|
102
|
+
* Controller for snackbars
|
|
89
103
|
*/
|
|
90
|
-
|
|
104
|
+
snackbarController?: import("./controllers/snackbar").SnackbarController;
|
|
91
105
|
};
|
package/dist/types/backend.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Entity
|
|
1
|
+
import type { Entity } from "./entities";
|
|
2
|
+
import type { EntityCollection, FilterValues, WhereFilterOp } from "./collections";
|
|
2
3
|
/**
|
|
3
4
|
* Abstract database connection interface.
|
|
4
5
|
* Represents a connection to any database system.
|
|
@@ -13,7 +14,7 @@ export interface DatabaseConnection {
|
|
|
13
14
|
*/
|
|
14
15
|
readonly isConnected?: boolean;
|
|
15
16
|
/**
|
|
16
|
-
* Close the database connection
|
|
17
|
+
* Close the database connection and release resources.
|
|
17
18
|
*/
|
|
18
19
|
close?(): Promise<void>;
|
|
19
20
|
}
|
|
@@ -28,30 +29,34 @@ export interface QueryFilter {
|
|
|
28
29
|
/**
|
|
29
30
|
* Options for fetching a collection of entities
|
|
30
31
|
*/
|
|
31
|
-
export interface FetchCollectionOptions<M extends Record<string,
|
|
32
|
+
export interface FetchCollectionOptions<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
32
33
|
filter?: FilterValues<Extract<keyof M, string>>;
|
|
33
34
|
orderBy?: string;
|
|
34
35
|
order?: "desc" | "asc";
|
|
35
36
|
limit?: number;
|
|
37
|
+
offset?: number;
|
|
36
38
|
startAfter?: unknown;
|
|
37
39
|
searchString?: string;
|
|
38
40
|
databaseId?: string;
|
|
41
|
+
collection?: EntityCollection;
|
|
39
42
|
}
|
|
40
43
|
/**
|
|
41
44
|
* Options for searching entities
|
|
42
45
|
*/
|
|
43
|
-
export interface SearchOptions<M extends Record<string,
|
|
46
|
+
export interface SearchOptions<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
44
47
|
filter?: FilterValues<Extract<keyof M, string>>;
|
|
45
48
|
orderBy?: string;
|
|
46
49
|
order?: "desc" | "asc";
|
|
47
50
|
limit?: number;
|
|
48
51
|
databaseId?: string;
|
|
52
|
+
collection?: EntityCollection;
|
|
49
53
|
}
|
|
50
54
|
/**
|
|
51
55
|
* Options for counting entities
|
|
52
56
|
*/
|
|
53
|
-
export interface CountOptions<M extends Record<string,
|
|
57
|
+
export interface CountOptions<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
54
58
|
filter?: FilterValues<Extract<keyof M, string>>;
|
|
59
|
+
searchString?: string;
|
|
55
60
|
databaseId?: string;
|
|
56
61
|
}
|
|
57
62
|
/**
|
|
@@ -63,11 +68,11 @@ export interface CountOptions<M extends Record<string, any> = any> {
|
|
|
63
68
|
*
|
|
64
69
|
* @template T The type of condition returned by the builder (e.g., SQL for PostgreSQL, Filter<Document> for MongoDB)
|
|
65
70
|
*/
|
|
66
|
-
export interface ConditionBuilder<T =
|
|
71
|
+
export interface ConditionBuilder<T = unknown> {
|
|
67
72
|
/**
|
|
68
73
|
* Build filter conditions from Rebase FilterValues
|
|
69
74
|
*/
|
|
70
|
-
buildFilterConditions<M extends Record<string,
|
|
75
|
+
buildFilterConditions<M extends Record<string, unknown>>(filter: FilterValues<Extract<keyof M, string>>, collectionPath: string, ...args: unknown[]): T[];
|
|
71
76
|
/**
|
|
72
77
|
* Build search conditions for text search
|
|
73
78
|
*/
|
|
@@ -89,8 +94,8 @@ export interface ConditionBuilder<T = any> {
|
|
|
89
94
|
* // DrizzleConditionBuilder satisfies this type
|
|
90
95
|
* const builder: ConditionBuilderStatic<SQL> = DrizzleConditionBuilder;
|
|
91
96
|
*/
|
|
92
|
-
export type ConditionBuilderStatic<T =
|
|
93
|
-
buildFilterConditions<M extends Record<string,
|
|
97
|
+
export type ConditionBuilderStatic<T = unknown> = {
|
|
98
|
+
buildFilterConditions<M extends Record<string, unknown>>(filter: FilterValues<Extract<keyof M, string>>, ...args: unknown[]): T[];
|
|
94
99
|
buildSearchConditions(searchString: string, properties: Record<string, unknown>, ...args: unknown[]): T[];
|
|
95
100
|
combineConditionsWithAnd(conditions: T[]): T | undefined;
|
|
96
101
|
combineConditionsWithOr(conditions: T[]): T | undefined;
|
|
@@ -108,23 +113,23 @@ export interface EntityRepository {
|
|
|
108
113
|
/**
|
|
109
114
|
* Fetch a single entity by ID
|
|
110
115
|
*/
|
|
111
|
-
fetchEntity<M extends Record<string,
|
|
116
|
+
fetchEntity<M extends Record<string, unknown>>(collectionPath: string, entityId: string | number, databaseId?: string): Promise<Entity<M> | undefined>;
|
|
112
117
|
/**
|
|
113
118
|
* Fetch a collection of entities with optional filtering, ordering, and pagination
|
|
114
119
|
*/
|
|
115
|
-
fetchCollection<M extends Record<string,
|
|
120
|
+
fetchCollection<M extends Record<string, unknown>>(collectionPath: string, options?: FetchCollectionOptions<M>): Promise<Entity<M>[]>;
|
|
116
121
|
/**
|
|
117
122
|
* Search entities by text
|
|
118
123
|
*/
|
|
119
|
-
searchEntities<M extends Record<string,
|
|
124
|
+
searchEntities<M extends Record<string, unknown>>(collectionPath: string, searchString: string, options?: SearchOptions<M>): Promise<Entity<M>[]>;
|
|
120
125
|
/**
|
|
121
126
|
* Count entities in a collection
|
|
122
127
|
*/
|
|
123
|
-
countEntities<M extends Record<string,
|
|
128
|
+
countEntities<M extends Record<string, unknown>>(collectionPath: string, options?: CountOptions<M>): Promise<number>;
|
|
124
129
|
/**
|
|
125
130
|
* Save an entity (create or update)
|
|
126
131
|
*/
|
|
127
|
-
saveEntity<M extends Record<string,
|
|
132
|
+
saveEntity<M extends Record<string, unknown>>(collectionPath: string, values: Partial<M>, entityId?: string | number, databaseId?: string): Promise<Entity<M>>;
|
|
128
133
|
/**
|
|
129
134
|
* Delete an entity by ID
|
|
130
135
|
*/
|
|
@@ -204,11 +209,173 @@ export interface DataTransformer {
|
|
|
204
209
|
/**
|
|
205
210
|
* Transform entity data for storage in the database
|
|
206
211
|
*/
|
|
207
|
-
serializeToDatabase<M extends Record<string,
|
|
212
|
+
serializeToDatabase<M extends Record<string, unknown>>(entity: M, collection: EntityCollection): Record<string, unknown>;
|
|
208
213
|
/**
|
|
209
214
|
* Transform database data back to entity format
|
|
210
215
|
*/
|
|
211
|
-
deserializeFromDatabase<M extends Record<string,
|
|
216
|
+
deserializeFromDatabase<M extends Record<string, unknown>>(data: Record<string, unknown>, collection: EntityCollection): Promise<M>;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Administrative operations for SQL-based databases (PostgreSQL, MySQL, etc.).
|
|
220
|
+
* Used by the SQL Editor, RLS Editor, and schema browser.
|
|
221
|
+
*
|
|
222
|
+
* @group Admin
|
|
223
|
+
*/
|
|
224
|
+
export interface SQLAdmin {
|
|
225
|
+
/**
|
|
226
|
+
* Execute raw SQL against the database.
|
|
227
|
+
*/
|
|
228
|
+
executeSql(sql: string, options?: {
|
|
229
|
+
database?: string;
|
|
230
|
+
role?: string;
|
|
231
|
+
}): Promise<Record<string, unknown>[]>;
|
|
232
|
+
/**
|
|
233
|
+
* Fetch the available databases on the server.
|
|
234
|
+
*/
|
|
235
|
+
fetchAvailableDatabases?(): Promise<string[]>;
|
|
236
|
+
/**
|
|
237
|
+
* Fetch the available database roles.
|
|
238
|
+
*/
|
|
239
|
+
fetchAvailableRoles?(): Promise<string[]>;
|
|
240
|
+
/**
|
|
241
|
+
* Fetch the current database name.
|
|
242
|
+
*/
|
|
243
|
+
fetchCurrentDatabase?(): Promise<string | undefined>;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Administrative operations for document-based databases (MongoDB, Firestore, etc.).
|
|
247
|
+
* Used by future document administration tools.
|
|
248
|
+
*
|
|
249
|
+
* @group Admin
|
|
250
|
+
*/
|
|
251
|
+
export interface DocumentAdmin {
|
|
252
|
+
/**
|
|
253
|
+
* Execute an aggregation pipeline or equivalent query.
|
|
254
|
+
*/
|
|
255
|
+
executeAggregate?(pipeline: Record<string, unknown>[]): Promise<Record<string, unknown>[]>;
|
|
256
|
+
/**
|
|
257
|
+
* Fetch statistics for a collection (document count, size, etc.).
|
|
258
|
+
*/
|
|
259
|
+
fetchCollectionStats?(collectionName: string): Promise<{
|
|
260
|
+
count: number;
|
|
261
|
+
sizeBytes?: number;
|
|
262
|
+
}>;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Administrative operations for schema management.
|
|
266
|
+
* Shared across SQL and document databases.
|
|
267
|
+
*
|
|
268
|
+
* @group Admin
|
|
269
|
+
*/
|
|
270
|
+
export interface SchemaAdmin {
|
|
271
|
+
/**
|
|
272
|
+
* Fetch database tables/collections not yet mapped to a Rebase collection.
|
|
273
|
+
*/
|
|
274
|
+
fetchUnmappedTables?(mappedPaths?: string[]): Promise<string[]>;
|
|
275
|
+
/**
|
|
276
|
+
* Fetch column/field metadata for a single table/collection.
|
|
277
|
+
* The return type is generic — SQL backends return TableMetadata,
|
|
278
|
+
* document backends may return a different shape.
|
|
279
|
+
*/
|
|
280
|
+
fetchTableMetadata?(tableName: string): Promise<unknown>;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Metadata for a database branch.
|
|
284
|
+
* @group Admin
|
|
285
|
+
*/
|
|
286
|
+
export interface BranchInfo {
|
|
287
|
+
/** Branch name (without prefix). */
|
|
288
|
+
name: string;
|
|
289
|
+
/** The database this branch was created from. */
|
|
290
|
+
parentDatabase: string;
|
|
291
|
+
/** When the branch was created. */
|
|
292
|
+
createdAt: Date;
|
|
293
|
+
/** Size in bytes, if available from the server. */
|
|
294
|
+
sizeBytes?: number;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Administrative operations for database branching.
|
|
298
|
+
* Allows creating isolated database copies for development/preview workflows.
|
|
299
|
+
*
|
|
300
|
+
* @group Admin
|
|
301
|
+
*/
|
|
302
|
+
export interface BranchAdmin {
|
|
303
|
+
/** Create a new branch (database copy) from the current or specified source database. */
|
|
304
|
+
createBranch(name: string, options?: {
|
|
305
|
+
source?: string;
|
|
306
|
+
}): Promise<BranchInfo>;
|
|
307
|
+
/** Delete a branch database. Cannot delete the main/default database. */
|
|
308
|
+
deleteBranch(name: string): Promise<void>;
|
|
309
|
+
/** List all branches (databases that were created via branching). */
|
|
310
|
+
listBranches(): Promise<BranchInfo[]>;
|
|
311
|
+
/** Get info about a specific branch. */
|
|
312
|
+
getBranchInfo(name: string): Promise<BranchInfo | undefined>;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Union type for all admin capabilities.
|
|
316
|
+
* A backend may implement any combination of these interfaces.
|
|
317
|
+
*
|
|
318
|
+
* Use type guards (`isSQLAdmin`, `isDocumentAdmin`, `isSchemaAdmin`, `isBranchAdmin`)
|
|
319
|
+
* to safely narrow the type before calling methods.
|
|
320
|
+
*
|
|
321
|
+
* @group Admin
|
|
322
|
+
*/
|
|
323
|
+
export type DatabaseAdmin = Partial<SQLAdmin> & Partial<DocumentAdmin> & Partial<SchemaAdmin> & Partial<BranchAdmin>;
|
|
324
|
+
/**
|
|
325
|
+
* Type guard: does this admin support SQL operations?
|
|
326
|
+
* @group Admin
|
|
327
|
+
*/
|
|
328
|
+
export declare function isSQLAdmin(admin: DatabaseAdmin | undefined): admin is SQLAdmin;
|
|
329
|
+
/**
|
|
330
|
+
* Type guard: does this admin support document operations?
|
|
331
|
+
* @group Admin
|
|
332
|
+
*/
|
|
333
|
+
export declare function isDocumentAdmin(admin: DatabaseAdmin | undefined): admin is DocumentAdmin;
|
|
334
|
+
/**
|
|
335
|
+
* Type guard: does this admin support schema management?
|
|
336
|
+
* @group Admin
|
|
337
|
+
*/
|
|
338
|
+
export declare function isSchemaAdmin(admin: DatabaseAdmin | undefined): admin is SchemaAdmin;
|
|
339
|
+
/**
|
|
340
|
+
* Type guard: does this admin support database branching?
|
|
341
|
+
* @group Admin
|
|
342
|
+
*/
|
|
343
|
+
export declare function isBranchAdmin(admin: DatabaseAdmin | undefined): admin is BranchAdmin;
|
|
344
|
+
/**
|
|
345
|
+
* Health check result returned by `healthCheck()`.
|
|
346
|
+
* @group Lifecycle
|
|
347
|
+
*/
|
|
348
|
+
export interface HealthCheckResult {
|
|
349
|
+
/** Whether the backend is healthy and able to serve requests. */
|
|
350
|
+
healthy: boolean;
|
|
351
|
+
/** Round-trip latency to the database in milliseconds. */
|
|
352
|
+
latencyMs: number;
|
|
353
|
+
/** Optional details (e.g., pool stats, replication lag). */
|
|
354
|
+
details?: Record<string, unknown>;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Lifecycle contract for backend components that hold resources
|
|
358
|
+
* (database connections, WebSocket pools, timers, etc.).
|
|
359
|
+
*
|
|
360
|
+
* All methods are optional — simple backends (e.g., in-memory) can skip them.
|
|
361
|
+
* @group Lifecycle
|
|
362
|
+
*/
|
|
363
|
+
export interface BackendLifecycle {
|
|
364
|
+
/**
|
|
365
|
+
* Initialize the backend: open connections, run migrations, seed data.
|
|
366
|
+
* Called once during startup. Idempotent.
|
|
367
|
+
*/
|
|
368
|
+
initialize?(): Promise<void>;
|
|
369
|
+
/**
|
|
370
|
+
* Check whether the backend is healthy and reachable.
|
|
371
|
+
* Should be fast (< 1 s) and safe to call frequently.
|
|
372
|
+
*/
|
|
373
|
+
healthCheck?(): Promise<HealthCheckResult>;
|
|
374
|
+
/**
|
|
375
|
+
* Gracefully shut down: close connections, flush buffers, cancel timers.
|
|
376
|
+
* After calling `destroy()`, no other methods should be called.
|
|
377
|
+
*/
|
|
378
|
+
destroy?(): Promise<void>;
|
|
212
379
|
}
|
|
213
380
|
/**
|
|
214
381
|
* Configuration for creating a database backend
|
|
@@ -228,9 +395,11 @@ export interface BackendConfig {
|
|
|
228
395
|
schema?: unknown;
|
|
229
396
|
}
|
|
230
397
|
/**
|
|
231
|
-
* A complete backend instance with all required services
|
|
398
|
+
* A complete backend instance with all required services.
|
|
399
|
+
*
|
|
400
|
+
* Now includes optional lifecycle management and admin capabilities.
|
|
232
401
|
*/
|
|
233
|
-
export interface BackendInstance {
|
|
402
|
+
export interface BackendInstance extends BackendLifecycle {
|
|
234
403
|
/**
|
|
235
404
|
* Entity repository for CRUD operations
|
|
236
405
|
*/
|
|
@@ -247,8 +416,121 @@ export interface BackendInstance {
|
|
|
247
416
|
* The underlying database connection
|
|
248
417
|
*/
|
|
249
418
|
connection: DatabaseConnection;
|
|
419
|
+
/**
|
|
420
|
+
* Administrative operations (SQL, schema, documents).
|
|
421
|
+
* What's available depends on the backend type — use type guards
|
|
422
|
+
* (`isSQLAdmin`, `isSchemaAdmin`, etc.) to narrow.
|
|
423
|
+
*/
|
|
424
|
+
admin?: DatabaseAdmin;
|
|
250
425
|
}
|
|
251
426
|
/**
|
|
252
427
|
* Factory function type for creating backend instances
|
|
253
428
|
*/
|
|
254
429
|
export type BackendFactory<TConfig extends BackendConfig = BackendConfig> = (config: TConfig) => BackendInstance;
|
|
430
|
+
/**
|
|
431
|
+
* A `BackendBootstrapper` encapsulates all driver-specific initialization logic.
|
|
432
|
+
*
|
|
433
|
+
* Instead of hard-coding Postgres setup into `initializeRebaseBackend()`,
|
|
434
|
+
* each database backend provides its own bootstrapper that knows how to:
|
|
435
|
+
* - Create the DataDriver from a config object
|
|
436
|
+
* - Optionally initialize auth tables
|
|
437
|
+
* - Optionally create a realtime service
|
|
438
|
+
* - Mount driver-specific API routes
|
|
439
|
+
*
|
|
440
|
+
* The main `initializeRebaseBackend()` becomes a **coordinator** that iterates
|
|
441
|
+
* registered bootstrappers, calls their hooks, and wires the results together.
|
|
442
|
+
*
|
|
443
|
+
* @group Backend
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```typescript
|
|
447
|
+
* // Third-party MySQL bootstrapper
|
|
448
|
+
* const mysqlBootstrapper: BackendBootstrapper = {
|
|
449
|
+
* type: "mysql",
|
|
450
|
+
* initializeDriver: async (config) => new MySQLDataDriver(config.connection),
|
|
451
|
+
* initializeRealtime: async (config) => new MySQLChangeStreamRealtime(config.connection),
|
|
452
|
+
* };
|
|
453
|
+
*
|
|
454
|
+
* initializeRebaseBackend({
|
|
455
|
+
* ...config,
|
|
456
|
+
* bootstrappers: [postgresBootstrapper, mysqlBootstrapper]
|
|
457
|
+
* });
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
460
|
+
export interface BackendBootstrapper {
|
|
461
|
+
/**
|
|
462
|
+
* Which driver type this bootstrapper handles.
|
|
463
|
+
* Must match the `type` field on the driver config object
|
|
464
|
+
* (e.g., `"postgres"`, `"mongodb"`, `"mysql"`).
|
|
465
|
+
*/
|
|
466
|
+
type: string;
|
|
467
|
+
/**
|
|
468
|
+
* Create a DataDriver from the given config.
|
|
469
|
+
* This is the only **required** method.
|
|
470
|
+
*/
|
|
471
|
+
initializeDriver(config: unknown): Promise<InitializedDriver>;
|
|
472
|
+
/**
|
|
473
|
+
* Initialize auth tables / services if this driver supports them.
|
|
474
|
+
* Return undefined if auth is not supported by this backend.
|
|
475
|
+
*/
|
|
476
|
+
initializeAuth?(config: unknown, driverResult: InitializedDriver): Promise<BootstrappedAuth | undefined>;
|
|
477
|
+
/**
|
|
478
|
+
* Initialize history tables / services if this driver supports them.
|
|
479
|
+
* Return undefined if history is not supported by this backend.
|
|
480
|
+
*/
|
|
481
|
+
initializeHistory?(config: unknown, driverResult: InitializedDriver): Promise<{
|
|
482
|
+
historyService: unknown;
|
|
483
|
+
} | undefined>;
|
|
484
|
+
/**
|
|
485
|
+
* Create a realtime provider for this driver.
|
|
486
|
+
* Return undefined if the driver does not support realtime.
|
|
487
|
+
*/
|
|
488
|
+
initializeRealtime?(config: unknown, driverResult: InitializedDriver): Promise<RealtimeProvider | undefined>;
|
|
489
|
+
/**
|
|
490
|
+
* Mount any driver-specific HTTP routes (e.g., custom admin endpoints).
|
|
491
|
+
* Called after all drivers are initialized.
|
|
492
|
+
*/
|
|
493
|
+
mountRoutes?(app: unknown, basePath: string, driverResult: InitializedDriver): void;
|
|
494
|
+
/**
|
|
495
|
+
* Return admin capabilities for this driver.
|
|
496
|
+
*/
|
|
497
|
+
getAdmin?(driverResult: InitializedDriver): DatabaseAdmin | undefined;
|
|
498
|
+
/**
|
|
499
|
+
* Initialize WebSocket server for realtime operations.
|
|
500
|
+
*/
|
|
501
|
+
initializeWebsockets?(server: unknown, realtimeService: RealtimeProvider, driver: import("../controllers/data_driver").DataDriver, config?: unknown): Promise<void> | void;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Result of `BackendBootstrapper.initializeDriver()`.
|
|
505
|
+
* @group Backend
|
|
506
|
+
*/
|
|
507
|
+
export interface InitializedDriver {
|
|
508
|
+
/** The DataDriver instance, ready for use. */
|
|
509
|
+
driver: import("../controllers/data_driver").DataDriver;
|
|
510
|
+
/** The realtime service, if the driver created one during init. */
|
|
511
|
+
realtimeProvider?: RealtimeProvider;
|
|
512
|
+
/** A collection registry to register schema / tables into. */
|
|
513
|
+
collectionRegistry?: CollectionRegistryInterface;
|
|
514
|
+
/** The underlying database connection (for lifecycle management). */
|
|
515
|
+
connection?: DatabaseConnection;
|
|
516
|
+
/**
|
|
517
|
+
* Opaque handle that the bootstrapper can use in subsequent hooks
|
|
518
|
+
* (e.g., `initializeAuth`, `mountRoutes`) to access driver internals.
|
|
519
|
+
* Not used by the coordinator.
|
|
520
|
+
*/
|
|
521
|
+
internals?: unknown;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Result of `BackendBootstrapper.initializeAuth()`.
|
|
525
|
+
* @group Backend
|
|
526
|
+
*/
|
|
527
|
+
export interface BootstrappedAuth {
|
|
528
|
+
/** User management service. */
|
|
529
|
+
userService: unknown;
|
|
530
|
+
/** Role management service. */
|
|
531
|
+
roleService: unknown;
|
|
532
|
+
/** Email service (optional). */
|
|
533
|
+
emailService?: unknown;
|
|
534
|
+
/** Combined Auth Repository for unified token and user management. */
|
|
535
|
+
authRepository?: unknown;
|
|
536
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AuthController } from "../controllers/auth";
|
|
2
|
+
import type { RebaseData } from "../controllers/data";
|
|
3
|
+
import type { User } from "../users";
|
|
4
|
+
import type { EntityCollection } from "./collections";
|
|
5
|
+
import type { AppView } from "../controllers/navigation";
|
|
6
|
+
export type EntityCollectionsBuilder<EC extends EntityCollection = EntityCollection> = (params: {
|
|
7
|
+
user: User | null;
|
|
8
|
+
authController: AuthController;
|
|
9
|
+
data: RebaseData;
|
|
10
|
+
}) => EC[] | Promise<EC[]>;
|
|
11
|
+
export type AppViewsBuilder = (params: {
|
|
12
|
+
user: User | null;
|
|
13
|
+
authController: AuthController;
|
|
14
|
+
data: RebaseData;
|
|
15
|
+
}) => AppView[] | Promise<AppView[]>;
|
package/dist/types/chips.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export type ColorScheme = {
|
|
|
2
2
|
color: string;
|
|
3
3
|
text: string;
|
|
4
4
|
};
|
|
5
|
-
export type ColorKey = "
|
|
5
|
+
export type ColorKey = "blue" | "cyan" | "teal" | "green" | "yellow" | "orange" | "red" | "pink" | "purple" | "gray" | "indigo" | "violet" | "fuchsia" | "rose" | "emerald";
|