@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,36 +1,24 @@
|
|
|
1
1
|
// ============================================================================
|
|
2
2
|
// TYPES
|
|
3
3
|
// ============================================================================
|
|
4
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
4
|
// ============================================================================
|
|
14
5
|
// IMPLEMENTATION
|
|
15
6
|
// ============================================================================
|
|
16
7
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
17
8
|
import { getProjectPath } from "./utils.js";
|
|
18
9
|
const GITLAB_API_URL = "https://gitlab.com";
|
|
19
|
-
function gitlabFetch(url, authToken) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
headers: { Authorization: `Bearer ${authToken}` },
|
|
23
|
-
});
|
|
24
|
-
if (!res.ok) {
|
|
25
|
-
throw new Error(`GitLab API error: ${res.status} ${res.statusText}`);
|
|
26
|
-
}
|
|
27
|
-
return res.json();
|
|
10
|
+
async function gitlabFetch(url, authToken) {
|
|
11
|
+
const res = await fetch(url, {
|
|
12
|
+
headers: { Authorization: `Bearer ${authToken}` },
|
|
28
13
|
});
|
|
14
|
+
if (!res.ok) {
|
|
15
|
+
throw new Error(`GitLab API error: ${res.status} ${res.statusText}`);
|
|
16
|
+
}
|
|
17
|
+
return res.json();
|
|
29
18
|
}
|
|
30
|
-
export const getMergeRequestContent =
|
|
31
|
-
var _b, _c, _d, _e, _f;
|
|
19
|
+
export const getMergeRequestContent = async ({ params, authParams, }) => {
|
|
32
20
|
const { authToken, baseUrl } = authParams;
|
|
33
|
-
const gitlabBaseUrl = baseUrl
|
|
21
|
+
const gitlabBaseUrl = baseUrl ?? GITLAB_API_URL;
|
|
34
22
|
if (!authToken) {
|
|
35
23
|
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
36
24
|
}
|
|
@@ -38,7 +26,7 @@ export const getMergeRequestContent = (_a) => __awaiter(void 0, [_a], void 0, fu
|
|
|
38
26
|
const projectPath = project_path
|
|
39
27
|
? project_path
|
|
40
28
|
: project_id
|
|
41
|
-
?
|
|
29
|
+
? await getProjectPath(project_id, authToken, `${gitlabBaseUrl}/api/v4`)
|
|
42
30
|
: undefined;
|
|
43
31
|
const encodedProjectPath = projectPath ? encodeURIComponent(projectPath) : undefined;
|
|
44
32
|
if (!encodedProjectPath) {
|
|
@@ -48,14 +36,14 @@ export const getMergeRequestContent = (_a) => __awaiter(void 0, [_a], void 0, fu
|
|
|
48
36
|
// 1. Fetch MR metadata
|
|
49
37
|
// --------------------------------------------------------------------------
|
|
50
38
|
const mrUrl = `${gitlabBaseUrl}/api/v4/projects/${encodedProjectPath}/merge_requests/${mr_iid}`;
|
|
51
|
-
const mr =
|
|
52
|
-
const webUrl =
|
|
39
|
+
const mr = await gitlabFetch(mrUrl, authToken);
|
|
40
|
+
const webUrl = mr.web_url ?? `${gitlabBaseUrl}/${encodedProjectPath}/-/merge_requests/${mr_iid}`;
|
|
53
41
|
const metadata = {
|
|
54
42
|
iid: mr.iid,
|
|
55
43
|
id: mr.id,
|
|
56
44
|
project_id: mr.project_id,
|
|
57
45
|
title: mr.title,
|
|
58
|
-
description:
|
|
46
|
+
description: mr.description ?? "",
|
|
59
47
|
state: mr.state,
|
|
60
48
|
merged: mr.merged,
|
|
61
49
|
sha: mr.sha,
|
|
@@ -64,14 +52,14 @@ export const getMergeRequestContent = (_a) => __awaiter(void 0, [_a], void 0, fu
|
|
|
64
52
|
web_url: webUrl,
|
|
65
53
|
source_branch: mr.source_branch,
|
|
66
54
|
target_branch: mr.target_branch,
|
|
67
|
-
source_sha:
|
|
68
|
-
target_sha:
|
|
55
|
+
source_sha: mr.diff_refs?.head_sha ?? mr.sha,
|
|
56
|
+
target_sha: mr.diff_refs?.base_sha,
|
|
69
57
|
};
|
|
70
58
|
// --------------------------------------------------------------------------
|
|
71
59
|
// 2. Fetch MR changes
|
|
72
60
|
// --------------------------------------------------------------------------
|
|
73
61
|
const changesUrl = `${gitlabBaseUrl}/api/v4/projects/${encodedProjectPath}/merge_requests/${mr_iid}/changes`;
|
|
74
|
-
const changesData =
|
|
62
|
+
const changesData = await gitlabFetch(changesUrl, authToken);
|
|
75
63
|
const changes = changesData.changes.map(c => ({
|
|
76
64
|
old_path: c.old_path,
|
|
77
65
|
new_path: c.new_path,
|
|
@@ -84,7 +72,7 @@ export const getMergeRequestContent = (_a) => __awaiter(void 0, [_a], void 0, fu
|
|
|
84
72
|
// 3. Fetch MR commits
|
|
85
73
|
// --------------------------------------------------------------------------
|
|
86
74
|
const commitsUrl = `${gitlabBaseUrl}/api/v4/projects/${encodedProjectPath}/merge_requests/${mr_iid}/commits`;
|
|
87
|
-
const commitsData =
|
|
75
|
+
const commitsData = await gitlabFetch(commitsUrl, authToken);
|
|
88
76
|
const commits = commitsData.map(c => ({
|
|
89
77
|
id: c.id,
|
|
90
78
|
title: c.title,
|
|
@@ -106,5 +94,5 @@ export const getMergeRequestContent = (_a) => __awaiter(void 0, [_a], void 0, fu
|
|
|
106
94
|
},
|
|
107
95
|
],
|
|
108
96
|
};
|
|
109
|
-
}
|
|
97
|
+
};
|
|
110
98
|
export default getMergeRequestContent;
|
|
@@ -1,34 +1,23 @@
|
|
|
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
|
const GITLAB_API_URL = "https://gitlab.com";
|
|
12
|
-
function gitlabFetch(endpoint, authToken) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
if (!res.ok) {
|
|
20
|
-
const text = yield res.text();
|
|
21
|
-
throw new Error(`GitLab API error: ${res.status} ${text}`);
|
|
22
|
-
}
|
|
23
|
-
return res.json();
|
|
3
|
+
async function gitlabFetch(endpoint, authToken) {
|
|
4
|
+
const res = await fetch(endpoint, {
|
|
5
|
+
headers: {
|
|
6
|
+
Authorization: `Bearer ${authToken}`,
|
|
7
|
+
},
|
|
24
8
|
});
|
|
9
|
+
if (!res.ok) {
|
|
10
|
+
const text = await res.text();
|
|
11
|
+
throw new Error(`GitLab API error: ${res.status} ${text}`);
|
|
12
|
+
}
|
|
13
|
+
return res.json();
|
|
25
14
|
}
|
|
26
15
|
/**
|
|
27
16
|
* List directory contents from a GitLab project
|
|
28
17
|
*/
|
|
29
|
-
const listDirectory =
|
|
18
|
+
const listDirectory = async ({ params, authParams, }) => {
|
|
30
19
|
const { authToken, baseUrl } = authParams;
|
|
31
|
-
const gitlabBaseUrl = baseUrl
|
|
20
|
+
const gitlabBaseUrl = baseUrl ?? GITLAB_API_URL;
|
|
32
21
|
if (!authToken)
|
|
33
22
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
34
23
|
const { group, project, path, ref = "main" } = params;
|
|
@@ -37,9 +26,8 @@ const listDirectory = (_a) => __awaiter(void 0, [_a], void 0, function* ({ param
|
|
|
37
26
|
const url = `${gitlabBaseUrl}/api/v4/projects/${encodedProjectPath}/repository/tree` +
|
|
38
27
|
`?path=${encodeURIComponent(path)}` +
|
|
39
28
|
`&ref=${encodeURIComponent(ref)}`;
|
|
40
|
-
const treeItems =
|
|
29
|
+
const treeItems = await gitlabFetch(url, authToken);
|
|
41
30
|
const results = treeItems.map(item => {
|
|
42
|
-
var _a;
|
|
43
31
|
const isFile = item.type === "blob";
|
|
44
32
|
const htmlUrl = `${gitlabBaseUrl}/${fullPath}/-/blob/${ref}/${item.path}`;
|
|
45
33
|
return {
|
|
@@ -49,11 +37,11 @@ const listDirectory = (_a) => __awaiter(void 0, [_a], void 0, function* ({ param
|
|
|
49
37
|
name: item.name,
|
|
50
38
|
path: item.path,
|
|
51
39
|
type: item.type, // "blob" or "tree"
|
|
52
|
-
size: isFile ? (
|
|
40
|
+
size: isFile ? (item.size ?? 0) : 0, // Size may not be returned; fallback to 0
|
|
53
41
|
htmlUrl,
|
|
54
42
|
},
|
|
55
43
|
};
|
|
56
44
|
});
|
|
57
45
|
return { success: true, results };
|
|
58
|
-
}
|
|
46
|
+
};
|
|
59
47
|
export default listDirectory;
|
|
@@ -1,12 +1,3 @@
|
|
|
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 { createProjectPathCache, getProjectPath, gitlabFetch } from "./utils.js";
|
|
12
3
|
const GITLAB_API_URL = "https://gitlab.com";
|
|
@@ -24,43 +15,39 @@ function constructBlobUrl(input) {
|
|
|
24
15
|
url += `#L${startline}`;
|
|
25
16
|
return url;
|
|
26
17
|
}
|
|
27
|
-
function enhanceBlobWithUrl(blob, authToken, baseUrl, gitlabWebBaseUrl, projectPathCache) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
startline: blob.startline,
|
|
36
|
-
});
|
|
37
|
-
return Object.assign(Object.assign({}, blob), { web_url });
|
|
18
|
+
async function enhanceBlobWithUrl(blob, authToken, baseUrl, gitlabWebBaseUrl, projectPathCache) {
|
|
19
|
+
const projectPath = await getProjectPath(blob.project_id, authToken, baseUrl, projectPathCache);
|
|
20
|
+
const web_url = constructBlobUrl({
|
|
21
|
+
baseUrl: gitlabWebBaseUrl,
|
|
22
|
+
projectPath,
|
|
23
|
+
ref: blob.ref,
|
|
24
|
+
path: blob.path,
|
|
25
|
+
startline: blob.startline,
|
|
38
26
|
});
|
|
27
|
+
return { ...blob, web_url };
|
|
39
28
|
}
|
|
40
|
-
function getCommitDetails(input) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
});
|
|
29
|
+
async function getCommitDetails(input) {
|
|
30
|
+
const { projectId, sha, authToken, baseUrl, webBaseUrl, projectPathCache } = input;
|
|
31
|
+
const projectPath = await getProjectPath(projectId, authToken, baseUrl, projectPathCache);
|
|
32
|
+
const commit = await gitlabFetch(`${baseUrl}/projects/${projectId}/repository/commits/${sha}`, authToken);
|
|
33
|
+
const diffs = await gitlabFetch(`${baseUrl}/projects/${projectId}/repository/commits/${sha}/diff`, authToken);
|
|
34
|
+
return {
|
|
35
|
+
sha: commit.id,
|
|
36
|
+
web_url: `${webBaseUrl}/${projectPath}/-/commit/${commit.id}`,
|
|
37
|
+
message: commit.message,
|
|
38
|
+
author: { name: commit.author_name, email: commit.author_email },
|
|
39
|
+
created_at: commit.created_at,
|
|
40
|
+
files: (diffs || []).slice(0, MAX_FILES_PER_COMMIT).map(diff => ({
|
|
41
|
+
old_path: diff.old_path,
|
|
42
|
+
new_path: diff.new_path,
|
|
43
|
+
diff: diff.diff ? diff.diff.split("\n").slice(0, MAX_PATCH_LINES).join("\n") : "",
|
|
44
|
+
})),
|
|
45
|
+
};
|
|
59
46
|
}
|
|
60
|
-
const searchGroup =
|
|
47
|
+
const searchGroup = async ({ params, authParams, }) => {
|
|
61
48
|
try {
|
|
62
49
|
const { authToken, baseUrl } = authParams;
|
|
63
|
-
const gitlabBaseUrl = baseUrl
|
|
50
|
+
const gitlabBaseUrl = baseUrl ?? GITLAB_API_URL;
|
|
64
51
|
const gitlabBaseApiUrl = `${gitlabBaseUrl}/api/v4`;
|
|
65
52
|
if (!authToken)
|
|
66
53
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
@@ -68,26 +55,29 @@ const searchGroup = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
|
|
|
68
55
|
const projectPathCache = createProjectPathCache();
|
|
69
56
|
const fullProjectPath = project ? `${groupId}/${project}` : undefined;
|
|
70
57
|
const encodedGroup = encodeURIComponent(groupId);
|
|
71
|
-
const fetchSearchResults = (scope) =>
|
|
58
|
+
const fetchSearchResults = async (scope) => {
|
|
72
59
|
const endpoint = fullProjectPath
|
|
73
60
|
? `${gitlabBaseApiUrl}/projects/${encodeURIComponent(fullProjectPath)}/search?scope=${scope}&search=${encodeURIComponent(query)}`
|
|
74
61
|
: `${gitlabBaseApiUrl}/groups/${encodedGroup}/search?scope=${scope}&search=${encodeURIComponent(query)}`;
|
|
75
62
|
return gitlabFetch(endpoint, authToken);
|
|
76
|
-
}
|
|
77
|
-
const [mrResults, blobResults, commitResults] =
|
|
63
|
+
};
|
|
64
|
+
const [mrResults, blobResults, commitResults] = await Promise.all([
|
|
78
65
|
fetchSearchResults("merge_requests"),
|
|
79
66
|
fetchSearchResults("blobs"),
|
|
80
67
|
fetchSearchResults("commits"),
|
|
81
68
|
]);
|
|
82
69
|
const limitedMRResults = mrResults.slice(0, MAX_ISSUES_OR_PRS);
|
|
83
|
-
const mergeRequests =
|
|
70
|
+
const mergeRequests = await Promise.all(limitedMRResults.map(async (metadata) => {
|
|
84
71
|
const endpoint = `${gitlabBaseApiUrl}/projects/${metadata.project_id}/merge_requests/${metadata.iid}/diffs`;
|
|
85
|
-
let diffs =
|
|
86
|
-
diffs = (diffs || []).slice(0, MAX_FILES_PER_PR).map(diff => (
|
|
72
|
+
let diffs = await gitlabFetch(endpoint, authToken);
|
|
73
|
+
diffs = (diffs || []).slice(0, MAX_FILES_PER_PR).map(diff => ({
|
|
74
|
+
...diff,
|
|
75
|
+
diff: diff.diff ? diff.diff.split("\n").slice(0, MAX_PATCH_LINES).join("\n") : diff.diff,
|
|
76
|
+
}));
|
|
87
77
|
return { metadata, diffs };
|
|
88
|
-
}))
|
|
78
|
+
}));
|
|
89
79
|
const limitedBlobResults = blobResults.slice(0, MAX_CODE_RESULTS);
|
|
90
|
-
const blobsWithUrls =
|
|
80
|
+
const blobsWithUrls = await Promise.all(limitedBlobResults.map(blob => enhanceBlobWithUrl(blob, authToken, gitlabBaseApiUrl, gitlabBaseUrl, projectPathCache)));
|
|
91
81
|
const blobs = blobsWithUrls.map(blob => {
|
|
92
82
|
const matches = mergeRequests
|
|
93
83
|
.filter(mr => mr.metadata.project_id === blob.project_id && mr.diffs.some(diff => diff.new_path === blob.path))
|
|
@@ -98,12 +88,15 @@ const searchGroup = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
|
|
|
98
88
|
merged_at: mr.metadata.merged_at,
|
|
99
89
|
}));
|
|
100
90
|
return {
|
|
101
|
-
metadata:
|
|
91
|
+
metadata: {
|
|
92
|
+
...blob,
|
|
93
|
+
data: blob.data.split("\n").slice(0, MAX_FRAGMENT_LINES).join("\n"),
|
|
94
|
+
},
|
|
102
95
|
matchedMergeRequests: matches,
|
|
103
96
|
};
|
|
104
97
|
});
|
|
105
98
|
const limitedCommitResults = commitResults.slice(0, MAX_COMMITS);
|
|
106
|
-
const commits =
|
|
99
|
+
const commits = await Promise.all(limitedCommitResults.map(commit => getCommitDetails({
|
|
107
100
|
projectId: commit.project_id,
|
|
108
101
|
sha: commit.id,
|
|
109
102
|
authToken,
|
|
@@ -144,5 +137,5 @@ const searchGroup = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
|
|
|
144
137
|
results: [],
|
|
145
138
|
};
|
|
146
139
|
}
|
|
147
|
-
}
|
|
140
|
+
};
|
|
148
141
|
export default searchGroup;
|
|
@@ -1,36 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
export function gitlabFetch(endpoint, authToken) {
|
|
11
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
12
|
-
const res = yield fetch(endpoint, { headers: { Authorization: `Bearer ${authToken}` } });
|
|
13
|
-
if (!res.ok)
|
|
14
|
-
throw new Error(`GitLab API error: ${res.status} ${res.statusText}`);
|
|
15
|
-
return res.json();
|
|
16
|
-
});
|
|
1
|
+
export async function gitlabFetch(endpoint, authToken) {
|
|
2
|
+
const res = await fetch(endpoint, { headers: { Authorization: `Bearer ${authToken}` } });
|
|
3
|
+
if (!res.ok)
|
|
4
|
+
throw new Error(`GitLab API error: ${res.status} ${res.statusText}`);
|
|
5
|
+
return res.json();
|
|
17
6
|
}
|
|
18
|
-
export function getProjectPath(projectId, authToken, baseUrl, projectPathCache) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
});
|
|
7
|
+
export async function getProjectPath(projectId, authToken, baseUrl, projectPathCache) {
|
|
8
|
+
if (projectPathCache && projectPathCache.has(projectId))
|
|
9
|
+
return projectPathCache.get(projectId);
|
|
10
|
+
try {
|
|
11
|
+
const project = await gitlabFetch(`${baseUrl}/projects/${projectId}`, authToken);
|
|
12
|
+
const path = project.path_with_namespace;
|
|
13
|
+
if (projectPathCache)
|
|
14
|
+
projectPathCache.set(projectId, path);
|
|
15
|
+
return path;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
console.warn(`Failed to fetch project path for project ${projectId}:`, error);
|
|
19
|
+
return `project-${projectId}`;
|
|
20
|
+
}
|
|
34
21
|
}
|
|
35
22
|
export function createProjectPathCache() {
|
|
36
23
|
return new Map();
|
|
@@ -1,22 +1,13 @@
|
|
|
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 { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
-
const addGroupMember =
|
|
3
|
+
const addGroupMember = async ({ params, authParams, }) => {
|
|
13
4
|
const { authToken } = authParams;
|
|
14
5
|
const { groupKey, email } = params;
|
|
15
6
|
if (!authToken) {
|
|
16
7
|
return { success: false, memberID: "", error: MISSING_AUTH_TOKEN };
|
|
17
8
|
}
|
|
18
9
|
try {
|
|
19
|
-
const response =
|
|
10
|
+
const response = await axiosClient.post(`https://admin.googleapis.com/admin/directory/v1/groups/${encodeURIComponent(groupKey)}/members`, { email }, {
|
|
20
11
|
headers: { Authorization: `Bearer ${authToken}` },
|
|
21
12
|
});
|
|
22
13
|
return {
|
|
@@ -31,5 +22,5 @@ const addGroupMember = (_a) => __awaiter(void 0, [_a], void 0, function* ({ para
|
|
|
31
22
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
32
23
|
};
|
|
33
24
|
}
|
|
34
|
-
}
|
|
25
|
+
};
|
|
35
26
|
export default addGroupMember;
|
|
@@ -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 { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
-
const addTextToTopOfDoc =
|
|
3
|
+
const addTextToTopOfDoc = async ({ params, authParams, }) => {
|
|
13
4
|
if (!authParams.authToken) {
|
|
14
5
|
return {
|
|
15
6
|
success: false,
|
|
@@ -20,7 +11,7 @@ const addTextToTopOfDoc = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
20
11
|
const { documentId, text } = params;
|
|
21
12
|
const baseApiUrl = "https://docs.googleapis.com/v1/documents";
|
|
22
13
|
try {
|
|
23
|
-
|
|
14
|
+
await axiosClient.post(`${baseApiUrl}/${documentId}:batchUpdate`, {
|
|
24
15
|
requests: [
|
|
25
16
|
{
|
|
26
17
|
insertText: {
|
|
@@ -50,5 +41,5 @@ const addTextToTopOfDoc = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
50
41
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
51
42
|
};
|
|
52
43
|
}
|
|
53
|
-
}
|
|
44
|
+
};
|
|
54
45
|
export default addTextToTopOfDoc;
|
|
@@ -1,19 +1,10 @@
|
|
|
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 { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
3
|
/**
|
|
13
4
|
* Appends rows to a Google Spreadsheet using OAuth authentication
|
|
14
5
|
* https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append
|
|
15
6
|
*/
|
|
16
|
-
const appendRowsToSpreadsheet =
|
|
7
|
+
const appendRowsToSpreadsheet = async ({ params, authParams, }) => {
|
|
17
8
|
if (!authParams.authToken) {
|
|
18
9
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
19
10
|
}
|
|
@@ -22,9 +13,9 @@ const appendRowsToSpreadsheet = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
22
13
|
// Schema: [[{ stringValue: "cell1" }, { stringValue: "cell2" }], ...]
|
|
23
14
|
// API expects: [["cell1", "cell2"], ...]
|
|
24
15
|
const values = rows.map(row => row.map(cell => cell.stringValue));
|
|
25
|
-
const appendUrl = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/'${sheetName
|
|
16
|
+
const appendUrl = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/'${sheetName ?? "Sheet1"}':append`;
|
|
26
17
|
try {
|
|
27
|
-
const response =
|
|
18
|
+
const response = await axiosClient.post(appendUrl, {
|
|
28
19
|
values,
|
|
29
20
|
majorDimension: "ROWS",
|
|
30
21
|
range: `'${sheetName}'`,
|
|
@@ -57,5 +48,5 @@ const appendRowsToSpreadsheet = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
57
48
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
58
49
|
};
|
|
59
50
|
}
|
|
60
|
-
}
|
|
51
|
+
};
|
|
61
52
|
export default appendRowsToSpreadsheet;
|
|
@@ -1,12 +1,3 @@
|
|
|
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 { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
3
|
/**
|
|
@@ -44,7 +35,6 @@ function parseHtmlToDocRequests(htmlContent) {
|
|
|
44
35
|
* Basic HTML parser that extracts text and formatting
|
|
45
36
|
*/
|
|
46
37
|
function parseHtmlContent(html) {
|
|
47
|
-
var _a;
|
|
48
38
|
const result = [];
|
|
49
39
|
// Handle line breaks
|
|
50
40
|
html = html.replace(/<br\s*\/?>/gi, "\n");
|
|
@@ -76,7 +66,7 @@ function parseHtmlContent(html) {
|
|
|
76
66
|
delete currentFormatting.underline;
|
|
77
67
|
}
|
|
78
68
|
else if (segment.match(/<\s*h[1-6]\s*>/i)) {
|
|
79
|
-
const headingLevel =
|
|
69
|
+
const headingLevel = segment.match(/<\s*h([1-6])\s*>/i)?.[1];
|
|
80
70
|
currentFormatting.fontSize = { magnitude: 18 - (parseInt(headingLevel || "1") - 1) * 2, unit: "PT" };
|
|
81
71
|
currentFormatting.bold = true;
|
|
82
72
|
}
|
|
@@ -89,7 +79,7 @@ function parseHtmlContent(html) {
|
|
|
89
79
|
// This is text content
|
|
90
80
|
result.push({
|
|
91
81
|
text: segment,
|
|
92
|
-
formatting: Object.keys(currentFormatting).length > 0 ?
|
|
82
|
+
formatting: Object.keys(currentFormatting).length > 0 ? { ...currentFormatting } : undefined,
|
|
93
83
|
});
|
|
94
84
|
}
|
|
95
85
|
}
|
|
@@ -105,14 +95,14 @@ function parseHtmlContent(html) {
|
|
|
105
95
|
/**
|
|
106
96
|
* Creates a new Google Doc document using OAuth authentication
|
|
107
97
|
*/
|
|
108
|
-
const createNewGoogleDoc =
|
|
98
|
+
const createNewGoogleDoc = async ({ params, authParams, }) => {
|
|
109
99
|
if (!authParams.authToken) {
|
|
110
100
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
111
101
|
}
|
|
112
102
|
const { title, content, usesHtml } = params;
|
|
113
103
|
const baseApiUrl = "https://docs.googleapis.com/v1/documents";
|
|
114
104
|
// Create the document with the provided title
|
|
115
|
-
const response =
|
|
105
|
+
const response = await axiosClient.post(baseApiUrl, { title }, {
|
|
116
106
|
headers: {
|
|
117
107
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
118
108
|
"Content-Type": "application/json",
|
|
@@ -124,7 +114,7 @@ const createNewGoogleDoc = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
124
114
|
if (usesHtml) {
|
|
125
115
|
// Parse HTML content and create requests for rich text formatting
|
|
126
116
|
const requests = parseHtmlToDocRequests(content);
|
|
127
|
-
|
|
117
|
+
await axiosClient.post(`${baseApiUrl}/${documentId}:batchUpdate`, { requests }, {
|
|
128
118
|
headers: {
|
|
129
119
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
130
120
|
"Content-Type": "application/json",
|
|
@@ -133,7 +123,7 @@ const createNewGoogleDoc = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
133
123
|
}
|
|
134
124
|
else {
|
|
135
125
|
// Add plain text content to the document
|
|
136
|
-
|
|
126
|
+
await axiosClient.post(`${baseApiUrl}/${documentId}:batchUpdate`, {
|
|
137
127
|
requests: [
|
|
138
128
|
{
|
|
139
129
|
insertText: {
|
|
@@ -158,5 +148,5 @@ const createNewGoogleDoc = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
158
148
|
? `https://docs.google.com/document/d/${response.data.documentId}/edit`
|
|
159
149
|
: undefined,
|
|
160
150
|
};
|
|
161
|
-
}
|
|
151
|
+
};
|
|
162
152
|
export default createNewGoogleDoc;
|
|
@@ -1,26 +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 { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
3
|
/**
|
|
13
4
|
* Creates a new Google Slides presentation using OAuth authentication
|
|
14
5
|
*/
|
|
15
|
-
const createPresentation =
|
|
6
|
+
const createPresentation = async ({ params, authParams, }) => {
|
|
16
7
|
if (!authParams.authToken) {
|
|
17
8
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
18
9
|
}
|
|
19
10
|
const { title, pageSize } = params;
|
|
20
11
|
const baseApiUrl = "https://slides.googleapis.com/v1/presentations";
|
|
21
|
-
const requestBody =
|
|
12
|
+
const requestBody = {
|
|
13
|
+
title,
|
|
14
|
+
...(pageSize && { pageSize }),
|
|
15
|
+
};
|
|
22
16
|
try {
|
|
23
|
-
const response =
|
|
17
|
+
const response = await axiosClient.post(baseApiUrl, requestBody, {
|
|
24
18
|
headers: {
|
|
25
19
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
26
20
|
"Content-Type": "application/json",
|
|
@@ -47,5 +41,5 @@ const createPresentation = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
47
41
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
48
42
|
};
|
|
49
43
|
}
|
|
50
|
-
}
|
|
44
|
+
};
|
|
51
45
|
export default createPresentation;
|