@pnp/cli-microsoft365 8.1.0-beta.3dec9fa → 8.1.0-beta.75a1364

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 (88) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/Auth.js +9 -9
  4. package/dist/Command.js +49 -2
  5. package/dist/cli/cli.js +66 -39
  6. package/dist/m365/commands/login.js +44 -96
  7. package/dist/m365/connection/commands/connection-remove.js +6 -2
  8. package/dist/m365/connection/commands/connection-set.js +4 -1
  9. package/dist/m365/connection/commands/connection-use.js +25 -4
  10. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-remove.js +123 -0
  11. package/dist/m365/entra/commands/group/group-set.js +256 -0
  12. package/dist/m365/entra/commands/m365group/m365group-user-add.js +109 -32
  13. package/dist/m365/entra/commands/m365group/m365group-user-set.js +159 -84
  14. package/dist/m365/entra/commands/multitenant/multitenant-add.js +65 -0
  15. package/dist/m365/entra/commands/multitenant/multitenant-remove.js +118 -0
  16. package/dist/m365/entra/commands/multitenant/multitenant-set.js +72 -0
  17. package/dist/m365/entra/commands.js +6 -0
  18. package/dist/m365/flow/commands/flow-get.js +1 -1
  19. package/dist/m365/pa/commands/app/app-export.js +13 -7
  20. package/dist/m365/spe/ContainerTypeProperties.js +2 -0
  21. package/dist/m365/spe/commands/containertype/containertype-list.js +49 -0
  22. package/dist/m365/spe/commands.js +2 -1
  23. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-get.js +16 -21
  24. package/dist/m365/spo/commands/commandset/commandset-get.js +31 -17
  25. package/dist/m365/spo/commands/file/file-roleassignment-add.js +1 -1
  26. package/dist/m365/spo/commands/file/file-roleinheritance-break.js +1 -1
  27. package/dist/m365/spo/commands/file/file-roleinheritance-reset.js +1 -1
  28. package/dist/m365/spo/commands/folder/folder-retentionlabel-ensure.js +1 -1
  29. package/dist/m365/spo/commands/folder/folder-sharinglink-get.js +86 -0
  30. package/dist/m365/spo/commands/folder/folder-sharinglink-list.js +110 -0
  31. package/dist/m365/spo/commands/list/ListInstance.js +6 -1
  32. package/dist/m365/spo/commands/list/list-get.js +9 -3
  33. package/dist/m365/spo/commands/list/list-roleassignment-add.js +46 -21
  34. package/dist/m365/spo/commands/list/list-roleassignment-remove.js +48 -46
  35. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-get.js +19 -5
  36. package/dist/m365/spo/commands/tenant/tenant-commandset-get.js +20 -6
  37. package/dist/m365/spo/commands.js +2 -0
  38. package/dist/m365/teams/commands/message/message-restore.js +106 -0
  39. package/dist/m365/teams/commands.js +1 -0
  40. package/dist/utils/drive.js +61 -0
  41. package/dist/utils/formatting.js +16 -0
  42. package/dist/utils/spo.js +69 -6
  43. package/dist/utils/zod.js +124 -0
  44. package/docs/docs/cmd/connection/connection-use.mdx +8 -2
  45. package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-remove.mdx +65 -0
  46. package/docs/docs/cmd/entra/group/group-add.mdx +0 -4
  47. package/docs/docs/cmd/entra/group/group-set.mdx +89 -0
  48. package/docs/docs/cmd/entra/m365group/m365group-user-add.mdx +28 -10
  49. package/docs/docs/cmd/entra/m365group/m365group-user-set.mdx +35 -11
  50. package/docs/docs/cmd/entra/multitenant/multitenant-add.mdx +107 -0
  51. package/docs/docs/cmd/entra/multitenant/multitenant-remove.mdx +58 -0
  52. package/docs/docs/cmd/entra/multitenant/multitenant-set.mdx +53 -0
  53. package/docs/docs/cmd/flow/flow-get.mdx +149 -283
  54. package/docs/docs/cmd/pa/app/app-export.mdx +15 -9
  55. package/docs/docs/cmd/planner/plan/plan-remove.mdx +1 -1
  56. package/docs/docs/cmd/spe/containertype/containertype-list.mdx +102 -0
  57. package/docs/docs/cmd/spo/app/app-uninstall.mdx +1 -1
  58. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-get.mdx +87 -38
  59. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-list.mdx +22 -28
  60. package/docs/docs/cmd/spo/commandset/commandset-get.mdx +75 -24
  61. package/docs/docs/cmd/spo/commandset/commandset-list.mdx +26 -32
  62. package/docs/docs/cmd/spo/file/file-retentionlabel-ensure.mdx +1 -1
  63. package/docs/docs/cmd/spo/file/file-roleassignment-add.mdx +2 -2
  64. package/docs/docs/cmd/spo/file/file-roleassignment-remove.mdx +1 -1
  65. package/docs/docs/cmd/spo/file/file-roleinheritance-break.mdx +1 -1
  66. package/docs/docs/cmd/spo/file/file-roleinheritance-reset.mdx +1 -1
  67. package/docs/docs/cmd/spo/folder/folder-retentionlabel-ensure.mdx +2 -2
  68. package/docs/docs/cmd/spo/folder/folder-sharinglink-get.mdx +110 -0
  69. package/docs/docs/cmd/spo/folder/folder-sharinglink-list.mdx +114 -0
  70. package/docs/docs/cmd/spo/list/list-get.mdx +6 -0
  71. package/docs/docs/cmd/spo/list/list-roleassignment-add.mdx +15 -3
  72. package/docs/docs/cmd/spo/list/list-roleassignment-remove.mdx +15 -3
  73. package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-ensure.mdx +4 -4
  74. package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-remove.mdx +1 -1
  75. package/docs/docs/cmd/spo/listitem/listitem-roleassignment-add.mdx +9 -9
  76. package/docs/docs/cmd/spo/listitem/listitem-roleassignment-remove.mdx +7 -7
  77. package/docs/docs/cmd/spo/site/site-recyclebinitem-list.mdx +1 -1
  78. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-get.mdx +79 -30
  79. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-list.mdx +20 -19
  80. package/docs/docs/cmd/spo/tenant/tenant-commandset-get.mdx +84 -38
  81. package/docs/docs/cmd/spo/tenant/tenant-commandset-list.mdx +20 -19
  82. package/docs/docs/cmd/spo/web/web-roleassignment-add.mdx +1 -1
  83. package/docs/docs/cmd/spo/web/web-roleassignment-remove.mdx +1 -1
  84. package/docs/docs/cmd/teams/meeting/meeting-list.mdx +7 -3
  85. package/docs/docs/cmd/teams/message/message-remove.mdx +2 -1
  86. package/docs/docs/cmd/teams/message/message-restore.mdx +62 -0
  87. package/npm-shrinkwrap.json +1002 -1147
  88. package/package.json +26 -23
