gd-sprest 9.7.2 → 9.7.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.
- package/@types/utils/base.d.ts +0 -3
- package/build/helper/executor.js +10 -20
- package/build/helper/fieldSchemaXML.js +85 -89
- package/build/helper/index.js +12 -28
- package/build/helper/jslink.js +124 -128
- package/build/helper/listForm.js +109 -118
- package/build/helper/listFormField.js +62 -65
- package/build/helper/methods/addContentEditorWebPart.js +9 -17
- package/build/helper/methods/addPermissionLevel.js +12 -16
- package/build/helper/methods/addScriptEditorWebPart.js +9 -17
- package/build/helper/methods/copyPermissionLevel.js +22 -26
- package/build/helper/methods/createContentType.js +96 -19
- package/build/helper/methods/createDocSet.js +10 -14
- package/build/helper/methods/getCurrentTheme.js +26 -31
- package/build/helper/methods/hasPermissions.js +8 -13
- package/build/helper/methods/index.js +16 -32
- package/build/helper/methods/loadSPCore.js +13 -17
- package/build/helper/methods/parse.js +5 -9
- package/build/helper/methods/request.js +4 -8
- package/build/helper/methods/setContentTypeFields.js +71 -79
- package/build/helper/methods/setGroupOwner.js +6 -10
- package/build/helper/methods/setWebProperty.js +26 -30
- package/build/helper/methods/stringify.js +3 -7
- package/build/helper/methods/webWorker.js +40 -20
- package/build/helper/ribbonLink.js +10 -14
- package/build/helper/sbLink.js +11 -15
- package/build/helper/sp/calloutManager.js +22 -25
- package/build/helper/sp/index.js +13 -16
- package/build/helper/sp/modalDialog.js +32 -35
- package/build/helper/sp/notify.js +9 -12
- package/build/helper/sp/ribbon.js +1 -4
- package/build/helper/sp/sod.js +9 -18
- package/build/helper/sp/status.js +18 -21
- package/build/helper/spCfg.js +232 -259
- package/build/helper/spCfgTypes.js +2 -5
- package/build/helper/taxonomy.js +144 -182
- package/build/helper/webpart.js +110 -94
- package/build/index.js +6 -23
- package/build/lib/apps.js +4 -7
- package/build/lib/contextInfo.js +217 -781
- package/build/lib/directorySession.js +4 -7
- package/build/lib/graph.js +16 -19
- package/build/lib/groupService.js +4 -7
- package/build/lib/groupSiteManager.js +4 -7
- package/build/lib/hubSites.js +11 -25
- package/build/lib/hubSitesUtility.js +4 -7
- package/build/lib/index.js +27 -43
- package/build/lib/list.js +49 -53
- package/build/lib/navigation.js +4 -7
- package/build/lib/peopleManager.js +4 -7
- package/build/lib/peoplePicker.js +4 -7
- package/build/lib/profileLoader.js +4 -7
- package/build/lib/search.js +30 -33
- package/build/lib/sensitivityLabels.js +6 -9
- package/build/lib/site.js +20 -35
- package/build/lib/siteIconManager.js +4 -7
- package/build/lib/siteManager.js +4 -7
- package/build/lib/sitePages.js +37 -51
- package/build/lib/socialFeed.js +13 -16
- package/build/lib/themeManager.js +4 -7
- package/build/lib/userProfile.js +4 -7
- package/build/lib/utility.js +12 -17
- package/build/lib/web.js +34 -49
- package/build/lib/webTemplateExtensions.js +4 -7
- package/build/lib/wfInstanceService.js +4 -7
- package/build/lib/wfSubscriptionService.js +4 -7
- package/build/mapper/custom/audit.js +3 -6
- package/build/mapper/custom/graph.js +13 -16
- package/build/mapper/custom/index.js +8 -24
- package/build/mapper/custom/odata.js +3 -6
- package/build/mapper/custom/old.js +42 -45
- package/build/mapper/custom/peoplePicker.js +4 -7
- package/build/mapper/custom/propertyValues.js +3 -6
- package/build/mapper/custom/utility.js +17 -20
- package/build/mapper/custom/webTemplateExtensions.js +19 -22
- package/build/mapper/def.js +1032 -989
- package/build/mapper/index.js +4 -9
- package/build/mapper/v2.js +2629 -2632
- package/build/rest.js +16 -19
- package/build/sptypes/graphtypes.js +694 -710
- package/build/sptypes/index.js +3 -7
- package/build/sptypes/sptypes.js +49 -52
- package/build/utils/base.js +20 -37
- package/build/utils/batch.js +53 -63
- package/build/utils/helper.js +79 -83
- package/build/utils/index.js +9 -25
- package/build/utils/methodInfo.js +88 -141
- package/build/utils/oData.js +62 -112
- package/build/utils/request.js +137 -155
- package/build/utils/requestType.js +1 -4
- package/build/utils/targetInfo.js +39 -52
- package/build/utils/xhrRequest.js +59 -107
- package/build/v2/drive.js +9 -13
- package/build/v2/drives.js +8 -12
- package/build/v2/index.js +3 -19
- package/build/v2/sites.js +61 -65
- package/dist/gd-sprest.d.ts +0 -3
- package/dist/gd-sprest.js +1 -1
- package/dist/gd-sprest.min.js +1 -1
- package/package.json +2 -2
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.TargetInfo = void 0;
|
|
4
|
-
var lib_1 = require("../lib");
|
|
5
|
-
var _1 = require(".");
|
|
1
|
+
import { ContextInfo } from "../lib";
|
|
2
|
+
import { RequestType } from ".";
|
|
6
3
|
/**
|
|
7
4
|
* Target Information
|
|
8
5
|
*/
|
|
9
|
-
|
|
6
|
+
export class TargetInfo {
|
|
10
7
|
/*********************************************************************************************************************************/
|
|
11
8
|
// Constructor
|
|
12
9
|
/*********************************************************************************************************************************/
|
|
13
|
-
|
|
10
|
+
constructor(props) {
|
|
14
11
|
// Default the properties
|
|
15
12
|
this.props = props || {};
|
|
16
13
|
this.requestData = this.props.data;
|
|
@@ -19,12 +16,12 @@ var TargetInfo = /** @class */ (function () {
|
|
|
19
16
|
// See if this is a graph request
|
|
20
17
|
if (this.isGraph) {
|
|
21
18
|
// Set the request method
|
|
22
|
-
this.requestMethod = this.requestMethod || (this.props.requestType ==
|
|
23
|
-
this.props.requestType ==
|
|
24
|
-
this.props.requestType ==
|
|
25
|
-
this.props.requestType ==
|
|
26
|
-
this.props.requestType ==
|
|
27
|
-
this.props.requestType ==
|
|
19
|
+
this.requestMethod = this.requestMethod || (this.props.requestType == RequestType.Get ||
|
|
20
|
+
this.props.requestType == RequestType.GetReplace ||
|
|
21
|
+
this.props.requestType == RequestType.GetWithArgsValueOnly ||
|
|
22
|
+
this.props.requestType == RequestType.GraphGet ||
|
|
23
|
+
this.props.requestType == RequestType.GraphGetReplace ||
|
|
24
|
+
this.props.requestType == RequestType.OData ? "GET" : "POST");
|
|
28
25
|
// Check the endpoint
|
|
29
26
|
if (this.props.endpoint.indexOf("http") == 0) {
|
|
30
27
|
// Set the request url
|
|
@@ -48,31 +45,23 @@ var TargetInfo = /** @class */ (function () {
|
|
|
48
45
|
this.setRESTRequestUrl();
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var _a, _b;
|
|
61
|
-
return ((_a = this.props.endpoint) === null || _a === void 0 ? void 0 : _a.startsWith("_api/v2.0/")) || ((_b = this.props.url) === null || _b === void 0 ? void 0 : _b.indexOf("_api/v2.0/")) >= 0 ||
|
|
62
|
-
this.props.requestType == _1.RequestType.GraphGet || this.props.requestType == _1.RequestType.GraphPost ||
|
|
63
|
-
this.props.requestType == _1.RequestType.GraphGetReplace || this.props.requestType == _1.RequestType.GraphPostReplace;
|
|
64
|
-
},
|
|
65
|
-
enumerable: false,
|
|
66
|
-
configurable: true
|
|
67
|
-
});
|
|
48
|
+
// Flag to determine if this is a batch request
|
|
49
|
+
get isBatchRequest() { return this.props.endpoint == "$batch"; }
|
|
50
|
+
// Flag to determine if this is a graph request
|
|
51
|
+
get isGraph() {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
return ((_a = this.props.endpoint) === null || _a === void 0 ? void 0 : _a.startsWith("_api/v2.0/")) || ((_b = this.props.url) === null || _b === void 0 ? void 0 : _b.indexOf("_api/v2.0/")) >= 0 ||
|
|
54
|
+
this.props.requestType == RequestType.GraphGet || this.props.requestType == RequestType.GraphPost ||
|
|
55
|
+
this.props.requestType == RequestType.GraphGetReplace || this.props.requestType == RequestType.GraphPostReplace;
|
|
56
|
+
}
|
|
68
57
|
/*********************************************************************************************************************************/
|
|
69
58
|
// Methods
|
|
70
59
|
/*********************************************************************************************************************************/
|
|
71
60
|
// Method to get the domain url
|
|
72
|
-
|
|
73
|
-
|
|
61
|
+
getDomainUrl() {
|
|
62
|
+
let url = ContextInfo.document ? ContextInfo.document.location.href : "";
|
|
74
63
|
// See if this is an app web
|
|
75
|
-
if (
|
|
64
|
+
if (ContextInfo.isAppWeb) {
|
|
76
65
|
// Set the url to the host url
|
|
77
66
|
url = TargetInfo.getQueryStringValue("SPHostUrl") + "";
|
|
78
67
|
}
|
|
@@ -84,11 +73,11 @@ var TargetInfo = /** @class */ (function () {
|
|
|
84
73
|
}
|
|
85
74
|
// Return the url
|
|
86
75
|
return url;
|
|
87
|
-
}
|
|
76
|
+
}
|
|
88
77
|
// Method to get a query string value
|
|
89
|
-
|
|
78
|
+
static getQueryStringValue(key) {
|
|
90
79
|
// Get the query string
|
|
91
|
-
var queryString =
|
|
80
|
+
var queryString = ContextInfo.existsFl && ContextInfo.document ? ContextInfo.document.location.href.split('?') : [""];
|
|
92
81
|
queryString = queryString.length > 1 ? queryString[1] : queryString[0];
|
|
93
82
|
// Parse the values
|
|
94
83
|
var values = queryString.split('&');
|
|
@@ -105,13 +94,13 @@ var TargetInfo = /** @class */ (function () {
|
|
|
105
94
|
}
|
|
106
95
|
// Key was not found
|
|
107
96
|
return null;
|
|
108
|
-
}
|
|
97
|
+
}
|
|
109
98
|
// Method to set the request url for the REST API
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
99
|
+
setRESTRequestUrl() {
|
|
100
|
+
let endpoint = this.props.endpoint ? "/" + this.props.endpoint : "";
|
|
101
|
+
let hostUrl = TargetInfo.getQueryStringValue("SPHostUrl");
|
|
102
|
+
let qs = (endpoint.indexOf("?") === -1 ? "?" : "&") + "@target='{{Target}}'";
|
|
103
|
+
let template = "{{Url}}";
|
|
115
104
|
// See if the template is targeting the _vti_bin
|
|
116
105
|
if (endpoint.indexOf("_vti_bin") >= 0) {
|
|
117
106
|
template += "/{{EndPoint}}{{TargetUrl}}";
|
|
@@ -120,23 +109,23 @@ var TargetInfo = /** @class */ (function () {
|
|
|
120
109
|
template += this.props.endpoint ? "/_api/{{EndPoint}}{{TargetUrl}}" : "";
|
|
121
110
|
}
|
|
122
111
|
// See if we are defaulting the url for the app web
|
|
123
|
-
if (
|
|
112
|
+
if (ContextInfo.existsFl && ContextInfo.window.$REST && ContextInfo.window.$REST.DefaultRequestToHostFl && ContextInfo.isAppWeb && !this.props.overrideDefaultRequestToHostFl && this.props.url == null) {
|
|
124
113
|
// Default the url to the host web
|
|
125
114
|
this.props.url = hostUrl;
|
|
126
115
|
}
|
|
127
116
|
// Ensure the url exists
|
|
128
117
|
if (this.props.url == null) {
|
|
129
118
|
// Default the url to the current site/web url
|
|
130
|
-
this.props.url = this.props.defaultToWebFl == false ?
|
|
119
|
+
this.props.url = this.props.defaultToWebFl == false ? ContextInfo.siteAbsoluteUrl : ContextInfo.webAbsoluteUrl;
|
|
131
120
|
}
|
|
132
121
|
// Else, see if the url already contains the full request
|
|
133
122
|
else if (/\/_api\//.test(this.props.url)) {
|
|
134
123
|
// Get the url
|
|
135
124
|
var url = this.props.url.toLowerCase().split("/_api/");
|
|
136
125
|
// See if this is the app web and we are executing against a different web
|
|
137
|
-
if (
|
|
126
|
+
if (ContextInfo.isAppWeb && url[0] != ContextInfo.webAbsoluteUrl.toLowerCase()) {
|
|
138
127
|
// Set the request url
|
|
139
|
-
this.requestUrl =
|
|
128
|
+
this.requestUrl = ContextInfo.webAbsoluteUrl + "/_api/SP.AppContextSite(@target)/" +
|
|
140
129
|
url[1] + endpoint + qs.replace(/{{Target}}/g, url[0]);
|
|
141
130
|
}
|
|
142
131
|
else {
|
|
@@ -151,10 +140,10 @@ var TargetInfo = /** @class */ (function () {
|
|
|
151
140
|
this.props.url = this.getDomainUrl() + this.props.url;
|
|
152
141
|
}
|
|
153
142
|
// See if this is the app web, and we are executing against a different web
|
|
154
|
-
if (
|
|
143
|
+
if (ContextInfo.isAppWeb && this.props.url != ContextInfo.webAbsoluteUrl) {
|
|
155
144
|
// Set the request url
|
|
156
145
|
this.requestUrl = template
|
|
157
|
-
.replace(/{{Url}}/g,
|
|
146
|
+
.replace(/{{Url}}/g, ContextInfo.webAbsoluteUrl)
|
|
158
147
|
.replace(/{{EndPoint}}/g, "SP.AppContextSite(@target)" + endpoint)
|
|
159
148
|
.replace(/{{TargetUrl}}/g, qs.replace(/{{Target}}/g, this.props.url));
|
|
160
149
|
}
|
|
@@ -165,7 +154,5 @@ var TargetInfo = /** @class */ (function () {
|
|
|
165
154
|
.replace(/{{EndPoint}}/g, this.props.endpoint)
|
|
166
155
|
.replace(/{{TargetUrl}}/g, "");
|
|
167
156
|
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
}());
|
|
171
|
-
exports.TargetInfo = TargetInfo;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.XHRRequest = void 0;
|
|
4
|
-
var lib_1 = require("../lib");
|
|
1
|
+
import { ContextInfo, Graph } from "../lib";
|
|
5
2
|
/**
|
|
6
3
|
* XML HTTP Request Class
|
|
7
4
|
*/
|
|
8
|
-
|
|
5
|
+
export class XHRRequest {
|
|
9
6
|
/*********************************************************************************************************************************/
|
|
10
7
|
// Constructor
|
|
11
8
|
/*********************************************************************************************************************************/
|
|
12
|
-
|
|
13
|
-
if (executeFl === void 0) { executeFl = true; }
|
|
9
|
+
constructor(asyncFl, targetInfo, callback, executeFl = true) {
|
|
14
10
|
// Default the properties
|
|
15
11
|
this.asyncFl = asyncFl;
|
|
16
12
|
this.executeFl = executeFl;
|
|
@@ -28,82 +24,42 @@ var XHRRequest = /** @class */ (function () {
|
|
|
28
24
|
this.defaultHeaders();
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
configurable: true
|
|
63
|
-
});
|
|
64
|
-
Object.defineProperty(XHRRequest.prototype, "requestData", {
|
|
65
|
-
// The data send in the body of the request
|
|
66
|
-
get: function () { return this.targetInfo.requestData; },
|
|
67
|
-
enumerable: false,
|
|
68
|
-
configurable: true
|
|
69
|
-
});
|
|
70
|
-
Object.defineProperty(XHRRequest.prototype, "requestHeaders", {
|
|
71
|
-
// The request headers
|
|
72
|
-
get: function () { return this.headers; },
|
|
73
|
-
enumerable: false,
|
|
74
|
-
configurable: true
|
|
75
|
-
});
|
|
76
|
-
Object.defineProperty(XHRRequest.prototype, "requestInfo", {
|
|
77
|
-
// The request information
|
|
78
|
-
get: function () {
|
|
79
|
-
// Return the request information
|
|
80
|
-
return {
|
|
81
|
-
data: this.targetInfo.requestData,
|
|
82
|
-
headers: this.headers,
|
|
83
|
-
method: this.targetInfo.requestMethod,
|
|
84
|
-
url: this.targetInfo.requestUrl
|
|
85
|
-
};
|
|
86
|
-
},
|
|
87
|
-
enumerable: false,
|
|
88
|
-
configurable: true
|
|
89
|
-
});
|
|
90
|
-
Object.defineProperty(XHRRequest.prototype, "requestUrl", {
|
|
91
|
-
// The request url
|
|
92
|
-
get: function () { return this.xhr ? this.xhr.responseURL : null; },
|
|
93
|
-
enumerable: false,
|
|
94
|
-
configurable: true
|
|
95
|
-
});
|
|
96
|
-
Object.defineProperty(XHRRequest.prototype, "status", {
|
|
97
|
-
// The request status
|
|
98
|
-
get: function () { return this.xhr ? this.xhr.status : null; },
|
|
99
|
-
enumerable: false,
|
|
100
|
-
configurable: true
|
|
101
|
-
});
|
|
27
|
+
/*********************************************************************************************************************************/
|
|
28
|
+
// Public Properties
|
|
29
|
+
/*********************************************************************************************************************************/
|
|
30
|
+
// Flag indicating if this is a batch request
|
|
31
|
+
get isBatch() { return this.targetInfo.isBatchRequest; }
|
|
32
|
+
// Flag indicating if this is a graph request
|
|
33
|
+
get isGraph() { return this.targetInfo.isGraph; }
|
|
34
|
+
// Flag indicating the request has completed
|
|
35
|
+
get completedFl() { return this.xhr ? this.xhr.readyState == 4 : false; }
|
|
36
|
+
// The response
|
|
37
|
+
get response() { return this.xhr ? this.xhr.response : null; }
|
|
38
|
+
// The xml http request
|
|
39
|
+
get request() { return this.xhr ? this.xhr : null; }
|
|
40
|
+
// The data send in the body of the request
|
|
41
|
+
get requestData() { return this.targetInfo.requestData; }
|
|
42
|
+
// The request headers
|
|
43
|
+
get requestHeaders() { return this.headers; }
|
|
44
|
+
// The request information
|
|
45
|
+
get requestInfo() {
|
|
46
|
+
// Return the request information
|
|
47
|
+
return {
|
|
48
|
+
data: this.targetInfo.requestData,
|
|
49
|
+
headers: this.headers,
|
|
50
|
+
method: this.targetInfo.requestMethod,
|
|
51
|
+
url: this.targetInfo.requestUrl
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// The request url
|
|
55
|
+
get requestUrl() { return this.xhr ? this.xhr.responseURL : null; }
|
|
56
|
+
// The request status
|
|
57
|
+
get status() { return this.xhr ? this.xhr.status : null; }
|
|
102
58
|
/*********************************************************************************************************************************/
|
|
103
59
|
// Private Methods
|
|
104
60
|
/*********************************************************************************************************************************/
|
|
105
61
|
// Method to create the xml http request
|
|
106
|
-
|
|
62
|
+
createXHR() {
|
|
107
63
|
// See if the generic object doesn't exist
|
|
108
64
|
if (typeof (XMLHttpRequest) !== "undefined") {
|
|
109
65
|
// Create an instance of the xml http request object
|
|
@@ -126,10 +82,10 @@ var XHRRequest = /** @class */ (function () {
|
|
|
126
82
|
catch (e) { }
|
|
127
83
|
// Log an error
|
|
128
84
|
console.error("This browser does not support xml http requests.");
|
|
129
|
-
}
|
|
85
|
+
}
|
|
130
86
|
// Method to default the request headers
|
|
131
|
-
|
|
132
|
-
|
|
87
|
+
defaultHeaders(requestDigest) {
|
|
88
|
+
let ifMatchExists = false;
|
|
133
89
|
// See if the custom headers exist
|
|
134
90
|
if (this.targetInfo.requestHeaders) {
|
|
135
91
|
// Parse the custom headers
|
|
@@ -167,7 +123,7 @@ var XHRRequest = /** @class */ (function () {
|
|
|
167
123
|
// See if this is a graph request
|
|
168
124
|
if (this.targetInfo.isGraph) {
|
|
169
125
|
// Ensure the access token exists
|
|
170
|
-
|
|
126
|
+
let accessToken = this.targetInfo.props.accessToken || Graph.Token;
|
|
171
127
|
if (accessToken) {
|
|
172
128
|
// Set the authorization
|
|
173
129
|
this.xhr ? this.xhr.setRequestHeader("Authorization", "bearer " + accessToken) : null;
|
|
@@ -196,16 +152,15 @@ var XHRRequest = /** @class */ (function () {
|
|
|
196
152
|
this.headers["IF-MATCH"] = "*";
|
|
197
153
|
}
|
|
198
154
|
}
|
|
199
|
-
}
|
|
155
|
+
}
|
|
200
156
|
// Method to execute the xml http request
|
|
201
|
-
|
|
202
|
-
var _this = this;
|
|
157
|
+
execute() {
|
|
203
158
|
// Set the request digest
|
|
204
|
-
|
|
159
|
+
let requestDigest = this.targetInfo.props.requestDigest || "";
|
|
205
160
|
if (requestDigest == "") {
|
|
206
161
|
// Set the request digest
|
|
207
|
-
requestDigest = requestDigest ? requestDigest.value :
|
|
208
|
-
requestDigest = requestDigest ? requestDigest : (
|
|
162
|
+
requestDigest = requestDigest ? requestDigest.value : ContextInfo.formDigestValue;
|
|
163
|
+
requestDigest = requestDigest ? requestDigest : (ContextInfo.document ? ContextInfo.document.querySelector("#__REQUESTDIGEST") : "");
|
|
209
164
|
}
|
|
210
165
|
// See if we are targeting the context endpoint
|
|
211
166
|
if (this.targetInfo.props.endpoint == "contextinfo") {
|
|
@@ -221,9 +176,9 @@ var XHRRequest = /** @class */ (function () {
|
|
|
221
176
|
}
|
|
222
177
|
else {
|
|
223
178
|
// Get the context information
|
|
224
|
-
|
|
179
|
+
ContextInfo.getWeb(this.targetInfo.props.url || document.location.pathname.substr(0, document.location.pathname.lastIndexOf('/'))).execute(contextInfo => {
|
|
225
180
|
// Execute the request
|
|
226
|
-
|
|
181
|
+
this.executeRequest(contextInfo.GetContextWebInformation.FormDigestValue);
|
|
227
182
|
});
|
|
228
183
|
}
|
|
229
184
|
}
|
|
@@ -231,10 +186,9 @@ var XHRRequest = /** @class */ (function () {
|
|
|
231
186
|
// Execute the request
|
|
232
187
|
this.executeRequest(requestDigest);
|
|
233
188
|
}
|
|
234
|
-
}
|
|
189
|
+
}
|
|
235
190
|
// Method to execute the xml http request
|
|
236
|
-
|
|
237
|
-
var _this = this;
|
|
191
|
+
executeRequest(requestDigest) {
|
|
238
192
|
// Ensure the xml http request exists
|
|
239
193
|
if (this.xhr == null) {
|
|
240
194
|
return null;
|
|
@@ -249,11 +203,11 @@ var XHRRequest = /** @class */ (function () {
|
|
|
249
203
|
// See if we are making an asynchronous request
|
|
250
204
|
if (this.asyncFl) {
|
|
251
205
|
// Set the state change event
|
|
252
|
-
this.xhr.onreadystatechange =
|
|
206
|
+
this.xhr.onreadystatechange = () => {
|
|
253
207
|
// See if the request has finished
|
|
254
|
-
if (
|
|
208
|
+
if (this.xhr.readyState == 4) {
|
|
255
209
|
// Execute the request completed event
|
|
256
|
-
|
|
210
|
+
this.onRequestCompleted ? this.onRequestCompleted(this) : null;
|
|
257
211
|
}
|
|
258
212
|
};
|
|
259
213
|
}
|
|
@@ -282,16 +236,16 @@ var XHRRequest = /** @class */ (function () {
|
|
|
282
236
|
headers: this.headers,
|
|
283
237
|
keepalive: true,
|
|
284
238
|
method: this.isGraph ? this.targetInfo.requestMethod : (this.targetInfo.requestMethod == "GET" ? "GET" : "POST")
|
|
285
|
-
}).then(
|
|
239
|
+
}).then(response => {
|
|
286
240
|
// Set the xhr object
|
|
287
|
-
|
|
241
|
+
this.xhr = response;
|
|
288
242
|
// Return the response
|
|
289
|
-
return (
|
|
290
|
-
}).then(
|
|
243
|
+
return (this.targetInfo.props.bufferFl ? response.arrayBuffer() : response.text());
|
|
244
|
+
}).then(response => {
|
|
291
245
|
// Set the xhr response
|
|
292
|
-
|
|
246
|
+
this.xhr.response = response;
|
|
293
247
|
// Execute the request completed event
|
|
294
|
-
|
|
248
|
+
this.onRequestCompleted ? this.onRequestCompleted(this) : null;
|
|
295
249
|
});
|
|
296
250
|
}
|
|
297
251
|
else {
|
|
@@ -299,7 +253,5 @@ var XHRRequest = /** @class */ (function () {
|
|
|
299
253
|
this.targetInfo.props.bufferFl || this.targetInfo.requestData == null ? this.xhr.send() : this.xhr.send(this.targetInfo.requestData);
|
|
300
254
|
}
|
|
301
255
|
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
}());
|
|
305
|
-
exports.XHRRequest = XHRRequest;
|
|
256
|
+
}
|
|
257
|
+
}
|
package/build/v2/drive.js
CHANGED
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.drive = void 0;
|
|
4
|
-
var contextInfo_1 = require("../lib/contextInfo");
|
|
5
|
-
var utils_1 = require("../utils");
|
|
1
|
+
import { ContextInfo } from "../lib/contextInfo";
|
|
2
|
+
import { Base, Request, RequestType } from "../utils";
|
|
6
3
|
/**
|
|
7
4
|
* Drive
|
|
8
5
|
* Returns the default library for a site.
|
|
9
6
|
*/
|
|
10
|
-
|
|
7
|
+
export const drive = ((props = {}) => {
|
|
11
8
|
var _a;
|
|
12
|
-
|
|
13
|
-
var drive = new utils_1.Base(props.targetInfo);
|
|
9
|
+
let drive = new Base(props.targetInfo);
|
|
14
10
|
// Default the properties
|
|
15
11
|
drive.targetInfo.defaultToWebFl = true;
|
|
16
|
-
drive.targetInfo.requestType =
|
|
12
|
+
drive.targetInfo.requestType = RequestType.GraphGet;
|
|
17
13
|
// Default the url
|
|
18
|
-
drive.targetInfo.url = props.siteUrl || ((_a = props === null || props === void 0 ? void 0 : props.targetInfo) === null || _a === void 0 ? void 0 : _a.url) ||
|
|
14
|
+
drive.targetInfo.url = props.siteUrl || ((_a = props === null || props === void 0 ? void 0 : props.targetInfo) === null || _a === void 0 ? void 0 : _a.url) || ContextInfo.webServerRelativeUrl;
|
|
19
15
|
// See if an endpoint is not defined
|
|
20
16
|
if (drive.targetInfo.endpoint == undefined) {
|
|
21
17
|
if (props.driveId) {
|
|
22
18
|
// Set the endpoint
|
|
23
|
-
drive.targetInfo.endpoint =
|
|
19
|
+
drive.targetInfo.endpoint = `_api/v2.0/${props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') + (props.webId ? "," + props.webId.replace(/^\{|\}$/g, '') : "") + "/" : ""}drives/${props.driveId}`;
|
|
24
20
|
}
|
|
25
21
|
else {
|
|
26
22
|
// Default the endpoint
|
|
27
|
-
drive.targetInfo.endpoint =
|
|
23
|
+
drive.targetInfo.endpoint = `_api/v2.0/${props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') + (props.webId ? "," + props.webId.replace(/^\{|\}$/g, '') : "") + "/" : ""}drive`;
|
|
28
24
|
}
|
|
29
25
|
// Add the methods
|
|
30
|
-
|
|
26
|
+
Request.addMethods(drive, { __metadata: { type: "@odata.context/_api/v2.0/$metadata#drive" } });
|
|
31
27
|
}
|
|
32
28
|
// Return the default library
|
|
33
29
|
return drive;
|
package/build/v2/drives.js
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.drives = void 0;
|
|
4
|
-
var contextInfo_1 = require("../lib/contextInfo");
|
|
5
|
-
var utils_1 = require("../utils");
|
|
1
|
+
import { ContextInfo } from "../lib/contextInfo";
|
|
2
|
+
import { Base, Request, RequestType } from "../utils";
|
|
6
3
|
/**
|
|
7
4
|
* Drives
|
|
8
5
|
* Returns the libraries for a site.
|
|
9
6
|
*/
|
|
10
|
-
|
|
7
|
+
export const drives = ((props = {}) => {
|
|
11
8
|
var _a;
|
|
12
|
-
|
|
13
|
-
var drives = new utils_1.Base(props.targetInfo);
|
|
9
|
+
let drives = new Base(props.targetInfo);
|
|
14
10
|
// Default the properties
|
|
15
11
|
drives.targetInfo.defaultToWebFl = true;
|
|
16
|
-
drives.targetInfo.requestType =
|
|
12
|
+
drives.targetInfo.requestType = RequestType.GraphGet;
|
|
17
13
|
// Default the url
|
|
18
|
-
drives.targetInfo.url = props.siteUrl || ((_a = props === null || props === void 0 ? void 0 : props.targetInfo) === null || _a === void 0 ? void 0 : _a.url) ||
|
|
14
|
+
drives.targetInfo.url = props.siteUrl || ((_a = props === null || props === void 0 ? void 0 : props.targetInfo) === null || _a === void 0 ? void 0 : _a.url) || ContextInfo.webServerRelativeUrl;
|
|
19
15
|
// See if an endpoint is not defined
|
|
20
16
|
if (drives.targetInfo.endpoint == undefined) {
|
|
21
17
|
// Default the endpoint
|
|
22
|
-
drives.targetInfo.endpoint =
|
|
18
|
+
drives.targetInfo.endpoint = `_api/v2.0/${props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') + (props.webId ? "," + props.webId.replace(/^\{|\}$/g, '') : "") + "/" : ""}drives`;
|
|
23
19
|
// Add the methods
|
|
24
|
-
|
|
20
|
+
Request.addMethods(drives, { __metadata: { type: "@odata.context/_api/v2.0/$metadata#drives" } });
|
|
25
21
|
}
|
|
26
22
|
// Return the libraries
|
|
27
23
|
return drives;
|
package/build/v2/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./drive"), exports);
|
|
18
|
-
__exportStar(require("./drives"), exports);
|
|
19
|
-
__exportStar(require("./sites"), exports);
|
|
1
|
+
export * from "./drive";
|
|
2
|
+
export * from "./drives";
|
|
3
|
+
export * from "./sites";
|