@rebasepro/cli 0.33.2 → 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.
Files changed (149) hide show
  1. package/dist/{agent-setup-Cg_zBWoW.js → agent-setup-kjdKozkF.js} +3 -3
  2. package/dist/{agent-setup-Cg_zBWoW.js.map → agent-setup-kjdKozkF.js.map} +1 -1
  3. package/dist/{api-TbmW33D7.js → api-CQh_qTyQ.js} +2 -2
  4. package/dist/{api-TbmW33D7.js.map → api-CQh_qTyQ.js.map} +1 -1
  5. package/dist/{api-keys-fPQ55DCm.js → api-keys-CG2IpknI.js} +5 -5
  6. package/dist/{api-keys-fPQ55DCm.js.map → api-keys-CG2IpknI.js.map} +1 -1
  7. package/dist/{apps-DBTRoOeP.js → apps-DaaWvv3o.js} +6 -6
  8. package/dist/{apps-DBTRoOeP.js.map → apps-DaaWvv3o.js.map} +1 -1
  9. package/dist/{atlas-dev-database-D6h65f2x.js → atlas-dev-database-BiDMUr9W.js} +2 -2
  10. package/dist/{atlas-dev-database-D6h65f2x.js.map → atlas-dev-database-BiDMUr9W.js.map} +1 -1
  11. package/dist/{auth-BpyYLEFY.js → auth-bi8x2YX1.js} +12 -12
  12. package/dist/{auth-BpyYLEFY.js.map → auth-bi8x2YX1.js.map} +1 -1
  13. package/dist/{auth-session-B6aT0Dyj.js → auth-session-BVoxE5tp.js} +4 -4
  14. package/dist/{auth-session-B6aT0Dyj.js.map → auth-session-BVoxE5tp.js.map} +1 -1
  15. package/dist/{backend-guard-Cf8eMK_f.js → backend-guard--SW3MTSh.js} +2 -2
  16. package/dist/{backend-guard-Cf8eMK_f.js.map → backend-guard--SW3MTSh.js.map} +1 -1
  17. package/dist/{branch-pointer-BJOF2Ubv.js → branch-pointer-BjKUoENm.js} +1 -1
  18. package/dist/{build-E5hfEWKj.js → build-D-0VCmbU.js} +11 -11
  19. package/dist/build-D-0VCmbU.js.map +1 -0
  20. package/dist/{bundle-CIiKGrte.js → bundle-BDTVS9XE.js} +7 -7
  21. package/dist/{bundle-CIiKGrte.js.map → bundle-BDTVS9XE.js.map} +1 -1
  22. package/dist/{cloud-DNJyUU0T.js → cloud-CR6Hps3B.js} +222 -31
  23. package/dist/cloud-CR6Hps3B.js.map +1 -0
  24. package/dist/{cms-directories-BaV-Is9a.js → cms-directories-AGHvFwH7.js} +2 -2
  25. package/dist/{cms-directories-BaV-Is9a.js.map → cms-directories-AGHvFwH7.js.map} +1 -1
  26. package/dist/{command-Bks5xkrQ.js → command-nWgittn1.js} +3 -3
  27. package/dist/{command-Bks5xkrQ.js.map → command-nWgittn1.js.map} +1 -1
  28. package/dist/commands/build.d.ts +2 -1
  29. package/dist/commands/cloud/db-connect.d.ts +31 -1
  30. package/dist/commands/cloud/db-query.d.ts +16 -0
  31. package/dist/commands/cloud/index.d.ts +1 -0
  32. package/dist/commands/cloud/resources.d.ts +19 -1
  33. package/dist/commands/dev.d.ts +15 -0
  34. package/dist/commands/users.d.ts +1 -0
  35. package/dist/{consent-UV6ObCME.js → consent-C8_Ik_GK.js} +3 -3
  36. package/dist/{consent-UV6ObCME.js.map → consent-C8_Ik_GK.js.map} +1 -1
  37. package/dist/{console-BVoYOLAO.js → console-BBGRHOFg.js} +5 -5
  38. package/dist/{console-BVoYOLAO.js.map → console-BBGRHOFg.js.map} +1 -1
  39. package/dist/{context-BOMEoKxn.js → context-C9lz1vTS.js} +6 -2
  40. package/dist/{context-BOMEoKxn.js.map → context-C9lz1vTS.js.map} +1 -1
  41. package/dist/{cron-ZRXsla0v.js → cron-BzzNxkBH.js} +3 -3
  42. package/dist/{cron-ZRXsla0v.js.map → cron-BzzNxkBH.js.map} +1 -1
  43. package/dist/{cron-CpUsQ739.js → cron-DuZ3Svjq.js} +4 -4
  44. package/dist/{cron-CpUsQ739.js.map → cron-DuZ3Svjq.js.map} +1 -1
  45. package/dist/{daemon-D5gdG7gx.js → daemon-BCBMn8hE.js} +2 -2
  46. package/dist/{daemon-D5gdG7gx.js.map → daemon-BCBMn8hE.js.map} +1 -1
  47. package/dist/{data-BJ9AZFUC.js → data-1eipHbxJ.js} +3 -3
  48. package/dist/{data-BJ9AZFUC.js.map → data-1eipHbxJ.js.map} +1 -1
  49. package/dist/{db-D_iF4E-v.js → db-DAotpOxs.js} +28 -28
  50. package/dist/{db-D_iF4E-v.js.map → db-DAotpOxs.js.map} +1 -1
  51. package/dist/{debug-nNbbxAeo.js → debug-CkiOcfsU.js} +2 -2
  52. package/dist/{debug-nNbbxAeo.js.map → debug-CkiOcfsU.js.map} +1 -1
  53. package/dist/{derive-Mky_u59_.js → derive-BU5kvcOP.js} +3 -3
  54. package/dist/{derive-Mky_u59_.js.map → derive-BU5kvcOP.js.map} +1 -1
  55. package/dist/{dev-bj6dEeSQ.js → dev-Ce9PVQS8.js} +34 -13
  56. package/dist/dev-Ce9PVQS8.js.map +1 -0
  57. package/dist/{dev-preflight-BMOf2N6r.js → dev-preflight-DROlafgr.js} +2 -2
  58. package/dist/{dev-preflight-BMOf2N6r.js.map → dev-preflight-DROlafgr.js.map} +1 -1
  59. package/dist/{dev-server-2XHSHM_q.js → dev-server-dsabI0UT.js} +2 -2
  60. package/dist/{dev-server-2XHSHM_q.js.map → dev-server-dsabI0UT.js.map} +1 -1
  61. package/dist/{doctor-FaBObSlb.js → doctor-Cdu3Llrw.js} +8 -8
  62. package/dist/{doctor-FaBObSlb.js.map → doctor-Cdu3Llrw.js.map} +1 -1
  63. package/dist/{eject-DK_M9kor.js → eject-Dy-qRYhW.js} +3 -3
  64. package/dist/{eject-DK_M9kor.js.map → eject-Dy-qRYhW.js.map} +1 -1
  65. package/dist/{fold-static-2t3UUX4z.js → fold-static-DzV3EJZm.js} +4 -4
  66. package/dist/{fold-static-2t3UUX4z.js.map → fold-static-DzV3EJZm.js.map} +1 -1
  67. package/dist/{function-portability-BIvlvR9q.js → function-portability-Dppl6uqg.js} +24 -5
  68. package/dist/{function-portability-BIvlvR9q.js.map → function-portability-Dppl6uqg.js.map} +1 -1
  69. package/dist/function-portability.d.ts +9 -0
  70. package/dist/{functions-B4JR6EZL.js → functions-BCEJnISw.js} +4 -4
  71. package/dist/{functions-B4JR6EZL.js.map → functions-BCEJnISw.js.map} +1 -1
  72. package/dist/{generate-view-BMaLQm8H.js → generate-view-CZ0SmsJc.js} +4 -4
  73. package/dist/{generate-view-BMaLQm8H.js.map → generate-view-CZ0SmsJc.js.map} +1 -1
  74. package/dist/{generate_sdk-ByD-gTsK.js → generate_sdk-MAbUUZoK.js} +6 -6
  75. package/dist/{generate_sdk-ByD-gTsK.js.map → generate_sdk-MAbUUZoK.js.map} +1 -1
  76. package/dist/index.es.js +54 -54
  77. package/dist/{init-DHCe5mJ5.js → init-BctfWO3w.js} +44 -24
  78. package/dist/init-BctfWO3w.js.map +1 -0
  79. package/dist/last-dev-database-w-r9T5Xm.js +2 -0
  80. package/dist/{legacy-layout-DI2VeQSV.js → legacy-layout-CiXWalS6.js} +2 -2
  81. package/dist/{legacy-layout-DI2VeQSV.js.map → legacy-layout-CiXWalS6.js.map} +1 -1
  82. package/dist/{logs-DpuMukJe.js → logs-B_mS4gCn.js} +4 -4
  83. package/dist/{logs-DpuMukJe.js.map → logs-B_mS4gCn.js.map} +1 -1
  84. package/dist/{manifest-RjqxfCpb.js → manifest-D6B4LA8x.js} +3 -3
  85. package/dist/{manifest-RjqxfCpb.js.map → manifest-D6B4LA8x.js.map} +1 -1
  86. package/dist/{migrate-CSY9ZDKy.js → migrate-DdcgLMyL.js} +3 -3
  87. package/dist/{migrate-CSY9ZDKy.js.map → migrate-DdcgLMyL.js.map} +1 -1
  88. package/dist/{normalize-imports-P86NVfpo.js → normalize-imports-CVjOssZ2.js} +2 -2
  89. package/dist/{normalize-imports-P86NVfpo.js.map → normalize-imports-CVjOssZ2.js.map} +1 -1
  90. package/dist/{package-manager-DSEOwTqM.js → package-manager-DTNNGHyK.js} +29 -12
  91. package/dist/package-manager-DTNNGHyK.js.map +1 -0
  92. package/dist/{path-flags-ekLdkbra.js → path-flags-B7Ydt5nv.js} +2 -2
  93. package/dist/{path-flags-ekLdkbra.js.map → path-flags-B7Ydt5nv.js.map} +1 -1
  94. package/dist/{prepare-BaJe0Zik.js → prepare-CFpYl1Nt.js} +4 -4
  95. package/dist/{prepare-BaJe0Zik.js.map → prepare-CFpYl1Nt.js.map} +1 -1
  96. package/dist/{project-DALmhb5R.js → project-CQ5nKddJ.js} +2 -2
  97. package/dist/{project-DALmhb5R.js.map → project-CQ5nKddJ.js.map} +1 -1
  98. package/dist/{project-command-Cl9EZzjr.js → project-command-5wM_bJQt.js} +7 -7
  99. package/dist/{project-command-Cl9EZzjr.js.map → project-command-5wM_bJQt.js.map} +1 -1
  100. package/dist/resolve-GDRel2ne.js +2 -0
  101. package/dist/{resources-Db3USuPO.js → resources-ecA0MEjy.js} +4 -4
  102. package/dist/{resources-Db3USuPO.js.map → resources-ecA0MEjy.js.map} +1 -1
  103. package/dist/{rls-BxrQ0P50.js → rls-B4zGbTKY.js} +3 -3
  104. package/dist/{rls-BxrQ0P50.js.map → rls-B4zGbTKY.js.map} +1 -1
  105. package/dist/{schema-_FzZEoB8.js → schema-CWzzn0cY.js} +13 -12
  106. package/dist/{schema-_FzZEoB8.js.map → schema-CWzzn0cY.js.map} +1 -1
  107. package/dist/{schema-dir-ChcYfWjP.js → schema-dir-Dd1Pzqq5.js} +2 -2
  108. package/dist/{schema-dir-ChcYfWjP.js.map → schema-dir-Dd1Pzqq5.js.map} +1 -1
  109. package/dist/schema-reconcile-DGEMmYJI.js +2 -0
  110. package/dist/{schema-show-h72UJ9zH.js → schema-show-DwYtOp4S.js} +5 -5
  111. package/dist/{schema-show-h72UJ9zH.js.map → schema-show-DwYtOp4S.js.map} +1 -1
  112. package/dist/{skills-DQ2bZGkj.js → skills-CWmBTCRW.js} +6 -6
  113. package/dist/{skills-DQ2bZGkj.js.map → skills-CWmBTCRW.js.map} +1 -1
  114. package/dist/{start-Cjx4W0bJ.js → start-4uhCu_md.js} +6 -6
  115. package/dist/{start-Cjx4W0bJ.js.map → start-4uhCu_md.js.map} +1 -1
  116. package/dist/{status-CDBk25VO.js → status-CVEzoSwX.js} +7 -7
  117. package/dist/{status-CDBk25VO.js.map → status-CVEzoSwX.js.map} +1 -1
  118. package/dist/{storage-Clc8dLG8.js → storage-Dqf5tyhs.js} +9 -9
  119. package/dist/{storage-Clc8dLG8.js.map → storage-Dqf5tyhs.js.map} +1 -1
  120. package/dist/{storage-objects-CfRKlTDe.js → storage-objects-DbFsemMV.js} +3 -3
  121. package/dist/{storage-objects-CfRKlTDe.js.map → storage-objects-DbFsemMV.js.map} +1 -1
  122. package/dist/{telemetry-DZU2-NCm.js → telemetry-B5RSeQIc.js} +3 -3
  123. package/dist/{telemetry-DZU2-NCm.js.map → telemetry-B5RSeQIc.js.map} +1 -1
  124. package/dist/{telemetry-EVtASbKb.js → telemetry-CJbrRuG3.js} +2 -2
  125. package/dist/{telemetry-EVtASbKb.js.map → telemetry-CJbrRuG3.js.map} +1 -1
  126. package/dist/{upgrade-ZASvgxWM.js → upgrade-CepjhRrz.js} +6 -6
  127. package/dist/{upgrade-ZASvgxWM.js.map → upgrade-CepjhRrz.js.map} +1 -1
  128. package/dist/{users-5PkqBY6R.js → users-Cx5HuaTn.js} +9 -6
  129. package/dist/users-Cx5HuaTn.js.map +1 -0
  130. package/dist/utils/package-manager.d.ts +12 -13
  131. package/dist/{verify-BdeqNb-V.js → verify-D-1y5HQS.js} +8 -8
  132. package/dist/{verify-BdeqNb-V.js.map → verify-D-1y5HQS.js.map} +1 -1
  133. package/package.json +10 -10
  134. package/templates/template/.cursorrules +2 -1
  135. package/templates/template/.github/copilot-instructions.md +2 -1
  136. package/templates/template/.windsurfrules +2 -1
  137. package/templates/template/AGENTS.md +2 -1
  138. package/templates/template/CLAUDE.md +2 -1
  139. package/templates/template/ai-instructions.md +5 -2
  140. package/templates/template/frontend/src/index.css +13 -0
  141. package/dist/build-E5hfEWKj.js.map +0 -1
  142. package/dist/cloud-DNJyUU0T.js.map +0 -1
  143. package/dist/dev-bj6dEeSQ.js.map +0 -1
  144. package/dist/init-DHCe5mJ5.js.map +0 -1
  145. package/dist/last-dev-database-CBVkEUEl.js +0 -2
  146. package/dist/package-manager-DSEOwTqM.js.map +0 -1
  147. package/dist/resolve-C36px9tR.js +0 -2
  148. package/dist/schema-reconcile-DV14XY4o.js +0 -2
  149. package/dist/users-5PkqBY6R.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"generate_sdk-ByD-gTsK.js","names":[],"sources":["../src/commands/generate_sdk.ts"],"sourcesContent":["/**\n * CLI command: generate-sdk\n *\n * Reads the project's tables — `backend/schema`, through the loader the\n * backend boots from, so the SDK describes exactly the tables served — or,\n * with `--from`, a running project's contract, and writes a typed TypeScript\n * SDK to the output directory (default: ./generated/sdk).\n */\n\nimport fs from \"fs\";\nimport path from \"path\";\nimport chalk from \"chalk\";\nimport { computeSchemaVersion, type TableDescriptor } from \"@rebasepro/types\";\nimport { CodegenError, generateSDK, GeneratedFile, toTableAccessor } from \"@rebasepro/codegen\";\nimport { isSchemaDefinitionError } from \"@rebasepro/common\";\nimport { findProjectRoot, readEnvFile } from \"../utils/project\";\nimport { DEV_BACKEND_URL_ENV } from \"../utils/dev-server\";\nimport { Refusal } from \"../utils/refusal\";\nimport { findBackendApp, GENERATED_DIR, loadManifest, manifestExists, writeManifest } from \"../manifest\";\nimport { readLink } from \"./cloud/context\";\nimport { SCHEMA_DIR_FLAG_HELP, PATH_RESOLUTION_RULE } from \"../utils/path-flags\";\nimport { loadProjectSchema, type ModuleAliases } from \"../utils/project-schema\";\n\ninterface GenerateSDKArgs {\n /** The schema directory: the one whose index exports the tables. */\n schemaDir: string;\n output: string;\n cwd: string;\n /**\n * Where to read the schema from instead of local source.\n *\n * `link` uses this checkout's linked project; anything else is treated as\n * the base URL of a Rebase backend. This is what lets a repository that\n * contains no tables — a separate frontend, a second web app — generate\n * a typed client from the project it talks to.\n */\n from?: string;\n /** Bearer token for the contract endpoint. Falls back to REBASE_SERVICE_KEY. */\n token?: string;\n /**\n * Also register the generated `Database` for server-side code: write the\n * types and the `Register` augmentation into `backend/generated/`. See\n * {@link writeRegistration}.\n */\n register?: boolean;\n /**\n * The directory holding `rebase.json`, where `--register` is remembered\n * and under which `backend/generated/` is. Found from `cwd` when not given.\n */\n projectRoot?: string;\n /** Module specifiers mapped to files when importing the schema (in-repo runs and tests). */\n moduleAliases?: ModuleAliases;\n help?: boolean;\n}\n\n/** What `--register` writes, and what marks a project as having opted in. */\nexport const REGISTER_FILE = \"register.ts\";\n\n/** The first line of {@link REGISTER_FILE}: a file without it is the developer's own. */\nconst REGISTER_MARKER = \"// Auto-generated by `rebase generate-sdk --register`. Do not edit.\";\n\nconst REGISTER_SOURCE = `${REGISTER_MARKER}\n//\n// Registers this project's generated \\`Database\\` on \\`@rebasepro/types\\`, so\n// \\`context.data\\` in table hooks, \\`rebase.dataAsAdmin\\`, and the\n// \\`rebase\\` a function or a cron receives are typed from it. Every later\n// \\`rebase generate-sdk\\` (and \\`rebase dev\\`) refreshes this directory; delete\n// it to go back to untyped server-side data.\nimport type { Database } from \"./database.types\";\n\ndeclare module \"@rebasepro/types\" {\n interface Register {\n database: Database;\n }\n}\n`;\n\n/**\n * Where `--register` writes: `backend/generated/` under the project root.\n *\n * Inside `backend/` because that is the program the hooks, functions and\n * crons it types are compiled in. The types are copied in beside the\n * registration rather than imported from `generated/sdk`, which is outside\n * the backend's `rootDir`.\n */\nexport function registrationDir(projectRoot: string): string {\n return path.join(projectRoot, GENERATED_DIR);\n}\n\n/** Whether this project opted in: the registration is there, and it is ours. */\nfunction hasRegistration(dir: string): boolean {\n try {\n return fs.readFileSync(path.join(dir, REGISTER_FILE), \"utf-8\").startsWith(REGISTER_MARKER);\n } catch {\n return false;\n }\n}\n\n/** Write a file only when its content changed, so a watcher on the directory does not restart for nothing. */\nfunction writeIfChanged(filePath: string, content: string): void {\n try {\n if (fs.readFileSync(filePath, \"utf-8\") === content) return;\n } catch {\n // Not there yet.\n }\n fs.writeFileSync(filePath, content, \"utf-8\");\n}\n\n/**\n * Write the generated `Database` and its `Register` augmentation into\n * {@link registrationDir}. Refuses to overwrite a `register.ts` it did not\n * write.\n */\nfunction writeRegistration(dir: string, databaseTypes: string): void {\n const registerPath = path.join(dir, REGISTER_FILE);\n if (fs.existsSync(registerPath) && !hasRegistration(dir)) {\n throw new Error(\n `${registerPath} exists and was not written by \"rebase generate-sdk --register\". ` +\n \"Move it, or register the Database there yourself.\"\n );\n }\n fs.mkdirSync(dir, { recursive: true });\n writeIfChanged(path.join(dir, \"database.types.ts\"), databaseTypes);\n writeIfChanged(registerPath, REGISTER_SOURCE);\n}\n\n/**\n * Write the server-side registration from the build's tables, exactly as\n * `rebase generate-sdk` writes it.\n *\n * Only for a project that asked for it: `registerDatabase` in `rebase.json`,\n * or a registration an earlier `--register` left, which is kept current. The\n * registration lives in gitignored `backend/generated/`, so a fresh clone (a\n * CI job) has none until something writes it, and a bundle compiled without\n * it types `context.data` as untyped rows: hooks that read a typed column fail\n * to compile there while they compile locally.\n *\n * Returns the directory written, or null when there was nothing to do.\n * Throws when a `register.ts` there is not ours, as `generate-sdk` refuses.\n */\nexport async function writeRegistrationForBuild(\n projectRoot: string,\n tables: readonly TableDescriptor[],\n registerDatabase: boolean\n): Promise<string | null> {\n const dir = registrationDir(projectRoot);\n if (!registerDatabase && !hasRegistration(dir)) return null;\n if (tables.length === 0) return null;\n const databaseTypes = generateSDK(sortedBySlug(tables), { includeReadme: false })\n .find((file) => file.path === \"database.types.ts\")?.content;\n if (databaseTypes === undefined) return null;\n writeRegistration(dir, databaseTypes);\n return dir;\n}\n\n/** Tables sorted by slug: the same schema generates the same bytes, whatever order the index lists it in. */\nfunction sortedBySlug(tables: readonly TableDescriptor[]): TableDescriptor[] {\n return [...tables].sort((a, b) => a.slug.localeCompare(b.slug));\n}\n\n/**\n * Whether `rebase.json` asks for the registration (`registerDatabase: true` on\n * the backend app). That is what survives a clone: `generated/` is gitignored,\n * so a `register.ts` from an earlier run is not there to say it.\n *\n * An unreadable manifest answers no; `rebase build` is where it is reported.\n */\nfunction manifestRegisters(projectRoot: string | undefined): boolean {\n if (!projectRoot || !manifestExists(projectRoot)) return false;\n try {\n return findBackendApp(loadManifest(projectRoot).manifest)?.app.registerDatabase === true;\n } catch {\n return false;\n }\n}\n\n/**\n * Remember `--register` in `rebase.json`, so later runs, `rebase dev` and a\n * fresh clone keep registering. Returns where it was written, or why not.\n *\n * Never creates the file: a project without one is synthesized from its\n * layout, and writing one is `rebase apps init`'s decision, not this flag's.\n */\nfunction rememberRegistration(projectRoot: string | undefined): { written: string } | { skipped: string } {\n if (!projectRoot || !manifestExists(projectRoot)) {\n return { skipped: \"No rebase.json here, so the choice lasts as long as the generated files.\" };\n }\n let loaded: ReturnType<typeof loadManifest>;\n try {\n loaded = loadManifest(projectRoot);\n } catch (error) {\n return { skipped: `rebase.json could not be read (${error instanceof Error ? error.message : String(error)}).` };\n }\n const backend = findBackendApp(loaded.manifest);\n if (!backend) return { skipped: \"rebase.json declares no backend app to remember it on.\" };\n if (backend.app.registerDatabase === true) return { written: loaded.filePath ?? projectRoot };\n const manifest = {\n ...loaded.manifest,\n apps: { ...loaded.manifest.apps, [backend.name]: { ...backend.app, registerDatabase: true } }\n };\n return { written: writeManifest(projectRoot, manifest) };\n}\n\n/**\n * The tables the backend serves, read the way it reads them: the schema\n * directory's index, through `loadBackendSchema`, compiled to descriptors.\n *\n * A definition the backend would refuse is fatal here too, as it is at boot:\n * `rebase dev` runs this on every save, and skipping a table would overwrite\n * good types with a `Database` that is silently short one. A missing\n * directory is a `Refusal`: the message says all there is. A module that\n * throws on import is not: that is the project's own code failing, and the\n * stack `--debug` prints points at the line.\n */\nasync function loadTables(projectRoot: string, schemaDir: string, aliases?: ModuleAliases): Promise<TableDescriptor[]> {\n const absDir = path.resolve(schemaDir);\n if (!fs.existsSync(absDir)) {\n throw new Refusal(`Schema directory not found: ${absDir} (${PATH_RESOLUTION_RULE})`);\n }\n const { compiled } = await loadProjectSchema(projectRoot, absDir, aliases);\n return compiled.descriptors;\n}\n\n/**\n * Write generated files to the output directory.\n */\nfunction writeFiles(outputDir: string, files: GeneratedFile[]): void {\n const absOutput = path.resolve(outputDir);\n\n // Create output directory\n fs.mkdirSync(absOutput, { recursive: true });\n\n for (const file of files) {\n const filePath = path.join(absOutput, file.path);\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n fs.writeFileSync(filePath, file.content, \"utf-8\");\n }\n}\n\nfunction printSdkHelp(): void {\n console.log(`\n${chalk.bold(\"rebase generate-sdk\")} — generate a typed client from a project's schema\n\n${chalk.bold(\"Usage\")}\n rebase generate-sdk [options]\n\n${chalk.bold(\"Options\")}\n --schema-dir <dir> ${SCHEMA_DIR_FLAG_HELP}\n -o, --output <dir> Where to write the SDK (default: ./generated/sdk)\n (--out is accepted too, as on 'rebase build')\n --from <link|url> Fetch the schema from a running project instead of\n local source. \"link\" uses this checkout's linked project.\n --token <token> Bearer token for the contract endpoint\n (default: $REBASE_SERVICE_KEY)\n --register Also type server-side data: write the types and the\n Register declaration to backend/generated/, and\n remember it in rebase.json so later runs keep it.\n -h, --help Show this help\n\n${chalk.bold(\"Examples\")}\n rebase generate-sdk From backend/schema\n rebase generate-sdk --from link From the linked project\n rebase generate-sdk --from https://api.acme.com From any Rebase backend\n rebase generate-sdk --register Type context.data and rebase.dataAsAdmin too\n`.trim());\n}\n\n/** What `--from` sent to the contract endpoint, and which keys it left behind. */\ninterface ContractCredential {\n /** The bearer token sent: `--token`, the shell's key, or none. */\n sent: \"token\" | \"ambient\" | null;\n /** `REBASE_SERVICE_KEY` is in the shell environment. */\n shellKey: boolean;\n /** `REBASE_SERVICE_KEY` is in the project's `.env`. */\n envFileKey: boolean;\n}\n\n/**\n * What to say when the contract endpoint refuses, by what was and was not sent.\n *\n * \"Set REBASE_SERVICE_KEY\" is only right when no key exists. The shell's key is\n * withheld from every host but the linked project, and `.env`'s is never read\n * here — it is the local backend's key, and the linked project is usually a\n * deployed one — so telling a reader whose key is in `.env` to set it sends them\n * to fix something that is not broken.\n */\nfunction contractRefusalHint(credential: ContractCredential): string[] {\n if (credential.sent === \"token\") {\n return [\"The token passed with --token was refused: pass a service key, or an admin's token.\"];\n }\n if (credential.sent === \"ambient\") {\n return [\"REBASE_SERVICE_KEY was sent and refused: it is not this project's service key. Pass the right one with --token.\"];\n }\n if (credential.shellKey) {\n return [\n \"REBASE_SERVICE_KEY is set, but it is only sent to this checkout's linked project, and this host is not it.\",\n \"Pass the key with --token to send it here.\"\n ];\n }\n if (credential.envFileKey) {\n return [\n \"REBASE_SERVICE_KEY in .env is not sent: --from sends the shell's REBASE_SERVICE_KEY, and only to this checkout's linked project.\",\n \"Pass the key with --token.\"\n ];\n }\n 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.\"];\n}\n\n/**\n * Whether one entry of a contract's `tables` is a table descriptor, as far as\n * the generator reads one: a slug, a SQL name, columns and relations.\n */\nfunction isTableDescriptor(value: unknown): value is TableDescriptor {\n return typeof value === \"object\" && value !== null\n && \"slug\" in value && typeof value.slug === \"string\"\n && \"table\" in value && typeof value.table === \"string\"\n && \"columns\" in value && Array.isArray(value.columns)\n && \"relations\" in value && Array.isArray(value.relations);\n}\n\n/**\n * The tables a running project serves, from its contract endpoint\n * (`{ schemaVersion, runtime, tables: TableDescriptor[] }`). The descriptors\n * are plain data — no thunks to rehydrate — so they go to the generator as\n * they arrive.\n */\nasync function fetchRemoteTables(\n baseUrl: string,\n token: string | undefined,\n credential: ContractCredential\n): Promise<{ tables: TableDescriptor[]; schemaVersion: string }> {\n const url = `${baseUrl.replace(/\\/+$/, \"\")}/api/meta/contract`;\n\n const headers: Record<string, string> = { accept: \"application/json\" };\n if (token) headers.authorization = `Bearer ${token}`;\n\n let response: Response;\n try {\n response = await fetch(url, { headers });\n } catch (err) {\n console.log(chalk.red(` ✗ Could not reach ${url}`));\n console.log(chalk.gray(` ${err instanceof Error ? err.message : String(err)}`));\n process.exit(1);\n }\n\n if (response.status === 401 || response.status === 403) {\n console.log(chalk.red(` ✗ Not authorized to read the project contract (${response.status}).`));\n console.log(chalk.gray(\" The contract describes every table and relation, so it is admin-only.\"));\n for (const line of contractRefusalHint(credential)) console.log(chalk.gray(` ${line}`));\n process.exit(1);\n }\n\n if (response.status === 404) {\n console.log(chalk.red(\" ✗ This server has no contract endpoint.\"));\n console.log(chalk.gray(\" It needs to be running Rebase 0.11 or newer.\"));\n process.exit(1);\n }\n\n if (!response.ok) {\n console.log(chalk.red(` ✗ Contract request failed with ${response.status}.`));\n process.exit(1);\n }\n\n const contract: unknown = await response.json();\n const field = (key: string): unknown =>\n typeof contract === \"object\" && contract !== null && key in contract\n ? Object.entries(contract).find(([name]) => name === key)?.[1]\n : undefined;\n const tables = field(\"tables\");\n const schemaVersion = field(\"schemaVersion\");\n\n if (!Array.isArray(tables)) {\n if (Array.isArray(field(\"collections\"))) {\n // A server from before tables: its contract lists collections, a\n // shape this CLI no longer generates from.\n console.log(chalk.red(\" ✗ This server answers the contract with collections: it runs a Rebase release from before tables.\"));\n console.log(chalk.gray(\" Upgrade the server to a release that serves `tables`, or generate from this project's\"));\n console.log(chalk.gray(\" own backend/schema by running `rebase generate-sdk` without --from.\"));\n process.exit(1);\n }\n console.log(chalk.red(\" ✗ The contract response did not contain tables.\"));\n process.exit(1);\n }\n const invalid = tables.findIndex(entry => !isTableDescriptor(entry));\n if (invalid !== -1) {\n console.log(chalk.red(` ✗ The contract's tables[${invalid}] is not a table descriptor (no slug, table, columns or relations).`));\n process.exit(1);\n }\n\n return {\n tables: tables.filter(isTableDescriptor),\n schemaVersion: typeof schemaVersion === \"string\" ? schemaVersion : \"unknown\"\n };\n}\n\n/**\n * Decide whether the ambient service key may be sent to this host.\n *\n * `REBASE_SERVICE_KEY` grants full admin bypass. Attaching it to whatever URL\n * happened to be passed — or, worse, to whatever a committed `.rebase/cloud.json`\n * points at — would hand the project's most powerful credential to a host nobody\n * vetted. An explicit `--token` is a decision the caller made; the ambient\n * variable is not, so it only travels to the project this checkout is linked to.\n */\nfunction mayUseAmbientKey(target: string, cwd: string): boolean {\n const link = readLink(findProjectRoot(cwd) ?? cwd);\n if (!link?.apiUrl) return false;\n try {\n // Origin, not host: with a link recorded as https, an `http://` target\n // for the same host would otherwise pass and send the key in cleartext.\n return new URL(link.apiUrl).origin === new URL(target).origin;\n } catch {\n return false;\n }\n}\n\n/**\n * The base URL to show in the printed usage example.\n *\n * `rebase dev` binds a port derived from the project path, not 3001, and writes\n * the one it actually got to `.rebase/state.json`. Printing a hardcoded\n * `localhost:3001` sent people to a port nothing was listening on — or, with\n * several projects on one machine, to a different project's backend. Prefer the\n * port `rebase dev` says it is starting the backend on (`DEV_BACKEND_URL_ENV`:\n * it regenerates the SDK before the backend binds), then the port this project\n * last ran on; fall back to the literal only when the project has never been\n * started.\n */\nexport function resolveExampleBaseUrl(cwd: string): string {\n const fromDev = process.env[DEV_BACKEND_URL_ENV]?.trim();\n if (fromDev) return fromDev;\n const projectRoot = findProjectRoot(cwd) ?? cwd;\n try {\n const state = JSON.parse(fs.readFileSync(path.join(projectRoot, \".rebase\", \"state.json\"), \"utf-8\"));\n if (typeof state.baseUrl === \"string\" && state.baseUrl) return state.baseUrl;\n if (typeof state.port === \"number\") return `http://localhost:${state.port}`;\n } catch {\n // Never started, or the file is unreadable — fall through.\n }\n return \"http://localhost:3001\";\n}\n\n/** Whether a slug can be written as `rebase.data.<slug>` rather than a lookup. */\nexport function isIdentifierLike(slug: string): boolean {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(slug);\n}\n\n/** Resolve `--from` into a base URL, following the link file when asked. */\nfunction resolveSchemaSource(from: string, cwd: string): string {\n if (from !== \"link\") {\n // A bare hostname or a typo would otherwise be handed to `fetch` and fail\n // with something unhelpful; a non-http scheme has no business here at all.\n let parsed: URL;\n try {\n parsed = new URL(from);\n } catch {\n console.log(chalk.red(` ✗ \"${from}\" is not a valid URL.`));\n console.log(chalk.gray(\" Pass a full URL, e.g. https://api.example.com, or \\\"link\\\".\"));\n process.exit(1);\n }\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n console.log(chalk.red(\" ✗ The project URL must be http or https.\"));\n process.exit(1);\n }\n return from;\n }\n\n const projectRoot = findProjectRoot(cwd) ?? cwd;\n const link = readLink(projectRoot);\n\n if (!link) {\n console.log(chalk.red(\" ✗ This checkout is not linked to a project.\"));\n console.log(chalk.gray(\" Run `rebase cloud link <url>`, or pass --from <url>.\"));\n process.exit(1);\n }\n\n const apiUrl = link.apiUrl;\n if (!apiUrl) {\n console.log(chalk.red(\" ✗ The project link has no API URL.\"));\n console.log(chalk.gray(\" Re-link with `rebase cloud link <url>` to record one.\"));\n process.exit(1);\n }\n\n return apiUrl;\n}\n\n/**\n * Main entry point for the generate-sdk command.\n */\nexport async function generateSdkCommand(args: GenerateSDKArgs): Promise<void> {\n const { schemaDir, output, cwd } = args;\n\n if (args.help) {\n printSdkHelp();\n return;\n }\n\n const resolvedSchemaDir = path.isAbsolute(schemaDir)\n ? schemaDir\n : path.join(cwd, schemaDir);\n const projectRoot = args.projectRoot ?? findProjectRoot(cwd) ?? undefined;\n\n const resolvedOutput = path.isAbsolute(output)\n ? output\n : path.join(cwd, output);\n\n console.log(\"\");\n console.log(chalk.bold(\" 🔧 Rebase SDK Generator\"));\n console.log(\"\");\n\n let tables: TableDescriptor[];\n let remoteSchemaVersion: string | undefined;\n\n if (args.from) {\n const baseUrl = resolveSchemaSource(args.from, cwd);\n console.log(` ${chalk.gray(\"Project:\")} ${baseUrl}`);\n console.log(` ${chalk.gray(\"Output:\")} ${resolvedOutput}`);\n console.log(\"\");\n console.log(chalk.cyan(\" → Fetching the project contract...\"));\n\n const ambient = mayUseAmbientKey(baseUrl, cwd)\n ? process.env.REBASE_SERVICE_KEY\n : undefined;\n\n if (!args.token && !ambient && process.env.REBASE_SERVICE_KEY) {\n console.log(chalk.dim(\n \" (not sending REBASE_SERVICE_KEY — this host is not the linked project; pass --token to override)\"\n ));\n }\n\n const remote = await fetchRemoteTables(baseUrl, args.token || ambient, {\n sent: args.token ? \"token\" : ambient ? \"ambient\" : null,\n shellKey: Boolean(process.env.REBASE_SERVICE_KEY),\n envFileKey: Boolean(readEnvFile(findProjectRoot(cwd) ?? cwd).REBASE_SERVICE_KEY)\n });\n tables = remote.tables;\n remoteSchemaVersion = remote.schemaVersion;\n } else {\n // A headless project has no schema directory by design: its API is\n // introspected from the live database at boot, and there is nothing here\n // to generate a client from. The scaffold ships `pnpm generate:sdk`\n // anyway, so the documented headless path had a script that could only\n // ever fail — and it failed with a path, which reads as a broken install\n // rather than a question with an answer.\n if (!fs.existsSync(resolvedSchemaDir)) {\n console.log(chalk.gray(\n \" ○ This project derives its API from the database — \"\n + \"there is no backend/schema to generate a client from.\"\n ));\n console.log(chalk.gray(\n ` Nothing to generate from: ${resolvedSchemaDir} does not exist.`\n ));\n console.log(\"\");\n return;\n }\n console.log(` ${chalk.gray(\"Schema:\")} ${resolvedSchemaDir}`);\n console.log(` ${chalk.gray(\"Output:\")} ${resolvedOutput}`);\n console.log(\"\");\n console.log(chalk.cyan(\" → Loading the tables...\"));\n try {\n tables = await loadTables(projectRoot ?? cwd, resolvedSchemaDir, args.moduleAliases);\n } catch (err) {\n // A definition the backend would refuse to boot on: every problem,\n // one per line, each naming its table.\n if (isSchemaDefinitionError(err)) {\n console.log(\"\");\n console.log(chalk.red(` ✗ ${err.message}`));\n process.exit(1);\n }\n throw err;\n }\n }\n\n // Sorted by slug, so the same schema generates the same SDK.\n tables = sortedBySlug(tables);\n\n if (tables.length === 0) {\n console.log(chalk.red(\" ✗ No tables found. Nothing to generate.\"));\n process.exit(1);\n }\n\n console.log(chalk.green(` ✓ Found ${tables.length} table(s): ${tables.map(table => table.slug).join(\", \")}`));\n console.log(\"\");\n\n // 2. Generate SDK files\n console.log(chalk.cyan(\" → Generating SDK files...\"));\n let files: GeneratedFile[];\n try {\n files = generateSDK(tables, { baseUrl: resolveExampleBaseUrl(cwd) });\n } catch (err) {\n // A schema that cannot be expressed as valid TypeScript — two slugs\n // that collide on one accessor, a slug with no usable name. The\n // generator refuses rather than emitting a file that does not compile,\n // or one that silently routes a table's reads to another's.\n if (err instanceof CodegenError) {\n console.log(\"\");\n console.log(chalk.red(` ✗ ${err.message}`));\n process.exit(1);\n }\n throw err;\n }\n\n // Stamp the schema this SDK was built from.\n //\n // Without it, an app in a separate repository has no way to know its client\n // is stale: the backend moves on, the frontend keeps compiling against types\n // captured weeks ago, and the mismatch only surfaces as a runtime error. With\n // it, CI can compare against `/api/meta/schema-version` and say so.\n //\n // No generation timestamp. Tables are sorted above precisely so that\n // the same schema produces the same bytes; a timestamp put that back,\n // turning every regeneration into a diff and making the obvious staleness\n // gate — `rebase generate-sdk && git diff --exit-code` — impossible to pass.\n // `SCHEMA_VERSION` already identifies what this was built from, and does it\n // in a way that can be compared against a running project.\n const schemaVersion = remoteSchemaVersion ?? computeSchemaVersion(tables);\n files.push({\n path: \"schema.meta.ts\",\n content: `// Auto-generated by \\`rebase generate-sdk\\`. Do not edit.\n//\n// The schema version this SDK was generated from. Compare it against the\n// project's current version to detect drift:\n//\n// curl -s <api-url>/api/meta/schema-version\n//\n// Pass it to the client as \\`schemaVersion\\` and every request carries it in\n// the \\`x-rebase-schema\\` header, so the server can name the drift instead of\n// answering a renamed field with a bare 400.\nexport const SCHEMA_VERSION = ${JSON.stringify(schemaVersion)};\n`\n });\n\n console.log(chalk.green(` ✓ Generated ${files.length} file(s)`));\n console.log(chalk.gray(` schema ${schemaVersion}`));\n\n // 3. Write to disk\n console.log(chalk.cyan(` → Writing to ${resolvedOutput}...`));\n writeFiles(resolvedOutput, files);\n\n // 4. The server-side registration: on request, and kept current once a\n // project has it, so `rebase dev` regenerating the SDK never leaves the\n // server typed against an older schema than the client.\n const registerDir = projectRoot ? registrationDir(projectRoot) : undefined;\n if (args.register || (registerDir && hasRegistration(registerDir)) || manifestRegisters(projectRoot)) {\n if (!registerDir || !fs.existsSync(path.dirname(registerDir))) {\n console.log(chalk.red(` ✗ No backend/ directory to register the Database in${registerDir ? ` (${path.dirname(registerDir)})` : \"\"}.`));\n console.log(chalk.gray(\" --register writes backend/generated/register.ts; run it inside a project with a backend.\"));\n process.exit(1);\n return;\n }\n const databaseTypes = files.find((file) => file.path === \"database.types.ts\")?.content;\n if (databaseTypes !== undefined) {\n try {\n writeRegistration(registerDir, databaseTypes);\n } catch (error) {\n console.log(chalk.red(` ✗ ${error instanceof Error ? error.message : String(error)}`));\n process.exit(1);\n return;\n }\n console.log(chalk.green(` ✓ Registered the Database for server-side code in ${registerDir}`));\n if (args.register) {\n const remembered = rememberRegistration(projectRoot);\n if (\"written\" in remembered) {\n console.log(chalk.gray(` Remembered in ${path.relative(cwd, remembered.written) || \"rebase.json\"} (registerDatabase).`));\n } else {\n console.log(chalk.yellow(` ${remembered.skipped}`));\n }\n }\n }\n }\n\n console.log(\"\");\n console.log(chalk.green.bold(\" ✓ SDK generated successfully!\"));\n console.log(\"\");\n const typesImport = `./${path.relative(cwd, path.join(resolvedOutput, \"database.types\"))}`;\n const metaImport = `./${path.relative(cwd, path.join(resolvedOutput, \"schema.meta\"))}`;\n const exampleSlug = tables[0]?.slug || \"my_table\";\n\n console.log(chalk.gray(\" Usage:\"));\n console.log(chalk.gray(\" import { createRebaseClient } from '@rebasepro/client';\"));\n console.log(chalk.gray(` import { tablesDictionary, type Database } from '${typesImport}';`));\n console.log(chalk.gray(` import { SCHEMA_VERSION } from '${metaImport}';`));\n console.log(\"\");\n console.log(chalk.gray(\" const rebase = createRebaseClient<Database>({\"));\n console.log(chalk.gray(` baseUrl: '${resolveExampleBaseUrl(cwd)}',`));\n // Sent as `x-rebase-schema` on every request. Costs one line here and is\n // the difference between a server that can say \"this client is three\n // deploys behind\" and one that can only reject a field it does not know.\n console.log(chalk.gray(\" schemaVersion: SCHEMA_VERSION,\"));\n // Without the dictionary a hyphenated slug is not resolvable from the\n // property name alone, and the request 404s at runtime.\n console.log(chalk.gray(\" tables: tablesDictionary,\"));\n console.log(chalk.gray(\" // token: 'your-jwt-token',\"));\n console.log(chalk.gray(\" });\"));\n console.log(\"\");\n // `rebase.data.<accessor>` is the typed surface, so it is what gets printed.\n // `rebase.data.table(slug)` exists too, but it is generic over\n // `Record<string, unknown>` and has no link to `Database` — it was the\n // headline example here for a while, which advertised the one call shape\n // that throws away the types this command just generated.\n const exampleAccessor = toTableAccessor(exampleSlug);\n const exampleAccess = isIdentifierLike(exampleAccessor)\n ? `rebase.data.${exampleAccessor}`\n : `rebase.data[${JSON.stringify(exampleAccessor)}]`;\n console.log(chalk.gray(` const { data } = await ${exampleAccess}.find();`));\n console.log(\"\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwDA,IAAa,gBAAgB;;AAG7B,IAAM,kBAAkB;AAExB,IAAM,kBAAkB,GAAG,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;AAwB3C,SAAgB,gBAAgB,aAA6B;CACzD,OAAO,KAAK,KAAK,aAAa,aAAa;AAC/C;;AAGA,SAAS,gBAAgB,KAAsB;CAC3C,IAAI;EACA,OAAO,GAAG,aAAa,KAAK,KAAK,KAAK,aAAa,GAAG,OAAO,CAAC,CAAC,WAAW,eAAe;CAC7F,QAAQ;EACJ,OAAO;CACX;AACJ;;AAGA,SAAS,eAAe,UAAkB,SAAuB;CAC7D,IAAI;EACA,IAAI,GAAG,aAAa,UAAU,OAAO,MAAM,SAAS;CACxD,QAAQ,CAER;CACA,GAAG,cAAc,UAAU,SAAS,OAAO;AAC/C;;;;;;AAOA,SAAS,kBAAkB,KAAa,eAA6B;CACjE,MAAM,eAAe,KAAK,KAAK,KAAK,aAAa;CACjD,IAAI,GAAG,WAAW,YAAY,KAAK,CAAC,gBAAgB,GAAG,GACnD,MAAM,IAAI,MACN,GAAG,aAAa,mHAEpB;CAEJ,GAAG,UAAU,KAA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I command: generate-sdk\n *\n * Reads the project's tables — `backend/schema`, through the loader the\n * backend boots from, so the SDK describes exactly the tables served — or,\n * with `--from`, a running project's contract, and writes a typed TypeScript\n * SDK to the output directory (default: ./generated/sdk).\n */\n\nimport fs from \"fs\";\nimport path from \"path\";\nimport chalk from \"chalk\";\nimport { computeSchemaVersion, type TableDescriptor } from \"@rebasepro/types\";\nimport { CodegenError, generateSDK, GeneratedFile, toTableAccessor } from \"@rebasepro/codegen\";\nimport { isSchemaDefinitionError } from \"@rebasepro/common\";\nimport { findProjectRoot, readEnvFile } from \"../utils/project\";\nimport { DEV_BACKEND_URL_ENV } from \"../utils/dev-server\";\nimport { Refusal } from \"../utils/refusal\";\nimport { findBackendApp, GENERATED_DIR, loadManifest, manifestExists, writeManifest } from \"../manifest\";\nimport { readLink } from \"./cloud/context\";\nimport { SCHEMA_DIR_FLAG_HELP, PATH_RESOLUTION_RULE } from \"../utils/path-flags\";\nimport { loadProjectSchema, type ModuleAliases } from \"../utils/project-schema\";\n\ninterface GenerateSDKArgs {\n /** The schema directory: the one whose index exports the tables. */\n schemaDir: string;\n output: string;\n cwd: string;\n /**\n * Where to read the schema from instead of local source.\n *\n * `link` uses this checkout's linked project; anything else is treated as\n * the base URL of a Rebase backend. This is what lets a repository that\n * contains no tables — a separate frontend, a second web app — generate\n * a typed client from the project it talks to.\n */\n from?: string;\n /** Bearer token for the contract endpoint. Falls back to REBASE_SERVICE_KEY. */\n token?: string;\n /**\n * Also register the generated `Database` for server-side code: write the\n * types and the `Register` augmentation into `backend/generated/`. See\n * {@link writeRegistration}.\n */\n register?: boolean;\n /**\n * The directory holding `rebase.json`, where `--register` is remembered\n * and under which `backend/generated/` is. Found from `cwd` when not given.\n */\n projectRoot?: string;\n /** Module specifiers mapped to files when importing the schema (in-repo runs and tests). */\n moduleAliases?: ModuleAliases;\n help?: boolean;\n}\n\n/** What `--register` writes, and what marks a project as having opted in. */\nexport const REGISTER_FILE = \"register.ts\";\n\n/** The first line of {@link REGISTER_FILE}: a file without it is the developer's own. */\nconst REGISTER_MARKER = \"// Auto-generated by `rebase generate-sdk --register`. Do not edit.\";\n\nconst REGISTER_SOURCE = `${REGISTER_MARKER}\n//\n// Registers this project's generated \\`Database\\` on \\`@rebasepro/types\\`, so\n// \\`context.data\\` in table hooks, \\`rebase.dataAsAdmin\\`, and the\n// \\`rebase\\` a function or a cron receives are typed from it. Every later\n// \\`rebase generate-sdk\\` (and \\`rebase dev\\`) refreshes this directory; delete\n// it to go back to untyped server-side data.\nimport type { Database } from \"./database.types\";\n\ndeclare module \"@rebasepro/types\" {\n interface Register {\n database: Database;\n }\n}\n`;\n\n/**\n * Where `--register` writes: `backend/generated/` under the project root.\n *\n * Inside `backend/` because that is the program the hooks, functions and\n * crons it types are compiled in. The types are copied in beside the\n * registration rather than imported from `generated/sdk`, which is outside\n * the backend's `rootDir`.\n */\nexport function registrationDir(projectRoot: string): string {\n return path.join(projectRoot, GENERATED_DIR);\n}\n\n/** Whether this project opted in: the registration is there, and it is ours. */\nfunction hasRegistration(dir: string): boolean {\n try {\n return fs.readFileSync(path.join(dir, REGISTER_FILE), \"utf-8\").startsWith(REGISTER_MARKER);\n } catch {\n return false;\n }\n}\n\n/** Write a file only when its content changed, so a watcher on the directory does not restart for nothing. */\nfunction writeIfChanged(filePath: string, content: string): void {\n try {\n if (fs.readFileSync(filePath, \"utf-8\") === content) return;\n } catch {\n // Not there yet.\n }\n fs.writeFileSync(filePath, content, \"utf-8\");\n}\n\n/**\n * Write the generated `Database` and its `Register` augmentation into\n * {@link registrationDir}. Refuses to overwrite a `register.ts` it did not\n * write.\n */\nfunction writeRegistration(dir: string, databaseTypes: string): void {\n const registerPath = path.join(dir, REGISTER_FILE);\n if (fs.existsSync(registerPath) && !hasRegistration(dir)) {\n throw new Error(\n `${registerPath} exists and was not written by \"rebase generate-sdk --register\". ` +\n \"Move it, or register the Database there yourself.\"\n );\n }\n fs.mkdirSync(dir, { recursive: true });\n writeIfChanged(path.join(dir, \"database.types.ts\"), databaseTypes);\n writeIfChanged(registerPath, REGISTER_SOURCE);\n}\n\n/**\n * Write the server-side registration from the build's tables, exactly as\n * `rebase generate-sdk` writes it.\n *\n * Only for a project that asked for it: `registerDatabase` in `rebase.json`,\n * or a registration an earlier `--register` left, which is kept current. The\n * registration lives in gitignored `backend/generated/`, so a fresh clone (a\n * CI job) has none until something writes it, and a bundle compiled without\n * it types `context.data` as untyped rows: hooks that read a typed column fail\n * to compile there while they compile locally.\n *\n * Returns the directory written, or null when there was nothing to do.\n * Throws when a `register.ts` there is not ours, as `generate-sdk` refuses.\n */\nexport async function writeRegistrationForBuild(\n projectRoot: string,\n tables: readonly TableDescriptor[],\n registerDatabase: boolean\n): Promise<string | null> {\n const dir = registrationDir(projectRoot);\n if (!registerDatabase && !hasRegistration(dir)) return null;\n if (tables.length === 0) return null;\n const databaseTypes = generateSDK(sortedBySlug(tables), { includeReadme: false })\n .find((file) => file.path === \"database.types.ts\")?.content;\n if (databaseTypes === undefined) return null;\n writeRegistration(dir, databaseTypes);\n return dir;\n}\n\n/** Tables sorted by slug: the same schema generates the same bytes, whatever order the index lists it in. */\nfunction sortedBySlug(tables: readonly TableDescriptor[]): TableDescriptor[] {\n return [...tables].sort((a, b) => a.slug.localeCompare(b.slug));\n}\n\n/**\n * Whether `rebase.json` asks for the registration (`registerDatabase: true` on\n * the backend app). That is what survives a clone: `generated/` is gitignored,\n * so a `register.ts` from an earlier run is not there to say it.\n *\n * An unreadable manifest answers no; `rebase build` is where it is reported.\n */\nfunction manifestRegisters(projectRoot: string | undefined): boolean {\n if (!projectRoot || !manifestExists(projectRoot)) return false;\n try {\n return findBackendApp(loadManifest(projectRoot).manifest)?.app.registerDatabase === true;\n } catch {\n return false;\n }\n}\n\n/**\n * Remember `--register` in `rebase.json`, so later runs, `rebase dev` and a\n * fresh clone keep registering. Returns where it was written, or why not.\n *\n * Never creates the file: a project without one is synthesized from its\n * layout, and writing one is `rebase apps init`'s decision, not this flag's.\n */\nfunction rememberRegistration(projectRoot: string | undefined): { written: string } | { skipped: string } {\n if (!projectRoot || !manifestExists(projectRoot)) {\n return { skipped: \"No rebase.json here, so the choice lasts as long as the generated files.\" };\n }\n let loaded: ReturnType<typeof loadManifest>;\n try {\n loaded = loadManifest(projectRoot);\n } catch (error) {\n return { skipped: `rebase.json could not be read (${error instanceof Error ? error.message : String(error)}).` };\n }\n const backend = findBackendApp(loaded.manifest);\n if (!backend) return { skipped: \"rebase.json declares no backend app to remember it on.\" };\n if (backend.app.registerDatabase === true) return { written: loaded.filePath ?? projectRoot };\n const manifest = {\n ...loaded.manifest,\n apps: { ...loaded.manifest.apps, [backend.name]: { ...backend.app, registerDatabase: true } }\n };\n return { written: writeManifest(projectRoot, manifest) };\n}\n\n/**\n * The tables the backend serves, read the way it reads them: the schema\n * directory's index, through `loadBackendSchema`, compiled to descriptors.\n *\n * A definition the backend would refuse is fatal here too, as it is at boot:\n * `rebase dev` runs this on every save, and skipping a table would overwrite\n * good types with a `Database` that is silently short one. A missing\n * directory is a `Refusal`: the message says all there is. A module that\n * throws on import is not: that is the project's own code failing, and the\n * stack `--debug` prints points at the line.\n */\nasync function loadTables(projectRoot: string, schemaDir: string, aliases?: ModuleAliases): Promise<TableDescriptor[]> {\n const absDir = path.resolve(schemaDir);\n if (!fs.existsSync(absDir)) {\n throw new Refusal(`Schema directory not found: ${absDir} (${PATH_RESOLUTION_RULE})`);\n }\n const { compiled } = await loadProjectSchema(projectRoot, absDir, aliases);\n return compiled.descriptors;\n}\n\n/**\n * Write generated files to the output directory.\n */\nfunction writeFiles(outputDir: string, files: GeneratedFile[]): void {\n const absOutput = path.resolve(outputDir);\n\n // Create output directory\n fs.mkdirSync(absOutput, { recursive: true });\n\n for (const file of files) {\n const filePath = path.join(absOutput, file.path);\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n fs.writeFileSync(filePath, file.content, \"utf-8\");\n }\n}\n\nfunction printSdkHelp(): void {\n console.log(`\n${chalk.bold(\"rebase generate-sdk\")} — generate a typed client from a project's schema\n\n${chalk.bold(\"Usage\")}\n rebase generate-sdk [options]\n\n${chalk.bold(\"Options\")}\n --schema-dir <dir> ${SCHEMA_DIR_FLAG_HELP}\n -o, --output <dir> Where to write the SDK (default: ./generated/sdk)\n (--out is accepted too, as on 'rebase build')\n --from <link|url> Fetch the schema from a running project instead of\n local source. \"link\" uses this checkout's linked project.\n --token <token> Bearer token for the contract endpoint\n (default: $REBASE_SERVICE_KEY)\n --register Also type server-side data: write the types and the\n Register declaration to backend/generated/, and\n remember it in rebase.json so later runs keep it.\n -h, --help Show this help\n\n${chalk.bold(\"Examples\")}\n rebase generate-sdk From backend/schema\n rebase generate-sdk --from link From the linked project\n rebase generate-sdk --from https://api.acme.com From any Rebase backend\n rebase generate-sdk --register Type context.data and rebase.dataAsAdmin too\n`.trim());\n}\n\n/** What `--from` sent to the contract endpoint, and which keys it left behind. */\ninterface ContractCredential {\n /** The bearer token sent: `--token`, the shell's key, or none. */\n sent: \"token\" | \"ambient\" | null;\n /** `REBASE_SERVICE_KEY` is in the shell environment. */\n shellKey: boolean;\n /** `REBASE_SERVICE_KEY` is in the project's `.env`. */\n envFileKey: boolean;\n}\n\n/**\n * What to say when the contract endpoint refuses, by what was and was not sent.\n *\n * \"Set REBASE_SERVICE_KEY\" is only right when no key exists. The shell's key is\n * withheld from every host but the linked project, and `.env`'s is never read\n * here — it is the local backend's key, and the linked project is usually a\n * deployed one — so telling a reader whose key is in `.env` to set it sends them\n * to fix something that is not broken.\n */\nfunction contractRefusalHint(credential: ContractCredential): string[] {\n if (credential.sent === \"token\") {\n return [\"The token passed with --token was refused: pass a service key, or an admin's token.\"];\n }\n if (credential.sent === \"ambient\") {\n return [\"REBASE_SERVICE_KEY was sent and refused: it is not this project's service key. Pass the right one with --token.\"];\n }\n if (credential.shellKey) {\n return [\n \"REBASE_SERVICE_KEY is set, but it is only sent to this checkout's linked project, and this host is not it.\",\n \"Pass the key with --token to send it here.\"\n ];\n }\n if (credential.envFileKey) {\n return [\n \"REBASE_SERVICE_KEY in .env is not sent: --from sends the shell's REBASE_SERVICE_KEY, and only to this checkout's linked project.\",\n \"Pass the key with --token.\"\n ];\n }\n 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.\"];\n}\n\n/**\n * Whether one entry of a contract's `tables` is a table descriptor, as far as\n * the generator reads one: a slug, a SQL name, columns and relations.\n */\nfunction isTableDescriptor(value: unknown): value is TableDescriptor {\n return typeof value === \"object\" && value !== null\n && \"slug\" in value && typeof value.slug === \"string\"\n && \"table\" in value && typeof value.table === \"string\"\n && \"columns\" in value && Array.isArray(value.columns)\n && \"relations\" in value && Array.isArray(value.relations);\n}\n\n/**\n * The tables a running project serves, from its contract endpoint\n * (`{ schemaVersion, runtime, tables: TableDescriptor[] }`). The descriptors\n * are plain data — no thunks to rehydrate — so they go to the generator as\n * they arrive.\n */\nasync function fetchRemoteTables(\n baseUrl: string,\n token: string | undefined,\n credential: ContractCredential\n): Promise<{ tables: TableDescriptor[]; schemaVersion: string }> {\n const url = `${baseUrl.replace(/\\/+$/, \"\")}/api/meta/contract`;\n\n const headers: Record<string, string> = { accept: \"application/json\" };\n if (token) headers.authorization = `Bearer ${token}`;\n\n let response: Response;\n try {\n response = await fetch(url, { headers });\n } catch (err) {\n console.log(chalk.red(` ✗ Could not reach ${url}`));\n console.log(chalk.gray(` ${err instanceof Error ? err.message : String(err)}`));\n process.exit(1);\n }\n\n if (response.status === 401 || response.status === 403) {\n console.log(chalk.red(` ✗ Not authorized to read the project contract (${response.status}).`));\n console.log(chalk.gray(\" The contract describes every table and relation, so it is admin-only.\"));\n for (const line of contractRefusalHint(credential)) console.log(chalk.gray(` ${line}`));\n process.exit(1);\n }\n\n if (response.status === 404) {\n console.log(chalk.red(\" ✗ This server has no contract endpoint.\"));\n console.log(chalk.gray(\" It needs to be running Rebase 0.11 or newer.\"));\n process.exit(1);\n }\n\n if (!response.ok) {\n console.log(chalk.red(` ✗ Contract request failed with ${response.status}.`));\n process.exit(1);\n }\n\n const contract: unknown = await response.json();\n const field = (key: string): unknown =>\n typeof contract === \"object\" && contract !== null && key in contract\n ? Object.entries(contract).find(([name]) => name === key)?.[1]\n : undefined;\n const tables = field(\"tables\");\n const schemaVersion = field(\"schemaVersion\");\n\n if (!Array.isArray(tables)) {\n if (Array.isArray(field(\"collections\"))) {\n // A server from before tables: its contract lists collections, a\n // shape this CLI no longer generates from.\n console.log(chalk.red(\" ✗ This server answers the contract with collections: it runs a Rebase release from before tables.\"));\n console.log(chalk.gray(\" Upgrade the server to a release that serves `tables`, or generate from this project's\"));\n console.log(chalk.gray(\" own backend/schema by running `rebase generate-sdk` without --from.\"));\n process.exit(1);\n }\n console.log(chalk.red(\" ✗ The contract response did not contain tables.\"));\n process.exit(1);\n }\n const invalid = tables.findIndex(entry => !isTableDescriptor(entry));\n if (invalid !== -1) {\n console.log(chalk.red(` ✗ The contract's tables[${invalid}] is not a table descriptor (no slug, table, columns or relations).`));\n process.exit(1);\n }\n\n return {\n tables: tables.filter(isTableDescriptor),\n schemaVersion: typeof schemaVersion === \"string\" ? schemaVersion : \"unknown\"\n };\n}\n\n/**\n * Decide whether the ambient service key may be sent to this host.\n *\n * `REBASE_SERVICE_KEY` grants full admin bypass. Attaching it to whatever URL\n * happened to be passed — or, worse, to whatever a committed `.rebase/cloud.json`\n * points at — would hand the project's most powerful credential to a host nobody\n * vetted. An explicit `--token` is a decision the caller made; the ambient\n * variable is not, so it only travels to the project this checkout is linked to.\n */\nfunction mayUseAmbientKey(target: string, cwd: string): boolean {\n const link = readLink(findProjectRoot(cwd) ?? cwd);\n if (!link?.apiUrl) return false;\n try {\n // Origin, not host: with a link recorded as https, an `http://` target\n // for the same host would otherwise pass and send the key in cleartext.\n return new URL(link.apiUrl).origin === new URL(target).origin;\n } catch {\n return false;\n }\n}\n\n/**\n * The base URL to show in the printed usage example.\n *\n * `rebase dev` binds a port derived from the project path, not 3001, and writes\n * the one it actually got to `.rebase/state.json`. Printing a hardcoded\n * `localhost:3001` sent people to a port nothing was listening on — or, with\n * several projects on one machine, to a different project's backend. Prefer the\n * port `rebase dev` says it is starting the backend on (`DEV_BACKEND_URL_ENV`:\n * it regenerates the SDK before the backend binds), then the port this project\n * last ran on; fall back to the literal only when the project has never been\n * started.\n */\nexport function resolveExampleBaseUrl(cwd: string): string {\n const fromDev = process.env[DEV_BACKEND_URL_ENV]?.trim();\n if (fromDev) return fromDev;\n const projectRoot = findProjectRoot(cwd) ?? cwd;\n try {\n const state = JSON.parse(fs.readFileSync(path.join(projectRoot, \".rebase\", \"state.json\"), \"utf-8\"));\n if (typeof state.baseUrl === \"string\" && state.baseUrl) return state.baseUrl;\n if (typeof state.port === \"number\") return `http://localhost:${state.port}`;\n } catch {\n // Never started, or the file is unreadable — fall through.\n }\n return \"http://localhost:3001\";\n}\n\n/** Whether a slug can be written as `rebase.data.<slug>` rather than a lookup. */\nexport function isIdentifierLike(slug: string): boolean {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(slug);\n}\n\n/** Resolve `--from` into a base URL, following the link file when asked. */\nfunction resolveSchemaSource(from: string, cwd: string): string {\n if (from !== \"link\") {\n // A bare hostname or a typo would otherwise be handed to `fetch` and fail\n // with something unhelpful; a non-http scheme has no business here at all.\n let parsed: URL;\n try {\n parsed = new URL(from);\n } catch {\n console.log(chalk.red(` ✗ \"${from}\" is not a valid URL.`));\n console.log(chalk.gray(\" Pass a full URL, e.g. https://api.example.com, or \\\"link\\\".\"));\n process.exit(1);\n }\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n console.log(chalk.red(\" ✗ The project URL must be http or https.\"));\n process.exit(1);\n }\n return from;\n }\n\n const projectRoot = findProjectRoot(cwd) ?? cwd;\n const link = readLink(projectRoot);\n\n if (!link) {\n console.log(chalk.red(\" ✗ This checkout is not linked to a project.\"));\n console.log(chalk.gray(\" Run `rebase cloud link <url>`, or pass --from <url>.\"));\n process.exit(1);\n }\n\n const apiUrl = link.apiUrl;\n if (!apiUrl) {\n console.log(chalk.red(\" ✗ The project link has no API URL.\"));\n console.log(chalk.gray(\" Re-link with `rebase cloud link <url>` to record one.\"));\n process.exit(1);\n }\n\n return apiUrl;\n}\n\n/**\n * Main entry point for the generate-sdk command.\n */\nexport async function generateSdkCommand(args: GenerateSDKArgs): Promise<void> {\n const { schemaDir, output, cwd } = args;\n\n if (args.help) {\n printSdkHelp();\n return;\n }\n\n const resolvedSchemaDir = path.isAbsolute(schemaDir)\n ? schemaDir\n : path.join(cwd, schemaDir);\n const projectRoot = args.projectRoot ?? findProjectRoot(cwd) ?? undefined;\n\n const resolvedOutput = path.isAbsolute(output)\n ? output\n : path.join(cwd, output);\n\n console.log(\"\");\n console.log(chalk.bold(\" 🔧 Rebase SDK Generator\"));\n console.log(\"\");\n\n let tables: TableDescriptor[];\n let remoteSchemaVersion: string | undefined;\n\n if (args.from) {\n const baseUrl = resolveSchemaSource(args.from, cwd);\n console.log(` ${chalk.gray(\"Project:\")} ${baseUrl}`);\n console.log(` ${chalk.gray(\"Output:\")} ${resolvedOutput}`);\n console.log(\"\");\n console.log(chalk.cyan(\" → Fetching the project contract...\"));\n\n const ambient = mayUseAmbientKey(baseUrl, cwd)\n ? process.env.REBASE_SERVICE_KEY\n : undefined;\n\n if (!args.token && !ambient && process.env.REBASE_SERVICE_KEY) {\n console.log(chalk.dim(\n \" (not sending REBASE_SERVICE_KEY — this host is not the linked project; pass --token to override)\"\n ));\n }\n\n const remote = await fetchRemoteTables(baseUrl, args.token || ambient, {\n sent: args.token ? \"token\" : ambient ? \"ambient\" : null,\n shellKey: Boolean(process.env.REBASE_SERVICE_KEY),\n envFileKey: Boolean(readEnvFile(findProjectRoot(cwd) ?? cwd).REBASE_SERVICE_KEY)\n });\n tables = remote.tables;\n remoteSchemaVersion = remote.schemaVersion;\n } else {\n // A headless project has no schema directory by design: its API is\n // introspected from the live database at boot, and there is nothing here\n // to generate a client from. The scaffold ships `pnpm generate:sdk`\n // anyway, so the documented headless path had a script that could only\n // ever fail — and it failed with a path, which reads as a broken install\n // rather than a question with an answer.\n if (!fs.existsSync(resolvedSchemaDir)) {\n console.log(chalk.gray(\n \" ○ This project derives its API from the database — \"\n + \"there is no backend/schema to generate a client from.\"\n ));\n console.log(chalk.gray(\n ` Nothing to generate from: ${resolvedSchemaDir} does not exist.`\n ));\n console.log(\"\");\n return;\n }\n console.log(` ${chalk.gray(\"Schema:\")} ${resolvedSchemaDir}`);\n console.log(` ${chalk.gray(\"Output:\")} ${resolvedOutput}`);\n console.log(\"\");\n console.log(chalk.cyan(\" → Loading the tables...\"));\n try {\n tables = await loadTables(projectRoot ?? cwd, resolvedSchemaDir, args.moduleAliases);\n } catch (err) {\n // A definition the backend would refuse to boot on: every problem,\n // one per line, each naming its table.\n if (isSchemaDefinitionError(err)) {\n console.log(\"\");\n console.log(chalk.red(` ✗ ${err.message}`));\n process.exit(1);\n }\n throw err;\n }\n }\n\n // Sorted by slug, so the same schema generates the same SDK.\n tables = sortedBySlug(tables);\n\n if (tables.length === 0) {\n console.log(chalk.red(\" ✗ No tables found. Nothing to generate.\"));\n process.exit(1);\n }\n\n console.log(chalk.green(` ✓ Found ${tables.length} table(s): ${tables.map(table => table.slug).join(\", \")}`));\n console.log(\"\");\n\n // 2. Generate SDK files\n console.log(chalk.cyan(\" → Generating SDK files...\"));\n let files: GeneratedFile[];\n try {\n files = generateSDK(tables, { baseUrl: resolveExampleBaseUrl(cwd) });\n } catch (err) {\n // A schema that cannot be expressed as valid TypeScript — two slugs\n // that collide on one accessor, a slug with no usable name. The\n // generator refuses rather than emitting a file that does not compile,\n // or one that silently routes a table's reads to another's.\n if (err instanceof CodegenError) {\n console.log(\"\");\n console.log(chalk.red(` ✗ ${err.message}`));\n process.exit(1);\n }\n throw err;\n }\n\n // Stamp the schema this SDK was built from.\n //\n // Without it, an app in a separate repository has no way to know its client\n // is stale: the backend moves on, the frontend keeps compiling against types\n // captured weeks ago, and the mismatch only surfaces as a runtime error. With\n // it, CI can compare against `/api/meta/schema-version` and say so.\n //\n // No generation timestamp. Tables are sorted above precisely so that\n // the same schema produces the same bytes; a timestamp put that back,\n // turning every regeneration into a diff and making the obvious staleness\n // gate — `rebase generate-sdk && git diff --exit-code` — impossible to pass.\n // `SCHEMA_VERSION` already identifies what this was built from, and does it\n // in a way that can be compared against a running project.\n const schemaVersion = remoteSchemaVersion ?? computeSchemaVersion(tables);\n files.push({\n path: \"schema.meta.ts\",\n content: `// Auto-generated by \\`rebase generate-sdk\\`. Do not edit.\n//\n// The schema version this SDK was generated from. Compare it against the\n// project's current version to detect drift:\n//\n// curl -s <api-url>/api/meta/schema-version\n//\n// Pass it to the client as \\`schemaVersion\\` and every request carries it in\n// the \\`x-rebase-schema\\` header, so the server can name the drift instead of\n// answering a renamed field with a bare 400.\nexport const SCHEMA_VERSION = ${JSON.stringify(schemaVersion)};\n`\n });\n\n console.log(chalk.green(` ✓ Generated ${files.length} file(s)`));\n console.log(chalk.gray(` schema ${schemaVersion}`));\n\n // 3. Write to disk\n console.log(chalk.cyan(` → Writing to ${resolvedOutput}...`));\n writeFiles(resolvedOutput, files);\n\n // 4. The server-side registration: on request, and kept current once a\n // project has it, so `rebase dev` regenerating the SDK never leaves the\n // server typed against an older schema than the client.\n const registerDir = projectRoot ? registrationDir(projectRoot) : undefined;\n if (args.register || (registerDir && hasRegistration(registerDir)) || manifestRegisters(projectRoot)) {\n if (!registerDir || !fs.existsSync(path.dirname(registerDir))) {\n console.log(chalk.red(` ✗ No backend/ directory to register the Database in${registerDir ? ` (${path.dirname(registerDir)})` : \"\"}.`));\n console.log(chalk.gray(\" --register writes backend/generated/register.ts; run it inside a project with a backend.\"));\n process.exit(1);\n return;\n }\n const databaseTypes = files.find((file) => file.path === \"database.types.ts\")?.content;\n if (databaseTypes !== undefined) {\n try {\n writeRegistration(registerDir, databaseTypes);\n } catch (error) {\n console.log(chalk.red(` ✗ ${error instanceof Error ? error.message : String(error)}`));\n process.exit(1);\n return;\n }\n console.log(chalk.green(` ✓ Registered the Database for server-side code in ${registerDir}`));\n if (args.register) {\n const remembered = rememberRegistration(projectRoot);\n if (\"written\" in remembered) {\n console.log(chalk.gray(` Remembered in ${path.relative(cwd, remembered.written) || \"rebase.json\"} (registerDatabase).`));\n } else {\n console.log(chalk.yellow(` ${remembered.skipped}`));\n }\n }\n }\n }\n\n console.log(\"\");\n console.log(chalk.green.bold(\" ✓ SDK generated successfully!\"));\n console.log(\"\");\n const typesImport = `./${path.relative(cwd, path.join(resolvedOutput, \"database.types\"))}`;\n const metaImport = `./${path.relative(cwd, path.join(resolvedOutput, \"schema.meta\"))}`;\n const exampleSlug = tables[0]?.slug || \"my_table\";\n\n console.log(chalk.gray(\" Usage:\"));\n console.log(chalk.gray(\" import { createRebaseClient } from '@rebasepro/client';\"));\n console.log(chalk.gray(` import { tablesDictionary, type Database } from '${typesImport}';`));\n console.log(chalk.gray(` import { SCHEMA_VERSION } from '${metaImport}';`));\n console.log(\"\");\n console.log(chalk.gray(\" const rebase = createRebaseClient<Database>({\"));\n console.log(chalk.gray(` baseUrl: '${resolveExampleBaseUrl(cwd)}',`));\n // Sent as `x-rebase-schema` on every request. Costs one line here and is\n // the difference between a server that can say \"this client is three\n // deploys behind\" and one that can only reject a field it does not know.\n console.log(chalk.gray(\" schemaVersion: SCHEMA_VERSION,\"));\n // Without the dictionary a hyphenated slug is not resolvable from the\n // property name alone, and the request 404s at runtime.\n console.log(chalk.gray(\" tables: tablesDictionary,\"));\n console.log(chalk.gray(\" // token: 'your-jwt-token',\"));\n console.log(chalk.gray(\" });\"));\n console.log(\"\");\n // `rebase.data.<accessor>` is the typed surface, so it is what gets printed.\n // `rebase.data.table(slug)` exists too, but it is generic over\n // `Record<string, unknown>` and has no link to `Database` — it was the\n // headline example here for a while, which advertised the one call shape\n // that throws away the types this command just generated.\n const exampleAccessor = toTableAccessor(exampleSlug);\n const exampleAccess = isIdentifierLike(exampleAccessor)\n ? `rebase.data.${exampleAccessor}`\n : `rebase.data[${JSON.stringify(exampleAccessor)}]`;\n console.log(chalk.gray(` const { data } = await ${exampleAccess}.find();`));\n console.log(\"\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwDA,IAAa,gBAAgB;;AAG7B,IAAM,kBAAkB;AAExB,IAAM,kBAAkB,GAAG,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;AAwB3C,SAAgB,gBAAgB,aAA6B;CACzD,OAAO,KAAK,KAAK,aAAa,aAAa;AAC/C;;AAGA,SAAS,gBAAgB,KAAsB;CAC3C,IAAI;EACA,OAAO,GAAG,aAAa,KAAK,KAAK,KAAK,aAAa,GAAG,OAAO,CAAC,CAAC,WAAW,eAAe;CAC7F,QAAQ;EACJ,OAAO;CACX;AACJ;;AAGA,SAAS,eAAe,UAAkB,SAAuB;CAC7D,IAAI;EACA,IAAI,GAAG,aAAa,UAAU,OAAO,MAAM,SAAS;CACxD,QAAQ,CAER;CACA,GAAG,cAAc,UAAU,SAAS,OAAO;AAC/C;;;;;;AAOA,SAAS,kBAAkB,KAAa,eAA6B;CACjE,MAAM,eAAe,KAAK,KAAK,KAAK,aAAa;CACjD,IAAI,GAAG,WAAW,YAAY,KAAK,CAAC,gBAAgB,GAAG,GACnD,MAAM,IAAI,MACN,GAAG,aAAa,mHAEpB;CAEJ,GAAG,UAAU,KAAK,EAAE,WAAW,KAAK,CAAC;CACrC,eAAe,KAAK,KAAK,KAAK,mBAAmB,GAAG,aAAa;CACjE,eAAe,cAAc,eAAe;AAChD;;;;;;;;;;;;;;;AAgBA,eAAsB,0BAClB,aACA,QACA,kBACsB;CACtB,MAAM,MAAM,gBAAgB,WAAW;CACvC,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,GAAG,GAAG,OAAO;CACvD,IAAI,OAAO,WAAW,GAAG,OAAO;CAChC,MAAM,gBAAgB,YAAY,aAAa,MAAM,GAAG,EAAE,eAAe,MAAM,CAAC,CAAC,CAC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;CAEvC,QAAQ,IAAI,MAAM,KAAK,UAAU,CAAC;CAClC,QAAQ,IAAI,MAAM,KAAK,6DAA6D,CAAC;CACrF,QAAQ,IAAI,MAAM,KAAK,wDAAwD,YAAY,GAAG,CAAC;CAC/F,QAAQ,IAAI,MAAM,KAAK,uCAAuC,WAAW,GAAG,CAAC;CAC7E,QAAQ,IAAI,EAAE;CACd,QAAQ,IAAI,MAAM,KAAK,mDAAmD,CAAC;CAC3E,QAAQ,IAAI,MAAM,KAAK,qBAAqB,sBAAsB,GAAG,EAAE,GAAG,CAAC;CAI3E,QAAQ,IAAI,MAAM,KAAK,wCAAwC,CAAC;CAGhE,QAAQ,IAAI,MAAM,KAAK,mCAAmC,CAAC;CAC3D,QAAQ,IAAI,MAAM,KAAK,qCAAqC,CAAC;CAC7D,QAAQ,IAAI,MAAM,KAAK,SAAS,CAAC;CACjC,QAAQ,IAAI,EAAE;CAMd,MAAM,kBAAkB,gBAAgB,WAAW;CACnD,MAAM,gBAAgB,iBAAiB,eAAe,IAChD,eAAe,oBACf,eAAe,KAAK,UAAU,eAAe,EAAE;CACrD,QAAQ,IAAI,MAAM,KAAK,8BAA8B,cAAc,SAAS,CAAC;CAC7E,QAAQ,IAAI,EAAE;AAClB"}
