@pipedream/microsoft_teams 0.1.2 → 0.1.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.
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Create Channel",
6
6
  description: "Create a new channel in Microsoft Teams. [See the docs here](https://docs.microsoft.com/en-us/graph/api/channel-post?view=graph-rest-1.0&tabs=http)",
7
7
  type: "action",
8
- version: "0.0.6",
8
+ version: "0.0.8",
9
9
  props: {
10
10
  microsoftTeams,
11
11
  teamId: {
@@ -5,7 +5,7 @@ export default {
5
5
  name: "List Channels",
6
6
  description: "Lists all channels in a Microsoft Team. [See the docs here](https://docs.microsoft.com/en-us/graph/api/channel-list?view=graph-rest-1.0&tabs=http)",
7
7
  type: "action",
8
- version: "0.0.6",
8
+ version: "0.0.8",
9
9
  props: {
10
10
  microsoftTeams,
11
11
  teamId: {
@@ -5,7 +5,7 @@ export default {
5
5
  name: "List Shifts",
6
6
  description: "Get the list of shift instances for a team. [See the documentation](https://learn.microsoft.com/en-us/graph/api/schedule-list-shifts?view=graph-rest-1.0&tabs=http)",
7
7
  type: "action",
8
- version: "0.0.3",
8
+ version: "0.0.5",
9
9
  props: {
10
10
  microsoftTeams,
11
11
  teamId: {
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Send Channel Message",
6
6
  description: "Send a message to a team's channel. [See the docs here](https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-1.0&tabs=http)",
7
7
  type: "action",
8
- version: "0.0.6",
8
+ version: "0.0.8",
9
9
  props: {
10
10
  microsoftTeams,
11
11
  teamId: {
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Send Chat Message",
6
6
  description: "Send a message to a team's chat. [See the docs here](https://docs.microsoft.com/en-us/graph/api/chat-post-messages?view=graph-rest-1.0&tabs=http)",
7
7
  type: "action",
8
- version: "0.0.6",
8
+ version: "0.0.8",
9
9
  props: {
10
10
  microsoftTeams,
11
11
  chatId: {
@@ -34,7 +34,8 @@ export default {
34
34
  label: "Channel",
35
35
  description: "Team Channel",
36
36
  async options({
37
- teamId, prevContext,
37
+ teamId,
38
+ prevContext,
38
39
  }) {
39
40
  const response = prevContext.nextLink
40
41
  ? await this.makeRequest({
@@ -58,21 +59,69 @@ export default {
58
59
  chat: {
59
60
  type: "string",
60
61
  label: "Chat",
61
- description: "Team Chat within the organization (No external Contacts)",
62
- async options({ prevContext }) {
63
- const response = prevContext.nextLink
62
+ description: "Select a chat (type to search by participant names)",
63
+ async options({
64
+ prevContext, query,
65
+ }) {
66
+ let path = "/chats?$expand=members";
67
+ path += "&$top=20";
68
+
69
+ if (query) {
70
+ path += `&$search="${query}"`;
71
+ }
72
+
73
+ const response = prevContext?.nextLink
64
74
  ? await this.makeRequest({
65
75
  path: prevContext.nextLink,
66
76
  })
67
- : await this.listChats();
77
+ : await this.makeRequest({
78
+ path,
79
+ });
80
+
81
+ this._userCache = this._userCache || new Map();
68
82
  const options = [];
83
+
69
84
  for (const chat of response.value) {
70
- const members = chat.members.map((member) => member.displayName);
85
+ let members = chat.members.map((member) => ({
86
+ displayName: member.displayName,
87
+ wasNull: !member.displayName,
88
+ userId: member.userId,
89
+ email: member.email,
90
+ }));
91
+
92
+ if (members.some((member) => !member.displayName)) {
93
+ try {
94
+ const messages = await this.makeRequest({
95
+ path: `/chats/${chat.id}/messages?$top=10&$orderby=createdDateTime desc`,
96
+ });
97
+
98
+ const nameMap = new Map();
99
+ messages.value.forEach((msg) => {
100
+ if (msg.from?.user?.id && msg.from?.user?.displayName) {
101
+ nameMap.set(msg.from.user.id, msg.from.user.displayName);
102
+ }
103
+ });
104
+
105
+ members = members.map((member) => ({
106
+ ...member,
107
+ displayName: member.displayName || nameMap.get(member.userId) || member.email || "Unknown User",
108
+ }));
109
+ } catch (err) {
110
+ console.error(`Failed to fetch messages for chat ${chat.id}:`, err);
111
+ }
112
+ }
113
+
114
+ const memberNames = members.map((member) =>
115
+ member.wasNull
116
+ ? `${member.displayName} (External)`
117
+ : member.displayName);
118
+
71
119
  options.push({
72
- label: members.join(", "),
120
+ label: memberNames.join(", "),
73
121
  value: chat.id,
74
122
  });
75
123
  }
124
+
76
125
  return {
77
126
  options,
78
127
  context: {
@@ -80,6 +129,7 @@ export default {
80
129
  },
81
130
  };
82
131
  },
132
+ useQuery: true,
83
133
  },
84
134
  channelDisplayName: {
85
135
  type: "string",
@@ -120,7 +170,10 @@ export default {
120
170
  });
121
171
  },
122
172
  async makeRequest({
123
- method, path, params = {}, content,
173
+ method,
174
+ path,
175
+ params = {},
176
+ content,
124
177
  }) {
125
178
  const api = this.client().api(path);
126
179
 
@@ -167,7 +220,8 @@ export default {
167
220
  });
168
221
  },
169
222
  async createChannel({
170
- teamId, content,
223
+ teamId,
224
+ content,
171
225
  }) {
172
226
  return this.makeRequest({
173
227
  method: "post",
@@ -176,7 +230,9 @@ export default {
176
230
  });
177
231
  },
178
232
  async sendChannelMessage({
179
- teamId, channelId, content,
233
+ teamId,
234
+ channelId,
235
+ content,
180
236
  }) {
181
237
  return this.makeRequest({
182
238
  method: "post",
@@ -185,7 +241,8 @@ export default {
185
241
  });
186
242
  },
187
243
  async sendChatMessage({
188
- chatId, content,
244
+ chatId,
245
+ content,
189
246
  }) {
190
247
  return this.makeRequest({
191
248
  method: "post",
@@ -215,7 +272,8 @@ export default {
215
272
  .get();
216
273
  },
217
274
  async listChannelMessages({
218
- teamId, channelId,
275
+ teamId,
276
+ channelId,
219
277
  }) {
220
278
  return this.makeRequest({
221
279
  path: `/teams/${teamId}/channels/${channelId}/messages/delta`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/microsoft_teams",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Pipedream Microsoft Teams Components",
5
5
  "main": "microsoft_teams.app.mjs",
6
6
  "keywords": [
@@ -5,7 +5,7 @@ export default {
5
5
  key: "microsoft_teams-new-channel",
6
6
  name: "New Channel",
7
7
  description: "Emit new event when a new channel is created within a team",
8
- version: "0.0.7",
8
+ version: "0.0.9",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "microsoft_teams-new-channel-message",
6
6
  name: "New Channel Message",
7
7
  description: "Emit new event when a new message is posted in a channel",
8
- version: "0.0.7",
8
+ version: "0.0.9",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "microsoft_teams-new-chat",
6
6
  name: "New Chat",
7
7
  description: "Emit new event when a new chat is created",
8
- version: "0.0.7",
8
+ version: "0.0.9",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "microsoft_teams-new-chat-message",
6
6
  name: "New Chat Message",
7
7
  description: "Emit new event when a new message is received in a chat",
8
- version: "0.0.7",
8
+ version: "0.0.9",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "microsoft_teams-new-team",
6
6
  name: "New Team",
7
7
  description: "Emit new event when a new team is joined by the authenticated user",
8
- version: "0.0.7",
8
+ version: "0.0.9",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "microsoft_teams-new-team-member",
6
6
  name: "New Team Member",
7
7
  description: "Emit new event when a new member is added to a team",
8
- version: "0.0.7",
8
+ version: "0.0.9",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {