@kwiz/common 1.0.132 → 1.0.133

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.
Files changed (98) hide show
  1. package/package.json +1 -1
  2. package/.github/workflows/npm-publish.yml +0 -24
  3. package/src/_dependencies.ts +0 -13
  4. package/src/config.ts +0 -19
  5. package/src/exports-index.ts +0 -4
  6. package/src/helpers/Guid.ts +0 -182
  7. package/src/helpers/base64.ts +0 -174
  8. package/src/helpers/browser.test.js +0 -13
  9. package/src/helpers/browser.ts +0 -1505
  10. package/src/helpers/browserinfo.ts +0 -293
  11. package/src/helpers/collections.base.test.js +0 -26
  12. package/src/helpers/collections.base.ts +0 -438
  13. package/src/helpers/collections.ts +0 -108
  14. package/src/helpers/color.ts +0 -55
  15. package/src/helpers/cookies.ts +0 -60
  16. package/src/helpers/date.test.js +0 -120
  17. package/src/helpers/date.ts +0 -189
  18. package/src/helpers/debug.ts +0 -187
  19. package/src/helpers/diagrams.ts +0 -44
  20. package/src/helpers/emails.ts +0 -7
  21. package/src/helpers/eval.ts +0 -5
  22. package/src/helpers/exports-index.ts +0 -30
  23. package/src/helpers/file.test.js +0 -51
  24. package/src/helpers/file.ts +0 -64
  25. package/src/helpers/flatted.ts +0 -150
  26. package/src/helpers/functions.ts +0 -17
  27. package/src/helpers/graph/calendar.types.ts +0 -11
  28. package/src/helpers/graph/exports-index.ts +0 -1
  29. package/src/helpers/http.ts +0 -70
  30. package/src/helpers/images.ts +0 -23
  31. package/src/helpers/json.ts +0 -45
  32. package/src/helpers/md5.ts +0 -190
  33. package/src/helpers/objects.test.js +0 -34
  34. package/src/helpers/objects.ts +0 -275
  35. package/src/helpers/promises.test.js +0 -38
  36. package/src/helpers/promises.ts +0 -166
  37. package/src/helpers/random.ts +0 -27
  38. package/src/helpers/scheduler/exports-index.ts +0 -1
  39. package/src/helpers/scheduler/scheduler.test.js +0 -104
  40. package/src/helpers/scheduler/scheduler.ts +0 -132
  41. package/src/helpers/sharepoint.ts +0 -797
  42. package/src/helpers/strings.test.js +0 -123
  43. package/src/helpers/strings.ts +0 -338
  44. package/src/helpers/typecheckers.test.js +0 -35
  45. package/src/helpers/typecheckers.ts +0 -267
  46. package/src/helpers/url.test.js +0 -44
  47. package/src/helpers/url.ts +0 -208
  48. package/src/helpers/urlhelper.ts +0 -112
  49. package/src/index.ts +0 -6
  50. package/src/types/auth.ts +0 -63
  51. package/src/types/common.types.ts +0 -16
  52. package/src/types/exports-index.ts +0 -15
  53. package/src/types/flatted.types.ts +0 -60
  54. package/src/types/globals.types.ts +0 -7
  55. package/src/types/graph/calendar.types.ts +0 -81
  56. package/src/types/graph/exports-index.ts +0 -1
  57. package/src/types/knownscript.types.ts +0 -19
  58. package/src/types/libs/datajs.types.ts +0 -29
  59. package/src/types/libs/exports-index.ts +0 -3
  60. package/src/types/libs/ics.types.ts +0 -31
  61. package/src/types/libs/msal.types.ts +0 -58
  62. package/src/types/locales.ts +0 -126
  63. package/src/types/localstoragecache.types.ts +0 -9
  64. package/src/types/location.types.ts +0 -28
  65. package/src/types/moment.ts +0 -12
  66. package/src/types/regex.types.ts +0 -17
  67. package/src/types/rest.types.ts +0 -96
  68. package/src/types/sharepoint.types.ts +0 -1467
  69. package/src/types/sharepoint.utils.types.ts +0 -307
  70. package/src/utils/auth/common.ts +0 -119
  71. package/src/utils/auth/discovery.test.js +0 -13
  72. package/src/utils/auth/discovery.ts +0 -132
  73. package/src/utils/auth/exports-index.ts +0 -2
  74. package/src/utils/base64.ts +0 -28
  75. package/src/utils/consolelogger.ts +0 -334
  76. package/src/utils/date.ts +0 -173
  77. package/src/utils/emails.ts +0 -25
  78. package/src/utils/exports-index.ts +0 -11
  79. package/src/utils/knownscript.ts +0 -287
  80. package/src/utils/localstoragecache.ts +0 -447
  81. package/src/utils/rest.ts +0 -502
  82. package/src/utils/script.ts +0 -171
  83. package/src/utils/sharepoint.rest/common.ts +0 -160
  84. package/src/utils/sharepoint.rest/date.ts +0 -63
  85. package/src/utils/sharepoint.rest/exports-index.ts +0 -11
  86. package/src/utils/sharepoint.rest/file.folder.ts +0 -685
  87. package/src/utils/sharepoint.rest/item.ts +0 -547
  88. package/src/utils/sharepoint.rest/list.ts +0 -1572
  89. package/src/utils/sharepoint.rest/listutils/GetListItemsByCaml.ts +0 -775
  90. package/src/utils/sharepoint.rest/listutils/GetListItemsById.ts +0 -275
  91. package/src/utils/sharepoint.rest/listutils/common.ts +0 -207
  92. package/src/utils/sharepoint.rest/listutils/exports-index.ts +0 -3
  93. package/src/utils/sharepoint.rest/location.ts +0 -142
  94. package/src/utils/sharepoint.rest/navigation-links.ts +0 -87
  95. package/src/utils/sharepoint.rest/user-search.ts +0 -253
  96. package/src/utils/sharepoint.rest/user.ts +0 -559
  97. package/src/utils/sharepoint.rest/web.ts +0 -1385
  98. package/src/utils/sod.ts +0 -195
