@credal/actions 0.1.14 → 0.1.15

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.
@@ -11,12 +11,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const sdk_1 = require("@credal/sdk");
13
13
  const callCopilot = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
+ var _b;
14
15
  const requestBody = {
15
16
  agentId: params.agentId,
16
17
  query: params.query,
17
18
  userEmail: params.userEmail,
18
19
  };
19
- const client = new sdk_1.CredalClient({ apiKey: authParams.apiKey });
20
+ const baseUrl = (_b = authParams.baseUrl) !== null && _b !== void 0 ? _b : "https://app.credal.ai/api";
21
+ const client = new sdk_1.CredalClient({ environment: baseUrl, apiKey: authParams.apiKey });
20
22
  const response = yield client.copilots.sendMessage({
21
23
  agentId: requestBody.agentId,
22
24
  message: requestBody.query,
@@ -0,0 +1,23 @@
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>;
@@ -0,0 +1,88 @@
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "AI Actions by Credal AI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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;