@quickback-dev/cli 0.16.5 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/README.md +7 -3
  2. package/dist/commands/compile.d.ts.map +1 -1
  3. package/dist/commands/compile.js +12 -48
  4. package/dist/commands/compile.js.map +1 -1
  5. package/dist/commands/create.d.ts +20 -0
  6. package/dist/commands/create.d.ts.map +1 -1
  7. package/dist/commands/create.js +216 -151
  8. package/dist/commands/create.js.map +1 -1
  9. package/dist/commands/login.d.ts +4 -2
  10. package/dist/commands/login.d.ts.map +1 -1
  11. package/dist/commands/login.js +25 -17
  12. package/dist/commands/login.js.map +1 -1
  13. package/dist/commands/start.d.ts +20 -0
  14. package/dist/commands/start.d.ts.map +1 -0
  15. package/dist/commands/start.js +163 -0
  16. package/dist/commands/start.js.map +1 -0
  17. package/dist/commands/whoami.d.ts.map +1 -1
  18. package/dist/commands/whoami.js +5 -4
  19. package/dist/commands/whoami.js.map +1 -1
  20. package/dist/docs/content.js +37 -37
  21. package/dist/docs/content.js.map +1 -1
  22. package/dist/index.js +27 -10
  23. package/dist/index.js.map +1 -1
  24. package/dist/lib/api-client.js +1 -1
  25. package/dist/lib/api-client.js.map +1 -1
  26. package/dist/lib/api-client.test.js +15 -0
  27. package/dist/lib/api-client.test.js.map +1 -1
  28. package/dist/lib/auth.d.ts +39 -3
  29. package/dist/lib/auth.d.ts.map +1 -1
  30. package/dist/lib/auth.js +57 -3
  31. package/dist/lib/auth.js.map +1 -1
  32. package/dist/lib/drizzle-meta-routing.test.js +16 -3
  33. package/dist/lib/drizzle-meta-routing.test.js.map +1 -1
  34. package/dist/lib/file-loader.d.ts +6 -4
  35. package/dist/lib/file-loader.d.ts.map +1 -1
  36. package/dist/lib/file-loader.js +30 -27
  37. package/dist/lib/file-loader.js.map +1 -1
  38. package/dist/lib/file-loader.test.js +16 -7
  39. package/dist/lib/file-loader.test.js.map +1 -1
  40. package/dist/skill/docs/changelog.md +145 -0
  41. package/dist/skill/docs/compiler/config/providers.md +87 -0
  42. package/dist/skill/docs/compiler/config/single-tenant.md +5 -11
  43. package/dist/skill/docs/compiler/definitions/access.md +43 -57
  44. package/dist/skill/docs/compiler/definitions/feature.md +7 -11
  45. package/dist/skill/docs/compiler/definitions/firewall.md +2 -4
  46. package/dist/skill/docs/compiler/definitions/guards.md +16 -18
  47. package/dist/skill/docs/compiler/definitions/index.md +10 -14
  48. package/dist/skill/docs/compiler/definitions/masking.md +6 -6
  49. package/dist/skill/docs/compiler/definitions/read.md +6 -11
  50. package/dist/skill/docs/compiler/definitions/schema.md +18 -18
  51. package/dist/skill/docs/compiler/definitions/views.md +3 -5
  52. package/dist/skill/docs/compiler/getting-started/full-example.md +6 -8
  53. package/dist/skill/docs/compiler/getting-started/hand-crafted.md +3 -5
  54. package/dist/skill/docs/compiler/getting-started/index.md +23 -20
  55. package/dist/skill/docs/compiler/getting-started/patterns.md +19 -31
  56. package/dist/skill/docs/compiler/getting-started/template-blog.md +6 -10
  57. package/dist/skill/docs/compiler/getting-started/template-cloudflare.md +3 -5
  58. package/dist/skill/docs/compiler/getting-started/template-empty.md +3 -5
  59. package/dist/skill/docs/compiler/targets/hono-api/using-the-api/batch-operations.md +29 -23
  60. package/dist/skill/docs/compiler/targets/hono-api/using-the-api/crud.md +12 -14
  61. package/dist/skill/docs/compiler/targets/hono-api/using-the-api/openapi.md +5 -2
  62. package/dist/skill/docs/compiler/targets/hono-api/using-the-api/query-params.md +5 -7
  63. package/dist/skill/docs/compiler/troubleshooting.md +10 -0
  64. package/dist/skill/docs/stack/auth/security.md +69 -0
  65. package/dist/skill/docs/stack/cms/actions.md +28 -0
  66. package/dist/skill/docs/stack/cms/connecting.md +2 -2
  67. package/dist/skill/docs/stack/cms/index.md +2 -2
  68. package/dist/skill/docs/stack/cms/record-layouts.md +19 -19
  69. package/dist/skill/docs/stack/cms/schema-format.md +33 -3
  70. package/dist/skill/docs/stack/cms/schema-registry.md +22 -2
  71. package/dist/skill/docs/stack/cms/security.md +10 -12
  72. package/dist/skill/docs/stack/cms/table-views.md +1 -1
  73. package/dist/skill/docs/stack/realtime/durable-objects.md +46 -5
  74. package/dist/skill/docs/stack/realtime/index.md +20 -3
  75. package/dist/skill/docs/stack/realtime/using-realtime.md +8 -6
  76. package/dist/skill/docs/stack/vector/embeddings.md +7 -6
  77. package/package.json +1 -1
  78. package/src/skill/docs/changelog.md +145 -0
  79. package/src/skill/docs/compiler/config/providers.md +87 -0
  80. package/src/skill/docs/compiler/config/single-tenant.md +5 -11
  81. package/src/skill/docs/compiler/definitions/access.md +43 -57
  82. package/src/skill/docs/compiler/definitions/feature.md +7 -11
  83. package/src/skill/docs/compiler/definitions/firewall.md +2 -4
  84. package/src/skill/docs/compiler/definitions/guards.md +16 -18
  85. package/src/skill/docs/compiler/definitions/index.md +10 -14
  86. package/src/skill/docs/compiler/definitions/masking.md +6 -6
  87. package/src/skill/docs/compiler/definitions/read.md +6 -11
  88. package/src/skill/docs/compiler/definitions/schema.md +18 -18
  89. package/src/skill/docs/compiler/definitions/views.md +3 -5
  90. package/src/skill/docs/compiler/getting-started/full-example.md +6 -8
  91. package/src/skill/docs/compiler/getting-started/hand-crafted.md +3 -5
  92. package/src/skill/docs/compiler/getting-started/index.md +23 -20
  93. package/src/skill/docs/compiler/getting-started/patterns.md +19 -31
  94. package/src/skill/docs/compiler/getting-started/template-blog.md +6 -10
  95. package/src/skill/docs/compiler/getting-started/template-cloudflare.md +3 -5
  96. package/src/skill/docs/compiler/getting-started/template-empty.md +3 -5
  97. package/src/skill/docs/compiler/targets/hono-api/using-the-api/batch-operations.md +29 -23
  98. package/src/skill/docs/compiler/targets/hono-api/using-the-api/crud.md +12 -14
  99. package/src/skill/docs/compiler/targets/hono-api/using-the-api/openapi.md +5 -2
  100. package/src/skill/docs/compiler/targets/hono-api/using-the-api/query-params.md +5 -7
  101. package/src/skill/docs/compiler/troubleshooting.md +10 -0
  102. package/src/skill/docs/stack/auth/security.md +69 -0
  103. package/src/skill/docs/stack/cms/actions.md +28 -0
  104. package/src/skill/docs/stack/cms/connecting.md +2 -2
  105. package/src/skill/docs/stack/cms/index.md +2 -2
  106. package/src/skill/docs/stack/cms/record-layouts.md +19 -19
  107. package/src/skill/docs/stack/cms/schema-format.md +33 -3
  108. package/src/skill/docs/stack/cms/schema-registry.md +22 -2
  109. package/src/skill/docs/stack/cms/security.md +10 -12
  110. package/src/skill/docs/stack/cms/table-views.md +1 -1
  111. package/src/skill/docs/stack/realtime/durable-objects.md +46 -5
  112. package/src/skill/docs/stack/realtime/index.md +20 -3
  113. package/src/skill/docs/stack/realtime/using-realtime.md +8 -6
  114. package/src/skill/docs/stack/vector/embeddings.md +7 -6
