@critical-path/svelte 0.7.0 → 0.9.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.
- package/CHANGELOG.md +35 -0
- package/dist/deliverable-state.svelte.d.ts +17 -0
- package/dist/deliverable-state.svelte.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +85 -2
- package/package.json +3 -3
- package/src/deliverable-state.svelte.ts +76 -0
- package/src/index.test.ts +58 -2
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @critical-path/svelte
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5a5930f: Add first-class Deliverable entity, Creative Workflow presets, and reactive UI bindings:
|
|
8
|
+
- `@critical-path/core`: Added `Deliverable` entity, `DeliverableSummary` rollup computation, `DEFAULT_CREATIVE_WORKFLOW` preset, `deliverableId` on tasks, store implementations (InMemory, SQLite, Firebase), domain events, and webhook integration.
|
|
9
|
+
- `@critical-path/server`: Added RESTful API endpoints for `/deliverables` and `/deliverables/:id/summary`.
|
|
10
|
+
- `@critical-path/client`: Added deliverable management and summary methods to `CriticalPathClient`.
|
|
11
|
+
- `@critical-path/react`: Added `useDeliverables` and `useDeliverableSummary` React hooks.
|
|
12
|
+
- `@critical-path/svelte`: Added `DeliverableState` and `createDeliverableState` Svelte 5 Runes state management.
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [5a5930f]
|
|
17
|
+
- @critical-path/core@0.12.0
|
|
18
|
+
- @critical-path/client@0.7.0
|
|
19
|
+
|
|
20
|
+
## 0.8.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- 55549e9: Support @mentions in comments with extraction and segmentation utilities
|
|
25
|
+
|
|
26
|
+
- Add `mentions?: string[]` to `Comment` interface
|
|
27
|
+
- Add `extractMentions` and `parseMentionSegments` utilities for mention parsing and UI rendering
|
|
28
|
+
- Auto-extract and populate mentions during `addComment` and `updateComment` in the engine
|
|
29
|
+
- Update SQLite comments schema with `mentions` column and migration
|
|
30
|
+
- Preserve and pass through mentions in server routes, client SDK, and Svelte bindings
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [55549e9]
|
|
35
|
+
- @critical-path/core@0.11.0
|
|
36
|
+
- @critical-path/client@0.6.0
|
|
37
|
+
|
|
3
38
|
## 0.7.0
|
|
4
39
|
|
|
5
40
|
### Minor Changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CriticalPathClient } from '@critical-path/client';
|
|
2
|
+
import type { Deliverable, DeliverableSummary, CreateDeliverableInput } from '@critical-path/core';
|
|
3
|
+
export declare class DeliverableState {
|
|
4
|
+
private client;
|
|
5
|
+
projectId?: string | undefined;
|
|
6
|
+
data: Deliverable[];
|
|
7
|
+
loading: boolean;
|
|
8
|
+
error: Error | null;
|
|
9
|
+
constructor(client: CriticalPathClient, projectId?: string | undefined);
|
|
10
|
+
fetch(projectId?: string): Promise<void>;
|
|
11
|
+
createDeliverable(input: CreateDeliverableInput): Promise<Deliverable>;
|
|
12
|
+
updateDeliverable(id: string, updates: Partial<Deliverable>): Promise<Deliverable>;
|
|
13
|
+
deleteDeliverable(id: string): Promise<void>;
|
|
14
|
+
getSummary(deliverableId: string): Promise<DeliverableSummary>;
|
|
15
|
+
}
|
|
16
|
+
export declare function createDeliverableState(client: CriticalPathClient, initialProjectId?: string): DeliverableState;
|
|
17
|
+
//# sourceMappingURL=deliverable-state.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deliverable-state.svelte.d.ts","sourceRoot":"","sources":["../src/deliverable-state.svelte.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAEnG,qBAAa,gBAAgB;IAKf,OAAO,CAAC,MAAM;IAA6B,SAAS,CAAC,EAAE,MAAM;IAJzE,IAAI,gBAA6B;IACjC,OAAO,UAA0B;IACjC,KAAK,eAA8B;gBAEf,MAAM,EAAE,kBAAkB,EAAS,SAAS,CAAC,EAAE,MAAM,YAAA;IAEnE,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM;IAiBxB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB;IAY/C,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC;IAe3D,iBAAiB,CAAC,EAAE,EAAE,MAAM;IAa5B,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAGrE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAE9G"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE/E,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,aAAa,GAAG,kBAAkB,CAEnF;AAED,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE/E,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,aAAa,GAAG,kBAAkB,CAEnF;AAED,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -601,9 +601,92 @@ function p(e, t) {
|
|
|
601
601
|
return new f(e, t);
|
|
602
602
|
}
|
|
603
603
|
//#endregion
|
|
604
|
+
//#region src/deliverable-state.svelte.ts
|
|
605
|
+
var m = class {
|
|
606
|
+
client;
|
|
607
|
+
projectId;
|
|
608
|
+
#e = t.state(t.proxy([]));
|
|
609
|
+
get data() {
|
|
610
|
+
return t.get(this.#e);
|
|
611
|
+
}
|
|
612
|
+
set data(e) {
|
|
613
|
+
t.set(this.#e, e, !0);
|
|
614
|
+
}
|
|
615
|
+
#t = t.state(!1);
|
|
616
|
+
get loading() {
|
|
617
|
+
return t.get(this.#t);
|
|
618
|
+
}
|
|
619
|
+
set loading(e) {
|
|
620
|
+
t.set(this.#t, e, !0);
|
|
621
|
+
}
|
|
622
|
+
#n = t.state(null);
|
|
623
|
+
get error() {
|
|
624
|
+
return t.get(this.#n);
|
|
625
|
+
}
|
|
626
|
+
set error(e) {
|
|
627
|
+
t.set(this.#n, e, !0);
|
|
628
|
+
}
|
|
629
|
+
constructor(e, t) {
|
|
630
|
+
this.client = e, this.projectId = t;
|
|
631
|
+
}
|
|
632
|
+
async fetch(e) {
|
|
633
|
+
if (e && (this.projectId = e), this.projectId) {
|
|
634
|
+
this.loading = !0, this.error = null;
|
|
635
|
+
try {
|
|
636
|
+
this.data = await this.client.getDeliverables(this.projectId);
|
|
637
|
+
} catch (e) {
|
|
638
|
+
this.error = e instanceof Error ? e : Error(String(e));
|
|
639
|
+
} finally {
|
|
640
|
+
this.loading = !1;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
async createDeliverable(e) {
|
|
645
|
+
try {
|
|
646
|
+
let t = await this.client.createDeliverable(e);
|
|
647
|
+
return this.data = [...this.data, t], t;
|
|
648
|
+
} catch (e) {
|
|
649
|
+
let t = e instanceof Error ? e : Error(String(e));
|
|
650
|
+
throw this.error = t, t;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
async updateDeliverable(e, t) {
|
|
654
|
+
let n = this.data;
|
|
655
|
+
this.data = this.data.map((n) => n.id === e ? {
|
|
656
|
+
...n,
|
|
657
|
+
...t
|
|
658
|
+
} : n);
|
|
659
|
+
try {
|
|
660
|
+
let n = await this.client.updateDeliverable(e, t);
|
|
661
|
+
return this.data = this.data.map((t) => t.id === e ? n : t), n;
|
|
662
|
+
} catch (e) {
|
|
663
|
+
this.data = n;
|
|
664
|
+
let t = e instanceof Error ? e : Error(String(e));
|
|
665
|
+
throw this.error = t, t;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
async deleteDeliverable(e) {
|
|
669
|
+
let t = this.data;
|
|
670
|
+
this.data = this.data.filter((t) => t.id !== e);
|
|
671
|
+
try {
|
|
672
|
+
await this.client.deleteDeliverable(e);
|
|
673
|
+
} catch (e) {
|
|
674
|
+
this.data = t;
|
|
675
|
+
let n = e instanceof Error ? e : Error(String(e));
|
|
676
|
+
throw this.error = n, n;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
async getSummary(e) {
|
|
680
|
+
return this.client.getDeliverableSummary(e);
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
function h(e, t) {
|
|
684
|
+
return new m(e, t);
|
|
685
|
+
}
|
|
686
|
+
//#endregion
|
|
604
687
|
//#region src/index.ts
|
|
605
|
-
function
|
|
688
|
+
function g(t) {
|
|
606
689
|
return new e(t);
|
|
607
690
|
}
|
|
608
691
|
//#endregion
|
|
609
|
-
export { u as AttachmentState, c as CommentState, n as ProjectState, f as TaskActivityState, i as TaskState, o as WorkflowState, d as createAttachmentState, l as createCommentState,
|
|
692
|
+
export { u as AttachmentState, c as CommentState, m as DeliverableState, n as ProjectState, f as TaskActivityState, i as TaskState, o as WorkflowState, d as createAttachmentState, l as createCommentState, g as createCriticalPathClient, h as createDeliverableState, r as createProjectState, p as createTaskActivityState, a as createTaskState, s as createWorkflowState };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@critical-path/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
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,8 +18,8 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@critical-path/client": "0.
|
|
22
|
-
"@critical-path/core": "0.
|
|
21
|
+
"@critical-path/client": "0.7.0",
|
|
22
|
+
"@critical-path/core": "0.12.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"svelte": "^5.0.0"
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import type { CriticalPathClient } from '@critical-path/client';
|
|
3
|
+
import type { Deliverable, DeliverableSummary, CreateDeliverableInput } from '@critical-path/core';
|
|
4
|
+
|
|
5
|
+
export class DeliverableState {
|
|
6
|
+
data = $state<Deliverable[]>([]);
|
|
7
|
+
loading = $state<boolean>(false);
|
|
8
|
+
error = $state<Error | null>(null);
|
|
9
|
+
|
|
10
|
+
constructor(private client: CriticalPathClient, public projectId?: string) {}
|
|
11
|
+
|
|
12
|
+
async fetch(projectId?: string) {
|
|
13
|
+
if (projectId) {
|
|
14
|
+
this.projectId = projectId;
|
|
15
|
+
}
|
|
16
|
+
if (!this.projectId) return;
|
|
17
|
+
|
|
18
|
+
this.loading = true;
|
|
19
|
+
this.error = null;
|
|
20
|
+
try {
|
|
21
|
+
this.data = await this.client.getDeliverables(this.projectId);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
this.error = err instanceof Error ? err : new Error(String(err));
|
|
24
|
+
} finally {
|
|
25
|
+
this.loading = false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async createDeliverable(input: CreateDeliverableInput) {
|
|
30
|
+
try {
|
|
31
|
+
const created = await this.client.createDeliverable(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 updateDeliverable(id: string, updates: Partial<Deliverable>) {
|
|
42
|
+
const previous = this.data;
|
|
43
|
+
this.data = this.data.map((d) => (d.id === id ? { ...d, ...updates } : d));
|
|
44
|
+
try {
|
|
45
|
+
const updated = await this.client.updateDeliverable(id, updates);
|
|
46
|
+
this.data = this.data.map((d) => (d.id === id ? updated : d));
|
|
47
|
+
return updated;
|
|
48
|
+
} catch (err) {
|
|
49
|
+
this.data = previous;
|
|
50
|
+
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
51
|
+
this.error = errorObj;
|
|
52
|
+
throw errorObj;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async deleteDeliverable(id: string) {
|
|
57
|
+
const previous = this.data;
|
|
58
|
+
this.data = this.data.filter((d) => d.id !== id);
|
|
59
|
+
try {
|
|
60
|
+
await this.client.deleteDeliverable(id);
|
|
61
|
+
} catch (err) {
|
|
62
|
+
this.data = previous;
|
|
63
|
+
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
64
|
+
this.error = errorObj;
|
|
65
|
+
throw errorObj;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async getSummary(deliverableId: string): Promise<DeliverableSummary> {
|
|
70
|
+
return this.client.getDeliverableSummary(deliverableId);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function createDeliverableState(client: CriticalPathClient, initialProjectId?: string): DeliverableState {
|
|
75
|
+
return new DeliverableState(client, initialProjectId);
|
|
76
|
+
}
|
package/src/index.test.ts
CHANGED
|
@@ -12,10 +12,12 @@ import {
|
|
|
12
12
|
AttachmentState,
|
|
13
13
|
createAttachmentState,
|
|
14
14
|
TaskActivityState,
|
|
15
|
-
createTaskActivityState
|
|
15
|
+
createTaskActivityState,
|
|
16
|
+
DeliverableState,
|
|
17
|
+
createDeliverableState
|
|
16
18
|
} from './index.js';
|
|
17
19
|
import type { CriticalPathClient } from '@critical-path/client';
|
|
18
|
-
import type { Project, Task, Workflow, Comment, Attachment } from '@critical-path/core';
|
|
20
|
+
import type { Project, Task, Workflow, Comment, Attachment, Deliverable, DeliverableSummary } from '@critical-path/core';
|
|
19
21
|
|
|
20
22
|
describe('@critical-path/svelte Svelte 5 Runes Test Suite', () => {
|
|
21
23
|
it('exports client factory and Svelte 5 Runes state factories', () => {
|
|
@@ -26,12 +28,14 @@ describe('@critical-path/svelte Svelte 5 Runes Test Suite', () => {
|
|
|
26
28
|
expect(createCommentState).toBeDefined();
|
|
27
29
|
expect(createAttachmentState).toBeDefined();
|
|
28
30
|
expect(createTaskActivityState).toBeDefined();
|
|
31
|
+
expect(createDeliverableState).toBeDefined();
|
|
29
32
|
expect(ProjectState).toBeDefined();
|
|
30
33
|
expect(TaskState).toBeDefined();
|
|
31
34
|
expect(WorkflowState).toBeDefined();
|
|
32
35
|
expect(CommentState).toBeDefined();
|
|
33
36
|
expect(AttachmentState).toBeDefined();
|
|
34
37
|
expect(TaskActivityState).toBeDefined();
|
|
38
|
+
expect(DeliverableState).toBeDefined();
|
|
35
39
|
});
|
|
36
40
|
|
|
37
41
|
describe('WorkflowState', () => {
|
|
@@ -352,5 +356,57 @@ describe('@critical-path/svelte Svelte 5 Runes Test Suite', () => {
|
|
|
352
356
|
expect(activityState.threads[0].attachments).toEqual([]);
|
|
353
357
|
});
|
|
354
358
|
});
|
|
359
|
+
|
|
360
|
+
describe('DeliverableState', () => {
|
|
361
|
+
it('fetches, creates, updates, and deletes deliverables and gets summary', async () => {
|
|
362
|
+
const mockDeliverable: Deliverable = {
|
|
363
|
+
id: 'deliv_1',
|
|
364
|
+
projectId: 'proj_1',
|
|
365
|
+
title: 'Commercial Cut 30s',
|
|
366
|
+
status: 'planned',
|
|
367
|
+
outputUrls: [],
|
|
368
|
+
createdAt: '2026-01-01',
|
|
369
|
+
updatedAt: '2026-01-01'
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
const mockSummary: DeliverableSummary = {
|
|
373
|
+
deliverable: mockDeliverable,
|
|
374
|
+
totalTasks: 2,
|
|
375
|
+
completedTasks: 1,
|
|
376
|
+
activeTasks: 1,
|
|
377
|
+
progressPercentage: 50,
|
|
378
|
+
estimatedHours: 10,
|
|
379
|
+
loggedHours: 5
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
const mockClient = {
|
|
383
|
+
getDeliverables: vi.fn().mockResolvedValue([mockDeliverable]),
|
|
384
|
+
createDeliverable: vi.fn().mockResolvedValue(mockDeliverable),
|
|
385
|
+
updateDeliverable: vi.fn().mockResolvedValue({ ...mockDeliverable, status: 'delivered' }),
|
|
386
|
+
deleteDeliverable: vi.fn().mockResolvedValue(true),
|
|
387
|
+
getDeliverableSummary: vi.fn().mockResolvedValue(mockSummary)
|
|
388
|
+
} as unknown as CriticalPathClient;
|
|
389
|
+
|
|
390
|
+
const state = createDeliverableState(mockClient, 'proj_1');
|
|
391
|
+
await state.fetch();
|
|
392
|
+
expect(state.data).toEqual([mockDeliverable]);
|
|
393
|
+
|
|
394
|
+
const created = await state.createDeliverable({
|
|
395
|
+
projectId: 'proj_1',
|
|
396
|
+
title: 'Commercial Cut 30s'
|
|
397
|
+
});
|
|
398
|
+
expect(created).toEqual(mockDeliverable);
|
|
399
|
+
|
|
400
|
+
const updated = await state.updateDeliverable('deliv_1', { status: 'delivered' });
|
|
401
|
+
expect(updated.status).toBe('delivered');
|
|
402
|
+
|
|
403
|
+
const summary = await state.getSummary('deliv_1');
|
|
404
|
+
expect(summary.totalTasks).toBe(2);
|
|
405
|
+
expect(summary.progressPercentage).toBe(50);
|
|
406
|
+
|
|
407
|
+
await state.deleteDeliverable('deliv_1');
|
|
408
|
+
expect(state.data).toEqual([]);
|
|
409
|
+
});
|
|
410
|
+
});
|
|
355
411
|
});
|
|
356
412
|
|