@credal/actions 0.1.17 → 0.1.20
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/README.md +4 -1
- package/dist/actions/actionMapper.js +14 -0
- package/dist/actions/autogen/templates.d.ts +2 -0
- package/dist/actions/autogen/templates.js +214 -1
- package/dist/actions/autogen/types.d.ts +264 -0
- package/dist/actions/autogen/types.js +93 -1
- package/dist/actions/groups.js +4 -0
- package/dist/actions/parse.js +1 -0
- package/dist/actions/providers/confluence/updatePage.js +9 -13
- package/dist/actions/providers/credal/callCopilot.js +2 -0
- package/dist/actions/providers/finnhub/getBasicFinancials.d.ts +3 -0
- package/dist/actions/providers/finnhub/getBasicFinancials.js +48 -0
- package/dist/actions/providers/finnhub/symbolLookup.d.ts +3 -0
- package/dist/actions/providers/finnhub/symbolLookup.js +33 -0
- package/dist/actions/providers/google-oauth/createNewGoogleDoc.js +32 -44
- package/dist/actions/providers/googlemaps/nearbysearchRestaurants.js +2 -5
- package/dist/actions/providers/googlemaps/validateAddress.js +2 -5
- package/dist/actions/providers/jira/createJiraTicket.js +35 -47
- package/dist/actions/providers/nws/getForecastForLocation.js +3 -6
- package/dist/actions/providers/openstreetmap/getLatitudeLongitudeFromLocation.js +2 -5
- package/dist/actions/providers/x/createXSharePostUrl.js +4 -1
- package/dist/actions/providers/zendesk/createZendeskTicket.js +2 -5
- package/dist/actions/util/axiosClient.d.ts +7 -0
- package/dist/actions/util/axiosClient.js +46 -0
- package/package.json +1 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.googleOauthCreateNewGoogleDocOutputSchema = exports.googleOauthCreateNewGoogleDocParamsSchema = exports.resendSendEmailOutputSchema = exports.resendSendEmailParamsSchema = exports.firecrawlScrapeTweetDataWithNitterOutputSchema = exports.firecrawlScrapeTweetDataWithNitterParamsSchema = exports.firecrawlScrapeUrlOutputSchema = exports.firecrawlScrapeUrlParamsSchema = exports.nwsGetForecastForLocationOutputSchema = exports.nwsGetForecastForLocationParamsSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = exports.snowflakeGetRowByFieldValueOutputSchema = exports.snowflakeGetRowByFieldValueParamsSchema = exports.mongoInsertMongoDocOutputSchema = exports.mongoInsertMongoDocParamsSchema = exports.xCreateShareXPostUrlOutputSchema = exports.xCreateShareXPostUrlParamsSchema = exports.linkedinCreateShareLinkedinPostUrlOutputSchema = exports.linkedinCreateShareLinkedinPostUrlParamsSchema = exports.zendeskCreateZendeskTicketOutputSchema = exports.zendeskCreateZendeskTicketParamsSchema = exports.credalCallCopilotOutputSchema = exports.credalCallCopilotParamsSchema = exports.googlemapsNearbysearchRestaurantsOutputSchema = exports.googlemapsNearbysearchRestaurantsParamsSchema = exports.googlemapsValidateAddressOutputSchema = exports.googlemapsValidateAddressParamsSchema = exports.jiraCreateJiraTicketOutputSchema = exports.jiraCreateJiraTicketParamsSchema = exports.confluenceUpdatePageOutputSchema = exports.confluenceUpdatePageParamsSchema = exports.mathAddOutputSchema = exports.mathAddParamsSchema = exports.slackListConversationsOutputSchema = exports.slackListConversationsParamsSchema = exports.slackSendMessageOutputSchema = exports.slackSendMessageParamsSchema = exports.AuthParamsSchema = void 0;
|
3
|
+
exports.finnhubGetBasicFinancialsOutputSchema = exports.finnhubGetBasicFinancialsParamsSchema = exports.finnhubSymbolLookupOutputSchema = exports.finnhubSymbolLookupParamsSchema = exports.googleOauthCreateNewGoogleDocOutputSchema = exports.googleOauthCreateNewGoogleDocParamsSchema = exports.resendSendEmailOutputSchema = exports.resendSendEmailParamsSchema = exports.firecrawlScrapeTweetDataWithNitterOutputSchema = exports.firecrawlScrapeTweetDataWithNitterParamsSchema = exports.firecrawlScrapeUrlOutputSchema = exports.firecrawlScrapeUrlParamsSchema = exports.nwsGetForecastForLocationOutputSchema = exports.nwsGetForecastForLocationParamsSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = exports.snowflakeGetRowByFieldValueOutputSchema = exports.snowflakeGetRowByFieldValueParamsSchema = exports.mongoInsertMongoDocOutputSchema = exports.mongoInsertMongoDocParamsSchema = exports.xCreateShareXPostUrlOutputSchema = exports.xCreateShareXPostUrlParamsSchema = exports.linkedinCreateShareLinkedinPostUrlOutputSchema = exports.linkedinCreateShareLinkedinPostUrlParamsSchema = exports.zendeskCreateZendeskTicketOutputSchema = exports.zendeskCreateZendeskTicketParamsSchema = exports.credalCallCopilotOutputSchema = exports.credalCallCopilotParamsSchema = exports.googlemapsNearbysearchRestaurantsOutputSchema = exports.googlemapsNearbysearchRestaurantsParamsSchema = exports.googlemapsValidateAddressOutputSchema = exports.googlemapsValidateAddressParamsSchema = exports.jiraCreateJiraTicketOutputSchema = exports.jiraCreateJiraTicketParamsSchema = exports.confluenceUpdatePageOutputSchema = exports.confluenceUpdatePageParamsSchema = exports.mathAddOutputSchema = exports.mathAddParamsSchema = exports.slackListConversationsOutputSchema = exports.slackListConversationsParamsSchema = exports.slackSendMessageOutputSchema = exports.slackSendMessageParamsSchema = exports.AuthParamsSchema = void 0;
|
4
4
|
const zod_1 = require("zod");
|
5
5
|
exports.AuthParamsSchema = zod_1.z.object({
|
6
6
|
authToken: zod_1.z.string().optional(),
|
@@ -11,6 +11,7 @@ exports.AuthParamsSchema = zod_1.z.object({
|
|
11
11
|
emailFrom: zod_1.z.string().optional(),
|
12
12
|
emailReplyTo: zod_1.z.string().optional(),
|
13
13
|
emailBcc: zod_1.z.string().optional(),
|
14
|
+
cloudId: zod_1.z.string().optional(),
|
14
15
|
});
|
15
16
|
exports.slackSendMessageParamsSchema = zod_1.z.object({
|
16
17
|
channelName: zod_1.z.string().describe("The name of the Slack channel to send the message to (e.g. general, alerts)"),
|
@@ -49,6 +50,11 @@ exports.jiraCreateJiraTicketParamsSchema = zod_1.z.object({
|
|
49
50
|
issueType: zod_1.z.string().describe("The issue type of the new ticket"),
|
50
51
|
reporter: zod_1.z.string().describe("The reporter for the new ticket creation").optional(),
|
51
52
|
assignee: zod_1.z.string().describe("The assignee for the new ticket creation").optional(),
|
53
|
+
customFields: zod_1.z
|
54
|
+
.object({})
|
55
|
+
.catchall(zod_1.z.any())
|
56
|
+
.describe("Custom fields to be set on the create ticket request")
|
57
|
+
.optional(),
|
52
58
|
});
|
53
59
|
exports.jiraCreateJiraTicketOutputSchema = zod_1.z.object({
|
54
60
|
ticketUrl: zod_1.z.string().describe("The url to the created Jira Ticket"),
|
@@ -140,6 +146,38 @@ exports.credalCallCopilotParamsSchema = zod_1.z.object({
|
|
140
146
|
});
|
141
147
|
exports.credalCallCopilotOutputSchema = zod_1.z.object({
|
142
148
|
response: zod_1.z.string().describe("The response from the Credal Copilot"),
|
149
|
+
referencedSources: zod_1.z
|
150
|
+
.array(zod_1.z
|
151
|
+
.object({
|
152
|
+
id: zod_1.z.string().describe("The id of the source"),
|
153
|
+
externalResourceId: zod_1.z
|
154
|
+
.object({
|
155
|
+
externalResourceId: zod_1.z.string().describe("The external resource id of the source"),
|
156
|
+
resourceType: zod_1.z.string().describe("The type of the resource"),
|
157
|
+
})
|
158
|
+
.describe("The external resource id of the source"),
|
159
|
+
name: zod_1.z.string().describe("The name of the source"),
|
160
|
+
url: zod_1.z.string().describe("The url of the source").optional(),
|
161
|
+
})
|
162
|
+
.describe("The source referenced in the response"))
|
163
|
+
.describe("The sources referenced in the response")
|
164
|
+
.optional(),
|
165
|
+
sourcesInDataContext: zod_1.z
|
166
|
+
.array(zod_1.z
|
167
|
+
.object({
|
168
|
+
id: zod_1.z.string().describe("The id of the source"),
|
169
|
+
externalResourceId: zod_1.z
|
170
|
+
.object({
|
171
|
+
externalResourceId: zod_1.z.string().describe("The external resource id of the source"),
|
172
|
+
resourceType: zod_1.z.string().describe("The type of the resource"),
|
173
|
+
})
|
174
|
+
.describe("The external resource id of the source"),
|
175
|
+
name: zod_1.z.string().describe("The name of the source"),
|
176
|
+
url: zod_1.z.string().describe("The url of the source").optional(),
|
177
|
+
})
|
178
|
+
.describe("The source in the data context of the response"))
|
179
|
+
.describe("The sources in the data context of the response")
|
180
|
+
.optional(),
|
143
181
|
});
|
144
182
|
exports.zendeskCreateZendeskTicketParamsSchema = zod_1.z.object({
|
145
183
|
subject: zod_1.z.string().describe("The subject of the ticket"),
|
@@ -245,3 +283,57 @@ exports.googleOauthCreateNewGoogleDocOutputSchema = zod_1.z.object({
|
|
245
283
|
documentId: zod_1.z.string().describe("The ID of the created Google Doc"),
|
246
284
|
documentUrl: zod_1.z.string().describe("The URL to access the created Google Doc").optional(),
|
247
285
|
});
|
286
|
+
exports.finnhubSymbolLookupParamsSchema = zod_1.z.object({ query: zod_1.z.string().describe("The query to look up") });
|
287
|
+
exports.finnhubSymbolLookupOutputSchema = zod_1.z.object({
|
288
|
+
result: zod_1.z
|
289
|
+
.array(zod_1.z
|
290
|
+
.object({
|
291
|
+
symbol: zod_1.z.string().describe("The symbol of the stock").optional(),
|
292
|
+
description: zod_1.z.string().describe("The description of the stock").optional(),
|
293
|
+
})
|
294
|
+
.describe("The metadata of the stock"))
|
295
|
+
.describe("The results of the symbol lookup"),
|
296
|
+
});
|
297
|
+
exports.finnhubGetBasicFinancialsParamsSchema = zod_1.z.object({
|
298
|
+
symbol: zod_1.z.string().describe("The symbol/TICKER of the stock"),
|
299
|
+
});
|
300
|
+
exports.finnhubGetBasicFinancialsOutputSchema = zod_1.z.object({
|
301
|
+
result: zod_1.z
|
302
|
+
.object({
|
303
|
+
annual: zod_1.z
|
304
|
+
.array(zod_1.z
|
305
|
+
.object({
|
306
|
+
metric: zod_1.z.string().describe("The name of the financial metric").optional(),
|
307
|
+
series: zod_1.z
|
308
|
+
.array(zod_1.z
|
309
|
+
.object({
|
310
|
+
period: zod_1.z.string().describe("The period of the financial metric in YYYY-MM-DD format").optional(),
|
311
|
+
v: zod_1.z.number().describe("The value of the financial metric").optional(),
|
312
|
+
})
|
313
|
+
.describe("The value of the financial metric"))
|
314
|
+
.describe("The series of values for the financial metric")
|
315
|
+
.optional(),
|
316
|
+
})
|
317
|
+
.describe("The annual financials of the stock"))
|
318
|
+
.describe("The annual financials of the stock")
|
319
|
+
.optional(),
|
320
|
+
quarterly: zod_1.z
|
321
|
+
.array(zod_1.z
|
322
|
+
.object({
|
323
|
+
metric: zod_1.z.string().describe("The name of the financial metric").optional(),
|
324
|
+
series: zod_1.z
|
325
|
+
.array(zod_1.z
|
326
|
+
.object({
|
327
|
+
period: zod_1.z.string().describe("The period of the financial metric in YYYY-MM-DD format").optional(),
|
328
|
+
v: zod_1.z.number().describe("The value of the financial metric").optional(),
|
329
|
+
})
|
330
|
+
.describe("The value of the financial metric"))
|
331
|
+
.describe("The series of values for the financial metric")
|
332
|
+
.optional(),
|
333
|
+
})
|
334
|
+
.describe("The quarterly financials of the stock"))
|
335
|
+
.describe("The quarterly financials of the stock")
|
336
|
+
.optional(),
|
337
|
+
})
|
338
|
+
.describe("The basic financials of the stock"),
|
339
|
+
});
|
package/dist/actions/groups.js
CHANGED
@@ -67,4 +67,8 @@ exports.ACTION_GROUPS = {
|
|
67
67
|
description: "Actions for interacting with X(formerly twitter)",
|
68
68
|
actions: [templates_1.xCreateShareXPostUrlDefinition],
|
69
69
|
},
|
70
|
+
FINNHUB: {
|
71
|
+
description: "Action for interacting with Finnhub for stock market data",
|
72
|
+
actions: [templates_1.finnhubSymbolLookupDefinition, templates_1.finnhubGetBasicFinancialsDefinition],
|
73
|
+
},
|
70
74
|
};
|
package/dist/actions/parse.js
CHANGED
@@ -8,30 +8,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const
|
16
|
-
function
|
17
|
-
|
12
|
+
const axiosClient_1 = require("../../util/axiosClient");
|
13
|
+
function getConfluenceRequestConfig(baseUrl, username, apiToken) {
|
14
|
+
return {
|
18
15
|
baseURL: baseUrl,
|
19
16
|
headers: {
|
20
17
|
Accept: "application/json",
|
21
|
-
// Tokens are associated with a specific user.
|
22
18
|
Authorization: `Basic ${Buffer.from(`${username}:${apiToken}`).toString("base64")}`,
|
23
19
|
},
|
24
|
-
}
|
25
|
-
return api;
|
20
|
+
};
|
26
21
|
}
|
27
22
|
const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
28
23
|
const { pageId, username, content, title } = params;
|
29
24
|
const { baseUrl, authToken } = authParams;
|
30
|
-
const
|
25
|
+
const config = getConfluenceRequestConfig(baseUrl, username, authToken);
|
31
26
|
// Get current version number
|
32
|
-
const response = yield
|
27
|
+
const response = yield axiosClient_1.axiosClient.get(`/api/v2/pages/${pageId}`, config);
|
33
28
|
const currVersion = response.data.version.number;
|
34
|
-
|
29
|
+
const payload = {
|
35
30
|
id: pageId,
|
36
31
|
status: "current",
|
37
32
|
title,
|
@@ -42,6 +37,7 @@ const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* (
|
|
42
37
|
version: {
|
43
38
|
number: currVersion + 1,
|
44
39
|
},
|
45
|
-
}
|
40
|
+
};
|
41
|
+
yield axiosClient_1.axiosClient.put(`/api/v2/pages/${pageId}`, payload, config);
|
46
42
|
});
|
47
43
|
exports.default = confluenceUpdatePage;
|
@@ -28,6 +28,8 @@ const callCopilot = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
|
|
28
28
|
response: response.sendChatResult.type === "ai_response_result"
|
29
29
|
? response.sendChatResult.response.message
|
30
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 : [],
|
31
33
|
};
|
32
34
|
});
|
33
35
|
exports.default = callCopilot;
|
@@ -0,0 +1,48 @@
|
|
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 types_1 = require("../../autogen/types");
|
13
|
+
const axiosClient_1 = require("../../util/axiosClient");
|
14
|
+
function transformData(data) {
|
15
|
+
return Object.entries(data).map(([key, value]) => ({
|
16
|
+
metric: key,
|
17
|
+
series: value.map(item => {
|
18
|
+
var _a;
|
19
|
+
return ({
|
20
|
+
period: item.period,
|
21
|
+
v: (_a = item.v) !== null && _a !== void 0 ? _a : undefined,
|
22
|
+
});
|
23
|
+
}),
|
24
|
+
}));
|
25
|
+
}
|
26
|
+
const getBasicFinancials = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
27
|
+
try {
|
28
|
+
const apiKey = authParams.apiKey;
|
29
|
+
const result = yield axiosClient_1.axiosClient.get(`https://finnhub.io/api/v1/stock/metric?symbol=${params.symbol}`, {
|
30
|
+
headers: {
|
31
|
+
"X-Finnhub-Token": apiKey,
|
32
|
+
},
|
33
|
+
});
|
34
|
+
return types_1.finnhubGetBasicFinancialsOutputSchema.parse({
|
35
|
+
result: {
|
36
|
+
annual: transformData(result.data.series.annual),
|
37
|
+
quarterly: transformData(result.data.series.quarterly),
|
38
|
+
},
|
39
|
+
});
|
40
|
+
}
|
41
|
+
catch (error) {
|
42
|
+
console.error(error);
|
43
|
+
return types_1.finnhubGetBasicFinancialsOutputSchema.parse({
|
44
|
+
result: {},
|
45
|
+
});
|
46
|
+
}
|
47
|
+
});
|
48
|
+
exports.default = getBasicFinancials;
|
@@ -0,0 +1,33 @@
|
|
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 types_1 = require("../../autogen/types");
|
13
|
+
const axiosClient_1 = require("../../util/axiosClient");
|
14
|
+
const symbolLookup = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
15
|
+
try {
|
16
|
+
const apiKey = authParams.apiKey;
|
17
|
+
const result = yield axiosClient_1.axiosClient.get(`https://finnhub.io/api/v1/search?q=${params.query}`, {
|
18
|
+
headers: {
|
19
|
+
"X-Finnhub-Token": apiKey,
|
20
|
+
},
|
21
|
+
});
|
22
|
+
return types_1.finnhubSymbolLookupOutputSchema.parse({
|
23
|
+
result: result.data.result,
|
24
|
+
});
|
25
|
+
}
|
26
|
+
catch (error) {
|
27
|
+
console.error(error);
|
28
|
+
return types_1.finnhubSymbolLookupOutputSchema.parse({
|
29
|
+
result: [],
|
30
|
+
});
|
31
|
+
}
|
32
|
+
});
|
33
|
+
exports.default = symbolLookup;
|
@@ -8,63 +8,51 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const
|
12
|
+
const axiosClient_1 = require("../../util/axiosClient");
|
16
13
|
/**
|
17
14
|
* Creates a new Google Doc document using OAuth authentication
|
18
15
|
*/
|
19
16
|
const createNewGoogleDoc = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
20
|
-
var _b, _c, _d;
|
21
17
|
if (!authParams.authToken) {
|
22
18
|
throw new Error("authToken is required for Google Docs API");
|
23
19
|
}
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
20
|
+
const { title, content } = params;
|
21
|
+
const baseApiUrl = "https://docs.googleapis.com/v1/documents";
|
22
|
+
// Create the document with the provided title
|
23
|
+
const response = yield axiosClient_1.axiosClient.post(baseApiUrl, { title }, {
|
24
|
+
headers: {
|
25
|
+
Authorization: `Bearer ${authParams.authToken}`,
|
26
|
+
"Content-Type": "application/json",
|
27
|
+
},
|
28
|
+
});
|
29
|
+
// If content is provided, update the document body with the content
|
30
|
+
if (content) {
|
31
|
+
const documentId = response.data.documentId;
|
32
|
+
// Add the description to the document content
|
33
|
+
yield axiosClient_1.axiosClient.post(`${baseApiUrl}/${documentId}:batchUpdate`, {
|
34
|
+
requests: [
|
35
|
+
{
|
36
|
+
insertText: {
|
37
|
+
location: {
|
38
|
+
index: 1, // Insert at the beginning of the document
|
39
|
+
},
|
40
|
+
text: content,
|
41
|
+
},
|
42
|
+
},
|
43
|
+
],
|
44
|
+
}, {
|
29
45
|
headers: {
|
30
46
|
Authorization: `Bearer ${authParams.authToken}`,
|
31
47
|
"Content-Type": "application/json",
|
32
48
|
},
|
33
49
|
});
|
34
|
-
// If description is provided, update the document body with the description
|
35
|
-
if (content) {
|
36
|
-
const documentId = response.data.documentId;
|
37
|
-
// Add the description to the document content
|
38
|
-
yield axios_1.default.post(`${baseApiUrl}/${documentId}:batchUpdate`, {
|
39
|
-
requests: [
|
40
|
-
{
|
41
|
-
insertText: {
|
42
|
-
location: {
|
43
|
-
index: 1, // Insert at the beginning of the document
|
44
|
-
},
|
45
|
-
text: content,
|
46
|
-
},
|
47
|
-
},
|
48
|
-
],
|
49
|
-
}, {
|
50
|
-
headers: {
|
51
|
-
Authorization: `Bearer ${authParams.authToken}`,
|
52
|
-
"Content-Type": "application/json",
|
53
|
-
},
|
54
|
-
});
|
55
|
-
}
|
56
|
-
return {
|
57
|
-
documentId: response.data.documentId,
|
58
|
-
documentUrl: response.data.documentId
|
59
|
-
? `https://docs.google.com/document/d/${response.data.documentId}/edit`
|
60
|
-
: undefined,
|
61
|
-
};
|
62
|
-
}
|
63
|
-
catch (error) {
|
64
|
-
if (axios_1.default.isAxiosError(error)) {
|
65
|
-
throw new Error(`Google Docs API error: ${((_d = (_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.message) || error.message}`);
|
66
|
-
}
|
67
|
-
throw error;
|
68
50
|
}
|
51
|
+
return {
|
52
|
+
documentId: response.data.documentId,
|
53
|
+
documentUrl: response.data.documentId
|
54
|
+
? `https://docs.google.com/document/d/${response.data.documentId}/edit`
|
55
|
+
: undefined,
|
56
|
+
};
|
69
57
|
});
|
70
58
|
exports.default = createNewGoogleDoc;
|
@@ -8,12 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const axios_1 = __importDefault(require("axios"));
|
16
12
|
const types_1 = require("../../autogen/types");
|
13
|
+
const axiosClient_1 = require("../../util/axiosClient");
|
17
14
|
const INCLUDED_TYPES = ["restaurant"];
|
18
15
|
const nearbysearchRestaurants = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
19
16
|
const url = `https://places.googleapis.com/v1/places:searchNearby`;
|
@@ -27,7 +24,7 @@ const nearbysearchRestaurants = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
27
24
|
"places.regularOpeningHours",
|
28
25
|
"places.websiteUri",
|
29
26
|
].join(",");
|
30
|
-
const response = yield
|
27
|
+
const response = yield axiosClient_1.axiosClient.post(url, {
|
31
28
|
maxResultCount: 20,
|
32
29
|
includedTypes: INCLUDED_TYPES,
|
33
30
|
locationRestriction: {
|
@@ -8,11 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const
|
12
|
+
const axiosClient_1 = require("../../util/axiosClient");
|
16
13
|
const validateAddress = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
17
14
|
const url = `https://addressvalidation.googleapis.com/v1:validateAddress?key=${authParams.apiKey}`;
|
18
15
|
const requestBody = {
|
@@ -20,7 +17,7 @@ const validateAddress = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
|
|
20
17
|
addressLines: [...params.addressLines, params.locality, params.regionCode, params.postalCode],
|
21
18
|
},
|
22
19
|
};
|
23
|
-
const response = yield
|
20
|
+
const response = yield axiosClient_1.axiosClient.post(url, requestBody, {
|
24
21
|
headers: {
|
25
22
|
"Content-Type": "application/json",
|
26
23
|
},
|
@@ -8,18 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const
|
16
|
-
function getUserAccountId(email,
|
12
|
+
const axiosClient_1 = require("../../util/axiosClient");
|
13
|
+
function getUserAccountId(email, apiUrl, authToken) {
|
17
14
|
return __awaiter(this, void 0, void 0, function* () {
|
18
15
|
try {
|
19
|
-
const response = yield
|
16
|
+
const response = yield axiosClient_1.axiosClient.get(`${apiUrl}/user/search?query=${encodeURIComponent(email)}`, {
|
20
17
|
headers: {
|
21
|
-
Authorization: `
|
22
|
-
|
18
|
+
Authorization: `Bearer ${authToken}`,
|
19
|
+
Accept: "application/json",
|
23
20
|
},
|
24
21
|
});
|
25
22
|
if (response.data && response.data.length > 0) {
|
@@ -28,6 +25,7 @@ function getUserAccountId(email, baseUrl, authToken, username) {
|
|
28
25
|
return null;
|
29
26
|
}
|
30
27
|
catch (error) {
|
28
|
+
// Try to complete request without assignee/reporter.
|
31
29
|
const axiosError = error;
|
32
30
|
console.error("Error finding user:", axiosError.message);
|
33
31
|
return null;
|
@@ -35,59 +33,49 @@ function getUserAccountId(email, baseUrl, authToken, username) {
|
|
35
33
|
});
|
36
34
|
}
|
37
35
|
const createJiraTicket = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
38
|
-
const { authToken,
|
39
|
-
const
|
36
|
+
const { authToken, cloudId, baseUrl } = authParams;
|
37
|
+
const apiUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/`;
|
38
|
+
if (!cloudId) {
|
39
|
+
throw new Error("Cloud ID is required to create a Jira ticket");
|
40
|
+
}
|
40
41
|
// If assignee is an email, look up the account ID
|
41
42
|
let reporterId = null;
|
42
|
-
if (params.reporter &&
|
43
|
-
|
44
|
-
params.reporter.includes("@") &&
|
45
|
-
baseUrl &&
|
46
|
-
authToken &&
|
47
|
-
username) {
|
48
|
-
reporterId = yield getUserAccountId(params.reporter, baseUrl, authToken, username);
|
43
|
+
if (params.reporter && typeof params.reporter === "string" && params.reporter.includes("@") && authToken) {
|
44
|
+
reporterId = yield getUserAccountId(params.reporter, apiUrl, authToken);
|
49
45
|
}
|
50
46
|
// If assignee is an email, look up the account ID
|
51
47
|
let assigneeId = null;
|
52
|
-
if (params.assignee &&
|
53
|
-
|
54
|
-
params.assignee.includes("@") &&
|
55
|
-
baseUrl &&
|
56
|
-
authToken &&
|
57
|
-
username) {
|
58
|
-
assigneeId = yield getUserAccountId(params.assignee, baseUrl, authToken, username);
|
48
|
+
if (params.assignee && typeof params.assignee === "string" && params.assignee.includes("@") && authToken) {
|
49
|
+
assigneeId = yield getUserAccountId(params.assignee, apiUrl, authToken);
|
59
50
|
}
|
60
|
-
const description =
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
}
|
76
|
-
: params.description;
|
51
|
+
const description = {
|
52
|
+
type: "doc",
|
53
|
+
version: 1,
|
54
|
+
content: [
|
55
|
+
{
|
56
|
+
type: "paragraph",
|
57
|
+
content: [
|
58
|
+
{
|
59
|
+
type: "text",
|
60
|
+
text: params.description,
|
61
|
+
},
|
62
|
+
],
|
63
|
+
},
|
64
|
+
],
|
65
|
+
};
|
77
66
|
const payload = {
|
78
|
-
fields: Object.assign(Object.assign({ project: {
|
67
|
+
fields: Object.assign(Object.assign(Object.assign({ project: {
|
79
68
|
key: params.projectKey,
|
80
69
|
}, summary: params.summary, description: description, issuetype: {
|
81
70
|
name: params.issueType,
|
82
|
-
} }, (reporterId ? { reporter: { id: reporterId } } : {})), (assigneeId ? { assignee: { id: assigneeId } } : {})),
|
71
|
+
} }, (reporterId ? { reporter: { id: reporterId } } : {})), (assigneeId ? { assignee: { id: assigneeId } } : {})), (params.customFields ? params.customFields : {})),
|
83
72
|
};
|
84
|
-
const response = yield
|
73
|
+
const response = yield axiosClient_1.axiosClient.post(`${apiUrl}/issue`, payload, {
|
85
74
|
headers: {
|
86
|
-
Authorization: `
|
87
|
-
|
75
|
+
Authorization: `Bearer ${authToken}`,
|
76
|
+
Accept: "application/json",
|
88
77
|
},
|
89
78
|
});
|
90
|
-
// At the end of your function, wrap the response
|
91
79
|
return {
|
92
80
|
ticketUrl: `${baseUrl}/browse/${response.data.key}`,
|
93
81
|
};
|
@@ -8,12 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const axios_1 = __importDefault(require("axios"));
|
16
12
|
const datetime_1 = require("../../../utils/datetime");
|
13
|
+
const axiosClient_1 = require("../../util/axiosClient");
|
17
14
|
const getForecastForLocation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
18
15
|
const { latitude, longitude, isoDate } = params;
|
19
16
|
const { userAgent } = authParams;
|
@@ -21,9 +18,9 @@ const getForecastForLocation = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
21
18
|
throw new Error("Invalid ISO date format");
|
22
19
|
}
|
23
20
|
const url = `https://api.weather.gov/points/${latitude},${longitude}`;
|
24
|
-
const pointsResponse = yield
|
21
|
+
const pointsResponse = yield axiosClient_1.axiosClient.get(url, { headers: { "User-Agent": userAgent } });
|
25
22
|
const forecastUrl = pointsResponse.data.properties.forecast;
|
26
|
-
const forecastResponse = yield
|
23
|
+
const forecastResponse = yield axiosClient_1.axiosClient.get(forecastUrl, {
|
27
24
|
headers: { "User-Agent": userAgent },
|
28
25
|
});
|
29
26
|
const forecastData = forecastResponse.data;
|
@@ -8,16 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const
|
12
|
+
const axiosClient_1 = require("../../util/axiosClient");
|
16
13
|
const getLatitudeLongitudeFromLocation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
17
14
|
const { location } = params;
|
18
15
|
const { userAgent } = authParams;
|
19
16
|
const url = `https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(location)}&format=json`;
|
20
|
-
const response = yield
|
17
|
+
const response = yield axiosClient_1.axiosClient.get(url, { headers: { "User-Agent": userAgent } });
|
21
18
|
return response.data.map((result) => ({
|
22
19
|
latitude: parseFloat(result.lat),
|
23
20
|
longitude: parseFloat(result.lon),
|
@@ -13,7 +13,10 @@ const createXSharePostUrl = ({ params, }) => {
|
|
13
13
|
}
|
14
14
|
// Add hashtags parameter if it exists
|
15
15
|
if (params.hashtag && params.hashtag.length > 0) {
|
16
|
-
|
16
|
+
const cleanedHashtags = params.hashtag.map(tag => tag.replace(/^#+/, "").trim()).filter(tag => tag.length > 0);
|
17
|
+
if (cleanedHashtags.length > 0) {
|
18
|
+
queryParams.append("hashtags", cleanedHashtags.join(","));
|
19
|
+
}
|
17
20
|
}
|
18
21
|
// Add via parameter if it exists
|
19
22
|
if (params.via) {
|
@@ -8,11 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const
|
12
|
+
const axiosClient_1 = require("../../util/axiosClient");
|
16
13
|
const createZendeskTicket = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
17
14
|
const { apiKey } = authParams;
|
18
15
|
const { subdomain, subject, body, requesterEmail } = params;
|
@@ -29,7 +26,7 @@ const createZendeskTicket = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
29
26
|
throw new Error("API key is required");
|
30
27
|
}
|
31
28
|
try {
|
32
|
-
const response = yield
|
29
|
+
const response = yield axiosClient_1.axiosClient.post(url, payload, {
|
33
30
|
auth: {
|
34
31
|
username: `${requesterEmail}/token`,
|
35
32
|
password: apiKey,
|