@credal/actions 0.1.3 → 0.1.4

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.
@@ -16,6 +16,7 @@ const getRowByFieldValue_1 = __importDefault(require("./providers/snowflake/getR
16
16
  const createZendeskTicket_1 = __importDefault(require("./providers/zendesk/createZendeskTicket"));
17
17
  const createJiraTicket_1 = __importDefault(require("./providers/jira/createJiraTicket"));
18
18
  const getLatitudeLongitudeFromLocation_1 = __importDefault(require("./providers/openstreetmap/getLatitudeLongitudeFromLocation"));
19
+ const getForecastForLocation_1 = __importDefault(require("./providers/nws/getForecastForLocation"));
19
20
  exports.ActionMapper = {
20
21
  math: {
21
22
  add: {
@@ -92,4 +93,11 @@ exports.ActionMapper = {
92
93
  outputSchema: types_1.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema,
93
94
  },
94
95
  },
96
+ nws: {
97
+ getForecastForLocation: {
98
+ fn: getForecastForLocation_1.default,
99
+ paramsSchema: types_1.nwsGetForecastForLocationParamsSchema,
100
+ outputSchema: types_1.nwsGetForecastForLocationOutputSchema,
101
+ },
102
+ },
95
103
  };
@@ -0,0 +1,5 @@
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;
@@ -0,0 +1,132 @@
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
+ };
@@ -10,3 +10,4 @@ export declare const zendeskCreateZendeskTicketDefinition: ActionTemplate;
10
10
  export declare const mongoInsertMongoDocDefinition: ActionTemplate;
11
11
  export declare const snowflakeGetRowByFieldValueDefinition: ActionTemplate;
12
12
  export declare const openstreetmapGetLatitudeLongitudeFromLocationDefinition: ActionTemplate;
13
+ export declare const nwsGetForecastForLocationDefinition: ActionTemplate;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = exports.snowflakeGetRowByFieldValueDefinition = exports.mongoInsertMongoDocDefinition = exports.zendeskCreateZendeskTicketDefinition = exports.credalCallCopilotDefinition = exports.googlemapsValidateAddressDefinition = exports.jiraCreateJiraTicketDefinition = exports.confluenceUpdatePageDefinition = exports.mathAddDefinition = exports.slackListConversationsDefinition = exports.slackSendMessageDefinition = void 0;
3
+ exports.nwsGetForecastForLocationDefinition = exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = exports.snowflakeGetRowByFieldValueDefinition = exports.mongoInsertMongoDocDefinition = exports.zendeskCreateZendeskTicketDefinition = exports.credalCallCopilotDefinition = exports.googlemapsValidateAddressDefinition = exports.jiraCreateJiraTicketDefinition = exports.confluenceUpdatePageDefinition = exports.mathAddDefinition = exports.slackListConversationsDefinition = exports.slackSendMessageDefinition = void 0;
4
4
  exports.slackSendMessageDefinition = {
5
5
  description: "Sends a message to a Slack channel",
6
6
  scopes: ["chat:write"],
@@ -549,3 +549,51 @@ exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = {
549
549
  name: "getLatitudeLongitudeFromLocation",
550
550
  provider: "openstreetmap",
551
551
  };
552
+ exports.nwsGetForecastForLocationDefinition = {
553
+ description: "Get the weather forecast for a location using latitude and longitude",
554
+ scopes: [],
555
+ parameters: {
556
+ type: "object",
557
+ required: ["latitude", "longitude", "isoDate"],
558
+ properties: {
559
+ latitude: {
560
+ type: "number",
561
+ description: "The latitude of the location",
562
+ },
563
+ longitude: {
564
+ type: "number",
565
+ description: "The longitude of the location",
566
+ },
567
+ isoDate: {
568
+ type: "string",
569
+ description: "The date to get the forecast for, in ISO datetime format",
570
+ },
571
+ },
572
+ },
573
+ output: {
574
+ type: "object",
575
+ required: [],
576
+ properties: {
577
+ result: {
578
+ type: "object",
579
+ required: ["temperature", "temperatureUnit", "forecast"],
580
+ properties: {
581
+ temperature: {
582
+ type: "number",
583
+ description: "The temperature at the location",
584
+ },
585
+ temperatureUnit: {
586
+ type: "string",
587
+ description: "The unit of temperature",
588
+ },
589
+ forecast: {
590
+ type: "string",
591
+ description: "The forecast for the location",
592
+ },
593
+ },
594
+ },
595
+ },
596
+ },
597
+ name: "getForecastForLocation",
598
+ provider: "nws",
599
+ };
@@ -7,14 +7,17 @@ export declare const AuthParamsSchema: z.ZodObject<{
7
7
  authToken: z.ZodOptional<z.ZodString>;
8
8
  baseUrl: z.ZodOptional<z.ZodString>;
9
9
  apiKey: z.ZodOptional<z.ZodString>;
10
+ userAgent: z.ZodOptional<z.ZodString>;
10
11
  }, "strip", z.ZodTypeAny, {
11
12
  authToken?: string | undefined;
12
13
  baseUrl?: string | undefined;
13
14
  apiKey?: string | undefined;
15
+ userAgent?: string | undefined;
14
16
  }, {
15
17
  authToken?: string | undefined;
16
18
  baseUrl?: string | undefined;
17
19
  apiKey?: string | undefined;
20
+ userAgent?: string | undefined;
18
21
  }>;
19
22
  export type AuthParamsType = z.infer<typeof AuthParamsSchema>;
20
23
  export declare const slackSendMessageParamsSchema: z.ZodObject<{
@@ -530,3 +533,46 @@ export declare const openstreetmapGetLatitudeLongitudeFromLocationOutputSchema:
530
533
  }>;
531
534
  export type openstreetmapGetLatitudeLongitudeFromLocationOutputType = z.infer<typeof openstreetmapGetLatitudeLongitudeFromLocationOutputSchema>;
532
535
  export type openstreetmapGetLatitudeLongitudeFromLocationFunction = ActionFunction<openstreetmapGetLatitudeLongitudeFromLocationParamsType, AuthParamsType, openstreetmapGetLatitudeLongitudeFromLocationOutputType>;
536
+ export declare const nwsGetForecastForLocationParamsSchema: z.ZodObject<{
537
+ latitude: z.ZodNumber;
538
+ longitude: z.ZodNumber;
539
+ isoDate: z.ZodString;
540
+ }, "strip", z.ZodTypeAny, {
541
+ latitude: number;
542
+ longitude: number;
543
+ isoDate: string;
544
+ }, {
545
+ latitude: number;
546
+ longitude: number;
547
+ isoDate: string;
548
+ }>;
549
+ export type nwsGetForecastForLocationParamsType = z.infer<typeof nwsGetForecastForLocationParamsSchema>;
550
+ export declare const nwsGetForecastForLocationOutputSchema: z.ZodObject<{
551
+ result: z.ZodOptional<z.ZodObject<{
552
+ temperature: z.ZodNumber;
553
+ temperatureUnit: z.ZodString;
554
+ forecast: z.ZodString;
555
+ }, "strip", z.ZodTypeAny, {
556
+ temperature: number;
557
+ temperatureUnit: string;
558
+ forecast: string;
559
+ }, {
560
+ temperature: number;
561
+ temperatureUnit: string;
562
+ forecast: string;
563
+ }>>;
564
+ }, "strip", z.ZodTypeAny, {
565
+ result?: {
566
+ temperature: number;
567
+ temperatureUnit: string;
568
+ forecast: string;
569
+ } | undefined;
570
+ }, {
571
+ result?: {
572
+ temperature: number;
573
+ temperatureUnit: string;
574
+ forecast: string;
575
+ } | undefined;
576
+ }>;
577
+ export type nwsGetForecastForLocationOutputType = z.infer<typeof nwsGetForecastForLocationOutputSchema>;
578
+ export type nwsGetForecastForLocationFunction = ActionFunction<nwsGetForecastForLocationParamsType, AuthParamsType, nwsGetForecastForLocationOutputType>;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = exports.snowflakeGetRowByFieldValueOutputSchema = exports.snowflakeGetRowByFieldValueParamsSchema = exports.mongoInsertMongoDocOutputSchema = exports.mongoInsertMongoDocParamsSchema = exports.zendeskCreateZendeskTicketOutputSchema = exports.zendeskCreateZendeskTicketParamsSchema = exports.credalCallCopilotOutputSchema = exports.credalCallCopilotParamsSchema = 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.nwsGetForecastForLocationOutputSchema = exports.nwsGetForecastForLocationParamsSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = exports.snowflakeGetRowByFieldValueOutputSchema = exports.snowflakeGetRowByFieldValueParamsSchema = exports.mongoInsertMongoDocOutputSchema = exports.mongoInsertMongoDocParamsSchema = exports.zendeskCreateZendeskTicketOutputSchema = exports.zendeskCreateZendeskTicketParamsSchema = exports.credalCallCopilotOutputSchema = exports.credalCallCopilotParamsSchema = 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(),
7
7
  baseUrl: zod_1.z.string().optional(),
8
8
  apiKey: zod_1.z.string().optional(),
9
+ userAgent: zod_1.z.string().optional(),
9
10
  });
10
11
  exports.slackSendMessageParamsSchema = zod_1.z.object({
11
12
  channelName: zod_1.z.string().describe("The name of the Slack channel to send the message to (e.g. general, alerts)"),
@@ -167,3 +168,17 @@ exports.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema = zod_1.z.obje
167
168
  .describe("The results of the query")
168
169
  .optional(),
169
170
  });
171
+ exports.nwsGetForecastForLocationParamsSchema = zod_1.z.object({
172
+ latitude: zod_1.z.number().describe("The latitude of the location"),
173
+ longitude: zod_1.z.number().describe("The longitude of the location"),
174
+ isoDate: zod_1.z.string().describe("The date to get the forecast for, in ISO datetime format"),
175
+ });
176
+ exports.nwsGetForecastForLocationOutputSchema = zod_1.z.object({
177
+ result: zod_1.z
178
+ .object({
179
+ temperature: zod_1.z.number().describe("The temperature at the location"),
180
+ temperatureUnit: zod_1.z.string().describe("The unit of temperature"),
181
+ forecast: zod_1.z.string().describe("The forecast for the location"),
182
+ })
183
+ .optional(),
184
+ });
@@ -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
+ };
@@ -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
+ };
@@ -43,6 +43,7 @@ z.object({
43
43
  authToken: z.string().optional(),
44
44
  baseUrl: z.string().optional(),
45
45
  apiKey: z.string().optional(),
46
+ userAgent: z.string().optional(),
46
47
  })