@@ -1,275 +0,0 @@
1
- import { chunkArray } from "../../../helpers/collections.base";
2
- import { getGlobal, jsonClone } from "../../../helpers/objects";
3
- import { isBoolean, isNotEmptyArray, isNullOrEmptyArray, isNullOrUndefined, isNumber } from "../../../helpers/typecheckers";
4
- import { jsonTypes } from "../../../types/rest.types";
5
- import { IRestItem } from "../../../types/sharepoint.utils.types";
6
- import { GetJson, GetJsonSync } from "../../rest";
7
- import { GetListRestUrl } from "../list";
8
-
9
- function _getGlobalCache() {
10
- let _cache = getGlobal<{ getItemsByIdCache: { [cachekey: string]: IRestItem[]; }; }>("SharePoint_Rest_List_Cache", {
11
- getItemsByIdCache: {}
12
- });
13
- return _cache;
14
- }
15
-
16
- /** return array will use the item ID as indexer, not a real array */
17
- export async function GetItemsById<T extends IRestItem>(siteUrl: string, listIdOrTitle: string, itemIds: number[], options?: {
18
- expand?: string[];
19
- select?: string[];
20
- refreshCache?: boolean;
21
- jsonMetadata?: jsonTypes;
22
- }) {
23
- try {
24
- let baseParams = _parseItemsByIdParams<T>(siteUrl, listIdOrTitle, itemIds, { ...options, batchRequests: itemIds.length > 1 });
25
-
26
- const { results, allowCache, queue } = baseParams;
27
- let cacheKey = baseParams.cacheKey;
28
-
29
- if (options && !isNullOrUndefined(options.jsonMetadata)) {
30
- cacheKey += "|jsonMetadata=" + options.jsonMetadata
31
- }
32
-
33
- if (queue.length > 0) {
34
- let promises = queue.map(batchRequestUrl => {
35
- return GetJson<tGetItemsByIdResult<T>>(batchRequestUrl, null, {
36
- //do not allow cache. modern forms have apply option which will need this to reload the item
37
- //it is cached in _restListItems anyways so this is not needed.
38
- allowCache: allowCache === true,
39
- includeDigestInGet: true,
40
- jsonMetadata: options && options.jsonMetadata
41
- }).then(obj => {
42
- if (!isNullOrUndefined(obj)) {
43
- //no-metadata will return a value, as a single result or array
44
- //otherwise, it'll go into "d"
45
- let items: T[] = [];
46
-
47
- if (isNoMetaDataResult(obj)) {
48
- items = isNotEmptyArray(obj.value)
49
- ? obj.value
50
- : [obj.value];
51
- }
52
- else if (isVerboseResult(obj)) {
53
- items = Array.isArray(obj.d.results)
54
- ? obj.d.results
55
- : [obj.d];
56
- }
57
- else if (isSingleResult(obj)) {
58
- // Issue 1471: If only single item returns it not an array and just object
59
- items.push(obj);
60
- }
61
-
62
- items.forEach((restItem) => {
63
- results[Number(restItem.Id)] = restItem;
64
- _addCacheItem(cacheKey, restItem);
65
- });
66
- }
67
- });
68
- });
69
-
70
- await Promise.all(promises);
71
- }
72
-
73
- return results;
74
- } catch (e) {
75
- throw new Error("Could not retrieve rest item from list");
76
- }
77
- }
78
-
79
- export function GetItemsByIdSync<T extends IRestItem>(siteUrl: string, listIdOrTitle: string, itemIds: number[], options?: {
80
- expand?: string[];
81
- select?: string[];
82
- refreshCache?: boolean;
83
- jsonMetadata?: jsonTypes;
84
- }) {
85
- try {
86
- let baseParams = _parseItemsByIdParams<T>(siteUrl, listIdOrTitle, itemIds, { ...options, batchRequests: itemIds.length > 1 });
87
-
88
- const { results, allowCache, queue } = baseParams;
89
- let cacheKey = baseParams.cacheKey;
90
-
91
- if (options && !isNullOrUndefined(options.jsonMetadata)) {
92
- cacheKey += "|jsonMetadata=" + options.jsonMetadata
93
- }
94
-
95
- if (queue.length > 0) {
96
- queue.forEach((batchRequestUrl) => {
97
- let response = GetJsonSync<tGetItemsByIdResult<T>>(batchRequestUrl, null, {
98
- //do not allow cache. modern forms have apply option which will need this to reload the item
99
- //it is cached in _restListItems anyways so this is not needed.
100
- allowCache: allowCache === true,
101
- includeDigestInGet: true,
102
- jsonMetadata: options && options.jsonMetadata
103
- });
104
-
105
- if (response && response.success && response.result) {
106
- //no-metadata will return a value, as a single result or array
107
- //otherwise, it'll go into "d"
108
- let items: T[] = [];
109
- if (isNoMetaDataResult(response.result)) {
110
- items = isNotEmptyArray(response.result.value)
111
- ? response.result.value
112
- : [response.result.value];
113
- }
114
- else if (isVerboseResult(response.result)) {
115
- items = Array.isArray(response.result.d.results)
116
- ? response.result.d.results
117
- : [response.result.d];
118
- }
119
- else if (isSingleResult(response.result)) {
120
- // Issue 1471: If only single item returns it not an array and just object
121
- items.push(response.result);
122
- }
123
-
124
- items.forEach((restItem) => {
125
- results[Number(restItem.Id)] = restItem;
126
- _addCacheItem(cacheKey, restItem);
127
- });
128
- }
129
- });
130
- }
131
-
132
- return results;
133
- } catch (e) {
134
- throw new Error("Could not retrieve rest item from list");
135
- }
136
- }
137
-
138
- function _addCacheItem<T extends IRestItem>(cacheKey: string, item: T) {
139
- let g_cache = _getGlobalCache();
140
- if (isNullOrUndefined(g_cache.getItemsByIdCache[cacheKey])) {
141
- g_cache.getItemsByIdCache[cacheKey] = [];
142
- }
143
- g_cache.getItemsByIdCache[cacheKey][item.Id] = jsonClone(item);
144
- }
145
-
146
- function _getCacheItem<T extends IRestItem>(cacheKey: string, itemId: number) {
147
- let g_cache = _getGlobalCache();
148
- if (isNullOrUndefined(g_cache.getItemsByIdCache[cacheKey])) {
149
- g_cache.getItemsByIdCache[cacheKey] = [];
150
- }
151
-
152
- if (!isNullOrUndefined(g_cache.getItemsByIdCache[cacheKey][Number(itemId)])) {
153
- return jsonClone(g_cache.getItemsByIdCache[cacheKey][Number(itemId)]) as T;
154
- }
155
-
156
- return null;
157
- }
158
-
159
- function _refreshCache(cacheKey: string) {
160
- let g_cache = _getGlobalCache();
161
- g_cache.getItemsByIdCache[cacheKey] = [];
162
- }
163
-
164
- function _getItemsByIdBaseUrl(siteUrl: string, listIdOrTitle: string) {
165
- return `${GetListRestUrl(siteUrl, listIdOrTitle)}/items`;
166
- }
167
-
168
- function _parseItemsByIdParams<T extends IRestItem>(siteUrl: string, listIdOrTitle: string, itemIds: number[], options?: {
169
- expand?: string[];
170
- select?: string[];
171
- refreshCache?: boolean;
172
- batchRequests?: boolean;
173
- }) {
174
- let baseUrl = _getItemsByIdBaseUrl(siteUrl, listIdOrTitle);
175
-
176
- let expand: string[] = [];
177
- let select: string[] = [];
178
- let allowCache = true;
179
- let results: T[] = [];
180
- let queue: string[] = [];
181
-
182
- if (!isNullOrUndefined(options)) {
183
- if (!isNullOrEmptyArray(options.select)) {
184
- select = options.select.sort();
185
- }
186
-
187
- if (!isNullOrEmptyArray(options.expand)) {
188
- expand = options.expand.sort();
189
- }
190
-
191
- if (isBoolean(options.refreshCache)) {
192
- allowCache = options.refreshCache !== true;
193
- }
194
- }
195
-
196
- let cacheKey = [baseUrl, select.join(",").toLowerCase(), expand.join(",").toLowerCase()].join("|");
197
-
198
- if (allowCache === true) {
199
- itemIds.forEach((itemId) => {
200
- let cachedItem = _getCacheItem<T>(cacheKey, itemId);
201
- if (!isNullOrUndefined(cachedItem)) {
202
- results[itemId] = cachedItem;
203
- }
204
- });
205
- } else {
206
- _refreshCache(cacheKey);
207
- }
208
-
209
- //remove item ids that were retrieved from cache
210
- itemIds = itemIds.filter((itemId) => {
211
- return !results.some((result) => {
212
- return Number(itemId) === Number(result.Id);
213
- });
214
- });
215
-
216
- if (itemIds.length !== 0) {
217
- let selectExpand: string[] = [];
218
-
219
- if (select.length) {
220
- selectExpand.push(`$select=${select.join(",")}`);
221
- }
222
- if (expand.length) {
223
- selectExpand.push(`$expand=${expand.join(",")}`);
224
- }
225
-
226
- let selectExpandQS = selectExpand.join("&");
227
-
228
- if (options.batchRequests === false) {
229
- itemIds.forEach((itemId) => {
230
- let getItemsRequestUrl = `${baseUrl}(${itemId})?${selectExpandQS}`;
231
- queue.push(getItemsRequestUrl);
232
- });
233
- } else {
234
- let chunks = chunkArray(itemIds, 60);
235
- for (var chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
236
- let chunk = chunks[chunkIndex];
237
-
238
- let filter = chunk.map((id) => {
239
- return `(ID eq ${id})`;
240
- }).join("or");
241
-
242
- let getItemsRequestUrl = `${baseUrl}?${[`$filter=${filter}`, selectExpandQS].join("&")}`;
243
- queue.push(getItemsRequestUrl);
244
- }
245
- }
246
- }
247
-
248
- return {
249
- results: results,
250
- allowCache: allowCache,
251
- queue: queue,
252
- cacheKey: cacheKey
253
- };
254
- }
255
-
256
- type tGetItemsByIdResult_Single<T> = T;
257
- type tGetItemsByIdResult_Verbose<T> = {
258
- d: T | {
259
- results: T[];
260
- }
261
- }
262
- type tGetItemsByIdResult_NoMetadata<T> = {
263
- value: T | T[]
264
- }
265
- type tGetItemsByIdResult<T> = tGetItemsByIdResult_Single<T> | tGetItemsByIdResult_Verbose<T> | tGetItemsByIdResult_NoMetadata<T>;
266
-
267
- function isVerboseResult<T extends IRestItem>(result: tGetItemsByIdResult<T>): result is tGetItemsByIdResult_Verbose<T> {
268
- return !isNullOrUndefined((result as tGetItemsByIdResult_Verbose<T>).d);
269
- }
270
- function isNoMetaDataResult<T extends IRestItem>(result: tGetItemsByIdResult<T>): result is tGetItemsByIdResult_NoMetadata<T> {
271
- return !isNullOrUndefined((result as tGetItemsByIdResult_NoMetadata<T>).value);
272
- }
273
- function isSingleResult<T extends IRestItem>(result: tGetItemsByIdResult<T>): result is tGetItemsByIdResult_Single<T> {
274
- return isNumber((result as tGetItemsByIdResult_Single<T>).Id);
275
- }
@@ -1,207 +0,0 @@
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
- "repairdocument"];
@@ -1,3 +0,0 @@
1
- export * from './GetListItemsByCaml';
2
- export * from './GetListItemsById';
3
- export * from './common';
@@ -1,142 +0,0 @@
1
- import { waitFor } from "../../helpers/browser";
2
- import { isNullOrEmptyArray, isNullOrEmptyString, isNullOrUndefined, isTypeofFullNameUndefined } from "../../helpers/typecheckers";
3
- import { SPFxAuthTokenType } from "../../types/auth";
4
- import { IMeetingLocation, IMeetingLocationEntityType } from "../../types/location.types";
5
- import { jsonTypes } from "../../types/rest.types";
6
- import { GetSPFxClientAuthToken } from "../auth/common";
7
- import { GetJson, shortLocalCache } from "../rest";
8
-
9
- interface IMeetingLocationsQuery {
10
- QueryConstraint: {
11
- Query: string;
12
- Id?: string;
13
- ResolveAvailability?: boolean;
14
- };
15
- LocationProvider: 32 | 8;
16
- BingMarket?: string;
17
- }
18
-
19
- interface IMeetingLocationResult {
20
- LocationType: IMeetingLocationEntityType
21
- RelevanceHint: string;
22
- RelevanceScore: number;
23
- MeetingLocation: IMeetingLocation;
24
- }
25
-
26
- interface IMeetingLocationsResponse {
27
- MeetingLocations: IMeetingLocationResult[],
28
- EmptyLocationsHint: string;
29
- }
30
-
31
- async function _findMeetingLocations(options: { bingUri: string; query: string }) {
32
- if (isNullOrUndefined(options) || (isNullOrEmptyString(options.bingUri) && isNullOrEmptyString(options.query))) {
33
- return null;
34
- }
35
-
36
- let contextReady = await waitFor(() => {
37
- return !isTypeofFullNameUndefined("_spPageContextInfo");
38
- });
39
-
40
- if (!contextReady) {
41
- return null;
42
- }
43
-
44
- let authToken = await GetSPFxClientAuthToken(_spPageContextInfo.webServerRelativeUrl, SPFxAuthTokenType.Outlook);
45
-
46
- if (isNullOrEmptyString(authToken)) {
47
- return null;
48
- }
49
-
50
- const { query, bingUri } = options;
51
-
52
- let useBingUri = !isNullOrEmptyString(bingUri);
53
-
54
- let queryData: IMeetingLocationsQuery = {
55
- QueryConstraint: {
56
- Query: useBingUri === true ? "" : query,
57
- Id: useBingUri === true ? bingUri : undefined,
58
- ResolveAvailability: useBingUri === true ? false : undefined
59
- },
60
- LocationProvider: useBingUri ? 8 : 32,
61
- BingMarket: _spPageContextInfo.currentCultureName
62
- };
63
-
64
- let url = "https://outlook.office365.com/SchedulingB2/api/v1.0/me/findmeetinglocations";
65
- let result = await GetJson<IMeetingLocationsResponse>(
66
- url,
67
- JSON.stringify(queryData),
68
- {
69
- ...shortLocalCache,
70
- postCacheKey: `${queryData.BingMarket}|${queryData.LocationProvider}|${useBingUri ? queryData.QueryConstraint.Id : queryData.QueryConstraint.Query}`,
71
- includeDigestInPost: false,
72
- headers: {
73
- "Accept": jsonTypes.verbose,
74
- "Authorization": `Bearer ${authToken}`,
75
- "content-type": jsonTypes.verbose,
76
- "x-anchormailbox": _spPageContextInfo.userEmail.toLowerCase(),
77
- "x-findmeetinglocations-appname": "sharepoint",
78
- "x-findmeetinglocations-appscenario": "locationfield",
79
- }
80
- });
81
-
82
- if (!isNullOrUndefined(result) && !isNullOrEmptyArray(result.MeetingLocations)) {
83
- let value = result.MeetingLocations.map((loc) => {
84
- return loc.MeetingLocation;
85
- });
86
- return value;
87
- }
88
-
89
- return null;
90
- }
91
-
92
- /**
93
- * Get meeting locations using outlook.office365.com/SchedulingB2/api/v1.0/me/findmeetinglocations
94
- * @param query The term to search for
95
- * @returns An array of meeting locations (https://learn.microsoft.com/en-us/graph/api/resources/location?view=graph-rest-1.0) sorted by relevance score
96
- */
97
- export async function FindMeetingLocations(query: string) {
98
- let results = await _findMeetingLocations({ query: query, bingUri: null });
99
- return !isNullOrEmptyArray(results) ? results : null;
100
- }
101
-
102
- /**
103
- * Resolve meeting locations using outlook.office365.com/SchedulingB2/api/v1.0/me/findmeetinglocations
104
- * @param bingUri The LocationUri for the meeting location
105
- * @returns A single meeting location
106
- */
107
- export async function ResolveLocationFromBingUri(bingUri: string) {
108
- let results = await _findMeetingLocations({ query: null, bingUri: bingUri });
109
- return !isNullOrEmptyArray(results) ? results[0] : null;
110
- }
111
-
112
- //example response
113
- //{
114
- // "MeetingLocations":
115
- // [{
116
- // "MeetingLocation":
117
- // {
118
- // "EntityType": "LocalBusiness",
119
- // "LocationSource": "Bing",
120
- // "LocationUri":
121
- // "https://www.bingapis.com/api/v6/localbusinesses/YN1226x25906078?setLang=en-CA",
122
- // "UniqueId": "https://www.bingapis.com/api/v6/localbusinesses/YN1226x25906078?setLang=en-CA",
123
- // "IsPreviouslyUsed": false, "DisplayName": "The Home Depot",
124
- // "Address": {
125
- // "Street": "99 Cross Ave",
126
- // "City": "Oakville", "State": "ON", "CountryOrRegion": "Canada", "PostalCode": "L6J 2W7"
127
- // }, "Coordinates": { "Latitude": 43.4548, "Longitude": -79.6886 }
128
- // },
129
- // "LocationType": "LocalBusiness",
130
- // "RelevanceScore": -20.0,
131
- // "RelevanceHint": "NonHistory"
132
- // },
133
- // {
134
- // "MeetingLocation":
135
- // {
136
- // "EntityType": "LocalBusiness", "LocationSource": "Bing",
137
- // "LocationUri": "https://www.bingapis.com/api/v6/localbusinesses/YN1226x262267234?setLang=en-CA",
138
- // "UniqueId": "https://www.bingapis.com/api/v6/localbusinesses/YN1226x262267234?setLang=en-CA", "IsPreviouslyUsed": false, "DisplayName": "The Home Depot", "Address": { "Street": "3300 South Service Rd W", "City": "Oakville", "State": "ON", "CountryOrRegion": "Canada", "PostalCode": "L6L 0B1" }, "Coordinates": { "Latitude": 43.3994, "Longitude": -79.7496 }
139
- // }, "LocationType": "LocalBusiness", "RelevanceScore": -20.0, "RelevanceHint": "NonHistory"
140
- // }, { "MeetingLocation": { "EntityType": "LocalBusiness", "LocationSource": "Bing", "LocationUri": "https://www.bingapis.com/api/v6/localbusinesses/YN1227x25906192?setLang=en-CA", "UniqueId": "https://www.bingapis.com/api/v6/localbusinesses/YN1227x25906192?setLang=en-CA", "IsPreviouslyUsed": false, "DisplayName": "The Home Depot", "Address": { "Street": "3050 Davidson Crt", "City": "Burlington", "State": "ON", "CountryOrRegion": "Canada", "PostalCode": "L7M 4M9" }, "Coordinates": { "Latitude": 43.3557, "Longitude": -79.8067 } }, "LocationType": "LocalBusiness", "RelevanceScore": -20.0, "RelevanceHint": "NonHistory" }, { "MeetingLocation": { "EntityType": "LocalBusiness", "LocationSource": "Bing", "LocationUri": "https://www.bingapis.com/api/v6/localbusinesses/YN1226x15474422097876230312?setLang=en-CA", "UniqueId": "https://www.bingapis.com/api/v6/localbusinesses/YN1226x15474422097876230312?setLang=en-CA", "IsPreviouslyUsed": false, "DisplayName": "The Home Depot", "Address": { "Street": "2555 Bristol Circle", "City": "Oakville", "State": "ON", "CountryOrRegion": "Canada", "PostalCode": "L6H 5W9" }, "Coordinates": { "Latitude": 43.518, "Longitude": -79.6847 } }, "LocationType": "LocalBusiness", "RelevanceScore": -20.0, "RelevanceHint": "NonHistory" }, { "MeetingLocation": { "EntityType": "LocalBusiness", "LocationSource": "Bing", "LocationUri": "https://www.bingapis.com/api/v6/localbusinesses/YN1228x262604067?setLang=en-CA", "UniqueId": "https://www.bingapis.com/api/v6/localbusinesses/YN1228x262604067?setLang=en-CA", "IsPreviouslyUsed": false, "DisplayName": "The Home Depot", "Address": { "Street": "350 Centennial Pky N", "City": "Hamilton", "State": "ON", "CountryOrRegion": "Canada", "PostalCode": "L8E 2X4" }, "Coordinates": { "Latitude": 43.2402, "Longitude": -79.7575 } }, "LocationType": "LocalBusiness", "RelevanceScore": -20.0, "RelevanceHint": "NonHistory" }],
141
- // "EmptyLocationsHint": ""
142
- // }