@rebasepro/server-postgres 0.12.1-canary.g5f403cf → 0.12.1-canary.g6fba3a4

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 (57) hide show
  1. package/dist/PostgresBackendDriver.d.ts +1 -1
  2. package/dist/PostgresBootstrapper.d.ts +25 -1
  3. package/dist/{backup-service-DH9kPg-E.js → backup-service-DLb2drIH.js} +9 -2
  4. package/dist/backup-service-DLb2drIH.js.map +1 -0
  5. package/dist/cli-helpers.d.ts +39 -0
  6. package/dist/{connection-B5Wndbr1.js → connection-BuZ97wsr.js} +57 -3
  7. package/dist/connection-BuZ97wsr.js.map +1 -0
  8. package/dist/connection.d.ts +42 -0
  9. package/dist/ensure-collection-policies-Dv21KDMJ.js +57 -0
  10. package/dist/ensure-collection-policies-Dv21KDMJ.js.map +1 -0
  11. package/dist/ensure-collection-tables-CT6xHB1d.js +650 -0
  12. package/dist/ensure-collection-tables-CT6xHB1d.js.map +1 -0
  13. package/dist/index.es.js +279 -60
  14. package/dist/index.es.js.map +1 -1
  15. package/dist/policy-CeA1JcxP.js +105 -0
  16. package/dist/policy-CeA1JcxP.js.map +1 -0
  17. package/dist/schema/ensure-collection-policies.d.ts +60 -0
  18. package/dist/schema/ensure-collection-tables.d.ts +44 -2
  19. package/dist/schema/generate-postgres-ddl-logic.d.ts +135 -1
  20. package/dist/services/FetchService.d.ts +4 -1
  21. package/dist/services/dataService.d.ts +3 -1
  22. package/dist/services/row-pipeline.d.ts +1 -1
  23. package/dist/{src-DihrDFuP.js → src-BkdpiQdw.js} +147 -97
  24. package/dist/src-BkdpiQdw.js.map +1 -0
  25. package/dist/utils/pg-error-utils.d.ts +19 -0
  26. package/dist/{websocket-BKcGvILX.js → websocket-B2LsrINK.js} +8 -6
  27. package/dist/websocket-B2LsrINK.js.map +1 -0
  28. package/package.json +6 -6
  29. package/src/PostgresAdapter.ts +21 -2
  30. package/src/PostgresBackendDriver.ts +4 -0
  31. package/src/PostgresBootstrapper.ts +192 -33
  32. package/src/cli-helpers.ts +70 -0
  33. package/src/cli.ts +33 -22
  34. package/src/connection.ts +73 -0
  35. package/src/databasePoolManager.ts +5 -2
  36. package/src/schema/ensure-collection-policies.ts +105 -0
  37. package/src/schema/ensure-collection-tables.test.ts +105 -9
  38. package/src/schema/ensure-collection-tables.ts +220 -32
  39. package/src/schema/generate-drizzle-schema-logic.ts +9 -2
  40. package/src/schema/generate-postgres-ddl-logic.ts +375 -16
  41. package/src/schema/introspect-db-logic.ts +21 -3
  42. package/src/schema/introspect-runtime.test.ts +56 -8
  43. package/src/schema/introspect-runtime.ts +31 -9
  44. package/src/security/policy-drift.test.ts +11 -3
  45. package/src/services/FetchService.ts +76 -14
  46. package/src/services/RelationService.ts +38 -3
  47. package/src/services/dataService.ts +3 -1
  48. package/src/services/realtimeService.ts +3 -3
  49. package/src/services/row-pipeline.ts +1 -1
  50. package/src/utils/pg-error-utils.ts +46 -0
  51. package/src/websocket.ts +18 -9
  52. package/dist/backup-service-DH9kPg-E.js.map +0 -1
  53. package/dist/connection-B5Wndbr1.js.map +0 -1
  54. package/dist/ensure-collection-tables-CIHSH962.js +0 -304
  55. package/dist/ensure-collection-tables-CIHSH962.js.map +0 -1
  56. package/dist/src-DihrDFuP.js.map +0 -1
  57. package/dist/websocket-BKcGvILX.js.map +0 -1
