@rebasepro/server-postgres 0.13.0 → 0.13.1-canary.g249daa1
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/PostgresBackendDriver.d.ts +48 -1
- package/dist/{src-DlPBctw_.js → auth-users-columns-Dt9g712t.js} +721 -47
- package/dist/auth-users-columns-Dt9g712t.js.map +1 -0
- package/dist/{backup-service-CD8o_1Sl.js → backup-service-Bww-Lg0s.js} +2 -2
- package/dist/{backup-service-CD8o_1Sl.js.map → backup-service-Bww-Lg0s.js.map} +1 -1
- package/dist/cli-helpers.d.ts +57 -1
- package/dist/{ensure-collection-policies-ViG8XiPn.js → ensure-collection-policies-CwYUliAa.js} +2 -2
- package/dist/{ensure-collection-policies-ViG8XiPn.js.map → ensure-collection-policies-CwYUliAa.js.map} +1 -1
- package/dist/{ensure-collection-tables-CBQdOETu.js → ensure-collection-tables-DRxaUG96.js} +86 -15
- package/dist/ensure-collection-tables-DRxaUG96.js.map +1 -0
- package/dist/index.es.js +765 -223
- package/dist/index.es.js.map +1 -1
- package/dist/{policy-CeA1JcxP.js → policy-CPkCqVTz.js} +4 -4
- package/dist/policy-CPkCqVTz.js.map +1 -0
- package/dist/rls-bootstrap-sql-Bpv3nUZo.js +244 -0
- package/dist/rls-bootstrap-sql-Bpv3nUZo.js.map +1 -0
- package/dist/schema/auth-users-columns.d.ts +97 -0
- package/dist/schema/ensure-collection-tables.d.ts +2 -2
- package/dist/schema/generate-drizzle-schema-logic.d.ts +1 -1
- package/dist/schema/generate-postgres-ddl-logic.d.ts +53 -5
- package/dist/schema/generated-schema-staleness.d.ts +39 -0
- package/dist/schema/rls-bootstrap-sql.d.ts +135 -0
- package/dist/schema/search-column.d.ts +199 -0
- package/dist/security/rls-enforcement.d.ts +53 -2
- package/dist/services/FetchService.d.ts +25 -7
- package/dist/services/dataService.d.ts +3 -0
- package/dist/services/realtimeService.d.ts +27 -21
- package/dist/{src-DoU9yPqq.js → src-C_wvdMnl.js} +91 -2
- package/dist/src-C_wvdMnl.js.map +1 -0
- package/dist/utils/drizzle-conditions.d.ts +71 -2
- package/dist/{websocket-B2LsrINK.js → websocket-D0TBU3ia.js} +3 -3
- package/dist/websocket-D0TBU3ia.js.map +1 -0
- package/package.json +9 -8
- package/src/PostgresBackendDriver.ts +165 -3
- package/src/PostgresBootstrapper.ts +41 -2
- package/src/auth/ensure-tables.ts +185 -86
- package/src/cli-helpers.ts +129 -10
- package/src/cli.ts +232 -30
- package/src/collections/validate-relations.ts +124 -17
- package/src/data-transformer.ts +31 -3
- package/src/history/ensure-history-table.ts +7 -0
- package/src/schema/auth-users-columns.ts +131 -0
- package/src/schema/doctor.ts +7 -5
- package/src/schema/ensure-collection-tables.ts +165 -20
- package/src/schema/generate-drizzle-schema-logic.ts +33 -3
- package/src/schema/generate-postgres-ddl-logic.ts +266 -15
- package/src/schema/generate-postgres-ddl.ts +25 -2
- package/src/schema/generated-schema-staleness.ts +169 -0
- package/src/schema/introspect-db-logic.ts +1 -1
- package/src/schema/non-sql-collections.test.ts +131 -0
- package/src/schema/rls-bootstrap-sql.ts +288 -0
- package/src/schema/search-column.ts +558 -0
- package/src/security/anonymous-grants.test.ts +4 -2
- package/src/security/rls-enforcement.ts +141 -3
- package/src/services/BranchService.ts +5 -0
- package/src/services/FetchService.ts +148 -108
- package/src/services/PersistService.ts +14 -1
- package/src/services/RelationService.ts +2 -1
- package/src/services/channel-history.ts +8 -0
- package/src/services/channel-presence.ts +6 -0
- package/src/services/dataService.ts +3 -0
- package/src/services/realtimeService.ts +46 -37
- package/src/utils/drizzle-conditions.ts +223 -2
- package/dist/ensure-collection-tables-CBQdOETu.js.map +0 -1
- package/dist/policy-CeA1JcxP.js.map +0 -1
- package/dist/schema/auth-bootstrap-sql.d.ts +0 -24
- package/dist/src-DlPBctw_.js.map +0 -1
- package/dist/src-DoU9yPqq.js.map +0 -1
- package/dist/websocket-B2LsrINK.js.map +0 -1
- package/src/schema/auth-bootstrap-sql.ts +0 -47
|
@@ -3,7 +3,7 @@ import { BranchService } from "./services/BranchService";
|
|
|
3
3
|
import { RealtimeService } from "./services/realtimeService";
|
|
4
4
|
import { DatabasePoolManager } from "./databasePoolManager";
|
|
5
5
|
import { DrizzleClient } from "./interfaces";
|
|
6
|
-
import { DatabaseAdmin, DataDriver, DeleteProps, CollectionConfig, FetchCollectionProps, FetchOneProps, ListenCollectionProps, ListenOneProps, RebaseClient, RebaseSdkData, RestFetchService, SaveManyProps, SaveProps, TableMetadata, User } from "@rebasepro/types";
|
|
6
|
+
import { DatabaseAdmin, DataDriver, DeleteProps, CollectionConfig, FetchCollectionProps, FetchOneProps, ListenCollectionProps, ListenOneProps, RebaseClient, RebaseSdkData, RestFetchService, SaveManyProps, SaveProps, UpdateManyProps, DeleteManyProps, TableMetadata, User } from "@rebasepro/types";
|
|
7
7
|
import { PostgresCollectionRegistry } from "./collections/PostgresCollectionRegistry";
|
|
8
8
|
import { HistoryService } from "./history/HistoryService";
|
|
9
9
|
export declare class PostgresBackendDriver implements DataDriver {
|
|
@@ -62,6 +62,25 @@ export declare class PostgresBackendDriver implements DataDriver {
|
|
|
62
62
|
* REST/SDK read leaks unmasked data (see {@link applyAfterReadForRest}).
|
|
63
63
|
*/
|
|
64
64
|
get restFetchService(): RestFetchService;
|
|
65
|
+
/**
|
|
66
|
+
* Build the context handed to every collection callback.
|
|
67
|
+
*
|
|
68
|
+
* Note `data: this.data` — `this` is whichever driver is running the
|
|
69
|
+
* operation, so the callback's data plane inherits that driver's privilege.
|
|
70
|
+
* On a user request `AuthenticatedPostgresBackendDriver.withTransaction`
|
|
71
|
+
* constructs a fresh base driver bound to the RLS-scoped transaction and
|
|
72
|
+
* runs the operation on it, so `this.data` speaks through that connection
|
|
73
|
+
* and policies apply. On server-context work `this` is the base driver on
|
|
74
|
+
* the owner connection, and they do not. Pinned by the
|
|
75
|
+
* `"scopes context.data to the caller"` case in the `rls-enforcement` e2e
|
|
76
|
+
* suite, because it is the kind of property that is easy to break from a
|
|
77
|
+
* distance and impossible to notice.
|
|
78
|
+
*
|
|
79
|
+
* Previously returned through `as unknown as RebaseCallContext`, which
|
|
80
|
+
* disabled checking for the whole object and let `driver` — documented in
|
|
81
|
+
* the callbacks guide — sit on the runtime context while absent from the
|
|
82
|
+
* contract. Both are declared now, so this is a plain typed return.
|
|
83
|
+
*/
|
|
65
84
|
private buildCallContext;
|
|
66
85
|
private resolveCollectionCallbacks;
|
|
67
86
|
/**
|
|
@@ -102,6 +121,34 @@ export declare class PostgresBackendDriver implements DataDriver {
|
|
|
102
121
|
* with the last write winning, exactly as separate calls would.
|
|
103
122
|
*/
|
|
104
123
|
saveMany<M extends Record<string, unknown>>({ path, rows, collection, upsert }: SaveManyProps<M>): Promise<Record<string, unknown>[]>;
|
|
124
|
+
/**
|
|
125
|
+
* Update many rows through the same pipeline as {@link save}, in one
|
|
126
|
+
* transaction.
|
|
127
|
+
*
|
|
128
|
+
* Structurally the mirror of {@link saveMany} — same tx-bound sub-driver,
|
|
129
|
+
* same deferred notifications, same per-row error labelling — but it calls
|
|
130
|
+
* `save` with an explicit `id` and `status: "existing"`, which is precisely
|
|
131
|
+
* what `saveMany` cannot do: that one passes `status: "new"` and keeps the
|
|
132
|
+
* key inside `values`, so it inserts or upserts and can never target a
|
|
133
|
+
* particular row.
|
|
134
|
+
*
|
|
135
|
+
* All-or-nothing, so an id matching no row aborts the batch. A partial
|
|
136
|
+
* update is the outcome with no good recovery: the caller cannot tell which
|
|
137
|
+
* half landed without re-reading everything.
|
|
138
|
+
*/
|
|
139
|
+
updateMany<M extends Record<string, unknown>>({ path, updates, collection }: UpdateManyProps<M>): Promise<Record<string, unknown>[]>;
|
|
140
|
+
/**
|
|
141
|
+
* Delete many rows in one transaction, running the full delete pipeline —
|
|
142
|
+
* `beforeDelete`, the delete, `afterDelete` — for each.
|
|
143
|
+
*
|
|
144
|
+
* Looping the single-row {@link delete} rather than emitting one
|
|
145
|
+
* `DELETE ... WHERE id = ANY($1)` is the deliberate choice: a single
|
|
146
|
+
* statement would be faster and would skip every callback, so a collection
|
|
147
|
+
* relying on `beforeDelete` to veto or on `afterDelete` to clean up
|
|
148
|
+
* dependents would behave differently depending on how many rows the caller
|
|
149
|
+
* happened to delete at once. Same pipeline, one transaction.
|
|
150
|
+
*/
|
|
151
|
+
deleteMany<M extends Record<string, unknown>>({ path, ids, collection }: DeleteManyProps<M>): Promise<void>;
|
|
105
152
|
delete<M extends Record<string, unknown>>({ row, collection }: DeleteProps<M>): Promise<void>;
|
|
106
153
|
deleteAll(path: string): Promise<void>;
|
|
107
154
|
checkUniqueField(path: string, name: string, value: unknown, id?: string, collection?: CollectionConfig): Promise<boolean>;
|