gd-sprest 7.8.3 → 7.8.5
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.
- package/@types/helper/executor.d.ts +1 -1
- package/build/lib/list.js +41 -30
- package/build/mapper/v2.js +2 -0
- package/build/rest.js +1 -1
- package/build/utils/helper.js +13 -1
- package/build/utils/methodInfo.js +6 -0
- package/build/v2/sites.js +1 -1
- package/dist/gd-sprest.d.ts +1 -1
- package/dist/gd-sprest.js +1 -1
- package/dist/gd-sprest.min.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
@@ -59,6 +59,24 @@ exports.List.getDataAsStream = (function (listFullUrl, parameters) {
|
|
|
59
59
|
});
|
|
60
60
|
// Static method for executing a flow against a list item
|
|
61
61
|
exports.List.runFlow = function (props) {
|
|
62
|
+
// Determine the urls
|
|
63
|
+
var authUrl = "";
|
|
64
|
+
var flowUrl = "";
|
|
65
|
+
switch (props.cloudEnv) {
|
|
66
|
+
case sptypes_1.SPTypes.CloudEnvironment.USL4:
|
|
67
|
+
authUrl = sptypes_1.SPTypes.CloudEnvironment.FlowHigh;
|
|
68
|
+
flowUrl = sptypes_1.SPTypes.CloudEnvironment.FlowHighAPI;
|
|
69
|
+
break;
|
|
70
|
+
case sptypes_1.SPTypes.CloudEnvironment.USL5:
|
|
71
|
+
authUrl = sptypes_1.SPTypes.CloudEnvironment.FlowDoD;
|
|
72
|
+
flowUrl = sptypes_1.SPTypes.CloudEnvironment.FlowDoDAPI;
|
|
73
|
+
break;
|
|
74
|
+
// Default
|
|
75
|
+
default:
|
|
76
|
+
authUrl = sptypes_1.SPTypes.CloudEnvironment.Flow;
|
|
77
|
+
flowUrl = sptypes_1.SPTypes.CloudEnvironment.FlowAPI;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
62
80
|
// Return a promise
|
|
63
81
|
return new Promise(function (resolve) {
|
|
64
82
|
// Gets the graph token
|
|
@@ -66,7 +84,7 @@ exports.List.runFlow = function (props) {
|
|
|
66
84
|
// Return a promise
|
|
67
85
|
return new Promise(function (resolveAuth) {
|
|
68
86
|
// Get the graph token
|
|
69
|
-
graph_1.Graph.getAccessToken(
|
|
87
|
+
graph_1.Graph.getAccessToken(authUrl).execute(function (auth) {
|
|
70
88
|
// Resolve the request
|
|
71
89
|
resolveAuth(auth.access_token);
|
|
72
90
|
},
|
|
@@ -93,36 +111,29 @@ exports.List.runFlow = function (props) {
|
|
|
93
111
|
else {
|
|
94
112
|
// Get the graph token
|
|
95
113
|
getGraphToken().then(function (token) {
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
});
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
114
|
+
// Set the url
|
|
115
|
+
var authUrl = "" + flowUrl + flowInfo.properties.environment.id + "/users/me/onBehalfOfTokenBundle?api-version=2016-11-01";
|
|
116
|
+
// Get the graph token from SharePoint
|
|
117
|
+
new utils_1.Base({
|
|
118
|
+
endpoint: authUrl,
|
|
119
|
+
method: "POST",
|
|
120
|
+
requestType: utils_1.RequestType.GraphPost,
|
|
121
|
+
requestHeader: {
|
|
122
|
+
"authorization": "Bearer " + token
|
|
123
|
+
}
|
|
124
|
+
}).execute(function (tokenInfo) {
|
|
123
125
|
// Resolve the request
|
|
124
|
-
resolveAuth(token);
|
|
125
|
-
}
|
|
126
|
+
resolveAuth(tokenInfo.audienceToToken["https://" + flowInfo.properties.connectionReferences.shared_sharepointonline.swagger.host] || token);
|
|
127
|
+
},
|
|
128
|
+
// Error
|
|
129
|
+
function (ex) {
|
|
130
|
+
// Resolve the request
|
|
131
|
+
resolve({
|
|
132
|
+
executed: false,
|
|
133
|
+
errorDetails: ex.response,
|
|
134
|
+
errorMessage: "Auth Error: Unable to get the flow token for cloud: " + props.cloudEnv
|
|
135
|
+
});
|
|
136
|
+
});
|
|
126
137
|
});
|
|
127
138
|
}
|
|
128
139
|
});
|
package/build/mapper/v2.js
CHANGED
|
@@ -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
package/build/utils/helper.js
CHANGED
|
@@ -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); };
|
package/dist/gd-sprest.d.ts
CHANGED
|
@@ -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
|
|