@kwiz/common 1.0.177 → 1.0.179
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/lib/cjs/utils/sharepoint.rest/file.folder.js +61 -31
- package/lib/cjs/utils/sharepoint.rest/file.folder.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/item.js +81 -11
- package/lib/cjs/utils/sharepoint.rest/item.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/list.js +112 -42
- package/lib/cjs/utils/sharepoint.rest/list.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/listutils/GetListItemsById.js +4 -2
- package/lib/cjs/utils/sharepoint.rest/listutils/GetListItemsById.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/listutils/common.js +18 -0
- package/lib/cjs/utils/sharepoint.rest/listutils/common.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/navigation-links.js +6 -2
- package/lib/cjs/utils/sharepoint.rest/navigation-links.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/sp-people-search-service.js +2 -1
- package/lib/cjs/utils/sharepoint.rest/sp-people-search-service.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/user.js +88 -25
- package/lib/cjs/utils/sharepoint.rest/user.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/web.js +166 -50
- package/lib/cjs/utils/sharepoint.rest/web.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/file.folder.js +61 -31
- package/lib/esm/utils/sharepoint.rest/file.folder.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/item.js +82 -13
- package/lib/esm/utils/sharepoint.rest/item.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/list.js +112 -42
- package/lib/esm/utils/sharepoint.rest/list.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/listutils/GetListItemsById.js +4 -2
- package/lib/esm/utils/sharepoint.rest/listutils/GetListItemsById.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/listutils/common.js +17 -0
- package/lib/esm/utils/sharepoint.rest/listutils/common.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/navigation-links.js +6 -2
- package/lib/esm/utils/sharepoint.rest/navigation-links.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/sp-people-search-service.js +2 -1
- package/lib/esm/utils/sharepoint.rest/sp-people-search-service.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/user.js +88 -25
- package/lib/esm/utils/sharepoint.rest/user.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/web.js +166 -50
- package/lib/esm/utils/sharepoint.rest/web.js.map +1 -1
- package/lib/types/utils/sharepoint.rest/file.folder.d.ts +1 -1
- package/lib/types/utils/sharepoint.rest/item.d.ts +4 -0
- package/lib/types/utils/sharepoint.rest/list.d.ts +2 -2
- package/lib/types/utils/sharepoint.rest/listutils/common.d.ts +5 -0
- package/package.json +1 -1
|
@@ -22,7 +22,10 @@ const logger = ConsoleLogger.get("utils/sharepoint.rest/web");
|
|
|
22
22
|
export async function GetSiteInfo(siteUrl) {
|
|
23
23
|
siteUrl = GetSiteUrl(siteUrl);
|
|
24
24
|
try {
|
|
25
|
-
const r = await GetJson(GetRestBaseUrl(siteUrl) + "/site?$select=id,serverRelativeUrl", null, {
|
|
25
|
+
const r = await GetJson(GetRestBaseUrl(siteUrl) + "/site?$select=id,serverRelativeUrl", null, {
|
|
26
|
+
...longLocalCache,
|
|
27
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
28
|
+
});
|
|
26
29
|
var id = normalizeGuid(r.d.Id);
|
|
27
30
|
var serverRelativeUrl = normalizeUrl(r.d.ServerRelativeUrl);
|
|
28
31
|
if (isNullOrEmptyString(serverRelativeUrl))
|
|
@@ -35,7 +38,10 @@ export async function GetSiteInfo(siteUrl) {
|
|
|
35
38
|
}
|
|
36
39
|
export function GetSiteInfoSync(siteUrl) {
|
|
37
40
|
siteUrl = GetSiteUrl(siteUrl);
|
|
38
|
-
let result = GetJsonSync(GetRestBaseUrl(siteUrl) + "/site?$select=id,serverRelativeUrl", null, {
|
|
41
|
+
let result = GetJsonSync(GetRestBaseUrl(siteUrl) + "/site?$select=id,serverRelativeUrl", null, {
|
|
42
|
+
...longLocalCache,
|
|
43
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
44
|
+
});
|
|
39
45
|
if (result.success) {
|
|
40
46
|
var id = normalizeGuid(result.result.d.Id);
|
|
41
47
|
var serverRelativeUrl = normalizeUrl(result.result.d.ServerRelativeUrl);
|
|
@@ -112,7 +118,10 @@ export function GetSiteIdSync(siteUrl) {
|
|
|
112
118
|
/** Get root web id lower case no {} */
|
|
113
119
|
export function GetRootWebInfo(siteUrl) {
|
|
114
120
|
siteUrl = GetSiteUrl(siteUrl);
|
|
115
|
-
return GetJson(GetRestBaseUrl(siteUrl) + "/site/rootWeb?$select=id,serverRelativeUrl", null, {
|
|
121
|
+
return GetJson(GetRestBaseUrl(siteUrl) + "/site/rootWeb?$select=id,serverRelativeUrl", null, {
|
|
122
|
+
...longLocalCache,
|
|
123
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
124
|
+
})
|
|
116
125
|
.then(r => {
|
|
117
126
|
var id = normalizeGuid(r.d.Id);
|
|
118
127
|
var serverRelativeUrl = normalizeUrl(r.d.ServerRelativeUrl);
|
|
@@ -124,7 +133,10 @@ export function GetRootWebInfo(siteUrl) {
|
|
|
124
133
|
/** Return the web Title */
|
|
125
134
|
export function GetWebTitle(siteUrl) {
|
|
126
135
|
siteUrl = GetSiteUrl(siteUrl);
|
|
127
|
-
return GetJson(GetRestBaseUrl(siteUrl) + `/web/Title`, null, {
|
|
136
|
+
return GetJson(GetRestBaseUrl(siteUrl) + `/web/Title`, null, {
|
|
137
|
+
...shortLocalCache,
|
|
138
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
139
|
+
})
|
|
128
140
|
.then(r => {
|
|
129
141
|
return r.d.Title;
|
|
130
142
|
})
|
|
@@ -135,7 +147,10 @@ function _getWebIdRequestUrl(siteUrl) {
|
|
|
135
147
|
}
|
|
136
148
|
/** Return the web id */
|
|
137
149
|
export function GetWebId(siteUrl) {
|
|
138
|
-
return GetJson(_getWebIdRequestUrl(siteUrl), null, {
|
|
150
|
+
return GetJson(_getWebIdRequestUrl(siteUrl), null, {
|
|
151
|
+
...longLocalCache,
|
|
152
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
153
|
+
})
|
|
139
154
|
.then(r => {
|
|
140
155
|
return normalizeGuid(r.d.Id);
|
|
141
156
|
})
|
|
@@ -143,7 +158,10 @@ export function GetWebId(siteUrl) {
|
|
|
143
158
|
}
|
|
144
159
|
/** Return the web id */
|
|
145
160
|
export function GetWebIdSync(siteUrl) {
|
|
146
|
-
let syncResult = GetJsonSync(_getWebIdRequestUrl(siteUrl), null, {
|
|
161
|
+
let syncResult = GetJsonSync(_getWebIdRequestUrl(siteUrl), null, {
|
|
162
|
+
...longLocalCache,
|
|
163
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
164
|
+
});
|
|
147
165
|
if (syncResult.success)
|
|
148
166
|
return syncResult.result.d.Id;
|
|
149
167
|
else
|
|
@@ -158,7 +176,10 @@ export async function IsRootWeb(siteUrl) {
|
|
|
158
176
|
}
|
|
159
177
|
export function UserHasAllPermissions(siteUrl, permissions) {
|
|
160
178
|
siteUrl = GetSiteUrl(siteUrl);
|
|
161
|
-
return GetJson(GetRestBaseUrl(siteUrl) + `/web/EffectiveBasePermissions`, null, {
|
|
179
|
+
return GetJson(GetRestBaseUrl(siteUrl) + `/web/EffectiveBasePermissions`, null, {
|
|
180
|
+
...shortLocalCache,
|
|
181
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
182
|
+
})
|
|
162
183
|
.then(r => {
|
|
163
184
|
var effectivePermissions = new SPBasePermissions(r.d.EffectiveBasePermissions);
|
|
164
185
|
return permissions.every((perm) => {
|
|
@@ -174,7 +195,10 @@ export function UserHasManageSitePermissions(siteUrl) {
|
|
|
174
195
|
if (_spPageContextInfo.isSiteAdmin || _spPageContextInfo["isSiteOwner"])
|
|
175
196
|
return Promise.resolve(true);
|
|
176
197
|
}
|
|
177
|
-
return GetJson(GetRestBaseUrl(siteUrl) + `/web/EffectiveBasePermissions`, null, {
|
|
198
|
+
return GetJson(GetRestBaseUrl(siteUrl) + `/web/EffectiveBasePermissions`, null, {
|
|
199
|
+
...shortLocalCache,
|
|
200
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
201
|
+
})
|
|
178
202
|
.then(r => {
|
|
179
203
|
return new SPBasePermissions(r.d.EffectiveBasePermissions).has(SPBasePermissionKind.ManageWeb);
|
|
180
204
|
})
|
|
@@ -224,7 +248,10 @@ export async function GetContentTypes(siteUrl, options = {}, refreshCache = fals
|
|
|
224
248
|
if (options.includeFields) {
|
|
225
249
|
allListFields = await GetListFields(siteUrl, options.listIdOrTitle);
|
|
226
250
|
}
|
|
227
|
-
return GetJson(url, null, {
|
|
251
|
+
return GetJson(url, null, {
|
|
252
|
+
allowCache: refreshCache !== true, jsonMetadata: jsonTypes.nometadata,
|
|
253
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
254
|
+
})
|
|
228
255
|
.then(result => {
|
|
229
256
|
if (!isNullOrUndefined(result)) {
|
|
230
257
|
return _postProcessGetContentTypes(result.value, options, allListFields);
|
|
@@ -239,7 +266,10 @@ export function GetContentTypesSync(siteUrl, options = {}, refreshCache = false)
|
|
|
239
266
|
if (options.includeFields) {
|
|
240
267
|
allListFields = GetListFieldsSync(siteUrl, options.listIdOrTitle);
|
|
241
268
|
}
|
|
242
|
-
let result = GetJsonSync(url, null, {
|
|
269
|
+
let result = GetJsonSync(url, null, {
|
|
270
|
+
allowCache: refreshCache !== true, jsonMetadata: jsonTypes.nometadata,
|
|
271
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
272
|
+
});
|
|
243
273
|
if (!isNullOrUndefined(result) && result.success === true && !isNullOrUndefined(result.result)) {
|
|
244
274
|
return _postProcessGetContentTypes(result.result.value, options, allListFields);
|
|
245
275
|
}
|
|
@@ -282,7 +312,10 @@ function _postProcessGetLists(lists, options = {}) {
|
|
|
282
312
|
export function GetLists(siteUrl, options = {}) {
|
|
283
313
|
let url = _getListsRequestUrl(siteUrl, options);
|
|
284
314
|
const allowCache = options.allowCache === undefined ? true : options.allowCache;
|
|
285
|
-
return GetJson(url, null, {
|
|
315
|
+
return GetJson(url, null, {
|
|
316
|
+
allowCache, jsonMetadata: jsonTypes.nometadata,
|
|
317
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
318
|
+
})
|
|
286
319
|
.then(result => {
|
|
287
320
|
return _postProcessGetLists(result.value, options);
|
|
288
321
|
})
|
|
@@ -290,7 +323,10 @@ export function GetLists(siteUrl, options = {}) {
|
|
|
290
323
|
}
|
|
291
324
|
export function GetListsSync(siteUrl, options = {}) {
|
|
292
325
|
let url = _getListsRequestUrl(siteUrl, options);
|
|
293
|
-
let response = GetJsonSync(url, null, {
|
|
326
|
+
let response = GetJsonSync(url, null, {
|
|
327
|
+
...shortLocalCache, jsonMetadata: jsonTypes.nometadata,
|
|
328
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
329
|
+
});
|
|
294
330
|
if (response && response.success && response.result && isNotEmptyArray(response.result.value)) {
|
|
295
331
|
return _postProcessGetLists(response.result.value, options);
|
|
296
332
|
}
|
|
@@ -317,7 +353,10 @@ export async function GetAllSubWebs(siteUrl, options) {
|
|
|
317
353
|
}
|
|
318
354
|
//Issue 6735 missing WebId for some customer (US, government GCC tenant will not return WebId)
|
|
319
355
|
let queryUrl = `${GetRestBaseUrl(siteUrl)}/search/query?querytext=%27${queryFilter}(contentclass:STS_Site)%20(contentclass:STS_Web)%27&trimduplicates=false&rowlimit=5000&selectproperties=%27Title,Url,WebTemplate,WebId%27`;
|
|
320
|
-
let response = await GetJson(queryUrl, null, {
|
|
356
|
+
let response = await GetJson(queryUrl, null, {
|
|
357
|
+
...shortLocalCache,
|
|
358
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
359
|
+
});
|
|
321
360
|
let results = response && response.d && response.d.query && response.d.query.PrimaryQueryResult;
|
|
322
361
|
let addedSites = [];
|
|
323
362
|
if (results && results.RelevantResults.RowCount >= 0) {
|
|
@@ -432,7 +471,10 @@ export async function __getSubSites(siteUrl, allowAppWebs) {
|
|
|
432
471
|
//try {
|
|
433
472
|
//maybe search is not wokring? use regular REST API
|
|
434
473
|
let restUrl = `${GetRestBaseUrl(siteUrl)}/web/getsubwebsfilteredforcurrentuser(nwebtemplatefilter=-1,nconfigurationfilter=0)?$Select=Title,ServerRelativeUrl,Id,WebTemplate`;
|
|
435
|
-
let result = await GetJson(restUrl, null, {
|
|
474
|
+
let result = await GetJson(restUrl, null, {
|
|
475
|
+
...shortLocalCache,
|
|
476
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
477
|
+
});
|
|
436
478
|
if (result && result.d && isNotEmptyArray(result.d.results)) {
|
|
437
479
|
let results = (allowAppWebs) ? result.d.results : result.d.results.filter(s => s.WebTemplate !== "APP");
|
|
438
480
|
let promises = [];
|
|
@@ -500,7 +542,8 @@ export async function GetWebInfo(siteUrl, webId, refreshCache) {
|
|
|
500
542
|
webInfoResponse = await GetJson(url, null, {
|
|
501
543
|
...shortLocalCache,
|
|
502
544
|
jsonMetadata: jsonTypes.nometadata,
|
|
503
|
-
allowCache: refreshCache !== true
|
|
545
|
+
allowCache: refreshCache !== true,
|
|
546
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
504
547
|
});
|
|
505
548
|
}
|
|
506
549
|
}
|
|
@@ -527,7 +570,8 @@ export function GetWebInfoSync(siteUrl, webId) {
|
|
|
527
570
|
let url = _getCurrentWebInfoRequestUrl(siteUrl);
|
|
528
571
|
let syncResult = GetJsonSync(url, null, {
|
|
529
572
|
...shortLocalCache,
|
|
530
|
-
jsonMetadata: jsonTypes.nometadata
|
|
573
|
+
jsonMetadata: jsonTypes.nometadata,
|
|
574
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
531
575
|
});
|
|
532
576
|
if (syncResult.success) {
|
|
533
577
|
webInfoResponse = syncResult.result;
|
|
@@ -536,7 +580,10 @@ export function GetWebInfoSync(siteUrl, webId) {
|
|
|
536
580
|
return _postProcessGetWebInfo(webInfoResponse);
|
|
537
581
|
}
|
|
538
582
|
export async function GetWebRoleDefinitions(siteUrl) {
|
|
539
|
-
return GetJson(GetRestBaseUrl(siteUrl) + `/web/RoleDefinitions?filter=Hidden ne true`, null, {
|
|
583
|
+
return GetJson(GetRestBaseUrl(siteUrl) + `/web/RoleDefinitions?filter=Hidden ne true`, null, {
|
|
584
|
+
...longLocalCache,
|
|
585
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
586
|
+
})
|
|
540
587
|
.then(r => {
|
|
541
588
|
return r.d.results || [];
|
|
542
589
|
})
|
|
@@ -546,12 +593,18 @@ export async function GetWebRoleDefinitions(siteUrl) {
|
|
|
546
593
|
/** get roles for site or list */
|
|
547
594
|
export async function GetRoleAssignments(siteUrl, listIdOrTitle, itemId) {
|
|
548
595
|
const url = `${isNullOrEmptyString(listIdOrTitle) ? GetRestBaseUrl(siteUrl) + "/web" : GetListRestUrl(siteUrl, listIdOrTitle)}/${isNullOrNaN(itemId) ? '' : `items(${itemId})/`}roleassignments?$expand=Member/users,RoleDefinitionBindings`;
|
|
549
|
-
const result = await GetJson(url, undefined, {
|
|
596
|
+
const result = await GetJson(url, undefined, {
|
|
597
|
+
jsonMetadata: jsonTypes.nometadata,
|
|
598
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
599
|
+
});
|
|
550
600
|
return result.value;
|
|
551
601
|
}
|
|
552
602
|
/** Web sub webs for the selected site */
|
|
553
603
|
export async function GetSubWebs(siteUrl, options) {
|
|
554
|
-
return GetJson(GetRestBaseUrl(siteUrl) + `/web/webs${options && options.allowAppWebs ? "" : "&$filter=WebTemplate ne 'APP'"}`, null, {
|
|
604
|
+
return GetJson(GetRestBaseUrl(siteUrl) + `/web/webs${options && options.allowAppWebs ? "" : "&$filter=WebTemplate ne 'APP'"}`, null, {
|
|
605
|
+
...shortLocalCache,
|
|
606
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
607
|
+
})
|
|
555
608
|
.then(r => {
|
|
556
609
|
return r.d.results;
|
|
557
610
|
})
|
|
@@ -564,7 +617,10 @@ export async function GetAppTiles(siteUrl) {
|
|
|
564
617
|
logger.warn('GetAppTiles does not work in an app web');
|
|
565
618
|
return null;
|
|
566
619
|
}
|
|
567
|
-
return GetJson(GetRestBaseUrl(siteUrl) + "/web/AppTiles?$filter=AppType%20eq%203&$select=Title,ProductId", null, {
|
|
620
|
+
return GetJson(GetRestBaseUrl(siteUrl) + "/web/AppTiles?$filter=AppType%20eq%203&$select=Title,ProductId", null, {
|
|
621
|
+
...shortLocalCache, jsonMetadata: jsonTypes.nometadata,
|
|
622
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
623
|
+
})
|
|
568
624
|
.then(r => {
|
|
569
625
|
return isNotEmptyArray(r.value) ? r.value.map(t => {
|
|
570
626
|
return {
|
|
@@ -583,7 +639,10 @@ export function GetAppTilesSync(siteUrl) {
|
|
|
583
639
|
logger.warn('GetAppTiles does not work in an app web');
|
|
584
640
|
return null;
|
|
585
641
|
}
|
|
586
|
-
let r = GetJsonSync(GetRestBaseUrl(siteUrl) + "/web/AppTiles?$filter=AppType%20eq%203&$select=Title,ProductId", null, {
|
|
642
|
+
let r = GetJsonSync(GetRestBaseUrl(siteUrl) + "/web/AppTiles?$filter=AppType%20eq%203&$select=Title,ProductId", null, {
|
|
643
|
+
...shortLocalCache, jsonMetadata: jsonTypes.nometadata,
|
|
644
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
645
|
+
});
|
|
587
646
|
return r.success && r.result && isNotEmptyArray(r.result.value) ? r.result.value.map(t => {
|
|
588
647
|
return {
|
|
589
648
|
Title: t.Title,
|
|
@@ -600,7 +659,10 @@ function GetWebType(WebTemplate) {
|
|
|
600
659
|
export async function GetServerTimeZone(siteUrl) {
|
|
601
660
|
siteUrl = GetSiteUrl(siteUrl);
|
|
602
661
|
let getTimeZoneUrl = `${GetRestBaseUrl(siteUrl)}/web/regionalSettings/timeZone`;
|
|
603
|
-
let result = await GetJson(getTimeZoneUrl, null, {
|
|
662
|
+
let result = await GetJson(getTimeZoneUrl, null, {
|
|
663
|
+
...extraLongLocalCache,
|
|
664
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
665
|
+
});
|
|
604
666
|
if (result && result.d && !isNullOrUndefined(result.d)) {
|
|
605
667
|
return result.d;
|
|
606
668
|
}
|
|
@@ -610,7 +672,10 @@ export async function GetServerTimeZone(siteUrl) {
|
|
|
610
672
|
export function GetServerTimeZoneSync(siteUrl) {
|
|
611
673
|
siteUrl = GetSiteUrl(siteUrl);
|
|
612
674
|
let getTimeZoneUrl = `${GetRestBaseUrl(siteUrl)}/web/regionalSettings/timeZone`;
|
|
613
|
-
let response = GetJsonSync(getTimeZoneUrl, null, {
|
|
675
|
+
let response = GetJsonSync(getTimeZoneUrl, null, {
|
|
676
|
+
...extraLongLocalCache,
|
|
677
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
678
|
+
});
|
|
614
679
|
if (response && response.result.d && !isNullOrUndefined(response.result.d)) {
|
|
615
680
|
return response.result.d;
|
|
616
681
|
}
|
|
@@ -630,7 +695,10 @@ async function GetServerTimeOffset(siteUrl, date) {
|
|
|
630
695
|
let dateStr = toIsoDateFormat(date, { zeroTime: true, omitZ: true });
|
|
631
696
|
let inputDate = new Date(dateStr);
|
|
632
697
|
let getTimeZoneOffsetUrl = `${GetRestBaseUrl(siteUrl)}/web/regionalSettings/timeZone/localTimeToUTC(@date)?@date='${encodeURIComponent(dateStr)}'`;
|
|
633
|
-
let result = await GetJson(getTimeZoneOffsetUrl, null, {
|
|
698
|
+
let result = await GetJson(getTimeZoneOffsetUrl, null, {
|
|
699
|
+
...weeekLongLocalCache, jsonMetadata: jsonTypes.nometadata,
|
|
700
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
701
|
+
});
|
|
634
702
|
if (result && !isNullOrEmptyString(result.value)) {
|
|
635
703
|
let resultDate = new Date(result.value.slice(0, result.value.length - 1)); //remove Z and get as date.
|
|
636
704
|
return (resultDate.getTime() - inputDate.getTime());
|
|
@@ -651,7 +719,10 @@ function GetServerTimeOffsetSync(siteUrl, date) {
|
|
|
651
719
|
let dateStr = toIsoDateFormat(date, { zeroTime: true, omitZ: true });
|
|
652
720
|
let inputDate = new Date(dateStr);
|
|
653
721
|
let getTimeZoneOffsetUrl = `${GetRestBaseUrl(siteUrl)}/web/regionalSettings/timeZone/localTimeToUTC(@date)?@date='${encodeURIComponent(dateStr)}'`;
|
|
654
|
-
let result = GetJsonSync(getTimeZoneOffsetUrl, null, {
|
|
722
|
+
let result = GetJsonSync(getTimeZoneOffsetUrl, null, {
|
|
723
|
+
...weeekLongLocalCache, jsonMetadata: jsonTypes.nometadata,
|
|
724
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
725
|
+
});
|
|
655
726
|
if (result && result.success && !isNullOrEmptyString(result.result.value)) {
|
|
656
727
|
let resultDate = new Date(result.result.value.slice(0, result.result.value.length - 1)); //remove Z and get as date.
|
|
657
728
|
return (resultDate.getTime() - inputDate.getTime());
|
|
@@ -712,7 +783,10 @@ export async function SPServerLocalTimeToUTC(siteUrl, date) {
|
|
|
712
783
|
}
|
|
713
784
|
}
|
|
714
785
|
let restUrl = `${GetRestBaseUrl(siteUrl)}/web/regionalSettings/timeZone/localTimeToUTC(@date)?@date='${encodeURIComponent(date)}'`;
|
|
715
|
-
let result = await GetJson(restUrl, null, {
|
|
786
|
+
let result = await GetJson(restUrl, null, {
|
|
787
|
+
...weeekLongLocalCache, jsonMetadata: jsonTypes.nometadata,
|
|
788
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
789
|
+
});
|
|
716
790
|
return result && result.value || null;
|
|
717
791
|
}
|
|
718
792
|
/**
|
|
@@ -743,7 +817,10 @@ export function SPServerLocalTimeToUTCSync(siteUrl, date) {
|
|
|
743
817
|
}
|
|
744
818
|
}
|
|
745
819
|
let restUrl = `${GetRestBaseUrl(siteUrl)}/web/regionalSettings/timeZone/localTimeToUTC(@date)?@date='${encodeURIComponent(date)}'`;
|
|
746
|
-
let result = GetJsonSync(restUrl, null, {
|
|
820
|
+
let result = GetJsonSync(restUrl, null, {
|
|
821
|
+
...weeekLongLocalCache, jsonMetadata: jsonTypes.nometadata,
|
|
822
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
823
|
+
});
|
|
747
824
|
return result.success && result.result.value || null;
|
|
748
825
|
}
|
|
749
826
|
/** get utc date yyyy-MM-ddTHH:mm:ssZ
|
|
@@ -783,7 +860,10 @@ export async function UTCToSPServerLocalTime(siteUrl, date) {
|
|
|
783
860
|
}
|
|
784
861
|
}
|
|
785
862
|
let restUrl = `${GetRestBaseUrl(siteUrl)}/web/regionalSettings/timeZone/utcToLocalTime(@date)?@date='${encodeURIComponent(date)}'`;
|
|
786
|
-
let result = await GetJson(restUrl, null, {
|
|
863
|
+
let result = await GetJson(restUrl, null, {
|
|
864
|
+
...longLocalCache, jsonMetadata: jsonTypes.nometadata,
|
|
865
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
866
|
+
});
|
|
787
867
|
return result && result.value || null;
|
|
788
868
|
}
|
|
789
869
|
/** get utc date yyyy-MM-ddTHH:mm:ssZ
|
|
@@ -823,7 +903,10 @@ export function UTCToSPServerLocalTimeSync(siteUrl, date) {
|
|
|
823
903
|
}
|
|
824
904
|
}
|
|
825
905
|
let restUrl = `${GetRestBaseUrl(siteUrl)}/web/regionalSettings/timeZone/utcToLocalTime(@date)?@date='${encodeURIComponent(date)}'`;
|
|
826
|
-
let result = GetJsonSync(restUrl, null, {
|
|
906
|
+
let result = GetJsonSync(restUrl, null, {
|
|
907
|
+
...longLocalCache, jsonMetadata: jsonTypes.nometadata,
|
|
908
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
909
|
+
});
|
|
827
910
|
return result.success && result.result.value || null;
|
|
828
911
|
}
|
|
829
912
|
function _momentUTCToLocalISO(date, timeZone, momentTimezone) {
|
|
@@ -940,7 +1023,8 @@ export function GetContextWebInformationSync(siteUrl) {
|
|
|
940
1023
|
maxAge: 5 * 60,
|
|
941
1024
|
includeDigestInPost: false,
|
|
942
1025
|
allowCache: true,
|
|
943
|
-
postCacheKey: `GetContextWebInformation_${normalizeGuid(siteId)}
|
|
1026
|
+
postCacheKey: `GetContextWebInformation_${normalizeGuid(siteId)}`,
|
|
1027
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
944
1028
|
});
|
|
945
1029
|
if (result && result.success) {
|
|
946
1030
|
return result.result.d.GetContextWebInformation;
|
|
@@ -968,7 +1052,8 @@ export async function GetContextWebInformation(siteUrl) {
|
|
|
968
1052
|
maxAge: 5 * 60,
|
|
969
1053
|
includeDigestInPost: false,
|
|
970
1054
|
allowCache: true,
|
|
971
|
-
postCacheKey: `GetContextWebInformation_${normalizeGuid(siteId)}
|
|
1055
|
+
postCacheKey: `GetContextWebInformation_${normalizeGuid(siteId)}`,
|
|
1056
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
972
1057
|
});
|
|
973
1058
|
return result.d.GetContextWebInformation;
|
|
974
1059
|
}
|
|
@@ -1026,7 +1111,8 @@ export async function GetUserCustomActions(siteUrl, listId, allowCache = true) {
|
|
|
1026
1111
|
let cacheOptions = allowCache === true ? shortLocalCache : { allowCache: false };
|
|
1027
1112
|
let restOptions = {
|
|
1028
1113
|
jsonMetadata: jsonTypes.nometadata,
|
|
1029
|
-
...cacheOptions
|
|
1114
|
+
...cacheOptions,
|
|
1115
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1030
1116
|
};
|
|
1031
1117
|
try {
|
|
1032
1118
|
let response = await GetJson(restUrl, null, restOptions);
|
|
@@ -1044,7 +1130,8 @@ export async function GetUserCustomActionById(siteUrl, customActionId, listId, a
|
|
|
1044
1130
|
let cacheOptions = allowCache === true ? shortLocalCache : { allowCache: false };
|
|
1045
1131
|
let restOptions = {
|
|
1046
1132
|
jsonMetadata: jsonTypes.nometadata,
|
|
1047
|
-
...cacheOptions
|
|
1133
|
+
...cacheOptions,
|
|
1134
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1048
1135
|
};
|
|
1049
1136
|
try {
|
|
1050
1137
|
let response = await GetJson(restUrl, null, restOptions);
|
|
@@ -1062,7 +1149,8 @@ export async function GetUserCustomActionByName(siteUrl, name, listId, allowCach
|
|
|
1062
1149
|
let cacheOptions = allowCache === true ? shortLocalCache : { allowCache: false };
|
|
1063
1150
|
let restOptions = {
|
|
1064
1151
|
jsonMetadata: jsonTypes.nometadata,
|
|
1065
|
-
...cacheOptions
|
|
1152
|
+
...cacheOptions,
|
|
1153
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1066
1154
|
};
|
|
1067
1155
|
try {
|
|
1068
1156
|
let response = await GetJson(restUrl, null, restOptions);
|
|
@@ -1080,7 +1168,8 @@ export async function AddUserCustomAction(siteUrl, userCustomActionInfo, listId)
|
|
|
1080
1168
|
let restOptions = {
|
|
1081
1169
|
jsonMetadata: jsonTypes.nometadata,
|
|
1082
1170
|
method: "POST",
|
|
1083
|
-
includeDigestInPost: true
|
|
1171
|
+
includeDigestInPost: true,
|
|
1172
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1084
1173
|
};
|
|
1085
1174
|
try {
|
|
1086
1175
|
let data = _convertCustomActionToPostData(userCustomActionInfo);
|
|
@@ -1100,7 +1189,8 @@ export async function UpdateUserCustomAction(siteUrl, customActionId, userCustom
|
|
|
1100
1189
|
jsonMetadata: jsonTypes.nometadata,
|
|
1101
1190
|
method: "POST",
|
|
1102
1191
|
xHttpMethod: "MERGE",
|
|
1103
|
-
includeDigestInPost: true
|
|
1192
|
+
includeDigestInPost: true,
|
|
1193
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1104
1194
|
};
|
|
1105
1195
|
try {
|
|
1106
1196
|
let data = _convertCustomActionToPostData(userCustomActionInfo);
|
|
@@ -1118,7 +1208,8 @@ export async function DeleteUserCustomAction(siteUrl, customActionId, listId) {
|
|
|
1118
1208
|
jsonMetadata: jsonTypes.nometadata,
|
|
1119
1209
|
method: "POST",
|
|
1120
1210
|
xHttpMethod: "DELETE",
|
|
1121
|
-
includeDigestInPost: true
|
|
1211
|
+
includeDigestInPost: true,
|
|
1212
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1122
1213
|
};
|
|
1123
1214
|
try {
|
|
1124
1215
|
let result = await GetJson(restUrl, null, restOptions);
|
|
@@ -1133,7 +1224,10 @@ export async function GetRegionalSettings(siteUrl) {
|
|
|
1133
1224
|
siteUrl = GetSiteUrl(siteUrl);
|
|
1134
1225
|
let restUrl = `${GetRestBaseUrl(siteUrl)}/web/regionalSettings`;
|
|
1135
1226
|
try {
|
|
1136
|
-
let result = await GetJson(restUrl, null, {
|
|
1227
|
+
let result = await GetJson(restUrl, null, {
|
|
1228
|
+
...mediumLocalCache, jsonMetadata: jsonTypes.nometadata,
|
|
1229
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1230
|
+
});
|
|
1137
1231
|
return result;
|
|
1138
1232
|
}
|
|
1139
1233
|
catch {
|
|
@@ -1145,7 +1239,10 @@ export async function GetAllWebProperties(siteUrl) {
|
|
|
1145
1239
|
siteUrl = GetSiteUrl(siteUrl);
|
|
1146
1240
|
let restUrl = `${GetRestBaseUrl(siteUrl)}/web/AllProperties`;
|
|
1147
1241
|
try {
|
|
1148
|
-
let result = await GetJson(restUrl, null, {
|
|
1242
|
+
let result = await GetJson(restUrl, null, {
|
|
1243
|
+
...shortLocalCache, jsonMetadata: jsonTypes.nometadata,
|
|
1244
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1245
|
+
});
|
|
1149
1246
|
return result;
|
|
1150
1247
|
}
|
|
1151
1248
|
catch {
|
|
@@ -1157,7 +1254,10 @@ export async function GetWebPropertyByName(name, siteUrl) {
|
|
|
1157
1254
|
siteUrl = GetSiteUrl(siteUrl);
|
|
1158
1255
|
let restUrl = `${GetRestBaseUrl(siteUrl)}/web/AllProperties?$select=${name}`;
|
|
1159
1256
|
try {
|
|
1160
|
-
let result = await GetJson(restUrl, null, {
|
|
1257
|
+
let result = await GetJson(restUrl, null, {
|
|
1258
|
+
...shortLocalCache, jsonMetadata: jsonTypes.nometadata,
|
|
1259
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1260
|
+
});
|
|
1161
1261
|
if (!isNullOrUndefined(result) && !isNullOrUndefined(result[name])) {
|
|
1162
1262
|
return result[name];
|
|
1163
1263
|
}
|
|
@@ -1213,7 +1313,10 @@ export function ensureLegacyProps(pageContext) {
|
|
|
1213
1313
|
}
|
|
1214
1314
|
export async function WebHasUniquePermissions(siteUrl) {
|
|
1215
1315
|
let url = `${GetRestBaseUrl(siteUrl)}/web?$select=hasuniqueroleassignments`;
|
|
1216
|
-
let has = await GetJson(url, undefined, {
|
|
1316
|
+
let has = await GetJson(url, undefined, {
|
|
1317
|
+
allowCache: false, jsonMetadata: jsonTypes.nometadata,
|
|
1318
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1319
|
+
});
|
|
1217
1320
|
return has.HasUniqueRoleAssignments === true;
|
|
1218
1321
|
}
|
|
1219
1322
|
export async function RestoreWebPermissionInheritance(siteUrl) {
|
|
@@ -1238,7 +1341,10 @@ export async function SetUserAsSiteAdmin(siteUrl, userId) {
|
|
|
1238
1341
|
await GetJson(url, jsonStringify({
|
|
1239
1342
|
"__metadata": { "type": "SP.User" },
|
|
1240
1343
|
"IsSiteAdmin": true
|
|
1241
|
-
}), {
|
|
1344
|
+
}), {
|
|
1345
|
+
method: 'POST', xHttpMethod: 'MERGE',
|
|
1346
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1347
|
+
});
|
|
1242
1348
|
return true;
|
|
1243
1349
|
}
|
|
1244
1350
|
/** get all the rentention labels (compliance tags) for a site */
|
|
@@ -1247,7 +1353,8 @@ export async function GetAvailableTagsForSite(siteUrlOrId) {
|
|
|
1247
1353
|
try {
|
|
1248
1354
|
let url = `${siteUrl}_api/SP.CompliancePolicy.SPPolicyStoreProxy.GetAvailableTagsForSite(siteUrl=@a1)?@a1='${encodeURIComponent(makeFullUrl(siteUrl))}'`;
|
|
1249
1355
|
let result = await GetJson(url, null, {
|
|
1250
|
-
jsonMetadata: jsonTypes.nometadata
|
|
1356
|
+
jsonMetadata: jsonTypes.nometadata,
|
|
1357
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1251
1358
|
});
|
|
1252
1359
|
return result.value;
|
|
1253
1360
|
}
|
|
@@ -1261,7 +1368,8 @@ export function GetAvailableTagsForSiteSync(siteUrlOrId) {
|
|
|
1261
1368
|
try {
|
|
1262
1369
|
let url = `${siteUrl}_api/SP.CompliancePolicy.SPPolicyStoreProxy.GetAvailableTagsForSite(siteUrl=@a1)?@a1='${encodeURIComponent(makeFullUrl(siteUrl))}'`;
|
|
1263
1370
|
let response = GetJsonSync(url, null, {
|
|
1264
|
-
jsonMetadata: jsonTypes.nometadata
|
|
1371
|
+
jsonMetadata: jsonTypes.nometadata,
|
|
1372
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1265
1373
|
});
|
|
1266
1374
|
return response.success ? response.result.value : [];
|
|
1267
1375
|
}
|
|
@@ -1277,7 +1385,8 @@ export async function GetActiveFeatures(siteUrlOrId, allowCache = true) {
|
|
|
1277
1385
|
method: "GET",
|
|
1278
1386
|
jsonMetadata: jsonTypes.nometadata,
|
|
1279
1387
|
includeDigestInGet: true,
|
|
1280
|
-
...(allowCache === true ? mediumLocalCache : noLocalCache)
|
|
1388
|
+
...(allowCache === true ? mediumLocalCache : noLocalCache),
|
|
1389
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1281
1390
|
});
|
|
1282
1391
|
return response.value;
|
|
1283
1392
|
}
|
|
@@ -1293,7 +1402,8 @@ export async function ActivateFeature(siteUrlOrId, id) {
|
|
|
1293
1402
|
let response = await GetJson(url, null, {
|
|
1294
1403
|
method: "POST",
|
|
1295
1404
|
jsonMetadata: jsonTypes.nometadata,
|
|
1296
|
-
includeDigestInPost: true
|
|
1405
|
+
includeDigestInPost: true,
|
|
1406
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1297
1407
|
});
|
|
1298
1408
|
return !isNullOrUndefined(response) && normalizeGuid(response.DefinitionId) === id;
|
|
1299
1409
|
}
|
|
@@ -1309,7 +1419,8 @@ export async function DectivateFeature(siteUrlOrId, id) {
|
|
|
1309
1419
|
let response = await GetJson(url, null, {
|
|
1310
1420
|
method: "POST",
|
|
1311
1421
|
jsonMetadata: jsonTypes.nometadata,
|
|
1312
|
-
includeDigestInPost: true
|
|
1422
|
+
includeDigestInPost: true,
|
|
1423
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1313
1424
|
});
|
|
1314
1425
|
return !isNullOrUndefined(response) && response["odata.null"] === true;
|
|
1315
1426
|
}
|
|
@@ -1323,7 +1434,8 @@ export async function GetWelcomePage(siteUrlOrId) {
|
|
|
1323
1434
|
let url = `${siteUrl}/_api/web/rootFolder`;
|
|
1324
1435
|
let response = await GetJson(url, null, {
|
|
1325
1436
|
method: "GET",
|
|
1326
|
-
jsonMetadata: jsonTypes.nometadata
|
|
1437
|
+
jsonMetadata: jsonTypes.nometadata,
|
|
1438
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1327
1439
|
});
|
|
1328
1440
|
if (!isNullOrUndefined(response) && response.Exists && !isNullOrEmptyString(response.WelcomePage)) {
|
|
1329
1441
|
return response.WelcomePage;
|
|
@@ -1343,7 +1455,8 @@ export async function SetWelcomePage(siteUrlOrId, welcomePage) {
|
|
|
1343
1455
|
method: "POST",
|
|
1344
1456
|
xHttpMethod: "MERGE",
|
|
1345
1457
|
jsonMetadata: jsonTypes.nometadata,
|
|
1346
|
-
includeDigestInPost: true
|
|
1458
|
+
includeDigestInPost: true,
|
|
1459
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1347
1460
|
});
|
|
1348
1461
|
return !isNullOrUndefined(response) && response["odata.null"] === true || isNullOrEmptyString(response);
|
|
1349
1462
|
}
|
|
@@ -1356,7 +1469,10 @@ export async function GetWebAssociatedGroups(siteUrl) {
|
|
|
1356
1469
|
siteUrl = GetSiteUrl(siteUrl);
|
|
1357
1470
|
let restUrl = `${GetRestBaseUrl(siteUrl)}/web?$select=AssociatedOwnerGroup,AssociatedMemberGroup,AssociatedVisitorGroup&$expand=AssociatedOwnerGroup,AssociatedMemberGroup,AssociatedVisitorGroup`;
|
|
1358
1471
|
try {
|
|
1359
|
-
let result = await GetJson(restUrl, null, {
|
|
1472
|
+
let result = await GetJson(restUrl, null, {
|
|
1473
|
+
...longLocalCache, jsonMetadata: jsonTypes.nometadata,
|
|
1474
|
+
spWebUrl: siteUrl //allow getDigest to work when not in SharePoint
|
|
1475
|
+
});
|
|
1360
1476
|
return result;
|
|
1361
1477
|
}
|
|
1362
1478
|
catch {
|