@@ -28,14 +28,12 @@ export default feature('jobs', {
28
28
  createable: ["title", "department", "status", "salaryMin", "salaryMax"],
29
29
  updatable: ["title", "department", "status"],
30
30
  },
31
- crud: {
32
- create: { access: { roles: ["owner", "hiring-manager"] } },
33
- update: { access: { roles: ["owner", "hiring-manager"] } },
34
- delete: { access: { roles: ["owner", "hiring-manager"] } },
35
- },
36
31
  read: {
37
32
  access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] },
38
33
  },
34
+ create: { access: { roles: ["owner", "hiring-manager"] } },
35
+ update: { access: { roles: ["owner", "hiring-manager"] } },
36
+ delete: { access: { roles: ["owner", "hiring-manager"] } },
39
37
  });
40
38
  ```
41
39
 
@@ -59,8 +57,10 @@ export const jobs = q.table('jobs', {
59
57
 
60
58
  export default defineTable(jobs, {
61
59
  guards: { /* ... */ },
62
- crud: { /* ... */ },
63
60
  read: { /* ... */ },
61
+ create: { /* ... */ },
62
+ update: { /* ... */ },
63
+ delete: { /* ... */ },
64
64
  });
65
65
 
66
66
  export type Job = typeof jobs.$infer;
@@ -182,7 +182,9 @@ export default defineTable(jobs, {
182
182
  createable: ["title", "department", "status", "salaryMin", "salaryMax"],
183
183
  updatable: ["title", "department", "status"],
184
184
  },
185
- crud: { /* ... */ },
185
+ create: { /* ... */ },
186
+ update: { /* ... */ },
187
+ delete: { /* ... */ },
186
188
  });
187
189
 
188
190
  export type Job = typeof jobs.$inferSelect;
@@ -253,13 +255,13 @@ quickback/
253
255
  ```
