@rebasepro/server-postgres 0.19.1 → 0.19.2-canary.g08eed46
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/{BranchService-ByLfM_Tt.js → BranchService-W3DMfcZZ.js} +2 -2
- package/dist/{BranchService-ByLfM_Tt.js.map → BranchService-W3DMfcZZ.js.map} +1 -1
- package/dist/PostgresBackendDriver.d.ts +81 -7
- package/dist/PostgresBootstrapper.d.ts +10 -0
- package/dist/{backup-cli-oM9WQVlV.js → backup-cli-DSpQyqcG.js} +2 -2
- package/dist/{backup-cli-oM9WQVlV.js.map → backup-cli-DSpQyqcG.js.map} +1 -1
- package/dist/{backup-service-Br3tqwsy.js → backup-service-DA7a6SUV.js} +2 -2
- package/dist/{backup-service-Br3tqwsy.js.map → backup-service-DA7a6SUV.js.map} +1 -1
- package/dist/{cli-errors-DxN4yzdH.js → cli-errors-C3g_kHBw.js} +137 -18
- package/dist/cli-errors-C3g_kHBw.js.map +1 -0
- package/dist/cli-errors.d.ts +19 -0
- package/dist/cli-helpers.d.ts +47 -0
- package/dist/cli.js +233 -19
- package/dist/cli.js.map +1 -1
- package/dist/{collection-index-BHgT_TKd.js → collection-index-DdnsxiJ_.js} +14 -4
- package/dist/{collection-index-BHgT_TKd.js.map → collection-index-DdnsxiJ_.js.map} +1 -1
- package/dist/collections/validate-relations.d.ts +7 -0
- package/dist/column-plan-helpers-CpILzHJS.js +145 -0
- package/dist/column-plan-helpers-CpILzHJS.js.map +1 -0
- package/dist/{doctor-D7HWmGzs.js → doctor-D5SrGJ5P.js} +175 -61
- package/dist/doctor-D5SrGJ5P.js.map +1 -0
- package/dist/{ensure-collection-policies-2c2NV8zX.js → ensure-collection-policies-CHO0moXQ.js} +5 -5
- package/dist/{ensure-collection-policies-2c2NV8zX.js.map → ensure-collection-policies-CHO0moXQ.js.map} +1 -1
- package/dist/{ensure-collection-tables-D4wJzM4y.js → ensure-collection-tables-Bkvehxdm.js} +318 -312
- package/dist/ensure-collection-tables-Bkvehxdm.js.map +1 -0
- package/dist/{ensure-tables-CIojK-Rx.js → ensure-tables-CYMtuuOd.js} +2 -2
- package/dist/{ensure-tables-CIojK-Rx.js.map → ensure-tables-CYMtuuOd.js.map} +1 -1
- package/dist/generate-drizzle-schema-logic-Dfyf_MRu.js +228 -0
- package/dist/generate-drizzle-schema-logic-Dfyf_MRu.js.map +1 -0
- package/dist/{generate-drizzle-schema-CwEgVyjO.js → generate-drizzle-schema-vSK-VdYT.js} +3 -3
- package/dist/generate-drizzle-schema-vSK-VdYT.js.map +1 -0
- package/dist/generate-postgres-ddl-logic-CR2xcS7e.js +475 -0
- package/dist/generate-postgres-ddl-logic-CR2xcS7e.js.map +1 -0
- package/dist/{generated-schema-staleness-DQdfJl2A.js → generated-schema-staleness-DRQe2BpC.js} +81 -3
- package/dist/{generated-schema-staleness-DQdfJl2A.js.map → generated-schema-staleness-DRQe2BpC.js.map} +1 -1
- package/dist/history/HistoryService.d.ts +23 -4
- package/dist/index.es.js +1991 -580
- package/dist/index.es.js.map +1 -1
- package/dist/introspect-db-logic-C6LQdTxj.js.map +1 -1
- package/dist/plan-schema-Hgl62S-w.js +1531 -0
- package/dist/plan-schema-Hgl62S-w.js.map +1 -0
- package/dist/{policy-drift-kNJ6X2Uj.js → policy-drift-B0GDRh7_.js} +2 -2
- package/dist/{policy-drift-kNJ6X2Uj.js.map → policy-drift-B0GDRh7_.js.map} +1 -1
- package/dist/{rls-bootstrap-sql-DLDnUjtx.js → rls-bootstrap-sql-BlzsOUtz.js} +111 -8
- package/dist/{rls-bootstrap-sql-DLDnUjtx.js.map → rls-bootstrap-sql-BlzsOUtz.js.map} +1 -1
- package/dist/{rls-enforcement-DeYEjYLt.js → rls-enforcement-BV12vBwQ.js} +2 -1
- package/dist/rls-enforcement-BV12vBwQ.js.map +1 -0
- package/dist/schema/catalogue-schema.d.ts +97 -0
- package/dist/schema/collection-index.d.ts +9 -0
- package/dist/schema/column-plan-helpers.d.ts +125 -0
- package/dist/schema/config-relations.d.ts +32 -0
- package/dist/schema/doctor-cli.js +4 -4
- package/dist/schema/doctor.d.ts +9 -0
- package/dist/schema/dynamic-tables.d.ts +27 -6
- package/dist/schema/ensure-collection-tables.d.ts +31 -268
- package/dist/schema/generate-drizzle-schema-logic.d.ts +26 -8
- package/dist/schema/generate-drizzle-schema.js +1 -1
- package/dist/schema/generate-postgres-ddl-logic.d.ts +84 -168
- package/dist/schema/generate-postgres-ddl.js +8 -2
- package/dist/schema/generate-postgres-ddl.js.map +1 -1
- package/dist/schema/generated-column-conflicts.d.ts +84 -0
- package/dist/schema/generated-schema-diff.d.ts +56 -0
- package/dist/schema/generated-schema-staleness.d.ts +33 -0
- package/dist/schema/introspect-db-logic.d.ts +2 -0
- package/dist/schema/plan/diff-plan.d.ts +220 -0
- package/dist/schema/plan/plan-schema.d.ts +84 -0
- package/dist/schema/plan/render-ddl.d.ts +62 -0
- package/dist/schema/plan/render-drizzle.d.ts +31 -0
- package/dist/schema/plan/types.d.ts +410 -0
- package/dist/schema/plan/updated-at-trigger.d.ts +22 -0
- package/dist/schema/relation-names.d.ts +28 -0
- package/dist/schema/search-column.d.ts +9 -0
- package/dist/security/rls-enforcement.d.ts +17 -0
- package/dist/services/FetchService.d.ts +176 -36
- package/dist/services/PersistService.d.ts +17 -4
- package/dist/services/RelationService.d.ts +11 -3
- package/dist/services/collection-helpers.d.ts +16 -2
- package/dist/services/dataService.d.ts +29 -2
- package/dist/services/field-op-sql.d.ts +16 -0
- package/dist/services/field-viewer.d.ts +19 -0
- package/dist/services/realtimeService.d.ts +35 -1
- package/dist/services/row-pipeline.d.ts +29 -5
- package/dist/services/soft-delete.d.ts +73 -0
- package/dist/utils/pg-error-utils.d.ts +41 -1
- package/dist/{vector-index-DkWxm2de.js → vector-index-CMJKb3C9.js} +3 -14
- package/dist/{vector-index-DkWxm2de.js.map → vector-index-CMJKb3C9.js.map} +1 -1
- package/package.json +18 -10
- package/dist/cli-errors-DxN4yzdH.js.map +0 -1
- package/dist/doctor-D7HWmGzs.js.map +0 -1
- package/dist/ensure-collection-tables-D4wJzM4y.js.map +0 -1
- package/dist/generate-drizzle-schema-CwEgVyjO.js.map +0 -1
- package/dist/generate-drizzle-schema-logic-so2Z_lyC.js +0 -528
- package/dist/generate-drizzle-schema-logic-so2Z_lyC.js.map +0 -1
- package/dist/generate-postgres-ddl-logic-CtnpIBVv.js +0 -1312
- package/dist/generate-postgres-ddl-logic-CtnpIBVv.js.map +0 -1
- package/dist/rls-enforcement-DeYEjYLt.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
__createRequire(import.meta.url);
|
|
3
3
|
import { a as __toESM, i as __require, n as __commonJSMin, r as __exportAll, t as require___vite_browser_external } from "./__vite-browser-external-BnuHet1e.js";
|
|
4
|
-
import { o as isRebaseIndexName } from "./collection-index-
|
|
4
|
+
import { o as isRebaseIndexName } from "./collection-index-DdnsxiJ_.js";
|
|
5
5
|
import { r as outWarn, t as out } from "./cli-output-CNdMql-L.js";
|
|
6
6
|
import { t as chalk } from "./source-Br7L7GOI.js";
|
|
7
7
|
import { LEGACY_RLS_SCHEMA, REBASE_SCHEMA, isManyToMany } from "@rebasepro/types";
|
|
@@ -6609,10 +6609,68 @@ async function applySearchDdl(databaseUrl, drizzleDir = path.resolve(process.cwd
|
|
|
6609
6609
|
* `search` block, which is every project that has not opted in.
|
|
6610
6610
|
*/
|
|
6611
6611
|
async function getSearchExcludes(collectionsPath) {
|
|
6612
|
-
const { searchExcludePatterns } = await import("./generate-postgres-ddl-logic-
|
|
6612
|
+
const { searchExcludePatterns } = await import("./generate-postgres-ddl-logic-CR2xcS7e.js").then((n) => n.o);
|
|
6613
6613
|
return searchExcludePatterns(await loadCollectionsForCli(collectionsPath));
|
|
6614
6614
|
}
|
|
6615
6615
|
/**
|
|
6616
|
+
* Every `generated column → column it reads` edge in the database.
|
|
6617
|
+
*
|
|
6618
|
+
* Read from `pg_depend` rather than by matching names in the expression text:
|
|
6619
|
+
* a generated column's `pg_attrdef` row carries one `deptype = 'n'` dependency
|
|
6620
|
+
* per column its expression references, which is the catalogue's own answer and
|
|
6621
|
+
* cannot be fooled by a column name that also appears inside a string literal
|
|
6622
|
+
* or as part of a longer identifier.
|
|
6623
|
+
*
|
|
6624
|
+
* Used by `db push` to find what has to come out of the way before Atlas runs —
|
|
6625
|
+
* see `generated-column-conflicts.ts` for why that is necessary at all.
|
|
6626
|
+
*/
|
|
6627
|
+
async function queryGeneratedColumnDependencies(databaseUrl) {
|
|
6628
|
+
const { Client } = await import("pg");
|
|
6629
|
+
const client = new Client({ connectionString: databaseUrl });
|
|
6630
|
+
await client.connect();
|
|
6631
|
+
try {
|
|
6632
|
+
return (await client.query(`
|
|
6633
|
+
SELECT n.nspname AS "schema",
|
|
6634
|
+
c.relname AS "table",
|
|
6635
|
+
gen.attname AS "column",
|
|
6636
|
+
dep.attname AS "dependsOn"
|
|
6637
|
+
FROM pg_attrdef ad
|
|
6638
|
+
JOIN pg_class c ON c.oid = ad.adrelid
|
|
6639
|
+
JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
6640
|
+
JOIN pg_attribute gen ON gen.attrelid = ad.adrelid AND gen.attnum = ad.adnum
|
|
6641
|
+
JOIN pg_depend d ON d.classid = 'pg_attrdef'::regclass
|
|
6642
|
+
AND d.objid = ad.oid
|
|
6643
|
+
AND d.refclassid = 'pg_class'::regclass
|
|
6644
|
+
AND d.refobjid = ad.adrelid
|
|
6645
|
+
AND d.deptype = 'n'
|
|
6646
|
+
JOIN pg_attribute dep ON dep.attrelid = ad.adrelid AND dep.attnum = d.refobjsubid
|
|
6647
|
+
WHERE gen.attgenerated <> ''
|
|
6648
|
+
AND NOT gen.attisdropped
|
|
6649
|
+
AND NOT dep.attisdropped;
|
|
6650
|
+
`)).rows;
|
|
6651
|
+
} finally {
|
|
6652
|
+
await client.end();
|
|
6653
|
+
}
|
|
6654
|
+
}
|
|
6655
|
+
/**
|
|
6656
|
+
* Drop the generated columns standing in the way of an apply.
|
|
6657
|
+
*
|
|
6658
|
+
* Their indexes and their `COMMENT ON COLUMN` stamp go with them, which is
|
|
6659
|
+
* exactly right: `applySearchDdl` rebuilds all three from `search.sql` and a
|
|
6660
|
+
* surviving stamp would make the rebuilt column look like drift.
|
|
6661
|
+
*/
|
|
6662
|
+
async function dropGeneratedColumns(databaseUrl, statements) {
|
|
6663
|
+
if (statements.length === 0) return;
|
|
6664
|
+
const { Client } = await import("pg");
|
|
6665
|
+
const client = new Client({ connectionString: databaseUrl });
|
|
6666
|
+
await client.connect();
|
|
6667
|
+
try {
|
|
6668
|
+
for (const statement of statements) await client.query(statement);
|
|
6669
|
+
} finally {
|
|
6670
|
+
await client.end();
|
|
6671
|
+
}
|
|
6672
|
+
}
|
|
6673
|
+
/**
|
|
6616
6674
|
* The generated SQL for the project's `vector` properties, if it has any.
|
|
6617
6675
|
*
|
|
6618
6676
|
* @param drizzleDir directory holding the generated SQL. Defaults to `drizzle`
|
|
@@ -6641,7 +6699,7 @@ function readVectorDdl(drizzleDir = path.resolve(process.cwd(), "drizzle")) {
|
|
|
6641
6699
|
async function applyVectorDdl(databaseUrl, drizzleDir = path.resolve(process.cwd(), "drizzle")) {
|
|
6642
6700
|
const sql = readVectorDdl(drizzleDir);
|
|
6643
6701
|
if (!sql) return;
|
|
6644
|
-
const { vectorExtensionHint } = await import("./vector-index-
|
|
6702
|
+
const { vectorExtensionHint } = await import("./vector-index-CMJKb3C9.js").then((n) => n.f);
|
|
6645
6703
|
const { Client } = await import("pg");
|
|
6646
6704
|
const client = new Client({ connectionString: databaseUrl });
|
|
6647
6705
|
await client.connect();
|
|
@@ -6664,10 +6722,54 @@ async function applyVectorDdl(databaseUrl, drizzleDir = path.resolve(process.cwd
|
|
|
6664
6722
|
* `vector` property, which is every project that has not opted in.
|
|
6665
6723
|
*/
|
|
6666
6724
|
async function getVectorExcludes(collectionsPath) {
|
|
6667
|
-
const { vectorExcludePatterns } = await import("./generate-postgres-ddl-logic-
|
|
6725
|
+
const { vectorExcludePatterns } = await import("./generate-postgres-ddl-logic-CR2xcS7e.js").then((n) => n.o);
|
|
6668
6726
|
return vectorExcludePatterns(await loadCollectionsForCli(collectionsPath));
|
|
6669
6727
|
}
|
|
6670
6728
|
/**
|
|
6729
|
+
* The generated SQL for the project's `autoValue: "on_update"` properties, if
|
|
6730
|
+
* it has any.
|
|
6731
|
+
*
|
|
6732
|
+
* @param drizzleDir directory holding the generated SQL. Defaults to `drizzle`
|
|
6733
|
+
* under the working directory.
|
|
6734
|
+
*/
|
|
6735
|
+
function readTriggersDdl(drizzleDir = path.resolve(process.cwd(), "drizzle")) {
|
|
6736
|
+
const triggersFile = path.join(drizzleDir, "triggers.sql");
|
|
6737
|
+
if (!fs.existsSync(triggersFile)) return "";
|
|
6738
|
+
return fs.readFileSync(triggersFile, "utf-8").trim();
|
|
6739
|
+
}
|
|
6740
|
+
/**
|
|
6741
|
+
* Install the `updated_at` trigger function and bind it to every column that
|
|
6742
|
+
* asked for one.
|
|
6743
|
+
*
|
|
6744
|
+
* Runs *after* Atlas, like {@link applySearchDdl} and {@link applyVectorDdl}:
|
|
6745
|
+
* a trigger needs its table and its column to exist. Atlas is told to ignore
|
|
6746
|
+
* the triggers ({@link getTriggerExcludes}) because it cannot manage a function
|
|
6747
|
+
* at all — its free tier refuses to parse a desired state containing one.
|
|
6748
|
+
*
|
|
6749
|
+
* A no-op when no property declares `autoValue: "on_update"`. A failure is
|
|
6750
|
+
* *not* swallowed: a push that reported success while the trigger never
|
|
6751
|
+
* appeared is how `updated_at` ends up silently stale for every writer that is
|
|
6752
|
+
* not the driver, which is the whole reason the trigger exists.
|
|
6753
|
+
*/
|
|
6754
|
+
async function applyTriggersDdl(databaseUrl, drizzleDir = path.resolve(process.cwd(), "drizzle")) {
|
|
6755
|
+
const sql = readTriggersDdl(drizzleDir);
|
|
6756
|
+
if (!sql) return;
|
|
6757
|
+
const { Client } = await import("pg");
|
|
6758
|
+
const client = new Client({ connectionString: databaseUrl });
|
|
6759
|
+
await client.connect();
|
|
6760
|
+
try {
|
|
6761
|
+
await client.query(sql);
|
|
6762
|
+
} finally {
|
|
6763
|
+
await client.end();
|
|
6764
|
+
}
|
|
6765
|
+
out(chalk.gray(" ✓ Applied `updated_at` triggers"));
|
|
6766
|
+
}
|
|
6767
|
+
/** @see getSearchExcludes */
|
|
6768
|
+
async function getTriggerExcludes(collectionsPath) {
|
|
6769
|
+
const { triggerExcludePatterns } = await import("./generate-postgres-ddl-logic-CR2xcS7e.js").then((n) => n.o);
|
|
6770
|
+
return triggerExcludePatterns(await loadCollectionsForCli(collectionsPath));
|
|
6771
|
+
}
|
|
6772
|
+
/**
|
|
6671
6773
|
* Query the live database for every user table/view outside the system
|
|
6672
6774
|
* catalogs. Separated from {@link getTableExcludes} so its failure mode can
|
|
6673
6775
|
* be handled explicitly (fail closed) and so tests can inject a stub.
|
|
@@ -6750,8 +6852,9 @@ async function getForeignIndexExcludes(databaseUrl, collectionsPath, deps = {})
|
|
|
6750
6852
|
*/
|
|
6751
6853
|
async function managedIndexNames(collectionsPath) {
|
|
6752
6854
|
const collections = await loadCollectionsForCli(collectionsPath);
|
|
6753
|
-
const {
|
|
6754
|
-
const {
|
|
6855
|
+
const { searchExcludePatterns, vectorExcludePatterns } = await import("./generate-postgres-ddl-logic-CR2xcS7e.js").then((n) => n.o);
|
|
6856
|
+
const { resolveColumnName } = await import("./column-plan-helpers-CpILzHJS.js").then((n) => n.n);
|
|
6857
|
+
const { buildCollectionIndexPlan } = await import("./collection-index-DdnsxiJ_.js").then((n) => n.i);
|
|
6755
6858
|
const names = new Set(buildCollectionIndexPlan(collections, resolveColumnName).map((spec) => spec.indexName));
|
|
6756
6859
|
for (const pattern of [...searchExcludePatterns(collections), ...vectorExcludePatterns(collections)]) names.add(pattern.slice(pattern.lastIndexOf(".") + 1));
|
|
6757
6860
|
return names;
|
|
@@ -7087,6 +7190,6 @@ async function dropLegacyAuthSchema(run, report) {
|
|
|
7087
7190
|
}
|
|
7088
7191
|
}
|
|
7089
7192
|
//#endregion
|
|
7090
|
-
export {
|
|
7193
|
+
export { execa as A, loadCollectionsForCli as C, readTriggersDdl as D, readSearchDdl as E, readVectorDdl as O, getVectorExcludes as S, queryGeneratedColumnDependencies as T, getDevDatabaseUrl as _, ExcludeIntrospectionError as a, getTableExcludes as b, applyVectorDdl as c, describeReinstallCommand as d, detectProjectPackageManager as f, ensureDevDatabaseExists as g, dropGeneratedColumns as h, rls_bootstrap_sql_exports as i, forLibpq as j, resolveLocalBin as k, describeBuildScriptRemedy as l, dropDevDatabase as m, RLS_BOOTSTRAP_STATEMENTS as n, applySearchDdl as o, diagnoseMissingBin as p, dropLegacyAuthSchema as r, applyTriggersDdl as s, RLS_BOOTSTRAP_SQL as t, describeDevAddCommand as u, getForeignIndexExcludes as v, promptConfirm as w, getTriggerExcludes as x, getSearchExcludes as y };
|
|
7091
7194
|
|
|
7092
|
-
//# sourceMappingURL=rls-bootstrap-sql-
|
|
7195
|
+
//# sourceMappingURL=rls-bootstrap-sql-BlzsOUtz.js.map
|