@pnp/cli-microsoft365 6.9.0-beta.41bb38c → 6.9.0-beta.8393174

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 (219) hide show
  1. package/.devcontainer/Dockerfile +12 -19
  2. package/.devcontainer/devcontainer.json +24 -17
  3. package/Dockerfile +5 -2
  4. package/dist/Auth.js +2 -8
  5. package/dist/AuthServer.js +2 -4
  6. package/dist/cli/Cli.js +16 -0
  7. package/dist/m365/aad/commands/app/app-add.js +258 -249
  8. package/dist/m365/aad/commands/app/app-get.js +65 -62
  9. package/dist/m365/aad/commands/app/app-remove.js +22 -23
  10. package/dist/m365/aad/commands/app/app-role-add.js +35 -34
  11. package/dist/m365/aad/commands/app/app-role-list.js +22 -23
  12. package/dist/m365/aad/commands/app/app-role-remove.js +76 -73
  13. package/dist/m365/aad/commands/app/app-set.js +103 -103
  14. package/dist/m365/aad/commands/approleassignment/approleassignment-add.js +16 -14
  15. package/dist/m365/aad/commands/approleassignment/approleassignment-list.js +43 -52
  16. package/dist/m365/aad/commands/approleassignment/approleassignment-remove.js +20 -16
  17. package/dist/m365/aad/commands/o365group/o365group-add.js +40 -37
  18. package/dist/m365/aad/commands/o365group/o365group-conversation-post-list.js +7 -6
  19. package/dist/m365/aad/commands/o365group/o365group-list.js +6 -11
  20. package/dist/m365/aad/commands/o365group/o365group-recyclebinitem-clear.js +7 -8
  21. package/dist/m365/aad/commands/o365group/o365group-recyclebinitem-restore.js +23 -24
  22. package/dist/m365/aad/commands/o365group/o365group-set.js +15 -20
  23. package/dist/m365/aad/commands/o365group/o365group-teamify.js +15 -16
  24. package/dist/m365/aad/commands/o365group/o365group-user-list.js +17 -10
  25. package/dist/m365/aad/commands/o365group/o365group-user-set.js +17 -10
  26. package/dist/m365/aad/commands/policy/policy-list.js +12 -13
  27. package/dist/m365/aad/commands/siteclassification/siteclassification-enable.js +1 -3
  28. package/dist/m365/aad/commands/siteclassification/siteclassification-set.js +19 -20
  29. package/dist/m365/aad/commands/sp/sp-add.js +22 -23
  30. package/dist/m365/aad/commands/sp/sp-get.js +22 -23
  31. package/dist/m365/app/commands/app-open.js +4 -14
  32. package/dist/m365/cli/commands/cli-issue.js +4 -10
  33. package/dist/m365/cli/commands/cli-reconsent.js +2 -8
  34. package/dist/m365/cli/commands/config/config-set.js +1 -0
  35. package/dist/m365/commands/docs.js +2 -8
  36. package/dist/m365/commands/login.js +20 -0
  37. package/dist/m365/commands/setupPresets.js +2 -0
  38. package/dist/m365/file/commands/convert/convert-pdf.js +147 -143
  39. package/dist/m365/file/commands/file-add.js +87 -93
  40. package/dist/m365/file/commands/file-list.js +49 -55
  41. package/dist/m365/flow/commands/flow-list.js +35 -2
  42. package/dist/m365/flow/commands/flow-remove.js +2 -3
  43. package/dist/m365/flow/commands/run/run-resubmit.js +11 -10
  44. package/dist/m365/onedrive/commands/onedrive-list.js +21 -32
  45. package/dist/m365/outlook/commands/message/message-list.js +18 -23
  46. package/dist/m365/outlook/commands/message/message-move.js +15 -20
  47. package/dist/m365/pa/commands/app/app-export.js +3 -4
  48. package/dist/m365/pa/commands/app/app-get.js +11 -9
  49. package/dist/m365/pa/commands/app/app-remove.js +1 -1
  50. package/dist/m365/pa/commands/pcf/pcf-init.js +1 -2
  51. package/dist/m365/pa/commands/solution/solution-init.js +1 -2
  52. package/dist/m365/pa/commands/solution/solution-reference-add.js +1 -2
  53. package/dist/m365/planner/commands/bucket/bucket-add.js +15 -13
  54. package/dist/m365/planner/commands/bucket/bucket-get.js +27 -28
  55. package/dist/m365/planner/commands/bucket/bucket-list.js +15 -13
  56. package/dist/m365/planner/commands/bucket/bucket-remove.js +33 -34
  57. package/dist/m365/planner/commands/bucket/bucket-set.js +33 -34
  58. package/dist/m365/planner/commands/plan/plan-add.js +49 -52
  59. package/dist/m365/planner/commands/plan/plan-set.js +19 -20
  60. package/dist/m365/planner/commands/task/task-add.js +75 -78
  61. package/dist/m365/planner/commands/task/task-checklistitem-add.js +11 -10
  62. package/dist/m365/planner/commands/task/task-checklistitem-remove.js +10 -8
  63. package/dist/m365/planner/commands/task/task-get.js +53 -56
  64. package/dist/m365/planner/commands/task/task-list.js +23 -24
  65. package/dist/m365/planner/commands/task/task-reference-add.js +11 -10
  66. package/dist/m365/planner/commands/task/task-reference-remove.js +13 -14
  67. package/dist/m365/planner/commands/task/task-remove.js +44 -48
  68. package/dist/m365/planner/commands/task/task-set.js +83 -87
  69. package/dist/m365/pp/commands/card/card-get.js +6 -1
  70. package/dist/m365/purview/commands/retentionevent/retentionevent-add.js +0 -5
  71. package/dist/m365/purview/commands/retentionevent/retentionevent-get.js +0 -5
  72. package/dist/m365/purview/commands/retentionevent/retentionevent-list.js +0 -5
  73. package/dist/m365/purview/commands/retentionevent/retentionevent-remove.js +0 -5
  74. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-add.js +0 -5
  75. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-get.js +0 -5
  76. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-list.js +0 -5
  77. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-remove.js +0 -5
  78. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-set.js +0 -5
  79. package/dist/m365/purview/commands/retentionlabel/retentionlabel-add.js +0 -5
  80. package/dist/m365/purview/commands/retentionlabel/retentionlabel-get.js +0 -5
  81. package/dist/m365/purview/commands/retentionlabel/retentionlabel-list.js +0 -5
  82. package/dist/m365/purview/commands/retentionlabel/retentionlabel-remove.js +19 -22
  83. package/dist/m365/purview/commands/retentionlabel/retentionlabel-set.js +0 -5
  84. package/dist/m365/spfx/commands/project/JsonRule.js +1 -1
  85. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN021003_PKG_engines_node.js +1 -0
  86. package/dist/m365/spo/commands/app/app-teamspackage-download.js +17 -24
  87. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-set.js +154 -0
  88. package/dist/m365/spo/commands/commandset/commandset-set.js +11 -2
  89. package/dist/m365/spo/commands/contenttype/contenttype-set.js +49 -2
  90. package/dist/m365/spo/commands/file/file-checkout-undo.js +119 -0
  91. package/dist/m365/spo/commands/homesite/homesite-remove.js +1 -1
  92. package/dist/m365/spo/commands/list/list-sensitivitylabel-ensure.js +127 -0
  93. package/dist/m365/spo/commands/navigation/navigation-node-add.js +31 -1
  94. package/dist/m365/spo/commands/navigation/navigation-node-set.js +31 -2
  95. package/dist/m365/{teams/Message.js → spo/commands/tenant/Solution.js} +1 -1
  96. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-set.js +156 -0
  97. package/dist/m365/spo/commands/tenant/tenant-commandset-add.js +215 -0
  98. package/dist/m365/spo/commands/tenant/tenant-commandset-get.js +114 -0
  99. package/dist/m365/spo/commands/tenant/tenant-commandset-list.js +50 -0
  100. package/dist/m365/spo/commands/tenant/tenant-commandset-set.js +1 -1
  101. package/dist/m365/spo/commands/term/term-group-add.js +14 -10
  102. package/dist/m365/spo/commands.js +7 -0
  103. package/dist/m365/teams/commands/team/team-add.js +53 -50
  104. package/dist/m365/util/commands/accesstoken/accesstoken-get.js +10 -7
  105. package/dist/settingsNames.js +1 -0
  106. package/dist/utils/browserUtil.js +23 -0
  107. package/dist/utils/md.js +1 -3
  108. package/dist/utils/spo.js +60 -0
  109. package/docs/docs/cmd/aad/app/app-add.mdx +113 -0
  110. package/docs/docs/cmd/aad/app/app-get.mdx +217 -0
  111. package/docs/docs/cmd/aad/app/app-list.mdx +21 -0
  112. package/docs/docs/cmd/aad/app/app-role-add.mdx +4 -0
  113. package/docs/docs/cmd/aad/app/app-role-list.mdx +63 -0
  114. package/docs/docs/cmd/aad/app/app-role-remove.mdx +4 -0
  115. package/docs/docs/cmd/aad/app/app-set.mdx +4 -0
  116. package/docs/docs/cmd/aad/approleassignment/approleassignment-add.mdx +61 -0
  117. package/docs/docs/cmd/aad/approleassignment/approleassignment-list.mdx +59 -0
  118. package/docs/docs/cmd/aad/approleassignment/approleassignment-remove.mdx +4 -0
  119. package/docs/docs/cmd/aad/group/group-get.mdx +24 -0
  120. package/docs/docs/cmd/aad/group/group-list.mdx +98 -0
  121. package/docs/docs/cmd/aad/groupsetting/groupsetting-add.mdx +114 -0
  122. package/docs/docs/cmd/aad/groupsetting/groupsetting-get.mdx +115 -0
  123. package/docs/docs/cmd/aad/groupsetting/groupsetting-list.mdx +115 -0
  124. package/docs/docs/cmd/aad/groupsetting/groupsetting-remove.mdx +4 -0
  125. package/docs/docs/cmd/aad/groupsetting/groupsetting-set.mdx +4 -0
  126. package/docs/docs/cmd/aad/groupsettingtemplate/groupsettingtemplate-get.mdx +63 -0
  127. package/docs/docs/cmd/aad/groupsettingtemplate/groupsettingtemplate-list.mdx +63 -0
  128. package/docs/docs/cmd/aad/o365group/o365group-add.mdx +122 -0
  129. package/docs/docs/cmd/aad/o365group/o365group-conversation-list.mdx +68 -0
  130. package/docs/docs/cmd/aad/o365group/o365group-conversation-post-list.mdx +77 -0
  131. package/docs/docs/cmd/aad/o365group/o365group-get.mdx +122 -0
  132. package/docs/docs/cmd/aad/o365group/o365group-list.mdx +99 -0
  133. package/docs/docs/cmd/aad/o365group/o365group-recyclebinitem-clear.mdx +4 -0
  134. package/docs/docs/cmd/aad/o365group/o365group-recyclebinitem-list.mdx +96 -0
  135. package/docs/docs/cmd/aad/o365group/o365group-recyclebinitem-remove.mdx +4 -0
  136. package/docs/docs/cmd/aad/o365group/o365group-recyclebinitem-restore.mdx +4 -0
  137. package/docs/docs/cmd/aad/o365group/o365group-remove.mdx +4 -0
  138. package/docs/docs/cmd/aad/o365group/o365group-renew.mdx +4 -0
  139. package/docs/docs/cmd/aad/o365group/o365group-report-activitycounts.mdx +48 -0
  140. package/docs/docs/cmd/aad/o365group/o365group-report-activitydetail.mdx +60 -0
  141. package/docs/docs/cmd/aad/o365group/o365group-report-activityfilecounts.mdx +46 -0
  142. package/docs/docs/cmd/aad/o365group/o365group-report-activitygroupcounts.mdx +46 -0
  143. package/docs/docs/cmd/aad/o365group/o365group-report-activitystorage.mdx +46 -0
  144. package/docs/docs/cmd/aad/o365group/o365group-set.mdx +4 -0
  145. package/docs/docs/cmd/aad/o365group/o365group-teamify.mdx +4 -0
  146. package/docs/docs/cmd/aad/o365group/o365group-user-add.mdx +4 -0
  147. package/docs/docs/cmd/aad/o365group/o365group-user-list.mdx +56 -0
  148. package/docs/docs/cmd/aad/o365group/o365group-user-remove.mdx +4 -0
  149. package/docs/docs/cmd/aad/o365group/o365group-user-set.mdx +8 -4
  150. package/docs/docs/cmd/aad/oauth2grant/oauth2grant-add.mdx +4 -0
  151. package/docs/docs/cmd/aad/oauth2grant/oauth2grant-list.mdx +59 -0
  152. package/docs/docs/cmd/aad/oauth2grant/oauth2grant-remove.mdx +4 -0
  153. package/docs/docs/cmd/aad/oauth2grant/oauth2grant-set.mdx +4 -0
  154. package/docs/docs/cmd/aad/policy/policy-list.mdx +77 -0
  155. package/docs/docs/cmd/aad/siteclassification/siteclassification-disable.mdx +4 -0
  156. package/docs/docs/cmd/aad/siteclassification/siteclassification-enable.mdx +4 -0
  157. package/docs/docs/cmd/aad/siteclassification/siteclassification-get.mdx +57 -0
  158. package/docs/docs/cmd/aad/siteclassification/siteclassification-set.mdx +4 -0
  159. package/docs/docs/cmd/aad/sp/sp-add.mdx +136 -0
  160. package/docs/docs/cmd/aad/sp/sp-get.mdx +166 -0
  161. package/docs/docs/cmd/aad/user/user-get.mdx +75 -0
  162. package/docs/docs/cmd/aad/user/user-guest-add.mdx +23 -0
  163. package/docs/docs/cmd/aad/user/user-hibp.mdx +82 -0
  164. package/docs/docs/cmd/aad/user/user-license-add.mdx +2 -2
  165. package/docs/docs/cmd/aad/user/user-license-remove.mdx +2 -2
  166. package/docs/docs/cmd/aad/user/user-list.mdx +52 -0
  167. package/docs/docs/cmd/aad/user/user-password-validate.mdx +67 -0
  168. package/docs/docs/cmd/aad/user/user-signin-list.mdx +131 -0
  169. package/docs/docs/cmd/flow/flow-list.mdx +11 -3
  170. package/docs/docs/cmd/login.mdx +39 -0
  171. package/docs/docs/cmd/purview/retentionevent/retentionevent-add.mdx +0 -6
  172. package/docs/docs/cmd/purview/retentionevent/retentionevent-get.mdx +0 -6
  173. package/docs/docs/cmd/purview/retentionevent/retentionevent-list.mdx +0 -7
  174. package/docs/docs/cmd/purview/retentionevent/retentionevent-remove.mdx +0 -6
  175. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-add.mdx +0 -6
  176. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-get.mdx +0 -6
  177. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-list.mdx +0 -6
  178. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-remove.mdx +0 -6
  179. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-set.mdx +0 -6
  180. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-add.mdx +0 -6
  181. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-get.mdx +0 -6
  182. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-list.mdx +0 -6
  183. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-remove.mdx +0 -6
  184. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-set.mdx +0 -6
  185. package/docs/docs/cmd/setup.mdx +2 -0
  186. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-set.mdx +72 -0
  187. package/docs/docs/cmd/spo/commandset/commandset-set.mdx +12 -3
  188. package/docs/docs/cmd/spo/file/file-checkout-undo.mdx +55 -0
  189. package/docs/docs/cmd/spo/list/list-sensitivitylabel-ensure.mdx +64 -0
  190. package/docs/docs/cmd/spo/navigation/navigation-node-add.mdx +7 -4
  191. package/docs/docs/cmd/spo/navigation/navigation-node-set.mdx +9 -0
  192. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-set.mdx +81 -0
  193. package/docs/docs/cmd/spo/tenant/tenant-commandset-add.mdx +183 -0
  194. package/docs/docs/cmd/spo/tenant/tenant-commandset-get.mdx +155 -0
  195. package/docs/docs/cmd/spo/tenant/tenant-commandset-list.mdx +114 -0
  196. package/docs/docs/cmd/spo/tenant/tenant-commandset-set.mdx +1 -1
  197. package/docs/docs/cmd/spo/term/term-group-add.mdx +63 -4
  198. package/docs/docs/cmd/status.mdx +6 -3
  199. package/docs/docs/cmd/util/accesstoken/accesstoken-get.mdx +12 -2
  200. package/npm-shrinkwrap.json +299 -272
  201. package/package.json +17 -17
  202. package/dist/m365/aad/commands/approleassignment/AppRoleAssignment.js +0 -3
  203. package/dist/m365/aad/commands/approleassignment/ServicePrincipal.js +0 -3
  204. package/dist/m365/aad/commands/groupsetting/GroupSetting.js +0 -3
  205. package/dist/m365/aad/commands/groupsettingtemplate/GroupSettingTemplate.js +0 -3
  206. package/dist/m365/aad/commands/siteclassification/DirectorySetting.js +0 -10
  207. package/dist/m365/aad/commands/siteclassification/DirectorySettingTemplatesRsp.js +0 -3
  208. package/dist/m365/aad/commands/siteclassification/DirectorySettingValue.js +0 -3
  209. package/dist/m365/outlook/Message.js +0 -3
  210. package/dist/m365/spo/commands/site/SitePermission.js +0 -3
  211. package/dist/m365/teams/Channel.js +0 -3
  212. package/dist/m365/teams/ConversationMember.js +0 -3
  213. package/dist/m365/teams/Reply.js +0 -3
  214. package/dist/m365/teams/Tab.js +0 -3
  215. package/dist/m365/teams/Team.js +0 -3
  216. package/dist/m365/teams/TeamsApp.js +0 -3
  217. package/dist/m365/teams/TeamsAppInstallation.js +0 -3
  218. package/dist/m365/teams/TeamsTabConfiguration.js +0 -3
  219. package/dist/m365/teams/commands/Meeting.js +0 -3
