@barivia/barsom-mcp 0.18.1 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,11 +4,9 @@
4
4
  * /api/results/:jobId/image/:filename. Bind to 127.0.0.1 only; port from BARIVIA_VIZ_PORT or 0.
5
5
  */
6
6
  import http from "node:http";
7
- import { consumeTrainingReview, getTrainingReview } from "./tools/training_review_store.js";
8
7
  const ID_REGEX = /^[a-zA-Z0-9_-]+$/;
9
8
  const FILENAME_REGEX = /^[a-zA-Z0-9_.-]+$/;
10
- const REVIEW_TOKEN_REGEX = /^[a-z0-9]+$/i;
11
- const ALLOWED_VIEWS = new Set(["results-explorer", "training-prep", "training-monitor"]);
9
+ const ALLOWED_VIEWS = new Set(["results-explorer", "training-monitor"]);
12
10
  const CORS_HEADERS = {
13
11
  "Access-Control-Allow-Origin": "*",
14
12
  "Access-Control-Allow-Methods": "GET, POST, OPTIONS",
@@ -183,74 +181,6 @@ export function startVizServer(apiCall, apiRawCall, loadViewHtml) {
183
181
  }
184
182
  return;
185
183
  }
186
- // GET /api/datasets/:datasetId/preview (for data-preview standalone; query e.g. n_rows=10)
187
- const previewMatch = pathname.match(/^\/api\/datasets\/([^/]+)\/preview$/);
188
- if (req.method === "GET" && previewMatch) {
189
- const datasetId = previewMatch[1];
190
- if (!ID_REGEX.test(datasetId)) {
191
- sendJson(400, { error: "Invalid dataset_id" });
192
- return;
193
- }
194
- try {
195
- const qs = url.search || "?n_rows=10";
196
- const data = await apiCall("GET", `/v1/datasets/${datasetId}/preview${qs}`);
197
- sendJson(200, data);
198
- }
199
- catch (err) {
200
- const status = err?.httpStatus ?? 500;
201
- const message = err instanceof Error ? err.message : "Request failed";
202
- sendJson(status, { error: message });
203
- }
204
- return;
205
- }
206
- // GET /api/training-prep/:reviewToken
207
- const trainingPrepMatch = pathname.match(/^\/api\/training-prep\/([^/]+)$/);
208
- if (req.method === "GET" && trainingPrepMatch) {
209
- const reviewToken = trainingPrepMatch[1];
210
- if (!REVIEW_TOKEN_REGEX.test(reviewToken)) {
211
- sendJson(400, { error: "Invalid review_token" });
212
- return;
213
- }
214
- const review = getTrainingReview(reviewToken);
215
- if (!review) {
216
- sendJson(404, { error: "Review token expired or missing" });
217
- return;
218
- }
219
- sendJson(200, review.payload ?? {
220
- dataset_id: review.datasetId,
221
- params: review.params,
222
- review_id: review.reviewId,
223
- review_expires_at: new Date(review.expiresAt).toISOString(),
224
- });
225
- return;
226
- }
227
- // POST /api/training-prep/:reviewToken/submit
228
- const trainingPrepSubmitMatch = pathname.match(/^\/api\/training-prep\/([^/]+)\/submit$/);
229
- if (req.method === "POST" && trainingPrepSubmitMatch) {
230
- const reviewToken = trainingPrepSubmitMatch[1];
231
- if (!REVIEW_TOKEN_REGEX.test(reviewToken)) {
232
- sendJson(400, { error: "Invalid review_token" });
233
- return;
234
- }
235
- const review = consumeTrainingReview(reviewToken);
236
- if (!review) {
237
- sendJson(404, { error: "Review token expired or already used" });
238
- return;
239
- }
240
- try {
241
- const data = await apiCall("POST", "/v1/jobs", {
242
- dataset_id: review.datasetId,
243
- params: review.params,
244
- });
245
- sendJson(200, data);
246
- }
247
- catch (err) {
248
- const status = err?.httpStatus ?? 500;
249
- const message = err instanceof Error ? err.message : "Request failed";
250
- sendJson(status, { error: message });
251
- }
252
- return;
253
- }
254
184
  send(404, "Not found", "text/plain");
255
185
  });
256
186
  return new Promise((resolve, reject) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barivia/barsom-mcp",
3
- "version": "0.18.1",
3
+ "version": "0.19.0",
4
4
  "description": "barSOM MCP proxy — connect any MCP client to the barSOM cloud API for Self-Organizing Map analytics",
5
5
  "keywords": [
6
6
  "mcp",
@@ -35,7 +35,7 @@
35
35
  "minify": "terser dist/index.js -o dist/index.js -c -m --toplevel",
36
36
  "build": "tsc && npm run build:views && npm run minify",
37
37
  "build:publish": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.publish.json && npm run build:views && npm run minify",
38
- "build:views": "INPUT=src/views/results-explorer/index.html vite build && INPUT=src/views/training-prep/index.html vite build && INPUT=src/views/training-monitor/index.html vite build",
38
+ "build:views": "INPUT=src/views/results-explorer/index.html vite build && INPUT=src/views/training-monitor/index.html vite build",
39
39
  "dev": "tsx src/index.ts",
40
40
  "test": "vitest run --config vitest.config.ts",
41
41
  "prepublishOnly": "npm run build:publish"