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
package/build/lib/search.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Search = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
1
|
+
import { Base, Request, RequestType } from "../utils";
|
|
5
2
|
/**
|
|
6
3
|
* Search
|
|
7
4
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export const Search = ((url, targetInfo) => {
|
|
6
|
+
let base = new Base(targetInfo);
|
|
7
|
+
let search = base;
|
|
11
8
|
// Default the properties
|
|
12
9
|
base.targetInfo.defaultToWebFl = true;
|
|
13
10
|
base.targetInfo.endpoint = "search";
|
|
@@ -17,24 +14,24 @@ exports.Search = (function (url, targetInfo) {
|
|
|
17
14
|
base.targetInfo.url = url;
|
|
18
15
|
}
|
|
19
16
|
// Add the methods
|
|
20
|
-
|
|
17
|
+
Request.addMethods(search, { __metadata: { type: "Microsoft.Office.Server.Search.REST.SearchService" } });
|
|
21
18
|
/** The search query method */
|
|
22
|
-
search.searchquery =
|
|
19
|
+
search.searchquery = (settings) => {
|
|
23
20
|
// Execute the request
|
|
24
21
|
return search.executeMethod("query", {
|
|
25
22
|
argNames: ["query"],
|
|
26
23
|
name: "query?[[query]]",
|
|
27
|
-
requestType:
|
|
28
|
-
},
|
|
24
|
+
requestType: RequestType.GetReplace
|
|
25
|
+
}, Search.getQuery(settings));
|
|
29
26
|
};
|
|
30
27
|
// Return the search
|
|
31
28
|
return search;
|
|
32
29
|
});
|
|
33
30
|
// Static method to compute the query
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
Search.getQuery = (parameters) => {
|
|
32
|
+
let query = "";
|
|
36
33
|
// Parse the parameters
|
|
37
|
-
for (
|
|
34
|
+
for (let key in parameters) {
|
|
38
35
|
// Append the parameter to the query
|
|
39
36
|
query += (query == "" ? "" : "&") + key + "='" + parameters[key] + "'";
|
|
40
37
|
}
|
|
@@ -42,14 +39,14 @@ exports.Search.getQuery = function (parameters) {
|
|
|
42
39
|
return [query];
|
|
43
40
|
};
|
|
44
41
|
// Static post query method
|
|
45
|
-
|
|
42
|
+
Search.postQuery = (props) => {
|
|
46
43
|
// Return a promise
|
|
47
|
-
return new Promise(
|
|
48
|
-
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
let queryProps = props.query;
|
|
49
46
|
// Set the get all items flag
|
|
50
|
-
|
|
47
|
+
let getAllItems = typeof (props.getAllItems) === "boolean" ? props.getAllItems : false;
|
|
51
48
|
// Compute the row count
|
|
52
|
-
|
|
49
|
+
let rowCount = 500;
|
|
53
50
|
if (typeof (queryProps.RowLimit) === "number") {
|
|
54
51
|
// Set the custom limit
|
|
55
52
|
rowCount = queryProps.RowLimit;
|
|
@@ -59,18 +56,18 @@ exports.Search.postQuery = function (props) {
|
|
|
59
56
|
queryProps.RowLimit = rowCount;
|
|
60
57
|
}
|
|
61
58
|
// Query the first batch
|
|
62
|
-
|
|
59
|
+
Search(props.url, props.targetInfo).postquery(queryProps).execute(
|
|
63
60
|
// Success
|
|
64
|
-
|
|
61
|
+
request => {
|
|
65
62
|
// Updates the table
|
|
66
|
-
|
|
63
|
+
let updateRequest = (searchResult) => {
|
|
67
64
|
// Ensure the results exist
|
|
68
65
|
if (searchResult) {
|
|
69
66
|
// Call the event
|
|
70
67
|
props.onQueryCompleted ? props.onQueryCompleted(searchResult) : null;
|
|
71
68
|
// Parse rows
|
|
72
|
-
for (
|
|
73
|
-
|
|
69
|
+
for (let i = 0; i < searchResult.PrimaryQueryResult.RelevantResults.Table.Rows.results.length; i++) {
|
|
70
|
+
let row = searchResult.PrimaryQueryResult.RelevantResults.Table.Rows.results[i];
|
|
74
71
|
// Append the result
|
|
75
72
|
request.postquery.PrimaryQueryResult.RelevantResults.Table.Rows.results.push(row);
|
|
76
73
|
}
|
|
@@ -81,14 +78,14 @@ exports.Search.postQuery = function (props) {
|
|
|
81
78
|
// Call the event
|
|
82
79
|
props.onQueryCompleted ? props.onQueryCompleted(request.postquery) : null;
|
|
83
80
|
// See if more results exist
|
|
84
|
-
|
|
81
|
+
let results = request.postquery.PrimaryQueryResult.RelevantResults;
|
|
85
82
|
if (getAllItems && results.TotalRows > results.RowCount) {
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
let search = Search(props.url, props.targetInfo);
|
|
84
|
+
let useBatch = typeof (props.useBatch) === "boolean" ? props.useBatch : true;
|
|
88
85
|
// Compute the total # of requests that we need to make
|
|
89
|
-
|
|
86
|
+
let totalPages = Math.ceil(results.TotalRows / rowCount);
|
|
90
87
|
// Loop for the total # of requests
|
|
91
|
-
for (
|
|
88
|
+
for (let i = 1; i < totalPages; i++) {
|
|
92
89
|
// Set the start row
|
|
93
90
|
queryProps.StartRow = i * rowCount;
|
|
94
91
|
// See if we are making a batch request
|
|
@@ -96,7 +93,7 @@ exports.Search.postQuery = function (props) {
|
|
|
96
93
|
// Create a batch request
|
|
97
94
|
search.postquery(queryProps).batch(
|
|
98
95
|
// Success
|
|
99
|
-
|
|
96
|
+
batchRequest => {
|
|
100
97
|
// Update the request
|
|
101
98
|
updateRequest(batchRequest.postquery);
|
|
102
99
|
},
|
|
@@ -107,7 +104,7 @@ exports.Search.postQuery = function (props) {
|
|
|
107
104
|
// Create the request
|
|
108
105
|
search.postquery(queryProps).execute(
|
|
109
106
|
// Success
|
|
110
|
-
|
|
107
|
+
batchRequest => {
|
|
111
108
|
// Update the request
|
|
112
109
|
updateRequest(batchRequest.postquery);
|
|
113
110
|
},
|
|
@@ -118,14 +115,14 @@ exports.Search.postQuery = function (props) {
|
|
|
118
115
|
// See if we are making a batch request
|
|
119
116
|
if (useBatch) {
|
|
120
117
|
// Execute the batch requests
|
|
121
|
-
search.execute(
|
|
118
|
+
search.execute(() => {
|
|
122
119
|
// Resolve the request
|
|
123
120
|
resolve(request.postquery);
|
|
124
121
|
}, reject);
|
|
125
122
|
}
|
|
126
123
|
else {
|
|
127
124
|
// Wait for the requests to complete
|
|
128
|
-
search.done(
|
|
125
|
+
search.done(() => {
|
|
129
126
|
// Resolve the request
|
|
130
127
|
resolve(request.postquery);
|
|
131
128
|
});
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SensitivityLabels = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
1
|
+
import { Base, Request } from "../utils";
|
|
5
2
|
/**
|
|
6
3
|
* Sensitivity Labels
|
|
7
4
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export const SensitivityLabels = ((targetInfo) => {
|
|
6
|
+
let sensitivityLabels = new Base(targetInfo);
|
|
10
7
|
// Default the properties
|
|
11
8
|
sensitivityLabels.targetInfo.defaultToWebFl = true;
|
|
12
9
|
sensitivityLabels.targetInfo.endpoint = "sp.sensitivitylabelcollection";
|
|
13
10
|
// Add the methods
|
|
14
|
-
|
|
11
|
+
Request.addMethods(sensitivityLabels, { __metadata: { type: "SP.SensitivityLabelCollection" } });
|
|
15
12
|
// Return the sensitivity labels
|
|
16
13
|
return sensitivityLabels;
|
|
17
14
|
});
|
|
18
|
-
|
|
15
|
+
SensitivityLabels.getLabelsForUser = () => {
|
|
19
16
|
// Call the method w/ default parameters
|
|
20
|
-
return
|
|
17
|
+
return SensitivityLabels().getSensitivityLabelsAsStream("sensitivityPolicySettings,sublabels($expand=sensitivityPolicySettings)", "applicableto has ''file''");
|
|
21
18
|
};
|
package/build/lib/site.js
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.Site = void 0;
|
|
15
|
-
var utils_1 = require("../utils");
|
|
16
|
-
var contextInfo_1 = require("./contextInfo");
|
|
17
|
-
var graph_1 = require("./graph");
|
|
1
|
+
import { Base, Request } from "../utils";
|
|
2
|
+
import { ContextInfo } from "./contextInfo";
|
|
3
|
+
import { Graph } from "./graph";
|
|
18
4
|
/**
|
|
19
5
|
* Site
|
|
20
6
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
export const Site = ((url, targetInfo) => {
|
|
8
|
+
let site = new Base(targetInfo);
|
|
23
9
|
// Default the properties
|
|
24
10
|
site.targetInfo.defaultToWebFl = true;
|
|
25
11
|
site.targetInfo.endpoint = "site";
|
|
@@ -29,50 +15,49 @@ exports.Site = (function (url, targetInfo) {
|
|
|
29
15
|
site.targetInfo.url = url;
|
|
30
16
|
}
|
|
31
17
|
// Add the methods
|
|
32
|
-
|
|
18
|
+
Request.addMethods(site, { __metadata: { type: "SP.Site" } });
|
|
33
19
|
// Return the site
|
|
34
20
|
return site;
|
|
35
21
|
});
|
|
36
22
|
// Static method to see if a site exists
|
|
37
|
-
|
|
23
|
+
Site.exists = ((url) => {
|
|
38
24
|
// Return the base object
|
|
39
|
-
return new
|
|
40
|
-
data: { url
|
|
25
|
+
return new Base({
|
|
26
|
+
data: { url },
|
|
41
27
|
defaultToWebFl: true,
|
|
42
28
|
endpoint: "SP.Site.Exists",
|
|
43
29
|
method: "POST"
|
|
44
30
|
});
|
|
45
31
|
});
|
|
46
32
|
// Static method to get the app context
|
|
47
|
-
|
|
33
|
+
Site.getAppContext = ((siteUrl) => {
|
|
48
34
|
// Return the base object
|
|
49
|
-
return new
|
|
50
|
-
data: { siteUrl
|
|
35
|
+
return new Base({
|
|
36
|
+
data: { siteUrl },
|
|
51
37
|
defaultToWebFl: true,
|
|
52
38
|
endpoint: "SP.AppContextSite",
|
|
53
39
|
method: "POST"
|
|
54
40
|
});
|
|
55
41
|
});
|
|
56
42
|
// Method to get the onedive web for the current user
|
|
57
|
-
|
|
58
|
-
if (targetInfo === void 0) { targetInfo = {}; }
|
|
43
|
+
Site.getOneDrive = (targetInfo = {}) => {
|
|
59
44
|
// Set the url of the drive
|
|
60
|
-
|
|
61
|
-
|
|
45
|
+
let host = document.location.host.split('.');
|
|
46
|
+
let url = `https://${host[0]}-my.${host[1]}.${host[2]}/personal/${ContextInfo.userPrincipalName.replace(/[@,.]/g, '_')}`;
|
|
62
47
|
// Return the web for the user's onedrive
|
|
63
|
-
return
|
|
48
|
+
return Site(url, Object.assign(Object.assign({}, targetInfo), {
|
|
64
49
|
requestHeader: {
|
|
65
|
-
Authorization: "Bearer " +
|
|
50
|
+
Authorization: "Bearer " + Graph.Token,
|
|
66
51
|
Accept: "application/json",
|
|
67
52
|
"Content-Type": "application/json"
|
|
68
53
|
}
|
|
69
54
|
}));
|
|
70
55
|
};
|
|
71
56
|
// Method to get the url by id
|
|
72
|
-
|
|
57
|
+
Site.getUrlById = ((id) => {
|
|
73
58
|
// Return the base object
|
|
74
|
-
return new
|
|
75
|
-
data: { id
|
|
59
|
+
return new Base({
|
|
60
|
+
data: { id },
|
|
76
61
|
defaultToWebFl: true,
|
|
77
62
|
endpoint: "SP.Site.GetUrlById",
|
|
78
63
|
method: "POST"
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SiteIconManager = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
1
|
+
import { Base, Request } from "../utils";
|
|
5
2
|
/**
|
|
6
3
|
* Site Icon Manager
|
|
7
4
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export const SiteIconManager = ((url, targetInfo) => {
|
|
6
|
+
let siteIconMgr = new Base(targetInfo);
|
|
10
7
|
// Default the properties
|
|
11
8
|
siteIconMgr.targetInfo.defaultToWebFl = true;
|
|
12
9
|
siteIconMgr.targetInfo.endpoint = "SiteIconManager";
|
|
@@ -16,7 +13,7 @@ exports.SiteIconManager = (function (url, targetInfo) {
|
|
|
16
13
|
siteIconMgr.targetInfo.url = url;
|
|
17
14
|
}
|
|
18
15
|
// Add the methods
|
|
19
|
-
|
|
16
|
+
Request.addMethods(siteIconMgr, { __metadata: { type: "Microsoft.SharePoint.Portal.SiteIconManager" } });
|
|
20
17
|
// Return the site
|
|
21
18
|
return siteIconMgr;
|
|
22
19
|
});
|
package/build/lib/siteManager.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SiteManager = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
1
|
+
import { Base, Request } from "../utils";
|
|
5
2
|
/**
|
|
6
3
|
* Site Manager
|
|
7
4
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export const SiteManager = ((url, targetInfo) => {
|
|
6
|
+
let siteMgr = new Base(targetInfo);
|
|
10
7
|
// Default the properties
|
|
11
8
|
siteMgr.targetInfo.defaultToWebFl = true;
|
|
12
9
|
siteMgr.targetInfo.endpoint = "SPSiteManager";
|
|
@@ -16,7 +13,7 @@ exports.SiteManager = (function (url, targetInfo) {
|
|
|
16
13
|
siteMgr.targetInfo.url = url;
|
|
17
14
|
}
|
|
18
15
|
// Add the methods
|
|
19
|
-
|
|
16
|
+
Request.addMethods(siteMgr, { __metadata: { type: "Microsoft.SharePoint.Portal.SPSiteManager" } });
|
|
20
17
|
// Return the site
|
|
21
18
|
return siteMgr;
|
|
22
19
|
});
|
package/build/lib/sitePages.js
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.SitePages = void 0;
|
|
15
|
-
var web_1 = require("./web");
|
|
16
|
-
var utils_1 = require("../utils");
|
|
17
|
-
var contextInfo_1 = require("./contextInfo");
|
|
1
|
+
import { Web } from "./web";
|
|
2
|
+
import { Base, Request } from "../utils";
|
|
3
|
+
import { ContextInfo } from "./contextInfo";
|
|
18
4
|
/**
|
|
19
5
|
* Site Pages
|
|
20
6
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
export const SitePages = ((url, targetInfo) => {
|
|
8
|
+
let sitePages = new Base(targetInfo);
|
|
23
9
|
// Default the properties
|
|
24
10
|
sitePages.targetInfo.defaultToWebFl = true;
|
|
25
11
|
sitePages.targetInfo.endpoint = "SitePages";
|
|
@@ -29,28 +15,28 @@ exports.SitePages = (function (url, targetInfo) {
|
|
|
29
15
|
sitePages.targetInfo.url = url;
|
|
30
16
|
}
|
|
31
17
|
// Add the methods
|
|
32
|
-
|
|
18
|
+
Request.addMethods(sitePages, { __metadata: { type: "SP.Publishing.SitePageService" } });
|
|
33
19
|
// Return the site pages
|
|
34
20
|
return sitePages;
|
|
35
21
|
});
|
|
36
22
|
// Static method to convert a modern page type
|
|
37
|
-
|
|
23
|
+
SitePages.convertPage = (pageUrl, layout, webUrl) => {
|
|
38
24
|
// Return a promise
|
|
39
|
-
return new Promise(
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
40
26
|
// Get the page
|
|
41
|
-
|
|
27
|
+
let getPage = (pageUrl) => {
|
|
42
28
|
// Return a promise
|
|
43
|
-
return new Promise(
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
44
30
|
// See if the web url is specified
|
|
45
31
|
if (webUrl) {
|
|
46
32
|
// Get the context info
|
|
47
|
-
|
|
33
|
+
ContextInfo.getWeb(webUrl).execute(context => {
|
|
48
34
|
// Get the page
|
|
49
|
-
|
|
35
|
+
Web(webUrl, {
|
|
50
36
|
requestDigest: context.GetContextWebInformation.FormDigestValue
|
|
51
37
|
}).Lists("Site Pages").Items().query({
|
|
52
38
|
Filter: "FileLeafRef eq '" + pageUrl + "'"
|
|
53
|
-
}).execute(
|
|
39
|
+
}).execute(items => {
|
|
54
40
|
// Resolve the request
|
|
55
41
|
resolve(items.results[0]);
|
|
56
42
|
}, reject);
|
|
@@ -58,9 +44,9 @@ exports.SitePages.convertPage = function (pageUrl, layout, webUrl) {
|
|
|
58
44
|
}
|
|
59
45
|
else {
|
|
60
46
|
// Get the page
|
|
61
|
-
|
|
47
|
+
Web().Lists("Site Pages").Items().query({
|
|
62
48
|
Filter: "FileLeafRef eq '" + pageUrl + "'"
|
|
63
|
-
}).execute(
|
|
49
|
+
}).execute(items => {
|
|
64
50
|
// Resolve the request
|
|
65
51
|
resolve(items.results[0]);
|
|
66
52
|
}, reject);
|
|
@@ -68,10 +54,10 @@ exports.SitePages.convertPage = function (pageUrl, layout, webUrl) {
|
|
|
68
54
|
});
|
|
69
55
|
};
|
|
70
56
|
// Get the page
|
|
71
|
-
getPage(pageUrl).then(
|
|
57
|
+
getPage(pageUrl).then(item => {
|
|
72
58
|
// Update the item
|
|
73
59
|
item.update({ PageLayoutType: layout }).execute(resolve, reject);
|
|
74
|
-
},
|
|
60
|
+
}, () => {
|
|
75
61
|
// Log
|
|
76
62
|
console.error("Unable to get the page: " + pageUrl);
|
|
77
63
|
// Reject the request
|
|
@@ -80,36 +66,36 @@ exports.SitePages.convertPage = function (pageUrl, layout, webUrl) {
|
|
|
80
66
|
});
|
|
81
67
|
};
|
|
82
68
|
// Static method to create a modern page
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return new Promise(
|
|
69
|
+
SitePages.createPage = ((pageName, pageTitle, pageTemplate, url, targetInfo) => {
|
|
70
|
+
let getContext = () => {
|
|
71
|
+
return new Promise(resolve => {
|
|
86
72
|
// See if the web url doesn't exists
|
|
87
73
|
if (url == null) {
|
|
88
74
|
resolve(null);
|
|
89
75
|
}
|
|
90
76
|
// Get the context of target web
|
|
91
|
-
|
|
77
|
+
ContextInfo.getWeb(url).execute(context => {
|
|
92
78
|
// Resolve the request
|
|
93
79
|
resolve(context.GetContextWebInformation.FormDigestValue);
|
|
94
80
|
});
|
|
95
81
|
});
|
|
96
82
|
};
|
|
97
83
|
// Return a promise
|
|
98
|
-
return new Promise(
|
|
84
|
+
return new Promise((resolve, reject) => {
|
|
99
85
|
// Method called after the updates have completed
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
86
|
+
let onComplete = (itemId, fileUrl) => {
|
|
87
|
+
let web = Web(url, targetInfo);
|
|
88
|
+
let results = { file: null, item: null, page: null };
|
|
103
89
|
// Get the file
|
|
104
|
-
web.getFileByUrl(fileUrl).query({ Select: ["*", "ListId"] }).execute(
|
|
90
|
+
web.getFileByUrl(fileUrl).query({ Select: ["*", "ListId"] }).execute(file => {
|
|
105
91
|
// Set the file
|
|
106
92
|
results.file = file;
|
|
107
93
|
// Get the list
|
|
108
|
-
web.Lists().getById(file.ListId).Items(itemId).execute(
|
|
94
|
+
web.Lists().getById(file.ListId).Items(itemId).execute(item => {
|
|
109
95
|
// Set the item
|
|
110
96
|
results.item = item;
|
|
111
97
|
// Get the page
|
|
112
|
-
|
|
98
|
+
SitePages(url, targetInfo).Pages(itemId).execute(page => {
|
|
113
99
|
// Set the page
|
|
114
100
|
results.page = page;
|
|
115
101
|
// Resolve the request
|
|
@@ -119,28 +105,28 @@ exports.SitePages.createPage = (function (pageName, pageTitle, pageTemplate, url
|
|
|
119
105
|
}, reject);
|
|
120
106
|
};
|
|
121
107
|
// Get the context information
|
|
122
|
-
getContext().then(
|
|
108
|
+
getContext().then(requestDigest => {
|
|
123
109
|
// Set the target information
|
|
124
|
-
targetInfo =
|
|
110
|
+
targetInfo = Object.assign({ requestDigest }, targetInfo);
|
|
125
111
|
// Create the page
|
|
126
|
-
|
|
112
|
+
SitePages(url, targetInfo).Pages().createAppPage({
|
|
127
113
|
Title: pageTitle,
|
|
128
114
|
PageLayoutType: pageTemplate
|
|
129
|
-
}).execute(
|
|
115
|
+
}).execute(page => {
|
|
130
116
|
// Update the file name
|
|
131
|
-
|
|
117
|
+
Web(url, targetInfo).Lists("Site Pages").Items(page.Id).update({
|
|
132
118
|
FileLeafRef: pageName
|
|
133
119
|
}).execute(
|
|
134
120
|
// Updated the file name successfully
|
|
135
|
-
|
|
121
|
+
() => {
|
|
136
122
|
// Update the file url
|
|
137
|
-
|
|
138
|
-
|
|
123
|
+
let idx = page.Url.lastIndexOf('/');
|
|
124
|
+
let fileUrl = page.Url.substring(0, idx + 1) + pageName;
|
|
139
125
|
// Complete the request
|
|
140
126
|
onComplete(page.Id, fileUrl);
|
|
141
127
|
},
|
|
142
128
|
// Unable to update the file name, but still return the object
|
|
143
|
-
|
|
129
|
+
() => {
|
|
144
130
|
// Complete the request
|
|
145
131
|
onComplete(page.Id, page.Url);
|
|
146
132
|
});
|
package/build/lib/socialFeed.js
CHANGED
|
@@ -1,44 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SocialFeed = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
1
|
+
import { Base, Request, RequestType } from "../utils";
|
|
5
2
|
/**
|
|
6
3
|
* Social Feed
|
|
7
4
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export const SocialFeed = ((targetInfo) => {
|
|
6
|
+
let base = new Base(targetInfo);
|
|
7
|
+
let socialFeed = base;
|
|
11
8
|
// Default the properties
|
|
12
9
|
base.targetInfo.defaultToWebFl = true;
|
|
13
10
|
base.targetInfo.endpoint = "social.feed";
|
|
14
11
|
// Add the methods
|
|
15
|
-
|
|
12
|
+
Request.addMethods(socialFeed, { __metadata: { type: "SP.Social.SocialRestFeedManager" } });
|
|
16
13
|
// Return the social feed
|
|
17
14
|
return socialFeed;
|
|
18
15
|
});
|
|
19
16
|
// Method to post to another user's feed
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
SocialFeed.postToFeed = (accountName, creationData) => {
|
|
18
|
+
let postInfo = { ID: null, creationData: creationData };
|
|
22
19
|
// Set the post metadata
|
|
23
20
|
postInfo["__metadata"] = { type: "SP.Social.SocialRestPostCreationData" };
|
|
24
21
|
postInfo.creationData["__metadata"] = { type: "SP.Social.SocialPostCreationData" };
|
|
25
22
|
// Execute the request
|
|
26
|
-
return
|
|
23
|
+
return SocialFeed().executeMethod("postToMyFeed", {
|
|
27
24
|
argNames: ["restCreationData"],
|
|
28
25
|
name: "actor(item=@v)/feed?@v='" + encodeURIComponent(accountName) + "'",
|
|
29
|
-
requestType:
|
|
26
|
+
requestType: RequestType.PostWithArgsInBody
|
|
30
27
|
}, [postInfo]);
|
|
31
28
|
};
|
|
32
29
|
// Method to post to the current user's feed
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
SocialFeed.postToMyFeed = (creationData) => {
|
|
31
|
+
let postInfo = { ID: null, creationData: creationData };
|
|
35
32
|
// Set the post metadata
|
|
36
33
|
postInfo["__metadata"] = { type: "SP.Social.SocialRestPostCreationData" };
|
|
37
34
|
postInfo.creationData["__metadata"] = { type: "SP.Social.SocialPostCreationData" };
|
|
38
35
|
// Execute the request
|
|
39
|
-
return
|
|
36
|
+
return SocialFeed().executeMethod("postToMyFeed", {
|
|
40
37
|
argNames: ["restCreationData"],
|
|
41
38
|
name: "my/feed/post",
|
|
42
|
-
requestType:
|
|
39
|
+
requestType: RequestType.PostWithArgsInBody
|
|
43
40
|
}, [postInfo]);
|
|
44
41
|
};
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ThemeManager = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
1
|
+
import { Base, Request } from "../utils";
|
|
5
2
|
/**
|
|
6
3
|
* Theme Manager
|
|
7
4
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export const ThemeManager = ((targetInfo) => {
|
|
6
|
+
let mgr = new Base(targetInfo);
|
|
10
7
|
// Default the properties
|
|
11
8
|
mgr.targetInfo.defaultToWebFl = true;
|
|
12
9
|
mgr.targetInfo.endpoint = "thememanager";
|
|
13
10
|
// Add the methods
|
|
14
|
-
|
|
11
|
+
Request.addMethods(mgr, { __metadata: { type: "SP.Utilities.ThemeManager" } });
|
|
15
12
|
// Return the theme manager
|
|
16
13
|
return mgr;
|
|
17
14
|
});
|
package/build/lib/userProfile.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserProfile = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
1
|
+
import { Base, Request } from "../utils";
|
|
5
2
|
/**
|
|
6
3
|
* User Profile
|
|
7
4
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export const UserProfile = ((targetInfo) => {
|
|
6
|
+
let userProfile = new Base(targetInfo);
|
|
10
7
|
// Default the properties
|
|
11
8
|
userProfile.targetInfo.defaultToWebFl = true;
|
|
12
9
|
userProfile.targetInfo.endpoint = "sp.userprofiles.profileloader.getprofileloader/getUserProfile";
|
|
13
10
|
userProfile.targetInfo.method = "POST";
|
|
14
11
|
// Add the methods
|
|
15
|
-
|
|
12
|
+
Request.addMethods(userProfile, { __metadata: { type: "SP.UserProfiles.UserProfile" } });
|
|
16
13
|
// Return the user profile
|
|
17
14
|
return userProfile;
|
|
18
15
|
});
|