@@ -91,13 +91,12 @@ class SpoContentTypeSetCommand extends SpoCommand_1.default {
91
91
  if (this.verbose) {
92
92
  logger.logToStderr(`Updating content type...`);
93
93
  }
94
- const payload = this.getRequestPayload(options);
95
94
  const requestOptions = {
96
95
  url: `${options.webUrl}/_vti_bin/client.svc/ProcessQuery`,
97
96
  headers: {
98
97
  'Content-Type': 'text/xml'
99
98
  },
100
- data: `<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>${payload}</Actions><ObjectPaths><Identity Id="9" Name="fc4179a0-e0d7-5000-c38b-bc3506fbab6f|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:${siteId}:web:${webId}:contenttype:${formatting_1.formatting.escapeXml(contentTypeId)}" /></ObjectPaths></Request>`
99
+ data: yield this.getCsomCallXmlBody(options, siteId, webId, contentTypeId)
101
100
  };
102
101
  const res = yield request_1.default.post(requestOptions);
103
102
  const json = JSON.parse(res);
@@ -107,6 +106,13 @@ class SpoContentTypeSetCommand extends SpoCommand_1.default {
107
106
  }
108
107
  });
109
108
  }
109
+ getCsomCallXmlBody(options, siteId, webId, contentTypeId) {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ const payload = this.getRequestPayload(options);
112
+ const list = yield this.getListId(options);
113
+ 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>${payload}</Actions><ObjectPaths><Identity Id="9" Name="fc4179a0-e0d7-5000-c38b-bc3506fbab6f|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:${siteId}:web:${webId}${list}:contenttype:${formatting_1.formatting.escapeXml(contentTypeId)}" /></ObjectPaths></Request>`;
114
+ });
115
+ }
110
116
  getRequestPayload(options) {
111
117
  const excludeOptions = [
112
118
  'webUrl',
@@ -130,6 +136,9 @@ class SpoContentTypeSetCommand extends SpoCommand_1.default {
130
136
  if (options.updateChildren) {
131
137
  payload.push(`<Method Name="Update" Id="${i++}" ObjectPathId="9"><Parameters><Parameter Type="Boolean">true</Parameter></Parameters></Method>`);
132
138
  }
139
+ else {
140
+ payload.push(`<Method Name="Update" Id="${i++}" ObjectPathId="9"><Parameters><Parameter Type="Boolean">false</Parameter></Parameters></Method>`);
141
+ }
133
142
  return payload.join('');
134
143
  }
135
144
  getSiteId(logger, webUrl) {
@@ -164,6 +173,41 @@ class SpoContentTypeSetCommand extends SpoCommand_1.default {
164
173
  return web.Id;
165
174
  });
166
175
  }
176
+ getListId(options) {
177
+ return __awaiter(this, void 0, void 0, function* () {
178
+ if (!options.listId && !options.listTitle && !options.listUrl) {
179
+ return '';
180
+ }
181
+ let baseString = ':list:';
182
+ if (options.listId) {
183
+ return baseString += options.listId;
184
+ }
185
+ else if (options.listTitle) {
186
+ const requestOptions = {
187
+ url: `${options.webUrl}/_api/web/lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(options.listTitle)}')?$select=Id`,
188
+ headers: {
189
+ accept: 'application/json;odata=nometadata'
190
+ },
191
+ responseType: 'json'
192
+ };
193
+ const listResponse = yield request_1.default.get(requestOptions);
194
+ baseString += listResponse.Id;
195
+ }
196
+ else if (options.listUrl) {
197
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(options.webUrl, options.listUrl);
198
+ const requestOptions = {
199
+ url: `${options.webUrl}/_api/web/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')?$select=Id`,
200
+ headers: {
201
+ accept: 'application/json;odata=nometadata'
202
+ },
203
+ responseType: 'json'
204
+ };
205
+ const listResponse = yield request_1.default.get(requestOptions);
206
+ baseString += listResponse.Id;
207
+ }
208
+ return baseString;
209
+ });
210
+ }
167
211
  }
