gd-sprest 8.4.6 → 8.4.7

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.
@@ -4,7 +4,7 @@ import { ITargetInfoProps } from "../utils";
4
4
 
5
5
  /**
6
6
  * #### REST API
7
- * _api/v2.0/drive
7
+ * _api/v2.1/drive
8
8
  *
9
9
  * #### Get the default library for a site.
10
10
  *
@@ -20,7 +20,7 @@ export const drive: Idrive;
20
20
 
21
21
  /**
22
22
  * Drive
23
- * The v2.0 REST endpoint.
23
+ * The v2.1 REST endpoint.
24
24
  * @category Drive
25
25
  */
26
26
  export interface Idrive {
@@ -4,7 +4,7 @@ import { ITargetInfoProps } from "../utils";
4
4
 
5
5
  /**
6
6
  * #### REST API
7
- * _api/v2.0/drives
7
+ * _api/v2.1/drives
8
8
  *
9
9
  * #### Get the libraries for a site.
10
10
  *
@@ -20,7 +20,7 @@ export const drives: Idrives;
20
20
 
21
21
  /**
22
22
  * Drives
23
- * The v2.0 REST endpoint.
23
+ * The v2.1 REST endpoint.
24
24
  * @category Drives
25
25
  */
26
26
  export interface Idrives {
@@ -1,11 +1,14 @@
1
- import { IBaseExecution } from "gd-sprest-def/lib/base";
1
+ import { IBaseExecution, IBaseQuery } from "gd-sprest-def/lib/base";
2
2
  import { sites } from "gd-sprest-def/lib/Microsoft/Graph/api";
3
- import { list, listMethods, siteMethods } from "gd-sprest-def/lib/Microsoft/Graph/entityTypes";
3
+ import {
4
+ drive, driveMethods, listItem, listItemMethods,
5
+ list, listMethods, siteMethods
6
+ } from "gd-sprest-def/lib/Microsoft/Graph/entityTypes";
4
7
  import { ITargetInfoProps } from "../utils";
5
8
 
6
9
  /**
7
10
  * #### REST API
8
- * _api/v2.0/sites
11
+ * _api/v2.1/sites
9
12
  *
10
13
  * #### Get the current site
11
14
  *
@@ -21,7 +24,7 @@ export const sites: Isites;
21
24
 
22
25
  /**
23
26
  * Sites
24
- * The v2.0 REST endpoint.
27
+ * The v2.1 REST endpoint.
25
28
  * @category Sites
26
29
  */
27
30
  export interface Isites {
@@ -33,11 +36,14 @@ export interface Isites {
33
36
  (props?: { siteId?: string, targetInfo?: ITargetInfoProps }): siteMethods & sites;
34
37
 
35
38
  /** Returns the current web. */
36
- static getCurrentWeb(): IBaseExecution<sites> & siteMethods;
39
+ static getCurrentWeb(): IBaseQuery<site> & siteMethods;
37
40
 
38
41
  /** Returns a drive for a site. */
39
- static getDrive(props: { siteId?: string, siteUrl?: string, libName?: string }): IBaseExecution<list> & listMethods;
42
+ static getDrive(props: { siteId?: string, siteUrl?: string, libName?: string }): PromiseLike<IBaseQuery<drive> & driveMethods>;
43
+
44
+ /** Returns a drive for a site. */
45
+ static getFile(props: { fileName: string, siteId?: string, siteUrl?: string, libName?: string }): PromiseLike<IBaseQuery<item> & itemMethods>;
40
46
 
41
47
  /** Returns a list for a site. */
42
- static getList(props: { siteId?: string, siteUrl?: string, listId?: string, listName?: string }): IBaseExecution<list> & listMethods;
48
+ static getList(props: { siteId?: string, siteUrl?: string, listId?: string, listName?: string }): PromiseLike<IBaseQuery<list> & listMethods>;
43
49
  }
package/build/lib/list.js CHANGED
@@ -119,7 +119,7 @@ exports.List.runFlow = function (props) {
119
119
  method: "POST",
120
120
  requestType: utils_1.RequestType.GraphPost,
121
121
  requestHeader: {
122
- "authorization": "Bearer " + token
122
+ "authorization": "bearer " + token
123
123
  }
124
124
  }).execute(function (tokenInfo) {
125
125
  // Resolve the request
@@ -50,6 +50,10 @@ exports.MapperV2 = {
50
50
  query: { argNames: ["oData"], requestType: utils_1.RequestType.OData },
51
51
  },
52
52
  drive: {
53
+ properties: [
54
+ "drives|drives|('[Name]')|drive", "items|items|([Name])|item",
55
+ "lists|lists|('[Name]')|list"
56
+ ],
53
57
  activities: {
54
58
  requestType: utils_1.RequestType.Get
55
59
  },
@@ -88,6 +92,10 @@ exports.MapperV2 = {
88
92
  children: {
89
93
  requestType: utils_1.RequestType.Get
90
94
  },
95
+ extractSensitivityLabel: {
96
+ name: "[base.eTag]/extractSensitivityLabel",
97
+ requestType: utils_1.RequestType.Post
98
+ },
91
99
  subscriptions: {
92
100
  requestType: utils_1.RequestType.Get
93
101
  },
@@ -110,6 +118,12 @@ exports.MapperV2 = {
110
118
  requestType: utils_1.RequestType.Get
111
119
  },
112
120
  query: { argNames: ["oData"], requestType: utils_1.RequestType.OData },
121
+ setSensitivityLabel: {
122
+ argNames: ["values"],
123
+ name: "[base.eTag]/setSensitivityLabel",
124
+ requestType: utils_1.RequestType.PostBodyNoArgs,
125
+ useToken: true
126
+ },
113
127
  update: {
114
128
  args: ["values"],
115
129
  name: "",
@@ -166,19 +180,10 @@ exports.MapperV2 = {
166
180
  requestType: utils_1.RequestType.GetWithArgsValueOnly,
167
181
  returnType: "analytics"
168
182
  },
169
- assignSensitivityLabel: {
170
- argNames: ["values"],
171
- name: "[base.eTag]/assignSensitivityLabel",
172
- requestType: utils_1.RequestType.PostBodyNoArgs
173
- },
174
183
  driveItem: {
175
184
  requestType: utils_1.RequestType.Get,
176
185
  returnType: "driveItem"
177
186
  },
178
- extractSensitivityLabels: {
179
- name: "[base.eTag]/extractSensitivityLabel",
180
- requestType: utils_1.RequestType.Post
181
- },
182
187
  fields: {
183
188
  appendRequest: true,
184
189
  requestType: utils_1.RequestType.Get,
@@ -189,6 +194,11 @@ exports.MapperV2 = {
189
194
  permissions: {
190
195
  requestType: utils_1.RequestType.Get
191
196
  },
197
+ setSensitivityLabel: {
198
+ argNames: ["values"],
199
+ name: "[base.eTag]/setSensitivityLabel",
200
+ requestType: utils_1.RequestType.PostBodyNoArgs
201
+ },
192
202
  update: {
193
203
  args: ["values"],
194
204
  name: "",
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.46,
12
+ __ver: 8.47,
13
13
  AppContext: function (siteUrl) { return Lib.Site.getAppContext(siteUrl); },
14
14
  Apps: Lib.Apps,
15
15
  ContextInfo: Lib.ContextInfo,
@@ -80,6 +80,7 @@ exports.Helper = {
80
80
  // Get the method information
81
81
  var methodInfo = new _1.MethodInfo(methodName, methodConfig, args);
82
82
  // Update the target information
83
+ targetInfo.accessToken = methodInfo.useToken ? lib_1.Graph.Token : null;
83
84
  targetInfo.bufferFl = methodConfig.requestType == _1.RequestType.GetBuffer;
84
85
  targetInfo.data = methodInfo.body;
85
86
  targetInfo.defaultToWebFl = typeof (targetInfo.defaultToWebFl) === "undefined" && base.base ? base.base.targetInfo.defaultToWebFl : targetInfo.defaultToWebFl;
@@ -253,7 +254,7 @@ exports.Helper = {
253
254
  if (obj["@odata.context"]) {
254
255
  // Get the object type
255
256
  var metadataType = (obj["@odata.context"] || objType);
256
- var values = metadataType.split("_api/v2.0/$metadata#");
257
+ var values = metadataType.split("_api/v2.1/$metadata#");
257
258
  if (values.length > 1) {
258
259
  objType = values[1];
259
260
  }
@@ -87,6 +87,12 @@ var MethodInfo = /** @class */ (function () {
87
87
  enumerable: false,
88
88
  configurable: true
89
89
  });
90
+ Object.defineProperty(MethodInfo.prototype, "useToken", {
91
+ // Flag to determine if the token should be used
92
+ get: function () { return this.methodInfo.useToken ? true : false; },
93
+ enumerable: false,
94
+ configurable: true
95
+ });
90
96
  Object.defineProperty(MethodInfo.prototype, "passDataInBody", {
91
97
  /*********************************************************************************************************************************/
92
98
  // Private Variables
@@ -35,7 +35,7 @@ exports.Request = {
35
35
  var metadata = isCollection ? data.results[0].__metadata : data.__metadata;
36
36
  // Get the object type
37
37
  var objType = metadata && metadata.type ? metadata.type : obj.targetInfo.endpoint;
38
- var isV2 = ((_b = (_a = obj === null || obj === void 0 ? void 0 : obj.parent) === null || _a === void 0 ? void 0 : _a.targetInfo) === null || _b === void 0 ? void 0 : _b.endpoint.startsWith("_api/v2.0/")) ||
38
+ var isV2 = ((_b = (_a = obj === null || obj === void 0 ? void 0 : obj.parent) === null || _a === void 0 ? void 0 : _a.targetInfo) === null || _b === void 0 ? void 0 : _b.endpoint.startsWith("_api/v2.1/")) ||
39
39
  obj["@odata.context"] || objType.startsWith("@odata.context") ? true : false;
40
40
  if (isV2) {
41
41
  // See if we are overriding the object type
@@ -46,7 +46,7 @@ exports.Request = {
46
46
  else {
47
47
  // Get the object type from the context
48
48
  var metadataType = (obj["@odata.context"] || objType);
49
- var values = metadataType.split("_api/v2.0/$metadata#");
49
+ var values = metadataType.split("_api/v2.1/$metadata#");
50
50
  if (values.length > 1) {
51
51
  objType = values[1];
52
52
  }
@@ -43,7 +43,7 @@ var TargetInfo = /** @class */ (function () {
43
43
  // Flag to determine if this is a graph request
44
44
  get: function () {
45
45
  var _a;
46
- return ((_a = this.props.endpoint) === null || _a === void 0 ? void 0 : _a.startsWith("_api/v2.0/")) ||
46
+ return ((_a = this.props.endpoint) === null || _a === void 0 ? void 0 : _a.startsWith("_api/v2.1/")) ||
47
47
  this.props.requestType == _1.RequestType.GraphGet || this.props.requestType == _1.RequestType.GraphPost ||
48
48
  this.props.requestType == _1.RequestType.GraphGetReplace || this.props.requestType == _1.RequestType.GraphPostReplace;
49
49
  },
@@ -157,8 +157,8 @@ var XHRRequest = /** @class */ (function () {
157
157
  // Ensure the access token exists
158
158
  if (this.targetInfo.props.accessToken) {
159
159
  // Set the authorization
160
- this.xhr ? this.xhr.setRequestHeader("Authorization", "Bearer " + this.targetInfo.props.accessToken) : null;
161
- this.headers["Authorization"] = "Bearer " + this.targetInfo.props.accessToken;
160
+ this.xhr ? this.xhr.setRequestHeader("Authorization", "bearer " + this.targetInfo.props.accessToken) : null;
161
+ this.headers["Authorization"] = "bearer " + this.targetInfo.props.accessToken;
162
162
  }
163
163
  else {
164
164
  // Set the request digest
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.init = void 0;
4
+ var graph_1 = require("../lib/graph");
5
+ /**
6
+ * Initialization for the v2 libs.
7
+ */
8
+ function init() {
9
+ // See if the token is already set
10
+ if (graph_1.Graph.Token) {
11
+ return;
12
+ }
13
+ // Set the cloud access token
14
+ graph_1.Graph.getAccessToken(graph_1.Graph.Cloud).execute(function (auth) {
15
+ // Set the access token
16
+ graph_1.Graph.Token = auth.access_token;
17
+ });
18
+ }
19
+ exports.init = init;
package/build/v2/drive.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.drive = void 0;
4
4
  var utils_1 = require("../utils");
5
+ var common_1 = require("./common");
5
6
  /**
6
7
  * Drive
7
8
  * Returns the default library for a site.
@@ -9,6 +10,8 @@ var utils_1 = require("../utils");
9
10
  exports.drive = (function (props) {
10
11
  if (props === void 0) { props = {}; }
11
12
  var drive = new utils_1.Base(props.targetInfo);
13
+ // Call the init event
14
+ common_1.init();
12
15
  // Default the properties
13
16
  drive.targetInfo.defaultToWebFl = true;
14
17
  drive.targetInfo.requestType = utils_1.RequestType.GraphGet;
@@ -20,9 +23,9 @@ exports.drive = (function (props) {
20
23
  // See if an endpoint is not defined
21
24
  if (drive.targetInfo.endpoint == undefined) {
22
25
  // Default the endpoint
23
- drive.targetInfo.endpoint = "_api/v2.0/" + (props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') : "") + "drive";
26
+ drive.targetInfo.endpoint = "_api/v2.1/" + (props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') : "") + "drive";
24
27
  // Add the methods
25
- utils_1.Request.addMethods(drive, { __metadata: { type: "@odata.context/_api/v2.0/$metadata#drive" } });
28
+ utils_1.Request.addMethods(drive, { __metadata: { type: "@odata.context/_api/v2.1/$metadata#drive" } });
26
29
  }
27
30
  // Return the default library
28
31
  return drive;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.drives = void 0;
4
4
  var utils_1 = require("../utils");
5
+ var common_1 = require("./common");
5
6
  /**
6
7
  * Drives
7
8
  * Returns the libraries for a site.
@@ -9,6 +10,8 @@ var utils_1 = require("../utils");
9
10
  exports.drives = (function (props) {
10
11
  if (props === void 0) { props = {}; }
11
12
  var drives = new utils_1.Base(props.targetInfo);
13
+ // Call the init event
14
+ common_1.init();
12
15
  // Default the properties
13
16
  drives.targetInfo.defaultToWebFl = true;
14
17
  drives.targetInfo.requestType = utils_1.RequestType.GraphGet;
@@ -20,17 +23,17 @@ exports.drives = (function (props) {
20
23
  // See if an endpoint is not defined
21
24
  if (drives.targetInfo.endpoint == undefined) {
22
25
  // Default the endpoint
23
- drives.targetInfo.endpoint = "_api/v2.0/" + (props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') : "") + "drives";
26
+ drives.targetInfo.endpoint = "_api/v2.1/" + (props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') : "") + "drives";
24
27
  // See if the drive id was provided
25
28
  if (props.driveId) {
26
29
  // Append the id
27
30
  drives.targetInfo.endpoint += "/" + props.driveId;
28
31
  // Add the methods
29
- utils_1.Request.addMethods(drives, { __metadata: { type: "@odata.context/_api/v2.0/$metadata#drive" } });
32
+ utils_1.Request.addMethods(drives, { __metadata: { type: "@odata.context/_api/v2.1/$metadata#drive" } });
30
33
  }
31
34
  else {
32
35
  // Add the methods
33
- utils_1.Request.addMethods(drives, { __metadata: { type: "@odata.context/_api/v2.0/$metadata#drives" } });
36
+ utils_1.Request.addMethods(drives, { __metadata: { type: "@odata.context/_api/v2.1/$metadata#drives" } });
34
37
  }
35
38
  }
36
39
  // Return the libraries
package/build/v2/sites.js CHANGED
@@ -4,6 +4,7 @@ exports.sites = void 0;
4
4
  var contextInfo_1 = require("../lib/contextInfo");
5
5
  var site_1 = require("../lib/site");
6
6
  var utils_1 = require("../utils");
7
+ var common_1 = require("./common");
7
8
  /**
8
9
  * Sites
9
10
  * The sites graph endpoint.
@@ -12,19 +13,21 @@ exports.sites = (function (props) {
12
13
  var _a;
13
14
  if (props === void 0) { props = {}; }
14
15
  var sites = new utils_1.Base(props.targetInfo);
16
+ // Call the init event
17
+ common_1.init();
15
18
  // Default the properties
16
19
  sites.targetInfo.defaultToWebFl = true;
17
- sites.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, '')));
20
+ 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, '')));
18
21
  sites.targetInfo.requestType = utils_1.RequestType.GraphGet;
19
22
  // Add the methods
20
- utils_1.Request.addMethods(sites, { __metadata: { type: "@odata.context/_api/v2.0/$metadata#sites" } });
23
+ utils_1.Request.addMethods(sites, { __metadata: { type: "@odata.context/_api/v2.1/$metadata#sites" } });
21
24
  // Return the sites
22
25
  return sites;
23
26
  });
24
27
  /** Returns the current web. */
25
28
  exports.sites.getCurrentWeb = function () { return exports.sites().sites(contextInfo_1.ContextInfo.webId.replace(/^\{|\}$/g, '')); };
26
29
  /** Returns a drive */
27
- exports.sites.getDrive = (function (props) {
30
+ exports.sites.getDrive = function (props) {
28
31
  // Return a promise
29
32
  return new Promise(function (resolve, reject) {
30
33
  // Method to get the drive id
@@ -67,7 +70,22 @@ exports.sites.getDrive = (function (props) {
67
70
  }, reject);
68
71
  }
69
72
  });
70
- });
73
+ };
74
+ /** Returns a file */
75
+ exports.sites.getFile = function (props) {
76
+ // Return a promise
77
+ 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);
85
+ }, reject);
86
+ }, reject);
87
+ });
88
+ };
71
89
  /** Returns a list */
72
90
  exports.sites.getList = (function (props) {
73
91
  // Return a promise
@@ -4443,7 +4443,7 @@ declare module 'gd-sprest/v2/drive' {
4443
4443
 
4444
4444
  /**
4445
4445
  * #### REST API
4446
- * _api/v2.0/drive
4446
+ * _api/v2.1/drive
4447
4447
  *
4448
4448
  * #### Get the default library for a site.
4449
4449
  *
@@ -4459,7 +4459,7 @@ declare module 'gd-sprest/v2/drive' {
4459
4459
 
4460
4460
  /**
4461
4461
  * Drive
4462
- * The v2.0 REST endpoint.
4462
+ * The v2.1 REST endpoint.
4463
4463
  * @category Drive
4464
4464
  */
4465
4465
  export interface Idrive {
@@ -4479,7 +4479,7 @@ declare module 'gd-sprest/v2/drives' {
4479
4479
 
4480
4480
  /**
4481
4481
  * #### REST API
4482
- * _api/v2.0/drives
4482
+ * _api/v2.1/drives
4483
4483
  *
4484
4484
  * #### Get the libraries for a site.
4485
4485
  *
@@ -4495,7 +4495,7 @@ declare module 'gd-sprest/v2/drives' {
4495
4495
 
4496
4496
  /**
4497
4497
  * Drives
4498
- * The v2.0 REST endpoint.
4498
+ * The v2.1 REST endpoint.
4499
4499
  * @category Drives
4500
4500
  */
4501
4501
  export interface Idrives {
@@ -4511,14 +4511,17 @@ declare module 'gd-sprest/v2/drives' {
4511
4511
  }
4512
4512
 
4513
4513
  declare module 'gd-sprest/v2/sites' {
4514
- import { IBaseExecution } from "gd-sprest-def/lib/base";
4514
+ import { IBaseExecution, IBaseQuery } from "gd-sprest-def/lib/base";
4515
4515
  import { sites } from "gd-sprest-def/lib/Microsoft/Graph/api";
4516
- import { list, listMethods, siteMethods } from "gd-sprest-def/lib/Microsoft/Graph/entityTypes";
4516
+ import {
4517
+ drive, driveMethods, listItem, listItemMethods,
4518
+ list, listMethods, siteMethods
4519
+ } from "gd-sprest-def/lib/Microsoft/Graph/entityTypes";
4517
4520
  import { ITargetInfoProps } from "gd-sprest/utils";
4518
4521
 
4519
4522
  /**
4520
4523
  * #### REST API
4521
- * _api/v2.0/sites
4524
+ * _api/v2.1/sites
4522
4525
  *
4523
4526
  * #### Get the current site
4524
4527
  *
@@ -4534,7 +4537,7 @@ declare module 'gd-sprest/v2/sites' {
4534
4537
 
4535
4538
  /**
4536
4539
  * Sites
4537
- * The v2.0 REST endpoint.
4540
+ * The v2.1 REST endpoint.
4538
4541
  * @category Sites
4539
4542
  */
4540
4543
  export interface Isites {
@@ -4546,13 +4549,16 @@ declare module 'gd-sprest/v2/sites' {
4546
4549
  (props?: { siteId?: string, targetInfo?: ITargetInfoProps }): siteMethods & sites;
4547
4550
 
4548
4551
  /** Returns the current web. */
4549
- static getCurrentWeb(): IBaseExecution<sites> & siteMethods;
4552
+ static getCurrentWeb(): IBaseQuery<site> & siteMethods;
4553
+
4554
+ /** Returns a drive for a site. */
4555
+ static getDrive(props: { siteId?: string, siteUrl?: string, libName?: string }): PromiseLike<IBaseQuery<drive> & driveMethods>;
4550
4556
 
4551
4557
  /** Returns a drive for a site. */
4552
- static getDrive(props: { siteId?: string, siteUrl?: string, libName?: string }): IBaseExecution<list> & listMethods;
4558
+ static getFile(props: { fileName: string, siteId?: string, siteUrl?: string, libName?: string }): PromiseLike<IBaseQuery<item> & itemMethods>;
4553
4559
 
4554
4560
  /** Returns a list for a site. */
4555
- static getList(props: { siteId?: string, siteUrl?: string, listId?: string, listName?: string }): IBaseExecution<list> & listMethods;
4561
+ static getList(props: { siteId?: string, siteUrl?: string, listId?: string, listName?: string }): PromiseLike<IBaseQuery<list> & listMethods>;
4556
4562
  }
4557
4563
  }
4558
4564