@pipedream/microsoft_teams 0.1.8 → 0.2.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.
@@ -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.11",
8
+ version: "0.0.12",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -0,0 +1,40 @@
1
+ import microsoftTeams from "../../microsoft_teams.app.mjs";
2
+
3
+ export default {
4
+ key: "microsoft_teams-get-chat-message",
5
+ name: "Get Chat Message",
6
+ description: "Get a specific message from a chat. [See the documentation](https://learn.microsoft.com/en-us/graph/api/chatmessage-get?view=graph-rest-1.0&tabs=http)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ microsoftTeams,
16
+ chatId: {
17
+ propDefinition: [
18
+ microsoftTeams,
19
+ "chat",
20
+ ],
21
+ },
22
+ messageId: {
23
+ propDefinition: [
24
+ microsoftTeams,
25
+ "messageId",
26
+ (c) => ({
27
+ chatId: c.chatId,
28
+ }),
29
+ ],
30
+ },
31
+ },
32
+ async run({ $ }) {
33
+ const response = await this.microsoftTeams.getChatMessage({
34
+ chatId: this.chatId,
35
+ messageId: this.messageId,
36
+ });
37
+ $.export("$summary", `Successfully fetched message "${response.body.content}"`);
38
+ return response;
39
+ },
40
+ };
@@ -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.11",
8
+ version: "0.0.12",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -0,0 +1,47 @@
1
+ import microsoftTeams from "../../microsoft_teams.app.mjs";
2
+
3
+ export default {
4
+ key: "microsoft_teams-list-messages-in-chat",
5
+ name: "List Messages in Chat",
6
+ description: "Get the list of messages in a chat. [See the documentation](https://learn.microsoft.com/en-us/graph/api/chat-list-messages?view=graph-rest-1.0&tabs=http)",
7
+ type: "action",
8
+ version: "0.0.1",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ microsoftTeams,
16
+ chatId: {
17
+ propDefinition: [
18
+ microsoftTeams,
19
+ "chat",
20
+ ],
21
+ },
22
+ maxResults: {
23
+ type: "integer",
24
+ label: "Max Results",
25
+ description: "The maximum number of results to return",
26
+ optional: true,
27
+ },
28
+ },
29
+ async run({ $ }) {
30
+ const messages = [];
31
+ const paginator = this.microsoftTeams.paginate(this.microsoftTeams.listChatMessages, {
32
+ chatId: this.chatId,
33
+ });
34
+
35
+ for await (const message of paginator) {
36
+ messages.push(message);
37
+ if (this.maxResults && messages.length >= this.maxResults) {
38
+ break;
39
+ }
40
+ }
41
+
42
+ $.export("$summary", `Successfully fetched ${messages.length} message${messages.length === 1
43
+ ? ""
44
+ : "s"}`);
45
+ return messages;
46
+ },
47
+ };
@@ -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.8",
8
+ version: "0.0.9",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -0,0 +1,80 @@
1
+ import microsoftTeams from "../../microsoft_teams.app.mjs";
2
+
3
+ export default {
4
+ key: "microsoft_teams-search-messages",
5
+ name: "Search Messages",
6
+ description: "Search for email or chat messages. [See the documentation](https://learn.microsoft.com/en-us/graph/api/search-query?view=graph-rest-1.0&tabs=http)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ microsoftTeams,
16
+ entityType: {
17
+ type: "string",
18
+ label: "Entity Type",
19
+ description: "The type of entity to search for",
20
+ options: [
21
+ {
22
+ label: "Email Messages",
23
+ value: "message",
24
+ },
25
+ {
26
+ label: "Chat Messages",
27
+ value: "chatMessage",
28
+ },
29
+ ],
30
+ },
31
+ queryString: {
32
+ type: "string",
33
+ label: "Query String",
34
+ description: "The query string to search for",
35
+ },
36
+ from: {
37
+ type: "integer",
38
+ label: "From",
39
+ description: "The index of the first result to return",
40
+ default: 0,
41
+ optional: true,
42
+ },
43
+ size: {
44
+ type: "integer",
45
+ label: "Size",
46
+ description: "The number of results to return",
47
+ default: 25,
48
+ max: 25,
49
+ optional: true,
50
+ },
51
+ },
52
+ async run({ $ }) {
53
+ const response = await this.microsoftTeams.searchQuery({
54
+ content: {
55
+ requests: [
56
+ {
57
+ entityTypes: [
58
+ this.entityType,
59
+ ],
60
+ query: {
61
+ queryString: this.queryString,
62
+ },
63
+ from: this.from,
64
+ size: this.size,
65
+ },
66
+ ],
67
+ },
68
+ });
69
+
70
+ if (response.value[0].hitsContainers[0].hits?.length > 0) {
71
+ $.export("$summary", `Successfully fetched ${response.value[0].hitsContainers[0].hits.length} result${response.value[0].hitsContainers[0].hits.length === 1
72
+ ? ""
73
+ : "s"}`);
74
+ } else {
75
+ $.export("$summary", "No results found");
76
+ }
77
+
78
+ return response;
79
+ },
80
+ };
@@ -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.11",
8
+ version: "0.0.12",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -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.11",
8
+ version: "0.0.12",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -131,6 +131,31 @@ export default {
131
131
  },
132
132
  useQuery: true,
133
133
  },