168
212
  _SpoContentTypeSetCommand_instances = new WeakSet(), _SpoContentTypeSetCommand_initTelemetry = function _SpoContentTypeSetCommand_initTelemetry() {
169
213
  this.telemetry.push((args) => {
@@ -204,6 +248,9 @@ _SpoContentTypeSetCommand_instances = new WeakSet(), _SpoContentTypeSetCommand_i
204
248
  if ((args.options.listId && (args.options.listTitle || args.options.listUrl)) || (args.options.listTitle && args.options.listUrl)) {
205
249
  return `Specify either listTitle, listId or listUrl.`;
206
250
  }
251
+ if ((args.options.listId || args.options.listTitle || args.options.listUrl) && args.options.updateChildren) {
252
+ return 'It is impossible to pass updateChildren when trying to update a list content type.';
253
+ }
207
254
  return true;
208
255
  }));
209
256
  }, _SpoContentTypeSetCommand_initTypes = function _SpoContentTypeSetCommand_initTypes() {
@@ -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 _SpoFileCheckoutUndoCommand_instances, _SpoFileCheckoutUndoCommand_initTelemetry, _SpoFileCheckoutUndoCommand_initOptions, _SpoFileCheckoutUndoCommand_initValidators, _SpoFileCheckoutUndoCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const request_1 = require("../../../../request");
20
+ const formatting_1 = require("../../../../utils/formatting");
21
+ const urlUtil_1 = require("../../../../utils/urlUtil");
22
+ const validation_1 = require("../../../../utils/validation");
23
+ const SpoCommand_1 = require("../../../base/SpoCommand");
24
+ const commands_1 = require("../../commands");
25
+ class SpoFileCheckoutUndoCommand extends SpoCommand_1.default {
26
+ get name() {
27
+ return commands_1.default.FILE_CHECKOUT_UNDO;
28
+ }
29
+ get description() {
30
+ return 'Discards a checked out file';
31
+ }
32
+ constructor() {
33
+ super();
34
+ _SpoFileCheckoutUndoCommand_instances.add(this);
35
+ __classPrivateFieldGet(this, _SpoFileCheckoutUndoCommand_instances, "m", _SpoFileCheckoutUndoCommand_initTelemetry).call(this);
36
+ __classPrivateFieldGet(this, _SpoFileCheckoutUndoCommand_instances, "m", _SpoFileCheckoutUndoCommand_initOptions).call(this);
37
+ __classPrivateFieldGet(this, _SpoFileCheckoutUndoCommand_instances, "m", _SpoFileCheckoutUndoCommand_initValidators).call(this);
38
+ __classPrivateFieldGet(this, _SpoFileCheckoutUndoCommand_instances, "m", _SpoFileCheckoutUndoCommand_initOptionSets).call(this);
39
+ }
40
+ commandAction(logger, args) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const undoCheckout = () => __awaiter(this, void 0, void 0, function* () {
43
+ try {
44
+ if (this.verbose) {
45
+ logger.logToStderr(`Undoing checkout for file ${args.options.fileId || args.options.fileUrl} on web ${args.options.webUrl}`);
46
+ }
47
+ let requestUrl = `${args.options.webUrl}/_api/web/`;
48
+ if (args.options.fileId) {
49
+ requestUrl += `getFileById('${args.options.fileId}')`;
50
+ }
51
+ else if (args.options.fileUrl) {
52
+ const serverRelativePath = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.fileUrl);
53
+ requestUrl += `getFileByServerRelativePath(DecodedUrl='${formatting_1.formatting.encodeQueryParameter(serverRelativePath)}')`;
54
+ }
55
+ requestUrl += '/undocheckout';
56
+ const requestOptions = {
57
+ url: requestUrl,
58
+ headers: {
59
+ 'accept': 'application/json;odata=nometadata'
60
+ },
61
+ responseType: 'json'
62
+ };
63
+ yield request_1.default.post(requestOptions);
64
+ }
65
+ catch (err) {
66
+ this.handleRejectedODataJsonPromise(err);
67
+ }
68
+ });
69
+ if (args.options.confirm) {
70
+ yield undoCheckout();
71
+ }
72
+ else {
73
+ const result = yield Cli_1.Cli.prompt({
74
+ type: 'confirm',
75
+ name: 'continue',
76
+ default: false,
77
+ message: `Are you sure you want to undo the checkout for file ${args.options.fileId || args.options.fileUrl} ?`
78
+ });
79
+ if (result.continue) {
80
+ yield undoCheckout();
81
+ }
82
+ }
83
+ });
84
+ }
85
+ }
86
+ _SpoFileCheckoutUndoCommand_instances = new WeakSet(), _SpoFileCheckoutUndoCommand_initTelemetry = function _SpoFileCheckoutUndoCommand_initTelemetry() {
87
+ this.telemetry.push((args) => {
88
+ Object.assign(this.telemetryProperties, {
89
+ fileId: typeof args.options.fileId !== 'undefined',
90
+ fileUrl: typeof args.options.fileUrl !== 'undefined',
91
+ confirm: !!args.options.confirm
92
+ });
93
+ });
94
+ }, _SpoFileCheckoutUndoCommand_initOptions = function _SpoFileCheckoutUndoCommand_initOptions() {
95
+ this.options.unshift({
96
+ option: '-u, --webUrl <webUrl>'
97
+ }, {
98
+ option: '-f, --fileUrl [fileUrl]'
99
+ }, {
100
+ option: '-i, --fileId [fileId]'
101
+ }, {
102
+ option: '--confirm'
103
+ });
104
+ }, _SpoFileCheckoutUndoCommand_initValidators = function _SpoFileCheckoutUndoCommand_initValidators() {
105
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
106
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
107
+ if (isValidSharePointUrl !== true) {
108
+ return isValidSharePointUrl;
109
+ }
110
+ if (args.options.fileId && !validation_1.validation.isValidGuid(args.options.fileId)) {
111
+ return `${args.options.fileId} is not a valid GUID`;
112
+ }
113
+ return true;
114
+ }));
115
+ }, _SpoFileCheckoutUndoCommand_initOptionSets = function _SpoFileCheckoutUndoCommand_initOptionSets() {
116
+ this.optionSets.push({ options: ['fileId', 'fileUrl'] });
117
+ };
118
+ module.exports = new SpoFileCheckoutUndoCommand();
119
+ //# sourceMappingURL=file-checkout-undo.js.map
@@ -58,7 +58,7 @@ class SpoHomeSiteRemoveCommand extends SpoCommand_1.default {
58
58
  }
