@pipedream/pumble 0.0.1 → 0.2.0

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,51 @@
1
+ import pumble from "../../pumble.app.mjs";
2
+
3
+ export default {
4
+ key: "pumble-create-channel",
5
+ name: "Create Channel",
6
+ description: "Create a new channel in Pumble. [See the documentation](https://pumble.com/help/integrations/add-pumble-apps/api-keys-integration/#create-channel)",
7
+ version: "0.0.2",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: false,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ pumble,
16
+ name: {
17
+ type: "string",
18
+ label: "Channel Name",
19
+ description: "Name of the new channel",
20
+ },
21
+ type: {
22
+ type: "string",
23
+ label: "Type",
24
+ description: "Whether the new channel is public or private. Defaults to `public`",
25
+ options: [
26
+ "PUBLIC",
27
+ "PRIVATE",
28
+ ],
29
+ default: "PUBLIC",
30
+ optional: true,
31
+ },
32
+ description: {
33
+ type: "string",
34
+ label: "Description",
35
+ description: "Description of the new channel",
36
+ optional: true,
37
+ },
38
+ },
39
+ async run({ $ }) {
40
+ const response = await this.pumble.createChannel({
41
+ $,
42
+ data: {
43
+ name: this.name,
44
+ type: this.type,
45
+ description: this.description,
46
+ },
47
+ });
48
+ $.export("$summary", `Successfully created channel with ID ${response.id}`);
49
+ return response;
50
+ },
51
+ };
@@ -0,0 +1,26 @@
1
+ import pumble from "../../pumble.app.mjs";
2
+
3
+ export default {
4
+ key: "pumble-list-channel-options",
5
+ name: "List Channel Options",
6
+ description: "Retrieves available options for the Channel field.",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ pumble,
16
+ },
17
+ async run({ $ }) {
18
+ const options = await pumble.propDefinitions.channel.options.call(this.pumble, {});
19
+ $.export("$summary", `Successfully retrieved ${options.length} option${
20
+ options.length === 1
21
+ ? ""
22
+ : "s"
23
+ }`);
24
+ return options;
25
+ },
26
+ };
@@ -0,0 +1,35 @@
1
+ import pumble from "../../pumble.app.mjs";
2
+
3
+ export default {
4
+ key: "pumble-list-messages",
5
+ name: "List Messages",
6
+ description: "List messages in a channel. [See the documentation](https://pumble.com/help/integrations/add-pumble-apps/api-keys-integration/#list-messages-in-a-channel)",
7
+ version: "0.0.2",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: true,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ pumble,
16
+ channel: {
17
+ propDefinition: [
18
+ pumble,
19
+ "channel",
20
+ ],
21
+ },
22
+ },
23
+ async run({ $ }) {
24
+ const { messages } = await this.pumble.listMessages({
25
+ $,
26
+ params: {
27
+ channel: this.channel,
28
+ },
29
+ });
30
+ $.export("$summary", `Successfully retrieved ${messages.length} message${messages.length === 1
31
+ ? ""
32
+ : "s"}`);
33
+ return messages;
34
+ },
35
+ };
@@ -0,0 +1,47 @@
1
+ import pumble from "../../pumble.app.mjs";
2
+
3
+ export default {
4
+ key: "pumble-send-message",
5
+ name: "Send Message",
6
+ description: "Send a message to a channel in Pumble. [See the documentation](https://pumble.com/help/integrations/add-pumble-apps/api-keys-integration/#send-messages)",
7
+ version: "0.0.2",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: false,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ pumble,
16
+ channel: {
17
+ propDefinition: [
18
+ pumble,
19
+ "channel",
20
+ ],
21
+ },
22
+ text: {
23
+ type: "string",
24
+ label: "Text",
25
+ description: "The message to send",
26
+ },
27
+ asBot: {
28
+ type: "boolean",
29
+ label: "As Bot",
30
+ description: "Whether to send the message from your personal account or as a bot. Defaults to `false`",
31
+ default: false,
32
+ optional: true,
33
+ },
34
+ },
35
+ async run({ $ }) {
36
+ const response = await this.pumble.sendMessage({
37
+ $,
38
+ data: {
39
+ channel: this.channel,
40
+ text: this.text,
41
+ asBot: this.asBot,
42
+ },
43
+ });
44
+ $.export("$summary", `Successfully sent message with ID ${response.id}`);
45
+ return response;
46
+ },
47
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/pumble",
3
- "version": "0.0.1",
3
+ "version": "0.2.0",
4
4
  "description": "Pipedream Pumble Components",