134
+ messageId: {
135
+ type: "string",
136
+ label: "Message ID",
137
+ description: "The ID of the message to retrieve",
138
+ async options({
139
+ prevContext, chatId,
140
+ }) {
141
+ const response = prevContext?.nextLink
142
+ ? await this.makeRequest({
143
+ path: prevContext.nextLink,
144
+ })
145
+ : await this.listChatMessages({
146
+ chatId,
147
+ });
148
+ return {
149
+ options: response.value.map((message) => ({
150
+ label: message.body.content,
151
+ value: message.id,
152
+ })),
153
+ context: {
154
+ nextLink: response["@odata.nextLink"],
155
+ },
156
+ };
157
+ },
158
+ },
134
159
  channelDisplayName: {
135
160
  type: "string",
136
161
  label: "Display Name",
@@ -294,5 +319,19 @@ export default {
294
319
  path: `/teams/${teamId}/schedule/shifts`,
295
320
  });
296
321
  },
322
+ async getChatMessage({
323
+ chatId, messageId,
324
+ }) {
325
+ return this.makeRequest({
326
+ path: `/chats/${chatId}/messages/${messageId}`,
327
+ });
328
+ },
329
+ async searchQuery({ content }) {
330
+ return this.makeRequest({
331
+ method: "post",
332
+ path: "/search/query",
333
+ content,
334
+ });
335
+ },
297
336
  },
298
337
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/microsoft_teams",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "description": "Pipedream Microsoft Teams Components",
5
5
  "main": "microsoft_teams.app.mjs",
6
6
  "keywords": [
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@microsoft/microsoft-graph-client": "^3.0.2",
18
- "@pipedream/platform": "^3.1.0",
18
+ "@pipedream/platform": "^3.1.1",
19
19
  "isomorphic-fetch": "^3.0.0"
20
20
  }
21
21
  }
@@ -59,21 +59,38 @@ export default {
59
59
  getResources() {
60
60
  throw new Error("getResources is not implemented");
61
61
  },
62
- },
63
- async run() {
64
- let lastDate = this._getLastDate();
65
- const tsField = this.getTsField();
62
+ async processEvents(max) {
63
+ let lastDate = this._getLastDate();
64
+ const tsField = this.getTsField();
65
+
66
+ const resources = await this.getResources(lastDate, tsField);
67
+ let items = [];
68
+ for (const resource of resources) {
69
+ const date = resource[tsField];
70
+ if (!lastDate || (date && Date.parse(date) > lastDate)) {
71
+ lastDate = Date.parse(date);
72
+ }
73
+ items.push(resource);
74
+ }
75
+
76
+ this._setLastDate(lastDate);
66
77
 
67
- const resources = await this.getResources(lastDate, tsField);
68
- for (const resource of resources) {
69
- const date = resource[tsField];
70
- if (!lastDate || (date && Date.parse(date) > lastDate)) {
71
- lastDate = Date.parse(date);
78
+ if (max) {
79
+ items = items.slice(0, max);
72
80
  }
73
- const meta = this.generateMeta(resource);
74
- this.$emit(resource, meta);
75
- }
76
81
 
77
- this._setLastDate(lastDate);
82
+ items.forEach((item) => {
83
+ const meta = this.generateMeta(item);
84
+ this.$emit(item, meta);
85
+ });
86
+ },
87
+ },
88
+ hooks: {
89
+ async deploy() {
90
+ await this.processEvents(10);
91
+ },
92
+ },
93
+ async run() {
94
+ await this.processEvents();
78
95
  },
79
96
  };
@@ -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. [See the documentation](https://learn.microsoft.com/en-us/graph/api/team-list-allchannels?view=graph-rest-1.0&tabs=http)",
8
- version: "0.0.13",
8
+ version: "0.0.15",
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. [See the documentation](https://learn.microsoft.com/en-us/graph/api/channel-list-messages?view=graph-rest-1.0&tabs=http)",
8
- version: "0.0.13",
8
+ version: "0.0.15",
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. [See the documentation](https://learn.microsoft.com/en-us/graph/api/chat-list?view=graph-rest-1.0&tabs=http)",
8
- version: "0.0.13",
8
+ version: "0.0.15",
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. [See the documentation](https://learn.microsoft.com/en-us/graph/api/chat-list-messages?view=graph-rest-1.0&tabs=http)",
8
- version: "0.0.13",
8
+ version: "0.0.15",
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. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-joinedteams?view=graph-rest-1.0&tabs=http)",
8
- version: "0.0.13",
8
+ version: "0.0.15",
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. [See the documentation](https://learn.microsoft.com/en-us/graph/api/team-list-members?view=graph-rest-1.0&tabs=http)",
8
- version: "0.0.13",
8
+ version: "0.0.15",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {
@@ -34,12 +34,12 @@ export default {
34
34
  ts: Date.now(),
35
35
  };
36
36
  },
37
- },
38
- async run() {
39
- const resources = await this.getResources();
40
- for (const resource of resources) {
41
- const meta = this.generateMeta(resource);
42
- this.$emit(resource, meta);
43
- }
37
+ async processEvents() {
38
+ const resources = await this.getResources();
39
+ for (const resource of resources) {
40
+ const meta = this.generateMeta(resource);
41
+ this.$emit(resource, meta);
42
+ }
43
+ },
44
44
  },
45
45
  };