@@ -3,14 +3,15 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
3
  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");
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _EntraM365GroupUserSetCommand_instances, _EntraM365GroupUserSetCommand_initTelemetry, _EntraM365GroupUserSetCommand_initOptions, _EntraM365GroupUserSetCommand_initValidators, _EntraM365GroupUserSetCommand_initOptionSets;
6
+ var _EntraM365GroupUserSetCommand_instances, _EntraM365GroupUserSetCommand_initTelemetry, _EntraM365GroupUserSetCommand_initOptions, _EntraM365GroupUserSetCommand_initValidators, _EntraM365GroupUserSetCommand_initOptionSets, _EntraM365GroupUserSetCommand_initTypes;
7
7
  import request from '../../../../request.js';
8
- import { odata } from '../../../../utils/odata.js';
9
8
  import { validation } from '../../../../utils/validation.js';
9
+ import { formatting } from '../../../../utils/formatting.js';
10
10
  import GraphCommand from '../../../base/GraphCommand.js';
11
11
  import teamsCommands from '../../../teams/commands.js';
12
12
  import commands from '../../commands.js';
13
13
  import { entraGroup } from '../../../../utils/entraGroup.js';
14
+ import { entraUser } from '../../../../utils/entraUser.js';
14
15
  import aadCommands from '../../aadCommands.js';
