@rebasepro/server-postgres 0.25.1 → 0.26.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.
- package/dist/{BranchService-ClklxyAQ.js → BranchService-CWBnDhcv.js} +25 -9
- package/dist/BranchService-CWBnDhcv.js.map +1 -0
- package/dist/PostgresBackendDriver.d.ts +13 -0
- package/dist/PostgresBootstrapper.d.ts +7 -0
- package/dist/auth/services.d.ts +8 -1
- package/dist/auth/verify-auth-tables.d.ts +21 -0
- package/dist/{backup-cli-gijeXe0u.js → backup-cli-PoRG-zEq.js} +3 -3
- package/dist/{backup-cli-gijeXe0u.js.map → backup-cli-PoRG-zEq.js.map} +1 -1
- package/dist/{boot-ddl-DYH95Qeg.js → boot-ddl-EsgqDkx0.js} +2 -2
- package/dist/{boot-ddl-DYH95Qeg.js.map → boot-ddl-EsgqDkx0.js.map} +1 -1
- package/dist/branch-diff-CxE4VlxT.js +1396 -0
- package/dist/branch-diff-CxE4VlxT.js.map +1 -0
- package/dist/branch-diff-report-DpvVf7hR.js +48 -0
- package/dist/branch-diff-report-DpvVf7hR.js.map +1 -0
- package/dist/branching/branch-diff-report.d.ts +7 -0
- package/dist/branching/branch-diff.d.ts +115 -0
- package/dist/{cli-console-CQrQ0lAY.js → cli-console-f0k6_TsJ.js} +38 -5
- package/dist/cli-console-f0k6_TsJ.js.map +1 -0
- package/dist/cli-console.d.ts +17 -1
- package/dist/{cli-errors-DiA0XFIS.js → cli-errors-DsYyNYzd.js} +53 -2
- package/dist/cli-errors-DsYyNYzd.js.map +1 -0
- package/dist/cli.js +102 -122
- package/dist/cli.js.map +1 -1
- package/dist/{collections-schema-version-T6cGvrDi.js → collections-schema-version-D7bDI0PJ.js} +13 -9
- package/dist/collections-schema-version-D7bDI0PJ.js.map +1 -0
- package/dist/{deferred-index-build-BE0I6sYU.js → deferred-index-build-CqaOv1Xx.js} +3 -3
- package/dist/{deferred-index-build-BE0I6sYU.js.map → deferred-index-build-CqaOv1Xx.js.map} +1 -1
- package/dist/{doctor-BT--1kq3.js → doctor-DW_mlTzz.js} +81 -33
- package/dist/doctor-DW_mlTzz.js.map +1 -0
- package/dist/{ensure-collection-policies-BnGOURpG.js → ensure-collection-policies-DLWgabQ2.js} +5 -5
- package/dist/{ensure-collection-policies-BnGOURpG.js.map → ensure-collection-policies-DLWgabQ2.js.map} +1 -1
- package/dist/{ensure-collection-tables-Cet4650m.js → ensure-collection-tables-CFIRq8ni.js} +5 -5
- package/dist/{ensure-collection-tables-Cet4650m.js.map → ensure-collection-tables-CFIRq8ni.js.map} +1 -1
- package/dist/{ensure-tables-l_OgFQjN.js → ensure-tables-4nA-tfwi.js} +4 -4
- package/dist/{ensure-tables-l_OgFQjN.js.map → ensure-tables-4nA-tfwi.js.map} +1 -1
- package/dist/{enum-labels-kept-nheku1pB.js → enum-labels-kept-PcPW65xy.js} +2 -2
- package/dist/{enum-labels-kept-nheku1pB.js.map → enum-labels-kept-PcPW65xy.js.map} +1 -1
- package/dist/history/HistoryService.d.ts +7 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.es.js +226 -8
- package/dist/index.es.js.map +1 -1
- package/dist/{db-subcommands-BPoHCxJR.js → migrate-baseline-B-2Ef4Mv.js} +266 -41
- package/dist/migrate-baseline-B-2Ef4Mv.js.map +1 -0
- package/dist/{migrate-policy-stamps-3eqfhes6.js → migrate-policy-stamps-BQtFHApx.js} +5 -5
- package/dist/{migrate-policy-stamps-3eqfhes6.js.map → migrate-policy-stamps-BQtFHApx.js.map} +1 -1
- package/dist/{open-rebase-EmqVmS14.js → open-rebase-C8jQ6s5a.js} +292 -46
- package/dist/open-rebase-C8jQ6s5a.js.map +1 -0
- package/dist/open-rebase.d.ts +9 -1
- package/dist/{pg-error-utils-CFEnm2m9.js → pg-error-utils-DhiUTlVx.js} +2 -2
- package/dist/{pg-error-utils-CFEnm2m9.js.map → pg-error-utils-DhiUTlVx.js.map} +1 -1
- package/dist/{push-index-prebuild-COd7i6wm.js → push-index-prebuild-UTvB5pqH.js} +3 -3
- package/dist/{push-index-prebuild-COd7i6wm.js.map → push-index-prebuild-UTvB5pqH.js.map} +1 -1
- package/dist/push-kept-defaults-BGOlOqRQ.js +137 -0
- package/dist/push-kept-defaults-BGOlOqRQ.js.map +1 -0
- package/dist/{push-legacy-renames-CLgYYwPE.js → push-legacy-renames-BwaKi8xF.js} +3 -3
- package/dist/{push-legacy-renames-CLgYYwPE.js.map → push-legacy-renames-BwaKi8xF.js.map} +1 -1
- package/dist/{push-policy-plan-D2gpQsdv.js → push-policy-plan-DQ2tWceD.js} +2 -2
- package/dist/{push-policy-plan-D2gpQsdv.js.map → push-policy-plan-DQ2tWceD.js.map} +1 -1
- package/dist/{rls-enforcement-DDyNoOSy.js → rls-enforcement-BOHuHVlc.js} +42 -3
- package/dist/rls-enforcement-BOHuHVlc.js.map +1 -0
- package/dist/schema/destructive-sql.d.ts +16 -0
- package/dist/schema/doctor-cli.js +3 -3
- package/dist/schema/introspect-db.js +1 -1
- package/dist/schema/migration-freshness.d.ts +69 -0
- package/dist/schema/push-kept-defaults.d.ts +57 -0
- package/dist/schema/rls-bootstrap-sql.d.ts +47 -10
- package/dist/security/rls-enforcement.d.ts +18 -0
- package/dist/services/FetchService.d.ts +12 -0
- package/dist/services/channel-presence.d.ts +3 -1
- package/dist/services/nested-path.d.ts +16 -0
- package/dist/services/realtimeService.d.ts +18 -1
- package/dist/{websocket-BKZwsjmf.js → websocket-CKYc3V4N.js} +41 -12
- package/dist/websocket-CKYc3V4N.js.map +1 -0
- package/package.json +7 -7
- package/dist/BranchService-ClklxyAQ.js.map +0 -1
- package/dist/cli-console-CQrQ0lAY.js.map +0 -1
- package/dist/cli-errors-DiA0XFIS.js.map +0 -1
- package/dist/collections-schema-version-T6cGvrDi.js.map +0 -1
- package/dist/db-subcommands-BPoHCxJR.js.map +0 -1
- package/dist/doctor-BT--1kq3.js.map +0 -1
- package/dist/open-rebase-EmqVmS14.js.map +0 -1
- package/dist/rls-enforcement-DDyNoOSy.js.map +0 -1
- package/dist/websocket-BKZwsjmf.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
__createRequire(import.meta.url);
|
|
3
3
|
import { c as pinSearchPath } from "./connection-czvI7TZL.js";
|
|
4
|
-
import { B as withAppClient } from "./cli-errors-
|
|
4
|
+
import { B as withAppClient } from "./cli-errors-DsYyNYzd.js";
|
|
5
5
|
import { a as outWarn, r as out, t as chalk } from "./source-fZb92pN8.js";
|
|
6
6
|
import { s as planCollectionPolicies } from "./generate-postgres-ddl-logic-DPl1oH_z.js";
|
|
7
|
-
import { n as loadCollections } from "./doctor-
|
|
8
|
-
import { policyStampSql, probeRenderedPolicies, readPolicyStamps } from "./ensure-collection-policies-
|
|
9
|
-
import { underSearchPath } from "./push-policy-plan-
|
|
7
|
+
import { n as loadCollections } from "./doctor-DW_mlTzz.js";
|
|
8
|
+
import { policyStampSql, probeRenderedPolicies, readPolicyStamps } from "./ensure-collection-policies-DLWgabQ2.js";
|
|
9
|
+
import { underSearchPath } from "./push-policy-plan-DQ2tWceD.js";
|
|
10
10
|
import path from "path";
|
|
11
11
|
//#region src/schema/migrate-policy-stamps.ts
|
|
12
12
|
/**
|
|
@@ -86,4 +86,4 @@ async function stampPoliciesStoredAsRendered(client, collections, options = {})
|
|
|
86
86
|
//#endregion
|
|
87
87
|
export { stampMigratedPolicies };
|
|
88
88
|
|
|
89
|
-
//# sourceMappingURL=migrate-policy-stamps-
|
|
89
|
+
//# sourceMappingURL=migrate-policy-stamps-BQtFHApx.js.map
|
package/dist/{migrate-policy-stamps-3eqfhes6.js.map → migrate-policy-stamps-BQtFHApx.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-policy-stamps-
|
|
1
|
+
{"version":3,"file":"migrate-policy-stamps-BQtFHApx.js","names":[],"sources":["../src/schema/migrate-policy-stamps.ts"],"sourcesContent":["/**\n * The stamps `rebase db migrate` leaves on the policies it applied.\n *\n * A boot leaves a table's policies alone only when each carries the stamp a\n * boot or a push writes (`COMMENT ON POLICY … IS 'rebase:<hash>'`, see\n * `policyStampSql`). `db push` stamps what `policies.sql` just created. A\n * migration runs the same statements — `db generate` appends `policies.sql` to\n * it — and stamped nothing, so the first boot after every migrate dropped and\n * re-created every policy once, an ACCESS EXCLUSIVE lock per table: 44 on the\n * blog scaffold.\n *\n * Migrate cannot stamp what the files hold, the way push stamps what it just\n * ran: a migration was written from the collections of its day, and the\n * database may hold something a later one, or a hand, made since. A stamp\n * there would tell the boot a policy is what the rule makes when it is not, and\n * the boot would never put it right. So each declared policy without a current\n * stamp is asked of Postgres instead, as `db push --dry-run` asks it\n * (`probeRenderedPolicies`): made again from its rule under a probe name, in a\n * transaction that is rolled back, and compared. Only a policy whose stored\n * definition is exactly what its rule makes is stamped. Any other keeps no\n * stamp, and the boot re-applies its table, as before.\n */\nimport path from \"path\";\nimport chalk from \"chalk\";\nimport type { CollectionConfig } from \"@rebasepro/types\";\nimport type { Queryable } from \"../security/policy-drift\";\nimport { withAppClient } from \"../cli-helpers\";\nimport { out, outWarn } from \"../cli-output\";\nimport { pinSearchPath } from \"../connection\";\nimport { planCollectionPolicies } from \"./generate-postgres-ddl-logic\";\nimport { policyStampSql, probeRenderedPolicies, readPolicyStamps } from \"./ensure-collection-policies\";\nimport { underSearchPath } from \"./push-policy-plan\";\nimport { loadCollections } from \"./doctor\";\n\n/**\n * `rebase db migrate`'s last step: stamp what the migration left as its rules\n * make it, on this process's connection. Never fatal — a policy left\n * unstamped costs the next boot a re-apply of its table, which is what every\n * boot after a migrate did before this.\n */\nexport async function stampMigratedPolicies(databaseUrl: string, collectionsPath: string): Promise<void> {\n try {\n const collections = await loadCollections(path.resolve(process.cwd(), collectionsPath));\n // The rule the boot's connections follow: `search_path=public` unless\n // the URL pins one of its own, in which case this connection has it too.\n const searchPath = pinSearchPath(databaseUrl) === databaseUrl ? undefined : \"public\";\n const { stamped } = await withAppClient(databaseUrl, client => stampPoliciesStoredAsRendered(\n { query: async (text, values) => ({ rows: (await client.query(text, values)).rows }) },\n collections,\n { searchPath }\n ));\n if (stamped > 0) {\n out(chalk.gray(` ✓ Stamped ${stamped} RLS ${stamped === 1 ? \"policy\" : \"policies\"} as their rules make them, so the next boot leaves ${stamped === 1 ? \"it\" : \"them\"} alone.`));\n }\n } catch (err) {\n outWarn(chalk.yellow(` ⚠️ The policies could not be stamped (${err instanceof Error ? err.message : String(err)}); the next boot applies them again.`));\n }\n}\n\n/**\n * Stamp every declared policy whose stored definition its rule would store\n * as it is, and none other.\n *\n * @param options.searchPath the `search_path` a boot reads policies under,\n * when the connection's own differs — the stamp hashes `pg_get_expr`,\n * whose spelling depends on it. See `PolicyStamping.searchPath`.\n * @returns how many policies were stamped.\n */\nexport async function stampPoliciesStoredAsRendered(\n client: Queryable,\n collections: CollectionConfig[],\n options: { searchPath?: string } = {}\n): Promise<{ stamped: number }> {\n const plans = planCollectionPolicies(collections);\n if (plans.length === 0) return { stamped: 0 };\n\n const states = await underSearchPath(client, options.searchPath, () => readPolicyStamps(client, collections));\n const unsure: { schema: string; table: string; name: string }[] = [];\n for (const plan of plans) {\n for (const [name, state] of states.get(plan.qualified) ?? []) {\n if (state !== \"current\") unsure.push({ schema: plan.schema, table: plan.table, name });\n }\n }\n if (unsure.length === 0) return { stamped: 0 };\n\n const confirmed = await probeRenderedPolicies(client, collections, unsure, { searchPath: options.searchPath });\n const statements: string[] = [];\n let stamped = 0;\n for (const plan of plans) {\n const names = new Set(unsure\n .filter(p => p.schema === plan.schema && p.table === plan.table\n && confirmed.get(`${p.schema}.${p.table}.${p.name}`) === true)\n .map(p => p.name));\n const statement = names.size > 0 ? policyStampSql(plan, names) : undefined;\n if (!statement) continue;\n statements.push(statement);\n stamped += names.size;\n }\n if (statements.length === 0) return { stamped: 0 };\n\n await underSearchPath(client, options.searchPath, async () => {\n for (const statement of statements) await client.query(statement);\n });\n return { stamped };\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