gd-sprest 9.6.7 → 9.6.9

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.
@@ -55,6 +55,12 @@ export interface ISite {
55
55
  */
56
56
  getAppContext(siteUrl: string): IBaseExecution;
57
57
 
58
+ /**
59
+ * Method to return the web of the current user's OneDrive.
60
+ * @param targetInfo - (Optional) The target information.
61
+ */
62
+ getOneDrive(targetInfo?: ITargetInfoProps): SP.IWeb;
63
+
58
64
  /**
59
65
  * Method to get the url of a site, by its id.
60
66
  * @param id - The site id.
@@ -28,7 +28,9 @@ export interface Idrive {
28
28
  * Get the default library for a site.
29
29
  * @param driveId - (Optional) Sets the drive to get, otherwise gets the default drive for the site.
30
30
  * @param siteId - (Optional) The site id to target, current by default.
31
+ * @param siteUrl - (Optional) The site url to target, current by default.
31
32
  * @param targetInfo - (Optional) The target information.
33
+ * @param webId - (Optional) The web id to target.
32
34
  */
33
- (props?: { driveId?: string, siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps }): IBaseQuery<drive> & driveMethods;
35
+ (props?: { driveId?: string, siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps, webId?: string }): IBaseQuery<drive> & driveMethods;
34
36
  }
@@ -26,10 +26,10 @@ export const drives: Idrives;
26
26
  export interface Idrives {
27
27
  /**
28
28
  * Get the libraries for a site.
29
- * @param id - (Optional) The drive id to target.
30
29
  * @param siteId - (Optional) The site id to target, current by default.
31
30
  * @param siteUrl - (Optional) The site url to target, current by default.
32
31
  * @param targetInfo - (Optional) The target information.
32
+ * @param webId - (Optional) The web id to target.
33
33
  */
34
- (props?: { siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps }): driveCollection;
34
+ (props?: { siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps, webId?: string }): driveCollection;
35
35
  }
package/build/lib/site.js CHANGED
@@ -1,7 +1,20 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.Site = void 0;
4
15
  var utils_1 = require("../utils");
16
+ var contextInfo_1 = require("./contextInfo");
17
+ var graph_1 = require("./graph");
5
18
  /**
6
19
  * Site
7
20
  */
@@ -40,6 +53,21 @@ exports.Site.getAppContext = (function (siteUrl) {
40
53
  method: "POST"
41
54
  });
42
55
  });
56
+ // Method to get the onedive web for the current user
57
+ exports.Site.getOneDrive = function (targetInfo) {
58
+ if (targetInfo === void 0) { targetInfo = {}; }
59
+ // Set the url of the drive
60
+ var host = document.location.host.split('.');
61
+ var url = "https://".concat(host[0], "-my.").concat(host[1], ".").concat(host[2], "/personal/").concat(contextInfo_1.ContextInfo.userPrincipalName.replace(/[@,.]/g, '_'));
62
+ // Return the web for the user's onedrive
63
+ return (0, exports.Site)(url, __assign(__assign({}, targetInfo), {
64
+ requestHeader: {
65
+ Authorization: "Bearer " + graph_1.Graph.Token,
66
+ Accept: "application/json",
67
+ "Content-Type": "application/json"
68
+ }
69
+ }));
70
+ };
43
71
  // Method to get the url by id
