@pipedream/slack 0.4.7 → 0.4.9

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/slack",
3
- "version": "0.4.7",
3
+ "version": "0.4.9",
4
4
  "description": "Pipedream Slack Components",
5
5
  "main": "slack.app.mjs",
6
6
  "keywords": [
@@ -0,0 +1,101 @@
1
+ import common from "../common/base.mjs";
2
+
3
+ export default {
4
+ name: "New Interaction Events",
5
+ version: "0.0.1",
6
+ key: "slack-new-interaction-event-received",
7
+ description:
8
+ "Emit new events on new Slack [interactivity events](https://api.slack.com/interactivity) sourced from [Block Kit interactive elements](https://api.slack.com/interactivity/components), [Slash commands](https://api.slack.com/interactivity/slash-commands), or [Shortcuts](https://api.slack.com/interactivity/shortcuts).",
9
+ type: "source",
10
+ props: {
11
+ ...common.props,
12
+ action_ids: {
13
+ type: "string[]",
14
+ label: "Action IDs",
15
+ description:
16
+ "Filter interaction events by specific `action_id`'s to subscribe for new interaction events. If none selected, all `action_ids` will emit new events.",
17
+ optional: true,
18
+ default: [],
19
+ },
20
+ conversations: {
21
+ propDefinition: [
22
+ common.props.slack,
23
+ "conversation",
24
+ ],
25
+ type: "string[]",
26
+ label: "Channels",
27
+ description:
28
+ "Filter interaction events by one or more channels. If none selected, any interaction event in any channel will emit new events.",
29
+ optional: true,
30
+ default: [],
31
+ },
32
+ // eslint-disable-next-line pipedream/props-description,pipedream/props-label
33
+ slackApphook: {
34
+ type: "$.interface.apphook",
35
+ appProp: "slack",
36
+ /**
37
+ * Subscribes to potentially 4 different events:
38
+ * `interaction_events` - all interaction events on the authenticated account
39
+ * `interaction_events:${action_id}` - all interaction events with a specific given action_id
40
+ * `interaction_events:${channel_id}` - all interaction events within a specific channel
41
+ * `interaction_events:${channel_id}:${action_id}` - action_id within a specific channel
42
+ * @returns string[]
43
+ */
44
+ async eventNames() {
45
+ // start with action_ids, since they can be the most specific
46
+ const action_events = this.action_ids.reduce((carry, action_id) => {
47
+ // if channels are provided, spread them
48
+ if (this.conversations && this.conversations.length > 0) {
49
+ return [
50
+ ...carry,
51
+ ...this.conversations.map(
52
+ (channel) => `interaction_events:${channel}:${action_id}`,
53
+ ),
54
+ ];
55
+ }
56
+
57
+ return [
58
+ ...carry,
59
+ `interaction_events:${action_id}`,
60
+ ];
61
+ }, []);
62
+
63
+ if (action_events.length > 0) return action_events;
64
+
65
+ // if no action_ids are specified, move down to channels
66
+ const channel_events = this.conversations.map(
67
+ (channel) => `interaction_events:${channel}`,
68
+ );
69
+
70
+ if (channel_events.length > 0) return channel_events;
71
+
72
+ // if not specific action_ids or channels are specified, subscribe to all events
73
+ return [
74
+ "interaction_events",
75
+ ];
76
+ },
77
+ },
78
+ },
79
+ methods: {},
80
+ async run(event) {
81
+ this.$emit(
82
+ {
83
+ event,
84
+ },
85
+ {
86
+ summary: `New interaction event${
87
+ event?.channel?.id
88
+ ? ` in channel ${event.channel.id}`
89
+ : ""
90
+ }${
91
+ event.actions?.length > 0
92
+ ? ` from action_ids ${event.actions
93
+ .map((action) => action.action_id)
94
+ .join(", ")}`
95
+ : ""
96
+ }`,
97
+ ts: Date.now(),
98
+ },
99
+ );
100
+ },
101
+ };
@@ -8,7 +8,7 @@ export default {
8
8
  ...common,
9
9
  key: "slack-new-star-added",
10
10
  name: "New Star Added (Instant)",
11
- version: "0.0.7",
11
+ version: "0.0.8",
12
12
  description: "Emit new event when a star is added to an item",
13
13
  type: "source",
14
14
  dedupe: "unique",
@@ -38,7 +38,9 @@ export default {
38
38
  return `New star added - ${events[type] ?? type}`;
39
39
  },
40
40
  async processEvent(event) {
41
- if (this.eventTypes?.length === 0 || this.eventTypes.includes(event.item.type)) {
41
+ if (this.eventTypes == null
42
+ || this.eventTypes.length === 0
43
+ || this.eventTypes.includes(event.item.type)) {
42
44
  return event;
43
45
  }
44
46
  },