@rebasepro/server-postgres 0.14.2-canary.gf913b76 → 0.15.1-canary.g869ace1
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 +1 -1
- package/dist/PostgresBootstrapper.d.ts +0 -11
- package/dist/auth/services.d.ts +2 -2
- package/dist/{auth-users-columns-DLwxDqYb.js → auth-users-columns-CgyPWQ18.js} +18 -8
- package/dist/auth-users-columns-CgyPWQ18.js.map +1 -0
- package/dist/backup/backup-logic.d.ts +20 -0
- package/dist/backup/backup-service.d.ts +6 -0
- package/dist/backup/retention.d.ts +11 -0
- package/dist/{backup-service-BH0Dzo_h.js → backup-service-BZoixhVl.js} +57 -12
- package/dist/backup-service-BZoixhVl.js.map +1 -0
- package/dist/collections-schema-version-BMeu3cgv.js +81 -0
- package/dist/collections-schema-version-BMeu3cgv.js.map +1 -0
- package/dist/{ensure-collection-policies-CjPPtN0e.js → ensure-collection-policies-BVFb2olB.js} +4 -3
- package/dist/ensure-collection-policies-BVFb2olB.js.map +1 -0
- package/dist/{ensure-collection-tables-Dnb7scJ1.js → ensure-collection-tables-BY1pHRD_.js} +3 -3
- package/dist/{ensure-collection-tables-Dnb7scJ1.js.map → ensure-collection-tables-BY1pHRD_.js.map} +1 -1
- package/dist/index.es.js +507 -32
- package/dist/index.es.js.map +1 -1
- package/dist/{rls-bootstrap-sql-69hYT8nr.js → rls-bootstrap-sql-B5Sajku6.js} +2 -2
- package/dist/{rls-bootstrap-sql-69hYT8nr.js.map → rls-bootstrap-sql-B5Sajku6.js.map} +1 -1
- package/dist/{rls-enforcement-BpsYVDGM.js → rls-enforcement-Ch0T6OwW.js} +8 -8
- package/dist/rls-enforcement-Ch0T6OwW.js.map +1 -0
- package/dist/schema/collections-schema-version.d.ts +32 -0
- package/dist/security/policy-drift.d.ts +2 -2
- package/dist/security/rls-enforcement.d.ts +6 -6
- package/dist/services/FetchService.d.ts +22 -0
- package/dist/services/realtimeService.d.ts +3 -1
- package/dist/{src-DCdn3Val.js → src-BBFsDaeA.js} +60 -2
- package/dist/src-BBFsDaeA.js.map +1 -0
- package/dist/utils/drizzle-conditions.d.ts +168 -1
- package/dist/{websocket-D2jXv0Ds.js → websocket-BVgDVO-V.js} +2 -2
- package/dist/websocket-BVgDVO-V.js.map +1 -0
- package/package.json +6 -6
- package/src/PostgresAdapter.ts +14 -0
- package/src/PostgresBackendDriver.ts +3 -3
- package/src/PostgresBootstrapper.ts +82 -12
- package/src/auth/services.ts +2 -2
- package/src/backup/backup-cli.ts +49 -12
- package/src/backup/backup-logic.ts +31 -0
- package/src/backup/backup-service.ts +42 -8
- package/src/backup/pg-tools.ts +12 -1
- package/src/backup/retention.ts +11 -0
- package/src/schema/collections-schema-version.ts +103 -0
- package/src/security/policy-drift.test.ts +25 -6
- package/src/security/policy-drift.ts +14 -6
- package/src/security/rls-enforcement.ts +7 -7
- package/src/services/FetchService.ts +155 -15
- package/src/services/realtimeService.ts +9 -1
- package/src/utils/drizzle-conditions.ts +594 -1
- package/dist/auth-users-columns-DLwxDqYb.js.map +0 -1
- package/dist/backup-service-BH0Dzo_h.js.map +0 -1
- package/dist/ensure-collection-policies-CjPPtN0e.js.map +0 -1
- package/dist/rls-enforcement-BpsYVDGM.js.map +0 -1
- package/dist/src-DCdn3Val.js.map +0 -1
- package/dist/websocket-D2jXv0Ds.js.map +0 -1
|
@@ -168,7 +168,7 @@ export declare class PostgresBackendDriver implements DataDriver {
|
|
|
168
168
|
* PostgreSQL roles from `pg_roles` (`postgres`, `rebase_user`, …). Those
|
|
169
169
|
* are the roles the SQL editor can `SET ROLE` to. *These* are the strings
|
|
170
170
|
* held in the users table's `roles` column, injected per-transaction as
|
|
171
|
-
* `
|
|
171
|
+
* `rebase.roles()` and matched by `SecurityRule.roles`. Feeding the pg roles
|
|
172
172
|
* into a `SecurityRule.roles` field produces a condition no user can ever
|
|
173
173
|
* satisfy, so the two must not be conflated.
|
|
174
174
|
*
|
|
@@ -134,15 +134,4 @@ export declare function describeSchemaDriftCause(provisioning: {
|
|
|
134
134
|
* ships `NODE_ENV=development` and some deployments inherit it.
|
|
135
135
|
*/
|
|
136
136
|
export declare function isScaffoldedLocalDatabase(connectionString: string | undefined): boolean;
|
|
137
|
-
/**
|
|
138
|
-
* Default PostgreSQL bootstrapper.
|
|
139
|
-
*
|
|
140
|
-
* Use it to register Postgres with `initializeRebaseBackend()`:
|
|
141
|
-
* ```typescript
|
|
142
|
-
* initializeRebaseBackend({
|
|
143
|
-
* ...config,
|
|
144
|
-
* bootstrappers: [postgresBootstrapper()]
|
|
145
|
-
* });
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
137
|
export declare function createPostgresBootstrapper(pgConfig: PostgresDriverConfig): BackendBootstrapper;
|
package/dist/auth/services.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export declare class UserService implements UserRepository {
|
|
|
44
44
|
* Run a privileged auth write with an explicitly cleared RLS context.
|
|
45
45
|
*
|
|
46
46
|
* The auth services run on the base/owner connection, which by design
|
|
47
|
-
* carries a NULL `app.uid` so the `
|
|
47
|
+
* carries a NULL `app.uid` so the `rebase.uid() IS NULL` server-escape
|
|
48
48
|
* in the default policies applies. That NULL is normally guaranteed by
|
|
49
49
|
* `set_config(..., is_local = true)` resetting at transaction end — but a
|
|
50
50
|
* GUC that survives on a pooled connection (or a connection role that
|
|
@@ -52,7 +52,7 @@ export declare class UserService implements UserRepository {
|
|
|
52
52
|
* turns the trusted write into an RLS-scoped one and denies it with
|
|
53
53
|
* SQLSTATE 42501. Clearing the GUCs here, transaction-locally at the
|
|
54
54
|
* single chokepoint, makes the server context deterministic instead of
|
|
55
|
-
* trusting whatever state the pool hands us. `
|
|
55
|
+
* trusting whatever state the pool hands us. `rebase.uid()` reads '' as
|
|
56
56
|
* NULL via NULLIF, so '' is the server context.
|
|
57
57
|
*/
|
|
58
58
|
private withServerContext;
|
|
@@ -3,7 +3,7 @@ import "process";
|
|
|
3
3
|
__createRequire(import.meta.url);
|
|
4
4
|
import { l as __require, s as __commonJSMin } from "./connection-BuZ97wsr.js";
|
|
5
5
|
import { a as policy, i as ANONYMOUS_USER_IDS, r as ANONYMOUS_USER_ID } from "./data_driver-ULAyJEi9.js";
|
|
6
|
-
import { a as rewriteLegacyRlsFunctions, c as isPostgresCollectionConfig, d as getDataSourceCapabilities, f as ALL_WHERE_FILTER_OPS,
|
|
6
|
+
import { _ as isRelationAggregateSort, a as rewriteLegacyRlsFunctions, b as toCanonicalOp, c as isPostgresCollectionConfig, d as getDataSourceCapabilities, f as ALL_WHERE_FILTER_OPS, h as REST_TO_CANONICAL, i as RLS_UID_SQL, l as isRelationalCollectionConfig, m as NULL_OPS, p as CANONICAL_TO_REST, r as RLS_ROLES_SQL, s as getDeclaredSubcollections, y as sortKeyToString } from "./src-BBFsDaeA.js";
|
|
7
7
|
import { createHash } from "node:crypto";
|
|
8
8
|
//#region ../types/src/types/entities.ts
|
|
9
9
|
/**
|
|
@@ -2719,7 +2719,7 @@ function rolesArraySql(roles) {
|
|
|
2719
2719
|
* rows").
|
|
2720
2720
|
*
|
|
2721
2721
|
* **For auth collections additionally**
|
|
2722
|
-
* 3. A permissive **self SELECT** grant (`id =
|
|
2722
|
+
* 3. A permissive **self SELECT** grant (`id = rebase.uid()`), so users can read
|
|
2723
2723
|
* their own row (profile, session bootstrap) without every app re-declaring
|
|
2724
2724
|
* it.
|
|
2725
2725
|
* 4. A **restrictive** admin write gate. Restrictive policies are AND'd with
|
|
@@ -2728,7 +2728,7 @@ function rolesArraySql(roles) {
|
|
|
2728
2728
|
* such as "a user may edit their own row". Without this, a permissive owner
|
|
2729
2729
|
* rule would let a user change their own `roles`.
|
|
2730
2730
|
*
|
|
2731
|
-
* The server context is recognised as `
|
|
2731
|
+
* The server context is recognised as `rebase.uid() IS NULL` (`policy.serverContext()`)
|
|
2732
2732
|
* — the built-in flows that run without a user (signup, migrations) set no user
|
|
2733
2733
|
* GUC — which also lets the owner connection satisfy these policies even under
|
|
2734
2734
|
* FORCE RLS. A *user* request never reaches that state: an anonymous one carries
|
|
@@ -4058,6 +4058,13 @@ var CollectionRegistry = class {
|
|
|
4058
4058
|
* the same value; the two are told apart by whether the first element is
|
|
4059
4059
|
* itself an array, which no field name ever is.
|
|
4060
4060
|
*
|
|
4061
|
+
* This is also where a {@link RelationAggregateSort} object stops being an
|
|
4062
|
+
* object. Above this function a sort key may be either spelling; below it,
|
|
4063
|
+
* every key is a string — which is what `OrderByTuple`, the REST parameter, the
|
|
4064
|
+
* driver contract and the cursor all already were. Doing it here means the one
|
|
4065
|
+
* place that already collapses the two *shapes* of a sort also collapses the
|
|
4066
|
+
* two *spellings* of a key, rather than every consumer learning about both.
|
|
4067
|
+
*
|
|
4061
4068
|
* @returns The keys in order of significance, or `undefined` for no sort. An
|
|
4062
4069
|
* empty list also returns `undefined` — "sort by nothing" is no sort, and
|
|
4063
4070
|
* letting `[]` through would have every layer below re-deciding what it meant.
|
|
@@ -4065,7 +4072,8 @@ var CollectionRegistry = class {
|
|
|
4065
4072
|
function normalizeOrderBy(orderBy) {
|
|
4066
4073
|
if (!orderBy || orderBy.length === 0) return void 0;
|
|
4067
4074
|
const list = Array.isArray(orderBy[0]) ? orderBy : [orderBy];
|
|
4068
|
-
|
|
4075
|
+
if (list.length === 0) return void 0;
|
|
4076
|
+
return list.map(([key, direction]) => [sortKeyToString(key), direction]);
|
|
4069
4077
|
}
|
|
4070
4078
|
/**
|
|
4071
4079
|
* Collapse the driver-level `{orderBy, order}` pair into the list form.
|
|
@@ -4112,14 +4120,16 @@ function parseOrderBySpecStrict(raw, order) {
|
|
|
4112
4120
|
if (raw === void 0 || raw === null || raw === "") return void 0;
|
|
4113
4121
|
if (typeof raw === "string") return normalizeDriverOrderBy(raw, order);
|
|
4114
4122
|
if (!Array.isArray(raw) || raw.length === 0) throw new OrderBySpecError(`${typeof raw} is not a field name or a list of sort keys`);
|
|
4115
|
-
if (typeof raw[0] === "string") return [toStrictTuple(raw, 0)];
|
|
4123
|
+
if (typeof raw[0] === "string" || isRelationAggregateSort(raw[0])) return [toStrictTuple(raw, 0)];
|
|
4116
4124
|
return raw.map(toStrictTuple);
|
|
4117
4125
|
}
|
|
4118
4126
|
function toStrictTuple(raw, index) {
|
|
4119
|
-
if (!Array.isArray(raw)
|
|
4127
|
+
if (!Array.isArray(raw)) throw new OrderBySpecError(`entry ${index} has no field name`);
|
|
4128
|
+
const key = isRelationAggregateSort(raw[0]) ? sortKeyToString(raw[0]) : raw[0];
|
|
4129
|
+
if (typeof key !== "string" || key.trim() === "") throw new OrderBySpecError(`entry ${index} has no field name`);
|
|
4120
4130
|
const direction = raw[1];
|
|
4121
4131
|
if (direction !== void 0 && direction !== "asc" && direction !== "desc") throw new OrderBySpecError(`entry ${index} has direction '${String(direction)}'`);
|
|
4122
|
-
return [
|
|
4132
|
+
return [key, direction ?? "asc"];
|
|
4123
4133
|
}
|
|
4124
4134
|
//#endregion
|
|
4125
4135
|
//#region ../common/src/data/query_builder.ts
|
|
@@ -5694,4 +5704,4 @@ function isAuthCollection(collection) {
|
|
|
5694
5704
|
//#endregion
|
|
5695
5705
|
export { mergeDeep as $, fieldKeyForColumn as A, parseIdValues as B, getJunctionCollectionConfig as C, policyToPostgres as D, getEffectiveSecurityRules as E, getTableVarName as F, updateDateAutoValues as G, createRelationRef as H, resolveCollectionRelations as I, legacyForeignKeyName as J, firstFreeKey as K, buildCompositeId as L, getColumnName as M, getEnumVarName as N, securityRuleToConditions as O, getTableName as P, isPrototypePollutingKey as Q, getDeclaredPrimaryKeys as R, resolveStringColumnLength as S, resolveJunctionSpecs as T, createRelationRefWithData as U, sortCollectionsBySlug as V, normalizeToEntityRelation as W, toWireKey as X, toPostgresIdentifier as Y, getPolicyNamesForRule as Z, OrderBySpecError as _, SEARCH_STAMP_PREFIX as a, isManyToMany as at, CollectionRegistry as b, assertSearchIsPostgresOnly as c, searchColumnStamps as d, camelCase as et, searchExtensionStatements as f, buildSdkData as g, visibleColumnProjection as h, isAuthCollection as i, hasForeignKeyOnTarget as it, findRelation as j, findAnonymousGrants as k, buildSearchColumnSpec as l, searchIndexStatements as m, authUsersColumnDefinition as n, DEFAULT_ONE_OF_TYPE as nt, SEARCH_TEXT_FN as o, Vector as ot, searchHelperFunctions as p, generateForeignKeyName as q, authUsersColumnSql as r, DEFAULT_ONE_OF_VALUE as rt, SEARCH_UNACCENT_FN as s, AUTH_USERS_COLUMNS as t, toSnakeCase as tt, hiddenColumnsOption as u, normalizeDriverOrderBy as v, getJunctionSecurityRules as w, relationalCollections as x, parseOrderBySpecStrict as y, isAddressableId as z };
|
|
5696
5706
|
|
|
5697
|
-
//# sourceMappingURL=auth-users-columns-
|
|
5707
|
+
//# sourceMappingURL=auth-users-columns-CgyPWQ18.js.map
|