@critical-path/svelte 0.17.11 → 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.
Files changed (54) hide show
  1. package/README.md +13 -0
  2. package/dist/activity-state.svelte.d.ts +3 -0
  3. package/dist/activity-state.svelte.d.ts.map +1 -1
  4. package/dist/attachment-state.svelte.d.ts +3 -0
  5. package/dist/attachment-state.svelte.d.ts.map +1 -1
  6. package/dist/comment-state.svelte.d.ts +3 -0
  7. package/dist/comment-state.svelte.d.ts.map +1 -1
  8. package/dist/critical-path-state.svelte.d.ts +3 -0
  9. package/dist/critical-path-state.svelte.d.ts.map +1 -1
  10. package/dist/deliverable-state.svelte.d.ts +3 -0
  11. package/dist/deliverable-state.svelte.d.ts.map +1 -1
  12. package/dist/deliverable-summary-state.svelte.d.ts +3 -0
  13. package/dist/deliverable-summary-state.svelte.d.ts.map +1 -1
  14. package/dist/index.js +645 -551
  15. package/dist/latest-request.d.ts +15 -0
  16. package/dist/latest-request.d.ts.map +1 -0
  17. package/dist/project-state.svelte.d.ts +3 -0
  18. package/dist/project-state.svelte.d.ts.map +1 -1
  19. package/dist/task-metrics-state.svelte.d.ts +3 -0
  20. package/dist/task-metrics-state.svelte.d.ts.map +1 -1
  21. package/dist/task-state.svelte.d.ts +3 -0
  22. package/dist/task-state.svelte.d.ts.map +1 -1
  23. package/dist/task-transitions-state.svelte.d.ts +3 -0
  24. package/dist/task-transitions-state.svelte.d.ts.map +1 -1
  25. package/dist/timeline-ladder-state.svelte.d.ts +3 -0
  26. package/dist/timeline-ladder-state.svelte.d.ts.map +1 -1
  27. package/dist/workflow-state.svelte.d.ts +3 -0
  28. package/dist/workflow-state.svelte.d.ts.map +1 -1
  29. package/dist/workload-state.svelte.d.ts +3 -0
  30. package/dist/workload-state.svelte.d.ts.map +1 -1
  31. package/package.json +10 -6
  32. package/CHANGELOG.md +0 -714
  33. package/dist/index.test.d.ts +0 -2
  34. package/dist/index.test.d.ts.map +0 -1
  35. package/src/activity-state.svelte.ts +0 -193
  36. package/src/attachment-state.svelte.ts +0 -61
  37. package/src/comment-state.svelte.ts +0 -130
  38. package/src/critical-path-state.svelte.ts +0 -33
  39. package/src/deliverable-state.svelte.ts +0 -77
  40. package/src/deliverable-summary-state.svelte.ts +0 -41
  41. package/src/index.test.ts +0 -885
  42. package/src/index.ts +0 -23
  43. package/src/kanban-state.svelte.ts +0 -113
  44. package/src/project-state.svelte.ts +0 -54
  45. package/src/task-metrics-state.svelte.ts +0 -83
  46. package/src/task-state.svelte.ts +0 -195
  47. package/src/task-transitions-state.svelte.ts +0 -36
  48. package/src/timeline-ladder-state.svelte.ts +0 -58
  49. package/src/webmcp-state.svelte.ts +0 -78
  50. package/src/workflow-state.svelte.ts +0 -62
  51. package/src/workload-state.svelte.ts +0 -83
  52. package/tsconfig.json +0 -8
  53. package/vite.config.ts +0 -22
  54. package/vitest.config.ts +0 -6
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
@@ -1,193 +0,0 @@
1
- /// <reference types="svelte" />
2
- import type { CreateAttachmentBody, CreateCommentBody } from '@critical-path/core/schemas';
3
- import type { CriticalPathClient } from '@critical-path/client';
4
- import type { Comment, Attachment } from '@critical-path/core';
5
-
6
- export interface ThreadedCommentWithAttachments extends Comment {
7
- attachments: Attachment[];
8
- replies: ThreadedCommentWithAttachments[];
9
- }
10
-
11
- export class TaskActivityState {
12
- comments = $state<Comment[]>([]);
13
- attachments = $state<Attachment[]>([]);
14
- loading = $state<boolean>(false);
15
- error = $state<Error | null>(null);
16
-
17
- threads = $derived.by(() => {
18
- const map = new Map<string, ThreadedCommentWithAttachments>();
19
- const roots: ThreadedCommentWithAttachments[] = [];
20
-
21
- // Group attachments by commentId
22
- const attachmentsByComment = new Map<string, Attachment[]>();
23
- for (const a of this.attachments) {
24
- if (a.commentId) {
25
- if (!attachmentsByComment.has(a.commentId)) {
26
- attachmentsByComment.set(a.commentId, []);
27
- }
28
- attachmentsByComment.get(a.commentId)!.push(a);
29
- }
30
- }
31
-
32
- for (const c of this.comments) {
33
- map.set(c.id, {
34
- ...c,
35
- attachments: attachmentsByComment.get(c.id) || [],
36
- replies: []
37
- });
38
- }
39
-
40
- for (const c of this.comments) {
41
- const threaded = map.get(c.id)!;
42
- if (c.parentId && map.has(c.parentId)) {
43
- map.get(c.parentId)!.replies.push(threaded);
44
- } else {
45
- roots.push(threaded);
46
- }
47
- }
48
-
49
- return roots;
50
- });
51
-
52
- standaloneAttachments = $derived.by(() => {
53
- return this.attachments.filter((a) => !a.commentId);
54
- });
55
-
56
- constructor(private client: CriticalPathClient, public taskId?: string) {}
57
-
58
- async fetch(taskId?: string) {
59
- const targetTaskId = taskId || this.taskId;
60
- if (!targetTaskId) {
61
- this.comments = [];
62
- this.attachments = [];
63
- return;
64
- }
65
- this.taskId = targetTaskId;
66
- this.loading = true;
67
- this.error = null;
68
- try {
69
- const [comments, attachments] = await Promise.all([
70
- this.client.getComments(targetTaskId),
71
- this.client.getAttachments({ taskId: targetTaskId })
72
- ]);
73
- this.comments = comments;
74
- this.attachments = attachments;
75
- } catch (err) {
76
- this.error = err instanceof Error ? err : new Error(String(err));
77
- } finally {
78
- this.loading = false;
79
- }
80
- }
81
-
82
- async addComment(
83
- input: Omit<CreateCommentBody, 'taskId'>,
84
- attachmentInputs?: Array<Omit<CreateAttachmentBody, 'taskId' | 'commentId'>>
85
- ) {
86
- if (!this.taskId) {
87
- throw new Error('TaskActivityState requires a taskId to add comments.');
88
- }
89
- try {
90
- const comment = await this.client.addComment({ ...input, taskId: this.taskId });
91
- let createdAttachments: Attachment[] = [];
92
-
93
- if (attachmentInputs && attachmentInputs.length > 0) {
94
- createdAttachments = await Promise.all(
95
- attachmentInputs.map((att) =>
96
- this.client.createAttachment({
97
- ...att,
98
- taskId: this.taskId,
99
- commentId: comment.id
100
- })
101
- )
102
- );
103
- }
104
-
105
- this.comments = [...this.comments, comment];
106
- if (createdAttachments.length > 0) {
107
- this.attachments = [...this.attachments, ...createdAttachments];
108
- }
109
- return { comment, attachments: createdAttachments };
110
- } catch (err) {
111
- const errorObj = err instanceof Error ? err : new Error(String(err));
112
- this.error = errorObj;
113
- throw errorObj;
114
- }
115
- }
116
-
117
- async addAttachment(input: Omit<Attachment, 'id' | 'taskId' | 'createdAt' | 'updatedAt'>) {
118
- if (!this.taskId) {
119
- throw new Error('TaskActivityState requires a taskId to add attachments.');
120
- }
121
- try {
122
- const created = await this.client.createAttachment({ ...input, taskId: this.taskId });
123
- this.attachments = [created, ...this.attachments];
124
- return created;
125
- } catch (err) {
126
- const errorObj = err instanceof Error ? err : new Error(String(err));
127
- this.error = errorObj;
128
- throw errorObj;
129
- }
130
- }
131
-
132
- async deleteComment(id: string) {
133
- const previous = this.comments;
134
- this.comments = this.comments.filter((c) => c.id !== id);
135
- try {
136
- await this.client.deleteComment(id);
137
- } catch (err) {
138
- this.comments = previous;
139
- const errorObj = err instanceof Error ? err : new Error(String(err));
140
- this.error = errorObj;
141
- throw errorObj;
142
- }
143
- }
144
-
145
- async deleteAttachment(id: string) {
146
- const previous = this.attachments;
147
- this.attachments = this.attachments.filter((a) => a.id !== id);
148
- try {
149
- await this.client.deleteAttachment(id);
150
- } catch (err) {
151
- this.attachments = previous;
152
- const errorObj = err instanceof Error ? err : new Error(String(err));
153
- this.error = errorObj;
154
- throw errorObj;
155
- }
156
- }
157
-
158
- async addReaction(
159
- commentId: string,
160
- emoji: string
161
- ) {
162
- try {
163
- const payload = { emoji };
164
- const updated = await this.client.addCommentReaction(commentId, payload);
165
- this.comments = this.comments.map((c) => (c.id === commentId ? updated : c));
166
- return updated;
167
- } catch (err) {
168
- const errorObj = err instanceof Error ? err : new Error(String(err));
169
- this.error = errorObj;
170
- throw errorObj;
171
- }
172
- }
173
-
174
- async removeReaction(
175
- commentId: string,
176
- emoji: string
177
- ) {
178
- try {
179
- const payload = { emoji };
180
- const updated = await this.client.removeCommentReaction(commentId, payload);
181
- this.comments = this.comments.map((c) => (c.id === commentId ? updated : c));
182
- return updated;
183
- } catch (err) {
184
- const errorObj = err instanceof Error ? err : new Error(String(err));
185
- this.error = errorObj;
186
- throw errorObj;
187
- }
188
- }
189
- }
190
-
191
- export function createTaskActivityState(client: CriticalPathClient, taskId?: string): TaskActivityState {
192
- return new TaskActivityState(client, taskId);
193
- }
@@ -1,61 +0,0 @@
1
- /// <reference types="svelte" />
2
- import type { CriticalPathClient } from '@critical-path/client';
3
- import type { Attachment } from '@critical-path/core';
4
-
5
- export interface AttachmentFilter {
6
- taskId?: string;
7
- projectId?: string;
8
- commentId?: string;
9
- }
10
-
11
- export class AttachmentState {
12
- data = $state<Attachment[]>([]);
13
- loading = $state<boolean>(false);
14
- error = $state<Error | null>(null);
15
-
16
- constructor(private client: CriticalPathClient, public filter?: AttachmentFilter) {}
17
-
18
- async fetch(filter?: AttachmentFilter) {
19
- if (filter) {
20
- this.filter = filter;
21
- }
22
- this.loading = true;
23
- this.error = null;
24
- try {
25
- this.data = await this.client.getAttachments(this.filter);
26
- } catch (err) {
27
- this.error = err instanceof Error ? err : new Error(String(err));
28
- } finally {
29
- this.loading = false;
30
- }
31
- }
32
-
33
- async createAttachment(input: Omit<Attachment, 'id' | 'createdAt' | 'updatedAt'>) {
34
- try {
35
- const created = await this.client.createAttachment(input);
36
- this.data = [created, ...this.data];
37
- return created;
38
- } catch (err) {
39
- const errorObj = err instanceof Error ? err : new Error(String(err));
40
- this.error = errorObj;
41
- throw errorObj;
42
- }
43
- }
44
-
45
- async deleteAttachment(id: string) {
46
- const previous = this.data;
47
- this.data = this.data.filter((a) => a.id !== id);
48
- try {
49
- await this.client.deleteAttachment(id);
50
- } catch (err) {
51
- this.data = previous;
52
- const errorObj = err instanceof Error ? err : new Error(String(err));
53
- this.error = errorObj;
54
- throw errorObj;
55
- }
56
- }
57
- }
58
-
59
- export function createAttachmentState(client: CriticalPathClient, initialFilter?: AttachmentFilter): AttachmentState {
60
- return new AttachmentState(client, initialFilter);
61
- }
@@ -1,130 +0,0 @@
1
- /// <reference types="svelte" />
2
- import type { CreateCommentBody, UpdateCommentBody } from '@critical-path/core/schemas';
3
- import type { CriticalPathClient } from '@critical-path/client';
4
- import type { Comment } from '@critical-path/core';
5
-
6
- export interface ThreadedComment extends Comment {
7
- replies: ThreadedComment[];
8
- }
9
-
10
- export class CommentState {
11
- data = $state<Comment[]>([]);
12
- loading = $state<boolean>(false);
13
- error = $state<Error | null>(null);
14
-
15
- threads = $derived.by(() => {
16
- const map = new Map<string, ThreadedComment>();
17
- const roots: ThreadedComment[] = [];
18
-
19
- for (const c of this.data) {
20
- map.set(c.id, { ...c, replies: [] });
21
- }
22
-
23
- for (const c of this.data) {
24
- const threaded = map.get(c.id)!;
25
- if (c.parentId && map.has(c.parentId)) {
26
- map.get(c.parentId)!.replies.push(threaded);
27
- } else {
28
- roots.push(threaded);
29
- }
30
- }
31
-
32
- return roots;
33
- });
34
-
35
- constructor(private client: CriticalPathClient, public taskId?: string) {}
36
-
37
- async fetch(taskId?: string) {
38
- const targetTaskId = taskId || this.taskId;
39
- if (!targetTaskId) {
40
- this.data = [];
41
- return;
42
- }
43
- this.taskId = targetTaskId;
44
- this.loading = true;
45
- this.error = null;
46
- try {
47
- this.data = await this.client.getComments(targetTaskId);
48
- } catch (err) {
49
- this.error = err instanceof Error ? err : new Error(String(err));
50
- } finally {
51
- this.loading = false;
52
- }
53
- }
54
-
55
- async addComment(input: Omit<CreateCommentBody, 'taskId'>) {
56
- if (!this.taskId) {
57
- throw new Error('CommentState requires a taskId to add comments.');
58
- }
59
- try {
60
- const created = await this.client.addComment({ ...input, taskId: this.taskId });
61
- this.data = [...this.data, created];
62
- return created;
63
- } catch (err) {
64
- const errorObj = err instanceof Error ? err : new Error(String(err));
65
- this.error = errorObj;
66
- throw errorObj;
67
- }
68
- }
69
-
70
- async updateComment(id: string, updates: UpdateCommentBody) {
71
- try {
72
- const updated = await this.client.updateComment(id, updates);
73
- this.data = this.data.map((c) => (c.id === id ? updated : c));
74
- return updated;
75
- } catch (err) {
76
- const errorObj = err instanceof Error ? err : new Error(String(err));
77
- this.error = errorObj;
78
- throw errorObj;
79
- }
80
- }
81
-
82
- async deleteComment(id: string) {
83
- const previous = this.data;
84
- this.data = this.data.filter((c) => c.id !== id);
85
- try {
86
- await this.client.deleteComment(id);
87
- } catch (err) {
88
- this.data = previous;
89
- const errorObj = err instanceof Error ? err : new Error(String(err));
90
- this.error = errorObj;
91
- throw errorObj;
92
- }
93
- }
94
-
95
- async addReaction(
96
- commentId: string,
97
- emoji: string
98
- ) {
99
- try {
100
- const payload = { emoji };
101
- const updated = await this.client.addCommentReaction(commentId, payload);
102
- this.data = this.data.map((c) => (c.id === commentId ? updated : c));
103
- return updated;
104
- } catch (err) {
105
- const errorObj = err instanceof Error ? err : new Error(String(err));
106
- this.error = errorObj;
107
- throw errorObj;
108
- }
109
- }
110
-
111
- async removeReaction(
112
- commentId: string,
113
- emoji: string
114
- ) {
115
- try {
116
- const payload = { emoji };
117
- const updated = await this.client.removeCommentReaction(commentId, payload);
118
- this.data = this.data.map((c) => (c.id === commentId ? updated : c));
119
- return updated;
120
- } catch (err) {
121
- const errorObj = err instanceof Error ? err : new Error(String(err));
122
- this.error = errorObj;
123
- throw errorObj;
124
- }
125
- }
126
- }
127
-
128
- export function createCommentState(client: CriticalPathClient, taskId?: string): CommentState {
129
- return new CommentState(client, taskId);
130
- }
@@ -1,33 +0,0 @@
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
- }
@@ -1,77 +0,0 @@
1
- /// <reference types="svelte" />
2
- import type { UpdateDeliverableBody } from '@critical-path/core/schemas';
3
- import type { CriticalPathClient } from '@critical-path/client';
4
- import type { Deliverable, DeliverableSummary, CreateDeliverableInput } from '@critical-path/core';
5
-
6
- export class DeliverableState {
7
- data = $state<Deliverable[]>([]);
8
- loading = $state<boolean>(false);
9
- error = $state<Error | null>(null);
10
-
11
- constructor(private client: CriticalPathClient, public projectId?: string) {}
12
-
13
- async fetch(projectId?: string) {
14
- if (projectId) {
15
- this.projectId = projectId;
16
- }
17
- if (!this.projectId) return;
18
-
19
- this.loading = true;
20
- this.error = null;
21
- try {
22
- this.data = await this.client.getDeliverables(this.projectId);
23
- } catch (err) {
24
- this.error = err instanceof Error ? err : new Error(String(err));
25
- } finally {
26
- this.loading = false;
27
- }
28
- }
29
-
30
- async createDeliverable(input: CreateDeliverableInput) {
31
- try {
32
- const created = await this.client.createDeliverable(input);
33
- this.data = [...this.data, created];
34
- return created;
35
- } catch (err) {
36
- const errorObj = err instanceof Error ? err : new Error(String(err));
37
- this.error = errorObj;
38
- throw errorObj;
39
- }
40
- }
41
-
42
- async updateDeliverable(id: string, updates: UpdateDeliverableBody) {
43
- const previous = this.data;
44
- this.data = this.data.map((d) => (d.id === id ? { ...d, ...updates } : d));
45
- try {
46
- const updated = await this.client.updateDeliverable(id, updates);
47
- this.data = this.data.map((d) => (d.id === id ? updated : d));
48
- return updated;
49
- } catch (err) {
50
- this.data = previous;
51
- const errorObj = err instanceof Error ? err : new Error(String(err));
52
- this.error = errorObj;
53
- throw errorObj;
54
- }
55
- }
56
-
57
- async deleteDeliverable(id: string) {
58
- const previous = this.data;
59
- this.data = this.data.filter((d) => d.id !== id);
60
- try {
61
- await this.client.deleteDeliverable(id);
62
- } catch (err) {
63
- this.data = previous;
64
- const errorObj = err instanceof Error ? err : new Error(String(err));
65
- this.error = errorObj;
66
- throw errorObj;
67
- }
68
- }
69
-
70
- async getSummary(deliverableId: string): Promise<DeliverableSummary> {
71
- return this.client.getDeliverableSummary(deliverableId);
72
- }
73
- }
74
-
75
- export function createDeliverableState(client: CriticalPathClient, initialProjectId?: string): DeliverableState {
76
- return new DeliverableState(client, initialProjectId);
77
- }
@@ -1,41 +0,0 @@
1
- /// <reference types="svelte" />
2
- import type { CriticalPathClient } from '@critical-path/client';
3
- import type { DeliverableSummary } from '@critical-path/core';
4
-
5
- export class DeliverableSummaryState {
6
- summary = $state<DeliverableSummary | null>(null);
7
- loading = $state<boolean>(false);
8
- error = $state<Error | null>(null);
9
-
10
- get data(): DeliverableSummary | null {
11
- return this.summary;
12
- }
13
-
14
- constructor(private client: CriticalPathClient, public deliverableId?: string) {}
15
-
16
- async fetch(deliverableId?: string) {
17
- const targetId = deliverableId || this.deliverableId;
18
- if (!targetId) {
19
- this.summary = null;
20
- this.loading = false;
21
- return;
22
- }
23
- this.deliverableId = targetId;
24
- this.loading = true;
25
- this.error = null;
26
- try {
27
- this.summary = await this.client.getDeliverableSummary(targetId);
28
- } catch (err) {
29
- this.error = err instanceof Error ? err : new Error(String(err));
30
- } finally {
31
- this.loading = false;
32
- }
33
- }
34
- }
35
-
36
- export function createDeliverableSummaryState(
37
- client: CriticalPathClient,
38
- deliverableId?: string
39
- ): DeliverableSummaryState {
40
- return new DeliverableSummaryState(client, deliverableId);
41
- }