@quickback-dev/cli 0.10.1 → 0.10.4

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 (48) 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 +44 -13
  4. package/dist/commands/compile.js.map +1 -1
  5. package/dist/commands/init.d.ts.map +1 -1
  6. package/dist/commands/init.js +22 -0
  7. package/dist/commands/init.js.map +1 -1
  8. package/dist/cursor/quickback.mdc +24 -13
  9. package/dist/docs/content.js +14 -14
  10. package/dist/docs/content.js.map +1 -1
  11. package/dist/index.js +3 -2
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/api-client.d.ts +15 -0
  14. package/dist/lib/api-client.d.ts.map +1 -1
  15. package/dist/lib/api-client.js +31 -2
  16. package/dist/lib/api-client.js.map +1 -1
  17. package/dist/lib/api-client.test.js +58 -0
  18. package/dist/lib/api-client.test.js.map +1 -1
  19. package/dist/lib/config-sync.d.ts +55 -0
  20. package/dist/lib/config-sync.d.ts.map +1 -0
  21. package/dist/lib/config-sync.js +207 -0
  22. package/dist/lib/config-sync.js.map +1 -0
  23. package/dist/lib/config-sync.test.d.ts +2 -0
  24. package/dist/lib/config-sync.test.d.ts.map +1 -0
  25. package/dist/lib/config-sync.test.js +151 -0
  26. package/dist/lib/config-sync.test.js.map +1 -0
  27. package/dist/lib/prepare-output.d.ts +31 -0
  28. package/dist/lib/prepare-output.d.ts.map +1 -0
  29. package/dist/lib/prepare-output.js +95 -0
  30. package/dist/lib/prepare-output.js.map +1 -0
  31. package/dist/lib/prepare-output.test.d.ts +2 -0
  32. package/dist/lib/prepare-output.test.d.ts.map +1 -0
  33. package/dist/lib/prepare-output.test.js +105 -0
  34. package/dist/lib/prepare-output.test.js.map +1 -0
  35. package/dist/lib/sweep-stale.d.ts +25 -0
  36. package/dist/lib/sweep-stale.d.ts.map +1 -0
  37. package/dist/lib/sweep-stale.js +179 -0
  38. package/dist/lib/sweep-stale.js.map +1 -0
  39. package/dist/lib/sweep-stale.test.d.ts +2 -0
  40. package/dist/lib/sweep-stale.test.d.ts.map +1 -0
  41. package/dist/lib/sweep-stale.test.js +130 -0
  42. package/dist/lib/sweep-stale.test.js.map +1 -0
  43. package/dist/skill/SKILL.md +245 -52
  44. package/dist/skill/agents/quickback-specialist/AGENT.md +42 -36
  45. package/package.json +14 -14
  46. package/src/cursor/quickback.mdc +24 -13
  47. package/src/skill/SKILL.md +245 -52
  48. package/src/skill/agents/quickback-specialist/AGENT.md +42 -36
@@ -55,47 +55,45 @@ Detect the database dialect from `quickback.config.ts`:
55
55
  - Cloudflare D1 / SQLite: Use `sqliteTable`, `text`, `integer` from `drizzle-orm/sqlite-core`
56
56
  - Supabase / PostgreSQL: Use `pgTable`, `text`, `boolean`, `timestamp` from `drizzle-orm/pg-core`
57
57
 
58
- ### Table Definition Pattern
58
+ ### Table Definition Pattern (recommended: `feature()` + `q.scope()`)
59
59
 
60
60
  ```typescript
61
- import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
62
- import { defineTable } from "@quickback/compiler";
63
-
64
- export const todos = sqliteTable("todos", {
65
- id: integer("id").primaryKey(),
66
- title: text("title").notNull(),
67
- completed: integer("completed", { mode: "boolean" }).default(false),
68
- userId: text("user_id").notNull(),
69
- organizationId: text("organization_id").notNull(),
70
- });
71
-
72
- export default defineTable(todos, {
73
- firewall: {
74
- organization: {}, // Auto-detects 'organizationId' column
75
- owner: {}, // Auto-detects 'userId' column
61
+ import { feature, q } from "@quickback/compiler";
62
+
63
+ export default feature("todos", {
64
+ columns: {
65
+ id: q.id(),
66
+ title: q.text().required(),
67
+ completed: q.bool().default(false),
68
+ ownerId: q.scope("owner"), // → ctx.userId, auto-firewalled, auto-populated
69
+ organizationId: q.scope("organization"), // → ctx.activeOrgId, same
76
70
  },
71
+ // firewall block omitted — q.scope() auto-derives:
72
+ // [{ field: 'organizationId', equals: 'ctx.activeOrgId' },
73
+ // { field: 'ownerId', equals: 'ctx.userId' },
74
+ // { field: 'deletedAt', isNull: true }]
75
+ read: { access: { roles: ["member", "admin"] } },
77
76
  crud: {
78
- list: { access: { roles: ["member", "admin"] } },
79
- get: { access: { roles: ["member", "admin"] } },
80
77
  create: { access: { roles: ["member", "admin"] } },
81
78
  update: { access: { roles: ["admin"] } },
82
79
  delete: { access: { roles: ["admin"] }, mode: "soft" },
83
80
  },
84
81
  guards: {
85
82
  createable: ["title", "completed"],
86
- updatable: ["title", "completed"],
87
- },
88
- masking: {
89
- userId: { type: "redact", show: { roles: ["admin"] } },
83
+ updatable: ["title", "completed"],
90
84
  },
91
85
  });
92
86
  ```