47
48
  `;
48
49
  function validateObject(object) {
@@ -0,0 +1,3 @@
1
+ import { jiraCreateTicketFunction } from "../../autogen/types";
2
+ declare const createTicket: jiraCreateTicketFunction;
3
+ export default createTicket;
@@ -0,0 +1,34 @@
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;
@@ -0,0 +1,3 @@
1
+ import { nwsGetForecastForLocationFunction } from "../../autogen/types";
2
+ declare const getForecastForLocation: nwsGetForecastForLocationFunction;
3
+ export default getForecastForLocation;
@@ -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
+ 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 datetime_1 = require("../../../utils/datetime");
17
+ const getForecastForLocation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
18
+ const { latitude, longitude, isoDate } = params;
19
+ const { userAgent } = authParams;
20
+ if (!(0, datetime_1.isValidIsoDatestring)(isoDate)) {
21
+ throw new Error("Invalid ISO date format");
22
+ }
23
+ const url = `https://api.weather.gov/points/${latitude},${longitude}`;
24
+ const pointsResponse = yield axios_1.default.get(url, { headers: { "User-Agent": userAgent } });
25
+ const forecastUrl = pointsResponse.data.properties.forecast;
26
+ const forecastResponse = yield axios_1.default.get(forecastUrl, {
27
+ headers: { "User-Agent": userAgent },
28
+ });
29
+ const forecastData = forecastResponse.data;
30
+ // Step 4: Filter for the target date
31
+ const targetDateString = isoDate.split("T")[0];
32
+ const relevantForecasts = forecastData.properties.periods.filter((period) => {
33
+ return (0, datetime_1.isBetweenDatetime)(targetDateString, period.startTime, period.endTime);
34
+ });
35
+ let result;
36
+ if (relevantForecasts.length > 0) {
37
+ result = {
38
+ temperature: relevantForecasts[0].temperature,
39
+ temperatureUnit: relevantForecasts[0].temperatureUnit,
40
+ forecast: relevantForecasts[0].detailedForecast,
41
+ };
42
+ }
43
+ return { result };
44
+ });
45
+ exports.default = getForecastForLocation;
@@ -13,10 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const axios_1 = __importDefault(require("axios"));
16
- const getLatitudeLongitudeFromLocation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, }) {
16
+ const getLatitudeLongitudeFromLocation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
17
17
  const { location } = params;
18
+ const { userAgent } = authParams;
18
19
  const url = `https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(location)}&format=json`;
19
- const response = yield axios_1.default.get(url, { headers: { "User-Agent": "Credal/1.0" } });
20
+ const response = yield axios_1.default.get(url, { headers: { "User-Agent": userAgent } });
20
21
  return response.data.map((result) => ({
21
22
  latitude: parseFloat(result.lat),
22
23
  longitude: parseFloat(result.lon),
@@ -0,0 +1,3 @@
1
+ import { slackListConversationsFunction } from "../../../actions/autogen/types";
2
+ declare const slackListConversations: slackListConversationsFunction;
3
+ export default slackListConversations;
@@ -0,0 +1,60 @@
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 web_api_1 = require("@slack/web-api");
13
+ const slackListConversations = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams, }) {
14
+ var _b;
15
+ const client = new web_api_1.WebClient(authParams.authToken);
16
+ const allChannels = [];
17
+ let cursor;
18
+ const limit = 100;
19
+ try {
20
+ do {
21
+ const response = yield client.conversations.list({
22
+ exclude_archived: true,
23
+ limit: limit,
24
+ cursor: cursor,
25
+ });
26
+ if (!response.ok) {
27
+ throw new Error(`Slack API error: ${response.error}`);
28
+ }
29
+ // Add channels from this page to our results
30
+ if (response.channels && Array.isArray(response.channels)) {
31
+ allChannels.push(...response.channels);
32
+ }
33
+ // Get cursor for next page
34
+ cursor = (_b = response.response_metadata) === null || _b === void 0 ? void 0 : _b.next_cursor;
35
+ // If user specified a limit and we've hit it, stop paginating
36
+ if (limit && allChannels.length >= limit) {
37
+ allChannels.splice(limit); // Trim to exact limit
38
+ break;
39
+ }
40
+ } while (cursor && cursor.length > 0);
41
+ return {
42
+ channels: allChannels.map(channel => ({
43
+ id: channel.id,
44
+ name: channel.name,
45
+ topic: channel.topic.value,
46
+ purpose: channel.purpose.value,
47
+ })),
48
+ };
49
+ }
50
+ catch (error) {
51
+ if (error instanceof Error) {
52
+ // Enhance error with more context
53
+ throw new Error(`Failed to list Slack conversations: ${error.message}`);
54
+ }
55
+ else {
56
+ throw error;
57
+ }
58
+ }
59
+ });
60
+ exports.default = slackListConversations;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createParametersObject = createParametersObject;
4
+ function createParametersObject(parameters) {
5
+ return Object.fromEntries(Object.entries(parameters).map(([key, param]) => [key, param.type]));
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/main.js ADDED
@@ -0,0 +1,11 @@
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
+ const list_conversations_1 = __importDefault(require("./actions/providers/slack/list_conversations"));
7
+ const result = (0, list_conversations_1.default)({
8
+ accessToken: "xoxp-4172665288294-8092684180551-8154529379075-89f1f70cc06e5648e8f912ba96f56626"
9
+ }).then((result) => {
10
+ console.log(result);
11
+ });
@@ -0,0 +1,2 @@
1
+ export declare function isBetweenDatetime(isoDatetime: string, isoStart: string, isoEnd: string): boolean;
2
+ export declare function isValidIsoDatestring(isoDatetime: string): boolean;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBetweenDatetime = isBetweenDatetime;
4
+ exports.isValidIsoDatestring = isValidIsoDatestring;
5
+ const date_fns_1 = require("date-fns");
6
+ function isBetweenDatetime(isoDatetime, isoStart, isoEnd) {
7
+ const datetime = new Date(isoDatetime);
8
+ const start = new Date(isoStart);
9
+ const end = new Date(isoEnd);
10
+ return datetime >= start && datetime <= end;
11
+ }
12
+ function isValidIsoDatestring(isoDatetime) {
13
+ return (0, date_fns_1.isValid)((0, date_fns_1.parseISO)(isoDatetime));
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "AI Actions by Credal AI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -42,6 +42,7 @@
42
42
  "@slack/web-api": "^7.8.0",
43
43
  "@types/snowflake-sdk": "^1.6.24",
44
44
  "ajv": "^8.17.1",
45
+ "date-fns": "^4.1.0",
45
46
  "json-schema-to-zod": "^2.5.0",
46
47
  "mongodb": "^6.13.1",
47
48
  "snowflake-sdk": "^2.0.2",
@@ -1,23 +0,0 @@
1
- declare const axios: any;
2
- declare const WORKDAY_BASE_URL = "https://your-workday-url/ccx/service/YOUR_TENANT/Absence_Management/v43.2";
3
- declare const TOKEN_URL = "https://your-workday-url/oauth2/YOUR_TENANT/token";
4
- declare const CLIENT_ID = "your-client-id";
5
- declare const CLIENT_SECRET = "your-client-secret";
6
- /**
7
- * Fetches an OAuth 2.0 access token from Workday.
8
- */
9
- declare function getAccessToken(): Promise<any>;
10
- /**
11
- * Submits a time-off request to Workday.
12
- * @param {Object} params - Time-off details.
13
- * @param {string} params.workerId - Worker's ID in Workday.
14
- * @param {string} params.startDate - Start date (YYYY-MM-DD).
15
- * @param {string} params.endDate - End date (YYYY-MM-DD).
16
- * @param {string} params.timeOffType - Time-off type (e.g., "SICK_LEAVE").
17
- */
18
- declare function submitTimeOff({ workerId, startDate, endDate, timeOffType }: {
19
- workerId: any;
20
- startDate: any;
21
- endDate: any;
22
- timeOffType: any;
23
- }): Promise<any>;
@@ -1,88 +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
- const axios = require("axios");
12
- const WORKDAY_BASE_URL = "https://your-workday-url/ccx/service/YOUR_TENANT/Absence_Management/v43.2";
13
- const TOKEN_URL = "https://your-workday-url/oauth2/YOUR_TENANT/token"; // OAuth token endpoint
14
- const CLIENT_ID = "your-client-id";
15
- const CLIENT_SECRET = "your-client-secret";
16
- /**
17
- * Fetches an OAuth 2.0 access token from Workday.
18
- */
19
- function getAccessToken() {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- var _a;
22
- try {
23
- const response = yield axios.post(TOKEN_URL, new URLSearchParams({ grant_type: "client_credentials" }), {
24
- auth: {
25
- username: CLIENT_ID,
26
- password: CLIENT_SECRET
27
- },
28
- headers: { "Content-Type": "application/x-www-form-urlencoded" }
29
- });
30
- return response.data.access_token;
31
- }
32
- catch (error) {
33
- console.error("Error fetching access token:", ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || error.message);
34
- throw error;
35
- }
36
- });
37
- }
38
- /**
39
- * Submits a time-off request to Workday.
40
- * @param {Object} params - Time-off details.
41
- * @param {string} params.workerId - Worker's ID in Workday.
42
- * @param {string} params.startDate - Start date (YYYY-MM-DD).
43
- * @param {string} params.endDate - End date (YYYY-MM-DD).
44
- * @param {string} params.timeOffType - Time-off type (e.g., "SICK_LEAVE").
45
- */
46
- function submitTimeOff(_a) {
47
- return __awaiter(this, arguments, void 0, function* ({ workerId, startDate, endDate, timeOffType }) {
48
- var _b;
49
- try {
50
- const token = yield getAccessToken(); // Get OAuth token
51
- const requestBody = {
52
- "wd:Enter_Time_Off_Request": {
53
- "wd:Worker_Reference": {
54
- "wd:ID": [{ "_": workerId, "$": { "wd:type": "WID" } }]
55
- },
56
- "wd:Time_Off_Entries": [
57
- {
58
- "wd:Start_Date": startDate,
59
- "wd:End_Date": endDate,
60
- "wd:Time_Off_Type_Reference": {
61
- "wd:ID": [{ "_": timeOffType, "$": { "wd:type": "Time_Off_Type_ID" } }]
62
- }
63
- }
64
- ]
65
- }
66
- };
67
- const response = yield axios.post(`${WORKDAY_BASE_URL}/Enter_Time_Off`, requestBody, {
68
- headers: {
69
- "Authorization": `Bearer ${token}`,
70
- "Content-Type": "application/json"
71
- }
72
- });
73
- console.log("Time-off request submitted successfully:", response.data);
74
- return response.data;
75
- }
76
- catch (error) {
77
- console.error("Error submitting time-off request:", ((_b = error.response) === null || _b === void 0 ? void 0 : _b.data) || error.message);
78
- throw error;
79
- }
80
- });
81
- }
82
- // Example Usage:
83
- submitTimeOff({
84
- workerId: "12345",
85
- startDate: "2025-03-10",
86
- endDate: "2025-03-12",
87
- timeOffType: "SICK_LEAVE"
88
- }).then(console.log).catch(console.error);