package/dist/index.es.js CHANGED
@@ -1,11 +1,11 @@
1
- import { i as recordEvent, n as isEnabled, u as errorClass } from "./telemetry-EVtASbKb.js";
1
+ import { i as recordEvent, n as isEnabled, u as errorClass } from "./telemetry-CJbrRuG3.js";
2
2
  import { n as unknownCommand } from "./unknown-command-DnZ2uhGs.js";
3
3
  import { n as parseCommandArgs, t as UsageError } from "./args-DHyrshtI.js";
4
- import { i as failAsJson, p as requireProjectRoot, y as wantsJsonOutput } from "./project-DALmhb5R.js";
5
- import { C as resolveBackendPaths, D as validateManifest, E as synthesizeManifest, O as writeManifest, S as manifestPath, T as staticAppAddress, _ as findBackendApp, a as DEFAULT_TABLES_DIR, b as loadManifest, c as LEGACY_CONFIG_DIR, d as STORAGE_FILE, f as TABLES_INDEX_FILES, g as compareMountOrder, h as cmsMountOf, i as DEFAULT_SCHEMA_FILE, l as ManifestError, m as buildableApps, n as DEFAULT_CRONS_DIR, o as GENERATED_DIR, p as assessManagedCompatibility, r as DEFAULT_FUNCTIONS_DIR, s as HOOKS_FILE, t as CURRENT_RUNTIME_RANGE, u as RESOURCES_FILE, v as findTablesIndex, w as selectDeployApp, x as manifestExists, y as formatAppAddress } from "./manifest-RjqxfCpb.js";
6
- import { a as refuseRemovedCollectionsFlag } from "./path-flags-ekLdkbra.js";
4
+ import { i as failAsJson, p as requireProjectRoot, y as wantsJsonOutput } from "./project-CQ5nKddJ.js";
5
+ import { C as resolveBackendPaths, D as validateManifest, E as synthesizeManifest, O as writeManifest, S as manifestPath, T as staticAppAddress, _ as findBackendApp, a as DEFAULT_TABLES_DIR, b as loadManifest, c as LEGACY_CONFIG_DIR, d as STORAGE_FILE, f as TABLES_INDEX_FILES, g as compareMountOrder, h as cmsMountOf, i as DEFAULT_SCHEMA_FILE, l as ManifestError, m as buildableApps, n as DEFAULT_CRONS_DIR, o as GENERATED_DIR, p as assessManagedCompatibility, r as DEFAULT_FUNCTIONS_DIR, s as HOOKS_FILE, t as CURRENT_RUNTIME_RANGE, u as RESOURCES_FILE, v as findTablesIndex, w as selectDeployApp, x as manifestExists, y as formatAppAddress } from "./manifest-D6B4LA8x.js";
6
+ import { a as refuseRemovedCollectionsFlag } from "./path-flags-B7Ydt5nv.js";
7
7
  import { n as cliVersion } from "./version-ONIeo7jl.js";
