@quickback-dev/cli 0.16.4 → 0.17.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/README.md +7 -3
- package/dist/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +12 -48
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/create.d.ts +20 -0
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +216 -151
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/login.d.ts +4 -2
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +25 -17
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/start.d.ts +20 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +163 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +5 -4
- package/dist/commands/whoami.js.map +1 -1
- package/dist/docs/content.js +37 -37
- package/dist/docs/content.js.map +1 -1
- package/dist/index.js +27 -10
- package/dist/index.js.map +1 -1
- package/dist/lib/api-client.js +1 -1
- package/dist/lib/api-client.js.map +1 -1
- package/dist/lib/api-client.test.js +15 -0
- package/dist/lib/api-client.test.js.map +1 -1
- package/dist/lib/auth.d.ts +39 -3
- package/dist/lib/auth.d.ts.map +1 -1
- package/dist/lib/auth.js +57 -3
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/drizzle-meta-routing.test.js +16 -3
- package/dist/lib/drizzle-meta-routing.test.js.map +1 -1
- package/dist/lib/file-loader.d.ts +6 -4
- package/dist/lib/file-loader.d.ts.map +1 -1
- package/dist/lib/file-loader.js +30 -27
- package/dist/lib/file-loader.js.map +1 -1
- package/dist/lib/file-loader.test.js +16 -7
- package/dist/lib/file-loader.test.js.map +1 -1
- package/dist/skill/docs/changelog.md +145 -0
- package/dist/skill/docs/compiler/config/providers.md +87 -0
- package/dist/skill/docs/compiler/config/single-tenant.md +5 -11
- package/dist/skill/docs/compiler/definitions/access.md +43 -57
- package/dist/skill/docs/compiler/definitions/feature.md +7 -11
- package/dist/skill/docs/compiler/definitions/firewall.md +2 -4
- package/dist/skill/docs/compiler/definitions/guards.md +16 -18
- package/dist/skill/docs/compiler/definitions/index.md +10 -14
- package/dist/skill/docs/compiler/definitions/masking.md +6 -6
- package/dist/skill/docs/compiler/definitions/read.md +6 -11
- package/dist/skill/docs/compiler/definitions/schema.md +19 -17
- package/dist/skill/docs/compiler/definitions/views.md +3 -5
- package/dist/skill/docs/compiler/getting-started/full-example.md +6 -8
- package/dist/skill/docs/compiler/getting-started/hand-crafted.md +3 -5
- package/dist/skill/docs/compiler/getting-started/index.md +23 -20
- package/dist/skill/docs/compiler/getting-started/patterns.md +19 -31
- package/dist/skill/docs/compiler/getting-started/template-blog.md +6 -10
- package/dist/skill/docs/compiler/getting-started/template-cloudflare.md +3 -5
- package/dist/skill/docs/compiler/getting-started/template-empty.md +3 -5
- package/dist/skill/docs/compiler/targets/hono-api/using-the-api/batch-operations.md +29 -23
- package/dist/skill/docs/compiler/targets/hono-api/using-the-api/crud.md +12 -14
- package/dist/skill/docs/compiler/targets/hono-api/using-the-api/openapi.md +5 -2
- package/dist/skill/docs/compiler/targets/hono-api/using-the-api/query-params.md +5 -7
- package/dist/skill/docs/compiler/troubleshooting.md +10 -0
- package/dist/skill/docs/stack/auth/security.md +69 -0
- package/dist/skill/docs/stack/cms/actions.md +28 -0
- package/dist/skill/docs/stack/cms/connecting.md +2 -2
- package/dist/skill/docs/stack/cms/index.md +2 -2
- package/dist/skill/docs/stack/cms/record-layouts.md +19 -19
- package/dist/skill/docs/stack/cms/schema-format.md +33 -3
- package/dist/skill/docs/stack/cms/schema-registry.md +22 -2
- package/dist/skill/docs/stack/cms/security.md +10 -12
- package/dist/skill/docs/stack/cms/table-views.md +1 -1
- package/dist/skill/docs/stack/realtime/durable-objects.md +46 -5
- package/dist/skill/docs/stack/realtime/index.md +20 -3
- package/dist/skill/docs/stack/realtime/using-realtime.md +8 -6
- package/dist/skill/docs/stack/vector/embeddings.md +7 -6
- package/package.json +1 -1
- package/src/skill/docs/changelog.md +183 -2
- package/src/skill/docs/compiler/config/index.md +13 -11
- package/src/skill/docs/compiler/config/providers.md +87 -0
- package/src/skill/docs/compiler/config/single-tenant.md +5 -11
- package/src/skill/docs/compiler/definitions/access.md +43 -57
- package/src/skill/docs/compiler/definitions/feature.md +7 -11
- package/src/skill/docs/compiler/definitions/firewall.md +2 -4
- package/src/skill/docs/compiler/definitions/guards.md +16 -18
- package/src/skill/docs/compiler/definitions/index.md +10 -14
- package/src/skill/docs/compiler/definitions/masking.md +6 -6
- package/src/skill/docs/compiler/definitions/read.md +6 -11
- package/src/skill/docs/compiler/definitions/schema.md +18 -18
- package/src/skill/docs/compiler/definitions/views.md +3 -5
- package/src/skill/docs/compiler/getting-started/full-example.md +6 -8
- package/src/skill/docs/compiler/getting-started/hand-crafted.md +3 -5
- package/src/skill/docs/compiler/getting-started/index.md +23 -20
- package/src/skill/docs/compiler/getting-started/patterns.md +19 -31
- package/src/skill/docs/compiler/getting-started/template-blog.md +6 -10
- package/src/skill/docs/compiler/getting-started/template-cloudflare.md +3 -5
- package/src/skill/docs/compiler/getting-started/template-empty.md +3 -5
- package/src/skill/docs/compiler/targets/hono-api/using-the-api/batch-operations.md +29 -23
- package/src/skill/docs/compiler/targets/hono-api/using-the-api/crud.md +12 -14
- package/src/skill/docs/compiler/targets/hono-api/using-the-api/openapi.md +5 -2
- package/src/skill/docs/compiler/targets/hono-api/using-the-api/query-params.md +5 -7
- package/src/skill/docs/compiler/troubleshooting.md +10 -0
- package/src/skill/docs/stack/auth/security.md +69 -0
- package/src/skill/docs/stack/cms/actions.md +28 -0
- package/src/skill/docs/stack/cms/connecting.md +2 -2
- package/src/skill/docs/stack/cms/index.md +2 -2
- package/src/skill/docs/stack/cms/record-layouts.md +19 -19
- package/src/skill/docs/stack/cms/schema-format.md +33 -3
- package/src/skill/docs/stack/cms/schema-registry.md +22 -2
- package/src/skill/docs/stack/cms/security.md +10 -12
- package/src/skill/docs/stack/cms/table-views.md +1 -1
- package/src/skill/docs/stack/realtime/durable-objects.md +46 -5
- package/src/skill/docs/stack/realtime/index.md +20 -3
- package/src/skill/docs/stack/realtime/using-realtime.md +8 -6
- package/src/skill/docs/stack/vector/embeddings.md +7 -6
|
@@ -4,6 +4,187 @@ Release notes for the Quickback compiler, CLI, and platform.
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
## v0.16.10 — May 14, 2026
|
|
8
|
+
|
|
9
|
+
### Cloudflare D1 now gets a compiler-native Drizzle safety layer
|
|
10
|
+
|
|
11
|
+
Quickback's `cloudflare-d1` provider no longer treats `drizzle-kit generate` output as deploy-ready SQL by default.
|
|
12
|
+
|
|
13
|
+
**A D1-specific post-generation pass now runs inside the compiler.** After Drizzle emits auth, features, webhooks, or audit migrations, the D1 provider inspects the generated SQL before the compile finishes:
|
|
14
|
+
|
|
15
|
+
- **Better Auth cleanup for retired managed tables** is stripped instead of being shipped as raw `DROP TABLE` statements.
|
|
16
|
+
- **Drop-only cleanup migrations** are reordered child-first when foreign-key dependencies require it.
|
|
17
|
+
- **Every generated D1 migration directory** is replayed against SQLite during compile, so a D1-breaking migration fails before `wrangler d1 migrations apply`.
|
|
18
|
+
|
|
19
|
+
This closes the class of failures where a compile succeeded but the later deploy exploded inside Cloudflare D1 because SQLite foreign-key enforcement rejected Drizzle's destructive cleanup ordering.
|
|
20
|
+
|
|
21
|
+
Pinned by `d1-drizzle-helper.test.ts` plus the existing compile-runner and migration-order regressions.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## v0.16.9 — May 13, 2026
|
|
26
|
+
|
|
27
|
+
### Resource-scoped realtime tickets and a shared broadcast targeting model
|
|
28
|
+
|
|
29
|
+
Quickback's realtime layer no longer assumes every WebSocket subscriber is an org member.
|
|
30
|
+
|
|
31
|
+
**`providers.database.config.realtime` can now be object-shaped.** `realtime: true` still enables the historical org-scoped broadcaster, but projects can now opt into a declarative ws-ticket policy:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
providers: {
|
|
35
|
+
database: defineDatabase("cloudflare-d1", {
|
|
36
|
+
realtime: {
|
|
37
|
+
wsTicket: {
|
|
38
|
+
role: "attendee",
|
|
39
|
+
requestField: "eventId",
|
|
40
|
+
scopeTable: "events",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
That lets the generated `/broadcast/v1/ws-ticket` route authenticate the caller with Better Auth, evaluate a declared authz relationship role like `attendee` against the request body, and mint a short-lived Quickback websocket ticket for the resolved resource scope. `scopeTable` is the parent resource that defines the broadcast channel; the relationship/junction table remains the proof of access.
|
|
48
|
+
|
|
49
|
+
**Realtime and broadcast now share one targeting model.** The generated helper and Broadcaster both route by `scopeKey || organizationId || userId`. Historical string targets still mean "organizationId shorthand", so existing code like `realtime.insert("claims", record, ctx.activeOrgId!)` keeps working. New explicit targets can scope a broadcast to a resource or a single user:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
await realtime.broadcast("event-page-updated", payload, {
|
|
53
|
+
scopeKey: "events:evt_123",
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
await realtime.broadcast("dm", payload, {
|
|
57
|
+
userId: recipientId,
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**WebSocket tickets are still Quickback-minted, not Better Auth tokens.** The front door remains your normal Better Auth cookie/bearer/JWT auth. After authorization succeeds, Quickback signs its own 60-second ws ticket and the Broadcaster verifies that ticket at upgrade time. Inline and separate broadcast-worker modes now both reuse `BETTER_AUTH_SECRET` for ticket signing so there is no extra secret to configure during beta.
|
|
62
|
+
|
|
63
|
+
Pinned by `realtime-ws-ticket-scope.test.ts`, plus the existing realtime routing and relationship-access regression suites.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## v0.16.8 — May 13, 2026
|
|
68
|
+
|
|
69
|
+
### Auth transport separation, cookie-backed CSRF middleware, and first-class Wrangler observability
|
|
70
|
+
|
|
71
|
+
Three security/runtime hardenings landed together.
|
|
72
|
+
|
|
73
|
+
**Exactly one auth transport per request.** Generated auth middleware now treats `Cookie`, `Authorization: Bearer`, and `x-api-key` as separate auth methods and rejects any mixed request with `400 AUTH_METHOD_CONFLICT`. Query-string API keys (`?api_key=` / `?key=`) are no longer accepted, which removes ambiguous precedence rules from the hot path and keeps machine-to-machine auth explicit.
|
|
74
|
+
|
|
75
|
+
**Cookie-backed mutating requests now get a CSRF gate.** Generated apps now block cross-site `POST` / `PUT` / `PATCH` / `DELETE` requests when the caller is relying on cookies. The middleware skips explicit `Authorization` clients, requires a trusted `Origin` or `Referer`, and blocks `Sec-Fetch-Site: cross-site`. This matters most for cross-subdomain session setups where `SameSite=None` is intentional and origin validation has to carry the load.
|
|
76
|
+
|
|
77
|
+
**Wrangler observability is now a first-class compiler surface.** `providers.runtime.config.observability` no longer stops at `enabled: true`. The compiler now understands top-level Workers Logs sampling plus nested `logs` / `traces` blocks for `headSamplingRate`, `destinations`, `persist`, and `logs.invocationLogs`, and emits the matching `[observability]`, `[observability.logs]`, and `[observability.traces]` TOML. The config validator also rejects ambiguous double-mapping of Workers Logs sampling (`observability.headSamplingRate` plus `observability.logs.headSamplingRate`) and requires explicit per-signal `enabled` flags when trace/log export settings are present.
|
|
78
|
+
|
|
79
|
+
Pinned by `config-wiring.test.ts`, `csrf-middleware.test.ts`, `cookie-security.test.ts`, `auth-api-key-query-param.test.ts`, and the deployed negative-auth regression checks.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## v0.16.7 — May 12, 2026
|
|
84
|
+
|
|
85
|
+
### Bearer wins over cookie, and bearer plugin defaults to `requireSignature: true`
|
|
86
|
+
|
|
87
|
+
Two hardenings to the auth middleware closing a mixed-credential ambiguity and a session-token replay path.
|
|
88
|
+
|
|
89
|
+
**Bearer-vs-cookie precedence.** A request that carries both an `Authorization` header and a session `Cookie` now resolves entirely from the bearer — the cookie is dropped before `getSession()` runs. Previously the api-key and JWT fast-paths already short-circuited above cookie resolution, but session-token bearers fell through to Better Auth's `getSession()` where cookie auth resolved first and the bearer was silently ignored. That meant a request with `Cookie: alice` + `Authorization: Bearer bob-session-token` would resolve as alice, silently dropping bob's explicit credential. The inconsistency between bearer flavors (api-key/JWT bearer-wins, session-bearer cookie-wins) was the bug; making bearer win universally aligns with Better Auth's own framing of the plugin as "intended only for APIs that don't support cookies, or require Bearer tokens for authentication." Cookie remains the resolution path when no `Authorization` header is present, so browser SPA flows are unchanged.
|
|
90
|
+
|
|
91
|
+
**`requireSignature: true` on the bearer plugin.** Better Auth's `bearer` plugin defaults `requireSignature` to `false`, which means the session token emitted in the CORS-exposed `set-auth-token` response header is a literal session secret — anyone who sees it in a proxy access log, a browser dev-tools panel, or a misrouted `Referer` can replay it. Quickback now emits `bearer({ requireSignature: true })` so Better Auth signs the token server-side with `BETTER_AUTH_SECRET` and rejects unsigned bearers on verify. JWT bearers and agent-auth bearers are independently signed and unaffected. Projects that genuinely need unsigned bearers can override by passing `bearer: { requireSignature: false }` in `providers.auth.config.plugins` — user-supplied options merge on top of the secure default.
|
|
92
|
+
|
|
93
|
+
See [Authentication Security → Bearer Tokens and Cookie Precedence](/stack/auth/security#bearer-tokens-and-cookie-precedence) for the full threat model and the four credential flavors Quickback supports.
|
|
94
|
+
|
|
95
|
+
Pinned by `agent-auth.test.ts` (asserts the `bearer({ requireSignature: true })` emission shape).
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## v0.16.5 — May 12, 2026
|
|
100
|
+
|
|
101
|
+
### Flat write DSL is now the preferred authored shape, with compatibility aliases preserved
|
|
102
|
+
|
|
103
|
+
Quickback's resource DSL had drifted into an awkward split: reads already lived under `read`, while writes still sat under a nested `crud` block that no longer represented the full CRUD surface. That shape was technically supported, but it was teaching the wrong mental model.
|
|
104
|
+
|
|
105
|
+
The preferred authored surface is now flat at the table level:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
defineTable(customers, {
|
|
109
|
+
read: { ... },
|
|
110
|
+
create: { access: { roles: ["admin"] } },
|
|
111
|
+
update: { access: { roles: ["admin"] } },
|
|
112
|
+
delete: { access: { roles: ["admin"] }, mode: "soft" },
|
|
113
|
+
upsert: { access: { roles: ["admin"] } },
|
|
114
|
+
guards: { ... },
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`crud` and top-level `put` still compile in v0.16.5 as deprecated compatibility aliases. The compiler now normalizes the flat shape into the existing internal write surface, rejects mixed usage on the same resource, and warns when legacy aliases are used. Generated outputs that expose authored table policy — including `schema-registry.json` — now emit flat `create` / `update` / `delete` / `upsert` aliases alongside the legacy normalized `crud` block so older consumers keep working during the transition.
|
|
119
|
+
|
|
120
|
+
### CMS standalone actions now have an explicit placement model for multi-table features
|
|
121
|
+
|
|
122
|
+
Standalone actions were unambiguous for single-table features and for clearly table-scoped paths, but multi-table feature-root actions had no clean place to live in the CMS metadata contract. The API knew what the action was; the CMS had to guess where to render it.
|
|
123
|
+
|
|
124
|
+
The contract is now explicit:
|
|
125
|
+
|
|
126
|
+
- `cms.placement: "feature"` shows the standalone action in the table toolbar for every table in the feature
|
|
127
|
+
- `cms.placement: "tables"` with `cms.tables` shows it only on specific tables
|
|
128
|
+
- `cms.hidden: true` keeps it API-only
|
|
129
|
+
|
|
130
|
+
The compiler now emits feature-root standalone actions under a new `featureActions` bucket in `schema-registry.json` instead of duplicating them across every table entry. The CMS merges those `featureActions` into table toolbars according to placement, while record action bars remain table-scoped by default. Ambiguous multi-table feature-root standalone actions without placement now compile with a warning instead of silently landing in the wrong UI surface.
|
|
131
|
+
|
|
132
|
+
### `openapi.types` can now keep colocated SPA clients in sync from a single compile
|
|
133
|
+
|
|
134
|
+
`quickback compile` already emitted `openapi.json` and a generated `api-types.gen.ts`, but projects with a colocated SPA often kept a second copy under something like `apps/web/src/lib/api-types.gen.ts`. That second file drifted unless a separate `codegen:api` step was run after every compile.
|
|
135
|
+
|
|
136
|
+
`openapi.types` now accepts a string array as well as `true`, `false`, or a single custom path. One compile can write the same generated types file to multiple locations, for example:
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
openapi: {
|
|
140
|
+
types: ['api-types.gen.ts', 'apps/web/src/lib/api-types.gen.ts'],
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
This keeps the API root artifact and any colocated SPA copy aligned without a second codegen command. The bundled Quickback CMS and Account SPAs do not use `api-types.gen.ts` themselves — CMS is schema-registry driven, and Account uses Better Auth plus hand-written fetch helpers — so this option is aimed at user-authored client apps that live beside the compiled API.
|
|
145
|
+
|
|
146
|
+
### Generated route files and `schema-registry.json` are now emitted in a stable order
|
|
147
|
+
|
|
148
|
+
Back-to-back `quickback compile` runs could previously regenerate functionally identical route files or `schema-registry.json` with different ordering. The API behavior did not change, but the diff noise was real.
|
|
149
|
+
|
|
150
|
+
The compiler now normalizes discovery order before it builds action bundles, route files, and the schema registry. Identical logical input produces stable emitted artifacts, which means fewer no-op diffs after a recompile and cleaner review when something actually changed.
|
|
151
|
+
|
|
152
|
+
## v0.16.4 — May 12, 2026
|
|
153
|
+
|
|
154
|
+
### Compile didn't emit a migration — v0.16.3 corrupted drizzle snapshots, fixed + self-heal
|
|
155
|
+
|
|
156
|
+
The v0.16.3 release stamped a `$$__quickback_warning__$$` key onto every drizzle metadata JSON file under `quickback/drizzle/<dialect>/meta/` — both `_journal.json` and each `<n>_snapshot.json`. The original change description noted that drizzle-kit "ignores unknown top-level fields when reading journals/snapshots" — but that's only true for journals. Snapshots are parsed by a strict Zod schema that rejects extras, so on every compile after the upgrade, drizzle-kit logged each `<n>_snapshot.json` as `"data is malformed"`, lost its diff base, and silently emitted no migration on schema changes. Users hand-wrote migrations (e.g. `0033`) to compensate. Reproduced against `examples/recruitment` by adding a column to `candidates` — the recruit tree's 8 snapshots all came back malformed and zero migrations were generated.
|
|
157
|
+
|
|
158
|
+
The fix narrows `DRIZZLE_META_JSON_RE` to a journal-only matcher (`DRIZZLE_JOURNAL_JSON_RE`) so the warning is stamped only where it's safe. A new `stripJsonHeader()` helper runs over `existingFiles` when the staging step encounters a `<n>_snapshot.json`, so projects whose tree was already corrupted by v0.16.3 self-heal on the next compile: the bad header is stripped on the way into the staging dir, drizzle-kit's diff resolves correctly, and the emitted snapshot writes back without the offending key. No manual snapshot surgery required after upgrading — the next `quickback compile` quietly cleans up the prior corruption.
|
|
159
|
+
|
|
160
|
+
Pinned by `drizzle-meta-header.test.ts`: journals receive the warning key at position 0; snapshots are byte-identical input/output (no warning key); `stripJsonHeader` strips a present warning, no-ops on absent, and tolerates unparseable / array-shaped JSON.
|
|
161
|
+
|
|
162
|
+
### `account.auth.*` now drives the server, not just the UI — closes a signup-disabled bypass
|
|
163
|
+
|
|
164
|
+
A 2026-05-11 external pentest of a production Loop deployment confirmed that `account.auth.signup: false` only hid the SPA's signup screen while leaving `POST /auth/v1/sign-up/email` wide open. A new account could be created against the server, and because `account.auth.emailVerification: false` was the only emit point (it never set the server's `requireEmailVerification`), the freshly issued session was immediately usable. The same shape applied to `password`, `passkey`, and `emailOTP` — every "friendly" `account.auth.*` flag was a SPA build flag with no server counterpart. The Account UI promised "signup is off"; the server cheerfully accepted the registration.
|
|
165
|
+
|
|
166
|
+
`apps/compiler/src/providers/auth/providers/better-auth/normalize-from-account.ts` introduces a one-way normalizer that runs in `parseCompilerInput` before any generator reads `providers.auth`. It maps `account.auth.*` into the Better Auth server config — `signup → emailAndPassword.disableSignUp` (inverted), `password → emailAndPassword.enabled`, `emailVerification → emailAndPassword.requireEmailVerification`, `passkey`/`emailOTP` → plugin additions — only when the user hasn't already set the BA field explicitly. Setting both sides incompatibly (e.g. `account.auth.signup: false` AND `emailAndPassword.disableSignUp: false`) throws at compile time with a precise multi-line error rather than picking a silent winner; the silent precedence is what created the bug in the first place.
|
|
167
|
+
|
|
168
|
+
The Account SPA's `VITE_ENABLE_*` flags are now derived from the same canonicalized BA config via a new `resolveAuthFeatureFlags()` helper in `generators/spa-builder.ts`, so the SPA bundle and the server cannot drift. The helper self-normalizes (idempotent) for direct callers and unit tests. Two new SPA flags ride along: `VITE_ENABLE_API_KEYS` (driven by the `apiKey` plugin) and `VITE_ENABLE_MAGIC_LINK` (driven by the `magicLink` plugin), so the existing api-keys route in `packages/account` can self-gate the same way passkey/emailOTP already do.
|
|
169
|
+
|
|
170
|
+
**Breaking** for anyone who was implicitly relying on the open signup endpoint: projects that set `account.auth.signup: false` but actually wanted server signup to remain open must now explicitly set `providers.auth.config.emailAndPassword.disableSignUp: false` (and accept the risk). Same migration path for `emailVerification` (now actually enforced server-side when set) and the plugin flags. Loop's existing config requires no change — the next recompile + deploy starts returning `403` on `POST /auth/v1/sign-up/email`, which is exactly what the config has been claiming since the field was added.
|
|
171
|
+
|
|
172
|
+
Pinned by `account-auth-normalize.test.ts` (19 unit tests covering the normalizer + flag resolver + contradiction detection on both array- and object-form plugins) and `loop-pentest-regression.test.ts` (compiles a trimmed Loop config and asserts the generated `auth.ts` carries `disableSignUp: true`).
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## v0.16.3 — May 9, 2026
|
|
177
|
+
|
|
178
|
+
### Standalone action mount order — literal paths no longer get swallowed by sibling CRUD `/:id` routes
|
|
179
|
+
|
|
180
|
+
When a feature exposed both CRUD routes and a standalone action at the same mount prefix, Hono could register the CRUD router first. A literal standalone path like `GET /api/v1/records/today-bundle` would then hit the CRUD router's `GET /:id`, treat `"today-bundle"` as a record id, and fail in the firewall layer as a fake record lookup instead of ever reaching the standalone handler.
|
|
181
|
+
|
|
182
|
+
The compiler now attaches an explicit registration priority to generated route mounts. Feature-level standalone action routers register before sibling CRUD routers when both mount at the exact same prefix, so literal paths win and `/:id` remains the fallback. The regression is pinned in `standalone-route-mount-order.test.ts`, which asserts both emitted routes and the final mount order in `src/index.ts`.
|
|
183
|
+
|
|
184
|
+
This is a routing-correctness fix, not a public API redesign. No user code changes are required, and existing standalone action paths do not need to be renamed. Recompile and shared-prefix standalone routes resolve correctly.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
7
188
|
## v0.16.1 — May 9, 2026
|
|
8
189
|
|
|
9
190
|
### Cloudflare ASSETS canonicalization — worker SPA emits no longer 307-loop
|
|
@@ -176,7 +357,7 @@ Test coverage: `auth-email-wiring.test.ts` was updated to assert the new shape
|
|
|
176
357
|
|
|
177
358
|
### Coming next — `id` field auto-injection (v0.14.8)
|
|
178
359
|
|
|
179
|
-
The compiler treats `id` as load-bearing across CRUD/action route generators, FK probing, access checks, OpenAPI emission, and CMS — but doesn't add it for you the way it adds `createdAt`/`modifiedAt`/`createdBy`/`modifiedBy` (or `organizationId` in org-scoped features, or `deletedAt`/`deletedBy` for soft-delete tables).
|
|
360
|
+
The compiler treats `id` as load-bearing across CRUD/action route generators, FK probing, access checks, OpenAPI emission, and CMS — but doesn't add it for you the way it adds `createdAt`/`modifiedAt`/`createdBy`/`modifiedBy` (or `organizationId` in org-scoped features, or `deletedAt`/`deletedBy` for soft-delete tables). At the time of v0.14.7, tables that omitted `id` (or used a non-`id` single PK like `userId.primaryKey()`, or a compound `primaryKey({ columns: [...] })` constraint) were not yet supported by the generated route and OpenAPI pipeline.
|
|
180
361
|
|
|
181
362
|
**Agreed direction:** mirror `injectAuditFields` with a new `injectIdField` that runs unconditionally — including on junction tables. Tables with no PK or a non-`id` PK get an `id` column auto-injected; existing column-level `.primaryKey()` on a non-`id` column gets demoted to `.notNull()`; `primaryKey({ columns: [...] })` constraints get rewritten to `uniqueIndex().on(...)`. The cost (one extra column per junction row) is minimal and closes the asymmetry — every table participating in routes gets a single string-typed `id`, just like every table gets `createdAt`. Migration tail (existing D1 databases need an ADD COLUMN + index rewrite per affected table) is generated alongside.
|
|
182
363
|
|
|
@@ -194,7 +375,7 @@ Filed in `research/attendvip-v014-mcp-and-firewall-gaps.md` after AttendVIP patc
|
|
|
194
375
|
|
|
195
376
|
**2. Auth middleware ignored `Authorization: Bearer <api-key>`.** MCP clients (claude.ai, etc.) only set `Authorization: Bearer ...`. The api-key block read from `x-api-key` header / `?api_key=` / `?key=` query but not from `Authorization`; the JWT fast-path narrowly gated on `bearerToken.startsWith('eyJ')`. Non-JWT bearers fell through to BA session auth, which doesn't recognise api-keys, so the request authenticated as anonymous and `tools/list` returned only PUBLIC tools. Fix: api-key extraction now also accepts a non-JWT `Authorization: Bearer <token>` as the key candidate. Three transports for one credential — header / query / Bearer.
|
|
196
377
|
|
|
197
|
-
**3. `auth.roleHierarchy` was silently inert for runtime role checks.** A user configured `auth.roleHierarchy: ['owner', 'admin', 'member']` and expected an `owner` to satisfy any check requiring `admin` or `member`. But the api-key + JWT fast-paths populated `ctx.roles` with the single org-member role, and the access checker did strict intersection — owner ∩ {admin, member} =
|
|
378
|
+
**3. `auth.roleHierarchy` was silently inert for runtime role checks.** A user configured `auth.roleHierarchy: ['owner', 'admin', 'member']` and expected an `owner` to satisfy any check requiring `admin` or `member`. But the api-key + JWT fast-paths populated `ctx.roles` with the single org-member role, and the access checker did strict intersection — `owner ∩ {admin, member} = ∅` → 403. Fix: at the api-key, JWT fast-path, AND BA session paths, expand the user's role via `auth.roleHierarchy` so a higher role inherits all lower-role privileges. The hierarchy is auto-normalized — users who write the array reversed (`['owner', 'admin', 'member']` instead of the documented `['member', 'admin', 'owner']`) now get the same correct expansion.
|
|
198
379
|
|
|
199
380
|
**4. Team-firewall predicate hardcoded `eq(table.teamId, ctx.activeTeamId!)` even when no team was active.** The `!` non-null assertion lied at runtime — api-keys, JWTs, and sessions without an active team carry `undefined`. The resulting SQL was `team_id = NULL` which matches nothing, so api-key callers saw zero rows on team-scoped resources. Fix: emit the team predicate as `(ctx.activeTeamId ? eq(...) : undefined)` — drizzle's `and(...)` drops `undefined`, so the WHERE collapses to the org scope only. Org and owner predicates are deliberately NOT softened the same way (those are security boundaries, not optional scopes).
|
|
200
381
|
|
|
@@ -288,17 +288,19 @@ account: {
|
|
|
288
288
|
|
|
289
289
|
### Auth Feature Flags
|
|
290
290
|
|
|
291
|
-
Control which authentication features are
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
|
296
|
-
|
|
297
|
-
| `auth.
|
|
298
|
-
| `auth.
|
|
299
|
-
| `auth.
|
|
300
|
-
| `auth.
|
|
301
|
-
| `auth.
|
|
291
|
+
Control which authentication features are exposed. Disabled features are excluded from the Account UI bundle at compile time (routes removed before the Vite build, keeping bundle sizes minimal) **and** enforced on the server side via the Better Auth config — so "signup off" actually closes `POST /auth/v1/sign-up/email`, not just the SPA's signup screen.
|
|
292
|
+
|
|
293
|
+
`account.auth.*` is a shorthand for `providers.auth.config` — the compiler maps each flag onto the Better Auth server config before any code is generated. You can write either side directly; setting both incompatibly (e.g. `account.auth.signup: false` and `emailAndPassword.disableSignUp: false`) fails the compile with a precise error rather than picking a silent winner.
|
|
294
|
+
|
|
295
|
+
| Flag | Type | Default | Maps to (server) | Description |
|
|
296
|
+
|------|------|---------|------------------|-------------|
|
|
297
|
+
| `auth.password` | `boolean` | `true` | `emailAndPassword.enabled` | Email/password authentication — both server endpoint and UI |
|
|
298
|
+
| `auth.emailOTP` | `boolean` | `false` | adds `emailOtp` plugin | Email one-time password login — adds plugin server-side, surfaces UI |
|
|
299
|
+
| `auth.passkey` | `boolean` | `false` | adds `passkey` plugin | WebAuthn/FIDO2 passkey authentication — adds plugin server-side, surfaces UI |
|
|
300
|
+
| `auth.signup` | `boolean` | `true` | `emailAndPassword.disableSignUp` (inverted) | Self-service account registration — false hides the UI **and** rejects the server endpoint with 403 |
|
|
301
|
+
| `auth.organizations` | `boolean` | `false` | UI surface only — server gating lives under `features.organizations` | Multi-tenant organization management UI (dashboard, invitations, roles). The BA `organization` plugin is auto-added by `features.organizations` for server-side reasons (org tables) independent of this UI flag |
|
|
302
|
+
| `auth.admin` | `boolean` | `false` | UI surface only — BA `admin` plugin is auto-added when `features.organizations` is on | Admin panel for user management in the Account SPA |
|
|
303
|
+
| `auth.emailVerification` | `boolean` | `false` | `emailAndPassword.requireEmailVerification` | Require email verification before sessions are issued. False = sessions usable immediately after signup |
|
|
302
304
|
|
|
303
305
|
## Trusted Origins
|
|
304
306
|
|
|
@@ -18,6 +18,49 @@ providers: {
|
|
|
18
18
|
}
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
### Runtime Options
|
|
22
|
+
|
|
23
|
+
| Option | Type | Description |
|
|
24
|
+
|--------|------|-------------|
|
|
25
|
+
| `compatibilityDate` | `string` | Emits Cloudflare `compatibility_date` in `wrangler.toml`. |
|
|
26
|
+
| `placement.mode` | `"smart" \| "standard"` | Emits Cloudflare's `[placement]` block. |
|
|
27
|
+
| `observability.enabled` | `boolean` | Emits top-level Workers Logs persistence under `[observability]`. |
|
|
28
|
+
| `observability.headSamplingRate` | `number` | Top-level Workers Logs sample rate from `0` to `1`. |
|
|
29
|
+
| `observability.logs.enabled` | `boolean` | Emits `[observability.logs]`. |
|
|
30
|
+
| `observability.logs.invocationLogs` | `boolean` | Enables or suppresses invocation logs. |
|
|
31
|
+
| `observability.logs.destinations` | `string[]` | Named log export destinations configured in Cloudflare. |
|
|
32
|
+
| `observability.logs.headSamplingRate` | `number` | Workers Logs sample rate from `0` to `1`. |
|
|
33
|
+
| `observability.logs.persist` | `boolean` | Keeps exported logs in the Cloudflare dashboard. |
|
|
34
|
+
| `observability.traces.enabled` | `boolean` | Emits `[observability.traces]`. |
|
|
35
|
+
| `observability.traces.destinations` | `string[]` | Named trace export destinations configured in Cloudflare. |
|
|
36
|
+
| `observability.traces.headSamplingRate` | `number` | Workers Traces sample rate from `0` to `1`. |
|
|
37
|
+
| `observability.traces.persist` | `boolean` | Keeps exported traces in the Cloudflare dashboard. |
|
|
38
|
+
| `routes` | `{ pattern, custom_domain? }[]` | Custom domain routes for the generated Worker. |
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
providers: {
|
|
42
|
+
runtime: defineRuntime("cloudflare", {
|
|
43
|
+
compatibilityDate: "2026-05-13",
|
|
44
|
+
placement: { mode: "smart" },
|
|
45
|
+
observability: {
|
|
46
|
+
enabled: true,
|
|
47
|
+
logs: {
|
|
48
|
+
enabled: true,
|
|
49
|
+
invocationLogs: false,
|
|
50
|
+
destinations: ["logs-prod"],
|
|
51
|
+
headSamplingRate: 0.6,
|
|
52
|
+
},
|
|
53
|
+
traces: {
|
|
54
|
+
enabled: true,
|
|
55
|
+
destinations: ["otel-prod"],
|
|
56
|
+
headSamplingRate: 0.05,
|
|
57
|
+
persist: false,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
21
64
|
## Database Providers
|
|
22
65
|
|
|
23
66
|
| Provider | Description |
|
|
@@ -59,6 +102,7 @@ providers: {
|
|
|
59
102
|
| `auditDatabaseName` | `string` | `"{app}-audit"` | D1 database name for audit events |
|
|
60
103
|
| `auditDatabaseId` | `string` | — | Explicit D1 database ID for audit events |
|
|
61
104
|
| `experimentalRemote` | `{ auth?, features?, audit?, webhooks?, files? }` | `{}` | Per-binding `experimental_remote = true` flag for `wrangler dev` (see [below](#sharing-deployed-d1-in-dev-experimental_remote)) |
|
|
105
|
+
| `realtime` | `boolean \| { enabled?, wsTicket? }` | `false` | Enables the Broadcaster Durable Object and optional resource-scoped ws-ticket auth (see [below](#realtime-broadcast-config)) |
|
|
62
106
|
| `webhookAdminRoles` | `string[]` | `["owner", "admin"]` | Org roles allowed to manage webhook endpoints |
|
|
63
107
|
|
|
64
108
|
#### Audit Database
|
|
@@ -125,6 +169,49 @@ Only `true` flips the flag on; `false` or omitted leaves the binding local. Off
|
|
|
125
169
|
> `experimental_remote` is a Wrangler dev feature. A flagged binding hits the deployed D1 from `wrangler dev`, so any write goes to production. Only enable for bindings you've decided are safe to read/write from local dev.
|
|
126
170
|
|
|
127
171
|
|
|
172
|
+
#### Realtime Broadcast Config
|
|
173
|
+
|
|
174
|
+
Set `realtime: true` to enable the generated Broadcaster Durable Object with the default organization-scoped routing model:
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
providers: {
|
|
178
|
+
database: defineDatabase("cloudflare-d1", {
|
|
179
|
+
realtime: true,
|
|
180
|
+
}),
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
For relationship-authorized resource scopes, use the object form:
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
providers: {
|
|
188
|
+
database: defineDatabase("cloudflare-d1", {
|
|
189
|
+
realtime: {
|
|
190
|
+
wsTicket: {
|
|
191
|
+
role: "attendee",
|
|
192
|
+
requestField: "eventId",
|
|
193
|
+
scopeTable: "events",
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
}),
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
`wsTicket` tells the compiler how to authorize `/broadcast/v1/ws-ticket` and what scope to stamp into the short-lived websocket ticket:
|
|
201
|
+
|
|
202
|
+
- `role`: an authz role declared under `authz.roles` that uses a direct relationship (`{ via: "..." }`)
|
|
203
|
+
- `requestField`: the JSON body field the client posts to `/broadcast/v1/ws-ticket`
|
|
204
|
+
- `scopeTable`: the parent resource table that defines the broadcast scope key
|
|
205
|
+
|
|
206
|
+
In other words: the relationship table proves access, and the `scopeTable` row defines the channel. For an attendee flow, `guests` (or RSVP) would be the relationship evidence and `events` would be the `scopeTable`.
|
|
207
|
+
|
|
208
|
+
Quickback keeps Better Auth as the front door, then mints its own 60-second websocket ticket after the authz check succeeds. The generated `createRealtime()` helper and Broadcaster share the same targeting model:
|
|
209
|
+
|
|
210
|
+
- string target: historical `organizationId` shorthand
|
|
211
|
+
- object target: `{ scopeKey?, organizationId?, userId? }`
|
|
212
|
+
|
|
213
|
+
See [Realtime](/stack/realtime) for the client-side connection flow and helper examples.
|
|
214
|
+
|
|
128
215
|
<Callout>
|
|
129
216
|
`usePlurals` only affects **auth tables** generated by Better Auth (e.g. `user` vs `users`, `session` vs `sessions`). Feature table names come directly from your Drizzle schema definitions — whatever you pass to `sqliteTable()` or `pgTable()` is used as-is. The `namingConvention` setting applies to both auth and feature column names.
|
|
130
217
|
</Callout>
|
|
@@ -46,9 +46,7 @@ export default defineTable(posts, {
|
|
|
46
46
|
read: {
|
|
47
47
|
access: { roles: ['user', 'admin'] },
|
|
48
48
|
},
|
|
49
|
-
|
|
50
|
-
create: { access: { roles: ['admin'] } },
|
|
51
|
-
},
|
|
49
|
+
create: { access: { roles: ['admin'] } },
|
|
52
50
|
});
|
|
53
51
|
|
|
54
52
|
// Public data (no ownership filtering)
|
|
@@ -57,11 +55,9 @@ export default defineTable(pages, {
|
|
|
57
55
|
read: {
|
|
58
56
|
access: { roles: ['PUBLIC'] },
|
|
59
57
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
delete: { access: { roles: ['admin'] } },
|
|
64
|
-
},
|
|
58
|
+
create: { access: { roles: ['admin'] } },
|
|
59
|
+
update: { access: { roles: ['admin'] } },
|
|
60
|
+
delete: { access: { roles: ['admin'] } },
|
|
65
61
|
});
|
|
66
62
|
```
|
|
67
63
|
|
|
@@ -76,9 +72,7 @@ Use the `PUBLIC` role to expose routes without authentication. This works the sa
|
|
|
76
72
|
read: {
|
|
77
73
|
access: { roles: ['PUBLIC'] }, // GET / and GET /:id — no auth required
|
|
78
74
|
},
|
|
79
|
-
|
|
80
|
-
create: { access: { roles: ['admin'] } }, // Admin only
|
|
81
|
-
}
|
|
75
|
+
create: { access: { roles: ['admin'] } }, // Admin only
|
|
82
76
|
```
|
|
83
77
|
|
|
84
78
|
## Role-Based Access
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Access - Role & Condition-Based Access Control
|
|
2
2
|
|
|
3
|
-
Define who can perform
|
|
3
|
+
Define who can perform read and write operations and under what conditions.
|
|
4
4
|
|
|
5
5
|
## Basic Usage
|
|
6
6
|
|
|
@@ -24,11 +24,9 @@ export default defineTable(applications, {
|
|
|
24
24
|
read: {
|
|
25
25
|
access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] },
|
|
26
26
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
delete: { access: { roles: ["owner", "hiring-manager"] } },
|
|
31
|
-
},
|
|
27
|
+
create: { access: { roles: ["owner", "hiring-manager", "recruiter"] } },
|
|
28
|
+
update: { access: { roles: ["owner", "hiring-manager", "recruiter"] } },
|
|
29
|
+
delete: { access: { roles: ["owner", "hiring-manager"] } },
|
|
32
30
|
});
|
|
33
31
|
```
|
|
34
32
|
|
|
@@ -51,10 +49,8 @@ Then in your resource definitions:
|
|
|
51
49
|
|
|
52
50
|
```typescript
|
|
53
51
|
read: { access: { roles: ["member+"] } }, // member, admin, owner
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
delete: { access: { roles: ["owner"] } }, // owner only (no +)
|
|
57
|
-
}
|
|
52
|
+
create: { access: { roles: ["admin+"] } }, // admin, owner
|
|
53
|
+
delete: { access: { roles: ["owner"] } }, // owner only (no +)
|
|
58
54
|
```
|
|
59
55
|
|
|
60
56
|
The `+` suffix expands at compile time — `"member+"` becomes `["member", "admin", "owner"]` in the generated code. You can mix hierarchical and exact roles: `roles: ["member+", "finance"]` expands to `["member", "admin", "owner", "finance"]`.
|
|
@@ -118,11 +114,9 @@ access: {
|
|
|
118
114
|
|
|
119
115
|
// CMS-internal resource: only platform admins
|
|
120
116
|
read: { access: { userRole: ['admin'] } },
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
delete: { access: { userRole: ['admin'] } },
|
|
125
|
-
}
|
|
117
|
+
create: { access: { userRole: ['admin'] } },
|
|
118
|
+
update: { access: { userRole: ['admin'] } },
|
|
119
|
+
delete: { access: { userRole: ['admin'] } },
|
|
126
120
|
```
|
|
127
121
|
|
|
128
122
|
When `roles` and `userRole` both appear in a single `Access` node, they're combined with AND — the user must satisfy both. Use `or:` to express "one or the other".
|
|
@@ -153,7 +147,7 @@ access: { roles: ["PUBLIC"] }
|
|
|
153
147
|
|
|
154
148
|
**Important:**
|
|
155
149
|
- `PUBLIC` skips authentication and role checks — anyone can call the endpoint
|
|
156
|
-
- **`PUBLIC` is the explicit, uppercase opt-in for unauthenticated access.** It works on every access node — reads,
|
|
150
|
+
- **`PUBLIC` is the explicit, uppercase opt-in for unauthenticated access.** It works on every access node — reads, top-level writes (`create`/`update`/`delete`/`upsert`), views, and actions. The compiler trusts the marker; row-level safety comes from the firewall, masking, and (for token-gated endpoints like RSVP confirm, magic-link redemption, List-Unsubscribe-Post, webhook ingest) your handler's own validation. Anonymous write endpoints typically pair `roles: ["PUBLIC"]` with `firewall: { exception: true }` on the resource so the row predicate doesn't reject every unauthenticated caller.
|
|
157
151
|
- **Firewall still applies** — data is scoped by the firewall (organization, owner, team)
|
|
158
152
|
- Every `PUBLIC` action invocation is **mandatory audit logged** to the security audit table (IP address, input, result, timing)
|
|
159
153
|
- The wildcard `"*"` is **not supported** — using it throws a compile-time error
|
|
@@ -172,9 +166,7 @@ The firewall WHERE clause is always enforced. If no `organizationId` is provided
|
|
|
172
166
|
export default defineTable(listings, {
|
|
173
167
|
firewall: [{ field: 'organizationId', equals: 'ctx.activeOrgId' }],
|
|
174
168
|
read: { access: { roles: ["PUBLIC"] } }, // Public browsing + detail
|
|
175
|
-
|
|
176
|
-
create: { access: { roles: ["admin", "member"] } }, // Auth required to create
|
|
177
|
-
},
|
|
169
|
+
create: { access: { roles: ["admin", "member"] } }, // Auth required to create
|
|
178
170
|
});
|
|
179
171
|
```
|
|
180
172
|
|
|
@@ -196,11 +188,9 @@ Use `roles: ["USER"]` for resources where each user only sees their own records.
|
|
|
196
188
|
export default defineTable(todos, {
|
|
197
189
|
firewall: [{ field: 'userId', equals: 'ctx.userId' }],
|
|
198
190
|
read: { access: { roles: ["USER"] } },
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
delete: { access: { roles: ["USER"] } },
|
|
203
|
-
},
|
|
191
|
+
create: { access: { roles: ["USER"] } },
|
|
192
|
+
update: { access: { roles: ["USER"] } },
|
|
193
|
+
delete: { access: { roles: ["USER"] } },
|
|
204
194
|
});
|
|
205
195
|
```
|
|
206
196
|
|
|
@@ -444,9 +434,9 @@ The validator and resolver reject:
|
|
|
444
434
|
- `+` hierarchy suffix on a relationship-role name (terminal, like pseudo-roles).
|
|
445
435
|
- Relationship-roles in `masking.show` / `actions.access` (deferred surfaces — see the table above).
|
|
446
436
|
|
|
447
|
-
## Read &
|
|
437
|
+
## Read & Write Configuration
|
|
448
438
|
|
|
449
|
-
Reads (`GET /` and `GET /:id`) live under `read:`; mutations live under `
|
|
439
|
+
Reads (`GET /` and `GET /:id`) live under `read:`; mutations live under top-level `create:`, `update:`, `delete:`, and `upsert:`. See [Read](/compiler/definitions/read) for the full read pipeline reference.
|
|
450
440
|
|
|
451
441
|
```typescript
|
|
452
442
|
read: {
|
|
@@ -462,35 +452,33 @@ read: {
|
|
|
462
452
|
},
|
|
463
453
|
}
|
|
464
454
|
|
|
465
|
-
|
|
455
|
+
create: {
|
|
466
456
|
// CREATE - POST /resource
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
stage: 'applied',
|
|
471
|
-
},
|
|
457
|
+
access: { roles: ["owner", "hiring-manager", "recruiter"] },
|
|
458
|
+
defaults: { // Default values for new records
|
|
459
|
+
stage: 'applied',
|
|
472
460
|
},
|
|
461
|
+
},
|
|
473
462
|
|
|
463
|
+
update: {
|
|
474
464
|
// UPDATE - PATCH /resource/:id
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
]
|
|
481
|
-
},
|
|
465
|
+
access: {
|
|
466
|
+
or: [
|
|
467
|
+
{ roles: ["hiring-manager", "recruiter"] },
|
|
468
|
+
{ roles: ["interviewer"], record: { stage: { equals: "interview" } } }
|
|
469
|
+
]
|
|
482
470
|
},
|
|
471
|
+
},
|
|
483
472
|
|
|
473
|
+
delete: {
|
|
484
474
|
// DELETE - DELETE /resource/:id
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
},
|
|
475
|
+
access: { roles: ["owner", "hiring-manager"] },
|
|
476
|
+
mode: "soft", // 'soft' (default) or 'hard'
|
|
477
|
+
},
|
|
489
478
|
|
|
479
|
+
upsert: {
|
|
490
480
|
// PUT - PUT /resource/:id (only when generateId: false + guards: false)
|
|
491
|
-
|
|
492
|
-
access: { roles: ["hiring-manager", "sync-service"] },
|
|
493
|
-
},
|
|
481
|
+
access: { roles: ["hiring-manager", "sync-service"] },
|
|
494
482
|
}
|
|
495
483
|
```
|
|
496
484
|
|
|
@@ -601,17 +589,15 @@ access: {
|
|
|
601
589
|
For complex access logic that can't be expressed declaratively, use a function:
|
|
602
590
|
|
|
603
591
|
```typescript
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
return membership.canEdit;
|
|
614
|
-
}
|
|
592
|
+
update: {
|
|
593
|
+
access: async (ctx, record) => {
|
|
594
|
+
// Custom logic - return true to allow, false to deny
|
|
595
|
+
if (ctx.roles.includes('admin')) return true;
|
|
596
|
+
if (record.ownerId === ctx.userId) return true;
|
|
597
|
+
|
|
598
|
+
// Check custom business logic
|
|
599
|
+
const membership = await checkTeamMembership(ctx.userId, record.teamId);
|
|
600
|
+
return membership.canEdit;
|
|
615
601
|
}
|
|
616
602
|
}
|
|
617
603
|
```
|
|
@@ -19,11 +19,9 @@ export const contacts = q.table("contacts", {
|
|
|
19
19
|
export default defineTable(contacts, {
|
|
20
20
|
firewall: [{ field: 'organizationId', equals: 'ctx.activeOrgId' }],
|
|
21
21
|
read: { access: { roles: ["member+"] } },
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
delete: { access: { roles: ["admin+"] }, mode: "soft" },
|
|
26
|
-
},
|
|
22
|
+
create: { access: { roles: ["member+"] } },
|
|
23
|
+
update: { access: { roles: ["member+"] } },
|
|
24
|
+
delete: { access: { roles: ["admin+"] }, mode: "soft" },
|
|
27
25
|
guards: { createable: ["address", "name"] },
|
|
28
26
|
});
|
|
29
27
|
|
|
@@ -44,11 +42,9 @@ export default feature("contacts", {
|
|
|
44
42
|
},
|
|
45
43
|
firewall: [{ field: 'organizationId', equals: 'ctx.activeOrgId' }],
|
|
46
44
|
read: { access: { roles: ["member+"] } },
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
delete: { access: { roles: ["admin+"] }, mode: "soft" },
|
|
51
|
-
},
|
|
45
|
+
create: { access: { roles: ["member+"] } },
|
|
46
|
+
update: { access: { roles: ["member+"] } },
|
|
47
|
+
delete: { access: { roles: ["admin+"] }, mode: "soft" },
|
|
52
48
|
guards: { createable: ["address", "name"] },
|
|
53
49
|
});
|
|
54
50
|
```
|
|
@@ -57,7 +53,7 @@ Type inference still works — `typeof import("./contacts").default.$infer` give
|
|
|
57
53
|
|
|
58
54
|
## How it works
|
|
59
55
|
|
|
60
|
-
`feature(name, config)` is a **compile-time sugar**, not a runtime abstraction. When the compiler sees `export default feature(...)`, it rewrites the source to the canonical two-export form before any parsing runs. Every downstream layer — dialect pass, audit injection, security contracts,
|
|
56
|
+
`feature(name, config)` is a **compile-time sugar**, not a runtime abstraction. When the compiler sees `export default feature(...)`, it rewrites the source to the canonical two-export form before any parsing runs. Every downstream layer — dialect pass, audit injection, security contracts, generated routes, OpenAPI, MCP tools, RLS emission — runs on the same Drizzle source it always did. Zero runtime cost; zero semantic difference from `q.table()` + `defineTable()`.
|
|
61
57
|
|
|
62
58
|
That means:
|
|
63
59
|
|
|
@@ -341,10 +341,8 @@ export default defineTable(jobs, {
|
|
|
341
341
|
// via record-level access conditions on /:id
|
|
342
342
|
access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] },
|
|
343
343
|
},
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
// (single-record GET inherits read.access, with optional record-level overrides)
|
|
347
|
-
},
|
|
344
|
+
// Use record conditions to allow public jobs OR owned jobs on GET /:id
|
|
345
|
+
// (single-record GET inherits read.access, with optional record-level overrides)
|
|
348
346
|
// ...
|
|
349
347
|
});
|
|
350
348
|
```
|