@quickback-dev/cli 0.18.0 → 0.34.1

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 (93) hide show
  1. package/dist/commands/compile.d.ts.map +1 -1
  2. package/dist/commands/compile.js +25 -1
  3. package/dist/commands/compile.js.map +1 -1
  4. package/dist/commands/migrations.d.ts +17 -0
  5. package/dist/commands/migrations.d.ts.map +1 -0
  6. package/dist/commands/migrations.js +328 -0
  7. package/dist/commands/migrations.js.map +1 -0
  8. package/dist/docs/content.d.ts.map +1 -1
  9. package/dist/docs/content.js +33 -63
  10. package/dist/docs/content.js.map +1 -1
  11. package/dist/index.js +7 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/api-client.d.ts +17 -0
  14. package/dist/lib/api-client.d.ts.map +1 -1
  15. package/dist/lib/api-client.js.map +1 -1
  16. package/dist/lib/file-loader.d.ts +39 -0
  17. package/dist/lib/file-loader.d.ts.map +1 -1
  18. package/dist/lib/file-loader.js +73 -0
  19. package/dist/lib/file-loader.js.map +1 -1
  20. package/dist/lib/file-loader.test.js +22 -1
  21. package/dist/lib/file-loader.test.js.map +1 -1
  22. package/dist/skill/docs/changelog.md +1118 -1
  23. package/dist/skill/docs/compiler/config/domains.md +70 -10
  24. package/dist/skill/docs/compiler/config/index.md +74 -3
  25. package/dist/skill/docs/compiler/config/output.md +1 -1
  26. package/dist/skill/docs/compiler/config/providers.md +6 -12
  27. package/dist/skill/docs/compiler/config/single-tenant.md +1 -1
  28. package/dist/skill/docs/compiler/config/variables.md +0 -30
  29. package/dist/skill/docs/compiler/definitions/access.md +357 -3
  30. package/dist/skill/docs/compiler/definitions/actions.md +85 -8
  31. package/dist/skill/docs/compiler/definitions/schema.md +6 -10
  32. package/dist/skill/docs/compiler/index.md +15 -34
  33. package/dist/skill/docs/compiler/targets/hono-api/cloudflare.md +1 -2
  34. package/dist/skill/docs/compiler/targets/hono-api/database/neon.md +0 -1
  35. package/dist/skill/docs/compiler/targets/hono-api/using-the-api/actions-api.md +19 -0
  36. package/dist/skill/docs/compiler/targets/hono-api/using-the-api/batch-operations.md +1 -1
  37. package/dist/skill/docs/compiler/targets/index.md +6 -34
  38. package/dist/skill/docs/index.md +2 -5
  39. package/dist/skill/docs/stack/account-ui/customization.md +2 -14
  40. package/dist/skill/docs/stack/account-ui/environment-variables.md +7 -1
  41. package/dist/skill/docs/stack/account-ui/features/admin.md +2 -2
  42. package/dist/skill/docs/stack/account-ui/features/avatars.md +2 -4
  43. package/dist/skill/docs/stack/account-ui/features/index.md +1 -1
  44. package/dist/skill/docs/stack/account-ui/features/organizations.md +31 -11
  45. package/dist/skill/docs/stack/account-ui/hooks.md +4 -0
  46. package/dist/skill/docs/stack/account-ui/index.md +5 -43
  47. package/dist/skill/docs/stack/account-ui/with-quickback.md +2 -75
  48. package/dist/skill/docs/stack/auth/plugins/aws-ses.md +60 -0
  49. package/dist/skill/docs/stack/auth/plugins/aws-sns.md +169 -0
  50. package/dist/skill/docs/stack/auth/plugins/index.md +106 -0
  51. package/package.json +1 -1
  52. package/src/skill/docs/changelog.md +1057 -0
  53. package/src/skill/docs/compiler/config/domains.md +26 -0
  54. package/src/skill/docs/compiler/config/index.md +74 -3
  55. package/src/skill/docs/compiler/config/providers.md +6 -12
  56. package/src/skill/docs/compiler/config/single-tenant.md +1 -1
  57. package/src/skill/docs/compiler/config/variables.md +0 -30
  58. package/src/skill/docs/compiler/definitions/access.md +357 -3
  59. package/src/skill/docs/compiler/definitions/actions.md +85 -8
  60. package/src/skill/docs/compiler/definitions/schema.md +6 -10
  61. package/src/skill/docs/compiler/index.md +15 -34
  62. package/src/skill/docs/compiler/targets/hono-api/cloudflare.md +1 -2
  63. package/src/skill/docs/compiler/targets/hono-api/database/neon.md +0 -1
  64. package/src/skill/docs/compiler/targets/hono-api/using-the-api/actions-api.md +19 -0
  65. package/src/skill/docs/compiler/targets/hono-api/using-the-api/batch-operations.md +1 -1
  66. package/src/skill/docs/compiler/targets/index.md +6 -34
  67. package/src/skill/docs/index.md +2 -5
  68. package/src/skill/docs/stack/account-ui/customization.md +2 -14
  69. package/src/skill/docs/stack/account-ui/environment-variables.md +7 -1
  70. package/src/skill/docs/stack/account-ui/features/admin.md +2 -2
  71. package/src/skill/docs/stack/account-ui/features/avatars.md +2 -4
  72. package/src/skill/docs/stack/account-ui/features/index.md +1 -1
  73. package/src/skill/docs/stack/account-ui/features/organizations.md +31 -11
  74. package/src/skill/docs/stack/account-ui/hooks.md +4 -0
  75. package/src/skill/docs/stack/account-ui/index.md +5 -43
  76. package/src/skill/docs/stack/account-ui/with-quickback.md +2 -75
  77. package/src/skill/docs/stack/auth/plugins/aws-ses.md +60 -0
  78. package/src/skill/docs/stack/auth/plugins/aws-sns.md +169 -0
  79. package/src/skill/docs/stack/auth/plugins/index.md +32 -0
  80. package/dist/skill/docs/compiler/targets/supabase-rls/index.md +0 -55
  81. package/dist/skill/docs/compiler/targets/supabase-rls/limitations.md +0 -48
  82. package/dist/skill/docs/compiler/targets/supabase-rls/mappings.md +0 -99
  83. package/dist/skill/docs/compiler/targets/supabase-rls/setup.md +0 -88
  84. package/dist/skill/docs/stack/account-ui/library-usage.md +0 -257
  85. package/dist/skill/docs/stack/account-ui/standalone.md +0 -149
  86. package/dist/skill/docs/stack/account-ui/worker.md +0 -362
  87. package/src/skill/docs/compiler/targets/supabase-rls/index.md +0 -55
  88. package/src/skill/docs/compiler/targets/supabase-rls/limitations.md +0 -48
  89. package/src/skill/docs/compiler/targets/supabase-rls/mappings.md +0 -99
  90. package/src/skill/docs/compiler/targets/supabase-rls/setup.md +0 -88
  91. package/src/skill/docs/stack/account-ui/library-usage.md +0 -257
  92. package/src/skill/docs/stack/account-ui/standalone.md +0 -149
  93. package/src/skill/docs/stack/account-ui/worker.md +0 -362
