@rebasepro/cli 0.30.1 → 0.31.0-canary.g59cd6fd

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/README.md +8 -7
  2. package/dist/{agent-setup-0uyfC7VX.js → agent-setup-DqAcoDcn.js} +10 -5
  3. package/dist/{agent-setup-0uyfC7VX.js.map → agent-setup-DqAcoDcn.js.map} +1 -1
  4. package/dist/{api-keys-Dfw5-9s1.js → api-keys-eIUjMqWn.js} +8 -7
  5. package/dist/api-keys-eIUjMqWn.js.map +1 -0
  6. package/dist/{apps-MKQbgDtN.js → apps-DExO4PEl.js} +8 -7
  7. package/dist/apps-DExO4PEl.js.map +1 -0
  8. package/dist/{project-CasK56vN.js → args-CaCcrYE1.js} +2 -351
  9. package/dist/args-CaCcrYE1.js.map +1 -0
  10. package/dist/{atlas-dev-database-BODqdCWt.js → atlas-dev-database-DOCKk6ht.js} +2 -2
  11. package/dist/{atlas-dev-database-BODqdCWt.js.map → atlas-dev-database-DOCKk6ht.js.map} +1 -1
  12. package/dist/{auth-Bv0rTbQX.js → auth-D96QYgFR.js} +7 -6
  13. package/dist/{auth-Bv0rTbQX.js.map → auth-D96QYgFR.js.map} +1 -1
  14. package/dist/backend-guard-C0mVkXBw.js +162 -0
  15. package/dist/backend-guard-C0mVkXBw.js.map +1 -0
  16. package/dist/{branch-pointer-BQUF6lYa.js → branch-pointer-DMPyvZoK.js} +1 -1
  17. package/dist/{build-BuKTnec8.js → build-CA5R07tw.js} +29 -9
  18. package/dist/build-CA5R07tw.js.map +1 -0
  19. package/dist/{bundle-BAH4FCju.js → bundle-DgILeA5b.js} +112 -138
  20. package/dist/bundle-DgILeA5b.js.map +1 -0
  21. package/dist/bundle.d.ts +35 -12
  22. package/dist/cli.d.ts +2 -2
  23. package/dist/{cloud-DtADfWwn.js → cloud-CYMk92iG.js} +72 -71
  24. package/dist/cloud-CYMk92iG.js.map +1 -0
  25. package/dist/cms-directories-BK3vcswg.js +33 -0
  26. package/dist/cms-directories-BK3vcswg.js.map +1 -0
  27. package/dist/codemod/collections-to-tables/ast.d.ts +135 -0
  28. package/dist/codemod/collections-to-tables/backend.d.ts +38 -0
  29. package/dist/codemod/collections-to-tables/command.d.ts +35 -0
  30. package/dist/codemod/collections-to-tables/comments.d.ts +45 -0
  31. package/dist/codemod/collections-to-tables/customization.d.ts +47 -0
  32. package/dist/codemod/collections-to-tables/dynamic-props.d.ts +34 -0
  33. package/dist/codemod/collections-to-tables/export-changes.d.ts +83 -0
  34. package/dist/codemod/collections-to-tables/firestore.d.ts +11 -0
  35. package/dist/codemod/collections-to-tables/helper-hooks.d.ts +41 -0
  36. package/dist/codemod/collections-to-tables/hooks.d.ts +44 -0
  37. package/dist/codemod/collections-to-tables/journal.d.ts +10 -0
  38. package/dist/codemod/collections-to-tables/legacy-shims.d.ts +52 -0
  39. package/dist/codemod/collections-to-tables/load-legacy.d.ts +81 -0
  40. package/dist/codemod/collections-to-tables/migrate.d.ts +20 -0
  41. package/dist/codemod/collections-to-tables/modules.d.ts +127 -0
  42. package/dist/codemod/collections-to-tables/moved-imports.d.ts +70 -0
  43. package/dist/codemod/collections-to-tables/moved-symbols.generated.d.ts +12 -0
  44. package/dist/codemod/collections-to-tables/own.d.ts +10 -0
  45. package/dist/codemod/collections-to-tables/path-aliases.d.ts +26 -0
  46. package/dist/codemod/collections-to-tables/plan-context.d.ts +49 -0
  47. package/dist/codemod/collections-to-tables/print-js.d.ts +44 -0
  48. package/dist/codemod/collections-to-tables/project-files.d.ts +144 -0
  49. package/dist/codemod/collections-to-tables/repoint.d.ts +50 -0
  50. package/dist/codemod/collections-to-tables/row-hands.d.ts +7 -0
  51. package/dist/codemod/collections-to-tables/sdk-calls.d.ts +88 -0
  52. package/dist/codemod/collections-to-tables/skills-step.d.ts +13 -0
  53. package/dist/codemod/collections-to-tables/split-constants.d.ts +42 -0
  54. package/dist/codemod/collections-to-tables/storage-paths.d.ts +28 -0
  55. package/dist/codemod/collections-to-tables/types.d.ts +164 -0
  56. package/dist/codemod/collections-to-tables/verify.d.ts +27 -0
  57. package/dist/codemod/collections-to-tables/vocabulary.d.ts +40 -0
  58. package/dist/command-D5lhW_-B.js +9984 -0
  59. package/dist/command-D5lhW_-B.js.map +1 -0
  60. package/dist/commands/agent-setup.d.ts +6 -2
  61. package/dist/commands/cloud/context.d.ts +1 -1
  62. package/dist/commands/cloud/init.d.ts +2 -2
  63. package/dist/commands/console.d.ts +1 -2
  64. package/dist/commands/db.d.ts +5 -6
  65. package/dist/commands/dev.d.ts +18 -17
  66. package/dist/commands/doctor.d.ts +4 -5
  67. package/dist/commands/eject.d.ts +17 -13
  68. package/dist/commands/generate-view.d.ts +20 -9
  69. package/dist/commands/generate_sdk.d.ts +27 -27
  70. package/dist/commands/init.d.ts +21 -8
  71. package/dist/commands/migrate.d.ts +24 -0
  72. package/dist/commands/schema-reconcile.d.ts +1 -1
  73. package/dist/commands/skills.d.ts +8 -0
  74. package/dist/commands/verify-cms.d.ts +28 -0
  75. package/dist/commands/verify.d.ts +14 -9
  76. package/dist/{consent-BD7F29T3.js → consent-BXLIrMl8.js} +2 -2
  77. package/dist/{consent-BD7F29T3.js.map → consent-BXLIrMl8.js.map} +1 -1
  78. package/dist/{console-CdwIYOMV.js → console-C1d3LwB7.js} +14 -14
  79. package/dist/console-C1d3LwB7.js.map +1 -0
  80. package/dist/{context-AXdAh-q8.js → context--JwaHaZp.js} +6 -5
  81. package/dist/context--JwaHaZp.js.map +1 -0
  82. package/dist/{daemon-Cp7oNXth.js → daemon-w30PsdwV.js} +2 -2
  83. package/dist/{daemon-Cp7oNXth.js.map → daemon-w30PsdwV.js.map} +1 -1
  84. package/dist/{db-DBbKpjYX.js → db-DQZK9n9c.js} +52 -51
  85. package/dist/db-DQZK9n9c.js.map +1 -0
  86. package/dist/{derive-ae9UOoOB.js → derive-C3ezmY-p.js} +105 -133
  87. package/dist/derive-C3ezmY-p.js.map +1 -0
  88. package/dist/{dev-C93d4QIv.js → dev-PY5h4O6u.js} +142 -84
  89. package/dist/dev-PY5h4O6u.js.map +1 -0
  90. package/dist/dev-db/attver.d.ts +32 -0
  91. package/dist/dev-db/pull.d.ts +15 -1
  92. package/dist/{dev-preflight-Cxv3TiD1.js → dev-preflight-DjvcV6SK.js} +5 -5
  93. package/dist/dev-preflight-DjvcV6SK.js.map +1 -0
  94. package/dist/{dev-server-OJsUGZEB.js → dev-server-BLxCbQEP.js} +2 -2
  95. package/dist/{dev-server-OJsUGZEB.js.map → dev-server-BLxCbQEP.js.map} +1 -1
  96. package/dist/{doctor-BBPQUO2g.js → doctor-CnUu8kpM.js} +39 -62
  97. package/dist/doctor-CnUu8kpM.js.map +1 -0
  98. package/dist/doctor-environment.d.ts +6 -6
  99. package/dist/{eject-DABcDnPN.js → eject-Bhzd6hgb.js} +25 -16
  100. package/dist/eject-Bhzd6hgb.js.map +1 -0
  101. package/dist/{fold-static-BWzxNn06.js → fold-static-CKewnAPX.js} +5 -3
  102. package/dist/fold-static-CKewnAPX.js.map +1 -0
  103. package/dist/{generate-view-IFwCADvb.js → generate-view-CTOluXvH.js} +160 -89
  104. package/dist/generate-view-CTOluXvH.js.map +1 -0
  105. package/dist/{generate_sdk-DNmNuFuW.js → generate_sdk-De-aLC1L.js} +120 -137
  106. package/dist/generate_sdk-De-aLC1L.js.map +1 -0
  107. package/dist/import-schema-module-Df67TIWj.js +51 -0
  108. package/dist/import-schema-module-Df67TIWj.js.map +1 -0
  109. package/dist/index.es.js +64 -51
  110. package/dist/index.es.js.map +1 -1
  111. package/dist/{init-vL1DWOeC.js → init-Dtl-IcXf.js} +83 -80
  112. package/dist/init-Dtl-IcXf.js.map +1 -0
  113. package/dist/last-dev-database-Dc8cP01o.js +2 -0
  114. package/dist/{manifest-BtzDy7KQ.js → manifest-C3uLDrrJ.js} +115 -40
  115. package/dist/manifest-C3uLDrrJ.js.map +1 -0
  116. package/dist/manifest.d.ts +79 -24
  117. package/dist/migrate-VrKoi3nB.js +138 -0
  118. package/dist/migrate-VrKoi3nB.js.map +1 -0
  119. package/dist/{normalize-imports-Bd5Y4yLp.js → normalize-imports-DwxqEMYq.js} +3 -3
  120. package/dist/{normalize-imports-Bd5Y4yLp.js.map → normalize-imports-DwxqEMYq.js.map} +1 -1
  121. package/dist/path-flags-7O5uPBcQ.js +139 -0
  122. package/dist/path-flags-7O5uPBcQ.js.map +1 -0
  123. package/dist/{prepare-CTw9NEkh.js → prepare-Ccxspoj-.js} +4 -4
  124. package/dist/{prepare-CTw9NEkh.js.map → prepare-Ccxspoj-.js.map} +1 -1
  125. package/dist/project-CLcF5i8c.js +360 -0
  126. package/dist/project-CLcF5i8c.js.map +1 -0
  127. package/dist/project-schema-CsSOG2gE.js +30 -0
  128. package/dist/project-schema-CsSOG2gE.js.map +1 -0
  129. package/dist/{pull-DDMpsZ5r.js → pull-DRWqBZp5.js} +327 -4
  130. package/dist/pull-DRWqBZp5.js.map +1 -0
  131. package/dist/resolve-BY7bSFRT.js +2 -0
  132. package/dist/resources/derive.d.ts +19 -13
  133. package/dist/{resources-CPSC5Kcu.js → resources-Dpfs2y8P.js} +5 -4
  134. package/dist/{resources-CPSC5Kcu.js.map → resources-Dpfs2y8P.js.map} +1 -1
  135. package/dist/{schema-DtLPsXbT.js → schema-CdDjv5zI.js} +41 -39
  136. package/dist/schema-CdDjv5zI.js.map +1 -0
  137. package/dist/schema-dir-Cd1kvYbf.js +98 -0
  138. package/dist/schema-dir-Cd1kvYbf.js.map +1 -0
  139. package/dist/schema-reconcile-BAupXfkd.js +2 -0
  140. package/dist/schema-text-CpNrsuMe.js +73 -0
  141. package/dist/schema-text-CpNrsuMe.js.map +1 -0
  142. package/dist/{skills-CbwV6vw_.js → skills-CXjA9TWw.js} +54 -10
  143. package/dist/skills-CXjA9TWw.js.map +1 -0
  144. package/dist/{start-YOr3X5Zm.js → start-Bwbtt2W5.js} +7 -10
  145. package/dist/{start-YOr3X5Zm.js.map → start-Bwbtt2W5.js.map} +1 -1
  146. package/dist/{status-BREvtzJm.js → status-D7XCGHu2.js} +12 -12
  147. package/dist/status-D7XCGHu2.js.map +1 -0
  148. package/dist/{storage-CO9ouK76.js → storage-iTqj5-Av.js} +12 -11
  149. package/dist/storage-iTqj5-Av.js.map +1 -0
  150. package/dist/{telemetry-DwK5RQJl.js → telemetry-BP_1Cl9r.js} +4 -4
  151. package/dist/{telemetry-DwK5RQJl.js.map → telemetry-BP_1Cl9r.js.map} +1 -1
  152. package/dist/{telemetry-CgwJPVMO.js → telemetry-M3HjlyhZ.js} +2 -2
  153. package/dist/{telemetry-CgwJPVMO.js.map → telemetry-M3HjlyhZ.js.map} +1 -1
  154. package/dist/{upgrade-B7sVwL8S.js → upgrade-oZzJ13jM.js} +5 -4
  155. package/dist/{upgrade-B7sVwL8S.js.map → upgrade-oZzJ13jM.js.map} +1 -1
  156. package/dist/utils/backend-guard.d.ts +47 -0
  157. package/dist/utils/cms-directories.d.ts +6 -0
  158. package/dist/utils/dev-preflight.d.ts +2 -2
  159. package/dist/utils/import-schema-module.d.ts +16 -0
  160. package/dist/utils/path-flags.d.ts +35 -16
  161. package/dist/utils/project-schema.d.ts +40 -0
  162. package/dist/utils/project.d.ts +8 -2
  163. package/dist/utils/schema-dir.d.ts +32 -0
  164. package/dist/utils/schema-drift.d.ts +6 -0
  165. package/dist/utils/schema-text.d.ts +24 -0
  166. package/dist/verify-5p_vaUG2.js +1160 -0
  167. package/dist/verify-5p_vaUG2.js.map +1 -0
  168. package/package.json +11 -8
  169. package/runtime/dev-server.mjs +5 -1
  170. package/templates/eject/Dockerfile +1 -4
  171. package/templates/eject/backend/src/env.ts +1 -1
  172. package/templates/eject/backend/src/index.ts +53 -40
  173. package/templates/eject/docker-compose.custom.yml +1 -1
  174. package/templates/overlays/baas/README.md +39 -12
  175. package/templates/overlays/baas/ai-instructions.md +8 -8
  176. package/templates/overlays/baas/{config → backend}/storage.ts +3 -4
  177. package/templates/overlays/baas/backend/tsconfig.json +10 -12
  178. package/templates/overlays/baas/package.json +1 -2
  179. package/templates/overlays/baas/pnpm-workspace.yaml +0 -1
  180. package/templates/presets/blank/backend/schema/index.ts +19 -0
  181. package/templates/presets/blank/frontend/src/App.tsx +56 -0
  182. package/templates/presets/ecommerce/backend/schema/categories.ts +12 -0
  183. package/templates/presets/ecommerce/backend/schema/index.ts +23 -0
  184. package/templates/presets/ecommerce/backend/schema/orders.ts +13 -0
  185. package/templates/presets/ecommerce/backend/schema/products.ts +18 -0
  186. package/templates/presets/ecommerce/frontend/src/App.tsx +59 -0
  187. package/templates/presets/ecommerce/frontend/src/cms/categories.tsx +12 -0
  188. package/templates/presets/ecommerce/frontend/src/cms/orders.tsx +38 -0
  189. package/templates/presets/ecommerce/frontend/src/cms/products.tsx +27 -0
  190. package/templates/resource-graphs/blank.json +2 -2
  191. package/templates/resource-graphs/blog.json +5 -5
  192. package/templates/resource-graphs/ecommerce.json +5 -5
  193. package/templates/resource-graphs/headless.json +1 -1
  194. package/templates/template/.claude/hooks/post-edit-collection.sh +27 -23
  195. package/templates/template/.cursorrules +2 -2
  196. package/templates/template/.env.example +6 -17
  197. package/templates/template/.github/copilot-instructions.md +2 -2
  198. package/templates/template/.windsurfrules +2 -2
  199. package/templates/template/AGENTS.md +2 -2
  200. package/templates/template/CLAUDE.md +2 -2
  201. package/templates/template/README.md +47 -13
  202. package/templates/template/ai-instructions.md +15 -14
  203. package/templates/template/backend/functions/hello.ts +1 -1
  204. package/templates/template/backend/package.json +0 -2
  205. package/templates/template/{config → backend}/resources.ts +3 -3
  206. package/templates/template/backend/schema/authors.ts +11 -0
  207. package/templates/template/backend/schema/index.ts +29 -0
  208. package/templates/template/backend/schema/posts.ts +29 -0
  209. package/templates/template/backend/schema/tags.ts +9 -0
  210. package/templates/template/backend/schema/users.ts +32 -0
  211. package/templates/template/{config → backend}/storage.ts +4 -4
  212. package/templates/template/backend/tsconfig.json +15 -20
  213. package/templates/template/docker-compose.yml +3 -3
  214. package/templates/template/frontend/package.json +0 -2
  215. package/templates/template/frontend/src/App.tsx +10 -4
  216. package/templates/template/frontend/src/cms/authors.tsx +7 -0
  217. package/templates/template/frontend/src/cms/posts.tsx +27 -0
  218. package/templates/template/frontend/src/cms/tags.tsx +11 -0
  219. package/templates/template/frontend/src/cms/ui-config.json +3 -0
  220. package/templates/template/frontend/src/cms/users.tsx +54 -0
  221. package/templates/template/frontend/src/{virtual.d.ts → vite-env.d.ts} +0 -4
  222. package/templates/template/frontend/vite.config.ts +6 -2
  223. package/templates/template/gitignore +1 -1
  224. package/templates/template/package.json +1 -2
  225. package/templates/template/pnpm-workspace.yaml +0 -1
  226. package/templates/template/scripts/example.ts +3 -3
  227. package/templates/template/tsconfig.json +1 -1
  228. package/templates/views/AppView.tsx.tmpl +4 -4
  229. package/templates/views/EntityView.tsx.tmpl +3 -4
  230. package/dist/api-keys-Dfw5-9s1.js.map +0 -1
  231. package/dist/apps-MKQbgDtN.js.map +0 -1
  232. package/dist/build-BuKTnec8.js.map +0 -1
  233. package/dist/bundle-BAH4FCju.js.map +0 -1
  234. package/dist/cloud-DtADfWwn.js.map +0 -1
  235. package/dist/collection-drift-BKj_BoMq.js +0 -106
  236. package/dist/collection-drift-BKj_BoMq.js.map +0 -1
  237. package/dist/collections-dir-DlvDhime.js +0 -69
  238. package/dist/collections-dir-DlvDhime.js.map +0 -1
  239. package/dist/console-CdwIYOMV.js.map +0 -1
  240. package/dist/context-AXdAh-q8.js.map +0 -1
  241. package/dist/db-DBbKpjYX.js.map +0 -1
  242. package/dist/derive-ae9UOoOB.js.map +0 -1
  243. package/dist/dev-C93d4QIv.js.map +0 -1
  244. package/dist/dev-preflight-Cxv3TiD1.js.map +0 -1
  245. package/dist/doctor-BBPQUO2g.js.map +0 -1
  246. package/dist/eject-DABcDnPN.js.map +0 -1
  247. package/dist/fold-static-BWzxNn06.js.map +0 -1
  248. package/dist/generate-view-IFwCADvb.js.map +0 -1
  249. package/dist/generate_sdk-DNmNuFuW.js.map +0 -1
  250. package/dist/init-vL1DWOeC.js.map +0 -1
  251. package/dist/last-dev-database-DpW5dfoX.js +0 -2
  252. package/dist/manifest-BtzDy7KQ.js.map +0 -1
  253. package/dist/path-flags-DNvtEi2-.js +0 -92
  254. package/dist/path-flags-DNvtEi2-.js.map +0 -1
  255. package/dist/project-CasK56vN.js.map +0 -1
  256. package/dist/pull-DDMpsZ5r.js.map +0 -1
  257. package/dist/resolve-D647F1LA.js +0 -2
  258. package/dist/schema-DtLPsXbT.js.map +0 -1
  259. package/dist/schema-reconcile-DkArN9jF.js +0 -2
  260. package/dist/skills-CbwV6vw_.js.map +0 -1
  261. package/dist/status-BREvtzJm.js.map +0 -1
  262. package/dist/storage-CO9ouK76.js.map +0 -1
  263. package/dist/utils/collection-drift.d.ts +0 -27
  264. package/dist/utils/collections-dir.d.ts +0 -14
  265. package/dist/verify-Y3rWSgfA.js +0 -730
  266. package/dist/verify-Y3rWSgfA.js.map +0 -1
  267. package/templates/overlays/baas/config/index.ts +0 -24
  268. package/templates/overlays/baas/config/package.json +0 -30
  269. package/templates/template/config/cms.d.ts +0 -15
  270. package/templates/template/config/collections/authors.ts +0 -47
  271. package/templates/template/config/collections/index.ts +0 -44
  272. package/templates/template/config/collections/posts.ts +0 -94
  273. package/templates/template/config/collections/presets/blank/index.ts +0 -5
  274. package/templates/template/config/collections/presets/ecommerce/categories.ts +0 -42
  275. package/templates/template/config/collections/presets/ecommerce/index.ts +0 -31
  276. package/templates/template/config/collections/presets/ecommerce/orders.ts +0 -78
  277. package/templates/template/config/collections/presets/ecommerce/products.ts +0 -73
  278. package/templates/template/config/collections/tags.ts +0 -27
  279. package/templates/template/config/collections/users.ts +0 -149
  280. package/templates/template/config/frontend-assets.d.ts +0 -17
  281. package/templates/template/config/index.ts +0 -12
  282. package/templates/template/config/package.json +0 -30
  283. package/templates/template/config/tsconfig.json +0 -35
  284. /package/templates/eject/{config → backend}/resources.ts +0 -0
