microsoft-graph 3.2.0 → 3.2.2

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.
@@ -1,23 +1,13 @@
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.
18
9
  * @param urlString SharePoint URL as a string.
19
- * @returns An object containing the host name, site name, drive name (if present), and item ID (if present).
20
- * @throws InvalidArgumentError if the URL is invalid or required components are missing.
10
+ * @returns An object containing the host name, site name, drive name, and item ID. Parameters are omitted if not found.
21
11
  */
22
12
  export declare function parseSharepointUrl(urlString: string): SharepointUrlComponents;
23
13
  //# sourceMappingURL=sharepointUrl.d.ts.map
@@ -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;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB,CAiD7E"}
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,23 +1,15 @@
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
  /**
10
5
  * Parses a SharePoint document URL string to extract the site name, host name, drive name and item ID if present.
11
6
  * @param urlString SharePoint URL as a string.
12
- * @returns An object containing the host name, site name, drive name (if present), and item ID (if present).
13
- * @throws InvalidArgumentError if the URL is invalid or required components are missing.
7
+ * @returns An object containing the host name, site name, drive name, and item ID. Parameters are omitted if not found.
14
8
  */
15
9
  function parseSharepointUrl(urlString) {
16
10
  let url;
17
11
  let hostName = null;
18
12
  let siteName = null;
19
- let driveName = null;
20
- let itemId = null;
21
13
  try {
22
14
  url = new URL(urlString);
23
15
  }
@@ -25,36 +17,23 @@ function parseSharepointUrl(urlString) {
25
17
  return {
26
18
  hostName: null,
27
19
  siteName: null,
28
- driveName: null,
29
- itemId: null,
30
20
  };
31
21
  }
32
22
  if (!url.hostname.endsWith(".sharepoint.com")) {
33
23
  return {
34
24
  hostName: null,
35
25
  siteName: null,
36
- driveName: null,
37
- itemId: null,
38
26
  };
39
27
  }
40
28
  hostName = url.hostname;
41
29
  const pathSegments = url.pathname.split("/").filter(Boolean);
42
30
  const sitesIdx = pathSegments.findIndex((seg) => seg.toLowerCase() === "sites");
43
31
  if (sitesIdx !== -1 && pathSegments[sitesIdx + 1]) {
44
- siteName = pathSegments[sitesIdx + 1];
45
- const afterSite = pathSegments[sitesIdx + 2];
46
- if (afterSite && afterSite.toLowerCase() !== "_layouts" && afterSite.toLowerCase() !== "forms") {
47
- driveName = afterSite;
48
- }
49
- }
50
- const sourcedoc = url.searchParams.get("sourcedoc");
51
- if (sourcedoc) {
52
- itemId = decodeURIComponent(sourcedoc.replace(/[{}]/g, "")).toUpperCase();
32
+ const rawSiteName = pathSegments[sitesIdx + 1];
33
+ siteName = rawSiteName ? decodeURIComponent(rawSiteName) : null;
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,23 +1,13 @@
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.
18
9
  * @param urlString SharePoint URL as a string.
19
- * @returns An object containing the host name, site name, drive name (if present), and item ID (if present).
20
- * @throws InvalidArgumentError if the URL is invalid or required components are missing.
10
+ * @returns An object containing the host name, site name, drive name, and item ID. Parameters are omitted if not found.
21
11
  */
22
12
  export declare function parseSharepointUrl(urlString: string): SharepointUrlComponents;
23
13
  //# sourceMappingURL=sharepointUrl.d.ts.map
@@ -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;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB,CAiD7E"}
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,20 +1,12 @@
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.
9
- * @returns An object containing the host name, site name, drive name (if present), and item ID (if present).
10
- * @throws InvalidArgumentError if the URL is invalid or required components are missing.
4
+ * @returns An object containing the host name, site name, drive name, and item ID. Parameters are omitted if not found.
11
5
  */
12
6
  export function parseSharepointUrl(urlString) {
13
7
  let url;
14
8
  let hostName = null;
15
9
  let siteName = null;
16
- let driveName = null;
17
- let itemId = null;
18
10
  try {
19
11
  url = new URL(urlString);
20
12
  }
@@ -22,36 +14,23 @@ export function parseSharepointUrl(urlString) {
22
14
  return {
23
15
  hostName: null,
24
16
  siteName: null,
25
- driveName: null,
26
- itemId: null,
27
17
  };
28
18
  }
29
19
  if (!url.hostname.endsWith(".sharepoint.com")) {
30
20
  return {
31
21
  hostName: null,
32
22
  siteName: null,
33
- driveName: null,
34
- itemId: null,
35
23
  };
36
24
  }
37
25
  hostName = url.hostname;
38
26
  const pathSegments = url.pathname.split("/").filter(Boolean);
39
27
  const sitesIdx = pathSegments.findIndex((seg) => seg.toLowerCase() === "sites");
40
28
  if (sitesIdx !== -1 && pathSegments[sitesIdx + 1]) {
41
- siteName = pathSegments[sitesIdx + 1];
42
- const afterSite = pathSegments[sitesIdx + 2];
43
- if (afterSite && afterSite.toLowerCase() !== "_layouts" && afterSite.toLowerCase() !== "forms") {
44
- driveName = afterSite;
45
- }
46
- }
47
- const sourcedoc = url.searchParams.get("sourcedoc");
48
- if (sourcedoc) {
49
- itemId = decodeURIComponent(sourcedoc.replace(/[{}]/g, "")).toUpperCase();
29
+ const rawSiteName = pathSegments[sitesIdx + 1];
30
+ siteName = rawSiteName ? decodeURIComponent(rawSiteName) : null;
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
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microsoft-graph",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
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,48 +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:25](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/services/sharepointUrl.ts#L25)
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 (if present), and item ID (if present).
45
-
46
- #### Throws
47
-
48
- InvalidArgumentError if the URL is invalid or required components are missing.