@rebasepro/server-postgres 0.16.0 → 0.16.1-canary.g041c925

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 (90) hide show
  1. package/dist/PostgresAdapter.d.ts +1 -1
  2. package/dist/PostgresBackendDriver.d.ts +16 -7
  3. package/dist/PostgresBootstrapper.d.ts +6 -6
  4. package/dist/auth/services.d.ts +1 -1
  5. package/dist/backup/backup-cron.d.ts +1 -1
  6. package/dist/backup/backup-service.d.ts +2 -2
  7. package/dist/backup/index.d.ts +4 -4
  8. package/dist/{backup-service-BZoixhVl.js → backup-service-FN6V3rVi.js} +4 -4
  9. package/dist/{backup-service-BZoixhVl.js.map → backup-service-FN6V3rVi.js.map} +1 -1
  10. package/dist/collections/PostgresCollectionRegistry.d.ts +1 -1
  11. package/dist/collections/buildRegistry.d.ts +1 -1
  12. package/dist/collections/validate-relations.d.ts +1 -1
  13. package/dist/{connection-BuZ97wsr.js → connection-GOKU3Hu5.js} +34 -7
  14. package/dist/connection-GOKU3Hu5.js.map +1 -0
  15. package/dist/connection.d.ts +16 -0
  16. package/dist/data-transformer.d.ts +1 -1
  17. package/dist/{ensure-collection-policies-BVFb2olB.js → ensure-collection-policies-B01cv9UC.js} +4 -4
  18. package/dist/{ensure-collection-policies-BVFb2olB.js.map → ensure-collection-policies-B01cv9UC.js.map} +1 -1
  19. package/dist/{auth-users-columns-CgyPWQ18.js → ensure-collection-tables-CvW6tbI7.js} +1482 -12
  20. package/dist/ensure-collection-tables-CvW6tbI7.js.map +1 -0
  21. package/dist/index.d.ts +16 -16
  22. package/dist/index.es.js +2183 -1817
  23. package/dist/index.es.js.map +1 -1
  24. package/dist/{rls-bootstrap-sql-B5Sajku6.js → rls-bootstrap-sql-DAwWHs81.js} +3 -3
  25. package/dist/{rls-bootstrap-sql-B5Sajku6.js.map → rls-bootstrap-sql-DAwWHs81.js.map} +1 -1
  26. package/dist/{rls-enforcement-Ch0T6OwW.js → rls-enforcement-eSahD7ec.js} +13 -3
  27. package/dist/rls-enforcement-eSahD7ec.js.map +1 -0
  28. package/dist/schema/classify-change.d.ts +82 -0
  29. package/dist/schema/dynamic-tables.d.ts +1 -1
  30. package/dist/schema/ensure-collection-policies.d.ts +1 -1
  31. package/dist/schema/ensure-collection-tables.d.ts +93 -2
  32. package/dist/schema/generate-schema-commit.d.ts +136 -0
  33. package/dist/schema/generated-schema-staleness.d.ts +19 -0
  34. package/dist/schema/introspect-db-constraints.d.ts +1 -1
  35. package/dist/schema/introspect-db-logic.d.ts +3 -3
  36. package/dist/schema/introspect-db-project.d.ts +1 -1
  37. package/dist/schema/introspect-db-queries.d.ts +1 -1
  38. package/dist/schema/introspect-db-structure.d.ts +2 -2
  39. package/dist/schema/introspect-runtime.d.ts +1 -1
  40. package/dist/schema/vector-index.d.ts +88 -0
  41. package/dist/services/BranchService.d.ts +2 -2
  42. package/dist/services/FetchService.d.ts +4 -4
  43. package/dist/services/PersistService.d.ts +5 -5
  44. package/dist/services/RelationService.d.ts +3 -3
  45. package/dist/services/RelationWriteService.d.ts +3 -3
  46. package/dist/services/cdc/junction-tables.d.ts +1 -1
  47. package/dist/services/cdc/trigger-cdc.d.ts +1 -1
  48. package/dist/services/channel-bus/PostgresChannelBus.d.ts +1 -1
  49. package/dist/services/channel-bus/index.d.ts +2 -2
  50. package/dist/services/collection-helpers.d.ts +1 -1
  51. package/dist/services/dataService.d.ts +10 -10
  52. package/dist/services/index.d.ts +4 -4
  53. package/dist/services/junction-writes.d.ts +2 -2
  54. package/dist/services/nested-path.d.ts +1 -1
  55. package/dist/services/realtimeService.d.ts +3 -3
  56. package/dist/services/row-pipeline.d.ts +1 -1
  57. package/dist/services/write-denial.d.ts +1 -1
  58. package/dist/{src-BBFsDaeA.js → src-DolrXONo.js} +93 -1
  59. package/dist/src-DolrXONo.js.map +1 -0
  60. package/dist/utils/drizzle-conditions.d.ts +2 -2
  61. package/dist/{websocket-BVgDVO-V.js → websocket-7Dp77lTh.js} +43 -6
  62. package/dist/websocket-7Dp77lTh.js.map +1 -0
  63. package/dist/websocket.d.ts +29 -2
  64. package/package.json +7 -7
  65. package/src/PostgresBackendDriver.ts +41 -2
  66. package/src/backup/backup-service.ts +1 -1
  67. package/src/cli-helpers.ts +3 -2
  68. package/src/connection.ts +37 -3
  69. package/src/databasePoolManager.ts +5 -2
  70. package/src/schema/classify-change.ts +436 -0
  71. package/src/schema/ensure-collection-tables.test.ts +168 -1
  72. package/src/schema/ensure-collection-tables.ts +344 -14
  73. package/src/schema/generate-drizzle-schema-logic.ts +23 -11
  74. package/src/schema/generate-drizzle-schema.ts +13 -2
  75. package/src/schema/generate-postgres-ddl-logic.ts +16 -1
  76. package/src/schema/generate-postgres-ddl.ts +13 -2
  77. package/src/schema/generate-schema-commit.ts +242 -0
  78. package/src/schema/generated-schema-staleness.ts +114 -1
  79. package/src/schema/vector-index.ts +278 -0
  80. package/src/services/collection-helpers.ts +3 -2
  81. package/src/websocket.ts +36 -2
  82. package/dist/auth-users-columns-CgyPWQ18.js.map +0 -1
  83. package/dist/connection-BuZ97wsr.js.map +0 -1
  84. package/dist/ensure-collection-tables-BY1pHRD_.js +0 -840
  85. package/dist/ensure-collection-tables-BY1pHRD_.js.map +0 -1
  86. package/dist/rls-enforcement-Ch0T6OwW.js.map +0 -1
  87. package/dist/src-BBFsDaeA.js.map +0 -1
  88. package/dist/utils/table-classification.d.ts +0 -8
  89. package/dist/websocket-BVgDVO-V.js.map +0 -1
  90. package/src/utils/table-classification.ts +0 -16
