From 6e4041338543bc349bce3e517d6391043d5916aa Mon Sep 17 00:00:00 2001 From: josh Date: Sat, 28 Mar 2026 02:35:00 -0400 Subject: [PATCH] claude went crazy --- .claude/settings.local.json | 3 +- .dockerignore | 2 + .gitea/workflows/build.yml | 2 +- .gitignore | 3 + Dockerfile | 16 +- README.md | 278 ++++--- data/.gitkeep | 0 docker-compose.yml | 9 +- js/app.js | 6 +- js/config.js | 19 +- js/db.js | 182 +---- js/ui.js | 70 +- nginx.conf | 19 - package-lock.json | 1472 +++++++++++++++++++++++++++++------ package.json | 12 +- server/db.js | 137 ++++ server/routes.js | 114 +++ server/server.js | 33 + tests/api.test.js | 239 ++++++ tests/db.test.js | 335 +++----- tests/helpers.test.js | 1 + vitest.config.js | 2 +- 22 files changed, 2167 insertions(+), 787 deletions(-) create mode 100644 data/.gitkeep delete mode 100644 nginx.conf create mode 100644 server/db.js create mode 100644 server/routes.js create mode 100644 server/server.js create mode 100644 tests/api.test.js diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 51caf60..59a95d5 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -1,7 +1,8 @@ { "permissions": { "allow": [ - "Bash(npm test:*)" + "Bash(npm test:*)", + "Bash(npm install:*)" ] } } diff --git a/.dockerignore b/.dockerignore index aff0042..2f9e3f5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,8 +1,10 @@ .git .gitea +.gitignore Dockerfile .dockerignore docker-compose.yml node_modules tests vitest.config.js +data diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 26192a8..5f168e1 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -20,7 +20,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v4 with: - node-version: lts/* + node-version: 'lts/*' cache: npm - name: Install dependencies diff --git a/.gitignore b/.gitignore index 0045a54..95f06bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ node_modules/ js/version.js +data/*.db +data/*.db-shm +data/*.db-wal diff --git a/Dockerfile b/Dockerfile index 1febd11..77fa638 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,12 @@ -FROM nginx:alpine -COPY nginx.conf /etc/nginx/conf.d/default.conf -COPY . /usr/share/nginx/html +FROM node:lts-alpine +WORKDIR /app + +COPY package*.json ./ +RUN npm ci --omit=dev + +COPY . . RUN awk -F'"' '/"version"/{printf "const VERSION = \"%s\";\n", $4; exit}' \ - /usr/share/nginx/html/package.json \ - > /usr/share/nginx/html/js/version.js + package.json > js/version.js + +EXPOSE 3000 +CMD ["node", "server/server.js"] diff --git a/README.md b/README.md index f394719..d012e11 100644 --- a/README.md +++ b/README.md @@ -1,134 +1,198 @@ # Catalyst -A lightweight instance registry for tracking self-hosted infrastructure. No backend, no framework — just a browser, a SQLite database compiled to WebAssembly, and a static file server. :) - -## Structure - -``` -index.html Entry point -css/app.css Styles -js/ - config.js Service definitions and seed data - db.js Data layer - ui.js Rendering, modals, notifications - app.js Router -``` - -## Data layer - -All reads and writes go through five functions in `js/db.js`. This is the boundary that would be replaced when wiring Catalyst to a real backend — nothing else in the codebase touches data directly. - -### `getInstances(filters?)` - -Returns an array of instances, sorted by name. All filters are optional. - -```js -getInstances() -getInstances({ search: 'plex' }) -getInstances({ state: 'degraded' }) -getInstances({ stack: 'production' }) -getInstances({ search: 'home', state: 'deployed', stack: 'production' }) -``` - -`search` matches against `name`, `vmid`, and `stack`. - -### `getInstance(vmid)` - -Returns a single instance by VMID, or `null` if not found. - -```js -getInstance(137) // → { id, name, vmid, state, stack, ...services, createdAt, updatedAt } -``` - -### `getDistinctStacks()` - -Returns a sorted array of unique stack names present in the registry. Used to populate the stack filter dynamically. - -```js -getDistinctStacks() // → ['development', 'production'] -``` - -### `createInstance(data)` - -Inserts a new instance. Returns `{ ok: true }` on success or `{ ok: false, error }` on failure (e.g. duplicate VMID). - -```js -createInstance({ - name: 'plex', - vmid: 117, - state: 'deployed', // 'deployed' | 'testing' | 'degraded' - stack: 'production', - tailscale_ip: '100.64.0.1', - atlas: 1, - argus: 1, - semaphore: 0, - patchmon: 1, - tailscale: 1, - andromeda: 0, - hardware_acceleration: 1, -}) -``` - -### `updateInstance(id, data)` - -Updates an existing instance by internal `id`. Accepts the same shape as `createInstance`. Returns `{ ok: true }` or `{ ok: false, error }`. - -### `deleteInstance(id)` - -Deletes an instance by internal `id`. Only instances on the `development` stack can be deleted — this is enforced in the UI before `deleteInstance` is ever called. +A self-hosted infrastructure registry. Track every VM, container, and service across your homelab — their state, stack, and which internal services are running on them. --- -## Instance shape +## Features -| Field | Type | Notes | -|---|---|---| -| `id` | integer | Internal autoincrement ID | -| `vmid` | integer | Unique. Used as the public identifier and in URLs (`/instance/137`) | -| `name` | string | Display name | -| `state` | string | `deployed`, `testing`, or `degraded` | -| `stack` | string | `production` or `development` | -| `tailscale_ip` | string | Optional | -| `atlas` | 0 \| 1 | | -| `argus` | 0 \| 1 | | -| `semaphore` | 0 \| 1 | | -| `patchmon` | 0 \| 1 | | -| `tailscale` | 0 \| 1 | | -| `andromeda` | 0 \| 1 | | -| `hardware_acceleration` | 0 \| 1 | | -| `createdAt` | ISO string | Set on insert | -| `updatedAt` | ISO string | Updated on every write | +- **Dashboard** — filterable, searchable instance list with state and stack badges +- **Detail pages** — per-instance view with service flags, Tailscale IP, and timestamps +- **Full CRUD** — add, edit, and delete instances via a clean modal interface +- **Production safeguard** — only development instances can be deleted; production instances must be demoted first +- **REST API** — every operation is a plain HTTP call; no magic, no framework lock-in +- **Persistent storage** — SQLite database on a Docker named volume; survives restarts and upgrades +- **Zero native dependencies** — SQLite via Node's built-in `node:sqlite`. No compilation, no binaries. + +--- + +## Quick start + +```bash +docker run -d \ + --name catalyst \ + -p 3000:3000 \ + -v catalyst-data:/app/data \ + gitea.thewrightserver.net/josh/catalyst:latest +``` + +Or with the included Compose file: + +```bash +docker compose up -d +``` + +Open [http://localhost:3000](http://localhost:3000). + +--- + +## REST API + +All endpoints are under `/api`. Request and response bodies are JSON. + +### Instances + +#### `GET /api/instances` + +Returns all instances, sorted by name. All query parameters are optional. + +| Parameter | Type | Description | +|-----------|--------|-----------------------------------------| +| `search` | string | Partial match on `name` or `vmid` | +| `state` | string | Exact match: `deployed`, `testing`, `degraded` | +| `stack` | string | Exact match: `production`, `development` | + +``` +GET /api/instances?search=plex&state=deployed +``` + +```json +[ + { + "vmid": 117, + "name": "plex", + "state": "deployed", + "stack": "production", + "tailscale_ip": "100.64.0.1", + "atlas": 1, "argus": 0, "semaphore": 0, + "patchmon": 1, "tailscale": 1, "andromeda": 0, + "hardware_acceleration": 1, + "created_at": "2024-01-15T10:30:00.000Z", + "updated_at": "2024-03-10T14:22:00.000Z" + } +] +``` + +--- + +#### `GET /api/instances/stacks` + +Returns a sorted array of distinct stack names present in the registry. + +``` +GET /api/instances/stacks +→ ["development", "production"] +``` + +--- + +#### `GET /api/instances/:vmid` + +Returns a single instance by VMID. + +| Status | Condition | +|--------|-----------| +| `200` | Instance found | +| `404` | No instance with that VMID | +| `400` | VMID is not a valid integer | + +--- + +#### `POST /api/instances` + +Creates a new instance. Returns the created record. + +| Status | Condition | +|--------|-----------| +| `201` | Created successfully | +| `400` | Validation error (see `errors` array in response) | +| `409` | VMID already exists | + +**Request body:** + +| Field | Type | Required | Notes | +|-------|------|----------|-------| +| `name` | string | yes | | +| `vmid` | integer | yes | Must be > 0, unique | +| `state` | string | yes | `deployed`, `testing`, or `degraded` | +| `stack` | string | yes | `production` or `development` | +| `tailscale_ip` | string | no | Defaults to `""` | +| `atlas` | 0\|1 | no | Defaults to `0` | +| `argus` | 0\|1 | no | | +| `semaphore` | 0\|1 | no | | +| `patchmon` | 0\|1 | no | | +| `tailscale` | 0\|1 | no | | +| `andromeda` | 0\|1 | no | | +| `hardware_acceleration` | 0\|1 | no | | + +--- + +#### `PUT /api/instances/:vmid` + +Replaces all fields on an existing instance. Accepts the same body shape as `POST`. The `vmid` in the body may differ from the URL — this is how you change a VMID. + +| Status | Condition | +|--------|-----------| +| `200` | Updated successfully | +| `400` | Validation error | +| `404` | No instance with that VMID | +| `409` | New VMID conflicts with an existing instance | + +--- + +#### `DELETE /api/instances/:vmid` + +Deletes an instance. Only instances on the `development` stack may be deleted. + +| Status | Condition | +|--------|-----------| +| `204` | Deleted successfully | +| `404` | No instance with that VMID | +| `422` | Instance is on the `production` stack | +| `400` | VMID is not a valid integer | + +--- + +## Development + +```bash +npm install +npm test # run all tests once +npm run test:watch # watch mode +npm start # start the server on :3000 +``` + +Tests are split across three files: + +| File | What it covers | +|------|----------------| +| `tests/db.test.js` | SQLite data layer — all CRUD operations, constraints, filters | +| `tests/api.test.js` | HTTP API — all endpoints, status codes, error cases | +| `tests/helpers.test.js` | UI helper functions — `esc()` XSS contract, `fmtDate()` | --- ## Versioning -Catalyst uses [semantic versioning](https://semver.org). The version in `package.json` is the source of truth and must match the release tag. +Catalyst uses [semantic versioning](https://semver.org). `package.json` is the single source of truth for the version number. | Change | Bump | Example | -|---|---|---| +|--------|------|---------| | Bug fix | patch | `1.0.0` → `1.0.1` | | New feature, backward compatible | minor | `1.0.0` → `1.1.0` | | Breaking change | major | `1.0.0` → `2.0.0` | ### Cutting a release -**1. Bump the version in `package.json`** -```json -"version": "1.1.0" -``` - -**2. Commit, tag, and push** ```bash +# 1. Bump version in package.json, then: git add package.json git commit -m "chore: release v1.1.0" git tag v1.1.0 git push && git push --tags ``` -Pushing the tag triggers the full pipeline: tests → build → release. +Pushing a tag triggers the full CI pipeline: **test → build → release**. -- The image is tagged `:1.1.0`, `:1.1`, and `:latest` in the Gitea registry -- A Gitea release is created at `v1.1.0` with the image reference in the release notes - -Pushes to `main` without a tag still run tests and build a `:latest` image — no release is created. +- Docker image tagged `:1.1.0`, `:1.1`, and `:latest` in the Gitea registry +- A Gitea release is created at `v1.1.0` diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml b/docker-compose.yml index 5a77f8c..5bd38d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,4 +3,11 @@ services: image: ${REGISTRY:-gitea.thewrightserver.net/josh}/catalyst:${TAG:-latest} restart: unless-stopped ports: - - "${PORT:-3000}:80" + - "${PORT:-3000}:3000" + volumes: + - catalyst-data:/app/data + environment: + - NODE_ENV=production + +volumes: + catalyst-data: diff --git a/js/app.js b/js/app.js index 288d202..72cc2b0 100644 --- a/js/app.js +++ b/js/app.js @@ -21,6 +21,7 @@ function handleRoute() { renderDetailPage(parseInt(m[1], 10)); } else { document.getElementById('page-dashboard').classList.add('active'); + renderDashboard(); } } @@ -39,7 +40,4 @@ window.addEventListener('popstate', e => { if (VERSION) document.getElementById('nav-version').textContent = `v${VERSION}`; -initDB().then(() => { - renderDashboard(); - handleRoute(); -}); +handleRoute(); diff --git a/js/config.js b/js/config.js index 50c26da..90d1acd 100644 --- a/js/config.js +++ b/js/config.js @@ -1,21 +1,6 @@ -// Services shown as dots on instance cards (all tracked services) +// Services shown as dots on instance cards const CARD_SERVICES = ['atlas', 'argus', 'semaphore', 'patchmon', 'tailscale', 'andromeda']; // Services shown in the detail page service grid -// (tailscale is shown separately under "network" alongside its IP) +// (tailscale lives in the network section alongside its IP) const DETAIL_SERVICES = ['atlas', 'argus', 'semaphore', 'patchmon', 'andromeda']; - -const SQL_JS_CDN = 'https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.10.2/'; - -const STORAGE_KEY = 'catalyst_db'; - -const SEED = [ - { name: 'plex', state: 'deployed', stack: 'production', vmid: 117, atlas: true, argus: true, semaphore: false, patchmon: true, tailscale: true, andromeda: false, tailscale_ip: '100.64.0.1', hardware_acceleration: true }, - { name: 'foldergram', state: 'testing', stack: 'development', vmid: 137, atlas: false, argus: false, semaphore: false, patchmon: false, tailscale: false, andromeda: false, tailscale_ip: '', hardware_acceleration: false }, - { name: 'homeassistant', state: 'deployed', stack: 'production', vmid: 102, atlas: true, argus: true, semaphore: true, patchmon: true, tailscale: true, andromeda: false, tailscale_ip: '100.64.0.5', hardware_acceleration: false }, - { name: 'gitea', state: 'deployed', stack: 'production', vmid: 110, atlas: true, argus: false, semaphore: true, patchmon: true, tailscale: true, andromeda: false, tailscale_ip: '100.64.0.8', hardware_acceleration: false }, - { name: 'postgres-primary', state: 'degraded', stack: 'production', vmid: 201, atlas: true, argus: true, semaphore: false, patchmon: true, tailscale: false, andromeda: true, tailscale_ip: '', hardware_acceleration: false }, - { name: 'nextcloud', state: 'testing', stack: 'development', vmid: 144, atlas: false, argus: false, semaphore: false, patchmon: false, tailscale: true, andromeda: false, tailscale_ip: '100.64.0.12', hardware_acceleration: false }, - { name: 'traefik', state: 'deployed', stack: 'production', vmid: 100, atlas: true, argus: true, semaphore: false, patchmon: true, tailscale: true, andromeda: false, tailscale_ip: '100.64.0.2', hardware_acceleration: false }, - { name: 'monitoring-stack', state: 'testing', stack: 'development', vmid: 155, atlas: false, argus: false, semaphore: true, patchmon: false, tailscale: false, andromeda: false, tailscale_ip: '', hardware_acceleration: false }, -]; diff --git a/js/db.js b/js/db.js index 4864f99..e3c69b3 100644 --- a/js/db.js +++ b/js/db.js @@ -1,159 +1,57 @@ -let db = null; +// API client — replaces the sql.js database layer. +// Swap these fetch() calls for any other transport when needed. -// ── Persistence ────────────────────────────────────────────────────────────── +const BASE = '/api'; -function saveToStorage() { - try { - const data = db.export(); // Uint8Array - let binary = ''; - const chunk = 8192; - for (let i = 0; i < data.length; i += chunk) { - binary += String.fromCharCode(...data.subarray(i, i + chunk)); - } - localStorage.setItem(STORAGE_KEY, btoa(binary)); - } catch (e) { - console.warn('catalyst: failed to persist database', e); - } +async function api(path, options = {}) { + const res = await fetch(BASE + path, options); + if (res.status === 204) return null; + return res.json().then(data => ({ ok: res.ok, status: res.status, data })); } -function loadFromStorage() { - try { - const stored = localStorage.getItem(STORAGE_KEY); - if (!stored) return null; - const binary = atob(stored); - const buf = new Uint8Array(binary.length); - for (let i = 0; i < binary.length; i++) buf[i] = binary.charCodeAt(i); - return buf; - } catch (e) { - console.warn('catalyst: failed to load database from storage', e); - return null; - } +// ── Queries ─────────────────────────────────────────────────────────────────── + +async function getInstances(filters = {}) { + const params = new URLSearchParams( + Object.entries(filters).filter(([, v]) => v) + ); + const res = await fetch(`${BASE}/instances?${params}`); + return res.json(); } -// ── Init ───────────────────────────────────────────────────────────────────── - -async function initDB() { - const SQL = await initSqlJs({ locateFile: f => SQL_JS_CDN + f }); - - const saved = loadFromStorage(); - if (saved) { - db = new SQL.Database(saved); - return; - } - - db = new SQL.Database(); - db.run(` - CREATE TABLE instances ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT NOT NULL, - state TEXT DEFAULT 'deployed', - stack TEXT DEFAULT '', - vmid INTEGER UNIQUE NOT NULL, - atlas INTEGER DEFAULT 0, - argus INTEGER DEFAULT 0, - semaphore INTEGER DEFAULT 0, - patchmon INTEGER DEFAULT 0, - tailscale INTEGER DEFAULT 0, - andromeda INTEGER DEFAULT 0, - tailscale_ip TEXT DEFAULT '', - hardware_acceleration INTEGER DEFAULT 0, - createdAt TEXT DEFAULT (datetime('now')), - updatedAt TEXT DEFAULT (datetime('now')) - ) - `); - - const stmt = db.prepare(` - INSERT INTO instances - (name, state, stack, vmid, atlas, argus, semaphore, patchmon, tailscale, andromeda, tailscale_ip, hardware_acceleration) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - `); - - SEED.forEach(s => stmt.run([ - s.name, s.state, s.stack, s.vmid, - +s.atlas, +s.argus, +s.semaphore, +s.patchmon, - +s.tailscale, +s.andromeda, s.tailscale_ip, +s.hardware_acceleration, - ])); - - stmt.free(); - saveToStorage(); +async function getInstance(vmid) { + const res = await fetch(`${BASE}/instances/${vmid}`); + if (res.status === 404) return null; + return res.json(); } -// ── Queries ────────────────────────────────────────────────────────────────── - -function getInstances(filters = {}) { - let sql = 'SELECT * FROM instances WHERE 1=1'; - const params = []; - - if (filters.search) { - sql += ' AND (name LIKE ? OR CAST(vmid AS TEXT) LIKE ? OR stack LIKE ?)'; - const s = `%${filters.search}%`; - params.push(s, s, s); - } - if (filters.state) { sql += ' AND state = ?'; params.push(filters.state); } - if (filters.stack) { sql += ' AND stack = ?'; params.push(filters.stack); } - - sql += ' ORDER BY name ASC'; - - const res = db.exec(sql, params); - if (!res.length) return []; - const cols = res[0].columns; - return res[0].values.map(row => Object.fromEntries(cols.map((c, i) => [c, row[i]]))); -} - -function getInstance(vmid) { - const res = db.exec('SELECT * FROM instances WHERE vmid = ?', [vmid]); - if (!res.length) return null; - const cols = res[0].columns; - return Object.fromEntries(cols.map((c, i) => [c, res[0].values[0][i]])); -} - -function getDistinctStacks() { - const res = db.exec(`SELECT DISTINCT stack FROM instances WHERE stack != '' ORDER BY stack`); - if (!res.length) return []; - return res[0].values.map(row => row[0]); +async function getDistinctStacks() { + const res = await fetch(`${BASE}/instances/stacks`); + return res.json(); } // ── Mutations ───────────────────────────────────────────────────────────────── -function createInstance(data) { - try { - db.run( - `INSERT INTO instances - (name, state, stack, vmid, atlas, argus, semaphore, patchmon, tailscale, andromeda, tailscale_ip, hardware_acceleration) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, - [data.name, data.state, data.stack, data.vmid, - data.atlas, data.argus, data.semaphore, data.patchmon, - data.tailscale, data.andromeda, data.tailscale_ip, data.hardware_acceleration] - ); - saveToStorage(); - return { ok: true }; - } catch (e) { - return { ok: false, error: e.message }; - } +async function createInstance(data) { + const { ok, data: body } = await api('/instances', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(data), + }); + if (!ok) return { ok: false, error: body.error ?? body.errors?.[0] ?? 'error creating instance' }; + return { ok: true }; } -function updateInstance(id, data) { - try { - db.run( - `UPDATE instances SET - name=?, state=?, stack=?, vmid=?, - atlas=?, argus=?, semaphore=?, patchmon=?, - tailscale=?, andromeda=?, tailscale_ip=?, hardware_acceleration=?, - updatedAt=datetime('now') - WHERE id=?`, - [data.name, data.state, data.stack, data.vmid, - data.atlas, data.argus, data.semaphore, data.patchmon, - data.tailscale, data.andromeda, data.tailscale_ip, data.hardware_acceleration, - id] - ); - saveToStorage(); - return { ok: true }; - } catch (e) { - return { ok: false, error: e.message }; - } +async function updateInstance(vmid, data) { + const { ok, data: body } = await api(`/instances/${vmid}`, { + method: 'PUT', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(data), + }); + if (!ok) return { ok: false, error: body.error ?? body.errors?.[0] ?? 'error updating instance' }; + return { ok: true }; } -function deleteInstance(id) { - db.run('DELETE FROM instances WHERE id = ?', [id]); - saveToStorage(); +async function deleteInstance(vmid) { + await api(`/instances/${vmid}`, { method: 'DELETE' }); } diff --git a/js/ui.js b/js/ui.js index 466ad4b..70f70de 100644 --- a/js/ui.js +++ b/js/ui.js @@ -1,5 +1,5 @@ // Module-level UI state -let editingId = null; +let editingVmid = null; let currentVmid = null; let toastTimer = null; @@ -27,8 +27,8 @@ function fmtDateFull(d) { // ── Dashboard ───────────────────────────────────────────────────────────────── -function renderDashboard() { - const all = getInstances(); +async function renderDashboard() { + const all = await getInstances(); document.getElementById('nav-count').textContent = `${all.length} instance${all.length !== 1 ? 's' : ''}`; const states = {}; @@ -39,18 +39,19 @@ function renderDashboard() {
deployed
${states['deployed'] || 0}
testing
${states['testing'] || 0}
degraded
${states['degraded'] || 0}
-
stacks
${getDistinctStacks().length}
+
stacks
${(await getDistinctStacks()).length}
`; - populateStackFilter(); - filterInstances(); + await populateStackFilter(); + await filterInstances(); } -function populateStackFilter() { +async function populateStackFilter() { const select = document.getElementById('filter-stack'); const current = select.value; select.innerHTML = ''; - getDistinctStacks().forEach(s => { + const stacks = await getDistinctStacks(); + stacks.forEach(s => { const opt = document.createElement('option'); opt.value = s; opt.textContent = s; @@ -59,11 +60,11 @@ function populateStackFilter() { }); } -function filterInstances() { +async function filterInstances() { const search = document.getElementById('search-input').value; const state = document.getElementById('filter-state').value; const stack = document.getElementById('filter-stack').value; - const instances = getInstances({ search, state, stack }); + const instances = await getInstances({ search, state, stack }); const grid = document.getElementById('instance-grid'); if (!instances.length) { @@ -76,7 +77,6 @@ function filterInstances() { `
` ).join(''); const activeCount = CARD_SERVICES.filter(s => inst[s]).length; - return `
@@ -100,8 +100,8 @@ function filterInstances() { // ── Detail Page ─────────────────────────────────────────────────────────────── -function renderDetailPage(vmid) { - const inst = getInstance(vmid); +async function renderDetailPage(vmid) { + const inst = await getInstance(vmid); if (!inst) { navigate('dashboard'); return; } currentVmid = vmid; @@ -109,7 +109,7 @@ function renderDetailPage(vmid) { document.getElementById('detail-name').textContent = inst.name; document.getElementById('detail-vmid-sub').textContent = inst.vmid; document.getElementById('detail-id-sub').textContent = inst.id; - document.getElementById('detail-created-sub').textContent = fmtDate(inst.createdAt); + document.getElementById('detail-created-sub').textContent = fmtDate(inst.created_at); document.getElementById('detail-identity').innerHTML = `
name${esc(inst.name)}
@@ -135,8 +135,8 @@ function renderDetailPage(vmid) { `).join(''); document.getElementById('detail-timestamps').innerHTML = ` -
created${fmtDateFull(inst.createdAt)}
-
updated${fmtDateFull(inst.updatedAt)}
+
created${fmtDateFull(inst.created_at)}
+
updated${fmtDateFull(inst.updated_at)}
`; document.getElementById('detail-edit-btn').onclick = () => openEditModal(inst.vmid); @@ -146,16 +146,16 @@ function renderDetailPage(vmid) { // ── Modal ───────────────────────────────────────────────────────────────────── function openNewModal() { - editingId = null; + editingVmid = null; document.getElementById('modal-title').textContent = 'new instance'; clearForm(); document.getElementById('instance-modal').classList.add('open'); } -function openEditModal(vmid) { - const inst = getInstance(vmid); +async function openEditModal(vmid) { + const inst = await getInstance(vmid); if (!inst) return; - editingId = inst.id; + editingVmid = inst.vmid; document.getElementById('modal-title').textContent = `edit / ${inst.name}`; document.getElementById('f-name').value = inst.name; document.getElementById('f-vmid').value = inst.vmid; @@ -186,19 +186,18 @@ function clearForm() { .forEach(id => { document.getElementById(id).checked = false; }); } -function saveInstance() { +async function saveInstance() { const name = document.getElementById('f-name').value.trim(); const vmid = parseInt(document.getElementById('f-vmid').value, 10); const state = document.getElementById('f-state').value; const stack = document.getElementById('f-stack').value; - const tip = document.getElementById('f-tailscale-ip').value.trim(); if (!name) { showToast('name is required', 'error'); return; } if (!vmid || vmid < 1) { showToast('a valid vmid is required', 'error'); return; } const data = { name, state, stack, vmid, - tailscale_ip: tip, + tailscale_ip: document.getElementById('f-tailscale-ip').value.trim(), atlas: +document.getElementById('f-atlas').checked, argus: +document.getElementById('f-argus').checked, semaphore: +document.getElementById('f-semaphore').checked, @@ -208,20 +207,19 @@ function saveInstance() { hardware_acceleration: +document.getElementById('f-hardware-accel').checked, }; - const result = editingId ? updateInstance(editingId, data) : createInstance(data); + const result = editingVmid + ? await updateInstance(editingVmid, data) + : await createInstance(data); - if (!result.ok) { - showToast(result.error.includes('UNIQUE') ? 'vmid already exists' : 'error saving instance', 'error'); - return; - } + if (!result.ok) { showToast(result.error, 'error'); return; } - showToast(`${name} ${editingId ? 'updated' : 'created'}`, 'success'); + showToast(`${name} ${editingVmid ? 'updated' : 'created'}`, 'success'); closeModal(); if (currentVmid && document.getElementById('page-detail').classList.contains('active')) { - renderDetailPage(vmid); + await renderDetailPage(vmid); } else { - renderDashboard(); + await renderDashboard(); } } @@ -232,11 +230,10 @@ function confirmDeleteDialog(inst) { showToast(`demote ${inst.name} to development before deleting`, 'error'); return; } - document.getElementById('confirm-title').textContent = `delete ${inst.name}?`; document.getElementById('confirm-msg').textContent = `This will permanently remove instance "${inst.name}" (vmid: ${inst.vmid}) from Catalyst. This action cannot be undone.`; - document.getElementById('confirm-ok').onclick = () => doDelete(inst.id, inst.name); + document.getElementById('confirm-ok').onclick = () => doDelete(inst.vmid, inst.name); document.getElementById('confirm-overlay').classList.add('open'); } @@ -244,9 +241,9 @@ function closeConfirm() { document.getElementById('confirm-overlay').classList.remove('open'); } -function doDelete(id, name) { - deleteInstance(id); +async function doDelete(vmid, name) { closeConfirm(); + await deleteInstance(vmid); showToast(`${name} deleted`, 'success'); navigate('dashboard'); } @@ -261,7 +258,7 @@ function showToast(msg, type = 'success') { toastTimer = setTimeout(() => t.classList.remove('show'), 3000); } -// ── Global keyboard handler ─────────────────────────────────────────────────── +// ── Keyboard / backdrop ─────────────────────────────────────────────────────── document.addEventListener('keydown', e => { if (e.key !== 'Escape') return; @@ -269,7 +266,6 @@ document.addEventListener('keydown', e => { if (document.getElementById('confirm-overlay').classList.contains('open')) { closeConfirm(); return; } }); -// Close modals on backdrop click document.getElementById('instance-modal').addEventListener('click', e => { if (e.target === document.getElementById('instance-modal')) closeModal(); }); diff --git a/nginx.conf b/nginx.conf deleted file mode 100644 index 4431e2b..0000000 --- a/nginx.conf +++ /dev/null @@ -1,19 +0,0 @@ -server { - listen 80; - root /usr/share/nginx/html; - index index.html; - - # SPA fallback for client-side routing - location / { - try_files $uri $uri/ /index.html; - } - - location ~* \.(css|js)$ { - expires 1y; - add_header Cache-Control "public, immutable"; - } - - location = /index.html { - add_header Cache-Control "no-store"; - } -} diff --git a/package-lock.json b/package-lock.json index d28ef61..e8bf6c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,19 @@ { - "name": "Catalyst", + "name": "catalyst", + "version": "1.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { + "name": "catalyst", + "version": "1.0.3", + "dependencies": { + "express": "^4.18.0" + }, "devDependencies": { "jsdom": "^25.0.0", - "sql.js": "^1.10.2", - "vitest": "^2.0.0" + "supertest": "^7.0.0", + "vitest": "^3.2.4" } }, "node_modules/@asamuzakjp/css-color": { @@ -140,9 +146,9 @@ } }, "node_modules/@esbuild/aix-ppc64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", - "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.4.tgz", + "integrity": "sha512-cQPwL2mp2nSmHHJlCyoXgHGhbEPMrEEU5xhkcy3Hs/O7nGZqEpZ2sUtLaL9MORLtDfRvVl2/3PAuEkYZH0Ty8Q==", "cpu": [ "ppc64" ], @@ -153,13 +159,13 @@ "aix" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/android-arm": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", - "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.4.tgz", + "integrity": "sha512-X9bUgvxiC8CHAGKYufLIHGXPJWnr0OCdR0anD2e21vdvgCI8lIfqFbnoeOz7lBjdrAGUhqLZLcQo6MLhTO2DKQ==", "cpu": [ "arm" ], @@ -170,13 +176,13 @@ "android" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/android-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", - "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.4.tgz", + "integrity": "sha512-gdLscB7v75wRfu7QSm/zg6Rx29VLdy9eTr2t44sfTW7CxwAtQghZ4ZnqHk3/ogz7xao0QAgrkradbBzcqFPasw==", "cpu": [ "arm64" ], @@ -187,13 +193,13 @@ "android" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/android-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", - "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.4.tgz", + "integrity": "sha512-PzPFnBNVF292sfpfhiyiXCGSn9HZg5BcAz+ivBuSsl6Rk4ga1oEXAamhOXRFyMcjwr2DVtm40G65N3GLeH1Lvw==", "cpu": [ "x64" ], @@ -204,13 +210,13 @@ "android" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", - "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.4.tgz", + "integrity": "sha512-b7xaGIwdJlht8ZFCvMkpDN6uiSmnxxK56N2GDTMYPr2/gzvfdQN8rTfBsvVKmIVY/X7EM+/hJKEIbbHs9oA4tQ==", "cpu": [ "arm64" ], @@ -221,13 +227,13 @@ "darwin" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", - "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.4.tgz", + "integrity": "sha512-sR+OiKLwd15nmCdqpXMnuJ9W2kpy0KigzqScqHI3Hqwr7IXxBp3Yva+yJwoqh7rE8V77tdoheRYataNKL4QrPw==", "cpu": [ "x64" ], @@ -238,13 +244,13 @@ "darwin" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", - "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.4.tgz", + "integrity": "sha512-jnfpKe+p79tCnm4GVav68A7tUFeKQwQyLgESwEAUzyxk/TJr4QdGog9sqWNcUbr/bZt/O/HXouspuQDd9JxFSw==", "cpu": [ "arm64" ], @@ -255,13 +261,13 @@ "freebsd" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", - "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.4.tgz", + "integrity": "sha512-2kb4ceA/CpfUrIcTUl1wrP/9ad9Atrp5J94Lq69w7UwOMolPIGrfLSvAKJp0RTvkPPyn6CIWrNy13kyLikZRZQ==", "cpu": [ "x64" ], @@ -272,13 +278,13 @@ "freebsd" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-arm": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", - "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.4.tgz", + "integrity": "sha512-aBYgcIxX/wd5n2ys0yESGeYMGF+pv6g0DhZr3G1ZG4jMfruU9Tl1i2Z+Wnj9/KjGz1lTLCcorqE2viePZqj4Eg==", "cpu": [ "arm" ], @@ -289,13 +295,13 @@ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", - "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.4.tgz", + "integrity": "sha512-7nQOttdzVGth1iz57kxg9uCz57dxQLHWxopL6mYuYthohPKEK0vU0C3O21CcBK6KDlkYVcnDXY099HcCDXd9dA==", "cpu": [ "arm64" ], @@ -306,13 +312,13 @@ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", - "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.4.tgz", + "integrity": "sha512-oPtixtAIzgvzYcKBQM/qZ3R+9TEUd1aNJQu0HhGyqtx6oS7qTpvjheIWBbes4+qu1bNlo2V4cbkISr8q6gRBFA==", "cpu": [ "ia32" ], @@ -323,13 +329,13 @@ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", - "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.4.tgz", + "integrity": "sha512-8mL/vh8qeCoRcFH2nM8wm5uJP+ZcVYGGayMavi8GmRJjuI3g1v6Z7Ni0JJKAJW+m0EtUuARb6Lmp4hMjzCBWzA==", "cpu": [ "loong64" ], @@ -340,13 +346,13 @@ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", - "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.4.tgz", + "integrity": "sha512-1RdrWFFiiLIW7LQq9Q2NES+HiD4NyT8Itj9AUeCl0IVCA459WnPhREKgwrpaIfTOe+/2rdntisegiPWn/r/aAw==", "cpu": [ "mips64el" ], @@ -357,13 +363,13 @@ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", - "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.4.tgz", + "integrity": "sha512-tLCwNG47l3sd9lpfyx9LAGEGItCUeRCWeAx6x2Jmbav65nAwoPXfewtAdtbtit/pJFLUWOhpv0FpS6GQAmPrHA==", "cpu": [ "ppc64" ], @@ -374,13 +380,13 @@ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", - "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.4.tgz", + "integrity": "sha512-BnASypppbUWyqjd1KIpU4AUBiIhVr6YlHx/cnPgqEkNoVOhHg+YiSVxM1RLfiy4t9cAulbRGTNCKOcqHrEQLIw==", "cpu": [ "riscv64" ], @@ -391,13 +397,13 @@ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", - "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.4.tgz", + "integrity": "sha512-+eUqgb/Z7vxVLezG8bVB9SfBie89gMueS+I0xYh2tJdw3vqA/0ImZJ2ROeWwVJN59ihBeZ7Tu92dF/5dy5FttA==", "cpu": [ "s390x" ], @@ -408,13 +414,13 @@ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", - "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.4.tgz", + "integrity": "sha512-S5qOXrKV8BQEzJPVxAwnryi2+Iq5pB40gTEIT69BQONqR7JH1EPIcQ/Uiv9mCnn05jff9umq/5nqzxlqTOg9NA==", "cpu": [ "x64" ], @@ -425,13 +431,30 @@ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.4.tgz", + "integrity": "sha512-xHT8X4sb0GS8qTqiwzHqpY00C95DPAq7nAwX35Ie/s+LO9830hrMd3oX0ZMKLvy7vsonee73x0lmcdOVXFzd6Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", - "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.4.tgz", + "integrity": "sha512-RugOvOdXfdyi5Tyv40kgQnI0byv66BFgAqjdgtAKqHoZTbTF2QqfQrFwa7cHEORJf6X2ht+l9ABLMP0dnKYsgg==", "cpu": [ "x64" ], @@ -442,13 +465,30 @@ "netbsd" ], "engines": { - "node": ">=12" + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.4.tgz", + "integrity": "sha512-2MyL3IAaTX+1/qP0O1SwskwcwCoOI4kV2IBX1xYnDDqthmq5ArrW94qSIKCAuRraMgPOmG0RDTA74mzYNQA9ow==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", - "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.4.tgz", + "integrity": "sha512-u8fg/jQ5aQDfsnIV6+KwLOf1CmJnfu1ShpwqdwC0uA7ZPwFws55Ngc12vBdeUdnuWoQYx/SOQLGDcdlfXhYmXQ==", "cpu": [ "x64" ], @@ -459,13 +499,30 @@ "openbsd" ], "engines": { - "node": ">=12" + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.4.tgz", + "integrity": "sha512-JkTZrl6VbyO8lDQO3yv26nNr2RM2yZzNrNHEsj9bm6dOwwu9OYN28CjzZkH57bh4w0I2F7IodpQvUAEd1mbWXg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", - "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.4.tgz", + "integrity": "sha512-/gOzgaewZJfeJTlsWhvUEmUG4tWEY2Spp5M20INYRg2ZKl9QPO3QEEgPeRtLjEWSW8FilRNacPOg8R1uaYkA6g==", "cpu": [ "x64" ], @@ -476,13 +533,13 @@ "sunos" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", - "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.4.tgz", + "integrity": "sha512-Z9SExBg2y32smoDQdf1HRwHRt6vAHLXcxD2uGgO/v2jK7Y718Ix4ndsbNMU/+1Qiem9OiOdaqitioZwxivhXYg==", "cpu": [ "arm64" ], @@ -493,13 +550,13 @@ "win32" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", - "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.4.tgz", + "integrity": "sha512-DAyGLS0Jz5G5iixEbMHi5KdiApqHBWMGzTtMiJ72ZOLhbu/bzxgAe8Ue8CTS3n3HbIUHQz/L51yMdGMeoxXNJw==", "cpu": [ "ia32" ], @@ -510,13 +567,13 @@ "win32" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/win32-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", - "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.4.tgz", + "integrity": "sha512-+knoa0BDoeXgkNvvV1vvbZX4+hizelrkwmGJBdT17t8FNPwG2lKemmuMZlmaNQ3ws3DKKCxpb4zRZEIp3UxFCg==", "cpu": [ "x64" ], @@ -527,7 +584,7 @@ "win32" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@jridgewell/sourcemap-codec": { @@ -537,6 +594,29 @@ "dev": true, "license": "MIT" }, + "node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@paralleldrive/cuid2": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@paralleldrive/cuid2/-/cuid2-2.3.1.tgz", + "integrity": "sha512-XO7cAxhnTZl0Yggq6jOgjiOHhbgcO4NqFqwSmQpjK3b6TEE6Uj/jfSk6wzYyemh3+I0sHirKSetjQwn5cZktFw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@noble/hashes": "^1.1.5" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.60.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.60.0.tgz", @@ -926,6 +1006,24 @@ "win32" ] }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/estree": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", @@ -934,38 +1032,39 @@ "license": "MIT" }, "node_modules/@vitest/expect": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.9.tgz", - "integrity": "sha512-UJCIkTBenHeKT1TTlKMJWy1laZewsRIzYighyYiJKZreqtdxSos/S1t+ktRMQWu2CKqaarrkeszJx1cgC5tGZw==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.4.tgz", + "integrity": "sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/spy": "2.1.9", - "@vitest/utils": "2.1.9", - "chai": "^5.1.2", - "tinyrainbow": "^1.2.0" + "@types/chai": "^5.2.2", + "@vitest/spy": "3.2.4", + "@vitest/utils": "3.2.4", + "chai": "^5.2.0", + "tinyrainbow": "^2.0.0" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/mocker": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-2.1.9.tgz", - "integrity": "sha512-tVL6uJgoUdi6icpxmdrn5YNo3g3Dxv+IHJBr0GXHaEdTcw3F+cPKnsXFhli6nO+f/6SDKPHEK1UN+k+TQv0Ehg==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.2.4.tgz", + "integrity": "sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/spy": "2.1.9", + "@vitest/spy": "3.2.4", "estree-walker": "^3.0.3", - "magic-string": "^0.30.12" + "magic-string": "^0.30.17" }, "funding": { "url": "https://opencollective.com/vitest" }, "peerDependencies": { "msw": "^2.4.9", - "vite": "^5.0.0" + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" }, "peerDependenciesMeta": { "msw": { @@ -977,75 +1076,89 @@ } }, "node_modules/@vitest/pretty-format": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-2.1.9.tgz", - "integrity": "sha512-KhRIdGV2U9HOUzxfiHmY8IFHTdqtOhIzCpd8WRdJiE7D/HUcZVD0EgQCVjm+Q9gkUXWgBvMmTtZgIG48wq7sOQ==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.4.tgz", + "integrity": "sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==", "dev": true, "license": "MIT", "dependencies": { - "tinyrainbow": "^1.2.0" + "tinyrainbow": "^2.0.0" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/runner": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-2.1.9.tgz", - "integrity": "sha512-ZXSSqTFIrzduD63btIfEyOmNcBmQvgOVsPNPe0jYtESiXkhd8u2erDLnMxmGrDCwHCCHE7hxwRDCT3pt0esT4g==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.2.4.tgz", + "integrity": "sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/utils": "2.1.9", - "pathe": "^1.1.2" + "@vitest/utils": "3.2.4", + "pathe": "^2.0.3", + "strip-literal": "^3.0.0" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/snapshot": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-2.1.9.tgz", - "integrity": "sha512-oBO82rEjsxLNJincVhLhaxxZdEtV0EFHMK5Kmx5sJ6H9L183dHECjiefOAdnqpIgT5eZwT04PoggUnW88vOBNQ==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.2.4.tgz", + "integrity": "sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "2.1.9", - "magic-string": "^0.30.12", - "pathe": "^1.1.2" + "@vitest/pretty-format": "3.2.4", + "magic-string": "^0.30.17", + "pathe": "^2.0.3" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/spy": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-2.1.9.tgz", - "integrity": "sha512-E1B35FwzXXTs9FHNK6bDszs7mtydNi5MIfUWpceJ8Xbfb1gBMscAnwLbEu+B44ed6W3XjL9/ehLPHR1fkf1KLQ==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.2.4.tgz", + "integrity": "sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==", "dev": true, "license": "MIT", "dependencies": { - "tinyspy": "^3.0.2" + "tinyspy": "^4.0.3" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/utils": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-2.1.9.tgz", - "integrity": "sha512-v0psaMSkNJ3A2NMrUEHFRzJtDPFn+/VWZ5WxImB21T9fjucJRmS7xCS3ppEnARb9y11OAzaD+P2Ps+b+BGX5iQ==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.2.4.tgz", + "integrity": "sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "2.1.9", - "loupe": "^3.1.2", - "tinyrainbow": "^1.2.0" + "@vitest/pretty-format": "3.2.4", + "loupe": "^3.1.4", + "tinyrainbow": "^2.0.0" }, "funding": { "url": "https://opencollective.com/vitest" } }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "license": "MIT", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/agent-base": { "version": "7.1.4", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", @@ -1056,6 +1169,19 @@ "node": ">= 14" } }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "license": "MIT" + }, + "node_modules/asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", + "dev": true, + "license": "MIT" + }, "node_modules/assertion-error": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", @@ -1073,6 +1199,66 @@ "dev": true, "license": "MIT" }, + "node_modules/body-parser": { + "version": "1.20.4", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz", + "integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "~1.2.0", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "on-finished": "~2.4.1", + "qs": "~6.14.0", + "raw-body": "~2.5.3", + "type-is": "~1.6.18", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/body-parser/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/body-parser/node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/body-parser/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -1087,7 +1273,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", - "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", @@ -1097,6 +1282,22 @@ "node": ">= 0.4" } }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/chai": { "version": "5.3.3", "resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz", @@ -1137,6 +1338,59 @@ "node": ">= 0.8" } }, + "node_modules/component-emitter": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.1.tgz", + "integrity": "sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz", + "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==", + "license": "MIT" + }, + "node_modules/cookiejar": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", + "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==", + "dev": true, + "license": "MIT" + }, "node_modules/cssstyle": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.6.0.tgz", @@ -1217,11 +1471,40 @@ "node": ">=0.4.0" } }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dezalgo": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", + "integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==", + "dev": true, + "license": "ISC", + "dependencies": { + "asap": "^2.0.0", + "wrappy": "1" + } + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", - "dev": true, "license": "MIT", "dependencies": { "call-bind-apply-helpers": "^1.0.1", @@ -1232,6 +1515,21 @@ "node": ">= 0.4" } }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/entities": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz", @@ -1249,7 +1547,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -1259,7 +1556,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -1276,7 +1572,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", - "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0" @@ -1302,9 +1597,9 @@ } }, "node_modules/esbuild": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", - "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.4.tgz", + "integrity": "sha512-Rq4vbHnYkK5fws5NF7MYTU68FPRE1ajX7heQ/8QXXWqNgqqJ/GkmmyxIzUnf2Sr/bakf8l54716CcMGHYhMrrQ==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -1312,34 +1607,43 @@ "esbuild": "bin/esbuild" }, "engines": { - "node": ">=12" + "node": ">=18" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.21.5", - "@esbuild/android-arm": "0.21.5", - "@esbuild/android-arm64": "0.21.5", - "@esbuild/android-x64": "0.21.5", - "@esbuild/darwin-arm64": "0.21.5", - "@esbuild/darwin-x64": "0.21.5", - "@esbuild/freebsd-arm64": "0.21.5", - "@esbuild/freebsd-x64": "0.21.5", - "@esbuild/linux-arm": "0.21.5", - "@esbuild/linux-arm64": "0.21.5", - "@esbuild/linux-ia32": "0.21.5", - "@esbuild/linux-loong64": "0.21.5", - "@esbuild/linux-mips64el": "0.21.5", - "@esbuild/linux-ppc64": "0.21.5", - "@esbuild/linux-riscv64": "0.21.5", - "@esbuild/linux-s390x": "0.21.5", - "@esbuild/linux-x64": "0.21.5", - "@esbuild/netbsd-x64": "0.21.5", - "@esbuild/openbsd-x64": "0.21.5", - "@esbuild/sunos-x64": "0.21.5", - "@esbuild/win32-arm64": "0.21.5", - "@esbuild/win32-ia32": "0.21.5", - "@esbuild/win32-x64": "0.21.5" + "@esbuild/aix-ppc64": "0.27.4", + "@esbuild/android-arm": "0.27.4", + "@esbuild/android-arm64": "0.27.4", + "@esbuild/android-x64": "0.27.4", + "@esbuild/darwin-arm64": "0.27.4", + "@esbuild/darwin-x64": "0.27.4", + "@esbuild/freebsd-arm64": "0.27.4", + "@esbuild/freebsd-x64": "0.27.4", + "@esbuild/linux-arm": "0.27.4", + "@esbuild/linux-arm64": "0.27.4", + "@esbuild/linux-ia32": "0.27.4", + "@esbuild/linux-loong64": "0.27.4", + "@esbuild/linux-mips64el": "0.27.4", + "@esbuild/linux-ppc64": "0.27.4", + "@esbuild/linux-riscv64": "0.27.4", + "@esbuild/linux-s390x": "0.27.4", + "@esbuild/linux-x64": "0.27.4", + "@esbuild/netbsd-arm64": "0.27.4", + "@esbuild/netbsd-x64": "0.27.4", + "@esbuild/openbsd-arm64": "0.27.4", + "@esbuild/openbsd-x64": "0.27.4", + "@esbuild/openharmony-arm64": "0.27.4", + "@esbuild/sunos-x64": "0.27.4", + "@esbuild/win32-arm64": "0.27.4", + "@esbuild/win32-ia32": "0.27.4", + "@esbuild/win32-x64": "0.27.4" } }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, "node_modules/estree-walker": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", @@ -1350,6 +1654,15 @@ "@types/estree": "^1.0.0" } }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/expect-type": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz", @@ -1360,6 +1673,125 @@ "node": ">=12.0.0" } }, + "node_modules/express": { + "version": "4.22.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz", + "integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==", + "license": "MIT", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "~1.20.3", + "content-disposition": "~0.5.4", + "content-type": "~1.0.4", + "cookie": "~0.7.1", + "cookie-signature": "~1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.3.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "~0.1.12", + "proxy-addr": "~2.0.7", + "qs": "~6.14.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "~0.19.0", + "serve-static": "~1.16.2", + "setprototypeof": "1.2.0", + "statuses": "~2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/express/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", + "dev": true, + "license": "MIT" + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/finalhandler": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz", + "integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "statuses": "~2.0.2", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/finalhandler/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/finalhandler/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, "node_modules/form-data": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", @@ -1377,6 +1809,42 @@ "node": ">= 6" } }, + "node_modules/formidable": { + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-3.5.4.tgz", + "integrity": "sha512-YikH+7CUTOtP44ZTnUhR7Ic2UASBPOqmaRkRKxRbywPTe5VxF7RRCck4af9wutiZ/QKM5nME9Bie2fFaPz5Gug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@paralleldrive/cuid2": "^2.2.2", + "dezalgo": "^1.0.4", + "once": "^1.4.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "url": "https://ko-fi.com/tunnckoCore/commissions" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -1396,7 +1864,6 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" @@ -1406,7 +1873,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", - "dev": true, "license": "MIT", "dependencies": { "call-bind-apply-helpers": "^1.0.2", @@ -1431,7 +1897,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", - "dev": true, "license": "MIT", "dependencies": { "dunder-proto": "^1.0.1", @@ -1445,7 +1910,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -1458,7 +1922,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -1487,7 +1950,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "dev": true, "license": "MIT", "dependencies": { "function-bind": "^1.1.2" @@ -1509,6 +1971,26 @@ "node": ">=18" } }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/http-proxy-agent": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", @@ -1550,6 +2032,21 @@ "node": ">=0.10.0" } }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, "node_modules/is-potential-custom-element-name": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", @@ -1557,6 +2054,13 @@ "dev": true, "license": "MIT" }, + "node_modules/js-tokens": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", + "integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==", + "dev": true, + "license": "MIT" + }, "node_modules/jsdom": { "version": "25.0.1", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-25.0.1.tgz", @@ -1626,17 +2130,54 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" } }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -1646,7 +2187,6 @@ "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dev": true, "license": "MIT", "dependencies": { "mime-db": "1.52.0" @@ -1659,7 +2199,6 @@ "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, "license": "MIT" }, "node_modules/nanoid": { @@ -1681,6 +2220,15 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/nwsapi": { "version": "2.2.23", "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.23.tgz", @@ -1688,6 +2236,40 @@ "dev": true, "license": "MIT" }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, "node_modules/parse5": { "version": "7.3.0", "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", @@ -1701,10 +2283,25 @@ "url": "https://github.com/inikulin/parse5?sponsor=1" } }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz", + "integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==", + "license": "MIT" + }, "node_modules/pathe": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", - "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", "dev": true, "license": "MIT" }, @@ -1725,6 +2322,19 @@ "dev": true, "license": "ISC" }, + "node_modules/picomatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/postcss": { "version": "8.5.8", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.8.tgz", @@ -1754,6 +2364,19 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -1764,6 +2387,57 @@ "node": ">=6" } }, + "node_modules/qs": { + "version": "6.14.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz", + "integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz", + "integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/raw-body/node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/rollup": { "version": "4.60.0", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.60.0.tgz", @@ -1816,11 +2490,30 @@ "dev": true, "license": "MIT" }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true, "license": "MIT" }, "node_modules/saxes": { @@ -1836,6 +2529,138 @@ "node": ">=v12.22.7" } }, + "node_modules/send": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz", + "integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.1", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "~2.4.1", + "range-parser": "~1.2.1", + "statuses": "~2.0.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/send/node_modules/debug/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/serve-static": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz", + "integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==", + "license": "MIT", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "~0.19.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/siginfo": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", @@ -1853,13 +2678,6 @@ "node": ">=0.10.0" } }, - "node_modules/sql.js": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/sql.js/-/sql.js-1.14.1.tgz", - "integrity": "sha512-gcj8zBWU5cFsi9WUP+4bFNXAyF1iRpA3LLyS/DP5xlrNzGmPIizUeBggKa8DbDwdqaKwUcTEnChtd2grWo/x/A==", - "dev": true, - "license": "MIT" - }, "node_modules/stackback": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", @@ -1867,6 +2685,15 @@ "dev": true, "license": "MIT" }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/std-env": { "version": "3.10.0", "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", @@ -1874,6 +2701,78 @@ "dev": true, "license": "MIT" }, + "node_modules/strip-literal": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.1.0.tgz", + "integrity": "sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "js-tokens": "^9.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/superagent": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-10.3.0.tgz", + "integrity": "sha512-B+4Ik7ROgVKrQsXTV0Jwp2u+PXYLSlqtDAhYnkkD+zn3yg8s/zjA2MeGayPoY/KICrbitwneDHrjSotxKL+0XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "component-emitter": "^1.3.1", + "cookiejar": "^2.1.4", + "debug": "^4.3.7", + "fast-safe-stringify": "^2.1.1", + "form-data": "^4.0.5", + "formidable": "^3.5.4", + "methods": "^1.1.2", + "mime": "2.6.0", + "qs": "^6.14.1" + }, + "engines": { + "node": ">=14.18.0" + } + }, + "node_modules/superagent/node_modules/mime": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", + "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==", + "dev": true, + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/supertest": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/supertest/-/supertest-7.2.2.tgz", + "integrity": "sha512-oK8WG9diS3DlhdUkcFn4tkNIiIbBx9lI2ClF8K+b2/m8Eyv47LSawxUzZQSNKUrVb2KsqeTDCcjAAVPYaSLVTA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cookie-signature": "^1.2.2", + "methods": "^1.1.2", + "superagent": "^10.3.0" + }, + "engines": { + "node": ">=14.18.0" + } + }, + "node_modules/supertest/node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, "node_modules/symbol-tree": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", @@ -1895,6 +2794,23 @@ "dev": true, "license": "MIT" }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, "node_modules/tinypool": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz", @@ -1906,9 +2822,9 @@ } }, "node_modules/tinyrainbow": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-1.2.0.tgz", - "integrity": "sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz", + "integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==", "dev": true, "license": "MIT", "engines": { @@ -1916,9 +2832,9 @@ } }, "node_modules/tinyspy": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz", - "integrity": "sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-4.0.4.tgz", + "integrity": "sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==", "dev": true, "license": "MIT", "engines": { @@ -1945,6 +2861,15 @@ "dev": true, "license": "MIT" }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, "node_modules/tough-cookie": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-5.1.2.tgz", @@ -1971,22 +2896,65 @@ "node": ">=18" } }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "license": "MIT", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/vite": { - "version": "5.4.21", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz", - "integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==", + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.1.tgz", + "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", "dev": true, "license": "MIT", "dependencies": { - "esbuild": "^0.21.3", - "postcss": "^8.4.43", - "rollup": "^4.20.0" + "esbuild": "^0.27.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" }, "bin": { "vite": "bin/vite.js" }, "engines": { - "node": "^18.0.0 || >=20.0.0" + "node": "^20.19.0 || >=22.12.0" }, "funding": { "url": "https://github.com/vitejs/vite?sponsor=1" @@ -1995,19 +2963,25 @@ "fsevents": "~2.3.3" }, "peerDependencies": { - "@types/node": "^18.0.0 || >=20.0.0", - "less": "*", + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", "lightningcss": "^1.21.0", - "sass": "*", - "sass-embedded": "*", - "stylus": "*", - "sugarss": "*", - "terser": "^5.4.0" + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" }, "peerDependenciesMeta": { "@types/node": { "optional": true }, + "jiti": { + "optional": true + }, "less": { "optional": true }, @@ -2028,74 +3002,84 @@ }, "terser": { "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true } } }, "node_modules/vite-node": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-2.1.9.tgz", - "integrity": "sha512-AM9aQ/IPrW/6ENLQg3AGY4K1N2TGZdR5e4gu/MmmR2xR3Ll1+dib+nook92g4TV3PXVyeyxdWwtaCAiUL0hMxA==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.2.4.tgz", + "integrity": "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==", "dev": true, "license": "MIT", "dependencies": { "cac": "^6.7.14", - "debug": "^4.3.7", - "es-module-lexer": "^1.5.4", - "pathe": "^1.1.2", - "vite": "^5.0.0" + "debug": "^4.4.1", + "es-module-lexer": "^1.7.0", + "pathe": "^2.0.3", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" }, "bin": { "vite-node": "vite-node.mjs" }, "engines": { - "node": "^18.0.0 || >=20.0.0" + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/vitest": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-2.1.9.tgz", - "integrity": "sha512-MSmPM9REYqDGBI8439mA4mWhV5sKmDlBKWIYbA3lRb2PTHACE0mgKwA8yQ2xq9vxDTuk4iPrECBAEW2aoFXY0Q==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.4.tgz", + "integrity": "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/expect": "2.1.9", - "@vitest/mocker": "2.1.9", - "@vitest/pretty-format": "^2.1.9", - "@vitest/runner": "2.1.9", - "@vitest/snapshot": "2.1.9", - "@vitest/spy": "2.1.9", - "@vitest/utils": "2.1.9", - "chai": "^5.1.2", - "debug": "^4.3.7", - "expect-type": "^1.1.0", - "magic-string": "^0.30.12", - "pathe": "^1.1.2", - "std-env": "^3.8.0", + "@types/chai": "^5.2.2", + "@vitest/expect": "3.2.4", + "@vitest/mocker": "3.2.4", + "@vitest/pretty-format": "^3.2.4", + "@vitest/runner": "3.2.4", + "@vitest/snapshot": "3.2.4", + "@vitest/spy": "3.2.4", + "@vitest/utils": "3.2.4", + "chai": "^5.2.0", + "debug": "^4.4.1", + "expect-type": "^1.2.1", + "magic-string": "^0.30.17", + "pathe": "^2.0.3", + "picomatch": "^4.0.2", + "std-env": "^3.9.0", "tinybench": "^2.9.0", - "tinyexec": "^0.3.1", - "tinypool": "^1.0.1", - "tinyrainbow": "^1.2.0", - "vite": "^5.0.0", - "vite-node": "2.1.9", + "tinyexec": "^0.3.2", + "tinyglobby": "^0.2.14", + "tinypool": "^1.1.1", + "tinyrainbow": "^2.0.0", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0", + "vite-node": "3.2.4", "why-is-node-running": "^2.3.0" }, "bin": { "vitest": "vitest.mjs" }, "engines": { - "node": "^18.0.0 || >=20.0.0" + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" }, "funding": { "url": "https://opencollective.com/vitest" }, "peerDependencies": { "@edge-runtime/vm": "*", - "@types/node": "^18.0.0 || >=20.0.0", - "@vitest/browser": "2.1.9", - "@vitest/ui": "2.1.9", + "@types/debug": "^4.1.12", + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "@vitest/browser": "3.2.4", + "@vitest/ui": "3.2.4", "happy-dom": "*", "jsdom": "*" }, @@ -2103,6 +3087,9 @@ "@edge-runtime/vm": { "optional": true }, + "@types/debug": { + "optional": true + }, "@types/node": { "optional": true }, @@ -2198,6 +3185,13 @@ "node": ">=8" } }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true, + "license": "ISC" + }, "node_modules/ws": { "version": "8.20.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.20.0.tgz", diff --git a/package.json b/package.json index 02cff78..eb9cea4 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,19 @@ { "name": "catalyst", - "version": "1.0.3", + "version": "1.1.0", "type": "module", "scripts": { + "start": "node server/server.js", "test": "vitest run", "test:watch": "vitest", "version:write": "node -e \"const {version}=JSON.parse(require('fs').readFileSync('package.json','utf8'));require('fs').writeFileSync('js/version.js','const VERSION = \\\"'+version+'\\\";\\n');\"" }, + "dependencies": { + "express": "^4.18.0" + }, "devDependencies": { - "vitest": "^2.0.0", - "sql.js": "^1.10.2", - "jsdom": "^25.0.0" + "jsdom": "^25.0.0", + "supertest": "^7.0.0", + "vitest": "^3.2.4" } } diff --git a/server/db.js b/server/db.js new file mode 100644 index 0000000..f7a0fb9 --- /dev/null +++ b/server/db.js @@ -0,0 +1,137 @@ +import { DatabaseSync } from 'node:sqlite'; +import { mkdirSync } from 'fs'; +import { dirname, join } from 'path'; +import { fileURLToPath } from 'url'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const DEFAULT_PATH = join(__dirname, '../data/catalyst.db'); + +let db; + +function init(path) { + if (path !== ':memory:') { + mkdirSync(dirname(path), { recursive: true }); + } + db = new DatabaseSync(path); + db.exec('PRAGMA journal_mode = WAL'); + db.exec('PRAGMA foreign_keys = ON'); + db.exec('PRAGMA synchronous = NORMAL'); + createSchema(); + if (path !== ':memory:') seed(); +} + +function createSchema() { + db.exec(` + CREATE TABLE IF NOT EXISTS instances ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL CHECK(length(name) BETWEEN 1 AND 100), + state TEXT NOT NULL DEFAULT 'deployed' + CHECK(state IN ('deployed','testing','degraded')), + stack TEXT NOT NULL DEFAULT 'development' + CHECK(stack IN ('production','development')), + vmid INTEGER NOT NULL UNIQUE CHECK(vmid > 0), + atlas INTEGER NOT NULL DEFAULT 0 CHECK(atlas IN (0,1)), + argus INTEGER NOT NULL DEFAULT 0 CHECK(argus IN (0,1)), + semaphore INTEGER NOT NULL DEFAULT 0 CHECK(semaphore IN (0,1)), + patchmon INTEGER NOT NULL DEFAULT 0 CHECK(patchmon IN (0,1)), + tailscale INTEGER NOT NULL DEFAULT 0 CHECK(tailscale IN (0,1)), + andromeda INTEGER NOT NULL DEFAULT 0 CHECK(andromeda IN (0,1)), + tailscale_ip TEXT NOT NULL DEFAULT '', + hardware_acceleration INTEGER NOT NULL DEFAULT 0 CHECK(hardware_acceleration IN (0,1)), + created_at TEXT NOT NULL DEFAULT (datetime('now')), + updated_at TEXT NOT NULL DEFAULT (datetime('now')) + ); + CREATE INDEX IF NOT EXISTS idx_instances_state ON instances(state); + CREATE INDEX IF NOT EXISTS idx_instances_stack ON instances(stack); + `); +} + +const SEED = [ + { name: 'plex', state: 'deployed', stack: 'production', vmid: 117, atlas: 1, argus: 1, semaphore: 0, patchmon: 1, tailscale: 1, andromeda: 0, tailscale_ip: '100.64.0.1', hardware_acceleration: 1 }, + { name: 'foldergram', state: 'testing', stack: 'development', vmid: 137, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }, + { name: 'homeassistant', state: 'deployed', stack: 'production', vmid: 102, atlas: 1, argus: 1, semaphore: 1, patchmon: 1, tailscale: 1, andromeda: 0, tailscale_ip: '100.64.0.5', hardware_acceleration: 0 }, + { name: 'gitea', state: 'deployed', stack: 'production', vmid: 110, atlas: 1, argus: 0, semaphore: 1, patchmon: 1, tailscale: 1, andromeda: 0, tailscale_ip: '100.64.0.8', hardware_acceleration: 0 }, + { name: 'postgres-primary', state: 'degraded', stack: 'production', vmid: 201, atlas: 1, argus: 1, semaphore: 0, patchmon: 1, tailscale: 0, andromeda: 1, tailscale_ip: '', hardware_acceleration: 0 }, + { name: 'nextcloud', state: 'testing', stack: 'development', vmid: 144, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 1, andromeda: 0, tailscale_ip: '100.64.0.12', hardware_acceleration: 0 }, + { name: 'traefik', state: 'deployed', stack: 'production', vmid: 100, atlas: 1, argus: 1, semaphore: 0, patchmon: 1, tailscale: 1, andromeda: 0, tailscale_ip: '100.64.0.2', hardware_acceleration: 0 }, + { name: 'monitoring-stack', state: 'testing', stack: 'development', vmid: 155, atlas: 0, argus: 0, semaphore: 1, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }, +]; + +function seed() { + const count = db.prepare('SELECT COUNT(*) as n FROM instances').get().n; + if (count > 0) return; + const insert = db.prepare(` + INSERT INTO instances + (name, state, stack, vmid, atlas, argus, semaphore, patchmon, + tailscale, andromeda, tailscale_ip, hardware_acceleration) + VALUES + (@name, @state, @stack, @vmid, @atlas, @argus, @semaphore, @patchmon, + @tailscale, @andromeda, @tailscale_ip, @hardware_acceleration) + `); + db.exec('BEGIN'); + for (const s of SEED) insert.run(s); + db.exec('COMMIT'); +} + +// ── Queries ─────────────────────────────────────────────────────────────────── + +export function getInstances(filters = {}) { + const parts = ['SELECT * FROM instances WHERE 1=1']; + const params = {}; + if (filters.search) { + parts.push('AND (name LIKE @search OR CAST(vmid AS TEXT) LIKE @search OR stack LIKE @search)'); + params.search = `%${filters.search}%`; + } + if (filters.state) { parts.push('AND state = @state'); params.state = filters.state; } + if (filters.stack) { parts.push('AND stack = @stack'); params.stack = filters.stack; } + parts.push('ORDER BY name ASC'); + return db.prepare(parts.join(' ')).all(params); +} + +export function getInstance(vmid) { + return db.prepare('SELECT * FROM instances WHERE vmid = ?').get(vmid) ?? null; +} + +export function getDistinctStacks() { + return db.prepare(`SELECT DISTINCT stack FROM instances WHERE stack != '' ORDER BY stack`) + .all().map(r => r.stack); +} + +// ── Mutations ───────────────────────────────────────────────────────────────── + +export function createInstance(data) { + return db.prepare(` + INSERT INTO instances + (name, state, stack, vmid, atlas, argus, semaphore, patchmon, + tailscale, andromeda, tailscale_ip, hardware_acceleration) + VALUES + (@name, @state, @stack, @vmid, @atlas, @argus, @semaphore, @patchmon, + @tailscale, @andromeda, @tailscale_ip, @hardware_acceleration) + `).run(data); +} + +export function updateInstance(vmid, data) { + return db.prepare(` + UPDATE instances SET + name=@name, state=@state, stack=@stack, vmid=@newVmid, + atlas=@atlas, argus=@argus, semaphore=@semaphore, patchmon=@patchmon, + tailscale=@tailscale, andromeda=@andromeda, tailscale_ip=@tailscale_ip, + hardware_acceleration=@hardware_acceleration, updated_at=datetime('now') + WHERE vmid=@vmid + `).run({ ...data, newVmid: data.vmid, vmid }); +} + +export function deleteInstance(vmid) { + return db.prepare('DELETE FROM instances WHERE vmid = ?').run(vmid); +} + +// ── Test helpers ────────────────────────────────────────────────────────────── + +export function _resetForTest() { + if (db) db.close(); + init(':memory:'); +} + +// ── Boot ────────────────────────────────────────────────────────────────────── + +init(process.env.DB_PATH ?? DEFAULT_PATH); diff --git a/server/routes.js b/server/routes.js new file mode 100644 index 0000000..8b1e199 --- /dev/null +++ b/server/routes.js @@ -0,0 +1,114 @@ +import { Router } from 'express'; +import { + getInstances, getInstance, getDistinctStacks, + createInstance, updateInstance, deleteInstance, +} from './db.js'; + +export const router = Router(); + +// ── Validation ──────────────────────────────────────────────────────────────── + +const VALID_STATES = ['deployed', 'testing', 'degraded']; +const VALID_STACKS = ['production', 'development']; +const SERVICE_KEYS = ['atlas', 'argus', 'semaphore', 'patchmon', 'tailscale', 'andromeda']; + +function validate(body) { + const errors = []; + if (!body.name || typeof body.name !== 'string' || !body.name.trim()) + errors.push('name is required'); + if (!Number.isInteger(body.vmid) || body.vmid < 1) + errors.push('vmid must be a positive integer'); + if (!VALID_STATES.includes(body.state)) + errors.push(`state must be one of: ${VALID_STATES.join(', ')}`); + if (!VALID_STACKS.includes(body.stack)) + errors.push(`stack must be one of: ${VALID_STACKS.join(', ')}`); + return errors; +} + +function normalise(body) { + const row = { + name: body.name.trim(), + state: body.state, + stack: body.stack, + vmid: body.vmid, + tailscale_ip: (body.tailscale_ip ?? '').trim(), + hardware_acceleration: body.hardware_acceleration ? 1 : 0, + }; + for (const svc of SERVICE_KEYS) row[svc] = body[svc] ? 1 : 0; + return row; +} + +// ── Routes ──────────────────────────────────────────────────────────────────── + +// GET /api/instances/stacks — must be declared before /:vmid +router.get('/instances/stacks', (_req, res) => { + res.json(getDistinctStacks()); +}); + +// GET /api/instances +router.get('/instances', (req, res) => { + const { search, state, stack } = req.query; + res.json(getInstances({ search, state, stack })); +}); + +// GET /api/instances/:vmid +router.get('/instances/:vmid', (req, res) => { + const vmid = parseInt(req.params.vmid, 10); + if (!vmid) return res.status(400).json({ error: 'invalid vmid' }); + + const instance = getInstance(vmid); + if (!instance) return res.status(404).json({ error: 'instance not found' }); + + res.json(instance); +}); + +// POST /api/instances +router.post('/instances', (req, res) => { + const errors = validate(req.body); + if (errors.length) return res.status(400).json({ errors }); + + try { + const data = normalise(req.body); + createInstance(data); + const created = getInstance(data.vmid); + res.status(201).json(created); + } catch (e) { + if (e.message.includes('UNIQUE')) return res.status(409).json({ error: 'vmid already exists' }); + if (e.message.includes('CHECK')) return res.status(400).json({ error: 'invalid field value' }); + throw e; + } +}); + +// PUT /api/instances/:vmid +router.put('/instances/:vmid', (req, res) => { + const vmid = parseInt(req.params.vmid, 10); + if (!vmid) return res.status(400).json({ error: 'invalid vmid' }); + if (!getInstance(vmid)) return res.status(404).json({ error: 'instance not found' }); + + const errors = validate(req.body); + if (errors.length) return res.status(400).json({ errors }); + + try { + const data = normalise(req.body); + updateInstance(vmid, data); + res.json(getInstance(data.vmid)); + } catch (e) { + if (e.message.includes('UNIQUE')) return res.status(409).json({ error: 'vmid already exists' }); + if (e.message.includes('CHECK')) return res.status(400).json({ error: 'invalid field value' }); + throw e; + } +}); + +// DELETE /api/instances/:vmid +router.delete('/instances/:vmid', (req, res) => { + const vmid = parseInt(req.params.vmid, 10); + if (!vmid) return res.status(400).json({ error: 'invalid vmid' }); + + const instance = getInstance(vmid); + if (!instance) return res.status(404).json({ error: 'instance not found' }); + if (instance.stack !== 'development') + return res.status(422).json({ error: 'only development instances can be deleted' }); + + deleteInstance(vmid); + res.status(204).end(); +}); diff --git a/server/server.js b/server/server.js new file mode 100644 index 0000000..a09660c --- /dev/null +++ b/server/server.js @@ -0,0 +1,33 @@ +import express from 'express'; +import { fileURLToPath } from 'url'; +import { dirname, join } from 'path'; +import { router } from './routes.js'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const PORT = process.env.PORT ?? 3000; + +export const app = express(); + +app.use(express.json()); + +// API +app.use('/api', router); + +// Static files +app.use(express.static(join(__dirname, '..'))); + +// SPA fallback — all non-API, non-asset routes serve index.html +app.get('*', (req, res) => { + res.sendFile(join(__dirname, '../index.html')); +}); + +// Error handler +app.use((err, _req, res, _next) => { + console.error(err); + res.status(500).json({ error: 'internal server error' }); +}); + +// Boot — only when run directly, not when imported by tests +if (process.argv[1] === fileURLToPath(import.meta.url)) { + app.listen(PORT, () => console.log(`catalyst on :${PORT}`)); +} diff --git a/tests/api.test.js b/tests/api.test.js new file mode 100644 index 0000000..79deb87 --- /dev/null +++ b/tests/api.test.js @@ -0,0 +1,239 @@ +import { describe, it, expect, beforeEach } from 'vitest' +import request from 'supertest' +import { app } from '../server/server.js' +import { _resetForTest } from '../server/db.js' + +beforeEach(() => _resetForTest()) + +const base = { + name: 'traefik', + vmid: 100, + state: 'deployed', + stack: 'production', + atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, + tailscale_ip: '', + hardware_acceleration: 0, +} + +// ── GET /api/instances ──────────────────────────────────────────────────────── + +describe('GET /api/instances', () => { + it('returns empty array when no instances exist', async () => { + const res = await request(app).get('/api/instances') + expect(res.status).toBe(200) + expect(res.body).toEqual([]) + }) + + it('returns all instances sorted by name', async () => { + await request(app).post('/api/instances').send({ ...base, vmid: 1, name: 'zebra' }) + await request(app).post('/api/instances').send({ ...base, vmid: 2, name: 'alpha' }) + const res = await request(app).get('/api/instances') + expect(res.status).toBe(200) + expect(res.body).toHaveLength(2) + expect(res.body[0].name).toBe('alpha') + expect(res.body[1].name).toBe('zebra') + }) + + it('filters by state', async () => { + await request(app).post('/api/instances').send({ ...base, vmid: 1, name: 'a', state: 'deployed' }) + await request(app).post('/api/instances').send({ ...base, vmid: 2, name: 'b', state: 'degraded' }) + const res = await request(app).get('/api/instances?state=deployed') + expect(res.body).toHaveLength(1) + expect(res.body[0].name).toBe('a') + }) + + it('filters by stack', async () => { + await request(app).post('/api/instances').send({ ...base, vmid: 1, name: 'a', stack: 'production' }) + await request(app).post('/api/instances').send({ ...base, vmid: 2, name: 'b', stack: 'development', state: 'testing' }) + const res = await request(app).get('/api/instances?stack=development') + expect(res.body).toHaveLength(1) + expect(res.body[0].name).toBe('b') + }) + + it('searches by name substring', async () => { + await request(app).post('/api/instances').send({ ...base, vmid: 1, name: 'plex' }) + await request(app).post('/api/instances').send({ ...base, vmid: 2, name: 'gitea' }) + const res = await request(app).get('/api/instances?search=ple') + expect(res.body).toHaveLength(1) + expect(res.body[0].name).toBe('plex') + }) + + it('searches by vmid', async () => { + await request(app).post('/api/instances').send({ ...base, vmid: 137, name: 'a' }) + await request(app).post('/api/instances').send({ ...base, vmid: 200, name: 'b' }) + const res = await request(app).get('/api/instances?search=137') + expect(res.body).toHaveLength(1) + expect(res.body[0].vmid).toBe(137) + }) + + it('combines search and state filters', async () => { + await request(app).post('/api/instances').send({ ...base, vmid: 1, name: 'plex', state: 'deployed' }) + await request(app).post('/api/instances').send({ ...base, vmid: 2, name: 'plex2', state: 'degraded' }) + const res = await request(app).get('/api/instances?search=plex&state=deployed') + expect(res.body).toHaveLength(1) + expect(res.body[0].name).toBe('plex') + }) +}) + +// ── GET /api/instances/stacks ───────────────────────────────────────────────── + +describe('GET /api/instances/stacks', () => { + it('returns empty array when no instances exist', async () => { + const res = await request(app).get('/api/instances/stacks') + expect(res.status).toBe(200) + expect(res.body).toEqual([]) + }) + + it('returns unique stacks sorted alphabetically', async () => { + await request(app).post('/api/instances').send({ ...base, vmid: 1, name: 'a', stack: 'production' }) + await request(app).post('/api/instances').send({ ...base, vmid: 2, name: 'b', stack: 'development', state: 'testing' }) + await request(app).post('/api/instances').send({ ...base, vmid: 3, name: 'c', stack: 'production' }) + const res = await request(app).get('/api/instances/stacks') + expect(res.body).toEqual(['development', 'production']) + }) +}) + +// ── GET /api/instances/:vmid ────────────────────────────────────────────────── + +describe('GET /api/instances/:vmid', () => { + it('returns the instance for a known vmid', async () => { + await request(app).post('/api/instances').send({ ...base, vmid: 117, name: 'plex' }) + const res = await request(app).get('/api/instances/117') + expect(res.status).toBe(200) + expect(res.body.name).toBe('plex') + expect(res.body.vmid).toBe(117) + }) + + it('returns 404 for unknown vmid', async () => { + const res = await request(app).get('/api/instances/999') + expect(res.status).toBe(404) + expect(res.body.error).toBeDefined() + }) + + it('returns 400 for non-numeric vmid', async () => { + const res = await request(app).get('/api/instances/abc') + expect(res.status).toBe(400) + }) +}) + +// ── POST /api/instances ─────────────────────────────────────────────────────── + +describe('POST /api/instances', () => { + it('creates an instance and returns 201 with the created record', async () => { + const res = await request(app).post('/api/instances').send(base) + expect(res.status).toBe(201) + expect(res.body.name).toBe('traefik') + expect(res.body.vmid).toBe(100) + expect(res.body.created_at).not.toBeNull() + expect(res.body.updated_at).not.toBeNull() + }) + + it('stores service flags correctly', async () => { + const res = await request(app).post('/api/instances').send({ ...base, atlas: 1, tailscale: 1, hardware_acceleration: 1 }) + expect(res.body.atlas).toBe(1) + expect(res.body.tailscale).toBe(1) + expect(res.body.hardware_acceleration).toBe(1) + expect(res.body.argus).toBe(0) + }) + + it('returns 409 for duplicate vmid', async () => { + await request(app).post('/api/instances').send(base) + const res = await request(app).post('/api/instances').send({ ...base, name: 'other' }) + expect(res.status).toBe(409) + expect(res.body.error).toMatch(/vmid/) + }) + + it('returns 400 when name is missing', async () => { + const res = await request(app).post('/api/instances').send({ ...base, name: '' }) + expect(res.status).toBe(400) + expect(res.body.errors).toBeInstanceOf(Array) + }) + + it('returns 400 for vmid less than 1', async () => { + const res = await request(app).post('/api/instances').send({ ...base, vmid: 0 }) + expect(res.status).toBe(400) + expect(res.body.errors).toBeInstanceOf(Array) + }) + + it('returns 400 for invalid state', async () => { + const res = await request(app).post('/api/instances').send({ ...base, state: 'invalid' }) + expect(res.status).toBe(400) + }) + + it('returns 400 for invalid stack', async () => { + const res = await request(app).post('/api/instances').send({ ...base, stack: 'invalid' }) + expect(res.status).toBe(400) + }) + + it('trims whitespace from name', async () => { + const res = await request(app).post('/api/instances').send({ ...base, name: ' plex ' }) + expect(res.status).toBe(201) + expect(res.body.name).toBe('plex') + }) +}) + +// ── PUT /api/instances/:vmid ────────────────────────────────────────────────── + +describe('PUT /api/instances/:vmid', () => { + it('updates fields and returns the updated record', async () => { + await request(app).post('/api/instances').send(base) + const res = await request(app).put('/api/instances/100').send({ ...base, name: 'updated', state: 'degraded' }) + expect(res.status).toBe(200) + expect(res.body.name).toBe('updated') + expect(res.body.state).toBe('degraded') + }) + + it('can change the vmid', async () => { + await request(app).post('/api/instances').send(base) + await request(app).put('/api/instances/100').send({ ...base, vmid: 200 }) + expect((await request(app).get('/api/instances/100')).status).toBe(404) + expect((await request(app).get('/api/instances/200')).status).toBe(200) + }) + + it('returns 404 for unknown vmid', async () => { + const res = await request(app).put('/api/instances/999').send(base) + expect(res.status).toBe(404) + }) + + it('returns 400 for validation errors', async () => { + await request(app).post('/api/instances').send(base) + const res = await request(app).put('/api/instances/100').send({ ...base, name: '' }) + expect(res.status).toBe(400) + expect(res.body.errors).toBeInstanceOf(Array) + }) + + it('returns 409 when new vmid conflicts with an existing instance', async () => { + await request(app).post('/api/instances').send({ ...base, vmid: 100, name: 'a' }) + await request(app).post('/api/instances').send({ ...base, vmid: 200, name: 'b' }) + const res = await request(app).put('/api/instances/100').send({ ...base, vmid: 200 }) + expect(res.status).toBe(409) + }) +}) + +// ── DELETE /api/instances/:vmid ─────────────────────────────────────────────── + +describe('DELETE /api/instances/:vmid', () => { + it('deletes a development instance and returns 204', async () => { + await request(app).post('/api/instances').send({ ...base, stack: 'development', state: 'testing' }) + const res = await request(app).delete('/api/instances/100') + expect(res.status).toBe(204) + expect((await request(app).get('/api/instances/100')).status).toBe(404) + }) + + it('returns 422 when attempting to delete a production instance', async () => { + await request(app).post('/api/instances').send({ ...base, stack: 'production' }) + const res = await request(app).delete('/api/instances/100') + expect(res.status).toBe(422) + expect(res.body.error).toMatch(/development/) + }) + + it('returns 404 for unknown vmid', async () => { + const res = await request(app).delete('/api/instances/999') + expect(res.status).toBe(404) + }) + + it('returns 400 for non-numeric vmid', async () => { + const res = await request(app).delete('/api/instances/abc') + expect(res.status).toBe(400) + }) +}) diff --git a/tests/db.test.js b/tests/db.test.js index eed7c0a..a61073e 100644 --- a/tests/db.test.js +++ b/tests/db.test.js @@ -1,250 +1,167 @@ import { describe, it, expect, beforeEach } from 'vitest' -import initSqlJs from 'sql.js' +import { + _resetForTest, + getInstances, getInstance, getDistinctStacks, + createInstance, updateInstance, deleteInstance, +} from '../server/db.js' -// ── Schema (mirrors db.js) ──────────────────────────────────────────────────── +beforeEach(() => _resetForTest()); -const SCHEMA = ` - CREATE TABLE instances ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT NOT NULL, - state TEXT DEFAULT 'deployed', - stack TEXT DEFAULT '', - vmid INTEGER UNIQUE NOT NULL, - atlas INTEGER DEFAULT 0, - argus INTEGER DEFAULT 0, - semaphore INTEGER DEFAULT 0, - patchmon INTEGER DEFAULT 0, - tailscale INTEGER DEFAULT 0, - andromeda INTEGER DEFAULT 0, - tailscale_ip TEXT DEFAULT '', - hardware_acceleration INTEGER DEFAULT 0, - createdAt TEXT DEFAULT (datetime('now')), - updatedAt TEXT DEFAULT (datetime('now')) - ) -` - -// ── Helpers ─────────────────────────────────────────────────────────────────── - -let db - -beforeEach(async () => { - const SQL = await initSqlJs() - db = new SQL.Database() - db.run(SCHEMA) -}) - -function rows(res) { - if (!res.length) return [] - const cols = res[0].columns - return res[0].values.map(row => Object.fromEntries(cols.map((c, i) => [c, row[i]]))) -} - -function insert(overrides = {}) { - const defaults = { - name: 'test-instance', state: 'deployed', stack: 'production', vmid: 100, - atlas: 0, argus: 0, semaphore: 0, patchmon: 0, - tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0, - } - const d = { ...defaults, ...overrides } - db.run( - `INSERT INTO instances - (name, state, stack, vmid, atlas, argus, semaphore, patchmon, tailscale, andromeda, tailscale_ip, hardware_acceleration) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, - [d.name, d.state, d.stack, d.vmid, d.atlas, d.argus, d.semaphore, - d.patchmon, d.tailscale, d.andromeda, d.tailscale_ip, d.hardware_acceleration] - ) - return d -} - -function getInstances(filters = {}) { - let sql = 'SELECT * FROM instances WHERE 1=1' - const params = [] - if (filters.search) { - sql += ' AND (name LIKE ? OR CAST(vmid AS TEXT) LIKE ? OR stack LIKE ?)' - const s = `%${filters.search}%` - params.push(s, s, s) - } - if (filters.state) { sql += ' AND state = ?'; params.push(filters.state) } - if (filters.stack) { sql += ' AND stack = ?'; params.push(filters.stack) } - sql += ' ORDER BY name ASC' - return rows(db.exec(sql, params)) -} - -function getInstance(vmid) { - const res = rows(db.exec('SELECT * FROM instances WHERE vmid = ?', [vmid])) - return res[0] ?? null -} - -function getDistinctStacks() { - const res = db.exec(`SELECT DISTINCT stack FROM instances WHERE stack != '' ORDER BY stack`) - if (!res.length) return [] - return res[0].values.map(r => r[0]) -} - -// ── Tests ───────────────────────────────────────────────────────────────────── +// ── getInstances ────────────────────────────────────────────────────────────── describe('getInstances', () => { - it('returns empty array when no instances exist', () => { - expect(getInstances()).toEqual([]) - }) + it('returns empty array when table is empty', () => { + expect(getInstances()).toEqual([]); + }); it('returns all instances sorted by name', () => { - insert({ name: 'zebra', vmid: 1 }) - insert({ name: 'alpha', vmid: 2 }) - const result = getInstances() - expect(result).toHaveLength(2) - expect(result[0].name).toBe('alpha') - expect(result[1].name).toBe('zebra') - }) + createInstance({ name: 'zebra', state: 'deployed', stack: 'production', vmid: 1, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + createInstance({ name: 'alpha', state: 'deployed', stack: 'production', vmid: 2, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + const result = getInstances(); + expect(result[0].name).toBe('alpha'); + expect(result[1].name).toBe('zebra'); + }); it('filters by state', () => { - insert({ name: 'a', vmid: 1, state: 'deployed' }) - insert({ name: 'b', vmid: 2, state: 'degraded' }) - insert({ name: 'c', vmid: 3, state: 'testing' }) - expect(getInstances({ state: 'deployed' })).toHaveLength(1) - expect(getInstances({ state: 'degraded' })).toHaveLength(1) - expect(getInstances({ state: 'testing' })).toHaveLength(1) - }) + createInstance({ name: 'a', state: 'deployed', stack: 'production', vmid: 1, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + createInstance({ name: 'b', state: 'degraded', stack: 'production', vmid: 2, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + createInstance({ name: 'c', state: 'testing', stack: 'development', vmid: 3, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + expect(getInstances({ state: 'deployed' })).toHaveLength(1); + expect(getInstances({ state: 'degraded' })).toHaveLength(1); + expect(getInstances({ state: 'testing' })).toHaveLength(1); + }); it('filters by stack', () => { - insert({ name: 'a', vmid: 1, stack: 'production' }) - insert({ name: 'b', vmid: 2, stack: 'development' }) - expect(getInstances({ stack: 'production' })).toHaveLength(1) - expect(getInstances({ stack: 'development' })).toHaveLength(1) - }) + createInstance({ name: 'a', state: 'deployed', stack: 'production', vmid: 1, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + createInstance({ name: 'b', state: 'testing', stack: 'development', vmid: 2, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + expect(getInstances({ stack: 'production' })).toHaveLength(1); + expect(getInstances({ stack: 'development' })).toHaveLength(1); + }); it('searches by name', () => { - insert({ name: 'plex', vmid: 1 }) - insert({ name: 'gitea', vmid: 2 }) - expect(getInstances({ search: 'ple' })).toHaveLength(1) - expect(getInstances({ search: 'ple' })[0].name).toBe('plex') - }) + createInstance({ name: 'plex', state: 'deployed', stack: 'production', vmid: 1, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + createInstance({ name: 'gitea', state: 'deployed', stack: 'production', vmid: 2, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + expect(getInstances({ search: 'ple' })).toHaveLength(1); + expect(getInstances({ search: 'ple' })[0].name).toBe('plex'); + }); it('searches by vmid', () => { - insert({ name: 'a', vmid: 137 }) - insert({ name: 'b', vmid: 200 }) - expect(getInstances({ search: '137' })).toHaveLength(1) - }) + createInstance({ name: 'a', state: 'deployed', stack: 'production', vmid: 137, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + createInstance({ name: 'b', state: 'deployed', stack: 'production', vmid: 200, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + expect(getInstances({ search: '137' })).toHaveLength(1); + }); - it('searches by stack', () => { - insert({ name: 'a', vmid: 1, stack: 'production' }) - insert({ name: 'b', vmid: 2, stack: 'development' }) - expect(getInstances({ search: 'prod' })).toHaveLength(1) - }) + it('combines filters', () => { + createInstance({ name: 'plex', state: 'deployed', stack: 'production', vmid: 1, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + createInstance({ name: 'plex2', state: 'degraded', stack: 'production', vmid: 2, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + expect(getInstances({ search: 'plex', state: 'deployed' })).toHaveLength(1); + }); +}); - it('combines search and state filters', () => { - insert({ name: 'plex', vmid: 1, state: 'deployed' }) - insert({ name: 'plex2', vmid: 2, state: 'degraded' }) - expect(getInstances({ search: 'plex', state: 'deployed' })).toHaveLength(1) - }) - - it('returns empty array when no results match', () => { - insert({ name: 'plex', vmid: 1 }) - expect(getInstances({ search: 'zzz' })).toEqual([]) - }) -}) +// ── getInstance ─────────────────────────────────────────────────────────────── describe('getInstance', () => { it('returns the instance with the given vmid', () => { - insert({ name: 'plex', vmid: 117 }) - const inst = getInstance(117) - expect(inst).not.toBeNull() - expect(inst.name).toBe('plex') - expect(inst.vmid).toBe(117) - }) + createInstance({ name: 'plex', state: 'deployed', stack: 'production', vmid: 117, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + const inst = getInstance(117); + expect(inst).not.toBeNull(); + expect(inst.name).toBe('plex'); + expect(inst.vmid).toBe(117); + }); - it('returns null for an unknown vmid', () => { - expect(getInstance(999)).toBeNull() - }) -}) + it('returns null for unknown vmid', () => { + expect(getInstance(999)).toBeNull(); + }); +}); + +// ── getDistinctStacks ───────────────────────────────────────────────────────── describe('getDistinctStacks', () => { - it('returns empty array when no instances exist', () => { - expect(getDistinctStacks()).toEqual([]) - }) + it('returns empty array when table is empty', () => { + expect(getDistinctStacks()).toEqual([]); + }); it('returns unique stacks sorted alphabetically', () => { - insert({ vmid: 1, stack: 'production' }) - insert({ vmid: 2, stack: 'development' }) - insert({ vmid: 3, stack: 'production' }) - expect(getDistinctStacks()).toEqual(['development', 'production']) - }) + createInstance({ name: 'a', state: 'deployed', stack: 'production', vmid: 1, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + createInstance({ name: 'b', state: 'testing', stack: 'development', vmid: 2, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + createInstance({ name: 'c', state: 'deployed', stack: 'production', vmid: 3, atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }); + expect(getDistinctStacks()).toEqual(['development', 'production']); + }); +}); - it('excludes blank stack values', () => { - insert({ vmid: 1, stack: '' }) - insert({ vmid: 2, stack: 'production' }) - expect(getDistinctStacks()).toEqual(['production']) - }) -}) +// ── createInstance ──────────────────────────────────────────────────────────── describe('createInstance', () => { - it('inserts a new instance', () => { - insert({ name: 'traefik', vmid: 100, stack: 'production', state: 'deployed' }) - const inst = getInstance(100) - expect(inst.name).toBe('traefik') - expect(inst.stack).toBe('production') - expect(inst.state).toBe('deployed') - }) + const base = { state: 'deployed', stack: 'production', atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }; + + it('inserts a new instance and sets timestamps', () => { + createInstance({ ...base, name: 'traefik', vmid: 100 }); + const inst = getInstance(100); + expect(inst.name).toBe('traefik'); + expect(inst.created_at).not.toBeNull(); + expect(inst.updated_at).not.toBeNull(); + }); it('stores service flags correctly', () => { - insert({ vmid: 1, atlas: 1, argus: 0, tailscale: 1, hardware_acceleration: 1 }) - const inst = getInstance(1) - expect(inst.atlas).toBe(1) - expect(inst.argus).toBe(0) - expect(inst.tailscale).toBe(1) - expect(inst.hardware_acceleration).toBe(1) - }) + createInstance({ ...base, name: 'plex', vmid: 1, atlas: 1, tailscale: 1, hardware_acceleration: 1 }); + const inst = getInstance(1); + expect(inst.atlas).toBe(1); + expect(inst.argus).toBe(0); + expect(inst.tailscale).toBe(1); + expect(inst.hardware_acceleration).toBe(1); + }); it('rejects duplicate vmid', () => { - insert({ vmid: 100 }) - expect(() => insert({ name: 'other', vmid: 100 })).toThrow() - }) + createInstance({ ...base, name: 'a', vmid: 100 }); + expect(() => createInstance({ ...base, name: 'b', vmid: 100 })).toThrow(); + }); - it('sets createdAt and updatedAt on insert', () => { - insert({ vmid: 1 }) - const inst = getInstance(1) - expect(inst.createdAt).not.toBeNull() - expect(inst.updatedAt).not.toBeNull() - }) -}) + it('rejects invalid state', () => { + expect(() => createInstance({ ...base, name: 'a', vmid: 1, state: 'invalid' })).toThrow(); + }); + + it('rejects invalid stack', () => { + expect(() => createInstance({ ...base, name: 'a', vmid: 1, stack: 'invalid' })).toThrow(); + }); +}); + +// ── updateInstance ──────────────────────────────────────────────────────────── describe('updateInstance', () => { - it('updates fields on an existing instance', () => { - insert({ name: 'old-name', vmid: 100, state: 'testing', stack: 'development' }) - const before = getInstance(100) - db.run( - `UPDATE instances SET name=?, state=?, stack=?, updatedAt=datetime('now') WHERE id=?`, - ['new-name', 'deployed', 'production', before.id] - ) - const after = getInstance(100) - expect(after.name).toBe('new-name') - expect(after.state).toBe('deployed') - expect(after.stack).toBe('production') - }) + const base = { state: 'deployed', stack: 'production', atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }; - it('updates updatedAt on write', () => { - insert({ vmid: 1 }) - const before = getInstance(1) - db.run(`UPDATE instances SET name=?, updatedAt=datetime('now') WHERE id=?`, ['updated', before.id]) - const after = getInstance(1) - expect(after.updatedAt).not.toBeNull() - }) -}) + it('updates fields and refreshes updated_at', () => { + createInstance({ ...base, name: 'old', vmid: 100 }); + updateInstance(100, { ...base, name: 'new', vmid: 100, state: 'degraded' }); + const inst = getInstance(100); + expect(inst.name).toBe('new'); + expect(inst.state).toBe('degraded'); + }); + + it('can change vmid', () => { + createInstance({ ...base, name: 'a', vmid: 100 }); + updateInstance(100, { ...base, name: 'a', vmid: 200 }); + expect(getInstance(100)).toBeNull(); + expect(getInstance(200)).not.toBeNull(); + }); +}); + +// ── deleteInstance ──────────────────────────────────────────────────────────── describe('deleteInstance', () => { + const base = { state: 'deployed', stack: 'production', atlas: 0, argus: 0, semaphore: 0, patchmon: 0, tailscale: 0, andromeda: 0, tailscale_ip: '', hardware_acceleration: 0 }; + it('removes the instance', () => { - insert({ vmid: 1 }) - const inst = getInstance(1) - db.run('DELETE FROM instances WHERE id = ?', [inst.id]) - expect(getInstance(1)).toBeNull() - }) + createInstance({ ...base, name: 'a', vmid: 1 }); + deleteInstance(1); + expect(getInstance(1)).toBeNull(); + }); it('only removes the targeted instance', () => { - insert({ name: 'a', vmid: 1 }) - insert({ name: 'b', vmid: 2 }) - const inst = getInstance(1) - db.run('DELETE FROM instances WHERE id = ?', [inst.id]) - expect(getInstance(1)).toBeNull() - expect(getInstance(2)).not.toBeNull() - }) -}) + createInstance({ ...base, name: 'a', vmid: 1 }); + createInstance({ ...base, name: 'b', vmid: 2 }); + deleteInstance(1); + expect(getInstance(1)).toBeNull(); + expect(getInstance(2)).not.toBeNull(); + }); +}); diff --git a/tests/helpers.test.js b/tests/helpers.test.js index 0ead3b9..dc3a809 100644 --- a/tests/helpers.test.js +++ b/tests/helpers.test.js @@ -1,3 +1,4 @@ +// @vitest-environment jsdom import { describe, it, expect } from 'vitest' // ── esc() ───────────────────────────────────────────────────────────────────── diff --git a/vitest.config.js b/vitest.config.js index 68e3449..2b1c323 100644 --- a/vitest.config.js +++ b/vitest.config.js @@ -2,6 +2,6 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { - environment: 'jsdom', + environment: 'node', }, })