trekoon 0.2.0 → 0.2.4

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.
@@ -4,6 +4,14 @@ import { appendEventWithGitContext } from "../sync/event-writes";
4
4
  import { ENTITY_OPERATIONS } from "./mutation-operations";
5
5
  import { TrackerDomain } from "./tracker-domain";
6
6
  import {
7
+ type CompactEpicCreateResult,
8
+ type CompactEpicExpandResult,
9
+ type CompactDependencyBatchAddResult,
10
+ type CompactDependencySpec,
11
+ type CompactSubtaskBatchCreateResult,
12
+ type CompactSubtaskSpec,
13
+ type CompactTaskBatchCreateResult,
14
+ type CompactTaskSpec,
7
15
  type DependencyRecord,
8
16
  type EpicRecord,
9
17
  type SearchEntityMatch,
@@ -104,6 +112,66 @@ export class MutationService {
104
112
  })();
105
113
  }
106
114
 
115
+ createEpicGraph(input: {
116
+ title: string;
117
+ description: string;
118
+ status?: string | undefined;
119
+ taskSpecs: readonly CompactTaskSpec[];
120
+ subtaskSpecs: readonly CompactSubtaskSpec[];
121
+ dependencySpecs: readonly CompactDependencySpec[];
122
+ }): CompactEpicCreateResult {
123
+ return this.#db.transaction((): CompactEpicCreateResult => {
124
+ const epic = this.#domain.createEpic(input);
125
+ const created = this.#domain.expandEpic({
126
+ epicId: epic.id,
127
+ taskSpecs: input.taskSpecs,
128
+ subtaskSpecs: input.subtaskSpecs,
129
+ dependencySpecs: input.dependencySpecs,
130
+ });
131
+
132
+ this.#appendEntityEvent("epic", epic.id, ENTITY_OPERATIONS.epic.created, {
133
+ title: epic.title,
134
+ description: epic.description,
135
+ status: epic.status,
136
+ });
137
+
138
+ for (const task of created.tasks) {
139
+ this.#appendEntityEvent("task", task.id, ENTITY_OPERATIONS.task.created, {
140
+ epic_id: task.epicId,
141
+ title: task.title,
142
+ description: task.description,
143
+ status: task.status,
144
+ });
145
+ }
146
+
147
+ for (const subtask of created.subtasks) {
148
+ this.#appendEntityEvent("subtask", subtask.id, ENTITY_OPERATIONS.subtask.created, {
149
+ task_id: subtask.taskId,
150
+ title: subtask.title,
151
+ description: subtask.description,
152
+ status: subtask.status,
153
+ });
154
+ }
155
+
156
+ for (const dependency of created.dependencies) {
157
+ this.#appendEntityEvent("dependency", dependency.id, ENTITY_OPERATIONS.dependency.added, {
158
+ source_id: dependency.sourceId,
159
+ source_kind: dependency.sourceKind,
160
+ depends_on_id: dependency.dependsOnId,
161
+ depends_on_kind: dependency.dependsOnKind,
162
+ });
163
+ }
164
+
165
+ return {
166
+ epic,
167
+ tasks: created.tasks,
168
+ subtasks: created.subtasks,
169
+ dependencies: created.dependencies,
170
+ result: created.result,
171
+ };
172
+ })();
173
+ }
174
+
107
175
  updateEpic(
108
176
  id: string,
109
177
  input: { title?: string | undefined; description?: string | undefined; status?: string | undefined },
@@ -139,6 +207,60 @@ export class MutationService {
139
207
  })();
140
208
  }
141
209
 
