@credal/actions 0.2.70 → 0.2.72
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/dist/actions/autogen/templates.js +6 -2
- package/dist/actions/autogen/types.d.ts +6 -3
- package/dist/actions/autogen/types.js +8 -1
- package/dist/actions/providers/salesforce/getSalesforceRecordsByQuery.js +9 -1
- package/dist/actions/providers/salesforce/searchSalesforceRecords.js +11 -3
- package/dist/actions/providers/slack/getChannelMessages.js +14 -7
- package/package.json +1 -1
|
@@ -613,11 +613,15 @@ export const slackGetChannelMessagesDefinition = {
|
|
|
613
613
|
scopes: ["channels:history"],
|
|
614
614
|
parameters: {
|
|
615
615
|
type: "object",
|
|
616
|
-
required: ["
|
|
616
|
+
required: ["oldest"],
|
|
617
617
|
properties: {
|
|
618
|
+
channelId: {
|
|
619
|
+
type: "string",
|
|
620
|
+
description: "The ID of the channel to get messages from. Either the channelId or channelName must be provided.",
|
|
621
|
+
},
|
|
618
622
|
channelName: {
|
|
619
623
|
type: "string",
|
|
620
|
-
description: "Name of the channel to summarize",
|
|
624
|
+
description: "Name of the channel to summarize. Either the channelId or channelName must be provided.",
|
|
621
625
|
},
|
|
622
626
|
oldest: {
|
|
623
627
|
type: "string",
|
|
@@ -765,14 +765,17 @@ export declare const slackSendMessageOutputSchema: z.ZodObject<{
|
|
|
765
765
|
export type slackSendMessageOutputType = z.infer<typeof slackSendMessageOutputSchema>;
|
|
766
766
|
export type slackSendMessageFunction = ActionFunction<slackSendMessageParamsType, AuthParamsType, slackSendMessageOutputType>;
|
|
767
767
|
export declare const slackGetChannelMessagesParamsSchema: z.ZodObject<{
|
|
768
|
-
|
|
768
|
+
channelId: z.ZodOptional<z.ZodString>;
|
|
769
|
+
channelName: z.ZodOptional<z.ZodString>;
|
|
769
770
|
oldest: z.ZodString;
|
|
770
771
|
}, "strip", z.ZodTypeAny, {
|
|
771
|
-
channelName: string;
|
|
772
772
|
oldest: string;
|
|
773
|
+
channelName?: string | undefined;
|
|
774
|
+
channelId?: string | undefined;
|
|
773
775
|
}, {
|
|
774
|
-
channelName: string;
|
|
775
776
|
oldest: string;
|
|
777
|
+
channelName?: string | undefined;
|
|
778
|
+
channelId?: string | undefined;
|
|
776
779
|
}>;
|
|
777
780
|
export type slackGetChannelMessagesParamsType = z.infer<typeof slackGetChannelMessagesParamsSchema>;
|
|
778
781
|
export declare const slackGetChannelMessagesOutputSchema: z.ZodObject<{
|
|
@@ -231,7 +231,14 @@ export const slackSendMessageOutputSchema = z.object({
|
|
|
231
231
|
error: z.string().describe("The error that occurred if the email was not sent successfully").optional(),
|
|
232
232
|
});
|
|
233
233
|
export const slackGetChannelMessagesParamsSchema = z.object({
|
|
234
|
-
|
|
234
|
+
channelId: z
|
|
235
|
+
.string()
|
|
236
|
+
.describe("The ID of the channel to get messages from. Either the channelId or channelName must be provided.")
|
|
237
|
+
.optional(),
|
|
238
|
+
channelName: z
|
|
239
|
+
.string()
|
|
240
|
+
.describe("Name of the channel to summarize. Either the channelId or channelName must be provided.")
|
|
241
|
+
.optional(),
|
|
235
242
|
oldest: z.string().describe("Only messages after this Unix timestamp will be included in results"),
|
|
236
243
|
});
|
|
237
244
|
export const slackGetChannelMessagesOutputSchema = z.object({
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { ApiError, axiosClient } from "../../util/axiosClient.js";
|
|
11
11
|
const MAX_RECORDS_LIMIT = 2000;
|
|
12
12
|
const getSalesforceRecordsByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
13
|
+
var _b;
|
|
13
14
|
const { authToken, baseUrl } = authParams;
|
|
14
15
|
const { query, limit } = params;
|
|
15
16
|
if (!authToken || !baseUrl) {
|
|
@@ -32,9 +33,16 @@ const getSalesforceRecordsByQuery = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
32
33
|
Authorization: `Bearer ${authToken}`,
|
|
33
34
|
},
|
|
34
35
|
});
|
|
36
|
+
// Salesforce record types are confusing and non standard
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
const recordsWithUrl = (_b = response.data.records) === null || _b === void 0 ? void 0 : _b.map((record) => {
|
|
39
|
+
const recordId = record.Id;
|
|
40
|
+
const webUrl = recordId ? `${baseUrl}/lightning/${recordId}` : undefined;
|
|
41
|
+
return Object.assign(Object.assign({}, record), { webUrl });
|
|
42
|
+
});
|
|
35
43
|
return {
|
|
36
44
|
success: true,
|
|
37
|
-
records: response.data,
|
|
45
|
+
records: Object.assign(Object.assign({}, response.data), { records: response.data.records ? recordsWithUrl : undefined }),
|
|
38
46
|
};
|
|
39
47
|
}
|
|
40
48
|
catch (error) {
|
|
@@ -11,6 +11,7 @@ import { ApiError, axiosClient } from "../../util/axiosClient.js";
|
|
|
11
11
|
const searchSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
12
|
const { authToken, baseUrl } = authParams;
|
|
13
13
|
const { keyword, recordType, fieldsToSearch } = params;
|
|
14
|
+
const searchFields = Array.from(new Set([...fieldsToSearch, "Id"]));
|
|
14
15
|
if (!authToken || !baseUrl) {
|
|
15
16
|
return {
|
|
16
17
|
success: false,
|
|
@@ -18,8 +19,8 @@ const searchSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
const maxLimit = 25;
|
|
21
|
-
const dateFieldExists =
|
|
22
|
-
const url = `${baseUrl}/services/data/v64.0/search/?q=${encodeURIComponent(`FIND {${keyword}} RETURNING ${recordType} (${
|
|
22
|
+
const dateFieldExists = searchFields.includes("CreatedDate");
|
|
23
|
+
const url = `${baseUrl}/services/data/v64.0/search/?q=${encodeURIComponent(`FIND {${keyword}} RETURNING ${recordType} (${searchFields.join(", ") + (dateFieldExists ? " ORDER BY CreatedDate DESC" : "")}) LIMIT ${params.limit && params.limit <= maxLimit ? params.limit : maxLimit}`)}`;
|
|
23
24
|
try {
|
|
24
25
|
const response = yield axiosClient.get(url, {
|
|
25
26
|
headers: {
|
|
@@ -42,9 +43,16 @@ const searchSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
}
|
|
46
|
+
// Salesforce record types are confusing and non standard
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
const recordsWithUrl = response.data.searchRecords.map((record) => {
|
|
49
|
+
const recordId = record.Id;
|
|
50
|
+
const webUrl = recordId ? `${baseUrl}/lightning/${recordId}` : undefined;
|
|
51
|
+
return Object.assign(Object.assign({}, record), { webUrl });
|
|
52
|
+
});
|
|
45
53
|
return {
|
|
46
54
|
success: true,
|
|
47
|
-
searchRecords:
|
|
55
|
+
searchRecords: recordsWithUrl,
|
|
48
56
|
};
|
|
49
57
|
}
|
|
50
58
|
catch (error) {
|
|
@@ -15,18 +15,25 @@ const getChannelMessages = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
15
15
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
16
16
|
}
|
|
17
17
|
const client = new WebClient(authParams.authToken);
|
|
18
|
-
const { channelName, oldest } = params;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const { channelId: inputChannelId, channelName, oldest } = params;
|
|
19
|
+
if (!inputChannelId && !channelName) {
|
|
20
|
+
throw Error("Either channelId or channelName must be provided");
|
|
21
|
+
}
|
|
22
|
+
let channelId = inputChannelId;
|
|
23
|
+
if (!channelId) {
|
|
24
|
+
const allChannels = yield getSlackChannels(client);
|
|
25
|
+
const channel = allChannels.find(channel => channel.name === channelName && channel.is_private === false);
|
|
26
|
+
if (!channel || !channel.id) {
|
|
27
|
+
throw Error(`Channel with name ${channelName} not found`);
|
|
28
|
+
}
|
|
29
|
+
channelId = channel.id;
|
|
23
30
|
}
|
|
24
31
|
const messages = yield client.conversations.history({
|
|
25
|
-
channel:
|
|
32
|
+
channel: channelId,
|
|
26
33
|
oldest: oldest,
|
|
27
34
|
});
|
|
28
35
|
if (!messages.ok) {
|
|
29
|
-
throw Error(`Failed to fetch messages from channel ${
|
|
36
|
+
throw Error(`Failed to fetch messages from channel ${channelName}, channelId: ${channelId}`);
|
|
30
37
|
}
|
|
31
38
|
return {
|
|
32
39
|
messages: messages.messages,
|