@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,14 +1,4 @@
|
|
|
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 getIssueDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
11
|
-
var _b;
|
|
1
|
+
const getIssueDetails = async ({ params, authParams, }) => {
|
|
12
2
|
const { authToken } = authParams;
|
|
13
3
|
const { issueId } = params;
|
|
14
4
|
if (!authToken) {
|
|
@@ -62,7 +52,7 @@ const getIssueDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
|
|
|
62
52
|
}
|
|
63
53
|
`;
|
|
64
54
|
try {
|
|
65
|
-
const response =
|
|
55
|
+
const response = await fetch("https://api.linear.app/graphql", {
|
|
66
56
|
method: "POST",
|
|
67
57
|
headers: {
|
|
68
58
|
"Content-Type": "application/json",
|
|
@@ -74,14 +64,14 @@ const getIssueDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
|
|
|
74
64
|
}),
|
|
75
65
|
});
|
|
76
66
|
if (!response.ok) {
|
|
77
|
-
const errorText =
|
|
67
|
+
const errorText = await response.text();
|
|
78
68
|
throw new Error(`HTTP error: status: ${response.status}, body: ${errorText}`);
|
|
79
69
|
}
|
|
80
|
-
const data =
|
|
70
|
+
const data = await response.json();
|
|
81
71
|
if (data.errors) {
|
|
82
72
|
throw new Error(`GraphQL errors: ${JSON.stringify(data.errors)}`);
|
|
83
73
|
}
|
|
84
|
-
if (!
|
|
74
|
+
if (!data.data?.issue) {
|
|
85
75
|
return {
|
|
86
76
|
success: false,
|
|
87
77
|
error: "Issue not found",
|
|
@@ -94,7 +84,7 @@ const getIssueDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
|
|
|
94
84
|
id,
|
|
95
85
|
title,
|
|
96
86
|
description: description || undefined,
|
|
97
|
-
state:
|
|
87
|
+
state: state?.name || undefined,
|
|
98
88
|
assignee: assignee ? { id: assignee.id, name: assignee.name } : undefined,
|
|
99
89
|
creator: creator ? { id: creator.id, name: creator.name } : undefined,
|
|
100
90
|
team: team ? { id: team.id, name: team.name } : undefined,
|
|
@@ -104,11 +94,11 @@ const getIssueDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
|
|
|
104
94
|
dueDate: dueDate || undefined,
|
|
105
95
|
createdAt: createdAt || undefined,
|
|
106
96
|
updatedAt: updatedAt || undefined,
|
|
107
|
-
labels: Array.isArray(labels
|
|
97
|
+
labels: Array.isArray(labels?.nodes) ? labels.nodes.map(({ name }) => name) : [],
|
|
108
98
|
url: url || undefined,
|
|
109
|
-
comments: Array.isArray(comments
|
|
99
|
+
comments: Array.isArray(comments?.nodes)
|
|
110
100
|
? comments.nodes.map(({ user, body }) => ({
|
|
111
|
-
author_name:
|
|
101
|
+
author_name: user?.name || "Unknown",
|
|
112
102
|
comment: body,
|
|
113
103
|
}))
|
|
114
104
|
: [],
|
|
@@ -123,5 +113,5 @@ const getIssueDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
|
|
|
123
113
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
124
114
|
};
|
|
125
115
|
}
|
|
126
|
-
}
|
|
116
|
+
};
|
|
127
117
|
export default getIssueDetails;
|
|
@@ -1,14 +1,4 @@
|
|
|
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 getIssues = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
11
|
-
var _b;
|
|
1
|
+
const getIssues = async ({ params, authParams, }) => {
|
|
12
2
|
const { authToken } = authParams;
|
|
13
3
|
const { query, maxResults } = params;
|
|
14
4
|
if (!authToken) {
|
|
@@ -77,7 +67,7 @@ const getIssues = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, a
|
|
|
77
67
|
first: Math.min(PAGE_SIZE, max - fetched),
|
|
78
68
|
after: afterCursor,
|
|
79
69
|
};
|
|
80
|
-
const response =
|
|
70
|
+
const response = await fetch("https://api.linear.app/graphql", {
|
|
81
71
|
method: "POST",
|
|
82
72
|
headers: {
|
|
83
73
|
"Content-Type": "application/json",
|
|
@@ -89,14 +79,14 @@ const getIssues = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, a
|
|
|
89
79
|
}),
|
|
90
80
|
});
|
|
91
81
|
if (!response.ok) {
|
|
92
|
-
const errorText =
|
|
82
|
+
const errorText = await response.text();
|
|
93
83
|
throw new Error(`HTTP error: status: ${response.status}, body: ${errorText}`);
|
|
94
84
|
}
|
|
95
|
-
const data =
|
|
85
|
+
const data = await response.json();
|
|
96
86
|
if (data.errors) {
|
|
97
87
|
throw new Error(`GraphQL errors: ${JSON.stringify(data.errors)}`);
|
|
98
88
|
}
|
|
99
|
-
const issuesData =
|
|
89
|
+
const issuesData = data.data?.issues;
|
|
100
90
|
if (!issuesData) {
|
|
101
91
|
break;
|
|
102
92
|
}
|
|
@@ -107,16 +97,16 @@ const getIssues = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, a
|
|
|
107
97
|
return {
|
|
108
98
|
id,
|
|
109
99
|
title,
|
|
110
|
-
labels: Array.isArray(labels
|
|
111
|
-
state:
|
|
100
|
+
labels: Array.isArray(labels?.nodes) ? labels.nodes.map(({ name }) => name) : [],
|
|
101
|
+
state: state?.name || "",
|
|
112
102
|
assignee: assignee ? { id: assignee.id, name: assignee.name } : null,
|
|
113
103
|
due_date: dueDate,
|
|
114
104
|
project: project ? { id: project.id, name: project.name } : null,
|
|
115
105
|
team: team ? { id: team.id, name: team.name } : null,
|
|
116
106
|
url,
|
|
117
|
-
comments: Array.isArray(comments
|
|
107
|
+
comments: Array.isArray(comments?.nodes)
|
|
118
108
|
? comments.nodes.map(({ user, body }) => ({
|
|
119
|
-
author_name:
|
|
109
|
+
author_name: user?.name || "Unknown",
|
|
120
110
|
comment: body,
|
|
121
111
|
}))
|
|
122
112
|
: [],
|
|
@@ -125,7 +115,7 @@ const getIssues = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, a
|
|
|
125
115
|
allIssues.push(...processedIssues);
|
|
126
116
|
fetched = allIssues.length;
|
|
127
117
|
}
|
|
128
|
-
if (!
|
|
118
|
+
if (!pageInfo?.hasNextPage || !pageInfo?.endCursor || allIssues.length >= max) {
|
|
129
119
|
break;
|
|
130
120
|
}
|
|
131
121
|
afterCursor = pageInfo.endCursor;
|
|
@@ -156,5 +146,5 @@ const getIssues = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, a
|
|
|
156
146
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
157
147
|
};
|
|
158
148
|
}
|
|
159
|
-
}
|
|
149
|
+
};
|
|
160
150
|
export default getIssues;
|
|
@@ -1,14 +1,4 @@
|
|
|
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 getProjectDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
11
|
-
var _b;
|
|
1
|
+
const getProjectDetails = async ({ params, authParams, }) => {
|
|
12
2
|
const { authToken } = authParams;
|
|
13
3
|
const { projectId } = params;
|
|
14
4
|
if (!authToken) {
|
|
@@ -57,7 +47,7 @@ const getProjectDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
57
47
|
}
|
|
58
48
|
`;
|
|
59
49
|
try {
|
|
60
|
-
const response =
|
|
50
|
+
const response = await fetch("https://api.linear.app/graphql", {
|
|
61
51
|
method: "POST",
|
|
62
52
|
headers: {
|
|
63
53
|
"Content-Type": "application/json",
|
|
@@ -69,14 +59,14 @@ const getProjectDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
69
59
|
}),
|
|
70
60
|
});
|
|
71
61
|
if (!response.ok) {
|
|
72
|
-
const errorText =
|
|
62
|
+
const errorText = await response.text();
|
|
73
63
|
throw new Error(`HTTP error: status: ${response.status}, body: ${errorText}`);
|
|
74
64
|
}
|
|
75
|
-
const data =
|
|
65
|
+
const data = await response.json();
|
|
76
66
|
if (data.errors) {
|
|
77
67
|
throw new Error(`GraphQL errors: ${JSON.stringify(data.errors)}`);
|
|
78
68
|
}
|
|
79
|
-
if (!
|
|
69
|
+
if (!data.data?.project) {
|
|
80
70
|
return {
|
|
81
71
|
success: false,
|
|
82
72
|
error: "Project not found",
|
|
@@ -95,10 +85,10 @@ const getProjectDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
95
85
|
createdAt: createdAt || undefined,
|
|
96
86
|
updatedAt: updatedAt || undefined,
|
|
97
87
|
lead: lead ? { id: lead.id, name: lead.name } : undefined,
|
|
98
|
-
team: Array.isArray(teams
|
|
88
|
+
team: Array.isArray(teams?.nodes) && teams.nodes.length > 0
|
|
99
89
|
? { id: teams.nodes[0].id, name: teams.nodes[0].name }
|
|
100
90
|
: undefined,
|
|
101
|
-
issues: Array.isArray(issues
|
|
91
|
+
issues: Array.isArray(issues?.nodes)
|
|
102
92
|
? issues.nodes.map(({ id, title, url }) => ({
|
|
103
93
|
id,
|
|
104
94
|
name: title,
|
|
@@ -106,11 +96,11 @@ const getProjectDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
106
96
|
}))
|
|
107
97
|
: [],
|
|
108
98
|
url: url || undefined,
|
|
109
|
-
updates: Array.isArray(projectUpdates
|
|
99
|
+
updates: Array.isArray(projectUpdates?.nodes)
|
|
110
100
|
? projectUpdates.nodes.map(({ id, body, user, createdAt }) => ({
|
|
111
101
|
id,
|
|
112
102
|
content: body,
|
|
113
|
-
author_name:
|
|
103
|
+
author_name: user?.name || "Unknown",
|
|
114
104
|
created_at: createdAt,
|
|
115
105
|
}))
|
|
116
106
|
: [],
|
|
@@ -125,5 +115,5 @@ const getProjectDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
125
115
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
126
116
|
};
|
|
127
117
|
}
|
|
128
|
-
}
|
|
118
|
+
};
|
|
129
119
|
export default getProjectDetails;
|
|
@@ -1,14 +1,4 @@
|
|
|
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 getProjects = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams, }) {
|
|
11
|
-
var _b;
|
|
1
|
+
const getProjects = async ({ authParams, }) => {
|
|
12
2
|
const { authToken } = authParams;
|
|
13
3
|
if (!authToken) {
|
|
14
4
|
throw new Error("Valid auth token is required to get Linear projects");
|
|
@@ -41,7 +31,7 @@ const getProjects = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authPar
|
|
|
41
31
|
}
|
|
42
32
|
`;
|
|
43
33
|
try {
|
|
44
|
-
const response =
|
|
34
|
+
const response = await fetch("https://api.linear.app/graphql", {
|
|
45
35
|
method: "POST",
|
|
46
36
|
headers: {
|
|
47
37
|
"Content-Type": "application/json",
|
|
@@ -54,11 +44,11 @@ const getProjects = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authPar
|
|
|
54
44
|
if (!response.ok) {
|
|
55
45
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
56
46
|
}
|
|
57
|
-
const data =
|
|
47
|
+
const data = await response.json();
|
|
58
48
|
if (data.errors) {
|
|
59
49
|
throw new Error(`GraphQL errors: ${JSON.stringify(data.errors)}`);
|
|
60
50
|
}
|
|
61
|
-
if (!
|
|
51
|
+
if (!data.data?.projects) {
|
|
62
52
|
return {
|
|
63
53
|
success: false,
|
|
64
54
|
error: "No projects found",
|
|
@@ -74,7 +64,7 @@ const getProjects = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authPar
|
|
|
74
64
|
id,
|
|
75
65
|
name,
|
|
76
66
|
status: state,
|
|
77
|
-
labels: Array.isArray(labels
|
|
67
|
+
labels: Array.isArray(labels?.nodes) ? labels.nodes.map(({ name }) => name) : [],
|
|
78
68
|
content: description || undefined,
|
|
79
69
|
description: description || undefined,
|
|
80
70
|
creator: creator ? { id: creator.id, name: creator.name } : undefined,
|
|
@@ -92,5 +82,5 @@ const getProjects = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authPar
|
|
|
92
82
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
93
83
|
};
|
|
94
84
|
}
|
|
95
|
-
}
|
|
85
|
+
};
|
|
96
86
|
export default getProjects;
|
|
@@ -1,14 +1,4 @@
|
|
|
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 getTeamDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
11
|
-
var _b;
|
|
1
|
+
const getTeamDetails = async ({ params, authParams, }) => {
|
|
12
2
|
const { authToken } = authParams;
|
|
13
3
|
const { teamId } = params;
|
|
14
4
|
if (!authToken) {
|
|
@@ -31,7 +21,7 @@ const getTeamDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ para
|
|
|
31
21
|
}
|
|
32
22
|
`;
|
|
33
23
|
try {
|
|
34
|
-
const response =
|
|
24
|
+
const response = await fetch("https://api.linear.app/graphql", {
|
|
35
25
|
method: "POST",
|
|
36
26
|
headers: {
|
|
37
27
|
"Content-Type": "application/json",
|
|
@@ -43,14 +33,14 @@ const getTeamDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ para
|
|
|
43
33
|
}),
|
|
44
34
|
});
|
|
45
35
|
if (!response.ok) {
|
|
46
|
-
const errorText =
|
|
36
|
+
const errorText = await response.text();
|
|
47
37
|
throw new Error(`HTTP error, status: ${response.status} body: ${errorText}`);
|
|
48
38
|
}
|
|
49
|
-
const data =
|
|
39
|
+
const data = await response.json();
|
|
50
40
|
if (data.errors) {
|
|
51
41
|
throw new Error(`GraphQL errors: ${JSON.stringify(data.errors)}`);
|
|
52
42
|
}
|
|
53
|
-
if (!
|
|
43
|
+
if (!data.data?.team) {
|
|
54
44
|
return {
|
|
55
45
|
success: false,
|
|
56
46
|
error: "Team not found",
|
|
@@ -63,7 +53,7 @@ const getTeamDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ para
|
|
|
63
53
|
id,
|
|
64
54
|
name,
|
|
65
55
|
identifier: key,
|
|
66
|
-
members: Array.isArray(members
|
|
56
|
+
members: Array.isArray(members?.nodes)
|
|
67
57
|
? members.nodes.map(({ id, name, email }) => ({
|
|
68
58
|
id,
|
|
69
59
|
name,
|
|
@@ -80,5 +70,5 @@ const getTeamDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ para
|
|
|
80
70
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
81
71
|
};
|
|
82
72
|
}
|
|
83
|
-
}
|
|
73
|
+
};
|
|
84
74
|
export default getTeamDetails;
|
|
@@ -1,14 +1,4 @@
|
|
|
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 getTeams = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams, }) {
|
|
11
|
-
var _b;
|
|
1
|
+
const getTeams = async ({ authParams, }) => {
|
|
12
2
|
const { authToken } = authParams;
|
|
13
3
|
if (!authToken) {
|
|
14
4
|
throw new Error("Valid auth token is required to get Linear teams");
|
|
@@ -24,7 +14,7 @@ const getTeams = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams
|
|
|
24
14
|
}
|
|
25
15
|
`;
|
|
26
16
|
try {
|
|
27
|
-
const response =
|
|
17
|
+
const response = await fetch("https://api.linear.app/graphql", {
|
|
28
18
|
method: "POST",
|
|
29
19
|
headers: {
|
|
30
20
|
"Content-Type": "application/json",
|
|
@@ -37,11 +27,11 @@ const getTeams = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams
|
|
|
37
27
|
if (!response.ok) {
|
|
38
28
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
39
29
|
}
|
|
40
|
-
const data =
|
|
30
|
+
const data = await response.json();
|
|
41
31
|
if (data.errors) {
|
|
42
32
|
throw new Error(`GraphQL errors: ${JSON.stringify(data.errors)}`);
|
|
43
33
|
}
|
|
44
|
-
if (!
|
|
34
|
+
if (!data.data?.teams) {
|
|
45
35
|
return {
|
|
46
36
|
success: false,
|
|
47
37
|
error: "No teams found",
|
|
@@ -64,5 +54,5 @@ const getTeams = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams
|
|
|
64
54
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
65
55
|
};
|
|
66
56
|
}
|
|
67
|
-
}
|
|
57
|
+
};
|
|
68
58
|
export default getTeams;
|
|
@@ -1,14 +1,5 @@
|
|
|
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
|
-
const enableUserByEmail =
|
|
2
|
+
const enableUserByEmail = async ({ params, authParams, }) => {
|
|
12
3
|
const { userEmail } = params;
|
|
13
4
|
const { baseUrl, clientId, clientSecret, authToken } = authParams;
|
|
14
5
|
if (!baseUrl) {
|
|
@@ -25,7 +16,7 @@ const enableUserByEmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
25
16
|
try {
|
|
26
17
|
// Use client_id and client_secret as URL query parameters
|
|
27
18
|
const loginUrl = `${baseUrl}/api/4.0/login?client_id=${encodeURIComponent(clientId)}&client_secret=${encodeURIComponent(clientSecret)}`;
|
|
28
|
-
const loginResponse =
|
|
19
|
+
const loginResponse = await axiosClient.post(loginUrl, {});
|
|
29
20
|
accessToken = loginResponse.data.access_token;
|
|
30
21
|
if (!accessToken) {
|
|
31
22
|
throw new Error("Failed to obtain authentication token from Looker API");
|
|
@@ -47,7 +38,7 @@ const enableUserByEmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
47
38
|
// Step 2: Search for the user by email
|
|
48
39
|
const searchUrl = `${baseUrl}/api/4.0/users/search?email=${encodeURIComponent(userEmail)}`;
|
|
49
40
|
console.log("Searching for user:", searchUrl);
|
|
50
|
-
const searchResponse =
|
|
41
|
+
const searchResponse = await axiosClient.get(searchUrl, { headers });
|
|
51
42
|
console.log("Search response:", searchResponse.data);
|
|
52
43
|
const users = searchResponse.data;
|
|
53
44
|
if (!users || users.length === 0) {
|
|
@@ -75,7 +66,7 @@ const enableUserByEmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
75
66
|
// Step 4: Enable the user (no confirmation check, automatically enable)
|
|
76
67
|
const updateUrl = `${baseUrl}/api/4.0/users/${user.id}`;
|
|
77
68
|
console.log("Enabling user:", updateUrl);
|
|
78
|
-
const updateResponse =
|
|
69
|
+
const updateResponse = await axiosClient.patch(updateUrl, {
|
|
79
70
|
is_disabled: false,
|
|
80
71
|
}, { headers });
|
|
81
72
|
console.log("Update response:", updateResponse.data);
|
|
@@ -100,5 +91,5 @@ const enableUserByEmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
100
91
|
message: error instanceof Error ? error.message : "Unknown error occurred",
|
|
101
92
|
};
|
|
102
93
|
}
|
|
103
|
-
}
|
|
94
|
+
};
|
|
104
95
|
export default enableUserByEmail;
|
|
@@ -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 mathAdd = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params }) {
|
|
1
|
+
const mathAdd = async ({ params }) => {
|
|
11
2
|
return {
|
|
12
3
|
result: params.a + params.b,
|
|
13
4
|
};
|
|
14
|
-
}
|
|
5
|
+
};
|
|
15
6
|
export default mathAdd;
|
|
@@ -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 { getGraphClient, validateAndSanitizeFileName } from "./utils.js";
|
|
11
|
-
const createDocument =
|
|
2
|
+
const createDocument = async ({ params, authParams, }) => {
|
|
12
3
|
const { folderId, name, content, siteId } = params;
|
|
13
4
|
let client = undefined;
|
|
14
5
|
try {
|
|
15
|
-
client =
|
|
6
|
+
client = await getGraphClient(authParams);
|
|
16
7
|
}
|
|
17
8
|
catch (error) {
|
|
18
9
|
return {
|
|
@@ -25,7 +16,7 @@ const createDocument = (_a) => __awaiter(void 0, [_a], void 0, function* ({ para
|
|
|
25
16
|
const endpoint = `${apiEndpointPrefix}/drive/items/${folderId || "root"}:/${sanitizedFileName}:/content`;
|
|
26
17
|
try {
|
|
27
18
|
// Create or update the document
|
|
28
|
-
const response =
|
|
19
|
+
const response = await client.api(endpoint).put(content);
|
|
29
20
|
return {
|
|
30
21
|
success: true,
|
|
31
22
|
documentId: response.id,
|
|
@@ -40,5 +31,5 @@ const createDocument = (_a) => __awaiter(void 0, [_a], void 0, function* ({ para
|
|
|
40
31
|
error: error instanceof Error ? error.message : "Unknown error occurred",
|
|
41
32
|
};
|
|
42
33
|
}
|
|
43
|
-
}
|
|
34
|
+
};
|
|
44
35
|
export default createDocument;
|
|
@@ -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 { getGraphClient } from "./utils.js";
|
|
11
|
-
const getDocument =
|
|
2
|
+
const getDocument = async ({ params, authParams, }) => {
|
|
12
3
|
const { siteId, documentId } = params;
|
|
13
4
|
let client;
|
|
14
5
|
try {
|
|
15
|
-
client =
|
|
6
|
+
client = await getGraphClient(authParams);
|
|
16
7
|
}
|
|
17
8
|
catch (error) {
|
|
18
9
|
return {
|
|
@@ -26,7 +17,7 @@ const getDocument = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
|
|
|
26
17
|
? `/sites/${siteId}/drive/items/${documentId}/content`
|
|
27
18
|
: `/me/drive/items/${documentId}/content`;
|
|
28
19
|
// Fetch the document content
|
|
29
|
-
const response =
|
|
20
|
+
const response = await client.api(endpoint).get();
|
|
30
21
|
return {
|
|
31
22
|
success: true,
|
|
32
23
|
content: response, // Assuming the response contains the document content
|
|
@@ -39,5 +30,5 @@ const getDocument = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
|
|
|
39
30
|
error: error instanceof Error ? error.message : "Unknown error occurred",
|
|
40
31
|
};
|
|
41
32
|
}
|
|
42
|
-
}
|
|
33
|
+
};
|
|
43
34
|
export default getDocument;
|
|
@@ -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 { getGraphClient } from "./utils.js";
|
|
11
|
-
const sendMessageToTeamsChannel =
|
|
2
|
+
const sendMessageToTeamsChannel = async ({ params, authParams, }) => {
|
|
12
3
|
const { channelId, teamId, message } = params;
|
|
13
4
|
let client = undefined;
|
|
14
5
|
try {
|
|
15
|
-
client =
|
|
6
|
+
client = await getGraphClient(authParams);
|
|
16
7
|
}
|
|
17
8
|
catch (error) {
|
|
18
9
|
return {
|
|
@@ -21,7 +12,7 @@ const sendMessageToTeamsChannel = (_a) => __awaiter(void 0, [_a], void 0, functi
|
|
|
21
12
|
};
|
|
22
13
|
}
|
|
23
14
|
try {
|
|
24
|
-
const response =
|
|
15
|
+
const response = await client.api(`/teams/${teamId}/channels/${channelId}/messages`).post({
|
|
25
16
|
body: {
|
|
26
17
|
content: message,
|
|
27
18
|
},
|
|
@@ -38,5 +29,5 @@ const sendMessageToTeamsChannel = (_a) => __awaiter(void 0, [_a], void 0, functi
|
|
|
38
29
|
error: "Error sending message: " + (error instanceof Error ? error.message : "Unknown error"),
|
|
39
30
|
};
|
|
40
31
|
}
|
|
41
|
-
}
|
|
32
|
+
};
|
|
42
33
|
export default sendMessageToTeamsChannel;
|
|
@@ -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 { getGraphClient } from "./utils.js";
|
|
11
|
-
const sendMessageToTeamsChat =
|
|
2
|
+
const sendMessageToTeamsChat = async ({ params, authParams, }) => {
|
|
12
3
|
const { chatId, message } = params;
|
|
13
4
|
let client = undefined;
|
|
14
5
|
try {
|
|
15
|
-
client =
|
|
6
|
+
client = await getGraphClient(authParams);
|
|
16
7
|
}
|
|
17
8
|
catch (error) {
|
|
18
9
|
return {
|
|
@@ -21,7 +12,7 @@ const sendMessageToTeamsChat = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
21
12
|
};
|
|
22
13
|
}
|
|
23
14
|
try {
|
|
24
|
-
const response =
|
|
15
|
+
const response = await client.api(`/chats/${chatId}/messages`).post({
|
|
25
16
|
body: {
|
|
26
17
|
content: message,
|
|
27
18
|
},
|
|
@@ -38,5 +29,5 @@ const sendMessageToTeamsChat = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
38
29
|
error: "Error sending message: " + (error instanceof Error ? error.message : "Unknown error"),
|
|
39
30
|
};
|
|
40
31
|
}
|
|
41
|
-
}
|
|
32
|
+
};
|
|
42
33
|
export default sendMessageToTeamsChat;
|
|
@@ -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 { getGraphClient } from "./utils.js";
|
|
11
|
-
const updateDocument =
|
|
2
|
+
const updateDocument = async ({ params, authParams, }) => {
|
|
12
3
|
const { documentId, content, siteId } = params;
|
|
13
4
|
let client = undefined;
|
|
14
5
|
try {
|
|
15
|
-
client =
|
|
6
|
+
client = await getGraphClient(authParams);
|
|
16
7
|
}
|
|
17
8
|
catch (error) {
|
|
18
9
|
return {
|
|
@@ -25,7 +16,7 @@ const updateDocument = (_a) => __awaiter(void 0, [_a], void 0, function* ({ para
|
|
|
25
16
|
const endpoint = siteId
|
|
26
17
|
? `/sites/${siteId}/drive/items/${documentId}/content`
|
|
27
18
|
: `/me/drive/items/${documentId}/content`;
|
|
28
|
-
const response =
|
|
19
|
+
const response = await client.api(endpoint).put(content);
|
|
29
20
|
return {
|
|
30
21
|
success: true,
|
|
31
22
|
documentUrl: response.webUrl,
|
|
@@ -38,5 +29,5 @@ const updateDocument = (_a) => __awaiter(void 0, [_a], void 0, function* ({ para
|
|
|
38
29
|
error: error instanceof Error ? error.message : "Unknown error occurred",
|
|
39
30
|
};
|
|
40
31
|
}
|
|
41
|
-
}
|
|
32
|
+
};
|
|
42
33
|
export default updateDocument;
|