@rebasepro/types 0.30.0 → 0.31.0-canary.g59cd6fd
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 +16 -18
- package/dist/call_context.d.ts +3 -3
- package/dist/controllers/client.d.ts +29 -0
- package/dist/controllers/data.d.ts +85 -332
- package/dist/controllers/data_driver.d.ts +47 -57
- package/dist/controllers/index.d.ts +0 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +2567 -1151
- package/dist/index.es.js.map +1 -1
- package/dist/schema/column_options.d.ts +336 -0
- package/dist/schema/column_type.d.ts +116 -0
- package/dist/schema/columns.d.ts +646 -0
- package/dist/schema/compiled.d.ts +114 -0
- package/dist/schema/descriptor.d.ts +349 -0
- package/dist/schema/hooks.d.ts +164 -0
- package/dist/schema/index.d.ts +13 -0
- package/dist/schema/infer.d.ts +340 -0
- package/dist/schema/json.d.ts +237 -0
- package/dist/schema/relations.d.ts +205 -0
- package/dist/schema/table.d.ts +304 -0
- package/dist/schema/table_options.d.ts +103 -0
- package/dist/schema/table_patch.d.ts +338 -0
- package/dist/types/auth_adapter.d.ts +12 -6
- package/dist/types/auth_hooks.d.ts +65 -0
- package/dist/types/backend.d.ts +85 -96
- package/dist/types/data_source.d.ts +4 -9
- package/dist/types/database_adapter.d.ts +30 -31
- package/dist/types/entities.d.ts +0 -162
- package/dist/types/filter-operators.d.ts +2 -26
- package/dist/types/history.d.ts +6 -9
- package/dist/types/index.d.ts +3 -9
- package/dist/types/mcp_app_modules.d.ts +0 -2
- package/dist/types/policy.d.ts +85 -10
- package/dist/types/project_manifest.d.ts +113 -46
- package/dist/types/read_query.d.ts +98 -0
- package/dist/types/register.d.ts +35 -5
- package/dist/types/relations.d.ts +0 -430
- package/dist/types/schema_editing.d.ts +54 -2
- package/dist/types/schema_version.d.ts +24 -4
- package/dist/types/security_rules.d.ts +225 -15
- package/dist/types/storage_authorize.d.ts +2 -2
- package/dist/types/tenancy.d.ts +3 -3
- package/dist/types/ui_preferences.d.ts +228 -0
- package/package.json +3 -2
- package/dist/controllers/auth_state.d.ts +0 -23
- package/dist/controllers/collection_registry.d.ts +0 -67
- package/dist/controllers/effective_role.d.ts +0 -4
- package/dist/types/admin_block.d.ts +0 -96
- package/dist/types/chips.d.ts +0 -16
- package/dist/types/collection_contract.d.ts +0 -43
- package/dist/types/collection_patch.d.ts +0 -74
- package/dist/types/collections.d.ts +0 -783
- package/dist/types/component_ref.d.ts +0 -81
- package/dist/types/conditions-contract.types.d.ts +0 -14
- package/dist/types/entity_callbacks.d.ts +0 -393
- package/dist/types/indexes.d.ts +0 -179
- package/dist/types/properties.d.ts +0 -1640
package/dist/types/backend.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { FilterValues, WhereFilterOp } from "./filter-operators.js";
|
|
2
|
+
import type { TableHooks } from "../schema/hooks.js";
|
|
3
|
+
import type { CompiledTable } from "../schema/compiled.js";
|
|
4
|
+
import type { TableDescriptor } from "../schema/descriptor.js";
|
|
3
5
|
import type { OrderByTuple } from "./filter-operators.js";
|
|
4
6
|
import type { LogicalCondition } from "../controllers/data.js";
|
|
5
7
|
import type { AuthAdapter } from "./auth_adapter.js";
|
|
@@ -14,7 +16,7 @@ import type { ApiKeyKind } from "./api_keys.js";
|
|
|
14
16
|
*/
|
|
15
17
|
export interface DatabaseConnection {
|
|
16
18
|
/**
|
|
17
|
-
* Type identifier for this database (e.g., 'postgres'
|
|
19
|
+
* Type identifier for this database (e.g., 'postgres')
|
|
18
20
|
*/
|
|
19
21
|
readonly type: string;
|
|
20
22
|
/**
|
|
@@ -47,7 +49,6 @@ export interface FetchCollectionOptions<M extends Record<string, unknown> = Reco
|
|
|
47
49
|
startAfter?: unknown;
|
|
48
50
|
searchString?: string;
|
|
49
51
|
databaseId?: string;
|
|
50
|
-
collection?: CollectionConfig;
|
|
51
52
|
}
|
|
52
53
|
/**
|
|
53
54
|
* Options for searching entities
|
|
@@ -59,7 +60,6 @@ export interface SearchOptions<M extends Record<string, unknown> = Record<string
|
|
|
59
60
|
order?: "desc" | "asc";
|
|
60
61
|
limit?: number;
|
|
61
62
|
databaseId?: string;
|
|
62
|
-
collection?: CollectionConfig;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* Options for counting entities
|
|
@@ -83,7 +83,7 @@ export interface CountOptions<M extends Record<string, unknown> = Record<string,
|
|
|
83
83
|
* Note: This interface can be implemented as instance methods or as a class with static methods.
|
|
84
84
|
* For static implementations (like DrizzleConditionBuilder), use the ConditionBuilderStatic type.
|
|
85
85
|
*
|
|
86
|
-
* @template T The type of condition returned by the builder (e.g., SQL for PostgreSQL
|
|
86
|
+
* @template T The type of condition returned by the builder (e.g., SQL for PostgreSQL)
|
|
87
87
|
*/
|
|
88
88
|
export interface ConditionBuilder<T = unknown> {
|
|
89
89
|
/**
|
|
@@ -397,51 +397,30 @@ export interface RealtimeCounts {
|
|
|
397
397
|
busFramesSkipped: number;
|
|
398
398
|
}
|
|
399
399
|
/**
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
*/
|
|
407
|
-
register(collection: CollectionConfig): void;
|
|
408
|
-
/**
|
|
409
|
-
* Get a collection by its path
|
|
410
|
-
*/
|
|
411
|
-
getCollectionByPath(path: string): CollectionConfig | undefined;
|
|
412
|
-
/**
|
|
413
|
-
* Get all registered collections
|
|
414
|
-
*/
|
|
415
|
-
getCollections(): CollectionConfig[];
|
|
416
|
-
/**
|
|
417
|
-
* Get the currently registered global callbacks, if any.
|
|
418
|
-
*/
|
|
419
|
-
getGlobalCallbacks(): any | undefined;
|
|
420
|
-
/**
|
|
421
|
-
* Take the global callbacks declared on `initializeRebaseBackend({ callbacks })`.
|
|
422
|
-
*
|
|
423
|
-
* A driver resolves callbacks from the registry it builds for itself, so
|
|
424
|
-
* this is how the backend's global ones reach it: the coordinator hands
|
|
425
|
-
* them over after `initializeDriver` returns. Optional so a registry for a
|
|
426
|
-
* driver that runs no callbacks still type-checks, but a project that
|
|
427
|
-
* declares global callbacks over a registry without it is refused at boot
|
|
428
|
-
* — hooks that never run look exactly like hooks that passed.
|
|
429
|
-
*/
|
|
430
|
-
setGlobalCallbacks?(callbacks: CollectionCallbacks): void;
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Abstract data transformer interface.
|
|
434
|
-
* Handles serialization/deserialization between frontend and database formats.
|
|
400
|
+
* The table registry a data driver builds for itself and returns on
|
|
401
|
+
* `InitializedDriver.tableRegistry`: the compiled tables it serves, by
|
|
402
|
+
* slug. The backend hands it the global hooks and later table hooks through
|
|
403
|
+
* it; it never holds a collection.
|
|
404
|
+
*
|
|
405
|
+
* @group Backend
|
|
435
406
|
*/
|
|
436
|
-
export interface
|
|
407
|
+
export interface TableRegistryInterface {
|
|
408
|
+
/** The table served at `/api/data/<slug>`, or `undefined`. */
|
|
409
|
+
getTable(slug: string): {
|
|
410
|
+
readonly descriptor: TableDescriptor;
|
|
411
|
+
} | undefined;
|
|
437
412
|
/**
|
|
438
|
-
*
|
|
413
|
+
* Take the global table hooks declared on `initializeRebaseBackend({ hooks })`.
|
|
414
|
+
* Optional so a registry for a driver that runs no hooks still
|
|
415
|
+
* type-checks; a project declaring global hooks over a registry without
|
|
416
|
+
* it is refused at boot.
|
|
439
417
|
*/
|
|
440
|
-
|
|
418
|
+
setGlobalHooks?(hooks: TableHooks): void;
|
|
441
419
|
/**
|
|
442
|
-
*
|
|
420
|
+
* Replace one table's own hooks after boot (`backend.setTableHooks`).
|
|
421
|
+
* Returns whether this registry serves the table.
|
|
443
422
|
*/
|
|
444
|
-
|
|
423
|
+
setTableHooks?(slug: string, hooks: TableHooks): boolean;
|
|
445
424
|
}
|
|
446
425
|
/**
|
|
447
426
|
* The table column a value of a {@link SqlScriptResult} was read from, as the
|
|
@@ -730,28 +709,8 @@ export interface SQLAdmin {
|
|
|
730
709
|
onReconnect?: () => void;
|
|
731
710
|
}): Promise<() => Promise<void>>;
|
|
732
711
|
}
|
|
733
|
-
/**
|
|
734
|
-
* Administrative operations for document-based databases (MongoDB, Firestore, etc.).
|
|
735
|
-
* Used by future document administration tools.
|
|
736
|
-
*
|
|
737
|
-
* @group Admin
|
|
738
|
-
*/
|
|
739
|
-
export interface DocumentAdmin {
|
|
740
|
-
/**
|
|
741
|
-
* Execute an aggregation pipeline or equivalent query.
|
|
742
|
-
*/
|
|
743
|
-
executeAggregate?(pipeline: Record<string, unknown>[]): Promise<Record<string, unknown>[]>;
|
|
744
|
-
/**
|
|
745
|
-
* Fetch statistics for a collection (document count, size, etc.).
|
|
746
|
-
*/
|
|
747
|
-
fetchCollectionStats?(collectionName: string): Promise<{
|
|
748
|
-
count: number;
|
|
749
|
-
sizeBytes?: number;
|
|
750
|
-
}>;
|
|
751
|
-
}
|
|
752
712
|
/**
|
|
753
713
|
* Administrative operations for schema management.
|
|
754
|
-
* Shared across SQL and document databases.
|
|
755
714
|
*
|
|
756
715
|
* @group Admin
|
|
757
716
|
*/
|
|
@@ -1060,12 +1019,12 @@ export interface BranchMergeResult {
|
|
|
1060
1019
|
* Union type for all admin capabilities.
|
|
1061
1020
|
* A backend may implement any combination of these interfaces.
|
|
1062
1021
|
*
|
|
1063
|
-
* Use type guards (`isSQLAdmin`, `
|
|
1022
|
+
* Use type guards (`isSQLAdmin`, `isSchemaAdmin`, `isBranchAdmin`)
|
|
1064
1023
|
* to safely narrow the type before calling methods.
|
|
1065
1024
|
*
|
|
1066
1025
|
* @group Admin
|
|
1067
1026
|
*/
|
|
1068
|
-
export type DatabaseAdmin = Partial<SQLAdmin> & Partial<
|
|
1027
|
+
export type DatabaseAdmin = Partial<SQLAdmin> & Partial<SchemaAdmin> & Partial<BranchAdmin> & Partial<SchemaEditingAdmin>;
|
|
1069
1028
|
/**
|
|
1070
1029
|
* Type guard: can this admin plan a live schema change?
|
|
1071
1030
|
*
|
|
@@ -1083,11 +1042,6 @@ export declare function isSchemaEditingAdmin(admin: DatabaseAdmin | undefined):
|
|
|
1083
1042
|
* @group Admin
|
|
1084
1043
|
*/
|
|
1085
1044
|
export declare function isSQLAdmin(admin: DatabaseAdmin | undefined): admin is SQLAdmin;
|
|
1086
|
-
/**
|
|
1087
|
-
* Type guard: does this admin support document operations?
|
|
1088
|
-
* @group Admin
|
|
1089
|
-
*/
|
|
1090
|
-
export declare function isDocumentAdmin(admin: DatabaseAdmin | undefined): admin is DocumentAdmin;
|
|
1091
1045
|
/**
|
|
1092
1046
|
* Type guard: does this admin support schema management?
|
|
1093
1047
|
* @group Admin
|
|
@@ -1165,10 +1119,8 @@ export interface BackendInstance extends BackendLifecycle {
|
|
|
1165
1119
|
* Realtime provider for subscriptions
|
|
1166
1120
|
*/
|
|
1167
1121
|
realtimeProvider: RealtimeProvider;
|
|
1168
|
-
/**
|
|
1169
|
-
|
|
1170
|
-
*/
|
|
1171
|
-
collectionRegistry: CollectionRegistryInterface;
|
|
1122
|
+
/** The driver's table registry. */
|
|
1123
|
+
tableRegistry: TableRegistryInterface;
|
|
1172
1124
|
/**
|
|
1173
1125
|
* The underlying database connection
|
|
1174
1126
|
*/
|
|
@@ -1349,7 +1301,7 @@ export interface BackendBootstrapper {
|
|
|
1349
1301
|
/**
|
|
1350
1302
|
* Which driver type this bootstrapper handles.
|
|
1351
1303
|
* Must match the `type` field on the driver config object
|
|
1352
|
-
* (e.g., `"postgres"
|
|
1304
|
+
* (e.g., `"postgres"`).
|
|
1353
1305
|
*/
|
|
1354
1306
|
type: string;
|
|
1355
1307
|
/**
|
|
@@ -1418,7 +1370,7 @@ export interface BackendBootstrapper {
|
|
|
1418
1370
|
* the caller treats a throw as fatal.
|
|
1419
1371
|
*
|
|
1420
1372
|
* `driverResult` is optional for the same reason as
|
|
1421
|
-
* {@link
|
|
1373
|
+
* {@link ensureTableSchema}: this runs before `initializeDriver`, so an
|
|
1422
1374
|
* adapter that was constructed with its own connection has to fall back to
|
|
1423
1375
|
* it.
|
|
1424
1376
|
*/
|
|
@@ -1444,12 +1396,12 @@ export interface BackendBootstrapper {
|
|
|
1444
1396
|
* `undefined` — dereferencing it unconditionally works for managed tenants
|
|
1445
1397
|
* and breaks every app that builds its own adapter.
|
|
1446
1398
|
*/
|
|
1447
|
-
|
|
1399
|
+
ensureTableSchema?(tables: readonly CompiledTable[], driverResult?: InitializedDriver, log?: (message: string) => void): Promise<{
|
|
1448
1400
|
applied: number;
|
|
1449
1401
|
}>;
|
|
1450
1402
|
/**
|
|
1451
1403
|
* Apply the collections' row-level-security policies, additively and
|
|
1452
|
-
* idempotently — the companion to {@link
|
|
1404
|
+
* idempotently — the companion to {@link ensureTableSchema}.
|
|
1453
1405
|
*
|
|
1454
1406
|
* That method creates the tables; a table with RLS disabled and no policies
|
|
1455
1407
|
* is not servable, because authenticated requests run as a restricted role:
|
|
@@ -1463,7 +1415,7 @@ export interface BackendBootstrapper {
|
|
|
1463
1415
|
* Runs after auth initialization, because the generated policies call the
|
|
1464
1416
|
* `auth.*` helper functions and `CREATE POLICY` validates they exist.
|
|
1465
1417
|
*/
|
|
1466
|
-
|
|
1418
|
+
ensureTablePolicies?(tables: readonly CompiledTable[], driverResult?: InitializedDriver, log?: (message: string) => void): Promise<{
|
|
1467
1419
|
applied: number;
|
|
1468
1420
|
}>;
|
|
1469
1421
|
/**
|
|
@@ -1494,10 +1446,10 @@ export interface BackendBootstrapper {
|
|
|
1494
1446
|
*/
|
|
1495
1447
|
finalizeSecurityPosture?(driverResult: InitializedDriver): Promise<void>;
|
|
1496
1448
|
/**
|
|
1497
|
-
* Read the
|
|
1449
|
+
* Read the schema version this database was last provisioned
|
|
1498
1450
|
* from, or `null` when nothing has ever stamped it.
|
|
1499
1451
|
*
|
|
1500
|
-
* The companion to {@link
|
|
1452
|
+
* The companion to {@link stampTablesSchemaVersion}: one process writes
|
|
1501
1453
|
* what it applied, every other process compares itself to it. This is what
|
|
1502
1454
|
* lets a split deployment — several processes over one database, only one of
|
|
1503
1455
|
* which provisions — notice that a unit is serving against a schema it was
|
|
@@ -1509,17 +1461,17 @@ export interface BackendBootstrapper {
|
|
|
1509
1461
|
* provisioned before the stamp existed reads this way, and so does every
|
|
1510
1462
|
* fresh one until its first provisioning boot finishes.
|
|
1511
1463
|
*/
|
|
1512
|
-
|
|
1464
|
+
readTablesSchemaVersion?(driverResult?: InitializedDriver): Promise<string | null>;
|
|
1513
1465
|
/**
|
|
1514
|
-
* Record the
|
|
1466
|
+
* Record the schema version this process just applied.
|
|
1515
1467
|
*
|
|
1516
1468
|
* Called only by the process that provisions, and only after both
|
|
1517
|
-
* {@link
|
|
1469
|
+
* {@link ensureTableSchema} and {@link ensureTablePolicies} have
|
|
1518
1470
|
* run — a stamp written before the policies would claim a schema that is
|
|
1519
1471
|
* only half in place, and the half that is missing is the one that fails
|
|
1520
1472
|
* without an error.
|
|
1521
1473
|
*/
|
|
1522
|
-
|
|
1474
|
+
stampTablesSchemaVersion?(version: string, driverResult?: InitializedDriver): Promise<void>;
|
|
1523
1475
|
/**
|
|
1524
1476
|
* Initialize WebSocket server for realtime operations.
|
|
1525
1477
|
*/
|
|
@@ -1534,17 +1486,19 @@ export interface InitializedDriver {
|
|
|
1534
1486
|
driver: import("../controllers/data_driver.js").DataDriver;
|
|
1535
1487
|
/** The realtime service, if the driver created one during init. */
|
|
1536
1488
|
realtimeProvider?: RealtimeProvider;
|
|
1537
|
-
/**
|
|
1538
|
-
|
|
1489
|
+
/** The driver's table registry: what the backend hands global and table hooks to. */
|
|
1490
|
+
tableRegistry?: TableRegistryInterface;
|
|
1539
1491
|
/**
|
|
1540
|
-
*
|
|
1541
|
-
*
|
|
1542
|
-
*
|
|
1543
|
-
*
|
|
1492
|
+
* The descriptors of the tables the driver derived from the live database
|
|
1493
|
+
* schema, read from the catalogue (columns as Postgres types, relations
|
|
1494
|
+
* from foreign keys, row-level security from `pg_policies`): what the
|
|
1495
|
+
* server serves, and `GET /api/schema/tables` describes, for a project
|
|
1496
|
+
* that declares no tables. Set by drivers that introspect (`baas` mode);
|
|
1497
|
+
* `undefined` means the driver never looked.
|
|
1544
1498
|
*/
|
|
1545
|
-
|
|
1499
|
+
tables?: import("../schema/descriptor.js").TableDescriptor[];
|
|
1546
1500
|
/**
|
|
1547
|
-
* Tables the driver found while deriving {@link
|
|
1501
|
+
* Tables the driver found while deriving {@link tables} and did not
|
|
1548
1502
|
* serve, because row-level security is disabled on them and so they have
|
|
1549
1503
|
* no authorization model (`baas.unprotectedTables` left at `"exclude"`).
|
|
1550
1504
|
*
|
|
@@ -1555,6 +1509,25 @@ export interface InitializedDriver {
|
|
|
1555
1509
|
schema: string;
|
|
1556
1510
|
table: string;
|
|
1557
1511
|
}[];
|
|
1512
|
+
/**
|
|
1513
|
+
* Serve these tables from now on, without a restart: what a live schema
|
|
1514
|
+
* apply (`/api/admin/schema/apply`) calls once its DDL has run, with
|
|
1515
|
+
* every compiled table the edited schema holds (hooks included).
|
|
1516
|
+
*
|
|
1517
|
+
* A driver that can MUST re-read the tables it stores from its own
|
|
1518
|
+
* database (a new table, a new or retyped column, a new relation and its
|
|
1519
|
+
* junction), keep the hooks the compiled tables carry, provision whatever
|
|
1520
|
+
* it provisions at boot for a table it did not serve before (change
|
|
1521
|
+
* capture, grants), stop serving a table the list no longer holds, and
|
|
1522
|
+
* swap all of it at once: a request sees the tables before the call or
|
|
1523
|
+
* those after it. A driver whose tables are unchanged by the list (the
|
|
1524
|
+
* edit touched another database's) MUST NOT read its catalogue again.
|
|
1525
|
+
*
|
|
1526
|
+
* Absent on a driver that cannot: the apply then says the change is
|
|
1527
|
+
* applied and served after a restart (`serving` on the result).
|
|
1528
|
+
* Rejecting leaves the driver serving the tables it served before.
|
|
1529
|
+
*/
|
|
1530
|
+
refreshTables?(tables: readonly CompiledTable[]): Promise<TableRefreshOutcome>;
|
|
1558
1531
|
/** The underlying database connection (for lifecycle management). */
|
|
1559
1532
|
connection?: DatabaseConnection;
|
|
1560
1533
|
/**
|
|
@@ -1564,6 +1537,22 @@ export interface InitializedDriver {
|
|
|
1564
1537
|
*/
|
|
1565
1538
|
internals?: unknown;
|
|
1566
1539
|
}
|
|
1540
|
+
/**
|
|
1541
|
+
* What a driver did with the tables a live schema apply handed it
|
|
1542
|
+
* ({@link InitializedDriver.refreshTables}).
|
|
1543
|
+
*
|
|
1544
|
+
* - `served` — it serves them now.
|
|
1545
|
+
* - `restart` — it keeps serving the tables it opened with until the process
|
|
1546
|
+
* restarts; `reason` says why, in a sentence the Studio shows.
|
|
1547
|
+
*
|
|
1548
|
+
* @group Backend
|
|
1549
|
+
*/
|
|
1550
|
+
export type TableRefreshOutcome = {
|
|
1551
|
+
status: "served";
|
|
1552
|
+
} | {
|
|
1553
|
+
status: "restart";
|
|
1554
|
+
reason: string;
|
|
1555
|
+
};
|
|
1567
1556
|
/**
|
|
1568
1557
|
* Result of `BackendBootstrapper.initializeAuth()`.
|
|
1569
1558
|
* @group Backend
|
|
@@ -2,7 +2,7 @@ import { WhereFilterOp } from "./filter-operators.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Describes the capabilities and features supported by a data source (driver).
|
|
4
4
|
*
|
|
5
|
-
* Each driver (Postgres, Firebase,
|
|
5
|
+
* Each driver (Postgres, Firebase, etc.) declares which features it
|
|
6
6
|
* supports. The admin uses this descriptor to:
|
|
7
7
|
* - Show/hide editor tabs (e.g. Relations for SQL, Subcollections for Firebase)
|
|
8
8
|
* - Filter the property type picker (e.g. `relation` for SQL, `reference` for Firebase)
|
|
@@ -11,7 +11,7 @@ import { WhereFilterOp } from "./filter-operators.js";
|
|
|
11
11
|
* @group Models
|
|
12
12
|
*/
|
|
13
13
|
export interface DataSourceCapabilities {
|
|
14
|
-
/** Unique driver key (e.g. "postgres", "firestore"
|
|
14
|
+
/** Unique driver key (e.g. "postgres", "firestore") */
|
|
15
15
|
key: string;
|
|
16
16
|
/** Human-readable label for the UI (e.g. "PostgreSQL", "Firebase / Firestore") */
|
|
17
17
|
label: string;
|
|
@@ -102,8 +102,6 @@ export interface DataSourceCapabilities {
|
|
|
102
102
|
relationAggregateSorts?: boolean;
|
|
103
103
|
/** Does this source support SQL admin operations (SQL editor, EXPLAIN, etc.)? */
|
|
104
104
|
supportsSQLAdmin: boolean;
|
|
105
|
-
/** Does this source support document admin operations (aggregation, stats)? */
|
|
106
|
-
supportsDocumentAdmin: boolean;
|
|
107
105
|
/** Does this source support schema admin (unmapped tables, table metadata)? */
|
|
108
106
|
supportsSchemaAdmin: boolean;
|
|
109
107
|
}
|
|
@@ -125,8 +123,7 @@ export declare const DEFAULT_DATA_SOURCE_KEY = "(default)";
|
|
|
125
123
|
*
|
|
126
124
|
* - `"server"` — through the Rebase backend (the `RebaseClient`). The backend
|
|
127
125
|
* holds the actual database adapter and routes by data-source key. This is
|
|
128
|
-
* the default and covers Postgres,
|
|
129
|
-
* engine.
|
|
126
|
+
* the default and covers Postgres, the only server engine.
|
|
130
127
|
* - `"direct"` — straight from the client to the external backend via its own
|
|
131
128
|
* SDK driver (e.g. Firestore). The Rebase backend is not in the data path.
|
|
132
129
|
* - `"custom"` — a developer-supplied {@link DataDriver}, transport unspecified.
|
|
@@ -152,7 +149,7 @@ export interface DataSourceDefinition {
|
|
|
152
149
|
*/
|
|
153
150
|
key: string;
|
|
154
151
|
/**
|
|
155
|
-
* The engine backing this data source (e.g. `"postgres"`,
|
|
152
|
+
* The engine backing this data source (e.g. `"postgres"`,
|
|
156
153
|
* `"firestore"`, or a custom id). Determines the
|
|
157
154
|
* {@link DataSourceCapabilities} surfaced in the editor.
|
|
158
155
|
*/
|
|
@@ -205,8 +202,6 @@ export declare const DEFAULT_FILTERABLE_RELATION_KINDS: readonly string[];
|
|
|
205
202
|
export declare const POSTGRES_CAPABILITIES: DataSourceCapabilities;
|
|
206
203
|
/** @group Models */
|
|
207
204
|
export declare const FIREBASE_CAPABILITIES: DataSourceCapabilities;
|
|
208
|
-
/** @group Models */
|
|
209
|
-
export declare const MONGODB_CAPABILITIES: DataSourceCapabilities;
|
|
210
205
|
/**
|
|
211
206
|
* Fallback capabilities when the driver is unknown.
|
|
212
207
|
* Enables everything so nothing is hidden unexpectedly.
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
* @group Backend
|
|
21
21
|
*/
|
|
22
22
|
import type { DataDriver } from "../controllers/data_driver.js";
|
|
23
|
-
import type {
|
|
24
|
-
import type {
|
|
23
|
+
import type { CompiledTable } from "../schema/compiled.js";
|
|
24
|
+
import type { DatabaseAdmin, InitializedDriver, RealtimeProvider, RealtimeSocketOptions, BootstrappedAuth } from "./backend.js";
|
|
25
25
|
import type { HistoryConfig } from "../controllers/client.js";
|
|
26
26
|
/**
|
|
27
27
|
* A `DatabaseAdapter` provides data persistence for Rebase.
|
|
@@ -32,7 +32,7 @@ export interface DatabaseAdapter {
|
|
|
32
32
|
/**
|
|
33
33
|
* Which database engine this adapter handles.
|
|
34
34
|
*
|
|
35
|
-
* @example "postgres"
|
|
35
|
+
* @example "postgres"
|
|
36
36
|
*/
|
|
37
37
|
readonly type: string;
|
|
38
38
|
/**
|
|
@@ -40,8 +40,8 @@ export interface DatabaseAdapter {
|
|
|
40
40
|
*
|
|
41
41
|
* This is the only **required** method.
|
|
42
42
|
*
|
|
43
|
-
* @param config - Coordinator-provided config
|
|
44
|
-
*
|
|
43
|
+
* @param config - Coordinator-provided config: the compiled tables the
|
|
44
|
+
* backend declares, and how the driver may open.
|
|
45
45
|
*/
|
|
46
46
|
initializeDriver(config: DatabaseAdapterInitConfig): Promise<InitializedDriver>;
|
|
47
47
|
/**
|
|
@@ -91,7 +91,7 @@ export interface DatabaseAdapter {
|
|
|
91
91
|
verifyConnection?(driverResult?: InitializedDriver): Promise<void>;
|
|
92
92
|
/**
|
|
93
93
|
* Bring the database's collection tables up to date, additively — the boot
|
|
94
|
-
* companion to `db push`. See `BackendBootstrapper.
|
|
94
|
+
* companion to `db push`. See `BackendBootstrapper.ensureTableSchema`
|
|
95
95
|
* for the contract (create-only; never drop, narrow, or rewrite).
|
|
96
96
|
*
|
|
97
97
|
* Optional, and MUST be forwarded by any wrapper that turns this adapter
|
|
@@ -107,20 +107,20 @@ export interface DatabaseAdapter {
|
|
|
107
107
|
* it was constructed with. An adapter that dereferences `driverResult`
|
|
108
108
|
* unconditionally works for managed tenants and breaks every self-built one.
|
|
109
109
|
*/
|
|
110
|
-
|
|
110
|
+
ensureTableSchema?(tables: readonly CompiledTable[], driverResult?: InitializedDriver, log?: (message: string) => void): Promise<{
|
|
111
111
|
applied: number;
|
|
112
112
|
}>;
|
|
113
113
|
/**
|
|
114
114
|
* Apply the collections' RLS policies (ENABLE ROW LEVEL SECURITY + the
|
|
115
115
|
* `securityRules` compiled to `CREATE POLICY`) — the boot companion to the
|
|
116
116
|
* policy half of `db push`. Idempotent; see
|
|
117
|
-
* `BackendBootstrapper.
|
|
117
|
+
* `BackendBootstrapper.ensureTablePolicies`.
|
|
118
118
|
*
|
|
119
|
-
* Same forwarding requirement as `
|
|
119
|
+
* Same forwarding requirement as `ensureTableSchema`: without the
|
|
120
120
|
* policies, tables exist but every user-context read is denied (a public
|
|
121
121
|
* collection answers 401).
|
|
122
122
|
*/
|
|
123
|
-
|
|
123
|
+
ensureTablePolicies?(tables: readonly CompiledTable[], driverResult?: InitializedDriver, log?: (message: string) => void): Promise<{
|
|
124
124
|
applied: number;
|
|
125
125
|
}>;
|
|
126
126
|
/**
|
|
@@ -132,7 +132,7 @@ export interface DatabaseAdapter {
|
|
|
132
132
|
* either, so every policy on it failed to create and every user read was
|
|
133
133
|
* denied — a collection declared on `database("analytics")` answered 401 on
|
|
134
134
|
* a healthy-looking backend. Idempotent; runs before
|
|
135
|
-
* `
|
|
135
|
+
* `ensureTablePolicies` on every non-default source.
|
|
136
136
|
*/
|
|
137
137
|
ensureRlsRuntime?(driverResult?: InitializedDriver): Promise<void>;
|
|
138
138
|
/**
|
|
@@ -146,7 +146,7 @@ export interface DatabaseAdapter {
|
|
|
146
146
|
*/
|
|
147
147
|
finalizeSecurityPosture?(driverResult: InitializedDriver): Promise<void>;
|
|
148
148
|
/**
|
|
149
|
-
* Read the
|
|
149
|
+
* Read the schema version this database was last provisioned
|
|
150
150
|
* from, or `null` when nothing has ever stamped it.
|
|
151
151
|
*
|
|
152
152
|
* `null` is not an error and MUST NOT be treated as one — every database
|
|
@@ -157,15 +157,15 @@ export interface DatabaseAdapter {
|
|
|
157
157
|
* it turns the check off, and a check that is off looks exactly like a check
|
|
158
158
|
* that passed.
|
|
159
159
|
*/
|
|
160
|
-
|
|
160
|
+
readTablesSchemaVersion?(driverResult?: InitializedDriver): Promise<string | null>;
|
|
161
161
|
/**
|
|
162
|
-
* Record the
|
|
162
|
+
* Record the schema version this process just applied.
|
|
163
163
|
*
|
|
164
164
|
* Called only by the process that provisions, and only after the tables AND
|
|
165
165
|
* the policies are in place — a stamp written earlier would claim a schema
|
|
166
166
|
* that a half-finished boot never finished creating.
|
|
167
167
|
*/
|
|
168
|
-
|
|
168
|
+
stampTablesSchemaVersion?(version: string, driverResult?: InitializedDriver): Promise<void>;
|
|
169
169
|
/**
|
|
170
170
|
* Return admin capabilities for this database (SQL editor, schema browser, branching).
|
|
171
171
|
*/
|
|
@@ -189,21 +189,20 @@ export interface DatabaseAdapter {
|
|
|
189
189
|
* @group Backend
|
|
190
190
|
*/
|
|
191
191
|
export interface DatabaseAdapterInitConfig {
|
|
192
|
-
/** Registered collection definitions. */
|
|
193
|
-
collections: CollectionConfig[];
|
|
194
192
|
/**
|
|
195
|
-
* The
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
193
|
+
* The tables the backend declares, compiled (`compileSchema`): each
|
|
194
|
+
* descriptor with its hooks, field-level hooks and definition — what a
|
|
195
|
+
* driver builds its runtime model of each table from. Absent (or empty)
|
|
196
|
+
* when the driver introspects the database, which describes its own tables.
|
|
199
197
|
*/
|
|
200
|
-
|
|
198
|
+
tables?: import("../schema/compiled.js").CompiledTable[];
|
|
201
199
|
/**
|
|
202
|
-
* The
|
|
203
|
-
*
|
|
204
|
-
*
|
|
200
|
+
* The data-source key this driver serves — `(default)`, or a declared
|
|
201
|
+
* one such as `analytics`. A driver given every table needs it to know
|
|
202
|
+
* which are its own: the ones whose `database` names this key, or name
|
|
203
|
+
* none when this is the default.
|
|
205
204
|
*/
|
|
206
|
-
|
|
205
|
+
dataSourceKey?: string;
|
|
207
206
|
/**
|
|
208
207
|
* Whether opening the driver may change the database (default `true`).
|
|
209
208
|
*
|
|
@@ -224,15 +223,15 @@ export interface DatabaseAdapterInitConfig {
|
|
|
224
223
|
/**
|
|
225
224
|
* Whether this driver should describe its own schema.
|
|
226
225
|
*
|
|
227
|
-
* True when the project declared no
|
|
228
|
-
*
|
|
229
|
-
*
|
|
226
|
+
* True when the project declared no tables, so there is nothing to serve
|
|
227
|
+
* unless the driver reads the live database and reports what it found on
|
|
228
|
+
* `InitializedDriver.tables`. Drivers that cannot introspect may
|
|
230
229
|
* ignore it — `initializeRebaseBackend` fails the boot with their name
|
|
231
230
|
* rather than serving nothing.
|
|
232
231
|
*
|
|
233
232
|
* This was a `mode: "cms" | "baas"` flag, which was never independent of
|
|
234
|
-
*
|
|
235
|
-
* before acting on it, so the flag could only ever agree or contradict.
|
|
233
|
+
* the declared tables: every consumer already required the list to be
|
|
234
|
+
* empty before acting on it, so the flag could only ever agree or contradict.
|
|
236
235
|
*/
|
|
237
236
|
introspectCollections?: boolean;
|
|
238
237
|
/**
|