gd-sprest 8.5.1 → 8.5.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.
@@ -31,19 +31,23 @@ export interface Isites {
31
31
  /**
32
32
  * Creates an instance of the site library.
33
33
  * @param siteId - (Optional) The site id to target, current by default.
34
+ * @param webId - (Optional) The sub-site id to target.
34
35
  * @param targetInfo - (Optional) The target information.
35
36
  */
36
- (props?: { siteId?: string, targetInfo?: ITargetInfoProps }): siteMethods & sites;
37
+ (props?: { siteId?: string, webId?: string, targetInfo?: ITargetInfoProps }): siteMethods & sites;
37
38
 
38
39
  /** Returns the current web. */
39
40
  static getCurrentWeb(): IBaseQuery<site> & siteMethods;
40
41
 
41
42
  /** Returns a drive for a site. */
42
- static getDrive(props: { siteId?: string, siteUrl?: string, libName?: string }): PromiseLike<IBaseQuery<drive> & driveMethods>;
43
+ static getDrive(props: { siteId?: string, siteUrl?: string, libName?: string, webId?: string }): PromiseLike<IBaseQuery<drive> & driveMethods>;
43
44
 
44
45
  /** Returns a drive for a site. */
45
- static getFile(props: { fileName: string, siteId?: string, siteUrl?: string, libName?: string }): PromiseLike<IBaseQuery<item> & itemMethods>;
46
+ static getFile(props: { fileUrl: string, siteId?: string, siteUrl?: string, libName?: string }): PromiseLike<IBaseQuery<item> & itemMethods>;
46
47
 
47
48
  /** Returns a list for a site. */
48
49
  static getList(props: { siteId?: string, siteUrl?: string, listId?: string, listName?: string }): PromiseLike<IBaseQuery<list> & listMethods>;
50
+
51
+ /** Returns the site and web ids. */
52
+ static getIdByUrl(siteUrl: string): PromiseLike<{ siteId: string, siteUrl: string, webId: string, webUrl: string }>;
49
53
  }
@@ -12,6 +12,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./audit"), exports);
14
14
  __exportStar(require("./graph"), exports);
15
+ __exportStar(require("./odata"), exports);
15
16
  __exportStar(require("./old"), exports);
16
17
  __exportStar(require("./peoplePicker"), exports);
