@quickback-dev/cli 0.66.24 → 0.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +4 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/cursor/quickback.mdc +6 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/api-client.d.ts +2 -0
- package/dist/lib/api-client.d.ts.map +1 -1
- package/dist/lib/api-client.js.map +1 -1
- package/dist/skill/SKILL.md +6 -0
- package/dist/skill/docs/api/actions.md +1 -1
- package/dist/skill/docs/api/errors.md +9 -6
- package/dist/skill/docs/api/typescript.md +3 -1
- package/dist/skill/docs/configure/providers.md +3 -0
- package/dist/skill/docs/define/access.md +12 -1
- package/dist/skill/docs/define/actions/scoped-db.md +79 -4
- package/dist/skill/docs/define/areas.md +3 -1
- package/dist/skill/docs/define/arrows.md +70 -9
- package/dist/skill/docs/define/authz-roles.md +2 -1
- package/dist/skill/docs/define/fga.md +4 -2
- package/dist/skill/docs/define/firewall.md +6 -3
- package/dist/skill/docs/define/permissions.md +1 -1
- package/dist/skill/docs/define/schema.md +1 -1
- package/dist/skill/docs/define/scopes.md +1 -1
- package/dist/skill/docs/define/triggers.md +13 -1
- package/dist/skill/docs/platform/auth/plugins/subscriptions.md +27 -3
- package/dist/skill/docs/platform/auth/security.md +23 -1
- package/dist/skill/docs/platform/database/neon.md +3 -1
- package/dist/skill/docs/platform/push/index.md +1 -1
- package/dist/skill/docs/tooling/output.md +19 -0
- package/dist/skill/docs/ui/account/features/admin.md +29 -0
- package/dist/skill/docs/ui/account/features/sessions.md +2 -0
- package/package.json +1 -1
- package/src/cursor/quickback.mdc +6 -0
- package/src/skill/SKILL.md +6 -0
- package/src/skill/docs/api/actions.md +1 -1
- package/src/skill/docs/api/errors.md +9 -6
- package/src/skill/docs/api/typescript.md +3 -1
- package/src/skill/docs/configure/providers.md +3 -0
- package/src/skill/docs/define/access.md +12 -1
- package/src/skill/docs/define/actions/scoped-db.md +79 -4
- package/src/skill/docs/define/areas.md +3 -1
- package/src/skill/docs/define/arrows.md +70 -9
- package/src/skill/docs/define/authz-roles.md +2 -1
- package/src/skill/docs/define/fga.md +4 -2
- package/src/skill/docs/define/firewall.md +6 -3
- package/src/skill/docs/define/permissions.md +1 -1
- package/src/skill/docs/define/schema.md +1 -1
- package/src/skill/docs/define/scopes.md +1 -1
- package/src/skill/docs/define/triggers.md +13 -1
- package/src/skill/docs/platform/auth/plugins/subscriptions.md +27 -3
- package/src/skill/docs/platform/auth/security.md +23 -1
- package/src/skill/docs/platform/database/neon.md +3 -1
- package/src/skill/docs/platform/push/index.md +1 -1
- package/src/skill/docs/tooling/output.md +19 -0
- package/src/skill/docs/ui/account/features/admin.md +29 -0
- package/src/skill/docs/ui/account/features/sessions.md +2 -0
|
@@ -69,14 +69,26 @@ the permission required **at the target object**, and it participates in the
|
|
|
69
69
|
permission composition graph (resolution + cycle detection) exactly like a
|
|
70
70
|
`{ permissionRef }`.
|
|
71
71
|
|
|
72
|
-
**
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
**Target restriction.** An arrow's target permission may reduce to either:
|
|
73
|
+
|
|
74
|
+
- **Org-membership roles** (`admin` / `owner` / `member`) — directly or through
|
|
75
|
+
a `permissionRef` / `anyOf` / `allOf` of org roles. The hop binds to the
|
|
76
|
+
caller's verified active-org claim (`ctx.activeOrgId`). So
|
|
77
|
+
`org:admin = anyOf(role('admin'), role('owner'))` is the canonical org target.
|
|
78
|
+
- **A single relationship** (relation-backed target, non-recursive hops only) —
|
|
79
|
+
the FK hop inherits a relationship the caller holds on the hopped-to parent
|
|
80
|
+
object. "Organizers of the parent event can see its sessions" is a
|
|
81
|
+
`{ arrowRef: 'sessionEvent', permission: 'event:organizer' }` arm where
|
|
82
|
+
`event:organizer` reduces to the `organizerOf` relationship. The arrow's `fk`
|
|
83
|
+
and the relationship's `resource.column` must address the **same parent-id
|
|
84
|
+
space** (the column the FK points at) — for a multi-hop relationship, its
|
|
85
|
+
first hop's `on` column, exactly as a `via:` arm reads it. See
|
|
86
|
+
[Emit shape 3](#emit-shape-3--relation-backed-target) for the composition.
|
|
87
|
+
|
|
88
|
+
A target that references a **scoped role**, a **pseudo-role**, a `not`, or a
|
|
89
|
+
**nested arrow** — or that **mixes** a relation with org roles, or pairs a
|
|
90
|
+
relation-backed target with a **recursive** hop — is a **compile error** (never
|
|
91
|
+
a silent allow). Those remain a documented fast-follow.
|
|
80
92
|
|
|
81
93
|
## Using the permission in a firewall
|
|
82
94
|
|
|
@@ -155,6 +167,54 @@ arrow is valid on either provider. Drizzle interpolates the column/table
|
|
|
155
167
|
surface (the FK column and tables are compile-time identifiers; the only
|
|
156
168
|
runtime value is the signed org claim).
|
|
157
169
|
|
|
170
|
+
## Emit shape 3 — relation-backed target
|
|
171
|
+
|
|
172
|
+
When the target permission reduces to a single relationship, the FK hop
|
|
173
|
+
composes with that relationship's subquery on the parent object. For
|
|
174
|
+
`sessionEvent: { from: 'session', fk: 'eventId', to: 'event' }` with target
|
|
175
|
+
`organizerOf` (keyed by `eventId`), an `{ arrowRef: 'sessionEvent' }` arm on a
|
|
176
|
+
resource constrained by `sessionId` lowers to:
|
|
177
|
+
|
|
178
|
+
```sql
|
|
179
|
+
agenda_item.sessionId IN (
|
|
180
|
+
SELECT session.id FROM session
|
|
181
|
+
WHERE session.eventId IN (
|
|
182
|
+
-- the organizerOf relationship subquery: the events the caller organizes
|
|
183
|
+
SELECT event_staff.eventId FROM event_staff
|
|
184
|
+
WHERE event_staff.userId = ? -- ? = ctx.userId
|
|
185
|
+
AND event_staff.role = 'organizer'
|
|
186
|
+
AND <event_staff's own firewall — soft-delete>
|
|
187
|
+
)
|
|
188
|
+
)
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
The inner subquery is the **same** [`via:` relationship
|
|
192
|
+
subquery](/compiler/definitions/firewall#relationship-based-scoping-via) — it
|
|
193
|
+
AND's the relationship table's own firewall (soft-delete) and binds `ctx.userId`
|
|
194
|
+
**fail-closed** (a null caller short-circuits to `1 = 0`). So a relation-backed
|
|
195
|
+
arrow inherits every `via:` guarantee; the FK hop just maps the resource's
|
|
196
|
+
column to the parent id space the relationship returns. The outer resource
|
|
197
|
+
firewall stays the outermost AND, so tenant isolation is never bypassed.
|
|
198
|
+
|
|
199
|
+
Relation-backed targets are **non-recursive only** — a recursive self-hop with
|
|
200
|
+
a relation target is a compile error (the bounded closure seed needs the
|
|
201
|
+
org-membership form; relation seeding is a fast-follow).
|
|
202
|
+
|
|
203
|
+
On **Postgres** the RLS policy enforces the same composition. The arrow lowers
|
|
204
|
+
to a `SECURITY DEFINER` helper that returns the `session` rows whose `eventId`
|
|
205
|
+
is in the caller's `public.qb_rel_organizer_of()` set — the same relationship
|
|
206
|
+
helper a `via:` arm calls — and the generated API reads through that same
|
|
207
|
+
helper, so the database and the API run one lookup:
|
|
208
|
+
|
|
209
|
+
```sql
|
|
210
|
+
agenda_item.session_id IN (SELECT r.id FROM public.qb_arrow_session_event_id_<hash>() r)
|
|
211
|
+
-- qb_arrow_…: SELECT f.* FROM session f
|
|
212
|
+
-- WHERE f.event_id IN (SELECT r.event_id FROM public.qb_rel_organizer_of() r)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
A relationship whose `subject` binds a claim the Worker never writes into the
|
|
216
|
+
transaction stays API-enforced there, exactly as its `via:` arm does.
|
|
217
|
+
|
|
158
218
|
## Tenant isolation semantics
|
|
159
219
|
|
|
160
220
|
Arrows are tenant-safe by construction. Three guarantees, all enforced at
|
|
@@ -260,7 +320,8 @@ authz.permissionMaxDepth?: Record<string, number>
|
|
|
260
320
|
- Every `{ arrowRef }` in a permission must name a declared `authz.arrows[*]`
|
|
261
321
|
entry, and the arrow's `fk` / `to` are checked against the real schema at
|
|
262
322
|
compile time.
|
|
263
|
-
- The target `permission` must reduce to org-membership roles
|
|
323
|
+
- The target `permission` must reduce to org-membership roles **or** a single
|
|
324
|
+
relationship (relation-backed targets are non-recursive only).
|
|
264
325
|
- See [Permissions](/define/permissions) for the expression DSL
|
|
265
326
|
the arrow leaf lives in, and [Firewall — named permissions](/define/firewall#named-permissions-permission)
|
|
266
327
|
for how the resulting `{ permission }` arm sits inside a firewall. The
|
|
@@ -64,11 +64,12 @@ export default defineAction({
|
|
|
64
64
|
|
|
65
65
|
### Rule shapes
|
|
66
66
|
|
|
67
|
-
Each entry in `authz.roles` is one of
|
|
67
|
+
Each entry in `authz.roles` is one of five shapes:
|
|
68
68
|
|
|
69
69
|
| Shape | Meaning |
|
|
70
70
|
|---|---|
|
|
71
71
|
| `{ roles: ['admin', 'member'] }` | Composition — matches any of the listed roles (BA, pseudo, or other named rules) |
|
|
72
|
+
| `{ userRole: ['appmanager', 'sysadmin'] }` | Platform role — the caller's user-table role, same semantics as `access.userRole` on a resource. Lets "paid subscribers **or** operators" be written once: `paid: { or: [{ roles: ['tier_pro'] }, { userRole: ['appmanager', 'sysadmin'] }] }` |
|
|
72
73
|
| `{ or: [ruleA, ruleB] }` | Matches if **any** sub-rule matches |
|
|
73
74
|
| `{ and: [ruleA, ruleB] }` | Matches only if **all** sub-rules match |
|
|
74
75
|
| `{ via: 'relationshipName' }` | Caller proves a declared relationship — see [Relationship-based authorization](#relationship-based-authorization) below |
|
|
@@ -335,5 +335,7 @@ access, even if it was written out-of-band — the model is the ceiling.
|
|
|
335
335
|
conditional tuple with a 400, and `POST /fga/v1/read` still returns one, so a
|
|
336
336
|
row planted out-of-band stays visible to an audit. Nothing Quickback generates
|
|
337
337
|
writes those columns — only raw SQL, a seed, or an OpenFGA import can.
|
|
338
|
-
- `ListObjects`
|
|
339
|
-
|
|
338
|
+
- `ListObjects` reverse-walks the caller's footprint (their direct, wildcard and
|
|
339
|
+
group grants and the relevant tuplesets) rather than every object of the type,
|
|
340
|
+
then Checks each candidate — so its cost tracks the caller's grants, not the
|
|
341
|
+
tenant's object count.
|
|
@@ -118,12 +118,12 @@ type FirewallConfig = ReadonlyArray<FirewallPredicate>;
|
|
|
118
118
|
firewallErrorMode?: 'reveal' | 'hide';
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
An `equals` value that doesn't start with `ctx.` is a **literal**: `{ field: 'visibility', equals: 'studio' }` emits `eq(table.visibility, "studio")`. Like any status filter it is enforced by the API only — in Postgres RLS a literal arm lowers to `true`, so `any: [studio, { all: [private, owner] }]` keeps its OR shape instead of hardening into an owner-only policy.
|
|
121
|
+
An `equals` value that doesn't start with `ctx.` is a **literal**: `{ field: 'visibility', equals: 'studio' }` emits `eq(table.visibility, "studio")`. The literal is always written as a string and read as the **column's** type: `{ field: 'includesAllGuests', equals: '1' }` on an `integer` column emits `eq(table.includesAllGuests, 1)`, and `'true'` / `'false'` (or `'1'` / `'0'`) on a boolean column emit a boolean. A literal the column cannot hold — `'yes'` on an integer — is a compile error naming the column. Like any status filter it is enforced by the API only — in Postgres RLS a literal arm lowers to `true`, so `any: [studio, { all: [private, owner] }]` keeps its OR shape instead of hardening into an owner-only policy.
|
|
122
122
|
|
|
123
123
|
On Postgres the RLS scope policy mirrors the firewall's `all`/`any` tree arm for arm, and the **database enforces relationship arms too**:
|
|
124
124
|
|
|
125
125
|
- A `via:` arm lowers to `project_id IN (SELECT r.project_id FROM public.qb_rel_<relationship>() r)` — a `SECURITY DEFINER` helper that runs the same relationship lookup as the API (subject = the caller's claim, the `where:` literals, the related table's soft delete). The generated API calls the same helper for every relationship lookup on Postgres, so a caller with no active org gets the same rows from the API as the policy admits. `[org, { any: [owner, { via }] }]` becomes `org AND (owner OR project_id IN (…))`, never `org AND owner`. See [Relationship arms in SQL](/platform/database/neon#relationship-arms-in-sql).
|
|
126
|
-
- A `{ permission }` arm expands exactly as the API expands it: relation leaves become `via:` helpers, arrows become `qb_arrow_…` helpers (a recursive arrow is a `maxDepth`-bounded closure).
|
|
126
|
+
- A `{ permission }` arm expands exactly as the API expands it: relation leaves become `via:` helpers, arrows become `qb_arrow_…` helpers (a recursive arrow is a `maxDepth`-bounded closure; a relation-backed arrow returns the hop's rows whose FK is in the target relationship's `qb_rel_…` set).
|
|
127
127
|
- Inside an `any` group that also has an org arm, the relationship, scope and principal arms are tenant-bound exactly where the API binds them — `(<arm> AND (organization_id = <active org> OR <no active org>))` — so an org-claiming caller never rides them into another org.
|
|
128
128
|
- The soft-delete filter the API adds to a table carrying `deletedAt` reaches the policy too, as `deleted_at IS NULL OR public.in_soft_delete()` in `USING` only — see [the soft-delete lane](/platform/database/neon#the-soft-delete-lane).
|
|
129
129
|
- Literals, literal `in` lists, and claims the Worker never writes into the transaction (`ctx.scope.<kind>.<subKey>`, area anchors like `ctx.event.id`, string `in` sets) stay API-only and lower to `true` — the policy has nothing to compare them against, and a literal conjunct would refuse status-changing updates.
|
|
@@ -290,7 +290,10 @@ leaf that traverses a foreign key to inherit authority from a parent object
|
|
|
290
290
|
("org admins of the event's org can see its announcements", "anyone who
|
|
291
291
|
administers an ancestor folder can read this one"). An arrow leaf lowers to
|
|
292
292
|
an FK-hop subquery (non-recursive) or a bounded `WITH RECURSIVE` CTE
|
|
293
|
-
(self-FK hierarchy), tenant-constrained at every row.
|
|
293
|
+
(self-FK hierarchy), tenant-constrained at every row. An arrow's target
|
|
294
|
+
permission may reduce to org-membership roles **or** a single relationship —
|
|
295
|
+
"organizers of the parent event can see its sessions" composes the FK hop with
|
|
296
|
+
the relationship's subquery (non-recursive hops only).
|
|
294
297
|
|
|
295
298
|
**M1 limit — firewall arms must be SQL-pushable.** A firewall runs as a
|
|
296
299
|
WHERE clause, so a permission referenced from one may only resolve to
|
|
@@ -57,7 +57,7 @@ object forms are the unambiguous escape hatch.
|
|
|
57
57
|
| `{ role: 'admin' }` | an org-membership role (`ctx.roles`) |
|
|
58
58
|
| `{ scopeRole: { kind: 'event', role: 'organizer' } }` | a [scoped role](/define/scopes) |
|
|
59
59
|
| `{ pseudoRole: 'AUTHENTICATED' }` | `PUBLIC` / `AUTHENTICATED` / `INTERNAL` / … |
|
|
60
|
-
| `{ arrowRef: 'eventOrg', permission: 'org:admin' }` | an [FK-traversal arrow](/define/arrows) — resolve the row's FK to its target object and require a permission there |
|
|
60
|
+
| `{ arrowRef: 'eventOrg', permission: 'org:admin' }` | an [FK-traversal arrow](/define/arrows) — resolve the row's FK to its target object and require a permission there. The target `permission` may reduce to org-membership roles **or** a single relationship (e.g. "organizers of the parent event"). |
|
|
61
61
|
|
|
62
62
|
String sugar for the prefixed forms is also accepted inside an expression:
|
|
63
63
|
`'permission:event:view'`, `'scope:event:organizer'`, `'role:admin'`. A bare
|
|
@@ -105,7 +105,7 @@ A few mechanics to know:
|
|
|
105
105
|
> `authz.relationships` `subject: { column: 'userId', equals: 'ctx.userId' }` does not need, and must not create, a SQL FK. See [Relationships](/define/relationships). To query Better Auth tables, use `c.get("authDb")` from an action — see [Scoped DB](/define/actions/scoped-db#reaching-better-auth-tables-authdb).
|
|
106
106
|
|
|
107
107
|
|
|
108
|
-
- **Indexes and constraints:** column-level `.index()` / `.unique()` / `.check(expr)`, or table-level `indexes` / `unique` / `check` as a third arg to `q.table(name, cols, { indexes, unique, check })`. With `feature()`, pass `indexes`, `unique` and `check` as top-level keys alongside `columns` — the sugar forwards them into the same `q.table` opts. See [Constraints](#constraints--check-and-unique).
|
|
108
|
+
- **Indexes and constraints:** column-level `.index()` / `.unique()` / `.check(expr)`, or table-level `indexes` / `unique` / `check` as a third arg to `q.table(name, cols, { indexes, unique, check })`. With `feature()`, pass `indexes`, `unique` and `check` as top-level keys alongside `columns` — the sugar forwards them into the same `q.table` opts. In the two-export form they go on `q.table`; on `defineTable(...)` they are a compile error, because they describe the table, not the resource. See [Constraints](#constraints--check-and-unique).
|
|
109
109
|
|
|
110
110
|
### Column Types
|
|
111
111
|
|
|
@@ -349,7 +349,7 @@ so it can only ever carry the role the caller actually proved this request.
|
|
|
349
349
|
- A **bulk-grant lane** (`{ roles: [...] }` or `{ team: true }`) mints **no** scope role — it opens the gate via the caller's org role without proving a relationship. The gate passes; the caller carries their org role, not a minted scope role.
|
|
350
350
|
- **The org claim is only ever signed beside a membership role.** Every mint site — `/scope/v1/enter`, the namespace resolver, `/api/v1/token` — writes `orgId` into the token only when a membership `role` accompanies it, and the auth middleware ignores an `orgId` claim that arrives without a `role`. A relationship-promoted tenant (the in-request `ctx.activeOrgId` stamped from the proven row so the firewall resolves) is never persisted as a bare tenant grant.
|
|
351
351
|
- **`/scope/v1/enter` drops the org claims for a foreign-tenant instance.** When the relationship's `from` table carries an organization column, the enter route reads it off the proven row (the same row the probe already fetched — no extra query) and compares it with `ctx.activeOrgId`. A mismatch — an org-B member entering an org-A event — mints the token **without** `orgId` / `role`: a relationship-only principal, exactly the state the namespace resolver gives the same caller. The caller keeps their org seat for org-B requests by using their session or a plain `/api/v1/token`; the scope token is for the scope. A `from` table with no organization column (a global reference relationship) leaves the claim untouched.
|
|
352
|
-
- **Every mint tenant-binds the instance.** A relationship row is matched without tenant scoping (a cross-tenant attendee has no `activeOrgId`), so the row alone can't prove which tenant's instance it names. When the relationship's `from` table carries an organization column, every site that mints from a relationship row — `/scope/v1/enter`, [`ctx.mintScope`](#sessionless-scope-mint--ctxmintscope), and this namespace resolver (the in-memory stamp **and** the `mintScope` token) — also loads the **instance** row, through its own firewall with tenant scopes stripped so soft-delete still applies, and grants the role only when the instance's organization equals the proving row's. A row created in org B naming org A's event proves nothing about org A and grants nothing; a deleted instance grants nothing. (The namespace gate itself still passes on the proven row; the caller just carries no scope for the foreign instance.) The instance table is the target of the relationship's `resource.column` foreign key,
|
|
352
|
+
- **Every mint tenant-binds the instance.** A relationship row is matched without tenant scoping (a cross-tenant attendee has no `activeOrgId`), so the row alone can't prove which tenant's instance it names. When the relationship's `from` table carries an organization column, every site that mints from a relationship row — `/scope/v1/enter`, [`ctx.mintScope`](#sessionless-scope-mint--ctxmintscope), and this namespace resolver (the in-memory stamp **and** the `mintScope` token) — also loads the **instance** row, through its own firewall with tenant scopes stripped so soft-delete still applies, and grants the role only when the instance's organization equals the proving row's. A row created in org B naming org A's event proves nothing about org A and grants nothing; a deleted instance grants nothing. (The namespace gate itself still passes on the proven row; the caller just carries no scope for the foreign instance.) The instance table is `authz.scopes.<kind>.instance` when declared (`instance: 'events'`), else the target of the relationship's `resource.column` foreign key, else the one table whose firewall pins its primary key to `ctx.scope.<kind>` (`{ field: 'id', equals: 'ctx.scope.event' }`). Several such tables is a compile error naming them — set `instance`. If nothing resolves, the compiler warns: set `instance` (or declare the FK) so the instance can be bound. A `from` table with no organization column has no tenant to compare, so it gets no binding.
|
|
353
353
|
|
|
354
354
|
### The bulk-grant lane is tenant-bound
|
|
355
355
|
|
|
@@ -239,7 +239,11 @@ an [action](/define/actions/scoped-db#reaching-better-auth-tables-authdb).
|
|
|
239
239
|
into the write payload, or throw to reject — the write never executes and
|
|
240
240
|
the request gets a structured `TRIGGER_REJECTED` (422) error. Audit
|
|
241
241
|
fields (`createdBy`, `modifiedAt`, …) are re-stamped after hooks run and
|
|
242
|
-
cannot be forged.
|
|
242
|
+
cannot be forged. A `before*` hook gets `values`, the pending write, and
|
|
243
|
+
never the stored row: nothing is read before the write. Destructuring `row`
|
|
244
|
+
or `old` in one is a compile error. To derive a column from the stored row
|
|
245
|
+
on update, use a Postgres `sql:` trigger, where `NEW."col"` is the whole row
|
|
246
|
+
with the update applied.
|
|
243
247
|
- **`after*` hooks run once per affected row and are awaited** before the
|
|
244
248
|
write's promise resolves. They may be `async`. A throw surfaces as
|
|
245
249
|
`TRIGGER_AFTER_FAILED` (500) with `details.committed: true` — the row was
|
|
@@ -298,6 +302,14 @@ write path, use the `sql:` lane and reject with `RAISE(ABORT, ...)` (D1) or
|
|
|
298
302
|
> `scheduled()` handler + `wrangler.toml` triggers. This note is only about
|
|
299
303
|
> the table-trigger `handler:` lane not firing inside them.
|
|
300
304
|
|
|
305
|
+
## Columns a `beforeInsert` trigger fills
|
|
306
|
+
|
|
307
|
+
An action's `db.insert(table).values(...)` doesn't have to supply a column a
|
|
308
|
+
`beforeInsert` trigger assigns. The compiler makes that column optional in the
|
|
309
|
+
insert type when a `sql:` body assigns it (`NEW."project_id" := …`) or a
|
|
310
|
+
`handler:` returns it as a key (`{ number: … }`). The column's
|
|
311
|
+
`.required()` stays in the schema, so it is still `NOT NULL` in the table.
|
|
312
|
+
|
|
301
313
|
## Choosing a lane
|
|
302
314
|
|
|
303
315
|
| Need | Use |
|
|
@@ -91,12 +91,14 @@ All mounted under your auth base path (`/auth/v1` by default).
|
|
|
91
91
|
| `POST` | `/subscriptions/checkout` | Authenticated — creates a Stripe Checkout Session |
|
|
92
92
|
| `POST` | `/subscriptions/portal` | Authenticated — creates a Stripe billing-portal session |
|
|
93
93
|
| `GET` | `/subscriptions` | Admin, or org-scoped with `?organizationId=` |
|
|
94
|
-
| `POST` | `/subscriptions` | Admin |
|
|
95
|
-
| `POST` | `/subscriptions/update` | Admin — takes `{ id, ... }` in the body |
|
|
94
|
+
| `POST` | `/subscriptions` | Admin — `{ userId, tier, organizationId?, status?, limits?, expiresAt?, startsAt? }` |
|
|
95
|
+
| `POST` | `/subscriptions/update` | Admin — takes `{ id, ... }` in the body; any of `tier`, `status`, `limits`, `expiresAt`, `startsAt` |
|
|
96
96
|
| `POST` | `/subscriptions/delete` | Admin — soft delete, takes `{ id }` in the body |
|
|
97
97
|
|
|
98
98
|
The two admin mutations are `POST` with the id in the **body**, not `PATCH`/`DELETE` on `/subscriptions/:id`. That matches the rest of the Better Auth surface, which is POST-with-body throughout; the generated OpenAPI describes them the same way.
|
|
99
99
|
|
|
100
|
+
`expiresAt` and `startsAt` take an ISO-8601 string or epoch milliseconds. This is the manual-billing path: a customer who pays by bank transfer gets a row with a paid-through `expiresAt`, and renewal is bumping that date via `/subscriptions/update`. Omit it (or send `null`) for a comp that grants until revoked — the [expiry bound](#expiry-is-the-second-bound) only applies to rows that carry a date. Anything that does not parse to a real instant is a 400, never a silently expired row.
|
|
101
|
+
|
|
100
102
|
`GET /subscriptions/me` returns the base tier with `isDefault: true` when the caller has no subscription row, so clients never have to special-case "not subscribed".
|
|
101
103
|
|
|
102
104
|
Checkout takes the tier name, not a price:
|
|
@@ -304,7 +306,29 @@ export default defineTable(projects, {
|
|
|
304
306
|
});
|
|
305
307
|
```
|
|
306
308
|
|
|
307
|
-
To enforce a limit, read `limits` from `GET /subscriptions/me` (or query the subscriptions table directly in an action) and compare it against a count before creating the row. Enforcement is yours to write
|
|
309
|
+
To enforce a limit, read `limits` from `GET /subscriptions/me` (or query the subscriptions table directly in an action) and compare it against a count before creating the row. Enforcement is yours to write; the plugin's job is to make the caller's current tier and its limits available.
|
|
310
|
+
|
|
311
|
+
### `seats` is the one key the compiler enforces
|
|
312
|
+
|
|
313
|
+
`seats` is reserved: it is memberships per organization, and the compiler enforces it on Better Auth's own seating routes. When the organization plugin is on, the generated auth wires three `organizationHooks` that read the organization's effective subscription and refuse with `403 SEAT_LIMIT_REACHED` when the cap would be exceeded:
|
|
314
|
+
|
|
315
|
+
| Route | Counted against the cap |
|
|
316
|
+
|-------|-------------------------|
|
|
317
|
+
| Create invitation | Current members **plus** pending, unexpired invitations |
|
|
318
|
+
| Accept invitation | Current members |
|
|
319
|
+
| Add member (server-side) | Current members |
|
|
320
|
+
|
|
321
|
+
```ts
|
|
322
|
+
tiers: {
|
|
323
|
+
solo: { name: 'Solo', limits: { seats: 1 } },
|
|
324
|
+
team: { name: 'Team', priceId: 'price_team', limits: { seats: 10 } },
|
|
325
|
+
enterprise: { name: 'Enterprise', priceId: 'price_ent', limits: { seats: -1 } },
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
No `seats` key, or a negative value, means unlimited. A subscription that has stopped granting (see [which statuses grant](#which-statuses-grant) and the [expiry bound](#expiry-is-the-second-bound)) counts as the base tier, so a lapsed team plan falls back to the base tier's `seats`. Existing members are never removed by a downgrade; the cap only stops new seating.
|
|
330
|
+
|
|
331
|
+
Two paths are outside Better Auth's routes and therefore outside this check: memberships you insert yourself from `quickback/hooks/after-user-create.ts` (domain auto-join, personal orgs) and direct database writes. The generated `src/plugins/subscriptions/index.ts` exports `seatsAvailable(env, organizationId)` for the first case. The count-then-insert is not transactional, so two acceptances racing for the last seat can both land.
|
|
308
332
|
|
|
309
333
|
## Local development
|
|
310
334
|
|
|
@@ -54,6 +54,28 @@ auth: defineAuth("better-auth", {
|
|
|
54
54
|
|
|
55
55
|
---
|
|
56
56
|
|
|
57
|
+
## Session Freshness and Password Reset
|
|
58
|
+
|
|
59
|
+
Two Better Auth session controls are emitted with stricter values than the library's own defaults:
|
|
60
|
+
|
|
61
|
+
| Setting | Quickback default | Better Auth default | Override |
|
|
62
|
+
|---------|-------------------|---------------------|----------|
|
|
63
|
+
| `session.freshAge` | 15 minutes | 24 hours | `session.freshAgeInHours` |
|
|
64
|
+
| `emailAndPassword.revokeSessionsOnPasswordReset` | `true` | `false` | `emailAndPassword.revokeSessionsOnPasswordReset: false` |
|
|
65
|
+
|
|
66
|
+
**Freshness** gates the sensitive account operations (`change-password`, `delete-user`, `change-email` confirmation): a session older than `freshAge` has to sign in again first. Better Auth's 24-hour window lets a day-old session on a shared machine delete the account; 15 minutes is the "full, valid login session" an assessor expects.
|
|
67
|
+
|
|
68
|
+
**Reset revocation** terminates every other session the moment a password is reset through the forgot-password flow. That is the point at which someone holding the old password should lose the sessions they opened with it. Password *change* from the Account UI already sends `revokeOtherSessions: true`; direct API callers pass that flag themselves.
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
auth: defineAuth("better-auth", {
|
|
72
|
+
session: { freshAgeInHours: 1 }, // loosen to an hour
|
|
73
|
+
emailAndPassword: { enabled: true, revokeSessionsOnPasswordReset: false }, // keep other sessions
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
57
79
|
## Rate Limiting
|
|
58
80
|
|
|
59
81
|
Quickback includes per-IP rate limiting by default to protect against brute-force attacks and abuse.
|
|
@@ -172,7 +194,7 @@ Quickback supports three bearer-token flavors alongside the standard browser ses
|
|
|
172
194
|
| Session cookie | Browser SPAs (CMS, Account, your app) | Better Auth session lookup |
|
|
173
195
|
| Session-token bearer | API clients that grabbed `set-auth-token` | Better Auth `bearer` plugin |
|
|
174
196
|
| JWT bearer | API clients that mint at `GET /auth/v1/token` | In-worker JWT fast-path (no DB hit) |
|
|
175
|
-
| API-key bearer | Long-lived programmatic access | `apiKey` plugin / `x-api-key`
|
|
197
|
+
| API-key bearer | Long-lived programmatic access | `apiKey` plugin / `x-api-key` header (never a query parameter) |
|
|
176
198
|
|
|
177
199
|
These match Better Auth's own framing of bearer tokens as **an alternative to cookies, not a supplement** — a request uses one or the other.
|
|
178
200
|
|
|
@@ -908,7 +908,9 @@ from the relationship table under its own policy.
|
|
|
908
908
|
— exactly where the API applies the same binding.
|
|
909
909
|
- **Permissions.** A `{ permission }` arm expands as the API expands it; arrow
|
|
910
910
|
hops become `qb_arrow_…` helpers (recursive arrows are a `maxDepth`-bounded
|
|
911
|
-
closure that re-checks the tenant on every row
|
|
911
|
+
closure that re-checks the tenant on every row; a relation-backed arrow keeps
|
|
912
|
+
the hop's rows whose FK is in the relationship's `qb_rel_…` set), called by
|
|
913
|
+
the API too.
|
|
912
914
|
- **Still API-only.** Literal status filters (a conjunct would refuse
|
|
913
915
|
status-changing updates, because PostgreSQL checks an UPDATE's new row against
|
|
914
916
|
the read policy) and claims the Worker never writes into the transaction —
|
|
@@ -55,7 +55,7 @@ With `push.defaultSchema: true`, the compiler injects a hardened, owner-scoped `
|
|
|
55
55
|
|
|
56
56
|
- **INTERNAL-only reads** — the crypto fields (`endpoint`, `p256dh`, `auth`) never leave the worker via any HTTP path. A `views.mine` projection exposes only `id`, `userAgent`, `lastSeenAt`, `createdAt` for "Your devices" UIs.
|
|
57
57
|
- **Owner firewall** — `owner_id` is auto-stamped on create; user A can never read or delete user B's subscription.
|
|
58
|
-
- **Create-time validation** — the endpoint must be `https:` (the worker POSTs VAPID-signed requests at that URL, so an arbitrary endpoint is an SSRF primitive), `p256dh` must decode to a 65-byte uncompressed P-256 point, and `auth` to a 16-byte secret. The `https:` check is not the whole SSRF story: at send time the push sender
|
|
58
|
+
- **Create-time validation** — the endpoint must be `https:` (the worker POSTs VAPID-signed requests at that URL, so an arbitrary endpoint is an SSRF primitive), `p256dh` must decode to a 65-byte uncompressed P-256 point, and `auth` to a 16-byte secret. The `https:` check is not the whole SSRF story: at send time the push sender runs the endpoint through the same destination policy as [outbound webhooks](/platform/webhooks/outbound) (`src/lib/webhooks/url-policy.ts`): every IANA special-purpose IPv4/IPv6 range (loopback, link-local and the cloud metadata address, RFC 1918, CGNAT, IPv4-mapped, ULA, NAT64, 6to4, Teredo), plus `localhost`, `.local`, `.internal`, `.home.arpa` and single-label names. Unlike webhooks it does **not** resolve DNS, so a public hostname that resolves to a private address is not caught. Together — **https + the destination policy** — this narrows the SSRF surface; treat it as defense-in-depth, not a guarantee that SSRF is impossible.
|
|
59
59
|
- **Proven identity tags** — a `tags` column is stamped **server-side** from `ctx`: `user:<id>`, and — only when the request carries a scoped token — `scope:<kind>:<subject>` plus one `scope:<kind>:<instance>#<role>` per scope role the verified claim grants (the same dialect realtime tickets use). Client-supplied tags are ignored: they drive fan-out targeting. **Org roles are never stamped** — a device is user-owned, and org audiences are resolved from live membership at send time; see [Targeting](#targeting).
|
|
60
60
|
- **Rate limit + cap** — creates are limited to 10/minute per caller, and only the newest 10 live subscriptions per user are kept (older rows are soft-deleted, so a user's new device always works).
|
|
61
61
|
|
|
@@ -577,6 +577,25 @@ if an earlier compiler already rewrote one.
|
|
|
577
577
|
> compiling. Compile does not delete snapshots it was never given.
|
|
578
578
|
|
|
579
579
|
|
|
580
|
+
### Merging branches that both added migrations
|
|
581
|
+
|
|
582
|
+
Everything under `quickback/drizzle/` is generated — never hand-edit a `.sql`
|
|
583
|
+
file or snapshot, and never resolve a merge conflict inside one. When your branch
|
|
584
|
+
and the target branch each added a migration, the numbers collide and
|
|
585
|
+
`meta/_journal.json` conflicts. Resolve it by regenerating, not merging:
|
|
586
|
+
|
|
587
|
+
1. Merge the `quickback/` definitions (features, config) as normal.
|
|
588
|
+
2. Take the target branch's `quickback/drizzle/` as-is, dropping the migrations
|
|
589
|
+
your branch added. The target's history is what deployed databases have.
|
|
590
|
+
3. `quickback build`. Your schema changes are diffed against the target's latest
|
|
591
|
+
snapshot and appended as a fresh migration after it.
|
|
592
|
+
4. `quickback migrations doctor` to confirm the journal and snapshots agree.
|
|
593
|
+
|
|
594
|
+
Only drop migrations that were never applied anywhere. D1 records applied
|
|
595
|
+
migrations by path, so if your branch's migration already ran against a shared
|
|
596
|
+
or preview database, dropping it leaves that database drifted — resolve that
|
|
597
|
+
database before merging.
|
|
598
|
+
|
|
580
599
|
For non-interactive environments (cloud compile, CI), table/column renames must be declared with `compiler.migrations.renames` in `quickback.config.ts`. This avoids interactive rename prompts during migration generation.
|
|
581
600
|
|
|
582
601
|
Migration files follow the Drizzle Kit naming convention:
|
|
@@ -67,6 +67,35 @@ So organization creation asks for an `ownerUserId`, seats that user, and never s
|
|
|
67
67
|
|
|
68
68
|
An operator who genuinely wants their own organization creates one naming themselves as owner — explicit, and visible in the audit trail rather than implied by whoever happened to make the call.
|
|
69
69
|
|
|
70
|
+
## Requiring a second factor
|
|
71
|
+
|
|
72
|
+
Operator accounts are the highest-value targets in a deployment, and CASA / ASVS require multi-factor authentication on every administrative interface. `operatorMfa` enforces it:
|
|
73
|
+
|
|
74
|
+
```ts title="quickback.config.ts"
|
|
75
|
+
providers: {
|
|
76
|
+
auth: defineAuth("better-auth", {
|
|
77
|
+
operatorMfa: true,
|
|
78
|
+
plugins: ["passkey", "admin"],
|
|
79
|
+
}),
|
|
80
|
+
},
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
With it on, an `appmanager` or `sysadmin` whose session was **not** established by a passkey assertion or a two-factor verification is treated as a plain `user` for that request. Every operator surface refuses with `403 MFA_REQUIRED`: the CMS and `/api/v1/schema`, the `/auth/v1/admin/*` operator routes, Better Auth's own admin endpoints (`list-users`, `set-role`, `ban-user`), and the sysadmin cross-tenant bypass. The Account UI keeps working, so the enrolment path is short:
|
|
84
|
+
|
|
85
|
+
1. Sign in with a password (or magic link / OTP) as usual.
|
|
86
|
+
2. Register a passkey at `/account/passkeys/setup`.
|
|
87
|
+
3. Sign out, then sign back in **with the passkey**.
|
|
88
|
+
|
|
89
|
+
How it works: the compiler adds a `session.amr` column (RFC 8176, *Authentication Methods Reference*) and a `session.create.before` hook that stamps `passkey` when the session comes from `/passkey/verify-authentication` and `mfa` when it comes from `/two-factor/verify-*`. Nothing else sets it, and it is not client-settable. The auth middleware reads it on the session lane and copies it into the JWT fast-path claims, so bearer callers are gated identically.
|
|
90
|
+
|
|
91
|
+
Things to know:
|
|
92
|
+
|
|
93
|
+
- **Requires `passkey` or `twoFactor`.** The compile fails otherwise: without a second factor to enrol, every operator would be locked out.
|
|
94
|
+
- **Passkey sign-in only.** A user who has a passkey but signs in with a password is not MFA'd; the session has to be created by the passkey assertion.
|
|
95
|
+
- **Two-factor "trust this device"** skips the verify endpoint, so a trusted-device sign-in does not count. Operators should not use it.
|
|
96
|
+
- **API keys never satisfy it.** An operator's API key is a single factor; operator routes reject it with `MFA_REQUIRED`.
|
|
97
|
+
- **Existing projects** get a new `amr` column on the auth `session` table on the next compile; apply the generated auth migration before deploying.
|
|
98
|
+
|
|
70
99
|
## Custom Admin Domain
|
|
71
100
|
|
|
72
101
|
Give the admin panel its own subdomain with `adminDomain`:
|
|
@@ -14,6 +14,8 @@ Users can see all devices where they're currently logged in, including:
|
|
|
14
14
|
|
|
15
15
|
Users can revoke any session except their current one. This immediately invalidates the session token.
|
|
16
16
|
|
|
17
|
+
Two events revoke other sessions without a click: changing the password from the profile page (the UI sends `revokeOtherSessions: true`), and resetting it through the forgot-password flow (the server default `revokeSessionsOnPasswordReset: true`, see [Session Freshness and Password Reset](/platform/auth/security#session-freshness-and-password-reset)).
|
|
18
|
+
|
|
17
19
|
## Related
|
|
18
20
|
|
|
19
21
|
- [Environment Variables](/ui/account/environment-variables)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quickback-dev/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.67.0",
|
|
4
4
|
"description": "CLI for Quickback — define your backend in TypeScript, compile to a fully wired Cloudflare Worker (or Bun / Node) with auth, database, migrations, security, CMS, and Account UI.",
|
|
5
5
|
"author": "Kardoe Incorporated <paul@kardoe.com>",
|
|
6
6
|
"license": "MIT",
|
package/src/cursor/quickback.mdc
CHANGED
|
@@ -283,6 +283,12 @@ quickback claude install # Install Claude Code skill
|
|
|
283
283
|
quickback cursor install # Install Cursor rules
|
|
284
284
|
```
|
|
285
285
|
|
|
286
|
+
Never hand-edit or hand-merge anything under `quickback/drizzle/` — it is generated,
|
|
287
|
+
append-only history. If two branches both added a migration, take the target branch's
|
|
288
|
+
`quickback/drizzle/`, drop your branch's never-applied migrations, run `quickback build`
|
|
289
|
+
to regenerate them on top, then `quickback migrations doctor`. See
|
|
290
|
+
https://docs.quickback.dev/tooling/output#merging-branches-that-both-added-migrations
|
|
291
|
+
|
|
286
292
|
## Full Documentation
|
|
287
293
|
|
|
288
294
|
https://docs.quickback.dev
|
package/src/skill/SKILL.md
CHANGED
|
@@ -108,6 +108,12 @@ compatible with the prod schema across the apply→deploy window. **Caveat:** if
|
|
|
108
108
|
and regenerates full `CREATE TABLE`s — which then collide with the live DB. Keep the
|
|
109
109
|
meta in git.
|
|
110
110
|
|
|
111
|
+
**Never hand-edit or hand-merge anything under `quickback/drizzle/`.** If two
|
|
112
|
+
branches both added a migration, take the target branch's `quickback/drizzle/`,
|
|
113
|
+
drop your branch's never-applied migrations, `quickback build` to regenerate
|
|
114
|
+
them on top, then `quickback migrations doctor`. See
|
|
115
|
+
[Output Structure](https://docs.quickback.dev/tooling/output#merging-branches-that-both-added-migrations).
|
|
116
|
+
|
|
111
117
|
---
|
|
112
118
|
|
|
113
119
|
## Tenancy is not yours to model
|
|
@@ -132,7 +132,7 @@ All actions (both standalone and record-based) receive a **scoped `db`** that ap
|
|
|
132
132
|
|
|
133
133
|
- `SELECT` / `UPDATE` / `DELETE` get the table's firewall `WHERE`, AND-merged with yours.
|
|
134
134
|
- `INSERT` stamps every claim column the firewall binds (`organizationId`, `ownerId`, …) from context.
|
|
135
|
-
- A caller
|
|
135
|
+
- A caller who carries none of the claims a table's firewall can bind cannot query it: every statement on that table fails with 403 `FIREWALL_CLAIM_MISSING` instead of silently matching nothing. The action's `db` type rejects such tables at compile time when its `access` can't guarantee the claim.
|
|
136
136
|
|
|
137
137
|
Full semantics: [Scoped Database](/define/actions/scoped-db).
|
|
138
138
|
|
|
@@ -125,12 +125,15 @@ Firewall filtering is transparent — the query is scoped by `WHERE organization
|
|
|
125
125
|
| `FIREWALL_SOFT_DELETED` | Record has been soft deleted |
|
|
126
126
|
| `FIREWALL_WRITE_DENIED` | A create would land a row outside the caller's firewall (see [Firewall on write](/define/firewall#firewall-on-write)); also a Postgres RLS refusal (`42501`) |
|
|
127
127
|
|
|
128
|
-
Inside an action,
|
|
129
|
-
|
|
130
|
-
`activeOrgId` for an org-scoped table, say
|
|
131
|
-
|
|
132
|
-
`
|
|
133
|
-
|
|
128
|
+
Inside an action, any statement through the [scoped `db`](/define/actions/scoped-db)
|
|
129
|
+
on a table whose firewall needs a claim the caller does not carry (no
|
|
130
|
+
`activeOrgId` for an org-scoped table, say — a `PUBLIC` or `AUTHENTICATED`
|
|
131
|
+
action, or a scope principal on a table with no arm for its kind) fails with
|
|
132
|
+
**403** `FIREWALL_CLAIM_MISSING`, `layer: "action"`, and
|
|
133
|
+
`details: { table, claims }` (the claim sets the firewall accepts) — the
|
|
134
|
+
statement never runs, so a read cannot silently return `[]` and a row is never
|
|
135
|
+
written into whatever tenant the body named. An `INSERT` whose conjunctive
|
|
136
|
+
claim is missing reports `details: { table, column, claim }`.
|
|
134
137
|
|
|
135
138
|
An `INSERT` through the scoped `db` whose row would land outside the table's
|
|
136
139
|
firewall (a project the caller has no relationship to) fails with **403**
|
|
@@ -72,7 +72,9 @@ const jobId = routeParams.id as Api.jobs.Id;
|
|
|
72
72
|
|
|
73
73
|
Columns that point at a Better Auth principal are branded too, even though
|
|
74
74
|
those tables are not part of your project: tenant scopes (`q.scope('organization')`,
|
|
75
|
-
`q.scope('owner')`, `q.scope('team')
|
|
75
|
+
`q.scope('owner')`, `q.scope('team')`, or a raw Drizzle column bound by the
|
|
76
|
+
firewall — branded by the arm it binds, so an owner firewall on `userId` makes
|
|
77
|
+
it a `Qb.UserId` whatever the column is called), the audit stamps (`createdBy`,
|
|
76
78
|
`modifiedBy`, `deletedBy`), and any `.references('user' | 'organization' | 'team')`
|
|
77
79
|
column.
|
|
78
80
|
|
|
@@ -339,6 +339,9 @@ providers: {
|
|
|
339
339
|
|--------|------|-------------|
|
|
340
340
|
| `session.expiresInDays` | `number` | Session expiration in days |
|
|
341
341
|
| `session.updateAgeInDays` | `number` | Session refresh interval in days |
|
|
342
|
+
| `session.freshAgeInHours` | `number` | How recent a sign-in must be for change-password / delete-account. Default `0.25` (15 minutes); `0` = always fresh |
|
|
343
|
+
| `emailAndPassword.revokeSessionsOnPasswordReset` | `boolean` | Terminate every other session when a password is reset. Default `true` |
|
|
344
|
+
| `operatorMfa` | `boolean` | Require a passkey or two-factor session for `appmanager` / `sysadmin`. Requires the `passkey` or `twoFactor` plugin. See [Requiring a second factor](/ui/account/features/admin#requiring-a-second-factor) |
|
|
342
345
|
| `rateLimit.enabled` | `boolean` | Enable rate limiting |
|
|
343
346
|
| `rateLimit.window` | `number` | Rate limit window in seconds |
|
|
344
347
|
| `rateLimit.max` | `number` | Max requests per window |
|
|
@@ -412,7 +412,18 @@ type FieldCondition =
|
|
|
412
412
|
| { lessThan: number }
|
|
413
413
|
| { greaterThan: number }
|
|
414
414
|
| { lessThanOrEqual: number }
|
|
415
|
-
| { greaterThanOrEqual: number }
|
|
415
|
+
| { greaterThanOrEqual: number }
|
|
416
|
+
| { null: true } // the column is unset — e.g. update only while still a draft
|
|
417
|
+
| { notNull: true };
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
Each field takes exactly one condition. Any other shape — `{ isNull: true }`,
|
|
421
|
+
two operators on one field — is a compile error, because at runtime it would
|
|
422
|
+
match nothing and deny every row. `{ null: true }` treats an absent value as
|
|
423
|
+
null, and on collection reads it becomes `IS NULL` in the `WHERE` clause:
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
update: { access: { roles: ["member"], record: { issuedAt: { null: true } } } },
|
|
416
427
|
```
|
|
417
428
|
|
|
418
429
|
## Evaluation Order
|