@quickback-dev/cli 0.50.3 → 0.50.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 (70) hide show
  1. package/dist/commands/deploy.d.ts +29 -0
  2. package/dist/commands/deploy.d.ts.map +1 -0
  3. package/dist/commands/deploy.js +324 -0
  4. package/dist/commands/deploy.js.map +1 -0
  5. package/dist/docs/content.d.ts.map +1 -1
  6. package/dist/docs/content.js +22 -17
  7. package/dist/docs/content.js.map +1 -1
  8. package/dist/index.js +10 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/lib/config-id-splice.d.ts +68 -0
  11. package/dist/lib/config-id-splice.d.ts.map +1 -0
  12. package/dist/lib/config-id-splice.js +364 -0
  13. package/dist/lib/config-id-splice.js.map +1 -0
  14. package/dist/lib/config-id-splice.test.d.ts +2 -0
  15. package/dist/lib/config-id-splice.test.d.ts.map +1 -0
  16. package/dist/lib/config-id-splice.test.js +246 -0
  17. package/dist/lib/config-id-splice.test.js.map +1 -0
  18. package/dist/lib/shell.d.ts +14 -0
  19. package/dist/lib/shell.d.ts.map +1 -1
  20. package/dist/lib/shell.js +27 -0
  21. package/dist/lib/shell.js.map +1 -1
  22. package/dist/lib/wrangler-resources.d.ts +131 -0
  23. package/dist/lib/wrangler-resources.d.ts.map +1 -0
  24. package/dist/lib/wrangler-resources.js +355 -0
  25. package/dist/lib/wrangler-resources.js.map +1 -0
  26. package/dist/lib/wrangler-resources.test.d.ts +2 -0
  27. package/dist/lib/wrangler-resources.test.d.ts.map +1 -0
  28. package/dist/lib/wrangler-resources.test.js +321 -0
  29. package/dist/lib/wrangler-resources.test.js.map +1 -0
  30. package/dist/skill/docs/changelog.md +6 -0
  31. package/dist/skill/docs/compiler/cloud-compiler/deploy.md +82 -0
  32. package/dist/skill/docs/compiler/cloud-compiler/endpoints.md +23 -0
  33. package/dist/skill/docs/compiler/cloud-compiler/local-compiler.md +2 -0
  34. package/dist/skill/docs/compiler/config/index.md +5 -0
  35. package/dist/skill/docs/compiler/config/security.md +1 -0
  36. package/dist/skill/docs/compiler/definitions/access.md +1 -0
  37. package/dist/skill/docs/compiler/definitions/actions.md +27 -1
  38. package/dist/skill/docs/compiler/definitions/encryption.md +1 -0
  39. package/dist/skill/docs/compiler/definitions/feature.md +2 -0
  40. package/dist/skill/docs/compiler/definitions/masking.md +1 -0
  41. package/dist/skill/docs/compiler/getting-started/hand-crafted.md +8 -1
  42. package/dist/skill/docs/compiler/getting-started/patterns.md +1 -1
  43. package/dist/skill/docs/compiler/targets/hono-api/database/neon.md +11 -4
  44. package/dist/skill/docs/compiler/targets/hono-api/using-the-api/errors.md +1 -0
  45. package/dist/skill/docs/stack/account-ui/environment-variables.md +11 -0
  46. package/dist/skill/docs/stack/account-ui/with-quickback.md +2 -0
  47. package/dist/skill/docs/stack/auth/jwt-optimization.md +9 -0
  48. package/dist/skill/docs/stack/cms/connecting.md +5 -0
  49. package/dist/skill/docs/stack/realtime/index.md +23 -5
  50. package/package.json +1 -1
  51. package/src/skill/docs/changelog.md +6 -0
  52. package/src/skill/docs/compiler/cloud-compiler/deploy.md +82 -0
  53. package/src/skill/docs/compiler/cloud-compiler/endpoints.md +23 -0
  54. package/src/skill/docs/compiler/cloud-compiler/local-compiler.md +2 -0
  55. package/src/skill/docs/compiler/config/index.md +5 -0
  56. package/src/skill/docs/compiler/config/security.md +1 -0
  57. package/src/skill/docs/compiler/definitions/access.md +1 -0
  58. package/src/skill/docs/compiler/definitions/actions.md +27 -1
  59. package/src/skill/docs/compiler/definitions/encryption.md +1 -0
  60. package/src/skill/docs/compiler/definitions/feature.md +2 -0
  61. package/src/skill/docs/compiler/definitions/masking.md +1 -0
  62. package/src/skill/docs/compiler/getting-started/hand-crafted.md +8 -1
  63. package/src/skill/docs/compiler/getting-started/patterns.md +1 -1
  64. package/src/skill/docs/compiler/targets/hono-api/database/neon.md +11 -4
  65. package/src/skill/docs/compiler/targets/hono-api/using-the-api/errors.md +1 -0
  66. package/src/skill/docs/stack/account-ui/environment-variables.md +11 -0
  67. package/src/skill/docs/stack/account-ui/with-quickback.md +2 -0
  68. package/src/skill/docs/stack/auth/jwt-optimization.md +9 -0
  69. package/src/skill/docs/stack/cms/connecting.md +5 -0
  70. package/src/skill/docs/stack/realtime/index.md +23 -5
