@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.
@@ -5342,7 +5342,7 @@ exports.salesforceCreateRecordDefinition = {
5342
5342
  scopes: [],
5343
5343
  parameters: {
5344
5344
  type: "object",
5345
- required: ["objectType", "fieldsToCreate"],
5345
+ required: ["objectType"],
5346
5346
  properties: {
5347
5347
  objectType: {
5348
5348
  type: "string",
@@ -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: Record<string, string>;
2400
+ fieldsToCreate?: Record<string, string> | undefined;
2401
2401
  }, {
2402
2402
  objectType: string;
2403
- fieldsToCreate: Record<string, string>;
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,3 @@
1
+ import { salesforceGetSalesforceRecordsByQueryFunction } from "../../autogen/types";
2
+ declare const getSalesforceRecordByQuery: salesforceGetSalesforceRecordsByQueryFunction;
3
+ export default getSalesforceRecordByQuery;
@@ -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 - 1 > limit) {
40
- queryResults.splice(limit + 1); // Include header
40
+ if (limit && queryResults.length > limit) {
41
+ queryResults.splice(limit);
41
42
  }
42
- const { formattedData, resultsLength } = (0, formatDataForCodeInterpreter_1.formatDataForCodeInterpreter)(queryResults, outputFormat);
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 { formattedData, resultsLength: queryResults.length };
42
+ return formattedData;
43
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.1.60",
3
+ "version": "0.1.62",
4
4
  "description": "AI Actions by Credal AI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,3 +0,0 @@
1
- import { confluenceUpdatePageFunction } from "../../../actions/autogen/types";
2
- declare const confluenceUpdatePage: confluenceUpdatePageFunction;
3
- export default confluenceUpdatePage;
@@ -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;