@credal/actions 0.1.34 → 0.1.36

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.
Files changed (37) hide show
  1. package/dist/actions/actionMapper.js +24 -0
  2. package/dist/actions/autogen/templates.d.ts +4 -0
  3. package/dist/actions/autogen/templates.js +189 -3
  4. package/dist/actions/autogen/types.d.ts +125 -0
  5. package/dist/actions/autogen/types.js +44 -1
  6. package/dist/actions/groups.js +9 -1
  7. package/dist/actions/providers/microsoft/createDocument.d.ts +3 -0
  8. package/dist/actions/providers/microsoft/createDocument.js +47 -0
  9. package/dist/actions/providers/microsoft/getDocument.d.ts +3 -0
  10. package/dist/actions/providers/microsoft/getDocument.js +45 -0
  11. package/dist/actions/providers/microsoft/messageTeamsChannel.js +18 -3
  12. package/dist/actions/providers/microsoft/messageTeamsChat.js +18 -3
  13. package/dist/actions/providers/microsoft/updateDocument.d.ts +3 -0
  14. package/dist/actions/providers/microsoft/updateDocument.js +45 -0
  15. package/dist/actions/providers/microsoft/updateSpreadsheet.d.ts +3 -0
  16. package/dist/actions/providers/microsoft/updateSpreadsheet.js +56 -0
  17. package/dist/actions/providers/microsoft/utils.d.ts +7 -2
  18. package/dist/actions/providers/microsoft/utils.js +26 -14
  19. package/package.json +2 -1
  20. package/dist/actions/autogen/definitions.d.ts +0 -5
  21. package/dist/actions/autogen/definitions.js +0 -132
  22. package/dist/actions/definitions.js +0 -35
  23. package/dist/actions/invokeMapper.d.ts +0 -9
  24. package/dist/actions/invokeMapper.js +0 -33
  25. package/dist/actions/providers/confluence/updatePage.d.ts +0 -3
  26. package/dist/actions/providers/confluence/updatePage.js +0 -43
  27. package/dist/actions/providers/googlemaps/nearbysearch.d.ts +0 -3
  28. package/dist/actions/providers/googlemaps/nearbysearch.js +0 -96
  29. package/dist/actions/providers/jira/createTicket.d.ts +0 -3
  30. package/dist/actions/providers/jira/createTicket.js +0 -34
  31. package/dist/actions/providers/slack/list_conversations.d.ts +0 -3
  32. package/dist/actions/providers/slack/list_conversations.js +0 -60
  33. package/dist/actions/providers/slack/summarizeChannel.d.ts +0 -3
  34. package/dist/actions/providers/slack/summarizeChannel.js +0 -51
  35. package/dist/actions/schema.js +0 -6
  36. package/dist/actions/types.js +0 -2
  37. package/dist/main.js +0 -11
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ const templates_1 = require("../../autogen/templates");
12
13
  const utils_1 = require("./utils");
13
14
  const sendMessageToTeamsChat = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
15
  const { chatId, message } = params;
@@ -24,18 +25,32 @@ const sendMessageToTeamsChat = (_a) => __awaiter(void 0, [_a], void 0, function*
24
25
  error: "Message content is required to send a message",
25
26
  };
26
27
  }
28
+ let client = undefined;
27
29
  try {
28
- const messageId = yield (0, utils_1.sendMessage)(`/chats/${chatId}/messages`, message, authParams);
30
+ client = yield (0, utils_1.getGraphClient)(authParams, templates_1.microsoftMessageTeamsChatDefinition.scopes.join(" "));
31
+ }
32
+ catch (error) {
33
+ return {
34
+ success: false,
35
+ error: "Error while authorizing: " + (error instanceof Error ? error.message : "Unknown error"),
36
+ };
37
+ }
38
+ try {
39
+ const response = yield client.api(`/chats/${chatId}/messages`).post({
40
+ body: {
41
+ content: message,
42
+ },
43
+ });
29
44
  return {
30
45
  success: true,
31
- messageId: messageId,
46
+ messageId: response.id,
32
47
  };
33
48
  }
