mindpm 1.2.21 → 1.2.22
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/index.js +20 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1022,6 +1022,25 @@ var getTaskHistory = async (_req, res, params) => {
|
|
|
1022
1022
|
).all(params.id);
|
|
1023
1023
|
sendJson(res, 200, rows);
|
|
1024
1024
|
};
|
|
1025
|
+
var createSession = async (req, res, params) => {
|
|
1026
|
+
const db2 = getDb();
|
|
1027
|
+
const body = await parseBody(req);
|
|
1028
|
+
if (!body.summary || typeof body.summary !== "string") {
|
|
1029
|
+
sendJson(res, 400, { error: "summary is required" });
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
const project = db2.prepare("SELECT id FROM projects WHERE id = ?").get(params.pid);
|
|
1033
|
+
if (!project) {
|
|
1034
|
+
sendJson(res, 404, { error: "Project not found" });
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
const id = generateId();
|
|
1038
|
+
db2.prepare(
|
|
1039
|
+
"INSERT INTO sessions (id, project_id, summary, next_steps) VALUES (?, ?, ?, ?)"
|
|
1040
|
+
).run(id, params.pid, body.summary, body.next_steps ?? null);
|
|
1041
|
+
const session = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(id);
|
|
1042
|
+
sendJson(res, 201, session);
|
|
1043
|
+
};
|
|
1025
1044
|
var listDecisions = async (_req, res, params) => {
|
|
1026
1045
|
const db2 = getDb();
|
|
1027
1046
|
const rows = db2.prepare("SELECT * FROM decisions WHERE project_id = ? ORDER BY created_at DESC").all(params.pid);
|
|
@@ -1031,6 +1050,7 @@ var routes = [
|
|
|
1031
1050
|
{ method: "GET", pattern: "/api/projects", handler: listProjects },
|
|
1032
1051
|
{ method: "GET", pattern: "/api/projects/:id", handler: getProject },
|
|
1033
1052
|
{ method: "PATCH", pattern: "/api/projects/:id", handler: updateProject },
|
|
1053
|
+
{ method: "POST", pattern: "/api/projects/:pid/sessions", handler: createSession },
|
|
1034
1054
|
{ method: "GET", pattern: "/api/projects/:pid/decisions", handler: listDecisions },
|
|
1035
1055
|
{ method: "GET", pattern: "/api/projects/:pid/tasks", handler: listTasks },
|
|
1036
1056
|
{ method: "POST", pattern: "/api/projects/:pid/tasks", handler: createTask },
|