@critical-path/core 0.36.0 → 0.36.1

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.
Files changed (185) hide show
  1. package/package.json +5 -1
  2. package/CHANGELOG.md +0 -593
  3. package/dist/deliverables.test.d.ts +0 -2
  4. package/dist/deliverables.test.d.ts.map +0 -1
  5. package/dist/deliverables.test.js +0 -232
  6. package/dist/deliverables.test.js.map +0 -1
  7. package/dist/domain/calendar.test.d.ts +0 -2
  8. package/dist/domain/calendar.test.d.ts.map +0 -1
  9. package/dist/domain/calendar.test.js +0 -181
  10. package/dist/domain/calendar.test.js.map +0 -1
  11. package/dist/domain/cpm.test.d.ts +0 -2
  12. package/dist/domain/cpm.test.d.ts.map +0 -1
  13. package/dist/domain/cpm.test.js +0 -166
  14. package/dist/domain/cpm.test.js.map +0 -1
  15. package/dist/domain/ddd.test.d.ts +0 -2
  16. package/dist/domain/ddd.test.d.ts.map +0 -1
  17. package/dist/domain/ddd.test.js +0 -349
  18. package/dist/domain/ddd.test.js.map +0 -1
  19. package/dist/domain/ladder.test.d.ts +0 -2
  20. package/dist/domain/ladder.test.d.ts.map +0 -1
  21. package/dist/domain/ladder.test.js +0 -213
  22. package/dist/domain/ladder.test.js.map +0 -1
  23. package/dist/domain/metrics.test.d.ts +0 -2
  24. package/dist/domain/metrics.test.d.ts.map +0 -1
  25. package/dist/domain/metrics.test.js +0 -252
  26. package/dist/domain/metrics.test.js.map +0 -1
  27. package/dist/domain/task-duration.test.d.ts +0 -2
  28. package/dist/domain/task-duration.test.d.ts.map +0 -1
  29. package/dist/domain/task-duration.test.js +0 -307
  30. package/dist/domain/task-duration.test.js.map +0 -1
  31. package/dist/domain/workload.test.d.ts +0 -2
  32. package/dist/domain/workload.test.d.ts.map +0 -1
  33. package/dist/domain/workload.test.js +0 -261
  34. package/dist/domain/workload.test.js.map +0 -1
  35. package/dist/engine/actor.test.d.ts +0 -2
  36. package/dist/engine/actor.test.d.ts.map +0 -1
  37. package/dist/engine/actor.test.js +0 -54
  38. package/dist/engine/actor.test.js.map +0 -1
  39. package/dist/engine/authorization.test.d.ts +0 -2
  40. package/dist/engine/authorization.test.d.ts.map +0 -1
  41. package/dist/engine/authorization.test.js +0 -154
  42. package/dist/engine/authorization.test.js.map +0 -1
  43. package/dist/engine/cascade.test.d.ts +0 -2
  44. package/dist/engine/cascade.test.d.ts.map +0 -1
  45. package/dist/engine/cascade.test.js +0 -99
  46. package/dist/engine/cascade.test.js.map +0 -1
  47. package/dist/engine/config.test.d.ts +0 -2
  48. package/dist/engine/config.test.d.ts.map +0 -1
  49. package/dist/engine/config.test.js +0 -46
  50. package/dist/engine/config.test.js.map +0 -1
  51. package/dist/engine/entity-events.test.d.ts +0 -2
  52. package/dist/engine/entity-events.test.d.ts.map +0 -1
  53. package/dist/engine/entity-events.test.js +0 -61
  54. package/dist/engine/entity-events.test.js.map +0 -1
  55. package/dist/index.test.d.ts +0 -2
  56. package/dist/index.test.d.ts.map +0 -1
  57. package/dist/index.test.js +0 -429
  58. package/dist/index.test.js.map +0 -1
  59. package/dist/plugins/plugins.test.d.ts +0 -2
  60. package/dist/plugins/plugins.test.d.ts.map +0 -1
  61. package/dist/plugins/plugins.test.js +0 -137
  62. package/dist/plugins/plugins.test.js.map +0 -1
  63. package/dist/schemas/schemas.test.d.ts +0 -2
  64. package/dist/schemas/schemas.test.d.ts.map +0 -1
  65. package/dist/schemas/schemas.test.js +0 -58
  66. package/dist/schemas/schemas.test.js.map +0 -1
  67. package/dist/status.test.d.ts +0 -2
  68. package/dist/status.test.d.ts.map +0 -1
  69. package/dist/status.test.js +0 -295
  70. package/dist/status.test.js.map +0 -1
  71. package/dist/storage/storage.test.d.ts +0 -2
  72. package/dist/storage/storage.test.d.ts.map +0 -1
  73. package/dist/storage/storage.test.js +0 -236
  74. package/dist/storage/storage.test.js.map +0 -1
  75. package/dist/storage/upload-limits.test.d.ts +0 -2
  76. package/dist/storage/upload-limits.test.d.ts.map +0 -1
  77. package/dist/storage/upload-limits.test.js +0 -31
  78. package/dist/storage/upload-limits.test.js.map +0 -1
  79. package/dist/store/conformance.test.d.ts +0 -2
  80. package/dist/store/conformance.test.d.ts.map +0 -1
  81. package/dist/store/conformance.test.js +0 -15
  82. package/dist/store/conformance.test.js.map +0 -1
  83. package/dist/store/firebase.test.d.ts +0 -2
  84. package/dist/store/firebase.test.d.ts.map +0 -1
  85. package/dist/store/firebase.test.js +0 -103
  86. package/dist/store/firebase.test.js.map +0 -1
  87. package/dist/store/query.test.d.ts +0 -2
  88. package/dist/store/query.test.d.ts.map +0 -1
  89. package/dist/store/query.test.js +0 -89
  90. package/dist/store/query.test.js.map +0 -1
  91. package/dist/store/sqlite.test.d.ts +0 -2
  92. package/dist/store/sqlite.test.d.ts.map +0 -1
  93. package/dist/store/sqlite.test.js +0 -177
  94. package/dist/store/sqlite.test.js.map +0 -1
  95. package/dist/task-state.test.d.ts +0 -2
  96. package/dist/task-state.test.d.ts.map +0 -1
  97. package/dist/task-state.test.js +0 -423
  98. package/dist/task-state.test.js.map +0 -1
  99. package/dist/use-case-validation.test.d.ts +0 -2
  100. package/dist/use-case-validation.test.d.ts.map +0 -1
  101. package/dist/use-case-validation.test.js +0 -281
  102. package/dist/use-case-validation.test.js.map +0 -1
  103. package/dist/utils/fractional-index.test.d.ts +0 -2
  104. package/dist/utils/fractional-index.test.d.ts.map +0 -1
  105. package/dist/utils/fractional-index.test.js +0 -182
  106. package/dist/utils/fractional-index.test.js.map +0 -1
  107. package/dist/utils/key.test.d.ts +0 -2
  108. package/dist/utils/key.test.d.ts.map +0 -1
  109. package/dist/utils/key.test.js +0 -65
  110. package/dist/utils/key.test.js.map +0 -1
  111. package/dist/utils/mentions.test.d.ts +0 -2
  112. package/dist/utils/mentions.test.d.ts.map +0 -1
  113. package/dist/utils/mentions.test.js +0 -114
  114. package/dist/utils/mentions.test.js.map +0 -1
  115. package/dist/webhooks/webhooks.test.d.ts +0 -2
  116. package/dist/webhooks/webhooks.test.d.ts.map +0 -1
  117. package/dist/webhooks/webhooks.test.js +0 -154
  118. package/dist/webhooks/webhooks.test.js.map +0 -1
  119. package/src/deliverables.test.ts +0 -284
  120. package/src/domain/authorization.ts +0 -82
  121. package/src/domain/calendar.test.ts +0 -216
  122. package/src/domain/calendar.ts +0 -502
  123. package/src/domain/cpm.test.ts +0 -189
  124. package/src/domain/cpm.ts +0 -258
  125. package/src/domain/custom-fields.ts +0 -172
  126. package/src/domain/ddd.test.ts +0 -442
  127. package/src/domain/entities.ts +0 -798
  128. package/src/domain/errors.ts +0 -38
  129. package/src/domain/events.ts +0 -369
  130. package/src/domain/graph.ts +0 -70
  131. package/src/domain/index.ts +0 -12
  132. package/src/domain/ladder.test.ts +0 -251
  133. package/src/domain/ladder.ts +0 -474
  134. package/src/domain/metrics.test.ts +0 -288
  135. package/src/domain/metrics.ts +0 -497
  136. package/src/domain/task-duration.test.ts +0 -354
  137. package/src/domain/workload.test.ts +0 -311
  138. package/src/domain/workload.ts +0 -457
  139. package/src/engine/actor.test.ts +0 -63
  140. package/src/engine/authorization.test.ts +0 -199
  141. package/src/engine/cascade.test.ts +0 -121
  142. package/src/engine/config.test.ts +0 -51
  143. package/src/engine/entity-events.test.ts +0 -67
  144. package/src/engine/index.ts +0 -2495
  145. package/src/index.test.ts +0 -514
  146. package/src/index.ts +0 -9
  147. package/src/plugins/index.ts +0 -103
  148. package/src/plugins/plugins.test.ts +0 -161
  149. package/src/schemas/index.ts +0 -402
  150. package/src/schemas/schemas.test.ts +0 -116
  151. package/src/status.test.ts +0 -354
  152. package/src/storage/file-storage.ts +0 -200
  153. package/src/storage/firebase-storage.ts +0 -209
  154. package/src/storage/index.ts +0 -3
  155. package/src/storage/s3.ts +0 -151
  156. package/src/storage/storage.test.ts +0 -274
  157. package/src/storage/upload-limits.test.ts +0 -41
  158. package/src/store/conformance.test.ts +0 -15
  159. package/src/store/firebase.test.ts +0 -131
  160. package/src/store/firebase.ts +0 -658
  161. package/src/store/index.ts +0 -623
  162. package/src/store/query.test.ts +0 -110
  163. package/src/store/query.ts +0 -113
  164. package/src/store/sqlite.test.ts +0 -218
  165. package/src/store/sqlite.ts +0 -1480
  166. package/src/task-state.test.ts +0 -506
  167. package/src/testing/conformance.ts +0 -319
  168. package/src/testing/index.ts +0 -1
  169. package/src/types/index.ts +0 -871
  170. package/src/use-case-validation.test.ts +0 -324
  171. package/src/utils/fractional-index.test.ts +0 -228
  172. package/src/utils/fractional-index.ts +0 -254
  173. package/src/utils/index.ts +0 -7
  174. package/src/utils/key.test.ts +0 -76
  175. package/src/utils/key.ts +0 -62
  176. package/src/utils/mentions.test.ts +0 -132
  177. package/src/utils/mentions.ts +0 -131
  178. package/src/utils/status.ts +0 -419
  179. package/src/utils/workflow.ts +0 -306
  180. package/src/webhooks/dispatcher.ts +0 -190
  181. package/src/webhooks/index.ts +0 -2
  182. package/src/webhooks/signature.ts +0 -57
  183. package/src/webhooks/webhooks.test.ts +0 -201
  184. package/tsconfig.json +0 -8
  185. package/tsconfig.tsbuildinfo +0 -1