8
- import { C as normalizeEsmSpecifiers, S as foldStaticIntoBundle, T as vendorDependencies, _ as detectFrameworkDepDrift, a as VENDOR_SIZE_WARN_BYTES, b as findIgnoredConfigStorageAuthorize, c as buildBundle, d as bundledNpmrc, f as collectDeclaredDependencies, g as detectDeclaredDepConflicts, h as describeDepConflicts, i as VENDOR_SIZE_MAX_BYTES, l as buildStaticBundle, m as composeBundleManifest, n as DEFAULT_BUNDLE_DIR, o as VENDOR_TARGET_CPU, p as commentSpans, r as UNVENDORED_COST, s as VENDOR_TARGET_OS, t as BUNDLED_UI_CONFIG, u as bundleUiConfig, v as detectNativeDependencies, w as unvendoredReason, x as findUnusedServerEntry, y as detectStorageAuthorize } from "./bundle-CIiKGrte.js";
8
+ import { C as normalizeEsmSpecifiers, S as foldStaticIntoBundle, T as vendorDependencies, _ as detectFrameworkDepDrift, a as VENDOR_SIZE_WARN_BYTES, b as findIgnoredConfigStorageAuthorize, c as buildBundle, d as bundledNpmrc, f as collectDeclaredDependencies, g as detectDeclaredDepConflicts, h as describeDepConflicts, i as VENDOR_SIZE_MAX_BYTES, l as buildStaticBundle, m as composeBundleManifest, n as DEFAULT_BUNDLE_DIR, o as VENDOR_TARGET_CPU, p as commentSpans, r as UNVENDORED_COST, s as VENDOR_TARGET_OS, t as BUNDLED_UI_CONFIG, u as bundleUiConfig, v as detectNativeDependencies, w as unvendoredReason, x as findUnusedServerEntry, y as detectStorageAuthorize } from "./bundle-BDTVS9XE.js";
9
9
  import chalk from "chalk";
