@rebasepro/cli 0.33.2 → 0.34.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.
Files changed (95) hide show
  1. package/dist/{agent-setup-Cg_zBWoW.js → agent-setup-CGeAuP0Q.js} +2 -2
  2. package/dist/{agent-setup-Cg_zBWoW.js.map → agent-setup-CGeAuP0Q.js.map} +1 -1
  3. package/dist/{api-keys-fPQ55DCm.js → api-keys-DaWN8dyI.js} +3 -3
  4. package/dist/{api-keys-fPQ55DCm.js.map → api-keys-DaWN8dyI.js.map} +1 -1
  5. package/dist/{api-TbmW33D7.js → api-zx1wSK5a.js} +2 -2
  6. package/dist/{api-TbmW33D7.js.map → api-zx1wSK5a.js.map} +1 -1
  7. package/dist/{apps-DBTRoOeP.js → apps-D6vtDrkJ.js} +3 -3
  8. package/dist/{apps-DBTRoOeP.js.map → apps-D6vtDrkJ.js.map} +1 -1
  9. package/dist/{auth-BpyYLEFY.js → auth-DY7kU0z-.js} +8 -8
  10. package/dist/{auth-BpyYLEFY.js.map → auth-DY7kU0z-.js.map} +1 -1
  11. package/dist/{auth-session-B6aT0Dyj.js → auth-session-DCG96UGH.js} +4 -4
  12. package/dist/{auth-session-B6aT0Dyj.js.map → auth-session-DCG96UGH.js.map} +1 -1
  13. package/dist/{build-E5hfEWKj.js → build-D0egCUfU.js} +4 -4
  14. package/dist/{build-E5hfEWKj.js.map → build-D0egCUfU.js.map} +1 -1
  15. package/dist/{bundle-CIiKGrte.js → bundle-DhdhtD8K.js} +3 -3
  16. package/dist/{bundle-CIiKGrte.js.map → bundle-DhdhtD8K.js.map} +1 -1
  17. package/dist/{cloud-DNJyUU0T.js → cloud-DOR7bxDw.js} +218 -27
  18. package/dist/cloud-DOR7bxDw.js.map +1 -0
  19. package/dist/{command-Bks5xkrQ.js → command-BzSP5gBh.js} +2 -2
  20. package/dist/{command-Bks5xkrQ.js.map → command-BzSP5gBh.js.map} +1 -1
  21. package/dist/commands/cloud/db-connect.d.ts +31 -1
  22. package/dist/commands/cloud/db-query.d.ts +16 -0
  23. package/dist/commands/cloud/index.d.ts +1 -0
  24. package/dist/commands/cloud/resources.d.ts +19 -1
  25. package/dist/commands/dev.d.ts +15 -0
  26. package/dist/commands/users.d.ts +1 -0
  27. package/dist/{context-BOMEoKxn.js → context-xt20FMFA.js} +5 -1
  28. package/dist/{context-BOMEoKxn.js.map → context-xt20FMFA.js.map} +1 -1
  29. package/dist/{cron-CpUsQ739.js → cron-BGkXIB1N.js} +4 -4
  30. package/dist/{cron-CpUsQ739.js.map → cron-BGkXIB1N.js.map} +1 -1
  31. package/dist/{cron-ZRXsla0v.js → cron-CJ6Xk42E.js} +3 -3
  32. package/dist/{cron-ZRXsla0v.js.map → cron-CJ6Xk42E.js.map} +1 -1
  33. package/dist/{data-BJ9AZFUC.js → data-BpkvtCUe.js} +3 -3
  34. package/dist/{data-BJ9AZFUC.js.map → data-BpkvtCUe.js.map} +1 -1
  35. package/dist/{debug-nNbbxAeo.js → debug-C7Ss34XB.js} +2 -2
  36. package/dist/{debug-nNbbxAeo.js.map → debug-C7Ss34XB.js.map} +1 -1
  37. package/dist/{derive-Mky_u59_.js → derive-ChP6vgfi.js} +2 -2
  38. package/dist/{derive-Mky_u59_.js.map → derive-ChP6vgfi.js.map} +1 -1
  39. package/dist/{dev-bj6dEeSQ.js → dev-C7n36E6f.js} +23 -2
  40. package/dist/dev-C7n36E6f.js.map +1 -0
  41. package/dist/{doctor-FaBObSlb.js → doctor-D0o54XSQ.js} +2 -2
  42. package/dist/{doctor-FaBObSlb.js.map → doctor-D0o54XSQ.js.map} +1 -1
  43. package/dist/{fold-static-2t3UUX4z.js → fold-static-DTpaqbB0.js} +2 -2
  44. package/dist/{fold-static-2t3UUX4z.js.map → fold-static-DTpaqbB0.js.map} +1 -1
  45. package/dist/{function-portability-BIvlvR9q.js → function-portability-Dppl6uqg.js} +24 -5
  46. package/dist/{function-portability-BIvlvR9q.js.map → function-portability-Dppl6uqg.js.map} +1 -1
  47. package/dist/function-portability.d.ts +9 -0
  48. package/dist/{functions-B4JR6EZL.js → functions-DLuuldt2.js} +4 -4
  49. package/dist/{functions-B4JR6EZL.js.map → functions-DLuuldt2.js.map} +1 -1
  50. package/dist/{generate_sdk-ByD-gTsK.js → generate_sdk-UT1lwwRT.js} +2 -2
  51. package/dist/{generate_sdk-ByD-gTsK.js.map → generate_sdk-UT1lwwRT.js.map} +1 -1
  52. package/dist/index.es.js +39 -39
  53. package/dist/{init-DHCe5mJ5.js → init-u5Xmr1Ct.js} +4 -4
  54. package/dist/{init-DHCe5mJ5.js.map → init-u5Xmr1Ct.js.map} +1 -1
  55. package/dist/{logs-DpuMukJe.js → logs-DBYRSs6W.js} +4 -4
  56. package/dist/{logs-DpuMukJe.js.map → logs-DBYRSs6W.js.map} +1 -1
  57. package/dist/{migrate-CSY9ZDKy.js → migrate-Cw1FkvUK.js} +3 -3
  58. package/dist/{migrate-CSY9ZDKy.js.map → migrate-Cw1FkvUK.js.map} +1 -1
  59. package/dist/{normalize-imports-P86NVfpo.js → normalize-imports-E4yA1HfW.js} +2 -2
  60. package/dist/{normalize-imports-P86NVfpo.js.map → normalize-imports-E4yA1HfW.js.map} +1 -1
  61. package/dist/{project-command-Cl9EZzjr.js → project-command-7EGMemEy.js} +5 -5
  62. package/dist/{project-command-Cl9EZzjr.js.map → project-command-7EGMemEy.js.map} +1 -1
  63. package/dist/{resources-Db3USuPO.js → resources-CE6BeL94.js} +2 -2
  64. package/dist/{resources-Db3USuPO.js.map → resources-CE6BeL94.js.map} +1 -1
  65. package/dist/{rls-BxrQ0P50.js → rls-BxWLfEKl.js} +3 -3
  66. package/dist/{rls-BxrQ0P50.js.map → rls-BxWLfEKl.js.map} +1 -1
  67. package/dist/{schema-_FzZEoB8.js → schema-D8xFSBbN.js} +7 -6
  68. package/dist/{schema-_FzZEoB8.js.map → schema-D8xFSBbN.js.map} +1 -1
  69. package/dist/schema-reconcile-D_wvZY91.js +2 -0
  70. package/dist/{schema-show-h72UJ9zH.js → schema-show-C7bY7SgE.js} +3 -3
  71. package/dist/{schema-show-h72UJ9zH.js.map → schema-show-C7bY7SgE.js.map} +1 -1
  72. package/dist/{skills-DQ2bZGkj.js → skills-C8WdRTFg.js} +4 -4
  73. package/dist/{skills-DQ2bZGkj.js.map → skills-C8WdRTFg.js.map} +1 -1
  74. package/dist/{start-Cjx4W0bJ.js → start-CN_9C205.js} +2 -2
  75. package/dist/{start-Cjx4W0bJ.js.map → start-CN_9C205.js.map} +1 -1
  76. package/dist/{status-CDBk25VO.js → status-HWlZbY1E.js} +2 -2
  77. package/dist/{status-CDBk25VO.js.map → status-HWlZbY1E.js.map} +1 -1
  78. package/dist/{storage-Clc8dLG8.js → storage-DBE8lgH-.js} +9 -9
  79. package/dist/{storage-Clc8dLG8.js.map → storage-DBE8lgH-.js.map} +1 -1
  80. package/dist/{storage-objects-CfRKlTDe.js → storage-objects-ljDmtuH7.js} +3 -3
  81. package/dist/{storage-objects-CfRKlTDe.js.map → storage-objects-ljDmtuH7.js.map} +1 -1
  82. package/dist/{users-5PkqBY6R.js → users-DrJEtL9k.js} +9 -6
  83. package/dist/users-DrJEtL9k.js.map +1 -0
  84. package/package.json +10 -10
  85. package/templates/template/.cursorrules +2 -1
  86. package/templates/template/.github/copilot-instructions.md +2 -1
  87. package/templates/template/.windsurfrules +2 -1
  88. package/templates/template/AGENTS.md +2 -1
  89. package/templates/template/CLAUDE.md +2 -1
  90. package/templates/template/ai-instructions.md +5 -2
  91. package/templates/template/frontend/src/index.css +13 -0
  92. package/dist/cloud-DNJyUU0T.js.map +0 -1
  93. package/dist/dev-bj6dEeSQ.js.map +0 -1
  94. package/dist/schema-reconcile-DV14XY4o.js +0 -2
  95. package/dist/users-5PkqBY6R.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"resources-Db3USuPO.js","names":[],"sources":["../src/commands/resources.ts"],"sourcesContent":["/**\n * CLI command: rebase resources\n *\n * Shows what a project declares, and keeps the committed graph honest.\n *\n * The graph is generated, so it can drift the moment somebody adds a bucket and\n * does not regenerate. Drift here is not cosmetic: the committed file is what a\n * host reads to decide what to provision, so a stale one means the console\n * offers a project one set of resources while the runtime asks for another.\n * `--check` is the gate that makes that impossible to land.\n */\nimport chalk from \"chalk\";\nimport path from \"path\";\nimport { failAsJson, requireProjectRoot } from \"../utils/project\";\nimport { findBackendApp, loadManifest, ManifestError } from \"../manifest\";\nimport { parseCommandArgs, wantsHelp } from \"../utils/args\";\nimport {\n RESOURCE_GRAPH_FILENAME,\n deriveOptionsFor, deriveResourceGraph,\n projectResourceGraph,\n readResourceGraphFile,\n serializeResourceGraph,\n writeResourceGraphFile,\n type ProjectedResource\n} from \"../resources/derive\";\nimport { declaredSubscriptions, type RebaseBackendAppConfig } from \"@rebasepro/types\";\n\nfunction usage(): void {\n console.log(`\n${chalk.bold(\"rebase resources\")} — what this project needs\n\n ${chalk.blue(\"rebase resources\")} List them, declared and implicit\n ${chalk.blue(\"rebase resources --write\")} Regenerate ${RESOURCE_GRAPH_FILENAME}\n ${chalk.blue(\"rebase resources --check\")} Fail if the committed graph is stale\n ${chalk.blue(\"rebase resources --json\")} The same set, machine-readable; with --check or --write,\n their result too (a failed check is an error envelope, exit 1)\n\nA resource is declared in config code — ${chalk.gray('database(\"analytics\"), bucket(\"media\"), topic(\"signups\")')} —\nand never in ${RESOURCE_GRAPH_FILENAME}, which is generated from those declarations so a host\ncan read what a project needs without building it. A backend also has a default\ndatabase and a default storage source nobody declared; both are listed here,\nmarked ${chalk.gray(\"implicit\")}, and neither is written to that file — the host supplies them.\n`);\n}\n\n/**\n * Render the projection the way somebody reads it: grouped by kind, key first.\n *\n * The projection, not the raw graph. `rebase status` has always included the\n * implicit default database and bucket and this listing did not, so the two\n * commands answered \"what does this project need\" differently on the same stock\n * scaffold. There is no \"no resources declared\" case any more: a backend has a\n * database and a storage source whether or not anyone wrote them down.\n */\nfunction print(resources: ProjectedResource[]): void {\n // Infrastructure first, then code: what needs binding is what a reader\n // is here to check.\n const order = [\"database\", \"bucket\", \"topic\", \"queue\", \"cron\", \"function\"];\n const kinds = [...new Set(resources.map(r => r.kind))]\n .sort((a, b) => (order.indexOf(a) === -1 ? 99 : order.indexOf(a)) - (order.indexOf(b) === -1 ? 99 : order.indexOf(b)));\n for (const kind of kinds) {\n console.log(`\\n ${chalk.bold(kind)}`);\n for (const r of resources.filter(x => x.kind === kind)) {\n const bits: string[] = [];\n if (kind === \"cron\") {\n bits.push(chalk.cyan(String(r.options.schedule)));\n bits.push(chalk.gray(r.options.timezone ? String(r.options.timezone) : \"local time\"));\n } else if (kind === \"function\") {\n bits.push(chalk.gray(String(r.options.file ?? \"\")));\n if (r.options.portable === false) bits.push(chalk.yellow(\"node-only\"));\n } else {\n bits.push(chalk.gray(r.engine));\n if (r.transport !== \"server\") bits.push(chalk.yellow(r.transport));\n for (const [k, v] of Object.entries(r.options)) bits.push(chalk.gray(`${k}=${String(v)}`));\n }\n // Marked, not hidden: a declared resource is recorded in\n // `rebase.resources.json` for a host to provision, and an implicit\n // one is a default the runtime supplies regardless.\n if (r.implicit) bits.push(chalk.gray(\"implicit\"));\n console.log(` ${r.key.padEnd(24)} ${bits.join(\" · \")}`);\n if (kind === \"topic\") {\n for (const sub of declaredSubscriptions(r.key)) {\n console.log(` ${chalk.gray(\"→\")} ${sub.name}`);\n }\n }\n if (r.usedBy && r.usedBy.length > 0) {\n console.log(` ${chalk.gray(\"used by\")} ${chalk.gray(r.usedBy.join(\", \"))}`);\n }\n }\n }\n console.log(\"\");\n}\n\nexport async function resourcesCommand(rawArgs: string[]): Promise<void> {\n if (wantsHelp(rawArgs)) return usage();\n\n const { flags } = parseCommandArgs({\n spec: {\n \"--write\": Boolean,\n \"--check\": Boolean,\n \"--json\": Boolean\n },\n rawArgs,\n commandWords: 1,\n command: \"resources\",\n maxPositionals: 0\n });\n\n const projectRoot = requireProjectRoot();\n\n // Every exit below has a `--json` arm, for the reason in `failAsJson`:\n // `--json` is a promise about stdout, and a promise kept on one exit of a\n // command and broken on the next is not one.\n const asJson = Boolean(flags[\"--json\"]);\n\n let backendApp: RebaseBackendAppConfig;\n try {\n const loaded = loadManifest(projectRoot);\n const backend = findBackendApp(loaded.manifest);\n if (!backend) {\n if (asJson) {\n failAsJson(\n \"This project declares no backend app, so it declares no resources.\",\n \"no_backend_app\",\n \"Add a backend app to rebase.json, or run `rebase apps init`.\"\n );\n }\n console.error(chalk.red(\"This project declares no backend app, so it declares no resources.\"));\n process.exitCode = 1;\n return;\n }\n backendApp = backend.app;\n } catch (err) {\n if (err instanceof ManifestError) {\n if (asJson) {\n failAsJson(err.message, \"manifest_invalid\", \"Fix rebase.json, then run this again.\",\n err.issues.map(issue => ({ path: issue.path, message: issue.message })));\n }\n console.error(chalk.red(err.message));\n for (const issue of err.issues) console.error(` ${chalk.gray(issue.path)} ${issue.message}`);\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n\n const { graph, issues } = await deriveResourceGraph(deriveOptionsFor(projectRoot, backendApp));\n\n if (issues.length > 0) {\n if (asJson) {\n failAsJson(\n `${issues.length} problem(s) in the declared resources.`,\n \"resource_declaration_invalid\",\n \"Fix the declarations the issues name, then run this again.\",\n issues.map(issue => ({ path: issue.path, message: issue.message }))\n );\n }\n console.error(chalk.red(`\\n✗ ${issues.length} problem(s) in the declared resources:\\n`));\n for (const issue of issues) console.error(` ${chalk.bold(issue.path)} ${issue.message}`);\n console.error(\"\");\n process.exitCode = 1;\n return;\n }\n\n // The projection, so this and `rebase status --json` describe the same\n // set. `version` is kept so a reader of either can tell them apart from a\n // future shape. `--check` and `--write` add what they did to it: `--json`\n // changes how the answer is printed, never which question is answered — it\n // used to return here, so `--check --json` exited 0 on any drift and\n // `--write --json` wrote nothing.\n const projection = () => ({ version: graph.version, resources: projectResourceGraph(graph) });\n\n if (flags[\"--check\"]) {\n const committed = readResourceGraphFile(projectRoot);\n const expected = serializeResourceGraph(graph);\n // Declaring nothing and having no file is a consistent state, not a\n // stale one. The file records declarations; a project with none has\n // nothing to record, and its default database and bucket are implicit\n // by design — that is the overwhelmingly common project and it must not\n // be required to commit an empty file saying so.\n //\n // This mattered the moment the check was put in a gate: it would have\n // failed this repository's own reference app, which declares nothing,\n // and every scaffolded project until someone declared a second bucket.\n const status = committed === expected\n ? \"current\"\n : committed === null && graph.resources.length === 0 ? \"nothing-declared\" : null;\n\n if (status !== null) {\n if (asJson) {\n console.log(JSON.stringify({ ...projection(), check: { file: RESOURCE_GRAPH_FILENAME, status } }, null, 2));\n return;\n }\n console.log(status === \"current\"\n ? chalk.green(`✓ ${RESOURCE_GRAPH_FILENAME} matches the declarations.`)\n : chalk.gray(\"✓ Nothing declared, so there is nothing to record.\"));\n return;\n }\n\n const state = committed === null ? \"missing\" : \"stale\";\n if (asJson) {\n failAsJson(\n `${RESOURCE_GRAPH_FILENAME} is ${state}.`,\n `resource_graph_${state}`,\n \"Regenerate it with `rebase resources --write`, and commit it.\"\n );\n }\n console.error(chalk.red(`\\n✗ ${RESOURCE_GRAPH_FILENAME} is ${state}.\\n`));\n console.error(\n \" A host reads this file to decide what to provision, so a stale one means the\\n\" +\n \" console offers one set of resources while the runtime asks for another.\\n\"\n );\n console.error(` Regenerate it: ${chalk.blue(\"rebase resources --write\")}\\n`);\n process.exitCode = 1;\n return;\n }\n\n if (flags[\"--write\"]) {\n const { changed, file } = writeResourceGraphFile(projectRoot, graph);\n const relative = path.relative(projectRoot, file);\n if (asJson) {\n console.log(JSON.stringify({ ...projection(), written: { file: relative, changed } }, null, 2));\n return;\n }\n console.log(changed\n ? chalk.green(`✓ Wrote ${relative}`)\n : chalk.gray(`${relative} already matched the declarations.`));\n return;\n }\n\n if (asJson) {\n console.log(JSON.stringify(projection(), null, 2));\n return;\n }\n\n print(projectResourceGraph(graph));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA2BA,SAAS,QAAc;CACnB,QAAQ,IAAI;EACd,MAAM,KAAK,kBAAkB,EAAE;;IAE7B,MAAM,KAAK,kB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MAAM,QAAQ,cAAc,OAAO,YAAY;EAC/C,IAAI,QACA,WACI,GAAG,wBAAwB,MAAM,MAAM,IACvC,kBAAkB,SAClB,+DACJ;EAEJ,QAAQ,MAAM,MAAM,IAAI,OAAO,wBAAwB,MAAM,MAAM,IAAI,CAAC;EACxE,QAAQ,MACJ,6JAEJ;EACA,QAAQ,MAAM,qBAAqB,MAAM,KAAK,0BAA0B,EAAE,GAAG;EAC7E,QAAQ,WAAW;EACnB;CACJ;CAEA,IAAI,MAAM,YAAY;EAClB,MAAM,EAAE,SAAS,SAAS,uBAAuB,aAAa,KAAK;EACnE,MAAM,WAAW,KAAK,SAAS,aAAa,IAAI;EAChD,IAAI,QAAQ;GACR,QAAQ,IAAI,KAAK,UAAU;IAAE,GAAG,WAAW;IAAG,SAAS;KAAE,MAAM;KAAU;IAAQ;GAAE,GAAG,MAAM,CAAC,CAAC;GAC9F;EACJ;EACA,QAAQ,IAAI,UACN,MAAM,MAAM,WAAW,UAAU,IACjC,MAAM,KAAK,GAAG,SAAS,mCAAmC,CAAC;EACjE;CACJ;CAEA,IAAI,QAAQ;EACR,QAAQ,IAAI,KAAK,UAAU,WAAW,GAAG,MAAM,CAAC,CAAC;EACjD;CACJ;CAEA,MAAM,qBAAqB,KAAK,CAAC;AACrC"}
