@rebasepro/server-postgres 0.30.0 → 0.31.0-canary.g902a0ce
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/README.md +11 -8
- package/dist/{BranchService-CrXvcES2.js → BranchService-USp1AvZB.js} +3 -3
- package/dist/{BranchService-CrXvcES2.js.map → BranchService-USp1AvZB.js.map} +1 -1
- package/dist/PostgresBackendDriver.d.ts +99 -54
- package/dist/PostgresBootstrapper.d.ts +12 -27
- package/dist/auth/ensure-tables.d.ts +16 -5
- package/dist/auth/schema-version.d.ts +2 -2
- package/dist/auth/services.d.ts +2 -3
- package/dist/{auth-users-columns-C72EMoDJ.js → auth-users-columns-BpfgbkxZ.js} +2 -16
- package/dist/auth-users-columns-BpfgbkxZ.js.map +1 -0
- package/dist/{backup-cli-CTKCOLpX.js → backup-cli-DbKyEj6c.js} +4 -4
- package/dist/{backup-cli-CTKCOLpX.js.map → backup-cli-DbKyEj6c.js.map} +1 -1
- package/dist/{boot-ddl-CqGIwSYx.js → boot-ddl-5H2bL_80.js} +2 -2
- package/dist/{boot-ddl-CqGIwSYx.js.map → boot-ddl-5H2bL_80.js.map} +1 -1
- package/dist/{cli-console-DBPw-oAz.js → cli-console-DsRgGSBR.js} +65 -39
- package/dist/cli-console-DsRgGSBR.js.map +1 -0
- package/dist/cli-console.d.ts +16 -13
- package/dist/cli-flags.d.ts +8 -9
- package/dist/cli-helpers.d.ts +15 -11
- package/dist/{cli-errors-DYTxnLbW.js → cli-schema-dir-CiN0ephV.js} +184 -70
- package/dist/cli-schema-dir-CiN0ephV.js.map +1 -0
- package/dist/cli-schema-dir.d.ts +64 -0
- package/dist/cli.js +192 -257
- package/dist/cli.js.map +1 -1
- package/dist/data-transformer.d.ts +50 -19
- package/dist/{database-preflight-iBpT7-vv.js → database-preflight-bfnIBnjM.js} +5 -5
- package/dist/database-preflight-bfnIBnjM.js.map +1 -0
- package/dist/{deferred-index-build-BCU9RoHK.js → deferred-index-build-CcSDA7wE.js} +69 -13
- package/dist/deferred-index-build-CcSDA7wE.js.map +1 -0
- package/dist/{ensure-collection-policies-Bo-_fDAy.js → ensure-policies-rRmXb5bt.js} +31 -31
- package/dist/ensure-policies-rRmXb5bt.js.map +1 -0
- package/dist/{ensure-collection-tables-DCJINkT_.js → ensure-tables-Bvm-F2wW.js} +44 -37
- package/dist/ensure-tables-Bvm-F2wW.js.map +1 -0
- package/dist/{ensure-tables-BPGaGh0y.js → ensure-tables-CC8p_AK3.js} +34 -29
- package/dist/ensure-tables-CC8p_AK3.js.map +1 -0
- package/dist/{enum-labels-kept-YAgOZS4I.js → enum-labels-kept-FlX9SHdf.js} +8 -8
- package/dist/enum-labels-kept-FlX9SHdf.js.map +1 -0
- package/dist/{generate-drizzle-schema-DcrFr7YX.js → generate-drizzle-schema-SJMXxzPI.js} +12 -12
- package/dist/generate-drizzle-schema-SJMXxzPI.js.map +1 -0
- package/dist/{generate-drizzle-schema-logic-LTLZvt6r.js → generate-drizzle-schema-logic-DL7R1rAF.js} +15 -8
- package/dist/generate-drizzle-schema-logic-DL7R1rAF.js.map +1 -0
- package/dist/{generate-files-CsaVzatS.js → generate-files-tlJ9_lGI.js} +23 -30
- package/dist/generate-files-tlJ9_lGI.js.map +1 -0
- package/dist/{generate-next-step-DgK5BlBn.js → generate-next-step-CO09dovd.js} +3 -3
- package/dist/generate-next-step-CO09dovd.js.map +1 -0
- package/dist/{generate-postgres-ddl-logic-Dg0bcENZ.js → generate-postgres-ddl-logic-B8huc03c.js} +51 -21
- package/dist/generate-postgres-ddl-logic-B8huc03c.js.map +1 -0
- package/dist/{generated-schema-diff-By4dxyTH.js → generated-schema-diff-DoT2dYDe.js} +297 -279
- package/dist/generated-schema-diff-DoT2dYDe.js.map +1 -0
- package/dist/{generated-schema-staleness-BvNF3i-s.js → generated-schema-staleness-YBVq2kTn.js} +21 -29
- package/dist/generated-schema-staleness-YBVq2kTn.js.map +1 -0
- package/dist/history/ensure-history-table.d.ts +22 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.es.js +201 -25
- package/dist/index.es.js.map +1 -1
- package/dist/interfaces.d.ts +3 -4
- package/dist/{introspect-db-queries-DevUrzll.js → introspect-db-queries-BgiRQqtR.js} +7 -2
- package/dist/introspect-db-queries-BgiRQqtR.js.map +1 -0
- package/dist/introspect-tables-Cw_A-kk4.js +2086 -0
- package/dist/introspect-tables-Cw_A-kk4.js.map +1 -0
- package/dist/load-tables-B1Re74ng.js +92 -0
- package/dist/load-tables-B1Re74ng.js.map +1 -0
- package/dist/{migrate-baseline-CmWXL7qx.js → migrate-baseline-DZmekgpD.js} +19 -32
- package/dist/migrate-baseline-DZmekgpD.js.map +1 -0
- package/dist/{migrate-policy-stamps-BN_Qad6c.js → migrate-policy-stamps-B_acrUQB.js} +18 -19
- package/dist/migrate-policy-stamps-B_acrUQB.js.map +1 -0
- package/dist/model/PostgresTableRegistry.d.ts +159 -0
- package/dist/model/build-registry.d.ts +25 -0
- package/dist/model/refresh-relational-schema.d.ts +24 -0
- package/dist/model/runtime-table.d.ts +53 -0
- package/dist/{collections → model}/validate-relations.d.ts +15 -21
- package/dist/{open-rebase-40paQfVW.js → open-rebase-4kisUF_k.js} +3946 -3870
- package/dist/open-rebase-4kisUF_k.js.map +1 -0
- package/dist/open-rebase.d.ts +16 -15
- package/dist/{pg-error-utils-DJHjCF7-.js → pg-error-utils-BT5NzGFZ.js} +17 -20
- package/dist/pg-error-utils-BT5NzGFZ.js.map +1 -0
- package/dist/plan-schema-Hbtjhge3.js +1633 -0
- package/dist/plan-schema-Hbtjhge3.js.map +1 -0
- package/dist/{policy-drift-C-m0uWHH.js → policy-drift-BVMyqHSa.js} +29 -29
- package/dist/policy-drift-BVMyqHSa.js.map +1 -0
- package/dist/{push-index-adoption-Cp7oZxSl.js → push-index-adoption-hpHTyXMR.js} +7 -7
- package/dist/push-index-adoption-hpHTyXMR.js.map +1 -0
- package/dist/{push-index-prebuild-DbwKGtQT.js → push-index-prebuild-Bty9F7bD.js} +6 -6
- package/dist/push-index-prebuild-Bty9F7bD.js.map +1 -0
- package/dist/{push-kept-defaults-CLcgsEPt.js → push-kept-defaults-Bst4MDup.js} +13 -16
- package/dist/push-kept-defaults-Bst4MDup.js.map +1 -0
- package/dist/{push-legacy-renames-BthD0E9W.js → push-legacy-renames-bB4bM6br.js} +6 -6
- package/dist/push-legacy-renames-bB4bM6br.js.map +1 -0
- package/dist/{push-policy-plan-BgcrroxQ.js → push-policy-plan-BI8U4BOD.js} +11 -11
- package/dist/push-policy-plan-BI8U4BOD.js.map +1 -0
- package/dist/{render-ddl-Ci3S_SoI.js → render-ddl-D4n86NHz.js} +14 -7
- package/dist/render-ddl-D4n86NHz.js.map +1 -0
- package/dist/{request-role-cli-Dy1EgJU9.js → request-role-cli-BdRzdE87.js} +11 -11
- package/dist/{request-role-cli-Dy1EgJU9.js.map → request-role-cli-BdRzdE87.js.map} +1 -1
- package/dist/{request-role-migration-GHTJnPMV.js → request-role-migration-C8aq_TO3.js} +2 -2
- package/dist/{request-role-migration-GHTJnPMV.js.map → request-role-migration-C8aq_TO3.js.map} +1 -1
- package/dist/{rls-enforcement-Cc_UhOxb.js → rls-enforcement-DB5HHj96.js} +19 -19
- package/dist/rls-enforcement-DB5HHj96.js.map +1 -0
- package/dist/{rls-settings-BCGMIig3.js → rls-settings-CmGK2U0a.js} +2 -2
- package/dist/rls-settings-CmGK2U0a.js.map +1 -0
- package/dist/schema/auth-users-columns.d.ts +1 -11
- package/dist/schema/catalogue-schema.d.ts +33 -29
- package/dist/schema/classify-change.d.ts +23 -16
- package/dist/schema/column-type-drift.d.ts +16 -0
- package/dist/schema/config-relations.d.ts +10 -9
- package/dist/schema/deferred-index-build.d.ts +1 -1
- package/dist/schema/doctor-cli.js +1544 -66
- package/dist/schema/doctor-cli.js.map +1 -1
- package/dist/schema/doctor-database.d.ts +7 -7
- package/dist/schema/doctor-policy-checks.d.ts +4 -4
- package/dist/schema/doctor-search-scale.d.ts +14 -14
- package/dist/schema/doctor.d.ts +27 -27
- package/dist/schema/dynamic-tables.d.ts +6 -5
- package/dist/schema/{ensure-collection-policies.d.ts → ensure-policies.d.ts} +20 -20
- package/dist/schema/{ensure-collection-tables.d.ts → ensure-tables.d.ts} +11 -11
- package/dist/schema/enum-labels-kept.d.ts +6 -6
- package/dist/schema/generate-drizzle-schema-logic.d.ts +3 -3
- package/dist/schema/generate-drizzle-schema.js +1 -1
- package/dist/schema/generate-files.d.ts +6 -6
- package/dist/schema/generate-postgres-ddl-logic.d.ts +23 -20
- package/dist/schema/generate-postgres-ddl.js +11 -11
- package/dist/schema/generate-postgres-ddl.js.map +1 -1
- package/dist/schema/generate-schema-commit.d.ts +13 -8
- package/dist/schema/generated-schema-diff.d.ts +16 -16
- package/dist/schema/generated-schema-staleness.d.ts +11 -11
- package/dist/schema/index-adoption.d.ts +4 -4
- package/dist/schema/introspect-db-customization.d.ts +47 -0
- package/dist/schema/introspect-db-inference.d.ts +30 -9
- package/dist/schema/introspect-db-logic.d.ts +79 -110
- package/dist/schema/introspect-db-project.d.ts +15 -18
- package/dist/schema/introspect-db-queries.d.ts +1 -1
- package/dist/schema/introspect-db-search.d.ts +25 -4
- package/dist/schema/introspect-db-storage.d.ts +4 -74
- package/dist/schema/introspect-db.js +102 -90
- package/dist/schema/introspect-db.js.map +1 -1
- package/dist/schema/introspect-runtime.d.ts +47 -36
- package/dist/schema/introspect-tables.d.ts +182 -0
- package/dist/schema/load-tables.d.ts +55 -0
- package/dist/schema/migrate-policy-stamps.d.ts +4 -4
- package/dist/schema/migration-freshness.d.ts +13 -13
- package/dist/schema/plan/column-order.d.ts +82 -0
- package/dist/schema/plan/diff-plan.d.ts +9 -3
- package/dist/schema/plan/plan-schema.d.ts +55 -52
- package/dist/schema/plan/render-drizzle.d.ts +1 -1
- package/dist/schema/plan/types.d.ts +24 -15
- package/dist/schema/push-index-adoption.d.ts +3 -3
- package/dist/schema/push-index-prebuild.d.ts +3 -3
- package/dist/schema/push-kept-defaults.d.ts +7 -7
- package/dist/schema/push-legacy-renames.d.ts +3 -3
- package/dist/schema/push-policy-plan.d.ts +5 -5
- package/dist/schema/reconcile-schema.d.ts +5 -5
- package/dist/schema/relation-names.d.ts +15 -20
- package/dist/schema/render-outputs.d.ts +76 -0
- package/dist/schema/search-column.d.ts +11 -43
- package/dist/schema/{collection-index.d.ts → table-index.d.ts} +21 -42
- package/dist/schema/{collections-schema-version.d.ts → tables-schema-version.d.ts} +8 -2
- package/dist/schema/vector-index.d.ts +24 -28
- package/dist/{search-column-BM-GV6vH.js → search-column-BO-WND-B.js} +86 -149
- package/dist/search-column-BO-WND-B.js.map +1 -0
- package/dist/security/caller-sql-columns.d.ts +9 -6
- package/dist/security/policy-drift.d.ts +14 -14
- package/dist/security/rls-enforcement.d.ts +19 -25
- package/dist/security/rls-settings.d.ts +2 -2
- package/dist/security/served-table-protection.d.ts +125 -0
- package/dist/services/FetchService.d.ts +22 -133
- package/dist/services/PersistService.d.ts +6 -17
- package/dist/services/RelationService.d.ts +57 -106
- package/dist/services/RelationWriteService.d.ts +59 -66
- package/dist/services/cdc/identity-columns.d.ts +7 -5
- package/dist/services/cdc/junction-tables.d.ts +14 -14
- package/dist/services/collection-helpers.d.ts +52 -95
- package/dist/services/dataService.d.ts +15 -12
- package/dist/services/field-op-sql.d.ts +11 -9
- package/dist/services/field-viewer.d.ts +12 -11
- package/dist/services/hidden-columns.d.ts +30 -0
- package/dist/services/index.d.ts +1 -1
- package/dist/services/junction-writes.d.ts +37 -18
- package/dist/services/nested-path.d.ts +18 -18
- package/dist/services/read-field-access.d.ts +23 -7
- package/dist/services/read-scope.d.ts +10 -9
- package/dist/services/realtimeService.d.ts +25 -10
- package/dist/services/relation-tables.d.ts +97 -0
- package/dist/services/row-pipeline.d.ts +50 -69
- package/dist/services/soft-delete.d.ts +25 -24
- package/dist/services/table-hooks.d.ts +146 -0
- package/dist/services/view-access.d.ts +7 -7
- package/dist/services/write-transaction-scope.d.ts +1 -1
- package/dist/{source-fZb92pN8.js → source-VxbrQojV.js} +111 -79
- package/dist/source-VxbrQojV.js.map +1 -0
- package/dist/{collections-schema-version-D7bDI0PJ.js → tables-schema-version-YvZIBlOP.js} +12 -6
- package/dist/tables-schema-version-YvZIBlOP.js.map +1 -0
- package/dist/utils/drizzle-conditions.d.ts +70 -84
- package/dist/utils/pg-array-null-patch.d.ts +27 -10
- package/dist/utils/pg-error-utils.d.ts +4 -4
- package/dist/{vector-index-DsQ3V2d2.js → vector-index-VSh3ufTd.js} +62 -54
- package/dist/vector-index-VSh3ufTd.js.map +1 -0
- package/dist/{websocket-B7ex6AQM.js → websocket-BevXvwfo.js} +51 -40
- package/dist/websocket-BevXvwfo.js.map +1 -0
- package/dist/websocket.d.ts +2 -2
- package/package.json +7 -7
- package/dist/auth-users-columns-C72EMoDJ.js.map +0 -1
- package/dist/cli-collections-path.d.ts +0 -31
- package/dist/cli-console-DBPw-oAz.js.map +0 -1
- package/dist/cli-errors-DYTxnLbW.js.map +0 -1
- package/dist/collections/PostgresCollectionRegistry.d.ts +0 -47
- package/dist/collections/buildRegistry.d.ts +0 -27
- package/dist/collections-schema-version-D7bDI0PJ.js.map +0 -1
- package/dist/column-plan-helpers-BeSztMor.js +0 -161
- package/dist/column-plan-helpers-BeSztMor.js.map +0 -1
- package/dist/database-preflight-iBpT7-vv.js.map +0 -1
- package/dist/deferred-index-build-BCU9RoHK.js.map +0 -1
- package/dist/doctor-Kg1oUK0Q.js +0 -1458
- package/dist/doctor-Kg1oUK0Q.js.map +0 -1
- package/dist/ensure-collection-policies-Bo-_fDAy.js.map +0 -1
- package/dist/ensure-collection-tables-DCJINkT_.js.map +0 -1
- package/dist/ensure-tables-BPGaGh0y.js.map +0 -1
- package/dist/enum-labels-kept-YAgOZS4I.js.map +0 -1
- package/dist/generate-drizzle-schema-DcrFr7YX.js.map +0 -1
- package/dist/generate-drizzle-schema-logic-LTLZvt6r.js.map +0 -1
- package/dist/generate-files-CsaVzatS.js.map +0 -1
- package/dist/generate-next-step-DgK5BlBn.js.map +0 -1
- package/dist/generate-postgres-ddl-logic-Dg0bcENZ.js.map +0 -1
- package/dist/generated-schema-diff-By4dxyTH.js.map +0 -1
- package/dist/generated-schema-staleness-BvNF3i-s.js.map +0 -1
- package/dist/introspect-db-logic-DWqAEURB.js +0 -2047
- package/dist/introspect-db-logic-DWqAEURB.js.map +0 -1
- package/dist/introspect-db-queries-DevUrzll.js.map +0 -1
- package/dist/migrate-baseline-CmWXL7qx.js.map +0 -1
- package/dist/migrate-policy-stamps-BN_Qad6c.js.map +0 -1
- package/dist/open-rebase-40paQfVW.js.map +0 -1
- package/dist/pg-error-utils-DJHjCF7-.js.map +0 -1
- package/dist/plan-schema-vJd3UEmT.js +0 -1604
- package/dist/plan-schema-vJd3UEmT.js.map +0 -1
- package/dist/policy-drift-C-m0uWHH.js.map +0 -1
- package/dist/push-index-adoption-Cp7oZxSl.js.map +0 -1
- package/dist/push-index-prebuild-DbwKGtQT.js.map +0 -1
- package/dist/push-kept-defaults-CLcgsEPt.js.map +0 -1
- package/dist/push-legacy-renames-BthD0E9W.js.map +0 -1
- package/dist/push-policy-plan-BgcrroxQ.js.map +0 -1
- package/dist/render-ddl-Ci3S_SoI.js.map +0 -1
- package/dist/rls-enforcement-Cc_UhOxb.js.map +0 -1
- package/dist/rls-settings-BCGMIig3.js.map +0 -1
- package/dist/schema/column-plan-helpers.d.ts +0 -161
- package/dist/schema/introspect-db-naming.d.ts +0 -10
- package/dist/search-column-BM-GV6vH.js.map +0 -1
- package/dist/source-fZb92pN8.js.map +0 -1
- package/dist/vector-index-DsQ3V2d2.js.map +0 -1
- package/dist/websocket-B7ex6AQM.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-files-tlJ9_lGI.js","names":[],"sources":["../src/schema/generate-files.ts"],"sourcesContent":["import { promises as fsPromises } from \"fs\";\nimport * as fs from \"fs\";\nimport path from \"path\";\nimport { pathToFileURL } from \"url\";\nimport { declaredDatabaseExtensions } from \"@rebasepro/types\";\nimport { loadTables } from \"./load-tables\";\nimport { generateSchema } from \"./generate-drizzle-schema-logic\";\nimport {\n generatePostgresDdl,\n generatePostgresPoliciesDdl,\n generatePostgresSearchDdl,\n generatePostgresTriggersDdl,\n generatePostgresViewsDdl,\n generatePostgresVectorDdl\n} from \"./generate-postgres-ddl-logic\";\nimport { describeFailure, out, outError } from \"../cli-output\";\nimport { nextStepAfterGenerate } from \"./generate-next-step\";\n\n/**\n * The two generators `rebase db push` runs as its step 1, as functions.\n *\n * They used to exist only as scripts, each its own `tsx` process: the driver\n * (itself a `tsx` process) spawned one for the Drizzle schema and then one for\n * the DDL, and each paid a Node start, tsx's loader and an import of the whole\n * server package before reading a single table — about 0.5 s apiece, a\n * second per push. The driver process is one-shot, so a fresh module graph per\n * generation bought nothing: the tables cannot change under it.\n *\n * The scripts remain (`generate-drizzle-schema.ts`, `generate-postgres-ddl.ts`)\n * for `--watch`, which re-imports the tables on every save and does need a\n * process of its own — Node's module cache would serve it the first version\n * forever.\n *\n * Both functions print their own success lines and their own error, exactly as\n * the scripts did, and throw {@link GenerationFailed} after printing — so a\n * caller can tell \"the generator said why\" from \"the generator never ran\".\n */\n\n/** Thrown once the generator has printed why it failed. */\nexport class GenerationFailed extends Error {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = \"GenerationFailed\";\n }\n}\n\nexport interface GenerateFileOptions {\n /** The schema directory (`backend/schema`: its index exports the tables), resolved against the cwd. */\n schemaDir: string;\n /** Where to write. Absent: print to stdout instead. */\n outputPath?: string;\n /**\n * End on the line that says what to run next. Only `rebase schema\n * generate` itself wants it: inside `db push` it told the push to run\n * `db generate`, and inside `db generate` to run itself.\n */\n nextStep?: boolean;\n}\n\n/** `src/schema.generated.ts`, from the tables. */\nexport async function writeDrizzleSchema(options: GenerateFileOptions): Promise<void> {\n try {\n // Shared with the runtime and the doctor (`loadTables`), in slug order so\n // the output does not depend on the index's export order.\n const tables = await loadTables(options.schemaDir);\n const schemaContent = generateSchema(tables);\n\n if (options.outputPath) {\n await fsPromises.mkdir(path.dirname(options.outputPath), { recursive: true });\n await fsPromises.writeFile(options.outputPath, schemaContent);\n out(`✅ Drizzle schema generated successfully at ${options.outputPath}`);\n } else {\n out(\"✅ Drizzle schema generated successfully.\");\n out(String(schemaContent));\n }\n\n if (options.nextStep !== false) out(nextStepAfterGenerate());\n } catch (error) {\n outError(`Error generating schema: ${describeFailure(error)}`);\n // `rebase db push` runs this as step 1 and must stop on it: going on\n // applied whatever `src/schema.generated.ts` was already there.\n throw new GenerationFailed(\"Drizzle schema generation failed\", { cause: error });\n }\n}\n\n/** Where a project declares its resources, relative to `backend/` (the schema directory's parent). */\nconst RESOURCE_ENTRIES = [\"resources.ts\", \"resources.js\", \"resources/index.ts\", \"resources/index.js\"];\n\n/**\n * Evaluate the project's `resources.ts`, so `declaredDatabaseExtensions()` can\n * answer.\n *\n * The DDL generator loads only the schema directory, so nothing else in it\n * would ever import the resources module — and a permission that reads as\n * absent because nobody loaded it is the worst shape this could take: the push\n * succeeds, `vector.sql` quietly omits the `CREATE EXTENSION`, and the failure\n * lands one statement later looking like a database problem.\n *\n * Imported directly rather than through the config index, for the reason\n * `boot/resource-loading.ts` gives: re-exporting from the index would work only\n * for projects that remember to.\n *\n * A project with no resources module is the normal case and declares nothing.\n * An import that *throws* is not swallowed — a resources module that does not\n * evaluate is a configuration error, and treating it as \"declared nothing\"\n * would turn it into a silently missing extension.\n */\nasync function loadDeclaredResources(backendDir: string): Promise<void> {\n const entry = RESOURCE_ENTRIES\n .map(name => path.join(backendDir, name))\n .find(candidate => fs.existsSync(candidate));\n if (!entry) return;\n await import(pathToFileURL(entry).href);\n}\n\n/**\n * `schema.sql` (Atlas's desired state) and, beside it, `policies.sql`,\n * `search.sql`, `vector.sql`, `triggers.sql` and `views.sql` — the parts Atlas\n * does not own.\n */\nexport async function writePostgresDdl(options: GenerateFileOptions): Promise<void> {\n try {\n const resolvedPath = path.resolve(options.schemaDir);\n\n // `backend/schema` is the path this is given, so `backend/` — where\n // `resources.ts` lives — is its parent: the same relationship\n // `rebase resources` and the boot loader assume.\n await loadDeclaredResources(path.dirname(resolvedPath));\n\n const tables = await loadTables(resolvedPath);\n\n // `schema.sql` is Atlas's desired state, and it carries neither the RLS\n // policies, nor the search apparatus, nor the vector columns: Atlas\n // manages none of them, and in the search and vector cases cannot. All\n // three are written beside it and applied by the CLI in their own right.\n const ddlContent = generatePostgresDdl(tables, {\n includePolicies: false,\n includeSearch: false,\n includeVector: false\n });\n const policiesContent = generatePostgresPoliciesDdl(tables);\n const searchContent = generatePostgresSearchDdl(tables);\n const vectorContent = generatePostgresVectorDdl(tables, {\n extensions: declaredDatabaseExtensions()\n });\n const triggersContent = generatePostgresTriggersDdl(tables);\n const viewsContent = generatePostgresViewsDdl(tables);\n\n const outputPath = options.outputPath;\n if (outputPath) {\n const outputDir = path.dirname(outputPath);\n await fsPromises.mkdir(outputDir, { recursive: true });\n await fsPromises.writeFile(outputPath, ddlContent);\n out(`✅ PostgreSQL DDL generated successfully at ${outputPath}`);\n\n const policiesPath = path.join(outputDir, \"policies.sql\");\n await fsPromises.writeFile(policiesPath, policiesContent);\n out(`✅ PostgreSQL Policies DDL generated successfully at ${policiesPath}`);\n\n // Removed when the last `search` block goes: the CLI applies this\n // file whenever it exists, and a stale one would keep re-creating\n // functions for tables that no longer want them.\n const searchPath = path.join(outputDir, \"search.sql\");\n if (searchContent) {\n await fsPromises.writeFile(searchPath, searchContent);\n out(`✅ PostgreSQL search DDL generated successfully at ${searchPath}`);\n } else if (fs.existsSync(searchPath)) {\n await fsPromises.rm(searchPath);\n }\n\n // Removed when the last vector column goes, for the same reason\n // `search.sql` is: the CLI applies whichever of these files exists,\n // and a stale one would keep re-adding a column the tables no\n // longer declare — which Atlas, no longer told to exclude it, would\n // then plan a DROP for on the very next push.\n const vectorPath = path.join(outputDir, \"vector.sql\");\n if (vectorContent) {\n await fsPromises.writeFile(vectorPath, vectorContent);\n out(`✅ PostgreSQL vector DDL generated successfully at ${vectorPath}`);\n } else if (fs.existsSync(vectorPath)) {\n await fsPromises.rm(vectorPath);\n }\n\n // `.onUpdateNow()` (`autoValue: \"on_update\"`), on the same terms as the two above: a\n // trigger is a function plus a binding, which Atlas's free tier\n // will not parse, and a stale file would keep re-installing a\n // trigger for a column nothing declares any more.\n const triggersPath = path.join(outputDir, \"triggers.sql\");\n if (triggersContent) {\n await fsPromises.writeFile(triggersPath, triggersContent);\n out(`✅ PostgreSQL trigger DDL generated successfully at ${triggersPath}`);\n } else if (fs.existsSync(triggersPath)) {\n await fsPromises.rm(triggersPath);\n }\n\n // The schema's views (`defineView`), which Atlas's free tier does not manage.\n // Removed with the last view, as the others are: the CLI applies\n // the file whenever it exists.\n const viewsPath = path.join(outputDir, \"views.sql\");\n if (viewsContent) {\n await fsPromises.writeFile(viewsPath, viewsContent);\n out(`✅ PostgreSQL view DDL generated successfully at ${viewsPath}`);\n } else if (fs.existsSync(viewsPath)) {\n await fsPromises.rm(viewsPath);\n }\n } else {\n out(\"✅ PostgreSQL DDL generated successfully.\");\n out(String(ddlContent));\n out(\"\\n✅ PostgreSQL Policies DDL generated successfully.\");\n out(String(policiesContent));\n }\n } catch (error) {\n outError(`Error generating DDL schema: ${describeFailure(error)}`);\n // Step 1 of `rebase db push` is this, and a failure has to stop it.\n // Going on made a resources module that does not evaluate — the single\n // most common cause here — report `✓ rebase db push completed\n // successfully` while Atlas applied whatever `drizzle/schema.sql`\n // happened to be on disk, sometimes minutes old. With no prior file the\n // same run died inside Atlas on `stat drizzle/schema.sql: no such file\n // or directory`, which hides the real cause two screens up.\n throw new GenerationFailed(\"Postgres DDL generation failed\", { cause: error });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAa,mBAAb,cAAsC,MAAM;CACxC,YAAY,SAAiB,SAA+B;EACxD,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CAChB;A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;GACzD,IAAI,OAAO,eAAe,CAAC;EAC/B;CACJ,SAAS,OAAO;EACZ,SAAS,gCAAgC,gBAAgB,KAAK,GAAG;EAQjE,MAAM,IAAI,iBAAiB,kCAAkC,EAAE,OAAO,MAAM,CAAC;CACjF;AACJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
__createRequire(import.meta.url);
|
|
3
|
-
import { t as chalk } from "./source-
|
|
3
|
+
import { t as chalk } from "./source-VxbrQojV.js";
|
|
4
4
|
//#region src/schema/generate-next-step.ts
|
|
5
5
|
/**
|
|
6
6
|
* The lines `rebase schema generate` and `rebase db generate` end on.
|
|
@@ -39,7 +39,7 @@ var command = (text) => chalk.bold.bgBlue.black(text);
|
|
|
39
39
|
* original wording.
|
|
40
40
|
*/
|
|
41
41
|
var nextStepAfterGenerate = () => {
|
|
42
|
-
if (process.env.REBASE_DEV_DATABASE_KIND === "managed") return `Start or restart ${command("rebase dev")} — boot applies your
|
|
42
|
+
if (process.env.REBASE_DEV_DATABASE_KIND === "managed") return `Start or restart ${command("rebase dev")} — boot applies your tables to the managed development database.`;
|
|
43
43
|
return `You can now run ${command("rebase db generate")} to generate the SQL migration files.`;
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
@@ -71,4 +71,4 @@ var nextStepAfterDbGenerate = (migration) => {
|
|
|
71
71
|
//#endregion
|
|
72
72
|
export { nextStepAfterGenerate as n, nextStepAfterDbGenerate as t };
|
|
73
73
|
|
|
74
|
-
//# sourceMappingURL=generate-next-step-
|
|
74
|
+
//# sourceMappingURL=generate-next-step-CO09dovd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-next-step-CO09dovd.js","names":[],"sources":["../src/schema/generate-next-step.ts"],"sourcesContent":["/**\n * The lines `rebase schema generate` and `rebase db generate` end on.\n *\n * Its own module because `generate-drizzle-schema.ts` uses `import.meta` to\n * decide whether it was executed directly, which the driver's jest suite cannot\n * load at all — so the one sentence in that file with a decision in it had no\n * test and could not have one where it stood.\n *\n * Printed only by `rebase schema generate` itself. `db push` and `db generate`\n * run the same generator as their first step, and inside them the line was\n * wrong advice: `db push` was told to run `db generate`, and `db generate` to\n * run itself.\n */\nimport chalk from \"chalk\";\n\n/**\n * A command name, highlighted the way the rest of the driver's output is: with\n * chalk, which drops the colour under `NO_COLOR`, when stdout is not a terminal,\n * and in CI logs. The escapes used to be written by hand here, so\n * `NO_COLOR=1 rebase schema generate > log` put `\\x1b[1m\\x1b[44m…` in the file.\n */\nconst command = (text: string): string => chalk.bold.bgBlue.black(text);\n\n/**\n * What to do with the file that was just generated.\n *\n * Not the same answer on the managed development database: `rebase db generate`\n * plans with Atlas, Atlas needs a second empty database to diff against, and\n * PGlite serves exactly one — so the CLI refuses that command outright there.\n * This line recommended it unconditionally, which meant every stock scaffold\n * was told, by the tool itself, to run something the same tool would refuse.\n *\n * The kind arrives as `REBASE_DEV_DATABASE_KIND`, set by the CLI from the\n * ordered resolution in `dev-db/resolve.ts`. It is a pure decision — nothing is\n * started to make it — and the driver cannot make it for itself: on the managed\n * path `DATABASE_URL` is a perfectly ordinary connection string to a Postgres\n * on loopback. Absent (the driver run directly, outside the CLI) keeps the\n * original wording.\n */\nexport const nextStepAfterGenerate = (): string => {\n if (process.env.REBASE_DEV_DATABASE_KIND === \"managed\") {\n return `Start or restart ${command(\"rebase dev\")} — boot applies your tables to the managed development database.`;\n }\n\n return `You can now run ${command(\"rebase db generate\")} to generate the SQL migration files.`;\n};\n\n/**\n * What to do with the migration `rebase db generate` just wrote, or nothing\n * when it wrote none.\n *\n * `db migrate`, and for a project's first migration on a database that has\n * already booted, `--baseline` instead. Boot creates every collection's tables,\n * so the first migration — which creates them too — stops on `already exists`\n * there, on the managed database and on a server of your own alike. The newest\n * version is named: boot made the tables the collections declare now, which is\n * what that migration describes.\n *\n * Not for a later one: boot may have made an additive change already, and then\n * `db migrate` stops and names the version itself, but it never drops a\n * column, and baselining a destructive migration would skip its DROP.\n */\nexport const nextStepAfterDbGenerate = (migration: {\n /** The newest migration's version, or null when none can be read. */\n newestVersion: string | null;\n /** Whether this run wrote a migration. */\n wrote: boolean;\n /** Whether it is the project's first. */\n first: boolean;\n}): string[] => {\n if (!migration.wrote) return [];\n const apply = ` Apply it with ${chalk.bold.green(\"rebase db migrate\")}.`;\n if (!migration.first) {\n return [`${apply} If boot has already made this change there, migrate stops and names the version to record.`];\n }\n const version = migration.newestVersion ?? \"<version>\";\n return [\n apply,\n \" On a database boot has already set up, these tables exist: record this first migration as applied instead,\",\n ` with ${chalk.bold.green(`rebase db migrate --baseline ${version}`)}.`\n ];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAM,WAAW,SAAyB,MAAM,KAAK,OAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;AAkBtE,IAAa,8BAAsC;CAC/C,IAAI,QAAQ,IAAI,6BAA6B,WACzC,OAAO,oBAAoB,QAAQ,YAAY,EAAE;CAGrD,OAAO,mBAAmB,QAAQ,oBAAoB,EAAE;AAC5D;;;;;;;;;;;;;;;;AAiBA,IAAa,2BAA2B,cAOxB;CACZ,IAAI,CAAC,UAAU,OAAO,OAAO,CAAC;CAC9B,MAAM,QAAQ,mBAAmB,MAAM,KAAK,MAAM,mBAAmB,EAAE;CACvE,IAAI,CAAC,UAAU,OACX,OAAO,CAAC,GAAG,MAAM,4FAA4F;CAEjH,MAAM,UAAU,UAAU,iBAAiB;CAC3C,OAAO;EACH;EACA;EACA,UAAU,MAAM,KAAK,MAAM,gCAAgC,SAAS,EAAE;CAC1E;AACJ"}
|
package/dist/{generate-postgres-ddl-logic-Dg0bcENZ.js → generate-postgres-ddl-logic-B8huc03c.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
__createRequire(import.meta.url);
|
|
3
3
|
import { i as __exportAll } from "./cli-prompt-DXG0yk-h.js";
|
|
4
|
-
import { n as planSchema } from "./plan-schema-
|
|
5
|
-
import { a as renderPoliciesDdl, d as renderVectorDdl, f as renderViewsDdl, h as vectorExcludePatternsOf, i as renderPgType, l as renderSearchDdl, m as triggerExcludePatternsOf, n as renderDenyingPolicyStatements, o as renderPolicyStatements, p as searchExcludePatternsOf, s as renderPostgresDdl, u as renderTriggersDdl } from "./render-ddl-
|
|
4
|
+
import { n as planSchema } from "./plan-schema-Hbtjhge3.js";
|
|
5
|
+
import { a as renderPoliciesDdl, d as renderVectorDdl, f as renderViewsDdl, h as vectorExcludePatternsOf, i as renderPgType, l as renderSearchDdl, m as triggerExcludePatternsOf, n as renderDenyingPolicyStatements, o as renderPolicyStatements, p as searchExcludePatternsOf, s as renderPostgresDdl, u as renderTriggersDdl } from "./render-ddl-D4n86NHz.js";
|
|
6
6
|
import { REBASE_ADMIN_REQUEST_ROLE } from "@rebasepro/types";
|
|
7
7
|
import "@rebasepro/common";
|
|
8
8
|
//#region src/schema/generate-postgres-ddl-logic.ts
|
|
@@ -13,7 +13,7 @@ import "@rebasepro/common";
|
|
|
13
13
|
* reads the collections into a {@link SchemaPlan} and `schema/plan/render-ddl.ts`
|
|
14
14
|
* writes the files; what remains here is the public entry points those two are
|
|
15
15
|
* reached through, plus the smaller plans (`planRelationalColumns`,
|
|
16
|
-
* `planJunctionTables`, `
|
|
16
|
+
* `planJunctionTables`, `planTablePolicies`) that other modules ask for as
|
|
17
17
|
* slices of the same plan.
|
|
18
18
|
*
|
|
19
19
|
* It used to hold `getSqlColumnType` and a `CREATE TABLE` walk with its own
|
|
@@ -27,8 +27,9 @@ var generate_postgres_ddl_logic_exports = /* @__PURE__ */ __exportAll({
|
|
|
27
27
|
generatePostgresTriggersDdl: () => generatePostgresTriggersDdl,
|
|
28
28
|
generatePostgresVectorDdl: () => generatePostgresVectorDdl,
|
|
29
29
|
generatePostgresViewsDdl: () => generatePostgresViewsDdl,
|
|
30
|
-
planCollectionPolicies: () => planCollectionPolicies,
|
|
31
30
|
planJunctionTables: () => planJunctionTables,
|
|
31
|
+
planRelationalColumns: () => planRelationalColumns,
|
|
32
|
+
planTablePolicies: () => planTablePolicies,
|
|
32
33
|
searchColumnDependencies: () => searchColumnDependencies,
|
|
33
34
|
searchExcludePatterns: () => searchExcludePatterns,
|
|
34
35
|
triggerExcludePatterns: () => triggerExcludePatterns,
|
|
@@ -42,9 +43,9 @@ var generate_postgres_ddl_logic_exports = /* @__PURE__ */ __exportAll({
|
|
|
42
43
|
* for no reason and made the one place that forgot to await it silently compare
|
|
43
44
|
* `[object Promise]`.
|
|
44
45
|
*/
|
|
45
|
-
var generatePostgresDdl = (
|
|
46
|
+
var generatePostgresDdl = (tables, options = {}) => renderPostgresDdl(planSchema(tables), options);
|
|
46
47
|
/** `.rebase/sql/policies.sql` — the RLS policies. Atlas has no model for a policy. */
|
|
47
|
-
var generatePostgresPoliciesDdl = (
|
|
48
|
+
var generatePostgresPoliciesDdl = (tables) => renderPoliciesDdl(planSchema(tables));
|
|
48
49
|
/**
|
|
49
50
|
* `.rebase/sql/search.sql` — everything a `search` block needs, as a file Rebase
|
|
50
51
|
* applies itself.
|
|
@@ -64,7 +65,7 @@ var generatePostgresPoliciesDdl = (allCollections) => renderPoliciesDdl(planSche
|
|
|
64
65
|
*
|
|
65
66
|
* Empty when nothing opted in — the caller writes no file then.
|
|
66
67
|
*/
|
|
67
|
-
var generatePostgresSearchDdl = (
|
|
68
|
+
var generatePostgresSearchDdl = (tables) => renderSearchDdl(planSchema(tables));
|
|
68
69
|
/**
|
|
69
70
|
* Glob patterns telling Atlas to leave the search column and its index alone.
|
|
70
71
|
*
|
|
@@ -72,7 +73,7 @@ var generatePostgresSearchDdl = (allCollections) => renderSearchDdl(planSchema(a
|
|
|
72
73
|
* instruction to drop the column — taking the index and the whole search
|
|
73
74
|
* feature with it on the next push.
|
|
74
75
|
*/
|
|
75
|
-
var searchExcludePatterns = (
|
|
76
|
+
var searchExcludePatterns = (tables) => searchExcludePatternsOf(planSchema(tables));
|
|
76
77
|
/**
|
|
77
78
|
* `.rebase/sql/vector.sql` — the `vector` columns, their ANN indexes and, when a
|
|
78
79
|
* database declared it, the extension.
|
|
@@ -84,9 +85,9 @@ var searchExcludePatterns = (allCollections) => searchExcludePatternsOf(planSche
|
|
|
84
85
|
* run — so `VECTOR(384)` resolves against a database that structurally cannot
|
|
85
86
|
* have pgvector, and every push dies with `type "vector" does not exist`.
|
|
86
87
|
*/
|
|
87
|
-
var generatePostgresVectorDdl = (
|
|
88
|
+
var generatePostgresVectorDdl = (tables, options = {}) => renderVectorDdl(planSchema(tables, { databaseExtensions: options.extensions }));
|
|
88
89
|
/** @see searchExcludePatterns */
|
|
89
|
-
var vectorExcludePatterns = (
|
|
90
|
+
var vectorExcludePatterns = (tables) => vectorExcludePatternsOf(planSchema(tables));
|
|
90
91
|
/**
|
|
91
92
|
* `.rebase/sql/triggers.sql` — the `BEFORE UPDATE` triggers behind
|
|
92
93
|
* `autoValue: "on_update"`, and the one function they share.
|
|
@@ -95,16 +96,45 @@ var vectorExcludePatterns = (allCollections) => vectorExcludePatternsOf(planSche
|
|
|
95
96
|
* for the first of the two reasons search is. Empty when no property declares
|
|
96
97
|
* `on_update` — the caller writes no file then, and removes a stale one.
|
|
97
98
|
*/
|
|
98
|
-
var generatePostgresTriggersDdl = (
|
|
99
|
+
var generatePostgresTriggersDdl = (tables) => renderTriggersDdl(planSchema(tables));
|
|
99
100
|
/**
|
|
100
101
|
* `.rebase/sql/views.sql` — the views of the collections that declare `view`,
|
|
101
102
|
* which Atlas's free tier does not manage. Empty when none does — the caller
|
|
102
103
|
* writes no file then, and removes a stale one.
|
|
103
104
|
*/
|
|
104
|
-
var generatePostgresViewsDdl = (
|
|
105
|
+
var generatePostgresViewsDdl = (tables) => renderViewsDdl(planSchema(tables));
|
|
105
106
|
/** @see searchExcludePatterns */
|
|
106
|
-
var triggerExcludePatterns = (
|
|
107
|
-
var planOf = (
|
|
107
|
+
var triggerExcludePatterns = (tables) => triggerExcludePatternsOf(planSchema(tables));
|
|
108
|
+
var planOf = (tables) => planSchema(tables);
|
|
109
|
+
/**
|
|
110
|
+
* The FK columns the declared collections own — one entry per `relation`
|
|
111
|
+
* (`belongsTo` side) or `reference` property.
|
|
112
|
+
*
|
|
113
|
+
* A view over the schema plan. It was a second walk of the collections beside
|
|
114
|
+
* the `CREATE TABLE` one, which is how boot-ensure came to add every relation
|
|
115
|
+
* column bare while `db push` made the same column `NOT NULL`.
|
|
116
|
+
*/
|
|
117
|
+
var planRelationalColumns = (tables) => {
|
|
118
|
+
const plan = planOf(tables);
|
|
119
|
+
const out = [];
|
|
120
|
+
for (const table of plan.tables) {
|
|
121
|
+
if (table.kind !== "collection") continue;
|
|
122
|
+
for (const column of table.columns) {
|
|
123
|
+
if (column.source.kind !== "relation" && column.source.kind !== "reference") continue;
|
|
124
|
+
out.push({
|
|
125
|
+
schema: table.schema,
|
|
126
|
+
table: table.table,
|
|
127
|
+
column: column.column,
|
|
128
|
+
type: renderPgType(column.type),
|
|
129
|
+
required: !column.nullable,
|
|
130
|
+
columnOwnedByProperty: column.columnOwnedByProperty,
|
|
131
|
+
legacyColumn: column.legacyColumn,
|
|
132
|
+
foreignKey: column.foreignKey
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
137
|
+
};
|
|
108
138
|
/**
|
|
109
139
|
* The junction tables a bundle's many-to-many relations imply.
|
|
110
140
|
*
|
|
@@ -112,7 +142,7 @@ var planOf = (collections) => planSchema(collections);
|
|
|
112
142
|
* here always has policies planned for it — a junction with row-level security
|
|
113
143
|
* left off is readable and writable by every signed-in user.
|
|
114
144
|
*/
|
|
115
|
-
var planJunctionTables = (
|
|
145
|
+
var planJunctionTables = (tables) => planOf(tables).tables.filter((table) => table.kind === "junction").map((table) => ({
|
|
116
146
|
schema: table.schema,
|
|
117
147
|
table: table.table,
|
|
118
148
|
columns: table.columns.map((c) => ({
|
|
@@ -131,8 +161,8 @@ var planJunctionTables = (allCollections) => planOf(allCollections).tables.filte
|
|
|
131
161
|
* The same policies `policies.sql` carries, from the same plan, so boot and
|
|
132
162
|
* `db push` produce identical RLS from identical collections.
|
|
133
163
|
*/
|
|
134
|
-
var
|
|
135
|
-
const plan = planOf(
|
|
164
|
+
var planTablePolicies = (tables, options = {}) => {
|
|
165
|
+
const plan = planOf(tables);
|
|
136
166
|
return [...plan.tables.filter((t) => t.kind === "collection"), ...plan.tables.filter((t) => t.kind === "junction")].map((table) => {
|
|
137
167
|
const policies = table.policies.flatMap((planned) => {
|
|
138
168
|
const policy = options.adminRoleAvailable === false && planned.adminTarget ? {
|
|
@@ -187,9 +217,9 @@ var planCollectionPolicies = (allCollections, options = {}) => {
|
|
|
187
217
|
* A spec's `fields[].column` is the physical column each search field starts
|
|
188
218
|
* at, which is exactly what the generated expression depends on.
|
|
189
219
|
*/
|
|
190
|
-
var searchColumnDependencies = (
|
|
220
|
+
var searchColumnDependencies = (tables) => {
|
|
191
221
|
const dependencies = [];
|
|
192
|
-
for (const table of planOf(
|
|
222
|
+
for (const table of planOf(tables).tables) {
|
|
193
223
|
const spec = table.search;
|
|
194
224
|
if (!spec) continue;
|
|
195
225
|
const generated = [spec.column, ...spec.fuzzy ? [spec.fuzzy.column] : []];
|
|
@@ -204,6 +234,6 @@ var searchColumnDependencies = (allCollections) => {
|
|
|
204
234
|
return dependencies;
|
|
205
235
|
};
|
|
206
236
|
//#endregion
|
|
207
|
-
export { generatePostgresVectorDdl as a,
|
|
237
|
+
export { generatePostgresVectorDdl as a, planJunctionTables as c, searchExcludePatterns as d, triggerExcludePatterns as f, generatePostgresTriggersDdl as i, planRelationalColumns as l, generatePostgresPoliciesDdl as n, generatePostgresViewsDdl as o, vectorExcludePatterns as p, generatePostgresSearchDdl as r, generate_postgres_ddl_logic_exports as s, generatePostgresDdl as t, planTablePolicies as u };
|
|
208
238
|
|
|
209
|
-
//# sourceMappingURL=generate-postgres-ddl-logic-
|
|
239
|
+
//# sourceMappingURL=generate-postgres-ddl-logic-B8huc03c.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-postgres-ddl-logic-B8huc03c.js","names":[],"sources":["../src/schema/generate-postgres-ddl-logic.ts"],"sourcesContent":["/**\n * The SQL half of `rebase db generate`, as a plan and a renderer.\n *\n * There is no interpretation left in this file. `schema/plan/plan-schema.ts`\n * reads the collections into a {@link SchemaPlan} and `schema/plan/render-ddl.ts`\n * writes the files; what remains here is the public entry points those two are\n * reached through, plus the smaller plans (`planRelationalColumns`,\n * `planJunctionTables`, `planTablePolicies`) that other modules ask for as\n * slices of the same plan.\n *\n * It used to hold `getSqlColumnType` and a `CREATE TABLE` walk with its own\n * reading of relations, junctions, enums and search — one of three such\n * readings. See `schema/plan/types.ts` for what that cost.\n */\nimport { REBASE_ADMIN_REQUEST_ROLE, type CompiledTable, type SecurityRule, type TableDescriptor } from \"@rebasepro/types\";\nimport { policyTableFromDescriptor, policyTableResolver, type ResolvePolicyTable } from \"@rebasepro/common\";\nimport { compileTableSecurityRule, planSchema, quoteSqlLiteral, defaultBelongsToOnDelete } from \"./plan/plan-schema\";\nimport {\n renderDenyingPolicyStatements,\n renderPgType,\n renderPoliciesDdl,\n renderPolicyStatements,\n renderPostgresDdl,\n renderSearchDdl,\n renderTriggersDdl,\n renderViewsDdl,\n renderVectorDdl,\n searchExcludePatternsOf,\n triggerExcludePatternsOf,\n vectorExcludePatternsOf,\n type DdlRenderOptions\n} from \"./plan/render-ddl\";\nimport type { ForeignKeyPlan, SchemaPlan } from \"./plan/types\";\nimport type { GeneratedColumnDependency } from \"./generated-column-conflicts\";\n\nexport { quoteSqlLiteral, defaultBelongsToOnDelete };\nexport type { ForeignKeyPlan };\n\n/**\n * The individual SQL statements a single security rule compiles to: a\n * `DROP POLICY IF EXISTS` / `CREATE POLICY` pair per operation, each a complete\n * statement (terminated by `;`, no trailing newline).\n *\n * This is the primitive the boot-time RLS applier runs one statement at a time\n * (the runtime's DB handle speaks the extended query protocol, which forbids\n * multiple commands in one execute), while `db push` writes the joined string.\n *\n * `resolveTable` answers the tables a rule's `existsIn` reaches; by default\n * only the table itself.\n */\nexport const generatePolicyStatements = (\n table: TableDescriptor,\n rule: SecurityRule,\n resolveTable: ResolvePolicyTable = policyTableResolver([table])\n): string[] =>\n compileTableSecurityRule(policyTableFromDescriptor(table), rule, resolveTable, false)\n .flatMap(policy => renderPolicyStatements({ schema: table.schema, table: table.table }, policy));\n\n/**\n * `.rebase/sql/schema.sql` — the desired state Atlas diffs the database against.\n *\n * Synchronous. It was `async` with nothing to await, which made every caller\n * (the writer script, the doctor, the live editor, two gates) carry a promise\n * for no reason and made the one place that forgot to await it silently compare\n * `[object Promise]`.\n */\nexport const generatePostgresDdl = (\n tables: readonly CompiledTable[],\n options: DdlRenderOptions = {}\n): string => renderPostgresDdl(planSchema(tables), options);\n\n/** `.rebase/sql/policies.sql` — the RLS policies. Atlas has no model for a policy. */\nexport const generatePostgresPoliciesDdl = (tables: readonly CompiledTable[]): string =>\n renderPoliciesDdl(planSchema(tables));\n\n/**\n * `.rebase/sql/search.sql` — everything a `search` block needs, as a file Rebase\n * applies itself.\n *\n * Search is one of the parts of the schema Atlas does not own, for two\n * independent reasons and either alone would be enough:\n *\n * 1. Its free tier refuses to *parse* a desired-state file that so much as\n * contains a function — \"functions and procedures are available to\n * logged-in users only\". A generated `tsvector` column cannot avoid one:\n * `unaccent` is STABLE and jsonb flattening needs a set-returning function,\n * so both have to be wrapped in an IMMUTABLE helper to be legal in a\n * generated column at all.\n * 2. Even with the file accepted, Atlas *wipes* the dev database it diffs\n * against, so a helper seeded there beforehand is gone by the time the plan\n * is analysed. There is no hook to reinstate it.\n *\n * Empty when nothing opted in — the caller writes no file then.\n */\nexport const generatePostgresSearchDdl = (tables: readonly CompiledTable[]): string =>\n renderSearchDdl(planSchema(tables));\n\n/**\n * Glob patterns telling Atlas to leave the search column and its index alone.\n *\n * Without these, a desired state that omits search reads to Atlas as an\n * instruction to drop the column — taking the index and the whole search\n * feature with it on the next push.\n */\nexport const searchExcludePatterns = (tables: readonly CompiledTable[]): string[] =>\n searchExcludePatternsOf(planSchema(tables));\n\n/**\n * `.rebase/sql/vector.sql` — the `vector` columns, their ANN indexes and, when a\n * database declared it, the extension.\n *\n * Vector is out of Atlas's hands for a narrower reason than search: not that\n * Atlas refuses to parse the file, but that it cannot *execute* it. To compute\n * a desired state Atlas materialises `schema.sql` in a dev database, that\n * database is created empty, and Atlas empties it again at the start of every\n * run — so `VECTOR(384)` resolves against a database that structurally cannot\n * have pgvector, and every push dies with `type \"vector\" does not exist`.\n */\nexport const generatePostgresVectorDdl = (\n tables: readonly CompiledTable[],\n options: { extensions?: readonly string[] } = {}\n): string => renderVectorDdl(planSchema(tables, { databaseExtensions: options.extensions }));\n\n/** @see searchExcludePatterns */\nexport const vectorExcludePatterns = (tables: readonly CompiledTable[]): string[] =>\n vectorExcludePatternsOf(planSchema(tables));\n\n/**\n * `.rebase/sql/triggers.sql` — the `BEFORE UPDATE` triggers behind\n * `autoValue: \"on_update\"`, and the one function they share.\n *\n * A trigger is a function plus a binding, so it is carved out of Atlas's view\n * for the first of the two reasons search is. Empty when no property declares\n * `on_update` — the caller writes no file then, and removes a stale one.\n */\nexport const generatePostgresTriggersDdl = (tables: readonly CompiledTable[]): string =>\n renderTriggersDdl(planSchema(tables));\n\n/**\n * `.rebase/sql/views.sql` — the views of the collections that declare `view`,\n * which Atlas's free tier does not manage. Empty when none does — the caller\n * writes no file then, and removes a stale one.\n */\nexport const generatePostgresViewsDdl = (tables: readonly CompiledTable[]): string =>\n renderViewsDdl(planSchema(tables));\n\n/** @see searchExcludePatterns */\nexport const triggerExcludePatterns = (tables: readonly CompiledTable[]): string[] =>\n triggerExcludePatternsOf(planSchema(tables));\n\n// ── Slices of the plan other modules ask for ─────────────────────────────────\n\n/** A column a `relation` or `reference` property owns on its own table. */\nexport interface RelationalColumnPlan {\n schema: string;\n /** Bare table name, no schema prefix. */\n table: string;\n column: string;\n /** Postgres type, exactly as the DDL renderer declares it. */\n type: string;\n /** `validation.required` on the property that owns the link. */\n required: boolean;\n /**\n * True when a declared property emits this column and the relation\n * contributes only the constraint — `postId` with `columnName: \"post_id\"`\n * beside a `belongsTo` on `post_id`.\n */\n columnOwnedByProperty?: boolean;\n /** Absent when the target collection is not part of this bundle. */\n foreignKey?: ForeignKeyPlan;\n /**\n * What this column would have been called before `generateForeignKeyName`\n * learned to singularize. Carried so the boot-time ensure can notice a\n * database provisioned under the old rule; never used to name anything.\n */\n legacyColumn?: string;\n}\n\n/** The table behind a many-to-many `through` relation. */\nexport interface JunctionTablePlan {\n schema: string;\n /** Bare table name, no schema prefix. */\n table: string;\n columns: { name: string; type: string; legacyName?: string }[];\n /** Both endpoint columns plus the composite primary key. */\n createTable: string;\n foreignKeys: ForeignKeyPlan[];\n}\n\nconst planOf = (tables: readonly CompiledTable[]): SchemaPlan => planSchema(tables);\n\n/**\n * The FK columns the declared collections own — one entry per `relation`\n * (`belongsTo` side) or `reference` property.\n *\n * A view over the schema plan. It was a second walk of the collections beside\n * the `CREATE TABLE` one, which is how boot-ensure came to add every relation\n * column bare while `db push` made the same column `NOT NULL`.\n */\nexport const planRelationalColumns = (tables: readonly CompiledTable[]): RelationalColumnPlan[] => {\n const plan = planOf(tables);\n const out: RelationalColumnPlan[] = [];\n for (const table of plan.tables) {\n if (table.kind !== \"collection\") continue;\n for (const column of table.columns) {\n if (column.source.kind !== \"relation\" && column.source.kind !== \"reference\") continue;\n out.push({\n schema: table.schema,\n table: table.table,\n column: column.column,\n type: renderPgType(column.type),\n required: !column.nullable,\n columnOwnedByProperty: column.columnOwnedByProperty,\n legacyColumn: column.legacyColumn,\n foreignKey: column.foreignKey\n });\n }\n }\n return out;\n};\n\n/**\n * The junction tables a bundle's many-to-many relations imply.\n *\n * Derived from the same plan the derived RLS comes from, so a table created\n * here always has policies planned for it — a junction with row-level security\n * left off is readable and writable by every signed-in user.\n */\nexport const planJunctionTables = (tables: readonly CompiledTable[]): JunctionTablePlan[] =>\n planOf(tables).tables\n .filter(table => table.kind === \"junction\")\n .map(table => ({\n schema: table.schema,\n table: table.table,\n columns: table.columns.map(c => ({\n name: c.column,\n type: renderPgType(c.type),\n legacyName: c.legacyColumn\n })),\n createTable:\n `CREATE TABLE IF NOT EXISTS \"${table.schema}\".\"${table.table}\" (` +\n table.columns.map(c => `\"${c.column}\" ${renderPgType(c.type)} NOT NULL`).join(\", \") +\n `, PRIMARY KEY (${table.primaryKey.map(c => `\"${c}\"`).join(\", \")}));`,\n foreignKeys: table.columns.map(c => c.foreignKey).filter((fk): fk is ForeignKeyPlan => fk !== undefined)\n }));\n\nexport interface TablePolicyPlan {\n /** The table's schema (e.g. `public`, `rebase`). */\n schema: string;\n /** The bare table name, no schema prefix. */\n table: string;\n /** `schema.table` — matches the keys `readExistingSchema` returns. */\n qualified: string;\n /** `ALTER TABLE … ENABLE ROW LEVEL SECURITY;` — locked by default. */\n enableRls: string;\n /** `DROP POLICY IF EXISTS` / `CREATE POLICY` statements, in order. */\n policyStatements: string[];\n /**\n * The same statements, grouped by policy, with each restrictive policy's\n * denying stand-in. What the boot applier's one-statement-at-a-time\n * fallback walks: it creates the restrictive gates before any grant, and\n * puts the stand-in where a gate could not be created.\n */\n policies: PolicyApplyPlan[];\n}\n\n/** One policy of a {@link TablePolicyPlan}, as the statements that make it. */\nexport interface PolicyApplyPlan {\n name: string;\n /** Written `TO rebase_admin` by the compiler's choice (`rls.adminPolicies`). */\n adminTarget: boolean;\n /** The `TO rebase_admin_request USING (true)` companion of an admin-only policy. */\n adminRequestTarget?: true;\n restrictive: boolean;\n /** Its `DROP POLICY IF EXISTS` / `CREATE POLICY` statements — a slice of `policyStatements`. */\n statements: string[];\n /** For a restrictive policy, the statements that make it deny every row instead. */\n denying?: string[];\n}\n\n/**\n * The per-table RLS plan for the declared collections and their junctions, as\n * executable statements — what the managed runtime applies at boot so a freshly\n * provisioned tenant database serves data instead of 401ing every read.\n *\n * The same policies `policies.sql` carries, from the same plan, so boot and\n * `db push` produce identical RLS from identical collections.\n */\nexport const planTablePolicies = (\n tables: readonly CompiledTable[],\n options: {\n adminRoleAvailable?: boolean;\n /**\n * The boot made `rebase_admin_request`, granted it to the admin request\n * roles alone, and checked the connection does not hold its\n * privileges. Only then are the companions planned; otherwise they\n * are left out, and the boot drops any left in the database.\n */\n adminRequestRoleAvailable?: boolean;\n } = {}\n): TablePolicyPlan[] => {\n const plan = planOf(tables);\n // Collections first, then the junctions no collection declares.\n const ordered = [\n ...plan.tables.filter(t => t.kind === \"collection\"),\n ...plan.tables.filter(t => t.kind === \"junction\")\n ];\n return ordered.map(table => {\n const policies: PolicyApplyPlan[] = table.policies.flatMap(planned => {\n // Where `rebase_admin` cannot exist, a policy the compiler put there\n // is written as it was before it did: `TO public`.\n const policy = options.adminRoleAvailable === false && planned.adminTarget\n ? { ...planned, roles: [\"public\"] }\n : planned;\n const restrictive = policy.mode === \"restrictive\";\n const applied: PolicyApplyPlan = {\n name: policy.name,\n adminTarget: policy.adminTarget === true && policy.roles[0] !== \"public\",\n restrictive,\n statements: renderPolicyStatements(table, policy),\n ...(restrictive ? { denying: renderDenyingPolicyStatements(table, policy) } : {})\n };\n // The companion goes only beside a policy actually written TO\n // rebase_admin, and never anywhere else: moved TO public, it would\n // be `USING (true)` for everyone.\n const companion = planned.adminRequestCompanion;\n if (!companion || !applied.adminTarget || options.adminRequestRoleAvailable !== true) return [applied];\n return [applied, {\n name: companion.name,\n adminTarget: false,\n adminRequestTarget: true,\n restrictive: false,\n statements: renderPolicyStatements(table, {\n ...policy,\n name: companion.name,\n mode: \"permissive\",\n roles: [REBASE_ADMIN_REQUEST_ROLE],\n using: companion.using,\n withCheck: companion.withCheck,\n adminTarget: undefined,\n adminRequestCompanion: undefined,\n supersedes: undefined\n })\n }];\n });\n return {\n schema: table.schema,\n table: table.table,\n qualified: table.qualified,\n enableRls: `ALTER TABLE \"${table.schema}\".\"${table.table}\" ENABLE ROW LEVEL SECURITY;`,\n policyStatements: policies.flatMap(policy => policy.statements),\n policies\n };\n });\n};\n\n/**\n * The `generated column → column it reads` edges a project's `search` blocks\n * imply, derived from the collections alone.\n *\n * The same edges `queryGeneratedColumnDependencies` reads out of `pg_depend`,\n * but available where no database is: `rebase db generate` writes a migration\n * that will run somewhere else, later, against a database it cannot inspect.\n * A spec's `fields[].column` is the physical column each search field starts\n * at, which is exactly what the generated expression depends on.\n */\nexport const searchColumnDependencies = (\n tables: readonly CompiledTable[]\n): GeneratedColumnDependency[] => {\n const dependencies: GeneratedColumnDependency[] = [];\n for (const table of planOf(tables).tables) {\n const spec = table.search;\n if (!spec) continue;\n const generated = [spec.column, ...(spec.fuzzy ? [spec.fuzzy.column] : [])];\n const sources = new Set(spec.fields.map(field => field.column));\n for (const column of generated) {\n for (const dependsOn of sources) {\n dependencies.push({ schema: table.schema, table: table.table, column, dependsOn });\n }\n }\n }\n return dependencies;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,IAAa,uBACT,QACA,UAA4B,CAAC,MACpB,kBAAkB,WAAW,MAAM,GAAG,OAAO;;AAG1D,IAAa,+BAA+B,WACxC,kBAAkB,WAAW,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;AAqBxC,IAAa,6BAA6B,WACtC,gBAAgB,WAAW,MAAM,CAAC;;;;;;;;AAStC,IAAa,yBAAyB,WAClC,wBAAwB,WAAW,MAAM,CAAC;;;;;;;;;;;;AAa9C,IAAa,6BACT,QACA,UAA8C,CAAC,MACtC,gBAAgB,WAAW,QAAQ,EAAE,oBAAoB,QAAQ,WAAW,CAAC,CAAC;;AAG3F,IAAa,yBAAyB,WAClC,wBAAwB,WAAW,MAAM,CAAC;;;;;;;;;AAU9C,IAAa,+BAA+B,WACxC,kBAAkB,WAAW,MAAM,CAAC;;;;;;AAOxC,IAAa,4BAA4B,WACrC,eAAe,WAAW,MAAM,CAAC;;AAGrC,IAAa,0BAA0B,WACnC,yBAAyB,WAA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