@pnp/cli-microsoft365 7.9.0-beta.d3d4146 → 7.10.0-beta.0d80e6e

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 (42) hide show
  1. package/.eslintrc.cjs +2 -0
  2. package/allCommands.json +1 -1
  3. package/allCommandsFull.json +1 -1
  4. package/dist/m365/base/DelegatedGraphCommand.js +17 -0
  5. package/dist/m365/base/PowerAppsCommand.js +2 -0
  6. package/dist/m365/base/PowerAutomateCommand.js +2 -0
  7. package/dist/m365/base/PowerBICommand.js +10 -0
  8. package/dist/m365/base/PowerPlatformCommand.js +2 -0
  9. package/dist/m365/base/VivaEngageCommand.js +10 -0
  10. package/dist/m365/commands/commands.js +1 -0
  11. package/dist/m365/commands/search.js +176 -0
  12. package/dist/m365/entra/commands/group/group-user-set.js +206 -0
  13. package/dist/m365/entra/commands/user/user-groupmembership-list.js +92 -0
  14. package/dist/m365/entra/commands/user/user-list.js +47 -44
  15. package/dist/m365/entra/commands.js +2 -0
  16. package/dist/m365/outlook/commands/message/message-move.js +2 -2
  17. package/dist/m365/spfx/commands/spfx-doctor.js +2 -2
  18. package/dist/m365/spo/commands/tenant/tenant-recyclebinitem-restore.js +44 -23
  19. package/dist/m365/teams/commands/chat/chat-message-send.js +2 -2
  20. package/dist/m365/todo/commands/list/list-add.js +2 -2
  21. package/dist/m365/todo/commands/list/list-get.js +2 -2
  22. package/dist/m365/todo/commands/list/list-list.js +2 -2
  23. package/dist/m365/todo/commands/list/list-remove.js +2 -2
  24. package/dist/m365/todo/commands/list/list-set.js +2 -2
  25. package/dist/m365/todo/commands/task/task-add.js +2 -2
  26. package/dist/m365/todo/commands/task/task-get.js +2 -2
  27. package/dist/m365/todo/commands/task/task-list.js +2 -2
  28. package/dist/m365/todo/commands/task/task-remove.js +2 -2
  29. package/dist/m365/todo/commands/task/task-set.js +2 -2
  30. package/dist/m365/viva/commands/engage/engage-community-get.js +49 -0
  31. package/dist/m365/viva/commands.js +1 -0
  32. package/dist/utils/accessToken.js +16 -0
  33. package/dist/utils/validation.js +3 -3
  34. package/docs/docs/cmd/entra/group/group-user-set.mdx +62 -0
  35. package/docs/docs/cmd/entra/user/user-groupmembership-list.mdx +121 -0
  36. package/docs/docs/cmd/entra/user/user-list.mdx +24 -9
  37. package/docs/docs/cmd/search.mdx +260 -0
  38. package/docs/docs/cmd/spe/containertype/containertype-add.mdx +3 -3
  39. package/docs/docs/cmd/spo/tenant/tenant-recyclebinitem-restore.mdx +3 -11
  40. package/docs/docs/cmd/viva/engage/engage-community-get.mdx +94 -0
  41. package/npm-shrinkwrap.json +15 -7
  42. package/package.json +7 -2
@@ -0,0 +1,17 @@
1
+ import auth from '../../Auth.js';
2
+ import { accessToken } from '../../utils/accessToken.js';
3
+ import GraphCommand from './GraphCommand.js';
4
+ /**
5
+ * This command class is for delegated-only Graph commands.
6
+ */
7
+ export default class DelegatedGraphCommand extends GraphCommand {
8
+ initAction(args, logger) {
9
+ super.initAction(args, logger);
10
+ if (!auth.connection.active) {
11
+ // we fail no login in the base command command class
12
+ return;
13
+ }
14
+ accessToken.assertDelegatedAccessToken();
15
+ }
16
+ }
17
+ //# sourceMappingURL=DelegatedGraphCommand.js.map
@@ -1,5 +1,6 @@
1
1
  import auth, { CloudType } from '../../Auth.js';
