@rebasepro/server-postgres 0.16.1-canary.gef08a6e → 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.
Files changed (33) hide show
  1. package/dist/{backup-service-BL5x6Fj5.js → backup-service-BtgHxfFm.js} +2 -1
  2. package/dist/{backup-service-BL5x6Fj5.js.map → backup-service-BtgHxfFm.js.map} +1 -1
  3. package/dist/cli-helpers.d.ts +41 -0
  4. package/dist/{ensure-collection-tables-DpGX_25A.js → collection-index-DxJBvVTH.js} +240 -1913
  5. package/dist/collection-index-DxJBvVTH.js.map +1 -0
  6. package/dist/{ensure-collection-policies-RK8-SFLs.js → ensure-collection-policies-DFpOl8SM.js} +3 -3
  7. package/dist/{ensure-collection-policies-RK8-SFLs.js.map → ensure-collection-policies-DFpOl8SM.js.map} +1 -1
  8. package/dist/ensure-collection-tables-DMjOkeRy.js +1952 -0
  9. package/dist/ensure-collection-tables-DMjOkeRy.js.map +1 -0
  10. package/dist/index.es.js +10 -9
  11. package/dist/index.es.js.map +1 -1
  12. package/dist/{rls-enforcement-da7ekLw-.js → rls-enforcement-CInuYj1-.js} +2 -2
  13. package/dist/{rls-enforcement-da7ekLw-.js.map → rls-enforcement-CInuYj1-.js.map} +1 -1
  14. package/dist/schema/collection-index.d.ts +182 -0
  15. package/dist/schema/introspect-db-inference.d.ts +1 -1
  16. package/dist/schema/introspect-db-logic.d.ts +4 -4
  17. package/dist/schema/introspect-db-project.d.ts +2 -2
  18. package/dist/src-DiDgtX8P.js.map +1 -1
  19. package/dist/{websocket-6b7Iy4TP.js → websocket-HcyLl1ZM.js} +5 -4
  20. package/dist/{websocket-6b7Iy4TP.js.map → websocket-HcyLl1ZM.js.map} +1 -1
  21. package/package.json +6 -6
  22. package/src/cli-helpers.ts +114 -0
  23. package/src/cli.ts +22 -0
  24. package/src/schema/collection-index.ts +427 -0
  25. package/src/schema/ensure-collection-tables.ts +21 -0
  26. package/src/schema/generate-postgres-ddl-logic.ts +17 -5
  27. package/src/schema/introspect-db-inference.ts +1 -1
  28. package/src/schema/introspect-db-logic.ts +4 -4
  29. package/src/schema/introspect-db-project.ts +2 -2
  30. package/src/schema/introspect-db.ts +2 -2
  31. package/src/services/realtimeService.ts +17 -4
  32. package/src/websocket.ts +1 -1
  33. package/dist/ensure-collection-tables-DpGX_25A.js.map +0 -1
package/dist/index.es.js CHANGED
@@ -2,11 +2,12 @@ import { createRequire as __createRequire } from "module";
2
2
  import process from "process";
3
3
  __createRequire(import.meta.url);
4
4
  import { a as createReadReplicaConnection, c as poolMaxCeiling, i as createPostgresDatabaseConnection, o as guardPoolAgainstDirtyRelease, r as createDirectDatabaseConnection, s as pinSearchPath, t as cappedPoolMax } from "./connection-GOKU3Hu5.js";
5
- import { $ as camelCase, I as resolveCollectionRelations, J as legacyForeignKeyName, K as firstFreeKey, P as getTableName$1, Y as toWireKey, _ as OrderBySpecError, b as CollectionRegistry, d as authUsersColumnSql, et as toSnakeCase, it as resolveClientListLimit, q as generateForeignKeyName, rt as ListLimitError, st as isManyToMany, u as AUTH_USERS_COLUMNS, y as parseOrderBySpecStrict } from "./ensure-collection-tables-DpGX_25A.js";
5
+ import { C as getTableName$1, F as firstFreeKey, I as generateForeignKeyName, J as resolveClientListLimit, L as legacyForeignKeyName, T as resolveCollectionRelations, U as camelCase, W as toSnakeCase, Z as isManyToMany, c as parseOrderBySpecStrict, l as CollectionRegistry, o as OrderBySpecError, q as ListLimitError, z as toWireKey } from "./collection-index-DxJBvVTH.js";
6
6
  import { l as isRelationalCollectionConfig } from "./src-DiDgtX8P.js";