@@ -1,5 +1,5 @@
1
1
  import { DatabaseAdapter } from "@rebasepro/types";
2
- import type { PostgresDriverConfig } from "./PostgresBootstrapper";
2
+ import type { PostgresDriverConfig } from "./PostgresBootstrapper.js";
3
3
  /**
4
4
  * Creates a Postgres database adapter for Rebase.
5
5
  */
@@ -1,11 +1,11 @@
1
- import { DataService } from "./services/dataService";
2
- import { BranchService } from "./services/BranchService";
3
- import { RealtimeService } from "./services/realtimeService";
4
- import { DatabasePoolManager } from "./databasePoolManager";
5
- import { DrizzleClient } from "./interfaces";
1
+ import { DataService } from "./services/dataService.js";
2
+ import { BranchService } from "./services/BranchService.js";
3
+ import { RealtimeService } from "./services/realtimeService.js";
4
+ import { DatabasePoolManager } from "./databasePoolManager.js";
5
+ 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
- import { PostgresCollectionRegistry } from "./collections/PostgresCollectionRegistry";
8
- import { HistoryService } from "./history/HistoryService";
7
+ import { PostgresCollectionRegistry } from "./collections/PostgresCollectionRegistry.js";
8
+ import { HistoryService } from "./history/HistoryService.js";
9
9
  export declare class PostgresBackendDriver implements DataDriver {
10
10
  db: DrizzleClient;
11
11
  readonly registry: PostgresCollectionRegistry;
@@ -54,6 +54,15 @@ export declare class PostgresBackendDriver implements DataDriver {
54
54
  * allowing test spies applied after construction to take effect.
55
55
  */
56
56
  get admin(): DatabaseAdmin;
57
+ /**
58
+ * The catalogue-reading shim the schema planner wants.
59
+ *
60
+ * Text in, rows out — every statement it issues is a catalogue read keyed by
61
+ * schema name, and schema names are identifiers rather than bindable values,
62
+ * so there is nothing to parameterise. Runs on the driver's own handle, which
63
+ * is the connection whose privileges are already known to work.
64
+ */
65
+ private schemaFactsQueryable;
57
66
  /**
58
67
  * REST-optimised fetch service (include-aware eager-loading).
59
68
  * Delegates to the underlying FetchService (include-aware eager loading),
@@ -5,12 +5,12 @@
5
5
  */
6
6
  import { NodePgDatabase } from "drizzle-orm/node-postgres";
7
7
  import { BackendBootstrapper, CollectionConfig, type RealtimeChannelsConfig } from "@rebasepro/types";
8
- import { PostgresBackendDriver } from "./PostgresBackendDriver";
9
- import { RealtimeService } from "./services/realtimeService";
10
- import { DatabasePoolManager } from "./databasePoolManager";
11
- import { PostgresCollectionRegistry } from "./collections/PostgresCollectionRegistry";
12
- import { type CdcTableRef } from "./services/cdc/trigger-cdc";
13
- import { type UnknownFilterFieldsMode } from "./utils/drizzle-conditions";
8
+ import { PostgresBackendDriver } from "./PostgresBackendDriver.js";
9
+ import { RealtimeService } from "./services/realtimeService.js";
10
+ import { DatabasePoolManager } from "./databasePoolManager.js";
11
+ import { PostgresCollectionRegistry } from "./collections/PostgresCollectionRegistry.js";
12
+ import { type CdcTableRef } from "./services/cdc/trigger-cdc.js";
13
+ import { type UnknownFilterFieldsMode } from "./utils/drizzle-conditions.js";
14
14
  export interface PostgresDriverConfig {
15
15
  connectionString?: string;
16
16
  adminConnectionString?: string;
@@ -1,5 +1,5 @@
1
1
  import { NodePgDatabase } from "drizzle-orm/node-postgres";
2
- import type { RebasePgTable } from "../types";
2
+ import type { RebasePgTable } from "../types.js";
3
3
  import { UserRepository, TokenRepository, MfaRepository, AuthRepository, UserData, CreateUserData, RoleData, CreateRoleData, RefreshTokenInfo, RefreshTokenSession, PasswordResetTokenInfo, MagicLinkTokenInfo, UserIdentityData, ListUsersOptions, PaginatedUsersResult, MfaFactor, MfaChallengeInfo, RoleData as Role } from "@rebasepro/server";
4
4
  export type { Role };
5
5
  export interface AuthSchemaTables {
@@ -1,6 +1,6 @@
1
1
  import type { CronJobDefinition } from "@rebasepro/types";
2
2
  import type { StorageController } from "@rebasepro/server";
3
- import { BackupDestination } from "./pg-tools";
3
+ import { BackupDestination } from "./pg-tools.js";
4
4
  export interface BackupCronConfig {
5
5
  /** Cron expression, e.g. `"0 3 * * *"` for 03:00 daily. */
6
6
  schedule: string;
@@ -1,6 +1,6 @@
1
1
  import type { StorageController } from "@rebasepro/server";
2
- import { BackupDestination, type RowSecurityIdentity, VersionCompatibility } from "./pg-tools";
3
- import { BackupObject, RetentionOptions } from "./retention";
2
+ import { BackupDestination, type RowSecurityIdentity, VersionCompatibility } from "./pg-tools.js";
3
+ import { BackupObject, RetentionOptions } from "./retention.js";
4
4
  /**
5
5
  * Remove a dump artifact abandoned by a failed tool run. See
6
6
  * {@link discardPartialDumpWith} for why this exists and why the logic lives
@@ -6,7 +6,7 @@
6
6
  * - `backup-service`— pg_dump/pg_restore + storage orchestration
7
7
  * - `backup-cron` — scheduled backups for the server cron system
8
8
  */
9
- export * from "./pg-tools";
10
- export * from "./retention";
11
- export * from "./backup-service";
12
- export * from "./backup-cron";
9
+ export * from "./pg-tools.js";
10
+ export * from "./retention.js";
11
+ export * from "./backup-service.js";
12
+ export * from "./backup-cron.js";
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __createRequire } from "module";
2
2
  import process from "process";
3
3
  __createRequire(import.meta.url);
4
- import { c as __exportAll, l as __require, s as __commonJSMin, u as __toESM } from "./connection-BuZ97wsr.js";
5
- import "./src-BBFsDaeA.js";
4
+ import { d as __require, f as __toESM, l as __commonJSMin, u as __exportAll } from "./connection-GOKU3Hu5.js";
5
+ import "./src-DolrXONo.js";
6
6
  import fs from "fs";
7
7
  import path from "path";
8
8
  import os from "os";
@@ -8992,7 +8992,7 @@ async function uploadBackup(storage, localFile, dest) {
8992
8992
  key,
8993
8993
  bucket: dest.bucket,
8994
8994
  metadata: { "rebase-backup": "1" }
8995
- })).storageUrl ?? `${dest.kind}://${dest.bucket}/${key}`
8995
+ })).storageUrl
8996
8996
  };
8997
8997
  }
8998
8998
  /**
@@ -9040,4 +9040,4 @@ async function pruneBackups(dest, options, storage) {
9040
9040
  //#endregion
9041
9041
  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
9042
 
9043
- //# sourceMappingURL=backup-service-BZoixhVl.js.map
9043
+ //# sourceMappingURL=backup-service-FN6V3rVi.js.map