@kodelyth/msteams 2026.5.42 → 2026.6.2

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 (177) hide show
  1. package/klaw.plugin.json +726 -2
  2. package/package.json +18 -6
  3. package/api.ts +0 -3
  4. package/channel-config-api.ts +0 -1
  5. package/channel-plugin-api.ts +0 -2
  6. package/config-api.ts +0 -4
  7. package/contract-api.ts +0 -4
  8. package/index.ts +0 -20
  9. package/runtime-api.ts +0 -66
  10. package/secret-contract-api.ts +0 -5
  11. package/setup-entry.ts +0 -13
  12. package/setup-plugin-api.ts +0 -3
  13. package/src/ai-entity.ts +0 -7
  14. package/src/approval-auth.ts +0 -44
  15. package/src/attachments/bot-framework.test.ts +0 -506
  16. package/src/attachments/bot-framework.ts +0 -348
  17. package/src/attachments/download.ts +0 -328
  18. package/src/attachments/graph.test.ts +0 -441
  19. package/src/attachments/graph.ts +0 -489
  20. package/src/attachments/html.ts +0 -122
  21. package/src/attachments/payload.ts +0 -14
  22. package/src/attachments/remote-media.test.ts +0 -187
  23. package/src/attachments/remote-media.ts +0 -86
  24. package/src/attachments/shared.test.ts +0 -547
  25. package/src/attachments/shared.ts +0 -655
  26. package/src/attachments/types.ts +0 -47
  27. package/src/attachments.graph.test.ts +0 -414
  28. package/src/attachments.helpers.test.ts +0 -245
  29. package/src/attachments.test-helpers.ts +0 -17
  30. package/src/attachments.test.ts +0 -754
  31. package/src/attachments.ts +0 -18
  32. package/src/block-streaming-config.test.ts +0 -61
  33. package/src/channel-api.ts +0 -1
  34. package/src/channel.actions.test.ts +0 -797
  35. package/src/channel.directory.test.ts +0 -176
  36. package/src/channel.message-adapter.test.ts +0 -227
  37. package/src/channel.runtime.ts +0 -56
  38. package/src/channel.setup.ts +0 -77
  39. package/src/channel.test.ts +0 -136
  40. package/src/channel.ts +0 -1176
  41. package/src/config-schema.ts +0 -6
  42. package/src/config-ui-hints.ts +0 -40
  43. package/src/conversation-store-fs.test.ts +0 -81
  44. package/src/conversation-store-fs.ts +0 -149
  45. package/src/conversation-store-helpers.test.ts +0 -202
  46. package/src/conversation-store-helpers.ts +0 -105
  47. package/src/conversation-store-memory.ts +0 -51
  48. package/src/conversation-store.shared.test.ts +0 -260
  49. package/src/conversation-store.ts +0 -71
  50. package/src/directory-live.test.ts +0 -156
  51. package/src/directory-live.ts +0 -111
  52. package/src/doctor.ts +0 -27
  53. package/src/errors.test.ts +0 -154
  54. package/src/errors.ts +0 -270
  55. package/src/feedback-reflection-prompt.ts +0 -117
  56. package/src/feedback-reflection-store.ts +0 -113
  57. package/src/feedback-reflection.test.ts +0 -237
  58. package/src/feedback-reflection.ts +0 -268
  59. package/src/file-consent-helpers.test.ts +0 -328
  60. package/src/file-consent-helpers.ts +0 -115
  61. package/src/file-consent-invoke.ts +0 -150
  62. package/src/file-consent.test.ts +0 -378
  63. package/src/file-consent.ts +0 -223
  64. package/src/graph-chat.ts +0 -36
  65. package/src/graph-group-management.test.ts +0 -332
  66. package/src/graph-group-management.ts +0 -168
  67. package/src/graph-members.test.ts +0 -89
  68. package/src/graph-members.ts +0 -48
  69. package/src/graph-messages.actions.test.ts +0 -253
  70. package/src/graph-messages.read.test.ts +0 -391
  71. package/src/graph-messages.search.test.ts +0 -227
  72. package/src/graph-messages.test-helpers.ts +0 -50
  73. package/src/graph-messages.ts +0 -534
  74. package/src/graph-teams.test.ts +0 -222
  75. package/src/graph-teams.ts +0 -114
  76. package/src/graph-thread.test.ts +0 -252
  77. package/src/graph-thread.ts +0 -146
  78. package/src/graph-upload.test.ts +0 -253
  79. package/src/graph-upload.ts +0 -531
  80. package/src/graph-users.ts +0 -29
  81. package/src/graph.test.ts +0 -540
  82. package/src/graph.ts +0 -308
  83. package/src/inbound.test.ts +0 -221
  84. package/src/inbound.ts +0 -148
  85. package/src/index.ts +0 -4
  86. package/src/media-helpers.test.ts +0 -220
  87. package/src/media-helpers.ts +0 -105
  88. package/src/mentions.test.ts +0 -254
  89. package/src/mentions.ts +0 -114
  90. package/src/messenger.test.ts +0 -961
  91. package/src/messenger.ts +0 -608
  92. package/src/monitor-handler/access.ts +0 -136
  93. package/src/monitor-handler/inbound-media.test.ts +0 -314
  94. package/src/monitor-handler/inbound-media.ts +0 -180
  95. package/src/monitor-handler/message-handler-mock-support.test-support.ts +0 -28
  96. package/src/monitor-handler/message-handler.authz.test.ts +0 -739
  97. package/src/monitor-handler/message-handler.dm-media.test.ts +0 -54
  98. package/src/monitor-handler/message-handler.test-support.ts +0 -99
  99. package/src/monitor-handler/message-handler.thread-parent.test.ts +0 -225
  100. package/src/monitor-handler/message-handler.thread-session.test.ts +0 -132
  101. package/src/monitor-handler/message-handler.ts +0 -1003
  102. package/src/monitor-handler/reaction-handler.test.ts +0 -325
  103. package/src/monitor-handler/reaction-handler.ts +0 -122
  104. package/src/monitor-handler/thread-session.ts +0 -30
  105. package/src/monitor-handler.adaptive-card.test.ts +0 -158
  106. package/src/monitor-handler.feedback-authz.test.ts +0 -357
  107. package/src/monitor-handler.file-consent.test.ts +0 -443
  108. package/src/monitor-handler.sso.test.ts +0 -576
  109. package/src/monitor-handler.test-helpers.ts +0 -181
  110. package/src/monitor-handler.ts +0 -538
  111. package/src/monitor-handler.types.ts +0 -27
  112. package/src/monitor-types.ts +0 -6
  113. package/src/monitor.lifecycle.test.ts +0 -457
  114. package/src/monitor.test.ts +0 -119
  115. package/src/monitor.ts +0 -476
  116. package/src/oauth.flow.ts +0 -77
  117. package/src/oauth.shared.ts +0 -37
  118. package/src/oauth.test.ts +0 -350
  119. package/src/oauth.token.ts +0 -162
  120. package/src/oauth.ts +0 -130
  121. package/src/outbound.test.ts +0 -400
  122. package/src/outbound.ts +0 -198
  123. package/src/pending-uploads-fs.test.ts +0 -261
  124. package/src/pending-uploads-fs.ts +0 -235
  125. package/src/pending-uploads.test.ts +0 -186
  126. package/src/pending-uploads.ts +0 -121
  127. package/src/policy.test.ts +0 -156
  128. package/src/policy.ts +0 -245
  129. package/src/polls-store-memory.ts +0 -32
  130. package/src/polls.test.ts +0 -169
  131. package/src/polls.ts +0 -312
  132. package/src/presentation.ts +0 -93
  133. package/src/probe.test.ts +0 -79
  134. package/src/probe.ts +0 -132
  135. package/src/reply-dispatcher.test.ts +0 -543
  136. package/src/reply-dispatcher.ts +0 -523
  137. package/src/reply-stream-controller.test.ts +0 -424
  138. package/src/reply-stream-controller.ts +0 -334
  139. package/src/resolve-allowlist.test.ts +0 -253
  140. package/src/resolve-allowlist.ts +0 -309
  141. package/src/revoked-context.ts +0 -17
  142. package/src/runtime.ts +0 -12
  143. package/src/sdk-types.ts +0 -59
  144. package/src/sdk.test.ts +0 -727
  145. package/src/sdk.ts +0 -916
  146. package/src/secret-contract.ts +0 -49
  147. package/src/secret-input.ts +0 -7
  148. package/src/send-context.test.ts +0 -93
  149. package/src/send-context.ts +0 -269
  150. package/src/send.test.ts +0 -588
  151. package/src/send.ts +0 -697
  152. package/src/sent-message-cache.test.ts +0 -106
  153. package/src/sent-message-cache.ts +0 -174
  154. package/src/session-route.ts +0 -40
  155. package/src/setup-core.ts +0 -162
  156. package/src/setup-surface.test.ts +0 -175
  157. package/src/setup-surface.ts +0 -319
  158. package/src/sso-token-store.test.ts +0 -74
  159. package/src/sso-token-store.ts +0 -166
  160. package/src/sso.ts +0 -300
  161. package/src/storage.ts +0 -25
  162. package/src/store-fs.ts +0 -42
  163. package/src/streaming-message.test.ts +0 -323
  164. package/src/streaming-message.ts +0 -327
  165. package/src/test-runtime.ts +0 -16
  166. package/src/thread-parent-context.test.ts +0 -224
  167. package/src/thread-parent-context.ts +0 -159
  168. package/src/token-response.ts +0 -11
  169. package/src/token.test.ts +0 -268
  170. package/src/token.ts +0 -194
  171. package/src/user-agent.test.ts +0 -121
  172. package/src/user-agent.ts +0 -53
  173. package/src/webhook-timeouts.ts +0 -27
  174. package/src/welcome-card.test.ts +0 -104
  175. package/src/welcome-card.ts +0 -57
  176. package/test-api.ts +0 -1
  177. package/tsconfig.json +0 -16