@@ -8,8 +8,7 @@
8
8
  #
9
9
  # Leave it unset and `rebase dev` starts a managed PostgreSQL for this project,
10
10
  # with its data under .rebase/ — no Docker, nothing to install. Set it and that
11
- # database wins over the managed one, always: PostgreSQL (postgresql://) or
12
- # MongoDB (mongodb:// or mongodb+srv://), detected from the scheme.
11
+ # database wins over the managed one, always (postgresql://).
13
12
  #
14
13
  # `rebase init` writes your project's `.env` with this line commented out, which
15
14
  # is what puts a new project on the managed database. `rebase db url` prints
@@ -19,7 +18,6 @@
19
18
  # schema tooling (atlas) would otherwise default to requiring SSL. Remove it
20
19
  # when pointing at a managed/cloud database.
21
20
  DATABASE_URL=postgresql://rebase_app:changeme@localhost:5432/rebase?options=-c%20search_path%3Dpublic&sslmode=disable
22
- # DATABASE_URL=mongodb://localhost:27017/rebase
23
21
  #
24
22
  # Seeing "SSL is not enabled on the server"? Something in your environment
25
23
  # asks for SSL — almost always a global PGSSLMODE=require
@@ -75,7 +73,7 @@ JWT_REFRESH_EXPIRES_IN=30d
75
73
  # Does the data API demand a token before it looks at anything? Defaults to