254
256
 
255
257
  **Key points:**
256
- - Tables with `export default defineTable(...)` get CRUD routes generated
258
+ - Tables with `export default defineTable(...)` get resource routes generated
257
259
  - Tables without a default export are internal (no routes, used for joins/relations)
258
260
  - Route paths are derived from filenames: `applications.ts` → `/api/v1/applications`
259
261
 
260
262
  ### defineTable vs defineResource
261
263
 
262
- - **`defineTable`** — The standard function for defining tables with CRUD routes
264
+ - **`defineTable`** — The standard function for defining tables with generated API routes
263
265
  - **`defineResource`** — Deprecated. Still works but emits a warning during compilation. Use `defineTable` instead.
264
266
 
265
267
  ```typescript
@@ -269,7 +271,7 @@ export default defineTable(jobs, { /* config */ });
269
271
 
270
272
  ## 1 Resource = 1 Security Boundary
271
273
 
272
- Each `defineTable()` call defines a complete, self-contained security boundary. The security config you write — firewall, access, guards, and masking — is compiled into a single resource file that wraps all CRUD routes for that table.
274
+ Each `defineTable()` call defines a complete, self-contained security boundary. The security config you write — firewall, access, guards, and masking — is compiled into a single resource file that wraps all generated routes for that table.
273
275
 
274
276
  This is a deliberate design choice. Mixing two resources with different security rules in one configuration would create ambiguity about which firewall, access, or masking rules apply to which table. By keeping it 1:1, there's never any question.
275
277
 
@@ -287,7 +289,7 @@ For junction tables or internal data structures that shouldn't have API routes,
287
289
  ```typescript
288
290
  // quickback/features/jobs/interview-scores.ts
289
291
 
290
- // @quickback-internal — child table, no CRUD routes intentionally.
292
+ // @quickback-internal — child table, no routes intentionally.
291
293
  import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
292
294
 
