@pipedream/slack 0.8.1 → 0.9.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.
@@ -0,0 +1,87 @@
1
+ import slack from "../../slack.app.mjs";
2
+ import constants from "../../common/constants.mjs";
3
+
4
+ export default {
5
+ key: "slack-approve-workflow",
6
+ name: "Approve Workflow",
7
+ description: "Suspend the workflow until approved by a Slack message. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)",
8
+ version: "0.0.2",
9
+ type: "action",
10
+ props: {
11
+ slack,
12
+ channelType: {
13
+ type: "string",
14
+ label: "Channel Type",
15
+ description: "The type of channel to send to. User/Direct Message (im), Group (mpim), Private Channel or Public Channel",
16
+ async options() {
17
+ return constants.CHANNEL_TYPE_OPTIONS;
18
+ },
19
+ },
20
+ conversation: {
21
+ propDefinition: [
22
+ slack,
23
+ "conversation",
24
+ (c) => ({
25
+ types: c.channelType === "Channels"
26
+ ? [
27
+ constants.CHANNEL_TYPE.PUBLIC,
28
+ constants.CHANNEL_TYPE.PRIVATE,
29
+ ]
30
+ : [
31
+ c.channelType,
32
+ ],
33
+ }),
34
+ ],
35
+ },
36
+ message: {
37
+ type: "string",
38
+ label: "Message",
39
+ description: "Text to include with the Approve and Cancel Buttons",
40
+ },
41
+ },
42
+ async run({ $ }) {
43
+ const {
44
+ resume_url, cancel_url,
45
+ } = $.flow.suspend();
46
+
47
+ const response = await this.slack.sdk().chat.postMessage({
48
+ text: "Click here to approve or cancel workflow",
49
+ blocks: [
50
+ {
51
+ type: "section",
52
+ text: {
53
+ type: "mrkdwn",
54
+ text: this.message,
55
+ },
56
+ },
57
+ {
58
+ type: "actions",
59
+ elements: [
60
+ {
61
+ type: "button",
62
+ text: {
63
+ type: "plain_text",
64
+ text: "Approve",
65
+ },
66
+ style: "primary",
67
+ url: resume_url,
68
+ },
69
+ {
70
+ type: "button",
71
+ text: {
72
+ type: "plain_text",
73
+ text: "Cancel",
74
+ },
75
+ style: "danger",
76
+ url: cancel_url,
77
+ },
78
+ ],
79
+ },
80
+ ],
81
+ channel: this.conversation,
82
+ });
83
+
84
+ $.export("$summary", "Successfully sent message");
85
+ return response;
86
+ },
87
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/slack",
3
- "version": "0.8.1",
3
+ "version": "0.9.1",
4
4
  "description": "Pipedream Slack Components",
5
5
  "main": "slack.app.mjs",
6
6
  "keywords": [