@rebasepro/cli 0.30.1 → 0.31.0-canary.g59cd6fd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/{agent-setup-0uyfC7VX.js → agent-setup-DqAcoDcn.js} +10 -5
- package/dist/{agent-setup-0uyfC7VX.js.map → agent-setup-DqAcoDcn.js.map} +1 -1
- package/dist/{api-keys-Dfw5-9s1.js → api-keys-eIUjMqWn.js} +8 -7
- package/dist/api-keys-eIUjMqWn.js.map +1 -0
- package/dist/{apps-MKQbgDtN.js → apps-DExO4PEl.js} +8 -7
- package/dist/apps-DExO4PEl.js.map +1 -0
- package/dist/{project-CasK56vN.js → args-CaCcrYE1.js} +2 -351
- package/dist/args-CaCcrYE1.js.map +1 -0
- package/dist/{atlas-dev-database-BODqdCWt.js → atlas-dev-database-DOCKk6ht.js} +2 -2
- package/dist/{atlas-dev-database-BODqdCWt.js.map → atlas-dev-database-DOCKk6ht.js.map} +1 -1
- package/dist/{auth-Bv0rTbQX.js → auth-D96QYgFR.js} +7 -6
- package/dist/{auth-Bv0rTbQX.js.map → auth-D96QYgFR.js.map} +1 -1
- package/dist/backend-guard-C0mVkXBw.js +162 -0
- package/dist/backend-guard-C0mVkXBw.js.map +1 -0
- package/dist/{branch-pointer-BQUF6lYa.js → branch-pointer-DMPyvZoK.js} +1 -1
- package/dist/{build-BuKTnec8.js → build-CA5R07tw.js} +29 -9
- package/dist/build-CA5R07tw.js.map +1 -0
- package/dist/{bundle-BAH4FCju.js → bundle-DgILeA5b.js} +112 -138
- package/dist/bundle-DgILeA5b.js.map +1 -0
- package/dist/bundle.d.ts +35 -12
- package/dist/cli.d.ts +2 -2
- package/dist/{cloud-DtADfWwn.js → cloud-CYMk92iG.js} +72 -71
- package/dist/cloud-CYMk92iG.js.map +1 -0
- package/dist/cms-directories-BK3vcswg.js +33 -0
- package/dist/cms-directories-BK3vcswg.js.map +1 -0
- package/dist/codemod/collections-to-tables/ast.d.ts +135 -0
- package/dist/codemod/collections-to-tables/backend.d.ts +38 -0
- package/dist/codemod/collections-to-tables/command.d.ts +35 -0
- package/dist/codemod/collections-to-tables/comments.d.ts +45 -0
- package/dist/codemod/collections-to-tables/customization.d.ts +47 -0
- package/dist/codemod/collections-to-tables/dynamic-props.d.ts +34 -0
- package/dist/codemod/collections-to-tables/export-changes.d.ts +83 -0
- package/dist/codemod/collections-to-tables/firestore.d.ts +11 -0
- package/dist/codemod/collections-to-tables/helper-hooks.d.ts +41 -0
- package/dist/codemod/collections-to-tables/hooks.d.ts +44 -0
- package/dist/codemod/collections-to-tables/journal.d.ts +10 -0
- package/dist/codemod/collections-to-tables/legacy-shims.d.ts +52 -0
- package/dist/codemod/collections-to-tables/load-legacy.d.ts +81 -0
- package/dist/codemod/collections-to-tables/migrate.d.ts +20 -0
- package/dist/codemod/collections-to-tables/modules.d.ts +127 -0
- package/dist/codemod/collections-to-tables/moved-imports.d.ts +70 -0
- package/dist/codemod/collections-to-tables/moved-symbols.generated.d.ts +12 -0
- package/dist/codemod/collections-to-tables/own.d.ts +10 -0
- package/dist/codemod/collections-to-tables/path-aliases.d.ts +26 -0
- package/dist/codemod/collections-to-tables/plan-context.d.ts +49 -0
- package/dist/codemod/collections-to-tables/print-js.d.ts +44 -0
- package/dist/codemod/collections-to-tables/project-files.d.ts +144 -0
- package/dist/codemod/collections-to-tables/repoint.d.ts +50 -0
- package/dist/codemod/collections-to-tables/row-hands.d.ts +7 -0
- package/dist/codemod/collections-to-tables/sdk-calls.d.ts +88 -0
- package/dist/codemod/collections-to-tables/skills-step.d.ts +13 -0
- package/dist/codemod/collections-to-tables/split-constants.d.ts +42 -0
- package/dist/codemod/collections-to-tables/storage-paths.d.ts +28 -0
- package/dist/codemod/collections-to-tables/types.d.ts +164 -0
- package/dist/codemod/collections-to-tables/verify.d.ts +27 -0
- package/dist/codemod/collections-to-tables/vocabulary.d.ts +40 -0
- package/dist/command-D5lhW_-B.js +9984 -0
- package/dist/command-D5lhW_-B.js.map +1 -0
- package/dist/commands/agent-setup.d.ts +6 -2
- package/dist/commands/cloud/context.d.ts +1 -1
- package/dist/commands/cloud/init.d.ts +2 -2
- package/dist/commands/console.d.ts +1 -2
- package/dist/commands/db.d.ts +5 -6
- package/dist/commands/dev.d.ts +18 -17
- package/dist/commands/doctor.d.ts +4 -5
- package/dist/commands/eject.d.ts +17 -13
- package/dist/commands/generate-view.d.ts +20 -9
- package/dist/commands/generate_sdk.d.ts +27 -27
- package/dist/commands/init.d.ts +21 -8
- package/dist/commands/migrate.d.ts +24 -0
- package/dist/commands/schema-reconcile.d.ts +1 -1
- package/dist/commands/skills.d.ts +8 -0
- package/dist/commands/verify-cms.d.ts +28 -0
- package/dist/commands/verify.d.ts +14 -9
- package/dist/{consent-BD7F29T3.js → consent-BXLIrMl8.js} +2 -2
- package/dist/{consent-BD7F29T3.js.map → consent-BXLIrMl8.js.map} +1 -1
- package/dist/{console-CdwIYOMV.js → console-C1d3LwB7.js} +14 -14
- package/dist/console-C1d3LwB7.js.map +1 -0
- package/dist/{context-AXdAh-q8.js → context--JwaHaZp.js} +6 -5
- package/dist/context--JwaHaZp.js.map +1 -0
- package/dist/{daemon-Cp7oNXth.js → daemon-w30PsdwV.js} +2 -2
- package/dist/{daemon-Cp7oNXth.js.map → daemon-w30PsdwV.js.map} +1 -1
- package/dist/{db-DBbKpjYX.js → db-DQZK9n9c.js} +52 -51
- package/dist/db-DQZK9n9c.js.map +1 -0
- package/dist/{derive-ae9UOoOB.js → derive-C3ezmY-p.js} +105 -133
- package/dist/derive-C3ezmY-p.js.map +1 -0
- package/dist/{dev-C93d4QIv.js → dev-PY5h4O6u.js} +142 -84
- package/dist/dev-PY5h4O6u.js.map +1 -0
- package/dist/dev-db/attver.d.ts +32 -0
- package/dist/dev-db/pull.d.ts +15 -1
- package/dist/{dev-preflight-Cxv3TiD1.js → dev-preflight-DjvcV6SK.js} +5 -5
- package/dist/dev-preflight-DjvcV6SK.js.map +1 -0
- package/dist/{dev-server-OJsUGZEB.js → dev-server-BLxCbQEP.js} +2 -2
- package/dist/{dev-server-OJsUGZEB.js.map → dev-server-BLxCbQEP.js.map} +1 -1
- package/dist/{doctor-BBPQUO2g.js → doctor-CnUu8kpM.js} +39 -62
- package/dist/doctor-CnUu8kpM.js.map +1 -0
- package/dist/doctor-environment.d.ts +6 -6
- package/dist/{eject-DABcDnPN.js → eject-Bhzd6hgb.js} +25 -16
- package/dist/eject-Bhzd6hgb.js.map +1 -0
- package/dist/{fold-static-BWzxNn06.js → fold-static-CKewnAPX.js} +5 -3
- package/dist/fold-static-CKewnAPX.js.map +1 -0
- package/dist/{generate-view-IFwCADvb.js → generate-view-CTOluXvH.js} +160 -89
- package/dist/generate-view-CTOluXvH.js.map +1 -0
- package/dist/{generate_sdk-DNmNuFuW.js → generate_sdk-De-aLC1L.js} +120 -137
- package/dist/generate_sdk-De-aLC1L.js.map +1 -0
- package/dist/import-schema-module-Df67TIWj.js +51 -0
- package/dist/import-schema-module-Df67TIWj.js.map +1 -0
- package/dist/index.es.js +64 -51
- package/dist/index.es.js.map +1 -1
- package/dist/{init-vL1DWOeC.js → init-Dtl-IcXf.js} +83 -80
- package/dist/init-Dtl-IcXf.js.map +1 -0
- package/dist/last-dev-database-Dc8cP01o.js +2 -0
- package/dist/{manifest-BtzDy7KQ.js → manifest-C3uLDrrJ.js} +115 -40
- package/dist/manifest-C3uLDrrJ.js.map +1 -0
- package/dist/manifest.d.ts +79 -24
- package/dist/migrate-VrKoi3nB.js +138 -0
- package/dist/migrate-VrKoi3nB.js.map +1 -0
- package/dist/{normalize-imports-Bd5Y4yLp.js → normalize-imports-DwxqEMYq.js} +3 -3
- package/dist/{normalize-imports-Bd5Y4yLp.js.map → normalize-imports-DwxqEMYq.js.map} +1 -1
- package/dist/path-flags-7O5uPBcQ.js +139 -0
- package/dist/path-flags-7O5uPBcQ.js.map +1 -0
- package/dist/{prepare-CTw9NEkh.js → prepare-Ccxspoj-.js} +4 -4
- package/dist/{prepare-CTw9NEkh.js.map → prepare-Ccxspoj-.js.map} +1 -1
- package/dist/project-CLcF5i8c.js +360 -0
- package/dist/project-CLcF5i8c.js.map +1 -0
- package/dist/project-schema-CsSOG2gE.js +30 -0
- package/dist/project-schema-CsSOG2gE.js.map +1 -0
- package/dist/{pull-DDMpsZ5r.js → pull-DRWqBZp5.js} +327 -4
- package/dist/pull-DRWqBZp5.js.map +1 -0
- package/dist/resolve-BY7bSFRT.js +2 -0
- package/dist/resources/derive.d.ts +19 -13
- package/dist/{resources-CPSC5Kcu.js → resources-Dpfs2y8P.js} +5 -4
- package/dist/{resources-CPSC5Kcu.js.map → resources-Dpfs2y8P.js.map} +1 -1
- package/dist/{schema-DtLPsXbT.js → schema-CdDjv5zI.js} +41 -39
- package/dist/schema-CdDjv5zI.js.map +1 -0
- package/dist/schema-dir-Cd1kvYbf.js +98 -0
- package/dist/schema-dir-Cd1kvYbf.js.map +1 -0
- package/dist/schema-reconcile-BAupXfkd.js +2 -0
- package/dist/schema-text-CpNrsuMe.js +73 -0
- package/dist/schema-text-CpNrsuMe.js.map +1 -0
- package/dist/{skills-CbwV6vw_.js → skills-CXjA9TWw.js} +54 -10
- package/dist/skills-CXjA9TWw.js.map +1 -0
- package/dist/{start-YOr3X5Zm.js → start-Bwbtt2W5.js} +7 -10
- package/dist/{start-YOr3X5Zm.js.map → start-Bwbtt2W5.js.map} +1 -1
- package/dist/{status-BREvtzJm.js → status-D7XCGHu2.js} +12 -12
- package/dist/status-D7XCGHu2.js.map +1 -0
- package/dist/{storage-CO9ouK76.js → storage-iTqj5-Av.js} +12 -11
- package/dist/storage-iTqj5-Av.js.map +1 -0
- package/dist/{telemetry-DwK5RQJl.js → telemetry-BP_1Cl9r.js} +4 -4
- package/dist/{telemetry-DwK5RQJl.js.map → telemetry-BP_1Cl9r.js.map} +1 -1
- package/dist/{telemetry-CgwJPVMO.js → telemetry-M3HjlyhZ.js} +2 -2
- package/dist/{telemetry-CgwJPVMO.js.map → telemetry-M3HjlyhZ.js.map} +1 -1
- package/dist/{upgrade-B7sVwL8S.js → upgrade-oZzJ13jM.js} +5 -4
- package/dist/{upgrade-B7sVwL8S.js.map → upgrade-oZzJ13jM.js.map} +1 -1
- package/dist/utils/backend-guard.d.ts +47 -0
- package/dist/utils/cms-directories.d.ts +6 -0
- package/dist/utils/dev-preflight.d.ts +2 -2
- package/dist/utils/import-schema-module.d.ts +16 -0
- package/dist/utils/path-flags.d.ts +35 -16
- package/dist/utils/project-schema.d.ts +40 -0
- package/dist/utils/project.d.ts +8 -2
- package/dist/utils/schema-dir.d.ts +32 -0
- package/dist/utils/schema-drift.d.ts +6 -0
- package/dist/utils/schema-text.d.ts +24 -0
- package/dist/verify-5p_vaUG2.js +1160 -0
- package/dist/verify-5p_vaUG2.js.map +1 -0
- package/package.json +11 -8
- package/runtime/dev-server.mjs +5 -1
- package/templates/eject/Dockerfile +1 -4
- package/templates/eject/backend/src/env.ts +1 -1
- package/templates/eject/backend/src/index.ts +53 -40
- package/templates/eject/docker-compose.custom.yml +1 -1
- package/templates/overlays/baas/README.md +39 -12
- package/templates/overlays/baas/ai-instructions.md +8 -8
- package/templates/overlays/baas/{config → backend}/storage.ts +3 -4
- package/templates/overlays/baas/backend/tsconfig.json +10 -12
- package/templates/overlays/baas/package.json +1 -2
- package/templates/overlays/baas/pnpm-workspace.yaml +0 -1
- package/templates/presets/blank/backend/schema/index.ts +19 -0
- package/templates/presets/blank/frontend/src/App.tsx +56 -0
- package/templates/presets/ecommerce/backend/schema/categories.ts +12 -0
- package/templates/presets/ecommerce/backend/schema/index.ts +23 -0
- package/templates/presets/ecommerce/backend/schema/orders.ts +13 -0
- package/templates/presets/ecommerce/backend/schema/products.ts +18 -0
- package/templates/presets/ecommerce/frontend/src/App.tsx +59 -0
- package/templates/presets/ecommerce/frontend/src/cms/categories.tsx +12 -0
- package/templates/presets/ecommerce/frontend/src/cms/orders.tsx +38 -0
- package/templates/presets/ecommerce/frontend/src/cms/products.tsx +27 -0
- package/templates/resource-graphs/blank.json +2 -2
- package/templates/resource-graphs/blog.json +5 -5
- package/templates/resource-graphs/ecommerce.json +5 -5
- package/templates/resource-graphs/headless.json +1 -1
- package/templates/template/.claude/hooks/post-edit-collection.sh +27 -23
- package/templates/template/.cursorrules +2 -2
- package/templates/template/.env.example +6 -17
- package/templates/template/.github/copilot-instructions.md +2 -2
- package/templates/template/.windsurfrules +2 -2
- package/templates/template/AGENTS.md +2 -2
- package/templates/template/CLAUDE.md +2 -2
- package/templates/template/README.md +47 -13
- package/templates/template/ai-instructions.md +15 -14
- package/templates/template/backend/functions/hello.ts +1 -1
- package/templates/template/backend/package.json +0 -2
- package/templates/template/{config → backend}/resources.ts +3 -3
- package/templates/template/backend/schema/authors.ts +11 -0
- package/templates/template/backend/schema/index.ts +29 -0
- package/templates/template/backend/schema/posts.ts +29 -0
- package/templates/template/backend/schema/tags.ts +9 -0
- package/templates/template/backend/schema/users.ts +32 -0
- package/templates/template/{config → backend}/storage.ts +4 -4
- package/templates/template/backend/tsconfig.json +15 -20
- package/templates/template/docker-compose.yml +3 -3
- package/templates/template/frontend/package.json +0 -2
- package/templates/template/frontend/src/App.tsx +10 -4
- package/templates/template/frontend/src/cms/authors.tsx +7 -0
- package/templates/template/frontend/src/cms/posts.tsx +27 -0
- package/templates/template/frontend/src/cms/tags.tsx +11 -0
- package/templates/template/frontend/src/cms/ui-config.json +3 -0
- package/templates/template/frontend/src/cms/users.tsx +54 -0
- package/templates/template/frontend/src/{virtual.d.ts → vite-env.d.ts} +0 -4
- package/templates/template/frontend/vite.config.ts +6 -2
- package/templates/template/gitignore +1 -1
- package/templates/template/package.json +1 -2
- package/templates/template/pnpm-workspace.yaml +0 -1
- package/templates/template/scripts/example.ts +3 -3
- package/templates/template/tsconfig.json +1 -1
- package/templates/views/AppView.tsx.tmpl +4 -4
- package/templates/views/EntityView.tsx.tmpl +3 -4
- package/dist/api-keys-Dfw5-9s1.js.map +0 -1
- package/dist/apps-MKQbgDtN.js.map +0 -1
- package/dist/build-BuKTnec8.js.map +0 -1
- package/dist/bundle-BAH4FCju.js.map +0 -1
- package/dist/cloud-DtADfWwn.js.map +0 -1
- package/dist/collection-drift-BKj_BoMq.js +0 -106
- package/dist/collection-drift-BKj_BoMq.js.map +0 -1
- package/dist/collections-dir-DlvDhime.js +0 -69
- package/dist/collections-dir-DlvDhime.js.map +0 -1
- package/dist/console-CdwIYOMV.js.map +0 -1
- package/dist/context-AXdAh-q8.js.map +0 -1
- package/dist/db-DBbKpjYX.js.map +0 -1
- package/dist/derive-ae9UOoOB.js.map +0 -1
- package/dist/dev-C93d4QIv.js.map +0 -1
- package/dist/dev-preflight-Cxv3TiD1.js.map +0 -1
- package/dist/doctor-BBPQUO2g.js.map +0 -1
- package/dist/eject-DABcDnPN.js.map +0 -1
- package/dist/fold-static-BWzxNn06.js.map +0 -1
- package/dist/generate-view-IFwCADvb.js.map +0 -1
- package/dist/generate_sdk-DNmNuFuW.js.map +0 -1
- package/dist/init-vL1DWOeC.js.map +0 -1
- package/dist/last-dev-database-DpW5dfoX.js +0 -2
- package/dist/manifest-BtzDy7KQ.js.map +0 -1
- package/dist/path-flags-DNvtEi2-.js +0 -92
- package/dist/path-flags-DNvtEi2-.js.map +0 -1
- package/dist/project-CasK56vN.js.map +0 -1
- package/dist/pull-DDMpsZ5r.js.map +0 -1
- package/dist/resolve-D647F1LA.js +0 -2
- package/dist/schema-DtLPsXbT.js.map +0 -1
- package/dist/schema-reconcile-DkArN9jF.js +0 -2
- package/dist/skills-CbwV6vw_.js.map +0 -1
- package/dist/status-BREvtzJm.js.map +0 -1
- package/dist/storage-CO9ouK76.js.map +0 -1
- package/dist/utils/collection-drift.d.ts +0 -27
- package/dist/utils/collections-dir.d.ts +0 -14
- package/dist/verify-Y3rWSgfA.js +0 -730
- package/dist/verify-Y3rWSgfA.js.map +0 -1
- package/templates/overlays/baas/config/index.ts +0 -24
- package/templates/overlays/baas/config/package.json +0 -30
- package/templates/template/config/cms.d.ts +0 -15
- package/templates/template/config/collections/authors.ts +0 -47
- package/templates/template/config/collections/index.ts +0 -44
- package/templates/template/config/collections/posts.ts +0 -94
- package/templates/template/config/collections/presets/blank/index.ts +0 -5
- package/templates/template/config/collections/presets/ecommerce/categories.ts +0 -42
- package/templates/template/config/collections/presets/ecommerce/index.ts +0 -31
- package/templates/template/config/collections/presets/ecommerce/orders.ts +0 -78
- package/templates/template/config/collections/presets/ecommerce/products.ts +0 -73
- package/templates/template/config/collections/tags.ts +0 -27
- package/templates/template/config/collections/users.ts +0 -149
- package/templates/template/config/frontend-assets.d.ts +0 -17
- package/templates/template/config/index.ts +0 -12
- package/templates/template/config/package.json +0 -30
- package/templates/template/config/tsconfig.json +0 -35
- /package/templates/eject/{config → backend}/resources.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-view-CTOluXvH.js","names":[],"sources":["../src/commands/generate-view.ts"],"sourcesContent":["/**\n * `rebase generate view <slug>` — scaffold a custom admin screen and register it.\n *\n * Most back-office screens are a table, a form or a board, and the admin draws\n * those from the table. The rest — a dispatch board, a reconciliation\n * screen, a record's audit trail — are a hundred lines of React. Written inside\n * the admin they inherit the sign-in, the security rules, the sidebar, the UI\n * kit and the data layer; written as a separate app they have to rebuild every\n * one of those. This command writes the first version of that file where the\n * admin will find it, so the screen starts native and registered.\n *\n * Two places, one file each:\n *\n * - **A screen** (default): `<frontend>/src/views/<Name>View.tsx`, listed in\n * `<frontend>/src/views/index.ts` as an `AppView`, which `App.tsx` hands to\n * `<RebaseCMS views>`. The first run wires `App.tsx`; later runs only append\n * to the list.\n * - **A record tab** (`--collection <slug>`, the slug of a table in\n * `backend/schema`): the same file location, with a component that takes\n * `EntityCustomViewParams`, added to the `entityViews` of that table's\n * `customizeTable(…)` in `<frontend>/src/cms/` — imported directly, because\n * that directory is the admin's own code and the backend never reads it. A\n * table with no customization yet gets one, `<frontend>/src/cms/<slug>.tsx`,\n * listed in `cms/index.ts`'s `tableCustomizations` when there is one.\n *\n * The frontend is where `rebase.json` says the CMS is (the static app with a\n * `cms` mount), which is `frontend/` in everything `rebase init` writes. A\n * project with no admin panel (`rebase init --headless`) is refused: there is\n * nowhere for a view to render.\n *\n * Edits to existing files are textual and conservative. When `App.tsx` already\n * passes its own `views`, or a customization's shape is not one this can read, the\n * view file is still written and the command prints the one line to add by\n * hand instead of guessing.\n */\nimport fs from \"fs\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\nimport chalk from \"chalk\";\n\nimport { tableIdentifier } from \"@rebasepro/common\";\nimport { cmsMountOf, loadManifest } from \"../manifest\";\nimport { resolveSchemaDir } from \"../utils/schema-dir\";\nimport { declaredTables } from \"../utils/schema-text\";\nimport { requireProjectRoot } from \"../utils/project\";\nimport { parseCommandArgs, UsageError, wantsHelp } from \"../utils/args\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\n/** What `rebase generate` dispatches. Read by `cli.ts` to name the subcommand. */\nexport const GENERATE_SUBCOMMANDS = [\"view\"] as const;\n\nconst VIEW_FLAGS = {\n \"--collection\": String,\n \"--name\": String,\n \"--icon\": String,\n \"--dry-run\": Boolean,\n \"--force\": Boolean\n} as const;\n\n/** A slug is a URL segment and an entity view key: kebab-case, starting with a letter. */\nconst SLUG_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\n\n/**\n * Top-level paths the admin's own routes answer (`RebaseRouteDefs` in\n * `@rebasepro/cms`): `/c/*` the collections, `/s` Studio, `/settings`. They are\n * declared before custom views, so a screen at one of them was listed in the\n * sidebar and opened the built-in page instead.\n */\nconst RESERVED_SCREEN_SLUGS: readonly string[] = [\"c\", \"s\", \"settings\"];\n\nexport interface GenerateViewOptions {\n projectRoot: string;\n slug: string;\n /** Register as a tab on this table's records (its slug) instead of as a screen. */\n collection?: string;\n /** The label in the sidebar or on the tab. Defaults to the slug in sentence case. */\n name?: string;\n /** A Lucide icon name for the sidebar. Screens only. */\n icon?: string;\n /** Replace an existing view file. Registration is never duplicated. */\n force?: boolean;\n}\n\nexport interface PlannedFile {\n /** Absolute path. */\n path: string;\n contents: string;\n action: \"create\" | \"update\" | \"replace\";\n}\n\nexport interface GenerateViewPlan {\n kind: \"app\" | \"entity\";\n componentName: string;\n viewFile: string;\n files: PlannedFile[];\n /** Steps the command could not take itself, as sentences to print. */\n manualSteps: string[];\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Names\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** `orders-board` → `OrdersBoardView`; `sales-view` → `SalesView`, not `SalesViewView`. */\nexport function viewComponentName(slug: string): string {\n const pascal = slug.split(\"-\").map(part => part.charAt(0).toUpperCase() + part.slice(1)).join(\"\");\n return pascal.endsWith(\"View\") ? pascal : `${pascal}View`;\n}\n\n/** `orders-board` → `Orders board`: labels are sentence case in the admin. */\nexport function viewLabel(slug: string): string {\n const words = slug.split(\"-\").join(\" \");\n return words.charAt(0).toUpperCase() + words.slice(1);\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Reading source without a parser\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * The source with every string, template literal, regular expression and\n * comment blanked out, character for character, so brackets and keys can be\n * found by position without being fooled by a `{` inside a string. String\n * contents become `_` (they are still \"something\"), comments become spaces.\n *\n * Exported for its tests.\n */\nexport function maskCode(source: string): string {\n const out = source.split(\"\");\n let i = 0;\n const blank = (from: number, to: number, fill: string) => {\n for (let k = from; k < to; k++) if (out[k] !== \"\\n\") out[k] = fill;\n };\n const previousSignificant = (at: number): string => {\n for (let k = at - 1; k >= 0; k--) {\n const ch = out[k];\n if (ch !== \" \" && ch !== \"\\t\" && ch !== \"\\n\" && ch !== \"\\r\") return ch;\n }\n return \"\";\n };\n while (i < source.length) {\n const ch = source[i];\n const next = source[i + 1];\n if (ch === \"/\" && next === \"/\") {\n const end = source.indexOf(\"\\n\", i);\n const stop = end === -1 ? source.length : end;\n blank(i, stop, \" \");\n i = stop;\n } else if (ch === \"/\" && next === \"*\") {\n const end = source.indexOf(\"*/\", i + 2);\n const stop = end === -1 ? source.length : end + 2;\n blank(i, stop, \" \");\n i = stop;\n } else if (ch === \"\\\"\" || ch === \"'\" || ch === \"`\") {\n let k = i + 1;\n while (k < source.length && source[k] !== ch) {\n if (source[k] === \"\\\\\") k++;\n k++;\n }\n blank(i + 1, k, \"_\");\n i = k + 1;\n } else if (ch === \"/\" && (previousSignificant(i) === \"\" || \"(,=:[!&|?{;\".includes(previousSignificant(i)))) {\n // A regular expression literal: `/` where a value is expected. Not\n // after `}`, which in a .tsx file is far more often `{value}/>`.\n let k = i + 1;\n let inClass = false;\n while (k < source.length && source[k] !== \"\\n\") {\n if (source[k] === \"\\\\\") k++;\n else if (source[k] === \"[\") inClass = true;\n else if (source[k] === \"]\") inClass = false;\n else if (source[k] === \"/\" && !inClass) break;\n k++;\n }\n blank(i + 1, k, \"_\");\n i = k + 1;\n } else {\n i++;\n }\n }\n return out.join(\"\");\n}\n\nconst CLOSERS: Record<string, string> = { \"{\": \"}\", \"[\": \"]\", \"(\": \")\" };\n\n/** The index of the bracket closing the one at `open`, in masked source. */\nfunction matchClose(masked: string, open: number): number {\n const stack: string[] = [];\n for (let i = open; i < masked.length; i++) {\n const ch = masked[i];\n if (ch in CLOSERS) stack.push(CLOSERS[ch]);\n else if (ch === \"}\" || ch === \"]\" || ch === \")\") {\n if (stack.pop() !== ch) return -1;\n if (stack.length === 0) return i;\n }\n }\n return -1;\n}\n\n/** The index of the innermost `{` still open at `at`, in masked source. */\nfunction enclosingBrace(masked: string, at: number): number {\n const stack: number[] = [];\n for (let i = 0; i < at; i++) {\n const ch = masked[i];\n if (ch === \"{\" || ch === \"[\" || ch === \"(\") stack.push(i);\n else if (ch === \"}\" || ch === \"]\" || ch === \")\") stack.pop();\n }\n for (let k = stack.length - 1; k >= 0; k--) {\n if (masked[stack[k]] === \"{\") return stack[k];\n }\n return -1;\n}\n\n/**\n * The position of `key:` as a direct property of the object whose `{` is at\n * `open`, followed by `opener` (`{` or `[`) — or -1.\n */\nfunction directProperty(masked: string, open: number, key: string, opener: \"{\" | \"[\"): { keyAt: number; valueOpen: number } | undefined {\n const close = matchClose(masked, open);\n if (close === -1) return undefined;\n const pattern = new RegExp(`(^|[\\\\s,{])${key}\\\\s*:\\\\s*\\\\${opener}`, \"g\");\n const body = masked.slice(open + 1, close);\n for (const match of body.matchAll(pattern)) {\n const keyAt = open + 1 + (match.index ?? 0) + match[1].length;\n if (enclosingBrace(masked, keyAt) !== open) continue;\n return { keyAt, valueOpen: open + 1 + (match.index ?? 0) + match[0].length - 1 };\n }\n return undefined;\n}\n\nfunction lineStart(source: string, at: number): number {\n return source.lastIndexOf(\"\\n\", at - 1) + 1;\n}\n\nfunction indentAt(source: string, at: number): string {\n const start = lineStart(source, at);\n return /^[ \\t]*/.exec(source.slice(start))?.[0] ?? \"\";\n}\n\n/**\n * The indentation step a file uses: the smallest non-zero leading run of\n * spaces, not counting the ` * ` lines of a block comment.\n */\nfunction indentUnit(source: string): string {\n if (/^\\t/m.test(source)) return \"\\t\";\n let unit = Infinity;\n for (const match of source.matchAll(/^( +)[^\\s*]/gm)) unit = Math.min(unit, match[1].length);\n return \" \".repeat(Number.isFinite(unit) ? unit : 4);\n}\n\nfunction reindent(block: string, indent: string): string {\n return block.split(\"\\n\").map(line => (line ? indent + line : line)).join(\"\\n\");\n}\n\n/**\n * Insert `element` (already indented one level past `indent`) as the last item\n * of the array whose `[` is at `open`.\n */\nfunction appendToArray(source: string, masked: string, open: number, element: string): string {\n const close = matchClose(masked, open);\n const inner = masked.slice(open + 1, close);\n const indent = indentAt(source, open);\n if (inner.trim() === \"\") {\n return `${source.slice(0, open + 1)}\\n${element}\\n${indent}${source.slice(close)}`;\n }\n // After the last non-blank character of the content, keeping any comment\n // after it where it was.\n let last = close - 1;\n while (last > open && /\\s/.test(masked[last])) last--;\n const hasTrailingComma = masked[last] === \",\";\n const insertAt = last + 1;\n return `${source.slice(0, insertAt)}${hasTrailingComma ? \"\" : \",\"}\\n${element}${source.slice(insertAt)}`;\n}\n\n/** Add an import line after the file's last import statement. */\nfunction addImport(source: string, line: string): string {\n const masked = maskCode(source);\n let end = 0;\n for (const match of masked.matchAll(/^import\\b[\\s\\S]*?[\"'][^\"'\\n]*[\"'];?[ \\t]*$/gm)) {\n end = (match.index ?? 0) + match[0].length;\n }\n if (end === 0) return `${line}\\n${source}`;\n return `${source.slice(0, end)}\\n${line}${source.slice(end)}`;\n}\n\n/** A path import from `fromDir` to `toFile`, without extension, always starting with `.`. */\nfunction relativeImport(fromDir: string, toFile: string): string {\n const relative = path.relative(fromDir, toFile).split(path.sep).join(\"/\").replace(/\\.tsx?$/, \"\");\n return relative.startsWith(\".\") ? relative : `./${relative}`;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Where things are\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** The admin's frontend directory: the static app that mounts the CMS, or `frontend/`. */\nexport function resolveFrontendDir(projectRoot: string): string | undefined {\n try {\n const cms = cmsMountOf(loadManifest(projectRoot).manifest);\n if (cms) return path.join(projectRoot, cms.app.root);\n } catch {\n // A malformed rebase.json is reported by the commands that own it.\n }\n const fallback = path.join(projectRoot, \"frontend\");\n return fs.existsSync(path.join(fallback, \"src\")) ? fallback : undefined;\n}\n\n/** The tables directory, as the backend app declares it — one resolver for every command. */\nexport { resolveSchemaDir };\n\n/** Every source file under the admin's `src/cms`, sorted: where table customizations live. */\nfunction customizationFiles(dir: string): string[] {\n if (!fs.existsSync(dir)) return [];\n const out: string[] = [];\n const entries = fs.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));\n for (const entry of entries) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if (entry.name !== \"node_modules\") out.push(...customizationFiles(full));\n } else if (/\\.tsx?$/.test(entry.name) && !/\\.(test|spec|d)\\.tsx?$/.test(entry.name)) {\n out.push(full);\n }\n }\n return out;\n}\n\n/**\n * Every `customizeTable(\"<slug>\", {` of a table, in code (not in a comment or\n * a string): the file, and where the options object opens. Empty when no file\n * under `cmsDir` customizes the table.\n */\nfunction findCustomization(cmsDir: string, slug: string): { file: string; optionsOpen: number }[] {\n const found: { file: string; optionsOpen: number }[] = [];\n const call = /\\bcustomizeTable\\s*(?:<[^>]*>)?\\(\\s*([\"'`])([^\"'`\\n]+)\\1\\s*,\\s*\\{/g;\n for (const file of customizationFiles(cmsDir)) {\n const source = fs.readFileSync(file, \"utf8\");\n const masked = maskCode(source);\n for (const match of source.matchAll(call)) {\n const at = match.index ?? 0;\n if (match[2] !== slug || masked[at] !== \"c\") continue;\n found.push({ file, optionsOpen: at + match[0].length - 1 });\n }\n }\n return found;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// The files\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * The scaffolds live in `templates/views/` rather than in template literals\n * here: they import React and the admin packages, and this package's sources\n * must not name those, even inside a string (`pnpm check:types-headless`).\n */\nfunction viewTemplate(name: string): string {\n const cliRoot = findCliRoot(__dirname);\n if (!cliRoot) throw new Error(`The CLI's templates/views folder is missing from ${__dirname}.`);\n return fs.readFileSync(path.join(cliRoot, \"templates\", \"views\", name), \"utf8\");\n}\n\n/** Walk up to the package root, which holds `templates/views`. */\nfunction findCliRoot(from: string): string | null {\n const root = path.parse(from).root;\n let dir = from;\n while (dir && dir !== root) {\n if (fs.existsSync(path.join(dir, \"templates\", \"views\"))) return dir;\n dir = path.dirname(dir);\n }\n return null;\n}\n\ntype ViewTemplateOptions = { slug: string; componentName: string; label: string; collection: string };\n\n/** The `{ key, name, Builder }` an entity view is registered as, with `unit` indentation inside. */\nfunction entityViewEntry(view: { key: string; name: string; componentName: string }, unit: string): string {\n return [\n \"{\",\n `${unit}key: ${JSON.stringify(view.key)},`,\n `${unit}name: ${JSON.stringify(view.name)},`,\n `${unit}Builder: ${view.componentName}`,\n \"}\"\n ].join(\"\\n\");\n}\n\n/**\n * A label as JSX text: written as is when it is plain, as a string expression\n * when it holds a character JSX reads — `{`, `}`, `<`, `>`, `&`. Pasted raw,\n * `--name \"KPIs {beta}\"` wrote `<Typography>KPIs {beta}</Typography>`, and the\n * view did not compile (\"Cannot find name 'beta'\").\n */\nfunction jsxText(text: string): string {\n return /[{}<>&]/.test(text) ? `{${JSON.stringify(text)}}` : text;\n}\n\n/** A label inside the leading `/** … *\\/` comment: one line, and no `*\\/` to close it early. */\nfunction commentText(text: string): string {\n return text.replace(/[\\r\\n]+/g, \" \").replaceAll(\"*/\", \"*\\\\/\");\n}\n\nfunction fillViewTemplate(template: string, options: ViewTemplateOptions): string {\n const { slug, componentName, label, collection } = options;\n return template\n .replaceAll(\"\\\"__COLLECTION__\\\"\", JSON.stringify(collection))\n .replaceAll(\"__COLLECTION__\", collection)\n .replaceAll(\"__COMPONENT__\", componentName)\n .replaceAll(\"__label_jsx__\", jsxText(label.toLowerCase()))\n .replaceAll(\"__LABEL_JSX__\", jsxText(label))\n .replaceAll(\"__label__\", commentText(label.toLowerCase()))\n .replaceAll(\"__LABEL__\", commentText(label))\n .replaceAll(\"__SLUG__\", slug);\n}\n\nexport function appViewSource(options: ViewTemplateOptions): string {\n return fillViewTemplate(viewTemplate(\"AppView.tsx.tmpl\"), options);\n}\n\nexport function entityViewSource(options: ViewTemplateOptions): string {\n return fillViewTemplate(viewTemplate(\"EntityView.tsx.tmpl\"), options);\n}\n\nfunction viewsIndexHeader(): string {\n return viewTemplate(\"index.ts.tmpl\");\n}\n\nfunction appViewEntry(options: { slug: string; label: string; icon: string; componentName: string }, unit: string): string {\n return [\n \"{\",\n `${unit}slug: ${JSON.stringify(options.slug)},`,\n `${unit}name: ${JSON.stringify(options.label)},`,\n `${unit}icon: ${JSON.stringify(options.icon)},`,\n `${unit}view: ${options.componentName}`,\n \"}\"\n ].join(\"\\n\");\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Planning\n// ─────────────────────────────────────────────────────────────────────────────\n\nfunction readIfExists(file: string): string | undefined {\n return fs.existsSync(file) ? fs.readFileSync(file, \"utf8\") : undefined;\n}\n\n/**\n * The frontend's package.json gains `@rebasepro/cms-types` when it lacks it.\n *\n * The view files import their prop types from it, and under pnpm a package the\n * frontend does not declare does not resolve from the frontend — the frontend's\n * `tsc` would fail on the first generated view. The version is the one the\n * frontend already uses for `@rebasepro/cms`, so the two cannot drift.\n */\nfunction planCmsTypesDependency(frontendDir: string, files: PlannedFile[], manualSteps: string[]): void {\n const manifestFile = path.join(frontendDir, \"package.json\");\n const raw = readIfExists(manifestFile);\n if (raw === undefined) return;\n let manifest: { dependencies?: Record<string, string>; devDependencies?: Record<string, string> };\n try {\n manifest = JSON.parse(raw);\n } catch {\n return;\n }\n const declared = { ...manifest.devDependencies, ...manifest.dependencies };\n if (declared[\"@rebasepro/cms-types\"]) return;\n const version = declared[\"@rebasepro/cms\"] ?? declared[\"@rebasepro/app\"];\n if (!version) return;\n const dependencies = { ...manifest.dependencies, \"@rebasepro/cms-types\": version };\n const sorted = Object.fromEntries(Object.entries(dependencies).sort(([a], [b]) => a.localeCompare(b)));\n const indent = /^(\\s+)\"/m.exec(raw)?.[1] ?? \" \";\n files.push({\n path: manifestFile,\n contents: `${JSON.stringify({ ...manifest, dependencies: sorted }, null, indent)}\\n`,\n action: \"update\"\n });\n manualSteps.push(`Run your package manager's install: ${path.basename(frontendDir)}/package.json now depends on @rebasepro/cms-types, which the view imports its types from.`);\n}\n\nfunction defaultCollectionFor(projectRoot: string): string {\n const slugs = declaredTables(resolveSchemaDir(projectRoot)).map(entry => entry.slug);\n return slugs.find(slug => slug !== \"users\") ?? slugs[0] ?? \"users\";\n}\n\n/**\n * Everything `rebase generate view` would write, without writing it.\n *\n * @throws UsageError when the slug is not a slug, there is no admin panel, the\n * view already exists (without `force`), or `--collection` names nothing.\n */\nexport function planGenerateView(options: GenerateViewOptions): GenerateViewPlan {\n const { projectRoot, slug } = options;\n if (!SLUG_PATTERN.test(slug)) {\n throw new UsageError(\n `\"${slug}\" is not a view slug: use lowercase letters, digits and dashes, starting with a letter (e.g. orders-board).`\n );\n }\n if (!options.collection && RESERVED_SCREEN_SLUGS.includes(slug)) {\n throw new UsageError(\n `\"${slug}\" is reserved: the admin's own routes answer /${slug}, so a screen there would never show. ` +\n `Pick another slug (e.g. ${slug === \"settings\" ? \"app-settings\" : `${slug}-view`}).`\n );\n }\n const frontendDir = resolveFrontendDir(projectRoot);\n if (!frontendDir) {\n throw new UsageError(\n \"This project has no admin panel to add a view to: rebase.json declares no app with a `cms` mount, and there is no frontend/src. \" +\n \"A project created with `rebase init --headless` has no admin.\"\n );\n }\n\n const componentName = viewComponentName(slug);\n const label = options.name?.trim() || viewLabel(slug);\n const viewsDir = path.join(frontendDir, \"src\", \"views\");\n const viewFile = path.join(viewsDir, `${componentName}.tsx`);\n const files: PlannedFile[] = [];\n const manualSteps: string[] = [];\n\n const viewExists = fs.existsSync(viewFile);\n if (viewExists && !options.force) {\n throw new UsageError(\n `${path.relative(projectRoot, viewFile)} already exists. Pass --force to replace it; its registration is kept.`\n );\n }\n const viewAction: PlannedFile[\"action\"] = viewExists ? \"replace\" : \"create\";\n\n if (options.collection) {\n const kind = \"entity\" as const;\n const table = options.collection;\n const schemaDir = resolveSchemaDir(projectRoot);\n const declared = declaredTables(schemaDir);\n if (!declared.some(entry => entry.slug === table)) {\n const known = [...new Set(declared.map(entry => entry.slug))].sort();\n throw new UsageError(\n `No table with slug \"${table}\" under ${path.relative(projectRoot, schemaDir) || \".\"}.` +\n (known.length ? ` Declared: ${known.join(\", \")}.` : \"\")\n );\n }\n const cmsDir = path.join(frontendDir, \"src\", \"cms\");\n const customizations = findCustomization(cmsDir, table);\n if (customizations.length > 1) {\n throw new UsageError(\n `More than one customizeTable(\"${table}\", …) under ${path.relative(projectRoot, cmsDir)}: ` +\n `${[...new Set(customizations.map(entry => path.relative(projectRoot, entry.file)))].join(\", \")}.`\n );\n }\n\n files.push({\n path: viewFile,\n contents: entityViewSource({ slug, componentName, label, collection: table }),\n action: viewAction\n });\n\n const view = { key: slug, name: label, componentName };\n if (customizations.length === 1) {\n const [{ file, optionsOpen }] = customizations;\n const importLine = `import { ${componentName} } from \"${relativeImport(path.dirname(file), viewFile)}\";`;\n const source = fs.readFileSync(file, \"utf8\");\n const updated = registerEntityView(source, optionsOpen, view);\n const where = path.relative(projectRoot, file);\n if (updated === \"already\") {\n // Registered on an earlier run: --force replaced the file only.\n } else if (updated === undefined) {\n manualSteps.push(\n `Add this to the entityViews of customizeTable(\"${table}\", …) in ${where}: ` +\n `{ key: ${JSON.stringify(slug)}, name: ${JSON.stringify(label)}, Builder: ${componentName} }, and ${importLine}`\n );\n } else {\n files.push({ path: file, contents: addImport(updated, importLine), action: \"update\" });\n }\n } else {\n const identifier = `${tableIdentifier(table)}Cms`;\n const file = path.join(cmsDir, `${table}.tsx`);\n if (fs.existsSync(file)) {\n throw new UsageError(\n `${path.relative(projectRoot, file)} exists but holds no customizeTable(\"${table}\", …): ` +\n \"add the record tab to the table's customization by hand, or move that file aside.\"\n );\n }\n const unit = \" \";\n files.push({\n path: file,\n contents: [\n \"import { customizeTable } from \\\"@rebasepro/cms\\\";\",\n `import { ${componentName} } from \"${relativeImport(cmsDir, viewFile)}\";`,\n \"\",\n `export const ${identifier} = customizeTable(\"${table}\", {`,\n `${unit}entityViews: [`,\n reindent(entityViewEntry(view, unit), unit + unit),\n `${unit}]`,\n \"});\",\n \"\"\n ].join(\"\\n\"),\n action: \"create\"\n });\n // Handed to the admin where the project lists its customizations:\n // a `tableCustomizations` list exported by `cms/index.ts`, else\n // the one `App.tsx` passes to `<RebaseCMS>`.\n const indexFile = path.join(cmsDir, \"index.ts\");\n const appFile = path.join(frontendDir, \"src\", \"App.tsx\");\n const index = readIfExists(indexFile);\n const app = readIfExists(appFile);\n const listedInIndex = index === undefined ? undefined : listCustomization(index, identifier, `./${table}`);\n const listedInApp = listedInIndex === undefined && app !== undefined\n ? listCustomization(app, identifier, `./cms/${table}`)\n : undefined;\n if (listedInIndex !== undefined) {\n if (listedInIndex !== \"already\") files.push({ path: indexFile, contents: listedInIndex, action: \"update\" });\n } else if (listedInApp !== undefined) {\n if (listedInApp !== \"already\") files.push({ path: appFile, contents: listedInApp, action: \"update\" });\n } else {\n manualSteps.push(\n `Hand the customization to the admin: import { ${identifier} } from \"./cms/${table}\" and add it to ` +\n `<RebaseCMS tableCustomizations={[…]}> in ${path.relative(projectRoot, appFile)}.`\n );\n }\n }\n planCmsTypesDependency(frontendDir, files, manualSteps);\n return { kind, componentName, viewFile, files, manualSteps };\n }\n\n files.push({\n path: viewFile,\n contents: appViewSource({ slug, componentName, label, collection: defaultCollectionFor(projectRoot) }),\n action: viewAction\n });\n\n // The list of screens.\n const indexFile = path.join(viewsDir, \"index.ts\");\n const existingIndex = readIfExists(indexFile);\n const icon = options.icon ?? \"LayoutDashboard\";\n if (existingIndex === undefined) {\n const unit = \" \";\n files.push({\n path: indexFile,\n contents: `${viewsIndexHeader()}import { ${componentName} } from \"./${componentName}\";\\n\\n` +\n `export const views: AppView[] = [\\n${reindent(appViewEntry({ slug, label, icon, componentName }, unit), unit)}\\n];\\n`,\n action: \"create\"\n });\n } else {\n const updated = registerAppView(existingIndex, { slug, label, icon, componentName });\n if (updated === undefined) {\n manualSteps.push(\n `Add { slug: ${JSON.stringify(slug)}, name: ${JSON.stringify(label)}, view: ${componentName} } to the views in ${path.relative(projectRoot, indexFile)}.`\n );\n } else if (updated !== \"already\") {\n files.push({ path: indexFile, contents: updated, action: \"update\" });\n }\n }\n\n // App.tsx hands the list to <RebaseCMS>, once.\n const appFile = path.join(frontendDir, \"src\", \"App.tsx\");\n const app = readIfExists(appFile);\n const wired = app === undefined ? undefined : wireViewsIntoApp(app);\n if (wired === undefined) {\n manualSteps.push(\n `Pass the screens to the admin: import { views } from \"./views\" and add views={views} to <RebaseCMS> in ${path.relative(projectRoot, appFile)}` +\n \" (or spread ...views into the views it already passes).\"\n );\n } else if (wired !== \"already\") {\n files.push({ path: appFile, contents: wired, action: \"update\" });\n }\n\n planCmsTypesDependency(frontendDir, files, manualSteps);\n return { kind: \"app\", componentName, viewFile, files, manualSteps };\n}\n\n/**\n * `views/index.ts` with one more entry, `\"already\"` when the slug is listed, or\n * `undefined` when the file has no `export const views … = [`.\n *\n * Exported for its tests.\n */\nexport function registerAppView(\n source: string,\n options: { slug: string; label: string; icon: string; componentName: string }\n): string | \"already\" | undefined {\n const masked = maskCode(source);\n const declaration = /export\\s+const\\s+views\\b[^=]*=\\s*\\[/.exec(masked);\n if (!declaration) return undefined;\n const open = declaration.index + declaration[0].length - 1;\n if (matchClose(masked, open) === -1) return undefined;\n const close = matchClose(masked, open);\n const listed = source.slice(open, close);\n if (new RegExp(`slug\\\\s*:\\\\s*[\"']${options.slug}[\"']`).test(listed)) return \"already\";\n\n const unit = indentUnit(source);\n const indent = indentAt(source, open) + unit;\n const element = reindent(appViewEntry(options, unit), indent);\n const appended = appendToArray(source, masked, open, element);\n return addImport(appended, `import { ${options.componentName} } from \"./${options.componentName}\";`);\n}\n\n/**\n * `App.tsx` with `views={views}` on `<RebaseCMS>` and its import, `\"already\"`\n * when it passes exactly that, or `undefined` when it cannot be done safely:\n * no `<RebaseCMS`, a `views` prop of its own, or a `views` name already in scope.\n *\n * Exported for its tests.\n */\nexport function wireViewsIntoApp(source: string): string | \"already\" | undefined {\n const masked = maskCode(source);\n const tag = /<RebaseCMS\\b/.exec(masked);\n if (!tag) return undefined;\n const tagEnd = masked.indexOf(\">\", tag.index);\n if (tagEnd === -1) return undefined;\n const attributes = masked.slice(tag.index, tagEnd);\n const importsViews = /import\\s*\\{\\s*views\\s*\\}\\s*from\\s*[\"']\\.\\/views(?:\\/index)?[\"']/.test(source);\n if (/\\sviews\\s*=/.test(attributes)) {\n return importsViews && /\\sviews\\s*=\\s*\\{\\s*views\\s*\\}/.test(attributes) ? \"already\" : undefined;\n }\n if (/\\bviews\\b/.test(masked)) return undefined;\n\n const insertAt = tag.index + \"<RebaseCMS\".length;\n const afterTag = source.slice(insertAt);\n const nextLine = /^[ \\t]*\\r?\\n([ \\t]*)\\S/.exec(afterTag);\n const attribute = nextLine ? `\\n${nextLine[1]}views={views}` : \" views={views}\";\n const withProp = source.slice(0, insertAt) + attribute + source.slice(insertAt);\n return addImport(withProp, \"import { views } from \\\"./views\\\";\");\n}\n\n/**\n * The customization file with a `{ key, name, Builder }` entry in the\n * `entityViews` of the `customizeTable(…)` options object whose `{` is at\n * `optionsOpen`; `\"already\"` when that key is there; `undefined` when the\n * shape cannot be read. The component's import is the caller's to add.\n *\n * Exported for its tests.\n */\nexport function registerEntityView(\n source: string,\n optionsOpen: number,\n view: { key: string; name: string; componentName: string }\n): string | \"already\" | undefined {\n const masked = maskCode(source);\n const close = matchClose(masked, optionsOpen);\n if (close === -1) return undefined;\n const unit = indentUnit(source);\n const entry = entityViewEntry(view, unit);\n\n const entityViews = directProperty(masked, optionsOpen, \"entityViews\", \"[\");\n if (entityViews) {\n const listClose = matchClose(masked, entityViews.valueOpen);\n if (listClose === -1) return undefined;\n const listed = source.slice(entityViews.valueOpen, listClose);\n if (new RegExp(`key\\\\s*:\\\\s*[\"']${view.key}[\"']|[\"']${view.key}[\"']`).test(listed)) return \"already\";\n const indent = indentAt(source, entityViews.keyAt) + unit;\n return appendToArray(source, masked, entityViews.valueOpen, reindent(entry, indent));\n }\n\n // `entityViews` as the first property of the options.\n const indent = indentAt(source, optionsOpen) + unit;\n const block = `${indent}entityViews: [\\n${reindent(entry, indent + unit)}\\n${indent}]`;\n const empty = masked.slice(optionsOpen + 1, close).trim() === \"\";\n const insertAt = optionsOpen + 1;\n return empty\n ? `${source.slice(0, insertAt)}\\n${block}\\n${indentAt(source, optionsOpen)}${source.slice(close)}`\n : `${source.slice(0, insertAt)}\\n${block},${source.slice(insertAt)}`;\n}\n\n/**\n * A source with `identifier` imported from `importPath` and appended to its\n * list of table customizations — `export const tableCustomizations = [ … ]`\n * (`cms/index.ts`) or `tableCustomizations={[ … ]}` on `<RebaseCMS>`\n * (`App.tsx`); `\"already\"` when it is listed; `undefined` when the source has\n * no such list.\n *\n * Exported for its tests.\n */\nexport function listCustomization(source: string, identifier: string, importPath: string): string | \"already\" | undefined {\n const masked = maskCode(source);\n const declaration = /export\\s+const\\s+tableCustomizations\\b[^=]*=\\s*\\[/.exec(masked)\n ?? /\\btableCustomizations\\s*=\\s*\\{\\s*\\[/.exec(masked);\n if (!declaration) return undefined;\n const open = declaration.index + declaration[0].length - 1;\n const close = matchClose(masked, open);\n if (close === -1) return undefined;\n if (new RegExp(`\\\\b${identifier}\\\\b`).test(masked.slice(open, close))) return \"already\";\n const inner = masked.slice(open + 1, close);\n let appended: string;\n if (inner.trim() !== \"\" && !inner.includes(\"\\n\")) {\n // A list written on one line stays on one line.\n let last = close - 1;\n while (last > open && /\\s/.test(masked[last])) last--;\n const comma = masked[last] === \",\" ? \" \" : \", \";\n appended = `${source.slice(0, last + 1)}${comma}${identifier}${source.slice(last + 1)}`;\n } else {\n const unit = indentUnit(source);\n appended = appendToArray(source, masked, open, `${indentAt(source, open)}${unit}${identifier}`);\n }\n return addImport(appended, `import { ${identifier} } from \"${importPath}\";`);\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// The command\n// ─────────────────────────────────────────────────────────────────────────────\n\nfunction printHelp(): void {\n console.log(`\n${chalk.bold(\"rebase generate\")} — scaffold code into this project\n\n${chalk.bold(\"Usage\")}\n rebase generate view <slug> A screen of the admin, in the sidebar\n rebase generate view <slug> --collection <slug> A tab on every record of a table\n\n${chalk.bold(\"What it writes\")}\n <frontend>/src/views/<Name>View.tsx The component, drawn with @rebasepro/ui\n <frontend>/src/views/index.ts The screens list (AppView[]), wired into\n <RebaseCMS views> in App.tsx on first run\n With --collection, the table's customizeTable(…) in <frontend>/src/cms gains\n an entityViews entry with the component (a new <slug>.tsx when it has none).\n\n${chalk.bold(\"Options\")}\n --collection <slug> Register as a record tab of the table with this slug\n --name <label> Sidebar or tab label ${chalk.gray(\"(default: the slug in sentence case)\")}\n --icon <Lucide name> Sidebar icon for a screen ${chalk.gray(\"(default: LayoutDashboard)\")}\n --dry-run List what would change, and change nothing\n --force Replace an existing view file\n -h, --help Show this help\n`.trim());\n}\n\nexport async function generateCommand(subcommand: string | undefined, rawArgs: string[] = []): Promise<void> {\n if (subcommand === undefined || subcommand === \"--help\" || (subcommand !== \"view\" && wantsHelp(rawArgs))) {\n printHelp();\n return;\n }\n switch (subcommand) {\n case \"view\":\n await generateViewCommand(rawArgs);\n return;\n default:\n throw new UsageError(`Unknown generate command \"${subcommand}\". Available: ${GENERATE_SUBCOMMANDS.join(\", \")}. See \\`rebase generate --help\\`.`);\n }\n}\n\nasync function generateViewCommand(rawArgs: string[]): Promise<void> {\n if (wantsHelp(rawArgs)) {\n printHelp();\n return;\n }\n const { flags, positionals } = parseCommandArgs({\n spec: VIEW_FLAGS,\n rawArgs,\n commandWords: 2,\n command: \"generate view\",\n maxPositionals: 1\n });\n const slug = positionals[0];\n if (!slug) {\n throw new UsageError(\"Name the view: `rebase generate view <slug>`, e.g. `rebase generate view orders-board`.\");\n }\n if (flags[\"--icon\"] && flags[\"--collection\"]) {\n throw new UsageError(\"--icon is for a screen in the sidebar; a record tab (--collection) has no icon here.\");\n }\n\n const projectRoot = requireProjectRoot();\n const plan = planGenerateView({\n projectRoot,\n slug,\n collection: flags[\"--collection\"],\n name: flags[\"--name\"],\n icon: flags[\"--icon\"],\n force: Boolean(flags[\"--force\"])\n });\n const dryRun = Boolean(flags[\"--dry-run\"]);\n\n for (const file of plan.files) {\n if (!dryRun) {\n fs.mkdirSync(path.dirname(file.path), { recursive: true });\n fs.writeFileSync(file.path, file.contents);\n }\n const verb = file.action === \"create\" ? \"created\" : file.action === \"replace\" ? \"replaced\" : \"updated\";\n console.log(`${chalk.green(\"✓\")} ${dryRun ? `would be ${verb}` : verb} ${path.relative(projectRoot, file.path)}`);\n }\n for (const step of plan.manualSteps) {\n console.log(`${chalk.yellow(\"!\")} ${step}`);\n }\n const where = plan.kind === \"app\" ? `/${slug} in the admin` : `a \"${flags[\"--name\"]?.trim() || viewLabel(slug)}\" tab on each ${flags[\"--collection\"]} record`;\n console.log(chalk.gray(` ${plan.componentName} renders at ${where}. Edit ${path.relative(projectRoot, plan.viewFile)} to build the screen.`));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,IAAM,YAAY,KAAK,QAAQ,cAAc,OAAO,KAAK,GAAG,CAAC;;AAG7D,IAAa,uBAAuB,CAAC,MAAM;AAE3C,IAAM,aAAa;CACf,gBAAgB;CAChB,UAAU;CACV,UAAU;CACV,aAAa;CACb,WAAW;AACf;;AAGA,IAAM,eAAe;;;;;;;AAQrB,IAAM,wBAA2C;CAAC;CAAK;CAAK;AAAU;;AAoCtE,SAAgB,kBAAkB,MAAsB;CACpD,MAAM,SAAS,KAAK,MAAM,GAAG,CAAC,CAAC,KAAI,SAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE;CAChG,OAAO,OAAO,SAAS,MAAM,IAAI,SAAS,GAAG,OAAO;AACxD;;AAGA,SAAgB,UAAU,MAAsB;CAC5C,MAAM,QAAQ,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;CACtC,OAAO,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,MAAM,MAAM,CAAC;AACxD;;;;;;;;;AAcA,SAAgB,SAAS,QAAwB;CAC7C,MAAM,MAAM,OAAO,MAAM,EAAE;CAC3B,IAAI,IAAI;CACR,MAAM,SAAS,MAAc,IAAY,SAAiB;EACtD,KAAK,IAAI,IAAI,MAAM,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,MAAM,IAAI,KAAK;CAClE;CACA,MAAM,uBAAuB,OAAuB;EAChD,KAAK,IAAI,IAAI,KAAK,GAAG,KAAK,GAAG,KAAK;GAC9B,MAAM,KAAK,IAAI;GACf,IAAI,OAAO,OAAO,OAAO,OAAQ,OAAO,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c as findProjectRoot, d as readEnvFile } from "./project-CLcF5i8c.js";
|
|
2
|
+
import { O as writeManifest, _ as findBackendApp, b as loadManifest, o as GENERATED_DIR, x as manifestExists } from "./manifest-C3uLDrrJ.js";
|
|
3
|
+
import { n as SCHEMA_DIR_FLAG_HELP, t as PATH_RESOLUTION_RULE } from "./path-flags-7O5uPBcQ.js";
|
|
4
|
+
import { t as loadProjectSchema } from "./project-schema-CsSOG2gE.js";
|
|
5
|
+
import { t as DEV_BACKEND_URL_ENV } from "./dev-server-BLxCbQEP.js";
|
|
6
|
+
import { V as readLink } from "./context--JwaHaZp.js";
|
|
7
7
|
import { t as Refusal } from "./refusal-ReeeGP8a.js";
|
|
8
|
-
import { n as isLoadedCollectionFile } from "./collection-drift-BKj_BoMq.js";
|
|
9
8
|
import chalk from "chalk";
|
|
10
9
|
import fs from "fs";
|
|
11
10
|
import path from "path";
|
|
12
|
-
import { computeSchemaVersion
|
|
13
|
-
import {
|
|
11
|
+
import { computeSchemaVersion } from "@rebasepro/types";
|
|
12
|
+
import { isSchemaDefinitionError } from "@rebasepro/common";
|
|
13
|
+
import { CodegenError, generateSDK, toTableAccessor } from "@rebasepro/codegen";
|
|
14
14
|
//#region src/commands/generate_sdk.ts
|
|
15
15
|
/**
|
|
16
16
|
* CLI command: generate-sdk
|
|
17
17
|
*
|
|
18
|
-
* Reads
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* Uses jiti for dynamic TypeScript import of collection files.
|
|
18
|
+
* Reads the project's tables — `backend/schema`, through the loader the
|
|
19
|
+
* backend boots from, so the SDK describes exactly the tables served — or,
|
|
20
|
+
* with `--from`, a running project's contract, and writes a typed TypeScript
|
|
21
|
+
* SDK to the output directory (default: ./generated/sdk).
|
|
23
22
|
*/
|
|
24
23
|
/** What `--register` writes, and what marks a project as having opted in. */
|
|
25
24
|
var REGISTER_FILE = "register.ts";
|
|
@@ -28,7 +27,7 @@ var REGISTER_MARKER = "// Auto-generated by `rebase generate-sdk --register`. Do
|
|
|
28
27
|
var REGISTER_SOURCE = `${REGISTER_MARKER}
|
|
29
28
|
//
|
|
30
29
|
// Registers this project's generated \`Database\` on \`@rebasepro/types\`, so
|
|
31
|
-
// \`context.data\` in
|
|
30
|
+
// \`context.data\` in table hooks, \`rebase.dataAsAdmin\`, and the
|
|
32
31
|
// \`rebase\` a function or a cron receives are typed from it. Every later
|
|
33
32
|
// \`rebase generate-sdk\` (and \`rebase dev\`) refreshes this directory; delete
|
|
34
33
|
// it to go back to untyped server-side data.
|
|
@@ -41,19 +40,15 @@ declare module "@rebasepro/types" {
|
|
|
41
40
|
}
|
|
42
41
|
`;
|
|
43
42
|
/**
|
|
44
|
-
* Where `--register` writes: `generated/`
|
|
45
|
-
* which is `config/generated/` in a scaffolded project.
|
|
43
|
+
* Where `--register` writes: `backend/generated/` under the project root.
|
|
46
44
|
*
|
|
47
|
-
* Inside `
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* outside `config/` into that package's program, which TypeScript refuses
|
|
52
|
-
* (the file is not under its `rootDir`) — so the types are copied in beside
|
|
53
|
-
* the registration rather than imported from the SDK.
|
|
45
|
+
* Inside `backend/` because that is the program the hooks, functions and
|
|
46
|
+
* crons it types are compiled in. The types are copied in beside the
|
|
47
|
+
* registration rather than imported from `generated/sdk`, which is outside
|
|
48
|
+
* the backend's `rootDir`.
|
|
54
49
|
*/
|
|
55
|
-
function registrationDir(
|
|
56
|
-
return path.join(
|
|
50
|
+
function registrationDir(projectRoot) {
|
|
51
|
+
return path.join(projectRoot, GENERATED_DIR);
|
|
57
52
|
}
|
|
58
53
|
/** Whether this project opted in: the registration is there, and it is ours. */
|
|
59
54
|
function hasRegistration(dir) {
|
|
@@ -83,31 +78,32 @@ function writeRegistration(dir, databaseTypes) {
|
|
|
83
78
|
writeIfChanged(registerPath, REGISTER_SOURCE);
|
|
84
79
|
}
|
|
85
80
|
/**
|
|
86
|
-
* Write the server-side registration from the
|
|
87
|
-
* `
|
|
81
|
+
* Write the server-side registration from the build's tables, exactly as
|
|
82
|
+
* `rebase generate-sdk` writes it.
|
|
88
83
|
*
|
|
89
84
|
* Only for a project that asked for it: `registerDatabase` in `rebase.json`,
|
|
90
85
|
* or a registration an earlier `--register` left, which is kept current. The
|
|
91
|
-
* registration lives in gitignored `
|
|
92
|
-
* job) has none until something writes it, and a bundle compiled without
|
|
93
|
-
* types `context.data` as untyped rows:
|
|
94
|
-
*
|
|
86
|
+
* registration lives in gitignored `backend/generated/`, so a fresh clone (a
|
|
87
|
+
* CI job) has none until something writes it, and a bundle compiled without
|
|
88
|
+
* it types `context.data` as untyped rows: hooks that read a typed column fail
|
|
89
|
+
* to compile there while they compile locally.
|
|
95
90
|
*
|
|
96
91
|
* Returns the directory written, or null when there was nothing to do.
|
|
97
92
|
* Throws when a `register.ts` there is not ours, as `generate-sdk` refuses.
|
|
98
93
|
*/
|
|
99
|
-
async function writeRegistrationForBuild(
|
|
100
|
-
const dir = registrationDir(
|
|
94
|
+
async function writeRegistrationForBuild(projectRoot, tables, registerDatabase) {
|
|
95
|
+
const dir = registrationDir(projectRoot);
|
|
101
96
|
if (!registerDatabase && !hasRegistration(dir)) return null;
|
|
102
|
-
if (
|
|
103
|
-
const
|
|
104
|
-
if (collections.length === 0) return null;
|
|
105
|
-
collections.sort((a, b) => a.slug.localeCompare(b.slug));
|
|
106
|
-
const databaseTypes = generateSDK(collections, { includeReadme: false }).find((file) => file.path === "database.types.ts")?.content;
|
|
97
|
+
if (tables.length === 0) return null;
|
|
98
|
+
const databaseTypes = generateSDK(sortedBySlug(tables), { includeReadme: false }).find((file) => file.path === "database.types.ts")?.content;
|
|
107
99
|
if (databaseTypes === void 0) return null;
|
|
108
100
|
writeRegistration(dir, databaseTypes);
|
|
109
101
|
return dir;
|
|
110
102
|
}
|
|
103
|
+
/** Tables sorted by slug: the same schema generates the same bytes, whatever order the index lists it in. */
|
|
104
|
+
function sortedBySlug(tables) {
|
|
105
|
+
return [...tables].sort((a, b) => a.slug.localeCompare(b.slug));
|
|
106
|
+
}
|
|
111
107
|
/**
|
|
112
108
|
* Whether `rebase.json` asks for the registration (`registerDatabase: true` on
|
|
113
109
|
* the backend app). That is what survives a clone: `generated/` is gitignored,
|
|
@@ -153,69 +149,21 @@ function rememberRegistration(projectRoot) {
|
|
|
153
149
|
}) };
|
|
154
150
|
}
|
|
155
151
|
/**
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* A directory is read as `loadCollectionsFromDirectory` in @rebasepro/server
|
|
159
|
-
* reads it: every top-level collection file, each default-exporting one
|
|
160
|
-
* collection. The barrel (`index.ts`) is not a registry. The runtime, the admin
|
|
161
|
-
* panel, `rebase build` and `rebase schema generate` all scan the directory, and
|
|
162
|
-
* the barrel only orders the panel's navigation and declares
|
|
163
|
-
* `defaultSecurityRules`. This command used to read the barrel instead, so a
|
|
164
|
-
* collection file left out of it was created, served at `/api/data/<slug>` and
|
|
165
|
-
* listed in the panel, and missing from the typed SDK alone.
|
|
166
|
-
*
|
|
167
|
-
* A file that does not load is fatal, as it is at boot: `rebase dev` runs this
|
|
168
|
-
* on every save, and skipping the file would overwrite good types with a
|
|
169
|
-
* `Database` that is silently short a collection.
|
|
152
|
+
* The tables the backend serves, read the way it reads them: the schema
|
|
153
|
+
* directory's index, through `loadBackendSchema`, compiled to descriptors.
|
|
170
154
|
*
|
|
171
|
-
* A
|
|
172
|
-
* `
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
* `--debug` prints points at the line, so `bin/rebase.js` keeps its hint.
|
|
155
|
+
* A definition the backend would refuse is fatal here too, as it is at boot:
|
|
156
|
+
* `rebase dev` runs this on every save, and skipping a table would overwrite
|
|
157
|
+
* good types with a `Database` that is silently short one. A missing
|
|
158
|
+
* directory is a `Refusal`: the message says all there is. A module that
|
|
159
|
+
* throws on import is not: that is the project's own code failing, and the
|
|
160
|
+
* stack `--debug` prints points at the line.
|
|
178
161
|
*/
|
|
179
|
-
async function
|
|
180
|
-
const absDir = path.resolve(
|
|
181
|
-
if (!fs.existsSync(absDir)) throw new Refusal(`
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const jitiModule = await import("jiti");
|
|
185
|
-
jiti = jitiModule.default || jitiModule;
|
|
186
|
-
} catch {
|
|
187
|
-
throw new Refusal(`Could not load 'jiti'. Install it with: ${[
|
|
188
|
-
...getPMCommands(detectPackageManager()).install,
|
|
189
|
-
"-D",
|
|
190
|
-
"jiti"
|
|
191
|
-
].join(" ")}\njiti is required to dynamically import TypeScript collection definitions.`);
|
|
192
|
-
}
|
|
193
|
-
if (!fs.statSync(absDir).isDirectory()) {
|
|
194
|
-
const mod = jiti(path.dirname(absDir), {
|
|
195
|
-
interopDefault: true,
|
|
196
|
-
esmResolve: true
|
|
197
|
-
})(absDir);
|
|
198
|
-
const listed = mod.backendCollections ?? mod.collections ?? mod.default;
|
|
199
|
-
if (Array.isArray(listed)) return listed;
|
|
200
|
-
throw new Refusal(`Could not extract collections from ${absDir}.\nA single collections module exports \`backendCollections\` or \`collections\`: an array of collections.`);
|
|
201
|
-
}
|
|
202
|
-
const jitiInstance = jiti(absDir, {
|
|
203
|
-
interopDefault: true,
|
|
204
|
-
esmResolve: true
|
|
205
|
-
});
|
|
206
|
-
const collections = [];
|
|
207
|
-
const failures = [];
|
|
208
|
-
const files = fs.readdirSync(absDir).filter(isLoadedCollectionFile).sort();
|
|
209
|
-
for (const file of files) try {
|
|
210
|
-
const mod = jitiInstance(path.join(absDir, file));
|
|
211
|
-
const exported = mod.default ?? mod;
|
|
212
|
-
if (exported && typeof exported === "object" && "slug" in exported) collections.push(exported);
|
|
213
|
-
else failures.push(`${file}: no default export of a collection`);
|
|
214
|
-
} catch (err) {
|
|
215
|
-
failures.push(`${file}: ${err.message}`);
|
|
216
|
-
}
|
|
217
|
-
if (failures.length > 0) throw new Error(`Could not load ${failures.length} collection file(s) from ${absDir}:\n` + failures.map((failure) => ` • ${failure}`).join("\n") + "\n\nEvery collection file must import cleanly and default-export a collection — the backend refuses to boot on the same file.");
|
|
218
|
-
return collections;
|
|
162
|
+
async function loadTables(projectRoot, schemaDir, aliases) {
|
|
163
|
+
const absDir = path.resolve(schemaDir);
|
|
164
|
+
if (!fs.existsSync(absDir)) throw new Refusal(`Schema directory not found: ${absDir} (${PATH_RESOLUTION_RULE})`);
|
|
165
|
+
const { compiled } = await loadProjectSchema(projectRoot, absDir, aliases);
|
|
166
|
+
return compiled.descriptors;
|
|
219
167
|
}
|
|
220
168
|
/**
|
|
221
169
|
* Write generated files to the output directory.
|
|
@@ -238,8 +186,7 @@ ${chalk.bold("Usage")}
|
|
|
238
186
|
rebase generate-sdk [options]
|
|
239
187
|
|
|
240
188
|
${chalk.bold("Options")}
|
|
241
|
-
|
|
242
|
-
(--collections-dir is accepted too)
|
|
189
|
+
--schema-dir <dir> ${SCHEMA_DIR_FLAG_HELP}
|
|
243
190
|
-o, --output <dir> Where to write the SDK (default: ./generated/sdk)
|
|
244
191
|
(--out is accepted too, as on 'rebase build')
|
|
245
192
|
--from <link|url> Fetch the schema from a running project instead of
|
|
@@ -247,12 +194,12 @@ ${chalk.bold("Options")}
|
|
|
247
194
|
--token <token> Bearer token for the contract endpoint
|
|
248
195
|
(default: $REBASE_SERVICE_KEY)
|
|
249
196
|
--register Also type server-side data: write the types and the
|
|
250
|
-
Register declaration to
|
|
197
|
+
Register declaration to backend/generated/, and
|
|
251
198
|
remember it in rebase.json so later runs keep it.
|
|
252
199
|
-h, --help Show this help
|
|
253
200
|
|
|
254
201
|
${chalk.bold("Examples")}
|
|
255
|
-
rebase generate-sdk From
|
|
202
|
+
rebase generate-sdk From backend/schema
|
|
256
203
|
rebase generate-sdk --from link From the linked project
|
|
257
204
|
rebase generate-sdk --from https://api.acme.com From any Rebase backend
|
|
258
205
|
rebase generate-sdk --register Type context.data and rebase.dataAsAdmin too
|
|
@@ -274,7 +221,20 @@ function contractRefusalHint(credential) {
|
|
|
274
221
|
if (credential.envFileKey) return ["REBASE_SERVICE_KEY in .env is not sent: --from sends the shell's REBASE_SERVICE_KEY, and only to this checkout's linked project.", "Pass the key with --token."];
|
|
275
222
|
return ["Pass --token <key>, a service key or an admin's token. The shell's REBASE_SERVICE_KEY is sent only to this checkout's linked project."];
|
|
276
223
|
}
|
|
277
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Whether one entry of a contract's `tables` is a table descriptor, as far as
|
|
226
|
+
* the generator reads one: a slug, a SQL name, columns and relations.
|
|
227
|
+
*/
|
|
228
|
+
function isTableDescriptor(value) {
|
|
229
|
+
return typeof value === "object" && value !== null && "slug" in value && typeof value.slug === "string" && "table" in value && typeof value.table === "string" && "columns" in value && Array.isArray(value.columns) && "relations" in value && Array.isArray(value.relations);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* The tables a running project serves, from its contract endpoint
|
|
233
|
+
* (`{ schemaVersion, runtime, tables: TableDescriptor[] }`). The descriptors
|
|
234
|
+
* are plain data — no thunks to rehydrate — so they go to the generator as
|
|
235
|
+
* they arrive.
|
|
236
|
+
*/
|
|
237
|
+
async function fetchRemoteTables(baseUrl, token, credential) {
|
|
278
238
|
const url = `${baseUrl.replace(/\/+$/, "")}/api/meta/contract`;
|
|
279
239
|
const headers = { accept: "application/json" };
|
|
280
240
|
if (token) headers.authorization = `Bearer ${token}`;
|
|
@@ -302,13 +262,27 @@ async function fetchRemoteCollections(baseUrl, token, credential) {
|
|
|
302
262
|
process.exit(1);
|
|
303
263
|
}
|
|
304
264
|
const contract = await response.json();
|
|
305
|
-
|
|
306
|
-
|
|
265
|
+
const field = (key) => typeof contract === "object" && contract !== null && key in contract ? Object.entries(contract).find(([name]) => name === key)?.[1] : void 0;
|
|
266
|
+
const tables = field("tables");
|
|
267
|
+
const schemaVersion = field("schemaVersion");
|
|
268
|
+
if (!Array.isArray(tables)) {
|
|
269
|
+
if (Array.isArray(field("collections"))) {
|
|
270
|
+
console.log(chalk.red(" ✗ This server answers the contract with collections: it runs a Rebase release from before tables."));
|
|
271
|
+
console.log(chalk.gray(" Upgrade the server to a release that serves `tables`, or generate from this project's"));
|
|
272
|
+
console.log(chalk.gray(" own backend/schema by running `rebase generate-sdk` without --from."));
|
|
273
|
+
process.exit(1);
|
|
274
|
+
}
|
|
275
|
+
console.log(chalk.red(" ✗ The contract response did not contain tables."));
|
|
276
|
+
process.exit(1);
|
|
277
|
+
}
|
|
278
|
+
const invalid = tables.findIndex((entry) => !isTableDescriptor(entry));
|
|
279
|
+
if (invalid !== -1) {
|
|
280
|
+
console.log(chalk.red(` ✗ The contract's tables[${invalid}] is not a table descriptor (no slug, table, columns or relations).`));
|
|
307
281
|
process.exit(1);
|
|
308
282
|
}
|
|
309
283
|
return {
|
|
310
|
-
|
|
311
|
-
schemaVersion:
|
|
284
|
+
tables: tables.filter(isTableDescriptor),
|
|
285
|
+
schemaVersion: typeof schemaVersion === "string" ? schemaVersion : "unknown"
|
|
312
286
|
};
|
|
313
287
|
}
|
|
314
288
|
/**
|
|
@@ -391,17 +365,18 @@ function resolveSchemaSource(from, cwd) {
|
|
|
391
365
|
* Main entry point for the generate-sdk command.
|
|
392
366
|
*/
|
|
393
367
|
async function generateSdkCommand(args) {
|
|
394
|
-
const {
|
|
368
|
+
const { schemaDir, output, cwd } = args;
|
|
395
369
|
if (args.help) {
|
|
396
370
|
printSdkHelp();
|
|
397
371
|
return;
|
|
398
372
|
}
|
|
399
|
-
const
|
|
373
|
+
const resolvedSchemaDir = path.isAbsolute(schemaDir) ? schemaDir : path.join(cwd, schemaDir);
|
|
374
|
+
const projectRoot = args.projectRoot ?? findProjectRoot(cwd) ?? void 0;
|
|
400
375
|
const resolvedOutput = path.isAbsolute(output) ? output : path.join(cwd, output);
|
|
401
376
|
console.log("");
|
|
402
377
|
console.log(chalk.bold(" 🔧 Rebase SDK Generator"));
|
|
403
378
|
console.log("");
|
|
404
|
-
let
|
|
379
|
+
let tables;
|
|
405
380
|
let remoteSchemaVersion;
|
|
406
381
|
if (args.from) {
|
|
407
382
|
const baseUrl = resolveSchemaSource(args.from, cwd);
|
|
@@ -411,37 +386,46 @@ async function generateSdkCommand(args) {
|
|
|
411
386
|
console.log(chalk.cyan(" → Fetching the project contract..."));
|
|
412
387
|
const ambient = mayUseAmbientKey(baseUrl, cwd) ? process.env.REBASE_SERVICE_KEY : void 0;
|
|
413
388
|
if (!args.token && !ambient && process.env.REBASE_SERVICE_KEY) console.log(chalk.dim(" (not sending REBASE_SERVICE_KEY — this host is not the linked project; pass --token to override)"));
|
|
414
|
-
const remote = await
|
|
389
|
+
const remote = await fetchRemoteTables(baseUrl, args.token || ambient, {
|
|
415
390
|
sent: args.token ? "token" : ambient ? "ambient" : null,
|
|
416
391
|
shellKey: Boolean(process.env.REBASE_SERVICE_KEY),
|
|
417
392
|
envFileKey: Boolean(readEnvFile(findProjectRoot(cwd) ?? cwd).REBASE_SERVICE_KEY)
|
|
418
393
|
});
|
|
419
|
-
|
|
394
|
+
tables = remote.tables;
|
|
420
395
|
remoteSchemaVersion = remote.schemaVersion;
|
|
421
396
|
} else {
|
|
422
|
-
if (!fs.existsSync(
|
|
423
|
-
console.log(chalk.gray(" ○ This project derives its API from the database —
|
|
424
|
-
console.log(chalk.gray(` Nothing to generate from: ${
|
|
397
|
+
if (!fs.existsSync(resolvedSchemaDir)) {
|
|
398
|
+
console.log(chalk.gray(" ○ This project derives its API from the database — there is no backend/schema to generate a client from."));
|
|
399
|
+
console.log(chalk.gray(` Nothing to generate from: ${resolvedSchemaDir} does not exist.`));
|
|
425
400
|
console.log("");
|
|
426
401
|
return;
|
|
427
402
|
}
|
|
428
|
-
console.log(` ${chalk.gray("
|
|
403
|
+
console.log(` ${chalk.gray("Schema:")} ${resolvedSchemaDir}`);
|
|
429
404
|
console.log(` ${chalk.gray("Output:")} ${resolvedOutput}`);
|
|
430
405
|
console.log("");
|
|
431
|
-
console.log(chalk.cyan(" → Loading
|
|
432
|
-
|
|
406
|
+
console.log(chalk.cyan(" → Loading the tables..."));
|
|
407
|
+
try {
|
|
408
|
+
tables = await loadTables(projectRoot ?? cwd, resolvedSchemaDir, args.moduleAliases);
|
|
409
|
+
} catch (err) {
|
|
410
|
+
if (isSchemaDefinitionError(err)) {
|
|
411
|
+
console.log("");
|
|
412
|
+
console.log(chalk.red(` ✗ ${err.message}`));
|
|
413
|
+
process.exit(1);
|
|
414
|
+
}
|
|
415
|
+
throw err;
|
|
416
|
+
}
|
|
433
417
|
}
|
|
434
|
-
|
|
435
|
-
if (
|
|
436
|
-
console.log(chalk.red(" ✗ No
|
|
418
|
+
tables = sortedBySlug(tables);
|
|
419
|
+
if (tables.length === 0) {
|
|
420
|
+
console.log(chalk.red(" ✗ No tables found. Nothing to generate."));
|
|
437
421
|
process.exit(1);
|
|
438
422
|
}
|
|
439
|
-
console.log(chalk.green(` ✓ Found ${
|
|
423
|
+
console.log(chalk.green(` ✓ Found ${tables.length} table(s): ${tables.map((table) => table.slug).join(", ")}`));
|
|
440
424
|
console.log("");
|
|
441
425
|
console.log(chalk.cyan(" → Generating SDK files..."));
|
|
442
426
|
let files;
|
|
443
427
|
try {
|
|
444
|
-
files = generateSDK(
|
|
428
|
+
files = generateSDK(tables, { baseUrl: resolveExampleBaseUrl(cwd) });
|
|
445
429
|
} catch (err) {
|
|
446
430
|
if (err instanceof CodegenError) {
|
|
447
431
|
console.log("");
|
|
@@ -450,7 +434,7 @@ async function generateSdkCommand(args) {
|
|
|
450
434
|
}
|
|
451
435
|
throw err;
|
|
452
436
|
}
|
|
453
|
-
const schemaVersion = remoteSchemaVersion ?? computeSchemaVersion(
|
|
437
|
+
const schemaVersion = remoteSchemaVersion ?? computeSchemaVersion(tables);
|
|
454
438
|
files.push({
|
|
455
439
|
path: "schema.meta.ts",
|
|
456
440
|
content: `// Auto-generated by \`rebase generate-sdk\`. Do not edit.
|
|
@@ -470,12 +454,11 @@ export const SCHEMA_VERSION = ${JSON.stringify(schemaVersion)};
|
|
|
470
454
|
console.log(chalk.gray(` schema ${schemaVersion}`));
|
|
471
455
|
console.log(chalk.cyan(` → Writing to ${resolvedOutput}...`));
|
|
472
456
|
writeFiles(resolvedOutput, files);
|
|
473
|
-
const registerDir = registrationDir(
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
console.log(chalk.
|
|
478
|
-
console.log(chalk.gray(" --register writes beside the collections directory; pass --collections."));
|
|
457
|
+
const registerDir = projectRoot ? registrationDir(projectRoot) : void 0;
|
|
458
|
+
if (args.register || registerDir && hasRegistration(registerDir) || manifestRegisters(projectRoot)) {
|
|
459
|
+
if (!registerDir || !fs.existsSync(path.dirname(registerDir))) {
|
|
460
|
+
console.log(chalk.red(` ✗ No backend/ directory to register the Database in${registerDir ? ` (${path.dirname(registerDir)})` : ""}.`));
|
|
461
|
+
console.log(chalk.gray(" --register writes backend/generated/register.ts; run it inside a project with a backend."));
|
|
479
462
|
process.exit(1);
|
|
480
463
|
return;
|
|
481
464
|
}
|
|
@@ -501,20 +484,20 @@ export const SCHEMA_VERSION = ${JSON.stringify(schemaVersion)};
|
|
|
501
484
|
console.log("");
|
|
502
485
|
const typesImport = `./${path.relative(cwd, path.join(resolvedOutput, "database.types"))}`;
|
|
503
486
|
const metaImport = `./${path.relative(cwd, path.join(resolvedOutput, "schema.meta"))}`;
|
|
504
|
-
const exampleSlug =
|
|
487
|
+
const exampleSlug = tables[0]?.slug || "my_table";
|
|
505
488
|
console.log(chalk.gray(" Usage:"));
|
|
506
489
|
console.log(chalk.gray(" import { createRebaseClient } from '@rebasepro/client';"));
|
|
507
|
-
console.log(chalk.gray(` import {
|
|
490
|
+
console.log(chalk.gray(` import { tablesDictionary, type Database } from '${typesImport}';`));
|
|
508
491
|
console.log(chalk.gray(` import { SCHEMA_VERSION } from '${metaImport}';`));
|
|
509
492
|
console.log("");
|
|
510
493
|
console.log(chalk.gray(" const rebase = createRebaseClient<Database>({"));
|
|
511
494
|
console.log(chalk.gray(` baseUrl: '${resolveExampleBaseUrl(cwd)}',`));
|
|
512
495
|
console.log(chalk.gray(" schemaVersion: SCHEMA_VERSION,"));
|
|
513
|
-
console.log(chalk.gray("
|
|
496
|
+
console.log(chalk.gray(" tables: tablesDictionary,"));
|
|
514
497
|
console.log(chalk.gray(" // token: 'your-jwt-token',"));
|
|
515
498
|
console.log(chalk.gray(" });"));
|
|
516
499
|
console.log("");
|
|
517
|
-
const exampleAccessor =
|
|
500
|
+
const exampleAccessor = toTableAccessor(exampleSlug);
|
|
518
501
|
const exampleAccess = isIdentifierLike(exampleAccessor) ? `rebase.data.${exampleAccessor}` : `rebase.data[${JSON.stringify(exampleAccessor)}]`;
|
|
519
502
|
console.log(chalk.gray(` const { data } = await ${exampleAccess}.find();`));
|
|
520
503
|
console.log("");
|
|
@@ -522,4 +505,4 @@ export const SCHEMA_VERSION = ${JSON.stringify(schemaVersion)};
|
|
|
522
505
|
//#endregion
|
|
523
506
|
export { generateSdkCommand, writeRegistrationForBuild };
|
|
524
507
|
|
|
525
|
-
//# sourceMappingURL=generate_sdk-
|
|
508
|
+
//# sourceMappingURL=generate_sdk-De-aLC1L.js.map
|