@credal/actions 0.1.25 → 0.1.27
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/actionMapper.js +5 -5
- package/dist/actions/autogen/templates.d.ts +1 -1
- package/dist/actions/autogen/templates.js +9 -21
- package/dist/actions/autogen/types.d.ts +14 -17
- package/dist/actions/autogen/types.js +7 -11
- package/dist/actions/groups.js +1 -1
- package/dist/actions/parse.js +2 -0
- package/dist/actions/providers/confluence/updatePage.js +15 -14
- package/dist/actions/providers/snowflake/runSnowflakeQuery.d.ts +3 -0
- package/dist/actions/providers/snowflake/{runSnowflakeQueryWriteResultsToS3.js → runSnowflakeQuery.js} +8 -44
- package/dist/actions/providers/workday/requestTimeOff.d.ts +23 -0
- package/dist/actions/providers/workday/requestTimeOff.js +88 -0
- package/package.json +1 -3
- package/dist/actions/providers/googlemaps/nearbysearch.d.ts +0 -3
- package/dist/actions/providers/googlemaps/nearbysearch.js +0 -96
- package/dist/actions/providers/snowflake/runSnowflakeQueryWriteResultsToS3.d.ts +0 -3
- package/dist/actions/providers/x/scrapeTweetDataWithNitter.d.ts +0 -3
- package/dist/actions/providers/x/scrapeTweetDataWithNitter.js +0 -45
@@ -27,7 +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
|
30
|
+
const runSnowflakeQuery_1 = __importDefault(require("./providers/snowflake/runSnowflakeQuery"));
|
31
31
|
exports.ActionMapper = {
|
32
32
|
math: {
|
33
33
|
add: {
|
@@ -99,10 +99,10 @@ exports.ActionMapper = {
|
|
99
99
|
paramsSchema: types_1.snowflakeGetRowByFieldValueParamsSchema,
|
100
100
|
outputSchema: types_1.snowflakeGetRowByFieldValueOutputSchema,
|
101
101
|
},
|
102
|
-
|
103
|
-
fn:
|
104
|
-
paramsSchema: types_1.
|
105
|
-
outputSchema: types_1.
|
102
|
+
runSnowflakeQuery: {
|
103
|
+
fn: runSnowflakeQuery_1.default,
|
104
|
+
paramsSchema: types_1.snowflakeRunSnowflakeQueryParamsSchema,
|
105
|
+
outputSchema: types_1.snowflakeRunSnowflakeQueryOutputSchema,
|
106
106
|
},
|
107
107
|
},
|
108
108
|
linkedin: {
|
@@ -13,7 +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
|
16
|
+
export declare const snowflakeRunSnowflakeQueryDefinition: ActionTemplate;
|
17
17
|
export declare const openstreetmapGetLatitudeLongitudeFromLocationDefinition: ActionTemplate;
|
18
18
|
export declare const nwsGetForecastForLocationDefinition: ActionTemplate;
|
19
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.
|
3
|
+
exports.finnhubGetBasicFinancialsDefinition = exports.finnhubSymbolLookupDefinition = exports.googleOauthCreateNewGoogleDocDefinition = exports.resendSendEmailDefinition = exports.firecrawlScrapeTweetDataWithNitterDefinition = exports.firecrawlScrapeUrlDefinition = exports.nwsGetForecastForLocationDefinition = exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = exports.snowflakeRunSnowflakeQueryDefinition = 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,12 +773,12 @@ exports.snowflakeGetRowByFieldValueDefinition = {
|
|
773
773
|
name: "getRowByFieldValue",
|
774
774
|
provider: "snowflake",
|
775
775
|
};
|
776
|
-
exports.
|
777
|
-
description: "Execute a Snowflake query and
|
776
|
+
exports.snowflakeRunSnowflakeQueryDefinition = {
|
777
|
+
description: "Execute a Snowflake query and return output.",
|
778
778
|
scopes: [],
|
779
779
|
parameters: {
|
780
780
|
type: "object",
|
781
|
-
required: ["databaseName", "warehouse", "query", "user", "accountName"
|
781
|
+
required: ["databaseName", "warehouse", "query", "user", "accountName"],
|
782
782
|
properties: {
|
783
783
|
databaseName: {
|
784
784
|
type: "string",
|
@@ -800,32 +800,20 @@ exports.snowflakeRunSnowflakeQueryWriteResultsToS3Definition = {
|
|
800
800
|
type: "string",
|
801
801
|
description: "The name of the Snowflake account",
|
802
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
803
|
outputFormat: {
|
812
804
|
type: "string",
|
813
|
-
description: "
|
805
|
+
description: "The format of the output",
|
814
806
|
enum: ["json", "csv"],
|
815
807
|
},
|
816
808
|
},
|
817
809
|
},
|
818
810
|
output: {
|
819
811
|
type: "object",
|
820
|
-
required: ["
|
812
|
+
required: ["content", "rowCount"],
|
821
813
|
properties: {
|
822
|
-
|
823
|
-
type: "string",
|
824
|
-
description: "The URL of the S3 bucket where the results are stored",
|
825
|
-
},
|
826
|
-
message: {
|
814
|
+
content: {
|
827
815
|
type: "string",
|
828
|
-
description: "
|
816
|
+
description: "The content of the query result (json)",
|
829
817
|
},
|
830
818
|
rowCount: {
|
831
819
|
type: "number",
|
@@ -833,7 +821,7 @@ exports.snowflakeRunSnowflakeQueryWriteResultsToS3Definition = {
|
|
833
821
|
},
|
834
822
|
},
|
835
823
|
},
|
836
|
-
name: "
|
824
|
+
name: "runSnowflakeQuery",
|
837
825
|
provider: "snowflake",
|
838
826
|
};
|
839
827
|
exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = {
|
@@ -13,9 +13,12 @@ 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
|
+
subdomain: z.ZodOptional<z.ZodString>;
|
17
|
+
password: z.ZodOptional<z.ZodString>;
|
16
18
|
awsAccessKeyId: z.ZodOptional<z.ZodString>;
|
17
19
|
awsSecretAccessKey: z.ZodOptional<z.ZodString>;
|
18
20
|
}, "strip", z.ZodTypeAny, {
|
21
|
+
subdomain?: string | undefined;
|
19
22
|
authToken?: string | undefined;
|
20
23
|
baseUrl?: string | undefined;
|
21
24
|
apiKey?: string | undefined;
|
@@ -25,9 +28,11 @@ export declare const AuthParamsSchema: z.ZodObject<{
|
|
25
28
|
emailReplyTo?: string | undefined;
|
26
29
|
emailBcc?: string | undefined;
|
27
30
|
cloudId?: string | undefined;
|
31
|
+
password?: string | undefined;
|
28
32
|
awsAccessKeyId?: string | undefined;
|
29
33
|
awsSecretAccessKey?: string | undefined;
|
30
34
|
}, {
|
35
|
+
subdomain?: string | undefined;
|
31
36
|
authToken?: string | undefined;
|
32
37
|
baseUrl?: string | undefined;
|
33
38
|
apiKey?: string | undefined;
|
@@ -37,6 +42,7 @@ export declare const AuthParamsSchema: z.ZodObject<{
|
|
37
42
|
emailReplyTo?: string | undefined;
|
38
43
|
emailBcc?: string | undefined;
|
39
44
|
cloudId?: string | undefined;
|
45
|
+
password?: string | undefined;
|
40
46
|
awsAccessKeyId?: string | undefined;
|
41
47
|
awsSecretAccessKey?: string | undefined;
|
42
48
|
}>;
|
@@ -769,14 +775,12 @@ export declare const snowflakeGetRowByFieldValueOutputSchema: z.ZodObject<{
|
|
769
775
|
}>;
|
770
776
|
export type snowflakeGetRowByFieldValueOutputType = z.infer<typeof snowflakeGetRowByFieldValueOutputSchema>;
|
771
777
|
export type snowflakeGetRowByFieldValueFunction = ActionFunction<snowflakeGetRowByFieldValueParamsType, AuthParamsType, snowflakeGetRowByFieldValueOutputType>;
|
772
|
-
export declare const
|
778
|
+
export declare const snowflakeRunSnowflakeQueryParamsSchema: z.ZodObject<{
|
773
779
|
databaseName: z.ZodString;
|
774
780
|
warehouse: z.ZodString;
|
775
781
|
query: z.ZodString;
|
776
782
|
user: z.ZodString;
|
777
783
|
accountName: z.ZodString;
|
778
|
-
s3BucketName: z.ZodString;
|
779
|
-
s3Region: z.ZodString;
|
780
784
|
outputFormat: z.ZodOptional<z.ZodEnum<["json", "csv"]>>;
|
781
785
|
}, "strip", z.ZodTypeAny, {
|
782
786
|
query: string;
|
@@ -784,8 +788,6 @@ export declare const snowflakeRunSnowflakeQueryWriteResultsToS3ParamsSchema: z.Z
|
|
784
788
|
accountName: string;
|
785
789
|
user: string;
|
786
790
|
warehouse: string;
|
787
|
-
s3BucketName: string;
|
788
|
-
s3Region: string;
|
789
791
|
outputFormat?: "json" | "csv" | undefined;
|
790
792
|
}, {
|
791
793
|
query: string;
|
@@ -793,26 +795,21 @@ export declare const snowflakeRunSnowflakeQueryWriteResultsToS3ParamsSchema: z.Z
|
|
793
795
|
accountName: string;
|
794
796
|
user: string;
|
795
797
|
warehouse: string;
|
796
|
-
s3BucketName: string;
|
797
|
-
s3Region: string;
|
798
798
|
outputFormat?: "json" | "csv" | undefined;
|
799
799
|
}>;
|
800
|
-
export type
|
801
|
-
export declare const
|
802
|
-
|
803
|
-
message: z.ZodString;
|
800
|
+
export type snowflakeRunSnowflakeQueryParamsType = z.infer<typeof snowflakeRunSnowflakeQueryParamsSchema>;
|
801
|
+
export declare const snowflakeRunSnowflakeQueryOutputSchema: z.ZodObject<{
|
802
|
+
content: z.ZodString;
|
804
803
|
rowCount: z.ZodNumber;
|
805
804
|
}, "strip", z.ZodTypeAny, {
|
806
|
-
|
807
|
-
bucketUrl: string;
|
805
|
+
content: string;
|
808
806
|
rowCount: number;
|
809
807
|
}, {
|
810
|
-
|
811
|
-
bucketUrl: string;
|
808
|
+
content: string;
|
812
809
|
rowCount: number;
|
813
810
|
}>;
|
814
|
-
export type
|
815
|
-
export type
|
811
|
+
export type snowflakeRunSnowflakeQueryOutputType = z.infer<typeof snowflakeRunSnowflakeQueryOutputSchema>;
|
812
|
+
export type snowflakeRunSnowflakeQueryFunction = ActionFunction<snowflakeRunSnowflakeQueryParamsType, AuthParamsType, snowflakeRunSnowflakeQueryOutputType>;
|
816
813
|
export declare const openstreetmapGetLatitudeLongitudeFromLocationParamsSchema: z.ZodObject<{
|
817
814
|
location: z.ZodString;
|
818
815
|
}, "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.
|
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.snowflakeRunSnowflakeQueryOutputSchema = exports.snowflakeRunSnowflakeQueryParamsSchema = 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
|
+
subdomain: zod_1.z.string().optional(),
|
16
|
+
password: zod_1.z.string().optional(),
|
15
17
|
awsAccessKeyId: zod_1.z.string().optional(),
|
16
18
|
awsSecretAccessKey: zod_1.z.string().optional(),
|
17
19
|
});
|
@@ -249,22 +251,16 @@ exports.snowflakeGetRowByFieldValueOutputSchema = zod_1.z.object({
|
|
249
251
|
})
|
250
252
|
.describe("The row from the Snowflake table"),
|
251
253
|
});
|
252
|
-
exports.
|
254
|
+
exports.snowflakeRunSnowflakeQueryParamsSchema = zod_1.z.object({
|
253
255
|
databaseName: zod_1.z.string().describe("The name of the database to query"),
|
254
256
|
warehouse: zod_1.z.string().describe("The warehouse to use for executing the query"),
|
255
257
|
query: zod_1.z.string().describe("The SQL query to execute"),
|
256
258
|
user: zod_1.z.string().describe("The username to authenticate with"),
|
257
259
|
accountName: zod_1.z.string().describe("The name of the Snowflake account"),
|
258
|
-
|
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(),
|
260
|
+
outputFormat: zod_1.z.enum(["json", "csv"]).describe("The format of the output").optional(),
|
264
261
|
});
|
265
|
-
exports.
|
266
|
-
|
267
|
-
message: zod_1.z.string().describe("A message describing the result or error"),
|
262
|
+
exports.snowflakeRunSnowflakeQueryOutputSchema = zod_1.z.object({
|
263
|
+
content: zod_1.z.string().describe("The content of the query result (json)"),
|
268
264
|
rowCount: zod_1.z.number().describe("The number of rows returned by the query"),
|
269
265
|
});
|
270
266
|
exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = zod_1.z.object({
|
package/dist/actions/groups.js
CHANGED
@@ -41,7 +41,7 @@ exports.ACTION_GROUPS = {
|
|
41
41
|
},
|
42
42
|
SNOWFLAKE_ACTIONS: {
|
43
43
|
description: "Action for getting content from a Snowflake table",
|
44
|
-
actions: [templates_1.snowflakeGetRowByFieldValueDefinition, templates_1.
|
44
|
+
actions: [templates_1.snowflakeGetRowByFieldValueDefinition, templates_1.snowflakeRunSnowflakeQueryDefinition],
|
45
45
|
},
|
46
46
|
JIRA_CREATE_TICKET: {
|
47
47
|
description: "Action for creating a Jira ticket",
|
package/dist/actions/parse.js
CHANGED
@@ -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
|
+
subdomain: z.string().optional(),
|
53
|
+
password: z.string().optional(),
|
52
54
|
awsAccessKeyId: z.string().optional(),
|
53
55
|
awsSecretAccessKey: z.string().optional(),
|
54
56
|
})
|
@@ -8,28 +8,30 @@ 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
|
+
};
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
const
|
13
|
-
function
|
14
|
-
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
16
|
+
function getConfluenceApi(baseUrl, username, apiToken) {
|
17
|
+
const api = axios_1.default.create({
|
15
18
|
baseURL: baseUrl,
|
16
19
|
headers: {
|
17
20
|
Accept: "application/json",
|
21
|
+
// Tokens are associated with a specific user.
|
18
22
|
Authorization: `Basic ${Buffer.from(`${username}:${apiToken}`).toString("base64")}`,
|
19
23
|
},
|
20
|
-
};
|
24
|
+
});
|
25
|
+
return api;
|
21
26
|
}
|
22
27
|
const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
23
|
-
const { pageId, content, title } = params;
|
24
|
-
const { baseUrl, authToken
|
25
|
-
|
26
|
-
throw new Error("Missing required authentication information");
|
27
|
-
}
|
28
|
-
const config = getConfluenceRequestConfig(baseUrl, username, authToken);
|
28
|
+
const { pageId, username, content, title } = params;
|
29
|
+
const { baseUrl, authToken } = authParams;
|
30
|
+
const api = getConfluenceApi(baseUrl, username, authToken);
|
29
31
|
// Get current version number
|
30
|
-
const response = yield
|
32
|
+
const response = yield api.get(`/api/v2/pages/${pageId}`);
|
31
33
|
const currVersion = response.data.version.number;
|
32
|
-
|
34
|
+
yield api.put(`/api/v2/pages/${pageId}`, {
|
33
35
|
id: pageId,
|
34
36
|
status: "current",
|
35
37
|
title,
|
@@ -40,7 +42,6 @@ const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* (
|
|
40
42
|
version: {
|
41
43
|
number: currVersion + 1,
|
42
44
|
},
|
43
|
-
};
|
44
|
-
yield axiosClient_1.axiosClient.put(`/api/v2/pages/${pageId}`, payload, config);
|
45
|
+
});
|
45
46
|
});
|
46
47
|
exports.default = confluenceUpdatePage;
|
@@ -14,22 +14,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
const snowflake_sdk_1 = __importDefault(require("snowflake-sdk"));
|
16
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
17
|
// Only log errors.
|
21
18
|
snowflake_sdk_1.default.configure({ logLevel: "ERROR" });
|
22
|
-
const
|
23
|
-
const { databaseName, warehouse, query, user, accountName,
|
24
|
-
const { apiKey: privateKey
|
19
|
+
const runSnowflakeQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
20
|
+
const { databaseName, warehouse, query, user, accountName, outputFormat = "json" } = params;
|
21
|
+
const { apiKey: privateKey } = authParams;
|
25
22
|
if (!privateKey) {
|
26
23
|
throw new Error("Snowflake private key is required");
|
27
24
|
}
|
28
|
-
if (!
|
29
|
-
throw new Error("
|
30
|
-
}
|
31
|
-
if (!accountName || !user || !databaseName || !warehouse || !query || !s3BucketName) {
|
32
|
-
throw new Error("Missing required parameters for Snowflake query or S3 destination");
|
25
|
+
if (!accountName || !user || !databaseName || !warehouse || !query) {
|
26
|
+
throw new Error("Missing required parameters for Snowflake query");
|
33
27
|
}
|
34
28
|
const getPrivateKeyCorrectFormat = (privateKey) => {
|
35
29
|
const buffer = Buffer.from(privateKey);
|
@@ -73,38 +67,10 @@ const runSnowflakeQueryWriteResultsToS3 = (_a) => __awaiter(void 0, [_a], void 0
|
|
73
67
|
}
|
74
68
|
else {
|
75
69
|
// Default to JSON
|
76
|
-
formattedData = JSON.stringify(queryResults,
|
70
|
+
formattedData = JSON.stringify(queryResults).replace(/\s+/g, "");
|
77
71
|
}
|
78
72
|
return { formattedData, resultsLength: queryResults.length };
|
79
73
|
});
|
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
74
|
// Process the private key
|
109
75
|
const privateKeyCorrectFormatString = getPrivateKeyCorrectFormat(privateKey);
|
110
76
|
// Set up a connection using snowflake-sdk
|
@@ -129,7 +95,6 @@ const runSnowflakeQueryWriteResultsToS3 = (_a) => __awaiter(void 0, [_a], void 0
|
|
129
95
|
});
|
130
96
|
});
|
131
97
|
const { formattedData, resultsLength } = yield executeQueryAndFormatData();
|
132
|
-
const presignedUrl = yield uploadToS3AndGetURL(formattedData);
|
133
98
|
// Return fields to match schema definition
|
134
99
|
connection.destroy(err => {
|
135
100
|
if (err) {
|
@@ -137,9 +102,8 @@ const runSnowflakeQueryWriteResultsToS3 = (_a) => __awaiter(void 0, [_a], void 0
|
|
137
102
|
}
|
138
103
|
});
|
139
104
|
return {
|
140
|
-
bucketUrl: presignedUrl,
|
141
|
-
message: `Query results successfully written to S3. URL valid for 1 hour.`,
|
142
105
|
rowCount: resultsLength,
|
106
|
+
content: formattedData,
|
143
107
|
};
|
144
108
|
}
|
145
109
|
catch (error) {
|
@@ -151,4 +115,4 @@ const runSnowflakeQueryWriteResultsToS3 = (_a) => __awaiter(void 0, [_a], void 0
|
|
151
115
|
throw Error(`An error occurred: ${error}`);
|
152
116
|
}
|
153
117
|
});
|
154
|
-
exports.default =
|
118
|
+
exports.default = runSnowflakeQuery;
|
@@ -0,0 +1,23 @@
|
|
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>;
|
@@ -0,0 +1,88 @@
|
|
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);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@credal/actions",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.27",
|
4
4
|
"description": "AI Actions by Credal AI",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -38,7 +38,6 @@
|
|
38
38
|
"typescript-eslint": "^8.18.0"
|
39
39
|
},
|
40
40
|
"dependencies": {
|
41
|
-
"@aws-sdk/s3-request-presigner": "^3.758.0",
|
42
41
|
"@credal/sdk": "^0.0.21",
|
43
42
|
"@mendable/firecrawl-js": "^1.19.0",
|
44
43
|
"@slack/web-api": "^7.8.0",
|
@@ -50,7 +49,6 @@
|
|
50
49
|
"resend": "^4.1.2",
|
51
50
|
"snowflake-sdk": "^2.0.2",
|
52
51
|
"ts-node": "^10.9.2",
|
53
|
-
"uuid": "^11.1.0",
|
54
52
|
"zod": "^3.24.1"
|
55
53
|
}
|
56
54
|
}
|
@@ -1,96 +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
|
-
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;
|
@@ -1,45 +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 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;
|