@credal/actions 0.2.197 → 0.2.199
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 +8 -1
- package/dist/actions/autogen/templates.d.ts +1 -0
- package/dist/actions/autogen/templates.js +79 -18
- package/dist/actions/autogen/types.d.ts +39 -0
- package/dist/actions/autogen/types.js +43 -8
- package/dist/actions/groups.js +4 -1
- package/dist/actions/invoke.js +11 -22
- package/dist/actions/parse.js +231 -244
- package/dist/actions/providers/asana/commentAsanaTask.js +8 -15
- package/dist/actions/providers/asana/createAsanaTask.js +20 -21
- package/dist/actions/providers/asana/getTasksDetails.js +18 -34
- package/dist/actions/providers/asana/listAsanaTasksByProject.js +62 -79
- package/dist/actions/providers/asana/searchAsanaTasks.js +6 -16
- package/dist/actions/providers/asana/updateAsanaTask.js +16 -15
- package/dist/actions/providers/asana/utils.js +47 -64
- package/dist/actions/providers/bing/getTopNSearchResultUrls.js +4 -14
- package/dist/actions/providers/confluence/fetchPageContent.js +5 -15
- package/dist/actions/providers/confluence/overwritePage.js +5 -14
- package/dist/actions/providers/finnhub/getBasicFinancials.js +7 -19
- package/dist/actions/providers/finnhub/symbolLookup.js +3 -12
- package/dist/actions/providers/firecrawl/deepResearch.js +11 -21
- package/dist/actions/providers/firecrawl/getTopNSearchResultUrls.js +8 -21
- package/dist/actions/providers/firecrawl/scrapeTweetDataWithNitter.js +4 -13
- package/dist/actions/providers/firecrawl/scrapeUrl.js +16 -21
- package/dist/actions/providers/firecrawl/searchAndScrape.js +6 -17
- package/dist/actions/providers/generic/fillTemplate.js +2 -11
- package/dist/actions/providers/github/createBranch.js +9 -18
- package/dist/actions/providers/github/createOrUpdateFile.js +6 -15
- package/dist/actions/providers/github/createPullRequest.js +5 -14
- package/dist/actions/providers/github/fetchFile.d.ts +3 -0
- package/dist/actions/providers/github/fetchFile.js +131 -0
- package/dist/actions/providers/github/getBranch.js +4 -13
- package/dist/actions/providers/github/getContents.d.ts +3 -0
- package/dist/actions/providers/github/getContents.js +41 -0
- package/dist/actions/providers/github/getFileContent.js +6 -16
- package/dist/actions/providers/github/getPullRequestDetails.js +39 -18
- package/dist/actions/providers/github/listCommits.js +17 -15
- package/dist/actions/providers/github/listDirectory.js +13 -25
- package/dist/actions/providers/github/listPullRequests.js +4 -13
- package/dist/actions/providers/github/searchOrganization.js +29 -49
- package/dist/actions/providers/github/utils.js +5 -16
- package/dist/actions/providers/gitlab/getFileContent.js +13 -24
- package/dist/actions/providers/gitlab/getMergeRequest.js +18 -30
- package/dist/actions/providers/gitlab/listDirectory.js +15 -27
- package/dist/actions/providers/gitlab/searchGroup.js +45 -52
- package/dist/actions/providers/gitlab/utils.js +19 -32
- package/dist/actions/providers/google-oauth/addGroupMember.js +3 -12
- package/dist/actions/providers/google-oauth/addTextToTopOfDoc.js +3 -12
- package/dist/actions/providers/google-oauth/appendRowsToSpreadsheet.js +4 -13
- package/dist/actions/providers/google-oauth/createNewGoogleDoc.js +7 -17
- package/dist/actions/providers/google-oauth/createPresentation.js +7 -13
- package/dist/actions/providers/google-oauth/createSpreadsheet.js +7 -13
- package/dist/actions/providers/google-oauth/deleteCalendarEvent.js +3 -12
- package/dist/actions/providers/google-oauth/deleteGroupMember.js +3 -12
- package/dist/actions/providers/google-oauth/deleteRowFromSpreadsheet.js +3 -12
- package/dist/actions/providers/google-oauth/editAGoogleCalendarEvent.js +4 -14
- package/dist/actions/providers/google-oauth/getDriveFileContentById.js +23 -33
- package/dist/actions/providers/google-oauth/getGroup.js +3 -12
- package/dist/actions/providers/google-oauth/getPresentation.js +23 -37
- package/dist/actions/providers/google-oauth/hasGroupMember.js +3 -12
- package/dist/actions/providers/google-oauth/listCalendarEvents.js +27 -21
- package/dist/actions/providers/google-oauth/listCalendars.js +4 -14
- package/dist/actions/providers/google-oauth/listGroupMembers.js +4 -13
- package/dist/actions/providers/google-oauth/listGroups.js +4 -14
- package/dist/actions/providers/google-oauth/queryGoogleBigQuery.js +10 -21
- package/dist/actions/providers/google-oauth/scheduleCalendarMeeting.js +11 -14
- package/dist/actions/providers/google-oauth/searchDriveByKeywords.js +3 -12
- package/dist/actions/providers/google-oauth/searchDriveByKeywordsAndGetFileContent.js +12 -23
- package/dist/actions/providers/google-oauth/searchDriveByQuery.js +30 -42
- package/dist/actions/providers/google-oauth/searchDriveByQueryAndGetFileContent.js +9 -20
- package/dist/actions/providers/google-oauth/updateCalendarEvent.js +3 -12
- package/dist/actions/providers/google-oauth/updateDoc.js +3 -12
- package/dist/actions/providers/google-oauth/updatePresentation.js +3 -12
- package/dist/actions/providers/google-oauth/updateRowsInSpreadsheet.js +4 -13
- package/dist/actions/providers/google-oauth/updateSpreadsheet.js +3 -12
- package/dist/actions/providers/google-oauth/utils/decodeMessage.js +7 -8
- package/dist/actions/providers/googleSearch/customSearch.js +18 -36
- package/dist/actions/providers/googlemail/listGmailThreads.js +7 -16
- package/dist/actions/providers/googlemail/replyToGmail.d.ts +3 -0
- package/dist/actions/providers/googlemail/replyToGmail.js +89 -0
- package/dist/actions/providers/googlemail/searchGmailMessages.js +10 -20
- package/dist/actions/providers/googlemail/sendGmail.js +7 -17
- package/dist/actions/providers/googlemaps/nearbysearchRestaurants.js +13 -25
- package/dist/actions/providers/googlemaps/validateAddress.js +3 -12
- package/dist/actions/providers/hubspot/getCompanies.js +4 -14
- package/dist/actions/providers/hubspot/getCompanyDetails.js +3 -12
- package/dist/actions/providers/hubspot/getContactDetails.js +3 -12
- package/dist/actions/providers/hubspot/getContacts.js +4 -14
- package/dist/actions/providers/hubspot/getDealDetails.js +3 -12
- package/dist/actions/providers/hubspot/getDeals.js +3 -12
- package/dist/actions/providers/hubspot/getTicketDetails.js +3 -12
- package/dist/actions/providers/hubspot/getTickets.js +3 -12
- package/dist/actions/providers/jira/assignJiraTicket.js +4 -13
- package/dist/actions/providers/jira/commentJiraTicket.js +3 -12
- package/dist/actions/providers/jira/createJiraTicket.js +22 -18
- package/dist/actions/providers/jira/createServiceDeskRequest.js +3 -12
- package/dist/actions/providers/jira/getJiraDCIssuesByQuery.js +5 -14
- package/dist/actions/providers/jira/getJiraIssuesByQuery.js +19 -29
- package/dist/actions/providers/jira/getJiraTicketDetails.js +3 -12
- package/dist/actions/providers/jira/getJiraTicketHistory.js +3 -12
- package/dist/actions/providers/jira/moveJiraTicketToProject.js +11 -21
- package/dist/actions/providers/jira/publicCommentOnServiceDeskRequest.js +3 -12
- package/dist/actions/providers/jira/updateJiraTicketDetails.js +15 -15
- package/dist/actions/providers/jira/updateJiraTicketStatus.js +4 -13
- package/dist/actions/providers/jira/utils.js +104 -126
- package/dist/actions/providers/linear/getIssueDetails.js +10 -20
- package/dist/actions/providers/linear/getIssues.js +11 -21
- package/dist/actions/providers/linear/getProjectDetails.js +10 -20
- package/dist/actions/providers/linear/getProjects.js +6 -16
- package/dist/actions/providers/linear/getTeamDetails.js +7 -17
- package/dist/actions/providers/linear/getTeams.js +5 -15
- package/dist/actions/providers/looker/enableUserByEmail.js +5 -14
- package/dist/actions/providers/math/add.js +2 -11
- package/dist/actions/providers/microsoft/createDocument.js +4 -13
- package/dist/actions/providers/microsoft/getDocument.js +4 -13
- package/dist/actions/providers/microsoft/messageTeamsChannel.js +4 -13
- package/dist/actions/providers/microsoft/messageTeamsChat.js +4 -13
- package/dist/actions/providers/microsoft/updateDocument.js +4 -13
- package/dist/actions/providers/microsoft/updateSpreadsheet.js +4 -13
- package/dist/actions/providers/microsoft/utils.js +9 -20
- package/dist/actions/providers/mongodb/insertMongoDoc.js +5 -14
- package/dist/actions/providers/notion/searchByTitle.js +3 -12
- package/dist/actions/providers/nws/getForecastForLocation.js +4 -13
- package/dist/actions/providers/oktaOrg/getOktaUserByName.js +3 -12
- package/dist/actions/providers/openstreetmap/getLatitudeLongitudeFromLocation.js +3 -12
- package/dist/actions/providers/perplexity/perplexityDeepResearch.js +11 -21
- package/dist/actions/providers/resend/sendEmail.js +3 -12
- package/dist/actions/providers/resend/sendEmailHtml.js +3 -12
- package/dist/actions/providers/salesforce/createCase.js +10 -13
- package/dist/actions/providers/salesforce/createRecord.js +3 -12
- package/dist/actions/providers/salesforce/executeReport.js +3 -12
- package/dist/actions/providers/salesforce/generateSalesReport.js +3 -12
- package/dist/actions/providers/salesforce/getRecord.js +3 -12
- package/dist/actions/providers/salesforce/getReportMetadata.js +11 -21
- package/dist/actions/providers/salesforce/getSalesforceRecordsByQuery.js +7 -17
- package/dist/actions/providers/salesforce/listReports.js +3 -12
- package/dist/actions/providers/salesforce/searchAllSalesforceRecords.js +3 -12
- package/dist/actions/providers/salesforce/searchSalesforceRecords.js +3 -12
- package/dist/actions/providers/salesforce/updateRecord.js +3 -12
- package/dist/actions/providers/slack/archiveChannel.js +9 -2
- package/dist/actions/providers/slack/createChannel.js +7 -17
- package/dist/actions/providers/slack/getChannelMembers.js +8 -18
- package/dist/actions/providers/slack/getChannelMessages.js +8 -18
- package/dist/actions/providers/slack/helpers.js +16 -47
- package/dist/actions/providers/slack/messageTransformers.js +10 -13
- package/dist/actions/providers/slack/sendDmFromBot.js +9 -19
- package/dist/actions/providers/slack/sendMessage.js +7 -17
- package/dist/actions/providers/slackUser/searchSlack.js +179 -212
- package/dist/actions/providers/slackUser/searchSlackRTS.js +20 -33
- package/dist/actions/providers/slackUser/utils.js +1 -1
- package/dist/actions/providers/snowflake/auth/getSnowflakeConnection.js +23 -34
- package/dist/actions/providers/snowflake/getRowByFieldValue.js +4 -13
- package/dist/actions/providers/snowflake/runSnowflakeQuery.js +9 -19
- package/dist/actions/providers/zendesk/addCommentToTicket.js +5 -14
- package/dist/actions/providers/zendesk/assignTicket.js +3 -12
- package/dist/actions/providers/zendesk/createZendeskTicket.js +3 -12
- package/dist/actions/providers/zendesk/getTicketDetails.js +3 -12
- package/dist/actions/providers/zendesk/listTickets.js +3 -12
- package/dist/actions/providers/zendesk/searchZendeskByQuery.js +3 -12
- package/dist/actions/providers/zendesk/updateTicketStatus.js +3 -12
- package/dist/actions/util/axiosClient.js +5 -5
- package/dist/app.js +14 -25
- package/dist/utils/google.js +122 -143
- package/dist/utils/pdf.js +10 -21
- package/package.json +10 -9
- package/dist/actions/providers/credal/callCopilot.d.ts +0 -3
- package/dist/actions/providers/credal/callCopilot.js +0 -36
- package/dist/actions/providers/math/index.d.ts +0 -1
- package/dist/actions/providers/math/index.js +0 -37
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.d.ts +0 -3
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.js +0 -43
- package/dist/actions/providers/slack/index.d.ts +0 -1
- package/dist/actions/providers/slack/index.js +0 -37
- package/dist/actions/providers/slack/listConversations.d.ts +0 -3
- package/dist/actions/providers/slack/listConversations.js +0 -41
|
@@ -1,30 +1,18 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { finnhubGetBasicFinancialsOutputSchema } from "../../autogen/types.js";
|
|
11
2
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
12
3
|
function transformData(data) {
|
|
13
4
|
return Object.entries(data).map(([key, value]) => ({
|
|
14
5
|
metric: key,
|
|
15
|
-
series: value.map(item => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
v: (_a = item.v) !== null && _a !== void 0 ? _a : undefined,
|
|
20
|
-
});
|
|
21
|
-
}),
|
|
6
|
+
series: value.map(item => ({
|
|
7
|
+
period: item.period,
|
|
8
|
+
v: item.v ?? undefined,
|
|
9
|
+
})),
|
|
22
10
|
}));
|
|
23
11
|
}
|
|
24
|
-
const getBasicFinancials =
|
|
12
|
+
const getBasicFinancials = async ({ params, authParams, }) => {
|
|
25
13
|
try {
|
|
26
14
|
const apiKey = authParams.apiKey;
|
|
27
|
-
const result =
|
|
15
|
+
const result = await axiosClient.get(`https://finnhub.io/api/v1/stock/metric?symbol=${params.symbol}`, {
|
|
28
16
|
headers: {
|
|
29
17
|
"X-Finnhub-Token": apiKey,
|
|
30
18
|
},
|
|
@@ -42,5 +30,5 @@ const getBasicFinancials = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
42
30
|
result: {},
|
|
43
31
|
});
|
|
44
32
|
}
|
|
45
|
-
}
|
|
33
|
+
};
|
|
46
34
|
export default getBasicFinancials;
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { finnhubSymbolLookupOutputSchema } from "../../autogen/types.js";
|
|
11
2
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
12
|
-
const symbolLookup =
|
|
3
|
+
const symbolLookup = async ({ params, authParams, }) => {
|
|
13
4
|
try {
|
|
14
5
|
const apiKey = authParams.apiKey;
|
|
15
|
-
const result =
|
|
6
|
+
const result = await axiosClient.get(`https://finnhub.io/api/v1/search?q=${params.query}`, {
|
|
16
7
|
headers: {
|
|
17
8
|
"X-Finnhub-Token": apiKey,
|
|
18
9
|
},
|
|
@@ -27,5 +18,5 @@ const symbolLookup = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params
|
|
|
27
18
|
result: [],
|
|
28
19
|
});
|
|
29
20
|
}
|
|
30
|
-
}
|
|
21
|
+
};
|
|
31
22
|
export default symbolLookup;
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { firecrawlDeepResearchOutputSchema } from "../../autogen/types.js";
|
|
12
3
|
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
13
|
-
const deepResearch =
|
|
14
|
-
var _b, _c, _d;
|
|
4
|
+
const deepResearch = async ({ params, authParams, }) => {
|
|
15
5
|
const { query, maxDepth, maxUrls, timeLimit } = params;
|
|
16
6
|
const { apiKey } = authParams;
|
|
17
7
|
if (!apiKey)
|
|
18
8
|
throw new Error("Missing Firecrawl API key");
|
|
19
9
|
const headers = { Authorization: `Bearer ${apiKey}` };
|
|
20
10
|
// 1) Kick off job
|
|
21
|
-
const start =
|
|
22
|
-
if (!
|
|
11
|
+
const start = await axiosClient.post("https://api.firecrawl.dev/v1/deep-research", { query, maxDepth, maxUrls, timeLimit }, { headers });
|
|
12
|
+
if (!start.data?.id) {
|
|
23
13
|
throw new Error(`Failed to start deep research (no job id). HTTP ${start.status}`);
|
|
24
14
|
}
|
|
25
15
|
const researchJobId = start.data.id;
|
|
@@ -27,24 +17,24 @@ const deepResearch = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params
|
|
|
27
17
|
const pollUrl = `https://api.firecrawl.dev/v1/deep-research/${researchJobId}`;
|
|
28
18
|
let intervalMs = 1000; // start at 1s
|
|
29
19
|
const maxIntervalMs = 5000; // cap at 5s
|
|
30
|
-
const maxWaitMs = (typeof timeLimit === "number" && timeLimit > 0 ? timeLimit : 60) * 1000 +
|
|
20
|
+
const maxWaitMs = (typeof timeLimit === "number" && timeLimit > 0 ? timeLimit : 60) * 1000 + 15_000; // timeLimit + 15s buffer
|
|
31
21
|
const deadline = Date.now() + maxWaitMs;
|
|
32
22
|
while (true) {
|
|
33
|
-
const res =
|
|
23
|
+
const res = await axiosClient.get(pollUrl, { headers });
|
|
34
24
|
const data = res.data;
|
|
35
|
-
if (!
|
|
25
|
+
if (!data?.status) {
|
|
36
26
|
// Defensive: transient bad payload
|
|
37
27
|
if (Date.now() > deadline)
|
|
38
28
|
throw new Error("Deep research polling timed out (no status).");
|
|
39
|
-
|
|
29
|
+
await sleep(intervalMs);
|
|
40
30
|
intervalMs = Math.min(Math.floor(intervalMs * 1.5), maxIntervalMs);
|
|
41
31
|
continue;
|
|
42
32
|
}
|
|
43
33
|
if (data.status === "completed") {
|
|
44
34
|
// Validate + return
|
|
45
35
|
return firecrawlDeepResearchOutputSchema.parse({
|
|
46
|
-
finalAnalysis:
|
|
47
|
-
sources:
|
|
36
|
+
finalAnalysis: data.finalAnalysis ?? "",
|
|
37
|
+
sources: data.sources ?? [],
|
|
48
38
|
});
|
|
49
39
|
}
|
|
50
40
|
if (data.status === "failed" || data.status === "cancelled") {
|
|
@@ -54,8 +44,8 @@ const deepResearch = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params
|
|
|
54
44
|
if (Date.now() > deadline) {
|
|
55
45
|
throw new Error("Deep research polling timed out.");
|
|
56
46
|
}
|
|
57
|
-
|
|
47
|
+
await sleep(intervalMs);
|
|
58
48
|
intervalMs = Math.min(Math.floor(intervalMs * 1.5), maxIntervalMs);
|
|
59
49
|
}
|
|
60
|
-
}
|
|
50
|
+
};
|
|
61
51
|
export default deepResearch;
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import FirecrawlApp from "@mendable/firecrawl-js";
|
|
11
2
|
// NOTE: authParams.apiKey should now be your FIRECRAWL API key.
|
|
12
|
-
const getTopNSearchResultUrls =
|
|
13
|
-
var _b;
|
|
3
|
+
const getTopNSearchResultUrls = async ({ params, authParams, }) => {
|
|
14
4
|
const { query, count = 5, site } = params;
|
|
15
5
|
const { apiKey } = authParams;
|
|
16
6
|
if (!apiKey) {
|
|
@@ -21,21 +11,18 @@ const getTopNSearchResultUrls = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
21
11
|
try {
|
|
22
12
|
const app = new FirecrawlApp({ apiKey });
|
|
23
13
|
// Firecrawl search (no scraping needed for URL list)
|
|
24
|
-
const res =
|
|
14
|
+
const res = await app.search(searchQuery, { limit: count });
|
|
25
15
|
// Map Firecrawl results into a Bing-like shape your schema expects
|
|
26
|
-
const webResults = (
|
|
27
|
-
const results = webResults.map(r => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
url: r.url,
|
|
32
|
-
});
|
|
33
|
-
});
|
|
16
|
+
const webResults = (res.web ?? []);
|
|
17
|
+
const results = webResults.map(r => ({
|
|
18
|
+
name: r.title ?? r.url,
|
|
19
|
+
url: r.url,
|
|
20
|
+
}));
|
|
34
21
|
return { results };
|
|
35
22
|
}
|
|
36
23
|
catch (error) {
|
|
37
24
|
console.error("Error fetching search results from Firecrawl:", error);
|
|
38
25
|
throw error;
|
|
39
26
|
}
|
|
40
|
-
}
|
|
27
|
+
};
|
|
41
28
|
export default getTopNSearchResultUrls;
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import FirecrawlApp from "@mendable/firecrawl-js";
|
|
11
2
|
import { MISSING_API_KEY } from "../../util/missingAuthConstants.js";
|
|
12
|
-
const scrapeTweetDataWithNitter =
|
|
3
|
+
const scrapeTweetDataWithNitter = async ({ params, authParams, }) => {
|
|
13
4
|
const tweetUrlRegex = /^(?:https?:\/\/)?(?:www\.)?(?:twitter\.com|x\.com)\/([a-zA-Z0-9_]+)\/status\/(\d+)(?:\?.*)?$/;
|
|
14
5
|
if (!tweetUrlRegex.test(params.tweetUrl)) {
|
|
15
6
|
throw new Error("Invalid tweet URL. Expected format: https://twitter.com/username/status/id or https://x.com/username/status/id");
|
|
@@ -25,7 +16,7 @@ const scrapeTweetDataWithNitter = (_a) => __awaiter(void 0, [_a], void 0, functi
|
|
|
25
16
|
try {
|
|
26
17
|
// Scrape the Nitter URL
|
|
27
18
|
// @ts-expect-error zeroDataRetention is not specified in the firecrawl types
|
|
28
|
-
const result =
|
|
19
|
+
const result = await firecrawl.scrape(nitterUrl, { zeroDataRetention: true });
|
|
29
20
|
// Extract the tweet text from the scraped content - simple approach - in practice, you might need more robust parsing based on nitter html structure
|
|
30
21
|
const tweetContent = result.markdown;
|
|
31
22
|
return {
|
|
@@ -33,7 +24,7 @@ const scrapeTweetDataWithNitter = (_a) => __awaiter(void 0, [_a], void 0, functi
|
|
|
33
24
|
};
|
|
34
25
|
}
|
|
35
26
|
catch (error) {
|
|
36
|
-
throw new Error(`Error scraping tweet: ${error instanceof Error ? error.message : error}
|
|
27
|
+
throw new Error(`Error scraping tweet: ${error instanceof Error ? error.message : error}`, { cause: error });
|
|
37
28
|
}
|
|
38
|
-
}
|
|
29
|
+
};
|
|
39
30
|
export default scrapeTweetDataWithNitter;
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import FirecrawlApp from "@mendable/firecrawl-js";
|
|
11
|
-
const scrapeUrl =
|
|
12
|
-
var _b, _c;
|
|
2
|
+
const scrapeUrl = async ({ params, authParams, }) => {
|
|
13
3
|
const firecrawl = new FirecrawlApp({
|
|
14
4
|
apiKey: authParams.apiKey,
|
|
15
5
|
});
|
|
16
|
-
const result =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
const result = await firecrawl.scrape(params.url, {
|
|
7
|
+
...(params.waitMs !== undefined && {
|
|
8
|
+
actions: [{ type: "wait", milliseconds: params.waitMs }],
|
|
9
|
+
}),
|
|
10
|
+
...(params.onlyMainContent !== undefined && {
|
|
11
|
+
onlyMainContent: params.onlyMainContent,
|
|
12
|
+
}),
|
|
13
|
+
...(params.formats !== undefined &&
|
|
14
|
+
params.formats.length > 0 && {
|
|
15
|
+
formats: params.formats,
|
|
16
|
+
}),
|
|
17
|
+
zeroDataRetention: true,
|
|
18
|
+
});
|
|
24
19
|
// Extract content based on requested formats
|
|
25
20
|
let content = "";
|
|
26
21
|
if (params.formats && params.formats.length > 0) {
|
|
@@ -65,11 +60,11 @@ const scrapeUrl = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, a
|
|
|
65
60
|
success: true,
|
|
66
61
|
results: [
|
|
67
62
|
{
|
|
68
|
-
name:
|
|
63
|
+
name: result.metadata?.title ?? "Untitled",
|
|
69
64
|
url: params.url,
|
|
70
65
|
contents: content,
|
|
71
66
|
},
|
|
72
67
|
],
|
|
73
68
|
};
|
|
74
|
-
}
|
|
69
|
+
};
|
|
75
70
|
export default scrapeUrl;
|
|
@@ -1,42 +1,31 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import FirecrawlApp from "@mendable/firecrawl-js";
|
|
11
|
-
const searchAndScrape =
|
|
12
|
-
var _b;
|
|
2
|
+
const searchAndScrape = async ({ params, authParams, }) => {
|
|
13
3
|
const { apiKey } = authParams;
|
|
14
4
|
if (!apiKey)
|
|
15
5
|
throw new Error("Missing Firecrawl API key");
|
|
16
6
|
const app = new FirecrawlApp({ apiKey });
|
|
17
7
|
const { query, count = 5, site } = params;
|
|
18
8
|
const searchQuery = `${query}${site ? ` site:${site}` : ""}`;
|
|
19
|
-
const searchRes =
|
|
9
|
+
const searchRes = await app.search(searchQuery, {
|
|
20
10
|
limit: count,
|
|
21
11
|
scrapeOptions: {
|
|
22
12
|
formats: ["markdown"],
|
|
23
13
|
timeout: 7500,
|
|
24
14
|
},
|
|
25
15
|
});
|
|
26
|
-
const webResults = (
|
|
16
|
+
const webResults = (searchRes.web ?? []);
|
|
27
17
|
const results = webResults
|
|
28
18
|
.map(r => {
|
|
29
|
-
|
|
30
|
-
const url = (_a = r.metadata) === null || _a === void 0 ? void 0 : _a.url;
|
|
19
|
+
const url = r.metadata?.url;
|
|
31
20
|
const contents = r.markdown;
|
|
32
|
-
const title =
|
|
21
|
+
const title = r.metadata?.title ?? null;
|
|
33
22
|
if (!url || !contents || !title)
|
|
34
23
|
return undefined;
|
|
35
24
|
return { url, title, contents };
|
|
36
25
|
})
|
|
37
26
|
.filter(NotEmpty);
|
|
38
27
|
return { results };
|
|
39
|
-
}
|
|
28
|
+
};
|
|
40
29
|
export default searchAndScrape;
|
|
41
30
|
function NotEmpty(value) {
|
|
42
31
|
return value !== null && value !== undefined;
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
const fillTemplate = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, }) {
|
|
1
|
+
const fillTemplate = async ({ params, }) => {
|
|
11
2
|
return {
|
|
12
3
|
result: params.template,
|
|
13
4
|
};
|
|
14
|
-
}
|
|
5
|
+
};
|
|
15
6
|
export default fillTemplate;
|
|
@@ -1,40 +1,31 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
11
2
|
import { getOctokit } from "./utils.js";
|
|
12
3
|
/**
|
|
13
4
|
* Creates a new branch in a GitHub repository
|
|
14
5
|
*/
|
|
15
|
-
const createBranch =
|
|
6
|
+
const createBranch = async ({ params, authParams, }) => {
|
|
16
7
|
if (!authParams.authToken) {
|
|
17
8
|
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
18
9
|
}
|
|
19
|
-
const octokit =
|
|
20
|
-
const { RequestError } =
|
|
10
|
+
const octokit = await getOctokit(authParams.authToken);
|
|
11
|
+
const { RequestError } = await import("@octokit/request-error");
|
|
21
12
|
const { repositoryOwner, repositoryName, branchName, baseRefOrHash } = params;
|
|
22
13
|
try {
|
|
23
14
|
// Get the reference or commit SHA for the base branch or tag
|
|
24
|
-
const { data: baseRefData } =
|
|
15
|
+
const { data: baseRefData } = await octokit.rest.git
|
|
25
16
|
.getRef({
|
|
26
17
|
owner: repositoryOwner,
|
|
27
18
|
repo: repositoryName,
|
|
28
19
|
ref: baseRefOrHash,
|
|
29
20
|
})
|
|
30
|
-
.catch((error) =>
|
|
21
|
+
.catch(async (error) => {
|
|
31
22
|
if (error.status === 404 && /^[a-f0-9]{40}$/i.test(baseRefOrHash)) {
|
|
32
23
|
// If baseRef is a full commit SHA and not a ref, use it directly
|
|
33
24
|
return { data: { object: { sha: baseRefOrHash } } };
|
|
34
25
|
}
|
|
35
26
|
else if (error.status === 404 && /^[a-f0-9]{7,39}$/i.test(baseRefOrHash)) {
|
|
36
27
|
// If baseRef is a short commit SHA, try to resolve it to a full SHA
|
|
37
|
-
const { data: commits } =
|
|
28
|
+
const { data: commits } = await octokit.rest.repos.listCommits({
|
|
38
29
|
owner: repositoryOwner,
|
|
39
30
|
repo: repositoryName,
|
|
40
31
|
sha: baseRefOrHash,
|
|
@@ -45,9 +36,9 @@ const createBranch = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params
|
|
|
45
36
|
}
|
|
46
37
|
}
|
|
47
38
|
throw error;
|
|
48
|
-
})
|
|
39
|
+
});
|
|
49
40
|
// Create a new branch from the base reference
|
|
50
|
-
|
|
41
|
+
await octokit.rest.git.createRef({
|
|
51
42
|
owner: repositoryOwner,
|
|
52
43
|
repo: repositoryName,
|
|
53
44
|
ref: `refs/heads/${branchName}`,
|
|
@@ -63,5 +54,5 @@ const createBranch = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params
|
|
|
63
54
|
console.error("Unexpected error:", error);
|
|
64
55
|
return { success: false, error: error instanceof Error ? error.message : "An unexpected error occurred" };
|
|
65
56
|
}
|
|
66
|
-
}
|
|
57
|
+
};
|
|
67
58
|
export default createBranch;
|
|
@@ -1,29 +1,20 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { z } from "zod";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
3
|
import { getOctokit } from "./utils.js";
|
|
13
4
|
/**
|
|
14
5
|
* Creates or updates a file in a GitHub repository
|
|
15
6
|
*/
|
|
16
|
-
const createOrUpdateFile =
|
|
7
|
+
const createOrUpdateFile = async ({ params, authParams, }) => {
|
|
17
8
|
if (!authParams.authToken) {
|
|
18
9
|
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
19
10
|
}
|
|
20
|
-
const octokit =
|
|
21
|
-
const { RequestError } =
|
|
11
|
+
const octokit = await getOctokit(authParams.authToken);
|
|
12
|
+
const { RequestError } = await import("@octokit/request-error");
|
|
22
13
|
const { repositoryOwner, repositoryName, filePath, branch, fileContent, commitMessage } = params;
|
|
23
14
|
let fileSha = undefined;
|
|
24
15
|
let operationPreformed = undefined;
|
|
25
16
|
try {
|
|
26
|
-
const { data: fileData } =
|
|
17
|
+
const { data: fileData } = await octokit.rest.repos.getContent({
|
|
27
18
|
owner: repositoryOwner,
|
|
28
19
|
repo: repositoryName,
|
|
29
20
|
path: filePath,
|
|
@@ -49,7 +40,7 @@ const createOrUpdateFile = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
49
40
|
}
|
|
50
41
|
}
|
|
51
42
|
try {
|
|
52
|
-
const { data: commitData } =
|
|
43
|
+
const { data: commitData } = await octokit.rest.repos.createOrUpdateFileContents({
|
|
53
44
|
owner: repositoryOwner,
|
|
54
45
|
repo: repositoryName,
|
|
55
46
|
path: filePath,
|
|
@@ -70,5 +61,5 @@ const createOrUpdateFile = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
70
61
|
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
|
|
71
62
|
return { success: false, error: errorMessage };
|
|
72
63
|
}
|
|
73
|
-
}
|
|
64
|
+
};
|
|
74
65
|
export default createOrUpdateFile;
|
|
@@ -1,27 +1,18 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
11
2
|
import { getOctokit } from "./utils.js";
|
|
12
3
|
/**
|
|
13
4
|
* Creates a pull request in a GitHub repository
|
|
14
5
|
*/
|
|
15
|
-
const createPullRequest =
|
|
6
|
+
const createPullRequest = async ({ params, authParams, }) => {
|
|
16
7
|
if (!authParams.authToken) {
|
|
17
8
|
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
18
9
|
}
|
|
19
10
|
const { repositoryOwner, repositoryName, head, base, title, description } = params;
|
|
20
|
-
const octokit =
|
|
21
|
-
const { RequestError } =
|
|
11
|
+
const octokit = await getOctokit(authParams.authToken);
|
|
12
|
+
const { RequestError } = await import("@octokit/request-error");
|
|
22
13
|
try {
|
|
23
14
|
// Create the pull request
|
|
24
|
-
const { data: pullRequestData } =
|
|
15
|
+
const { data: pullRequestData } = await octokit.rest.pulls.create({
|
|
25
16
|
owner: repositoryOwner,
|
|
26
17
|
repo: repositoryName,
|
|
27
18
|
head,
|
|
@@ -43,5 +34,5 @@ const createPullRequest = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
43
34
|
console.error("Unexpected error:", error);
|
|
44
35
|
return { success: false, error: "An unexpected error occurred" };
|
|
45
36
|
}
|
|
46
|
-
}
|
|
37
|
+
};
|
|
47
38
|
export default createPullRequest;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
11
|
+
// Limits on the number of results to return
|
|
12
|
+
const MAX_CODE_RESULTS = 15;
|
|
13
|
+
const MAX_COMMITS = 10;
|
|
14
|
+
const MAX_FILES_PER_COMMIT = 5;
|
|
15
|
+
const MAX_ISSUES_OR_PRS = 10;
|
|
16
|
+
const MAX_FILES_PER_PR = 5;
|
|
17
|
+
const MAX_PATCH_LINES = 20;
|
|
18
|
+
const MAX_FRAGMENT_LINES = 20;
|
|
19
|
+
const searchRepository = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
20
|
+
const { Octokit } = yield import("octokit");
|
|
21
|
+
if (!authParams.authToken) {
|
|
22
|
+
throw new Error(MISSING_AUTH_TOKEN);
|
|
23
|
+
}
|
|
24
|
+
const octokit = new Octokit({ auth: authParams.authToken });
|
|
25
|
+
const { organization, repository, query } = params;
|
|
26
|
+
// Search CODE with text match metadata
|
|
27
|
+
const codeResultsResponse = yield octokit.rest.search.code({
|
|
28
|
+
q: `${query} in:file,path repo:${organization}/${repository}`,
|
|
29
|
+
text_match: true,
|
|
30
|
+
headers: {
|
|
31
|
+
accept: "application/vnd.github.v3.text-match+json",
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const codeResults = codeResultsResponse.data.items.slice(0, MAX_CODE_RESULTS).map(item => ({
|
|
35
|
+
name: item.name,
|
|
36
|
+
path: item.path,
|
|
37
|
+
sha: item.sha,
|
|
38
|
+
url: item.url,
|
|
39
|
+
repository: {
|
|
40
|
+
full_name: item.repository.full_name,
|
|
41
|
+
html_url: item.repository.html_url,
|
|
42
|
+
},
|
|
43
|
+
score: item.score,
|
|
44
|
+
textMatches: item.text_matches
|
|
45
|
+
? item.text_matches.map(match => {
|
|
46
|
+
var _a, _b, _c, _d;
|
|
47
|
+
return ({
|
|
48
|
+
object_url: (_a = match.object_url) !== null && _a !== void 0 ? _a : undefined,
|
|
49
|
+
object_type: (_b = match.object_type) !== null && _b !== void 0 ? _b : undefined,
|
|
50
|
+
fragment: (_c = match.fragment) === null || _c === void 0 ? void 0 : _c.split("\n").slice(0, MAX_FRAGMENT_LINES).join("\n"),
|
|
51
|
+
matches: (_d = match.matches) !== null && _d !== void 0 ? _d : [],
|
|
52
|
+
});
|
|
53
|
+
})
|
|
54
|
+
: [],
|
|
55
|
+
}));
|
|
56
|
+
// Search COMMITS
|
|
57
|
+
const commitResults = yield octokit.rest.search.commits({
|
|
58
|
+
q: `${query} repo:${organization}/${repository}`,
|
|
59
|
+
headers: {
|
|
60
|
+
accept: "application/vnd.github.cloak-preview+json",
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
const commitSHAs = commitResults.data.items.slice(0, MAX_COMMITS).map(item => item.sha);
|
|
64
|
+
const commitDetails = yield Promise.all(commitSHAs.map(sha => octokit.rest.repos.getCommit({ owner: organization, repo: repository, ref: sha })));
|
|
65
|
+
const enrichedCommits = commitResults.data.items.slice(0, MAX_COMMITS).map(item => {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
const full = commitDetails.find(c => c.data.sha === item.sha);
|
|
68
|
+
return {
|
|
69
|
+
sha: item.sha,
|
|
70
|
+
url: item.url,
|
|
71
|
+
commit: {
|
|
72
|
+
message: item.commit.message,
|
|
73
|
+
author: item.commit.author,
|
|
74
|
+
},
|
|
75
|
+
score: item.score,
|
|
76
|
+
author: (_a = item.author) !== null && _a !== void 0 ? _a : undefined,
|
|
77
|
+
files: ((_b = full === null || full === void 0 ? void 0 : full.data.files) === null || _b === void 0 ? void 0 : _b.slice(0, MAX_FILES_PER_COMMIT).map(f => {
|
|
78
|
+
var _a;
|
|
79
|
+
return ({
|
|
80
|
+
filename: f.filename,
|
|
81
|
+
status: f.status,
|
|
82
|
+
patch: (_a = f.patch) === null || _a === void 0 ? void 0 : _a.split("\n").slice(0, MAX_PATCH_LINES).join("\n"),
|
|
83
|
+
});
|
|
84
|
+
})) || [],
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
// Search ISSUES & PRs
|
|
88
|
+
const issueResults = yield octokit.rest.search.issuesAndPullRequests({
|
|
89
|
+
q: `${query} repo:${organization}/${repository}`,
|
|
90
|
+
});
|
|
91
|
+
const prItems = issueResults.data.items.filter(item => item.pull_request).slice(0, MAX_ISSUES_OR_PRS);
|
|
92
|
+
const prNumbers = prItems.map(item => item.number);
|
|
93
|
+
const prFiles = yield Promise.all(prNumbers.map(number => octokit.rest.pulls.listFiles({ owner: organization, repo: repository, pull_number: number })));
|
|
94
|
+
const issuesAndPRs = issueResults.data.items
|
|
95
|
+
.slice(0, MAX_ISSUES_OR_PRS)
|
|
96
|
+
.map(item => {
|
|
97
|
+
var _a, _b, _c, _d;
|
|
98
|
+
const isPR = !!item.pull_request;
|
|
99
|
+
const prIndex = prNumbers.indexOf(item.number);
|
|
100
|
+
const files = isPR && prIndex !== -1
|
|
101
|
+
? prFiles[prIndex].data.slice(0, MAX_FILES_PER_PR).map(f => {
|
|
102
|
+
var _a;
|
|
103
|
+
return ({
|
|
104
|
+
filename: f.filename,
|
|
105
|
+
status: f.status,
|
|
106
|
+
patch: (_a = f.patch) === null || _a === void 0 ? void 0 : _a.split("\n").slice(0, MAX_PATCH_LINES).join("\n"),
|
|
107
|
+
});
|
|
108
|
+
})
|
|
109
|
+
: undefined;
|
|
110
|
+
return {
|
|
111
|
+
number: item.number,
|
|
112
|
+
title: item.title,
|
|
113
|
+
html_url: item.html_url,
|
|
114
|
+
state: item.state,
|
|
115
|
+
isPullRequest: isPR,
|
|
116
|
+
body: item.body,
|
|
117
|
+
user: {
|
|
118
|
+
email: (_b = (_a = item.user) === null || _a === void 0 ? void 0 : _a.email) !== null && _b !== void 0 ? _b : undefined,
|
|
119
|
+
name: (_d = (_c = item.user) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : undefined,
|
|
120
|
+
},
|
|
121
|
+
score: item.score,
|
|
122
|
+
files,
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
return {
|
|
126
|
+
code: codeResults,
|
|
127
|
+
commits: enrichedCommits,
|
|
128
|
+
issuesAndPullRequests: issuesAndPRs,
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
export default searchRepository;
|