@credal/actions 0.2.107 → 0.2.109
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 +7 -1
- package/dist/actions/autogen/templates.d.ts +1 -0
- package/dist/actions/autogen/templates.js +315 -1
- package/dist/actions/autogen/types.d.ts +612 -0
- package/dist/actions/autogen/types.js +133 -0
- package/dist/actions/groups.js +11 -1
- package/dist/actions/providers/confluence/updatePage.d.ts +3 -0
- package/dist/actions/providers/confluence/updatePage.js +46 -0
- package/dist/actions/providers/credal/callCopilot.d.ts +3 -0
- package/dist/actions/providers/credal/callCopilot.js +36 -0
- package/dist/actions/providers/generic/fillTemplateAction.d.ts +7 -0
- package/dist/actions/providers/generic/fillTemplateAction.js +18 -0
- package/dist/actions/providers/generic/genericApiCall.d.ts +3 -0
- package/dist/actions/providers/generic/genericApiCall.js +38 -0
- package/dist/actions/providers/github/getBranch.d.ts +7 -0
- package/dist/actions/providers/github/getBranch.js +67 -0
- package/dist/actions/providers/google-oauth/editAGoogleCalendarEvent.js +9 -1
- package/dist/actions/providers/google-oauth/getDriveContentById.d.ts +3 -0
- package/dist/actions/providers/google-oauth/getDriveContentById.js +161 -0
- package/dist/actions/providers/google-oauth/listCalendarEvents.js +3 -0
- package/dist/actions/providers/google-oauth/scheduleCalendarMeeting.d.ts +1 -0
- package/dist/actions/providers/google-oauth/scheduleCalendarMeeting.js +50 -4
- package/dist/actions/providers/google-oauth/searchAndGetDriveContentByKeywords.d.ts +3 -0
- package/dist/actions/providers/google-oauth/searchAndGetDriveContentByKeywords.js +47 -0
- package/dist/actions/providers/google-oauth/searchDriveAndGetContentByKeywords.d.ts +3 -0
- package/dist/actions/providers/google-oauth/searchDriveAndGetContentByKeywords.js +110 -0
- package/dist/actions/providers/google-oauth/searchDriveAndGetContentByQuery.d.ts +3 -0
- package/dist/actions/providers/google-oauth/searchDriveAndGetContentByQuery.js +78 -0
- package/dist/actions/providers/google-oauth/utils/extractContentFromDriveFileId.d.ts +15 -0
- package/dist/actions/providers/google-oauth/utils/extractContentFromDriveFileId.js +129 -0
- package/dist/actions/providers/googlemaps/nearbysearch.d.ts +3 -0
- package/dist/actions/providers/googlemaps/nearbysearch.js +96 -0
- package/dist/actions/providers/math/index.d.ts +1 -0
- package/dist/actions/providers/math/index.js +37 -0
- package/dist/actions/providers/slack/index.d.ts +1 -0
- package/dist/actions/providers/slack/index.js +37 -0
- package/dist/actions/providers/slack/listConversations.d.ts +3 -0
- package/dist/actions/providers/slack/listConversations.js +41 -0
- package/dist/actions/providers/snowflake/runSnowflakeQueryWriteResultsToS3.d.ts +3 -0
- package/dist/actions/providers/snowflake/runSnowflakeQueryWriteResultsToS3.js +154 -0
- package/dist/actions/providers/x/scrapeTweetDataWithNitter.d.ts +3 -0
- package/dist/actions/providers/x/scrapeTweetDataWithNitter.js +45 -0
- package/dist/actions/providers/zendesk/addCommentToTicket.js +2 -1
- package/dist/actions/providers/zendesk/assignTicket.js +2 -1
- package/dist/actions/providers/zendesk/createZendeskTicket.js +2 -1
- package/dist/actions/providers/zendesk/getTicketDetails.js +3 -2
- package/dist/actions/providers/zendesk/listTickets.js +2 -1
- package/dist/actions/providers/zendesk/searchZendeskByQuery.js +2 -1
- package/dist/actions/providers/zendesk/updateTicketStatus.js +2 -1
- package/dist/actions/util/axiosClient.d.ts +4 -1
- package/dist/actions/util/axiosClient.js +7 -3
- package/dist/utils/datetime.d.ts +1 -0
- package/dist/utils/datetime.js +7 -0
- package/package.json +1 -1
- package/dist/actions/providers/github/fetchFile.d.ts +0 -3
- package/dist/actions/providers/github/fetchFile.js +0 -131
- package/dist/actions/providers/github/getContents.d.ts +0 -3
- package/dist/actions/providers/github/getContents.js +0 -41
|
@@ -1541,11 +1541,32 @@ export const googleOauthScheduleCalendarMeetingParamsSchema = z.object({
|
|
|
1541
1541
|
.string()
|
|
1542
1542
|
.describe("The time zone for the meeting, IANA Time Zone identifier (e.g., 'America/New_York')")
|
|
1543
1543
|
.optional(),
|
|
1544
|
+
recurrence: z
|
|
1545
|
+
.object({
|
|
1546
|
+
frequency: z.enum(["DAILY", "WEEKLY", "MONTHLY", "YEARLY"]).describe("How often the meeting repeats").optional(),
|
|
1547
|
+
interval: z.number().int().gte(1).describe("The interval between recurrences (e.g., every 2 weeks)").optional(),
|
|
1548
|
+
count: z.number().int().gte(1).describe("Number of occurrences after which to stop the recurrence").optional(),
|
|
1549
|
+
until: z.string().describe("End date for the recurrence in RFC3339 format (YYYY-MM-DDTHH:MM:SSZ)").optional(),
|
|
1550
|
+
byDay: z
|
|
1551
|
+
.array(z.enum(["MO", "TU", "WE", "TH", "FR", "SA", "SU"]))
|
|
1552
|
+
.describe("Days of the week when the meeting occurs (for WEEKLY frequency)")
|
|
1553
|
+
.optional(),
|
|
1554
|
+
byMonthDay: z
|
|
1555
|
+
.array(z.number().int().gte(1).lte(31))
|
|
1556
|
+
.describe("Days of the month when the meeting occurs (for MONTHLY frequency)")
|
|
1557
|
+
.optional(),
|
|
1558
|
+
})
|
|
1559
|
+
.describe("Recurring meeting configuration. If not provided, creates a one-time meeting.")
|
|
1560
|
+
.optional(),
|
|
1544
1561
|
});
|
|
1545
1562
|
export const googleOauthScheduleCalendarMeetingOutputSchema = z.object({
|
|
1546
1563
|
success: z.boolean().describe("Whether the meeting was scheduled successfully"),
|
|
1547
1564
|
eventId: z.string().describe("The ID of the event that was scheduled").optional(),
|
|
1548
1565
|
eventUrl: z.string().describe("The URL to access the scheduled event").optional(),
|
|
1566
|
+
eventDayOfWeek: z
|
|
1567
|
+
.string()
|
|
1568
|
+
.describe("The day of the week when the event is scheduled (e.g., Monday, Tuesday, etc.)")
|
|
1569
|
+
.optional(),
|
|
1549
1570
|
error: z.string().describe("The error that occurred if the meeting was not scheduled successfully").optional(),
|
|
1550
1571
|
});
|
|
1551
1572
|
export const googleOauthListCalendarsParamsSchema = z.object({
|
|
@@ -1583,7 +1604,15 @@ export const googleOauthListCalendarEventsOutputSchema = z.object({
|
|
|
1583
1604
|
description: z.string().describe("Description of the event").optional(),
|
|
1584
1605
|
location: z.string().describe("Geographic location of the event as free-form text").optional(),
|
|
1585
1606
|
start: z.string().describe("Start date/time (for timed events, RFC3339 timestamp)").optional(),
|
|
1607
|
+
startDayOfWeek: z
|
|
1608
|
+
.string()
|
|
1609
|
+
.describe("The day of the week when the event starts (e.g., Monday, Tuesday, etc.)")
|
|
1610
|
+
.optional(),
|
|
1586
1611
|
end: z.string().describe("End date/time (for timed events, RFC3339 timestamp)").optional(),
|
|
1612
|
+
endDayOfWeek: z
|
|
1613
|
+
.string()
|
|
1614
|
+
.describe("The day of the week when the event ends (e.g., Monday, Tuesday, etc.)")
|
|
1615
|
+
.optional(),
|
|
1587
1616
|
attendees: z
|
|
1588
1617
|
.array(z.object({
|
|
1589
1618
|
email: z.string().describe("The attendee's email address").optional(),
|
|
@@ -1679,6 +1708,10 @@ export const googleOauthEditAGoogleCalendarEventOutputSchema = z.object({
|
|
|
1679
1708
|
success: z.boolean().describe("Whether the event was edited successfully"),
|
|
1680
1709
|
eventId: z.string().describe("The ID of the edited event").optional(),
|
|
1681
1710
|
eventUrl: z.string().describe("The URL to access the edited event").optional(),
|
|
1711
|
+
eventDayOfWeek: z
|
|
1712
|
+
.string()
|
|
1713
|
+
.describe("The day of the week when the edited event occurs (e.g., Monday, Tuesday, etc.)")
|
|
1714
|
+
.optional(),
|
|
1682
1715
|
error: z.string().describe("The error that occurred if the event was not edited successfully").optional(),
|
|
1683
1716
|
});
|
|
1684
1717
|
export const googleOauthDeleteCalendarEventParamsSchema = z.object({
|
|
@@ -3823,6 +3856,106 @@ export const githubSearchOrganizationOutputSchema = z.object({
|
|
|
3823
3856
|
}))
|
|
3824
3857
|
.describe("A list of issues and pull requests that match the query"),
|
|
3825
3858
|
});
|
|
3859
|
+
export const githubGetBranchParamsSchema = z.object({
|
|
3860
|
+
repositoryOwner: z.string().describe("The owner of the repository"),
|
|
3861
|
+
repositoryName: z.string().describe("The name of the repository"),
|
|
3862
|
+
branchName: z.string().describe("The name of the branch to retrieve"),
|
|
3863
|
+
});
|
|
3864
|
+
export const githubGetBranchOutputSchema = z.object({
|
|
3865
|
+
success: z.boolean().describe("Whether the operation was successful"),
|
|
3866
|
+
error: z.string().describe("The error that occurred if the operation was not successful").optional(),
|
|
3867
|
+
branch: z
|
|
3868
|
+
.object({
|
|
3869
|
+
name: z.string().describe("The name of the branch").optional(),
|
|
3870
|
+
commit: z
|
|
3871
|
+
.object({
|
|
3872
|
+
sha: z.string().describe("The SHA of the commit").optional(),
|
|
3873
|
+
node_id: z.string().describe("The node ID of the commit").optional(),
|
|
3874
|
+
url: z.string().describe("The API URL of the commit").optional(),
|
|
3875
|
+
html_url: z.string().describe("The HTML URL of the commit").optional(),
|
|
3876
|
+
comments_url: z.string().describe("The URL for commit comments").optional(),
|
|
3877
|
+
commit: z
|
|
3878
|
+
.object({
|
|
3879
|
+
author: z
|
|
3880
|
+
.object({ name: z.string().optional(), email: z.string().optional(), date: z.string().optional() })
|
|
3881
|
+
.nullable()
|
|
3882
|
+
.describe("The commit author")
|
|
3883
|
+
.optional(),
|
|
3884
|
+
committer: z
|
|
3885
|
+
.object({ name: z.string().optional(), email: z.string().optional(), date: z.string().optional() })
|
|
3886
|
+
.nullable()
|
|
3887
|
+
.describe("The commit committer")
|
|
3888
|
+
.optional(),
|
|
3889
|
+
message: z.string().describe("The commit message").optional(),
|
|
3890
|
+
tree: z
|
|
3891
|
+
.object({ sha: z.string().optional(), url: z.string().optional() })
|
|
3892
|
+
.describe("The commit tree")
|
|
3893
|
+
.optional(),
|
|
3894
|
+
url: z.string().describe("The commit URL").optional(),
|
|
3895
|
+
comment_count: z.number().int().describe("Number of comments on the commit").optional(),
|
|
3896
|
+
})
|
|
3897
|
+
.describe("The git commit object")
|
|
3898
|
+
.optional(),
|
|
3899
|
+
author: z
|
|
3900
|
+
.object({
|
|
3901
|
+
login: z.string().optional(),
|
|
3902
|
+
id: z.number().int().optional(),
|
|
3903
|
+
node_id: z.string().optional(),
|
|
3904
|
+
avatar_url: z.string().optional(),
|
|
3905
|
+
html_url: z.string().optional(),
|
|
3906
|
+
type: z.string().optional(),
|
|
3907
|
+
})
|
|
3908
|
+
.nullable()
|
|
3909
|
+
.describe("The commit author user")
|
|
3910
|
+
.optional(),
|
|
3911
|
+
committer: z
|
|
3912
|
+
.object({
|
|
3913
|
+
login: z.string().optional(),
|
|
3914
|
+
id: z.number().int().optional(),
|
|
3915
|
+
node_id: z.string().optional(),
|
|
3916
|
+
avatar_url: z.string().optional(),
|
|
3917
|
+
html_url: z.string().optional(),
|
|
3918
|
+
type: z.string().optional(),
|
|
3919
|
+
})
|
|
3920
|
+
.nullable()
|
|
3921
|
+
.describe("The commit committer user")
|
|
3922
|
+
.optional(),
|
|
3923
|
+
parents: z
|
|
3924
|
+
.array(z.object({ sha: z.string().optional(), url: z.string().optional(), html_url: z.string().optional() }))
|
|
3925
|
+
.describe("The commit parents")
|
|
3926
|
+
.optional(),
|
|
3927
|
+
})
|
|
3928
|
+
.describe("The commit information")
|
|
3929
|
+
.optional(),
|
|
3930
|
+
_links: z
|
|
3931
|
+
.object({
|
|
3932
|
+
html: z.string().describe("The HTML URL of the branch").optional(),
|
|
3933
|
+
self: z.string().describe("The API URL of the branch").optional(),
|
|
3934
|
+
})
|
|
3935
|
+
.describe("Links related to the branch")
|
|
3936
|
+
.optional(),
|
|
3937
|
+
protected: z.boolean().describe("Whether the branch is protected").optional(),
|
|
3938
|
+
protection: z
|
|
3939
|
+
.object({
|
|
3940
|
+
enabled: z.boolean().describe("Whether protection is enabled").optional(),
|
|
3941
|
+
required_status_checks: z
|
|
3942
|
+
.object({
|
|
3943
|
+
enforcement_level: z.string().optional(),
|
|
3944
|
+
contexts: z.array(z.string()).optional(),
|
|
3945
|
+
strict: z.boolean().optional(),
|
|
3946
|
+
})
|
|
3947
|
+
.nullable()
|
|
3948
|
+
.describe("Required status checks")
|
|
3949
|
+
.optional(),
|
|
3950
|
+
})
|
|
3951
|
+
.nullable()
|
|
3952
|
+
.describe("Branch protection details")
|
|
3953
|
+
.optional(),
|
|
3954
|
+
protection_url: z.string().describe("The URL of the branch protection settings").optional(),
|
|
3955
|
+
})
|
|
3956
|
+
.describe("The branch information")
|
|
3957
|
+
.optional(),
|
|
3958
|
+
});
|
|
3826
3959
|
export const githubListCommitsParamsSchema = z.object({
|
|
3827
3960
|
repositoryOwner: z.string().describe("The owner of the repository"),
|
|
3828
3961
|
repositoryName: z.string().describe("The name of the repository"),
|
package/dist/actions/groups.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { genericFillTemplateDefinition, confluenceOverwritePageDefinition, googlemapsValidateAddressDefinition, mathAddDefinition, mongoInsertMongoDocDefinition, slackSendMessageDefinition, slackGetChannelMessagesDefinition, slackCreateChannelDefinition, slackArchiveChannelDefinition, snowflakeGetRowByFieldValueDefinition, zendeskCreateZendeskTicketDefinition, zendeskListZendeskTicketsDefinition, zendeskGetTicketDetailsDefinition, zendeskUpdateTicketStatusDefinition, zendeskAddCommentToTicketDefinition, zendeskAssignTicketDefinition, openstreetmapGetLatitudeLongitudeFromLocationDefinition, nwsGetForecastForLocationDefinition, jiraAssignJiraTicketDefinition, jiraCommentJiraTicketDefinition, jiraCreateJiraTicketDefinition, jiraGetJiraTicketDetailsDefinition, jiraGetJiraTicketHistoryDefinition, jiraUpdateJiraTicketDetailsDefinition, jiraUpdateJiraTicketStatusDefinition, jiraGetServiceDesksDefinition, jiraCreateServiceDeskRequestDefinition, googlemapsNearbysearchRestaurantsDefinition, firecrawlScrapeUrlDefinition, resendSendEmailDefinition, linkedinCreateShareLinkedinPostUrlDefinition, googleOauthCreateNewGoogleDocDefinition, xCreateShareXPostUrlDefinition, firecrawlScrapeTweetDataWithNitterDefinition, finnhubSymbolLookupDefinition, finnhubGetBasicFinancialsDefinition, confluenceFetchPageContentDefinition, snowflakeRunSnowflakeQueryDefinition, lookerEnableUserByEmailDefinition, googleOauthUpdateDocDefinition, googleOauthScheduleCalendarMeetingDefinition, googleOauthListCalendarsDefinition, googleOauthListCalendarEventsDefinition, googleOauthUpdateCalendarEventDefinition, googleOauthDeleteCalendarEventDefinition, googleOauthCreateSpreadsheetDefinition, googleOauthUpdateSpreadsheetDefinition, googleOauthCreatePresentationDefinition, googleOauthUpdatePresentationDefinition, googleOauthSearchDriveByKeywordsDefinition, googlemailSearchGmailMessagesDefinition, googlemailListGmailThreadsDefinition, googleOauthListGroupsDefinition, googleOauthGetGroupDefinition, googleOauthListGroupMembersDefinition, googleOauthHasGroupMemberDefinition, googleOauthAddGroupMemberDefinition, googleOauthDeleteGroupMemberDefinition, salesforceUpdateRecordDefinition, salesforceCreateCaseDefinition, salesforceGenerateSalesReportDefinition, salesforceGetRecordDefinition, salesforceGetSalesforceRecordsByQueryDefinition, microsoftMessageTeamsChatDefinition, microsoftMessageTeamsChannelDefinition, asanaCommentTaskDefinition, asanaCreateTaskDefinition, asanaUpdateTaskDefinition, asanaSearchTasksDefinition, githubCreateOrUpdateFileDefinition, githubCreateBranchDefinition, githubCreatePullRequestDefinition, microsoftUpdateSpreadsheetDefinition, microsoftUpdateDocumentDefinition, microsoftCreateDocumentDefinition, microsoftGetDocumentDefinition, salesforceFetchSalesforceSchemaByObjectDefinition, firecrawlDeepResearchDefinition, jiraGetJiraIssuesByQueryDefinition, githubListPullRequestsDefinition, salesforceCreateRecordDefinition, ashbyCreateNoteDefinition, ashbyGetCandidateInfoDefinition, ashbyListCandidatesDefinition, ashbyListCandidateNotesDefinition, ashbySearchCandidatesDefinition, ashbyCreateCandidateDefinition, ashbyUpdateCandidateDefinition, ashbyAddCandidateToProjectDefinition, bingGetTopNSearchResultUrlsDefinition, gongGetGongTranscriptsDefinition, kandjiGetFVRecoveryKeyForDeviceDefinition, asanaListAsanaTasksByProjectDefinition, notionSearchByTitleDefinition, asanaGetTasksDetailsDefinition, jamfGetJamfComputerInventoryDefinition, jamfGetJamfFileVaultRecoveryKeyDefinition, oktaListOktaUsersDefinition, oktaGetOktaUserDefinition, oktaListOktaUserGroupsDefinition, oktaListOktaGroupsDefinition, oktaGetOktaGroupDefinition, oktaListOktaGroupMembersDefinition, oktaRemoveUserFromGroupDefinition, oktaAddUserToGroupDefinition, oktaResetPasswordDefinition, oktaResetMFADefinition, oktaListMFADefinition, jamfGetJamfUserComputerIdDefinition, jamfLockJamfComputerByIdDefinition, oktaTriggerOktaWorkflowDefinition, jiraOrgAssignJiraTicketDefinition, jiraOrgCreateJiraTicketDefinition, jiraOrgCommentJiraTicketDefinition, jiraOrgGetJiraTicketDetailsDefinition, jiraOrgGetJiraTicketHistoryDefinition, jiraOrgUpdateJiraTicketDetailsDefinition, jiraOrgUpdateJiraTicketStatusDefinition, jiraOrgGetJiraIssuesByQueryDefinition, googleOauthGetDriveFileContentByIdDefinition, googleOauthSearchDriveByQueryDefinition, googleOauthSearchDriveByQueryAndGetFileContentDefinition, githubGetFileContentDefinition, githubListDirectoryDefinition, } from "./autogen/templates.js";
|
|
1
|
+
import { genericFillTemplateDefinition, confluenceOverwritePageDefinition, googlemapsValidateAddressDefinition, mathAddDefinition, mongoInsertMongoDocDefinition, slackSendMessageDefinition, slackGetChannelMessagesDefinition, slackCreateChannelDefinition, slackArchiveChannelDefinition, snowflakeGetRowByFieldValueDefinition, zendeskCreateZendeskTicketDefinition, zendeskListZendeskTicketsDefinition, zendeskGetTicketDetailsDefinition, zendeskUpdateTicketStatusDefinition, zendeskAddCommentToTicketDefinition, zendeskAssignTicketDefinition, openstreetmapGetLatitudeLongitudeFromLocationDefinition, nwsGetForecastForLocationDefinition, jiraAssignJiraTicketDefinition, jiraCommentJiraTicketDefinition, jiraCreateJiraTicketDefinition, jiraGetJiraTicketDetailsDefinition, jiraGetJiraTicketHistoryDefinition, jiraUpdateJiraTicketDetailsDefinition, jiraUpdateJiraTicketStatusDefinition, jiraGetServiceDesksDefinition, jiraCreateServiceDeskRequestDefinition, googlemapsNearbysearchRestaurantsDefinition, firecrawlScrapeUrlDefinition, resendSendEmailDefinition, linkedinCreateShareLinkedinPostUrlDefinition, googleOauthCreateNewGoogleDocDefinition, xCreateShareXPostUrlDefinition, firecrawlScrapeTweetDataWithNitterDefinition, finnhubSymbolLookupDefinition, finnhubGetBasicFinancialsDefinition, confluenceFetchPageContentDefinition, snowflakeRunSnowflakeQueryDefinition, lookerEnableUserByEmailDefinition, googleOauthUpdateDocDefinition, googleOauthScheduleCalendarMeetingDefinition, googleOauthListCalendarsDefinition, googleOauthListCalendarEventsDefinition, googleOauthUpdateCalendarEventDefinition, googleOauthDeleteCalendarEventDefinition, googleOauthCreateSpreadsheetDefinition, googleOauthUpdateSpreadsheetDefinition, googleOauthCreatePresentationDefinition, googleOauthUpdatePresentationDefinition, googleOauthSearchDriveByKeywordsDefinition, googlemailSearchGmailMessagesDefinition, googlemailListGmailThreadsDefinition, googleOauthListGroupsDefinition, googleOauthGetGroupDefinition, googleOauthListGroupMembersDefinition, googleOauthHasGroupMemberDefinition, googleOauthAddGroupMemberDefinition, googleOauthDeleteGroupMemberDefinition, salesforceUpdateRecordDefinition, salesforceCreateCaseDefinition, salesforceGenerateSalesReportDefinition, salesforceGetRecordDefinition, salesforceGetSalesforceRecordsByQueryDefinition, microsoftMessageTeamsChatDefinition, microsoftMessageTeamsChannelDefinition, asanaCommentTaskDefinition, asanaCreateTaskDefinition, asanaUpdateTaskDefinition, asanaSearchTasksDefinition, githubCreateOrUpdateFileDefinition, githubCreateBranchDefinition, githubCreatePullRequestDefinition, microsoftUpdateSpreadsheetDefinition, microsoftUpdateDocumentDefinition, microsoftCreateDocumentDefinition, microsoftGetDocumentDefinition, salesforceFetchSalesforceSchemaByObjectDefinition, firecrawlDeepResearchDefinition, jiraGetJiraIssuesByQueryDefinition, githubListPullRequestsDefinition, salesforceCreateRecordDefinition, ashbyCreateNoteDefinition, ashbyGetCandidateInfoDefinition, ashbyListCandidatesDefinition, ashbyListCandidateNotesDefinition, ashbySearchCandidatesDefinition, ashbyCreateCandidateDefinition, ashbyUpdateCandidateDefinition, ashbyAddCandidateToProjectDefinition, bingGetTopNSearchResultUrlsDefinition, gongGetGongTranscriptsDefinition, kandjiGetFVRecoveryKeyForDeviceDefinition, asanaListAsanaTasksByProjectDefinition, notionSearchByTitleDefinition, asanaGetTasksDetailsDefinition, linearGetIssueDetailsDefinition, linearGetProjectsDefinition, linearGetProjectDetailsDefinition, linearGetTeamDetailsDefinition, linearGetTeamsDefinition, jamfGetJamfComputerInventoryDefinition, jamfGetJamfFileVaultRecoveryKeyDefinition, oktaListOktaUsersDefinition, oktaGetOktaUserDefinition, oktaListOktaUserGroupsDefinition, oktaListOktaGroupsDefinition, oktaGetOktaGroupDefinition, oktaListOktaGroupMembersDefinition, oktaRemoveUserFromGroupDefinition, oktaAddUserToGroupDefinition, oktaResetPasswordDefinition, oktaResetMFADefinition, oktaListMFADefinition, jamfGetJamfUserComputerIdDefinition, jamfLockJamfComputerByIdDefinition, oktaTriggerOktaWorkflowDefinition, jiraOrgAssignJiraTicketDefinition, jiraOrgCreateJiraTicketDefinition, jiraOrgCommentJiraTicketDefinition, jiraOrgGetJiraTicketDetailsDefinition, jiraOrgGetJiraTicketHistoryDefinition, jiraOrgUpdateJiraTicketDetailsDefinition, jiraOrgUpdateJiraTicketStatusDefinition, jiraOrgGetJiraIssuesByQueryDefinition, googleOauthGetDriveFileContentByIdDefinition, googleOauthSearchDriveByQueryDefinition, googleOauthSearchDriveByQueryAndGetFileContentDefinition, githubGetFileContentDefinition, githubListDirectoryDefinition, } from "./autogen/templates.js";
|
|
2
2
|
export const ACTION_GROUPS = {
|
|
3
3
|
GENERIC: {
|
|
4
4
|
description: "Generic utility actions",
|
|
@@ -248,4 +248,14 @@ export const ACTION_GROUPS = {
|
|
|
248
248
|
oktaTriggerOktaWorkflowDefinition,
|
|
249
249
|
],
|
|
250
250
|
},
|
|
251
|
+
LINEAR: {
|
|
252
|
+
description: "Actions for interacting with Linear",
|
|
253
|
+
actions: [
|
|
254
|
+
linearGetIssueDetailsDefinition,
|
|
255
|
+
linearGetProjectsDefinition,
|
|
256
|
+
linearGetProjectDetailsDefinition,
|
|
257
|
+
linearGetTeamDetailsDefinition,
|
|
258
|
+
linearGetTeamsDefinition,
|
|
259
|
+
],
|
|
260
|
+
},
|
|
251
261
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const axiosClient_1 = require("../../util/axiosClient");
|
|
13
|
+
function getConfluenceRequestConfig(baseUrl, username, apiToken) {
|
|
14
|
+
return {
|
|
15
|
+
baseURL: baseUrl,
|
|
16
|
+
headers: {
|
|
17
|
+
Accept: "application/json",
|
|
18
|
+
Authorization: `Basic ${Buffer.from(`${username}:${apiToken}`).toString("base64")}`,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
23
|
+
const { pageId, content, title } = params;
|
|
24
|
+
const { baseUrl, authToken, username } = authParams;
|
|
25
|
+
if (!baseUrl || !authToken || !username) {
|
|
26
|
+
throw new Error("Missing required authentication information");
|
|
27
|
+
}
|
|
28
|
+
const config = getConfluenceRequestConfig(baseUrl, username, authToken);
|
|
29
|
+
// Get current version number
|
|
30
|
+
const response = yield axiosClient_1.axiosClient.get(`/api/v2/pages/${pageId}`, config);
|
|
31
|
+
const currVersion = response.data.version.number;
|
|
32
|
+
const payload = {
|
|
33
|
+
id: pageId,
|
|
34
|
+
status: "current",
|
|
35
|
+
title,
|
|
36
|
+
body: {
|
|
37
|
+
representation: "storage",
|
|
38
|
+
value: content,
|
|
39
|
+
},
|
|
40
|
+
version: {
|
|
41
|
+
number: currVersion + 1,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
yield axiosClient_1.axiosClient.put(`/api/v2/pages/${pageId}`, payload, config);
|
|
45
|
+
});
|
|
46
|
+
exports.default = confluenceUpdatePage;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const sdk_1 = require("@credal/sdk");
|
|
13
|
+
const callCopilot = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
14
|
+
var _b;
|
|
15
|
+
const requestBody = {
|
|
16
|
+
agentId: params.agentId,
|
|
17
|
+
query: params.query,
|
|
18
|
+
userEmail: params.userEmail,
|
|
19
|
+
};
|
|
20
|
+
const baseUrl = (_b = authParams.baseUrl) !== null && _b !== void 0 ? _b : "https://app.credal.ai/api";
|
|
21
|
+
const client = new sdk_1.CredalClient({ environment: baseUrl, apiKey: authParams.apiKey });
|
|
22
|
+
const response = yield client.copilots.sendMessage({
|
|
23
|
+
agentId: requestBody.agentId,
|
|
24
|
+
message: requestBody.query,
|
|
25
|
+
userEmail: requestBody.userEmail,
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
response: response.sendChatResult.type === "ai_response_result"
|
|
29
|
+
? response.sendChatResult.response.message
|
|
30
|
+
: "Error getting response",
|
|
31
|
+
referencedSources: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.referencedSources : [],
|
|
32
|
+
sourcesInDataContext: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.sourcesInDataContext : [],
|
|
33
|
+
webSearchResults: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.webSearchResults : [],
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
exports.default = callCopilot;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const fillTemplateAction = (_a) => __awaiter(void 0, [_a], void 0, function* ({ template }) {
|
|
13
|
+
// Simply return the template without any modification
|
|
14
|
+
return {
|
|
15
|
+
result: template,
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
exports.default = fillTemplateAction;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
16
|
+
const genericApiCall = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, }) {
|
|
17
|
+
try {
|
|
18
|
+
const { endpoint, method, headers, body } = params;
|
|
19
|
+
const response = yield (0, axios_1.default)({
|
|
20
|
+
url: endpoint,
|
|
21
|
+
method,
|
|
22
|
+
headers,
|
|
23
|
+
data: method !== "GET" ? body : undefined,
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
statusCode: response.status,
|
|
27
|
+
headers: response.headers,
|
|
28
|
+
data: response.data,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
33
|
+
throw Error("Axios Error: " + (error.message || "Failed to make API call"));
|
|
34
|
+
}
|
|
35
|
+
throw Error("Error: " + (error || "Failed to make API call"));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
exports.default = genericApiCall;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { githubGetBranchFunction } from "../../autogen/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Get a branch in a GitHub repository
|
|
4
|
+
* https://docs.github.com/en/rest/branches/branches?apiVersion=2022-11-28#get-a-branch
|
|
5
|
+
*/
|
|
6
|
+
declare const getBranch: githubGetBranchFunction;
|
|
7
|
+
export default getBranch;
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
import { getOctokit } from "./utils.js";
|
|
12
|
+
/**
|
|
13
|
+
* Get a branch in a GitHub repository
|
|
14
|
+
* https://docs.github.com/en/rest/branches/branches?apiVersion=2022-11-28#get-a-branch
|
|
15
|
+
*/
|
|
16
|
+
const getBranch = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
17
|
+
if (!authParams.authToken) {
|
|
18
|
+
return {
|
|
19
|
+
success: false,
|
|
20
|
+
error: MISSING_AUTH_TOKEN,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const octokit = yield getOctokit(authParams.authToken);
|
|
24
|
+
const { repositoryOwner, repositoryName, branchName } = params;
|
|
25
|
+
try {
|
|
26
|
+
const response = yield octokit.rest.repos.getBranch({
|
|
27
|
+
owner: repositoryOwner,
|
|
28
|
+
repo: repositoryName,
|
|
29
|
+
branch: branchName,
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
success: true,
|
|
33
|
+
branch: {
|
|
34
|
+
name: response.data.name,
|
|
35
|
+
commit: {
|
|
36
|
+
sha: response.data.commit.sha,
|
|
37
|
+
node_id: response.data.commit.node_id,
|
|
38
|
+
url: response.data.commit.url,
|
|
39
|
+
html_url: response.data.commit.html_url,
|
|
40
|
+
comments_url: response.data.commit.comments_url,
|
|
41
|
+
commit: {
|
|
42
|
+
author: response.data.commit.commit.author,
|
|
43
|
+
committer: response.data.commit.commit.committer,
|
|
44
|
+
message: response.data.commit.commit.message,
|
|
45
|
+
tree: response.data.commit.commit.tree,
|
|
46
|
+
url: response.data.commit.commit.url,
|
|
47
|
+
comment_count: response.data.commit.commit.comment_count,
|
|
48
|
+
},
|
|
49
|
+
author: response.data.commit.author,
|
|
50
|
+
committer: response.data.commit.committer,
|
|
51
|
+
parents: response.data.commit.parents,
|
|
52
|
+
},
|
|
53
|
+
_links: response.data._links,
|
|
54
|
+
protected: response.data.protected,
|
|
55
|
+
protection: response.data.protection,
|
|
56
|
+
protection_url: response.data.protection_url,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
return {
|
|
62
|
+
success: false,
|
|
63
|
+
error: `Failed to get branch: ${error instanceof Error ? error.message : String(error)}`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
export default getBranch;
|
|
@@ -9,9 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
11
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
+
import { getDayOfWeek } from "../../../utils/datetime.js";
|
|
12
13
|
const editAGoogleCalendarEvent = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
14
|
+
var _b, _c;
|
|
13
15
|
if (!authParams.authToken) {
|
|
14
|
-
return { success: false, error: MISSING_AUTH_TOKEN, eventId: "", eventUrl: "" };
|
|
16
|
+
return { success: false, error: MISSING_AUTH_TOKEN, eventId: "", eventUrl: "", eventDayOfWeek: "" };
|
|
15
17
|
}
|
|
16
18
|
const { calendarId, eventId, title, description, start, end, location, attendees, status, organizer, timeZone } = params;
|
|
17
19
|
const url = `https://www.googleapis.com/calendar/v3/calendars/${encodeURIComponent(calendarId)}/events/${encodeURIComponent(eventId)}`;
|
|
@@ -47,10 +49,15 @@ const editAGoogleCalendarEvent = (_a) => __awaiter(void 0, [_a], void 0, functio
|
|
|
47
49
|
},
|
|
48
50
|
});
|
|
49
51
|
const { id, htmlLink } = res.data;
|
|
52
|
+
// Get the event day of week from the start time (use provided start or fetch from response)
|
|
53
|
+
const eventDayOfWeek = start
|
|
54
|
+
? getDayOfWeek(start)
|
|
55
|
+
: getDayOfWeek(((_b = res.data.start) === null || _b === void 0 ? void 0 : _b.dateTime) || ((_c = res.data.start) === null || _c === void 0 ? void 0 : _c.date) || "");
|
|
50
56
|
return {
|
|
51
57
|
success: true,
|
|
52
58
|
eventId: id,
|
|
53
59
|
eventUrl: htmlLink,
|
|
60
|
+
eventDayOfWeek,
|
|
54
61
|
};
|
|
55
62
|
}
|
|
56
63
|
catch (error) {
|
|
@@ -59,6 +66,7 @@ const editAGoogleCalendarEvent = (_a) => __awaiter(void 0, [_a], void 0, functio
|
|
|
59
66
|
error: error instanceof Error ? error.message : "Unknown error editing event",
|
|
60
67
|
eventId: "",
|
|
61
68
|
eventUrl: "",
|
|
69
|
+
eventDayOfWeek: "",
|
|
62
70
|
};
|
|
63
71
|
}
|
|
64
72
|
});
|
|
@@ -0,0 +1,161 @@
|
|
|
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 pdf from "pdf-parse/lib/pdf-parse.js";
|
|
11
|
+
import { axiosClient } from "../../util/axiosClient.js";
|
|
12
|
+
import mammoth from "mammoth";
|
|
13
|
+
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
14
|
+
const getDriveFileContentByID = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
15
|
+
if (!authParams.authToken) {
|
|
16
|
+
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
17
|
+
}
|
|
18
|
+
const { fileId, limit } = params;
|
|
19
|
+
try {
|
|
20
|
+
// First, get file metadata to determine the file type
|
|
21
|
+
const metadataUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?fields=name,mimeType,size`;
|
|
22
|
+
const metadataRes = yield axiosClient.get(metadataUrl, {
|
|
23
|
+
headers: {
|
|
24
|
+
Authorization: `Bearer ${authParams.authToken}`,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const { name: fileName, mimeType, size } = metadataRes.data;
|
|
28
|
+
// Check if file is too large (50MB limit for safety)
|
|
29
|
+
if (size && parseInt(size) > 50 * 1024 * 1024) {
|
|
30
|
+
return {
|
|
31
|
+
success: false,
|
|
32
|
+
error: "File too large (>50MB)",
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
let content = "";
|
|
36
|
+
// Handle different file types - read content directly
|
|
37
|
+
if (mimeType === "application/vnd.google-apps.document") {
|
|
38
|
+
// Google Docs - download as plain text
|
|
39
|
+
const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media&format=txt`;
|
|
40
|
+
const downloadRes = yield axiosClient.get(downloadUrl, {
|
|
41
|
+
headers: {
|
|
42
|
+
Authorization: `Bearer ${authParams.authToken}`,
|
|
43
|
+
},
|
|
44
|
+
responseType: 'text',
|
|
45
|
+
});
|
|
46
|
+
content = downloadRes.data;
|
|
47
|
+
}
|
|
48
|
+
else if (mimeType === "application/vnd.google-apps.spreadsheet") {
|
|
49
|
+
// Google Sheets - download as CSV
|
|
50
|
+
const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media&format=csv`;
|
|
51
|
+
const downloadRes = yield axiosClient.get(downloadUrl, {
|
|
52
|
+
headers: {
|
|
53
|
+
Authorization: `Bearer ${authParams.authToken}`,
|
|
54
|
+
},
|
|
55
|
+
responseType: 'text',
|
|
56
|
+
});
|
|
57
|
+
content = downloadRes.data;
|
|
58
|
+
}
|
|
59
|
+
else if (mimeType === "application/vnd.google-apps.presentation") {
|
|
60
|
+
// Google Slides - download as plain text
|
|
61
|
+
const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media&format=txt`;
|
|
62
|
+
const downloadRes = yield axiosClient.get(downloadUrl, {
|
|
63
|
+
headers: {
|
|
64
|
+
Authorization: `Bearer ${authParams.authToken}`,
|
|
65
|
+
},
|
|
66
|
+
responseType: 'text',
|
|
67
|
+
});
|
|
68
|
+
content = downloadRes.data;
|
|
69
|
+
}
|
|
70
|
+
else if (mimeType === "application/pdf") {
|
|
71
|
+
// PDF files - use pdf-parse
|
|
72
|
+
const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media`;
|
|
73
|
+
const downloadRes = yield axiosClient.get(downloadUrl, {
|
|
74
|
+
headers: {
|
|
75
|
+
Authorization: `Bearer ${authParams.authToken}`,
|
|
76
|
+
},
|
|
77
|
+
responseType: 'arraybuffer',
|
|
78
|
+
});
|
|
79
|
+
try {
|
|
80
|
+
const pdfData = yield pdf(downloadRes.data);
|
|
81
|
+
content = pdfData.text;
|
|
82
|
+
}
|
|
83
|
+
catch (pdfError) {
|
|
84
|
+
return {
|
|
85
|
+
success: false,
|
|
86
|
+
error: `Failed to parse PDF: ${pdfError instanceof Error ? pdfError.message : 'Unknown PDF error'}`,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else if (mimeType === "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ||
|
|
91
|
+
mimeType === "application/msword") {
|
|
92
|
+
// Word documents (.docx or .doc) - download and extract text using mammoth
|
|
93
|
+
const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media`;
|
|
94
|
+
const downloadRes = yield axiosClient.get(downloadUrl, {
|
|
95
|
+
headers: {
|
|
96
|
+
Authorization: `Bearer ${authParams.authToken}`,
|
|
97
|
+
},
|
|
98
|
+
responseType: 'arraybuffer',
|
|
99
|
+
});
|
|
100
|
+
try {
|
|
101
|
+
// mammoth works with .docx files. It will ignore formatting and return raw text
|
|
102
|
+
const result = yield mammoth.extractRawText({ buffer: Buffer.from(downloadRes.data) });
|
|
103
|
+
content = result.value; // raw text
|
|
104
|
+
}
|
|
105
|
+
catch (wordError) {
|
|
106
|
+
return {
|
|
107
|
+
success: false,
|
|
108
|
+
error: `Failed to parse Word document: ${wordError instanceof Error ? wordError.message : 'Unknown Word error'}`,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else if (mimeType === "text/plain" ||
|
|
113
|
+
mimeType === "text/html" ||
|
|
114
|
+
mimeType === "application/rtf" ||
|
|
115
|
+
(mimeType === null || mimeType === void 0 ? void 0 : mimeType.startsWith("text/"))) {
|
|
116
|
+
// Text-based files
|
|
117
|
+
const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media`;
|
|
118
|
+
const downloadRes = yield axiosClient.get(downloadUrl, {
|
|
119
|
+
headers: {
|
|
120
|
+
Authorization: `Bearer ${authParams.authToken}`,
|
|
121
|
+
},
|
|
122
|
+
responseType: 'text',
|
|
123
|
+
});
|
|
124
|
+
content = downloadRes.data;
|
|
125
|
+
}
|
|
126
|
+
else if (mimeType === null || mimeType === void 0 ? void 0 : mimeType.startsWith("image/")) {
|
|
127
|
+
// Skip images
|
|
128
|
+
return {
|
|
129
|
+
success: false,
|
|
130
|
+
error: "Image files are not supported for text extraction",
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
// Unsupported file type
|
|
135
|
+
return {
|
|
136
|
+
success: false,
|
|
137
|
+
error: `Unsupported file type: ${mimeType}`,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
content = content.trim();
|
|
141
|
+
const originalLength = content.length;
|
|
142
|
+
// Naive way to truncate content
|
|
143
|
+
if (limit && content.length > limit) {
|
|
144
|
+
content = content.substring(0, limit);
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
success: true,
|
|
148
|
+
content,
|
|
149
|
+
fileName,
|
|
150
|
+
fileLength: originalLength,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
console.error("Error getting Google Drive file content", error);
|
|
155
|
+
return {
|
|
156
|
+
success: false,
|
|
157
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
export default getDriveFileContentByID;
|