@kwiz/common 1.0.73 → 1.0.74

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 (546) hide show
  1. package/lib/cjs/_dependencies.js.map +1 -0
  2. package/lib/cjs/config.js.map +1 -0
  3. package/lib/cjs/exports-index.js.map +1 -0
  4. package/lib/cjs/helpers/Guid.js.map +1 -0
  5. package/lib/cjs/helpers/_dependencies.js.map +1 -0
  6. package/lib/cjs/helpers/base64.js.map +1 -0
  7. package/lib/cjs/helpers/browser.js.map +1 -0
  8. package/lib/cjs/helpers/browserinfo.js.map +1 -0
  9. package/{dist → lib/cjs}/helpers/collections.base.js +0 -3
  10. package/lib/cjs/helpers/collections.base.js.map +1 -0
  11. package/lib/cjs/helpers/collections.js.map +1 -0
  12. package/lib/cjs/helpers/color.js.map +1 -0
  13. package/lib/cjs/helpers/cookies.js.map +1 -0
  14. package/lib/cjs/helpers/date.js.map +1 -0
  15. package/{dist → lib/cjs}/helpers/debug.js +1 -1
  16. package/lib/cjs/helpers/debug.js.map +1 -0
  17. package/lib/cjs/helpers/emails.js.map +1 -0
  18. package/lib/cjs/helpers/eval.js.map +1 -0
  19. package/lib/cjs/helpers/exports-index.js.map +1 -0
  20. package/lib/cjs/helpers/file.js.map +1 -0
  21. package/lib/cjs/helpers/flatted.js.map +1 -0
  22. package/lib/cjs/helpers/functions.js.map +1 -0
  23. package/lib/cjs/helpers/graph/calendar.types.js.map +1 -0
  24. package/lib/cjs/helpers/graph/exports-index.js.map +1 -0
  25. package/lib/cjs/helpers/http.js.map +1 -0
  26. package/lib/cjs/helpers/images.js.map +1 -0
  27. package/lib/cjs/helpers/json.js.map +1 -0
  28. package/lib/cjs/helpers/md5.js.map +1 -0
  29. package/lib/cjs/helpers/objects.js.map +1 -0
  30. package/{dist → lib/cjs}/helpers/promises.js +8 -3
  31. package/lib/cjs/helpers/promises.js.map +1 -0
  32. package/lib/cjs/helpers/random.js.map +1 -0
  33. package/lib/cjs/helpers/scheduler/exports-index.js.map +1 -0
  34. package/lib/cjs/helpers/scheduler/scheduler.js.map +1 -0
  35. package/{dist → lib/cjs}/helpers/sharepoint.js +17 -17
  36. package/lib/cjs/helpers/sharepoint.js.map +1 -0
  37. package/lib/cjs/helpers/strings.js.map +1 -0
  38. package/lib/cjs/helpers/typecheckers.js.map +1 -0
  39. package/lib/cjs/helpers/url.js.map +1 -0
  40. package/lib/cjs/helpers/urlhelper.js.map +1 -0
  41. package/{dist → lib/cjs}/index.js +5 -2
  42. package/lib/cjs/index.js.map +1 -0
  43. package/lib/cjs/types/auth.js.map +1 -0
  44. package/lib/cjs/types/common.types.js.map +1 -0
  45. package/lib/cjs/types/exports-index.js.map +1 -0
  46. package/lib/cjs/types/flatted.types.js.map +1 -0
  47. package/lib/cjs/types/globals.types.js.map +1 -0
  48. package/lib/cjs/types/graph/calendar.types.js.map +1 -0
  49. package/lib/cjs/types/graph/exports-index.js.map +1 -0
  50. package/lib/cjs/types/knownscript.types.js.map +1 -0
  51. package/lib/cjs/types/libs/datajs.types.js.map +1 -0
  52. package/lib/cjs/types/libs/exports-index.js.map +1 -0
  53. package/lib/cjs/types/libs/ics.types.js.map +1 -0
  54. package/lib/cjs/types/libs/msal.types.js.map +1 -0
  55. package/{dist → lib/cjs}/types/locales.js.map +1 -1
  56. package/lib/cjs/types/localstoragecache.types.js.map +1 -0
  57. package/lib/cjs/types/location.types.js.map +1 -0
  58. package/{dist → lib/cjs}/types/moment.js.map +1 -1
  59. package/{dist → lib/cjs}/types/regex.types.js.map +1 -1
  60. package/lib/cjs/types/rest.types.js.map +1 -0
  61. package/lib/cjs/types/sharepoint.types.js.map +1 -0
  62. package/lib/cjs/types/sharepoint.utils.types.js.map +1 -0
  63. package/lib/cjs/utils/_dependencies.js.map +1 -0
  64. package/lib/cjs/utils/auth/common.js.map +1 -0
  65. package/{dist → lib/cjs}/utils/auth/discovery.js +16 -14
  66. package/lib/cjs/utils/auth/discovery.js.map +1 -0
  67. package/lib/cjs/utils/auth/exports-index.js.map +1 -0
  68. package/{dist → lib/cjs}/utils/base64.js +4 -3
  69. package/lib/cjs/utils/base64.js.map +1 -0
  70. package/{dist → lib/cjs}/utils/consolelogger.js +31 -26
  71. package/lib/cjs/utils/consolelogger.js.map +1 -0
  72. package/{dist → lib/cjs}/utils/date.js +3 -3
  73. package/lib/cjs/utils/date.js.map +1 -0
  74. package/{dist → lib/cjs}/utils/emails.js +2 -2
  75. package/lib/cjs/utils/emails.js.map +1 -0
  76. package/lib/cjs/utils/exports-index.js.map +1 -0
  77. package/{dist → lib/cjs}/utils/knownscript.js +9 -5
  78. package/lib/cjs/utils/knownscript.js.map +1 -0
  79. package/{dist → lib/cjs}/utils/localstoragecache.js +40 -27
  80. package/lib/cjs/utils/localstoragecache.js.map +1 -0
  81. package/{dist → lib/cjs}/utils/rest.js +63 -48
  82. package/lib/cjs/utils/rest.js.map +1 -0
  83. package/{dist → lib/cjs}/utils/script.js +15 -10
  84. package/lib/cjs/utils/script.js.map +1 -0
  85. package/lib/cjs/utils/sharepoint.rest/common.js.map +1 -0
  86. package/{dist → lib/cjs}/utils/sharepoint.rest/date.js +10 -9
  87. package/lib/cjs/utils/sharepoint.rest/date.js.map +1 -0
  88. package/lib/cjs/utils/sharepoint.rest/exports-index.js.map +1 -0
  89. package/{dist → lib/cjs}/utils/sharepoint.rest/file.folder.js +49 -46
  90. package/lib/cjs/utils/sharepoint.rest/file.folder.js.map +1 -0
  91. package/{dist → lib/cjs}/utils/sharepoint.rest/item.js +51 -45
  92. package/lib/cjs/utils/sharepoint.rest/item.js.map +1 -0
  93. package/{dist → lib/cjs}/utils/sharepoint.rest/list.js +131 -124
  94. package/lib/cjs/utils/sharepoint.rest/list.js.map +1 -0
  95. package/{dist → lib/cjs}/utils/sharepoint.rest/listutils/GetListItemsByCaml.js +55 -50
  96. package/lib/cjs/utils/sharepoint.rest/listutils/GetListItemsByCaml.js.map +1 -0
  97. package/{dist → lib/cjs}/utils/sharepoint.rest/listutils/GetListItemsById.js +31 -23
  98. package/lib/cjs/utils/sharepoint.rest/listutils/GetListItemsById.js.map +1 -0
  99. package/{dist → lib/cjs}/utils/sharepoint.rest/listutils/common.js +20 -16
  100. package/lib/cjs/utils/sharepoint.rest/listutils/common.js.map +1 -0
  101. package/lib/cjs/utils/sharepoint.rest/listutils/exports-index.js.map +1 -0
  102. package/{dist → lib/cjs}/utils/sharepoint.rest/location.js +3 -3
  103. package/lib/cjs/utils/sharepoint.rest/location.js.map +1 -0
  104. package/{dist → lib/cjs}/utils/sharepoint.rest/navigation-links.js +3 -3
  105. package/lib/cjs/utils/sharepoint.rest/navigation-links.js.map +1 -0
  106. package/{dist → lib/cjs}/utils/sharepoint.rest/user-search.js +7 -5
  107. package/lib/cjs/utils/sharepoint.rest/user-search.js.map +1 -0
  108. package/{dist → lib/cjs}/utils/sharepoint.rest/user.js +52 -47
  109. package/lib/cjs/utils/sharepoint.rest/user.js.map +1 -0
  110. package/{dist → lib/cjs}/utils/sharepoint.rest/web.js +167 -158
  111. package/lib/cjs/utils/sharepoint.rest/web.js.map +1 -0
  112. package/{dist → lib/cjs}/utils/sod.js +12 -11
  113. package/lib/cjs/utils/sod.js.map +1 -0
  114. package/lib/esm/_dependencies.js +12 -0
  115. package/lib/esm/_dependencies.js.map +1 -0
  116. package/lib/esm/config.js +12 -0
  117. package/lib/esm/config.js.map +1 -0
  118. package/lib/esm/exports-index.js +5 -0
  119. package/lib/esm/exports-index.js.map +1 -0
  120. package/lib/esm/helpers/Guid.js +179 -0
  121. package/lib/esm/helpers/Guid.js.map +1 -0
  122. package/{src/helpers/_dependencies.ts → lib/esm/helpers/_dependencies.js} +3 -3
  123. package/lib/esm/helpers/_dependencies.js.map +1 -0
  124. package/lib/esm/helpers/base64.js +157 -0
  125. package/lib/esm/helpers/base64.js.map +1 -0
  126. package/lib/esm/helpers/browser.js +1158 -0
  127. package/lib/esm/helpers/browser.js.map +1 -0
  128. package/lib/esm/helpers/browserinfo.js +206 -0
  129. package/lib/esm/helpers/browserinfo.js.map +1 -0
  130. package/lib/esm/helpers/collections.base.js +372 -0
  131. package/lib/esm/helpers/collections.base.js.map +1 -0
  132. package/lib/esm/helpers/collections.js +96 -0
  133. package/lib/esm/helpers/collections.js.map +1 -0
  134. package/lib/esm/helpers/color.js +51 -0
  135. package/lib/esm/helpers/color.js.map +1 -0
  136. package/lib/esm/helpers/cookies.js +53 -0
  137. package/lib/esm/helpers/cookies.js.map +1 -0
  138. package/lib/esm/helpers/date.js +163 -0
  139. package/lib/esm/helpers/date.js.map +1 -0
  140. package/lib/esm/helpers/debug.js +156 -0
  141. package/lib/esm/helpers/debug.js.map +1 -0
  142. package/lib/esm/helpers/emails.js +6 -0
  143. package/lib/esm/helpers/emails.js.map +1 -0
  144. package/lib/esm/helpers/eval.js +6 -0
  145. package/lib/esm/helpers/eval.js.map +1 -0
  146. package/lib/esm/helpers/exports-index.js +30 -0
  147. package/lib/esm/helpers/exports-index.js.map +1 -0
  148. package/lib/esm/helpers/file.js +49 -0
  149. package/lib/esm/helpers/file.js.map +1 -0
  150. package/lib/esm/helpers/flatted.js +131 -0
  151. package/lib/esm/helpers/flatted.js.map +1 -0
  152. package/lib/esm/helpers/functions.js +13 -0
  153. package/lib/esm/helpers/functions.js.map +1 -0
  154. package/lib/esm/helpers/graph/calendar.types.js +10 -0
  155. package/lib/esm/helpers/graph/calendar.types.js.map +1 -0
  156. package/lib/esm/helpers/graph/exports-index.js +2 -0
  157. package/lib/esm/helpers/graph/exports-index.js.map +1 -0
  158. package/lib/esm/helpers/http.js +65 -0
  159. package/lib/esm/helpers/http.js.map +1 -0
  160. package/lib/esm/helpers/images.js +18 -0
  161. package/lib/esm/helpers/images.js.map +1 -0
  162. package/lib/esm/helpers/json.js +39 -0
  163. package/lib/esm/helpers/json.js.map +1 -0
  164. package/lib/esm/helpers/md5.js +168 -0
  165. package/lib/esm/helpers/md5.js.map +1 -0
  166. package/lib/esm/helpers/objects.js +258 -0
  167. package/lib/esm/helpers/objects.js.map +1 -0
  168. package/lib/esm/helpers/promises.js +152 -0
  169. package/lib/esm/helpers/promises.js.map +1 -0
  170. package/lib/esm/helpers/random.js +27 -0
  171. package/lib/esm/helpers/random.js.map +1 -0
  172. package/lib/esm/helpers/scheduler/exports-index.js +2 -0
  173. package/lib/esm/helpers/scheduler/exports-index.js.map +1 -0
  174. package/lib/esm/helpers/scheduler/scheduler.js +103 -0
  175. package/lib/esm/helpers/scheduler/scheduler.js.map +1 -0
  176. package/lib/esm/helpers/sharepoint.js +669 -0
  177. package/lib/esm/helpers/sharepoint.js.map +1 -0
  178. package/lib/esm/helpers/strings.js +273 -0
  179. package/lib/esm/helpers/strings.js.map +1 -0
  180. package/lib/esm/helpers/typecheckers.js +238 -0
  181. package/lib/esm/helpers/typecheckers.js.map +1 -0
  182. package/lib/esm/helpers/url.js +190 -0
  183. package/lib/esm/helpers/url.js.map +1 -0
  184. package/lib/esm/helpers/urlhelper.js +100 -0
  185. package/lib/esm/helpers/urlhelper.js.map +1 -0
  186. package/lib/esm/index.js +6 -0
  187. package/lib/esm/index.js.map +1 -0
  188. package/lib/esm/types/auth.js +38 -0
  189. package/lib/esm/types/auth.js.map +1 -0
  190. package/lib/esm/types/common.types.js +3 -0
  191. package/lib/esm/types/common.types.js.map +1 -0
  192. package/lib/esm/types/exports-index.js +16 -0
  193. package/lib/esm/types/exports-index.js.map +1 -0
  194. package/lib/esm/types/flatted.types.js +2 -0
  195. package/lib/esm/types/flatted.types.js.map +1 -0
  196. package/lib/esm/types/globals.types.js +2 -0
  197. package/lib/esm/types/globals.types.js.map +1 -0
  198. package/lib/esm/types/graph/calendar.types.js +2 -0
  199. package/lib/esm/types/graph/calendar.types.js.map +1 -0
  200. package/lib/esm/types/graph/exports-index.js +2 -0
  201. package/lib/esm/types/graph/exports-index.js.map +1 -0
  202. package/lib/esm/types/knownscript.types.js +2 -0
  203. package/lib/esm/types/knownscript.types.js.map +1 -0
  204. package/lib/esm/types/libs/datajs.types.js +2 -0
  205. package/lib/esm/types/libs/datajs.types.js.map +1 -0
  206. package/lib/esm/types/libs/exports-index.js +4 -0
  207. package/lib/esm/types/libs/exports-index.js.map +1 -0
  208. package/lib/esm/types/libs/ics.types.js +2 -0
  209. package/lib/esm/types/libs/ics.types.js.map +1 -0
  210. package/lib/esm/types/libs/msal.types.js +28 -0
  211. package/lib/esm/types/libs/msal.types.js.map +1 -0
  212. package/lib/esm/types/locales.js +2 -0
  213. package/lib/esm/types/locales.js.map +1 -0
  214. package/lib/esm/types/localstoragecache.types.js +2 -0
  215. package/lib/esm/types/localstoragecache.types.js.map +1 -0
  216. package/lib/esm/types/location.types.js +2 -0
  217. package/lib/esm/types/location.types.js.map +1 -0
  218. package/lib/esm/types/moment.js +2 -0
  219. package/lib/esm/types/moment.js.map +1 -0
  220. package/lib/esm/types/regex.types.js +2 -0
  221. package/lib/esm/types/regex.types.js.map +1 -0
  222. package/lib/esm/types/rest.types.js +21 -0
  223. package/lib/esm/types/rest.types.js.map +1 -0
  224. package/lib/esm/types/sharepoint.types.js +660 -0
  225. package/lib/esm/types/sharepoint.types.js.map +1 -0
  226. package/lib/esm/types/sharepoint.utils.types.js +51 -0
  227. package/lib/esm/types/sharepoint.utils.types.js.map +1 -0
  228. package/{src/utils/_dependencies.ts → lib/esm/utils/_dependencies.js} +4 -4
  229. package/lib/esm/utils/_dependencies.js.map +1 -0
  230. package/lib/esm/utils/auth/common.js +61 -0
  231. package/lib/esm/utils/auth/common.js.map +1 -0
  232. package/lib/esm/utils/auth/discovery.js +104 -0
  233. package/lib/esm/utils/auth/discovery.js.map +1 -0
  234. package/lib/esm/utils/auth/exports-index.js +3 -0
  235. package/lib/esm/utils/auth/exports-index.js.map +1 -0
  236. package/lib/esm/utils/base64.js +27 -0
  237. package/lib/esm/utils/base64.js.map +1 -0
  238. package/lib/esm/utils/consolelogger.js +271 -0
  239. package/lib/esm/utils/consolelogger.js.map +1 -0
  240. package/lib/esm/utils/date.js +26 -0
  241. package/lib/esm/utils/date.js.map +1 -0
  242. package/lib/esm/utils/emails.js +23 -0
  243. package/lib/esm/utils/emails.js.map +1 -0
  244. package/lib/esm/utils/exports-index.js +12 -0
  245. package/lib/esm/utils/exports-index.js.map +1 -0
  246. package/lib/esm/utils/knownscript.js +247 -0
  247. package/lib/esm/utils/knownscript.js.map +1 -0
  248. package/lib/esm/utils/localstoragecache.js +378 -0
  249. package/lib/esm/utils/localstoragecache.js.map +1 -0
  250. package/lib/esm/utils/rest.js +432 -0
  251. package/lib/esm/utils/rest.js.map +1 -0
  252. package/lib/esm/utils/script.js +154 -0
  253. package/lib/esm/utils/script.js.map +1 -0
  254. package/lib/esm/utils/sharepoint.rest/common.js +134 -0
  255. package/lib/esm/utils/sharepoint.rest/common.js.map +1 -0
  256. package/lib/esm/utils/sharepoint.rest/date.js +54 -0
  257. package/lib/esm/utils/sharepoint.rest/date.js.map +1 -0
  258. package/lib/esm/utils/sharepoint.rest/exports-index.js +12 -0
  259. package/lib/esm/utils/sharepoint.rest/exports-index.js.map +1 -0
  260. package/lib/esm/utils/sharepoint.rest/file.folder.js +444 -0
  261. package/lib/esm/utils/sharepoint.rest/file.folder.js.map +1 -0
  262. package/lib/esm/utils/sharepoint.rest/item.js +453 -0
  263. package/lib/esm/utils/sharepoint.rest/item.js.map +1 -0
  264. package/lib/esm/utils/sharepoint.rest/list.js +924 -0
  265. package/lib/esm/utils/sharepoint.rest/list.js.map +1 -0
  266. package/lib/esm/utils/sharepoint.rest/listutils/GetListItemsByCaml.js +624 -0
  267. package/lib/esm/utils/sharepoint.rest/listutils/GetListItemsByCaml.js.map +1 -0
  268. package/lib/esm/utils/sharepoint.rest/listutils/GetListItemsById.js +214 -0
  269. package/lib/esm/utils/sharepoint.rest/listutils/GetListItemsById.js.map +1 -0
  270. package/lib/esm/utils/sharepoint.rest/listutils/common.js +198 -0
  271. package/lib/esm/utils/sharepoint.rest/listutils/common.js.map +1 -0
  272. package/lib/esm/utils/sharepoint.rest/listutils/exports-index.js +4 -0
  273. package/lib/esm/utils/sharepoint.rest/listutils/exports-index.js.map +1 -0
  274. package/lib/esm/utils/sharepoint.rest/location.js +103 -0
  275. package/lib/esm/utils/sharepoint.rest/location.js.map +1 -0
  276. package/lib/esm/utils/sharepoint.rest/navigation-links.js +80 -0
  277. package/lib/esm/utils/sharepoint.rest/navigation-links.js.map +1 -0
  278. package/lib/esm/utils/sharepoint.rest/user-search.js +218 -0
  279. package/lib/esm/utils/sharepoint.rest/user-search.js.map +1 -0
  280. package/lib/esm/utils/sharepoint.rest/user.js +414 -0
  281. package/lib/esm/utils/sharepoint.rest/user.js.map +1 -0
  282. package/lib/esm/utils/sharepoint.rest/web.js +1158 -0
  283. package/lib/esm/utils/sharepoint.rest/web.js.map +1 -0
  284. package/lib/esm/utils/sod.js +164 -0
  285. package/lib/esm/utils/sod.js.map +1 -0
  286. package/{dist → lib/types}/helpers/collections.base.d.ts +1 -1
  287. package/{dist → lib/types}/helpers/collections.d.ts +1 -1
  288. package/{dist → lib/types}/helpers/flatted.d.ts +1 -1
  289. package/{dist → lib/types}/helpers/graph/calendar.types.d.ts +1 -1
  290. package/{dist → lib/types}/helpers/sharepoint.d.ts +3 -1
  291. package/{dist → lib/types}/helpers/strings.d.ts +1 -1
  292. package/{dist → lib/types}/helpers/url.d.ts +1 -1
  293. package/{dist → lib/types}/utils/auth/discovery.d.ts +1 -1
  294. package/{dist → lib/types}/utils/knownscript.d.ts +5 -1
  295. package/{dist → lib/types}/utils/localstoragecache.d.ts +1 -1
  296. package/{dist → lib/types}/utils/rest.d.ts +1 -1
  297. package/{dist → lib/types}/utils/script.d.ts +1 -1
  298. package/{dist → lib/types}/utils/sharepoint.rest/date.d.ts +1 -1
  299. package/{dist → lib/types}/utils/sharepoint.rest/file.folder.d.ts +4 -1
  300. package/{dist → lib/types}/utils/sharepoint.rest/item.d.ts +3 -1
  301. package/{dist → lib/types}/utils/sharepoint.rest/list.d.ts +4 -1
  302. package/{dist → lib/types}/utils/sharepoint.rest/listutils/GetListItemsByCaml.d.ts +1 -1
  303. package/{dist → lib/types}/utils/sharepoint.rest/listutils/GetListItemsById.d.ts +2 -1
  304. package/{dist → lib/types}/utils/sharepoint.rest/listutils/common.d.ts +2 -1
  305. package/{dist → lib/types}/utils/sharepoint.rest/navigation-links.d.ts +1 -1
  306. package/{dist → lib/types}/utils/sharepoint.rest/user-search.d.ts +1 -1
  307. package/{dist → lib/types}/utils/sharepoint.rest/user.d.ts +3 -1
  308. package/{dist → lib/types}/utils/sharepoint.rest/web.d.ts +3 -1
  309. package/{dist → lib/types}/utils/sod.d.ts +1 -1
  310. package/package.json +15 -7
  311. package/src/helpers/browser.ts +1 -1
  312. package/src/helpers/collections.base.ts +1 -2
  313. package/src/helpers/collections.ts +1 -1
  314. package/src/helpers/debug.ts +1 -1
  315. package/src/helpers/flatted.ts +1 -1
  316. package/src/helpers/graph/calendar.types.ts +1 -1
  317. package/src/helpers/promises.ts +10 -5
  318. package/src/helpers/sharepoint.ts +3 -1
  319. package/src/helpers/strings.ts +1 -1
  320. package/src/helpers/url.ts +1 -1
  321. package/src/utils/auth/discovery.ts +3 -1
  322. package/src/utils/base64.ts +2 -1
  323. package/src/utils/consolelogger.ts +7 -1
  324. package/src/utils/date.ts +1 -1
  325. package/src/utils/emails.ts +1 -1
  326. package/src/utils/knownscript.ts +7 -1
  327. package/src/utils/localstoragecache.ts +39 -20
  328. package/src/utils/rest.ts +23 -4
  329. package/src/utils/script.ts +4 -1
  330. package/src/utils/sharepoint.rest/date.ts +3 -1
  331. package/src/utils/sharepoint.rest/file.folder.ts +7 -1
  332. package/src/utils/sharepoint.rest/item.ts +9 -1
  333. package/src/utils/sharepoint.rest/list.ts +10 -1
  334. package/src/utils/sharepoint.rest/listutils/GetListItemsByCaml.ts +9 -1
  335. package/src/utils/sharepoint.rest/listutils/GetListItemsById.ts +14 -4
  336. package/src/utils/sharepoint.rest/listutils/common.ts +6 -1
  337. package/src/utils/sharepoint.rest/location.ts +1 -1
  338. package/src/utils/sharepoint.rest/navigation-links.ts +2 -1
  339. package/src/utils/sharepoint.rest/user-search.ts +4 -1
  340. package/src/utils/sharepoint.rest/user.ts +7 -1
  341. package/src/utils/sharepoint.rest/web.ts +12 -2
  342. package/src/utils/sod.ts +3 -1
  343. package/dist/_dependencies.js.map +0 -1
  344. package/dist/config.js.map +0 -1
  345. package/dist/exports-index.js.map +0 -1
  346. package/dist/helpers/Guid.js.map +0 -1
  347. package/dist/helpers/_dependencies.js.map +0 -1
  348. package/dist/helpers/base64.js.map +0 -1
  349. package/dist/helpers/browser.js.map +0 -1
  350. package/dist/helpers/browserinfo.js.map +0 -1
  351. package/dist/helpers/collections.base.js.map +0 -1
  352. package/dist/helpers/collections.js.map +0 -1
  353. package/dist/helpers/color.js.map +0 -1
  354. package/dist/helpers/cookies.js.map +0 -1
  355. package/dist/helpers/date.js.map +0 -1
  356. package/dist/helpers/debug.js.map +0 -1
  357. package/dist/helpers/emails.js.map +0 -1
  358. package/dist/helpers/eval.js.map +0 -1
  359. package/dist/helpers/exports-index.js.map +0 -1
  360. package/dist/helpers/file.js.map +0 -1
  361. package/dist/helpers/flatted.js.map +0 -1
  362. package/dist/helpers/functions.js.map +0 -1
  363. package/dist/helpers/graph/calendar.types.js.map +0 -1
  364. package/dist/helpers/graph/exports-index.js.map +0 -1
  365. package/dist/helpers/http.js.map +0 -1
  366. package/dist/helpers/images.js.map +0 -1
  367. package/dist/helpers/json.js.map +0 -1
  368. package/dist/helpers/md5.js.map +0 -1
  369. package/dist/helpers/objects.js.map +0 -1
  370. package/dist/helpers/promises.js.map +0 -1
  371. package/dist/helpers/random.js.map +0 -1
  372. package/dist/helpers/scheduler/exports-index.js.map +0 -1
  373. package/dist/helpers/scheduler/scheduler.js.map +0 -1
  374. package/dist/helpers/sharepoint.js.map +0 -1
  375. package/dist/helpers/strings.js.map +0 -1
  376. package/dist/helpers/typecheckers.js.map +0 -1
  377. package/dist/helpers/url.js.map +0 -1
  378. package/dist/helpers/urlhelper.js.map +0 -1
  379. package/dist/index.js.map +0 -1
  380. package/dist/types/auth.js.map +0 -1
  381. package/dist/types/common.types.js.map +0 -1
  382. package/dist/types/exports-index.js.map +0 -1
  383. package/dist/types/flatted.types.js.map +0 -1
  384. package/dist/types/globals.types.js.map +0 -1
  385. package/dist/types/graph/calendar.types.js.map +0 -1
  386. package/dist/types/graph/exports-index.js.map +0 -1
  387. package/dist/types/knownscript.types.js.map +0 -1
  388. package/dist/types/libs/datajs.types.js.map +0 -1
  389. package/dist/types/libs/exports-index.js.map +0 -1
  390. package/dist/types/libs/ics.types.js.map +0 -1
  391. package/dist/types/libs/msal.types.js.map +0 -1
  392. package/dist/types/localstoragecache.types.js.map +0 -1
  393. package/dist/types/location.types.js.map +0 -1
  394. package/dist/types/rest.types.js.map +0 -1
  395. package/dist/types/sharepoint.types.js.map +0 -1
  396. package/dist/types/sharepoint.utils.types.js.map +0 -1
  397. package/dist/utils/_dependencies.js.map +0 -1
  398. package/dist/utils/auth/common.js.map +0 -1
  399. package/dist/utils/auth/discovery.js.map +0 -1
  400. package/dist/utils/auth/exports-index.js.map +0 -1
  401. package/dist/utils/base64.js.map +0 -1
  402. package/dist/utils/consolelogger.js.map +0 -1
  403. package/dist/utils/date.js.map +0 -1
  404. package/dist/utils/emails.js.map +0 -1
  405. package/dist/utils/exports-index.js.map +0 -1
  406. package/dist/utils/knownscript.js.map +0 -1
  407. package/dist/utils/localstoragecache.js.map +0 -1
  408. package/dist/utils/rest.js.map +0 -1
  409. package/dist/utils/script.js.map +0 -1
  410. package/dist/utils/sharepoint.rest/common.js.map +0 -1
  411. package/dist/utils/sharepoint.rest/date.js.map +0 -1
  412. package/dist/utils/sharepoint.rest/exports-index.js.map +0 -1
  413. package/dist/utils/sharepoint.rest/file.folder.js.map +0 -1
  414. package/dist/utils/sharepoint.rest/item.js.map +0 -1
  415. package/dist/utils/sharepoint.rest/list.js.map +0 -1
  416. package/dist/utils/sharepoint.rest/listutils/GetListItemsByCaml.js.map +0 -1
  417. package/dist/utils/sharepoint.rest/listutils/GetListItemsById.js.map +0 -1
  418. package/dist/utils/sharepoint.rest/listutils/common.js.map +0 -1
  419. package/dist/utils/sharepoint.rest/listutils/exports-index.js.map +0 -1
  420. package/dist/utils/sharepoint.rest/location.js.map +0 -1
  421. package/dist/utils/sharepoint.rest/navigation-links.js.map +0 -1
  422. package/dist/utils/sharepoint.rest/user-search.js.map +0 -1
  423. package/dist/utils/sharepoint.rest/user.js.map +0 -1
  424. package/dist/utils/sharepoint.rest/web.js.map +0 -1
  425. package/dist/utils/sod.js.map +0 -1
  426. /package/{dist → lib/cjs}/_dependencies.js +0 -0
  427. /package/{dist → lib/cjs}/config.js +0 -0
  428. /package/{dist → lib/cjs}/exports-index.js +0 -0
  429. /package/{dist → lib/cjs}/helpers/Guid.js +0 -0
  430. /package/{dist → lib/cjs}/helpers/_dependencies.js +0 -0
  431. /package/{dist → lib/cjs}/helpers/base64.js +0 -0
  432. /package/{dist → lib/cjs}/helpers/browser.js +0 -0
  433. /package/{dist → lib/cjs}/helpers/browserinfo.js +0 -0
  434. /package/{dist → lib/cjs}/helpers/collections.js +0 -0
  435. /package/{dist → lib/cjs}/helpers/color.js +0 -0
  436. /package/{dist → lib/cjs}/helpers/cookies.js +0 -0
  437. /package/{dist → lib/cjs}/helpers/date.js +0 -0
  438. /package/{dist → lib/cjs}/helpers/emails.js +0 -0
  439. /package/{dist → lib/cjs}/helpers/eval.js +0 -0
  440. /package/{dist → lib/cjs}/helpers/exports-index.js +0 -0
  441. /package/{dist → lib/cjs}/helpers/file.js +0 -0
  442. /package/{dist → lib/cjs}/helpers/flatted.js +0 -0
  443. /package/{dist → lib/cjs}/helpers/functions.js +0 -0
  444. /package/{dist → lib/cjs}/helpers/graph/calendar.types.js +0 -0
  445. /package/{dist → lib/cjs}/helpers/graph/exports-index.js +0 -0
  446. /package/{dist → lib/cjs}/helpers/http.js +0 -0
  447. /package/{dist → lib/cjs}/helpers/images.js +0 -0
  448. /package/{dist → lib/cjs}/helpers/json.js +0 -0
  449. /package/{dist → lib/cjs}/helpers/md5.js +0 -0
  450. /package/{dist → lib/cjs}/helpers/objects.js +0 -0
  451. /package/{dist → lib/cjs}/helpers/random.js +0 -0
  452. /package/{dist → lib/cjs}/helpers/scheduler/exports-index.js +0 -0
  453. /package/{dist → lib/cjs}/helpers/scheduler/scheduler.js +0 -0
  454. /package/{dist → lib/cjs}/helpers/strings.js +0 -0
  455. /package/{dist → lib/cjs}/helpers/typecheckers.js +0 -0
  456. /package/{dist → lib/cjs}/helpers/url.js +0 -0
  457. /package/{dist → lib/cjs}/helpers/urlhelper.js +0 -0
  458. /package/{dist → lib/cjs}/types/auth.js +0 -0
  459. /package/{dist → lib/cjs}/types/common.types.js +0 -0
  460. /package/{dist → lib/cjs}/types/exports-index.js +0 -0
  461. /package/{dist → lib/cjs}/types/flatted.types.js +0 -0
  462. /package/{dist → lib/cjs}/types/globals.types.js +0 -0
  463. /package/{dist → lib/cjs}/types/graph/calendar.types.js +0 -0
  464. /package/{dist → lib/cjs}/types/graph/exports-index.js +0 -0
  465. /package/{dist → lib/cjs}/types/knownscript.types.js +0 -0
  466. /package/{dist → lib/cjs}/types/libs/datajs.types.js +0 -0
  467. /package/{dist → lib/cjs}/types/libs/exports-index.js +0 -0
  468. /package/{dist → lib/cjs}/types/libs/ics.types.js +0 -0
  469. /package/{dist → lib/cjs}/types/libs/msal.types.js +0 -0
  470. /package/{dist → lib/cjs}/types/locales.js +0 -0
  471. /package/{dist → lib/cjs}/types/localstoragecache.types.js +0 -0
  472. /package/{dist → lib/cjs}/types/location.types.js +0 -0
  473. /package/{dist → lib/cjs}/types/moment.js +0 -0
  474. /package/{dist → lib/cjs}/types/regex.types.js +0 -0
  475. /package/{dist → lib/cjs}/types/rest.types.js +0 -0
  476. /package/{dist → lib/cjs}/types/sharepoint.types.js +0 -0
  477. /package/{dist → lib/cjs}/types/sharepoint.utils.types.js +0 -0
  478. /package/{dist → lib/cjs}/utils/_dependencies.js +0 -0
  479. /package/{dist → lib/cjs}/utils/auth/common.js +0 -0
  480. /package/{dist → lib/cjs}/utils/auth/exports-index.js +0 -0
  481. /package/{dist → lib/cjs}/utils/exports-index.js +0 -0
  482. /package/{dist → lib/cjs}/utils/sharepoint.rest/common.js +0 -0
  483. /package/{dist → lib/cjs}/utils/sharepoint.rest/exports-index.js +0 -0
  484. /package/{dist → lib/cjs}/utils/sharepoint.rest/listutils/exports-index.js +0 -0
  485. /package/{dist → lib/types}/_dependencies.d.ts +0 -0
  486. /package/{dist → lib/types}/config.d.ts +0 -0
  487. /package/{dist → lib/types}/exports-index.d.ts +0 -0
  488. /package/{dist → lib/types}/helpers/Guid.d.ts +0 -0
  489. /package/{dist → lib/types}/helpers/_dependencies.d.ts +0 -0
  490. /package/{dist → lib/types}/helpers/base64.d.ts +0 -0
  491. /package/{dist → lib/types}/helpers/browser.d.ts +0 -0
  492. /package/{dist → lib/types}/helpers/browserinfo.d.ts +0 -0
  493. /package/{dist → lib/types}/helpers/color.d.ts +0 -0
  494. /package/{dist → lib/types}/helpers/cookies.d.ts +0 -0
  495. /package/{dist → lib/types}/helpers/date.d.ts +0 -0
  496. /package/{dist → lib/types}/helpers/debug.d.ts +0 -0
  497. /package/{dist → lib/types}/helpers/emails.d.ts +0 -0
  498. /package/{dist → lib/types}/helpers/eval.d.ts +0 -0
  499. /package/{dist → lib/types}/helpers/exports-index.d.ts +0 -0
  500. /package/{dist → lib/types}/helpers/file.d.ts +0 -0
  501. /package/{dist → lib/types}/helpers/functions.d.ts +0 -0
  502. /package/{dist → lib/types}/helpers/graph/exports-index.d.ts +0 -0
  503. /package/{dist → lib/types}/helpers/http.d.ts +0 -0
  504. /package/{dist → lib/types}/helpers/images.d.ts +0 -0
  505. /package/{dist → lib/types}/helpers/json.d.ts +0 -0
  506. /package/{dist → lib/types}/helpers/md5.d.ts +0 -0
  507. /package/{dist → lib/types}/helpers/objects.d.ts +0 -0
  508. /package/{dist → lib/types}/helpers/promises.d.ts +0 -0
  509. /package/{dist → lib/types}/helpers/random.d.ts +0 -0
  510. /package/{dist → lib/types}/helpers/scheduler/exports-index.d.ts +0 -0
  511. /package/{dist → lib/types}/helpers/scheduler/scheduler.d.ts +0 -0
  512. /package/{dist → lib/types}/helpers/typecheckers.d.ts +0 -0
  513. /package/{dist → lib/types}/helpers/urlhelper.d.ts +0 -0
  514. /package/{dist → lib/types}/index.d.ts +0 -0
  515. /package/{dist → lib/types}/types/auth.d.ts +0 -0
  516. /package/{dist → lib/types}/types/common.types.d.ts +0 -0
  517. /package/{dist → lib/types}/types/exports-index.d.ts +0 -0
  518. /package/{dist → lib/types}/types/flatted.types.d.ts +0 -0
  519. /package/{dist → lib/types}/types/globals.types.d.ts +0 -0
  520. /package/{dist → lib/types}/types/graph/calendar.types.d.ts +0 -0
  521. /package/{dist → lib/types}/types/graph/exports-index.d.ts +0 -0
  522. /package/{dist → lib/types}/types/knownscript.types.d.ts +0 -0
  523. /package/{dist → lib/types}/types/libs/datajs.types.d.ts +0 -0
  524. /package/{dist → lib/types}/types/libs/exports-index.d.ts +0 -0
  525. /package/{dist → lib/types}/types/libs/ics.types.d.ts +0 -0
  526. /package/{dist → lib/types}/types/libs/msal.types.d.ts +0 -0
  527. /package/{dist → lib/types}/types/locales.d.ts +0 -0
  528. /package/{dist → lib/types}/types/localstoragecache.types.d.ts +0 -0
  529. /package/{dist → lib/types}/types/location.types.d.ts +0 -0
  530. /package/{dist → lib/types}/types/moment.d.ts +0 -0
  531. /package/{dist → lib/types}/types/regex.types.d.ts +0 -0
  532. /package/{dist → lib/types}/types/rest.types.d.ts +0 -0
  533. /package/{dist → lib/types}/types/sharepoint.types.d.ts +0 -0
  534. /package/{dist → lib/types}/types/sharepoint.utils.types.d.ts +0 -0
  535. /package/{dist → lib/types}/utils/_dependencies.d.ts +0 -0
  536. /package/{dist → lib/types}/utils/auth/common.d.ts +0 -0
  537. /package/{dist → lib/types}/utils/auth/exports-index.d.ts +0 -0
  538. /package/{dist → lib/types}/utils/base64.d.ts +0 -0
  539. /package/{dist → lib/types}/utils/consolelogger.d.ts +0 -0
  540. /package/{dist → lib/types}/utils/date.d.ts +0 -0
  541. /package/{dist → lib/types}/utils/emails.d.ts +0 -0
  542. /package/{dist → lib/types}/utils/exports-index.d.ts +0 -0
  543. /package/{dist → lib/types}/utils/sharepoint.rest/common.d.ts +0 -0
  544. /package/{dist → lib/types}/utils/sharepoint.rest/exports-index.d.ts +0 -0
  545. /package/{dist → lib/types}/utils/sharepoint.rest/listutils/exports-index.d.ts +0 -0
  546. /package/{dist → lib/types}/utils/sharepoint.rest/location.d.ts +0 -0