@@ -1,146 +0,0 @@
1
- import { fetchGraphJson, type GraphResponse } from "./graph.js";
2
-
3
- export type GraphThreadMessage = {
4
- id?: string;
5
- from?: {
6
- user?: { displayName?: string; id?: string };
7
- application?: { displayName?: string; id?: string };
8
- };
9
- body?: { content?: string; contentType?: string };
10
- createdDateTime?: string;
11
- };
12
-
13
- // TTL cache for team ID -> group GUID mapping.
14
- const teamGroupIdCache = new Map<string, { groupId: string; expiresAt: number }>();
15
- const CACHE_TTL_MS = 10 * 60 * 1000; // 10 minutes
16
-
17
- /**
18
- * Strip HTML tags from Teams message content, preserving @mention display names.
19
- * Teams wraps mentions in <at>Name</at> tags.
20
- */
21
- export function stripHtmlFromTeamsMessage(html: string): string {
22
- // Preserve mention display names by replacing <at>Name</at> with @Name.
23
- let text = html.replace(/<at[^>]*>(.*?)<\/at>/gi, "@$1");
24
- // Strip remaining HTML tags.
25
- text = text.replace(/<[^>]*>/g, " ");
26
- // Decode common HTML entities.
27
- text = text
28
- .replace(/&amp;/g, "&")
29
- .replace(/&lt;/g, "<")
30
- .replace(/&gt;/g, ">")
31
- .replace(/&quot;/g, '"')
32
- .replace(/&#39;/g, "'")
33
- .replace(/&nbsp;/g, " ");
34
- // Normalize whitespace.
35
- return text.replace(/\s+/g, " ").trim();
36
- }
37
-
38
- /**
39
- * Resolve the Azure AD group GUID for a Teams conversation team ID.
40
- * Results are cached with a TTL to avoid repeated Graph API calls.
41
- */
42
- export async function resolveTeamGroupId(
43
- token: string,
44
- conversationTeamId: string,
45
- ): Promise<string> {
46
- const cached = teamGroupIdCache.get(conversationTeamId);
47
- if (cached && cached.expiresAt > Date.now()) {
48
- return cached.groupId;
49
- }
50
-
51
- // The team ID in channelData is typically the group ID itself for standard teams.
52
- // Validate by fetching /teams/{id} and returning the confirmed id.
53
- // Requires Team.ReadBasic.All permission; fall back to raw ID if missing.
54
- try {
55
- const path = `/teams/${encodeURIComponent(conversationTeamId)}?$select=id`;
56
- const team = await fetchGraphJson<{ id?: string }>({ token, path });
57
- const groupId = team.id ?? conversationTeamId;
58
-
59
- // Only cache when the Graph lookup succeeds — caching a fallback raw ID
60
- // can cause silent failures for the entire TTL if the ID is not a valid
61
- // Graph team GUID (e.g. Bot Framework conversation key).
62
- teamGroupIdCache.set(conversationTeamId, {
63
- groupId,
64
- expiresAt: Date.now() + CACHE_TTL_MS,
65
- });
66
-
67
- return groupId;
68
- } catch {
69
- // Fallback to raw team ID without caching so subsequent calls retry the
70
- // Graph lookup instead of using a potentially invalid cached value.
71
- return conversationTeamId;
72
- }
73
- }
74
-
75
- /**
76
- * Fetch a single channel message (the parent/root of a thread).
77
- * Returns undefined on error so callers can degrade gracefully.
78
- */
79
- export async function fetchChannelMessage(
80
- token: string,
81
- groupId: string,
82
- channelId: string,
83
- messageId: string,
84
- ): Promise<GraphThreadMessage | undefined> {
85
- const path = `/teams/${encodeURIComponent(groupId)}/channels/${encodeURIComponent(channelId)}/messages/${encodeURIComponent(messageId)}?$select=id,from,body,createdDateTime`;
86
- try {
87
- return await fetchGraphJson<GraphThreadMessage>({ token, path });
88
- } catch {
89
- return undefined;
90
- }
91
- }
92
-
93
- /**
94
- * Fetch thread replies for a channel message, ordered chronologically.
95
- *
96
- * **Limitation:** The Graph API replies endpoint (`/messages/{id}/replies`) does not
97
- * support `$orderby`, so results are always returned in ascending (oldest-first) order.
98
- * Combined with the `$top` cap of 50, this means only the **oldest 50 replies** are
99
- * returned for long threads — newer replies are silently omitted. There is currently no
100
- * Graph API workaround for this; pagination via `@odata.nextLink` can retrieve more
101
- * replies but still in ascending order only.
102
- */
103
- export async function fetchThreadReplies(
104
- token: string,
105
- groupId: string,
106
- channelId: string,
107
- messageId: string,
108
- limit = 50,
109
- ): Promise<GraphThreadMessage[]> {
110
- const top = Math.min(Math.max(limit, 1), 50);
111
- // NOTE: Graph replies endpoint returns oldest-first and does not support $orderby.
112
- // For threads with >50 replies, only the oldest 50 are returned. The most recent
113
- // replies (often the most relevant context) may be truncated.
114
- const path = `/teams/${encodeURIComponent(groupId)}/channels/${encodeURIComponent(channelId)}/messages/${encodeURIComponent(messageId)}/replies?$top=${top}&$select=id,from,body,createdDateTime`;
115
- const res = await fetchGraphJson<GraphResponse<GraphThreadMessage>>({ token, path });
116
- return res.value ?? [];
117
- }
118
-
119
- /**
120
- * Format thread messages into a context string for the agent.
121
- * Skips the current message (by id) and blank messages.
122
- */
123
- export function formatThreadContext(
124
- messages: GraphThreadMessage[],
125
- currentMessageId?: string,
126
- ): string {
127
- const lines: string[] = [];
128
- for (const msg of messages) {
129
- if (msg.id && msg.id === currentMessageId) {
130
- continue;
131
- } // Skip the triggering message.
132
- const sender = msg.from?.user?.displayName ?? msg.from?.application?.displayName ?? "unknown";
133
- const contentType = msg.body?.contentType ?? "text";
134
- const rawContent = msg.body?.content ?? "";
135
- const content =
136
- contentType === "html" ? stripHtmlFromTeamsMessage(rawContent) : rawContent.trim();
137
- if (!content) {
138
- continue;
139
- }
140
- lines.push(`${sender}: ${content}`);
141
- }
142
- return lines.join("\n");
143
- }
144
-
145
- // Exported for testing only.
146
- export { teamGroupIdCache as _teamGroupIdCacheForTest };
@@ -1,253 +0,0 @@
1
- import { withFetchPreconnect } from "klaw/plugin-sdk/test-env";
2
- import { describe, expect, it, vi } from "vitest";
3
- import { buildTeamsFileInfoCard } from "./graph-chat.js";
4
- import { resolveGraphChatId, uploadToOneDrive, uploadToSharePoint } from "./graph-upload.js";
5
-
6
- type FetchCall = [string, { method?: string; headers?: Record<string, string> } | undefined];
7
-
8
- function requireFetchCall(fetchFn: ReturnType<typeof vi.fn>, index = 0): FetchCall {
9
- const call = fetchFn.mock.calls[index] as unknown as FetchCall | undefined;
10
- if (!call) {
11
- throw new Error(`fetch call ${index} missing`);
12
- }
13
- return call;
14
- }
15
-
16
- function expectGraphUploadFetch(fetchFn: ReturnType<typeof vi.fn>, expectedUrl: string): void {
17
- const [url, init] = requireFetchCall(fetchFn);
18
- expect(url).toBe(expectedUrl);
19
- expect(init?.method).toBe("PUT");
20
- expect(init?.headers?.Authorization).toBe("Bearer graph-token");
21
- expect(init?.headers?.["Content-Type"]).toBe("application/octet-stream");
22
- expect(init?.headers?.["User-Agent"]).toMatch(/^teams\.ts\[apps\]\/.+ Klaw\/.+$/);
23
- }
24
-
25
- describe("graph upload helpers", () => {
26
- const tokenProvider = {
27
- getAccessToken: vi.fn(async () => "graph-token"),
28
- };
29
-
30
- it("uploads to OneDrive with the personal drive path", async () => {
31
- const fetchFn = vi.fn(
32
- async () =>
33
- new Response(
34
- JSON.stringify({ id: "item-1", webUrl: "https://example.com/1", name: "a.txt" }),
35
- {
36
- status: 200,
37
- headers: { "content-type": "application/json" },
38
- },
39
- ),
40
- );
41
-
42
- const result = await uploadToOneDrive({
43
- buffer: Buffer.from("hello"),
44
- filename: "a.txt",
45
- tokenProvider,
46
- fetchFn: withFetchPreconnect(fetchFn),
47
- });
48
-
49
- expectGraphUploadFetch(
50
- fetchFn,
51
- "https://graph.microsoft.com/v1.0/me/drive/root:/KlawShared/a.txt:/content",
52
- );
53
- expect(result).toEqual({
54
- id: "item-1",
55
- webUrl: "https://example.com/1",
56
- name: "a.txt",
57
- });
58
- });
59
-
60
- it("uploads to SharePoint with the site drive path", async () => {
61
- const fetchFn = vi.fn(
62
- async () =>
63
- new Response(
64
- JSON.stringify({ id: "item-2", webUrl: "https://example.com/2", name: "b.txt" }),
65
- {
66
- status: 200,
67
- headers: { "content-type": "application/json" },
68
- },
69
- ),
70
- );
71
-
72
- const result = await uploadToSharePoint({
73
- buffer: Buffer.from("world"),
74
- filename: "b.txt",
75
- siteId: "site-123",
76
- tokenProvider,
77
- fetchFn: withFetchPreconnect(fetchFn),
78
- });
79
-
80
- expectGraphUploadFetch(
81
- fetchFn,
82
- "https://graph.microsoft.com/v1.0/sites/site-123/drive/root:/KlawShared/b.txt:/content",
83
- );
84
- expect(result).toEqual({
85
- id: "item-2",
86
- webUrl: "https://example.com/2",
87
- name: "b.txt",
88
- });
89
- });
90
-
91
- it("rejects upload responses missing required fields", async () => {
92
- const fetchFn = vi.fn(
93
- async () =>
94
- new Response(JSON.stringify({ id: "item-3" }), {
95
- status: 200,
96
- headers: { "content-type": "application/json" },
97
- }),
98
- );
99
-
100
- await expect(
101
- uploadToSharePoint({
102
- buffer: Buffer.from("world"),
103
- filename: "bad.txt",
104
- siteId: "site-123",
105
- tokenProvider,
106
- fetchFn: withFetchPreconnect(fetchFn),
107
- }),
108
- ).rejects.toThrow("SharePoint upload response missing required fields");
109
- });
110
- });
111
-
112
- describe("resolveGraphChatId", () => {
113
- const tokenProvider = {
114
- getAccessToken: vi.fn(async () => "graph-token"),
115
- };
116
-
117
- it("returns the ID directly when it already starts with 19:", async () => {
118
- const fetchFn = vi.fn();
119
- const result = await resolveGraphChatId({
120
- botFrameworkConversationId: "19:abc123@thread.tacv2",
121
- tokenProvider,
122
- fetchFn: withFetchPreconnect(fetchFn),
123
- });
124
- // Should short-circuit without making any API call
125
- expect(fetchFn).not.toHaveBeenCalled();
126
- expect(result).toBe("19:abc123@thread.tacv2");
127
- });
128
-
129
- it("resolves personal DM chat ID via Graph API using user AAD object ID", async () => {
130
- const fetchFn = vi.fn(
131
- async () =>
132
- new Response(JSON.stringify({ value: [{ id: "19:dm-chat-id@unq.gbl.spaces" }] }), {
133
- status: 200,
134
- headers: { "content-type": "application/json" },
135
- }),
136
- );
137
-
138
- const result = await resolveGraphChatId({
139
- botFrameworkConversationId: "a:1abc_bot_framework_dm_id",
140
- userAadObjectId: "user-aad-object-id-123",
141
- tokenProvider,
142
- fetchFn: withFetchPreconnect(fetchFn),
143
- });
144
-
145
- expect(fetchFn).toHaveBeenCalledTimes(1);
146
- const [callUrlRaw, init] = requireFetchCall(fetchFn);
147
- expect(init?.headers?.Authorization).toBe("Bearer graph-token");
148
- expect(init?.headers?.["User-Agent"]).toMatch(/^teams\.ts\[apps\]\/.+ Klaw\/.+$/);
149
- const callUrl = new URL(callUrlRaw);
150
- expect(callUrl.origin).toBe("https://graph.microsoft.com");
151
- expect(callUrl.pathname).toBe("/v1.0/me/chats");
152
- expect(callUrl.searchParams.get("$filter")).toBe(
153
- "chatType eq 'oneOnOne' and members/any(m:m/microsoft.graph.aadUserConversationMember/userId eq 'user-aad-object-id-123')",
154
- );
155
- expect(callUrl.searchParams.get("$select")).toBe("id");
156
- expect(result).toBe("19:dm-chat-id@unq.gbl.spaces");
157
- });
158
-
159
- it("resolves personal DM chat ID without user AAD object ID (lists all 1:1 chats)", async () => {
160
- const fetchFn = vi.fn(
161
- async () =>
162
- new Response(JSON.stringify({ value: [{ id: "19:fallback-chat@unq.gbl.spaces" }] }), {
163
- status: 200,
164
- headers: { "content-type": "application/json" },
165
- }),
166
- );
167
-
168
- const result = await resolveGraphChatId({
169
- botFrameworkConversationId: "8:orgid:user-object-id",
170
- tokenProvider,
171
- fetchFn: withFetchPreconnect(fetchFn),
172
- });
173
-
174
- expect(fetchFn).toHaveBeenCalledOnce();
175
- expect(result).toBe("19:fallback-chat@unq.gbl.spaces");
176
- });
177
-
178
- it("returns null when Graph API returns no chats", async () => {
179
- const fetchFn = vi.fn(
180
- async () =>
181
- new Response(JSON.stringify({ value: [] }), {
182
- status: 200,
183
- headers: { "content-type": "application/json" },
184
- }),
185
- );
186
-
187
- const result = await resolveGraphChatId({
188
- botFrameworkConversationId: "a:1unknown_dm",
189
- userAadObjectId: "some-user",
190
- tokenProvider,
191
- fetchFn: withFetchPreconnect(fetchFn),
192
- });
193
-
194
- expect(result).toBeNull();
195
- });
196
-
197
- it("returns null when Graph API call fails", async () => {
198
- const fetchFn = vi.fn(
199
- async () =>
200
- new Response("Unauthorized", {
201
- status: 401,
202
- headers: { "content-type": "text/plain" },
203
- }),
204
- );
205
-
206
- const result = await resolveGraphChatId({
207
- botFrameworkConversationId: "a:1some_dm_id",
208
- userAadObjectId: "some-user",
209
- tokenProvider,
210
- fetchFn: withFetchPreconnect(fetchFn),
211
- });
212
-
213
- expect(result).toBeNull();
214
- });
215
- });
216
-
217
- describe("buildTeamsFileInfoCard", () => {
218
- it("extracts a unique id from quoted etags and lowercases file extensions", () => {
219
- expect(
220
- buildTeamsFileInfoCard({
221
- eTag: '"{ABC-123},42"',
222
- name: "Quarterly.Report.PDF",
223
- webDavUrl: "https://sharepoint.example.com/file.pdf",
224
- }),
225
- ).toEqual({
226
- contentType: "application/vnd.microsoft.teams.card.file.info",
227
- contentUrl: "https://sharepoint.example.com/file.pdf",
228
- name: "Quarterly.Report.PDF",
229
- content: {
230
- uniqueId: "ABC-123",
231
- fileType: "pdf",
232
- },
233
- });
234
- });
235
-
236
- it("keeps the raw etag when no version suffix exists and handles extensionless files", () => {
237
- expect(
238
- buildTeamsFileInfoCard({
239
- eTag: "plain-etag",
240
- name: "README",
241
- webDavUrl: "https://sharepoint.example.com/readme",
242
- }),
243
- ).toEqual({
244
- contentType: "application/vnd.microsoft.teams.card.file.info",
245
- contentUrl: "https://sharepoint.example.com/readme",
246
- name: "README",
247
- content: {
248
- uniqueId: "plain-etag",
249
- fileType: "",
250
- },
251
- });
252
- });
253
- });