@rebasepro/cli 0.34.0 → 0.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-setup-CGeAuP0Q.js → agent-setup-kjdKozkF.js} +3 -3
- package/dist/{agent-setup-CGeAuP0Q.js.map → agent-setup-kjdKozkF.js.map} +1 -1
- package/dist/{api-zx1wSK5a.js → api-CQh_qTyQ.js} +2 -2
- package/dist/{api-zx1wSK5a.js.map → api-CQh_qTyQ.js.map} +1 -1
- package/dist/{api-keys-DaWN8dyI.js → api-keys-CG2IpknI.js} +5 -5
- package/dist/{api-keys-DaWN8dyI.js.map → api-keys-CG2IpknI.js.map} +1 -1
- package/dist/{apps-D6vtDrkJ.js → apps-DaaWvv3o.js} +6 -6
- package/dist/{apps-D6vtDrkJ.js.map → apps-DaaWvv3o.js.map} +1 -1
- package/dist/{atlas-dev-database-D6h65f2x.js → atlas-dev-database-BiDMUr9W.js} +2 -2
- package/dist/{atlas-dev-database-D6h65f2x.js.map → atlas-dev-database-BiDMUr9W.js.map} +1 -1
- package/dist/{auth-DY7kU0z-.js → auth-bi8x2YX1.js} +12 -12
- package/dist/{auth-DY7kU0z-.js.map → auth-bi8x2YX1.js.map} +1 -1
- package/dist/{auth-session-DCG96UGH.js → auth-session-BVoxE5tp.js} +4 -4
- package/dist/{auth-session-DCG96UGH.js.map → auth-session-BVoxE5tp.js.map} +1 -1
- package/dist/{backend-guard-Cf8eMK_f.js → backend-guard--SW3MTSh.js} +2 -2
- package/dist/{backend-guard-Cf8eMK_f.js.map → backend-guard--SW3MTSh.js.map} +1 -1
- package/dist/{branch-pointer-BJOF2Ubv.js → branch-pointer-BjKUoENm.js} +1 -1
- package/dist/{build-D0egCUfU.js → build-D-0VCmbU.js} +11 -11
- package/dist/build-D-0VCmbU.js.map +1 -0
- package/dist/{bundle-DhdhtD8K.js → bundle-BDTVS9XE.js} +6 -6
- package/dist/{bundle-DhdhtD8K.js.map → bundle-BDTVS9XE.js.map} +1 -1
- package/dist/{cloud-DOR7bxDw.js → cloud-CR6Hps3B.js} +12 -12
- package/dist/{cloud-DOR7bxDw.js.map → cloud-CR6Hps3B.js.map} +1 -1
- package/dist/{cms-directories-BaV-Is9a.js → cms-directories-AGHvFwH7.js} +2 -2
- package/dist/{cms-directories-BaV-Is9a.js.map → cms-directories-AGHvFwH7.js.map} +1 -1
- package/dist/{command-BzSP5gBh.js → command-nWgittn1.js} +3 -3
- package/dist/{command-BzSP5gBh.js.map → command-nWgittn1.js.map} +1 -1
- package/dist/commands/build.d.ts +2 -1
- package/dist/{consent-UV6ObCME.js → consent-C8_Ik_GK.js} +3 -3
- package/dist/{consent-UV6ObCME.js.map → consent-C8_Ik_GK.js.map} +1 -1
- package/dist/{console-BVoYOLAO.js → console-BBGRHOFg.js} +5 -5
- package/dist/{console-BVoYOLAO.js.map → console-BBGRHOFg.js.map} +1 -1
- package/dist/{context-xt20FMFA.js → context-C9lz1vTS.js} +2 -2
- package/dist/{context-xt20FMFA.js.map → context-C9lz1vTS.js.map} +1 -1
- package/dist/{cron-CJ6Xk42E.js → cron-BzzNxkBH.js} +3 -3
- package/dist/{cron-CJ6Xk42E.js.map → cron-BzzNxkBH.js.map} +1 -1
- package/dist/{cron-BGkXIB1N.js → cron-DuZ3Svjq.js} +4 -4
- package/dist/{cron-BGkXIB1N.js.map → cron-DuZ3Svjq.js.map} +1 -1
- package/dist/{daemon-D5gdG7gx.js → daemon-BCBMn8hE.js} +2 -2
- package/dist/{daemon-D5gdG7gx.js.map → daemon-BCBMn8hE.js.map} +1 -1
- package/dist/{data-BpkvtCUe.js → data-1eipHbxJ.js} +3 -3
- package/dist/{data-BpkvtCUe.js.map → data-1eipHbxJ.js.map} +1 -1
- package/dist/{db-D_iF4E-v.js → db-DAotpOxs.js} +28 -28
- package/dist/{db-D_iF4E-v.js.map → db-DAotpOxs.js.map} +1 -1
- package/dist/{debug-C7Ss34XB.js → debug-CkiOcfsU.js} +2 -2
- package/dist/{debug-C7Ss34XB.js.map → debug-CkiOcfsU.js.map} +1 -1
- package/dist/{derive-ChP6vgfi.js → derive-BU5kvcOP.js} +2 -2
- package/dist/{derive-ChP6vgfi.js.map → derive-BU5kvcOP.js.map} +1 -1
- package/dist/{dev-C7n36E6f.js → dev-Ce9PVQS8.js} +13 -13
- package/dist/{dev-C7n36E6f.js.map → dev-Ce9PVQS8.js.map} +1 -1
- package/dist/{dev-preflight-BMOf2N6r.js → dev-preflight-DROlafgr.js} +2 -2
- package/dist/{dev-preflight-BMOf2N6r.js.map → dev-preflight-DROlafgr.js.map} +1 -1
- package/dist/{dev-server-2XHSHM_q.js → dev-server-dsabI0UT.js} +2 -2
- package/dist/{dev-server-2XHSHM_q.js.map → dev-server-dsabI0UT.js.map} +1 -1
- package/dist/{doctor-D0o54XSQ.js → doctor-Cdu3Llrw.js} +7 -7
- package/dist/{doctor-D0o54XSQ.js.map → doctor-Cdu3Llrw.js.map} +1 -1
- package/dist/{eject-DK_M9kor.js → eject-Dy-qRYhW.js} +3 -3
- package/dist/{eject-DK_M9kor.js.map → eject-Dy-qRYhW.js.map} +1 -1
- package/dist/{fold-static-DTpaqbB0.js → fold-static-DzV3EJZm.js} +4 -4
- package/dist/{fold-static-DTpaqbB0.js.map → fold-static-DzV3EJZm.js.map} +1 -1
- package/dist/{functions-DLuuldt2.js → functions-BCEJnISw.js} +4 -4
- package/dist/{functions-DLuuldt2.js.map → functions-BCEJnISw.js.map} +1 -1
- package/dist/{generate-view-BMaLQm8H.js → generate-view-CZ0SmsJc.js} +4 -4
- package/dist/{generate-view-BMaLQm8H.js.map → generate-view-CZ0SmsJc.js.map} +1 -1
- package/dist/{generate_sdk-UT1lwwRT.js → generate_sdk-MAbUUZoK.js} +6 -6
- package/dist/{generate_sdk-UT1lwwRT.js.map → generate_sdk-MAbUUZoK.js.map} +1 -1
- package/dist/index.es.js +54 -54
- package/dist/{init-u5Xmr1Ct.js → init-BctfWO3w.js} +44 -24
- package/dist/init-BctfWO3w.js.map +1 -0
- package/dist/last-dev-database-w-r9T5Xm.js +2 -0
- package/dist/{legacy-layout-DI2VeQSV.js → legacy-layout-CiXWalS6.js} +2 -2
- package/dist/{legacy-layout-DI2VeQSV.js.map → legacy-layout-CiXWalS6.js.map} +1 -1
- package/dist/{logs-DBYRSs6W.js → logs-B_mS4gCn.js} +4 -4
- package/dist/{logs-DBYRSs6W.js.map → logs-B_mS4gCn.js.map} +1 -1
- package/dist/{manifest-RjqxfCpb.js → manifest-D6B4LA8x.js} +3 -3
- package/dist/{manifest-RjqxfCpb.js.map → manifest-D6B4LA8x.js.map} +1 -1
- package/dist/{migrate-Cw1FkvUK.js → migrate-DdcgLMyL.js} +3 -3
- package/dist/{migrate-Cw1FkvUK.js.map → migrate-DdcgLMyL.js.map} +1 -1
- package/dist/{normalize-imports-E4yA1HfW.js → normalize-imports-CVjOssZ2.js} +2 -2
- package/dist/{normalize-imports-E4yA1HfW.js.map → normalize-imports-CVjOssZ2.js.map} +1 -1
- package/dist/{package-manager-DSEOwTqM.js → package-manager-DTNNGHyK.js} +29 -12
- package/dist/package-manager-DTNNGHyK.js.map +1 -0
- package/dist/{path-flags-ekLdkbra.js → path-flags-B7Ydt5nv.js} +2 -2
- package/dist/{path-flags-ekLdkbra.js.map → path-flags-B7Ydt5nv.js.map} +1 -1
- package/dist/{prepare-BaJe0Zik.js → prepare-CFpYl1Nt.js} +4 -4
- package/dist/{prepare-BaJe0Zik.js.map → prepare-CFpYl1Nt.js.map} +1 -1
- package/dist/{project-DALmhb5R.js → project-CQ5nKddJ.js} +2 -2
- package/dist/{project-DALmhb5R.js.map → project-CQ5nKddJ.js.map} +1 -1
- package/dist/{project-command-7EGMemEy.js → project-command-5wM_bJQt.js} +7 -7
- package/dist/{project-command-7EGMemEy.js.map → project-command-5wM_bJQt.js.map} +1 -1
- package/dist/resolve-GDRel2ne.js +2 -0
- package/dist/{resources-CE6BeL94.js → resources-ecA0MEjy.js} +4 -4
- package/dist/{resources-CE6BeL94.js.map → resources-ecA0MEjy.js.map} +1 -1
- package/dist/{rls-BxWLfEKl.js → rls-B4zGbTKY.js} +3 -3
- package/dist/{rls-BxWLfEKl.js.map → rls-B4zGbTKY.js.map} +1 -1
- package/dist/{schema-D8xFSBbN.js → schema-CWzzn0cY.js} +11 -11
- package/dist/{schema-D8xFSBbN.js.map → schema-CWzzn0cY.js.map} +1 -1
- package/dist/{schema-dir-ChcYfWjP.js → schema-dir-Dd1Pzqq5.js} +2 -2
- package/dist/{schema-dir-ChcYfWjP.js.map → schema-dir-Dd1Pzqq5.js.map} +1 -1
- package/dist/schema-reconcile-DGEMmYJI.js +2 -0
- package/dist/{schema-show-C7bY7SgE.js → schema-show-DwYtOp4S.js} +5 -5
- package/dist/{schema-show-C7bY7SgE.js.map → schema-show-DwYtOp4S.js.map} +1 -1
- package/dist/{skills-C8WdRTFg.js → skills-CWmBTCRW.js} +5 -5
- package/dist/{skills-C8WdRTFg.js.map → skills-CWmBTCRW.js.map} +1 -1
- package/dist/{start-CN_9C205.js → start-4uhCu_md.js} +6 -6
- package/dist/{start-CN_9C205.js.map → start-4uhCu_md.js.map} +1 -1
- package/dist/{status-HWlZbY1E.js → status-CVEzoSwX.js} +7 -7
- package/dist/{status-HWlZbY1E.js.map → status-CVEzoSwX.js.map} +1 -1
- package/dist/{storage-DBE8lgH-.js → storage-Dqf5tyhs.js} +9 -9
- package/dist/{storage-DBE8lgH-.js.map → storage-Dqf5tyhs.js.map} +1 -1
- package/dist/{storage-objects-ljDmtuH7.js → storage-objects-DbFsemMV.js} +3 -3
- package/dist/{storage-objects-ljDmtuH7.js.map → storage-objects-DbFsemMV.js.map} +1 -1
- package/dist/{telemetry-DZU2-NCm.js → telemetry-B5RSeQIc.js} +3 -3
- package/dist/{telemetry-DZU2-NCm.js.map → telemetry-B5RSeQIc.js.map} +1 -1
- package/dist/{telemetry-EVtASbKb.js → telemetry-CJbrRuG3.js} +2 -2
- package/dist/{telemetry-EVtASbKb.js.map → telemetry-CJbrRuG3.js.map} +1 -1
- package/dist/{upgrade-ZASvgxWM.js → upgrade-CepjhRrz.js} +6 -6
- package/dist/{upgrade-ZASvgxWM.js.map → upgrade-CepjhRrz.js.map} +1 -1
- package/dist/{users-DrJEtL9k.js → users-Cx5HuaTn.js} +3 -3
- package/dist/{users-DrJEtL9k.js.map → users-Cx5HuaTn.js.map} +1 -1
- package/dist/utils/package-manager.d.ts +12 -13
- package/dist/{verify-BdeqNb-V.js → verify-D-1y5HQS.js} +8 -8
- package/dist/{verify-BdeqNb-V.js.map → verify-D-1y5HQS.js.map} +1 -1
- package/package.json +10 -10
- package/dist/build-D0egCUfU.js.map +0 -1
- package/dist/init-u5Xmr1Ct.js.map +0 -1
- package/dist/last-dev-database-CBVkEUEl.js +0 -2
- package/dist/package-manager-DSEOwTqM.js.map +0 -1
- package/dist/resolve-C36px9tR.js +0 -2
- package/dist/schema-reconcile-D_wvZY91.js +0 -2
|
@@ -1 +1 @@
|
|
|
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,GAAG,EAAE,cAAc,eAAe,OAAO,EAAE;EAC7F,MAAM,KAAK,KAAK,MAAM,IAAI,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,EAAE,OAAO,IAAI,MAAM,IAAI,IAAI,GAAG;CACpF;CACA,MAAM,OAAO,KAAK,WAAW,QAAO,MAChC,CAAC,KAAK,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AAK,MAAM,KAAK,KAAK,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,MAAM,GAAG;EAC/H,MAAM,KAAK,kDAAkD,EAAE;CAChE;EACO;CACJ;CAEA,QAAQ,IAAI;EACd,MAAM,KAAK,eAAe,EAAE;;EAE5B,MAAM,MAAM,KAAK,OAAO,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;IAClC,MAAM,KAAK,iBAAiB,EAAE;;EAEhC,MAAM,MAAM,KAAK,eAAe,EAAE;IAChC,MAAM,KAAK,OAAO,EAAE;CACvB;AACD"}
|
|
1
|
+
{"version":3,"file":"schema-CWzzn0cY.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,IAA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AAE;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;IAClC,MAAM,KAAK,iBAAiB,EAAE;;EAEhC,MAAM,MAAM,KAAK,eAAe,EAAE;IAChC,MAAM,KAAK,OAAO,EAAE;CACvB;AACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import { C as resolveBackendPaths, _ as findBackendApp, a as DEFAULT_TABLES_DIR, b as loadManifest } from "./manifest-
|
|
2
|
+
import { C as resolveBackendPaths, _ as findBackendApp, a as DEFAULT_TABLES_DIR, b as loadManifest } from "./manifest-D6B4LA8x.js";
|
|
3
3
|
import path from "path";
|
|
4
4
|
//#region src/utils/schema-dir.ts
|
|
5
5
|
/**
|
|
@@ -95,4 +95,4 @@ function schemaDirArgs(projectRoot, driverArgs) {
|
|
|
95
95
|
//#endregion
|
|
96
96
|
export { schema_dir_exports as i, resolveSchemaDir as n, schemaDirArgs as r, SCHEMA_DIR_FLAG as t };
|
|
97
97
|
|
|
98
|
-
//# sourceMappingURL=schema-dir-
|
|
98
|
+
//# sourceMappingURL=schema-dir-Dd1Pzqq5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-dir-
|
|
1
|
+
{"version":3,"file":"schema-dir-Dd1Pzqq5.js","names":[],"sources":["../src/utils/schema-dir.ts"],"sourcesContent":["/**\n * Where this project's tables are declared: one answer for every command.\n *\n * `rebase.json`'s `apps.<backend>.tables` names the directory whose `index.ts`\n * exports the tables (default `backend/schema`). Every command that reads the\n * schema — the dev runtime and watcher, `rebase build`, `verify`, `doctor`,\n * `generate-sdk`, `generate view`, `console`, and the driver's `db` / `schema`\n * commands — asks here, so a project that moves the directory moves it for all\n * of them. The previous layout had one resolver too, and still grew five\n * commands that hardcoded `config/collections` beside it; this module is the\n * only place the default is spelled.\n *\n * A directory typed on the command line still wins wherever a command takes\n * one; this is only the default.\n */\nimport path from \"path\";\nimport { DEFAULT_TABLES_DIR, findBackendApp, loadManifest, resolveBackendPaths } from \"../manifest\";\n\n/**\n * The flag that hands the driver CLI (`@rebasepro/server-postgres`) the schema\n * directory, as an absolute path.\n *\n * The receiving end is the driver's own argument spec: when the driver slice\n * renames its flag, this constant and {@link schemaDirFlag} are the only CLI\n * lines that change.\n */\nexport const SCHEMA_DIR_FLAG = \"--schema-dir\";\n\n/** The tables directory, relative to the project root, as the backend app declares it. */\nexport function resolveTablesDir(projectRoot: string): string {\n try {\n const backend = findBackendApp(loadManifest(projectRoot).manifest);\n if (backend) return resolveBackendPaths(backend.app, projectRoot).tables;\n } catch {\n // A malformed rebase.json is reported by the commands that own it; the\n // conventional layout is the answer until then.\n }\n return DEFAULT_TABLES_DIR;\n}\n\n/** The tables directory, absolute. */\nexport function resolveSchemaDir(projectRoot: string): string {\n return path.join(projectRoot, resolveTablesDir(projectRoot));\n}\n\n/**\n * The driver argv naming `dir` as the schema directory: `[\"--schema-dir\", dir]`.\n *\n * The whole CLI → driver contract for this flag, in one function. `dir` is\n * absolute — the driver runs with `cwd: backend/`, so a relative path would be\n * resolved from a directory the user never typed it in.\n */\nexport function schemaDirFlag(dir: string): string[] {\n return [SCHEMA_DIR_FLAG, dir];\n}\n\n/** Whether a command line already names a schema directory. */\nfunction namesSchemaDir(args: readonly string[]): boolean {\n return args.some(arg => arg === SCHEMA_DIR_FLAG || arg.startsWith(`${SCHEMA_DIR_FLAG}=`));\n}\n\n/**\n * The driver commands that read the schema directory. Keyed as the driver's\n * argv starts: domain, then subcommand (or the bare command for the\n * single-word ones).\n */\nconst DRIVER_COMMANDS_READING_SCHEMA = new Set([\n \"db push\",\n \"db generate\",\n // It stamps the policies the migration created as the tables' rules make them.\n \"db migrate\",\n \"schema generate\",\n // It writes the introspected tables there.\n \"schema introspect\",\n \"schema stale\",\n \"doctor\",\n \"console\"\n]);\n\n/**\n * {@link schemaDirFlag} for a driver command line, or nothing.\n *\n * `driverArgs` is the line as the driver gets it (`[\"db\", \"push\", …]`,\n * `[\"doctor\", …]`). Nothing for a command that does not read the schema,\n * nothing when the line already names a directory, and nothing when the\n * project keeps its tables at the default — the driver's own default is\n * `backend/schema` (`schema` from its `cwd`), so a conventional project's\n * command lines stay as short as they were.\n */\nexport function schemaDirArgs(projectRoot: string, driverArgs: readonly string[]): string[] {\n const command = DRIVER_COMMANDS_READING_SCHEMA.has(driverArgs[0])\n ? driverArgs[0]\n : `${driverArgs[0]} ${driverArgs[1]}`;\n if (!DRIVER_COMMANDS_READING_SCHEMA.has(command)) return [];\n if (namesSchemaDir(driverArgs)) return [];\n const dir = resolveSchemaDir(projectRoot);\n if (dir === path.join(projectRoot, DEFAULT_TABLES_DIR)) return [];\n return schemaDirFlag(dir);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,kBAAkB;;AAG/B,SAAgB,iBAAiB,aAA6B;CAC1D,IAAI;EACA,MAAM,UAAU,eAAe,aAAa,WAAW,CAAC,CAAC,QAAQ;EACjE,IAAI,SAAS,OAAO,oBAAoB,QAAQ,KAAK,WAAW,CAAC,CAAC;CACtE,QAAQ,CAGR;CACA,OAAO;AACX;;AAGA,SAAgB,iBAAiB,aAA6B;CAC1D,OAAO,KAAK,KAAK,aAAa,iBAAiB,WAAW,CAAC;AAC/D;;;;;;;;AASA,SAAgB,cAAc,KAAuB;CACjD,OAAO,CAAC,iBAAiB,GAAG;AAChC;;AAGA,SAAS,eAAe,MAAkC;CACtD,OAAO,KAAK,MAAK,QAAO,QAAA,kBAA2B,IAAI,WAAW,eAAqB,CAAC;AAC5F;;;;;;AAOA,IAAM,iDAAiC,IAAI,IAAI;CAC3C;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;AACJ,CAAC;;;;;;;;;;;AAYD,SAAgB,cAAc,aAAqB,YAAyC;CACxF,MAAM,UAAU,+BAA+B,IAAI,WAAW,EAAE,IAC1D,WAAW,KACX,GAAG,WAAW,GAAG,GAAG,WAAW;CACrC,IAAI,CAAC,+BAA+B,IAAI,OAAO,GAAG,OAAO,CAAC;CAC1D,IAAI,eAAe,UAAU,GAAG,OAAO,CAAC;CACxC,MAAM,MAAM,iBAAiB,WAAW;CACxC,IAAI,QAAQ,KAAK,KAAK,aAAA,gBAA+B,GAAG,OAAO,CAAC;CAChE,OAAO,cAAc,GAAG;AAC5B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as parseCommandArgs, t as UsageError } from "./args-DHyrshtI.js";
|
|
2
|
-
import { p as requireProjectRoot } from "./project-
|
|
3
|
-
import { n as resolveSchemaDir } from "./schema-dir-
|
|
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-
|
|
5
|
-
import { M as note, m as emit, v as fail } from "./context-
|
|
2
|
+
import { p as requireProjectRoot } from "./project-CQ5nKddJ.js";
|
|
3
|
+
import { n as resolveSchemaDir } from "./schema-dir-Dd1Pzqq5.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-5wM_bJQt.js";
|
|
5
|
+
import { M as note, m as emit, v as fail } from "./context-C9lz1vTS.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-
|
|
127
|
+
//# sourceMappingURL=schema-show-DwYtOp4S.js.map
|
|
@@ -1 +1 @@
|
|
|
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,MAAM,OAAO,OAAO,OAAO,SAAS,WAAW,OAAO,OAAO,SAAS,OAAO,IAAI,IAAI,SAAS,OAAO,KAAK,IAAI,KAAK,KAAK,UAAU,OAAO,IAAI,IAAI;EACjJ,OAAO;GAAE,KAAK,SAAS,OAAO,GAAG,KAAK;GAAK;GAAM,UAAU,OAAO,aAAa;GAAO;EAAM;CAChG,CAAC;CACD,MAAM,YAAY,UAAU,IAAI,SAAS,CAAC,CAAC,KAAI,cAAa;EACxD,KAAK,SAAS,SAAS,OAAO,SAAS,IAAI,KAAK;EAChD,MAAM,SAAS,SAAS,IAAI,KAAK;EACjC,QAAQ,SAAS,SAAS,UAAU,SAAS,KAAK,KAAK;CAC3D,EAAE;CACF,MAAM,MAAM,SAAS,IAAI,GAAG,IACtB,CAAC,SAAS,IAAI,IAAI,OAAO,GAAG,MAAM,QAAQ,IAAI,IAAI,KAAK,IAAI,GAAG,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ACvC,MAAM,YAAY,MAAM,kBAAkB,KAAK,QAAQ,MAAM,eAAe,IAAI,iBAAiB,WAAW;EAC5G,MAAM,EAAE,sBAAsB,MAAM,OAAO,+BAAA,CAAA,MAAA,MAAA,EAAA,CAAA;EAC3C,IAAI;GACA,MAAM,EAAE,aAAa,MAAM,kBAAkB,aAAa,SAAS;GACnE,OAAO,SAAS,YAAY,KAAI,eAAc,KAAK,MAAM,KAAK,UAAU,UAAU,CAAC,CAAY,CAAC,CAAC,OAAO,QAAQ;EACpH,SAAS,GAAG;GACR,KAAK,kBAAkB,KAAK,SAAS,QAAQ,IAAI,GAAG,SAAS,KAAK,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-DwYtOp4S.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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AAK,UAAU,UAAU,CAAC,CAAY,CAAC,CAAC,OAAO,QAAQ;EACpH,SAAS,GAAG;GACR,KAAK,kBAAkB,KAAK,SAAS,QAAQ,IAAI,GAAG,SAAS,KAAK,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,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
2
|
import { n as unknownCommand } from "./unknown-command-DnZ2uhGs.js";
|
|
3
3
|
import { a as wantsHelp, n as parseCommandArgs, t as UsageError } from "./args-DHyrshtI.js";
|
|
4
|
-
import { c as findProjectRoot } from "./project-
|
|
4
|
+
import { c as findProjectRoot } from "./project-CQ5nKddJ.js";
|
|
5
5
|
import chalk from "chalk";
|
|
6
6
|
import fs from "fs";
|
|
7
7
|
import os from "os";
|
|
@@ -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-
|
|
708
|
+
const { installAgentHooks, AGENT_HOOK_SCRIPT } = await import("./agent-setup-kjdKozkF.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,8 +808,8 @@ 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-
|
|
812
|
-
const { detectPackageManager } = await import("./package-manager-
|
|
811
|
+
const { MCP_SERVER_NAME, ensureMcpDependency, mcpDependencyNote, mcpServerRegistered, writeMcpConfig, cliPackageRoot } = await import("./agent-setup-kjdKozkF.js");
|
|
812
|
+
const { detectPackageManager } = await import("./package-manager-DTNNGHyK.js").then((n) => n.r);
|
|
813
813
|
const shownFile = (file) => path.relative(process.cwd(), path.join(projectDir, file)) || file;
|
|
814
814
|
if (withMcp) {
|
|
815
815
|
console.log("");
|
|
@@ -892,4 +892,4 @@ function reportRootPointers(result) {
|
|
|
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-
|
|
895
|
+
//# sourceMappingURL=skills-CWmBTCRW.js.map
|