@critical-path/core 0.20.1 → 0.21.0
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/CHANGELOG.md +20 -0
- package/README.md +41 -0
- package/dist/domain/entities.d.ts +4 -0
- package/dist/domain/entities.d.ts.map +1 -1
- package/dist/domain/entities.js +56 -0
- package/dist/domain/entities.js.map +1 -1
- package/dist/domain/metrics.d.ts.map +1 -1
- package/dist/domain/metrics.js +2 -1
- package/dist/domain/metrics.js.map +1 -1
- package/dist/domain/task-duration.test.js +161 -0
- package/dist/domain/task-duration.test.js.map +1 -1
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/index.js +113 -21
- package/dist/engine/index.js.map +1 -1
- package/dist/status.test.js +97 -1
- package/dist/status.test.js.map +1 -1
- package/dist/store/sqlite.d.ts.map +1 -1
- package/dist/store/sqlite.js +22 -7
- package/dist/store/sqlite.js.map +1 -1
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/fractional-index.d.ts +50 -0
- package/dist/utils/fractional-index.d.ts.map +1 -0
- package/dist/utils/fractional-index.js +230 -0
- package/dist/utils/fractional-index.js.map +1 -0
- package/dist/utils/fractional-index.test.d.ts +2 -0
- package/dist/utils/fractional-index.test.d.ts.map +1 -0
- package/dist/utils/fractional-index.test.js +151 -0
- package/dist/utils/fractional-index.test.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/key.d.ts +5 -0
- package/dist/utils/key.d.ts.map +1 -1
- package/dist/utils/key.js +10 -0
- package/dist/utils/key.js.map +1 -1
- package/dist/utils/key.test.js +18 -1
- package/dist/utils/key.test.js.map +1 -1
- package/dist/utils/mentions.d.ts +13 -5
- package/dist/utils/mentions.d.ts.map +1 -1
- package/dist/utils/mentions.js +52 -16
- package/dist/utils/mentions.js.map +1 -1
- package/dist/utils/mentions.test.js +32 -1
- package/dist/utils/mentions.test.js.map +1 -1
- package/dist/utils/status.d.ts +80 -1
- package/dist/utils/status.d.ts.map +1 -1
- package/dist/utils/status.js +194 -0
- package/dist/utils/status.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/entities.ts +56 -0
- package/src/domain/metrics.ts +2 -1
- package/src/domain/task-duration.test.ts +184 -0
- package/src/engine/index.ts +121 -28
- package/src/status.test.ts +130 -2
- package/src/store/sqlite.ts +28 -7
- package/src/types/index.ts +7 -0
- package/src/utils/fractional-index.test.ts +191 -0
- package/src/utils/fractional-index.ts +260 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/key.test.ts +22 -1
- package/src/utils/key.ts +11 -0
- package/src/utils/mentions.test.ts +37 -1
- package/src/utils/mentions.ts +58 -16
- package/src/utils/status.ts +247 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { extractMentions, parseMentionSegments } from './mentions.js';
|
|
2
|
+
import { extractMentions, parseMentionSegments, stripMarkdownCode } from './mentions.js';
|
|
3
3
|
|
|
4
4
|
describe('mentions utility', () => {
|
|
5
5
|
describe('extractMentions', () => {
|
|
@@ -37,6 +37,42 @@ describe('mentions utility', () => {
|
|
|
37
37
|
const text = 'Check with @turquoise. Then ping @john.doe! Also ask @coordinator, and @"Jane Doe".';
|
|
38
38
|
expect(extractMentions(text)).toEqual(['turquoise', 'john.doe', 'coordinator', 'Jane Doe']);
|
|
39
39
|
});
|
|
40
|
+
|
|
41
|
+
it('suppresses mentions inside fenced code blocks and inline backticks (UCH-128, UCH-138)', () => {
|
|
42
|
+
const markdown = `
|
|
43
|
+
Hey @alice, please review this test output:
|
|
44
|
+
\`\`\`ts
|
|
45
|
+
import { describe } from '@vitest/runner';
|
|
46
|
+
// mention in code comment: @bob
|
|
47
|
+
const handler = () => '@charlie';
|
|
48
|
+
\`\`\`
|
|
49
|
+
Also do not match \`@david\` in inline backticks or ~~~@eva~~~ in tilde fences.
|
|
50
|
+
Only real mentions like @frank should match.
|
|
51
|
+
`;
|
|
52
|
+
expect(extractMentions(markdown)).toEqual(['alice', 'frank']);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('suppresses mentions inside HTML <pre> and <code> blocks', () => {
|
|
56
|
+
const html = 'Hello @alice! Check <pre>npm i @types/node</pre> and <code>@bob</code>. Thanks @charlie!';
|
|
57
|
+
expect(extractMentions(html)).toEqual(['alice', 'charlie']);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('suppresses handles inside URLs and markdown link destinations', () => {
|
|
61
|
+
const text = 'Visit https://github.com/@org/repo and [profile](https://example.com/@jack) then ping @jack';
|
|
62
|
+
expect(extractMentions(text)).toEqual(['jack']);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('preserves rich text HTML mention nodes while ignoring attributes', () => {
|
|
66
|
+
const html = '<p>Assigned to <span data-type="mention" data-label="Jane Doe" data-mention-suggestion-char="@">@Jane Doe</span> and ping @coordinator</p>';
|
|
67
|
+
expect(extractMentions(html)).toEqual(['Jane Doe', 'coordinator']);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('stripMarkdownCode', () => {
|
|
72
|
+
it('strips code blocks, tilde blocks, inline backticks, pre and code tags', () => {
|
|
73
|
+
const raw = 'Before ```code @foo``` and `inline @bar` and <pre>pre @baz</pre> and <code>c @qux</code> after @real';
|
|
74
|
+
expect(stripMarkdownCode(raw)).toBe('Before and and and after @real');
|
|
75
|
+
});
|
|
40
76
|
});
|
|
41
77
|
|
|
42
78
|
describe('parseMentionSegments', () => {
|
package/src/utils/mentions.ts
CHANGED
|
@@ -6,29 +6,72 @@ export interface MentionSegment {
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Regex matching mentions:
|
|
9
|
-
* - Quoted mentions: @"Jane Doe"
|
|
10
|
-
* - Standard
|
|
11
|
-
*
|
|
9
|
+
* - Quoted mentions: @"Jane Doe", "Jane Doe"
|
|
10
|
+
* - Standard handles: @planner, @user-1, @john.smith
|
|
11
|
+
* Unquoted handles exclude trailing punctuation (e.g. @turquoise. matches handle "turquoise" without the dot).
|
|
12
12
|
*/
|
|
13
|
-
export const MENTION_REGEX =
|
|
13
|
+
export const MENTION_REGEX =
|
|
14
|
+
/(?:^|[\s>(*_"';\\/[\]{}~`:]|"|>|<|&)@(?:"([^"]+)"|"([^&]+)"|([a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+)*))/g;
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
17
|
+
* Strips code blocks and inline code from markdown or HTML content:
|
|
18
|
+
* - Fenced code blocks: ```...``` and ~~~...~~~
|
|
19
|
+
* - Inline backtick code: `...`
|
|
20
|
+
* - HTML code/pre tags: <pre>...</pre>, <code>...</code>
|
|
21
|
+
* Used to avoid false-positive mention parsing within code snippets, terminal logs, or stack traces.
|
|
22
|
+
*/
|
|
23
|
+
export function stripMarkdownCode(content: string): string {
|
|
24
|
+
if (!content || typeof content !== 'string') return '';
|
|
25
|
+
return content
|
|
26
|
+
.replace(/```[\s\S]*?```/g, '')
|
|
27
|
+
.replace(/~~~[\s\S]*?~~~/g, '')
|
|
28
|
+
.replace(/<pre[\s\S]*?<\/pre>/gi, '')
|
|
29
|
+
.replace(/<code[\s\S]*?<\/code>/gi, '')
|
|
30
|
+
.replace(/`[^`\n]*`/g, '');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Extracts unique mention handles from a text string, ignoring trailing punctuation,
|
|
35
|
+
* code blocks or inline code snippets, URLs, markdown link destinations, and pre-existing HTML mention nodes.
|
|
18
36
|
* Preserves the order of their first appearance.
|
|
19
37
|
*/
|
|
20
38
|
export function extractMentions(content: string): string[] {
|
|
21
39
|
if (!content || typeof content !== 'string') return [];
|
|
22
40
|
|
|
41
|
+
// Normalize rich text mention nodes (e.g. from TipTap or custom mention spans)
|
|
42
|
+
const normalizedMentionNodes = content.replace(
|
|
43
|
+
/<span\b[^>]*\b(?:data-type=["']mention["']|class=["'][^"']*pixerate-mention-node[^"']*["'])[^>]*>([\s\S]*?)<\/span>/gi,
|
|
44
|
+
(match, inner) => {
|
|
45
|
+
const labelMatch = match.match(/\bdata-label=["']([^"']+)["']/i);
|
|
46
|
+
if (labelMatch) {
|
|
47
|
+
const val = labelMatch[1].trim();
|
|
48
|
+
return val.includes(' ') ? ` @"${val}" ` : ` @${val} `;
|
|
49
|
+
}
|
|
50
|
+
const idMatch = match.match(/\bdata-id=["']([^"']+)["']/i);
|
|
51
|
+
if (idMatch) {
|
|
52
|
+
const val = idMatch[1].trim();
|
|
53
|
+
return val.includes(' ') ? ` @"${val}" ` : ` @${val} `;
|
|
54
|
+
}
|
|
55
|
+
return ` ${inner} `;
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const cleanContent = stripMarkdownCode(normalizedMentionNodes);
|
|
60
|
+
// Strip URLs and markdown link destinations so @package or @handles in URLs are not extracted as mentions
|
|
61
|
+
const withoutUrls = cleanContent
|
|
62
|
+
.replace(/(?:https?|ftp|file):\/\/[^\s<>()]+/gi, '')
|
|
63
|
+
.replace(/\]\([^)]*\)/g, ']');
|
|
64
|
+
// Strip remaining HTML tags
|
|
65
|
+
const textOnly = withoutUrls.replace(/<[^>]+>/g, ' ');
|
|
66
|
+
|
|
23
67
|
const mentions: string[] = [];
|
|
24
68
|
const seen = new Set<string>();
|
|
25
69
|
|
|
26
|
-
// Reset regex lastIndex
|
|
27
70
|
const regex = new RegExp(MENTION_REGEX.source, 'g');
|
|
28
71
|
let match: RegExpExecArray | null;
|
|
29
72
|
|
|
30
|
-
while ((match = regex.exec(
|
|
31
|
-
const handle = match[1] ?? match[2];
|
|
73
|
+
while ((match = regex.exec(textOnly)) !== null) {
|
|
74
|
+
const handle = (match[1] ?? match[2] ?? match[3] ?? '').trim();
|
|
32
75
|
if (handle && !seen.has(handle)) {
|
|
33
76
|
seen.add(handle);
|
|
34
77
|
mentions.push(handle);
|
|
@@ -52,12 +95,11 @@ export function parseMentionSegments(content: string): MentionSegment[] {
|
|
|
52
95
|
|
|
53
96
|
while ((match = regex.exec(content)) !== null) {
|
|
54
97
|
const fullMatch = match[0];
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const matchStart = match.index + leadingWhitespace.length;
|
|
98
|
+
const atIndex = fullMatch.indexOf('@');
|
|
99
|
+
const prefix = atIndex > 0 ? fullMatch.slice(0, atIndex) : '';
|
|
100
|
+
const mentionToken = fullMatch.slice(atIndex);
|
|
101
|
+
const handle = match[1] ?? match[2] ?? match[3];
|
|
102
|
+
const matchStart = match.index + prefix.length;
|
|
61
103
|
|
|
62
104
|
// Push text before this mention if any
|
|
63
105
|
if (matchStart > lastIndex) {
|
|
@@ -74,7 +116,7 @@ export function parseMentionSegments(content: string): MentionSegment[] {
|
|
|
74
116
|
handle
|
|
75
117
|
});
|
|
76
118
|
|
|
77
|
-
lastIndex =
|
|
119
|
+
lastIndex = matchStart + mentionToken.length;
|
|
78
120
|
}
|
|
79
121
|
|
|
80
122
|
// Push any remaining text after the last match
|
package/src/utils/status.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
StatusDefinition,
|
|
4
4
|
SemanticStatus,
|
|
5
5
|
TaskDerivedStatus,
|
|
6
|
+
Workflow
|
|
6
7
|
} from '../types/index.js';
|
|
7
8
|
|
|
8
9
|
export const DEFAULT_STATUS_DEFINITIONS: Record<string, StatusDefinition> = {
|
|
@@ -170,3 +171,249 @@ export function deriveTaskLifecycleState(
|
|
|
170
171
|
isCancelled
|
|
171
172
|
};
|
|
172
173
|
}
|
|
174
|
+
|
|
175
|
+
export type TaskLike = {
|
|
176
|
+
status?: string | null;
|
|
177
|
+
semanticStatus?: SemanticStatus | string | null;
|
|
178
|
+
trashed?: boolean | null;
|
|
179
|
+
trashedAt?: string | null;
|
|
180
|
+
archived?: boolean | null;
|
|
181
|
+
archivedAt?: string | null;
|
|
182
|
+
isDraft?: boolean | null;
|
|
183
|
+
assigneeId?: string | null;
|
|
184
|
+
assignees?: Array<{ id?: string; name?: string } | string> | null;
|
|
185
|
+
customFields?: Record<string, unknown> | null;
|
|
186
|
+
[key: string]: unknown;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Extracts a list of StatusDefinitions from either a Workflow or an array of definitions.
|
|
191
|
+
*/
|
|
192
|
+
export function extractStatusDefinitions(
|
|
193
|
+
workflowOrStatuses?: Workflow | StatusDefinition[] | unknown
|
|
194
|
+
): StatusDefinition[] | undefined {
|
|
195
|
+
if (!workflowOrStatuses) return undefined;
|
|
196
|
+
if (Array.isArray(workflowOrStatuses)) {
|
|
197
|
+
return workflowOrStatuses as StatusDefinition[];
|
|
198
|
+
}
|
|
199
|
+
if (typeof workflowOrStatuses === 'object' && workflowOrStatuses !== null) {
|
|
200
|
+
const statuses = (workflowOrStatuses as any).statuses;
|
|
201
|
+
if (Array.isArray(statuses)) {
|
|
202
|
+
return statuses as StatusDefinition[];
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Checks whether a task is flagged as a draft outside the active workflow.
|
|
210
|
+
*/
|
|
211
|
+
export function isDraftTask(task: TaskLike | null | undefined): boolean {
|
|
212
|
+
if (!task) return false;
|
|
213
|
+
return Boolean(task.isDraft);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Checks whether a task is archived.
|
|
218
|
+
*/
|
|
219
|
+
export function isArchivedTask(task: TaskLike | null | undefined): boolean {
|
|
220
|
+
if (!task) return false;
|
|
221
|
+
return (
|
|
222
|
+
Boolean(task.archived) ||
|
|
223
|
+
Boolean(task.archivedAt) ||
|
|
224
|
+
task.status === 'archived' ||
|
|
225
|
+
Boolean((task.customFields as any)?.isArchived)
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Checks whether a task is soft-deleted / trashed.
|
|
231
|
+
*/
|
|
232
|
+
export function isTrashedTask(task: TaskLike | null | undefined): boolean {
|
|
233
|
+
if (!task) return false;
|
|
234
|
+
return (
|
|
235
|
+
Boolean(task.trashed) ||
|
|
236
|
+
Boolean(task.trashedAt) ||
|
|
237
|
+
task.status === 'trashed' ||
|
|
238
|
+
Boolean((task.customFields as any)?.isTrashed)
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Checks whether a task is trashed, archived, or soft-deleted.
|
|
244
|
+
*/
|
|
245
|
+
export function isTrashedOrArchivedTask(task: TaskLike | null | undefined): boolean {
|
|
246
|
+
if (!task) return false;
|
|
247
|
+
return isTrashedTask(task) || isArchivedTask(task);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Determines whether a task is part of the legitimate project workflow.
|
|
252
|
+
* A workflow task is not trashed, not archived, and not a draft.
|
|
253
|
+
*/
|
|
254
|
+
export function isWorkflowTask(task: TaskLike | null | undefined): boolean {
|
|
255
|
+
if (!task) return false;
|
|
256
|
+
return !isTrashedTask(task) && !isArchivedTask(task) && !isDraftTask(task);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export const isTaskDraft = isDraftTask;
|
|
260
|
+
export const isTaskArchived = isArchivedTask;
|
|
261
|
+
export const isTaskTrashed = isTrashedTask;
|
|
262
|
+
export const isTaskTrashedOrArchived = isTrashedOrArchivedTask;
|
|
263
|
+
export const isTaskWorkflow = isWorkflowTask;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Resolves the canonical SemanticStatus for a task based on the project's workflow or default heuristics.
|
|
267
|
+
*/
|
|
268
|
+
export function getTaskSemanticStatus(
|
|
269
|
+
task: TaskLike | null | undefined,
|
|
270
|
+
workflowOrStatuses?: Workflow | StatusDefinition[] | unknown
|
|
271
|
+
): SemanticStatus {
|
|
272
|
+
if (!task) return 'not_started';
|
|
273
|
+
|
|
274
|
+
const customDefs = extractStatusDefinitions(workflowOrStatuses);
|
|
275
|
+
|
|
276
|
+
// 1. Look up the task's status in custom workflow definitions
|
|
277
|
+
if (task.status) {
|
|
278
|
+
if (customDefs) {
|
|
279
|
+
const match = customDefs.find((s) => s.key === task.status);
|
|
280
|
+
if (match?.category) return match.category;
|
|
281
|
+
if (match) {
|
|
282
|
+
if ((match as any).completionState === 'done') {
|
|
283
|
+
return (match as any).isCancelled ? 'canceled' : 'completed';
|
|
284
|
+
}
|
|
285
|
+
if ((match as any).executionState === 'active') {
|
|
286
|
+
return 'in_progress';
|
|
287
|
+
}
|
|
288
|
+
if ((match as any).completionState === 'not_done') {
|
|
289
|
+
return 'not_started';
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// 2. Default status definition lookup from @critical-path/core for standard statuses
|
|
295
|
+
const normalizedKey = task.status.toLowerCase().replace(/[-\s]+/g, '_');
|
|
296
|
+
const defaultDef =
|
|
297
|
+
DEFAULT_STATUS_DEFINITIONS[task.status] || DEFAULT_STATUS_DEFINITIONS[normalizedKey];
|
|
298
|
+
if (defaultDef?.category) {
|
|
299
|
+
return defaultDef.category;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// 3. If task has an explicit valid semanticStatus (for custom/unknown status), use it
|
|
304
|
+
if (task.semanticStatus) {
|
|
305
|
+
const raw = String(task.semanticStatus).toLowerCase();
|
|
306
|
+
if (
|
|
307
|
+
raw === 'completed' ||
|
|
308
|
+
raw === 'in_progress' ||
|
|
309
|
+
raw === 'not_started' ||
|
|
310
|
+
raw === 'canceled' ||
|
|
311
|
+
raw === 'cancelled'
|
|
312
|
+
) {
|
|
313
|
+
return raw === 'cancelled' ? 'canceled' : (raw as SemanticStatus);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// 4. Fallback to resolveStatusDefinition for general fallback or 'not_started'
|
|
318
|
+
if (task.status) {
|
|
319
|
+
const def = resolveStatusDefinition(task.status, customDefs);
|
|
320
|
+
if (def?.category) {
|
|
321
|
+
return def.category;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return 'not_started';
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Determines whether a task has reached completion in its lifecycle.
|
|
330
|
+
*/
|
|
331
|
+
export function isTaskCompleted(
|
|
332
|
+
task: TaskLike | null | undefined,
|
|
333
|
+
workflowOrStatuses?: Workflow | StatusDefinition[] | unknown
|
|
334
|
+
): boolean {
|
|
335
|
+
if (!task) return false;
|
|
336
|
+
return getTaskSemanticStatus(task, workflowOrStatuses) === 'completed';
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export const isTaskDone = isTaskCompleted;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Determines whether a task is actively in progress.
|
|
343
|
+
*/
|
|
344
|
+
export function isTaskInProgress(
|
|
345
|
+
task: TaskLike | null | undefined,
|
|
346
|
+
workflowOrStatuses?: Workflow | StatusDefinition[] | unknown
|
|
347
|
+
): boolean {
|
|
348
|
+
if (!task) return false;
|
|
349
|
+
return getTaskSemanticStatus(task, workflowOrStatuses) === 'in_progress';
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Determines whether a task is pending or not yet started.
|
|
354
|
+
*/
|
|
355
|
+
export function isTaskNotStarted(
|
|
356
|
+
task: TaskLike | null | undefined,
|
|
357
|
+
workflowOrStatuses?: Workflow | StatusDefinition[] | unknown
|
|
358
|
+
): boolean {
|
|
359
|
+
if (!task) return false;
|
|
360
|
+
return getTaskSemanticStatus(task, workflowOrStatuses) === 'not_started';
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Determines whether a task has been canceled or abandoned.
|
|
365
|
+
*/
|
|
366
|
+
export function isTaskCanceled(
|
|
367
|
+
task: TaskLike | null | undefined,
|
|
368
|
+
workflowOrStatuses?: Workflow | StatusDefinition[] | unknown
|
|
369
|
+
): boolean {
|
|
370
|
+
if (!task) return false;
|
|
371
|
+
return getTaskSemanticStatus(task, workflowOrStatuses) === 'canceled';
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Determines whether a task is active in an ongoing project workflow.
|
|
376
|
+
* An active task:
|
|
377
|
+
* 1. Is not trashed or archived.
|
|
378
|
+
* 2. Is not a draft (exists within the active workflow).
|
|
379
|
+
* 3. Has not reached terminal completion ('completed') or terminal abandonment ('canceled').
|
|
380
|
+
*/
|
|
381
|
+
export function isTaskActive(
|
|
382
|
+
task: TaskLike | null | undefined,
|
|
383
|
+
workflowOrStatuses?: Workflow | StatusDefinition[] | unknown
|
|
384
|
+
): boolean {
|
|
385
|
+
if (!task) return false;
|
|
386
|
+
if (isTrashedOrArchivedTask(task)) return false;
|
|
387
|
+
if (isDraftTask(task)) return false;
|
|
388
|
+
const sem = getTaskSemanticStatus(task, workflowOrStatuses);
|
|
389
|
+
return sem !== 'completed' && sem !== 'canceled';
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Checks whether a task currently has no assigned owner.
|
|
394
|
+
*/
|
|
395
|
+
export function isTaskUnassigned(task: TaskLike | null | undefined): boolean {
|
|
396
|
+
if (!task) return true;
|
|
397
|
+
|
|
398
|
+
const rawId = task.assigneeId ? String(task.assigneeId).trim() : '';
|
|
399
|
+
const hasAssigneeId = rawId !== '' && rawId.toLowerCase() !== 'unassigned';
|
|
400
|
+
|
|
401
|
+
const hasValidAssignees =
|
|
402
|
+
Array.isArray(task.assignees) &&
|
|
403
|
+
task.assignees.some((a: any) => {
|
|
404
|
+
if (!a) return false;
|
|
405
|
+
if (typeof a === 'string') {
|
|
406
|
+
const s = a.trim();
|
|
407
|
+
return s !== '' && s.toLowerCase() !== 'unassigned';
|
|
408
|
+
}
|
|
409
|
+
const id = a.id ? String(a.id).trim() : '';
|
|
410
|
+
const name = a.name ? String(a.name).trim() : '';
|
|
411
|
+
return (
|
|
412
|
+
(id !== '' && id.toLowerCase() !== 'unassigned') ||
|
|
413
|
+
(name !== '' && name.toLowerCase() !== 'unassigned')
|
|
414
|
+
);
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
return !hasAssigneeId && !hasValidAssignees;
|
|
418
|
+
}
|
|
419
|
+
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/deliverables.test.ts","./src/index.test.ts","./src/index.ts","./src/status.test.ts","./src/task-state.test.ts","./src/use-case-validation.test.ts","./src/domain/calendar.test.ts","./src/domain/calendar.ts","./src/domain/cpm.test.ts","./src/domain/cpm.ts","./src/domain/custom-fields.ts","./src/domain/ddd.test.ts","./src/domain/entities.ts","./src/domain/events.ts","./src/domain/graph.ts","./src/domain/index.ts","./src/domain/ladder.test.ts","./src/domain/ladder.ts","./src/domain/metrics.test.ts","./src/domain/metrics.ts","./src/domain/task-duration.test.ts","./src/domain/workload.test.ts","./src/domain/workload.ts","./src/engine/index.ts","./src/plugins/index.ts","./src/storage/file-storage.ts","./src/storage/firebase-storage.ts","./src/storage/index.ts","./src/storage/s3.ts","./src/storage/storage.test.ts","./src/store/firebase.test.ts","./src/store/firebase.ts","./src/store/index.ts","./src/store/sqlite.test.ts","./src/store/sqlite.ts","./src/types/index.ts","./src/utils/index.ts","./src/utils/key.test.ts","./src/utils/key.ts","./src/utils/mentions.test.ts","./src/utils/mentions.ts","./src/utils/status.ts","./src/utils/workflow.ts"],"version":"5.9.3"}
|
|
1
|
+
{"root":["./src/deliverables.test.ts","./src/index.test.ts","./src/index.ts","./src/status.test.ts","./src/task-state.test.ts","./src/use-case-validation.test.ts","./src/domain/calendar.test.ts","./src/domain/calendar.ts","./src/domain/cpm.test.ts","./src/domain/cpm.ts","./src/domain/custom-fields.ts","./src/domain/ddd.test.ts","./src/domain/entities.ts","./src/domain/events.ts","./src/domain/graph.ts","./src/domain/index.ts","./src/domain/ladder.test.ts","./src/domain/ladder.ts","./src/domain/metrics.test.ts","./src/domain/metrics.ts","./src/domain/task-duration.test.ts","./src/domain/workload.test.ts","./src/domain/workload.ts","./src/engine/index.ts","./src/plugins/index.ts","./src/storage/file-storage.ts","./src/storage/firebase-storage.ts","./src/storage/index.ts","./src/storage/s3.ts","./src/storage/storage.test.ts","./src/store/firebase.test.ts","./src/store/firebase.ts","./src/store/index.ts","./src/store/sqlite.test.ts","./src/store/sqlite.ts","./src/types/index.ts","./src/utils/fractional-index.test.ts","./src/utils/fractional-index.ts","./src/utils/index.ts","./src/utils/key.test.ts","./src/utils/key.ts","./src/utils/mentions.test.ts","./src/utils/mentions.ts","./src/utils/status.ts","./src/utils/workflow.ts"],"version":"5.9.3"}
|