@pnp/cli-microsoft365 6.3.0 → 6.4.0-beta.140530d

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 (212) hide show
  1. package/.devcontainer/Dockerfile +5 -2
  2. package/.eslintrc.js +4 -0
  3. package/Dockerfile +6 -3
  4. package/README.md +12 -1
  5. package/dist/Auth.js +1 -3
  6. package/dist/Command.js +1 -0
  7. package/dist/m365/aad/commands/user/user-get.js +3 -0
  8. package/dist/m365/aad/commands/user/user-license-remove.js +2 -1
  9. package/dist/m365/aad/commands/user/user-recyclebinitem-restore.js +2 -9
  10. package/dist/m365/aad/commands/user/user-set.js +3 -0
  11. package/dist/m365/aad/commands/user/user-signin-list.js +3 -0
  12. package/dist/m365/file/commands/file-list.js +5 -1
  13. package/dist/m365/flow/commands/flow-disable.js +9 -2
  14. package/dist/m365/flow/commands/flow-enable.js +9 -2
  15. package/dist/m365/flow/commands/flow-get.js +9 -2
  16. package/dist/m365/flow/commands/flow-list.js +1 -1
  17. package/dist/m365/flow/commands/flow-remove.js +2 -2
  18. package/dist/m365/flow/commands/owner/owner-ensure.js +147 -0
  19. package/dist/m365/flow/commands/owner/owner-list.js +89 -0
  20. package/dist/m365/flow/commands/owner/owner-remove.js +147 -0
  21. package/dist/m365/flow/commands/run/run-cancel.js +9 -2
  22. package/dist/m365/flow/commands/run/run-list.js +5 -2
  23. package/dist/m365/flow/commands.js +3 -0
  24. package/dist/m365/planner/commands/roster/roster-member-add.js +3 -0
  25. package/dist/m365/planner/commands/roster/roster-member-get.js +98 -0
  26. package/dist/m365/planner/commands.js +1 -0
  27. package/dist/m365/purview/commands/retentionevent/retentionevent-add.js +138 -0
  28. package/dist/m365/purview/commands/retentionlabel/retentionlabel-add.js +48 -14
  29. package/dist/m365/purview/commands.js +1 -0
  30. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.17.0-beta.1.js +59 -0
  31. package/dist/m365/spfx/commands/project/project-upgrade.js +16 -13
  32. package/dist/m365/spfx/commands/spfx-doctor.js +43 -29
  33. package/dist/m365/spo/commands/commandset/commandset-add.js +138 -0
  34. package/dist/m365/spo/commands/commandset/commandset-get.js +128 -0
  35. package/dist/m365/spo/commands/commandset/commandset-list.js +77 -0
  36. package/dist/m365/spo/commands/commandset/commandset-remove.js +146 -0
  37. package/dist/m365/spo/commands/commandset/commandset-set.js +182 -0
  38. package/dist/m365/spo/commands/customaction/customaction-get.js +27 -7
  39. package/dist/m365/spo/commands/file/file-move.js +1 -1
  40. package/dist/m365/spo/commands/group/group-member-add.js +54 -95
  41. package/dist/m365/spo/commands/list/list-add.js +11 -8
  42. package/dist/m365/spo/commands/list/list-set.js +3 -3
  43. package/dist/m365/spo/commands/navigation/navigation-node-add.js +5 -4
  44. package/dist/m365/spo/commands/navigation/navigation-node-set.js +5 -1
  45. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-get.js +118 -0
  46. package/dist/m365/spo/commands/term/term-get.js +68 -48
  47. package/dist/m365/spo/commands/user/user-ensure.js +105 -0
  48. package/dist/m365/spo/commands.js +7 -0
  49. package/dist/m365/todo/commands/task/task-add.js +35 -3
  50. package/dist/utils/aadGroup.js +18 -0
  51. package/dist/utils/aadUser.js +37 -0
  52. package/dist/utils/md.js +7 -0
  53. package/dist/utils/spo.js +32 -0
  54. package/docs/docs/cmd/aad/app/app-add.md +3 -3
  55. package/docs/docs/cmd/aad/approleassignment/approleassignment-add.md +5 -5
  56. package/docs/docs/cmd/aad/approleassignment/approleassignment-remove.md +3 -3
  57. package/docs/docs/cmd/aad/user/user-remove.md +1 -1
  58. package/docs/docs/cmd/cli/completion/completion-clink-update.md +4 -4
  59. package/docs/docs/cmd/flow/owner/owner-ensure.md +61 -0
  60. package/docs/docs/cmd/flow/owner/owner-list.md +90 -0
  61. package/docs/docs/cmd/flow/owner/owner-remove.md +67 -0
  62. package/docs/docs/cmd/flow/run/run-list.md +28 -0
  63. package/docs/docs/cmd/onenote/page/page-list.md +1 -1
  64. package/docs/docs/cmd/outlook/mail/mail-send.md +7 -3
  65. package/docs/docs/cmd/outlook/message/message-get.md +143 -0
  66. package/docs/docs/cmd/outlook/message/message-list.md +119 -0
  67. package/docs/docs/cmd/outlook/message/message-move.md +4 -0
  68. package/docs/docs/cmd/outlook/report/report-mailactivitycounts.md +40 -0
  69. package/docs/docs/cmd/outlook/report/report-mailactivityusercounts.md +40 -0
  70. package/docs/docs/cmd/outlook/report/report-mailactivityuserdetail.md +45 -0
  71. package/docs/docs/cmd/outlook/report/report-mailappusageappsusercounts.md +43 -0
  72. package/docs/docs/cmd/outlook/report/report-mailappusageusercounts.md +44 -0
  73. package/docs/docs/cmd/outlook/report/report-mailappusageuserdetail.md +48 -0
  74. package/docs/docs/cmd/outlook/report/report-mailappusageversionsusercounts.md +41 -0
  75. package/docs/docs/cmd/outlook/report/report-mailboxusagedetail.md +49 -0
  76. package/docs/docs/cmd/outlook/report/report-mailboxusagemailboxcount.md +37 -0
  77. package/docs/docs/cmd/outlook/report/report-mailboxusagequotastatusmailboxcounts.md +40 -0
  78. package/docs/docs/cmd/outlook/report/report-mailboxusagestorage.md +36 -0
  79. package/docs/docs/cmd/outlook/room/room-list.md +81 -0
  80. package/docs/docs/cmd/outlook/roomlist/roomlist-list.md +58 -0
  81. package/docs/docs/cmd/planner/plan/plan-add.md +3 -3
  82. package/docs/docs/cmd/planner/plan/plan-set.md +73 -7
  83. package/docs/docs/cmd/planner/roster/roster-add.md +16 -1
  84. package/docs/docs/cmd/planner/roster/roster-member-get.md +87 -0
  85. package/docs/docs/cmd/planner/task/task-add.md +230 -0
  86. package/docs/docs/cmd/planner/task/task-checklistitem-add.md +55 -0
  87. package/docs/docs/cmd/planner/task/task-checklistitem-list.md +55 -0
  88. package/docs/docs/cmd/planner/task/task-checklistitem-remove.md +4 -0
  89. package/docs/docs/cmd/planner/task/task-get.md +131 -0
  90. package/docs/docs/cmd/planner/task/task-list.md +92 -0
  91. package/docs/docs/cmd/planner/task/task-reference-add.md +46 -0
  92. package/docs/docs/cmd/planner/task/task-reference-list.md +46 -0
  93. package/docs/docs/cmd/planner/task/task-reference-remove.md +4 -0
  94. package/docs/docs/cmd/planner/task/task-remove.md +4 -0
  95. package/docs/docs/cmd/planner/task/task-set.md +230 -0
  96. package/docs/docs/cmd/planner/tenant/tenant-settings-list.md +55 -0
  97. package/docs/docs/cmd/planner/tenant/tenant-settings-set.md +55 -0
  98. package/docs/docs/cmd/pp/card/card-get.md +2 -2
  99. package/docs/docs/cmd/pp/card/card-list.md +2 -2
  100. package/docs/docs/cmd/purview/retentionevent/retentionevent-add.md +149 -0
  101. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-add.md +7 -7
  102. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-add.md +12 -0
  103. package/docs/docs/cmd/skype/report/report-activitycounts.md +38 -0
  104. package/docs/docs/cmd/skype/report/report-activityusercounts.md +38 -0
  105. package/docs/docs/cmd/skype/report/report-activityuserdetail.md +67 -0
  106. package/docs/docs/cmd/spfx/project/project-doctor.md +3 -3
  107. package/docs/docs/cmd/spfx/project/project-externalize.md +3 -3
  108. package/docs/docs/cmd/spfx/project/project-permissions-grant.md +21 -0
  109. package/docs/docs/cmd/spfx/project/project-upgrade.md +3 -3
  110. package/docs/docs/cmd/spfx/spfx-doctor.md +3 -3
  111. package/docs/docs/cmd/spo/cdn/cdn-get.md +6 -6
  112. package/docs/docs/cmd/spo/cdn/cdn-origin-add.md +3 -3
  113. package/docs/docs/cmd/spo/cdn/cdn-origin-list.md +3 -3
  114. package/docs/docs/cmd/spo/cdn/cdn-origin-remove.md +3 -3
  115. package/docs/docs/cmd/spo/cdn/cdn-policy-list.md +3 -3
  116. package/docs/docs/cmd/spo/cdn/cdn-policy-set.md +3 -3
  117. package/docs/docs/cmd/spo/cdn/cdn-set.md +3 -3
  118. package/docs/docs/cmd/spo/commandset/commandset-add.md +159 -0
  119. package/docs/docs/cmd/spo/commandset/commandset-get.md +149 -0
  120. package/docs/docs/cmd/spo/commandset/commandset-list.md +109 -0
  121. package/docs/docs/cmd/spo/commandset/commandset-remove.md +55 -0
  122. package/docs/docs/cmd/spo/commandset/commandset-set.md +71 -0
  123. package/docs/docs/cmd/spo/customaction/customaction-get.md +113 -11
  124. package/docs/docs/cmd/spo/externaluser/externaluser-list.md +2 -0
  125. package/docs/docs/cmd/spo/group/group-member-add.md +26 -4
  126. package/docs/docs/cmd/spo/hidedefaultthemes/hidedefaultthemes-get.md +2 -0
  127. package/docs/docs/cmd/spo/hidedefaultthemes/hidedefaultthemes-set.md +2 -0
  128. package/docs/docs/cmd/spo/homesite/homesite-remove.md +2 -0
  129. package/docs/docs/cmd/spo/homesite/homesite-set.md +2 -0
  130. package/docs/docs/cmd/spo/knowledgehub/knowledgehub-get.md +2 -0
  131. package/docs/docs/cmd/spo/knowledgehub/knowledgehub-remove.md +2 -0
  132. package/docs/docs/cmd/spo/knowledgehub/knowledgehub-set.md +3 -3
  133. package/docs/docs/cmd/spo/list/list-add.md +2 -2
  134. package/docs/docs/cmd/spo/list/list-set.md +2 -2
  135. package/docs/docs/cmd/spo/listitem/listitem-add.md +1 -1
  136. package/docs/docs/cmd/spo/listitem/listitem-batch-add.md +1 -1
  137. package/docs/docs/cmd/spo/listitem/listitem-set.md +1 -1
  138. package/docs/docs/cmd/spo/navigation/navigation-node-add.md +3 -3
  139. package/docs/docs/cmd/spo/navigation/navigation-node-set.md +2 -2
  140. package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-add.md +2 -0
  141. package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-list.md +2 -0
  142. package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-remove.md +2 -0
  143. package/docs/docs/cmd/spo/orgnewssite/orgnewssite-list.md +2 -0
  144. package/docs/docs/cmd/spo/orgnewssite/orgnewssite-remove.md +2 -0
  145. package/docs/docs/cmd/spo/orgnewssite/orgnewssite-set.md +3 -3
  146. package/docs/docs/cmd/spo/site/site-appcatalog-add.md +2 -0
  147. package/docs/docs/cmd/spo/site/site-appcatalog-remove.md +3 -3
  148. package/docs/docs/cmd/spo/site/site-commsite-enable.md +2 -0
  149. package/docs/docs/cmd/spo/site/site-list.md +3 -3
  150. package/docs/docs/cmd/spo/site/site-remove.md +3 -3
  151. package/docs/docs/cmd/spo/site/site-rename.md +3 -3
  152. package/docs/docs/cmd/spo/site/site-set.md +5 -5
  153. package/docs/docs/cmd/spo/storageentity/storageentity-remove.md +3 -3
  154. package/docs/docs/cmd/spo/storageentity/storageentity-set.md +3 -3
  155. package/docs/docs/cmd/spo/tenant/tenant-appcatalog-add.md +3 -3
  156. package/docs/docs/cmd/spo/tenant/tenant-appcatalogurl-get.md +2 -0
  157. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-add.md +3 -3
  158. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-get.md +142 -0
  159. package/docs/docs/cmd/spo/tenant/tenant-recyclebinitem-list.md +2 -0
  160. package/docs/docs/cmd/spo/tenant/tenant-recyclebinitem-remove.md +3 -3
  161. package/docs/docs/cmd/spo/tenant/tenant-recyclebinitem-restore.md +3 -3
  162. package/docs/docs/cmd/spo/tenant/tenant-settings-list.md +2 -0
  163. package/docs/docs/cmd/spo/tenant/tenant-settings-set.md +28 -26
  164. package/docs/docs/cmd/spo/term/term-add.md +3 -3
  165. package/docs/docs/cmd/spo/term/term-get.md +3 -3
  166. package/docs/docs/cmd/spo/term/term-group-add.md +2 -0
  167. package/docs/docs/cmd/spo/term/term-group-get.md +2 -0
  168. package/docs/docs/cmd/spo/term/term-group-list.md +2 -0
  169. package/docs/docs/cmd/spo/term/term-list.md +3 -1
  170. package/docs/docs/cmd/spo/term/term-set-add.md +3 -3
  171. package/docs/docs/cmd/spo/term/term-set-get.md +2 -0
  172. package/docs/docs/cmd/spo/term/term-set-list.md +2 -0
  173. package/docs/docs/cmd/spo/theme/theme-apply.md +3 -3
  174. package/docs/docs/cmd/spo/theme/theme-get.md +2 -0
  175. package/docs/docs/cmd/spo/theme/theme-list.md +2 -0
  176. package/docs/docs/cmd/spo/theme/theme-remove.md +2 -0
  177. package/docs/docs/cmd/spo/theme/theme-set.md +3 -3
  178. package/docs/docs/cmd/spo/user/user-ensure.md +109 -0
  179. package/docs/docs/cmd/teams/channel/channel-get.md +1 -1
  180. package/docs/docs/cmd/teams/channel/channel-member-add.md +2 -2
  181. package/docs/docs/cmd/teams/message/message-get.md +39 -4
  182. package/docs/docs/cmd/teams/message/message-list.md +41 -6
  183. package/docs/docs/cmd/teams/message/message-reply-list.md +39 -4
  184. package/docs/docs/cmd/teams/messagingsettings/messagingsettings-list.md +20 -2
  185. package/docs/docs/cmd/teams/messagingsettings/messagingsettings-set.md +8 -8
  186. package/docs/docs/cmd/teams/report/report-deviceusagedistributionusercounts.md +12 -5
  187. package/docs/docs/cmd/teams/report/report-deviceusageusercounts.md +13 -6
  188. package/docs/docs/cmd/teams/report/report-deviceusageuserdetail.md +14 -7
  189. package/docs/docs/cmd/teams/report/report-directroutingcalls.md +13 -6
  190. package/docs/docs/cmd/teams/report/report-pstncalls.md +13 -6
  191. package/docs/docs/cmd/teams/report/report-useractivitycounts.md +13 -6
  192. package/docs/docs/cmd/teams/report/report-useractivityusercounts.md +13 -6
  193. package/docs/docs/cmd/teams/report/report-useractivityuserdetail.md +13 -6
  194. package/docs/docs/cmd/teams/tab/tab-add.md +16 -0
  195. package/docs/docs/cmd/teams/tab/tab-get.md +17 -0
  196. package/docs/docs/cmd/teams/tab/tab-list.md +19 -0
  197. package/docs/docs/cmd/teams/team/team-add.md +77 -8
  198. package/docs/docs/cmd/teams/team/team-app-list.md +18 -2
  199. package/docs/docs/cmd/teams/team/team-archive.md +2 -2
  200. package/docs/docs/cmd/teams/team/team-clone.md +8 -8
  201. package/docs/docs/cmd/teams/team/team-get.md +34 -4
  202. package/docs/docs/cmd/teams/team/team-list.md +34 -3
  203. package/docs/docs/cmd/teams/team/team-remove.md +3 -3
  204. package/docs/docs/cmd/teams/team/team-set.md +8 -8
  205. package/docs/docs/cmd/teams/team/team-unarchive.md +3 -2
  206. package/docs/docs/cmd/teams/user/user-app-add.md +3 -3
  207. package/docs/docs/cmd/teams/user/user-app-list.md +18 -2
  208. package/docs/docs/cmd/teams/user/user-app-remove.md +4 -4
  209. package/docs/docs/cmd/teams/user/user-list.md +21 -4
  210. package/docs/docs/cmd/todo/task/task-add.md +47 -2
  211. package/npm-shrinkwrap.json +279 -194
  212. package/package.json +15 -14
