@quickback-dev/cli 0.66.6 → 0.66.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.
Files changed (50) hide show
  1. package/dist/commands/build.d.ts +0 -1
  2. package/dist/commands/build.d.ts.map +1 -1
  3. package/dist/commands/build.js +0 -1
  4. package/dist/commands/build.js.map +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/lib/api-client.d.ts +1 -1
  7. package/dist/lib/api-client.d.ts.map +1 -1
  8. package/dist/lib/api-client.js +13 -8
  9. package/dist/lib/api-client.js.map +1 -1
  10. package/dist/lib/api-client.test.js +47 -0
  11. package/dist/lib/api-client.test.js.map +1 -1
  12. package/dist/lib/file-writer.d.ts +1 -1
  13. package/dist/lib/file-writer.d.ts.map +1 -1
  14. package/dist/lib/file-writer.js +2 -3
  15. package/dist/lib/file-writer.js.map +1 -1
  16. package/dist/lib/migrations/drizzle.d.ts.map +1 -1
  17. package/dist/lib/migrations/drizzle.js +6 -1
  18. package/dist/lib/migrations/drizzle.js.map +1 -1
  19. package/dist/lib/migrations/drizzle.test.js +7 -0
  20. package/dist/lib/migrations/drizzle.test.js.map +1 -1
  21. package/dist/lib/migrations/executor.d.ts.map +1 -1
  22. package/dist/lib/migrations/executor.js +4 -0
  23. package/dist/lib/migrations/executor.js.map +1 -1
  24. package/dist/lib/migrations/postprocessors/better-auth-upgrade.d.ts +7 -0
  25. package/dist/lib/migrations/postprocessors/better-auth-upgrade.d.ts.map +1 -0
  26. package/dist/lib/migrations/postprocessors/better-auth-upgrade.js +149 -0
  27. package/dist/lib/migrations/postprocessors/better-auth-upgrade.js.map +1 -0
  28. package/dist/skill/docs/define/actions/index.md +6 -0
  29. package/dist/skill/docs/define/actions/scoped-db.md +88 -41
  30. package/dist/skill/docs/define/transitions.md +11 -0
  31. package/dist/skill/docs/define/triggers.md +4 -0
  32. package/dist/skill/docs/platform/auth/index.md +37 -0
  33. package/dist/skill/docs/platform/database/d1.md +2 -2
  34. package/dist/skill/docs/platform/database/neon.md +246 -55
  35. package/dist/skill/docs/platform/queues/handlers.md +12 -0
  36. package/dist/skill/docs/platform/schedules/index.md +3 -1
  37. package/dist/skill/docs/tooling/cloud-compiler/endpoints.md +10 -0
  38. package/dist/skill/docs/tooling/cloud-compiler/troubleshooting.md +16 -0
  39. package/package.json +1 -1
  40. package/src/skill/docs/define/actions/index.md +6 -0
  41. package/src/skill/docs/define/actions/scoped-db.md +88 -41
  42. package/src/skill/docs/define/transitions.md +11 -0
  43. package/src/skill/docs/define/triggers.md +4 -0
  44. package/src/skill/docs/platform/auth/index.md +37 -0
  45. package/src/skill/docs/platform/database/d1.md +2 -2
  46. package/src/skill/docs/platform/database/neon.md +246 -55
  47. package/src/skill/docs/platform/queues/handlers.md +12 -0
  48. package/src/skill/docs/platform/schedules/index.md +3 -1
  49. package/src/skill/docs/tooling/cloud-compiler/endpoints.md +10 -0
  50. package/src/skill/docs/tooling/cloud-compiler/troubleshooting.md +16 -0
