@critical-path/svelte 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 +26 -0
- package/README.md +62 -0
- package/dist/critical-path-state.svelte.d.ts +13 -0
- package/dist/critical-path-state.svelte.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +561 -350
- package/dist/timeline-ladder-state.svelte.d.ts +23 -0
- package/dist/timeline-ladder-state.svelte.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/critical-path-state.svelte.ts +33 -0
- package/src/index.test.ts +94 -2
- package/src/index.ts +2 -0
- package/src/timeline-ladder-state.svelte.ts +58 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CriticalPathClient } from '@critical-path/client';
|
|
2
|
+
import type { TimelineLadder, TimelineLadderOptions, AbstractionLevel, MacroTimelineSummary, ConcreteTaskEvidence } from '@critical-path/core';
|
|
3
|
+
export declare class TimelineLadderState {
|
|
4
|
+
private client;
|
|
5
|
+
projectId: string;
|
|
6
|
+
data: TimelineLadder | null;
|
|
7
|
+
level: AbstractionLevel;
|
|
8
|
+
loading: boolean;
|
|
9
|
+
error: Error | null;
|
|
10
|
+
macro: MacroTimelineSummary | null;
|
|
11
|
+
standard: {
|
|
12
|
+
tasks: import("@critical-path/client").StandardTaskTimelineItem[];
|
|
13
|
+
criticalPathTaskIds: string[];
|
|
14
|
+
dependencies: import("@critical-path/core").TaskDependency[];
|
|
15
|
+
totalDurationHours: number;
|
|
16
|
+
} | null | undefined;
|
|
17
|
+
concrete: Record<string, ConcreteTaskEvidence> | null;
|
|
18
|
+
constructor(client: CriticalPathClient, projectId: string, initialOptions?: TimelineLadderOptions);
|
|
19
|
+
setLevel(newLevel: AbstractionLevel): Promise<void>;
|
|
20
|
+
fetch(options?: TimelineLadderOptions): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export declare function createTimelineLadderState(client: CriticalPathClient, projectId: string, initialOptions?: TimelineLadderOptions): TimelineLadderState;
|
|
23
|
+
//# sourceMappingURL=timeline-ladder-state.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-ladder-state.svelte.d.ts","sourceRoot":"","sources":["../src/timeline-ladder-state.svelte.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAE7B,qBAAa,mBAAmB;IAW5B,OAAO,CAAC,MAAM;IACP,SAAS,EAAE,MAAM;IAX1B,IAAI,wBAAuC;IAC3C,KAAK,mBAAmC;IACxC,OAAO,UAA0B;IACjC,KAAK,eAA8B;IAEnC,KAAK,8BAAmE;IACxE,QAAQ;;;;;yBAA4E;IACpF,QAAQ,8CAAsF;gBAGpF,MAAM,EAAE,kBAAkB,EAC3B,SAAS,EAAE,MAAM,EACxB,cAAc,CAAC,EAAE,qBAAqB;IAOlC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB;IAKnC,KAAK,CAAC,OAAO,CAAC,EAAE,qBAAqB;CAc5C;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,MAAM,EACjB,cAAc,CAAC,EAAE,qBAAqB,GACrC,mBAAmB,CAErB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@critical-path/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "Svelte 5 Runes state and reactive integrations for Critical Path headless project management framework",
|
|
5
5
|
"author": "Jack James",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@critical-path/
|
|
22
|
-
"@critical-path/
|
|
23
|
-
"@critical-path/
|
|
21
|
+
"@critical-path/core": "0.16.0",
|
|
22
|
+
"@critical-path/mcp": "0.3.1",
|
|
23
|
+
"@critical-path/client": "0.10.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"svelte": "^5.0.0"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import type { CriticalPathClient } from '@critical-path/client';
|
|
3
|
+
import type { CriticalPathAnalysis } from '@critical-path/core';
|
|
4
|
+
|
|
5
|
+
export class CriticalPathState {
|
|
6
|
+
data = $state<CriticalPathAnalysis | null>(null);
|
|
7
|
+
loading = $state<boolean>(false);
|
|
8
|
+
error = $state<Error | null>(null);
|
|
9
|
+
|
|
10
|
+
constructor(
|
|
11
|
+
private client: CriticalPathClient,
|
|
12
|
+
public projectId: string
|
|
13
|
+
) {}
|
|
14
|
+
|
|
15
|
+
async fetch() {
|
|
16
|
+
this.loading = true;
|
|
17
|
+
this.error = null;
|
|
18
|
+
try {
|
|
19
|
+
this.data = await this.client.calculateCriticalPath(this.projectId);
|
|
20
|
+
} catch (err) {
|
|
21
|
+
this.error = err instanceof Error ? err : new Error(String(err));
|
|
22
|
+
} finally {
|
|
23
|
+
this.loading = false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function createCriticalPathState(
|
|
29
|
+
client: CriticalPathClient,
|
|
30
|
+
projectId: string
|
|
31
|
+
): CriticalPathState {
|
|
32
|
+
return new CriticalPathState(client, projectId);
|
|
33
|
+
}
|
package/src/index.test.ts
CHANGED
|
@@ -22,10 +22,24 @@ import {
|
|
|
22
22
|
TaskTransitionsState,
|
|
23
23
|
createTaskTransitionsState,
|
|
24
24
|
WebMcpState,
|
|
25
|
-
createWebMcpState
|
|
25
|
+
createWebMcpState,
|
|
26
|
+
CriticalPathState,
|
|
27
|
+
createCriticalPathState,
|
|
28
|
+
TimelineLadderState,
|
|
29
|
+
createTimelineLadderState
|
|
26
30
|
} from './index.js';
|
|
27
31
|
import type { CriticalPathClient } from '@critical-path/client';
|
|
28
|
-
import type {
|
|
32
|
+
import type {
|
|
33
|
+
Project,
|
|
34
|
+
Task,
|
|
35
|
+
Workflow,
|
|
36
|
+
Comment,
|
|
37
|
+
Attachment,
|
|
38
|
+
Deliverable,
|
|
39
|
+
DeliverableSummary,
|
|
40
|
+
CriticalPathAnalysis,
|
|
41
|
+
TimelineLadder
|
|
42
|
+
} from '@critical-path/core';
|
|
29
43
|
|
|
30
44
|
describe('@critical-path/svelte Svelte 5 Runes Test Suite', () => {
|
|
31
45
|
it('exports client factory and Svelte 5 Runes state factories', () => {
|
|
@@ -568,6 +582,84 @@ describe('@critical-path/svelte Svelte 5 Runes Test Suite', () => {
|
|
|
568
582
|
expect(summaryState.data).toEqual(mockSummary);
|
|
569
583
|
});
|
|
570
584
|
});
|
|
585
|
+
|
|
586
|
+
describe('CriticalPathState', () => {
|
|
587
|
+
it('manages loading, error, and critical path analysis data', async () => {
|
|
588
|
+
const mockAnalysis: CriticalPathAnalysis = {
|
|
589
|
+
projectId: 'proj_cpm',
|
|
590
|
+
calculatedAt: '2026-09-11T12:00:00Z',
|
|
591
|
+
totalDurationHours: 42,
|
|
592
|
+
criticalTaskIds: ['t1', 't2'],
|
|
593
|
+
tasks: []
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
const mockClient = {
|
|
597
|
+
calculateCriticalPath: vi.fn().mockResolvedValue(mockAnalysis)
|
|
598
|
+
} as unknown as CriticalPathClient;
|
|
599
|
+
|
|
600
|
+
const cpmState = createCriticalPathState(mockClient, 'proj_cpm');
|
|
601
|
+
expect(cpmState.data).toBeNull();
|
|
602
|
+
expect(cpmState.loading).toBe(false);
|
|
603
|
+
|
|
604
|
+
await cpmState.fetch();
|
|
605
|
+
expect(mockClient.calculateCriticalPath).toHaveBeenCalledWith('proj_cpm');
|
|
606
|
+
expect(cpmState.data).toEqual(mockAnalysis);
|
|
607
|
+
expect(cpmState.loading).toBe(false);
|
|
608
|
+
});
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
describe('TimelineLadderState', () => {
|
|
612
|
+
it('manages multi-scale ladder data, levels, and derived rungs', async () => {
|
|
613
|
+
const mockLadder: TimelineLadder = {
|
|
614
|
+
projectId: 'proj_ladder',
|
|
615
|
+
generatedAt: '2026-09-11T12:00:00Z',
|
|
616
|
+
level: 'all',
|
|
617
|
+
macro: {
|
|
618
|
+
projectId: 'proj_ladder',
|
|
619
|
+
projectName: 'Ladder Proj',
|
|
620
|
+
totalDurationHours: 50,
|
|
621
|
+
criticalPathDurationHours: 40,
|
|
622
|
+
overallProgressPercentage: 60,
|
|
623
|
+
health: 'on_track',
|
|
624
|
+
totalTasks: 5,
|
|
625
|
+
completedTasks: 3,
|
|
626
|
+
inProgressTasks: 2,
|
|
627
|
+
blockedTasks: 0,
|
|
628
|
+
totalEstimatedHours: 50,
|
|
629
|
+
totalLoggedHours: 25,
|
|
630
|
+
phases: []
|
|
631
|
+
},
|
|
632
|
+
standard: {
|
|
633
|
+
tasks: [],
|
|
634
|
+
criticalPathTaskIds: [],
|
|
635
|
+
dependencies: [],
|
|
636
|
+
totalDurationHours: 40
|
|
637
|
+
},
|
|
638
|
+
concrete: {}
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
const mockClient = {
|
|
642
|
+
getTimelineLadder: vi.fn().mockResolvedValue(mockLadder)
|
|
643
|
+
} as unknown as CriticalPathClient;
|
|
644
|
+
|
|
645
|
+
const ladderState = createTimelineLadderState(mockClient, 'proj_ladder', { level: 'all' });
|
|
646
|
+
expect(ladderState.data).toBeNull();
|
|
647
|
+
expect(ladderState.macro).toBeNull();
|
|
648
|
+
expect(ladderState.standard).toBeNull();
|
|
649
|
+
expect(ladderState.concrete).toBeNull();
|
|
650
|
+
|
|
651
|
+
await ladderState.fetch();
|
|
652
|
+
expect(mockClient.getTimelineLadder).toHaveBeenCalledWith('proj_ladder', { level: 'all' });
|
|
653
|
+
expect(ladderState.data).toEqual(mockLadder);
|
|
654
|
+
expect(ladderState.macro?.projectName).toBe('Ladder Proj');
|
|
655
|
+
expect(ladderState.standard?.tasks).toEqual([]);
|
|
656
|
+
expect(ladderState.concrete).toEqual({});
|
|
657
|
+
|
|
658
|
+
await ladderState.setLevel('macro');
|
|
659
|
+
expect(ladderState.level).toBe('macro');
|
|
660
|
+
expect(mockClient.getTimelineLadder).toHaveBeenCalledWith('proj_ladder', { level: 'macro' });
|
|
661
|
+
});
|
|
662
|
+
});
|
|
571
663
|
});
|
|
572
664
|
|
|
573
665
|
|
package/src/index.ts
CHANGED
|
@@ -15,5 +15,7 @@ export * from './deliverable-summary-state.svelte.js';
|
|
|
15
15
|
export * from './kanban-state.svelte.js';
|
|
16
16
|
export * from './task-transitions-state.svelte.js';
|
|
17
17
|
export * from './webmcp-state.svelte.js';
|
|
18
|
+
export * from './critical-path-state.svelte.js';
|
|
19
|
+
export * from './timeline-ladder-state.svelte.js';
|
|
18
20
|
|
|
19
21
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import type { CriticalPathClient } from '@critical-path/client';
|
|
3
|
+
import type {
|
|
4
|
+
TimelineLadder,
|
|
5
|
+
TimelineLadderOptions,
|
|
6
|
+
AbstractionLevel,
|
|
7
|
+
MacroTimelineSummary,
|
|
8
|
+
ConcreteTaskEvidence
|
|
9
|
+
} from '@critical-path/core';
|
|
10
|
+
|
|
11
|
+
export class TimelineLadderState {
|
|
12
|
+
data = $state<TimelineLadder | null>(null);
|
|
13
|
+
level = $state<AbstractionLevel>('all');
|
|
14
|
+
loading = $state<boolean>(false);
|
|
15
|
+
error = $state<Error | null>(null);
|
|
16
|
+
|
|
17
|
+
macro = $derived<MacroTimelineSummary | null>(this.data?.macro ?? null);
|
|
18
|
+
standard = $derived<TimelineLadder['standard'] | null>(this.data?.standard ?? null);
|
|
19
|
+
concrete = $derived<Record<string, ConcreteTaskEvidence> | null>(this.data?.concrete ?? null);
|
|
20
|
+
|
|
21
|
+
constructor(
|
|
22
|
+
private client: CriticalPathClient,
|
|
23
|
+
public projectId: string,
|
|
24
|
+
initialOptions?: TimelineLadderOptions
|
|
25
|
+
) {
|
|
26
|
+
if (initialOptions?.level) {
|
|
27
|
+
this.level = initialOptions.level;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async setLevel(newLevel: AbstractionLevel) {
|
|
32
|
+
this.level = newLevel;
|
|
33
|
+
await this.fetch();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async fetch(options?: TimelineLadderOptions) {
|
|
37
|
+
this.loading = true;
|
|
38
|
+
this.error = null;
|
|
39
|
+
try {
|
|
40
|
+
this.data = await this.client.getTimelineLadder(this.projectId, {
|
|
41
|
+
level: this.level,
|
|
42
|
+
...options
|
|
43
|
+
});
|
|
44
|
+
} catch (err) {
|
|
45
|
+
this.error = err instanceof Error ? err : new Error(String(err));
|
|
46
|
+
} finally {
|
|
47
|
+
this.loading = false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function createTimelineLadderState(
|
|
53
|
+
client: CriticalPathClient,
|
|
54
|
+
projectId: string,
|
|
55
|
+
initialOptions?: TimelineLadderOptions
|
|
56
|
+
): TimelineLadderState {
|
|
57
|
+
return new TimelineLadderState(client, projectId, initialOptions);
|
|
58
|
+
}
|