1
+ {"version":3,"file":"resources-CE6BeL94.js","names":[],"sources":["../src/commands/resources.ts"],"sourcesContent":["/**\n * CLI command: rebase resources\n *\n * Shows what a project declares, and keeps the committed graph honest.\n *\n * The graph is generated, so it can drift the moment somebody adds a bucket and\n * does not regenerate. Drift here is not cosmetic: the committed file is what a\n * host reads to decide what to provision, so a stale one means the console\n * offers a project one set of resources while the runtime asks for another.\n * `--check` is the gate that makes that impossible to land.\n */\nimport chalk from \"chalk\";\nimport path from \"path\";\nimport { failAsJson, requireProjectRoot } from \"../utils/project\";\nimport { findBackendApp, loadManifest, ManifestError } from \"../manifest\";\nimport { parseCommandArgs, wantsHelp } from \"../utils/args\";\nimport {\n RESOURCE_GRAPH_FILENAME,\n deriveOptionsFor, deriveResourceGraph,\n projectResourceGraph,\n readResourceGraphFile,\n serializeResourceGraph,\n writeResourceGraphFile,\n type ProjectedResource\n} from \"../resources/derive\";\nimport { declaredSubscriptions, type RebaseBackendAppConfig } from \"@rebasepro/types\";\n\nfunction usage(): void {\n console.log(`\n${chalk.bold(\"rebase resources\")} — what this project needs\n\n ${chalk.blue(\"rebase resources\")} List them, declared and implicit\n ${chalk.blue(\"rebase resources --write\")} Regenerate ${RESOURCE_GRAPH_FILENAME}\n ${chalk.blue(\"rebase resources --check\")} Fail if the committed graph is stale\n ${chalk.blue(\"rebase resources --json\")} The same set, machine-readable; with --check or --write,\n their result too (a failed check is an error envelope, exit 1)\n\nA resource is declared in config code — ${chalk.gray('database(\"analytics\"), bucket(\"media\"), topic(\"signups\")')} —\nand never in ${RESOURCE_GRAPH_FILENAME}, which is generated from those declarations so a host\ncan read what a project needs without building it. A backend also has a default\ndatabase and a default storage source nobody declared; both are listed here,\nmarked ${chalk.gray(\"implicit\")}, and neither is written to that file — the host supplies them.\n`);\n}\n\n/**\n * Render the projection the way somebody reads it: grouped by kind, key first.\n *\n * The projection, not the raw graph. `rebase status` has always included the\n * implicit default database and bucket and this listing did not, so the two\n * commands answered \"what does this project need\" differently on the same stock\n * scaffold. There is no \"no resources declared\" case any more: a backend has a\n * database and a storage source whether or not anyone wrote them down.\n */\nfunction print(resources: ProjectedResource[]): void {\n // Infrastructure first, then code: what needs binding is what a reader\n // is here to check.\n const order = [\"database\", \"bucket\", \"topic\", \"queue\", \"cron\", \"function\"];\n const kinds = [...new Set(resources.map(r => r.kind))]\n .sort((a, b) => (order.indexOf(a) === -1 ? 99 : order.indexOf(a)) - (order.indexOf(b) === -1 ? 99 : order.indexOf(b)));\n for (const kind of kinds) {\n console.log(`\\n ${chalk.bold(kind)}`);\n for (const r of resources.filter(x => x.kind === kind)) {\n const bits: string[] = [];\n if (kind === \"cron\") {\n bits.push(chalk.cyan(String(r.options.schedule)));\n bits.push(chalk.gray(r.options.timezone ? String(r.options.timezone) : \"local time\"));\n } else if (kind === \"function\") {\n bits.push(chalk.gray(String(r.options.file ?? \"\")));\n if (r.options.portable === false) bits.push(chalk.yellow(\"node-only\"));\n } else {\n bits.push(chalk.gray(r.engine));\n if (r.transport !== \"server\") bits.push(chalk.yellow(r.transport));\n for (const [k, v] of Object.entries(r.options)) bits.push(chalk.gray(`${k}=${String(v)}`));\n }\n // Marked, not hidden: a declared resource is recorded in\n // `rebase.resources.json` for a host to provision, and an implicit\n // one is a default the runtime supplies regardless.\n if (r.implicit) bits.push(chalk.gray(\"implicit\"));\n console.log(` ${r.key.padEnd(24)} ${bits.join(\" · \")}`);\n if (kind === \"topic\") {\n for (const sub of declaredSubscriptions(r.key)) {\n console.log(` ${chalk.gray(\"→\")} ${sub.name}`);\n }\n }\n if (r.usedBy && r.usedBy.length > 0) {\n console.log(` ${chalk.gray(\"used by\")} ${chalk.gray(r.usedBy.join(\", \"))}`);\n }\n }\n }\n console.log(\"\");\n}\n\nexport async function resourcesCommand(rawArgs: string[]): Promise<void> {\n if (wantsHelp(rawArgs)) return usage();\n\n const { flags } = parseCommandArgs({\n spec: {\n \"--write\": Boolean,\n \"--check\": Boolean,\n \"--json\": Boolean\n },\n rawArgs,\n commandWords: 1,\n command: \"resources\",\n maxPositionals: 0\n });\n\n const projectRoot = requireProjectRoot();\n\n // Every exit below has a `--json` arm, for the reason in `failAsJson`:\n // `--json` is a promise about stdout, and a promise kept on one exit of a\n // command and broken on the next is not one.\n const asJson = Boolean(flags[\"--json\"]);\n\n let backendApp: RebaseBackendAppConfig;\n try {\n const loaded = loadManifest(projectRoot);\n const backend = findBackendApp(loaded.manifest);\n if (!backend) {\n if (asJson) {\n failAsJson(\n \"This project declares no backend app, so it declares no resources.\",\n \"no_backend_app\",\n \"Add a backend app to rebase.json, or run `rebase apps init`.\"\n );\n }\n console.error(chalk.red(\"This project declares no backend app, so it declares no resources.\"));\n process.exitCode = 1;\n return;\n }\n backendApp = backend.app;\n } catch (err) {\n if (err instanceof ManifestError) {\n if (asJson) {\n failAsJson(err.message, \"manifest_invalid\", \"Fix rebase.json, then run this again.\",\n err.issues.map(issue => ({ path: issue.path, message: issue.message })));\n }\n console.error(chalk.red(err.message));\n for (const issue of err.issues) console.error(` ${chalk.gray(issue.path)} ${issue.message}`);\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n\n const { graph, issues } = await deriveResourceGraph(deriveOptionsFor(projectRoot, backendApp));\n\n if (issues.length > 0) {\n if (asJson) {\n failAsJson(\n `${issues.length} problem(s) in the declared resources.`,\n \"resource_declaration_invalid\",\n \"Fix the declarations the issues name, then run this again.\",\n issues.map(issue => ({ path: issue.path, message: issue.message }))\n );\n }\n console.error(chalk.red(`\\n✗ ${issues.length} problem(s) in the declared resources:\\n`));\n for (const issue of issues) console.error(` ${chalk.bold(issue.path)} ${issue.message}`);\n console.error(\"\");\n process.exitCode = 1;\n return;\n }\n\n // The projection, so this and `rebase status --json` describe the same\n // set. `version` is kept so a reader of either can tell them apart from a\n // future shape. `--check` and `--write` add what they did to it: `--json`\n // changes how the answer is printed, never which question is answered — it\n // used to return here, so `--check --json` exited 0 on any drift and\n // `--write --json` wrote nothing.\n const projection = () => ({ version: graph.version, resources: projectResourceGraph(graph) });\n\n if (flags[\"--check\"]) {\n const committed = readResourceGraphFile(projectRoot);\n const expected = serializeResourceGraph(graph);\n // Declaring nothing and having no file is a consistent state, not a\n // stale one. The file records declarations; a project with none has\n // nothing to record, and its default database and bucket are implicit\n // by design — that is the overwhelmingly common project and it must not\n // be required to commit an empty file saying so.\n //\n // This mattered the moment the check was put in a gate: it would have\n // failed this repository's own reference app, which declares nothing,\n // and every scaffolded project until someone declared a second bucket.\n const status = committed === expected\n ? \"current\"\n : committed === null && graph.resources.length === 0 ? \"nothing-declared\" : null;\n\n if (status !== null) {\n if (asJson) {\n console.log(JSON.stringify({ ...projection(), check: { file: RESOURCE_GRAPH_FILENAME, status } }, null, 2));\n return;\n }\n console.log(status === \"current\"\n ? chalk.green(`✓ ${RESOURCE_GRAPH_FILENAME} matches the declarations.`)\n : chalk.gray(\"✓ Nothing declared, so there is nothing to record.\"));\n return;\n }\n\n const state = committed === null ? \"missing\" : \"stale\";\n if (asJson) {\n failAsJson(\n `${RESOURCE_GRAPH_FILENAME} is ${state}.`,\n `resource_graph_${state}`,\n \"Regenerate it with `rebase resources --write`, and commit it.\"\n );\n }\n console.error(chalk.red(`\\n✗ ${RESOURCE_GRAPH_FILENAME} is ${state}.\\n`));\n console.error(\n \" A host reads this file to decide what to provision, so a stale one means the\\n\" +\n \" console offers one set of resources while the runtime asks for another.\\n\"\n );\n console.error(` Regenerate it: ${chalk.blue(\"rebase resources --write\")}\\n`);\n process.exitCode = 1;\n return;\n }\n\n if (flags[\"--write\"]) {\n const { changed, file } = writeResourceGraphFile(projectRoot, graph);\n const relative = path.relative(projectRoot, file);\n if (asJson) {\n console.log(JSON.stringify({ ...projection(), written: { file: relative, changed } }, null, 2));\n return;\n }\n console.log(changed\n ? chalk.green(`✓ Wrote ${relative}`)\n : chalk.gray(`${relative} already matched the declarations.`));\n return;\n }\n\n if (asJson) {\n console.log(JSON.stringify(projection(), null, 2));\n return;\n }\n\n print(projectResourceGraph(graph));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA2BA,SAAS,QAAc;CACnB,QAAQ,IAAI;EACd,MAAM,KAAK,kBAAkB,EAAE;;IAE7B,MAAM,KAAK,kBAAkB,EAAE;IAC/B,MAAM,KAAK,0BAA0B,EAAE,iBAAiB,wBAAwB;IAChF,MAAM,KAAK,0BAA0B,EAAE;IACvC,MAAM,KAAK,yBAAyB,EAAE;;;0CAGA,MAAM,KAAK,gEAA0D,EAAE;eAClG,wBAAwB;;;SAG9B,MAAM,KAAK,UAAU,EAAE;CAC/B;AACD;;;;;;;;;;AAWA,SAAS,MAAM,WAAsC;CAGjD,MAAM,QAAQ;EAAC;EAAY;EAAU;EAAS;EAAS;EAAQ;CAAU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EAClB,MAAM,EAAE,SAAS,SAAS,uBAAuB,aAAa,KAAK;EACnE,MAAM,WAAW,KAAK,SAAS,aAAa,IAAI;EAChD,IAAI,QAAQ;GACR,QAAQ,IAAI,KAAK,UAAU;IAAE,GAAG,WAAW;IAAG,SAAS;KAAE,MAAM;KAAU;IAAQ;GAAE,GAAG,MAAM,CAAC,CAAC;GAC9F;EACJ;EACA,QAAQ,IAAI,UACN,MAAM,MAAM,WAAW,UAAU,IACjC,MAAM,KAAK,GAAG,SAAS,mCAAmC,CAAC;EACjE;CACJ;CAEA,IAAI,QAAQ;EACR,QAAQ,IAAI,KAAK,UAAU,WAAW,GAAG,MAAM,CAAC,CAAC;EACjD;CACJ;CAEA,MAAM,qBAAqB,KAAK,CAAC;AACrC"}
@@ -1,7 +1,7 @@
1
1
  import { n as unknownCommand } from "./unknown-command-DnZ2uhGs.js";
2
2
  import { a as wantsHelp, n as parseCommandArgs, t as UsageError } from "./args-DHyrshtI.js";
3
- import { a as projectTarget, c as requestJson, d as PROJECT_TARGET_FLAGS, i as printProjectHelp, l as startProjectCommand, n as isRecord, o as recordsOf, r as parsedLine, u as stringOf } from "./project-command-Cl9EZzjr.js";
4
- import { M as note, m as emit } from "./context-BOMEoKxn.js";
3
+ import { a as projectTarget, c as requestJson, d as PROJECT_TARGET_FLAGS, i as printProjectHelp, l as startProjectCommand, n as isRecord, o as recordsOf, r as parsedLine, u as stringOf } from "./project-command-7EGMemEy.js";
4
+ import { M as note, m as emit } from "./context-xt20FMFA.js";
5
5
  import chalk from "chalk";
6
6
  //#region src/commands/rls.ts
7
7
  /** Everything the switch below dispatches, for the did-you-mean. */
@@ -130,4 +130,4 @@ function printRlsHelp() {
130
130
  //#endregion
131
131
  export { RLS_SUBCOMMANDS, rlsCommand };
132
132
 
133
- //# sourceMappingURL=rls-BxrQ0P50.js.map
133
+ //# sourceMappingURL=rls-BxWLfEKl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rls-BxrQ0P50.js","names":[],"sources":["../src/commands/rls.ts"],"sourcesContent":["/**\n * CLI command: rebase rls <action>\n *\n * What another identity would see: the app's RLS simulator\n * (`/api/admin/rls-simulator`), the one Studio's \"view as\" uses. For a role,\n * a user or a service key it answers, table by table, how many rows that\n * identity reads against how many you read, which tables its scopes shut it\n * out of, and which columns it cannot read. Read-only: nothing is written.\n *\n * The simulator answers an administrator's own session, never a key — a\n * machine credential could otherwise borrow anyone's view. So this command\n * sends the session `rebase auth login` stored for the server, and says so\n * when there is none.\n *\n * `rebase verify --live` is the static half: policies checked against the\n * schema with no identity in mind.\n */\nimport type arg from \"arg\";\nimport chalk from \"chalk\";\n\nimport { parseCommandArgs, UsageError, wantsHelp } from \"../utils/args\";\nimport { unknownCommand } from \"../utils/unknown-command\";\nimport { PROJECT_TARGET_FLAGS } from \"../utils/project-target\";\nimport {\n emit,\n isRecord,\n parsedLine,\n printProjectHelp,\n projectTarget,\n recordsOf,\n requestJson,\n startProjectCommand,\n stringOf,\n type HelpAction\n} from \"../utils/project-command\";\nimport { note } from \"./cloud/context\";\n\n/** Everything the switch below dispatches, for the did-you-mean. */\nexport const RLS_SUBCOMMANDS = [\"simulate\", \"options\"] as const;\n\nconst SIMULATOR = \"/api/admin/rls-simulator\";\n\nexport async function rlsCommand(subcommand: string | undefined, rawArgs: string[]): Promise<void> {\n startProjectCommand(rawArgs);\n if (!subcommand || subcommand === \"--help\" || wantsHelp(rawArgs)) {\n printRlsHelp();\n return;\n }\n switch (subcommand) {\n case \"simulate\":\n await simulate(rawArgs);\n break;\n case \"options\":\n await options(rawArgs);\n break;\n default:\n unknownCommand(subcommand, RLS_SUBCOMMANDS, \"rls\");\n }\n}\n\nexport const RLS_OPTIONS_FLAGS = { ...PROJECT_TARGET_FLAGS } satisfies arg.Spec;\n\nasync function options(rawArgs: string[]): Promise<void> {\n const { flags } = parsedLine(() => parseCommandArgs({\n spec: RLS_OPTIONS_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"rls options\",\n maxPositionals: 0\n }));\n const target = await projectTarget(flags, { command: \"rls options\", defaultCredential: \"person\" });\n const body = await requestJson(target, `${SIMULATOR}/options`, \"Failed to read what can be simulated\");\n emit(() => {\n const roles = recordsOf(isRecord(body) ? body.roles : undefined);\n const keys = recordsOf(isRecord(body) ? body.apiKeys : undefined);\n console.log(chalk.bold(\" Roles\"));\n for (const role of roles) console.log(` ${stringOf(role.id) ?? \"?\"}`);\n console.log(chalk.bold(\" Service keys\"));\n if (keys.length === 0) console.log(chalk.gray(\" none\"));\n for (const key of keys) console.log(` ${stringOf(key.id) ?? \"?\"} ${stringOf(key.name) ?? \"\"} ${chalk.gray(`[${stringOf(key.keyPrefix) ?? \"\"}•••]`)}`);\n }, body);\n}\n\nexport const RLS_SIMULATE_FLAGS = {\n ...PROJECT_TARGET_FLAGS,\n \"--role\": String,\n \"--user\": String,\n \"--key\": String,\n \"--table\": String\n} satisfies arg.Spec;\n\nasync function simulate(rawArgs: string[]): Promise<void> {\n const { flags, simulation } = parsedLine(() => {\n const parsed = parseCommandArgs({\n spec: RLS_SIMULATE_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"rls simulate\",\n maxPositionals: 0\n });\n const given = [parsed.flags[\"--role\"], parsed.flags[\"--user\"], parsed.flags[\"--key\"]].filter(v => v !== undefined);\n if (given.length !== 1) throw new UsageError(\"Name one identity: --role <role>, --user <uid> or --key <api-key-id> (`rebase rls options` lists them).\");\n return {\n flags: parsed.flags,\n simulation: {\n ...(parsed.flags[\"--role\"] ? { role: parsed.flags[\"--role\"] } : {}),\n ...(parsed.flags[\"--user\"] ? { userId: parsed.flags[\"--user\"] } : {}),\n ...(parsed.flags[\"--key\"] ? { apiKeyId: parsed.flags[\"--key\"] } : {})\n }\n };\n });\n const target = await projectTarget(flags, { command: \"rls simulate\", defaultCredential: \"person\" });\n const body = await requestJson(target, `${SIMULATOR}/preview`, \"Failed to simulate\", { method: \"POST\", json: simulation });\n const tables = recordsOf(isRecord(body) ? body.collections : undefined)\n .filter(view => !flags[\"--table\"] || view.slug === flags[\"--table\"]);\n emit(() => {\n const identity = isRecord(body) && isRecord(body.identity) ? body.identity : undefined;\n const who = stringOf(simulation.role) ?? stringOf(simulation.userId) ?? stringOf(simulation.apiKeyId) ?? \"?\";\n const roles = identity && Array.isArray(identity.roles) ? identity.roles.map(String).join(\", \") : \"\";\n console.log(chalk.bold(` As ${who}`) + (roles ? chalk.gray(` roles: ${roles}`) : \"\"));\n if (tables.length === 0) return note(flags[\"--table\"] ? `No table named ${flags[\"--table\"]}.` : \"No tables.\");\n const width = Math.max(5, ...tables.map(view => (stringOf(view.slug) ?? \"\").length));\n for (const view of tables) {\n const slug = stringOf(view.slug) ?? \"?\";\n const hidden = stringOf(view.hiddenBy);\n const visible = typeof view.visibleRows === \"number\" ? view.visibleRows : undefined;\n const total = typeof view.totalRows === \"number\" ? view.totalRows : undefined;\n const rows = hidden === \"scope\"\n ? chalk.gray(\"shut out by the key's scopes\")\n : hidden === \"error\"\n ? chalk.red(`read fails: ${stringOf(view.error) ?? \"unknown error\"}`)\n : `${visible ?? \"?\"} of ${total ?? \"?\"} rows${hidden === \"rls\" ? chalk.yellow(\" (policies hide every row)\") : \"\"}`;\n const masked = Array.isArray(view.maskedColumns) && view.maskedColumns.length > 0\n ? chalk.gray(` cannot read: ${view.maskedColumns.map(String).join(\", \")}`)\n : \"\";\n console.log(` ${slug.padEnd(width)} ${rows}${masked}`);\n }\n }, body);\n}\n\nconst RLS_ACTIONS: HelpAction[] = [\n {\n action: \"simulate\",\n description: \"Per table: the rows an identity reads against yours, scope shut-outs, unreadable columns\",\n flags: [\n [\"--role <role>\", \"Simulate a role (anon for a visitor)\"],\n [\"--user <uid>\", \"Simulate one user, with their live roles\"],\n [\"--key <api-key-id>\", \"Simulate a service key, with its scopes\"],\n [\"--table <slug>\", \"Only this table\"]\n ]\n },\n { action: \"options\", description: \"The roles and service keys there are to simulate\" }\n];\n\nfunction printRlsHelp(): void {\n printProjectHelp({\n command: \"rls\",\n title: \"What another identity would see, under the app's row-level security\",\n actions: RLS_ACTIONS,\n notes: [\n \"The simulator answers an administrator's own session, never a key: sign in first with `rebase auth login`.\",\n \"Example: rebase rls simulate --role anon\",\n \"`rebase verify --live` checks the policies themselves, with no identity in mind.\"\n ]\n });\n}\n"],"mappings":";;;;;;;AAsCA,IAAa,kBAAkB,CAAC,YAAY,SAAS;AAErD,IAAM,YAAY;AAElB,eAAsB,WAAW,YAAgC,SAAkC;CAC/F,oBAAoB,OAAO;CAC3B,IAAI,CAAC,cAAc,eAAe,YAAY,UAAU,OAAO,GAAG;EAC9D,aAAa;EACb;CACJ;CACA,QAAQ,YAAR;EACI,KAAK;GACD,MAAM,SAAS,OAAO;GACtB;EACJ,KAAK;GACD,MAAM,QAAQ,OAAO;GACrB;EACJ,SACI,eAAe,YAAY,iBAAiB,KAAK;CACzD;AACJ;AAEA,IAAa,oBAAoB,EAAE,GAAG,qBAAqB;AAE3D,eAAe,QAAQ,SAAkC;CACrD,MAAM,EAAE,UAAU,iBAAiB,iBAAiB;EAChD,MAAM;EACN;EACA,cAAc;EACd,SAAS;EACT,gBAAgB;CACpB,CAAC,CAAC;CAEF,MAAM,OAAO,MAAM,YAAY,MADV,cAAc,OAAO;EAAE,SAAS;EAAe,mBAAmB;CAAS,CAAC,GAC1D,GAAG,UAAU,WAAW,sCAAsC;CACrG,WAAW;EACP,MAAM,QAAQ,UAAU,SAAS,IAAI,IAAI,KAAK,QAAQ,KAAA,CAAS;EAC/D,MAAM,OAAO,UAAU,SAAS,IAAI,IAAI,KAAK,UAAU,KAAA,CAAS;EAChE,QAAQ,IAAI,MAAM,KAAK,SAAS,CAAC;EACjC,KAAK,MAAM,QAAQ,OAAO,QAAQ,IAAI,OAAO,SAAS,KAAK,EAAE,KAAK,KAAK;EACvE,QAAQ,IAAI,MAAM,KAAK,gBAAgB,CAAC;EACxC,IAAI,KAAK,WAAW,GAAG,QAAQ,IAAI,MAAM,KAAK,UAAU,CAAC;EACzD,KAAK,MAAM,OAA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;CACI,QAAQ;CACR,aAAa;CACb,OAAO;EACH,CAAC,iBAAiB,sCAAsC;EACxD,CAAC,gBAAgB,0CAA0C;EAC3D,CAAC,sBAAsB,yCAAyC;EAChE,CAAC,kBAAkB,iBAAiB;CACxC;AACJ,GACA;CAAE,QAAQ;CAAW,aAAa;AAAmD,CACzF;AAEA,SAAS,eAAqB;CAC1B,iBAAiB;EACb,SAAS;EACT,OAAO;EACP,SAAS;EACT,OAAO;GACH;GACA;GACA;EACJ;CACJ,CAAC;AACL"}
1
+ {"version":3,"file":"rls-BxWLfEKl.js","names":[],"sources":["../src/commands/rls.ts"],"sourcesContent":["/**\n * CLI command: rebase rls <action>\n *\n * What another identity would see: the app's RLS simulator\n * (`/api/admin/rls-simulator`), the one Studio's \"view as\" uses. For a role,\n * a user or a service key it answers, table by table, how many rows that\n * identity reads against how many you read, which tables its scopes shut it\n * out of, and which columns it cannot read. Read-only: nothing is written.\n *\n * The simulator answers an administrator's own session, never a key — a\n * machine credential could otherwise borrow anyone's view. So this command\n * sends the session `rebase auth login` stored for the server, and says so\n * when there is none.\n *\n * `rebase verify --live` is the static half: policies checked against the\n * schema with no identity in mind.\n */\nimport type arg from \"arg\";\nimport chalk from \"chalk\";\n\nimport { parseCommandArgs, UsageError, wantsHelp } from \"../utils/args\";\nimport { unknownCommand } from \"../utils/unknown-command\";\nimport { PROJECT_TARGET_FLAGS } from \"../utils/project-target\";\nimport {\n emit,\n isRecord,\n parsedLine,\n printProjectHelp,\n projectTarget,\n recordsOf,\n requestJson,\n startProjectCommand,\n stringOf,\n type HelpAction\n} from \"../utils/project-command\";\nimport { note } from \"./cloud/context\";\n\n/** Everything the switch below dispatches, for the did-you-mean. */\nexport const RLS_SUBCOMMANDS = [\"simulate\", \"options\"] as const;\n\nconst SIMULATOR = \"/api/admin/rls-simulator\";\n\nexport async function rlsCommand(subcommand: string | undefined, rawArgs: string[]): Promise<void> {\n startProjectCommand(rawArgs);\n if (!subcommand || subcommand === \"--help\" || wantsHelp(rawArgs)) {\n printRlsHelp();\n return;\n }\n switch (subcommand) {\n case \"simulate\":\n await simulate(rawArgs);\n break;\n case \"options\":\n await options(rawArgs);\n break;\n default:\n unknownCommand(subcommand, RLS_SUBCOMMANDS, \"rls\");\n }\n}\n\nexport const RLS_OPTIONS_FLAGS = { ...PROJECT_TARGET_FLAGS } satisfies arg.Spec;\n\nasync function options(rawArgs: string[]): Promise<void> {\n const { flags } = parsedLine(() => parseCommandArgs({\n spec: RLS_OPTIONS_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"rls options\",\n maxPositionals: 0\n }));\n const target = await projectTarget(flags, { command: \"rls options\", defaultCredential: \"person\" });\n const body = await requestJson(target, `${SIMULATOR}/options`, \"Failed to read what can be simulated\");\n emit(() => {\n const roles = recordsOf(isRecord(body) ? body.roles : undefined);\n const keys = recordsOf(isRecord(body) ? body.apiKeys : undefined);\n console.log(chalk.bold(\" Roles\"));\n for (const role of roles) console.log(` ${stringOf(role.id) ?? \"?\"}`);\n console.log(chalk.bold(\" Service keys\"));\n if (keys.length === 0) console.log(chalk.gray(\" none\"));\n for (const key of keys) console.log(` ${stringOf(key.id) ?? \"?\"} ${stringOf(key.name) ?? \"\"} ${chalk.gray(`[${stringOf(key.keyPrefix) ?? \"\"}•••]`)}`);\n }, body);\n}\n\nexport const RLS_SIMULATE_FLAGS = {\n ...PROJECT_TARGET_FLAGS,\n \"--role\": String,\n \"--user\": String,\n \"--key\": String,\n \"--table\": String\n} satisfies arg.Spec;\n\nasync function simulate(rawArgs: string[]): Promise<void> {\n const { flags, simulation } = parsedLine(() => {\n const parsed = parseCommandArgs({\n spec: RLS_SIMULATE_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"rls simulate\",\n maxPositionals: 0\n });\n const given = [parsed.flags[\"--role\"], parsed.flags[\"--user\"], parsed.flags[\"--key\"]].filter(v => v !== undefined);\n if (given.length !== 1) throw new UsageError(\"Name one identity: --role <role>, --user <uid> or --key <api-key-id> (`rebase rls options` lists them).\");\n return {\n flags: parsed.flags,\n simulation: {\n ...(parsed.flags[\"--role\"] ? { role: parsed.flags[\"--role\"] } : {}),\n ...(parsed.flags[\"--user\"] ? { userId: parsed.flags[\"--user\"] } : {}),\n ...(parsed.flags[\"--key\"] ? { apiKeyId: parsed.flags[\"--key\"] } : {})\n }\n };\n });\n const target = await projectTarget(flags, { command: \"rls simulate\", defaultCredential: \"person\" });\n const body = await requestJson(target, `${SIMULATOR}/preview`, \"Failed to simulate\", { method: \"POST\", json: simulation });\n const tables = recordsOf(isRecord(body) ? body.collections : undefined)\n .filter(view => !flags[\"--table\"] || view.slug === flags[\"--table\"]);\n emit(() => {\n const identity = isRecord(body) && isRecord(body.identity) ? body.identity : undefined;\n const who = stringOf(simulation.role) ?? stringOf(simulation.userId) ?? stringOf(simulation.apiKeyId) ?? \"?\";\n const roles = identity && Array.isArray(identity.roles) ? identity.roles.map(String).join(\", \") : \"\";\n console.log(chalk.bold(` As ${who}`) + (roles ? chalk.gray(` roles: ${roles}`) : \"\"));\n if (tables.length === 0) return note(flags[\"--table\"] ? `No table named ${flags[\"--table\"]}.` : \"No tables.\");\n const width = Math.max(5, ...tables.map(view => (stringOf(view.slug) ?? \"\").length));\n for (const view of tables) {\n const slug = stringOf(view.slug) ?? \"?\";\n const hidden = stringOf(view.hiddenBy);\n const visible = typeof view.visibleRows === \"number\" ? view.visibleRows : undefined;\n const total = typeof view.totalRows === \"number\" ? view.totalRows : undefined;\n const rows = hidden === \"scope\"\n ? chalk.gray(\"shut out by the key's scopes\")\n : hidden === \"error\"\n ? chalk.red(`read fails: ${stringOf(view.error) ?? \"unknown error\"}`)\n : `${visible ?? \"?\"} of ${total ?? \"?\"} rows${hidden === \"rls\" ? chalk.yellow(\" (policies hide every row)\") : \"\"}`;\n const masked = Array.isArray(view.maskedColumns) && view.maskedColumns.length > 0\n ? chalk.gray(` cannot read: ${view.maskedColumns.map(String).join(\", \")}`)\n : \"\";\n console.log(` ${slug.padEnd(width)} ${rows}${masked}`);\n }\n }, body);\n}\n\nconst RLS_ACTIONS: HelpAction[] = [\n {\n action: \"simulate\",\n description: \"Per table: the rows an identity reads against yours, scope shut-outs, unreadable columns\",\n flags: [\n [\"--role <role>\", \"Simulate a role (anon for a visitor)\"],\n [\"--user <uid>\", \"Simulate one user, with their live roles\"],\n [\"--key <api-key-id>\", \"Simulate a service key, with its scopes\"],\n [\"--table <slug>\", \"Only this table\"]\n ]\n },\n { action: \"options\", description: \"The roles and service keys there are to simulate\" }\n];\n\nfunction printRlsHelp(): void {\n printProjectHelp({\n command: \"rls\",\n title: \"What another identity would see, under the app's row-level security\",\n actions: RLS_ACTIONS,\n notes: [\n \"The simulator answers an administrator's own session, never a key: sign in first with `rebase auth login`.\",\n \"Example: rebase rls simulate --role anon\",\n \"`rebase verify --live` checks the policies themselves, with no identity in mind.\"\n ]\n });\n}\n"],"mappings":";;;;;;;AAsCA,IAAa,kBAAkB,CAAC,YAAY,SAAS;AAErD,IAAM,YAAY;AAElB,eAAsB,WAAW,YAAgC,SAAkC;CAC/F,oBAAoB,OAAO;CAC3B,IAAI,CAAC,cAAc,eAAe,YAAY,UAAU,OAAO,GAAG;EAC9D,aAAa;EACb;CACJ;CACA,QAAQ,YAAR;EACI,KAAK;GACD,MAAM,SAAS,OAAO;GACtB;EACJ,KAAK;GACD,MAAM,QAAQ,OAAO;GACrB;EACJ,SACI,eAAe,YAAY,iBAAiB,KAAK;CACzD;AACJ;AAEA,IAAa,oBAAoB,EAAE,GAAG,qBAAqB;AAE3D,eAAe,QAAQ,SAAkC;CACrD,MAAM,EAAE,UAAU,iBAAiB,iBAAiB;EAChD,MAAM;EACN;EACA,cAAc;EACd,SAAS;EACT,gBAAgB;CACpB,CAAC,CAAC;CAEF,MAAM,OAAO,MAAM,YAAY,MADV,cAAc,OAAO;EAAE,SAAS;EAAe,mBAAmB;CAAS,CAAC,GAC1D,GAAG,UAAU,WAAW,sCAAsC;CACrG,WAAW;EACP,MAAM,QAAQ,UAAU,SAAS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AClE,GAAG,WAAW,IAAI,MAAM,SAAS,IAAI,OAAO,WAAW,QAAQ,MAAM,OAAO,6BAA6B,IAAI;GACvH,MAAM,SAAS,MAAM,QAAQ,KAAK,aAAa,KAAK,KAAK,cAAc,SAAS,IAC1E,MAAM,KAAK,kBAAkB,KAAK,cAAc,IAAI,MAAM,CAAC,CAAC,KAAK,IAAI,GAAG,IACxE;GACN,QAAQ,IAAI,KAAK,KAAK,OAAO,KAAK,EAAE,IAAI,OAAO,QAAQ;EAC3D;CACJ,GAAG,IAAI;AACX;AAEA,IAAM,cAA4B,CAC9B;CACI,QAAQ;CACR,aAAa;CACb,OAAO;EACH,CAAC,iBAAiB,sCAAsC;EACxD,CAAC,gBAAgB,0CAA0C;EAC3D,CAAC,sBAAsB,yCAAyC;EAChE,CAAC,kBAAkB,iBAAiB;CACxC;AACJ,GACA;CAAE,QAAQ;CAAW,aAAa;AAAmD,CACzF;AAEA,SAAS,eAAqB;CAC1B,iBAAiB;EACb,SAAS;EACT,OAAO;EACP,SAAS;EACT,OAAO;GACH;GACA;GACA;EACJ;CACJ,CAAC;AACL"}
@@ -4,8 +4,8 @@ import { a as wantsHelp, t as UsageError } from "./args-DHyrshtI.js";
4
4
  import { f as requireBackendDir, h as resolvePluginCliScript, l as getActiveBackendPlugin, o as findEnvFile, p as requireProjectRoot, r as exitDependenciesNotInstalled } from "./project-DALmhb5R.js";
5
5
  import { r as schemaDirArgs } from "./schema-dir-ChcYfWjP.js";
6
6
  import { a as refuseRemovedCollectionsFlag, i as refuseMissingSchemaDir, n as SCHEMA_DIR_FLAG_HELP } from "./path-flags-ekLdkbra.js";
7
- import { a as projectTarget, d as PROJECT_TARGET_FLAGS } from "./project-command-Cl9EZzjr.js";
8
- import { n as describeFailure } from "./api-keys-fPQ55DCm.js";
7
+ import { a as projectTarget, d as PROJECT_TARGET_FLAGS } from "./project-command-7EGMemEy.js";
8
+ import { n as describeFailure } from "./api-keys-DaWN8dyI.js";
9
9
  import { DEV_DATABASE_KIND_ENV, devDatabaseKind, managedNotices, prepareDatabaseEnv } from "./prepare-BaJe0Zik.js";
10
10
  import { absolutizeLocalPathArgs, ensureDockerDatabase, n as argsFromCommand, spawnDriverCli, t as reportSpawnFailure } from "./db-D_iF4E-v.js";
11
11
  import chalk from "chalk";
@@ -184,14 +184,14 @@ async function schemaCommand(subcommand, rawArgs) {
184
184
  if (!SCHEMA_ACTION_HELP[subcommand]) unknownCommand(subcommand, Object.keys(SCHEMA_ACTION_HELP), "schema");
185
185
  refuseRemovedCollectionsFlag(rawArgs.slice(2), `schema ${subcommand}`);
186
186
  if (subcommand === "show") {
187
- const { schemaShowCommand } = await import("./schema-show-h72UJ9zH.js");
187
+ const { schemaShowCommand } = await import("./schema-show-C7bY7SgE.js");
188
188
  await schemaShowCommand(rawArgs);
189
189
  return;
190
190
  }
191
191
  const projectRoot = requireProjectRoot();
192
192
  if (subcommand === "reconcile") {
193
193
  recordEvent("cli.schema", { subcommand }, { projectRoot });
194
- const { schemaReconcileCommand } = await import("./schema-reconcile-DV14XY4o.js");
194
+ const { schemaReconcileCommand } = await import("./schema-reconcile-D_wvZY91.js");
195
195
  await schemaReconcileCommand(rawArgs);
196
196
  return;
197
197
  }
@@ -249,7 +249,7 @@ var SCHEMA_ACTION_HELP = {
249
249
  notes: ["--watch regenerates on every change to a schema file.", `--schema-dir <dir>: ${SCHEMA_DIR_FLAG_HELP}.`]
250
250
  },
251
251
  introspect: {
252
- usage: "rebase schema introspect [--schema-dir <dir>] [--schema <name>] [--force] [--data-inference | --no-data-inference]",
252
+ usage: "rebase schema introspect [--schema-dir <dir>] [--schema <name>] [--force] [--from supabase] [--data-inference | --no-data-inference]",
253
253
  summary: "Read an existing database and write its tables as defineTable modules into backend/schema.",
254
254
  notes: [
255
255
  "--force overwrites table modules that are already there.",
@@ -327,6 +327,7 @@ ${chalk.green.bold("introspect Options")}
327
327
  ${chalk.blue("--docker")} Read the compose database, starting it if needed
328
328
  ${chalk.blue("--data-inference")} Sample rows to detect formats and constraints ${chalk.gray("(asked when omitted)")}
329
329
  ${chalk.blue("--no-data-inference")} Read the structure only, without asking
330
+ ${chalk.blue("--from supabase")} Translate Supabase's auth.uid(), auth.users and anon/authenticated for a Rebase database
330
331
 
331
332
  ${chalk.green.bold("stale Options")}
332
333
  ${chalk.blue("--fix")} Regenerate the stale files instead of only reporting them
@@ -335,4 +336,4 @@ ${chalk.green.bold("stale Options")}
335
336
  //#endregion
336
337
  export { SCHEMA_SUBCOMMANDS, schemaReconcileCommand as i, describeReconcilePlan as n, parseReconcileArgs as r, schemaCommand, RECONCILE_USAGE as t };
337
338
 
338
- //# sourceMappingURL=schema-_FzZEoB8.js.map
339
+ //# sourceMappingURL=schema-D8xFSBbN.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-_FzZEoB8.js","names":[],"sources":["../src/commands/schema-reconcile.ts","../src/commands/schema.ts"],"sourcesContent":["/**\n * CLI command: rebase schema reconcile\n *\n * The reviewed step for what boot will not do. Boot only ever adds, so a\n * column made nullable keeps its NOT NULL, and a column removed from a table\n * leaves it behind, with its data, and blocking inserts if it was\n * required. This asks the running backend for the plan that fixes both, prints\n * it, and applies it only once confirmed.\n *\n * Through the backend rather than a database URL, because on Rebase Cloud the\n * backend is the one thing that can reach the database — and because it plans\n * against the tables it actually runs, not the ones in this checkout.\n * Columns are dropped only when named with `--drop`; the confirmation sends\n * the plan's digest, so the server runs exactly the statements printed here.\n */\nimport arg from \"arg\";\nimport chalk from \"chalk\";\nimport readline from \"node:readline/promises\";\nimport { RebaseApiError } from \"@rebasepro/client\";\nimport type { SchemaReconcilePlan } from \"@rebasepro/types\";\nimport { PROJECT_TARGET_FLAGS } from \"../utils/project-target\";\nimport { projectTarget } from \"../utils/project-command\";\nimport { UsageError } from \"../utils/args\";\nimport { describeFailure } from \"./api-keys\";\n\nexport const RECONCILE_USAGE = \"rebase schema reconcile [--drop <table>.<column>]... [--yes] [--url <server> | --project <slug>]\";\n\n/** The flags `schema reconcile` takes: `--drop` and every project command's target flags. */\nconst RECONCILE_FLAGS = { ...PROJECT_TARGET_FLAGS, \"--drop\": [String] } satisfies arg.Spec;\n\nexport function parseReconcileArgs(rawArgs: string[]): { drop: string[]; yes: boolean; target: Record<string, unknown> } {\n const flags = arg(RECONCILE_FLAGS, { argv: rawArgs.slice(2) });\n if (flags._.length > 0) throw new UsageError(`Unexpected argument \"${flags._[0]}\". Usage: ${RECONCILE_USAGE}`);\n return { drop: flags[\"--drop\"] ?? [], yes: flags[\"--yes\"] === true, target: flags };\n}\n\n/** The plan, as a person reviews it. Returned as lines so it can be tested. */\nexport function describeReconcilePlan(plan: SchemaReconcilePlan): string[] {\n const lines: string[] = [];\n for (const r of plan.relaxed) {\n const why = r.undeclared\n ? `\"${r.collection}\" does not declare it, and every insert fails on it; its data stays`\n : `nullable in \"${r.collection}\", NOT NULL in the database`;\n lines.push(` ${chalk.cyan(\"relax\")} ${r.table}.${r.column} ${chalk.gray(why)}`);\n }\n for (const d of plan.dropped) {\n const rows = d.rowsWithValue === undefined ? \"\" : `${d.rowsWithValue.toLocaleString(\"en-US\")} row(s) hold a value`;\n lines.push(` ${chalk.red(\"drop\")} ${d.table}.${d.column} ${chalk.red(rows)}`);\n }\n const kept = plan.undeclared.filter(u =>\n !plan.dropped.some(d => d.table === u.table && d.column === u.column)\n && !plan.relaxed.some(r => r.undeclared && r.table === u.table && r.column === u.column));\n for (const u of kept) {\n const note = u.blocksInserts\n ? chalk.yellow(\"NOT NULL with no default: every insert fails until it is dropped or relaxed\")\n : chalk.gray(\"no table declares it; kept\");\n lines.push(` ${chalk.gray(\"keep\")} ${u.table}.${u.column} ${note}`);\n }\n return lines;\n}\n\ninterface Backend {\n baseUrl: string;\n post<T>(path: string, body: unknown): Promise<T>;\n}\n\n/**\n * The project's backend, holding the service key — or the credential the\n * target flags name (`--url`, `--project`, …), as every project command\n * resolves it.\n *\n * Applying runs as a machine on purpose: the reconcile route takes the\n * service key, and its plan's digest is the confirmation (see\n * `api/live-schema-routes.ts`, which pins that decision).\n */\nasync function connect(flags: Readonly<Record<string, unknown>>): Promise<Backend> {\n const target = await projectTarget(flags, { command: \"schema reconcile\" });\n return {\n baseUrl: target.label,\n async post<T>(path: string, body: unknown): Promise<T> {\n let response: Response;\n try {\n response = await target.request(`/api/admin/schema/reconcile${path}`, { method: \"POST\", json: body });\n } catch (error: unknown) {\n throw new RebaseApiError(error instanceof Error ? error.message : String(error), { status: 0, code: \"NETWORK_ERROR\" });\n }\n const answer: unknown = await response.json().catch(() => undefined);\n if (!response.ok) {\n const error = answer && typeof answer === \"object\" && \"error\" in answer && answer.error && typeof answer.error === \"object\"\n ? answer.error as { message?: unknown; code?: unknown; details?: unknown }\n : undefined;\n throw new RebaseApiError(\n typeof error?.message === \"string\" ? error.message : `The server answered ${response.status}.`,\n { status: response.status, code: typeof error?.code === \"string\" ? error.code : undefined, details: error?.details }\n );\n }\n return answer as T;\n }\n };\n}\n\nfunction fail(action: string, error: unknown, baseUrl: string): never {\n for (const line of describeFailure(action, error, baseUrl)) {\n console.error(line.startsWith(\"✗\") ? chalk.red(line) : chalk.gray(line));\n }\n if (error instanceof RebaseApiError && error.status === 404) {\n console.error(chalk.gray(\" This backend has no reconcile route: it needs a runtime that has `rebase schema reconcile`.\"));\n }\n process.exit(1);\n}\n\nexport async function schemaReconcileCommand(rawArgs: string[]): Promise<void> {\n const { drop, yes, target } = parseReconcileArgs(rawArgs);\n const backend = await connect(target);\n\n let plan: SchemaReconcilePlan;\n try {\n plan = await backend.post<SchemaReconcilePlan>(\"/plan\", { drop });\n } catch (error) {\n fail(\"Failed to plan the reconcile\", error, backend.baseUrl);\n }\n\n console.log(chalk.bold(`\\nSchema reconcile for ${backend.baseUrl}\\n`));\n const described = describeReconcilePlan(plan);\n if (described.length > 0) console.log(described.join(\"\\n\"));\n\n if (plan.problems.length > 0) {\n console.error(chalk.red(\"\\n✗ This plan cannot be applied:\"));\n for (const problem of plan.problems) console.error(chalk.red(` • ${problem}`));\n process.exit(1);\n }\n if (plan.statements.length === 0) {\n console.log(chalk.green(\"✓ Nothing to do: the database already matches what the tables declare.\"));\n }\n if (plan.undeclared.length > plan.dropped.length) {\n console.log(chalk.gray(\" To drop a column no table declares, name it: --drop <table>.<column>\"));\n }\n if (plan.statements.length === 0) return;\n\n console.log(chalk.bold(\"\\nStatements\"));\n for (const statement of plan.statements) console.log(` ${statement}`);\n if (plan.dropped.length > 0) {\n console.log(chalk.red(\"\\n Dropping a column destroys its data. Back the database up first if you may want it back.\"));\n }\n\n if (!yes) {\n if (!process.stdin.isTTY) {\n console.error(chalk.red(\"\\n✗ Not applied: confirming needs a terminal. Re-run with --yes once you have read the plan.\"));\n process.exit(1);\n }\n const rl = readline.createInterface({ input: process.stdin, output: process.stdout });\n const answer = (await rl.question(`\\nApply ${plan.statements.length} statement(s)? Type \"yes\" to continue: `)).trim();\n rl.close();\n if (answer !== \"yes\") {\n console.log(chalk.gray(\"Aborted. Nothing was changed.\"));\n return;\n }\n }\n\n try {\n const result = await backend.post<{ applied: string[] }>(\"/apply\", { drop, confirm: plan.digest });\n console.log(chalk.green(`✓ Applied ${result.applied.length} statement(s).`));\n } catch (error) {\n if (error instanceof RebaseApiError && error.code === \"SCHEMA_RECONCILE_STALE\") {\n console.error(chalk.red(\"✗ Not applied: the database or the tables changed since this plan was made. Run it again to review the new plan.\"));\n process.exit(1);\n }\n fail(\"Failed to apply the reconcile\", error, backend.baseUrl);\n }\n}\n","/**\n * CLI command: rebase schema <action>\n */\nimport arg from \"arg\";\nimport chalk from \"chalk\";\nimport { ensureDockerDatabase, spawnDriverCli } from \"./db\";\nimport {\n requireProjectRoot,\n requireBackendDir,\n getActiveBackendPlugin,\n resolvePluginCliScript,\n resolveTsx,\n findEnvFile,\n exitDependenciesNotInstalled\n} from \"../utils/project\";\nimport { recordEvent } from \"../telemetry\";\nimport { wantsHelp } from \"../utils/args\";\nimport { reportSpawnFailure } from \"../utils/spawn-error\";\nimport { argsFromCommand } from \"../utils/command-words\";\nimport { unknownCommand } from \"../utils/unknown-command\";\nimport { DEV_DATABASE_KIND_ENV, devDatabaseKind, managedNotices, prepareDatabaseEnv } from \"../dev-db/prepare\";\nimport { absolutizeLocalPathArgs } from \"./db\";\nimport { SCHEMA_DIR_FLAG_HELP, refuseMissingSchemaDir, refuseRemovedCollectionsFlag } from \"../utils/path-flags\";\nimport { schemaDirArgs } from \"../utils/schema-dir\";\nimport { RECONCILE_USAGE } from \"./schema-reconcile\";\n\n/**\n * The line handed to the driver, its paths resolved from where the command was\n * run (the driver runs in `backend/`). `--schema` is left alone: on\n * `introspect` it names a Postgres schema, not a file.\n */\nexport function schemaDriverArgs(rawArgs: string[], cwd: string): string[] {\n return absolutizeLocalPathArgs(argsFromCommand(rawArgs, \"schema\"), cwd, [\"--schema-dir\", \"--output\", \"-o\", \"--out\"]);\n}\n\nexport async function schemaCommand(subcommand: string | undefined, rawArgs: string[]): Promise<void> {\n // `--help` is answered here, before `requireProjectRoot` and before the\n // driver is spawned — the same shape `db.ts` already uses, and for the same\n // reason.\n //\n // `cli.ts` rewrites the subcommand to `\"--help\"` only when the user named\n // none, so `rebase schema --help` was covered and `rebase schema generate\n // --help` was not: the flag travelled into `rawArgs.slice(2)` and reached\n // the driver, whose own `schemaCommand` has no `--help` case. It *ran the\n // generator* — overwriting `src/schema.generated.ts` — for a flag whose\n // entire job is to print text. Worse, the first thing it hit outside a\n // project was `requireProjectRoot`, so `rebase schema introspect --help` in\n // an empty directory exited 1 with \"Could not find a Rebase project root\":\n // help you cannot read until you already have a project is help for nobody.\n if (!subcommand || subcommand === \"--help\" || wantsHelp(rawArgs)) {\n printSchemaHelp(subcommand === \"--help\" ? undefined : subcommand);\n return;\n }\n\n // A typo is answered here, in the same words every other family uses.\n //\n // It used to travel to the driver, which said the bare line `Unknown schema\n // command.` — no list, no pointer, no did-you-mean, for a family with three\n // subcommands. The set comes from the help table, so what a typo is measured\n // against and what `--help` prints cannot drift apart.\n if (!SCHEMA_ACTION_HELP[subcommand]) {\n unknownCommand(subcommand, Object.keys(SCHEMA_ACTION_HELP), \"schema\");\n }\n\n // Before anything else runs.\n refuseRemovedCollectionsFlag(rawArgs.slice(2), `schema ${subcommand}`);\n\n // Reads the local tables or a running server's description of them; with a\n // target flag it needs no project at all.\n if (subcommand === \"show\") {\n const { schemaShowCommand } = await import(\"./schema-show\");\n await schemaShowCommand(rawArgs);\n return;\n }\n\n const projectRoot = requireProjectRoot();\n\n // Talks to the running backend, not the driver: on Rebase Cloud the\n // backend is the only thing that reaches the database.\n if (subcommand === \"reconcile\") {\n void recordEvent(\"cli.schema\", { subcommand }, { projectRoot });\n const { schemaReconcileCommand } = await import(\"./schema-reconcile\");\n await schemaReconcileCommand(rawArgs);\n return;\n }\n\n // Fire-and-forget, and a no-op unless the developer opted in. Never awaited:\n // the command is what the user is waiting for, and a slow collector must not\n // sit in front of it.\n void recordEvent(\"cli.schema\", { subcommand: subcommand ?? \"none\" }, { projectRoot });\n const backendDir = requireBackendDir(projectRoot);\n\n const activePlugin = getActiveBackendPlugin(backendDir);\n if (!activePlugin) {\n console.error(chalk.red(\"✗ Could not detect an active database plugin.\"));\n console.error(chalk.gray(\" Make sure a package like @rebasepro/server-postgres is installed in backend/package.json.\"));\n process.exit(1);\n }\n\n const pluginCli = resolvePluginCliScript(backendDir, activePlugin);\n if (!pluginCli) {\n exitDependenciesNotInstalled(projectRoot);\n }\n\n // Set up environment with DOTENV_CONFIG_PATH\n const envFile = findEnvFile(projectRoot);\n const env: Record<string, string> = { ...process.env as Record<string, string> };\n if (envFile) {\n env.DOTENV_CONFIG_PATH = envFile;\n }\n // Which database this project is on, so the driver's closing line does not\n // recommend a command that database refuses. A pure decision — nothing is\n // started, which matters here above all: `schema generate` reads the\n // schema directory and writes one file, and booting a database to run it would be a\n // side effect nobody asked for.\n env[DEV_DATABASE_KIND_ENV] = devDatabaseKind(projectRoot) ?? \"\";\n\n refuseMissingSchemaDir(rawArgs, process.cwd(), backendDir);\n\n // `introspect` is the one schema command that reads a database, and it\n // reads the project's — resolved the way every `db` command resolves it,\n // started if that is what it takes. It used to pass `.env` and nothing\n // else, so on the managed database or after `rebase dev --docker` (with\n // the scaffold's DATABASE_URL commented out, on purpose) it said\n // \"DATABASE_URL is not set\", and `--docker` and `--database-url` passed the\n // flag check only to be ignored.\n if (subcommand === \"introspect\") {\n const flags = arg(\n { \"--database-url\": String, \"--docker\": Boolean },\n { argv: rawArgs.slice(2), permissive: true }\n );\n await ensureDockerDatabase(projectRoot, rawArgs);\n const prepared = await prepareDatabaseEnv(projectRoot, {\n flagUrl: flags[\"--database-url\"] ?? null,\n flagDocker: flags[\"--docker\"] === true,\n onProgress: (message) => console.log(chalk.gray(` ${message}`))\n });\n Object.assign(env, prepared.env);\n env[DEV_DATABASE_KIND_ENV] = prepared.database.kind;\n for (const line of managedNotices(prepared)) console.log(chalk.gray(` ${line}`));\n }\n\n try {\n // The one spawn, shared with `db`. This file used to carry its own copy\n // of the tsx-or-node decision; three copies of that rule existed and two\n // were fixed while the third went on spawning plain node.\n const driverArgs = schemaDriverArgs(rawArgs, process.cwd());\n await spawnDriverCli(\n { projectRoot, backendDir, pluginCli, env },\n [...driverArgs, ...schemaDirArgs(projectRoot, driverArgs)]\n );\n } catch (error) {\n // A child that ran and exited non-zero already printed its diagnostics\n // through inherited stdio; a child that never started (ENOENT on tsx,\n // EACCES on the script) printed nothing at all, and this used to exit 1\n // in silence.\n reportSpawnFailure(error);\n process.exit(1);\n }\n}\n\n/** One page per subcommand, so `rebase schema <action> --help` says something. */\nconst SCHEMA_ACTION_HELP: Record<string, { usage: string; summary: string; notes?: string[] }> = {\n generate: {\n usage: \"rebase schema generate [--schema-dir <dir>] [--output <file>] [--watch]\",\n summary: \"Generate the Drizzle schema from the tables in backend/schema.\",\n notes: [\"--watch regenerates on every change to a schema file.\", `--schema-dir <dir>: ${SCHEMA_DIR_FLAG_HELP}.`]\n },\n introspect: {\n usage: \"rebase schema introspect [--schema-dir <dir>] [--schema <name>] [--force] [--data-inference | --no-data-inference]\",\n summary: \"Read an existing database and write its tables as defineTable modules into backend/schema.\",\n notes: [\n \"--force overwrites table modules that are already there.\",\n `--schema-dir <dir>: where the tables are written — ${SCHEMA_DIR_FLAG_HELP}.`,\n \"--data-inference samples up to 100 rows per table to detect formats, constraints and UI settings; \"\n + \"--no-data-inference reads the structure only. Without either it asks, and without a terminal \"\n + \"it reads the structure only.\",\n \"Reads this project's database, the one `rebase db url` prints: --database-url <url> names another; \"\n + \"--docker uses the compose one, starting it if needed.\"\n ]\n },\n reconcile: {\n usage: RECONCILE_USAGE,\n summary: \"Relax and drop what boot will not: NOT NULL on columns made nullable, and columns no table declares.\",\n notes: [\n \"Plans on the running backend (the one `.env` and the cloud link point at), prints the plan, and applies it once you type yes.\",\n \"A column is dropped only when named: --drop voice_cache.wav. Each drop shows how many rows hold a value.\",\n \"--yes skips the prompt, for a plan already read. Sends REBASE_SERVICE_KEY from .env by default.\",\n \"Target flags: --url <server>, --project <slug> (Rebase Cloud), --cloud, --token <bearer>, --session, --anon, --json.\"\n ]\n },\n show: {\n usage: \"rebase schema show [table] [--remote] [--schema-dir <dir>]\",\n summary: \"The tables, or one table's columns, relations and row-level security.\",\n notes: [\n \"Reads backend/schema by default (--schema-dir <dir> names another directory).\",\n \"--remote asks the running server instead (GET /api/schema/tables): what the API describes to this credential.\",\n \"Target flags imply --remote: --project <slug> (Rebase Cloud), --cloud (the linked project), --url <server>,\",\n \"--token <bearer>, --session (after `rebase auth login`), --anon. --json prints the descriptors; --yes is accepted and unused.\"\n ]\n },\n stale: {\n usage: \"rebase schema stale [--schema-dir <dir>] [--output <file>] [--fix]\",\n summary: \"Report generated schema files that no longer match the tables.\",\n notes: [\"--fix regenerates them instead of only reporting.\"]\n }\n};\n\n/** Every subcommand the family dispatches — the help table's keys. */\nexport const SCHEMA_SUBCOMMANDS = Object.keys(SCHEMA_ACTION_HELP);\n\nfunction printSchemaHelp(action?: string) {\n const entry = action ? SCHEMA_ACTION_HELP[action] : undefined;\n if (entry) {\n console.log(`\n${chalk.bold(`rebase schema ${action}`)}\n\n ${entry.summary}\n\n${chalk.green.bold(\"Usage\")}\n ${chalk.blue(entry.usage)}\n${entry.notes?.length ? `\\n${chalk.green.bold(\"Notes\")}\\n${entry.notes.map(n => ` ${chalk.gray(`• ${n}`)}`).join(\"\\n\")}\\n` : \"\"}\n${chalk.gray(\"Run `rebase schema --help` for every subcommand.\")}\n`);\n return;\n }\n\n console.log(`\n${chalk.bold(\"rebase schema\")} — Schema management commands\n\n${chalk.green.bold(\"Usage\")}\n rebase schema ${chalk.blue(\"<command>\")} [options]\n\n${chalk.green.bold(\"Commands\")}\n ${chalk.gray(\"(Commands are provided by your active database driver plugin)\")}\n ${chalk.blue.bold(\"generate\")} Generate the Drizzle schema from the tables in backend/schema\n ${chalk.blue.bold(\"introspect\")} Introspect an existing database into defineTable modules in backend/schema\n ${chalk.blue.bold(\"stale\")} Report generated schema files that no longer match the tables\n ${chalk.blue.bold(\"reconcile\")} Relax NOT NULL and drop columns the tables no longer declare, after review\n\n${chalk.green.bold(\"generate / stale Options\")}\n ${chalk.blue(\"--schema-dir\")} ${SCHEMA_DIR_FLAG_HELP}\n ${chalk.blue(\"--output, -o\")} Output path for generated schema\n ${chalk.blue(\"--watch, -w\")} Watch for changes and regenerate automatically\n\n${chalk.green.bold(\"introspect Options\")}\n ${chalk.blue(\"--schema-dir\")} Where the tables are written ${chalk.gray(\"(default: backend/schema)\")}\n ${chalk.blue(\"--schema\")} Postgres schema to read (default: public)\n ${chalk.blue(\"--force, -f\")} Overwrite table modules that already exist\n ${chalk.blue(\"--database-url\")} Read this database instead of the project's own\n ${chalk.blue(\"--docker\")} Read the compose database, starting it if needed\n ${chalk.blue(\"--data-inference\")} Sample rows to detect formats and constraints ${chalk.gray(\"(asked when omitted)\")}\n ${chalk.blue(\"--no-data-inference\")} Read the structure only, without asking\n\n${chalk.green.bold(\"stale Options\")}\n ${chalk.blue(\"--fix\")} Regenerate the stale files instead of only reporting them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EAAE;kBACV,MAAM,KAAK,WAAW,EAAE;;EAExC,MAAM,MAAM,KAAK,UAAU,EAAE;IAC3B,MAAM,KAAK,+DAA+D,EAAE;IAC5E,MAAM,KAAK,KAAK,UAAU,EAAE;IAC5B,MAAM,KAAK,KAAK,YAAY,EAAE;IAC9B,MAAM,KAAK,KAAK,OAAO,EAAE;IACzB,MAAM,KAAK,KAAK,WAAW,EAAE;;EAE/B,MAAM,MAAM,KAAK,0BAA0B,EAAE;IAC3C,MAAM,KAAK,cAAc,EAAE,SAAS,qBAAqB;IACzD,MAAM,KAAK,cAAc,EAAE;IAC3B,MAAM,KAAK,aAAa,EAAE;;EAE5B,MAAM,MAAM,KAAK,oBAAoB,EAAE;IACrC,MAAM,KAAK,cAAc,EAAE,sCAAsC,MAAM,KAAK,2BAA2B,EAAE;IACzG,MAAM,KAAK,UAAU,EAAE;IACvB,MAAM,KAAK,aAAa,EAAE;IAC1B,MAAM,KAAK,gBAAgB,EAAE;IAC7B,MAAM,KAAK,UAAU,EAAE;IACvB,MAAM,KAAK,kBAAkB,EAAE,mDAAmD,MAAM,KAAK,sBAAsB,EAAE;IACrH,MAAM,KAAK,qBAAqB,EAAE;;EAEpC,MAAM,MAAM,KAAK,eAAe,EAAE;IAChC,MAAM,KAAK,OAAO,EAAE;CACvB;AACD"}
1
+ {"version":3,"file":"schema-D8xFSBbN.js","names":[],"sources":["../src/commands/schema-reconcile.ts","../src/commands/schema.ts"],"sourcesContent":["/**\n * CLI command: rebase schema reconcile\n *\n * The reviewed step for what boot will not do. Boot only ever adds, so a\n * column made nullable keeps its NOT NULL, and a column removed from a table\n * leaves it behind, with its data, and blocking inserts if it was\n * required. This asks the running backend for the plan that fixes both, prints\n * it, and applies it only once confirmed.\n *\n * Through the backend rather than a database URL, because on Rebase Cloud the\n * backend is the one thing that can reach the database — and because it plans\n * against the tables it actually runs, not the ones in this checkout.\n * Columns are dropped only when named with `--drop`; the confirmation sends\n * the plan's digest, so the server runs exactly the statements printed here.\n */\nimport arg from \"arg\";\nimport chalk from \"chalk\";\nimport readline from \"node:readline/promises\";\nimport { RebaseApiError } from \"@rebasepro/client\";\nimport type { SchemaReconcilePlan } from \"@rebasepro/types\";\nimport { PROJECT_TARGET_FLAGS } from \"../utils/project-target\";\nimport { projectTarget } from \"../utils/project-command\";\nimport { UsageError } from \"../utils/args\";\nimport { describeFailure } from \"./api-keys\";\n\nexport const RECONCILE_USAGE = \"rebase schema reconcile [--drop <table>.<column>]... [--yes] [--url <server> | --project <slug>]\";\n\n/** The flags `schema reconcile` takes: `--drop` and every project command's target flags. */\nconst RECONCILE_FLAGS = { ...PROJECT_TARGET_FLAGS, \"--drop\": [String] } satisfies arg.Spec;\n\nexport function parseReconcileArgs(rawArgs: string[]): { drop: string[]; yes: boolean; target: Record<string, unknown> } {\n const flags = arg(RECONCILE_FLAGS, { argv: rawArgs.slice(2) });\n if (flags._.length > 0) throw new UsageError(`Unexpected argument \"${flags._[0]}\". Usage: ${RECONCILE_USAGE}`);\n return { drop: flags[\"--drop\"] ?? [], yes: flags[\"--yes\"] === true, target: flags };\n}\n\n/** The plan, as a person reviews it. Returned as lines so it can be tested. */\nexport function describeReconcilePlan(plan: SchemaReconcilePlan): string[] {\n const lines: string[] = [];\n for (const r of plan.relaxed) {\n const why = r.undeclared\n ? `\"${r.collection}\" does not declare it, and every insert fails on it; its data stays`\n : `nullable in \"${r.collection}\", NOT NULL in the database`;\n lines.push(` ${chalk.cyan(\"relax\")} ${r.table}.${r.column} ${chalk.gray(why)}`);\n }\n for (const d of plan.dropped) {\n const rows = d.rowsWithValue === undefined ? \"\" : `${d.rowsWithValue.toLocaleString(\"en-US\")} row(s) hold a value`;\n lines.push(` ${chalk.red(\"drop\")} ${d.table}.${d.column} ${chalk.red(rows)}`);\n }\n const kept = plan.undeclared.filter(u =>\n !plan.dropped.some(d => d.table === u.table && d.column === u.column)\n && !plan.relaxed.some(r => r.undeclared && r.table === u.table && r.column === u.column));\n for (const u of kept) {\n const note = u.blocksInserts\n ? chalk.yellow(\"NOT NULL with no default: every insert fails until it is dropped or relaxed\")\n : chalk.gray(\"no table declares it; kept\");\n lines.push(` ${chalk.gray(\"keep\")} ${u.table}.${u.column} ${note}`);\n }\n return lines;\n}\n\ninterface Backend {\n baseUrl: string;\n post<T>(path: string, body: unknown): Promise<T>;\n}\n\n/**\n * The project's backend, holding the service key — or the credential the\n * target flags name (`--url`, `--project`, …), as every project command\n * resolves it.\n *\n * Applying runs as a machine on purpose: the reconcile route takes the\n * service key, and its plan's digest is the confirmation (see\n * `api/live-schema-routes.ts`, which pins that decision).\n */\nasync function connect(flags: Readonly<Record<string, unknown>>): Promise<Backend> {\n const target = await projectTarget(flags, { command: \"schema reconcile\" });\n return {\n baseUrl: target.label,\n async post<T>(path: string, body: unknown): Promise<T> {\n let response: Response;\n try {\n response = await target.request(`/api/admin/schema/reconcile${path}`, { method: \"POST\", json: body });\n } catch (error: unknown) {\n throw new RebaseApiError(error instanceof Error ? error.message : String(error), { status: 0, code: \"NETWORK_ERROR\" });\n }\n const answer: unknown = await response.json().catch(() => undefined);\n if (!response.ok) {\n const error = answer && typeof answer === \"object\" && \"error\" in answer && answer.error && typeof answer.error === \"object\"\n ? answer.error as { message?: unknown; code?: unknown; details?: unknown }\n : undefined;\n throw new RebaseApiError(\n typeof error?.message === \"string\" ? error.message : `The server answered ${response.status}.`,\n { status: response.status, code: typeof error?.code === \"string\" ? error.code : undefined, details: error?.details }\n );\n }\n return answer as T;\n }\n };\n}\n\nfunction fail(action: string, error: unknown, baseUrl: string): never {\n for (const line of describeFailure(action, error, baseUrl)) {\n console.error(line.startsWith(\"✗\") ? chalk.red(line) : chalk.gray(line));\n }\n if (error instanceof RebaseApiError && error.status === 404) {\n console.error(chalk.gray(\" This backend has no reconcile route: it needs a runtime that has `rebase schema reconcile`.\"));\n }\n process.exit(1);\n}\n\nexport async function schemaReconcileCommand(rawArgs: string[]): Promise<void> {\n const { drop, yes, target } = parseReconcileArgs(rawArgs);\n const backend = await connect(target);\n\n let plan: SchemaReconcilePlan;\n try {\n plan = await backend.post<SchemaReconcilePlan>(\"/plan\", { drop });\n } catch (error) {\n fail(\"Failed to plan the reconcile\", error, backend.baseUrl);\n }\n\n console.log(chalk.bold(`\\nSchema reconcile for ${backend.baseUrl}\\n`));\n const described = describeReconcilePlan(plan);\n if (described.length > 0) console.log(described.join(\"\\n\"));\n\n if (plan.problems.length > 0) {\n console.error(chalk.red(\"\\n✗ This plan cannot be applied:\"));\n for (const problem of plan.problems) console.error(chalk.red(` • ${problem}`));\n process.exit(1);\n }\n if (plan.statements.length === 0) {\n console.log(chalk.green(\"✓ Nothing to do: the database already matches what the tables declare.\"));\n }\n if (plan.undeclared.length > plan.dropped.length) {\n console.log(chalk.gray(\" To drop a column no table declares, name it: --drop <table>.<column>\"));\n }\n if (plan.statements.length === 0) return;\n\n console.log(chalk.bold(\"\\nStatements\"));\n for (const statement of plan.statements) console.log(` ${statement}`);\n if (plan.dropped.length > 0) {\n console.log(chalk.red(\"\\n Dropping a column destroys its data. Back the database up first if you may want it back.\"));\n }\n\n if (!yes) {\n if (!process.stdin.isTTY) {\n console.error(chalk.red(\"\\n✗ Not applied: confirming needs a terminal. Re-run with --yes once you have read the plan.\"));\n process.exit(1);\n }\n const rl = readline.createInterface({ input: process.stdin, output: process.stdout });\n const answer = (await rl.question(`\\nApply ${plan.statements.length} statement(s)? Type \"yes\" to continue: `)).trim();\n rl.close();\n if (answer !== \"yes\") {\n console.log(chalk.gray(\"Aborted. Nothing was changed.\"));\n return;\n }\n }\n\n try {\n const result = await backend.post<{ applied: string[] }>(\"/apply\", { drop, confirm: plan.digest });\n console.log(chalk.green(`✓ Applied ${result.applied.length} statement(s).`));\n } catch (error) {\n if (error instanceof RebaseApiError && error.code === \"SCHEMA_RECONCILE_STALE\") {\n console.error(chalk.red(\"✗ Not applied: the database or the tables changed since this plan was made. Run it again to review the new plan.\"));\n process.exit(1);\n }\n fail(\"Failed to apply the reconcile\", error, backend.baseUrl);\n }\n}\n","/**\n * CLI command: rebase schema <action>\n */\nimport arg from \"arg\";\nimport chalk from \"chalk\";\nimport { ensureDockerDatabase, spawnDriverCli } from \"./db\";\nimport {\n requireProjectRoot,\n requireBackendDir,\n getActiveBackendPlugin,\n resolvePluginCliScript,\n resolveTsx,\n findEnvFile,\n exitDependenciesNotInstalled\n} from \"../utils/project\";\nimport { recordEvent } from \"../telemetry\";\nimport { wantsHelp } from \"../utils/args\";\nimport { reportSpawnFailure } from \"../utils/spawn-error\";\nimport { argsFromCommand } from \"../utils/command-words\";\nimport { unknownCommand } from \"../utils/unknown-command\";\nimport { DEV_DATABASE_KIND_ENV, devDatabaseKind, managedNotices, prepareDatabaseEnv } from \"../dev-db/prepare\";\nimport { absolutizeLocalPathArgs } from \"./db\";\nimport { SCHEMA_DIR_FLAG_HELP, refuseMissingSchemaDir, refuseRemovedCollectionsFlag } from \"../utils/path-flags\";\nimport { schemaDirArgs } from \"../utils/schema-dir\";\nimport { RECONCILE_USAGE } from \"./schema-reconcile\";\n\n/**\n * The line handed to the driver, its paths resolved from where the command was\n * run (the driver runs in `backend/`). `--schema` is left alone: on\n * `introspect` it names a Postgres schema, not a file.\n */\nexport function schemaDriverArgs(rawArgs: string[], cwd: string): string[] {\n return absolutizeLocalPathArgs(argsFromCommand(rawArgs, \"schema\"), cwd, [\"--schema-dir\", \"--output\", \"-o\", \"--out\"]);\n}\n\nexport async function schemaCommand(subcommand: string | undefined, rawArgs: string[]): Promise<void> {\n // `--help` is answered here, before `requireProjectRoot` and before the\n // driver is spawned — the same shape `db.ts` already uses, and for the same\n // reason.\n //\n // `cli.ts` rewrites the subcommand to `\"--help\"` only when the user named\n // none, so `rebase schema --help` was covered and `rebase schema generate\n // --help` was not: the flag travelled into `rawArgs.slice(2)` and reached\n // the driver, whose own `schemaCommand` has no `--help` case. It *ran the\n // generator* — overwriting `src/schema.generated.ts` — for a flag whose\n // entire job is to print text. Worse, the first thing it hit outside a\n // project was `requireProjectRoot`, so `rebase schema introspect --help` in\n // an empty directory exited 1 with \"Could not find a Rebase project root\":\n // help you cannot read until you already have a project is help for nobody.\n if (!subcommand || subcommand === \"--help\" || wantsHelp(rawArgs)) {\n printSchemaHelp(subcommand === \"--help\" ? undefined : subcommand);\n return;\n }\n\n // A typo is answered here, in the same words every other family uses.\n //\n // It used to travel to the driver, which said the bare line `Unknown schema\n // command.` — no list, no pointer, no did-you-mean, for a family with three\n // subcommands. The set comes from the help table, so what a typo is measured\n // against and what `--help` prints cannot drift apart.\n if (!SCHEMA_ACTION_HELP[subcommand]) {\n unknownCommand(subcommand, Object.keys(SCHEMA_ACTION_HELP), \"schema\");\n }\n\n // Before anything else runs.\n refuseRemovedCollectionsFlag(rawArgs.slice(2), `schema ${subcommand}`);\n\n // Reads the local tables or a running server's description of them; with a\n // target flag it needs no project at all.\n if (subcommand === \"show\") {\n const { schemaShowCommand } = await import(\"./schema-show\");\n await schemaShowCommand(rawArgs);\n return;\n }\n\n const projectRoot = requireProjectRoot();\n\n // Talks to the running backend, not the driver: on Rebase Cloud the\n // backend is the only thing that reaches the database.\n if (subcommand === \"reconcile\") {\n void recordEvent(\"cli.schema\", { subcommand }, { projectRoot });\n const { schemaReconcileCommand } = await import(\"./schema-reconcile\");\n await schemaReconcileCommand(rawArgs);\n return;\n }\n\n // Fire-and-forget, and a no-op unless the developer opted in. Never awaited:\n // the command is what the user is waiting for, and a slow collector must not\n // sit in front of it.\n void recordEvent(\"cli.schema\", { subcommand: subcommand ?? \"none\" }, { projectRoot });\n const backendDir = requireBackendDir(projectRoot);\n\n const activePlugin = getActiveBackendPlugin(backendDir);\n if (!activePlugin) {\n console.error(chalk.red(\"✗ Could not detect an active database plugin.\"));\n console.error(chalk.gray(\" Make sure a package like @rebasepro/server-postgres is installed in backend/package.json.\"));\n process.exit(1);\n }\n\n const pluginCli = resolvePluginCliScript(backendDir, activePlugin);\n if (!pluginCli) {\n exitDependenciesNotInstalled(projectRoot);\n }\n\n // Set up environment with DOTENV_CONFIG_PATH\n const envFile = findEnvFile(projectRoot);\n const env: Record<string, string> = { ...process.env as Record<string, string> };\n if (envFile) {\n env.DOTENV_CONFIG_PATH = envFile;\n }\n // Which database this project is on, so the driver's closing line does not\n // recommend a command that database refuses. A pure decision — nothing is\n // started, which matters here above all: `schema generate` reads the\n // schema directory and writes one file, and booting a database to run it would be a\n // side effect nobody asked for.\n env[DEV_DATABASE_KIND_ENV] = devDatabaseKind(projectRoot) ?? \"\";\n\n refuseMissingSchemaDir(rawArgs, process.cwd(), backendDir);\n\n // `introspect` is the one schema command that reads a database, and it\n // reads the project's — resolved the way every `db` command resolves it,\n // started if that is what it takes. It used to pass `.env` and nothing\n // else, so on the managed database or after `rebase dev --docker` (with\n // the scaffold's DATABASE_URL commented out, on purpose) it said\n // \"DATABASE_URL is not set\", and `--docker` and `--database-url` passed the\n // flag check only to be ignored.\n if (subcommand === \"introspect\") {\n const flags = arg(\n { \"--database-url\": String, \"--docker\": Boolean },\n { argv: rawArgs.slice(2), permissive: true }\n );\n await ensureDockerDatabase(projectRoot, rawArgs);\n const prepared = await prepareDatabaseEnv(projectRoot, {\n flagUrl: flags[\"--database-url\"] ?? null,\n flagDocker: flags[\"--docker\"] === true,\n onProgress: (message) => console.log(chalk.gray(` ${message}`))\n });\n Object.assign(env, prepared.env);\n env[DEV_DATABASE_KIND_ENV] = prepared.database.kind;\n for (const line of managedNotices(prepared)) console.log(chalk.gray(` ${line}`));\n }\n\n try {\n // The one spawn, shared with `db`. This file used to carry its own copy\n // of the tsx-or-node decision; three copies of that rule existed and two\n // were fixed while the third went on spawning plain node.\n const driverArgs = schemaDriverArgs(rawArgs, process.cwd());\n await spawnDriverCli(\n { projectRoot, backendDir, pluginCli, env },\n [...driverArgs, ...schemaDirArgs(projectRoot, driverArgs)]\n );\n } catch (error) {\n // A child that ran and exited non-zero already printed its diagnostics\n // through inherited stdio; a child that never started (ENOENT on tsx,\n // EACCES on the script) printed nothing at all, and this used to exit 1\n // in silence.\n reportSpawnFailure(error);\n process.exit(1);\n }\n}\n\n/** One page per subcommand, so `rebase schema <action> --help` says something. */\nconst SCHEMA_ACTION_HELP: Record<string, { usage: string; summary: string; notes?: string[] }> = {\n generate: {\n usage: \"rebase schema generate [--schema-dir <dir>] [--output <file>] [--watch]\",\n summary: \"Generate the Drizzle schema from the tables in backend/schema.\",\n notes: [\"--watch regenerates on every change to a schema file.\", `--schema-dir <dir>: ${SCHEMA_DIR_FLAG_HELP}.`]\n },\n introspect: {\n usage: \"rebase schema introspect [--schema-dir <dir>] [--schema <name>] [--force] [--from supabase] [--data-inference | --no-data-inference]\",\n summary: \"Read an existing database and write its tables as defineTable modules into backend/schema.\",\n notes: [\n \"--force overwrites table modules that are already there.\",\n `--schema-dir <dir>: where the tables are written — ${SCHEMA_DIR_FLAG_HELP}.`,\n \"--data-inference samples up to 100 rows per table to detect formats, constraints and UI settings; \"\n + \"--no-data-inference reads the structure only. Without either it asks, and without a terminal \"\n + \"it reads the structure only.\",\n \"Reads this project's database, the one `rebase db url` prints: --database-url <url> names another; \"\n + \"--docker uses the compose one, starting it if needed.\"\n ]\n },\n reconcile: {\n usage: RECONCILE_USAGE,\n summary: \"Relax and drop what boot will not: NOT NULL on columns made nullable, and columns no table declares.\",\n notes: [\n \"Plans on the running backend (the one `.env` and the cloud link point at), prints the plan, and applies it once you type yes.\",\n \"A column is dropped only when named: --drop voice_cache.wav. Each drop shows how many rows hold a value.\",\n \"--yes skips the prompt, for a plan already read. Sends REBASE_SERVICE_KEY from .env by default.\",\n \"Target flags: --url <server>, --project <slug> (Rebase Cloud), --cloud, --token <bearer>, --session, --anon, --json.\"\n ]\n },\n show: {\n usage: \"rebase schema show [table] [--remote] [--schema-dir <dir>]\",\n summary: \"The tables, or one table's columns, relations and row-level security.\",\n notes: [\n \"Reads backend/schema by default (--schema-dir <dir> names another directory).\",\n \"--remote asks the running server instead (GET /api/schema/tables): what the API describes to this credential.\",\n \"Target flags imply --remote: --project <slug> (Rebase Cloud), --cloud (the linked project), --url <server>,\",\n \"--token <bearer>, --session (after `rebase auth login`), --anon. --json prints the descriptors; --yes is accepted and unused.\"\n ]\n },\n stale: {\n usage: \"rebase schema stale [--schema-dir <dir>] [--output <file>] [--fix]\",\n summary: \"Report generated schema files that no longer match the tables.\",\n notes: [\"--fix regenerates them instead of only reporting.\"]\n }\n};\n\n/** Every subcommand the family dispatches — the help table's keys. */\nexport const SCHEMA_SUBCOMMANDS = Object.keys(SCHEMA_ACTION_HELP);\n\nfunction printSchemaHelp(action?: string) {\n const entry = action ? SCHEMA_ACTION_HELP[action] : undefined;\n if (entry) {\n console.log(`\n${chalk.bold(`rebase schema ${action}`)}\n\n ${entry.summary}\n\n${chalk.green.bold(\"Usage\")}\n ${chalk.blue(entry.usage)}\n${entry.notes?.length ? `\\n${chalk.green.bold(\"Notes\")}\\n${entry.notes.map(n => ` ${chalk.gray(`• ${n}`)}`).join(\"\\n\")}\\n` : \"\"}\n${chalk.gray(\"Run `rebase schema --help` for every subcommand.\")}\n`);\n return;\n }\n\n console.log(`\n${chalk.bold(\"rebase schema\")} — Schema management commands\n\n${chalk.green.bold(\"Usage\")}\n rebase schema ${chalk.blue(\"<command>\")} [options]\n\n${chalk.green.bold(\"Commands\")}\n ${chalk.gray(\"(Commands are provided by your active database driver plugin)\")}\n ${chalk.blue.bold(\"generate\")} Generate the Drizzle schema from the tables in backend/schema\n ${chalk.blue.bold(\"introspect\")} Introspect an existing database into defineTable modules in backend/schema\n ${chalk.blue.bold(\"stale\")} Report generated schema files that no longer match the tables\n ${chalk.blue.bold(\"reconcile\")} Relax NOT NULL and drop columns the tables no longer declare, after review\n\n${chalk.green.bold(\"generate / stale Options\")}\n ${chalk.blue(\"--schema-dir\")} ${SCHEMA_DIR_FLAG_HELP}\n ${chalk.blue(\"--output, -o\")} Output path for generated schema\n ${chalk.blue(\"--watch, -w\")} Watch for changes and regenerate automatically\n\n${chalk.green.bold(\"introspect Options\")}\n ${chalk.blue(\"--schema-dir\")} Where the tables are written ${chalk.gray(\"(default: backend/schema)\")}\n ${chalk.blue(\"--schema\")} Postgres schema to read (default: public)\n ${chalk.blue(\"--force, -f\")} Overwrite table modules that already exist\n ${chalk.blue(\"--database-url\")} Read this database instead of the project's own\n ${chalk.blue(\"--docker\")} Read the compose database, starting it if needed\n ${chalk.blue(\"--data-inference\")} Sample rows to detect formats and constraints ${chalk.gray(\"(asked when omitted)\")}\n ${chalk.blue(\"--no-data-inference\")} Read the structure only, without asking\n ${chalk.blue(\"--from supabase\")} Translate Supabase's auth.uid(), auth.users and anon/authenticated for a Rebase database\n\n${chalk.green.bold(\"stale Options\")}\n ${chalk.blue(\"--fix\")} Regenerate the stale files instead of only reporting them\n`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,kBAAkB;;AAG/B,IAAM,kBAAkB;CAAE,GAAG;CAAsB,UAAU,CAAC,MAAM;AAAE;AAEtE,SAAgB,mBAAmB,SAAsF;CACrH,MAAM,QAAQ,IAAI,iBAAiB,EAAE,MAAM,QAAQ,MAAM,CAAC,EAAE,CAAC;CAC7D,IAAI,MAAM,EAAE,SAAS,GAAG,MAAM,IAAI,WAAW,wBAAwB,MAAM,EAAE,GAAG,YAAY,iBAAiB;CAC7G,OAAO;EAAE,MAAM,MAAM,aAAa,CAAC;EAAG,KAAK,MAAM,aAAa;EAAM,QAAQ;CAAM;AACtF;;AAGA,SAAgB,sBAAsB,MAAqC;CACvE,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,KAAK,KAAK,SAAS;EAC1B,MAAM,MAAM,EAAE,aACR,IAAI,EAAE,WAAW,uEACjB,gBAAgB,EAAE,WAAW;EACnC,MAAM,KAAK,KAAK,MAAM,KAAK,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE,OAAO,IAAI,MAAM,KAAK,GAAG,GAAG;CACrF;CACA,KAAK,MAAM,KAAK,KAAK,SAAS;EAC1B,MAAM,OAAO,EAAE,kBAAkB,KAAA,IAAY,KAAK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AAM,KAAK,OAAO,EAAE;CACvB;AACD"}
@@ -0,0 +1,2 @@
1
+ import { i as schemaReconcileCommand } from "./schema-D8xFSBbN.js";
2
+ export { schemaReconcileCommand };
@@ -1,8 +1,8 @@
1
1
  import { n as parseCommandArgs, t as UsageError } from "./args-DHyrshtI.js";
2
2
  import { p as requireProjectRoot } from "./project-DALmhb5R.js";
3
3
  import { n as resolveSchemaDir } from "./schema-dir-ChcYfWjP.js";
4
- import { a as projectTarget, c as requestJson, d as PROJECT_TARGET_FLAGS, l as startProjectCommand, n as isRecord, o as recordsOf, r as parsedLine, u as stringOf } from "./project-command-Cl9EZzjr.js";
5
- import { M as note, m as emit, v as fail } from "./context-BOMEoKxn.js";
4
+ import { a as projectTarget, c as requestJson, d as PROJECT_TARGET_FLAGS, l as startProjectCommand, n as isRecord, o as recordsOf, r as parsedLine, u as stringOf } from "./project-command-7EGMemEy.js";
5
+ import { M as note, m as emit, v as fail } from "./context-xt20FMFA.js";
6
6
  import chalk from "chalk";
7
7
  import path from "path";
8
8
  //#region src/commands/schema-show.ts
@@ -124,4 +124,4 @@ async function schemaShowCommand(rawArgs) {
124
124
  //#endregion
125
125
  export { schemaShowCommand };
126
126
 
127
- //# sourceMappingURL=schema-show-h72UJ9zH.js.map
127
+ //# sourceMappingURL=schema-show-C7bY7SgE.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-show-h72UJ9zH.js","names":[],"sources":["../src/commands/schema-show.ts"],"sourcesContent":["/**\n * CLI command: rebase schema show [table]\n *\n * The tables, and one table's columns, relations and row-level security —\n * from `backend/schema` as this checkout declares them, or with `--remote`\n * (or any target flag) as a running server describes them to the caller\n * (`GET /api/schema/tables`). The remote answer is what the API serves *to\n * you*: a credential without `schema:read` sees no policies, and a table you\n * cannot read is not listed.\n *\n * What an agent reads before `rebase data query`, so it uses the real column\n * names rather than guessing them.\n */\nimport path from \"path\";\nimport type arg from \"arg\";\nimport chalk from \"chalk\";\n\nimport { parseCommandArgs, UsageError } from \"../utils/args\";\nimport { PROJECT_TARGET_FLAGS } from \"../utils/project-target\";\nimport {\n emit,\n fail,\n isRecord,\n parsedLine,\n projectTarget,\n recordsOf,\n requestJson,\n startProjectCommand,\n stringOf\n} from \"../utils/project-command\";\nimport { requireProjectRoot } from \"../utils/project\";\nimport { resolveSchemaDir } from \"../utils/schema-dir\";\nimport { note } from \"./cloud/context\";\n\nexport const SCHEMA_SHOW_FLAGS = {\n ...PROJECT_TARGET_FLAGS,\n \"--remote\": Boolean,\n \"--schema-dir\": String\n} satisfies arg.Spec;\n\n/** One table, as much of it as `show` prints — the same reading for a local descriptor and a served one. */\ninterface TableView {\n slug: string;\n name: string;\n kind: string;\n description?: string;\n primaryKey: string[];\n columns: Array<{ key: string; type: string; nullable: boolean; extra: string[] }>;\n relations: Array<{ key: string; kind: string; target: string }>;\n rls: string;\n}\n\n/** Read a descriptor (`TableDescriptor`, local or served) into what `show` prints. */\nexport function tableView(raw: Record<string, unknown>): TableView {\n const columns = recordsOf(raw.columns).map(column => {\n const extra: string[] = [];\n if (column.primaryKey === true) extra.push(\"pk\");\n if (column.unique === true) extra.push(\"unique\");\n if (column.readOnly === true) extra.push(\"read-only\");\n if (column.generated) extra.push(\"generated\");\n if (column.default !== undefined) extra.push(\"default\");\n if (isRecord(column.stamp)) extra.push(`stamp:${stringOf(column.stamp.kind) ?? \"?\"}`);\n const type = typeof column.type === \"string\" ? column.type : isRecord(column.type) ? stringOf(column.type.kind) ?? JSON.stringify(column.type) : \"?\";\n return { key: stringOf(column.key) ?? \"?\", type, nullable: column.nullable !== false, extra };\n });\n const relations = recordsOf(raw.relations).map(relation => ({\n key: stringOf(relation.key ?? relation.name) ?? \"?\",\n kind: stringOf(relation.kind) ?? \"?\",\n target: stringOf(relation.target ?? relation.table) ?? \"?\"\n }));\n const rls = isRecord(raw.rls)\n ? [stringOf(raw.rls.posture), Array.isArray(raw.rls.rules) ? `${raw.rls.rules.length} rule(s)` : undefined].filter(Boolean).join(\", \")\n : \"\";\n return {\n slug: stringOf(raw.slug) ?? stringOf(raw.name) ?? \"?\",\n name: stringOf(raw.name) ?? \"?\",\n kind: stringOf(raw.kind) ?? \"table\",\n ...(stringOf(raw.description) ? { description: stringOf(raw.description) } : {}),\n primaryKey: Array.isArray(raw.primaryKey) ? raw.primaryKey.map(String) : [],\n columns,\n relations,\n rls\n };\n}\n\nfunction printTableList(tables: TableView[], from: string): void {\n if (tables.length === 0) return note(`No tables (${from}).`);\n note(chalk.gray(from));\n const width = Math.max(5, ...tables.map(table => table.slug.length));\n for (const table of tables) {\n console.log(` ${chalk.bold(table.slug.padEnd(width))} ${chalk.gray(`${table.columns.length} columns${table.kind === \"view\" ? \", view\" : \"\"}`)}${table.description ? ` ${table.description}` : \"\"}`);\n }\n}\n\nfunction printTable(table: TableView): void {\n console.log(` ${chalk.bold(table.slug)}${table.kind === \"view\" ? chalk.gray(\" (view)\") : \"\"}${table.description ? ` ${chalk.gray(table.description)}` : \"\"}`);\n console.log(\"\");\n const width = Math.max(6, ...table.columns.map(column => column.key.length));\n for (const column of table.columns) {\n console.log(` ${column.key.padEnd(width)} ${column.type}${column.nullable ? \"\" : chalk.yellow(\" not null\")}${column.extra.length ? chalk.gray(` ${column.extra.join(\", \")}`) : \"\"}`);\n }\n if (table.relations.length > 0) {\n console.log(\"\");\n for (const relation of table.relations) console.log(` ${chalk.cyan(relation.key)} ${relation.kind} → ${relation.target}`);\n }\n if (table.rls) {\n console.log(\"\");\n console.log(chalk.gray(` row-level security: ${table.rls}`));\n }\n}\n\nexport async function schemaShowCommand(rawArgs: string[]): Promise<void> {\n startProjectCommand(rawArgs);\n const { flags, positionals } = parsedLine(() => parseCommandArgs({\n spec: SCHEMA_SHOW_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"schema show\",\n maxPositionals: 1\n }));\n const wanted = positionals[0];\n const remote = flags[\"--remote\"] === true\n || flags[\"--project\"] !== undefined || flags[\"--cloud\"] === true || flags[\"--url\"] !== undefined\n || flags[\"--token\"] !== undefined || flags[\"--session\"] === true || flags[\"--anon\"] === true;\n\n let raws: Record<string, unknown>[];\n let from: string;\n if (remote) {\n if (flags[\"--schema-dir\"]) fail(\"--schema-dir reads local files; it does not go with --remote or a target flag.\", undefined, \"usage\");\n const target = await projectTarget(flags, { command: \"schema show\" });\n const body = await requestJson(target, \"/api/schema/tables\", \"Failed to read the tables\");\n raws = recordsOf(Array.isArray(body) ? body : isRecord(body) ? body.tables ?? body.data : undefined);\n from = `as ${target.label} describes them to this credential`;\n } else {\n const projectRoot = requireProjectRoot();\n const schemaDir = flags[\"--schema-dir\"] ? path.resolve(flags[\"--schema-dir\"]) : resolveSchemaDir(projectRoot);\n const { loadProjectSchema } = await import(\"../utils/project-schema\");\n try {\n const { compiled } = await loadProjectSchema(projectRoot, schemaDir);\n raws = compiled.descriptors.map(descriptor => JSON.parse(JSON.stringify(descriptor)) as unknown).filter(isRecord);\n } catch (e) {\n fail(`Could not load ${path.relative(process.cwd(), schemaDir) || schemaDir}: ${e instanceof Error ? e.message : String(e)}`, undefined, \"schema_load_failed\");\n }\n from = `from ${path.relative(process.cwd(), schemaDir) || schemaDir}`;\n }\n\n const tables = raws.map(tableView);\n if (wanted) {\n const index = tables.findIndex(table => table.slug === wanted || table.name === wanted);\n if (index === -1) {\n parsedLine(() => {\n throw new UsageError(`No table named ${wanted} (${from}). Known: ${tables.map(table => table.slug).join(\", \") || \"none\"}.`);\n });\n }\n emit(() => printTable(tables[index]), raws[index]);\n return;\n }\n emit(() => printTableList(tables, from), raws);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,oBAAoB;CAC7B,GAAG;CACH,YAAY;CACZ,gBAAgB;AACpB;;AAeA,SAAgB,UAAU,KAAyC;CAC/D,MAAM,UAAU,UAAU,IAAI,OAAO,CAAC,CAAC,KAAI,WAAU;EACjD,MAAM,QAAkB,CAAC;EACzB,IAAI,OAAO,eAAe,MAAM,MAAM,KAAK,IAAI;EAC/C,IAAI,OAAO,WA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K,UAAU,IAAI,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,KAAK,KAAA,GAAW,oBAAoB;EACjK;EACA,OAAO,QAAQ,KAAK,SAAS,QAAQ,IAAI,GAAG,SAAS,KAAK;CAC9D;CAEA,MAAM,SAAS,KAAK,IAAI,SAAS;CACjC,IAAI,QAAQ;EACR,MAAM,QAAQ,OAAO,WAAU,UAAS,MAAM,SAAS,UAAU,MAAM,SAAS,MAAM;EACtF,IAAI,UAAU,IACV,iBAAiB;GACb,MAAM,IAAI,WAAW,kBAAkB,OAAO,IAAI,KAAK,YAAY,OAAO,KAAI,UAAS,MAAM,IAAI,CAAC,CAAC,KAAK,IAAI,KAAK,OAAO,EAAE;EAC9H,CAAC;EAEL,WAAW,WAAW,OAAO,MAAM,GAAG,KAAK,MAAM;EACjD;CACJ;CACA,WAAW,eAAe,QAAQ,IAAI,GAAG,IAAI;AACjD"}
1
+ {"version":3,"file":"schema-show-C7bY7SgE.js","names":[],"sources":["../src/commands/schema-show.ts"],"sourcesContent":["/**\n * CLI command: rebase schema show [table]\n *\n * The tables, and one table's columns, relations and row-level security —\n * from `backend/schema` as this checkout declares them, or with `--remote`\n * (or any target flag) as a running server describes them to the caller\n * (`GET /api/schema/tables`). The remote answer is what the API serves *to\n * you*: a credential without `schema:read` sees no policies, and a table you\n * cannot read is not listed.\n *\n * What an agent reads before `rebase data query`, so it uses the real column\n * names rather than guessing them.\n */\nimport path from \"path\";\nimport type arg from \"arg\";\nimport chalk from \"chalk\";\n\nimport { parseCommandArgs, UsageError } from \"../utils/args\";\nimport { PROJECT_TARGET_FLAGS } from \"../utils/project-target\";\nimport {\n emit,\n fail,\n isRecord,\n parsedLine,\n projectTarget,\n recordsOf,\n requestJson,\n startProjectCommand,\n stringOf\n} from \"../utils/project-command\";\nimport { requireProjectRoot } from \"../utils/project\";\nimport { resolveSchemaDir } from \"../utils/schema-dir\";\nimport { note } from \"./cloud/context\";\n\nexport const SCHEMA_SHOW_FLAGS = {\n ...PROJECT_TARGET_FLAGS,\n \"--remote\": Boolean,\n \"--schema-dir\": String\n} satisfies arg.Spec;\n\n/** One table, as much of it as `show` prints — the same reading for a local descriptor and a served one. */\ninterface TableView {\n slug: string;\n name: string;\n kind: string;\n description?: string;\n primaryKey: string[];\n columns: Array<{ key: string; type: string; nullable: boolean; extra: string[] }>;\n relations: Array<{ key: string; kind: string; target: string }>;\n rls: string;\n}\n\n/** Read a descriptor (`TableDescriptor`, local or served) into what `show` prints. */\nexport function tableView(raw: Record<string, unknown>): TableView {\n const columns = recordsOf(raw.columns).map(column => {\n const extra: string[] = [];\n if (column.primaryKey === true) extra.push(\"pk\");\n if (column.unique === true) extra.push(\"unique\");\n if (column.readOnly === true) extra.push(\"read-only\");\n if (column.generated) extra.push(\"generated\");\n if (column.default !== undefined) extra.push(\"default\");\n if (isRecord(column.stamp)) extra.push(`stamp:${stringOf(column.stamp.kind) ?? \"?\"}`);\n const type = typeof column.type === \"string\" ? column.type : isRecord(column.type) ? stringOf(column.type.kind) ?? JSON.stringify(column.type) : \"?\";\n return { key: stringOf(column.key) ?? \"?\", type, nullable: column.nullable !== false, extra };\n });\n const relations = recordsOf(raw.relations).map(relation => ({\n key: stringOf(relation.key ?? relation.name) ?? \"?\",\n kind: stringOf(relation.kind) ?? \"?\",\n target: stringOf(relation.target ?? relation.table) ?? \"?\"\n }));\n const rls = isRecord(raw.rls)\n ? [stringOf(raw.rls.posture), Array.isArray(raw.rls.rules) ? `${raw.rls.rules.length} rule(s)` : undefined].filter(Boolean).join(\", \")\n : \"\";\n return {\n slug: stringOf(raw.slug) ?? stringOf(raw.name) ?? \"?\",\n name: stringOf(raw.name) ?? \"?\",\n kind: stringOf(raw.kind) ?? \"table\",\n ...(stringOf(raw.description) ? { description: stringOf(raw.description) } : {}),\n primaryKey: Array.isArray(raw.primaryKey) ? raw.primaryKey.map(String) : [],\n columns,\n relations,\n rls\n };\n}\n\nfunction printTableList(tables: TableView[], from: string): void {\n if (tables.length === 0) return note(`No tables (${from}).`);\n note(chalk.gray(from));\n const width = Math.max(5, ...tables.map(table => table.slug.length));\n for (const table of tables) {\n console.log(` ${chalk.bold(table.slug.padEnd(width))} ${chalk.gray(`${table.columns.length} columns${table.kind === \"view\" ? \", view\" : \"\"}`)}${table.description ? ` ${table.description}` : \"\"}`);\n }\n}\n\nfunction printTable(table: TableView): void {\n console.log(` ${chalk.bold(table.slug)}${table.kind === \"view\" ? chalk.gray(\" (view)\") : \"\"}${table.description ? ` ${chalk.gray(table.description)}` : \"\"}`);\n console.log(\"\");\n const width = Math.max(6, ...table.columns.map(column => column.key.length));\n for (const column of table.columns) {\n console.log(` ${column.key.padEnd(width)} ${column.type}${column.nullable ? \"\" : chalk.yellow(\" not null\")}${column.extra.length ? chalk.gray(` ${column.extra.join(\", \")}`) : \"\"}`);\n }\n if (table.relations.length > 0) {\n console.log(\"\");\n for (const relation of table.relations) console.log(` ${chalk.cyan(relation.key)} ${relation.kind} → ${relation.target}`);\n }\n if (table.rls) {\n console.log(\"\");\n console.log(chalk.gray(` row-level security: ${table.rls}`));\n }\n}\n\nexport async function schemaShowCommand(rawArgs: string[]): Promise<void> {\n startProjectCommand(rawArgs);\n const { flags, positionals } = parsedLine(() => parseCommandArgs({\n spec: SCHEMA_SHOW_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"schema show\",\n maxPositionals: 1\n }));\n const wanted = positionals[0];\n const remote = flags[\"--remote\"] === true\n || flags[\"--project\"] !== undefined || flags[\"--cloud\"] === true || flags[\"--url\"] !== undefined\n || flags[\"--token\"] !== undefined || flags[\"--session\"] === true || flags[\"--anon\"] === true;\n\n let raws: Record<string, unknown>[];\n let from: string;\n if (remote) {\n if (flags[\"--schema-dir\"]) fail(\"--schema-dir reads local files; it does not go with --remote or a target flag.\", undefined, \"usage\");\n const target = await projectTarget(flags, { command: \"schema show\" });\n const body = await requestJson(target, \"/api/schema/tables\", \"Failed to read the tables\");\n raws = recordsOf(Array.isArray(body) ? body : isRecord(body) ? body.tables ?? body.data : undefined);\n from = `as ${target.label} describes them to this credential`;\n } else {\n const projectRoot = requireProjectRoot();\n const schemaDir = flags[\"--schema-dir\"] ? path.resolve(flags[\"--schema-dir\"]) : resolveSchemaDir(projectRoot);\n const { loadProjectSchema } = await import(\"../utils/project-schema\");\n try {\n const { compiled } = await loadProjectSchema(projectRoot, schemaDir);\n raws = compiled.descriptors.map(descriptor => JSON.parse(JSON.stringify(descriptor)) as unknown).filter(isRecord);\n } catch (e) {\n fail(`Could not load ${path.relative(process.cwd(), schemaDir) || schemaDir}: ${e instanceof Error ? e.message : String(e)}`, undefined, \"schema_load_failed\");\n }\n from = `from ${path.relative(process.cwd(), schemaDir) || schemaDir}`;\n }\n\n const tables = raws.map(tableView);\n if (wanted) {\n const index = tables.findIndex(table => table.slug === wanted || table.name === wanted);\n if (index === -1) {\n parsedLine(() => {\n throw new UsageError(`No table named ${wanted} (${from}). Known: ${tables.map(table => table.slug).join(\", \") || \"none\"}.`);\n });\n }\n emit(() => printTable(tables[index]), raws[index]);\n return;\n }\n emit(() => printTableList(tables, from), raws);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,oBAAoB;CAC7B,GAAG;CACH,YAAY;CACZ,gBAAgB;AACpB;;AAeA,SAAgB,UAAU,KAAyC;CAC/D,MAAM,UAAU,UAAU,IAAI,OAAO,CAAC,CAAC,KAAI,WAAU;EACjD,MAAM,QAAkB,CAAC;EACzB,IAAI,OAAO,eAAe,MAAM,MAAM,KAAK,IAAI;EAC/C,IAAI,OAAO,WAAW,MAAM,MAAM,KAAK,QAAQ;EAC/C,IAAI,OAAO,aAAa,MAAM,MAAM,KAAK,WAAW;EACpD,IAAI,OAAO,WAAW,MAAM,KAAK,WAAW;EAC5C,IAAI,OAAO,YAAY,KAAA,GAAW,MAAM,KAAK,SAAS;EACtD,IAAI,SAAS,OAAO,KAAK,GAAG,MAAM,KAAK,SAAS,SAAS,OAAO,MAAM,IAAI,KAAK,KAAK;EACpF,M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,MAAM;EACtF,IAAI,UAAU,IACV,iBAAiB;GACb,MAAM,IAAI,WAAW,kBAAkB,OAAO,IAAI,KAAK,YAAY,OAAO,KAAI,UAAS,MAAM,IAAI,CAAC,CAAC,KAAK,IAAI,KAAK,OAAO,EAAE;EAC9H,CAAC;EAEL,WAAW,WAAW,OAAO,MAAM,GAAG,KAAK,MAAM;EACjD;CACJ;CACA,WAAW,eAAe,QAAQ,IAAI,GAAG,IAAI;AACjD"}
@@ -705,7 +705,7 @@ async function skillsHooks(rawArgs) {
705
705
  * one line per file.
706
706
  */
707
707
  async function installHooksAndReport(projectDir, force) {
708
- const { installAgentHooks, AGENT_HOOK_SCRIPT } = await import("./agent-setup-Cg_zBWoW.js");
708
+ const { installAgentHooks, AGENT_HOOK_SCRIPT } = await import("./agent-setup-CGeAuP0Q.js");
709
709
  const shown = (file) => path.relative(process.cwd(), path.join(projectDir, file)) || file;
710
710
  for (const { file, status } of installAgentHooks(projectDir, { force })) if (status === "added" || status === "replaced") console.log(` ${chalk.green("✓")} ${status === "added" ? "Wrote" : "Replaced"} ${chalk.gray(shown(file))}`);
711
711
  else if (status === "present") console.log(` ${chalk.green("✓")} ${chalk.gray(shown(file))} already in place`);
@@ -808,7 +808,7 @@ async function skillsInstall(rawArgs = []) {
808
808
  console.log(chalk.yellow(" Edited files were left as they are. To replace them with the bundle's copy:"));
809
809
  console.log(` ${chalk.cyan("rebase skills install --force")}`);
810
810
  }
811
- const { MCP_SERVER_NAME, ensureMcpDependency, mcpDependencyNote, mcpServerRegistered, writeMcpConfig, cliPackageRoot } = await import("./agent-setup-Cg_zBWoW.js");
811
+ const { MCP_SERVER_NAME, ensureMcpDependency, mcpDependencyNote, mcpServerRegistered, writeMcpConfig, cliPackageRoot } = await import("./agent-setup-CGeAuP0Q.js");
812
812
  const { detectPackageManager } = await import("./package-manager-DSEOwTqM.js").then((n) => n.r);
813
813
  const shownFile = (file) => path.relative(process.cwd(), path.join(projectDir, file)) || file;
814
814
  if (withMcp) {
@@ -885,11 +885,11 @@ ${chalk.green.bold("Examples")}
885
885
  /** One line per repository-root agent file the project's rules were written into, or left alone. */
886
886
  function reportRootPointers(result) {
887
887
  const shown = (file) => path.relative(process.cwd(), file) || file;
888
- for (const file of result.changed) console.log(` ${chalk.green("✓")} Rebase rules in ${chalk.gray(shown(file))}, for an assistant started at the repository root`);
888
+ for (const file of result.changed) console.log(` ${chalk.green("✓")} Rebase rules in ${chalk.gray(shown(file))}, outside the project, for an assistant started at the repository root ${chalk.gray("(REBASE_ROOT_RULES=0 skips this)")}`);
889
889
  for (const { file, reason } of result.untouched) console.warn(` ${chalk.yellow("!")} Left ${chalk.gray(shown(file))} as it is: ${reason}. Fix or remove them and run ${chalk.cyan("rebase skills install")} again.`);
890
890
  if (result.refused !== null) console.log(chalk.gray(` No Rebase rules at the repository root: ${result.refused}.`));
891
891
  }
892
892
  //#endregion
893
893
  export { installSkills as a, reportRootPointers as c, writeRootPointers as d, detectInstalledAgents as i, resolveAgentNames as l, AGENT_KEYS as n, isAgentKey as o, SKILLS_MANIFEST as r, loadBundledSkills as s, AGENTS as t, skills_exports as u };
894
894
 
895
- //# sourceMappingURL=skills-DQ2bZGkj.js.map
895
+ //# sourceMappingURL=skills-C8WdRTFg.js.map