Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdfd835a3c |
No files matched your search
@@ -2,8 +2,10 @@
|
||||
description: Cloud edition implementation details, PostgreSQL Row-Level Security (RLS) isolation, cross-subdomain auth, and cryptographic license keys.
|
||||
paths:
|
||||
- "src/lib/auth*"
|
||||
- "src/lib/auth/**/*"
|
||||
- "src/app/api/auth/**/*"
|
||||
- "src/core/auth.ts"
|
||||
- "src/core/storage.ts"
|
||||
- "src/core/tenant.ts"
|
||||
---
|
||||
|
||||
> **SUPERSEDED by ADR-003** (`docs/architecture/decisions/adr-0003-shared-identity-and-ecosystem-auth-host.md`).
|
||||
@@ -175,15 +177,13 @@ DATABASE_URL=postgresql://...
|
||||
|
||||
## Edition Adapters
|
||||
|
||||
Three thin adapter modules provide all edition-specific behaviour -- everything else is edition-unaware:
|
||||
Three thin files are all that differs between editions — everything else is edition-unaware:
|
||||
|
||||
| Adapter | Local | Cloud | Demo |
|
||||
|---|---|---|---|
|
||||
| `src/lib/auth.ts` | Auth.js `Credentials` (bcrypt + PostgreSQL) | Auth.js `@auth/supabase-adapter` | Disabled |
|
||||
| Storage adapter (planned) | `fs.writeFile()` to `data/` | Supabase Storage SDK | Read-only |
|
||||
| Tenant adapter (planned) | No-op (single tenant) | Sets `app.tenant_id` for RLS | No-op |
|
||||
|
||||
> The storage and tenant adapters listed above are planned for the Cloud edition build-out and are not yet implemented as separate files. Auth is fully implemented in `src/lib/auth.ts` and `src/lib/auth.config.ts`.
|
||||
| `src/core/auth.ts` | Auth.js `Credentials` (bcrypt + PostgreSQL) | Auth.js `@auth/supabase-adapter` | Disabled |
|
||||
| `src/core/storage.ts` | `fs.writeFile()` to `data/` | Supabase Storage SDK | Read-only |
|
||||
| `src/core/tenant.ts` | No-op (single tenant) | Sets `app.tenant_id` for RLS | No-op |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -89,60 +89,3 @@ This means:
|
||||
|
||||
> [!CAUTION]
|
||||
> The most common silent bug: seeder sends `{ items: [...] }` (an object), frontend plugin omits `mapWebsocketPayload`. Data arrives but WsClient drops it with a console warning. The globe stays empty. Always implement `mapWebsocketPayload` for any plugin whose seeder sends an object payload.
|
||||
|
||||
## 8. Seeder Authoring Contract — the module shape
|
||||
|
||||
§7 covers what a seeder **sends**. This covers how you **write** one. The engine
|
||||
auto-discovers a seeder by scanning `SEEDERS_DIR` for any folder with
|
||||
`dist/index.mjs` and importing its **default export**. The seeder's `id` is the
|
||||
**folder name**, not the `name` field. You never call a register function — the
|
||||
authoritative reference is `wwv-data-engine/README.md` → "Authoring a Seeder".
|
||||
|
||||
The default export is `{ name }` plus **one** of these shapes:
|
||||
|
||||
| Shape | You provide | How data is published |
|
||||
|---|---|---|
|
||||
| `interval` + `fetch(ctx)` | `fetch` **returns** the array | scheduler wraps + stores + broadcasts it for you |
|
||||
| `cron` + `fn(ctx)` | `fn` publishes itself | `import { setLiveSnapshot } from '@worldwideview/seeder-sdk'` and call it |
|
||||
| `init(ctx)` | a persistent listener | publish via the SDK as push data arrives |
|
||||
|
||||
**The trap (this caused a real, silent CI failure):** `ctx` is **only `{ redis }`**.
|
||||
There is no `ctx.setLiveSnapshot`. Reaching for it throws at runtime and the
|
||||
snapshot never lands. Publish helpers come from `@worldwideview/seeder-sdk`, not
|
||||
from `ctx`. The engine now types `ctx` as `SeederContext { redis }`, so this is a
|
||||
compile error for any typed seeder — but `.mjs` seeders without type-checking get
|
||||
no such safety net, so know the contract.
|
||||
|
||||
<bad-example>
|
||||
```ts
|
||||
// cron + fn reaching for a method that does not exist on ctx
|
||||
export default {
|
||||
name: "earthquakes",
|
||||
cron: "0 * * * *",
|
||||
fn: async (ctx) => {
|
||||
await ctx.setLiveSnapshot("earthquakes", items, 3600); // ❌ not a function — dies silently
|
||||
},
|
||||
};
|
||||
```
|
||||
</bad-example>
|
||||
|
||||
<good-example>
|
||||
```ts
|
||||
// Option A — cron + fn: publish via the SDK (dominant idiom)
|
||||
import { setLiveSnapshot } from "@worldwideview/seeder-sdk";
|
||||
export default {
|
||||
name: "earthquakes",
|
||||
cron: "0 * * * *",
|
||||
fn: async () => {
|
||||
await setLiveSnapshot("earthquakes", { source: "earthquakes", fetchedAt: new Date().toISOString(), items, totalCount: items.length }, 3600);
|
||||
},
|
||||
};
|
||||
|
||||
// Option B — interval + fetch: just return the array, scheduler does the rest
|
||||
export default {
|
||||
name: "earthquakes",
|
||||
interval: 60_000,
|
||||
fetch: async () => items, // ✅ no publishing call needed
|
||||
};
|
||||
```
|
||||
</good-example>
|
||||
@@ -206,10 +206,18 @@ Hard refresh: `Ctrl+Shift+R`
|
||||
|
||||
## Creating Static OSM Plugins
|
||||
|
||||
Use the `plugin-new` skill (`.agents/skills/plugin-new/SKILL.md`) to scaffold new plugins, including OSM-based static data plugins. The old `scaffold-osm-plugin.mjs` script and `osm-static-plugin-creation.md` skill were removed; static OSM plugins are now built as standard `bundle` format plugins via the wwv-cli:
|
||||
See full guide: `.agents/skills/osm-static-plugin-creation.md`
|
||||
|
||||
**Quick start:**
|
||||
```bash
|
||||
node packages/wwv-cli/dist/index.js create <name> --local
|
||||
node scripts/scaffold-osm-plugin.mjs '{
|
||||
"name": "volcanoes",
|
||||
"displayName": "Volcanoes",
|
||||
"osmTag": "natural=volcano",
|
||||
"icon": "Mountain",
|
||||
"color": "#ef4444",
|
||||
"category": "Natural Disaster"
|
||||
}'
|
||||
```
|
||||
|
||||
**Manual Overpass API query (PowerShell):**
|
||||
@@ -219,29 +227,26 @@ $body = "data=[out:json][timeout:300];(node[$tag];way[$tag];relation[$tag];);out
|
||||
Invoke-RestMethod -Uri 'https://overpass-api.de/api/interpreter' -Method Post -Body $body -OutFile 'tmp/raw_data.json'
|
||||
```
|
||||
|
||||
**Note:** OSM data is licensed under **ODbL** - include attribution in plugin READMEs.
|
||||
**Note:** OSM data is licensed under **ODbL** — include attribution in plugin READMEs.
|
||||
|
||||
---
|
||||
|
||||
## npm Plugin Publishing
|
||||
|
||||
The `npm-plugin-publishing.md` skill was removed. Use the wwv-cli publish command:
|
||||
See full guide: `.agents/skills/version-control/npm-plugin-publishing.md`
|
||||
|
||||
```bash
|
||||
# Publish a local plugin
|
||||
node packages/wwv-cli/dist/index.js publish <name> [--org <your-org>]
|
||||
|
||||
# Or publish directly via pnpm (for packages/ workspace members)
|
||||
# First-time publish
|
||||
pnpm publish --workspace=packages/wwv-plugin-<name> --access public
|
||||
|
||||
# Future versions via Trusted Publishing (GitHub Actions CI/CD)
|
||||
# Future versions — via Trusted Publishing (GitHub Actions CI/CD)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Git / Version Control
|
||||
|
||||
The `git-version-control.md` skill was removed. See `.agents/skills/using-git-worktrees/SKILL.md` for worktree workflows and `.agents/skills/branch-cleanup/SKILL.md` for the post-merge teardown flow.
|
||||
See full guide: `.agents/skills/version-control/git-version-control.md`
|
||||
|
||||
**Commit convention:** `feat:`, `fix:`, `chore:`, `docs:` prefixes.
|
||||
**Commit when:** A new feature is completed (per project rules).
|
||||
@@ -250,7 +255,7 @@ The `git-version-control.md` skill was removed. See `.agents/skills/using-git-wo
|
||||
|
||||
## Security Checks
|
||||
|
||||
The `security-check.md` skill was removed. Security reviews are handled by the `security-reviewer` agent (`.agents/agents/security-reviewer.md`). Trigger it after any change touching auth routes, API routes, plugin loading, or marketplace flows.
|
||||
See full guide: `.agents/skills/security/security-check.md`
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ GET marketplace.worldwideview.dev/api/registry
|
||||
- Trust is **always stamped server-side** — no client-side trust claims accepted
|
||||
- Registry response cached for **5 minutes** (in-memory on each WWV instance)
|
||||
- If registry unreachable, last cached result used; new unknowns default to `unverified`
|
||||
- **Managing:** Use the marketplace admin API (`/api/admin/registry`) to manage the signed plugin registry. The old `src/data/verifiedPlugins.ts` static file was replaced by database-driven registry management.
|
||||
- **Managing:** Edit `src/data/verifiedPlugins.ts` in marketplace repo and redeploy
|
||||
- **Revoking:** Remove plugin ID and redeploy — WWV instances drop trust on next cache refresh
|
||||
|
||||
### Unverified Plugin Warning
|
||||
@@ -437,7 +437,7 @@ This queries Overpass API, converts to GeoJSON, scaffolds the package, and print
|
||||
| Power plants | `power=plant` | 15k |
|
||||
| Wind farms | `generator:source=wind` | 50k |
|
||||
|
||||
The `osm-static-plugin-creation.md` skill was removed. Use `node packages/wwv-cli/dist/index.js create <name> --local` to scaffold a new plugin, then populate it with OSM data fetched via the Overpass API.
|
||||
See skill: `.agents/skills/osm-static-plugin-creation.md`
|
||||
|
||||
---
|
||||
|
||||
@@ -462,7 +462,7 @@ To solve this friction and make third-party plugin hosting highly intuitive, the
|
||||
2. **Backend SDK:** They write simple `.ts` fetch scripts returning `GeoEntity[]` and drop them into a mounted `/seeders` volume.
|
||||
3. **Zero Configuration:** The Docker engine hot-reloads these seeders, handles the Redis caching, and exposes standardized REST or WebSocket endpoints automatically. The developer focuses only on fetching data, avoiding all backend infrastructure setup.
|
||||
|
||||
The `data-engine-seeder-creation.md` skill was removed. Seeder implementation rules are documented inline in `.agents/rules/data-engine-architecture.md`. Seeders live in `local-seeders/community/` or `local-seeders/private/` (separate git clones).
|
||||
See skill: `.agents/skills/data-engine-seeder-creation.md`
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
# /triage-issue
|
||||
|
||||
Triage a single GitHub issue in `silvertakana/worldwideview` per the project's [TRIAGE.md](../../TRIAGE.md) intake rules. Classifies the issue, recommends a disposition, and executes it after explicit user confirmation.
|
||||
|
||||
**Usage:** `/triage-issue <issue-number>`
|
||||
|
||||
`$ARGUMENTS` = the issue number to triage.
|
||||
|
||||
## Procedure
|
||||
|
||||
### 1. Fetch the issue
|
||||
|
||||
```bash
|
||||
gh issue view $ARGUMENTS --repo silvertakana/worldwideview --json number,title,body,labels,comments,author
|
||||
```
|
||||
|
||||
### 2. Classify
|
||||
|
||||
Determine the type from the title prefix and body:
|
||||
|
||||
| Signal | Type |
|
||||
|---|---|
|
||||
| `[PLUGIN]`, "data source", "show X on the globe" | **plugin-request** |
|
||||
| `[FEATURE]`, "feature request", capability not tied to a data source | **enhancement** |
|
||||
| `[BUG]`, error, stack trace, "doesn't work" | **bug** |
|
||||
| Open-ended question, no actionable ask | **question** |
|
||||
|
||||
### 3. Apply the TRIAGE.md rule
|
||||
|
||||
- **plugin-request:** vet the API first (dispatch the `plugin-researcher` agent if the source is unknown). Then apply the build/do-not-build rule (free API + renders something meaningful + fits the demo).
|
||||
- Viable -> propose: add a checklist line to #4, label `plugin-request` + `good first issue` + `help wanted`, close standalone with "Tracked in #4."
|
||||
- Not viable -> propose: close with the specific reason.
|
||||
- **enhancement:** propose: label `enhancement`, add a one-line ROADMAP backlog entry, keep open.
|
||||
- **bug:** propose: label `bug`, reproduce, then fix inline or route to the `debugger` agent.
|
||||
- **question:** draft a reply; propose answer-then-close.
|
||||
|
||||
### 4. Confirm before any state change
|
||||
|
||||
Present the classification and proposed actions as a short summary. **Do not** comment, label, pin, close, or edit anything until the user explicitly approves (per the project's "explicit user authorization before any state-changing action" rule). Comments are posted from the owner account, so they read as owner triage notes - keep them accurate and neutral.
|
||||
|
||||
### 5. Execute
|
||||
|
||||
On approval, run the `gh` commands for the approved actions only. Report each result with its URL.
|
||||
|
||||
## Notes
|
||||
|
||||
- Issue #4 (Plugin Wishlist) is the canonical pinned funnel for plugin ideas - never create a competing wishlist.
|
||||
- Never promise dates on `enhancement` issues.
|
||||
- See [TRIAGE.md](../../TRIAGE.md) for the full rationale and the build/do-not-build test.
|
||||
@@ -61,7 +61,6 @@ jobs:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=raw,value=ci,enable={{is_default_branch}}
|
||||
type=ref,event=branch
|
||||
type=sha,format=short
|
||||
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
# Trigger model: merge to main with a version bump in the relevant package.json is the
|
||||
# intended signal. This workflow checks npm for the exact version before publishing, so
|
||||
# re-running on an already-published version is safe and idempotent.
|
||||
#
|
||||
# Auth: a single npm granular token scoped to @worldwideview/*, stored as the
|
||||
# org-level GitHub secret NPM_TOKEN. One secret covers every @worldwideview package
|
||||
# (these libs + all wwv-plugins), so no per-package setup is needed. `actions/setup-node`
|
||||
# (with registry-url) writes an .npmrc that reads NODE_AUTH_TOKEN. We still request
|
||||
# `id-token: write` and pass `--provenance` so npm records a signed build-provenance
|
||||
# attestation (provenance works with token auth; it does NOT require per-package config).
|
||||
#
|
||||
# Publish tool: we use `npm publish` (not `pnpm publish`). Correct ONLY while these packages
|
||||
# have no `workspace:*` dependencies (npm does not rewrite the workspace: protocol). The 3
|
||||
# packages here have none (sdk -> react peer; libs -> sdk peer via a semver range). If any
|
||||
# package later adds a `workspace:*` dependency, switch its publish step to
|
||||
# `pnpm publish --no-git-checks`.
|
||||
|
||||
name: Publish Packages to npm
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
# Serialize runs so two fast-follow merges can't both pass the version-check and then
|
||||
# race to publish the same version (npm would 403 the loser). Never cancel an in-flight
|
||||
# publish.
|
||||
concurrency:
|
||||
group: publish-packages
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
# id-token: write is for build-provenance attestation (not auth); scope to this job.
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
# Auth for every npm publish step in this job (setup-node reads NODE_AUTH_TOKEN).
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: pnpm/action-setup@v6
|
||||
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 20
|
||||
registry-url: https://registry.npmjs.org
|
||||
cache: pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build wwv-plugin-sdk
|
||||
run: pnpm --filter @worldwideview/wwv-plugin-sdk run build
|
||||
|
||||
- name: Publish @worldwideview/wwv-plugin-sdk
|
||||
run: |
|
||||
LOCAL_VERSION=$(node -p "require('./packages/wwv-plugin-sdk/package.json').version")
|
||||
# Equality check (not exit-code): only skip when that EXACT version is already on
|
||||
# npm. An unpublished-yet-existing package returns empty here -> we publish. --silent
|
||||
# keeps npm notices off stdout so the comparison stays clean.
|
||||
NPM_VERSION=$(npm view "@worldwideview/wwv-plugin-sdk@${LOCAL_VERSION}" version --silent 2>/dev/null || true)
|
||||
if [ "$NPM_VERSION" = "$LOCAL_VERSION" ]; then
|
||||
echo "@worldwideview/wwv-plugin-sdk@${LOCAL_VERSION} already published — skipping"
|
||||
else
|
||||
echo "Publishing @worldwideview/wwv-plugin-sdk@${LOCAL_VERSION}"
|
||||
npm publish ./packages/wwv-plugin-sdk --provenance --access public
|
||||
fi
|
||||
|
||||
- name: Publish @worldwideview/wwv-lib-incidents
|
||||
run: |
|
||||
LOCAL_VERSION=$(node -p "require('./packages/wwv-lib-incidents/package.json').version")
|
||||
NPM_VERSION=$(npm view "@worldwideview/wwv-lib-incidents@${LOCAL_VERSION}" version --silent 2>/dev/null || true)
|
||||
if [ "$NPM_VERSION" = "$LOCAL_VERSION" ]; then
|
||||
echo "@worldwideview/wwv-lib-incidents@${LOCAL_VERSION} already published — skipping"
|
||||
else
|
||||
echo "Publishing @worldwideview/wwv-lib-incidents@${LOCAL_VERSION}"
|
||||
npm publish ./packages/wwv-lib-incidents --provenance --access public
|
||||
fi
|
||||
|
||||
- name: Publish @worldwideview/wwv-lib-aviation
|
||||
run: |
|
||||
LOCAL_VERSION=$(node -p "require('./packages/wwv-lib-aviation/package.json').version")
|
||||
NPM_VERSION=$(npm view "@worldwideview/wwv-lib-aviation@${LOCAL_VERSION}" version --silent 2>/dev/null || true)
|
||||
if [ "$NPM_VERSION" = "$LOCAL_VERSION" ]; then
|
||||
echo "@worldwideview/wwv-lib-aviation@${LOCAL_VERSION} already published — skipping"
|
||||
else
|
||||
echo "Publishing @worldwideview/wwv-lib-aviation@${LOCAL_VERSION}"
|
||||
npm publish ./packages/wwv-lib-aviation --provenance --access public
|
||||
fi
|
||||
@@ -0,0 +1,38 @@
|
||||
name: Publish Plugin to NPM
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "wwv-plugin-*-v*" # e.g. wwv-plugin-aviation-v1.0.1
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write # Required for OIDC trusted publishing (no NPM_TOKEN needed)
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 20
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Detect package name from tag
|
||||
id: pkg
|
||||
run: |
|
||||
TAG="${{ github.ref_name }}"
|
||||
# Strips the -vX.Y.Z suffix: "wwv-plugin-aviation-v1.0.1" → "wwv-plugin-aviation"
|
||||
PKG=$(echo "$TAG" | sed 's/-v[0-9].*//')
|
||||
echo "package=$PKG" >> $GITHUB_OUTPUT
|
||||
echo "Publishing: $PKG"
|
||||
|
||||
- name: Build package
|
||||
run: npm run build -w packages/${{ steps.pkg.outputs.package }}
|
||||
|
||||
- name: Publish to NPM (OIDC)
|
||||
run: npm publish packages/${{ steps.pkg.outputs.package }} --access public --provenance
|
||||
@@ -1,122 +0,0 @@
|
||||
---
|
||||
phase: 17-instance-picker-ui-overhaul
|
||||
plan: "01"
|
||||
subsystem: marketplace-instance-data-layer
|
||||
tags: [api, tdd, validation, prisma, auth]
|
||||
dependency_graph:
|
||||
requires: []
|
||||
provides: [SavedInstance-lastUsedAt, GET-me-instances-fixed, validateInstanceUrl, POST-instances-link, DELETE-PATCH-instances-id]
|
||||
affects: [InstancePicker, InstanceHydrator, InstanceCapture, InstanceConfig]
|
||||
tech_stack:
|
||||
added: []
|
||||
patterns: [discriminated-union, idempotent-upsert, ownership-check-404, tdd-red-green]
|
||||
key_files:
|
||||
created:
|
||||
- C:/dev/wwv/worldwideview-marketplace/src/lib/instanceValidation.ts
|
||||
- C:/dev/wwv/worldwideview-marketplace/src/lib/instanceValidation.spec.ts
|
||||
- C:/dev/wwv/worldwideview-marketplace/src/app/api/instances/link/route.ts
|
||||
- C:/dev/wwv/worldwideview-marketplace/src/app/api/instances/[id]/route.ts
|
||||
- C:/dev/wwv/worldwideview-marketplace/src/app/api/instances/link/route.test.ts
|
||||
modified:
|
||||
- C:/dev/wwv/worldwideview-marketplace/src/lib/instanceStore.ts
|
||||
- C:/dev/wwv/worldwideview-marketplace/src/app/api/me/instances/route.ts
|
||||
- C:/dev/wwv/worldwideview-marketplace/src/app/api/me/instances/route.test.ts
|
||||
decisions:
|
||||
- "GET /api/me/instances kept at current URL - not renamed to /api/instances"
|
||||
- "Anon callers still receive 200 + empty array - no 401 switch"
|
||||
- "SavedInstance gets lastUsedAt only - createdAt deliberately excluded per plan"
|
||||
- "Route test mocks updated to reflect getOrCreateMarketplaceUser addition (Rule 1 fix)"
|
||||
metrics:
|
||||
duration: "~25 minutes"
|
||||
completed: "2026-05-30"
|
||||
tasks_completed: 3
|
||||
files_changed: 8
|
||||
---
|
||||
|
||||
# Phase 17 Plan 01: Instance Data Layer Summary
|
||||
|
||||
**One-liner:** Server-side instance sync data layer with idempotent upsert, URL validation discriminated union, and ownership-checked CRUD routes.
|
||||
|
||||
## Tasks Completed
|
||||
|
||||
| Task | Name | Commit | Files |
|
||||
|------|------|--------|-------|
|
||||
| 1 | Add lastUsedAt to SavedInstance + fix GET | 421a5b8 | instanceStore.ts, me/instances/route.ts |
|
||||
| 2 (RED) | validateInstanceUrl failing tests | 269cad1 | instanceValidation.spec.ts |
|
||||
| 2 (GREEN) | validateInstanceUrl implementation | 9a3fcb7 | instanceValidation.ts |
|
||||
| 3 (RED) | link route failing tests | 20c7ea0 | instances/link/route.test.ts |
|
||||
| 3 (GREEN) | link + [id] routes implementation | e69ebca | instances/link/route.ts, instances/[id]/route.ts, route.test.ts fix |
|
||||
|
||||
## What Was Built
|
||||
|
||||
**Task 1** fixed two issues in the existing GET route:
|
||||
- `SavedInstance` interface now includes `lastUsedAt: string` (no `createdAt` per plan)
|
||||
- GET route now calls `getOrCreateMarketplaceUser` to resolve the marketplace cuid before querying `LinkedInstance.userId`. The previous bug queried with the raw Supabase user id, so rows written by `/api/install/start` (which use the marketplace cuid) were never returned.
|
||||
- `lastUsedAt` added to the SELECT
|
||||
- Anonymous callers still receive `200 + { instances: [] }` - no auth-contract regression
|
||||
|
||||
**Task 2** ported `instanceValidation.ts` with full TDD:
|
||||
- `InstanceValidationResult` discriminated union: `{ ok: true; url: string } | { ok: false; reason: string }`
|
||||
- `validateInstanceUrl(raw, marketplaceOrigin)` normalises to `parsed.origin`, rejects non-http(s), self-loops, unparseable, empty/null
|
||||
- 8 Vitest cases (split null/undefined case and empty-string into separate `it` blocks)
|
||||
- RED commit preceded GREEN commit
|
||||
|
||||
**Task 3** ported both write routes with TDD:
|
||||
- `POST /api/instances/link`: idempotent upsert via `userId_url` compound key, bumps `lastUsedAt` on repeat
|
||||
- `DELETE /api/instances/[id]`: ownership check via `findFirst { id, userId }`; returns 404 (never 403)
|
||||
- `PATCH /api/instances/[id]`: nickname trimmed to 80 chars, null clears field; 404 for non-owned
|
||||
- Link route unit tests: 401 for anon + upsert called with correct `userId_url`
|
||||
- RED commit preceded GREEN commit
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug] Existing route.test.ts for GET /api/me/instances broken by Task 1**
|
||||
- **Found during:** Task 3 full test run
|
||||
- **Issue:** The existing `src/app/api/me/instances/route.test.ts` mocked `prisma` without `user.findUnique` and did not mock `getOrCreateMarketplaceUser`. After Task 1 added `getOrCreateMarketplaceUser` to the route, the test threw `TypeError: Cannot read properties of undefined (reading 'findUnique')`.
|
||||
- **Fix:** Updated the test to mock `getOrCreateMarketplaceUser`, updated prisma mock (no longer needs `user` table), and adjusted assertions to use marketplace user id (`mkt-456`) instead of raw supabase id.
|
||||
- **Files modified:** `src/app/api/me/instances/route.test.ts`
|
||||
- **Commit:** e69ebca (bundled with Task 3 GREEN)
|
||||
|
||||
### Pre-existing Failures (Out of Scope)
|
||||
|
||||
- `src/app/oauth/authorize/actions.spec.ts` has 1 failing test that existed before this plan. Verified by stash-and-test. Not caused by any change in this plan. Logged for deferred attention.
|
||||
|
||||
## TDD Gate Compliance
|
||||
|
||||
| Gate | Commit | Status |
|
||||
|------|--------|--------|
|
||||
| Task 2 RED | 269cad1 | test(17-01): add failing tests for validateInstanceUrl (RED) |
|
||||
| Task 2 GREEN | 9a3fcb7 | feat(17-01): implement validateInstanceUrl (GREEN) |
|
||||
| Task 3 RED | 20c7ea0 | test(17-01): add failing tests for POST /api/instances/link (RED) |
|
||||
| Task 3 GREEN | e69ebca | feat(17-01): create POST /api/instances/link + DELETE/PATCH /api/instances/[id] (GREEN) |
|
||||
|
||||
Both TDD cycles satisfied: RED commit preceded GREEN commit for Tasks 2 and 3.
|
||||
|
||||
## Known Stubs
|
||||
|
||||
None. All routes are fully implemented and wired to live Prisma queries.
|
||||
|
||||
## Threat Surface Scan
|
||||
|
||||
All mitigations from the plan's threat model are present:
|
||||
- T-17-01: `validateInstanceUrl` rejects non-http(s), unparseable, marketplace self-origin; only `parsed.origin` stored
|
||||
- T-17-02: DELETE/PATCH use `findFirst { id, userId }` ownership check; return 404 (not 403)
|
||||
- T-17-03: GET uses `getOrCreateMarketplaceUser` scoped to caller's marketplace cuid
|
||||
- T-17-04: PATCH trims nickname to 80 chars before persist
|
||||
|
||||
No new security surface introduced beyond what the threat model covers.
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- `src/lib/instanceStore.ts` - FOUND, contains `lastUsedAt: string`
|
||||
- `src/app/api/me/instances/route.ts` - FOUND, uses `getOrCreateMarketplaceUser`
|
||||
- `src/lib/instanceValidation.ts` - FOUND, exports `validateInstanceUrl`
|
||||
- `src/lib/instanceValidation.spec.ts` - FOUND, 8 `it(` blocks
|
||||
- `src/app/api/instances/link/route.ts` - FOUND, exports `POST`
|
||||
- `src/app/api/instances/[id]/route.ts` - FOUND, exports `DELETE` and `PATCH`
|
||||
- `src/app/api/instances/link/route.test.ts` - FOUND, 2 tests pass
|
||||
- Commits 421a5b8, 269cad1, 9a3fcb7, 20c7ea0, e69ebca - all present in git log
|
||||
- `npx tsc --noEmit` - no errors
|
||||
- `pnpm test` - 75 passed, 1 pre-existing failure (oauth, out of scope)
|
||||
@@ -60,7 +60,6 @@ Agents MUST respect these at all times:
|
||||
> - **MUST** require explicit user authorization before any state-changing action that isn't simple/safe.
|
||||
> - **MUST** ask clarifying questions rather than assume when requirements are unclear.
|
||||
> - **MUST** update `.agents/rules/` files immediately whenever an architectural shift invalidates them.
|
||||
> - **MUST** close context gaps: when missing/wrong/undocumented context made you err, struggle, or go slow, fix the relevant doc/context (or add a type/guardrail) at its source — or ask the user to update it when it depends on their knowledge. In autonomous mode, log the gap to revisit later. Never fix only the symptom and leave the trap armed for the next contributor.
|
||||
|
||||
---
|
||||
|
||||
@@ -133,7 +132,6 @@ See `.agents/context/INDEX.md` for the full navigation table. Key files:
|
||||
| `/five` | Five Whys root cause analysis | `.agents/workflows/five.md` |
|
||||
| `/stitch-to-nextjs` | Generate UI with Stitch MCP, port into Next.js | `.agents/workflows/stitch-to-nextjs.md` |
|
||||
| `/branch-cleanup` | **Post-merge teardown** — commit leftovers, delete plan file, remove worktree via worktree-manager | `.agents/skills/branch-cleanup/SKILL.md` |
|
||||
| `/triage-issue` | Triage a single issue (plugin/feature/bug/question) per `TRIAGE.md`; confirm before any state change | `.agents/workflows/triage-issue.md` |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
# Issue Triage Guide
|
||||
|
||||
How incoming **plugin requests** and **feature requests** are handled in `silvertakana/worldwideview`. The goal is a consistent, low-effort intake so nothing rots and contributors always know where their idea stands.
|
||||
|
||||
Run `/triage-issue <number>` to apply this guide to a specific issue.
|
||||
|
||||
## 1. Intake types and labels
|
||||
|
||||
Every non-bug request is one of two types:
|
||||
|
||||
| Type | What it is | Label | Examples |
|
||||
|---|---|---|---|
|
||||
| **Plugin request** | A new data source to render on the globe | `plugin-request` | BirdNET (#148), ISS tracker, AIS ships |
|
||||
| **Feature request** | A platform capability, not a data source | `enhancement` | GeoJSON editor (#84), ontology layer (#138) |
|
||||
|
||||
Community-buildable plugin requests also get `good first issue` + `help wanted`.
|
||||
|
||||
## 2. Plugin requests funnel into #4
|
||||
|
||||
[Issue #4 - Plugin Wishlist](https://github.com/silvertakana/worldwideview/issues/4) is the **single pinned funnel** for plugin ideas. When a `[PLUGIN]` issue arrives:
|
||||
|
||||
1. **Vet the data source.** Is there a free, public API? Check rate limits and CORS. The `plugin-researcher` agent does this in about a minute.
|
||||
2. **If viable:** add it as a checklist line in #4, label the standalone `plugin-request` + `good first issue` + `help wanted`, then close the standalone with a note: "Tracked in the Plugin Wishlist #4." This keeps one canonical list instead of scattered duplicates.
|
||||
3. **If not viable** (no free API, paywalled, or geofenced - e.g. aviation/OpenSky in #149): close with the reason stated, so nobody re-opens the same dead end.
|
||||
|
||||
## 3. Feature requests stay open as tracking threads
|
||||
|
||||
1. Label `enhancement`.
|
||||
2. Add a one-line entry to the `.planning` ROADMAP backlog (shared root, see `WWV_SHARED_PLANNING`).
|
||||
3. Leave the issue **open** as the canonical tracking thread. Reply with status, but **promise no dates**.
|
||||
|
||||
## 4. The build / do-not-build rule
|
||||
|
||||
Only build a plugin yourself (or kick off the `/plugin-new` pipeline) when **all three** hold:
|
||||
|
||||
1. **Free API exists** - no paywall, usable rate limits.
|
||||
2. **Renders something meaningful** - points, paths, or regions on the globe, not just a number.
|
||||
3. **Fits the demo** - relevant to the live `demo` edition, not a niche one-off.
|
||||
|
||||
If any one fails, it lives in the wishlist (#4) for community contributors. The same three-part test is why aviation was pulled from the demo (#149): the only free API was unreliable.
|
||||
|
||||
## 5. Quick reference
|
||||
|
||||
```
|
||||
[PLUGIN] issue -> vet API -> viable? yes: add to #4, label, close standalone
|
||||
no: close with reason
|
||||
[FEATURE] issue -> label enhancement -> add to ROADMAP backlog -> keep open
|
||||
bug -> reproduce -> label bug -> fix or route to debugger agent
|
||||
question -> answer -> close
|
||||
```
|
||||
@@ -1,97 +0,0 @@
|
||||
# Reusable compose for plugin smoke CI (consumed by wwv-plugins repo).
|
||||
#
|
||||
# Boots a full stack with a STUB seeder that emits known-good GeoEntity[]
|
||||
# data under the plugin-under-test's id. This isolates "is the frontend
|
||||
# wiring correct" from "is the real backend healthy" — a broken real seeder
|
||||
# cannot fail plugin CI.
|
||||
#
|
||||
# ─── Scope boundary (what THIS compose does vs what the workflow does) ───
|
||||
#
|
||||
# This compose only boots services. The consuming workflow's Playwright
|
||||
# `globalSetup` is responsible for:
|
||||
# 1. Inserting the test user into `users` (for NextAuth credentials login)
|
||||
# 2. Inserting the `InstalledPlugin` row with the plugin's manifest JSON
|
||||
# (entry URL → http://localhost:3000/plugins-local/<PLUGIN_ID>/frontend.mjs)
|
||||
# 3. UI login → save storageState.json
|
||||
# 4. Running the smoke spec
|
||||
#
|
||||
# Reuse the pattern from worldwideview/tests/global.setup.ts. DB migrations
|
||||
# are handled automatically by the wwv-app entrypoint at container start.
|
||||
#
|
||||
# ─── Stub seeder source ───
|
||||
#
|
||||
# The stub seeder is baked into the `wwv-data-engine:ci` image at
|
||||
# /app/seeders/stub (see wwv-data-engine/Dockerfile.ci). The compose only needs
|
||||
# to set STUB_PLUGIN_ID — no volume mount, so a consumer repo can download just
|
||||
# this YAML and run it without the worldwideview source tree present.
|
||||
#
|
||||
# Expected env vars from consuming workflow:
|
||||
# PLUGIN_ID — kebab-case id of the plugin under test (e.g. "aviation")
|
||||
# PLUGIN_BUNDLE_DIR — host path to the plugin's compiled dist/ (mounted into wwv-app)
|
||||
# CI_IMAGE_TAG — image tag to pull (default: ci)
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres:15-alpine
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: worldwideview
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres -d worldwideview"]
|
||||
interval: 3s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
|
||||
wwv-redis:
|
||||
image: redis:7-alpine
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 3s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
|
||||
wwv-data-engine:
|
||||
image: ghcr.io/silvertakana/wwv-data-engine:${CI_IMAGE_TAG:-ci}
|
||||
command: ["node", "dist/server.js"]
|
||||
ports:
|
||||
- "5000:5000"
|
||||
environment:
|
||||
PORT: 5000
|
||||
REDIS_URL: redis://wwv-redis:6379
|
||||
SEEDERS_DIR: /app/seeders
|
||||
DB_PATH: /tmp/engine.db
|
||||
# Stub seeder reads the target plugin id from this env var
|
||||
STUB_PLUGIN_ID: ${PLUGIN_ID}
|
||||
WWV_SKIP_WS_AUTH: "true"
|
||||
NODE_ENV: ci
|
||||
# No volume mount: the stub seeder is baked into the :ci image at
|
||||
# /app/seeders/stub, so the engine discovers it as id "stub" with no host
|
||||
# path dependency.
|
||||
depends_on:
|
||||
wwv-redis:
|
||||
condition: service_healthy
|
||||
|
||||
wwv-app:
|
||||
image: ghcr.io/silvertakana/worldwideview:${CI_IMAGE_TAG:-ci}
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
AUTH_SECRET: ci-placeholder-secret-not-used-in-tests
|
||||
DATABASE_URL: postgresql://postgres:postgres@db:5432/worldwideview?schema=public
|
||||
NEXT_PUBLIC_WWV_EDITION: local
|
||||
NEXT_PUBLIC_WWV_PLUGIN_DATA_ENGINE_URL: http://localhost:5000
|
||||
volumes:
|
||||
# Mount the plugin's compiled bundle so the app can load it locally
|
||||
- ${PLUGIN_BUNDLE_DIR}:/app/public/plugins-local/${PLUGIN_ID}:ro
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
wwv-data-engine:
|
||||
condition: service_started
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 30
|
||||
start_period: 30s
|
||||
@@ -1,64 +0,0 @@
|
||||
# Reusable compose for seeder smoke CI (consumed by wwv-seeders-* repos).
|
||||
#
|
||||
# Runs the REAL seeder against a MOCK upstream HTTP server. This isolates
|
||||
# "is the seeder code correct" from "is the upstream provider up" — a
|
||||
# NASA FIRMS / OpenSky / Overpass outage cannot fail seeder CI.
|
||||
#
|
||||
# Expected env vars from consuming workflow:
|
||||
# SEEDER_NAME — kebab-case name of the seeder under test
|
||||
# SEEDER_DIST_DIR — host path to the seeder's compiled dist/ + package.json
|
||||
# FIXTURE_DIR — host path to the seeder's __fixtures__ directory
|
||||
# CI_IMAGE_TAG — image tag to pull (default: ci)
|
||||
#
|
||||
# Plus any seeder-specific upstream env vars (e.g. OPENSKY_API_BASE)
|
||||
# already exported in the workflow shell, all pointing at http://mock-upstream:8080
|
||||
|
||||
services:
|
||||
wwv-redis:
|
||||
image: redis:7-alpine
|
||||
ports:
|
||||
- "6379:6379"
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 3s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
|
||||
mock-upstream:
|
||||
build:
|
||||
context: ./mock-upstream
|
||||
volumes:
|
||||
- ${FIXTURE_DIR}:/fixtures:ro
|
||||
environment:
|
||||
FIXTURE_DIR: /fixtures
|
||||
PORT: 8080
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -q -O- http://localhost:8080/__health || exit 1"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
|
||||
wwv-data-engine:
|
||||
image: ghcr.io/silvertakana/wwv-data-engine:${CI_IMAGE_TAG:-ci}
|
||||
command: ["node", "dist/server.js"]
|
||||
ports:
|
||||
- "5000:5000"
|
||||
volumes:
|
||||
# Mount ONLY this seeder under /app/seeders/community/<name> — isolates
|
||||
# the test from any cross-seeder dependencies or collisions.
|
||||
- ${SEEDER_DIST_DIR}:/app/seeders/community/${SEEDER_NAME}:ro
|
||||
environment:
|
||||
PORT: 5000
|
||||
REDIS_URL: redis://wwv-redis:6379
|
||||
SEEDERS_DIR: /app/seeders
|
||||
DB_PATH: /tmp/engine.db
|
||||
# Seeder-specific upstream env vars are injected by the consuming
|
||||
# workflow via `environment:` overrides or `env_file:`.
|
||||
env_file:
|
||||
- path: ./.seeder.env
|
||||
required: false
|
||||
depends_on:
|
||||
wwv-redis:
|
||||
condition: service_healthy
|
||||
mock-upstream:
|
||||
condition: service_healthy
|
||||
@@ -1,5 +0,0 @@
|
||||
FROM node:22-alpine
|
||||
WORKDIR /mock
|
||||
COPY server.mjs ./
|
||||
EXPOSE 8080
|
||||
CMD ["node", "/mock/server.mjs"]
|
||||
@@ -1,48 +0,0 @@
|
||||
# mock-upstream
|
||||
|
||||
Tiny HTTP server used in CI to stand in for upstream data APIs (OpenSky, NASA FIRMS, Overpass, etc.) so seeder CI can run hermetically without real API keys or network flakiness.
|
||||
|
||||
## How it works
|
||||
|
||||
Mount a fixture directory at `/fixtures`. The directory must contain a `routes.json` mapping request paths → fixture filenames:
|
||||
|
||||
```json
|
||||
{
|
||||
"/api/states/all": "opensky-states.json",
|
||||
"/api/v2/flights": "flights.json"
|
||||
}
|
||||
```
|
||||
|
||||
When the server receives `GET /api/states/all`, it serves the contents of `/fixtures/opensky-states.json`.
|
||||
|
||||
## Env vars
|
||||
|
||||
| Var | Default | Purpose |
|
||||
|---|---|---|
|
||||
| `FIXTURE_DIR` | `/fixtures` | Directory mounted from the seeder repo |
|
||||
| `ROUTES_FILE` | `${FIXTURE_DIR}/routes.json` | Override the routes manifest path |
|
||||
| `PORT` | `8080` | Listen port |
|
||||
|
||||
## Per-seeder convention
|
||||
|
||||
Each seeder ships its own `__fixtures__/` folder next to `src/`:
|
||||
|
||||
```
|
||||
wwv-seeders-community/aviation/
|
||||
├── src/index.ts
|
||||
└── __fixtures__/
|
||||
├── routes.json
|
||||
└── opensky-states.json
|
||||
```
|
||||
|
||||
In CI compose, that folder is mounted into the mock-upstream container at `/fixtures` for the duration of the seeder smoke test.
|
||||
|
||||
## Architectural contract
|
||||
|
||||
Seeders MUST read upstream URLs from documented env vars with the production URL as the default, e.g.:
|
||||
|
||||
```ts
|
||||
const UPSTREAM = process.env.OPENSKY_API_BASE ?? "https://opensky-network.org";
|
||||
```
|
||||
|
||||
The CI compose then overrides `OPENSKY_API_BASE=http://mock-upstream:8080`. Without this convention, CI mocking is impossible — hardcoded URLs cannot be intercepted.
|
||||
@@ -1,61 +0,0 @@
|
||||
import { createServer } from "node:http";
|
||||
import { readFileSync, existsSync } from "node:fs";
|
||||
import { resolve, join } from "node:path";
|
||||
|
||||
const FIXTURE_DIR = process.env.FIXTURE_DIR ?? "/fixtures";
|
||||
const PORT = Number(process.env.PORT ?? 8080);
|
||||
const ROUTES_FILE = process.env.ROUTES_FILE ?? join(FIXTURE_DIR, "routes.json");
|
||||
|
||||
if (!existsSync(ROUTES_FILE)) {
|
||||
console.error(`[mock-upstream] no routes file at ${ROUTES_FILE}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let routes;
|
||||
try {
|
||||
routes = JSON.parse(readFileSync(ROUTES_FILE, "utf8"));
|
||||
} catch (err) {
|
||||
console.error(`[mock-upstream] failed to parse ${ROUTES_FILE}:`, err);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`[mock-upstream] loaded ${Object.keys(routes).length} routes from ${ROUTES_FILE}`);
|
||||
|
||||
createServer((req, res) => {
|
||||
const path = req.url?.split("?")[0] ?? "/";
|
||||
if (path === "/__health") {
|
||||
res.statusCode = 200;
|
||||
res.setHeader("content-type", "application/json");
|
||||
res.end(JSON.stringify({ status: "ok" }));
|
||||
return;
|
||||
}
|
||||
const file = routes[path];
|
||||
if (!file) {
|
||||
console.warn(`[mock-upstream] 404 ${req.method} ${path}`);
|
||||
res.statusCode = 404;
|
||||
res.setHeader("content-type", "application/json");
|
||||
res.end(JSON.stringify({ error: "no fixture", path }));
|
||||
return;
|
||||
}
|
||||
|
||||
const filePath = resolve(FIXTURE_DIR, file);
|
||||
if (!filePath.startsWith(resolve(FIXTURE_DIR))) {
|
||||
res.statusCode = 400;
|
||||
res.end("bad fixture path");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const body = readFileSync(filePath);
|
||||
res.statusCode = 200;
|
||||
res.setHeader("content-type", file.endsWith(".json") ? "application/json" : "text/plain");
|
||||
res.end(body);
|
||||
console.log(`[mock-upstream] 200 ${req.method} ${path} -> ${file}`);
|
||||
} catch (err) {
|
||||
console.error(`[mock-upstream] 500 ${req.method} ${path}:`, err);
|
||||
res.statusCode = 500;
|
||||
res.end("fixture read failed");
|
||||
}
|
||||
}).listen(PORT, () => {
|
||||
console.log(`[mock-upstream] listening on :${PORT}`);
|
||||
});
|
||||
Vendored
-55
@@ -1,55 +0,0 @@
|
||||
// CI-only stub seeder. Emits a known-good GeoEntity[] payload under the
|
||||
// plugin id provided via STUB_PLUGIN_ID. Used by plugin-CI to isolate
|
||||
// frontend wiring from real backend health.
|
||||
//
|
||||
// NOTE: This bypasses ADR-0002's compile-time name rule on purpose — the
|
||||
// data engine reads `name` once at load time, so an env-driven name is
|
||||
// fine in CI. Do NOT copy this pattern into real seeders.
|
||||
|
||||
const pluginId = process.env.STUB_PLUGIN_ID;
|
||||
// When unconfigured (e.g. seeder-CI, where this stub is baked into the shared
|
||||
// :ci image but unused), export a nameless module so the seeder-loader skips
|
||||
// it instead of crashing the engine.
|
||||
//
|
||||
// Uses the interval+fetch seeder contract: fetch() RETURNS the array and the
|
||||
// scheduler auto-wraps it into a snapshot stored under the seeder id. The
|
||||
// cron+fn contract would require the engine-internal setLiveSnapshot, which is
|
||||
// NOT exposed on the seeder ctx (ctx is only { redis }).
|
||||
|
||||
function makeEntities() {
|
||||
const now = new Date().toISOString();
|
||||
return [
|
||||
{
|
||||
id: `${pluginId}-stub-1`,
|
||||
pluginId,
|
||||
latitude: 0,
|
||||
longitude: 0,
|
||||
altitude: 0,
|
||||
timestamp: now,
|
||||
label: "Stub entity 1",
|
||||
properties: { source: "ci-stub" },
|
||||
},
|
||||
{
|
||||
id: `${pluginId}-stub-2`,
|
||||
pluginId,
|
||||
latitude: 10,
|
||||
longitude: 10,
|
||||
altitude: 0,
|
||||
timestamp: now,
|
||||
label: "Stub entity 2",
|
||||
properties: { source: "ci-stub" },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export default pluginId
|
||||
? {
|
||||
name: pluginId,
|
||||
interval: 10000,
|
||||
fetch: async () => {
|
||||
const entities = makeEntities();
|
||||
console.log(`[stub-seeder] emitting ${entities.length} entities for ${pluginId}`);
|
||||
return entities;
|
||||
},
|
||||
}
|
||||
: {};
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"name": "stub-seeder",
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"main": "dist/index.mjs",
|
||||
"private": true
|
||||
}
|
||||
@@ -20,32 +20,6 @@ pnpm dev
|
||||
4. The marketplace load API auto-discovers them in dev mode
|
||||
5. Everything in this directory is gitignored
|
||||
|
||||
## Property Conventions
|
||||
|
||||
Use the SDK property tag helpers to give the Intel panel rich rendering for dates, URLs, images, and video. Without them, values display as plain text.
|
||||
|
||||
```ts
|
||||
import { dtProp, urlProp, imageProp, videoProp } from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
properties: {
|
||||
// Dates — pass ISO 8601 strings
|
||||
updated_at: dtProp(item.timestamp ?? null),
|
||||
// External links
|
||||
source_url: urlProp(item.url ?? null),
|
||||
// Images
|
||||
preview: imageProp(item.image_url ?? null),
|
||||
// Video/streams
|
||||
live_stream: videoProp(item.stream_url ?? null),
|
||||
// Plain values — no helper needed
|
||||
name: item.name,
|
||||
count: item.count,
|
||||
}
|
||||
```
|
||||
|
||||
All helpers are null-safe — passing `null` or `undefined` returns `null`, which the panel skips.
|
||||
|
||||
See the [SDK README](../worldwideview/packages/wwv-plugin-sdk/README.md) for the full reference.
|
||||
|
||||
## Publishing to NPM
|
||||
|
||||
When your plugin is ready to share, you can publish it directly to NPM from the root directory:
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "worldwideview",
|
||||
"version": "2.48.30",
|
||||
"version": "2.48.14",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"packageManager": "[email protected]",
|
||||
@@ -82,7 +82,7 @@
|
||||
"@typescript-eslint/parser": "^8.60.1",
|
||||
"@vitejs/plugin-react": "^6.0.2",
|
||||
"@vitest/coverage-v8": "4.1.8",
|
||||
"concurrently": "^10.0.3",
|
||||
"concurrently": "^9.2.1",
|
||||
"copy-webpack-plugin": "^14.0.0",
|
||||
"eslint": "^9",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
# @worldwideview/wwv-ci-probe
|
||||
|
||||
CI probe — asserts plugin/seeder integration health for the WorldWideView ecosystem.
|
||||
|
||||
Used by the smoke-test workflows in [`wwv-plugins`](https://github.com/silvertakana/wwv-plugins), [`wwv-seeders-community`](https://github.com/silvertakana/wwv-seeders-community), and [`wwv-seeders-private`](https://github.com/silvertakana/wwv-seeders-private).
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
# Via npx (recommended in CI)
|
||||
npx --yes @worldwideview/wwv-ci-probe <subcommand>
|
||||
|
||||
# Or as a dev dependency
|
||||
pnpm add -D @worldwideview/wwv-ci-probe
|
||||
```
|
||||
|
||||
## Subcommands
|
||||
|
||||
### `seeder <name>`
|
||||
|
||||
Polls Redis for `data:<name>:live` and validates the payload shape. Accepts `GeoEntity[]`, `{ items: [...] }`, or `{ <key>: [...] }`. Use this in seeder CI after booting the data engine against a mock upstream.
|
||||
|
||||
```bash
|
||||
wwv-probe seeder aviation --redis redis://localhost:6379 --timeout 60000
|
||||
```
|
||||
|
||||
### `ws <name>`
|
||||
|
||||
Connects to the data engine's `/stream` WebSocket and waits for a `data` message matching the given `pluginId`. Validates the same payload shapes as `seeder`. Use this when you want to assert the engine is broadcasting (not just persisting).
|
||||
|
||||
```bash
|
||||
wwv-probe ws aviation --url ws://localhost:5000/stream --timeout 30000
|
||||
```
|
||||
|
||||
### `id-contract <seederDist>`
|
||||
|
||||
Statically validates that a compiled seeder exports a kebab-case `name` (ADR-0002). Optionally checks the name matches an expected id.
|
||||
|
||||
```bash
|
||||
wwv-probe id-contract ./dist/index.mjs --expect aviation
|
||||
```
|
||||
|
||||
## Plugin smoke testing — not in this probe
|
||||
|
||||
The probe deliberately does **not** include a `plugin` subcommand. Plugin smoke tests need to exercise the full Next.js + Cesium frontend (plugin bundle loading, `mapWebsocketPayload`, DataBus wiring), which requires a real browser via Playwright.
|
||||
|
||||
The `wwv-plugins` repo writes its own Playwright spec for that — it reuses the auth bootstrap pattern from `worldwideview/tests/global.setup.ts` (insert test user + `InstalledPlugin` row, UI login to capture `storageState.json`, then run the plugin-toggle smoke).
|
||||
|
||||
Keeping that logic inside `wwv-plugins` avoids coupling this probe to `@playwright/test` and to the specific UI structure of the Next.js frontend.
|
||||
|
||||
## Exit codes
|
||||
|
||||
- `0` — assertion passed within the timeout
|
||||
- `1` — assertion failed (timeout exceeded, invalid payload shape, or contract violation)
|
||||
- `2` — fatal probe error (unhandled exception)
|
||||
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-ci-probe",
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"description": "CI probe — asserts plugin/seeder integration health (ADR-0002, WS payload contract, Redis snapshots)",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
"wwv-probe": "dist/index.js"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"README.md"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"dev": "tsc --watch",
|
||||
"clean": "rm -rf dist",
|
||||
"prepublishOnly": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"commander": "^14.0.3",
|
||||
"ioredis": "^5.4.1",
|
||||
"ws": "^8.18.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^25.9.1",
|
||||
"@types/ws": "^8.5.13",
|
||||
"typescript": "^5.0.0"
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
const KEBAB_RE = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
||||
|
||||
/**
|
||||
* Validates ADR-0002: a seeder's exported `name` field must be kebab-case
|
||||
* and (optionally) match an expected plugin id.
|
||||
*
|
||||
* @returns true if the contract holds; false (with stderr explanation) otherwise.
|
||||
*/
|
||||
export async function probeIdContract(opts: {
|
||||
seederDist: string;
|
||||
expectId?: string;
|
||||
}): Promise<boolean> {
|
||||
const absPath = resolve(opts.seederDist);
|
||||
let mod: any;
|
||||
try {
|
||||
mod = await import(pathToFileURL(absPath).href);
|
||||
} catch (err) {
|
||||
console.error(`[id-contract] failed to import ${absPath}:`, err);
|
||||
return false;
|
||||
}
|
||||
|
||||
const seeder = mod.default ?? mod;
|
||||
if (!seeder || typeof seeder !== "object") {
|
||||
console.error(`[id-contract] ${absPath} has no default export (or export is not an object)`);
|
||||
return false;
|
||||
}
|
||||
|
||||
const name = seeder.name;
|
||||
if (typeof name !== "string" || name.length === 0) {
|
||||
console.error(`[id-contract] seeder default export missing required string field 'name'`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!KEBAB_RE.test(name)) {
|
||||
console.error(`[id-contract] seeder name "${name}" is not valid kebab-case (must match ${KEBAB_RE})`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (opts.expectId && opts.expectId !== name) {
|
||||
console.error(
|
||||
`[id-contract] seeder name "${name}" does not match expected plugin id "${opts.expectId}" (ADR-0002 violation)`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log(`[id-contract] OK — seeder name "${name}"${opts.expectId ? ` matches expected id` : ""}`);
|
||||
return true;
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
import { Command } from "commander";
|
||||
import { probeSeeder } from "./seeder.js";
|
||||
import { probeWs } from "./ws.js";
|
||||
import { probeIdContract } from "./id-contract.js";
|
||||
|
||||
const program = new Command();
|
||||
|
||||
program
|
||||
.name("wwv-probe")
|
||||
.description("WorldWideView CI probe — asserts plugin/seeder integration health")
|
||||
.version("0.1.0");
|
||||
|
||||
program
|
||||
.command("seeder")
|
||||
.description("Wait for Redis key data:<name>:live to be populated and validate payload shape")
|
||||
.argument("<name>", "Canonical plugin id (kebab-case)")
|
||||
.option("--redis <url>", "Redis URL", "redis://localhost:6379")
|
||||
.option("--timeout <ms>", "Timeout in milliseconds", "60000")
|
||||
.action(async (name: string, opts: { redis: string; timeout: string }) => {
|
||||
const ok = await probeSeeder({
|
||||
name,
|
||||
redisUrl: opts.redis,
|
||||
timeoutMs: Number(opts.timeout),
|
||||
});
|
||||
process.exit(ok ? 0 : 1);
|
||||
});
|
||||
|
||||
program
|
||||
.command("ws")
|
||||
.description("Connect to engine /stream and wait for a data payload for the given pluginId")
|
||||
.argument("<name>", "Canonical plugin id (kebab-case)")
|
||||
.option("--url <url>", "WebSocket URL", "ws://localhost:5000/stream")
|
||||
.option("--timeout <ms>", "Timeout in milliseconds", "30000")
|
||||
.action(async (name: string, opts: { url: string; timeout: string }) => {
|
||||
const ok = await probeWs({
|
||||
name,
|
||||
wsUrl: opts.url,
|
||||
timeoutMs: Number(opts.timeout),
|
||||
});
|
||||
process.exit(ok ? 0 : 1);
|
||||
});
|
||||
|
||||
program
|
||||
.command("id-contract")
|
||||
.description("Verify seeder dist exports a kebab-case name matching the expected plugin id (ADR-0002)")
|
||||
.argument("<seederDist>", "Path to compiled seeder dist/index.mjs")
|
||||
.option("--expect <id>", "Expected plugin id (if omitted, only validates kebab-case)")
|
||||
.action(async (seederDist: string, opts: { expect?: string }) => {
|
||||
const ok = await probeIdContract({
|
||||
seederDist,
|
||||
expectId: opts.expect,
|
||||
});
|
||||
process.exit(ok ? 0 : 1);
|
||||
});
|
||||
|
||||
program.parseAsync().catch((err) => {
|
||||
console.error("[wwv-probe] fatal:", err);
|
||||
process.exit(2);
|
||||
});
|
||||
@@ -1,38 +0,0 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { validatePayloadValue, validatePayloadString } from "./payloadShape.js";
|
||||
|
||||
describe("validatePayloadValue", () => {
|
||||
it("accepts a non-empty GeoEntity array", () => {
|
||||
expect(validatePayloadValue([{ id: "a" }])).toEqual({ ok: true, shape: "geo-entity-array" });
|
||||
});
|
||||
it("rejects an empty array", () => {
|
||||
expect(validatePayloadValue([])).toEqual({ ok: false, reason: "GeoEntity[] is empty" });
|
||||
});
|
||||
it("accepts a non-empty items object", () => {
|
||||
expect(validatePayloadValue({ items: [1] })).toEqual({ ok: true, shape: "items-object" });
|
||||
});
|
||||
it("rejects an empty items array", () => {
|
||||
expect(validatePayloadValue({ items: [] })).toEqual({ ok: false, reason: "items[] is empty" });
|
||||
});
|
||||
it("accepts a single named collection", () => {
|
||||
expect(validatePayloadValue({ quakes: [1, 2] })).toEqual({ ok: true, shape: "named-collection" });
|
||||
});
|
||||
it("rejects an object with no array field", () => {
|
||||
const r = validatePayloadValue({ a: 1, b: 2 });
|
||||
expect(r.ok).toBe(false);
|
||||
});
|
||||
it("rejects a non-object, non-array value", () => {
|
||||
const r = validatePayloadValue(42);
|
||||
expect(r.ok).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("validatePayloadString", () => {
|
||||
it("parses then validates", () => {
|
||||
expect(validatePayloadString('[{"id":"x"}]')).toEqual({ ok: true, shape: "geo-entity-array" });
|
||||
});
|
||||
it("rejects invalid JSON", () => {
|
||||
const r = validatePayloadString("{not json");
|
||||
expect(r.ok).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,59 +0,0 @@
|
||||
/**
|
||||
* Shared payload-shape validator for the WWV data contract (data-engine-architecture.md §7).
|
||||
* A valid live payload is one of three non-empty shapes:
|
||||
* - geo-entity-array: a top-level non-empty array
|
||||
* - items-object: an object with a non-empty `items` array
|
||||
* - named-collection: an object whose single array-valued key is non-empty
|
||||
*/
|
||||
export type PayloadShape = "geo-entity-array" | "items-object" | "named-collection";
|
||||
|
||||
export type PayloadValidation =
|
||||
| { ok: true; shape: PayloadShape }
|
||||
| { ok: false; reason: string };
|
||||
|
||||
/**
|
||||
* Validate an already-parsed payload value.
|
||||
* @param p - parsed JSON value
|
||||
* @returns ok with the detected shape, or a reason for rejection
|
||||
*/
|
||||
export function validatePayloadValue(p: unknown): PayloadValidation {
|
||||
if (Array.isArray(p)) {
|
||||
return p.length > 0
|
||||
? { ok: true, shape: "geo-entity-array" }
|
||||
: { ok: false, reason: "GeoEntity[] is empty" };
|
||||
}
|
||||
if (p && typeof p === "object") {
|
||||
const obj = p as Record<string, unknown>;
|
||||
if (Array.isArray(obj.items)) {
|
||||
return obj.items.length > 0
|
||||
? { ok: true, shape: "items-object" }
|
||||
: { ok: false, reason: "items[] is empty" };
|
||||
}
|
||||
const arrayKeys = Object.keys(obj).filter((k) => Array.isArray(obj[k]));
|
||||
if (arrayKeys.length === 1) {
|
||||
const arr = obj[arrayKeys[0]] as unknown[];
|
||||
return arr.length > 0
|
||||
? { ok: true, shape: "named-collection" }
|
||||
: { ok: false, reason: `${arrayKeys[0]}[] is empty` };
|
||||
}
|
||||
return {
|
||||
ok: false,
|
||||
reason: `payload object has no recognizable array field (keys: ${Object.keys(obj).join(", ")})`,
|
||||
};
|
||||
}
|
||||
return { ok: false, reason: `payload is neither array nor object (typeof=${typeof p})` };
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a raw JSON string, then validate the resulting value's shape.
|
||||
* @param raw - raw JSON string from Redis
|
||||
*/
|
||||
export function validatePayloadString(raw: string): PayloadValidation {
|
||||
let parsed: unknown;
|
||||
try {
|
||||
parsed = JSON.parse(raw);
|
||||
} catch (err) {
|
||||
return { ok: false, reason: `not valid JSON (${(err as Error).message})` };
|
||||
}
|
||||
return validatePayloadValue(parsed);
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
import { Redis } from "ioredis";
|
||||
import { validatePayloadString } from "./payloadShape.js";
|
||||
|
||||
/**
|
||||
* Polls Redis for `data:<name>:live` and validates that the seeder produced a
|
||||
* non-empty payload in one of the three accepted shapes (see
|
||||
* data-engine-architecture.md §7).
|
||||
*
|
||||
* @returns true if a valid payload arrived within the timeout; false otherwise.
|
||||
*/
|
||||
export async function probeSeeder(opts: {
|
||||
name: string;
|
||||
redisUrl: string;
|
||||
timeoutMs: number;
|
||||
}): Promise<boolean> {
|
||||
const redis = new Redis(opts.redisUrl, { lazyConnect: true, maxRetriesPerRequest: 1 });
|
||||
const key = `data:${opts.name}:live`;
|
||||
const deadline = Date.now() + opts.timeoutMs;
|
||||
const pollIntervalMs = 1000;
|
||||
|
||||
try {
|
||||
await redis.connect();
|
||||
} catch (err) {
|
||||
console.error(`[seeder] cannot connect to Redis at ${opts.redisUrl}:`, err);
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log(`[seeder] waiting for ${key} (timeout ${opts.timeoutMs}ms)`);
|
||||
|
||||
while (Date.now() < deadline) {
|
||||
const raw = await redis.get(key);
|
||||
if (raw && raw.length > 0) {
|
||||
const validation = validatePayloadString(raw);
|
||||
await redis.quit();
|
||||
if (!validation.ok) {
|
||||
console.error(`[seeder] payload present but invalid: ${validation.reason}`);
|
||||
return false;
|
||||
}
|
||||
console.log(`[seeder] OK — ${key} populated (shape: ${validation.shape}, bytes: ${raw.length})`);
|
||||
return true;
|
||||
}
|
||||
await sleep(pollIntervalMs);
|
||||
}
|
||||
|
||||
await redis.quit();
|
||||
console.error(`[seeder] timed out — ${key} never populated within ${opts.timeoutMs}ms`);
|
||||
return false;
|
||||
}
|
||||
|
||||
function sleep(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
import { describe, it, expect, afterEach } from "vitest";
|
||||
import { WebSocketServer } from "ws";
|
||||
import { probeWs } from "./ws.js";
|
||||
|
||||
let server: WebSocketServer | undefined;
|
||||
afterEach(() => { server?.close(); server = undefined; });
|
||||
|
||||
function startEngine(opts: { pluginId: string; requireSubscribe: boolean }) {
|
||||
server = new WebSocketServer({ port: 0 });
|
||||
server.on("connection", (sock) => {
|
||||
sock.send(JSON.stringify({ type: "welcome", engine: "test", plugins: [opts.pluginId] }));
|
||||
const send = () =>
|
||||
sock.send(JSON.stringify({ type: "data", pluginId: opts.pluginId, payload: [{ id: "x" }] }));
|
||||
if (!opts.requireSubscribe) { setInterval(send, 20); return; }
|
||||
sock.on("message", (raw) => {
|
||||
const msg = JSON.parse(raw.toString());
|
||||
if (msg.action === "subscribe" && msg.pluginId === opts.pluginId) send();
|
||||
});
|
||||
});
|
||||
const addr = server.address();
|
||||
const port = typeof addr === "object" && addr ? addr.port : 0;
|
||||
return `ws://127.0.0.1:${port}/stream`;
|
||||
}
|
||||
|
||||
describe("probeWs", () => {
|
||||
it("receives data from a subscribe-required engine (sends subscribe frame)", async () => {
|
||||
const url = startEngine({ pluginId: "stub", requireSubscribe: true });
|
||||
const ok = await probeWs({ name: "stub", wsUrl: url, timeoutMs: 3000 });
|
||||
expect(ok).toBe(true);
|
||||
});
|
||||
it("times out (false) when the plugin never produces data", async () => {
|
||||
const url = startEngine({ pluginId: "other", requireSubscribe: true });
|
||||
const ok = await probeWs({ name: "stub", wsUrl: url, timeoutMs: 800 });
|
||||
expect(ok).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,74 +0,0 @@
|
||||
import WebSocket from "ws";
|
||||
import { validatePayloadValue } from "./payloadShape.js";
|
||||
|
||||
/**
|
||||
* Connects to the data-engine's /stream WebSocket and resolves when a
|
||||
* `{ type: "data", pluginId: <name>, payload: ... }` message arrives for the
|
||||
* given plugin id (see data-engine-architecture.md §7).
|
||||
*
|
||||
* Rejects with exit code 1 if no matching payload arrives within the timeout
|
||||
* — which is the signature of an ADR-0002 id mismatch or a silently-dropped
|
||||
* object payload.
|
||||
*/
|
||||
export async function probeWs(opts: {
|
||||
name: string;
|
||||
wsUrl: string;
|
||||
timeoutMs: number;
|
||||
}): Promise<boolean> {
|
||||
return new Promise((resolve) => {
|
||||
const ws = new WebSocket(opts.wsUrl);
|
||||
let settled = false;
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
if (settled) return;
|
||||
settled = true;
|
||||
console.error(
|
||||
`[ws] timed out — no data message with pluginId="${opts.name}" in ${opts.timeoutMs}ms ` +
|
||||
`(check ADR-0002 seeder.name vs plugin id, and that the seeder is producing data)`,
|
||||
);
|
||||
ws.terminate();
|
||||
resolve(false);
|
||||
}, opts.timeoutMs);
|
||||
|
||||
ws.on("open", () => {
|
||||
// The engine is subscribe-required: it only broadcasts a plugin's data to
|
||||
// connections that have subscribed to it (websocket.ts broadcastPluginData).
|
||||
// Auth is bypassed in CI via WWV_SKIP_WS_AUTH=true, so no auth frame is sent.
|
||||
ws.send(JSON.stringify({ action: "subscribe", pluginId: opts.name }));
|
||||
console.log(`[ws] connected to ${opts.wsUrl}, subscribed to pluginId="${opts.name}"`);
|
||||
});
|
||||
|
||||
ws.on("message", (raw) => {
|
||||
let msg: any;
|
||||
try {
|
||||
msg = JSON.parse(raw.toString());
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
if (msg?.type !== "data" || msg.pluginId !== opts.name) return;
|
||||
if (settled) return;
|
||||
|
||||
const payload = msg.payload;
|
||||
const valid = validatePayloadValue(payload);
|
||||
if (!valid.ok) {
|
||||
console.error(`[ws] received message for "${opts.name}" but payload invalid: ${valid.reason}`);
|
||||
// Keep waiting — a later message might be valid.
|
||||
return;
|
||||
}
|
||||
|
||||
settled = true;
|
||||
clearTimeout(timer);
|
||||
console.log(`[ws] OK — received valid payload for "${opts.name}" (shape: ${valid.shape})`);
|
||||
ws.close();
|
||||
resolve(true);
|
||||
});
|
||||
|
||||
ws.on("error", (err) => {
|
||||
if (settled) return;
|
||||
settled = true;
|
||||
clearTimeout(timer);
|
||||
console.error(`[ws] connection error:`, err);
|
||||
resolve(false);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": false
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
"test": "node --test \"test/**/*.test.mjs\""
|
||||
},
|
||||
"dependencies": {
|
||||
"commander": "^15.0.0",
|
||||
"commander": "^14.0.3",
|
||||
"prompts": "^2.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
"name": "@worldwideview/wwv-lib-aviation",
|
||||
"version": "1.0.2",
|
||||
"description": "Shared abstract base classes for WorldWideView aviation plugins (commercial, military, specialized)",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-lib-aviation"
|
||||
},
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
@@ -21,6 +16,6 @@
|
||||
"author": "WorldWideView",
|
||||
"license": "ISC",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "workspace:*"
|
||||
"@worldwideview/wwv-plugin-sdk": "^1.4.10"
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,6 @@
|
||||
"name": "@worldwideview/wwv-lib-incidents",
|
||||
"version": "1.0.4",
|
||||
"description": "Shared abstract base classes for WorldWideView incident plugins (earthquakes, wildfires, conflicts)",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-lib-incidents"
|
||||
},
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
@@ -21,6 +16,6 @@
|
||||
"author": "WorldWideView",
|
||||
"license": "ISC",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "workspace:*"
|
||||
"@worldwideview/wwv-plugin-sdk": "^1.4.10"
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -24,7 +24,7 @@ export interface IconUrlOptions extends Record<string, unknown> {
|
||||
* Pass `{ background: false }` to opt out.
|
||||
*/
|
||||
export declare function createSvgIconUrl(Icon: ComponentType<any>, opts?: IconUrlOptions): string;
|
||||
export type { PluginManifest, PluginFormat, PluginType, TrustTier, PluginCapability, DataSourceConfig, FieldMapping, RenderingConfig, McpToolDeclaration, LocalDataSourceDeclaration } from "./manifest";
|
||||
export type { PluginManifest, PluginFormat, PluginType, TrustTier, PluginCapability, DataSourceConfig, FieldMapping, RenderingConfig, McpToolDeclaration } from "./manifest";
|
||||
export type PluginCategory = "aviation" | "maritime" | "military" | "conflict" | "natural-disaster" | "infrastructure" | "space" | "cyber" | "economic" | "intelligence" | "custom";
|
||||
export interface TimeRange {
|
||||
start: Date;
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AA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aAAa,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAGhB,UAAU,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,IAAI,IAAI,CAAC;IAGhB,KAAK,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAClD,kBAAkB,IAAI,MAAM,CAAC;IAG7B,cAAc,IAAI,WAAW,CAAC;IAC9B,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,mBALine truncated
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-sdk",
|
||||
"version": "1.7.2",
|
||||
"version": "1.7.1",
|
||||
"description": "Plugin SDK — types, interfaces, and utilities for building WorldWideView globe plugins",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
||||
@@ -96,7 +96,7 @@ export function wwvPluginGlobals(): any {
|
||||
return `
|
||||
const SDK = globalThis.__WWV_HOST__.WWVPluginSDK;
|
||||
export default SDK;
|
||||
export const { WorldPlugin, PluginManifest, createSvgIconUrl, DEFAULT_ICON_SIZE, dtProp, urlProp, imageProp, videoProp } = SDK;
|
||||
export const { WorldPlugin, PluginManifest, createSvgIconUrl, DEFAULT_ICON_SIZE } = SDK;
|
||||
`;
|
||||
}
|
||||
if (originalId === "zustand") {
|
||||
|
||||
Generated
+73
-1306
File diff suppressed because it is too large.
Load diff
@@ -1,5 +0,0 @@
|
||||
-- Add sessionVersion to users table.
|
||||
-- Existing rows default to 0, which matches the @default(0) in schema.prisma.
|
||||
-- This column is embedded in every JWT at sign-in; bumping it invalidates all
|
||||
-- existing sessions for that user (logout-everywhere / credential rotation).
|
||||
ALTER TABLE "users" ADD COLUMN "sessionVersion" INTEGER NOT NULL DEFAULT 0;
|
||||
@@ -1,247 +0,0 @@
|
||||
/**
|
||||
* ci-plugin-smoke/smoke.mjs
|
||||
* Tier 2: Load the bundle and verify WorldPlugin interface shape.
|
||||
* Tier 3: Exercise pure methods — getLayerConfig, renderEntity, mapWebsocketPayload.
|
||||
*
|
||||
* Plugin bundles reference globalThis.__WWV_HOST__ for all externals (React, Cesium,
|
||||
* wwv-plugin-sdk, etc.) via the wwvPluginGlobals() Vite plugin. No Node.js module
|
||||
* hooks are needed — setting up __WWV_HOST__ before import() is sufficient.
|
||||
*
|
||||
* Usage: node scripts/ci-plugin-smoke/smoke.mjs <path-to-dist/frontend.mjs>
|
||||
*/
|
||||
|
||||
import { pathToFileURL } from "node:url";
|
||||
import path from "node:path";
|
||||
|
||||
// ── Args ─────────────────────────────────────────────────────────────────────
|
||||
const [, , bundleArg] = process.argv;
|
||||
if (!bundleArg) {
|
||||
console.error("Usage: node scripts/ci-plugin-smoke/smoke.mjs <path-to-dist/frontend.mjs>");
|
||||
process.exit(2);
|
||||
}
|
||||
const bundleAbs = path.resolve(bundleArg);
|
||||
const bundleUrl = pathToFileURL(bundleAbs).href;
|
||||
|
||||
// ── Mock host globals ─────────────────────────────────────────────────────────
|
||||
// Mirrors what the host app injects at runtime. All externals in the bundle
|
||||
// resolve to these via globalThis.__WWV_HOST__.<name>.
|
||||
const noop = () => {};
|
||||
|
||||
globalThis.__WWV_HOST__ = {
|
||||
React: new Proxy(
|
||||
{
|
||||
createElement: () => null,
|
||||
Fragment: Symbol("Fragment"),
|
||||
memo: (c) => c,
|
||||
forwardRef: (fn) => fn,
|
||||
lazy: () => null,
|
||||
createContext: () => ({ Provider: null, Consumer: null, _currentValue: null }),
|
||||
Component: class Component {},
|
||||
PureComponent: class PureComponent {},
|
||||
},
|
||||
{
|
||||
get(target, key) {
|
||||
if (key in target) return target[key];
|
||||
if (["useState", "useRef", "useContext", "useReducer"].includes(key)) return () => [null, noop];
|
||||
if (["useEffect", "useLayoutEffect", "useInsertionEffect"].includes(key)) return noop;
|
||||
if (["useMemo", "useCallback"].includes(key)) return (fn) => (typeof fn === "function" ? fn() : fn);
|
||||
return noop;
|
||||
},
|
||||
}
|
||||
),
|
||||
ReactDOM: { createPortal: () => null, flushSync: (fn) => fn(), render: noop },
|
||||
jsxRuntime: { jsx: () => null, jsxs: () => null, Fragment: null },
|
||||
Cesium: new Proxy(
|
||||
{},
|
||||
{
|
||||
get(_, key) {
|
||||
if (key === "Math") return Math;
|
||||
if (key === Symbol.toPrimitive) return undefined;
|
||||
return function MockCesium() {};
|
||||
},
|
||||
}
|
||||
),
|
||||
Resium: new Proxy({}, { get: () => function MockResium() {} }),
|
||||
WWVPluginSDK: {
|
||||
createSvgIconUrl: () => "data:image/svg+xml;base64,PHN2Zy8+",
|
||||
DEFAULT_ICON_SIZE: 32,
|
||||
dtProp: (v) => (v ? `datetime:${v}` : null),
|
||||
urlProp: (v) => (v ? `url:${v}` : null),
|
||||
imageProp: (v) => (v ? `image:${v}` : null),
|
||||
videoProp: (v) => (v ? `video:${v}` : null),
|
||||
},
|
||||
zustand: {
|
||||
create: () => Object.assign(() => ({}), { getState: () => ({}), setState: noop, subscribe: () => noop }),
|
||||
createStore: () => ({ getState: () => ({}), setState: noop, subscribe: () => noop }),
|
||||
},
|
||||
useStore: () => ({}),
|
||||
pluginManager: { getPlugin: () => null, registerPlugin: noop },
|
||||
CameraStream: null,
|
||||
};
|
||||
|
||||
// No-op fetch so any top-level module code that calls fetch() does not throw.
|
||||
globalThis.fetch ??= async () => ({ ok: true, status: 200, json: async () => [], text: async () => "[]" });
|
||||
|
||||
// ── Load the bundle ───────────────────────────────────────────────────────────
|
||||
let mod;
|
||||
try {
|
||||
mod = await import(bundleUrl);
|
||||
} catch (err) {
|
||||
console.error(`FAIL [Tier 2] Bundle failed to load: ${err.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// ── Instantiate (mirrors loadBundlePlugin logic) ──────────────────────────────
|
||||
function tryInstantiate(maybeExport) {
|
||||
if (!maybeExport) return null;
|
||||
if (typeof maybeExport === "function") {
|
||||
try {
|
||||
const inst = new maybeExport();
|
||||
if (inst && typeof inst.initialize === "function") return inst;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (typeof maybeExport === "object" && typeof maybeExport.initialize === "function") return maybeExport;
|
||||
return null;
|
||||
}
|
||||
|
||||
let plugin = null;
|
||||
if (mod.default) {
|
||||
plugin = typeof mod.default === "function"
|
||||
? (tryInstantiate(mod.default) ?? new mod.default())
|
||||
: mod.default;
|
||||
}
|
||||
if (!plugin) {
|
||||
for (const k of Object.keys(mod)) {
|
||||
plugin = tryInstantiate(mod[k]);
|
||||
if (plugin) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!plugin) {
|
||||
console.error("FAIL [Tier 2] No valid WorldPlugin export found in bundle.");
|
||||
process.exit(1);
|
||||
}
|
||||
console.log("OK [Tier 2] Bundle loaded and plugin instantiated");
|
||||
|
||||
// ── Tier 2: Required interface fields ────────────────────────────────────────
|
||||
const REQUIRED_STRINGS = ["id", "name", "description", "category", "version"];
|
||||
const REQUIRED_METHODS = ["initialize", "destroy", "fetch", "getPollingInterval", "getLayerConfig", "renderEntity"];
|
||||
let passed = true;
|
||||
|
||||
for (const field of REQUIRED_STRINGS) {
|
||||
if (typeof plugin[field] !== "string" || !plugin[field]) {
|
||||
console.error(`FAIL [Tier 2] Missing or empty string field: "${field}" (got ${JSON.stringify(plugin[field])})`);
|
||||
passed = false;
|
||||
} else {
|
||||
console.log(` ok ${field} = ${JSON.stringify(plugin[field])}`);
|
||||
}
|
||||
}
|
||||
for (const method of REQUIRED_METHODS) {
|
||||
if (typeof plugin[method] !== "function") {
|
||||
console.error(`FAIL [Tier 2] Missing required method: ${method}()`);
|
||||
passed = false;
|
||||
} else {
|
||||
console.log(` ok ${method}()`);
|
||||
}
|
||||
}
|
||||
|
||||
if (!passed) {
|
||||
console.error("FAIL [Tier 2] WorldPlugin shape validation failed — see above");
|
||||
process.exit(1);
|
||||
}
|
||||
console.log("OK [Tier 2] WorldPlugin interface shape validated");
|
||||
|
||||
// ── Tier 3: Exercise pure methods ─────────────────────────────────────────────
|
||||
// These methods must be callable without a real engine or network.
|
||||
|
||||
// getPollingInterval()
|
||||
try {
|
||||
const interval = plugin.getPollingInterval();
|
||||
if (typeof interval !== "number" || interval < 0) {
|
||||
console.error(`FAIL [Tier 3] getPollingInterval() returned invalid value: ${JSON.stringify(interval)}`);
|
||||
passed = false;
|
||||
} else {
|
||||
console.log(` ok getPollingInterval() = ${interval}`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`FAIL [Tier 3] getPollingInterval() threw: ${err.message}`);
|
||||
passed = false;
|
||||
}
|
||||
|
||||
// getLayerConfig()
|
||||
let layerConfig;
|
||||
try {
|
||||
layerConfig = plugin.getLayerConfig();
|
||||
if (!layerConfig || typeof layerConfig !== "object") {
|
||||
console.error(`FAIL [Tier 3] getLayerConfig() returned non-object: ${JSON.stringify(layerConfig)}`);
|
||||
passed = false;
|
||||
} else if (typeof layerConfig.color !== "string") {
|
||||
console.error(`FAIL [Tier 3] getLayerConfig().color is not a string: ${JSON.stringify(layerConfig.color)}`);
|
||||
passed = false;
|
||||
} else {
|
||||
console.log(` ok getLayerConfig() color=${layerConfig.color}`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`FAIL [Tier 3] getLayerConfig() threw: ${err.message}`);
|
||||
passed = false;
|
||||
}
|
||||
|
||||
// renderEntity() with a mock GeoEntity
|
||||
const mockEntity = {
|
||||
id: "ci-smoke-001",
|
||||
pluginId: plugin.id,
|
||||
latitude: 37.7749,
|
||||
longitude: -122.4194,
|
||||
altitude: 0,
|
||||
timestamp: new Date(),
|
||||
label: "Smoke Test",
|
||||
properties: {},
|
||||
};
|
||||
try {
|
||||
const opts = plugin.renderEntity(mockEntity);
|
||||
if (!opts || typeof opts !== "object") {
|
||||
console.error(`FAIL [Tier 3] renderEntity() returned non-object: ${JSON.stringify(opts)}`);
|
||||
passed = false;
|
||||
} else if (typeof opts.type !== "string") {
|
||||
console.error(`FAIL [Tier 3] renderEntity().type is not a string (got ${JSON.stringify(opts.type)})`);
|
||||
passed = false;
|
||||
} else {
|
||||
console.log(` ok renderEntity() type=${opts.type}`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`FAIL [Tier 3] renderEntity() threw: ${err.message}`);
|
||||
passed = false;
|
||||
}
|
||||
|
||||
// mapWebsocketPayload() — optional but validated when present
|
||||
if (typeof plugin.mapWebsocketPayload === "function") {
|
||||
// A flat GeoEntity[] is the simplest payload shape. Plugins that receive
|
||||
// object payloads from the seeder (e.g. { items: [...] }) must implement
|
||||
// this method to map to GeoEntity[]. We test with the flat-array case first.
|
||||
const mockPayload = [mockEntity];
|
||||
try {
|
||||
const result = plugin.mapWebsocketPayload(mockPayload, []);
|
||||
if (!Array.isArray(result)) {
|
||||
console.error(
|
||||
`FAIL [Tier 3] mapWebsocketPayload([entity]) returned non-array: ${JSON.stringify(typeof result)}`
|
||||
);
|
||||
passed = false;
|
||||
} else {
|
||||
console.log(` ok mapWebsocketPayload([1 entity]) -> ${result.length} entities`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`FAIL [Tier 3] mapWebsocketPayload() threw: ${err.message}`);
|
||||
passed = false;
|
||||
}
|
||||
} else {
|
||||
console.log(" -- mapWebsocketPayload not implemented (flat GeoEntity[] assumed — OK)");
|
||||
}
|
||||
|
||||
if (!passed) {
|
||||
console.error("FAIL [Tier 3] Method contract violations — see above");
|
||||
process.exit(1);
|
||||
}
|
||||
console.log("OK [Tier 3] Method contracts validated");
|
||||
console.log("PASS smoke test complete");
|
||||
+7
-40
@@ -148,9 +148,6 @@ const ANTI_PATTERNS = [
|
||||
tier: 'A',
|
||||
globs: ['*.ts', '*.tsx'],
|
||||
pattern: '@ts-ignore',
|
||||
// Only flag the actual suppression directive form (// @ts-ignore or /* @ts-ignore),
|
||||
// not the token appearing in JSDoc prose (e.g. "No @ts-ignore used here").
|
||||
directiveOnly: true,
|
||||
desc: '@ts-ignore suppresses real type errors — remove and fix the underlying type',
|
||||
},
|
||||
{
|
||||
@@ -158,7 +155,6 @@ const ANTI_PATTERNS = [
|
||||
tier: 'A',
|
||||
globs: ['*.ts', '*.tsx'],
|
||||
pattern: '@ts-nocheck',
|
||||
directiveOnly: true,
|
||||
desc: '@ts-nocheck disables all type checking for the file — remove and fix types',
|
||||
},
|
||||
{
|
||||
@@ -179,7 +175,7 @@ const ANTI_PATTERNS = [
|
||||
];
|
||||
|
||||
function detectAntiPatterns() {
|
||||
for (const { id, tier, globs, pattern, desc, excludePrefix, directiveOnly } of ANTI_PATTERNS) {
|
||||
for (const { id, tier, globs, pattern, desc, excludePrefix } of ANTI_PATTERNS) {
|
||||
const globArgs = globs.map(g => `"${g}"`).join(' ');
|
||||
const raw = run(`git grep -En "${pattern}" -- ${globArgs}`);
|
||||
if (!raw) continue;
|
||||
@@ -193,19 +189,13 @@ function detectAntiPatterns() {
|
||||
const m = line.match(/^([^:]+):(\d+):(.*)/);
|
||||
if (!m) continue;
|
||||
if (m[1].startsWith('node_modules/') || m[1].includes('public/cesium')) continue;
|
||||
const content = m[3].trim();
|
||||
// For directive-only patterns (e.g. @ts-ignore), skip lines where the token
|
||||
// appears in prose rather than as a comment suppression directive.
|
||||
// A real directive has @ts-ignore/@ts-nocheck immediately after the // or /*
|
||||
// comment opener — not buried mid-sentence in a comment that mentions it.
|
||||
if (directiveOnly && !/^\s*\/[/*]\s*@ts-(ignore|nocheck)/.test(m[3])) continue;
|
||||
add({
|
||||
type: 'anti-pattern',
|
||||
patternId: id,
|
||||
tier,
|
||||
file: m[1],
|
||||
line: parseInt(m[2], 10),
|
||||
content: content.slice(0, 200),
|
||||
content: m[3].trim().slice(0, 200),
|
||||
description: desc,
|
||||
});
|
||||
}
|
||||
@@ -316,36 +306,13 @@ function detectOutdatedDeps() {
|
||||
if (!existsSync(join(ROOT, 'package.json'))) return;
|
||||
const raw = run('pnpm outdated --no-color 2>/dev/null || true');
|
||||
if (!raw) return;
|
||||
// pnpm outdated renders a Unicode box-drawing table. Data rows start with │ and
|
||||
// contain pipe-separated columns; separator/border rows contain ─ or ┼ characters.
|
||||
// We extract data rows by splitting on │ and discarding header/separator lines.
|
||||
const SEPARATOR_CHARS = /[┌┐└┘├┤─]/;
|
||||
const tableDataRows = raw
|
||||
const dataLines = raw
|
||||
.split('\n')
|
||||
.filter(l => l.startsWith('│') && !SEPARATOR_CHARS.test(l));
|
||||
// Fall back to plain whitespace-separated output (older pnpm / --no-color plain format)
|
||||
const plainDataLines = !tableDataRows.length
|
||||
? raw.split('\n').filter(l => l.trim() && !l.startsWith('Package') && !l.startsWith('Legend') && !l.startsWith(' '))
|
||||
: [];
|
||||
|
||||
const dataLines = tableDataRows.length ? tableDataRows : plainDataLines;
|
||||
|
||||
.filter(l => l.trim() && !l.startsWith('Package') && !l.startsWith('Legend') && !l.startsWith(' '));
|
||||
for (const line of dataLines.slice(0, 12)) {
|
||||
let pkg, current, latest;
|
||||
if (tableDataRows.length) {
|
||||
// Parse │ col1 │ col2 │ col3 │ format
|
||||
const cols = line.split('│').map(c => c.trim()).filter(Boolean);
|
||||
if (cols.length < 3) continue;
|
||||
// Header row: first column is literally "Package"
|
||||
if (cols[0] === 'Package') continue;
|
||||
[pkg, current, latest] = cols;
|
||||
// current may be "1.2.3 (wanted 1.2.4)" — extract just the installed version
|
||||
current = current.split(' ')[0];
|
||||
} else {
|
||||
const cols = line.trim().split(/\s+/);
|
||||
if (cols.length < 3) continue;
|
||||
[pkg, current, latest] = cols;
|
||||
}
|
||||
const cols = line.trim().split(/\s+/);
|
||||
if (cols.length < 3) continue;
|
||||
const [pkg, current, latest] = cols;
|
||||
if (!pkg || !current || !latest || current === latest) continue;
|
||||
const isMajor = current.replace(/^[^0-9]*/, '').split('.')[0] !== latest.replace(/^[^0-9]*/, '').split('.')[0];
|
||||
add({
|
||||
|
||||
@@ -30,14 +30,7 @@ export default function LoginForm() {
|
||||
setLoading(true);
|
||||
|
||||
const formData = new FormData(e.currentTarget);
|
||||
let result;
|
||||
try {
|
||||
result = await loginAction(formData);
|
||||
} catch {
|
||||
setError("Something went wrong. Please try again.");
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
const result = await loginAction(formData);
|
||||
|
||||
if (result.success) {
|
||||
const target = getSafeRedirect(next);
|
||||
|
||||
@@ -28,10 +28,6 @@ export async function loginAction(formData: FormData): Promise<LoginResult> {
|
||||
: "Something went wrong.",
|
||||
};
|
||||
}
|
||||
// Non-AuthError (e.g. DB unavailable, missing column, network issue):
|
||||
// log server-side and return a safe generic message so the client
|
||||
// never receives raw stack traces and loading state always resets.
|
||||
console.error("[loginAction] unexpected error:", error);
|
||||
return { success: false, error: "Something went wrong. Please try again." };
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ export function BottomPanelManager() {
|
||||
);
|
||||
|
||||
const isCoveredRef = useRef(false);
|
||||
const isDraggingRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (activeBottomPanel) {
|
||||
@@ -40,18 +39,17 @@ export function BottomPanelManager() {
|
||||
}, [activeBottomPanel]);
|
||||
|
||||
// Pointer-capture drag handlers — attached directly to the resize handle element.
|
||||
// setPointerCapture ensures pointermove/pointerup are delivered to the element even
|
||||
// when the pointer leaves its bounds (required for fast real-user drags and Playwright).
|
||||
// isDraggingRef guards the move handler instead of hasPointerCapture, which has
|
||||
// inconsistent behaviour across webkit versions in CI for repeated drag sequences.
|
||||
// Using setPointerCapture ensures pointermove/pointerup are delivered to the
|
||||
// element even when the pointer leaves it, which is required for webkit
|
||||
// (without capture, webkit drops synthetic pointermove events from Playwright
|
||||
// and from fast real-user drags that leave the element bounds).
|
||||
const handleResizePointerDown = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
e.currentTarget.setPointerCapture(e.pointerId);
|
||||
isDraggingRef.current = true;
|
||||
document.body.classList.add("is-dragging-bottom-panel");
|
||||
};
|
||||
|
||||
const handleResizePointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (!isDraggingRef.current) return;
|
||||
if (!e.currentTarget.hasPointerCapture(e.pointerId)) return;
|
||||
const newHeight = window.innerHeight - e.clientY;
|
||||
const clampedHeight = Math.max(120, Math.min(newHeight, window.innerHeight - 100));
|
||||
setBottomPanelHeight(clampedHeight);
|
||||
@@ -59,7 +57,6 @@ export function BottomPanelManager() {
|
||||
|
||||
const handleResizePointerUp = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
e.currentTarget.releasePointerCapture(e.pointerId);
|
||||
isDraggingRef.current = false;
|
||||
document.body.classList.remove("is-dragging-bottom-panel");
|
||||
};
|
||||
|
||||
|
||||
@@ -375,53 +375,3 @@ describe("validateManifest no execution field required (MAN-04)", () => {
|
||||
expect(hasExecutionError).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SEC-URL: entry URL allowlist must host-match the PARSED hostname.
|
||||
// Substring checks (includes / startsWith on the raw string) are bypassable
|
||||
// and would allow an attacker-controlled origin to serve the imported bundle.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe("validateManifest entry URL allowlist (security)", () => {
|
||||
const ERR =
|
||||
"entry URL must be a relative path, CDN, localhost, or worldwideview.dev domain";
|
||||
|
||||
const accepts = (entry: string) => {
|
||||
const result = validateManifest(baseManifest({ entry }));
|
||||
expect(result.errors, `expected "${entry}" to be accepted`).not.toContain(ERR);
|
||||
};
|
||||
const rejects = (entry: string) => {
|
||||
const result = validateManifest(baseManifest({ entry }));
|
||||
expect(result.errors, `expected "${entry}" to be rejected`).toContain(ERR);
|
||||
};
|
||||
|
||||
it("accepts relative and exact known-host absolute entries", () => {
|
||||
accepts("/plugins/test/frontend.mjs");
|
||||
accepts("./frontend.mjs");
|
||||
accepts("https://unpkg.com/@wwv/plugin/frontend.mjs");
|
||||
accepts("https://cdn.jsdelivr.net/npm/@wwv/plugin/frontend.mjs");
|
||||
accepts("https://marketplace.worldwideview.dev/p/frontend.mjs");
|
||||
accepts("https://worldwideview.dev/p/frontend.mjs");
|
||||
accepts("http://localhost:3000/plugins/x/frontend.mjs");
|
||||
accepts("http://127.0.0.1:5000/plugins/x/frontend.mjs");
|
||||
accepts("http://[::1]:5000/plugins/x/frontend.mjs");
|
||||
});
|
||||
|
||||
it("rejects substring-bypass hostnames the old check allowed", () => {
|
||||
rejects("https://unpkg.com.evil.com/frontend.mjs");
|
||||
rejects("https://cdn.jsdelivr.net.evil.com/frontend.mjs");
|
||||
rejects("https://sub.worldwideview.dev.evil.com/frontend.mjs");
|
||||
rejects("https://evil.com/#.worldwideview.dev");
|
||||
rejects("https://evil.com/?x=.worldwideview.dev");
|
||||
rejects("http://localhost.evil.com/frontend.mjs");
|
||||
rejects("https://hacker.com/malicious.js");
|
||||
});
|
||||
|
||||
it("rejects protocol-relative, slash-backslash, userinfo and non-http(s) scheme tricks", () => {
|
||||
rejects("//evil.com/frontend.mjs");
|
||||
rejects("/\\evil.com/frontend.mjs");
|
||||
rejects("https://[email protected]/frontend.mjs");
|
||||
rejects("javascript:alert(1)");
|
||||
rejects("data:text/javascript,alert(1)");
|
||||
});
|
||||
});
|
||||
@@ -86,41 +86,25 @@ export function validateManifest(
|
||||
errors.push("Missing required field: entry");
|
||||
} else {
|
||||
const entry = manifest.entry.trim();
|
||||
// A relative path starts with "/" or "./". Reject protocol-relative
|
||||
// ("//host") and slash-backslash ("/\\host") forms: they start with "/"
|
||||
// but resolve to an EXTERNAL origin when import()-ed.
|
||||
const isRelative =
|
||||
entry.startsWith("./") ||
|
||||
(entry.startsWith("/") && entry[1] !== "/" && entry[1] !== "\\");
|
||||
const isRelative = entry.startsWith("/") || entry.startsWith("./");
|
||||
const isLocal = entry.startsWith("http://localhost") || entry.startsWith("http://127.0.0.1");
|
||||
const isWWV = entry.includes(".worldwideview.dev");
|
||||
const isCDN = entry.startsWith("https://cdn.jsdelivr.net") || entry.startsWith("https://unpkg.com");
|
||||
|
||||
// Absolute entry URLs are host-matched against an allowlist using the
|
||||
// PARSED hostname. Substring checks on the raw string (includes /
|
||||
// startsWith) are bypassable, e.g. "https://unpkg.com.evil.com/x.mjs"
|
||||
// or "https://sub.worldwideview.dev.evil.com/x.mjs", which would let an
|
||||
// attacker-controlled origin serve the dynamically imported bundle (RCE).
|
||||
let isAllowedHost = false;
|
||||
if (!isRelative) {
|
||||
// Accept bundles served from a configured marketplace/instance host
|
||||
// (e.g. marketplace.wwv.local) derived from env, so custom deployment
|
||||
// hostnames work without being hardcoded.
|
||||
let isConfiguredHost = false;
|
||||
if (ENV_ALLOWED_ENTRY_HOSTS.size > 0) {
|
||||
try {
|
||||
const url = new URL(entry);
|
||||
const host = url.hostname;
|
||||
const isSecure = url.protocol === "https:";
|
||||
const isLocalhost =
|
||||
(url.protocol === "http:" || isSecure) &&
|
||||
(host === "localhost" || host === "127.0.0.1" || host === "[::1]");
|
||||
const isWWV =
|
||||
isSecure &&
|
||||
(host === "worldwideview.dev" || host.endsWith(".worldwideview.dev"));
|
||||
const isCDN = isSecure && (host === "cdn.jsdelivr.net" || host === "unpkg.com");
|
||||
// Operator-configured hosts (from NEXT_PUBLIC_*MARKETPLACE_URL) are an
|
||||
// explicit deployment opt-in, so their protocol is trusted as set.
|
||||
const isConfiguredHost = ENV_ALLOWED_ENTRY_HOSTS.has(host);
|
||||
isAllowedHost = isLocalhost || isWWV || isCDN || isConfiguredHost;
|
||||
isConfiguredHost = ENV_ALLOWED_ENTRY_HOSTS.has(new URL(entry).hostname);
|
||||
} catch {
|
||||
// Not a parseable absolute URL and not relative: rejected below.
|
||||
// Relative paths and other non-absolute entries aren't parseable
|
||||
// as full URLs — they're already covered by `isRelative`.
|
||||
}
|
||||
}
|
||||
|
||||
if (!isRelative && !isAllowedHost) {
|
||||
if (!isRelative && !isLocal && !isWWV && !isCDN && !isConfiguredHost) {
|
||||
errors.push("entry URL must be a relative path, CDN, localhost, or worldwideview.dev domain");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user