@critical-path/core 0.36.0 → 0.37.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.
Files changed (214) hide show
  1. package/README.md +1 -1
  2. package/dist/domain/authorization.d.ts.map +1 -1
  3. package/dist/domain/authorization.js +10 -7
  4. package/dist/domain/authorization.js.map +1 -1
  5. package/dist/engine/index.d.ts +6 -0
  6. package/dist/engine/index.d.ts.map +1 -1
  7. package/dist/engine/index.js +28 -2
  8. package/dist/engine/index.js.map +1 -1
  9. package/dist/schemas/index.d.ts +42 -12
  10. package/dist/schemas/index.d.ts.map +1 -1
  11. package/dist/schemas/index.js +4 -1
  12. package/dist/schemas/index.js.map +1 -1
  13. package/dist/store/firebase.d.ts +2 -2
  14. package/dist/store/firebase.d.ts.map +1 -1
  15. package/dist/store/firebase.js +4 -2
  16. package/dist/store/firebase.js.map +1 -1
  17. package/dist/store/index.d.ts +7 -2
  18. package/dist/store/index.d.ts.map +1 -1
  19. package/dist/store/index.js +3 -2
  20. package/dist/store/index.js.map +1 -1
  21. package/dist/store/sqlite.d.ts +2 -2
  22. package/dist/store/sqlite.d.ts.map +1 -1
  23. package/dist/store/sqlite.js +5 -3
  24. package/dist/store/sqlite.js.map +1 -1
  25. package/dist/testing/conformance.d.ts.map +1 -1
  26. package/dist/testing/conformance.js +9 -0
  27. package/dist/testing/conformance.js.map +1 -1
  28. package/dist/types/index.d.ts +13 -2
  29. package/dist/types/index.d.ts.map +1 -1
  30. package/package.json +5 -1
  31. package/CHANGELOG.md +0 -593
  32. package/dist/deliverables.test.d.ts +0 -2
  33. package/dist/deliverables.test.d.ts.map +0 -1
  34. package/dist/deliverables.test.js +0 -232
  35. package/dist/deliverables.test.js.map +0 -1
  36. package/dist/domain/calendar.test.d.ts +0 -2
  37. package/dist/domain/calendar.test.d.ts.map +0 -1
  38. package/dist/domain/calendar.test.js +0 -181
  39. package/dist/domain/calendar.test.js.map +0 -1
  40. package/dist/domain/cpm.test.d.ts +0 -2
  41. package/dist/domain/cpm.test.d.ts.map +0 -1
  42. package/dist/domain/cpm.test.js +0 -166
  43. package/dist/domain/cpm.test.js.map +0 -1
  44. package/dist/domain/ddd.test.d.ts +0 -2
  45. package/dist/domain/ddd.test.d.ts.map +0 -1
  46. package/dist/domain/ddd.test.js +0 -349
  47. package/dist/domain/ddd.test.js.map +0 -1
  48. package/dist/domain/ladder.test.d.ts +0 -2
  49. package/dist/domain/ladder.test.d.ts.map +0 -1
  50. package/dist/domain/ladder.test.js +0 -213
  51. package/dist/domain/ladder.test.js.map +0 -1
  52. package/dist/domain/metrics.test.d.ts +0 -2
  53. package/dist/domain/metrics.test.d.ts.map +0 -1
  54. package/dist/domain/metrics.test.js +0 -252
  55. package/dist/domain/metrics.test.js.map +0 -1
  56. package/dist/domain/task-duration.test.d.ts +0 -2
  57. package/dist/domain/task-duration.test.d.ts.map +0 -1
  58. package/dist/domain/task-duration.test.js +0 -307
  59. package/dist/domain/task-duration.test.js.map +0 -1
  60. package/dist/domain/workload.test.d.ts +0 -2
  61. package/dist/domain/workload.test.d.ts.map +0 -1
  62. package/dist/domain/workload.test.js +0 -261
  63. package/dist/domain/workload.test.js.map +0 -1
  64. package/dist/engine/actor.test.d.ts +0 -2
  65. package/dist/engine/actor.test.d.ts.map +0 -1
  66. package/dist/engine/actor.test.js +0 -54
  67. package/dist/engine/actor.test.js.map +0 -1
  68. package/dist/engine/authorization.test.d.ts +0 -2
  69. package/dist/engine/authorization.test.d.ts.map +0 -1
  70. package/dist/engine/authorization.test.js +0 -154
  71. package/dist/engine/authorization.test.js.map +0 -1
  72. package/dist/engine/cascade.test.d.ts +0 -2
  73. package/dist/engine/cascade.test.d.ts.map +0 -1
  74. package/dist/engine/cascade.test.js +0 -99
  75. package/dist/engine/cascade.test.js.map +0 -1
  76. package/dist/engine/config.test.d.ts +0 -2
  77. package/dist/engine/config.test.d.ts.map +0 -1
  78. package/dist/engine/config.test.js +0 -46
  79. package/dist/engine/config.test.js.map +0 -1
  80. package/dist/engine/entity-events.test.d.ts +0 -2
  81. package/dist/engine/entity-events.test.d.ts.map +0 -1
  82. package/dist/engine/entity-events.test.js +0 -61
  83. package/dist/engine/entity-events.test.js.map +0 -1
  84. package/dist/index.test.d.ts +0 -2
  85. package/dist/index.test.d.ts.map +0 -1
  86. package/dist/index.test.js +0 -429
  87. package/dist/index.test.js.map +0 -1
  88. package/dist/plugins/plugins.test.d.ts +0 -2
  89. package/dist/plugins/plugins.test.d.ts.map +0 -1
  90. package/dist/plugins/plugins.test.js +0 -137
  91. package/dist/plugins/plugins.test.js.map +0 -1
  92. package/dist/schemas/schemas.test.d.ts +0 -2
  93. package/dist/schemas/schemas.test.d.ts.map +0 -1
  94. package/dist/schemas/schemas.test.js +0 -58
  95. package/dist/schemas/schemas.test.js.map +0 -1
  96. package/dist/status.test.d.ts +0 -2
  97. package/dist/status.test.d.ts.map +0 -1
  98. package/dist/status.test.js +0 -295
  99. package/dist/status.test.js.map +0 -1
  100. package/dist/storage/storage.test.d.ts +0 -2
  101. package/dist/storage/storage.test.d.ts.map +0 -1
  102. package/dist/storage/storage.test.js +0 -236
  103. package/dist/storage/storage.test.js.map +0 -1
  104. package/dist/storage/upload-limits.test.d.ts +0 -2
  105. package/dist/storage/upload-limits.test.d.ts.map +0 -1
  106. package/dist/storage/upload-limits.test.js +0 -31
  107. package/dist/storage/upload-limits.test.js.map +0 -1
  108. package/dist/store/conformance.test.d.ts +0 -2
  109. package/dist/store/conformance.test.d.ts.map +0 -1
  110. package/dist/store/conformance.test.js +0 -15
  111. package/dist/store/conformance.test.js.map +0 -1
  112. package/dist/store/firebase.test.d.ts +0 -2
  113. package/dist/store/firebase.test.d.ts.map +0 -1
  114. package/dist/store/firebase.test.js +0 -103
  115. package/dist/store/firebase.test.js.map +0 -1
  116. package/dist/store/query.test.d.ts +0 -2
  117. package/dist/store/query.test.d.ts.map +0 -1
  118. package/dist/store/query.test.js +0 -89
  119. package/dist/store/query.test.js.map +0 -1
  120. package/dist/store/sqlite.test.d.ts +0 -2
  121. package/dist/store/sqlite.test.d.ts.map +0 -1
  122. package/dist/store/sqlite.test.js +0 -177
  123. package/dist/store/sqlite.test.js.map +0 -1
  124. package/dist/task-state.test.d.ts +0 -2
  125. package/dist/task-state.test.d.ts.map +0 -1
  126. package/dist/task-state.test.js +0 -423
  127. package/dist/task-state.test.js.map +0 -1
  128. package/dist/use-case-validation.test.d.ts +0 -2
  129. package/dist/use-case-validation.test.d.ts.map +0 -1
  130. package/dist/use-case-validation.test.js +0 -281
  131. package/dist/use-case-validation.test.js.map +0 -1
  132. package/dist/utils/fractional-index.test.d.ts +0 -2
  133. package/dist/utils/fractional-index.test.d.ts.map +0 -1
  134. package/dist/utils/fractional-index.test.js +0 -182
  135. package/dist/utils/fractional-index.test.js.map +0 -1
  136. package/dist/utils/key.test.d.ts +0 -2
  137. package/dist/utils/key.test.d.ts.map +0 -1
  138. package/dist/utils/key.test.js +0 -65
  139. package/dist/utils/key.test.js.map +0 -1
  140. package/dist/utils/mentions.test.d.ts +0 -2
  141. package/dist/utils/mentions.test.d.ts.map +0 -1
  142. package/dist/utils/mentions.test.js +0 -114
  143. package/dist/utils/mentions.test.js.map +0 -1
  144. package/dist/webhooks/webhooks.test.d.ts +0 -2
  145. package/dist/webhooks/webhooks.test.d.ts.map +0 -1
  146. package/dist/webhooks/webhooks.test.js +0 -154
  147. package/dist/webhooks/webhooks.test.js.map +0 -1
  148. package/src/deliverables.test.ts +0 -284
  149. package/src/domain/authorization.ts +0 -82
  150. package/src/domain/calendar.test.ts +0 -216
  151. package/src/domain/calendar.ts +0 -502
  152. package/src/domain/cpm.test.ts +0 -189
  153. package/src/domain/cpm.ts +0 -258
  154. package/src/domain/custom-fields.ts +0 -172
  155. package/src/domain/ddd.test.ts +0 -442
  156. package/src/domain/entities.ts +0 -798
  157. package/src/domain/errors.ts +0 -38
  158. package/src/domain/events.ts +0 -369
  159. package/src/domain/graph.ts +0 -70
  160. package/src/domain/index.ts +0 -12
  161. package/src/domain/ladder.test.ts +0 -251
  162. package/src/domain/ladder.ts +0 -474
  163. package/src/domain/metrics.test.ts +0 -288
  164. package/src/domain/metrics.ts +0 -497
  165. package/src/domain/task-duration.test.ts +0 -354
  166. package/src/domain/workload.test.ts +0 -311
  167. package/src/domain/workload.ts +0 -457
  168. package/src/engine/actor.test.ts +0 -63
  169. package/src/engine/authorization.test.ts +0 -199
  170. package/src/engine/cascade.test.ts +0 -121
  171. package/src/engine/config.test.ts +0 -51
  172. package/src/engine/entity-events.test.ts +0 -67
  173. package/src/engine/index.ts +0 -2495
  174. package/src/index.test.ts +0 -514
  175. package/src/index.ts +0 -9
  176. package/src/plugins/index.ts +0 -103
  177. package/src/plugins/plugins.test.ts +0 -161
  178. package/src/schemas/index.ts +0 -402
  179. package/src/schemas/schemas.test.ts +0 -116
  180. package/src/status.test.ts +0 -354
  181. package/src/storage/file-storage.ts +0 -200
  182. package/src/storage/firebase-storage.ts +0 -209
  183. package/src/storage/index.ts +0 -3
  184. package/src/storage/s3.ts +0 -151
  185. package/src/storage/storage.test.ts +0 -274
  186. package/src/storage/upload-limits.test.ts +0 -41
  187. package/src/store/conformance.test.ts +0 -15
  188. package/src/store/firebase.test.ts +0 -131
  189. package/src/store/firebase.ts +0 -658
  190. package/src/store/index.ts +0 -623
  191. package/src/store/query.test.ts +0 -110
  192. package/src/store/query.ts +0 -113
  193. package/src/store/sqlite.test.ts +0 -218
  194. package/src/store/sqlite.ts +0 -1480
  195. package/src/task-state.test.ts +0 -506
  196. package/src/testing/conformance.ts +0 -319
  197. package/src/testing/index.ts +0 -1
  198. package/src/types/index.ts +0 -871
  199. package/src/use-case-validation.test.ts +0 -324
  200. package/src/utils/fractional-index.test.ts +0 -228
  201. package/src/utils/fractional-index.ts +0 -254
  202. package/src/utils/index.ts +0 -7
  203. package/src/utils/key.test.ts +0 -76
  204. package/src/utils/key.ts +0 -62
  205. package/src/utils/mentions.test.ts +0 -132
  206. package/src/utils/mentions.ts +0 -131
  207. package/src/utils/status.ts +0 -419
  208. package/src/utils/workflow.ts +0 -306
  209. package/src/webhooks/dispatcher.ts +0 -190
  210. package/src/webhooks/index.ts +0 -2
  211. package/src/webhooks/signature.ts +0 -57
  212. package/src/webhooks/webhooks.test.ts +0 -201
  213. package/tsconfig.json +0 -8
  214. package/tsconfig.tsbuildinfo +0 -1