293
295
  export const interviewScores = sqliteTable('interview_scores', {
@@ -297,7 +299,7 @@ export const interviewScores = sqliteTable('interview_scores', {
297
299
  organizationId: text('organization_id').notNull(), // Scope junction tables for cascade soft-deletes
298
300
  });
299
301
 
300
- // No default export = no CRUD routes generated
302
+ // No default export = no routes generated
301
303
  ```
302
304
 
303
305
  These internal tables still participate in the database schema and migrations — they just don't get API routes or security configuration. Without the `@quickback-internal` marker the compiler emits a warning per table, since the missing `defineTable` is more often a bug than a deliberate choice.
@@ -314,8 +316,6 @@ The compiler automatically injects the four **[audit fields](#audit-fields)** (`
314
316
  > Unlike audit fields, the `id` column is your responsibility today. The CRUD/action route generators, FK probing, access checks, and OpenAPI emission all assume every queryable table has a single string-typed `id` column. Tables that omit it — or use a non-`id` single PK (`userId.primaryKey()`) or a compound `primaryKey({ columns: [...] })` constraint — parse fine but produce broken generated code downstream.
315
317
  >
316
318
  > Use `q.id()` (preferred) or `id: text("id").primaryKey()` / `id: integer("id").primaryKey({ autoIncrement: true })` on every table that participates in routes. For internal tables marked `// @quickback-internal`, the constraint doesn't apply.
317
- >
318
- > This asymmetry is being closed in **v0.14.8** — `injectIdField` will run unconditionally alongside audit injection, including on junction tables. See the [v0.14.7 changelog](/docs/changelog#coming-next--id-field-auto-injection-v0148) for the migration plan.
319
319
 
320
320
 
321
321
  ## Audit Fields
@@ -415,14 +415,14 @@ This turns off both layers — schema injection and the runtime wrapper.
415
415
  | `deletedAt` | timestamp | Set when the record is soft-deleted |
416
416
  | `deletedBy` | text | Actor that performed the soft delete (`ctx.userId`) |
417
417
 
418
- The compiler injects them only when the resource uses soft delete — i.e. when neither `crud.delete.mode` nor `crud.batchDelete.mode` is explicitly `'hard'`. Soft is the default, so most tables get the columns. Tables with both delete paths set to `'hard'` skip them entirely, which also drops the `isNull(deletedAt)` predicate from the firewall WHERE clause.
418
+ The compiler injects them only when the resource uses soft delete — i.e. when neither `delete.mode` nor `delete.batch.mode` is explicitly `'hard'`. Soft is the default, so most tables get the columns. Tables with both delete paths set to `'hard'` skip them entirely, which also drops the `isNull(deletedAt)` predicate from the firewall WHERE clause.
419
419
 
420
420
  ```typescript
421
421
  // soft delete (default) — table gets deletedAt + deletedBy
422
- crud: { delete: {} }
422
+ delete: {}
423
423
 
424
424
  // hard delete — no deletedAt/deletedBy columns, no soft-delete predicate
425
- crud: { delete: { mode: 'hard' }, batchDelete: { mode: 'hard' } }
425
+ delete: { mode: 'hard', batch: { mode: 'hard' } }
426
426
  ```
427
427
 
428
428
  ### Caller contract
@@ -701,6 +701,6 @@ export const jobs = pgTable('jobs', {
701
701
  ## Next Steps
702
702
 
703
703
  - [Configure the firewall](/compiler/definitions/firewall) for data isolation
704
- - [Set up access control](/compiler/definitions/access) for CRUD operations
704
+ - [Set up access control](/compiler/definitions/access) for read and write operations
705
705
  - [Define guards](/compiler/definitions/guards) for field modification rules
706
706
  - [Add custom actions](/compiler/definitions/actions) for business logic
@@ -371,10 +371,8 @@ export default defineTable(jobs, {
371
371
  },
372
372
  },
373
373
 
374
- crud: {
375
- create: { access: { roles: ['owner', 'hiring-manager'] } },
376
- update: { access: { roles: ['owner', 'hiring-manager'] } },
377
- delete: { access: { roles: ['owner', 'hiring-manager'] } },
378
- },
374
+ create: { access: { roles: ['owner', 'hiring-manager'] } },
375
+ update: { access: { roles: ['owner', 'hiring-manager'] } },
376
+ delete: { access: { roles: ['owner', 'hiring-manager'] } },
379
377
  });
380
378
  ```
@@ -6,7 +6,7 @@ This example shows a complete resource definition using all five security layers
6
6
 
7
7
  A `candidates` resource for a multi-tenant recruitment application with:
8
8
  - Organization-level data isolation
9
- - Role-based CRUD permissions
9
+ - Role-based write permissions
10
10
  - Field-level write protection
11
11
  - PII masking for sensitive fields
12
12
  - Column-level views for different access levels
@@ -57,12 +57,10 @@ export default feature('candidates', {
57
57
  },
58
58
  },
59
59
 
60
- // CRUD — Write operations
61
- crud: {
62
- create: { access: { roles: ['hiring-manager', 'recruiter'] } },
63
- update: { access: { roles: ['hiring-manager', 'recruiter'] } },
64
- delete: { access: { roles: ['hiring-manager'] }, mode: 'hard' },
65
- },
60
+ // WRITE OPERATIONS
61
+ create: { access: { roles: ['hiring-manager', 'recruiter'] } },
62
+ update: { access: { roles: ['hiring-manager', 'recruiter'] } },
63
+ delete: { access: { roles: ['hiring-manager'] }, mode: 'hard' },
66
64
  });
67
65
  ```
68
66
 
@@ -211,7 +209,7 @@ export function maskCandidates<T extends Record<string, any>>(
211
209
  return records.map(r => maskCandidate(r, ctx));
212
210
  }
213
211
 
214
- // CRUD Access configuration (write operations only)
212
+ // Write access configuration (internal normalized shape)
215
213
  export const CRUD_ACCESS = {
216
214
  create: { access: { roles: ['hiring-manager', 'recruiter'] } },
217
215
  update: { access: { roles: ['hiring-manager', 'recruiter'] } },
@@ -89,11 +89,9 @@ export default defineTable(candidates, {
89
89
  read: {
90
90
  access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] },
91
91
  },
92
- crud: {
93
- create: { access: { roles: ["owner", "hiring-manager", "recruiter"] } },
94
- update: { access: { roles: ["owner", "hiring-manager", "recruiter"] } },
95
- delete: { access: { roles: ["owner", "hiring-manager"] }, mode: "soft" },
96
- },
92
+ create: { access: { roles: ["owner", "hiring-manager", "recruiter"] } },
93
+ update: { access: { roles: ["owner", "hiring-manager", "recruiter"] } },
94
+ delete: { access: { roles: ["owner", "hiring-manager"] }, mode: "soft" },
97
95
  });
98
96
  ```
99
97
 
@@ -2,29 +2,34 @@
2
2
 
3
3
  Get started with Quickback in minutes. This guide shows you how to define a complete table with security configuration.
4
4
 
5
- ## Install the CLI
5
+ ## Start a Project
6
6
 
7
7
  ```bash
8
- npm install -g @quickback-dev/cli
8
+ mkdir my-app && cd my-app
9
+ npx @quickback-dev/cli start
9
10
  ```
10
11
 
11
- ## Create a Project
12
+ `quickback start` is interactive — it asks for a template and project name, scaffolds the project on disk, and only prompts for an account just before compiling. If you cancel at the login prompt the scaffold stays put; finish later with `quickback login && quickback compile`.
13
+
14
+ Prefer a scriptable form?
12
15
 
13
16
  ```bash
17
+ npm install -g @quickback-dev/cli
14
18
  quickback create cloudflare my-app
15
19
  cd my-app
16
20
  ```
17
21
 
18
- This scaffolds a complete project with:
22
+ Both paths scaffold the same project:
19
23
  - `quickback.config.ts` — Project configuration
20
24
  - `quickback/features/` — Your table definitions
21
- - Example feature with full security configuration
25
+ - Working example feature with full security configuration (when you pick `todos`/`blog`/`saas`)
22
26
 
23
27
  **Available templates:**
24
- - `cloudflare` — Cloudflare Workers + D1 + Better Auth (free)
25
- - `blog` — Single-tenant blog (PUBLIC reads, admin writes) (free)
28
+ - `cloudflare` — Cloudflare Workers + D1 + Better Auth, bare scaffold (free)
29
+ - `todos` — Working CRUD example with masking + actions (free)
30
+ - `blog` — Single-tenant blog, PUBLIC reads, admin writes (free)
26
31
  - `empty` — Cloudflare scaffold, no example features (free)
27
- - `multi-tenant` — Full SaaS with orgs, teams, billing (pro)
32
+ - `saas` — Full B2B SaaS with orgs, R2 file storage, webhooks (pro)
28
33
 
29
34
  ## File Structure
30
35
 
@@ -77,16 +82,14 @@ export default feature('jobs', {
77
82
  pageSize: 25,
78
83
  },
79
84
 
80
- // 4. CRUD — Write operations
81
- crud: {
82
- create: { access: { roles: ["owner", "hiring-manager"] } },
83
- update: { access: { roles: ["owner", "hiring-manager"] } },
84
- delete: { access: { roles: ["owner", "hiring-manager"] }, mode: "soft" },
85
- },
85
+ // 4. WRITE OPERATIONS
86
+ create: { access: { roles: ["owner", "hiring-manager"] } },
87
+ update: { access: { roles: ["owner", "hiring-manager"] } },
88
+ delete: { access: { roles: ["owner", "hiring-manager"] }, mode: "soft" },
86
89
  });
87
90
  ```
88
91
 
89
- One import, one export, every security layer declared in one place. Secure by default — no CRUD routes ship until you opt in with `crud: { … }`.
92
+ One import, one export, every security layer declared in one place. Secure by default — no write routes ship until you opt in with top-level `create`, `update`, `delete`, or `upsert`.
90
93
 
91
94
  ### Alternatives — same result, different shape
92
95
 
@@ -117,21 +120,21 @@ See [feature() — single-export sugar](/compiler/definitions/feature) and [Sche
117
120
 
118
121
  1. **Firewall**: Automatically adds `WHERE organizationId = ?` to every query. Users in Org A can never see Org B's data.
119
122
  2. **Guards**: Controls which fields can be modified — `createable` for POST, `updatable` for PATCH, `protected` for action-only fields.
120
- 3. **CRUD Access**: Role-based access control for each operation. All roles can read, only hiring managers can write.
123
+ 3. **Write Access**: Role-based access control for each operation. All roles can read, only hiring managers can write.
121
124
 
122
125
  ## Compile and Run
123
126
 
124
127
  ```bash
125
- # Log in (first time only)
126
- quickback login
127
-
128
- # Compile your definitions
128
+ # Compile your definitions — prompts you to sign in or sign up
129
+ # if you haven't already (no separate `quickback login` step needed)
129
130
  quickback compile
130
131
 
131
132
  # Run locally
132
133
  npm run dev
133
134
  ```
134
135
 
136
+ The first compile prompts for an account; subsequent compiles re-use the stored session.
137
+
135
138
  ## Generated Endpoints
136
139
 
137
140
  Quickback generates these endpoints from the example above:
@@ -17,11 +17,9 @@ export default defineTable(jobs, {
17
17
  read: {
18
18
  access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] },
19
19
  },
20
- crud: {
21
- create: { access: { roles: ["owner", "hiring-manager"] } },
22
- update: { access: { roles: ["owner", "hiring-manager"] } },
23
- delete: { access: { roles: ["owner", "hiring-manager"] } },
24
- },
20
+ create: { access: { roles: ["owner", "hiring-manager"] } },
21
+ update: { access: { roles: ["owner", "hiring-manager"] } },
22
+ delete: { access: { roles: ["owner", "hiring-manager"] } },
25
23
  });
26
24
  ```
27
25
 
@@ -54,11 +52,9 @@ export default defineTable(interviewNotes, {
54
52
  read: {
55
53
  access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] },
56
54
  },
57
- crud: {
58
- create: { access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] } },
59
- update: { access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] } },
60
- delete: { access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] } },
61
- },
55
+ create: { access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] } },
56
+ update: { access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] } },
57
+ delete: { access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] } },
62
58
  });
63
59
  ```
64
60
 
@@ -79,11 +75,9 @@ export default defineTable(applications, {
79
75
  read: {
80
76
  access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] },
81
77
  },
82
- crud: {
83
- create: { access: { roles: ["owner", "hiring-manager", "recruiter"] } },
84
- update: { access: { roles: ["owner", "hiring-manager", "recruiter"] } },
85
- delete: { access: { roles: ["owner", "hiring-manager"] } },
86
- },
78
+ create: { access: { roles: ["owner", "hiring-manager", "recruiter"] } },
79
+ update: { access: { roles: ["owner", "hiring-manager", "recruiter"] } },
80
+ delete: { access: { roles: ["owner", "hiring-manager"] } },
87
81
  });
