@quickback-dev/cli 0.66.20 → 0.66.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/commands/migrate.js +2 -2
  2. package/dist/commands/migrate.js.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/lib/migrations/drizzle-prompts.d.ts +2 -0
  5. package/dist/lib/migrations/drizzle-prompts.d.ts.map +1 -1
  6. package/dist/lib/migrations/drizzle-prompts.js +11 -0
  7. package/dist/lib/migrations/drizzle-prompts.js.map +1 -1
  8. package/dist/lib/migrations/file-envelopes.d.ts.map +1 -1
  9. package/dist/lib/migrations/file-envelopes.js +21 -51
  10. package/dist/lib/migrations/file-envelopes.js.map +1 -1
  11. package/dist/lib/migrations/prompt-runner.d.ts.map +1 -1
  12. package/dist/lib/migrations/prompt-runner.js +6 -1
  13. package/dist/lib/migrations/prompt-runner.js.map +1 -1
  14. package/dist/skill/docs/api/actions.md +13 -6
  15. package/dist/skill/docs/api/batch-operations.md +6 -2
  16. package/dist/skill/docs/api/crud.md +72 -9
  17. package/dist/skill/docs/api/errors.md +86 -6
  18. package/dist/skill/docs/api/openapi.md +1 -1
  19. package/dist/skill/docs/api/query-params.md +8 -7
  20. package/dist/skill/docs/api/typescript.md +196 -0
  21. package/dist/skill/docs/configure/index.md +36 -2
  22. package/dist/skill/docs/configure/providers.md +37 -9
  23. package/dist/skill/docs/define/actions/defining.md +16 -7
  24. package/dist/skill/docs/define/actions/record-and-standalone.md +10 -0
  25. package/dist/skill/docs/define/actions/scoped-db.md +18 -3
  26. package/dist/skill/docs/define/changesets.md +2 -0
  27. package/dist/skill/docs/define/firewall.md +39 -0
  28. package/dist/skill/docs/define/guards.md +7 -2
  29. package/dist/skill/docs/define/masking.md +14 -0
  30. package/dist/skill/docs/define/read.md +3 -0
  31. package/dist/skill/docs/define/relationships.md +9 -0
  32. package/dist/skill/docs/define/schema.md +14 -10
  33. package/dist/skill/docs/define/transitions.md +12 -5
  34. package/dist/skill/docs/define/triggers.md +2 -1
  35. package/dist/skill/docs/index.md +1 -0
  36. package/dist/skill/docs/platform/auth/plugins/agent-auth.md +1 -1
  37. package/dist/skill/docs/platform/database/neon.md +110 -30
  38. package/dist/skill/docs/platform/payments/index.md +1 -1
  39. package/dist/skill/docs/start/frontend.md +278 -0
  40. package/dist/skill/docs/start/index.md +1 -0
  41. package/dist/skill/docs/tooling/cli.md +28 -7
  42. package/dist/skill/docs/tooling/cloud-compiler/troubleshooting.md +6 -0
  43. package/dist/skill/docs/tooling/output.md +42 -11
  44. package/dist/skill/docs/tooling/troubleshooting.md +67 -0
  45. package/dist/skill/docs/ui/admin/actions.md +6 -2
  46. package/dist/skill/docs/ui/admin/index.md +1 -1
  47. package/dist/skill/docs/ui/admin/inline-editing.md +6 -2
  48. package/dist/skill/docs/ui/admin/schema-format.md +74 -36
  49. package/dist/skill/docs/ui/admin/schema-registry.md +22 -9
  50. package/dist/skill/docs/ui/admin/security.md +2 -2
  51. package/dist/skill/docs/ui/components/action-dialog.md +62 -0
  52. package/dist/skill/docs/ui/components/auth.md +90 -0
  53. package/dist/skill/docs/ui/components/index.md +48 -0
  54. package/dist/skill/docs/ui/components/install.md +118 -0
  55. package/dist/skill/docs/ui/components/quickback-provider.md +123 -0
  56. package/dist/skill/docs/ui/components/resource-form.md +80 -0
  57. package/dist/skill/docs/ui/components/resource-table.md +46 -0
  58. package/package.json +1 -1
  59. package/src/skill/docs/api/actions.md +13 -6
  60. package/src/skill/docs/api/batch-operations.md +6 -2
  61. package/src/skill/docs/api/crud.md +72 -9
  62. package/src/skill/docs/api/errors.md +86 -6
  63. package/src/skill/docs/api/openapi.md +1 -1
  64. package/src/skill/docs/api/query-params.md +8 -7
  65. package/src/skill/docs/api/typescript.md +196 -0
  66. package/src/skill/docs/configure/index.md +36 -2
  67. package/src/skill/docs/configure/providers.md +37 -9
  68. package/src/skill/docs/define/actions/defining.md +16 -7
  69. package/src/skill/docs/define/actions/record-and-standalone.md +10 -0
  70. package/src/skill/docs/define/actions/scoped-db.md +18 -3
  71. package/src/skill/docs/define/changesets.md +2 -0
  72. package/src/skill/docs/define/firewall.md +39 -0
  73. package/src/skill/docs/define/guards.md +7 -2
  74. package/src/skill/docs/define/masking.md +14 -0
  75. package/src/skill/docs/define/read.md +3 -0
  76. package/src/skill/docs/define/relationships.md +9 -0
  77. package/src/skill/docs/define/schema.md +14 -10
  78. package/src/skill/docs/define/transitions.md +12 -5
  79. package/src/skill/docs/define/triggers.md +2 -1
  80. package/src/skill/docs/index.md +1 -0
  81. package/src/skill/docs/platform/auth/plugins/agent-auth.md +1 -1
  82. package/src/skill/docs/platform/database/neon.md +110 -30
  83. package/src/skill/docs/platform/payments/index.md +1 -1
  84. package/src/skill/docs/start/frontend.md +278 -0
  85. package/src/skill/docs/start/index.md +1 -0
  86. package/src/skill/docs/tooling/cli.md +28 -7
  87. package/src/skill/docs/tooling/cloud-compiler/troubleshooting.md +6 -0
  88. package/src/skill/docs/tooling/output.md +42 -11
  89. package/src/skill/docs/tooling/troubleshooting.md +67 -0
  90. package/src/skill/docs/ui/admin/actions.md +6 -2
  91. package/src/skill/docs/ui/admin/index.md +1 -1
  92. package/src/skill/docs/ui/admin/inline-editing.md +6 -2
  93. package/src/skill/docs/ui/admin/schema-format.md +74 -36
  94. package/src/skill/docs/ui/admin/schema-registry.md +22 -9
  95. package/src/skill/docs/ui/admin/security.md +2 -2
  96. package/src/skill/docs/ui/components/action-dialog.md +62 -0
  97. package/src/skill/docs/ui/components/auth.md +90 -0
  98. package/src/skill/docs/ui/components/index.md +48 -0
  99. package/src/skill/docs/ui/components/install.md +118 -0
  100. package/src/skill/docs/ui/components/quickback-provider.md +123 -0
  101. package/src/skill/docs/ui/components/resource-form.md +80 -0
  102. package/src/skill/docs/ui/components/resource-table.md +46 -0
