@medicine-wheel/app 0.15.4 → 0.15.6
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/api/ceremonies/[id]/route.ts +36 -0
- package/app/api/ceremonies/route.ts +20 -1
- package/package.json +25 -25
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NextResponse } from "next/server";
|
|
2
2
|
import { createProvider, detectProvider } from "@medicine-wheel/storage-provider";
|
|
3
|
+
import { getAllBeats } from "@/lib/store";
|
|
3
4
|
|
|
4
5
|
type RouteContext = { params: Promise<{ id: string }> };
|
|
5
6
|
|
|
@@ -22,3 +23,38 @@ export async function GET(_request: Request, context: RouteContext) {
|
|
|
22
23
|
return NextResponse.json({ error: message }, { status: 500 });
|
|
23
24
|
}
|
|
24
25
|
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Remove one ceremony record (0.15.6, #146). A ceremony someone took part in is
|
|
29
|
+
* never removed: the wheel refuses (409) while a closing, a turn (a beat that
|
|
30
|
+
* names it) or a diary entry holds it, the way a node is refused while
|
|
31
|
+
* relations hold it. What remains removable is a record nobody entered, such
|
|
32
|
+
* as one a test run wrote to the wrong wheel.
|
|
33
|
+
*/
|
|
34
|
+
export async function DELETE(_request: Request, context: RouteContext) {
|
|
35
|
+
try {
|
|
36
|
+
const { id } = await context.params;
|
|
37
|
+
const store = await createProvider();
|
|
38
|
+
const ceremony = await store.getCeremony(id);
|
|
39
|
+
if (!ceremony) {
|
|
40
|
+
return NextResponse.json({ error: `Ceremony not found: ${id}` }, { status: 404 });
|
|
41
|
+
}
|
|
42
|
+
const closings = (await store.getAllCeremonies(Number.MAX_SAFE_INTEGER)).filter((c) => c.closes === id).length;
|
|
43
|
+
const turns = getAllBeats().filter((b) => Array.isArray(b.ceremonies) && b.ceremonies.includes(id)).length;
|
|
44
|
+
const diary = (await store.listDiaryEntries()).filter((e) => e.metadata?.ceremony_id === id).length;
|
|
45
|
+
if (closings + turns + diary > 0) {
|
|
46
|
+
return NextResponse.json(
|
|
47
|
+
{
|
|
48
|
+
error: `Ceremony ${id} is held by ${closings} closing(s), ${turns} turn(s) and ${diary} diary entr${diary === 1 ? "y" : "ies"} — nothing was removed.`,
|
|
49
|
+
holders: { closings, turns, diary },
|
|
50
|
+
},
|
|
51
|
+
{ status: 409 },
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
await store.deleteCeremony(id);
|
|
55
|
+
return NextResponse.json({ success: true, deleted: { id }, provider: detectProvider() });
|
|
56
|
+
} catch (error: unknown) {
|
|
57
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
58
|
+
return NextResponse.json({ error: message }, { status: 500 });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -16,6 +16,7 @@ export async function GET(request: Request) {
|
|
|
16
16
|
const episodePath = searchParams.get("episode_path");
|
|
17
17
|
const circleId = searchParams.get("circle_id");
|
|
18
18
|
const closes = searchParams.get("closes");
|
|
19
|
+
const subjectId = searchParams.get("subject_id");
|
|
19
20
|
|
|
20
21
|
const limit = parseLimit(searchParams.get("limit"));
|
|
21
22
|
if (limit instanceof NextResponse) return limit;
|
|
@@ -57,6 +58,11 @@ export async function GET(request: Request) {
|
|
|
57
58
|
ceremonies = ceremonies.filter((c) => c.closes === closes);
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
// `?subject_id=<node id>` answers "which ceremonies gathered around this node" (#146).
|
|
62
|
+
if (subjectId) {
|
|
63
|
+
ceremonies = ceremonies.filter((c) => c.subject_id === subjectId);
|
|
64
|
+
}
|
|
65
|
+
|
|
60
66
|
const matched = ceremonies.length;
|
|
61
67
|
if (limit !== null && ceremonies.length > limit) {
|
|
62
68
|
ceremonies = ceremonies.slice(0, limit);
|
|
@@ -69,7 +75,7 @@ export async function GET(request: Request) {
|
|
|
69
75
|
// `total` is the whole store, `matched` what the filters selected. When
|
|
70
76
|
// count < matched the caller holds a page and can now see that it does.
|
|
71
77
|
total,
|
|
72
|
-
...(direction || type || episodePath || circleId || closes ? { matched } : {}),
|
|
78
|
+
...(direction || type || episodePath || circleId || closes || subjectId ? { matched } : {}),
|
|
73
79
|
truncated: ceremonies.length < matched,
|
|
74
80
|
});
|
|
75
81
|
} catch (error: unknown) {
|
|
@@ -123,6 +129,18 @@ export async function POST(request: Request) {
|
|
|
123
129
|
}
|
|
124
130
|
}
|
|
125
131
|
|
|
132
|
+
if (body.subject_id !== undefined) {
|
|
133
|
+
if (typeof body.subject_id !== "string" || !body.subject_id) {
|
|
134
|
+
return NextResponse.json({ error: "subject_id must be a node id" }, { status: 400 });
|
|
135
|
+
}
|
|
136
|
+
if (!(await store.getNode(body.subject_id))) {
|
|
137
|
+
return NextResponse.json(
|
|
138
|
+
{ error: `Cannot hold a ceremony about a node that does not exist: ${body.subject_id}`, hint: "Create the node first on /nodes." },
|
|
139
|
+
{ status: 404 },
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
126
144
|
const ceremony = {
|
|
127
145
|
id: body.id || crypto.randomUUID(),
|
|
128
146
|
type: body.type,
|
|
@@ -138,6 +156,7 @@ export async function POST(request: Request) {
|
|
|
138
156
|
...(typeof body.source === "string" && body.source ? { source: body.source } : {}),
|
|
139
157
|
...(typeof body.closes === "string" ? { closes: body.closes } : {}),
|
|
140
158
|
...(typeof body.circle_id === "string" ? { circle_id: body.circle_id } : {}),
|
|
159
|
+
...(typeof body.subject_id === "string" ? { subject_id: body.subject_id } : {}),
|
|
141
160
|
};
|
|
142
161
|
|
|
143
162
|
await store.logCeremony(ceremony);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medicine-wheel/app",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.6",
|
|
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",
|
|
@@ -89,30 +89,30 @@
|
|
|
89
89
|
"release:major": "npm run version:major && npm run publish:all && npm run release:commit"
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"@medicine-wheel/ceremonial-diary": "^0.15.
|
|
93
|
-
"@medicine-wheel/ceremony-protocol": "^0.15.
|
|
94
|
-
"@medicine-wheel/community-review": "^0.15.
|
|
95
|
-
"@medicine-wheel/consent-lifecycle": "^0.15.
|
|
96
|
-
"@medicine-wheel/creative-orientation": "^0.15.
|
|
97
|
-
"@medicine-wheel/data-store": "^0.15.
|
|
98
|
-
"@medicine-wheel/data-store-postgres": "^0.15.
|
|
99
|
-
"@medicine-wheel/fire-keeper": "^0.15.
|
|
100
|
-
"@medicine-wheel/github-ceremony": "^0.15.
|
|
101
|
-
"@medicine-wheel/graph-viz": "^0.15.
|
|
102
|
-
"@medicine-wheel/honcho": "^0.15.
|
|
103
|
-
"@medicine-wheel/importance-unit": "^0.15.
|
|
104
|
-
"@medicine-wheel/mcp": "^4.15.
|
|
105
|
-
"@medicine-wheel/narrative-cluster": "^0.15.
|
|
106
|
-
"@medicine-wheel/narrative-engine": "^0.15.
|
|
107
|
-
"@medicine-wheel/ontology-core": "^0.15.
|
|
108
|
-
"@medicine-wheel/perception-layer": "^0.15.
|
|
109
|
-
"@medicine-wheel/prompt-decomposition": "^0.15.
|
|
110
|
-
"@medicine-wheel/relational-index": "^0.15.
|
|
111
|
-
"@medicine-wheel/relational-query": "^0.15.
|
|
112
|
-
"@medicine-wheel/session-reader": "^0.15.
|
|
113
|
-
"@medicine-wheel/storage-provider": "^0.15.
|
|
114
|
-
"@medicine-wheel/transformation-tracker": "^0.15.
|
|
115
|
-
"@medicine-wheel/ui-components": "^0.15.
|
|
92
|
+
"@medicine-wheel/ceremonial-diary": "^0.15.6",
|
|
93
|
+
"@medicine-wheel/ceremony-protocol": "^0.15.6",
|
|
94
|
+
"@medicine-wheel/community-review": "^0.15.6",
|
|
95
|
+
"@medicine-wheel/consent-lifecycle": "^0.15.6",
|
|
96
|
+
"@medicine-wheel/creative-orientation": "^0.15.6",
|
|
97
|
+
"@medicine-wheel/data-store": "^0.15.6",
|
|
98
|
+
"@medicine-wheel/data-store-postgres": "^0.15.6",
|
|
99
|
+
"@medicine-wheel/fire-keeper": "^0.15.6",
|
|
100
|
+
"@medicine-wheel/github-ceremony": "^0.15.6",
|
|
101
|
+
"@medicine-wheel/graph-viz": "^0.15.6",
|
|
102
|
+
"@medicine-wheel/honcho": "^0.15.6",
|
|
103
|
+
"@medicine-wheel/importance-unit": "^0.15.6",
|
|
104
|
+
"@medicine-wheel/mcp": "^4.15.6",
|
|
105
|
+
"@medicine-wheel/narrative-cluster": "^0.15.6",
|
|
106
|
+
"@medicine-wheel/narrative-engine": "^0.15.6",
|
|
107
|
+
"@medicine-wheel/ontology-core": "^0.15.6",
|
|
108
|
+
"@medicine-wheel/perception-layer": "^0.15.6",
|
|
109
|
+
"@medicine-wheel/prompt-decomposition": "^0.15.6",
|
|
110
|
+
"@medicine-wheel/relational-index": "^0.15.6",
|
|
111
|
+
"@medicine-wheel/relational-query": "^0.15.6",
|
|
112
|
+
"@medicine-wheel/session-reader": "^0.15.6",
|
|
113
|
+
"@medicine-wheel/storage-provider": "^0.15.6",
|
|
114
|
+
"@medicine-wheel/transformation-tracker": "^0.15.6",
|
|
115
|
+
"@medicine-wheel/ui-components": "^0.15.6",
|
|
116
116
|
"@neondatabase/serverless": "^0.10.0",
|
|
117
117
|
"@xyflow/react": "^12.3.0",
|
|
118
118
|
"clsx": "^2.1.1",
|