@rebasepro/cli 0.30.1 → 0.31.0-canary.g902a0ce
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/{agent-setup-0uyfC7VX.js → agent-setup-DqAcoDcn.js} +10 -5
- package/dist/{agent-setup-0uyfC7VX.js.map → agent-setup-DqAcoDcn.js.map} +1 -1
- package/dist/{api-keys-Dfw5-9s1.js → api-keys-eIUjMqWn.js} +8 -7
- package/dist/api-keys-eIUjMqWn.js.map +1 -0
- package/dist/{apps-MKQbgDtN.js → apps-DExO4PEl.js} +8 -7
- package/dist/apps-DExO4PEl.js.map +1 -0
- package/dist/{project-CasK56vN.js → args-CaCcrYE1.js} +2 -351
- package/dist/args-CaCcrYE1.js.map +1 -0
- package/dist/{atlas-dev-database-BODqdCWt.js → atlas-dev-database-DOCKk6ht.js} +2 -2
- package/dist/{atlas-dev-database-BODqdCWt.js.map → atlas-dev-database-DOCKk6ht.js.map} +1 -1
- package/dist/{auth-Bv0rTbQX.js → auth-CyADghFQ.js} +7 -6
- package/dist/{auth-Bv0rTbQX.js.map → auth-CyADghFQ.js.map} +1 -1
- package/dist/backend-guard-C0mVkXBw.js +162 -0
- package/dist/backend-guard-C0mVkXBw.js.map +1 -0
- package/dist/{branch-pointer-BQUF6lYa.js → branch-pointer-DMPyvZoK.js} +1 -1
- package/dist/{build-BuKTnec8.js → build-CA5R07tw.js} +29 -9
- package/dist/build-CA5R07tw.js.map +1 -0
- package/dist/{bundle-BAH4FCju.js → bundle-DgILeA5b.js} +112 -138
- package/dist/bundle-DgILeA5b.js.map +1 -0
- package/dist/bundle.d.ts +35 -12
- package/dist/cli.d.ts +2 -2
- package/dist/{cloud-DtADfWwn.js → cloud-CYMk92iG.js} +72 -71
- package/dist/cloud-CYMk92iG.js.map +1 -0
- package/dist/cms-directories-BK3vcswg.js +33 -0
- package/dist/cms-directories-BK3vcswg.js.map +1 -0
- package/dist/codemod/collections-to-tables/ast.d.ts +135 -0
- package/dist/codemod/collections-to-tables/backend.d.ts +38 -0
- package/dist/codemod/collections-to-tables/command.d.ts +35 -0
- package/dist/codemod/collections-to-tables/comments.d.ts +45 -0
- package/dist/codemod/collections-to-tables/customization.d.ts +47 -0
- package/dist/codemod/collections-to-tables/dynamic-props.d.ts +34 -0
- package/dist/codemod/collections-to-tables/export-changes.d.ts +83 -0
- package/dist/codemod/collections-to-tables/firestore.d.ts +11 -0
- package/dist/codemod/collections-to-tables/helper-hooks.d.ts +41 -0
- package/dist/codemod/collections-to-tables/hooks.d.ts +44 -0
- package/dist/codemod/collections-to-tables/journal.d.ts +10 -0
- package/dist/codemod/collections-to-tables/legacy-shims.d.ts +52 -0
- package/dist/codemod/collections-to-tables/load-legacy.d.ts +81 -0
- package/dist/codemod/collections-to-tables/migrate.d.ts +20 -0
- package/dist/codemod/collections-to-tables/modules.d.ts +127 -0
- package/dist/codemod/collections-to-tables/moved-imports.d.ts +70 -0
- package/dist/codemod/collections-to-tables/moved-symbols.generated.d.ts +12 -0
- package/dist/codemod/collections-to-tables/own.d.ts +10 -0
- package/dist/codemod/collections-to-tables/path-aliases.d.ts +26 -0
- package/dist/codemod/collections-to-tables/plan-context.d.ts +49 -0
- package/dist/codemod/collections-to-tables/print-js.d.ts +44 -0
- package/dist/codemod/collections-to-tables/project-files.d.ts +144 -0
- package/dist/codemod/collections-to-tables/repoint.d.ts +50 -0
- package/dist/codemod/collections-to-tables/row-hands.d.ts +7 -0
- package/dist/codemod/collections-to-tables/sdk-calls.d.ts +88 -0
- package/dist/codemod/collections-to-tables/skills-step.d.ts +13 -0
- package/dist/codemod/collections-to-tables/split-constants.d.ts +42 -0
- package/dist/codemod/collections-to-tables/storage-paths.d.ts +28 -0
- package/dist/codemod/collections-to-tables/types.d.ts +164 -0
- package/dist/codemod/collections-to-tables/verify.d.ts +27 -0
- package/dist/codemod/collections-to-tables/vocabulary.d.ts +40 -0
- package/dist/command-D5lhW_-B.js +9984 -0
- package/dist/command-D5lhW_-B.js.map +1 -0
- package/dist/commands/agent-setup.d.ts +6 -2
- package/dist/commands/cloud/context.d.ts +1 -1
- package/dist/commands/cloud/init.d.ts +2 -2
- package/dist/commands/console.d.ts +1 -2
- package/dist/commands/db.d.ts +5 -6
- package/dist/commands/dev.d.ts +18 -17
- package/dist/commands/doctor.d.ts +4 -5
- package/dist/commands/eject.d.ts +17 -13
- package/dist/commands/generate-view.d.ts +20 -9
- package/dist/commands/generate_sdk.d.ts +27 -27
- package/dist/commands/init.d.ts +21 -8
- package/dist/commands/migrate.d.ts +24 -0
- package/dist/commands/schema-reconcile.d.ts +1 -1
- package/dist/commands/skills.d.ts +8 -0
- package/dist/commands/verify-cms.d.ts +28 -0
- package/dist/commands/verify.d.ts +14 -9
- package/dist/{consent-BD7F29T3.js → consent-BXLIrMl8.js} +2 -2
- package/dist/{consent-BD7F29T3.js.map → consent-BXLIrMl8.js.map} +1 -1
- package/dist/{console-CdwIYOMV.js → console-CMjhgMUE.js} +14 -14
- package/dist/console-CMjhgMUE.js.map +1 -0
- package/dist/{context-AXdAh-q8.js → context--JwaHaZp.js} +6 -5
- package/dist/context--JwaHaZp.js.map +1 -0
- package/dist/{daemon-Cp7oNXth.js → daemon-w30PsdwV.js} +2 -2
- package/dist/{daemon-Cp7oNXth.js.map → daemon-w30PsdwV.js.map} +1 -1
- package/dist/{db-DBbKpjYX.js → db-A7XDCIIO.js} +51 -51
- package/dist/db-A7XDCIIO.js.map +1 -0
- package/dist/{derive-ae9UOoOB.js → derive-C3ezmY-p.js} +105 -133
- package/dist/derive-C3ezmY-p.js.map +1 -0
- package/dist/dev-db/attver.d.ts +11 -0
- package/dist/{dev-preflight-Cxv3TiD1.js → dev-preflight-DjvcV6SK.js} +5 -5
- package/dist/dev-preflight-DjvcV6SK.js.map +1 -0
- package/dist/{dev-server-OJsUGZEB.js → dev-server-BLxCbQEP.js} +2 -2
- package/dist/{dev-server-OJsUGZEB.js.map → dev-server-BLxCbQEP.js.map} +1 -1
- package/dist/{dev-C93d4QIv.js → dev-tWwPyWkQ.js} +142 -84
- package/dist/dev-tWwPyWkQ.js.map +1 -0
- package/dist/{doctor-BBPQUO2g.js → doctor-BBM0dWvZ.js} +39 -62
- package/dist/doctor-BBM0dWvZ.js.map +1 -0
- package/dist/doctor-environment.d.ts +6 -6
- package/dist/{eject-DABcDnPN.js → eject-Bhzd6hgb.js} +25 -16
- package/dist/eject-Bhzd6hgb.js.map +1 -0
- package/dist/{fold-static-BWzxNn06.js → fold-static-CKewnAPX.js} +5 -3
- package/dist/fold-static-CKewnAPX.js.map +1 -0
- package/dist/{generate-view-IFwCADvb.js → generate-view-CTOluXvH.js} +160 -89
- package/dist/generate-view-CTOluXvH.js.map +1 -0
- package/dist/{generate_sdk-DNmNuFuW.js → generate_sdk-De-aLC1L.js} +120 -137
- package/dist/generate_sdk-De-aLC1L.js.map +1 -0
- package/dist/import-schema-module-Df67TIWj.js +51 -0
- package/dist/import-schema-module-Df67TIWj.js.map +1 -0
- package/dist/index.es.js +64 -51
- package/dist/index.es.js.map +1 -1
- package/dist/{init-vL1DWOeC.js → init-Dtl-IcXf.js} +83 -80
- package/dist/init-Dtl-IcXf.js.map +1 -0
- package/dist/last-dev-database-Dc8cP01o.js +2 -0
- package/dist/{manifest-BtzDy7KQ.js → manifest-C3uLDrrJ.js} +115 -40
- package/dist/manifest-C3uLDrrJ.js.map +1 -0
- package/dist/manifest.d.ts +79 -24
- package/dist/migrate-VrKoi3nB.js +138 -0
- package/dist/migrate-VrKoi3nB.js.map +1 -0
- package/dist/{normalize-imports-Bd5Y4yLp.js → normalize-imports-DwxqEMYq.js} +3 -3
- package/dist/{normalize-imports-Bd5Y4yLp.js.map → normalize-imports-DwxqEMYq.js.map} +1 -1
- package/dist/path-flags-7O5uPBcQ.js +139 -0
- package/dist/path-flags-7O5uPBcQ.js.map +1 -0
- package/dist/{prepare-CTw9NEkh.js → prepare-Ccxspoj-.js} +4 -4
- package/dist/{prepare-CTw9NEkh.js.map → prepare-Ccxspoj-.js.map} +1 -1
- package/dist/project-CLcF5i8c.js +360 -0
- package/dist/project-CLcF5i8c.js.map +1 -0
- package/dist/project-schema-CsSOG2gE.js +30 -0
- package/dist/project-schema-CsSOG2gE.js.map +1 -0
- package/dist/{pull-DDMpsZ5r.js → pull-D9WvpDYY.js} +189 -1
- package/dist/pull-D9WvpDYY.js.map +1 -0
- package/dist/resolve-BY7bSFRT.js +2 -0
- package/dist/resources/derive.d.ts +19 -13
- package/dist/{resources-CPSC5Kcu.js → resources-Dpfs2y8P.js} +5 -4
- package/dist/{resources-CPSC5Kcu.js.map → resources-Dpfs2y8P.js.map} +1 -1
- package/dist/{schema-DtLPsXbT.js → schema-DwFDI1iU.js} +41 -39
- package/dist/schema-DwFDI1iU.js.map +1 -0
- package/dist/schema-dir-Cd1kvYbf.js +98 -0
- package/dist/schema-dir-Cd1kvYbf.js.map +1 -0
- package/dist/schema-reconcile-Tto54Qbv.js +2 -0
- package/dist/schema-text-CpNrsuMe.js +73 -0
- package/dist/schema-text-CpNrsuMe.js.map +1 -0
- package/dist/{skills-CbwV6vw_.js → skills-CXjA9TWw.js} +54 -10
- package/dist/skills-CXjA9TWw.js.map +1 -0
- package/dist/{start-YOr3X5Zm.js → start-Bwbtt2W5.js} +7 -10
- package/dist/{start-YOr3X5Zm.js.map → start-Bwbtt2W5.js.map} +1 -1
- package/dist/{status-BREvtzJm.js → status-DQ_PPz4C.js} +12 -12
- package/dist/status-DQ_PPz4C.js.map +1 -0
- package/dist/{storage-CO9ouK76.js → storage-iTqj5-Av.js} +12 -11
- package/dist/storage-iTqj5-Av.js.map +1 -0
- package/dist/{telemetry-DwK5RQJl.js → telemetry-BP_1Cl9r.js} +4 -4
- package/dist/{telemetry-DwK5RQJl.js.map → telemetry-BP_1Cl9r.js.map} +1 -1
- package/dist/{telemetry-CgwJPVMO.js → telemetry-M3HjlyhZ.js} +2 -2
- package/dist/{telemetry-CgwJPVMO.js.map → telemetry-M3HjlyhZ.js.map} +1 -1
- package/dist/{upgrade-B7sVwL8S.js → upgrade-oZzJ13jM.js} +5 -4
- package/dist/{upgrade-B7sVwL8S.js.map → upgrade-oZzJ13jM.js.map} +1 -1
- package/dist/utils/backend-guard.d.ts +47 -0
- package/dist/utils/cms-directories.d.ts +6 -0
- package/dist/utils/dev-preflight.d.ts +2 -2
- package/dist/utils/import-schema-module.d.ts +16 -0
- package/dist/utils/path-flags.d.ts +35 -16
- package/dist/utils/project-schema.d.ts +40 -0
- package/dist/utils/project.d.ts +8 -2
- package/dist/utils/schema-dir.d.ts +32 -0
- package/dist/utils/schema-drift.d.ts +6 -0
- package/dist/utils/schema-text.d.ts +24 -0
- package/dist/verify-DkJqhYPI.js +1160 -0
- package/dist/verify-DkJqhYPI.js.map +1 -0
- package/package.json +11 -8
- package/runtime/dev-server.mjs +5 -1
- package/templates/eject/Dockerfile +1 -4
- package/templates/eject/backend/src/env.ts +1 -1
- package/templates/eject/backend/src/index.ts +53 -40
- package/templates/eject/docker-compose.custom.yml +1 -1
- package/templates/overlays/baas/README.md +39 -12
- package/templates/overlays/baas/ai-instructions.md +8 -8
- package/templates/overlays/baas/{config → backend}/storage.ts +3 -4
- package/templates/overlays/baas/backend/tsconfig.json +10 -12
- package/templates/overlays/baas/package.json +1 -2
- package/templates/overlays/baas/pnpm-workspace.yaml +0 -1
- package/templates/presets/blank/backend/schema/index.ts +19 -0
- package/templates/presets/blank/frontend/src/App.tsx +56 -0
- package/templates/presets/ecommerce/backend/schema/categories.ts +12 -0
- package/templates/presets/ecommerce/backend/schema/index.ts +23 -0
- package/templates/presets/ecommerce/backend/schema/orders.ts +13 -0
- package/templates/presets/ecommerce/backend/schema/products.ts +18 -0
- package/templates/presets/ecommerce/frontend/src/App.tsx +59 -0
- package/templates/presets/ecommerce/frontend/src/cms/categories.tsx +12 -0
- package/templates/presets/ecommerce/frontend/src/cms/orders.tsx +38 -0
- package/templates/presets/ecommerce/frontend/src/cms/products.tsx +27 -0
- package/templates/resource-graphs/blank.json +2 -2
- package/templates/resource-graphs/blog.json +5 -5
- package/templates/resource-graphs/ecommerce.json +5 -5
- package/templates/resource-graphs/headless.json +1 -1
- package/templates/template/.claude/hooks/post-edit-collection.sh +27 -23
- package/templates/template/.cursorrules +2 -2
- package/templates/template/.env.example +6 -17
- package/templates/template/.github/copilot-instructions.md +2 -2
- package/templates/template/.windsurfrules +2 -2
- package/templates/template/AGENTS.md +2 -2
- package/templates/template/CLAUDE.md +2 -2
- package/templates/template/README.md +47 -13
- package/templates/template/ai-instructions.md +15 -14
- package/templates/template/backend/functions/hello.ts +1 -1
- package/templates/template/backend/package.json +0 -2
- package/templates/template/{config → backend}/resources.ts +3 -3
- package/templates/template/backend/schema/authors.ts +11 -0
- package/templates/template/backend/schema/index.ts +29 -0
- package/templates/template/backend/schema/posts.ts +29 -0
- package/templates/template/backend/schema/tags.ts +9 -0
- package/templates/template/backend/schema/users.ts +32 -0
- package/templates/template/{config → backend}/storage.ts +4 -4
- package/templates/template/backend/tsconfig.json +15 -20
- package/templates/template/docker-compose.yml +3 -3
- package/templates/template/frontend/package.json +0 -2
- package/templates/template/frontend/src/App.tsx +10 -4
- package/templates/template/frontend/src/cms/authors.tsx +7 -0
- package/templates/template/frontend/src/cms/posts.tsx +27 -0
- package/templates/template/frontend/src/cms/tags.tsx +11 -0
- package/templates/template/frontend/src/cms/ui-config.json +3 -0
- package/templates/template/frontend/src/cms/users.tsx +54 -0
- package/templates/template/frontend/src/{virtual.d.ts → vite-env.d.ts} +0 -4
- package/templates/template/frontend/vite.config.ts +6 -2
- package/templates/template/gitignore +1 -1
- package/templates/template/package.json +1 -2
- package/templates/template/pnpm-workspace.yaml +0 -1
- package/templates/template/scripts/example.ts +3 -3
- package/templates/template/tsconfig.json +1 -1
- package/templates/views/AppView.tsx.tmpl +4 -4
- package/templates/views/EntityView.tsx.tmpl +3 -4
- package/dist/api-keys-Dfw5-9s1.js.map +0 -1
- package/dist/apps-MKQbgDtN.js.map +0 -1
- package/dist/build-BuKTnec8.js.map +0 -1
- package/dist/bundle-BAH4FCju.js.map +0 -1
- package/dist/cloud-DtADfWwn.js.map +0 -1
- package/dist/collection-drift-BKj_BoMq.js +0 -106
- package/dist/collection-drift-BKj_BoMq.js.map +0 -1
- package/dist/collections-dir-DlvDhime.js +0 -69
- package/dist/collections-dir-DlvDhime.js.map +0 -1
- package/dist/console-CdwIYOMV.js.map +0 -1
- package/dist/context-AXdAh-q8.js.map +0 -1
- package/dist/db-DBbKpjYX.js.map +0 -1
- package/dist/derive-ae9UOoOB.js.map +0 -1
- package/dist/dev-C93d4QIv.js.map +0 -1
- package/dist/dev-preflight-Cxv3TiD1.js.map +0 -1
- package/dist/doctor-BBPQUO2g.js.map +0 -1
- package/dist/eject-DABcDnPN.js.map +0 -1
- package/dist/fold-static-BWzxNn06.js.map +0 -1
- package/dist/generate-view-IFwCADvb.js.map +0 -1
- package/dist/generate_sdk-DNmNuFuW.js.map +0 -1
- package/dist/init-vL1DWOeC.js.map +0 -1
- package/dist/last-dev-database-DpW5dfoX.js +0 -2
- package/dist/manifest-BtzDy7KQ.js.map +0 -1
- package/dist/path-flags-DNvtEi2-.js +0 -92
- package/dist/path-flags-DNvtEi2-.js.map +0 -1
- package/dist/project-CasK56vN.js.map +0 -1
- package/dist/pull-DDMpsZ5r.js.map +0 -1
- package/dist/resolve-D647F1LA.js +0 -2
- package/dist/schema-DtLPsXbT.js.map +0 -1
- package/dist/schema-reconcile-DkArN9jF.js +0 -2
- package/dist/skills-CbwV6vw_.js.map +0 -1
- package/dist/status-BREvtzJm.js.map +0 -1
- package/dist/storage-CO9ouK76.js.map +0 -1
- package/dist/utils/collection-drift.d.ts +0 -27
- package/dist/utils/collections-dir.d.ts +0 -14
- package/dist/verify-Y3rWSgfA.js +0 -730
- package/dist/verify-Y3rWSgfA.js.map +0 -1
- package/templates/overlays/baas/config/index.ts +0 -24
- package/templates/overlays/baas/config/package.json +0 -30
- package/templates/template/config/cms.d.ts +0 -15
- package/templates/template/config/collections/authors.ts +0 -47
- package/templates/template/config/collections/index.ts +0 -44
- package/templates/template/config/collections/posts.ts +0 -94
- package/templates/template/config/collections/presets/blank/index.ts +0 -5
- package/templates/template/config/collections/presets/ecommerce/categories.ts +0 -42
- package/templates/template/config/collections/presets/ecommerce/index.ts +0 -31
- package/templates/template/config/collections/presets/ecommerce/orders.ts +0 -78
- package/templates/template/config/collections/presets/ecommerce/products.ts +0 -73
- package/templates/template/config/collections/tags.ts +0 -27
- package/templates/template/config/collections/users.ts +0 -149
- package/templates/template/config/frontend-assets.d.ts +0 -17
- package/templates/template/config/index.ts +0 -12
- package/templates/template/config/package.json +0 -30
- package/templates/template/config/tsconfig.json +0 -35
- /package/templates/eject/{config → backend}/resources.ts +0 -0
|
@@ -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
|
|
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
|
|
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
|
|
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
|
-
#
|
|
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
|
|
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
|
|
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
|
|
10
|
-
- **Data goes through the SDK:** `rebase.dataAsAdmin.<
|
|
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
|
|
10
|
-
- **Data goes through the SDK:** `rebase.dataAsAdmin.<
|
|
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
|
|
10
|
-
- **Data goes through the SDK:** `rebase.dataAsAdmin.<
|
|
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
|
|
10
|
-
- **Data goes through the SDK:** `rebase.dataAsAdmin.<
|
|
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
|
|
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 `
|
|
38
|
-
|
|
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
|
|
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
|
-
├──
|
|
80
|
-
├──
|
|
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
|
-
├──
|
|
84
|
-
│ └──
|
|
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 `
|
|
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
|
|
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
|
-
###
|
|
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
|
-
|
|
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
|
|
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 (
|
|
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:
|
|
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 →
|
|
14
|
-
| `pnpm generate:sdk` | Regenerate the typed client in `generated/sdk/` from
|
|
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
|
|
19
|
-
| `rebase verify` | After every
|
|
20
|
-
| `rebase resources --write` | After declaring a database, bucket or topic in `
|
|
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
|
|
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`;
|
|
29
|
-
- **Never edit `rebase.resources.json`.** It is generated from `
|
|
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**:
|
|
35
|
-
2. **Applying a
|
|
36
|
-
3. **Use the SDK**: server-side that is `rebase.dataAsAdmin.<
|
|
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
|
-
- **
|
|
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
|
|
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
|
*
|
|
@@ -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
|
|
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
|
|
54
|
+
* Point a column at it by handle — the same name, spelled once:
|
|
55
55
|
*
|
|
56
56
|
* import { media } from "../resources";
|
|
57
|
-
* cover: {
|
|
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,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.
|
|
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
|
|
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?.
|
|
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
|
-
// `
|
|
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
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
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
|
-
//
|
|
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
|
|
53
|
-
//
|
|
54
|
-
|
|
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
|
-
#
|
|
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
|
|
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
|
|
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",
|