@pipedream/microsoft_teams 0.1.6 → 0.1.7

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.9",
8
+ version: "0.0.10",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -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.9",
8
+ version: "0.0.10",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -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.6",
8
+ version: "0.0.7",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -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.9",
8
+ version: "0.0.10",
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.9",
8
+ version: "0.0.10",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -286,7 +286,7 @@ export default {
286
286
  },
287
287
  async listChatMessages({ chatId }) {
288
288
  return this.makeRequest({
289
- path: `/chats/${chatId}/messages`,
289
+ path: `/chats/${chatId}/messages?$orderby=createdDateTime%20desc`,
290
290
  });
291
291
  },
292
292
  async listShifts({ teamId }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/microsoft_teams",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Pipedream Microsoft Teams Components",
5
5
  "main": "microsoft_teams.app.mjs",
6
6
  "keywords": [
@@ -13,27 +13,30 @@ export default {
13
13
  },
14
14
  },
15
15
  methods: {
16
- _getLastCreated() {
17
- return this.db.get("lastCreated");
16
+ _getLastDate() {
17
+ return this.db.get("lastDate");
18
18
  },
19
- _setLastCreated(lastCreated) {
20
- this.db.set("lastCreated", lastCreated);
19
+ _setLastDate(lastDate) {
20
+ this.db.set("lastDate", lastDate);
21
21
  },
22
- isNew(resource, lastCreated) {
23
- if (!resource.createdDateTime || !lastCreated) {
22
+ getTsField() {
23
+ return "createdDateTime";
24
+ },
25
+ isNew(resource, lastDate, tsField) {
26
+ if (!tsField || !resource[tsField] || !lastDate) {
24
27
  return true;
25
28
  }
26
- return Date.parse(resource.createdDateTime) > lastCreated;
29
+ return Date.parse(resource[tsField]) > lastDate;
27
30
  },
28
- async getNewPaginatedResources(fn, params, lastCreated) {
31
+ async getNewPaginatedResources(fn, params, lastDate, tsField, isSorted = false) {
29
32
  const resources = [];
30
33
  const paginator = this.paginate(fn, params);
31
34
 
32
35
  for await (const resource of paginator) {
33
- const isNewResource = this.isNew(resource, lastCreated);
36
+ const isNewResource = this.isNew(resource, lastDate, tsField);
34
37
  if (isNewResource) {
35
38
  resources.push(resource);
36
- } else {
39
+ } else if (isSorted) {
37
40
  break;
38
41
  }
39
42
  }
@@ -58,18 +61,19 @@ export default {
58
61
  },
59
62
  },
60
63
  async run() {
61
- let lastCreated = Date.parse(this._getLastCreated());
64
+ let lastDate = this._getLastDate();
65
+ const tsField = this.getTsField();
62
66
 
63
- const resources = await this.getResources(lastCreated);
67
+ const resources = await this.getResources(lastDate, tsField);
64
68
  for (const resource of resources) {
65
- const { createdDateTime } = resource;
66
- if (!lastCreated || (createdDateTime && Date.parse(createdDateTime) > lastCreated)) {
67
- lastCreated = Date.parse(createdDateTime);
69
+ const date = resource[tsField];
70
+ if (!lastDate || (date && Date.parse(date) > lastDate)) {
71
+ lastDate = Date.parse(date);
68
72
  }
69
73
  const meta = this.generateMeta(resource);
70
74
  this.$emit(resource, meta);
71
75
  }
72
76
 
73
- this._setLastCreated(lastCreated);
77
+ this._setLastDate(lastDate);
74
78
  },
75
79
  };
@@ -4,8 +4,8 @@ export default {
4
4
  ...base,
5
5
  key: "microsoft_teams-new-channel",
6
6
  name: "New Channel",
7
- description: "Emit new event when a new channel is created within a team",
8
- version: "0.0.11",
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.12",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {
@@ -19,13 +19,14 @@ export default {
19
19
  },
20
20
  methods: {
21
21
  ...base.methods,
22
- async getResources(lastCreated) {
22
+ async getResources(lastCreated, tsField) {
23
23
  return this.getNewPaginatedResources(
24
24
  this.microsoftTeams.listChannels,
25
25
  {
26
26
  teamId: this.team,
27
27
  },
28
28
  lastCreated,
29
+ tsField,
29
30
  );
30
31
  },
31
32
  generateMeta(channel) {
@@ -4,8 +4,8 @@ export default {
4
4
  ...base,
5
5
  key: "microsoft_teams-new-channel-message",
6
6
  name: "New Channel Message",
7
- description: "Emit new event when a new message is posted in a channel",
8
- version: "0.0.11",
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.12",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {
@@ -28,14 +28,19 @@ export default {
28
28
  },
29
29
  methods: {
30
30
  ...base.methods,
31
- async getResources(lastCreated) {
31
+ getTsField() {
32
+ return "lastModifiedDateTime";
33
+ },
34
+ async getResources(lastUpdated, tsField) {
32
35
  return this.getNewPaginatedResources(
33
36
  this.microsoftTeams.listChannelMessages,
34
37
  {
35
38
  teamId: this.team,
36
39
  channelId: this.channel,
37
40
  },
38
- lastCreated,
41
+ lastUpdated,
42
+ tsField,
43
+ true, // Sorted by last modified date
39
44
  );
40
45
  },
41
46
  generateMeta(message) {
@@ -4,17 +4,18 @@ export default {
4
4
  ...base,
5
5
  key: "microsoft_teams-new-chat",
6
6
  name: "New Chat",
7
- description: "Emit new event when a new chat is created",
8
- version: "0.0.11",
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.12",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
12
12
  ...base.methods,
13
- async getResources(lastCreated) {
13
+ async getResources(lastCreated, tsField) {
14
14
  return this.getNewPaginatedResources(
15
15
  this.microsoftTeams.listChats,
16
16
  {},
17
17
  lastCreated,
18
+ tsField,
18
19
  );
19
20
  },
20
21
  generateMeta(chat) {
@@ -4,8 +4,8 @@ export default {
4
4
  ...base,
5
5
  key: "microsoft_teams-new-chat-message",
6
6
  name: "New Chat Message",
7
- description: "Emit new event when a new message is received in a chat",
8
- version: "0.0.11",
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.12",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {
@@ -19,13 +19,15 @@ export default {
19
19
  },
20
20
  methods: {
21
21
  ...base.methods,
22
- async getResources(lastCreated) {
22
+ async getResources(lastCreated, tsField) {
23
23
  return this.getNewPaginatedResources(
24
24
  this.microsoftTeams.listChatMessages,
25
25
  {
26
26
  chatId: this.chat,
27
27
  },
28
28
  lastCreated,
29
+ tsField,
30
+ true, // Sorted by creation date
29
31
  );
30
32
  },
31
33
  generateMeta(message) {
@@ -4,17 +4,18 @@ export default {
4
4
  ...base,
5
5
  key: "microsoft_teams-new-team",
6
6
  name: "New Team",
7
- description: "Emit new event when a new team is joined by the authenticated user",
8
- version: "0.0.11",
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.12",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
12
12
  ...base.methods,
13
- async getResources(lastCreated) {
13
+ async getResources(lastCreated, tsField) {
14
14
  return this.getNewPaginatedResources(
15
15
  this.microsoftTeams.listTeams,
16
16
  {},
17
17
  lastCreated,
18
+ tsField,
18
19
  );
19
20
  },
20
21
  generateMeta(team) {
@@ -4,8 +4,8 @@ export default {
4
4
  ...base,
5
5
  key: "microsoft_teams-new-team-member",
6
6
  name: "New Team Member",
7
- description: "Emit new event when a new member is added to a team",
8
- version: "0.0.11",
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.12",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {