@pipedream/slack 0.9.0 → 0.9.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 (47) hide show
  1. package/actions/add-emoji-reaction/add-emoji-reaction.mjs +2 -2
  2. package/actions/approve-workflow/approve-workflow.mjs +6 -4
  3. package/actions/archive-channel/archive-channel.mjs +2 -2
  4. package/actions/common/send-message.mjs +6 -4
  5. package/actions/create-channel/create-channel.mjs +2 -2
  6. package/actions/create-reminder/create-reminder.mjs +2 -2
  7. package/actions/delete-file/delete-file.mjs +11 -2
  8. package/actions/delete-message/delete-message.mjs +2 -2
  9. package/actions/find-message/find-message.mjs +1 -1
  10. package/actions/find-user-by-email/find-user-by-email.mjs +2 -2
  11. package/actions/get-file/get-file.mjs +11 -2
  12. package/actions/invite-user-to-channel/invite-user-to-channel.mjs +15 -7
  13. package/actions/kick-user/kick-user.mjs +15 -7
  14. package/actions/list-channels/list-channels.mjs +32 -4
  15. package/actions/list-files/list-files.mjs +16 -3
  16. package/actions/list-group-members/list-group-members.mjs +33 -12
  17. package/actions/list-members-in-channel/list-members-in-channel.mjs +30 -5
  18. package/actions/list-replies/list-replies.mjs +32 -5
  19. package/actions/list-users/list-users.mjs +32 -5
  20. package/actions/reply-to-a-message/reply-to-a-message.mjs +1 -1
  21. package/actions/send-block-kit-message/send-block-kit-message.mjs +1 -1
  22. package/actions/send-large-message/send-large-message.mjs +8 -5
  23. package/actions/send-message/send-message.mjs +1 -1
  24. package/actions/send-message-advanced/send-message-advanced.mjs +1 -1
  25. package/actions/send-message-to-channel/send-message-to-channel.mjs +1 -1
  26. package/actions/send-message-to-user-or-group/send-message-to-user-or-group.mjs +1 -1
  27. package/actions/set-channel-description/set-channel-description.mjs +2 -2
  28. package/actions/set-channel-topic/set-channel-topic.mjs +2 -2
  29. package/actions/set-status/set-status.mjs +2 -2
  30. package/actions/update-group-members/update-group-members.mjs +3 -3
  31. package/actions/update-message/update-message.mjs +2 -2
  32. package/actions/update-profile/update-profile.mjs +2 -2
  33. package/actions/upload-file/upload-file.mjs +51 -7
  34. package/actions/verify-slack-signature/verify-slack-signature.mjs +1 -1
  35. package/common/constants.mjs +1 -1
  36. package/package.json +2 -2
  37. package/slack.app.mjs +267 -56
  38. package/sources/common/base.mjs +6 -6
  39. package/sources/new-channel-created/new-channel-created.mjs +1 -1
  40. package/sources/new-direct-message/new-direct-message.mjs +1 -1
  41. package/sources/new-interaction-event-received/new-interaction-event-received.mjs +1 -1
  42. package/sources/new-keyword-mention/new-keyword-mention.mjs +1 -1
  43. package/sources/new-message-in-channels/new-message-in-channels.mjs +1 -1
  44. package/sources/new-reaction-added/new-reaction-added.mjs +1 -1
  45. package/sources/new-saved-message/new-saved-message.mjs +1 -1
  46. package/sources/new-user-added/new-user-added.mjs +1 -1
  47. package/sources/new-user-mention/new-user-mention.mjs +1 -1
