microsoft-graph 3.2.1 → 3.2.3

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 (29) hide show
  1. package/dist/cjs/operations/driveItem/getDriveItemByPath.d.ts.map +1 -1
  2. package/dist/cjs/operations/driveItem/getDriveItemByPath.js +2 -1
  3. package/dist/cjs/services/sharepointUrl.d.ts +0 -9
  4. package/dist/cjs/services/sharepointUrl.d.ts.map +1 -1
  5. package/dist/cjs/services/sharepointUrl.js +0 -21
  6. package/dist/cjs/tasks/getSiteByUrl.d.ts +13 -0
  7. package/dist/cjs/tasks/getSiteByUrl.d.ts.map +1 -0
  8. package/dist/cjs/tasks/getSiteByUrl.js +26 -0
  9. package/dist/esm/operations/driveItem/getDriveItemByPath.d.ts.map +1 -1
  10. package/dist/esm/operations/driveItem/getDriveItemByPath.js +2 -1
  11. package/dist/esm/services/sharepointUrl.d.ts +0 -9
  12. package/dist/esm/services/sharepointUrl.d.ts.map +1 -1
  13. package/dist/esm/services/sharepointUrl.js +0 -21
  14. package/dist/esm/tasks/getSiteByUrl.d.ts +13 -0
  15. package/dist/esm/tasks/getSiteByUrl.d.ts.map +1 -0
  16. package/dist/esm/tasks/getSiteByUrl.js +20 -0
  17. package/docs/api/README.md +7 -2
  18. package/docs/api/services/sharepointUrl.md +40 -0
  19. package/docs/api/tasks/getSiteByUrl.md +30 -0
  20. package/docs/topics/findingSiteDriveId.md +11 -5
  21. package/package.json +11 -11
  22. package/dist/cjs/tasks/getDriveFromUrl.d.ts +0 -20
  23. package/dist/cjs/tasks/getDriveFromUrl.d.ts.map +0 -1
  24. package/dist/cjs/tasks/getDriveFromUrl.js +0 -50
  25. package/dist/esm/tasks/getDriveFromUrl.d.ts +0 -20
  26. package/dist/esm/tasks/getDriveFromUrl.d.ts.map +0 -1
  27. package/dist/esm/tasks/getDriveFromUrl.js +0 -44
  28. package/docs/api/getDriveFromUrl.md +0 -34
  29. package/docs/api/sharepointUrl.md +0 -44
