@critical-path/core 0.3.0 → 0.5.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/engine/index.d.ts +8 -1
  4. package/dist/engine/index.d.ts.map +1 -1
  5. package/dist/engine/index.js +93 -3
  6. package/dist/engine/index.js.map +1 -1
  7. package/dist/index.test.js +44 -0
  8. package/dist/index.test.js.map +1 -1
  9. package/dist/store/firebase.d.ts +6 -1
  10. package/dist/store/firebase.d.ts.map +1 -1
  11. package/dist/store/firebase.js +37 -0
  12. package/dist/store/firebase.js.map +1 -1
  13. package/dist/store/firebase.test.js +16 -0
  14. package/dist/store/firebase.test.js.map +1 -1
  15. package/dist/store/index.d.ts +12 -1
  16. package/dist/store/index.d.ts.map +1 -1
  17. package/dist/store/index.js +35 -0
  18. package/dist/store/index.js.map +1 -1
  19. package/dist/store/sqlite.d.ts +7 -1
  20. package/dist/store/sqlite.d.ts.map +1 -1
  21. package/dist/store/sqlite.js +81 -10
  22. package/dist/store/sqlite.js.map +1 -1
  23. package/dist/store/sqlite.test.js +21 -0
  24. package/dist/store/sqlite.test.js.map +1 -1
  25. package/dist/types/index.d.ts +32 -1
  26. package/dist/types/index.d.ts.map +1 -1
  27. package/dist/use-case-validation.test.d.ts +2 -0
  28. package/dist/use-case-validation.test.d.ts.map +1 -0
  29. package/dist/use-case-validation.test.js +281 -0
  30. package/dist/use-case-validation.test.js.map +1 -0
  31. package/dist/utils/index.d.ts +1 -0
  32. package/dist/utils/index.d.ts.map +1 -1
  33. package/dist/utils/index.js +1 -0
  34. package/dist/utils/index.js.map +1 -1
  35. package/dist/utils/status.js +1 -1
  36. package/dist/utils/status.js.map +1 -1
  37. package/dist/utils/workflow.d.ts +14 -0
  38. package/dist/utils/workflow.d.ts.map +1 -0
  39. package/dist/utils/workflow.js +136 -0
  40. package/dist/utils/workflow.js.map +1 -0
  41. package/package.json +1 -1
  42. package/src/engine/index.ts +106 -4
  43. package/src/index.test.ts +54 -0
  44. package/src/store/firebase.test.ts +21 -0
  45. package/src/store/firebase.ts +42 -1
  46. package/src/store/index.ts +48 -1
  47. package/src/store/sqlite.test.ts +28 -0
  48. package/src/store/sqlite.ts +114 -7
  49. package/src/types/index.ts +38 -1
  50. package/src/use-case-validation.test.ts +324 -0
  51. package/src/utils/index.ts +2 -0
  52. package/src/utils/status.ts +1 -1
  53. package/src/utils/workflow.ts +164 -0
  54. package/tsconfig.tsbuildinfo +1 -1
@@ -46,6 +46,35 @@ export interface CustomFieldDefinition {
46
46
  defaultValue?: unknown;
47
47
  }
48
48
 
