@pnp/cli-microsoft365 6.8.0-beta.e41be56 → 6.8.0

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 (290) hide show
  1. package/.eslintrc.js +2 -0
  2. package/.mocharc.json +1 -0
  3. package/README.md +6 -1
  4. package/dist/Command.js +6 -0
  5. package/dist/chili/chili.js +298 -0
  6. package/dist/chili/index.js +20 -0
  7. package/dist/cli/Cli.js +2 -2
  8. package/dist/m365/aad/commands/user/user-add.js +30 -21
  9. package/dist/m365/app/commands/permission/permission-add.js +279 -0
  10. package/dist/m365/app/commands.js +1 -0
  11. package/dist/m365/commands/commands.js +2 -0
  12. package/dist/m365/commands/docs.js +42 -0
  13. package/dist/m365/commands/login.js +1 -1
  14. package/dist/m365/commands/setup.js +180 -0
  15. package/dist/m365/commands/setupPresets.js +25 -0
  16. package/dist/m365/pa/commands/app/app-consent-set.js +101 -0
  17. package/dist/m365/pa/commands.js +1 -0
  18. package/dist/m365/planner/commands/roster/roster-plan-list.js +102 -0
  19. package/dist/m365/planner/commands.js +1 -0
  20. package/dist/m365/purview/commands/sensitivitylabel/sensitivitylabel-get.js +97 -0
  21. package/dist/m365/purview/commands/sensitivitylabel/sensitivitylabel-list.js +85 -0
  22. package/dist/m365/purview/commands/sensitivitylabel/sensitivitylabel-policysettings-list.js +89 -0
  23. package/dist/m365/purview/commands.js +3 -0
  24. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.2.js +25 -0
  25. package/dist/m365/spfx/commands/project/project-doctor/rules/FN001035_DEP_fluentui_react.js +18 -0
  26. package/dist/m365/spfx/commands/project/project-doctor/rules/FN021009_PKG_no_duplicate_oui_deps.js +11 -4
  27. package/dist/m365/spfx/commands/project/project-doctor.js +2 -1
  28. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN001035_DEP_fluentui_react.js +18 -0
  29. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.15.2.js +2 -0
  30. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.17.2.js +61 -0
  31. package/dist/m365/spfx/commands/project/project-upgrade.js +2 -1
  32. package/dist/m365/spfx/commands/spfx-doctor.js +29 -30
  33. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-remove.js +146 -0
  34. package/dist/m365/spo/commands/file/file-checkin.js +8 -3
  35. package/dist/m365/spo/commands/file/file-checkout.js +8 -3
  36. package/dist/m365/spo/commands/file/file-copy.js +4 -4
  37. package/dist/m365/spo/commands/file/file-get.js +3 -1
  38. package/dist/m365/spo/commands/file/file-list.js +17 -6
  39. package/dist/m365/spo/commands/file/file-move.js +6 -7
  40. package/dist/m365/spo/commands/file/file-remove.js +6 -12
  41. package/dist/m365/spo/commands/file/file-rename.js +3 -3
  42. package/dist/m365/spo/commands/file/file-roleassignment-add.js +2 -1
  43. package/dist/m365/spo/commands/file/file-roleassignment-remove.js +3 -3
  44. package/dist/m365/spo/commands/file/file-roleinheritance-break.js +2 -1
  45. package/dist/m365/spo/commands/file/file-roleinheritance-reset.js +2 -1
  46. package/dist/m365/spo/commands/file/file-sharinginfo-get.js +4 -2
  47. package/dist/m365/spo/commands/file/file-version-clear.js +3 -1
  48. package/dist/m365/spo/commands/file/file-version-get.js +3 -1
  49. package/dist/m365/spo/commands/file/file-version-remove.js +3 -1
  50. package/dist/m365/spo/commands/file/file-version-restore.js +3 -1
  51. package/dist/m365/spo/commands/folder/folder-copy.js +4 -4
  52. package/dist/m365/spo/commands/folder/folder-get.js +5 -2
  53. package/dist/m365/spo/commands/folder/folder-move.js +3 -2
  54. package/dist/m365/spo/commands/folder/folder-rename.js +5 -2
  55. package/dist/m365/spo/commands/list/list-get.js +30 -3
  56. package/dist/m365/spo/commands/list/list-list.js +39 -2
  57. package/dist/m365/spo/commands/listitem/listitem-batch-set.js +308 -0
  58. package/dist/m365/spo/commands/page/page-section-add.js +2 -3
  59. package/dist/m365/spo/commands/serviceprincipal/serviceprincipal-permissionrequest-list.js +46 -1
  60. package/dist/m365/spo/commands/site/site-recyclebinitem-move.js +119 -0
  61. package/dist/m365/spo/commands/site/site-recyclebinitem-remove.js +106 -0
  62. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-get.js +30 -39
  63. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-list.js +47 -0
  64. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-remove.js +151 -0
  65. package/dist/m365/spo/commands/tenant/tenant-commandset-remove.js +152 -0
  66. package/dist/m365/spo/commands/tenant/tenant-commandset-set.js +203 -0
  67. package/dist/m365/spo/commands/tenant/tenant-settings-set.js +4 -0
  68. package/dist/m365/spo/commands/term/term-add.js +13 -4
  69. package/dist/m365/spo/commands/term/term-get.js +14 -5
  70. package/dist/m365/spo/commands/term/term-group-get.js +12 -3
  71. package/dist/m365/spo/commands/term/term-group-list.js +39 -4
  72. package/dist/m365/spo/commands/term/term-list.js +18 -9
  73. package/dist/m365/spo/commands/term/term-set-add.js +13 -4
  74. package/dist/m365/spo/commands/term/term-set-get.js +12 -3
  75. package/dist/m365/spo/commands/term/term-set-list.js +12 -3
  76. package/dist/m365/spo/commands.js +9 -0
  77. package/dist/m365/teams/commands/chat/chat-member-remove.js +137 -0
  78. package/dist/m365/teams/commands/meeting/meeting-transcript-list.js +124 -0
  79. package/dist/m365/teams/commands.js +2 -0
  80. package/dist/utils/formatting.js +35 -11
  81. package/dist/utils/pid.js +5 -0
  82. package/dist/utils/spo.js +1 -1
  83. package/docs/docs/cmd/aad/o365group/o365group-get.md +0 -12
  84. package/docs/docs/cmd/aad/user/user-add.md +4 -0
  85. package/docs/docs/cmd/aad/user/user-set.md +2 -2
  86. package/docs/docs/cmd/adaptivecard/adaptivecard-send.md +13 -13
  87. package/docs/docs/cmd/app/app-get.md +25 -6
  88. package/docs/docs/cmd/app/app-open.md +8 -2
  89. package/docs/docs/cmd/app/permission/permission-add.md +53 -0
  90. package/docs/docs/cmd/app/permission/permission-list.md +19 -19
  91. package/docs/docs/cmd/booking/business/business-get.md +30 -8
  92. package/docs/docs/cmd/booking/business/business-list.md +17 -8
  93. package/docs/docs/cmd/cli/cli-consent.md +6 -0
  94. package/docs/docs/cmd/cli/cli-doctor.md +17 -0
  95. package/docs/docs/cmd/cli/cli-issue.md +6 -0
  96. package/docs/docs/cmd/cli/cli-reconsent.md +6 -0
  97. package/docs/docs/cmd/cli/completion/completion-sh-setup.md +6 -0
  98. package/docs/docs/cmd/cli/config/config-get.md +6 -0
  99. package/docs/docs/cmd/docs.md +51 -0
  100. package/docs/docs/cmd/flow/environment/environment-list.md +18 -0
  101. package/docs/docs/cmd/flow/flow-get.md +20 -0
  102. package/docs/docs/cmd/flow/flow-list.md +17 -0
  103. package/docs/docs/cmd/graph/changelog/changelog-list.md +52 -0
  104. package/docs/docs/cmd/graph/schemaextension/schemaextension-add.md +61 -0
  105. package/docs/docs/cmd/graph/schemaextension/schemaextension-get.md +61 -0
  106. package/docs/docs/cmd/graph/schemaextension/schemaextension-list.md +61 -0
  107. package/docs/docs/cmd/graph/schemaextension/schemaextension-remove.md +4 -0
  108. package/docs/docs/cmd/graph/schemaextension/schemaextension-set.md +4 -0
  109. package/docs/docs/cmd/graph/subscription/subscription-add.md +73 -0
  110. package/docs/docs/cmd/login.md +1 -1
  111. package/docs/docs/cmd/onedrive/onedrive-list.md +225 -0
  112. package/docs/docs/cmd/onedrive/report/report-activityfilecounts.md +39 -0
  113. package/docs/docs/cmd/onedrive/report/report-activityusercounts.md +39 -0
  114. package/docs/docs/cmd/onedrive/report/report-activityuserdetail.md +43 -0
  115. package/docs/docs/cmd/onedrive/report/report-usageaccountcounts.md +38 -0
  116. package/docs/docs/cmd/onedrive/report/report-usageaccountdetail.md +43 -0
  117. package/docs/docs/cmd/onedrive/report/report-usagefilecounts.md +38 -0
  118. package/docs/docs/cmd/onedrive/report/report-usagestorage.md +37 -0
  119. package/docs/docs/cmd/onenote/notebook/notebook-list.md +79 -0
  120. package/docs/docs/cmd/pa/app/app-consent-set.md +47 -0
  121. package/docs/docs/cmd/planner/plan/plan-get.md +1 -1
  122. package/docs/docs/cmd/planner/plan/plan-list.md +1 -1
  123. package/docs/docs/cmd/planner/roster/roster-add.md +2 -1
  124. package/docs/docs/cmd/planner/roster/roster-get.md +1 -1
  125. package/docs/docs/cmd/planner/roster/roster-plan-list.md +109 -0
  126. package/docs/docs/cmd/planner/roster/roster-remove.md +2 -1
  127. package/docs/docs/cmd/planner/task/task-get.md +0 -6
  128. package/docs/docs/cmd/planner/task/task-set.md +1 -1
  129. package/docs/docs/cmd/purview/retentionevent/retentionevent-add.md +6 -7
  130. package/docs/docs/cmd/purview/retentionevent/retentionevent-get.md +6 -7
  131. package/docs/docs/cmd/purview/retentionevent/retentionevent-list.md +4 -4
  132. package/docs/docs/cmd/purview/retentionevent/retentionevent-remove.md +4 -4
  133. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-add.md +10 -10
  134. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-get.md +11 -11
  135. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-list.md +10 -10
  136. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-remove.md +10 -10
  137. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-set.md +10 -10
  138. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-add.md +12 -12
  139. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-get.md +8 -9
  140. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-list.md +8 -9
  141. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-remove.md +8 -8
  142. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-set.md +8 -8
  143. package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-get.md +118 -0
  144. package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-list.md +111 -0
  145. package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-policysettings-list.md +97 -0
  146. package/docs/docs/cmd/search/externalconnection/externalconnection-get.md +17 -0
  147. package/docs/docs/cmd/search/externalconnection/externalconnection-list.md +17 -0
  148. package/docs/docs/cmd/setup.md +86 -0
  149. package/docs/docs/cmd/spfx/project/project-doctor.md +1 -1
  150. package/docs/docs/cmd/spfx/project/project-upgrade.md +1 -1
  151. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-add.md +1 -1
  152. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-remove.md +77 -0
  153. package/docs/docs/cmd/spo/commandset/commandset-set.md +1 -1
  154. package/docs/docs/cmd/spo/contenttype/contenttype-set.md +2 -2
  155. package/docs/docs/cmd/spo/customaction/customaction-add.md +1 -1
  156. package/docs/docs/cmd/spo/customaction/customaction-set.md +1 -1
  157. package/docs/docs/cmd/spo/feature/feature-enable.md +2 -2
  158. package/docs/docs/cmd/spo/file/file-add.md +1 -1
  159. package/docs/docs/cmd/spo/file/file-checkin.md +1 -1
  160. package/docs/docs/cmd/spo/file/file-checkout.md +1 -1
  161. package/docs/docs/cmd/spo/file/file-copy.md +1 -1
  162. package/docs/docs/cmd/spo/file/file-get.md +1 -1
  163. package/docs/docs/cmd/spo/file/file-list.md +9 -6
  164. package/docs/docs/cmd/spo/file/file-move.md +3 -3
  165. package/docs/docs/cmd/spo/file/file-remove.md +12 -0
  166. package/docs/docs/cmd/spo/file/file-rename.md +1 -1
  167. package/docs/docs/cmd/spo/file/file-retentionlabel-ensure.md +3 -3
  168. package/docs/docs/cmd/spo/file/file-retentionlabel-remove.md +2 -2
  169. package/docs/docs/cmd/spo/file/file-roleassignment-add.md +1 -1
  170. package/docs/docs/cmd/spo/file/file-roleassignment-remove.md +1 -1
  171. package/docs/docs/cmd/spo/file/file-roleinheritance-break.md +1 -1
  172. package/docs/docs/cmd/spo/file/file-roleinheritance-reset.md +1 -1
  173. package/docs/docs/cmd/spo/file/file-sharinginfo-get.md +1 -1
  174. package/docs/docs/cmd/spo/file/file-sharinglink-add.md +1 -1
  175. package/docs/docs/cmd/spo/file/file-sharinglink-clear.md +1 -1
  176. package/docs/docs/cmd/spo/file/file-sharinglink-get.md +1 -1
  177. package/docs/docs/cmd/spo/file/file-sharinglink-list.md +1 -1
  178. package/docs/docs/cmd/spo/file/file-sharinglink-remove.md +1 -1
  179. package/docs/docs/cmd/spo/file/file-sharinglink-set.md +1 -1
  180. package/docs/docs/cmd/spo/file/file-version-clear.md +2 -2
  181. package/docs/docs/cmd/spo/file/file-version-get.md +1 -1
  182. package/docs/docs/cmd/spo/file/file-version-list.md +1 -1
  183. package/docs/docs/cmd/spo/file/file-version-remove.md +1 -1
  184. package/docs/docs/cmd/spo/file/file-version-restore.md +1 -1
  185. package/docs/docs/cmd/spo/folder/folder-add.md +9 -3
  186. package/docs/docs/cmd/spo/folder/folder-copy.md +2 -2
  187. package/docs/docs/cmd/spo/folder/folder-get.md +7 -7
  188. package/docs/docs/cmd/spo/folder/folder-list.md +11 -11
  189. package/docs/docs/cmd/spo/folder/folder-move.md +1 -1
  190. package/docs/docs/cmd/spo/folder/folder-remove.md +7 -7
  191. package/docs/docs/cmd/spo/folder/folder-rename.md +11 -5
  192. package/docs/docs/cmd/spo/folder/folder-retentionlabel-ensure.md +3 -3
  193. package/docs/docs/cmd/spo/folder/folder-retentionlabel-remove.md +1 -1
  194. package/docs/docs/cmd/spo/folder/folder-roleinheritance-break.md +1 -1
  195. package/docs/docs/cmd/spo/folder/folder-roleinheritance-reset.md +4 -4
  196. package/docs/docs/cmd/spo/list/list-get.md +10 -0
  197. package/docs/docs/cmd/spo/list/list-list.md +28 -0
  198. package/docs/docs/cmd/spo/listitem/listitem-batch-set.md +67 -0
  199. package/docs/docs/cmd/spo/listitem/listitem-list.md +1 -1
  200. package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-list.md +19 -0
  201. package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-remove.md +12 -0
  202. package/docs/docs/cmd/spo/orgnewssite/orgnewssite-list.md +6 -0
  203. package/docs/docs/cmd/spo/page/page-column-get.md +15 -0
  204. package/docs/docs/cmd/spo/page/page-column-list.md +16 -0
  205. package/docs/docs/cmd/spo/page/page-control-get.md +18 -0
  206. package/docs/docs/cmd/spo/page/page-control-list.md +18 -0
  207. package/docs/docs/cmd/spo/page/page-copy.md +35 -0
  208. package/docs/docs/cmd/spo/page/page-get.md +39 -0
  209. package/docs/docs/cmd/spo/page/page-list.md +53 -0
  210. package/docs/docs/cmd/spo/page/page-section-get.md +12 -0
  211. package/docs/docs/cmd/spo/page/page-section-list.md +13 -0
  212. package/docs/docs/cmd/spo/page/page-template-list.md +31 -0
  213. package/docs/docs/cmd/spo/propertybag/propertybag-get.md +6 -0
  214. package/docs/docs/cmd/spo/propertybag/propertybag-list.md +13 -0
  215. package/docs/docs/cmd/spo/report/report-activityfilecounts.md +7 -0
  216. package/docs/docs/cmd/spo/report/report-activitypages.md +7 -0
  217. package/docs/docs/cmd/spo/report/report-activityusercounts.md +7 -0
  218. package/docs/docs/cmd/spo/report/report-activityuserdetail.md +7 -0
  219. package/docs/docs/cmd/spo/report/report-siteusagedetail.md +7 -0
  220. package/docs/docs/cmd/spo/report/report-siteusagefilecounts.md +7 -0
  221. package/docs/docs/cmd/spo/report/report-siteusagepages.md +7 -0
  222. package/docs/docs/cmd/spo/report/report-siteusagesitecounts.md +7 -0
  223. package/docs/docs/cmd/spo/report/report-siteusagestorage.md +7 -0
  224. package/docs/docs/cmd/spo/roledefinition/roledefinition-get.md +20 -0
  225. package/docs/docs/cmd/spo/roledefinition/roledefinition-list.md +20 -0
  226. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-grant-add.md +20 -0
  227. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-grant-list.md +18 -0
  228. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-permissionrequest-approve.md +20 -0
  229. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-permissionrequest-list.md +17 -0
  230. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-set.md +13 -0
  231. package/docs/docs/cmd/spo/site/site-recyclebinitem-move.md +43 -0
  232. package/docs/docs/cmd/spo/site/site-recyclebinitem-remove.md +45 -0
  233. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-add.md +1 -1
  234. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-list.md +103 -0
  235. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-remove.md +49 -0
  236. package/docs/docs/cmd/spo/tenant/tenant-commandset-remove.md +49 -0
  237. package/docs/docs/cmd/spo/tenant/tenant-commandset-set.md +57 -0
  238. package/docs/docs/cmd/spo/tenant/tenant-settings-set.md +57 -54
  239. package/docs/docs/cmd/spo/term/term-add.md +107 -6
  240. package/docs/docs/cmd/spo/term/term-get.md +111 -10
  241. package/docs/docs/cmd/spo/term/term-group-get.md +71 -5
  242. package/docs/docs/cmd/spo/term/term-group-list.md +70 -2
  243. package/docs/docs/cmd/spo/term/term-list.md +80 -8
  244. package/docs/docs/cmd/spo/term/term-set-add.md +95 -11
  245. package/docs/docs/cmd/spo/term/term-set-get.md +92 -8
  246. package/docs/docs/cmd/spo/term/term-set-list.md +85 -5
  247. package/docs/docs/cmd/teams/app/app-list.md +17 -0
  248. package/docs/docs/cmd/teams/app/app-publish.md +18 -1
  249. package/docs/docs/cmd/teams/channel/channel-add.md +20 -0
  250. package/docs/docs/cmd/teams/channel/channel-get.md +21 -0
  251. package/docs/docs/cmd/teams/channel/channel-list.md +21 -0
  252. package/docs/docs/cmd/teams/channel/channel-member-list.md +20 -0
  253. package/docs/docs/cmd/teams/channel/channel-member-set.md +21 -0
  254. package/docs/docs/cmd/teams/chat/chat-get.md +22 -0
  255. package/docs/docs/cmd/teams/chat/chat-list.md +22 -0
  256. package/docs/docs/cmd/teams/chat/chat-member-list.md +20 -0
  257. package/docs/docs/cmd/teams/chat/chat-member-remove.md +52 -0
  258. package/docs/docs/cmd/teams/chat/chat-message-list.md +23 -0
  259. package/docs/docs/cmd/teams/funsettings/funsettings-list.md +15 -0
  260. package/docs/docs/cmd/teams/guestsettings/guestsettings-list.md +13 -0
  261. package/docs/docs/cmd/teams/meeting/meeting-transcript-list.md +96 -0
  262. package/docs/docs/cmd/teams/membersettings/membersettings-list.md +17 -0
  263. package/docs/docs/cmd/teams/tab/tab-remove.md +1 -1
  264. package/docs/docs/cmd/todo/list/list-add.md +18 -0
  265. package/docs/docs/cmd/todo/list/list-get.md +18 -0
  266. package/docs/docs/cmd/todo/list/list-list.md +18 -0
  267. package/docs/docs/cmd/todo/task/task-get.md +21 -0
  268. package/docs/docs/cmd/todo/task/task-list.md +21 -0
  269. package/docs/docs/cmd/util/accesstoken/accesstoken-get.md +6 -0
  270. package/docs/docs/cmd/version.md +1 -1
  271. package/docs/docs/cmd/viva/connections/connections-app-create.md +3 -3
  272. package/docs/docs/cmd/yammer/group/group-list.md +42 -0
  273. package/docs/docs/cmd/yammer/message/message-add.md +32 -0
  274. package/docs/docs/cmd/yammer/message/message-get.md +32 -0
  275. package/docs/docs/cmd/yammer/message/message-list.md +34 -0
  276. package/docs/docs/cmd/yammer/network/network-list.md +70 -0
  277. package/docs/docs/cmd/yammer/report/report-activitycounts.md +7 -0
  278. package/docs/docs/cmd/yammer/report/report-activityusercounts.md +7 -0
  279. package/docs/docs/cmd/yammer/report/report-activityuserdetail.md +7 -0
  280. package/docs/docs/cmd/yammer/report/report-deviceusagedistributionusercounts.md +7 -0
  281. package/docs/docs/cmd/yammer/report/report-deviceusageusercounts.md +7 -0
  282. package/docs/docs/cmd/yammer/report/report-deviceusageuserdetail.md +7 -0
  283. package/docs/docs/cmd/yammer/report/report-groupsactivitycounts.md +7 -0
  284. package/docs/docs/cmd/yammer/report/report-groupsactivitydetail.md +7 -0
  285. package/docs/docs/cmd/yammer/report/report-groupsactivitygroupcounts.md +7 -0
  286. package/docs/docs/cmd/yammer/user/user-get.md +55 -0
  287. package/docs/docs/cmd/yammer/user/user-list.md +55 -0
  288. package/docs/docs/cmd/yammer/yammer-search.md +15 -3
  289. package/npm-shrinkwrap.json +267 -334
  290. package/package.json +15 -13
