@medicine-wheel/app 0.27.18 β 0.27.19
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/app/nodes/page.tsx +57 -13
- package/package.json +30 -30
package/app/nodes/page.tsx
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useEffect, useState, useCallback } from "react";
|
|
3
|
+
import { Suspense, useEffect, useState, useCallback } from "react";
|
|
4
4
|
import type { SubmitEvent } from "react";
|
|
5
5
|
import Link from "next/link";
|
|
6
|
+
import { useSearchParams } from "next/navigation";
|
|
7
|
+
import { ArrowDownToLine, ArrowUpRight } from "lucide-react";
|
|
6
8
|
import {
|
|
7
9
|
type RelationalNode,
|
|
8
10
|
type RelationalEdge,
|
|
@@ -20,10 +22,20 @@ const DIRECTIONS: DirectionName[] = ["east", "south", "west", "north"];
|
|
|
20
22
|
const NODE_TYPE_ICONS: Record<NodeType, string> = { human: "π€", land: "π", spirit: "β¨", ancestor: "πͺΆ", future: "π±", knowledge: "π", circle: "β", agent: "π€" };
|
|
21
23
|
const DIRECTION_ICONS: Record<DirectionName, string> = { east: "π
", south: "π", west: "π", north: "βοΈ" };
|
|
22
24
|
|
|
25
|
+
const PINNED_DESIGN_SOURCE = /^https:\/\/github\.com\/[A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*\/blob\/[0-9a-f]{40}(?:[0-9a-f]{24})?\/(?:[\w~-][\w.~-]*\/)*[\w~-][\w.~-]*$/;
|
|
26
|
+
|
|
23
27
|
function describeNode(node: NodeRecord): string {
|
|
24
28
|
return node.description || (typeof node.metadata?.description === "string" ? node.metadata.description : "");
|
|
25
29
|
}
|
|
26
30
|
|
|
31
|
+
function designSource(node: NodeRecord) {
|
|
32
|
+
const { kind, source_url: url } = node.metadata ?? {};
|
|
33
|
+
if (node.type !== "knowledge" || (kind !== "system" && kind !== "diagram")) return;
|
|
34
|
+
if (typeof url === "string" && url.trim() === url && PINNED_DESIGN_SOURCE.test(url)) {
|
|
35
|
+
return { url, label: kind === "diagram" ? "drawing" : kind };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
27
39
|
function DirectionChip({ direction }: { direction?: DirectionName }) {
|
|
28
40
|
if (!direction) return <span className="mw-badge">no direction</span>;
|
|
29
41
|
return (
|
|
@@ -34,6 +46,15 @@ function DirectionChip({ direction }: { direction?: DirectionName }) {
|
|
|
34
46
|
}
|
|
35
47
|
|
|
36
48
|
export default function NodesPage() {
|
|
49
|
+
return (
|
|
50
|
+
<Suspense fallback={<div className="text-center py-12 text-muted-foreground">Loading nodesβ¦</div>}>
|
|
51
|
+
<NodesList />
|
|
52
|
+
</Suspense>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function NodesList() {
|
|
57
|
+
const focusedNodeId = useSearchParams().get("node");
|
|
37
58
|
const [nodes, setNodes] = useState<NodeRecord[]>([]);
|
|
38
59
|
const [edges, setEdges] = useState<RelationalEdge[]>([]);
|
|
39
60
|
const [loading, setLoading] = useState(true);
|
|
@@ -42,7 +63,6 @@ export default function NodesPage() {
|
|
|
42
63
|
const [searchQuery, setSearchQuery] = useState("");
|
|
43
64
|
const [expandedNode, setExpandedNode] = useState<string | null>(null);
|
|
44
65
|
const [showAddNode, setShowAddNode] = useState(false);
|
|
45
|
-
const [focusedNodeId, setFocusedNodeId] = useState<string | null>(null);
|
|
46
66
|
const [editingNode, setEditingNode] = useState<string | null>(null);
|
|
47
67
|
const [deletingNode, setDeletingNode] = useState<NodeRecord | null>(null);
|
|
48
68
|
const [busy, setBusy] = useState(false);
|
|
@@ -77,11 +97,6 @@ export default function NodesPage() {
|
|
|
77
97
|
|
|
78
98
|
useEffect(() => { loadNodes(); }, [loadNodes]);
|
|
79
99
|
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
const params = new URLSearchParams(window.location.search);
|
|
82
|
-
setFocusedNodeId(params.get("node"));
|
|
83
|
-
}, []);
|
|
84
|
-
|
|
85
100
|
useEffect(() => {
|
|
86
101
|
if (loading || !focusedNodeId || !nodes.some((node) => node.id === focusedNodeId)) return;
|
|
87
102
|
|
|
@@ -104,6 +119,12 @@ export default function NodesPage() {
|
|
|
104
119
|
return edges.filter((e) => e.from_id === nodeId || e.to_id === nodeId);
|
|
105
120
|
}
|
|
106
121
|
|
|
122
|
+
function clearFilters() {
|
|
123
|
+
setFilterType("all");
|
|
124
|
+
setFilterDirection("all");
|
|
125
|
+
setSearchQuery("");
|
|
126
|
+
}
|
|
127
|
+
|
|
107
128
|
async function addNode(e: SubmitEvent<HTMLFormElement>) {
|
|
108
129
|
e.preventDefault();
|
|
109
130
|
const form = new FormData(e.currentTarget);
|
|
@@ -140,7 +161,7 @@ export default function NodesPage() {
|
|
|
140
161
|
};
|
|
141
162
|
setBusy(true);
|
|
142
163
|
try {
|
|
143
|
-
const res = await fetch(`/api/nodes/${node.id}`, { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
|
|
164
|
+
const res = await fetch(`/api/nodes/${encodeURIComponent(node.id)}`, { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
|
|
144
165
|
const data = await res.json();
|
|
145
166
|
if (!res.ok) throw new Error(data.issues?.join("; ") || data.error || "Changes were not saved");
|
|
146
167
|
toast.success(`Changes to "${data.node.name}" saved`);
|
|
@@ -156,7 +177,7 @@ export default function NodesPage() {
|
|
|
156
177
|
async function deleteNode(node: NodeRecord) {
|
|
157
178
|
setBusy(true);
|
|
158
179
|
try {
|
|
159
|
-
const res = await fetch(`/api/nodes/${node.id}`, { method: "DELETE" });
|
|
180
|
+
const res = await fetch(`/api/nodes/${encodeURIComponent(node.id)}`, { method: "DELETE" });
|
|
160
181
|
const data = await res.json();
|
|
161
182
|
if (!res.ok) throw new Error(data.error || "Node was not deleted");
|
|
162
183
|
toast.success(`Node "${node.name}" released from the wheel`);
|
|
@@ -237,7 +258,7 @@ export default function NodesPage() {
|
|
|
237
258
|
{DIRECTIONS.map((d) => <option key={d} value={d}>{DIRECTION_ICONS[d]} {d}</option>)}
|
|
238
259
|
</select>
|
|
239
260
|
{(filterType !== "all" || filterDirection !== "all" || searchQuery) && (
|
|
240
|
-
<button onClick={
|
|
261
|
+
<button onClick={clearFilters} className="mw-btn mw-btn--ghost">Clear filters</button>
|
|
241
262
|
)}
|
|
242
263
|
</div>
|
|
243
264
|
|
|
@@ -263,6 +284,7 @@ export default function NodesPage() {
|
|
|
263
284
|
const nodeRelations = relationsOf(node.id);
|
|
264
285
|
const isExpanded = expandedNode === node.id;
|
|
265
286
|
const isEditing = editingNode === node.id;
|
|
287
|
+
const source = isExpanded && !isEditing ? designSource(node) : undefined;
|
|
266
288
|
return (
|
|
267
289
|
<div
|
|
268
290
|
key={node.id}
|
|
@@ -325,6 +347,18 @@ export default function NodesPage() {
|
|
|
325
347
|
) : (
|
|
326
348
|
<>
|
|
327
349
|
{describeNode(node) && <p className="text-sm">{describeNode(node)}</p>}
|
|
350
|
+
{source && (
|
|
351
|
+
<a
|
|
352
|
+
href={source.url}
|
|
353
|
+
target="_blank"
|
|
354
|
+
rel="noreferrer"
|
|
355
|
+
className="mw-btn mw-btn--ghost min-h-9 max-w-full focus-visible:outline focus-visible:outline-2"
|
|
356
|
+
aria-label={`View ${source.label} source on GitHub (opens in a new tab)`}
|
|
357
|
+
>
|
|
358
|
+
View {source.label} source
|
|
359
|
+
<ArrowUpRight aria-hidden size={16} strokeWidth={1.9} className="shrink-0" />
|
|
360
|
+
</a>
|
|
361
|
+
)}
|
|
328
362
|
<div className="grid grid-cols-2 gap-4 text-sm">
|
|
329
363
|
<div><span className="text-muted-foreground">Type:</span> <span className="capitalize">{node.type}</span></div>
|
|
330
364
|
<div><span className="text-muted-foreground">Direction:</span> <DirectionChip direction={node.direction} /></div>
|
|
@@ -341,11 +375,21 @@ export default function NodesPage() {
|
|
|
341
375
|
nodeRelations.map((e) => {
|
|
342
376
|
const otherId = e.from_id === node.id ? e.to_id : e.from_id;
|
|
343
377
|
const other = nodes.find((n) => n.id === otherId);
|
|
378
|
+
const designLink = e.kinship_type === "drawn-by" || e.kinship_type === "member-of";
|
|
344
379
|
return (
|
|
345
380
|
<div key={[e.from_id, e.to_id, ...(e.kinship_type ? [e.kinship_type] : [])].join(":")} className="py-1 text-sm border-b border-border/50 flex items-center gap-2">
|
|
346
381
|
<span className="text-muted-foreground">{e.relationship_type}</span>
|
|
347
382
|
<span aria-hidden>{e.from_id === node.id ? "β" : "β"}</span>
|
|
348
|
-
{
|
|
383
|
+
{designLink ? (
|
|
384
|
+
<Link
|
|
385
|
+
href={`/nodes?node=${encodeURIComponent(otherId)}`}
|
|
386
|
+
onNavigate={clearFilters}
|
|
387
|
+
className="inline-flex min-h-9 min-w-0 items-center gap-1 underline underline-offset-2 focus-visible:outline focus-visible:outline-2"
|
|
388
|
+
>
|
|
389
|
+
<span className="break-words min-w-0">{other?.name ?? "Open related node"}</span>
|
|
390
|
+
<ArrowDownToLine aria-hidden size={16} strokeWidth={1.9} className="shrink-0" />
|
|
391
|
+
</Link>
|
|
392
|
+
) : other?.name || "?"}
|
|
349
393
|
<span className="text-xs text-muted-foreground">({Math.round(e.strength * 100)}%)</span>
|
|
350
394
|
{e.ceremony_honored && <span style={{ color: "var(--mw-ceremony)" }} title="Ceremony honored">β¦</span>}
|
|
351
395
|
</div>
|
|
@@ -355,7 +399,7 @@ export default function NodesPage() {
|
|
|
355
399
|
</div>
|
|
356
400
|
<div className="flex gap-2 pt-1">
|
|
357
401
|
<button onClick={() => setEditingNode(node.id)} className="mw-btn mw-btn--secondary">Edit node</button>
|
|
358
|
-
<Link href={`/graph?node=${node.id}`} className="mw-btn mw-btn--ghost">See on the wheel</Link>
|
|
402
|
+
<Link href={`/graph?node=${encodeURIComponent(node.id)}`} className="mw-btn mw-btn--ghost">See on the wheel</Link>
|
|
359
403
|
<button onClick={() => setDeletingNode(node)} className="mw-btn mw-btn--danger">Delete node</button>
|
|
360
404
|
</div>
|
|
361
405
|
</>
|
|
@@ -380,7 +424,7 @@ export default function NodesPage() {
|
|
|
380
424
|
</p>
|
|
381
425
|
<div className="flex gap-2 justify-end">
|
|
382
426
|
<button onClick={() => setDeletingNode(null)} className="mw-btn mw-btn--ghost">Keep the node</button>
|
|
383
|
-
<Link href={`/relations?node=${deletingNode.id}`} className="mw-btn mw-btn--primary">Review its relations</Link>
|
|
427
|
+
<Link href={`/relations?node=${encodeURIComponent(deletingNode.id)}`} className="mw-btn mw-btn--primary">Review its relations</Link>
|
|
384
428
|
</div>
|
|
385
429
|
</>
|
|
386
430
|
) : (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medicine-wheel/app",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.19",
|
|
4
4
|
"description": "Medicine Wheel β Interactive visual layer for Indigenous relational research with Four Directions, ceremonies, and narrative arcs",
|
|
5
5
|
"bin": {
|
|
6
6
|
"mw": "dist/cli/mw.js",
|
|
@@ -96,35 +96,35 @@
|
|
|
96
96
|
"release:major": "npm run version:major && npm run publish:all && npm run release:commit"
|
|
97
97
|
},
|
|
98
98
|
"dependencies": {
|
|
99
|
-
"@medicine-wheel/ceremonial-diary": "^0.27.
|
|
100
|
-
"@medicine-wheel/ceremony-protocol": "^0.27.
|
|
101
|
-
"@medicine-wheel/community-identity": "^0.27.
|
|
102
|
-
"@medicine-wheel/community-review": "^0.27.
|
|
103
|
-
"@medicine-wheel/consent-lifecycle": "^0.27.
|
|
104
|
-
"@medicine-wheel/creative-orientation": "^0.27.
|
|
105
|
-
"@medicine-wheel/data-store": "^0.27.
|
|
106
|
-
"@medicine-wheel/data-store-postgres": "^0.27.
|
|
107
|
-
"@medicine-wheel/episode-ui": "^0.27.
|
|
108
|
-
"@medicine-wheel/episode-vessel": "^0.27.
|
|
109
|
-
"@medicine-wheel/events": "^0.27.
|
|
110
|
-
"@medicine-wheel/fire-keeper": "^0.27.
|
|
111
|
-
"@medicine-wheel/github-ceremony": "^0.27.
|
|
112
|
-
"@medicine-wheel/graph-viz": "^0.27.
|
|
113
|
-
"@medicine-wheel/honcho": "^0.27.
|
|
114
|
-
"@medicine-wheel/importance-unit": "^0.27.
|
|
115
|
-
"@medicine-wheel/mcp": "^4.27.
|
|
116
|
-
"@medicine-wheel/memory": "^0.27.
|
|
117
|
-
"@medicine-wheel/narrative-cluster": "^0.27.
|
|
118
|
-
"@medicine-wheel/narrative-engine": "^0.27.
|
|
119
|
-
"@medicine-wheel/ontology-core": "^0.27.
|
|
120
|
-
"@medicine-wheel/perception-layer": "^0.27.
|
|
121
|
-
"@medicine-wheel/prompt-decomposition": "^0.27.
|
|
122
|
-
"@medicine-wheel/relational-index": "^0.27.
|
|
123
|
-
"@medicine-wheel/relational-query": "^0.27.
|
|
124
|
-
"@medicine-wheel/session-reader": "^0.27.
|
|
125
|
-
"@medicine-wheel/storage-provider": "^0.27.
|
|
126
|
-
"@medicine-wheel/transformation-tracker": "^0.27.
|
|
127
|
-
"@medicine-wheel/ui-components": "^0.27.
|
|
99
|
+
"@medicine-wheel/ceremonial-diary": "^0.27.19",
|
|
100
|
+
"@medicine-wheel/ceremony-protocol": "^0.27.19",
|
|
101
|
+
"@medicine-wheel/community-identity": "^0.27.19",
|
|
102
|
+
"@medicine-wheel/community-review": "^0.27.19",
|
|
103
|
+
"@medicine-wheel/consent-lifecycle": "^0.27.19",
|
|
104
|
+
"@medicine-wheel/creative-orientation": "^0.27.19",
|
|
105
|
+
"@medicine-wheel/data-store": "^0.27.19",
|
|
106
|
+
"@medicine-wheel/data-store-postgres": "^0.27.19",
|
|
107
|
+
"@medicine-wheel/episode-ui": "^0.27.19",
|
|
108
|
+
"@medicine-wheel/episode-vessel": "^0.27.19",
|
|
109
|
+
"@medicine-wheel/events": "^0.27.19",
|
|
110
|
+
"@medicine-wheel/fire-keeper": "^0.27.19",
|
|
111
|
+
"@medicine-wheel/github-ceremony": "^0.27.19",
|
|
112
|
+
"@medicine-wheel/graph-viz": "^0.27.19",
|
|
113
|
+
"@medicine-wheel/honcho": "^0.27.19",
|
|
114
|
+
"@medicine-wheel/importance-unit": "^0.27.19",
|
|
115
|
+
"@medicine-wheel/mcp": "^4.27.19",
|
|
116
|
+
"@medicine-wheel/memory": "^0.27.19",
|
|
117
|
+
"@medicine-wheel/narrative-cluster": "^0.27.19",
|
|
118
|
+
"@medicine-wheel/narrative-engine": "^0.27.19",
|
|
119
|
+
"@medicine-wheel/ontology-core": "^0.27.19",
|
|
120
|
+
"@medicine-wheel/perception-layer": "^0.27.19",
|
|
121
|
+
"@medicine-wheel/prompt-decomposition": "^0.27.19",
|
|
122
|
+
"@medicine-wheel/relational-index": "^0.27.19",
|
|
123
|
+
"@medicine-wheel/relational-query": "^0.27.19",
|
|
124
|
+
"@medicine-wheel/session-reader": "^0.27.19",
|
|
125
|
+
"@medicine-wheel/storage-provider": "^0.27.19",
|
|
126
|
+
"@medicine-wheel/transformation-tracker": "^0.27.19",
|
|
127
|
+
"@medicine-wheel/ui-components": "^0.27.19",
|
|
128
128
|
"@neondatabase/serverless": "^0.10.0",
|
|
129
129
|
"@xyflow/react": "^12.3.0",
|
|
130
130
|
"clsx": "^2.1.1",
|