@nestos/kanban 0.0.0-stage → 0.5.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/LICENSE +674 -0
- package/README.md +165 -2
- package/dist/activity-BbC4sgKL.d.cts +258 -0
- package/dist/activity-Czlan5xW.d.ts +258 -0
- package/dist/activity-module-DaO1Rry0.d.cts +22 -0
- package/dist/activity-module-T22wliZu.d.ts +22 -0
- package/dist/activity-ports-Dqxa86zT.d.cts +12 -0
- package/dist/activity-ports-cxfrelaL.d.ts +12 -0
- package/dist/activity.cjs +16 -0
- package/dist/activity.cjs.map +1 -0
- package/dist/activity.d.cts +12 -0
- package/dist/activity.d.ts +12 -0
- package/dist/activity.js +16 -0
- package/dist/activity.js.map +1 -0
- package/dist/chunk-3JYLJPE5.js +95 -0
- package/dist/chunk-3JYLJPE5.js.map +1 -0
- package/dist/chunk-3LEIHB7Y.js +221 -0
- package/dist/chunk-3LEIHB7Y.js.map +1 -0
- package/dist/chunk-4XF6LQSU.cjs +9 -0
- package/dist/chunk-4XF6LQSU.cjs.map +1 -0
- package/dist/chunk-5Q7WB63A.cjs +282 -0
- package/dist/chunk-5Q7WB63A.cjs.map +1 -0
- package/dist/chunk-7KDOTBRX.cjs +58 -0
- package/dist/chunk-7KDOTBRX.cjs.map +1 -0
- package/dist/chunk-AHHEGTUA.js +148 -0
- package/dist/chunk-AHHEGTUA.js.map +1 -0
- package/dist/chunk-AOHQCX7K.cjs +95 -0
- package/dist/chunk-AOHQCX7K.cjs.map +1 -0
- package/dist/chunk-DINLR6E6.cjs +443 -0
- package/dist/chunk-DINLR6E6.cjs.map +1 -0
- package/dist/chunk-EYTVC2H5.cjs +1612 -0
- package/dist/chunk-EYTVC2H5.cjs.map +1 -0
- package/dist/chunk-FEE2YBZ7.js +1972 -0
- package/dist/chunk-FEE2YBZ7.js.map +1 -0
- package/dist/chunk-FNO5K3A7.js +282 -0
- package/dist/chunk-FNO5K3A7.js.map +1 -0
- package/dist/chunk-IHHDXZPZ.js +382 -0
- package/dist/chunk-IHHDXZPZ.js.map +1 -0
- package/dist/chunk-J3EAIVA3.js +280 -0
- package/dist/chunk-J3EAIVA3.js.map +1 -0
- package/dist/chunk-KH3WF3K4.js +443 -0
- package/dist/chunk-KH3WF3K4.js.map +1 -0
- package/dist/chunk-M35X5PHO.js +196 -0
- package/dist/chunk-M35X5PHO.js.map +1 -0
- package/dist/chunk-QRGZD2JU.cjs +1972 -0
- package/dist/chunk-QRGZD2JU.cjs.map +1 -0
- package/dist/chunk-RBOER6EW.cjs +221 -0
- package/dist/chunk-RBOER6EW.cjs.map +1 -0
- package/dist/chunk-RQP77ZTY.js +9 -0
- package/dist/chunk-RQP77ZTY.js.map +1 -0
- package/dist/chunk-RSH6QSEC.cjs +196 -0
- package/dist/chunk-RSH6QSEC.cjs.map +1 -0
- package/dist/chunk-VMRDXOLX.cjs +148 -0
- package/dist/chunk-VMRDXOLX.cjs.map +1 -0
- package/dist/chunk-X4UHZX6F.js +58 -0
- package/dist/chunk-X4UHZX6F.js.map +1 -0
- package/dist/chunk-XBSGUVCY.cjs +382 -0
- package/dist/chunk-XBSGUVCY.cjs.map +1 -0
- package/dist/chunk-XKDZHAUE.js +1612 -0
- package/dist/chunk-XKDZHAUE.js.map +1 -0
- package/dist/chunk-ZUZGAO6G.cjs +280 -0
- package/dist/chunk-ZUZGAO6G.cjs.map +1 -0
- package/dist/content-C5aJZFlw.d.cts +35 -0
- package/dist/content-hLH5BNud.d.ts +35 -0
- package/dist/contracts/index.cjs +31 -0
- package/dist/contracts/index.cjs.map +1 -0
- package/dist/contracts/index.d.cts +5 -0
- package/dist/contracts/index.d.ts +5 -0
- package/dist/contracts/index.js +31 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/discovery-9E-LfwIw.d.cts +61 -0
- package/dist/discovery-D60yrjej.d.ts +61 -0
- package/dist/discovery.cjs +377 -0
- package/dist/discovery.cjs.map +1 -0
- package/dist/discovery.d.cts +22 -0
- package/dist/discovery.d.ts +22 -0
- package/dist/discovery.js +377 -0
- package/dist/discovery.js.map +1 -0
- package/dist/execution-bridge-fpCnH6z5.d.cts +52 -0
- package/dist/execution-bridge-rk0uVy_n.d.ts +52 -0
- package/dist/execution.cjs +18 -0
- package/dist/execution.cjs.map +1 -0
- package/dist/execution.d.cts +42 -0
- package/dist/execution.d.ts +42 -0
- package/dist/execution.js +18 -0
- package/dist/execution.js.map +1 -0
- package/dist/index.cjs +74 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +54 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +74 -0
- package/dist/index.js.map +1 -0
- package/dist/module-CYfE7YhM.d.ts +11 -0
- package/dist/module-Ca9L3qCn.d.cts +11 -0
- package/dist/planning-CHrOqQ6b.d.cts +879 -0
- package/dist/planning-CHrOqQ6b.d.ts +879 -0
- package/dist/ports-B0McVg7B.d.ts +143 -0
- package/dist/ports-BeGO1VRI.d.cts +49 -0
- package/dist/ports-GQy0x-RI.d.cts +143 -0
- package/dist/ports-ykGiNUSx.d.ts +49 -0
- package/dist/runtime/index.cjs +205 -0
- package/dist/runtime/index.cjs.map +1 -0
- package/dist/runtime/index.d.cts +75 -0
- package/dist/runtime/index.d.ts +75 -0
- package/dist/runtime/index.js +205 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/integration.cjs +423 -0
- package/dist/runtime/integration.cjs.map +1 -0
- package/dist/runtime/integration.d.cts +658 -0
- package/dist/runtime/integration.d.ts +658 -0
- package/dist/runtime/integration.js +423 -0
- package/dist/runtime/integration.js.map +1 -0
- package/dist/storage.cjs +21 -0
- package/dist/storage.cjs.map +1 -0
- package/dist/storage.d.cts +71 -0
- package/dist/storage.d.ts +71 -0
- package/dist/storage.js +21 -0
- package/dist/storage.js.map +1 -0
- package/dist/store-DPwHzGiz.d.cts +28 -0
- package/dist/store-DgdrPCV9.d.ts +28 -0
- package/dist/task-projection-CSorlMws.d.ts +11 -0
- package/dist/task-projection-DKKB_ueb.d.cts +11 -0
- package/examples/standalone.ts +22 -0
- package/package.json +143 -4
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
import {
|
|
2
|
+
catalog,
|
|
3
|
+
createBoardState,
|
|
4
|
+
limits,
|
|
5
|
+
queryRecords,
|
|
6
|
+
recordSummary,
|
|
7
|
+
reduce,
|
|
8
|
+
related,
|
|
9
|
+
summary,
|
|
10
|
+
terminal,
|
|
11
|
+
viewFromState
|
|
12
|
+
} from "./chunk-XKDZHAUE.js";
|
|
13
|
+
import {
|
|
14
|
+
executable,
|
|
15
|
+
identity,
|
|
16
|
+
normalizeActor,
|
|
17
|
+
principal,
|
|
18
|
+
principalKey,
|
|
19
|
+
requireValue,
|
|
20
|
+
sameOwner,
|
|
21
|
+
workType
|
|
22
|
+
} from "./chunk-3LEIHB7Y.js";
|
|
23
|
+
import {
|
|
24
|
+
kanbanReference
|
|
25
|
+
} from "./chunk-X4UHZX6F.js";
|
|
26
|
+
import {
|
|
27
|
+
KanbanError,
|
|
28
|
+
randomUUID
|
|
29
|
+
} from "./chunk-M35X5PHO.js";
|
|
30
|
+
import {
|
|
31
|
+
boardControlPhase,
|
|
32
|
+
projectKanbanTask
|
|
33
|
+
} from "./chunk-3JYLJPE5.js";
|
|
34
|
+
|
|
35
|
+
// src/references.ts
|
|
36
|
+
async function resolveReference(reference, store, read) {
|
|
37
|
+
requireValue(typeof reference === "string" && reference.length <= 100, "INVALID_REFERENCE");
|
|
38
|
+
const match = /^KB-([1-9]\d*)(?:#([1-9]\d*)|\/(L|D)-([1-9]\d*))?$/i.exec(reference.trim());
|
|
39
|
+
requireValue(match && [match[1], match[2], match[4]].every((value) => value === void 0 || Number.isSafeInteger(Number(value))), "INVALID_REFERENCE");
|
|
40
|
+
const id = await store.boardId?.(Number(match[1]));
|
|
41
|
+
requireValue(id, "REFERENCE_NOT_FOUND");
|
|
42
|
+
const view = await read(id), board = view.state.board;
|
|
43
|
+
requireValue(board.number === Number(match[1]), "INVALID_NUMBERING");
|
|
44
|
+
const target = { boardId: id, scope: board.scope, reference: kanbanReference(board) };
|
|
45
|
+
if (match[2]) {
|
|
46
|
+
const item = [...view.items, ...view.state.archiveIndex ?? []].find((item2) => item2.number === Number(match[2]));
|
|
47
|
+
requireValue(item, "REFERENCE_NOT_FOUND");
|
|
48
|
+
target.itemId = item.id;
|
|
49
|
+
target.reference = kanbanReference(board, item);
|
|
50
|
+
} else if (match[3]) {
|
|
51
|
+
const record = view.records.find((record2) => record2.kind === (match[3].toUpperCase() === "L" ? "log" : "decision") && record2.number === Number(match[4]));
|
|
52
|
+
requireValue(record, "REFERENCE_NOT_FOUND");
|
|
53
|
+
target.recordId = record.id;
|
|
54
|
+
target.reference = kanbanReference(board, record);
|
|
55
|
+
}
|
|
56
|
+
return target;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/suggestions.ts
|
|
60
|
+
function validateSuggestionQuery(query) {
|
|
61
|
+
requireValue(query && ["item", "parent", "dependency", "area", "milestone", "decision", "session"].includes(query.kind), "INVALID_SUGGESTION_KIND");
|
|
62
|
+
requireValue(query.search === void 0 || typeof query.search === "string" && query.search.length <= 256, "INVALID_FILTER");
|
|
63
|
+
const limit = query.limit ?? 20;
|
|
64
|
+
requireValue(Number.isSafeInteger(limit) && limit > 0 && limit <= 50, "INVALID_LIMIT");
|
|
65
|
+
if (query.excludeItemId !== void 0) identity(query.excludeItemId);
|
|
66
|
+
if (query.excludeIds !== void 0) {
|
|
67
|
+
requireValue(Array.isArray(query.excludeIds) && query.excludeIds.length <= 100, "INVALID_FILTER");
|
|
68
|
+
query.excludeIds.forEach(identity);
|
|
69
|
+
}
|
|
70
|
+
if (query.childKind !== void 0) identity(query.childKind);
|
|
71
|
+
return limit;
|
|
72
|
+
}
|
|
73
|
+
function suggestionPage(revision, rows, query) {
|
|
74
|
+
const limit = validateSuggestionQuery(query), search = query.search?.trim().toLocaleLowerCase() ?? "";
|
|
75
|
+
const matched = rows.filter((row) => !query.excludeIds?.includes(row.id)).filter((row) => `${row.id} ${row.label} ${row.detail ?? ""}`.toLocaleLowerCase().includes(search)).sort((a, b) => score(a.label, search) - score(b.label, search) || a.label.localeCompare(b.label) || a.id.localeCompare(b.id));
|
|
76
|
+
return { revision, items: matched.slice(0, limit).map((row) => ({ id: row.id, label: row.label.slice(0, 256), ...row.detail ? { detail: row.detail.slice(0, 512) } : {}, ...row.status ? { status: row.status } : {}, ...row.archived !== void 0 ? { archived: row.archived } : {} })), hasMore: matched.length > limit };
|
|
77
|
+
}
|
|
78
|
+
var score = (label, query) => label.toLocaleLowerCase() === query ? 0 : label.toLocaleLowerCase().startsWith(query) ? 1 : 2;
|
|
79
|
+
function suggestFromState(state, query, items = catalog(state), records = (state.records ?? []).map(recordSummary)) {
|
|
80
|
+
validateSuggestionQuery(query);
|
|
81
|
+
if (query.kind === "area" || query.kind === "milestone") {
|
|
82
|
+
const names = [...new Set(items.map((item) => item.planning[query.kind]).filter((name) => !!name))];
|
|
83
|
+
return suggestionPage(state.board.revision, names.map((name) => ({ id: name, label: name })), query);
|
|
84
|
+
}
|
|
85
|
+
if (query.kind === "decision") return suggestionPage(state.board.revision, records.filter((record) => record.kind === "decision" && record.status === "confirmed").map((record) => ({ id: record.id, label: record.title, detail: kanbanReference(state.board, record) })), query);
|
|
86
|
+
if (query.kind === "session") {
|
|
87
|
+
const ids = /* @__PURE__ */ new Set([
|
|
88
|
+
...state.board.participants.map((p) => p.sessionId),
|
|
89
|
+
...items.flatMap((item) => item.sessionIds),
|
|
90
|
+
...records.flatMap((record) => record.sessionIds)
|
|
91
|
+
]);
|
|
92
|
+
return suggestionPage(state.board.revision, [...ids].map((id) => ({ id, label: id })), query);
|
|
93
|
+
}
|
|
94
|
+
const blocked = query.kind === "dependency" && query.excludeItemId ? dependents(items, query.excludeItemId) : /* @__PURE__ */ new Set();
|
|
95
|
+
const rank = query.kind === "parent" ? workType(state.board, query.childKind ?? state.board.defaultWorkType ?? "task").rank : void 0;
|
|
96
|
+
const rows = items.filter((item) => item.id !== query.excludeItemId && !blocked.has(item.id) && (query.kind !== "dependency" || item.status !== "cancelled") && (rank === void 0 || item.archivedAt === void 0 && !terminal(item) && workType(state.board, item.planning.kind).rank < rank)).map((item) => ({
|
|
97
|
+
id: item.id,
|
|
98
|
+
label: item.title,
|
|
99
|
+
status: item.status,
|
|
100
|
+
archived: item.archivedAt !== void 0,
|
|
101
|
+
detail: [kanbanReference(state.board, item), item.planning.area, item.planning.milestone].filter(Boolean).join(" \xB7 ")
|
|
102
|
+
}));
|
|
103
|
+
return suggestionPage(state.board.revision, rows, query);
|
|
104
|
+
}
|
|
105
|
+
function dependents(items, id) {
|
|
106
|
+
const reverse = /* @__PURE__ */ new Map();
|
|
107
|
+
for (const item of items) for (const dependency of item.planning.dependencies) reverse.set(dependency, [...reverse.get(dependency) ?? [], item.id]);
|
|
108
|
+
const result = /* @__PURE__ */ new Set([id]), pending = [id];
|
|
109
|
+
while (pending.length) for (const next of reverse.get(pending.pop()) ?? []) if (!result.has(next)) {
|
|
110
|
+
result.add(next);
|
|
111
|
+
pending.push(next);
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/queries.ts
|
|
117
|
+
function queryItems(state, query = {}, all = catalog(state), now = Date.now()) {
|
|
118
|
+
const { cursor, limit = 50, ...filters } = query;
|
|
119
|
+
requireValue(Number.isSafeInteger(limit) && limit >= 1 && limit <= 200, "INVALID_PAGE_SIZE");
|
|
120
|
+
requireValue(["ready", "backlog", "in-progress", "review", "closed", "proposed", "archive", "all"].includes(query.view ?? "ready"), "INVALID_VIEW");
|
|
121
|
+
for (const field of ["area", "milestone", "parentId", "kind", "sessionId", "search"]) if (filters[field] !== void 0) requireValue(typeof filters[field] === "string" && filters[field].length <= 256, "INVALID_FILTER");
|
|
122
|
+
if (filters.reference) requireValue(typeof filters.reference.system === "string" && typeof filters.reference.id === "string" && filters.reference.system.length <= 256 && filters.reference.id.length <= 256, "INVALID_REFERENCE_FILTER");
|
|
123
|
+
const fingerprint = JSON.stringify(Object.fromEntries(Object.entries({ ...filters, view: filters.view ?? "ready" }).sort(([a], [b]) => a.localeCompare(b)))), revision = state.board.revision;
|
|
124
|
+
all = all.map((item) => ({ ...item, task: projectKanbanTask(item, state.workflow, now, all) }));
|
|
125
|
+
const matches = all.filter((item) => matchesQuery(item, filters, state.board)).sort(filters.view === "archive" ? (a, b) => (b.archivedAt ?? 0) - (a.archivedAt ?? 0) || a.id.localeCompare(b.id) : order);
|
|
126
|
+
let start = 0;
|
|
127
|
+
if (cursor) {
|
|
128
|
+
requireValue(typeof cursor === "string" && cursor.length <= 4e3, "INVALID_CURSOR");
|
|
129
|
+
let decoded;
|
|
130
|
+
try {
|
|
131
|
+
decoded = JSON.parse(cursor);
|
|
132
|
+
} catch {
|
|
133
|
+
requireValue(false, "INVALID_CURSOR");
|
|
134
|
+
}
|
|
135
|
+
requireValue(decoded && decoded.filter === fingerprint, "CURSOR_SCOPE_MISMATCH");
|
|
136
|
+
requireValue(decoded.revision === revision, "CURSOR_STALE");
|
|
137
|
+
start = matches.findIndex((i) => i.id === decoded.after) + 1;
|
|
138
|
+
requireValue(start > 0, "INVALID_CURSOR");
|
|
139
|
+
}
|
|
140
|
+
const progress = progressByParent(state, all);
|
|
141
|
+
const items = matches.slice(start, start + limit).map((item) => ({ ...item, ...progress.has(item.id) ? { progress: progress.get(item.id) } : {} }));
|
|
142
|
+
return { revision, total: matches.length, items, ...start + items.length < matches.length ? {
|
|
143
|
+
nextCursor: JSON.stringify({ revision, after: items.at(-1).id, filter: fingerprint })
|
|
144
|
+
} : {} };
|
|
145
|
+
}
|
|
146
|
+
function order(a, b) {
|
|
147
|
+
return a.planning.priority - b.planning.priority || a.createdAt - b.createdAt || a.id.localeCompare(b.id);
|
|
148
|
+
}
|
|
149
|
+
function matchesQuery(item, query, board) {
|
|
150
|
+
if (item.deletedAt !== void 0 && !query.includeDeleted) return false;
|
|
151
|
+
if (query.phase && item.task?.phase !== query.phase) return false;
|
|
152
|
+
if (!matchesView(item, query.view ?? "ready")) return false;
|
|
153
|
+
for (const field of ["area", "milestone", "parentId", "kind"]) if (query[field] !== void 0 && item.planning[field] !== query[field]) return false;
|
|
154
|
+
if (query.reference && !item.externalRefs?.some((r) => r.system === query.reference.system && r.id === query.reference.id)) return false;
|
|
155
|
+
if (query.sessionId && !item.sessionIds.includes(query.sessionId)) return false;
|
|
156
|
+
if (query.search && !`${kanbanReference(board, item)} ${item.id} ${item.title} ${item.planning.area ?? ""}`.toLowerCase().includes(query.search.toLowerCase())) return false;
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
function matchesView(item, view) {
|
|
160
|
+
if (view === "archive") return item.archivedAt !== void 0;
|
|
161
|
+
if (view === "all") return true;
|
|
162
|
+
if (item.archivedAt !== void 0) return false;
|
|
163
|
+
if (view === "in-progress") return item.status === "claimed" || item.status === "review";
|
|
164
|
+
if (view === "closed") return terminal(item);
|
|
165
|
+
return item.status === { ready: "open", backlog: "backlog", review: "review", proposed: "proposed" }[view];
|
|
166
|
+
}
|
|
167
|
+
function overview(state, now, items = state.board.items.map(summary)) {
|
|
168
|
+
items = items.filter((item) => item.deletedAt === void 0);
|
|
169
|
+
const count = (status) => items.filter((i) => i.status === status).length;
|
|
170
|
+
const age = state.board.policy.backlogReviewMs;
|
|
171
|
+
return {
|
|
172
|
+
revision: state.board.revision,
|
|
173
|
+
visible: items.length,
|
|
174
|
+
active: items.filter((i) => !terminal(i)).length,
|
|
175
|
+
archived: state.archiveIndex?.length ?? 0,
|
|
176
|
+
ready: count("open"),
|
|
177
|
+
inProgress: count("claimed") + count("review"),
|
|
178
|
+
backlog: count("backlog"),
|
|
179
|
+
proposed: count("proposed"),
|
|
180
|
+
closed: count("completed") + count("cancelled"),
|
|
181
|
+
dueForReview: age ? items.filter((i) => i.status === "backlog" && now - i.updatedAt >= age).length : 0,
|
|
182
|
+
limits: limits(state)
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function progressByParent(state, all) {
|
|
186
|
+
const byId = new Map(all.map((i) => [i.id, i]));
|
|
187
|
+
const result = /* @__PURE__ */ new Map();
|
|
188
|
+
for (const item of all.filter((i) => executable(state.board, i))) {
|
|
189
|
+
let parent = item.planning.parentId;
|
|
190
|
+
const seen = /* @__PURE__ */ new Set();
|
|
191
|
+
while (parent && !seen.has(parent)) {
|
|
192
|
+
seen.add(parent);
|
|
193
|
+
const progress = result.get(parent) ?? { total: 0, completed: 0, cancelled: 0, inProgress: 0 };
|
|
194
|
+
progress.total++;
|
|
195
|
+
if (item.status === "completed") progress.completed++;
|
|
196
|
+
if (item.status === "cancelled") progress.cancelled++;
|
|
197
|
+
if (item.status === "claimed" || item.status === "review") progress.inProgress++;
|
|
198
|
+
result.set(parent, progress);
|
|
199
|
+
parent = byId.get(parent)?.planning.parentId;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// src/module.ts
|
|
206
|
+
function createKanbanModule(options) {
|
|
207
|
+
return new KanbanModule(options);
|
|
208
|
+
}
|
|
209
|
+
var KanbanModule = class {
|
|
210
|
+
constructor(options) {
|
|
211
|
+
this.options = options;
|
|
212
|
+
this.now = options.now ?? Date.now;
|
|
213
|
+
this.id = options.id ?? randomUUID;
|
|
214
|
+
this.actor = normalizeActor(options.actor);
|
|
215
|
+
}
|
|
216
|
+
stopping = false;
|
|
217
|
+
pending = /* @__PURE__ */ new Set();
|
|
218
|
+
async quiesce() {
|
|
219
|
+
this.stopping = true;
|
|
220
|
+
await Promise.allSettled([...this.pending]);
|
|
221
|
+
}
|
|
222
|
+
async dispose() {
|
|
223
|
+
await this.quiesce();
|
|
224
|
+
}
|
|
225
|
+
now;
|
|
226
|
+
id;
|
|
227
|
+
actor;
|
|
228
|
+
workflow = (boardId) => this.guard(this.id(), boardId, "workflow", async () => structuredClone((await this.readView(boardId)).state.workflow ?? { plans: {}, dispatches: {}, ready: [], completedPlans: [] }));
|
|
229
|
+
resolve = (reference) => this.guard(this.id(), void 0, "resolve", () => resolveReference(reference, this.options.store, (id) => this.readView(id)));
|
|
230
|
+
suggest = (boardId, query) => this.guard(this.id(), boardId, "suggest", async () => {
|
|
231
|
+
const snapshot = structuredClone(query), limit = validateSuggestionQuery(snapshot), view = await this.readView(boardId), state = view.state;
|
|
232
|
+
const suggestions = () => suggestFromState(state, snapshot, [...view.items, ...state.archiveIndex ?? []], view.records);
|
|
233
|
+
if (!this.options.suggestions) return suggestions();
|
|
234
|
+
const rows = await this.options.suggestions(structuredClone(state.board), snapshot.kind, snapshot.search?.trim() ?? "", limit + 1);
|
|
235
|
+
if (rows === void 0) return suggestions();
|
|
236
|
+
const known = suggestions().items.filter((row) => !rows.some((entry) => entry.id === row.id));
|
|
237
|
+
return suggestionPage(state.board.revision, [...rows, ...known], snapshot);
|
|
238
|
+
});
|
|
239
|
+
records = (boardId, query) => this.guard(this.id(), boardId, "records", async () => {
|
|
240
|
+
const view = await this.readView(boardId);
|
|
241
|
+
return structuredClone(queryRecords(view.state, query, view.records));
|
|
242
|
+
});
|
|
243
|
+
record = (boardId, recordId) => this.guard(this.id(), boardId, "record", async () => {
|
|
244
|
+
identity(recordId);
|
|
245
|
+
const record = (await this.readState(boardId)).records?.find((record2) => record2.id === recordId);
|
|
246
|
+
requireValue(record, "RECORD_NOT_FOUND");
|
|
247
|
+
return structuredClone(record);
|
|
248
|
+
});
|
|
249
|
+
currentPrincipal = async () => structuredClone(principal(this.actor));
|
|
250
|
+
create = (input) => {
|
|
251
|
+
const snapshot = structuredClone(input);
|
|
252
|
+
return this.guard(this.id(), snapshot.id, "create", async () => {
|
|
253
|
+
const initial = createBoardState(snapshot, this.actor, this.now()), board = initial.board;
|
|
254
|
+
await this.authorize(board, "create");
|
|
255
|
+
const state = await this.options.store.update(board.id, `create:${board.id}`, JSON.stringify({ snapshot, actor: this.actor }), (previous) => {
|
|
256
|
+
requireValue(!previous, "BOARD_EXISTS");
|
|
257
|
+
return initial;
|
|
258
|
+
});
|
|
259
|
+
return structuredClone(state.board);
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
read = (boardId) => this.guard(
|
|
263
|
+
this.id(),
|
|
264
|
+
boardId,
|
|
265
|
+
"read",
|
|
266
|
+
async () => structuredClone((await this.readState(boardId)).board)
|
|
267
|
+
);
|
|
268
|
+
catalog = () => this.guard(this.id(), void 0, "catalog", async () => {
|
|
269
|
+
const boards = [];
|
|
270
|
+
for (const id of await this.options.store.ids()) {
|
|
271
|
+
try {
|
|
272
|
+
const view = await this.readView(id);
|
|
273
|
+
if (view.state.board.deletedAt !== void 0) continue;
|
|
274
|
+
boards.push({ ...view.state.board, executionPhase: boardControlPhase({ ...view.state.board, items: view.items }), items: view.items.filter((item) => item.deletedAt === void 0).map(({ id: id2, title, number }) => ({ id: id2, title, ...number === void 0 ? {} : { number } })) });
|
|
275
|
+
} catch (error) {
|
|
276
|
+
if (!(error instanceof KanbanError) || error.code !== "FORBIDDEN") throw error;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return structuredClone(boards);
|
|
280
|
+
});
|
|
281
|
+
list = () => this.guard(this.id(), void 0, "list", async () => {
|
|
282
|
+
const boards = [];
|
|
283
|
+
for (const boardId of await this.options.store.ids()) {
|
|
284
|
+
try {
|
|
285
|
+
const board = (await this.readState(boardId)).board;
|
|
286
|
+
if (board.deletedAt === void 0) boards.push(structuredClone(board));
|
|
287
|
+
} catch (error) {
|
|
288
|
+
if (!(error instanceof KanbanError) || error.code !== "FORBIDDEN") throw error;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return boards;
|
|
292
|
+
});
|
|
293
|
+
execute = (boardId, input) => this.guard(input.operationId, boardId, `execute:${input.command.type}`, async () => {
|
|
294
|
+
const request = structuredClone(input);
|
|
295
|
+
identity(request.operationId);
|
|
296
|
+
const state = await this.readState(boardId);
|
|
297
|
+
await this.authorize(state.board, request.command.type, request.command);
|
|
298
|
+
requireValue(state.board.deletedAt === void 0, "BOARD_DELETED");
|
|
299
|
+
if (request.command.type === "delete-board") await this.options.verifyDeletion?.(structuredClone(state.board));
|
|
300
|
+
await this.options.verifyLifecycle?.(structuredClone(state.board), request.command);
|
|
301
|
+
await this.verifyRelease(state.board, request.command);
|
|
302
|
+
const verifyStage = request.command.type === "observe-execution" && request.command.outcome === "succeeded" ? "observe" : request.command.type === "accept-execution" && request.command.accept ? "accept" : void 0;
|
|
303
|
+
if (verifyStage && "dispatchId" in request.command) {
|
|
304
|
+
const dispatch = state.workflow?.dispatches[request.command.dispatchId];
|
|
305
|
+
requireValue(dispatch, "DISPATCH_NOT_FOUND");
|
|
306
|
+
const outputs = request.command.type === "observe-execution" ? request.command.outputs : dispatch.outputs;
|
|
307
|
+
if (outputs?.length) requireValue(await this.options.verifyOutputs?.({
|
|
308
|
+
stage: verifyStage,
|
|
309
|
+
board: state.board,
|
|
310
|
+
itemId: dispatch.itemId,
|
|
311
|
+
dispatchId: dispatch.id,
|
|
312
|
+
outputs: structuredClone(outputs)
|
|
313
|
+
}), "OUTPUT_VERIFICATION_REQUIRED");
|
|
314
|
+
}
|
|
315
|
+
const restore = request.command.type === "restore-item" ? await this.options.store.archived(boardId, request.command.itemId) : void 0;
|
|
316
|
+
const result = await this.options.store.update(boardId, request.operationId, JSON.stringify({ actor: this.actor, request }), (current) => {
|
|
317
|
+
requireValue(current && current.board.revision === state.board.revision, "REVISION_CONFLICT");
|
|
318
|
+
requireValue(current.board.revision === request.expectedRevision, "REVISION_CONFLICT");
|
|
319
|
+
if (restore) current.restore = restore;
|
|
320
|
+
return reduce(current, request.command, this.actor, request.operationId, this.now(), this.id());
|
|
321
|
+
});
|
|
322
|
+
await this.publishNotifications(boardId, request.operationId);
|
|
323
|
+
return structuredClone(result.board);
|
|
324
|
+
});
|
|
325
|
+
events = (boardId, after = 0, limit = 100) => this.guard(this.id(), boardId, "events", async () => {
|
|
326
|
+
requireValue(Number.isSafeInteger(after) && after >= 0 && Number.isSafeInteger(limit) && limit > 0 && limit <= 500, "INVALID_CURSOR");
|
|
327
|
+
const { state } = await this.readView(boardId);
|
|
328
|
+
return this.options.store.events(boardId, after, limit, state.sequence);
|
|
329
|
+
});
|
|
330
|
+
query = (boardId, query) => this.guard(this.id(), boardId, "query", async () => {
|
|
331
|
+
const view = await this.readView(boardId);
|
|
332
|
+
return structuredClone(queryItems(view.state, query, [...view.items, ...view.state.archiveIndex ?? []], this.now()));
|
|
333
|
+
});
|
|
334
|
+
overview = (boardId) => this.guard(this.id(), boardId, "overview", async () => {
|
|
335
|
+
const view = await this.readView(boardId);
|
|
336
|
+
return overview(view.state, this.now(), view.items);
|
|
337
|
+
});
|
|
338
|
+
item = (boardId, itemId) => this.guard(this.id(), boardId, "item", async () => {
|
|
339
|
+
identity(itemId);
|
|
340
|
+
const state = await this.readState(boardId), item = state.board.items.find((i) => i.id === itemId);
|
|
341
|
+
if (item) return { item: structuredClone(item), task: projectKanbanTask(item, state.workflow, this.now(), [...state.board.items, ...state.archiveIndex ?? []]) };
|
|
342
|
+
requireValue(state.archiveIndex?.some((i) => i.id === itemId), "ITEM_NOT_FOUND");
|
|
343
|
+
const record = await this.options.store.archived(boardId, itemId);
|
|
344
|
+
requireValue(record, "REVISION_CONFLICT");
|
|
345
|
+
return { item: structuredClone(record.item), task: projectKanbanTask(record.item, state.workflow, this.now(), state.archiveIndex), archive: { archivedAt: record.archivedAt, reason: record.reason } };
|
|
346
|
+
});
|
|
347
|
+
related = (sessionId) => this.guard(this.id(), void 0, "related", async () => {
|
|
348
|
+
identity(sessionId);
|
|
349
|
+
const result = [];
|
|
350
|
+
for (const board of await this.list()) {
|
|
351
|
+
const state = await this.readState(board.id);
|
|
352
|
+
if (related(board).includes(sessionId) || state.records?.some((record) => record.sources.some((source) => source.sessionId === sessionId)) || state.archiveIndex?.some((i) => i.sessionIds.includes(sessionId))) result.push(board);
|
|
353
|
+
}
|
|
354
|
+
return result;
|
|
355
|
+
});
|
|
356
|
+
scan = () => this.guard(this.id(), void 0, "scan", async () => {
|
|
357
|
+
const errors = [];
|
|
358
|
+
for (const id of await this.options.store.ids()) {
|
|
359
|
+
try {
|
|
360
|
+
const board = (await this.readState(id)).board;
|
|
361
|
+
if (board.deletedAt !== void 0) {
|
|
362
|
+
await this.publishNotifications(id, this.id());
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
await this.execute(board.id, { operationId: this.id(), expectedRevision: board.revision, command: { type: "scan" } });
|
|
366
|
+
} catch (error) {
|
|
367
|
+
if (!(error instanceof KanbanError) || !["REVISION_CONFLICT", "FORBIDDEN"].includes(error.code)) errors.push(error);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (errors.length) throw new AggregateError(errors, "KANBAN_SCAN_FAILED");
|
|
371
|
+
});
|
|
372
|
+
async verifyRelease(board, command) {
|
|
373
|
+
if (command.type !== "release-item") return;
|
|
374
|
+
const item = board.items.find((i) => i.id === command.itemId);
|
|
375
|
+
requireValue(item?.owner && item.owner.token === command.token, "OWNER_MISMATCH");
|
|
376
|
+
const own = sameOwner(item.owner, this.actor), actor = principal(this.actor);
|
|
377
|
+
const coordinator = board.members?.some((m) => principalKey(m) === principalKey(actor) && m.roles?.includes("coordinator"));
|
|
378
|
+
requireValue(own || coordinator, "OWNER_MISMATCH");
|
|
379
|
+
if (!(own && actor.kind === "human")) requireValue(await this.options.verifyRelease?.({ actor: this.actor, board: structuredClone(board), item: structuredClone(item) }), "EXECUTION_NOT_SETTLED");
|
|
380
|
+
}
|
|
381
|
+
async publishNotifications(boardId, operationId) {
|
|
382
|
+
if (!this.options.onCommitted) return;
|
|
383
|
+
const started = this.now();
|
|
384
|
+
try {
|
|
385
|
+
await this.options.onCommitted(boardId, this, this.now());
|
|
386
|
+
this.log(operationId, boardId, "notify", started, "success");
|
|
387
|
+
} catch (error) {
|
|
388
|
+
this.log(operationId, boardId, "notify", started, "failure", safeCode(error, "NOTIFICATION_PROJECTION_FAILED"));
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
async readView(boardId) {
|
|
392
|
+
identity(boardId);
|
|
393
|
+
if (!this.options.store.view) return viewFromState(await this.readState(boardId));
|
|
394
|
+
const view = await this.options.store.view(boardId);
|
|
395
|
+
requireValue(view, "BOARD_NOT_FOUND");
|
|
396
|
+
await this.authorize(view.state.board, "read");
|
|
397
|
+
return view;
|
|
398
|
+
}
|
|
399
|
+
async readState(boardId) {
|
|
400
|
+
identity(boardId);
|
|
401
|
+
const state = await this.options.store.read(boardId);
|
|
402
|
+
requireValue(state, "BOARD_NOT_FOUND");
|
|
403
|
+
await this.authorize(state.board, "read");
|
|
404
|
+
return state;
|
|
405
|
+
}
|
|
406
|
+
authorize(board, action, command) {
|
|
407
|
+
return this.options.authorize({ actor: structuredClone(this.actor), board: structuredClone(board), action, command: structuredClone(command) });
|
|
408
|
+
}
|
|
409
|
+
async guard(operationId, boardId, stage, run) {
|
|
410
|
+
const start = this.now();
|
|
411
|
+
if (this.stopping) {
|
|
412
|
+
this.log(operationId, boardId, stage, start, "failure", "SERVICE_STOPPING");
|
|
413
|
+
throw new KanbanError("SERVICE_STOPPING");
|
|
414
|
+
}
|
|
415
|
+
const operation = Promise.resolve().then(run);
|
|
416
|
+
this.pending.add(operation);
|
|
417
|
+
try {
|
|
418
|
+
const result = await operation;
|
|
419
|
+
this.log(operationId, boardId, stage, start, "success");
|
|
420
|
+
return result;
|
|
421
|
+
} catch (error) {
|
|
422
|
+
this.log(operationId, boardId, stage, start, "failure", safeCode(error, "PORT_FAILURE"));
|
|
423
|
+
throw error;
|
|
424
|
+
} finally {
|
|
425
|
+
this.pending.delete(operation);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
log(operationId, boardId, stage, start, result, code) {
|
|
429
|
+
try {
|
|
430
|
+
this.options.log({ operationId, boardId, stage, result, code, durationMs: this.now() - start });
|
|
431
|
+
} catch {
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
function safeCode(error, fallback) {
|
|
436
|
+
const code = error?.code;
|
|
437
|
+
return typeof code === "string" && /^[A-Z][A-Z0-9_]{0,79}$/.test(code) ? code : fallback;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export {
|
|
441
|
+
createKanbanModule
|
|
442
|
+
};
|
|
443
|
+
//# sourceMappingURL=chunk-KH3WF3K4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/references.ts","../src/suggestions.ts","../src/queries.ts","../src/module.ts"],"sourcesContent":["import {kanbanReference, type KanbanReferenceTarget} from './contracts';\nimport type {KanbanReadView, KanbanStore} from './ports';\nimport {requireValue} from './rules';\n\nexport async function resolveReference(reference: string, store: KanbanStore, read: (id: string) => Promise<KanbanReadView>): Promise<KanbanReferenceTarget> {\n requireValue(typeof reference === 'string' && reference.length <= 100, 'INVALID_REFERENCE');\n const match = /^KB-([1-9]\\d*)(?:#([1-9]\\d*)|\\/(L|D)-([1-9]\\d*))?$/i.exec(reference.trim());\n requireValue(match && [match[1], match[2], match[4]].every(value => value === undefined || Number.isSafeInteger(Number(value))), 'INVALID_REFERENCE');\n const id = await store.boardId?.(Number(match[1])); requireValue(id, 'REFERENCE_NOT_FOUND');\n const view = await read(id), board = view.state.board;\n requireValue(board.number === Number(match[1]), 'INVALID_NUMBERING');\n const target: KanbanReferenceTarget = {boardId: id, scope: board.scope, reference: kanbanReference(board)};\n if (match[2]) {\n const item = [...view.items, ...(view.state.archiveIndex ?? [])].find(item => item.number === Number(match[2]));\n requireValue(item, 'REFERENCE_NOT_FOUND'); target.itemId = item.id; target.reference = kanbanReference(board, item);\n } else if (match[3]) {\n const record = view.records.find(record => record.kind === (match[3].toUpperCase() === 'L' ? 'log' : 'decision') && record.number === Number(match[4]));\n requireValue(record, 'REFERENCE_NOT_FOUND'); target.recordId = record.id; target.reference = kanbanReference(board, record);\n }\n return target;\n}\n","import {kanbanReference} from './contracts';\nimport type {KanbanSuggestion, KanbanSuggestionPage, KanbanSuggestionQuery} from './contracts';\nimport type {KanbanState} from './ports';\nimport {recordSummary} from './project-records';\nimport {catalog, terminal} from './planning';\nimport {workType} from './configuration';\nimport {identity, requireValue} from './rules';\n\nexport function validateSuggestionQuery(query: KanbanSuggestionQuery): number {\n requireValue(query && ['item', 'parent', 'dependency', 'area', 'milestone', 'decision', 'session'].includes(query.kind), 'INVALID_SUGGESTION_KIND');\n requireValue(query.search === undefined || typeof query.search === 'string' && query.search.length <= 256, 'INVALID_FILTER');\n const limit = query.limit ?? 20; requireValue(Number.isSafeInteger(limit) && limit > 0 && limit <= 50, 'INVALID_LIMIT');\n if (query.excludeItemId !== undefined) identity(query.excludeItemId);\n if (query.excludeIds !== undefined) {requireValue(Array.isArray(query.excludeIds) && query.excludeIds.length <= 100, 'INVALID_FILTER'); query.excludeIds.forEach(identity);}\n if (query.childKind !== undefined) identity(query.childKind);\n return limit;\n}\nexport function suggestionPage(revision: number, rows: KanbanSuggestion[], query: KanbanSuggestionQuery): KanbanSuggestionPage {\n const limit = validateSuggestionQuery(query), search = query.search?.trim().toLocaleLowerCase() ?? '';\n const matched = rows.filter(row => !query.excludeIds?.includes(row.id)).filter(row => `${row.id} ${row.label} ${row.detail ?? ''}`.toLocaleLowerCase().includes(search))\n .sort((a, b) => score(a.label, search) - score(b.label, search) || a.label.localeCompare(b.label) || a.id.localeCompare(b.id));\n return {revision, items: matched.slice(0, limit).map(row => ({id: row.id, label: row.label.slice(0, 256), ...(row.detail ? {detail: row.detail.slice(0, 512)} : {}), ...(row.status ? {status: row.status} : {}), ...(row.archived !== undefined ? {archived: row.archived} : {})})), hasMore: matched.length > limit};\n}\nconst score = (label: string, query: string) => label.toLocaleLowerCase() === query ? 0 : label.toLocaleLowerCase().startsWith(query) ? 1 : 2;\nexport function suggestFromState(state: KanbanState, query: KanbanSuggestionQuery, items = catalog(state), records = (state.records ?? []).map(recordSummary)): KanbanSuggestionPage {\n validateSuggestionQuery(query);\n if (query.kind === 'area' || query.kind === 'milestone') {\n const names = [...new Set(items.map(item => item.planning[query.kind as 'area' | 'milestone']).filter((name): name is string => !!name))];\n return suggestionPage(state.board.revision, names.map(name => ({id: name, label: name})), query);\n }\n if (query.kind === 'decision') return suggestionPage(state.board.revision, records\n .filter(record => record.kind === 'decision' && record.status === 'confirmed').map(record => ({id: record.id, label: record.title, detail: kanbanReference(state.board, record)})), query);\n if (query.kind === 'session') {\n const ids = new Set([...state.board.participants.map(p => p.sessionId), ...items.flatMap(item => item.sessionIds),\n ...records.flatMap(record => record.sessionIds)]);\n return suggestionPage(state.board.revision, [...ids].map(id => ({id, label: id})), query);\n }\n const blocked = query.kind === 'dependency' && query.excludeItemId ? dependents(items, query.excludeItemId) : new Set<string>();\n const rank = query.kind === 'parent' ? workType(state.board, query.childKind ?? state.board.defaultWorkType ?? 'task').rank : undefined;\n const rows = items.filter(item => item.id !== query.excludeItemId && !blocked.has(item.id)\n && (query.kind !== 'dependency' || item.status !== 'cancelled')\n && (rank === undefined || item.archivedAt === undefined && !terminal(item) && workType(state.board, item.planning.kind).rank < rank))\n .map(item => ({id: item.id, label: item.title, status: item.status, archived: item.archivedAt !== undefined,\n detail: [kanbanReference(state.board, item), item.planning.area, item.planning.milestone].filter(Boolean).join(' · ')}));\n return suggestionPage(state.board.revision, rows, query);\n}\nfunction dependents(items: import('./contracts').KanbanItemSummary[], id: string): Set<string> {\n const reverse = new Map<string, string[]>();\n for (const item of items) for (const dependency of item.planning.dependencies) reverse.set(dependency, [...(reverse.get(dependency) ?? []), item.id]);\n const result = new Set([id]), pending = [id];\n while (pending.length) for (const next of reverse.get(pending.pop()!) ?? []) if (!result.has(next)) {result.add(next); pending.push(next);}\n return result;\n}\n","import {projectKanbanTask} from './contracts/task-projection';\nimport {kanbanReference} from './contracts';\nimport type {KanbanItemPage, KanbanItemQuery, KanbanItemSummary, KanbanOverview} from './contracts';\nimport type {KanbanState} from './ports';\nimport {requireValue} from './rules';\nimport {executable} from './configuration';\nimport {catalog, limits, summary, terminal} from './planning';\n\nexport function queryItems(state: KanbanState, query: KanbanItemQuery = {}, all = catalog(state), now = Date.now()): KanbanItemPage {\n const {cursor, limit = 50, ...filters} = query;\n requireValue(Number.isSafeInteger(limit) && limit >= 1 && limit <= 200, 'INVALID_PAGE_SIZE');\n requireValue(['ready', 'backlog', 'in-progress', 'review', 'closed', 'proposed', 'archive', 'all'].includes(query.view ?? 'ready'), 'INVALID_VIEW');\n for (const field of ['area', 'milestone', 'parentId', 'kind', 'sessionId', 'search'] as const) if (filters[field] !== undefined) requireValue(typeof filters[field] === 'string' && filters[field]!.length <= 256, 'INVALID_FILTER');\n if (filters.reference) requireValue(typeof filters.reference.system === 'string' && typeof filters.reference.id === 'string' && filters.reference.system.length <= 256 && filters.reference.id.length <= 256, 'INVALID_REFERENCE_FILTER');\n const fingerprint = JSON.stringify(Object.fromEntries(Object.entries({...filters, view: filters.view ?? 'ready'}).sort(([a], [b]) => a.localeCompare(b)))), revision = state.board.revision;\n all = all.map(item => ({...item, task: projectKanbanTask(item, state.workflow, now, all)}));\n const matches = all.filter(item => matchesQuery(item, filters, state.board)).sort(filters.view === 'archive'\n ? (a, b) => (b.archivedAt ?? 0) - (a.archivedAt ?? 0) || a.id.localeCompare(b.id) : order);\n let start = 0;\n if (cursor) {\n requireValue(typeof cursor === 'string' && cursor.length <= 4000, 'INVALID_CURSOR');\n let decoded: {revision: number; after: string; filter: string};\n try {decoded = JSON.parse(cursor);} catch {requireValue(false, 'INVALID_CURSOR');}\n requireValue(decoded && decoded.filter === fingerprint, 'CURSOR_SCOPE_MISMATCH');\n requireValue(decoded.revision === revision, 'CURSOR_STALE');\n start = matches.findIndex(i => i.id === decoded.after) + 1; requireValue(start > 0, 'INVALID_CURSOR');\n }\n const progress = progressByParent(state, all);\n const items = matches.slice(start, start + limit).map(item => ({...item, ...(progress.has(item.id) ? {progress: progress.get(item.id)} : {})}));\n return {revision, total: matches.length, items, ...(start + items.length < matches.length ? {\n nextCursor: JSON.stringify({revision, after: items.at(-1)!.id, filter: fingerprint}),\n } : {})};\n}\nfunction order(a: KanbanItemSummary, b: KanbanItemSummary): number {\n return a.planning.priority - b.planning.priority || a.createdAt - b.createdAt || a.id.localeCompare(b.id);\n}\nfunction matchesQuery(item: KanbanItemSummary, query: Omit<KanbanItemQuery, 'cursor' | 'limit'>, board: KanbanState['board']): boolean {\n if (item.deletedAt !== undefined && !query.includeDeleted) return false;\n if (query.phase && item.task?.phase !== query.phase) return false;\n if (!matchesView(item, query.view ?? 'ready')) return false;\n for (const field of ['area', 'milestone', 'parentId', 'kind'] as const) if (query[field] !== undefined && item.planning[field] !== query[field]) return false;\n if (query.reference && !item.externalRefs?.some(r => r.system === query.reference!.system && r.id === query.reference!.id)) return false;\n if (query.sessionId && !item.sessionIds.includes(query.sessionId)) return false;\n if (query.search && !`${kanbanReference(board, item)} ${item.id} ${item.title} ${item.planning.area ?? ''}`.toLowerCase().includes(query.search.toLowerCase())) return false;\n return true;\n}\nfunction matchesView(item: KanbanItemSummary, view: KanbanItemQuery['view']): boolean {\n if (view === 'archive') return item.archivedAt !== undefined;\n if (view === 'all') return true;\n if (item.archivedAt !== undefined) return false;\n if (view === 'in-progress') return item.status === 'claimed' || item.status === 'review';\n if (view === 'closed') return terminal(item);\n return item.status === ({ready: 'open', backlog: 'backlog', review: 'review', proposed: 'proposed'} as Record<string, string>)[view!];\n}\nexport function overview(state: KanbanState, now: number, items = state.board.items.map(summary)): KanbanOverview {\n items = items.filter(item => item.deletedAt === undefined);\n const count = (status: string) => items.filter(i => i.status === status).length;\n const age = state.board.policy.backlogReviewMs;\n return {revision: state.board.revision, visible: items.length, active: items.filter(i => !terminal(i)).length, archived: state.archiveIndex?.length ?? 0, ready: count('open'),\n inProgress: count('claimed') + count('review'), backlog: count('backlog'), proposed: count('proposed'),\n closed: count('completed') + count('cancelled'), dueForReview: age ? items.filter(i => i.status === 'backlog' && now - i.updatedAt >= age).length : 0,\n limits: limits(state)};\n}\n\nfunction progressByParent(state: KanbanState, all: KanbanItemSummary[]): Map<string, NonNullable<KanbanItemSummary['progress']>> {\n const byId = new Map(all.map(i => [i.id, i]));\n const result = new Map<string, NonNullable<KanbanItemSummary['progress']>>();\n for (const item of all.filter(i => executable(state.board, i))) {\n let parent = item.planning.parentId; const seen = new Set<string>();\n while (parent && !seen.has(parent)) {\n seen.add(parent); const progress = result.get(parent) ?? {total: 0, completed: 0, cancelled: 0, inProgress: 0};\n progress.total++; if (item.status === 'completed') progress.completed++; if (item.status === 'cancelled') progress.cancelled++;\n if (item.status === 'claimed' || item.status === 'review') progress.inProgress++;\n result.set(parent, progress); parent = byId.get(parent)?.planning.parentId;\n }\n }\n return result;\n}\n","import {boardControlPhase} from './contracts/board-control';\nimport {projectKanbanTask} from './contracts/task-projection';\nimport {resolveReference} from './references';\nimport {suggestFromState, suggestionPage, validateSuggestionQuery} from './suggestions';\nimport {queryRecords} from './project-records';\nimport { randomUUID } from './utils';\nimport type { KanbanBoard, KanbanRequest, KanbanService, KanbanItemQuery, KanbanBoardInput } from './contracts';\nimport { KanbanError, type KanbanModuleOptions, type KanbanState } from './ports';\nimport { identity, requireValue } from './rules';\nimport {createBoardState} from './board';\nimport {normalizeActor, principal, principalKey, sameOwner} from './identity';\nimport {queryItems, overview} from './queries';\nimport {viewFromState} from './storage-codec';\nimport { reduce, related } from './reducer';\n\n/** Optional host-owned service; no timer or model calls are started implicitly. */\nexport function createKanbanModule(options: KanbanModuleOptions): KanbanModuleHandle { return new KanbanModule(options); }\nexport interface KanbanModuleHandle extends KanbanService {quiesce(): Promise<void>; dispose(): Promise<void>}\nclass KanbanModule implements KanbanService {\n private stopping = false;\n private readonly pending = new Set<Promise<unknown>>();\n async quiesce(): Promise<void> {this.stopping = true; await Promise.allSettled([...this.pending]);}\n async dispose(): Promise<void> {await this.quiesce();}\n private readonly now;\n private readonly id;\n private readonly actor;\n constructor(private readonly options: KanbanModuleOptions) {\n this.now = options.now ?? Date.now; this.id = options.id ?? randomUUID;\n this.actor = normalizeActor(options.actor);\n }\n workflow = (boardId: string) => this.guard(this.id(), boardId, 'workflow', async () => structuredClone((await this.readView(boardId)).state.workflow ?? {plans:{},dispatches:{},ready:[],completedPlans:[]}));\n resolve = (reference: string) => this.guard(this.id(), undefined, 'resolve', () => resolveReference(reference, this.options.store, id => this.readView(id)));\n suggest = (boardId: string, query: import('./contracts').KanbanSuggestionQuery) => this.guard(this.id(), boardId, 'suggest', async () => {\n const snapshot = structuredClone(query), limit = validateSuggestionQuery(snapshot), view = await this.readView(boardId), state = view.state;\n const suggestions = () => suggestFromState(state, snapshot, [...view.items, ...(state.archiveIndex ?? [])], view.records);\n if (!this.options.suggestions) return suggestions();\n const rows = await this.options.suggestions(structuredClone(state.board), snapshot.kind, snapshot.search?.trim() ?? '', limit + 1);\n if (rows === undefined) return suggestions();\n const known = suggestions().items.filter(row => !rows.some(entry => entry.id === row.id));\n return suggestionPage(state.board.revision, [...rows, ...known], snapshot);\n });\n records = (boardId: string, query?: import('./contracts').KanbanRecordQuery) => this.guard(this.id(), boardId, 'records', async () => {const view = await this.readView(boardId); return structuredClone(queryRecords(view.state, query, view.records));});\n record = (boardId: string, recordId: string) => this.guard(this.id(), boardId, 'record', async () => {\n identity(recordId); const record = (await this.readState(boardId)).records?.find(record => record.id === recordId);\n requireValue(record, 'RECORD_NOT_FOUND'); return structuredClone(record);\n });\n currentPrincipal = async () => structuredClone(principal(this.actor));\n create = (input: KanbanBoardInput): Promise<KanbanBoard> => {\n const snapshot = structuredClone(input);\n return this.guard(this.id(), snapshot.id, 'create', async () => {\n const initial = createBoardState(snapshot, this.actor, this.now()), board = initial.board;\n await this.authorize(board, 'create');\n const state = await this.options.store.update(board.id, `create:${board.id}`, JSON.stringify({ snapshot, actor: this.actor }), previous => {\n requireValue(!previous, 'BOARD_EXISTS'); return initial;\n });\n return structuredClone(state.board);\n });\n };\n read = (boardId: string): Promise<KanbanBoard> => this.guard(this.id(), boardId, 'read',\n async () => structuredClone((await this.readState(boardId)).board));\n catalog = () => this.guard(this.id(), undefined, 'catalog', async () => {\n const boards: import('./contracts').KanbanBoardSummary[] = [];\n for (const id of await this.options.store.ids()) {\n try {const view = await this.readView(id); if (view.state.board.deletedAt !== undefined) continue; boards.push({...view.state.board, executionPhase: boardControlPhase({...view.state.board, items: view.items}), items: view.items.filter(item => item.deletedAt === undefined).map(({id, title, number}) => ({id, title, ...(number === undefined ? {} : {number})}))});}\n catch (error) {if (!(error instanceof KanbanError) || error.code !== 'FORBIDDEN') throw error;}\n }\n return structuredClone(boards);\n });\n list = (): Promise<KanbanBoard[]> => this.guard(this.id(), undefined, 'list', async () => {\n const boards: KanbanBoard[] = [];\n for (const boardId of await this.options.store.ids()) {\n try { const board = (await this.readState(boardId)).board; if (board.deletedAt === undefined) boards.push(structuredClone(board)); }\n catch (error) { if (!(error instanceof KanbanError) || error.code !== 'FORBIDDEN') throw error; }\n }\n return boards;\n });\n execute = (boardId: string, input: KanbanRequest): Promise<KanbanBoard> => this.guard(input.operationId, boardId, `execute:${input.command.type}`, async () => {\n const request = structuredClone(input); identity(request.operationId);\n const state = await this.readState(boardId);\n await this.authorize(state.board, request.command.type, request.command);\n requireValue(state.board.deletedAt === undefined, 'BOARD_DELETED');\n if (request.command.type === 'delete-board') await this.options.verifyDeletion?.(structuredClone(state.board));\n await this.options.verifyLifecycle?.(structuredClone(state.board), request.command);\n await this.verifyRelease(state.board, request.command);\n const verifyStage = request.command.type === 'observe-execution' && request.command.outcome === 'succeeded' ? 'observe'\n : request.command.type === 'accept-execution' && request.command.accept ? 'accept' : undefined;\n if (verifyStage && 'dispatchId' in request.command) {\n const dispatch = state.workflow?.dispatches[request.command.dispatchId]; requireValue(dispatch, 'DISPATCH_NOT_FOUND');\n const outputs = request.command.type === 'observe-execution' ? request.command.outputs : dispatch.outputs;\n if (outputs?.length) requireValue(await this.options.verifyOutputs?.({stage: verifyStage, board: state.board, itemId: dispatch.itemId,\n dispatchId: dispatch.id, outputs: structuredClone(outputs)}), 'OUTPUT_VERIFICATION_REQUIRED');\n }\n const restore = request.command.type === 'restore-item' ? await this.options.store.archived(boardId, request.command.itemId) : undefined;\n const result = await this.options.store.update(boardId, request.operationId, JSON.stringify({ actor: this.actor, request }), current => {\n requireValue(current && current.board.revision === state.board.revision, 'REVISION_CONFLICT');\n requireValue(current.board.revision === request.expectedRevision, 'REVISION_CONFLICT');\n if (restore) current.restore = restore;\n return reduce(current, request.command, this.actor, request.operationId, this.now(), this.id());\n });\n await this.publishNotifications(boardId, request.operationId);\n return structuredClone(result.board);\n });\n events = (boardId: string, after = 0, limit = 100) => this.guard(this.id(), boardId, 'events', async () => {\n requireValue(Number.isSafeInteger(after) && after >= 0 && Number.isSafeInteger(limit) && limit > 0 && limit <= 500, 'INVALID_CURSOR');\n const {state} = await this.readView(boardId);\n return this.options.store.events(boardId, after, limit, state.sequence);\n });\n query = (boardId: string, query?: KanbanItemQuery) => this.guard(this.id(), boardId, 'query', async () => {const view = await this.readView(boardId); return structuredClone(queryItems(view.state, query, [...view.items, ...(view.state.archiveIndex ?? [])], this.now()));});\n overview = (boardId: string) => this.guard(this.id(), boardId, 'overview', async () => {const view = await this.readView(boardId); return overview(view.state, this.now(), view.items);});\n item = (boardId: string, itemId: string) => this.guard(this.id(), boardId, 'item', async () => {\n identity(itemId); const state = await this.readState(boardId), item = state.board.items.find(i => i.id === itemId);\n if (item) return {item: structuredClone(item),task:projectKanbanTask(item,state.workflow,this.now(),[...state.board.items,...state.archiveIndex??[]])};\n requireValue(state.archiveIndex?.some(i => i.id === itemId), 'ITEM_NOT_FOUND');\n const record = await this.options.store.archived(boardId, itemId); requireValue(record, 'REVISION_CONFLICT');\n return {item: structuredClone(record.item), task:projectKanbanTask(record.item,state.workflow,this.now(),state.archiveIndex), archive: {archivedAt: record.archivedAt, reason: record.reason}};\n });\n related = (sessionId: string): Promise<KanbanBoard[]> => this.guard(this.id(), undefined, 'related', async () => {\n identity(sessionId); const result: KanbanBoard[] = [];\n for (const board of await this.list()) {\n const state = await this.readState(board.id);\n if (related(board).includes(sessionId) || state.records?.some(record => record.sources.some(source => source.sessionId === sessionId)) || state.archiveIndex?.some(i => i.sessionIds.includes(sessionId))) result.push(board);\n }\n return result;\n });\n scan = (): Promise<void> => this.guard(this.id(), undefined, 'scan', async () => {\n const errors: unknown[] = [];\n for (const id of await this.options.store.ids()) {\n try {\n const board = (await this.readState(id)).board;\n if (board.deletedAt !== undefined) {await this.publishNotifications(id,this.id()); continue;}\n await this.execute(board.id, { operationId: this.id(), expectedRevision: board.revision, command: { type: 'scan' } });\n }\n catch (error) {\n if (!(error instanceof KanbanError) || !['REVISION_CONFLICT','FORBIDDEN'].includes(error.code)) errors.push(error);\n }\n }\n if (errors.length) throw new AggregateError(errors, 'KANBAN_SCAN_FAILED');\n });\n private async verifyRelease(board: KanbanBoard, command: KanbanRequest['command']): Promise<void> {\n if (command.type !== 'release-item') return;\n const item = board.items.find(i => i.id === command.itemId); requireValue(item?.owner && item.owner.token === command.token, 'OWNER_MISMATCH');\n const own = sameOwner(item.owner, this.actor), actor = principal(this.actor);\n const coordinator = board.members?.some(m => principalKey(m) === principalKey(actor) && m.roles?.includes('coordinator'));\n requireValue(own || coordinator, 'OWNER_MISMATCH');\n if (!(own && actor.kind === 'human')) requireValue(await this.options.verifyRelease?.({actor: this.actor, board: structuredClone(board), item: structuredClone(item)}), 'EXECUTION_NOT_SETTLED');\n }\n private async publishNotifications(boardId: string, operationId: string): Promise<void> {\n if (!this.options.onCommitted) return;\n const started = this.now();\n try {await this.options.onCommitted(boardId, this, this.now()); this.log(operationId, boardId, 'notify', started, 'success');}\n catch (error) {this.log(operationId, boardId, 'notify', started, 'failure', safeCode(error, 'NOTIFICATION_PROJECTION_FAILED'));}\n }\n private async readView(boardId: string) {\n identity(boardId);\n if (!this.options.store.view) return viewFromState(await this.readState(boardId));\n const view = await this.options.store.view(boardId); requireValue(view, 'BOARD_NOT_FOUND');\n await this.authorize(view.state.board, 'read'); return view;\n }\n private async readState(boardId: string): Promise<KanbanState> {\n identity(boardId); const state = await this.options.store.read(boardId); requireValue(state, 'BOARD_NOT_FOUND');\n await this.authorize(state.board, 'read'); return state;\n }\n private authorize(board: KanbanBoard, action: Parameters<KanbanModuleOptions['authorize']>[0]['action'], command?: KanbanRequest['command']) {\n return this.options.authorize({ actor: structuredClone(this.actor), board: structuredClone(board), action, command: structuredClone(command) });\n }\n private async guard<T>(operationId: string, boardId: string | undefined, stage: string, run: () => Promise<T>): Promise<T> {\n const start = this.now();\n if (this.stopping) {this.log(operationId,boardId,stage,start,'failure','SERVICE_STOPPING'); throw new KanbanError('SERVICE_STOPPING');}\n const operation = Promise.resolve().then(run); this.pending.add(operation);\n try { const result = await operation; this.log(operationId, boardId, stage, start, 'success'); return result; }\n catch (error) {\n this.log(operationId, boardId, stage, start, 'failure', safeCode(error, 'PORT_FAILURE')); throw error;\n } finally {this.pending.delete(operation);}\n }\n private log(operationId: string, boardId: string | undefined, stage: string, start: number, result: 'success' | 'failure', code?: string): void {\n try { this.options.log({ operationId, boardId, stage, result, code, durationMs: this.now() - start }); }\n catch { /* Diagnostics cannot undo a commit. */ }\n }\n}\n\nfunction safeCode(error: unknown, fallback: string): string {\n const code = (error as {code?: unknown})?.code;\n return typeof code === 'string' && /^[A-Z][A-Z0-9_]{0,79}$/.test(code) ? code : fallback;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,eAAsB,iBAAiB,WAAmB,OAAoB,MAA+E;AACzJ,eAAa,OAAO,cAAc,YAAY,UAAU,UAAU,KAAK,mBAAmB;AAC1F,QAAM,QAAQ,sDAAsD,KAAK,UAAU,KAAK,CAAC;AACzF,eAAa,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,MAAM,WAAS,UAAU,UAAa,OAAO,cAAc,OAAO,KAAK,CAAC,CAAC,GAAG,mBAAmB;AACpJ,QAAM,KAAK,MAAM,MAAM,UAAU,OAAO,MAAM,CAAC,CAA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