59
59
  }
60
60
  catch (err) {
61
- this.handleRejectedPromise(err);
61
+ this.handleRejectedODataJsonPromise(err);
62
62
  }
63
63
  });
64
64
  if (args.options.confirm) {
@@ -0,0 +1,127 @@
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 _SpoListSensitivityLabelEnsureCommand_instances, _SpoListSensitivityLabelEnsureCommand_initTelemetry, _SpoListSensitivityLabelEnsureCommand_initOptions, _SpoListSensitivityLabelEnsureCommand_initValidators, _SpoListSensitivityLabelEnsureCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const formatting_1 = require("../../../../utils/formatting");
20
+ const urlUtil_1 = require("../../../../utils/urlUtil");
21
+ const validation_1 = require("../../../../utils/validation");
22
+ const SpoCommand_1 = require("../../../base/SpoCommand");
23
+ const commands_1 = require("../../commands");
24
+ class SpoListSensitivityLabelEnsureCommand extends SpoCommand_1.default {
25
+ get name() {
26
+ return commands_1.default.LIST_SENSITIVITYLABEL_ENSURE;
27
+ }
28
+ get description() {
29
+ return 'Applies a default sensitivity label to the specified document library';
30
+ }
31
+ constructor() {
32
+ super();
33
+ _SpoListSensitivityLabelEnsureCommand_instances.add(this);
34
+ __classPrivateFieldGet(this, _SpoListSensitivityLabelEnsureCommand_instances, "m", _SpoListSensitivityLabelEnsureCommand_initTelemetry).call(this);
35
+ __classPrivateFieldGet(this, _SpoListSensitivityLabelEnsureCommand_instances, "m", _SpoListSensitivityLabelEnsureCommand_initOptions).call(this);
36
+ __classPrivateFieldGet(this, _SpoListSensitivityLabelEnsureCommand_instances, "m", _SpoListSensitivityLabelEnsureCommand_initValidators).call(this);
37
+ __classPrivateFieldGet(this, _SpoListSensitivityLabelEnsureCommand_instances, "m", _SpoListSensitivityLabelEnsureCommand_initOptionSets).call(this);
38
+ }
39
+ commandAction(logger, args) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ try {
42
+ const sensitivityLabelId = yield this.getSensitivityLabelId(args, logger);
43
+ if (this.verbose) {
44
+ logger.logToStderr(`Applying a sensitivity label ${sensitivityLabelId} to the document library...`);
45
+ }
46
+ let requestUrl = `${args.options.webUrl}/_api/web`;
47
+ if (args.options.listId) {
48
+ requestUrl += `/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
49
+ }
50
+ else if (args.options.listTitle) {
51
+ requestUrl += `/lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
52
+ }
53
+ else if (args.options.listUrl) {
54
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
55
+ requestUrl += `/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
56
+ }
57
+ const requestOptions = {
58
+ url: requestUrl,
59
+ headers: {
60
+ accept: 'application/json;odata=nometadata',
61
+ 'content-type': 'application/json;odata=nometadata',
62
+ 'if-match': '*'
63
+ },
64
+ data: { 'DefaultSensitivityLabelForLibrary': sensitivityLabelId },
65
+ responseType: 'json'
66
+ };
67
+ yield request_1.default.patch(requestOptions);
68
+ }
69
+ catch (err) {
70
+ this.handleRejectedODataJsonPromise(err);
71
+ }
72
+ });
73
+ }
74
+ getSensitivityLabelId(args, logger) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ const { name } = args.options;
77
+ if (this.verbose) {
78
+ logger.logToStderr(`Retrieving sensitivity label id of ${name}...`);
79
+ }
80
+ const requestOptions = {
81
+ url: `https://graph.microsoft.com/beta/security/informationProtection/sensitivityLabels?$filter=name eq '${formatting_1.formatting.encodeQueryParameter(name)}'&$select=id`,
82
+ headers: {
83
+ accept: 'application/json;odata.metadata=none'
84
+ },
85
+ responseType: 'json'
86
+ };
87
+ const res = yield request_1.default.get(requestOptions);
88
+ const sensitivityLabelItem = res.value[0];
89
+ if (!sensitivityLabelItem) {
90
+ throw Error(`The specified sensitivity label does not exist`);
91
+ }
92
+ return sensitivityLabelItem.id;
93
+ });
94
+ }
95
+ }
96
+ _SpoListSensitivityLabelEnsureCommand_instances = new WeakSet(), _SpoListSensitivityLabelEnsureCommand_initTelemetry = function _SpoListSensitivityLabelEnsureCommand_initTelemetry() {
97
+ this.telemetry.push((args) => {
98
+ Object.assign(this.telemetryProperties, {
99
+ listId: typeof args.options.listId !== 'undefined',
100
+ listTitle: typeof args.options.listTitle !== 'undefined',
101
+ listUrl: typeof args.options.listUrl !== 'undefined'
102
+ });
103
+ });
104
+ }, _SpoListSensitivityLabelEnsureCommand_initOptions = function _SpoListSensitivityLabelEnsureCommand_initOptions() {
105
+ this.options.unshift({
106
+ option: '-u, --webUrl <webUrl>'
107
+ }, {
108
+ option: '-n, --name <name>'
109
+ }, {
110
+ option: '-t, --listTitle [listTitle]'
111
+ }, {
112
+ option: '-l, --listId [listId]'
113
+ }, {
114
+ option: '--listUrl [listUrl]'
115
+ });
116
+ }, _SpoListSensitivityLabelEnsureCommand_initValidators = function _SpoListSensitivityLabelEnsureCommand_initValidators() {
117
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
118
+ if (args.options.listId && !validation_1.validation.isValidGuid(args.options.listId)) {
119
+ return `${args.options.listId} is not a valid GUID`;
120
+ }
121
+ return validation_1.validation.isValidSharePointUrl(args.options.webUrl);
122
+ }));
123
+ }, _SpoListSensitivityLabelEnsureCommand_initOptionSets = function _SpoListSensitivityLabelEnsureCommand_initOptionSets() {
124
+ this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] });
125
+ };
126
+ module.exports = new SpoListSensitivityLabelEnsureCommand();
127
+ //# sourceMappingURL=list-sensitivitylabel-ensure.js.map
@@ -16,6 +16,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
16
16
  var _SpoNavigationNodeAddCommand_instances, _SpoNavigationNodeAddCommand_initTelemetry, _SpoNavigationNodeAddCommand_initOptions, _SpoNavigationNodeAddCommand_initValidators, _SpoNavigationNodeAddCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
