@pipedream/slack 0.3.2 → 0.4.1

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 (50) hide show
  1. package/actions/add-star/add-star.mjs +43 -0
  2. package/actions/archive-channel/archive-channel.mjs +23 -0
  3. package/actions/common/send-message.mjs +170 -0
  4. package/actions/complete-reminder/complete-reminder.mjs +23 -0
  5. package/actions/create-channel/create-channel.mjs +30 -0
  6. package/actions/create-reminder/create-reminder.mjs +47 -0
  7. package/actions/delete-file/delete-file.mjs +23 -0
  8. package/actions/delete-message/delete-message.mjs +38 -0
  9. package/actions/delete_reminder/delete-reminder.mjs +23 -0
  10. package/actions/find-message/find-message.mjs +38 -0
  11. package/actions/find-user-by-email/find-user-by-email.mjs +23 -0
  12. package/actions/get-channel/get-channel.mjs +23 -0
  13. package/actions/get-file/get-file.mjs +30 -0
  14. package/actions/get-reminder/get-reminder.mjs +23 -0
  15. package/actions/invite-user-to-channel/invite-user-to-channel.mjs +31 -0
  16. package/actions/join-channel/join-channel.mjs +23 -0
  17. package/actions/kick-user/kick-user.mjs +30 -0
  18. package/actions/leave-channel/leave-channel.mjs +23 -0
  19. package/actions/list-channels/list-channels.mjs +15 -0
  20. package/actions/list-files/list-files.mjs +47 -0
  21. package/actions/list-members-in-channel/list-members-in-channel.mjs +23 -0
  22. package/actions/list-reminders/list-reminders.mjs +24 -0
  23. package/actions/list-replies/list-replies.mjs +30 -0
  24. package/actions/list-users/list-users.mjs +22 -0
  25. package/actions/remove-star/remove-star.mjs +40 -0
  26. package/actions/reply-to-a-message-thread/reply-to-a-message-thread.mjs +41 -0
  27. package/actions/send-block-kit-message/send-block-kit-message.mjs +33 -0
  28. package/actions/send-custom-message/send-custom-message.mjs +79 -0
  29. package/actions/send-direct-message/send-direct-message.mjs +52 -0
  30. package/actions/send-group-message/send-group-message.mjs +52 -0
  31. package/actions/send-large-message/send-large-message.mjs +91 -0
  32. package/actions/send-message-private-channel/send-message-private-channel.mjs +52 -0
  33. package/actions/send-message-public-channel/send-message-public-channel.mjs +52 -0
  34. package/actions/set-channel-topic/set-channel-topic.mjs +30 -0
  35. package/actions/set-purpose-of-channel/set-purpose-of-channel.mjs +30 -0
  36. package/actions/unarchive-channel/unarchive-channel.mjs +23 -0
  37. package/actions/update-message/update-message.mjs +52 -0
  38. package/actions/update-profile/update-profile.mjs +30 -0
  39. package/actions/upload-file/upload-file.mjs +38 -0
  40. package/package.json +19 -16
  41. package/slack.app.mjs +544 -0
  42. package/sources/common/base.mjs +97 -0
  43. package/sources/common/constants.mjs +30 -0
  44. package/sources/new-direct-message/new-direct-message.mjs +51 -0
  45. package/sources/new-mention/new-mention.mjs +95 -0
  46. package/sources/new-message-in-channels/new-message-in-channels.mjs +84 -0
  47. package/sources/new-reaction-added/new-reaction-added.mjs +65 -0
  48. package/sources/new-star-added/new-star-added.mjs +46 -0
  49. package/slack.app.js +0 -48
  50. package/sources/new-message-in-channels/new-message-in-channels.js +0 -151
