dsh-workbench-tasks 0.0.0-stage → 5.2.20
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/LICENSE +21 -0
- package/README.md +26 -2
- package/cordis.patch.yml +7 -0
- package/lib/client.js +11963 -0
- package/lib/db/db-core.js +432 -0
- package/lib/db/db-legacy.js +473 -0
- package/lib/db/db.js +97 -0
- package/lib/db/ownership-path.js +33 -0
- package/lib/db/timeline-schema.js +7 -0
- package/lib/db/workspace-schema.js +15 -0
- package/lib/index.js +232 -0
- package/lib/infra/backup.js +289 -0
- package/lib/infra/config.js +462 -0
- package/lib/infra/data.js +368 -0
- package/lib/infra/sync.js +189 -0
- package/lib/publisher/brief.js +76 -0
- package/lib/publisher/catalog.js +99 -0
- package/lib/publisher/command.js +81 -0
- package/lib/stats/activity-calendar.js +74 -0
- package/lib/stats/difficulty-bins.js +49 -0
- package/lib/stats/events.js +40 -0
- package/lib/stats/overview.js +99 -0
- package/lib/stats/stats-today.js +26 -0
- package/lib/stats/stats.js +589 -0
- package/lib/stats/timeline-stats.js +174 -0
- package/lib/tagging/source.js +89 -0
- package/lib/tagging/tag-options.js +99 -0
- package/lib/tagging/tagging.js +371 -0
- package/lib/task/model/task-difficulty.js +15 -0
- package/lib/task/model/task-model.js +256 -0
- package/lib/task/model/task-ownership-path.js +22 -0
- package/lib/task/model/task-priority.js +33 -0
- package/lib/task/read/task-discovery.js +123 -0
- package/lib/task/read/task-publish-filter.js +31 -0
- package/lib/task/read/task-query.js +351 -0
- package/lib/task/read/task-search-schema.js +34 -0
- package/lib/task/read/task-view.js +146 -0
- package/lib/task/write/task-bulk.js +247 -0
- package/lib/task/write/task-claim.js +229 -0
- package/lib/task/write/task-create-schema.js +34 -0
- package/lib/task/write/task-create.js +178 -0
- package/lib/task/write/task-operations.js +207 -0
- package/lib/task/write/task-target.js +56 -0
- package/lib/task/write/task-transaction.js +18 -0
- package/lib/task/write/task-update.js +104 -0
- package/lib/tasks.js +456 -0
- package/lib/timeline/task-timelines.js +110 -0
- package/lib/timeline/timeline-actions.js +69 -0
- package/lib/timeline/timeline-migration.js +70 -0
- package/lib/timeline/timeline-store.js +57 -0
- package/lib/timeline/timeline-sync.js +46 -0
- package/lib/tree/task-node-write.js +26 -0
- package/lib/tree/tree.js +517 -0
- package/lib/workspace/workspace-actions.js +217 -0
- package/lib/workspace/workspace-store.js +196 -0
- package/package.json +144 -4
- package/shared/tree/limits.cjs +3 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { metaSet } from '../db/db.js';
|
|
3
|
+
import { taskTransaction } from '../task/write/task-transaction.js';
|
|
4
|
+
import { timelineError, timelineChange } from './timeline-store.js';
|
|
5
|
+
// The same pure classifier drives preview and apply. No startup backfill.
|
|
6
|
+
export function classifyTimelineHistory(rows) {
|
|
7
|
+
const groups=new Map(),invalid=[];
|
|
8
|
+
for(const row of rows) {
|
|
9
|
+
const key=row.timeline_key;
|
|
10
|
+
if(key===null || key===undefined || String(key)==='') {invalid.push(row);continue;}
|
|
11
|
+
const id=String(key); if(!groups.has(id)) groups.set(id,[]); groups.get(id).push(row);
|
|
12
|
+
}
|
|
13
|
+
return {invalid,groups:[...groups].map(([key,members])=>({key,members,classification:members.length===1&&String(members[0].id)===key?'ambiguousSelfId':'legacyGrouped',restartOnlyCandidate:members.length>1&&new Set(members.map(r=>r.restart_key)).size===1}))};
|
|
14
|
+
}
|
|
15
|
+
function syncReviewCandidates(db) {
|
|
16
|
+
return db.prepare("SELECT k,v FROM meta WHERE substr(k,1,?)=? ORDER BY k").all('task_timeline_migration:sync-candidate:'.length,'task_timeline_migration:sync-candidate:').map(row=>{
|
|
17
|
+
try {
|
|
18
|
+
const value=JSON.parse(row.v);
|
|
19
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('invalid candidate');
|
|
20
|
+
return {recordKey:row.k,taskId:value.taskId,timelineKey:value.timelineKey,updatedAt:value.updatedAt,reason:value.reason,requiresApproval:true,approved:false};
|
|
21
|
+
} catch { return {recordKey:row.k,reason:'INVALID_SYNC_CANDIDATE',raw:row.v,requiresApproval:true,approved:false}; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function plan(db,args) {
|
|
25
|
+
const rows=db.prepare('SELECT * FROM task ORDER BY id').all();
|
|
26
|
+
const entities=db.prepare('SELECT * FROM task_timeline ORDER BY id').all();
|
|
27
|
+
const links=db.prepare('SELECT * FROM task_timeline_link ORDER BY id').all();
|
|
28
|
+
const snapshotHash=createHash('sha256').update(JSON.stringify({rows,entities,links})).digest('hex');
|
|
29
|
+
if(args.approvedKeys!==undefined && (!Array.isArray(args.approvedKeys)||args.approvedKeys.some(k=>typeof k!=='string'||!k))) throw timelineError('MIGRATION_APPROVAL_INVALID','approvedKeys 必须为非空字符串数组');
|
|
30
|
+
const approved=new Set(args.approvedKeys||[]),classified=classifyTimelineHistory(rows),pendingEntities=[],pendingLinks=[],conflicts=[];
|
|
31
|
+
let existingIdentical=0;
|
|
32
|
+
for(const key of approved) if(!classified.groups.some(g=>g.key===key)) conflicts.push({key,reason:'UNKNOWN_APPROVED_KEY'});
|
|
33
|
+
for(const group of classified.groups) {
|
|
34
|
+
if(!approved.has(group.key)) continue;
|
|
35
|
+
const members=group.members,live=members.filter(r=>r.deleted_at===null).sort((left,right)=>String(left.publish_date).localeCompare(String(right.publish_date))||String(left.id).localeCompare(String(right.id)));
|
|
36
|
+
const created=Math.min(...members.map(r=>r.created_at)),updated=Math.max(...members.map(r=>r.updated_at));
|
|
37
|
+
const entity={id:group.key,title:live[0]?.title||'未命名时间线',description:'',created_at:created,updated_at:updated,deleted_at:live.length?null:updated,rev:1};
|
|
38
|
+
const old=entities.find(e=>e.id===group.key);
|
|
39
|
+
if(old) {
|
|
40
|
+
if(Object.keys(entity).every(k=>old[k]===entity[k])) existingIdentical++;
|
|
41
|
+
else conflicts.push({key:group.key,reason:'ENTITY_ALREADY_CHANGED'});
|
|
42
|
+
} else pendingEntities.push(entity);
|
|
43
|
+
for(const task of members) {
|
|
44
|
+
const link={id:task.id,task_id:task.id,timeline_id:group.key,created_at:task.created_at,updated_at:task.updated_at,deleted_at:task.deleted_at,rev:1};
|
|
45
|
+
const oldLink=links.find(l=>l.task_id===task.id);
|
|
46
|
+
if(oldLink) {
|
|
47
|
+
if(Object.keys(link).every(k=>oldLink[k]===link[k])) existingIdentical++;
|
|
48
|
+
else conflicts.push({key:group.key,taskId:task.id,reason:'MEMBERSHIP_ALREADY_CHANGED'});
|
|
49
|
+
} else pendingLinks.push(link);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const report={dryRun:true,snapshotHash,scanned:rows.length,live:rows.filter(r=>r.deleted_at===null).length,deleted:rows.filter(r=>r.deleted_at!==null).length,distinctKeys:classified.groups.length,ordinaryOrAmbiguousSelf:classified.groups.filter(g=>g.classification==='ambiguousSelfId').length,approvedSelf:classified.groups.filter(g=>g.classification==='ambiguousSelfId'&&approved.has(g.key)).length,legacyGrouped:classified.groups.filter(g=>g.classification==='legacyGrouped').length,restartOnlyCandidates:classified.groups.filter(g=>g.restartOnlyCandidate).length,emptyInvalidKeys:classified.invalid.map(r=>({id:r.id,key:r.timeline_key})),wouldCreateTimelines:pendingEntities.length,wouldCreateLiveLinks:pendingLinks.filter(l=>l.deleted_at===null).length,wouldCreateTombstoneLinks:pendingLinks.filter(l=>l.deleted_at!==null).length,existingIdentical,conflicts,skipped:classified.groups.filter(g=>!approved.has(g.key)).length,wouldLog:pendingEntities.length+pendingLinks.length,sourceCount:rows.length,targetCount:{timelines:entities.length,links:links.length},candidates:classified.groups.map(g=>({key:g.key,classification:g.classification,restartOnlyCandidate:g.restartOnlyCandidate,approved:approved.has(g.key),members:g.members.map(r=>({id:r.id,timelineKey:r.timeline_key,createdAt:r.created_at,updatedAt:r.updated_at,rev:r.rev,deletedAt:r.deleted_at}))}))};
|
|
53
|
+
// Sync hints are review-only, never merged into historical approvedKeys or the apply plan.
|
|
54
|
+
report.syncCandidates=syncReviewCandidates(db);
|
|
55
|
+
return {report,pendingEntities,pendingLinks};
|
|
56
|
+
}
|
|
57
|
+
export function migrateTimelines(db,args,origin,api) {
|
|
58
|
+
if(args.dryRun!==false) return plan(db,args).report;
|
|
59
|
+
if(!Array.isArray(args.approvedKeys)||!args.snapshotHash) throw timelineError('MIGRATION_APPROVAL_REQUIRED','apply 必须明确 approvedKeys 和 snapshotHash');
|
|
60
|
+
return taskTransaction(db,api,buffered=>{
|
|
61
|
+
const {report,pendingEntities,pendingLinks}=plan(db,args);
|
|
62
|
+
if(report.snapshotHash!==args.snapshotHash) throw timelineError('MIGRATION_SNAPSHOT_CHANGED','快照已变化,请重新 dryRun');
|
|
63
|
+
if(report.conflicts.length) throw timelineError('MIGRATION_CONFLICT','存在冲突,未写入',{conflicts:report.conflicts});
|
|
64
|
+
for(const row of pendingEntities) {db.prepare('INSERT INTO task_timeline(id,title,description,created_at,updated_at,deleted_at,rev) VALUES(?,?,?,?,?,?,?)').run(...Object.values(row));timelineChange(db,'task_timeline',row,origin,buffered,'create');}
|
|
65
|
+
for(const row of pendingLinks) {db.prepare('INSERT INTO task_timeline_link(id,task_id,timeline_id,created_at,updated_at,deleted_at,rev) VALUES(?,?,?,?,?,?,?)').run(...Object.values(row));timelineChange(db,'task_timeline_link',row,origin,buffered,'create');}
|
|
66
|
+
const result={...report,dryRun:false,createdTimelines:pendingEntities.length,createdLinks:pendingLinks.length,migrationVersion:1,createdEntityIds:pendingEntities.map(r=>r.id),createdLinkIds:pendingLinks.map(r=>r.id)};
|
|
67
|
+
if(pendingEntities.length||pendingLinks.length) metaSet(db,'task_timeline_migration:'+report.snapshotHash,JSON.stringify(result));
|
|
68
|
+
return result;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { logChange, now } from '../db/db-core.js';
|
|
2
|
+
export { TIMELINE_DDL } from "../db/timeline-schema.js";
|
|
3
|
+
export function timelineError(code, message, details = {}) { return Object.assign(new Error(message), {code, ...details}); }
|
|
4
|
+
export function timelineIdArg(args, required = true) {
|
|
5
|
+
const a = args.timelineId == null ? null : String(args.timelineId);
|
|
6
|
+
const b = args.timelineKey == null ? null : String(args.timelineKey);
|
|
7
|
+
if (a !== null && b !== null && a !== b) throw timelineError('TIMELINE_PARAMETER_CONFLICT','timelineId 与 timelineKey 不一致');
|
|
8
|
+
const id = a ?? b;
|
|
9
|
+
if (required && !id) throw timelineError('TIMELINE_ID_REQUIRED','必须提供 timelineId(兼容 timelineKey)');
|
|
10
|
+
return id || null;
|
|
11
|
+
}
|
|
12
|
+
export function requireTimeline(db, id) {
|
|
13
|
+
const row = db.prepare('SELECT * FROM task_timeline WHERE id=?').get(String(id));
|
|
14
|
+
if (!row) throw timelineError('TIMELINE_NOT_FOUND','时间线不存在:' + id);
|
|
15
|
+
if (row.deleted_at !== null) throw timelineError('TIMELINE_DELETED','时间线已删除:' + id);
|
|
16
|
+
return row;
|
|
17
|
+
}
|
|
18
|
+
export function activeTimeline(db, taskId) {
|
|
19
|
+
return db.prepare('SELECT e.* FROM task_timeline e JOIN task_timeline_link l ON l.timeline_id=e.id JOIN task t ON t.id=l.task_id WHERE l.task_id=? AND l.deleted_at IS NULL AND e.deleted_at IS NULL AND t.deleted_at IS NULL').get(String(taskId)) || null;
|
|
20
|
+
}
|
|
21
|
+
export function timelineOut(row) {
|
|
22
|
+
return {id:row.id,timelineId:row.id,timelineKey:row.id,title:row.title,description:row.description,createdAt:row.created_at,updatedAt:row.updated_at,deletedAt:row.deleted_at,rev:row.rev};
|
|
23
|
+
}
|
|
24
|
+
export function timelineChange(db, table, row, origin, api, op = 'update') {
|
|
25
|
+
logChange(db,table,row.id,op,row,origin,row.updated_at);
|
|
26
|
+
api.emit('tasks-changed',{id:row.id,op});
|
|
27
|
+
api.emit('task-timelines-changed',{id:row.id,op});
|
|
28
|
+
}
|
|
29
|
+
export function touchTimelines(db, ids, origin, api, ts = now()) {
|
|
30
|
+
for (const id of new Set(ids)) {
|
|
31
|
+
if (!id) continue;
|
|
32
|
+
const row = db.prepare('SELECT * FROM task_timeline WHERE id=? AND deleted_at IS NULL').get(id);
|
|
33
|
+
if (!row) continue;
|
|
34
|
+
row.updated_at=ts; row.rev++;
|
|
35
|
+
db.prepare('UPDATE task_timeline SET updated_at=?,rev=? WHERE id=?').run(ts,row.rev,id);
|
|
36
|
+
timelineChange(db,'task_timeline',row,origin,api);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Caller owns the transaction. A shared touched set batches entity rev changes.
|
|
40
|
+
export function setMembership(db, taskId, timelineId, origin, api, {ts=now(), touched, project=true} = {}) {
|
|
41
|
+
if (timelineId !== null) requireTimeline(db,timelineId);
|
|
42
|
+
const old = db.prepare('SELECT * FROM task_timeline_link WHERE task_id=?').get(String(taskId));
|
|
43
|
+
if ((!old || old.deleted_at !== null) && timelineId === null) return false;
|
|
44
|
+
if (old && old.deleted_at === null && old.timeline_id === timelineId) return false;
|
|
45
|
+
const row = {id:String(taskId),task_id:String(taskId),timeline_id:timelineId ?? old.timeline_id,created_at:old?.created_at ?? ts,updated_at:ts,deleted_at:timelineId === null ? ts : null,rev:(old?.rev ?? 0)+1};
|
|
46
|
+
db.prepare('INSERT INTO task_timeline_link(id,task_id,timeline_id,created_at,updated_at,deleted_at,rev) VALUES(?,?,?,?,?,?,?) ON CONFLICT(task_id) DO UPDATE SET timeline_id=excluded.timeline_id,updated_at=excluded.updated_at,deleted_at=excluded.deleted_at,rev=excluded.rev').run(...Object.values(row));
|
|
47
|
+
timelineChange(db,'task_timeline_link',row,origin,api,old?'update':'create');
|
|
48
|
+
if (project) {
|
|
49
|
+
db.prepare('UPDATE task SET timeline_key=?,updated_at=?,rev=rev+1 WHERE id=?').run(timelineId,ts,String(taskId));
|
|
50
|
+
const task = db.prepare('SELECT * FROM task WHERE id=?').get(String(taskId));
|
|
51
|
+
if (task) { logChange(db,'task',task.id,'update',task,origin,ts); api.emit('tasks-changed',{id:task.id,op:'update'}); }
|
|
52
|
+
}
|
|
53
|
+
const ids = [old?.deleted_at === null ? old.timeline_id : null,timelineId];
|
|
54
|
+
if (touched) { for(const id of ids) if(id) touched.add(id); }
|
|
55
|
+
else touchTimelines(db,ids,origin,api,ts);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Legacy keys are candidates only. Membership comes exclusively from stable link rows. */
|
|
2
|
+
function fail(code) { throw Object.assign(new Error(code), { code }); }
|
|
3
|
+
function projectTask(db, id) {
|
|
4
|
+
const link = db.prepare('SELECT * FROM task_timeline_link WHERE task_id=?').get(id);
|
|
5
|
+
if (!link) return; // preserve unapproved historical candidates
|
|
6
|
+
const live = db.prepare('SELECT e.id FROM task_timeline e JOIN task_timeline_link l ON l.timeline_id=e.id JOIN task t ON t.id=l.task_id WHERE l.task_id=? AND e.deleted_at IS NULL AND l.deleted_at IS NULL AND t.deleted_at IS NULL').get(id);
|
|
7
|
+
db.prepare('UPDATE task SET timeline_key=? WHERE id=?').run(live?.id ?? null, id);
|
|
8
|
+
}
|
|
9
|
+
export function normalizeTimelineTask({db,row,local}) {
|
|
10
|
+
const result = {...row};
|
|
11
|
+
// 旧客户端仍可能发送已删除的任务手动排序列。
|
|
12
|
+
delete result.sort;
|
|
13
|
+
const hasTimelineKey = Object.hasOwn(row, "timeline_key");
|
|
14
|
+
if (!hasTimelineKey && local) result.timeline_key = local.timeline_key;
|
|
15
|
+
// 旧客户端不认识接取列:incoming 缺这三列时保留本地值,绝不用 undefined 清空;
|
|
16
|
+
// 显式传 null 视为新值(例如对方已释放),交给整行覆盖逻辑。
|
|
17
|
+
for (const column of ["owner", "claimed_at", "claim_token"]) {
|
|
18
|
+
if (!Object.hasOwn(row, column) && local) result[column] = local[column];
|
|
19
|
+
}
|
|
20
|
+
// Derived fields are not persisted as task columns. Never use them to create membership.
|
|
21
|
+
delete result.timeline_id; delete result.timelineId; delete result.timelineKey;
|
|
22
|
+
const link = db.prepare('SELECT * FROM task_timeline_link WHERE task_id=?').get(row.id);
|
|
23
|
+
if (link) {
|
|
24
|
+
// Incoming dual writes can precede the corresponding link update; the link remains authoritative.
|
|
25
|
+
const entity = db.prepare('SELECT deleted_at FROM task_timeline WHERE id=?').get(link.timeline_id);
|
|
26
|
+
result.timeline_key = row.deleted_at == null && link.deleted_at == null && entity && entity.deleted_at == null ? link.timeline_id : null;
|
|
27
|
+
if (hasTimelineKey && row.timeline_key !== result.timeline_key && (!local || Number(row.updated_at) >= Number(local.updated_at))) {
|
|
28
|
+
// Keep the incoming hint for explicit review; do not silently reinterpret it as membership.
|
|
29
|
+
const key = "task_timeline_migration:sync-candidate:" + JSON.stringify([row.id,row.updated_at,row.timeline_key ?? null]);
|
|
30
|
+
const value = JSON.stringify({taskId:row.id,timelineKey:row.timeline_key ?? null,updatedAt:row.updated_at,reason:"INCOMING_KEY_DIFFERS_FROM_LINK",requiresApproval:true});
|
|
31
|
+
db.prepare("INSERT INTO meta(k,v) VALUES(?,?) ON CONFLICT(k) DO NOTHING").run(key,value);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
export function normalizeTimelineLink({row}) {
|
|
37
|
+
if (typeof row.id !== 'string' || !row.id || row.id !== row.task_id) fail('TIMELINE_LINK_ID_MISMATCH');
|
|
38
|
+
if (typeof row.timeline_id !== 'string' || !row.timeline_id) fail('TIMELINE_REFERENCE_INVALID');
|
|
39
|
+
// Out-of-order parents are retained but hidden by activeTimeline's three-way live join.
|
|
40
|
+
return row;
|
|
41
|
+
}
|
|
42
|
+
export function afterTimelineTask({db,row}) { projectTask(db,row.id); }
|
|
43
|
+
export function afterTimelineLink({db,row}) { projectTask(db,row.task_id); }
|
|
44
|
+
export function afterTimelineEntity({db,row}) {
|
|
45
|
+
for (const link of db.prepare('SELECT task_id FROM task_timeline_link WHERE timeline_id=?').all(row.id)) projectTask(db,link.task_id);
|
|
46
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** 节点无事务助手:调用者必须持有最外层 BEGIN IMMEDIATE,事件由调用者提交后发送。 */
|
|
2
|
+
import limits from '../../shared/tree/limits.cjs';
|
|
3
|
+
const { NAME_MAX } = limits;
|
|
4
|
+
import { nodeMap, newId, now, insertNode, logChange } from '../db/db.js';
|
|
5
|
+
import { ownershipError, pathFromMap } from '../task/model/task-ownership-path.js';
|
|
6
|
+
export function validateNodePlacement(db, parentId, name, excludeId = '') {
|
|
7
|
+
const map = nodeMap(db), parent = map.get(String(parentId));
|
|
8
|
+
if (!parent || parent.deleted_at != null) throw ownershipError('TREE_CORRUPT', '父节点不存在或已删除:' + parentId);
|
|
9
|
+
if (!['0', '2'].includes(String(parent.type))) throw ownershipError('PATH_TYPE_CONFLICT', '任务表下面不能再建节点');
|
|
10
|
+
pathFromMap(parent.id, map);
|
|
11
|
+
if (!name || name.length > NAME_MAX) throw ownershipError('INVALID_PATH', `节点名称不能为空且最多 ${NAME_MAX} 个字符`);
|
|
12
|
+
const matches = db.prepare('SELECT * FROM task_node WHERE parent_id=? AND name=? AND deleted_at IS NULL AND id<>?').all(String(parentId), name, String(excludeId));
|
|
13
|
+
if (matches.length) throw ownershipError('PATH_AMBIGUOUS', '同一父节点下已存在同名节点:' + name, { candidates: matches.map(n => ({ id: String(n.id), type: String(n.type), path: pathFromMap(n.id, map).path })) });
|
|
14
|
+
return parent;
|
|
15
|
+
}
|
|
16
|
+
export function insertOwnedNode(db, parentId, name, type, description, origin) {
|
|
17
|
+
const parent = validateNodePlacement(db, parentId, name);
|
|
18
|
+
if (!['0','1'].includes(String(type))) throw ownershipError('PATH_TYPE_CONFLICT', '只能新建组或任务表');
|
|
19
|
+
if (typeof description !== 'string' || description.length > 2000) throw ownershipError('INVALID_PATH', 'description 必须是最多2000字符的字符串');
|
|
20
|
+
const ts = now(), id = newId();
|
|
21
|
+
const max = db.prepare('SELECT MAX(sort) AS m FROM task_node WHERE parent_id=? AND deleted_at IS NULL').get(String(parent.id));
|
|
22
|
+
const parentChain = pathFromMap(parent.id, nodeMap(db)).pathSegments;
|
|
23
|
+
const row = { id, name, description, type: String(type), parent_id: String(parent.id), path: '/' + parentChain.map(n => n.id).concat(id).join('/') + '/', sort: max.m == null ? 0 : Number(max.m)+1, depth: parentChain.length, created_at: ts, updated_at: ts, deleted_at: null, rev: 1 };
|
|
24
|
+
insertNode(db, row); logChange(db, 'task_node', id, 'create', row, origin, ts);
|
|
25
|
+
return row;
|
|
26
|
+
}
|