76
74
  # `true`. Set `false` for a backend a public website reads — row-level security
77
75
  # still decides which rows come back, this only removes the gate in front of it,
78
- # so a collection with no `select` rule still returns nothing.
76
+ # so a table with no `select` rule still returns nothing.
79
77
  # AUTH_REQUIRE=false
80
78
 
81
79
  # ── Registration ──────────────────────────────────────────────────────────────
@@ -204,11 +202,11 @@ VITE_API_URL=
204
202
  # interface and pass it directly in your backend config.
205
203
 
206
204
  # --- Several buckets ------------------------------------------------------
207
- # Declare them in config/resources.ts, then configure each from the SAME
205
+ # Declare them in backend/resources.ts, then configure each from the SAME
208
206
  # variable names carrying its own suffix. The default source takes no suffix, so
209
207
  # everything above keeps working and a single-bucket project declares nothing.
210
208
  #
211
- # config/resources.ts: export const media = bucket("media", { engine: "s3" });
209
+ # backend/resources.ts: export const media = bucket("media", { engine: "s3" });
212
210
  #
213
211
  # Then `rebase resources --write` regenerates rebase.resources.json, which is
214
212
  # what readers that cannot run your code — the build, the control plane — see.
@@ -252,15 +250,6 @@ VITE_API_URL=
252
250
  # Falls back to false. Useful for databases with application-only roles or managed setups.
253
251
  # DISABLE_DB_ROLE_SWITCHING=true
254
252
 
255
- # ── Collection config strictness (optional) ───────────────────────────────────
256
- # What boot does with a key in your collections that this version does not read.
257
- # A key it knows *moved* is always fatal; this governs the ones it simply does
258
- # not recognise, which are usually a typo and occasionally deliberate metadata.
259
- # warn log it and boot (the default)
260
- # error refuse to boot — worth turning on in CI
261
- # off say nothing
262
- # REBASE_STRICT_COLLECTION_CONFIG=error
263
-
264
253
  # ── Self-hosting (docker compose) ─────────────────────────────────────────────
265
254
  # The runtime image tag the compose file runs: `rebasepro/server:${REBASE_VERSION}`.
266
255
  # `rebase init` pins it to the version it scaffolded against, so a project does
@@ -268,9 +257,9 @@ VITE_API_URL=
268
257
  # unset. To upgrade, change this and restart — your bundle is untouched.
269
258
  REBASE_VERSION=latest
270
259
 
271
- # Whether boot provisions the schema your collections describe.
260
+ # Whether boot provisions the schema your tables describe.
272
261
  # ensure create missing tables, columns and enum types, additively (the default)
273
- # none leave your collections' schema alone (auth's tables are still kept current)
262
+ # none leave your tables' schema alone (auth's tables are still kept current)
274
263
  # Any other value refuses to boot. Boot never runs migration files: the ones
275
264
  # `rebase db generate` writes to `backend/drizzle/migrations` are applied with
276
265
  # `rebase db migrate`.
@@ -6,8 +6,8 @@ The Rebase skills for this assistant live in `.github/instructions/`. If they ar
6
6
 