44
72
  exports.Site.getUrlById = (function (id) {
45
73
  // Return the base object
package/build/lib/web.js CHANGED
@@ -12,8 +12,8 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.Web = void 0;
15
- var contextInfo_1 = require("./contextInfo");
16
15
  var utils_1 = require("../utils");
16
+ var contextInfo_1 = require("./contextInfo");
17
17
  var graph_1 = require("./graph");
18
18
  exports.Web = (function (url, targetInfo) {
19
19
  var web = new utils_1.Base(targetInfo);
package/build/rest.js CHANGED
@@ -9,7 +9,7 @@ var sptypes_1 = require("./sptypes");
9
9
  * SharePoint REST Library
10
10
  */
11
11
  exports.$REST = {
12
- __ver: 9.67,
12
+ __ver: 9.69,
13
13
  AppContext: function (siteUrl) { return Lib.Site.getAppContext(siteUrl); },
14
14
  Apps: Lib.Apps,
15
15
  ContextInfo: Lib.ContextInfo,
package/build/v2/drive.js CHANGED
@@ -20,11 +20,11 @@ exports.drive = (function (props) {
20
20
  if (drive.targetInfo.endpoint == undefined) {
21
21
  if (props.driveId) {
22
22
  // Set the endpoint
23
- drive.targetInfo.endpoint = "_api/v2.0/".concat(props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') + "/" : "", "drives/").concat(props.driveId);
23
+ drive.targetInfo.endpoint = "_api/v2.0/".concat(props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') + (props.webId ? "," + props.webId.replace(/^\{|\}$/g, '') : "") + "/" : "", "drives/").concat(props.driveId);
24
24
  }
25
25
  else {
26
26
  // Default the endpoint
27
- drive.targetInfo.endpoint = "_api/v2.0/".concat(props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') + "/" : "", "drive");
27
+ drive.targetInfo.endpoint = "_api/v2.0/".concat(props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') + (props.webId ? "," + props.webId.replace(/^\{|\}$/g, '') : "") + "/" : "", "drive");
28
28
  }
29
29
  // Add the methods
30
30
  utils_1.Request.addMethods(drive, { __metadata: { type: "@odata.context/_api/v2.0/$metadata#drive" } });
@@ -19,7 +19,7 @@ exports.drives = (function (props) {
19
19
  // See if an endpoint is not defined
20
20
  if (drives.targetInfo.endpoint == undefined) {
21
21
  // Default the endpoint
22
- drives.targetInfo.endpoint = "_api/v2.0/".concat(props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') + "/" : "", "drives");
22
+ drives.targetInfo.endpoint = "_api/v2.0/".concat(props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') + (props.webId ? "," + props.webId.replace(/^\{|\}$/g, '') : "") + "/" : "", "drives");
23
23
  // Add the methods
24
24
  utils_1.Request.addMethods(drives, { __metadata: { type: "@odata.context/_api/v2.0/$metadata#drives" } });
25
25
  }
@@ -4256,6 +4256,12 @@ declare module 'gd-sprest/lib/site' {
4256
4256
  */
4257
4257
  getAppContext(siteUrl: string): IBaseExecution;
4258
4258
 
4259
+ /**
4260
+ * Method to return the web of the current user's OneDrive.
4261
+ * @param targetInfo - (Optional) The target information.
4262
+ */
4263
+ getOneDrive(targetInfo?: ITargetInfoProps): SP.IWeb;
4264
+
4259
4265
  /**
4260
4266
  * Method to get the url of a site, by its id.
4261
4267
  * @param id - The site id.
@@ -4704,9 +4710,11 @@ declare module 'gd-sprest/v2/drive' {
4704
4710
  * Get the default library for a site.
4705
4711
  * @param driveId - (Optional) Sets the drive to get, otherwise gets the default drive for the site.
4706
4712
  * @param siteId - (Optional) The site id to target, current by default.
4713
+ * @param siteUrl - (Optional) The site url to target, current by default.
4707
4714
  * @param targetInfo - (Optional) The target information.
4715
+ * @param webId - (Optional) The web id to target.
4708
4716
  */
4709
- (props?: { driveId?: string, siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps }): IBaseQuery<drive> & driveMethods;
4717
+ (props?: { driveId?: string, siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps, webId?: string }): IBaseQuery<drive> & driveMethods;
4710
4718
  }
4711
4719
  }
4712
4720
 
@@ -4739,12 +4747,12 @@ declare module 'gd-sprest/v2/drives' {
4739
4747
  export interface Idrives {
4740
4748
  /**
4741
4749
  * Get the libraries for a site.
4742
- * @param id - (Optional) The drive id to target.
4743
4750
  * @param siteId - (Optional) The site id to target, current by default.
4744
4751
  * @param siteUrl - (Optional) The site url to target, current by default.
4745
4752
  * @param targetInfo - (Optional) The target information.
4753
+ * @param webId - (Optional) The web id to target.
4746
4754
  */
4747
- (props?: { siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps }): driveCollection;
4755
+ (props?: { siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps, webId?: string }): driveCollection;
4748
4756
  }
4749
4757
  }
4750
4758