@credal/actions 0.2.171 → 0.2.173
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/definitions.d.ts +5 -0
- package/dist/actions/autogen/definitions.js +132 -0
- package/dist/actions/autogen/templates.d.ts +1 -0
- package/dist/actions/autogen/templates.js +222 -0
- package/dist/actions/autogen/types.d.ts +48 -10
- package/dist/actions/autogen/types.js +25 -23
- package/dist/actions/definitions.js +35 -0
- package/dist/actions/groups.js +14 -1
- package/dist/actions/invokeMapper.d.ts +9 -0
- package/dist/actions/invokeMapper.js +33 -0
- package/dist/actions/parse.d.ts +3 -0
- package/dist/actions/parse.js +94 -1
- package/dist/actions/providers/confluence/updatePage.d.ts +3 -0
- package/dist/actions/providers/confluence/updatePage.js +43 -0
- package/dist/actions/providers/google-oauth/getSheetValue.d.ts +3 -0
- package/dist/actions/providers/google-oauth/getSheetValue.js +50 -0
- package/dist/actions/providers/google-oauth/getSheetValues.d.ts +3 -0
- package/dist/actions/providers/google-oauth/getSheetValues.js +50 -0
- package/dist/actions/providers/google-oauth/listGmailThreads.d.ts +3 -0
- package/dist/actions/providers/google-oauth/listGmailThreads.js +98 -0
- package/dist/actions/providers/google-oauth/searchGmailMessages.d.ts +3 -0
- package/dist/actions/providers/google-oauth/searchGmailMessages.js +91 -0
- package/dist/actions/providers/googlemaps/nearbysearch.d.ts +3 -0
- package/dist/actions/providers/googlemaps/nearbysearch.js +96 -0
- package/dist/actions/providers/jamf/types.d.ts +8 -0
- package/dist/actions/providers/jamf/types.js +7 -0
- package/dist/actions/providers/jira/createTicket.d.ts +3 -0
- package/dist/actions/providers/jira/createTicket.js +34 -0
- package/dist/actions/providers/slack/archiveChannel.js +9 -2
- package/dist/actions/providers/slack/listConversations.d.ts +1 -1
- package/dist/actions/providers/slack/list_conversations.d.ts +3 -0
- package/dist/actions/providers/slack/list_conversations.js +60 -0
- package/dist/actions/providers/slack/sendDmFromBot.d.ts +11 -0
- package/dist/actions/providers/slack/sendDmFromBot.js +86 -0
- package/dist/actions/providers/slack/summarizeChannel.d.ts +3 -0
- package/dist/actions/providers/slack/summarizeChannel.js +51 -0
- package/dist/actions/schema.js +6 -0
- package/dist/actions/types.js +2 -0
- package/dist/main.js +11 -0
- package/package.json +1 -1
|
@@ -101,6 +101,12 @@ export declare const AuthParamsSchema: z.ZodObject<{
|
|
|
101
101
|
redirectUri?: string | undefined;
|
|
102
102
|
}>;
|
|
103
103
|
export type AuthParamsType = z.infer<typeof AuthParamsSchema>;
|
|
104
|
+
export declare const ActionTagSchema: z.ZodEnum<["read", "write"]>;
|
|
105
|
+
export type ActionTag = z.infer<typeof ActionTagSchema>;
|
|
106
|
+
export declare const ACTION_TAGS: readonly ["read", "write"];
|
|
107
|
+
export declare const ParameterTagSchema: z.ZodEnum<["recommend-predefined"]>;
|
|
108
|
+
export type ParameterTag = z.infer<typeof ParameterTagSchema>;
|
|
109
|
+
export declare const PARAMETER_TAGS: readonly ["recommend-predefined"];
|
|
104
110
|
export declare const genericFillTemplateParamsSchema: z.ZodObject<{
|
|
105
111
|
template: z.ZodString;
|
|
106
112
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -758,6 +764,38 @@ export declare const asanaGetTasksDetailsOutputSchema: z.ZodObject<{
|
|
|
758
764
|
}>;
|
|
759
765
|
export type asanaGetTasksDetailsOutputType = z.infer<typeof asanaGetTasksDetailsOutputSchema>;
|
|
760
766
|
export type asanaGetTasksDetailsFunction = ActionFunction<asanaGetTasksDetailsParamsType, AuthParamsType, asanaGetTasksDetailsOutputType>;
|
|
767
|
+
export declare const slackSendDmFromBotParamsSchema: z.ZodObject<{
|
|
768
|
+
email: z.ZodString;
|
|
769
|
+
message: z.ZodString;
|
|
770
|
+
}, "strip", z.ZodTypeAny, {
|
|
771
|
+
message: string;
|
|
772
|
+
email: string;
|
|
773
|
+
}, {
|
|
774
|
+
message: string;
|
|
775
|
+
email: string;
|
|
776
|
+
}>;
|
|
777
|
+
export type slackSendDmFromBotParamsType = z.infer<typeof slackSendDmFromBotParamsSchema>;
|
|
778
|
+
export declare const slackSendDmFromBotOutputSchema: z.ZodObject<{
|
|
779
|
+
success: z.ZodBoolean;
|
|
780
|
+
error: z.ZodOptional<z.ZodString>;
|
|
781
|
+
channelId: z.ZodOptional<z.ZodString>;
|
|
782
|
+
timestamp: z.ZodOptional<z.ZodString>;
|
|
783
|
+
permalink: z.ZodOptional<z.ZodString>;
|
|
784
|
+
}, "strip", z.ZodTypeAny, {
|
|
785
|
+
success: boolean;
|
|
786
|
+
error?: string | undefined;
|
|
787
|
+
channelId?: string | undefined;
|
|
788
|
+
timestamp?: string | undefined;
|
|
789
|
+
permalink?: string | undefined;
|
|
790
|
+
}, {
|
|
791
|
+
success: boolean;
|
|
792
|
+
error?: string | undefined;
|
|
793
|
+
channelId?: string | undefined;
|
|
794
|
+
timestamp?: string | undefined;
|
|
795
|
+
permalink?: string | undefined;
|
|
796
|
+
}>;
|
|
797
|
+
export type slackSendDmFromBotOutputType = z.infer<typeof slackSendDmFromBotOutputSchema>;
|
|
798
|
+
export type slackSendDmFromBotFunction = ActionFunction<slackSendDmFromBotParamsType, AuthParamsType, slackSendDmFromBotOutputType>;
|
|
761
799
|
export declare const slackCreateChannelParamsSchema: z.ZodObject<{
|
|
762
800
|
channelName: z.ZodString;
|
|
763
801
|
isPrivate: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -793,12 +831,12 @@ export declare const slackSendMessageParamsSchema: z.ZodObject<{
|
|
|
793
831
|
message: z.ZodString;
|
|
794
832
|
}, "strip", z.ZodTypeAny, {
|
|
795
833
|
message: string;
|
|
796
|
-
channelName?: string | undefined;
|
|
797
834
|
channelId?: string | undefined;
|
|
835
|
+
channelName?: string | undefined;
|
|
798
836
|
}, {
|
|
799
837
|
message: string;
|
|
800
|
-
channelName?: string | undefined;
|
|
801
838
|
channelId?: string | undefined;
|
|
839
|
+
channelName?: string | undefined;
|
|
802
840
|
}>;
|
|
803
841
|
export type slackSendMessageParamsType = z.infer<typeof slackSendMessageParamsSchema>;
|
|
804
842
|
export declare const slackSendMessageOutputSchema: z.ZodObject<{
|
|
@@ -826,16 +864,16 @@ export declare const slackGetChannelMessagesParamsSchema: z.ZodObject<{
|
|
|
826
864
|
includeThreadReplies: z.ZodOptional<z.ZodBoolean>;
|
|
827
865
|
}, "strip", z.ZodTypeAny, {
|
|
828
866
|
oldest: string;
|
|
829
|
-
channelName?: string | undefined;
|
|
830
867
|
channelId?: string | undefined;
|
|
868
|
+
channelName?: string | undefined;
|
|
831
869
|
latest?: string | undefined;
|
|
832
870
|
limit?: number | undefined;
|
|
833
871
|
cursor?: string | undefined;
|
|
834
872
|
includeThreadReplies?: boolean | undefined;
|
|
835
873
|
}, {
|
|
836
874
|
oldest: string;
|
|
837
|
-
channelName?: string | undefined;
|
|
838
875
|
channelId?: string | undefined;
|
|
876
|
+
channelName?: string | undefined;
|
|
839
877
|
latest?: string | undefined;
|
|
840
878
|
limit?: number | undefined;
|
|
841
879
|
cursor?: string | undefined;
|
|
@@ -953,9 +991,9 @@ export declare const slackUserSearchSlackOutputSchema: z.ZodObject<{
|
|
|
953
991
|
userName?: string | undefined;
|
|
954
992
|
}[] | undefined;
|
|
955
993
|
text?: string | undefined;
|
|
994
|
+
permalink?: string | undefined;
|
|
956
995
|
userEmail?: string | undefined;
|
|
957
996
|
userName?: string | undefined;
|
|
958
|
-
permalink?: string | undefined;
|
|
959
997
|
context?: {
|
|
960
998
|
ts: string;
|
|
961
999
|
text?: string | undefined;
|
|
@@ -971,9 +1009,9 @@ export declare const slackUserSearchSlackOutputSchema: z.ZodObject<{
|
|
|
971
1009
|
userName?: string | undefined;
|
|
972
1010
|
}[] | undefined;
|
|
973
1011
|
text?: string | undefined;
|
|
1012
|
+
permalink?: string | undefined;
|
|
974
1013
|
userEmail?: string | undefined;
|
|
975
1014
|
userName?: string | undefined;
|
|
976
|
-
permalink?: string | undefined;
|
|
977
1015
|
context?: {
|
|
978
1016
|
ts: string;
|
|
979
1017
|
text?: string | undefined;
|
|
@@ -993,9 +1031,9 @@ export declare const slackUserSearchSlackOutputSchema: z.ZodObject<{
|
|
|
993
1031
|
userName?: string | undefined;
|
|
994
1032
|
}[] | undefined;
|
|
995
1033
|
text?: string | undefined;
|
|
1034
|
+
permalink?: string | undefined;
|
|
996
1035
|
userEmail?: string | undefined;
|
|
997
1036
|
userName?: string | undefined;
|
|
998
|
-
permalink?: string | undefined;
|
|
999
1037
|
context?: {
|
|
1000
1038
|
ts: string;
|
|
1001
1039
|
text?: string | undefined;
|
|
@@ -1015,9 +1053,9 @@ export declare const slackUserSearchSlackOutputSchema: z.ZodObject<{
|
|
|
1015
1053
|
userName?: string | undefined;
|
|
1016
1054
|
}[] | undefined;
|
|
1017
1055
|
text?: string | undefined;
|
|
1056
|
+
permalink?: string | undefined;
|
|
1018
1057
|
userEmail?: string | undefined;
|
|
1019
1058
|
userName?: string | undefined;
|
|
1020
|
-
permalink?: string | undefined;
|
|
1021
1059
|
context?: {
|
|
1022
1060
|
ts: string;
|
|
1023
1061
|
text?: string | undefined;
|
|
@@ -1053,9 +1091,9 @@ export declare const slackUserSearchSlackOutputSchema: z.ZodObject<{
|
|
|
1053
1091
|
userName?: string | undefined;
|
|
1054
1092
|
}[] | undefined;
|
|
1055
1093
|
text?: string | undefined;
|
|
1094
|
+
permalink?: string | undefined;
|
|
1056
1095
|
userEmail?: string | undefined;
|
|
1057
1096
|
userName?: string | undefined;
|
|
1058
|
-
permalink?: string | undefined;
|
|
1059
1097
|
context?: {
|
|
1060
1098
|
ts: string;
|
|
1061
1099
|
text?: string | undefined;
|
|
@@ -1083,9 +1121,9 @@ export declare const slackUserSearchSlackOutputSchema: z.ZodObject<{
|
|
|
1083
1121
|
userName?: string | undefined;
|
|
1084
1122
|
}[] | undefined;
|
|
1085
1123
|
text?: string | undefined;
|
|
1124
|
+
permalink?: string | undefined;
|
|
1086
1125
|
userEmail?: string | undefined;
|
|
1087
1126
|
userName?: string | undefined;
|
|
1088
|
-
permalink?: string | undefined;
|
|
1089
1127
|
context?: {
|
|
1090
1128
|
ts: string;
|
|
1091
1129
|
text?: string | undefined;
|
|
@@ -57,6 +57,10 @@ export const AuthParamsSchema = z.object({
|
|
|
57
57
|
redirectUri: z.string().optional(),
|
|
58
58
|
userEmail: z.string().optional(),
|
|
59
59
|
});
|
|
60
|
+
export const ActionTagSchema = z.enum(["read", "write"]);
|
|
61
|
+
export const ACTION_TAGS = ["read", "write"];
|
|
62
|
+
export const ParameterTagSchema = z.enum(["recommend-predefined"]);
|
|
63
|
+
export const PARAMETER_TAGS = ["recommend-predefined"];
|
|
60
64
|
export const genericFillTemplateParamsSchema = z.object({
|
|
61
65
|
template: z.string().describe("The template string to be processed and returned"),
|
|
62
66
|
});
|
|
@@ -228,6 +232,17 @@ export const asanaGetTasksDetailsOutputSchema = z.object({
|
|
|
228
232
|
.describe("The list of tasks that match search query")
|
|
229
233
|
.optional(),
|
|
230
234
|
});
|
|
235
|
+
export const slackSendDmFromBotParamsSchema = z.object({
|
|
236
|
+
email: z.string().describe("The email of the user to send the DM to"),
|
|
237
|
+
message: z.string().describe("The message content to send"),
|
|
238
|
+
});
|
|
239
|
+
export const slackSendDmFromBotOutputSchema = z.object({
|
|
240
|
+
success: z.boolean().describe("Whether the DM was sent successfully"),
|
|
241
|
+
error: z.string().describe("Error message if the operation failed").optional(),
|
|
242
|
+
channelId: z.string().describe("The ID of the DM channel").optional(),
|
|
243
|
+
timestamp: z.string().describe("The timestamp of the sent message").optional(),
|
|
244
|
+
permalink: z.string().describe("The permalink to the sent message").optional(),
|
|
245
|
+
});
|
|
231
246
|
export const slackCreateChannelParamsSchema = z.object({
|
|
232
247
|
channelName: z.string().describe("The name of the channel to create (without '#')"),
|
|
233
248
|
isPrivate: z.boolean().describe("Whether to create a private channel (defaults to false)").optional(),
|
|
@@ -2174,8 +2189,7 @@ export const googleOauthUpdateSpreadsheetParamsSchema = z.object({
|
|
|
2174
2189
|
const schemas = [
|
|
2175
2190
|
z
|
|
2176
2191
|
.object({
|
|
2177
|
-
addSheet: z
|
|
2178
|
-
.object({
|
|
2192
|
+
addSheet: z.object({
|
|
2179
2193
|
properties: z
|
|
2180
2194
|
.object({
|
|
2181
2195
|
title: z.string().describe("The title of the new sheet").optional(),
|
|
@@ -2187,21 +2201,17 @@ export const googleOauthUpdateSpreadsheetParamsSchema = z.object({
|
|
|
2187
2201
|
.optional(),
|
|
2188
2202
|
})
|
|
2189
2203
|
.optional(),
|
|
2190
|
-
})
|
|
2191
|
-
.optional(),
|
|
2204
|
+
}),
|
|
2192
2205
|
})
|
|
2193
2206
|
.describe("Add or update a sheet"),
|
|
2194
2207
|
z
|
|
2195
2208
|
.object({
|
|
2196
|
-
deleteSheet: z
|
|
2197
|
-
.object({ sheetId: z.number().describe("The ID of the sheet to delete").optional() })
|
|
2198
|
-
.optional(),
|
|
2209
|
+
deleteSheet: z.object({ sheetId: z.number().describe("The ID of the sheet to delete").optional() }),
|
|
2199
2210
|
})
|
|
2200
2211
|
.describe("Delete a sheet"),
|
|
2201
2212
|
z
|
|
2202
2213
|
.object({
|
|
2203
|
-
updateCells: z
|
|
2204
|
-
.object({
|
|
2214
|
+
updateCells: z.object({
|
|
2205
2215
|
range: z
|
|
2206
2216
|
.object({
|
|
2207
2217
|
sheetId: z.number().describe("The ID of the sheet").optional(),
|
|
@@ -2227,14 +2237,12 @@ export const googleOauthUpdateSpreadsheetParamsSchema = z.object({
|
|
|
2227
2237
|
.optional(),
|
|
2228
2238
|
}))
|
|
2229
2239
|
.optional(),
|
|
2230
|
-
})
|
|
2231
|
-
.optional(),
|
|
2240
|
+
}),
|
|
2232
2241
|
})
|
|
2233
2242
|
.describe("Update cells in a range"),
|
|
2234
2243
|
z
|
|
2235
2244
|
.object({
|
|
2236
|
-
updateSheetProperties: z
|
|
2237
|
-
.object({
|
|
2245
|
+
updateSheetProperties: z.object({
|
|
2238
2246
|
properties: z
|
|
2239
2247
|
.object({
|
|
2240
2248
|
sheetId: z.number().describe("The ID of the sheet to update").optional(),
|
|
@@ -2253,14 +2261,12 @@ export const googleOauthUpdateSpreadsheetParamsSchema = z.object({
|
|
|
2253
2261
|
.string()
|
|
2254
2262
|
.describe("The fields to update (comma-separated list using JSON field paths)")
|
|
2255
2263
|
.optional(),
|
|
2256
|
-
})
|
|
2257
|
-
.optional(),
|
|
2264
|
+
}),
|
|
2258
2265
|
})
|
|
2259
2266
|
.describe("Update sheet properties"),
|
|
2260
2267
|
z
|
|
2261
2268
|
.object({
|
|
2262
|
-
updateSpreadsheetProperties: z
|
|
2263
|
-
.object({
|
|
2269
|
+
updateSpreadsheetProperties: z.object({
|
|
2264
2270
|
properties: z
|
|
2265
2271
|
.object({
|
|
2266
2272
|
title: z.string().describe("The title of the spreadsheet").optional(),
|
|
@@ -2315,10 +2321,7 @@ export const googleOauthUpdateSpreadsheetParamsSchema = z.object({
|
|
|
2315
2321
|
fontSize: z.number().describe("The size of the font in points").optional(),
|
|
2316
2322
|
bold: z.boolean().describe("Whether the text is bold").optional(),
|
|
2317
2323
|
italic: z.boolean().describe("Whether the text is italic").optional(),
|
|
2318
|
-
strikethrough: z
|
|
2319
|
-
.boolean()
|
|
2320
|
-
.describe("Whether the text has a strikethrough")
|
|
2321
|
-
.optional(),
|
|
2324
|
+
strikethrough: z.boolean().describe("Whether the text has a strikethrough").optional(),
|
|
2322
2325
|
underline: z.boolean().describe("Whether the text is underlined").optional(),
|
|
2323
2326
|
})
|
|
2324
2327
|
.optional(),
|
|
@@ -2330,8 +2333,7 @@ export const googleOauthUpdateSpreadsheetParamsSchema = z.object({
|
|
|
2330
2333
|
.string()
|
|
2331
2334
|
.describe("The fields to update (comma-separated list using JSON field paths)")
|
|
2332
2335
|
.optional(),
|
|
2333
|
-
})
|
|
2334
|
-
.optional(),
|
|
2336
|
+
}),
|
|
2335
2337
|
})
|
|
2336
2338
|
.describe("Update spreadsheet properties"),
|
|
2337
2339
|
];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mathAddDefinition = exports.slackSendMessageDefinition = void 0;
|
|
4
|
+
exports.slackSendMessageDefinition = {
|
|
5
|
+
name: "send_message",
|
|
6
|
+
description: "Sends a message to a Slack channel",
|
|
7
|
+
parameters: {
|
|
8
|
+
"channel": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The Slack channel to send the message to (e.g., \\#general, \\#alerts)",
|
|
11
|
+
"required": true
|
|
12
|
+
},
|
|
13
|
+
"message": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "The message content to send to Slack. Can include markdown formatting.",
|
|
16
|
+
"required": true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.mathAddDefinition = {
|
|
21
|
+
name: "add",
|
|
22
|
+
description: "Adds two numbers together",
|
|
23
|
+
parameters: {
|
|
24
|
+
"a": {
|
|
25
|
+
"type": "number",
|
|
26
|
+
"description": "The first number to add",
|
|
27
|
+
"required": true
|
|
28
|
+
},
|
|
29
|
+
"b": {
|
|
30
|
+
"type": "number",
|
|
31
|
+
"description": "The second number to add",
|
|
32
|
+
"required": true
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
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, } 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",
|
|
@@ -47,6 +47,7 @@ export const ACTION_GROUPS = {
|
|
|
47
47
|
googleOauthUpdatePresentationDefinition,
|
|
48
48
|
googleOauthSearchDriveByKeywordsDefinition,
|
|
49
49
|
googleOauthSearchDriveByQueryDefinition,
|
|
50
|
+
googleOauthSearchDriveByQueryAndGetFileContentDefinition,
|
|
50
51
|
googleOauthGetDriveFileContentByIdDefinition,
|
|
51
52
|
],
|
|
52
53
|
},
|
|
@@ -198,6 +199,8 @@ export const ACTION_GROUPS = {
|
|
|
198
199
|
githubCreateBranchDefinition,
|
|
199
200
|
githubCreatePullRequestDefinition,
|
|
200
201
|
githubListPullRequestsDefinition,
|
|
202
|
+
githubGetFileContentDefinition,
|
|
203
|
+
githubListDirectoryDefinition,
|
|
201
204
|
],
|
|
202
205
|
},
|
|
203
206
|
ASHBY: {
|
|
@@ -245,4 +248,14 @@ export const ACTION_GROUPS = {
|
|
|
245
248
|
oktaTriggerOktaWorkflowDefinition,
|
|
246
249
|
],
|
|
247
250
|
},
|
|
251
|
+
LINEAR: {
|
|
252
|
+
description: "Actions for interacting with Linear",
|
|
253
|
+
actions: [
|
|
254
|
+
linearGetIssueDetailsDefinition,
|
|
255
|
+
linearGetProjectsDefinition,
|
|
256
|
+
linearGetProjectDetailsDefinition,
|
|
257
|
+
linearGetTeamDetailsDefinition,
|
|
258
|
+
linearGetTeamsDefinition,
|
|
259
|
+
],
|
|
260
|
+
},
|
|
248
261
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ActionFunction } from "./autogen/types";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
interface ActionFunctionComponents {
|
|
4
|
+
fn: ActionFunction<any, any, any>;
|
|
5
|
+
paramsSchema: z.ZodSchema;
|
|
6
|
+
outputSchema: z.ZodSchema;
|
|
7
|
+
}
|
|
8
|
+
export declare const FunctionMapper: Record<string, Record<string, ActionFunctionComponents>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FunctionMapper = void 0;
|
|
7
|
+
const add_1 = __importDefault(require("./providers/math/add"));
|
|
8
|
+
const list_conversations_1 = __importDefault(require("./providers/slack/list_conversations"));
|
|
9
|
+
const updatePage_1 = __importDefault(require("./providers/confluence/updatePage"));
|
|
10
|
+
const types_1 = require("./autogen/types");
|
|
11
|
+
exports.FunctionMapper = {
|
|
12
|
+
math: {
|
|
13
|
+
add: {
|
|
14
|
+
fn: add_1.default,
|
|
15
|
+
paramsSchema: types_1.mathAddParamsSchema,
|
|
16
|
+
outputSchema: types_1.mathAddOutputSchema,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
slack: {
|
|
20
|
+
listConversations: {
|
|
21
|
+
fn: list_conversations_1.default,
|
|
22
|
+
paramsSchema: types_1.slackListConversationsParamsSchema,
|
|
23
|
+
outputSchema: types_1.slackListConversationsOutputSchema,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
confluence: {
|
|
27
|
+
updatePage: {
|
|
28
|
+
fn: updatePage_1.default,
|
|
29
|
+
paramsSchema: types_1.confluenceUpdatePageParamsSchema,
|
|
30
|
+
outputSchema: types_1.confluenceUpdatePageOutputSchema,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
package/dist/actions/parse.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
declare const actionTemplateSchema: z.ZodObject<{
|
|
3
3
|
description: z.ZodString;
|
|
4
4
|
scopes: z.ZodArray<z.ZodString, "many">;
|
|
5
|
+
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodEnum<["read", "write"]>, "many">>>;
|
|
5
6
|
parameters: z.ZodOptional<z.ZodObject<{
|
|
6
7
|
type: z.ZodString;
|
|
7
8
|
required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -34,6 +35,7 @@ declare const actionTemplateSchema: z.ZodObject<{
|
|
|
34
35
|
}, "strip", z.ZodTypeAny, {
|
|
35
36
|
description: string;
|
|
36
37
|
scopes: string[];
|
|
38
|
+
tags: ("read" | "write")[];
|
|
37
39
|
name: string;
|
|
38
40
|
provider: string;
|
|
39
41
|
parameters?: {
|
|
@@ -51,6 +53,7 @@ declare const actionTemplateSchema: z.ZodObject<{
|
|
|
51
53
|
scopes: string[];
|
|
52
54
|
name: string;
|
|
53
55
|
provider: string;
|
|
56
|
+
tags?: ("read" | "write")[] | undefined;
|
|
54
57
|
parameters?: {
|
|
55
58
|
type: string;
|
|
56
59
|
required?: string[] | undefined;
|
package/dist/actions/parse.js
CHANGED
|
@@ -15,14 +15,25 @@ import { Project, VariableDeclarationKind } from "ts-morph";
|
|
|
15
15
|
import { z } from "zod";
|
|
16
16
|
import { snakeToPascal } from "../utils/string.js";
|
|
17
17
|
// TODO support oneOf correctly
|
|
18
|
+
// Tag enum definitions - must be defined before schemas for validation
|
|
19
|
+
const actionTagValues = [
|
|
20
|
+
"read", // this action is read-only in the source system
|
|
21
|
+
"write", // this action executes writes in the source system
|
|
22
|
+
];
|
|
23
|
+
const parameterTagValues = [
|
|
24
|
+
"recommend-predefined", // we recommend that this parameter is predefined by the user versus AI generated at runtime
|
|
25
|
+
];
|
|
18
26
|
const jsonObjectSchema = z.object({
|
|
19
27
|
type: z.string(),
|
|
20
28
|
required: z.array(z.string()).optional(),
|
|
21
29
|
properties: z.record(z.string(), z.any()).optional(), // Permissive for now, validate using JSON schema later
|
|
22
30
|
});
|
|
31
|
+
const parameterTagEnum = z.enum([...parameterTagValues]);
|
|
32
|
+
const actionTagEnum = z.enum([...actionTagValues]);
|
|
23
33
|
const actionSchema = z.object({
|
|
24
34
|
description: z.string(),
|
|
25
35
|
scopes: z.array(z.string()),
|
|
36
|
+
tags: z.array(actionTagEnum).optional().default([]),
|
|
26
37
|
parameters: jsonObjectSchema.optional(),
|
|
27
38
|
output: jsonObjectSchema.optional(),
|
|
28
39
|
});
|
|
@@ -65,6 +76,8 @@ function validateObject(object) {
|
|
|
65
76
|
strictTuples: true,
|
|
66
77
|
strictRequired: true,
|
|
67
78
|
});
|
|
79
|
+
// Add custom keyword - just allow it, we'll validate manually
|
|
80
|
+
ajv.addKeyword("tags");
|
|
68
81
|
// validate schema and check required fields
|
|
69
82
|
const validParameters = ajv.validateSchema(object);
|
|
70
83
|
if (!validParameters) {
|
|
@@ -79,6 +92,20 @@ function validateObject(object) {
|
|
|
79
92
|
}
|
|
80
93
|
}
|
|
81
94
|
}
|
|
95
|
+
// Validate tags in property schemas using Zod
|
|
96
|
+
if (object.properties) {
|
|
97
|
+
for (const [propName, propSchema] of Object.entries(object.properties)) {
|
|
98
|
+
if (propSchema && typeof propSchema === "object" && "tags" in propSchema) {
|
|
99
|
+
const tags = propSchema.tags;
|
|
100
|
+
if (tags !== undefined) {
|
|
101
|
+
const result = z.array(parameterTagEnum).safeParse(tags);
|
|
102
|
+
if (!result.success) {
|
|
103
|
+
throw new Error(`Property "${propName}" has invalid tags: ${result.error.errors.map(e => e.message).join(", ")}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
82
109
|
});
|
|
83
110
|
}
|
|
84
111
|
function addActionTypes(_a) {
|
|
@@ -183,8 +210,67 @@ function generateTypes(_a) {
|
|
|
183
210
|
type: "z.infer<typeof AuthParamsSchema>",
|
|
184
211
|
isExported: true,
|
|
185
212
|
});
|
|
213
|
+
// ActionTag enum for action-level tags (using values defined at top of file)
|
|
214
|
+
typesFile.addVariableStatement({
|
|
215
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
216
|
+
isExported: true,
|
|
217
|
+
declarations: [
|
|
218
|
+
{
|
|
219
|
+
name: "ActionTagSchema",
|
|
220
|
+
initializer: `z.enum([${actionTagValues.map(t => `"${t}"`).join(", ")}])`,
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
});
|
|
224
|
+
typesFile.addTypeAlias({
|
|
225
|
+
name: "ActionTag",
|
|
226
|
+
type: "z.infer<typeof ActionTagSchema>",
|
|
227
|
+
isExported: true,
|
|
228
|
+
});
|
|
229
|
+
typesFile.addVariableStatement({
|
|
230
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
231
|
+
isExported: true,
|
|
232
|
+
declarations: [
|
|
233
|
+
{
|
|
234
|
+
name: "ACTION_TAGS",
|
|
235
|
+
initializer: `[${actionTagValues.map(t => `"${t}"`).join(", ")}] as const`,
|
|
236
|
+
},
|
|
237
|
+
],
|
|
238
|
+
});
|
|
239
|
+
// ParameterTag enum for parameter property tags (using values defined at top of file)
|
|
240
|
+
typesFile.addVariableStatement({
|
|
241
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
242
|
+
isExported: true,
|
|
243
|
+
declarations: [
|
|
244
|
+
{
|
|
245
|
+
name: "ParameterTagSchema",
|
|
246
|
+
initializer: `z.enum([${parameterTagValues.map(t => `"${t}"`).join(", ")}])`,
|
|
247
|
+
},
|
|
248
|
+
],
|
|
249
|
+
});
|
|
250
|
+
typesFile.addTypeAlias({
|
|
251
|
+
name: "ParameterTag",
|
|
252
|
+
type: "z.infer<typeof ParameterTagSchema>",
|
|
253
|
+
isExported: true,
|
|
254
|
+
});
|
|
255
|
+
typesFile.addVariableStatement({
|
|
256
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
257
|
+
isExported: true,
|
|
258
|
+
declarations: [
|
|
259
|
+
{
|
|
260
|
+
name: "PARAMETER_TAGS",
|
|
261
|
+
initializer: `[${parameterTagValues.map(t => `"${t}"`).join(", ")}] as const`,
|
|
262
|
+
},
|
|
263
|
+
],
|
|
264
|
+
});
|
|
186
265
|
for (const [categoryName, category] of Object.entries(parsedConfig.actions)) {
|
|
187
266
|
for (const [actionName, action] of Object.entries(category)) {
|
|
267
|
+
// Validate action-level tags
|
|
268
|
+
if (action.tags && action.tags.length > 0) {
|
|
269
|
+
const invalidTags = action.tags.filter(tag => !actionTagValues.includes(tag));
|
|
270
|
+
if (invalidTags.length > 0) {
|
|
271
|
+
throw new Error(`Action "${categoryName}.${actionName}" has invalid tag values: ${invalidTags.join(", ")}. Valid values are: ${actionTagValues.join(", ")}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
188
274
|
if (action.parameters) {
|
|
189
275
|
yield validateObject(action.parameters);
|
|
190
276
|
}
|
|
@@ -223,4 +309,11 @@ function generateTypes(_a) {
|
|
|
223
309
|
yield typesFile.save();
|
|
224
310
|
});
|
|
225
311
|
}
|
|
226
|
-
generateTypes({})
|
|
312
|
+
generateTypes({}).catch(error => {
|
|
313
|
+
console.error("Error generating types:", error);
|
|
314
|
+
if (error instanceof Error) {
|
|
315
|
+
console.error(error.message);
|
|
316
|
+
console.error(error.stack);
|
|
317
|
+
}
|
|
318
|
+
process.exit(1);
|
|
319
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
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, username, content, title } = params;
|
|
24
|
+
const { baseUrl, authToken } = authParams;
|
|
25
|
+
const config = getConfluenceRequestConfig(baseUrl, username, authToken);
|
|
26
|
+
// Get current version number
|
|
27
|
+
const response = yield axiosClient_1.axiosClient.get(`/api/v2/pages/${pageId}`, config);
|
|
28
|
+
const currVersion = response.data.version.number;
|
|
29
|
+
const payload = {
|
|
30
|
+
id: pageId,
|
|
31
|
+
status: "current",
|
|
32
|
+
title,
|
|
33
|
+
body: {
|
|
34
|
+
representation: "storage",
|
|
35
|
+
value: content,
|
|
36
|
+
},
|
|
37
|
+
version: {
|
|
38
|
+
number: currVersion + 1,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
yield axiosClient_1.axiosClient.put(`/api/v2/pages/${pageId}`, payload, config);
|
|
42
|
+
});
|
|
43
|
+
exports.default = confluenceUpdatePage;
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { axiosClient } from "../../util/axiosClient.js";
|
|
11
|
+
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
+
const getSheetValues = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
13
|
+
const { authToken } = authParams;
|
|
14
|
+
const { spreadsheetId, ranges } = params;
|
|
15
|
+
if (!authToken) {
|
|
16
|
+
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const url = new URL(`https://sheets.googleapis.com/v4/spreadsheets/${encodeURIComponent(spreadsheetId)}/values:batchGet`);
|
|
20
|
+
// Add ranges as query parameters if provided
|
|
21
|
+
if (ranges && ranges.length > 0) {
|
|
22
|
+
ranges.forEach(range => {
|
|
23
|
+
url.searchParams.append("ranges", range);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const response = yield axiosClient.get(url.toString(), {
|
|
27
|
+
headers: { Authorization: `Bearer ${authToken}` },
|
|
28
|
+
});
|
|
29
|
+
const { valueRanges } = response.data;
|
|
30
|
+
// Transform the response to match our schema
|
|
31
|
+
const transformedValueRanges = valueRanges === null || valueRanges === void 0 ? void 0 : valueRanges.map((vr) => {
|
|
32
|
+
var _a;
|
|
33
|
+
return ({
|
|
34
|
+
range: vr.range,
|
|
35
|
+
values: ((_a = vr.values) === null || _a === void 0 ? void 0 : _a.flatMap(row => row.map(cell => ({ value: cell != null ? String(cell) : undefined })))) || [],
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
success: true,
|
|
40
|
+
valueRanges: transformedValueRanges,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return {
|
|
45
|
+
success: false,
|
|
46
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
export default getSheetValues;
|