+ const spo_1 = require("../../../../utils/spo");
19
20
  const validation_1 = require("../../../../utils/validation");
20
21
  const SpoCommand_1 = require("../../../base/SpoCommand");
21
22
  const commands_1 = require("../../commands");
@@ -62,6 +63,20 @@ class SpoNavigationNodeAddCommand extends SpoCommand_1.default {
62
63
  };
63
64
  try {
64
65
  const res = yield request_1.default.post(requestOptions);
66
+ if (args.options.openInNewWindow) {
67
+ if (this.verbose) {
68
+ logger.logToStderr(`Making sure that the newly added navigation node opens in a new window.`);
69
+ }
70
+ const id = res.Id.toString();
71
+ let menuState = args.options.location === 'TopNavigationBar' ? yield spo_1.spo.getTopNavigationMenuState(args.options.webUrl) : yield spo_1.spo.getQuickLaunchMenuState(args.options.webUrl);
72
+ let menuStateItem = this.getMenuStateNode(menuState.Nodes, id);
73
+ if (args.options.parentNodeId && !menuStateItem) {
74
+ menuState = yield spo_1.spo.getTopNavigationMenuState(args.options.webUrl);
75
+ menuStateItem = this.getMenuStateNode(menuState.Nodes, id);
76
+ }
77
+ menuStateItem.OpenInNewWindow = true;
78
+ yield spo_1.spo.saveMenuState(args.options.webUrl, menuState);
79
+ }
65
80
  logger.log(res);
66
81
  }