34
49
  catch (error) {
35
50
  console.error(error);
36
51
  return {
37
52
  success: false,
38
- error: error instanceof Error ? error.message : "Unknown error",
53
+ error: "Error sending message: " + (error instanceof Error ? error.message : "Unknown error"),
39
54
  };
40
55
  }
41
56
  });
@@ -0,0 +1,3 @@
1
+ import { microsoftUpdateDocumentFunction } from "../../autogen/types";
2
+ declare const updateDocument: microsoftUpdateDocumentFunction;
3
+ export default updateDocument;
@@ -0,0 +1,45 @@
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 templates_1 = require("../../autogen/templates");
13
+ const utils_1 = require("./utils");
14
+ const updateDocument = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
15
+ const { documentId, content, siteId } = params;
16
+ let client = undefined;
17
+ try {
18
+ client = yield (0, utils_1.getGraphClient)(authParams, templates_1.microsoftUpdateDocumentDefinition.scopes.join(" "));
19
+ }
20
+ catch (error) {
21
+ return {
22
+ success: false,
23
+ error: "Error while authorizing: " + (error instanceof Error ? error.message : "Unknown error"),
24
+ };
25
+ }
26
+ try {
27
+ // Determine the endpoint based on whether siteId is provided
28
+ const endpoint = siteId
29
+ ? `/sites/${siteId}/drive/items/${documentId}/content`
30
+ : `/me/drive/items/${documentId}/content`;
31
+ const response = yield client.api(endpoint).put(content);
32
+ return {
33
+ success: true,
34
+ documentUrl: response.webUrl,
35
+ };
36
+ }
37
+ catch (error) {
38
+ console.error("Error updating document:", error);
39
+ return {
40
+ success: false,
41
+ error: error instanceof Error ? error.message : "Unknown error occurred",
42
+ };
43
+ }
44
+ });
45
+ exports.default = updateDocument;
@@ -0,0 +1,3 @@
1
+ import { microsoftUpdateSpreadsheetFunction } from "../../autogen/types";
2
+ declare const updateSpreadsheet: microsoftUpdateSpreadsheetFunction;
3
+ export default updateSpreadsheet;
@@ -0,0 +1,56 @@
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 templates_1 = require("../../autogen/templates");
13
+ const utils_1 = require("./utils");
14
+ const updateSpreadsheet = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
15
+ const { spreadsheetId, range, values, siteId } = params; // Added siteId to destructured params
16
+ let client = undefined;
17
+ try {
18
+ client = yield (0, utils_1.getGraphClient)(authParams, templates_1.microsoftUpdateSpreadsheetDefinition.scopes.join(" "));
19
+ }
20
+ catch (error) {
21
+ return {
22
+ success: false,
23
+ error: "Error while authorizing: " + (error instanceof Error ? error.message : "Unknown error"),
24
+ };
25
+ }
26
+ const apiEndpointPrefix = siteId ? `/sites/${siteId}` : "/me";
27
+ if (!range.includes("!")) {
28
+ return {
29
+ success: false,
30
+ error: "Invalid range format. Expected format: 'SheetName!CellRange'",
31
+ };
32
+ }
33
+ const [sheetName, cellRange] = range.split("!");
34
+ if (!sheetName || !cellRange) {
35
+ return {
36
+ success: false,
37
+ error: "Invalid range format. Both sheet name and cell range must be specified.",
38
+ };
39
+ }
40
+ const apiEndpoint = `${apiEndpointPrefix}/drive/items/${spreadsheetId}/workbook/worksheets/${sheetName}/range(address='${cellRange}')`;
41
+ try {
42
+ const response = yield client.api(apiEndpoint).patch({ values });
43
+ return {
44
+ success: true,
45
+ updatedRange: response.address,
46
+ };
47
+ }
48
+ catch (error) {
49
+ console.error("Error updating spreadsheet:", error);
50
+ return {
51
+ success: false,
52
+ error: error instanceof Error ? error.message : "Unknown error occurred",
53
+ };
54
+ }
55
+ });
56
+ exports.default = updateSpreadsheet;
@@ -1,4 +1,9 @@
1
1
  import { Client } from "@microsoft/microsoft-graph-client";
2
2
  import { AuthParamsType } from "../../autogen/types";
