gd-sprest 8.4.5 → 8.4.6

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.
@@ -29,5 +29,5 @@ export interface Idrive {
29
29
  * @param siteId - (Optional) The site id to target, current by default.
30
30
  * @param targetInfo - (Optional) The target information.
31
31
  */
32
- (props?: { siteId?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<drive>;
32
+ (props?: { siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<drive>;
33
33
  }
@@ -28,7 +28,8 @@ export interface Idrives {
28
28
  * Get the libraries for a site.
29
29
  * @param id - (Optional) The drive id to target.
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.
32
33
  */
33
- (props?: { driveId?: string, siteId?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<driveCollection>;
34
+ (props?: { driveId?: string, siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<driveCollection>;
34
35
  }
@@ -27,7 +27,7 @@ export const sites: Isites;
27
27
  export interface Isites {
28
28
  /**
29
29
  * Creates an instance of the site library.
30
- * @param id - (Optional) The site id to target, current by default.
30
+ * @param siteId - (Optional) The site id to target, current by default.
31
31
  * @param targetInfo - (Optional) The target information.
32
32
  */
33
33
  (props?: { siteId?: string, targetInfo?: ITargetInfoProps }): siteMethods & sites;
@@ -35,6 +35,9 @@ export interface Isites {
35
35
  /** Returns the current web. */
36
36
  static getCurrentWeb(): IBaseExecution<sites> & siteMethods;
37
37
 
38
- /** Returns a list for a web. */
38
+ /** Returns a drive for a site. */
39
+ static getDrive(props: { siteId?: string, siteUrl?: string, libName?: string }): IBaseExecution<list> & listMethods;
40
+
41
+ /** Returns a list for a site. */
39
42
  static getList(props: { siteId?: string, siteUrl?: string, listId?: string, listName?: string }): IBaseExecution<list> & listMethods;
40
43
  }
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: 8.45,
12
+ __ver: 8.46,
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
@@ -1,23 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.drive = void 0;
4
- var contextInfo_1 = require("../lib/contextInfo");
5
4
  var utils_1 = require("../utils");
6
5
  /**
7
6
  * Drive
8
7
  * Returns the default library for a site.
9
8
  */
10
9
  exports.drive = (function (props) {
11
- var _a;
12
10
  if (props === void 0) { props = {}; }
13
11
  var drive = new utils_1.Base(props.targetInfo);
14
12
  // Default the properties
15
13
  drive.targetInfo.defaultToWebFl = true;
16
14
  drive.targetInfo.requestType = utils_1.RequestType.GraphGet;
15
+ // See if the web url exists
16
+ if (props.siteUrl) {
17
+ // Set the settings
18
+ drive.targetInfo.url = props.siteUrl;
19
+ }
17
20
  // See if an endpoint is not defined
18
21
  if (drive.targetInfo.endpoint == undefined) {
19
22
  // Default the endpoint
20
- drive.targetInfo.endpoint = "_api/v2.0/sites/" + (props.siteId || ((_a = contextInfo_1.ContextInfo === null || contextInfo_1.ContextInfo === void 0 ? void 0 : contextInfo_1.ContextInfo.siteId) === null || _a === void 0 ? void 0 : _a.replace(/[{}]/g, ''))) + "/drive";
23
+ drive.targetInfo.endpoint = "_api/v2.0/" + (props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') : "") + "drive";
21
24
  // Add the methods
22
25
  utils_1.Request.addMethods(drive, { __metadata: { type: "@odata.context/_api/v2.0/$metadata#drive" } });
23
26
  }
@@ -1,23 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.drives = void 0;
4
- var contextInfo_1 = require("../lib/contextInfo");
5
4
  var utils_1 = require("../utils");
6
5
  /**
7
6
  * Drives
8
7
  * Returns the libraries for a site.
9
8
  */
10
9
  exports.drives = (function (props) {
11
- var _a;
12
10
  if (props === void 0) { props = {}; }
13
11
  var drives = new utils_1.Base(props.targetInfo);
14
12
  // Default the properties
15
13
  drives.targetInfo.defaultToWebFl = true;
16
14
  drives.targetInfo.requestType = utils_1.RequestType.GraphGet;
15
+ // See if the web url exists
16
+ if (props.siteUrl) {
17
+ // Set the settings
18
+ drives.targetInfo.url = props.siteUrl;
19
+ }
17
20
  // See if an endpoint is not defined
18
21
  if (drives.targetInfo.endpoint == undefined) {
19
22
  // Default the endpoint
20
- drives.targetInfo.endpoint = "_api/v2.0/sites/" + (props.siteId || ((_a = contextInfo_1.ContextInfo === null || contextInfo_1.ContextInfo === void 0 ? void 0 : contextInfo_1.ContextInfo.siteId) === null || _a === void 0 ? void 0 : _a.replace(/[{}]/g, ''))) + "/drives";
23
+ drives.targetInfo.endpoint = "_api/v2.0/" + (props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') : "") + "drives";
21
24
  // See if the drive id was provided
22
25
  if (props.driveId) {
23
26
  // Append the id
package/build/v2/sites.js CHANGED
@@ -23,7 +23,52 @@ exports.sites = (function (props) {
23
23
  });
24
24
  /** Returns the current web. */
25
25
  exports.sites.getCurrentWeb = function () { return exports.sites().sites(contextInfo_1.ContextInfo.webId.replace(/^\{|\}$/g, '')); };
26
- /** Returns a list by its title from the current web. */
26
+ /** Returns a drive */
27
+ exports.sites.getDrive = (function (props) {
28
+ // Return a promise
29
+ return new Promise(function (resolve, reject) {
30
+ // Method to get the drive id
31
+ var getDriveId = function (siteId, libName) {
32
+ // Return a promise
33
+ return new Promise(function (resolve, reject) {
34
+ // Get the drives
35
+ exports.sites({ siteId: siteId }).drives().query({ Select: ["id", "name"] }).execute(function (drives) {
36
+ // Parse the drives
37
+ for (var i = 0; i < drives.results.length; i++) {
38
+ var drive = drives.results[i];
39
+ // See if this is the target library
40
+ if (drive["name"] == libName) {
41
+ // Resolve the request
42
+ resolve(drive.id);
43
+ return;
44
+ }
45
+ }
46
+ // Not found
47
+ reject();
48
+ }, reject);
49
+ });
50
+ };
51
+ // See if the site id exists
52
+ if (props.siteId) {
53
+ // Get the drive id
54
+ getDriveId(props.siteId, props.libName).then(function (driveId) {
55
+ // Resolve the request
56
+ resolve(exports.sites({ siteId: props.siteId }).drives(driveId));
57
+ }, reject);
58
+ }
59
+ else {
60
+ // Get the site
61
+ site_1.Site(props.siteUrl).query({ Select: ["Id"] }).execute(function (site) {
62
+ // Get the drive id
63
+ getDriveId(site.Id, props.libName).then(function (driveId) {
64
+ // Resolve the request
65
+ resolve(exports.sites({ siteId: site.Id }).drives(driveId));
66
+ }, reject);
67
+ }, reject);
68
+ }
69
+ });
70
+ });
71
+ /** Returns a list */
27
72
  exports.sites.getList = (function (props) {
28
73
  // Return a promise
29
74
  return new Promise(function (resolve, reject) {
@@ -4468,7 +4468,7 @@ declare module 'gd-sprest/v2/drive' {
4468
4468
  * @param siteId - (Optional) The site id to target, current by default.
4469
4469
  * @param targetInfo - (Optional) The target information.
4470
4470
  */
4471
- (props?: { siteId?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<drive>;
4471
+ (props?: { siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<drive>;
4472
4472
  }
4473
4473
  }
4474
4474
 
@@ -4503,9 +4503,10 @@ declare module 'gd-sprest/v2/drives' {
4503
4503
  * Get the libraries for a site.
4504
4504
  * @param id - (Optional) The drive id to target.
4505
4505
  * @param siteId - (Optional) The site id to target, current by default.
4506
+ * @param siteUrl - (Optional) The site url to target, current by default.
4506
4507
  * @param targetInfo - (Optional) The target information.
4507
4508
  */
4508
- (props?: { driveId?: string, siteId?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<driveCollection>;
4509
+ (props?: { driveId?: string, siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<driveCollection>;
4509
4510
  }
4510
4511
  }
4511
4512
 
@@ -4539,7 +4540,7 @@ declare module 'gd-sprest/v2/sites' {
4539
4540
  export interface Isites {
4540
4541
  /**
4541
4542
  * Creates an instance of the site library.
4542
- * @param id - (Optional) The site id to target, current by default.
4543
+ * @param siteId - (Optional) The site id to target, current by default.
4543
4544
  * @param targetInfo - (Optional) The target information.
4544
4545
  */
4545
4546
  (props?: { siteId?: string, targetInfo?: ITargetInfoProps }): siteMethods & sites;
@@ -4547,7 +4548,10 @@ declare module 'gd-sprest/v2/sites' {
4547
4548
  /** Returns the current web. */
4548
4549
  static getCurrentWeb(): IBaseExecution<sites> & siteMethods;
4549
4550
 
4550
- /** Returns a list for a web. */
4551
+ /** Returns a drive for a site. */
4552
+ static getDrive(props: { siteId?: string, siteUrl?: string, libName?: string }): IBaseExecution<list> & listMethods;
4553
+
4554
+ /** Returns a list for a site. */
4551
4555
  static getList(props: { siteId?: string, siteUrl?: string, listId?: string, listName?: string }): IBaseExecution<list> & listMethods;
4552
4556
  }
4553
4557
  }