@@ -105,7 +105,7 @@ export declare class PostgresBackendDriver implements DataDriver {
105
105
  delete<M extends Record<string, unknown>>({ row, collection }: DeleteProps<M>): Promise<void>;
106
106
  deleteAll(path: string): Promise<void>;
107
107
  checkUniqueField(path: string, name: string, value: unknown, id?: string, collection?: CollectionConfig): Promise<boolean>;
108
- count<M extends Record<string, unknown>>({ path, collection, filter, searchString }: FetchCollectionProps<M>): Promise<number>;
108
+ count<M extends Record<string, unknown>>({ path, collection, filter, logical, searchString }: FetchCollectionProps<M>): Promise<number>;
109
109
  private getTargetDb;
110
110
  executeSql(sqlText: string, options?: {
111
111
  database?: string;
@@ -4,7 +4,7 @@
4
4
  * Implements the `BackendBootstrapper` interface for PostgreSQL.
5
5
  */
6
6
  import { NodePgDatabase } from "drizzle-orm/node-postgres";
7
- import { BackendBootstrapper, type RealtimeChannelsConfig } from "@rebasepro/types";
7
+ import { BackendBootstrapper, CollectionConfig, type RealtimeChannelsConfig } from "@rebasepro/types";
8
8
  import { PostgresBackendDriver } from "./PostgresBackendDriver";
9
9
  import { RealtimeService } from "./services/realtimeService";
10
10
  import { DatabasePoolManager } from "./databasePoolManager";
@@ -65,6 +65,30 @@ export interface PostgresDriverInternals {
65
65
  */
66
66
  provisionCdcForTables?: (tables: CdcTableRef[]) => Promise<void>;
67
67
  }
68
+ /**
69
+ * Which table name the boot-time drift check should look for, for one collection.
70
+ *
71
+ * A declared `table` IS the table name, not a hint to be second-guessed. This
72
+ * used to ask the registry whether it had indexed the declared name and fall
73
+ * back to the SLUG when it had not — but "the registry does not know this table"
74
+ * is exactly the condition the drift check exists to report, so the fallback
75
+ * fired precisely when it was most harmful.
76
+ *
77
+ * A collection with `slug: "usage-daily", table: "usage_daily"` was reported as
78
+ * missing table `usage-daily`: a name that does not exist, should never exist,
79
+ * and that nobody can find by looking. Worse, the remediation the caller prints
80
+ * says to run `rebase db push` — which would then CREATE that invented table
81
+ * beside the correct one, the same "second copy" hazard the misplaced-schema
82
+ * branch further down exists to prevent. Seen in production, where a correctly
83
+ * migrated database reported drift on every boot.
84
+ *
85
+ * The slug is used only when nothing was declared, which is the config shape
86
+ * where the slug genuinely is the table name.
87
+ *
88
+ * Exported for its own test: the caller needs a live pool and a real database,
89
+ * and this is the part that was wrong.
90
+ */
91
+ export declare function resolveDriftCheckName(col: CollectionConfig, registeredTableNames: string[]): string;
68
92
  /**
69
93
  * Default PostgreSQL bootstrapper.
70
94
  *
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __createRequire } from "module";
2
2
  import process from "process";
3
3
  __createRequire(import.meta.url);
4
- import { c as __require, l as __toESM, o as __commonJSMin, s as __exportAll } from "./connection-B5Wndbr1.js";
4
+ import { c as __exportAll, l as __require, s as __commonJSMin, u as __toESM } from "./connection-BuZ97wsr.js";
5
5
  import "./src-DoU9yPqq.js";
6
6
  import "@rebasepro/server";
7
7
  import fs from "fs";
@@ -23,6 +23,7 @@ import { appendFileSync, createReadStream, createWriteStream, readFileSync, stat
23
23
  import { finished } from "node:stream/promises";
24
24
  import { Duplex, PassThrough, Readable, Transform, Writable, getDefaultHighWaterMark } from "node:stream";
25
25
  import { Buffer as Buffer$1 } from "node:buffer";
26
+ import "module";
26
27
  import { fileURLToPath as fileURLToPath$1 } from "url";
27
28
  //#region src/backup/pg-tools.ts
28
29
  /**
@@ -6446,6 +6447,11 @@ createExeca(mapNode);
6446
6447
  createExeca(mapScriptAsync, {}, deepScriptOptions, setScriptSync);
6447
6448
  var { sendMessage, getOneMessage, getEachMessage, getCancelSignal } = getIpcExport();
6448
6449
  //#endregion
6450
+ //#region __vite-browser-external
6451
+ var require___vite_browser_external = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6452
+ module.exports = {};
6453
+ }));
6454
+ //#endregion
6449
6455
  //#region ../../node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js
6450
6456
  var require_color_name = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6451
6457
  module.exports = {
@@ -8495,6 +8501,7 @@ var require_source = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8495
8501
  chalk.stderr.supportsColor = stderrColor;
8496
8502
  module.exports = chalk;
8497
8503
  }));
8504
+ require___vite_browser_external();
8498
8505
  require_source();
8499
8506
  var moduleDir = path.dirname(fileURLToPath$1(import.meta.url));
8500
8507
  //#endregion
@@ -8863,4 +8870,4 @@ async function pruneBackups(dest, options, storage) {
8863
8870
  //#endregion
8864
8871
  export { serverVersionNumToMajor as A, globalsFileForDump as C, parseDbNameFromUrl as D, parseBackupTimestamp as E, withDatabaseName as M, parsePgToolMajor as O, checkToolServerCompatibility as S, parseBackupDestination as T, buildBackupFilename as _, detectToolMajor as a, buildPgRestoreArgs as b, listBackups as c, resolvePgBinary as d, restoreDump as f, selectBackupsToPrune as g, require_source as h, createDump as i, splitGlobalsStatements as j, resolveConnectionString as k, preflight as l, validateDump as m, applyGlobals as n, ensureDatabaseExists as o, uploadBackup as p, backup_service_exports as r, getServerVersionMajor as s, BackupToolError as t, pruneBackups as u, buildPgDumpArgs as v, joinStorageKey as w, buildPgRestoreListArgs as x, buildPgDumpallGlobalsArgs as y };
8865
8872
 
8866
- //# sourceMappingURL=backup-service-DH9kPg-E.js.map
8873
+ //# sourceMappingURL=backup-service-DLb2drIH.js.map