@quickback-dev/cli 0.65.1 → 0.66.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/compile.d.ts +1 -1
- package/dist/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +13 -0
- package/dist/commands/compile.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/action-harvest.d.ts.map +1 -1
- package/dist/lib/action-harvest.js +14 -6
- package/dist/lib/action-harvest.js.map +1 -1
- package/dist/lib/action-harvest.test.js +26 -0
- package/dist/lib/action-harvest.test.js.map +1 -1
- package/dist/lib/migrations/drizzle.d.ts.map +1 -1
- package/dist/lib/migrations/drizzle.js +6 -1
- package/dist/lib/migrations/drizzle.js.map +1 -1
- package/dist/lib/migrations/drizzle.test.js +3 -0
- package/dist/lib/migrations/drizzle.test.js.map +1 -1
- package/dist/lib/wrangler-resources.d.ts.map +1 -1
- package/dist/lib/wrangler-resources.js +5 -2
- package/dist/lib/wrangler-resources.js.map +1 -1
- package/dist/lib/wrangler-resources.test.js +6 -0
- package/dist/lib/wrangler-resources.test.js.map +1 -1
- package/dist/skill/SKILL.md +18 -3
- package/dist/skill/docs/api/batch-operations.md +1 -1
- package/dist/skill/docs/api/crud.md +1 -1
- package/dist/skill/docs/api/index.md +1 -1
- package/dist/skill/docs/api/query-params.md +5 -8
- package/dist/skill/docs/changelog/index.md +87 -1
- package/dist/skill/docs/configure/auth.md +20 -12
- package/dist/skill/docs/configure/domains.md +1 -1
- package/dist/skill/docs/configure/index.md +19 -29
- package/dist/skill/docs/configure/providers.md +6 -4
- package/dist/skill/docs/configure/single-tenant.md +7 -3
- package/dist/skill/docs/define/access.md +3 -0
- package/dist/skill/docs/define/actions/defining.md +2 -2
- package/dist/skill/docs/define/actions/index.md +1 -1
- package/dist/skill/docs/define/actions/record-and-standalone.md +1 -1
- package/dist/skill/docs/define/actions/scoped-db.md +23 -6
- package/dist/skill/docs/define/changesets.md +7 -8
- package/dist/skill/docs/define/feature.md +3 -2
- package/dist/skill/docs/define/firewall.md +2 -0
- package/dist/skill/docs/define/index.md +1 -1
- package/dist/skill/docs/define/read.md +2 -2
- package/dist/skill/docs/define/relationships.md +7 -0
- package/dist/skill/docs/define/schema.md +21 -1
- package/dist/skill/docs/define/triggers.md +14 -3
- package/dist/skill/docs/platform/api-contract/index.md +52 -42
- package/dist/skill/docs/platform/auth/api-keys.md +1 -1
- package/dist/skill/docs/platform/auth/jwt-optimization.md +1 -1
- package/dist/skill/docs/platform/database/d1.md +13 -1
- package/dist/skill/docs/platform/database/neon.md +1 -1
- package/dist/skill/docs/platform/realtime/durable-objects.md +69 -36
- package/dist/skill/docs/platform/realtime/index.md +8 -10
- package/dist/skill/docs/platform/realtime/named-invalidations.md +23 -9
- package/dist/skill/docs/platform/realtime/using-realtime.md +62 -36
- package/dist/skill/docs/platform/webhooks/outbound.md +4 -5
- package/dist/skill/docs/start/deploy-browser.md +2 -2
- package/dist/skill/docs/start/deploy-owner-access.md +49 -50
- package/dist/skill/docs/start/deploy.md +2 -2
- package/dist/skill/docs/start/first-api.md +1 -1
- package/dist/skill/docs/start/patterns.md +17 -2
- package/dist/skill/docs/start/template-cloudflare.md +1 -1
- package/dist/skill/docs/tooling/cli.md +1 -1
- package/dist/skill/docs/tooling/cloud-compiler/authentication.md +1 -1
- package/dist/skill/docs/tooling/cloud-compiler/troubleshooting.md +28 -0
- package/dist/skill/docs/tooling/output.md +1 -1
- package/dist/skill/docs/ui/account/customization.md +1 -1
- package/dist/skill/docs/ui/account/features/api-keys.md +10 -8
- package/dist/skill/docs/ui/account/features/index.md +7 -6
- package/dist/skill/docs/ui/account/features/organizations.md +1 -1
- package/dist/skill/docs/ui/account/hooks.md +2 -1
- package/dist/skill/docs/ui/account/index.md +7 -4
- package/dist/skill/docs/ui/account/with-quickback.md +1 -1
- package/package.json +1 -1
- package/src/skill/SKILL.md +18 -3
- package/src/skill/docs/api/batch-operations.md +1 -1
- package/src/skill/docs/api/crud.md +1 -1
- package/src/skill/docs/api/index.md +1 -1
- package/src/skill/docs/api/query-params.md +5 -8
- package/src/skill/docs/changelog/index.md +87 -1
- package/src/skill/docs/configure/auth.md +20 -12
- package/src/skill/docs/configure/domains.md +1 -1
- package/src/skill/docs/configure/index.md +19 -29
- package/src/skill/docs/configure/providers.md +6 -4
- package/src/skill/docs/configure/single-tenant.md +7 -3
- package/src/skill/docs/define/access.md +3 -0
- package/src/skill/docs/define/actions/defining.md +2 -2
- package/src/skill/docs/define/actions/index.md +1 -1
- package/src/skill/docs/define/actions/record-and-standalone.md +1 -1
- package/src/skill/docs/define/actions/scoped-db.md +23 -6
- package/src/skill/docs/define/changesets.md +7 -8
- package/src/skill/docs/define/feature.md +3 -2
- package/src/skill/docs/define/firewall.md +2 -0
- package/src/skill/docs/define/index.md +1 -1
- package/src/skill/docs/define/read.md +2 -2
- package/src/skill/docs/define/relationships.md +7 -0
- package/src/skill/docs/define/schema.md +21 -1
- package/src/skill/docs/define/triggers.md +14 -3
- package/src/skill/docs/platform/api-contract/index.md +52 -42
- package/src/skill/docs/platform/auth/api-keys.md +1 -1
- package/src/skill/docs/platform/auth/jwt-optimization.md +1 -1
- package/src/skill/docs/platform/database/d1.md +13 -1
- package/src/skill/docs/platform/database/neon.md +1 -1
- package/src/skill/docs/platform/realtime/durable-objects.md +69 -36
- package/src/skill/docs/platform/realtime/index.md +8 -10
- package/src/skill/docs/platform/realtime/named-invalidations.md +23 -9
- package/src/skill/docs/platform/realtime/using-realtime.md +62 -36
- package/src/skill/docs/platform/webhooks/outbound.md +4 -5
- package/src/skill/docs/start/deploy-browser.md +2 -2
- package/src/skill/docs/start/deploy-owner-access.md +49 -50
- package/src/skill/docs/start/deploy.md +2 -2
- package/src/skill/docs/start/first-api.md +1 -1
- package/src/skill/docs/start/patterns.md +17 -2
- package/src/skill/docs/start/template-cloudflare.md +1 -1
- package/src/skill/docs/tooling/cli.md +1 -1
- package/src/skill/docs/tooling/cloud-compiler/authentication.md +1 -1
- package/src/skill/docs/tooling/cloud-compiler/troubleshooting.md +28 -0
- package/src/skill/docs/tooling/output.md +1 -1
- package/src/skill/docs/ui/account/customization.md +1 -1
- package/src/skill/docs/ui/account/features/api-keys.md +10 -8
- package/src/skill/docs/ui/account/features/index.md +7 -6
- package/src/skill/docs/ui/account/features/organizations.md +1 -1
- package/src/skill/docs/ui/account/hooks.md +2 -1
- package/src/skill/docs/ui/account/index.md +7 -4
- package/src/skill/docs/ui/account/with-quickback.md +1 -1
|
@@ -339,11 +339,10 @@ format:
|
|
|
339
339
|
| `webhook-timestamp` | unix seconds |
|
|
340
340
|
| `webhook-signature` | `v1,<base64 HMAC-SHA256 over id.timestamp.body>` |
|
|
341
341
|
|
|
342
|
-
|
|
343
|
-
`X-Webhook-Signature` / `X-Webhook-Event` / `X-Webhook-Delivery` set,
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
(and its Stripe-format signature) is dropped.
|
|
342
|
+
These are the **only** signature headers sent. The legacy
|
|
343
|
+
`X-Webhook-Signature` / `X-Webhook-Event` / `X-Webhook-Delivery` set, and its
|
|
344
|
+
Stripe-format signature, are gone — a receiver still reading them sees no
|
|
345
|
+
signature at all, so move verification onto `webhook-signature` first.
|
|
347
346
|
|
|
348
347
|
Receiver verification (any Standard Webhooks library works):
|
|
349
348
|
|
|
@@ -113,7 +113,7 @@ Deploy is disabled while a reconnect is pending, so a deploy never starts on a c
|
|
|
113
113
|
|
|
114
114
|
### Reconnecting
|
|
115
115
|
|
|
116
|
-
**Reconnect** re-runs the same consent and lands on the **same connection record** — your account picker, deploys, and
|
|
116
|
+
**Reconnect** re-runs the same consent and lands on the **same connection record** — your account picker, deploys, and admin password reset all keep working. Reconnecting is also how you widen a grant that's missing a permission.
|
|
117
117
|
|
|
118
118
|
### Connecting more than one Cloudflare account
|
|
119
119
|
|
|
@@ -177,7 +177,7 @@ Start keeps a chip above the composer naming the app this chat deployed, with li
|
|
|
177
177
|
Your app answers at `https://<app-name>.<your-subdomain>.workers.dev`:
|
|
178
178
|
|
|
179
179
|
- **API-only apps** serve a small landing page at `/` (browsers) and a JSON service descriptor (everything else), linking `/api/v1`, `/openapi.json`, and `/health` — never a bare 404 on first visit.
|
|
180
|
-
- **Apps with the Account UI or CMS** redirect `/` to the login page or CMS. Both ship by default from Start, at `/cms/` and `/account/`. The CMS needs `user.role === "
|
|
180
|
+
- **Apps with the Account UI or CMS** redirect `/` to the login page or CMS. Both ship by default from Start, at `/cms/` and `/account/`. The CMS needs `user.role === "sysadmin"`, which your first deploy seeds (along with a first organization) — see [Owner access](/start/deploy-owner-access).
|
|
181
181
|
- `/health` reports status and whether email is configured.
|
|
182
182
|
|
|
183
183
|
The deployed app is a normal Worker in *your* account: logs, metrics, and settings live in your Cloudflare dashboard, and you can take over management with the CLI at any time — download the project from Start and `quickback deploy` picks up the same resources.
|
|
@@ -1,73 +1,72 @@
|
|
|
1
1
|
# Owner access after a browser deploy
|
|
2
2
|
|
|
3
3
|
When you deploy from Quickback Start's **Deploy to Cloudflare** card, the very
|
|
4
|
-
first deploy seeds your app's first administrator (
|
|
5
|
-
|
|
4
|
+
first deploy seeds your app's first administrator (`user.role === "sysadmin"`),
|
|
5
|
+
a first organization they own, and a password. The card shows the **email**, a
|
|
6
|
+
**click-to-reveal password**, and a normal link to your app's Account login:
|
|
6
7
|
|
|
7
8
|
```
|
|
8
|
-
https://<your-app>.<subdomain>.workers.dev/
|
|
9
|
+
https://<your-app>.<subdomain>.workers.dev/account/login
|
|
9
10
|
```
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
email + password login every other user of your app gets. If your app has
|
|
38
|
-
the Account UI enabled, you land on `/account`; API-only apps sign in via
|
|
39
|
-
`POST /auth/v1/sign-in/email`.
|
|
12
|
+
Sign in with that email and password. That's the whole setup. After sign-in,
|
|
13
|
+
`/cms/` opens because the seeded role is `sysadmin` — the CMS data-plane tier,
|
|
14
|
+
one above `appmanager`.
|
|
15
|
+
|
|
16
|
+
## What you get
|
|
17
|
+
|
|
18
|
+
- **Shown once.** The plaintext password is returned to Start on the deploy
|
|
19
|
+
that created the admin, and again only if you explicitly reset it. Quickback
|
|
20
|
+
stores the hash in your app's auth database, never the password.
|
|
21
|
+
- **A first organization.** The deploy also inserts an organization named after
|
|
22
|
+
your Worker and seats the admin as `owner`, so org-scoped tables and the CMS
|
|
23
|
+
tenant picker have somewhere to land. A routine redeploy does not create a
|
|
24
|
+
second one. If the compiled config sets `features.pinnedOrganizationId`, that
|
|
25
|
+
string **is** the organization id — the pin and the AUTH_DB row match, the
|
|
26
|
+
CMS skips the tenant picker, and the seeded sysadmin is `owner` of that org
|
|
27
|
+
(so create/update/delete in the CMS actually work). Without a pin the id is
|
|
28
|
+
a random hex.
|
|
29
|
+
- **Your app's login.** After that reveal you sign in through **your app's
|
|
30
|
+
own auth** — the same email + password login every other user of your app
|
|
31
|
+
gets. If your app has the Account UI enabled, that's `/account/login`.
|
|
32
|
+
- **A public URL, not a secret.** The login link is an ordinary
|
|
33
|
+
`<a href="…/account/login">`. It does not carry a token. Anyone can open
|
|
34
|
+
the page; only the password signs you in.
|
|
35
|
+
|
|
36
|
+
The synthetic email looks like `owner@<your-app>.invalid`. Type it exactly as
|
|
37
|
+
shown next to the password.
|
|
40
38
|
|
|
41
39
|
## Signing up yourself doesn't make you an admin
|
|
42
40
|
|
|
43
41
|
`/account/signup` creates an ordinary user. It never sets
|
|
44
|
-
`role === "
|
|
45
|
-
the only path to the first
|
|
42
|
+
`role === "sysadmin"`, so that account can't open `/cms/`. The seeded
|
|
43
|
+
admin is the only path to the first administrator.
|
|
46
44
|
|
|
47
45
|
No confirmation email is sent, either — apps built from Start default to email
|
|
48
46
|
and password with verification off, because a `workers.dev` deploy has no
|
|
49
47
|
verified sending domain. If you're waiting on a signup email, nothing is
|
|
50
|
-
coming;
|
|
48
|
+
coming; use the credentials on the deploy card.
|
|
51
49
|
|
|
52
|
-
**Quickback is not your app's identity provider.** The
|
|
53
|
-
bootstrap window, not a login method: once
|
|
54
|
-
no runtime dependency on Quickback or the deploy broker for
|
|
50
|
+
**Quickback is not your app's identity provider.** The password reveal is a
|
|
51
|
+
bootstrap window, not a login method: once you've signed in (or reset), your
|
|
52
|
+
app has no runtime dependency on Quickback or the deploy broker for
|
|
53
|
+
authentication.
|
|
55
54
|
|
|
56
|
-
## Lost access?
|
|
55
|
+
## Lost access? Reset from Start
|
|
57
56
|
|
|
58
57
|
Deployed apps on `workers.dev` can't send password-reset email, so your
|
|
59
|
-
Cloudflare account is the recovery root: in the deploy card
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
Cloudflare account is the recovery root: in the deploy card (or the chip above
|
|
59
|
+
the composer), **Reset admin password** writes a new hash and shows a fresh
|
|
60
|
+
password once — authorized by the same Cloudflare connection that deployed
|
|
61
|
+
the app.
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
nothing has to be reset first, because "claimable" just means a signed,
|
|
66
|
-
unexpired, unused token exists.
|
|
63
|
+
A routine redeploy does **not** re-surface credentials. Only an explicit
|
|
64
|
+
reset does.
|
|
67
65
|
|
|
68
66
|
## For CLI deploys
|
|
69
67
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
Browser deploys seed the admin automatically. Apps deployed with
|
|
69
|
+
`quickback deploy` don't; create your admin through your own flow, or deploy
|
|
70
|
+
once through Start to bootstrap. The generated `/__quickback/claim` route
|
|
71
|
+
still exists for older apps and answers 404 unless a leftover
|
|
72
|
+
`QUICKBACK_CLAIM_KEY` Worker secret is set — new deploys do not set it.
|
|
@@ -15,7 +15,7 @@ cd my-app && quickback deploy
|
|
|
15
15
|
1. **Preflight** — verifies `wrangler` is runnable (via `npx`) and authenticated with Cloudflare (`wrangler whoami`). Log in with `npx wrangler login` or set `CLOUDFLARE_API_TOKEN`.
|
|
16
16
|
2. **Compiles first if needed** — if the project has never compiled (no `wrangler.toml`), it runs the same flow as `quickback compile` before planning anything.
|
|
17
17
|
3. **Plans from wrangler.toml** — reads the generated `wrangler.toml` and finds every resource whose id is still a placeholder:
|
|
18
|
-
- **D1 databases** — auth, features, files, and
|
|
18
|
+
- **D1 databases** — auth, features, files, webhooks, and audit databases (whichever your project's features pull in; split-database projects get one entry each)
|
|
19
19
|
- **KV namespace** — the `KV` binding used for rate limiting and session overflow
|
|
20
20
|
- **R2 buckets** — file-storage buckets (R2 is referenced by name, so buckets are simply ensured to exist)
|
|
21
21
|
4. **Creates what's missing** — `wrangler d1 create <name>`, `wrangler kv namespace create <BINDING>`, `wrangler r2 bucket create <name>`. Resources are named from your project name exactly the way the compiler names them (`my-app-auth`, `my-app-features`, `my-app-files`, `my-app-KV`, …). If a resource with the expected name already exists in your account, its id is reused instead of creating a duplicate.
|
|
@@ -78,7 +78,7 @@ Re-run with `--force` to take Cloudflare's value, or fix the config by hand.
|
|
|
78
78
|
|
|
79
79
|
## Notes
|
|
80
80
|
|
|
81
|
-
- **Security-audit database** — projects using unsafe
|
|
81
|
+
- **Security-audit database** — projects using unsafe, `PUBLIC`, or hard-delete actions get an `AUDIT_DB` D1. Compile emits a placeholder id; `quickback deploy` creates the database and writes `auditDatabaseId` back, same as AUTH_DB / features DB. Direct `wrangler deploy` of the placeholder fails Cloudflare 10021 — use `quickback deploy`.
|
|
82
82
|
- **Neon projects** — `quickback deploy` does not apply Postgres migrations. Run `npm run db:migrate` (needs `DATABASE_MIGRATION_URL`) before traffic hits the worker, or use the generated project's `npm run deploy` script which chains both.
|
|
83
83
|
- **Hyperdrive** — a Hyperdrive binding can't be auto-created (it needs your database connection string). Create it with `wrangler hyperdrive create <name> --connection-string=… --caching-disabled` and set `providers.database.config.hyperdrive.id`.
|
|
84
84
|
- **Two logins** — the compile step uses your Quickback account (`quickback login`); resource creation and deploy use your wrangler credentials.
|
|
@@ -70,7 +70,7 @@ export default feature('candidates', {
|
|
|
70
70
|
});
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
> `mode: 'hard'` is also available, but hard deletes erase the row — so they require the security-audit pipeline. On D1
|
|
73
|
+
> `mode: 'hard'` is also available, but hard deletes erase the row — so they require the security-audit pipeline. On D1 the compiler emits an `AUDIT_DB` binding (placeholder id until `quickback deploy` creates the database). A table only drops `...q.softDelete()` when **both** `delete.mode` and `batchDelete.mode` are `'hard'`; declaring the pair on a hard-delete table is itself a compile error.
|
|
74
74
|
|
|
75
75
|
> Prefer the explicit two-export form (or interop with existing Drizzle schemas)? See [feature() — single-export sugar](/define/feature) and [Schema: choosing between `q` and Drizzle](/define/schema#choosing-between-q-and-drizzle). All forms compile identically; mix freely per file.
|
|
76
76
|
|
|
@@ -161,7 +161,14 @@ export default defineAction({
|
|
|
161
161
|
|
|
162
162
|
## Referencing Users / Org Members (Assignees)
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
The **caller's** identity is already on the request — `ctx.userId`,
|
|
165
|
+
`ctx.activeOrgId`, `ctx.roles`, `ctx.userRole`. Do not query `AUTH_DB` for
|
|
166
|
+
the acting user.
|
|
167
|
+
|
|
168
|
+
Assignee-style features need to validate that a *submitted* `userId` is
|
|
169
|
+
actually a member of the caller's organization. The scoped `db` never
|
|
170
|
+
includes Better Auth tables — that is by design. Reach AUTH_DB from an
|
|
171
|
+
**action** via `c.get("authDb")` and the generated `getOrgMemberRole` helper:
|
|
165
172
|
|
|
166
173
|
```typescript
|
|
167
174
|
// quickback/features/projects/actions/assign.ts
|
|
@@ -189,7 +196,15 @@ export default defineAction({
|
|
|
189
196
|
});
|
|
190
197
|
```
|
|
191
198
|
|
|
192
|
-
Store the assignee as a plain text column (e.g. `assigneeId: q.text().optional()`) — don't name it `userId`. `userId` is *not* auto-detected as an owner column on feature tables (that column is `ownerId`), but the compiler flags it: an error if it's the only candidate column on the table, a warning alongside a detected isolation column. Rename to `assigneeId`, or declare `firewall: { owner: { column: "userId" } }` if the column really is the row's owner. See [Firewall](/define/firewall).
|
|
199
|
+
Store the assignee as a plain text column (e.g. `assigneeId: q.text().optional()`) — don't name it `userId`, and **never** `.references(() => users.id)`. Better Auth tables live in `AUTH_DB`; feature tables live in `DB`. A SQL FK across those databases is not possible, and drizzle-kit fails generating features migrations. `userId` is *not* auto-detected as an owner column on feature tables (that column is `ownerId`), but the compiler flags it: an error if it's the only candidate column on the table, a warning alongside a detected isolation column. Rename to `assigneeId`, or declare `firewall: { owner: { column: "userId" } }` if the column really is the row's owner. See [Firewall](/define/firewall) and [Schema → References](/define/schema).
|
|
200
|
+
|
|
201
|
+
On D1 the Better Auth tables are `user`, `organization`, and `member` — not
|
|
202
|
+
`organization_membership`. For a richer query from an `actions/` file, import
|
|
203
|
+
those from `../../../auth/schema` and query `c.get("authDb")`. Account hooks
|
|
204
|
+
get `{ authDb, authSchema }` injected ([Auth Hooks](/ui/account/hooks)).
|
|
205
|
+
Trigger `handler:` args are `{ ctx, db, env }` — `db` is features only; there
|
|
206
|
+
is no `c` and no `authDb`. Prefer `ctx`. Do not import `../../auth/schema`
|
|
207
|
+
from a table file ([Triggers](/define/triggers)).
|
|
193
208
|
|
|
194
209
|
## Admin-Only Status Field
|
|
195
210
|
|
|
@@ -216,7 +216,7 @@ Depending on your configuration, the compiler may also generate bindings for:
|
|
|
216
216
|
|
|
217
217
|
By default, the Cloudflare template separates auth tables from application tables:
|
|
218
218
|
|
|
219
|
-
- **`AUTH_DB`** — Better Auth tables (`
|
|
219
|
+
- **`AUTH_DB`** — Better Auth tables (`user`, `session`, `account`, `organization`, `member`)
|
|
220
220
|
- **`DB`** — Your feature tables (`todos`, etc.)
|
|
221
221
|
|
|
222
222
|
This keeps auth data isolated and allows independent scaling. Each database gets its own migration directory:
|
|
@@ -372,7 +372,7 @@ quickback compile
|
|
|
372
372
|
|
|
373
373
|
The API key takes precedence over stored credentials from `quickback login`.
|
|
374
374
|
|
|
375
|
-
You can create API keys from your [Quickback account](https://account.quickback.dev/
|
|
375
|
+
You can create API keys from your [Quickback account](https://account.quickback.dev/api-keys). Each key is scoped to your organization.
|
|
376
376
|
|
|
377
377
|
### Custom Compiler URL
|
|
378
378
|
|
|
@@ -22,7 +22,7 @@ For non-interactive environments (CI/CD, scripts), use an API key:
|
|
|
22
22
|
QUICKBACK_API_KEY=your_api_key quickback compile
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
Create API keys from your [Quickback account](https://account.quickback.dev/
|
|
25
|
+
Create API keys from your [Quickback account](https://account.quickback.dev/api-keys). Each key is scoped to your organization.
|
|
26
26
|
|
|
27
27
|
The API key takes precedence over stored credentials from `quickback login`.
|
|
28
28
|
|
|
@@ -67,6 +67,34 @@ If a hint is missing, compile now fails loudly with the exact key path to add, f
|
|
|
67
67
|
- `Expected hint key: compiler.migrations.renames.tables["events_v2"]`
|
|
68
68
|
- `Expected hint key: compiler.migrations.renames.columns["events"]["summary_text"]`
|
|
69
69
|
|
|
70
|
+
## `Critical command failed: Generate features database migrations`
|
|
71
|
+
|
|
72
|
+
drizzle-kit could not load the generated **features** schema. The usual cause on
|
|
73
|
+
D1 (`splitDatabases: true`) is a feature column that `.references()` a Better
|
|
74
|
+
Auth table:
|
|
75
|
+
|
|
76
|
+
{/* doc-compile: skip — illegal one-liner, not a host feature */}
|
|
77
|
+
```typescript
|
|
78
|
+
userId: q.text().required().references(() => users.id, { onDelete: 'cascade' }) // illegal
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`users` / `user` / `organization` / `member` live in `AUTH_DB`. Features live in
|
|
82
|
+
`DB`. SQLite cannot FK across them, and drizzle-kit cannot resolve `users` when
|
|
83
|
+
generating features migrations.
|
|
84
|
+
|
|
85
|
+
A Start chat compile (`complete=false`) still succeeds — it never runs
|
|
86
|
+
drizzle-kit. Deploy (`complete=true`) is the first time that command runs.
|
|
87
|
+
|
|
88
|
+
Store the Better Auth id as plain text:
|
|
89
|
+
|
|
90
|
+
{/* doc-compile: skip — one-liner, not a host feature */}
|
|
91
|
+
```typescript
|
|
92
|
+
userId: q.text().required()
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`.references()` is only for another feature table in `DB`. See
|
|
96
|
+
[Schema → References](/define/schema).
|
|
97
|
+
|
|
70
98
|
## "Could not load organizations"
|
|
71
99
|
|
|
72
100
|
This can happen if your session token expired or if the API is temporarily unavailable. Re-login:
|
|
@@ -378,7 +378,7 @@ For each feature, the compiler generates a routes file at `src/features/{name}/r
|
|
|
378
378
|
| `POST /{action}` | Standalone actions defined |
|
|
379
379
|
|
|
380
380
|
Routes are mounted under `/api/v1/{feature}` by default, or
|
|
381
|
-
`/api/v2/{feature}` when `contract: { routes: "v2" }` is set.
|
|
381
|
+
`/api/v2/{feature}` when `contract: { routes: "v2" }` is set. The standard API shape
|
|
382
382
|
selects semantics and leaves these paths alone.
|
|
383
383
|
|
|
384
384
|
## Migrations
|
|
@@ -93,7 +93,7 @@ setAppConfig({
|
|
|
93
93
|
| `privacy` | "Privacy Policy" | Footer link text |
|
|
94
94
|
| `support` | "Contact Support" | Footer link text |
|
|
95
95
|
| `company` | (from `VITE_COMPANY_NAME`) | Footer company name |
|
|
96
|
-
| `organizations` | "Organizations" | Navigation and page titles |
|
|
96
|
+
| `organizations` | "Organizations" | Navigation and page titles. Profile and the user menu prefix this as **Manage …** (`Manage Organizations`). |
|
|
97
97
|
|
|
98
98
|
## Custom Messages
|
|
99
99
|
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
# API Key Management
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
API keys are a user credential. Manage them at `/api-keys`, linked from `/profile`. The `apiKey` plugin is on by default.
|
|
4
4
|
|
|
5
5
|
## Creating API Keys
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
7
|
+
- Custom name
|
|
8
|
+
- Shown once at creation — copy it then
|
|
9
|
+
- Scoped to an organization via `metadata.organizationId` so the key inherits your role in that tenant
|
|
10
|
+
- One organization: stamped automatically
|
|
11
|
+
- Several organizations: pick one when creating
|
|
12
12
|
|
|
13
13
|
## Managing Keys
|
|
14
14
|
|
|
15
|
-
-
|
|
16
|
-
- See last-used timestamp
|
|
15
|
+
- List every key you own (not filtered to the current org)
|
|
16
|
+
- See last-used timestamp and which organization the key is scoped to
|
|
17
17
|
- Revoke individual keys
|
|
18
18
|
|
|
19
|
+
`/$slug/api-keys` redirects here so old bookmarks still work.
|
|
20
|
+
|
|
19
21
|
## Related
|
|
20
22
|
|
|
21
23
|
- [API Keys Auth](/platform/auth/api-keys) — Server-side API key authentication
|
|
@@ -171,10 +171,10 @@ VITE_ENABLE_GOOGLE_OAUTH=false # default: false
|
|
|
171
171
|
|
|
172
172
|
**When enabled:**
|
|
173
173
|
- "Continue with Google" button on the login and signup pages
|
|
174
|
-
- Google row
|
|
174
|
+
- Google row on `/connected-accounts` (linked from **Manage Connected Accounts** on `/profile`)
|
|
175
175
|
|
|
176
176
|
**When disabled:**
|
|
177
|
-
- No social sign-in button, no Connected Accounts
|
|
177
|
+
- No social sign-in button, no **Manage Connected Accounts** link, no `/connected-accounts` page
|
|
178
178
|
|
|
179
179
|
**Requirements:**
|
|
180
180
|
- Google OAuth credentials configured on the Better Auth side
|
|
@@ -187,14 +187,14 @@ VITE_ENABLE_CLOUDFLARE_OAUTH=false # default: false
|
|
|
187
187
|
|
|
188
188
|
**When enabled:**
|
|
189
189
|
- "Continue with Cloudflare" button on the login and signup pages
|
|
190
|
-
- Cloudflare rows
|
|
190
|
+
- Cloudflare rows on `/connected-accounts` — unlike
|
|
191
191
|
Google, more than one Cloudflare identity can be linked to the same user
|
|
192
192
|
(**Connect another Cloudflare account**), and every linked identity signs
|
|
193
193
|
in to this user. Link work and personal Cloudflare logins here so each one
|
|
194
194
|
doesn't mint its own separate account.
|
|
195
195
|
|
|
196
196
|
**When disabled:**
|
|
197
|
-
- No Cloudflare sign-in button, no Connected Accounts
|
|
197
|
+
- No Cloudflare sign-in button, no **Manage Connected Accounts** link, no `/connected-accounts` page
|
|
198
198
|
|
|
199
199
|
**Requirements:**
|
|
200
200
|
- `socialProviders.cloudflare.enabled` in the auth config (Cloudflare rides
|
|
@@ -256,10 +256,11 @@ VITE_ENABLE_ORGANIZATIONS=false # default: false
|
|
|
256
256
|
```
|
|
257
257
|
|
|
258
258
|
**When enabled:**
|
|
259
|
-
-
|
|
260
|
-
- Organization management pages
|
|
259
|
+
- `/dashboard` lists organizations and pending invitations
|
|
260
|
+
- Organization management pages (`/$slug`)
|
|
261
261
|
- Member invitations and roles
|
|
262
262
|
- `/organizations/*` routes
|
|
263
|
+
- Sign-in still lands on `/profile`; **Manage Organizations** opens `/dashboard`
|
|
263
264
|
|
|
264
265
|
**When disabled:**
|
|
265
266
|
- Single-user mode only
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Organizations
|
|
2
2
|
|
|
3
|
-
Account UI provides a complete organization management interface when `VITE_ENABLE_ORGANIZATIONS=true`. Teams are a separate opt-in (`VITE_ENABLE_ORG_TEAMS`), surfaced when the compiler detects `organization({ teams: { enabled: true } })` in the Better Auth config.
|
|
3
|
+
Account UI provides a complete organization management interface when `VITE_ENABLE_ORGANIZATIONS=true`. `/dashboard` is that surface: the organizations you belong to and pending invitations. **Manage Organizations** on `/profile` (and in the user menu) opens it. Personal account settings live on `/profile`. The profile **Go to…** picker opens the tenant app using `account.appUrl` and `account.tenantPattern` — see [Customization](/ui/account/customization#tenant-url-patterns). Teams are a separate opt-in (`VITE_ENABLE_ORG_TEAMS`), surfaced when the compiler detects `organization({ teams: { enabled: true } })` in the Better Auth config.
|
|
4
4
|
|
|
5
5
|
## Organization CRUD
|
|
6
6
|
|
|
@@ -45,7 +45,6 @@ the business decision.
|
|
|
45
45
|
|
|
46
46
|
This surface is deliberately explicit and narrow. It requires all of:
|
|
47
47
|
|
|
48
|
-
- `contract.version: "v2"`
|
|
49
48
|
- Cloudflare Workers
|
|
50
49
|
- one Neon database using `connectionMode: "hyperdrive"`
|
|
51
50
|
- the Better Auth `emailOtp` plugin with effective `disableSignUp: true`
|
|
@@ -220,6 +219,8 @@ type HookCtx = {
|
|
|
220
219
|
|
|
221
220
|
`authDb` is the load-bearing piece: hooks must write to the auth DB via Drizzle directly. See the [CSRF caveat](#csrf-caveat-server-side-org-create) below. `authSchema` is the namespace export of the generated auth schema module; destructure the tables you need.
|
|
222
221
|
|
|
222
|
+
This injection is unique to account hooks. Actions reach AUTH_DB via `c.get("authDb")` ([Scoped DB](/define/actions/scoped-db#reaching-better-auth-tables-authdb)). Trigger handlers on a table file get neither — use `ctx` for the acting user, and do not import `../../auth/schema` from the table file.
|
|
223
|
+
|
|
223
224
|
The atomic email-OTP hook additionally receives `db` (the transaction-bound
|
|
224
225
|
full application Drizzle client), `schema` (the full generated application
|
|
225
226
|
schema), and `atomicRoute: "emailOtpSignIn"`. In a single-database Neon project,
|
|
@@ -8,13 +8,15 @@ Account UI is a single React SPA that contains three distinct sections:
|
|
|
8
8
|
|
|
9
9
|
### Account (every user)
|
|
10
10
|
|
|
11
|
-
Login, signup, profile editing, password management, device sessions, email changes, and account deletion. This is what every user interacts with.
|
|
11
|
+
Login, signup, profile editing, password management, device sessions, email changes, and account deletion. This is what every user interacts with. After sign-in, Account UI lands on `/profile`.
|
|
12
|
+
|
|
13
|
+
When organizations are enabled, `/profile` has **Manage Organizations** (the `/dashboard` org list and invites) and a **Go to…** control that opens the tenant app. The URL is `account.appUrl` plus `account.tenantPattern` with the org slug substituted (the same `getTenantUrl` used on the org dashboard). One org is a single button; several orgs is a picker. The control is hidden when those config values cannot produce a URL.
|
|
12
14
|
|
|
13
15
|
Served on its own domain (e.g., `auth.example.com`) or at `/account/` when embedded alongside the CMS.
|
|
14
16
|
|
|
15
17
|
### Organization Management (multi-tenant)
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
`/dashboard` is org management — org list, pending invitations, and the path into org settings (`/$slug`). Personal account settings stay on `/profile`. Only available when `auth.organizations` is enabled.
|
|
18
20
|
|
|
19
21
|
### Admin Panel (admin users only)
|
|
20
22
|
|
|
@@ -86,7 +88,7 @@ Auth feature flags control which pages are included in the bundle:
|
|
|
86
88
|
| `auth.password` | Password login, inline password change on profile |
|
|
87
89
|
| `auth.emailOTP` | Email OTP login flow, email-based password reset |
|
|
88
90
|
| `auth.passkey` | Passkey setup and management |
|
|
89
|
-
| `auth.organizations` |
|
|
91
|
+
| `auth.organizations` | `/dashboard` (org list + invitations), org creation, member management |
|
|
90
92
|
| `auth.admin` | Admin panel (user management) |
|
|
91
93
|
|
|
92
94
|
When a flag is `false`, the corresponding routes **guard themselves at runtime** — each feature route checks its flag from the worker-injected `window.__QUICKBACK_RUNTIME` config in `beforeLoad` and redirects away, and navigation entries for it are hidden. The Account SPA ships as one generic prebuilt bundle; flags decide which surfaces exist for your project.
|
|
@@ -95,9 +97,10 @@ When a flag is `false`, the corresponding routes **guard themselves at runtime**
|
|
|
95
97
|
|
|
96
98
|
- **Authentication** — Email/password, passkeys (WebAuthn), email OTP, magic links, email verification, password reset
|
|
97
99
|
- **Account Management** — Profile editing, avatar upload, password changes, device/session management, account deletion
|
|
100
|
+
- **Connected Accounts** — Link Google and Cloudflare logins from `/connected-accounts` (linked from profile)
|
|
98
101
|
- **Organizations** — Multi-tenant org management with owner/admin/member roles, invitations, and org settings
|
|
99
102
|
- **Admin Panel** — User management dashboard with search, create, ban/unban, password reset, and session viewing
|
|
100
|
-
- **API Keys** — Generate and manage API keys
|
|
103
|
+
- **API Keys** — Generate and manage API keys from `/api-keys` (linked from profile)
|
|
101
104
|
- **CLI Authorization** — Device authorization flow for `quickback login`
|
|
102
105
|
|
|
103
106
|
## Next Steps
|
|
@@ -68,7 +68,7 @@ auth: {
|
|
|
68
68
|
password: true, // Email/password login + inline password change
|
|
69
69
|
emailOTP: false, // Email OTP login flow
|
|
70
70
|
passkey: true, // WebAuthn passkey setup + management
|
|
71
|
-
organizations: true, //
|
|
71
|
+
organizations: true, // /dashboard org list, org management, invitations
|
|
72
72
|
admin: true, // Admin panel (user management)
|
|
73
73
|
}
|
|
74
74
|
```
|