7
7
  These hold before you have opened ai-instructions.md, and in every session:
8
8
 
9
- - **A table is a collection.** Declare it in `config/collections/<name>.ts` with `defineCollection`, and `pnpm dev` creates it. Never `CREATE TABLE`, `ALTER TABLE` or `CREATE INDEX` in code, and never SQL as the database owner against an application table: `rebase.sql()` skips row-level security, validation and callbacks, so keep it for server work that needs every row and for reading a column marked `excludeFromApi`. When the SDK cannot express a query, run it as the caller with `getSql(c)` — the same row-level security as the SDK, read-only unless `{ write: true }`, every value in `params`. A table that already exists gets its collection from `pnpm schema:introspect`.
10
- - **Data goes through the SDK:** `rebase.dataAsAdmin.<slug>` in functions and crons, `getDriver(c)` to act as the caller.
9
+ - **A table is a file in `backend/schema/`.** Declare it with `defineTable` from `@rebasepro/server/schema` — columns, relations and a required `rls` — export it from `backend/schema/index.ts`, and `pnpm dev` creates it. How it looks in the admin panel is a separate, optional file: `frontend/src/cms/<table>.tsx` with `customizeTable`, which imports the table as a type only. Never `CREATE TABLE`, `ALTER TABLE` or `CREATE INDEX` in code, and never SQL as the database owner against an application table: `rebase.sql()` skips row-level security, validation and hooks, so keep it for server work that needs every row and for reading a column marked `.private()`. When the SDK cannot express a query, run it as the caller with `getSql(c)` — the same row-level security as the SDK, read-only unless `{ write: true }`, every value in `params`. A table that already exists gets its file from `pnpm schema:introspect`. With no `backend/schema/` (a headless project) the database is the schema instead: ai-instructions.md says how to serve a table.
10
+ - **Data goes through the SDK:** `rebase.dataAsAdmin.<table>` in functions and crons, `getDriver(c)` to act as the caller.
11
11
  - **A route in `backend/functions/` is public until you guard it** with `requireAuth` or `requireAdmin` from `@rebasepro/server/functions`.
12
12
  - **Never deploy, never edit `.env`, never edit generated files** (`backend/src/schema.generated.ts`, `rebase.resources.json`).
13
13
  - **When Rebase cannot do what the task needs, tell the human** what is missing instead of working around it.
@@ -6,8 +6,8 @@ The Rebase skills for this assistant live in `.windsurf/rules/`. If they are not
6
6
 
7
7
  These hold before you have opened ai-instructions.md, and in every session:
8
8
 
9
- - **A table is a collection.** Declare it in `config/collections/<name>.ts` with `defineCollection`, and `pnpm dev` creates it. Never `CREATE TABLE`, `ALTER TABLE` or `CREATE INDEX` in code, and never SQL as the database owner against an application table: `rebase.sql()` skips row-level security, validation and callbacks, so keep it for server work that needs every row and for reading a column marked `excludeFromApi`. When the SDK cannot express a query, run it as the caller with `getSql(c)` — the same row-level security as the SDK, read-only unless `{ write: true }`, every value in `params`. A table that already exists gets its collection from `pnpm schema:introspect`.
10
- - **Data goes through the SDK:** `rebase.dataAsAdmin.<slug>` in functions and crons, `getDriver(c)` to act as the caller.
9
+ - **A table is a file in `backend/schema/`.** Declare it with `defineTable` from `@rebasepro/server/schema` — columns, relations and a required `rls` — export it from `backend/schema/index.ts`, and `pnpm dev` creates it. How it looks in the admin panel is a separate, optional file: `frontend/src/cms/<table>.tsx` with `customizeTable`, which imports the table as a type only. Never `CREATE TABLE`, `ALTER TABLE` or `CREATE INDEX` in code, and never SQL as the database owner against an application table: `rebase.sql()` skips row-level security, validation and hooks, so keep it for server work that needs every row and for reading a column marked `.private()`. When the SDK cannot express a query, run it as the caller with `getSql(c)` — the same row-level security as the SDK, read-only unless `{ write: true }`, every value in `params`. A table that already exists gets its file from `pnpm schema:introspect`. With no `backend/schema/` (a headless project) the database is the schema instead: ai-instructions.md says how to serve a table.
10
+ - **Data goes through the SDK:** `rebase.dataAsAdmin.<table>` in functions and crons, `getDriver(c)` to act as the caller.
11
11
  - **A route in `backend/functions/` is public until you guard it** with `requireAuth` or `requireAdmin` from `@rebasepro/server/functions`.
12
12
  - **Never deploy, never edit `.env`, never edit generated files** (`backend/src/schema.generated.ts`, `rebase.resources.json`).
13
13
  - **When Rebase cannot do what the task needs, tell the human** what is missing instead of working around it.
@@ -6,8 +6,8 @@ The Rebase skills for this assistant live in `.agents/skills/`. If they are not
6
6
 
7
7
  These hold before you have opened ai-instructions.md, and in every session:
8
8
 
9
- - **A table is a collection.** Declare it in `config/collections/<name>.ts` with `defineCollection`, and `pnpm dev` creates it. Never `CREATE TABLE`, `ALTER TABLE` or `CREATE INDEX` in code, and never SQL as the database owner against an application table: `rebase.sql()` skips row-level security, validation and callbacks, so keep it for server work that needs every row and for reading a column marked `excludeFromApi`. When the SDK cannot express a query, run it as the caller with `getSql(c)` — the same row-level security as the SDK, read-only unless `{ write: true }`, every value in `params`. A table that already exists gets its collection from `pnpm schema:introspect`.
10
- - **Data goes through the SDK:** `rebase.dataAsAdmin.<slug>` in functions and crons, `getDriver(c)` to act as the caller.
9
+ - **A table is a file in `backend/schema/`.** Declare it with `defineTable` from `@rebasepro/server/schema` — columns, relations and a required `rls` — export it from `backend/schema/index.ts`, and `pnpm dev` creates it. How it looks in the admin panel is a separate, optional file: `frontend/src/cms/<table>.tsx` with `customizeTable`, which imports the table as a type only. Never `CREATE TABLE`, `ALTER TABLE` or `CREATE INDEX` in code, and never SQL as the database owner against an application table: `rebase.sql()` skips row-level security, validation and hooks, so keep it for server work that needs every row and for reading a column marked `.private()`. When the SDK cannot express a query, run it as the caller with `getSql(c)` — the same row-level security as the SDK, read-only unless `{ write: true }`, every value in `params`. A table that already exists gets its file from `pnpm schema:introspect`. With no `backend/schema/` (a headless project) the database is the schema instead: ai-instructions.md says how to serve a table.
10
+ - **Data goes through the SDK:** `rebase.dataAsAdmin.<table>` in functions and crons, `getDriver(c)` to act as the caller.
11
11
  - **A route in `backend/functions/` is public until you guard it** with `requireAuth` or `requireAdmin` from `@rebasepro/server/functions`.
12
12
  - **Never deploy, never edit `.env`, never edit generated files** (`backend/src/schema.generated.ts`, `rebase.resources.json`).
13
13
  - **When Rebase cannot do what the task needs, tell the human** what is missing instead of working around it.
@@ -6,8 +6,8 @@ The Rebase skills for this assistant live in `.claude/skills/`. If they are not
6
6
 
7
7
  These hold before you have opened ai-instructions.md, and in every session:
8
8
 
9
- - **A table is a collection.** Declare it in `config/collections/<name>.ts` with `defineCollection`, and `pnpm dev` creates it. Never `CREATE TABLE`, `ALTER TABLE` or `CREATE INDEX` in code, and never SQL as the database owner against an application table: `rebase.sql()` skips row-level security, validation and callbacks, so keep it for server work that needs every row and for reading a column marked `excludeFromApi`. When the SDK cannot express a query, run it as the caller with `getSql(c)` — the same row-level security as the SDK, read-only unless `{ write: true }`, every value in `params`. A table that already exists gets its collection from `pnpm schema:introspect`.
10
- - **Data goes through the SDK:** `rebase.dataAsAdmin.<slug>` in functions and crons, `getDriver(c)` to act as the caller.
9
+ - **A table is a file in `backend/schema/`.** Declare it with `defineTable` from `@rebasepro/server/schema` — columns, relations and a required `rls` — export it from `backend/schema/index.ts`, and `pnpm dev` creates it. How it looks in the admin panel is a separate, optional file: `frontend/src/cms/<table>.tsx` with `customizeTable`, which imports the table as a type only. Never `CREATE TABLE`, `ALTER TABLE` or `CREATE INDEX` in code, and never SQL as the database owner against an application table: `rebase.sql()` skips row-level security, validation and hooks, so keep it for server work that needs every row and for reading a column marked `.private()`. When the SDK cannot express a query, run it as the caller with `getSql(c)` — the same row-level security as the SDK, read-only unless `{ write: true }`, every value in `params`. A table that already exists gets its file from `pnpm schema:introspect`. With no `backend/schema/` (a headless project) the database is the schema instead: ai-instructions.md says how to serve a table.
10
+ - **Data goes through the SDK:** `rebase.dataAsAdmin.<table>` in functions and crons, `getDriver(c)` to act as the caller.
11
11
  - **A route in `backend/functions/` is public until you guard it** with `requireAuth` or `requireAdmin` from `@rebasepro/server/functions`.
