@credal/actions 0.1.24 → 0.1.25

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.
@@ -27,6 +27,7 @@ const symbolLookup_1 = __importDefault(require("./providers/finnhub/symbolLookup
27
27
  const getBasicFinancials_1 = __importDefault(require("./providers/finnhub/getBasicFinancials"));
28
28
  const overwritePage_1 = __importDefault(require("./providers/confluence/overwritePage"));
29
29
  const fetchPageContent_1 = __importDefault(require("./providers/confluence/fetchPageContent"));
30
+ const runSnowflakeQueryWriteResultsToS3_1 = __importDefault(require("./providers/snowflake/runSnowflakeQueryWriteResultsToS3"));
30
31
  exports.ActionMapper = {
31
32
  math: {
32
33
  add: {
@@ -98,6 +99,11 @@ exports.ActionMapper = {
98
99
  paramsSchema: types_1.snowflakeGetRowByFieldValueParamsSchema,
99
100
  outputSchema: types_1.snowflakeGetRowByFieldValueOutputSchema,
100
101
  },
102
+ runSnowflakeQueryWriteResultsToS3: {
103
+ fn: runSnowflakeQueryWriteResultsToS3_1.default,
104
+ paramsSchema: types_1.snowflakeRunSnowflakeQueryWriteResultsToS3ParamsSchema,
105
+ outputSchema: types_1.snowflakeRunSnowflakeQueryWriteResultsToS3OutputSchema,
106
+ },
101
107
  },
102
108
  linkedin: {
103
109
  createShareLinkedinPostUrl: {
@@ -13,6 +13,7 @@ export declare const linkedinCreateShareLinkedinPostUrlDefinition: ActionTemplat
13
13
  export declare const xCreateShareXPostUrlDefinition: ActionTemplate;
14
14
  export declare const mongoInsertMongoDocDefinition: ActionTemplate;
15
15
  export declare const snowflakeGetRowByFieldValueDefinition: ActionTemplate;
16
+ export declare const snowflakeRunSnowflakeQueryWriteResultsToS3Definition: ActionTemplate;
16
17
  export declare const openstreetmapGetLatitudeLongitudeFromLocationDefinition: ActionTemplate;
17
18
  export declare const nwsGetForecastForLocationDefinition: ActionTemplate;
18
19
  export declare const firecrawlScrapeUrlDefinition: ActionTemplate;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.finnhubGetBasicFinancialsDefinition = exports.finnhubSymbolLookupDefinition = exports.googleOauthCreateNewGoogleDocDefinition = exports.resendSendEmailDefinition = exports.firecrawlScrapeTweetDataWithNitterDefinition = exports.firecrawlScrapeUrlDefinition = exports.nwsGetForecastForLocationDefinition = exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = exports.snowflakeGetRowByFieldValueDefinition = exports.mongoInsertMongoDocDefinition = exports.xCreateShareXPostUrlDefinition = exports.linkedinCreateShareLinkedinPostUrlDefinition = exports.zendeskCreateZendeskTicketDefinition = exports.credalCallCopilotDefinition = exports.googlemapsNearbysearchRestaurantsDefinition = exports.googlemapsValidateAddressDefinition = exports.jiraCreateJiraTicketDefinition = exports.confluenceFetchPageContentDefinition = exports.confluenceOverwritePageDefinition = exports.mathAddDefinition = exports.slackListConversationsDefinition = exports.slackSendMessageDefinition = void 0;
3
+ exports.finnhubGetBasicFinancialsDefinition = exports.finnhubSymbolLookupDefinition = exports.googleOauthCreateNewGoogleDocDefinition = exports.resendSendEmailDefinition = exports.firecrawlScrapeTweetDataWithNitterDefinition = exports.firecrawlScrapeUrlDefinition = exports.nwsGetForecastForLocationDefinition = exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = exports.snowflakeRunSnowflakeQueryWriteResultsToS3Definition = exports.snowflakeGetRowByFieldValueDefinition = exports.mongoInsertMongoDocDefinition = exports.xCreateShareXPostUrlDefinition = exports.linkedinCreateShareLinkedinPostUrlDefinition = exports.zendeskCreateZendeskTicketDefinition = exports.credalCallCopilotDefinition = exports.googlemapsNearbysearchRestaurantsDefinition = exports.googlemapsValidateAddressDefinition = exports.jiraCreateJiraTicketDefinition = exports.confluenceFetchPageContentDefinition = exports.confluenceOverwritePageDefinition = exports.mathAddDefinition = exports.slackListConversationsDefinition = exports.slackSendMessageDefinition = void 0;
4
4
  exports.slackSendMessageDefinition = {
5
5
  description: "Sends a message to a Slack channel",
6
6
  scopes: ["chat:write"],
@@ -773,6 +773,69 @@ exports.snowflakeGetRowByFieldValueDefinition = {
773
773
  name: "getRowByFieldValue",
774
774
  provider: "snowflake",
775
775
  };
776
+ exports.snowflakeRunSnowflakeQueryWriteResultsToS3Definition = {
777
+ description: "Execute a Snowflake query and write results to an S3 bucket",
778
+ scopes: [],
779
+ parameters: {
780
+ type: "object",
781
+ required: ["databaseName", "warehouse", "query", "user", "accountName", "s3BucketName", "s3Region"],
782
+ properties: {
783
+ databaseName: {
784
+ type: "string",
785
+ description: "The name of the database to query",
786
+ },
787
+ warehouse: {
788
+ type: "string",
789
+ description: "The warehouse to use for executing the query",
790
+ },
791
+ query: {
792
+ type: "string",
793
+ description: "The SQL query to execute",
794
+ },
795
+ user: {
796
+ type: "string",
797
+ description: "The username to authenticate with",
798
+ },
799
+ accountName: {
800
+ type: "string",
801
+ description: "The name of the Snowflake account",
802
+ },
803
+ s3BucketName: {
804
+ type: "string",
805
+ description: "The name of the S3 bucket to write results to",
806
+ },
807
+ s3Region: {
808
+ type: "string",
809
+ description: "The AWS region where the S3 bucket is located",
810
+ },
811
+ outputFormat: {
812
+ type: "string",
813
+ description: "Format for the output file (json or csv, defaults to json)",
814
+ enum: ["json", "csv"],
815
+ },
816
+ },
817
+ },
818
+ output: {
819
+ type: "object",
820
+ required: ["bucketUrl", "message", "rowCount"],
821
+ properties: {
822
+ bucketUrl: {
823
+ type: "string",
824
+ description: "The URL of the S3 bucket where the results are stored",
825
+ },
826
+ message: {
827
+ type: "string",
828
+ description: "A message describing the result or error",
829
+ },
830
+ rowCount: {
831
+ type: "number",
832
+ description: "The number of rows returned by the query",
833
+ },
834
+ },
835
+ },
836
+ name: "runSnowflakeQueryWriteResultsToS3",
837
+ provider: "snowflake",
838
+ };
776
839
  exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = {
777
840
  description: "Get the latitude and longitude of a location",
778
841
  scopes: [],
@@ -13,6 +13,8 @@ export declare const AuthParamsSchema: z.ZodObject<{
13
13
  emailReplyTo: z.ZodOptional<z.ZodString>;
14
14
  emailBcc: z.ZodOptional<z.ZodString>;
15
15
  cloudId: z.ZodOptional<z.ZodString>;
16
+ awsAccessKeyId: z.ZodOptional<z.ZodString>;
17
+ awsSecretAccessKey: z.ZodOptional<z.ZodString>;
16
18
  }, "strip", z.ZodTypeAny, {
17
19
  authToken?: string | undefined;
18
20
  baseUrl?: string | undefined;
@@ -23,6 +25,8 @@ export declare const AuthParamsSchema: z.ZodObject<{
23
25
  emailReplyTo?: string | undefined;
24
26
  emailBcc?: string | undefined;
25
27
  cloudId?: string | undefined;
28
+ awsAccessKeyId?: string | undefined;
29
+ awsSecretAccessKey?: string | undefined;
26
30
  }, {
27
31
  authToken?: string | undefined;
28
32
  baseUrl?: string | undefined;
@@ -33,6 +37,8 @@ export declare const AuthParamsSchema: z.ZodObject<{
33
37
  emailReplyTo?: string | undefined;
34
38
  emailBcc?: string | undefined;
35
39
  cloudId?: string | undefined;
40
+ awsAccessKeyId?: string | undefined;
41
+ awsSecretAccessKey?: string | undefined;
36
42
  }>;
37
43
  export type AuthParamsType = z.infer<typeof AuthParamsSchema>;
38
44
  export declare const slackSendMessageParamsSchema: z.ZodObject<{
@@ -763,6 +769,50 @@ export declare const snowflakeGetRowByFieldValueOutputSchema: z.ZodObject<{
763
769
  }>;
764
770
  export type snowflakeGetRowByFieldValueOutputType = z.infer<typeof snowflakeGetRowByFieldValueOutputSchema>;
765
771
  export type snowflakeGetRowByFieldValueFunction = ActionFunction<snowflakeGetRowByFieldValueParamsType, AuthParamsType, snowflakeGetRowByFieldValueOutputType>;
772
+ export declare const snowflakeRunSnowflakeQueryWriteResultsToS3ParamsSchema: z.ZodObject<{
773
+ databaseName: z.ZodString;
774
+ warehouse: z.ZodString;
775
+ query: z.ZodString;
776
+ user: z.ZodString;
777
+ accountName: z.ZodString;
778
+ s3BucketName: z.ZodString;
779
+ s3Region: z.ZodString;
780
+ outputFormat: z.ZodOptional<z.ZodEnum<["json", "csv"]>>;
781
+ }, "strip", z.ZodTypeAny, {
782
+ query: string;
783
+ databaseName: string;
784
+ accountName: string;
785
+ user: string;
786
+ warehouse: string;
787
+ s3BucketName: string;
788
+ s3Region: string;
789
+ outputFormat?: "json" | "csv" | undefined;
790
+ }, {
791
+ query: string;
792
+ databaseName: string;
793
+ accountName: string;
794
+ user: string;
795
+ warehouse: string;
796
+ s3BucketName: string;
797
+ s3Region: string;
798
+ outputFormat?: "json" | "csv" | undefined;
799
+ }>;
800
+ export type snowflakeRunSnowflakeQueryWriteResultsToS3ParamsType = z.infer<typeof snowflakeRunSnowflakeQueryWriteResultsToS3ParamsSchema>;
801
+ export declare const snowflakeRunSnowflakeQueryWriteResultsToS3OutputSchema: z.ZodObject<{
802
+ bucketUrl: z.ZodString;
803
+ message: z.ZodString;
804
+ rowCount: z.ZodNumber;
805
+ }, "strip", z.ZodTypeAny, {
806
+ message: string;
807
+ bucketUrl: string;
808
+ rowCount: number;
809
+ }, {
810
+ message: string;
811
+ bucketUrl: string;
812
+ rowCount: number;
813
+ }>;
814
+ export type snowflakeRunSnowflakeQueryWriteResultsToS3OutputType = z.infer<typeof snowflakeRunSnowflakeQueryWriteResultsToS3OutputSchema>;
815
+ export type snowflakeRunSnowflakeQueryWriteResultsToS3Function = ActionFunction<snowflakeRunSnowflakeQueryWriteResultsToS3ParamsType, AuthParamsType, snowflakeRunSnowflakeQueryWriteResultsToS3OutputType>;
766
816
  export declare const openstreetmapGetLatitudeLongitudeFromLocationParamsSchema: z.ZodObject<{
767
817
  location: z.ZodString;
768
818
  }, "strip", z.ZodTypeAny, {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.finnhubGetBasicFinancialsOutputSchema = exports.finnhubGetBasicFinancialsParamsSchema = exports.finnhubSymbolLookupOutputSchema = exports.finnhubSymbolLookupParamsSchema = exports.googleOauthCreateNewGoogleDocOutputSchema = exports.googleOauthCreateNewGoogleDocParamsSchema = exports.resendSendEmailOutputSchema = exports.resendSendEmailParamsSchema = exports.firecrawlScrapeTweetDataWithNitterOutputSchema = exports.firecrawlScrapeTweetDataWithNitterParamsSchema = exports.firecrawlScrapeUrlOutputSchema = exports.firecrawlScrapeUrlParamsSchema = exports.nwsGetForecastForLocationOutputSchema = exports.nwsGetForecastForLocationParamsSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = exports.snowflakeGetRowByFieldValueOutputSchema = exports.snowflakeGetRowByFieldValueParamsSchema = exports.mongoInsertMongoDocOutputSchema = exports.mongoInsertMongoDocParamsSchema = exports.xCreateShareXPostUrlOutputSchema = exports.xCreateShareXPostUrlParamsSchema = exports.linkedinCreateShareLinkedinPostUrlOutputSchema = exports.linkedinCreateShareLinkedinPostUrlParamsSchema = exports.zendeskCreateZendeskTicketOutputSchema = exports.zendeskCreateZendeskTicketParamsSchema = exports.credalCallCopilotOutputSchema = exports.credalCallCopilotParamsSchema = exports.googlemapsNearbysearchRestaurantsOutputSchema = exports.googlemapsNearbysearchRestaurantsParamsSchema = exports.googlemapsValidateAddressOutputSchema = exports.googlemapsValidateAddressParamsSchema = exports.jiraCreateJiraTicketOutputSchema = exports.jiraCreateJiraTicketParamsSchema = exports.confluenceFetchPageContentOutputSchema = exports.confluenceFetchPageContentParamsSchema = exports.confluenceOverwritePageOutputSchema = exports.confluenceOverwritePageParamsSchema = exports.mathAddOutputSchema = exports.mathAddParamsSchema = exports.slackListConversationsOutputSchema = exports.slackListConversationsParamsSchema = exports.slackSendMessageOutputSchema = exports.slackSendMessageParamsSchema = exports.AuthParamsSchema = void 0;
3
+ exports.finnhubGetBasicFinancialsOutputSchema = exports.finnhubGetBasicFinancialsParamsSchema = exports.finnhubSymbolLookupOutputSchema = exports.finnhubSymbolLookupParamsSchema = exports.googleOauthCreateNewGoogleDocOutputSchema = exports.googleOauthCreateNewGoogleDocParamsSchema = exports.resendSendEmailOutputSchema = exports.resendSendEmailParamsSchema = exports.firecrawlScrapeTweetDataWithNitterOutputSchema = exports.firecrawlScrapeTweetDataWithNitterParamsSchema = exports.firecrawlScrapeUrlOutputSchema = exports.firecrawlScrapeUrlParamsSchema = exports.nwsGetForecastForLocationOutputSchema = exports.nwsGetForecastForLocationParamsSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = exports.snowflakeRunSnowflakeQueryWriteResultsToS3OutputSchema = exports.snowflakeRunSnowflakeQueryWriteResultsToS3ParamsSchema = exports.snowflakeGetRowByFieldValueOutputSchema = exports.snowflakeGetRowByFieldValueParamsSchema = exports.mongoInsertMongoDocOutputSchema = exports.mongoInsertMongoDocParamsSchema = exports.xCreateShareXPostUrlOutputSchema = exports.xCreateShareXPostUrlParamsSchema = exports.linkedinCreateShareLinkedinPostUrlOutputSchema = exports.linkedinCreateShareLinkedinPostUrlParamsSchema = exports.zendeskCreateZendeskTicketOutputSchema = exports.zendeskCreateZendeskTicketParamsSchema = exports.credalCallCopilotOutputSchema = exports.credalCallCopilotParamsSchema = exports.googlemapsNearbysearchRestaurantsOutputSchema = exports.googlemapsNearbysearchRestaurantsParamsSchema = exports.googlemapsValidateAddressOutputSchema = exports.googlemapsValidateAddressParamsSchema = exports.jiraCreateJiraTicketOutputSchema = exports.jiraCreateJiraTicketParamsSchema = exports.confluenceFetchPageContentOutputSchema = exports.confluenceFetchPageContentParamsSchema = exports.confluenceOverwritePageOutputSchema = exports.confluenceOverwritePageParamsSchema = exports.mathAddOutputSchema = exports.mathAddParamsSchema = exports.slackListConversationsOutputSchema = exports.slackListConversationsParamsSchema = exports.slackSendMessageOutputSchema = exports.slackSendMessageParamsSchema = exports.AuthParamsSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.AuthParamsSchema = zod_1.z.object({
6
6
  authToken: zod_1.z.string().optional(),
@@ -12,6 +12,8 @@ exports.AuthParamsSchema = zod_1.z.object({
12
12
  emailReplyTo: zod_1.z.string().optional(),
13
13
  emailBcc: zod_1.z.string().optional(),
14
14
  cloudId: zod_1.z.string().optional(),
15
+ awsAccessKeyId: zod_1.z.string().optional(),
16
+ awsSecretAccessKey: zod_1.z.string().optional(),
15
17
  });
16
18
  exports.slackSendMessageParamsSchema = zod_1.z.object({
17
19
  channelName: zod_1.z.string().describe("The name of the Slack channel to send the message to (e.g. general, alerts)"),
@@ -247,6 +249,24 @@ exports.snowflakeGetRowByFieldValueOutputSchema = zod_1.z.object({
247
249
  })
248
250
  .describe("The row from the Snowflake table"),
249
251
  });
252
+ exports.snowflakeRunSnowflakeQueryWriteResultsToS3ParamsSchema = zod_1.z.object({
253
+ databaseName: zod_1.z.string().describe("The name of the database to query"),
254
+ warehouse: zod_1.z.string().describe("The warehouse to use for executing the query"),
255
+ query: zod_1.z.string().describe("The SQL query to execute"),
256
+ user: zod_1.z.string().describe("The username to authenticate with"),
257
+ accountName: zod_1.z.string().describe("The name of the Snowflake account"),
258
+ s3BucketName: zod_1.z.string().describe("The name of the S3 bucket to write results to"),
259
+ s3Region: zod_1.z.string().describe("The AWS region where the S3 bucket is located"),
260
+ outputFormat: zod_1.z
261
+ .enum(["json", "csv"])
262
+ .describe("Format for the output file (json or csv, defaults to json)")
263
+ .optional(),
264
+ });
265
+ exports.snowflakeRunSnowflakeQueryWriteResultsToS3OutputSchema = zod_1.z.object({
266
+ bucketUrl: zod_1.z.string().describe("The URL of the S3 bucket where the results are stored"),
267
+ message: zod_1.z.string().describe("A message describing the result or error"),
268
+ rowCount: zod_1.z.number().describe("The number of rows returned by the query"),
269
+ });
250
270
  exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = zod_1.z.object({
251
271
  location: zod_1.z.string().describe("The location to get the latitude and longitude of"),
252
272
  });
@@ -39,9 +39,9 @@ exports.ACTION_GROUPS = {
39
39
  description: "Action for inserting a document into a MongoDB collection",
40
40
  actions: [templates_1.mongoInsertMongoDocDefinition],
41
41
  },
42
- SNOWFLAKE_GET_ROW_BY_FIELD_VALUE: {
43
- description: "Action for getting a row from a Snowflake table by field value",
44
- actions: [templates_1.snowflakeGetRowByFieldValueDefinition],
42
+ SNOWFLAKE_ACTIONS: {
43
+ description: "Action for getting content from a Snowflake table",
44
+ actions: [templates_1.snowflakeGetRowByFieldValueDefinition, templates_1.snowflakeRunSnowflakeQueryWriteResultsToS3Definition],
45
45
  },
46
46
  JIRA_CREATE_TICKET: {
47
47
  description: "Action for creating a Jira ticket",
@@ -49,6 +49,8 @@ z.object({
49
49
  emailReplyTo: z.string().optional(),
50
50
  emailBcc: z.string().optional(),
51
51
  cloudId: z.string().optional(),
52
+ awsAccessKeyId: z.string().optional(),
53
+ awsSecretAccessKey: z.string().optional(),
52
54
  })
53
55
  `;
54
56
  function validateObject(object) {
@@ -8,30 +8,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  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({
12
+ const axiosClient_1 = require("../../util/axiosClient");
13
+ function getConfluenceRequestConfig(baseUrl, username, apiToken) {
14
+ return {
18
15
  baseURL: baseUrl,
19
16
  headers: {
20
17
  Accept: "application/json",
21
- // Tokens are associated with a specific user.
22
18
  Authorization: `Basic ${Buffer.from(`${username}:${apiToken}`).toString("base64")}`,
23
19
  },
24
- });
25
- return api;
20
+ };
26
21
  }
27
22
  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);
23
+ const { pageId, content, title } = params;
24
+ const { baseUrl, authToken, username } = authParams;
25
+ if (!baseUrl || !authToken || !username) {
26
+ throw new Error("Missing required authentication information");
27
+ }
28
+ const config = getConfluenceRequestConfig(baseUrl, username, authToken);
31
29
  // Get current version number
32
- const response = yield api.get(`/api/v2/pages/${pageId}`);
30
+ const response = yield axiosClient_1.axiosClient.get(`/api/v2/pages/${pageId}`, config);
33
31
  const currVersion = response.data.version.number;
34
- yield api.put(`/api/v2/pages/${pageId}`, {
32
+ const payload = {
35
33
  id: pageId,
36
34
  status: "current",
37
35
  title,
@@ -42,6 +40,7 @@ const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* (
42
40
  version: {
43
41
  number: currVersion + 1,
44
42
  },
45
- });
43
+ };
44
+ yield axiosClient_1.axiosClient.put(`/api/v2/pages/${pageId}`, payload, config);
46
45
  });
47
46
  exports.default = confluenceUpdatePage;
@@ -0,0 +1,3 @@
1
+ import { googlemapsNearbysearchFunction } from "../../autogen/types";
2
+ declare const nearbysearch: googlemapsNearbysearchFunction;
3
+ export default nearbysearch;
@@ -0,0 +1,96 @@
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
+ const types_1 = require("../../autogen/types");
17
+ const INCLUDED_TYPES = [
18
+ "monument",
19
+ "museum",
20
+ "art_gallery",
21
+ "sculpture",
22
+ "cultural_landmark",
23
+ "historical_place",
24
+ "performing_arts_theater",
25
+ "university",
26
+ "aquarium",
27
+ "botanical_garden",
28
+ "comedy_club",
29
+ "park",
30
+ "movie_theater",
31
+ "national_park",
32
+ "garden",
33
+ "night_club",
34
+ "tourist_attraction",
35
+ "water_park",
36
+ "zoo",
37
+ "bar",
38
+ "restaurant",
39
+ "food_court",
40
+ "bakery",
41
+ "cafe",
42
+ "coffee_shop",
43
+ "pub",
44
+ "wine_bar",
45
+ "spa",
46
+ "beach",
47
+ "market",
48
+ "shopping_mall",
49
+ "stadium",
50
+ ];
51
+ const nearbysearch = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
52
+ const url = `https://places.googleapis.com/v1/places:searchNearby`;
53
+ const fieldMask = [
54
+ "places.displayName",
55
+ "places.formattedAddress",
56
+ "places.priceLevel",
57
+ "places.rating",
58
+ "places.primaryTypeDisplayName",
59
+ "places.editorialSummary",
60
+ "places.regularOpeningHours",
61
+ ].join(",");
62
+ const response = yield axios_1.default.post(url, {
63
+ maxResultCount: 20,
64
+ includedTypes: INCLUDED_TYPES,
65
+ locationRestriction: {
66
+ circle: {
67
+ center: {
68
+ latitude: params.latitude,
69
+ longitude: params.longitude,
70
+ },
71
+ radius: 10000,
72
+ },
73
+ },
74
+ }, {
75
+ headers: {
76
+ "X-Goog-Api-Key": authParams.apiKey,
77
+ "X-Goog-FieldMask": fieldMask,
78
+ "Content-Type": "application/json",
79
+ },
80
+ });
81
+ return types_1.googlemapsNearbysearchOutputSchema.parse({
82
+ results: response.data.places.map((place) => {
83
+ var _a, _b;
84
+ return ({
85
+ name: place.displayName.text,
86
+ address: place.formattedAddress,
87
+ priceLevel: place.priceLevel,
88
+ rating: place.rating,
89
+ primaryType: place.primaryTypeDisplayName.text,
90
+ editorialSummary: ((_a = place.editorialSummary) === null || _a === void 0 ? void 0 : _a.text) || "",
91
+ openingHours: ((_b = place.regularOpeningHours) === null || _b === void 0 ? void 0 : _b.weekdayDescriptions.join("\n")) || "",
92
+ });
93
+ }),
94
+ });
95
+ });
96
+ exports.default = nearbysearch;
@@ -0,0 +1,3 @@
1
+ import { snowflakeRunSnowflakeQueryWriteResultsToS3Function } from "../../autogen/types";
2
+ declare const runSnowflakeQueryWriteResultsToS3: snowflakeRunSnowflakeQueryWriteResultsToS3Function;
3
+ export default runSnowflakeQueryWriteResultsToS3;
@@ -0,0 +1,154 @@
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 snowflake_sdk_1 = __importDefault(require("snowflake-sdk"));
16
+ const crypto_1 = __importDefault(require("crypto"));
17
+ const client_s3_1 = require("@aws-sdk/client-s3");
18
+ const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
19
+ const uuid_1 = require("uuid");
20
+ // Only log errors.
21
+ snowflake_sdk_1.default.configure({ logLevel: "ERROR" });
22
+ const runSnowflakeQueryWriteResultsToS3 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
23
+ const { databaseName, warehouse, query, user, accountName, s3BucketName, s3Region, outputFormat = "json" } = params;
24
+ const { apiKey: privateKey, awsAccessKeyId, awsSecretAccessKey } = authParams;
25
+ if (!privateKey) {
26
+ throw new Error("Snowflake private key is required");
27
+ }
28
+ if (!awsAccessKeyId || !awsSecretAccessKey) {
29
+ throw new Error("AWS credentials are required");
30
+ }
31
+ if (!accountName || !user || !databaseName || !warehouse || !query || !s3BucketName) {
32
+ throw new Error("Missing required parameters for Snowflake query or S3 destination");
33
+ }
34
+ const getPrivateKeyCorrectFormat = (privateKey) => {
35
+ const buffer = Buffer.from(privateKey);
36
+ const privateKeyObject = crypto_1.default.createPrivateKey({
37
+ key: buffer,
38
+ format: "pem",
39
+ passphrase: "password",
40
+ });
41
+ const privateKeyCorrectFormat = privateKeyObject.export({
42
+ format: "pem",
43
+ type: "pkcs8",
44
+ });
45
+ return privateKeyCorrectFormat.toString();
46
+ };
47
+ const executeQueryAndFormatData = () => __awaiter(void 0, void 0, void 0, function* () {
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
+ const queryResults = yield new Promise((resolve, reject) => {
50
+ connection.execute({
51
+ sqlText: query,
52
+ complete: (err, stmt, rows) => {
53
+ if (err) {
54
+ return reject(err);
55
+ }
56
+ return resolve(rows || []);
57
+ },
58
+ });
59
+ });
60
+ // Format the results based on the output format
61
+ let formattedData;
62
+ if (outputFormat.toLowerCase() === "csv") {
63
+ if (queryResults.length === 0) {
64
+ formattedData = "";
65
+ }
66
+ else {
67
+ const headers = Object.keys(queryResults[0]).join(",");
68
+ const rows = queryResults.map(row => Object.values(row)
69
+ .map(value => (typeof value === "object" && value !== null ? JSON.stringify(value) : value))
70
+ .join(","));
71
+ formattedData = [headers, ...rows].join("\n");
72
+ }
73
+ }
74
+ else {
75
+ // Default to JSON
76
+ formattedData = JSON.stringify(queryResults, null, 2);
77
+ }
78
+ return { formattedData, resultsLength: queryResults.length };
79
+ });
80
+ const uploadToS3AndGetURL = (formattedData) => __awaiter(void 0, void 0, void 0, function* () {
81
+ // Create S3 client
82
+ const s3Client = new client_s3_1.S3Client({
83
+ region: s3Region,
84
+ credentials: {
85
+ accessKeyId: awsAccessKeyId,
86
+ secretAccessKey: awsSecretAccessKey,
87
+ },
88
+ });
89
+ const contentType = outputFormat.toLowerCase() === "csv" ? "text/csv" : "application/json";
90
+ const fileExtension = outputFormat.toLowerCase() === "csv" ? "csv" : "json";
91
+ const finalKey = `${databaseName}/${(0, uuid_1.v4)()}.${fileExtension}`;
92
+ // Upload to S3 without ACL
93
+ const uploadCommand = new client_s3_1.PutObjectCommand({
94
+ Bucket: s3BucketName,
95
+ Key: finalKey,
96
+ Body: formattedData,
97
+ ContentType: contentType,
98
+ });
99
+ yield s3Client.send(uploadCommand);
100
+ // Generate a presigned URL (valid for an hour)
101
+ const getObjectCommand = new client_s3_1.GetObjectCommand({
102
+ Bucket: s3BucketName,
103
+ Key: finalKey,
104
+ });
105
+ const presignedUrl = yield (0, s3_request_presigner_1.getSignedUrl)(s3Client, getObjectCommand, { expiresIn: 3600 });
106
+ return presignedUrl;
107
+ });
108
+ // Process the private key
109
+ const privateKeyCorrectFormatString = getPrivateKeyCorrectFormat(privateKey);
110
+ // Set up a connection using snowflake-sdk
111
+ const connection = snowflake_sdk_1.default.createConnection({
112
+ account: accountName,
113
+ username: user,
114
+ privateKey: privateKeyCorrectFormatString,
115
+ authenticator: "SNOWFLAKE_JWT",
116
+ role: "ACCOUNTADMIN",
117
+ warehouse: warehouse,
118
+ database: databaseName,
119
+ });
120
+ try {
121
+ // Connect to Snowflake
122
+ yield new Promise((resolve, reject) => {
123
+ connection.connect((err, conn) => {
124
+ if (err) {
125
+ console.error("Unable to connect to Snowflake:", err.message);
126
+ return reject(err);
127
+ }
128
+ resolve(conn);
129
+ });
130
+ });
131
+ const { formattedData, resultsLength } = yield executeQueryAndFormatData();
132
+ const presignedUrl = yield uploadToS3AndGetURL(formattedData);
133
+ // Return fields to match schema definition
134
+ connection.destroy(err => {
135
+ if (err) {
136
+ console.log("Failed to disconnect from Snowflake:", err);
137
+ }
138
+ });
139
+ return {
140
+ bucketUrl: presignedUrl,
141
+ message: `Query results successfully written to S3. URL valid for 1 hour.`,
142
+ rowCount: resultsLength,
143
+ };
144
+ }
145
+ catch (error) {
146
+ connection.destroy(err => {
147
+ if (err) {
148
+ console.log("Failed to disconnect from Snowflake:", err);
149
+ }
150
+ });
151
+ throw Error(`An error occurred: ${error}`);
152
+ }
153
+ });
154
+ exports.default = runSnowflakeQueryWriteResultsToS3;
@@ -0,0 +1,3 @@
1
+ import { xScrapePostDataWithNitterFunction } from "../../autogen/types";
2
+ declare const scrapeTweetDataWithNitter: xScrapePostDataWithNitterFunction;
3
+ export default scrapeTweetDataWithNitter;
@@ -0,0 +1,45 @@
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 firecrawl_js_1 = __importDefault(require("@mendable/firecrawl-js"));
16
+ const scrapeTweetDataWithNitter = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
17
+ const tweetUrlRegex = /^(?:https?:\/\/)?(?:www\.)?(?:twitter\.com|x\.com)\/([a-zA-Z0-9_]+)\/status\/(\d+)(?:\?.*)?$/;
18
+ if (!tweetUrlRegex.test(params.tweetUrl)) {
19
+ throw new Error("Invalid tweet URL. Expected format: https://twitter.com/username/status/id or https://x.com/username/status/id");
20
+ }
21
+ const nitterUrl = params.tweetUrl.replace(/^(?:https?:\/\/)?(?:www\.)?(?:twitter\.com|x\.com)/i, "https://nitter.net");
22
+ // Initialize Firecrawl
23
+ if (!authParams.apiKey) {
24
+ throw new Error("API key is required for X+Nitter+Firecrawl");
25
+ }
26
+ const firecrawl = new firecrawl_js_1.default({
27
+ apiKey: authParams.apiKey,
28
+ });
29
+ try {
30
+ // Scrape the Nitter URL
31
+ const result = yield firecrawl.scrapeUrl(nitterUrl);
32
+ if (!result.success) {
33
+ throw new Error(`Failed to scrape tweet: ${result.error || "Unknown error"}`);
34
+ }
35
+ // Extract the tweet text from the scraped content - simple approach - in practice, you might need more robust parsing based on nitter html structure
36
+ const tweetContent = result.markdown;
37
+ return {
38
+ text: tweetContent || "Error scraping with firecrawl",
39
+ };
40
+ }
41
+ catch (error) {
42
+ throw new Error(`Error scraping tweet: ${error instanceof Error ? error.message : error}`);
43
+ }
44
+ });
45
+ exports.default = scrapeTweetDataWithNitter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "AI Actions by Credal AI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -38,6 +38,7 @@
38
38
  "typescript-eslint": "^8.18.0"
39
39
  },
40
40
  "dependencies": {
41
+ "@aws-sdk/s3-request-presigner": "^3.758.0",
41
42
  "@credal/sdk": "^0.0.21",
42
43
  "@mendable/firecrawl-js": "^1.19.0",
43
44
  "@slack/web-api": "^7.8.0",
@@ -49,6 +50,7 @@
49
50
  "resend": "^4.1.2",
50
51
  "snowflake-sdk": "^2.0.2",
51
52
  "ts-node": "^10.9.2",
53
+ "uuid": "^11.1.0",
52
54
  "zod": "^3.24.1"
53
55
  }
54
56
  }
@@ -1,23 +0,0 @@
1
- declare const axios: any;
2
- declare const WORKDAY_BASE_URL = "https://your-workday-url/ccx/service/YOUR_TENANT/Absence_Management/v43.2";
3
- declare const TOKEN_URL = "https://your-workday-url/oauth2/YOUR_TENANT/token";
4
- declare const CLIENT_ID = "your-client-id";
5
- declare const CLIENT_SECRET = "your-client-secret";
6
- /**
7
- * Fetches an OAuth 2.0 access token from Workday.
8
- */
9
- declare function getAccessToken(): Promise<any>;
10
- /**
11
- * Submits a time-off request to Workday.
12
- * @param {Object} params - Time-off details.
13
- * @param {string} params.workerId - Worker's ID in Workday.
14
- * @param {string} params.startDate - Start date (YYYY-MM-DD).
15
- * @param {string} params.endDate - End date (YYYY-MM-DD).
16
- * @param {string} params.timeOffType - Time-off type (e.g., "SICK_LEAVE").
17
- */
18
- declare function submitTimeOff({ workerId, startDate, endDate, timeOffType }: {
19
- workerId: any;
20
- startDate: any;
21
- endDate: any;
22
- timeOffType: any;
23
- }): Promise<any>;
@@ -1,88 +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
- const axios = require("axios");
12
- const WORKDAY_BASE_URL = "https://your-workday-url/ccx/service/YOUR_TENANT/Absence_Management/v43.2";
13
- const TOKEN_URL = "https://your-workday-url/oauth2/YOUR_TENANT/token"; // OAuth token endpoint
14
- const CLIENT_ID = "your-client-id";
15
- const CLIENT_SECRET = "your-client-secret";
16
- /**
17
- * Fetches an OAuth 2.0 access token from Workday.
18
- */
19
- function getAccessToken() {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- var _a;
22
- try {
23
- const response = yield axios.post(TOKEN_URL, new URLSearchParams({ grant_type: "client_credentials" }), {
24
- auth: {
25
- username: CLIENT_ID,
26
- password: CLIENT_SECRET
27
- },
28
- headers: { "Content-Type": "application/x-www-form-urlencoded" }
29
- });
30
- return response.data.access_token;
31
- }
32
- catch (error) {
33
- console.error("Error fetching access token:", ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || error.message);
34
- throw error;
35
- }
36
- });
37
- }
38
- /**
39
- * Submits a time-off request to Workday.
40
- * @param {Object} params - Time-off details.
41
- * @param {string} params.workerId - Worker's ID in Workday.
42
- * @param {string} params.startDate - Start date (YYYY-MM-DD).
43
- * @param {string} params.endDate - End date (YYYY-MM-DD).
44
- * @param {string} params.timeOffType - Time-off type (e.g., "SICK_LEAVE").
45
- */
46
- function submitTimeOff(_a) {
47
- return __awaiter(this, arguments, void 0, function* ({ workerId, startDate, endDate, timeOffType }) {
48
- var _b;
49
- try {
50
- const token = yield getAccessToken(); // Get OAuth token
51
- const requestBody = {
52
- "wd:Enter_Time_Off_Request": {
53
- "wd:Worker_Reference": {
54
- "wd:ID": [{ "_": workerId, "$": { "wd:type": "WID" } }]
55
- },
56
- "wd:Time_Off_Entries": [
57
- {
58
- "wd:Start_Date": startDate,
59
- "wd:End_Date": endDate,
60
- "wd:Time_Off_Type_Reference": {
61
- "wd:ID": [{ "_": timeOffType, "$": { "wd:type": "Time_Off_Type_ID" } }]
62
- }
63
- }
64
- ]
65
- }
66
- };
67
- const response = yield axios.post(`${WORKDAY_BASE_URL}/Enter_Time_Off`, requestBody, {
68
- headers: {
69
- "Authorization": `Bearer ${token}`,
70
- "Content-Type": "application/json"
71
- }
72
- });
73
- console.log("Time-off request submitted successfully:", response.data);
74
- return response.data;
75
- }
76
- catch (error) {
77
- console.error("Error submitting time-off request:", ((_b = error.response) === null || _b === void 0 ? void 0 : _b.data) || error.message);
78
- throw error;
79
- }
80
- });
81
- }
82
- // Example Usage:
83
- submitTimeOff({
84
- workerId: "12345",
85
- startDate: "2025-03-10",
86
- endDate: "2025-03-12",
87
- timeOffType: "SICK_LEAVE"
88
- }).then(console.log).catch(console.error);