@critical-path/svelte 0.18.0 → 0.18.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/package.json +10 -6
- package/CHANGELOG.md +0 -730
- package/dist/cancellation.test.d.ts +0 -2
- package/dist/cancellation.test.d.ts.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/src/activity-state.svelte.ts +0 -203
- package/src/attachment-state.svelte.ts +0 -71
- package/src/cancellation.test.ts +0 -43
- package/src/comment-state.svelte.ts +0 -140
- package/src/critical-path-state.svelte.ts +0 -43
- package/src/deliverable-state.svelte.ts +0 -87
- package/src/deliverable-summary-state.svelte.ts +0 -51
- package/src/index.test.ts +0 -885
- package/src/index.ts +0 -23
- package/src/kanban-state.svelte.ts +0 -113
- package/src/latest-request.ts +0 -24
- package/src/project-state.svelte.ts +0 -64
- package/src/task-metrics-state.svelte.ts +0 -103
- package/src/task-state.svelte.ts +0 -205
- package/src/task-transitions-state.svelte.ts +0 -46
- package/src/timeline-ladder-state.svelte.ts +0 -68
- package/src/webmcp-state.svelte.ts +0 -78
- package/src/workflow-state.svelte.ts +0 -72
- package/src/workload-state.svelte.ts +0 -93
- package/tsconfig.json +0 -8
- package/vite.config.ts +0 -22
- package/vitest.config.ts +0 -6
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { CriticalPathClient } from '@critical-path/client';
|
|
2
|
-
import { registerWebMcpTools, type WebMcpRegistryHandle } from '@critical-path/mcp/web';
|
|
3
|
-
|
|
4
|
-
export interface WebMcpStateOptions {
|
|
5
|
-
projectId?: string;
|
|
6
|
-
tools?: string[];
|
|
7
|
-
autoRegister?: boolean;
|
|
8
|
-
document?: any;
|
|
9
|
-
navigator?: any;
|
|
10
|
-
window?: any;
|
|
11
|
-
onToolExecuted?: (toolName: string, input: any, result: any) => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class WebMcpState {
|
|
15
|
-
registered = $state<boolean>(false);
|
|
16
|
-
activeProjectId = $state<string | undefined>(undefined);
|
|
17
|
-
tools = $state<string[]>([]);
|
|
18
|
-
error = $state<Error | null>(null);
|
|
19
|
-
|
|
20
|
-
private handle: WebMcpRegistryHandle | null = null;
|
|
21
|
-
private abortController: AbortController | null = null;
|
|
22
|
-
|
|
23
|
-
constructor(private client: CriticalPathClient, private options: WebMcpStateOptions = {}) {
|
|
24
|
-
this.activeProjectId = options.projectId;
|
|
25
|
-
if (options.autoRegister ?? true) {
|
|
26
|
-
this.register();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
register(): void {
|
|
31
|
-
if (this.registered) return;
|
|
32
|
-
this.error = null;
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
this.abortController = new AbortController();
|
|
36
|
-
this.handle = registerWebMcpTools({
|
|
37
|
-
client: this.client,
|
|
38
|
-
projectId: this.activeProjectId,
|
|
39
|
-
tools: this.options.tools,
|
|
40
|
-
signal: this.abortController.signal,
|
|
41
|
-
document: this.options.document,
|
|
42
|
-
navigator: this.options.navigator,
|
|
43
|
-
window: this.options.window,
|
|
44
|
-
onToolExecuted: (name, input, result) => {
|
|
45
|
-
this.options.onToolExecuted?.(name, input, result);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
this.tools = this.handle.getRegisteredTools().map((t) => t.name);
|
|
49
|
-
this.registered = true;
|
|
50
|
-
} catch (err) {
|
|
51
|
-
this.error = err instanceof Error ? err : new Error(String(err));
|
|
52
|
-
this.registered = false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
unregister(): void {
|
|
57
|
-
if (!this.registered) return;
|
|
58
|
-
this.abortController?.abort();
|
|
59
|
-
this.handle?.unregister();
|
|
60
|
-
this.handle = null;
|
|
61
|
-
this.abortController = null;
|
|
62
|
-
this.registered = false;
|
|
63
|
-
this.tools = [];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
setProjectId(projectId?: string): void {
|
|
67
|
-
if (this.activeProjectId === projectId) return;
|
|
68
|
-
this.activeProjectId = projectId;
|
|
69
|
-
if (this.registered) {
|
|
70
|
-
this.unregister();
|
|
71
|
-
this.register();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function createWebMcpState(client: CriticalPathClient, options?: WebMcpStateOptions): WebMcpState {
|
|
77
|
-
return new WebMcpState(client, options);
|
|
78
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/// <reference types="svelte" />
|
|
2
|
-
import type { CriticalPathClient } from '@critical-path/client';
|
|
3
|
-
import type { Workflow } from '@critical-path/core';
|
|
4
|
-
import { LatestRequest } from './latest-request.js';
|
|
5
|
-
|
|
6
|
-
export class WorkflowState {
|
|
7
|
-
#fetchRequest = new LatestRequest();
|
|
8
|
-
data = $state<Workflow[]>([]);
|
|
9
|
-
loading = $state<boolean>(false);
|
|
10
|
-
error = $state<Error | null>(null);
|
|
11
|
-
|
|
12
|
-
constructor(private client: CriticalPathClient) {}
|
|
13
|
-
|
|
14
|
-
async fetch() {
|
|
15
|
-
const { api, signal } = this.#fetchRequest.begin(this.client);
|
|
16
|
-
this.loading = true;
|
|
17
|
-
this.error = null;
|
|
18
|
-
try {
|
|
19
|
-
this.data = await api.getWorkflows();
|
|
20
|
-
if (signal.aborted) return;
|
|
21
|
-
} catch (err) {
|
|
22
|
-
if (signal.aborted) return;
|
|
23
|
-
this.error = err instanceof Error ? err : new Error(String(err));
|
|
24
|
-
} finally {
|
|
25
|
-
if (!signal.aborted) this.loading = false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async createWorkflow(input: Omit<Workflow, 'id' | 'createdAt' | 'updatedAt'>) {
|
|
30
|
-
try {
|
|
31
|
-
const created = await this.client.createWorkflow(input);
|
|
32
|
-
this.data = [...this.data, created];
|
|
33
|
-
return created;
|
|
34
|
-
} catch (err) {
|
|
35
|
-
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
36
|
-
this.error = errorObj;
|
|
37
|
-
throw errorObj;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async updateWorkflow(id: string, updates: Partial<Workflow>) {
|
|
42
|
-
try {
|
|
43
|
-
const updated = await this.client.updateWorkflow(id, updates);
|
|
44
|
-
this.data = this.data.map((w) => (w.id === id ? updated : w));
|
|
45
|
-
return updated;
|
|
46
|
-
} catch (err) {
|
|
47
|
-
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
48
|
-
this.error = errorObj;
|
|
49
|
-
throw errorObj;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async deleteWorkflow(id: string) {
|
|
54
|
-
try {
|
|
55
|
-
await this.client.deleteWorkflow(id);
|
|
56
|
-
this.data = this.data.filter((w) => w.id !== id);
|
|
57
|
-
} catch (err) {
|
|
58
|
-
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
59
|
-
this.error = errorObj;
|
|
60
|
-
throw errorObj;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Cancels in-flight requests, e.g. from a component's onDestroy. */
|
|
65
|
-
destroy() {
|
|
66
|
-
this.#fetchRequest.cancel();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function createWorkflowState(client: CriticalPathClient): WorkflowState {
|
|
71
|
-
return new WorkflowState(client);
|
|
72
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/// <reference types="svelte" />
|
|
2
|
-
import type { CriticalPathClient } from '@critical-path/client';
|
|
3
|
-
import { LatestRequest } from './latest-request.js';
|
|
4
|
-
import type {
|
|
5
|
-
WorkloadDistribution,
|
|
6
|
-
WorkloadDistributionOptions,
|
|
7
|
-
WorkloadInterval,
|
|
8
|
-
WorkloadGroupBy,
|
|
9
|
-
WorkloadMetric,
|
|
10
|
-
WorkloadBucket
|
|
11
|
-
} from '@critical-path/core';
|
|
12
|
-
|
|
13
|
-
export class WorkloadState {
|
|
14
|
-
#fetchRequest = new LatestRequest();
|
|
15
|
-
data = $state<WorkloadDistribution | null>(null);
|
|
16
|
-
interval = $state<WorkloadInterval>('week');
|
|
17
|
-
groupBy = $state<WorkloadGroupBy>('assignee');
|
|
18
|
-
metric = $state<WorkloadMetric>('blended');
|
|
19
|
-
loading = $state<boolean>(false);
|
|
20
|
-
error = $state<Error | null>(null);
|
|
21
|
-
|
|
22
|
-
buckets = $derived<WorkloadBucket[]>(this.data?.buckets ?? []);
|
|
23
|
-
seriesKeys = $derived<string[]>(this.data?.seriesKeys ?? []);
|
|
24
|
-
seriesLabels = $derived<Record<string, string>>(this.data?.seriesLabels ?? {});
|
|
25
|
-
totalHours = $derived<number>(this.data?.totalHours ?? 0);
|
|
26
|
-
totalCapacity = $derived<number>(this.data?.totalCapacity ?? 0);
|
|
27
|
-
averageUtilization = $derived<number | undefined>(this.data?.averageUtilization);
|
|
28
|
-
|
|
29
|
-
constructor(
|
|
30
|
-
private client: CriticalPathClient,
|
|
31
|
-
public projectId?: string,
|
|
32
|
-
public initialOptions?: WorkloadDistributionOptions
|
|
33
|
-
) {
|
|
34
|
-
if (initialOptions?.interval) {
|
|
35
|
-
this.interval = initialOptions.interval;
|
|
36
|
-
}
|
|
37
|
-
if (initialOptions?.groupBy) {
|
|
38
|
-
this.groupBy = initialOptions.groupBy;
|
|
39
|
-
}
|
|
40
|
-
if (initialOptions?.metric) {
|
|
41
|
-
this.metric = initialOptions.metric;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async setInterval(newInterval: WorkloadInterval) {
|
|
46
|
-
this.interval = newInterval;
|
|
47
|
-
await this.fetch();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async setGroupBy(newGroupBy: WorkloadGroupBy) {
|
|
51
|
-
this.groupBy = newGroupBy;
|
|
52
|
-
await this.fetch();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async setMetric(newMetric: WorkloadMetric) {
|
|
56
|
-
this.metric = newMetric;
|
|
57
|
-
await this.fetch();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async fetch(options?: WorkloadDistributionOptions) {
|
|
61
|
-
const { api, signal } = this.#fetchRequest.begin(this.client);
|
|
62
|
-
this.loading = true;
|
|
63
|
-
this.error = null;
|
|
64
|
-
try {
|
|
65
|
-
this.data = await api.getWorkloadDistribution(this.projectId, {
|
|
66
|
-
...this.initialOptions,
|
|
67
|
-
interval: this.interval,
|
|
68
|
-
groupBy: this.groupBy,
|
|
69
|
-
metric: this.metric,
|
|
70
|
-
...options
|
|
71
|
-
});
|
|
72
|
-
if (signal.aborted) return;
|
|
73
|
-
} catch (err) {
|
|
74
|
-
if (signal.aborted) return;
|
|
75
|
-
this.error = err instanceof Error ? err : new Error(String(err));
|
|
76
|
-
} finally {
|
|
77
|
-
if (!signal.aborted) this.loading = false;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** Cancels in-flight requests, e.g. from a component's onDestroy. */
|
|
82
|
-
destroy() {
|
|
83
|
-
this.#fetchRequest.cancel();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function createWorkloadState(
|
|
88
|
-
client: CriticalPathClient,
|
|
89
|
-
projectId?: string,
|
|
90
|
-
initialOptions?: WorkloadDistributionOptions
|
|
91
|
-
): WorkloadState {
|
|
92
|
-
return new WorkloadState(client, projectId, initialOptions);
|
|
93
|
-
}
|
package/tsconfig.json
DELETED
package/vite.config.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
3
|
-
import { resolve } from 'node:path';
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
plugins: [svelte()],
|
|
7
|
-
build: {
|
|
8
|
-
lib: {
|
|
9
|
-
entry: resolve(import.meta.dirname, 'src/index.ts'),
|
|
10
|
-
formats: ['es'],
|
|
11
|
-
fileName: () => 'index.js'
|
|
12
|
-
},
|
|
13
|
-
rollupOptions: {
|
|
14
|
-
external: [
|
|
15
|
-
'@critical-path/client',
|
|
16
|
-
'@critical-path/core',
|
|
17
|
-
'svelte',
|
|
18
|
-
/^svelte\//
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
});
|