12
12
  - **Never deploy, never edit `.env`, never edit generated files** (`backend/src/schema.generated.ts`, `rebase.resources.json`).
13
13
  - **When Rebase cannot do what the task needs, tell the human** what is missing instead of working around it.
@@ -17,7 +17,7 @@ point for this project.
17
17
 
18
18
  That is the whole list. There is no database to install: with no `DATABASE_URL`
19
19
  set, `rebase dev` starts a managed PostgreSQL (PGlite) inside this project, and
20
- the runtime creates your collections' tables at boot.
20
+ the runtime creates your tables at boot.
21
21
 
22
22
  ### Run it
23
23
 
@@ -34,8 +34,8 @@ pnpm dev # or: npm run dev
34
34
  ```
35
35
 
36
36
  That is the whole first run. `rebase dev` generates the Drizzle schema and the
37
- SDK types from `config/collections`, starts the database, creates a table for
38
- every collection declared there, and serves the API and the admin panel.
37
+ SDK types from `backend/schema`, starts the database, creates every table
38
+ declared there, and serves the API and the admin panel.
39
39
 
40
40
  `rebase dev` prints the two URLs it actually bound. The first account you
41
41
  register becomes the admin. `REBASE_ADMIN_EMAIL` and `REBASE_ADMIN_PASSWORD` in
@@ -64,7 +64,7 @@ pnpm run db:push
64
64
 
65
65
  Boot already creates missing tables and columns, and their row-level security,
66
66
  additively, so `db push` is for what it deliberately leaves alone: any change
67
- that is not purely additive — a renamed column, a narrowed type, a removed field.
67
+ that is not purely additive — a renamed column, a narrowed type, a removed column.
68
68
 
69
69
  The `docker-compose.yml` in this project runs PostgreSQL in a container if you
70
70
  would rather not install one:
@@ -76,12 +76,14 @@ docker compose up -d db
76
76
  ## Project Structure
77
77
 
78
78
  ```
79
- ├── frontend/ # Your admin panel (React + Vite)
80
- ├── backend/ # Server code
79
+ ├── backend/ # The API — no admin-panel code in here
80
+ │ ├── schema/ # Your tables: defineTable(...), one per file, exported from index.ts
81
81
  │ ├── functions/ # Custom API endpoints (auto-discovered)
82
+ │ ├── resources.ts # Databases, buckets and topics this project needs
83
+ │ ├── storage.ts # Who may read and write files in storage
82
84
  │ └── src/ # Generated database schema
83
- ├── config/ # Shared collection definitions
84
- │ └── collections/ # Schema-as-Code TypeScript files
85
+ ├── frontend/ # Your admin panel (React + Vite)
86
+ │ └── src/cms/ # customizeTable(...): how a table looks in the admin panel
85
87
  ├── scripts/ # Scripts that call the API, e.g. example.ts
86
88
  ├── rebase.json # Which apps this repository contains
87
89
  ├── docker-compose.yml # Self-hosting stack (Postgres + the Rebase runtime)
