@rebasepro/server-postgres 0.31.0 → 0.32.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-USp1AvZB.js → BranchService-C8LtpMho.js} +3 -3
- package/dist/{BranchService-USp1AvZB.js.map → BranchService-C8LtpMho.js.map} +1 -1
- package/dist/{backup-cli-DbKyEj6c.js → backup-cli-DtV6n3oB.js} +3 -3
- package/dist/{backup-cli-DbKyEj6c.js.map → backup-cli-DtV6n3oB.js.map} +1 -1
- package/dist/{boot-ddl-5H2bL_80.js → boot-ddl-CSYhSSZD.js} +2 -2
- package/dist/{boot-ddl-5H2bL_80.js.map → boot-ddl-CSYhSSZD.js.map} +1 -1
- package/dist/{cli-console-DsRgGSBR.js → cli-console-Cu1DzqvR.js} +4 -4
- package/dist/{cli-console-DsRgGSBR.js.map → cli-console-Cu1DzqvR.js.map} +1 -1
- package/dist/{cli-schema-dir-CiN0ephV.js → cli-schema-dir-DuZIsF2e.js} +5 -5
- package/dist/{cli-schema-dir-CiN0ephV.js.map → cli-schema-dir-DuZIsF2e.js.map} +1 -1
- package/dist/cli.js +124 -36
- package/dist/cli.js.map +1 -1
- package/dist/{database-preflight-bfnIBnjM.js → database-preflight-CyTCWlfc.js} +2 -2
- package/dist/{database-preflight-bfnIBnjM.js.map → database-preflight-CyTCWlfc.js.map} +1 -1
- package/dist/{deferred-index-build-CcSDA7wE.js → deferred-index-build-ueYVUBZc.js} +4 -4
- package/dist/{deferred-index-build-CcSDA7wE.js.map → deferred-index-build-ueYVUBZc.js.map} +1 -1
- package/dist/{ensure-policies-rRmXb5bt.js → ensure-policies-13mHWjBs.js} +7 -7
- package/dist/{ensure-policies-rRmXb5bt.js.map → ensure-policies-13mHWjBs.js.map} +1 -1
- package/dist/{ensure-tables-Bvm-F2wW.js → ensure-tables-B3Kh2RwT.js} +7 -7
- package/dist/{ensure-tables-Bvm-F2wW.js.map → ensure-tables-B3Kh2RwT.js.map} +1 -1
- package/dist/{ensure-tables-CC8p_AK3.js → ensure-tables-DM1U9AZK.js} +3 -3
- package/dist/{ensure-tables-CC8p_AK3.js.map → ensure-tables-DM1U9AZK.js.map} +1 -1
- package/dist/{enum-labels-kept-FlX9SHdf.js → enum-labels-kept-CJDVtX14.js} +2 -2
- package/dist/{enum-labels-kept-FlX9SHdf.js.map → enum-labels-kept-CJDVtX14.js.map} +1 -1
- package/dist/{generate-drizzle-schema-SJMXxzPI.js → generate-drizzle-schema-B-Mkf8UI.js} +2 -2
- package/dist/{generate-drizzle-schema-SJMXxzPI.js.map → generate-drizzle-schema-B-Mkf8UI.js.map} +1 -1
- package/dist/{generate-files-tlJ9_lGI.js → generate-files-8MUP8UHC.js} +2 -2
- package/dist/{generate-files-tlJ9_lGI.js.map → generate-files-8MUP8UHC.js.map} +1 -1
- package/dist/{generate-postgres-ddl-logic-B8huc03c.js → generate-postgres-ddl-logic-CQof4iFH.js} +89 -45
- package/dist/generate-postgres-ddl-logic-CQof4iFH.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.es.js +14 -14
- package/dist/{migrate-baseline-DZmekgpD.js → migrate-baseline-DnMlSDup.js} +9 -2
- package/dist/{migrate-baseline-DZmekgpD.js.map → migrate-baseline-DnMlSDup.js.map} +1 -1
- package/dist/{migrate-policy-stamps-B_acrUQB.js → migrate-policy-stamps-BpHyEFkk.js} +5 -5
- package/dist/{migrate-policy-stamps-B_acrUQB.js.map → migrate-policy-stamps-BpHyEFkk.js.map} +1 -1
- package/dist/{open-rebase-4kisUF_k.js → open-rebase-B2mAA7UE.js} +175 -38
- package/dist/open-rebase-B2mAA7UE.js.map +1 -0
- package/dist/{pg-error-utils-BT5NzGFZ.js → pg-error-utils-CpUiBkp-.js} +2 -2
- package/dist/{pg-error-utils-BT5NzGFZ.js.map → pg-error-utils-CpUiBkp-.js.map} +1 -1
- package/dist/{policy-drift-BVMyqHSa.js → policy-drift-C9xRcbsU.js} +4 -4
- package/dist/{policy-drift-BVMyqHSa.js.map → policy-drift-C9xRcbsU.js.map} +1 -1
- package/dist/{push-index-adoption-hpHTyXMR.js → push-index-adoption-D-ph6kBc.js} +2 -2
- package/dist/{push-index-adoption-hpHTyXMR.js.map → push-index-adoption-D-ph6kBc.js.map} +1 -1
- package/dist/{push-index-prebuild-Bty9F7bD.js → push-index-prebuild-DUKtH87s.js} +3 -3
- package/dist/{push-index-prebuild-Bty9F7bD.js.map → push-index-prebuild-DUKtH87s.js.map} +1 -1
- package/dist/{push-legacy-renames-bB4bM6br.js → push-legacy-renames-wLSsAg80.js} +3 -3
- package/dist/{push-legacy-renames-bB4bM6br.js.map → push-legacy-renames-wLSsAg80.js.map} +1 -1
- package/dist/{push-policy-plan-BI8U4BOD.js → push-policy-plan-I9RNoP_-.js} +3 -3
- package/dist/{push-policy-plan-BI8U4BOD.js.map → push-policy-plan-I9RNoP_-.js.map} +1 -1
- package/dist/{request-role-cli-BdRzdE87.js → request-role-cli-D9yWoeSl.js} +8 -8
- package/dist/{request-role-cli-BdRzdE87.js.map → request-role-cli-D9yWoeSl.js.map} +1 -1
- package/dist/{request-role-migration-C8aq_TO3.js → request-role-migration-DQLiYJ4c.js} +2 -2
- package/dist/{request-role-migration-C8aq_TO3.js.map → request-role-migration-DQLiYJ4c.js.map} +1 -1
- package/dist/{rls-enforcement-DB5HHj96.js → rls-enforcement-Cwh5SJRx.js} +2 -2
- package/dist/{rls-enforcement-DB5HHj96.js.map → rls-enforcement-Cwh5SJRx.js.map} +1 -1
- package/dist/schema/doctor-cli.js +5 -5
- package/dist/schema/generate-drizzle-schema.js +1 -1
- package/dist/schema/generate-postgres-ddl-logic.d.ts +51 -8
- package/dist/schema/generate-postgres-ddl.js +1 -1
- package/dist/schema/introspect-db.js +1 -1
- package/dist/services/cdc/capture-consumers.d.ts +65 -0
- package/dist/services/cdc/wal-cdc.d.ts +13 -0
- package/dist/services/realtimeService.d.ts +18 -2
- package/dist/{websocket-BevXvwfo.js → websocket-CSVNOYHC.js} +3 -3
- package/dist/{websocket-BevXvwfo.js.map → websocket-CSVNOYHC.js.map} +1 -1
- package/package.json +7 -7
- package/dist/generate-postgres-ddl-logic-B8huc03c.js.map +0 -1
- package/dist/open-rebase-4kisUF_k.js.map +0 -1
|
@@ -1 +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;AACJ;;AAgBA,eAAsB,mBAAmB,SAA6C;CAClF,IAAI;EAIA,MAAM,gBAAgB,eAAe,MADhB,WAAW,QAAQ,SAAS,CACN;EAE3C,IAAI,QAAQ,YAAY;GACpB,MAAM,SAAW,MAAM,KAAK,QAAQ,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;GAC5E,MAAM,SAAW,UAAU,QAAQ,YAAY,aAAa;GAC5D,IAAI,8CAA8C,QAAQ,YAAY;EAC1E,OAAO;GACH,IAAI,0CAA0C;GAC9C,IAAI,OAAO,aAAa,CAAC;EAC7B;EAEA,IAAI,QAAQ,aAAa,OAAO,IAAI,sBAAsB,CAAC;CAC/D,SAAS,OAAO;EACZ,SAAS,4BAA4B,gBAAgB,KAAK,GAAG;EAG7D,MAAM,IAAI,iBAAiB,oCAAoC,EAAE,OAAO,MAAM,CAAC;CACnF;AACJ;;AAGA,IAAM,mBAAmB;CAAC;CAAgB;CAAgB;CAAsB;AAAoB;;;;;;;;;;;;;;;;;;;;AAqBpG,eAAe,sBAAsB,YAAmC;CACpE,MAAM,QAAQ,iBACT,KAAI,SAAQ,KAAK,KAAK,YAAY,IAAI,CAAC,CAAC,CACxC,MAAK,cAAa,KAAG,WAAW,SAAS,CAAC;CAC/C,IAAI,CAAC,OAAO;CACZ,MAAM,OAAO,cAAc,KAAK,CAAC,CAAC;AACtC;;;;;;AAOA,eAAsB,iBAAiB,SAA6C;CAChF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,cAAc;GAC5E,OAAO,IAAI,KAAG,WAAW,YAAY,GACjC,MAAM,SAAW,GAAG,YAAY;GAMpC,MAAM,YAAY,KAAK,KAAK,WAAW,WAAW;GAClD,IAAI,cAAc;IACd,MAAM,SAAW,UAAU,WAAW,YAAY;IAClD,IAAI,mDAAmD,WAAW;GACtE,OAAO,IAAI,KAAG,WAAW,SAAS,GAC9B,MAAM,SAAW,GAAG,SAAS;EAErC,OAAO;GACH,IAAI,0CAA0C;GAC9C,IAAI,OAAO,UAAU,CAAC;GACtB,IAAI,qDAAqD;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
|
+
{"version":3,"file":"generate-files-8MUP8UHC.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;AACJ;;AAgBA,eAAsB,mBAAmB,SAA6C;CAClF,IAAI;EAIA,MAAM,gBAAgB,eAAe,MADhB,WAAW,QAAQ,SAAS,CACN;EAE3C,IAAI,QAAQ,YAAY;GACpB,MAAM,SAAW,MAAM,KAAK,QAAQ,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;GAC5E,MAAM,SAAW,UAAU,QAAQ,YAAY,aAAa;GAC5D,IAAI,8CAA8C,QAAQ,YAAY;EAC1E,OAAO;GACH,IAAI,0CAA0C;GAC9C,IAAI,OAAO,aAAa,CAAC;EAC7B;EAEA,IAAI,QAAQ,aAAa,OAAO,IAAI,sBAAsB,CAAC;CAC/D,SAAS,OAAO;EACZ,SAAS,4BAA4B,gBAAgB,KAAK,GAAG;EAG7D,MAAM,IAAI,iBAAiB,oCAAoC,EAAE,OAAO,MAAM,CAAC;CACnF;AACJ;;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C/B,MAAM,SAAW,GAAG,UAAU;GAQlC,MAAM,aAAa,KAAK,KAAK,WAAW,YAAY;GACpD,IAAI,eAAe;IACf,MAAM,SAAW,UAAU,YAAY,aAAa;IACpD,IAAI,qDAAqD,YAAY;GACzE,OAAO,IAAI,KAAG,WAAW,UAAU,GAC/B,MAAM,SAAW,GAAG,UAAU;GAOlC,MAAM,eAAe,KAAK,KAAK,WAAW,cAAc;GACxD,IAAI,iBAAiB;IACjB,MAAM,SAAW,UAAU,cAAc,eAAe;IACxD,IAAI,sDAAsD,cAAc;GAC5E,OAAO,IAAI,KAAG,WAAW,YAAY,GACjC,MAAM,SAAW,GAAG,YAAY;GAMpC,MAAM,YAAY,KAAK,KAAK,WAAW,WAAW;GAClD,IAAI,cAAc;IACd,MAAM,SAAW,UAAU,WAAW,YAAY;IAClD,IAAI,mDAAmD,WAAW;GACtE,OAAO,IAAI,KAAG,WAAW,SAAS,GAC9B,MAAM,SAAW,GAAG,SAAS;EAErC,OAAO;GACH,IAAI,0CAA0C;GAC9C,IAAI,OAAO,UAAU,CAAC;GACtB,IAAI,qDAAqD;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"}
|
package/dist/{generate-postgres-ddl-logic-B8huc03c.js → generate-postgres-ddl-logic-CQof4iFH.js}
RENAMED
|
@@ -28,6 +28,7 @@ var generate_postgres_ddl_logic_exports = /* @__PURE__ */ __exportAll({
|
|
|
28
28
|
generatePostgresVectorDdl: () => generatePostgresVectorDdl,
|
|
29
29
|
generatePostgresViewsDdl: () => generatePostgresViewsDdl,
|
|
30
30
|
planJunctionTables: () => planJunctionTables,
|
|
31
|
+
planPolicyDefinitions: () => planPolicyDefinitions,
|
|
31
32
|
planRelationalColumns: () => planRelationalColumns,
|
|
32
33
|
planTablePolicies: () => planTablePolicies,
|
|
33
34
|
searchColumnDependencies: () => searchColumnDependencies,
|
|
@@ -153,6 +154,44 @@ var planJunctionTables = (tables) => planOf(tables).tables.filter((table) => tab
|
|
|
153
154
|
createTable: `CREATE TABLE IF NOT EXISTS "${table.schema}"."${table.table}" (` + table.columns.map((c) => `"${c.column}" ${renderPgType(c.type)} NOT NULL`).join(", ") + `, PRIMARY KEY (${table.primaryKey.map((c) => `"${c}"`).join(", ")}));`,
|
|
154
155
|
foreignKeys: table.columns.map((c) => c.foreignKey).filter((fk) => fk !== void 0)
|
|
155
156
|
}));
|
|
157
|
+
/** The planned tables in the order the boot writes them: collections first, then the junctions no collection declares. */
|
|
158
|
+
var policyTablesOf = (tables) => {
|
|
159
|
+
const plan = planOf(tables);
|
|
160
|
+
return [...plan.tables.filter((t) => t.kind === "collection"), ...plan.tables.filter((t) => t.kind === "junction")];
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* A table's policies as the boot writes them — the one reading both
|
|
164
|
+
* {@link planTablePolicies} (as statements) and {@link planPolicyDefinitions}
|
|
165
|
+
* (as data) render, so the two cannot describe different policies.
|
|
166
|
+
*/
|
|
167
|
+
var writtenPolicies = (table, options) => table.policies.flatMap((planned) => {
|
|
168
|
+
const policy = options.adminRoleAvailable === false && planned.adminTarget ? {
|
|
169
|
+
...planned,
|
|
170
|
+
roles: ["public"]
|
|
171
|
+
} : planned;
|
|
172
|
+
const written = {
|
|
173
|
+
policy,
|
|
174
|
+
adminTarget: policy.adminTarget === true && policy.roles[0] !== "public",
|
|
175
|
+
adminRequestTarget: false
|
|
176
|
+
};
|
|
177
|
+
const companion = planned.adminRequestCompanion;
|
|
178
|
+
if (!companion || !written.adminTarget || options.adminRequestRoleAvailable !== true) return [written];
|
|
179
|
+
return [written, {
|
|
180
|
+
policy: {
|
|
181
|
+
...policy,
|
|
182
|
+
name: companion.name,
|
|
183
|
+
mode: "permissive",
|
|
184
|
+
roles: [REBASE_ADMIN_REQUEST_ROLE],
|
|
185
|
+
using: companion.using,
|
|
186
|
+
withCheck: companion.withCheck,
|
|
187
|
+
adminTarget: void 0,
|
|
188
|
+
adminRequestCompanion: void 0,
|
|
189
|
+
supersedes: void 0
|
|
190
|
+
},
|
|
191
|
+
adminTarget: false,
|
|
192
|
+
adminRequestTarget: true
|
|
193
|
+
}];
|
|
194
|
+
});
|
|
156
195
|
/**
|
|
157
196
|
* The per-table RLS plan for the declared collections and their junctions, as
|
|
158
197
|
* executable statements — what the managed runtime applies at boot so a freshly
|
|
@@ -161,52 +200,57 @@ var planJunctionTables = (tables) => planOf(tables).tables.filter((table) => tab
|
|
|
161
200
|
* The same policies `policies.sql` carries, from the same plan, so boot and
|
|
162
201
|
* `db push` produce identical RLS from identical collections.
|
|
163
202
|
*/
|
|
164
|
-
var planTablePolicies = (tables, options = {}) => {
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
const policies = table.policies.flatMap((planned) => {
|
|
168
|
-
const policy = options.adminRoleAvailable === false && planned.adminTarget ? {
|
|
169
|
-
...planned,
|
|
170
|
-
roles: ["public"]
|
|
171
|
-
} : planned;
|
|
172
|
-
const restrictive = policy.mode === "restrictive";
|
|
173
|
-
const applied = {
|
|
174
|
-
name: policy.name,
|
|
175
|
-
adminTarget: policy.adminTarget === true && policy.roles[0] !== "public",
|
|
176
|
-
restrictive,
|
|
177
|
-
statements: renderPolicyStatements(table, policy),
|
|
178
|
-
...restrictive ? { denying: renderDenyingPolicyStatements(table, policy) } : {}
|
|
179
|
-
};
|
|
180
|
-
const companion = planned.adminRequestCompanion;
|
|
181
|
-
if (!companion || !applied.adminTarget || options.adminRequestRoleAvailable !== true) return [applied];
|
|
182
|
-
return [applied, {
|
|
183
|
-
name: companion.name,
|
|
184
|
-
adminTarget: false,
|
|
185
|
-
adminRequestTarget: true,
|
|
186
|
-
restrictive: false,
|
|
187
|
-
statements: renderPolicyStatements(table, {
|
|
188
|
-
...policy,
|
|
189
|
-
name: companion.name,
|
|
190
|
-
mode: "permissive",
|
|
191
|
-
roles: [REBASE_ADMIN_REQUEST_ROLE],
|
|
192
|
-
using: companion.using,
|
|
193
|
-
withCheck: companion.withCheck,
|
|
194
|
-
adminTarget: void 0,
|
|
195
|
-
adminRequestCompanion: void 0,
|
|
196
|
-
supersedes: void 0
|
|
197
|
-
})
|
|
198
|
-
}];
|
|
199
|
-
});
|
|
203
|
+
var planTablePolicies = (tables, options = {}) => policyTablesOf(tables).map((table) => {
|
|
204
|
+
const policies = writtenPolicies(table, options).map(({ policy, adminTarget, adminRequestTarget }) => {
|
|
205
|
+
const restrictive = policy.mode === "restrictive";
|
|
200
206
|
return {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
+
name: policy.name,
|
|
208
|
+
adminTarget,
|
|
209
|
+
...adminRequestTarget ? { adminRequestTarget: true } : {},
|
|
210
|
+
restrictive,
|
|
211
|
+
statements: renderPolicyStatements(table, policy),
|
|
212
|
+
...restrictive ? { denying: renderDenyingPolicyStatements(table, policy) } : {}
|
|
207
213
|
};
|
|
208
214
|
});
|
|
209
|
-
|
|
215
|
+
return {
|
|
216
|
+
schema: table.schema,
|
|
217
|
+
table: table.table,
|
|
218
|
+
qualified: table.qualified,
|
|
219
|
+
enableRls: `ALTER TABLE "${table.schema}"."${table.table}" ENABLE ROW LEVEL SECURITY;`,
|
|
220
|
+
policyStatements: policies.flatMap((policy) => policy.statements),
|
|
221
|
+
policies
|
|
222
|
+
};
|
|
223
|
+
});
|
|
224
|
+
function policyCommandOf(operation) {
|
|
225
|
+
switch (operation) {
|
|
226
|
+
case "all": return "ALL";
|
|
227
|
+
case "select": return "SELECT";
|
|
228
|
+
case "insert": return "INSERT";
|
|
229
|
+
case "update": return "UPDATE";
|
|
230
|
+
case "delete": return "DELETE";
|
|
231
|
+
default: throw new Error(`Internal: a policy was planned for the operation "${operation}", which is not a Postgres policy command.`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Every policy a boot writes for the tables and their junctions, as data:
|
|
236
|
+
* the same policies, in the same order, as {@link planTablePolicies} renders
|
|
237
|
+
* to statements. For a caller that reasons about the policies rather than
|
|
238
|
+
* applying them — `rebase verify` reads them to find a policy Postgres would
|
|
239
|
+
* refuse to expand (42P17, "infinite recursion detected in policy").
|
|
240
|
+
*/
|
|
241
|
+
var planPolicyDefinitions = (tables, options = {}) => policyTablesOf(tables).flatMap((table) => writtenPolicies(table, options).map(({ policy }) => ({
|
|
242
|
+
schema: table.schema,
|
|
243
|
+
table: table.table,
|
|
244
|
+
name: policy.name,
|
|
245
|
+
command: policyCommandOf(policy.operation),
|
|
246
|
+
permissive: policy.mode !== "restrictive",
|
|
247
|
+
roles: [...policy.roles],
|
|
248
|
+
using: policy.using,
|
|
249
|
+
withCheck: policy.withCheck,
|
|
250
|
+
ruleKey: policy.ruleKey,
|
|
251
|
+
injected: policy.injected,
|
|
252
|
+
junction: table.kind === "junction"
|
|
253
|
+
})));
|
|
210
254
|
/**
|
|
211
255
|
* The `generated column → column it reads` edges a project's `search` blocks
|
|
212
256
|
* imply, derived from the collections alone.
|
|
@@ -234,6 +278,6 @@ var searchColumnDependencies = (tables) => {
|
|
|
234
278
|
return dependencies;
|
|
235
279
|
};
|
|
236
280
|
//#endregion
|
|
237
|
-
export { generatePostgresVectorDdl as a, planJunctionTables as c,
|
|
281
|
+
export { generatePostgresVectorDdl as a, planJunctionTables as c, planTablePolicies as d, searchExcludePatterns as f, generatePostgresTriggersDdl as i, planPolicyDefinitions as l, vectorExcludePatterns as m, generatePostgresPoliciesDdl as n, generatePostgresViewsDdl as o, triggerExcludePatterns as p, generatePostgresSearchDdl as r, generate_postgres_ddl_logic_exports as s, generatePostgresDdl as t, planRelationalColumns as u };
|
|
238
282
|
|
|
239
|
-
//# sourceMappingURL=generate-postgres-ddl-logic-
|
|
283
|
+
//# sourceMappingURL=generate-postgres-ddl-logic-CQof4iFH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-postgres-ddl-logic-CQof4iFH.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, PolicyPlan, SchemaPlan, TablePlan } 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/** What the database a boot writes the policies into can hold. */\nexport interface PolicyPlanOptions {\n /**\n * Whether `rebase_admin` exists. Where it cannot, a policy the compiler\n * put `TO rebase_admin` is written `TO public`. Assumed when unset.\n */\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\n/** One policy as the boot writes it, before it is rendered to statements. */\ninterface WrittenPolicy {\n policy: PolicyPlan;\n /** Written `TO rebase_admin` by the compiler's choice, and not moved `TO public`. */\n adminTarget: boolean;\n /** The `TO rebase_admin_request` companion of the policy before it. */\n adminRequestTarget: boolean;\n}\n\n/** The planned tables in the order the boot writes them: collections first, then the junctions no collection declares. */\nconst policyTablesOf = (tables: readonly CompiledTable[]): TablePlan[] => {\n const plan = planOf(tables);\n return [\n ...plan.tables.filter(t => t.kind === \"collection\"),\n ...plan.tables.filter(t => t.kind === \"junction\")\n ];\n};\n\n/**\n * A table's policies as the boot writes them — the one reading both\n * {@link planTablePolicies} (as statements) and {@link planPolicyDefinitions}\n * (as data) render, so the two cannot describe different policies.\n */\nconst writtenPolicies = (table: TablePlan, options: PolicyPlanOptions): WrittenPolicy[] =>\n table.policies.flatMap((planned): WrittenPolicy[] => {\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 written: WrittenPolicy = {\n policy,\n adminTarget: policy.adminTarget === true && policy.roles[0] !== \"public\",\n adminRequestTarget: false\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 || !written.adminTarget || options.adminRequestRoleAvailable !== true) return [written];\n return [written, {\n policy: {\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 adminTarget: false,\n adminRequestTarget: true\n }];\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: PolicyPlanOptions = {}\n): TablePolicyPlan[] =>\n policyTablesOf(tables).map(table => {\n const policies: PolicyApplyPlan[] = writtenPolicies(table, options).map(({ policy, adminTarget, adminRequestTarget }) => {\n const restrictive = policy.mode === \"restrictive\";\n return {\n name: policy.name,\n adminTarget,\n ...(adminRequestTarget ? { adminRequestTarget: true as const } : {}),\n restrictive,\n statements: renderPolicyStatements(table, policy),\n ...(restrictive ? { denying: renderDenyingPolicyStatements(table, policy) } : {})\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 * One policy as a boot writes it, as data rather than DDL: the row\n * `pg_policies` holds for it once it is applied, plus the rule it came from.\n */\nexport interface PlannedPolicy {\n schema: string;\n table: string;\n name: string;\n /** `FOR …`, upper-case as `pg_policies.cmd` spells it. */\n command: \"ALL\" | \"SELECT\" | \"INSERT\" | \"UPDATE\" | \"DELETE\";\n /** PERMISSIVE policies OR together; RESTRICTIVE ones AND. */\n permissive: boolean;\n /** The `TO` list; `[\"public\"]` for every role. */\n roles: string[];\n /** The compiled `USING` clause, or null when the policy has none. */\n using: string | null;\n /** The compiled `WITH CHECK` clause, or null when the policy has none. */\n withCheck: string | null;\n /**\n * The rule it compiles from: the rule's `name`, or `#<index>` into the\n * table's rules — its declared ones first, then the ones Rebase injects.\n * An admin-request companion carries its base policy's.\n */\n ruleKey: string;\n /** Rebase added the rule (the admin baseline, the auth table's, the tenant scope), not the author. */\n injected: boolean;\n /** A junction table the planner derives for a many-to-many relation, not a declared table. */\n junction: boolean;\n}\n\nfunction policyCommandOf(operation: string): PlannedPolicy[\"command\"] {\n switch (operation) {\n case \"all\": return \"ALL\";\n case \"select\": return \"SELECT\";\n case \"insert\": return \"INSERT\";\n case \"update\": return \"UPDATE\";\n case \"delete\": return \"DELETE\";\n default: throw new Error(`Internal: a policy was planned for the operation \"${operation}\", which is not a Postgres policy command.`);\n }\n}\n\n/**\n * Every policy a boot writes for the tables and their junctions, as data:\n * the same policies, in the same order, as {@link planTablePolicies} renders\n * to statements. For a caller that reasons about the policies rather than\n * applying them — `rebase verify` reads them to find a policy Postgres would\n * refuse to expand (42P17, \"infinite recursion detected in policy\").\n */\nexport const planPolicyDefinitions = (\n tables: readonly CompiledTable[],\n options: PolicyPlanOptions = {}\n): PlannedPolicy[] =>\n policyTablesOf(tables).flatMap(table => writtenPolicies(table, options).map(({ policy }) => ({\n schema: table.schema,\n table: table.table,\n name: policy.name,\n command: policyCommandOf(policy.operation),\n permissive: policy.mode !== \"restrictive\",\n roles: [...policy.roles],\n using: policy.using,\n withCheck: policy.withCheck,\n ruleKey: policy.ruleKey,\n injected: policy.injected,\n junction: table.kind === \"junction\"\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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O;CACb,SAAS,gBAAgB,OAAO,SAAS;CACzC,YAAY,OAAO,SAAS;CAC5B,OAAO,CAAC,GAAG,OAAO,KAAK;CACvB,OAAO,OAAO;CACd,WAAW,OAAO;CAClB,SAAS,OAAO;CAChB,UAAU,OAAO;CACjB,UAAU,MAAM,SAAS;AAC7B,EAAE,CAAC;;;;;;;;;;;AAYP,IAAa,4BACT,WAC8B;CAC9B,MAAM,eAA4C,CAAC;CACnD,KAAK,MAAM,SAAS,OAAO,MAAM,CAAC,CAAC,QAAQ;EACvC,MAAM,OAAO,MAAM;EACnB,IAAI,CAAC,MAAM;EACX,MAAM,YAAY,CAAC,KAAK,QAAQ,GAAI,KAAK,QAAQ,CAAC,KAAK,MAAM,MAAM,IAAI,CAAC,CAAE;EAC1E,MAAM,UAAU,IAAI,IAAI,KAAK,OAAO,KAAI,UAAS,MAAM,MAAM,CAAC;EAC9D,KAAK,MAAM,UAAU,WACjB,KAAK,MAAM,aAAa,SACpB,aAAa,KAAK;GAAE,QAAQ,MAAM;GAAQ,OAAO,MAAM;GAAO;GAAQ;EAAU,CAAC;CAG7F;CACA,OAAO;AACX"}
|
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,13 @@ export { compareMigrationVersions, migrationVersionOf } from "./schema/migrate-b
|
|
|
39
39
|
* what the rule says rather than as a hand-written hole.
|
|
40
40
|
*/
|
|
41
41
|
export { isGeneratedPolicyName } from "./security/policy-drift.js";
|
|
42
|
+
/**
|
|
43
|
+
* Every policy a boot writes for the tables, as data — name, command, roles
|
|
44
|
+
* and clauses. `rebase verify` reads it to find a policy Postgres would refuse
|
|
45
|
+
* to expand (42P17, "infinite recursion detected in policy").
|
|
46
|
+
*/
|
|
47
|
+
export { planPolicyDefinitions } from "./schema/generate-postgres-ddl-logic.js";
|
|
48
|
+
export type { PlannedPolicy, PolicyPlanOptions } from "./schema/generate-postgres-ddl-logic.js";
|
|
42
49
|
/**
|
|
43
50
|
* Everything the schema pipeline emits for a collection set, as text — the
|
|
44
51
|
* plan-golden corpus's renderer, and how `rebase migrate collections-to-tables`
|
package/dist/index.es.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
__createRequire(import.meta.url);
|
|
3
3
|
import { a as createPostgresDatabaseConnection, c as guardPoolAgainstDirtyRelease, d as poolMaxCeiling, i as createDirectDatabaseConnection, o as createReadReplicaConnection, s as defaultPoolTimeouts, t as cappedPoolMax, u as pinSearchPath } from "./connection-C1zXTPJq.js";
|
|
4
|
-
import { $ as PostgresBackendDriver, B as passwordResetTokens, C as PostgresChannelBus, D as frameByteLength, E as MemoryChannelBus, F as magicLinkTokensRelations, G as refreshTokensRelations, H as recoveryCodes, I as mfaChallenges, J as users, K as userIdentities, L as mfaChallengesRelations, M as appConfig, N as createAuthSchema, O as isChannelBusInstance, P as magicLinkTokens, Q as CONNECTION_OWNER, R as mfaFactors, S as PG_NOTIFY_MAX_PAYLOAD_BYTES, T as parseChannelBusPayload, U as recoveryCodesRelations, V as passwordResetTokensRelations, W as refreshTokens, X as usersSchema, Y as usersRelations, Z as AuthenticatedPostgresBackendDriver, _ as refetchConcurrencyFor, a as openPostgresDriver, b as CHANNEL_BUS_NOTIFY_CHANNEL, c as PostgresTableRegistry, d as PostgresRealtimeProvider, dt as PostgresConditionBuilder, et as RoleSwitchUnavailableError, f as RealtimeService, ft as configureUnknownFilterFields, g as parseRealtimeTuning, gt as listedColumnKeys, h as parseMaxSubscriptionsPerSocket, ht as joinColumn, i as isScaffoldedLocalDatabase, it as sqlRoleRanAs, l as DEFAULT_MAX_SUBSCRIPTIONS_PER_SOCKET, m as parseMaxSocketsPerUser, mt as getUnknownFilterFieldsMode, n as createPostgresBootstrapper, nt as effectiveSqlRole, o as postgresDriverConfigFromEnv, p as packEntityChanges, pt as escapeLikePattern, q as userIdentitiesRelations, r as describeSchemaDriftCause, rt as isRoleSwitchingOptedOut, s as resolveSourceUrls, t as openRebase, tt as branchParentDatabase, u as DEFAULT_RECOUNT_MIN_ROWS, ut as DrizzleConditionBuilder, v as createChannelBus, w as parseChannelBusFrame, x as DEFAULT_BATCH_WINDOW_MS, y as resolveChannelBusSetting, z as mfaFactorsRelations } from "./open-rebase-
|
|
5
|
-
import { n as assertNoCollectionsFlag } from "./cli-schema-dir-
|
|
6
|
-
import { a as reopenedDatabasesNotice, i as reopenClosedDatabases, r as BranchingUnsupportedError, t as BranchService } from "./BranchService-
|
|
4
|
+
import { $ as PostgresBackendDriver, B as passwordResetTokens, C as PostgresChannelBus, D as frameByteLength, E as MemoryChannelBus, F as magicLinkTokensRelations, G as refreshTokensRelations, H as recoveryCodes, I as mfaChallenges, J as users, K as userIdentities, L as mfaChallengesRelations, M as appConfig, N as createAuthSchema, O as isChannelBusInstance, P as magicLinkTokens, Q as CONNECTION_OWNER, R as mfaFactors, S as PG_NOTIFY_MAX_PAYLOAD_BYTES, T as parseChannelBusPayload, U as recoveryCodesRelations, V as passwordResetTokensRelations, W as refreshTokens, X as usersSchema, Y as usersRelations, Z as AuthenticatedPostgresBackendDriver, _ as refetchConcurrencyFor, a as openPostgresDriver, b as CHANNEL_BUS_NOTIFY_CHANNEL, c as PostgresTableRegistry, d as PostgresRealtimeProvider, dt as PostgresConditionBuilder, et as RoleSwitchUnavailableError, f as RealtimeService, ft as configureUnknownFilterFields, g as parseRealtimeTuning, gt as listedColumnKeys, h as parseMaxSubscriptionsPerSocket, ht as joinColumn, i as isScaffoldedLocalDatabase, it as sqlRoleRanAs, l as DEFAULT_MAX_SUBSCRIPTIONS_PER_SOCKET, m as parseMaxSocketsPerUser, mt as getUnknownFilterFieldsMode, n as createPostgresBootstrapper, nt as effectiveSqlRole, o as postgresDriverConfigFromEnv, p as packEntityChanges, pt as escapeLikePattern, q as userIdentitiesRelations, r as describeSchemaDriftCause, rt as isRoleSwitchingOptedOut, s as resolveSourceUrls, t as openRebase, tt as branchParentDatabase, u as DEFAULT_RECOUNT_MIN_ROWS, ut as DrizzleConditionBuilder, v as createChannelBus, w as parseChannelBusFrame, x as DEFAULT_BATCH_WINDOW_MS, y as resolveChannelBusSetting, z as mfaFactorsRelations } from "./open-rebase-B2mAA7UE.js";
|
|
5
|
+
import { n as assertNoCollectionsFlag } from "./cli-schema-dir-DuZIsF2e.js";
|
|
6
|
+
import { a as reopenedDatabasesNotice, i as reopenClosedDatabases, r as BranchingUnsupportedError, t as BranchService } from "./BranchService-C8LtpMho.js";
|
|
7
7
|
import { n as resolveRlsSettings, r as rlsConfigFromEnv, t as cliRlsSettings } from "./rls-settings-CmGK2U0a.js";
|
|
8
|
-
import { _ as recordRequestRoles, c as ensureAppRole, f as findOtherRoleMembers, g as readRecordedRequestRoles, l as ensureAppRoleGrants, s as detectConnectionPosture, t as REBASE_USER_ROLE } from "./rls-enforcement-
|
|
8
|
+
import { _ as recordRequestRoles, c as ensureAppRole, f as findOtherRoleMembers, g as readRecordedRequestRoles, l as ensureAppRoleGrants, s as detectConnectionPosture, t as REBASE_USER_ROLE } from "./rls-enforcement-Cwh5SJRx.js";
|
|
9
9
|
import { n as planSchema } from "./plan-schema-Hbtjhge3.js";
|
|
10
10
|
import { t as generateSchema } from "./generate-drizzle-schema-logic-DL7R1rAF.js";
|
|
11
|
-
import { a as generatePostgresVectorDdl, c as planJunctionTables, d as
|
|
12
|
-
import { a as migrationVersionOf, c as isDriverDbSubcommand, g as assertKnownFlags, l as backupActionOf, n as compareMigrationVersions, u as assertKnownBranchFlags } from "./migrate-baseline-
|
|
13
|
-
import { r as planTableSchemaEnsure } from "./ensure-tables-
|
|
11
|
+
import { a as generatePostgresVectorDdl, c as planJunctionTables, d as planTablePolicies, f as searchExcludePatterns, i as generatePostgresTriggersDdl, l as planPolicyDefinitions, m as vectorExcludePatterns, n as generatePostgresPoliciesDdl, o as generatePostgresViewsDdl, p as triggerExcludePatterns, r as generatePostgresSearchDdl, t as generatePostgresDdl, u as planRelationalColumns } from "./generate-postgres-ddl-logic-CQof4iFH.js";
|
|
12
|
+
import { a as migrationVersionOf, c as isDriverDbSubcommand, g as assertKnownFlags, l as backupActionOf, n as compareMigrationVersions, u as assertKnownBranchFlags } from "./migrate-baseline-DnMlSDup.js";
|
|
13
|
+
import { r as planTableSchemaEnsure } from "./ensure-tables-B3Kh2RwT.js";
|
|
14
14
|
import { a as mergeDatabaseBranch, i as diffDatabaseBranch, n as DEFAULT_BRANCH_DIFF_SAMPLE_LIMIT, t as DEFAULT_BRANCH_DIFF_MAX_ROWS } from "./branch-diff-CxE4VlxT.js";
|
|
15
15
|
import { t as DatabasePoolManager } from "./databasePoolManager-DIjzlTK4.js";
|
|
16
|
-
import { t as main } from "./generate-drizzle-schema-
|
|
17
|
-
import { a as createPostgresWebSocket, i as TOO_MANY_SOCKETS_CLOSE_CODE, n as PUBLIC_TYPES, o as isSocketRealtimeService, r as SESSION_ENDED_CLOSE_CODE, s as socketRealtimeMissing, t as ADMIN_PLANE_TYPES } from "./websocket-
|
|
18
|
-
import { A as buildBackupFilename, B as diagnoseRowSecurityDumpFailure, C as restoreDumpReplacing, D as resolvePgBinary, E as pgToolVariable, F as buildPgRestoreScriptArgs, G as parseBackupTimestamp, H as isBackupOfDatabase, I as buildPsqlScriptArgs, J as parsePgToolMajor, K as parseDbNameFromUrl, L as buildRowSecurityPgOptions, M as buildPgDumpallGlobalsArgs, N as buildPgRestoreArgs, O as selectBackupsToPrune, P as buildPgRestoreListArgs, Q as withDatabaseName, R as checkToolServerCompatibility, S as restoreDump, T as validateDump, U as joinStorageKey, V as globalsFileForDump, W as parseBackupDestination, X as serverVersionNumToMajor, Y as resolveConnectionString, Z as splitGlobalsStatements, _ as listBackups, a as BackupToolError, b as readDumpObjects, d as detectToolMajor, f as discardPartialDump, g as getServerVersionMajor, h as findRestoreConflicts, i as parseRestoreLine, j as buildPgDumpArgs, k as CLEAN_LOCK_TIMEOUT, l as createDump, m as findCleanExtras, n as parseBackupLine, o as CleanRestoreFailed, p as ensureDatabaseExists, q as parseDumpObjects, r as parseBackupsListLine, s as applyGlobals, u as describeUnreadableDump, v as preflight, w as uploadBackup, x as resetSharedSession, y as pruneBackups, z as cleanRestorePrelude } from "./backup-cli-
|
|
19
|
-
import { n as parseRequestRoleLine, t as parseProvisionLine } from "./request-role-cli-
|
|
20
|
-
import { a as isGeneratedPolicyName } from "./policy-drift-
|
|
16
|
+
import { t as main } from "./generate-drizzle-schema-B-Mkf8UI.js";
|
|
17
|
+
import { a as createPostgresWebSocket, i as TOO_MANY_SOCKETS_CLOSE_CODE, n as PUBLIC_TYPES, o as isSocketRealtimeService, r as SESSION_ENDED_CLOSE_CODE, s as socketRealtimeMissing, t as ADMIN_PLANE_TYPES } from "./websocket-CSVNOYHC.js";
|
|
18
|
+
import { A as buildBackupFilename, B as diagnoseRowSecurityDumpFailure, C as restoreDumpReplacing, D as resolvePgBinary, E as pgToolVariable, F as buildPgRestoreScriptArgs, G as parseBackupTimestamp, H as isBackupOfDatabase, I as buildPsqlScriptArgs, J as parsePgToolMajor, K as parseDbNameFromUrl, L as buildRowSecurityPgOptions, M as buildPgDumpallGlobalsArgs, N as buildPgRestoreArgs, O as selectBackupsToPrune, P as buildPgRestoreListArgs, Q as withDatabaseName, R as checkToolServerCompatibility, S as restoreDump, T as validateDump, U as joinStorageKey, V as globalsFileForDump, W as parseBackupDestination, X as serverVersionNumToMajor, Y as resolveConnectionString, Z as splitGlobalsStatements, _ as listBackups, a as BackupToolError, b as readDumpObjects, d as detectToolMajor, f as discardPartialDump, g as getServerVersionMajor, h as findRestoreConflicts, i as parseRestoreLine, j as buildPgDumpArgs, k as CLEAN_LOCK_TIMEOUT, l as createDump, m as findCleanExtras, n as parseBackupLine, o as CleanRestoreFailed, p as ensureDatabaseExists, q as parseDumpObjects, r as parseBackupsListLine, s as applyGlobals, u as describeUnreadableDump, v as preflight, w as uploadBackup, x as resetSharedSession, y as pruneBackups, z as cleanRestorePrelude } from "./backup-cli-DtV6n3oB.js";
|
|
19
|
+
import { n as parseRequestRoleLine, t as parseProvisionLine } from "./request-role-cli-D9yWoeSl.js";
|
|
20
|
+
import { a as isGeneratedPolicyName } from "./policy-drift-C9xRcbsU.js";
|
|
21
21
|
import { logger } from "@rebasepro/server";
|
|
22
22
|
import { resetDeclaredResources } from "@rebasepro/types";
|
|
23
23
|
import { sortTablesBySlug } from "@rebasepro/common";
|
|
@@ -106,7 +106,7 @@ function createBackupCron(config) {
|
|
|
106
106
|
enabled: config.enabled ?? true,
|
|
107
107
|
timeoutSeconds: 3600,
|
|
108
108
|
async handler({ log }) {
|
|
109
|
-
const { createDump, discardPartialDump, pruneBackups, uploadBackup, validateDump } = await import("./backup-cli-
|
|
109
|
+
const { createDump, discardPartialDump, pruneBackups, uploadBackup, validateDump } = await import("./backup-cli-DtV6n3oB.js").then((n) => n.c);
|
|
110
110
|
const { destination } = config;
|
|
111
111
|
if (destination.kind !== "local" && !config.storage) throw new Error(`Backup destination is ${destination.kind} but no storage controller was provided. Pass the backend's configured StorageController to createBackupCron({ storage }).`);
|
|
112
112
|
log(`Starting backup of "${dbName}"…`);
|
|
@@ -661,6 +661,6 @@ function renderSchemaOutputs(tables, options = {}) {
|
|
|
661
661
|
});
|
|
662
662
|
}
|
|
663
663
|
//#endregion
|
|
664
|
-
export { ADMIN_PLANE_TYPES, AuthenticatedPostgresBackendDriver, BackupToolError, BranchService, BranchingUnsupportedError, CHANNEL_BUS_NOTIFY_CHANNEL, CLEAN_LOCK_TIMEOUT, CONNECTION_OWNER, CleanRestoreFailed, DEFAULT_BATCH_WINDOW_MS, DEFAULT_BRANCH_DIFF_MAX_ROWS, DEFAULT_BRANCH_DIFF_SAMPLE_LIMIT, DEFAULT_MAX_SUBSCRIPTIONS_PER_SOCKET, DEFAULT_RECOUNT_MIN_ROWS, DatabasePoolManager, DrizzleConditionBuilder, MemoryChannelBus, PG_NOTIFY_MAX_PAYLOAD_BYTES, PLANNER_ENV_VARIABLES, PUBLIC_TYPES, PostgresBackendDriver, PostgresChannelBus, PostgresConditionBuilder, PostgresRealtimeProvider, PostgresTableRegistry, REBASE_USER_ROLE, RealtimeService, RoleSwitchUnavailableError, SESSION_ENDED_CLOSE_CODE, TOO_MANY_SOCKETS_CLOSE_CODE, appConfig, applyGlobals, assertDbCommandLine, backupCronConfigFromEnv, branchParentDatabase, buildBackupFilename, buildPgDumpArgs, buildPgDumpallGlobalsArgs, buildPgRestoreArgs, buildPgRestoreListArgs, buildPgRestoreScriptArgs, buildPsqlScriptArgs, buildRowSecurityPgOptions, cappedPoolMax, checkToolServerCompatibility, cleanRestorePrelude, cliRlsSettings, compareMigrationVersions, configureUnknownFilterFields, createAuthSchema, createBackupCron, createChannelBus, createDirectDatabaseConnection, createDump, createPostgresAdapter, createPostgresBootstrapper, createPostgresDatabaseConnection, createPostgresWebSocket, createReadReplicaConnection, defaultPoolTimeouts, describeSchemaDriftCause, describeUnreadableDump, detectConnectionPosture, detectToolMajor, diagnoseRowSecurityDumpFailure, diffDatabaseBranch, discardPartialDump, effectiveSqlRole, ensureAppRole, ensureAppRoleGrants, ensureDatabaseExists, escapeLikePattern, findCleanExtras, findOtherRoleMembers, findRestoreConflicts, findUnmigratedSchema, frameByteLength, generateSchema, getServerVersionMajor, getUnknownFilterFieldsMode, globalsFileForDump, guardPoolAgainstDirtyRelease, isBackupOfDatabase, isChannelBusInstance, isGeneratedPolicyName, isRoleSwitchingOptedOut, isScaffoldedLocalDatabase, isSocketRealtimeService, joinColumn, joinStorageKey, listBackups, listedColumnKeys, magicLinkTokens, magicLinkTokensRelations, main, mergeDatabaseBranch, mfaChallenges, mfaChallengesRelations, mfaFactors, mfaFactorsRelations, migrationVersionOf, openPostgresDriver, openRebase, packEntityChanges, parseBackupDestination, parseBackupTimestamp, parseChannelBusFrame, parseChannelBusPayload, parseDbNameFromUrl, parseDumpObjects, parseMaxSocketsPerUser, parseMaxSubscriptionsPerSocket, parsePgToolMajor, parseRealtimeTuning, passwordResetTokens, passwordResetTokensRelations, pinSearchPath, poolMaxCeiling, postgresDriverConfigFromEnv, preflight, pruneBackups, readDumpObjects, readRecordedRequestRoles, recordRequestRoles, recoveryCodes, recoveryCodesRelations, refetchConcurrencyFor, refreshTokens, refreshTokensRelations, renderSchemaOutputs, reopenClosedDatabases, reopenedDatabasesNotice, resetSharedSession, resolveChannelBusSetting, resolveConnectionString, resolvePgBinary, resolveRlsSettings, resolveSourceUrls, restoreDump, restoreDumpReplacing, rlsConfigFromEnv, selectBackupsToPrune, serverVersionNumToMajor, socketRealtimeMissing, splitGlobalsStatements, sqlRoleRanAs, toStableJson, uploadBackup, userIdentities, userIdentitiesRelations, users, usersRelations, usersSchema, validateDump, withDatabaseName, withPinnedPlannerWorld };
|
|
664
|
+
export { ADMIN_PLANE_TYPES, AuthenticatedPostgresBackendDriver, BackupToolError, BranchService, BranchingUnsupportedError, CHANNEL_BUS_NOTIFY_CHANNEL, CLEAN_LOCK_TIMEOUT, CONNECTION_OWNER, CleanRestoreFailed, DEFAULT_BATCH_WINDOW_MS, DEFAULT_BRANCH_DIFF_MAX_ROWS, DEFAULT_BRANCH_DIFF_SAMPLE_LIMIT, DEFAULT_MAX_SUBSCRIPTIONS_PER_SOCKET, DEFAULT_RECOUNT_MIN_ROWS, DatabasePoolManager, DrizzleConditionBuilder, MemoryChannelBus, PG_NOTIFY_MAX_PAYLOAD_BYTES, PLANNER_ENV_VARIABLES, PUBLIC_TYPES, PostgresBackendDriver, PostgresChannelBus, PostgresConditionBuilder, PostgresRealtimeProvider, PostgresTableRegistry, REBASE_USER_ROLE, RealtimeService, RoleSwitchUnavailableError, SESSION_ENDED_CLOSE_CODE, TOO_MANY_SOCKETS_CLOSE_CODE, appConfig, applyGlobals, assertDbCommandLine, backupCronConfigFromEnv, branchParentDatabase, buildBackupFilename, buildPgDumpArgs, buildPgDumpallGlobalsArgs, buildPgRestoreArgs, buildPgRestoreListArgs, buildPgRestoreScriptArgs, buildPsqlScriptArgs, buildRowSecurityPgOptions, cappedPoolMax, checkToolServerCompatibility, cleanRestorePrelude, cliRlsSettings, compareMigrationVersions, configureUnknownFilterFields, createAuthSchema, createBackupCron, createChannelBus, createDirectDatabaseConnection, createDump, createPostgresAdapter, createPostgresBootstrapper, createPostgresDatabaseConnection, createPostgresWebSocket, createReadReplicaConnection, defaultPoolTimeouts, describeSchemaDriftCause, describeUnreadableDump, detectConnectionPosture, detectToolMajor, diagnoseRowSecurityDumpFailure, diffDatabaseBranch, discardPartialDump, effectiveSqlRole, ensureAppRole, ensureAppRoleGrants, ensureDatabaseExists, escapeLikePattern, findCleanExtras, findOtherRoleMembers, findRestoreConflicts, findUnmigratedSchema, frameByteLength, generateSchema, getServerVersionMajor, getUnknownFilterFieldsMode, globalsFileForDump, guardPoolAgainstDirtyRelease, isBackupOfDatabase, isChannelBusInstance, isGeneratedPolicyName, isRoleSwitchingOptedOut, isScaffoldedLocalDatabase, isSocketRealtimeService, joinColumn, joinStorageKey, listBackups, listedColumnKeys, magicLinkTokens, magicLinkTokensRelations, main, mergeDatabaseBranch, mfaChallenges, mfaChallengesRelations, mfaFactors, mfaFactorsRelations, migrationVersionOf, openPostgresDriver, openRebase, packEntityChanges, parseBackupDestination, parseBackupTimestamp, parseChannelBusFrame, parseChannelBusPayload, parseDbNameFromUrl, parseDumpObjects, parseMaxSocketsPerUser, parseMaxSubscriptionsPerSocket, parsePgToolMajor, parseRealtimeTuning, passwordResetTokens, passwordResetTokensRelations, pinSearchPath, planPolicyDefinitions, poolMaxCeiling, postgresDriverConfigFromEnv, preflight, pruneBackups, readDumpObjects, readRecordedRequestRoles, recordRequestRoles, recoveryCodes, recoveryCodesRelations, refetchConcurrencyFor, refreshTokens, refreshTokensRelations, renderSchemaOutputs, reopenClosedDatabases, reopenedDatabasesNotice, resetSharedSession, resolveChannelBusSetting, resolveConnectionString, resolvePgBinary, resolveRlsSettings, resolveSourceUrls, restoreDump, restoreDumpReplacing, rlsConfigFromEnv, selectBackupsToPrune, serverVersionNumToMajor, socketRealtimeMissing, splitGlobalsStatements, sqlRoleRanAs, toStableJson, uploadBackup, userIdentities, userIdentitiesRelations, users, usersRelations, usersSchema, validateDump, withDatabaseName, withPinnedPlannerWorld };
|
|
665
665
|
|
|
666
666
|
//# sourceMappingURL=index.es.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
__createRequire(import.meta.url);
|
|
3
3
|
import { a as __require, n as require_arg, o as __toESM, r as __commonJSMin } from "./cli-prompt-DXG0yk-h.js";
|
|
4
|
-
import { G as withAppClient, ot as redactConnectionPasswords } from "./cli-schema-dir-
|
|
4
|
+
import { G as withAppClient, ot as redactConnectionPasswords } from "./cli-schema-dir-DuZIsF2e.js";
|
|
5
5
|
import { d as isRebaseIndexName, p as renderPredicate } from "./source-VxbrQojV.js";
|
|
6
6
|
import { suggestNearMiss } from "@rebasepro/utils";
|
|
7
7
|
import process$1, { execArgv, execPath, hrtime, platform } from "node:process";
|
|
@@ -6660,6 +6660,13 @@ var BRANCH_ACTION_FLAGS = {
|
|
|
6660
6660
|
"--yes": Boolean,
|
|
6661
6661
|
"-y": "--yes"
|
|
6662
6662
|
},
|
|
6663
|
+
merge: {
|
|
6664
|
+
"--on-conflict": String,
|
|
6665
|
+
"--skip-blocked": Boolean,
|
|
6666
|
+
"--sample-limit": Number,
|
|
6667
|
+
"--yes": Boolean,
|
|
6668
|
+
"-y": "--yes"
|
|
6669
|
+
},
|
|
6663
6670
|
prune: {
|
|
6664
6671
|
"--older-than": String,
|
|
6665
6672
|
"--include-dev-diff": Boolean,
|
|
@@ -6933,4 +6940,4 @@ async function latestRecordedMigration(databaseUrl) {
|
|
|
6933
6940
|
//#endregion
|
|
6934
6941
|
export { declaredIndexesIfNotExists as C, readIndexShapes as E, execa as S, planIndexAdoptions as T, closestWord as _, migrationVersionOf as a, resolveDriverSwitches as b, isDriverDbSubcommand as c, branchNameIn as d, branchSourceIn as f, assertKnownFlags as g, RELAYED_FLAGS as h, latestRecordedMigration as i, backupActionOf as l, unexpectedBranchArgs as m, compareMigrationVersions as n, planBaseline as o, resolveBranchSwitches as p, describeBaselinePlan as r, DRIVER_DB_SUBCOMMANDS as s, baselineVersionProblem as t, assertKnownBranchFlags as u, parseCommandFlags as v, indexAdoptionStatement as w, schemaDirIn as x, parseDriverLine as y };
|
|
6935
6942
|
|
|
6936
|
-
//# sourceMappingURL=migrate-baseline-
|
|
6943
|
+
//# sourceMappingURL=migrate-baseline-DnMlSDup.js.map
|