88
82
  ```
89
83
 
@@ -138,11 +132,9 @@ export default defineTable(applications, {
138
132
  read: {
139
133
  access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] },
140
134
  },
141
- crud: {
142
- create: { access: { roles: ["owner", "hiring-manager", "recruiter"] } },
143
- update: { access: { roles: ["owner", "hiring-manager", "recruiter"] } },
144
- delete: { access: { roles: ["hiring-manager"] } },
145
- },
135
+ create: { access: { roles: ["owner", "hiring-manager", "recruiter"] } },
136
+ update: { access: { roles: ["owner", "hiring-manager", "recruiter"] } },
137
+ delete: { access: { roles: ["hiring-manager"] } },
146
138
  });
147
139
  ```
148
140
 
@@ -181,11 +173,9 @@ export default defineTable(candidates, {
181
173
  read: {
182
174
  access: { roles: ["owner", "hiring-manager", "recruiter", "interviewer"] },
183
175
  },
184
- crud: {
185
- create: { access: { roles: ["hiring-manager", "recruiter"] } },
186
- update: { access: { roles: ["hiring-manager", "recruiter"] } },
187
- delete: { access: { roles: ["hiring-manager"] } },
188
- },
176
+ create: { access: { roles: ["hiring-manager", "recruiter"] } },
177
+ update: { access: { roles: ["hiring-manager", "recruiter"] } },
178
+ delete: { access: { roles: ["hiring-manager"] } },
189
179
  });
