@jxsuite/server 0.20.0 → 0.21.1
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.
- package/package.json +7 -4
- package/src/studio-api.js +45 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jxsuite/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"description": "Jx development server with live reload, server-side proxy, and studio integration",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -20,13 +20,16 @@
|
|
|
20
20
|
"provenance": true
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"upgrade": "bunx npm-check-updates -u && bun install"
|
|
23
|
+
"upgrade": "bunx npm-check-updates -u && bun install",
|
|
24
|
+
"test": "bun test --isolate",
|
|
25
|
+
"test:coverage": "bun test --isolate --coverage"
|
|
24
26
|
},
|
|
25
27
|
"dependencies": {
|
|
26
|
-
"@anthropic-ai/claude-agent-sdk": "^0.3.
|
|
28
|
+
"@anthropic-ai/claude-agent-sdk": "^0.3.153",
|
|
27
29
|
"@anthropic-ai/sdk": "^0.99.0",
|
|
30
|
+
"@jxsuite/compiler": "^0.21.1",
|
|
28
31
|
"@jxsuite/create": "^0.19.0",
|
|
29
|
-
"@jxsuite/parser": "^0.
|
|
32
|
+
"@jxsuite/parser": "^0.21.1",
|
|
30
33
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
31
34
|
"chokidar": "^5.0.0",
|
|
32
35
|
"zod": "^4.4.3"
|
package/src/studio-api.js
CHANGED
|
@@ -11,6 +11,7 @@ import { resolve, relative, basename, dirname, isAbsolute } from "node:path";
|
|
|
11
11
|
import { readdir, stat, readFile, writeFile, rename, unlink, mkdir } from "node:fs/promises";
|
|
12
12
|
import { readFileSync, existsSync } from "node:fs";
|
|
13
13
|
import { transpileJxMarkdown } from "@jxsuite/parser/transpile";
|
|
14
|
+
import { loadContentTypes, queryContentType, findEntry } from "@jxsuite/compiler/content-loader";
|
|
14
15
|
import * as claude from "./claude-session.js";
|
|
15
16
|
|
|
16
17
|
/** Normalise a path to forward slashes (Windows `path` module returns backslashes). */
|
|
@@ -1066,6 +1067,50 @@ export async function handleStudioApi(req, url, root, activeProjectRoot = null)
|
|
|
1066
1067
|
}
|
|
1067
1068
|
}
|
|
1068
1069
|
|
|
1070
|
+
// ─── Content Type Resolution ──────────────────────────────────────────────
|
|
1071
|
+
|
|
1072
|
+
if (path === "/__studio/content" && req.method === "POST") {
|
|
1073
|
+
try {
|
|
1074
|
+
const body = await req.json();
|
|
1075
|
+
const { $prototype, contentType, id, filter, sort, limit } = body;
|
|
1076
|
+
const projectRoot = activeProjectRoot || root;
|
|
1077
|
+
|
|
1078
|
+
let projectConfig;
|
|
1079
|
+
try {
|
|
1080
|
+
projectConfig = JSON.parse(readFileSync(resolve(projectRoot, "project.json"), "utf8"));
|
|
1081
|
+
} catch {
|
|
1082
|
+
return Response.json({ error: "No project.json found" }, { status: 404 });
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
if (!projectConfig.contentTypes?.[contentType]) {
|
|
1086
|
+
return Response.json({ error: `Content type "${contentType}" not found` }, { status: 404 });
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
const contentTypes = await loadContentTypes(projectRoot, projectConfig);
|
|
1090
|
+
const entries = contentTypes.get(contentType);
|
|
1091
|
+
if (!entries || entries.length === 0) {
|
|
1092
|
+
return Response.json($prototype === "ContentCollection" ? [] : null);
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
if ($prototype === "ContentCollection") {
|
|
1096
|
+
const result = queryContentType(entries, { filter, sort, limit });
|
|
1097
|
+
return Response.json(result);
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
if ($prototype === "ContentEntry") {
|
|
1101
|
+
const entry = findEntry(entries, id);
|
|
1102
|
+
return Response.json(entry ?? null);
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
return Response.json({ error: "Invalid $prototype" }, { status: 400 });
|
|
1106
|
+
} catch (/** @type {unknown} */ e) {
|
|
1107
|
+
return Response.json(
|
|
1108
|
+
{ error: /** @type {{ message?: string }} */ (e).message },
|
|
1109
|
+
{ status: 500 },
|
|
1110
|
+
);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1069
1114
|
// ─── AI Assistant ─────────────────────────────────────────────────────────
|
|
1070
1115
|
|
|
1071
1116
|
if (path === "/__studio/ai/auth-status" && req.method === "GET") {
|