10
10
  import arg from "arg";
11
11
  import path from "path";
@@ -101,67 +101,67 @@ var NO_VOCABULARY = {
101
101
  async function commandVocabulary(command) {
102
102
  switch (command) {
103
103
  case "schema": return {
104
- subcommands: (await import("./schema-_FzZEoB8.js")).SCHEMA_SUBCOMMANDS,
104
+ subcommands: (await import("./schema-CWzzn0cY.js")).SCHEMA_SUBCOMMANDS,
105
105
  aliases: {}
106
106
  };
107
107
  case "db": return {
108
- subcommands: (await import("./db-D_iF4E-v.js")).DB_SUBCOMMANDS,
108
+ subcommands: (await import("./db-DAotpOxs.js")).DB_SUBCOMMANDS,
109
109
  aliases: {}
110
110
  };
111
111
  case "auth": return {
112
- subcommands: (await import("./auth-BpyYLEFY.js")).AUTH_SUBCOMMANDS,
112
+ subcommands: (await import("./auth-bi8x2YX1.js")).AUTH_SUBCOMMANDS,
113
113
  aliases: {}
114
114
  };
115
115
  case "skills": return {
116
- subcommands: (await import("./skills-DQ2bZGkj.js").then((n) => n.u)).SKILLS_SUBCOMMANDS,
116
+ subcommands: (await import("./skills-CWmBTCRW.js").then((n) => n.u)).SKILLS_SUBCOMMANDS,
117
117
  aliases: {}
118
118
  };
119
119
  case "api-keys": return {
120
- subcommands: (await import("./api-keys-fPQ55DCm.js").then((n) => n.t)).API_KEYS_SUBCOMMANDS,
120
+ subcommands: (await import("./api-keys-CG2IpknI.js").then((n) => n.t)).API_KEYS_SUBCOMMANDS,
121
121
  aliases: {}
122
122
  };
123
123
  case "storage": return {
124
- subcommands: (await import("./storage-Clc8dLG8.js")).STORAGE_SUBCOMMANDS,
124
+ subcommands: (await import("./storage-Dqf5tyhs.js")).STORAGE_SUBCOMMANDS,
125
125
  aliases: {}
126
126
  };
127
127
  case "data": return {
128
- subcommands: (await import("./data-BJ9AZFUC.js")).DATA_SUBCOMMANDS,
128
+ subcommands: (await import("./data-1eipHbxJ.js")).DATA_SUBCOMMANDS,
129
129
  aliases: {}
130
130
  };
131
131
  case "users": return {
132
- subcommands: (await import("./users-5PkqBY6R.js")).USERS_SUBCOMMANDS,
132
+ subcommands: (await import("./users-Cx5HuaTn.js")).USERS_SUBCOMMANDS,
133
133
  aliases: {}
134
134
  };
135
135
  case "cron": return {
136
- subcommands: (await import("./cron-CpUsQ739.js")).CRON_SUBCOMMANDS,
136
+ subcommands: (await import("./cron-DuZ3Svjq.js")).CRON_SUBCOMMANDS,
137
137
  aliases: {}
138
138
  };
139
139
  case "functions": return {
140
- subcommands: (await import("./functions-B4JR6EZL.js")).FUNCTIONS_SUBCOMMANDS,
140
+ subcommands: (await import("./functions-BCEJnISw.js")).FUNCTIONS_SUBCOMMANDS,
141
141
  aliases: {}
142
142
  };
143
143
  case "rls": return {
144
- subcommands: (await import("./rls-BxrQ0P50.js")).RLS_SUBCOMMANDS,
144
+ subcommands: (await import("./rls-B4zGbTKY.js")).RLS_SUBCOMMANDS,
145
145
  aliases: {}
146
146
  };
147
147
  case "apps": return {
148
- subcommands: (await import("./apps-DBTRoOeP.js")).APPS_SUBCOMMANDS,
148
+ subcommands: (await import("./apps-DaaWvv3o.js")).APPS_SUBCOMMANDS,
149
149
  aliases: {}
150
150
  };
151
151
  case "telemetry": return {
152
- subcommands: (await import("./telemetry-DZU2-NCm.js")).TELEMETRY_SUBCOMMANDS,
152
+ subcommands: (await import("./telemetry-B5RSeQIc.js")).TELEMETRY_SUBCOMMANDS,
153
153
  aliases: {}
154
154
  };
155
155
  case "generate": return {
156
- subcommands: (await import("./generate-view-BMaLQm8H.js")).GENERATE_SUBCOMMANDS,
156
+ subcommands: (await import("./generate-view-CZ0SmsJc.js")).GENERATE_SUBCOMMANDS,
157
157
  aliases: {}
158
158
  };
159
159
  case "migrate": return {
160
- subcommands: (await import("./migrate-CSY9ZDKy.js")).MIGRATE_SUBCOMMANDS,
160
+ subcommands: (await import("./migrate-DdcgLMyL.js")).MIGRATE_SUBCOMMANDS,
161
161
  aliases: {}
162
162
  };
163
163
  case "cloud": {
164
- const cloud = await import("./cloud-DNJyUU0T.js");
164
+ const cloud = await import("./cloud-CR6Hps3B.js");
165
165
  return {
166
166
  subcommands: cloud.CLOUD_GROUP_NAMES,
167
167
  aliases: cloud.GROUP_ALIASES
@@ -289,7 +289,7 @@ async function dispatch(command, effectiveSubcommand, args, parsedArgs, namespac
289
289
  return;
290
290
  }
291
291
  case "init": {
292
- const { createRebaseApp } = await import("./init-DHCe5mJ5.js");
292
+ const { createRebaseApp } = await import("./init-BctfWO3w.js");
293
293
  await createRebaseApp(args);
294
294
  break;
295
295
  }
@@ -311,9 +311,9 @@ async function dispatch(command, effectiveSubcommand, args, parsedArgs, namespac
311
311
  maxPositionals: 0
312
312
  });
313
313
  const sdkRoot = sdkHelp ? process.cwd() : requireProjectRoot();
314
- const { generateSdkCommand } = await import("./generate_sdk-ByD-gTsK.js");
314
+ const { generateSdkCommand } = await import("./generate_sdk-MAbUUZoK.js");
315
315
  await generateSdkCommand({
316
- schemaDir: sdkArgs["--schema-dir"] || (sdkHelp ? sdkRoot : (await import("./schema-dir-ChcYfWjP.js").then((n) => n.i)).resolveSchemaDir(sdkRoot)),
316
+ schemaDir: sdkArgs["--schema-dir"] || (sdkHelp ? sdkRoot : (await import("./schema-dir-Dd1Pzqq5.js").then((n) => n.i)).resolveSchemaDir(sdkRoot)),
317
317
  output: sdkArgs["--output"] || path.join(sdkRoot, "generated/sdk"),
318
318
  from: sdkArgs["--from"],
319
319
  token: sdkArgs["--token"],
@@ -325,151 +325,151 @@ async function dispatch(command, effectiveSubcommand, args, parsedArgs, namespac
325
325
  break;
326
326
  }
327
327
  case "schema": {
328
- const { schemaCommand } = await import("./schema-_FzZEoB8.js");
328
+ const { schemaCommand } = await import("./schema-CWzzn0cY.js");
329
329
  await schemaCommand(effectiveSubcommand, args);
330
330
  break;
331
331
  }
332
332
  case "db": {
333
- const { dbCommand } = await import("./db-D_iF4E-v.js");
333
+ const { dbCommand } = await import("./db-DAotpOxs.js");
334
334
  await dbCommand(effectiveSubcommand, args);
335
335
  break;
336
336
  }
337
337
  case "console": {
338
- const { consoleCommand } = await import("./console-BVoYOLAO.js");
338
+ const { consoleCommand } = await import("./console-BBGRHOFg.js");
339
339
  await consoleCommand(args);
340
340
  break;
341
341
  }
342
342
  case "dev": {
343
- const { devCommand } = await import("./dev-bj6dEeSQ.js");
343
+ const { devCommand } = await import("./dev-Ce9PVQS8.js");
344
344
  await devCommand(args);
345
345
  break;
346
346
  }
347
347
  case "normalize-imports": {
348
- const { normalizeImportsCommand } = await import("./normalize-imports-P86NVfpo.js");
348
+ const { normalizeImportsCommand } = await import("./normalize-imports-CVjOssZ2.js");
349
349
  await normalizeImportsCommand(args);
350
350
  break;
351
351
  }
352
352
  case "build": {
353
- const { buildCommand } = await import("./build-E5hfEWKj.js").then((n) => n.n);
353
+ const { buildCommand } = await import("./build-D-0VCmbU.js").then((n) => n.n);
354
354
  await buildCommand(args);
355
355
  break;
356
356
  }
357
357
  case "start": {
358
- const { startCommand } = await import("./start-Cjx4W0bJ.js");
358
+ const { startCommand } = await import("./start-4uhCu_md.js");
359
359
  await startCommand(args);
360
360
  break;
361
361
  }
362
362
  case "upgrade": {
363
- const { upgradeCommand } = await import("./upgrade-ZASvgxWM.js");
363
+ const { upgradeCommand } = await import("./upgrade-CepjhRrz.js");
364
364
  await upgradeCommand(args);
365
365
  break;
366
366
  }
367
367
  case "migrate": {
368
- const { migrateCommand } = await import("./migrate-CSY9ZDKy.js");
368
+ const { migrateCommand } = await import("./migrate-DdcgLMyL.js");
369
369
  await migrateCommand(effectiveSubcommand, args);
370
370
  break;
371
371
  }
372
372
  case "apps": {
373
- const { appsCommand } = await import("./apps-DBTRoOeP.js");
373
+ const { appsCommand } = await import("./apps-DaaWvv3o.js");
374
374
  await appsCommand(effectiveSubcommand, args);
375
375
  break;
376
376
  }
377
377
  case "generate": {
378
- const { generateCommand } = await import("./generate-view-BMaLQm8H.js");
378
+ const { generateCommand } = await import("./generate-view-CZ0SmsJc.js");
379
379
  await generateCommand(effectiveSubcommand, args);
380
380
  break;
381
381
  }
382
382
  case "eject": {
383
- const { ejectCommand } = await import("./eject-DK_M9kor.js");
383
+ const { ejectCommand } = await import("./eject-Dy-qRYhW.js");
384
384
  await ejectCommand(args);
385
385
  break;
386
386
  }
387
387
  case "auth": {
388
- const { authCommand } = await import("./auth-BpyYLEFY.js");
388
+ const { authCommand } = await import("./auth-bi8x2YX1.js");
389
389
  await authCommand(effectiveSubcommand, args);
390
390
  break;
391
391
  }
392
392
  case "status": {
393
- const { statusCommand } = await import("./status-CDBk25VO.js");
393
+ const { statusCommand } = await import("./status-CVEzoSwX.js");
394
394
  await statusCommand(args);
395
395
  break;
396
396
  }
397
397
  case "resources": {
398
- const { resourcesCommand } = await import("./resources-Db3USuPO.js");
398
+ const { resourcesCommand } = await import("./resources-ecA0MEjy.js");
399
399
  await resourcesCommand(args);
400
400
  break;
401
401
  }
402
402
  case "doctor": {
403
- const { doctorCommand } = await import("./doctor-FaBObSlb.js");
403
+ const { doctorCommand } = await import("./doctor-Cdu3Llrw.js");
404
404
  await doctorCommand(args);
405
405
  break;
406
406
  }
407
407
  case "verify": {
408
- const { verifyCommand } = await import("./verify-BdeqNb-V.js");
408
+ const { verifyCommand } = await import("./verify-D-1y5HQS.js");
409
409
  await verifyCommand(args);
410
410
  break;
411
411
  }
412
412
  case "skills": {
413
- const { skillsCommand } = await import("./skills-DQ2bZGkj.js").then((n) => n.u);
413
+ const { skillsCommand } = await import("./skills-CWmBTCRW.js").then((n) => n.u);
414
414
  await skillsCommand(effectiveSubcommand, args);
415
415
  break;
416
416
  }
417
417
  case "api-keys": {
418
- const { apiKeysCommand } = await import("./api-keys-fPQ55DCm.js").then((n) => n.t);
418
+ const { apiKeysCommand } = await import("./api-keys-CG2IpknI.js").then((n) => n.t);
419
419
  await apiKeysCommand(effectiveSubcommand, args);
420
420
  break;
421
421
  }
422
422
  case "storage": {
423
- const { storageCommand } = await import("./storage-Clc8dLG8.js");
423
+ const { storageCommand } = await import("./storage-Dqf5tyhs.js");
424
424
  await storageCommand(effectiveSubcommand, args);
425
425
  break;
426
426
  }
427
427
  case "cloud": {
428
- const { cloudCommand } = await import("./cloud-DNJyUU0T.js");
428
+ const { cloudCommand } = await import("./cloud-CR6Hps3B.js");
429
429
  await cloudCommand(effectiveSubcommand, args);
430
430
  break;
431
431
  }
432
432
  case "telemetry": {
433
- const { telemetryCommand } = await import("./telemetry-DZU2-NCm.js");
433
+ const { telemetryCommand } = await import("./telemetry-B5RSeQIc.js");
434
434
  await telemetryCommand(args);
435
435
  break;
436
436
  }
437
437
  case "api": {
438
- const { apiCommand } = await import("./api-TbmW33D7.js");
438
+ const { apiCommand } = await import("./api-CQh_qTyQ.js");
439
439
  await apiCommand(args);
440
440
  break;
441
441
  }
442
442
  case "data": {
443
- const { dataCommand } = await import("./data-BJ9AZFUC.js");
443
+ const { dataCommand } = await import("./data-1eipHbxJ.js");
444
444
  await dataCommand(effectiveSubcommand, args);
445
445
  break;
446
446
  }
447
447
  case "users": {
448
- const { usersCommand } = await import("./users-5PkqBY6R.js");
448
+ const { usersCommand } = await import("./users-Cx5HuaTn.js");
449
449
  await usersCommand(effectiveSubcommand, args);
450
450
  break;
451
451
  }
452
452
  case "cron": {
453
- const { cronCommand } = await import("./cron-CpUsQ739.js");
453
+ const { cronCommand } = await import("./cron-DuZ3Svjq.js");
454
454
  await cronCommand(effectiveSubcommand, args);
455
455
  break;
456
456
  }
457
457
  case "logs": {
458
- const { logsCommand } = await import("./logs-DpuMukJe.js");
458
+ const { logsCommand } = await import("./logs-B_mS4gCn.js");
459
459
  await logsCommand(args);
460
460
  break;
461
461
  }
462
462
  case "functions": {
463
- const { functionsCommand } = await import("./functions-B4JR6EZL.js");
463
+ const { functionsCommand } = await import("./functions-BCEJnISw.js");
464
464
  await functionsCommand(effectiveSubcommand, args);
465
465
  break;
466
466
  }
467
467
  case "rls": {
468
- const { rlsCommand } = await import("./rls-BxrQ0P50.js");
468
+ const { rlsCommand } = await import("./rls-B4zGbTKY.js");
469
469
  await rlsCommand(effectiveSubcommand, args);
470
470
  break;
471
471
  }
472
- default: unknownCommand(command, namespacedCommands, "", { cloud: (await import("./cloud-DNJyUU0T.js")).CLOUD_GROUP_NAMES });
472
+ default: unknownCommand(command, namespacedCommands, "", { cloud: (await import("./cloud-CR6Hps3B.js")).CLOUD_GROUP_NAMES });
473
473
  }
474
474
  }
475
475
  /** The global help. Exported so its Options block can be held against {@link ROOT_FLAGS}. */
@@ -1,14 +1,14 @@
1
- import { i as recordEvent, l as durationBucket } from "./telemetry-EVtASbKb.js";
2
- import { n as getPMCommands, t as detectPackageManager } from "./package-manager-DSEOwTqM.js";
1
+ import { i as recordEvent, l as durationBucket } from "./telemetry-CJbrRuG3.js";
2
+ import { n as getPMCommands, t as detectPackageManager } from "./package-manager-DTNNGHyK.js";
3
3
  import { a as wantsHelp, n as parseCommandArgs } from "./args-DHyrshtI.js";
4
4
  import { n as cliVersion } from "./version-ONIeo7jl.js";
5
- import { c as reportRootPointers, d as writeRootPointers, l as resolveAgentNames, n as AGENT_KEYS, t as AGENTS } from "./skills-DQ2bZGkj.js";
6
- import { configureAgents, printAgentSetup, promptForAgents, retargetScaffoldMcpConfig } from "./agent-setup-Cg_zBWoW.js";
7
- import { et as resolveCloudUrl, lt as writeLink } from "./context-BOMEoKxn.js";
5
+ import { c as reportRootPointers, d as writeRootPointers, l as resolveAgentNames, n as AGENT_KEYS, t as AGENTS } from "./skills-CWmBTCRW.js";
6
+ import { configureAgents, printAgentSetup, promptForAgents, retargetScaffoldMcpConfig } from "./agent-setup-kjdKozkF.js";
7
+ import { et as resolveCloudUrl, lt as writeLink } from "./context-C9lz1vTS.js";
8
8
  import { t as Refusal } from "./refusal-ReeeGP8a.js";
9
- import { r as dockerClaimedPorts } from "./dev-preflight-BMOf2N6r.js";
9
+ import { r as dockerClaimedPorts } from "./dev-preflight-DROlafgr.js";
10
10
  import { t as invokedRebaseCommand } from "./invoked-command-FBeIBS8o.js";
11
- import { n as promptForConsent } from "./consent-UV6ObCME.js";
11
+ import { n as promptForConsent } from "./consent-C8_Ik_GK.js";
12
12
  import chalk from "chalk";
13
13
  import fs from "fs";
14
14
  import os from "os";
@@ -650,6 +650,26 @@ function initNextSteps(input) {
650
650
  lines.push(note("REBASE_ADMIN_EMAIL in .env is created at boot instead."));
651
651
  lines.push("");
652
652
  lines.push(headless ? introspected ? chalk.gray("This starts a headless API (Hono + PostgreSQL) over the tables just ") + chalk.gray("generated from your database in backend/schema. Edit them to change what the ") + chalk.gray("API exposes; its OpenAPI document is /api/docs for signed-in callers (Swagger UI: set REBASE_ENABLE_SWAGGER=true).") : chalk.gray("This starts a headless API (Hono + PostgreSQL). There is no backend/schema: ") + chalk.gray("the API is derived from your database schema. Once it serves a table, its OpenAPI document is /api/docs for signed-in callers (Swagger UI: set REBASE_ENABLE_SWAGGER=true).") : chalk.gray("This starts both the backend (Hono + PostgreSQL)") + chalk.gray(" and the frontend (Vite + React) concurrently."));
653
+ lines.push("");
654
+ lines.push(chalk.bold("Once it is running:"));
655
+ lines.push("");
656
+ if (headless) {
657
+ lines.push(note("1. Open the URL dev prints. Ports come from the project's path, so trust the terminal."));
658
+ lines.push(note("2. Every table with row-level security and a policy is served at /api/data/<table>."));
659
+ lines.push(note("3. Ship it to Rebase Cloud:"));
660
+ lines.push(cmd(pm.run("deploy")));
661
+ lines.push(note(" or self-host it with Docker. README.md has both."));
662
+ } else {
663
+ lines.push(note("1. Open the admin panel at the URL dev prints."));
664
+ lines.push(note(" Ports come from the project's path, so trust the terminal over 3001/5173."));
665
+ lines.push(note("2. Add a table: a file in backend/schema/ with defineTable(...), exported from"));
666
+ lines.push(note(" backend/schema/index.ts. dev regenerates the schema and SDK and creates it."));
667
+ lines.push(note("3. Choose how it looks in the admin in frontend/src/cms/<table>.tsx."));
668
+ lines.push(note("4. Call the API from your own code: scripts/example.ts uses the typed client."));
669
+ lines.push(note("5. Ship it to Rebase Cloud:"));
670
+ lines.push(cmd(pm.run("deploy")));
671
+ lines.push(note(" or self-host it with docker compose. README.md has both."));
672
+ }
653
673
  return lines;
654
674
  }
655
675
  /**
@@ -876,18 +896,9 @@ async function createProject(options) {
876
896
  console.log("");
877
897
  console.log(`${chalk.green.bold("✓")} Project ${chalk.bold(options.projectName)} created successfully!`);
878
898
  console.log("");
879
- console.log(chalk.bold("Next steps:"));
899
+ console.log(chalk.bold("🤖 AI Agent Skills"));
880
900
  console.log("");
881
- const nextSteps = initNextSteps({
882
- headless: options.headless,
883
- ownDatabase: Boolean(options.databaseUrl),
884
- introspect: Boolean(options.introspect),
885
- introspected,
886
- installed,
887
- cdTarget: formatCdTarget(process.cwd(), options.targetDirectory),
888
- pm: pmCommands
889
- });
890
- for (const line of nextSteps) console.log(line);
901
+ for (const line of agentNextSteps(options.agents, options.interactive === true, pmCommands)) console.log(line);
891
902
  console.log("");
892
903
  console.log(chalk.gray("Docs: https://rebase.pro/docs"));
893
904
  const repo = initRepoLine(hasSeenStarNudge(), {
@@ -896,11 +907,6 @@ async function createProject(options) {
896
907
  });
897
908
  console.log(repo.nudge ? repo.line : chalk.gray(repo.line));
898
909
  if (repo.nudge) markStarNudgeSeen();
899
- console.log("");
900
- console.log(chalk.bold("🤖 AI Agent Skills"));
901
- console.log("");
902
- for (const line of agentNextSteps(options.agents, options.interactive === true, pmCommands)) console.log(line);
903
- console.log("");
904
910
  const initProperties = {
905
911
  preset: options.headless ? "none" : options.preset,
906
912
  headless: Boolean(options.headless),
@@ -913,6 +919,20 @@ async function createProject(options) {
913
919
  duration: durationBucket(Date.now() - startedAt)
914
920
  };
915
921
  if (await promptForConsent({ reAskDeclined: true })) await recordEvent("cli.init", initProperties, { projectRoot: options.targetDirectory });
922
+ console.log("");
923
+ console.log(chalk.bold("Next steps:"));
924
+ console.log("");
925
+ const nextSteps = initNextSteps({
926
+ headless: options.headless,
927
+ ownDatabase: Boolean(options.databaseUrl),
928
+ introspect: Boolean(options.introspect),
929
+ introspected,
930
+ installed,
931
+ cdTarget: formatCdTarget(process.cwd(), options.targetDirectory),
932
+ pm: pmCommands
933
+ });
934
+ for (const line of nextSteps) console.log(line);
935
+ console.log("");
916
936
  }
917
937
  /**
918
938
  * Reduce the scaffolded project to the chosen shape.
@@ -1382,4 +1402,4 @@ async function configureEnvFile(targetDirectory, databaseUrl) {
1382
1402
  //#endregion
1383
1403
  export { createRebaseApp };
1384
1404
 
1385
- //# sourceMappingURL=init-DHCe5mJ5.js.map
1405
+ //# sourceMappingURL=init-BctfWO3w.js.map