@@ -91,11 +93,11 @@ docker compose up -d db
91
93
  ```
92
94
 
93
95
  Each workspace typechecks on its own, with its own `tsconfig.json`:
94
- `cd backend && npx tsc --noEmit`, and the same in `config/` and `frontend/`.
96
+ `cd backend && npx tsc --noEmit`, and the same in `frontend/`.
95
97
  `tsc --noEmit` at the root checks `scripts/`.
96
98
 
97
99
  There is no Dockerfile, and that is deliberate: `rebase build` produces a
98
- **bundle** — your compiled collections, functions, crons and admin assets — and
100
+ **bundle** — your compiled tables, functions, crons and admin assets — and
99
101
  the published `rebasepro/server` image boots it. The artifact you self-host is
100
102
  the artifact Rebase Cloud runs, so moving between them changes nothing in this
101
103
  repository.
@@ -138,9 +140,41 @@ caller simply gets `undefined` and the handler runs. Put `requireAuth` /
138
140
  `requireAdmin` in the route's own middleware slot rather than in `app.use()`,
139
141
  which only covers routes declared below it.
140
142
 
141
- ### Shared Collections
143
+ ### Tables and the admin panel
144
+
145
+ A table is declared once, in `backend/schema/<table>.ts`, with its columns,
146
+ relations and row-level security:
147
+
148
+ ```typescript
149
+ // backend/schema/tags.ts
150
+ import { defineTable, col } from "@rebasepro/server/schema";
151
+
152
+ export const tags = defineTable("tags", {
153
+ columns: {
154
+ id: col.integer().primaryKey().generatedByDefaultAsIdentity(),
155
+ name: col.text().notNull()
156
+ },
157
+ rls: "inherit" // the defaultRls exported from backend/schema/index.ts
158
+ });
159
+ ```
160
+
161
+ The admin panel lists every table the backend serves, with no code. To change
162
+ how one looks — labels, icons, enum colours, a custom field — add
163
+ `frontend/src/cms/<table>.tsx`, which imports the table as a type only, so no
164
+ server code reaches the browser:
165
+
166
+ ```tsx
167
+ // frontend/src/cms/tags.tsx
168
+ import { customizeTable } from "@rebasepro/cms";
169
+ import type { tags } from "../../../backend/schema/tags";
170
+
171
+ export const tagsCms = customizeTable<typeof tags>("tags", {
172
+ icon: "Tag",
173
+ fields: { name: { name: "Tag Name" } }
174
+ });
175
+ ```
142
176
 
143
- Collections are defined once in `config/collections/` and used by both the frontend and backend. This ensures your schema stays in sync across the stack.
177
+ and list it in `frontend/src/App.tsx`: `<RebaseCMS tableCustomizations={[tagsCms]} />`.
144
178
 
145
179
  ## Environment Configuration
146
180
 
@@ -168,7 +202,7 @@ compose database is a database of your own, so step 0 is the same one line.
168
202
  # 1. Build your project into ./dist-bundle
169
203
  pnpm run build # or: npm run build
170
204
 
171
- # 2. Start the database. Boot creates the tables from your collections;
205
+ # 2. Start the database. Boot creates the tables from backend/schema;
172
206
  # `db:push` is for what it leaves alone — any change that is not purely
173
207
  # additive.
174
208
  docker compose up -d db
@@ -1,39 +1,39 @@
1
1
  # Rebase AI Coding Rules
2
2
 
3
- `.mcp.json` in this directory wires the Rebase MCP server up already — no login, no token: it reads `.rebase/state.json` while `pnpm dev` is running. For the full skills (collections, auth, RLS, deployment, the UI kit), run `pnpm skills:install`, or `rebase skills install --agent <claude|cursor|windsurf|gemini|codex|kiro|copilot>` to pick one.
3
+ `.mcp.json` in this directory wires the Rebase MCP server up already — no login, no token: it reads `.rebase/state.json` while `pnpm dev` is running. For the full skills (tables, auth, RLS, deployment, the UI kit), run `pnpm skills:install`, or `rebase skills install --agent <claude|cursor|windsurf|gemini|codex|kiro|copilot>` to pick one.
4
4
 
5
5
  ## Commands
6
6
 
7
7
  | Command | What it does |
8
8
  |---|---|
9
9
  | `pnpm dev` | Backend, frontend and the managed development database, together |
10
- | `pnpm schema:generate` then `pnpm generate:sdk` | The same loop with `pnpm dev` not running: collections → Drizzle schema and SDK types. The next boot creates what is missing |
10
+ | `pnpm schema:generate` then `pnpm generate:sdk` | The same loop with `pnpm dev` not running: `backend/schema/` → Drizzle schema and SDK types. The next boot creates what is missing |
11
11
  | `pnpm db:push` | The changes boot leaves alone (a rename, a narrowed type, a removed field), on the managed development database as on your own PostgreSQL |
12
12
  | `pnpm db:generate` then `pnpm db:migrate` | The production path — write the migration file, then apply it |
13
- | `pnpm schema:introspect` | The other direction: existing tables → collection definitions |
14
- | `pnpm generate:sdk` | Regenerate the typed client in `generated/sdk/` from the collections. `pnpm dev` already does this on start and on every save; the script is for CI and for when `pnpm dev` is not running |
13
+ | `pnpm schema:introspect` | The other direction: existing tables → `defineTable(...)` files in `backend/schema/` |
14
+ | `pnpm generate:sdk` | Regenerate the typed client in `generated/sdk/` from `backend/schema/`. `pnpm dev` already does this on start and on every save; the script is for CI and for when `pnpm dev` is not running |
15
15
  | `pnpm build` then `pnpm start` | Build the deployable bundle, then run it |
16
16
  | `pnpm skills:install` | Install the Rebase skills for your assistant |
17
17
  | `pnpm example` | Run `scripts/example.ts` against the running backend: a health check, and an SDK call to uncomment |
18
- | `rebase doctor` | What disagrees between collections, generated schema and the live database — run this before guessing |
19
- | `rebase verify` | After every collection edit, and in CI: options that do not exist, UI options outside `admin`, missing `securityRules`, migrations behind the collections. `--json` names each file, path and fix. Claude Code runs it for you through `.claude/hooks/post-edit-collection.sh` |
20
- | `rebase resources --write` | After declaring a database, bucket or topic in `config/resources.ts`: regenerate `rebase.resources.json` and commit it (`pnpm build` does this too) |
18
+ | `rebase doctor` | What disagrees between `backend/schema/`, the generated schema and the live database — run this before guessing |
19
+ | `rebase verify` | After every schema edit, and in CI: a table the server would refuse, a `rls` that does not compile, migrations behind the tables. `--json` names each file, path and fix. Claude Code runs it for you after each edit under `backend/schema/` or `frontend/src/cms/`, through `.claude/hooks/post-edit-collection.sh` |
20
+ | `rebase resources --write` | After declaring a database, bucket or topic in `backend/resources.ts`: regenerate `rebase.resources.json` and commit it (`pnpm build` does this too) |
21
21
  | `pnpm deploy` | Deploys this project. Never run it; see below |
22
22
 
23
23
  ## Never
24
24
 
25
- - **Never create or change a table in code, and never write SQL as the database owner against application tables.** A table is a collection (core rule 1), and one that already exists gets its collection from `pnpm schema:introspect`. `rebase.sql()` runs as the owner — no row-level security, validation or hooks — so it is for server work that genuinely needs every row, and for reading a column marked `excludeFromApi`, which the API never returns; it logs a warning naming the fix when it is used to create, alter, drop or index a table. Prefer the SDK where it fits: `aggregate()` with `countDistinct`, `mode`, `percentile`, `distinct` and groups by `lower(…)`, `day(…)` or `unnest(tags)`; `fingerprint()` instead of hashing a table; `updateMany` with a value per row and `createMany` (one statement for the batch); `array-contains-all` / `array-contained-by` filters; a collection with `view: { query }` for a query worth naming. For anything else, write the SQL **as the caller**: `getSql(c)` in a function runs one statement in the caller's transaction under the same row-level security as the SDK, read-only unless `{ write: true }`. The query text is yours and every value goes in `params` (`$1`, `$2`, …) — never interpolate into the string. Columns the caller may not read (`excludeFromApi`, `access.read`) are dropped from what it returns when the query names them plainly, not when it computes from them; read hooks, validation and save hooks do not run.
25
+ - **Never create or change a table in code, and never write SQL as the database owner against application tables.** A table is a file in `backend/schema/` (core rule 1), and one that already exists gets its file from `pnpm schema:introspect`. `rebase.sql()` runs as the owner — no row-level security, validation or hooks — so it is for server work that genuinely needs every row, and for reading a column marked `.private()`, which the API never returns; it logs a warning naming the fix when it is used to create, alter, drop or index a table. Prefer the SDK where it fits: `aggregate()` with `countDistinct`, `mode`, `percentile`, `distinct` and groups by `lower(…)`, `day(…)` or `unnest(tags)`; `fingerprint()` instead of hashing a table; `updateMany` with a value per row and `createMany` (one statement for the batch); `array-contains-all` / `array-contained-by` filters; a `defineView(...)` in `backend/schema/` for a query worth naming. For anything else, write the SQL **as the caller**: `getSql(c)` in a function runs one statement in the caller's transaction under the same row-level security as the SDK, read-only unless `{ write: true }`. The query text is yours and every value goes in `params` (`$1`, `$2`, …) — never interpolate into the string. Columns the caller may not read (`.private()`, `.access({ read })`) are dropped from what it returns when the query names them plainly, not when it computes from them; read hooks, validation and save hooks do not run.
26
26
  - **Never deploy.** `pnpm deploy`, `rebase cloud deploy`, `firebase deploy`, `gcloud run deploy` — print the command and let the human run it, even when the task list ends in "deploy" and the tests are green.
27
27
  - **Never edit `.env`.** It holds generated secrets and the connection string. Add a variable by asking, and document it in `.env.example`.
28
- - **Never edit `backend/src/schema.generated.ts`.** It is overwritten by `pnpm schema:generate`; the collection file is the source.
29
- - **Never edit `rebase.resources.json`.** It is generated from `config/resources.ts` — declare there, then `rebase resources --write`.
28
+ - **Never edit `backend/src/schema.generated.ts`.** It is overwritten by `pnpm schema:generate`; `backend/schema/` is the source.
29
+ - **Never edit `rebase.resources.json`.** It is generated from `backend/resources.ts` — declare there, then `rebase resources --write`.
30
30
  - **Never pass `--allow-destructive`** to anything pointed at a database that is not the local development one. It drops columns and tables.
31
31
 
32
32
  ## Core rules
33
33
 
34
- 1. **Schema-as-code**: define and edit collections in `config/collections/` with `defineCollection` from `@rebasepro/cms-types`, one collection per file, default-exported. Every file in that directory is loaded — by the backend, the admin panel and the SDK generator — whether or not `index.ts` lists it: the barrel is a sort order for the admin navigation (and holds `defaultSecurityRules`), not a registry. To remove a collection, delete its file and its import and entry in `index.ts`. Never hand-edit generated schemas or Postgres tables.
35
- 2. **Applying a collection change**: while `pnpm dev` is running, saving a file in `config/collections/` is the whole step — it regenerates `backend/src/schema.generated.ts` and the SDK types in `generated/sdk/`, restarts the backend, and boot creates the tables and columns that are missing. With `pnpm dev` stopped, that is `pnpm schema:generate` and `pnpm generate:sdk`. `pnpm db:push` is only for what boot deliberately leaves alone — a renamed column, a narrowed type, a removed field — on the managed development database as on your own PostgreSQL. In production the pair is `pnpm db:generate` then `pnpm db:migrate`.
36
- 3. **Use the SDK**: server-side that is `rebase.dataAsAdmin.<slug>` for work done as the service identity, or `getDriver(c)` inside a function when the read should run as the caller. The server client has no plain `data` accessor — it is omitted precisely so that the choice of identity is written down.
34
+ 1. **Schema-as-code**: a table is `backend/schema/<table>.ts` — `export const posts = defineTable("posts", { columns, relations, rls })` with `col.*` and `rel.*` from `@rebasepro/server/schema` — exported from `backend/schema/index.ts`. Only what `index.ts` exports is served; a `defineTable` it does not export is an error. `rls` is required on every table: a list of rules, `"admin-only"`, or `"inherit"` for the `defaultRls` that `index.ts` exports. Columns are nullable until `.notNull()`. A foreign key is a `rel.belongsTo(() => other)` beside its column. To remove a table, delete its file and its export. Never hand-edit generated schemas or Postgres tables.
35
+ 2. **Applying a schema change**: while `pnpm dev` is running, saving a file in `backend/schema/` is the whole step — it regenerates `backend/src/schema.generated.ts` and the SDK types in `generated/sdk/`, restarts the backend, and boot creates the tables and columns that are missing. With `pnpm dev` stopped, that is `pnpm schema:generate` and `pnpm generate:sdk`. `pnpm db:push` is only for what boot deliberately leaves alone — a renamed column, a narrowed type, a removed column — on the managed development database as on your own PostgreSQL. In production the pair is `pnpm db:generate` then `pnpm db:migrate`.
36
+ 3. **Use the SDK**: server-side that is `rebase.dataAsAdmin.<table>` for work done as the service identity, or `getDriver(c)` inside a function when the read should run as the caller. The server client has no plain `data` accessor — it is omitted precisely so that the choice of identity is written down.
37
37
  4. **Guard every custom route**: routes in `backend/functions/` are mounted **without** an auth requirement — webhook receivers need that — so each one is public until you guard it. Import `requireAuth` / `requireAdmin` from `@rebasepro/server/functions` and pass them in the route's own middleware slot (`app.post("/", requireAuth, handler)`), not via `app.use()`, which only covers routes declared below it. Reading `getUser(c)` is not a guard: an anonymous caller gets `undefined` and the handler still runs. See `backend/functions/hello.ts` for all three tiers.
38
38
  5. **In `backend/functions/`, always import from `@rebasepro/server/functions`** — never from `@rebasepro/server`. Both work today; the subpath is the portable one, and it also gives you the typed context accessors (`getUser`, `getDriver`, `requireDriver`) instead of casting `c.get("user")`. The package root is for a server entrypoint, not for route handlers.
39
39
  6. **Never read `process.env` at the top of a function file.** A module-scope read that comes back undefined throws at import time, and the loader reports that as a *skipped function* — the route simply 404s with no error attached to it. Read configuration inside the handler with `requireEnv(c, "NAME")`, or build a client once with `lazyResource(env => new Client(env.KEY))`.
@@ -58,4 +58,5 @@
58
58
  These rules apply to views inside the Rebase admin panel: custom views, home pages, dashboards and entity tabs. A public site or a static app this project serves (an `apps` entry with `"type": "static"`) is not the admin panel. Style it the way that app is already styled. It does not need `@rebasepro/ui`.
59
59
 
60
60
  - **Build admin UI from the kit, never from scratch**: every one of those views is composed from `@rebasepro/ui` components (`Card`, `Typography`, `Button`, `Chip`, `Alert`, …) and the theme's tokens. Backgrounds and borders take a surface by role — `bg-surface-frame`, `bg-surface-sheet`, `bg-surface-card`, `bg-surface-raised`, `bg-surface-field`, `bg-surface-well`, `border-hairline` — and those switch with the theme on their own, so they need no `dark:` pair; text takes `<Typography>` or `text-text-primary dark:text-text-primary-dark`. Do **not** invent a palette, a type scale, or hand-written CSS: a hardcoded colour like `#111` is invisible in one of the two themes and nothing will catch it. The roles and their reasoning are in `@rebasepro/ui/theme.css` in your `node_modules`; the live reference is `import { UIReferenceView } from "@rebasepro/app/debug"` — mount it on a route and look before building a view. See [Styling Custom UI](https://rebase.pro/docs/frontend/styling).
