@quickback-dev/cli 0.10.4 → 0.10.8

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.
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, it } from 'bun:test';
2
2
  import { mkdtemp, mkdir, rm, writeFile } from 'fs/promises';
3
3
  import { tmpdir } from 'os';
4
4
  import { join } from 'path';
5
- import { loadDrizzleMeta } from './file-loader.js';
5
+ import { loadDrizzleMeta, loadFeatures, loadProjectLib } from './file-loader.js';
6
6
  const tempDirs = [];
7
7
  async function createTempDir() {
8
8
  const dir = await mkdtemp(join(tmpdir(), 'quickback-cli-meta-'));
@@ -72,4 +72,215 @@ describe('loadDrizzleMeta', () => {
72
72
  expect(meta).toBeUndefined();
73
73
  });
74
74
  });
75
+ // ─────────────────────────────────────────────────────────────────
76
+ // Fixtures
77
+ // ─────────────────────────────────────────────────────────────────
78
+ const FEATURE_PROFILES_TS = `
79
+ import { feature, q } from "@quickback/compiler";
80
+ export default feature("profiles", {
81
+ columns: { id: q.id(), name: q.text().required() },
82
+ });
83
+ `;
84
+ const FEATURE_EPISODES_TS = `
85
+ import { feature, q } from "@quickback/compiler";
86
+ export default feature("episodes", {
87
+ columns: { id: q.id(), title: q.text().required() },
88
+ });
89
+ `;
90
+ const NEW_SHAPE_RECORD_ACTION = `
91
+ import { defineAction } from "../.quickback/define-action";
92
+ import { z } from "zod";
93
+ import { profiles } from "../profiles";
94
+
95
+ export default defineAction({
96
+ description: "Publish a profile",
97
+ input: z.object({}),
98
+ access: { roles: ["admin"] },
99
+ execute: async ({ db, record }) => record,
100
+ });
101
+ `;
102
+ const NEW_SHAPE_STANDALONE_ACTION = `
103
+ import { defineAction } from "../.quickback/define-action";
104
+ import { z } from "zod";
105
+
106
+ export default defineAction({
107
+ description: "Twilio webhook",
108
+ path: "/twilioIncoming",
109
+ method: "POST",
110
+ input: z.object({ Body: z.string() }),
111
+ access: { roles: ["PUBLIC"] },
112
+ execute: async () => ({}),
113
+ });
114
+ `;
115
+ const NEW_SHAPE_NESTED_ACTION = `
116
+ import { defineAction } from "../../.quickback/define-action.profiles";
117
+ import { z } from "zod";
118
+
119
+ export default defineAction({
120
+ description: "Publish a profile",
121
+ input: z.object({}),
122
+ access: { roles: ["admin"] },
123
+ execute: async ({ record }) => record,
124
+ });
125
+ `;
126
+ // ─────────────────────────────────────────────────────────────────
127
+ // Happy path — new shape (one file per action)
128
+ // ─────────────────────────────────────────────────────────────────
129
+ describe('loadFeatures — one-file-per-action shape', () => {
130
+ it('discovers flat actions/<name>.ts files into actionFiles', async () => {
131
+ const root = await createTempDir();
132
+ const featureDir = join(root, 'profiles');
133
+ await mkdir(join(featureDir, 'actions'), { recursive: true });
134
+ await writeFile(join(featureDir, 'profiles.ts'), FEATURE_PROFILES_TS);
135
+ await writeFile(join(featureDir, 'actions', 'publish.ts'), NEW_SHAPE_RECORD_ACTION);
136
+ await writeFile(join(featureDir, 'actions', 'webhook.ts'), NEW_SHAPE_STANDALONE_ACTION);
137
+ const features = await loadFeatures(root);
138
+ expect(features).toHaveLength(1);
139
+ const profiles = features[0];
140
+ expect(Object.keys(profiles.actionFiles).sort()).toEqual([
141
+ 'actions/publish.ts',
142
+ 'actions/webhook.ts',
143
+ ]);
144
+ expect(profiles.actionFiles['actions/publish.ts']).toContain('export default defineAction');
145
+ });
146
+ it('discovers nested actions/<table>/<name>.ts files', async () => {
147
+ const root = await createTempDir();
148
+ const featureDir = join(root, 'podcast');
149
+ await mkdir(join(featureDir, 'actions', 'profiles'), { recursive: true });
150
+ await writeFile(join(featureDir, 'profiles.ts'), FEATURE_PROFILES_TS);
151
+ await writeFile(join(featureDir, 'episodes.ts'), FEATURE_EPISODES_TS);
152
+ await writeFile(join(featureDir, 'actions', 'profiles', 'publish.ts'), NEW_SHAPE_NESTED_ACTION);
153
+ const features = await loadFeatures(root);
154
+ const podcast = features[0];
155
+ expect(Object.keys(podcast.actionFiles)).toEqual(['actions/profiles/publish.ts']);
156
+ });
157
+ it('picks up feature-local lib/ helpers as featureLibFiles', async () => {
158
+ const root = await createTempDir();
159
+ const featureDir = join(root, 'records');
160
+ await mkdir(join(featureDir, 'actions'), { recursive: true });
161
+ await mkdir(join(featureDir, 'lib', 'sub'), { recursive: true });
162
+ await writeFile(join(featureDir, 'records.ts'), FEATURE_PROFILES_TS);
163
+ await writeFile(join(featureDir, 'actions', 'focus.ts'), NEW_SHAPE_RECORD_ACTION);
164
+ await writeFile(join(featureDir, 'lib', 'inputs.ts'), 'export const isoDate = "...";');
165
+ await writeFile(join(featureDir, 'lib', 'sub', 'helper.ts'), 'export const helper = () => 2;');
166
+ const features = await loadFeatures(root);
167
+ const records = features[0];
168
+ expect(Object.keys(records.featureLibFiles).sort()).toEqual([
169
+ 'lib/inputs.ts',
170
+ 'lib/sub/helper.ts',
171
+ ]);
172
+ expect(records.featureLibFiles['lib/sub/helper.ts']).toContain('helper');
173
+ });
174
+ it('supports tableless features (only actions/, no table file)', async () => {
175
+ const root = await createTempDir();
176
+ const featureDir = join(root, 'export');
177
+ await mkdir(join(featureDir, 'actions'), { recursive: true });
178
+ await writeFile(join(featureDir, 'actions', 'pipeline-csv.ts'), NEW_SHAPE_STANDALONE_ACTION);
179
+ const features = await loadFeatures(root);
180
+ const exportFeature = features[0];
181
+ expect(exportFeature.actionFiles).toBeDefined();
182
+ expect(Object.keys(exportFeature.actionFiles)).toEqual(['actions/pipeline-csv.ts']);
183
+ expect(exportFeature.tables).toEqual([]);
184
+ });
185
+ });
186
+ // ─────────────────────────────────────────────────────────────────
187
+ // Migration errors — every retired primitive rejects with a clear message
188
+ // ─────────────────────────────────────────────────────────────────
189
+ describe('loadFeatures — retired primitives', () => {
190
+ const LEGACY_DEFINE_ACTIONS = `
191
+ import { z } from "zod";
192
+ import { defineActions } from "@quickback/compiler";
193
+ import profiles from "./profiles";
194
+ export default defineActions(profiles, {
195
+ publish: { input: z.object({}), access: { roles: ["owner"] }, handler: "./handlers/publish" },
196
+ });
197
+ `;
198
+ it('rejects bundled actions.ts with a migration message', async () => {
199
+ const root = await createTempDir();
200
+ const featureDir = join(root, 'profiles');
201
+ await mkdir(featureDir, { recursive: true });
202
+ await writeFile(join(featureDir, 'profiles.ts'), FEATURE_PROFILES_TS);
203
+ await writeFile(join(featureDir, 'actions.ts'), LEGACY_DEFINE_ACTIONS);
204
+ await expect(loadFeatures(root)).rejects.toThrow(/Bundled `actions\.ts` is retired/);
205
+ });
206
+ it('rejects _feature.ts with a migration message', async () => {
207
+ const root = await createTempDir();
208
+ const featureDir = join(root, 'profiles');
209
+ await mkdir(featureDir, { recursive: true });
210
+ await writeFile(join(featureDir, 'profiles.ts'), FEATURE_PROFILES_TS);
211
+ await writeFile(join(featureDir, '_feature.ts'), 'export default { actions: {} };');
212
+ await expect(loadFeatures(root)).rejects.toThrow(/`_feature\.ts` is retired/);
213
+ });
214
+ it('rejects handlers/ directory with a migration message', async () => {
215
+ const root = await createTempDir();
216
+ const featureDir = join(root, 'profiles');
217
+ await mkdir(join(featureDir, 'handlers'), { recursive: true });
218
+ await writeFile(join(featureDir, 'profiles.ts'), FEATURE_PROFILES_TS);
219
+ await writeFile(join(featureDir, 'handlers', 'publish.ts'), 'export const execute = async () => {};');
220
+ await expect(loadFeatures(root)).rejects.toThrow(/`handlers\/` directory is retired/);
221
+ });
222
+ it('rejects colocated defineActions(...) inside a table file', async () => {
223
+ const root = await createTempDir();
224
+ const featureDir = join(root, 'profiles');
225
+ await mkdir(featureDir, { recursive: true });
226
+ await writeFile(join(featureDir, 'profiles.ts'), FEATURE_PROFILES_TS + '\n' + LEGACY_DEFINE_ACTIONS);
227
+ await expect(loadFeatures(root)).rejects.toThrow(/Colocated `defineActions\(\.\.\.\)` inside `profiles\.ts` is retired/);
228
+ });
229
+ it('rejects defineActions(...) inside an actions/<flat>.ts shard', async () => {
230
+ const root = await createTempDir();
231
+ const featureDir = join(root, 'profiles');
232
+ await mkdir(join(featureDir, 'actions'), { recursive: true });
233
+ await writeFile(join(featureDir, 'profiles.ts'), FEATURE_PROFILES_TS);
234
+ await writeFile(join(featureDir, 'actions', 'profiles.ts'), LEGACY_DEFINE_ACTIONS);
235
+ await expect(loadFeatures(root)).rejects.toThrow(/uses the retired `defineActions\(\.\.\.\)` \(plural\)/);
236
+ });
237
+ it('rejects retired filename patterns *-actions.ts and *.actions.ts', async () => {
238
+ const root = await createTempDir();
239
+ const featureDir = join(root, 'profiles');
240
+ await mkdir(featureDir, { recursive: true });
241
+ await writeFile(join(featureDir, 'profiles.ts'), FEATURE_PROFILES_TS);
242
+ await writeFile(join(featureDir, 'profiles-actions.ts'), '// stub');
243
+ await writeFile(join(featureDir, 'episodes.actions.ts'), '// stub');
244
+ await expect(loadFeatures(root)).rejects.toThrow(/Filename pattern `(profiles-actions|episodes\.actions)\.ts` is retired/);
245
+ });
246
+ it('batches multiple retired-primitive conflicts into one error', async () => {
247
+ const root = await createTempDir();
248
+ // Feature A: actions.ts + handlers/
249
+ const featureA = join(root, 'profiles');
250
+ await mkdir(join(featureA, 'handlers'), { recursive: true });
251
+ await writeFile(join(featureA, 'profiles.ts'), FEATURE_PROFILES_TS);
252
+ await writeFile(join(featureA, 'actions.ts'), LEGACY_DEFINE_ACTIONS);
253
+ await writeFile(join(featureA, 'handlers', 'publish.ts'), 'export const execute = async () => {};');
254
+ // Feature B: _feature.ts
255
+ const featureB = join(root, 'shows');
256
+ await mkdir(featureB, { recursive: true });
257
+ await writeFile(join(featureB, 'shows.ts'), FEATURE_PROFILES_TS.replace(/profiles/g, 'shows'));
258
+ await writeFile(join(featureB, '_feature.ts'), 'export default { actions: {} };');
259
+ await expect(loadFeatures(root)).rejects.toThrow(/Action discovery found 3 conflict/);
260
+ });
261
+ });
262
+ // ─────────────────────────────────────────────────────────────────
263
+ // loadProjectLib — quickback/lib/ at the project root
264
+ // ─────────────────────────────────────────────────────────────────
265
+ describe('loadProjectLib', () => {
266
+ it('loads quickback/lib/**.ts as flat keyed paths', async () => {
267
+ const projectRoot = await createTempDir();
268
+ await mkdir(join(projectRoot, 'quickback', 'lib', 'nested'), { recursive: true });
269
+ await writeFile(join(projectRoot, 'quickback', 'lib', 'inputs.ts'), 'export const a = 1;');
270
+ await writeFile(join(projectRoot, 'quickback', 'lib', 'ids.ts'), 'export const b = 2;');
271
+ await writeFile(join(projectRoot, 'quickback', 'lib', 'nested', 'utils.ts'), 'export const c = 3;');
272
+ const lib = await loadProjectLib(projectRoot);
273
+ expect(Object.keys(lib).sort()).toEqual([
274
+ 'lib/ids.ts',
275
+ 'lib/inputs.ts',
276
+ 'lib/nested/utils.ts',
277
+ ]);
278
+ expect(lib['lib/inputs.ts']).toBe('export const a = 1;');
279
+ });
280
+ it('returns empty object when quickback/lib does not exist', async () => {
281
+ const projectRoot = await createTempDir();
282
+ const lib = await loadProjectLib(projectRoot);
283
+ expect(lib).toEqual({});
284
+ });
285
+ });
75
286
  //# sourceMappingURL=file-loader.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-loader.test.js","sourceRoot":"","sources":["../../src/lib/file-loader.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,QAAQ,GAAa,EAAE,CAAC;AAE9B,KAAK,UAAU,aAAa;IAC1B,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,qBAAqB,CAAC,CAAC,CAAC;IACjE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,GAAG,CAAC;AACb,CAA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ema + security (defineTable)