15
16
  class EntraM365GroupUserSetCommand extends GraphCommand {
16
17
  get name() {
@@ -25,135 +26,209 @@ class EntraM365GroupUserSetCommand extends GraphCommand {
25
26
  constructor() {
26
27
  super();
27
28
  _EntraM365GroupUserSetCommand_instances.add(this);
29
+ this.allowedRoles = ['owner', 'member'];
28
30
  __classPrivateFieldGet(this, _EntraM365GroupUserSetCommand_instances, "m", _EntraM365GroupUserSetCommand_initTelemetry).call(this);
29
31
  __classPrivateFieldGet(this, _EntraM365GroupUserSetCommand_instances, "m", _EntraM365GroupUserSetCommand_initOptions).call(this);
30
32
  __classPrivateFieldGet(this, _EntraM365GroupUserSetCommand_instances, "m", _EntraM365GroupUserSetCommand_initValidators).call(this);
31
33
  __classPrivateFieldGet(this, _EntraM365GroupUserSetCommand_instances, "m", _EntraM365GroupUserSetCommand_initOptionSets).call(this);
34
+ __classPrivateFieldGet(this, _EntraM365GroupUserSetCommand_instances, "m", _EntraM365GroupUserSetCommand_initTypes).call(this);
32
35
  }
33
36
  async commandAction(logger, args) {
34
37
  await this.showDeprecationWarning(logger, aadCommands.M365GROUP_USER_SET, commands.M365GROUP_USER_SET);
38
+ if (args.options.userName) {
39
+ await this.warn(logger, `Option 'userName' is deprecated. Please use 'ids' or 'userNames' instead.`);
40
+ }
35
41
  try {
36
- const groupId = (typeof args.options.groupId !== 'undefined') ? args.options.groupId : args.options.teamId;
42
+ const userNames = args.options.userNames || args.options.userName;
43
+ const groupId = await this.getGroupId(logger, args);
37
44
  const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId);
38
45
  if (!isUnifiedGroup) {
39
46
  throw Error(`Specified group with id '${groupId}' is not a Microsoft 365 group.`);
40
47
  }
41
- let users = await this.getOwners(groupId, logger);
42
- const membersAndGuests = await this.getMembersAndGuests(groupId, logger);
43
- users = users.concat(membersAndGuests);
44
- // Filter out duplicate added values for owners (as they are returned as members as well)
45
- users = users.filter((groupUser, index, self) => index === self.findIndex((t) => (t.id === groupUser.id && t.displayName === groupUser.displayName)));
46
- if (this.debug) {
47
- await logger.logToStderr((typeof args.options.groupId !== 'undefined') ? 'Group owners and members:' : 'Team owners and members:');
48
- await logger.logToStderr(users);
49
- await logger.logToStderr('');
50
- }
51
- if (users.filter(i => args.options.userName.toUpperCase() === i.userPrincipalName.toUpperCase()).length <= 0) {
52
- const userNotInGroup = (typeof args.options.groupId !== 'undefined') ?
53
- 'The specified user does not belong to the given Microsoft 365 Group. Please use the \'m365group user add\' command to add new users.' :
54
- 'The specified user does not belong to the given Microsoft Teams team. Please use the \'graph teams user add\' command to add new users.';
55
- throw new Error(userNotInGroup);
56
- }
57
- if (args.options.role === "Owner") {
58
- const foundMember = users.find(e => args.options.userName.toUpperCase() === e.userPrincipalName.toUpperCase() && e.userType === 'Member');
59
- if (foundMember !== undefined) {
60
- const endpoint = `${this.resource}/v1.0/groups/${groupId}/owners/$ref`;
61
- const requestOptions = {
62
- url: endpoint,
63
- headers: {
64
- 'accept': 'application/json;odata.metadata=none'
65
- },
66
- responseType: 'json',
67
- data: { "@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/" + foundMember.id }
68
- };
69
- await request.post(requestOptions);
70
- }
71
- else {
72
- const userAlreadyOwner = (typeof args.options.groupId !== 'undefined') ?
73
- 'The specified user is already an owner in the specified Microsoft 365 group, and thus cannot be promoted.' :
74
- 'The specified user is already an owner in the specified Microsoft Teams team, and thus cannot be promoted.';
75
- throw new Error(userAlreadyOwner);
76
- }
77
- }
78
- else {
79
- const foundOwner = users.find(e => args.options.userName.toUpperCase() === e.userPrincipalName.toUpperCase() && e.userType === 'Owner');
80
- if (foundOwner !== undefined) {
81
- const endpoint = `${this.resource}/v1.0/groups/${groupId}/owners/${foundOwner.id}/$ref`;
82
- const requestOptions = {
83
- url: endpoint,
84
- headers: {
85
- 'accept': 'application/json;odata.metadata=none'
86
- }
87
- };
88
- await request.delete(requestOptions);
89
- }
90
- else {
91
- const userAlreadyMember = (typeof args.options.groupId !== 'undefined') ?
92
- 'The specified user is already a member in the specified Microsoft 365 group, and thus cannot be demoted.' :
93
- 'The specified user is already a member in the specified Microsoft Teams team, and thus cannot be demoted.';
94
- throw new Error(userAlreadyMember);
95
- }
96
- }
48
+ const userIds = await this.getUserIds(logger, args.options.ids, userNames);
49
+ // we can't simply switch the role
50
+ // first add users to the new role
51
+ await this.addUsers(groupId, userIds, args.options.role);
52
+ // remove users from the old role
53
+ await this.removeUsersFromRole(logger, groupId, userIds, args.options.role);
97
54
  }
98
55
  catch (err) {
99
56
  this.handleRejectedODataJsonPromise(err);
100
57
  }
101
58
  }
102
- async getOwners(groupId, logger) {
59
+ async getGroupId(logger, args) {
60
+ if (args.options.groupId) {
61
+ return args.options.groupId;
62
+ }
63
+ if (args.options.teamId) {
64
+ return args.options.teamId;
65
+ }
66
+ const name = args.options.groupName || args.options.teamName;
103
67
  if (this.verbose) {
104
- await logger.logToStderr(`Retrieving owners of the group with id ${groupId}`);
105
- }
106
- const endpoint = `${this.resource}/v1.0/groups/${groupId}/owners?$select=id,displayName,userPrincipalName,userType`;
107
- const users = await odata.getAllItems(endpoint);
108
- // Currently there is a bug in the Microsoft Graph that returns Owners as
109
- // userType 'member'. We therefore update all returned user as owner
110
- users.forEach(user => {
111
- user.userType = 'Owner';
112
- });
113
- return users;
68
+ await logger.logToStderr('Retrieving Group ID by display name...');
69
+ }
70
+ return entraGroup.getGroupIdByDisplayName(name);
71
+ }
72
+ async getUserIds(logger, userIds, userNames) {
73
+ if (userIds) {
74
+ return formatting.splitAndTrim(userIds);
75
+ }
76
+ if (this.verbose) {
77
+ await logger.logToStderr('Retrieving user ID(s) by username(s)...');
78
+ }
79
+ return entraUser.getUserIdsByUpns(formatting.splitAndTrim(userNames));
114
80
  }
115
- async getMembersAndGuests(groupId, logger) {
81
+ async removeUsersFromRole(logger, groupId, userIds, role) {
82
+ const userIdsToRemove = [];
83
+ const currentRole = (role.toLowerCase() === 'member') ? 'owners' : 'members';
116
84
  if (this.verbose) {
117
- await logger.logToStderr(`Retrieving members of the group with id ${groupId}`);
85
+ await logger.logToStderr(`Removing users from the old role '${currentRole}'.`);
86
+ }
87
+ for (let i = 0; i < userIds.length; i += 20) {
88
+ const userIdsBatch = userIds.slice(i, i + 20);
89
+ const requestOptions = this.getRequestOptions();
90
+ userIdsBatch.map(userId => {
91
+ requestOptions.data.requests.push({
92
+ id: userId,
93
+ method: 'GET',
94
+ url: `/groups/${groupId}/${currentRole}/$count?$filter=id eq '${userId}'`,
95
+ headers: {
96
+ 'ConsistencyLevel': 'eventual'
97
+ }
98
+ });
99
+ });
100
+ // send batch request
101
+ const res = await request.post(requestOptions);
102
+ for (const response of res.responses) {
103
+ if (response.status === 200) {
104
+ if (response.body === 1) {
105
+ // user can be removed from current role
106
+ userIdsToRemove.push(response.id);
107
+ }
108
+ }
109
+ else {
110
+ throw response.body;
111
+ }
112
+ }
113
+ }
114
+ for (let i = 0; i < userIdsToRemove.length; i += 20) {
115
+ const userIdsBatch = userIds.slice(i, i + 20);
116
+ const requestOptions = this.getRequestOptions();
117
+ userIdsBatch.map(userId => {
118
+ requestOptions.data.requests.push({
119
+ id: userId,
120
+ method: 'DELETE',
121
+ url: `/groups/${groupId}/${currentRole}/${userId}/$ref`
122
+ });
123
+ });
124
+ const res = await request.post(requestOptions);
125
+ for (const response of res.responses) {
126
+ if (response.status !== 204) {
127
+ throw response.body;
128
+ }
129
+ }
130
+ }
131
+ }
132
+ async addUsers(groupId, userIds, role) {
133
+ for (let i = 0; i < userIds.length; i += 400) {
134
+ const userIdsBatch = userIds.slice(i, i + 400);
135
+ const requestOptions = this.getRequestOptions();
136
+ for (let j = 0; j < userIdsBatch.length; j += 20) {
137
+ const userIdsChunk = userIdsBatch.slice(j, j + 20);
138
+ requestOptions.data.requests.push({
139
+ id: j + 1,
140
+ method: 'PATCH',
141
+ url: `/groups/${groupId}`,
142
+ headers: {
143
+ 'content-type': 'application/json;odata.metadata=none'
144
+ },
145
+ body: {
146
+ [`${role.toLowerCase() === 'member' ? 'members' : 'owners'}@odata.bind`]: userIdsChunk.map(u => `${this.resource}/v1.0/directoryObjects/${u}`)
147
+ }
148
+ });
149
+ }
150
+ const res = await request.post(requestOptions);
151
+ for (const response of res.responses) {
152
+ if (response.status !== 204) {
153
+ throw response.body;
154
+ }
155
+ }
118
156
  }
119
- const endpoint = `${this.resource}/v1.0/groups/${groupId}/members?$select=id,displayName,userPrincipalName,userType`;
120
- return await odata.getAllItems(endpoint);
157
+ }
158
+ getRequestOptions() {
159
+ const requestOptions = {
160
+ url: `${this.resource}/v1.0/$batch`,
161
+ headers: {
162
+ 'content-type': 'application/json;odata.metadata=none'
163
+ },
164
+ responseType: 'json',
165
+ data: {
166
+ requests: []
167
+ }
168
+ };
169
+ return requestOptions;
121
170
  }
122
171
  }
123
172
  _EntraM365GroupUserSetCommand_instances = new WeakSet(), _EntraM365GroupUserSetCommand_initTelemetry = function _EntraM365GroupUserSetCommand_initTelemetry() {
124
173
  this.telemetry.push((args) => {
125
174
  Object.assign(this.telemetryProperties, {
126
175
  teamId: typeof args.options.teamId !== 'undefined',
176
+ teamName: typeof args.options.teamName !== 'undefined',
127
177
  groupId: typeof args.options.groupId !== 'undefined',
128
- role: args.options.role
178
+ groupName: typeof args.options.groupName !== 'undefined',
179
+ ids: typeof args.options.ids !== 'undefined',
180
+ userNames: typeof args.options.userNames !== 'undefined'
129
181
  });
130
182
  });
131
183
  }, _EntraM365GroupUserSetCommand_initOptions = function _EntraM365GroupUserSetCommand_initOptions() {
132
184
  this.options.unshift({
133
- option: "-i, --groupId [groupId]"
185
+ option: '-n, --userName [userName]'
186
+ }, {
187
+ option: '--ids [ids]'
188
+ }, {
189
+ option: '--userNames [userNames]'
190
+ }, {
191
+ option: '-i, --groupId [groupId]'
134
192
  }, {
135
- option: "--teamId [teamId]"
193
+ option: '--groupName [groupName]'
136
194
  }, {
137
- option: '-n, --userName <userName>'
195
+ option: '--teamId [teamId]'
196
+ }, {
197
+ option: '--teamName [teamName]'
138
198
  }, {
139
199
  option: '-r, --role <role>',
140
- autocomplete: ['Owner', 'Member']
200
+ autocomplete: this.allowedRoles
141
201
  });
142
202
  }, _EntraM365GroupUserSetCommand_initValidators = function _EntraM365GroupUserSetCommand_initValidators() {
143
203
  this.validators.push(async (args) => {
144
204
  if (args.options.teamId && !validation.isValidGuid(args.options.teamId)) {
145
- return `${args.options.teamId} is not a valid GUID`;
205
+ return `'${args.options.teamId}' is not a valid GUID for option 'teamId'.`;
146
206
  }
147
207
  if (args.options.groupId && !validation.isValidGuid(args.options.groupId)) {
148
- return `${args.options.groupId} is not a valid GUID`;
208
+ return `'${args.options.groupId}' is not a valid GUID for option 'groupId'.`;
209
+ }
210
+ if (args.options.ids) {
211
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.ids);
212
+ if (isValidGUIDArrayResult !== true) {
213
+ return `The following GUIDs are invalid for the option 'ids': ${isValidGUIDArrayResult}.`;
214
+ }
215
+ }
216
+ if (args.options.userNames) {
217
+ const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.userNames);
218
+ if (isValidUPNArrayResult !== true) {
219
+ return `The following user principal names are invalid for the option 'userNames': ${isValidUPNArrayResult}.`;
220
+ }
149
221
  }
150
- if (['Owner', 'Member'].indexOf(args.options.role) === -1) {
151
- return `${args.options.role} is not a valid role value. Allowed values Owner|Member`;
222
+ if (args.options.role && !this.allowedRoles.some(role => role.toLowerCase() === args.options.role.toLowerCase())) {
223
+ return `'${args.options.role}' is not a valid role. Allowed values are: ${this.allowedRoles.join(',')}`;
152
224
  }
153
225
  return true;
154
226
  });
155
227
  }, _EntraM365GroupUserSetCommand_initOptionSets = function _EntraM365GroupUserSetCommand_initOptionSets() {
156
- this.optionSets.push({ options: ['groupId', 'teamId'] });
228
+ this.optionSets.push({ options: ['groupId', 'groupName', 'teamId', 'teamName'] });
229
+ this.optionSets.push({ options: ['userName', 'ids', 'userNames'] });
230
+ }, _EntraM365GroupUserSetCommand_initTypes = function _EntraM365GroupUserSetCommand_initTypes() {
231
+ this.types.string.push('userName', 'ids', 'userNames', 'groupId', 'groupName', 'teamId', 'teamName', 'role');
157
232
  };
158
233
  export default new EntraM365GroupUserSetCommand();
159
234
  //# sourceMappingURL=m365group-user-set.js.map
@@ -0,0 +1,65 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ 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");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _EntraMultitenantAddCommand_instances, _EntraMultitenantAddCommand_initTelemetry, _EntraMultitenantAddCommand_initOptions, _EntraMultitenantAddCommand_initTypes;
7
+ import request from '../../../../request.js';
8
+ import GraphCommand from '../../../base/GraphCommand.js';
9
+ import commands from '../../commands.js';
10
+ class EntraMultitenantAddCommand extends GraphCommand {
11
+ get name() {
12
+ return commands.MULTITENANT_ADD;
13
+ }
14
+ get description() {
15
+ return 'Creates a new multitenant organization';
16
+ }
17
+ constructor() {
18
+ super();
19
+ _EntraMultitenantAddCommand_instances.add(this);
20
+ __classPrivateFieldGet(this, _EntraMultitenantAddCommand_instances, "m", _EntraMultitenantAddCommand_initTelemetry).call(this);
21
+ __classPrivateFieldGet(this, _EntraMultitenantAddCommand_instances, "m", _EntraMultitenantAddCommand_initOptions).call(this);
22
+ __classPrivateFieldGet(this, _EntraMultitenantAddCommand_instances, "m", _EntraMultitenantAddCommand_initTypes).call(this);
23
+ }
24
+ async commandAction(logger, args) {
25
+ if (this.verbose) {
26
+ await logger.logToStderr('Creating multitenant organization...');
27
+ }
28
+ const requestOptions = {
29
+ url: `${this.resource}/v1.0/tenantRelationships/multiTenantOrganization`,
30
+ headers: {
31
+ accept: 'application/json;odata.metadata=none'
32
+ },
33
+ responseType: 'json',
34
+ data: {
35
+ description: args.options.description,
36
+ displayName: args.options.displayName
37
+ }
38
+ };
39
+ try {
40
+ const multitenantOrg = await request.put(requestOptions);
41
+ await logger.log(multitenantOrg);
42
+ }
43
+ catch (err) {
44
+ this.handleRejectedODataJsonPromise(err);
45
+ }
46
+ }
47
+ }
48
+ _EntraMultitenantAddCommand_instances = new WeakSet(), _EntraMultitenantAddCommand_initTelemetry = function _EntraMultitenantAddCommand_initTelemetry() {
49
+ this.telemetry.push((args) => {
50
+ Object.assign(this.telemetryProperties, {
51
+ displayName: typeof args.options.displayName !== 'undefined',
52
+ description: typeof args.options.description !== 'undefined'
53
+ });
54
+ });
55
+ }, _EntraMultitenantAddCommand_initOptions = function _EntraMultitenantAddCommand_initOptions() {
56
+ this.options.unshift({
57
+ option: '-n, --displayName <displayName>'
58
+ }, {
59
+ option: '-d, --description [description]'
60
+ });
61
+ }, _EntraMultitenantAddCommand_initTypes = function _EntraMultitenantAddCommand_initTypes() {
62
+ this.types.string.push('displayName', 'description');
63
+ };
64
+ export default new EntraMultitenantAddCommand();
65
+ //# sourceMappingURL=multitenant-add.js.map
@@ -0,0 +1,118 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ 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");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _EntraMultitenantRemoveCommand_instances, _EntraMultitenantRemoveCommand_initTelemetry, _EntraMultitenantRemoveCommand_initOptions;
7
+ import request from '../../../../request.js';
8
+ import GraphCommand from '../../../base/GraphCommand.js';
9
+ import commands from '../../commands.js';
10
+ import { odata } from '../../../../utils/odata.js';
11
+ import { cli } from '../../../../cli/cli.js';
12
+ class EntraMultitenantRemoveCommand extends GraphCommand {
13
+ get name() {
14
+ return commands.MULTITENANT_REMOVE;
15
+ }
16
+ get description() {
17
+ return 'Removes a multitenant organization';
18
+ }
19
+ constructor() {
20
+ super();
21
+ _EntraMultitenantRemoveCommand_instances.add(this);
22
+ __classPrivateFieldGet(this, _EntraMultitenantRemoveCommand_instances, "m", _EntraMultitenantRemoveCommand_initTelemetry).call(this);
23
+ __classPrivateFieldGet(this, _EntraMultitenantRemoveCommand_instances, "m", _EntraMultitenantRemoveCommand_initOptions).call(this);
24
+ }
25
+ async commandAction(logger, args) {
26
+ const removeMultitenantOrg = async () => {
27
+ try {
28
+ const tenantId = await this.getCurrentTenantId();
29
+ let tenantsId = await this.getAllTenantsIds();
30
+ const tenantsCount = tenantsId.length;
31
+ if (tenantsCount > 0) {
32
+ const tasks = tenantsId
33
+ .filter(x => x !== tenantId)
34
+ .map(t => this.removeTenant(logger, t));
35
+ await Promise.all(tasks);
36
+ do {
37
+ if (this.verbose) {
38
+ await logger.logToStderr(`Waiting 30 seconds...`);
39
+ }
40
+ await new Promise(resolve => setTimeout(resolve, 30000));
41
+ // from current behavior, removing tenant can take a few seconds
42
+ // current tenant must be removed once all previous ones were removed
43
+ if (this.verbose) {
44
+ await logger.logToStderr(`Checking all tenants were removed...`);
45
+ }
46
+ tenantsId = await this.getAllTenantsIds();
47
+ if (this.verbose) {
48
+ await logger.logToStderr(`Number of removed tenants: ${tenantsCount - tenantsId.length}`);
49
+ }
50
+ } while (tenantsId.length !== 1);
51
+ // current tenant must be removed as the last one
52
+ await this.removeTenant(logger, tenantId);
53
+ await logger.logToStderr('Your Multi-Tenant organization is being removed. This can take up to 2 hours.');
54
+ }
55
+ }
56
+ catch (err) {
57
+ this.handleRejectedODataJsonPromise(err);
58
+ }
59
+ };
60
+ if (args.options.force) {
61
+ await removeMultitenantOrg();
62
+ }
63
+ else {
64
+ const result = await cli.promptForConfirmation({ message: 'Are you sure you want to remove multitenant organization?' });
65
+ if (result) {
66
+ await removeMultitenantOrg();
67
+ }
68
+ }
69
+ }
70
+ async getAllTenantsIds() {
71
+ const requestOptions = {
72
+ url: `${this.resource}/v1.0/tenantRelationships/multiTenantOrganization/tenants?$select=tenantId`,
73
+ headers: {
74
+ accept: 'application/json;odata.metadata=none'
75
+ },
76
+ responseType: 'json'
77
+ };
78
+ const tenants = await odata.getAllItems(requestOptions);
79
+ return tenants.map(x => x.tenantId);
80
+ }
81
+ async getCurrentTenantId() {
82
+ const requestOptions = {
83
+ url: `${this.resource}/v1.0/organization?$select=id`,
84
+ headers: {
85
+ accept: 'application/json;odata.metadata=none'
86
+ },
87
+ responseType: 'json'
88
+ };
89
+ const organizations = await odata.getAllItems(requestOptions);
90
+ return organizations[0].id;
91
+ }
92
+ async removeTenant(logger, tenantId) {
93
+ if (this.verbose) {
94
+ await logger.logToStderr(`Removing tenant: ${tenantId}`);
95
+ }
96
+ const requestOptions = {
97
+ url: `${this.resource}/v1.0/tenantRelationships/multiTenantOrganization/tenants/${tenantId}`,
98
+ headers: {
99
+ accept: 'application/json;odata.metadata=none'
100
+ },
101
+ responseType: 'json'
102
+ };
103
+ await request.delete(requestOptions);
104
+ }
105
+ }
106
+ _EntraMultitenantRemoveCommand_instances = new WeakSet(), _EntraMultitenantRemoveCommand_initTelemetry = function _EntraMultitenantRemoveCommand_initTelemetry() {
107
+ this.telemetry.push((args) => {
108
+ Object.assign(this.telemetryProperties, {
109
+ force: !!args.options.force
110
+ });
111
+ });
112
+ }, _EntraMultitenantRemoveCommand_initOptions = function _EntraMultitenantRemoveCommand_initOptions() {
113
+ this.options.unshift({
114
+ option: '-f, --force'
115
+ });
116
+ };
117
+ export default new EntraMultitenantRemoveCommand();
118
+ //# sourceMappingURL=multitenant-remove.js.map
@@ -0,0 +1,72 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ 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");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _EntraMultitenantSetCommand_instances, _EntraMultitenantSetCommand_initTelemetry, _EntraMultitenantSetCommand_initOptions, _EntraMultitenantSetCommand_initValidators, _EntraMultitenantSetCommand_initTypes;
7
+ import request from '../../../../request.js';
8
+ import GraphCommand from '../../../base/GraphCommand.js';
9
+ import commands from '../../commands.js';
10
+ class EntraMultitenantSetCommand extends GraphCommand {
11
+ get name() {
12
+ return commands.MULTITENANT_SET;
13
+ }
14
+ get description() {
15
+ return 'Updates the properties of a multitenant organization';
16
+ }
17
+ constructor() {
18
+ super();
19
+ _EntraMultitenantSetCommand_instances.add(this);
20
+ __classPrivateFieldGet(this, _EntraMultitenantSetCommand_instances, "m", _EntraMultitenantSetCommand_initTelemetry).call(this);
21
+ __classPrivateFieldGet(this, _EntraMultitenantSetCommand_instances, "m", _EntraMultitenantSetCommand_initOptions).call(this);
22
+ __classPrivateFieldGet(this, _EntraMultitenantSetCommand_instances, "m", _EntraMultitenantSetCommand_initValidators).call(this);
23
+ __classPrivateFieldGet(this, _EntraMultitenantSetCommand_instances, "m", _EntraMultitenantSetCommand_initTypes).call(this);
24
+ }
25
+ async commandAction(logger, args) {
26
+ if (this.verbose) {
27
+ await logger.logToStderr('Updating multitenant organization...');
28
+ }
29
+ const requestOptions = {
30
+ url: `${this.resource}/v1.0/tenantRelationships/multiTenantOrganization`,
31
+ headers: {
32
+ accept: 'application/json;odata.metadata=none'
33
+ },
34
+ responseType: 'json',
35
+ data: {
36
+ description: args.options.description,
37
+ displayName: args.options.displayName
38
+ }
39
+ };
40
+ try {
41
+ await request.patch(requestOptions);
42
+ }
43
+ catch (err) {
44
+ this.handleRejectedODataJsonPromise(err);
45
+ }
46
+ }
47
+ }
48
+ _EntraMultitenantSetCommand_instances = new WeakSet(), _EntraMultitenantSetCommand_initTelemetry = function _EntraMultitenantSetCommand_initTelemetry() {
49
+ this.telemetry.push((args) => {
50
+ Object.assign(this.telemetryProperties, {
51
+ displayName: typeof args.options.displayName !== 'undefined',
52
+ description: typeof args.options.description !== 'undefined'
53
+ });
54
+ });
55
+ }, _EntraMultitenantSetCommand_initOptions = function _EntraMultitenantSetCommand_initOptions() {
56
+ this.options.unshift({
57
+ option: '-n, --displayName [displayName]'
58
+ }, {
59
+ option: '-d, --description [description]'
60
+ });
61
+ }, _EntraMultitenantSetCommand_initValidators = function _EntraMultitenantSetCommand_initValidators() {
62
+ this.validators.push(async (args) => {
63
+ if (!args.options.displayName && !args.options.description) {
64
+ return 'Specify either displayName or description or both.';
65
+ }
66
+ return true;
67
+ });
68
+ }, _EntraMultitenantSetCommand_initTypes = function _EntraMultitenantSetCommand_initTypes() {
69
+ this.types.string.push('displayName', 'description');
70
+ };
71
+ export default new EntraMultitenantSetCommand();
72
+ //# sourceMappingURL=multitenant-set.js.map
@@ -35,10 +35,12 @@ export default {
35
35
  ENTERPRISEAPP_ADD: `${prefix} enterpriseapp add`,
36
36
  ENTERPRISEAPP_GET: `${prefix} enterpriseapp get`,
37
37
  ENTERPRISEAPP_LIST: `${prefix} enterpriseapp list`,
38
+ ENTERPRISEAPP_REMOVE: `${prefix} enterpriseapp remove`,
38
39
  GROUP_ADD: `${prefix} group add`,
39
40
  GROUP_GET: `${prefix} group get`,
40
41
  GROUP_LIST: `${prefix} group list`,
41
42
  GROUP_REMOVE: `${prefix} group remove`,
43
+ GROUP_SET: `${prefix} group set`,
42
44
  GROUP_USER_ADD: `${prefix} group user add`,
43
45
  GROUP_USER_LIST: `${prefix} group user list`,
44
46
  GROUP_USER_SET: `${prefix} group user set`,
@@ -72,7 +74,10 @@ export default {
72
74
  M365GROUP_USER_LIST: `${prefix} m365group user list`,
73
75
  M365GROUP_USER_REMOVE: `${prefix} m365group user remove`,
74
76
  M365GROUP_USER_SET: `${prefix} m365group user set`,
77
+ MULTITENANT_ADD: `${prefix} multitenant add`,
75
78
  MULTITENANT_GET: `${prefix} multitenant get`,
79
+ MULTITENANT_REMOVE: `${prefix} multitenant remove`,
80
+ MULTITENANT_SET: `${prefix} multitenant set`,
76
81
  OAUTH2GRANT_ADD: `${prefix} oauth2grant add`,
77
82
  OAUTH2GRANT_LIST: `${prefix} oauth2grant list`,
78
83
  OAUTH2GRANT_REMOVE: `${prefix} oauth2grant remove`,
@@ -89,6 +94,7 @@ export default {
89
94
  SP_ADD: `${prefix} sp add`,
90
95
  SP_GET: `${prefix} sp get`,
91
96
  SP_LIST: `${prefix} sp list`,
97
+ SP_REMOVE: `${prefix} sp remove`,
92
98
  USER_ADD: `${prefix} user add`,
93
99
  USER_GET: `${prefix} user get`,
94
100
  USER_GUEST_ADD: `${prefix} user guest add`,
@@ -29,7 +29,7 @@ class FlowGetCommand extends PowerAutomateCommand {
29
29
  await logger.logToStderr(`Retrieving information about Microsoft Flow ${args.options.name}...`);
30
30
  }
31
31
  const requestOptions = {
32
- url: `${this.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.name)}?api-version=2016-11-01`,
32
+ url: `${this.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.name)}?api-version=2016-11-01&$expand=swagger,properties.connectionreferences.apidefinition,properties.definitionsummary.operations.apioperation,operationDefinition,plan,properties.throttleData,properties.estimatedsuspensiondata,properties.licenseData`,
33
33
  headers: {
34
34
  accept: 'application/json'
35
35
  },