@rebasepro/server-postgres 0.16.1-canary.ge71347e → 0.17.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/dist/PostgresBackendDriver.d.ts +59 -5
- package/dist/{backup-service-BL5x6Fj5.js → backup-service-BtgHxfFm.js} +2 -1
- package/dist/{backup-service-BL5x6Fj5.js.map → backup-service-BtgHxfFm.js.map} +1 -1
- package/dist/cli-helpers.d.ts +41 -0
- package/dist/{ensure-collection-tables-C_Gr59le.js → collection-index-DxJBvVTH.js} +427 -1914
- package/dist/collection-index-DxJBvVTH.js.map +1 -0
- package/dist/{ensure-collection-policies-CMYAvFpM.js → ensure-collection-policies-DFpOl8SM.js} +3 -3
- package/dist/{ensure-collection-policies-CMYAvFpM.js.map → ensure-collection-policies-DFpOl8SM.js.map} +1 -1
- package/dist/ensure-collection-tables-DMjOkeRy.js +1952 -0
- package/dist/ensure-collection-tables-DMjOkeRy.js.map +1 -0
- package/dist/index.es.js +13 -7488
- package/dist/index.es.js.map +1 -1
- package/dist/{rls-enforcement-HLy7w5hL.js → rls-enforcement-CInuYj1-.js} +3 -3
- package/dist/rls-enforcement-CInuYj1-.js.map +1 -0
- package/dist/schema/collection-index.d.ts +182 -0
- package/dist/schema/introspect-db-inference.d.ts +1 -1
- package/dist/schema/introspect-db-logic.d.ts +4 -4
- package/dist/schema/introspect-db-project.d.ts +2 -2
- package/dist/src-DiDgtX8P.js.map +1 -1
- package/dist/websocket-HcyLl1ZM.js +8188 -0
- package/dist/websocket-HcyLl1ZM.js.map +1 -0
- package/package.json +6 -6
- package/src/PostgresBackendDriver.ts +149 -57
- package/src/cli-helpers.ts +114 -0
- package/src/cli.ts +22 -0
- package/src/schema/collection-index.ts +427 -0
- package/src/schema/ensure-collection-tables.ts +21 -0
- package/src/schema/generate-postgres-ddl-logic.ts +17 -5
- package/src/schema/introspect-db-inference.ts +1 -1
- package/src/schema/introspect-db-logic.ts +4 -4
- package/src/schema/introspect-db-project.ts +2 -2
- package/src/schema/introspect-db.ts +2 -2
- package/src/services/realtimeService.ts +17 -4
- package/src/websocket.ts +12 -2
- package/dist/data_driver-ULAyJEi9.js +0 -193
- package/dist/data_driver-ULAyJEi9.js.map +0 -1
- package/dist/ensure-collection-tables-C_Gr59le.js.map +0 -1
- package/dist/rls-enforcement-HLy7w5hL.js.map +0 -1
- package/dist/websocket-D0YNv8hp.js +0 -651
- package/dist/websocket-D0YNv8hp.js.map +0 -1
|
@@ -6,6 +6,46 @@ import { DrizzleClient } from "./interfaces.js";
|
|
|
6
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.js";
|
|
8
8
|
import { HistoryService } from "./history/HistoryService.js";
|
|
9
|
+
/**
|
|
10
|
+
* Has an operator opted out of database role switching entirely?
|
|
11
|
+
*
|
|
12
|
+
* `DISABLE_DB_ROLE_SWITCHING=true` is documented (README, the configuration
|
|
13
|
+
* page, the backend skill) as "run Studio SQL Editor queries as the connection
|
|
14
|
+
* owner", for deployments whose application roles have no database role behind
|
|
15
|
+
* them. It is the only sanctioned way a statement that named a role runs
|
|
16
|
+
* without it — every other route now refuses.
|
|
17
|
+
*
|
|
18
|
+
* Exact `"true"` on purpose, matching the check this replaced. `=1` and `=yes`
|
|
19
|
+
* silently do nothing, which `docs/audits/80-config-and-env.md` already records
|
|
20
|
+
* as a finding across the env surface; fixing it here alone would make this one
|
|
21
|
+
* variable disagree with the rest.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isRoleSwitchingOptedOut(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The role a statement will actually have run as, given the role it asked for.
|
|
26
|
+
*
|
|
27
|
+
* For the audit log, which recorded `options.role` — the *requested* role — and
|
|
28
|
+
* so restated the caller's request as though it were the outcome. The two part
|
|
29
|
+
* company exactly when {@link isRoleSwitchingOptedOut} holds, because every
|
|
30
|
+
* other divergence is now an error rather than a quiet substitution.
|
|
31
|
+
*/
|
|
32
|
+
export declare function effectiveSqlRole(requestedRole?: string): string;
|
|
33
|
+
/** How {@link effectiveSqlRole} names "whatever role the connection holds". */
|
|
34
|
+
export declare const CONNECTION_OWNER = "<connection owner>";
|
|
35
|
+
/**
|
|
36
|
+
* A statement named a database role the connection cannot assume.
|
|
37
|
+
*
|
|
38
|
+
* Its own type because the tempting recovery — run it anyway, as the owner — is
|
|
39
|
+
* the one thing that must not happen. Callers that catch this should report it,
|
|
40
|
+
* not retry unscoped.
|
|
41
|
+
*/
|
|
42
|
+
export declare class RoleSwitchUnavailableError extends Error {
|
|
43
|
+
readonly code = "ROLE_SWITCH_UNAVAILABLE";
|
|
44
|
+
readonly role: string;
|
|
45
|
+
/** The underlying Postgres error, when the refusal came from a live attempt. */
|
|
46
|
+
readonly pgError?: unknown;
|
|
47
|
+
constructor(role: string, pgError?: unknown);
|
|
48
|
+
}
|
|
9
49
|
export declare class PostgresBackendDriver implements DataDriver {
|
|
10
50
|
db: DrizzleClient;
|
|
11
51
|
readonly registry: PostgresCollectionRegistry;
|
|
@@ -20,12 +60,18 @@ export declare class PostgresBackendDriver implements DataDriver {
|
|
|
20
60
|
data: RebaseSdkData;
|
|
21
61
|
client?: RebaseClient;
|
|
22
62
|
/**
|
|
23
|
-
* Auto-set to `true`
|
|
24
|
-
* privileges, so
|
|
25
|
-
*
|
|
26
|
-
*
|
|
63
|
+
* Auto-set to `true` once a `SET LOCAL ROLE` has failed with insufficient
|
|
64
|
+
* privileges, so later statements refuse without spending the round trip
|
|
65
|
+
* to be refused again.
|
|
66
|
+
*
|
|
67
|
+
* Deliberately NOT a mirror of `DISABLE_DB_ROLE_SWITCHING`, which it used
|
|
68
|
+
* to be described as. The env var is an operator saying "run these as the
|
|
69
|
+
* connection owner"; this flag is the database saying "I cannot give you
|
|
70
|
+
* the role you asked for". The first is a decision and permits the
|
|
71
|
+
* fallback, the second is a failure and must not — see the SECURITY note
|
|
72
|
+
* in {@link executeSql}.
|
|
27
73
|
*/
|
|
28
|
-
private
|
|
74
|
+
private _roleSwitchingUnavailable;
|
|
29
75
|
/**
|
|
30
76
|
* Restricted role that authenticated (user-context) requests run as (via
|
|
31
77
|
* `SET LOCAL ROLE`) so RLS binds every statement — reads *and* writes. Set
|
|
@@ -163,6 +209,14 @@ export declare class PostgresBackendDriver implements DataDriver {
|
|
|
163
209
|
checkUniqueField(path: string, name: string, value: unknown, id?: string, collection?: CollectionConfig): Promise<boolean>;
|
|
164
210
|
count<M extends Record<string, unknown>>({ path, collection, filter, logical, searchString, vectorSearch }: FetchCollectionProps<M>): Promise<number>;
|
|
165
211
|
private getTargetDb;
|
|
212
|
+
/**
|
|
213
|
+
* Build one statement, binding `$n` placeholders as real parameters.
|
|
214
|
+
*
|
|
215
|
+
* Shared by the role-switched path (inside a transaction) and the
|
|
216
|
+
* unswitched one. They held byte-identical copies of this loop, which is
|
|
217
|
+
* exactly the shape where a fix lands in one copy and not the other.
|
|
218
|
+
*/
|
|
219
|
+
private buildStatement;
|
|
166
220
|
executeSql(sqlText: string, options?: {
|
|
167
221
|
database?: string;
|
|
168
222
|
role?: string;
|
|
@@ -2,6 +2,7 @@ import { createRequire as __createRequire } from "module";
|
|
|
2
2
|
import process from "process";
|
|
3
3
|
__createRequire(import.meta.url);
|
|
4
4
|
import { d as __require, f as __toESM, l as __commonJSMin, u as __exportAll } from "./connection-GOKU3Hu5.js";
|
|
5
|
+
import "./collection-index-DxJBvVTH.js";
|
|
5
6
|
import "./src-DiDgtX8P.js";
|
|
6
7
|
import fs from "fs";
|
|
7
8
|
import path from "path";
|
|
@@ -9040,4 +9041,4 @@ async function pruneBackups(dest, options, storage) {
|
|
|
9040
9041
|
//#endregion
|
|
9041
9042
|
export { parseDbNameFromUrl as A, buildRowSecurityPgOptions as C, joinStorageKey as D, globalsFileForDump as E, withDatabaseName as F, resolveConnectionString as M, serverVersionNumToMajor as N, parseBackupDestination as O, splitGlobalsStatements as P, buildPgRestoreListArgs as S, diagnoseRowSecurityDumpFailure as T, selectBackupsToPrune as _, detectToolMajor as a, buildPgDumpallGlobalsArgs as b, getServerVersionMajor as c, pruneBackups as d, resolvePgBinary as f, require_source as g, validateDump as h, createDump as i, parsePgToolMajor as j, parseBackupTimestamp as k, listBackups as l, uploadBackup as m, applyGlobals as n, discardPartialDump as o, restoreDump as p, backup_service_exports as r, ensureDatabaseExists as s, BackupToolError as t, preflight as u, buildBackupFilename as v, checkToolServerCompatibility as w, buildPgRestoreArgs as x, buildPgDumpArgs as y };
|
|
9042
9043
|
|
|
9043
|
-
//# sourceMappingURL=backup-service-
|
|
9044
|
+
//# sourceMappingURL=backup-service-BtgHxfFm.js.map
|