@@ -0,0 +1,146 @@
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 _SpoCommandSetRemoveCommand_instances, _SpoCommandSetRemoveCommand_initTelemetry, _SpoCommandSetRemoveCommand_initOptions, _SpoCommandSetRemoveCommand_initValidators, _SpoCommandSetRemoveCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const commands_1 = require("../../commands");
19
+ const validation_1 = require("../../../../utils/validation");
20
+ const SpoCommand_1 = require("../../../base/SpoCommand");
21
+ const request_1 = require("../../../../request");
22
+ const formatting_1 = require("../../../../utils/formatting");
23
+ const spo_1 = require("../../../../utils/spo");
24
+ const Cli_1 = require("../../../../cli/Cli");
25
+ class SpoCommandSetRemoveCommand extends SpoCommand_1.default {
26
+ get name() {
27
+ return commands_1.default.COMMANDSET_REMOVE;
28
+ }
29
+ get description() {
30
+ return 'Remove a ListView Command Set that is added to a site.';
31
+ }
32
+ constructor() {
33
+ super();
34
+ _SpoCommandSetRemoveCommand_instances.add(this);
35
+ __classPrivateFieldGet(this, _SpoCommandSetRemoveCommand_instances, "m", _SpoCommandSetRemoveCommand_initTelemetry).call(this);
36
+ __classPrivateFieldGet(this, _SpoCommandSetRemoveCommand_instances, "m", _SpoCommandSetRemoveCommand_initOptions).call(this);
37
+ __classPrivateFieldGet(this, _SpoCommandSetRemoveCommand_instances, "m", _SpoCommandSetRemoveCommand_initValidators).call(this);
38
+ __classPrivateFieldGet(this, _SpoCommandSetRemoveCommand_instances, "m", _SpoCommandSetRemoveCommand_initOptionSets).call(this);
39
+ }
40
+ commandAction(logger, args) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ if (this.verbose) {
43
+ logger.logToStderr(`Removing ListView Command Set ${args.options.clientSideComponentId || args.options.title || args.options.id} to site '${args.options.webUrl}'...`);
44
+ }
45
+ if (args.options.confirm) {
46
+ yield this.deleteCommandset(args);
47
+ }
48
+ else {
49
+ const result = yield Cli_1.Cli.prompt({
50
+ type: 'confirm',
51
+ name: 'continue',
52
+ default: false,
53
+ message: `Are you sure you want to remove command set '${args.options.clientSideComponentId || args.options.title || args.options.id}'?`
54
+ });
55
+ if (result.continue) {
56
+ yield this.deleteCommandset(args);
57
+ }
58
+ }
59
+ });
60
+ }
61
+ getCommandSetId(options) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ if (options.id) {
64
+ return options.id;
65
+ }
66
+ let commandSets = [];
67
+ if (options.title) {
68
+ commandSets = yield spo_1.spo.getCustomActions(options.webUrl, options.scope, `(Title eq '${formatting_1.formatting.encodeQueryParameter(options.title)}') and (startswith(Location,'ClientSideExtension.ListViewCommandSet'))`);
69
+ }
70
+ else {
71
+ commandSets = yield spo_1.spo.getCustomActions(options.webUrl, options.scope, `(ClientSideComponentId eq guid'${options.clientSideComponentId}') and (startswith(Location,'ClientSideExtension.ListViewCommandSet'))`);
72
+ }
73
+ if (commandSets.length === 0) {
74
+ throw `No user commandsets with ${options.title ? `title '${options.title}'` : `ClientSideComponentId '${options.clientSideComponentId}'`} found`;
75
+ }
76
+ if (commandSets.length > 1) {
77
+ throw `Multiple user commandsets with ${options.title ? `title '${options.title}'` : `ClientSideComponentId '${options.clientSideComponentId}'`} found. Please disambiguate using IDs: ${commandSets.map((commandSet) => commandSet.Id).join(', ')}`;
78
+ }
79
+ return commandSets[0].Id;
80
+ });
81
+ }
82
+ deleteCommandset(args) {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ if (!args.options.scope) {
85
+ args.options.scope = 'Site';
86
+ }
87
+ try {
88
+ const id = yield this.getCommandSetId(args.options);
89
+ const requestOptions = {
90
+ url: `${args.options.webUrl}/_api/${args.options.scope}/UserCustomActions('${formatting_1.formatting.encodeQueryParameter(id)}')`,
91
+ headers: {
92
+ accept: 'application/json;odata=nometadata'
93
+ },
94
+ responseType: 'json'
95
+ };
96
+ yield request_1.default.delete(requestOptions);
97
+ }
98
+ catch (err) {
99
+ this.handleRejectedODataJsonPromise(err);
100
+ }
101
+ });
102
+ }
103
+ }
104
+ _SpoCommandSetRemoveCommand_instances = new WeakSet(), _SpoCommandSetRemoveCommand_initTelemetry = function _SpoCommandSetRemoveCommand_initTelemetry() {
105
+ this.telemetry.push((args) => {
106
+ Object.assign(this.telemetryProperties, {
107
+ title: typeof args.options.title !== 'undefined',
108
+ id: typeof args.options.id !== 'undefined',
109
+ clientSideComponentId: typeof args.options.clientSideComponentId !== 'undefined',
110
+ scope: typeof args.options.scope !== 'undefined',
111
+ confirm: !!args.options.confirm
112
+ });
113
+ });
114
+ }, _SpoCommandSetRemoveCommand_initOptions = function _SpoCommandSetRemoveCommand_initOptions() {
115
+ this.options.unshift({
116
+ option: '-u, --webUrl <webUrl>'
117
+ }, {
118
+ option: '-t, --title [title]'
119
+ }, {
120
+ option: '-i, --id [id]'
121
+ }, {
122
+ option: '-c, --clientSideComponentId [clientSideComponentId]'
123
+ }, {
124
+ option: '-s, --scope [scope]', autocomplete: SpoCommandSetRemoveCommand.scopes
125
+ }, {
126
+ option: '--confirm'
127
+ });
128
+ }, _SpoCommandSetRemoveCommand_initValidators = function _SpoCommandSetRemoveCommand_initValidators() {
129
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
130
+ if (args.options.id && !validation_1.validation.isValidGuid(args.options.id)) {
131
+ return `${args.options.id} is not a valid GUID`;
132
+ }
133
+ if (args.options.clientSideComponentId && !validation_1.validation.isValidGuid(args.options.clientSideComponentId)) {
134
+ return `${args.options.clientSideComponentId} is not a valid GUID`;
135
+ }
136
+ if (args.options.scope && SpoCommandSetRemoveCommand.scopes.indexOf(args.options.scope) < 0) {
137
+ return `${args.options.scope} is not a valid scope. Allowed values are ${SpoCommandSetRemoveCommand.scopes.join(', ')}`;
138
+ }
139
+ return validation_1.validation.isValidSharePointUrl(args.options.webUrl);
140
+ }));
141
+ }, _SpoCommandSetRemoveCommand_initOptionSets = function _SpoCommandSetRemoveCommand_initOptionSets() {
142
+ this.optionSets.push({ options: ['id', 'title', 'clientSideComponentId'] });
143
+ };
144
+ SpoCommandSetRemoveCommand.scopes = ['All', 'Site', 'Web'];
145
+ module.exports = new SpoCommandSetRemoveCommand();
146
+ //# sourceMappingURL=commandset-remove.js.map
@@ -0,0 +1,182 @@
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 _SpoCommandSetSetCommand_instances, _SpoCommandSetSetCommand_initTelemetry, _SpoCommandSetSetCommand_initOptions, _SpoCommandSetSetCommand_initValidators, _SpoCommandSetSetCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const commands_1 = require("../../commands");
19
+ const validation_1 = require("../../../../utils/validation");
20
+ const SpoCommand_1 = require("../../../base/SpoCommand");
21
+ const request_1 = require("../../../../request");
22
+ const formatting_1 = require("../../../../utils/formatting");
23
+ const spo_1 = require("../../../../utils/spo");
24
+ class SpoCommandSetSetCommand extends SpoCommand_1.default {
25
+ get name() {
26
+ return commands_1.default.COMMANDSET_SET;
27
+ }
28
+ get description() {
29
+ return 'Updates a ListView Command Set on a site.';
30
+ }
31
+ constructor() {
32
+ super();
33
+ _SpoCommandSetSetCommand_instances.add(this);
34
+ __classPrivateFieldGet(this, _SpoCommandSetSetCommand_instances, "m", _SpoCommandSetSetCommand_initTelemetry).call(this);
35
+ __classPrivateFieldGet(this, _SpoCommandSetSetCommand_instances, "m", _SpoCommandSetSetCommand_initOptions).call(this);
36
+ __classPrivateFieldGet(this, _SpoCommandSetSetCommand_instances, "m", _SpoCommandSetSetCommand_initValidators).call(this);
37
+ __classPrivateFieldGet(this, _SpoCommandSetSetCommand_instances, "m", _SpoCommandSetSetCommand_initOptionSets).call(this);
38
+ }
39
+ commandAction(logger, args) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ if (this.verbose) {
42
+ logger.logToStderr(`Updating ListView Command Set ${args.options.clientSideComponentId} to site '${args.options.webUrl}'...`);
43
+ }
44
+ if (!args.options.scope) {
45
+ args.options.scope = 'Site';
46
+ }
47
+ const location = this.getLocation(args.options.location ? args.options.location : '');
48
+ try {
49
+ const requestBody = {};
50
+ if (args.options.newTitle) {
51
+ requestBody.Title = args.options.newTitle;
52
+ }
53
+ if (args.options.location) {
54
+ requestBody.Location = location;
55
+ }
56
+ if (args.options.listType) {
57
+ requestBody.RegistrationId = this.getListTemplate(args.options.listType);
58
+ }
59
+ if (args.options.clientSideComponentProperties) {
60
+ requestBody.ClientSideComponentProperties = args.options.clientSideComponentProperties;
61
+ }
62
+ const id = yield this.getCommandSetId(args.options);
63
+ const requestOptions = {
64
+ url: `${args.options.webUrl}/_api/${args.options.scope}/UserCustomActions('${formatting_1.formatting.encodeQueryParameter(id)}')`,
65
+ headers: {
66
+ accept: 'application/json;odata=nometadata',
67
+ 'X-HTTP-Method': 'MERGE'
68
+ },
69
+ data: requestBody,
70
+ responseType: 'json'
71
+ };
72
+ yield request_1.default.post(requestOptions);
73
+ }
74
+ catch (err) {
75
+ this.handleRejectedODataJsonPromise(err);
76
+ }
77
+ });
78
+ }
79
+ getCommandSetId(options) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ if (options.id) {
82
+ return options.id;
83
+ }
84
+ let commandSets = [];
85
+ if (options.title) {
86
+ commandSets = yield spo_1.spo.getCustomActions(options.webUrl, options.scope, `(Title eq '${formatting_1.formatting.encodeQueryParameter(options.title)}') and (startswith(Location,'ClientSideExtension.ListViewCommandSet'))`);
87
+ }
88
+ else {
89
+ commandSets = yield spo_1.spo.getCustomActions(options.webUrl, options.scope, `(ClientSideComponentId eq guid'${options.clientSideComponentId}') and (startswith(Location,'ClientSideExtension.ListViewCommandSet'))`);
90
+ }
91
+ if (commandSets.length === 0) {
92
+ throw `No user commandsets with ${options.title ? `title '${options.title}'` : `ClientSideComponentId '${options.clientSideComponentId}'`} found`;
93
+ }
94
+ if (commandSets.length > 1) {
95
+ throw `Multiple user commandsets with ${options.title ? `title '${options.title}'` : `ClientSideComponentId '${options.clientSideComponentId}'`} found. Please disambiguate using IDs: ${commandSets.map((commandSet) => commandSet.Id).join(', ')}`;
96
+ }
97
+ return commandSets[0].Id;
98
+ });
99
+ }
100
+ getLocation(location) {
101
+ switch (location) {
102
+ case 'Both':
103
+ return 'ClientSideExtension.ListViewCommandSet';
104
+ case 'ContextMenu':
105
+ return 'ClientSideExtension.ListViewCommandSet.ContextMenu';
106
+ default:
107
+ return 'ClientSideExtension.ListViewCommandSet.CommandBar';
108
+ }
109
+ }
110
+ getListTemplate(listTemplate) {
111
+ switch (listTemplate) {
112
+ case 'SitePages':
113
+ return '119';
114
+ case 'Library':
115
+ return '101';
116
+ default:
117
+ return '100';
118
+ }
119
+ }
120
+ }
121
+ _SpoCommandSetSetCommand_instances = new WeakSet(), _SpoCommandSetSetCommand_initTelemetry = function _SpoCommandSetSetCommand_initTelemetry() {
122
+ this.telemetry.push((args) => {
123
+ Object.assign(this.telemetryProperties, {
124
+ title: typeof args.options.title !== 'undefined',
125
+ id: typeof args.options.id !== 'undefined',
126
+ clientSideComponentId: typeof args.options.clientSideComponentId !== 'undefined',
127
+ listType: typeof args.options.listType !== 'undefined',
128
+ clientSideComponentProperties: typeof args.options.clientSideComponentProperties !== 'undefined',
129
+ scope: typeof args.options.scope !== 'undefined',
130
+ location: typeof args.options.location !== 'undefined'
131
+ });
132
+ });
133
+ }, _SpoCommandSetSetCommand_initOptions = function _SpoCommandSetSetCommand_initOptions() {
134
+ this.options.unshift({
135
+ option: '-u, --webUrl <webUrl>'
136
+ }, {
137
+ option: '-t, --title [title]'
138
+ }, {
139
+ option: '-i, --id [id]'
140
+ }, {
141
+ option: '-c, --clientSideComponentId [clientSideComponentId]'
142
+ }, {
143
+ option: '--newTitle [newTitle]'
144
+ }, {
145
+ option: '-l, --listType [listType]', autocomplete: SpoCommandSetSetCommand.listTypes
146
+ }, {
147
+ option: '--clientSideComponentProperties [clientSideComponentProperties]'
148
+ }, {
149
+ option: '-s, --scope [scope]', autocomplete: SpoCommandSetSetCommand.scopes
150
+ }, {
151
+ option: '--location [location]', autocomplete: SpoCommandSetSetCommand.locations
152
+ });
153
+ }, _SpoCommandSetSetCommand_initValidators = function _SpoCommandSetSetCommand_initValidators() {
154
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
155
+ if (args.options.id && !validation_1.validation.isValidGuid(args.options.id)) {
156
+ return `${args.options.id} is not a valid GUID`;
157
+ }
158
+ if (args.options.clientSideComponentId && !validation_1.validation.isValidGuid(args.options.clientSideComponentId)) {
159
+ return `${args.options.clientSideComponentId} is not a valid GUID`;
160
+ }
161
+ if (args.options.listType && SpoCommandSetSetCommand.listTypes.indexOf(args.options.listType) < 0) {
162
+ return `${args.options.listType} is not a valid list type. Allowed values are ${SpoCommandSetSetCommand.listTypes.join(', ')}`;
163
+ }
164
+ if (args.options.scope && SpoCommandSetSetCommand.scopes.indexOf(args.options.scope) < 0) {
165
+ return `${args.options.scope} is not a valid scope. Allowed values are ${SpoCommandSetSetCommand.scopes.join(', ')}`;
166
+ }
167
+ if (args.options.location && SpoCommandSetSetCommand.locations.indexOf(args.options.location) < 0) {
168
+ return `${args.options.location} is not a valid location. Allowed values are ${SpoCommandSetSetCommand.locations.join(', ')}`;
169
+ }
170
+ if (!args.options.newTitle && !args.options.listType && !args.options.clientSideComponentProperties && !args.options.location) {
171
+ return `Please specify option to be updated`;
172
+ }
173
+ return validation_1.validation.isValidSharePointUrl(args.options.webUrl);
174
+ }));
175
+ }, _SpoCommandSetSetCommand_initOptionSets = function _SpoCommandSetSetCommand_initOptionSets() {
176
+ this.optionSets.push({ options: ['id', 'title', 'clientSideComponentId'] });
177
+ };
178
+ SpoCommandSetSetCommand.listTypes = ['List', 'Library', 'SitePages'];
179
+ SpoCommandSetSetCommand.scopes = ['All', 'Site', 'Web'];
180
+ SpoCommandSetSetCommand.locations = ['ContextMenu', 'CommandBar', 'Both'];
181
+ module.exports = new SpoCommandSetSetCommand();
182
+ //# sourceMappingURL=commandset-set.js.map
@@ -77,14 +77,26 @@ class SpoCustomActionGetCommand extends SpoCommand_1.default {
77
77
  }