@@ -1 +1 @@
1
- {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/lib/migrations/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,EACtB,iBAAiB,GAElB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAA6B,MAAM,WAAW,CAAC;AACzE,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,2B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AG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CACnD,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,cAAc,CAAC,MAA+B;IACrD,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;QACpB,MAAM,MAAM,CAAC,MAAM,YAAY,KAAK;YAClC,CAAC,CAAC,MAAM,CAAC,MAAM;YACf,CAAC,CAAC,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAChD,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,MAA6B;IAC7D,IAAI,MAAM,CAAC,iBAAiB,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACnD,OAAO,OAAO,CACZ,MAAM,CAAC,WAAW;QAClB,CACE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;YACvD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,IAAI,EAAE,CAAC;iBAC5C,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CACtD,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ /** Issuers in the pinned 1.7.2 built-ins; ambiguous/custom identities fail closed. */
2
+ export declare function accountIssuerBackfill(providerColumn: string): string;
3
+ /** Upgrade a generated SQLite account ADD into a populated-table-safe rebuild. */
4
+ export declare function upgradeSqliteAuthMigration(sql: string, snapshot: any): string;
5
+ /** Only modify NEW compiler-owned deltas, never supplied migration history. */
6
+ export declare function prepareBetterAuthUpgradeMigrations(outputDir: string, existingFiles: Record<string, string>): Promise<void>;
7
+ //# sourceMappingURL=better-auth-upgrade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"better-auth-upgrade.d.ts","sourceRoot":"","sources":["../../../../src/lib/migrations/postprocessors/better-auth-upgrade.ts"],"names":[],"mappings":"AAMA,sFAAsF;AACtF,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAYpE;AAED,kFAAkF;AAClF,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,MAAM,CA4C7E;AAgCD,+EAA+E;AAC/E,wBAAsB,kCAAkC,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAuChI"}
@@ -0,0 +1,149 @@
1
+ // Kept in parity with apps/compiler/src/utils/better-auth-upgrade.ts.
2
+ import { readFile, readdir, writeFile } from 'fs/promises';
3
+ import { join, relative } from 'path';
4
+ const quote = (name) => `"${name.replaceAll('"', '""')}"`;
5
+ /** Issuers in the pinned 1.7.2 built-ins; ambiguous/custom identities fail closed. */
6
+ export function accountIssuerBackfill(providerColumn) {
7
+ const p = quote(providerColumn);
8
+ return `CASE ${p}
9
+ WHEN 'credential' THEN 'local:credential'
10
+ WHEN 'siwe' THEN 'local:siwe'
11
+ WHEN 'google' THEN 'https://accounts.google.com'
12
+ WHEN 'apple' THEN 'https://appleid.apple.com'
13
+ WHEN 'facebook' THEN 'https://www.facebook.com'
14
+ WHEN 'line' THEN 'https://access.line.me'
15
+ WHEN 'github' THEN 'local:oauth:github'
16
+ WHEN 'cloudflare' THEN 'local:oauth:cloudflare'
17
+ ELSE NULL END`;
18
+ }
19
+ /** Upgrade a generated SQLite account ADD into a populated-table-safe rebuild. */
20
+ export function upgradeSqliteAuthMigration(sql, snapshot) {
21
+ for (const table of Object.values(snapshot.tables ?? {})) {
22
+ if (!/^accounts?$/.test(table.name) || !table.columns.issuer || !(table.columns.provider_id || table.columns.providerId))
23
+ continue;
24
+ const name = table.name;
25
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
26
+ const add = new RegExp('ALTER TABLE [`"]' + escaped + '[`"] ADD (?:COLUMN )?[`"]issuer[`"] text NOT NULL;', 'i');
27
+ if (!add.test(sql))
28
+ continue;
29
+ for (const key of ['compositePrimaryKeys', 'uniqueConstraints', 'checkConstraints']) {
30
+ if (Object.keys(table[key] ?? {}).length)
31
+ throw new Error(`Better Auth 1.7 upgrade: custom ${key} on ${name} needs an explicit account migration.`);
32
+ }
33
+ for (const other of Object.values(snapshot.tables ?? {})) {
34
+ if (Object.values(other.foreignKeys ?? {}).some(fk => fk.tableTo === name)) {
35
+ throw new Error(`Better Auth 1.7 upgrade: ${other.name} references ${name}; prepare an explicit migration to preserve those relationships.`);
36
+ }
37
+ }
38
+ const columns = Object.values(table.columns);
39
+ const provider = table.columns.provider_id ? 'provider_id' : 'providerId';
40
+ const accountId = table.columns.account_id ? 'account_id' : 'accountId';
41
+ const userId = table.columns.user_id ? 'user_id' : 'userId';
42
+ const temp = `__qb_auth17_${name}`;
43
+ const definitions = columns.map(c => `${quote(c.name)} ${c.type}${c.primaryKey ? ' PRIMARY KEY' : ''}${c.notNull ? ' NOT NULL' : ''}${c.default !== undefined ? ` DEFAULT ${c.default}` : ''}`);
44
+ for (const fk of Object.values(table.foreignKeys ?? {})) {
45
+ definitions.push(`FOREIGN KEY (${fk.columnsFrom.map(quote).join(', ')}) REFERENCES ${quote(fk.tableTo)} (${fk.columnsTo.map(quote).join(', ')}) ON UPDATE ${fk.onUpdate} ON DELETE ${fk.onDelete}`);
46
+ }
47
+ const selected = columns.map(c => c.name === 'issuer' ? accountIssuerBackfill(provider)
48
+ : c.name === accountId ? `CASE WHEN ${quote(provider)} = 'credential' THEN ${quote(userId)} ELSE ${quote(accountId)} END`
49
+ : quote(c.name));
50
+ // Create the unique identity index BEFORE copying, so a collision or
51
+ // unknown provider aborts before the old account table can be dropped.
52
+ const indexes = Object.values(table.indexes ?? {});
53
+ const identityIndex = indexes.find(i => i.isUnique && i.columns.includes('issuer'));
54
+ if (!identityIndex)
55
+ throw new Error('Better Auth 1.7 upgrade: missing account identity index');
56
+ const rebuild = `-- Better Auth 1.7 account identity backfill. Unknown providers/collisions abort; existing accounts remain intact.\n` +
57
+ `CREATE TABLE ${quote(temp)} (\n ${definitions.join(',\n ')}\n);\n` +
58
+ `CREATE UNIQUE INDEX ${quote(temp + '_identity')} ON ${quote(temp)} (${identityIndex.columns.map(quote).join(', ')});\n` +
59
+ `INSERT INTO ${quote(temp)} (${columns.map(c => quote(c.name)).join(', ')}) SELECT ${selected.join(', ')} FROM ${quote(name)};\n` +
60
+ `DROP TABLE ${quote(name)};\nALTER TABLE ${quote(temp)} RENAME TO ${quote(name)};\nDROP INDEX ${quote(temp + '_identity')};\n` +
61
+ indexes.map(i => `CREATE ${i.isUnique ? 'UNIQUE ' : ''}INDEX ${quote(i.name)} ON ${quote(name)} (${i.columns.map(quote).join(', ')});`).join('\n');
62
+ // The rebuild restores all indexes, including the newly added identity
63
+ // index. Remove later CREATEs for this table to avoid duplicate names.
64
+ sql = sql.replace(new RegExp('CREATE (?:UNIQUE )?INDEX [`"][^`"]+[`"] ON [`"]' + escaped + '[`"][^;]*;', 'gi'), '');
65
+ sql = sql.replace(add, rebuild);
66
+ }
67
+ return upgradeOAuthData(sql, snapshot);
68
+ }
69
+ /** 1.6 grants do not record resources; require reauthorization after upgrade. */
70
+ function upgradeOAuthData(sql, snapshot) {
71
+ for (const table of Object.values(snapshot.tables ?? {})) {
72
+ const name = table.name;
73
+ const ref = table.schema ? `${quote(table.schema)}.${quote(name)}` : quote(name);
74
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
75
+ const tablePattern = table.schema ? quote(table.schema).replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '\\.' + quote(name) : '[`"]' + escaped + '[`"]';
76
+ const resources = new RegExp('ALTER TABLE ' + tablePattern + ' ADD (?:COLUMN )?[`"]resources[`"] (?:text(?:\\[\\])?|jsonb?);', 'i');
77
+ if (resources.test(sql)) {
78
+ const revoked = table.columns.revoked;
79
+ if (revoked) {
80
+ sql += `\n-- Pre-1.7 grants have no authorized resource set: revoke rather than widen.\nUPDATE ${ref} SET ${quote('revoked')} = ${snapshot.dialect === 'postgresql' ? 'CURRENT_TIMESTAMP' : '1'} WHERE ${quote('resources')} IS NULL;\n`;
81
+ }
82
+ else if (/oauth_consent/.test(name)) {
83
+ sql += `\nDELETE FROM ${ref} WHERE ${quote('resources')} IS NULL;\n`;
84
+ }
85
+ }
86
+ const applicationType = table.columns.application_type ? 'application_type' : 'applicationType';
87
+ const dropType = new RegExp('ALTER TABLE ' + tablePattern + ' DROP COLUMN [`"]type[`"];', 'i');
88
+ if (dropType.test(sql) && table.columns[applicationType]) {
89
+ sql = sql.replace(dropType, `UPDATE ${ref} SET ${quote(applicationType)} = CASE WHEN ${quote('type')} = 'native' THEN 'native' ELSE 'web' END WHERE ${quote(applicationType)} IS NULL;\n$&`);
90
+ }
91
+ const dropPublic = new RegExp('ALTER TABLE ' + tablePattern + ' DROP COLUMN [`"]public[`"];', 'i');
92
+ const method = table.columns.token_endpoint_auth_method ? 'token_endpoint_auth_method' : 'tokenEndpointAuthMethod';
93
+ if (dropPublic.test(sql) && table.columns[method]) {
94
+ sql = sql.replace(dropPublic, `UPDATE ${ref} SET ${quote(method)} = 'none' WHERE ${quote('public')} = ${snapshot.dialect === 'postgresql' ? 'true' : '1'};\n$&`);
95
+ }
96
+ }
97
+ return sql;
98
+ }
99
+ /** Only modify NEW compiler-owned deltas, never supplied migration history. */
100
+ export async function prepareBetterAuthUpgradeMigrations(outputDir, existingFiles) {
101
+ if (!Object.keys(existingFiles).some(p => /(?:^|\/)meta\/\d+_snapshot\.json$/.test(p)))
102
+ return;
103
+ async function visit(dir) {
104
+ for (const entry of await readdir(dir, { withFileTypes: true })) {
105
+ const path = join(dir, entry.name);
106
+ if (entry.isDirectory()) {
107
+ if (!['node_modules', '.git'].includes(entry.name))
108
+ await visit(path);
109
+ }
110
+ else if (/^\d+.*\.sql$/.test(entry.name)) {
111
+ const rel = relative(outputDir, path).replaceAll('\\', '/');
112
+ if (existingFiles[rel] !== undefined)
113
+ continue;
114
+ const sql = await readFile(path, 'utf8');
115
+ if (!/ADD (?:COLUMN )?[`"]issuer[`"] text NOT NULL/i.test(sql))
116
+ continue;
117
+ const index = entry.name.match(/^\d+/)[0];
118
+ const snapshot = JSON.parse(await readFile(join(dir, 'meta', `${index}_snapshot.json`), 'utf8'));
119
+ if (snapshot.dialect !== 'sqlite') {
120
+ // Postgres can tighten the column after a backfill without rebuilding
121
+ // its table; retain all existing foreign keys and indexes.
122
+ let upgraded = sql;
123
+ for (const table of Object.values(snapshot.tables ?? {})) {
124
+ if (!/^accounts?$/.test(table.name) || !table.columns.issuer)
125
+ continue;
126
+ const ref = table.schema ? `${quote(table.schema)}.${quote(table.name)}` : quote(table.name);
127
+ const add = `ALTER TABLE ${ref} ADD COLUMN "issuer" text NOT NULL;`;
128
+ if (!upgraded.includes(add))
129
+ continue;
130
+ const provider = table.columns.provider_id ? 'provider_id' : 'providerId';
131
+ const accountId = table.columns.account_id ? 'account_id' : 'accountId';
132
+ const userId = table.columns.user_id ? 'user_id' : 'userId';
133
+ upgraded = upgraded.replace(add, `ALTER TABLE ${ref} ADD COLUMN "issuer" text;\n` +
134
+ `UPDATE ${ref} SET "issuer" = ${accountIssuerBackfill(provider)}, ${quote(accountId)} = CASE WHEN ${quote(provider)} = 'credential' THEN ${quote(userId)} ELSE ${quote(accountId)} END;\n` +
135
+ `ALTER TABLE ${ref} ALTER COLUMN "issuer" SET NOT NULL;`);
136
+ }
137
+ if (upgraded === sql)
138
+ throw new Error('Better Auth 1.7 upgrade: unrecognized account migration; prepare an explicit issuer backfill.');
139
+ await writeFile(path, upgradeOAuthData(upgraded, snapshot));
140
+ }
141
+ else {
142
+ await writeFile(path, upgradeSqliteAuthMigration(sql, snapshot));
143
+ }
144
+ }
145
+ }
146
+ }
147
+ await visit(outputDir);
148
+ }
149
+ //# sourceMappingURL=better-auth-upgrade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"better-auth-upgrade.js","sourceRoot":"","sources":["../../../../src/lib/migrations/postprocessors/better-auth-upgrade.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEtC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AAElE,sFAAsF;AACtF,MAAM,UAAU,qBAAqB,CAAC,cAAsB;IAC1D,MAAM,CAAC,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC;IAChC,OAAO,QAAQ,CAAC;;;;;;;;;kBASA,CAAC;AACnB,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,0BAA0B,CAAC,GAAW,EAAE,QAAa;IACnE,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAU,EAAE,CAAC;QAClE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;YAAE,SAAS;QACnI,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACxB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;QAC5D,MAAM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SAAS;wBACtC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;wBAC1E,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC;wBACxE,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;wBAC5D,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,8BAA8B;4BAC/E,UAAU,GAAG,mBAAmB,qBAAqB,CAAC,QAAQ,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC,gBAAgB,KAAK,CAAC,QAAQ,CAAC,wBAAwB,KAAK,CAAC,MAAM,CAAC,SAAS,KAAK,CAAC,SAAS,CAAC,SAAS;4BAC1L,eAAe,GAAG,sCAAsC,CAAC,CAAC;oBAC9D,CAAC;oBACD,IAAI,QAAQ,KAAK,GAAG;wBAAE,MAAM,IAAI,KAAK,CAAC,+FAA+F,CAAC,CAAC;oBACvI,MAAM,SAAS,CAAC,IAAI,EAAE,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;gBAC9D,CAAC;qBAAM,CAAC;oBACN,MAAM,SAAS,CAAC,IAAI,EAAE,0BAA0B,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;gBACnE,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC;AACzB,CAAC"}
@@ -19,6 +19,12 @@ most common needless action is one of these hand-rolled.
19
19
  Write the action for the remainder: third-party calls, multi-step orchestration,
20
20
  AI/streaming responses, anything genuinely imperative.
21
21
 
22
+ The compiler backstops this check: an action named `<crudVerb><Table>`
23
+ (`createIssue`, `listIssues`) or `<statusVerb><Table>` (`closeIssue`,
24
+ `cancelReservation`) with no `transition:` config compiles with a **warning**
25
+ pointing at the primitive it shadows. Heed it — the duplicate route never
26
+ inherits the table's guards, masking, or ETags.
27
+
22
28
  ## Overview
23
29
 
24
30
  Quickback supports two types of actions:
@@ -74,11 +74,17 @@ intersected with the same authority context: a single or shared hydration
74
74
  target is required, while targets selected by distinct relationship lanes are
75
75
  optional and must be narrowed by the handler.
76
76
 
77
- For tables queried by authored actions, `resource.databaseAccess` adds an
78
- independent Postgres RLS policy without adding HTTP surface. It never mounts a
79
- read/CRUD route and never adds an OpenAPI operation. The action remains the API
80
- layer where validation, state transitions, side effects, and business logic
81
- belong; `databaseAccess` is only the database's row-level upper bound.
77
+ For tables queried by authored actions, `resource.databaseAccess` opens a
78
+ **delegated-principal lane** at the database: an independent Postgres RLS policy
79
+ with no HTTP surface. It never mounts a read/CRUD route and never adds an
80
+ OpenAPI operation. The action remains the API layer where validation, state
81
+ transitions, side effects, and business logic belong; `databaseAccess` is only
82
+ the database's row-level upper bound.
83
+
84
+ It exists for one reason. A delegated principal has no `userId`, no active
85
+ organization, and no membership roles, so the table's ordinary firewall
86
+ predicate — `organizationId = ctx.activeOrgId` — can never match for it. The
87
+ lane is the row rule that CAN: the principal's own verified claims.
82
88
 
83
89
  {/* doc-compile: skip — provider prerequisite: `resource.databaseAccess` compiles only on Cloudflare + Neon `connectionMode: "hyperdrive"` (RLS + transaction-local claims), and the gate's harness is D1. The file is otherwise whole and compiles on a Neon project. */}
84
90
  ```typescript
@@ -95,49 +101,81 @@ export const attendanceEvidence = q.table('attendanceEvidence', {
95
101
  });
96
102
 
97
103
  export default defineTable(attendanceEvidence, {
98
- // Ordinary account CRUD remains organization-scoped.
104
+ // The ACCOUNT lane: ordinary organization-scoped CRUD. This is the firewall,
105
+ // and the firewall is the only pillar that lowers to SQL.
99
106
  firewall: [
100
107
  { field: "organizationId", equals: "ctx.activeOrgId" },
101
108
  ],
102
109
 
103
- // Authored actions can use their caller-scoped db under one of two exact
104
- // row lanes. Sibling arms OR; fields in each arm AND.
110
+ // The DELEGATE lane: the event delegate has no active organization, so the
111
+ // firewall above can never admit it. Its rows are the ones its own claims
112
+ // name. Fields inside one arm AND; sibling `or` arms are independent lanes.
105
113
  databaseAccess: {
106
114
  select: {
107
- or: [
108
- {
109
- roles: ["AUTHENTICATED"],
110
- record: {
111
- organizationId: { equals: "$ctx.activeOrgId" },
112
- },
113
- },
114
- {
115
- principals: ["event_delegate"],
116
- record: {
117
- eventId: { equals: "$ctx.principal.claims.eventId" },
118
- personId: { equals: "$ctx.principal.claims.personId" },
119
- },
120
- },
121
- ],
115
+ principals: ["event_delegate"],
116
+ record: {
117
+ eventId: { equals: "$ctx.principal.claims.eventId" },
118
+ personId: { equals: "$ctx.principal.claims.personId" },
119
+ },
122
120
  },
123
121
  },
124
122
  });
125
123
  ```
126
124
 
127
- `databaseAccess` supports `select`, `insert`, `update`, and `delete` with a
128
- purpose-built, SQL-pushable rule language: `principals`, `roles`, recursive
129
- `or`/`and`, and record `equals` against a DB-visible account or principal
130
- context value. Application-only values such as `userRole`, functions, and
131
- request/body fields stay at the action access layer; the compiler refuses them
132
- inside database RLS rather than pretending PostgreSQL can evaluate them.
133
-
134
- Every authorization path must contain at least one nonempty record equality.
135
- A principal-only or role-only leaf is rejected; every `or` arm must be bounded.
136
- An `and` group is bounded when at least one child bounds every expansion (for
137
- example, a principal child AND an event-id record child). A node cannot mix
138
- leaf fields with `or`/`and`, because the boolean node is the complete rule.
139
- This mandatory shape prevents an action declaration from accidentally granting
140
- the delegated principal an entire table.
125
+ ### One lane, one policy
126
+
127
+ The compiler emits exactly **one** permissive policy per table with a lane,
128
+ `<table>_principal_scope`, whose `USING` is the OR over the declared principal
129
+ arms. Two principal types on the same table are two arms of that one policy,
130
+ not two policies.
131
+
132
+ Its **command is the lane's declared reach**:
133
+
134
+ | Declared | Emitted |
135
+ |----------|---------|
136
+ | `select` only | `FOR SELECT`, `USING` only — the lane reads and cannot write |
137
+ | any of `insert` / `update` / `delete` | `FOR ALL`, with the same predicate as `WITH CHECK` |
138
+
139
+ Whether a delegate may write is a property of the lane, declared once by the
140
+ author, so the database enforces it as the policy's command. Which *verb* a
141
+ caller may reach is still the API's decision — RLS is the lane backstop, not a
142
+ per-operation access matrix.
143
+
144
+ The policy is **permissive**, and PostgreSQL ORs permissive policies together,
145
+ so the lane opens *beside* the table's `<table>_scope` firewall policy rather
146
+ than narrowing it. That is the point — the delegated caller has no active
147
+ organization — but it means a `databaseAccess` arm is never a place to write a
148
+ restriction: a row that satisfies the arm is reachable even when the table
149
+ firewall would not have matched it, and even when it is soft-deleted.
150
+ Restrictions belong in `firewall`. The restrictive `<table>_deny_anon` and
151
+ `<table>_principal_fence` policies remain the only arms that cap every lane.
152
+
153
+ ### What the compiler refuses, and why
154
+
155
+ `databaseAccess` lowers **only** `principals` + `record`, plus recursive
156
+ `or`/`and` over those. Two shapes that used to be spellable here are now
157
+ compile errors:
158
+
159
+ - **`roles`, anywhere.** Authored roles are enforced by the API and never reach
160
+ SQL (generated RLS is a backstop, not a second copy of `access`), so a role
161
+ arm here promised an authorization the database did not enforce. `roles` is
162
+ absent from the `DatabaseAccessRule` type as well, so an editor rejects it
163
+ before the compiler does.
164
+ - **A `record` equality with no `principals` gate.** That is an owner or tenant
165
+ rule, and those go in `firewall` — the one pillar that lowers to SQL. If the
166
+ owner boundary must hold at the database, author it as a firewall arm.
167
+
168
+ Both produce: *databaseAccess lowers only delegated-principal lanes (principals
169
+ + record). Account-lane scope belongs in firewall; roles are enforced by the
170
+ API.*
171
+
172
+ Every authorization path must also contain at least one record equality. A
173
+ principal-only leaf is rejected; every `or` arm must be bounded on its own,
174
+ because each is an independent lane. An `and` group is one lane whose children
175
+ may split the principal gate and the row bound between them. A node cannot mix
176
+ leaf fields with `or`/`and`, because the boolean node is the complete rule. This
177
+ mandatory shape is what stops a lane declaration from quietly granting a
178
+ delegated principal an entire table.
141
179
 
142
180
  The supported equality sources are `ctx.userId`, `ctx.activeOrgId`,
143
181
  `ctx.activeTeamId`, `ctx.principal.actor.id`, optional principal session/family
@@ -145,10 +183,19 @@ ids, and `ctx.principal.claims.<name>` (with or without a leading `$`). The
145
183
  record keys are Drizzle/JavaScript table field names; Quickback resolves them
146
184
  through the table metadata and quotes the exact physical PostgreSQL identifier,
147
185
  so a field such as `eventId: text("event-id")` is safe. Unknown fields fail the
148
- compile. `ADMIN` and the app-only `INTERNAL` marker are forbidden on this DB
149
- surface, while `SYSADMIN` retains its explicit `cms.sysadmin` prerequisite. The
150
- feature is rejected outside Cloudflare + Neon Hyperdrive because those targets
151
- cannot guarantee request-scoped Postgres claims.
186
+ compile. Application-only values — `userRole`, functions, request/body fields —
187
+ stay at the action access layer; the compiler refuses them rather than
188
+ pretending PostgreSQL can evaluate them. The feature is rejected outside
189
+ Cloudflare + Neon Hyperdrive because no other target can guarantee
190
+ request-scoped Postgres claims.
191
+
192
+ > **Upgrading.** The four per-operation `<table>_database_<op>` policies are
193
+ > retired. One appended `quickback_rls` migration drops them on every table and
194
+ > creates the single `<table>_principal_scope` where a lane is declared —
195
+ > append-only, like every other security migration. A `databaseAccess` block that
196
+ > still carries `roles` (or a principal-less `record`) fails the compile with the
197
+ > message above; move the account arm to `firewall` and keep the principal arm.
198
+
152
199
 
153
200
  ### Scoped relational-query safety
154
201
 
@@ -15,6 +15,17 @@ Two declaration sites:
15
15
  idempotency, and compiler-applied writes, for an action you are writing
16
16
  anyway.
17
17
 
18
+ Both work on **any table in the feature** — the primary and its siblings
19
+ alike. A sibling table's transitions synthesize to
20
+ `actions/<table>/<name>.ts`, bound to that table, importing the generated
21
+ per-table helper (`.quickback/define-action.<table>`), and mount at
22
+ `POST /<table>/:id/<name>` exactly like a primary's. So a status machine on a
23
+ child table (`reservations` inside `features/sessions/`) does not force the
24
+ table into its own feature — group related tables freely. Never replace
25
+ declared transitions with hand-written per-verb actions: you lose the
26
+ generated routes, the `guards.protected` integration, and the CMS
27
+ affordances.
28
+
18
29
  ## Two lines per state change
19
30
 
20
31
  ```typescript
@@ -78,6 +78,10 @@ the next migrate.
78
78
  - `OLD.column` / `NEW.column` references use **SQL column names**
79
79
  (`deleted_at`, not `deletedAt`) and are validated against the table at
80
80
  compile time.
81
+ - Bare `CASE ... END` expressions, including nested cases, are supported.
82
+ For example: `SELECT CASE WHEN NEW.total < 0 THEN RAISE(ABORT, 'invalid total') END;`.
83
+ That `END` closes the expression; authored `BEGIN ... END` trigger frames
84
+ are rejected.
81
85
  - Optional `when:` is a SQL expression guard (`WHEN` clause).
82
86
  - To reject a write, `SELECT RAISE(ABORT, 'message');` — this is the only
83
87
  trigger form that blocks *every* write path, including raw SQL.
@@ -62,3 +62,40 @@ Roles are used throughout the security layers — in [Access](/define/access) ru
62
62
 
63
63
  - [Plugins](/platform/auth/plugins) — Email OTP, passkeys, magic links, and more
64
64
  - [Security](/platform/auth/security) — Cookies, rate limiting, cross-domain auth
65
+
66
+ ## Compiler-managed auth versions and upgrades
67
+
68
+ The compiler pins Better Auth, its schema CLI, and the generated companion
69
+ packages to **1.7.2**. Recompile and install the emitted dependencies together;
70
+ remove older Better Auth overrides from `build.dependencies`. An incompatible
71
+ override is rejected because it would run a different auth version from the
72
+ one that generated your schema.
73
+
74
+ For an existing project, retain its `quickback/drizzle` migration history and
75
+ use the updated CLI when recompiling. The CLI generates the upgrade locally;
76
+ migration history stays on your machine. Apply the newly generated auth migration before
77
+ starting the updated Worker. Existing migration SQL is preserved. The upgrade
78
+ adds the current JWT/OAuth schema, including JWKS `alg`/`crv` and resource-bound
79
+ grants, and backfills account identities without resetting credentials.
80
+
81
+ Automatic account backfill covers password, SIWE, Google, Apple, Facebook,
82
+ Line, GitHub, and compiler-managed Cloudflare accounts. Unknown/custom provider
83
+ identities and duplicate identities must be resolved with an explicit migration;
84
+ the generated migration fails before replacing existing account rows. Custom
85
+ foreign keys into SQLite's account table also require an explicit migration.
86
+ Rehearse the migration against a database copy, and stop old auth writers during
87
+ the cutover so they cannot write the previous account shape.
88
+
89
+ Existing OAuth grants without a recorded resource set are revoked during the
90
+ upgrade; clients must authorize again. Client registrations and ordinary
91
+ sessions are retained. The compiler maps its audience configuration into the
92
+ 1.7 `resources` option and preserves the previous global resource allowlist
93
+ for clients (`enforcePerClientResources: false`). Authorization-code and refresh
94
+ grants still bind resources and reject widening to an unauthorized resource.
95
+ Projects opting into per-client resource restrictions must link their clients
96
+ to resources using the OAuth provider's resource administration APIs.
97
+
98
+ The bundled Account UI uses `signIn.social` and `linkSocial` for generic OAuth
99
+ providers, including Cloudflare. Their callback is now
100
+ `/auth/v1/callback/cloudflare`; update the registered redirect URI when upgrading
101
+ an existing Cloudflare login integration.
@@ -395,7 +395,7 @@ For all Quickback-generated code, D1's application-layer security provides equiv
395
395
  2. **Generated code enforces rules** - All CRUD and Action endpoints automatically apply firewall, access, guards, and masking.
396
396
  3. **Single entry point** - Every request flows through your API where security is enforced.
397
397
 
398
- Unlike Neon, where PostgreSQL RLS provides database-level enforcement (protecting data even if application code has bugs), D1's security comes from architecture: the database is inaccessible except through your Worker, and all generated routes apply the four security pillars. The trade-off is that **custom routes you write outside Quickback must manually apply security** — there is no database-level safety net.
398
+ Unlike Neon, where PostgreSQL RLS provides a database-level backstop (protecting tenant scope, soft delete and lane admission even if application code has bugs — roles, status, transitions and masking stay with the API either way, see [Row Level Security](/platform/database/neon#row-level-security)), D1's security comes from architecture: the database is inaccessible except through your Worker, and all generated routes apply the four security pillars. The trade-off is that **custom routes you write outside Quickback must manually apply security** — there is no database-level safety net.
399
399
 
400
400
  ### Comparison with Neon RLS
401
401
 
@@ -403,7 +403,7 @@ Unlike Neon, where PostgreSQL RLS provides database-level enforcement (protectin
403
403
  |----------|------|-----|
404
404
  | CRUD endpoints | ✅ Secure (RLS + App) | ✅ Secure (App) |
405
405
  | Actions | ✅ Secure (RLS + App) | ✅ Secure (App) |
406
- | Manual routes | ✅ RLS still protects | ⚠️ Must apply firewall |
406
+ | Manual routes | ✅ RLS still fences tenant scope, soft delete and lane admission — not roles | ⚠️ Must apply firewall |
407
407
  | External DB access | ⚠️ Possible with credentials | ✅ Not possible |
408
408
  | Dashboard queries | Via the Neon console | ⚠️ Admin only (audit logged) |
409
409