@kwiz/common 1.0.149 → 1.0.151
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/.mocharc.js +12 -0
- package/lib/cjs/_dependencies.js +2 -2
- package/lib/cjs/_dependencies.js.map +1 -1
- package/lib/cjs/config.js +1 -2
- package/lib/cjs/config.js.map +1 -1
- package/lib/cjs/helpers/base64.js +7 -8
- package/lib/cjs/helpers/base64.js.map +1 -1
- package/lib/cjs/helpers/browser.js +80 -93
- package/lib/cjs/helpers/browser.js.map +1 -1
- package/lib/cjs/helpers/browserinfo.js +10 -5
- package/lib/cjs/helpers/browserinfo.js.map +1 -1
- package/lib/cjs/helpers/collections.base.js +33 -34
- package/lib/cjs/helpers/collections.base.js.map +1 -1
- package/lib/cjs/helpers/collections.js +3 -4
- package/lib/cjs/helpers/collections.js.map +1 -1
- package/lib/cjs/helpers/color.js +3 -4
- package/lib/cjs/helpers/color.js.map +1 -1
- package/lib/cjs/helpers/cookies.js +5 -6
- package/lib/cjs/helpers/cookies.js.map +1 -1
- package/lib/cjs/helpers/date.js +17 -17
- package/lib/cjs/helpers/date.js.map +1 -1
- package/lib/cjs/helpers/debug.js +7 -8
- package/lib/cjs/helpers/debug.js.map +1 -1
- package/lib/cjs/helpers/emails.js +2 -2
- package/lib/cjs/helpers/emails.js.map +1 -1
- package/lib/cjs/helpers/eval.js +1 -2
- package/lib/cjs/helpers/eval.js.map +1 -1
- package/lib/cjs/helpers/file.js +4 -4
- package/lib/cjs/helpers/file.js.map +1 -1
- package/lib/cjs/helpers/flatted.js +2 -2
- package/lib/cjs/helpers/flatted.js.map +1 -1
- package/lib/cjs/helpers/functions.js +1 -2
- package/lib/cjs/helpers/functions.js.map +1 -1
- package/lib/cjs/helpers/graph/calendar.types.js +2 -3
- package/lib/cjs/helpers/graph/calendar.types.js.map +1 -1
- package/lib/cjs/helpers/http.js +3 -3
- package/lib/cjs/helpers/http.js.map +1 -1
- package/lib/cjs/helpers/json.js +3 -4
- package/lib/cjs/helpers/json.js.map +1 -1
- package/lib/cjs/helpers/md5.js +5 -2
- package/lib/cjs/helpers/md5.js.map +1 -1
- package/lib/cjs/helpers/objects.js +16 -16
- package/lib/cjs/helpers/objects.js.map +1 -1
- package/lib/cjs/helpers/promises.js +8 -9
- package/lib/cjs/helpers/promises.js.map +1 -1
- package/lib/cjs/helpers/random.js +2 -3
- package/lib/cjs/helpers/random.js.map +1 -1
- package/lib/cjs/helpers/scheduler/scheduler.js +4 -4
- package/lib/cjs/helpers/scheduler/scheduler.js.map +1 -1
- package/lib/cjs/helpers/sharepoint.js +57 -55
- package/lib/cjs/helpers/sharepoint.js.map +1 -1
- package/lib/cjs/helpers/strings.js +29 -30
- package/lib/cjs/helpers/strings.js.map +1 -1
- package/lib/cjs/helpers/typecheckers.js +36 -36
- package/lib/cjs/helpers/typecheckers.js.map +1 -1
- package/lib/cjs/helpers/url.js +14 -15
- package/lib/cjs/helpers/url.js.map +1 -1
- package/lib/cjs/utils/auth/common.js +11 -10
- package/lib/cjs/utils/auth/common.js.map +1 -1
- package/lib/cjs/utils/auth/discovery.js +4 -5
- package/lib/cjs/utils/auth/discovery.js.map +1 -1
- package/lib/cjs/utils/base64.js +1 -2
- package/lib/cjs/utils/base64.js.map +1 -1
- package/lib/cjs/utils/date.js +2 -3
- package/lib/cjs/utils/date.js.map +1 -1
- package/lib/cjs/utils/emails.js +1 -2
- package/lib/cjs/utils/emails.js.map +1 -1
- package/lib/cjs/utils/localstoragecache.js +8 -8
- package/lib/cjs/utils/localstoragecache.js.map +1 -1
- package/lib/cjs/utils/rest.js +52 -42
- package/lib/cjs/utils/rest.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/common.js +32 -27
- package/lib/cjs/utils/sharepoint.rest/common.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/date.js +8 -6
- package/lib/cjs/utils/sharepoint.rest/date.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/file.folder.js +28 -29
- package/lib/cjs/utils/sharepoint.rest/file.folder.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/item.js +33 -32
- package/lib/cjs/utils/sharepoint.rest/item.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/list.js +116 -72
- package/lib/cjs/utils/sharepoint.rest/list.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/listutils/GetListItemsByCaml.js +1 -2
- package/lib/cjs/utils/sharepoint.rest/listutils/GetListItemsByCaml.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/listutils/GetListItemsById.js +2 -3
- package/lib/cjs/utils/sharepoint.rest/listutils/GetListItemsById.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/listutils/common.js +2 -2
- package/lib/cjs/utils/sharepoint.rest/listutils/common.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/location.js +2 -3
- package/lib/cjs/utils/sharepoint.rest/location.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/navigation-links.js +3 -4
- package/lib/cjs/utils/sharepoint.rest/navigation-links.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/user.js +26 -27
- package/lib/cjs/utils/sharepoint.rest/user.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/web.js +109 -73
- package/lib/cjs/utils/sharepoint.rest/web.js.map +1 -1
- package/lib/esm/helpers/browser.js +8 -20
- package/lib/esm/helpers/browser.js.map +1 -1
- package/lib/esm/helpers/browserinfo.js +5 -1
- package/lib/esm/helpers/browserinfo.js.map +1 -1
- package/lib/esm/helpers/md5.js +4 -0
- package/lib/esm/helpers/md5.js.map +1 -1
- package/lib/esm/helpers/sharepoint.js +12 -10
- package/lib/esm/helpers/sharepoint.js.map +1 -1
- package/lib/esm/helpers/typecheckers.js +1 -1
- package/lib/esm/helpers/typecheckers.js.map +1 -1
- package/lib/esm/utils/auth/common.js +7 -5
- package/lib/esm/utils/auth/common.js.map +1 -1
- package/lib/esm/utils/rest.js +48 -38
- package/lib/esm/utils/rest.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/common.js +20 -16
- package/lib/esm/utils/sharepoint.rest/common.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/date.js +7 -4
- package/lib/esm/utils/sharepoint.rest/date.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/item.js +7 -6
- package/lib/esm/utils/sharepoint.rest/item.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/list.js +57 -13
- package/lib/esm/utils/sharepoint.rest/list.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/web.js +46 -9
- package/lib/esm/utils/sharepoint.rest/web.js.map +1 -1
- package/lib/types/helpers/browser.d.ts +1 -1
- package/lib/types/helpers/browserinfo.d.ts +1 -0
- package/lib/types/helpers/sharepoint.d.ts +1 -1
- package/lib/types/utils/sharepoint.rest/common.d.ts +2 -0
- package/lib/types/utils/sharepoint.rest/item.d.ts +4 -1
- package/lib/types/utils/sharepoint.rest/list.d.ts +11 -2
- package/lib/types/utils/sharepoint.rest/web.d.ts +3 -1
- package/package.json +12 -3
- package/test/auth.ts +31 -0
- package/test/hooks.ts +181 -0
- package/test/readme.md +61 -0
- package/test/sp/files-folders.ts +258 -0
- package/test/sp/items.ts +295 -0
- package/test/sp/lists.ts +679 -0
- package/test/sp/users.ts +57 -0
- package/test/sp/webs.ts +43 -0
|
@@ -1,7 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.GetListRestUrl = GetListRestUrl;
|
|
4
|
+
exports.GetListId = GetListId;
|
|
5
|
+
exports.GetListIdFromPageSync = GetListIdFromPageSync;
|
|
6
|
+
exports.EnsureAssetLibrary = EnsureAssetLibrary;
|
|
7
|
+
exports.EnsureSitePagesLibrary = EnsureSitePagesLibrary;
|
|
8
|
+
exports.GetSiteAssetLibrary = GetSiteAssetLibrary;
|
|
9
|
+
exports.GetListTitle = GetListTitle;
|
|
10
|
+
exports.GetList = GetList;
|
|
11
|
+
exports.GetListSync = GetListSync;
|
|
12
|
+
exports.GetListNameSync = GetListNameSync;
|
|
13
|
+
exports.GetListName = GetListName;
|
|
14
|
+
exports.GetListRootFolder = GetListRootFolder;
|
|
15
|
+
exports.GetListRootFolderSync = GetListRootFolderSync;
|
|
16
|
+
exports.GetListField = GetListField;
|
|
17
|
+
exports.GetStandardListFields = GetStandardListFields;
|
|
18
|
+
exports.GetListFields = GetListFields;
|
|
19
|
+
exports.GetListFieldsSync = GetListFieldsSync;
|
|
20
|
+
exports.GetListFieldsAsHash = GetListFieldsAsHash;
|
|
21
|
+
exports.GetListFieldsAsHashSync = GetListFieldsAsHashSync;
|
|
22
|
+
exports.GetListWorkflows = GetListWorkflows;
|
|
23
|
+
exports.GetListEffectiveBasePermissions = GetListEffectiveBasePermissions;
|
|
24
|
+
exports.GetListEffectiveBasePermissionsSync = GetListEffectiveBasePermissionsSync;
|
|
25
|
+
exports.UserHasManagePermissions = UserHasManagePermissions;
|
|
26
|
+
exports.UserHasEditPermissions = UserHasEditPermissions;
|
|
27
|
+
exports.UserHasPermissions = UserHasPermissions;
|
|
28
|
+
exports.UserHasPermissionsSync = UserHasPermissionsSync;
|
|
29
|
+
exports.CreateField = CreateField;
|
|
30
|
+
exports.UpdateField = UpdateField;
|
|
31
|
+
exports.ChangeTextFieldMode = ChangeTextFieldMode;
|
|
32
|
+
exports.ChangeDatetimeFieldMode = ChangeDatetimeFieldMode;
|
|
33
|
+
exports.DeleteField = DeleteField;
|
|
34
|
+
exports.GetListViews = GetListViews;
|
|
35
|
+
exports.GetListViewsSync = GetListViewsSync;
|
|
36
|
+
exports.AddViewFieldToListView = AddViewFieldToListView;
|
|
37
|
+
exports.RemoveViewFieldFromListView = RemoveViewFieldFromListView;
|
|
38
|
+
exports.GetListContentTypes = GetListContentTypes;
|
|
39
|
+
exports.GetListContentTypesSync = GetListContentTypesSync;
|
|
40
|
+
exports.GetListFormUrl = GetListFormUrl;
|
|
41
|
+
exports.GetFieldSchemaSync = GetFieldSchemaSync;
|
|
42
|
+
exports.GetFieldSchema = GetFieldSchema;
|
|
43
|
+
exports.GetListItems = GetListItems;
|
|
44
|
+
exports.GetListItemsSync = GetListItemsSync;
|
|
45
|
+
exports.FindListItemById = FindListItemById;
|
|
46
|
+
exports.GetListEventReceivers = GetListEventReceivers;
|
|
47
|
+
exports.AddListEventReceiver = AddListEventReceiver;
|
|
48
|
+
exports.DeleteListEventReceiver = DeleteListEventReceiver;
|
|
49
|
+
exports.GetListLastItemModifiedDate = GetListLastItemModifiedDate;
|
|
50
|
+
exports.ReloadListLastModified = ReloadListLastModified;
|
|
51
|
+
exports.ListHasUniquePermissions = ListHasUniquePermissions;
|
|
52
|
+
exports.RestoreListPermissionInheritance = RestoreListPermissionInheritance;
|
|
53
|
+
exports.BreakListPermissionInheritance = BreakListPermissionInheritance;
|
|
54
|
+
exports.AssignListPermission = AssignListPermission;
|
|
55
|
+
exports.RemoveListPermission = RemoveListPermission;
|
|
56
|
+
exports.CreateList = CreateList;
|
|
57
|
+
exports.RecycleList = RecycleList;
|
|
58
|
+
exports.DeleteList = DeleteList;
|
|
59
|
+
exports.SearchList = SearchList;
|
|
60
|
+
exports.UpdateListExperience = UpdateListExperience;
|
|
61
|
+
exports.GetListVersionSettings = GetListVersionSettings;
|
|
62
|
+
exports.SetListVersionSettings = SetListVersionSettings;
|
|
5
63
|
const collections_base_1 = require("../../helpers/collections.base");
|
|
6
64
|
const json_1 = require("../../helpers/json");
|
|
7
65
|
const objects_1 = require("../../helpers/objects");
|
|
@@ -24,7 +82,6 @@ function GetListRestUrl(siteUrl, listIdOrTitle) {
|
|
|
24
82
|
let listPart = (0, typecheckers_1.isValidGuid)(listId) ? `getById('${(0, strings_1.normalizeGuid)(listId)}')` : `getByTitle('${encodeURIComponent(listIdOrTitle)}')`;
|
|
25
83
|
return (0, common_1.GetRestBaseUrl)(siteUrl) + `/web/lists/${listPart}`;
|
|
26
84
|
}
|
|
27
|
-
exports.GetListRestUrl = GetListRestUrl;
|
|
28
85
|
function GetListId(siteUrl, listIdOrTitle) {
|
|
29
86
|
if ((0, typecheckers_1.isNullOrEmptyString)(listIdOrTitle))
|
|
30
87
|
return null;
|
|
@@ -40,7 +97,6 @@ function GetListId(siteUrl, listIdOrTitle) {
|
|
|
40
97
|
var list = (0, collections_base_1.firstOrNull)(lists, l => l.Title.toLowerCase() === lower);
|
|
41
98
|
return list && list.Id || null;
|
|
42
99
|
}
|
|
43
|
-
exports.GetListId = GetListId;
|
|
44
100
|
/** get the list ID from a list page, such as a list view or an item form */
|
|
45
101
|
function GetListIdFromPageSync(siteUrl, listPageUrl) {
|
|
46
102
|
let url = `${(0, common_1.GetRestBaseUrl)(siteUrl)}/web/getlist('${(0, url_1.makeServerRelativeUrl)(listPageUrl.split('?')[0].split('#')[0])}')?$select=id`;
|
|
@@ -54,7 +110,6 @@ function GetListIdFromPageSync(siteUrl, listPageUrl) {
|
|
|
54
110
|
}
|
|
55
111
|
return null;
|
|
56
112
|
}
|
|
57
|
-
exports.GetListIdFromPageSync = GetListIdFromPageSync;
|
|
58
113
|
/** ensures the site assets library exists and return its info. on errors - it will return null. */
|
|
59
114
|
function EnsureAssetLibrary(siteUrl) {
|
|
60
115
|
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
@@ -72,7 +127,6 @@ function EnsureAssetLibrary(siteUrl) {
|
|
|
72
127
|
return null;
|
|
73
128
|
}).catch(() => null);
|
|
74
129
|
}
|
|
75
|
-
exports.EnsureAssetLibrary = EnsureAssetLibrary;
|
|
76
130
|
/** ensures the site pages library exists and return its info. on errors - it will return null. */
|
|
77
131
|
async function EnsureSitePagesLibrary(siteUrl) {
|
|
78
132
|
let url = `${(0, common_1.GetRestBaseUrl)(siteUrl)}/web/lists/EnsureSitePagesLibrary`
|
|
@@ -92,7 +146,6 @@ async function EnsureSitePagesLibrary(siteUrl) {
|
|
|
92
146
|
}
|
|
93
147
|
return null;
|
|
94
148
|
}
|
|
95
|
-
exports.EnsureSitePagesLibrary = EnsureSitePagesLibrary;
|
|
96
149
|
function GetSiteAssetLibrary(siteUrl, sync) {
|
|
97
150
|
let reqUrl = `${(0, common_1.GetRestBaseUrl)(siteUrl)}/web/lists?`
|
|
98
151
|
//Issue 1492: isSiteAssetsLibrary eq true does not work for reader users.
|
|
@@ -117,7 +170,6 @@ function GetSiteAssetLibrary(siteUrl, sync) {
|
|
|
117
170
|
else
|
|
118
171
|
return result.success ? transform(result.result) : null;
|
|
119
172
|
}
|
|
120
|
-
exports.GetSiteAssetLibrary = GetSiteAssetLibrary;
|
|
121
173
|
/** Return the list Title */
|
|
122
174
|
function GetListTitle(siteUrl, listIdOrTitle) {
|
|
123
175
|
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
@@ -127,7 +179,6 @@ function GetListTitle(siteUrl, listIdOrTitle) {
|
|
|
127
179
|
})
|
|
128
180
|
.catch(() => null);
|
|
129
181
|
}
|
|
130
|
-
exports.GetListTitle = GetListTitle;
|
|
131
182
|
/** Return the list */
|
|
132
183
|
function GetList(siteUrlOrId, listIdOrTitle, options, refreshCache = false) {
|
|
133
184
|
let siteUrl = (0, common_1.GetSiteUrl)(siteUrlOrId);
|
|
@@ -174,7 +225,6 @@ function GetList(siteUrlOrId, listIdOrTitle, options, refreshCache = false) {
|
|
|
174
225
|
})
|
|
175
226
|
.catch(() => null);
|
|
176
227
|
}
|
|
177
|
-
exports.GetList = GetList;
|
|
178
228
|
/** Return the list */
|
|
179
229
|
function GetListSync(siteUrl, listIdOrTitle) {
|
|
180
230
|
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
@@ -196,17 +246,14 @@ function GetListSync(siteUrl, listIdOrTitle) {
|
|
|
196
246
|
else
|
|
197
247
|
return null;
|
|
198
248
|
}
|
|
199
|
-
exports.GetListSync = GetListSync;
|
|
200
249
|
function GetListNameSync(webUrl, listIdOrTitle) {
|
|
201
250
|
let list = GetListSync(webUrl, listIdOrTitle);
|
|
202
251
|
return (0, sharepoint_1.NormalizeListName)({ EntityTypeName: list.EntityTypeName, BaseType: list.BaseType });
|
|
203
252
|
}
|
|
204
|
-
exports.GetListNameSync = GetListNameSync;
|
|
205
253
|
async function GetListName(webUrl, listIdOrTitle) {
|
|
206
254
|
let list = await GetList(webUrl, listIdOrTitle);
|
|
207
255
|
return (0, sharepoint_1.NormalizeListName)({ EntityTypeName: list.EntityTypeName, BaseType: list.BaseType });
|
|
208
256
|
}
|
|
209
|
-
exports.GetListName = GetListName;
|
|
210
257
|
function GetListRootFolder(siteUrlOrId, listIdOrTitle) {
|
|
211
258
|
let siteUrl = (0, common_1.GetSiteUrl)(siteUrlOrId);
|
|
212
259
|
return (0, rest_1.GetJson)(GetListRestUrl(siteUrl, listIdOrTitle) + `/RootFolder?$Select=Name,ServerRelativeUrl`, null, rest_1.longLocalCache)
|
|
@@ -215,13 +262,11 @@ function GetListRootFolder(siteUrlOrId, listIdOrTitle) {
|
|
|
215
262
|
})
|
|
216
263
|
.catch(() => null);
|
|
217
264
|
}
|
|
218
|
-
exports.GetListRootFolder = GetListRootFolder;
|
|
219
265
|
function GetListRootFolderSync(siteUrlOrId, listIdOrTitle) {
|
|
220
266
|
let siteUrl = (0, common_1.GetSiteUrl)(siteUrlOrId);
|
|
221
267
|
let result = (0, rest_1.GetJsonSync)(GetListRestUrl(siteUrl, listIdOrTitle) + `/RootFolder?$Select=Name,ServerRelativeUrl`, null, rest_1.longLocalCache);
|
|
222
268
|
return (0, typecheckers_1.SafeIfElse)(() => result.result.d, null);
|
|
223
269
|
}
|
|
224
|
-
exports.GetListRootFolderSync = GetListRootFolderSync;
|
|
225
270
|
function GetListField(siteUrlOrId, listIdOrTitle, fieldIdOrName, refreshCache) {
|
|
226
271
|
let siteUrl = (0, common_1.GetSiteUrl)(siteUrlOrId);
|
|
227
272
|
var url = GetListRestUrl(siteUrl, listIdOrTitle) + `/fields`;
|
|
@@ -238,7 +283,6 @@ function GetListField(siteUrlOrId, listIdOrTitle, fieldIdOrName, refreshCache) {
|
|
|
238
283
|
.catch(() => null);
|
|
239
284
|
return result;
|
|
240
285
|
}
|
|
241
|
-
exports.GetListField = GetListField;
|
|
242
286
|
function _getListFieldsRequestUrl(siteUrl, listIdOrTitle) {
|
|
243
287
|
return GetListRestUrl(siteUrl, listIdOrTitle) + `/fields`;
|
|
244
288
|
}
|
|
@@ -247,7 +291,6 @@ function GetStandardListFields(siteUrlOrId, listIdOrTitle, refreshCache) {
|
|
|
247
291
|
let fieldNames = ["ID", "Title", "ContentType", "Author", "Editor", "Created", "Modified"];
|
|
248
292
|
return GetListFields(siteUrlOrId, listIdOrTitle, { refreshCache: refreshCache, fieldNames: fieldNames });
|
|
249
293
|
}
|
|
250
|
-
exports.GetStandardListFields = GetStandardListFields;
|
|
251
294
|
function _processGetListFields(fields, fieldNames) {
|
|
252
295
|
if ((0, typecheckers_1.isNullOrEmptyArray)(fields)) {
|
|
253
296
|
return fields;
|
|
@@ -274,7 +317,6 @@ function GetListFields(siteUrlOrId, listIdOrTitle, options = {}) {
|
|
|
274
317
|
return null;
|
|
275
318
|
});
|
|
276
319
|
}
|
|
277
|
-
exports.GetListFields = GetListFields;
|
|
278
320
|
function GetListFieldsSync(siteUrlOrId, listIdOrTitle, options = {}) {
|
|
279
321
|
let siteUrl = (0, common_1.GetSiteUrl)(siteUrlOrId);
|
|
280
322
|
let url = _getListFieldsRequestUrl(siteUrl, listIdOrTitle);
|
|
@@ -288,7 +330,6 @@ function GetListFieldsSync(siteUrlOrId, listIdOrTitle, options = {}) {
|
|
|
288
330
|
}
|
|
289
331
|
return null;
|
|
290
332
|
}
|
|
291
|
-
exports.GetListFieldsSync = GetListFieldsSync;
|
|
292
333
|
async function GetListFieldsAsHash(siteUrlOrId, listIdOrTitle, refreshCache) {
|
|
293
334
|
let siteUrl = (0, common_1.GetSiteUrl)(siteUrlOrId);
|
|
294
335
|
let fields = await GetListFields(siteUrl, listIdOrTitle, { refreshCache: refreshCache });
|
|
@@ -298,7 +339,6 @@ async function GetListFieldsAsHash(siteUrlOrId, listIdOrTitle, refreshCache) {
|
|
|
298
339
|
}
|
|
299
340
|
return hash;
|
|
300
341
|
}
|
|
301
|
-
exports.GetListFieldsAsHash = GetListFieldsAsHash;
|
|
302
342
|
function GetListFieldsAsHashSync(siteUrlOrId, listIdOrTitle, refreshCache) {
|
|
303
343
|
let siteUrl = (0, common_1.GetSiteUrl)(siteUrlOrId);
|
|
304
344
|
let fields = GetListFieldsSync(siteUrl, listIdOrTitle, { refreshCache: refreshCache });
|
|
@@ -308,7 +348,6 @@ function GetListFieldsAsHashSync(siteUrlOrId, listIdOrTitle, refreshCache) {
|
|
|
308
348
|
}
|
|
309
349
|
return hash;
|
|
310
350
|
}
|
|
311
|
-
exports.GetListFieldsAsHashSync = GetListFieldsAsHashSync;
|
|
312
351
|
function GetListWorkflows(siteUrl, listIdOrTitle, refreshCache) {
|
|
313
352
|
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
314
353
|
return (0, rest_1.GetJson)(GetListRestUrl(siteUrl, listIdOrTitle) + `/workflowAssociations`, null, { allowCache: refreshCache !== true })
|
|
@@ -327,40 +366,33 @@ function GetListWorkflows(siteUrl, listIdOrTitle, refreshCache) {
|
|
|
327
366
|
})
|
|
328
367
|
.catch(() => []);
|
|
329
368
|
}
|
|
330
|
-
exports.GetListWorkflows = GetListWorkflows;
|
|
331
369
|
async function GetListEffectiveBasePermissions(siteUrlOrId, listIdOrTitle) {
|
|
332
370
|
let siteUrl = (0, common_1.GetSiteUrl)(siteUrlOrId);
|
|
333
371
|
let response = await (0, rest_1.GetJson)(GetListRestUrl(siteUrl, listIdOrTitle) + `/EffectiveBasePermissions`, null, { ...rest_1.shortLocalCache });
|
|
334
372
|
return response.d.EffectiveBasePermissions;
|
|
335
373
|
}
|
|
336
|
-
exports.GetListEffectiveBasePermissions = GetListEffectiveBasePermissions;
|
|
337
374
|
function GetListEffectiveBasePermissionsSync(siteUrlOrId, listIdOrTitle) {
|
|
338
375
|
let siteUrl = (0, common_1.GetSiteUrl)(siteUrlOrId);
|
|
339
376
|
let response = (0, rest_1.GetJsonSync)(GetListRestUrl(siteUrl, listIdOrTitle) + `/EffectiveBasePermissions`, null, { ...rest_1.shortLocalCache });
|
|
340
377
|
return response.result.d.EffectiveBasePermissions;
|
|
341
378
|
}
|
|
342
|
-
exports.GetListEffectiveBasePermissionsSync = GetListEffectiveBasePermissionsSync;
|
|
343
379
|
function UserHasManagePermissions(siteUrlOrId, listIdOrTitle) {
|
|
344
380
|
return GetListEffectiveBasePermissions(siteUrlOrId, listIdOrTitle).then((effectiveBasePermissions) => {
|
|
345
381
|
return new sharepoint_1.SPBasePermissions(effectiveBasePermissions).has(sharepoint_types_1.SPBasePermissionKind.ManageLists);
|
|
346
382
|
}).catch(() => null);
|
|
347
383
|
}
|
|
348
|
-
exports.UserHasManagePermissions = UserHasManagePermissions;
|
|
349
384
|
function UserHasEditPermissions(siteUrlOrId, listIdOrTitle) {
|
|
350
385
|
return UserHasPermissions(siteUrlOrId, listIdOrTitle, sharepoint_types_1.SPBasePermissionKind.EditListItems);
|
|
351
386
|
}
|
|
352
|
-
exports.UserHasEditPermissions = UserHasEditPermissions;
|
|
353
387
|
function UserHasPermissions(siteUrlOrId, listIdOrTitle, permissionKind) {
|
|
354
388
|
return GetListEffectiveBasePermissions(siteUrlOrId, listIdOrTitle).then((effectiveBasePermissions) => {
|
|
355
389
|
return new sharepoint_1.SPBasePermissions(effectiveBasePermissions).has(permissionKind);
|
|
356
390
|
}).catch(() => null);
|
|
357
391
|
}
|
|
358
|
-
exports.UserHasPermissions = UserHasPermissions;
|
|
359
392
|
function UserHasPermissionsSync(siteUrlOrId, listIdOrTitle, permissionKind) {
|
|
360
393
|
let effectiveBasePermissions = GetListEffectiveBasePermissionsSync(siteUrlOrId, listIdOrTitle);
|
|
361
394
|
return new sharepoint_1.SPBasePermissions(effectiveBasePermissions).has(permissionKind);
|
|
362
395
|
}
|
|
363
|
-
exports.UserHasPermissionsSync = UserHasPermissionsSync;
|
|
364
396
|
/** create a new column and try to add it to default view. Send either Title and Type, or SchemaXml. Create with SchemaXml also adds to all content types */
|
|
365
397
|
async function CreateField(siteUrl, listIdOrTitle, options) {
|
|
366
398
|
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
@@ -373,12 +405,19 @@ async function CreateField(siteUrl, listIdOrTitle, options) {
|
|
|
373
405
|
let fields = await GetListFields(siteUrl, listIdOrTitle, { refreshCache: true });
|
|
374
406
|
try {
|
|
375
407
|
if (options.SkipAddToDefaultView !== true) {
|
|
376
|
-
|
|
377
|
-
|
|
408
|
+
if (options.AwaitAddToDefaultView === true) {
|
|
409
|
+
const views = await GetListViews(siteUrl, listIdOrTitle);
|
|
378
410
|
let defaultView = (0, collections_base_1.firstOrNull)(views, v => v.DefaultView);
|
|
379
411
|
if (defaultView)
|
|
380
|
-
(0, rest_1.GetJson)(GetListRestUrl(siteUrl, listIdOrTitle) + `/views('${defaultView.Id}')/ViewFields/addViewField('${internalName}')`, null, { method: "POST", spWebUrl: siteUrl });
|
|
381
|
-
}
|
|
412
|
+
await (0, rest_1.GetJson)(GetListRestUrl(siteUrl, listIdOrTitle) + `/views('${defaultView.Id}')/ViewFields/addViewField('${internalName}')`, null, { method: "POST", spWebUrl: siteUrl });
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
GetListViews(siteUrl, listIdOrTitle).then(views => {
|
|
416
|
+
let defaultView = (0, collections_base_1.firstOrNull)(views, v => v.DefaultView);
|
|
417
|
+
if (defaultView)
|
|
418
|
+
(0, rest_1.GetJson)(GetListRestUrl(siteUrl, listIdOrTitle) + `/views('${defaultView.Id}')/ViewFields/addViewField('${internalName}')`, null, { method: "POST", spWebUrl: siteUrl });
|
|
419
|
+
});
|
|
420
|
+
}
|
|
382
421
|
}
|
|
383
422
|
}
|
|
384
423
|
catch (e) { }
|
|
@@ -445,7 +484,6 @@ async function CreateField(siteUrl, listIdOrTitle, options) {
|
|
|
445
484
|
return null;
|
|
446
485
|
}
|
|
447
486
|
}
|
|
448
|
-
exports.CreateField = CreateField;
|
|
449
487
|
/** Update field SchemaXml OR Title, only 1 update at a time supported. */
|
|
450
488
|
async function UpdateField(siteUrlOrId, listIdOrTitle, fieldInternalName, options) {
|
|
451
489
|
let siteUrl = (0, common_1.GetSiteUrl)(siteUrlOrId);
|
|
@@ -521,7 +559,6 @@ async function UpdateField(siteUrlOrId, listIdOrTitle, fieldInternalName, option
|
|
|
521
559
|
return null;
|
|
522
560
|
}
|
|
523
561
|
}
|
|
524
|
-
exports.UpdateField = UpdateField;
|
|
525
562
|
async function ChangeTextFieldMode(siteUrlOrId, listIdOrTitle, textMode, currentField) {
|
|
526
563
|
const newSchema = (0, objects_1.jsonClone)(currentField.SchemaJson);
|
|
527
564
|
const currentSchemaAttributes = newSchema.Attributes;
|
|
@@ -571,7 +608,6 @@ async function ChangeTextFieldMode(siteUrlOrId, listIdOrTitle, textMode, current
|
|
|
571
608
|
// If object is null or undefined then request has failed.
|
|
572
609
|
return !(0, typecheckers_1.isNullOrUndefined)(fieldUpdated);
|
|
573
610
|
}
|
|
574
|
-
exports.ChangeTextFieldMode = ChangeTextFieldMode;
|
|
575
611
|
async function ChangeDatetimeFieldMode(siteUrlOrId, listIdOrTitle, includeTime, currentField) {
|
|
576
612
|
const dateTimeFormat = 'DateTime';
|
|
577
613
|
const dateOnlyFormat = 'DateOnly';
|
|
@@ -596,7 +632,6 @@ async function ChangeDatetimeFieldMode(siteUrlOrId, listIdOrTitle, includeTime,
|
|
|
596
632
|
// If an already existing format was chosen.
|
|
597
633
|
return true;
|
|
598
634
|
}
|
|
599
|
-
exports.ChangeDatetimeFieldMode = ChangeDatetimeFieldMode;
|
|
600
635
|
async function DeleteField(siteUrl, listIdOrTitle, fieldInternalName, options) {
|
|
601
636
|
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
602
637
|
// let finish = async () => {
|
|
@@ -613,7 +648,6 @@ async function DeleteField(siteUrl, listIdOrTitle, fieldInternalName, options) {
|
|
|
613
648
|
.then(r => true)
|
|
614
649
|
.catch((e) => false);
|
|
615
650
|
}
|
|
616
|
-
exports.DeleteField = DeleteField;
|
|
617
651
|
function GetListViews(siteUrl, listIdOrTitle, options, refreshCache = false) {
|
|
618
652
|
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
619
653
|
let url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/views?$select=Title,Id,ServerRelativeUrl,RowLimit,Paged,ViewQuery,ListViewXml,PersonalView,MobileView,MobileDefaultView,Hidden,DefaultView,ReadOnlyView${options && options.includeViewFields ? "&$expand=ViewFields" : ""}`;
|
|
@@ -632,7 +666,6 @@ function GetListViews(siteUrl, listIdOrTitle, options, refreshCache = false) {
|
|
|
632
666
|
})
|
|
633
667
|
.catch(() => null);
|
|
634
668
|
}
|
|
635
|
-
exports.GetListViews = GetListViews;
|
|
636
669
|
function GetListViewsSync(siteUrl, listIdOrTitle, options, refreshCache = false) {
|
|
637
670
|
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
638
671
|
let url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/views?$select=Title,Id,ServerRelativeUrl,RowLimit,Paged,ViewQuery,ListViewXml,PersonalView,MobileView,MobileDefaultView,Hidden,DefaultView,ReadOnlyView${options && options.includeViewFields ? "&$expand=ViewFields" : ""}`;
|
|
@@ -646,21 +679,18 @@ function GetListViewsSync(siteUrl, listIdOrTitle, options, refreshCache = false)
|
|
|
646
679
|
}
|
|
647
680
|
return null;
|
|
648
681
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
return _addOrRemoveViewField(siteUrl, listIdOrTitle, viewId, viewField, "addviewfield");
|
|
682
|
+
async function AddViewFieldToListView(siteUrl, listIdOrTitle, viewId, viewField, refreshCache = false) {
|
|
683
|
+
return _addOrRemoveViewField(siteUrl, listIdOrTitle, viewId, viewField, "addviewfield", refreshCache);
|
|
652
684
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
return _addOrRemoveViewField(siteUrl, listIdOrTitle, viewId, viewField, "removeviewfield");
|
|
685
|
+
async function RemoveViewFieldFromListView(siteUrl, listIdOrTitle, viewId, viewField, refreshCache = false) {
|
|
686
|
+
return _addOrRemoveViewField(siteUrl, listIdOrTitle, viewId, viewField, "removeviewfield", refreshCache);
|
|
656
687
|
}
|
|
657
|
-
|
|
658
|
-
async function _addOrRemoveViewField(siteUrl, listIdOrTitle, viewId, viewField, action) {
|
|
688
|
+
async function _addOrRemoveViewField(siteUrl, listIdOrTitle, viewId, viewField, action, refreshCache) {
|
|
659
689
|
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
660
690
|
if ((0, typecheckers_1.isNullOrEmptyString)(viewField) || !(0, typecheckers_1.isValidGuid)(viewId)) {
|
|
661
691
|
return false;
|
|
662
692
|
}
|
|
663
|
-
let views = await GetListViews(siteUrl, listIdOrTitle, { includeViewFields: true });
|
|
693
|
+
let views = await GetListViews(siteUrl, listIdOrTitle, { includeViewFields: true }, refreshCache);
|
|
664
694
|
if ((0, typecheckers_1.isNullOrEmptyArray)(views)) {
|
|
665
695
|
return false;
|
|
666
696
|
}
|
|
@@ -679,8 +709,8 @@ async function _addOrRemoveViewField(siteUrl, listIdOrTitle, viewId, viewField,
|
|
|
679
709
|
}
|
|
680
710
|
try {
|
|
681
711
|
let url = GetListRestUrl(siteUrl, listIdOrTitle) + `/views('${(0, strings_1.normalizeGuid)(view.Id)}')/viewfields/${action}('${viewField}')`;
|
|
682
|
-
let result = await (0, rest_1.GetJson)(url, null, { method: "POST" });
|
|
683
|
-
if (result && result
|
|
712
|
+
let result = await (0, rest_1.GetJson)(url, null, { method: "POST", allowCache: false });
|
|
713
|
+
if (result && (result.d.AddViewField === null || result.d.RemoveViewField === null)) {
|
|
684
714
|
return true;
|
|
685
715
|
}
|
|
686
716
|
}
|
|
@@ -690,11 +720,9 @@ async function _addOrRemoveViewField(siteUrl, listIdOrTitle, viewId, viewField,
|
|
|
690
720
|
function GetListContentTypes(siteUrl, listIdOrTitle, options, refreshCache = false) {
|
|
691
721
|
return (0, web_1.GetContentTypes)(siteUrl, { ...(options || {}), listIdOrTitle: listIdOrTitle }, refreshCache);
|
|
692
722
|
}
|
|
693
|
-
exports.GetListContentTypes = GetListContentTypes;
|
|
694
723
|
function GetListContentTypesSync(siteUrl, listIdOrTitle, options, refreshCache = false) {
|
|
695
724
|
return (0, web_1.GetContentTypesSync)(siteUrl, { ...(options || {}), listIdOrTitle: listIdOrTitle }, refreshCache);
|
|
696
725
|
}
|
|
697
|
-
exports.GetListContentTypesSync = GetListContentTypesSync;
|
|
698
726
|
/** generic version. for the KWIZ forms version that supports action id call GetListFormUrlAppsWeb instead */
|
|
699
727
|
function GetListFormUrl(siteUrl, listId, pageType, params) {
|
|
700
728
|
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
@@ -711,7 +739,6 @@ function GetListFormUrl(siteUrl, listId, pageType, params) {
|
|
|
711
739
|
}
|
|
712
740
|
return url;
|
|
713
741
|
}
|
|
714
|
-
exports.GetListFormUrl = GetListFormUrl;
|
|
715
742
|
function GetFieldSchemaSync(siteUrl, listIdOrTitle, fieldInternalName, refreshCache) {
|
|
716
743
|
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
717
744
|
//ISSUE: 1516 - The get schema request will fail if the field doesn't exist in the list, so we load the fields and ensure the field
|
|
@@ -739,7 +766,6 @@ function GetFieldSchemaSync(siteUrl, listIdOrTitle, fieldInternalName, refreshCa
|
|
|
739
766
|
// return null;
|
|
740
767
|
//#endregion
|
|
741
768
|
}
|
|
742
|
-
exports.GetFieldSchemaSync = GetFieldSchemaSync;
|
|
743
769
|
async function GetFieldSchema(siteUrl, listIdOrTitle, fieldInternalName, refreshCache) {
|
|
744
770
|
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
745
771
|
//ISSUE: 1516 - The get schema request will fail if the field doesn't exist in the list, so we load the fields and ensure the field
|
|
@@ -754,7 +780,6 @@ async function GetFieldSchema(siteUrl, listIdOrTitle, fieldInternalName, refresh
|
|
|
754
780
|
let field = fields[0];
|
|
755
781
|
return (0, sharepoint_1.SchemaXmlToJson)(field.SchemaXml);
|
|
756
782
|
}
|
|
757
|
-
exports.GetFieldSchema = GetFieldSchema;
|
|
758
783
|
async function GetListItems(siteUrl, listIdOrTitle, options) {
|
|
759
784
|
let info = _GetListItemsInfo(siteUrl, listIdOrTitle, options);
|
|
760
785
|
let items = [];
|
|
@@ -785,7 +810,6 @@ async function GetListItems(siteUrl, listIdOrTitle, options) {
|
|
|
785
810
|
} while (!(0, typecheckers_1.isNullOrEmptyString)(info.requestUrl));
|
|
786
811
|
return (0, common_2.__fixGetListItemsResults)(siteUrl, listIdOrTitle, items, options.foldersBehaviour, info.expandedLookupFields);
|
|
787
812
|
}
|
|
788
|
-
exports.GetListItems = GetListItems;
|
|
789
813
|
function GetListItemsSync(siteUrl, listIdOrTitle, options) {
|
|
790
814
|
let info = _GetListItemsInfo(siteUrl, listIdOrTitle, options);
|
|
791
815
|
let items = [];
|
|
@@ -815,7 +839,6 @@ function GetListItemsSync(siteUrl, listIdOrTitle, options) {
|
|
|
815
839
|
} while (!(0, typecheckers_1.isNullOrEmptyString)(info.requestUrl));
|
|
816
840
|
return (0, common_2.__fixGetListItemsResults)(siteUrl, listIdOrTitle, items, options.foldersBehaviour, info.expandedLookupFields);
|
|
817
841
|
}
|
|
818
|
-
exports.GetListItemsSync = GetListItemsSync;
|
|
819
842
|
function _GetListItemsInfo(siteUrl, listIdOrTitle, options) {
|
|
820
843
|
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
821
844
|
let url = GetListRestUrl(siteUrl, listIdOrTitle) + `/items`;
|
|
@@ -886,7 +909,6 @@ function FindListItemById(items, itemId) {
|
|
|
886
909
|
//not found
|
|
887
910
|
return null;
|
|
888
911
|
}
|
|
889
|
-
exports.FindListItemById = FindListItemById;
|
|
890
912
|
function _getListEventReceiversRequestUrl(siteUrl, listIdOrTitle) {
|
|
891
913
|
return GetListRestUrl(siteUrl, listIdOrTitle) + `/EventReceivers`;
|
|
892
914
|
}
|
|
@@ -903,7 +925,6 @@ async function GetListEventReceivers(siteUrl, listIdOrTitle, refreshCache) {
|
|
|
903
925
|
}
|
|
904
926
|
return null;
|
|
905
927
|
}
|
|
906
|
-
exports.GetListEventReceivers = GetListEventReceivers;
|
|
907
928
|
async function AddListEventReceiver(siteUrl, listIdOrTitle, eventReceiverDefinition) {
|
|
908
929
|
let newEventReceiver = {
|
|
909
930
|
ReceiverAssembly: "",
|
|
@@ -926,7 +947,6 @@ async function AddListEventReceiver(siteUrl, listIdOrTitle, eventReceiverDefinit
|
|
|
926
947
|
}
|
|
927
948
|
return null;
|
|
928
949
|
}
|
|
929
|
-
exports.AddListEventReceiver = AddListEventReceiver;
|
|
930
950
|
async function DeleteListEventReceiver(siteUrl, listIdOrTitle, eventReceiverId) {
|
|
931
951
|
try {
|
|
932
952
|
let url = `${_getListEventReceiversRequestUrl(siteUrl, listIdOrTitle)}('${(0, strings_1.normalizeGuid)(eventReceiverId)}')/deleteObject`;
|
|
@@ -941,7 +961,6 @@ async function DeleteListEventReceiver(siteUrl, listIdOrTitle, eventReceiverId)
|
|
|
941
961
|
}
|
|
942
962
|
return false;
|
|
943
963
|
}
|
|
944
|
-
exports.DeleteListEventReceiver = DeleteListEventReceiver;
|
|
945
964
|
function GetListLastItemModifiedDate(siteUrl, listIdOrTitle, options) {
|
|
946
965
|
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
947
966
|
let endPoint = options && options.userChangesOnly ? 'LastItemUserModifiedDate' : 'LastItemModifiedDate';
|
|
@@ -957,7 +976,6 @@ function GetListLastItemModifiedDate(siteUrl, listIdOrTitle, options) {
|
|
|
957
976
|
else
|
|
958
977
|
return result.success ? result.result.value : null;
|
|
959
978
|
}
|
|
960
|
-
exports.GetListLastItemModifiedDate = GetListLastItemModifiedDate;
|
|
961
979
|
async function ReloadListLastModified(siteUrl, listIdOrTitle) {
|
|
962
980
|
await GetListLastItemModifiedDate(siteUrl, listIdOrTitle, { refreshCache: true });
|
|
963
981
|
//make sure we do it for both title and id, we don't know how the other callers may use this in their API
|
|
@@ -976,33 +994,27 @@ async function ReloadListLastModified(siteUrl, listIdOrTitle) {
|
|
|
976
994
|
catch (e) { }
|
|
977
995
|
}
|
|
978
996
|
}
|
|
979
|
-
exports.ReloadListLastModified = ReloadListLastModified;
|
|
980
997
|
async function ListHasUniquePermissions(siteUrl, listIdOrTitle) {
|
|
981
998
|
let url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/?$select=hasuniqueroleassignments`;
|
|
982
999
|
let has = await (0, rest_1.GetJson)(url, undefined, { allowCache: false, jsonMetadata: rest_types_1.jsonTypes.nometadata });
|
|
983
1000
|
return has.HasUniqueRoleAssignments === true;
|
|
984
1001
|
}
|
|
985
|
-
exports.ListHasUniquePermissions = ListHasUniquePermissions;
|
|
986
1002
|
async function RestoreListPermissionInheritance(siteUrl, listIdOrTitle) {
|
|
987
1003
|
let url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/ResetRoleInheritance`;
|
|
988
1004
|
await (0, rest_1.GetJson)(url, undefined, { method: "POST", allowCache: false, jsonMetadata: rest_types_1.jsonTypes.nometadata, spWebUrl: siteUrl });
|
|
989
1005
|
}
|
|
990
|
-
exports.RestoreListPermissionInheritance = RestoreListPermissionInheritance;
|
|
991
1006
|
async function BreakListPermissionInheritance(siteUrl, listIdOrTitle, clear = true) {
|
|
992
1007
|
let url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/breakroleinheritance(copyRoleAssignments=${clear ? 'false' : 'true'}, clearSubscopes=true)`;
|
|
993
1008
|
await (0, rest_1.GetJson)(url, undefined, { method: "POST", allowCache: false, jsonMetadata: rest_types_1.jsonTypes.nometadata, spWebUrl: siteUrl });
|
|
994
1009
|
}
|
|
995
|
-
exports.BreakListPermissionInheritance = BreakListPermissionInheritance;
|
|
996
1010
|
async function AssignListPermission(siteUrl, listIdOrTitle, principalId, roleId) {
|
|
997
1011
|
let url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/roleassignments/addroleassignment(principalid=${principalId},roleDefId=${roleId})`;
|
|
998
1012
|
await (0, rest_1.GetJson)(url, undefined, { method: "POST", allowCache: false, jsonMetadata: rest_types_1.jsonTypes.nometadata, spWebUrl: siteUrl });
|
|
999
1013
|
}
|
|
1000
|
-
exports.AssignListPermission = AssignListPermission;
|
|
1001
1014
|
async function RemoveListPermission(siteUrl, listIdOrTitle, principalId, roleId) {
|
|
1002
1015
|
let url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/roleassignments/removeroleassignment(principalid=${principalId},roleDefId=${roleId})`;
|
|
1003
1016
|
await (0, rest_1.GetJson)(url, undefined, { method: "POST", allowCache: false, jsonMetadata: rest_types_1.jsonTypes.nometadata, spWebUrl: siteUrl });
|
|
1004
1017
|
}
|
|
1005
|
-
exports.RemoveListPermission = RemoveListPermission;
|
|
1006
1018
|
async function CreateList(siteUrl, info) {
|
|
1007
1019
|
let url = `${(0, common_1.GetRestBaseUrl)(siteUrl)}/web/lists`;
|
|
1008
1020
|
const body = {
|
|
@@ -1018,7 +1030,43 @@ async function CreateList(siteUrl, info) {
|
|
|
1018
1030
|
(0, strings_1.normalizeGuid)(newList.Id);
|
|
1019
1031
|
return newList;
|
|
1020
1032
|
}
|
|
1021
|
-
|
|
1033
|
+
async function RecycleList(siteUrl, listIdOrTitle) {
|
|
1034
|
+
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
1035
|
+
const url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/recycle()`;
|
|
1036
|
+
const result = { recycled: true };
|
|
1037
|
+
try {
|
|
1038
|
+
await (0, rest_1.GetJson)(url, null, {
|
|
1039
|
+
method: "POST",
|
|
1040
|
+
allowCache: false,
|
|
1041
|
+
jsonMetadata: rest_types_1.jsonTypes.nometadata,
|
|
1042
|
+
spWebUrl: siteUrl
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
catch (e) {
|
|
1046
|
+
result.recycled = false;
|
|
1047
|
+
result.errorMessage = (0, common_1.__getSPRestErrorData)(e).message;
|
|
1048
|
+
}
|
|
1049
|
+
return result;
|
|
1050
|
+
}
|
|
1051
|
+
async function DeleteList(siteUrl, listIdOrTitle) {
|
|
1052
|
+
siteUrl = (0, common_1.GetSiteUrl)(siteUrl);
|
|
1053
|
+
const url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/deleteObject`;
|
|
1054
|
+
const result = { deleted: true };
|
|
1055
|
+
try {
|
|
1056
|
+
await (0, rest_1.GetJson)(url, null, {
|
|
1057
|
+
method: "POST",
|
|
1058
|
+
xHttpMethod: "DELETE",
|
|
1059
|
+
allowCache: false,
|
|
1060
|
+
jsonMetadata: rest_types_1.jsonTypes.nometadata,
|
|
1061
|
+
spWebUrl: siteUrl
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
catch (e) {
|
|
1065
|
+
result.deleted = false;
|
|
1066
|
+
result.errorMessage = (0, common_1.__getSPRestErrorData)(e).message;
|
|
1067
|
+
}
|
|
1068
|
+
return result;
|
|
1069
|
+
}
|
|
1022
1070
|
async function SearchList(siteUrl, listIdOrTitle, query) {
|
|
1023
1071
|
let listId = GetListId(siteUrl, listIdOrTitle);
|
|
1024
1072
|
let url = `${(0, common_1.GetRestBaseUrl)(siteUrl)}/search/query?querytext='(${query}*)'&querytemplate='{searchTerms} (NormListID:${listId})'`;
|
|
@@ -1057,7 +1105,6 @@ async function SearchList(siteUrl, listIdOrTitle, query) {
|
|
|
1057
1105
|
}
|
|
1058
1106
|
return [];
|
|
1059
1107
|
}
|
|
1060
|
-
exports.SearchList = SearchList;
|
|
1061
1108
|
async function UpdateListExperience(siteUrl, listId, experience) {
|
|
1062
1109
|
try {
|
|
1063
1110
|
let url = GetListRestUrl(siteUrl, listId);
|
|
@@ -1075,7 +1122,6 @@ async function UpdateListExperience(siteUrl, listId, experience) {
|
|
|
1075
1122
|
}
|
|
1076
1123
|
return false;
|
|
1077
1124
|
}
|
|
1078
|
-
exports.UpdateListExperience = UpdateListExperience;
|
|
1079
1125
|
async function GetListVersionSettings(siteUrlOrId, listIdOrTitle, options) {
|
|
1080
1126
|
let siteUrl = (0, common_1.GetSiteUrl)(siteUrlOrId);
|
|
1081
1127
|
if ((0, typecheckers_1.isNullOrEmptyString)(listIdOrTitle))
|
|
@@ -1092,7 +1138,6 @@ async function GetListVersionSettings(siteUrlOrId, listIdOrTitle, options) {
|
|
|
1092
1138
|
return result_1;
|
|
1093
1139
|
}
|
|
1094
1140
|
}
|
|
1095
|
-
exports.GetListVersionSettings = GetListVersionSettings;
|
|
1096
1141
|
async function SetListVersionSettings(siteUrlOrId, listIdOrTitle, options) {
|
|
1097
1142
|
let siteUrl = (0, common_1.GetSiteUrl)(siteUrlOrId);
|
|
1098
1143
|
if ((0, typecheckers_1.isNullOrEmptyString)(listIdOrTitle))
|
|
@@ -1138,5 +1183,4 @@ async function SetListVersionSettings(siteUrlOrId, listIdOrTitle, options) {
|
|
|
1138
1183
|
return result;
|
|
1139
1184
|
}
|
|
1140
1185
|
}
|
|
1141
|
-
exports.SetListVersionSettings = SetListVersionSettings;
|
|
1142
1186
|
//# sourceMappingURL=list.js.map
|