@credal/actions 0.1.15 → 0.1.16

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.
@@ -22,6 +22,8 @@ const scrapeUrl_1 = __importDefault(require("./providers/firecrawl/scrapeUrl"));
22
22
  const sendEmail_1 = __importDefault(require("./providers/resend/sendEmail"));
23
23
  const createSharePostLinkedinUrl_1 = __importDefault(require("./providers/linkedin/createSharePostLinkedinUrl"));
24
24
  const createNewGoogleDoc_1 = __importDefault(require("./providers/google-oauth/createNewGoogleDoc"));
25
+ const createXSharePostUrl_1 = __importDefault(require("./providers/x/createXSharePostUrl"));
26
+ const scrapeTweetDataWithNitter_1 = __importDefault(require("./providers/x/scrapeTweetDataWithNitter"));
25
27
  exports.ActionMapper = {
26
28
  math: {
27
29
  add: {
@@ -138,4 +140,16 @@ exports.ActionMapper = {
138
140
  outputSchema: types_1.googleOauthCreateNewGoogleDocOutputSchema,
139
141
  },
140
142
  },
143
+ x: {
144
+ createShareXPostUrl: {
145
+ fn: createXSharePostUrl_1.default,
146
+ paramsSchema: types_1.xCreateShareXPostUrlParamsSchema,
147
+ outputSchema: types_1.xCreateShareXPostUrlOutputSchema,
148
+ },
149
+ scrapePostDataWithNitter: {
150
+ fn: scrapeTweetDataWithNitter_1.default,
151
+ paramsSchema: types_1.xScrapePostDataWithNitterParamsSchema,
152
+ outputSchema: types_1.xScrapePostDataWithNitterOutputSchema,
153
+ },
154
+ },
141
155
  };
@@ -9,6 +9,8 @@ export declare const googlemapsNearbysearchRestaurantsDefinition: ActionTemplate
9
9
  export declare const credalCallCopilotDefinition: ActionTemplate;
10
10
  export declare const zendeskCreateZendeskTicketDefinition: ActionTemplate;
11
11
  export declare const linkedinCreateShareLinkedinPostUrlDefinition: ActionTemplate;
12
+ export declare const xCreateShareXPostUrlDefinition: ActionTemplate;
13
+ export declare const xScrapePostDataWithNitterDefinition: ActionTemplate;
12
14
  export declare const mongoInsertMongoDocDefinition: ActionTemplate;
13
15
  export declare const snowflakeGetRowByFieldValueDefinition: ActionTemplate;
14
16
  export declare const openstreetmapGetLatitudeLongitudeFromLocationDefinition: ActionTemplate;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.googleOauthCreateNewGoogleDocDefinition = exports.resendSendEmailDefinition = exports.firecrawlScrapeUrlDefinition = exports.nwsGetForecastForLocationDefinition = exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = exports.snowflakeGetRowByFieldValueDefinition = exports.mongoInsertMongoDocDefinition = exports.linkedinCreateShareLinkedinPostUrlDefinition = exports.zendeskCreateZendeskTicketDefinition = exports.credalCallCopilotDefinition = exports.googlemapsNearbysearchRestaurantsDefinition = exports.googlemapsValidateAddressDefinition = exports.jiraCreateJiraTicketDefinition = exports.confluenceUpdatePageDefinition = exports.mathAddDefinition = exports.slackListConversationsDefinition = exports.slackSendMessageDefinition = void 0;
3
+ exports.googleOauthCreateNewGoogleDocDefinition = exports.resendSendEmailDefinition = exports.firecrawlScrapeUrlDefinition = exports.nwsGetForecastForLocationDefinition = exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = exports.snowflakeGetRowByFieldValueDefinition = exports.mongoInsertMongoDocDefinition = exports.xScrapePostDataWithNitterDefinition = exports.xCreateShareXPostUrlDefinition = exports.linkedinCreateShareLinkedinPostUrlDefinition = exports.zendeskCreateZendeskTicketDefinition = exports.credalCallCopilotDefinition = exports.googlemapsNearbysearchRestaurantsDefinition = exports.googlemapsValidateAddressDefinition = exports.jiraCreateJiraTicketDefinition = exports.confluenceUpdatePageDefinition = 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"],
@@ -504,6 +504,77 @@ exports.linkedinCreateShareLinkedinPostUrlDefinition = {
504
504
  name: "createShareLinkedinPostUrl",
505
505
  provider: "linkedin",
506
506
  };
507
+ exports.xCreateShareXPostUrlDefinition = {
508
+ description: "Create a share X (formerly twitter) post link",
509
+ scopes: [],
510
+ parameters: {
511
+ type: "object",
512
+ required: ["text"],
513
+ properties: {
514
+ text: {
515
+ type: "string",
516
+ description: "The text for the X(formerly twitter) post",
517
+ },
518
+ url: {
519
+ type: "string",
520
+ description: "The url for the X(formerly twitter) post",
521
+ },
522
+ hashtag: {
523
+ type: "array",
524
+ description: "List of hashtags to include in the X post",
525
+ items: {
526
+ type: "string",
527
+ },
528
+ },
529
+ via: {
530
+ type: "string",
531
+ description: "The twitter username to associate with the tweet",
532
+ },
533
+ inReplyTo: {
534
+ type: "string",
535
+ description: "The tweet ID to reply to",
536
+ },
537
+ },
538
+ },
539
+ output: {
540
+ type: "object",
541
+ required: ["xUrl"],
542
+ properties: {
543
+ xUrl: {
544
+ type: "string",
545
+ description: "The share post X(formerly twitter) URL",
546
+ },
547
+ },
548
+ },
549
+ name: "createShareXPostUrl",
550
+ provider: "x",
551
+ };
552
+ exports.xScrapePostDataWithNitterDefinition = {
553
+ description: "Given A tweet URL scrape the tweet data with nitter+firecrawl",
554
+ scopes: [],
555
+ parameters: {
556
+ type: "object",
557
+ required: ["tweetUrl"],
558
+ properties: {
559
+ tweetUrl: {
560
+ type: "string",
561
+ description: "The url for the X(formerly twitter) post",
562
+ },
563
+ },
564
+ },
565
+ output: {
566
+ type: "object",
567
+ required: ["text"],
568
+ properties: {
569
+ text: {
570
+ type: "string",
571
+ description: "The text in the tweet URL",
572
+ },
573
+ },
574
+ },
575
+ name: "scrapePostDataWithNitter",
576
+ provider: "x",
577
+ };
507
578
  exports.mongoInsertMongoDocDefinition = {
508
579
  description: "Insert a document into a MongoDB collection",
509
580
  scopes: [],
@@ -513,6 +513,52 @@ export declare const linkedinCreateShareLinkedinPostUrlOutputSchema: z.ZodObject
513
513
  }>;
514
514
  export type linkedinCreateShareLinkedinPostUrlOutputType = z.infer<typeof linkedinCreateShareLinkedinPostUrlOutputSchema>;
515
515
  export type linkedinCreateShareLinkedinPostUrlFunction = ActionFunction<linkedinCreateShareLinkedinPostUrlParamsType, AuthParamsType, linkedinCreateShareLinkedinPostUrlOutputType>;
516
+ export declare const xCreateShareXPostUrlParamsSchema: z.ZodObject<{
517
+ text: z.ZodString;
518
+ url: z.ZodOptional<z.ZodString>;
519
+ hashtag: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
520
+ via: z.ZodOptional<z.ZodString>;
521
+ inReplyTo: z.ZodOptional<z.ZodString>;
522
+ }, "strip", z.ZodTypeAny, {
523
+ text: string;
524
+ url?: string | undefined;
525
+ hashtag?: string[] | undefined;
526
+ via?: string | undefined;
527
+ inReplyTo?: string | undefined;
528
+ }, {
529
+ text: string;
530
+ url?: string | undefined;
531
+ hashtag?: string[] | undefined;
532
+ via?: string | undefined;
533
+ inReplyTo?: string | undefined;
534
+ }>;
535
+ export type xCreateShareXPostUrlParamsType = z.infer<typeof xCreateShareXPostUrlParamsSchema>;
536
+ export declare const xCreateShareXPostUrlOutputSchema: z.ZodObject<{
537
+ xUrl: z.ZodString;
538
+ }, "strip", z.ZodTypeAny, {
539
+ xUrl: string;
540
+ }, {
541
+ xUrl: string;
542
+ }>;
543
+ export type xCreateShareXPostUrlOutputType = z.infer<typeof xCreateShareXPostUrlOutputSchema>;
544
+ export type xCreateShareXPostUrlFunction = ActionFunction<xCreateShareXPostUrlParamsType, AuthParamsType, xCreateShareXPostUrlOutputType>;
545
+ export declare const xScrapePostDataWithNitterParamsSchema: z.ZodObject<{
546
+ tweetUrl: z.ZodString;
547
+ }, "strip", z.ZodTypeAny, {
548
+ tweetUrl: string;
549
+ }, {
550
+ tweetUrl: string;
551
+ }>;
552
+ export type xScrapePostDataWithNitterParamsType = z.infer<typeof xScrapePostDataWithNitterParamsSchema>;
553
+ export declare const xScrapePostDataWithNitterOutputSchema: z.ZodObject<{
554
+ text: z.ZodString;
555
+ }, "strip", z.ZodTypeAny, {
556
+ text: string;
557
+ }, {
558
+ text: string;
559
+ }>;
560
+ export type xScrapePostDataWithNitterOutputType = z.infer<typeof xScrapePostDataWithNitterOutputSchema>;
561
+ export type xScrapePostDataWithNitterFunction = ActionFunction<xScrapePostDataWithNitterParamsType, AuthParamsType, xScrapePostDataWithNitterOutputType>;
516
562
  export declare const mongoInsertMongoDocParamsSchema: z.ZodObject<{
517
563
  databaseName: z.ZodString;
518
564
  collectionName: z.ZodString;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.googleOauthCreateNewGoogleDocOutputSchema = exports.googleOauthCreateNewGoogleDocParamsSchema = exports.resendSendEmailOutputSchema = exports.resendSendEmailParamsSchema = exports.firecrawlScrapeUrlOutputSchema = exports.firecrawlScrapeUrlParamsSchema = exports.nwsGetForecastForLocationOutputSchema = exports.nwsGetForecastForLocationParamsSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = exports.snowflakeGetRowByFieldValueOutputSchema = exports.snowflakeGetRowByFieldValueParamsSchema = exports.mongoInsertMongoDocOutputSchema = exports.mongoInsertMongoDocParamsSchema = 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.confluenceUpdatePageOutputSchema = exports.confluenceUpdatePageParamsSchema = exports.mathAddOutputSchema = exports.mathAddParamsSchema = exports.slackListConversationsOutputSchema = exports.slackListConversationsParamsSchema = exports.slackSendMessageOutputSchema = exports.slackSendMessageParamsSchema = exports.AuthParamsSchema = void 0;
3
+ exports.googleOauthCreateNewGoogleDocOutputSchema = exports.googleOauthCreateNewGoogleDocParamsSchema = exports.resendSendEmailOutputSchema = exports.resendSendEmailParamsSchema = exports.firecrawlScrapeUrlOutputSchema = exports.firecrawlScrapeUrlParamsSchema = exports.nwsGetForecastForLocationOutputSchema = exports.nwsGetForecastForLocationParamsSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = exports.snowflakeGetRowByFieldValueOutputSchema = exports.snowflakeGetRowByFieldValueParamsSchema = exports.mongoInsertMongoDocOutputSchema = exports.mongoInsertMongoDocParamsSchema = exports.xScrapePostDataWithNitterOutputSchema = exports.xScrapePostDataWithNitterParamsSchema = 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.confluenceUpdatePageOutputSchema = exports.confluenceUpdatePageParamsSchema = 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(),
@@ -158,6 +158,22 @@ exports.linkedinCreateShareLinkedinPostUrlParamsSchema = zod_1.z.object({
158
158
  exports.linkedinCreateShareLinkedinPostUrlOutputSchema = zod_1.z.object({
159
159
  linkedinUrl: zod_1.z.string().describe("The share post linkedin URL"),
160
160
  });
161
+ exports.xCreateShareXPostUrlParamsSchema = zod_1.z.object({
162
+ text: zod_1.z.string().describe("The text for the X(formerly twitter) post"),
163
+ url: zod_1.z.string().describe("The url for the X(formerly twitter) post").optional(),
164
+ hashtag: zod_1.z.array(zod_1.z.string()).describe("List of hashtags to include in the X post").optional(),
165
+ via: zod_1.z.string().describe("The twitter username to associate with the tweet").optional(),
166
+ inReplyTo: zod_1.z.string().describe("The tweet ID to reply to").optional(),
167
+ });
168
+ exports.xCreateShareXPostUrlOutputSchema = zod_1.z.object({
169
+ xUrl: zod_1.z.string().describe("The share post X(formerly twitter) URL"),
170
+ });
171
+ exports.xScrapePostDataWithNitterParamsSchema = zod_1.z.object({
172
+ tweetUrl: zod_1.z.string().describe("The url for the X(formerly twitter) post"),
173
+ });
174
+ exports.xScrapePostDataWithNitterOutputSchema = zod_1.z.object({
175
+ text: zod_1.z.string().describe("The text in the tweet URL"),
176
+ });
161
177
  exports.mongoInsertMongoDocParamsSchema = zod_1.z.object({
162
178
  databaseName: zod_1.z.string().describe("Database to connect to"),
163
179
  collectionName: zod_1.z.string().describe("Collection to insert the document into"),
@@ -63,4 +63,8 @@ exports.ACTION_GROUPS = {
63
63
  description: "Action for sending an email",
64
64
  actions: [templates_1.resendSendEmailDefinition],
65
65
  },
66
+ X: {
67
+ description: "Actions for interacting with X(formerly twitter)",
68
+ actions: [templates_1.xCreateShareXPostUrlDefinition, templates_1.xScrapePostDataWithNitterDefinition],
69
+ },
66
70
  };
@@ -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 { xCreateShareXPostUrlFunction } from "../../autogen/types";
2
+ declare const createXSharePostUrl: xCreateShareXPostUrlFunction;
3
+ export default createXSharePostUrl;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const createXSharePostUrl = ({ params, }) => {
4
+ const baseUrl = "https://twitter.com/intent/tweet";
5
+ const queryParams = new URLSearchParams();
6
+ // Add text parameter (required) with encoding
7
+ if (params.text) {
8
+ queryParams.append("text", params.text + "\n");
9
+ }
10
+ // Add url parameter if it exists
11
+ if (params.url) {
12
+ queryParams.append("url", params.url);
13
+ }
14
+ // Add hashtags parameter if it exists
15
+ if (params.hashtag && params.hashtag.length > 0) {
16
+ queryParams.append("hashtags", params.hashtag.join(","));
17
+ }
18
+ // Add via parameter if it exists
19
+ if (params.via) {
20
+ queryParams.append("via", params.via);
21
+ }
22
+ // Add in_reply_to parameter if it exists
23
+ if (params.inReplyTo) {
24
+ queryParams.append("in_reply_to", params.inReplyTo);
25
+ }
26
+ // Build the final URL
27
+ const shareUrl = queryParams.toString() ? `${baseUrl}?${queryParams.toString()}` : baseUrl;
28
+ return Promise.resolve({
29
+ xUrl: shareUrl,
30
+ });
31
+ };
32
+ exports.default = createXSharePostUrl;
@@ -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.15",
3
+ "version": "0.1.16",
4
4
  "description": "AI Actions by Credal AI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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);