210
+ createTaskBatch(input: { epicId: string; specs: readonly CompactTaskSpec[] }): CompactTaskBatchCreateResult {
211
+ return this.#db.transaction((): CompactTaskBatchCreateResult => {
212
+ const created = this.#domain.createTaskBatch(input);
213
+ for (const task of created.tasks) {
214
+ this.#appendEntityEvent("task", task.id, ENTITY_OPERATIONS.task.created, {
215
+ epic_id: task.epicId,
216
+ title: task.title,
217
+ description: task.description,
218
+ status: task.status,
219
+ });
220
+ }
221
+ return created;
222
+ })();
223
+ }
224
+
225
+ expandEpic(input: {
226
+ epicId: string;
227
+ taskSpecs: readonly CompactTaskSpec[];
228
+ subtaskSpecs: readonly CompactSubtaskSpec[];
229
+ dependencySpecs: readonly CompactDependencySpec[];
230
+ }): CompactEpicExpandResult {
231
+ return this.#db.transaction((): CompactEpicExpandResult => {
232
+ const created = this.#domain.expandEpic(input);
233
+ for (const task of created.tasks) {
234
+ this.#appendEntityEvent("task", task.id, ENTITY_OPERATIONS.task.created, {
235
+ epic_id: task.epicId,
236
+ title: task.title,
237
+ description: task.description,
238
+ status: task.status,
239
+ });
240
+ }
241
+
242
+ for (const subtask of created.subtasks) {
243
+ this.#appendEntityEvent("subtask", subtask.id, ENTITY_OPERATIONS.subtask.created, {
244
+ task_id: subtask.taskId,
245
+ title: subtask.title,
246
+ description: subtask.description,
247
+ status: subtask.status,
248
+ });
249
+ }
250
+
251
+ for (const dependency of created.dependencies) {
252
+ this.#appendEntityEvent("dependency", dependency.id, ENTITY_OPERATIONS.dependency.added, {
253
+ source_id: dependency.sourceId,
254
+ source_kind: dependency.sourceKind,
255
+ depends_on_id: dependency.dependsOnId,
256
+ depends_on_kind: dependency.dependsOnKind,
257
+ });
258
+ }
259
+
260
+ return created;
261
+ })();
262
+ }
263
+
142
264
  updateTask(
143
265
  id: string,
144
266
  input: { title?: string | undefined; description?: string | undefined; status?: string | undefined },
@@ -180,6 +302,21 @@ export class MutationService {
180
302
  })();
181
303
  }
182
304
 
305
+ createSubtaskBatch(input: { taskId: string; specs: readonly CompactSubtaskSpec[] }): CompactSubtaskBatchCreateResult {
306
+ return this.#db.transaction((): CompactSubtaskBatchCreateResult => {
307
+ const created = this.#domain.createSubtaskBatch(input);
308
+ for (const subtask of created.subtasks) {
309
+ this.#appendEntityEvent("subtask", subtask.id, ENTITY_OPERATIONS.subtask.created, {
310
+ task_id: subtask.taskId,
311
+ title: subtask.title,
312
+ description: subtask.description,
313
+ status: subtask.status,
314
+ });
315
+ }
316
+ return created;
317
+ })();
318
+ }
319
+
183
320
  updateSubtask(
184
321
  id: string,
185
322
  input: { title?: string | undefined; description?: string | undefined; status?: string | undefined },
@@ -216,6 +353,21 @@ export class MutationService {
216
353
  })();
217
354
  }
218
355
 
356
+ addDependencyBatch(input: { specs: readonly CompactDependencySpec[] }): CompactDependencyBatchAddResult {
357
+ return this.#db.transaction((): CompactDependencyBatchAddResult => {
358
+ const created = this.#domain.addDependencyBatch(input);
359
+ for (const dependency of created.dependencies) {
360
+ this.#appendEntityEvent("dependency", dependency.id, ENTITY_OPERATIONS.dependency.added, {
361
+ source_id: dependency.sourceId,
362
+ source_kind: dependency.sourceKind,
363
+ depends_on_id: dependency.dependsOnId,
364
+ depends_on_kind: dependency.dependsOnKind,
365
+ });
366
+ }
367
+ return created;
368
+ })();
369
+ }
370
+
219
371
  removeDependency(sourceId: string, dependsOnId: string): number {
220
372
  return this.#db.transaction((): number => {
221
373
  const removed = this.#domain.removeDependency(sourceId, dependsOnId);