@@ -0,0 +1,924 @@
1
+ import { PushNoDuplicate, firstOrNull, makeUniqueArray, toHash } from "../../helpers/collections.base";
2
+ import { jsonStringify } from "../../helpers/json";
3
+ import { NormalizeListName, SPBasePermissions, SchemaXmlToJson, extendFieldInfo } from "../../helpers/sharepoint";
4
+ import { normalizeGuid } from "../../helpers/strings";
5
+ import { SafeIfElse, isBoolean, isNotEmptyArray, isNullOrEmptyArray, isNullOrEmptyString, isNullOrUndefined, isNumber, isPromise, isString, isValidGuid } from "../../helpers/typecheckers";
6
+ import { makeServerRelativeUrl, normalizeUrl } from "../../helpers/url";
7
+ import { contentTypes, jsonTypes } from "../../types/rest.types";
8
+ import { SPBasePermissionKind } from "../../types/sharepoint.types";
9
+ import { ConsoleLogger } from "../consolelogger";
10
+ import { GetJson, GetJsonSync, longLocalCache, shortLocalCache } from "../rest";
11
+ import { GetRestBaseUrl, GetSiteUrl, LIST_EXPAND, LIST_SELECT } from "./common";
12
+ import { __fixGetListItemsResults } from "./listutils/common";
13
+ import { GetContentTypes, GetContentTypesSync, GetListsSync } from "./web";
14
+ const logger = ConsoleLogger.get("SharePoint.Rest.List");
15
+ /** returns /_api/web/lists/getById() or /_api/web/lists/getByTitle() */
16
+ export function GetListRestUrl(siteUrl, listIdOrTitle) {
17
+ siteUrl = GetSiteUrl(siteUrl);
18
+ let listId = GetListId(siteUrl, listIdOrTitle);
19
+ let listPart = isValidGuid(listId) ? `getById('${normalizeGuid(listId)}')` : `getByTitle('${encodeURIComponent(listIdOrTitle)}')`;
20
+ return GetRestBaseUrl(siteUrl) + `/web/lists/${listPart}`;
21
+ }
22
+ export function GetListId(siteUrl, listIdOrTitle) {
23
+ if (isNullOrEmptyString(listIdOrTitle))
24
+ return null;
25
+ if (isValidGuid(listIdOrTitle))
26
+ return listIdOrTitle;
27
+ //Issue 7508
28
+ //When translation is enabled, and user changes list title but he is not on the same language as the site
29
+ //he translates the list, but not changing its title
30
+ //so REST api /lists/getByTitle will not work
31
+ //instead, we need to get the list id from the web's lists collection.
32
+ let lists = GetListsSync(siteUrl);
33
+ var lower = listIdOrTitle.toLowerCase();
34
+ var list = firstOrNull(lists, l => l.Title.toLowerCase() === lower);
35
+ return list && list.Id || null;
36
+ }
37
+ /** get the list ID from a list page, such as a list view or an item form */
38
+ export function GetListIdFromPageSync(siteUrl, listPageUrl) {
39
+ let url = `${GetRestBaseUrl(siteUrl)}/web/getlist('${makeServerRelativeUrl(listPageUrl.split('?')[0].split('#')[0])}')?$select=id`;
40
+ let response = GetJsonSync(url, null, {
41
+ ...longLocalCache,
42
+ jsonMetadata: jsonTypes.nometadata
43
+ });
44
+ if (!isNullOrUndefined(response) && response.success) {
45
+ let listId = response.result.Id;
46
+ return normalizeGuid(listId);
47
+ }
48
+ return null;
49
+ }
50
+ /** ensures the site assets library exists and return its info. on errors - it will return null. */
51
+ export function EnsureAssetLibrary(siteUrl) {
52
+ siteUrl = GetSiteUrl(siteUrl);
53
+ let url = GetRestBaseUrl(siteUrl) +
54
+ "/web/lists/EnsureSiteAssetsLibrary?$select=ID,RootFolder/Name,RootFolder/ServerRelativeUrl,RootFolder/Exists&$expand=RootFolder";
55
+ return GetJson(url, null, { method: "POST", spWebUrl: siteUrl, ...longLocalCache }).then(result => {
56
+ if (result && result.d) {
57
+ return {
58
+ Id: result.d.Id,
59
+ Name: result.d.RootFolder.Name,
60
+ ServerRelativeUrl: result.d.RootFolder.ServerRelativeUrl
61
+ };
62
+ }
63
+ else
64
+ return null;
65
+ }).catch(() => null);
66
+ }
67
+ /** ensures the site pages library exists and return its info. on errors - it will return null. */
68
+ export async function EnsureSitePagesLibrary(siteUrl) {
69
+ let url = `${GetRestBaseUrl(siteUrl)}/web/lists/EnsureSitePagesLibrary`
70
+ + `?$select=ID,RootFolder/Name,RootFolder/ServerRelativeUrl,RootFolder/Exists&$expand=RootFolder`;
71
+ let response = await GetJson(url, null, {
72
+ method: "POST",
73
+ jsonMetadata: jsonTypes.nometadata,
74
+ includeDigestInPost: true,
75
+ ...longLocalCache
76
+ });
77
+ if (!isNullOrUndefined(response) && !isNullOrUndefined(response.RootFolder)) {
78
+ return {
79
+ Id: response.Id,
80
+ Name: response.RootFolder.Name,
81
+ ServerRelativeUrl: response.RootFolder.ServerRelativeUrl
82
+ };
83
+ }
84
+ return null;
85
+ }
86
+ export function GetSiteAssetLibrary(siteUrl, sync) {
87
+ let reqUrl = `${GetRestBaseUrl(siteUrl)}/web/lists?`
88
+ //Issue 1492: isSiteAssetsLibrary eq true does not work for reader users.
89
+ //+ `$filter=isSiteAssetsLibrary eq true&$select=ID,RootFolder/Name,RootFolder/ServerRelativeUrl,RootFolder/Exists`
90
+ + `$filter=EntityTypeName%20eq%20%27SiteAssets%27&$select=ID,RootFolder/Name,RootFolder/ServerRelativeUrl,RootFolder/Exists`
91
+ + `&$expand=RootFolder`;
92
+ let caller = sync ? GetJsonSync : GetJson;
93
+ let result = caller(reqUrl, null, { ...longLocalCache, jsonMetadata: jsonTypes.nometadata });
94
+ let transform = (v) => {
95
+ if (isNotEmptyArray(v && v.value)) {
96
+ let assetLibrary = v.value[0];
97
+ return {
98
+ Id: assetLibrary.Id,
99
+ Name: assetLibrary.RootFolder.Name,
100
+ ServerRelativeUrl: assetLibrary.RootFolder.ServerRelativeUrl
101
+ };
102
+ }
103
+ return null;
104
+ };
105
+ if (isPromise(result))
106
+ return result.then(r => transform(r), () => null);
107
+ else
108
+ return result.success ? transform(result.result) : null;
109
+ }
110
+ /** Return the list Title */
111
+ export function GetListTitle(siteUrl, listIdOrTitle) {
112
+ siteUrl = GetSiteUrl(siteUrl);
113
+ return GetJson(GetListRestUrl(siteUrl, listIdOrTitle) + `/Title`, null, { allowCache: true })
114
+ .then(r => {
115
+ return r.d.Title;
116
+ })
117
+ .catch(() => null);
118
+ }
119
+ /** Return the list */
120
+ export function GetList(siteUrlOrId, listIdOrTitle, options) {
121
+ let siteUrl = GetSiteUrl(siteUrlOrId);
122
+ if (isNullOrEmptyString(listIdOrTitle))
123
+ return null;
124
+ return GetJson(GetListRestUrl(siteUrl, listIdOrTitle) + `?$select=${LIST_SELECT}&$expand=${LIST_EXPAND}`, null, { allowCache: true })
125
+ .then(async (r) => {
126
+ let list = r.d;
127
+ if (options) {
128
+ if (options.includeViews)
129
+ list.Views = await GetListViews(siteUrl, listIdOrTitle, options.viewOptions);
130
+ if (options.includeContentTypes)
131
+ list.ContentTypes = await GetListContentTypes(siteUrl, listIdOrTitle);
132
+ if (options.includeRootFolder)
133
+ list.RootFolder = await GetListRootFolder(siteUrl, listIdOrTitle);
134
+ if (options.includeEventReceivers)
135
+ list.EventReceivers = await GetListEventReceivers(siteUrl, listIdOrTitle);
136
+ }
137
+ if (list.EffectiveBasePermissions
138
+ && (isString(list.EffectiveBasePermissions.High)
139
+ || isString(list.EffectiveBasePermissions.Low))) {
140
+ list.EffectiveBasePermissions = {
141
+ High: Number(list.EffectiveBasePermissions.High),
142
+ Low: Number(list.EffectiveBasePermissions.Low)
143
+ };
144
+ }
145
+ return list;
146
+ })
147
+ .catch(() => null);
148
+ }
149
+ /** Return the list */
150
+ export function GetListSync(siteUrl, listIdOrTitle) {
151
+ siteUrl = GetSiteUrl(siteUrl);
152
+ if (isNullOrEmptyString(listIdOrTitle))
153
+ return null;
154
+ let result = GetJsonSync(GetListRestUrl(siteUrl, listIdOrTitle) + `?$select=${LIST_SELECT}&$expand=${LIST_EXPAND}`, null, shortLocalCache);
155
+ if (result && result.success) {
156
+ let list = result.result.d;
157
+ if (list.EffectiveBasePermissions
158
+ && (isString(list.EffectiveBasePermissions.High)
159
+ || isString(list.EffectiveBasePermissions.Low))) {
160
+ list.EffectiveBasePermissions = {
161
+ High: Number(list.EffectiveBasePermissions.High),
162
+ Low: Number(list.EffectiveBasePermissions.Low)
163
+ };
164
+ }
165
+ return list;
166
+ }
167
+ else
168
+ return null;
169
+ }
170
+ export function GetListNameSync(webUrl, listIdOrTitle) {
171
+ let list = GetListSync(webUrl, listIdOrTitle);
172
+ return NormalizeListName({ EntityTypeName: list.EntityTypeName, BaseType: list.BaseType });
173
+ }
174
+ export async function GetListName(webUrl, listIdOrTitle) {
175
+ let list = await GetList(webUrl, listIdOrTitle);
176
+ return NormalizeListName({ EntityTypeName: list.EntityTypeName, BaseType: list.BaseType });
177
+ }
178
+ export function GetListRootFolder(siteUrlOrId, listIdOrTitle) {
179
+ let siteUrl = GetSiteUrl(siteUrlOrId);
180
+ return GetJson(GetListRestUrl(siteUrl, listIdOrTitle) + `/RootFolder?$Select=Name,ServerRelativeUrl`, null, longLocalCache)
181
+ .then(r => {
182
+ return r.d;
183
+ })
184
+ .catch(() => null);
185
+ }
186
+ export function GetListRootFolderSync(siteUrlOrId, listIdOrTitle) {
187
+ let siteUrl = GetSiteUrl(siteUrlOrId);
188
+ let result = GetJsonSync(GetListRestUrl(siteUrl, listIdOrTitle) + `/RootFolder?$Select=Name,ServerRelativeUrl`, null, longLocalCache);
189
+ return SafeIfElse(() => result.result.d, null);
190
+ }
191
+ export function GetListField(siteUrlOrId, listIdOrTitle, fieldIdOrName, refreshCache) {
192
+ let siteUrl = GetSiteUrl(siteUrlOrId);
193
+ var url = GetListRestUrl(siteUrl, listIdOrTitle) + `/fields`;
194
+ if (isValidGuid(fieldIdOrName)) {
195
+ url += `('${normalizeGuid(fieldIdOrName)}')`;
196
+ }
197
+ else {
198
+ url += `/getbyinternalnameortitle(@u)?@u='${encodeURIComponent(fieldIdOrName)}'`;
199
+ }
200
+ let result = GetJson(url, null, { allowCache: refreshCache !== true })
201
+ .then(r => {
202
+ return r.d;
203
+ })
204
+ .catch(() => null);
205
+ return result;
206
+ }
207
+ function _getListFieldsRequestUrl(siteUrl, listIdOrTitle) {
208
+ return GetListRestUrl(siteUrl, listIdOrTitle) + `/fields`;
209
+ }
210
+ /** Gets ID, Title, ContentType Author, Editor, Created and Modified fields */
211
+ export function GetStandardListFields(siteUrlOrId, listIdOrTitle, refreshCache) {
212
+ let fieldNames = ["ID", "Title", "ContentType", "Author", "Editor", "Created", "Modified"];
213
+ return GetListFields(siteUrlOrId, listIdOrTitle, { refreshCache: refreshCache, fieldNames: fieldNames });
214
+ }
215
+ function _processGetListFields(fields, fieldNames) {
216
+ if (isNullOrEmptyArray(fields)) {
217
+ return fields;
218
+ }
219
+ let extendedFields = fields.map(f => extendFieldInfo(f, fields));
220
+ if (!isNullOrEmptyArray(fieldNames)) {
221
+ return extendedFields.filter((extendedField) => {
222
+ return fieldNames.includes(extendedField.InternalName);
223
+ });
224
+ }
225
+ return extendedFields;
226
+ }
227
+ export function GetListFields(siteUrlOrId, listIdOrTitle, options = {}) {
228
+ let siteUrl = GetSiteUrl(siteUrlOrId);
229
+ let url = _getListFieldsRequestUrl(siteUrl, listIdOrTitle);
230
+ let restOptions = {
231
+ allowCache: options.refreshCache !== true,
232
+ jsonMetadata: jsonTypes.nometadata
233
+ };
234
+ return GetJson(url, null, restOptions)
235
+ .then((result) => {
236
+ return _processGetListFields(result.value, options.fieldNames);
237
+ }).catch(() => {
238
+ return null;
239
+ });
240
+ }
241
+ export function GetListFieldsSync(siteUrlOrId, listIdOrTitle, options = {}) {
242
+ let siteUrl = GetSiteUrl(siteUrlOrId);
243
+ let url = _getListFieldsRequestUrl(siteUrl, listIdOrTitle);
244
+ let restOptions = {
245
+ allowCache: options.refreshCache !== true,
246
+ jsonMetadata: jsonTypes.nometadata
247
+ };
248
+ let result = GetJsonSync(url, null, restOptions);
249
+ if (result.success && !isNullOrUndefined(result.result)) {
250
+ return _processGetListFields(result.result.value, options.fieldNames);
251
+ }
252
+ return null;
253
+ }
254
+ export async function GetListFieldsAsHash(siteUrlOrId, listIdOrTitle, refreshCache) {
255
+ let siteUrl = GetSiteUrl(siteUrlOrId);
256
+ let fields = await GetListFields(siteUrl, listIdOrTitle, { refreshCache: refreshCache });
257
+ let hash = {};
258
+ if (isNotEmptyArray(fields)) {
259
+ hash = toHash(fields, f => f.InternalName);
260
+ }
261
+ return hash;
262
+ }
263
+ export function GetListFieldsAsHashSync(siteUrlOrId, listIdOrTitle, refreshCache) {
264
+ let siteUrl = GetSiteUrl(siteUrlOrId);
265
+ let fields = GetListFieldsSync(siteUrl, listIdOrTitle, { refreshCache: refreshCache });
266
+ let hash = {};
267
+ if (isNotEmptyArray(fields)) {
268
+ fields.forEach(f => { hash[f.InternalName] = f; });
269
+ }
270
+ return hash;
271
+ }
272
+ export function GetListWorkflows(siteUrl, listIdOrTitle, refreshCache) {
273
+ siteUrl = GetSiteUrl(siteUrl);
274
+ return GetJson(GetListRestUrl(siteUrl, listIdOrTitle) + `/workflowAssociations`, null, { allowCache: refreshCache !== true })
275
+ .then(r => {
276
+ if (r && r.d && isNotEmptyArray(r.d.results)) {
277
+ r.d.results.forEach(wf => {
278
+ wf.BaseId = normalizeGuid(wf.BaseId);
279
+ wf.Id = normalizeGuid(wf.Id);
280
+ wf.ListId = normalizeGuid(wf.ListId);
281
+ wf.WebId = normalizeGuid(wf.WebId);
282
+ });
283
+ return r.d.results;
284
+ }
285
+ else
286
+ return [];
287
+ })
288
+ .catch(() => []);
289
+ }
290
+ export function UserHasManagePermissions(siteUrl, listIdOrTitle) {
291
+ siteUrl = GetSiteUrl(siteUrl);
292
+ return GetJson(GetListRestUrl(siteUrl, listIdOrTitle) + `/EffectiveBasePermissions`, null, { ...shortLocalCache })
293
+ .then(r => {
294
+ return new SPBasePermissions(r.d.EffectiveBasePermissions).has(SPBasePermissionKind.ManageLists);
295
+ })
296
+ .catch(() => null);
297
+ }
298
+ export function UserHasEditPermissions(siteUrl, listIdOrTitle) {
299
+ return UserHasPermissions(siteUrl, listIdOrTitle, SPBasePermissionKind.EditListItems);
300
+ }
301
+ export function UserHasPermissions(siteUrlOrId, listIdOrTitle, permissionKind) {
302
+ let siteUrl = GetSiteUrl(siteUrlOrId);
303
+ return GetJson(GetListRestUrl(siteUrl, listIdOrTitle) + `/EffectiveBasePermissions`, null, { ...shortLocalCache })
304
+ .then(r => {
305
+ return new SPBasePermissions(r.d.EffectiveBasePermissions).has(permissionKind);
306
+ })
307
+ .catch(() => null);
308
+ }
309
+ export function UserHasPermissionsSync(siteUrlOrId, listIdOrTitle, permissionKind) {
310
+ let siteUrl = GetSiteUrl(siteUrlOrId);
311
+ const res = GetJsonSync(GetListRestUrl(siteUrl, listIdOrTitle) + `/EffectiveBasePermissions`, null, { ...shortLocalCache });
312
+ return new SPBasePermissions(res.result.d.EffectiveBasePermissions).has(permissionKind);
313
+ }
314
+ /** 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 */
315
+ export async function CreateField(siteUrl, listIdOrTitle, options) {
316
+ siteUrl = GetSiteUrl(siteUrl);
317
+ let finish = async (result) => {
318
+ if (!result) {
319
+ return null;
320
+ }
321
+ let internalName = result.InternalName;
322
+ //we need to clear and reload the list fields cache, so call it and return our field from that collection.
323
+ let fields = await GetListFields(siteUrl, listIdOrTitle, { refreshCache: true });
324
+ try {
325
+ if (options.SkipAddToDefaultView !== true) {
326
+ //try to add it to default view, don't wait for it
327
+ GetListViews(siteUrl, listIdOrTitle).then(views => {
328
+ let defaultView = firstOrNull(views, v => v.DefaultView);
329
+ if (defaultView)
330
+ GetJson(GetListRestUrl(siteUrl, listIdOrTitle) + `/views('${defaultView.Id}')/ViewFields/addViewField('${internalName}')`, null, { method: "POST", spWebUrl: siteUrl });
331
+ });
332
+ }
333
+ }
334
+ catch (e) { }
335
+ return firstOrNull(fields, f => f.InternalName === internalName);
336
+ };
337
+ if (!isNullOrEmptyString(options.SchemaXml)) {
338
+ try {
339
+ let updateObject = {
340
+ 'parameters': {
341
+ '__metadata': { 'type': 'SP.XmlSchemaFieldCreationInformation' },
342
+ 'SchemaXml': options.SchemaXml,
343
+ 'Options': options.SchemaXmlSpecificInternalName !== true ?
344
+ 4 : //SP.AddFieldOptions.addToAllContentTypes
345
+ 4 | 8 //SP.AddFieldOptions.addToAllContentTypes | addFieldInternalNameHint
346
+ }
347
+ };
348
+ let url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/fields/createFieldAsXml`;
349
+ let newFieldResult = await GetJson(url, JSON.stringify(updateObject));
350
+ if (!isNullOrUndefined(newFieldResult)
351
+ && !isNullOrUndefined(newFieldResult.d)) {
352
+ if ((!isNullOrEmptyString(options.Title) && options.Title !== newFieldResult.d.Title)
353
+ || (isBoolean(options.Indexed) && options.Indexed !== newFieldResult.d.Indexed)) {
354
+ let updatedField = await UpdateField(siteUrl, listIdOrTitle, newFieldResult.d.InternalName, {
355
+ Title: options.Title,
356
+ Indexed: options.Indexed === true
357
+ });
358
+ return finish(updatedField);
359
+ }
360
+ }
361
+ return finish(newFieldResult && newFieldResult.d);
362
+ }
363
+ catch {
364
+ }
365
+ return null;
366
+ }
367
+ else if (!isNullOrEmptyString(options.Title) && !isNullOrUndefined(options.Type)) {
368
+ let updateObject = {
369
+ '__metadata': { 'type': 'SP.Field' },
370
+ 'Title': options.Title,
371
+ 'FieldTypeKind': options.Type,
372
+ 'Required': options.Required === true,
373
+ 'Indexed': options.Indexed === true
374
+ };
375
+ if (!isNullOrEmptyString(options.ClientSideComponentId)) {
376
+ updateObject.ClientSideComponentId = options.ClientSideComponentId;
377
+ }
378
+ if (!isNullOrEmptyString(options.ClientSideComponentProperties)) {
379
+ updateObject.ClientSideComponentProperties = options.ClientSideComponentProperties;
380
+ }
381
+ if (!isNullOrEmptyString(options.JSLink)) {
382
+ updateObject.JSLink = options.JSLink;
383
+ }
384
+ try {
385
+ let url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/fields`;
386
+ let newFieldResult = await GetJson(url, JSON.stringify(updateObject));
387
+ return finish(newFieldResult && newFieldResult.d);
388
+ }
389
+ catch {
390
+ }
391
+ return null;
392
+ }
393
+ else {
394
+ console.error("You must send either SchemaXml or Title and Type");
395
+ return null;
396
+ }
397
+ }
398
+ /** Update field SchemaXml OR Title, only 1 update at a time supported. */
399
+ export async function UpdateField(siteUrlOrId, listIdOrTitle, fieldInternalName, options) {
400
+ let siteUrl = GetSiteUrl(siteUrlOrId);
401
+ let finish = async () => {
402
+ //we need to clear and reload the list fields cache, so call it and return our field from that collection.
403
+ let fields = await GetListFields(siteUrl, listIdOrTitle, { refreshCache: true });
404
+ return firstOrNull(fields, f => f.InternalName === fieldInternalName);
405
+ };
406
+ let fields = await GetListFieldsAsHash(siteUrl, listIdOrTitle, true);
407
+ let thisField = fields[fieldInternalName];
408
+ //updates can either be SchemaXml, or others. Cannot be both.
409
+ let updates = {
410
+ '__metadata': { 'type': 'SP.Field' }
411
+ };
412
+ if (!isNullOrEmptyString(options.SchemaXml)) {
413
+ updates.SchemaXml = options.SchemaXml;
414
+ }
415
+ else {
416
+ //cannot send schema updates with other updates.
417
+ if (!isNullOrEmptyString(options.Title)) {
418
+ updates.Title = options.Title;
419
+ }
420
+ if (!isNullOrEmptyString(options.FieldType)) {
421
+ updates.TypeAsString = options.FieldType;
422
+ }
423
+ if (isBoolean(options.Required)) {
424
+ updates.Required = options.Required === true;
425
+ }
426
+ if (isBoolean(options.Indexed)) {
427
+ updates.Indexed = options.Indexed === true;
428
+ }
429
+ if (!isNullOrEmptyArray(options.Choices)) {
430
+ let choiceType = options.FieldType || thisField.TypeAsString;
431
+ if (choiceType === "Choice" || choiceType === "MultiChoice") {
432
+ updates["__metadata"]["type"] = choiceType === "Choice" ? "SP.FieldChoice" : "SP.FieldMultiChoice";
433
+ updates.Choices = { "results": options.Choices };
434
+ }
435
+ else {
436
+ logger.warn("Can only update 'Choices' property on 'Choice' and 'MultiChoice' field types.");
437
+ }
438
+ }
439
+ if (isBoolean(options.Hidden)) {
440
+ //this requries the CanToggleHidden to be in the schema... if not - we will need to add it before we can update this.
441
+ let fields = await GetListFieldsAsHash(siteUrl, listIdOrTitle, false);
442
+ let thisField = fields[fieldInternalName];
443
+ if (thisField.Hidden !== options.Hidden) {
444
+ if (thisField) {
445
+ if (thisField.SchemaJson.Attributes.CanToggleHidden !== "TRUE") {
446
+ await UpdateField(siteUrl, listIdOrTitle, fieldInternalName, {
447
+ SchemaXml: thisField.SchemaXml.replace("<Field ", `<Field CanToggleHidden="TRUE" `)
448
+ });
449
+ }
450
+ }
451
+ updates.Hidden = options.Hidden === true;
452
+ }
453
+ }
454
+ if (!isNullOrEmptyString(options.ClientSideComponentId))
455
+ updates.ClientSideComponentId = options.ClientSideComponentId;
456
+ if (!isNullOrEmptyString(options.ClientSideComponentProperties))
457
+ updates.ClientSideComponentProperties = options.ClientSideComponentProperties;
458
+ if (!isNullOrEmptyString(options.JSLink))
459
+ updates.JSLink = options.JSLink;
460
+ }
461
+ if (Object.keys(updates).length > 1) {
462
+ return GetJson(GetListRestUrl(siteUrl, listIdOrTitle) + `/fields/getbyinternalnameortitle('${fieldInternalName}')`, JSON.stringify(updates), { xHttpMethod: "MERGE" })
463
+ .then(r => {
464
+ return finish();
465
+ })
466
+ .catch(() => null);
467
+ }
468
+ else {
469
+ console.error("You must send an option to update");
470
+ return null;
471
+ }
472
+ }
473
+ export async function DeleteField(siteUrl, listIdOrTitle, fieldInternalName, options) {
474
+ siteUrl = GetSiteUrl(siteUrl);
475
+ // let finish = async () => {
476
+ // //we need to clear and reload the list fields cache, so call it and return our field from that collection.
477
+ // let fields = await GetListFields(siteUrl, listIdOrTitle, { refreshCache: true });
478
+ // return firstOrNull(fields, f => f.InternalName === fieldInternalName);
479
+ // };
480
+ if (options && options.DeleteHiddenField)
481
+ await UpdateField(siteUrl, listIdOrTitle, fieldInternalName, { Hidden: false });
482
+ return GetJson(GetListRestUrl(siteUrl, listIdOrTitle) + `/fields/getbyinternalnameortitle('${fieldInternalName}')`, null, {
483
+ method: "POST",
484
+ xHttpMethod: "DELETE"
485
+ })
486
+ .then(r => true)
487
+ .catch((e) => false);
488
+ }
489
+ export function GetListViews(siteUrl, listIdOrTitle, options) {
490
+ siteUrl = GetSiteUrl(siteUrl);
491
+ return GetJson(GetListRestUrl(siteUrl, listIdOrTitle) + `/views?$select=Title,Id,ServerRelativeUrl,RowLimit,Paged,ViewQuery,ListViewXml,PersonalView,MobileView,MobileDefaultView,Hidden,DefaultView,ReadOnlyView${options && options.includeViewFields ? "&$expand=ViewFields" : ""}`, null, { allowCache: true, jsonMetadata: jsonTypes.nometadata })
492
+ .then(r => {
493
+ let views = r.value;
494
+ if (isNotEmptyArray(views)) {
495
+ views.forEach(v => {
496
+ v.Id = normalizeGuid(v.Id);
497
+ if (options && options.includeViewFields) {
498
+ v.ViewFields = v.ViewFields && v.ViewFields["Items"] && v.ViewFields["Items"] || [];
499
+ }
500
+ });
501
+ }
502
+ return views;
503
+ })
504
+ .catch(() => null);
505
+ }
506
+ export function GetListViewsSync(siteUrl, listIdOrTitle) {
507
+ siteUrl = GetSiteUrl(siteUrl);
508
+ let result = GetJsonSync(GetListRestUrl(siteUrl, listIdOrTitle) + `/views`, null, { allowCache: true });
509
+ if (result.success) {
510
+ let views = result && result.result && result.result.d && result.result.d.results;
511
+ if (isNotEmptyArray(views)) {
512
+ views.forEach(v => { v.Id = normalizeGuid(v.Id); });
513
+ }
514
+ return views;
515
+ }
516
+ return null;
517
+ }
518
+ export async function AddViewFieldToListView(siteUrl, listIdOrTitle, viewId, viewField) {
519
+ return _addOrRemoveViewField(siteUrl, listIdOrTitle, viewId, viewField, "addviewfield");
520
+ }
521
+ export async function RemoveViewFieldFromListView(siteUrl, listIdOrTitle, viewId, viewField) {
522
+ return _addOrRemoveViewField(siteUrl, listIdOrTitle, viewId, viewField, "removeviewfield");
523
+ }
524
+ async function _addOrRemoveViewField(siteUrl, listIdOrTitle, viewId, viewField, action) {
525
+ siteUrl = GetSiteUrl(siteUrl);
526
+ if (isNullOrEmptyString(viewField) || !isValidGuid(viewId)) {
527
+ return false;
528
+ }
529
+ let views = await GetListViews(siteUrl, listIdOrTitle, { includeViewFields: true });
530
+ if (isNullOrEmptyArray(views)) {
531
+ return false;
532
+ }
533
+ let view = views.filter((view) => {
534
+ return normalizeGuid(view.Id) === normalizeGuid(viewId);
535
+ })[0];
536
+ if (isNullOrUndefined(view)) {
537
+ return false;
538
+ }
539
+ let hasField = view.ViewFields.includes(viewField);
540
+ if (action === "addviewfield" && hasField === true) {
541
+ return true;
542
+ }
543
+ if (action === "removeviewfield" && hasField === false) {
544
+ return true;
545
+ }
546
+ try {
547
+ let url = GetListRestUrl(siteUrl, listIdOrTitle) + `/views('${normalizeGuid(view.Id)}')/viewfields/${action}('${viewField}')`;
548
+ let result = await GetJson(url, null, { method: "POST" });
549
+ if (result && result["odata.null"] === true) {
550
+ return true;
551
+ }
552
+ }
553
+ catch { }
554
+ return false;
555
+ }
556
+ export function GetListContentTypes(siteUrl, listIdOrTitle, options, refreshCache = false) {
557
+ return GetContentTypes(siteUrl, { ...(options || {}), listIdOrTitle: listIdOrTitle }, refreshCache);
558
+ }
559
+ export function GetListContentTypesSync(siteUrl, listIdOrTitle, options, refreshCache = false) {
560
+ return GetContentTypesSync(siteUrl, { ...(options || {}), listIdOrTitle: listIdOrTitle }, refreshCache);
561
+ }
562
+ /** generic version. for the KWIZ forms version that supports action id call GetListFormUrlAppsWeb instead */
563
+ export function GetListFormUrl(siteUrl, listId, pageType, params) {
564
+ siteUrl = GetSiteUrl(siteUrl);
565
+ if (!isValidGuid(listId))
566
+ console.error('GetListFormUrl requires a list id');
567
+ let url = `${normalizeUrl(siteUrl)}/_layouts/15/listform.aspx?PageType=${pageType}&ListId=${encodeURIComponent(listId)}`;
568
+ if (params) {
569
+ if (!isNullOrEmptyString(params.contentTypeId))
570
+ url += `&ContentTypeId=${encodeURIComponent(params.contentTypeId)}`;
571
+ if (!isNullOrEmptyString(params.itemId))
572
+ url += `&ID=${encodeURIComponent(params.itemId)}`;
573
+ if (!isNullOrEmptyString(params.rootFolder))
574
+ url += `&RootFolder=${encodeURIComponent(params.rootFolder)}`;
575
+ }
576
+ return url;
577
+ }
578
+ export function GetFieldSchemaSync(siteUrl, listIdOrTitle, fieldInternalName, refreshCache) {
579
+ siteUrl = GetSiteUrl(siteUrl);
580
+ //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
581
+ //exists before requesting the schema.
582
+ let fields = GetListFieldsSync(siteUrl, listIdOrTitle, {
583
+ refreshCache: refreshCache,
584
+ fieldNames: [fieldInternalName]
585
+ });
586
+ if (isNullOrEmptyArray(fields)) {
587
+ return null;
588
+ }
589
+ let field = fields[0];
590
+ return SchemaXmlToJson(field.SchemaXml);
591
+ // let url = GetListRestUrl(siteUrl, listIdOrTitle) + `/fields/getByInternalNameOrTitle('${fieldInternalName}')?$select=SchemaXml`;
592
+ // let result = GetJsonSync<{ d: { SchemaXml: string; }; }>(
593
+ // url,
594
+ // null,
595
+ // {
596
+ // ...shortLocalCache,
597
+ // forceCacheUpdate: refreshCache === true
598
+ // });
599
+ // if (result && result.success) {
600
+ // return SchemaXmlToJson(result.result.d.SchemaXml);
601
+ // }
602
+ // return null;
603
+ //#endregion
604
+ }
605
+ export async function GetFieldSchema(siteUrl, listIdOrTitle, fieldInternalName, refreshCache) {
606
+ siteUrl = GetSiteUrl(siteUrl);
607
+ //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
608
+ //exists before requesting the schema
609
+ let fields = await GetListFields(siteUrl, listIdOrTitle, {
610
+ refreshCache: refreshCache,
611
+ fieldNames: [fieldInternalName]
612
+ });
613
+ if (isNullOrEmptyArray(fields)) {
614
+ return null;
615
+ }
616
+ let field = fields[0];
617
+ return SchemaXmlToJson(field.SchemaXml);
618
+ }
619
+ export async function GetListItems(siteUrl, listIdOrTitle, options) {
620
+ let info = _GetListItemsInfo(siteUrl, listIdOrTitle, options);
621
+ let items = [];
622
+ do {
623
+ let resultItems = [];
624
+ let next = null;
625
+ if (info.noMetadata) {
626
+ let requestResult = (await GetJson(info.requestUrl, null, {
627
+ allowCache: options.refreshCache !== true,
628
+ jsonMetadata: options.jsonMetadata
629
+ }));
630
+ resultItems = requestResult.value;
631
+ next = requestResult["odata.nextLink"];
632
+ }
633
+ else {
634
+ let requestResult = (await GetJson(info.requestUrl, null, {
635
+ allowCache: options.refreshCache !== true
636
+ }));
637
+ resultItems = requestResult.d.results;
638
+ next = requestResult.d.__next;
639
+ }
640
+ if (isNotEmptyArray(resultItems))
641
+ items.push(...resultItems);
642
+ if (info.totalNumberOfItemsToGet > items.length)
643
+ info.requestUrl = next;
644
+ else
645
+ info.requestUrl = null;
646
+ } while (!isNullOrEmptyString(info.requestUrl));
647
+ return __fixGetListItemsResults(siteUrl, listIdOrTitle, items, options.foldersBehaviour, info.expandedLookupFields);
648
+ }
649
+ export function GetListItemsSync(siteUrl, listIdOrTitle, options) {
650
+ let info = _GetListItemsInfo(siteUrl, listIdOrTitle, options);
651
+ let items = [];
652
+ do {
653
+ let resultItems = [];
654
+ let next = null;
655
+ if (info.noMetadata) {
656
+ let requestResult = GetJsonSync(info.requestUrl, null, { allowCache: true });
657
+ if (requestResult.success) {
658
+ resultItems = requestResult.result.value;
659
+ next = requestResult.result["odata.nextLink"];
660
+ }
661
+ }
662
+ else {
663
+ let requestResult = GetJsonSync(info.requestUrl, null, { allowCache: true });
664
+ if (requestResult.success) {
665
+ resultItems = requestResult.result.d.results;
666
+ next = requestResult.result.d.__next;
667
+ }
668
+ }
669
+ if (isNotEmptyArray(resultItems))
670
+ items.push(...resultItems);
671
+ if (info.totalNumberOfItemsToGet > items.length)
672
+ info.requestUrl = next;
673
+ else
674
+ info.requestUrl = null;
675
+ } while (!isNullOrEmptyString(info.requestUrl));
676
+ return __fixGetListItemsResults(siteUrl, listIdOrTitle, items, options.foldersBehaviour, info.expandedLookupFields);
677
+ }
678
+ function _GetListItemsInfo(siteUrl, listIdOrTitle, options) {
679
+ siteUrl = GetSiteUrl(siteUrl);
680
+ let url = GetListRestUrl(siteUrl, listIdOrTitle) + `/items`;
681
+ let queryParams = [];
682
+ //Issue 8189 expand lookup fields
683
+ let columns = [];
684
+ let expand = [];
685
+ let expandedLookupFields = [];
686
+ options.columns.forEach(c => {
687
+ if (isString(c))
688
+ columns.push(c);
689
+ else {
690
+ let internalName = c.InternalName;
691
+ //Issue 828, 336
692
+ if (internalName.startsWith("_"))
693
+ internalName = `OData_${internalName}`;
694
+ let isLookupField = c.TypeAsString === "Lookup" || c.TypeAsString === "LookupMulti";
695
+ let isUserField = c.TypeAsString === "User" || c.TypeAsString === "UserMulti";
696
+ if (isLookupField || isUserField) {
697
+ //ISSUE: 1519 - Added lookupField property to able to retrieve value of the additional lookup field key
698
+ let lookupField = c.LookupField;
699
+ if (!isNullOrEmptyString(lookupField) && isLookupField) {
700
+ columns.push(`${internalName}/${lookupField}`);
701
+ }
702
+ //we want to expand it
703
+ columns.push(`${internalName}/Title`);
704
+ columns.push(`${internalName}/Id`);
705
+ expand.push(internalName);
706
+ expandedLookupFields.push(c);
707
+ }
708
+ else
709
+ columns.push(internalName);
710
+ }
711
+ });
712
+ if (isNotEmptyArray(options.expand)) {
713
+ expand.push(...options.expand);
714
+ }
715
+ //add the ones we need
716
+ PushNoDuplicate(columns, "Id");
717
+ PushNoDuplicate(columns, "FileRef");
718
+ PushNoDuplicate(columns, "FileSystemObjectType");
719
+ queryParams.push(`$select=${encodeURIComponent(makeUniqueArray(columns).join(','))}`);
720
+ if (isNotEmptyArray(expand))
721
+ queryParams.push(`$expand=${encodeURIComponent(makeUniqueArray(expand).join(','))}`);
722
+ let batchSize = 2000;
723
+ let limit = options.rowLimit >= 0 && options.rowLimit < batchSize ? options.rowLimit : batchSize;
724
+ let totalNumberOfItemsToGet = !isNumber(options.rowLimit) || options.rowLimit < 1 ? 99999 : options.rowLimit > batchSize ? options.rowLimit : limit;
725
+ if (!isNullOrEmptyString(options.$filter))
726
+ queryParams.push(`$filter=${options.$filter}`);
727
+ queryParams.push(`$top=${limit}`);
728
+ let requestUrl = url + (queryParams.length > 0 ? '?' + queryParams.join('&') : '');
729
+ let noMetadata = options.jsonMetadata === jsonTypes.nometadata;
730
+ return { requestUrl, noMetadata, totalNumberOfItemsToGet, expandedLookupFields };
731
+ }
732
+ /** Find an item by id, even if it is nested in a sub-folder */
733
+ export function FindListItemById(items, itemId) {
734
+ for (let i = 0; i < items.length; i++) {
735
+ let current = items[i];
736
+ if (current.Id === itemId)
737
+ return current;
738
+ else if (isNotEmptyArray(current.__Items)) //folder? look inside
739
+ {
740
+ let nestedResult = FindListItemById(current.__Items, itemId);
741
+ if (!isNullOrUndefined(nestedResult))
742
+ return nestedResult;
743
+ }
744
+ }
745
+ //not found
746
+ return null;
747
+ }
748
+ function _getListEventReceiversRequestUrl(siteUrl, listIdOrTitle) {
749
+ return GetListRestUrl(siteUrl, listIdOrTitle) + `/EventReceivers`;
750
+ }
751
+ export async function GetListEventReceivers(siteUrl, listIdOrTitle, refreshCache) {
752
+ try {
753
+ let url = _getListEventReceiversRequestUrl(siteUrl, listIdOrTitle);
754
+ let response = await GetJson(url, null, {
755
+ allowCache: refreshCache !== true,
756
+ jsonMetadata: jsonTypes.nometadata
757
+ });
758
+ return !isNullOrUndefined(response) ? response.value : null;
759
+ }
760
+ catch {
761
+ }
762
+ return null;
763
+ }
764
+ export async function AddListEventReceiver(siteUrl, listIdOrTitle, eventReceiverDefinition) {
765
+ let newEventReceiver = {
766
+ ReceiverAssembly: "",
767
+ ReceiverClass: "",
768
+ ...eventReceiverDefinition
769
+ };
770
+ try {
771
+ let url = _getListEventReceiversRequestUrl(siteUrl, listIdOrTitle);
772
+ let response = await GetJson(url, JSON.stringify(newEventReceiver), {
773
+ method: "POST",
774
+ includeDigestInPost: true,
775
+ jsonMetadata: jsonTypes.nometadata,
776
+ headers: {
777
+ "content-type": contentTypes.json
778
+ }
779
+ });
780
+ return !isNullOrUndefined(response) && isValidGuid(response.ReceiverId) ? response : null;
781
+ }
782
+ catch {
783
+ }
784
+ return null;
785
+ }
786
+ export async function DeleteListEventReceiver(siteUrl, listIdOrTitle, eventReceiverId) {
787
+ try {
788
+ let url = `${_getListEventReceiversRequestUrl(siteUrl, listIdOrTitle)}('${normalizeGuid(eventReceiverId)}')/deleteObject`;
789
+ let response = await GetJson(url, null, {
790
+ method: "POST",
791
+ includeDigestInPost: true,
792
+ jsonMetadata: jsonTypes.nometadata
793
+ });
794
+ return !isNullOrUndefined(response) && response["odata.null"] === true;
795
+ }
796
+ catch {
797
+ }
798
+ return false;
799
+ }
800
+ export function GetListLastItemModifiedDate(siteUrl, listIdOrTitle, options) {
801
+ siteUrl = GetSiteUrl(siteUrl);
802
+ let endPoint = options && options.userChangesOnly ? 'LastItemUserModifiedDate' : 'LastItemModifiedDate';
803
+ let sync = options && options.sync ? true : false;
804
+ let caller = sync ? GetJsonSync : GetJson;
805
+ let result = caller(GetListRestUrl(siteUrl, listIdOrTitle) + `/${endPoint}`, null, {
806
+ allowCache: true, //in memory only
807
+ jsonMetadata: jsonTypes.nometadata,
808
+ forceCacheUpdate: options && options.refreshCache === true || false
809
+ });
810
+ if (isPromise(result))
811
+ return result.then(r => r.value, () => null);
812
+ else
813
+ return result.success ? result.result.value : null;
814
+ }
815
+ export async function ReloadListLastModified(siteUrl, listIdOrTitle) {
816
+ await GetListLastItemModifiedDate(siteUrl, listIdOrTitle, { refreshCache: true });
817
+ //make sure we do it for both title and id, we don't know how the other callers may use this in their API
818
+ if (!isValidGuid(listIdOrTitle)) {
819
+ try {
820
+ var listId = GetListId(siteUrl, listIdOrTitle);
821
+ await GetListLastItemModifiedDate(siteUrl, listId, { refreshCache: true });
822
+ }
823
+ catch (e) { }
824
+ }
825
+ else {
826
+ try {
827
+ var listTitle = await GetListTitle(siteUrl, listIdOrTitle);
828
+ await GetListLastItemModifiedDate(siteUrl, listTitle, { refreshCache: true });
829
+ }
830
+ catch (e) { }
831
+ }
832
+ }
833
+ export async function ListHasUniquePermissions(siteUrl, listIdOrTitle) {
834
+ let url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/?$select=hasuniqueroleassignments`;
835
+ let has = await GetJson(url, undefined, { allowCache: false, jsonMetadata: jsonTypes.nometadata });
836
+ return has.HasUniqueRoleAssignments === true;
837
+ }
838
+ export async function RestoreListPermissionInheritance(siteUrl, listIdOrTitle) {
839
+ let url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/ResetRoleInheritance`;
840
+ await GetJson(url, undefined, { method: "POST", allowCache: false, jsonMetadata: jsonTypes.nometadata, spWebUrl: siteUrl });
841
+ }
842
+ export async function BreakListPermissionInheritance(siteUrl, listIdOrTitle, clear = true) {
843
+ let url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/breakroleinheritance(copyRoleAssignments=${clear ? 'false' : 'true'}, clearSubscopes=true)`;
844
+ await GetJson(url, undefined, { method: "POST", allowCache: false, jsonMetadata: jsonTypes.nometadata, spWebUrl: siteUrl });
845
+ }
846
+ export async function AssignListPermission(siteUrl, listIdOrTitle, principalId, roleId) {
847
+ let url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/roleassignments/addroleassignment(principalid=${principalId},roleDefId=${roleId})`;
848
+ await GetJson(url, undefined, { method: "POST", allowCache: false, jsonMetadata: jsonTypes.nometadata, spWebUrl: siteUrl });
849
+ }
850
+ export async function RemoveListPermission(siteUrl, listIdOrTitle, principalId, roleId) {
851
+ let url = `${GetListRestUrl(siteUrl, listIdOrTitle)}/roleassignments/removeroleassignment(principalid=${principalId},roleDefId=${roleId})`;
852
+ await GetJson(url, undefined, { method: "POST", allowCache: false, jsonMetadata: jsonTypes.nometadata, spWebUrl: siteUrl });
853
+ }
854
+ export async function CreateList(siteUrl, info) {
855
+ let url = `${GetRestBaseUrl(siteUrl)}/web/lists`;
856
+ const body = {
857
+ __metadata: { type: 'SP.List' },
858
+ AllowContentTypes: false,
859
+ ContentTypesEnabled: false,
860
+ BaseTemplate: info.template,
861
+ BaseType: info.type,
862
+ Description: info.description,
863
+ Title: info.title
864
+ };
865
+ let newList = (await GetJson(url, jsonStringify(body))).d;
866
+ normalizeGuid(newList.Id);
867
+ return newList;
868
+ }
869
+ export async function SearchList(siteUrl, listIdOrTitle, query) {
870
+ let listId = GetListId(siteUrl, listIdOrTitle);
871
+ let url = `${GetRestBaseUrl(siteUrl)}/search/query?querytext='(${query}*)'&querytemplate='{searchTerms} (NormListID:${listId})'`;
872
+ try {
873
+ const result = await GetJson(url, null, { jsonMetadata: jsonTypes.nometadata });
874
+ logger.json(result.PrimaryQueryResult.RelevantResults, `search ${query}`);
875
+ let rows = result.PrimaryQueryResult.RelevantResults.Table.Rows;
876
+ const mapped = [];
877
+ rows.forEach(r => {
878
+ try {
879
+ const rowValues = {};
880
+ r.Cells.forEach(cell => {
881
+ rowValues[cell.Key] = cell.ValueType === "Edm.Int64" || cell.ValueType === "Edm.Double"
882
+ ? parseInt(cell.Value, 10)
883
+ : cell.ValueType === "Edm.DateTime"
884
+ ? new Date(cell.Value)
885
+ : cell.ValueType === "Null"
886
+ ? ""
887
+ : cell.Value;
888
+ });
889
+ let resultPath = isNullOrEmptyString(rowValues.Path) ? "" : rowValues.Path.toLowerCase();
890
+ let indexOfId = resultPath.toLowerCase().indexOf("id=");
891
+ let itemId = indexOfId >= 0 ? parseInt(resultPath.slice(indexOfId + 3)) : -1;
892
+ if (itemId >= 0)
893
+ rowValues.$itemId = itemId;
894
+ mapped.push(rowValues);
895
+ }
896
+ catch (e) {
897
+ return null;
898
+ }
899
+ });
900
+ return mapped;
901
+ }
902
+ catch (e) {
903
+ logger.error(e);
904
+ }
905
+ return [];
906
+ }
907
+ export async function UpdateListExperience(siteUrl, listId, experience) {
908
+ try {
909
+ let url = GetListRestUrl(siteUrl, listId);
910
+ let data = {
911
+ "ListExperienceOptions": experience
912
+ };
913
+ let result = await GetJson(url, JSON.stringify(data), {
914
+ xHttpMethod: "MERGE",
915
+ jsonMetadata: jsonTypes.nometadata
916
+ });
917
+ return isNullOrEmptyString(result);
918
+ }
919
+ catch (e) {
920
+ logger.error(e);
921
+ }
922
+ return false;
923
+ }
924
+ //# sourceMappingURL=list.js.map