feat(FN-5129): complete Step 1 — add lineage child guard primitives
Fusion-Task-Id: FN-5129 Fusion-Task-Lineage: 77519a37-0552-4e8b-8061-ce84012de978
This commit is contained in:
committed by
gsxdsm
parent
b6623c6001
commit
911125f1c9
@@ -596,6 +596,21 @@ export class TaskHasDependentsError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
export class TaskHasLineageChildrenError extends Error {
|
||||
readonly taskId: string;
|
||||
readonly childIds: string[];
|
||||
|
||||
constructor(taskId: string, childIds: string[]) {
|
||||
super(
|
||||
`Cannot delete task ${taskId}: still referenced as a lineage parent by ${childIds.join(", ")}. ` +
|
||||
`Pass { removeLineageReferences: true } to clear these references before deleting.`,
|
||||
);
|
||||
this.name = "TaskHasLineageChildrenError";
|
||||
this.taskId = taskId;
|
||||
this.childIds = childIds;
|
||||
}
|
||||
}
|
||||
|
||||
export class InvalidFileScopeError extends Error {
|
||||
readonly taskId: string;
|
||||
readonly invalidEntries: string[];
|
||||
@@ -2028,6 +2043,16 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
|
||||
return dependents;
|
||||
}
|
||||
|
||||
private findLiveLineageChildren(id: string): string[] {
|
||||
const rows = this.db
|
||||
.prepare(
|
||||
`SELECT id FROM tasks WHERE sourceParentTaskId = ? AND id != ? AND "column" != 'archived' AND ${TaskStore.ACTIVE_TASKS_WHERE}`,
|
||||
)
|
||||
.all(id, id) as Array<{ id: string }>;
|
||||
|
||||
return rows.map((row) => row.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up event listeners for activity logging.
|
||||
* Call after init() to record task lifecycle events.
|
||||
|
||||
Reference in New Issue
Block a user