61
- - **Set `admin.span` on every property you write, from what it holds.** The admin form puts every field at full width unless the property says otherwise, pairing only two neighbouring fields with the same small editor (two numbers, two switches, two dates, two short selects); it never pairs free text and never looks at the title. Pair two short values that belong together (`2` + `2`: start / end date, provider / region; `1` for numbers, booleans and short codes beside their siblings), keep anything that reads long at `4` (names, URLs, emails, ids, descriptions, markdown, files), make each row add up to 4, and declare pairs next to each other. See the `rebase-collections` skill, "Form layout".
61
+ - **The admin panel shows every table with no code; `frontend/src/cms/<table>.tsx` changes how one looks.** `export const postsCms = customizeTable<typeof posts>("posts", { icon, fields: { … } })` from `@rebasepro/cms`, with `import type { posts } from "../../../backend/schema/posts"` — a type import only: a value import from `backend/` would put server code in the browser bundle, and `check:templates` refuses it. List it in `App.tsx`: `<RebaseCMS tableCustomizations={[postsCms]} />`. Labels, enum colours, icons, markdown and custom `Field` components live there, never in `backend/schema/`.
62
+ - **Set `span` on every field you customize, from what it holds.** The admin form puts every field at full width unless the property says otherwise, pairing only two neighbouring fields with the same small editor (two numbers, two switches, two dates, two short selects); it never pairs free text and never looks at the title. Pair two short values that belong together (`2` + `2`: start / end date, provider / region; `1` for numbers, booleans and short codes beside their siblings), keep anything that reads long at `4` (names, URLs, emails, ids, descriptions, markdown, files), make each row add up to 4, and declare pairs next to each other. It goes in `fields: { <column>: { span } }` of the table's `customizeTable`.
@@ -51,7 +51,7 @@ import {
51
51
  * `functions:invoke` scope (or `functions:invoke:hello`), it passes
52
52
  * `requireAuth`, and a service key created with `--roles admin` passes
53
53
  * `requireAdmin`. To let a key do one thing here and not another, declare a
54
- * scope under `auth.scopes` on the users collection and add
54
+ * scope under `auth.scopes` on the users table (`backend/schema/users.ts`) and add
55
55
  * `requireScope("reports:read")` to that route — every signed-in person holds
56
56
  * every app scope, so it narrows keys, not people.
57
57
  *
@@ -8,8 +8,6 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@ariga/atlas": "^1.2.3",
11
- "{{PROJECT_NAME}}-config": "*",
12
- "@rebasepro/cms-types": "workspace:*",
13
11
  "@rebasepro/server": "workspace:*",
14
12
  "@rebasepro/server-postgres": "workspace:*",
15
13
  "@rebasepro/types": "workspace:*",
@@ -43,7 +43,7 @@ export const main = database();
43
43
  * export const files = bucket({ engine: "s3" });
44
44
  * export const media = bucket("media", { engine: "s3" });
45
45
  *
46
- * An upload whose property names no `storageSource` goes to the default
46
+ * An upload whose column names no `source` goes to the default
47
47
  * bucket, which keeps its own variables — `STORAGE_PATH` (else `./uploads`),
48
48
  * `S3_BUCKET` / `GCS_BUCKET` — whatever you declare here, so adding
49
49
  * `bucket("media")` never moves the files already there. To send those
@@ -51,10 +51,10 @@ export const main = database();
51
51
  * `bucket("media", { engine: "s3", default: true })`. Two buckets may not
52
52
  * share a directory or a bucket; boot refuses if they would.
53
53
  *
54
- * Point a property at it by handle — the same name, spelled once:
54
+ * Point a column at it by handle — the same name, spelled once:
55
55
  *
56
56
  * import { media } from "../resources";
57
- * cover: { type: "string", storage: { storageSource: media } }
57
+ * cover: col.storage({ source: media, path: "covers/" })
58
58
  *
59
59
  * ## When you have several on one provider
60
60
  *
@@ -0,0 +1,11 @@
1
+ import { defineTable, col } from "@rebasepro/server/schema";
2
+
3
+ export const authors = defineTable("authors", {
4
+ columns: {
5
+ id: col.integer().primaryKey().generatedByDefaultAsIdentity(),
6
+ name: col.text().notNull(),
7
+ email: col.text().notNull(),
8
+ picture: col.storage({ path: "author_pictures/" })
9
+ },
10
+ rls: "inherit"
11
+ });
@@ -0,0 +1,29 @@
1
+ import type { DefaultRls } from "@rebasepro/server/schema";
2
+
3
+ /**
4
+ * Every table this backend serves. A `defineTable` that is not exported from
5
+ * here is refused at boot and by `rebase db generate`.
6
+ */
7
+ export { posts } from "./posts";
8
+ export { authors } from "./authors";
9
+ export { tags } from "./tags";
10
+ export { users } from "./users";
11
+
12
+ /**
13
+ * What a table with `rls: "inherit"` gets: every caller reads every row, only
14
+ * admins write.
15
+ *
16
+ * `access: "public"` is about ROWS, not about who may call the API — it means
17
+ * "no row filter", not "no login". A request with no token is still answered
18
+ * 401 by the API before row-level security is ever consulted. To serve readers
19
+ * who are not signed in (a public website reading this backend), set
20
+ * `AUTH_REQUIRE=false` in the backend's environment; access then rests entirely
21
+ * on these rules, which is what they are for.
22
+ *
23
+ * These live beside the tables because `rebase db push` and boot generate the
24
+ * Postgres policies from them — that is what actually enforces access.
25
+ */
26
+ export const defaultRls: DefaultRls = [
27
+ { operation: "select", access: "public" },
28
+ { operations: ["insert", "update", "delete"], roles: ["admin"] }
29
+ ];
@@ -0,0 +1,29 @@
1
+ import { defineTable, col, rel } from "@rebasepro/server/schema";
2
+ import { authors } from "./authors";
3
+ import { tags } from "./tags";
4
+
5
+ export const posts = defineTable("posts", {
6
+ columns: {
7
+ id: col.integer().primaryKey().generatedByDefaultAsIdentity(),
8
+ title: col.text().notNull(),
9
+ content: col.text(),
10
+ status: col.enum(["draft", "review", "published"]),
11
+ authorId: col.integer()
12
+ },
13
+ relations: {
14
+ // Binds to `authorId` (SQL `author_id`), the column declared above.
15
+ author: rel.belongsTo(() => authors),
16
+ // Creates the `posts_tags` junction table, with its own policies.
17
+ tags: rel.manyToMany(() => tags)
18
+ },
19
+ // A post is readable once it is published, not before. With `"inherit"` it
20
+ // would take `defaultRls` from index.ts, and every reader would see drafts —
21
+ // anonymous ones too, once AUTH_REQUIRE=false serves a public site from this
22
+ // backend.
23
+ rls: [
24
+ { operation: "select", using: "{status} = 'published'" },
25
+ // Editors read drafts and posts in review; admins already read everything.
26
+ { operation: "select", roles: ["editor"] },
27
+ { operations: ["insert", "update", "delete"], roles: ["admin"] }
28
+ ]
29
+ });
@@ -0,0 +1,9 @@
1
+ import { defineTable, col } from "@rebasepro/server/schema";
2
+
3
+ export const tags = defineTable("tags", {
4
+ columns: {
5
+ id: col.integer().primaryKey().generatedByDefaultAsIdentity(),
6
+ name: col.text().notNull()
7
+ },
8
+ rls: "inherit"
9
+ });
@@ -0,0 +1,32 @@
1
+ import { defineAuthTable, col, json } from "@rebasepro/server/schema";
2
+
3
+ /**
4
+ * The accounts table: sign-up, sign-in and password reset write here, and every
5
+ * other table's policies read the caller from it. `defineAuthTable` adds what an
6
+ * auth table needs on top of these rules — a user reads their own row, and only
7
+ * an admin may change `roles`.
8
+ *
9
+ * `roles` lists the roles this project knows. `backend/storage.ts` and the
10
+ * policies in the other tables name them; add yours here first.
11
+ */
12
+ export const users = defineAuthTable("users", {
13
+ schema: "rebase",
14
+ columns: {
15
+ id: col.uuid().primaryKey().defaultRandom(),
16
+ email: col.text().notNull().unique(),
17
+ displayName: col.text(),
18
+ photoURL: col.text().validate({ url: true }),
19
+ roles: col.text({ enum: ["admin", "editor", "viewer"] }).array(),
20
+ passwordHash: col.text().private(),
21
+ emailVerified: col.boolean().default(false),
22
+ emailVerificationToken: col.text().private(),
23
+ emailVerificationSentAt: col.timestamp({ withTimezone: true }),
24
+ metadata: col.jsonb(json.object({}, { additional: true })).default({}),
25
+ createdAt: col.timestamp({ withTimezone: true }).onCreateNow(),
26
+ updatedAt: col.timestamp({ withTimezone: true }).onUpdateNow()
27
+ },
28
+ rls: [
29
+ { operation: "select", roles: ["admin"] },
30
+ { operations: ["insert", "update", "delete"], roles: ["admin"] }
31
+ ]
32
+ });
@@ -3,7 +3,7 @@ import type { StorageAuthorize } from "@rebasepro/types";
3
3
  /**
4
4
  * Who may do what to files in storage.
5
5
  *
6
- * Storage is **not** under row-level security. Collections are: a request runs as
6
+ * Storage is **not** under row-level security. Tables are: a request runs as
7
7
  * `rebase_user` and Postgres decides row by row. Object storage has no equivalent,
8
8
  * so keys share one flat namespace and this hook is the whole authorization model.
9
9
  * Without it the server refuses to boot in production, because "authenticated"
@@ -14,7 +14,7 @@ import type { StorageAuthorize } from "@rebasepro/types";
14
14
  * ## The model this starter ships
15
15
  *
16
16
  * A CMS's files are **shared content**, not private per-user documents: hero
17
- * images, author pictures, product photos. The collections in this template upload
17
+ * images, author pictures, product photos. The tables in this template upload
18
18
  * to `author_pictures/`, `posts/hero/`, `product_images/` — paths named after the
19
19
  * content, not after a user. So the boundary that matters here is not *whose file
20
20
  * is this* but *who is allowed to change the library*:
@@ -45,7 +45,7 @@ import type { StorageAuthorize } from "@rebasepro/types";
45
45
  * if (operation === "list") return key.startsWith(`users/${user.uid}/`);
46
46
  *
47
47
  * // Reads and deletes check the row that owns the object.
48
- * const attachment = (await data?.collection("attachments").find({
48
+ * const attachment = (await data?.table("attachments").find({
49
49
  * where: { storage_key: ["==", key] }, limit: 1
50
50
  * }))?.data?.[0];
51
51
  * return attachment?.owner_id === user.uid;
@@ -85,7 +85,7 @@ export const storageAuthorize: StorageAuthorize = ({ key, user, operation }) =>
85
85
  }
86
86
 
87
87
  // Changing or enumerating the library is an editor's job. Matches the roles in
88
- // `collections/users.ts` — widen this if you add your own.
88
+ // `schema/users.ts` — widen this if you add your own.
89
89
  const roles = user.roles ?? [];
90
90
  return roles.includes("admin") || roles.includes("editor");
91
91
  };
@@ -5,12 +5,10 @@
5
5
  "moduleResolution": "bundler",
6
6
  "lib": ["ES2022"],
7
7
  "outDir": "./dist",
8
- // The program includes `../config/**`, so tsc's common source directory is
9
- // the project root and the emit already lands at `dist/backend/src/…` —
10
- // which is what `scripts.start` runs. Saying so explicitly is required from
11
- // TypeScript 6, which refuses to infer it (TS5011), and changes nothing
12
- // about the layout.
13
- "rootDir": "..",
8
+ // Everything this program compiles lives under backend/, so the emit
9
+ // mirrors it: `dist/schema/…`, `dist/functions/…`, `dist/src/…`. Saying so
10
+ // is required from TypeScript 6, which refuses to infer it (TS5011).
11
+ "rootDir": ".",
14
12
  "strict": true,
15
13
  "esModuleInterop": true,
16
14
  "allowSyntheticDefaultImports": true,
@@ -36,20 +34,17 @@
36
34
  // and the faster compile.
37
35
  "types": ["node"]
38
36
  },
39
- // `functions/` is included so `tsc` actually checks your custom routes. It
40
- // was omitted here (the baas flavour has always had it), which meant the one
41
- // place you write server code by hand was the one place a type error went
42
- // unnoticed until runtime. The inferred common root is already the project
43
- // root because of `../config`, so this adds no `rootDir` and moves nothing
44
- // that dist/ already contains.
45
- //
46
- // `crons/` for the same reason, and for one more: `rebase build` compiles it
47
- // through a generated tsconfig, but an ejected project builds with *this*
48
- // file — so leaving crons out meant an ejected server had no compiled jobs to
49
- // load and stopped running every schedule, nightly backups included.
37
+ // Every directory you write server code in, so `tsc` checks all of it:
50
38
  //
39
+ // `schema/` holds the tables, and `resources.ts` / `storage.ts` what the
40
+ // runtime reads beside them. `functions/` are your routes — the one place
41
+ // you write server code by hand, so the one place a type error must not wait
42
+ // until runtime. `crons/`: `rebase build` compiles it through a generated
43
+ // tsconfig, but an ejected project builds with *this* file, so leaving it out
44
+ // meant an ejected server had no compiled jobs and stopped every schedule.
51
45
  // `scripts/` because that is where the Scripts page puts a script that opens
52
- // the project with `openRebase`: typed by the same `Database` as a function,
53
- // which only holds if `tsc` reads it.
54
- "include": ["src/**/*", "functions/**/*", "crons/**/*", "scripts/**/*", "../config/**/*", "drizzle.config.ts"]
46
+ // the project with `openRebase`, typed by the same `Database` as a function.
47
+ // `generated/` holds `register.ts`, which `rebase generate-sdk --register`
48
+ // writes so `Database` is the generated one everywhere this program compiles.
49
+ "include": ["src/**/*", "schema/**/*", "functions/**/*", "crons/**/*", "scripts/**/*", "generated/**/*", "resources.ts", "storage.ts", "hooks.ts"]
55
50
  }
