@sigloch/graph-view-edit 0.22.0 → 0.23.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.
- package/dist/assets/{elk.bundled-DGnZovU7.js → elk.bundled-BxtaK_fH.js} +1 -1
- package/dist/assets/index-BQGzkC9X.js +168 -0
- package/dist/index.html +1 -1
- package/package.json +5 -4
- package/src/code-lookup.mjs +54 -16
- package/src/host-verlauf.mjs +65 -0
- package/vite.config.js +14 -10
- package/dist/assets/index-DH6ZJfj1.js +0 -168
package/dist/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>graph-view-edit</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-BQGzkC9X.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-B3cgYeCa.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sigloch/graph-view-edit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "React/Vite viewer+editor over @sigloch/graphcode — 12 graph-views + 16 doc-views via a declarative View-Registry, plus an SE-Dashboard sibling route. Reads docs/graph/<member>.graph.json client-side (no 2nd Kuzu handle).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"bin",
|
|
12
12
|
"vite.config.js",
|
|
13
13
|
"src/config.mjs",
|
|
14
|
-
"src/code-lookup.mjs"
|
|
14
|
+
"src/code-lookup.mjs",
|
|
15
|
+
"src/host-verlauf.mjs"
|
|
15
16
|
],
|
|
16
17
|
"scripts": {
|
|
17
18
|
"dev": "vite",
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
"comment:deps": "Runtime = what vite.config.js + bin/gve.mjs load at Node level when serving the prebuilt dist/. The UI libs (react, react-dom, elkjs, @tanstack/react-table, zustand) are bundled INTO dist/ by vite and must stay devDependencies — shipping them would make consumers download the whole UI stack twice.",
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"@sigloch/contracts": ">=12.9 <13",
|
|
26
|
-
"@sigloch/graph-api-core": ">=5.11 <
|
|
27
|
+
"@sigloch/graph-api-core": ">=5.11 <7",
|
|
27
28
|
"@sigloch/graphcode-client": ">=3.2 <4",
|
|
28
29
|
"@sigloch/se-engine": ">=3 <4",
|
|
29
30
|
"@vitejs/plugin-react": "^4.3.4",
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@playwright/test": "^1.58.2",
|
|
35
|
-
"@sigloch/graphcode": "^0.
|
|
36
|
+
"@sigloch/graphcode": "^0.42.0",
|
|
36
37
|
"@tanstack/react-table": "^8.20.5",
|
|
37
38
|
"@testing-library/react": "^16.0.1",
|
|
38
39
|
"elkjs": "^0.11.1",
|
package/src/code-lookup.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Code
|
|
3
|
-
*
|
|
2
|
+
* Code eines Knotens für die Detailspalte — Server-Seite. FUNC und SCHEMA zeigen ihren `realRef` (CR-GVE-390,
|
|
3
|
+
* CR-GVE-407), ein TEST eine Datei aus seinen `testRefs` (CR-GVE-407). Der Pfad kommt aus dem Graphen, nie aus der
|
|
4
|
+
* Anfrage: der Browser nennt nur id und Index, kann also keine beliebige Datei lesen oder öffnen.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
* ungebaute Funktion noch keinen (`missing`). Ein Skill hat kein
|
|
6
|
+
* Ein Knoten ohne Code ist ein gültiger Stand, kein Fehler: ein Block hat seinen Code in den Teilen (`block`), eine
|
|
7
|
+
* ungebaute Funktion, ein ungebundenes Schema oder ein ungebundener Test noch keinen (`missing`). Ein Skill hat kein
|
|
8
|
+
* `symbol`: die Datei ist die Funktion, Zeile 1. Eine Testdatei beginnt immer bei Zeile 1.
|
|
7
9
|
*
|
|
8
10
|
* @author andreas@siglochconsulting
|
|
9
11
|
*/
|
|
@@ -29,28 +31,64 @@ export function symbolLine(text, symbol) {
|
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* @param {{elements?: object[], traces?: object[]}} graph
|
|
32
|
-
* @param {string}
|
|
34
|
+
* @param {string} id FUNC, SCHEMA oder TEST
|
|
33
35
|
* @param {string} repoRoot
|
|
34
|
-
* @
|
|
36
|
+
* @param {number} [ref] bei TEST: Index in `testRefs`
|
|
37
|
+
* @returns {{status: 'ok', file: string, path: string, line: number, total: number, excerpt: string[], result?: string}
|
|
35
38
|
* | {status: 'block', parts: number} | {status: 'missing'} | {status: 'no-file', file: string} | {status: 'unknown'}}
|
|
36
39
|
*/
|
|
37
|
-
export function codeOf(graph,
|
|
40
|
+
export function codeOf(graph, id, repoRoot, ref = 0) {
|
|
38
41
|
const elements = graph?.elements ?? [];
|
|
39
|
-
const el = elements.find((e) => e.id ===
|
|
40
|
-
if (el?.type
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
const el = elements.find((e) => e.id === id);
|
|
43
|
+
if (el?.type === 'TEST') {
|
|
44
|
+
const refs = el.testRefs ?? [];
|
|
45
|
+
if (!refs.length) return { status: 'missing' };
|
|
46
|
+
const r = refs[ref];
|
|
47
|
+
if (!r) return { status: 'unknown' };
|
|
48
|
+
const code = excerptOf(r.file, null, repoRoot);
|
|
49
|
+
return code.status === 'ok' && r.result ? { ...code, result: r.result } : code;
|
|
50
|
+
}
|
|
51
|
+
if (el?.type !== 'FUNC' && el?.type !== 'SCHEMA') return { status: 'unknown' };
|
|
52
|
+
const realRef = el.realRef;
|
|
53
|
+
if (!realRef?.file) {
|
|
54
|
+
if (el.type === 'SCHEMA') return { status: 'missing' };
|
|
43
55
|
const isFunc = new Set(elements.filter((e) => e.type === 'FUNC').map((e) => e.id));
|
|
44
|
-
const parts = (graph.traces ?? []).filter((t) => t.type === 'compose' && t.source ===
|
|
56
|
+
const parts = (graph.traces ?? []).filter((t) => t.type === 'compose' && t.source === id && isFunc.has(t.target)).length;
|
|
45
57
|
return parts ? { status: 'block', parts } : { status: 'missing' };
|
|
46
58
|
}
|
|
47
|
-
|
|
59
|
+
return excerptOf(realRef.file, realRef.symbol, repoRoot);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Auszug ab dem Symbol, sonst ab Zeile 1. Ein Pfad aus dem Repo heraus gilt als nicht gefunden. */
|
|
63
|
+
function excerptOf(file, symbol, repoRoot) {
|
|
64
|
+
if (!file) return { status: 'missing' };
|
|
65
|
+
const path = resolve(repoRoot, file);
|
|
48
66
|
const inside = relative(repoRoot, path);
|
|
49
|
-
if (inside.startsWith('..') || isAbsolute(inside) || !existsSync(path)) return { status: 'no-file', file
|
|
67
|
+
if (inside.startsWith('..') || isAbsolute(inside) || !existsSync(path)) return { status: 'no-file', file };
|
|
50
68
|
const text = readFileSync(path, 'utf8');
|
|
51
69
|
const lines = text.split('\n');
|
|
52
|
-
const line =
|
|
53
|
-
return { status: 'ok', file
|
|
70
|
+
const line = symbol ? symbolLine(text, symbol) : 1;
|
|
71
|
+
return { status: 'ok', file, path, line, total: lines.length, excerpt: lines.slice(line - 1, line - 1 + EXCERPT_LINES) };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Die Tests einer SCHEMA (`TEST -verify-> SCHEMA`), je `testRefs`-Eintrag eine Zeile; ein Test ohne `testRefs` steht
|
|
76
|
+
* mit `ref: 0` da und zeigt dann „missing". Der Vertragstest (R-32, Datei `*.vertrag.test.*`) steht zuerst.
|
|
77
|
+
* @returns {{id: string, name: string, ref: number, file?: string}[]}
|
|
78
|
+
*/
|
|
79
|
+
export function testsOfSchema(graph, schemaId) {
|
|
80
|
+
const byId = new Map((graph?.elements ?? []).map((e) => [e.id, e]));
|
|
81
|
+
if (byId.get(schemaId)?.type !== 'SCHEMA') return [];
|
|
82
|
+
const rows = [];
|
|
83
|
+
for (const t of graph?.traces ?? []) {
|
|
84
|
+
const test = byId.get(t.source);
|
|
85
|
+
if (t.type !== 'verify' || t.target !== schemaId || test?.type !== 'TEST') continue;
|
|
86
|
+
const refs = test.testRefs ?? [];
|
|
87
|
+
if (!refs.length) rows.push({ id: test.id, name: test.name || test.id, ref: 0 });
|
|
88
|
+
refs.forEach((r, ref) => rows.push({ id: test.id, name: test.name || test.id, ref, file: r.file }));
|
|
89
|
+
}
|
|
90
|
+
const contract = (r) => (/\.vertrag\.test\./.test(r.file ?? '') ? 0 : 1);
|
|
91
|
+
return rows.sort((a, b) => contract(a) - contract(b) || a.id.localeCompare(b.id) || a.ref - b.ref);
|
|
54
92
|
}
|
|
55
93
|
|
|
56
94
|
/**
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verlauf und Ablehnung vom graphcode-Host (CR-GVE-403).
|
|
3
|
+
*
|
|
4
|
+
* Beide Zahlenquellen gehören dem Host: `graph_readiness({verlauf})` misst die jüngsten
|
|
5
|
+
* Stände, `audit_stats` zählt Anwendung und Ablehnung am Gate. gve reicht durch und
|
|
6
|
+
* filtert für die Anzeige — es rechnet nichts nach. Ohne Host: `available: false`, keine
|
|
7
|
+
* Ersatzrechnung. Derselbe `host.sock`-Weg wie /api/suggest und /api/mutate.
|
|
8
|
+
*
|
|
9
|
+
* @author andreas@siglochconsulting
|
|
10
|
+
*/
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import { callHost, HOST_SOCK_BASENAME } from '@sigloch/graphcode-client';
|
|
13
|
+
|
|
14
|
+
/** Zahl der jüngsten Stände, die die Karte „Wirkt die Arbeit?" zeigt. */
|
|
15
|
+
export const VERLAUF_WINDOW = 24;
|
|
16
|
+
|
|
17
|
+
const sockOf = (repoRoot) => join(repoRoot, '.graphcode', HOST_SOCK_BASENAME);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Der Verlauf der jüngsten Stände. Eine Antwort ohne `verlauf.states` (Host vor
|
|
21
|
+
* graphcode CR-GC-946) ist nicht verwertbar und zählt wie „kein Host".
|
|
22
|
+
*/
|
|
23
|
+
export async function fetchVerlauf(repoRoot, callHostImpl = callHost) {
|
|
24
|
+
try {
|
|
25
|
+
const report = await callHostImpl(sockOf(repoRoot), 'graph_readiness', { verlauf: VERLAUF_WINDOW });
|
|
26
|
+
if (!Array.isArray(report?.verlauf?.states)) {
|
|
27
|
+
return { available: false, reason: 'graph_readiness lieferte keinen Verlauf (verlauf.states)' };
|
|
28
|
+
}
|
|
29
|
+
return { available: true, verlauf: report.verlauf };
|
|
30
|
+
} catch (err) {
|
|
31
|
+
return { available: false, reason: err.message };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Die Ablehnung am Gate aus `audit_stats`: Gesamtzahl, die blockenden Regeln
|
|
37
|
+
* (`blocked` > 0, Reihenfolge des Hosts) und je Skill angewandt/abgelehnt.
|
|
38
|
+
* `skill: null` bleibt null — die Anzeige sagt „nicht erfasst".
|
|
39
|
+
*/
|
|
40
|
+
export function ablehnungPayload(stats) {
|
|
41
|
+
if (!stats?.totals || !Array.isArray(stats.byRule) || !Array.isArray(stats.bySkill)) return null;
|
|
42
|
+
return {
|
|
43
|
+
available: true,
|
|
44
|
+
window: { since: stats.window?.since ?? null, until: stats.window?.until ?? null },
|
|
45
|
+
totals: { applied: stats.totals.applied, rejected: stats.totals.rejected },
|
|
46
|
+
rules: stats.byRule
|
|
47
|
+
.filter((r) => r.blocked > 0)
|
|
48
|
+
.map((r) => ({ ruleId: r.ruleId, blocked: r.blocked, firedIn: r.firedIn ?? null })),
|
|
49
|
+
skills: stats.bySkill.map((s) => ({
|
|
50
|
+
skill: s.skill ?? null,
|
|
51
|
+
applied: s.applied,
|
|
52
|
+
rejected: s.rejected,
|
|
53
|
+
topBlockingRule: s.topBlockingRule ?? null,
|
|
54
|
+
})),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function fetchAblehnung(repoRoot, callHostImpl = callHost) {
|
|
59
|
+
try {
|
|
60
|
+
const payload = ablehnungPayload(await callHostImpl(sockOf(repoRoot), 'audit_stats', {}));
|
|
61
|
+
return payload ?? { available: false, reason: 'audit_stats lieferte keine verwertbare Antwort (totals, byRule, bySkill)' };
|
|
62
|
+
} catch (err) {
|
|
63
|
+
return { available: false, reason: err.message };
|
|
64
|
+
}
|
|
65
|
+
}
|
package/vite.config.js
CHANGED
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
HOST_SOCK_BASENAME,
|
|
39
39
|
} from '@sigloch/graphcode-client';
|
|
40
40
|
import { loadConfig } from './src/config.mjs';
|
|
41
|
-
import { codeOf, openInEditor } from './src/code-lookup.mjs';
|
|
41
|
+
import { codeOf, openInEditor, testsOfSchema } from './src/code-lookup.mjs';
|
|
42
42
|
import { fetchVerlauf, fetchAblehnung } from './src/host-verlauf.mjs';
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -1232,12 +1232,13 @@ function mutateApiPlugin() {
|
|
|
1232
1232
|
}
|
|
1233
1233
|
|
|
1234
1234
|
/**
|
|
1235
|
-
* GET /api/code?
|
|
1236
|
-
*
|
|
1235
|
+
* GET /api/code?id=<id>&ref=<n> und POST /api/open-code { id, ref } — der Code eines Knotens für die Detailspalte und
|
|
1236
|
+
* der Start des Editors: FUNC (CR-GVE-390), SCHEMA und TEST (CR-GVE-407). Eine SCHEMA bringt ihre Tests als `tests`
|
|
1237
|
+
* mit. Beide lesen `realRef`/`testRefs` aus dem Graphen auf der Platte; siehe src/code-lookup.mjs.
|
|
1237
1238
|
*/
|
|
1238
1239
|
function codeApiPlugin() {
|
|
1239
1240
|
const repoRoot = resolveRepoRoot();
|
|
1240
|
-
const
|
|
1241
|
+
const readGraph = () => JSON.parse(readFileSync(join(repoRoot, servedGraphPath(repoRoot)), 'utf8'));
|
|
1241
1242
|
const send = (res, status, body) => {
|
|
1242
1243
|
res.statusCode = status;
|
|
1243
1244
|
res.setHeader('Content-Type', 'application/json');
|
|
@@ -1247,24 +1248,27 @@ function codeApiPlugin() {
|
|
|
1247
1248
|
const middleware = (req, res, next) => {
|
|
1248
1249
|
const url = new URL(req.url ?? '/', 'http://localhost');
|
|
1249
1250
|
if (url.pathname === '/api/code') {
|
|
1250
|
-
const
|
|
1251
|
-
|
|
1251
|
+
const graph = readGraph();
|
|
1252
|
+
const id = url.searchParams.get('id');
|
|
1253
|
+
const code = codeOf(graph, id, repoRoot, Number(url.searchParams.get('ref') ?? 0));
|
|
1254
|
+
const tests = testsOfSchema(graph, id);
|
|
1255
|
+
send(res, code.status === 'unknown' ? 404 : 200, tests.length ? { ...code, tests } : code);
|
|
1252
1256
|
return;
|
|
1253
1257
|
}
|
|
1254
1258
|
if (url.pathname !== '/api/open-code' || req.method !== 'POST') return next();
|
|
1255
1259
|
let raw = '';
|
|
1256
1260
|
req.on('data', (chunk) => { raw += chunk; });
|
|
1257
1261
|
req.on('end', async () => {
|
|
1258
|
-
let
|
|
1262
|
+
let id, ref;
|
|
1259
1263
|
try {
|
|
1260
|
-
({
|
|
1264
|
+
({ id, ref = 0 } = JSON.parse(raw));
|
|
1261
1265
|
} catch {
|
|
1262
1266
|
send(res, 400, { success: false, error: 'invalid JSON body' });
|
|
1263
1267
|
return;
|
|
1264
1268
|
}
|
|
1265
|
-
const code =
|
|
1269
|
+
const code = codeOf(readGraph(), id, repoRoot, ref);
|
|
1266
1270
|
if (code.status !== 'ok') {
|
|
1267
|
-
send(res, 404, { success: false, error: `kein Code zu ${
|
|
1271
|
+
send(res, 404, { success: false, error: `kein Code zu ${id}: ${code.status}` });
|
|
1268
1272
|
return;
|
|
1269
1273
|
}
|
|
1270
1274
|
send(res, 200, await openInEditor(code, APP_CONFIG.editor.command));
|