@rebasepro/server-postgres 0.9.1-canary.d198c11 → 0.9.1-canary.d906fb7
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/dist/PostgresBootstrapper.d.ts +10 -0
- package/dist/collections/buildRegistry.d.ts +27 -0
- package/dist/data-transformer.d.ts +9 -2
- package/dist/index.es.js +474 -292
- package/dist/index.es.js.map +1 -1
- package/dist/services/FetchService.d.ts +4 -32
- package/dist/services/RelationService.d.ts +34 -1
- package/dist/services/collection-helpers.d.ts +76 -0
- package/dist/services/index.d.ts +1 -1
- package/dist/services/realtimeService.d.ts +7 -0
- package/dist/services/row-pipeline.d.ts +63 -0
- package/package.json +10 -7
- package/src/PostgresBackendDriver.ts +39 -11
- package/src/PostgresBootstrapper.ts +62 -25
- package/src/collections/buildRegistry.ts +59 -0
- package/src/data-transformer.ts +11 -9
- package/src/schema/introspect-db.ts +19 -2
- package/src/services/FetchService.ts +50 -229
- package/src/services/PersistService.ts +9 -2
- package/src/services/RelationService.ts +153 -94
- package/src/services/collection-helpers.ts +166 -3
- package/src/services/index.ts +1 -0
- package/src/services/realtimeService.ts +40 -19
- package/src/services/row-pipeline.ts +215 -0
- package/src/utils/drizzle-conditions.ts +13 -0
|
@@ -9,6 +9,7 @@ import { PostgresBackendDriver } from "./PostgresBackendDriver";
|
|
|
9
9
|
import { RealtimeService } from "./services/realtimeService";
|
|
10
10
|
import { DatabasePoolManager } from "./databasePoolManager";
|
|
11
11
|
import { PostgresCollectionRegistry } from "./collections/PostgresCollectionRegistry";
|
|
12
|
+
import { type CdcTableRef } from "./services/cdc/trigger-cdc";
|
|
12
13
|
export interface PostgresDriverConfig {
|
|
13
14
|
connectionString?: string;
|
|
14
15
|
adminConnectionString?: string;
|
|
@@ -36,6 +37,15 @@ export interface PostgresDriverInternals {
|
|
|
36
37
|
realtimeService: RealtimeService;
|
|
37
38
|
driver: PostgresBackendDriver;
|
|
38
39
|
poolManager?: DatabasePoolManager;
|
|
40
|
+
/**
|
|
41
|
+
* Attach CDC triggers to tables that did not exist when the driver
|
|
42
|
+
* bootstrapped. Only set when database-level capture is actually active.
|
|
43
|
+
*
|
|
44
|
+
* Auth owns its own tables and creates them later in boot, so at driver
|
|
45
|
+
* bootstrap they are legitimately missing and get skipped; without this
|
|
46
|
+
* they would stay uninstrumented until the next restart.
|
|
47
|
+
*/
|
|
48
|
+
provisionCdcForTables?: (tables: CdcTableRef[]) => Promise<void>;
|
|
39
49
|
}
|
|
40
50
|
/**
|
|
41
51
|
* Default PostgreSQL bootstrapper.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Relations } from "drizzle-orm";
|
|
2
|
+
import { PgEnum } from "drizzle-orm/pg-core";
|
|
3
|
+
import { CollectionConfig } from "@rebasepro/types";
|
|
4
|
+
import { PostgresCollectionRegistry } from "./PostgresCollectionRegistry";
|
|
5
|
+
/**
|
|
6
|
+
* Everything a registry is built from: the collections, and the drizzle schema
|
|
7
|
+
* they are backed by. In BaaS mode all of it is introspected from the live
|
|
8
|
+
* database; in CMS mode it comes from the config and the generated schema.
|
|
9
|
+
*/
|
|
10
|
+
export interface RegistrySchema {
|
|
11
|
+
collections?: CollectionConfig[];
|
|
12
|
+
tables?: Record<string, unknown>;
|
|
13
|
+
enums?: Record<string, PgEnum<[string, ...string[]]>>;
|
|
14
|
+
relations?: Record<string, Relations>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Build the collection registry for a driver.
|
|
18
|
+
*
|
|
19
|
+
* The order matters and is the reason this is one function rather than a run of
|
|
20
|
+
* statements in the bootstrapper. Keys are resolved from the drizzle schema, so
|
|
21
|
+
* anything that inspects them has to run *after* the tables are registered —
|
|
22
|
+
* and `warnOnKeysTheAdminCannotResolve` fails open if it does not, because a
|
|
23
|
+
* collection whose table it cannot look up is one it has nothing to say about.
|
|
24
|
+
* Warned too early, it would skip every collection and report nothing, which
|
|
25
|
+
* reads exactly like having nothing to report.
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildCollectionRegistry(schema: RegistrySchema): PostgresCollectionRegistry;
|
|
@@ -12,12 +12,19 @@ import { PostgresCollectionRegistry } from "./collections/PostgresCollectionRegi
|
|
|
12
12
|
export interface SerializedEntityData {
|
|
13
13
|
/** Scalar column values ready for INSERT/UPDATE. */
|
|
14
14
|
scalarData: Record<string, unknown>;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Inverse relation updates that must be applied to target tables.
|
|
17
|
+
*
|
|
18
|
+
* No address here: the row being written does not know its own. These are
|
|
19
|
+
* applied by `PersistService`, which addresses them with the id it holds —
|
|
20
|
+
* the one it was given for an update, or the one the INSERT returned — and
|
|
21
|
+
* that is the authority. This item used to carry a `currentId` derived from
|
|
22
|
+
* the *input* values, which nothing ever read.
|
|
23
|
+
*/
|
|
16
24
|
inverseRelationUpdates: Array<{
|
|
17
25
|
relationKey: string;
|
|
18
26
|
relation: Relation;
|
|
19
27
|
newValue: unknown;
|
|
20
|
-
currentId?: string | number;
|
|
21
28
|
}>;
|
|
22
29
|
/** JoinPath relation updates that require multi-hop writes. */
|
|
23
30
|
joinPathRelationUpdates: Array<{
|