@quickback-dev/cli 0.10.2 → 0.10.5

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 (56) hide show
  1. package/dist/commands/compile.d.ts +9 -1
  2. package/dist/commands/compile.d.ts.map +1 -1
  3. package/dist/commands/compile.js +56 -16
  4. package/dist/commands/compile.js.map +1 -1
  5. package/dist/commands/create.js +108 -55
  6. package/dist/commands/create.js.map +1 -1
  7. package/dist/commands/init.d.ts.map +1 -1
  8. package/dist/commands/init.js +22 -0
  9. package/dist/commands/init.js.map +1 -1
  10. package/dist/cursor/quickback.mdc +61 -46
  11. package/dist/docs/content.js +18 -18
  12. package/dist/docs/content.js.map +1 -1
  13. package/dist/index.js +3 -2
  14. package/dist/index.js.map +1 -1
  15. package/dist/lib/api-client.d.ts +34 -2
  16. package/dist/lib/api-client.d.ts.map +1 -1
  17. package/dist/lib/api-client.js +31 -2
  18. package/dist/lib/api-client.js.map +1 -1
  19. package/dist/lib/api-client.test.js +58 -0
  20. package/dist/lib/api-client.test.js.map +1 -1
  21. package/dist/lib/config-sync.d.ts +55 -0
  22. package/dist/lib/config-sync.d.ts.map +1 -0
  23. package/dist/lib/config-sync.js +207 -0
  24. package/dist/lib/config-sync.js.map +1 -0
  25. package/dist/lib/config-sync.test.d.ts +2 -0
  26. package/dist/lib/config-sync.test.d.ts.map +1 -0
  27. package/dist/lib/config-sync.test.js +151 -0
  28. package/dist/lib/config-sync.test.js.map +1 -0
  29. package/dist/lib/file-loader.d.ts +39 -5
  30. package/dist/lib/file-loader.d.ts.map +1 -1
  31. package/dist/lib/file-loader.js +226 -63
  32. package/dist/lib/file-loader.js.map +1 -1
  33. package/dist/lib/file-loader.test.js +212 -1
  34. package/dist/lib/file-loader.test.js.map +1 -1
  35. package/dist/lib/prepare-output.d.ts +31 -0
  36. package/dist/lib/prepare-output.d.ts.map +1 -0
  37. package/dist/lib/prepare-output.js +95 -0
  38. package/dist/lib/prepare-output.js.map +1 -0
  39. package/dist/lib/prepare-output.test.d.ts +2 -0
  40. package/dist/lib/prepare-output.test.d.ts.map +1 -0
  41. package/dist/lib/prepare-output.test.js +105 -0
  42. package/dist/lib/prepare-output.test.js.map +1 -0
  43. package/dist/lib/sweep-stale.d.ts +25 -0
  44. package/dist/lib/sweep-stale.d.ts.map +1 -0
  45. package/dist/lib/sweep-stale.js +179 -0
  46. package/dist/lib/sweep-stale.js.map +1 -0
  47. package/dist/lib/sweep-stale.test.d.ts +2 -0
  48. package/dist/lib/sweep-stale.test.d.ts.map +1 -0
  49. package/dist/lib/sweep-stale.test.js +130 -0
  50. package/dist/lib/sweep-stale.test.js.map +1 -0
  51. package/dist/skill/SKILL.md +327 -103
  52. package/dist/skill/agents/quickback-specialist/AGENT.md +93 -81
  53. package/package.json +14 -14
  54. package/src/cursor/quickback.mdc +61 -46
  55. package/src/skill/SKILL.md +327 -103
  56. package/src/skill/agents/quickback-specialist/AGENT.md +93 -81
@@ -21,8 +21,10 @@ my-app/
21
21
  │ └── features/
22
22
  │ └── {feature-name}/
23
23
  │ ├── {table}.ts # Schema + security (defineTable)