@@ -0,0 +1,321 @@
1
+ import { describe, expect, it } from 'bun:test';
2
+ import { WranglerClient, buildProvisionPlan, configKeyForD1, isPlaceholderId, parseD1CreateOutput, parseD1ListOutput, parseKvCreateOutput, parseKvListOutput, parseWranglerToml, } from './wrangler-resources.js';
3
+ // A realistic compiler-emitted wrangler.toml (split-database D1 project with
4
+ // KV + R2 file storage), fresh from a first compile → all placeholder ids.
5
+ const FRESH_TOML = `# Generated by Quickback
6
+ name = "my-app"
7
+ main = "src/index.ts"
8
+ compatibility_date = "2025-01-01"
9
+ compatibility_flags = ["nodejs_compat"]
10
+
11
+ # Auth Database (Better Auth tables: users, sessions, accounts, ...)
12
+ [[d1_databases]]
13
+ binding = "AUTH_DB"
14
+ database_name = "my-app-auth"
15
+ database_id = "placeholder-1-auth-db-id"
16
+ migrations_dir = "quickback/drizzle/auth"
17
+
18
+ # Features Database (application tables)
19
+ [[d1_databases]]
20
+ binding = "DB"
21
+ database_name = "my-app-features"
22
+ database_id = "placeholder-2-features-db-id"
23
+ migrations_dir = "quickback/drizzle/features"
24
+
25
+ # Webhooks Database (webhook events, endpoints, deliveries)
26
+ [[d1_databases]]
27
+ binding = "WEBHOOKS_DB"
28
+ database_name = "my-app-webhooks"
29
+ database_id = "placeholder-5-webhooks-db-id"
30
+ migrations_dir = "quickback/drizzle/webhooks"
31
+
32
+ [[kv_namespaces]]
33
+ binding = "KV"
34
+ id = "placeholder-3-kv-namespace-id"
35
+
36
+ # R2 File Storage
37
+ [[r2_buckets]]
38
+ binding = "STORAGE"
39
+ bucket_name = "my-app-files"
40
+
41
+ # Files Metadata Database
42
+ [[d1_databases]]
43
+ binding = "FILES_DB"
44
+ database_name = "my-app-files"
45
+ database_id = "placeholder-4-files-db-id"
46
+ migrations_dir = "quickback/drizzle/files"
47
+
48
+ [assets]
49
+ binding = "ASSETS"
50
+ directory = "src/apps"
51
+ `;
52
+ describe('parseWranglerToml', () => {
53
+ // User story: As `quickback deploy`, I read the generated wrangler.toml as
54
+ // the source of truth for which Cloudflare resources the project needs.
55
+ it('extracts worker name, d1, kv, and r2 sections', () => {
56
+ const res = parseWranglerToml(FRESH_TOML);
57
+ expect(res.workerName).toBe('my-app');
58
+ expect(res.d1).toHaveLength(4);
59
+ expect(res.d1[0]).toEqual({
60
+ binding: 'AUTH_DB',
61
+ databaseName: 'my-app-auth',
62
+ databaseId: 'placeholder-1-auth-db-id',
63
+ migrationsDir: 'quickback/drizzle/auth',
64
+ });
65
+ expect(res.kv).toEqual([{ binding: 'KV', id: 'placeholder-3-kv-namespace-id' }]);
66
+ expect(res.r2).toEqual([{ binding: 'STORAGE', bucketName: 'my-app-files' }]);
67
+ });
68
+ it('does not confuse `binding = ...` inside plain tables ([assets]) with resources', () => {
69
+ const res = parseWranglerToml(FRESH_TOML);
70
+ const bindings = [...res.d1.map((d) => d.binding), ...res.kv.map((k) => k.binding), ...res.r2.map((r) => r.binding)];
71
+ expect(bindings).not.toContain('ASSETS');
72
+ });
73
+ it('parses hyperdrive sections', () => {
74
+ const res = parseWranglerToml('[[hyperdrive]]\nbinding = "HYPERDRIVE"\nid = "local"\n');
75
+ expect(res.hyperdrive).toEqual([{ binding: 'HYPERDRIVE', id: 'local' }]);
76
+ });
77
+ });
78
+ describe('isPlaceholderId', () => {
79
+ // Replicates apps/compiler/src/constants/placeholders.ts — both the
80
+ // self-describing `placeholder-*` generation and the legacy `local*` set
81
+ // must be recognized (all projects compiled pre-rename use the legacy set).
82
+ it('detects self-describing placeholder ids', () => {
83
+ expect(isPlaceholderId('placeholder-1-auth-db-id')).toBe(true);
84
+ expect(isPlaceholderId('placeholder-2-features-db-id')).toBe(true);
85
+ expect(isPlaceholderId('placeholder-3-kv-namespace-id')).toBe(true);
86
+ expect(isPlaceholderId('placeholder-4-files-db-id')).toBe(true);
87
+ expect(isPlaceholderId('placeholder-5-webhooks-db-id')).toBe(true);
88
+ expect(isPlaceholderId('placeholder-1-db-id')).toBe(true);
89
+ });
90
+ it('detects legacy placeholder ids', () => {
91
+ expect(isPlaceholderId('local')).toBe(true);
92
+ expect(isPlaceholderId('local-auth')).toBe(true);
93
+ expect(isPlaceholderId('local-features')).toBe(true);
94
+ expect(isPlaceholderId('local-files')).toBe(true);
95
+ expect(isPlaceholderId('local-webhooks')).toBe(true);
96
+ });
97
+ it('treats missing/empty ids as placeholders', () => {
98
+ expect(isPlaceholderId(undefined)).toBe(true);
99
+ expect(isPlaceholderId('')).toBe(true);
100
+ });
101
+ it('does not flag real Cloudflare ids', () => {
102
+ expect(isPlaceholderId('13b688c8-66cb-48ee-8840-6aaf0a7f5aad')).toBe(false); // D1 uuid
103
+ expect(isPlaceholderId('a8a94354f31849acb1b83bacc19b7597')).toBe(false); // KV 32-hex
104
+ // A user-named resource that merely CONTAINS 'local' must not be flagged.
105
+ expect(isPlaceholderId('localization-db-id')).toBe(false);
106
+ });
107
+ });
108
+ describe('configKeyForD1', () => {
109
+ it('maps self-describing placeholders to provider-config keys', () => {
110
+ expect(configKeyForD1({ binding: 'X', databaseName: 'n', databaseId: 'placeholder-1-auth-db-id' })).toBe('authDatabaseId');
111
+ expect(configKeyForD1({ binding: 'X', databaseName: 'n', databaseId: 'placeholder-2-features-db-id' })).toBe('featuresDatabaseId');
112
+ expect(configKeyForD1({ binding: 'X', databaseName: 'n', databaseId: 'placeholder-4-files-db-id' })).toBe('filesDatabaseId');
113
+ expect(configKeyForD1({ binding: 'X', databaseName: 'n', databaseId: 'placeholder-5-webhooks-db-id' })).toBe('webhooksDatabaseId');
114
+ expect(configKeyForD1({ binding: 'X', databaseName: 'n', databaseId: 'placeholder-1-db-id' })).toBe('databaseId');
115
+ });
116
+ it('maps legacy placeholders to provider-config keys', () => {
117
+ expect(configKeyForD1({ binding: 'X', databaseName: 'n', databaseId: 'local-auth' })).toBe('authDatabaseId');
118
+ expect(configKeyForD1({ binding: 'X', databaseName: 'n', databaseId: 'local-features' })).toBe('featuresDatabaseId');
119
+ expect(configKeyForD1({ binding: 'X', databaseName: 'n', databaseId: 'local' })).toBe('databaseId');
120
+ });
121
+ it('falls back to the binding name for unknown placeholders', () => {
122
+ expect(configKeyForD1({ binding: 'AUTH_DB', databaseName: 'n', databaseId: 'placeholder-99-mystery' })).toBe('authDatabaseId');
123
+ expect(configKeyForD1({ binding: 'AUDIT_DB', databaseName: 'n', databaseId: 'placeholder-99-mystery' })).toBe('auditDatabaseId');
124
+ expect(configKeyForD1({ binding: 'TOTALLY_CUSTOM', databaseName: 'n', databaseId: 'placeholder-99-mystery' })).toBeNull();
125
+ });
126
+ });
127
+ describe('buildProvisionPlan', () => {
128
+ it('splits resources into to-provision vs ready', () => {
129
+ const res = parseWranglerToml(FRESH_TOML);
130
+ const plan = buildProvisionPlan(res);
131
+ expect(plan.d1ToProvision.map((d) => d.databaseName)).toEqual([
132
+ 'my-app-auth', 'my-app-features', 'my-app-webhooks', 'my-app-files',
133
+ ]);
134
+ expect(plan.kvToProvision).toHaveLength(1);
135
+ expect(plan.r2ToEnsure).toHaveLength(1);
136
+ expect(plan.hasWork).toBe(true);
137
+ });
138
+ // User story: the second `quickback deploy` run must find nothing to create.
139
+ it('is a no-op plan once real ids are in place (idempotent second run)', () => {
140
+ const realToml = FRESH_TOML
141
+ .replace('placeholder-1-auth-db-id', '13b688c8-66cb-48ee-8840-6aaf0a7f5aad')
142
+ .replace('placeholder-2-features-db-id', '03d44a59-c286-4e41-918d-b54d13fdf7a1')
143
+ .replace('placeholder-5-webhooks-db-id', '1454bb29-a614-4a2d-a49d-7954f7405921')
144
+ .replace('placeholder-4-files-db-id', '99d44a59-c286-4e41-918d-b54d13fdf7aa')
145
+ .replace('placeholder-3-kv-namespace-id', 'a8a94354f31849acb1b83bacc19b7597');
146
+ const plan = buildProvisionPlan(parseWranglerToml(realToml));
147
+ expect(plan.d1ToProvision).toHaveLength(0);
148
+ expect(plan.kvToProvision).toHaveLength(0);
149
+ expect(plan.d1Ready).toHaveLength(4);
150
+ expect(plan.kvReady).toHaveLength(1);
151
+ });
152
+ });
153
+ describe('wrangler output parsing', () => {
154
+ // Current wrangler emits a JSON config snippet after creation.
155
+ it('parses `wrangler d1 create` JSON output', () => {
156
+ const output = [
157
+ "✅ Successfully created DB 'my-app-auth' in region WNAM",
158
+ 'Created your new D1 database.',
159
+ '',
160
+ '{',
161
+ ' "d1_databases": [',
162
+ ' {',
163
+ ' "binding": "DB",',
164
+ ' "database_name": "my-app-auth",',
165
+ ' "database_id": "f6b8f9a0-1234-4cde-9f01-abcdefabcdef"',
166
+ ' }',
167
+ ' ]',
168
+ '}',
169
+ ].join('\n');
170
+ expect(parseD1CreateOutput(output)).toBe('f6b8f9a0-1234-4cde-9f01-abcdefabcdef');
171
+ });
172
+ // Older wrangler emitted a TOML snippet instead.
173
+ it('parses `wrangler d1 create` TOML output', () => {
174
+ const output = [
175
+ "✅ Successfully created DB 'my-app-auth'",
176
+ '',
177
+ '[[d1_databases]]',
178
+ 'binding = "DB"',
179
+ 'database_name = "my-app-auth"',
180
+ 'database_id = "f6b8f9a0-1234-4cde-9f01-abcdefabcdef"',
181
+ ].join('\n');
182
+ expect(parseD1CreateOutput(output)).toBe('f6b8f9a0-1234-4cde-9f01-abcdefabcdef');
183
+ });
184
+ it('returns null when d1 create output has no id', () => {
185
+ expect(parseD1CreateOutput('something went sideways')).toBeNull();
186
+ });
187
+ it('parses `wrangler kv namespace create` JSON output', () => {
188
+ const output = [
189
+ '🌀 Creating namespace with title "my-app-KV"',
190
+ '✨ Success!',
191
+ 'Add the following to your configuration file in your kv_namespaces array:',
192
+ '{',
193
+ ' "kv_namespaces": [',
194
+ ' {',
195
+ ' "binding": "KV",',
196
+ ' "id": "032eb64c2e4a4a4f8f4a34f52f4a4a4f"',
197
+ ' }',
198
+ ' ]',
199
+ '}',
200
+ ].join('\n');
201
+ expect(parseKvCreateOutput(output)).toBe('032eb64c2e4a4a4f8f4a34f52f4a4a4f');
202
+ });
203
+ it('parses `wrangler kv namespace create` TOML output', () => {
204
+ const output = [
205
+ '🌀 Creating namespace with title "my-app-KV"',
206
+ '✨ Success!',
207
+ '[[kv_namespaces]]',
208
+ 'binding = "KV"',
209
+ 'id = "032eb64c2e4a4a4f8f4a34f52f4a4a4f"',
210
+ ].join('\n');
211
+ expect(parseKvCreateOutput(output)).toBe('032eb64c2e4a4a4f8f4a34f52f4a4a4f');
212
+ });
213
+ it('parses `wrangler d1 list --json` output with leading banner noise', () => {
214
+ const output = [
215
+ ' ⛅️ wrangler 4.2.0',
216
+ '-------------------',
217
+ '[',
218
+ ' { "uuid": "13b688c8-66cb-48ee-8840-6aaf0a7f5aad", "name": "my-app-auth", "version": "production" },',
219
+ ' { "uuid": "03d44a59-c286-4e41-918d-b54d13fdf7a1", "name": "my-app-features" }',
220
+ ']',
221
+ ].join('\n');
222
+ const map = parseD1ListOutput(output);
223
+ expect(map.get('my-app-auth')).toBe('13b688c8-66cb-48ee-8840-6aaf0a7f5aad');
224
+ expect(map.get('my-app-features')).toBe('03d44a59-c286-4e41-918d-b54d13fdf7a1');
225
+ });
226
+ it('parses `wrangler kv namespace list` output', () => {
227
+ const output = '[\n { "id": "a8a94354f31849acb1b83bacc19b7597", "title": "my-app-KV" }\n]';
228
+ const map = parseKvListOutput(output);
229
+ expect(map.get('my-app-KV')).toBe('a8a94354f31849acb1b83bacc19b7597');
230
+ });
231
+ });
232
+ describe('WranglerClient (with injected runner)', () => {
233
+ function runnerFromScript(script) {
234
+ const calls = [];
235
+ const runner = async (args) => {
236
+ const key = args.join(' ');
237
+ calls.push(key);
238
+ const result = script[key];
239
+ if (!result)
240
+ throw new Error(`Unexpected wrangler call in test: ${key}`);
241
+ return result;
242
+ };
243
+ return { runner, calls };
244
+ }
245
+ it('d1Create falls back to d1 list when create output is unparseable', async () => {
246
+ const { runner, calls } = runnerFromScript({
247
+ 'd1 create my-app-auth': { code: 0, stdout: 'Created your new D1 database.', stderr: '' },
248
+ 'd1 list --json': {
249
+ code: 0,
250
+ stdout: '[{ "uuid": "13b688c8-66cb-48ee-8840-6aaf0a7f5aad", "name": "my-app-auth" }]',
251
+ stderr: '',
252
+ },
253
+ });
254
+ const client = new WranglerClient(runner);
255
+ expect(await client.d1Create('my-app-auth')).toBe('13b688c8-66cb-48ee-8840-6aaf0a7f5aad');
256
+ expect(calls).toEqual(['d1 create my-app-auth', 'd1 list --json']);
257
+ });
258
+ it('d1Create tolerates "already exists" and resolves the id via list', async () => {
259
+ const { runner } = runnerFromScript({
260
+ 'd1 create my-app-auth': { code: 1, stdout: '', stderr: 'A database with that name already exists' },
261
+ 'd1 list --json': {
262
+ code: 0,
263
+ stdout: '[{ "uuid": "13b688c8-66cb-48ee-8840-6aaf0a7f5aad", "name": "my-app-auth" }]',
264
+ stderr: '',
265
+ },
266
+ });
267
+ const client = new WranglerClient(runner);
268
+ expect(await client.d1Create('my-app-auth')).toBe('13b688c8-66cb-48ee-8840-6aaf0a7f5aad');
269
+ });
270
+ it('d1Create surfaces real failures', async () => {
271
+ const { runner } = runnerFromScript({
272
+ 'd1 create my-app-auth': { code: 1, stdout: '', stderr: 'Authentication error [code: 10000]' },
273
+ });
274
+ const client = new WranglerClient(runner);
275
+ await expect(client.d1Create('my-app-auth')).rejects.toThrow(/Authentication error/);
276
+ });
277
+ it('kvCreate parses the created namespace id', async () => {
278
+ const { runner } = runnerFromScript({
279
+ 'kv namespace create KV': {
280
+ code: 0,
281
+ stdout: '✨ Success!\n{ "kv_namespaces": [ { "binding": "KV", "id": "032eb64c2e4a4a4f8f4a34f52f4a4a4f" } ] }',
282
+ stderr: '',
283
+ },
284
+ });
285
+ const client = new WranglerClient(runner);
286
+ expect(await client.kvCreate('KV', 'my-app-KV')).toBe('032eb64c2e4a4a4f8f4a34f52f4a4a4f');
287
+ });
288
+ it('r2Create treats "already exists" as success', async () => {
289
+ const { runner } = runnerFromScript({
290
+ 'r2 bucket create my-app-files': {
291
+ code: 1,
292
+ stdout: '',
293
+ stderr: 'The bucket you tried to create already exists, and you own it. [code: 10004]',
294
+ },
295
+ });
296
+ const client = new WranglerClient(runner);
297
+ expect(await client.r2Create('my-app-files')).toBe('exists');
298
+ });
299
+ it('whoami reports unauthenticated sessions', async () => {
300
+ const { runner } = runnerFromScript({
301
+ whoami: { code: 0, stdout: 'You are not authenticated. Please run `wrangler login`.', stderr: '' },
302
+ });
303
+ const client = new WranglerClient(runner);
304
+ const result = await client.whoami();
305
+ expect(result.ok).toBe(false);
306
+ });
307
+ it('whoami extracts the account email when logged in', async () => {
308
+ const { runner } = runnerFromScript({
309
+ whoami: {
310
+ code: 0,
311
+ stdout: 'Getting User settings...\n👋 You are logged in with an OAuth Token, associated with the email paul@example.com!',
312
+ stderr: '',
313
+ },
314
+ });
315
+ const client = new WranglerClient(runner);
316
+ const result = await client.whoami();
317
+ expect(result.ok).toBe(true);
318
+ expect(result.detail).toBe('paul@example.com');
319
+ });
320
+ });
321
+ //# sourceMappingURL=wrangler-resources.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrangler-resources.test.js","sourceRoot":"","sources":["../../src/lib/wrangler-resources.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,GAGlB,MAAM,yBAAyB,CAAC;AAEjC,6EAA6E;AAC7E,2EAA2E;AAC3E,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8ClB,CAAC;AAEF,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,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E,MAAM,EAAE,yDAAyD,EAAE,MAAM,EAAE,EAAE,EAAE;SACnG,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAChE,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC;YAClC,MAAM,EAAE;gBACN,IAAI,EAAE,CAAC;gBACP,MAAM,EAAE,iHAAiH;gBACzH,MAAM,EAAE,EAAE;aACX;SACF,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ### Security: three fail-closed fixes in the generated runtime
6
+
7
+ - **Scoped `db` blocks Drizzle's relational query API.** `db.query.<table>.findFirst()` / `findMany()` build their SQL outside the scoped wrapper's reach, so they read across organizations. The scoped `db` handed to actions now **throws** on any `db.query.<table>` access (and the Neon hyperdrive typed `db`/`tx` fails `tsc` on it) with directions to `db.select()` (auto-scoped) or an `unsafe: true` action's `unsafeDb.query` with an explicit scope predicate. Handlers that relied on the unscoped pass-through were reading other tenants' rows and must be updated. See [Relational queries are blocked](/compiler/definitions/actions#relational-queries-are-blocked-fail-closed).
8
+ - **`POST /api/v1/token` requires session authentication.** The auth middleware now stamps `ctx.authMethod` (`'session' | 'jwt' | 'api-key' | 'oauth'`), and the token endpoint rejects anything but `'session'` with `401 AUTH_SESSION_REQUIRED`. Pre-fix, a JWT could mint its own replacement — a stolen or revoked token (banned user, removed member, demoted role) could roll a 180s-TTL token forever without re-validating the session.
9
+ - **Broadcaster DO no longer trusts the `X-Internal-Call` header alone.** Inline-mode `checkAuth` now requires `X-Internal-Secret` to match `BETTER_AUTH_SECRET` (already provisioned; the secret never leaves the worker/DO boundary on a stub call), separate mode compares `ACCESS_TOKEN` constant-time, and every generated internal caller (`lib/realtime.ts` senders, the live-view seq reader, the Better Auth role-change hook) sends the secret. A spoofed header can no longer reach broadcast injection or webhook repointing through any forwarded route.
10
+
5
11
  ### Neon reads through user-anchored relationships
6
12
 
7
13
  Resources readable via a multi-hop chain anchored on the caller's user id (e.g. a
@@ -0,0 +1,82 @@
1
+ # Deploying
2
+
3
+ A freshly compiled project's `wrangler.toml` contains **placeholder resource ids** — the compiler can't know your D1 database ids or KV namespace id until those resources exist in your Cloudflare account. Historically that meant a manual dance: `wrangler d1 create`, copy the id, paste it into `quickback.config.ts`, repeat for every database, recompile, deploy.
4
+
5
+ `quickback deploy` does the whole dance for you:
6
+
7
+ ```bash
8
+ cd my-app && quickback deploy
9
+ ```
10
+
11
+ ## What it does
12
+
13
+ 1. **Preflight** — verifies `wrangler` is runnable (via `npx`) and authenticated with Cloudflare (`wrangler whoami`). Log in with `npx wrangler login` or set `CLOUDFLARE_API_TOKEN`.
14
+ 2. **Compiles first if needed** — if the project has never compiled (no `wrangler.toml`), it runs the same flow as `quickback compile` before planning anything.
15
+ 3. **Plans from wrangler.toml** — reads the generated `wrangler.toml` and finds every resource whose id is still a placeholder:
16
+ - **D1 databases** — auth, features, files, and webhooks databases (whichever your project's features pull in; split-database projects get one entry each)
17
+ - **KV namespace** — the `KV` binding used for rate limiting and session overflow
18
+ - **R2 buckets** — file-storage buckets (R2 is referenced by name, so buckets are simply ensured to exist)
19
+ 4. **Creates what's missing** — `wrangler d1 create <name>`, `wrangler kv namespace create <BINDING>`, `wrangler r2 bucket create <name>`. Resources are named from your project name exactly the way the compiler names them (`my-app-auth`, `my-app-features`, `my-app-files`, `my-app-KV`, …). If a resource with the expected name already exists in your account, its id is reused instead of creating a duplicate.
20
+ 5. **Writes ids back into quickback.config.ts** — a surgical, formatting-preserving edit of your `providers.database.config` (and `providers.storage.config` for the KV id when you declare a `cloudflare-kv` storage provider). Comments, indentation, and every other key are left untouched. Works with both authoring styles:
21
+
22
+ ```ts
23
+ // defineDatabase(...) wrapper
24
+ database: defineDatabase("cloudflare-d1", {
25
+ splitDatabases: true,
26
+ authDatabaseId: "…", // ← inserted/updated here
27
+ featuresDatabaseId: "…",
28
+ }),
29
+
30
+ // plain object form
31
+ database: {
32
+ name: "cloudflare-d1",
33
+ config: {
34
+ authDatabaseId: "…", // ← or here
35
+ },
36
+ },
37
+ ```
38
+
39
+ 6. **Recompiles** — so `wrangler.toml` regenerates with the real ids.
40
+ 7. **Applies D1 migrations remotely** — `wrangler d1 migrations apply <db> --remote` for each database that has pending migration files (each database's `migrations_dir` comes straight from `wrangler.toml`).
41
+ 8. **Deploys** — `wrangler deploy`, streaming wrangler's output.
42
+
43
+ ## Idempotent by design
44
+
45
+ Run it again any time. When every id is real, there's nothing to create — the command goes straight to compile → migrations → deploy. It's a perfectly good everyday "ship it" command, not just a first-deploy tool.
46
+
47
+ ## Flags
48
+
49
+ | Flag | Effect |
50
+ |------|--------|
51
+ | `--dry-run` | Print the provisioning plan (what would be created vs. what's already set) and exit. Creates nothing. |
52
+ | `--skip-deploy` | Provision resources + sync ids + recompile, but skip migrations and the deploy itself. |
53
+ | `--force` | Overwrite a config id that differs from what Cloudflare reports. Without it, a mismatch prints both values and aborts — never silently overwritten. |
54
+ | `--verbose` | Detailed remote compile failure output (same as `quickback compile --verbose`). |
55
+
56
+ ```bash
57
+ # See the plan without touching your account
58
+ quickback deploy --dry-run
59
+
60
+ # Provision + write ids only; deploy later
61
+ quickback deploy --skip-deploy
62
+ ```
63
+
64
+ ## Conflicting ids
65
+
66
+ If `quickback.config.ts` already carries a real id for a resource and Cloudflare reports a different one for the same-named resource, `quickback deploy` prints both and stops:
67
+
68
+ ```
69
+ ✖ Config ids differ from what Cloudflare reports:
70
+ providers.database.config.authDatabaseId
71
+ in quickback.config.ts: 13b688c8-…
72
+ from Cloudflare: f6b8f9a0-…
73
+ ```
74
+
75
+ Re-run with `--force` to take Cloudflare's value, or fix the config by hand.
76
+
77
+ ## Notes
78
+
79
+ - **Security-audit database** — projects using unsafe cross-tenant actions require an audit D1 database, and the compiler fails closed at compile time until `auditDatabaseId` is set. Follow the compile error's instructions (create the database, set the id), then re-run `quickback deploy`.
80
+ - **Neon projects** — `quickback deploy` does not apply Postgres migrations. Run `npm run db:migrate` (needs `DATABASE_MIGRATION_URL`) before traffic hits the worker, or use the generated project's `npm run deploy` script which chains both.
81
+ - **Hyperdrive** — a Hyperdrive binding can't be auto-created (it needs your database connection string). Create it with `wrangler hyperdrive create <name> --connection-string=… --caching-disabled` and set `providers.database.config.hyperdrive.id`.
82
+ - **Two logins** — the compile step uses your Quickback account (`quickback login`); resource creation and deploy use your wrangler credentials.
@@ -17,6 +17,29 @@ The cloud compiler API is hosted at `https://compiler.quickback.dev`.
17
17
 
18
18
  The `/compile` endpoint requires either a session token (from `quickback login`) or an API key (via `QUICKBACK_API_KEY` header). See [Authentication](/compiler/cloud-compiler/authentication) for details.
19
19
 
20
+ ## Raw-files mode (`POST /compile`)
21
+
22
+ `/compile` normally expects the parsed `CompilerInput` the CLI assembles client-side. Thin clients (agents, web builders, CI without the CLI) can instead send the project sources verbatim and let the compiler organize them server-side:
23
+
24
+ ```json
25
+ {
26
+ "rawFiles": {
27
+ "quickback/quickback.config.ts": "import { defineConfig } from …",
28
+ "quickback/features/todos/todos.ts": "import { feature, q } from …",
29
+ "quickback/features/todos/actions/complete.ts": "…"
30
+ }
31
+ }
32
+ ```
33
+
34
+ The map uses project-root-relative paths and follows the same layout `quickback compile` reads from disk: `quickback/quickback.config.ts`, `quickback/features/**`, `quickback/services/**`, `quickback/{lib,hooks,plugins,middlewares,email-templates}/**`, plus `quickback/drizzle/**/meta/**` and `wrangler.toml` for incremental builds.
35
+
36
+ Two constraints, both fail-closed:
37
+
38
+ - **The config must be fully static.** The compiler parses `quickback.config.ts` with a literals-only evaluator — it never executes user code. Object/array/string/number/boolean literals, substitution-free template literals, and the `define*` helper calls all work; variables, computed values, and imports-as-values are rejected with a 400 that names the offending construct and line.
39
+ - **Action input schemas are optional.** The CLI harvests `z.toJSONSchema` on your machine; raw-files requests may pass `actionInputSchemas` alongside `rawFiles`, otherwise the compiler's static parser supplies lower-fidelity input schemas.
40
+
41
+ Works with both `?complete=true` and `?complete=false` (validation-only) compiles.
42
+
20
43
  ## Environment Variables
21
44
 
22
45
  | Variable | Description |
@@ -74,6 +74,8 @@ The Docker image includes:
74
74
 
75
75
  When compiling a project with `cms: true` or `account: true`, the compiler builds the SPAs from source inside the container with the correct Vite environment variables (e.g., `VITE_QUICKBACK_API_URL`, `VITE_QUICKBACK_ACCOUNT_URL`). This ensures each project gets properly configured SPA assets without manual intervention.
76
76
 
77
+ The generated worker additionally injects the same per-project values into every served SPA shell as `window.__QUICKBACK_RUNTIME`, and the SPAs prefer that runtime blob over the baked env — so the served behavior is identical even with a generic (no-`.env`) SPA build.
78
+
77
79
  ## Deploying to Cloud
78
80
 
79
81
  After making changes to the compiler, deploy to `compiler.quickback.dev`:
@@ -8,6 +8,11 @@ import { defineConfig, defineRuntime, defineDatabase, defineAuth } from "@quickb
8
8
  export default defineConfig({
9
9
  name: "my-app",
10
10
  template: "hono",
11
+ auth: {
12
+ // Required for "+" role expansion in access rules (e.g. roles: ["member+"]).
13
+ // Lowest → highest. Omit if you always list roles explicitly.
14
+ roleHierarchy: ["member", "admin", "owner"],
15
+ },
11
16
  providers: {
12
17
  runtime: defineRuntime("cloudflare"),
13
18
  database: defineDatabase("cloudflare-d1"),
@@ -129,6 +129,7 @@ When you opt into a `csp` object, the compiler additively widens directives base
129
129
  | `cms: true` OR `account: true` | `https://fonts.gstatic.com` | `fontSrc` | The googleapis CSS loads `.woff2` from gstatic |
130
130
  | `csp` set (always) | `@trustedOrigins` | `connectSrc` | XHR/fetch must reach the same allowlist `cors()` permits — covers cross-subdomain APIs without re-listing them |
131
131
  | `cms: true` OR `account: true` | `https://${domain}` for each `cms.domain` / `account.domain` / `domain` / inferred unified domain | `connectSrc` | The Vite bundle hardcodes `VITE_QUICKBACK_API_URL` at compile time, so the SPA fetches that exact URL even when the page is served from a different origin (e.g. localhost dev hitting prod-baked SPA). Emitted with the host's first letter capitalised (`https://Api.example.com`) so `wrangler dev`'s response-header rewrite can't mangle it — see [the `wrangler dev` note below](#why-the-spa-baked-origin-shows-up-capitalised-in-csp). |
132
+ | `cms: true` OR `account: true` | `'sha256-…'` (one exact hash per bundled SPA) | `scriptSrc` | The worker injects `<script>window.__QUICKBACK_RUNTIME={...}</script>` into every served SPA shell (runtime-configured SPAs). The blob is fixed at compile time, so an exact script hash keeps strict `script-src` policies intact — no `'unsafe-inline'`. |
132
133
 
133
134
  **Scaffold rule:** if you set `defaultSrc` but omit the target directive (e.g. you wrote `defaultSrc: ['@self']` and nothing for `connectSrc`), auto-config creates the new directive seeded with your `defaultSrc` values plus the addition. `defaultSrc` itself stays clean. So `defaultSrc: ['@self']` + auto-config produces:
134
135
 
@@ -278,6 +278,7 @@ access: { userRole: ["appmanager"] }
278
278
  access: { roles: ["SYSADMIN"] }
279
279
 
280
280
  // Org-membership roles with hierarchy expansion
281
+ // ("+" requires auth.roleHierarchy in quickback.config.ts — see Role Hierarchy above)
281
282
  access: { roles: ["member+"] } // expands to ["member", "admin", "owner"]
282
283
  access: { roles: ["admin+"] } // expands to ["admin", "owner"]
283
284
  access: { roles: ["admin"] } // exact match (no expansion)
@@ -41,7 +41,10 @@ features/applications/
41
41
  | `actions/<name>.ts` | The feature's primary table (table file matching the feature name), or standalone if `path:` is set. |
42
42
  | `actions/<table>/<name>.ts` | The sibling table file `<table>.ts` at the feature root. Standalone actions inside a subdir ignore the binding. |
43
43
 
44
- The action's filename (sans `.ts`) is the action name and the URL segment.
44
+ The action's filename (sans `.ts`) is the action name and the URL segment, and
45
+ it must be a valid **camelCase identifier** — `sendMessage.ts`, not
46
+ `send-message.ts` (hyphenated names are a compile error, since the name becomes
47
+ a generated identifier).
45
48
  Uniqueness is enforced per `(bound table, name)` pair — sibling-bound
46
49
  actions on **different** tables may share a verb (`actions/episodes/publish.ts`
47
50
  and `actions/shows/publish.ts` mount at `/episodes/:id/publish` and
@@ -657,6 +660,29 @@ async execute({ db, ctx, input }) {
657
660
  - **Masking** — actions are backend code that may need raw data
658
661
  - **Access** — already checked before action execution
659
662
 
663
+ ### Relational queries are blocked (fail-closed)
664
+
665
+ Drizzle's relational query API — `db.query.<table>.findFirst()` /
666
+ `findMany()` (including nested `with:` relations) — builds its SQL from the
667
+ relations config and your `where` alone, so the scoped wrapper cannot inject
668
+ the org/owner/team firewall into it. Rather than silently returning rows from
669
+ every tenant, the scoped `db` **throws** on any `db.query.<table>` access:
670
+
671
+ ```typescript
672
+ async execute({ db, input }) {
673
+ // ❌ Throws: relational queries aren't org-scoped
674
+ const item = await db.query.media.findFirst({ where: eq(media.id, input.id) });
675
+
676
+ // ✅ Scoped builder — firewall conditions injected automatically
677
+ const [item] = await db.select().from(media).where(eq(media.id, input.id));
678
+ }
679
+ ```
680
+
681
+ If you genuinely need the relational API, declare the action `unsafe: true`
682
+ and query `unsafeDb.query` with an **explicit** scope predicate in the WHERE
683
+ (e.g. `eq(media.organizationId, ctx.activeOrgId)`), exactly like any other
684
+ unsafe read.
685
+
660
686
  ### Unsafe Mode
661
687
 
662
688
  Actions that need to bypass scoped DB filters (for example, platform-level support operations) can enable unsafe mode.
@@ -11,6 +11,7 @@ export default feature('guests', {
11
11
  emergencyContact: q.text().encrypted(),
12
12
  dietaryNotes: q.text().encrypted(),
13
13
  },
14
+ // "+" role expansion requires auth.roleHierarchy in quickback.config.ts
14
15
  read: { access: { roles: ['member+'] } },
15
16
  create: { access: { roles: ['member+'] } },
16
17
  });
@@ -16,6 +16,7 @@ export const contacts = q.table("contacts", {
16
16
 
17
17
  export default defineTable(contacts, {
18
18
  firewall: [{ field: 'organizationId', equals: 'ctx.activeOrgId' }],
19
+ // "+" role expansion requires auth.roleHierarchy in quickback.config.ts
19
20
  read: { access: { roles: ["member+"] } },
20
21
  create: { access: { roles: ["member+"] } },
21
22
  update: { access: { roles: ["member+"] } },
@@ -39,6 +40,7 @@ export default feature("contacts", {
39
40
  name: q.text().optional(),
40
41
  },
41
42
  firewall: [{ field: 'organizationId', equals: 'ctx.activeOrgId' }],
43
+ // "+" role expansion requires auth.roleHierarchy in quickback.config.ts
42
44
  read: { access: { roles: ["member+"] } },
43
45
  create: { access: { roles: ["member+"] } },
44
46
  update: { access: { roles: ["member+"] } },
@@ -260,6 +260,7 @@ export default feature('candidates', {
260
260
  },
261
261
  },
262
262
  read: {
263
+ // "+" role expansion requires auth.roleHierarchy in quickback.config.ts
263
264
  access: { roles: ['member+'] },
264
265
  views: {
265
266
  pipeline: {
@@ -39,7 +39,14 @@ import { defineConfig } from "@quickback/compiler";
39
39
  export default defineConfig({
40
40
  name: "my-app",
41
41
  template: "hono",
42
- features: ["organizations"],
42
+ features: {
43
+ organizations: true,
44
+ },
45
+ auth: {
46
+ // Required for "+" role expansion in access rules (e.g. roles: ["member+"]).
47
+ // Lowest → highest. Omit if you always list roles explicitly.
48
+ roleHierarchy: ["member", "admin", "owner"],
49
+ },
43
50
  providers: {
44
51
  runtime: { name: "cloudflare", config: {} },
45
52
  database: {
@@ -134,7 +134,7 @@ import { projects } from "../projects";
134
134
  export default defineAction({
135
135
  description: "Assign a project to an org member",
136
136
  input: z.object({ assigneeId: z.string() }),
137
- access: { roles: ["member+"] },
137
+ access: { roles: ["member+"] }, // "+" requires auth.roleHierarchy in quickback.config.ts
138
138
  async execute({ db, record, input, ctx, c, whereRecord }) {
139
139
  const role = await getOrgMemberRole(c.get("authDb"), input.assigneeId, ctx.activeOrgId!);
140
140
  if (!role) {