78
78
  return customAction;
79
79
  }
80
- const customActions = yield spo_1.spo.getCustomActions(options.webUrl, options.scope, `Title eq '${formatting_1.formatting.encodeQueryParameter(options.title)}'`);
81
- if (customActions.length === 1) {
82
- return customActions[0];
80
+ else if (options.title) {
81
+ const customActions = yield spo_1.spo.getCustomActions(options.webUrl, options.scope, `Title eq '${formatting_1.formatting.encodeQueryParameter(options.title)}'`);
82
+ if (customActions.length === 1) {
83
+ return customActions[0];
84
+ }
85
+ if (customActions.length === 0) {
86
+ throw `No user custom action with title '${options.title}' found`;
87
+ }
88
+ throw `Multiple user custom actions with title '${options.title}' found. Please disambiguate using IDs: ${customActions.map(a => a.Id).join(', ')}`;
83
89
  }
84
- if (customActions.length === 0) {
85
- throw `No user custom action with title '${options.title}' found`;
90
+ else {
91
+ const customActions = yield spo_1.spo.getCustomActions(options.webUrl, options.scope, `ClientSideComponentId eq guid'${options.clientSideComponentId}'`);
92
+ if (customActions.length === 0) {
93
+ throw `No user custom action with ClientSideComponentId '${options.clientSideComponentId}' found`;
94
+ }
95
+ if (customActions.length > 1) {
96
+ throw `Multiple user custom actions with ClientSideComponentId '${options.clientSideComponentId}' found. Please disambiguate using IDs: ${customActions.map((customAction) => customAction.Id).join(', ')}`;
97
+ }
98
+ return customActions[0];
86
99
  }
87
- throw `Multiple user custom actions with title '${options.title}' found. Please disambiguate using IDs: ${customActions.map(a => a.Id).join(', ')}`;
88
100
  });
