gd-sprest 7.8.2 → 7.8.4

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.
@@ -10,5 +10,5 @@ export const Executor: IExecutor;
10
10
  * Executor
11
11
  */
12
12
  export interface IExecutor {
13
- <T = any>(methodParams: Array<T>, method: (param: T) => PromiseLike<any> | void, onExecuted?: (...args) => PromiseLike<any> | void): PromiseLike<any>;
13
+ <T = any>(methodParams: Array<T>, method: (param: T) => PromiseLike<any | undefined> | void, onExecuted?: (...args) => PromiseLike<any | undefined> | void): PromiseLike<any | undefined>;
14
14
  }
package/build/lib/list.js CHANGED
@@ -66,7 +66,7 @@ exports.List.runFlow = function (props) {
66
66
  // Return a promise
67
67
  return new Promise(function (resolveAuth) {
68
68
  // Get the graph token
69
- graph_1.Graph.getAccessToken(sptypes_1.SPTypes.CloudEnvironment.Flow).execute(function (auth) {
69
+ graph_1.Graph.getAccessToken(props.cloudEnv).execute(function (auth) {
70
70
  // Resolve the request
71
71
  resolveAuth(auth.access_token);
72
72
  },
@@ -93,36 +93,43 @@ exports.List.runFlow = function (props) {
93
93
  else {
94
94
  // Get the graph token
95
95
  getGraphToken().then(function (token) {
96
- // See if the cloud environment was provided
97
- if (props.cloudEnv) {
98
- // Set the url
99
- var authUrl = "" + props.cloudEnv + flowInfo.properties.environment.id + "/users/me/onBehalfOfTokenBundle?api-version=2016-11-01";
100
- // Execute the request
101
- new utils_1.Base({
102
- endpoint: authUrl,
103
- method: "POST",
104
- requestType: utils_1.RequestType.GraphPost,
105
- requestHeader: {
106
- "authorization": "Bearer " + token
107
- }
108
- }).execute(function (tokenInfo) {
109
- // Resolve the request
110
- resolveAuth(tokenInfo.audienceToToken["https://" + flowInfo.properties.connectionReferences.shared_sharepointonline.swagger.host] || token);
111
- },
112
- // Error
113
- function (ex) {
114
- // Resolve the request
115
- resolve({
116
- executed: false,
117
- errorDetails: ex.response,
118
- errorMessage: "Auth Error: Unable to get the flow token for cloud: " + props.cloudEnv
119
- });
120
- });
96
+ // Determine the flow url
97
+ var flowUrl = "";
98
+ switch (props.cloudEnv) {
99
+ case sptypes_1.SPTypes.CloudEnvironment.USL4:
100
+ flowUrl = sptypes_1.SPTypes.CloudEnvironment.FlowHigh;
101
+ break;
102
+ case sptypes_1.SPTypes.CloudEnvironment.USL5:
103
+ flowUrl = sptypes_1.SPTypes.CloudEnvironment.FlowDoD;
104
+ break;
105
+ // Default
106
+ default:
107
+ flowUrl = sptypes_1.SPTypes.CloudEnvironment.Flow;
108
+ break;
121
109
  }
122
- else {
110
+ // Set the url
111
+ var authUrl = "" + flowUrl + flowInfo.properties.environment.id + "/users/me/onBehalfOfTokenBundle?api-version=2016-11-01";
112
+ // Execute the request
113
+ new utils_1.Base({
114
+ endpoint: authUrl,
115
+ method: "POST",
116
+ requestType: utils_1.RequestType.GraphPost,
117
+ requestHeader: {
118
+ "authorization": "Bearer " + token
119
+ }
120
+ }).execute(function (tokenInfo) {
123
121
  // Resolve the request
124
- resolveAuth(token);
125
- }
122
+ resolveAuth(tokenInfo.audienceToToken["https://" + flowInfo.properties.connectionReferences.shared_sharepointonline.swagger.host] || token);
123
+ },
124
+ // Error
125
+ function (ex) {
126
+ // Resolve the request
127
+ resolve({
128
+ executed: false,
129
+ errorDetails: ex.response,
130
+ errorMessage: "Auth Error: Unable to get the flow token for cloud: " + props.cloudEnv
131
+ });
132
+ });
126
133
  });
127
134
  }
128
135
  });
@@ -157,7 +157,9 @@ exports.MapperV2 = {
157
157
  returnType: "driveItem"
158
158
  },
159
159
  fields: {
160
+ appendRequest: true,
160
161
  requestType: utils_1.RequestType.Get,
162
+ name: "([base.id])/fields",
161
163
  returnType: "fields"
162
164
  },
163
165
  query: { argNames: ["oData"], requestType: utils_1.RequestType.OData },
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: 7.82,
12
+ __ver: 7.84,
13
13
  AppContext: function (siteUrl) { return Lib.Site.getAppContext(siteUrl); },
14
14
  Apps: Lib.Apps,
15
15
  ContextInfo: Lib.ContextInfo,
@@ -44,6 +44,7 @@ exports.Helper = {
44
44
  },
45
45
  // Method to execute a method
46
46
  executeMethod: function (base, methodName, methodConfig, args) {
47
+ var _a;
47
48
  var targetInfo = null;
48
49
  // See if the metadata is defined for the base object
49
50
  var metadata = base["d"] ? base["d"].__metadata : base["__metadata"];
@@ -64,6 +65,17 @@ exports.Helper = {
64
65
  // Copy the target information
65
66
  targetInfo = Object.create(base.targetInfo);
66
67
  }
68
+ // See if the method config name has a base reference
69
+ var startIdx = (_a = methodConfig === null || methodConfig === void 0 ? void 0 : methodConfig.name) === null || _a === void 0 ? void 0 : _a.indexOf("[base.");
70
+ if (startIdx >= 0) {
71
+ // Get the property name
72
+ var endIdx = methodConfig.name.indexOf("]", startIdx);
73
+ var propName = methodConfig.name.substring(startIdx, endIdx).split(".")[1];
74
+ // Get the property value
75
+ var propValue = base[propName] || "";
76
+ // Update the method name
77
+ methodConfig.name = methodConfig.name.replace("[base." + propName + "]", propValue);
78
+ }
67
79
  // Get the method information
68
80
  var methodInfo = new _1.MethodInfo(methodName, methodConfig, args);
69
81
  // Update the target information
@@ -90,7 +102,7 @@ exports.Helper = {
90
102
  // See if the endpoint exists, and the method is not a query string
91
103
  if (targetInfo.endpoint && methodInfo.url && methodInfo.url.indexOf("?") != 0) {
92
104
  // Add a "/" separator to the url
93
- targetInfo.endpoint += "/";
105
+ targetInfo.endpoint += methodInfo.appendRequest ? "" : "/";
94
106
  }
95
107
  // See if we already have a qs defined and appending another qs
96
108
  if (methodInfo.url.indexOf("?") == 0 && targetInfo.endpoint.indexOf('?') > 0) {
@@ -29,6 +29,12 @@ var MethodInfo = /** @class */ (function () {
29
29
  enumerable: false,
30
30
  configurable: true
31
31
  });
32
+ Object.defineProperty(MethodInfo.prototype, "appendRequest", {
33
+ // Flag to determine if we are appending the name or adding a "/" to the request url
34
+ get: function () { return this.methodInfo.appendRequest; },
35
+ enumerable: false,
36
+ configurable: true
37
+ });
32
38
  Object.defineProperty(MethodInfo.prototype, "body", {
33
39
  // The data passed through the body of the request
34
40
  get: function () { return this.methodData; },
package/build/v2/sites.js CHANGED
@@ -20,6 +20,6 @@ exports.sites = (function (id, targetInfo) {
20
20
  return sites;
21
21
  });
22
22
  /** Returns the current web. */
23
- exports.sites.getCurrentWeb = function () { return exports.sites().sites(contextInfo_1.ContextInfo.webId); };
23
+ exports.sites.getCurrentWeb = function () { return exports.sites().sites(contextInfo_1.ContextInfo.webId.replace(/^\{|\}$/g, '')); };
24
24
  /** Returns a list by its title from the current web. */
25
25
  exports.sites.getList = function (title) { return exports.sites().lists(title); };
@@ -2125,7 +2125,7 @@ declare module 'gd-sprest/helper/executor' {
2125
2125
  * Executor
2126
2126
  */
2127
2127
  export interface IExecutor {
2128
- <T = any>(methodParams: Array<T>, method: (param: T) => PromiseLike<any> | void, onExecuted?: (...args) => PromiseLike<any> | void): PromiseLike<any>;
2128
+ <T = any>(methodParams: Array<T>, method: (param: T) => PromiseLike<any | undefined> | void, onExecuted?: (...args) => PromiseLike<any | undefined> | void): PromiseLike<any | undefined>;
2129
2129
  }
2130
2130
  }
2131
2131