@credal/actions 0.2.72 → 0.2.74

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.
@@ -7,13 +7,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { microsoftCreateDocumentDefinition } from "../../autogen/templates.js";
11
10
  import { getGraphClient, validateAndSanitizeFileName } from "./utils.js";
12
11
  const createDocument = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
13
12
  const { folderId, name, content, siteId } = params;
14
13
  let client = undefined;
15
14
  try {
16
- client = yield getGraphClient(authParams, microsoftCreateDocumentDefinition.scopes.join(" "));
15
+ client = yield getGraphClient(authParams);
17
16
  }
18
17
  catch (error) {
19
18
  return {
@@ -12,7 +12,7 @@ const getDocument = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
12
12
  const { siteId, documentId } = params;
13
13
  let client;
14
14
  try {
15
- client = yield getGraphClient(authParams, "Files.ReadWrite Sites.ReadWrite.All");
15
+ client = yield getGraphClient(authParams);
16
16
  }
17
17
  catch (error) {
18
18
  return {
@@ -7,13 +7,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { microsoftMessageTeamsChannelDefinition } from "../../autogen/templates.js";
11
10
  import { getGraphClient } from "./utils.js";
12
11
  const sendMessageToTeamsChannel = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
13
12
  const { channelId, teamId, message } = params;
14
13
  let client = undefined;
15
14
  try {
16
- client = yield getGraphClient(authParams, microsoftMessageTeamsChannelDefinition.scopes.join(" "));
15
+ client = yield getGraphClient(authParams);
17
16
  }
18
17
  catch (error) {
19
18
  return {
@@ -7,13 +7,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { microsoftMessageTeamsChatDefinition } from "../../autogen/templates.js";
11
10
  import { getGraphClient } from "./utils.js";
12
11
  const sendMessageToTeamsChat = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
13
12
  const { chatId, message } = params;
14
13
  let client = undefined;
15
14
  try {
16
- client = yield getGraphClient(authParams, microsoftMessageTeamsChatDefinition.scopes.join(" "));
15
+ client = yield getGraphClient(authParams);
17
16
  }
18
17
  catch (error) {
19
18
  return {
@@ -7,13 +7,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { microsoftUpdateDocumentDefinition } from "../../autogen/templates.js";
11
10
  import { getGraphClient } from "./utils.js";
12
11
  const updateDocument = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
13
12
  const { documentId, content, siteId } = params;
14
13
  let client = undefined;
15
14
  try {
16
- client = yield getGraphClient(authParams, microsoftUpdateDocumentDefinition.scopes.join(" "));
15
+ client = yield getGraphClient(authParams);
17
16
  }
18
17
  catch (error) {
19
18
  return {
@@ -7,13 +7,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { microsoftUpdateSpreadsheetDefinition } from "../../autogen/templates.js";
11
10
  import { getGraphClient } from "./utils.js";
12
11
  const updateSpreadsheet = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
13
12
  const { spreadsheetId, range, values, siteId } = params; // Added siteId to destructured params
14
13
  let client = undefined;
15
14
  try {
16
- client = yield getGraphClient(authParams, microsoftUpdateSpreadsheetDefinition.scopes.join(" "));
15
+ client = yield getGraphClient(authParams);
17
16
  }
18
17
  catch (error) {
19
18
  return {
@@ -1,6 +1,6 @@
1
1
  import { Client } from "@microsoft/microsoft-graph-client";
2
2
  import type { AuthParamsType } from "../../autogen/types.js";
3
- export declare function getGraphClient(authParams: AuthParamsType, scope: string): Promise<Client>;
3
+ export declare function getGraphClient(authParams: AuthParamsType): Promise<Client>;
4
4
  /**
5
5
  * Validates and sanitizes a filename for SharePoint or OneDrive.
6
6
  * @param fileName The original filename to validate and sanitize.
@@ -8,29 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { Client } from "@microsoft/microsoft-graph-client";
11
- import { axiosClient } from "../../util/axiosClient.js";
12
- export function getGraphClient(authParams, scope) {
11
+ export function getGraphClient(authParams) {
13
12
  return __awaiter(this, void 0, void 0, function* () {
14
- if (!authParams.clientId ||
15
- !authParams.clientSecret ||
16
- !authParams.tenantId ||
17
- !authParams.refreshToken ||
18
- !authParams.redirectUri) {
13
+ if (!authParams.authToken) {
19
14
  throw new Error("Missing required authentication parameters");
20
15
  }
21
- const url = `https://login.microsoftonline.com/${authParams.tenantId}/oauth2/v2.0/token`;
22
- const params = new URLSearchParams({
23
- client_id: authParams.clientId,
24
- client_secret: authParams.clientSecret,
25
- scope: `offline_access ${scope}`,
26
- grant_type: "refresh_token",
27
- refresh_token: authParams.refreshToken,
28
- redirect_uri: authParams.redirectUri,
29
- });
30
- const response = yield axiosClient.post(url, params, {
31
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
32
- });
33
- const accessToken = response.data.access_token;
16
+ const accessToken = authParams.authToken;
34
17
  return Client.init({
35
18
  authProvider: done => {
36
19
  done(null, accessToken);
@@ -37,7 +37,7 @@ const getSalesforceRecordsByQuery = (_a) => __awaiter(void 0, [_a], void 0, func
37
37
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
38
  const recordsWithUrl = (_b = response.data.records) === null || _b === void 0 ? void 0 : _b.map((record) => {
39
39
  const recordId = record.Id;
40
- const webUrl = recordId ? `${baseUrl}/lightning/${recordId}` : undefined;
40
+ const webUrl = recordId ? `${baseUrl}/lightning/r/${recordId}/view` : undefined;
41
41
  return Object.assign(Object.assign({}, record), { webUrl });
42
42
  });
43
43
  return {
@@ -47,7 +47,7 @@ const searchSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, function
47
47
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
48
  const recordsWithUrl = response.data.searchRecords.map((record) => {
49
49
  const recordId = record.Id;
50
- const webUrl = recordId ? `${baseUrl}/lightning/${recordId}` : undefined;
50
+ const webUrl = recordId ? `${baseUrl}/lightning/r/${recordId}/view` : undefined;
51
51
  return Object.assign(Object.assign({}, record), { webUrl });
52
52
  });
53
53
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.2.72",
3
+ "version": "0.2.74",
4
4
  "type": "module",
5
5
  "description": "AI Actions by Credal AI",
6
6
  "sideEffects": false,