67
82
  catch (err) {
@@ -69,6 +84,18 @@ class SpoNavigationNodeAddCommand extends SpoCommand_1.default {
69
84
  }
70
85
  });
71
86
  }
87
+ getMenuStateNode(nodes, id) {
88
+ let menuNode = nodes.find((node) => node.Key !== null && node.Key === id);
89
+ if (menuNode === undefined) {
90
+ for (const node of nodes.filter(node => node.Nodes.length > 0)) {
91
+ menuNode = this.getMenuStateNode(node.Nodes, id);
92
+ if (menuNode) {
93
+ break;
94
+ }
95
+ }
96
+ }
97
+ return menuNode;
98
+ }
72
99
  }
73
100
  _SpoNavigationNodeAddCommand_instances = new WeakSet(), _SpoNavigationNodeAddCommand_initTelemetry = function _SpoNavigationNodeAddCommand_initTelemetry() {
74
101
  this.telemetry.push((args) => {
@@ -77,7 +104,8 @@ _SpoNavigationNodeAddCommand_instances = new WeakSet(), _SpoNavigationNodeAddCom
77
104
  location: typeof args.options.location !== 'undefined',
78
105
  parentNodeId: typeof args.options.parentNodeId !== 'undefined',
79
106
  audienceIds: typeof args.options.audienceIds !== 'undefined',
80
- url: typeof args.options.url !== 'undefined'
107
+ url: typeof args.options.url !== 'undefined',
108
+ openInNewWindow: !!args.options.openInNewWindow
81
109
  });
82
110
  });
83
111
  }, _SpoNavigationNodeAddCommand_initOptions = function _SpoNavigationNodeAddCommand_initOptions() {
@@ -96,6 +124,8 @@ _SpoNavigationNodeAddCommand_instances = new WeakSet(), _SpoNavigationNodeAddCom
96
124
  option: '--isExternal'
97
125
  }, {
98
126
  option: '--audienceIds [audienceIds]'
127
+ }, {
128
+ option: '--openInNewWindow'
99
129
  });
