@critical-path/svelte 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jack James
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ export * from './stores.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './stores.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { createProjectStore, createTaskStore } from './stores.js';
3
+ describe('@critical-path/svelte Stores Test', () => {
4
+ it('exports stores factory functions', () => {
5
+ expect(createProjectStore).toBeDefined();
6
+ expect(createTaskStore).toBeDefined();
7
+ });
8
+ });
9
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAElE,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,CAAC,kBAAkB,CAAC,CAAC,WAAW,EAAE,CAAC;QACzC,MAAM,CAAC,eAAe,CAAC,CAAC,WAAW,EAAE,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { CriticalPathClient, type ClientOptions } from '@critical-path/client';
2
+ import type { Project, Task, TaskStatus } from '@critical-path/core';
3
+ export declare function createCriticalPathClient(options: ClientOptions): CriticalPathClient;
4
+ export interface StoreState<T> {
5
+ data: T;
6
+ loading: boolean;
7
+ error: Error | null;
8
+ }
9
+ export type Subscriber<T> = (value: StoreState<T>) => void;
10
+ export declare function createProjectStore(client: CriticalPathClient): {
11
+ subscribe: (subscriber: Subscriber<Project[]>) => () => void;
12
+ fetch: () => Promise<void>;
13
+ createProject: (input: Omit<Project, "id" | "createdAt" | "updatedAt">) => Promise<Project>;
14
+ };
15
+ export declare function createTaskStore(client: CriticalPathClient, projectId?: string): {
16
+ subscribe: (subscriber: Subscriber<Task[]>) => () => void;
17
+ fetch: () => Promise<void>;
18
+ createTask: (input: Omit<Task, "id" | "createdAt" | "updatedAt">) => Promise<Task>;
19
+ updateTaskStatus: (taskId: string, status: TaskStatus) => Promise<Task>;
20
+ deleteTask: (taskId: string) => Promise<void>;
21
+ };
22
+ //# sourceMappingURL=stores.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stores.d.ts","sourceRoot":"","sources":["../src/stores.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAErE,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,aAAa,GAAG,kBAAkB,CAEnF;AAED,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAwB3D,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB;;;2BAavB,IAAI,CAAC,OAAO,EAAE,IAAI,GAAG,WAAW,GAAG,WAAW,CAAC;EAYpF;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,SAAS,CAAC,EAAE,MAAM;;;wBAa3C,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW,GAAG,WAAW,CAAC;+BAOrC,MAAM,UAAU,UAAU;yBAOhC,MAAM;EAazC"}
package/dist/stores.js ADDED
@@ -0,0 +1,84 @@
1
+ import { CriticalPathClient } from '@critical-path/client';
2
+ export function createCriticalPathClient(options) {
3
+ return new CriticalPathClient(options);
4
+ }
5
+ function createBaseStore(initialData) {
6
+ let state = { data: initialData, loading: false, error: null };
7
+ const subscribers = new Set();
8
+ function subscribe(subscriber) {
9
+ subscribers.add(subscriber);
10
+ subscriber(state);
11
+ return () => {
12
+ subscribers.delete(subscriber);
13
+ };
14
+ }
15
+ function set(newState) {
16
+ state = { ...state, ...newState };
17
+ for (const sub of subscribers) {
18
+ sub(state);
19
+ }
20
+ }
21
+ return { subscribe, get: () => state, set };
22
+ }
23
+ export function createProjectStore(client) {
24
+ const store = createBaseStore([]);
25
+ async function fetch() {
26
+ store.set({ loading: true, error: null });
27
+ try {
28
+ const projects = await client.getProjects();
29
+ store.set({ data: projects, loading: false });
30
+ }
31
+ catch (err) {
32
+ store.set({ error: err instanceof Error ? err : new Error(String(err)), loading: false });
33
+ }
34
+ }
35
+ async function createProject(input) {
36
+ const created = await client.createProject(input);
37
+ const current = store.get().data;
38
+ store.set({ data: [...current, created] });
39
+ return created;
40
+ }
41
+ return {
42
+ subscribe: store.subscribe,
43
+ fetch,
44
+ createProject
45
+ };
46
+ }
47
+ export function createTaskStore(client, projectId) {
48
+ const store = createBaseStore([]);
49
+ async function fetch() {
50
+ store.set({ loading: true, error: null });
51
+ try {
52
+ const tasks = await client.getTasks(projectId);
53
+ store.set({ data: tasks, loading: false });
54
+ }
55
+ catch (err) {
56
+ store.set({ error: err instanceof Error ? err : new Error(String(err)), loading: false });
57
+ }
58
+ }
59
+ async function createTask(input) {
60
+ const created = await client.createTask(input);
61
+ const current = store.get().data;
62
+ store.set({ data: [...current, created] });
63
+ return created;
64
+ }
65
+ async function updateTaskStatus(taskId, status) {
66
+ const updated = await client.updateTask(taskId, { status });
67
+ const current = store.get().data;
68
+ store.set({ data: current.map((t) => (t.id === taskId ? updated : t)) });
69
+ return updated;
70
+ }
71
+ async function deleteTask(taskId) {
72
+ await client.deleteTask(taskId);
73
+ const current = store.get().data;
74
+ store.set({ data: current.filter((t) => t.id !== taskId) });
75
+ }
76
+ return {
77
+ subscribe: store.subscribe,
78
+ fetch,
79
+ createTask,
80
+ updateTaskStatus,
81
+ deleteTask
82
+ };
83
+ }
84
+ //# sourceMappingURL=stores.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stores.js","sourceRoot":"","sources":["../src/stores.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAsB,MAAM,uBAAuB,CAAC;AAG/E,MAAM,UAAU,wBAAwB,CAAC,OAAsB;IAC7D,OAAO,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC;AAUD,SAAS,eAAe,CAAI,WAAc;IACxC,IAAI,KAAK,GAAkB,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC9E,MAAM,WAAW,GAAG,IAAI,GAAG,EAAiB,CAAC;IAE7C,SAAS,SAAS,CAAC,UAAyB;QAC1C,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC5B,UAAU,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,GAAG,EAAE;YACV,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACjC,CAAC,CAAC;IACJ,CAAC;IAED,SAAS,GAAG,CAAC,QAAgC;QAC3C,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;QAClC,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC9B,GAAG,CAAC,KAAK,CAAC,CAAC;QACb,CAAC;IACH,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAA0B;IAC3D,MAAM,KAAK,GAAG,eAAe,CAAY,EAAE,CAAC,CAAC;IAE7C,KAAK,UAAU,KAAK;QAClB,KAAK,CAAC,GAAG,CAAC,EA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QAChC,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;QACjC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,KAAK;QACL,UAAU;QACV,gBAAgB;QAChB,UAAU;KACX,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@critical-path/svelte",
3
+ "version": "0.1.0",
4
+ "description": "Svelte stores and reactive integrations for Critical Path headless project management framework",
5
+ "author": "Jack James",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "dependencies": {
17
+ "@critical-path/client": "0.1.0",
18
+ "@critical-path/core": "0.1.0"
19
+ },
20
+ "peerDependencies": {
21
+ "svelte": "^4.0.0 || ^5.0.0"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^24.0.0",
25
+ "svelte": "^5.0.0",
26
+ "typescript": "^5.7.0",
27
+ "vitest": "^3.0.0"
28
+ },
29
+ "engines": {
30
+ "node": ">=24.0.0"
31
+ },
32
+ "scripts": {
33
+ "build": "tsc --build",
34
+ "test": "vitest run",
35
+ "clean": "rm -rf dist *.tsbuildinfo"
36
+ }
37
+ }
@@ -0,0 +1,9 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { createProjectStore, createTaskStore } from './stores.js';
3
+
4
+ describe('@critical-path/svelte Stores Test', () => {
5
+ it('exports stores factory functions', () => {
6
+ expect(createProjectStore).toBeDefined();
7
+ expect(createTaskStore).toBeDefined();
8
+ });
9
+ });
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './stores.js';
package/src/stores.ts ADDED
@@ -0,0 +1,105 @@
1
+ import { CriticalPathClient, type ClientOptions } from '@critical-path/client';
2
+ import type { Project, Task, TaskStatus } from '@critical-path/core';
3
+
4
+ export function createCriticalPathClient(options: ClientOptions): CriticalPathClient {
5
+ return new CriticalPathClient(options);
6
+ }
7
+
8
+ export interface StoreState<T> {
9
+ data: T;
10
+ loading: boolean;
11
+ error: Error | null;
12
+ }
13
+
14
+ export type Subscriber<T> = (value: StoreState<T>) => void;
15
+
16
+ function createBaseStore<T>(initialData: T) {
17
+ let state: StoreState<T> = { data: initialData, loading: false, error: null };
18
+ const subscribers = new Set<Subscriber<T>>();
19
+
20
+ function subscribe(subscriber: Subscriber<T>) {
21
+ subscribers.add(subscriber);
22
+ subscriber(state);
23
+ return () => {
24
+ subscribers.delete(subscriber);
25
+ };
26
+ }
27
+
28
+ function set(newState: Partial<StoreState<T>>) {
29
+ state = { ...state, ...newState };
30
+ for (const sub of subscribers) {
31
+ sub(state);
32
+ }
33
+ }
34
+
35
+ return { subscribe, get: () => state, set };
36
+ }
37
+
38
+ export function createProjectStore(client: CriticalPathClient) {
39
+ const store = createBaseStore<Project[]>([]);
40
+
41
+ async function fetch() {
42
+ store.set({ loading: true, error: null });
43
+ try {
44
+ const projects = await client.getProjects();
45
+ store.set({ data: projects, loading: false });
46
+ } catch (err) {
47
+ store.set({ error: err instanceof Error ? err : new Error(String(err)), loading: false });
48
+ }
49
+ }
50
+
51
+ async function createProject(input: Omit<Project, 'id' | 'createdAt' | 'updatedAt'>) {
52
+ const created = await client.createProject(input);
53
+ const current = store.get().data;
54
+ store.set({ data: [...current, created] });
55
+ return created;
56
+ }
57
+
58
+ return {
59
+ subscribe: store.subscribe,
60
+ fetch,
61
+ createProject
62
+ };
63
+ }
64
+
65
+ export function createTaskStore(client: CriticalPathClient, projectId?: string) {
66
+ const store = createBaseStore<Task[]>([]);
67
+
68
+ async function fetch() {
69
+ store.set({ loading: true, error: null });
70
+ try {
71
+ const tasks = await client.getTasks(projectId);
72
+ store.set({ data: tasks, loading: false });
73
+ } catch (err) {
74
+ store.set({ error: err instanceof Error ? err : new Error(String(err)), loading: false });
75
+ }
76
+ }
77
+
78
+ async function createTask(input: Omit<Task, 'id' | 'createdAt' | 'updatedAt'>) {
79
+ const created = await client.createTask(input);
80
+ const current = store.get().data;
81
+ store.set({ data: [...current, created] });
82
+ return created;
83
+ }
84
+
85
+ async function updateTaskStatus(taskId: string, status: TaskStatus) {
86
+ const updated = await client.updateTask(taskId, { status });
87
+ const current = store.get().data;
88
+ store.set({ data: current.map((t) => (t.id === taskId ? updated : t)) });
89
+ return updated;
90
+ }
91
+
92
+ async function deleteTask(taskId: string) {
93
+ await client.deleteTask(taskId);
94
+ const current = store.get().data;
95
+ store.set({ data: current.filter((t) => t.id !== taskId) });
96
+ }
97
+
98
+ return {
99
+ subscribe: store.subscribe,
100
+ fetch,
101
+ createTask,
102
+ updateTaskStatus,
103
+ deleteTask
104
+ };
105
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src"
6
+ },
7
+ "include": ["src/**/*"]
8
+ }
@@ -0,0 +1 @@
1
+ {"root":["./src/index.test.ts","./src/index.ts","./src/stores.ts"],"version":"5.9.3"}