49
+ export interface WorkflowTransition {
50
+ id?: string;
51
+ name?: string;
52
+ fromStatusKey: string | '*';
53
+ toStatusKey: string;
54
+ }
55
+
56
+ export interface TaskTypeDefinition {
57
+ key: string;
58
+ label: string;
59
+ description?: string;
60
+ icon?: string;
61
+ defaultStatusKey?: string;
62
+ workflowId?: string;
63
+ }
64
+
65
+ export interface Workflow {
66
+ id: string;
67
+ name: string;
68
+ description?: string;
69
+ statuses: StatusDefinition[];
70
+ transitions: WorkflowTransition[];
71
+ taskTypes?: TaskTypeDefinition[];
72
+ defaultStatusKey?: string;
73
+ isDefault?: boolean;
74
+ createdAt: string;
75
+ updatedAt: string;
76
+ }
77
+
49
78
  export interface Project {
50
79
  id: string;
51
80
  key?: string; // e.g. "CP" or "PROJ"
@@ -54,6 +83,9 @@ export interface Project {
54
83
  ownerId?: string;
55
84
  members?: string[]; // user IDs
56
85
  teamIds?: string[]; // team IDs
86
+ workflowId?: string;
87
+ workflow?: Workflow;
88
+ taskTypes?: TaskTypeDefinition[];
57
89
  statusDefinitions?: StatusDefinition[];
58
90
  priorityDefinitions?: Array<{ key: string; label: string; level?: number }>;
59
91
  customFieldDefinitions?: CustomFieldDefinition[];
@@ -95,6 +127,7 @@ export interface Task {
95
127
  description?: string;
96
128
  status: TaskStatus;
97
129
  priority: Priority;
130
+ taskType?: string; // e.g. "bug", "feature", "task", "epic"
98
131
  assigneeId?: string;
99
132
  reporterId?: string;
100
133
  reviewerId?: string;
@@ -184,7 +217,10 @@ export type WebhookEvent =
184
217
  | 'iteration.started'
185
218
  | 'iteration.completed'
186
219
  | 'team.created'
187
- | 'container.created';
220
+ | 'container.created'
221
+ | 'workflow.created'
222
+ | 'workflow.updated'
223
+ | 'workflow.deleted';
188
224
 
189
225
  export interface PluginHooks {
190
226
  beforeTaskCreate?: (task: Partial<Task>) => Promise<Partial<Task>> | Partial<Task>;
@@ -216,5 +252,6 @@ export interface CriticalPathConfig {
216
252
  iterations?: Iteration[];
217
253
  teams?: Team[];
218
254
  containers?: TaskContainer[];
255
+ workflows?: Workflow[];
219
256
  };
220
257
  }
@@ -0,0 +1,324 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { CriticalPathEngine, DEFAULT_SOFTWARE_WORKFLOW, DEFAULT_VFX_WORKFLOW } from './index.js';
3
+
4
+ describe('Critical Path Use Case Validation Suite', () => {
5
+ describe('Use Case 1: Software Development (Product Planning & Issue Tracking)', () => {
6
+ it('supports full software development lifecycle with epics, sprints, dependencies, custom fields, and workflow transitions', async () => {
7
+ const engine = new CriticalPathEngine();
8
+
9
+ // 1. Create Workflow & Project
10
+ const softwareProject = await engine.createProject({
11
+ key: 'DEV',
12
+ name: 'Mobile App Project',
13
+ description: 'Software development project for mobile client',
14
+ workflow: DEFAULT_SOFTWARE_WORKFLOW,
15
+ customFieldDefinitions: [
16
+ { id: 'cf_story_points', key: 'storyPoints', label: 'Story Points', type: 'number' },
17
+ { id: 'cf_severity', key: 'severity', label: 'Severity', type: 'single_select', options: ['low', 'medium', 'high', 'critical'] }
18
+ ]
19
+ });
20
+
21
+ expect(softwareProject.id).toBeDefined();
22
+
23
+ // 2. Setup Team and Sprint Iteration
24
+ const devTeam = await engine.createTeam({
25
+ name: 'Frontend Core Team',
26
+ memberIds: ['dev_alice', 'dev_bob', 'lead_charlie']
27
+ });
28
+
29
+ const sprint = await engine.createIteration({
30
+ projectId: softwareProject.id,
31
+ name: 'Sprint 24',
32
+ type: 'sprint',
33
+ startDate: '2026-09-01T00:00:00.000Z',
34
+ endDate: '2026-09-14T00:00:00.000Z',
35
+ status: 'active'
36
+ });
37
+
38
+ // 3. Epics / Task Containers
39
+ const authEpic = await engine.createContainer({
40
+ projectId: softwareProject.id,
41
+ name: 'OAuth2 & Biometric Auth Epic',
42
+ type: 'epic'
43
+ });
44
+
45
+ // 4. Tasks & Subtasks
46
+ // Feature task under Auth Epic
47
+ const featureTask = await engine.createTask({
48
+ projectId: softwareProject.id,
49
+ title: 'Implement FaceID & TouchID Login',
50
+ description: 'Add biometric authentication flow to iOS and Android builds',
51
+ status: 'backlog',
52
+ priority: 'high',
53
+ taskType: 'feature',
54
+ reporterId: 'lead_charlie',
55
+ reviewerId: 'lead_charlie',
56
+ teamId: devTeam.id,
57
+ containerId: authEpic.id,
58
+ iterationId: sprint.id,
59
+ estimatedHours: 16,
60
+ customFields: {
61
+ storyPoints: 5,
62
+ severity: 'high'
63
+ }
64
+ });
65
+
66
+ // Bug task blocking the feature release
67
+ const bugTask = await engine.createTask({
68
+ projectId: softwareProject.id,
69
+ title: 'Fix OAuth Token Expiry Edge Case',
70
+ description: 'Token refresh fails when app is backgrounded over 24 hours',
71
+ status: 'todo',
72
+ priority: 'urgent',
73
+ taskType: 'bug',
74
+ assigneeId: 'dev_alice',
75
+ reporterId: 'dev_bob',
76
+ reviewerId: 'lead_charlie',
77
+ iterationId: sprint.id,
78
+ estimatedHours: 4,
79
+ customFields: {
80
+ storyPoints: 2,
81
+ severity: 'critical'
82
+ }
83
+ });
84
+
85
+ // Subtask under Feature Task
86
+ const subTask = await engine.createTask({
87
+ projectId: softwareProject.id,
88
+ title: 'iOS LocalAuthentication Bridge',
89
+ status: 'todo',
90
+ priority: 'high',
91
+ taskType: 'subtask',
92
+ assigneeId: 'dev_bob',
93
+ parentId: featureTask.id,
94
+ estimatedHours: 8
95
+ });
96
+
97
+ expect(subTask.parentId).toBe(featureTask.id);
98
+
99
+ // 5. Blocker Dependency: FeatureTask depends on BugTask being resolved first
100
+ await engine.store.addDependency({
101
+ taskId: featureTask.id,
102
+ dependsOnTaskId: bugTask.id,
103
+ type: 'blocking'
104
+ });
105
+
106
+ const bugGraph = await engine.getTaskDependencyGraph(bugTask.id);
107
+ expect(bugGraph.downstreamTasks.map((t) => t.id)).toContain(featureTask.id);
108
+
109
+ // 6. Execution & Workflow Transitions
110
+ // Move Feature from Backlog -> Todo -> In Progress
111
+ await engine.updateTask(featureTask.id, { status: 'todo' });
112
+ await engine.updateTask(featureTask.id, {
113
+ status: 'in_progress',
114
+ assigneeId: 'dev_alice',
115
+ actualStartDate: '2026-09-02T09:00:00.000Z'
116
+ });
117
+
118
+ // Log progress and hours
119
+ const updatedFeature = await engine.updateTask(featureTask.id, {
120
+ loggedHours: 10,
121
+ progress: 60
122
+ });
123
+ expect(updatedFeature?.loggedHours).toBe(10);
124
+ expect(updatedFeature?.progress).toBe(60);
125
+
126
+ // Transition In Progress -> In Review
127
+ const reviewTask = await engine.updateTask(featureTask.id, { status: 'in_review' });
128
+ expect(reviewTask?.status).toBe('in_review');
129
+
130
+ // Invalid Transition Check: Try to transition back from Done to Backlog directly (not allowed by workflow)
131
+ const doneTask = await engine.updateTask(featureTask.id, { status: 'done', actualEndDate: '2026-09-05T17:00:00.000Z' });
132
+ expect(doneTask?.status).toBe('done');
133
+
134
+ await expect(
135
+ engine.updateTask(featureTask.id, { status: 'backlog' })
136
+ ).rejects.toThrow();
137
+
138
+ // Check Lifecycle State
139
+ const lifecycle = await engine.getTaskLifecycleState(featureTask.id);
140
+ expect(lifecycle?.isDone).toBe(true);
141
+ expect(lifecycle?.completionState).toBe('done');
142
+ });
143
+ });
144
+
145
+ describe('Use Case 2: Visual Effects (VFX) Production', () => {
146
+ it('supports VFX shot deliverable hierarchies, drafting/bidding, artist/vendor assignment, and multi-stage review workflows', async () => {
147
+ const engine = new CriticalPathEngine();
148
+
149
+ // 1. Setup VFX Project with DEFAULT_VFX_WORKFLOW
150
+ const vfxProject = await engine.createProject({
151
+ key: 'FX_MOP',
152
+ name: 'Feature Film - Movie Project',
153
+ description: 'VFX shot production for sequence SEQ_101',
154
+ workflow: DEFAULT_VFX_WORKFLOW,
155
+ customFieldDefinitions: [
156
+ { id: 'cf_bid_days', key: 'bidDays', label: 'Bid Days', type: 'number' },
157
+ { id: 'cf_bid_amount', key: 'bidAmountUSD', label: 'Bid Amount ($)', type: 'number' },
158
+ { id: 'cf_frame_count', key: 'frameCount', label: 'Frame Count', type: 'number' },
159
+ { id: 'cf_resolution', key: 'resolution', label: 'Resolution', type: 'single_select', options: ['2K', '4K', '8K'] },
160
+ { id: 'cf_vfx_version', key: 'vfxVersion', label: 'VFX Version', type: 'text' },
161
+ { id: 'cf_review_url', key: 'reviewMediaUrl', label: 'Review Media URL', type: 'text' }
162
+ ]
163
+ });
164
+
165
+ // 2. Outsource Vendor & Internal Department Teams
166
+ const vendorTeam = await engine.createTeam({
167
+ name: 'Outsource Vendor Studio X',
168
+ description: '3D Simulation & FX Vendor Studio',
169
+ memberIds: ['vendor_lead_mark', 'vendor_artist_joe']
170
+ });
171
+
172
+ const internalLeadTeam = await engine.createTeam({
173
+ name: 'Internal VFX Supervisors',
174
+ memberIds: ['vfx_sup_sarah', 'comp_lead_dave']
175
+ });
176
+
177
+ expect(vendorTeam.id).toBeDefined();
178
+ expect(internalLeadTeam.id).toBeDefined();
179
+
180
+ // 3. Hierarchy Deliverables: Sequence Container -> Shot Container
181
+ const sequenceContainer = await engine.createContainer({
182
+ projectId: vfxProject.id,
183
+ name: 'SEQ_101 - Desert Canyon Chase',
184
+ type: 'sequence'
185
+ });
186
+
187
+ const shotContainer = await engine.createContainer({
188
+ projectId: vfxProject.id,
189
+ name: 'SHOT_101_010 - Hero Vehicle Explosion',
190
+ type: 'shot',
191
+ parentId: sequenceContainer.id
192
+ });
193
+
194
+ expect(shotContainer.parentId).toBe(sequenceContainer.id);
195
+
196
+ // 4. Draft & Bidding Phase
197
+ // Create VFX Task for FX Simulation department under SHOT_101_010
198
+ const fxBiddingTask = await engine.createTask({
199
+ projectId: vfxProject.id,
200
+ title: 'FX Simulation - Fire & Vehicle Debris',
201
+ description: 'Heavy pyro explosion and fracturing geometry',
202
+ status: 'bidding', // Starts in Draft & Bidding
203
+ priority: 'high',
204
+ taskType: 'vfx_task',
205
+ reporterId: 'vfx_sup_sarah',
206
+ containerId: shotContainer.id,
207
+ teamId: vendorTeam.id,
208
+ customFields: {
209
+ bidDays: 12.5,
210
+ bidAmountUSD: 15000,
211
+ frameCount: 180,
212
+ resolution: '4K',
213
+ vfxVersion: 'v000'
214
+ }
215
+ });
216
+
217
+ expect(fxBiddingTask.status).toBe('bidding');
218
+ expect(fxBiddingTask.customFields?.bidAmountUSD).toBe(15000);
219
+
220
+ // Element Subtask
221
+ const dustElementTask = await engine.createTask({
222
+ projectId: vfxProject.id,
223
+ title: 'Secondary Dust Cloud Elements',
224
+ status: 'bidding',
225
+ priority: 'medium',
226
+ taskType: 'subtask',
227
+ parentId: fxBiddingTask.id,
228
+ customFields: { bidDays: 3 }
229
+ });
230
+
231
+ expect(dustElementTask.parentId).toBe(fxBiddingTask.id);
232
+
233
+ // 5. Award Bids & Transition to In Production
234
+ const awardedTask = await engine.updateTask(fxBiddingTask.id, {
235
+ status: 'awarded'
236
+ });
237
+ expect(awardedTask?.status).toBe('awarded');
238
+
239
+ // Assign to Vendor Artist and start production
240
+ const productionTask = await engine.updateTask(fxBiddingTask.id, {
241
+ status: 'in_production',
242
+ assigneeId: 'vendor_artist_joe',
243
+ reviewerId: 'comp_lead_dave',
244
+ customFields: {
245
+ ...fxBiddingTask.customFields,
246
+ vfxVersion: 'v001'
247
+ }
248
+ });
249
+ expect(productionTask?.status).toBe('in_production');
250
+ expect(productionTask?.assigneeId).toBe('vendor_artist_joe');
251
+
252
+ // 6. Review & Approval Process
253
+ // Artist finishes v001 and submits to Internal Review
254
+ const internalReviewTask = await engine.updateTask(fxBiddingTask.id, {
255
+ status: 'internal_review',
256
+ customFields: {
257
+ ...productionTask?.customFields,
258
+ vfxVersion: 'v001',
259
+ reviewMediaUrl: 'https://vfx-pipeline.studio.com/reviews/SHOT_101_010_FX_v001.mov'
260
+ }
261
+ });
262
+ expect(internalReviewTask?.status).toBe('internal_review');
263
+
264
+ // Internal Lead rejects v001 and requests revisions with notes
265
+ await engine.store.addComment({
266
+ taskId: fxBiddingTask.id,
267
+ authorId: 'comp_lead_dave',
268
+ content: 'Fire velocity looks great, but debris needs 20% more scale and air resistance.'
269
+ });
270
+
271
+ const revisionTask = await engine.updateTask(fxBiddingTask.id, {
272
+ status: 'revision_requested'
273
+ });
274
+ expect(revisionTask?.status).toBe('revision_requested');
275
+
276
+ // Artist addresses revisions -> In Production -> Resubmits v002 to Internal Review
277
+ await engine.updateTask(fxBiddingTask.id, {
278
+ status: 'in_production',
279
+ customFields: {
280
+ ...revisionTask?.customFields,
281
+ vfxVersion: 'v002'
282
+ }
283
+ });
284
+
285
+ const internalReviewPass = await engine.updateTask(fxBiddingTask.id, {
286
+ status: 'internal_review',
287
+ customFields: {
288
+ ...revisionTask?.customFields,
289
+ vfxVersion: 'v002',
290
+ reviewMediaUrl: 'https://vfx-pipeline.studio.com/reviews/SHOT_101_010_FX_v002.mov'
291
+ }
292
+ });
293
+ expect(internalReviewPass?.status).toBe('internal_review');
294
+
295
+ // Internal Lead approves and passes shot to Client Review
296
+ const clientReviewTask = await engine.updateTask(fxBiddingTask.id, {
297
+ status: 'client_review'
298
+ });
299
+ expect(clientReviewTask?.status).toBe('client_review');
300
+
301
+ // Director / Client Supervisor approves final shot
302
+ await engine.store.addComment({
303
+ taskId: fxBiddingTask.id,
304
+ authorId: 'vfx_sup_sarah',
305
+ content: 'Client Supervisor approved v002 for final comp assembly.'
306
+ });
307
+
308
+ const finalApprovedTask = await engine.updateTask(fxBiddingTask.id, {
309
+ status: 'approved',
310
+ progress: 100
311
+ });
312
+ expect(finalApprovedTask?.status).toBe('approved');
313
+ expect(finalApprovedTask?.progress).toBe(100);
314
+
315
+ // Verify task lifecycle status shows completed
316
+ const lifecycle = await engine.getTaskLifecycleState(fxBiddingTask.id);
317
+ expect(lifecycle?.isDone).toBe(true);
318
+
319
+ // Verify audit log history recorded all approval steps
320
+ const activities = await engine.store.getActivities({ taskId: fxBiddingTask.id });
321
+ expect(activities.length).toBeGreaterThanOrEqual(6);
322
+ });
323
+ });
324
+ });
@@ -1,2 +1,4 @@
1
1
  export * from './status.js';
2
2
  export * from './key.js';
3
+ export * from './workflow.js';
4
+
@@ -36,7 +36,7 @@ export function resolveStatusDefinition(
36
36
  return DEFAULT_STATUS_DEFINITIONS[statusKey];
37
37
  }
38
38
  // Fallback heuristic for unknown custom statuses:
39
- const isDoneKey = ['done', 'completed', 'finished', 'closed', 'canceled', 'cancelled'].includes(statusKey.toLowerCase());
39
+ const isDoneKey = ['done', 'completed', 'finished', 'closed', 'canceled', 'cancelled', 'approved', 'final'].includes(statusKey.toLowerCase());
40
40
  const isActiveKey = ['in_progress', 'active', 'working', 'in_review', 'review'].includes(statusKey.toLowerCase());
41
41
  return {
42
42
  key: statusKey,
@@ -0,0 +1,164 @@
1
+ import type {
2
+ Workflow,
3
+ StatusDefinition,
4
+ TaskTypeDefinition
5
+ } from '../types/index.js';
6
+ import { DEFAULT_STATUS_DEFINITIONS } from './status.js';
7
+
8
+ export class WorkflowValidationError extends Error {
9
+ public readonly fromStatus: string;
10
+ public readonly toStatus: string;
11
+ public readonly workflowId?: string;
12
+
13
+ constructor(fromStatus: string, toStatus: string, workflowId?: string, message?: string) {
14
+ const msg = message || `Illegal status transition from "${fromStatus}" to "${toStatus}"${workflowId ? ` in workflow "${workflowId}"` : ''}.`;
15
+ super(msg);
16
+ this.name = 'WorkflowValidationError';
17
+ this.fromStatus = fromStatus;
18
+ this.toStatus = toStatus;
19
+ this.workflowId = workflowId;
20
+ }
21
+ }
22
+
23
+ export const DEFAULT_TASK_TYPES: TaskTypeDefinition[] = [
24
+ { key: 'task', label: 'Task', description: 'A standard work item', icon: 'check-square' },
25
+ { key: 'bug', label: 'Bug', description: 'A problem or defect that needs fixing', icon: 'bug' },
26
+ { key: 'feature', label: 'Feature', description: 'A new capability or enhancement', icon: 'sparkles' },
27
+ { key: 'epic', label: 'Epic', description: 'A large body of work that spans multiple tasks', icon: 'layers' },
28
+ { key: 'subtask', label: 'Subtask', description: 'A piece of work required to complete a parent task', icon: 'corner-down-right' }
29
+ ];
30
+
31
+ export const DEFAULT_SOFTWARE_WORKFLOW: Workflow = {
32
+ id: 'wf_software_default',
33
+ name: 'Software Development Workflow',
34
+ description: 'Standard software development lifecycle with backlog, review, and completion states.',
35
+ statuses: [
36
+ DEFAULT_STATUS_DEFINITIONS.backlog,
37
+ DEFAULT_STATUS_DEFINITIONS.todo,
38
+ DEFAULT_STATUS_DEFINITIONS.in_progress,
39
+ DEFAULT_STATUS_DEFINITIONS.in_review,
40
+ DEFAULT_STATUS_DEFINITIONS.done,
41
+ DEFAULT_STATUS_DEFINITIONS.canceled
42
+ ],
43
+ transitions: [
44
+ { name: 'Start Work', fromStatusKey: 'backlog', toStatusKey: 'todo' },
45
+ { name: 'Start Implementation', fromStatusKey: 'todo', toStatusKey: 'in_progress' },
46
+ { name: 'Complete Task', fromStatusKey: 'todo', toStatusKey: 'done' },
47
+ { name: 'Submit for Review', fromStatusKey: 'in_progress', toStatusKey: 'in_review' },
48
+ { name: 'Complete Implementation', fromStatusKey: 'in_progress', toStatusKey: 'done' },
49
+ { name: 'Approve & Complete', fromStatusKey: 'in_review', toStatusKey: 'done' },
50
+ { name: 'Request Changes', fromStatusKey: 'in_review', toStatusKey: 'in_progress' },
51
+ { name: 'Reopen', fromStatusKey: 'done', toStatusKey: 'todo' },
52
+ { name: 'Cancel', fromStatusKey: '*', toStatusKey: 'canceled' },
53
+ { name: 'Restore', fromStatusKey: 'canceled', toStatusKey: 'todo' }
54
+ ],
55
+ taskTypes: DEFAULT_TASK_TYPES,
56
+ defaultStatusKey: 'todo',
57
+ isDefault: true,
58
+ createdAt: '2026-01-01T00:00:00.000Z',
59
+ updatedAt: '2026-01-01T00:00:00.000Z'
60
+ };
61
+
62
+ export const DEFAULT_SIMPLE_WORKFLOW: Workflow = {
63
+ id: 'wf_simple_default',
64
+ name: 'Simple Task Workflow',
65
+ description: 'Lightweight workflow with To Do, In Progress, and Done states.',
66
+ statuses: [
67
+ DEFAULT_STATUS_DEFINITIONS.todo,
68
+ DEFAULT_STATUS_DEFINITIONS.in_progress,
69
+ DEFAULT_STATUS_DEFINITIONS.done
70
+ ],
71
+ transitions: [
72
+ { name: 'Start', fromStatusKey: 'todo', toStatusKey: 'in_progress' },
73
+ { name: 'Complete', fromStatusKey: 'todo', toStatusKey: 'done' },
74
+ { name: 'Complete', fromStatusKey: 'in_progress', toStatusKey: 'done' },
75
+ { name: 'Reopen', fromStatusKey: 'done', toStatusKey: 'todo' }
76
+ ],
77
+ taskTypes: DEFAULT_TASK_TYPES.filter((t) => ['task', 'subtask'].includes(t.key)),
78
+ defaultStatusKey: 'todo',
79
+ isDefault: true,
80
+ createdAt: '2026-01-01T00:00:00.000Z',
81
+ updatedAt: '2026-01-01T00:00:00.000Z'
82
+ };
83
+
84
+ export const DEFAULT_VFX_WORKFLOW: Workflow = {
85
+ id: 'wf_vfx_default',
86
+ name: 'VFX Production Workflow',
87
+ description: 'Visual effects production pipeline from bidding and drafting to internal lead review and client supervisor approval.',
88
+ statuses: [
89
+ { key: 'bidding', label: 'Bidding & Draft', completionState: 'not_done', executionState: 'inactive' },
90
+ { key: 'awarded', label: 'Awarded / Ready', completionState: 'not_done', executionState: 'inactive' },
91
+ { key: 'in_production', label: 'In Production', completionState: 'not_done', executionState: 'active' },
92
+ { key: 'internal_review', label: 'Internal Review', completionState: 'not_done', executionState: 'active' },
93
+ { key: 'client_review', label: 'Client Review', completionState: 'not_done', executionState: 'active' },
94
+ { key: 'revision_requested', label: 'Revision Requested', completionState: 'not_done', executionState: 'active' },
95
+ { key: 'approved', label: 'Approved (Final)', completionState: 'done', executionState: 'inactive' },
96
+ DEFAULT_STATUS_DEFINITIONS.canceled
97
+ ],
98
+ transitions: [
99
+ { name: 'Award Bid', fromStatusKey: 'bidding', toStatusKey: 'awarded' },
100
+ { name: 'Start Work', fromStatusKey: 'awarded', toStatusKey: 'in_production' },
101
+ { name: 'Submit to Lead Review', fromStatusKey: 'in_production', toStatusKey: 'internal_review' },
102
+ { name: 'Submit to Client Review', fromStatusKey: 'internal_review', toStatusKey: 'client_review' },
103
+ { name: 'Request Internal Revisions', fromStatusKey: 'internal_review', toStatusKey: 'revision_requested' },
104
+ { name: 'Request Client Revisions', fromStatusKey: 'client_review', toStatusKey: 'revision_requested' },
105
+ { name: 'Address Revisions', fromStatusKey: 'revision_requested', toStatusKey: 'in_production' },
106
+ { name: 'Approve Final Shot', fromStatusKey: 'client_review', toStatusKey: 'approved' },
107
+ { name: 'Cancel', fromStatusKey: '*', toStatusKey: 'canceled' }
108
+ ],
109
+ taskTypes: [
110
+ { key: 'vfx_task', label: 'VFX Task', description: 'Department task (e.g. Matchmove, Animation, FX, Comp)', icon: 'film' },
111
+ { key: 'asset', label: 'Asset', description: '3D or 2D asset element', icon: 'box' },
112
+ { key: 'subtask', label: 'Subtask', description: 'Element subtask required to complete a department task', icon: 'corner-down-right' }
113
+ ],
114
+ defaultStatusKey: 'bidding',
115
+ isDefault: false,
116
+ createdAt: '2026-01-01T00:00:00.000Z',
117
+ updatedAt: '2026-01-01T00:00:00.000Z'
118
+ };
119
+
120
+ export function validateTransition(
121
+ workflow: Workflow | undefined,
122
+ fromStatus: string,
123
+ toStatus: string
124
+ ): boolean {
125
+ if (fromStatus === toStatus) return true;
126
+ if (!workflow || !workflow.transitions || workflow.transitions.length === 0) return true;
127
+
128
+ return workflow.transitions.some(
129
+ (t) =>
130
+ (t.fromStatusKey === '*' || t.fromStatusKey === fromStatus) &&
131
+ (t.toStatusKey === '*' || t.toStatusKey === toStatus)
132
+ );
133
+ }
134
+
135
+ export function getAllowedNextStatuses(
136
+ workflow: Workflow | undefined,
137
+ currentStatus: string
138
+ ): string[] {
139
+ if (!workflow || !workflow.statuses || workflow.statuses.length === 0) {
140
+ return Object.keys(DEFAULT_STATUS_DEFINITIONS);
141
+ }
142
+
143
+ const allStatusKeys = workflow.statuses.map((s) => s.key);
144
+ if (!workflow.transitions || workflow.transitions.length === 0) {
145
+ return allStatusKeys;
146
+ }
147
+
148
+ const matches = workflow.transitions.filter(
149
+ (t) => t.fromStatusKey === '*' || t.fromStatusKey === currentStatus
150
+ );
151
+
152
+ if (matches.some((t) => t.toStatusKey === '*')) {
153
+ return allStatusKeys;
154
+ }
155
+
156
+ const allowed = new Set<string>();
157
+ for (const t of matches) {
158
+ if (allStatusKeys.includes(t.toStatusKey)) {
159
+ allowed.add(t.toStatusKey);
160
+ }
161
+ }
162
+
163
+ return Array.from(allowed);
164
+ }
@@ -1 +1 @@
1
- {"root":["./src/index.test.ts","./src/index.ts","./src/engine/index.ts","./src/plugins/index.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/status.ts"],"version":"5.9.3"}
1
+ {"root":["./src/index.test.ts","./src/index.ts","./src/use-case-validation.test.ts","./src/engine/index.ts","./src/plugins/index.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/status.ts","./src/utils/workflow.ts"],"version":"5.9.3"}