93
87
 
88
+ For Drizzle interop (bringing forward existing schemas), use `sqliteTable` + `defineTable` and rely on auto-detection by column name (`organizationId`, `userId`, `ownerId`, `teamId`).
89
+
94
90
  ### Actions Pattern
95
91
 
92
+ Per-action permissions live under `access:` (same shape as resource-level access). Use `whereRecord(table)` for protected-field writes — it AND-merges firewall + soft-delete + the record id in one expression.
93
+
96
94
  ```typescript
97
95
  // quickback/features/todos/actions.ts
98
- import { todos } from './todos';
96
+ import todos from './todos'; // default import: feature() exports
99
97
  import { defineActions } from '@quickback/compiler';
100
98
  import { z } from 'zod';
101
99
 
@@ -105,18 +103,22 @@ export default defineActions(todos, {
105
103
  input: z.object({
106
104
  completedAt: z.string().datetime().optional(),
107
105
  }),
108
- guard: {
106
+ access: {
109
107
  roles: ["member", "admin"],
110
108
  record: { completed: { equals: false } },
111
109
  },
112
- execute: async ({ db, record, ctx, input }) => {
113
- await db.update(todos).set({ completed: true }).where(eq(todos.id, record.id));
110
+ execute: async ({ db, record, whereRecord, auditFields }) => {
111
+ await db.update(todos)
112
+ .set({ completed: true, modifiedAt: auditFields.modifiedAt })
113
+ .where(whereRecord!(todos));
114
114
  return { success: true };
115
115
  },
116
116
  },
117
117
  });
118
118
  ```
119
119
 
120
+ For state-machine fields (status, lifecycle), add `transition: { field, via|to, fromTo }` so the runtime enforces the from→to pair and returns 409 `ACCESS_ACTION_NOT_ALLOWED_FOR_STATE` on illegal transitions. For cross-tenant or platform-level work, use `unsafe: { reason, adminOnly, crossTenant, targetScope }` (object form is required for new code — auto-injects audit logging).
121
+
120
122
  ## Security Principles
121
123
 
122
124
  1. **Secure by default** - Nothing is accessible until explicitly opened