7
- import { C as deriveRowAddress, E as buildPropertyCallbacks, S as getUnknownFilterFieldsMode, T as warnOnKeysTheAdminCannotResolve, _ as sanitizeErrorForClient, a as AuthenticatedPostgresBackendDriver, b as configureUnknownFilterFields, c as RoleSwitchUnavailableError, d as generateSchema, f as getDrizzleColumn, g as extractPgError, h as classifyConnectFailure, l as effectiveSqlRole, m as DataService, n as PUBLIC_TYPES, o as CONNECTION_OWNER, p as BranchService, r as createPostgresWebSocket, s as PostgresBackendDriver, t as ADMIN_ONLY_TYPES, u as isRoleSwitchingOptedOut, v as DrizzleConditionBuilder, w as getPrimaryKeys, x as escapeLikePattern, y as PostgresConditionBuilder } from "./websocket-6b7Iy4TP.js";
8
- import { a as warnOnAnonymousGrants, c as REBASE_USER_ROLE, i as validatePolicyPgRoles, l as revokeInternalTableAccess, n as detectConnectionPosture, o as warnOnLegacyRlsFunctions, r as ensureAppRole, s as warnOnRoleSchemaCollision, t as applyAuthContext, u as revokeInternalTableSql } from "./rls-enforcement-da7ekLw-.js";
9
- import { A as parseDbNameFromUrl, C as buildRowSecurityPgOptions, D as joinStorageKey, E as globalsFileForDump, F as withDatabaseName, M as resolveConnectionString, N as serverVersionNumToMajor, O as parseBackupDestination, P as splitGlobalsStatements, S as buildPgRestoreListArgs, T as diagnoseRowSecurityDumpFailure, _ as selectBackupsToPrune, a as detectToolMajor, b as buildPgDumpallGlobalsArgs, c as getServerVersionMajor, d as pruneBackups, f as resolvePgBinary, g as require_source, h as validateDump, i as createDump, j as parsePgToolMajor, k as parseBackupTimestamp, l as listBackups, m as uploadBackup, n as applyGlobals, o as discardPartialDump, p as restoreDump, s as ensureDatabaseExists, t as BackupToolError, u as preflight, v as buildBackupFilename, w as checkToolServerCompatibility, x as buildPgRestoreArgs, y as buildPgDumpArgs } from "./backup-service-BL5x6Fj5.js";
7
+ import { d as authUsersColumnSql, u as AUTH_USERS_COLUMNS } from "./ensure-collection-tables-DMjOkeRy.js";
8
+ import { C as deriveRowAddress, E as buildPropertyCallbacks, S as getUnknownFilterFieldsMode, T as warnOnKeysTheAdminCannotResolve, _ as sanitizeErrorForClient, a as AuthenticatedPostgresBackendDriver, b as configureUnknownFilterFields, c as RoleSwitchUnavailableError, d as generateSchema, f as getDrizzleColumn, g as extractPgError, h as classifyConnectFailure, l as effectiveSqlRole, m as DataService, n as PUBLIC_TYPES, o as CONNECTION_OWNER, p as BranchService, r as createPostgresWebSocket, s as PostgresBackendDriver, t as ADMIN_ONLY_TYPES, u as isRoleSwitchingOptedOut, v as DrizzleConditionBuilder, w as getPrimaryKeys, x as escapeLikePattern, y as PostgresConditionBuilder } from "./websocket-HcyLl1ZM.js";
9
+ import { a as warnOnAnonymousGrants, c as REBASE_USER_ROLE, i as validatePolicyPgRoles, l as revokeInternalTableAccess, n as detectConnectionPosture, o as warnOnLegacyRlsFunctions, r as ensureAppRole, s as warnOnRoleSchemaCollision, t as applyAuthContext, u as revokeInternalTableSql } from "./rls-enforcement-CInuYj1-.js";
10
+ import { A as parseDbNameFromUrl, C as buildRowSecurityPgOptions, D as joinStorageKey, E as globalsFileForDump, F as withDatabaseName, M as resolveConnectionString, N as serverVersionNumToMajor, O as parseBackupDestination, P as splitGlobalsStatements, S as buildPgRestoreListArgs, T as diagnoseRowSecurityDumpFailure, _ as selectBackupsToPrune, a as detectToolMajor, b as buildPgDumpallGlobalsArgs, c as getServerVersionMajor, d as pruneBackups, f as resolvePgBinary, g as require_source, h as validateDump, i as createDump, j as parsePgToolMajor, k as parseBackupTimestamp, l as listBackups, m as uploadBackup, n as applyGlobals, o as discardPartialDump, p as restoreDump, s as ensureDatabaseExists, t as BackupToolError, u as preflight, v as buildBackupFilename, w as checkToolServerCompatibility, x as buildPgRestoreArgs, y as buildPgDumpArgs } from "./backup-service-BtgHxfFm.js";
10
11
  import { t as RLS_BOOTSTRAP_STATEMENTS } from "./rls-bootstrap-sql-DNzaWd4C.js";