24
- │ ├── actions.ts # Custom actions (optional)
25
- │ └── handlers/ # Action handlers (optional)
24
+ │ ├── actions/ # One file per action — defineAction({...}) (optional)
25
+ │ │ ├── {action}.ts # Binds to primary table (or standalone if path: is set)
26
+ │ │ └── {table}/{action}.ts # Binds to sibling <table>.ts (multi-table features)
27
+ │ └── lib/ # Feature-local helpers, copied verbatim (optional)
26
28
  └── ...
27
29
  ```
28
30
 
@@ -63,10 +65,13 @@ export const todos = sqliteTable("todos", {
63
65
  });
64
66
 
65
67
  export default defineTable(todos, {
66
- firewall: { organization: {}, owner: {} },
68
+ firewall: [
69
+ { field: "organizationId", equals: "ctx.activeOrgId" },
70
+ { field: "userId", equals: "ctx.userId" },
71
+ { field: "deletedAt", isNull: true },
72
+ ],
73
+ read: { access: { roles: ["member", "admin"] } },
67
74
  crud: {
68
- list: { access: { roles: ["member", "admin"] } },
69
- get: { access: { roles: ["member", "admin"] } },
70
75
  create: { access: { roles: ["member", "admin"] } },
71
76
  update: { access: { roles: ["admin"] } },
72
77
  delete: { access: { roles: ["admin"] }, mode: "soft" },
@@ -87,25 +92,30 @@ Every request passes through: `Request → Firewall → Access → Guards → Da
87
92
 
88
93
  ### 1. Firewall — Data Isolation
89
94
 
90
- Auto WHERE clauses for tenant isolation:
95
+ Auto WHERE clauses for tenant isolation. Predicates are AND'd:
91
96
 
92
97
  ```typescript
93
- firewall: {
94
- organization: {}, // WHERE organizationId = ctx.activeOrgId
95
- owner: {}, // AND userId = ctx.userId
96
- team: {}, // WHERE teamId = ctx.activeTeamId
97
- softDelete: {}, // AND deletedAt IS NULL
98
- exception: true, // No filtering (public)
99
- }
98
+ firewall: [
99
+ { field: 'organizationId', equals: 'ctx.activeOrgId' }, // WHERE organizationId = ctx.activeOrgId
100
+ { field: 'ownerId', equals: 'ctx.userId' }, // AND ownerId = ctx.userId
101
+ { field: 'teamId', equals: 'ctx.activeTeamId' }, // AND teamId = ctx.activeTeamId
102
+ { field: 'deletedAt', isNull: true }, // AND deletedAt IS NULL
103
+ ]
104
+
105
+ // Public/system resources opt out of tenant scoping (soft-delete still applied):
106
+ firewall: [{ exception: true }]
100
107
  ```
101
108
 
109
+ Auto-derived when omitted: scans the schema for `organizationId` / `ownerId` / `teamId` and emits matching predicates. Two or more isolation columns → declare explicitly.
110
+
102
111
  ### 2. Access — Permission Checks
103
112
 
104
- Role-based and record-based (deny by default):
113
+ Role-based and record-based (deny by default). Reads (`GET /` and `GET /:id`) gate via `read.access`; mutations gate via `crud.{create,update,delete}.access`.
105
114
 
106
115
  ```typescript
116
+ read: { access: { roles: ['member'] } }, // gates GET / and GET /:id
107
117
  crud: {
108
- list: { access: { roles: ['member'] } },
118
+ create: { access: { roles: ['admin'] } },
109
119
  update: {
110
120
  access: {
111
121
  or: [
@@ -114,9 +124,12 @@ crud: {
114
124
  ],
115
125
  },
116
126
  },
127
+ delete: { access: { roles: ['admin'] } },
117
128
  }
118
129
  ```
119
130
 
131
+ > **DSL v2:** `crud.list` and `crud.get` are rejected at compile time. Move them to `read.access`.
132
+
120
133
  Operators: `equals`, `notEquals`, `in`, `notIn`, `greaterThan`, `lessThan`
