|
1 | | -# RLS Testing |
| 1 | +# Supabase Test |
2 | 2 |
|
3 | | -``` |
| 3 | +<p align="center" width="100%"> |
| 4 | + <img height="250" src="https://raw.githubusercontent.com/launchql/supabase-test/refs/heads/main/docs/img/logos.svg" /> |
| 5 | +</p> |
| 6 | + |
| 7 | +<p align="center" width="100%"> |
| 8 | + <a href="https://github.com/launchql/supabase-test/actions/workflows/ci.yml"> |
| 9 | + <img height="20" src="https://github.com/launchql/supabase-test/actions/workflows/ci.yml/badge.svg" /> |
| 10 | + </a> |
| 11 | + <a href="https://github.com/launchql/supabase-test/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a> |
| 12 | +</p> |
| 13 | + |
| 14 | + |
| 15 | +A friendly playground for building and validating Supabase Row‑Level Security (RLS) using LaunchQL. It includes real‑world examples, migrations, and a comprehensive test suite you can run locally. |
| 16 | + |
| 17 | +## Features |
| 18 | + |
| 19 | +- Policy‑driven examples for users, products, storage, realtime, and functions |
| 20 | +- Supabase CLI local stack for zero‑setup Postgres |
| 21 | +- Jest‑based tests that exercise RLS behavior end‑to‑end |
| 22 | +- Modular schema packages you can reuse and extend |
| 23 | + |
| 24 | +## Quick start (tl;dr) |
| 25 | + |
| 26 | +```bash |
| 27 | +# bring up a local supabase stack |
4 | 28 | npx supabase init |
5 | 29 | npx supabase start |
6 | | -``` |
7 | 30 |
|
8 | | -``` |
| 31 | +# install deps and run all package tests |
9 | 32 | pnpm install |
10 | | -cd packages/base32 |
| 33 | + |
| 34 | +# if your env needs explicit pg vars, export these: |
11 | 35 | export PGPORT=54322 |
12 | 36 | export PGHOST=localhost |
13 | 37 | export PGUSER=postgres |
14 | 38 | export PGPASSWORD=postgres |
15 | 39 |
|
| 40 | +# run every package’s tests |
| 41 | +pnpm test |
| 42 | +``` |
| 43 | + |
| 44 | +## getting started (step by step) |
| 45 | + |
| 46 | +this section will walk through everything slowly, from installing tools to running focused tests and exploring the schemas. |
| 47 | + |
| 48 | +- [ ] step 1: install prerequisites (node, pnpm, supabase cli) |
| 49 | +- [ ] step 2: initialize supabase and confirm services are healthy |
| 50 | +- [ ] step 3: configure pg env vars if your shell needs them |
| 51 | +- [ ] step 4: run migrations or package deploys as needed |
| 52 | +- [ ] step 5: run tests (full suite and targeted) |
| 53 | +- [ ] step 6: inspect policies and iterate |
| 54 | + |
| 55 | +for the expanded guide with screenshots and copy‑paste commands, see `docs/img/USAGE.md` (coming soon). |
| 56 | + |
| 57 | +## repository layout |
| 58 | + |
| 59 | +- `packages/supabase`: supabase‑focused sql, tests, and helpers |
| 60 | +- `packages/rls-demo`: demo extension showcasing rls with users/products |
| 61 | + |
| 62 | +## scripts you’ll use often |
| 63 | + |
| 64 | +```bash |
| 65 | +# run the whole workspace test suite |
16 | 66 | pnpm test |
17 | 67 | ``` |
18 | 68 |
|
| 69 | +## Adding a package using `lql` |
| 70 | + |
| 71 | +## Requirements |
| 72 | + |
| 73 | +- Node.js 20+ |
| 74 | +- pnpm 10+ |
| 75 | +- Supabase CLI 2+ |
| 76 | + |
| 77 | +## troubleshooting |
| 78 | + |
| 79 | +- if `pnpm test` can’t reach postgres, confirm supabase services are running and the `PG*` env vars match the port printed by `npx supabase start` |
| 80 | +- if ports are busy, stop old containers or pass a different port to supabase |
| 81 | +- node version mismatches can cause odd errors; use node 20+ |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | +## Related LaunchQL Tooling |
| 87 | + |
| 88 | +### 🧪 Testing |
| 89 | + |
| 90 | +* [launchql/pgsql-test](https://github.com/launchql/launchql/tree/main/packages/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation. |
| 91 | +* [launchql/graphile-test](https://github.com/launchql/launchql/tree/main/packages/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts. |
| 92 | +* [launchql/pg-query-context](https://github.com/launchql/launchql/tree/main/packages/pg-query-context): **🔒 Session context injection** to add session-local context (e.g., `SET LOCAL`) into queries—ideal for setting `role`, `jwt.claims`, and other session settings. |
| 93 | + |
| 94 | +### 🧠 Parsing & AST |
| 95 | + |
| 96 | +* [launchql/pgsql-parser](https://github.com/launchql/pgsql-parser): **🔄 SQL conversion engine** that interprets and converts PostgreSQL syntax. |
| 97 | +* [launchql/libpg-query-node](https://github.com/launchql/libpg-query-node): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees. |
| 98 | +* [launchql/pg-proto-parser](https://github.com/launchql/pg-proto-parser): **📦 Protobuf parser** for parsing PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums. |
| 99 | +* [@pgsql/enums](https://github.com/launchql/pgsql-parser/tree/main/packages/enums): **🏷️ TypeScript enums** for PostgreSQL AST for safe and ergonomic parsing logic. |
| 100 | +* [@pgsql/types](https://github.com/launchql/pgsql-parser/tree/main/packages/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript. |
| 101 | +* [@pgsql/utils](https://github.com/launchql/pgsql-parser/tree/main/packages/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees. |
| 102 | +* [launchql/pg-ast](https://github.com/launchql/launchql/tree/main/packages/pg-ast): **🔍 Low-level AST tools** and transformations for Postgres query structures. |
| 103 | + |
| 104 | +### 🚀 API & Dev Tools |
| 105 | + |
| 106 | +* [launchql/server](https://github.com/launchql/launchql/tree/main/packages/server): **⚡ Express-based API server** powered by PostGraphile to expose a secure, scalable GraphQL API over your Postgres database. |
| 107 | +* [launchql/explorer](https://github.com/launchql/launchql/tree/main/packages/explorer): **🔎 Visual API explorer** with GraphiQL for browsing across all databases and schemas—useful for debugging, documentation, and API prototyping. |
| 108 | + |
| 109 | +### 🔁 Streaming & Uploads |
| 110 | + |
| 111 | +* [launchql/s3-streamer](https://github.com/launchql/launchql/tree/main/packages/s3-streamer): **📤 Direct S3 streaming** for large files with support for metadata injection and content validation. |
| 112 | +* [launchql/etag-hash](https://github.com/launchql/launchql/tree/main/packages/etag-hash): **🏷️ S3-compatible ETags** created by streaming and hashing file uploads in chunks. |
| 113 | +* [launchql/etag-stream](https://github.com/launchql/launchql/tree/main/packages/etag-stream): **🔄 ETag computation** via Node stream transformer during upload or transfer. |
| 114 | +* [launchql/uuid-hash](https://github.com/launchql/launchql/tree/main/packages/uuid-hash): **🆔 Deterministic UUIDs** generated from hashed content, great for deduplication and asset referencing. |
| 115 | +* [launchql/uuid-stream](https://github.com/launchql/launchql/tree/main/packages/uuid-stream): **🌊 Streaming UUID generation** based on piped file content—ideal for upload pipelines. |
| 116 | +* [launchql/upload-names](https://github.com/launchql/launchql/tree/main/packages/upload-names): **📂 Collision-resistant filenames** utility for structured and unique file names for uploads. |
| 117 | + |
| 118 | +### 🧰 CLI & Codegen |
| 119 | + |
| 120 | +* [@launchql/cli](https://github.com/launchql/launchql/tree/main/packages/cli): **🖥️ Command-line toolkit** for managing LaunchQL projects—supports database scaffolding, migrations, seeding, code generation, and automation. |
| 121 | +* [launchql/launchql-gen](https://github.com/launchql/launchql/tree/main/packages/launchql-gen): **✨ Auto-generated GraphQL** mutations and queries dynamically built from introspected schema data. |
| 122 | +* [@launchql/query-builder](https://github.com/launchql/launchql/tree/main/packages/query-builder): **🏗️ SQL constructor** providing a robust TypeScript-based query builder for dynamic generation of `SELECT`, `INSERT`, `UPDATE`, `DELETE`, and stored procedure calls—supports advanced SQL features like `JOIN`, `GROUP BY`, and schema-qualified queries. |
| 123 | +* [@launchql/query](https://github.com/launchql/launchql/tree/main/packages/query): **🧩 Fluent GraphQL builder** for PostGraphile schemas. ⚡ Schema-aware via introspection, 🧩 composable and ergonomic for building deeply nested queries. |
| 124 | + |
| 125 | +## Disclaimer |
| 126 | + |
| 127 | +AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. |
| 128 | + |
| 129 | +No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value. |
0 commit comments