@@ -0,0 +1,308 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
17
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
18
+ var m = o[Symbol.asyncIterator], i;
19
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
20
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
21
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
22
+ };
23
+ var _SpoListItemBatchSetCommand_instances, _SpoListItemBatchSetCommand_initTelemetry, _SpoListItemBatchSetCommand_initOptions, _SpoListItemBatchSetCommand_initValidators, _SpoListItemBatchSetCommand_initOptionSets;
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ const fs = require("fs");
26
+ const config_1 = require("../../../../config");
27
+ const request_1 = require("../../../../request");
28
+ const formatting_1 = require("../../../../utils/formatting");
29
+ const odata_1 = require("../../../../utils/odata");
30
+ const spo_1 = require("../../../../utils/spo");
31
+ const urlUtil_1 = require("../../../../utils/urlUtil");
32
+ const validation_1 = require("../../../../utils/validation");
33
+ const SpoCommand_1 = require("../../../base/SpoCommand");
34
+ const commands_1 = require("../../commands");
35
+ class SpoListItemBatchSetCommand extends SpoCommand_1.default {
36
+ get name() {
37
+ return commands_1.default.LISTITEM_BATCH_SET;
38
+ }
39
+ get description() {
40
+ return 'Updates list items in a batch';
41
+ }
42
+ constructor() {
43
+ super();
44
+ _SpoListItemBatchSetCommand_instances.add(this);
45
+ __classPrivateFieldGet(this, _SpoListItemBatchSetCommand_instances, "m", _SpoListItemBatchSetCommand_initTelemetry).call(this);
46
+ __classPrivateFieldGet(this, _SpoListItemBatchSetCommand_instances, "m", _SpoListItemBatchSetCommand_initOptions).call(this);
47
+ __classPrivateFieldGet(this, _SpoListItemBatchSetCommand_instances, "m", _SpoListItemBatchSetCommand_initValidators).call(this);
48
+ __classPrivateFieldGet(this, _SpoListItemBatchSetCommand_instances, "m", _SpoListItemBatchSetCommand_initOptionSets).call(this);
49
+ }
50
+ commandAction(logger, args) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ try {
53
+ if (this.verbose) {
54
+ logger.logToStderr(`Starting to create batch items from csv at path ${args.options.filePath}`);
55
+ }
56
+ const csvContent = fs.readFileSync(args.options.filePath, 'utf8');
57
+ const jsonContent = formatting_1.formatting.parseCsvToJson(csvContent);
58
+ const amountOfRows = jsonContent.length;
59
+ const idColumn = args.options.idColumn || 'ID';
60
+ if (!jsonContent[0].hasOwnProperty(idColumn)) {
61
+ throw `The specified value for idColumn does not exist in the array. Specified idColumn is '${args.options.idColumn || 'ID'}'. Please specify the correct value.`;
62
+ }
63
+ const listId = yield this.getListId(args.options, logger);
64
+ const fields = yield this.getListFields(args.options, listId, jsonContent, idColumn, logger);
65
+ const userFields = fields.filter(field => field.TypeAsString === 'UserMulti' || field.TypeAsString === 'User');
66
+ const resolvedUsers = yield this.getUsersFromCsv(args.options.webUrl, jsonContent, userFields);
67
+ const formDigestValue = (yield spo_1.spo.getRequestDigest(args.options.webUrl)).FormDigestValue;
68
+ const objectIdentity = (yield spo_1.spo.getCurrentWebIdentity(args.options.webUrl, formDigestValue)).objectIdentity;
69
+ let counter = 0;
70
+ while (jsonContent.length > 0) {
71
+ const entriesToProcess = jsonContent.splice(0, 50);
72
+ const objectPaths = [], actions = [];
73
+ let index = 1;
74
+ for (const row of entriesToProcess) {
75
+ counter += 1;
76
+ objectPaths.push(`<Identity Id="${index}" Name="${objectIdentity}:list:${listId}:item:${row[idColumn]},1" />`);
77
+ const [actionString, updatedIndex] = this.mapActions(index, row, fields, resolvedUsers, args.options.systemUpdate);
78
+ index = updatedIndex;
79
+ actions.push(actionString);
80
+ }
81
+ if (this.verbose) {
82
+ logger.logToStderr(`Writing away batch of items, currently at: ${counter}/${amountOfRows}.`);
83
+ }
84
+ yield this.sendBatchRequest(args.options.webUrl, this.getRequestBody(objectPaths, actions));
85
+ }
86
+ }
87
+ catch (err) {
88
+ this.handleRejectedODataJsonPromise(err);
89
+ }
90
+ });
91
+ }
92
+ getRequestBody(objectPaths, actions) {
93
+ return `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions>${actions.join('')}</Actions><ObjectPaths>${objectPaths.join('')}</ObjectPaths></Request>`;
94
+ }
95
+ sendBatchRequest(webUrl, requestBody) {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ const requestOptions = {
98
+ url: `${webUrl}/_vti_bin/client.svc/ProcessQuery`,
99
+ headers: {
100
+ 'Content-Type': 'text/xml'
101
+ },
102
+ data: requestBody
103
+ };
104
+ const res = yield request_1.default.post(requestOptions);
105
+ const json = JSON.parse(res);
106
+ const response = json[0];
107
+ if (response.ErrorInfo) {
108
+ throw response.ErrorInfo.ErrorMessage + ' - ' + response.ErrorInfo.ErrorValue;
109
+ }
110
+ });
111
+ }
112
+ mapActions(index, row, fields, users, systemUpdate) {
113
+ const objectPathId = index;
114
+ let actionString = '';
115
+ fields.forEach((field) => {
116
+ if (row[field.InternalName] === undefined || row[field.InternalName] === '') {
117
+ actionString += `<Method Name="ParseAndSetFieldValue" Id="${index += 1}" ObjectPathId="${objectPathId}"><Parameters><Parameter Type="String">${field.InternalName}</Parameter><Parameter Type="String"></Parameter></Parameters></Method>`;
118
+ }
119
+ else {
120
+ switch (field.TypeAsString) {
121
+ case 'User':
122
+ const userDetail = users.find(us => us.email === row[field.InternalName]);
123
+ actionString += `<Method Name="ParseAndSetFieldValue" Id="${index += 1}" ObjectPathId="${objectPathId}"><Parameters><Parameter Type="String">${field.InternalName}</Parameter><Parameter Type="String">${userDetail.id}</Parameter></Parameters></Method>`;
124
+ break;
125
+ case 'UserMulti':
126
+ const userMultiString = row[field.InternalName].toString().split(';').map((element) => {
127
+ const userDetail = users.find(us => us.email === element);
128
+ return `<Object TypeId="{c956ab54-16bd-4c18-89d2-996f57282a6f}"><Property Name="Email" Type="Null" /><Property Name="LookupId" Type="Int32">${userDetail.id}</Property><Property Name="LookupValue" Type="Null" /></Object>`;
129
+ });
130
+ actionString += `<Method Name="SetFieldValue" Id="${index += 1}" ObjectPathId="${objectPathId}"><Parameters><Parameter Type="String">${field.InternalName}</Parameter><Parameter Type="Array">${userMultiString.join('')}</Parameter></Parameters></Method>`;
131
+ break;
132
+ case 'Lookup':
133
+ actionString += `<Method Name="SetFieldValue" Id="${index += 1}" ObjectPathId="${objectPathId}"><Parameters><Parameter Type="String">${field.InternalName}</Parameter><Parameter TypeId="{f1d34cc0-9b50-4a78-be78-d5facfcccfb7}"><Property Name="LookupId" Type="Int32">${row[field.InternalName]}</Property><Property Name="LookupValue" Type="Null"/></Parameter></Parameters></Method>`;
134
+ break;
135
+ case 'LookupMulti':
136
+ const lookupMultiString = row[field.InternalName].toString().split(';').map((element) => {
137
+ return `<Object TypeId="{f1d34cc0-9b50-4a78-be78-d5facfcccfb7}"><Property Name="LookupId" Type="Int32">${element}</Property><Property Name="LookupValue" Type="Null" /></Object>`;
138
+ });
139
+ actionString += `<Method Name="SetFieldValue" Id="${index += 1}" ObjectPathId="${objectPathId}"><Parameters><Parameter Type="String">${field.InternalName}</Parameter><Parameter Type="Array">${lookupMultiString.join('')}</Parameter></Parameters></Method>`;
140
+ break;
141
+ default:
142
+ actionString += `<Method Name="ParseAndSetFieldValue" Id="${index += 1}" ObjectPathId="${objectPathId}"><Parameters><Parameter Type="String">${field.InternalName}</Parameter><Parameter Type="String">${row[field.InternalName].toString()}</Parameter></Parameters></Method>`;
143
+ break;
144
+ }
145
+ }
146
+ });
147
+ actionString += `<Method Name="${systemUpdate ? 'System' : ''}Update" Id="${index += 1}" ObjectPathId="${objectPathId}"/>`;
148
+ return [actionString, index];
149
+ }
150
+ getListFields(options, listId, jsonContent, idColumn, logger) {
151
+ return __awaiter(this, void 0, void 0, function* () {
152
+ if (this.verbose) {
153
+ logger.logToStderr(`Retrieving fields for list with id ${listId}`);
154
+ }
155
+ const filterFields = [];
156
+ const objectKeys = Object.keys(jsonContent[0]);
157
+ const index = objectKeys.indexOf(idColumn, 0);
158
+ if (index > -1) {
159
+ objectKeys.splice(index, 1);
160
+ }
161
+ objectKeys.map(objectKey => {
162
+ filterFields.push(`InternalName eq '${objectKey}'`);
163
+ });
164
+ const fields = yield odata_1.odata.getAllItems(`${options.webUrl}/_api/web/lists(guid'${formatting_1.formatting.encodeQueryParameter(listId)}')/fields?$select=InternalName,TypeAsString&$filter=${filterFields.join(' or ')}`);
165
+ if (fields.length !== objectKeys.length) {
166
+ const fieldsThatDontExist = [];
167
+ objectKeys.forEach(key => {
168
+ const field = fields.find(field => field.InternalName === key);
169
+ if (!field) {
170
+ fieldsThatDontExist.push(key);
171
+ }
172
+ });
173
+ throw `Following fields specified in the csv do not exist on the list: ${fieldsThatDontExist.join(', ')}`;
174
+ }
175
+ return fields;
176
+ });
177
+ }
178
+ getListId(options, logger) {
179
+ return __awaiter(this, void 0, void 0, function* () {
180
+ if (options.listId) {
181
+ return options.listId;
182
+ }
183
+ if (this.verbose) {
184
+ logger.logToStderr('Retrieving list id');
185
+ }
186
+ let listUrl = `${options.webUrl}/_api/web`;
187
+ if (options.listTitle) {
188
+ listUrl += `/lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(options.listTitle)}')`;
189
+ }
190
+ else {
191
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(options.webUrl, options.listUrl);
192
+ listUrl += `/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
193
+ }
194
+ const requestOptions = {
195
+ url: `${listUrl}?$select=Id`,
196
+ headers: {
197
+ 'accept': 'application/json;odata=nometadata'
198
+ },
199
+ responseType: 'json'
200
+ };
201
+ const listResult = yield request_1.default.get(requestOptions);
202
+ return listResult.Id;
203
+ });
204
+ }
205
+ getUsersFromCsv(webUrl, jsonContent, userFields) {
206
+ var _a, e_1, _b, _c;
207
+ return __awaiter(this, void 0, void 0, function* () {
208
+ if (userFields.length === 0) {
209
+ return [];
210
+ }
211
+ const userFieldValues = [];
212
+ const emailsToResolve = this.getEmailsToEnsure(jsonContent, userFields);
213
+ try {
214
+ for (var _d = true, emailsToResolve_1 = __asyncValues(emailsToResolve), emailsToResolve_1_1; emailsToResolve_1_1 = yield emailsToResolve_1.next(), _a = emailsToResolve_1_1.done, !_a;) {
215
+ _c = emailsToResolve_1_1.value;
216
+ _d = false;
217
+ try {
218
+ const email = _c;
219
+ const requestOptions = {
220
+ url: `${webUrl}/_api/web/ensureUser('${email}')?$select=Id`,
221
+ headers: {
222
+ accept: 'application/json',
223
+ 'content-type': 'application/json'
224
+ },
225
+ responseType: 'json'
226
+ };
227
+ const response = yield request_1.default.post(requestOptions);
228
+ userFieldValues.push({ email: email, id: response.Id });
229
+ }
230
+ finally {
231
+ _d = true;
232
+ }
233
+ }
234
+ }
235
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
236
+ finally {
237
+ try {
238
+ if (!_d && !_a && (_b = emailsToResolve_1.return)) yield _b.call(emailsToResolve_1);
239
+ }
240
+ finally { if (e_1) throw e_1.error; }
241
+ }
242
+ return userFieldValues;
243
+ });
244
+ }
245
+ getEmailsToEnsure(jsonContent, userFields) {
246
+ const emailsToResolve = [];
247
+ userFields.forEach((userField) => {
248
+ jsonContent.forEach(row => {
249
+ const fieldValue = row[userField.InternalName];
250
+ if (fieldValue !== undefined && fieldValue !== '') {
251
+ const emailsSplitted = fieldValue.split(';');
252
+ emailsSplitted.forEach((email) => {
253
+ if (!emailsToResolve.some(existingMail => existingMail === email)) {
254
+ emailsToResolve.push(email);
255
+ }
256
+ });
257
+ }
258
+ });
259
+ });
260
+ return emailsToResolve;
261
+ }
262
+ }
263
+ _SpoListItemBatchSetCommand_instances = new WeakSet(), _SpoListItemBatchSetCommand_initTelemetry = function _SpoListItemBatchSetCommand_initTelemetry() {
264
+ this.telemetry.push((args) => {
265
+ Object.assign(this.telemetryProperties, {
266
+ idColumn: typeof args.options.idColumn !== 'undefined',
267
+ listId: typeof args.options.listId !== 'undefined',
268
+ listTitle: typeof args.options.listTitle !== 'undefined',
269
+ listUrl: typeof args.options.listUrl !== 'undefined',
270
+ systemUpdate: !!args.options.systemUpdate
271
+ });
272
+ });
273
+ }, _SpoListItemBatchSetCommand_initOptions = function _SpoListItemBatchSetCommand_initOptions() {
274
+ this.options.unshift({
275
+ option: '-p, --filePath <filePath>'
276
+ }, {
277
+ option: '-u, --webUrl <webUrl>'
278
+ }, {
279
+ option: '-l, --listId [listId]'
280
+ }, {
281
+ option: '-t, --listTitle [listTitle]'
282
+ }, {
283
+ option: '--listUrl [listUrl]'
284
+ }, {
285
+ option: '--idColumn [idColumn]'
286
+ }, {
287
+ option: '-s, --systemUpdate'
288
+ });
289
+ }, _SpoListItemBatchSetCommand_initValidators = function _SpoListItemBatchSetCommand_initValidators() {
290
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
291
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
292
+ if (isValidSharePointUrl !== true) {
293
+ return isValidSharePointUrl;
294
+ }
295
+ if (args.options.listId &&
296
+ !validation_1.validation.isValidGuid(args.options.listId)) {
297
+ return `${args.options.listId} in option listId is not a valid GUID`;
298
+ }
299
+ if (!fs.existsSync(args.options.filePath)) {
300
+ return `File with path ${args.options.filePath} does not exist`;
301
+ }
302
+ return true;
303
+ }));
304
+ }, _SpoListItemBatchSetCommand_initOptionSets = function _SpoListItemBatchSetCommand_initOptionSets() {
305
+ this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] });
306
+ };
307
+ module.exports = new SpoListItemBatchSetCommand();
308
+ //# sourceMappingURL=listitem-batch-set.js.map
@@ -15,7 +15,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _SpoPageSectionAddCommand_instances, _SpoPageSectionAddCommand_initTelemetry, _SpoPageSectionAddCommand_initOptions, _SpoPageSectionAddCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- const util_1 = require("util");
19
18
  const request_1 = require("../../../../request");
20
19
  const formatting_1 = require("../../../../utils/formatting");
21
20
  const validation_1 = require("../../../../utils/validation");
@@ -64,7 +63,7 @@ class SpoPageSectionAddCommand extends SpoCommand_1.default {
64
63
  },
65
64
  responseType: 'json'
66
65
  };
67
- return request_1.default.post(requestOptions);
66
+ yield request_1.default.post(requestOptions);
68
67
  }
69
68
  // get columns
70
69
  const columns = canvasContent
@@ -187,7 +186,7 @@ _SpoPageSectionAddCommand_instances = new WeakSet(), _SpoPageSectionAddCommand_i
187
186
  return `${args.options.sectionTemplate} is not a valid section template. Allowed values are OneColumn|OneColumnFullWidth|TwoColumn|ThreeColumn|TwoColumnLeft|TwoColumnRight`;
188
187
  }
189
188
  if (typeof args.options.order !== 'undefined') {
190
- if (!(0, util_1.isNumber)(args.options.order) || args.options.order < 1) {
189
+ if (!Number.isInteger(args.options.order) || args.options.order < 1) {
191
190
  return 'The value of parameter order must be 1 or higher';
192
191
  }
193
192
  }
@@ -46,8 +46,21 @@ class SpoServicePrincipalPermissionRequestListCommand extends SpoCommand_1.defau
46
46
  throw response.ErrorInfo.ErrorMessage;
47
47
  }
48
48
  else {
49
+ let spoWebAppServicePrincipalPermissionRequestResult = [];
49
50
  const result = json[json.length - 1]._Child_Items_;
50
- logger.log(result.map(r => {
51
+ if (result.length > 0) {
52
+ const spoClientExtensibilityWebApplicationPrincipalId = yield this.getSPOClientExtensibilityWebApplicationPrincipalId();
53
+ if (spoClientExtensibilityWebApplicationPrincipalId !== null) {
54
+ const oAuth2PermissionGrants = yield this.getOAuth2PermissionGrants(spoClientExtensibilityWebApplicationPrincipalId);
55
+ if (oAuth2PermissionGrants) {
56
+ spoWebAppServicePrincipalPermissionRequestResult = result.filter(x => oAuth2PermissionGrants.indexOf(x.Scope) === -1);
57
+ }
58
+ }
59
+ }
60
+ if (spoWebAppServicePrincipalPermissionRequestResult.length === 0) {
61
+ spoWebAppServicePrincipalPermissionRequestResult = result;
62
+ }
63
+ logger.log(spoWebAppServicePrincipalPermissionRequestResult.map(r => {
51
64
  return {
52
65
  Id: r.Id.replace('/Guid(', '').replace(')/', ''),
53
66
  Resource: r.Resource,
@@ -62,6 +75,38 @@ class SpoServicePrincipalPermissionRequestListCommand extends SpoCommand_1.defau
62
75
  }
63
76
  });
64
77
  }
78
+ getOAuth2PermissionGrants(spoClientExtensibilityWebApplicationPrincipalId) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ const requestOptions = {
81
+ url: `https://graph.microsoft.com/v1.0/oAuth2Permissiongrants/?$filter=clientId eq '${spoClientExtensibilityWebApplicationPrincipalId}' and consentType eq 'AllPrincipals'`,
82
+ headers: {
83
+ accept: 'application/json;odata.metadata=none'
84
+ },
85
+ responseType: 'json'
86
+ };
87
+ const response = yield request_1.default.get(requestOptions);
88
+ if (response.value && response.value.length > 0) {
89
+ return response.value[0].scope.split(' ');
90
+ }
91
+ return null;
92
+ });
93
+ }
94
+ getSPOClientExtensibilityWebApplicationPrincipalId() {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ const requestOptions = {
97
+ url: `https://graph.microsoft.com/v1.0/servicePrincipals/?$filter=displayName eq 'SharePoint Online Client Extensibility Web Application Principal'`,
98
+ headers: {
99
+ accept: 'application/json;odata.metadata=none'
100
+ },
101
+ responseType: 'json'
102
+ };
103
+ const response = yield request_1.default.get(requestOptions);
104
+ if (response.value && response.value.length > 0) {
105
+ return response.value[0].id;
106
+ }
107
+ return null;
108
+ });
109
+ }
65
110
  }
