@rebasepro/server-postgres 0.30.1 → 0.31.0-canary.g59cd6fd
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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-postgres-ddl.js","names":[],"sources":["../../src/schema/generate-postgres-ddl.ts","../../src/schema/bin/generate-postgres-ddl.ts"],"sourcesContent":["import path from \"path\";\nimport { out } from \"../cli-output\";\nimport { writePostgresDdl } from \"./generate-files\";\n\n/**\n * The generator as its own process — what `--watch` runs, because a watch has\n * to re-import the
|
|
1
|
+
{"version":3,"file":"generate-postgres-ddl.js","names":[],"sources":["../../src/schema/generate-postgres-ddl.ts","../../src/schema/bin/generate-postgres-ddl.ts"],"sourcesContent":["import path from \"path\";\nimport { out } from \"../cli-output\";\nimport { writePostgresDdl } from \"./generate-files\";\n\n/**\n * The generator as its own process — what `--watch` runs, because a watch has\n * to re-import the tables on every save and Node's module cache would\n * serve it the first version forever. One-shot generation runs in the driver's\n * own process instead; see `generate-files.ts`.\n */\nconst runGeneration = async (schemaDir?: string, outputPath?: string) => {\n if (!schemaDir) {\n throw new Error(\"No schema directory provided.\");\n }\n try {\n await writePostgresDdl({ schemaDir: path.resolve(schemaDir), outputPath });\n } catch (error) {\n // A caller that reads nothing but this process's exit code must not\n // see 0 after an error was printed — see `writePostgresDdl`.\n process.exitCode = 1;\n throw error;\n }\n};\n\nexport const main = async () => {\n const schemaDirArg = process.argv.find(arg => arg.startsWith(\"--schema-dir=\"));\n const schemaDir = schemaDirArg ? schemaDirArg.split(\"=\")[1] : process.argv[2];\n\n const outputPathArg = process.argv.find(arg => arg.startsWith(\"--output=\"));\n const outputPath = outputPathArg ? outputPathArg.split(\"=\")[1] : undefined;\n\n const watch = process.argv.includes(\"--watch\");\n\n if (!schemaDir) {\n out(\"Usage: ts-node generate-postgres-ddl.ts --schema-dir=<backend/schema> [--output=<path-to-output-file>] [--watch]\");\n return;\n }\n\n const resolvedPath = path.resolve(process.cwd(), schemaDir);\n const resolvedOutputPath = outputPath ? path.resolve(process.cwd(), outputPath) : undefined;\n\n if (watch) {\n out(`Watching for changes in ${resolvedPath}...`);\n // Imported here rather than at module scope, and this is not a style\n // choice: chokidar is needed only by `--watch`, which is a\n // schema-authoring path that never runs inside the runtime image. A\n // top-level import puts it on the boot path of the published driver\n // bundle, and the image installs a hand-listed set of runtime\n // dependencies that does not include it — so the whole driver failed to\n // load with \"Cannot find package 'chokidar'\", and every self-hosted\n // container answered 500 with a stack trace about a file watcher.\n //\n // Same reasoning the image already applies to @ariga/atlas: an\n // authoring-only dependency does not belong on a boot path.\n const { default: chokidar } = await import(\"chokidar\");\n const watcher = chokidar.watch(resolvedPath, {\n persistent: true,\n ignoreInitial: false\n });\n\n watcher.on(\"all\", (event, filePath) => {\n out(`[${event}] ${filePath}. Regenerating DDL schema...`);\n // A watch session outlives a bad edit: the cause is already on\n // stderr, and the next save is the retry. Only the one-shot run\n // below turns a failure into an exit code.\n void runGeneration(resolvedPath, resolvedOutputPath).catch(() => undefined);\n });\n } else {\n await runGeneration(resolvedPath, resolvedOutputPath);\n }\n};\n\n// This check ensures the script only runs when executed directly\nif (import.meta.url.endsWith(process.argv[1])) {\n // `runGeneration` has already printed the cause and set the exit code; the\n // handler is here so the last thing on the terminal is that message rather\n // than Node's unhandled-rejection dump of the same stack.\n main().catch(() => {\n process.exitCode = 1;\n });\n}\n","/**\n * The built entry point for `generate-postgres-ddl`.\n *\n * `generate-postgres-ddl.ts` guards its own `main()` with\n * `import.meta.url.endsWith(process.argv[1])`, because `src/index.ts` re-exports\n * the module and importing the driver must not run the generator. That guard is\n * correct when the file IS the process entry — which is how it runs from source\n * under tsx — and silently false once the module is bundled: the executed file\n * is a stub, the code lives in a shared chunk, and the chunk's `import.meta.url`\n * is not the stub's path. The generator then did nothing, exited 0, and the\n * caller reported success over an unwritten schema.\n *\n * So the built path gets an entry that says what it means.\n */\nimport { main } from \"../generate-postgres-ddl\";\n\nmain().catch(() => {\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;;;;;;;AAUA,IAAM,gBAAgB,OAAO,WAAoB,eAAwB;CACrE,IAAI,CAAC,WACD,MAAM,IAAI,MAAM,+BAA+B;CAEnD,IAAI;EACA,MAAM,iBAAiB;GAAE,WAAW,KAAK,QAAQ,SAAS;GAAG;EAAW,CAAC;CAC7E,SAAS,OAAO;EAGZ,QAAQ,WAAW;EACnB,MAAM;CACV;AACJ;AAEA,IAAa,OAAO,YAAY;CAC5B,MAAM,eAAe,QAAQ,KAAK,MAAK,QAAO,IAAI,WAAW,eAAe,CAAC;CAC7E,MAAM,YAAY,eAAe,aAAa,MAAM,GAAG,CAAC,CAAC,KAAK,QAAQ,KAAK;CAE3E,MAAM,gBAAgB,QAAQ,KAAK,MAAK,QAAO,IAAI,WAAW,WAAW,CAAC;CAC1E,MAAM,aAAa,gBAAgB,cAAc,MAAM,GAAG,CAAC,CAAC,KAAK,KAAA;CAEjE,MAAM,QAAQ,QAAQ,KAAK,SAAS,SAAS;CAE7C,IAAI,CAAC,WAAW;EACZ,IAAI,kHAAkH;EACtH;CACJ;CAEA,MAAM,eAAe,KAAK,QAAQ,QAAQ,IAAI,GAAG,SAAS;CAC1D,MAAM,qBAAqB,aAAa,KAAK,QAAQ,QAAQ,IAAI,GAAG,UAAU,IAAI,KAAA;CAElF,IAAI,OAAO;EACP,IAAI,2BAA2B,aAAa,IAAI;EAYhD,MAAM,EAAE,SAAS,aAAa,MAAM,OAAO;EAM3C,SALyB,MAAM,cAAc;GACzC,YAAY;GACZ,eAAe;EACnB,CAEA,CAAA,CAAQ,GAAG,QAAQ,OAAO,aAAa;GACnC,IAAI,IAAI,MAAM,IAAI,SAAS,6BAA6B;GAIxD,cAAmB,cAAc,kBAAkB,CAAC,CAAC,YAAY,KAAA,CAAS;EAC9E,CAAC;CACL,OACI,MAAM,cAAc,cAAc,kBAAkB;AAE5D;AAGA,IAAI,OAAO,KAAK,IAAI,SAAS,QAAQ,KAAK,EAAE,GAIxC,KAAK,CAAC,CAAC,YAAY;CACf,QAAQ,WAAW;AACvB,CAAC;;;;;;;;;;;;;;;;;AC/DL,KAAK,CAAC,CAAC,YAAY;CACf,QAAQ,WAAW;AACvB,CAAC"}
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
* migration this module cannot make valid would be worse than handing the
|
|
38
38
|
* statements to a caller who knows which kind of project it is.
|
|
39
39
|
*/
|
|
40
|
-
import { type
|
|
41
|
-
import { type EnsureOptions, type ExistingSchema, type WithheldConstraint } from "./ensure-
|
|
42
|
-
import { type ClassifiedChanges } from "./classify-change.js";
|
|
40
|
+
import { type CompiledTable, type SchemaCommitPaths } from "@rebasepro/types";
|
|
41
|
+
import { type EnsureOptions, type ExistingSchema, type WithheldConstraint } from "./ensure-tables.js";
|
|
42
|
+
import { type ClassifiedChanges, type SchemaFacts } from "./classify-change.js";
|
|
43
43
|
/**
|
|
44
44
|
* Re-exported from the shared kernel. `@rebasepro/server` derives these for a
|
|
45
45
|
* project in a subdirectory and cannot import a driver to do it, so the shape
|
|
@@ -51,10 +51,10 @@ export interface SchemaCommitFile {
|
|
|
51
51
|
contents: string;
|
|
52
52
|
}
|
|
53
53
|
export interface SchemaCommitInput {
|
|
54
|
-
/** What the running database was built from. */
|
|
55
|
-
before:
|
|
56
|
-
/** What the editor is proposing. */
|
|
57
|
-
after:
|
|
54
|
+
/** What the running database was built from, compiled. */
|
|
55
|
+
before: readonly CompiledTable[];
|
|
56
|
+
/** What the editor is proposing, compiled (`compileSchemaDefs` over the edited definitions). */
|
|
57
|
+
after: readonly CompiledTable[];
|
|
58
58
|
/**
|
|
59
59
|
* Files the caller has already produced — in practice the rewritten
|
|
60
60
|
* collection source from the AST editor. Carried through unchanged so the
|
|
@@ -128,7 +128,7 @@ export declare class SchemaCommitError extends Error {
|
|
|
128
128
|
* generating a commit for inspection, and the tests that compare two plans —
|
|
129
129
|
* where there is no database to describe.
|
|
130
130
|
*/
|
|
131
|
-
export declare function additiveStatements(before:
|
|
131
|
+
export declare function additiveStatements(before: readonly CompiledTable[], after: readonly CompiledTable[], existing?: ExistingSchema, options?: EnsureOptions): string[];
|
|
132
132
|
/**
|
|
133
133
|
* The commit of an "Edit source only": what changed in the source, and what
|
|
134
134
|
* the database keeps — `chore(schema): remove sku from products (source only —
|
|
@@ -146,3 +146,8 @@ export declare function commitMessage(classified: ClassifiedChanges): string;
|
|
|
146
146
|
* exactly which change was the problem.
|
|
147
147
|
*/
|
|
148
148
|
export declare function generateSchemaCommit(input: SchemaCommitInput): Promise<SchemaCommit>;
|
|
149
|
+
/**
|
|
150
|
+
* Classify an edit as the live editor hands it: both sides compiled
|
|
151
|
+
* ({@link classifyTableChanges}).
|
|
152
|
+
*/
|
|
153
|
+
export declare function classifyEditedTables(before: readonly CompiledTable[], after: readonly CompiledTable[], facts?: SchemaFacts): ClassifiedChanges;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TableDescriptor } from "@rebasepro/types";
|
|
2
2
|
import type { TableMeta } from "./introspect-db-logic.js";
|
|
3
3
|
import type { Queryable } from "./introspect-runtime.js";
|
|
4
4
|
export type SchemaDifferenceKind = "missing-table" | "missing-column" | "extra-column" | "type" | "nullability";
|
|
@@ -6,12 +6,12 @@ export interface SchemaDifference {
|
|
|
6
6
|
kind: SchemaDifferenceKind;
|
|
7
7
|
/** Bare table name, as both sides spell it. */
|
|
8
8
|
table: string;
|
|
9
|
-
/** The
|
|
10
|
-
|
|
9
|
+
/** The slug of the declared table backed by that table, when one is. */
|
|
10
|
+
slug?: string;
|
|
11
11
|
/** The column, in database terms. */
|
|
12
12
|
column?: string;
|
|
13
|
-
/** The
|
|
14
|
-
|
|
13
|
+
/** The key it is served under, where the table declares it. */
|
|
14
|
+
key?: string;
|
|
15
15
|
/** What `schema.generated.ts` says. */
|
|
16
16
|
generated?: string;
|
|
17
17
|
/** What the database says. */
|
|
@@ -35,15 +35,15 @@ export declare function typeFamily(sqlType: string | undefined): string;
|
|
|
35
35
|
* One-directional in one respect only: a table the module has and the database
|
|
36
36
|
* does not is reported (that is the stale-file case), while a table the database
|
|
37
37
|
* has and the module does not is left alone — a database may hold anything, and
|
|
38
|
-
* the
|
|
38
|
+
* the declared-tables-vs-file question is `generated-schema-staleness`'s.
|
|
39
39
|
*/
|
|
40
40
|
export declare function diffGeneratedSchemaAgainstCatalogue(options: {
|
|
41
41
|
/** The `tables` export of the bundle's schema module. */
|
|
42
42
|
generated: Record<string, unknown> | undefined;
|
|
43
43
|
/** What was introspected for this data source, keyed by bare table name. */
|
|
44
44
|
catalogue: Map<string, TableMeta>;
|
|
45
|
-
/**
|
|
46
|
-
|
|
45
|
+
/** The declared tables of this source, so a column can be named by its key. */
|
|
46
|
+
tables: readonly TableDescriptor[];
|
|
47
47
|
}): SchemaDifference[];
|
|
48
48
|
/**
|
|
49
49
|
* Boot's drift question, asked of a database from outside a boot.
|
|
@@ -56,21 +56,21 @@ export declare function diffGeneratedSchemaAgainstCatalogue(options: {
|
|
|
56
56
|
* doctor compared on its own terms, it answered "In sync" over a NOT NULL and a
|
|
57
57
|
* left-behind column that boot had just warned about.
|
|
58
58
|
*
|
|
59
|
-
* `
|
|
59
|
+
* `tables` are the data source's own, as boot filters them.
|
|
60
60
|
*/
|
|
61
61
|
export declare function readGeneratedSchemaDrift(options: {
|
|
62
62
|
client: Queryable;
|
|
63
63
|
/** The `tables` export of `schema.generated.ts`. */
|
|
64
64
|
generated: Record<string, unknown> | undefined;
|
|
65
|
-
|
|
65
|
+
tables: readonly TableDescriptor[];
|
|
66
66
|
defaultSchema: string;
|
|
67
67
|
}): Promise<SchemaDifference[]>;
|
|
68
|
-
/** One line, in the terms the reader has:
|
|
68
|
+
/** One line, in the terms the reader has: table slug, column key, column. */
|
|
69
69
|
export declare function describeSchemaDifference(difference: SchemaDifference): string;
|
|
70
70
|
/**
|
|
71
71
|
* The `rebase schema reconcile` line for a difference it can apply: a column
|
|
72
|
-
* the database requires and the
|
|
73
|
-
*
|
|
72
|
+
* the database requires and the table made nullable, or one the table no
|
|
73
|
+
* longer declares. Undefined for the rest.
|
|
74
74
|
*/
|
|
75
75
|
export declare function reconcileFix(difference: SchemaDifference): string | undefined;
|
|
76
76
|
/**
|
|
@@ -78,13 +78,13 @@ export declare function reconcileFix(difference: SchemaDifference): string | und
|
|
|
78
78
|
*
|
|
79
79
|
* Per difference rather than one summary block on purpose: these are read out of
|
|
80
80
|
* a log aggregator as often as a terminal, and a single multi-line message
|
|
81
|
-
* cannot be filtered down to the one
|
|
81
|
+
* cannot be filtered down to the one table somebody is looking at.
|
|
82
82
|
*
|
|
83
83
|
* The fix it names is `rebase db push`. `rebase dev` rewrites
|
|
84
|
-
* schema.generated.ts from the
|
|
84
|
+
* schema.generated.ts from the tables on every change, and boot applies
|
|
85
85
|
* only additive changes, so what is still different at boot is the database
|
|
86
86
|
* behind the file: a rename, a dropped column, a narrowed type, a NOT NULL.
|
|
87
87
|
* `rebase schema generate` rewrites the file and leaves the database as it is,
|
|
88
|
-
* so it is named only for
|
|
88
|
+
* so it is named only for tables that changed since the file was written.
|
|
89
89
|
*/
|
|
90
90
|
export declare function warnOnGeneratedSchemaDrift(differences: SchemaDifference[]): void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TableDescriptor } from "@rebasepro/types";
|
|
2
2
|
/**
|
|
3
3
|
* Notice a generated Drizzle schema that a *library upgrade* invalidated.
|
|
4
4
|
*
|
|
5
|
-
* `rebase dev` already watches `
|
|
6
|
-
*
|
|
5
|
+
* `rebase dev` already watches `backend/schema` and warns when a table file
|
|
6
|
+
* changes. That covers drift the developer caused. It cannot cover this one,
|
|
7
7
|
* because nothing the developer owns changed: 0.13 derives `category_id` where
|
|
8
|
-
* 0.12 derived `categorie_id`, from the same unedited
|
|
8
|
+
* 0.12 derived `categorie_id`, from the same unedited table. The watcher
|
|
9
9
|
* never fires, and `backend/src/schema.generated.ts` quietly stops describing the
|
|
10
10
|
* schema the runtime expects.
|
|
11
11
|
*
|
|
@@ -32,28 +32,28 @@ export interface LegacyForeignKeyName {
|
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* @param generatedSource contents of `backend/src/schema.generated.ts`
|
|
35
|
-
* @param
|
|
35
|
+
* @param tables the project's compiled tables
|
|
36
36
|
*/
|
|
37
|
-
export declare function findLegacyForeignKeyNames(generatedSource: string,
|
|
37
|
+
export declare function findLegacyForeignKeyNames(generatedSource: string, tables: readonly TableDescriptor[]): LegacyForeignKeyName[];
|
|
38
38
|
/** One-line summary for a log or a CLI notice. */
|
|
39
39
|
export declare function describeLegacyForeignKeyNames(found: LegacyForeignKeyName[]): string;
|
|
40
|
-
/** Something the
|
|
40
|
+
/** Something the tables derive that the generated schema does not declare. */
|
|
41
41
|
export interface MissingGeneratedName {
|
|
42
42
|
/** The table it belongs to, or is. */
|
|
43
43
|
table: string;
|
|
44
44
|
/** The column, when a column is what is missing. */
|
|
45
45
|
column?: string;
|
|
46
|
-
/** `<
|
|
46
|
+
/** `<table>` or `<table>.<relation>`, for the message. */
|
|
47
47
|
source: string;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* Tables and derived foreign-key columns the
|
|
50
|
+
* Tables and derived foreign-key columns the tables name and the generated
|
|
51
51
|
* schema does not.
|
|
52
52
|
*
|
|
53
53
|
* @param generatedSource contents of `backend/src/schema.generated.ts`
|
|
54
|
-
* @param
|
|
54
|
+
* @param tables the project's compiled tables
|
|
55
55
|
*/
|
|
56
|
-
export declare function findMissingGeneratedNames(generatedSource: string,
|
|
56
|
+
export declare function findMissingGeneratedNames(generatedSource: string, tables: readonly TableDescriptor[]): MissingGeneratedName[];
|
|
57
57
|
/** One-line summary for a log or a CLI notice. */
|
|
58
58
|
export declare function describeMissingGeneratedNames(missing: MissingGeneratedName[]): string;
|
|
59
59
|
/** What `rebase schema stale` found, and what that costs. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Adopting an index the database already has, instead of building a twin.
|
|
3
3
|
*
|
|
4
|
-
* A declared index is found by its derived name (`
|
|
4
|
+
* A declared index is found by its derived name (`table-index.ts`), so an
|
|
5
5
|
* index someone made by hand — or one an introspected database arrived with —
|
|
6
6
|
* is invisible to it however exactly it matches the declaration: boot and
|
|
7
7
|
* `db push` built the same index again under the derived name, and every write
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* answering a narrower question than the one declared, so a predicate this
|
|
30
30
|
* cannot read as the same is not adopted.
|
|
31
31
|
*/
|
|
32
|
-
import { type
|
|
32
|
+
import { type TableIndexSpec } from "./table-index.js";
|
|
33
33
|
/** What the catalogue says about one existing index. */
|
|
34
34
|
export interface ExistingIndexShape {
|
|
35
35
|
schema: string;
|
|
@@ -75,7 +75,7 @@ export interface ShapeQueryable {
|
|
|
75
75
|
/** Read the {@link ExistingIndexShape}s of the given schemas. */
|
|
76
76
|
export declare function readIndexShapes(client: ShapeQueryable, schemas: readonly string[]): Promise<ExistingIndexShape[]>;
|
|
77
77
|
/** Whether `shape` is `spec` under another name. */
|
|
78
|
-
export declare function indexMatchesSpec(spec:
|
|
78
|
+
export declare function indexMatchesSpec(spec: TableIndexSpec, shape: ExistingIndexShape): boolean;
|
|
79
79
|
/**
|
|
80
80
|
* The renames that make existing indexes the declared ones: for each spec
|
|
81
81
|
* whose derived name the catalogue does not hold, the first existing index on
|
|
@@ -83,7 +83,7 @@ export declare function indexMatchesSpec(spec: CollectionIndexSpec, shape: Exist
|
|
|
83
83
|
* some declaration's, or one a removed declaration left for push to drop), and
|
|
84
84
|
* never the same one twice.
|
|
85
85
|
*/
|
|
86
|
-
export declare function planIndexAdoptions(specs: readonly
|
|
86
|
+
export declare function planIndexAdoptions(specs: readonly TableIndexSpec[], shapes: readonly ExistingIndexShape[]): IndexAdoption[];
|
|
87
87
|
/** The `ALTER INDEX … RENAME TO …` for one adoption. */
|
|
88
88
|
export declare function indexAdoptionStatement(adoption: IndexAdoption): string;
|
|
89
89
|
/**
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `frontend/src/cms/<table>.tsx` introspection writes beside a table whose
|
|
3
|
+
* structure suggested how the panel should show it: a `customizeTable(…)` of
|
|
4
|
+
* plain data (an icon, a group, a title field, a board, a sort, the list and
|
|
5
|
+
* form order, field options).
|
|
6
|
+
*
|
|
7
|
+
* A minimal emitter on purpose. Its values are strings, booleans, arrays and
|
|
8
|
+
* nested objects — never code — so it needs none of the CLI codemod's
|
|
9
|
+
* customization printer (which handles functions and JSX, and which this
|
|
10
|
+
* package must not depend on).
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/** A value this emitter prints: data only. */
|
|
15
|
+
export type CustomizationValue = string | number | boolean | readonly CustomizationValue[] | {
|
|
16
|
+
readonly [key: string]: CustomizationValue | undefined;
|
|
17
|
+
};
|
|
18
|
+
/** The package `customizeTable` is imported from. */
|
|
19
|
+
export declare const CMS_PACKAGE = "@rebasepro/cms";
|
|
20
|
+
/** One value as source, four-space indented, `depth` levels in. Short scalar arrays stay on one line. */
|
|
21
|
+
export declare function printCustomizationValue(value: CustomizationValue, depth?: number): string;
|
|
22
|
+
/** What {@link printCustomizationModule} prints. */
|
|
23
|
+
export interface CustomizationModule {
|
|
24
|
+
/** The table's slug, `customizeTable`'s first argument. */
|
|
25
|
+
slug: string;
|
|
26
|
+
/** The identifier the table is exported as from its schema module. */
|
|
27
|
+
tableIdentifier: string;
|
|
28
|
+
/** The schema module, relative to the customization file, without extension: `../../../backend/schema/film`. */
|
|
29
|
+
tableImport: string;
|
|
30
|
+
/** The options: plain data. */
|
|
31
|
+
options: {
|
|
32
|
+
readonly [key: string]: CustomizationValue | undefined;
|
|
33
|
+
};
|
|
34
|
+
/** Comment lines written above the export. */
|
|
35
|
+
comments?: readonly string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The whole module:
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { customizeTable } from "@rebasepro/cms";
|
|
42
|
+
* import type { film } from "../../../backend/schema/film";
|
|
43
|
+
*
|
|
44
|
+
* export const filmCms = customizeTable<typeof film>("film", { … });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function printCustomizationModule(module: CustomizationModule): string;
|
|
@@ -1,12 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { ColumnType, ColumnValidation } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* What sampled rows suggest about a column (`schema introspect
|
|
4
|
+
* --data-inference`).
|
|
5
|
+
*
|
|
6
|
+
* The column's type is the catalogue's and is never second-guessed from data:
|
|
7
|
+
* a `smallint` holding only 0s and 1s is still a `smallint`, a `text` of ISO
|
|
8
|
+
* dates is still `text`, and declaring otherwise would plan a type change on
|
|
9
|
+
* the first push. What the rows can add is what the type does not say — a
|
|
10
|
+
* bound the API may check, and how the panel should edit the value.
|
|
11
|
+
*/
|
|
12
|
+
export interface ColumnHints {
|
|
13
|
+
/** Rules the API checks before a write, merged into the column's `.validate()`. */
|
|
14
|
+
validate?: ColumnValidation;
|
|
15
|
+
/** Field options for the panel, written into the table's `customizeTable`. */
|
|
16
|
+
field?: {
|
|
17
|
+
multiline?: true;
|
|
18
|
+
markdown?: true;
|
|
19
|
+
urlPreview?: "image";
|
|
20
|
+
};
|
|
4
21
|
}
|
|
5
|
-
export declare function inferPropertyFromData(columnName: string, pgDataType: string, currentPropType: string, sampleValues: unknown[], isPk: boolean,
|
|
6
22
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
23
|
+
* Read a column's sampled values for what they add to its declared type.
|
|
24
|
+
*
|
|
25
|
+
* - a number column named like a percentage (`*percent*`, `*rate*`, `*score*`)
|
|
26
|
+
* whose values lie in 0–100 is validated to that range; one named like a
|
|
27
|
+
* quantity (`*count*`, `*total*`, `*amount*`) with no negative value, to `min: 0`;
|
|
28
|
+
* - a text column whose every value is an absolute URL is validated as one,
|
|
29
|
+
* and previewed as an image when the values (or the name) say so;
|
|
30
|
+
* - a text column holding markdown is edited as markdown, one holding line
|
|
31
|
+
* breaks or long values in a multi-line box.
|
|
11
32
|
*/
|
|
12
|
-
|
|
33
|
+
export declare function inferColumnHints(columnName: string, type: ColumnType, sampleValues: readonly unknown[]): ColumnHints;
|
|
@@ -30,6 +30,12 @@ export interface TableColumn {
|
|
|
30
30
|
character_maximum_length?: number | null;
|
|
31
31
|
numeric_precision?: number | null;
|
|
32
32
|
numeric_scale?: number | null;
|
|
33
|
+
/**
|
|
34
|
+
* `format_type(atttypid, atttypmod)`: the type as Postgres spells it in
|
|
35
|
+
* full, modifiers included (`timestamp(3) without time zone`,
|
|
36
|
+
* `geometry(Point,4326)`) — what a `col.custom()` column is declared as.
|
|
37
|
+
*/
|
|
38
|
+
formatted_type?: string | null;
|
|
33
39
|
}
|
|
34
40
|
export interface EnumValue {
|
|
35
41
|
enum_name: string;
|
|
@@ -129,37 +135,16 @@ export interface SchemaMetadata {
|
|
|
129
135
|
*/
|
|
130
136
|
rowCounts: Record<string, number>;
|
|
131
137
|
}
|
|
132
|
-
/**
|
|
133
|
-
* Why a table keyed on several columns is not generated as a collection, or
|
|
134
|
-
* `undefined` when it is.
|
|
135
|
-
*
|
|
136
|
-
* Several `isId` properties are one composite key, and the planner builds that
|
|
137
|
-
* table under the same `PRIMARY KEY (a, b)` — so such a table round-trips when
|
|
138
|
-
* two things hold:
|
|
139
|
-
*
|
|
140
|
-
* - **Every key column can carry `isId`,** which exists on string and number
|
|
141
|
-
* properties, and on a date property over a `date` column (a calendar day).
|
|
142
|
-
* Read from the column's SQL type, not a data sample: a
|
|
143
|
-
* `line_no` holding only 1s is not a boolean. A key with a column of another
|
|
144
|
-
* type — pagila's `payment` is keyed on a timestamp too — can be marked on
|
|
145
|
-
* some of its columns only, and those would be read as the whole key.
|
|
146
|
-
* - **Nothing points at it.** A foreign key into it, or a junction, is a link
|
|
147
|
-
* into a composite key, which the planner refuses: the relation has one
|
|
148
|
-
* column to point with.
|
|
149
|
-
*/
|
|
150
|
-
export declare function compositeKeySkipReason(meta: TableMeta, allFks: ForeignKeyRow[]): string | undefined;
|
|
151
138
|
export interface TableMeta {
|
|
152
139
|
name: string;
|
|
153
140
|
columns: TableColumn[];
|
|
154
141
|
pks: string[];
|
|
155
142
|
fks: ForeignKeyRow[];
|
|
156
143
|
}
|
|
157
|
-
export declare function singularize(word: string): string;
|
|
158
144
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
145
|
+
* The icon a table's name suggests, for its panel customization: `Database`
|
|
146
|
+
* when the name suggests none (and then no icon is written).
|
|
161
147
|
*/
|
|
162
|
-
export declare function toCollectionVarName(tableName: string): string;
|
|
163
148
|
export declare function getIconForTable(tableName: string): string;
|
|
164
149
|
export { mapPgType };
|
|
165
150
|
export declare function buildEnumMap(enumValues: EnumValue[]): Map<string, string[]>;
|
|
@@ -174,9 +159,10 @@ export declare function buildTablesMap(tables: TableRow[], columns: TableColumn[
|
|
|
174
159
|
* quantity and discount — because it recognises `id`, `created_at` and
|
|
175
160
|
* `updated_at` by name and calls everything else a foreign key.
|
|
176
161
|
*
|
|
177
|
-
* Still
|
|
178
|
-
*
|
|
179
|
-
*
|
|
162
|
+
* Still the runtime's rule (`describeTables(…, { purpose: "serve" })`): what a
|
|
163
|
+
* backend with no `backend/schema` has always folded away, kept so the set of
|
|
164
|
+
* tables it serves does not move. Row counts, which `classifyTables` needs,
|
|
165
|
+
* are not read at boot.
|
|
180
166
|
*/
|
|
181
167
|
export declare function identifyJoinTables(tablesMap: Map<string, TableMeta>): Set<string>;
|
|
182
168
|
/**
|
|
@@ -222,106 +208,89 @@ export interface PropertyOrderEntry {
|
|
|
222
208
|
ctx: PropertyOrderingContext;
|
|
223
209
|
}
|
|
224
210
|
export declare function sortPropertiesOrder(entries: PropertyOrderEntry[]): string[];
|
|
225
|
-
export interface GeneratedFile {
|
|
226
|
-
tableName: string;
|
|
227
|
-
fileName: string;
|
|
228
|
-
content: string;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* The structural analysis a run can hand the generator.
|
|
232
|
-
*
|
|
233
|
-
* Optional in full, and the generator degrades to exactly its previous output
|
|
234
|
-
* without it. That is not politeness towards old callers: three existing test
|
|
235
|
-
* suites and the `rebase init` scaffold path build a `TableMeta` by hand and
|
|
236
|
-
* have no database to read constraints or row counts from, and they must keep
|
|
237
|
-
* producing a valid collection.
|
|
238
|
-
*/
|
|
239
|
-
/**
|
|
240
|
-
* Which `defineCollection` — if any — the project being generated into can import.
|
|
241
|
-
*
|
|
242
|
-
* A bare `const x: PostgresCollectionConfig = { … }` annotation widens `properties`
|
|
243
|
-
* to `Record<string, …>`, and every key-shaped field in the admin block —
|
|
244
|
-
* `titleProperty`, `sort`, `propertiesOrder`, `listProperties`, `fixedFilter` — is
|
|
245
|
-
* derived from those keys. Annotated, they accept any string: introspection was
|
|
246
|
-
* emitting a `propertiesOrder` array that nothing checked, so renaming a column and
|
|
247
|
-
* re-introspecting left a stale key that compiled silently. `defineCollection` is
|
|
248
|
-
* the identity function whose `const P` type parameter keeps the keys literal, which
|
|
249
|
-
* is what turns that checking on.
|
|
250
|
-
*
|
|
251
|
-
* There are two of them and they are not interchangeable:
|
|
252
|
-
*
|
|
253
|
-
* - `admin-types` — `@rebasepro/cms-types`. Its index side-effect-imports
|
|
254
|
-
* `augment.ts`, so importing it is also what *declares* the `admin` block. Only a
|
|
255
|
-
* project that depends on the package can resolve it.
|
|
256
|
-
* - `common` — `@rebasepro/common`. Same key inference, no admin surface, no React
|
|
257
|
-
* anywhere in its graph (`scripts/headless-guard` lists it as core). This is the
|
|
258
|
-
* headless flavour.
|
|
259
|
-
* - `annotation` — neither package is declared, so neither import would resolve and
|
|
260
|
-
* the old annotation is the only honest thing to emit. Projects scaffolded before
|
|
261
|
-
* `@rebasepro/common` joined the headless config package land here.
|
|
262
|
-
*
|
|
263
|
-
* The last two emit **no admin block, on the collection or on any property**. That is
|
|
264
|
-
* not a downgrade: `@rebasepro/types` declares no `admin` field at all, so the block
|
|
265
|
-
* introspection used to emit was a type error in every headless project it was
|
|
266
|
-
* written into. See `packages/cms-types/src/augment.ts`.
|
|
267
|
-
*/
|
|
268
|
-
export type CollectionBuilder = "admin-types" | "common" | "annotation";
|
|
269
211
|
/**
|
|
270
|
-
*
|
|
212
|
+
* What one `schema introspect` run hands the generator.
|
|
271
213
|
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
* cannot be reasoned around — so the string simply never appears in that shape
|
|
277
|
-
* here. Inlining them back into the templates re-breaks `check:types-headless`.
|
|
214
|
+
* Everything but `metadata` is optional, and the generator degrades without
|
|
215
|
+
* it: no classification is no table roles and no presentation heuristics, no
|
|
216
|
+
* CHECK facts is no bounds, no samples is no data hints, no `cms` is no
|
|
217
|
+
* `customizeTable` files.
|
|
278
218
|
*/
|
|
279
|
-
export
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
export interface GenerationContext {
|
|
283
|
-
metadata?: SchemaMetadata;
|
|
219
|
+
export interface SchemaGenerationInput {
|
|
220
|
+
metadata: SchemaMetadata;
|
|
221
|
+
/** Each table's role (`classifyTables`): junctions fold into `manyToMany`, the rest steer the panel. */
|
|
284
222
|
classifications?: Map<string, TableClassification>;
|
|
223
|
+
/** The CHECK constraints, parsed (`parseCheckConstraints`). */
|
|
285
224
|
checkFacts?: CheckFactsByTable;
|
|
225
|
+
/** Sampled rows by table (`--data-inference`). */
|
|
226
|
+
samples?: ReadonlyMap<string, readonly Record<string, unknown>[]>;
|
|
227
|
+
/** Tables not to generate, which nothing may then point at (a name that is no file name). */
|
|
228
|
+
leaveOut?: ReadonlySet<string>;
|
|
286
229
|
/**
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
230
|
+
* Present when the project has a frontend that imports `@rebasepro/cms`:
|
|
231
|
+
* the import path from a `frontend/src/cms/<table>.tsx` to the table's
|
|
232
|
+
* schema module. Absent, no customization is written.
|
|
290
233
|
*/
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
* generated file.
|
|
297
|
-
*/
|
|
298
|
-
notes?: string[];
|
|
299
|
-
/**
|
|
300
|
-
* Tables this run does not generate a collection for, so nothing may point
|
|
301
|
-
* at them: a relation whose target file does not exist is an import that
|
|
302
|
-
* does not resolve.
|
|
303
|
-
*/
|
|
304
|
-
skippedTables?: ReadonlySet<string>;
|
|
234
|
+
cms?: {
|
|
235
|
+
tableImport: (table: string) => string;
|
|
236
|
+
};
|
|
237
|
+
/** Where the builders are imported from. `@rebasepro/server/schema` when omitted. */
|
|
238
|
+
specifier?: string;
|
|
305
239
|
}
|
|
306
240
|
/**
|
|
307
|
-
*
|
|
308
|
-
* the introspection to say once — or `undefined` when there are none.
|
|
241
|
+
* The source written for one table.
|
|
309
242
|
*/
|
|
310
|
-
export
|
|
243
|
+
export interface GeneratedTable {
|
|
244
|
+
table: string;
|
|
245
|
+
/** What `backend/schema/<table>.ts` exports, and `index.ts` re-exports. */
|
|
246
|
+
identifier: string;
|
|
247
|
+
/** `backend/schema/<table>.ts`. */
|
|
248
|
+
schemaModule: string;
|
|
249
|
+
/** `frontend/src/cms/<table>.tsx`, when a presentation heuristic fired and the project has a frontend. */
|
|
250
|
+
customization?: string;
|
|
251
|
+
/** What `rebase db push` would not reproduce exactly, each also at the top of the module. */
|
|
252
|
+
notes: string[];
|
|
253
|
+
/** Decisions the module states that the reader may want to undo (`index: false`, …), each also at its top. */
|
|
254
|
+
remarks: string[];
|
|
255
|
+
}
|
|
311
256
|
/**
|
|
312
|
-
*
|
|
313
|
-
* Pure function — no I/O.
|
|
257
|
+
* What {@link generateSchemaModules} returns.
|
|
314
258
|
*/
|
|
315
|
-
export
|
|
259
|
+
export interface SchemaGeneration {
|
|
260
|
+
tables: GeneratedTable[];
|
|
261
|
+
/** Tables whose descriptor could not be printed, each with why. */
|
|
262
|
+
failed: {
|
|
263
|
+
table: string;
|
|
264
|
+
reason: string;
|
|
265
|
+
}[];
|
|
266
|
+
/** The generated tables whose row-level security is off: the first push switches it on. */
|
|
267
|
+
rlsOff: string[];
|
|
268
|
+
}
|
|
316
269
|
/**
|
|
317
|
-
*
|
|
270
|
+
* The source `rebase schema introspect` writes for a database: one
|
|
271
|
+
* `backend/schema/<table>.ts` per table through the one table printer
|
|
272
|
+
* (`printTableModule`), and a `frontend/src/cms/<table>.tsx` beside a table
|
|
273
|
+
* whose structure suggested how the panel should show it.
|
|
274
|
+
*
|
|
275
|
+
* The tables are described with `describeTables(…, { purpose: "generate" })`:
|
|
276
|
+
* columns as their Postgres types, foreign keys as `belongsTo` with the column
|
|
277
|
+
* declared, the reverse `hasMany`, a junction as `manyToMany`, the policies as
|
|
278
|
+
* `rls` (or `"admin-only"` when the table holds only the admin baseline). Pure.
|
|
318
279
|
*/
|
|
319
|
-
export declare function
|
|
280
|
+
export declare function generateSchemaModules(input: SchemaGenerationInput): SchemaGeneration;
|
|
320
281
|
/**
|
|
321
|
-
*
|
|
322
|
-
*
|
|
282
|
+
* `backend/schema/index.ts` with an export line added for each table it does
|
|
283
|
+
* not export yet — what a run without `--force` does to an index that exists.
|
|
323
284
|
*/
|
|
324
|
-
export declare function
|
|
285
|
+
export declare function mergeIndexModule(existing: string, tables: readonly {
|
|
286
|
+
identifier: string;
|
|
287
|
+
importPath: string;
|
|
288
|
+
}[]): string;
|
|
289
|
+
/**
|
|
290
|
+
* What `rebase db push` does to tables whose row-level security is off, for
|
|
291
|
+
* the introspection to say once — or `undefined` when there are none.
|
|
292
|
+
*/
|
|
293
|
+
export declare function describeRlsOffTables(tableNames: readonly string[]): string | undefined;
|
|
325
294
|
/**
|
|
326
295
|
* Safely extract the host portion of a database URL for logging.
|
|
327
296
|
*/
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { type CollectionBuilder } from "./introspect-db-logic.js";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Reading the manifests along that same path answers the only question that matters —
|
|
12
|
-
* *will this import resolve in the project I am writing into* — from the state on disk
|
|
13
|
-
* at the moment of generation. The alternatives are all proxies for it: `rebase.json`'s
|
|
14
|
-
* `apps` block says a CMS scaffold declared an admin app, and a `frontend/` directory
|
|
15
|
-
* says one was scaffolded, but neither is what the compiler consults, and either can be
|
|
16
|
-
* true of a project whose `config` package does not depend on `@rebasepro/cms-types`.
|
|
2
|
+
* The project root above a directory: the first ancestor holding a
|
|
3
|
+
* `rebase.json`, or `undefined` when none does within reach.
|
|
4
|
+
*/
|
|
5
|
+
export declare function findProjectRoot(from: string): string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* The `frontend/src/cms` directory introspection writes `customizeTable`
|
|
8
|
+
* files into, or `undefined` when the project has no frontend that can import
|
|
9
|
+
* `@rebasepro/cms`.
|
|
17
10
|
*
|
|
18
|
-
*
|
|
19
|
-
* a
|
|
11
|
+
* The project root is the one above the schema directory (`rebase.json`), or —
|
|
12
|
+
* in a layout without one — the parent of `backend/`. The frontend is
|
|
13
|
+
* `<root>/frontend`, and it counts only when a manifest on the path a
|
|
14
|
+
* `frontend/src/cms/<table>.tsx` resolves bare specifiers along (the frontend's
|
|
15
|
+
* own `package.json`, then the root's) declares `@rebasepro/cms`: that is the
|
|
16
|
+
* import the file opens with, and a headless project could not resolve it.
|
|
20
17
|
*/
|
|
21
|
-
export declare function
|
|
18
|
+
export declare function detectCmsDir(schemaDir: string): string | undefined;
|