@quickback-dev/cli 0.10.2 → 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 +11 -11
  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 +1 -1
  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
  });