3
- export declare function getGraphClientForMessageSend(authParams: AuthParamsType): Promise<Client>;
4
- export declare function sendMessage(api_url: string, message: string, authParams: AuthParamsType): Promise<string>;
3
+ export declare function getGraphClient(authParams: AuthParamsType, scope: string): Promise<Client>;
4
+ /**
5
+ * Validates and sanitizes a filename for SharePoint or OneDrive.
6
+ * @param fileName The original filename to validate and sanitize.
7
+ * @returns A sanitized filename that is safe to use.
8
+ */
9
+ export declare function validateAndSanitizeFileName(fileName: string): string;
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getGraphClientForMessageSend = getGraphClientForMessageSend;
13
- exports.sendMessage = sendMessage;
12
+ exports.getGraphClient = getGraphClient;
13
+ exports.validateAndSanitizeFileName = validateAndSanitizeFileName;
14
14
  const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
15
15
  const axiosClient_1 = require("../../util/axiosClient");
16
- function getGraphClientForMessageSend(authParams) {
16
+ function getGraphClient(authParams, scope) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
18
  if (!authParams.clientId ||
19
19
  !authParams.clientSecret ||
@@ -26,7 +26,7 @@ function getGraphClientForMessageSend(authParams) {
26
26
  const params = new URLSearchParams({
27
27
  client_id: authParams.clientId,
28
28
  client_secret: authParams.clientSecret,
29
- scope: "offline_access ChannelMessage.Send ChatMessage.Send",
29
+ scope: `offline_access ${scope}`,
30
30
  grant_type: "refresh_token",
31
31
  refresh_token: authParams.refreshToken,
32
32
  redirect_uri: authParams.redirectUri,
@@ -42,14 +42,26 @@ function getGraphClientForMessageSend(authParams) {
42
42
  });
43
43
  });
44
44
  }
45
- function sendMessage(api_url, message, authParams) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- const client = yield getGraphClientForMessageSend(authParams);
48
- const response = yield client.api(api_url).post({
49
- body: {
50
- content: message,
51
- },
52
- });
53
- return response.id;
54
- });
45
+ /**
46
+ * Validates and sanitizes a filename for SharePoint or OneDrive.
47
+ * @param fileName The original filename to validate and sanitize.
48
+ * @returns A sanitized filename that is safe to use.
49
+ */
50
+ function validateAndSanitizeFileName(fileName) {
51
+ // Define invalid characters for SharePoint and OneDrive
52
+ const invalidCharacters = /[~"#%&*:<>?/{|}\\]/g;
53
+ // Replace invalid characters with an underscore
54
+ let sanitizedFileName = fileName.replace(invalidCharacters, "_");
55
+ // Remove leading or trailing spaces
56
+ sanitizedFileName = sanitizedFileName.trim();
57
+ // Replace consecutive periods with a single period
58
+ sanitizedFileName = sanitizedFileName.replace(/\.{2,}/g, ".");
59
+ // Ensure the filename does not exceed 400 characters
60
+ if (sanitizedFileName.length > 400) {
61
+ const extensionIndex = sanitizedFileName.lastIndexOf(".");
62
+ const baseName = sanitizedFileName.slice(0, extensionIndex);
63
+ const extension = sanitizedFileName.slice(extensionIndex);
64
+ sanitizedFileName = baseName.slice(0, 400 - extension.length) + extension;
65
+ }
66
+ return sanitizedFileName;
55
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.1.34",
3
+ "version": "0.1.36",
4
4
  "description": "AI Actions by Credal AI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -47,6 +47,7 @@
47
47
  "@types/snowflake-sdk": "^1.6.24",
48
48
  "ajv": "^8.17.1",
49
49
  "date-fns": "^4.1.0",
50
+ "docx": "^9.3.0",
50
51
  "dotenv": "^16.4.7",
51
52
  "json-schema-to-zod": "^2.5.0",
52
53
  "jsonwebtoken": "^9.0.2",
@@ -1,5 +0,0 @@
1
- import { ActionTemplate } from "@/actions/parse";
2
- export declare const slackSendMessageDefinition: ActionTemplate;
3
- export declare const slackListConversationsDefinition: ActionTemplate;
4
- export declare const mathAddDefinition: ActionTemplate;
5
- export declare const confluenceUpdatePageDefinition: ActionTemplate;
@@ -1,132 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.confluenceUpdatePageDefinition = exports.mathAddDefinition = exports.slackListConversationsDefinition = exports.slackSendMessageDefinition = void 0;
4
- exports.slackSendMessageDefinition = {
5
- provider: "slack",
6
- name: "send_message",
7
- description: "Sends a message to a Slack channel",
8
- scopes: ["chat:write"],
9
- parameters: {
10
- channel: {
11
- type: "string",
12
- description: "The Slack channel to send the message to (e.g., \\#general, \\#alerts)",
13
- required: true,
14
- },
15
- message: {
16
- type: "string",
17
- description: "The message content to send to Slack. Can include markdown formatting.",
18
- required: true,
19
- },
20
- },
21
- output: {},
22
- };
23
- exports.slackListConversationsDefinition = {
24
- provider: "slack",
25
- name: "list_conversations",
26
- description: "Lists all conversations in a Slack workspace",
27
- scopes: ["channels:read", "groups:read", "im:read", "mpim:read"],
28
- authToken: {
29
- type: "string",
30
- description: "The Slack access token to use",
31
- required: true,
32
- },
33
- parameters: {},
34
- output: {
35
- channels: {
36
- type: "array",
37
- description: "A list of channels in Slack",
38
- required: true,
39
- items: {
40
- type: "object",
41
- description: "A channel in Slack",
42
- required: true,
43
- properties: {
44
- id: {
45
- type: "string",
46
- description: "The ID of the channel",
47
- required: true,
48
- },
49
- name: {
50
- type: "string",
51
- description: "The name of the channel",
52
- required: true,
53
- },
54
- topic: {
55
- type: "string",
56
- description: "The topic of the channel",
57
- required: true,
58
- },
59
- purpose: {
60
- type: "string",
61
- description: "The purpose of the channel",
62
- required: true,
63
- },
64
- },
65
- },
66
- },
67
- },
68
- };
69
- exports.mathAddDefinition = {
70
- provider: "math",
71
- name: "add",
72
- description: "Adds two numbers together",
73
- scopes: [],
74
- parameters: {
75
- a: {
76
- type: "number",
77
- description: "The first number to add",
78
- required: true,
79
- },
80
- b: {
81
- type: "number",
82
- description: "The second number to add",
83
- required: true,
84
- },
85
- },
86
- output: {
87
- result: {
88
- type: "number",
89
- description: "The sum of the two numbers",
90
- required: true,
91
- },
92
- },
93
- };
94
- exports.confluenceUpdatePageDefinition = {
95
- provider: "confluence",
96
- name: "updatePage",
97
- description: "Updates a confluence page with the new content specified",
98
- scopes: [],
99
- authToken: {
100
- type: "string",
101
- description: "The access token to use for confluence",
102
- required: true,
103
- },
104
- baseUrl: {
105
- type: "string",
106
- description: "The base url required to access the confluence instance",
107
- required: true,
108
- },
109
- parameters: {
110
- pageId: {
111
- type: "string",
112
- description: "The page id that should be updated",
113
- required: true,
114
- },
115
- title: {
116
- type: "string",
117
- description: "The title of the page that should be updated",
118
- required: true,
119
- },
120
- username: {
121
- type: "string",
122
- description: "The username of the person updating the page",
123
- required: true,
124
- },
125
- content: {
126
- type: "string",
127
- description: "The new content for the page",
128
- required: true,
129
- },
130
- },
131
- output: {},
132
- };
@@ -1,35 +0,0 @@
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
- };
@@ -1,9 +0,0 @@
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 {};
@@ -1,33 +0,0 @@
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
- };
@@ -1,3 +0,0 @@
1
- import { confluenceUpdatePageFunction } from "../../../actions/autogen/types";
2
- declare const confluenceUpdatePage: confluenceUpdatePageFunction;
3
- export default confluenceUpdatePage;
@@ -1,43 +0,0 @@
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;
@@ -1,3 +0,0 @@
1
- import { googlemapsNearbysearchFunction } from "../../autogen/types";
2
- declare const nearbysearch: googlemapsNearbysearchFunction;
3
- export default nearbysearch;
@@ -1,96 +0,0 @@
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 types_1 = require("../../autogen/types");
17
- const INCLUDED_TYPES = [
18
- // "monument",
19
- // "museum",
20
- // "art_gallery",
21
- // "sculpture",
22
- // "cultural_landmark",
23
- // "historical_place",
24
- // "performing_arts_theater",
25
- // "university",
26
- // "aquarium",
27
- // "botanical_garden",
28
- // "comedy_club",
29
- // "park",
30
- // "movie_theater",
31
- // "national_park",
32
- // "garden",
33
- // "night_club",
34
- // "tourist_attraction",
35
- // "water_park",
36
- // "zoo",
37
- // "bar",
38
- "restaurant",
39
- // "food_court",
40
- // "bakery",
41
- // "cafe",
42
- // "coffee_shop",
43
- // "pub",
44
- // "wine_bar",
45
- // "spa",
46
- // "beach",
47
- // "market",
48
- // "shopping_mall",
49
- // "stadium",
50
- ];
51
- const nearbysearch = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
52
- const url = `https://places.googleapis.com/v1/places:searchNearby`;
53
- const fieldMask = [
54
- "places.displayName",
55
- "places.formattedAddress",
56
- "places.priceLevel",
57
- "places.rating",
58
- "places.primaryTypeDisplayName",
59
- "places.editorialSummary",
60
- "places.regularOpeningHours",
61
- ].join(",");
62
- const response = yield axios_1.default.post(url, {
63
- maxResultCount: 20,
64
- includedTypes: INCLUDED_TYPES,
65
- locationRestriction: {
66
- circle: {
67
- center: {
68
- latitude: params.latitude,
69
- longitude: params.longitude,
70
- },
71
- radius: 10000,
72
- },
73
- },
74
- }, {
75
- headers: {
76
- "X-Goog-Api-Key": authParams.apiKey,
77
- "X-Goog-FieldMask": fieldMask,
78
- "Content-Type": "application/json",
79
- },
80
- });
81
- return types_1.googlemapsNearbysearchOutputSchema.parse({
82
- results: response.data.places.map((place) => {
83
- var _a, _b;
84
- return ({
85
- name: place.displayName.text,
86
- address: place.formattedAddress,
87
- priceLevel: place.priceLevel,
88
- rating: place.rating,
89
- primaryType: place.primaryTypeDisplayName.text,
90
- editorialSummary: ((_a = place.editorialSummary) === null || _a === void 0 ? void 0 : _a.text) || "",
91
- openingHours: ((_b = place.regularOpeningHours) === null || _b === void 0 ? void 0 : _b.weekdayDescriptions.join("\n")) || "",
92
- });
93
- }),
94
- });
95
- });
96
- exports.default = nearbysearch;
@@ -1,3 +0,0 @@
1
- import { jiraCreateTicketFunction } from "../../autogen/types";
2
- declare const createTicket: jiraCreateTicketFunction;
3
- export default createTicket;
@@ -1,34 +0,0 @@
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 createTicket = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
17
- const { authToken, baseUrl } = authParams;
18
- const url = `${baseUrl}/rest/api/3/issue`;
19
- const payload = {
20
- fields: Object.assign({ project: {
21
- key: params.projectKey,
22
- }, summary: params.summary, description: params.description, issuetype: {
23
- name: params.issueType,
24
- } }, (params.reporter ? { reporter: { id: params.reporter } } : {})),
25
- };
26
- const response = yield axios_1.default.post(url, payload, {
27
- headers: {
28
- Authorization: `Basic ${Buffer.from(`${params.username}:${authToken}`).toString("base64")}`,
29
- "Content-Type": "application/json",
30
- },
31
- });
32
- return response.data;
33
- });
34
- exports.default = createTicket;
@@ -1,3 +0,0 @@
1
- import { slackListConversationsFunction } from "../../../actions/autogen/types";
2
- declare const slackListConversations: slackListConversationsFunction;
3
- export default slackListConversations;