Metadata-Version: 2.4
Name: supabase-user-delete-tui
Version: 0.1.0
Summary: A terminal UI for deleting user data from Supabase
Home-page: https://github.com/Navi-th/user-delete-tui
Author: Navi-th
Author-email: Navi <navi@rareminds.in>
License: MIT
Project-URL: Homepage, https://github.com/Navi-th/user-delete-tui
Project-URL: Repository, https://github.com/Navi-th/user-delete-tui
Project-URL: Issues, https://github.com/Navi-th/user-delete-tui/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: User Interfaces
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: textual==0.59.0
Requires-Dist: supabase==2.12.0
Requires-Dist: python-dotenv==1.0.0
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# Supabase User Delete TUI

A terminal UI for deleting user data from Supabase — runs in any terminal
on **Mac** and **Windows PowerShell**.

Built with Python + [Textual](https://textual.textualize.io/).

---

## Installation

### Install from PyPI (when published)

```bash
pip install supabase-user-delete-tui
```

### Install from source

```bash
# Clone the repository
git clone https://github.com/Navi-th/user-delete-tui.git
cd user-delete-tui

# Install in development mode
pip install -e .
```

### Quick Start

After installation, you can run the tool using:

```bash
supabase-user-delete
```

Or if installed locally:

```bash
python -m src.app
```

---

## Configuration

Before using the tool, you need to set up your Supabase credentials:

1. Create a `.env` file in your working directory (or copy from `.env.example`)
2. Add your Supabase credentials:

```env
SUPABASE_URL=your_project_url
SUPABASE_SERVICE_KEY=your_service_role_key
```

### Getting your Supabase credentials

1. Go to https://supabase.com/dashboard
2. Open your project → **Settings** → **API**
3. Copy **Project URL** → `SUPABASE_URL`
4. Copy **service_role** key (not anon!) → `SUPABASE_SERVICE_KEY`

---

## Project structure

```
user-delete-tui/
├── main.py              ← entry point
├── requirements.txt
├── .env.example         ← copy to .env and fill in credentials
├── .gitignore
├── src/
│   ├── app.py           ← Textual TUI app
│   ├── db.py            ← all Supabase queries
│   ├── audit.py         ← audit log writer
│   └── modals.py        ← confirm + mode picker dialogs
└── tests/
    └── test_db.py       ← unit tests
```

---

## Development Setup

If you want to contribute or modify the tool:

### Mac

```bash
# 1. Clone / open in Kiro
cd user-delete-tui

# 2. Create virtual environment
python3 -m venv .venv
source .venv/bin/activate

# 3. Install dependencies
pip install -r requirements.txt

# 4. Add credentials
cp .env.example .env
# open .env and fill in SUPABASE_URL and SUPABASE_SERVICE_KEY

# 5. Run
python main.py
```

### Windows (PowerShell)

```powershell
# 1. Open PowerShell in the project folder

# 2. Create virtual environment
python -m venv .venv
.venv\Scripts\Activate.ps1

# 3. Install dependencies
pip install -r requirements.txt

# 4. Add credentials
Copy-Item .env.example .env
# open .env in notepad and fill in credentials

# 5. Run
python main.py
```

> **Windows note:** if you see `cannot be loaded because running scripts is disabled`,
> run this once: `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned`

---

## Getting your Supabase credentials

1. Go to https://supabase.com/dashboard
2. Open your project → **Settings** → **API**
3. Copy **Project URL** → `SUPABASE_URL`
4. Copy **service_role** key (not anon!) → `SUPABASE_SERVICE_KEY`

---

## Usage

| Key       | Action                              |
|-----------|-------------------------------------|
| `f`       | Fetch all tables for a user_id      |
| `m`       | Open mode picker                    |
| `d`       | Delete (respects current mode)      |
| `a`       | Select all rows in current table    |
| `Escape`  | Clear current selection             |
| `Enter`   | Select/deselect a row in the table  |
| `Ctrl+C`  | Quit                                |

### Selection modes

| Mode         | Behaviour                                         |
|--------------|---------------------------------------------------|
| Multi-select | Toggle individual rows on/off, any number         |
| Single-select| Only one row selected at a time                   |
| Whole table  | Deletes every row in the table for that user      |

---

## Audit log

Every delete writes a JSON line to `audit.log`:

```json
{
  "ts": "2026-06-03T10:22:01.123456",
  "kind": "rows",
  "table": "results",
  "user_id": "1234",
  "deleted_ids": ["10", "20"],
  "count": 2
}
```

---

## Run tests

```bash
pip install pytest
pytest tests/
```

---

## Adding a new table

Open `src/db.py` and add your table + its user FK column to `TABLE_USER_COL`:

```python
TABLE_USER_COL = {
    "your_table": "user_id",   # ← add here
    ...
}
```

That's it — it will appear automatically in the sidebar on next fetch.