@@ -5,7 +5,7 @@ export default {
5
5
  key: "slack-send-large-message",
6
6
  name: "Send a Large Message (3000+ characters)",
7
7
  description: "Send a large message (more than 3000 characters) to a channel, group or user. See [postMessage](https://api.slack.com/methods/chat.postMessage) or [scheduleMessage](https://api.slack.com/methods/chat.scheduleMessage) docs here",
8
- version: "0.0.21",
8
+ version: "0.0.23",
9
9
  type: "action",
10
10
  props: {
11
11
  slack: common.props.slack,
@@ -70,17 +70,20 @@ export default {
70
70
  let response;
71
71
  if (this.post_at) {
72
72
  obj.post_at = this.post_at;
73
- response = await this.slack.sdk().chat.scheduleMessage(obj);
73
+ response = await this.slack.scheduleMessage(obj);
74
+ } else {
75
+ response = await this.slack.postChatMessage(obj);
74
76
  }
75
77
 
76
- response = await this.slack.sdk().chat.postMessage(obj);
77
78
  const { channel } = await this.slack.conversationsInfo({
78
79
  channel: response.channel,
79
80
  });
80
81
  let channelName = `#${channel?.name}`;
81
82
  if (channel.is_im) {
82
- const usernames = await this.slack.userNames();
83
- channelName = `@${usernames[channel.user]}`;
83
+ const { profile } = await this.slack.getUserProfile({
84
+ user: channel.user,
85
+ });
86
+ channelName = `@${profile.real_name}`;
84
87
  } else if (channel.is_mpim) {
85
88
  channelName = `@${channel.purpose.value}`;
86
89
  }
@@ -6,7 +6,7 @@ export default {
6
6
  key: "slack-send-message",
7
7
  name: "Send Message",
8
8
  description: "Send a message to a user, group, private channel or public channel. [See the documentation](https://api.slack.com/methods/chat.postMessage)",
9
- version: "0.0.17",
9
+ version: "0.0.19",
10
10
  type: "action",
11
11
  props: {
12
12
  slack: common.props.slack,
@@ -7,7 +7,7 @@ export default {
7
7
  key: "slack-send-message-advanced",
8
8
  name: "Send Message (Advanced)",
9
9
  description: "Customize advanced setttings and send a message to a channel, group or user. See [postMessage](https://api.slack.com/methods/chat.postMessage) or [scheduleMessage](https://api.slack.com/methods/chat.scheduleMessage) docs here",
10
- version: "0.0.4",
10
+ version: "0.0.6",
11
11
  type: "action",
12
12
  props: {
13
13
  slack: common.props.slack,
@@ -6,7 +6,7 @@ export default {
6
6
  key: "slack-send-message-to-channel",
7
7
  name: "Send Message to Channel",
8
8
  description: "Send a message to a public or private channel. [See the documentation](https://api.slack.com/methods/chat.postMessage)",
9
- version: "0.0.2",
9
+ version: "0.0.4",
10
10
  type: "action",
11
11
  props: {
12
12
  slack: common.props.slack,
@@ -7,7 +7,7 @@ export default {
7
7
  key: "slack-send-message-to-user-or-group",
8
8
  name: "Send Message to User or Group",
9
9
  description: "Send a message to a user or group. [See the documentation](https://api.slack.com/methods/chat.postMessage)",
10
- version: "0.0.2",
10
+ version: "0.0.4",
11
11
  type: "action",
12
12
  props: {
13
13
  slack: common.props.slack,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "slack-set-channel-description",
5
5
  name: "Set Channel Description",
6
6
  description: "Change the description or purpose of a channel. [See the documentation](https://api.slack.com/methods/conversations.setPurpose)",
7
- version: "0.0.6",
7
+ version: "0.0.8",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -22,7 +22,7 @@ export default {
22
22
  },
23
23
  },
24
24
  async run({ $ }) {
25
- const response = await this.slack.sdk().conversations.setPurpose({
25
+ const response = await this.slack.setChannelDescription({
26
26
  channel: this.conversation,
27
27
  purpose: this.purpose,
28
28
  });
@@ -4,7 +4,7 @@ export default {
4
4
  key: "slack-set-channel-topic",
5
5
  name: "Set Channel Topic",
6
6
  description: "Set the topic on a selected channel. [See the documentation](https://api.slack.com/methods/conversations.setTopic)",
7
- version: "0.0.21",
7
+ version: "0.0.23",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -22,7 +22,7 @@ export default {
22
22
  },
23
23
  },
24
24
  async run({ $ }) {
25
- const response = await this.slack.sdk().conversations.setTopic({
25
+ const response = await this.slack.setChannelTopic({
26
26
  channel: this.conversation,
27
27
  topic: this.topic,
28
28
  });
@@ -4,7 +4,7 @@ export default {
4
4
  key: "slack-set-status",
5
5
  name: "Set Status",
6
6
  description: "Set the current status for a user. [See the documentation](https://api.slack.com/methods/users.profile.set)",
7
- version: "0.0.6",
7
+ version: "0.0.8",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -30,7 +30,7 @@ export default {
30
30
  },
31
31
  },
32
32
  async run({ $ }) {
33
- const response = await this.slack.sdk().users.profile.set({
33
+ const response = await this.slack.updateProfile({
34
34
  profile: {
35
35
  status_text: this.statusText,
36
36
  status_emoji: this.statusEmoji && `:${this.statusEmoji}:`,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "slack-update-group-members",
5
5
  name: "Update Groups Members",
6
6
  description: "Update the list of users for a User Group. [See the documentation](https://api.slack.com/methods/usergroups.users.update)",
7
- version: "0.0.6",
7
+ version: "0.0.8",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -50,13 +50,13 @@ export default {
50
50
  usersToRemove,
51
51
  team,
52
52
  } = this;
53
- let { users } = await this.slack.sdk().usergroups.users.list({
53
+ let { users } = await this.slack.listGroupMembers({
54
54
  usergroup: userGroup,
55
55
  team_id: team,
56
56
  });
57
57
  users = users.filter((user) => !usersToRemove.includes(user));
58
58
  users.push(...usersToAdd);
59
- const response = await this.slack.sdk().usergroups.users.update({
59
+ const response = await this.slack.updateGroupMembers({
60
60
  usergroup: userGroup,
61
61
  users,
62
62
  team_id: team,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "slack-update-message",
5
5
  name: "Update Message",
6
6
  description: "Update a message. [See the documentation](https://api.slack.com/methods/chat.update)",
7
- version: "0.1.21",
7
+ version: "0.1.23",
8
8
  type: "action",
9
9
  props: {
10
10
  slack,
@@ -41,7 +41,7 @@ export default {
41
41
  },
42
42
  },
43
43
  async run({ $ }) {
44
- const response = await this.slack.sdk().chat.update({
44
+ const response = await this.slack.updateMessage({
45
45
  ts: this.timestamp,
46
46
  text: this.text,
47
47
  channel: this.conversation,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "slack-update-profile",
6
6
  name: "Update Profile",
7
7
  description: "Update basic profile field such as name or title. [See the documentation](https://api.slack.com/methods/users.profile.set)",
8
- version: "0.0.21",
8
+ version: "0.0.23",
9
9
  type: "action",
10
10
  props: {
11
11
  slack,
@@ -70,7 +70,7 @@ export default {
70
70
  ) {
71
71
  throw new ConfigurationError("Please provide at least one value to update");
72
72
  }
73
- const response = await this.slack.sdk().users.profile.set({
73
+ const response = await this.slack.updateProfile({
74
74
  profile: {
75
75
  display_name: this.displayName,
76
76
  first_name: this.firstName,
@@ -1,12 +1,15 @@
1
- import { ConfigurationError } from "@pipedream/platform";
1
+ import {
2
+ ConfigurationError, axios,
3
+ } from "@pipedream/platform";
2
4
  import fs from "fs";
5
+ import FormData from "form-data";
3
6
  import slack from "../../slack.app.mjs";
4
7
 
5
8
  export default {
6
9
  key: "slack-upload-file",
7
10
  name: "Upload File",
8
- description: "Upload a file. [See the documentation](https://api.slack.com/methods/files.upload)",
9
- version: "0.0.25",
11
+ description: "Upload a file. [See the documentation](https://api.slack.com/messaging/files#uploading_files)",
12
+ version: "0.0.27",
10
13
  type: "action",
11
14
  props: {
12
15
  slack,
@@ -35,13 +38,54 @@ export default {
35
38
  if (!fs.existsSync(this.content)) {
36
39
  throw new ConfigurationError(`\`${this.content}\` not found, a valid \`/tmp\` path is needed`);
37
40
  }
38
- const response = await this.slack.sdk().filesUploadV2({
39
- file: fs.createReadStream(this.content),
41
+
42
+ const filename = this.content.split("/").pop();
43
+
44
+ // Get an upload URL from Slack
45
+ const getUploadUrlResponse = await this.slack.getUploadUrl({
46
+ filename,
47
+ length: fs.statSync(this.content).size,
48
+ });
49
+
50
+ if (!getUploadUrlResponse.ok) {
51
+ throw new ConfigurationError(`Error getting upload URL: ${JSON.stringify(getUploadUrlResponse)}`);
52
+ }
53
+
54
+ const {
55
+ upload_url: uploadUrl, file_id: fileId,
56
+ } = getUploadUrlResponse;
57
+
58
+ // Upload the file to the provided URL
59
+ const formData = new FormData();
60
+ formData.append("file", fs.createReadStream(this.content));
61
+ formData.append("filename", filename);
62
+
63
+ await axios($, {
64
+ url: uploadUrl,
65
+ data: formData,
66
+ method: "POST",
67
+ headers: {
68
+ ...formData.getHeaders(),
69
+ Authorization: `Bearer ${this.slack.getToken()}`,
70
+ },
71
+ });
72
+
73
+ // Complete the file upload process in Slack
74
+ const completeUploadResponse = await this.slack.completeUpload({
40
75
  channel_id: this.conversation,
41
76
  initial_comment: this.initialComment,
42
- filename: this.content.split("/").pop(),
77
+ files: [
78
+ {
79
+ id: fileId,
80
+ },
81
+ ],
43
82
  });
83
+
84
+ if (!completeUploadResponse.ok) {
85
+ throw new Error(`Error completing upload: ${JSON.stringify(completeUploadResponse)}`);
86
+ }
87
+
44
88
  $.export("$summary", "Successfully uploaded file");
45
- return response;
89
+ return completeUploadResponse;
46
90
  },
47
91
  };
@@ -5,7 +5,7 @@ export default {
5
5
  key: "slack-verify-slack-signature",
6
6
  name: "Verify Slack Signature",
7
7
  description: "Verifying requests from Slack, slack signs its requests using a secret that's unique to your app. [See the documentation](https://api.slack.com/authentication/verifying-requests-from-slack)",
8
- version: "0.0.14",
8
+ version: "0.0.16",
9
9
  type: "action",
10
10
  props: {
11
11
  slack,
@@ -1,5 +1,5 @@
1
1
  const MAX_RESOURCES = 800;
2
- const LIMIT = 200;
2
+ const LIMIT = 250;
3
3
 
4
4
  const CHANNEL_TYPE = {
5
5
  PUBLIC: "public_channel",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/slack",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Pipedream Slack Components",
5
5
  "main": "slack.app.mjs",
6
6
  "keywords": [
@@ -15,6 +15,6 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@pipedream/platform": "^3.0.0",
18
- "@slack/web-api": "^7.0.4"
18
+ "@slack/web-api": "^7.9.0"
19
19
  }
20
20
  }