@@ -1,319 +0,0 @@
1
- /**
2
- * Storage adapter conformance suite. Run it against any `StorageAdapter` (including your own) to
3
- * check it behaves like the built-in adapters:
4
- *
5
- * import { describe, it, expect } from 'vitest';
6
- * import { runStorageAdapterConformance } from '@critical-path/core/testing';
7
- * runStorageAdapterConformance({ name: 'PostgresStore', createStore: () => new PostgresStore(...), describe, it, expect });
8
- *
9
- * The test runner functions are passed in so core has no test-framework dependency.
10
- */
11
- import type { StorageAdapter } from '../store/index.js';
12
- import type { Project, Task, Team, Workflow, Attachment, Deliverable, TaskContainer, Iteration, Comment } from '../types/index.js';
13
-
14
- type Describe = (name: string, fn: () => void) => void;
15
- type It = (name: string, fn: () => Promise<void> | void) => void;
16
- // Minimal expect surface used by the suite (compatible with vitest and jest)
17
- type Expect = (value: unknown) => {
18
- toEqual(expected: unknown): void;
19
- toBe(expected: unknown): void;
20
- toBeNull(): void;
21
- toBeUndefined(): void;
22
- toBeDefined(): void;
23
- toHaveLength(length: number): void;
24
- toMatchObject(expected: object): void;
25
- not: { toBeNull(): void; toHaveProperty(key: string): void };
26
- };
27
-
28
- export interface ConformanceOptions {
29
- name: string;
30
- createStore: () => StorageAdapter | Promise<StorageAdapter>;
31
- describe: Describe;
32
- it: It;
33
- expect: Expect;
34
- }
35
-
36
- const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
37
-
38
- const schedule = {
39
- name: 'Four-day week',
40
- timezone: 'Europe/London',
41
- defaultHoursPerDay: 8,
42
- days: [{ dayOfWeek: 1, isWorkingDay: true, hours: [{ start: '09:00', end: '17:00' }] }],
43
- holidays: [{ date: '2026-12-25', name: 'Christmas' }]
44
- };
45
-
46
- /** A project with every optional field set. */
47
- const fullProject = (): Omit<Project, 'id' | 'createdAt' | 'updatedAt'> => ({
48
- key: 'CONF',
49
- name: 'Conformance',
50
- description: 'Every field',
51
- ownerId: 'owner-1',
52
- members: [{ userId: 'u1', role: 'admin' }],
53
- teamIds: ['team-1'],
54
- workflowId: 'wf-1',
55
- taskTypes: [{ key: 'bug', label: 'Bug' }],
56
- statusDefinitions: [{ key: 'todo', label: 'To Do', category: 'not_started' }],
57
- priorityDefinitions: [{ key: 'p1', label: 'P1', level: 1 }],
58
- customFieldDefinitions: [{ id: 'f1', key: 'client', label: 'Client', type: 'text', required: false }],
59
- schedule,
60
- startDate: '2026-10-01',
61
- targetEndDate: '2026-12-31',
62
- tenantId: 'tenant-1'
63
- });
64
-
65
- /** A task with every optional field set. */
66
- const fullTask = (projectId: string): Omit<Task, 'id' | 'createdAt' | 'updatedAt'> => ({
67
- projectId,
68
- key: 'CONF-1',
69
- title: 'Every field',
70
- description: 'All of them',
71
- status: 'in_progress',
72
- semanticStatus: 'in_progress',
73
- priority: 'high',
74
- taskType: 'bug',
75
- assigneeId: 'u1',
76
- assignees: [{ id: 'u1', name: 'Ana', role: 'lead', type: 'user', avatarUrl: 'https://example.com/a.png' }],
77
- reporterId: 'u2',
78
- reviewerId: 'u3',
79
- iterationId: 'it-1',
80
- teamId: 'team-1',
81
- containerId: 'c-1',
82
- deliverableId: 'd-1',
83
- plannedStartDate: '2026-10-01',
84
- actualStartDate: '2026-10-02T09:00:00.000Z',
85
- dueDate: '2026-10-10',
86
- estimatedHours: 8,
87
- loggedHours: 2,
88
- actualHours: 2,
89
- billableHours: 1,
90
- estimatedDurationMinutes: 480,
91
- actualDurationMinutes: 120,
92
- billableDurationMinutes: 60,
93
- actualDurationSeconds: 7200,
94
- inProgressSince: '2026-10-02T09:00:00.000Z',
95
- blockedDurationSeconds: 60,
96
- progress: 25,
97
- isBlocked: false,
98
- tags: ['a', 'b'],
99
- todos: [{ id: 'todo-1', title: 'First', completed: false, createdAt: '2026-10-02T09:00:00.000Z' }],
100
- customFields: { client: 'Acme', nested: { level: 2 } },
101
- parentId: 'parent-1'
102
- });
103
-
104
- export function runStorageAdapterConformance({ name, createStore, describe, it, expect }: ConformanceOptions): void {
105
- describe(`StorageAdapter conformance: ${name}`, () => {
106
- it('round-trips every project field', async () => {
107
- const store = await createStore();
108
- const input = fullProject();
109
- const created = await store.createProject(input);
110
- expect(await store.getProject(created.id)).toMatchObject(input);
111
- expect(await store.getProjects()).toHaveLength(1);
112
- });
113
-
114
- it('round-trips every task field', async () => {
115
- const store = await createStore();
116
- const project = await store.createProject({ name: 'P' });
117
- const input = fullTask(project.id);
118
- const created = await store.createTask(input);
119
- expect(await store.getTask(created.id)).toMatchObject(input);
120
- });
121
-
122
- it('updates tasks partially, clears fields set to undefined, and replaces nested objects', async () => {
123
- const store = await createStore();
124
- const project = await store.createProject({ name: 'P' });
125
- const created = await store.createTask(fullTask(project.id));
126
-
127
- await store.updateTask(created.id, {
128
- title: 'Renamed',
129
- completedAt: undefined,
130
- parentId: undefined,
131
- iterationId: undefined,
132
- customFields: { client: 'Globex' }
133
- });
134
- const updated = (await store.getTask(created.id)) as unknown as Record<string, unknown>;
135
- expect(updated.title).toBe('Renamed');
136
- expect(updated.description).toBe('All of them');
137
- expect(updated.parentId).toBeUndefined();
138
- expect(updated.iterationId).toBeUndefined();
139
- expect(updated.customFields).toEqual({ client: 'Globex' });
140
- expect(updated.parentId === null).toBe(false);
141
- });
142
-
143
- it('returns copies, so mutating results or reused inputs does not change stored records', async () => {
144
- const store = await createStore();
145
- const project = await store.createProject({ name: 'P' });
146
- const input = { projectId: project.id, title: 'Original', status: 'todo', priority: 'medium', tags: ['a'] };
147
- const created = await store.createTask(input);
148
-
149
- input.tags.push('mutated-input');
150
- input.title = 'Mutated input';
151
- const fetched = (await store.getTask(created.id))!;
152
- fetched.tags!.push('mutated-result');
153
- fetched.title = 'Mutated result';
154
- (await store.getTasks(project.id))[0].title = 'Mutated list';
155
-
156
- const stored = await store.getTask(created.id);
157
- expect(stored?.title).toBe('Original');
158
- expect(stored?.tags).toEqual(['a']);
159
- });
160
-
161
- it('follows the not-found contract', async () => {
162
- const store = await createStore();
163
- expect(await store.getProject('missing')).toBeNull();
164
- expect(await store.getTask('missing')).toBeNull();
165
- expect(await store.updateTask('missing', { title: 'x' })).toBeNull();
166
- expect(await store.updateProject('missing', { name: 'x' })).toBeNull();
167
- expect(await store.deleteTask('missing')).toBe(false);
168
- expect(await store.deleteProject('missing')).toBe(false);
169
- expect(await store.getComment('missing')).toBeNull();
170
- expect(await store.deleteComment('missing')).toBe(false);
171
- expect(await store.getAttachment('missing')).toBeNull();
172
- expect(await store.deleteAttachment('missing')).toBe(false);
173
- expect(await store.getDependency('missing')).toBeNull();
174
- expect(await store.removeDependency('missing')).toBe(false);
175
- expect(await store.getWebhook('missing')).toBeNull();
176
- expect(await store.deleteWebhook('missing')).toBe(false);
177
- });
178
-
179
- it('round-trips teams, workflows, containers, iterations and deliverables', async () => {
180
- const store = await createStore();
181
- const project = await store.createProject({ name: 'P' });
182
-
183
- const team: Omit<Team, 'id' | 'createdAt' | 'updatedAt'> = {
184
- name: 'Core',
185
- description: 'Team',
186
- leaderId: 'u1',
187
- memberIds: ['u1', 'u2'],
188
- weeklyCapacityHours: 80,
189
- schedule,
190
- tenantId: 'tenant-1'
191
- };
192
- expect(await store.getTeam((await store.createTeam(team)).id)).toMatchObject(team);
193
-
194
- const workflow: Omit<Workflow, 'id' | 'createdAt' | 'updatedAt'> = {
195
- name: 'Flow',
196
- description: 'Workflow',
197
- statuses: [{ key: 'todo', label: 'To Do', category: 'not_started' }],
198
- transitions: [{ id: 't1', name: 'Start', fromStatusKey: '*', toStatusKey: 'todo' }],
199
- taskTypes: [{ key: 'bug', label: 'Bug' }],
200
- defaultStatusKey: 'todo',
201
- isDefault: true,
202
- tenantId: 'tenant-1'
203
- };
204
- expect(await store.getWorkflow((await store.createWorkflow(workflow)).id)).toMatchObject(workflow);
205
-
206
- const container: Omit<TaskContainer, 'id' | 'createdAt' | 'updatedAt'> = {
207
- projectId: project.id,
208
- name: 'Epic',
209
- description: 'Container',
210
- parentId: 'c-0',
211
- type: 'epic',
212
- color: '#ff0000'
213
- };
214
- expect(await store.getContainer((await store.createContainer(container)).id)).toMatchObject(container);
215
-
216
- const iteration: Omit<Iteration, 'id' | 'createdAt'> = {
217
- projectId: project.id,
218
- name: 'Sprint 1',
219
- goal: 'Ship',
220
- type: 'sprint',
221
- startDate: '2026-10-01',
222
- endDate: '2026-10-14',
223
- status: 'active'
224
- };
225
- expect(await store.getIteration((await store.createIteration(iteration)).id)).toMatchObject(iteration);
226
-
227
- const deliverable: Omit<Deliverable, 'id' | 'createdAt' | 'updatedAt'> = {
228
- projectId: project.id,
229
- title: 'Cut',
230
- description: 'Deliverable',
231
- status: 'planned',
232
- format: '4K',
233
- specs: { fps: 24 },
234
- leadId: 'u1',
235
- reviewerId: 'u2',
236
- dueDate: '2026-11-01',
237
- deliveredAt: '2026-11-02T00:00:00.000Z',
238
- outputUrls: ['https://example.com/cut.mov'],
239
- customFields: { client: 'Acme' }
240
- };
241
- expect(await store.getDeliverable((await store.createDeliverable(deliverable)).id)).toMatchObject(deliverable);
242
- });
243
-
244
- it('round-trips comments with reactions, ordered oldest first', async () => {
245
- const store = await createStore();
246
- const project = await store.createProject({ name: 'P' });
247
- const task = await store.createTask({ projectId: project.id, title: 'T', status: 'todo', priority: 'medium' });
248
- const input: Omit<Comment, 'id' | 'createdAt' | 'updatedAt'> = {
249
- taskId: task.id,
250
- authorId: 'u1',
251
- authorType: 'agent',
252
- content: 'First',
253
- mentions: ['u2'],
254
- metadata: { source: 'cli' }
255
- };
256
- const first = await store.addComment(input);
257
- await sleep(2);
258
- await store.addComment({ taskId: task.id, authorId: 'u2', content: 'Second' });
259
-
260
- expect(await store.getComment(first.id)).toMatchObject(input);
261
- expect((await store.getComments(task.id)).map((c) => c.content)).toEqual(['First', 'Second']);
262
- });
263
-
264
- it('round-trips attachments and applies every attachment filter together', async () => {
265
- const store = await createStore();
266
- const input: Omit<Attachment, 'id' | 'createdAt' | 'updatedAt'> = {
267
- taskId: 't1',
268
- projectId: 'p1',
269
- commentId: 'c1',
270
- uploaderId: 'u1',
271
- uploaderType: 'user',
272
- filename: 'spec.pdf',
273
- mimeType: 'application/pdf',
274
- sizeBytes: 1234,
275
- url: 'https://example.com/spec.pdf',
276
- storageKey: 'projects/p1/spec.pdf',
277
- artifactType: 'spec',
278
- metadata: { pages: 3 }
279
- };
280
- const created = await store.createAttachment(input);
281
- await store.createAttachment({ ...input, commentId: 'c2' });
282
- await store.createAttachment({ ...input, taskId: 't2' });
283
-
284
- expect(await store.getAttachment(created.id)).toMatchObject(input);
285
- expect(await store.getAttachments({ taskId: 't1', commentId: 'c1' })).toHaveLength(1);
286
- expect(await store.getAttachments({ taskId: 't1' })).toHaveLength(2);
287
- });
288
-
289
- it('returns activities newest first and applies every activity filter together', async () => {
290
- const store = await createStore();
291
- await store.logActivity({ projectId: 'p1', taskId: 't1', actorId: 'u1', action: 'first', details: { n: 1 } });
292
- await sleep(2);
293
- await store.logActivity({ projectId: 'p1', taskId: 't2', actorId: 'u1', action: 'second', details: {} });
294
- await sleep(2);
295
- await store.logActivity({ projectId: 'p2', taskId: 't1', actorId: 'u1', action: 'third', details: {} });
296
-
297
- expect((await store.getActivities({ projectId: 'p1' })).map((a) => a.action)).toEqual(['second', 'first']);
298
- expect((await store.getActivities({ projectId: 'p1', taskId: 't1' })).map((a) => a.action)).toEqual(['first']);
299
- expect((await store.getActivities()).map((a) => a.action)).toEqual(['third', 'second', 'first']);
300
- expect((await store.getActivities({ taskId: 't1' }))[1]).toMatchObject({ details: { n: 1 } });
301
- });
302
-
303
- it('round-trips dependencies, time entries and webhooks', async () => {
304
- const store = await createStore();
305
- const dep = await store.addDependency({ taskId: 'a', dependsOnTaskId: 'b', type: 'blocked_by' });
306
- expect(await store.getDependency(dep.id)).toEqual(dep);
307
- expect(await store.getDependencies('b')).toHaveLength(1);
308
- expect(await store.removeDependency(dep.id)).toBe(true);
309
-
310
- const entry = await store.logTime({ taskId: 't1', userId: 'u1', hours: 1.5, isBillable: false, description: 'Work', loggedAt: '2026-10-01T10:00:00.000Z' });
311
- expect((await store.getTimeEntries('t1'))[0]).toMatchObject({ id: entry.id, hours: 1.5, isBillable: false, description: 'Work', loggedAt: '2026-10-01T10:00:00.000Z' });
312
- expect(await store.deleteTimeEntry(entry.id)).toBe(true);
313
- expect(await store.getTimeEntries('t1')).toHaveLength(0);
314
-
315
- const webhook = await store.addWebhook({ name: 'Hook', url: 'https://example.com/h', secret: 'whsec_x', events: ['*'], active: true, tenantId: 'tenant-1' });
316
- expect(await store.getWebhook(webhook.id)).toMatchObject({ name: 'Hook', secret: 'whsec_x', events: ['*'], active: true, tenantId: 'tenant-1' });
317
- });
318
- });
319
- }
@@ -1 +0,0 @@
1
- export * from './conformance.js';