190
180
  ```
191
181
 
@@ -197,7 +187,7 @@ export default defineTable(candidates, {
197
187
 
198
188
  ## External System Sync
199
189
 
200
- An import table for syncing candidates from an external ATS via PUT/upsert:
190
+ An import table for syncing candidates from an external ATS via upsert:
201
191
 
202
192
  ```typescript
203
193
  // quickback/features/ats-imports/ats-imports.ts
@@ -210,11 +200,9 @@ export default defineTable(atsImports, {
210
200
  read: {
211
201
  access: { roles: ["owner", "hiring-manager"] },
212
202
  },
213
- crud: {
214
- create: { access: { roles: ["owner", "hiring-manager"] } },
215
- update: { access: { roles: ["owner", "hiring-manager"] } },
216
- delete: { access: { roles: ["owner"] } },
217
- },
203
+ create: { access: { roles: ["owner", "hiring-manager"] } },
204
+ update: { access: { roles: ["owner", "hiring-manager"] } },
205
+ delete: { access: { roles: ["owner"] } },
218
206
  });
219
207
  ```
220
208
 
@@ -84,11 +84,9 @@ export default defineTable(posts, {
84
84
  read: {
85
85
  access: { roles: ["PUBLIC"] },
86
86
  },
87
- crud: {
88
- create: { access: { roles: ["admin"] } },
89
- update: { access: { roles: ["admin"] } },
90
- delete: { access: { roles: ["admin"] }, mode: "soft" },
91
- },
87
+ create: { access: { roles: ["admin"] } },
88
+ update: { access: { roles: ["admin"] } },
89
+ delete: { access: { roles: ["admin"] }, mode: "soft" },
92
90
  });
93
91
  ```
94
92
 
@@ -248,11 +246,9 @@ export default defineTable(pages, {
248
246
  read: {
249
247
  access: { roles: ["PUBLIC"] },
250
248
  },
251
- crud: {
252
- create: { access: { roles: ["admin"] } },
253
- update: { access: { roles: ["admin"] } },
254
- delete: { access: { roles: ["admin"] } },
255
- },
249
+ create: { access: { roles: ["admin"] } },
250
+ update: { access: { roles: ["admin"] } },
251
+ delete: { access: { roles: ["admin"] } },
256
252
  });
257
253
  ```
258
254
 
@@ -88,11 +88,9 @@ export default defineTable(todos, {
88
88
  read: {
89
89
  access: { roles: ["owner", "admin", "member"] },
90
90
  },
91
- crud: {
92
- create: { access: { roles: ["owner", "admin", "member"] } },
93
- update: { access: { roles: ["owner", "admin", "member"] } },
94
- delete: { access: { roles: ["owner", "admin"] }, mode: "soft" },
95
- },
91
+ create: { access: { roles: ["owner", "admin", "member"] } },
92
+ update: { access: { roles: ["owner", "admin", "member"] } },
93
+ delete: { access: { roles: ["owner", "admin"] }, mode: "soft" },
96
94
  });
97
95
  ```
98
96
 