100
130
  }, _SpoNavigationNodeAddCommand_initValidators = function _SpoNavigationNodeAddCommand_initValidators() {
101
131
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -16,6 +16,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
16
16
  var _SpoNavigationNodeSetCommand_instances, _SpoNavigationNodeSetCommand_initTelemetry, _SpoNavigationNodeSetCommand_initTypes, _SpoNavigationNodeSetCommand_initOptions, _SpoNavigationNodeSetCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
+ const spo_1 = require("../../../../utils/spo");
19
20
  const validation_1 = require("../../../../utils/validation");
20
21
  const SpoCommand_1 = require("../../../base/SpoCommand");
21
22
  const commands_1 = require("../../commands");
@@ -65,12 +66,37 @@ class SpoNavigationNodeSetCommand extends SpoCommand_1.default {
65
66
  if (response['odata.null'] === true) {
66
67
  throw `Navigation node does not exist.`;
67
68
  }
69
+ if (args.options.openInNewWindow !== undefined) {
70
+ if (this.verbose) {
71
+ logger.logToStderr(`Making sure that the navigation node opens in a new window.`);
72
+ }
73
+ let menuState = yield spo_1.spo.getQuickLaunchMenuState(args.options.webUrl);
74
+ let menuStateItem = this.getMenuStateNode(menuState.Nodes, args.options.id);
75
+ if (!menuStateItem) {
76
+ menuState = yield spo_1.spo.getTopNavigationMenuState(args.options.webUrl);
77
+ menuStateItem = this.getMenuStateNode(menuState.Nodes, args.options.id);
78
+ }
79
+ menuStateItem.OpenInNewWindow = args.options.openInNewWindow;
80
+ yield spo_1.spo.saveMenuState(args.options.webUrl, menuState);
81
+ }
68
82
  }
69
83
  catch (err) {
70
84
  this.handleRejectedODataJsonPromise(err);
71
85
  }
72
86
  });
73
87
  }
88
+ getMenuStateNode(nodes, id) {
89
+ let menuNode = nodes.find((node) => node.Key.toString() === id.toString());
90
+ if (menuNode === undefined) {
91
+ for (const node of nodes.filter(node => node.Nodes.length > 0)) {
92
+ menuNode = this.getMenuStateNode(node.Nodes, id);
93
+ if (menuNode) {
94
+ break;
95
+ }
96
+ }
97
+ }
98
+ return menuNode;
99
+ }
74
100
  }
75
101
  _SpoNavigationNodeSetCommand_instances = new WeakSet(), _SpoNavigationNodeSetCommand_initTelemetry = function _SpoNavigationNodeSetCommand_initTelemetry() {
76
102
  this.telemetry.push((args) => {
@@ -78,7 +104,8 @@ _SpoNavigationNodeSetCommand_instances = new WeakSet(), _SpoNavigationNodeSetCom
78
104
  title: typeof args.options.title !== 'undefined',
79
105
  url: typeof args.options.url !== 'undefined',
80
106
  isExternal: typeof args.options.isExternal !== 'undefined',
81
- audienceIds: typeof args.options.audienceIds !== 'undefined'
107
+ audienceIds: typeof args.options.audienceIds !== 'undefined',
108
+ openInNewWindow: typeof args.options.openInNewWindow !== 'undefined'
82
109
  });
83
110
  });
84
111
  }, _SpoNavigationNodeSetCommand_initTypes = function _SpoNavigationNodeSetCommand_initTypes() {
@@ -96,6 +123,8 @@ _SpoNavigationNodeSetCommand_instances = new WeakSet(), _SpoNavigationNodeSetCom
96
123
  option: '--audienceIds [audienceIds]'
97
124
  }, {
98
125
  option: '--isExternal [isExternal]'
126
+ }, {
127
+ option: '--openInNewWindow [openInNewWindow]'
99
128
  });