@@ -1,419 +0,0 @@
1
- import type {
2
- Task,
3
- StatusDefinition,
4
- SemanticStatus,
5
- TaskDerivedStatus,
6
- Workflow
7
- } from '../types/index.js';
8
-
9
- export const DEFAULT_STATUS_DEFINITIONS: Record<string, StatusDefinition> = {
10
- backlog: { key: 'backlog', label: 'Backlog', category: 'not_started' },
11
- todo: { key: 'todo', label: 'To Do', category: 'not_started' },
12
- in_progress: { key: 'in_progress', label: 'In Progress', category: 'in_progress' },
13
- in_review: { key: 'in_review', label: 'In Review', category: 'in_progress' },
14
- done: { key: 'done', label: 'Done', category: 'completed' },
15
- canceled: { key: 'canceled', label: 'Canceled', category: 'canceled' }
16
- };
17
-
18
- export interface DeriveTaskLifecycleOptions {
19
- customDefinitions?: StatusDefinition[];
20
- referenceDate?: Date;
21
- upstreamTasks?: Task[];
22
- stalledThresholdDays?: number;
23
- }
24
-
25
- export function resolveStatusDefinition(
26
- statusKey: string,
27
- customDefinitions?: StatusDefinition[]
28
- ): StatusDefinition {
29
- if (customDefinitions) {
30
- const found = customDefinitions.find((def) => def.key === statusKey);
31
- if (found) return found;
32
- }
33
- if (DEFAULT_STATUS_DEFINITIONS[statusKey]) {
34
- return DEFAULT_STATUS_DEFINITIONS[statusKey];
35
- }
36
-
37
- // Fallback heuristic for unknown custom statuses:
38
- const lower = statusKey.toLowerCase();
39
- let category: SemanticStatus = 'not_started';
40
- if (['canceled', 'cancelled', 'rejected', 'abandoned', 'void', 'dropped'].some((k) => lower.includes(k))) {
41
- category = 'canceled';
42
- } else if (['done', 'completed', 'finished', 'closed', 'approved', 'final', 'delivered', 'shipped'].some((k) => lower.includes(k))) {
43
- category = 'completed';
44
- } else if (['in_progress', 'active', 'working', 'in_review', 'review', 'testing', 'qa', 'building', 'editing'].some((k) => lower.includes(k))) {
45
- category = 'in_progress';
46
- }
47
-
48
- return {
49
- key: statusKey,
50
- label: statusKey,
51
- category
52
- };
53
- }
54
-
55
- export function deriveTaskLifecycleState(
56
- task: Task,
57
- customDefinitionsOrOptions?: StatusDefinition[] | DeriveTaskLifecycleOptions,
58
- legacyReferenceDate?: Date
59
- ): TaskDerivedStatus {
60
- let customDefinitions: StatusDefinition[] | undefined;
61
- let referenceDate = legacyReferenceDate ?? new Date();
62
- let upstreamTasks: Task[] = [];
63
- let stalledThresholdDays = 5;
64
-
65
- if (Array.isArray(customDefinitionsOrOptions)) {
66
- customDefinitions = customDefinitionsOrOptions;
67
- } else if (customDefinitionsOrOptions) {
68
- customDefinitions = customDefinitionsOrOptions.customDefinitions;
69
- if (customDefinitionsOrOptions.referenceDate) {
70
- referenceDate = customDefinitionsOrOptions.referenceDate;
71
- }
72
- if (customDefinitionsOrOptions.upstreamTasks) {
73
- upstreamTasks = customDefinitionsOrOptions.upstreamTasks;
74
- }
75
- if (customDefinitionsOrOptions.stalledThresholdDays !== undefined) {
76
- stalledThresholdDays = customDefinitionsOrOptions.stalledThresholdDays;
77
- }
78
- }
79
-
80
- const def = resolveStatusDefinition(task.status, customDefinitions);
81
- const semanticStatus: SemanticStatus = def.category;
82
- const isDone = semanticStatus === 'completed' || semanticStatus === 'canceled';
83
- const isActive = semanticStatus === 'in_progress';
84
- const isCancelled = semanticStatus === 'canceled';
85
-
86
- // Dependency & Flow Indicators
87
- const blockingTasks = upstreamTasks.filter((t) => {
88
- const upstreamDef = resolveStatusDefinition(t.status, customDefinitions);
89
- return upstreamDef.category !== 'completed';
90
- });
91
- const blockingTaskIds = blockingTasks.map((t) => t.id);
92
- const isExplicitlyBlocked = Boolean(task.isBlocked === true);
93
- const isBlocked = !isDone && (blockingTaskIds.length > 0 || isExplicitlyBlocked);
94
- const isReady = semanticStatus === 'not_started' && !isBlocked;
95
-
96
- // Time & Schedule Indicators
97
- let isOverdue = false;
98
- if (!isDone && task.dueDate) {
99
- const due = new Date(task.dueDate);
100
- if (!isNaN(due.getTime()) && due < referenceDate) {
101
- isOverdue = true;
102
- }
103
- }
104
-
105
- let isUpcoming = false;
106
- if (semanticStatus === 'not_started' && task.plannedStartDate) {
107
- const plannedStart = new Date(task.plannedStartDate);
108
- if (!isNaN(plannedStart.getTime()) && plannedStart > referenceDate) {
109
- isUpcoming = true;
110
- }
111
- }
112
-
113
- const isUnplanned = semanticStatus === 'not_started' && !task.iterationId && !task.plannedStartDate && !task.dueDate;
114
-
115
- // Resource & Activity Indicators
116
- const hasAssignee = Boolean(task.assigneeId || (task.assignees && task.assignees.length > 0));
117
- const isUnassigned = !isDone && !hasAssignee;
118
-
119
- let isStalled = false;
120
- if (semanticStatus === 'in_progress') {
121
- const lastActivity = task.updatedAt ? new Date(task.updatedAt) : (task.createdAt ? new Date(task.createdAt) : null);
122
- if (lastActivity && !isNaN(lastActivity.getTime())) {
123
- const thresholdMs = stalledThresholdDays * 24 * 60 * 60 * 1000;
124
- if (referenceDate.getTime() - lastActivity.getTime() > thresholdMs) {
125
- isStalled = true;
126
- }
127
- }
128
- }
129
-
130
- // Effort & Estimate Indicators
131
- let isOverEstimate = false;
132
- const loggedH = task.loggedHours ?? task.actualHours;
133
- const estimatedH = task.estimatedHours;
134
- if (estimatedH !== undefined && estimatedH > 0 && loggedH !== undefined && loggedH > estimatedH) {
135
- isOverEstimate = true;
136
- }
137
- const actualM = task.actualDurationMinutes;
138
- const estimatedM = task.estimatedDurationMinutes;
139
- if (estimatedM !== undefined && estimatedM > 0 && actualM !== undefined && actualM > estimatedM) {
140
- isOverEstimate = true;
141
- }
142
-
143
- let isPaceWarning = false;
144
- if (semanticStatus === 'in_progress' && task.actualStartDate) {
145
- const start = new Date(task.actualStartDate);
146
- if (!isNaN(start.getTime())) {
147
- const elapsedMs = referenceDate.getTime() - start.getTime();
148
- const elapsedHours = elapsedMs / (1000 * 60 * 60);
149
- if (estimatedH !== undefined && estimatedH > 0 && elapsedHours > estimatedH) {
150
- isPaceWarning = true;
151
- } else if (estimatedM !== undefined && estimatedM > 0 && (elapsedMs / (1000 * 60)) > estimatedM) {
152
- isPaceWarning = true;
153
- }
154
- }
155
- }
156
-
157
- return {
158
- semanticStatus,
159
- isReady,
160
- isBlocked,
161
- blockingTaskIds,
162
- isOverdue,
163
- isUpcoming,
164
- isUnplanned,
165
- isUnassigned,
166
- isStalled,
167
- isOverEstimate,
168
- isPaceWarning,
169
- isDone,
170
- isActive,
171
- isCancelled
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
-