@rebasepro/server-postgres 0.12.1-canary.gf5f1d39 → 0.13.1-canary.g18cfeb7
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 +49 -2
- package/dist/PostgresBootstrapper.d.ts +25 -1
- package/dist/auth/services.d.ts +21 -0
- package/dist/{src-BbFOPJ1S.js → auth-users-columns-Do9mw5Y5.js} +602 -200
- package/dist/auth-users-columns-Do9mw5Y5.js.map +1 -0
- package/dist/backup/backup-service.d.ts +10 -1
- package/dist/backup/pg-tools.d.ts +47 -0
- package/dist/backup-service-Bww-Lg0s.js +8999 -0
- package/dist/backup-service-Bww-Lg0s.js.map +1 -0
- package/dist/cli-helpers.d.ts +40 -1
- package/dist/connection-BuZ97wsr.js +250 -0
- package/dist/connection-BuZ97wsr.js.map +1 -0
- package/dist/connection.d.ts +42 -0
- package/dist/ensure-collection-policies-DMUdRQdM.js +57 -0
- package/dist/ensure-collection-policies-DMUdRQdM.js.map +1 -0
- package/dist/ensure-collection-tables-DSIxvLLD.js +694 -0
- package/dist/ensure-collection-tables-DSIxvLLD.js.map +1 -0
- package/dist/index.es.js +1701 -10167
- package/dist/index.es.js.map +1 -1
- package/dist/policy-CPkCqVTz.js +105 -0
- 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-schema.d.ts +83 -144
- package/dist/schema/auth-users-columns.d.ts +97 -0
- package/dist/schema/ensure-collection-policies.d.ts +60 -0
- package/dist/schema/ensure-collection-tables.d.ts +45 -3
- package/dist/schema/generate-drizzle-schema-logic.d.ts +1 -1
- package/dist/schema/generate-postgres-ddl-logic.d.ts +137 -3
- package/dist/schema/generated-schema-staleness.d.ts +39 -0
- package/dist/schema/introspect-db-constraints.d.ts +57 -0
- package/dist/schema/introspect-db-logic.d.ts +94 -5
- package/dist/schema/introspect-db-queries.d.ts +119 -0
- package/dist/schema/introspect-db-structure.d.ts +263 -0
- package/dist/schema/introspect-db-types.d.ts +11 -0
- package/dist/schema/rls-bootstrap-sql.d.ts +135 -0
- package/dist/security/rls-enforcement.d.ts +53 -2
- package/dist/services/FetchService.d.ts +14 -8
- package/dist/services/RelationService.d.ts +24 -1
- package/dist/services/channel-bus/index.d.ts +1 -7
- package/dist/services/collection-helpers.d.ts +36 -2
- package/dist/services/dataService.d.ts +5 -1
- package/dist/services/realtimeService.d.ts +25 -21
- package/dist/services/row-pipeline.d.ts +1 -1
- package/dist/{src-Zqwaw3P5.js → src-C_wvdMnl.js} +78 -145
- package/dist/src-C_wvdMnl.js.map +1 -0
- package/dist/utils/connection-string.d.ts +29 -0
- package/dist/utils/drizzle-conditions.d.ts +5 -4
- package/dist/utils/pg-error-utils.d.ts +35 -0
- package/dist/websocket-D0TBU3ia.js +530 -0
- package/dist/websocket-D0TBU3ia.js.map +1 -0
- package/package.json +17 -16
- package/src/PostgresAdapter.ts +21 -2
- package/src/PostgresBackendDriver.ts +169 -3
- package/src/PostgresBootstrapper.ts +233 -35
- package/src/auth/ensure-tables.ts +335 -81
- package/src/auth/services.ts +24 -2
- package/src/backup/backup-cli.ts +41 -2
- package/src/backup/backup-service.ts +38 -5
- package/src/backup/pg-tools.ts +96 -3
- package/src/cli-helpers.ts +92 -9
- package/src/cli.ts +219 -56
- package/src/collections/validate-relations.ts +136 -14
- package/src/connection.ts +73 -0
- package/src/data-transformer.ts +22 -6
- package/src/databasePoolManager.ts +5 -2
- package/src/history/ensure-history-table.ts +7 -0
- package/src/schema/auth-schema.ts +30 -19
- package/src/schema/auth-users-columns.ts +131 -0
- package/src/schema/doctor.ts +7 -5
- package/src/schema/ensure-collection-policies.ts +105 -0
- package/src/schema/ensure-collection-tables.test.ts +105 -9
- package/src/schema/ensure-collection-tables.ts +301 -44
- package/src/schema/generate-drizzle-schema-logic.ts +49 -7
- package/src/schema/generate-postgres-ddl-logic.ts +474 -27
- package/src/schema/generated-schema-staleness.ts +169 -0
- package/src/schema/introspect-db-constraints.ts +385 -0
- package/src/schema/introspect-db-inference.ts +18 -8
- package/src/schema/introspect-db-logic.ts +385 -71
- package/src/schema/introspect-db-queries.ts +326 -0
- package/src/schema/introspect-db-structure.ts +670 -0
- package/src/schema/introspect-db-types.ts +56 -0
- package/src/schema/introspect-db.ts +37 -80
- package/src/schema/introspect-runtime.test.ts +56 -8
- package/src/schema/introspect-runtime.ts +31 -9
- package/src/schema/non-sql-collections.test.ts +131 -0
- package/src/schema/rls-bootstrap-sql.ts +288 -0
- package/src/security/anonymous-grants.test.ts +4 -2
- package/src/security/policy-drift.test.ts +11 -3
- package/src/security/rls-enforcement.ts +141 -3
- package/src/services/BranchService.ts +71 -28
- package/src/services/FetchService.ts +100 -107
- package/src/services/PersistService.ts +34 -7
- package/src/services/RelationService.ts +249 -48
- package/src/services/channel-bus/index.ts +0 -9
- package/src/services/channel-history.ts +8 -0
- package/src/services/channel-presence.ts +6 -0
- package/src/services/collection-helpers.ts +69 -3
- package/src/services/dataService.ts +5 -1
- package/src/services/realtimeService.ts +38 -35
- package/src/services/row-pipeline.ts +1 -1
- package/src/utils/connection-string.ts +58 -0
- package/src/utils/drizzle-conditions.ts +31 -6
- package/src/utils/pg-error-utils.ts +65 -0
- package/src/websocket.ts +18 -9
- package/dist/chunk-DSJWtz9O.js +0 -40
- package/dist/ensure-collection-tables-CNTcZGvn.js +0 -304
- package/dist/ensure-collection-tables-CNTcZGvn.js.map +0 -1
- package/dist/schema/auth-bootstrap-sql.d.ts +0 -24
- package/dist/src-BbFOPJ1S.js.map +0 -1
- package/dist/src-Zqwaw3P5.js.map +0 -1
- package/src/schema/auth-bootstrap-sql.ts +0 -47
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StorageController } from "@rebasepro/server";
|
|
2
|
-
import { BackupDestination, VersionCompatibility } from "./pg-tools";
|
|
2
|
+
import { BackupDestination, type RowSecurityIdentity, VersionCompatibility } from "./pg-tools";
|
|
3
3
|
import { BackupObject, RetentionOptions } from "./retention";
|
|
4
4
|
export declare class BackupToolError extends Error {
|
|
5
5
|
readonly hint?: string | undefined;
|
|
@@ -54,6 +54,15 @@ export declare function createDump(opts: {
|
|
|
54
54
|
inheritStdio?: boolean;
|
|
55
55
|
includeGlobals?: boolean;
|
|
56
56
|
env?: Record<string, string | undefined>;
|
|
57
|
+
/**
|
|
58
|
+
* Dump with row security left on, reading as this identity.
|
|
59
|
+
*
|
|
60
|
+
* The escape hatch for a managed Postgres, where the dumping role owns
|
|
61
|
+
* nothing and has no `BYPASSRLS`. Off by default, and deliberately so: with
|
|
62
|
+
* row security on, `pg_dump` stops erroring on rows it cannot see and
|
|
63
|
+
* simply omits them. See {@link RowSecurityIdentity}.
|
|
64
|
+
*/
|
|
65
|
+
rowSecurity?: RowSecurityIdentity;
|
|
57
66
|
}): Promise<BackupResult>;
|
|
58
67
|
/**
|
|
59
68
|
* Cheap integrity check on a freshly written dump: it must be non-empty and
|
|
@@ -79,6 +79,36 @@ export declare function parseBackupDestination(out: string): BackupDestination;
|
|
|
79
79
|
* doubled slash.
|
|
80
80
|
*/
|
|
81
81
|
export declare function joinStorageKey(prefix: string, fileName: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* The identity `pg_dump` reads rows as, when row security is left on.
|
|
84
|
+
*
|
|
85
|
+
* Not optional, and that is the whole design. `pg_dump --enable-row-security`
|
|
86
|
+
* on its own is the dangerous command in this file: it turns the "query would
|
|
87
|
+
* be affected by row-level security policy" *error* into a dump that exits 0
|
|
88
|
+
* and is silently missing every row the dumping role's policies exclude. A
|
|
89
|
+
* backup that looks fine and restores most of your data is worse than one that
|
|
90
|
+
* refused to run.
|
|
91
|
+
*
|
|
92
|
+
* So the flag is unreachable without a subject to evaluate the policies
|
|
93
|
+
* against. Rebase's generated policies read `app.uid` and `app.user_roles`;
|
|
94
|
+
* supplying an admin role satisfies the `admin_full_access` rule and the dump
|
|
95
|
+
* sees everything that rule sees.
|
|
96
|
+
*/
|
|
97
|
+
export interface RowSecurityIdentity {
|
|
98
|
+
/** Written to `app.uid`. Any non-empty value — it is only an audit trail. */
|
|
99
|
+
uid: string;
|
|
100
|
+
/** Written to `app.user_roles`. Must include a role the policies admit. */
|
|
101
|
+
roles: string[];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* `PGOPTIONS` carrying an identity, for a libpq tool that has no other way to
|
|
105
|
+
* set a GUC.
|
|
106
|
+
*
|
|
107
|
+
* A backslash escape rather than quoting, which is what libpq's `-c` parsing
|
|
108
|
+
* takes: a space inside a value ends the option otherwise, so a role list is
|
|
109
|
+
* comma-joined and never spaced.
|
|
110
|
+
*/
|
|
111
|
+
export declare function buildRowSecurityPgOptions(identity: RowSecurityIdentity): string;
|
|
82
112
|
/**
|
|
83
113
|
* Assemble the `pg_dump` argument vector. Uses the custom format (`-Fc`),
|
|
84
114
|
* which is compressed and restorable selectively via `pg_restore`.
|
|
@@ -90,7 +120,24 @@ export declare function buildPgDumpArgs(opts: {
|
|
|
90
120
|
excludeSchemas?: string[];
|
|
91
121
|
/** Number of parallel jobs (directory format only; ignored for -Fc). */
|
|
92
122
|
noOwner?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Dump with row security on, as this identity. Omit — which is the default
|
|
125
|
+
* — and `pg_dump` errors rather than skipping rows it cannot see.
|
|
126
|
+
*/
|
|
127
|
+
rowSecurity?: RowSecurityIdentity;
|
|
93
128
|
}): string[];
|
|
129
|
+
/**
|
|
130
|
+
* Whether a `pg_dump` failure is the row-security one, and what to do about it.
|
|
131
|
+
*
|
|
132
|
+
* The error text names the table and nothing else, so the first read of it is
|
|
133
|
+
* "why would a backup be affected by RLS at all?" — the answer being that the
|
|
134
|
+
* dumping role is not the tables' owner and has no `BYPASSRLS`, which is the
|
|
135
|
+
* normal state of the `postgres` user on Cloud SQL, RDS and every other managed
|
|
136
|
+
* Postgres. Nothing about that is visible from the message.
|
|
137
|
+
*
|
|
138
|
+
* Returns `null` for any other failure, so the caller reports it unchanged.
|
|
139
|
+
*/
|
|
140
|
+
export declare function diagnoseRowSecurityDumpFailure(error: unknown): string | null;
|
|
94
141
|
/**
|
|
95
142
|
* Assemble the `pg_restore` argument vector for a custom-format dump.
|
|
96
143
|
*/
|