Skip to content

Commit bddac8c

Browse files
committed
beekeeper init
1 parent 87649cc commit bddac8c

File tree

832 files changed

+206011
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

832 files changed

+206011
-4
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import beekeeper from "../../beekeeper.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "beekeeper-create-post",
6+
name: "Create Post",
7+
description: "Create a new text or multimedia post in a defined stream. [See the documentation](https://beekeeper.stoplight.io/docs/beekeeper-api/18408b41927b9-creates-a-new-post)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
beekeeper,
12+
streamId: {
13+
propDefinition: [
14+
beekeeper,
15+
"streamId",
16+
],
17+
},
18+
files: {
19+
type: "string[]",
20+
label: "Files",
21+
description: "Array of files to be attached to the post",
22+
optional: true,
23+
},
24+
locked: {
25+
type: "boolean",
26+
label: "Locked",
27+
description: "Disables adding comments on the post",
28+
optional: true,
29+
},
30+
title: {
31+
type: "string",
32+
label: "Title",
33+
description: "The title of the post",
34+
optional: true,
35+
},
36+
media: {
37+
type: "string",
38+
label: "Media",
39+
description: "Media attachment for the post",
40+
optional: true,
41+
},
42+
labels: {
43+
type: "string[]",
44+
label: "Labels",
45+
description: "Array of labels for the post",
46+
optional: true,
47+
},
48+
sticky: {
49+
type: "boolean",
50+
label: "Sticky",
51+
description: "Make the post sticky",
52+
optional: true,
53+
},
54+
photos: {
55+
type: "string[]",
56+
label: "Photos",
57+
description: "Array of photos to be attached to the post",
58+
optional: true,
59+
},
60+
reactionsDisabled: {
61+
type: "boolean",
62+
label: "Reactions Disabled",
63+
description: "Disable reactions for the post",
64+
optional: true,
65+
},
66+
text: {
67+
type: "string",
68+
label: "Text",
69+
description: "The text content of the post",
70+
optional: true,
71+
},
72+
options: {
73+
type: "object",
74+
label: "Options",
75+
description: "Additional options for the post",
76+
optional: true,
77+
},
78+
scheduledAt: {
79+
type: "string",
80+
label: "Scheduled At",
81+
description: "The scheduled time for the post in the format (UTC, yyyy-mm-ddTHH:MM:SS)",
82+
optional: true,
83+
},
84+
},
85+
async run({ $ }) {
86+
const response = await this.beekeeper.createPost({
87+
streamId: this.streamId,
88+
files: this.files,
89+
locked: this.locked,
90+
title: this.title,
91+
media: this.media,
92+
labels: this.labels,
93+
sticky: this.sticky,
94+
photos: this.photos,
95+
reactionsDisabled: this.reactionsDisabled,
96+
text: this.text,
97+
options: this.options,
98+
scheduledAt: this.scheduledAt,
99+
});
100+
101+
$.export("$summary", `Successfully created post with title: ${this.title || "Untitled"}`);
102+
return response;
103+
},
104+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import beekeeper from "../../beekeeper.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "beekeeper-get-profile",
6+
name: "Get User Profile",
7+
description: "Retrieve the profile details of a specific user. [See the documentation](https://beekeeper.stoplight.io/docs/beekeeper-api/05bcd13b38a67-get-profile-of-the-given-user)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
beekeeper,
12+
userId: {
13+
propDefinition: [
14+
beekeeper,
15+
"userId",
16+
],
17+
},
18+
includeActivities: {
19+
type: "boolean",
20+
label: "Include Activities",
21+
description: "Whether to include the user's activities. True by default.",
22+
optional: true,
23+
default: true,
24+
},
25+
includeTotals: {
26+
type: "boolean",
27+
label: "Include Totals",
28+
description: "Whether to include the user's total number of posts, comments, and likes received. True by default.",
29+
optional: true,
30+
default: true,
31+
},
32+
},
33+
async run({ $ }) {
34+
const response = await this.beekeeper.getUserProfile({
35+
userId: this.userId,
36+
includeActivities: this.includeActivities,
37+
includeTotals: this.includeTotals,
38+
});
39+
40+
$.export("$summary", `Successfully retrieved profile for user ID ${this.userId}`);
41+
return response;
42+
},
43+
};
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import beekeeper from "../../beekeeper.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "beekeeper-send-message-group-chat",
6+
name: "Send Message to Group Chat",
7+
description: "Send a precomposed message to a defined group chat. [See the documentation](https://beekeeper.stoplight.io/docs/beekeeper-api/9075b32d36db4-send-a-message-to-a-group-chat)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
beekeeper,
12+
chatId: {
13+
propDefinition: [
14+
beekeeper,
15+
"chatId",
16+
],
17+
},
18+
body: {
19+
type: "string",
20+
label: "Body",
21+
description: "The message body. Supports rich text formatting.",
22+
optional: true,
23+
},
24+
attachment: {
25+
type: "object",
26+
label: "Attachment",
27+
description: "JSON object representing attachment. A valid attachment object can be created and fetched using the POST /files/{usage_type}/upload endpoint.",
28+
optional: true,
29+
},
30+
eventType: {
31+
type: "string",
32+
label: "Event Type",
33+
description: "Type of event that the message corresponds to.",
34+
optional: true,
35+
},
36+
chatStateAddons: {
37+
type: "string[]",
38+
label: "Chat State Addons",
39+
description: "Array of objects containing type and data fields for chat state addons.",
40+
optional: true,
41+
},
42+
messageAddons: {
43+
type: "string[]",
44+
label: "Message Addons",
45+
description: "Array of objects containing type and data fields for message addons.",
46+
optional: true,
47+
},
48+
refersTo: {
49+
type: "string",
50+
label: "Refers To",
51+
description: "Field used by message deletion event. Marks the ID of the message the deletion message refers to.",
52+
optional: true,
53+
},
54+
mentions: {
55+
type: "string[]",
56+
label: "Mentions",
57+
description: "IDs of the users mentioned in the message body. Can also have value of 'all', which means all the chat members were mentioned.",
58+
optional: true,
59+
},
60+
},
61+
async run({ $ }) {
62+
const data = {
63+
body: this.body,
64+
attachment: this.attachment,
65+
event: {
66+
type: this.eventType,
67+
},
68+
chat_state_addons: this.chatStateAddons?.map(JSON.parse),
69+
message_addons: this.messageAddons?.map(JSON.parse),
70+
refers_to: this.refersTo,
71+
mentions: this.mentions,
72+
};
73+
74+
const response = await this.beekeeper.sendMessage({
75+
chatId: this.chatId,
76+
...data,
77+
});
78+
79+
$.export("$summary", `Message sent successfully to chat ID: ${this.chatId}`);
80+
return response;
81+
},
82+
};
Lines changed: 131 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,138 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "beekeeper",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
chatId: {
8+
type: "string",
9+
label: "Chat ID",
10+
description: "The ID of the chat to send a message",
11+
async options() {
12+
const chats = await this.listChats();
13+
return chats.map((chat) => ({
14+
label: chat.name,
15+
value: chat.id,
16+
}));
17+
},
18+
},
19+
streamId: {
20+
type: "string",
21+
label: "Stream ID",
22+
description: "The ID of the stream to create a post",
23+
async options() {
24+
const streams = await this.listStreams();
25+
return streams.map((stream) => ({
26+
label: stream.name,
27+
value: stream.id,
28+
}));
29+
},
30+
},
31+
userId: {
32+
type: "string",
33+
label: "User ID",
34+
description: "The user ID for profile details",
35+
async options() {
36+
const users = await this.listUsers();
37+
return users.map((user) => ({
38+
label: user.display_name,
39+
value: user.id,
40+
}));
41+
},
42+
},
43+
},
544
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
45+
_baseUrl() {
46+
return "https://api.beekeeper.io";
47+
},
48+
async _makeRequest(opts = {}) {
49+
const {
50+
$ = this,
51+
method = "GET",
52+
path = "/",
53+
headers,
54+
...otherOpts
55+
} = opts;
56+
return axios($, {
57+
...otherOpts,
58+
method,
59+
url: this._baseUrl() + path,
60+
headers: {
61+
...headers,
62+
Authorization: `Bearer ${this.$auth.api_key}`,
63+
},
64+
});
65+
},
66+
async listChats(opts = {}) {
67+
return this._makeRequest({
68+
path: "/api/v1/chats",
69+
...opts,
70+
});
71+
},
72+
async listStreams(opts = {}) {
73+
return this._makeRequest({
74+
path: "/streams",
75+
...opts,
76+
});
77+
},
78+
async listUsers(opts = {}) {
79+
return this._makeRequest({
80+
path: "/users",
81+
...opts,
82+
});
83+
},
84+
async createPost({
85+
streamId, files, locked, title, media, labels, sticky, photos, reactionsDisabled, text, options, scheduledAt,
86+
}) {
87+
const data = {
88+
files,
89+
locked,
90+
title,
91+
media,
92+
labels,
93+
sticky,
94+
photos,
95+
reactions_disabled: reactionsDisabled,
96+
text,
97+
options,
98+
scheduled_at: scheduledAt,
99+
};
100+
return this._makeRequest({
101+
method: "POST",
102+
path: `/streams/${streamId}/posts`,
103+
data,
104+
});
105+
},
106+
async sendMessage({
107+
chatId, body, attachment, eventType, chatStateAddons, messageAddons, refersTo, mentions,
108+
}) {
109+
const data = {
110+
body,
111+
attachment,
112+
event: {
113+
type: eventType,
114+
},
115+
chat_state_addons: chatStateAddons,
116+
message_addons: messageAddons,
117+
refers_to: refersTo,
118+
mentions,
119+
};
120+
return this._makeRequest({
121+
method: "POST",
122+
path: `/api/2/chats/groups/${chatId}/messages`,
123+
data,
124+
});
125+
},
126+
async getUserProfile({
127+
userId, includeActivities, includeTotals,
128+
}) {
129+
return this._makeRequest({
130+
path: `/profiles/${userId}`,
131+
params: {
132+
include_activities: includeActivities,
133+
include_totals: includeTotals,
134+
},
135+
});
9136
},
10137
},
11138
};

components/beekeeper/node_modules/@pipedream/platform/.eslintignore

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)