@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.
- package/CHANGELOG.md +16 -0
- package/README.md +4 -0
- package/dist/domain/ddd.test.js +50 -1
- package/dist/domain/ddd.test.js.map +1 -1
- package/dist/engine/index.d.ts +1 -0
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/index.js +9 -1
- package/dist/engine/index.js.map +1 -1
- package/dist/index.test.js +28 -0
- package/dist/index.test.js.map +1 -1
- package/dist/store/sqlite.d.ts.map +1 -1
- package/dist/store/sqlite.js +13 -5
- package/dist/store/sqlite.js.map +1 -1
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/workflow.d.ts +1 -0
- package/dist/utils/workflow.d.ts.map +1 -1
- package/dist/utils/workflow.js +30 -1
- package/dist/utils/workflow.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/ddd.test.ts +62 -0
- package/src/engine/index.ts +9 -0
- package/src/index.test.ts +33 -0
- package/src/store/sqlite.ts +13 -3
- package/src/types/index.ts +9 -0
- package/src/utils/workflow.ts +42 -1
package/src/utils/workflow.ts
CHANGED
|
@@ -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
|
+
}
|