11
12
  import { Client, Pool } from "pg";
12
13
  import { drizzle } from "drizzle-orm/node-postgres";
@@ -1887,13 +1888,13 @@ var RealtimeService = class RealtimeService extends EventEmitter {
1887
1888
  }
1888
1889
  }
1889
1890
  }
1891
+ await this.presenceStoreOp(() => this.presenceStore.removeClient(clientId), "client removal");
1890
1892
  for (const [channel, members] of this.channels.entries()) if (members.has(clientId)) {
1891
1893
  members.delete(clientId);
1892
1894
  this.removePresence(clientId, channel, { skipStore: true });
1893
1895
  if (members.size === 0) this.channels.delete(channel);
1894
1896
  }
1895
1897
  for (const [channel] of this.presence) this.removePresence(clientId, channel, { skipStore: true });
1896
- this.presenceStoreOp(() => this.presenceStore.removeClient(clientId), "client removal");
1897
1898
  }
1898
1899
  async handleMessage(clientId, message, authContext) {
1899
1900
  const payload = message.payload;
@@ -3451,7 +3452,7 @@ function createBackupCron(config) {
3451
3452
  enabled: config.enabled ?? true,
3452
3453
  timeoutSeconds: 3600,
3453
3454
  async handler({ log }) {
3454
- const { createDump, pruneBackups, uploadBackup, validateDump } = await import("./backup-service-BL5x6Fj5.js").then((n) => n.r);
3455
+ const { createDump, pruneBackups, uploadBackup, validateDump } = await import("./backup-service-BtgHxfFm.js").then((n) => n.r);
3455
3456
  const { destination } = config;
3456
3457
  if (destination.kind !== "local" && !config.storage) throw new Error(`Backup destination is ${destination.kind} but no storage controller was provided. Pass the backend's configured StorageController to createBackupCron({ storage }).`);
3457
3458
  log(`Starting backup of "${dbName}"…`);
@@ -6891,7 +6892,7 @@ function createPostgresBootstrapper(pgConfig) {
6891
6892
  * proved it can bootstrap with.
6892
6893
  */
6893
6894
  async ensureCollectionSchema(collections, driverResult, log) {
6894
- const { ensureCollectionTables } = await import("./ensure-collection-tables-DpGX_25A.js").then((n) => n.t);
6895
+ const { ensureCollectionTables } = await import("./ensure-collection-tables-DMjOkeRy.js").then((n) => n.t);
6895
6896
  const plan = await ensureCollectionTables(provisioningQueryable(driverResult), collections, log);
6896
6897
  for (const failure of plan.failures) logger.warn(failure.kind === "comment-column" ? `🔍 [schema] Could not record the search fingerprint on "${failure.target}" — search works, but a later change to the \`search\` block will not be detected: ${failure.error}` : `🔗 [schema] Could not add foreign key "${failure.target}" — the column exists and the collection still serves, but rows are not policed by this constraint: ${failure.error}`);
6897
6898
  return { applied: plan.actions.length - plan.failures.length };
@@ -6912,7 +6913,7 @@ function createPostgresBootstrapper(pgConfig) {
6912
6913
  * stays RLS-enabled, so it denies rather than leaks.
6913
6914
  */
6914
6915
  async ensureCollectionPolicies(collections, driverResult, log) {
6915
- const { ensureCollectionPolicies } = await import("./ensure-collection-policies-RK8-SFLs.js");
6916
+ const { ensureCollectionPolicies } = await import("./ensure-collection-policies-DFpOl8SM.js");
6916
6917
  const queryable = provisioningQueryable(driverResult);
6917
6918
  const outcome = await ensureCollectionPolicies(queryable, collections, log);
6918
6919
  for (const skip of outcome.skipped) logger.warn(`🔐 [rls] Policies not applied to "${skip.table}": ${skip.reason}`);
@@ -6955,7 +6956,7 @@ function createPostgresBootstrapper(pgConfig) {
6955
6956
  },
6956
6957
  mountRoutes(app, basePath, driverResult) {},
6957
6958
  async initializeWebsockets(server, realtimeService, driver, config, adapter) {
6958
- const { createPostgresWebSocket } = await import("./websocket-6b7Iy4TP.js").then((n) => n.i);
6959
+ const { createPostgresWebSocket } = await import("./websocket-HcyLl1ZM.js").then((n) => n.i);
6959
6960
  createPostgresWebSocket(server, realtimeService, driver, config, adapter);
6960
6961
  }
6961
6962
  };