@@ -224,6 +224,16 @@ with a mounted prefix, two more forms apply:
224
224
  An action's `access:` and `anchor:` may reference vocabulary declared by an ancestor area —
225
225
  and never vocabulary of an area the feature is not inside (compile error).
226
226
 
227
+ A standalone path under a feature's own collection, like `path: "/users/:id/likes"`, is still
228
+ standalone. It binds to nothing, so there is no record fetch. Read `:id` yourself and check it
229
+ through the scoped `db`. If you want the record fetched and firewalled for you, drop `path:`
230
+ and write a record-based action.
231
+
232
+ A standalone path may not land on a route the compiler already mounts. That includes a record
233
+ action with the same name (`actions/users/likes.ts` → `POST /users/:id/likes`) and the
234
+ generated CRUD routes (`GET /users/:id`). Parameter names don't matter to the router, so
235
+ `/users/:userId/likes` collides too. Either case is a compile error naming both routes.
236
+
227
237
  ### Feature-area transition adapter
228
238
 
229
239
  A record [state transition](/define/transitions) normally lives on a
@@ -9,13 +9,22 @@ the same generated `WHERE` clause the table's CRUD routes use:
9
9
  |-----------|---------------------------|
10
10
  | `SELECT` | the table's firewall (org / owner / team / scope / `via:` arms) AND soft-delete filter |
11
11
  | `UPDATE` / `DELETE` | the same firewall `WHERE`, AND-merged with yours |
12
- | `INSERT` | every required claim column the firewall binds (e.g. `organizationId` from `ctx.activeOrgId`), overwriting any value you passed |
13
- | `INSERT … onConflictDoUpdate` | the firewall AND-merged into `setWhere` — a conflict with a row the caller can't update (another tenant's id) is a no-op, never an overwrite |
12
+ | `INSERT` | every required claim column the firewall binds (e.g. `organizationId` from `ctx.activeOrgId`), overwriting any value you passed — then, where those stamps can't guarantee the row passes the firewall (a `via:` / `{ permission }` / literal / `any:` arm), the [firewall-on-write check](/define/firewall#firewall-on-write): every row of `.values(row)` or `.values([rows])` must pass the table's firewall, or nothing is written and the action answers **403 `FIREWALL_WRITE_DENIED`** |
13
+ | `INSERT … onConflictDoUpdate` / `onConflictDoNothing` | the insert branch runs the same firewall-on-write check; the conflict update gets the firewall AND-merged into `setWhere` — a conflict with a row the caller can't update (another tenant's id) is a no-op, never an overwrite |
14
14
 
15
15
  The firewall is set on the builder when you call `.from()` / `.set()` /
16
16
  `.delete()`, so every executor gets it: `await`, `.all()`, `.get()`,
17
17
  `.values()`, `.run()`, `.execute()`, `.prepare()`, and the builder embedded as
18
- a subquery (`inArray(col, db.select(...).from(t))`).
18
+ a subquery (`inArray(col, db.select(...).from(t))`). The firewall-on-write
19
+ check on an `INSERT` is async, so it runs when the insert executes — on
20
+ `await`, on any executor, and ahead of `db.batch([...])`. A `.prepare()`d
21
+ insert into a table that needs the check is refused (`FIREWALL_WRITE_CHECK_UNSUPPORTED`):
22
+ it would run later with nothing to check it.
23
+
24
+ The same refusal comes back from Postgres itself when an `INSERT` reaches the
25
+ database outside the caller's firewall (RLS `42501`): the action route maps it
26
+ to the same **403 `FIREWALL_WRITE_DENIED`** Problem, never a generic action
27
+ failure — so D1 and Postgres answer alike.
19
28
 
20
29
  It is not a guess from column names. `any:` groups, `optional` arms, scope
21
30
  (`ctx.scope.*`) and `via:` relationship arms, the null-claim deny, the