121
134
  Context: `$ctx.userId`, `$ctx.activeOrgId`, `$ctx.roles`
122
135
 
@@ -164,50 +177,52 @@ validation: {
164
177
 
165
178
  ## Actions — Custom Business Logic
166
179
 
167
- Separate `actions.ts` file:
180
+ One file per action under `actions/<name>.ts`. The filename is the action name AND URL segment. `actions/<name>.ts` binds to the feature's primary table; `actions/<table>/<name>.ts` binds to a sibling table. Setting `path:` makes the action standalone.
168
181
 
169
182
  ```typescript
170
- import { todos } from './todos';
171
- import { defineActions } from '@quickback/compiler';
172
- import { z } from 'zod';
173
-
174
- export default defineActions(todos, {
175
- complete: {
176
- description: "Mark todo as complete",
177
- input: z.object({ completedAt: z.string().datetime().optional() }),
178
- guard: { roles: ["member", "admin"] },
179
- execute: async ({ db, record, ctx, input }) => {
180
- await db.update(todos).set({ completed: true }).where(eq(todos.id, record.id));
181
- return { success: true };
182
- },
183
+ // features/todos/actions/complete.ts
184
+ import { z } from "zod";
185
+ import { eq } from "drizzle-orm";
186
+ import { defineAction } from "../.quickback/define-action";
187
+ import { todos } from "../todos";
188
+
189
+ export default defineAction({
190
+ description: "Mark todo as complete",
191
+ input: z.object({ completedAt: z.string().datetime().optional() }),
192
+ access: { roles: ["member", "admin"], record: { completed: { equals: false } } },
193
+ async execute({ db, record, auditFields }) {
194
+ await db.update(todos)
195
+ .set({ completed: true, modifiedAt: auditFields!.modifiedAt })
196
+ .where(eq(todos.id, record.id));
197
+ return { success: true };
183
198
  },
184
199
  });
185
200
  ```
186
201
 
187
- Record-based: `POST /api/v1/{resource}/:id/{action}`
188
- Standalone: `standalone: true`, custom `path` and `method`
202
+ Record-based (no `path:`): `POST /api/v1/{resource}/:id/{action}`
203
+ Standalone (`path:` set): custom `path` and `method`
204
+
205
+ `execute:` must be an `async (ctx) => { … }` arrow function. Retired (rejected at load time): bundled `actions.ts`, `_feature.ts`, `handlers/` directory, `defineActions()`.
189
206
 
190
207
  ### Actions-Only Features (no tables)
191
208
 
209
+ A feature with no top-level `*.ts` files is "tableless" — every action must be standalone (have `path:`).
210
+
192
211
  ```typescript
193
- // quickback/features/utilities/actions.ts
194
- import { defineActions } from '@quickback/compiler';
195
- import { z } from 'zod';
196
-
197
- export default defineActions(null, {
198
- healthCheck: {
199
- standalone: true,
200
- path: "/health",
201
- method: "GET",
202
- input: z.object({}),
203
- guard: { roles: ["member", "admin"] },
204
- handler: "./handlers/health-check",
205
- },
212
+ // quickback/features/utilities/actions/health-check.ts
213
+ import { z } from "zod";
214
+ import { defineAction } from "../.quickback/define-action";
215
+
216
+ export default defineAction({
217
+ description: "Health check",
218
+ path: "/health",
219
+ method: "GET",
220
+ input: z.object({}),
221
+ access: { roles: ["member", "admin"] },
222
+ async execute() { return { ok: true }; },
206
223
  });
207
224
  ```
208
225
 
209
- All actions must have `standalone: true` when there is no table.
210
-
211
226
  ### Public Actions
212
227
 
213
228
  Use `roles: ["PUBLIC"]` for unauthenticated endpoints. Mandatory audit logged. The wildcard `"*"` is not supported.