@quickback-dev/cli 0.66.21 → 0.66.23
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/check.js +1 -1
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/create.js +82 -165
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +92 -1
- package/dist/commands/mcp.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/api-client.d.ts +3 -0
- package/dist/lib/api-client.d.ts.map +1 -1
- package/dist/lib/api-client.js +1 -1
- package/dist/lib/api-client.js.map +1 -1
- package/dist/lib/file-writer.d.ts +2 -0
- package/dist/lib/file-writer.d.ts.map +1 -1
- package/dist/lib/file-writer.js.map +1 -1
- package/dist/lib/harness.d.ts +59 -0
- package/dist/lib/harness.d.ts.map +1 -0
- package/dist/lib/harness.js +178 -0
- package/dist/lib/harness.js.map +1 -0
- package/dist/lib/migrations/drizzle-prompts.d.ts +2 -0
- package/dist/lib/migrations/drizzle-prompts.d.ts.map +1 -1
- package/dist/lib/migrations/drizzle-prompts.js +11 -0
- package/dist/lib/migrations/drizzle-prompts.js.map +1 -1
- package/dist/lib/migrations/file-envelopes.d.ts.map +1 -1
- package/dist/lib/migrations/file-envelopes.js +21 -51
- package/dist/lib/migrations/file-envelopes.js.map +1 -1
- package/dist/lib/migrations/prompt-runner.d.ts.map +1 -1
- package/dist/lib/migrations/prompt-runner.js +6 -1
- package/dist/lib/migrations/prompt-runner.js.map +1 -1
- package/dist/skill/docs/api/actions.md +13 -6
- package/dist/skill/docs/api/batch-operations.md +6 -2
- package/dist/skill/docs/api/crud.md +72 -9
- package/dist/skill/docs/api/errors.md +78 -6
- package/dist/skill/docs/api/openapi.md +1 -1
- package/dist/skill/docs/api/query-params.md +6 -7
- package/dist/skill/docs/api/typescript.md +193 -0
- package/dist/skill/docs/configure/index.md +36 -2
- package/dist/skill/docs/configure/providers.md +32 -7
- package/dist/skill/docs/define/changesets.md +2 -0
- package/dist/skill/docs/define/guards.md +7 -2
- package/dist/skill/docs/define/masking.md +14 -0
- package/dist/skill/docs/define/read.md +3 -0
- package/dist/skill/docs/define/schema.md +13 -10
- package/dist/skill/docs/define/transitions.md +9 -4
- package/dist/skill/docs/index.md +1 -0
- package/dist/skill/docs/platform/auth/plugins/agent-auth.md +1 -1
- package/dist/skill/docs/platform/payments/index.md +1 -1
- package/dist/skill/docs/start/frontend.md +278 -0
- package/dist/skill/docs/start/index.md +1 -0
- package/dist/skill/docs/start/template-blog.md +36 -58
- package/dist/skill/docs/start/templates.md +3 -3
- package/dist/skill/docs/tooling/claude-skill.md +10 -1
- package/dist/skill/docs/tooling/cli.md +5 -1
- package/dist/skill/docs/tooling/cloud-compiler/endpoints.md +10 -0
- package/dist/skill/docs/tooling/cloud-compiler/troubleshooting.md +6 -0
- package/dist/skill/docs/tooling/output.md +38 -9
- package/dist/skill/docs/tooling/troubleshooting.md +67 -0
- package/dist/skill/docs/ui/admin/actions.md +6 -2
- package/dist/skill/docs/ui/admin/index.md +1 -1
- package/dist/skill/docs/ui/admin/inline-editing.md +6 -2
- package/dist/skill/docs/ui/admin/schema-format.md +74 -36
- package/dist/skill/docs/ui/admin/schema-registry.md +22 -9
- package/dist/skill/docs/ui/admin/security.md +2 -2
- package/dist/skill/docs/ui/components/action-dialog.md +62 -0
- package/dist/skill/docs/ui/components/auth.md +90 -0
- package/dist/skill/docs/ui/components/index.md +48 -0
- package/dist/skill/docs/ui/components/install.md +118 -0
- package/dist/skill/docs/ui/components/quickback-provider.md +123 -0
- package/dist/skill/docs/ui/components/resource-form.md +80 -0
- package/dist/skill/docs/ui/components/resource-table.md +46 -0
- package/dist/templates/registry.js +1 -1
- package/dist/templates/registry.js.map +1 -1
- package/package.json +1 -1
- package/src/skill/docs/api/actions.md +13 -6
- package/src/skill/docs/api/batch-operations.md +6 -2
- package/src/skill/docs/api/crud.md +72 -9
- package/src/skill/docs/api/errors.md +78 -6
- package/src/skill/docs/api/openapi.md +1 -1
- package/src/skill/docs/api/query-params.md +6 -7
- package/src/skill/docs/api/typescript.md +193 -0
- package/src/skill/docs/configure/index.md +36 -2
- package/src/skill/docs/configure/providers.md +32 -7
- package/src/skill/docs/define/changesets.md +2 -0
- package/src/skill/docs/define/guards.md +7 -2
- package/src/skill/docs/define/masking.md +14 -0
- package/src/skill/docs/define/read.md +3 -0
- package/src/skill/docs/define/schema.md +13 -10
- package/src/skill/docs/define/transitions.md +9 -4
- package/src/skill/docs/index.md +1 -0
- package/src/skill/docs/platform/auth/plugins/agent-auth.md +1 -1
- package/src/skill/docs/platform/payments/index.md +1 -1
- package/src/skill/docs/start/frontend.md +278 -0
- package/src/skill/docs/start/index.md +1 -0
- package/src/skill/docs/start/template-blog.md +36 -58
- package/src/skill/docs/start/templates.md +3 -3
- package/src/skill/docs/tooling/claude-skill.md +10 -1
- package/src/skill/docs/tooling/cli.md +5 -1
- package/src/skill/docs/tooling/cloud-compiler/endpoints.md +10 -0
- package/src/skill/docs/tooling/cloud-compiler/troubleshooting.md +6 -0
- package/src/skill/docs/tooling/output.md +38 -9
- package/src/skill/docs/tooling/troubleshooting.md +67 -0
- package/src/skill/docs/ui/admin/actions.md +6 -2
- package/src/skill/docs/ui/admin/index.md +1 -1
- package/src/skill/docs/ui/admin/inline-editing.md +6 -2
- package/src/skill/docs/ui/admin/schema-format.md +74 -36
- package/src/skill/docs/ui/admin/schema-registry.md +22 -9
- package/src/skill/docs/ui/admin/security.md +2 -2
- package/src/skill/docs/ui/components/action-dialog.md +62 -0
- package/src/skill/docs/ui/components/auth.md +90 -0
- package/src/skill/docs/ui/components/index.md +48 -0
- package/src/skill/docs/ui/components/install.md +118 -0
- package/src/skill/docs/ui/components/quickback-provider.md +123 -0
- package/src/skill/docs/ui/components/resource-form.md +80 -0
- package/src/skill/docs/ui/components/resource-table.md +46 -0
|
@@ -9,7 +9,7 @@ The generated API returns structured error responses with consistent fields acro
|
|
|
9
9
|
| `200` | OK | Successful GET, PATCH, DELETE |
|
|
10
10
|
| `201` | Created | Successful POST |
|
|
11
11
|
| `207` | Multi-Status | Batch operation with mixed results |
|
|
12
|
-
| `400` | Bad Request | Guard violation, validation error, invalid input |
|
|
12
|
+
| `400` | Bad Request | Guard violation, validation error, invalid input, malformed record id (`INVALID_ID`) |
|
|
13
13
|
| `401` | Unauthorized | Missing or expired authentication |
|
|
14
14
|
| `403` | Forbidden | Access denied (wrong role, condition failed) or firewall blocked it |
|
|
15
15
|
| `404` | Not Found | Firewall blocked the record on a resource that set `firewallErrorMode: 'hide'` (or the route doesn't exist) |
|
|
@@ -66,7 +66,7 @@ enough to triage or hand the response to an LLM agent without grepping logs:
|
|
|
66
66
|
| `layer` | string | Extension — security layer that rejected the request |
|
|
67
67
|
| `code` | string | Extension — machine-readable error code (the full enum ships in `openapi.json` as `Problem.code`) |
|
|
68
68
|
| `details` | object | Extension — layer-specific context (optional) |
|
|
69
|
-
| `pointer` | string | Extension — first
|
|
69
|
+
| `pointer` | string | Extension — first key of `details.fields` for guard and validation failures, e.g. `/stage` (optional) |
|
|
70
70
|
| `hint` | string | Extension — actionable guidance for resolution (optional) |
|
|
71
71
|
| `request` | object | Extension — method, URL, redacted body, and request ID. Auto-attached by the runtime so the error body is self-contained — bodies are capped at 4 KB and well-known sensitive keys (`password`, `token`, `secret`, `apiKey`, `otp`, `code`, `authorization`, …) plus every credential field the compiler itself introduces (`sessionToken`, `eventSessionToken`, `scopeJwt`, `scopeToken`, `wsTicket`, `inviteToken`, `jwt`, `signature`, …) are replaced with `"[REDACTED]"` |
|
|
72
72
|
|
|
@@ -197,13 +197,16 @@ Guard violations return **400 Bad Request** when the request body contains field
|
|
|
197
197
|
"layer": "guards",
|
|
198
198
|
"code": "GUARD_FIELD_NOT_CREATEABLE",
|
|
199
199
|
"details": {
|
|
200
|
-
"fields":
|
|
200
|
+
"fields": { "stage": "cannot be set on create" }
|
|
201
201
|
},
|
|
202
202
|
"pointer": "/stage",
|
|
203
203
|
"hint": "These fields are set automatically or must be omitted"
|
|
204
204
|
}
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
+
`GUARD_FIELD_PROTECTED` also carries `details.actions` — the actions that may
|
|
208
|
+
change the field.
|
|
209
|
+
|
|
207
210
|
**Error codes:**
|
|
208
211
|
|
|
209
212
|
| Code | Description |
|
|
@@ -214,6 +217,67 @@ Guard violations return **400 Bad Request** when the request body contains field
|
|
|
214
217
|
| `GUARD_FIELD_IMMUTABLE` | Field cannot be modified after creation |
|
|
215
218
|
| `GUARD_SYSTEM_MANAGED` | System field (createdAt, modifiedAt, etc.) |
|
|
216
219
|
|
|
220
|
+
### Malformed record id (400)
|
|
221
|
+
|
|
222
|
+
Record routes (`GET`/`PATCH`/`PUT`/`DELETE /:id`, the changeset `PATCH`, and
|
|
223
|
+
record actions at `/:id/<action>`) check `:id` against the table's id format
|
|
224
|
+
and answer **400** before any database work when it can't be an id — a UUID
|
|
225
|
+
route given `job_123`, a serial route given `abc`:
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"type": "https://quickback.dev/problems/invalid-id",
|
|
230
|
+
"title": "Invalid id",
|
|
231
|
+
"status": 400,
|
|
232
|
+
"detail": "Malformed \"id\" path parameter",
|
|
233
|
+
"layer": "validation",
|
|
234
|
+
"code": "INVALID_ID",
|
|
235
|
+
"details": { "param": "id", "expected": "a UUID" },
|
|
236
|
+
"hint": "\"id\" must be a UUID. No record was looked up."
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
| Code | Description |
|
|
241
|
+
|------|-------------|
|
|
242
|
+
| `INVALID_ID` | `:id` isn't shaped like the table's ids — see [Malformed ids](/api/crud#malformed-ids-400-invalid_id) for the per-strategy shapes, what is never checked, and the `validateIdParams: false` opt-out |
|
|
243
|
+
|
|
244
|
+
It is its own code, not a `VALIDATION_*` one: those describe the request
|
|
245
|
+
*body*, and carry a JSON pointer into it. A bad path segment has no pointer,
|
|
246
|
+
and "that's not an id" (400) versus "no such row" (403/404) is the
|
|
247
|
+
distinction a client wants to branch on.
|
|
248
|
+
|
|
249
|
+
### Validation (400)
|
|
250
|
+
|
|
251
|
+
A body that fails the column or action-input schema returns **400** with
|
|
252
|
+
`layer: "validation"`: `VALIDATION_ERROR` for CRUD bodies,
|
|
253
|
+
`VALIDATION_INVALID_INPUT` for action input and query parameters (which also
|
|
254
|
+
carries the raw Zod `details.issues`), `VALIDATION_FAILED` inside a changeset.
|
|
255
|
+
`details.fields` maps each offending field to its message; an unknown key is
|
|
256
|
+
reported under its own name:
|
|
257
|
+
|
|
258
|
+
```json
|
|
259
|
+
{
|
|
260
|
+
"detail": "Invalid input",
|
|
261
|
+
"layer": "validation",
|
|
262
|
+
"code": "VALIDATION_INVALID_INPUT",
|
|
263
|
+
"details": {
|
|
264
|
+
"issues": [ … ],
|
|
265
|
+
"fields": { "name": "Required", "status": "Unrecognized field" }
|
|
266
|
+
},
|
|
267
|
+
"pointer": "/name"
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Field errors — one shape
|
|
272
|
+
|
|
273
|
+
`details.fields` has **one** shape on every layer that names fields — guards,
|
|
274
|
+
body and action-input validation, `FK_NOT_FOUND`: an object mapping the field
|
|
275
|
+
name (a dotted path for nested input) to a human-readable message. A form can
|
|
276
|
+
render each message under its input without knowing which layer rejected the
|
|
277
|
+
request; the generated client exposes it as
|
|
278
|
+
[`QuickbackError.fields`](/api/typescript#fetch-client). `pointer` names the
|
|
279
|
+
first entry.
|
|
280
|
+
|
|
217
281
|
### Masking
|
|
218
282
|
|
|
219
283
|
Masking doesn't produce errors — it silently transforms field values in the response.
|
|
@@ -227,11 +291,19 @@ Surfaced when a SQL write fails *post-validation* — most often a `NOT NULL` or
|
|
|
227
291
|
"detail": "Duplicate value",
|
|
228
292
|
"layer": "database",
|
|
229
293
|
"code": "DB_UNIQUE_VIOLATION",
|
|
230
|
-
"details": {
|
|
231
|
-
|
|
294
|
+
"details": {
|
|
295
|
+
"column": "organizationId",
|
|
296
|
+
"columns": ["organizationId", "email"],
|
|
297
|
+
"fields": { "organizationId": "Already taken", "email": "Already taken" }
|
|
298
|
+
},
|
|
299
|
+
"hint": "A record with this \"organizationId\" + \"email\" already exists"
|
|
232
300
|
}
|
|
233
301
|
```
|
|
234
302
|
|
|
303
|
+
A unique violation names every column of the constraint (a composite unique
|
|
304
|
+
lists all of them) as API field names, and marks each in `details.fields` so a
|
|
305
|
+
form can show the conflict inline. `details.column` is the first of them.
|
|
306
|
+
|
|
235
307
|
**Error codes:**
|
|
236
308
|
|
|
237
309
|
| Code | Status | Description |
|
|
@@ -273,7 +345,7 @@ keep the internal flat shape (`error` message field, `layer`, `code`,
|
|
|
273
345
|
"error": "Field cannot be set during creation",
|
|
274
346
|
"layer": "guards",
|
|
275
347
|
"code": "GUARD_FIELD_NOT_CREATEABLE",
|
|
276
|
-
"details": { "fields":
|
|
348
|
+
"details": { "fields": { "stage": "cannot be set on create" } },
|
|
277
349
|
"hint": "These fields are set automatically or must be omitted"
|
|
278
350
|
}
|
|
279
351
|
}
|
|
@@ -35,7 +35,7 @@ The generated component schemas carry enough type information that strict valida
|
|
|
35
35
|
- **Logical q types survive database lowering** — `q.bool()` remains `boolean`, `q.timestamp()` remains an ISO date-time string, and `q.url()` retains its URI format even when D1 stores the value as text or integer.
|
|
36
36
|
- **Closed enums on `text(_, { enum: [...] })` columns** — emitted as `{ type: "string", enum: [...] }`, narrowing to a literal union in TS.
|
|
37
37
|
- **`Error.code` is a closed enum** — every `code` value the API can emit (`AUTH_MISSING`, `DB_UNIQUE_VIOLATION`, `BATCH_SIZE_EXCEEDED`, …) is enumerated so consumers can `switch` exhaustively.
|
|
38
|
-
- **ID `format`** — only emitted as `format: "uuid"` when your project
|
|
38
|
+
- **ID `format`** — only emitted as `format: "uuid"` when your project sets `generateId: "uuid"` explicitly. An unset `generateId` mints UUIDs too, but the table may still hold prefixed ids from before `"uuid"` became the default, so it gets no `format`. cuid2 / prefixed / nanoid / serial generators get plain `{ type: "string" }`, keeping strict OpenAPI validators happy.
|
|
39
39
|
|
|
40
40
|
### Action input and output schemas
|
|
41
41
|
|
|
@@ -90,8 +90,8 @@ currently wired into the emitted route.
|
|
|
90
90
|
- `view` — the named projection behind the response; `null` for the default collection read
|
|
91
91
|
- `count` — number of records returned on this page
|
|
92
92
|
- `page` / `pageSize` — derived from `?offset=` and `?limit=`
|
|
93
|
-
- `hasMore` — whether more rows exist in the queried direction. Without `?total=true` it comes from a `limit + 1` over-fetch probe, so it never lies on a final page that exactly fills the limit; with `?total=true` it is page arithmetic (`page < totalPages`).
|
|
94
|
-
- `nextCursor` / `prevCursor` — keyset cursors; pass them back as `?starting_after=` and `?ending_before=`. Treat them as opaque, but they are encoded, not encrypted: they carry the boundary row's sort-key values. Either can be `null` — including when the sort includes a [masked](/define/masking) column the caller may sort by (`query.roles`) but not see (`show.roles`); page with `?offset=` in that case.
|
|
93
|
+
- `hasMore` — whether more rows exist in the queried direction. Without `?total=true` it comes from a `limit + 1` over-fetch probe, so it never lies on a final page that exactly fills the limit; with `?total=true` it is page arithmetic (`page < totalPages`) on offset pages, and the probe again on cursor pages.
|
|
94
|
+
- `nextCursor` / `prevCursor` — keyset cursors; pass them back as `?starting_after=` and `?ending_before=`. Treat them as opaque, but they are encoded, not encrypted: they carry the boundary row's sort-key values. Either can be `null` — including when the sort includes a [masked](/define/masking) column the caller may sort by (`query.roles`) but not see (`show.roles`), or a column the response does not carry (a view sorting on a field it doesn't list, or `?fields=` without the sort key); page with `?offset=` in that case.
|
|
95
95
|
- `total` / `totalPages` — present **only** when the request passed `?total=true` (see below)
|
|
96
96
|
|
|
97
97
|
There is no `limit` or `offset` member in `pagination`.
|
|
@@ -156,13 +156,13 @@ GET /api/v1/jobs?fields=id,title,status&status=open&sort=-createdAt
|
|
|
156
156
|
GET /api/v1/jobs/job_123?fields=id,title,salaryMin,salaryMax
|
|
157
157
|
```
|
|
158
158
|
|
|
159
|
-
All columns are available including system columns (`id`, `organizationId`, `createdAt`, `modifiedAt`, etc.).
|
|
159
|
+
All declared columns are available, including system columns (`id`, `organizationId`, `createdAt`, `modifiedAt`, etc.). An unknown field name is a `400` Problem (`Unknown field "<name>"`), never silently dropped. An empty `?fields=` returns all columns. Views ignore `?fields=` — they project their own `fields`.
|
|
160
160
|
|
|
161
161
|
**Security**: Masking still applies to selected fields. Requesting `?fields=ssn` will return the masked value, not the raw data.
|
|
162
162
|
|
|
163
163
|
## Total Count
|
|
164
164
|
|
|
165
|
-
Get the total number of matching records across all pages by adding `?total=true`. Available on LIST and VIEW routes.
|
|
165
|
+
Get the total number of matching records across all pages by adding `?total=true`. Available on LIST and VIEW routes. The count ignores `?starting_after=` / `?ending_before=`: a cursor page reports the same `total` as the first page.
|
|
166
166
|
|
|
167
167
|
```bash
|
|
168
168
|
GET /api/v1/jobs?status=open&total=true
|
|
@@ -318,9 +318,8 @@ by target primary key — row objects are never mutated.
|
|
|
318
318
|
each listed FK column in its `fields` projection (compile error
|
|
319
319
|
otherwise — the embedded lookup pivots on that column).
|
|
320
320
|
|
|
321
|
-
**Strict fields
|
|
322
|
-
`fields[<fk>]=` are rejected with a 400 Problem.
|
|
323
|
-
historical silent-drop for bare `?fields=`.) A `?fields=` projection that
|
|
321
|
+
**Strict fields:** unknown names in bare `?fields=` and in
|
|
322
|
+
`fields[<fk>]=` are rejected with a 400 Problem. A `?fields=` projection that
|
|
324
323
|
drops the FK column of a requested `?include=` is also a **400** —
|
|
325
324
|
`include=orderId requires "orderId" in ?fields=` — never a silently-empty
|
|
326
325
|
`included` slot.
|
|
@@ -112,6 +112,23 @@ function that requires the real value cannot silently accept the default row.
|
|
|
112
112
|
Name the role you fetched with to get the revealed type; a union role
|
|
113
113
|
(`Row<"member" | "admin">`) yields `T | Qb.Masked<T>`.
|
|
114
114
|
|
|
115
|
+
A masked value narrower than a free string — a number, boolean, array, JSON
|
|
116
|
+
value or enum literal — cannot keep its type once masked: the `redact` mask
|
|
117
|
+
replaces it with the string `"[REDACTED]"`. `Qb.Masked<T>` admits that
|
|
118
|
+
marker, typed `Qb.Redacted`, so narrow before using the value:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// masking: { salary: { type: 'redact', show: { roles: ['admin'] } } } — q.int()
|
|
122
|
+
declare const row: Api.jobs.Row;
|
|
123
|
+
row.salary; // Qb.Masked<number> | null (includes Qb.Redacted)
|
|
124
|
+
if (typeof row.salary === "number") console.log(row.salary * 12);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
OpenAPI documents the same thing: the column's schema becomes
|
|
128
|
+
`anyOf: [<schema>, { type: "string", enum: ["[REDACTED]"] }]`. String-shaped
|
|
129
|
+
masks (`email`, `phone`, …) can't mask such columns at all — see
|
|
130
|
+
[Masking](/define/masking#non-string-columns).
|
|
131
|
+
|
|
115
132
|
`show: { or: 'owner' }` reveals by record ownership, which no type parameter
|
|
116
133
|
can see, so those columns stay `Masked` for every role outside `show.roles`.
|
|
117
134
|
|
|
@@ -208,6 +225,182 @@ const api = createClient<paths>({ baseUrl: "https://api.example.com" });
|
|
|
208
225
|
const { data } = await api.GET("/api/v1/jobs/{id}", { params: { path: { id } } });
|
|
209
226
|
```
|
|
210
227
|
|
|
228
|
+
## Fetch client
|
|
229
|
+
|
|
230
|
+
Set `client: true` and every compile also emits `quickback.client.ts`: a
|
|
231
|
+
zero-dependency `fetch` client with one method per generated route, typed
|
|
232
|
+
through `quickback.gen.ts`. It has no React and no runtime package, and it is
|
|
233
|
+
the only generated code that knows the wire format (list envelopes, filter
|
|
234
|
+
syntax, Problem Details), so UI code built on it never builds a URL or parses a
|
|
235
|
+
response.
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
export default defineConfig({
|
|
239
|
+
client: true, // quickback.client.ts
|
|
240
|
+
// client: "apps/web/src/lib/api.ts", // or one custom path
|
|
241
|
+
// client: ["apps/web/src/api.ts", "apps/admin/src/api.ts"],
|
|
242
|
+
});
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
`client` requires `types` — the client imports `Api` and `Qb` from the first
|
|
246
|
+
`types` output, and the compile fails if `types` is `false`. It is off by
|
|
247
|
+
default.
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
import { createClient, QuickbackError } from "./quickback.client";
|
|
251
|
+
|
|
252
|
+
const api = createClient({
|
|
253
|
+
baseUrl: "https://api.example.com", // paths already include /api/v1
|
|
254
|
+
// credentials: "include" by default — the Better Auth session cookie
|
|
255
|
+
// headers: () => ({ authorization: `Bearer ${token}` }),
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// GET /api/v1/applications?stage.in=screen,offer&sort=-createdAt&total=true
|
|
259
|
+
const page = await api.applications.list({
|
|
260
|
+
filter: { "stage.in": ["screen", "offer"] },
|
|
261
|
+
sort: "-createdAt",
|
|
262
|
+
total: true,
|
|
263
|
+
});
|
|
264
|
+
page.data; // Api.applications.Row[]
|
|
265
|
+
page.pagination.total; // present because total: true
|
|
266
|
+
|
|
267
|
+
const app = await api.applications.get(id); // bare record
|
|
268
|
+
await api.applications.update(id, { notes: "…" }); // bare record
|
|
269
|
+
await api.applications.delete(id); // void ({ success: true } on the wire)
|
|
270
|
+
await api.applications.views.pipeline({ limit: 25 });
|
|
271
|
+
await api.applications.actions.advance(id, { notes: "Strong interview" });
|
|
272
|
+
|
|
273
|
+
try {
|
|
274
|
+
await api.applications.create({ candidateId, jobId });
|
|
275
|
+
} catch (err) {
|
|
276
|
+
if (err instanceof QuickbackError) {
|
|
277
|
+
err.status; // HTTP status
|
|
278
|
+
err.problem; // Qb.Problem when the body was application/problem+json, else null
|
|
279
|
+
err.fields; // { [field]: message } from details.fields — guards and validation alike — else null
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Batch, upsert and pagination
|
|
285
|
+
|
|
286
|
+
Where the batch routes exist, `api.<x>.batch` sends the documented
|
|
287
|
+
[batch bodies](/api/batch-operations); `207` partial success resolves (read
|
|
288
|
+
`errors` and `meta.transactional`), a fail-fast stop throws. `upsert(id, body)`
|
|
289
|
+
is `PUT /:id` and exists only on tables that mount it (`guards: false` +
|
|
290
|
+
`generateId: false`).
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
const result = await api.applications.batch.create(records, { failFast: true });
|
|
294
|
+
result.success; // Api.applications.Row[]
|
|
295
|
+
result.errors; // [{ index, record, error: { code, details: { fields } } }]
|
|
296
|
+
await api.applications.batch.update([{ id, stage: "offer" }]);
|
|
297
|
+
await api.applications.batch.delete([id1, id2]);
|
|
298
|
+
|
|
299
|
+
// Every page, following pagination.nextCursor (?starting_after=). When the
|
|
300
|
+
// cursor is null — sorting by a column masked for you — it pages by offset.
|
|
301
|
+
import { paginate } from "./quickback.client";
|
|
302
|
+
for await (const page of paginate(api.applications.list, { limit: 100 })) {
|
|
303
|
+
page.data;
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Bearer lane (React Native, native clients)
|
|
308
|
+
|
|
309
|
+
By default the client authenticates with the Better Auth session cookie
|
|
310
|
+
(`credentials: "include"`). React Native and other non-browser clients send
|
|
311
|
+
no `Origin` header, so every cookie-authenticated write is refused with
|
|
312
|
+
`403 CSRF_ORIGIN_REJECTED` — the [CSRF guard](/platform/auth/security) only
|
|
313
|
+
admits cookie mutations from a trusted origin. Use the bearer lane instead:
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
import * as SecureStore from "expo-secure-store";
|
|
317
|
+
|
|
318
|
+
const api = createClient({
|
|
319
|
+
baseUrl: "https://api.example.com",
|
|
320
|
+
auth: "bearer", // no cookies; credentials default to "omit"
|
|
321
|
+
sessionStore: { // default: memory, lost on reload
|
|
322
|
+
get: () => SecureStore.getItemAsync("qb.session"),
|
|
323
|
+
set: (token) => (token
|
|
324
|
+
? SecureStore.setItemAsync("qb.session", token)
|
|
325
|
+
: SecureStore.deleteItemAsync("qb.session")),
|
|
326
|
+
},
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
// Sign in through the client: the session token arrives in set-auth-token
|
|
330
|
+
// on /auth/v1/* and is saved to sessionStore.
|
|
331
|
+
await api.request("POST", "/auth/v1/sign-in/email", { body: { email, password } });
|
|
332
|
+
await api.applications.list();
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Every request carries `Authorization: Bearer <token>`:
|
|
336
|
+
|
|
337
|
+
1. the JWT the API returned last in `set-auth-token` (kept in memory — with
|
|
338
|
+
[`auth.jwt`](/platform/auth/jwt-optimization) every session-authenticated
|
|
339
|
+
call returns one), else
|
|
340
|
+
2. the session token from `sessionStore`.
|
|
341
|
+
|
|
342
|
+
`set-auth-token` means two things by path: under `/auth/v1` it is Better
|
|
343
|
+
Auth's **session** token (saved to `sessionStore`); anywhere else it is a
|
|
344
|
+
short-lived **JWT** (cached in memory). When the API answers `401` to a JWT —
|
|
345
|
+
expired, key rotated, [revoked](/platform/auth/jwt-optimization#revocation--revocationcheck-kv) —
|
|
346
|
+
the client drops it and retries the request **once** on the session token;
|
|
347
|
+
the session path re-validates and returns a fresh JWT. A `401` on the session
|
|
348
|
+
token itself is final. An `authorization` header you pass in `headers` wins
|
|
349
|
+
over the lane.
|
|
350
|
+
|
|
351
|
+
### Realtime
|
|
352
|
+
|
|
353
|
+
With realtime enabled, `api.realtime.subscribe(handler, { ticket? })` opens
|
|
354
|
+
the WebSocket for you: it mints a [ws-ticket](/platform/realtime/using-realtime)
|
|
355
|
+
through the same auth lane (a fresh one for every reconnect — tickets live 60
|
|
356
|
+
seconds), shares one socket between subscribers with the same `ticket` body,
|
|
357
|
+
reconnects two seconds after a drop, and closes when the last subscriber
|
|
358
|
+
unsubscribes. Frames are CloudEvents envelopes — switch on `qbframe`.
|
|
359
|
+
|
|
360
|
+
```typescript
|
|
361
|
+
const unsubscribe = api.realtime.subscribe((frame) => {
|
|
362
|
+
if (frame.qbframe === "postgres_changes") refetch(frame.data.table);
|
|
363
|
+
});
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
The client mirrors the type tree: `api.<x>` exists wherever `Api.<x>` is a
|
|
367
|
+
table with routes, and a method exists **only** if its route does — a table
|
|
368
|
+
without `delete` access has no `delete`. Record actions take the record id
|
|
369
|
+
first; standalone actions with path parameters take a `params` object; `GET`
|
|
370
|
+
actions send their input as query parameters. Actions declared
|
|
371
|
+
`responseType: 'stream'` or `'file'` resolve to the raw `Response`.
|
|
372
|
+
List-shaped methods accept `limit`, `offset`, `sort`, `search`, `total`,
|
|
373
|
+
`fields`, `include`, `startingAfter` / `endingBefore` and `filter` — see
|
|
374
|
+
[Query Parameters](/api/query-params); array filter values are comma-joined for
|
|
375
|
+
`.in`, and an unknown filter field is a `400`, not an ignored key.
|
|
376
|
+
Changeset (`application/vnd.quickback.changeset+json`) writes are not in the
|
|
377
|
+
client; send them with `api.request`.
|
|
378
|
+
|
|
379
|
+
Runtime extras for generic UI and native clients:
|
|
380
|
+
|
|
381
|
+
- `resources` — keyed by **schema-registry table name** (the key of
|
|
382
|
+
`SchemaRegistry.tables`, the table's JS name), so UI holding a registry
|
|
383
|
+
table can reach its routes without building a URL:
|
|
384
|
+
`{ client, table, ops, views, actions, recordActions, routes }`. `client` is
|
|
385
|
+
the dotted path on the client (`"applications"`, `"crm.contacts"`);
|
|
386
|
+
`recordActions` is the subset of `actions` that take the record id;
|
|
387
|
+
`routes` maps `list` / `get` / `create` / `update` / `delete` / `upsert`,
|
|
388
|
+
`batchCreate` / `batchUpdate` / `batchDelete` / `batchUpsert`,
|
|
389
|
+
`views.<name>` and `actions.<name>` to `{ method, path }` (path templates
|
|
390
|
+
with `{id}`) for clients that build requests themselves (Swift, Kotlin).
|
|
391
|
+
- `api.schema()` — `GET /api/v1/schema`, typed as `SchemaRegistry` (see
|
|
392
|
+
[Schema Registry](/ui/admin/schema-registry)). The registry is **fetched,
|
|
393
|
+
never embedded**: it describes columns, roles and masking, so it stays
|
|
394
|
+
behind that route's auth gate instead of shipping in every frontend bundle.
|
|
395
|
+
The gate defaults to platform sysadmins; open it to your frontend's users
|
|
396
|
+
with [`schemaRegistry.access`](/configure#schema-registry-access).
|
|
397
|
+
- `api.request(method, path, { query, body })` — any other route (Better Auth,
|
|
398
|
+
changesets, custom paths) through the same auth lane and error handling.
|
|
399
|
+
|
|
400
|
+
The emitted file is plain TypeScript that passes `strict`,
|
|
401
|
+
`erasableSyntaxOnly`, `verbatimModuleSyntax` and `noUnused*` — it drops into a
|
|
402
|
+
Vite / shadcn template as-is.
|
|
403
|
+
|
|
211
404
|
## Configuration
|
|
212
405
|
|
|
213
406
|
The artifact is on by default:
|
|
@@ -108,7 +108,8 @@ Every optional top-level key the config accepts is listed below. You never have
|
|
|
108
108
|
| `security` | `object \| false` | HTTP response security headers (CSP, HSTS, COOP/COEP, Referrer/Permissions-Policy) — see [Security Headers](/configure/security) |
|
|
109
109
|
| `openapi` | `object` | OpenAPI spec generation (`generate`, `publish`, `docs: 'scalar' \| 'swagger'`, `types`) — see [OpenAPI](/api/openapi) |
|
|
110
110
|
| `types` | `boolean \| object` | Quickback's first-party TypeScript contract (`output`, `brandIds`) — see [TypeScript](/api/typescript) |
|
|
111
|
-
| `
|
|
111
|
+
| `client` | `boolean \| string \| string[]` | Emit `quickback.client.ts`, a zero-dependency `fetch` client typed by `types` (default off; requires `types`) — see [Fetch client](/api/typescript#fetch-client) |
|
|
112
|
+
| `schemaRegistry` | `object` | Schema registry for the CMS and generic UI: `{ generate: false }` disables it; `access` sets who may read `GET /api/v1/schema` — see [Schema registry access](#schema-registry-access) and [Schema Registry](/ui/admin/schema-registry) |
|
|
112
113
|
| `etag` | `object` | ETag caching for GET responses (`{ enabled: false }` to disable) — see [Caching & ETags](/api/caching) |
|
|
113
114
|
| `email` | `object` | Email delivery config (`provider`, `from`, `fromName`, `region`) — see [Email Configuration](#email-configuration) |
|
|
114
115
|
| `push` | `object` | Web Push (VAPID keys, TTL/urgency defaults, queue fan-out) — see [Push](/platform/push) |
|
|
@@ -557,6 +558,39 @@ If you only want Better Auth to **advertise** itself on a different URL (e.g. so
|
|
|
557
558
|
|
|
558
559
|
`auth.domain` (Shape 1, above) is the heavier option: it binds an actual hostname to the Worker, configures CORS/cookies/CSP for it, and adds the path-shortcut rewriter. Use it when you want the dedicated hostname as a real ingress, not just a label.
|
|
559
560
|
|
|
561
|
+
## Schema registry access
|
|
562
|
+
|
|
563
|
+
`GET /api/v1/schema` serves the [schema registry](/ui/admin/schema-registry) —
|
|
564
|
+
the columns, validation rules, views, actions, masking and access metadata
|
|
565
|
+
that generic UI renders from (the CMS, and components built on the
|
|
566
|
+
[fetch client](/api/typescript#fetch-client)'s `api.schema()`). It describes
|
|
567
|
+
your data model, so it is gated, by default to platform sysadmins.
|
|
568
|
+
|
|
569
|
+
A frontend for your own users opens it with `schemaRegistry.access`, with or
|
|
570
|
+
without the CMS:
|
|
571
|
+
|
|
572
|
+
```typescript
|
|
573
|
+
export default defineConfig({
|
|
574
|
+
client: true,
|
|
575
|
+
schemaRegistry: { access: "member" },
|
|
576
|
+
});
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
| `schemaRegistry.access` | Admits | Denied with |
|
|
580
|
+
|---|---|---|
|
|
581
|
+
| omitted | whatever `cms.access` admits (`"sysadmin"` by default) | `403 CMS_ACCESS_DENIED` |
|
|
582
|
+
| `"sysadmin"` | `user.role === "sysadmin"` | `403 CMS_ACCESS_DENIED` |
|
|
583
|
+
| `"member"` | sysadmins, and any caller holding an organization membership | `403 CMS_ACCESS_DENIED` |
|
|
584
|
+
| `"authenticated"` | any signed-in caller — for owner-scoped apps with no organizations | `401 AUTH_MISSING` |
|
|
585
|
+
|
|
586
|
+
In every mode an anonymous caller gets `401 AUTH_MISSING` (sign in) first;
|
|
587
|
+
`403 CMS_ACCESS_DENIED` is only ever sent to a signed-in caller who lacks the
|
|
588
|
+
role.
|
|
589
|
+
|
|
590
|
+
The route is also the CMS's gate, so with `cms` enabled `schemaRegistry.access`
|
|
591
|
+
must equal `cms.access` — a mismatch is a compile error rather than a silent
|
|
592
|
+
widening of the CMS. The CMS has no `"authenticated"` mode.
|
|
593
|
+
|
|
560
594
|
## CMS Configuration
|
|
561
595
|
|
|
562
596
|
Embed the [Admin UI](/ui/admin) in your compiled Worker. It reads your schema registry and renders a complete admin interface — zero UI code per table.
|
|
@@ -578,7 +612,7 @@ cms: { domain: "cms.example.com", sysadmin: true },
|
|
|
578
612
|
| Option | Type | Default | Description |
|
|
579
613
|
|--------|------|---------|-------------|
|
|
580
614
|
| `domain` | `string` | — | Custom domain for CMS. Adds a `custom_domain` route to `wrangler.toml`. |
|
|
581
|
-
| `access` | `"
|
|
615
|
+
| `access` | `"sysadmin" \| "member"` | `"sysadmin"` | Who can use the CMS. `"sysadmin"` admits `user.role === "sysadmin"` only; `"member"` also admits any caller holding an organization membership, scoped to their active organization. `appmanager` is admitted by neither. The real gate is `GET /api/v1/schema` (and `custom_view` CRUD) — both answer 403 with `CMS_ACCESS_DENIED` naming the requirement (401 `AUTH_MISSING` when not signed in); the SPA shell is served to any signed-in caller so it can explain. The pre-v0.62 values `"admin"` and `"user"` are compile errors. See [CMS Connecting](/ui/admin/connecting) for the full enforcement model. |
|
|
582
616
|
| `sysadmin` | `boolean` | `false` | Cross-tenant DB-admin tier. When `true`, opts into the `SYSADMIN` pseudo-role (`user.role === "sysadmin"`), the firewall escape hatch (sysadmins bypass tenant scopes, soft-delete still enforced), the cross-tenant `/auth/v1/admin/list-organizations` endpoint (sibling of Better Auth's `/auth/v1/admin/list-users`, gated to sysadmin only), and the SPA's "All organizations" sentinel. The CMS HTML gate admits `userRole === "sysadmin"` alongside `"appmanager"`. Off by default. See [`SYSADMIN` pseudo-role](/define/access#sysadmin--cross-tenant-db-admin-tier). |
|
|
583
617
|
|
|
584
618
|
### Sysadmin tier (`cms.sysadmin: true`)
|
|
@@ -85,8 +85,9 @@ import { defineDatabase } from "@quickback/compiler";
|
|
|
85
85
|
|
|
86
86
|
providers: {
|
|
87
87
|
database: defineDatabase("cloudflare-d1", {
|
|
88
|
-
generateId: "
|
|
88
|
+
generateId: "uuid", // default; "cuid" | "nanoid" | "short" | "prefixed" | "serial" | false
|
|
89
89
|
allowClientIds: false, // true: POST bodies MAY carry a strategy-shaped id
|
|
90
|
+
validateIdParams: true, // false: /:id is a plain string again (see the hazard below)
|
|
90
91
|
namingConvention: "snake_case", // "camelCase" | "snake_case"
|
|
91
92
|
usePlurals: false, // Auth table names: "users" vs "user"
|
|
92
93
|
}),
|
|
@@ -101,8 +102,9 @@ single Postgres database with no bindings or split mode (see
|
|
|
101
102
|
|
|
102
103
|
| Option | Type | Default (D1) | Description |
|
|
103
104
|
|--------|------|---------|-------------|
|
|
104
|
-
| `generateId` | `string \| false` | `"
|
|
105
|
+
| `generateId` | `string \| false` | `"uuid"` (every provider) | ID generation strategy — see [ID Generation Options](#id-generation-options) |
|
|
105
106
|
| `allowClientIds` | `boolean` | `false` | Accept an optional client-supplied `id` on create, shaped like the `generateId` strategy — see [Client-supplied IDs](/api/crud#client-supplied-ids-optimistic-updates). Ignored under `generateId: false` (ids are already client-supplied and required) and `"serial"` / numeric PKs |
|
|
107
|
+
| `validateIdParams` | `boolean` | `true` | Check a record route's `:id` against the table's id format and answer `400 INVALID_ID` before any database work — see [Malformed ids](/api/crud#malformed-ids-400-invalid_id). **Set `false` if any table holds rows whose ids don't match the current `generateId` shape** (the strategy changed after rows were written, imported data, ids hand-minted by actions): with the check on, those rows answer 400 instead of the row. Tables whose format the compiler can't know (`generateId: false`, an authored id default) are never checked |
|
|
106
108
|
| `namingConvention` | `string` | `"snake_case"` | Column naming convention |
|
|
107
109
|
| `usePlurals` | `boolean` | `false` | Pluralize auth table names (e.g. `user` vs `users`) |
|
|
108
110
|
| `splitDatabases` | `boolean` | `true` | Separate auth and features databases (D1 only) |
|
|
@@ -269,7 +271,7 @@ See [Realtime](/platform/realtime) for the client-side connection flow and helpe
|
|
|
269
271
|
|
|
270
272
|
| Value | Description | Example |
|
|
271
273
|
|-------|-------------|---------|
|
|
272
|
-
| `"uuid"` | Server generates UUID | `550e8400-e29b-41d4-a716-446655440000` |
|
|
274
|
+
| `"uuid"` (default) | Server generates UUID | `550e8400-e29b-41d4-a716-446655440000` |
|
|
273
275
|
| `"cuid"` | Server generates CUID | `clh2v8k9g0000l508h5gx8j1a` |
|
|
274
276
|
| `"nanoid"` | Server generates nanoid (21-char, URL-safe) | `V1StGXR8_Z5jdHi6B-myT` |
|
|
275
277
|
| `"short"` | 6-char alphanumeric (nanoid `customAlphabet`) | `a3F9xK` |
|
|
@@ -277,10 +279,33 @@ See [Realtime](/platform/realtime) for the client-side connection flow and helpe
|
|
|
277
279
|
| `"serial"` | Database auto-increments | `1`, `2`, `3` |
|
|
278
280
|
| `false` | Client provides ID (enables PUT/upsert) | Any string |
|
|
279
281
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
>
|
|
282
|
+
Leave `generateId` unset and every provider mints UUIDs, in the CRUD route and
|
|
283
|
+
in the schema default an action's `db.insert()` falls back on alike.
|
|
284
|
+
|
|
285
|
+
> **Upgrading: the default changed from prefixed to uuid**
|
|
286
|
+
>
|
|
287
|
+
> Before this release an unset `generateId` minted **prefixed** ids on D1
|
|
288
|
+
> (`job_550e8400e29b41d4a716446655440000`), and on every provider the CRUD route
|
|
289
|
+
> fell back to prefixed. Unset now means `"uuid"` everywhere. Existing rows keep
|
|
290
|
+
> their ids, so a table that was on the old default holds both shapes:
|
|
291
|
+
>
|
|
292
|
+
> - **Old rows stay reachable.** While `generateId` is unset, record routes'
|
|
293
|
+
> [`:id` check](/api/crud#malformed-ids-400-invalid_id) accepts a UUID **or**
|
|
294
|
+
> any prefixed id the old default minted, and the OpenAPI spec declares no
|
|
295
|
+
> `format` on ids, so a strict client doesn't reject old ids.
|
|
296
|
+
> - **New rows are UUIDs**, including client-supplied ids under `allowClientIds`.
|
|
297
|
+
> - **To keep minting prefixed ids**, set `generateId: "prefixed"` explicitly.
|
|
298
|
+
> - **Once every row is a UUID** (or on a new project), set `generateId: "uuid"`
|
|
299
|
+
> explicitly. That is a promise about every row, so `:id` then accepts only a
|
|
300
|
+
> UUID and ids get `format: "uuid"` in OpenAPI.
|
|
301
|
+
>
|
|
302
|
+
> Code that parses the `<prefix>_` part of an id breaks on new rows either way.
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
> `"short"` produces IDs with ~56.8 billion possible values (62^6). That's fine for small/scoped tables like rooms, invites, or share codes — but at roughly 238,000 rows you hit a 50% chance of collision (birthday bound). Don't use it for high-volume records.
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
> `"cuid"`, `"nanoid"`, and `"short"` mint with an npm package: `@paralleldrive/cuid2` for `"cuid"`, and `nanoid` for the other two. The compiler adds the package to the generated `package.json` and imports it wherever it mints an id, so don't add it yourself, and don't import it in a table file (table files can't import it). Every server-side mint produces the shape in the table: the CRUD route, and the schema default that a `db.insert()` in an action falls back on. Older compilers backed the schema-side `createId()` with a `crypto.randomUUID()` polyfill, so a `cuid` table can hold UUID rows; record routes' [`:id` check](/api/crud#malformed-ids-400-invalid_id) accepts both.
|
|
284
309
|
|
|
285
310
|
|
|
286
311
|
## Auth Providers
|
|
@@ -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
|
|
@@ -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
|