@kwiz/common 1.0.78 → 1.0.80
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/.github/workflows/npm-publish.yml +24 -0
- package/.madgerc +2 -2
- package/LICENSE +21 -21
- package/fix-folder-imports.js +26 -26
- package/lib/cjs/helpers/sharepoint.js +5 -1
- package/lib/cjs/helpers/sharepoint.js.map +1 -1
- package/lib/cjs/helpers/typecheckers.js +5 -1
- package/lib/cjs/helpers/typecheckers.js.map +1 -1
- package/lib/cjs/types/libs/msal.types.js +26 -26
- package/lib/cjs/utils/sharepoint.rest/list.js +1 -1
- package/lib/cjs/utils/sharepoint.rest/list.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/user.js +11 -11
- package/lib/esm/helpers/sharepoint.js +3 -0
- package/lib/esm/helpers/sharepoint.js.map +1 -1
- package/lib/esm/helpers/typecheckers.js +3 -0
- package/lib/esm/helpers/typecheckers.js.map +1 -1
- package/lib/esm/types/libs/msal.types.js +26 -26
- package/lib/esm/utils/sharepoint.rest/list.js +2 -2
- package/lib/esm/utils/sharepoint.rest/list.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/user.js +11 -11
- package/lib/types/helpers/sharepoint.d.ts +1 -0
- package/lib/types/helpers/typecheckers.d.ts +1 -0
- package/package.json +77 -77
- package/readme.md +17 -17
- package/src/_dependencies.ts +12 -12
- package/src/config.ts +17 -17
- package/src/helpers/Guid.ts +181 -181
- package/src/helpers/base64.ts +173 -173
- package/src/helpers/browser.test.js +13 -13
- package/src/helpers/browser.ts +1348 -1348
- package/src/helpers/browserinfo.ts +292 -292
- package/src/helpers/collections.base.test.js +25 -25
- package/src/helpers/collections.base.ts +437 -437
- package/src/helpers/collections.ts +107 -107
- package/src/helpers/color.ts +54 -54
- package/src/helpers/cookies.ts +59 -59
- package/src/helpers/date.test.js +119 -119
- package/src/helpers/date.ts +188 -188
- package/src/helpers/debug.ts +186 -186
- package/src/helpers/emails.ts +6 -6
- package/src/helpers/eval.ts +5 -5
- package/src/helpers/file.test.js +50 -50
- package/src/helpers/file.ts +58 -58
- package/src/helpers/flatted.ts +149 -149
- package/src/helpers/functions.ts +16 -16
- package/src/helpers/graph/calendar.types.ts +10 -10
- package/src/helpers/http.ts +69 -69
- package/src/helpers/images.ts +22 -22
- package/src/helpers/json.ts +38 -38
- package/src/helpers/md5.ts +189 -189
- package/src/helpers/objects.test.js +33 -33
- package/src/helpers/objects.ts +270 -270
- package/src/helpers/promises.test.js +37 -37
- package/src/helpers/promises.ts +165 -165
- package/src/helpers/random.ts +27 -27
- package/src/helpers/scheduler/scheduler.test.js +103 -103
- package/src/helpers/scheduler/scheduler.ts +131 -131
- package/src/helpers/sharepoint.ts +776 -772
- package/src/helpers/strings.test.js +101 -101
- package/src/helpers/strings.ts +317 -317
- package/src/helpers/typecheckers.test.js +34 -34
- package/src/helpers/typecheckers.ts +266 -262
- package/src/helpers/url.test.js +43 -43
- package/src/helpers/url.ts +207 -207
- package/src/helpers/urlhelper.ts +111 -111
- package/src/index.ts +6 -6
- package/src/types/auth.ts +54 -54
- package/src/types/common.types.ts +15 -15
- package/src/types/flatted.types.ts +59 -59
- package/src/types/globals.types.ts +6 -6
- package/src/types/graph/calendar.types.ts +80 -80
- package/src/types/knownscript.types.ts +18 -18
- package/src/types/libs/datajs.types.ts +28 -28
- package/src/types/libs/ics.types.ts +30 -30
- package/src/types/libs/msal.types.ts +49 -49
- package/src/types/locales.ts +124 -124
- package/src/types/localstoragecache.types.ts +8 -8
- package/src/types/location.types.ts +27 -27
- package/src/types/moment.ts +11 -11
- package/src/types/regex.types.ts +16 -16
- package/src/types/rest.types.ts +95 -95
- package/src/types/sharepoint.types.ts +1465 -1465
- package/src/types/sharepoint.utils.types.ts +287 -287
- package/src/utils/auth/common.ts +74 -74
- package/src/utils/auth/discovery.test.js +12 -12
- package/src/utils/auth/discovery.ts +132 -132
- package/src/utils/base64.ts +27 -27
- package/src/utils/consolelogger.ts +320 -320
- package/src/utils/date.ts +35 -35
- package/src/utils/emails.ts +24 -24
- package/src/utils/knownscript.ts +286 -286
- package/src/utils/localstoragecache.ts +441 -441
- package/src/utils/rest.ts +501 -501
- package/src/utils/script.ts +170 -170
- package/src/utils/sharepoint.rest/common.ts +154 -154
- package/src/utils/sharepoint.rest/date.ts +62 -62
- package/src/utils/sharepoint.rest/file.folder.ts +598 -598
- package/src/utils/sharepoint.rest/item.ts +547 -547
- package/src/utils/sharepoint.rest/list.ts +1388 -1388
- package/src/utils/sharepoint.rest/listutils/GetListItemsByCaml.ts +774 -774
- package/src/utils/sharepoint.rest/listutils/GetListItemsById.ts +275 -275
- package/src/utils/sharepoint.rest/listutils/common.ts +206 -206
- package/src/utils/sharepoint.rest/location.ts +141 -141
- package/src/utils/sharepoint.rest/navigation-links.ts +86 -86
- package/src/utils/sharepoint.rest/user-search.ts +252 -252
- package/src/utils/sharepoint.rest/user.ts +491 -491
- package/src/utils/sharepoint.rest/web.ts +1384 -1384
- package/src/utils/sod.ts +194 -194
- package/lib/cjs/helpers/_dependencies.js +0 -21
- package/lib/cjs/helpers/_dependencies.js.map +0 -1
- package/lib/cjs/utils/_dependencies.js +0 -24
- package/lib/cjs/utils/_dependencies.js.map +0 -1
- package/lib/esm/helpers/_dependencies.js +0 -3
- package/lib/esm/helpers/_dependencies.js.map +0 -1
- package/lib/esm/utils/_dependencies.js +0 -4
- package/lib/esm/utils/_dependencies.js.map +0 -1
- package/lib/types/helpers/_dependencies.d.ts +0 -2
- package/lib/types/utils/_dependencies.d.ts +0 -3
|
@@ -1,207 +1,207 @@
|
|
|
1
|
-
import { lastIndexOf, toHash } from "../../../helpers/collections.base";
|
|
2
|
-
import { isNotEmptyArray, isNullOrEmptyString, isNullOrUndefined, isNumber } from "../../../helpers/typecheckers";
|
|
3
|
-
import { IDictionary } from "../../../types/common.types";
|
|
4
|
-
import { jsonTypes } from "../../../types/rest.types";
|
|
5
|
-
import { FileSystemObjectTypes, IFieldInfoEX, IFieldLookupInfo } from "../../../types/sharepoint.types";
|
|
6
|
-
import { GeListItemsFoldersBehaviour, IRestItem } from "../../../types/sharepoint.utils.types";
|
|
7
|
-
import { ConsoleLogger } from "../../consolelogger";
|
|
8
|
-
import { DecodeFieldValuesAsTextKey, GetFieldNameFromRawValues } from "../common";
|
|
9
|
-
import { GetItemsByIdSync } from "./GetListItemsById";
|
|
10
|
-
|
|
11
|
-
const logger = ConsoleLogger.get("sharepoint.rest/list/common");
|
|
12
|
-
|
|
13
|
-
export function __fixGetListItemsResults(siteUrl: string, listIdOrTitle: string, items: IRestItem[], foldersBehaviour?: GeListItemsFoldersBehaviour, expandedLookupFields?: IFieldInfoEX[]): IRestItem[] {
|
|
14
|
-
let folders: { [folderPath: string]: IRestItem; } = {};
|
|
15
|
-
|
|
16
|
-
let itemFileRefMap: IDictionary<{ FileRef: string; FileSystemObjectType: FileSystemObjectTypes }> = {};
|
|
17
|
-
if (isNotEmptyArray(items) && isNullOrUndefined(items[0].FileRef)) {
|
|
18
|
-
//customer support ticket - request was missing teh FileRef column!
|
|
19
|
-
let additionalItems = GetItemsByIdSync(siteUrl, listIdOrTitle, items.map(i => i.Id), {
|
|
20
|
-
select: ["Id", "FileRef", "FileSystemObjectType"],
|
|
21
|
-
jsonMetadata: jsonTypes.nometadata
|
|
22
|
-
});
|
|
23
|
-
itemFileRefMap = toHash(additionalItems, i => i.Id.toString(10));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
items.forEach(item => {
|
|
27
|
-
try {
|
|
28
|
-
if (itemFileRefMap[item.Id]) {
|
|
29
|
-
let mappedValue = itemFileRefMap[item.Id];
|
|
30
|
-
item.FileRef = mappedValue.FileRef;
|
|
31
|
-
item.FileSystemObjectType = mappedValue.FileSystemObjectType;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let fileRef = item.FileRef as string || "";
|
|
35
|
-
let parts = fileRef.split('/');
|
|
36
|
-
item.FileLeafRef = parts.pop() || "";
|
|
37
|
-
item.FileDirRef = parts.join('/');
|
|
38
|
-
item.FileOrFolderName = item.FileLeafRef.split('.')[0];
|
|
39
|
-
|
|
40
|
-
if (item.FileSystemObjectType === 1) {
|
|
41
|
-
item.FileType = "folder";
|
|
42
|
-
item.__Items = [];
|
|
43
|
-
folders[fileRef.toLowerCase()] = item;
|
|
44
|
-
item.__DisplayTitle = item.FileLeafRef;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
//issue 8094 file name might have multiple dots
|
|
48
|
-
let splitDot = item.FileLeafRef.split('.');
|
|
49
|
-
item.FileType = splitDot.length > 1 ? splitDot.pop().toLowerCase() : "folder";
|
|
50
|
-
item.__DisplayTitle = splitDot.join('.');
|
|
51
|
-
if (item.FileType === '000') {
|
|
52
|
-
item.FileType = 'listitem';
|
|
53
|
-
item.__DisplayTitle = item.Title;
|
|
54
|
-
if (isNullOrEmptyString(item.__DisplayTitle))
|
|
55
|
-
item.__DisplayTitle = `Item #${item.Id}`;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (isNotEmptyArray(expandedLookupFields))
|
|
60
|
-
expandedLookupFields.forEach((f: IFieldLookupInfo) => {
|
|
61
|
-
//ISSUE: 1519
|
|
62
|
-
let lookupField = f.LookupField;
|
|
63
|
-
|
|
64
|
-
//ISSUE: 1250 - expanded lookup fields with names that start with '_'
|
|
65
|
-
//will be returned as OData__name. We have to use the field name returned
|
|
66
|
-
//from GetFieldNameFromRawValues without the 'Id' appended to the name because
|
|
67
|
-
//the value has been expanded.
|
|
68
|
-
let fieldInternalName = f.InternalName;
|
|
69
|
-
let rawValue = item[f.InternalName];
|
|
70
|
-
if (isNullOrUndefined(rawValue)) {
|
|
71
|
-
fieldInternalName = GetFieldNameFromRawValues(f, {
|
|
72
|
-
excludeIdFromName: true
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
rawValue = item[fieldInternalName];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (rawValue) {
|
|
79
|
-
item.FieldValuesAsText = item.FieldValuesAsText || {};
|
|
80
|
-
|
|
81
|
-
let value: { Id: number; Title: string;[InternalName: string]: any } | { Id: number; Title: string;[InternalName: string]: any }[] = rawValue;
|
|
82
|
-
if (Array.isArray(value))//multi value
|
|
83
|
-
{
|
|
84
|
-
let id: number[] = [];
|
|
85
|
-
let text: string[] = [];
|
|
86
|
-
value.forEach(v => {
|
|
87
|
-
id.push(v.Id);
|
|
88
|
-
if (!isNullOrEmptyString(lookupField) && !isNullOrUndefined(v[lookupField])) {
|
|
89
|
-
text.push(v[lookupField]);
|
|
90
|
-
} else {
|
|
91
|
-
text.push(v.Title);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
item[`${fieldInternalName}Id`] = id;
|
|
95
|
-
item.FieldValuesAsText[DecodeFieldValuesAsTextKey(fieldInternalName)] = text.join(", ");
|
|
96
|
-
}
|
|
97
|
-
else if (isNumber(value && value.Id)) {
|
|
98
|
-
item[`${fieldInternalName}Id`] = value.Id;
|
|
99
|
-
//ISSUE: 1519 - condition to check if lookup field exists and get the value from the rawValue object by string index of lookup field key
|
|
100
|
-
if (!isNullOrEmptyString(lookupField) && !isNullOrUndefined(value[lookupField])) {
|
|
101
|
-
item.FieldValuesAsText[DecodeFieldValuesAsTextKey(fieldInternalName)] = value[lookupField];
|
|
102
|
-
} else {
|
|
103
|
-
item.FieldValuesAsText[DecodeFieldValuesAsTextKey(fieldInternalName)] = value.Title;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
} catch (e) {
|
|
109
|
-
logger.error(`Failed to fix list item result ${item && item.Id || 'unknown id'}`);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
//loop through items, put them inside folders
|
|
114
|
-
let itemsInRoot: IRestItem[] = [];
|
|
115
|
-
items.forEach(item => {
|
|
116
|
-
let parentFolder = folders[item.FileDirRef.toLowerCase()];
|
|
117
|
-
if (!isNullOrUndefined(parentFolder)) {
|
|
118
|
-
|
|
119
|
-
if (item.FileSystemObjectType === FileSystemObjectTypes.Folder) {
|
|
120
|
-
//add it before any items, so we have folders first (sorted) and items after
|
|
121
|
-
let indexOfLastFolder = lastIndexOf(parentFolder.__Items, i => i.FileSystemObjectType === FileSystemObjectTypes.Folder);
|
|
122
|
-
parentFolder.__Items.splice(indexOfLastFolder + 1, 0, item);
|
|
123
|
-
} else
|
|
124
|
-
parentFolder.__Items.push(item);
|
|
125
|
-
item.__ParentFolder = parentFolder;
|
|
126
|
-
}
|
|
127
|
-
else itemsInRoot.push(item);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
switch (foldersBehaviour) {
|
|
131
|
-
case GeListItemsFoldersBehaviour.AllItemsNoFolders:
|
|
132
|
-
return items.filter(r => r.FileSystemObjectType !== 1);
|
|
133
|
-
case GeListItemsFoldersBehaviour.ItemsInsideFolders:
|
|
134
|
-
return itemsInRoot;
|
|
135
|
-
case GeListItemsFoldersBehaviour.ItemsAndFoldersFlat:
|
|
136
|
-
default:
|
|
137
|
-
return items;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export var SkipFields: string[] = [
|
|
142
|
-
"appauthor",
|
|
143
|
-
"appeditor",
|
|
144
|
-
"linktitle",
|
|
145
|
-
"linktitlenomenu",
|
|
146
|
-
"linkfilename",
|
|
147
|
-
"linkfilenamenomenu",
|
|
148
|
-
"_copysource",
|
|
149
|
-
"_complianceflags",
|
|
150
|
-
"_compliancetag",
|
|
151
|
-
"_compliancetagwrittentime",
|
|
152
|
-
"_compliancetaguserid",
|
|
153
|
-
"_isrecord",
|
|
154
|
-
//issue 5576: allow user to see version column "_uiversionstring",
|
|
155
|
-
"itemchildcount",
|
|
156
|
-
"folderchildcount",
|
|
157
|
-
"complianceassetid",
|
|
158
|
-
"xd_progid",
|
|
159
|
-
"xd_signature",
|
|
160
|
-
"_shortcuturl",
|
|
161
|
-
"_shortcutsiteid",
|
|
162
|
-
"_shortcutwebid",
|
|
163
|
-
"_shortcutuniqueid",
|
|
164
|
-
"_hascopydestinations",
|
|
165
|
-
"sortbehavior",
|
|
166
|
-
"permmask",
|
|
167
|
-
"syncclientid",
|
|
168
|
-
"progid",
|
|
169
|
-
"scopeid",
|
|
170
|
-
"virusstatus",
|
|
171
|
-
"_editmenutablestart",
|
|
172
|
-
"_editmenutablestart2",
|
|
173
|
-
"_editmenutableend",
|
|
174
|
-
"linkfilename2",
|
|
175
|
-
"basename",
|
|
176
|
-
"metainfo",
|
|
177
|
-
"_level",
|
|
178
|
-
"_iscurrentversion",
|
|
179
|
-
"originatorid",
|
|
180
|
-
"noexecute",
|
|
181
|
-
"bsn",
|
|
182
|
-
"_listschemaversion",
|
|
183
|
-
"_dirty",
|
|
184
|
-
"_parsable",
|
|
185
|
-
"_stubfile",
|
|
186
|
-
"_virusstatus",
|
|
187
|
-
"_virusvendorid",
|
|
188
|
-
"_virusinfo",
|
|
189
|
-
"_rmstemplateid",
|
|
190
|
-
"_iplabelid",
|
|
191
|
-
"_displayname",
|
|
192
|
-
"smtotalsize",
|
|
193
|
-
"smlastmodifieddate",
|
|
194
|
-
"smtotalfilestreamsize",
|
|
195
|
-
"smtotalfilecount",
|
|
196
|
-
"selecttitle",
|
|
197
|
-
"selectfilename",
|
|
198
|
-
"edit",
|
|
199
|
-
"workflowversion",
|
|
200
|
-
"workflowinstanceid",
|
|
201
|
-
"parentversionstring",
|
|
202
|
-
"parentleafname",
|
|
203
|
-
"docconcurrencynumber",
|
|
204
|
-
"parentuniqueid",
|
|
205
|
-
"streamhash",
|
|
206
|
-
"combine",
|
|
1
|
+
import { lastIndexOf, toHash } from "../../../helpers/collections.base";
|
|
2
|
+
import { isNotEmptyArray, isNullOrEmptyString, isNullOrUndefined, isNumber } from "../../../helpers/typecheckers";
|
|
3
|
+
import { IDictionary } from "../../../types/common.types";
|
|
4
|
+
import { jsonTypes } from "../../../types/rest.types";
|
|
5
|
+
import { FileSystemObjectTypes, IFieldInfoEX, IFieldLookupInfo } from "../../../types/sharepoint.types";
|
|
6
|
+
import { GeListItemsFoldersBehaviour, IRestItem } from "../../../types/sharepoint.utils.types";
|
|
7
|
+
import { ConsoleLogger } from "../../consolelogger";
|
|
8
|
+
import { DecodeFieldValuesAsTextKey, GetFieldNameFromRawValues } from "../common";
|
|
9
|
+
import { GetItemsByIdSync } from "./GetListItemsById";
|
|
10
|
+
|
|
11
|
+
const logger = ConsoleLogger.get("sharepoint.rest/list/common");
|
|
12
|
+
|
|
13
|
+
export function __fixGetListItemsResults(siteUrl: string, listIdOrTitle: string, items: IRestItem[], foldersBehaviour?: GeListItemsFoldersBehaviour, expandedLookupFields?: IFieldInfoEX[]): IRestItem[] {
|
|
14
|
+
let folders: { [folderPath: string]: IRestItem; } = {};
|
|
15
|
+
|
|
16
|
+
let itemFileRefMap: IDictionary<{ FileRef: string; FileSystemObjectType: FileSystemObjectTypes }> = {};
|
|
17
|
+
if (isNotEmptyArray(items) && isNullOrUndefined(items[0].FileRef)) {
|
|
18
|
+
//customer support ticket - request was missing teh FileRef column!
|
|
19
|
+
let additionalItems = GetItemsByIdSync(siteUrl, listIdOrTitle, items.map(i => i.Id), {
|
|
20
|
+
select: ["Id", "FileRef", "FileSystemObjectType"],
|
|
21
|
+
jsonMetadata: jsonTypes.nometadata
|
|
22
|
+
});
|
|
23
|
+
itemFileRefMap = toHash(additionalItems, i => i.Id.toString(10));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
items.forEach(item => {
|
|
27
|
+
try {
|
|
28
|
+
if (itemFileRefMap[item.Id]) {
|
|
29
|
+
let mappedValue = itemFileRefMap[item.Id];
|
|
30
|
+
item.FileRef = mappedValue.FileRef;
|
|
31
|
+
item.FileSystemObjectType = mappedValue.FileSystemObjectType;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let fileRef = item.FileRef as string || "";
|
|
35
|
+
let parts = fileRef.split('/');
|
|
36
|
+
item.FileLeafRef = parts.pop() || "";
|
|
37
|
+
item.FileDirRef = parts.join('/');
|
|
38
|
+
item.FileOrFolderName = item.FileLeafRef.split('.')[0];
|
|
39
|
+
|
|
40
|
+
if (item.FileSystemObjectType === 1) {
|
|
41
|
+
item.FileType = "folder";
|
|
42
|
+
item.__Items = [];
|
|
43
|
+
folders[fileRef.toLowerCase()] = item;
|
|
44
|
+
item.__DisplayTitle = item.FileLeafRef;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
//issue 8094 file name might have multiple dots
|
|
48
|
+
let splitDot = item.FileLeafRef.split('.');
|
|
49
|
+
item.FileType = splitDot.length > 1 ? splitDot.pop().toLowerCase() : "folder";
|
|
50
|
+
item.__DisplayTitle = splitDot.join('.');
|
|
51
|
+
if (item.FileType === '000') {
|
|
52
|
+
item.FileType = 'listitem';
|
|
53
|
+
item.__DisplayTitle = item.Title;
|
|
54
|
+
if (isNullOrEmptyString(item.__DisplayTitle))
|
|
55
|
+
item.__DisplayTitle = `Item #${item.Id}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (isNotEmptyArray(expandedLookupFields))
|
|
60
|
+
expandedLookupFields.forEach((f: IFieldLookupInfo) => {
|
|
61
|
+
//ISSUE: 1519
|
|
62
|
+
let lookupField = f.LookupField;
|
|
63
|
+
|
|
64
|
+
//ISSUE: 1250 - expanded lookup fields with names that start with '_'
|
|
65
|
+
//will be returned as OData__name. We have to use the field name returned
|
|
66
|
+
//from GetFieldNameFromRawValues without the 'Id' appended to the name because
|
|
67
|
+
//the value has been expanded.
|
|
68
|
+
let fieldInternalName = f.InternalName;
|
|
69
|
+
let rawValue = item[f.InternalName];
|
|
70
|
+
if (isNullOrUndefined(rawValue)) {
|
|
71
|
+
fieldInternalName = GetFieldNameFromRawValues(f, {
|
|
72
|
+
excludeIdFromName: true
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
rawValue = item[fieldInternalName];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (rawValue) {
|
|
79
|
+
item.FieldValuesAsText = item.FieldValuesAsText || {};
|
|
80
|
+
|
|
81
|
+
let value: { Id: number; Title: string;[InternalName: string]: any } | { Id: number; Title: string;[InternalName: string]: any }[] = rawValue;
|
|
82
|
+
if (Array.isArray(value))//multi value
|
|
83
|
+
{
|
|
84
|
+
let id: number[] = [];
|
|
85
|
+
let text: string[] = [];
|
|
86
|
+
value.forEach(v => {
|
|
87
|
+
id.push(v.Id);
|
|
88
|
+
if (!isNullOrEmptyString(lookupField) && !isNullOrUndefined(v[lookupField])) {
|
|
89
|
+
text.push(v[lookupField]);
|
|
90
|
+
} else {
|
|
91
|
+
text.push(v.Title);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
item[`${fieldInternalName}Id`] = id;
|
|
95
|
+
item.FieldValuesAsText[DecodeFieldValuesAsTextKey(fieldInternalName)] = text.join(", ");
|
|
96
|
+
}
|
|
97
|
+
else if (isNumber(value && value.Id)) {
|
|
98
|
+
item[`${fieldInternalName}Id`] = value.Id;
|
|
99
|
+
//ISSUE: 1519 - condition to check if lookup field exists and get the value from the rawValue object by string index of lookup field key
|
|
100
|
+
if (!isNullOrEmptyString(lookupField) && !isNullOrUndefined(value[lookupField])) {
|
|
101
|
+
item.FieldValuesAsText[DecodeFieldValuesAsTextKey(fieldInternalName)] = value[lookupField];
|
|
102
|
+
} else {
|
|
103
|
+
item.FieldValuesAsText[DecodeFieldValuesAsTextKey(fieldInternalName)] = value.Title;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
} catch (e) {
|
|
109
|
+
logger.error(`Failed to fix list item result ${item && item.Id || 'unknown id'}`);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
//loop through items, put them inside folders
|
|
114
|
+
let itemsInRoot: IRestItem[] = [];
|
|
115
|
+
items.forEach(item => {
|
|
116
|
+
let parentFolder = folders[item.FileDirRef.toLowerCase()];
|
|
117
|
+
if (!isNullOrUndefined(parentFolder)) {
|
|
118
|
+
|
|
119
|
+
if (item.FileSystemObjectType === FileSystemObjectTypes.Folder) {
|
|
120
|
+
//add it before any items, so we have folders first (sorted) and items after
|
|
121
|
+
let indexOfLastFolder = lastIndexOf(parentFolder.__Items, i => i.FileSystemObjectType === FileSystemObjectTypes.Folder);
|
|
122
|
+
parentFolder.__Items.splice(indexOfLastFolder + 1, 0, item);
|
|
123
|
+
} else
|
|
124
|
+
parentFolder.__Items.push(item);
|
|
125
|
+
item.__ParentFolder = parentFolder;
|
|
126
|
+
}
|
|
127
|
+
else itemsInRoot.push(item);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
switch (foldersBehaviour) {
|
|
131
|
+
case GeListItemsFoldersBehaviour.AllItemsNoFolders:
|
|
132
|
+
return items.filter(r => r.FileSystemObjectType !== 1);
|
|
133
|
+
case GeListItemsFoldersBehaviour.ItemsInsideFolders:
|
|
134
|
+
return itemsInRoot;
|
|
135
|
+
case GeListItemsFoldersBehaviour.ItemsAndFoldersFlat:
|
|
136
|
+
default:
|
|
137
|
+
return items;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export var SkipFields: string[] = [
|
|
142
|
+
"appauthor",
|
|
143
|
+
"appeditor",
|
|
144
|
+
"linktitle",
|
|
145
|
+
"linktitlenomenu",
|
|
146
|
+
"linkfilename",
|
|
147
|
+
"linkfilenamenomenu",
|
|
148
|
+
"_copysource",
|
|
149
|
+
"_complianceflags",
|
|
150
|
+
"_compliancetag",
|
|
151
|
+
"_compliancetagwrittentime",
|
|
152
|
+
"_compliancetaguserid",
|
|
153
|
+
"_isrecord",
|
|
154
|
+
//issue 5576: allow user to see version column "_uiversionstring",
|
|
155
|
+
"itemchildcount",
|
|
156
|
+
"folderchildcount",
|
|
157
|
+
"complianceassetid",
|
|
158
|
+
"xd_progid",
|
|
159
|
+
"xd_signature",
|
|
160
|
+
"_shortcuturl",
|
|
161
|
+
"_shortcutsiteid",
|
|
162
|
+
"_shortcutwebid",
|
|
163
|
+
"_shortcutuniqueid",
|
|
164
|
+
"_hascopydestinations",
|
|
165
|
+
"sortbehavior",
|
|
166
|
+
"permmask",
|
|
167
|
+
"syncclientid",
|
|
168
|
+
"progid",
|
|
169
|
+
"scopeid",
|
|
170
|
+
"virusstatus",
|
|
171
|
+
"_editmenutablestart",
|
|
172
|
+
"_editmenutablestart2",
|
|
173
|
+
"_editmenutableend",
|
|
174
|
+
"linkfilename2",
|
|
175
|
+
"basename",
|
|
176
|
+
"metainfo",
|
|
177
|
+
"_level",
|
|
178
|
+
"_iscurrentversion",
|
|
179
|
+
"originatorid",
|
|
180
|
+
"noexecute",
|
|
181
|
+
"bsn",
|
|
182
|
+
"_listschemaversion",
|
|
183
|
+
"_dirty",
|
|
184
|
+
"_parsable",
|
|
185
|
+
"_stubfile",
|
|
186
|
+
"_virusstatus",
|
|
187
|
+
"_virusvendorid",
|
|
188
|
+
"_virusinfo",
|
|
189
|
+
"_rmstemplateid",
|
|
190
|
+
"_iplabelid",
|
|
191
|
+
"_displayname",
|
|
192
|
+
"smtotalsize",
|
|
193
|
+
"smlastmodifieddate",
|
|
194
|
+
"smtotalfilestreamsize",
|
|
195
|
+
"smtotalfilecount",
|
|
196
|
+
"selecttitle",
|
|
197
|
+
"selectfilename",
|
|
198
|
+
"edit",
|
|
199
|
+
"workflowversion",
|
|
200
|
+
"workflowinstanceid",
|
|
201
|
+
"parentversionstring",
|
|
202
|
+
"parentleafname",
|
|
203
|
+
"docconcurrencynumber",
|
|
204
|
+
"parentuniqueid",
|
|
205
|
+
"streamhash",
|
|
206
|
+
"combine",
|
|
207
207
|
"repairdocument"];
|