@frogbotai/piece-slack 0.22.0 → 0.23.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.
- package/README.md +114 -0
- package/dist/actions.d.ts +1673 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +641 -0
- package/dist/actions.js.map +1 -0
- package/dist/client.d.ts +44 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +116 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +42 -0
- package/dist/config.js.map +1 -0
- package/dist/files.d.ts +11 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +48 -0
- package/dist/files.js.map +1 -0
- package/dist/index.d.ts +1010 -61
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +99 -113
- package/dist/index.js.map +1 -1
- package/dist/options.d.ts +12 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +50 -0
- package/dist/options.js.map +1 -0
- package/dist/triggers.d.ts +592 -0
- package/dist/triggers.d.ts.map +1 -0
- package/dist/triggers.js +348 -0
- package/dist/triggers.js.map +1 -0
- package/dist/webhook.d.ts +15 -0
- package/dist/webhook.d.ts.map +1 -0
- package/dist/webhook.js +99 -0
- package/dist/webhook.js.map +1 -0
- package/package.json +8 -11
- package/slack-manifest.yaml +32 -0
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,OAAO,EAAE,iBAAiB,EAAoB,MAAM,aAAa,CAAC;AAClE,OAAO,EAA2B,WAAW,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAqC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
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
'chat:write',
|
|
20
|
-
'groups:read',
|
|
21
|
-
'groups:write',
|
|
22
|
-
'groups:history',
|
|
23
|
-
'reactions:read',
|
|
24
|
-
'mpim:read',
|
|
25
|
-
'mpim:write',
|
|
26
|
-
'mpim:history',
|
|
27
|
-
'im:write',
|
|
28
|
-
'im:read',
|
|
29
|
-
'im:history',
|
|
30
|
-
'users:read',
|
|
31
|
-
'files:write',
|
|
32
|
-
'files:read',
|
|
33
|
-
'users:read.email',
|
|
34
|
-
'reactions:write',
|
|
35
|
-
'usergroups:read',
|
|
36
|
-
'usergroups:write',
|
|
37
|
-
'chat:write.customize',
|
|
38
|
-
'links:read',
|
|
39
|
-
'links:write',
|
|
40
|
-
'emoji:read',
|
|
41
|
-
'users.profile:read',
|
|
42
|
-
'channels:write.invites',
|
|
43
|
-
'groups:write.invites',
|
|
44
|
-
'channels:join',
|
|
45
|
-
'conversations.connect:write',
|
|
46
|
-
];
|
|
47
|
-
export function createSlack(config) {
|
|
48
|
-
const piece = createActivepiecesPiece({
|
|
49
|
-
module: module,
|
|
50
|
-
service: 'slack',
|
|
51
|
-
credentialType: 'oauth2',
|
|
52
|
-
defaultActions: slackActions,
|
|
53
|
-
scopes: slackScopes,
|
|
54
|
-
config,
|
|
55
|
-
});
|
|
56
|
-
return Object.assign(piece, {
|
|
57
|
-
/** Add Reaction to Message: Add an emoji reaction to a message. */
|
|
58
|
-
slackAddReactionToMessage: piece.tool('slack-add-reaction-to-message'),
|
|
59
|
-
/** Send Message To A User: Send message to a user */
|
|
60
|
-
sendDirectMessage: piece.tool('send_direct_message'),
|
|
61
|
-
/** Send Message To A Channel: Send message to a channel */
|
|
62
|
-
sendChannelMessage: piece.tool('send_channel_message'),
|
|
63
|
-
/** Request Approval from A User: Send approval message to a user and then wait until the message is approved or disapproved */
|
|
64
|
-
requestApprovalDirectMessage: piece.tool('request_approval_direct_message'),
|
|
65
|
-
/** Request Approval in a Channel: Send approval message to a channel and then wait until the message is approved or disapproved */
|
|
66
|
-
requestApprovalMessage: piece.tool('request_approval_message'),
|
|
67
|
-
/** Request Action from A User: Send a message to a user and wait until the user selects an action */
|
|
68
|
-
requestActionDirectMessage: piece.tool('request_action_direct_message'),
|
|
69
|
-
/** Request Action in A Channel: Send a message in a channel and wait until an action is selected */
|
|
70
|
-
requestActionMessage: piece.tool('request_action_message'),
|
|
71
|
-
/** Upload file: Upload file without sharing it to a channel or user */
|
|
72
|
-
uploadFile: piece.tool('uploadFile'),
|
|
73
|
-
/** Get File: Return information about a given file ID. */
|
|
74
|
-
getFile: piece.tool('get-file'),
|
|
75
|
-
/** Search messages: Searches for messages matching a query */
|
|
76
|
-
searchMessages: piece.tool('searchMessages'),
|
|
77
|
-
/** Find User by Email: Finds a user by matching against their email address. */
|
|
78
|
-
slackFindUserByEmail: piece.tool('slack-find-user-by-email'),
|
|
79
|
-
/** Find User by Handle: Finds a user by matching against their Slack handle. */
|
|
80
|
-
slackFindUserByHandle: piece.tool('slack-find-user-by-handle'),
|
|
81
|
-
/** Find User by ID: Finds a user by their ID. */
|
|
82
|
-
findUserById: piece.tool('find-user-by-id'),
|
|
83
|
-
/** List users: List all users of the workspace */
|
|
84
|
-
listUsers: piece.tool('listUsers'),
|
|
85
|
-
/** Update message: Update an existing message */
|
|
86
|
-
updateMessage: piece.tool('updateMessage'),
|
|
87
|
-
/** Delete Message: Deletes a specific message from a channel using the message's timestamp. */
|
|
88
|
-
deleteMessage: piece.tool('delete-message'),
|
|
89
|
-
/** Create Channel: Creates a new channel. */
|
|
90
|
-
slackCreateChannel: piece.tool('slack-create-channel'),
|
|
91
|
-
/** Update Profile: Update basic profile field such as name or title. */
|
|
92
|
-
slackUpdateProfile: piece.tool('slack-update-profile'),
|
|
93
|
-
/** Get channel history: Retrieve all messages from a specific channel ("conversation") between specified timestamps */
|
|
94
|
-
getChannelHistory: piece.tool('getChannelHistory'),
|
|
95
|
-
/** Set User Status: Sets a user's custom status */
|
|
96
|
-
slackSetUserStatus: piece.tool('slack-set-user-status'),
|
|
97
|
-
/** Markdown to Slack format: Convert Markdown-formatted text to Slack's pseudo - markdown syntax */
|
|
98
|
-
markdownToSlackFormat: piece.tool('markdownToSlackFormat'),
|
|
99
|
-
/** Retrieve Thread Messages: Retrieves thread messages by channel and thread timestamp. */
|
|
100
|
-
retrieveThreadMessages: piece.tool('retrieveThreadMessages'),
|
|
101
|
-
/** Set Channel Topic: Sets the topic on a selected channel. */
|
|
102
|
-
setChannelTopic: piece.tool('set-channel-topic'),
|
|
103
|
-
/** Get Message by Timestamp: Retrieves a specific message from a channel history using the message's timestamp. */
|
|
104
|
-
getMessage: piece.tool('get-message'),
|
|
105
|
-
/** Invite User to Channel: Invites an existing User to an existing channel. */
|
|
106
|
-
inviteUserToChannel: piece.tool('invite-user-to-channel'),
|
|
107
|
-
/** Get User Group by Handle: Finds a Slack user group by its handle (e.g., @user-group) and returns its details. To mention this group in a message, map the returned ID using the syntax <!subteam^ID>. Read more: https://api.slack.com/reference/surfaces/formatting#mentioning-groups */
|
|
108
|
-
getGroupByHandle: piece.tool('get_group_by_handle'),
|
|
109
|
-
/** Update User Group Members: Add users to or overwrite the member list of a Slack user group. */
|
|
110
|
-
updateGroupUsers: piece.tool('update_group_users'),
|
|
111
|
-
/** Custom API Call: Make a custom API call to a specific endpoint */
|
|
112
|
-
customApiCall: piece.tool('custom_api_call'),
|
|
113
|
-
});
|
|
1
|
+
import { createSlackAdapter } from '@chat-adapter/slack';
|
|
2
|
+
import { definePiece, } from 'frogbot/pieces';
|
|
3
|
+
import { slackActions } from './actions.js';
|
|
4
|
+
import { createSlackClient } from './client.js';
|
|
5
|
+
import { slackAuth, slackOptions, slackScopes } from './config.js';
|
|
6
|
+
import { slackTriggers } from './triggers.js';
|
|
7
|
+
import { parseSlackWebhook, slackHandshake, verifySlackWebhook } from './webhook.js';
|
|
8
|
+
export const slackActionNames = slackActions.map((action) => action.slug);
|
|
9
|
+
export const slackTriggerNames = slackTriggers.map((trigger) => trigger.slug);
|
|
10
|
+
export { slackScopes };
|
|
11
|
+
function userToken(tokens) {
|
|
12
|
+
const user = tokens.authed_user;
|
|
13
|
+
return user &&
|
|
14
|
+
typeof user === 'object' &&
|
|
15
|
+
'access_token' in user &&
|
|
16
|
+
typeof user.access_token === 'string'
|
|
17
|
+
? user.access_token
|
|
18
|
+
: undefined;
|
|
114
19
|
}
|
|
20
|
+
function teamId(tokens) {
|
|
21
|
+
const team = tokens.team;
|
|
22
|
+
return team && typeof team === 'object' && 'id' in team && typeof team.id === 'string'
|
|
23
|
+
? team.id
|
|
24
|
+
: undefined;
|
|
25
|
+
}
|
|
26
|
+
const slackAccount = async ({ client }) => {
|
|
27
|
+
const account = await client.request('auth.test');
|
|
28
|
+
const id = typeof account.team_id === 'string' ? account.team_id : '';
|
|
29
|
+
const label = typeof account.team === 'string' ? account.team : id;
|
|
30
|
+
if (!id)
|
|
31
|
+
throw new Error('Slack auth.test did not return a workspace ID.');
|
|
32
|
+
return { id, label };
|
|
33
|
+
};
|
|
34
|
+
const slackWebhook = {
|
|
35
|
+
verify: verifySlackWebhook,
|
|
36
|
+
async handshake({ req }) {
|
|
37
|
+
return slackHandshake(req);
|
|
38
|
+
},
|
|
39
|
+
parse({ req }) {
|
|
40
|
+
return parseSlackWebhook(req);
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
export const createSlack = definePiece({
|
|
44
|
+
slug: 'slack',
|
|
45
|
+
label: 'Slack',
|
|
46
|
+
admin: {
|
|
47
|
+
description: 'Manage Slack messages, files, channels, users, groups, and workspace events',
|
|
48
|
+
group: 'Communication',
|
|
49
|
+
},
|
|
50
|
+
auth: slackAuth,
|
|
51
|
+
options: slackOptions,
|
|
52
|
+
client: createSlackClient,
|
|
53
|
+
oauth: {
|
|
54
|
+
authorizationUrl: 'https://slack.com/oauth/v2/authorize',
|
|
55
|
+
tokenUrl: 'https://slack.com/api/oauth.v2.access',
|
|
56
|
+
scopes: [...slackScopes],
|
|
57
|
+
params: {
|
|
58
|
+
user_scope: 'search:read,users.profile:write,reactions:read,reactions:write,im:history,stars:read,channels:write,groups:write,im:write,mpim:write,channels:write.invites,groups:write.invites,channels:history,groups:history,chat:write,users:read,usergroups:write',
|
|
59
|
+
},
|
|
60
|
+
toAuth: ({ tokens }) => ({
|
|
61
|
+
botToken: tokens.access_token ?? '',
|
|
62
|
+
userToken: userToken(tokens),
|
|
63
|
+
teamId: teamId(tokens),
|
|
64
|
+
}),
|
|
65
|
+
account: slackAccount,
|
|
66
|
+
},
|
|
67
|
+
webhook: slackWebhook,
|
|
68
|
+
channel: {
|
|
69
|
+
adapter({ auth, options }) {
|
|
70
|
+
if (!options.signingSecret) {
|
|
71
|
+
throw new Error('Slack channels require a signingSecret option for webhook verification.');
|
|
72
|
+
}
|
|
73
|
+
return createSlackAdapter({
|
|
74
|
+
botToken: auth.botToken,
|
|
75
|
+
signingSecret: options.signingSecret,
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
async identity({ author, client, req }) {
|
|
79
|
+
const response = await client.request('users.info', { user: author.userId });
|
|
80
|
+
const user = response.user;
|
|
81
|
+
const profile = user && typeof user === 'object' && 'profile' in user ? user.profile : undefined;
|
|
82
|
+
const email = profile && typeof profile === 'object' && 'email' in profile ? profile.email : undefined;
|
|
83
|
+
if (typeof email !== 'string' || !email.trim())
|
|
84
|
+
return null;
|
|
85
|
+
const config = await req.frogbot.config;
|
|
86
|
+
const payloadConfig = await config._internal.payloadConfig;
|
|
87
|
+
const result = await req.frogbot.find({
|
|
88
|
+
collection: payloadConfig.admin.user,
|
|
89
|
+
where: { email: { equals: email.trim().toLowerCase() } },
|
|
90
|
+
limit: 1,
|
|
91
|
+
overrideAccess: true,
|
|
92
|
+
req,
|
|
93
|
+
});
|
|
94
|
+
const match = result.docs[0];
|
|
95
|
+
return match ? { ...match, collection: payloadConfig.admin.user } : null;
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
actions: slackActions,
|
|
99
|
+
triggers: slackTriggers,
|
|
100
|
+
});
|
|
115
101
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,WAAW,GAIZ,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAoB,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAErF,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC1E,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,SAAS,SAAS,CAAC,MAA+B;IAChD,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;IAEhC,OA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SlackClient } from './client.js';
|
|
3
|
+
export declare function channelOptions({ client }: {
|
|
4
|
+
client: SlackClient;
|
|
5
|
+
}): Promise<PieceOption[]>;
|
|
6
|
+
export declare function userOptions({ client }: {
|
|
7
|
+
client: SlackClient;
|
|
8
|
+
}): Promise<PieceOption[]>;
|
|
9
|
+
export declare function userGroupOptions({ client }: {
|
|
10
|
+
client: SlackClient;
|
|
11
|
+
}): Promise<PieceOption[]>;
|
|
12
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM/C,wBAAsB,cAAc,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,0BAiBvE;AAED,wBAAsB,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,0BAgBpE;AAED,wBAAsB,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,0BAazE"}
|
package/dist/options.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function text(value) {
|
|
2
|
+
return typeof value === 'string' ? value : '';
|
|
3
|
+
}
|
|
4
|
+
export async function channelOptions({ client }) {
|
|
5
|
+
const channels = await client.paginate({
|
|
6
|
+
path: 'conversations.list',
|
|
7
|
+
body: { types: 'public_channel,private_channel', exclude_archived: true },
|
|
8
|
+
item: 'channels',
|
|
9
|
+
limit: 2000,
|
|
10
|
+
});
|
|
11
|
+
return channels.flatMap((channel) => {
|
|
12
|
+
if (!channel || typeof channel !== 'object')
|
|
13
|
+
return [];
|
|
14
|
+
if (!('id' in channel) || !('name' in channel))
|
|
15
|
+
return [];
|
|
16
|
+
const value = text(channel.id);
|
|
17
|
+
const label = text(channel.name);
|
|
18
|
+
return value && label ? [{ label, value }] : [];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export async function userOptions({ client }) {
|
|
22
|
+
const users = await client.paginate({
|
|
23
|
+
path: 'users.list',
|
|
24
|
+
item: 'members',
|
|
25
|
+
body: { limit: 1000 },
|
|
26
|
+
});
|
|
27
|
+
return users.flatMap((user) => {
|
|
28
|
+
if (!user || typeof user !== 'object' || !('id' in user) || !('name' in user))
|
|
29
|
+
return [];
|
|
30
|
+
if ('deleted' in user && user.deleted === true)
|
|
31
|
+
return [];
|
|
32
|
+
const value = text(user.id);
|
|
33
|
+
const label = text(user.name);
|
|
34
|
+
return value && label ? [{ label, value }] : [];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export async function userGroupOptions({ client }) {
|
|
38
|
+
const response = await client.request('usergroups.list');
|
|
39
|
+
const groups = Array.isArray(response.usergroups) ? response.usergroups : [];
|
|
40
|
+
return groups.flatMap((group) => {
|
|
41
|
+
if (!group || typeof group !== 'object' || !('id' in group))
|
|
42
|
+
return [];
|
|
43
|
+
if ('date_delete' in group && Boolean(group.date_delete))
|
|
44
|
+
return [];
|
|
45
|
+
const value = text(group.id);
|
|
46
|
+
const label = 'handle' in group ? text(group.handle) : 'name' in group ? text(group.name) : '';
|
|
47
|
+
return value && label ? [{ label, value }] : [];
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAIA,SAAS,IAAI,CAAC,KAAc;IAC1B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EAAE,MAAM,EAA2B;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