17
18
  __exportStar(require("./propertyValues"), exports);
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.odata = void 0;
4
+ var utils_1 = require("../../utils");
5
+ /**
6
+ * OData
7
+ */
8
+ exports.odata = {
9
+ // Adds the odata query option
10
+ query: { argNames: ["oData"], requestType: utils_1.RequestType.OData }
11
+ };
@@ -4101,7 +4101,7 @@ exports.Mapper = {
4101
4101
  "SP.File": {
4102
4102
  properties: [
4103
4103
  "Author|SP.User", "CheckedOutByUser|SP.User", "EffectiveInformationRightsManagementSettings", "InformationRightsManagementSettings",
4104
- "ListItemAllFields", "LockedByUser|SP.User", "ModifiedBy|SP.User", "Properties", "VersionEvents", "Versions|SP.FileVersion.Collection"
4104
+ "ListItemAllFields|odata", "LockedByUser|SP.User", "ModifiedBy|SP.User", "Properties", "VersionEvents", "Versions|SP.FileVersion.Collection"
4105
4105
  ],
4106
4106
  addClientActivities: {
4107
4107
  argNames: ["activitiesStream"],
@@ -4377,7 +4377,7 @@ exports.Mapper = {
4377
4377
  },
4378
4378
  "SP.Folder": {
4379
4379
  properties: [
4380
- "Files|SP.File.Collection|/getByUrl('[Name]')|SP.File", "Folders|SP.Folder.Collection|/getByUrl('[Name]')|SP.Folder", "ListItemAllFields",
4380
+ "Files|SP.File.Collection|/getByUrl('[Name]')|SP.File", "Folders|SP.Folder.Collection|/getByUrl('[Name]')|SP.Folder", "ListItemAllFields|odata",
4381
4381
  "ParentFolder|SP.Folder", "Properties", "StorageMetrics"
4382
4382
  ],
4383
4383
  addSubFolder: {
@@ -4432,7 +4432,7 @@ exports.Mapper = {
4432
4432
  },
4433
4433
  "SP.Folder.Collection": {
4434
4434
  properties: [
4435
- "Files|SP.File.Collection|/getByUrl('[Name]')|SP.File", "Folders|SP.Folder.Collection|/getByUrl('[Name]')|SP.Folder", "ListItemAllFields",
4435
+ "Files|SP.File.Collection|/getByUrl('[Name]')|SP.File", "Folders|SP.Folder.Collection|/getByUrl('[Name]')|SP.Folder",
4436
4436
  "ParentFolder", "StorageMetrics"
4437
4437
  ],
4438
4438
  add: {
@@ -120,7 +120,6 @@ exports.MapperV2 = {
120
120
  query: { argNames: ["oData"], requestType: utils_1.RequestType.OData },
121
121
  setSensitivityLabel: {
122
122
  argNames: ["values"],
123
- name: "[base.eTag]/setSensitivityLabel",
124
123
  requestType: utils_1.RequestType.PostBodyNoArgs,
125
124
  useToken: true
126
125
  },
@@ -196,7 +195,6 @@ exports.MapperV2 = {
196
195
  },
197
196
  setSensitivityLabel: {
198
197
  argNames: ["values"],
199
- name: "[base.eTag]/setSensitivityLabel",
200
198
  requestType: utils_1.RequestType.PostBodyNoArgs
201
199
  },
202
200
  update: {
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.51,
12
+ __ver: 8.53,
13
13
  AppContext: function (siteUrl) { return Lib.Site.getAppContext(siteUrl); },
14
14
  Apps: Lib.Apps,
15
15
  ContextInfo: Lib.ContextInfo,
package/build/v2/sites.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sites = void 0;
4
4
  var contextInfo_1 = require("../lib/contextInfo");
5
5
  var site_1 = require("../lib/site");
6
+ var web_1 = require("../lib/web");
6
7
  var utils_1 = require("../utils");
7
8
  var common_1 = require("./common");
8
9
  /**
@@ -19,6 +20,11 @@ exports.sites = (function (props) {
19
20
  sites.targetInfo.defaultToWebFl = true;
20
21
  sites.targetInfo.endpoint = "_api/v2.1/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, '')));
21
22
  sites.targetInfo.requestType = utils_1.RequestType.GraphGet;
23
+ // See if the web id is provided
24
+ if (props.webId) {
25
+ // Append the web id
26
+ sites.targetInfo.endpoint += "," + props.webId;
27
+ }
22
28
  // Add the methods
23
29
  utils_1.Request.addMethods(sites, { __metadata: { type: "@odata.context/_api/v2.1/$metadata#sites" } });
24
30
  // Return the sites
@@ -31,11 +37,11 @@ exports.sites.getDrive = function (props) {
31
37
  // Return a promise
32
38
  return new Promise(function (resolve, reject) {
33
39
  // Method to get the drive id
34
- var getDriveId = function (siteId, libName) {
40
+ var getDriveId = function (siteId, webId, libName) {
35
41
  // Return a promise
36
42
  return new Promise(function (resolve, reject) {
37
43
  // Get the drives
38
- exports.sites({ siteId: siteId }).drives().query({ Select: ["id", "name"] }).execute(function (drives) {
44
+ exports.sites({ siteId: siteId, webId: webId }).drives().query({ Select: ["id", "name"] }).execute(function (drives) {
39
45
  // Parse the drives
40
46
  for (var i = 0; i < drives.results.length; i++) {
41
47
  var drive = drives.results[i];
@@ -54,18 +60,18 @@ exports.sites.getDrive = function (props) {
54
60
  // See if the site id exists
55
61
  if (props.siteId) {
56
62
  // Get the drive id
57
- getDriveId(props.siteId, props.libName).then(function (driveId) {
63
+ getDriveId(props.siteId, props.webId, props.libName).then(function (driveId) {
58
64
  // Resolve the request
59
65
  resolve(exports.sites({ siteId: props.siteId }).drives(driveId));
60
66
  }, reject);
61
67
  }
62
68
  else {
63
- // Get the site
64
- site_1.Site(props.siteUrl).query({ Select: ["Id"] }).execute(function (site) {
69
+ // Get the site/web ids
70
+ exports.sites.getIdByUrl(props.siteUrl).then(function (info) {
65
71
  // Get the drive id
66
- getDriveId(site.Id, props.libName).then(function (driveId) {
72
+ getDriveId(info.siteId, info.webId, props.libName).then(function (driveId) {
67
73
  // Resolve the request
68
- resolve(exports.sites({ siteId: site.Id }).drives(driveId));
74
+ resolve(exports.sites({ siteId: info.siteId, webId: info.webId }).drives(driveId));
69
75
  }, reject);
70
76
  }, reject);
71
77
  }
@@ -75,13 +81,24 @@ exports.sites.getDrive = function (props) {
75
81
  exports.sites.getFile = function (props) {
76
82
  // Return a promise
77
83
  return new Promise(function (resolve, reject) {
78
- // Get the library
79
- exports.sites.getDrive(props).then(function (drive) {
80
- // Get the file
81
- drive.items().query({ Filter: "name eq '" + props.fileName + "'" }).execute(function (resp) {
82
- var file = resp.results[0];
83
- // Resolve the request
84
- resolve(file ? drive.items(file.id) : null);
84
+ // Get the site/web info
85
+ exports.sites.getIdByUrl(props.fileUrl).then(function (info) {
86
+ // Get the drive
87
+ exports.sites.getDrive({ siteId: info.siteId, webId: info.webId, libName: props.libName }).then(function (drive) {
88
+ // Get the file
89
+ web_1.Web(info.webUrl).getFileByUrl(props.fileUrl).execute(function (file) {
90
+ // Get the item for this file
91
+ file.ListItemAllFields().query({ Expand: ["ParentList"] }).execute(function (item) {
92
+ drive.items().query({
93
+ Expand: ["listItem"],
94
+ Filter: "listItem/id eq '" + item.Id + "'"
95
+ }).execute(function (resp) {
96
+ var file = resp.results[0];
97
+ // Resolve the request
98
+ resolve(file ? drive.items(file.id) : null);
99
+ }, reject);
100
+ });
101
+ });
85
102
  }, reject);
86
103
  }, reject);
87
104
  });
@@ -96,11 +113,33 @@ exports.sites.getList = (function (props) {
96
113
  resolve(exports.sites({ siteId: props.siteId }).lists(props.listId || props.listName));
97
114
  }
98
115
  else {
99
- // Get the site
100
- site_1.Site(props.siteUrl).query({ Select: ["Id"] }).execute(function (site) {
116
+ // Get the ids
117
+ exports.sites.getIdByUrl(props.siteUrl).then(function (info) {
101
118
  // Resolve the request
102
- resolve(exports.sites({ siteId: site.Id }).lists(props.listId || props.listName));
119
+ resolve(exports.sites({ siteId: info.siteId, webId: info.webId }).lists(props.listId || props.listName));
103
120
  }, reject);
104
121
  }
105
122
  });
106
123
  });
124
+ /** Gets the site and web id from a url */
125
+ exports.sites.getIdByUrl = function (siteUrl) {
126
+ // Return a promise
127
+ return new Promise(function (resolve, reject) {
128
+ // Get the context information
129
+ contextInfo_1.ContextInfo.getWeb(siteUrl).execute(function (context) {
130
+ // Get the site id
131
+ site_1.Site(context.GetContextWebInformation.SiteFullUrl).query({ Select: ["Id"] }).execute(function (site) {
132
+ // Get the web id
133
+ web_1.Web(context.GetContextWebInformation.WebFullUrl).query({ Select: ["Id"] }).execute(function (web) {
134
+ // Resolve the request
135
+ resolve({
136
+ siteId: site.Id,
137
+ siteUrl: context.GetContextWebInformation.SiteFullUrl,
138
+ webId: web.Id,
139
+ webUrl: context.GetContextWebInformation.WebFullUrl
140
+ });
141
+ });
142
+ }, reject);
143
+ });
144
+ });
145
+ };
@@ -4545,21 +4545,25 @@ declare module 'gd-sprest/v2/sites' {
4545
4545
  /**
4546
4546
  * Creates an instance of the site library.
4547
4547
  * @param siteId - (Optional) The site id to target, current by default.
4548
+ * @param webId - (Optional) The sub-site id to target.
4548
4549
  * @param targetInfo - (Optional) The target information.
4549
4550
  */
4550
- (props?: { siteId?: string, targetInfo?: ITargetInfoProps }): siteMethods & sites;
4551
+ (props?: { siteId?: string, webId?: string, targetInfo?: ITargetInfoProps }): siteMethods & sites;
4551
4552
 
4552
4553
  /** Returns the current web. */
4553
4554
  static getCurrentWeb(): IBaseQuery<site> & siteMethods;
4554
4555
 
4555
4556
  /** Returns a drive for a site. */
4556
- static getDrive(props: { siteId?: string, siteUrl?: string, libName?: string }): PromiseLike<IBaseQuery<drive> & driveMethods>;
4557
+ static getDrive(props: { siteId?: string, siteUrl?: string, libName?: string, webId?: string }): PromiseLike<IBaseQuery<drive> & driveMethods>;
4557
4558
 
4558
4559
  /** Returns a drive for a site. */
4559
- static getFile(props: { fileName: string, siteId?: string, siteUrl?: string, libName?: string }): PromiseLike<IBaseQuery<item> & itemMethods>;
4560
+ static getFile(props: { fileUrl: string, siteId?: string, siteUrl?: string, libName?: string }): PromiseLike<IBaseQuery<item> & itemMethods>;
4560
4561
 
4561
4562
  /** Returns a list for a site. */
4562
4563
  static getList(props: { siteId?: string, siteUrl?: string, listId?: string, listName?: string }): PromiseLike<IBaseQuery<list> & listMethods>;
4564
+
4565
+ /** Returns the site and web ids. */
4566
+ static getIdByUrl(siteUrl: string): PromiseLike<{ siteId: string, siteUrl: string, webId: string, webUrl: string }>;
4563
4567
  }
4564
4568
  }
4565
4569