@@ -1 +1 @@
1
- {"version":3,"file":"getDriveItemByPath.d.ts","sourceRoot":"","sources":["../../../../src/operations/driveItem/getDriveItemByPath.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAElE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAe,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAKrE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,cAAc,CAAC,SAAS,GAAG,YAAY,CAAC,CAqBhI"}
1
+ {"version":3,"file":"getDriveItemByPath.d.ts","sourceRoot":"","sources":["../../../../src/operations/driveItem/getDriveItemByPath.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAElE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAe,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAKrE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,cAAc,CAAC,SAAS,GAAG,YAAY,CAAC,CAuBhI"}
@@ -24,10 +24,11 @@ function getDriveItemByPath(driveRef, itemPath) {
24
24
  if (!itemPath.startsWith("/")) {
25
25
  throw new InvalidArgumentError_ts_1.default("itemPath must start with a forward slash (/)");
26
26
  }
27
+ const normalizedPath = itemPath === "/" ? "/sites/{site-id}/drives/{drive-id}/root" : `/sites/{site-id}/drives/{drive-id}/root:${itemPath}`;
27
28
  return (0, operationInvoker_ts_1.operation)({
28
29
  context: driveRef.context,
29
30
  method: "GET",
30
- path: (0, templatedPaths_ts_1.generatePath)(`/sites/{site-id}/drives/{drive-id}/root:${itemPath}`, driveRef),
31
+ path: (0, templatedPaths_ts_1.generatePath)(normalizedPath, driveRef),
31
32
  headers: {},
32
33
  body: null,
33
34
  responseTransform: (response) => {
@@ -1,17 +1,8 @@
1
- /**
2
- * Utilities for parsing and extracting information from SharePoint URLs.
3
- * @module sharepointUrl
4
- * @category Services
5
- */
6
- import type { DriveName } from "../models/Drive.ts";
7
- import type { DriveItemId } from "../models/DriveItem.ts";
8
1
  import type { HostName } from "../models/HostName.ts";
9
2
  import type { SiteName } from "../models/Site.ts";
10
3
  export type SharepointUrlComponents = {
11
4
  hostName: HostName | null;
12
5
  siteName: SiteName | null;
13
- driveName: DriveName | null;
14
- itemId: DriveItemId | null;
15
6
  };
16
7
  /**
17
8
  * Parses a SharePoint document URL string to extract the site name, host name, drive name and item ID if present.
@@ -1 +1 @@
1
- {"version":3,"file":"sharepointUrl.d.ts","sourceRoot":"","sources":["../../../src/services/sharepointUrl.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,MAAM,uBAAuB,GAAG;IACrC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB,CAkD7E"}
1
+ {"version":3,"file":"sharepointUrl.d.ts","sourceRoot":"","sources":["../../../src/services/sharepointUrl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,MAAM,uBAAuB,GAAG;IACrC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB,CAiC7E"}
@@ -1,9 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * Utilities for parsing and extracting information from SharePoint URLs.
4
- * @module sharepointUrl
5
- * @category Services
6
- */
7
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.parseSharepointUrl = parseSharepointUrl;
9
4
  /**
@@ -15,8 +10,6 @@ function parseSharepointUrl(urlString) {
15
10
  let url;
16
11
  let hostName = null;
17
12
  let siteName = null;
18
- let driveName = null;
19
- let itemId = null;
20
13
  try {
21
14
  url = new URL(urlString);
22
15
  }
@@ -24,16 +17,12 @@ function parseSharepointUrl(urlString) {
24
17
  return {
25
18
  hostName: null,
26
19
  siteName: null,
27
- driveName: null,
28
- itemId: null,
29
20
  };
30
21
  }
31
22
  if (!url.hostname.endsWith(".sharepoint.com")) {
32
23
  return {
33
24
  hostName: null,
34
25
  siteName: null,
35
- driveName: null,
36
- itemId: null,
37
26
  };
38
27
  }
39
28
  hostName = url.hostname;
@@ -42,19 +31,9 @@ function parseSharepointUrl(urlString) {
42
31
  if (sitesIdx !== -1 && pathSegments[sitesIdx + 1]) {
43
32
  const rawSiteName = pathSegments[sitesIdx + 1];
44
33
  siteName = rawSiteName ? decodeURIComponent(rawSiteName) : null;
45
- const afterSite = pathSegments[sitesIdx + 2];
46
- if (afterSite && afterSite.toLowerCase() !== "_layouts" && afterSite.toLowerCase() !== "forms") {
47
- driveName = decodeURIComponent(afterSite);
48
- }
49
- }
50
- const sourcedoc = url.searchParams.get("sourcedoc");
51
- if (sourcedoc) {
52
- itemId = decodeURIComponent(sourcedoc.replace(/[{}]/g, "")).toUpperCase();
53
34
  }
54
35
  return {
55
36
  hostName,
56
37
  siteName,
57
- driveName,
58
- itemId,
59
38
  };
60
39
  }
@@ -0,0 +1,13 @@
1
+ import type { Site } from "@microsoft/microsoft-graph-types";
2
+ import type { ContextRef } from "../models/Context.ts";
3
+ import type { SiteRef } from "../models/Site.ts";
4
+ /**
5
+ * Retrieves a site from a SharePoint URL.
6
+ *
7
+ * @param contextRef Context reference containing authentication and environment information.
8
+ * @param url SharePoint URL pointing to the site.
9
+ * @returns A Promise that resolves to the Site object
10
+ * @throws If the URL is invalid or the site cannot be found.
11
+ */
12
+ export default function getSiteByUrl(contextRef: ContextRef, url: string): Promise<Site & SiteRef>;
13
+ //# sourceMappingURL=getSiteByUrl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSiteByUrl.d.ts","sourceRoot":"","sources":["../../../src/tasks/getSiteByUrl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;;;;;;GAOG;AACH,wBAA8B,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,CAWvG"}
@@ -0,0 +1,26 @@
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.default = getSiteByUrl;
7
+ const getSiteByName_ts_1 = __importDefault(require("../operations/site/getSiteByName.js"));
8
+ const sharepointUrl_ts_1 = require("../services/sharepointUrl.js");
9
+ /**
10
+ * Retrieves a site from a SharePoint URL.
11
+ *
12
+ * @param contextRef Context reference containing authentication and environment information.
13
+ * @param url SharePoint URL pointing to the site.
14
+ * @returns A Promise that resolves to the Site object
15
+ * @throws If the URL is invalid or the site cannot be found.
16
+ */
17
+ async function getSiteByUrl(contextRef, url) {
18
+ const { hostName, siteName } = (0, sharepointUrl_ts_1.parseSharepointUrl)(url);
19
+ if (!hostName) {
20
+ throw new Error("Invalid SharePoint URL: Host name is missing.");
21
+ }
22
+ if (!siteName) {
23
+ throw new Error("Invalid SharePoint URL: Site name is missing.");
24
+ }
25
+ return await (0, getSiteByName_ts_1.default)(contextRef, hostName, siteName);
26
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"getDriveItemByPath.d.ts","sourceRoot":"","sources":["../../../../src/operations/driveItem/getDriveItemByPath.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAElE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAe,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAKrE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,cAAc,CAAC,SAAS,GAAG,YAAY,CAAC,CAqBhI"}
1
+ {"version":3,"file":"getDriveItemByPath.d.ts","sourceRoot":"","sources":["../../../../src/operations/driveItem/getDriveItemByPath.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAElE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAe,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAKrE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,cAAc,CAAC,SAAS,GAAG,YAAY,CAAC,CAuBhI"}
@@ -18,10 +18,11 @@ export default function getDriveItemByPath(driveRef, itemPath) {
18
18
  if (!itemPath.startsWith("/")) {
19
19
  throw new InvalidArgumentError("itemPath must start with a forward slash (/)");
20
20
  }
21
+ const normalizedPath = itemPath === "/" ? "/sites/{site-id}/drives/{drive-id}/root" : `/sites/{site-id}/drives/{drive-id}/root:${itemPath}`;
21
22
  return operation({
22
23
  context: driveRef.context,
23
24
  method: "GET",
24
- path: generatePath(`/sites/{site-id}/drives/{drive-id}/root:${itemPath}`, driveRef),
25
+ path: generatePath(normalizedPath, driveRef),
25
26
  headers: {},
26
27
  body: null,
27
28
  responseTransform: (response) => {
@@ -1,17 +1,8 @@
1
- /**
2
- * Utilities for parsing and extracting information from SharePoint URLs.
3
- * @module sharepointUrl
4
- * @category Services
5
- */
6
- import type { DriveName } from "../models/Drive.ts";
7
- import type { DriveItemId } from "../models/DriveItem.ts";
8
1
  import type { HostName } from "../models/HostName.ts";
9
2
  import type { SiteName } from "../models/Site.ts";
10
3
  export type SharepointUrlComponents = {
11
4
  hostName: HostName | null;
12
5
  siteName: SiteName | null;
13
- driveName: DriveName | null;
14
- itemId: DriveItemId | null;
15
6
  };
16
7
  /**
17
8
  * Parses a SharePoint document URL string to extract the site name, host name, drive name and item ID if present.
@@ -1 +1 @@
1
- {"version":3,"file":"sharepointUrl.d.ts","sourceRoot":"","sources":["../../../src/services/sharepointUrl.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,MAAM,uBAAuB,GAAG;IACrC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB,CAkD7E"}
1
+ {"version":3,"file":"sharepointUrl.d.ts","sourceRoot":"","sources":["../../../src/services/sharepointUrl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,MAAM,uBAAuB,GAAG;IACrC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB,CAiC7E"}
@@ -1,8 +1,3 @@
1
- /**
2
- * Utilities for parsing and extracting information from SharePoint URLs.
3
- * @module sharepointUrl
4
- * @category Services
5
- */
6
1
  /**
7
2
  * Parses a SharePoint document URL string to extract the site name, host name, drive name and item ID if present.
8
3
  * @param urlString SharePoint URL as a string.
@@ -12,8 +7,6 @@ export function parseSharepointUrl(urlString) {
12
7
  let url;
13
8
  let hostName = null;
14
9
  let siteName = null;
15
- let driveName = null;
16
- let itemId = null;
17
10
  try {
18
11
  url = new URL(urlString);
19
12
  }
@@ -21,16 +14,12 @@ export function parseSharepointUrl(urlString) {
21
14
  return {
22
15
  hostName: null,
23
16
  siteName: null,
24
- driveName: null,
25
- itemId: null,
26
17
  };
27
18
  }
28
19
  if (!url.hostname.endsWith(".sharepoint.com")) {
29
20
  return {
30
21
  hostName: null,
31
22
  siteName: null,
32
- driveName: null,
33
- itemId: null,
34
23
  };
35
24
  }
36
25
  hostName = url.hostname;
@@ -39,19 +28,9 @@ export function parseSharepointUrl(urlString) {
39
28
  if (sitesIdx !== -1 && pathSegments[sitesIdx + 1]) {
40
29
  const rawSiteName = pathSegments[sitesIdx + 1];
41
30
  siteName = rawSiteName ? decodeURIComponent(rawSiteName) : null;
42
- const afterSite = pathSegments[sitesIdx + 2];
43
- if (afterSite && afterSite.toLowerCase() !== "_layouts" && afterSite.toLowerCase() !== "forms") {
44
- driveName = decodeURIComponent(afterSite);
45
- }
46
- }
47
- const sourcedoc = url.searchParams.get("sourcedoc");
48
- if (sourcedoc) {
49
- itemId = decodeURIComponent(sourcedoc.replace(/[{}]/g, "")).toUpperCase();
50
31
  }
51
32
  return {
52
33
  hostName,
53
34
  siteName,
54
- driveName,
55
- itemId,
56
35
  };
57
36
  }
@@ -0,0 +1,13 @@
1
+ import type { Site } from "@microsoft/microsoft-graph-types";
2
+ import type { ContextRef } from "../models/Context.ts";
3
+ import type { SiteRef } from "../models/Site.ts";
4
+ /**
5
+ * Retrieves a site from a SharePoint URL.
6
+ *
7
+ * @param contextRef Context reference containing authentication and environment information.
8
+ * @param url SharePoint URL pointing to the site.
9
+ * @returns A Promise that resolves to the Site object
10
+ * @throws If the URL is invalid or the site cannot be found.
11
+ */
12
+ export default function getSiteByUrl(contextRef: ContextRef, url: string): Promise<Site & SiteRef>;
13
+ //# sourceMappingURL=getSiteByUrl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSiteByUrl.d.ts","sourceRoot":"","sources":["../../../src/tasks/getSiteByUrl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;;;;;;GAOG;AACH,wBAA8B,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,CAWvG"}
@@ -0,0 +1,20 @@
1
+ import getSiteByName from "../operations/site/getSiteByName.js";
2
+ import { parseSharepointUrl } from "../services/sharepointUrl.js";
3
+ /**
4
+ * Retrieves a site from a SharePoint URL.
5
+ *
6
+ * @param contextRef Context reference containing authentication and environment information.
7
+ * @param url SharePoint URL pointing to the site.
8
+ * @returns A Promise that resolves to the Site object
9
+ * @throws If the URL is invalid or the site cannot be found.
10
+ */
11
+ export default async function getSiteByUrl(contextRef, url) {
12
+ const { hostName, siteName } = parseSharepointUrl(url);
13
+ if (!hostName) {
14
+ throw new Error("Invalid SharePoint URL: Host name is missing.");
15
+ }
16
+ if (!siteName) {
17
+ throw new Error("Invalid SharePoint URL: Site name is missing.");
18
+ }
19
+ return await getSiteByName(contextRef, hostName, siteName);
20
+ }
@@ -139,6 +139,13 @@
139
139
  | [updateWorkbookWorksheet](updateWorkbookWorksheet.md) | Update the name, position, and/or visibility of a worksheet. |
140
140
  | [userSendMail](userSendMail.md) | Send an email. |
141
141
 
142
+ ## Other
143
+
144
+ | Module | Description |
145
+ | ------ | ------ |
146
+ | [services/sharepointUrl](services/sharepointUrl.md) | - |
147
+ | [tasks/getSiteByUrl](tasks/getSiteByUrl.md) | - |
148
+
142
149
  ## Services
143
150
 
144
151
  | Module | Description |
@@ -161,7 +168,6 @@
161
168
  | [operationInvoker](operationInvoker.md) | Invoke operations, potentially as parallel or sequential batches. |
162
169
  | [random](random.md) | Utilities for generating random values for spreadsheet and API operations. |
163
170
  | [rangeManipulation](rangeManipulation.md) | Utilities for inferring and manipulating spreadsheet ranges and objects. |
164
- | [sharepointUrl](sharepointUrl.md) | Utilities for parsing and extracting information from SharePoint URLs. |
165
171
  | [site](site.md) | Utilities for working with Microsoft Graph Site references and operations. |
166
172
  | [sleep](sleep.md) | Utility for pausing execution (sleep) in async workflows. |
167
173
  | [stringCaseConversion](stringCaseConversion.md) | Utilities for converting string case styles (e.g., kebab-case to camelCase). |
@@ -180,7 +186,6 @@
180
186
  | [copyDriveItem](copyDriveItem.md) | Copy a drive item. |
181
187
  | [createWorkbookAndStartSession](createWorkbookAndStartSession.md) | Create a new workbook and open a session for that workbook. |
182
188
  | [downloadDriveItemContent](downloadDriveItemContent.md) | Download a drive item and save it to the local disk. |
183
- | [getDriveFromUrl](getDriveFromUrl.md) | Retrieves a Drive from a SharePoint URL. |
184
189
  | [insertWorkbookRangeRow](insertWorkbookRangeRow.md) | Inserts a single row into a workbook range. |
185
190
  | [insertWorkbookRangeRows](insertWorkbookRangeRows.md) | Inserts rows into a workbook range. |
186
191
  | [iterateDriveItems](iterateDriveItems.md) | List drive items in a drive or a drive item. |
@@ -0,0 +1,40 @@
1
+ [Microsoft Graph SDK](../README.md) / services/sharepointUrl
2
+
3
+ # services/sharepointUrl
4
+
5
+ ## Type Aliases
6
+
7
+ ### SharepointUrlComponents
8
+
9
+ > **SharepointUrlComponents** = `object`
10
+
11
+ Defined in: [src/services/sharepointUrl.ts:4](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/services/sharepointUrl.ts#L4)
12
+
13
+ #### Properties
14
+
15
+ | Property | Type | Defined in |
16
+ | ------ | ------ | ------ |
17
+ | <a id="hostname"></a> `hostName` | [`HostName`](../HostName.md#hostname) \| `null` | [src/services/sharepointUrl.ts:5](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/services/sharepointUrl.ts#L5) |
18
+ | <a id="sitename"></a> `siteName` | [`SiteName`](../Site-1.md#sitename) \| `null` | [src/services/sharepointUrl.ts:6](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/services/sharepointUrl.ts#L6) |
19
+
20
+ ## Functions
21
+
22
+ ### parseSharepointUrl()
23
+
24
+ > **parseSharepointUrl**(`urlString`): [`SharepointUrlComponents`](#sharepointurlcomponents)
25
+
26
+ Defined in: [src/services/sharepointUrl.ts:14](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/services/sharepointUrl.ts#L14)
27
+
28
+ Parses a SharePoint document URL string to extract the site name, host name, drive name and item ID if present.
29
+
30
+ #### Parameters
31
+
32
+ | Parameter | Type | Description |
33
+ | ------ | ------ | ------ |
34
+ | `urlString` | `string` | SharePoint URL as a string. |
35
+
36
+ #### Returns
37
+
38
+ [`SharepointUrlComponents`](#sharepointurlcomponents)
39
+
40
+ An object containing the host name, site name, drive name, and item ID. Parameters are omitted if not found.
@@ -0,0 +1,30 @@
1
+ [Microsoft Graph SDK](../README.md) / tasks/getSiteByUrl
2
+
3
+ # tasks/getSiteByUrl
4
+
5
+ ## Functions
6
+
7
+ ### getSiteByUrl()
8
+
9
+ > **getSiteByUrl**(`contextRef`, `url`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`Site` & [`SiteRef`](../Site-1.md#siteref)\>
10
+
11
+ Defined in: [src/tasks/getSiteByUrl.ts:15](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/tasks/getSiteByUrl.ts#L15)
12
+
13
+ Retrieves a site from a SharePoint URL.
14
+
15
+ #### Parameters
16
+
17
+ | Parameter | Type | Description |
18
+ | ------ | ------ | ------ |
19
+ | `contextRef` | [`ContextRef`](../Context-1.md#contextref) | Context reference containing authentication and environment information. |
20
+ | `url` | `string` | SharePoint URL pointing to the site. |
21
+
22
+ #### Returns
23
+
24
+ [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`Site` & [`SiteRef`](../Site-1.md#siteref)\>
25
+
26
+ A Promise that resolves to the Site object
27
+
28
+ #### Throws
29
+
30
+ If the URL is invalid or the site cannot be found.
@@ -2,12 +2,18 @@
2
2
  At the time of writing there is no **good** way to get these values. So what follows is a work-around process.
3
3
 
4
4
  ## SiteId
5
- 1. Open the Sharepoint UI for the site you're interested in (ie https://msftfuturesecureai.sharepoint.com/sites/FSAI-MQG/)
6
- 2. In your browser, open "View Source"
7
- 3. Search the source for `siteId` and look immediately after it.
8
- 4. The SiteId is a GUID and will look something like "89cb90aa-7977-412d-8215-31c74db72d7b"
5
+ ### Automated way
6
+ Install [Microsoft Graph Tool](https://www.npmjs.com/package/microsoft-graph-tool) and run `graph get-site <url>` (ie `graph get-site https://myhost.sharepoint.com/sites/sitename/`) and you will be given the rool
7
+
8
+ ### Manual way
9
+ Go to this path on your site https://{host-name}/sites/{site-name}/_api/site/id (ie https://myhost.sharepoint.com/sites/sitename/_api/site/id) and you will be given the ID
9
10
 
10
11
  ## DriveID
12
+
13
+ ### Automated way
14
+ Install [Microsoft Graph Tool](https://www.npmjs.com/package/microsoft-graph-tool) and run `graph list-drives <siteId>`
15
+
16
+ ### Manual way
11
17
  1. In the Sharepoint UI, create a workbook. New > Workbook
12
18
  2. Close the file and back in Sharepoint refresh the page
13
19
  3. Open your web browsers Inspect tool
@@ -15,7 +21,7 @@ At the time of writing there is no **good** way to get these values. So what fol
15
21
  5. In the inspect tool, swap to the "Network" table and filter the view vy "Fetch/XHR"
16
22
  6. Find the request to the Graph API. It will look like this:
17
23
  `https://msftfuturesecureai.sharepoint.com/_api/v2.1/drives/b!qpDLiXd5LUGCFTHHTbcte07zDZGO-jpHhga5szhvDwEvhFVvV24OSrAv5WljW1aA/items/01LRCMNGPGDA4PSPHWF5AZN45DNO37BP3Z?%24select=id%2Creactions%2Ctrending&%24expand=insights(%24expand%3DkeyPoints)%2Canalytics(%24expand%3DallTime(%24expand%3Dactivities))%2CrecommendedActionSet(%24expand%3DnonAggregatedRecommendedActions%2CaggregatedEditRecommendedAction(%24expand%3DimportantActorsAndActivities))%2CconversationSet(%24expand%3DemailConversations(%24expand%3Dparticipants)%2CmeetingConversations(%24expand%3Dparticipants)%2CteamsConversations(%24expand%3Dparticipants))`
18
- 7. Note the portion between `/drives/` and `/items`/. This is your driveId. In the above example it is `b!qpDLiXd5LUGCFTHHTbcte07zDZGO-jpHhga5szhvDwEvhFVvV24OSrAv5WljW1aA`.
24
+ 1. Note the portion between `/drives/` and `/items`/. This is your driveId. In the above example it is `b!qpDLiXd5LUGCFTHHTbcte07zDZGO-jpHhga5szhvDwEvhFVvV24OSrAv5WljW1aA`.
19
25
 
20
26
 
21
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microsoft-graph",
3
- "version": "3.2.1",
3
+ "version": "3.2.3",
4
4
  "description": "Microsoft GraphAPI SDK for NodeJS",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -1649,16 +1649,6 @@
1649
1649
  "require": "./dist/cjs/tasks/downloadDriveItemContent.js",
1650
1650
  "types": "./dist/esm/tasks/downloadDriveItemContent.d.ts"
1651
1651
  },
1652
- "./getDriveFromUrl": {
1653
- "import": "./dist/esm/tasks/getDriveFromUrl.js",
1654
- "require": "./dist/cjs/tasks/getDriveFromUrl.js",
1655
- "types": "./dist/esm/tasks/getDriveFromUrl.d.ts"
1656
- },
1657
- "./dist/cjs/tasks/getDriveFromUrl": {
1658
- "import": "./dist/esm/tasks/getDriveFromUrl.js",
1659
- "require": "./dist/cjs/tasks/getDriveFromUrl.js",
1660
- "types": "./dist/esm/tasks/getDriveFromUrl.d.ts"
1661
- },
1662
1652
  "./getRangeLastUsedCell": {
1663
1653
  "import": "./dist/esm/tasks/getRangeLastUsedCell.js",
1664
1654
  "require": "./dist/cjs/tasks/getRangeLastUsedCell.js",
@@ -1669,6 +1659,16 @@
1669
1659
  "require": "./dist/cjs/tasks/getRangeLastUsedCell.js",
1670
1660
  "types": "./dist/esm/tasks/getRangeLastUsedCell.d.ts"
1671
1661
  },
1662
+ "./getSiteByUrl": {
1663
+ "import": "./dist/esm/tasks/getSiteByUrl.js",
1664
+ "require": "./dist/cjs/tasks/getSiteByUrl.js",
1665
+ "types": "./dist/esm/tasks/getSiteByUrl.d.ts"
1666
+ },
1667
+ "./dist/cjs/tasks/getSiteByUrl": {
1668
+ "import": "./dist/esm/tasks/getSiteByUrl.js",
1669
+ "require": "./dist/cjs/tasks/getSiteByUrl.js",
1670
+ "types": "./dist/esm/tasks/getSiteByUrl.d.ts"
1671
+ },
1672
1672
  "./getWorkbookTableVisibleBody": {
1673
1673
  "import": "./dist/esm/tasks/getWorkbookTableVisibleBody.js",
1674
1674
  "require": "./dist/cjs/tasks/getWorkbookTableVisibleBody.js",
@@ -1,20 +0,0 @@
1
- /**
2
- * Retrieves a Drive from a SharePoint URL.
3
- * @module getDriveFromUrl
4
- * @category Tasks
5
- */
6
- import type { Drive } from "@microsoft/microsoft-graph-types";
7
- import type { ContextRef } from "../models/Context.ts";
8
- import type { DriveRef } from "../models/Drive.ts";
9
- /**
10
- * Retrieves a Drive from a SharePoint URL.
11
- *
12
- * Parses the given SharePoint URL to extract the host, site, and drive names, then locates and returns the corresponding Drive object.
13
- *
14
- * @param contextRef - The context reference containing authentication and environment information.
15
- * @param url - The SharePoint URL pointing to the drive.
16
- * @returns A Promise that resolves to the Drive object with additional DriveRef properties.
17
- * @throws If the URL is invalid or the drive cannot be found.
18
- */
19
- export default function getDriveFromUrl(contextRef: ContextRef, url: string): Promise<Drive & DriveRef>;
20
- //# sourceMappingURL=getDriveFromUrl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getDriveFromUrl.d.ts","sourceRoot":"","sources":["../../../src/tasks/getDriveFromUrl.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAKnD;;;;;;;;;GASG;AACH,wBAA8B,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,CA2B5G"}
@@ -1,50 +0,0 @@
1
- "use strict";
2
- /**
3
- * Retrieves a Drive from a SharePoint URL.
4
- * @module getDriveFromUrl
5
- * @category Tasks
6
- */
7
- var __importDefault = (this && this.__importDefault) || function (mod) {
8
- return (mod && mod.__esModule) ? mod : { "default": mod };
9
- };
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.default = getDriveFromUrl;
12
- const getSiteByName_ts_1 = __importDefault(require("../operations/site/getSiteByName.js"));
13
- const sharepointUrl_ts_1 = require("../services/sharepointUrl.js");
14
- const iterateDrives_ts_1 = __importDefault(require("./iterateDrives.js"));
15
- /**
16
- * Retrieves a Drive from a SharePoint URL.
17
- *
18
- * Parses the given SharePoint URL to extract the host, site, and drive names, then locates and returns the corresponding Drive object.
19
- *
20
- * @param contextRef - The context reference containing authentication and environment information.
21
- * @param url - The SharePoint URL pointing to the drive.
22
- * @returns A Promise that resolves to the Drive object with additional DriveRef properties.
23
- * @throws If the URL is invalid or the drive cannot be found.
24
- */
25
- async function getDriveFromUrl(contextRef, url) {
26
- const { hostName, siteName, driveName } = (0, sharepointUrl_ts_1.parseSharepointUrl)(url);
27
- if (!hostName) {
28
- throw new Error("Invalid SharePoint URL: Host name is missing.");
29
- }
30
- if (!siteName) {
31
- throw new Error("Invalid SharePoint URL: Site name is missing.");
32
- }
33
- if (!driveName) {
34
- throw new Error("Invalid SharePoint URL: Drive name is missing.");
35
- }
36
- const site = await (0, getSiteByName_ts_1.default)(contextRef, hostName, siteName);
37
- let drive = null;
38
- for await (const d of (0, iterateDrives_ts_1.default)(site)) {
39
- if (sanitizeUrlName(d.name ?? "") === driveName) {
40
- drive = d;
41
- }
42
- }
43
- if (!drive) {
44
- throw new Error(`Drive "${driveName}" not found in site "${siteName}" on host "${hostName}".`);
45
- }
46
- return drive;
47
- }
48
- function sanitizeUrlName(name) {
49
- return name.replace(/[^A-Za-z0-9\-_.~]/g, "");
50
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Retrieves a Drive from a SharePoint URL.
3
- * @module getDriveFromUrl
4
- * @category Tasks
5
- */
6
- import type { Drive } from "@microsoft/microsoft-graph-types";
7
- import type { ContextRef } from "../models/Context.ts";
8
- import type { DriveRef } from "../models/Drive.ts";
9
- /**
10
- * Retrieves a Drive from a SharePoint URL.
11
- *
12
- * Parses the given SharePoint URL to extract the host, site, and drive names, then locates and returns the corresponding Drive object.
13
- *
14
- * @param contextRef - The context reference containing authentication and environment information.
15
- * @param url - The SharePoint URL pointing to the drive.
16
- * @returns A Promise that resolves to the Drive object with additional DriveRef properties.
17
- * @throws If the URL is invalid or the drive cannot be found.
18
- */
19
- export default function getDriveFromUrl(contextRef: ContextRef, url: string): Promise<Drive & DriveRef>;
20
- //# sourceMappingURL=getDriveFromUrl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getDriveFromUrl.d.ts","sourceRoot":"","sources":["../../../src/tasks/getDriveFromUrl.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAKnD;;;;;;;;;GASG;AACH,wBAA8B,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,CA2B5G"}
@@ -1,44 +0,0 @@
1
- /**
2
- * Retrieves a Drive from a SharePoint URL.
3
- * @module getDriveFromUrl
4
- * @category Tasks
5
- */
6
- import getSiteByName from "../operations/site/getSiteByName.js";
7
- import { parseSharepointUrl } from "../services/sharepointUrl.js";
8
- import iterateDrives from "./iterateDrives.js";
9
- /**
10
- * Retrieves a Drive from a SharePoint URL.
11
- *
12
- * Parses the given SharePoint URL to extract the host, site, and drive names, then locates and returns the corresponding Drive object.
13
- *
14
- * @param contextRef - The context reference containing authentication and environment information.
15
- * @param url - The SharePoint URL pointing to the drive.
16
- * @returns A Promise that resolves to the Drive object with additional DriveRef properties.
17
- * @throws If the URL is invalid or the drive cannot be found.
18
- */
19
- export default async function getDriveFromUrl(contextRef, url) {
20
- const { hostName, siteName, driveName } = parseSharepointUrl(url);
21
- if (!hostName) {
22
- throw new Error("Invalid SharePoint URL: Host name is missing.");
23
- }
24
- if (!siteName) {
25
- throw new Error("Invalid SharePoint URL: Site name is missing.");
26
- }
27
- if (!driveName) {
28
- throw new Error("Invalid SharePoint URL: Drive name is missing.");
29
- }
30
- const site = await getSiteByName(contextRef, hostName, siteName);
31
- let drive = null;
32
- for await (const d of iterateDrives(site)) {
33
- if (sanitizeUrlName(d.name ?? "") === driveName) {
34
- drive = d;
35
- }
36
- }
37
- if (!drive) {
38
- throw new Error(`Drive "${driveName}" not found in site "${siteName}" on host "${hostName}".`);
39
- }
40
- return drive;
41
- }
42
- function sanitizeUrlName(name) {
43
- return name.replace(/[^A-Za-z0-9\-_.~]/g, "");
44
- }
@@ -1,34 +0,0 @@
1
- [Microsoft Graph SDK](README.md) / getDriveFromUrl
2
-
3
- # getDriveFromUrl
4
-
5
- Retrieves a Drive from a SharePoint URL.
6
-
7
- ## Functions
8
-
9
- ### getDriveFromUrl()
10
-
11
- > **getDriveFromUrl**(`contextRef`, `url`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`Drive` & [`SiteRef`](Site-1.md#siteref) & `object`\>
12
-
13
- Defined in: [src/tasks/getDriveFromUrl.ts:24](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/tasks/getDriveFromUrl.ts#L24)
14
-
15
- Retrieves a Drive from a SharePoint URL.
16
-
17
- Parses the given SharePoint URL to extract the host, site, and drive names, then locates and returns the corresponding Drive object.
18
-
19
- #### Parameters
20
-
21
- | Parameter | Type | Description |
22
- | ------ | ------ | ------ |
23
- | `contextRef` | [`ContextRef`](Context-1.md#contextref) | The context reference containing authentication and environment information. |
24
- | `url` | `string` | The SharePoint URL pointing to the drive. |
25
-
26
- #### Returns
27
-
28
- [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`Drive` & [`SiteRef`](Site-1.md#siteref) & `object`\>
29
-
30
- A Promise that resolves to the Drive object with additional DriveRef properties.
31
-
32
- #### Throws
33
-
34
- If the URL is invalid or the drive cannot be found.
@@ -1,44 +0,0 @@
1
- [Microsoft Graph SDK](README.md) / sharepointUrl
2
-
3
- # sharepointUrl
4
-
5
- Utilities for parsing and extracting information from SharePoint URLs.
6
-
7
- ## Type Aliases
8
-
9
- ### SharepointUrlComponents
10
-
11
- > **SharepointUrlComponents** = `object`
12
-
13
- Defined in: [src/services/sharepointUrl.ts:12](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/services/sharepointUrl.ts#L12)
14
-
15
- #### Properties
16
-
17
- | Property | Type | Defined in |
18
- | ------ | ------ | ------ |
19
- | <a id="drivename"></a> `driveName` | [`DriveName`](Drive-1.md#drivename) \| `null` | [src/services/sharepointUrl.ts:15](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/services/sharepointUrl.ts#L15) |
20
- | <a id="hostname"></a> `hostName` | [`HostName`](HostName.md#hostname) \| `null` | [src/services/sharepointUrl.ts:13](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/services/sharepointUrl.ts#L13) |
21
- | <a id="itemid"></a> `itemId` | [`DriveItemId`](DriveItem-1.md#driveitemid) \| `null` | [src/services/sharepointUrl.ts:16](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/services/sharepointUrl.ts#L16) |
22
- | <a id="sitename"></a> `siteName` | [`SiteName`](Site-1.md#sitename) \| `null` | [src/services/sharepointUrl.ts:14](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/services/sharepointUrl.ts#L14) |
23
-
24
- ## Functions
25
-
26
- ### parseSharepointUrl()
27
-
28
- > **parseSharepointUrl**(`urlString`): [`SharepointUrlComponents`](#sharepointurlcomponents)
29
-
30
- Defined in: [src/services/sharepointUrl.ts:24](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/services/sharepointUrl.ts#L24)
31
-
32
- Parses a SharePoint document URL string to extract the site name, host name, drive name and item ID if present.
33
-
34
- #### Parameters
35
-
36
- | Parameter | Type | Description |
37
- | ------ | ------ | ------ |
38
- | `urlString` | `string` | SharePoint URL as a string. |
39
-
40
- #### Returns
41
-
42
- [`SharepointUrlComponents`](#sharepointurlcomponents)
43
-
44
- An object containing the host name, site name, drive name, and item ID. Parameters are omitted if not found.