mcp-sunsama 0.3.0 → 0.5.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.
@@ -1,45 +1,48 @@
1
- import type { Task } from "sunsama-api";
1
+ import type { Task, TaskIntegration } from "sunsama-api";
2
2
 
3
3
  /**
4
4
  * Trimmed task type containing only essential properties for API responses.
5
5
  * Reduces response size by 60-80% while preserving core task information.
6
- *
6
+ *
7
7
  * Extends core Task properties with simplified versions of complex fields:
8
8
  * - integration: Service name only (instead of full nested object)
9
9
  * - subtasks: Array of titles only (instead of full subtask objects)
10
10
  */
11
- export type TrimmedTask = Pick<Task,
12
- | '_id'
13
- | 'text'
14
- | 'completed'
15
- | 'assigneeId'
16
- | 'createdAt'
11
+ export type TrimmedTask = Pick<Task,
12
+ | '_id'
13
+ | 'text'
14
+ | 'completed'
15
+ | 'assigneeId'
16
+ | 'createdAt'
17
17
  | 'lastModified'
18
18
  | 'objectiveId'
19
- | 'completeDate'
20
- | 'timeEstimate'
21
- | 'dueDate'
22
- | 'notes'
19
+ | 'completeDate'
20
+ | 'timeEstimate'
21
+ | 'dueDate'
22
+ | 'notes'
23
23
  | 'streamIds'
24
24
  > & {
25
25
  /** Integration service name (e.g., 'website', 'googleCalendar') or null */
26
- integration: string | null;
26
+ integration: {
27
+ service: TaskIntegration['service'];
28
+ url?: string;
29
+ } | null;
27
30
  /** Array of subtask titles only (simplified from full subtask objects) */
28
31
  subtasks: string[];
29
32
  };
30
33
 
31
34
  /**
32
35
  * Trims a task object to include only essential properties for API responses.
33
- *
36
+ *
34
37
  * Included properties:
35
38
  * - Core identifiers: _id, assigneeId, objectiveId
36
- * - Content: text, notes
39
+ * - Content: text, notes
37
40
  * - Status: completed, completeDate
38
41
  * - Timestamps: createdAt, lastModified
39
42
  * - Planning: timeEstimate, dueDate, streamIds
40
43
  * - Simplified integration: service name only (not full nested object)
41
44
  * - Simplified subtasks: titles only (not full objects with metadata)
42
- *
45
+ *
43
46
  * Excluded properties (for size reduction):
44
47
  * - Internal metadata: notesChecksum, editorVersion, collabSnapshot, __typename
45
48
  * - Complex nested objects: full integration objects, sequence, ritual, eventInfo, runDate, timeHorizon
@@ -47,11 +50,22 @@ export type TrimmedTask = Pick<Task,
47
50
  * - UI state: subtasksCollapsed, seededEventIds, followers
48
51
  * - Redundant fields: completedBy, completeOn, recommendedTimeEstimate, recommendedStreamId, notesMarkdown
49
52
  * - Metadata: groupId, taskType, private, deleted, createdBy, archivedAt, duration
50
- *
53
+ *
51
54
  * @param task - Full task object from Sunsama API
52
55
  * @returns Trimmed task object with only essential properties
53
56
  */
54
57
  export function trimTaskForResponse(task: Task): TrimmedTask {
58
+ let integration: TrimmedTask['integration'] = null;
59
+
60
+ // Extract minimal integration data: service type and URL if available
61
+ // Integration identifiers vary by service - some have URLs (websites), others have different properties
62
+ if (task.integration) {
63
+ integration = { service: task.integration.service };
64
+ if ("url" in task.integration.identifier) {
65
+ integration.url = task.integration.identifier.url;
66
+ }
67
+ }
68
+
55
69
  return {
56
70
  _id: task._id,
57
71
  assigneeId: task.assigneeId,
@@ -59,7 +73,7 @@ export function trimTaskForResponse(task: Task): TrimmedTask {
59
73
  completed: task.completed,
60
74
  createdAt: task.createdAt,
61
75
  dueDate: task.dueDate,
62
- integration: task.integration?.service || null,
76
+ integration: integration,
63
77
  lastModified: task.lastModified,
64
78
  notes: task.notes,
65
79
  objectiveId: task.objectiveId,
@@ -72,7 +86,7 @@ export function trimTaskForResponse(task: Task): TrimmedTask {
72
86
 
73
87
  /**
74
88
  * Trims an array of task objects to include only essential properties.
75
- *
89
+ *
76
90
  * @param tasks - Array of full task objects from Sunsama API
77
91
  * @returns Array of trimmed task objects
78
92
  */