@quickback-dev/cli 0.18.0 → 0.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/commands/compile.d.ts.map +1 -1
  2. package/dist/commands/compile.js +25 -1
  3. package/dist/commands/compile.js.map +1 -1
  4. package/dist/commands/migrations.d.ts +17 -0
  5. package/dist/commands/migrations.d.ts.map +1 -0
  6. package/dist/commands/migrations.js +328 -0
  7. package/dist/commands/migrations.js.map +1 -0
  8. package/dist/docs/content.d.ts.map +1 -1
  9. package/dist/docs/content.js +33 -63
  10. package/dist/docs/content.js.map +1 -1
  11. package/dist/index.js +7 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/api-client.d.ts +17 -0
  14. package/dist/lib/api-client.d.ts.map +1 -1
  15. package/dist/lib/api-client.js.map +1 -1
  16. package/dist/lib/file-loader.d.ts +39 -0
  17. package/dist/lib/file-loader.d.ts.map +1 -1
  18. package/dist/lib/file-loader.js +73 -0
  19. package/dist/lib/file-loader.js.map +1 -1
  20. package/dist/lib/file-loader.test.js +22 -1
  21. package/dist/lib/file-loader.test.js.map +1 -1
  22. package/dist/skill/docs/changelog.md +1118 -1
  23. package/dist/skill/docs/compiler/config/domains.md +70 -10
  24. package/dist/skill/docs/compiler/config/index.md +74 -3
  25. package/dist/skill/docs/compiler/config/output.md +1 -1
  26. package/dist/skill/docs/compiler/config/providers.md +6 -12
  27. package/dist/skill/docs/compiler/config/single-tenant.md +1 -1
  28. package/dist/skill/docs/compiler/config/variables.md +0 -30
  29. package/dist/skill/docs/compiler/definitions/access.md +357 -3
  30. package/dist/skill/docs/compiler/definitions/actions.md +85 -8
  31. package/dist/skill/docs/compiler/definitions/schema.md +6 -10
  32. package/dist/skill/docs/compiler/index.md +15 -34
  33. package/dist/skill/docs/compiler/targets/hono-api/cloudflare.md +1 -2
  34. package/dist/skill/docs/compiler/targets/hono-api/database/neon.md +0 -1
  35. package/dist/skill/docs/compiler/targets/hono-api/using-the-api/actions-api.md +19 -0
  36. package/dist/skill/docs/compiler/targets/hono-api/using-the-api/batch-operations.md +1 -1
  37. package/dist/skill/docs/compiler/targets/index.md +6 -34
  38. package/dist/skill/docs/index.md +2 -5
  39. package/dist/skill/docs/stack/account-ui/customization.md +2 -14
  40. package/dist/skill/docs/stack/account-ui/environment-variables.md +7 -1
  41. package/dist/skill/docs/stack/account-ui/features/admin.md +2 -2
  42. package/dist/skill/docs/stack/account-ui/features/avatars.md +2 -4
  43. package/dist/skill/docs/stack/account-ui/features/index.md +1 -1
  44. package/dist/skill/docs/stack/account-ui/features/organizations.md +31 -11
  45. package/dist/skill/docs/stack/account-ui/hooks.md +4 -0
  46. package/dist/skill/docs/stack/account-ui/index.md +5 -43
  47. package/dist/skill/docs/stack/account-ui/with-quickback.md +2 -75
  48. package/dist/skill/docs/stack/auth/plugins/aws-ses.md +60 -0
  49. package/dist/skill/docs/stack/auth/plugins/aws-sns.md +169 -0
  50. package/dist/skill/docs/stack/auth/plugins/index.md +106 -0
  51. package/package.json +1 -1
  52. package/src/skill/docs/changelog.md +1057 -0
  53. package/src/skill/docs/compiler/config/domains.md +26 -0
  54. package/src/skill/docs/compiler/config/index.md +74 -3
  55. package/src/skill/docs/compiler/config/providers.md +6 -12
  56. package/src/skill/docs/compiler/config/single-tenant.md +1 -1
  57. package/src/skill/docs/compiler/config/variables.md +0 -30
  58. package/src/skill/docs/compiler/definitions/access.md +357 -3
  59. package/src/skill/docs/compiler/definitions/actions.md +85 -8
  60. package/src/skill/docs/compiler/definitions/schema.md +6 -10
  61. package/src/skill/docs/compiler/index.md +15 -34
  62. package/src/skill/docs/compiler/targets/hono-api/cloudflare.md +1 -2
  63. package/src/skill/docs/compiler/targets/hono-api/database/neon.md +0 -1
  64. package/src/skill/docs/compiler/targets/hono-api/using-the-api/actions-api.md +19 -0
  65. package/src/skill/docs/compiler/targets/hono-api/using-the-api/batch-operations.md +1 -1
  66. package/src/skill/docs/compiler/targets/index.md +6 -34
  67. package/src/skill/docs/index.md +2 -5
  68. package/src/skill/docs/stack/account-ui/customization.md +2 -14
  69. package/src/skill/docs/stack/account-ui/environment-variables.md +7 -1
  70. package/src/skill/docs/stack/account-ui/features/admin.md +2 -2
  71. package/src/skill/docs/stack/account-ui/features/avatars.md +2 -4
  72. package/src/skill/docs/stack/account-ui/features/index.md +1 -1
  73. package/src/skill/docs/stack/account-ui/features/organizations.md +31 -11
  74. package/src/skill/docs/stack/account-ui/hooks.md +4 -0
  75. package/src/skill/docs/stack/account-ui/index.md +5 -43
  76. package/src/skill/docs/stack/account-ui/with-quickback.md +2 -75
  77. package/src/skill/docs/stack/auth/plugins/aws-ses.md +60 -0
  78. package/src/skill/docs/stack/auth/plugins/aws-sns.md +169 -0
  79. package/src/skill/docs/stack/auth/plugins/index.md +32 -0
  80. package/dist/skill/docs/compiler/targets/supabase-rls/index.md +0 -55
  81. package/dist/skill/docs/compiler/targets/supabase-rls/limitations.md +0 -48
  82. package/dist/skill/docs/compiler/targets/supabase-rls/mappings.md +0 -99
  83. package/dist/skill/docs/compiler/targets/supabase-rls/setup.md +0 -88
  84. package/dist/skill/docs/stack/account-ui/library-usage.md +0 -257
  85. package/dist/skill/docs/stack/account-ui/standalone.md +0 -149
  86. package/dist/skill/docs/stack/account-ui/worker.md +0 -362
  87. package/src/skill/docs/compiler/targets/supabase-rls/index.md +0 -55
  88. package/src/skill/docs/compiler/targets/supabase-rls/limitations.md +0 -48
  89. package/src/skill/docs/compiler/targets/supabase-rls/mappings.md +0 -99
  90. package/src/skill/docs/compiler/targets/supabase-rls/setup.md +0 -88
  91. package/src/skill/docs/stack/account-ui/library-usage.md +0 -257
  92. package/src/skill/docs/stack/account-ui/standalone.md +0 -149
  93. package/src/skill/docs/stack/account-ui/worker.md +0 -362
