@allpepper/task-orchestrator 1.1.0 → 1.1.2
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 +1 -1
- package/src/repos/projects.ts +15 -10
- package/src/repos/tasks.ts +14 -2
- package/src/tools/manage-container.ts +0 -1
package/package.json
CHANGED
package/src/repos/projects.ts
CHANGED
|
@@ -253,12 +253,19 @@ export function deleteProject(id: string, options?: { cascade?: boolean }): Resu
|
|
|
253
253
|
|
|
254
254
|
const result = transaction(() => {
|
|
255
255
|
if (cascade) {
|
|
256
|
-
// Get all
|
|
257
|
-
const
|
|
258
|
-
'SELECT id FROM
|
|
256
|
+
// Get all feature IDs for this project first (needed for task cleanup)
|
|
257
|
+
const featureIds = queryAll<{ id: string }>(
|
|
258
|
+
'SELECT id FROM features WHERE project_id = ?',
|
|
259
259
|
[id]
|
|
260
260
|
);
|
|
261
261
|
|
|
262
|
+
// Get all task IDs: tasks directly under project OR under features of this project
|
|
263
|
+
const taskIds = queryAll<{ id: string }>(
|
|
264
|
+
`SELECT id FROM tasks WHERE project_id = ?
|
|
265
|
+
OR feature_id IN (SELECT id FROM features WHERE project_id = ?)`,
|
|
266
|
+
[id, id]
|
|
267
|
+
);
|
|
268
|
+
|
|
262
269
|
// Delete each task's dependencies, sections, and tags
|
|
263
270
|
for (const task of taskIds) {
|
|
264
271
|
execute('DELETE FROM dependencies WHERE from_task_id = ? OR to_task_id = ?', [task.id, task.id]);
|
|
@@ -266,13 +273,11 @@ export function deleteProject(id: string, options?: { cascade?: boolean }): Resu
|
|
|
266
273
|
deleteTags(task.id, EntityType.TASK);
|
|
267
274
|
}
|
|
268
275
|
|
|
269
|
-
// Delete all tasks
|
|
270
|
-
execute(
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
'SELECT id FROM features WHERE project_id = ?',
|
|
275
|
-
[id]
|
|
276
|
+
// Delete all tasks: directly under project OR under features of this project
|
|
277
|
+
execute(
|
|
278
|
+
`DELETE FROM tasks WHERE project_id = ?
|
|
279
|
+
OR feature_id IN (SELECT id FROM features WHERE project_id = ?)`,
|
|
280
|
+
[id, id]
|
|
276
281
|
);
|
|
277
282
|
|
|
278
283
|
// Delete each feature's sections and tags
|
package/src/repos/tasks.ts
CHANGED
|
@@ -73,7 +73,6 @@ function validateComplexity(complexity: number): boolean {
|
|
|
73
73
|
// ============================================================================
|
|
74
74
|
|
|
75
75
|
export function createTask(params: {
|
|
76
|
-
projectId?: string;
|
|
77
76
|
featureId?: string;
|
|
78
77
|
title: string;
|
|
79
78
|
summary: string;
|
|
@@ -97,6 +96,19 @@ export function createTask(params: {
|
|
|
97
96
|
return err('Summary is required', 'VALIDATION_ERROR');
|
|
98
97
|
}
|
|
99
98
|
|
|
99
|
+
// Derive projectId from feature - feature is the source of truth for project membership
|
|
100
|
+
let projectId: string | undefined;
|
|
101
|
+
if (params.featureId) {
|
|
102
|
+
const feature = queryOne<{ project_id: string | null }>(
|
|
103
|
+
'SELECT project_id FROM features WHERE id = ?',
|
|
104
|
+
[params.featureId]
|
|
105
|
+
);
|
|
106
|
+
if (!feature) {
|
|
107
|
+
return err(`Feature not found: ${params.featureId}`, 'NOT_FOUND');
|
|
108
|
+
}
|
|
109
|
+
projectId = feature.project_id ?? undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
100
112
|
const id = generateId();
|
|
101
113
|
const timestamp = now();
|
|
102
114
|
const status = params.status ?? TaskStatus.PENDING;
|
|
@@ -113,7 +125,7 @@ export function createTask(params: {
|
|
|
113
125
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
114
126
|
[
|
|
115
127
|
id,
|
|
116
|
-
|
|
128
|
+
projectId ?? null,
|
|
117
129
|
params.featureId ?? null,
|
|
118
130
|
params.title.trim(),
|
|
119
131
|
params.summary.trim(),
|