@@ -128,17 +130,21 @@ export default defineActions(todos, {
128
130
 
129
131
  ### Multi-tenant resource
130
132
  ```typescript
131
- firewall: {
132
- organization: {} // Auto-detects organizationId column
133
- }
133
+ // Auto-derived if organizationId is the only isolation column in the schema —
134
+ // you can omit `firewall:` entirely. Equivalent explicit form:
135
+ firewall: [
136
+ { field: 'organizationId', equals: 'ctx.activeOrgId' },
137
+ { field: 'deletedAt', isNull: true },
138
+ ]
134
139
  ```
135
140
 
136
- ### Owner-scoped with admin override
141
+ ### Owner-scoped, org-aware
137
142
  ```typescript
138
- firewall: {
139
- organization: {},
140
- owner: { mode: 'optional' } // Admins see all, users see own
141
- }
143
+ firewall: [
144
+ { field: 'organizationId', equals: 'ctx.activeOrgId' },
145
+ { field: 'ownerId', equals: 'ctx.userId' },
146
+ { field: 'deletedAt', isNull: true },
147
+ ]
142
148
  ```
143
149
 
144
150
  ### Workflow with protected status
@@ -182,7 +188,7 @@ chat: {
182
188
  method: "POST",
183
189
  responseType: "stream",
184
190
  input: z.object({ message: z.string() }),
185
- guard: { roles: ["member"] },
191
+ access: { roles: ["member"] },
186
192
  handler: "./handlers/chat",
187
193
  }
188
194
  ```
@@ -200,7 +206,7 @@ export default defineActions(null, {
200
206
  method: "GET",
201
207
  description: "Health check endpoint",
202
208
  input: z.object({}),
203
- guard: { roles: ["member", "admin"] },
209
+ access: { roles: ["member", "admin"] },
204
210
  handler: "./handlers/health-check",
205
211
  },
206
212
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quickback-dev/cli",
3
- "version": "0.10.1",
3
+ "version": "0.10.4",
4
4
  "description": "CLI for Quickback — define your backend in TypeScript, compile to a fully wired Cloudflare Worker (or Bun / Node) with auth, database, migrations, security, CMS, and Account UI.",
5
5
  "author": "Kardoe Incorporated <paul@kardoe.com>",
6
6
  "license": "MIT",
@@ -41,6 +41,18 @@
41
41
  "README.md",
42
42
  "LICENSE"
43
43
  ],
44
+ "scripts": {
45
+ "prebuild": "npx tsx scripts/inject-version.ts && npm run bundle:docs && npm run bundle:skill && npm run bundle:examples",
46
+ "build": "tsc",
47
+ "postbuild": "npx tsx scripts/bundle-cursor.ts && rm -rf dist/skill dist/examples && cp -r src/skill dist/skill && cp -r src/examples dist/examples",
48
+ "dev": "tsc --watch",
49
+ "test": "bun test",
50
+ "typecheck": "tsc --noEmit",
51
+ "bundle:docs": "npx tsx scripts/bundle-docs.ts",
52
+ "bundle:skill": "npx tsx scripts/bundle-skill.ts",
53
+ "bundle:cursor": "npx tsx scripts/bundle-cursor.ts",
54
+ "bundle:examples": "npx tsx scripts/bundle-examples.ts"
55
+ },
44
56
  "dependencies": {
45
57
  "@modelcontextprotocol/sdk": "^1.11.0",
46
58
  "esbuild": "^0.27.2",
@@ -65,17 +77,5 @@
65
77
  },
66
78
  "engines": {
67
79
  "node": ">=18.0.0"
68
- },
69
- "scripts": {
70
- "prebuild": "npx tsx scripts/inject-version.ts && npm run bundle:docs && npm run bundle:skill && npm run bundle:examples",
71
- "build": "tsc",
72
- "postbuild": "npx tsx scripts/bundle-cursor.ts && rm -rf dist/skill dist/examples && cp -r src/skill dist/skill && cp -r src/examples dist/examples",
73
- "dev": "tsc --watch",
74
- "test": "bun test",
75
- "typecheck": "tsc --noEmit",
76
- "bundle:docs": "npx tsx scripts/bundle-docs.ts",
77
- "bundle:skill": "npx tsx scripts/bundle-skill.ts",
78
- "bundle:cursor": "npx tsx scripts/bundle-cursor.ts",
79
- "bundle:examples": "npx tsx scripts/bundle-examples.ts"
80
80
  }
81
- }
81
+ }
@@ -63,10 +63,13 @@ export const todos = sqliteTable("todos", {
63
63
  });
64
64
 
65
65
  export default defineTable(todos, {
66
- firewall: { organization: {}, owner: {} },
66
+ firewall: [
67
+ { field: "organizationId", equals: "ctx.activeOrgId" },
68
+ { field: "userId", equals: "ctx.userId" },
69
+ { field: "deletedAt", isNull: true },
70
+ ],
71
+ read: { access: { roles: ["member", "admin"] } },
67
72
  crud: {
68
- list: { access: { roles: ["member", "admin"] } },
69
- get: { access: { roles: ["member", "admin"] } },
70
73
  create: { access: { roles: ["member", "admin"] } },
71
74
  update: { access: { roles: ["admin"] } },
72
75
  delete: { access: { roles: ["admin"] }, mode: "soft" },
@@ -87,25 +90,30 @@ Every request passes through: `Request → Firewall → Access → Guards → Da
87
90
 
88
91
  ### 1. Firewall — Data Isolation
89
92
 
90
- Auto WHERE clauses for tenant isolation:
93
+ Auto WHERE clauses for tenant isolation. Predicates are AND'd:
91
94
 
92
95
  ```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
- }
96
+ firewall: [
97
+ { field: 'organizationId', equals: 'ctx.activeOrgId' }, // WHERE organizationId = ctx.activeOrgId
98
+ { field: 'ownerId', equals: 'ctx.userId' }, // AND ownerId = ctx.userId
99
+ { field: 'teamId', equals: 'ctx.activeTeamId' }, // AND teamId = ctx.activeTeamId
100
+ { field: 'deletedAt', isNull: true }, // AND deletedAt IS NULL
101
+ ]
102
+
103
+ // Public/system resources opt out of tenant scoping (soft-delete still applied):
104
+ firewall: [{ exception: true }]
100
105
  ```
101
106
 
107
+ Auto-derived when omitted: scans the schema for `organizationId` / `ownerId` / `teamId` and emits matching predicates. Two or more isolation columns → declare explicitly.
108
+
102
109
  ### 2. Access — Permission Checks
103
110
 
104
- Role-based and record-based (deny by default):
111
+ 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
112
 
106
113
  ```typescript
114
+ read: { access: { roles: ['member'] } }, // gates GET / and GET /:id
107
115
  crud: {
108
- list: { access: { roles: ['member'] } },
116
+ create: { access: { roles: ['admin'] } },
109
117
  update: {
110
118
  access: {
111
119
  or: [
@@ -114,9 +122,12 @@ crud: {
114
122
  ],
115
123
  },
116
124
  },
125
+ delete: { access: { roles: ['admin'] } },
117
126
  }
118
127
  ```
119
128
 
129
+ > **DSL v2:** `crud.list` and `crud.get` are rejected at compile time. Move them to `read.access`.
130
+
120
131
  Operators: `equals`, `notEquals`, `in`, `notIn`, `greaterThan`, `lessThan`
121
132
  Context: `$ctx.userId`, `$ctx.activeOrgId`, `$ctx.roles`
122
133