Fix issue #8: Sync toggle on foundry

This commit is contained in:
Gitea OpenCode Agent
2026-10-13 23:02:43 +00:00
parent af76cf1050
commit 7d19a22a4b
6 changed files with 439 additions and 9 deletions

View File

@@ -12,8 +12,10 @@ dice widgets, shared markdown, sounds). It is a two-app monorepo:
- `backend/` — Node + **Express 5** + **Mongoose 9** (MongoDB) REST API, JWT auth. CommonJS.
- `frontend/` — **Nuxt 4 / Vue 3** client (Composition API, `<script setup>`), SCSS, axios, marked, mitt, motion.
There is **no** database seeding, no ORM migrations, no test suite, no linter/formatter config, no
Pinia/Vuex, and no Vue Router pages (see §5.1 — the UI is a window manager, not routed pages).
There is **no** database seeding, no ORM migrations, no linter/formatter config, no Pinia/Vuex, and no
Vue Router pages (see §5.1 — the UI is a window manager, not routed pages). The only automated tests
are `tests/*.test.js` (`npm test`, Node's built-in runner), which exercise the Foundry module's sync
logic against stubbed Foundry globals.
Git: default branch `master`, hosted on a self-hosted Gitea (`git.aranroig.com/BinarySandia04/Dragonroll`).
CI (`.gitea/workflows/deploy.yml`) builds two Docker images on every push to `master`, pushes them to
@@ -31,6 +33,7 @@ dragonroll/
├── ecosystem.config.js PM2 config (stale: runs `npm start`, which does not exist — see §9)
├── .gitea/workflows/deploy.yml
├── static/media/ README logo images only
├── tests/ `node --test` tests (Foundry module sync toggle)
├── package.json root: only `concurrently`, used by `npm run dev`
└── README.md install/run instructions are STALE (see §9)
```
@@ -49,10 +52,13 @@ npm --prefix backend run dev # backend only
npm --prefix frontend run dev # frontend only
npm --prefix frontend run build # nuxt build --dotenv .env.production
npm --prefix frontend run preview
npm test # node --test tests/ (Foundry module sync logic, no dependencies)
```
There is no `start` script in either package, no test command, and no lint command.
Verification = run the dev server and exercise the flow (`/api/test` returns a JSON hello).
There is no `start` script in either package and no lint command.
Verification = run the dev server and exercise the flow (`/api/test` returns a JSON hello);
`npm test` covers the Foundry character/item sync toggle and per-actor force sync.
### Environment files
@@ -240,6 +246,10 @@ Rules worth knowing before editing this:
which the sync skips.
- **`fullSync` preserves Dragonroll edits** (only new rows are overwritten); live Foundry events
overwrite. Item pruning requires the full snapshot, since only it sees world items and actor copies.
- **Autosync is a Foundry-side switch** (`autoSync` client setting, on by default): when off, the
module queues no CRUD push, runs no periodic reconcile and sends no startup snapshot; the actor
directory's `Dragonroll: Force Sync` entry still pushes the selected actors as an upsert
(`fullSync:false`, so it never prunes). The read-only bridge snapshot is not gated by it.
- `Actor.inventory` stays a flattened copy of the actor's embedded items; it is not linked to `Item`.
- `GET /api/foundry/*` (`routes/foundry.js`) is unrelated: a JWT-protected proxy over the read-only
bridge, only useful when `FOUNDRY_API_URL` is configured.