@@ -132,13 +132,13 @@ services:
132
132
  DISABLE_SELF_REGISTRATION: ${DISABLE_SELF_REGISTRATION:-true}
133
133
 
134
134
  # `ensure` (the default) creates missing tables and columns at boot —
135
- # your collections' as well as auth's — with their row-level security,
135
+ # yours, from backend/schema, as well as auth's — with their row-level security,
136
136
  # and is additive only: nothing is dropped, narrowed or rewritten,
137
137
  # because that must never happen as a side effect of a container restart.
138
138
  #
139
139
  # `rebase db push` is still what applies the rest: any change that is not
140
140
  # purely additive.
141
- # Set this to `none` to leave your collections' schema alone; auth's
141
+ # Set this to `none` to leave your tables' schema alone; auth's
142
142
  # tables are still kept current. REBASE_PROVISION=false changes nothing
143
143
  # in the database at all.
144
144
  REBASE_MIGRATE_ON_BOOT: ${REBASE_MIGRATE_ON_BOOT:-ensure}
@@ -152,7 +152,7 @@ services:
152
152
  # if you move storage off-box.
153
153
  #
154
154
  # The volume is mounted at /storage, one level above STORAGE_PATH, because
155
- # every bucket you declare in config/resources.ts gets a directory beside
155
+ # every bucket you declare in backend/resources.ts gets a directory beside
156
156
  # this one: bucket("media") is /storage/uploads__media. Mounted at
157
157
  # /storage/uploads itself, the volume would hold the default bucket only,
158
158
  # and every other bucket's files would go with the container.
@@ -7,12 +7,10 @@
7
7
  "@rebasepro/app": "workspace:*",
8
8
  "@rebasepro/client": "workspace:*",
9
9
  "@rebasepro/cms": "workspace:*",
10
- "@rebasepro/cms-types": "workspace:*",
11
10
  "@rebasepro/studio": "workspace:*",
12
11
  "@rebasepro/types": "workspace:*",
13
12
  "@rebasepro/ui": "workspace:*",
14
13
  "@fontsource/jetbrains-mono": "^5.2.5",
15
- "{{PROJECT_NAME}}-config": "*",
16
14
  "react": "^19.0.0",
17
15
  "react-dom": "^19.0.0",
18
16
  "react-router": "^8.3.0",