2
2
  import Command, { CommandError } from '../../Command.js';
3
+ import { accessToken } from '../../utils/accessToken.js';
3
4
  export default class PowerAppsCommand extends Command {
4
5
  get resource() {
5
6
  return 'https://api.powerapps.com';
@@ -13,6 +14,7 @@ export default class PowerAppsCommand extends Command {
13
14
  if (auth.connection.cloudType !== CloudType.Public) {
14
15
  throw new CommandError(`Power Apps commands only support the public cloud at the moment. We'll add support for other clouds in the future. Sorry for the inconvenience.`);
15
16
  }
17
+ accessToken.assertDelegatedAccessToken();
16
18
  }
17
19
  }
18
20
  //# sourceMappingURL=PowerAppsCommand.js.map
@@ -1,5 +1,6 @@
1
1
  import auth, { CloudType } from '../../Auth.js';
2
2
  import Command, { CommandError } from '../../Command.js';
3
+ import { accessToken } from '../../utils/accessToken.js';
3
4
  export default class PowerAutomateCommand extends Command {
4
5
  get resource() {
5
6
  return 'https://api.flow.microsoft.com';
@@ -13,6 +14,7 @@ export default class PowerAutomateCommand extends Command {
13
14
  if (auth.connection.cloudType !== CloudType.Public) {
14
15
  throw new CommandError(`Power Automate commands only support the public cloud at the moment. We'll add support for other clouds in the future. Sorry for the inconvenience.`);
15
16
  }
17
+ accessToken.assertDelegatedAccessToken();
16
18
  }
17
19
  }
18
20
  //# sourceMappingURL=PowerAutomateCommand.js.map
@@ -1,7 +1,17 @@
1
1
  import Command from '../../Command.js';
2
+ import auth from '../../Auth.js';
3
+ import { accessToken } from '../../utils/accessToken.js';
2
4
  export default class PowerBICommand extends Command {
3
5
  get resource() {
4
6
  return 'https://api.powerbi.com';
5
7
  }
8
+ initAction(args, logger) {
9
+ super.initAction(args, logger);
10
+ if (!auth.connection.active) {
11
+ // we fail no login in the base command command class
12
+ return;
13
+ }
14
+ accessToken.assertDelegatedAccessToken();
15
+ }
6
16
  }
7
17
  //# sourceMappingURL=PowerBICommand.js.map
@@ -1,5 +1,6 @@
1
1
  import auth, { CloudType } from '../../Auth.js';
2
2
  import Command, { CommandError } from '../../Command.js';
3
+ import { accessToken } from '../../utils/accessToken.js';
3
4
  export default class PowerPlatformCommand extends Command {
4
5
  get resource() {
5
6
  return 'https://api.bap.microsoft.com';
@@ -13,6 +14,7 @@ export default class PowerPlatformCommand extends Command {
13
14
  if (auth.connection.cloudType !== CloudType.Public) {
14
15
  throw new CommandError(`Power Platform commands only support the public cloud at the moment. We'll add support for other clouds in the future. Sorry for the inconvenience.`);
15
16
  }
17
+ accessToken.assertDelegatedAccessToken();
16
18
  }
17
19
  }
18
20
  //# sourceMappingURL=PowerPlatformCommand.js.map
@@ -1,8 +1,18 @@
1
1
  import Command, { CommandError } from "../../Command.js";
2
+ import auth from "../../Auth.js";
3
+ import { accessToken } from "../../utils/accessToken.js";
2
4
  export default class VivaEngageCommand extends Command {
3
5
  get resource() {
4
6
  return 'https://www.yammer.com/api';
5
7
  }
8
+ initAction(args, logger) {
9
+ super.initAction(args, logger);
10
+ if (!auth.connection.active) {
11
+ // we fail no login in the base command command class
12
+ return;
13
+ }
14
+ accessToken.assertDelegatedAccessToken();
15
+ }
6
16
  handleRejectedODataJsonPromise(response) {
7
17
  if (response.statusCode === 404) {
8
18
  throw new CommandError("Not found (404)");
@@ -3,6 +3,7 @@ export default {
3
3
  LOGIN: `login`,
4
4
  LOGOUT: `logout`,
5
5
  REQUEST: `request`,
6
+ SEARCH: `search`,
6
7
  SETUP: `setup`,
7
8
  STATUS: `status`,
8
9
  VERSION: 'version'
@@ -0,0 +1,176 @@
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 _SearchCommand_instances, _SearchCommand_initTelemetry, _SearchCommand_initOptions, _SearchCommand_initValidators;
7
+ import request from '../../request.js';
8
+ import GraphCommand from '../base/GraphCommand.js';
9
+ import commands from './commands.js';
10
+ class SearchCommand extends GraphCommand {
11
+ get name() {
12
+ return commands.SEARCH;
13
+ }
14
+ get description() {
15
+ return 'Uses the Microsoft Search to query Microsoft 365 data';
16
+ }
17
+ constructor() {
18
+ super();
19
+ _SearchCommand_instances.add(this);
20
+ this.allowedScopes = ['chatMessage', 'message', 'event', 'drive', 'driveItem', 'list', 'listItem', 'site', 'bookmark', 'acronym', 'person'];
21
+ __classPrivateFieldGet(this, _SearchCommand_instances, "m", _SearchCommand_initTelemetry).call(this);
22
+ __classPrivateFieldGet(this, _SearchCommand_instances, "m", _SearchCommand_initOptions).call(this);
23
+ __classPrivateFieldGet(this, _SearchCommand_instances, "m", _SearchCommand_initValidators).call(this);
24
+ }
25
+ async commandAction(logger, args) {
26
+ let result;
27
+ const searchHits = [];
28
+ try {
29
+ let allResults = args.options.allResults ? args.options.allResults : false;
30
+ let startIndex = args.options.startIndex ? args.options.startIndex : 0;
31
+ const pageSize = args.options.pageSize ? args.options.pageSize : 25;
32
+ do {
33
+ const requestOptions = {
34
+ url: `${this.resource}/v1.0/search/query`,
35
+ headers: {
36
+ accept: 'application/json;odata.metadata=none'
37
+ },
38
+ responseType: 'json',
39
+ data: {
40
+ requests: [
41
+ {
42
+ "entityTypes": args.options.scopes.split(',').map(scope => scope.trim()),
43
+ "query": {
44
+ "queryString": args.options.queryText ?? '*'
45
+ },
46
+ "enableTopResults": args.options.enableTopResults,
47
+ "from": startIndex,
48
+ "size": pageSize,
49
+ "fields": this.getProperties(args.options),
50
+ "sortProperties": this.getSortProperties(args.options),
51
+ "queryAlterationOptions": {
52
+ "enableModification": args.options.enableSpellingModification,
53
+ "enableSuggestion": args.options.enableSpellingSuggestion
54
+ }
55
+ }
56
+ ]
57
+ }
58
+ };
59
+ const response = await request.post(requestOptions);
60
+ result = response.value[0];
61
+ if (allResults && result.hitsContainers) {
62
+ allResults = result.hitsContainers[0].moreResultsAvailable;
63
+ }
64
+ if (allResults) {
65
+ startIndex += pageSize;
66
+ }
67
+ if (result.hitsContainers && result.hitsContainers[0].hits) {
68
+ searchHits.push(...result.hitsContainers[0].hits);
69
+ }
70
+ } while (allResults);
71
+ if (args.options.resultsOnly) {
72
+ await logger.log(searchHits);
73
+ }
74
+ else {
75
+ if (result.hitsContainers && result.hitsContainers[0].hits) {
76
+ result.hitsContainers[0].hits = searchHits;
77
+ }
78
+ await logger.log(result);
79
+ }
80
+ }
81
+ catch (err) {
82
+ this.handleRejectedODataJsonPromise(err);
83
+ }
84
+ }
85
+ getProperties(options) {
86
+ if (!options.select) {
87
+ return undefined;
88
+ }
89
+ return options.select.split(',').map(prop => prop.trim());
90
+ }
91
+ getSortProperties(options) {
92
+ if (!options.sortBy) {
93
+ return undefined;
94
+ }
95
+ const properties = options.sortBy.split(',').map(prop => prop.trim()).map(property => {
96
+ const sortDefinitions = property.split(':');
97
+ const name = sortDefinitions[0];
98
+ let isDescending = false;
99
+ if (sortDefinitions.length === 2) {
100
+ const order = sortDefinitions[1].trim();
101
+ isDescending = order === 'desc';
102
+ }
103
+ return {
104
+ "name": name,
105
+ "isDescending": isDescending
106
+ };
107
+ });
108
+ return properties;
109
+ }
110
+ }
111
+ _SearchCommand_instances = new WeakSet(), _SearchCommand_initTelemetry = function _SearchCommand_initTelemetry() {
112
+ this.telemetry.push((args) => {
113
+ Object.assign(this.telemetryProperties, {
114
+ queryText: typeof args.options.queryText !== 'undefined',
115
+ startIndex: typeof args.options.startIndex !== 'undefined',
116
+ pageSize: typeof args.options.pageSize !== 'undefined',
117
+ allResults: !!args.options.allResults,
118
+ resultsOnly: !!args.options.resultsOnly,
119
+ enableTopResults: !!args.options.enableTopResults,
120
+ select: typeof args.options.select !== 'undefined',
121
+ sortBy: typeof args.options.sortBy !== 'undefined',
122
+ enableSpellingSuggestion: !!args.options.enableSpellingSuggestion,
123
+ enableSpellingModification: !!args.options.enableSpellingModification
124
+ });
125
+ });
126
+ }, _SearchCommand_initOptions = function _SearchCommand_initOptions() {
127
+ this.options.unshift({
128
+ option: '-q, --queryText [queryText]'
129
+ }, {
130
+ option: '-s, --scopes <scopes>',
131
+ autocomplete: this.allowedScopes
132
+ }, {
133
+ option: '--startIndex [startIndex]'
134
+ }, {
135
+ option: '--pageSize [pageSize]'
136
+ }, {
137
+ option: '--allResults'
138
+ }, {
139
+ option: '--resultsOnly'
140
+ }, {
141
+ option: '--enableTopResults'
142
+ }, {
143
+ option: '--select [select]'
144
+ }, {
145
+ option: '--sortBy [sortBy]'
146
+ }, {
147
+ option: '--enableSpellingSuggestion'
148
+ }, {
149
+ option: '--enableSpellingModification'
150
+ });
151
+ }, _SearchCommand_initValidators = function _SearchCommand_initValidators() {
152
+ this.validators.push(async (args) => {
153
+ const scopes = args.options.scopes.split(',').map(x => x.trim());
154
+ if (!scopes.every(scope => this.allowedScopes.indexOf(scope) > -1)) {
155
+ const invalidScope = scopes.find(scope => this.allowedScopes.indexOf(scope) === -1);
156
+ return `'${invalidScope}'' is not a valid scope. Allowed scopes are ${this.allowedScopes.join(', ')}.`;
157
+ }
158
+ if (args.options.startIndex !== undefined && args.options.startIndex < 0) {
159
+ return `'${args.options.startIndex}' is not a valid value for option 'startIndex'. Start index must be greater or equal to 0.`;
160
+ }
161
+ if (args.options.pageSize !== undefined && (args.options.pageSize < 1 || args.options.pageSize > 500)) {
162
+ return `'${args.options.pageSize}' is not a valid value for option 'pageSize'. Page size must be between 1 and 500.`;
163
+ }
164
+ if (args.options.sortBy && scopes.some(scope => scope === 'message' || scope === 'event')) {
165
+ return 'Sorting the results is not supported for messages and events.';
166
+ }
167
+ if (args.options.enableTopResults &&
168
+ ((scopes.length === 1 && scopes.indexOf('message') === -1 && scopes.indexOf('chatMessage') === -1) ||
169
+ (scopes.length === 2) && !(scopes.indexOf('message') > -1 && scopes.indexOf('chatMessage') > -1))) {
170
+ return 'Top results are only supported for messages and chat messages.';
171
+ }
172
+ return true;
173
+ });
174
+ };
175
+ export default new SearchCommand();
176
+ //# sourceMappingURL=search.js.map
@@ -0,0 +1,206 @@
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 _EntraGroupUserSetCommand_instances, _EntraGroupUserSetCommand_initTelemetry, _EntraGroupUserSetCommand_initOptions, _EntraGroupUserSetCommand_initValidators, _EntraGroupUserSetCommand_initOptionSets, _EntraGroupUserSetCommand_initTypes;
7
+ import request from '../../../../request.js';
8
+ import { entraGroup } from '../../../../utils/entraGroup.js';
9
+ import { entraUser } from '../../../../utils/entraUser.js';
10
+ import { validation } from '../../../../utils/validation.js';
11
+ import GraphCommand from '../../../base/GraphCommand.js';
12
+ import commands from '../../commands.js';
13
+ class EntraGroupUserSetCommand extends GraphCommand {
14
+ get name() {
15
+ return commands.GROUP_USER_SET;
16
+ }
17
+ get description() {
18
+ return 'Updates role of users in a Microsoft Entra ID group';
19
+ }
20
+ constructor() {
21
+ super();
22
+ _EntraGroupUserSetCommand_instances.add(this);
23
+ this.roleValues = ['Owner', 'Member'];
24
+ __classPrivateFieldGet(this, _EntraGroupUserSetCommand_instances, "m", _EntraGroupUserSetCommand_initTelemetry).call(this);
25
+ __classPrivateFieldGet(this, _EntraGroupUserSetCommand_instances, "m", _EntraGroupUserSetCommand_initOptions).call(this);
26
+ __classPrivateFieldGet(this, _EntraGroupUserSetCommand_instances, "m", _EntraGroupUserSetCommand_initValidators).call(this);
27
+ __classPrivateFieldGet(this, _EntraGroupUserSetCommand_instances, "m", _EntraGroupUserSetCommand_initOptionSets).call(this);
28
+ __classPrivateFieldGet(this, _EntraGroupUserSetCommand_instances, "m", _EntraGroupUserSetCommand_initTypes).call(this);
29
+ }
30
+ async commandAction(logger, args) {
31
+ try {
32
+ if (this.verbose) {
33
+ await logger.logToStderr(`Adding user(s) ${args.options.ids || args.options.userNames} to group ${args.options.groupId || args.options.groupDisplayName}...`);
34
+ }
35
+ const groupId = await this.getGroupId(logger, args.options);
36
+ const userIds = await this.getUserIds(logger, args.options);
37
+ // we can't simply switch the role
38
+ // first add users to the new role
39
+ await this.addUsers(groupId, userIds, args.options);
40
+ // remove users from the old role
41
+ await this.removeUsersFromRole(logger, groupId, userIds, args.options);
42
+ }
43
+ catch (err) {
44
+ this.handleRejectedODataJsonPromise(err);
45
+ }
46
+ }
47
+ async getGroupId(logger, options) {
48
+ if (options.groupId) {
49
+ return options.groupId;
50
+ }
51
+ if (this.verbose) {
52
+ await logger.logToStderr(`Retrieving ID of group ${options.groupDisplayName}...`);
53
+ }
54
+ return entraGroup.getGroupIdByDisplayName(options.groupDisplayName);
55
+ }
56
+ async getUserIds(logger, options) {
57
+ if (options.ids) {
58
+ return options.ids.split(',').map(i => i.trim());
59
+ }
60
+ if (this.verbose) {
61
+ await logger.logToStderr('Retrieving ID(s) of user(s)...');
62
+ }
63
+ return entraUser.getUserIdsByUpns(options.userNames.split(',').map(u => u.trim()));
64
+ }
65
+ async removeUsersFromRole(logger, groupId, userIds, options) {
66
+ const userIdsToRemove = [];
67
+ const currentRole = options.role === 'Member' ? 'owners' : 'members';
68
+ if (this.verbose) {
69
+ await logger.logToStderr(`Removing users from the old role '${currentRole}'.`);
70
+ }
71
+ for (let i = 0; i < userIds.length; i += 20) {
72
+ const userIdsBatch = userIds.slice(i, i + 20);
73
+ const requestOptions = this.getRequestOptions();
74
+ userIdsBatch.map(userId => {
75
+ requestOptions.data.requests.push({
76
+ id: userId,
77
+ method: 'GET',
78
+ url: `/groups/${groupId}/${currentRole}/$count?$filter=id eq '${userId}'`,
79
+ headers: {
80
+ 'ConsistencyLevel': 'eventual'
81
+ }
82
+ });
83
+ });
84
+ // send batch request
85
+ const res = await request.post(requestOptions);
86
+ for (const response of res.responses) {
87
+ if (response.status === 200) {
88
+ if (response.body === 1) {
89
+ // user can be removed from current role
90
+ userIdsToRemove.push(response.id);
91
+ }
92
+ }
93
+ else {
94
+ throw response.body;
95
+ }
96
+ }
97
+ }
98
+ for (let i = 0; i < userIdsToRemove.length; i += 20) {
99
+ const userIdsBatch = userIds.slice(i, i + 20);
100
+ const requestOptions = this.getRequestOptions();
101
+ userIdsBatch.map(userId => {
102
+ requestOptions.data.requests.push({
103
+ id: userId,
104
+ method: 'DELETE',
105
+ url: `/groups/${groupId}/${currentRole}/${userId}/$ref`
106
+ });
107
+ });
108
+ const res = await request.post(requestOptions);
109
+ for (const response of res.responses) {
110
+ if (response.status !== 204) {
111
+ throw response.body;
112
+ }
113
+ }
114
+ }
115
+ }
116
+ async addUsers(groupId, userIds, options) {
117
+ for (let i = 0; i < userIds.length; i += 400) {
118
+ const userIdsBatch = userIds.slice(i, i + 400);
119
+ const requestOptions = this.getRequestOptions();
120
+ for (let j = 0; j < userIdsBatch.length; j += 20) {
121
+ const userIdsChunk = userIdsBatch.slice(j, j + 20);
122
+ requestOptions.data.requests.push({
123
+ id: j + 1,
124
+ method: 'PATCH',
125
+ url: `/groups/${groupId}`,
126
+ headers: {
127
+ 'content-type': 'application/json;odata.metadata=none'
128
+ },
129
+ body: {
130
+ [`${options.role === 'Member' ? 'members' : 'owners'}@odata.bind`]: userIdsChunk.map(u => `${this.resource}/v1.0/directoryObjects/${u}`)
131
+ }
132
+ });
133
+ }
134
+ const res = await request.post(requestOptions);
135
+ for (const response of res.responses) {
136
+ if (response.status !== 204) {
137
+ throw response.body;
138
+ }
139
+ }
140
+ }
141
+ }
142
+ getRequestOptions() {
143
+ const requestOptions = {
144
+ url: `${this.resource}/v1.0/$batch`,
145
+ headers: {
146
+ 'content-type': 'application/json;odata.metadata=none'
147
+ },
148
+ responseType: 'json',
149
+ data: {
150
+ requests: []
151
+ }
152
+ };
153
+ return requestOptions;
154
+ }
155
+ }
156
+ _EntraGroupUserSetCommand_instances = new WeakSet(), _EntraGroupUserSetCommand_initTelemetry = function _EntraGroupUserSetCommand_initTelemetry() {
157
+ this.telemetry.push((args) => {
158
+ Object.assign(this.telemetryProperties, {
159
+ groupId: typeof args.options.groupId !== 'undefined',
160
+ groupDisplayName: typeof args.options.groupDisplayName !== 'undefined',
161
+ ids: typeof args.options.ids !== 'undefined',
162
+ userNames: typeof args.options.userNames !== 'undefined'
163
+ });
164
+ });
165
+ }, _EntraGroupUserSetCommand_initOptions = function _EntraGroupUserSetCommand_initOptions() {
166
+ this.options.unshift({
167
+ option: '-i, --groupId [groupId]'
168
+ }, {
169
+ option: '-n, --groupDisplayName [groupDisplayName]'
170
+ }, {
171
+ option: '--ids [ids]'
172
+ }, {
173
+ option: '--userNames [userNames]'
174
+ }, {
175
+ option: '-r, --role <role>',
176
+ autocomplete: this.roleValues
177
+ });
178
+ }, _EntraGroupUserSetCommand_initValidators = function _EntraGroupUserSetCommand_initValidators() {
179
+ this.validators.push(async (args) => {
180
+ if (args.options.groupId && !validation.isValidGuid(args.options.groupId)) {
181
+ return `${args.options.groupId} is not a valid GUID for option groupId.`;
182
+ }
183
+ if (args.options.ids) {
184
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.ids);
185
+ if (isValidGUIDArrayResult !== true) {
186
+ return `'${isValidGUIDArrayResult}' is not a valid GUID for option 'ids'.`;
187
+ }
188
+ }
189
+ if (args.options.userNames) {
190
+ const isValidUserPrincipalNameArray = validation.isValidUserPrincipalNameArray(args.options.userNames);
191
+ if (isValidUserPrincipalNameArray !== true) {
192
+ return `User principal name '${isValidUserPrincipalNameArray}' is invalid for option 'userNames'.`;
193
+ }
194
+ }
195
+ if (this.roleValues.indexOf(args.options.role) === -1) {
196
+ return `Option 'role' must be one of the following values: ${this.roleValues.join(', ')}.`;
197
+ }
198
+ return true;
199
+ });
200
+ }, _EntraGroupUserSetCommand_initOptionSets = function _EntraGroupUserSetCommand_initOptionSets() {
201
+ this.optionSets.push({ options: ['groupId', 'groupDisplayName'] }, { options: ['ids', 'userNames'] });
202
+ }, _EntraGroupUserSetCommand_initTypes = function _EntraGroupUserSetCommand_initTypes() {
203
+ this.types.string.push('groupId', 'groupDisplayName', 'ids', 'userNames', 'role');
204
+ };
205
+ export default new EntraGroupUserSetCommand();
206
+ //# sourceMappingURL=group-user-set.js.map
@@ -0,0 +1,92 @@
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 _EntraUserGroupmembershipListCommand_instances, _EntraUserGroupmembershipListCommand_initTelemetry, _EntraUserGroupmembershipListCommand_initOptions, _EntraUserGroupmembershipListCommand_initValidators, _EntraUserGroupmembershipListCommand_initOptionSets;
7
+ import request from '../../../../request.js';
8
+ import { entraUser } from '../../../../utils/entraUser.js';
9
+ import { validation } from '../../../../utils/validation.js';
10
+ import GraphCommand from '../../../base/GraphCommand.js';
11
+ import commands from '../../commands.js';
12
+ class EntraUserGroupmembershipListCommand extends GraphCommand {
13
+ get name() {
14
+ return commands.USER_GROUPMEMBERSHIP_LIST;
15
+ }
16
+ get description() {
17
+ return 'Retrieves all groups where the user is a member of';
18
+ }
19
+ constructor() {
20
+ super();
21
+ _EntraUserGroupmembershipListCommand_instances.add(this);
22
+ __classPrivateFieldGet(this, _EntraUserGroupmembershipListCommand_instances, "m", _EntraUserGroupmembershipListCommand_initTelemetry).call(this);
23
+ __classPrivateFieldGet(this, _EntraUserGroupmembershipListCommand_instances, "m", _EntraUserGroupmembershipListCommand_initOptions).call(this);
24
+ __classPrivateFieldGet(this, _EntraUserGroupmembershipListCommand_instances, "m", _EntraUserGroupmembershipListCommand_initValidators).call(this);
25
+ __classPrivateFieldGet(this, _EntraUserGroupmembershipListCommand_instances, "m", _EntraUserGroupmembershipListCommand_initOptionSets).call(this);
26
+ }
27
+ async commandAction(logger, args) {
28
+ let userId = args.options.userId;
29
+ try {
30
+ if (args.options.userName) {
31
+ userId = await entraUser.getUserIdByUpn(args.options.userName);
32
+ }
33
+ else if (args.options.userEmail) {
34
+ userId = await entraUser.getUserIdByEmail(args.options.userEmail);
35
+ }
36
+ const requestOptions = {
37
+ url: `${this.resource}/v1.0/users/${userId}/getMemberGroups`,
38
+ headers: {
39
+ accept: 'application/json;odata.metadata=none'
40
+ },
41
+ responseType: 'json',
42
+ data: {
43
+ securityEnabledOnly: !!args.options.securityEnabledOnly
44
+ }
45
+ };
46
+ const groups = [];
47
+ const results = await request.post(requestOptions);
48
+ results.value.forEach(x => groups.push({ groupId: x }));
49
+ await logger.log(groups);
50
+ }
51
+ catch (err) {
52
+ this.handleRejectedODataJsonPromise(err);
53
+ }
54
+ }
55
+ }
56
+ _EntraUserGroupmembershipListCommand_instances = new WeakSet(), _EntraUserGroupmembershipListCommand_initTelemetry = function _EntraUserGroupmembershipListCommand_initTelemetry() {
57
+ this.telemetry.push((args) => {
58
+ Object.assign(this.telemetryProperties, {
59
+ userId: typeof args.options.userId !== 'undefined',
60
+ userName: typeof args.options.userName !== 'undefined',
61
+ userEmail: typeof args.options.userEmail !== 'undefined',
62
+ securityEnabledOnly: !!args.options.securityEnabledOnly
63
+ });
64
+ });
65
+ }, _EntraUserGroupmembershipListCommand_initOptions = function _EntraUserGroupmembershipListCommand_initOptions() {
66
+ this.options.unshift({
67
+ option: '-i, --userId [userId]'
68
+ }, {
69
+ option: '-n, --userName [userName]'
70
+ }, {
71
+ option: '-e, --userEmail [userEmail]'
72
+ }, {
73
+ option: '--securityEnabledOnly [securityEnabledOnly]'
74
+ });
75
+ }, _EntraUserGroupmembershipListCommand_initValidators = function _EntraUserGroupmembershipListCommand_initValidators() {
76
+ this.validators.push(async (args) => {
77
+ if (args.options.userId && !validation.isValidGuid(args.options.userId)) {
78
+ return `${args.options.userId} is not a valid GUID`;
79
+ }
80
+ if (args.options.userName && !validation.isValidUserPrincipalName(args.options.userName)) {
81
+ return `${args.options.userName} is not a valid user principal name`;
82
+ }
83
+ if (args.options.userEmail && !validation.isValidUserPrincipalName(args.options.userEmail)) {
84
+ return `${args.options.userEmail} is not a valid user email`;
85
+ }
86
+ return true;
87
+ });
88
+ }, _EntraUserGroupmembershipListCommand_initOptionSets = function _EntraUserGroupmembershipListCommand_initOptionSets() {
89
+ this.optionSets.push({ options: ['userId', 'userName', 'userEmail'] });
90
+ };
91
+ export default new EntraUserGroupmembershipListCommand();
92
+ //# sourceMappingURL=user-groupmembership-list.js.map