@credal/actions 0.1.60 → 0.1.62
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 +1 -1
- package/dist/actions/autogen/types.d.ts +3 -3
- package/dist/actions/autogen/types.js +1 -1
- package/dist/actions/providers/salesforce/createRecord.js +6 -0
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.d.ts +3 -0
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.js +43 -0
- package/dist/actions/providers/snowflake/runSnowflakeQuery.js +5 -4
- package/dist/actions/util/formatDataForCodeInterpreter.d.ts +1 -4
- package/dist/actions/util/formatDataForCodeInterpreter.js +1 -1
- package/package.json +1 -1
- package/dist/actions/providers/confluence/updatePage.d.ts +0 -3
- package/dist/actions/providers/confluence/updatePage.js +0 -47
@@ -2394,13 +2394,13 @@ export type salesforceUpdateRecordOutputType = z.infer<typeof salesforceUpdateRe
|
|
2394
2394
|
export type salesforceUpdateRecordFunction = ActionFunction<salesforceUpdateRecordParamsType, AuthParamsType, salesforceUpdateRecordOutputType>;
|
2395
2395
|
export declare const salesforceCreateRecordParamsSchema: z.ZodObject<{
|
2396
2396
|
objectType: z.ZodString;
|
2397
|
-
fieldsToCreate: z.ZodRecord<z.ZodString, z.ZodString
|
2397
|
+
fieldsToCreate: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
2398
2398
|
}, "strip", z.ZodTypeAny, {
|
2399
2399
|
objectType: string;
|
2400
|
-
fieldsToCreate
|
2400
|
+
fieldsToCreate?: Record<string, string> | undefined;
|
2401
2401
|
}, {
|
2402
2402
|
objectType: string;
|
2403
|
-
fieldsToCreate
|
2403
|
+
fieldsToCreate?: Record<string, string> | undefined;
|
2404
2404
|
}>;
|
2405
2405
|
export type salesforceCreateRecordParamsType = z.infer<typeof salesforceCreateRecordParamsSchema>;
|
2406
2406
|
export declare const salesforceCreateRecordOutputSchema: z.ZodObject<{
|
@@ -2129,7 +2129,7 @@ exports.salesforceUpdateRecordOutputSchema = zod_1.z.object({
|
|
2129
2129
|
});
|
2130
2130
|
exports.salesforceCreateRecordParamsSchema = zod_1.z.object({
|
2131
2131
|
objectType: zod_1.z.string().describe("The Salesforce object type to create (e.g., Lead, Account, Contact)"),
|
2132
|
-
fieldsToCreate: zod_1.z.record(zod_1.z.string()).describe("The fields to create on the record"),
|
2132
|
+
fieldsToCreate: zod_1.z.record(zod_1.z.string()).describe("The fields to create on the record").optional(),
|
2133
2133
|
});
|
2134
2134
|
exports.salesforceCreateRecordOutputSchema = zod_1.z.object({
|
2135
2135
|
success: zod_1.z.boolean().describe("Whether the record was successfully created"),
|
@@ -19,6 +19,12 @@ const createRecord = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params
|
|
19
19
|
error: "authToken and baseUrl are required for Salesforce API",
|
20
20
|
};
|
21
21
|
}
|
22
|
+
if (!fieldsToCreate) {
|
23
|
+
return {
|
24
|
+
success: false,
|
25
|
+
error: "fieldsToCreate is required to create a Salesforce object",
|
26
|
+
};
|
27
|
+
}
|
22
28
|
const url = `${baseUrl}/services/data/v56.0/sobjects/${objectType}/`;
|
23
29
|
try {
|
24
30
|
const response = yield axiosClient_1.axiosClient.post(url, fieldsToCreate, {
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
const axiosClient_1 = require("../../util/axiosClient");
|
13
|
+
const getSalesforceRecordByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
14
|
+
const { authToken, baseUrl } = authParams;
|
15
|
+
const { query, limit } = params;
|
16
|
+
if (!authToken || !baseUrl) {
|
17
|
+
return {
|
18
|
+
success: false,
|
19
|
+
error: "authToken and baseUrl are required for Salesforce API",
|
20
|
+
};
|
21
|
+
}
|
22
|
+
// The API limits the maximum number of records returned to 2000, the limit lets the user set a smaller custom limit
|
23
|
+
const url = `${baseUrl}/services/data/v56.0/query/?q=${encodeURIComponent(query + " LIMIT " + (limit != undefined && limit <= 2000 ? limit : 2000))}`;
|
24
|
+
try {
|
25
|
+
const response = yield axiosClient_1.axiosClient.get(url, {
|
26
|
+
headers: {
|
27
|
+
Authorization: `Bearer ${authToken}`,
|
28
|
+
},
|
29
|
+
});
|
30
|
+
return {
|
31
|
+
success: true,
|
32
|
+
records: response.data,
|
33
|
+
};
|
34
|
+
}
|
35
|
+
catch (error) {
|
36
|
+
console.error("Error retrieving Salesforce record:", error);
|
37
|
+
return {
|
38
|
+
success: false,
|
39
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
40
|
+
};
|
41
|
+
}
|
42
|
+
});
|
43
|
+
exports.default = getSalesforceRecordByQuery;
|
@@ -35,12 +35,13 @@ const runSnowflakeQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
35
35
|
},
|
36
36
|
});
|
37
37
|
});
|
38
|
+
const fullResultLength = queryResults.length;
|
38
39
|
// Format the results based on the output format
|
39
|
-
if (limit && queryResults.length
|
40
|
-
queryResults.splice(limit
|
40
|
+
if (limit && queryResults.length > limit) {
|
41
|
+
queryResults.splice(limit);
|
41
42
|
}
|
42
|
-
const
|
43
|
-
return { formattedData, resultsLength };
|
43
|
+
const formattedData = (0, formatDataForCodeInterpreter_1.formatDataForCodeInterpreter)(queryResults, outputFormat);
|
44
|
+
return { formattedData: formattedData, resultsLength: fullResultLength };
|
44
45
|
});
|
45
46
|
// Set up a connection using snowflake-sdk
|
46
47
|
const connection = (0, getSnowflakeConnection_1.getSnowflakeConnection)({
|
@@ -4,7 +4,4 @@
|
|
4
4
|
* @param outputFormat The desired output format ("csv" or "json")
|
5
5
|
* @returns Object containing formatted data and result count
|
6
6
|
*/
|
7
|
-
export declare function formatDataForCodeInterpreter(queryResults: any[], outputFormat?: string):
|
8
|
-
formattedData: string;
|
9
|
-
resultsLength: number;
|
10
|
-
};
|
7
|
+
export declare function formatDataForCodeInterpreter(queryResults: any[], outputFormat?: string): string;
|
@@ -39,5 +39,5 @@ function formatDataForCodeInterpreter(queryResults, outputFormat = "json") {
|
|
39
39
|
// Default to JSON - keep it formatted for readability
|
40
40
|
formattedData = JSON.stringify(queryResults, null, 2);
|
41
41
|
}
|
42
|
-
return
|
42
|
+
return formattedData;
|
43
43
|
}
|
package/package.json
CHANGED
@@ -1,47 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const axios_1 = __importDefault(require("axios"));
|
16
|
-
function getConfluenceApi(baseUrl, username, apiToken) {
|
17
|
-
const api = axios_1.default.create({
|
18
|
-
baseURL: baseUrl,
|
19
|
-
headers: {
|
20
|
-
Accept: "application/json",
|
21
|
-
// Tokens are associated with a specific user.
|
22
|
-
Authorization: `Basic ${Buffer.from(`${username}:${apiToken}`).toString("base64")}`,
|
23
|
-
},
|
24
|
-
});
|
25
|
-
return api;
|
26
|
-
}
|
27
|
-
const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
28
|
-
const { pageId, username, content, title } = params;
|
29
|
-
const { baseUrl, authToken } = authParams;
|
30
|
-
const api = getConfluenceApi(baseUrl, username, authToken);
|
31
|
-
// Get current version number
|
32
|
-
const response = yield api.get(`/api/v2/pages/${pageId}`);
|
33
|
-
const currVersion = response.data.version.number;
|
34
|
-
yield api.put(`/api/v2/pages/${pageId}`, {
|
35
|
-
id: pageId,
|
36
|
-
status: "current",
|
37
|
-
title,
|
38
|
-
body: {
|
39
|
-
representation: "storage",
|
40
|
-
value: content,
|
41
|
-
},
|
42
|
-
version: {
|
43
|
-
number: currVersion + 1,
|
44
|
-
},
|
45
|
-
});
|
46
|
-
});
|
47
|
-
exports.default = confluenceUpdatePage;
|