100
129
  }, _SpoNavigationNodeSetCommand_initValidators = function _SpoNavigationNodeSetCommand_initValidators() {
101
130
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -103,7 +132,7 @@ _SpoNavigationNodeSetCommand_instances = new WeakSet(), _SpoNavigationNodeSetCom
103
132
  if (isValidSharePointUrl !== true) {
104
133
  return isValidSharePointUrl;
105
134
  }
106
- if (args.options.audienceIds === undefined && !args.options.url && args.options.isExternal === undefined && !args.options.title) {
135
+ if (args.options.audienceIds === undefined && !args.options.url && args.options.isExternal === undefined && !args.options.title && args.options.openInNewWindow === undefined) {
107
136
  return `Please specify atleast one property to update.`;
108
137
  }
109
138
  if (args.options.audienceIds) {
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=Message.js.map
3
+ //# sourceMappingURL=Solution.js.map
@@ -0,0 +1,156 @@
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 _SpoTenantApplicationCustomizerSetCommand_instances, _SpoTenantApplicationCustomizerSetCommand_initTelemetry, _SpoTenantApplicationCustomizerSetCommand_initOptions, _SpoTenantApplicationCustomizerSetCommand_initValidators, _SpoTenantApplicationCustomizerSetCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const formatting_1 = require("../../../../utils/formatting");
19
+ const odata_1 = require("../../../../utils/odata");
20
+ const spo_1 = require("../../../../utils/spo");
21
+ const urlUtil_1 = require("../../../../utils/urlUtil");
22
+ const validation_1 = require("../../../../utils/validation");
23
+ const SpoCommand_1 = require("../../../base/SpoCommand");
24
+ const commands_1 = require("../../commands");
25
+ const os = require("os");
26
+ const request_1 = require("../../../../request");
27
+ class SpoTenantApplicationCustomizerSetCommand extends SpoCommand_1.default {
28
+ get name() {
29
+ return commands_1.default.TENANT_APPLICATIONCUSTOMIZER_SET;
30
+ }
31
+ get description() {
32
+ return 'Updates an Application Customizer that is deployed as a tenant-wide extension';
33
+ }
34
+ constructor() {
35
+ super();
36
+ _SpoTenantApplicationCustomizerSetCommand_instances.add(this);
37
+ __classPrivateFieldGet(this, _SpoTenantApplicationCustomizerSetCommand_instances, "m", _SpoTenantApplicationCustomizerSetCommand_initTelemetry).call(this);
38
+ __classPrivateFieldGet(this, _SpoTenantApplicationCustomizerSetCommand_instances, "m", _SpoTenantApplicationCustomizerSetCommand_initOptions).call(this);
39
+ __classPrivateFieldGet(this, _SpoTenantApplicationCustomizerSetCommand_instances, "m", _SpoTenantApplicationCustomizerSetCommand_initValidators).call(this);
40
+ __classPrivateFieldGet(this, _SpoTenantApplicationCustomizerSetCommand_instances, "m", _SpoTenantApplicationCustomizerSetCommand_initOptionSets).call(this);
41
+ }
42
+ commandAction(logger, args) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ try {
45
+ const appCatalogUrl = yield spo_1.spo.getTenantAppCatalogUrl(logger, this.debug);
46
+ if (!appCatalogUrl) {
47
+ throw 'No app catalog URL found';
48
+ }
49
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(appCatalogUrl, '/lists/TenantWideExtensions');
50
+ const listItemId = yield this.getListItemId(appCatalogUrl, args.options, listServerRelativeUrl, logger);
51
+ yield this.updateTenantWideExtension(appCatalogUrl, args.options, listServerRelativeUrl, listItemId, logger);
52
+ }
53
+ catch (err) {
54
+ return this.handleRejectedODataJsonPromise(err);
55
+ }
56
+ });
57
+ }
58
+ getListItemId(appCatalogUrl, options, listServerRelativeUrl, logger) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const { title, id, clientSideComponentId } = options;
61
+ const filter = title ? `Title eq '${title}'` : id ? `Id eq '${id}'` : `TenantWideExtensionComponentId eq '${clientSideComponentId}'`;
62
+ if (this.verbose) {
63
+ logger.logToStderr(`Getting tenant-wide application customizer: "${title || id || clientSideComponentId}"...`);
64
+ }
65
+ const listItemInstances = yield odata_1.odata.getAllItems(`${appCatalogUrl}/_api/web/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')/items?$filter=TenantWideExtensionLocation eq 'ClientSideExtension.ApplicationCustomizer' and ${filter}`);
66
+ if (!listItemInstances || listItemInstances.length === 0) {
67
+ throw 'The specified application customizer was not found';
68
+ }
69
+ if (listItemInstances.length > 1) {
70
+ throw `Multiple application customizers with ${title ? `title '${title}'` : `ClientSideComponentId '${clientSideComponentId}'`} found. Please disambiguate using IDs: ${os.EOL}${listItemInstances.map(item => `- ${item.Id}`).join(os.EOL)}`;
71
+ }
72
+ return listItemInstances[0].Id;
73
+ });
74
+ }
75
+ updateTenantWideExtension(appCatalogUrl, options, listServerRelativeUrl, itemId, logger) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ const { title, id, clientSideComponentId, newTitle, clientSideComponentProperties, webTemplate } = options;
78
+ if (this.verbose) {
79
+ logger.logToStderr(`Updating tenant-wide application customizer: "${title || id || clientSideComponentId}"...`);
80
+ }
81
+ const formValues = [];
82
+ if (newTitle !== undefined) {
83
+ formValues.push({
84
+ FieldName: 'Title',
85
+ FieldValue: newTitle
86
+ });
87
+ }
88
+ if (clientSideComponentProperties !== undefined) {
89
+ formValues.push({
90
+ FieldName: 'TenantWideExtensionComponentProperties',
91
+ FieldValue: clientSideComponentProperties
92
+ });
93
+ }
94
+ if (webTemplate !== undefined) {
95
+ formValues.push({
96
+ FieldName: 'TenantWideExtensionWebTemplate',
97
+ FieldValue: webTemplate
98
+ });
99
+ }
100
+ const requestOptions = {
101
+ url: `${appCatalogUrl}/_api/web/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')/Items(${itemId})/ValidateUpdateListItem()`,
102
+ headers: {
103
+ 'accept': 'application/json;odata=nometadata'
104
+ },
105
+ data: {
106
+ formValues: formValues
107
+ },
108
+ responseType: 'json'
109
+ };
110
+ yield request_1.default.post(requestOptions);
111
+ });
112
+ }
113
+ }
114
+ _SpoTenantApplicationCustomizerSetCommand_instances = new WeakSet(), _SpoTenantApplicationCustomizerSetCommand_initTelemetry = function _SpoTenantApplicationCustomizerSetCommand_initTelemetry() {
115
+ this.telemetry.push((args) => {
116
+ Object.assign(this.telemetryProperties, {
117
+ title: typeof args.options.title !== 'undefined',
118
+ id: typeof args.options.id !== 'undefined',
119
+ clientSideComponentId: typeof args.options.clientSideComponentId !== 'undefined',
120
+ newTitle: typeof args.options.newTitle !== 'undefined',
121
+ clientSideComponentProperties: typeof args.options.clientSideComponentProperties !== 'undefined',
122
+ webTemplate: typeof args.options.webTemplate !== 'undefined'
123
+ });
124
+ });
125
+ }, _SpoTenantApplicationCustomizerSetCommand_initOptions = function _SpoTenantApplicationCustomizerSetCommand_initOptions() {
126
+ this.options.unshift({
127
+ option: '-i, --id [id]'
128
+ }, {
129
+ option: '-t, --title [title]'
130
+ }, {
131
+ option: '-c, --clientSideComponentId [clientSideComponentId]'
132
+ }, {
133
+ option: '--newTitle [newTitle]'
134
+ }, {
135
+ option: '-p, --clientSideComponentProperties [clientSideComponentProperties]'
136
+ }, {
137
+ option: '-w, --webTemplate [webTemplate]'
138
+ });
139
+ }, _SpoTenantApplicationCustomizerSetCommand_initValidators = function _SpoTenantApplicationCustomizerSetCommand_initValidators() {
140
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
141
+ if (args.options.id && isNaN(parseInt(args.options.id))) {
142
+ return `${args.options.id} is not a number`;
143
+ }
144
+ if (args.options.clientSideComponentId && !validation_1.validation.isValidGuid(args.options.clientSideComponentId)) {
145
+ return `${args.options.clientSideComponentId} is not a valid GUID`;
146
+ }
147
+ if (!args.options.newTitle && !args.options.clientSideComponentProperties && !args.options.webTemplate) {
148
+ return `Please specify an option to be updated`;
149
+ }
150
+ return true;
151
+ }));
152
+ }, _SpoTenantApplicationCustomizerSetCommand_initOptionSets = function _SpoTenantApplicationCustomizerSetCommand_initOptionSets() {
153
+ this.optionSets.push({ options: ['title', 'id', 'clientSideComponentId'] });
154
+ };
155
+ module.exports = new SpoTenantApplicationCustomizerSetCommand();
156
+ //# sourceMappingURL=tenant-applicationcustomizer-set.js.map