Compare commits

..
Author SHA1 Message Date
Antigravity AI a0646a5ab1 fix: merge origin/main, resolve version conflict (bump to 2.48.24)
Merged latest main (2.48.23) into fix/hardcoded-engine-urls. Resolved the
single conflict in package.json by taking main's changes and bumping the
version to 2.48.24 per the patch-level commit rule.
2026-06-05 00:28:16 +12:00
Antigravity AI 3200d38194 refactor(env): rename NEXT_PUBLIC_WWV_DATA_ENGINE_URL to NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL
Rename the env var to make its scope unambiguous: it is a local dev
override only and must never be set in production. Split the old single
var into two with clearly documented purposes:

- NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL (local dev, .env.local, browser+server)
  Used by resolveEngineUrl.ts and engineManifest.ts to redirect WS
  connections to a locally-running engine during plugin development.
  Each worktree should use a different port to avoid collisions.

- WWV_DATA_ENGINE_URL (production, docker-compose/Coolify, server-side only)
  Used by service.ts for MCP REST calls to the engine. NOT read by
  the browser. Set in docker-compose, not in .env.local.

service.ts shim reads WWV_DATA_ENGINE_URL first so existing production
docker-compose deployments are not broken by this rename.

Also fixes stale dataengine.worldwideview.dev subdomain references in
hostGlobals.ts (cloud fallback URLs now correctly point to dataenginev2).
2026-06-05 00:24:27 +12:00
Antigravity AI 1831e7e5d8 docs(rules): document data engine agnosticism separation of concern
Add an explicit rule section clarifying that plugins own their streamUrl,
WWV never overrides it globally, and the NEXT_PUBLIC_WWV_DATA_ENGINE_URL var
is for server-side REST calls only -- not plugin streaming.
2026-06-04 22:35:45 +12:00
Antigravity AI 0f43baacf0 fix(engine): replace stale dataengine subdomain with dataenginev2
hostGlobals.ts and resolveEngineUrl.ts comment both referenced the old
dataengine.worldwideview.dev subdomain; updated to dataenginev2.worldwideview.dev.
2026-06-04 22:35:17 +12:00
Antigravity AI 138f26c8e8 refactor(data-engine): consolidate engine URL to single NEXT_PUBLIC_WWV_DATA_ENGINE_URL
Replaces two separate env vars (NEXT_PUBLIC_WWV_LOCAL_ENGINE_PORT and
WWV_DATA_ENGINE_URL) with one: NEXT_PUBLIC_WWV_DATA_ENGINE_URL (full
HTTP base URL, default http://localhost:5000). Available both client-side
and server-side so it only needs to be defined once.

- engineManifest.ts: getLocalEngineBase() reads the new var directly
- resolveEngineUrl.ts: getLocalWsUrl() converts http->ws from the new var
- service.ts: getEngineUrl() reads the new var (fixes 5001->5000 default)
- Tests updated to set the full URL instead of a port number
- .env.example documents the new var with local and Docker examples
2026-06-04 22:24:08 +12:00
Antigravity AI cdad4dc776 fix(data-engine): replace hardcoded engine URLs with env var
Deduplicates the WWV_DATA_ENGINE_URL fallback: discoveryHelpers.ts now
calls getEngineUrl() from data-query/service instead of inlining the
same logic. Comments and test mocks that referenced literal localhost:5001
or localhost:5000 now reference NEXT_PUBLIC_WWV_LOCAL_ENGINE_PORT or use
a generic test host. Closes #182.
2026-06-04 21:10:21 +12:00
26 changed files with 193 additions and 1279 deletions

No files matched your search

+16
View File
@@ -12,6 +12,22 @@ paths:
## Purpose
The standard operating procedure for instantiating, modifying, and registering a new data source plugin within the engine.
## Data Engine Agnosticism (Separation of Concern)
> [!IMPORTANT]
> **WWV is agnostic to which data engine a plugin uses.** Each plugin MUST declare its own `streamUrl` in `getServerConfig()`. The WWV application never controls or overrides plugin stream URLs.
This is intentional architectural separation: a user can have 30 plugins pointing to 30 different custom backend servers, and WWV opens 30 separate WebSocket connections without caring. The WWV app does not have a "the data engine" — each plugin has its own.
**Practical rules:**
- Plugins hardcode their cloud engine URL (e.g. `wss://dataenginev2.worldwideview.dev/stream`) — this is correct and by design.
- Do not add env vars to let WWV override a plugin's `streamUrl` globally — that breaks the separation.
- When editing a plugin's fallback fetch URL, use `https://dataenginev2.worldwideview.dev` (note the `v2`).
- `NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL` is a local dev only var (`.env.local` only, never production) that routes locally-developed plugin seeders to a local engine instance. It is NOT injected into plugin stream URLs.
- `WWV_DATA_ENGINE_URL` is the production server-side var (docker-compose / Coolify) for the WWV app's own REST calls (MCP tools, entity search). Never set `NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL` in production.
---
## The WorldPlugin Contract
All data ingest flows through `WorldPlugin` (defined entirely within `@worldwideview/wwv-plugin-sdk`).
+13
View File
@@ -96,6 +96,19 @@ PROXY_HOST_ALLOWLIST=*
# Comma-separated list of plugin IDs
NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS=
# Local Engine URL (local dev only — set in .env.local, NEVER in production)
# Points at your local data engine instance for per-plugin WS stream routing.
# Each worktree should use a different port so their engines don't collide.
# Local dev (engine on host): http://localhost:5000
NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL=
# Data Engine REST URL (production / Docker Compose — server-side only)
# Used by MCP data tools and server-side entity queries to reach the engine REST API.
# NOT read by the browser. Set this in docker-compose or Coolify, not in .env.local.
# Docker Compose (same network): http://wwv-data-engine:5000
# External engine: http://<engine-host-ip>:5002
# WWV_DATA_ENGINE_URL=
# Edition: "local" | "cloud" | "demo"
NEXT_PUBLIC_WWV_EDITION=local
-93
View File
@@ -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
+38
View File
@@ -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
-26
View File
@@ -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:
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "worldwideview",
"version": "2.48.30",
"version": "2.48.24",
"private": true,
"type": "module",
"packageManager": "[email protected]",
+1 -6
View File
@@ -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"
}
}
+1 -6
View File
@@ -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
View File
@@ -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
View File
@@ -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;AAI3C,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAKpC,MAAM,WAAW,cAAe,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oEAAoE;IACpE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,EACxB,IAAI,GAAE,cAAmB,GAC1B,MAAM,CA4BR;AAGD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAGzM,MAAM,MAAM,cAAc,GACpB,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,kBAAkB,GAClB,gBAAgB,GAChB,OAAO,GACP,OAAO,GACP,UAAU,GACV,cAAc,GACd,QAAQ,CAAC;AAGf,MAAM,WAAW,SAAS;IACtB,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;CACb;AAED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CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAE1C;;;;GAIG;AACH,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,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 -1
View File
@@ -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",
+1 -1
View File
@@ -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") {
+6 -856
View File
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;
-247
View File
@@ -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");
+2 -2
View File
@@ -15,7 +15,7 @@
import type { PluginDataSnapshot } from "@/lib/data-query/types";
import type { RegionOptions } from "@/lib/data-query/types";
import type { FilterDefinition } from "@/core/plugins/PluginTypes";
import { getAllPluginSnapshots } from "@/lib/data-query/service";
import { getAllPluginSnapshots, getEngineUrl } from "@/lib/data-query/service";
import { getLocalSourceIds } from "@/lib/data-query/localSources";
import { readActiveSessions, readGlobeState } from "@/lib/globeStateStore";
import { readSessionCatalog } from "@/lib/mcpSessionCatalog";
@@ -112,7 +112,7 @@ export interface ListStreamingPluginsResult {
* are not blocked waiting for a slow engine.
*/
async function probeEngineReachable(): Promise<boolean> {
const engineUrl = (process.env.WWV_DATA_ENGINE_URL ?? "http://localhost:5001") + "/manifest";
const engineUrl = getEngineUrl() + "/manifest";
try {
const res = await fetch(engineUrl, { signal: AbortSignal.timeout(2000) });
return res.ok;
+1 -8
View File
@@ -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);
+1 -5
View File
@@ -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;
}
}
+1 -1
View File
@@ -64,7 +64,7 @@ describe("resolveEngineUrl", () => {
await fetchLocalEngineManifest();
const url = resolveEngineUrl("plugin-local");
expect(url).toContain("localhost:5000/stream");
expect(url).toMatch(/ws:\/\/localhost:\d+\/stream/);
});
it("should fall back to plugin's custom streamUrl if not local", () => {
@@ -0,0 +1,46 @@
// src/core/data/__tests__/engineManifest.test.ts
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { fetchLocalEngineManifest, resetManifestCache } from '../engineManifest';
const mockFetch = vi.fn();
describe('fetchLocalEngineManifest', () => {
beforeEach(() => {
resetManifestCache();
mockFetch.mockReset();
vi.stubGlobal('fetch', mockFetch);
});
afterEach(() => {
vi.unstubAllGlobals();
delete process.env.NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL;
});
it('probes port 5000 when NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL is not set', async () => {
mockFetch.mockResolvedValue({ ok: false } as Response);
await fetchLocalEngineManifest();
expect(mockFetch).toHaveBeenCalledWith(
expect.stringContaining(':5000/manifest'),
expect.any(Object)
);
});
it('probes the env-configured URL when NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL is set', async () => {
process.env.NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL = 'http://localhost:5003';
mockFetch.mockResolvedValue({ ok: false } as Response);
await fetchLocalEngineManifest();
expect(mockFetch).toHaveBeenCalledWith(
expect.stringContaining(':5003/manifest'),
expect.any(Object)
);
});
it('returns plugin list when engine responds successfully', async () => {
mockFetch.mockResolvedValue({
ok: true,
json: async () => ({ plugins: ['flight-tracker', 'ais-tracker'] }),
} as Response);
const result = await fetchLocalEngineManifest();
expect(result).toEqual(['flight-tracker', 'ais-tracker']);
});
});
@@ -0,0 +1,42 @@
// src/core/data/__tests__/resolveEngineUrl.test.ts
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
vi.mock('../engineManifest', () => ({
localEngineHasPlugin: vi.fn(),
}));
vi.mock('@/core/plugins/PluginManager', () => ({
pluginManager: {
getPlugin: vi.fn().mockReturnValue(null),
getManifest: vi.fn().mockReturnValue(null),
},
}));
import { resolveEngineUrl } from '../resolveEngineUrl';
import { localEngineHasPlugin } from '../engineManifest';
describe('resolveEngineUrl', () => {
beforeEach(() => {
vi.mocked(localEngineHasPlugin).mockReset();
});
afterEach(() => {
delete process.env.NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL;
});
it('uses port 5000 by default when no env var is set', () => {
vi.mocked(localEngineHasPlugin).mockReturnValue(true);
expect(resolveEngineUrl('test-plugin')).toContain(':5000/stream');
});
it('uses the configured URL when NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL is set', () => {
process.env.NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL = 'http://localhost:5003';
vi.mocked(localEngineHasPlugin).mockReturnValue(true);
expect(resolveEngineUrl('test-plugin')).toContain(':5003/stream');
});
it('falls back to cloud URL when local engine does not have the plugin', () => {
vi.mocked(localEngineHasPlugin).mockReturnValue(false);
expect(resolveEngineUrl('test-plugin')).toContain('worldwideview.dev');
});
});
+5 -8
View File
@@ -8,16 +8,13 @@ let manifestFetched = false;
/**
* Resolve the base URL of the local data engine.
*
* Always checks localhost:5000 — the port docker-compose.yml binds for
* wwv-data-engine. NEXT_PUBLIC_WWV_PLUGIN_DATA_ENGINE_URL is intentionally
* NOT used here: that variable belongs to each plugin's own declared engine
* URL (production, third-party, etc.) and must not poison local detection.
* Mixing the two caused the production engine to be reported as "local".
* Reads NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL (default http://localhost:5000).
* Only set this in .env.local for local development — never in production.
* Each plugin owns its own streamUrl; this variable is only for routing
* locally-developed plugin seeders to a local engine instance.
*/
function getLocalEngineBase() {
const port = process.env.NEXT_PUBLIC_WWV_LOCAL_ENGINE_PORT || '5000';
if (typeof window === "undefined") return `http://localhost:${port}`;
return `${window.location.protocol}//${window.location.hostname}:${port}`;
return process.env.NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL ?? 'http://localhost:5000';
}
/**
+5 -5
View File
@@ -20,19 +20,19 @@ function toWsStreamUrl(url: string): string {
const DEFAULT_ENGINE_URL = toWsStreamUrl(RAW_ENGINE_URL);
function getLocalWsUrl() {
const port = process.env.NEXT_PUBLIC_WWV_LOCAL_ENGINE_PORT || '5000';
if (typeof window === "undefined") return `ws://localhost:${port}/stream`;
return `${window.location.protocol === "https:" ? "wss:" : "ws:"}//${window.location.hostname}:${port}/stream`;
const base = process.env.NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL ?? 'http://localhost:5000';
const ws = base.replace(/^https:\/\//, 'wss://').replace(/^http:\/\//, 'ws://');
return ws.replace(/\/+$/, '') + '/stream';
}
/**
* Resolves the WebSocket engine URL for a given plugin.
*
* Resolution order:
* 1. Local engine (if running at localhost:5000 and has this plugin's seeder)
* 1. Local engine (if running at NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL and has this plugin's seeder)
* 2. Plugin's ServerPluginConfig.streamUrl (code-based plugins)
* 3. Plugin's PluginManifest.dataSource.streamUrl (manifest-based plugins)
* 4. NEXT_PUBLIC_WWV_PLUGIN_DATA_ENGINE_URL env var
* 5. Fallback: wss://dataengine.worldwideview.dev/stream (cloud)
* 5. Fallback: wss://dataenginev2.worldwideview.dev/stream (cloud)
*/
export function resolveEngineUrl(pluginId: string): string {
// 1. Local engine (split-routing) - PRIORITY #1
+4 -4
View File
@@ -70,18 +70,18 @@ export async function injectHostGlobals(): Promise<void> {
};
// REST Engine URL (Fallback)
// Note: Local Docker-based engine interception (localhost:5000) happens dynamically inside
// resolveEngineUrl.ts during plugin routing. These variables act as global fallbacks.
// Note: Local engine interception (via NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL) happens dynamically
// inside resolveEngineUrl.ts during plugin routing. These variables act as global fallbacks.
const envDataEngine = process.env.NEXT_PUBLIC_WWV_PLUGIN_DATA_ENGINE_URL;
if (envDataEngine) {
(globalThis as Record<string, unknown>).__WWV_ENGINE_URL__ = envDataEngine;
} else {
// ALWAYS default to the cloud engine unless explicitly told otherwise via env var
(globalThis as Record<string, unknown>).__WWV_ENGINE_URL__ = 'https://dataengine.worldwideview.dev';
(globalThis as Record<string, unknown>).__WWV_ENGINE_URL__ = 'https://dataenginev2.worldwideview.dev';
}
// WebSocket Engine URL
const fallbackWs = envDataEngine ? `${envDataEngine.replace(/^http/, "ws")}/stream` : 'wss://dataengine.worldwideview.dev/stream';
const fallbackWs = envDataEngine ? `${envDataEngine.replace(/^http/, "ws")}/stream` : 'wss://dataenginev2.worldwideview.dev/stream';
(globalThis as Record<string, unknown>).__WWV_WS_ENGINE_URL__ = fallbackWs;
console.log("[HostGlobals] React and SDK injected for dynamic plugins");
@@ -123,7 +123,7 @@ describe("DeclarativePlugin", () => {
getCurrentTime: () => new Date(),
env: {},
edition: "local",
getEngineUrl: () => "http://localhost:5001",
getEngineUrl: () => "http://test-engine/",
});
const entities = await plugin.fetch({ start: new Date(), end: new Date() });
+5 -1
View File
@@ -12,7 +12,11 @@ import type { FilterValue } from "@/core/plugins/PluginTypes";
import { hasLocalSource, resolveLocalSnapshot, getLocalSourceIds } from "./localSources";
export function getEngineUrl(): string {
return process.env.WWV_DATA_ENGINE_URL ?? "http://localhost:5001";
// WWV_DATA_ENGINE_URL = production (docker-compose, server-side only)
// NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL = local dev override
return process.env.WWV_DATA_ENGINE_URL
?? process.env.NEXT_PUBLIC_WWV_LOCAL_ENGINE_URL
?? "http://localhost:5000";
}
function normalizeEntity(raw: unknown): GeoEntity | null {