@credal/actions 0.1.14 → 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.
- package/dist/actions/actionMapper.js +14 -0
- package/dist/actions/autogen/templates.d.ts +2 -0
- package/dist/actions/autogen/templates.js +72 -1
- package/dist/actions/autogen/types.d.ts +46 -0
- package/dist/actions/autogen/types.js +17 -1
- package/dist/actions/groups.js +4 -0
- package/dist/actions/providers/credal/callCopilot.js +3 -1
- package/dist/actions/providers/x/createXSharePostUrl.d.ts +3 -0
- package/dist/actions/providers/x/createXSharePostUrl.js +32 -0
- package/dist/actions/providers/x/scrapeTweetDataWithNitter.d.ts +3 -0
- package/dist/actions/providers/x/scrapeTweetDataWithNitter.js +45 -0
- package/package.json +1 -1
@@ -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"),
|
package/dist/actions/groups.js
CHANGED
@@ -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
|
};
|
@@ -11,12 +11,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
const sdk_1 = require("@credal/sdk");
|
13
13
|
const callCopilot = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
14
|
+
var _b;
|
14
15
|
const requestBody = {
|
15
16
|
agentId: params.agentId,
|
16
17
|
query: params.query,
|
17
18
|
userEmail: params.userEmail,
|
18
19
|
};
|
19
|
-
const
|
20
|
+
const baseUrl = (_b = authParams.baseUrl) !== null && _b !== void 0 ? _b : "https://app.credal.ai/api";
|
21
|
+
const client = new sdk_1.CredalClient({ environment: baseUrl, apiKey: authParams.apiKey });
|
20
22
|
const response = yield client.copilots.sendMessage({
|
21
23
|
agentId: requestBody.agentId,
|
22
24
|
message: requestBody.query,
|
@@ -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,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;
|