89
101
  }
90
102
  humanizeScope(scope) {
@@ -100,6 +112,9 @@ class SpoCustomActionGetCommand extends SpoCommand_1.default {
100
112
  _SpoCustomActionGetCommand_instances = new WeakSet(), _SpoCustomActionGetCommand_initTelemetry = function _SpoCustomActionGetCommand_initTelemetry() {
101
113
  this.telemetry.push((args) => {
102
114
  Object.assign(this.telemetryProperties, {
115
+ id: typeof args.options.id !== 'undefined',
116
+ title: typeof args.options.title !== 'undefined',
117
+ clientSideComponentId: typeof args.options.clientSideComponentId !== 'undefined',
103
118
  scope: args.options.scope || 'All'
104
119
  });
105
120
  });
@@ -108,6 +123,8 @@ _SpoCustomActionGetCommand_instances = new WeakSet(), _SpoCustomActionGetCommand
108
123
  option: '-i, --id [id]'
109
124
  }, {
110
125
  option: '-t, --title [title]'
126
+ }, {
127
+ option: '-c, --clientSideComponentId [clientSideComponentId]'
111
128
  }, {
112
129
  option: '-u, --webUrl <webUrl>'
113
130
  }, {
@@ -130,10 +147,13 @@ _SpoCustomActionGetCommand_instances = new WeakSet(), _SpoCustomActionGetCommand
130
147
  return `${args.options.scope} is not a valid custom action scope. Allowed values are Site|Web|All`;
131
148
  }
132
149
  }
150
+ if (args.options.clientSideComponentId && validation_1.validation.isValidGuid(args.options.clientSideComponentId) === false) {
151
+ return `${args.options.clientSideComponentId} is not a valid GUID.`;
152
+ }
133
153
  return true;
134
154
  }));