@@ -1,5 +1,1062 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.34.0 — May 23, 2026
4
+
5
+ Customizable email-OTP templates and a dedicated admin-create-user hook
6
+ — closes a longstanding gap where projects on `email.provider: 'aws-ses'`
7
+ had to live with the generic "Your password reset code is ..." copy for
8
+ admin-bootstrapped accounts.
9
+
10
+ ### Per-type email-OTP template overrides
11
+
12
+ Drop a `.ts` file at `quickback/email-templates/<name>.ts` that
13
+ default-exports `(input) => ({ subject, html, text })`, then reference
14
+ it from the new `plugins.emailOtp.templates` map. Missing keys fall
15
+ through to the package defaults from `@quickback-dev/better-auth-aws-ses`
16
+ — this is purely additive; existing `emailOtp: true` projects emit the
17
+ same code they did before.
18
+
19
+ ```ts title="quickback/quickback.config.ts"
20
+ defineAuth("better-auth", {
21
+ plugins: {
22
+ emailOtp: {
23
+ templates: {
24
+ 'forget-password': './email-templates/forget-password',
25
+ 'welcome': './email-templates/welcome',
26
+ },
27
+ },
28
+ },
29
+ });
30
+ ```
31
+
32
+ ```ts title="quickback/email-templates/welcome.ts"
33
+ export default function welcome({ otp, name, appName, appUrl }) {
34
+ const greeting = name ? `Hi ${name},` : 'Hi,';
35
+ return {
36
+ subject: `Welcome to ${appName} — set your password`,
37
+ html: `<h1>Welcome to ${appName}</h1><p>${greeting} use this code: <b>${otp}</b></p>`,
38
+ text: `${greeting}\n\nYour ${appName} code: ${otp}`,
39
+ };
40
+ }
41
+ ```
42
+
43
+ Recognized keys: `'sign-in' | 'email-verification' | 'forget-password' |
44
+ 'welcome'`. The first three map 1:1 to Better Auth's emailOTP `type`
45
+ enum.
46
+
47
+ ### Synthetic `welcome` routing — credential-row lookup
48
+
49
+ `'welcome'` has no native Better Auth OTP type. When configured, the
50
+ generated `sendVerificationOTP` callback queries the `account` table
51
+ for a `credential`-provider row for the recipient *before* rendering;
52
+ if the user has none (typical of an admin-plugin-created account
53
+ without a password), the send is rerouted through the welcome
54
+ template. Without a welcome template, those sends fall through to
55
+ `forget-password` — same behavior as before. DB-error path fails open
56
+ to the normal forget-password flow so a transient failure can't
57
+ deadlock the password-reset surface.
58
+
59
+ Provider scope: overrides are only honored on `email.provider:
60
+ 'aws-ses'`. The Cloudflare Email path uses the helper's own template
61
+ pipeline and ignores the new config.
62
+
63
+ ### New recognized hook: `after-admin-user-create.ts`
64
+
65
+ A virtual event that wires into the same Better Auth
66
+ `databaseHooks.user.create.after` slot as the generic
67
+ `after-user-create.ts`, but the generator gates the call on
68
+ `_baCtx?.context?.path` matching `/admin/create-user` so it only fires
69
+ when the row came from the admin plugin's create-user endpoint. Use it
70
+ for first-time-user provisioning (welcome email, default org
71
+ assignment, audit-log writes) without inspecting the BA context by
72
+ hand. The generic `after-user-create.ts` still runs for every signup,
73
+ including admin-created ones; the two coexist in a single merged
74
+ `after:` handler.
75
+
76
+ ```
77
+ quickback/hooks/
78
+ after-user-create.ts # every signup
79
+ after-admin-user-create.ts # admin-plugin /admin/create-user only
80
+ ```
81
+
82
+ ### File transport mirrors existing slots
83
+
84
+ The new `quickback/email-templates/` directory follows the same
85
+ pattern as `quickback/plugins/`, `quickback/hooks/`, and
86
+ `quickback/lib/`: the CLI walks the folder and uploads each `.ts` file
87
+ in a new `projectEmailTemplates` field on the compile request; the
88
+ better-auth provider stages referenced files into
89
+ `src/email-templates/<name>.ts` and emits default imports in
90
+ `src/lib/auth.ts`. Files not referenced by any template entry are
91
+ ignored — the CLI uploads the whole directory; the compiler picks only
92
+ what's needed. A relative path pointing at a file the CLI never
93
+ shipped fails compile fast with a "place the file at … and rerun"
94
+ hint.
95
+
96
+ See [AWS SES Plugin → Per-Type Template Overrides](/stack/auth/plugins/aws-ses#per-type-template-overrides)
97
+ and [Account UI → Hooks](/stack/account-ui/hooks#recognized-events).
98
+
99
+ ## v0.33.6 — May 22, 2026
100
+
101
+ Two compiler-side fixes for the queue-consumer / embedding surface and one
102
+ schema-emission bug that blocked `generateId: 'cuid'` projects.
103
+
104
+ ### Schema-emitted `createId()` now ships with a polyfill (no missing import)
105
+
106
+ When `providers.database.config.generateId` is set to `'cuid'`, the audit-
107
+ field injector emits an id column like
108
+ `id: text('id').primaryKey().$defaultFn(() => createId())`. Previously the
109
+ schema source referenced `createId` but no import landed, so `tsc` on the
110
+ generated project failed with `Cannot find name 'createId'`. Recurring
111
+ bug — every recompile re-emitted the broken file (the "do not edit"
112
+ banner doesn't protect from regeneration).
113
+
114
+ Fix: the injector now prepends a top-of-file polyfill backed by
115
+ `crypto.randomUUID()` — a Workers / Node 19+ / Bun global — instead of
116
+ trying to import `@paralleldrive/cuid2`. The package isn't bundled by
117
+ Quickback (per the [hooks doc](/stack/account-ui/hooks)'s "stick to
118
+ built-ins" guidance) and the schema-gen sandbox can't resolve project
119
+ node_modules anyway, so the polyfill is the only path that works
120
+ out-of-the-box.
121
+
122
+ ```ts title="Generated schema header (cuid strategy)"
123
+ import { sqliteTable, text } from 'drizzle-orm/sqlite-core';
124
+
125
+ // Polyfill — Quickback compiler does not ship @paralleldrive/cuid2 in
126
+ // generated projects, and the schema-gen sandbox can't see node_modules.
127
+ // crypto.randomUUID() is a Workers / Node 19+ / Bun global.
128
+ const createId = () => crypto.randomUUID();
129
+
130
+ export const widgets = sqliteTable('widgets', {
131
+ id: text('id').primaryKey().$defaultFn(() => createId()),
132
+ // ...
133
+ });
134
+ ```
135
+
136
+ If you want real cuid2 strings (collision-resistant, shorter than UUIDs)
137
+ you can still install `@paralleldrive/cuid2` and add the import yourself —
138
+ the injector honours an existing import and skips the polyfill.
139
+
140
+ ### queue-consumer.ts header reflects what the file actually does
141
+
142
+ Before v0.33.6 the generated `src/queue-consumer.ts` always carried the
143
+ preamble:
144
+
145
+ ```
146
+ * Queue Consumer for Embedding Jobs & Custom Queue Handlers
147
+ *
148
+ * Processes embedding jobs asynchronously using Workers AI and Vectorize.
149
+ * Also supports custom queue handlers defined in services/queues/.
150
+ ```
151
+
152
+ — even on projects with zero embedding features. Users on
153
+ custom-queue-only deployments would search for `EMBEDDINGS_QUEUE` /
154
+ Vectorize bindings that wrangler.toml correctly didn't emit, wasting
155
+ diagnostic time.
156
+
157
+ The preamble now reflects the actual surface:
158
+
159
+ | `hasEmbeddings` | `hasCustomHandlers` | Header |
160
+ |---|---|---|
161
+ | ✓ | ✓ | "Queue Consumer for Embedding Jobs & Custom Queue Handlers" |
162
+ | ✓ | — | "Queue Consumer for Embedding Jobs" |
163
+ | — | ✓ | "Queue Consumer for Custom Queue Handlers" + explicit "No embedding bindings (EMBEDDINGS_QUEUE / Vectorize / AI) are referenced" |
164
+ | — | — | "Queue Consumer Stub" (additionalQueues with no handler yet) |
165
+
166
+ ### Symmetric embedding detection prevents silent drift
167
+
168
+ The wrangler.toml emit path (`EMBEDDINGS_QUEUE` producer/consumer
169
+ declaration) and the queue-consumer.ts emit path (embedding handler code)
170
+ previously used two different functions to detect "this project has
171
+ embeddings": `hasEmbeddingsConfig` checked both `feature.resource.
172
+ embeddings` and `feature.tables[].resource.embeddings`;
173
+ `extractEmbeddingFeatures` only iterated the tables array. A feature
174
+ shape with feature-level embeddings sugar but no populated tables would
175
+ land in the wrangler binding while NOT landing in the consumer file
176
+ — silent drift.
177
+
178
+ `hasEmbeddingsConfig` is now defined as
179
+ `extractEmbeddingFeatures(...).length > 0`. The two stay in lock-step
180
+ by construction. `extractEmbeddingFeatures` now reads from both shapes
181
+ (tables-level when present, feature-level otherwise).
182
+
183
+ ## v0.33.5 — May 22, 2026
184
+
185
+ Two structural fixes that resolve recurring classes of bug for projects with
186
+ integer primary keys and for projects whose audit columns drift between
187
+ schema and database.
188
+
189
+ ### URL `:id` params coerce to Number when the PK column is integer
190
+
191
+ Per-id CRUD handlers (`GET /:id`, `PATCH /:id`, `DELETE /:id`, `PUT /:id`)
192
+ extracted the URL param as a string and passed it straight into
193
+ `eq(table.id, id)`. For resources with `integer().primaryKey()` columns —
194
+ triggered either by `generateId: 'serial'` on the database config or by
195
+ imported legacy schemas — every per-id route raised a downstream tsc
196
+ type error (integer ≠ string). One production project reported 249 such
197
+ errors across 30+ generated `*.routes.ts` files.
198
+
199
+ Generated handlers for integer-PK resources now emit:
200
+
201
+ ```ts
202
+ const __idRaw = c.req.param('id');
203
+ const id = Number(__idRaw);
204
+ if (!Number.isInteger(id)) {
205
+ return c.json(ValidationErrors.invalidInput([{
206
+ path: ['id'],
207
+ message: `Expected integer, got "${__idRaw}"`,
208
+ code: 'invalid_type',
209
+ }]), 400);
210
+ }
211
+ ```
212
+
213
+ Text-PK resources (the default and the recommended path) are unchanged.
214
+
215
+ A soft-deprecation warning now fires at compile time when
216
+ `providers.database.config.generateId === 'serial'` is set, nudging new
217
+ projects toward text-PK strategies (`'cuid'`, `'uuid'`, `'prefixed'`, or
218
+ the default). Existing serial-PK projects keep working.
219
+
220
+ ### Audit-field injection now runs for every dialect
221
+
222
+ The compiler auto-injects `created_at`, `modified_at`, `created_by`, and
223
+ `modified_by` columns into every feature table, and the scoped-db
224
+ runtime auto-fills them on insert. Until v0.33.5, the early injection
225
+ step in `parseCompilerInput` was gated on `targetDialect ===
226
+ 'postgresql'`. SQLite/D1 projects fell back to a later injection inside
227
+ `generateFeature`, which only fired when `feature.tables.length > 0` —
228
+ features arriving without a populated tables array (raw-drizzle shapes,
229
+ certain legacy migration tables) silently skipped audit injection.
230
+
231
+ Symptom: schemas claimed the columns existed (so the scoped-db proxy
232
+ tried to fill them on insert), but the database table didn't have them.
233
+ Inserts failed with "column doesn't exist." Users reported this for the
234
+ `user_preferences` table and, earlier, for `chat_reads` (the
235
+ `0028_chat_reads_id_column.sql` incident).
236
+
237
+ The early injection now runs for all dialects. `injectAuditFields` is
238
+ already idempotent, so the subsequent per-target injections in
239
+ `compilePureSQLTarget` and `feature-generator.ts` are no-ops when the
240
+ columns are already present. Net: every feature's schema source has
241
+ audit columns by the time drizzle-kit reads it, regardless of dialect
242
+ or feature shape.
243
+
244
+ Upgrade path: recompile against v0.33.5, commit the generated migration
245
+ that adds the missing audit columns, then `wrangler d1 migrations apply`.
246
+
247
+ ## v0.33.4 — May 21, 2026
248
+
249
+ Patch fixes covering upgrade-path bugs and OpenAPI spec/route divergence. No
250
+ new features or breaking changes.
251
+
252
+ ### OpenAPI emits CRUD endpoints only when the route emitter registers them
253
+
254
+ The OpenAPI emitter previously advertised `GET /`, `POST /`, `GET /:id`,
255
+ `PATCH /:id`, `DELETE /:id`, and the corresponding `/batch` operations on
256
+ every resource, regardless of which CRUD verbs were actually declared.
257
+ Clients generated from `openapi.json` then issued requests that fell
258
+ through to `ROUTE_NOT_FOUND` from the firewall layer — a silent contract
259
+ break for anyone whose code path was driven by openapi-typescript or
260
+ similar codegen.
261
+
262
+ Each gate now mirrors the route emitter exactly. A resource that only
263
+ declares `read + create + delete` (no `update`) gets no PATCH operations
264
+ in the spec. A write-only sink (`create` only, no `read`) gets no GET
265
+ operations. Same for batch variants — `POST /batch` only when
266
+ `crud.create` is set, `DELETE /batch` only when `crud.delete` is set,
267
+ etc.
268
+
269
+ If your generated client was calling these spurious endpoints, those
270
+ calls were already failing at runtime; this just removes them from the
271
+ spec.
272
+
273
+ ### Legacy D1 audit-timestamp migrations rewritten in place
274
+
275
+ Compilers ≤ v0.33.1 emitted
276
+ `DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))` for audit columns
277
+ (`created_at`, `modified_at`, etc.). Cloudflare D1 rejects this in
278
+ `ALTER TABLE ADD COLUMN` with `SQLITE_ERROR [code: 7500] "Cannot add a
279
+ column with non-constant default"`. v0.33.2 stopped emitting the
280
+ non-constant form, but pending unapplied legacy migration files on
281
+ upgrading projects still poisoned `wrangler d1 migrations apply` and
282
+ left the deploy stuck.
283
+
284
+ The D1 migration safety pass now retrofits these files in place,
285
+ replacing the strftime expression with the same `'1970-01-01T00:00:00.000Z'`
286
+ constant v0.33.2+ uses. The compile-time warning lists the affected
287
+ columns:
288
+
289
+ ```
290
+ ⚠ D1 helper adjusted features migrations for Cloudflare D1 safety:
291
+ 0004_early_dracula.sql [rewrote=applied_at,created_at,modified_at]
292
+ ```
293
+
294
+ Upgrade path: recompile against v0.33.4, commit the rewritten SQL, then
295
+ `wrangler d1 migrations apply` proceeds.
296
+
297
+ ### D1 helper warning is now actionable
298
+
299
+ The same migration safety pass auto-prepends `PRAGMA defer_foreign_keys
300
+ = on` to every drizzle table-rebuild migration — required on D1
301
+ because it doesn't honour `PRAGMA foreign_keys=OFF/ON` mid-migration the
302
+ way SQLite does. The pass used to surface this insertion as a warning
303
+ on every recompile, training users to ignore the warning entirely.
304
+
305
+ The PRAGMA is still inserted (it has to be), but no longer fires the
306
+ warning. Stripped Better Auth cleanup, reordered child-first DROPs, and
307
+ the new `rewrote=…` annotation above still warn — those are cases where
308
+ a human should look.
309
+
310
+ ### Reference: `account.appUrl` / `account.tenantPattern`
311
+
312
+ v0.33's redesigned dashboard org-card uses two new optional fields on
313
+ the `account` config to deep-link into the tenant's own app:
314
+
315
+ ```ts
316
+ // quickback.config.ts
317
+ account: {
318
+ // …existing fields
319
+ appUrl: 'https://app.example.com',
320
+ tenantPattern: '/{slug}',
321
+ }
322
+ ```
323
+
324
+ Both are typed in the config schema and baked into the Account SPA at
325
+ build time as `VITE_QUICKBACK_APP_URL` and `VITE_TENANT_URL_PATTERN`.
326
+ Without them, the dashboard falls back to a single-target card that
327
+ links to the account org-settings page (legacy v0.32 behaviour). Adding
328
+ them enables the two-zone layout with the external deep-link affordance.
329
+
330
+ (No code change in v0.33.4 — the fields shipped with v0.33.0 but weren't
331
+ called out in the changelog.)
332
+
333
+ ## v0.33.0 — May 21, 2026
334
+
335
+ ### Dedicated hostnames for `/auth/v1/*` and `/api/v1/*` (Shape 1)
336
+
337
+ Two new optional overrides let you carve specific backend surfaces onto dedicated hostnames, served by the same Worker:
338
+
339
+ ```ts
340
+ // quickback.config.ts
341
+ auth: { domain: 'auth.example.com' }, // /auth/v1/* lives here too
342
+ api: { domain: 'api.example.com' }, // /api/v1/* lives here too
343
+ ```
344
+
345
+ On the dedicated hostname, the hostname IS the namespace — `/v1/*` is a shortcut that the Worker-entry rewriter prepends with `/auth` or `/api` before route matching. So `https://api.example.com/v1/users` reaches the same handler as `https://quickback.example.com/api/v1/users`. Both forms work; the long form is also accepted on the dedicated host. Non-matching paths return a JSON 404 ("Not found on api.domain — this hostname serves /api/v1/* and the /v1/* shortcut only") — each hostname stays dedicated to its surface. `/health` and `/openapi.json` are explicit exceptions because monitoring/discovery agents expect them everywhere.
346
+
347
+ Both new domains:
348
+ - Get a `{ pattern, custom_domain: true }` route in `wrangler.toml`
349
+ - Join `trustedOrigins` (CORS allowlist)
350
+ - Join the cross-subdomain cookie inference (auto-enables `crossSubDomainCookies` when ≥2 same-parent subdomains are configured)
351
+ - Join CSP `connect-src` so SPAs can fetch from them
352
+
353
+ **Dual-reach:** all routes remain reachable at the unified backend host (see below) regardless of which dedicated hostnames are configured. The dedicated hostnames are aliases, never replacements.
354
+
355
+ ### `quickback.{baseDomain}` codified as the always-present unified backend
356
+
357
+ The compiler has always auto-inferred a `quickback.{baseDomain}` hostname when any subdomain is configured. v0.33 promotes this from inferred fallback to **load-bearing contract**:
358
+
359
+ - The unified backend hostname is GUARANTEED to exist when any custom subdomain (`account.domain`, `cms.domain`, `auth.domain`, `api.domain`, `apps.<n>.domain`) is set.
360
+ - Every compiler-emitted backend route (api, auth, storage, health, openapi, realtime, mcp, bundled SPAs, sysadmin endpoints) is reachable at the unified host, always.
361
+ - Per-surface domain overrides are additive (Shape 1) — they create more hostnames, never remove routes from the unified host.
362
+
363
+ This is forward-pointing: the future management layer can rely on a single discovery URL pattern (`https://quickback.{baseDomain}/...`) to find any backend regardless of how the operator split their surfaces onto subdomains.
364
+
365
+ Inference also extends to consider `auth.domain` and `api.domain` as domain sources, so a project configuring only one of them still derives `quickback.{baseDomain}` automatically. Explicit `config.domain` still wins over inference.
366
+
367
+ ### `compiler.routes` config block (scaffold — partial)
368
+
369
+ Optional path-prefix overrides for compiler-emitted system routes:
370
+
371
+ ```ts
372
+ compiler: {
373
+ routes: {
374
+ storage: '/files', // default '/storage'
375
+ broadcast: '/realtime', // default '/broadcast/v1'
376
+ mcp: '/agent', // default '/mcp'
377
+ health: '/_health', // default '/health'
378
+ openapi: '/openapi.yaml', // default '/openapi.json'
379
+ },
380
+ }
381
+ ```
382
+
383
+ **Status:** the config is validated and reaches the reserved-prefix registry (so SPA pass-through and compile-time collision detection already honor overrides), but the per-section route emitters still hardcode the defaults. Setting a non-default value today will produce a misconfigured Worker — the registry knows the new path but the actual `app.route('/storage/v1', …)` mount uses the old one. **Don't set these in production yet.** Per-section emit wiring lands in a follow-up.
384
+
385
+ `/api/v1/` and `/auth/v1/` are NOT configurable here — those are deep contracts touched by feature emitters, OpenAPI generation, generated clients, and BA's own basePath. The Shape 1 hostname overrides above are the supported way to relocate them.
386
+
387
+ ## v0.32.0 — May 21, 2026
388
+
389
+ ### Single-origin path-routed architecture
390
+
391
+ A modern Quickback project now runs on **one Cloudflare Worker behind one custom domain**, with the bundled Account and CMS SPAs path-mounted at `/account/` and `/cms/`, system routes at `/api/`, `/auth/`, `/storage/`, and the user's own SPAs anywhere else they want. No cross-subdomain cookies, zero CORS preflights, no separate `api.`/`account.`/`cms.` subdomains required:
392
+
393
+ ```ts
394
+ // quickback.config.ts
395
+ apps: { www: { domain: 'app.example.com' } }, // user's root SPA
396
+ account: true, // bundled at /account/
397
+ cms: true, // bundled at /cms/
398
+ // /api/, /auth/, /storage/, /openapi.json, /health all live here too
399
+ ```
400
+
401
+ The bug that previously broke this shape: when a hostname-mounted root SPA was configured (`apps.www.domain`), its middleware swallowed every path that wasn't in a hardcoded list (`/api/`, `/auth/`, `/admin/`, `/storage/`, `/health`). Requests to `/account/profile` got remapped to `/www/account/profile`, 404'd, then SPA-fallback'd to the wrong SPA. v0.32 introduces a **reserved-prefix registry** (`resolveReservedPrefixes` in `apps/compiler/src/generators/core/reserved-prefixes.ts`) as the single source of truth for what every catchall middleware must pass through:
402
+
403
+ - **System** (always present): `/api/`, `/auth/`, `/storage/`, `/health`, `/openapi.json`
404
+ - **Conditional** (only when feature is on): `/account/` (when `account: true`), `/cms/` (when `cms: true`), `/broadcast/v1/` (realtime), `/mcp` (MCP server)
405
+ - **User-contributed**: every `apps.<name>.path` for path-mounted apps
406
+
407
+ Path-mounted apps that collide with a system or bundled-SPA reservation throw a compile-time error naming both owners. `apps.api = { path: '/api' }` errors clearly instead of silently hijacking feature routes at runtime.
408
+
409
+ ### Admin URL namespace migration: `/admin/v1/*` → `/auth/v1/admin/*`
410
+
411
+ Quickback's legacy admin tier emitted three things under `/admin/v1/*`:
412
+
413
+ 1. A role-admit middleware that admitted both `'admin'` and `'sysadmin'` — contradicting the pseudo-role evaluator's strict-independence model (`ADMIN` admits `'admin'` only; `SYSADMIN` admits `'sysadmin'` only).
414
+ 2. `GET /admin/v1/organizations` — a thin proxy to Better Auth's own `/auth/v1/organization/list`.
415
+ 3. `GET /admin/v1/sysadmin/organizations` — cross-tenant org listing, sysadmin-only.
416
+
417
+ In v0.32, the first two are **removed** and the third **renames** to `GET /auth/v1/admin/list-organizations`. The new path sits under Better Auth's admin URL namespace (sibling of `/auth/v1/admin/list-users`, `/auth/v1/admin/ban-user`, etc.), follows BA's verb-noun convention, and keeps its sysadmin-only gate inside the handler — Quickback-emitted, not BA-mounted.
418
+
419
+ What this enables: `/admin/*` is no longer a reserved system prefix. Projects can mount their own admin SPA via `apps.admin = { path: '/admin' }` without colliding with anything.
420
+
421
+ What changes for callers:
422
+ - The bundled CMS SPA's sysadmin org switcher is updated in lockstep (no migration needed for projects using the SPA as-is).
423
+ - External callers of `/admin/v1/organizations` should migrate to BA's `/auth/v1/organization/list` (same behavior — caller's memberships).
424
+ - External callers of `/admin/v1/sysadmin/organizations` should migrate to `/auth/v1/admin/list-organizations`.
425
+ - Features that previously relied on the "admit both admin AND sysadmin" middleware should declare `access: { roles: ['ADMIN', 'SYSADMIN'] }` explicitly on each route.
426
+
427
+ The `ADMIN_ROUTE_FEATURES` carve-out in the compiler is also removed — feature routes always mount at `/api/v1/<feature>`, and admin-only behavior is enforced by per-operation `access: { roles: ['ADMIN'] }` at the resource level.
428
+
429
+ ### Two compiler bug fixes
430
+
431
+ - **Soft-delete index callback parameter bug.** The auto-index injector emitted hardcoded `t.<col>` references regardless of the existing extras callback's parameter name. When a user (or upstream transform) wrote `(table3) => ({ … })`, the appended composite-index entries referenced `t.organizationId, t.deletedAt` — `t` undefined inside the arrow scope, `ReferenceError` at module load. Fixed in `apps/compiler/src/utils/auto-indexes.ts` by capturing and reusing the callback's parameter name.
432
+ - **Reserved-word action filename collision.** Action discovery walks `actions/*.ts` and emits `import <name> from './actions/<name>'`. A user filename of `import.ts`, `delete.ts`, `await.ts`, `export.ts`, etc. produced `import import from './actions/import';` — a SyntaxError on module load. Fixed in `apps/compiler/src/codegen/discovered-actions.ts` by aliasing reserved-word and invalid-identifier filenames to `__action_<sanitized>` bindings while preserving the public action key (route emitters use bracket notation, so reserved-word keys are fine in the lookup map).
433
+
434
+ ## v0.29.0 — May 19, 2026
435
+
436
+ ### Opt-in `id` auto-injection (`compiler.injectId: 'auto'`)
437
+
438
+ Quickback's generated CRUD routes, FK extractor, relationship resolver, and `/:id` mount points all assume every feature table has an `id` primary key column. Authoring a table without one — common when porting an existing schema, or when a domain genuinely uses a compound or non-`id` PK — produced silent failures: routes that 404, batch operations that targeted the wrong rows, FK lookups that returned empty.
439
+
440
+ v0.29 adds an opt-in flag that auto-injects an `id` column into every feature table that doesn't already declare one. Same mechanism as the existing `createdAt`/`modifiedAt` injection — early-pass, idempotent, dialect-aware.
441
+
442
+ ```ts
443
+ // quickback.config.ts
444
+ compiler: {
445
+ injectId: 'auto', // off by default; opt in per project
446
+ }
447
+ ```
448
+
449
+ When `'auto'`:
450
+ - Tables with no `.primaryKey()` declared get `id: text("id").primaryKey().$defaultFn(() => createId())` (or the matching shape for `dbConfig.generateId` — `serial`, `uuid`, `prefixed`).
451
+ - Tables that already declare an `id` column (in any shape) are no-op — the injector is idempotent.
452
+ - Tables with a `.primaryKey()` on a non-`id` column raise a clear compile error that names the offending column and points at the v0.30 follow-up which will rewrite custom PKs to unique indexes automatically. v0.29 surfaces the conflict; v0.30 fixes it.
453
+
454
+ Default stays `false` so existing projects don't get migration churn. Opt in when you want to lean on every-table-has-id semantics across your schema.
455
+
456
+ ### Why this is opt-in (and what v0.30 changes)
457
+
458
+ The "every table has `id`" assumption is load-bearing across 68+ sites in the compiler — every CRUD emitter, the FK regex (`.references(() => target.id)`), the relationship resolver hydration block, the `/:id` route mounts. v0.29 only injects the column; v0.30 will close the remaining gaps:
459
+
460
+ - FK extraction migrates from `.id` regex to schema-aware metadata lookup, so tables with non-`id` PKs participate in FK display + relationship resolution.
461
+ - The PK→unique-index rewrite lands — tables with explicit non-`id` PKs auto-keep their uniqueness as a constraint while gaining the auto-injected `id`.
462
+ - The flag flips to default-on; opting out becomes the rare path.
463
+
464
+ v0.29 ships the foundation so projects can opt in today without waiting for the full structural pass.
465
+
466
+ ## v0.28.0 — May 19, 2026
467
+
468
+ ### INTERNAL pseudo-role: server-only schemas, unforgeable from HTTP
469
+
470
+ v0.27 had five pseudo-roles — `PUBLIC`, `AUTHENTICATED`, `USER`, `ADMIN`, `SYSADMIN` — and one structural gap: there was no way to mark a schema as "the server enumerates this; no user-facing route should ever read across tenants." Push subscriptions, personal access tokens, OAuth tokens, broadcast job tables — anywhere the server needs full visibility but users should only see their own row. The workaround was `firewall: { exception: true }` plus an out-of-band convention, which left auth on the schema looking incidental.
471
+
472
+ v0.28 adds **`INTERNAL`** as the sixth pseudo-role. Schemas with `roles: ['INTERNAL']` are reachable only by `AppContext` values where `ctx.internal === true` — a flag the HTTP auth middleware **never** sets. No session, JWT, header, query parameter, or body field populates it. The flag is reserved for compiler-emitted server-internal entry points (queue consumers, cron workers, server-side helpers that bypass HTTP entirely).
473
+
474
+ ```ts
475
+ // features/comms/push-subscriptions.ts
476
+ export default defineTable(push_subscriptions, {
477
+ firewall: [{ field: 'ownerId', equals: 'ctx.userId' }],
478
+ // User reads their own subscriptions via the standard CRUD route.
479
+ read: { access: { roles: ['USER'] } },
480
+ // Server enumerates ALL subscriptions for a broadcast — INTERNAL only.
481
+ crud: {
482
+ delete: { access: { roles: ['INTERNAL'] } },
483
+ },
484
+ });
485
+ ```
486
+
487
+ The split-surface pattern is the recommended shape: a user-facing access node uses `USER` / `AUTHENTICATED` / a real role; a server-only access node uses `INTERNAL`. Mixing INTERNAL with a user-facing pseudo-role on the **same** access node is a compile error — it almost always means the developer is confused about which side of the trust boundary they're on. The error names the cohabiting markers explicitly and points at the fix (split into separate access blocks).
488
+
489
+ The runtime stamping (queue consumer ctx, cron worker ctx) lands in a follow-up; v0.28 ships the declarative surface so projects can mark schemas accurately today. Until the stamping ships, server-internal code uses `unsafeDb` to enumerate INTERNAL surfaces — the security guarantee is in place because no HTTP-derived context can ever carry `ctx.internal === true`.
490
+
491
+ ### Reserved-name fix: SYSADMIN and INTERNAL added to ALWAYS_RESERVED
492
+
493
+ `SYSADMIN` was previously omitted from the `ALWAYS_RESERVED` set in `authz-schema.ts`. The runtime validator rejected `roles: ['SYSADMIN']` when `cms.sysadmin: true` wasn't set, but the **shadow-declaration path** — user code writing `authz.roles.SYSADMIN: { roles: [...] }` to silently change the pseudo-role's meaning — wasn't blocked. v0.28 closes that gap by adding both `SYSADMIN` and `INTERNAL` to the unconditionally-reserved set.
494
+
495
+ ### Per-table OWNER_SCOPE_RULES: explicit owner predicates no longer over-scope
496
+
497
+ When a user declared a non-canonical owner predicate on one table — e.g. `firewall: [{ field: 'linkedUserId', equals: 'ctx.userId' }]` — that column got promoted into the **project-global** `OWNER_SCOPE_RULES` list. Any other table in the project that happened to have a `linkedUserId` column (even as a plain FK reference, not for scoping) had the same `WHERE linkedUserId = ctx.userId` injected on every read, update, and delete. Silent over-scoping that surfaced only when a query returned the wrong rows.
498
+
499
+ v0.28 narrows the global list to the **canonical owner column** — the one matching `authDefaults.owner.column` (default `ownerId`). Explicit predicates on custom-named columns are honored on their declaring table via that table's own `buildFirewallConditions` helper, but stay per-table. Reads on other tables with the same column name are unaffected.
500
+
501
+ ```ts
502
+ // Before v0.28: linkedUserId on `comments` ALSO got the WHERE
503
+ // because `event_organizers` declared an explicit owner predicate.
504
+ export default defineTable(event_organizers, {
505
+ firewall: [{ field: 'linkedUserId', equals: 'ctx.userId' }],
506
+ });
507
+ export default defineTable(comments, {
508
+ // comments.linkedUserId is just an FK reference; we don't want it scoped.
509
+ firewall: [{ field: 'eventId', equals: 'ctx.activeOrgId' }],
510
+ });
511
+ ```
512
+
513
+ In v0.28, `event_organizers` queries get the per-table `linkedUserId = ctx.userId` predicate as before; `comments` queries are no longer mis-scoped.
514
+
515
+ If you genuinely want the same column to scope multiple tables (rare), declare the explicit firewall predicate on each table. The implicit "every table with this column gets scoped" behavior was the bug — explicit-per-table is the cure.
516
+
517
+ ## v0.27.0 — May 19, 2026
518
+
519
+ ### Narrow `ctx.<exposeAs>` typing for namespace-scoped actions
520
+
521
+ Since v0.23 the namespace middleware has hydrated `ctx.<exposeAs>` with the loaded resource row before each action runs. The static type of that field stayed `any` — runtime safety was solid, but autocomplete and typo-catching were missed opportunities.
522
+
523
+ v0.27 ships the second half: one **per-namespace `defineAction` helper** emitted alongside the standard one. Importing from the narrowed helper retypes `ctx.<exposeAs>` inside `execute({ ctx })` to the loaded row's `$inferSelect` shape. Nothing about discovery, routing, or runtime behavior changes — this is purely TypeScript ergonomics.
524
+
525
+ ```ts title="features/feeds/actions/feed-moments.ts"
526
+ // Before — ctx.event is `any`
527
+ import { defineAction } from '../.quickback/define-action';
528
+
529
+ // After — ctx.event is `typeof events.$inferSelect`
530
+ import { defineAction } from '../.quickback/define-action.event-scope';
531
+
532
+ export default defineAction({
533
+ path: '/event/:eventId/feed-moments',
534
+ method: 'POST',
535
+ input: z.object({ body: z.string() }),
536
+ access: { roles: ['attendee'] },
537
+ async execute({ ctx, input }) {
538
+ ctx.event.id // ✓ string, autocomplete works
539
+ ctx.event.startsAt // ✓ Date
540
+ ctx.event.idd // ✗ TS2339 — typo caught at compile time
541
+ },
542
+ });
543
+ ```
544
+
545
+ #### Where the file lives
546
+
547
+ The compiler emits one narrowed helper per `(feature, namespace)` pair where the feature owns at least one action whose `path:` falls under the namespace prefix. Filename is `define-action.<kebab(namespaceName)>.ts` (`eventScope` → `define-action.event-scope.ts`), sibling to the standard `define-action.ts`:
548
+
549
+ ```text
550
+ src/features/feeds/.quickback/
551
+ ├── define-action.ts # generic — standard fallback
552
+ └── define-action.event-scope.ts # ctx.event narrowed
553
+ ```
554
+
555
+ A feature contributing to multiple namespaces gets one helper per namespace. Each action picks the import that matches its path.
556
+
557
+ #### Opt-in, no breaking change
558
+
559
+ Actions that keep their existing `import { defineAction } from '../.quickback/define-action'` continue to compile unchanged. The `AppContext` index signature still admits `ctx.event` at type `any`; runtime hydration is unaffected. Flip imports per action at your own pace.
560
+
561
+ #### Compile-time advisory
562
+
563
+ When `quickback compile` sees a namespace-scoped action still importing the generic helper, it logs a one-line `[quickback:typing]` advisory pointing at the narrowed path:
564
+
565
+ ```text
566
+ [quickback:typing] action "feedMoments" in feature "feeds" lives under
567
+ namespace "eventScope" — switch its import to
568
+ `../.quickback/define-action.event-scope` for narrow ctx.<exposeAs> typing.
569
+ (Runtime behavior is unchanged; the narrowed helper only refines TS types.)
570
+ ```
571
+
572
+ Non-blocking — same family as `[quickback:authz]`.
573
+
574
+ #### Side fix
575
+
576
+ Repaired a latent off-by-one in the inlined `AppContext` import path that landed in the v0.26 helper prelude but hadn't been exercised against a recompiled project yet (`"../../lib/types"` → `"../../../lib/types"`). New compiles produce a helper whose `AppContext` import actually resolves.
577
+
578
+ #### Out of scope
579
+
580
+ Non-namespace standalone actions with relationship-based access keep their existing `(ctx.event as typeof events.$inferSelect)` body cast. Same per-relationship helper pattern would apply if the demand surfaces — defer until requested.
581
+
582
+ ## v0.26.0 — May 19, 2026
583
+
584
+ ### Bulk-grant namespace lanes: org admins and team members in one line
585
+
586
+ v0.25 widened `via:` to accept an array of relationship lanes — attendeeOf OR organizerOf, first match wins. That covers per-row authorization paths. v0.26 adds the missing piece: **bulk-grant lanes** for the "you work here, so you see everything in your scope" case. Org admins, team members, and other tenant-scoped staff no longer need a per-event relationship row to be authorized for a namespace.
587
+
588
+ ```ts
589
+ authz: {
590
+ namespaces: {
591
+ eventScope: {
592
+ prefix: '/event/:eventId',
593
+ via: [
594
+ 'attendeeOf', // per-event relationship
595
+ 'organizerOf', // per-event relationship
596
+ { roles: ['admin', 'owner'] }, // org-role bulk grant
597
+ { team: true }, // active-team-membership bulk grant
598
+ ],
599
+ },
600
+ },
601
+ }
602
+ ```
603
+
604
+ Lanes resolve in declaration order, first match wins. Per-row relationships and bulk-grant guards compose freely.
605
+
606
+ #### What each bulk-grant lane does
607
+
608
+ - **`{ roles: [...] }`** — passes when the caller's BA org-role for the namespace's loaded resource includes any listed role. The check is in-memory and short-circuits the relationship loop entirely. The loads-table firewall (scoped by `ctx.activeOrgId`) does the tenant isolation; this lane just adds the role precondition on top.
609
+ - **`{ team: true }`** — passes when `ctx.activeTeamId` is set. The loads-table firewall (which scopes by team for team-scoped tables) does the actual `events.teamId === ctx.activeTeamId` match during hydration. If the firewall returns no row, the request gets a contextual 404 explaining the row isn't visible to the current session — same ambiguous-by-design phrasing the firewall has always used to prevent cross-tenant ID probing.
610
+
611
+ #### Why this matters
612
+
613
+ Until v0.26, the only way to authorize an org admin for a namespace was to write `access.or: [{ via: 'attendeeOf' }, { roles: ['admin', 'owner'] }]` on every individual action under it. That OR-arm shim worked but defeated the purpose of namespaces — the whole point of hoisting the gate was to write the auth rule once. Now you do.
614
+
615
+ #### Rich deny payloads
616
+
617
+ The 403 response when every lane misses lists every path the caller could have taken — relationship names, role names, and `"team-membership"` for `{ team: true }` lanes — in the `required` field. A developer hitting an unexpected 403 sees the full set of authorization options they need to satisfy, not a generic "Insufficient permissions" wall.
618
+
619
+ The 404 from hydration (when the loads-table firewall filters the request out) now includes a hint explaining that the row may exist out of scope, and a `details` field with the resource name and key, so a developer working in their own environment has enough to debug.
620
+
621
+ #### Compile-time guards
622
+
623
+ - **Pure bulk-grant namespaces** (no relationship lane at all) are accepted as long as `loads:` + `exposeAs:` are declared directly on the namespace. With at least one relationship lane present, those fields are inherited from the relationship — declare them on the namespace itself only when no relationship lane is available to anchor hydration.
624
+ - **Heterogeneous `loads:` between relationship lanes is rejected** — `ctx.<exposeAs>` must always hydrate the same table regardless of which lane matched.
625
+ - **`namespace.loads` that disagrees with the inherited value is rejected** with a clear "drop one or align the other" message.
626
+
627
+ ## v0.25.0 — May 19, 2026
628
+
629
+ ### Multi-lane namespace gates: more than one way to be authorized
630
+
631
+ v0.24 lets you hoist a namespace gate to the project level via `authz.namespaces.<name>.via: 'attendeeOf'` — one relationship-resolver middleware running once per request for every action under `/event/:eventId/*`. That works when there's exactly one way to be authorized for the resource. It breaks the moment you have **two**: an attendee row and a per-event organizer row, say. The shim today is to OR the second check inside every individual action's `access` block, which puts you back to writing the gate over and over.
632
+
633
+ v0.25 widens `via:` to accept an array of relationship lanes. The middleware tries each in declaration order, and the first one whose subject row matches authorizes the request and hydrates `ctx.<exposeAs>`.
634
+
635
+ ```ts
636
+ authz: {
637
+ relationships: {
638
+ attendeeOf: {
639
+ from: 'guests',
640
+ subject: { column: 'linkedUserId', equals: 'ctx.userId' },
641
+ resource: { column: 'eventId' },
642
+ where: { status: 'confirmed' },
643
+ loads: 'events',
644
+ exposeAs: 'event',
645
+ },
646
+ // Per-event named organizers. The subject can be a user OUTSIDE
647
+ // the event's organization — e.g. a freelance event manager.
648
+ organizerOf: {
649
+ from: 'eventOrganizers',
650
+ subject: { column: 'linkedUserId', equals: 'ctx.userId' },
651
+ resource: { column: 'eventId' },
652
+ loads: 'events',
653
+ exposeAs: 'event',
654
+ },
655
+ },
656
+ namespaces: {
657
+ eventScope: {
658
+ prefix: '/event/:eventId',
659
+ via: ['attendeeOf', 'organizerOf'], // first match wins
660
+ },
661
+ },
662
+ }
663
+ ```
664
+
665
+ The thing this actually unlocks isn't "two checks instead of one." It's **per-event grants for users outside the owning organization** — external co-organizers, freelance event managers, partner staff. They don't need a `member` row in the event's org; they just need a row in `event_organizers` for that specific event. The horizontal axis (org / team membership) stays for "staff at this company"; the new vertical axis (per-event relationships) handles "specifically connected to this event," regardless of payroll.
666
+
667
+ #### Backward compatible
668
+
669
+ The string form keeps working — `via: 'attendeeOf'` is sugar for `via: ['attendeeOf']`. No existing namespaces break; opt into multi-lane by switching to the array form when you actually need it.
670
+
671
+ #### Compile-time guards
672
+
673
+ The validator rejects three things at parse time:
674
+
675
+ - **Undeclared lane names** — every entry in the array must resolve to an `authz.relationships[*]` declaration.
676
+ - **Lanes that disagree on `loads:` or `exposeAs:`** — if attendeeOf loads `events` as `ctx.event` and organizerOf loads `agendaItems` as `ctx.agendaItem`, downstream handlers can't predict what's in `ctx.<exposeAs>`. Lanes in one namespace must hydrate the same shape.
677
+ - **Empty arrays** — at least one lane is required (otherwise the namespace gate is meaningless).
678
+
679
+ #### Follow-up: v0.26 bulk-grant lanes (shipped same day — see above)
680
+
681
+ The full 4-lane shape adds heterogeneous `via:` arrays accepting `{ roles: ['admin', 'owner'] }` and `{ team: true }` entries, so org admins and team members get the gate without writing relationship rows. v0.25 was the foundation; [v0.26](#v0260--may-19-2026) lifted the existing per-action `access.or: [..., { roles: [...] }]` shim into the namespace and landed same-day.
682
+
683
+ ## v0.24.0 — May 19, 2026
684
+
685
+ ### Cross-feature namespaces: one hoisted gate, many features
686
+
687
+ v0.23 shipped `defineTable({ namespace: { prefix, via } })` — a hoisted relationship-resolver middleware that gates every standalone action in *one feature's* Hono app. That covers the 95% case where a domain concept (events) and the actions under it all live in the same feature directory.
688
+
689
+ v0.24 lifts the namespace to the project level so it can span multiple features. A new `authz.namespaces` block on `quickback.config.ts` declares a path-prefix gate that any feature's standalone action can participate in by matching the prefix in its `path:`. One synthetic routes file, one resolver mount, one relationship match per request — regardless of how many feature directories contribute actions.
690
+
691
+ ```ts
692
+ // quickback.config.ts
693
+ authz: {
694
+ relationships: {
695
+ attendeeOf: {
696
+ from: 'guests',
697
+ subject: { column: 'userId', equals: 'ctx.userId' },
698
+ resource: { column: 'eventId' },
699
+ loads: 'events',
700
+ exposeAs: 'event',
701
+ },
702
+ },
703
+ namespaces: {
704
+ eventScope: { prefix: '/event/:eventId', via: 'attendeeOf' },
705
+ },
706
+ }
707
+
708
+ // features/feeds/actions/feed-moments.ts (cross-feature)
709
+ export default defineAction({
710
+ path: '/event/:eventId/feed-moments',
711
+ method: 'POST',
712
+ // No gate boilerplate. ctx.event is typed.
713
+ });
714
+
715
+ // features/rsvp/actions/respond.ts (different feature, same namespace)
716
+ export default defineAction({
717
+ path: '/event/:eventId/respond',
718
+ method: 'POST',
719
+ });
720
+ ```
721
+
722
+ The compiler emits one `src/routes/__namespace-event-scope.routes.ts` mounted at `/api/v1/event/:eventId/*`. The file imports each contributing feature's `actions` map under a distinct alias (`feedsActions`, `rsvpActions`), runs the `attendeeOf` resolver once per request at the head of the file, and dispatches to the matching action handler.
723
+
724
+ #### Discovery is path-prefix-only
725
+
726
+ No new `namespace: 'eventScope'` field on `defineAction`. Actions opt in by matching `path:` against a declared namespace prefix — same model the table-level v0.23 form uses, just lifted to the project level. This means actions move in/out of the namespace based on their path strings, which is the simplest discovery story and matches today's convention (filenames and paths are already the discoverable surface).
727
+
728
+ #### Source-feature stays the action's home for metadata
729
+
730
+ OpenAPI tags, MCP tool grouping, and CMS form discovery continue to bucket each action under its source feature. Only the *runtime routes file* moves to the synthetic location — the feed-moments action is still tagged "feeds" in OpenAPI, the response shape doesn't change, and your generated SDK reads identically. The URL conveys the namespace membership without forcing every layer of the compiler to re-anchor the action.
731
+
732
+ #### Worker-root mount order
733
+
734
+ Synthetic namespace routes files register at priority `20` — ahead of per-feature mounts (priority `0`/`10`). `sortRoutesBySpecificity` keeps the order stable, and the namespace prefix's path parameter makes it sort more specific than `/api/v1/<feature>` anyway, so the middleware fires first for every request under its prefix.
735
+
736
+ #### Compile-time guardrails
737
+
738
+ The same v0.23 invariants apply at the project level, with two additions:
739
+
740
+ - **`via:` must point at a declared `authz.relationships[*]` entry**, and that relationship must declare `loads + exposeAs` — without `loads` there's nothing for the middleware to hydrate, and a namespace that only gates without hydrating is indistinguishable from a per-action access rule.
741
+ - **`prefix:` must contain at least one `:param` segment** — middleware runs before input parsing, so the relationship key comes from `c.req.param()`.
742
+ - **Same-name conflict** between `defineTable({ namespace })` and `authz.namespaces.<sameName>` is rejected. Pick one declaration site.
743
+ - **Ambiguous prefixes** like `/a/:x` and `/a/:y` (same shape, different `:param` names) error at compile time. Strict super/sub-set relationships (e.g. `/event/:e` and `/event/:e/admin`) are fine — the harvester routes each action to the longest matching prefix.
744
+ - **Unused namespace warning** emits `[quickback:authz]` when no standalone action's path matches a declared prefix. Not a hard error — the namespace may be staged ahead of the actions.
745
+
746
+ #### Picking the right declaration site
747
+
748
+ The table-level v0.23 form is now the **single-feature shorthand**. The project-level v0.24 form is **canonical for cross-feature**.
749
+
750
+ - **Use `defineTable({ namespace })`** when every action under the prefix lives in the same feature directory. The namespace travels with the table that owns it; nothing to add to `quickback.config.ts`.
751
+ - **Use `authz.namespaces`** when the namespace spans features. The declaration sits next to your `authz.relationships` and `authz.roles` — the canonical home for cross-cutting authz config.
752
+
753
+ The two forms can't coexist for the same namespace name. If a v0.23 table-level namespace is starting to attract cross-feature actions, lift it to `authz.namespaces` — same shape, just at the project level, and the matching paths in other features will join automatically.
754
+
755
+ #### Migration
756
+
757
+ Zero breaking changes. Nothing in v0.23 needs to change for v0.24 to land. The new field is opt-in; existing projects pick it up the moment they declare an `authz.namespaces` entry.
758
+
759
+ The harvester runs after Zod schema validation but before route generation, so unused or misconfigured namespaces surface immediately as errors or warnings rather than as silently-broken routes.
760
+
761
+ #### Fixes shipped alongside
762
+
763
+ The first two were load-bearing for v0.23 namespaces to actually work — projects upgrading from a pre-fix v0.23 will see crashes/compile errors disappear on the v0.24 recompile.
764
+
765
+ - **No more dual emission of namespace-claimed standalone routes.** Pre-fix, an action with a cross-feature path like `/event/:eventId/agenda/list-my-agenda` emitted into both `src/index.ts` (without the namespace resolver) and the synthetic file (with it). The plain root copy in `src/index.ts` won every URL match and `ctx.<exposeAs>` was never hydrated — every request 500'd with `Cannot read properties of undefined (reading 'id')`. `extractStandaloneActions` now skips namespace-claimed actions; the synthetic namespace file is the sole emission.
766
+ - **Stripped-path validator no longer rejects namespace-claimed actions.** The synthetic file mounts at `/api/v1${namespace.prefix}` and strips the prefix from each action's local path. The per-action relationship-resolver was validating the *stripped* path for `:eventId`, finding nothing, and rejecting every namespace-mounted action with "action's surface exposes neither a path parameter ':eventId' nor an input field 'eventId'". `planRelationshipResolver` now receives the namespace's `via` and skips its surface-key check entirely — the hoisted middleware is the single source of truth.
767
+ - **Broadcaster DO migration tag consistent across `realtime.mode`.** Inline-mode emission was already going through `qb-do-${className}` + `new_sqlite_classes`. Separate-mode was still hardcoded `tag = "v1"` + `new_classes`, so flipping `realtime: { mode }` produced different migration tags for the same DO class and tripped CF error 10074 ("class already depended on") on cross-mode deploys. Both modes now emit `tag = "qb-do-Broadcaster"` + `new_sqlite_classes`.
768
+ - **Batch handler id arrays type-derive from the input parser.** Pre-fix, `validIds`, `recordMap`, and `validEntries` in bulk-delete / bulk-update / bulk-upsert were hardcoded `string[]` / `Map<string, any>` even when the table's PK column was `integer("id")` — 274× TS2769 in projects mixing string and integer PKs. Handlers now declare `type IdT = typeof ids[number]` (or `typeof records[number]['id']`) and use it for the local id types. Strings stay strings, integers stay integers, no emitter knowledge of the PK column type required.
769
+ - **`ctx` in action handlers is now `AppContext`, not `any`.** Both `StandaloneExecuteParams.ctx` and `RecordExecuteParams.ctx` in the generated `<feature>/.quickback/define-action.ts` are typed `AppContext`. AppContext keeps its `[key: string]: any` index signature so hydrated namespace keys (`ctx.event`, `ctx.<exposeAs>`) stay accessible without TS2339; named fields (`userId`, `activeOrgId`, `roles`, `authenticated`, `user`) get autocomplete and type-checking. Cleared ~49× TS2339 in generated projects.
770
+ - **`c.get('ctx') as AppContext` in every emitted route handler.** Pre-fix, `const ctx = c.get('ctx')` returned `any`, so `ctx.roles?.some(r => …)` left the callback parameter implicitly `any` — 16× TS7006. Now `ctx.roles` is `string[] | undefined`, `r` is `string`, no callback annotation needed.
771
+
772
+ #### Deferred (tracked, not blocking)
773
+
774
+ - Per-namespace narrow typing of `ctx.<exposeAs>` (so `ctx.event` resolves to `typeof events.$inferSelect` instead of `any`). The compiler emits a typed cast at the `execute()` call site in the routes file today, which type-checks the call but not the handler body. Full narrow typing requires per-namespace helper emission (one `define-action.<namespace>.ts` per namespace, or a generic param threading through the action config). Tracked separately.
775
+
776
+ ---
777
+
778
+ ## v0.23.0 — May 19, 2026
779
+
780
+ ### Authz relationships: compile-time guarantees, less boilerplate, hoisted middleware
781
+
782
+ This release closes the gap between what `authz.relationships` *promised* in v0.19 and what it actually enforced. Every documented invariant is now a real compile-time check; every per-action ergonomic friction has a fix. Net effect: relationship-based authorization feels native — declare the relationship once, use the role anywhere, the compiler does the wiring.
783
+
784
+ #### Compile-time guarantees (the authz `firewall` parity)
785
+
786
+ The org/owner/team firewall has always been compile-time-checked: a routed resource without a scope fails the compile, full stop. As of this release, `authz.relationships` carries the same guarantees:
787
+
788
+ - **Bad `via:` names fail at parse time.** A typo in a firewall predicate (`firewall: [{ field: 'eventId', via: 'guestOff' }]`) used to surface deep inside the firewall generator after most validation had passed. It's now caught alongside the `authz.roles` `via:` validation, same layer, same error format.
789
+ - **Relationship-from tables can't opt out.** The doc at `define/types/authz.ts:73-74` always said a relationship `from:` table with `firewall: { exception: true }` "refuses to compile" — that's now enforced. Without this check, every `via:` subquery that pivots through an exception-marked table loses tenant isolation and can return rows from other tenants.
790
+ - **`allowResourceMigration` is now mandatory** when the relationship's `resource.column` is on a writable update endpoint. A guest doing `PATCH /messages/:id { eventId: <other-event-id> }` to migrate a row out of their access scope used to slip past the runtime — it now fails compile with a three-option remediation (set the flag, mark the column immutable, or drop it from the guards.updatable allowlist).
791
+ - **`via: string[]` in firewall predicates.** "Member of attendees OR speakers" no longer requires inventing a composite role just to use it once in a firewall — `firewall: [{ field: 'eventId', via: ['attendeeOf', 'speakerOf'] }]` lowers to an OR-combined subquery.
792
+
793
+ #### Less boilerplate: auto-derivation + realtime resolver
794
+
795
+ - **`resource.column` auto-derives from FKs.** Omit it and the compiler scans the relationship's `from:` table for foreign-key columns, drops the `subject.column`, and picks the remaining FK. One match → auto; zero or many → error with the candidate list. Pattern mirrors the existing firewall auto-detection.
796
+ - **`realtime.requiredRoles` accepts authz roles.** Previously a relationship-role in `realtime.requiredRoles` fell through with a misleading "unknown role" error. The compiler now flattens declared authz roles into their composing Better Auth roles before the realtime ticket-handshake sees them. Relationship-only roles (no static BA fallback) emit a `[quickback:authz]` warning and fail-close at handshake — the row-stream firewall continues to enforce the relationship dimension on the data side.
797
+
798
+ #### Record-based actions can finally use relationship-roles
799
+
800
+ The v0.19 fail-closed hardening had an unintended side effect: a record-based action with `access: { roles: ['attendee'] }` (where `attendee` was a relationship-role) 403'd every caller, including the legitimate ones. The runtime helper couldn't evaluate `relationship:` arms, so it fail-closed correctly — but the inline match expression that *would* evaluate the relationship was never wired up for record-based actions.
801
+
802
+ This release routes record-based actions with relationship arms through the same inline access generator the resource CRUD path already uses. `roles: ['attendee']` on `/applications/:id/recap` now actually checks whether the caller is an attendee, with the loaded record in scope. Non-relationship access trees keep the runtime path unchanged.
803
+
804
+ #### Typed `ctx.<exposeAs>` in action handlers
805
+
806
+ When a relationship declares `loads: 'events', exposeAs: 'event'`, the runtime hydrates `ctx.event` with the loaded row — but the static type was always `any`, so handlers had to write `const event = ctx.event as typeof events.$inferSelect`. As of this release, when an action's access references **exactly one** relationship with `loads + exposeAs`, the compiler emits the cast for you at the execute() call site. Handlers read `ctx.event` with the right shape; no per-handler boilerplate.
807
+
808
+ Multi-arm OR actions (referencing two relationships with hydration) keep the `any` shape — we can't statically know which arm matched.
809
+
810
+ #### New: `defineNamespace` — one mount, one resolver, many actions
811
+
812
+ The marquee Wave 3 change. Today's pattern for "five standalone actions under `/event/:eventId/*` all gated by `attendeeOf`" requires writing the same inline relationship resolver in each action — and pays the resolver cost (one subquery, one row-load) on every request, multiplied by N actions. The new `namespace` field on `defineTable` hoists the resolver into a single Hono middleware mount:
813
+
814
+ ```ts
815
+ // features/events/events.ts
816
+ export default defineTable(events, {
817
+ firewall: [...],
818
+ crud: { ... },
819
+ namespace: {
820
+ prefix: '/event/:eventId', // absolute URL path the mount covers
821
+ via: 'attendeeOf', // relationship gate
822
+ },
823
+ });
824
+
825
+ // features/events/actions/post-announcement.ts
826
+ export default defineAction({
827
+ path: '/event/:eventId/announcements',
828
+ method: 'POST',
829
+ // No relationship-gate boilerplate. ctx.event is typed
830
+ // `typeof events.$inferSelect` inside execute().
831
+ });
832
+ ```
833
+
834
+ The compiler:
835
+ 1. Emits one `app.use('/:eventId/*', async (c, next) => { /* relationship resolver */; await next(); })` at the head of the feature's standalone-routes file (path-prefix stripping handles the feature mount).
836
+ 2. Skips the inline relationship resolver in every per-action handler under the prefix — the middleware already ran it.
837
+ 3. Hydrates `ctx.event` once per request and threads the typed cast into every namespace action's execute() call.
838
+
839
+ **Validation guardrails:**
840
+ - `namespace.via` must point at a declared `authz.relationships[*]` entry.
841
+ - The referenced relationship must declare `loads + exposeAs` — without `loads` there's nothing for the middleware to hydrate, and the namespace gate would be indistinguishable from a per-action access rule.
842
+ - `namespace.prefix` must contain at least one `:param` segment — the middleware reads the relationship key from `c.req.param()`, not from request body (body parsing hasn't run at middleware time).
843
+
844
+ **Scope (v1):**
845
+ - Namespace lives within a single feature's Hono `app`; cross-feature shared namespaces are deferred to v2.
846
+ - One namespace per `defineTable` declaration; multiple namespaces in a feature mount as siblings.
847
+ - For namespace actions whose access references additional relationships beyond the namespace's via, the inline resolver still fires for those — namespace handles only its own.
848
+
849
+ #### Migration
850
+
851
+ Nothing in v0.20 → v0.23 breaks existing code that compiles cleanly. The new errors fire only against patterns that were already latent bugs:
852
+
853
+ - A `via:` typo that previously surfaced as a deep codegen error now surfaces at parse time, same message.
854
+ - A `firewall: { exception: true }` on a relationship-from table now errors; this configuration was always documented as unsupported.
855
+ - A relationship's `resource.column` writable on the resource's UPDATE endpoint now errors unless `allowResourceMigration: true` is set; previously this was a runtime escape hatch.
856
+ - Record-based actions with `roles: ['<relationship-role>']` previously 403'd every caller; they now work as the v0.19 docs originally promised.
857
+
858
+ #### Why this matters
859
+
860
+ Authz relationships are how Quickback expresses "the caller is allowed to touch this resource because of a row in *that* table" — guest-of-event, member-of-organization, scorer-of-interview. Until now, the feature worked but had sharp edges: typos surfaced late, the documented exception-not-allowed constraint wasn't enforced, and the namespace pattern (which most apps with nested resources end up wanting) required repeating the same gate in every action. This release brings authz to parity with the org/owner/team firewall: declare it once, the compiler enforces it everywhere, the runtime emits exactly one query per request.
861
+
862
+ ---
863
+
864
+ ## v0.22.0 — May 19, 2026
865
+
866
+ ### Quickback Stack is Cloudflare-only: one runtime, two databases, one auth provider
867
+
868
+ We've focused the platform on the stack we actually believe in: **Cloudflare Workers + Hono + Better Auth**, with **Cloudflare D1** or **Neon** as the database. Providers and modes that targeted non-Cloudflare backends are gone. The result is a smaller concept set, fewer footguns, and clearer docs.
869
+
870
+ #### What's been removed
871
+
872
+ - **Runtimes**: `bun` and `supabase-edge` are no longer supported. The only runtime is `cloudflare`. Local development for compiled projects has always used `wrangler dev` — that's unchanged.
873
+ - **Databases**: `supabase`, `libsql`, `better-sqlite3`, `bun-sqlite` are removed. Use `cloudflare-d1` for SQLite at the edge or `neon` for PostgreSQL via Hyperdrive.
874
+ - **Auth providers**: `supabase-auth` is removed. `better-auth` is the default; `external` (Cloudflare service binding) remains for advanced setups.
875
+ - **Template**: `template: 'nextjs'` is removed from the public config type. It was never fully implemented. The only template is `'hono'`. If you need a Next.js frontend, bring it as a separate deploy and call the Quickback API, or drop a static export into the `apps:` mount.
876
+ - **Quickback for Supabase RLS** product line is retired. The compiler no longer emits Supabase Row Level Security policies. The `/products/quickback-supabase-rls/` and `/for/supabase-users/` pages have been removed from the marketing site, and the `compiler/targets/supabase-rls/` docs section has been deleted.
877
+
878
+ #### Account UI: one delivery mode
879
+
880
+ The standalone `quickback-better-auth-account-ui` npm package has been **deprecated** and the upstream GitHub repo (`Kardoe-com/quickback-better-auth-account-ui`) has been **archived**. Account UI is now exclusively delivered the way 99% of projects already use it: the compiler builds it from source and bundles it into your Worker.
881
+
882
+ - `account: { domain: 'auth.example.com', ... }` in `quickback.config.ts` — that's the entire integration story.
883
+ - The compiler builds the SPA inside Docker with your branding and feature flags baked in, emits hostname-based routing, and wires cross-subdomain cookies automatically.
884
+ - The three standalone delivery-mode docs (`stack/account-ui/standalone`, `library-usage`, `worker`) are removed; the remaining pages explain the compiler-bundled flow.
885
+
886
+ If you previously deployed the standalone Account UI Worker against a Quickback backend, switch to `account: { domain }` in the config — same end result, one less deploy.
887
+
888
+ #### `VITE_AUTH_ROUTE` hardcoded to Quickback
889
+
890
+ The `VITE_AUTH_ROUTE` env var (which used to switch between `quickback` and `better-auth` routing dialects) is gone. The auth-client always uses Quickback's namespaced routes (`/auth/v1`, `/api/v1`, `/storage/v1`). Generic Better Auth backends are no longer a supported target. Removing the var also closes a known footgun where setting the wrong value silently 404'd every auth call.
891
+
892
+ #### New: every config option is now discoverable
893
+
894
+ When you bootstrap a project, the kitchen-sink marker block in `quickback.config.ts` lists every option Quickback supports — with descriptions and sensible defaults — commented out for you to copy above the marker as needed. Three top-level options were missing from this discovery surface and are now included:
895
+
896
+ - **`apps`** — mount your own prebuilt SPA on its own hostname (`apps: { www: { domain: 'www.example.com', aliasDomains: ['example.com'] } }`). Drop the build at `quickback/apps/<name>/` and the compiler serves it from your Worker alongside the API. Reserved names: `cms`, `account`, `public`.
897
+ - **`security`** — HTTP security headers (CSP, COOP, COEP, HSTS, Referrer-Policy, Permissions-Policy, X-Frame-Options). Set `security: false` to suppress everything; defaults are sensible for the embedded SPAs.
898
+ - **`authz`** — relationship-based authorization roles. Declare joins between the caller and a resource column, then bind role names to those joins for use in `access: { roles: [...] }`.
899
+
900
+ #### Migration
901
+
902
+ Projects that compile cleanly against v0.21 and use any of these providers will hit a clear error at compile time:
903
+
904
+ ```
905
+ Unknown database provider: "supabase". Available: cloudflare-d1, neon
906
+ ```
907
+
908
+ To migrate:
909
+
910
+ 1. **From Supabase**: switch `providers.database` to `cloudflare-d1` or `neon`, and `providers.auth` to `better-auth`. Your `defineTable()` definitions transfer as-is; the security DSL (firewall, access, guards, masking) compiles to Better Auth + Drizzle queries instead of RLS policies.
911
+ 2. **From Bun runtime / `bun-sqlite`**: switch `providers.runtime` to `cloudflare` and `providers.database` to `cloudflare-d1`. Local dev becomes `wrangler dev`.
912
+ 3. **From libsql / Turso**: switch to `cloudflare-d1` or `neon`. Both run natively from Cloudflare Workers via the right binding.
913
+ 4. **From `template: 'nextjs'`**: deploy Next.js separately and call the Quickback API, or drop a static export into `apps:`.
914
+
915
+ #### Why this matters
916
+
917
+ The Quickback Stack is the Supabase alternative for Cloudflare. Every Quickback project ships a Hono API, an Account SPA, a CMS SPA, optional realtime/storage/queues — all built from one config and bundled into one Worker. Keeping that promise focused is more valuable than supporting deployment targets that don't share the runtime.
918
+
919
+ ---
920
+
921
+ ## v0.21.0 — May 19, 2026
922
+
923
+ ### Auto-firewall column swap: `ownerId` is now canonical on feature tables, `userId` warns
924
+
925
+ The compiler's default auto-firewall column for feature tables flips from `userId` to `ownerId`. This closes a long-standing footgun where a `userId` column meaning "a user this row references" (a member, a contact, an invitee) got silently clobbered with `ctx.userId` on insert, because the wrapper matched purely on column name across every table in the project.
926
+
927
+ **What changed in the compiler**
928
+
929
+ - `BETTER_AUTH_DEFAULTS.owner.column`: `'userId'` → `'ownerId'`. Schemas with an `ownerId` column auto-resolve to `firewall: [{ field: 'ownerId', equals: 'ctx.userId' }]` and have `ownerId` auto-stamped on insert.
930
+ - The generated `OWNER_SCOPE_RULES` in `src/lib/scoped-db.ts` is seeded with `ownerId` instead of `userId`. Schemas that don't explicitly name `userId` in a `firewall:` block no longer trigger the global `userId`-stamping rule — the most common collision goes away without renames.
931
+ - A new compile-time warning fires when a feature table carries both an auto-resolved isolation column AND a `userId` column. The warning recommends renaming the column to `linkedUserId` (or similar) if it's informational, or declaring `firewall: [{ field: 'userId', equals: 'ctx.userId' }]` if it really is the access boundary on that table.
932
+ - The targeted compile-time error for "the only candidate column is `userId`" now points users at `ownerId` and the explicit-firewall escape hatch. The previous error wording (which assumed `ownerId` was business-logic) is removed.
933
+
934
+ **What stayed the same**
935
+
936
+ - Better Auth's own internal tables (`session`, `account`, `member`, `passkey`, `subscriptions`) still use `userId` by convention. They aren't feature tables and don't pass through the auto-firewall.
937
+ - Explicit `firewall: [{ field: 'userId', equals: 'ctx.userId' }]` declarations continue to work and are still recognized as the "owner" pattern in the generated comment header.
938
+ - The `USER` pseudo-role validator behaviour is unchanged; only the error-message wording flips to lead with `ownerId` and list `userId` as the explicit fallback.
939
+ - Audit-wrapper (`createdBy` / `modifiedBy`) behavior is untouched.
940
+
941
+ **Migration**
942
+
943
+ Projects that auto-firewalled on a `userId` column will see a hard error on next compile telling them which table is affected, with two suggested fixes:
944
+
945
+ 1. **Recommended**: rename the column to `ownerId` in the schema. Cleanest semantics — readers immediately understand the column is access-control.
946
+ 2. **Explicit firewall**: keep the `userId` column and add `firewall: [{ field: 'userId', equals: 'ctx.userId' }]` to the resource. The auto-stamping and auto-scoping still happen; you've just opted in by name.
947
+
948
+ Projects that have a `userId` column meaning "a user this row references" no longer need the `linkedUserId` rename workaround — auto-stamping won't touch the column unless you name it in a firewall block. The new warning makes this audit-discoverable.
949
+
950
+ **Caveat (deferred)**: explicit `firewall: { owner: { column: 'X' } }` declarations still populate the project-global `OWNER_SCOPE_RULES` list, so a hand-named owner column on one resource will still match by name on every other table that happens to have a column called `X`. A future release will make scope-rule resolution per-table rather than project-global. The warning text calls this out so callers know what to expect.
951
+
952
+ ---
953
+
954
+ ## v0.20.0 — May 19, 2026
955
+
956
+ ### CMS + Account SPAs: shadcn base-ui migration, central Tailwind config
957
+
958
+ Both first-party SPAs are now on the shadcn **base-ui** variants (`@base-ui/react`) instead of the Radix-based primitives, applied via shadcn preset **`bdvxIkMq`** (style `base-mira`, `baseColor: zinc`, `iconLibrary: remixicon`, Inter Variable font). The migration also collapses the previously duplicated per-SPA theme + `components.json` into a single source at `packages/ui/`.
959
+
960
+ #### Single source of truth in `packages/ui/`
961
+
962
+ Both SPAs were independently declaring the same `@theme` / `:root` / `.dark` token blocks in their own `app.css`, and each had its own `components.json` pointing at non-existent local component directories. That's gone:
963
+
964
+ - `packages/ui/styles/theme.css` — the only place tokens live. Includes the base-mira palette, sidebar + chart tokens, and the Inter font import.
965
+ - `packages/ui/components.json` — the only shadcn config in the repo. Future `pnpm dlx shadcn@latest add <name>` runs from `packages/ui/`.
966
+ - `packages/cms/app/app.css` and `packages/account/app/app.css` reduce to two imports plus SPA-specific layers (CMS keeps its AG Grid + richtext-display overrides). `packages/{cms,account}/components.json` deleted.
967
+
968
+ #### Components, icons, deps
969
+
970
+ - All 22 shadcn primitives regenerated against `@base-ui/react` (`@radix-ui/*` removed everywhere). `Drawer` stays on `vaul` — base-ui has no Drawer primitive.
971
+ - Icons migrated from `lucide-react` to `@remixicon/react` line variants across ~100 source files (`Plus → RiAddLine`, `ChevronDown → RiArrowDownSLine`, `X → RiCloseLine`, etc.). `lucide-react` removed from all `package.json` + `deps-spa-*` files.
972
+ - `pnpm.overrides` pin `@types/react ^19.2.0` workspace-wide to resolve the duplicate-React-types conflict introduced by `@base-ui/react`'s bundled type peer.
973
+ - Per-SPA deps and the Docker build mirrors (`apps/compiler/deps-spa-{cms,account}-package.json`) both gain `@base-ui/react`, `@remixicon/react`, `@fontsource-variable/inter`, and bump `shadcn` to `^4.7.0`.
974
+
975
+ #### Backwards-compat `asChild` shim
976
+
977
+ Base-ui replaces Radix's `asChild` boolean with a `render={<X />}` prop. To avoid rewriting ~44 caller sites, the shadcn-generated wrappers for `Button`, `DropdownMenuTrigger`, `DropdownMenuItem`, and `PopoverTrigger` carry an `asChild?: boolean` prop that delegates to base-ui's `render` API when set:
978
+
979
+ ```tsx
980
+ // Caller code keeps working as-is:
981
+ <Button asChild>
982
+ <Link to="/foo">Click</Link>
983
+ </Button>
984
+ ```
985
+
986
+ `ResponsiveModal` survived the migration unchanged — it composes the higher-level Dialog + Drawer wrappers (preserved public API), not the underlying primitives.
987
+
988
+ #### Caller-side API changes worth noting
989
+
990
+ Base-ui ships some real behavioural changes the Radix variants didn't:
991
+
992
+ - `<Select onValueChange>` now receives `(value: string | null, eventDetails) => void` (was `(value: string) => void`). Existing `Dispatch<SetStateAction<string>>` setters reject `null` — wrap callbacks defensively: `onValueChange={(v) => v != null && setX(v)}`.
993
+ - `<DropdownMenuContent forceMount>` removed (base-ui has no `forceMount`). Use base-ui's `keepMounted` on the Popup/Positioner if you need to preserve unmounted state.
994
+ - Component sub-names shifted (`Dialog.Content` → `Dialog.Popup`, `Dialog.Overlay` → `Dialog.Backdrop`). Data attributes are now `data-open` / `data-closed` (no more `data-state="open"`).
995
+
996
+ #### Adding a new primitive after this release
997
+
998
+ ```bash
999
+ cd packages/ui
1000
+ pnpm dlx shadcn@latest add <component> --overwrite --yes
1001
+ # Sweep generated `@/` imports to relative paths — the SPAs' vite-tsconfig-paths
1002
+ # plugin doesn't see packages/ui's @/* mapping at bundle time:
1003
+ sed -i.bak \
1004
+ -e 's|"@/lib/utils"|"../lib/utils"|g' \
1005
+ -e 's|"@/components/|"./|g' \
1006
+ -e 's|"@/hooks/|"../hooks/|g' \
1007
+ components/<component>.tsx && rm components/<component>.tsx.bak
1008
+ ```
1009
+
1010
+ If the new primitive pulls in fresh deps, mirror them into `apps/compiler/deps-spa-{cms,account}-package.json` per the SPA build pipeline or Docker SPA builds will fail.
1011
+
1012
+ ---
1013
+
1014
+ ## v0.18.1 — May 18, 2026
1015
+
1016
+ ### Account SPA — teams, active-team picker, permission-aware UI
1017
+
1018
+ The Account SPA's organization surface is now feature-parity with Better Auth's `organization` plugin for the basic team workflow, and replaces the long-standing hardcoded `role === 'owner' || 'admin'` checks with `checkRolePermission` so projects that ship custom roles get a UI that respects them.
1019
+
1020
+ #### Teams (opt-in)
1021
+
1022
+ When the BA config enables teams — `organization({ teams: { enabled: true } })` — the compiler emits `VITE_ENABLE_ORG_TEAMS=true` and the Account SPA exposes a Teams tab on each organization:
1023
+
1024
+ - **Teams index** (`/$slug/teams`) — splits into "Your teams" (from `listUserTeams`) and "Other teams" so non-admins land on what's relevant. Create / rename / delete from the list, gated on `team:create` / `team:update` / `team:delete`.
1025
+ - **Team detail** (`/$slug/teams/$teamId`) — member roster with add / remove, joining `listTeamMembers` against the org's full member list for display.
1026
+ - **Active-team picker** in the org header — calls `setActiveTeam` and exposes the choice via `OrganizationContext.activeTeamId` so downstream routes (and the BA `session.activeTeamId` server-side) stay in sync.
1027
+ - **Team-aware invites** — `InviteMemberDialog` shows an optional team picker when teams are on and forwards `teamId` to `inviteMember`, so accepting the invite drops the new member straight into the right team.
1028
+
1029
+ Teams are loaded once by the `$slug` layout (`listTeams` + `listUserTeams`) and exposed via `OrganizationContext.teams` / `userTeamIds` / `refreshTeams`, so individual team routes don't re-fetch the list.
1030
+
1031
+ #### Permission-aware UI via `checkRolePermission`
1032
+
1033
+ `OrganizationContext.isOwnerOrAdmin` is gone. Routes now read `can(resource, action)` from context, which delegates to `authClient.organization.checkRolePermission` — synchronous, no roundtrip, and aware of any custom roles registered via the BA `ac` option. Multi-role users (BA stores multiple roles comma-separated) are handled by checking each role; the action is allowed if any role grants it.
1034
+
1035
+ Migrated sites:
1036
+
1037
+ - `$slug.tsx` tab gates → `can('invitation', 'create')`, `can('organization', 'update')`
1038
+ - `members.tsx` action menu → `can('member', 'update' | 'delete')`; the owner-hierarchy guard (non-owners can't touch owner-role members) is preserved as a client-side mirror of BA's server enforcement
1039
+ - `invitations.tsx` → `can('invitation', 'create' | 'cancel')` gates the Invite button, resend, and cancel separately
1040
+ - `settings.tsx` → `can('organization', 'update')` for the form, `can('organization', 'delete')` for the danger zone (was owner-only)
1041
+ - `teams.tsx` / `teams.$teamId.tsx` → `can('team', 'create' | 'update' | 'delete')`
1042
+
1043
+ Projects on the default three-role hierarchy see no behaviour change; projects that defined `admin`/`member` overrides via BA's access-control API now get a UI that matches what the server will actually authorize.
1044
+
1045
+ #### Editable slug + metadata on organization settings
1046
+
1047
+ The `$slug/settings.tsx` form now edits two more `organization.update` fields:
1048
+
1049
+ - **URL slug** — full debounced `checkSlug` flow (mirroring the create-org form); on rename, the SPA navigates to `/${newSlug}/settings` and the layout re-fetches with the new slug.
1050
+ - **Metadata** — single `Record<string, any> | null` JSON textarea, parsed on submit with inline error messaging. Empty clears the field.
1051
+
1052
+ Slug rename is non-breaking for the SPA itself, but every external link / bookmark that references the old slug becomes a 404 — the form warns about this before saving.
1053
+
1054
+ #### Auth client wiring
1055
+
1056
+ When `VITE_ENABLE_ORG_TEAMS=true`, the SPA's `organizationClient(...)` is instantiated with `teams: { enabled: true }` so the team APIs are typed end-to-end. When the flag is off, team methods aren't surfaced — and the Teams tab is hidden — keeping the bundle and UI honest about what the server actually supports.
1057
+
1058
+ ---
1059
+
3
1060
  ## v0.18.0 — May 17, 2026
4
1061
 
5
1062
  ### `config.apps` — mount user-authored SPAs on dedicated hostnames