@@ -283,6 +292,12 @@ predicate in the `WHERE` (for example,
283
292
 
284
293
  Actions that need to bypass scoped DB filters (for example, platform-level support operations) can enable unsafe mode.
285
294
 
295
+ `unsafeDb` and a raw `createDb()` handle are **unchecked by design**: no
296
+ firewall `WHERE`, no claim stamping, no firewall-on-write check. On Postgres a
297
+ non-cross-tenant `unsafeDb` still runs under the caller's RLS claims, so an
298
+ insert the policy refuses comes back as 403 `FIREWALL_WRITE_DENIED`; on D1 it
299
+ lands. That is the point of the escape hatch — and why it is audited.
300
+
286
301
  `unsafe` is the only sanctioned way around the scoped `db`. The compiler warns
287
302
  when a non-`unsafe` action — or a file it imports from the feature's `lib/`,
288
303
  the project's `lib/`, `hooks/` or `plugins/` (relative or `~/` imports) —
@@ -197,6 +197,8 @@ Every **child op** then pays:
197
197
  8. **Server-minted child ids** — a client-supplied child primary key on an
198
198
  insert is rejected (like the plain POST's strict body schema), unless the
199
199
  project is configured for client-provided ids (`generateId: false`).
200
+ There the id is exempt from the child's `guards.createable`, as on the
201
+ plain POST.
200
202
 
201
203
  Child `delete` ops stamp the **fixed `deletedAt`** audit column — exactly what
202
204
  the plain DELETE route stamps (the audit wrapper then auto-stamps
@@ -118,6 +118,16 @@ 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.
122
+
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
+
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).
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
+ - 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
+ - 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.
130
+
121
131
  The top-level array is AND'd together. `firewallErrorMode` lives at the resource top level — it's a presentation-layer choice (403 vs 404), not a query-shape one.
122
132
 
123
133
  ## Boolean groups: `all` / `any`
@@ -516,6 +526,35 @@ export default defineTable(records, {
516
526
  });
517
527
  ```
518
528
 
529
+ ### Firewall on write
530
+
531
+ A create may not land a row the caller could not read. When a firewall's
532
+ admission isn't guaranteed by the values a create stamps — a `via:` or
533
+ `{ permission }` arm (a task in a project you have no relationship to), a
534
+ literal or `in` arm, any `any:` group — every create path (`POST /`,
535
+ `POST /batch`, the create side of `PUT /:id` and `PUT /batch`, and a changeset's
536
+ root and owned-child inserts) evaluates the table's own firewall against the new
537
+ row before inserting it — and so does an action's [scoped `db`](/define/actions/scoped-db)
538
+ on every `insert(...).values(...)` (single row or array, and the insert branch
539
+ of an upsert) — and refuses with:
540
+
541
+ ```json
542
+ {
543
+ "error": "Record would be outside your firewall",
544
+ "code": "FIREWALL_WRITE_DENIED",
545
+ "layer": "firewall"
546
+ }
547
+ ```
548
+
549
+ Status `403`. The verdict is the same on D1 and Postgres: it is the table's
550
+ generated `buildFirewallConditions` — the same WHERE every read applies —
551
+ evaluated over the candidate row. (On Postgres the RLS policy would refuse the
552
+ row anyway; a refusal that still reaches the database maps to the same Problem,
553
+ never a raw `42501` — in a CRUD route or an action.) Firewalls made only of
554
+ stamped `ctx.*` equalities and `isNull` skip the check — the stamps already
555
+ guarantee admission. An action's `unsafeDb` and a raw `createDb()` handle are
556
+ unchecked by design (see [Unsafe Mode](/define/actions/scoped-db#unsafe-mode)).
557
+
519
558
  ### Foreign-Key Referential Checks
520
559
 
521
560
  Every generated write handler — `POST /`, `POST /batch`, `PATCH /:id`, `PATCH /batch`, `PUT /:id` (both its update and create paths), `PUT /batch`, and the root of a [changeset](/define/changesets) — validates foreign-key columns against the **target table's** firewall before writing. Creates check every FK in the body; updates check every FK whose value **changes** (a value equal to the stored one costs no query). If a record references a row that the caller can't see (wrong org, soft-deleted, or non-existent), the request fails with:
@@ -65,7 +65,7 @@ guards: {
65
65
 
66
66
  | List | What it controls |
67
67
  |------|------------------|
68
- | `createable` | Fields allowed in create (POST) request body |
68
+ | `createable` | Fields allowed in create (POST) request body. A client-supplied `id` (`generateId: false` or `allowClientIds`) is exempt and need not be listed |
69
69
  | `updatable` | Fields allowed in update (PATCH) request body |
70
70
  | `protected` | Fields blocked from direct writes; writable only by the actions named for them |
71
71
  | `immutable` | Fields allowed on create, then never written again — by CRUD, batch, changeset, **or actions** |
@@ -284,7 +284,12 @@ When upsert creates a new record, ownership fields are auto-set from context:
284
284
  | `'short'` | No | Server generates 6-char alphanumeric ID (e.g. `a3F9xK`) |
285
285
  | `'prefixed'` | No | Server generates prefixed ID (e.g. `room_abc123`) |
286
286
  | `'serial'` | No | Database auto-increments |
287
- | `false` | Yes (if guards: false) | Client provides ID |
287
+ | `false` | Yes (if guards: false) | Client provides ID (required on create) |
288
+
289
+ Under `generateId: false` a guarded table still creates normally: the
290
+ client-supplied `id` is compiler-managed, not a guarded field, so it is exempt
291
+ from `createable` — list only the fields the client may set. Guards keep
292
+ rejecting every other field outside `createable`.
288
293
 
289
294
  Need client-generated ids without giving up server minting or guards? Set
290
295
  `allowClientIds: true` instead — creates accept an **optional**
@@ -168,6 +168,20 @@ export default feature('candidates', {
168
168
  | `'redact'` | `anything` | `[REDACTED]` |
169
169
  | `'custom'` | (your logic) | (your output) |
170
170
 
171
+ ### Non-string columns
172
+
173
+ The string-shaped masks (`email`, `phone`, `ssn`, `creditCard`, `name`) format
174
+ text, so they are a compile error on a column whose value isn't a string —
175
+ `q.int()`, `q.bigint()`, `q.smallint()`, `q.bool()`, `q.json()`,
176
+ `q.timestamp()` (a `Date` on Postgres), or any `.array()`. Use `'redact'` or
177
+ `'custom'` there.
178
+
179
+ A redacted non-string value arrives as the string `"[REDACTED]"` — a masked
180
+ `q.int()` is not a number for that caller. The generated types say so:
181
+ [`Qb.Masked<number>`](/api/typescript#masked-columns) admits `Qb.Redacted`,
182
+ and OpenAPI documents the column as
183
+ `anyOf: [{ type: "integer" }, { type: "string", enum: ["[REDACTED]"] }]`.
184
+
171
185
  ## Configuration
172
186
 
173
187
  ```typescript
@@ -115,6 +115,9 @@ Single-record `GET /:id` evaluates checks in this order to close the
115
115
  404-vs-403 ID-probe channel:
116
116
 
117
117
  1. **Auth gate** — 401 if unauthenticated
118
+ - **Id shape** — 400 `INVALID_ID` if `:id` can't be one of this table's ids
119
+ (see [Malformed ids](/api/crud#malformed-ids-400-invalid_id)); depends on
120
+ the URL string alone, so it reveals nothing about which rows exist
118
121
  2. **Pre-record access** — role-only check (skips `access.record` predicates)
119
122
  3. **Firewall query** — `WHERE` clause filters by ownership
120
123
  4. **Post-record access** — full check including record-level predicates
@@ -96,6 +96,15 @@ export default defineConfig({
96
96
  >
97
97
  > Adding `defineTable` does not force a public API onto the join table — gate or omit its
98
98
  > `read` / `crud` blocks as you would any other table. What it supplies is the firewall.
99
+ >
100
+ > The `from:` table may also be the table that consumes the relationship — e.g.
101
+ > `projectMemberOf = { from: 'projectMembers', … }` used as `{ field: 'projectId', via: 'projectMemberOf' }`
102
+ > on `projectMembers` itself ("see the members of projects I belong to"). The subquery then
103
+ > calls the module's own firewall with `skipTenantScopes`, which returns before any `via:`
104
+ > arm is built, so it cannot recurse. On Postgres the API and the database both read the
105
+ > relationship through a `SECURITY DEFINER` helper (`public.qb_rel_<relationship>()`) that reads
106
+ > the relationship table without its own policy, so neither can recurse — see
107
+ > [Relationship arms in SQL](/platform/database/neon#relationship-arms-in-sql).
99
108
 
100
109
 
101
110
  ### Using relationship-roles in resources
@@ -110,7 +110,7 @@ A few mechanics to know:
110
110
  | Builder | Drizzle equivalent | Zod type |
111
111
  |---------|---------------------|----------|
112
112
  | `q.text()` | `text(...)` | `z.string()` |
113
- | `q.url()` | `text(...)` | `z.string().url()` |
113
+ | `q.url()` | `text(...)` | `z.string().url({ protocol: /^https?$/ })` |
114
114
  | `q.int()` | `integer(...)` | `z.number().int()` |
115
115
  | `q.bigint()` | `bigint(..., { mode: 'number' })` | `z.number().int()` within ±(2^53 − 1) |
116
116
  | `q.smallint()` | `smallint(...)` | `z.number().int()` within −32768..32767 |
@@ -132,9 +132,9 @@ In request bodies a column that is not `.required()` is `.optional().nullable()`
132
132
 
133
133
  `q.text()` and `q.url()` accept either a SQL-name string or an options object — `q.text({ sqlName: 'org_id', maxLength: 80 })`. `maxLength` adds `z.string().max(n)` at the validation edge; the SQL column stays `text` (D1 ignores `VARCHAR(n)` length anyway).
134
134
 
135
- `q.url()` is `q.text()` plus `z.string().url()` at the validation edge, so `javascript:` / `data:` URIs and free-form strings are rejected before they ever land in storage or get rendered in the CMS.
135
+ `q.url()` is `q.text()` plus an absolute-`http(s)`-URL check at the validation edge, so `javascript:` / `data:` / `ftp:` URIs and free-form strings are rejected before they ever land in storage or get rendered in the CMS.
136
136
 
137
- `q.id()` emits a plain text primary key. Actual ID assignment at insert time is driven by the provider's `generateId` setting. This keeps q's output decoupled from any specific ID library.
137
+ `q.id()` emits a plain text primary key. Actual ID assignment at insert time is driven by the provider's `generateId` setting (default `"uuid"`). This keeps q's output decoupled from any specific ID library.
138
138
 
139
139
  #### Typed JSON columns
140
140
 
@@ -168,11 +168,12 @@ The schema must be written inline from `z` and literals, because the compiler co
168
168
  - using `z` anywhere else in the table file
169
169
  - importing anything from `zod` other than `{ z }`
170
170
 
171
- For `generateId: "cuid"`, there is one important nuance: import-capable runtime
172
- paths can emit real `createId()` usage, but compiler-managed schema
173
- auto-injection may keep the same `createId()` call site and back it with a
174
- file-local `crypto.randomUUID()` polyfill so schema-generation sandboxes do not
175
- depend on project `node_modules`.
171
+ Under `generateId: "cuid"`, `"nanoid"`, or `"short"`, the `q.id()` default
172
+ calls an npm helper (`createId` from `@paralleldrive/cuid2`, or `nanoid` /
173
+ `customAlphabet` from `nanoid`). Don't import it in the table file, which may
174
+ not import either package. The compiler adds the import to the generated
175
+ `schema.ts` and the package to `package.json`, so the default mints the same
176
+ id shape as the CRUD route.
176
177
 
177
178
  ### Decimals, dates, 64-bit integers, and arrays
178
179
 
@@ -212,6 +213,7 @@ export default feature("invoices", {
212
213
 
213
214
  - **Decimals are strings**, so no value passes through a float. Send `"19.9"` and the API stores and returns `"19.90"`: the value is padded to `scale` digits and leading zeros are dropped, which is how Postgres prints `numeric(p,s)`. D1 stores that same canonical text, so both dialects return identical strings. `precision` (1–1000) and `scale` (0–`precision`) must be number literals, or the compile fails.
214
215
  - **Dates have no time zone.** A `q.date()` value is never converted, so `"2026-03-31"` is the same day for every caller. Use `q.timestamp()` for an instant.
216
+ - **Timestamps are ISO strings on the wire, on both dialects.** On D1, `q.timestamp()` is `text` holding the ISO string. On Postgres it is `timestamptz`. The column accepts a `Date` or an ISO string on write, and its TypeScript type is `Date | string`. Reads come back as a `Date`, which serializes as the same ISO `Z` string. Because Drizzle uses one type for reads and writes, a read is also typed `Date | string` even though it is always a `Date` at runtime — wrap it as `new Date(row.dueAt)` before calling `Date` methods such as `.getTime()` (a breaking type change for Postgres projects written against the earlier `Date`-only type). So `.set({ archivedAt: now })` works and typechecks on either database, on every handle: the scoped `db`, `unsafeDb`, and a raw `createDb()`. Postgres feature schemas import this column's `timestamp` from the generated `src/lib/pg-timestamp.ts` instead of `drizzle-orm/pg-core`. Its SQL type and migrations are unchanged. Filter values for a Postgres timestamp column must parse as a timestamp, or the request returns `400`.
215
217
  - **`q.bigint()` values are JSON numbers, and are capped at ±(2^53 − 1).** Past that, a JSON number can't hold an exact integer, and D1 returns every `INTEGER` as a JS number. The cap still takes a cents column past $90 trillion, where `q.int()` (Postgres `integer`) stops at about $21.4 million. Values written to a Postgres `bigint` outside the API beyond 2^53 will read back rounded.
216
218
  - **Defaults are checked at compile time** against the same rules, because nothing re-validates a DDL default. `q.smallint().default(40000)` fails the compile. A decimal default must already be in canonical form, so write `.default("0.00")` for scale 2, not `"0"`.
217
219
  - **`.array()`** works on `q.text()`, `q.enum()`, `q.int()`, and `q.uuid()`, and must be written once. `.default([])` gives Postgres `'{}'` and D1 `'[]'`. An array column can't declare `.references()`: Postgres has no foreign keys over array elements, so use a join table.
@@ -228,6 +230,8 @@ What you can query depends on the type. The compiler refuses the rest at compile
228
230
 
229
231
  `.searchable()` and `.filterable("like")` are text-only. Masks that format strings (`email`, `phone`, `partial`, and the rest) are refused on `q.bigint()`, `q.smallint()`, and array columns; use `redact` or `custom` there. Decimal and date values are strings, so every mask type works on them. `.defaultNow()` is only accepted on `q.timestamp()`.
230
232
 
233
+ `.defaultNow()` stamps the insert time whenever an insert omits the column. On Postgres it is a real `DEFAULT now()`. On SQLite / D1 the column carries a constant `DEFAULT '1970-01-01T00:00:00.000Z'` (D1 refuses a non-constant default on `ALTER TABLE ADD COLUMN`) plus a `$defaultFn`, and the generated `src/db/index.ts` makes every Drizzle insert use the `$defaultFn` — so only raw SQL that omits the column gets the epoch. Compilers from v0.33.2 until this fix wrote the epoch for Drizzle inserts too; see [Troubleshooting → timestamps read 1970-01-01](/tooling/troubleshooting#timestamps-read-1970-01-01-sqlite--d1) to find and repair affected rows.
234
+
231
235
  ### q.scope() — tenant scope columns
232
236
 
233
237
  `q.scope(kind)` is the canonical way to declare a column that holds a tenant-scope value (org / owner / team). It compiles to `text(...).notNull()` like a regular required text column, plus metadata that the compiler reads to:
@@ -671,7 +675,7 @@ Opt out of audit injection entirely with `compiler.features.auditFields: false`
671
675
 
672
676
  The scoped `db` injected into actions stamps these four columns for you. A handle built directly from `createDb()` does not — that's the documented escape hatch for system writes, sessionless principals, and broad reads the scoped wrapper over-narrows.
673
677
 
674
- Those writes still land in audit-managed tables, and the managed columns carry a DDL default of the unix epoch (so `ALTER TABLE ADD COLUMN` works on populated tables). An omitted column therefore **does not** fail loudly on `NOT NULL` — it silently persists `1970-01-01T00:00:00.000Z`, which reads as a real timestamp everywhere downstream.
678
+ Those writes still land in audit-managed tables. A Drizzle insert that omits `createdAt` / `modifiedAt` gets the insert time (Postgres `DEFAULT now()`; on SQLite the column's `$defaultFn`), but nothing fills `createdBy` / `modifiedBy` — they stay `NULL`. On SQLite the managed timestamps also carry a DDL default of the unix epoch (so `ALTER TABLE ADD COLUMN` works on populated tables), so **raw SQL** that omits them does not fail on `NOT NULL` — it silently persists `1970-01-01T00:00:00.000Z`, which reads as a real timestamp everywhere downstream.
675
679
 
676
680
  Spread the stamp instead of hand-writing four columns at each call site:
677
681
 
@@ -770,7 +774,7 @@ If this is an intentional system-side write, use the unwrapped db directly.
770
774
  Two paths to fix it, depending on intent:
771
775
 
772
776
  - **Mint a synthetic actor** (preferred — preserves attribution) — populate `ctx.userId` with one of the conventions above before calling into your handler.
773
- - **Bypass the wrapper entirely** — use the unwrapped `createDb` instead of the request-context `db`. Use this only for migrations, schema repair, or backfill scripts where you genuinely don't want any audit attribution. The audit columns will fall back to DB defaults (`createdAt`/`modifiedAt` populate from `defaultNow()`; `createdBy`/`modifiedBy` end up `NULL`).
777
+ - **Bypass the wrapper entirely** — use the unwrapped `createDb` instead of the request-context `db`. Use this only for migrations, schema repair, or backfill scripts where you genuinely don't want any audit attribution. `createdAt`/`modifiedAt` still get the insert time from their column default (a raw SQL insert that omits them on SQLite gets the epoch — set them yourself); `createdBy`/`modifiedBy` end up `NULL`.
774
778
 
775
779
  ### Disabling Audit Fields
776
780
 
@@ -123,7 +123,9 @@ Semantics:
123
123
  - **`field: null`** declares a pure stamp transition (check-in/check-out
124
124
  style) — guards + stamps with no state column.
125
125
  - **`actx.now`**: every action's execute context now carries `now` — one ISO
126
- timestamp per invocation. Prefer it over `new Date().toISOString()`.
126
+ timestamp per invocation. Prefer it over `new Date().toISOString()`. It
127
+ writes into a `q.timestamp()` column as-is, on every database and every
128
+ `db` handle — see [Column types](/define/schema#decimals-dates-64-bit-integers-and-arrays).
127
129
 
128
130
  ### On a feature-area route
129
131
 
@@ -254,14 +256,19 @@ otherwise the action would be unreachable, which is almost certainly a bug.
254
256
 
255
257
  ### Wire-level errors
256
258
 
257
- The compiled guard returns **409 `ACCESS_ACTION_NOT_ALLOWED_FOR_STATE`** with
258
- the field, the current value, the requested target, and the allowed set:
259
+ The compiled guard returns **409 `ACCESS_ACTION_NOT_ALLOWED_FOR_STATE`** as
260
+ `application/problem+json` (like every [API error](/api/errors)), with the
261
+ field, the current value, the requested target, and the allowed set:
259
262
 
260
263
  ```json
261
264
  {
262
- "error": "Action not allowed for current record state",
263
- "layer": "access",
265
+ "type": "https://quickback.dev/problems/access-action-not-allowed-for-state",
266
+ "title": "Access action not allowed for state",
267
+ "status": 409,
264
268
  "code": "ACCESS_ACTION_NOT_ALLOWED_FOR_STATE",
269
+ "detail": "Action not allowed for current record state",
270
+ "instance": "/api/v1/applications/app_123/advance",
271
+ "layer": "access",
265
272
  "details": {
266
273
  "field": "status",
267
274
  "current": "interview",
@@ -372,5 +372,6 @@ execute: async ({ db, effects }) => {
372
372
 
373
373
  Effects enqueued by an `execute` that later throws are dropped. The context
374
374
  also carries `now` — one ISO timestamp per invocation; prefer it over
375
- `new Date().toISOString()`.
375
+ `new Date().toISOString()`. See [Column types](/define/schema#decimals-dates-64-bit-integers-and-arrays) for
376
+ writing it into a `q.timestamp()` column.
376
377
 
@@ -76,5 +76,6 @@ The runtime services around your compiled code. Everything you need for a comple
76
76
  - **[Webhooks](/platform/webhooks)** — Inbound (signed) and outbound (retried)
77
77
  - **[Admin UI](/ui/admin)** — Schema-driven admin UI
78
78
  - **[Account UI](/ui/account)** — Pre-built auth and profile pages
79
+ - **[Components](/ui/components)** — shadcn tables, forms, and action dialogs for your own React app
79
80
 
80
81
  Everything runs on **your own Cloudflare account** — no Quickback infrastructure between you and your data.
@@ -124,7 +124,7 @@ When `fromOpenAPI: false`, the emitted call has `capabilities: []` and no proxy
124
124
  - **WebAuthn step-up isn't wired in the approval UI yet.** Capabilities tagged `approvalStrength: "webauthn"` show a Step-up badge but the actual escalation call isn't made — the upstream API for that escalation is still settling. Until it lands, those capabilities will fail server-side regardless of approval.
125
125
  - **No CLI helpers for listing / revoking agents.** Use the BA admin API directly.
126
126
  - **Self-fetch on Cloudflare Workers** adds one subrequest per capability call (~50ms). For typical agent traffic this is fine; for very high-frequency agents consider pinning a custom `onExecute` that uses `app.request()` for in-process routing.
127
- - **`@better-auth/agent-auth` 0.4.5 ships ESM-only exports** without a `require` condition. The compiler image patches the package's `package.json` at install time so the Better Auth CLI's `auth generate` step (jiti / CJS) can resolve it. Remove the patch in the Dockerfile when upstream ships proper exports.
127
+ - **`@better-auth/agent-auth` 0.6.2 ships ESM-only exports** without a `require` condition. The compiler image patches the package's `package.json` at install time so the Better Auth CLI's `auth generate` step (jiti / CJS) can resolve it. Remove the patch in the Dockerfile when upstream ships proper exports.
128
128
 
129
129
  ## Why bearer-only?
130
130
 
@@ -42,11 +42,16 @@ so an extra database silently splits the bootstrap: the roles look right in
42
42
  separating. Two apps means two Neon projects, not two databases.
43
43
 
44
44
  Mixing providers — for example D1 for auth with Neon for features — is not
45
- supported. The per-service config form is rejected at compile time:
45
+ supported. The per-service config form is a type error under `quickback check`
46
+ (the config type has no `auth` / `features` keys) and is rejected at compile
47
+ time:
46
48
 
47
49
  ```
48
- providers.database service-map form is not supported in v2.
49
- Configure one database provider; auth and feature data use the same database.
50
+ providers.database service-map form is not supported in v2 ({ auth, features } is the retired v1 shape).
51
+ Configure ONE database provider — auth and feature data share it:
52
+ database: defineDatabase("cloudflare-d1", { ... }) or database: { name: "neon", config: { ... } }.
53
+ On D1, auth keeps its own database by default (splitDatabases: true);
54
+ name the bindings with authBinding / featuresBinding.
50
55
  ```
51
56
 
52
57
  ## Configuration
@@ -599,8 +604,12 @@ WITH CHECK (
599
604
 
600
605
  ### The soft-delete lane
601
606
 
602
- `deleted_at IS NULL` keeps soft-deleted rows out of every caller's reach. On its
603
- own it also blocks the delete that put them there.
607
+ `deleted_at IS NULL` keeps soft-deleted rows out of every caller's reach. It is
608
+ in the scope policy of every table that carries `deleted_at`, exactly where the
609
+ API firewall adds its own `isNull(deletedAt)` — including a `firewall: [...]`
610
+ array that never mentions `deletedAt` (declare a predicate on `deletedAt`
611
+ yourself to take it over). On its own it also blocks the delete that put them
612
+ there.
604
613
 
605
614
  PostgreSQL applies a SELECT-applicable policy's `USING` expression to the **new**
606
615
  row of an `UPDATE`, not only the existing one, whenever the statement reads the
@@ -819,6 +828,17 @@ USING (owner_id = auth.user_id())
819
828
  WITH CHECK (owner_id = auth.user_id());
820
829
  ```
821
830
 
831
+ **Relationship-scoped** (`{ field: 'projectId', via: 'projectMemberOf' }`) — see
832
+ [Relationship arms in SQL](#relationship-arms-in-sql):
833
+
834
+ ```sql
835
+ CREATE POLICY "tasks_scope" ON "app"."tasks" FOR ALL TO quickback
836
+ USING (organization_id = public.get_active_org_id()
837
+ AND project_id IN (SELECT r.project_id FROM public.qb_rel_project_member_of() r))
838
+ WITH CHECK (organization_id = public.get_active_org_id()
839
+ AND project_id IN (SELECT r.project_id FROM public.qb_rel_project_member_of() r));
840
+ ```
841
+
822
842
  **Exception tables** (`firewall: [{ exception: true }]`) — no scope predicate,
823
843
  so the restrictive deny-anon policy is the only fence left:
824
844
 
@@ -827,6 +847,77 @@ CREATE POLICY "categories_all" ON "app"."categories" FOR ALL TO quickback
827
847
  USING (true) WITH CHECK (true);
828
848
  ```
829
849
 
850
+ ### Relationship arms in SQL
851
+
852
+ Every relationship lookup is enforced by the database, and the generated API
853
+ reads through the same place. Each declared relationship gets one helper,
854
+ emitted in the RLS migration ahead of the policies that call it:
855
+
856
+ ```sql
857
+ CREATE OR REPLACE FUNCTION public.qb_rel_project_member_of()
858
+ RETURNS SETOF "app"."project_members"
859
+ LANGUAGE sql STABLE SECURITY DEFINER SET search_path = ''
860
+ AS $$
861
+ SELECT a.*
862
+ FROM "app"."project_members" a
863
+ WHERE a."user_id" = auth.user_id()
864
+ AND a."deleted_at" IS NULL
865
+ $$;
866
+ ALTER FUNCTION public.qb_rel_project_member_of() OWNER TO quickback_owner;
867
+ REVOKE ALL ON FUNCTION public.qb_rel_project_member_of() FROM PUBLIC;
868
+ GRANT EXECUTE ON FUNCTION public.qb_rel_project_member_of() TO quickback;
869
+ ```
870
+
871
+ The scope policy calls it as
872
+ `"project_id" IN (SELECT r."project_id" FROM public.qb_rel_project_member_of() r)`,
873
+ and so does the generated API: a firewall `via:` arm, a relationship-role access
874
+ check, the action resolver's match row, the `/scope/v1/enter` probe and the
875
+ ws-ticket probe all read the caller's relationship rows from the helper, never
876
+ from the relationship table under its own policy.
877
+
878
+ - **Same lookup as D1.** The body is the relationship subquery the API runs on
879
+ D1: the subject column against the caller's claim, the `where:` literals
880
+ (SQL-quoted), and the related table's soft-delete filter — the API's
881
+ `skipTenantScopes` body. Multi-hop (`hops`) relationships join the same chain
882
+ and return the first hop's rows.
883
+ - **Why `SECURITY DEFINER`.** Under the relationship table's own policy the
884
+ lookup would recurse for a relationship that reads the table it protects
885
+ (`projectMemberOf` on `project_members`), and the table's tenant scope would
886
+ zero a caller with no active org — the case the API skips on purpose. The
887
+ helper runs as `quickback_owner`, which reads the related table through one
888
+ `<table>_quickback_owner_read` policy (`FOR SELECT TO quickback_owner USING (true)`).
889
+ Feature tables `FORCE ROW LEVEL SECURITY`, so the owner needs it; it grants
890
+ nothing new — an owner can always lift `FORCE` on its own table — and the
891
+ runtime role `quickback` is not a member of `quickback_owner`.
892
+ - **Locked down.** `search_path = ''` and fully-qualified names; `EXECUTE` is
893
+ revoked from `PUBLIC` and granted to `quickback` only. The caller comes from
894
+ the transaction's claims, so a lookup on the service handle (no caller)
895
+ returns nothing.
896
+ - **Evaluated once per statement.** The helper takes no arguments, so
897
+ `col IN (SELECT … FROM helper() r)` is an uncorrelated subquery — one hashed
898
+ subplan per statement, the same InitPlan discipline as the claim helpers. A
899
+ per-row `helper(row.col)` call could never be inlined.
900
+ - **Returns the table's own rows.** One helper serves every projection a lookup
901
+ needs (the resource column, the tenant columns the action resolver stamps,
902
+ scope sub-keys), and `CREATE OR REPLACE` stays valid as the table's columns
903
+ change. A helper whose relationship now returns a different table is dropped
904
+ first — with the generated policies that call it, which the same migration
905
+ re-creates.
906
+ - **Tenant binding.** Beside an org arm in an `any:` group the arm becomes
907
+ `(project_id IN (SELECT …) AND (organization_id = <active org> OR <no active org>))`
908
+ — exactly where the API applies the same binding.
909
+ - **Permissions.** A `{ permission }` arm expands as the API expands it; arrow
910
+ hops become `qb_arrow_…` helpers (recursive arrows are a `maxDepth`-bounded
911
+ closure that re-checks the tenant on every row), called by the API too.
912
+ - **Still API-only.** Literal status filters (a conjunct would refuse
913
+ status-changing updates, because PostgreSQL checks an UPDATE's new row against
914
+ the read policy) and claims the Worker never writes into the transaction —
915
+ `ctx.scope.<kind>.<subKey>`, area anchors such as `ctx.event.id`, and
916
+ relationships whose `subject` binds one. These lower to `true` in the policy,
917
+ and the API keeps the table query for such a relationship.
918
+
919
+ Helpers no compile references any more are dropped at the end of the migration.
920
+
830
921
  ### Helper functions
831
922
 
832
923
  | Function | Purpose |
@@ -963,31 +1054,20 @@ is a compile error everywhere, not a Neon-only concern.
963
1054
 
964
1055
  ### How the read is served
965
1056
 
966
- On **Neon**, a via-relationship reachability predicate cannot be expressed as an
967
- RLS policy — the correlated multi-hop join reaches across intermediate tables
968
- that each `FORCE ROW LEVEL SECURITY`, so caller-claims RLS would deny the attendee
969
- to *zero* rows before the app-layer WHERE ever runs. Quickback resolves this by
970
- routing that resource's **read** handlers through the service-role handle
971
- (`createServiceDb(c.env)`) instead of the caller-claims client. RLS stops denying,
972
- and the compiled `buildFirewallConditions(...)` reachability WHERE — the exact
973
- same clause D1 uses — becomes the **sole** row filter.
974
-
975
- This is the D1 trust model, applied to Neon for exactly these reads: the
976
- application layer is the firewall, and RLS is a coarse tenant backstop that steps
977
- aside where it cannot express the grant. It is surgical and fail-closed:
978
-
979
- - Only the affected resource's reads swap handles. **Org / owner / team reads keep
980
- caller claims + the RLS backstop** — they resolve to policies RLS *can* express.
981
- - The swap is gated on a non-empty firewall carrying the reachability predicate;
982
- a service-handle read with no WHERE is a compile error (it would return every
983
- tenant's rows). Fail closed.
984
- - It applies to the **collection `GET /`, `GET /:id`, and views** alike. **Writes
985
- are unchanged** — creates/updates/deletes keep caller claims and the RLS
986
- backstop.
987
-
988
- The **same config compiles identically on D1**, where there is no RLS to bypass:
989
- the read handlers keep `c.get('db')` and the app-layer reachability WHERE was
990
- already the whole story.
1057
+ Reads keep the **caller-claims** handle and the full RLS backstop, on Neon as
1058
+ everywhere else. The reachability WHERE (`buildFirewallConditions(...)`) and the
1059
+ resource's scope policy both call the relationship's
1060
+ [helper](#relationship-arms-in-sql), which walks the hop chain without the
1061
+ intermediate tables' tenant policies — so an attendee with no active org gets
1062
+ exactly their reachable rows, from the API and from the database alike.
1063
+
1064
+ Earlier releases routed these reads through the service-role handle
1065
+ (`createServiceDb`) instead, because the multi-hop join read the intermediate
1066
+ tables under their own tenant scopes and came back empty. That bypassed RLS for
1067
+ the whole read; the routing is gone.
1068
+
1069
+ The **same config compiles identically on D1**: the read handlers keep
1070
+ `c.get('db')`, and the app-layer reachability WHERE runs the join directly.
991
1071
 
992
1072
  ## Webhooks on Neon
993
1073
 
@@ -39,7 +39,7 @@ Condition 2 is broader than it may look, and deliberately so. There is no
39
39
  per-provider inbound webhook configuration surface: the inbound route registers
40
40
  exactly one provider, Stripe, so *any* project that turned webhooks on is a
41
41
  project that can receive Stripe events. The same condition adds `stripe` to the
42
- generated `package.json` (pinned at `^22.5.0`), so the dependency and the client
42
+ generated `package.json` (pinned at `^22.6.1`), so the dependency and the client
43
43
  can never disagree about whether Stripe is in play.
44
44
 
45
45
  > **Accepted over-trigger.** A project that only *receives* Stripe webhooks and