@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,134 @@
1
+ import { jsonParse } from "../../helpers/json";
2
+ import { isNullOrEmptyString, isNullOrUndefined, isString, isValidGuid } from "../../helpers/typecheckers";
3
+ import { makeServerRelativeUrl, normalizeUrl } from "../../helpers/url";
4
+ import { ConsoleLogger } from "../consolelogger";
5
+ import { getCacheItem, setCacheItem } from "../localstoragecache";
6
+ import { mediumLocalCache } from "../rest";
7
+ import { GetWebIdSync, GetWebInfoSync } from "./web";
8
+ const logger = ConsoleLogger.get("sharepoint.rest/common");
9
+ export const LIST_SELECT = `ListExperienceOptions,EffectiveBasePermissions,Description,Title,EnableAttachments,EnableModeration,BaseTemplate,BaseType,Id,Hidden,IsApplicationList,IsPrivate,IsCatalog,ImageUrl,ItemCount,ParentWebUrl,EntityTypeName,DefaultViewUrl,ParentWeb/Id,ParentWeb/Title`;
10
+ export const LIST_EXPAND = `ParentWeb/Id,ParentWeb/Title`;
11
+ export const WEB_SELECT = "Title,ServerRelativeUrl,Id,WebTemplate,Description,SiteLogoUrl";
12
+ export const CONTENT_TYPES_SELECT = "Name,Description,StringId,Group,Hidden,ReadOnly,NewFormUrl,DisplayFormUrl,EditFormUrl,Sealed,MobileDisplayFormUrl,MobileNewFormUrl,MobileEditFormUrl,NewFormTemplateName,DisplayFormTemplateName,EditFormTemplateName";
13
+ export const CONTENT_TYPES_SELECT_WITH_FIELDS = `${CONTENT_TYPES_SELECT},Fields`;
14
+ export function hasGlobalContext() {
15
+ //_spPageContextInfo.webServerRelativeUrl can be empty string
16
+ return typeof (_spPageContextInfo) !== "undefined" && isString(_spPageContextInfo.webServerRelativeUrl);
17
+ }
18
+ export function GetFileSiteUrl(fileUrl) {
19
+ let siteUrl;
20
+ let urlParts = fileUrl.split('/');
21
+ if (urlParts[urlParts.length - 1].indexOf('.') > 0) //file name
22
+ urlParts.pop(); //file name
23
+ let key = "GetSiteUrl|" + urlParts.join("/").toLowerCase();
24
+ siteUrl = getCacheItem(key);
25
+ if (isNullOrUndefined(siteUrl)) {
26
+ while (!isValidGuid(GetWebIdSync(urlParts.join('/'))))
27
+ urlParts.pop();
28
+ siteUrl = normalizeUrl(urlParts.join('/'));
29
+ setCacheItem(key, siteUrl, mediumLocalCache.localStorageExpiration); //keep for 15 minutes
30
+ }
31
+ //must end with / otherwise root sites will return "" and we will think there is no site url.
32
+ return makeServerRelativeUrl(normalizeUrl(siteUrl, true));
33
+ }
34
+ /** gets a site URL or null, returns the current web URL or siteUrl as relative URL - end with /
35
+ * If you send a guid - it will look for a site with that ID in the current context site collection
36
+ */
37
+ export function GetSiteUrl(siteUrlOrId) {
38
+ let siteUrl;
39
+ if (isNullOrUndefined(siteUrlOrId)) {
40
+ if (hasGlobalContext()) {
41
+ siteUrl = _spPageContextInfo.webServerRelativeUrl;
42
+ if (_spPageContextInfo.isAppWeb) //#1300 if in a classic app sub-site
43
+ siteUrl = siteUrl.substring(0, siteUrl.lastIndexOf("/"));
44
+ }
45
+ else {
46
+ siteUrl = GetFileSiteUrl(window.location.pathname);
47
+ }
48
+ }
49
+ else if (isValidGuid(siteUrlOrId)) {
50
+ //GetWebInfoSync calls GetSiteUrl recursively, but with null should not get in here
51
+ let webInfo = GetWebInfoSync(null, siteUrlOrId);
52
+ siteUrl = webInfo.ServerRelativeUrl;
53
+ }
54
+ else
55
+ siteUrl = siteUrlOrId;
56
+ //must end with / otherwise root sites will return "" and we will think there is no site url.
57
+ return makeServerRelativeUrl(normalizeUrl(siteUrl, true));
58
+ }
59
+ /** gets a site url, returns its REST _api url */
60
+ export function GetRestBaseUrl(siteUrl) {
61
+ siteUrl = GetSiteUrl(siteUrl);
62
+ return siteUrl + '_api';
63
+ }
64
+ /** Get the field internal name as you can find it in item.FieldValuesAsText[name] (Or FieldValuesForEdit) */
65
+ export function DecodeFieldValuesAsTextKey(key) {
66
+ return key.replace(/_x005f_/g, "_").replace('OData__', '_');
67
+ }
68
+ /** Gets REST FieldValuesAsText or FieldValuesForEdit and fix their column names so that you can get a field value by its internal name */
69
+ export function DecodeFieldValuesAsText(FieldValuesAsText) {
70
+ return DecodeFieldValuesForEdit(FieldValuesAsText);
71
+ }
72
+ /** Gets REST FieldValuesAsText or FieldValuesForEdit and fix their column names so that you can get a field value by its internal name */
73
+ export function DecodeFieldValuesForEdit(FieldValuesForEdit) {
74
+ let result = {};
75
+ Object.keys(FieldValuesForEdit).forEach(key => {
76
+ result[DecodeFieldValuesAsTextKey(key)] = FieldValuesForEdit[key];
77
+ });
78
+ return result;
79
+ }
80
+ /** Get the field internal name as you can find it in the item[name] to get raw values */
81
+ export function GetFieldNameFromRawValues(field,
82
+ //ISSUE: 1250
83
+ options = {
84
+ excludeIdFromName: false
85
+ }) {
86
+ let fieldName = field.InternalName;
87
+ if (options.excludeIdFromName !== true && (field.TypeAsString === "User" ||
88
+ field.TypeAsString === "UserMulti" ||
89
+ field.TypeAsString === "Lookup" ||
90
+ field.TypeAsString === "LookupMulti" ||
91
+ field.InternalName === "ContentType")) {
92
+ fieldName = fieldName += "Id";
93
+ }
94
+ //issue 6698 fields that are too short will encode their first letter, and will start with _. this will add OData_ as a prefix in REST
95
+ //Issue 336 _EndDate > OData__EndDate
96
+ if (fieldName.startsWith('_')) {
97
+ fieldName = "OData_" + fieldName;
98
+ }
99
+ return fieldName;
100
+ }
101
+ /** Get the field name to set on the item update REST request */
102
+ export function getFieldNameForUpdate(field) {
103
+ if (field.TypeAsString === "TaxonomyFieldTypeMulti") {
104
+ //Updating multi taxonomy value is allowed as string to the associated hidden text field
105
+ return field.HiddenMultiValueFieldName;
106
+ }
107
+ return GetFieldNameFromRawValues(field);
108
+ }
109
+ export function __isIRestError(e) {
110
+ let x = e;
111
+ return !isNullOrUndefined(x) && !isNullOrUndefined(x.xhr) && isString(x.message);
112
+ }
113
+ /** extract the error message from a SharePoint REST failed request */
114
+ export function __getSPRestErrorData(restError) {
115
+ let code = "Unknown";
116
+ let errorMessage = "Unspecified error";
117
+ if (restError && restError.message)
118
+ errorMessage = restError.message;
119
+ if (restError && restError.xhr && !isNullOrEmptyString(restError.xhr.responseText)) {
120
+ let errorData = jsonParse(restError.xhr.responseText);
121
+ let error = errorData && errorData.error;
122
+ if (!error && errorData) //in minimal rest - error is in "odata.error"
123
+ error = errorData && errorData["odata.error"];
124
+ if (error) {
125
+ if (error && error.message && error.message.value)
126
+ errorMessage = error.message.value;
127
+ if (error && error.code)
128
+ code = error.code;
129
+ }
130
+ }
131
+ logger.error(errorMessage);
132
+ return { code: code, message: errorMessage };
133
+ }
134
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../src/utils/sharepoint.rest/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC3G,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAKxE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC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AAC;IACD,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC3B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAkB,CAAC;AACjE,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { isISODate, isISODateUTC } from "../../helpers/date";
2
+ import { isDate, isNullOrEmptyString, isNullOrUndefined } from "../../helpers/typecheckers";
3
+ import { toIsoDateFormat } from "../date";
4
+ import { LocaleKnownScript } from "../knownscript";
5
+ import { SPServerLocalTimeToUTCSync } from "./web";
6
+ function _SPServerLocalTimeToUTC(dateValueStr) {
7
+ //yyyy-MM-ddTHH:mm or SPServerLocalTime (5/27/2021 11:34) to UTC
8
+ let utcTimeValue = SPServerLocalTimeToUTCSync(_spPageContextInfo.webServerRelativeUrl, dateValueStr);
9
+ if (!isNullOrEmptyString(utcTimeValue)) {
10
+ return new Date(utcTimeValue);
11
+ }
12
+ return null;
13
+ }
14
+ export function parseDate(value) {
15
+ if (isNullOrUndefined(value) || (isNullOrEmptyString(value) && !isDate(value))) {
16
+ return null;
17
+ }
18
+ let dateValueStr = isDate(value) ? value.toISOString() : value;
19
+ var valueAsDate = null;
20
+ if (isISODateUTC(dateValueStr)) {
21
+ valueAsDate = new Date(dateValueStr);
22
+ }
23
+ else if (isISODate(dateValueStr)) {
24
+ //yyyy-MM-ddTHH:mm or SPServerLocalTime (5/27/2021 11:34) to UTC
25
+ valueAsDate = _SPServerLocalTimeToUTC(dateValueStr);
26
+ }
27
+ else {
28
+ //Don't think this is necessary because the SPServerLocalTimeToUTCSync can accept date strings in non ISO format (5/27/2021 11:34)
29
+ var dateParts = dateValueStr.split(" ");
30
+ if (dateParts.length) {
31
+ let locales = LocaleKnownScript.loadSync();
32
+ valueAsDate = locales.ParseDate(dateValueStr);
33
+ dateValueStr = toIsoDateFormat(valueAsDate, { omitZ: true });
34
+ valueAsDate = _SPServerLocalTimeToUTC(dateValueStr);
35
+ if (valueAsDate instanceof Date && dateParts.length === 2) {
36
+ var time = dateParts[1];
37
+ if (time.length) {
38
+ var timeParts = locales.GetCurrentCulture() ? locales.GetCurrentCulture().dateTimeFormat.TimeSeparator : ":";
39
+ if (timeParts.length === 2) {
40
+ var hours = Number(timeParts[0]);
41
+ var minutes = Number(timeParts[1]);
42
+ valueAsDate.setHours(hours);
43
+ valueAsDate.setMinutes(minutes);
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+ if (!valueAsDate) {
50
+ valueAsDate = new Date(dateValueStr);
51
+ }
52
+ return isDate(valueAsDate) ? valueAsDate : null;
53
+ }
54
+ //# sourceMappingURL=date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../src/utils/sharepoint.rest/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE5F,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,OAAO,CAAC;AAEnD,SAAS,uBAAuB,CAAC,YAAoB;IACjD,gEAAgE;IAChE,IAAI,YAAY,GAAG,0BAA0B,CAAC,kBAAkB,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC;IAErG,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,EAAE,CAAC;QACrC,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAoB;IAC1C,IAAI,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAA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GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;wBACjC,IAAI,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;wBAEnC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;wBAC5B,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBACpC,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED,IAAI,CAAC,WAAW,EAAE,CAAC;QACf,WAAW,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;AACpD,CAAC"}
@@ -0,0 +1,12 @@
1
+ export * from './listutils/exports-index';
2
+ export * from './common';
3
+ export * from './date';
4
+ export * from './file.folder';
5
+ export * from './item';
6
+ export * from './list';
7
+ export * from './location';
8
+ export * from './navigation-links';
9
+ export * from './user-search';
10
+ export * from './user';
11
+ export * from './web';
12
+ //# sourceMappingURL=exports-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports-index.js","sourceRoot":"","sources":["../../../../src/utils/sharepoint.rest/exports-index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC"}
@@ -0,0 +1,444 @@
1
+ import { jsonStringify } from "../../helpers/json";
2
+ import { isNotEmptyArray, isNullOrEmptyString, isNullOrUndefined, isNumber, isNumeric, newGuid } from "../../helpers/typecheckers";
3
+ import { encodeURIComponentEX, makeServerRelativeUrl, normalizeUrl } from "../../helpers/url";
4
+ import { jsonTypes } from "../../types/rest.types";
5
+ import { ConsoleLogger } from "../consolelogger";
6
+ import { GetJson, GetJsonSync, longLocalCache, mediumLocalCache, noLocalCache, shortLocalCache } from "../rest";
7
+ import { GetRestBaseUrl, GetSiteUrl } from "./common";
8
+ import { GetListRestUrl } from "./list";
9
+ const logger = ConsoleLogger.get("SharePoint.Rest.FileNFolder");
10
+ let existingFolders = [];
11
+ export async function EnsureFolderPath(siteUrl, folderServerRelativeUrl) {
12
+ siteUrl = GetSiteUrl(siteUrl);
13
+ //issue 7176
14
+ folderServerRelativeUrl = makeServerRelativeUrl(folderServerRelativeUrl, siteUrl);
15
+ if (existingFolders.indexOf(folderServerRelativeUrl) >= 0) {
16
+ return true;
17
+ }
18
+ let url = `${GetRestBaseUrl(siteUrl)}/Web/getFolderByServerRelativeUrl(serverRelativeUrl='${folderServerRelativeUrl}')?$select=exists`;
19
+ let folder = await GetJson(url);
20
+ if (folder && folder.d.Exists) {
21
+ existingFolders.push(folderServerRelativeUrl);
22
+ return true;
23
+ }
24
+ else {
25
+ let parts = folderServerRelativeUrl.split('/');
26
+ if (parts.length > 1) {
27
+ let parentFolder = parts.slice(0, parts.length - 1).join('/');
28
+ //ensure parent
29
+ let parent = await EnsureFolderPath(siteUrl, parentFolder);
30
+ if (parent) {
31
+ //create it
32
+ let ensure = await EnsureFolder(siteUrl, parentFolder, parts[parts.length - 1]);
33
+ if (ensure.Exists) {
34
+ existingFolders.push(folderServerRelativeUrl);
35
+ return true;
36
+ }
37
+ }
38
+ }
39
+ }
40
+ return false;
41
+ }
42
+ export function EnsureFolder(siteUrl, parentFolderServerRelativeUrl, folderName) {
43
+ siteUrl = GetSiteUrl(siteUrl);
44
+ parentFolderServerRelativeUrl = makeServerRelativeUrl(parentFolderServerRelativeUrl, siteUrl);
45
+ return GetJson(`${GetRestBaseUrl(siteUrl)}/Web/getFolderByServerRelativeUrl(serverRelativeUrl='${parentFolderServerRelativeUrl}')/folders/add(url='${folderName}')`, null, { method: "POST", spWebUrl: siteUrl })
46
+ .then(r => { return r.d; })
47
+ .catch(() => { return { Exists: false }; });
48
+ }
49
+ export function DeleteFolder(siteUrl, folderUrl) {
50
+ siteUrl = GetSiteUrl(siteUrl);
51
+ folderUrl = makeServerRelativeUrl(folderUrl, siteUrl);
52
+ var requestUrl = `${GetRestBaseUrl(siteUrl)}/Web/getFolderByServerRelativeUrl(serverRelativeUrl='${folderUrl}')`;
53
+ return GetJson(requestUrl, null, {
54
+ method: "POST",
55
+ xHttpMethod: "DELETE"
56
+ })
57
+ .then(r => true)
58
+ .catch((e) => false);
59
+ }
60
+ export function GetFolderFiles(siteUrl, folderUrl) {
61
+ siteUrl = GetSiteUrl(siteUrl);
62
+ folderUrl = makeServerRelativeUrl(folderUrl, siteUrl);
63
+ var requestUrl = `${GetRestBaseUrl(siteUrl)}/Web/getFolderByServerRelativeUrl(serverRelativeUrl='${folderUrl}')`
64
+ + `/files?$select=Exists,Name,ServerRelativeUrl,Title,TimeCreated,TimeLastModified`;
65
+ return GetJson(requestUrl).then(r => {
66
+ return r.d && r.d.results || [];
67
+ }).catch(() => {
68
+ return [];
69
+ });
70
+ }
71
+ export function UploadFileSync(siteUrl, folderServerRelativeUrl, fileName, fileContent) {
72
+ siteUrl = GetSiteUrl(siteUrl);
73
+ folderServerRelativeUrl = makeServerRelativeUrl(folderServerRelativeUrl, siteUrl);
74
+ let res = GetJsonSync(`${GetRestBaseUrl(siteUrl)}/Web/getFolderByServerRelativeUrl(serverRelativeUrl='${folderServerRelativeUrl}')/files/add(url='${fileName}',overwrite=true)?$expand=ListItemAllFields`, fileContent, {
75
+ method: 'POST',
76
+ spWebUrl: siteUrl
77
+ });
78
+ return res.success && res.result && res.result.d ? res.result.d : { Exists: false };
79
+ }
80
+ export async function UploadFile(siteUrl, folderServerRelativeUrl, fileName, fileContent,
81
+ /** default options: { overwrite: true } */
82
+ options) {
83
+ siteUrl = GetSiteUrl(siteUrl);
84
+ options = options || { overwrite: true };
85
+ folderServerRelativeUrl = makeServerRelativeUrl(folderServerRelativeUrl, siteUrl);
86
+ if (options && options.autoRename) {
87
+ //get all files from this folder and find the next available name
88
+ let files = await GetFolderFiles(siteUrl, folderServerRelativeUrl);
89
+ let fileNames = files.map(f => f.Name.toLowerCase());
90
+ let counter = 0;
91
+ let originalName = fileName.split('.');
92
+ originalName.splice(originalName.length - 1, 0, counter.toString());
93
+ while (fileNames.includes(fileName.toLowerCase())) {
94
+ counter++;
95
+ originalName[originalName.length - 2] = counter.toString();
96
+ fileName = originalName.join('.');
97
+ }
98
+ }
99
+ return GetJson(`${GetRestBaseUrl(siteUrl)}/Web/getFolderByServerRelativeUrl(serverRelativeUrl='${folderServerRelativeUrl}')/files/add(url='${fileName}'${options.overwrite ? ',overwrite=true' : ''})?$expand=ListItemAllFields`, fileContent, {
100
+ method: 'POST',
101
+ spWebUrl: siteUrl,
102
+ allowCache: false,
103
+ postCacheKey: null
104
+ }) //Issue 6657 force set "POST" since we might send empty string as the value
105
+ .then(r => { return r.d; })
106
+ .catch(() => { return { Exists: false }; });
107
+ }
108
+ export async function PublishFile(siteUrl, fileUrl, comment = "") {
109
+ let result = await _moderateFile(siteUrl, fileUrl, "publish");
110
+ return result;
111
+ }
112
+ export async function UnpublishFile(siteUrl, fileUrl, comment = "") {
113
+ let result = await _moderateFile(siteUrl, fileUrl, "unpublish");
114
+ return result;
115
+ }
116
+ export async function ApproveFile(siteUrl, fileUrl, comment = "") {
117
+ siteUrl = GetSiteUrl(siteUrl);
118
+ let result = await _moderateFile(siteUrl, fileUrl, "approve");
119
+ return result;
120
+ }
121
+ export async function RejectFile(siteUrl, fileUrl, comment = "") {
122
+ let result = await _moderateFile(siteUrl, fileUrl, "deny");
123
+ return result;
124
+ }
125
+ async function _moderateFile(siteUrl, fileUrl, action, comment = "") {
126
+ siteUrl = GetSiteUrl(siteUrl);
127
+ let fileServerRelativeUrl = makeServerRelativeUrl(fileUrl, siteUrl);
128
+ try {
129
+ let publishUrl = `${GetRestBaseUrl(siteUrl)}/Web/getFileByServerRelativeUrl('${fileServerRelativeUrl}')/${action}('${comment}')`;
130
+ let publishResult = await GetJson(publishUrl, null, {
131
+ method: "POST",
132
+ jsonMetadata: jsonTypes.nometadata,
133
+ includeDigestInPost: true
134
+ });
135
+ return !isNullOrUndefined(publishResult) && publishResult["odata.null"] === true;
136
+ }
137
+ catch {
138
+ }
139
+ return null;
140
+ }
141
+ export function RecycleFile(siteUrl, fileServerRelativeUrl) {
142
+ siteUrl = GetSiteUrl(siteUrl);
143
+ let fileRestUrl = GetFileRestUrl(siteUrl, fileServerRelativeUrl) + "/recycle()";
144
+ return GetJson(fileRestUrl, null, {
145
+ method: "POST",
146
+ headers: {
147
+ "IF-MATCH": "*"
148
+ }
149
+ })
150
+ .then(r => true)
151
+ .catch((e) => false);
152
+ }
153
+ export function DeleteFile(siteUrl, fileServerRelativeUrl) {
154
+ siteUrl = GetSiteUrl(siteUrl);
155
+ let fileRestUrl = GetFileRestUrl(siteUrl, fileServerRelativeUrl);
156
+ return GetJson(fileRestUrl, null, {
157
+ method: "POST",
158
+ xHttpMethod: "DELETE"
159
+ })
160
+ .then(r => true)
161
+ .catch((e) => false);
162
+ }
163
+ /** get the REST url for the site/_api/web/getfile....() */
164
+ function GetFileRestUrl(siteUrl, fileServerRelativeUrl) {
165
+ fileServerRelativeUrl = makeServerRelativeUrl(fileServerRelativeUrl, siteUrl);
166
+ let fileRestUrl = `${GetRestBaseUrl(siteUrl)}/Web/getFileByServerRelativeUrl('${fileServerRelativeUrl}')`;
167
+ return fileRestUrl;
168
+ }
169
+ export function GetFileSync(siteUrl, fileServerRelativeUrl, responseType, options) {
170
+ siteUrl = GetSiteUrl(siteUrl);
171
+ let restOptions = isNullOrUndefined(options) || options.cache !== "long"
172
+ ? { ...shortLocalCache }
173
+ : { ...longLocalCache };
174
+ if (options && options.cache === "nocache")
175
+ restOptions.forceCacheUpdate = true;
176
+ if (!isNullOrUndefined(responseType)) {
177
+ restOptions.responseType = responseType;
178
+ }
179
+ let fileRestUrl = GetFileRestUrl(siteUrl, fileServerRelativeUrl);
180
+ if (!restOptions.forceCacheUpdate && reloadCacheFileModifiedRecently(siteUrl, fileServerRelativeUrl)) {
181
+ restOptions.forceCacheUpdate = true;
182
+ }
183
+ let response = GetJsonSync(`${fileRestUrl}/$value`, null, restOptions);
184
+ if (response && response.success)
185
+ return {
186
+ Exists: true,
187
+ Content: response.result
188
+ };
189
+ else
190
+ return {
191
+ Exists: false
192
+ };
193
+ }
194
+ export function GetFile(siteUrl, fileServerRelativeUrl, allowCache, responseType) {
195
+ siteUrl = GetSiteUrl(siteUrl);
196
+ let options = { ...(allowCache === true ? shortLocalCache : noLocalCache), forceCacheUpdate: allowCache !== true };
197
+ if (!isNullOrUndefined(responseType)) {
198
+ options.responseType = responseType;
199
+ }
200
+ let fileRestUrl = GetFileRestUrl(siteUrl, fileServerRelativeUrl);
201
+ if (!options.forceCacheUpdate && reloadCacheFileModifiedRecently(siteUrl, fileServerRelativeUrl)) {
202
+ options.forceCacheUpdate = true;
203
+ }
204
+ return GetJson(`${fileRestUrl}/$value`, null, options).then(r => {
205
+ return {
206
+ Exists: true,
207
+ Content: r
208
+ };
209
+ }).catch(() => {
210
+ return {
211
+ Exists: false
212
+ };
213
+ });
214
+ }
215
+ var $reloadCacheFileModifiedRecentlyFlagged = [];
216
+ function reloadCacheFileModifiedRecently(siteUrl, fileServerRelativeUrl) {
217
+ let fileRestUrl = GetFileRestUrl(siteUrl, fileServerRelativeUrl);
218
+ let key = fileRestUrl.toLowerCase();
219
+ //only flag it once, first time it is requested...
220
+ if (!$reloadCacheFileModifiedRecentlyFlagged.includes(key)) {
221
+ try {
222
+ $reloadCacheFileModifiedRecentlyFlagged.push(key);
223
+ let fileInfo = GetJsonSync(`${fileRestUrl}?$select=TimeLastModified`, null, {
224
+ allowCache: true, //only allow in-memory cache for this
225
+ jsonMetadata: jsonTypes.nometadata
226
+ });
227
+ if (fileInfo.success && fileInfo.result) {
228
+ let modified = new Date(fileInfo.result.TimeLastModified);
229
+ let now = new Date();
230
+ let difference = now.getTime() - modified.getTime();
231
+ if (difference < 5 * 60 * 1000) {
232
+ //file has changed in the past 5 minutes - do not allow cache on it.
233
+ //happens when user uses classic app to change settings, the clear cache does not clear it on the main
234
+ //site URL ( support case - Issue 778 780 & 782 )
235
+ return true;
236
+ }
237
+ }
238
+ }
239
+ catch (e) { }
240
+ }
241
+ return false;
242
+ }
243
+ export async function GetFileSize(siteUrl, fileServerRelativeUrlOrListId, itemIdOrAllowCache, allowCache) {
244
+ siteUrl = GetSiteUrl(siteUrl);
245
+ let requestUrl = "";
246
+ if (isNumber(itemIdOrAllowCache) || isNumeric(itemIdOrAllowCache)) {
247
+ requestUrl = GetListRestUrl(siteUrl, fileServerRelativeUrlOrListId) + `/items(${itemIdOrAllowCache})/File`;
248
+ }
249
+ else {
250
+ allowCache = itemIdOrAllowCache === true;
251
+ requestUrl = GetFileRestUrl(siteUrl, fileServerRelativeUrlOrListId);
252
+ }
253
+ let options = { allowCache: allowCache === true, jsonMetadata: jsonTypes.nometadata };
254
+ try {
255
+ let result = await GetJson(`${requestUrl}/Properties?$select=vti_x005f_filesize`, null, options);
256
+ return result.vti_x005f_filesize;
257
+ }
258
+ catch (e) {
259
+ return null;
260
+ }
261
+ }
262
+ export async function GetListFolders(siteUrl, listIdOrTitle) {
263
+ siteUrl = GetSiteUrl(siteUrl);
264
+ //switched to get request with no meta data - much faster.
265
+ let url = GetListRestUrl(siteUrl, listIdOrTitle) + `/items?$Select=Folder/ServerRelativeUrl,Folder/Name&$filter=FSObjType eq 1&$expand=Folder`;
266
+ let results = [];
267
+ try {
268
+ let requestResult = (await GetJson(url, null, { allowCache: true, jsonMetadata: jsonTypes.nometadata }));
269
+ if (isNotEmptyArray(requestResult && requestResult.value)) {
270
+ results = requestResult.value.map(f => ({
271
+ Name: f.Folder.Name,
272
+ ServerRelativeUrl: normalizeUrl(f.Folder.ServerRelativeUrl)
273
+ }));
274
+ }
275
+ }
276
+ catch (e) {
277
+ //Issue 7543 throttled library with lots of items will fail so return empty array
278
+ logger.error(`Could not get folders from ${listIdOrTitle}, check network for more infromation.`);
279
+ }
280
+ return results;
281
+ }
282
+ export async function GetFolder(siteUrl, folderUrl, options = {}) {
283
+ options = { includeFiles: false, includeFolders: false, allowCache: true, ...options };
284
+ siteUrl = GetSiteUrl(siteUrl);
285
+ try {
286
+ let folderServerRelativeUrl = makeServerRelativeUrl(folderUrl, siteUrl);
287
+ let restUrl = `${GetRestBaseUrl(siteUrl)}/web/getFolderByServerRelativeUrl('${encodeURIComponentEX(folderServerRelativeUrl)}')`;
288
+ if (options.includeFiles === true || options.includeFolders === true) {
289
+ let expand = [];
290
+ if (options.includeFiles) {
291
+ expand.push("Files");
292
+ }
293
+ if (options.includeFolders) {
294
+ expand.push("Folders");
295
+ }
296
+ restUrl += `?$expand=${expand.join(",")}`;
297
+ }
298
+ const result = await GetJson(restUrl, null, {
299
+ ...(options.allowCache ? mediumLocalCache : noLocalCache),
300
+ jsonMetadata: jsonTypes.nometadata
301
+ });
302
+ return result;
303
+ }
304
+ catch {
305
+ }
306
+ return null;
307
+ }
308
+ export async function GetFileItemId(siteUrl, fileServerRelativeUrl) {
309
+ siteUrl = GetSiteUrl(siteUrl);
310
+ const restUrl = `${GetRestBaseUrl(siteUrl)}/web/getFileByServerRelativeUrl('${encodeURIComponentEX(fileServerRelativeUrl)}')/ListItemAllFields/id`;
311
+ const result = await GetJson(restUrl, null, { jsonMetadata: jsonTypes.nometadata });
312
+ return result.value;
313
+ }
314
+ export async function GetFileModerationStatus(siteUrl, fileServerRelativeUrl) {
315
+ siteUrl = GetSiteUrl(siteUrl);
316
+ const restUrl = `${GetRestBaseUrl(siteUrl)}/web/getFileByServerRelativeUrl('${encodeURIComponentEX(fileServerRelativeUrl)}')/ListItemAllFields/OData__ModerationStatus`;
317
+ const result = await GetJson(restUrl, null, { jsonMetadata: jsonTypes.nometadata });
318
+ return result.value;
319
+ }
320
+ export async function GetFilePublishingStatus(siteUrl, fileServerRelativeUrl) {
321
+ siteUrl = GetSiteUrl(siteUrl);
322
+ const restUrl = `${GetRestBaseUrl(siteUrl)}/web/getFileByServerRelativeUrl('${encodeURIComponentEX(fileServerRelativeUrl)}')/level`;
323
+ const result = await GetJson(restUrl, null, { jsonMetadata: jsonTypes.nometadata });
324
+ return result.value;
325
+ }
326
+ export async function GetFileItemInfo(siteUrl, fileServerRelativeUrl) {
327
+ try {
328
+ siteUrl = GetSiteUrl(siteUrl);
329
+ const restUrl = `${GetRestBaseUrl(siteUrl)}/web/getFileByServerRelativeUrl('${encodeURIComponentEX(fileServerRelativeUrl)}')/ListItemAllFields`;
330
+ const result = await GetJson(restUrl, null, {
331
+ jsonMetadata: jsonTypes.verbose
332
+ });
333
+ const itemId = result.d.Id;
334
+ const listId = result.d.__metadata.uri.split("'")[1];
335
+ return { listId, itemId };
336
+ }
337
+ catch (e) {
338
+ return null;
339
+ }
340
+ }
341
+ export async function GetFolderItemInfo(siteUrl, folderServerRelativeUrl) {
342
+ try {
343
+ siteUrl = GetSiteUrl(siteUrl);
344
+ const restUrl = `${GetRestBaseUrl(siteUrl)}/web/getFolderByServerRelativeUrl('${encodeURIComponentEX(folderServerRelativeUrl)}')/ListItemAllFields`;
345
+ const result = await GetJson(restUrl, null, { jsonMetadata: jsonTypes.verbose });
346
+ const itemId = result.d.Id;
347
+ const listId = result.d.__metadata.uri.split("'")[1];
348
+ return { listId, itemId };
349
+ }
350
+ catch (e) {
351
+ return null;
352
+ }
353
+ }
354
+ /** Creates a modern single app page and return its URL. if a file in that name exists, it will return one with (1) appended to it. */
355
+ export async function CreateAppPage(siteUrl, info) {
356
+ //read more:
357
+ //https://petelus.sharepoint.com/sites/CMSTest/_api/SitePages/Pages/CreateAppPage
358
+ //https://spblog.net/post/2019/03/05/what-s-new-and-what-s-changed-in-sharepoint-online-rest-api-in-january-february-2019
359
+ function getFileServerRelativeUrl(siteRelative) {
360
+ const fileRelativeUrl = makeServerRelativeUrl(`${siteUrl}${siteRelative}`);
361
+ return fileRelativeUrl;
362
+ }
363
+ let webPartDataAsJson = info.webPartDataAsJson;
364
+ if (isNullOrEmptyString(webPartDataAsJson.instanceId))
365
+ webPartDataAsJson.instanceId = newGuid();
366
+ if (isNullOrEmptyString(webPartDataAsJson.dataVersion))
367
+ webPartDataAsJson.dataVersion = "1.0";
368
+ return logger.groupAsync("CreateAppPage", async (log) => {
369
+ siteUrl = GetSiteUrl(siteUrl);
370
+ const restUrl = `${GetRestBaseUrl(siteUrl)}/SitePages/Pages/CreateAppPage`;
371
+ const result = await GetJson(restUrl, jsonStringify({
372
+ webPartDataAsJson: jsonStringify(webPartDataAsJson)
373
+ }), { method: 'POST', jsonMetadata: jsonTypes.nometadata });
374
+ log(`created page`);
375
+ log(jsonStringify(result));
376
+ let fileRelativeUrl = getFileServerRelativeUrl(result.value);
377
+ const fileId = await GetFileItemId(siteUrl, fileRelativeUrl);
378
+ const updateRestUrl = `${GetRestBaseUrl(siteUrl)}/SitePages/Pages/UpdateAppPage`;
379
+ const updateResult = await GetJson(updateRestUrl, jsonStringify({
380
+ pageId: fileId,
381
+ title: info.name,
382
+ webPartDataAsJson: jsonStringify(webPartDataAsJson)
383
+ }), { method: 'POST', jsonMetadata: jsonTypes.nometadata });
384
+ log(`updated page`);
385
+ log(jsonStringify(updateResult));
386
+ fileRelativeUrl = getFileServerRelativeUrl(updateResult.value);
387
+ return fileRelativeUrl;
388
+ });
389
+ }
390
+ /** Move a file to a new name/url, this API allows for changing file extension as well */
391
+ export async function MoveFile(siteUrl, currentServerRelativeUrl, targetServerRelativeUrl, options) {
392
+ return CopyOrMoveFile(siteUrl, currentServerRelativeUrl, targetServerRelativeUrl, "move", options);
393
+ //this does NOT allow to change the file extension. only file name.
394
+ // return UpdateItem(siteUrl, listIdOrTitle, itemId, {
395
+ // FileLeafRef: newFileName "hello.txt" >> "hello.md" won't work.
396
+ // });
397
+ }
398
+ /** Copy a file to a new name/url, this API allows for changing file extension as well */
399
+ export async function CopyFile(siteUrl, currentServerRelativeUrl, targetServerRelativeUrl, options) {
400
+ return CopyOrMoveFile(siteUrl, currentServerRelativeUrl, targetServerRelativeUrl, "copy", options);
401
+ }
402
+ async function CopyOrMoveFile(siteUrl, currentServerRelativeUrl, targetServerRelativeUrl, action, options) {
403
+ try {
404
+ if (options && options.autoRename) {
405
+ let targetParts = targetServerRelativeUrl.split('/');
406
+ let fileName = targetParts.pop();
407
+ let targetFolderUrl = targetParts.join('/');
408
+ //get all files from this folder and find the next available name
409
+ let files = await GetFolderFiles(siteUrl, targetFolderUrl);
410
+ let fileNames = files.map(f => f.Name.toLowerCase());
411
+ let counter = 0;
412
+ let originalName = fileName.split('.');
413
+ originalName.splice(originalName.length - 1, 0, counter.toString());
414
+ while (fileNames.includes(fileName.toLowerCase())) {
415
+ counter++;
416
+ originalName[originalName.length - 2] = counter.toString();
417
+ fileName = originalName.join('.');
418
+ }
419
+ targetServerRelativeUrl = `${targetFolderUrl}/${fileName}`;
420
+ }
421
+ let url = `${GetRestBaseUrl(siteUrl)}/web/getfilebyserverrelativeurl('${currentServerRelativeUrl}')/`;
422
+ if (action === "copy") {
423
+ url += `copyto(strNewUrl='${targetServerRelativeUrl}',bOverwrite=${options && options.overwrite ? "true" : "false"})`;
424
+ }
425
+ else {
426
+ url += `moveto(newurl='${targetServerRelativeUrl}',flags=${options && options.overwrite ? 1 : 0})`;
427
+ }
428
+ let result = await GetJson(url, undefined, {
429
+ method: "POST",
430
+ jsonMetadata: jsonTypes.nometadata
431
+ });
432
+ logger.json(result, "CopyOrMoveFile");
433
+ return true;
434
+ }
435
+ catch (e) {
436
+ logger.json(e, "CopyOrMoveFile");
437
+ return false;
438
+ }
439
+ //this does NOT allow to change the file extension. only file name.
440
+ // return UpdateItem(siteUrl, listIdOrTitle, itemId, {
441
+ // FileLeafRef: newFileName "hello.txt" >> "hello.md" won't work.
442
+ // });
443
+ }
444
+ //# sourceMappingURL=file.folder.js.map