@critical-path/core 0.12.0 → 0.13.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.
@@ -42,7 +42,9 @@ export const DEFAULT_SOFTWARE_WORKFLOW: Workflow = {
42
42
  ],
43
43
  transitions: [
44
44
  { name: 'Start Work', fromStatusKey: 'backlog', toStatusKey: 'todo' },
45
+ { name: 'Return to Backlog', fromStatusKey: 'todo', toStatusKey: 'backlog' },
45
46
  { name: 'Start Implementation', fromStatusKey: 'todo', toStatusKey: 'in_progress' },
47
+ { name: 'Return to To Do', fromStatusKey: 'in_progress', toStatusKey: 'todo' },
46
48
  { name: 'Complete Task', fromStatusKey: 'todo', toStatusKey: 'done' },
47
49
  { name: 'Submit for Review', fromStatusKey: 'in_progress', toStatusKey: 'in_review' },
48
50
  { name: 'Complete Implementation', fromStatusKey: 'in_progress', toStatusKey: 'done' },
@@ -70,9 +72,11 @@ export const DEFAULT_SIMPLE_WORKFLOW: Workflow = {
70
72
  ],
71
73
  transitions: [
72
74
  { name: 'Start', fromStatusKey: 'todo', toStatusKey: 'in_progress' },
75
+ { name: 'Return to To Do', fromStatusKey: 'in_progress', toStatusKey: 'todo' },
73
76
  { name: 'Complete', fromStatusKey: 'todo', toStatusKey: 'done' },
74
77
  { name: 'Complete', fromStatusKey: 'in_progress', toStatusKey: 'done' },
75
- { name: 'Reopen', fromStatusKey: 'done', toStatusKey: 'todo' }
78
+ { name: 'Reopen', fromStatusKey: 'done', toStatusKey: 'todo' },
79
+ { name: 'Return to In Progress', fromStatusKey: 'done', toStatusKey: 'in_progress' }
76
80
  ],
77
81
  taskTypes: DEFAULT_TASK_TYPES.filter((t) => ['task', 'subtask'].includes(t.key)),
78
82
  defaultStatusKey: 'todo',
@@ -200,3 +204,40 @@ export function getAllowedNextStatuses(
200
204
 
201
205
  return Array.from(allowed);
202
206
  }
207
+
208
+ export function getAllowedPreviousStatuses(
209
+ workflow: Workflow | undefined,
210
+ currentStatus: string
211
+ ): string[] {
212
+ if (!workflow || !workflow.statuses || workflow.statuses.length === 0) {
213
+ return [];
214
+ }
215
+
216
+ const allStatusKeys = workflow.statuses.map((s) => s.key);
217
+ const currentIndex = allStatusKeys.indexOf(currentStatus);
218
+ if (currentIndex <= 0) {
219
+ return [];
220
+ }
221
+
222
+ const previousStatusKeys = allStatusKeys.slice(0, currentIndex);
223
+
224
+ if (workflow.transitions && workflow.transitions.length > 0) {
225
+ const matches = workflow.transitions.filter(
226
+ (t) => t.fromStatusKey === '*' || t.fromStatusKey === currentStatus
227
+ );
228
+
229
+ const allowed = new Set<string>();
230
+ for (const t of matches) {
231
+ if (t.toStatusKey === '*') {
232
+ return previousStatusKeys;
233
+ }
234
+ if (previousStatusKeys.includes(t.toStatusKey)) {
235
+ allowed.add(t.toStatusKey);
236
+ }
237
+ }
238
+
239
+ return Array.from(allowed);
240
+ }
241
+
242
+ return [allStatusKeys[currentIndex - 1]];
243
+ }