5
5
  "main": "pumble.app.mjs",
6
6
  "keywords": [
@@ -11,5 +11,8 @@
11
11
  "author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
12
12
  "publishConfig": {
13
13
  "access": "public"
14
+ },
15
+ "dependencies": {
16
+ "@pipedream/platform": "^2.0.2"
14
17
  }
15
18
  }
package/pumble.app.mjs CHANGED
@@ -1,11 +1,66 @@
1
+ import { axios } from "@pipedream/platform";
2
+
1
3
  export default {
2
4
  type: "app",
3
5
  app: "pumble",
4
- propDefinitions: {},
6
+ propDefinitions: {
7
+ channel: {
8
+ type: "string",
9
+ label: "Channel",
10
+ description: "The name of the channel",
11
+ async options() {
12
+ const channels = await this.listChannels();
13
+ return channels
14
+ ?.filter(({ channel }) => channel.name)
15
+ ?.map(({ channel }) => channel.name) || [];
16
+ },
17
+ },
18
+ },
5
19
  methods: {
6
- // this.$auth contains connected account data
7
- authKeys() {
8
- console.log(Object.keys(this.$auth));
20
+ _baseUrl() {
21
+ return "https://pumble-api-keys.addons.marketplace.cake.com";
22
+ },
23
+ _headers() {
24
+ return {
25
+ "Api-Key": `${this.$auth.api_key}`,
26
+ };
27
+ },
28
+ _makeRequest({
29
+ $ = this,
30
+ path,
31
+ ...opts
32
+ }) {
33
+ return axios($, {
34
+ url: `${this._baseUrl()}${path}`,
35
+ headers: this._headers(),
36
+ ...opts,
37
+ });
38
+ },
39
+ listChannels(opts = {}) {
40
+ return this._makeRequest({
41
+ path: "/listChannels",
42
+ ...opts,
43
+ });
44
+ },
45
+ listMessages(opts = {}) {
46
+ return this._makeRequest({
47
+ path: "/listMessages",
48
+ ...opts,
49
+ });
50
+ },
51
+ createChannel(opts = {}) {
52
+ return this._makeRequest({
53
+ method: "POST",
54
+ path: "/createChannel",
55
+ ...opts,
56
+ });
57
+ },
58
+ sendMessage(opts = {}) {
59
+ return this._makeRequest({
60
+ method: "POST",
61
+ path: "/sendMessage",
62
+ ...opts,
63
+ });
9
64
  },
10
65
  },
11
- };
66
+ };
@@ -0,0 +1,24 @@
1
+ import pumble from "../../pumble.app.mjs";
2
+ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
3
+
4
+ export default {
5
+ props: {
6
+ pumble,
7
+ db: "$.service.db",
8
+ timer: {
9
+ type: "$.interface.timer",
10
+ default: {
11
+ intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
12
+ },
13
+ },
14
+ },
15
+ methods: {
16
+ emitEvent(item) {
17
+ const meta = this.generateMeta(item);
18
+ this.$emit(item, meta);
19
+ },
20
+ generateMeta() {
21
+ throw new Error("generateMeta is not implemented");
22
+ },
23
+ },
24
+ };
@@ -0,0 +1,29 @@
1
+ import common from "../common/base.mjs";
2
+ import sampleEmit from "./test-event.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ key: "pumble-new-channel-created",
7
+ name: "New Channel Created",
8
+ description: "Emit new event when a new channel is created in Pumble",
9
+ version: "0.0.1",
10
+ type: "source",
11
+ dedupe: "unique",
12
+ methods: {
13
+ ...common.methods,
14
+ generateMeta(channel) {
15
+ return {
16
+ id: channel.id,
17
+ summary: `New Channel: ${channel.name}`,
18
+ ts: Date.now(),
19
+ };
20
+ },
21
+ },
22
+ async run() {
23
+ const channels = await this.pumble.listChannels();
24
+ channels
25
+ .filter(({ channel }) => channel.name)
26
+ .forEach(({ channel }) => this.emitEvent(channel));
27
+ },
28
+ sampleEmit,
29
+ };
@@ -0,0 +1,28 @@
1
+ export default {
2
+ "id": "66575d32d3c8847e4c85e00f",
3
+ "workspaceId": "66575d31d3c8847e4c85e009",
4
+ "channelType": "PUBLIC",
5
+ "name": "general",
6
+ "description": "",
7
+ "isMember": true,
8
+ "isMuted": false,
9
+ "isHidden": false,
10
+ "isArchived": false,
11
+ "isPumbleBot": false,
12
+ "isAddonBot": false,
13
+ "lastMarkTimestamp": "2024-05-29T17:25:50.805Z",
14
+ "lastMarkTimestampMilli": 1717003550805,
15
+ "isMain": true,
16
+ "isInitial": true,
17
+ "sectionId": "",
18
+ "postingPermissions": {
19
+ "allowThreads": true,
20
+ "allowMentions": true,
21
+ "postingPermissionsGroup": "EVERYONE",
22
+ "workspaceUserIds": []
23
+ },
24
+ "desktopNotificationPreferences": null,
25
+ "mobileNotificationPreferences": null,
26
+ "notifyAboutRepliesInThreads": false,
27
+ "addedById": "66575d31d3c8847e4c85e00a"
28
+ }
@@ -0,0 +1,57 @@
1
+ import common from "../common/base.mjs";
2
+ import sampleEmit from "./test-event.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ key: "pumble-new-message-in-channel",
7
+ name: "New Message in Channel",
8
+ description: "Emit new event when a message is posted in the specified channel in Pumble",
9
+ version: "0.0.1",
10
+ type: "source",
11
+ dedupe: "unique",
12
+ props: {
13
+ ...common.props,
14
+ channel: {
15
+ propDefinition: [
16
+ common.props.pumble,
17
+ "channel",
18
+ ],
19
+ },
20
+ },
21
+ methods: {
22
+ ...common.methods,
23
+ _getLastTs() {
24
+ return this.db.get("lastTs") || 0;
25
+ },
26
+ _setLastTs(lastTs) {
27
+ this.db.set("lastTs", lastTs);
28
+ },
29
+ generateMeta(message) {
30
+ return {
31
+ id: message.id,
32
+ summary: `New Message: ${message.text}`,
33
+ ts: Date.parse(message.timestamp),
34
+ };
35
+ },
36
+ },
37
+ async run() {
38
+ const lastTs = this._getLastTs();
39
+ let maxTs = lastTs;
40
+
41
+ const { messages } = await this.pumble.listMessages({
42
+ params: {
43
+ channel: this.channel,
44
+ },
45
+ });
46
+ for (const message of messages) {
47
+ const ts = Date.parse(message.timestamp);
48
+ if (ts >= lastTs) {
49
+ this.emitEvent(message);
50
+ maxTs = Math.max(ts, maxTs);
51
+ }
52
+ }
53
+
54
+ this._setLastTs(maxTs);
55
+ },
56
+ sampleEmit,
57
+ };
@@ -0,0 +1,40 @@
1
+ export default {
2
+ "id": "6657650a3ca2f542afff7151",
3
+ "workspaceId": "66575d31d3c8847e4c85e009",
4
+ "channelId": "66575d32d3c8847e4c85e00f",
5
+ "author": "66575d31d3c8847e4c85e00a",
6
+ "text": "hello world",
7
+ "timestamp": "2024-05-29T17:25:30Z",
8
+ "timestampMilli": 1717003530000,
9
+ "subtype": "",
10
+ "reactions": [],
11
+ "linkPreviews": [],
12
+ "isFollowing": true,
13
+ "threadRootInfo": null,
14
+ "threadReplyInfo": null,
15
+ "files": [],
16
+ "deleted": false,
17
+ "edited": false,
18
+ "localId": "665765820b689728fcc64b52",
19
+ "attachments": [],
20
+ "sharedMessage": null,
21
+ "savedTimestampMilli": 0,
22
+ "blocks": [
23
+ {
24
+ "type": "rich_text",
25
+ "elements": [
26
+ {
27
+ "type": "rich_text_section",
28
+ "elements": [
29
+ {
30
+ "type": "text",
31
+ "text": "hello world"
32
+ }
33
+ ]
34
+ }
35
+ ]
36
+ }
37
+ ],
38
+ "meta": null,
39
+ "authorAppId": null
40
+ }