@@ -84,11 +84,9 @@ export default defineTable(products, {
84
84
  read: {
85
85
  access: { roles: ["member+"] },
86
86
  },
87
- crud: {
88
- create: { access: { roles: ["member+"] } },
89
- update: { access: { roles: ["member+"] } },
90
- delete: { access: { roles: ["admin+"] }, mode: "soft" },
91
- },
87
+ create: { access: { roles: ["member+"] } },
88
+ update: { access: { roles: ["member+"] } },
89
+ delete: { access: { roles: ["admin+"] }, mode: "soft" },
92
90
  });
93
91
  ```
94
92
 
@@ -1,22 +1,22 @@
1
1
  # Batch Operations
2
2
 
3
- Batch operations let you create, update, or delete multiple records in a single request. They are **auto-enabled** when the corresponding CRUD operation exists in your definition.
3
+ Batch operations let you create, update, upsert, or delete multiple records in a single request. They are **auto-enabled** when the corresponding write operation exists in your definition.
4
4
 
5
5
  ## Available Endpoints
6
6
 
7
7
  | Endpoint | Method | Auto-enabled When |
8
8
  |----------|--------|-------------------|
9
- | `/{resource}/batch` | `POST` | `crud.create` exists |
10
- | `/{resource}/batch` | `PATCH` | `crud.update` exists |
11
- | `/{resource}/batch` | `DELETE` | `crud.delete` exists |
12
- | `/{resource}/batch` | `PUT` | `crud.put` exists |
9
+ | `/{resource}/batch` | `POST` | `create` exists |
10
+ | `/{resource}/batch` | `PATCH` | `update` exists |
11
+ | `/{resource}/batch` | `DELETE` | `delete` exists |
12
+ | `/{resource}/batch` | `PUT` | `upsert` exists |
13
13
 
14
14
  To disable a batch operation, set it to `false` in your definition:
15
15
 
16
16
  ```typescript