66
111
  module.exports = new SpoServicePrincipalPermissionRequestListCommand();
67
112
  //# sourceMappingURL=serviceprincipal-permissionrequest-list.js.map
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _SpoSiteRecycleBinItemMoveCommand_instances, _SpoSiteRecycleBinItemMoveCommand_initTelemetry, _SpoSiteRecycleBinItemMoveCommand_initOptions, _SpoSiteRecycleBinItemMoveCommand_initOptionSets, _SpoSiteRecycleBinItemMoveCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const request_1 = require("../../../../request");
20
+ const validation_1 = require("../../../../utils/validation");
21
+ const SpoCommand_1 = require("../../../base/SpoCommand");
22
+ const commands_1 = require("../../commands");
23
+ class SpoSiteRecycleBinItemMoveCommand extends SpoCommand_1.default {
24
+ get name() {
25
+ return commands_1.default.SITE_RECYCLEBINITEM_MOVE;
26
+ }
27
+ get description() {
28
+ return 'Moves items from the first-stage recycle bin to the second-stage recycle bin';
29
+ }
30
+ constructor() {
31
+ super();
32
+ _SpoSiteRecycleBinItemMoveCommand_instances.add(this);
33
+ __classPrivateFieldGet(this, _SpoSiteRecycleBinItemMoveCommand_instances, "m", _SpoSiteRecycleBinItemMoveCommand_initTelemetry).call(this);
34
+ __classPrivateFieldGet(this, _SpoSiteRecycleBinItemMoveCommand_instances, "m", _SpoSiteRecycleBinItemMoveCommand_initOptions).call(this);
35
+ __classPrivateFieldGet(this, _SpoSiteRecycleBinItemMoveCommand_instances, "m", _SpoSiteRecycleBinItemMoveCommand_initOptionSets).call(this);
36
+ __classPrivateFieldGet(this, _SpoSiteRecycleBinItemMoveCommand_instances, "m", _SpoSiteRecycleBinItemMoveCommand_initValidators).call(this);
37
+ }
38
+ commandAction(logger, args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (args.options.confirm) {
41
+ yield this.moveRecycleBinItem(args, logger);
42
+ }
43
+ else {
44
+ const result = yield Cli_1.Cli.prompt({
45
+ type: 'confirm',
46
+ name: 'continue',
47
+ default: false,
48
+ message: 'Are you sure you want to move these items to the second-stage recycle bin?'
49
+ });
50
+ if (result.continue) {
51
+ yield this.moveRecycleBinItem(args, logger);
52
+ }
53
+ }
54
+ });
55
+ }
56
+ moveRecycleBinItem(args, logger) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ try {
59
+ const requestOptions = {
60
+ url: `${args.options.siteUrl}/_api/web/recycleBin/MoveAllToSecondStage`,
61
+ headers: {
62
+ 'accept': 'application/json;odata=nometadata'
63
+ },
64
+ responseType: 'json'
65
+ };
66
+ if (args.options.ids !== undefined) {
67
+ const ids = args.options.ids.split(',');
68
+ if (this.verbose) {
69
+ logger.logToStderr(`Moving ${ids.length} items to the second-stage recycle bin.`);
70
+ }
71
+ requestOptions.data = {
72
+ ids: ids
73
+ };
74
+ }
75
+ else if (this.verbose) {
76
+ logger.logToStderr('Moving all items to the second-stage recycle bin.');
77
+ }
78
+ yield request_1.default.post(requestOptions);
79
+ }
80
+ catch (err) {
81
+ this.handleRejectedODataJsonPromise(err);
82
+ }
83
+ });
84
+ }
85
+ }
86
+ _SpoSiteRecycleBinItemMoveCommand_instances = new WeakSet(), _SpoSiteRecycleBinItemMoveCommand_initTelemetry = function _SpoSiteRecycleBinItemMoveCommand_initTelemetry() {
87
+ this.telemetry.push((args) => {
88
+ Object.assign(this.telemetryProperties, {
89
+ ids: typeof args.options.ids !== 'undefined',
90
+ all: !!args.options.all,
91
+ confirm: !!args.options.confirm
92
+ });
93
+ });
94
+ }, _SpoSiteRecycleBinItemMoveCommand_initOptions = function _SpoSiteRecycleBinItemMoveCommand_initOptions() {
95
+ this.options.unshift({
96
+ option: '-u, --siteUrl <siteUrl>'
97
+ }, {
98
+ option: '-i, --ids [ids]'
99
+ }, {
100
+ option: '--all'
101
+ }, {
102
+ option: '--confirm'
103
+ });
104
+ }, _SpoSiteRecycleBinItemMoveCommand_initOptionSets = function _SpoSiteRecycleBinItemMoveCommand_initOptionSets() {
105
+ this.optionSets.push({ options: ['ids', 'all'] });
106
+ }, _SpoSiteRecycleBinItemMoveCommand_initValidators = function _SpoSiteRecycleBinItemMoveCommand_initValidators() {
107
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
108
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.siteUrl);
109
+ if (isValidSharePointUrl !== true) {
110
+ return isValidSharePointUrl;
111
+ }
112
+ if (args.options.ids && !validation_1.validation.isValidGuidArray(args.options.ids.split(','))) {
113
+ return 'The option ids contains one or more invalid GUIDs';
114
+ }
115
+ return true;
116
+ }));
117
+ };
118
+ module.exports = new SpoSiteRecycleBinItemMoveCommand();
119
+ //# sourceMappingURL=site-recyclebinitem-move.js.map
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _SpoSiteRecycleBinItemRemoveCommand_instances, _SpoSiteRecycleBinItemRemoveCommand_initTelemetry, _SpoSiteRecycleBinItemRemoveCommand_initOptions, _SpoSiteRecycleBinItemRemoveCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const request_1 = require("../../../../request");
20
+ const validation_1 = require("../../../../utils/validation");
21
+ const SpoCommand_1 = require("../../../base/SpoCommand");
22
+ const commands_1 = require("../../commands");
23
+ class SpoSiteRecycleBinItemRemoveCommand extends SpoCommand_1.default {
24
+ get name() {
25
+ return commands_1.default.SITE_RECYCLEBINITEM_REMOVE;
26
+ }
27
+ get description() {
28
+ return 'Permanently deletes specific items from the site recycle bin';
29
+ }
30
+ constructor() {
31
+ super();
32
+ _SpoSiteRecycleBinItemRemoveCommand_instances.add(this);
33
+ __classPrivateFieldGet(this, _SpoSiteRecycleBinItemRemoveCommand_instances, "m", _SpoSiteRecycleBinItemRemoveCommand_initTelemetry).call(this);
34
+ __classPrivateFieldGet(this, _SpoSiteRecycleBinItemRemoveCommand_instances, "m", _SpoSiteRecycleBinItemRemoveCommand_initOptions).call(this);
35
+ __classPrivateFieldGet(this, _SpoSiteRecycleBinItemRemoveCommand_instances, "m", _SpoSiteRecycleBinItemRemoveCommand_initValidators).call(this);
36
+ }
37
+ commandAction(logger, args) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ if (args.options.confirm) {
40
+ yield this.removeRecycleBinItem(args, logger);
41
+ }
42
+ else {
43
+ const result = yield Cli_1.Cli.prompt({
44
+ type: 'confirm',
45
+ name: 'continue',
46
+ default: false,
47
+ message: `Are you sure you want to permanently delete ${args.options.ids.split(',').length} item(s) from the site recycle bin?`
48
+ });
49
+ if (result.continue) {
50
+ yield this.removeRecycleBinItem(args, logger);
51
+ }
52
+ }
53
+ });
54
+ }
55
+ removeRecycleBinItem(args, logger) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ if (this.verbose) {
58
+ logger.logToStderr(`Permanently deleting items from the site recycle bin at site ${args.options.siteUrl}...`);
59
+ }
60
+ try {
61
+ const requestOptions = {
62
+ url: `${args.options.siteUrl}/_api/site/RecycleBin/DeleteByIds`,
63
+ headers: {
64
+ accept: 'application/json;odata=nometadata'
65
+ },
66
+ responseType: 'json',
67
+ data: {
68
+ ids: args.options.ids.split(',')
69
+ }
70
+ };
71
+ yield request_1.default.post(requestOptions);
72
+ }
73
+ catch (err) {
74
+ this.handleRejectedODataJsonPromise(err);
75
+ }
76
+ });
77
+ }
78
+ }
79
+ _SpoSiteRecycleBinItemRemoveCommand_instances = new WeakSet(), _SpoSiteRecycleBinItemRemoveCommand_initTelemetry = function _SpoSiteRecycleBinItemRemoveCommand_initTelemetry() {
80
+ this.telemetry.push((args) => {
81
+ Object.assign(this.telemetryProperties, {
82
+ confirm: !!args.options.confirm
83
+ });
84
+ });
85
+ }, _SpoSiteRecycleBinItemRemoveCommand_initOptions = function _SpoSiteRecycleBinItemRemoveCommand_initOptions() {
86
+ this.options.unshift({
87
+ option: '-u, --siteUrl <siteUrl>'
88
+ }, {
89
+ option: '-i, --ids <ids>'
90
+ }, {
91
+ option: '--confirm'
92
+ });
93
+ }, _SpoSiteRecycleBinItemRemoveCommand_initValidators = function _SpoSiteRecycleBinItemRemoveCommand_initValidators() {
94
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
95
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.siteUrl);
96
+ if (isValidSharePointUrl !== true) {
97
+ return isValidSharePointUrl;
98
+ }
99
+ if (!validation_1.validation.isValidGuidArray(args.options.ids.split(','))) {
100
+ return 'The option ids contains one or more invalid GUIDs.';
101
+ }
102
+ return true;
103
+ }));
104
+ };
105
+ module.exports = new SpoSiteRecycleBinItemRemoveCommand();
106
+ //# sourceMappingURL=site-recyclebinitem-remove.js.map