135
155
  }, _SpoCustomActionGetCommand_initOptionSets = function _SpoCustomActionGetCommand_initOptionSets() {
136
- this.optionSets.push({ options: ['id', 'title'] });
156
+ this.optionSets.push({ options: ['id', 'title', 'clientSideComponentId'] });
137
157
  };
138
158
  module.exports = new SpoCustomActionGetCommand();
139
159
  //# sourceMappingURL=customaction-get.js.map
@@ -55,7 +55,7 @@ class SpoFileMoveCommand extends SpoCommand_1.default {
55
55
  // A user might enter folder instead of file as source url by mistake
56
56
  // then there are edge cases when deleteIfAlreadyExists flag is set
57
57
  // the user can receive misleading error message.
58
- this.fileExists(tenantUrl, webUrl, args.options.sourceUrl);
58
+ yield this.fileExists(tenantUrl, webUrl, args.options.sourceUrl);
59
59
  if (args.options.deleteIfAlreadyExists) {
60
60
  // try delete target file, if deleteIfAlreadyExists flag is set
61
61
  const filename = args.options.sourceUrl.replace(/^.*[\\\/]/, '');
@@ -15,15 +15,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _SpoGroupMemberAddCommand_instances, _SpoGroupMemberAddCommand_initTelemetry, _SpoGroupMemberAddCommand_initOptions, _SpoGroupMemberAddCommand_initValidators, _SpoGroupMemberAddCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- const Cli_1 = require("../../../../cli/Cli");
19
18
  const request_1 = require("../../../../request");
20
19
  const formatting_1 = require("../../../../utils/formatting");
21
20
  const validation_1 = require("../../../../utils/validation");
22
- const AadUserGetCommand = require("../../../aad/commands/user/user-get");
23
- const AadGroupGetCommand = require("../../../aad/commands/group/group-get");
24
- const SpoUserGetCommand = require("../user/user-get");
25
21
  const SpoCommand_1 = require("../../../base/SpoCommand");
26
22
  const commands_1 = require("../../commands");
23
+ const aadUser_1 = require("../../../../utils/aadUser");
24
+ const aadGroup_1 = require("../../../../utils/aadGroup");
25
+ const spo_1 = require("../../../../utils/spo");
27
26
  class SpoGroupMemberAddCommand extends SpoCommand_1.default {
28
27
  get name() {
29
28
  return commands_1.default.GROUP_MEMBER_ADD;
@@ -48,21 +47,20 @@ class SpoGroupMemberAddCommand extends SpoCommand_1.default {
48
47
  const groupId = yield this.getGroupId(args, logger);
49
48
  const resolvedUsernameList = yield this.getValidUsers(args, logger);
50
49
  if (this.verbose) {
51
- logger.logToStderr(`Adding user(s) to SharePoint Group ${args.options.groupId || args.options.groupName}`);
50
+ logger.logToStderr(`Adding resource(s) to SharePoint Group ${args.options.groupId || args.options.groupName}`);
52
51
  }
53
- const data = {
54
- url: args.options.webUrl,
55
- peoplePickerInput: this.getFormattedUserList(resolvedUsernameList),
56
- roleValue: `group:${groupId}`
57
- };
58
52
  const requestOptions = {
59
53
  url: `${args.options.webUrl}/_api/SP.Web.ShareObject`,
60
54
  headers: {
61
- 'Accept': 'application/json;odata=nometadata',
62
- 'Content-type': 'application/json;odata=verbose'
55
+ accept: 'application/json;odata=nometadata',
56
+ 'content-type': 'application/json;odata=nometadata'
63
57
  },
64
- data: data,
65
- responseType: 'json'
58
+ responseType: 'json',
59
+ data: {
60
+ url: args.options.webUrl,
61
+ peoplePickerInput: this.getFormattedUserList(resolvedUsernameList),
62
+ roleValue: `group:${groupId}`
63
+ }
66
64
  };
67
65
  const sharingResult = yield request_1.default.post(requestOptions);
68
66
  if (sharingResult.ErrorMessage !== null) {
@@ -83,7 +81,7 @@ class SpoGroupMemberAddCommand extends SpoCommand_1.default {
83
81
  `GetByName('${formatting_1.formatting.encodeQueryParameter(args.options.groupName)}')` :
84
82
  `GetById('${args.options.groupId}')`;
85
83
  const requestOptions = {
86
- url: `${args.options.webUrl}/_api/web/sitegroups/${getGroupMethod}`,
84
+ url: `${args.options.webUrl}/_api/web/sitegroups/${getGroupMethod}?$select=Id`,
87
85
  headers: {
88
86
  'accept': 'application/json;odata=nometadata'
89
87
  },
@@ -91,91 +89,52 @@ class SpoGroupMemberAddCommand extends SpoCommand_1.default {
91
89
  };
92
90
  return request_1.default
93
91
  .get(requestOptions)
94
- .then(response => {
95
- const groupId = response.Id;
96
- if (!groupId) {
97
- return Promise.reject(`The specified group does not exist in the SharePoint site`);
98
- }
99
- return groupId;
100
- });
92
+ .then(response => response.Id);
101
93
  }
102
94
  getValidUsers(args, logger) {
103
- if (this.verbose) {
104
- logger.logToStderr(`Checking if the specified users exist`);
105
- }
106
- const validUserNames = [];
107
- const invalidUserNames = [];
108
- const userIdentifiers = args.options.userName || args.options.email || args.options.aadGroupId || args.options.aadGroupName || args.options.userId.toString();
109
- return Promise
110
- .all(userIdentifiers.split(',').map((userIdentifier) => __awaiter(this, void 0, void 0, function* () {
111
- const user = userIdentifier.trim();
112
- try {
113
- if (args.options.userId) {
114
- yield this.spoUserGet(args.options, user, logger, validUserNames);
115
- }
116
- else if (args.options.aadGroupId || args.options.aadGroupName) {
117
- yield this.aadGroupGet(args.options, user, logger, validUserNames);
118
- }
119
- else {
120
- yield this.aadUserGet(args.options, user, logger, validUserNames);
121
- }
122
- }
123
- catch (err) {
124
- logger.logToStderr(err.stderr);
125
- invalidUserNames.push(userIdentifier);
126
- return err;
127
- }
128
- })))
129
- .then(() => {
130
- if (invalidUserNames.length > 0) {
131
- return Promise.reject(`Users not added to the group because the following users don't exist: ${invalidUserNames.join(', ')}`);
132
- }
133
- return Promise.resolve(validUserNames);
134
- });
135
- }
136
- aadUserGet(options, userIdentifier, logger, validUserNames) {
95
+ var _a, _b, _c, _d;
137
96
  return __awaiter(this, void 0, void 0, function* () {
138
97
  if (this.verbose) {
139
- logger.logToStderr(`Get UPN from Azure AD for user ${userIdentifier}`);
98
+ logger.logToStderr('Checking if the specified users and groups exist');
140
99
  }
141
- const aadUserGetCommandoptions = Object.assign(Object.assign(Object.assign({}, (options.userName && { userName: userIdentifier })), (options.email && { email: userIdentifier })), { output: 'json', debug: options.debug, verbose: options.verbose });
142
- const aadUserGetOutput = yield Cli_1.Cli.executeCommandWithOutput(AadUserGetCommand, { options: Object.assign(Object.assign({}, aadUserGetCommandoptions), { _: [] }) });
143
- if (this.debug) {
144
- logger.logToStderr(aadUserGetOutput.stderr);
145
- }
146
- validUserNames.push(JSON.parse(aadUserGetOutput.stdout).userPrincipalName);
147
- });
148
- }
149
- aadGroupGet(options, userIdentifier, logger, validUserNames) {
150
- return __awaiter(this, void 0, void 0, function* () {
151
- if (this.verbose) {
152
- logger.logToStderr(`Get UPN from Azure AD for group ${userIdentifier}`);
153
- }
154
- const aadUserGetCommandoptions = Object.assign(Object.assign(Object.assign({}, (options.aadGroupId && { id: userIdentifier })), (options.aadGroupName && { title: userIdentifier })), { output: 'json', debug: options.debug, verbose: options.verbose });
155
- const aadGroupGetOutput = yield Cli_1.Cli.executeCommandWithOutput(AadGroupGetCommand, { options: Object.assign(Object.assign({}, aadUserGetCommandoptions), { _: [] }) });
156
- if (this.debug) {
157
- logger.logToStderr(aadGroupGetOutput.stderr);
158
- }
159
- validUserNames.push(JSON.parse(aadGroupGetOutput.stdout).mail);
160
- });
161
- }
162
- spoUserGet(options, userIdentifier, logger, validUserNames) {
163
- return __awaiter(this, void 0, void 0, function* () {
164
- if (this.verbose) {
165
- logger.logToStderr(`Get UPN from SharePoint for user ${userIdentifier}`);
166
- }
167
- const spoUserGetCommandoptions = {
168
- id: userIdentifier,
169
- webUrl: options.webUrl,
170
- output: 'json',
171
- debug: options.debug,
172
- verbose: options.verbose
173
- };
174
- const spoUserGetOutput = yield Cli_1.Cli.executeCommandWithOutput(SpoUserGetCommand, { options: Object.assign(Object.assign({}, spoUserGetCommandoptions), { _: [] }) });
175
- if (this.debug) {
176
- logger.logToStderr(spoUserGetOutput.stderr);
177
- }
178
- validUserNames.push(JSON.parse(spoUserGetOutput.stdout).UserPrincipalName);
100
+ const validUserNames = [];
101
+ const identifiers = (_d = (_c = (_b = (_a = args.options.userName) !== null && _a !== void 0 ? _a : args.options.email) !== null && _b !== void 0 ? _b : args.options.aadGroupId) !== null && _c !== void 0 ? _c : args.options.aadGroupName) !== null && _d !== void 0 ? _d : args.options.userId.toString();
102
+ yield Promise.all(identifiers.split(',').map((identifier) => __awaiter(this, void 0, void 0, function* () {
103
+ const trimmedIdentifier = identifier.trim();
104
+ try {
105
+ if (args.options.userId) {
106
+ if (this.verbose) {
107
+ logger.logToStderr(`Getting AAD ID of user with ID ${trimmedIdentifier}`);
108
+ }
109
+ const spoUserAzureId = yield spo_1.spo.getUserAzureIdBySpoId(args.options.webUrl, trimmedIdentifier);
110
+ validUserNames.push(spoUserAzureId);
111
+ }
112
+ else if (args.options.userName) {
113
+ validUserNames.push(trimmedIdentifier);
114
+ }
115
+ else if (args.options.aadGroupId) {
116
+ validUserNames.push(trimmedIdentifier);
117
+ }
118
+ else if (args.options.aadGroupName) {
119
+ if (this.verbose) {
120
+ logger.logToStderr(`Getting ID of Azure AD group ${trimmedIdentifier}`);
121
+ }
122
+ const groupId = yield aadGroup_1.aadGroup.getGroupIdByDisplayName(trimmedIdentifier);
123
+ validUserNames.push(groupId);
124
+ }
125
+ else {
126
+ if (this.verbose) {
127
+ logger.logToStderr(`Getting Azure AD ID for user ${trimmedIdentifier}`);
128
+ }
129
+ const upn = yield aadUser_1.aadUser.getUserIdByEmail(trimmedIdentifier);
130
+ validUserNames.push(upn);
131
+ }
132
+ }
133
+ catch (err) {
134
+ throw `Resource '${trimmedIdentifier}' does not exist.`;
135
+ }
136
+ })));
137
+ return validUserNames;
179
138
  });
180
139
  }
181
140
  getFormattedUserList(activeUserList) {