@@ -0,0 +1,43 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-add-star",
5
+ name: "Add Star",
6
+ description: "Add a star to an item on behalf of the authenticated user. [See docs here](https://api.slack.com/methods/stars.add)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ conversation: {
12
+ propDefinition: [
13
+ slack,
14
+ "conversation",
15
+ ],
16
+ optional: true,
17
+ description: "Channel to add star to, or channel where the message to add star to was posted (used with timestamp).",
18
+ },
19
+ timestamp: {
20
+ propDefinition: [
21
+ slack,
22
+ "timestamp",
23
+ ],
24
+ optional: true,
25
+ description: "Timestamp of the message to add star to.",
26
+ },
27
+ file: {
28
+ propDefinition: [
29
+ slack,
30
+ "file",
31
+ ],
32
+ optional: true,
33
+ description: "File to add star to.",
34
+ },
35
+ },
36
+ async run() {
37
+ return await this.slack.sdk().stars.add({
38
+ channel: this.conversation,
39
+ timestamp: this.timestamp,
40
+ file: this.file,
41
+ });
42
+ },
43
+ };
@@ -0,0 +1,23 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-archive-channel",
5
+ name: "Archive Channel",
6
+ description: "Archive a channel. [See docs here](https://api.slack.com/methods/conversations.archive)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ conversation: {
12
+ propDefinition: [
13
+ slack,
14
+ "conversation",
15
+ ],
16
+ },
17
+ },
18
+ async run() {
19
+ return await this.slack.sdk().conversations.archive({
20
+ channel: this.conversation,
21
+ });
22
+ },
23
+ };
@@ -0,0 +1,170 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ /* eslint-disable pipedream/required-properties-key, pipedream/required-properties-name,
4
+ pipedream/required-properties-version, pipedream/required-properties-description */
5
+ export default {
6
+ type: "action",
7
+ props: {
8
+ slack,
9
+ as_user: {
10
+ propDefinition: [
11
+ slack,
12
+ "as_user",
13
+ ],
14
+ },
15
+ username: {
16
+ propDefinition: [
17
+ slack,
18
+ "username",
19
+ ],
20
+ },
21
+ icon_emoji: {
22
+ propDefinition: [
23
+ slack,
24
+ "icon_emoji",
25
+ ],
26
+ },
27
+ icon_url: {
28
+ propDefinition: [
29
+ slack,
30
+ "icon_url",
31
+ ],
32
+ },
33
+ post_at: {
34
+ propDefinition: [
35
+ slack,
36
+ "post_at",
37
+ ],
38
+ },
39
+ include_sent_via_pipedream_flag: {
40
+ type: "boolean",
41
+ optional: true,
42
+ default: true,
43
+ label: "Include link to workflow",
44
+ description: "Defaults to `true`, includes a link to the workflow at the end of your Slack message.",
45
+ },
46
+ metadata_event_type: {
47
+ propDefinition: [
48
+ slack,
49
+ "metadata_event_type",
50
+ ],
51
+ },
52
+ metadata_event_payload: {
53
+ propDefinition: [
54
+ slack,
55
+ "metadata_event_payload",
56
+ ],
57
+ },
58
+ },
59
+ methods: {
60
+ _makeSentViaPipedreamBlock() {
61
+ const workflowId = process.env.PIPEDREAM_WORKFLOW_ID;
62
+ // The link is a URL without a protocol to prevent link unfurling. See
63
+ // https://api.slack.com/reference/messaging/link-unfurling#classic_unfurl
64
+ const link = `https://pipedream.com/@/${workflowId}?o=a&a=slack`;
65
+ return {
66
+ "type": "context",
67
+ "elements": [
68
+ {
69
+ "type": "mrkdwn",
70
+ "text": `Sent via <${link}|Pipedream>`,
71
+ },
72
+ ],
73
+ };
74
+ },
75
+ _makeTextBlock(mrkdwn = true) {
76
+ const { text } = this;
77
+ let serializedText = text;
78
+ // The Slack SDK expects the value of text's "text" property to be a string. If this.text is
79
+ // anything other than string, number, or boolean, then encode it as a JSON string.
80
+ if (typeof text !== "string" && typeof text !== "number" && typeof text !== "boolean") {
81
+ serializedText = JSON.stringify(text);
82
+ }
83
+ return {
84
+ "type": "section",
85
+ "text": {
86
+ "type": mrkdwn
87
+ ? "mrkdwn"
88
+ : "plain_text",
89
+ "text": serializedText,
90
+ },
91
+ };
92
+ },
93
+ },
94
+ async run() {
95
+ let blocks = this.blocks;
96
+
97
+ if (!blocks) {
98
+ blocks = [
99
+ this._makeTextBlock(this.mrkdwn),
100
+ ];
101
+ } else if (typeof blocks === "string") {
102
+ blocks = JSON.parse(blocks);
103
+ }
104
+
105
+ if (this.include_sent_via_pipedream_flag) {
106
+ const sentViaPipedreamText = this._makeSentViaPipedreamBlock();
107
+ blocks.push(sentViaPipedreamText);
108
+ }
109
+
110
+ let metadataEventPayload;
111
+
112
+ if (this.metadata_event_type) {
113
+ try {
114
+ metadataEventPayload = JSON.parse(this.metadata_event_payload);
115
+ } catch (error) {
116
+ throw new Error(`Invalid JSON in metadata_event_payload: ${error.message}`);
117
+ }
118
+
119
+ this.metadata = {
120
+ event_type: this.metadata_event_type,
121
+ event_payload: metadataEventPayload,
122
+ };
123
+ }
124
+
125
+ const obj = {
126
+ text: this.text,
127
+ channel: this.conversation ?? this.reply_channel,
128
+ attachments: this.attachments,
129
+ unfurl_links: this.unfurl_links,
130
+ unfurl_media: this.unfurl_media,
131
+ parse: this.parse,
132
+ as_user: this.as_user,
133
+ username: this.username,
134
+ icon_emoji: this.icon_emoji,
135
+ icon_url: this.icon_url,
136
+ mrkdwn: this.mrkdwn,
137
+ blocks,
138
+ link_names: this.link_names,
139
+ reply_broadcast: this.reply_broadcast,
140
+ thread_ts: this.thread_ts,
141
+ metadata: this.metadata || null,
142
+ };
143
+
144
+ console.log({
145
+ text: this.text,
146
+ channel: this.conversation ?? this.reply_channel,
147
+ attachments: this.attachments,
148
+ unfurl_links: this.unfurl_links,
149
+ unfurl_media: this.unfurl_media,
150
+ parse: this.parse,
151
+ as_user: this.as_user,
152
+ username: this.username,
153
+ icon_emoji: this.icon_emoji,
154
+ icon_url: this.icon_url,
155
+ mrkdwn: this.mrkdwn,
156
+ blocks,
157
+ link_names: this.link_names,
158
+ reply_broadcast: this.reply_broadcast,
159
+ thread_ts: this.thread_ts,
160
+ metadata: this.metadata || null,
161
+ });
162
+
163
+ if (this.post_at) {
164
+ obj.post_at = this.post_at;
165
+ return await this.slack.sdk().chat.scheduleMessage(obj);
166
+ }
167
+
168
+ return await this.slack.sdk().chat.postMessage(obj);
169
+ },
170
+ };
@@ -0,0 +1,23 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-complete-reminder",
5
+ name: "Complete Reminder",
6
+ description: "Complete a reminder. [See docs here](https://api.slack.com/methods/reminders.complete)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ reminder: {
12
+ propDefinition: [
13
+ slack,
14
+ "reminder",
15
+ ],
16
+ },
17
+ },
18
+ async run() {
19
+ return await this.slack.sdk().reminders.complete({
20
+ reminder: this.reminder,
21
+ });
22
+ },
23
+ };
@@ -0,0 +1,30 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-create-channel",
5
+ name: "Create a Channel",
6
+ description: "Create a new channel. [See docs here](https://api.slack.com/methods/conversations.create)",
7
+ version: "0.0.6",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ channelName: {
12
+ label: "Channel name",
13
+ description: "Name of the public or private channel to create",
14
+ type: "string",
15
+ },
16
+ isPrivate: {
17
+ label: "Is private?",
18
+ type: "boolean",
19
+ description: "`false` by default. Pass `true` to create a private channel instead of a public one.",
20
+ default: false,
21
+ optional: true,
22
+ },
23
+ },
24
+ async run() {
25
+ return await this.slack.sdk().conversations.create({
26
+ name: this.channelName,
27
+ is_private: this.isPrivate,
28
+ });
29
+ },
30
+ };
@@ -0,0 +1,47 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-create-reminder",
5
+ name: "Create Reminder",
6
+ description: "Create a reminder. [See docs here](https://api.slack.com/methods/reminders.add)",
7
+ version: "0.0.6",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ text: {
12
+ propDefinition: [
13
+ slack,
14
+ "text",
15
+ ],
16
+ },
17
+ timestamp: {
18
+ propDefinition: [
19
+ slack,
20
+ "timestamp",
21
+ ],
22
+ description: "When this reminder should happen: the Unix timestamp (up to five years from now), the number of seconds until the reminder (if within 24 hours), or a natural language description (Ex. in 15 minutes, or every Thursday)",
23
+ },
24
+ team_id: {
25
+ propDefinition: [
26
+ slack,
27
+ "team",
28
+ ],
29
+ optional: true,
30
+ },
31
+ user: {
32
+ propDefinition: [
33
+ slack,
34
+ "user",
35
+ ],
36
+ optional: true,
37
+ },
38
+ },
39
+ async run() {
40
+ return await this.slack.sdk().reminders.add({
41
+ text: this.text,
42
+ team_id: this.team_id,
43
+ time: this.timestamp,
44
+ user: this.user,
45
+ });
46
+ },
47
+ };
@@ -0,0 +1,23 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-delete-file",
5
+ name: "Delete File",
6
+ description: "Delete a file. [See docs here](https://api.slack.com/methods/files.delete)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ file: {
12
+ propDefinition: [
13
+ slack,
14
+ "file",
15
+ ],
16
+ },
17
+ },
18
+ async run() {
19
+ return await this.slack.sdk().files.delete({
20
+ file: this.file,
21
+ });
22
+ },
23
+ };
@@ -0,0 +1,38 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-delete-message",
5
+ name: "Delete Message",
6
+ description: "Delete a message. [See docs here](https://api.slack.com/methods/chat.delete)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ conversation: {
12
+ propDefinition: [
13
+ slack,
14
+ "conversation",
15
+ ],
16
+ },
17
+ timestamp: {
18
+ propDefinition: [
19
+ slack,
20
+ "timestamp",
21
+ ],
22
+ },
23
+ as_user: {
24
+ propDefinition: [
25
+ slack,
26
+ "as_user",
27
+ ],
28
+ description: "Pass true to update the message as the authed user. Bot users in this context are considered authed users.",
29
+ },
30
+ },
31
+ async run() {
32
+ return await this.slack.sdk().chat.delete({
33
+ channel: this.conversation,
34
+ ts: this.timestamp,
35
+ as_user: this.as_user,
36
+ });
37
+ },
38
+ };
@@ -0,0 +1,23 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-delete-reminder",
5
+ name: "Delete Reminder",
6
+ description: "Delete a reminder. [See docs here](https://api.slack.com/methods/reminders.delete)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ reminder: {
12
+ propDefinition: [
13
+ slack,
14
+ "reminder",
15
+ ],
16
+ },
17
+ },
18
+ async run() {
19
+ return await this.slack.sdk().reminders.delete({
20
+ reminder: this.reminder,
21
+ });
22
+ },
23
+ };
@@ -0,0 +1,38 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-find-message",
5
+ name: "Find Message",
6
+ description: "Find a Slack message. [See docs here](https://api.slack.com/methods/search.messages)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ query: {
12
+ propDefinition: [
13
+ slack,
14
+ "query",
15
+ ],
16
+ },
17
+ count: {
18
+ propDefinition: [
19
+ slack,
20
+ "count",
21
+ ],
22
+ optional: true,
23
+ },
24
+ team_id: {
25
+ propDefinition: [
26
+ slack,
27
+ "team",
28
+ ],
29
+ optional: true,
30
+ },
31
+ },
32
+ async run() {
33
+ return await this.slack.sdk().search.messages({
34
+ query: this.query,
35
+ count: this.count,
36
+ });
37
+ },
38
+ };
@@ -0,0 +1,23 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-find-user-by-email",
5
+ name: "Find User by Email",
6
+ description: "Find a user by matching against their email. [See docs here](https://api.slack.com/methods/users.lookupByEmail)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ email: {
12
+ propDefinition: [
13
+ slack,
14
+ "email",
15
+ ],
16
+ },
17
+ },
18
+ async run() {
19
+ return await this.slack.sdk().users.lookupByEmail({
20
+ email: this.email,
21
+ });
22
+ },
23
+ };
@@ -0,0 +1,23 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-get-channel",
5
+ name: "Get Channel",
6
+ description: "Return information about a workspace channel. [See docs here](https://api.slack.com/methods/conversations.info)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ conversation: {
12
+ propDefinition: [
13
+ slack,
14
+ "conversation",
15
+ ],
16
+ },
17
+ },
18
+ async run() {
19
+ return await this.slack.sdk().conversations.info({
20
+ channel: this.conversation,
21
+ });
22
+ },
23
+ };
@@ -0,0 +1,30 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-get-file",
5
+ name: "Get File",
6
+ description: "Return information about a file. [See docs here](https://api.slack.com/methods/files.info)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ file: {
12
+ propDefinition: [
13
+ slack,
14
+ "file",
15
+ ],
16
+ },
17
+ count: {
18
+ propDefinition: [
19
+ slack,
20
+ "count",
21
+ ],
22
+ },
23
+ },
24
+ async run() {
25
+ return await this.slack.sdk().files.info({
26
+ file: this.file,
27
+ count: this.count,
28
+ });
29
+ },
30
+ };
@@ -0,0 +1,23 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-get-reminder",
5
+ name: "Get Reminder",
6
+ description: "Return information about a reminder. [See docs here](https://api.slack.com/methods/reminders.info)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ reminder: {
12
+ propDefinition: [
13
+ slack,
14
+ "reminder",
15
+ ],
16
+ },
17
+ },
18
+ async run() {
19
+ return await this.slack.sdk().reminders.info({
20
+ reminder: this.reminder,
21
+ });
22
+ },
23
+ };
@@ -0,0 +1,31 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-invite-user-to-channel",
5
+ name: "Invite User to Channel",
6
+ description: "Invite a user to an existing channel. [See docs here](https://api.slack.com/methods/conversations.invite)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ conversation: {
12
+ propDefinition: [
13
+ slack,
14
+ "conversation",
15
+ ],
16
+ },
17
+ user: {
18
+ propDefinition: [
19
+ slack,
20
+ "user",
21
+ ],
22
+ },
23
+
24
+ },
25
+ async run() {
26
+ return await this.slack.sdk().conversations.invite({
27
+ channel: this.conversation,
28
+ users: this.user,
29
+ });
30
+ },
31
+ };
@@ -0,0 +1,23 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-join-channel",
5
+ name: "Join Channel",
6
+ description: "Join an existing channel. [See docs here](https://api.slack.com/methods/conversations.join)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ conversation: {
12
+ propDefinition: [
13
+ slack,
14
+ "conversation",
15
+ ],
16
+ },
17
+ },
18
+ async run() {
19
+ return await this.slack.sdk().conversations.join({
20
+ channel: this.conversation,
21
+ });
22
+ },
23
+ };
@@ -0,0 +1,30 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-kick-user",
5
+ name: "Kick User",
6
+ description: "Remove a user from a conversation. [See docs here](https://api.slack.com/methods/conversations.kick)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ conversation: {
12
+ propDefinition: [
13
+ slack,
14
+ "conversation",
15
+ ],
16
+ },
17
+ user: {
18
+ propDefinition: [
19
+ slack,
20
+ "user",
21
+ ],
22
+ },
23
+ },
24
+ async run() {
25
+ return await this.slack.sdk().conversations.kick({
26
+ channel: this.conversation,
27
+ user: this.user,
28
+ });
29
+ },
30
+ };
@@ -0,0 +1,23 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-leave-channel",
5
+ name: "Leave Channel",
6
+ description: "Leave an existing channel. [See docs here](https://api.slack.com/methods/conversations.leave)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ conversation: {
12
+ propDefinition: [
13
+ slack,
14
+ "conversation",
15
+ ],
16
+ },
17
+ },
18
+ async run() {
19
+ return await this.slack.sdk().conversations.leave({
20
+ channel: this.conversation,
21
+ });
22
+ },
23
+ };
@@ -0,0 +1,15 @@
1
+ import slack from "../../slack.app.mjs";
2
+
3
+ export default {
4
+ key: "slack-list-channels",
5
+ name: "List Channels",
6
+ description: "Return a list of all channels in a workspace. [See docs here](https://api.slack.com/methods/conversations.list)",
7
+ version: "0.0.5",
8
+ type: "action",
9
+ props: {
10
+ slack,
11
+ },
12
+ async run() {
13
+ return await this.slack.sdk().conversations.list();
14
+ },
15
+ };