17
- crud: {
18
- create: { access: { roles: ['hiring-manager'] } },
19
- batchCreate: false, // Disable batch create
17
+ create: {
18
+ access: { roles: ['hiring-manager'] },
19
+ batch: false, // Disable batch create
20
20
  }
21
21
  ```
22
22
 
@@ -309,33 +309,39 @@ The default maximum batch size is **100 records**. Requests exceeding the limit
309
309
 
310
310
  ## Configuration
311
311
 
312
- Batch operations inherit access control from their corresponding CRUD operation. You can override per-batch settings:
312
+ Batch operations inherit access control from their corresponding write operation. You can override per-batch settings:
313
313
 
314
314
  ```typescript
315
315
  export default defineTable(applications, {
316
- crud: {
317
- create: { access: { roles: ['hiring-manager', 'recruiter'] } },
318
- update: { access: { roles: ['hiring-manager', 'recruiter'] } },
319
- delete: { access: { roles: ['hiring-manager'] }, mode: 'soft' },
320
-
321
- // Override batch-specific settings
322
- batchCreate: {
323
- access: { roles: ['hiring-manager'] }, // More restrictive than single create
324
- maxBatchSize: 50, // Default: 100
325
- allowFailFast: true, // Default: true
316
+ create: {
317
+ access: { roles: ['hiring-manager', 'recruiter'] },
318
+ batch: {
319
+ access: { roles: ['hiring-manager'] }, // More restrictive than single create
320
+ maxBatchSize: 50, // Default: 100
321
+ allowFailFast: true, // Default: true
326
322
  },
327
- batchUpdate: {
323
+ },
324
+ update: {
325
+ access: { roles: ['hiring-manager', 'recruiter'] },
326
+ batch: {
328
327
  maxBatchSize: 100,
329
328
  allowFailFast: true,
330
329
  },
331
- batchDelete: {
330
+ },
331
+ delete: {
332
+ access: { roles: ['hiring-manager'] },
333
+ mode: 'soft',
334
+ batch: {
332
335
  access: { roles: ['hiring-manager'] },
333
336
  maxBatchSize: 100,
334
337
  allowFailFast: true,
335
338
  },
339
+ },
336
340
 
337
- // Disable a batch operation entirely
338
- batchUpsert: false,
341
+ // Disable only batch upsert
342
+ upsert: {
343
+ access: { roles: ['hiring-manager'] },
344
+ batch: false,
339
345
  },
340
346
  });
341
347
  ```
@@ -580,30 +580,28 @@ All batch operation errors include:
580
580
 
581
581
  #### Configuration
582
582
 
583
- Batch operations are **auto-enabled** when corresponding CRUD operations exist:
583
+ Batch operations are **auto-enabled** when corresponding write operations exist:
584
584
 
585
585
  ```typescript
586
586
  // Auto-enabled - no configuration needed
587
- crud: {
588
- create: { access: { roles: ['recruiter'] } },
589
- update: { access: { roles: ['recruiter'] } }
590
- // batchCreate and batchUpdate automatically available
591
- }
587
+ create: { access: { roles: ['recruiter'] } },
588
+ update: { access: { roles: ['recruiter'] } }
589
+ // create.batch and update.batch automatically available
592
590
 
593
591
  // Customize batch operations
594
- crud: {
595
- create: { access: { roles: ['recruiter'] } },
596
- batchCreate: {
592
+ create: {
593
+ access: { roles: ['recruiter'] },
594
+ batch: {
597
595
  access: { roles: ['hiring-manager'] }, // Different access rules
598
- maxBatchSize: 50, // Lower limit
599
- allowFailFast: false // Disable failFast mode
596
+ maxBatchSize: 50, // Lower limit
597
+ allowFailFast: false // Disable failFast mode
600
598
  }
601
599
  }
602
600
 
603
601
  // Disable batch operations
604
- crud: {
605
- create: { access: { roles: ['recruiter'] } },
606
- batchCreate: false // Explicitly disable
602
+ create: {
603
+ access: { roles: ['recruiter'] },
604
+ batch: false // Explicitly disable
607
605
  }
608
606
  ```
609
607
 
@@ -140,18 +140,21 @@ const { data, error } = await client.GET('/api/v1/jobs', { params: { query: { li
140
140
  | `true` (default) | Write `api-types.gen.ts` to the project root |
141
141
  | `false` | Don't emit the types file |
142
142
  | `"src/lib/api-types.ts"` | Custom output path (relative to project root) |
143
+ | `["api-types.gen.ts", "apps/web/src/lib/api-types.gen.ts"]` | Write the same generated types to multiple paths in one compile |
143
144
 
144
145
  ```typescript
145
146
  // quickback.config.ts
146
147
  export default defineConfig({
147
148
  // ...
148
149
  openapi: {
149
- types: 'src/lib/api-types.gen.ts', // emit straight into your client app
150
+ types: ['api-types.gen.ts', 'apps/web/src/lib/api-types.gen.ts'],
150
151
  },
151
152
  });
152
153
  ```
153
154
 
154
- The file is generated by piping the in-memory spec through [openapi-typescript](https://github.com/openapi-ts/openapi-typescript) — you can keep running it manually if you want a different output path or version, but for the typical case there's nothing to wire up. Skipped automatically when `openapi.generate` is `false`.
155
+ The file is generated by piping the in-memory spec through [openapi-typescript](https://github.com/openapi-ts/openapi-typescript) — you can keep running it manually if you want a different output path or version, but for the typical case there's nothing to wire up. If your API project and SPA live in the same repo, prefer multiple `openapi.types` outputs over a second manual `codegen:api` step so one `quickback compile` keeps both copies in sync. Skipped automatically when `openapi.generate` is `false`.
156
+
157
+ The bundled Quickback CMS and Account SPAs do not import `api-types.gen.ts`. CMS is driven by `schema-registry.json`, and Account uses Better Auth plus small hand-written fetch helpers. Use `openapi.types` for your own colocated client apps.
155
158
 
156
159
  ### External viewer
157
160
 
@@ -42,15 +42,13 @@ GET /api/v1/jobs?department.in=Engineering,Design,Product
42
42
  GET /api/v1/jobs?limit=25&offset=50
43
43
  ```
44
44
 
45
- The default `limit` can be configured per-resource in your definition:
45
+ The default `limit` can be configured per-resource in your `read` definition:
46
46
 
47
47
  ```typescript
48
- crud: {
49
- list: {
50
- access: { roles: ["recruiter"] },
51
- pageSize: 25, // Default limit
52
- maxPageSize: 100, // Maximum allowed limit
53
- },
48
+ read: {
49
+ access: { roles: ["recruiter"] },
50
+ pageSize: 25, // Default limit
51
+ maxPageSize: 100, // Maximum allowed limit
54
52
  },
55
53
  ```
56
54
 
@@ -65,6 +65,16 @@ To clean up, you'd need to manually create a migration.
65
65
 
66
66
  If compilation fails with `drizzle-kit requested interactive rename input`, add explicit rename hints in your config. See [Drizzle rename prompts](/compiler/cloud-compiler/troubleshooting#drizzle-rename-prompts-in-ciheadless-compile).
67
67
 
68
+ ### Cloudflare D1 destructive migrations
69
+
70
+ Quickback now adds a D1-specific safety pass around Drizzle-generated migrations for the `cloudflare-d1` provider:
71
+
72
+ 1. **Better Auth cleanup** for retired managed tables is stripped instead of shipped as raw `DROP TABLE` SQL.
73
+ 2. **Drop-only cleanup migrations** are reordered child-first when foreign keys require it.
74
+ 3. **All D1 migration directories** generated by the compiler are replayed against SQLite during compile, so a D1-breaking migration fails before deploy.
75
+
76
+ If `quickback compile` now fails with a D1 replay error, treat that as a real migration problem instead of a deploy-time surprise. The generated SQL needs manual intervention or a schema change that Drizzle can express more safely.
77
+
68
78
  ## Runtime Issues
69
79
 
70
80
  ### 401 on all requests