@pnp/cli-microsoft365 7.4.0 → 7.5.0-beta.0ae7da4
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.
- package/.devcontainer/Dockerfile +2 -2
- package/Dockerfile +2 -5
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/m365/app/commands/app-get.js +2 -2
- package/dist/m365/entra/aadCommands.js +1 -0
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-get.js +2 -2
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-member-add.js +8 -8
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-member-get.js +2 -2
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-member-list.js +2 -2
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-remove.js +2 -2
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-roleassignment-add.js +4 -4
- package/dist/m365/entra/commands/app/app-permission-add.js +3 -7
- package/dist/m365/entra/commands/app/app-permission-list.js +182 -0
- package/dist/m365/entra/commands/group/group-add.js +224 -0
- package/dist/m365/entra/commands/group/group-get.js +3 -3
- package/dist/m365/entra/commands/group/group-remove.js +2 -2
- package/dist/m365/entra/commands/group/group-user-add.js +145 -0
- package/dist/m365/entra/commands/group/group-user-list.js +2 -2
- package/dist/m365/entra/commands/m365group/m365group-conversation-list.js +2 -2
- package/dist/m365/entra/commands/m365group/m365group-conversation-post-list.js +3 -3
- package/dist/m365/entra/commands/m365group/m365group-get.js +3 -3
- package/dist/m365/entra/commands/m365group/m365group-remove.js +2 -2
- package/dist/m365/entra/commands/m365group/m365group-renew.js +2 -2
- package/dist/m365/entra/commands/m365group/m365group-set.js +2 -2
- package/dist/m365/entra/commands/m365group/m365group-teamify.js +2 -2
- package/dist/m365/entra/commands/m365group/m365group-user-add.js +2 -2
- package/dist/m365/entra/commands/m365group/m365group-user-list.js +3 -3
- package/dist/m365/entra/commands/m365group/m365group-user-remove.js +2 -2
- package/dist/m365/entra/commands/m365group/m365group-user-set.js +2 -2
- package/dist/m365/entra/commands/user/user-get.js +38 -38
- package/dist/m365/entra/commands.js +3 -0
- package/dist/m365/external/commands/connection/connection-doctor.js +2 -1
- package/dist/m365/file/commands/file-copy.js +151 -0
- package/dist/m365/file/commands.js +1 -0
- package/dist/m365/flow/commands/owner/owner-ensure.js +4 -4
- package/dist/m365/flow/commands/owner/owner-remove.js +4 -4
- package/dist/m365/onenote/commands/notebook/notebook-list.js +2 -2
- package/dist/m365/onenote/commands/page/page-list.js +2 -2
- package/dist/m365/pa/commands/app/app-owner-set.js +2 -2
- package/dist/m365/pa/commands/app/app-permission-ensure.js +4 -4
- package/dist/m365/pa/commands/app/app-permission-remove.js +4 -4
- package/dist/m365/planner/commands/bucket/bucket-add.js +2 -2
- package/dist/m365/planner/commands/bucket/bucket-get.js +2 -2
- package/dist/m365/planner/commands/bucket/bucket-list.js +2 -2
- package/dist/m365/planner/commands/bucket/bucket-remove.js +2 -2
- package/dist/m365/planner/commands/bucket/bucket-set.js +2 -2
- package/dist/m365/planner/commands/plan/plan-add.js +2 -2
- package/dist/m365/planner/commands/plan/plan-get.js +2 -2
- package/dist/m365/planner/commands/plan/plan-list.js +2 -2
- package/dist/m365/planner/commands/plan/plan-remove.js +2 -2
- package/dist/m365/planner/commands/plan/plan-set.js +2 -2
- package/dist/m365/planner/commands/roster/roster-member-add.js +2 -2
- package/dist/m365/planner/commands/roster/roster-member-get.js +2 -2
- package/dist/m365/planner/commands/roster/roster-member-remove.js +2 -2
- package/dist/m365/planner/commands/task/task-add.js +2 -2
- package/dist/m365/planner/commands/task/task-get.js +2 -2
- package/dist/m365/planner/commands/task/task-list.js +2 -2
- package/dist/m365/planner/commands/task/task-remove.js +2 -2
- package/dist/m365/planner/commands/task/task-set.js +2 -2
- package/dist/m365/spfx/commands/project/project-github-workflow-add.js +1 -1
- package/dist/m365/spo/commands/group/group-member-add.js +4 -4
- package/dist/m365/spo/commands/group/group-member-remove.js +2 -2
- package/dist/m365/spo/commands/group/group-set.js +2 -2
- package/dist/m365/spo/commands/site/site-remove.js +2 -2
- package/dist/m365/spo/commands/site/site-set.js +2 -2
- package/dist/m365/spo/commands/user/user-ensure.js +2 -2
- package/dist/m365/teams/commands/app/app-install.js +2 -2
- package/dist/m365/teams/commands/channel/channel-get.js +2 -2
- package/dist/m365/teams/commands/channel/channel-list.js +2 -2
- package/dist/m365/teams/commands/channel/channel-member-add.js +2 -2
- package/dist/m365/teams/commands/channel/channel-member-list.js +2 -2
- package/dist/m365/teams/commands/channel/channel-member-remove.js +2 -2
- package/dist/m365/teams/commands/channel/channel-member-set.js +2 -2
- package/dist/m365/teams/commands/channel/channel-remove.js +2 -2
- package/dist/m365/teams/commands/channel/channel-set.js +2 -2
- package/dist/m365/teams/commands/meeting/meeting-add.js +2 -2
- package/dist/m365/teams/commands/meeting/meeting-attendancereport-list.js +2 -2
- package/dist/m365/teams/commands/meeting/meeting-get.js +3 -3
- package/dist/m365/teams/commands/meeting/meeting-list.js +2 -2
- package/dist/m365/teams/commands/meeting/meeting-transcript-list.js +2 -2
- package/dist/m365/teams/commands/tab/tab-get.js +2 -2
- package/dist/m365/teams/commands/team/team-add.js +6 -6
- package/dist/m365/teams/commands/team/team-archive.js +2 -2
- package/dist/m365/teams/commands/team/team-get.js +2 -2
- package/dist/m365/teams/commands/team/team-remove.js +2 -2
- package/dist/m365/teams/commands/team/team-unarchive.js +2 -2
- package/dist/utils/{aadAdministrativeUnit.js → entraAdministrativeUnit.js} +2 -2
- package/dist/utils/{aadDevice.js → entraDevice.js} +2 -2
- package/dist/utils/{aadGroup.js → entraGroup.js} +2 -2
- package/dist/utils/{aadUser.js → entraUser.js} +38 -2
- package/dist/utils/spo.js +24 -2
- package/dist/utils/urlUtil.js +31 -0
- package/dist/utils/validation.js +8 -0
- package/docs/docs/cmd/entra/app/app-permission-add.mdx +2 -2
- package/docs/docs/cmd/entra/app/app-permission-list.mdx +105 -0
- package/docs/docs/cmd/entra/group/group-add.mdx +231 -0
- package/docs/docs/cmd/entra/group/group-user-add.mdx +62 -0
- package/docs/docs/cmd/file/file-copy.mdx +68 -0
- package/docs/docs/cmd/spo/listitem/listitem-list.mdx +1 -1
- package/npm-shrinkwrap.json +170 -168
- package/package.json +19 -19
|
@@ -0,0 +1,145 @@
|
|
|
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 _EntraGroupUserAddCommand_instances, _EntraGroupUserAddCommand_initTelemetry, _EntraGroupUserAddCommand_initOptions, _EntraGroupUserAddCommand_initValidators, _EntraGroupUserAddCommand_initOptionSets, _EntraGroupUserAddCommand_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 EntraGroupUserAddCommand extends GraphCommand {
|
|
14
|
+
get name() {
|
|
15
|
+
return commands.GROUP_USER_ADD;
|
|
16
|
+
}
|
|
17
|
+
get description() {
|
|
18
|
+
return 'Adds a user to a Microsoft Entra ID group';
|
|
19
|
+
}
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
_EntraGroupUserAddCommand_instances.add(this);
|
|
23
|
+
this.roleValues = ['Owner', 'Member'];
|
|
24
|
+
__classPrivateFieldGet(this, _EntraGroupUserAddCommand_instances, "m", _EntraGroupUserAddCommand_initTelemetry).call(this);
|
|
25
|
+
__classPrivateFieldGet(this, _EntraGroupUserAddCommand_instances, "m", _EntraGroupUserAddCommand_initOptions).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _EntraGroupUserAddCommand_instances, "m", _EntraGroupUserAddCommand_initValidators).call(this);
|
|
27
|
+
__classPrivateFieldGet(this, _EntraGroupUserAddCommand_instances, "m", _EntraGroupUserAddCommand_initOptionSets).call(this);
|
|
28
|
+
__classPrivateFieldGet(this, _EntraGroupUserAddCommand_instances, "m", _EntraGroupUserAddCommand_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
|
+
for (let i = 0; i < userIds.length; i += 400) {
|
|
38
|
+
const userIdsBatch = userIds.slice(i, i + 400);
|
|
39
|
+
const requestOptions = {
|
|
40
|
+
url: `${this.resource}/v1.0/$batch`,
|
|
41
|
+
headers: {
|
|
42
|
+
'content-type': 'application/json;odata.metadata=none'
|
|
43
|
+
},
|
|
44
|
+
responseType: 'json',
|
|
45
|
+
data: {
|
|
46
|
+
requests: []
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
for (let j = 0; j < userIdsBatch.length; j += 20) {
|
|
50
|
+
const userIdsChunk = userIdsBatch.slice(j, j + 20);
|
|
51
|
+
requestOptions.data.requests.push({
|
|
52
|
+
id: j + 1,
|
|
53
|
+
method: 'PATCH',
|
|
54
|
+
url: `/groups/${groupId}`,
|
|
55
|
+
headers: {
|
|
56
|
+
'content-type': 'application/json;odata.metadata=none'
|
|
57
|
+
},
|
|
58
|
+
body: {
|
|
59
|
+
[`${args.options.role === 'Member' ? 'members' : 'owners'}@odata.bind`]: userIdsChunk.map(u => `${this.resource}/v1.0/directoryObjects/${u}`)
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const res = await request.post(requestOptions);
|
|
64
|
+
for (const response of res.responses) {
|
|
65
|
+
if (response.status !== 204) {
|
|
66
|
+
throw response.body;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
this.handleRejectedODataJsonPromise(err);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async getGroupId(logger, options) {
|
|
76
|
+
if (options.groupId) {
|
|
77
|
+
return options.groupId;
|
|
78
|
+
}
|
|
79
|
+
if (this.verbose) {
|
|
80
|
+
await logger.logToStderr(`Retrieving ID of group ${options.groupDisplayName}...`);
|
|
81
|
+
}
|
|
82
|
+
return entraGroup.getGroupIdByDisplayName(options.groupDisplayName);
|
|
83
|
+
}
|
|
84
|
+
async getUserIds(logger, options) {
|
|
85
|
+
if (options.ids) {
|
|
86
|
+
return options.ids.split(',').map(i => i.trim());
|
|
87
|
+
}
|
|
88
|
+
if (this.verbose) {
|
|
89
|
+
await logger.logToStderr('Retrieving ID(s) of user(s)...');
|
|
90
|
+
}
|
|
91
|
+
return entraUser.getUserIdsByUpns(options.userNames.split(',').map(u => u.trim()));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
_EntraGroupUserAddCommand_instances = new WeakSet(), _EntraGroupUserAddCommand_initTelemetry = function _EntraGroupUserAddCommand_initTelemetry() {
|
|
95
|
+
this.telemetry.push((args) => {
|
|
96
|
+
Object.assign(this.telemetryProperties, {
|
|
97
|
+
groupId: typeof args.options.groupId !== 'undefined',
|
|
98
|
+
groupDisplayName: typeof args.options.groupDisplayName !== 'undefined',
|
|
99
|
+
ids: typeof args.options.ids !== 'undefined',
|
|
100
|
+
userNames: typeof args.options.userNames !== 'undefined'
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}, _EntraGroupUserAddCommand_initOptions = function _EntraGroupUserAddCommand_initOptions() {
|
|
104
|
+
this.options.unshift({
|
|
105
|
+
option: '-i, --groupId [groupId]'
|
|
106
|
+
}, {
|
|
107
|
+
option: '-n, --groupDisplayName [groupDisplayName]'
|
|
108
|
+
}, {
|
|
109
|
+
option: '--ids [ids]'
|
|
110
|
+
}, {
|
|
111
|
+
option: '--userNames [userNames]'
|
|
112
|
+
}, {
|
|
113
|
+
option: '-r, --role <role>',
|
|
114
|
+
autocomplete: this.roleValues
|
|
115
|
+
});
|
|
116
|
+
}, _EntraGroupUserAddCommand_initValidators = function _EntraGroupUserAddCommand_initValidators() {
|
|
117
|
+
this.validators.push(async (args) => {
|
|
118
|
+
if (args.options.groupId && !validation.isValidGuid(args.options.groupId)) {
|
|
119
|
+
return `${args.options.groupId} is not a valid GUID for option groupId.`;
|
|
120
|
+
}
|
|
121
|
+
if (args.options.ids) {
|
|
122
|
+
const ids = args.options.ids.split(',').map(i => i.trim());
|
|
123
|
+
if (!validation.isValidGuidArray(ids)) {
|
|
124
|
+
const invalidGuid = ids.find(id => !validation.isValidGuid(id));
|
|
125
|
+
return `'${invalidGuid}' is not a valid GUID for option 'ids'.`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (args.options.userNames) {
|
|
129
|
+
const isValidUserPrincipalNameArray = validation.isValidUserPrincipalNameArray(args.options.userNames.split(',').map(u => u.trim()));
|
|
130
|
+
if (isValidUserPrincipalNameArray !== true) {
|
|
131
|
+
return `User principal name '${isValidUserPrincipalNameArray}' is invalid for option 'userNames'.`;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (this.roleValues.indexOf(args.options.role) === -1) {
|
|
135
|
+
return `Option 'role' must be one of the following values: ${this.roleValues.join(', ')}.`;
|
|
136
|
+
}
|
|
137
|
+
return true;
|
|
138
|
+
});
|
|
139
|
+
}, _EntraGroupUserAddCommand_initOptionSets = function _EntraGroupUserAddCommand_initOptionSets() {
|
|
140
|
+
this.optionSets.push({ options: ['groupId', 'groupDisplayName'] }, { options: ['ids', 'userNames'] });
|
|
141
|
+
}, _EntraGroupUserAddCommand_initTypes = function _EntraGroupUserAddCommand_initTypes() {
|
|
142
|
+
this.types.string.push('groupId', 'groupDisplayName', 'ids', 'userNames', 'role');
|
|
143
|
+
};
|
|
144
|
+
export default new EntraGroupUserAddCommand();
|
|
145
|
+
//# sourceMappingURL=group-user-add.js.map
|
|
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _EntraGroupUserListCommand_instances, _EntraGroupUserListCommand_initTelemetry, _EntraGroupUserListCommand_initOptions, _EntraGroupUserListCommand_initOptionSets, _EntraGroupUserListCommand_initValidators;
|
|
7
|
-
import {
|
|
7
|
+
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
8
8
|
import { odata } from '../../../../utils/odata.js';
|
|
9
9
|
import { validation } from '../../../../utils/validation.js';
|
|
10
10
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
@@ -64,7 +64,7 @@ class EntraGroupUserListCommand extends GraphCommand {
|
|
|
64
64
|
if (this.verbose) {
|
|
65
65
|
await logger.logToStderr('Retrieving Group Id...');
|
|
66
66
|
}
|
|
67
|
-
return await
|
|
67
|
+
return await entraGroup.getGroupIdByDisplayName(options.groupDisplayName);
|
|
68
68
|
}
|
|
69
69
|
async getUsers(options, role, groupId, logger) {
|
|
70
70
|
const { properties, filter } = options;
|
|
@@ -8,7 +8,7 @@ import { odata } from '../../../../utils/odata.js';
|
|
|
8
8
|
import { validation } from '../../../../utils/validation.js';
|
|
9
9
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
10
10
|
import commands from '../../commands.js';
|
|
11
|
-
import {
|
|
11
|
+
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
12
12
|
import aadCommands from '../../aadCommands.js';
|
|
13
13
|
class EntraM365GroupConversationListCommand extends GraphCommand {
|
|
14
14
|
get name() {
|
|
@@ -31,7 +31,7 @@ class EntraM365GroupConversationListCommand extends GraphCommand {
|
|
|
31
31
|
}
|
|
32
32
|
async commandAction(logger, args) {
|
|
33
33
|
try {
|
|
34
|
-
const isUnifiedGroup = await
|
|
34
|
+
const isUnifiedGroup = await entraGroup.isUnifiedGroup(args.options.groupId);
|
|
35
35
|
if (!isUnifiedGroup) {
|
|
36
36
|
throw Error(`Specified group with id '${args.options.groupId}' is not a Microsoft 365 group.`);
|
|
37
37
|
}
|
|
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _EntraM365GroupConversationPostListCommand_instances, _EntraM365GroupConversationPostListCommand_initTelemetry, _EntraM365GroupConversationPostListCommand_initOptions, _EntraM365GroupConversationPostListCommand_initValidators, _EntraM365GroupConversationPostListCommand_initOptionSets;
|
|
7
|
-
import {
|
|
7
|
+
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
8
8
|
import { formatting } from '../../../../utils/formatting.js';
|
|
9
9
|
import { odata } from '../../../../utils/odata.js';
|
|
10
10
|
import { validation } from '../../../../utils/validation.js';
|
|
@@ -35,7 +35,7 @@ class EntraM365GroupConversationPostListCommand extends GraphCommand {
|
|
|
35
35
|
async commandAction(logger, args) {
|
|
36
36
|
try {
|
|
37
37
|
const retrievedgroupId = await this.getGroupId(args);
|
|
38
|
-
const isUnifiedGroup = await
|
|
38
|
+
const isUnifiedGroup = await entraGroup.isUnifiedGroup(retrievedgroupId);
|
|
39
39
|
if (!isUnifiedGroup) {
|
|
40
40
|
throw Error(`Specified group with id '${retrievedgroupId}' is not a Microsoft 365 group.`);
|
|
41
41
|
}
|
|
@@ -50,7 +50,7 @@ class EntraM365GroupConversationPostListCommand extends GraphCommand {
|
|
|
50
50
|
if (args.options.groupId) {
|
|
51
51
|
return formatting.encodeQueryParameter(args.options.groupId);
|
|
52
52
|
}
|
|
53
|
-
const group = await
|
|
53
|
+
const group = await entraGroup.getGroupByDisplayName(args.options.groupDisplayName);
|
|
54
54
|
return group.id;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -5,7 +5,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
5
5
|
};
|
|
6
6
|
var _EntraM365GroupGetCommand_instances, _EntraM365GroupGetCommand_initOptions, _EntraM365GroupGetCommand_initValidators;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
|
-
import {
|
|
8
|
+
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
9
9
|
import { validation } from '../../../../utils/validation.js';
|
|
10
10
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
11
11
|
import aadCommands from '../../aadCommands.js';
|
|
@@ -29,11 +29,11 @@ class EntraM365GroupGetCommand extends GraphCommand {
|
|
|
29
29
|
async commandAction(logger, args) {
|
|
30
30
|
let group;
|
|
31
31
|
try {
|
|
32
|
-
const isUnifiedGroup = await
|
|
32
|
+
const isUnifiedGroup = await entraGroup.isUnifiedGroup(args.options.id);
|
|
33
33
|
if (!isUnifiedGroup) {
|
|
34
34
|
throw Error(`Specified group with id '${args.options.id}' is not a Microsoft 365 group.`);
|
|
35
35
|
}
|
|
36
|
-
group = await
|
|
36
|
+
group = await entraGroup.getGroupById(args.options.id);
|
|
37
37
|
if (args.options.includeSiteUrl) {
|
|
38
38
|
const requestOptions = {
|
|
39
39
|
url: `${this.resource}/v1.0/groups/${group.id}/drive?$select=webUrl`,
|
|
@@ -6,7 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
6
6
|
var _EntraM365GroupRemoveCommand_instances, _EntraM365GroupRemoveCommand_initTelemetry, _EntraM365GroupRemoveCommand_initOptions, _EntraM365GroupRemoveCommand_initValidators;
|
|
7
7
|
import { cli } from '../../../../cli/cli.js';
|
|
8
8
|
import request from '../../../../request.js';
|
|
9
|
-
import {
|
|
9
|
+
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
10
10
|
import { validation } from '../../../../utils/validation.js';
|
|
11
11
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
12
12
|
import commands from '../../commands.js';
|
|
@@ -39,7 +39,7 @@ class EntraM365GroupRemoveCommand extends GraphCommand {
|
|
|
39
39
|
await logger.logToStderr(`Removing Microsoft 365 Group: ${args.options.id}...`);
|
|
40
40
|
}
|
|
41
41
|
try {
|
|
42
|
-
const isUnifiedGroup = await
|
|
42
|
+
const isUnifiedGroup = await entraGroup.isUnifiedGroup(args.options.id);
|
|
43
43
|
if (!isUnifiedGroup) {
|
|
44
44
|
throw Error(`Specified group with id '${args.options.id}' is not a Microsoft 365 group.`);
|
|
45
45
|
}
|
|
@@ -5,7 +5,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
5
5
|
};
|
|
6
6
|
var _EntraM365GroupRenewCommand_instances, _EntraM365GroupRenewCommand_initOptions, _EntraM365GroupRenewCommand_initValidators;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
|
-
import {
|
|
8
|
+
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
9
9
|
import { validation } from '../../../../utils/validation.js';
|
|
10
10
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
11
11
|
import aadCommands from '../../aadCommands.js';
|
|
@@ -31,7 +31,7 @@ class EntraM365GroupRenewCommand extends GraphCommand {
|
|
|
31
31
|
await logger.logToStderr(`Renewing Microsoft 365 group's expiration: ${args.options.id}...`);
|
|
32
32
|
}
|
|
33
33
|
try {
|
|
34
|
-
const isUnifiedGroup = await
|
|
34
|
+
const isUnifiedGroup = await entraGroup.isUnifiedGroup(args.options.id);
|
|
35
35
|
if (!isUnifiedGroup) {
|
|
36
36
|
throw Error(`Specified group with id '${args.options.id}' is not a Microsoft 365 group.`);
|
|
37
37
|
}
|
|
@@ -11,7 +11,7 @@ import request from '../../../../request.js';
|
|
|
11
11
|
import { validation } from '../../../../utils/validation.js';
|
|
12
12
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
13
13
|
import commands from '../../commands.js';
|
|
14
|
-
import {
|
|
14
|
+
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
15
15
|
import aadCommands from '../../aadCommands.js';
|
|
16
16
|
class EntraM365GroupSetCommand extends GraphCommand {
|
|
17
17
|
get name() {
|
|
@@ -34,7 +34,7 @@ class EntraM365GroupSetCommand extends GraphCommand {
|
|
|
34
34
|
}
|
|
35
35
|
async commandAction(logger, args) {
|
|
36
36
|
try {
|
|
37
|
-
const isUnifiedGroup = await
|
|
37
|
+
const isUnifiedGroup = await entraGroup.isUnifiedGroup(args.options.id);
|
|
38
38
|
if (!isUnifiedGroup) {
|
|
39
39
|
throw Error(`Specified group with id '${args.options.id}' is not a Microsoft 365 group.`);
|
|
40
40
|
}
|
|
@@ -6,7 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
6
6
|
var _EntraM365GroupTeamifyCommand_instances, _EntraM365GroupTeamifyCommand_initTelemetry, _EntraM365GroupTeamifyCommand_initOptions, _EntraM365GroupTeamifyCommand_initValidators, _EntraM365GroupTeamifyCommand_initOptionSets;
|
|
7
7
|
import { cli } from '../../../../cli/cli.js';
|
|
8
8
|
import request from '../../../../request.js';
|
|
9
|
-
import {
|
|
9
|
+
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
10
10
|
import { formatting } from '../../../../utils/formatting.js';
|
|
11
11
|
import { validation } from '../../../../utils/validation.js';
|
|
12
12
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
@@ -56,7 +56,7 @@ class EntraM365GroupTeamifyCommand extends GraphCommand {
|
|
|
56
56
|
async commandAction(logger, args) {
|
|
57
57
|
try {
|
|
58
58
|
const groupId = await this.getGroupId(args.options);
|
|
59
|
-
const isUnifiedGroup = await
|
|
59
|
+
const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId);
|
|
60
60
|
if (!isUnifiedGroup) {
|
|
61
61
|
throw Error(`Specified group with id '${groupId}' is not a Microsoft 365 group.`);
|
|
62
62
|
}
|
|
@@ -5,7 +5,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
5
5
|
};
|
|
6
6
|
var _EntraM365GroupUserAddCommand_instances, _EntraM365GroupUserAddCommand_initTelemetry, _EntraM365GroupUserAddCommand_initOptions, _EntraM365GroupUserAddCommand_initValidators, _EntraM365GroupUserAddCommand_initOptionSets;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
|
-
import {
|
|
8
|
+
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
9
9
|
import { formatting } from '../../../../utils/formatting.js';
|
|
10
10
|
import { validation } from '../../../../utils/validation.js';
|
|
11
11
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
@@ -33,7 +33,7 @@ class EntraM365GroupUserAddCommand extends GraphCommand {
|
|
|
33
33
|
async commandAction(logger, args) {
|
|
34
34
|
try {
|
|
35
35
|
const providedGroupId = (typeof args.options.groupId !== 'undefined') ? args.options.groupId : args.options.teamId;
|
|
36
|
-
const isUnifiedGroup = await
|
|
36
|
+
const isUnifiedGroup = await entraGroup.isUnifiedGroup(providedGroupId);
|
|
37
37
|
if (!isUnifiedGroup) {
|
|
38
38
|
throw Error(`Specified group with id '${providedGroupId}' is not a Microsoft 365 group.`);
|
|
39
39
|
}
|
|
@@ -8,7 +8,7 @@ import { odata } from '../../../../utils/odata.js';
|
|
|
8
8
|
import { validation } from '../../../../utils/validation.js';
|
|
9
9
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
10
10
|
import commands from '../../commands.js';
|
|
11
|
-
import {
|
|
11
|
+
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
12
12
|
import aadCommands from '../../aadCommands.js';
|
|
13
13
|
class EntraM365GroupUserListCommand extends GraphCommand {
|
|
14
14
|
get name() {
|
|
@@ -34,7 +34,7 @@ class EntraM365GroupUserListCommand extends GraphCommand {
|
|
|
34
34
|
this.warn(logger, `Value 'Guest' for the option role is deprecated. Use --filter "userType eq 'Guest'" instead.`);
|
|
35
35
|
}
|
|
36
36
|
const groupId = await this.getGroupId(args.options, logger);
|
|
37
|
-
const isUnifiedGroup = await
|
|
37
|
+
const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId);
|
|
38
38
|
if (!isUnifiedGroup) {
|
|
39
39
|
throw Error(`Specified group '${args.options.groupId || args.options.groupDisplayName}' is not a Microsoft 365 group.`);
|
|
40
40
|
}
|
|
@@ -71,7 +71,7 @@ class EntraM365GroupUserListCommand extends GraphCommand {
|
|
|
71
71
|
if (this.verbose) {
|
|
72
72
|
await logger.logToStderr('Retrieving Group Id...');
|
|
73
73
|
}
|
|
74
|
-
return await
|
|
74
|
+
return await entraGroup.getGroupIdByDisplayName(options.groupDisplayName);
|
|
75
75
|
}
|
|
76
76
|
async getUsers(options, role, groupId, logger) {
|
|
77
77
|
const { properties, filter } = options;
|
|
@@ -6,7 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
6
6
|
var _EntraM365GroupUserRemoveCommand_instances, _EntraM365GroupUserRemoveCommand_initTelemetry, _EntraM365GroupUserRemoveCommand_initOptions, _EntraM365GroupUserRemoveCommand_initValidators, _EntraM365GroupUserRemoveCommand_initOptionSets;
|
|
7
7
|
import { cli } from '../../../../cli/cli.js';
|
|
8
8
|
import request from '../../../../request.js';
|
|
9
|
-
import {
|
|
9
|
+
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
10
10
|
import { formatting } from '../../../../utils/formatting.js';
|
|
11
11
|
import { validation } from '../../../../utils/validation.js';
|
|
12
12
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
@@ -35,7 +35,7 @@ class EntraM365GroupUserRemoveCommand extends GraphCommand {
|
|
|
35
35
|
const groupId = (typeof args.options.groupId !== 'undefined') ? args.options.groupId : args.options.teamId;
|
|
36
36
|
const removeUser = async () => {
|
|
37
37
|
try {
|
|
38
|
-
const isUnifiedGroup = await
|
|
38
|
+
const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId);
|
|
39
39
|
if (!isUnifiedGroup) {
|
|
40
40
|
throw Error(`Specified group with id '${groupId}' is not a Microsoft 365 group.`);
|
|
41
41
|
}
|
|
@@ -10,7 +10,7 @@ import { validation } from '../../../../utils/validation.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
|
-
import {
|
|
13
|
+
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
14
14
|
import aadCommands from '../../aadCommands.js';
|
|
15
15
|
class EntraM365GroupUserSetCommand extends GraphCommand {
|
|
16
16
|
get name() {
|
|
@@ -33,7 +33,7 @@ class EntraM365GroupUserSetCommand extends GraphCommand {
|
|
|
33
33
|
async commandAction(logger, args) {
|
|
34
34
|
try {
|
|
35
35
|
const groupId = (typeof args.options.groupId !== 'undefined') ? args.options.groupId : args.options.teamId;
|
|
36
|
-
const isUnifiedGroup = await
|
|
36
|
+
const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId);
|
|
37
37
|
if (!isUnifiedGroup) {
|
|
38
38
|
throw Error(`Specified group with id '${groupId}' is not a Microsoft 365 group.`);
|
|
39
39
|
}
|
|
@@ -5,12 +5,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
5
5
|
};
|
|
6
6
|
var _EntraUserGetCommand_instances, _EntraUserGetCommand_initTelemetry, _EntraUserGetCommand_initOptions, _EntraUserGetCommand_initValidators, _EntraUserGetCommand_initOptionSets;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
|
-
import { formatting } from '../../../../utils/formatting.js';
|
|
9
8
|
import { validation } from '../../../../utils/validation.js';
|
|
10
9
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
11
10
|
import commands from '../../commands.js';
|
|
12
|
-
import { cli } from '../../../../cli/cli.js';
|
|
13
11
|
import aadCommands from '../../aadCommands.js';
|
|
12
|
+
import { entraUser } from '../../../../utils/entraUser.js';
|
|
13
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
14
14
|
class EntraUserGetCommand extends GraphCommand {
|
|
15
15
|
get name() {
|
|
16
16
|
return commands.USER_GET;
|
|
@@ -30,50 +30,50 @@ class EntraUserGetCommand extends GraphCommand {
|
|
|
30
30
|
__classPrivateFieldGet(this, _EntraUserGetCommand_instances, "m", _EntraUserGetCommand_initOptionSets).call(this);
|
|
31
31
|
}
|
|
32
32
|
async commandAction(logger, args) {
|
|
33
|
-
const properties = args.options.properties ?
|
|
34
|
-
`&$select=${args.options.properties.split(',').map(p => formatting.encodeQueryParameter(p.trim())).join(',')}` :
|
|
35
|
-
'';
|
|
36
|
-
let requestUrl = `${this.resource}/v1.0/users`;
|
|
37
|
-
if (args.options.id) {
|
|
38
|
-
requestUrl += `?$filter=id eq '${formatting.encodeQueryParameter(args.options.id)}'${properties}`;
|
|
39
|
-
}
|
|
40
|
-
else if (args.options.userName) {
|
|
41
|
-
requestUrl += `?$filter=userPrincipalName eq '${formatting.encodeQueryParameter(args.options.userName)}'${properties}`;
|
|
42
|
-
}
|
|
43
|
-
else if (args.options.email) {
|
|
44
|
-
requestUrl += `?$filter=mail eq '${formatting.encodeQueryParameter(args.options.email)}'${properties}`;
|
|
45
|
-
}
|
|
46
|
-
if (args.options.withManager) {
|
|
47
|
-
requestUrl += '&$expand=manager($select=displayName,userPrincipalName,id,mail)';
|
|
48
|
-
}
|
|
49
|
-
const requestOptions = {
|
|
50
|
-
url: requestUrl,
|
|
51
|
-
headers: {
|
|
52
|
-
accept: 'application/json;odata.metadata=none'
|
|
53
|
-
},
|
|
54
|
-
responseType: 'json'
|
|
55
|
-
};
|
|
56
33
|
try {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (res.value.length === 0) {
|
|
62
|
-
throw `The specified user with ${identifier} does not exist`;
|
|
34
|
+
let userIdOrPrincipalName = args.options.id;
|
|
35
|
+
if (args.options.userName) {
|
|
36
|
+
// single user can be retrieved also by user principal name
|
|
37
|
+
userIdOrPrincipalName = formatting.encodeQueryParameter(args.options.userName);
|
|
63
38
|
}
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
const result = await cli.handleMultipleResultsFound(`Multiple users with ${identifier} found.`, resultAsKeyValuePair);
|
|
67
|
-
await logger.log(result);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
await logger.log(res.value[0]);
|
|
39
|
+
else if (args.options.email) {
|
|
40
|
+
userIdOrPrincipalName = await entraUser.getUserIdByEmail(args.options.email);
|
|
71
41
|
}
|
|
42
|
+
const requestUrl = this.getRequestUrl(userIdOrPrincipalName, args.options);
|
|
43
|
+
const requestOptions = {
|
|
44
|
+
url: requestUrl,
|
|
45
|
+
headers: {
|
|
46
|
+
accept: 'application/json;odata.metadata=none'
|
|
47
|
+
},
|
|
48
|
+
responseType: 'json'
|
|
49
|
+
};
|
|
50
|
+
const user = await request.get(requestOptions);
|
|
51
|
+
await logger.log(user);
|
|
72
52
|
}
|
|
73
53
|
catch (err) {
|
|
74
54
|
this.handleRejectedODataJsonPromise(err);
|
|
75
55
|
}
|
|
76
56
|
}
|
|
57
|
+
getRequestUrl(userIdOrPrincipalName, options) {
|
|
58
|
+
const queryParameters = [];
|
|
59
|
+
if (options.properties) {
|
|
60
|
+
const allProperties = options.properties.split(',');
|
|
61
|
+
const selectProperties = allProperties.filter(prop => !prop.includes('/'));
|
|
62
|
+
if (selectProperties.length > 0) {
|
|
63
|
+
queryParameters.push(`$select=${selectProperties}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (options.withManager) {
|
|
67
|
+
queryParameters.push('$expand=manager($select=displayName,userPrincipalName,id,mail)');
|
|
68
|
+
}
|
|
69
|
+
const queryString = queryParameters.length > 0
|
|
70
|
+
? `?${queryParameters.join('&')}`
|
|
71
|
+
: '';
|
|
72
|
+
// user principal name can start with $ but it violates the OData URL convention, so it must be enclosed in parenthesis and single quotes
|
|
73
|
+
return userIdOrPrincipalName.startsWith('%24')
|
|
74
|
+
? `${this.resource}/v1.0/users('${userIdOrPrincipalName}')${queryString}`
|
|
75
|
+
: `${this.resource}/v1.0/users/${userIdOrPrincipalName}${queryString}`;
|
|
76
|
+
}
|
|
77
77
|
}
|
|
78
78
|
_EntraUserGetCommand_instances = new WeakSet(), _EntraUserGetCommand_initTelemetry = function _EntraUserGetCommand_initTelemetry() {
|
|
79
79
|
this.telemetry.push((args) => {
|
|
@@ -14,15 +14,18 @@ export default {
|
|
|
14
14
|
APP_REMOVE: `${prefix} app remove`,
|
|
15
15
|
APP_SET: `${prefix} app set`,
|
|
16
16
|
APP_PERMISSION_ADD: `${prefix} app permission add`,
|
|
17
|
+
APP_PERMISSION_LIST: `${prefix} app permission list`,
|
|
17
18
|
APP_ROLE_ADD: `${prefix} app role add`,
|
|
18
19
|
APP_ROLE_LIST: `${prefix} app role list`,
|
|
19
20
|
APP_ROLE_REMOVE: `${prefix} app role remove`,
|
|
20
21
|
APPROLEASSIGNMENT_ADD: `${prefix} approleassignment add`,
|
|
21
22
|
APPROLEASSIGNMENT_LIST: `${prefix} approleassignment list`,
|
|
22
23
|
APPROLEASSIGNMENT_REMOVE: `${prefix} approleassignment remove`,
|
|
24
|
+
GROUP_ADD: `${prefix} group add`,
|
|
23
25
|
GROUP_GET: `${prefix} group get`,
|
|
24
26
|
GROUP_LIST: `${prefix} group list`,
|
|
25
27
|
GROUP_REMOVE: `${prefix} group remove`,
|
|
28
|
+
GROUP_USER_ADD: `${prefix} group user add`,
|
|
26
29
|
GROUP_USER_LIST: `${prefix} group user list`,
|
|
27
30
|
GROUPSETTING_ADD: `${prefix} groupsetting add`,
|
|
28
31
|
GROUPSETTING_GET: `${prefix} groupsetting get`,
|
|
@@ -228,7 +228,8 @@ class ExternalConnectionDoctorCommand extends GraphCommand {
|
|
|
228
228
|
const requestOptions = {
|
|
229
229
|
url: `${this.resource}/v1.0/external/connections/${args.options.id}/schema`,
|
|
230
230
|
headers: {
|
|
231
|
-
accept: 'application/json;odata.metadata=none'
|
|
231
|
+
accept: 'application/json;odata.metadata=none',
|
|
232
|
+
prefer: 'include-unknown-enum-members'
|
|
232
233
|
},
|
|
233
234
|
responseType: 'json'
|
|
234
235
|
};
|