@@ -1,362 +0,0 @@
1
- # Worker Setup
2
-
3
- > **Compiler-Embedded is Recommended**
4
- >
5
- > Most Quickback projects embed Account UI via the compiler (`account: { ... }` in config). The compiler builds the SPA from source with your settings baked in — no manual Worker setup needed. See [With Quickback](/stack/account-ui/with-quickback) for the recommended approach. This page is for standalone deployments where you need a separate Worker.
6
-
7
-
8
- # Worker Setup
9
-
10
- Deploy the Account UI as a Cloudflare Worker with static asset serving.
11
-
12
- ## Quick Start
13
-
14
- ### Using the Template
15
-
16
- ```bash
17
- npx degit Kardoe-com/quickback-better-auth-account-ui my-account-app
18
- cd my-account-app
19
- npm install
20
- ```
21
-
22
- ### Using the Library
23
-
24
- If you're consuming Account UI as an npm package, re-export the worker from the library:
25
-
26
- ```ts title="src/worker.ts"
27
- export { default } from 'quickback-better-auth-account-ui/worker';
28
- ```
29
-
30
- Then continue with the Wrangler configuration below.
31
-
32
- ### 2. Configure Wrangler
33
-
34
- The template includes a `wrangler.toml` pre-configured for Cloudflare Workers:
35
-
36
- ```toml title="wrangler.toml"
37
- name = "my-account-app"
38
- compatibility_date = "2025-01-01"
39
- compatibility_flags = ["nodejs_compat"]
40
-
41
- # Custom domain (uncomment and set your domain)
42
- # routes = [
43
- # { pattern = "account.example.com", custom_domain = true }
44
- # ]
45
-
46
- # Worker entry point
47
- main = "src/worker.ts"
48
-
49
- # Static assets
50
- [assets]
51
- binding = "ASSETS"
52
- directory = "dist/client"
53
- ```
54
-
55
- ### 3. Build and Deploy
56
-
57
- ```bash
58
- npm run build
59
- npx wrangler deploy
60
- ```
61
-
62
- ## Worker Entry Point
63
-
64
- The worker is at `src/worker.ts`. It serves static assets and handles SPA routing:
65
-
66
- - Static asset serving via the `ASSETS` binding
67
- - SPA routing (all routes serve `index.html`)
68
- - Health check endpoint (`/health`)
69
-
70
- ### Custom Worker Logic
71
-
72
- Edit `src/worker.ts` directly to add custom logic:
73
-
74
- ```ts title="src/worker.ts"
75
- export default {
76
- async fetch(request: Request, env: Env): Promise<Response> {
77
- const url = new URL(request.url);
78
-
79
- // Custom health check with more info
80
- if (url.pathname === '/health') {
81
- return new Response(JSON.stringify({
82
- status: 'ok',
83
- app: 'my-account-ui',
84
- version: '1.0.0',
85
- timestamp: new Date().toISOString(),
86
- }), {
87
- headers: { 'Content-Type': 'application/json' }
88
- });
89
- }
90
-
91
- // Custom analytics or logging
92
- console.log(`${request.method} ${url.pathname}`);
93
-
94
- // Try to serve static asset
95
- const assetResponse = await env.ASSETS.fetch(request);
96
-
97
- // If asset found, return it
98
- if (assetResponse.status !== 404) {
99
- return assetResponse;
100
- }
101
-
102
- // SPA routing: serve index.html for all other routes
103
- const indexRequest = new Request(`${url.origin}/index.html`, request);
104
- return env.ASSETS.fetch(indexRequest);
105
- },
106
- };
107
- ```
108
-
109
- ## Wrangler Configuration
110
-
111
- ### Environment Variables
112
-
113
- For production deployment, set environment variables in Cloudflare dashboard or via wrangler:
114
-
115
- ```toml title="wrangler.toml"
116
- [env.production]
117
- name = "my-account-app"
118
-
119
- [env.production.vars]
120
- # Catch-all: API + Account + CMS URLs all derive from this origin.
121
- VITE_QUICKBACK_URL = "https://secure.example.com"
122
- VITE_ACCOUNT_APP_URL = "https://account.example.com"
123
- VITE_APP_NAME = "My App"
124
- VITE_QUICKBACK_APP_URL = "https://app.example.com"
125
- ```
126
-
127
- > **Build-Time Variables**
128
- >
129
- > Vite environment variables (`VITE_*`) are baked into the build at build time. Changing them in `wrangler.toml` requires rebuilding. Use `.env.production` for production builds.
130
-
131
-
132
- ### Multiple Environments
133
-
134
- ```toml title="wrangler.toml"
135
- # Development
136
- [env.dev]
137
- name = "my-account-app-dev"
138
- route = "account-dev.example.com/*"
139
-
140
- [env.dev.vars]
141
- VITE_QUICKBACK_URL = "https://secure-dev.example.com"
142
- VITE_ACCOUNT_APP_URL = "https://account-dev.example.com"
143
-
144
- # Staging
145
- [env.staging]
146
- name = "my-account-app-staging"
147
- route = "account-staging.example.com/*"
148
-
149
- [env.staging.vars]
150
- VITE_QUICKBACK_URL = "https://secure-staging.example.com"
151
- VITE_ACCOUNT_APP_URL = "https://account-staging.example.com"
152
-
153
- # Production
154
- [env.production]
155
- name = "my-account-app"
156
- route = "account.example.com/*"
157
-
158
- [env.production.vars]
159
- VITE_QUICKBACK_URL = "https://secure.example.com"
160
- VITE_ACCOUNT_APP_URL = "https://account.example.com"
161
- ```
162
-
163
- Deploy to specific environment:
164
-
165
- ```bash
166
- wrangler deploy --env staging
167
- wrangler deploy --env production
168
- ```
169
-
170
- ## Cloudflare Pages Alternative
171
-
172
- You can also deploy to Cloudflare Pages instead of Workers:
173
-
174
- ### 1. Configure Build
175
-
176
- ```toml title="wrangler.toml"
177
- # Remove [assets] section - Pages handles this
178
-
179
- name = "my-account-app"
180
- pages_build_output_dir = "dist/client"
181
- ```
182
-
183
- ### 2. Deploy to Pages
184
-
185
- ```bash
186
- # First time setup
187
- wrangler pages project create my-account-app
188
-
189
- # Deploy
190
- wrangler pages deploy dist/client
191
- ```
192
-
193
- ### 3. Configure Environment Variables
194
-
195
- Set environment variables in Cloudflare Pages dashboard:
196
- 1. Go to your Pages project
197
- 2. **Settings** → **Environment Variables**
198
- 3. Add `VITE_*` variables
199
- 4. Redeploy
200
-
201
- > **Pages vs Workers**
202
- >
203
- > **Workers**: Better for custom server logic, middleware, edge compute
204
- > **Pages**: Simpler for static SPAs, automatic preview deployments, built-in analytics
205
-
206
-
207
- ## Local Development
208
-
209
- ### Option 1: Vite Dev Server
210
-
211
- The fastest way to develop locally:
212
-
213
- ```bash
214
- npx vite dev
215
- ```
216
-
217
- This starts the Vite dev server with hot module replacement on `localhost:5173`.
218
-
219
- ### Option 2: Wrangler Dev
220
-
221
- Test the worker locally with `wrangler dev`:
222
-
223
- ```bash
224
- npm run build && wrangler dev
225
- ```
226
-
227
- This runs the worker on `localhost:8787`.
228
-
229
- ## Health Check
230
-
231
- The worker includes a built-in health check endpoint:
232
-
233
- ```bash
234
- curl https://account.example.com/health
235
- ```
236
-
237
- Response:
238
-
239
- ```json
240
- {
241
- "status": "ok",
242
- "app": "auth-ui"
243
- }
244
- ```
245
-
246
- Use this for:
247
- - Uptime monitoring
248
- - Load balancer health checks
249
- - Deployment verification
250
-
251
- ## Security Headers
252
-
253
- Add security headers by editing `src/worker.ts`:
254
-
255
- ```ts title="src/worker.ts"
256
- export default {
257
- async fetch(request: Request, env: Env): Promise<Response> {
258
- // ... routing logic ...
259
-
260
- // Add security headers to response
261
- const response = await env.ASSETS.fetch(request);
262
-
263
- const headers = new Headers(response.headers);
264
- headers.set('X-Frame-Options', 'DENY');
265
- headers.set('X-Content-Type-Options', 'nosniff');
266
- headers.set('Referrer-Policy', 'strict-origin-when-cross-origin');
267
- headers.set('Permissions-Policy', 'geolocation=(), microphone=(), camera=()');
268
-
269
- return new Response(response.body, {
270
- status: response.status,
271
- statusText: response.statusText,
272
- headers,
273
- });
274
- },
275
- };
276
- ```
277
-
278
- ## Custom 404 Page
279
-
280
- Serve a custom 404 page for unmatched routes:
281
-
282
- ```ts title="src/worker.ts"
283
- export default {
284
- async fetch(request: Request, env: Env): Promise<Response> {
285
- const url = new URL(request.url);
286
-
287
- // Try to serve static asset
288
- const assetResponse = await env.ASSETS.fetch(request);
289
-
290
- if (assetResponse.status !== 404) {
291
- return assetResponse;
292
- }
293
-
294
- // Serve index.html for SPA routes
295
- if (!url.pathname.startsWith('/api/')) {
296
- const indexRequest = new Request(`${url.origin}/index.html`, request);
297
- return env.ASSETS.fetch(indexRequest);
298
- }
299
-
300
- // Custom 404 for API routes
301
- return new Response('Not Found', { status: 404 });
302
- },
303
- };
304
- ```
305
-
306
- ## Deployment Checklist
307
-
308
- Before deploying to production:
309
-
310
- - [ ] Set all required environment variables (`VITE_QUICKBACK_URL` or `VITE_QUICKBACK_API_URL`, etc.)
311
- - [ ] Configure custom domain in Cloudflare
312
- - [ ] Add SSL certificate (automatic with Cloudflare)
313
- - [ ] Test all authentication flows
314
- - [ ] Configure DNS records
315
- - [ ] Set up monitoring/health checks
316
- - [ ] Test email sending
317
- - [ ] Verify passkey functionality (requires HTTPS)
318
- - [ ] Check CORS configuration on API
319
- - [ ] Review security headers
320
- - [ ] Test organization invitations
321
- - [ ] Verify redirection to main app works
322
-
323
- ## Troubleshooting
324
-
325
- ### Assets Not Loading
326
-
327
- **Problem**: 404 errors for static assets (JS, CSS)
328
-
329
- **Solution**: Check `directory` path in `wrangler.toml`:
330
-
331
- ```toml
332
- [assets]
333
- binding = "ASSETS"
334
- directory = "dist/client" # Must point to Vite's client build output
335
- ```
336
-
337
- ### Environment Variables Not Working
338
-
339
- **Problem**: Config values are undefined
340
-
341
- **Solution**: Remember that `VITE_*` variables are build-time. Either:
342
- 1. Set them in `.env.production` before building
343
- 2. Use `setAppConfig()` in `src/main.tsx` for runtime overrides
344
- 3. Edit `src/config/app.ts` defaults directly
345
-
346
- ### SPA Routing Issues
347
-
348
- **Problem**: Refreshing on `/profile` returns 404
349
-
350
- **Solution**: Ensure your worker serves `index.html` for all non-asset routes:
351
-
352
- ```ts
353
- if (assetResponse.status === 404 && !url.pathname.startsWith('/api/')) {
354
- return env.ASSETS.fetch(new Request(`${url.origin}/index.html`, request));
355
- }
356
- ```
357
-
358
- ## Next Steps
359
-
360
- - **[Environment Variables](/stack/account-ui/environment-variables)** - Configure your deployment
361
- - **[Feature Flags](/stack/account-ui/features)** - Enable features
362
- - **[Customization](/stack/account-ui/customization)** - Brand your UI
@@ -1,55 +0,0 @@
1
- # Quickback for Supabase RLS
2
-
3
- **Quickback for Supabase RLS** compiles the same `defineTable()` definitions into PostgreSQL Row Level Security policies for Supabase. You keep Supabase Auth, Storage, and Realtime — Quickback adds the database-level security layer.
4
-
5
- ## Who this is for
6
-
7
- You're already on Supabase (or want to be) and you want:
8
-
9
- - **Database-level security** — RLS policies enforced even if a service role key leaks
10
- - **A type-safe DSL** — write security rules in TypeScript, compile to SQL
11
- - **One source of truth** — the same `firewall` and `access` config that powers a Quickback Hono API also generates RLS policies
12
-
13
- What you don't get from this target: generated API routes, batch endpoints, OpenAPI spec, MCP server. Those live with [Quickback for Hono API](/compiler/targets/hono-api). For Supabase you bring your own application code (PostgREST, Edge Functions, or your own server) and the RLS policies enforce security beneath it.
14
-
15
- ## What compiles to RLS
16
-
17
- | Definition | Compiles to |
18
- |------------|-------------|
19
- | `defineTable({ schema })` | `CREATE TABLE` + Drizzle schema |
20
- | `firewall: [...]` | `FOR ALL USING` policies (data isolation) |
21
- | `access.roles: [...]` | `FOR SELECT/INSERT/UPDATE/DELETE USING` policies (role checks) |
22
- | `defineActions()` | **Not compiled** — implement in Edge Functions or your app |
23
- | `views` | **Not compiled** — use Postgres views or column lists |
24
- | `masking` | **Not compiled** — runtime concern, handle in app code |
25
- | `guards` | **Not compiled** — runtime concern, handle in app code |
26
-
27
- See [Mappings](/compiler/targets/supabase-rls/mappings) for full examples and [Limitations](/compiler/targets/supabase-rls/limitations) for what to handle in app code.
28
-
29
- ## Quick start
30
-
31
- ```typescript title="quickback/quickback.config.ts"
32
- import { defineConfig, defineRuntime, defineDatabase, defineAuth } from "@quickback/compiler";
33
-
34
- export default defineConfig({
35
- name: "my-app",
36
- providers: {
37
- runtime: defineRuntime("supabase"),
38
- database: defineDatabase("supabase"),
39
- auth: defineAuth("supabase-auth"),
40
- },
41
- });
42
- ```
43
-
44
- ```bash
45
- quickback compile
46
- supabase db push
47
- ```
48
-
49
- The compiler emits RLS migrations under `supabase/migrations/`. See [Setup](/compiler/targets/supabase-rls/setup) for the full flow.
50
-
51
- ## In this section
52
-
53
- - **[Setup](/compiler/targets/supabase-rls/setup)** — Configure the target, compile, apply migrations
54
- - **[Mappings](/compiler/targets/supabase-rls/mappings)** — Which definitions become which RLS policies
55
- - **[Limitations](/compiler/targets/supabase-rls/limitations)** — What doesn't compile and how to handle it
@@ -1,48 +0,0 @@
1
- # Limitations
2
-
3
- The Supabase target compiles **schema, firewall, and access** to RLS. The other Quickback primitives are runtime concerns that RLS can't express. This page lists what doesn't compile and where to handle it.
4
-
5
- ## Actions
6
-
7
- `defineActions()` describes custom endpoints with input validation, role checks, and side effects. RLS only governs row access, not arbitrary procedures.
8
-
9
- **Where to handle them:**
10
-
11
- - **Supabase Edge Functions** — port the action body to a TypeScript Deno function. Role checks happen in the function; the underlying database mutations still pass through your RLS policies.
12
- - **Postgres functions** — for simple state transitions, write a `CREATE FUNCTION` and call it via `supabase.rpc()`. Use `SECURITY INVOKER` (the default) so RLS still applies.
13
- - **Your application server** — any backend you already run can host the action, with the JWT forwarded to Supabase for the underlying writes.
14
-
15
- ## Views
16
-
17
- Quickback `views` define column-level projections per role (e.g. "members see name + email; admins also see salary"). RLS gates rows, not columns.
18
-
19
- **Where to handle them:**
20
-
21
- - **Postgres views** — `CREATE VIEW` with `SELECT` lists matching each Quickback view. Apply RLS to the view or the underlying table.
22
- - **Column lists in queries** — pass the projection at the application layer: `supabase.from('users').select('id, name, email')`.
23
- - **Column-level grants** — `GRANT SELECT (col1, col2) ON table TO role` for fine-grained server-side restriction.
24
-
25
- ## Masking
26
-
27
- Masking redacts sensitive fields per role at response time (email → `j***@example.com`, SSN → `***-**-1234`). This is purely a runtime transformation — the data is in the row, RLS just decides whether the row is returned.
28
-
29
- **Where to handle it:**
30
-
31
- - **Edge Functions or your server** — apply the mask in the layer that serializes the response.
32
- - **Postgres functions** — for SQL-driven masking, write a wrapper view or function that applies the mask conditionally on `auth.jwt() ->> 'role'`.
33
-
34
- ## Guards
35
-
36
- `guards` block field modifications based on row state, role, or external context (e.g. "members can change `notes` but not `status`; only admins can set `archived`"). Some of this can be expressed with RLS `WITH CHECK`, but the full Quickback guard model is richer than RLS supports.
37
-
38
- **Where to handle them:**
39
-
40
- - **`WITH CHECK` clauses** — simple field-level guards (e.g. "only admins can set `archived = true`") can sometimes be expressed via more granular `FOR UPDATE` policies.
41
- - **Triggers** — `BEFORE UPDATE` triggers can `RAISE EXCEPTION` if a guarded field is modified by a non-eligible role.
42
- - **Edge Functions / app server** — for anything stateful or context-dependent, validate guards in the layer that issues the update.
43
-
44
- ## Generated API routes, batch ops, OpenAPI, MCP
45
-
46
- These are Hono-target features. The Supabase target doesn't generate application code — your app talks to Supabase directly (PostgREST, Edge Functions, or your own server).
47
-
48
- If you want generated routes alongside RLS, consider compiling to the [Hono target with Neon](/compiler/targets/hono-api/database/neon), which gives you both the generated API and database-level RLS.
@@ -1,99 +0,0 @@
1
- # Mappings
2
-
3
- This page shows how each Quickback primitive maps to RLS policy SQL. The same `firewall` and `access` config used by the [Hono target](/compiler/targets/hono-api) generates these policies — no Supabase-specific re-authoring required.
4
-
5
- ## Schema → Tables
6
-
7
- `defineTable({ schema })` compiles to a Drizzle PostgreSQL schema and a `CREATE TABLE` statement. RLS is enabled on the table by default:
8
-
9
- ```sql
10
- ALTER TABLE projects ENABLE ROW LEVEL SECURITY;
11
- ```
12
-
13
- ## Firewall → `FOR ALL USING`
14
-
15
- Firewall rules isolate data by tenant or owner. They become a single `FOR ALL USING` policy applied to every operation.
16
-
17
- **Org-scoped:**
18
-
19
- ```typescript
20
- firewall: [
21
- { field: 'organizationId', equals: 'ctx.activeOrgId' },
22
- ]
23
- ```
24
-
25
- ```sql
26
- CREATE POLICY "projects_firewall" ON projects FOR ALL
27
- USING (organization_id = public.get_active_org_id());
28
- ```
29
-
30
- **User-scoped:**
31
-
32
- ```typescript
33
- firewall: [
34
- { field: 'userId', equals: 'ctx.userId' },
35
- ]
36
- ```
37
-
38
- ```sql
39
- CREATE POLICY "preferences_firewall" ON preferences FOR ALL
40
- USING (user_id = auth.uid());
41
- ```
42
-
43
- ## Access → `FOR SELECT/INSERT/UPDATE/DELETE USING`
44
-
45
- Access rules layer role-based checks on top of the firewall. Each operation gets its own policy.
46
-
47
- ```typescript
48
- access: {
49
- roles: ['admin', 'member'],
50
- list: { roles: ['admin', 'member'] },
51
- create: { roles: ['admin'] },
52
- update: { roles: ['admin'] },
53
- delete: { roles: ['admin'] },
54
- }
55
- ```
56
-
57
- ```sql
58
- CREATE POLICY "projects_select" ON projects FOR SELECT
59
- USING (
60
- organization_id = public.get_active_org_id()
61
- AND public.has_any_role(ARRAY['admin', 'member'])
62
- );
63
-
64
- CREATE POLICY "projects_insert" ON projects FOR INSERT
65
- WITH CHECK (
66
- organization_id = public.get_active_org_id()
67
- AND public.has_any_role(ARRAY['admin'])
68
- );
69
- ```
70
-
71
- ## Defense in depth — anon deny
72
-
73
- Every generated table gets an explicit deny policy for the `anon` role:
74
-
75
- ```sql
76
- CREATE POLICY "projects_deny_anon" ON projects FOR ALL
77
- TO anon
78
- USING (false);
79
- ```
80
-
81
- Unauthenticated requests are blocked at the database level even if a policy elsewhere is misconfigured.
82
-
83
- ## Helper functions
84
-
85
- Quickback emits a set of helper functions in `0100_create_rls_helpers.sql` that the policies reference:
86
-
87
- | Function | Purpose |
88
- |----------|---------|
89
- | `get_active_org_id()` | Returns the user's active organization from `user_sessions` |
90
- | `has_any_role(roles[])` | Checks if the user has any of the listed roles in the active org |
91
- | `has_org_role(role)` | Checks for a single specific role |
92
- | `is_org_member()` | Checks org membership |
93
- | `get_user_role()` | Returns the user's role in the active org |
94
-
95
- These are used by the generated policies but you can also call them from views, triggers, or stored procedures.
96
-
97
- ## What does not compile
98
-
99
- `defineActions()`, `views`, `masking`, and runtime `guards` do **not** become RLS — see [Limitations](/compiler/targets/supabase-rls/limitations).
@@ -1,88 +0,0 @@
1
- # Setup
2
-
3
- ## Prerequisites
4
-
5
- - A Supabase project (free tier is fine for development)
6
- - The Supabase CLI installed: `npm install -g supabase`
7
- - A Quickback project (`quickback create` or existing)
8
-
9
- ## 1. Configure the target
10
-
11
- ```typescript title="quickback/quickback.config.ts"
12
- import { defineConfig, defineRuntime, defineDatabase, defineAuth } from "@quickback/compiler";
13
-
14
- export default defineConfig({
15
- name: "my-app",
16
- providers: {
17
- runtime: defineRuntime("supabase"),
18
- database: defineDatabase("supabase"),
19
- auth: defineAuth("supabase-auth"),
20
- },
21
- });
22
- ```
23
-
24
- The `supabase-auth` provider tells Quickback to emit RLS policies that reference `auth.uid()` — Supabase's built-in JWT claim function — rather than the Better Auth equivalents used by the Neon target.
25
-
26
- ## 2. Compile
27
-
28
- ```bash
29
- quickback compile
30
- ```
31
-
32
- This generates:
33
-
34
- ```
35
- supabase/
36
- ├── migrations/
37
- │ ├── 0100_create_rls_helpers.sql # get_active_org_id(), has_any_role(), etc.
38
- │ ├── 0101_create_rls_policies.sql # Per-table SELECT/INSERT/UPDATE/DELETE policies
39
- │ └── 0102_create_audit_triggers.sql # Optional audit logging
40
- src/
41
- ├── db/
42
- │ └── schema.ts # Drizzle schema (typed access from your app)
43
- ```
44
-
45
- ## 3. Apply migrations
46
-
47
- ```bash
48
- supabase db push
49
- ```
50
-
51
- Supabase applies the migrations to your remote project. RLS is enabled on every generated table and the deny-anon policy is installed.
52
-
53
- ## 4. Use from your app
54
-
55
- Quickback for Supabase doesn't generate API routes. Your application code (PostgREST, Edge Functions, your own server) talks to Supabase as normal — the RLS policies are enforced beneath it.
56
-
57
- ```typescript
58
- import { createClient } from '@supabase/supabase-js';
59
-
60
- const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
61
- global: { headers: { Authorization: `Bearer ${userJwt}` } },
62
- });
63
-
64
- // RLS policies generated by Quickback enforce row-level access
65
- const { data } = await supabase.from('projects').select('*');
66
- ```
67
-
68
- ## Updating the schema
69
-
70
- Edit your `defineTable()` files, recompile, and push:
71
-
72
- ```bash
73
- quickback compile
74
- supabase db push
75
- ```
76
-
77
- The compiler diffs against the previous compilation and emits a new migration only for what changed.
78
-
79
- ## Comparison with the Neon target
80
-
81
- | | Supabase | Neon |
82
- |---|----------|------|
83
- | Auth function | `auth.uid()` | `auth.user_id()` |
84
- | Auth provider | Supabase Auth | Better Auth + Neon Authorize |
85
- | Users table | `auth.users` | `public.users` |
86
- | API code generated | No | Yes (Hono routes) |
87
-
88
- Both targets emit RLS policies. The difference is who issues the JWTs and where the application logic lives.