61
- │ ├── actions.ts # Custom actions (optional)
62
- │ ├── handlers/ # Action handlers (optional)
61
+ │ ├── actions/ # One file per action — defineAction({...})
62
+ │ │ ├── {action}.ts # Binds to primary table (or standalone if path: is set)
63
+ │ │ └── {table}/{action}.ts # Binds to sibling <table>.ts (multi-table features)
64
+ │ ├── lib/ # Feature-local helpers, copied verbatim (optional)
63
65
  │ └── pages/ # Custom CMS pages (optional)
64
66
  │ └── {slug}.ts # definePage() call
65
67
  ├── src/ # ← compiled output
@@ -90,11 +92,11 @@ export default defineConfig({
90
92
  tagline: "Build faster, ship sooner",
91
93
  build: true, // Set false to skip SPA rebuild on subsequent compiles
92
94
  auth: {
93
- password: true, // Email/password login (default: false)
94
- emailOTP: true, // Email OTP login (default: true)
95
- passkey: true, // WebAuthn passkeys (default: true)
95
+ password: true, // Email/password login (default: true)
96
+ emailOTP: true, // Email OTP login (default: false)
97
+ passkey: true, // WebAuthn passkeys (default: false)
96
98
  signup: true, // User registration (default: true)
97
- organizations: true, // Multi-tenant org management (default: true)
99
+ organizations: true, // Multi-tenant org management UI (default: false; the orgs plugin itself is enabled by `features.organizations` which defaults true)
98
100
  admin: true, // Admin panel (default: true)
99
101
  emailVerification: true, // Require email verification (default: true)
100
102
  },
@@ -157,11 +159,54 @@ export default defineConfig({
157
159
 
158
160
  ## Automatic Audit Fields
159
161
 
160
- Quickback automatically injects these fields into every table:
161
- - `createdAt`, `modifiedAt`, `deletedAt` (timestamps)
162
- - `createdBy`, `modifiedBy`, `deletedBy` (user IDs)
162
+ Quickback injects four **audit columns** into every table at compile time, and the runtime hard-stamps them on every write:
163
163
 
164
- **Do NOT add these to your schema files.** They are auto-injected by the compiler.
164
+ - `createdAt`, `createdBy` — set on insert
165
+ - `modifiedAt`, `modifiedBy` — set on every insert and every update
166
+
167
+ `deletedAt` / `deletedBy` are **soft-delete fields**, not audit fields. They're a separate per-table mechanism, injected only when the resource uses soft delete (the default). When `crud.delete.mode` and `crud.batchDelete.mode` are both `'hard'`, the columns aren't injected and the soft-delete firewall predicate is dropped.
168
+
169
+ **Do NOT add any of these six to your schema files.** They are injected by the compiler.
170
+
171
+ ### Caller contract (write through the request-context `db`)
172
+
173
+ The wrapper around `db` overwrites all four audit fields on every `.insert().values()` and `.set()` call — caller-supplied values are silently dropped. So in custom actions:
174
+
175
+ ✅ INSERT — set `id` and domain fields only:
176
+
177
+ ```ts
178
+ await db.insert(records).values({ id: createId(), name: input.name });
179
+ ```
180
+
181
+ ✅ UPDATE — set domain fields only:
182
+
183
+ ```ts
184
+ await db.update(records).set({ status: 'closed' }).where(...);
185
+ ```
186
+
187
+ ✅ SOFT DELETE — pass `deletedAt` as the *signal* of intent (any value works; the wrapper overwrites with `now`/`ctx.userId`):
188
+
189
+ ```ts
190
+ await db.update(records).set({ deletedAt: new Date() }).where(...);
191
+ ```
192
+
193
+ ❌ Don't pass `createdAt`, `createdBy`, `modifiedAt`, `modifiedBy`, or `deletedBy` — they're not yours to set.
194
+
195
+ ### Actor convention (`ctx.userId` for non-user writes)
196
+
197
+ The wrapper throws `audit-wrapper: <op> reached without ctx.userId` if a write reaches it without a userId. For user-driven requests, auth middleware fills it in. For non-user entry points, mint a synthetic actor id at the boundary:
198
+
199
+ | Boundary | Actor id |
200
+ |---|---|
201
+ | Inbound webhook | `system:webhook-<provider>` |
202
+ | Cron / scheduled | `system:cron-<job>` |
203
+ | Queue worker | `system:queue-<queue>` |
204
+ | Quickback platform-internal write | `system:quickback` |
205
+ | Out-of-band operator script | `system:script-<name>` |
206
+
207
+ **Inherit before you mint.** A user request that triggers cascades, hooks, or enqueues background jobs should carry the user's id through every downstream write. Only mint when there is genuinely no upstream user.
208
+
209
+ For migrations / schema repair / backfill scripts that genuinely should not be audited at all, use the unwrapped `createDb` directly instead of the request-context `db`. That bypasses the wrapper entirely; `createdBy`/`modifiedBy` will be `NULL` on those rows.
165
210
 
166
211
  ---
167
212
 
@@ -310,22 +355,28 @@ export const roomAmenities = q.table('roomAmenities', {
310
355
 
311
356
  The compiler warns once per such table so you confirm the opt-out is intentional.
312
357
 
313
- ### Handlers use `q.*` for query helpers too
358
+ ### Action files use `q.*` for query helpers too
314
359
 
315
- Custom action handlers query via the same `q` namespace:
360
+ Action `execute` functions query via the same `q` namespace:
316
361
 
317
362
  ```typescript
318
- // quickback/features/mail/handlers/inbound.ts
363
+ // quickback/features/mail/actions/inbound.ts
364
+ import { defineAction } from "../.quickback/define-action";
319
365
  import { q } from "../../../lib/q";
320
- import mailboxes from "../mailboxes";
321
- import messages from "../messages";
322
-
323
- export const execute = async ({ unsafeDb, input }) => {
324
- const mailbox = await unsafeDb.query.mailboxes.findFirst({
325
- where: q.eq(mailboxes.address, input.mailboxAddress),
326
- });
327
- // …
328
- };
366
+ import { mailboxes } from "../mailboxes";
367
+ import { messages } from "../messages";
368
+
369
+ export default defineAction({
370
+ description: "Process inbound mail",
371
+ path: "/inbound",
372
+ /* ... */
373
+ async execute({ unsafeDb, input }) {
374
+ const mailbox = await unsafeDb.query.mailboxes.findFirst({
375
+ where: q.eq(mailboxes.address, input.mailboxAddress),
376
+ });
377
+ // …
378
+ },
379
+ });
329
380
  ```
330
381
 
331
382
  Available: `q.and`, `q.or`, `q.not`, `q.eq`, `q.ne`, `q.gt`, `q.gte`, `q.lt`, `q.lte`, `q.like`, `q.ilike`, `q.inArray`, `q.notInArray`, `q.isNull`, `q.isNotNull`, `q.between`, `q.desc`, `q.asc`, `q.sql`. Pure re-export of Drizzle's query builder under the Quickback namespace — users can still `import { eq } from "drizzle-orm"` directly if they prefer.
@@ -350,18 +401,18 @@ export const execute = async ({ unsafeDb, input }) => {
350
401
 
351
402
  ### Import style
352
403
 
353
- With `feature()`, tables are **default exports** — use default imports in actions/other files:
404
+ With `feature()`, tables are **default exports** — use default imports:
354
405
 
355
406
  ```typescript
356
- // features/applications/actions.ts
357
- import applications from "./applications";
358
- import { defineActions } from "@quickback/compiler";
407
+ // features/applications/actions/advance.ts
408
+ import applications from "../applications";
409
+ import { defineAction } from "../.quickback/define-action";
359
410
  ```
360
411
 
361
- With the two-export form, tables are **named exports** — use named imports:
412
+ With the two-export form (`defineTable`), tables are **named exports** — use named imports:
362
413
 
363
414
  ```typescript
364
- import { applications } from "./applications";
415
+ import { applications } from "../applications";
365
416
  ```
366
417
 
367
418
  Both produce the same typed handle.
@@ -434,7 +485,7 @@ columns: {
434
485
  | `organizationId` / `organisationId` | `{ field: '...', equals: 'ctx.activeOrgId' }` |
435
486
  | `userId` (or `ownerId`) | `{ field: '...', equals: 'ctx.userId' }` |
436
487
  | `teamId` | `{ field: 'teamId', equals: 'ctx.activeTeamId' }` |
437
- | `deletedAt` (always present via audit injection) | `{ field: 'deletedAt', isNull: true }` |
488
+ | `deletedAt` (present whenever the resource uses soft delete, which is the default) | `{ field: 'deletedAt', isNull: true }` |
438
489
 
439
490
  - Exactly one isolation column → auto-derived.
440
491
  - Two or more → compile-time error; declare `firewall: [...]` explicitly OR use `q.scope()` to lock semantics in the source.
@@ -663,41 +714,47 @@ Docs: `quickback docs account-ui` | https://docs.quickback.dev/account-ui
663
714
 
664
715
  ## Actions — Custom Business Logic
665
716
 
666
- Defined in a separate `actions.ts` file using `defineActions()`. Per-action permissions live under `access:` (same shape as resource-level access).
717
+ Defined with `defineAction()` (singular). Per-action permissions live under `access:` (same shape as resource-level access).
718
+
719
+ **One file per action.** Each action is its own module under the feature's `actions/` directory:
720
+
721
+ - `actions/<name>.ts` — binds to the feature's primary table (the `<feature>.ts` file at the feature root). If `path:` is set, becomes a standalone action.
722
+ - `actions/<table>/<name>.ts` — binds to the sibling table file `<table>.ts` at the feature root. Use this in multi-table features.
723
+
724
+ The action's filename (sans `.ts`) is the action name AND the URL segment. Uniqueness is enforced per **`(bound table, name)` pair** — sibling-bound actions on different tables may share a verb (e.g. `actions/episodes/publish.ts` + `actions/shows/publish.ts` mount at `/episodes/:id/publish` and `/shows/:id/publish`). The compiler errors only when two action files would mount at the same URL.
725
+
726
+ For shared Zod schemas or helpers, put them under `<feature>/lib/` and import from each action file.
727
+
728
+ **Retired layouts** (rejected at load time with migration guidance): `actions.ts` (bundle), `_feature.ts`, `handlers/` directory, `defineActions(table, {...})`, `defineActions(null, {...})`, `*-actions.ts` / `*.actions.ts` filenames.
729
+
730
+ `execute:` must be an **async arrow function** (`async (ctx) => { … }`). `async function` declarations and non-async forms are rejected at parse time.
667
731
 
668
732
  ```typescript
669
- import todos from './todos'; // default import: feature() exports
670
- // import { todos } from './todos'; // named import: two-export form
671
- import { defineActions } from '@quickback/compiler';
672
- import { q } from '../../lib/q'; // generated namespace; same as drizzle-orm
673
- import { z } from 'zod';
674
-
675
- export default defineActions(todos, {
676
- complete: {
677
- description: "Mark todo as complete",
678
- input: z.object({ completedAt: z.string().datetime().optional() }),
679
- access: { roles: ["member", "admin"], record: { completed: { equals: false } } },
680
- execute: async ({ db, record, whereRecord, auditFields }) => {
681
- await db.update(todos)
682
- .set({ completed: true, modifiedAt: auditFields.modifiedAt })
683
- .where(whereRecord!(todos)); // firewall + soft-delete + id, in one
684
- return { success: true };
685
- },
686
- sideEffects: "sync",
687
- },
688
- archive: {
689
- description: "Archive a todo",
690
- input: z.object({}),
691
- access: { roles: ["admin"] },
692
- handler: "./handlers/archive",
733
+ // features/todos/actions/complete.ts
734
+ import { z } from "zod";
735
+ import { defineAction } from "../.quickback/define-action";
736
+ import { q } from "../../../lib/q"; // generated namespace; same as drizzle-orm
737
+ import todos from "../todos"; // default import: feature() exports
738
+ // import { todos } from "../todos"; // named import: two-export form
739
+
740
+ export default defineAction({
741
+ description: "Mark todo as complete",
742
+ input: z.object({ completedAt: z.string().datetime().optional() }),
743
+ access: { roles: ["member", "admin"], record: { completed: { equals: false } } },
744
+ sideEffects: "sync",
745
+ async execute({ db, record, whereRecord, auditFields }) {
746
+ await db.update(todos)
747
+ .set({ completed: true, modifiedAt: auditFields!.modifiedAt })
748
+ .where(whereRecord!(todos)); // firewall + soft-delete + id, in one
749
+ return { success: true };
693
750
  },
694
751
  });
695
752
  ```
696
753
 
697
- **Record-based** (default): `POST /api/v1/{resource}/:id/{action}` — record is loaded, firewall + access checks run, then `execute` is called with `record`, `whereRecord`, scoped `db`.
698
- **Standalone**: `standalone: true`, custom `path` and `method`. No record context, no firewall preload.
754
+ **Record-based** (no `path:`): `POST /api/v1/{resource}/:id/{action}` — record is loaded, firewall + access checks run, then `execute` is called with `record`, `whereRecord`, scoped `db`.
755
+ **Standalone** (`path:` set): custom `path` and `method`. No record context, no firewall preload.
699
756
 
700
- Action options: `standalone`, `method` (GET/POST/PUT/PATCH/DELETE), `responseType` (json/stream/file), `sideEffects` (sync/async/fire-and-forget), `transition`, `unsafe`, `allowRawSql`.
757
+ Action options: `path`, `method` (GET/POST/PUT/PATCH/DELETE), `responseType` (json/stream/file), `sideEffects` (sync/async/fire-and-forget), `transition`, `unsafe`, `allowRawSql`, `cms`.
701
758
 
702
759
  ### `whereRecord(table)` — explicit, scope-safe WHERE
703
760
 
@@ -708,7 +765,12 @@ In record-based actions, `whereRecord(table)` returns a Drizzle expression that
708
765
  For protected fields that follow a state machine (status, lifecycle, fulfilment), enforce the *from/to pair*, not just the current state. Without `transition`, an `advance` action whose access allows `status in ['applied', 'screening']` will happily run `applied → offer` (a skip) or `screening → applied` (a regression).
709
766
 
710
767
  ```typescript
711
- advance: {
768
+ // features/applications/actions/advance.ts
769
+ import { z } from "zod";
770
+ import { defineAction } from "../.quickback/define-action";
771
+ import { applications } from "../applications";
772
+
773
+ export default defineAction({
712
774
  description: "Move application forward",
713
775
  input: z.object({ nextStatus: z.enum(['screening', 'interview', 'offer']) }),
714
776
  access: { roles: ['owner', 'admin'] },
@@ -721,9 +783,18 @@ advance: {
721
783
  interview: ['offer'],
722
784
  },
723
785
  },
724
- handler: './handlers/advance',
725
- },
726
- hire: {
786
+ async execute({ db, record, input, auditFields, whereTransition }) { /* … */ },
787
+ });
788
+ ```
789
+
790
+ ```typescript
791
+ // features/applications/actions/hire.ts
792
+ import { z } from "zod";
793
+ import { defineAction } from "../.quickback/define-action";
794
+ import { applications } from "../applications";
795
+
796
+ export default defineAction({
797
+ description: "Finalize an offer",
727
798
  input: z.object({}),
728
799
  access: { roles: ['owner'] },
729
800
  transition: {
@@ -731,8 +802,8 @@ hire: {
731
802
  to: 'hired', // fixed target — same value every call
732
803
  fromTo: { offer: ['hired'] },
733
804
  },
734
- handler: './handlers/hire',
735
- },
805
+ async execute({ db, record, auditFields, whereTransition }) { /* … */ },
806
+ });
736
807
  ```
737
808
 
738
809
  Exactly one of `via` or `to` must be provided. On a bad transition the runtime returns **409 `ACCESS_ACTION_NOT_ALLOWED_FOR_STATE`** with `field`, `current`, `target`, `allowedTargets`. The same 409 fires when a plain `access.record` precondition fails (was 403 before — splitting it lets clients tell *"you can't do this"* from *"you can't do this **yet**"*).
@@ -742,25 +813,31 @@ Exactly one of `via` or `to` must be provided. On a bad transition the runtime r
742
813
  For platform-level support / cross-tenant operations, opt out of the scoped DB. The object form is required for new code — it makes the policy explicit and forces an audit reason:
743
814
 
744
815
  ```typescript
745
- adminReport: {
816
+ // features/admin/actions/admin-report.ts
817
+ import { z } from "zod";
818
+ import { defineAction } from "../.quickback/define-action";
819
+ import { applications } from "../../applications/applications";
820
+
821
+ export default defineAction({
746
822
  description: "Cross-org hiring report",
823
+ path: "/admin/cross-org-report",
824
+ input: z.object({ startDate: z.string() }),
825
+ access: { roles: ['owner'] },
747
826
  unsafe: {
748
827
  reason: "Support investigation for enterprise customer",
749
828
  adminOnly: true, // default true — gates on ctx.userRole === 'admin'
750
829
  crossTenant: true, // default true — bypasses firewall
751
830
  targetScope: 'all', // 'all' | 'organization'
752
831
  },
753
- input: z.object({ startDate: z.string() }),
754
- access: { roles: ['owner'] },
755
- execute: async ({ db, unsafeDb, ctx, input }) => {
832
+ async execute({ db, unsafeDb, ctx, input }) {
756
833
  // db is still scoped (safety net for accidental writes)
757
834
  // unsafeDb bypasses scoped filters
758
835
  return await unsafeDb.select().from(applications);
759
836
  },
760
- },
837
+ });
761
838
  ```
762
839
 
763
- Generated runtime auto-injects: Better Auth required, platform admin gate, mandatory audit logging on deny/success/error. Without unsafe mode, `unsafeDb` is `undefined`. Legacy `unsafe: true` still works but object form is preferred.
840
+ Generated runtime auto-injects: Better Auth required, platform admin gate, mandatory audit logging on deny/success/error. Without unsafe mode, `unsafeDb` is `undefined`.
764
841
 
765
842
  ### Soft-delete cascade (cross-feature)
766
843
 
@@ -768,28 +845,25 @@ When a parent is soft-deleted, every child table that holds an FK to it — both
768
845
 
769
846
  ### Actions-Only Features
770
847
 
771
- Features that only contain standalone actions (no tables). Use `defineActions(null, { ... })`:
848
+ A feature directory with no top-level `*.ts` files is "tableless" — every action under `actions/` must be standalone (have `path:`). Use this for utility endpoints like webhooks, reports, or integrations.
772
849
 
773
850
  ```typescript
774
- // quickback/features/utilities/actions.ts
775
- import { defineActions } from '@quickback/compiler';
776
- import { z } from 'zod';
777
-
778
- export default defineActions(null, {
779
- healthCheck: {
780
- standalone: true,
781
- path: "/health",
782
- method: "GET",
783
- description: "Health check endpoint",
784
- input: z.object({}),
785
- access: { roles: ["member", "admin"] },
786
- handler: "./handlers/health-check",
851
+ // quickback/features/utilities/actions/health-check.ts
852
+ import { z } from "zod";
853
+ import { defineAction } from "../.quickback/define-action";
854
+
855
+ export default defineAction({
856
+ description: "Health check endpoint",
857
+ path: "/health",
858
+ method: "GET",
859
+ input: z.object({}),
860
+ access: { roles: ["member", "admin"] },
861
+ async execute() {
862
+ return { ok: true };
787
863
  },
788
864
  });
789
865
  ```
790
866
 
791
- All actions in an actions-only feature must have `standalone: true` (since there's no table for record-based actions).
792
-
793
867
  ---
794
868
 
795
869
  ## API Reference