@pnp/cli-microsoft365 8.1.0-beta.bf59841 → 9.0.0-beta.2b15817
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/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/config.js +1 -1
- package/dist/m365/app/commands/permission/permission-add.js +9 -9
- package/dist/m365/commands/status.js +2 -2
- package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-add.js +13 -13
- package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-get.js +18 -18
- package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-list.js +1 -1
- package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-remove.js +123 -0
- package/dist/m365/entra/commands/group/group-set.js +256 -0
- package/dist/m365/entra/commands/group/group-user-list.js +4 -4
- package/dist/m365/entra/commands/m365group/m365group-conversation-post-list.js +4 -4
- package/dist/m365/entra/commands/m365group/m365group-recyclebinitem-list.js +3 -3
- package/dist/m365/entra/commands/m365group/m365group-user-add.js +109 -32
- package/dist/m365/entra/commands/m365group/m365group-user-list.js +6 -9
- package/dist/m365/entra/commands/m365group/m365group-user-set.js +159 -84
- package/dist/m365/entra/commands.js +3 -0
- package/dist/m365/flow/commands/flow-get.js +1 -1
- package/dist/m365/outlook/commands/message/message-get.js +11 -11
- package/dist/m365/pa/commands/app/app-export.js +13 -7
- package/dist/m365/spfx/commands/project/DeployWorkflow.js +1 -1
- package/dist/m365/spfx/commands/project/project-github-workflow-add.js +1 -10
- package/dist/m365/spo/commands/file/file-copy.js +55 -34
- package/dist/m365/spo/commands/folder/folder-set.js +0 -4
- package/dist/m365/spo/commands/folder/folder-sharinglink-get.js +86 -0
- package/dist/m365/spo/commands/folder/folder-sharinglink-list.js +110 -0
- package/dist/m365/spo/commands/list/ListInstance.js +6 -1
- package/dist/m365/spo/commands/list/list-get.js +9 -3
- package/dist/m365/spo/commands/list/list-list.js +1 -4
- package/dist/m365/spo/commands/site/site-appcatalog-remove.js +48 -24
- package/dist/m365/spo/commands/site/site-remove.js +1 -7
- package/dist/m365/spo/commands/tenant/tenant-recyclebinitem-restore.js +2 -22
- package/dist/m365/spo/commands.js +2 -1
- package/dist/m365/teams/commands/message/message-restore.js +106 -0
- package/dist/m365/teams/commands.js +1 -0
- package/dist/utils/drive.js +61 -0
- package/dist/utils/spo.js +106 -0
- package/docs/docs/cmd/app/permission/permission-add.mdx +5 -5
- package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-add.mdx +12 -12
- package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-get.mdx +14 -14
- package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-list.mdx +5 -5
- package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-remove.mdx +65 -0
- package/docs/docs/cmd/entra/group/group-add.mdx +0 -4
- package/docs/docs/cmd/entra/group/group-set.mdx +89 -0
- package/docs/docs/cmd/entra/group/group-user-list.mdx +7 -7
- package/docs/docs/cmd/entra/m365group/m365group-conversation-post-list.mdx +5 -5
- package/docs/docs/cmd/entra/m365group/m365group-recyclebinitem-list.mdx +3 -3
- package/docs/docs/cmd/entra/m365group/m365group-user-add.mdx +28 -10
- package/docs/docs/cmd/entra/m365group/m365group-user-list.mdx +1 -1
- package/docs/docs/cmd/entra/m365group/m365group-user-set.mdx +35 -11
- package/docs/docs/cmd/flow/flow-get.mdx +149 -283
- package/docs/docs/cmd/outlook/message/message-get.mdx +5 -5
- package/docs/docs/cmd/pa/app/app-export.mdx +15 -9
- package/docs/docs/cmd/spfx/project/project-github-workflow-add.mdx +11 -12
- package/docs/docs/cmd/spo/app/app-uninstall.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-copy.mdx +119 -12
- package/docs/docs/cmd/spo/folder/folder-set.mdx +0 -6
- package/docs/docs/cmd/spo/folder/folder-sharinglink-get.mdx +110 -0
- package/docs/docs/cmd/spo/folder/folder-sharinglink-list.mdx +114 -0
- package/docs/docs/cmd/spo/list/list-get.mdx +6 -0
- package/docs/docs/cmd/spo/list/list-list.mdx +5 -7
- package/docs/docs/cmd/spo/site/site-appcatalog-remove.mdx +11 -2
- package/docs/docs/cmd/spo/site/site-remove.mdx +0 -3
- package/docs/docs/cmd/spo/tenant/tenant-recyclebinitem-restore.mdx +2 -49
- package/docs/docs/cmd/teams/message/message-remove.mdx +2 -1
- package/docs/docs/cmd/teams/message/message-restore.mdx +62 -0
- package/npm-shrinkwrap.json +574 -479
- package/package.json +22 -22
package/dist/config.js
CHANGED
|
@@ -3,7 +3,7 @@ const cliEntraAppId = '31359c7f-bd7e-475c-86db-fdb8c937548e';
|
|
|
3
3
|
export default {
|
|
4
4
|
applicationName: `CLI for Microsoft 365 v${app.packageJson().version}`,
|
|
5
5
|
delimiter: 'm365\$',
|
|
6
|
-
cliEntraAppId: process.env.CLIMICROSOFT365_ENTRAAPPID ||
|
|
6
|
+
cliEntraAppId: process.env.CLIMICROSOFT365_ENTRAAPPID || cliEntraAppId,
|
|
7
7
|
tenant: process.env.CLIMICROSOFT365_TENANT || 'common',
|
|
8
8
|
configstoreName: 'cli-m365-config'
|
|
9
9
|
};
|
|
@@ -33,12 +33,12 @@ class AppPermissionAddCommand extends AppCommand {
|
|
|
33
33
|
const appObject = await this.getAppObject();
|
|
34
34
|
const servicePrincipals = await odata.getAllItems(`${this.resource}/v1.0/myorganization/servicePrincipals?$select=appId,appRoles,id,oauth2PermissionScopes,servicePrincipalNames`);
|
|
35
35
|
const appPermissions = [];
|
|
36
|
-
if (args.options.
|
|
37
|
-
const delegatedPermissions = await this.getRequiredResourceAccessForApis(servicePrincipals, args.options.
|
|
36
|
+
if (args.options.delegatedPermissions) {
|
|
37
|
+
const delegatedPermissions = await this.getRequiredResourceAccessForApis(servicePrincipals, args.options.delegatedPermissions, ScopeType.Scope, appPermissions, logger);
|
|
38
38
|
this.addPermissionsToResourceArray(delegatedPermissions, appObject.requiredResourceAccess);
|
|
39
39
|
}
|
|
40
|
-
if (args.options.
|
|
41
|
-
const applicationPermissions = await this.getRequiredResourceAccessForApis(servicePrincipals, args.options.
|
|
40
|
+
if (args.options.applicationPermissions) {
|
|
41
|
+
const applicationPermissions = await this.getRequiredResourceAccessForApis(servicePrincipals, args.options.applicationPermissions, ScopeType.Role, appPermissions, logger);
|
|
42
42
|
this.addPermissionsToResourceArray(applicationPermissions, appObject.requiredResourceAccess);
|
|
43
43
|
}
|
|
44
44
|
const addPermissionsRequestOptions = {
|
|
@@ -198,17 +198,17 @@ _AppPermissionAddCommand_instances = new WeakSet(), _AppPermissionAddCommand_ini
|
|
|
198
198
|
this.telemetry.push((args) => {
|
|
199
199
|
Object.assign(this.telemetryProperties, {
|
|
200
200
|
appId: typeof args.options.appId !== 'undefined',
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
applicationPermissions: typeof args.options.applicationPermissions !== 'undefined',
|
|
202
|
+
delegatedPermissions: typeof args.options.delegatedPermissions !== 'undefined',
|
|
203
203
|
grantAdminConsent: !!args.options.grantAdminConsent
|
|
204
204
|
});
|
|
205
205
|
});
|
|
206
206
|
}, _AppPermissionAddCommand_initOptions = function _AppPermissionAddCommand_initOptions() {
|
|
207
|
-
this.options.unshift({ option: '--appId [appId]' }, { option: '--
|
|
207
|
+
this.options.unshift({ option: '--appId [appId]' }, { option: '--applicationPermissions [applicationPermissions]' }, { option: '--delegatedPermissions [delegatedPermissions]' }, { option: '--grantAdminConsent' });
|
|
208
208
|
}, _AppPermissionAddCommand_initOptionSets = function _AppPermissionAddCommand_initOptionSets() {
|
|
209
209
|
this.optionSets.push({
|
|
210
|
-
options: ['
|
|
211
|
-
runsWhen: (args) => args.options.
|
|
210
|
+
options: ['applicationPermissions', 'delegatedPermissions'],
|
|
211
|
+
runsWhen: (args) => args.options.delegatedPermissions === undefined && args.options.applicationPermissions === undefined
|
|
212
212
|
});
|
|
213
213
|
};
|
|
214
214
|
export default new AppPermissionAddCommand();
|
|
@@ -30,8 +30,8 @@ class StatusCommand extends Command {
|
|
|
30
30
|
const connections = await auth.getAllConnections();
|
|
31
31
|
if (this.verbose) {
|
|
32
32
|
const message = connections.length > 0
|
|
33
|
-
? `Logged out
|
|
34
|
-
: 'Logged out
|
|
33
|
+
? `Logged out, signed in connections available`
|
|
34
|
+
: 'Logged out';
|
|
35
35
|
await logger.logToStderr(message);
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
@@ -30,12 +30,12 @@ class EntraEnterpriseAppAddCommand extends GraphCommand {
|
|
|
30
30
|
__classPrivateFieldGet(this, _EntraEnterpriseAppAddCommand_instances, "m", _EntraEnterpriseAppAddCommand_initOptionSets).call(this);
|
|
31
31
|
}
|
|
32
32
|
async getAppId(args) {
|
|
33
|
-
if (args.options.
|
|
34
|
-
return args.options.
|
|
33
|
+
if (args.options.id) {
|
|
34
|
+
return args.options.id;
|
|
35
35
|
}
|
|
36
36
|
let spMatchQuery = '';
|
|
37
|
-
if (args.options.
|
|
38
|
-
spMatchQuery = `displayName eq '${formatting.encodeQueryParameter(args.options.
|
|
37
|
+
if (args.options.displayName) {
|
|
38
|
+
spMatchQuery = `displayName eq '${formatting.encodeQueryParameter(args.options.displayName)}'`;
|
|
39
39
|
}
|
|
40
40
|
else if (args.options.objectId) {
|
|
41
41
|
spMatchQuery = `id eq '${formatting.encodeQueryParameter(args.options.objectId)}'`;
|
|
@@ -54,7 +54,7 @@ class EntraEnterpriseAppAddCommand extends GraphCommand {
|
|
|
54
54
|
}
|
|
55
55
|
if (response.value.length > 1) {
|
|
56
56
|
const resultAsKeyValuePair = formatting.convertArrayToHashTable('appId', response.value);
|
|
57
|
-
const result = await cli.handleMultipleResultsFound(`Multiple Entra apps with name '${args.options.
|
|
57
|
+
const result = await cli.handleMultipleResultsFound(`Multiple Entra apps with name '${args.options.displayName}' found.`, resultAsKeyValuePair);
|
|
58
58
|
return result.appId;
|
|
59
59
|
}
|
|
60
60
|
return spItem.appId;
|
|
@@ -85,31 +85,31 @@ class EntraEnterpriseAppAddCommand extends GraphCommand {
|
|
|
85
85
|
_EntraEnterpriseAppAddCommand_instances = new WeakSet(), _EntraEnterpriseAppAddCommand_initTelemetry = function _EntraEnterpriseAppAddCommand_initTelemetry() {
|
|
86
86
|
this.telemetry.push((args) => {
|
|
87
87
|
Object.assign(this.telemetryProperties, {
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
id: (!(!args.options.id)).toString(),
|
|
89
|
+
displayName: (!(!args.options.displayName)).toString(),
|
|
90
90
|
objectId: (!(!args.options.objectId)).toString()
|
|
91
91
|
});
|
|
92
92
|
});
|
|
93
93
|
}, _EntraEnterpriseAppAddCommand_initOptions = function _EntraEnterpriseAppAddCommand_initOptions() {
|
|
94
94
|
this.options.unshift({
|
|
95
|
-
option: '--
|
|
95
|
+
option: '-i, --id [id]'
|
|
96
96
|
}, {
|
|
97
|
-
option: '--
|
|
97
|
+
option: '-n, --displayName [displayName]'
|
|
98
98
|
}, {
|
|
99
99
|
option: '--objectId [objectId]'
|
|
100
100
|
});
|
|
101
101
|
}, _EntraEnterpriseAppAddCommand_initValidators = function _EntraEnterpriseAppAddCommand_initValidators() {
|
|
102
102
|
this.validators.push(async (args) => {
|
|
103
|
-
if (args.options.
|
|
104
|
-
return `${args.options.
|
|
103
|
+
if (args.options.id && !validation.isValidGuid(args.options.id)) {
|
|
104
|
+
return `${args.options.id} is not a valid GUID`;
|
|
105
105
|
}
|
|
106
106
|
if (args.options.objectId && !validation.isValidGuid(args.options.objectId)) {
|
|
107
|
-
return `${args.options.objectId} is not a valid
|
|
107
|
+
return `${args.options.objectId} is not a valid GUID`;
|
|
108
108
|
}
|
|
109
109
|
return true;
|
|
110
110
|
});
|
|
111
111
|
}, _EntraEnterpriseAppAddCommand_initOptionSets = function _EntraEnterpriseAppAddCommand_initOptionSets() {
|
|
112
|
-
this.optionSets.push({ options: ['
|
|
112
|
+
this.optionSets.push({ options: ['id', 'displayName', 'objectId'] });
|
|
113
113
|
};
|
|
114
114
|
export default new EntraEnterpriseAppAddCommand();
|
|
115
115
|
//# sourceMappingURL=enterpriseapp-add.js.map
|
|
@@ -30,15 +30,15 @@ class EntraEnterpriseAppGetCommand extends GraphCommand {
|
|
|
30
30
|
__classPrivateFieldGet(this, _EntraEnterpriseAppGetCommand_instances, "m", _EntraEnterpriseAppGetCommand_initOptionSets).call(this);
|
|
31
31
|
}
|
|
32
32
|
async getSpId(args) {
|
|
33
|
-
if (args.options.
|
|
34
|
-
return args.options.
|
|
33
|
+
if (args.options.objectId) {
|
|
34
|
+
return args.options.objectId;
|
|
35
35
|
}
|
|
36
36
|
let spMatchQuery = '';
|
|
37
|
-
if (args.options.
|
|
38
|
-
spMatchQuery = `displayName eq '${formatting.encodeQueryParameter(args.options.
|
|
37
|
+
if (args.options.displayName) {
|
|
38
|
+
spMatchQuery = `displayName eq '${formatting.encodeQueryParameter(args.options.displayName)}'`;
|
|
39
39
|
}
|
|
40
|
-
else if (args.options.
|
|
41
|
-
spMatchQuery = `appId eq '${formatting.encodeQueryParameter(args.options.
|
|
40
|
+
else if (args.options.id) {
|
|
41
|
+
spMatchQuery = `appId eq '${formatting.encodeQueryParameter(args.options.id)}'`;
|
|
42
42
|
}
|
|
43
43
|
const idRequestOptions = {
|
|
44
44
|
url: `${this.resource}/v1.0/servicePrincipals?$filter=${spMatchQuery}`,
|
|
@@ -54,7 +54,7 @@ class EntraEnterpriseAppGetCommand extends GraphCommand {
|
|
|
54
54
|
}
|
|
55
55
|
if (response.value.length > 1) {
|
|
56
56
|
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', response.value);
|
|
57
|
-
const result = await cli.handleMultipleResultsFound(`Multiple Entra apps with name '${args.options.
|
|
57
|
+
const result = await cli.handleMultipleResultsFound(`Multiple Entra apps with name '${args.options.displayName}' found.`, resultAsKeyValuePair);
|
|
58
58
|
return result.id;
|
|
59
59
|
}
|
|
60
60
|
return spItem.id;
|
|
@@ -85,31 +85,31 @@ class EntraEnterpriseAppGetCommand extends GraphCommand {
|
|
|
85
85
|
_EntraEnterpriseAppGetCommand_instances = new WeakSet(), _EntraEnterpriseAppGetCommand_initTelemetry = function _EntraEnterpriseAppGetCommand_initTelemetry() {
|
|
86
86
|
this.telemetry.push((args) => {
|
|
87
87
|
Object.assign(this.telemetryProperties, {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
id: (!(!args.options.id)).toString(),
|
|
89
|
+
displayName: (!(!args.options.displayName)).toString(),
|
|
90
|
+
objectId: (!(!args.options.objectId)).toString()
|
|
91
91
|
});
|
|
92
92
|
});
|
|
93
93
|
}, _EntraEnterpriseAppGetCommand_initOptions = function _EntraEnterpriseAppGetCommand_initOptions() {
|
|
94
94
|
this.options.unshift({
|
|
95
|
-
option: '-i, --
|
|
95
|
+
option: '-i, --id [id]'
|
|
96
96
|
}, {
|
|
97
|
-
option: '-n, --
|
|
97
|
+
option: '-n, --displayName [displayName]'
|
|
98
98
|
}, {
|
|
99
|
-
option: '--
|
|
99
|
+
option: '--objectId [objectId]'
|
|
100
100
|
});
|
|
101
101
|
}, _EntraEnterpriseAppGetCommand_initValidators = function _EntraEnterpriseAppGetCommand_initValidators() {
|
|
102
102
|
this.validators.push(async (args) => {
|
|
103
|
-
if (args.options.
|
|
104
|
-
return `${args.options.
|
|
103
|
+
if (args.options.id && !validation.isValidGuid(args.options.id)) {
|
|
104
|
+
return `${args.options.id} is not a valid GUID`;
|
|
105
105
|
}
|
|
106
|
-
if (args.options.
|
|
107
|
-
return `${args.options.
|
|
106
|
+
if (args.options.objectId && !validation.isValidGuid(args.options.objectId)) {
|
|
107
|
+
return `${args.options.objectId} is not a valid GUID`;
|
|
108
108
|
}
|
|
109
109
|
return true;
|
|
110
110
|
});
|
|
111
111
|
}, _EntraEnterpriseAppGetCommand_initOptionSets = function _EntraEnterpriseAppGetCommand_initOptionSets() {
|
|
112
|
-
this.optionSets.push({ options: ['
|
|
112
|
+
this.optionSets.push({ options: ['id', 'displayName', 'objectId'] });
|
|
113
113
|
};
|
|
114
114
|
export default new EntraEnterpriseAppGetCommand();
|
|
115
115
|
//# sourceMappingURL=enterpriseapp-get.js.map
|
|
@@ -61,7 +61,7 @@ _EntraEnterpriseAppListCommand_instances = new WeakSet(), _EntraEnterpriseAppLis
|
|
|
61
61
|
});
|
|
62
62
|
}, _EntraEnterpriseAppListCommand_initOptions = function _EntraEnterpriseAppListCommand_initOptions() {
|
|
63
63
|
this.options.unshift({
|
|
64
|
-
option: '--displayName [displayName]'
|
|
64
|
+
option: '-n, --displayName [displayName]'
|
|
65
65
|
}, {
|
|
66
66
|
option: '--tag [tag]'
|
|
67
67
|
});
|
|
@@ -0,0 +1,123 @@
|
|
|
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 _EntraEnterpriseAppRemoveCommand_instances, _EntraEnterpriseAppRemoveCommand_initTelemetry, _EntraEnterpriseAppRemoveCommand_initOptions, _EntraEnterpriseAppRemoveCommand_initValidators, _EntraEnterpriseAppRemoveCommand_initOptionSets, _EntraEnterpriseAppRemoveCommand_initTypes;
|
|
7
|
+
import { cli } from '../../../../cli/cli.js';
|
|
8
|
+
import request from '../../../../request.js';
|
|
9
|
+
import { odata } from '../../../../utils/odata.js';
|
|
10
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
11
|
+
import { validation } from '../../../../utils/validation.js';
|
|
12
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
13
|
+
import commands from '../../commands.js';
|
|
14
|
+
class EntraEnterpriseAppRemoveCommand extends GraphCommand {
|
|
15
|
+
get name() {
|
|
16
|
+
return commands.ENTERPRISEAPP_REMOVE;
|
|
17
|
+
}
|
|
18
|
+
get description() {
|
|
19
|
+
return 'Deletes an enterprise application (or service principal)';
|
|
20
|
+
}
|
|
21
|
+
alias() {
|
|
22
|
+
return [commands.SP_REMOVE];
|
|
23
|
+
}
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
_EntraEnterpriseAppRemoveCommand_instances.add(this);
|
|
27
|
+
__classPrivateFieldGet(this, _EntraEnterpriseAppRemoveCommand_instances, "m", _EntraEnterpriseAppRemoveCommand_initTelemetry).call(this);
|
|
28
|
+
__classPrivateFieldGet(this, _EntraEnterpriseAppRemoveCommand_instances, "m", _EntraEnterpriseAppRemoveCommand_initOptions).call(this);
|
|
29
|
+
__classPrivateFieldGet(this, _EntraEnterpriseAppRemoveCommand_instances, "m", _EntraEnterpriseAppRemoveCommand_initValidators).call(this);
|
|
30
|
+
__classPrivateFieldGet(this, _EntraEnterpriseAppRemoveCommand_instances, "m", _EntraEnterpriseAppRemoveCommand_initOptionSets).call(this);
|
|
31
|
+
__classPrivateFieldGet(this, _EntraEnterpriseAppRemoveCommand_instances, "m", _EntraEnterpriseAppRemoveCommand_initTypes).call(this);
|
|
32
|
+
}
|
|
33
|
+
async commandAction(logger, args) {
|
|
34
|
+
const removeEnterpriseApplication = async () => {
|
|
35
|
+
if (this.verbose) {
|
|
36
|
+
await logger.logToStderr(`Removing enterprise application ${args.options.id || args.options.displayName || args.options.objectId}...`);
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
let url = `${this.resource}/v1.0`;
|
|
40
|
+
if (args.options.id) {
|
|
41
|
+
url += `/servicePrincipals(appId='${args.options.id}')`;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const id = await this.getSpId(args.options);
|
|
45
|
+
url += `/servicePrincipals/${id}`;
|
|
46
|
+
}
|
|
47
|
+
const requestOptions = {
|
|
48
|
+
url: url,
|
|
49
|
+
headers: {
|
|
50
|
+
accept: 'application/json;odata.metadata=none'
|
|
51
|
+
},
|
|
52
|
+
responseType: 'json'
|
|
53
|
+
};
|
|
54
|
+
await request.delete(requestOptions);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
this.handleRejectedODataJsonPromise(err);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
if (args.options.force) {
|
|
61
|
+
await removeEnterpriseApplication();
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove enterprise application '${args.options.id || args.options.displayName || args.options.objectId}'?` });
|
|
65
|
+
if (result) {
|
|
66
|
+
await removeEnterpriseApplication();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async getSpId(options) {
|
|
71
|
+
if (options.objectId) {
|
|
72
|
+
return options.objectId;
|
|
73
|
+
}
|
|
74
|
+
const spItemsResponse = await odata.getAllItems(`${this.resource}/v1.0/servicePrincipals?$filter=displayName eq '${formatting.encodeQueryParameter(options.displayName)}'&$select=id`);
|
|
75
|
+
if (spItemsResponse.length === 0) {
|
|
76
|
+
throw `The specified enterprise application does not exist.`;
|
|
77
|
+
}
|
|
78
|
+
if (spItemsResponse.length > 1) {
|
|
79
|
+
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', spItemsResponse);
|
|
80
|
+
const result = await cli.handleMultipleResultsFound(`Multiple enterprise applications with name '${options.displayName}' found.`, resultAsKeyValuePair);
|
|
81
|
+
return result.id;
|
|
82
|
+
}
|
|
83
|
+
const spItem = spItemsResponse[0];
|
|
84
|
+
return spItem.id;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
_EntraEnterpriseAppRemoveCommand_instances = new WeakSet(), _EntraEnterpriseAppRemoveCommand_initTelemetry = function _EntraEnterpriseAppRemoveCommand_initTelemetry() {
|
|
88
|
+
this.telemetry.push((args) => {
|
|
89
|
+
Object.assign(this.telemetryProperties, {
|
|
90
|
+
id: typeof args.options.id !== 'undefined',
|
|
91
|
+
displayName: typeof args.options.displayName !== 'undefined',
|
|
92
|
+
objectId: typeof args.options.objectId !== 'undefined',
|
|
93
|
+
force: !!args.options.force
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}, _EntraEnterpriseAppRemoveCommand_initOptions = function _EntraEnterpriseAppRemoveCommand_initOptions() {
|
|
97
|
+
this.options.unshift({
|
|
98
|
+
option: '-i, --id [id]'
|
|
99
|
+
}, {
|
|
100
|
+
option: '-n, --displayName [displayName]'
|
|
101
|
+
}, {
|
|
102
|
+
option: '--objectId [objectId]'
|
|
103
|
+
}, {
|
|
104
|
+
option: '-f, --force'
|
|
105
|
+
});
|
|
106
|
+
}, _EntraEnterpriseAppRemoveCommand_initValidators = function _EntraEnterpriseAppRemoveCommand_initValidators() {
|
|
107
|
+
this.validators.push(async (args) => {
|
|
108
|
+
if (args.options.id && !validation.isValidGuid(args.options.id)) {
|
|
109
|
+
return `The option 'id' with value '${args.options.id}' is not a valid GUID.`;
|
|
110
|
+
}
|
|
111
|
+
if (args.options.objectId && !validation.isValidGuid(args.options.objectId)) {
|
|
112
|
+
return `The option 'objectId' with value '${args.options.objectId}' is not a valid GUID.`;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
});
|
|
116
|
+
}, _EntraEnterpriseAppRemoveCommand_initOptionSets = function _EntraEnterpriseAppRemoveCommand_initOptionSets() {
|
|
117
|
+
this.optionSets.push({ options: ['id', 'displayName', 'objectId'] });
|
|
118
|
+
}, _EntraEnterpriseAppRemoveCommand_initTypes = function _EntraEnterpriseAppRemoveCommand_initTypes() {
|
|
119
|
+
this.types.string.push('id', 'displayName', 'objectId');
|
|
120
|
+
this.types.boolean.push('force');
|
|
121
|
+
};
|
|
122
|
+
export default new EntraEnterpriseAppRemoveCommand();
|
|
123
|
+
//# sourceMappingURL=enterpriseapp-remove.js.map
|
|
@@ -0,0 +1,256 @@
|
|
|
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 _EntraGroupSetCommand_instances, _EntraGroupSetCommand_initTelemetry, _EntraGroupSetCommand_initOptions, _EntraGroupSetCommand_initValidators, _EntraGroupSetCommand_initOptionSets, _EntraGroupSetCommand_initTypes;
|
|
7
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
8
|
+
import commands from '../../commands.js';
|
|
9
|
+
import { validation } from '../../../../utils/validation.js';
|
|
10
|
+
import request from '../../../../request.js';
|
|
11
|
+
import { entraUser } from '../../../../utils/entraUser.js';
|
|
12
|
+
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
13
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
14
|
+
import { odata } from '../../../../utils/odata.js';
|
|
15
|
+
class EntraGroupSetCommand extends GraphCommand {
|
|
16
|
+
get name() {
|
|
17
|
+
return commands.GROUP_SET;
|
|
18
|
+
}
|
|
19
|
+
get description() {
|
|
20
|
+
return 'Updates a Microsoft Entra group';
|
|
21
|
+
}
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
_EntraGroupSetCommand_instances.add(this);
|
|
25
|
+
this.allowedVisibility = ['Public', 'Private'];
|
|
26
|
+
__classPrivateFieldGet(this, _EntraGroupSetCommand_instances, "m", _EntraGroupSetCommand_initTelemetry).call(this);
|
|
27
|
+
__classPrivateFieldGet(this, _EntraGroupSetCommand_instances, "m", _EntraGroupSetCommand_initOptions).call(this);
|
|
28
|
+
__classPrivateFieldGet(this, _EntraGroupSetCommand_instances, "m", _EntraGroupSetCommand_initValidators).call(this);
|
|
29
|
+
__classPrivateFieldGet(this, _EntraGroupSetCommand_instances, "m", _EntraGroupSetCommand_initOptionSets).call(this);
|
|
30
|
+
__classPrivateFieldGet(this, _EntraGroupSetCommand_instances, "m", _EntraGroupSetCommand_initTypes).call(this);
|
|
31
|
+
}
|
|
32
|
+
async commandAction(logger, args) {
|
|
33
|
+
let groupId = args.options.id;
|
|
34
|
+
try {
|
|
35
|
+
if (args.options.displayName) {
|
|
36
|
+
if (this.verbose) {
|
|
37
|
+
await logger.logToStderr(`Retrieving group id...`);
|
|
38
|
+
}
|
|
39
|
+
groupId = await entraGroup.getGroupIdByDisplayName(args.options.displayName);
|
|
40
|
+
}
|
|
41
|
+
const requestOptions = {
|
|
42
|
+
url: `${this.resource}/v1.0/groups/${groupId}`,
|
|
43
|
+
headers: {
|
|
44
|
+
accept: 'application/json;odata.metadata=none'
|
|
45
|
+
},
|
|
46
|
+
data: {
|
|
47
|
+
displayName: args.options.newDisplayName,
|
|
48
|
+
description: args.options.description === '' ? null : args.options.description,
|
|
49
|
+
mailNickName: args.options.mailNickname,
|
|
50
|
+
visibility: args.options.visibility
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
await request.patch(requestOptions);
|
|
54
|
+
const ownerIds = await this.getUserIds(logger, args.options.ownerIds, args.options.ownerUserNames);
|
|
55
|
+
if (ownerIds.length !== 0) {
|
|
56
|
+
await this.updateUsers(logger, groupId, 'owners', ownerIds);
|
|
57
|
+
}
|
|
58
|
+
else if (this.verbose) {
|
|
59
|
+
await logger.logToStderr(`No owners to update.`);
|
|
60
|
+
}
|
|
61
|
+
const memberIds = await this.getUserIds(logger, args.options.memberIds, args.options.memberUserNames);
|
|
62
|
+
if (memberIds.length !== 0) {
|
|
63
|
+
await this.updateUsers(logger, groupId, 'members', memberIds);
|
|
64
|
+
}
|
|
65
|
+
else if (this.verbose) {
|
|
66
|
+
await logger.logToStderr(`No members to update.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
this.handleRejectedODataJsonPromise(err);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
;
|
|
74
|
+
async getUserIds(logger, userIds, userNames) {
|
|
75
|
+
if (userIds) {
|
|
76
|
+
return formatting.splitAndTrim(userIds);
|
|
77
|
+
}
|
|
78
|
+
if (userNames) {
|
|
79
|
+
if (this.verbose) {
|
|
80
|
+
await logger.logToStderr(`Retrieving user IDs...`);
|
|
81
|
+
}
|
|
82
|
+
return entraUser.getUserIdsByUpns(formatting.splitAndTrim(userNames));
|
|
83
|
+
}
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
async updateUsers(logger, groupId, role, userIds) {
|
|
87
|
+
const groupUsers = await odata.getAllItems(`${this.resource}/v1.0/groups/${groupId}/${role}/microsoft.graph.user?$select=id`);
|
|
88
|
+
const userIdsToAdd = userIds.filter(userId => !groupUsers.some(groupUser => groupUser.id === userId));
|
|
89
|
+
const userIdsToRemove = groupUsers.filter(groupUser => !userIds.some(userId => groupUser.id === userId)).map(user => user.id);
|
|
90
|
+
if (this.verbose) {
|
|
91
|
+
await logger.logToStderr(`Adding ${userIdsToAdd.length} ${role}...`);
|
|
92
|
+
}
|
|
93
|
+
for (let i = 0; i < userIdsToAdd.length; i += 400) {
|
|
94
|
+
const userIdsBatch = userIdsToAdd.slice(i, i + 400);
|
|
95
|
+
const batchRequestOptions = this.getBatchRequestOptions();
|
|
96
|
+
// only 20 requests per one batch are allowed
|
|
97
|
+
for (let j = 0; j < userIdsBatch.length; j += 20) {
|
|
98
|
+
// only 20 users can be added in one request
|
|
99
|
+
const userIdsChunk = userIdsBatch.slice(j, j + 20);
|
|
100
|
+
batchRequestOptions.data.requests.push({
|
|
101
|
+
id: j + 1,
|
|
102
|
+
method: 'PATCH',
|
|
103
|
+
url: `/groups/${groupId}`,
|
|
104
|
+
headers: {
|
|
105
|
+
'content-type': 'application/json;odata.metadata=none',
|
|
106
|
+
accept: 'application/json;odata.metadata=none'
|
|
107
|
+
},
|
|
108
|
+
body: {
|
|
109
|
+
[`${role}@odata.bind`]: userIdsChunk.map(u => `${this.resource}/v1.0/directoryObjects/${u}`)
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const res = await request.post(batchRequestOptions);
|
|
114
|
+
for (const response of res.responses) {
|
|
115
|
+
if (response.status !== 204) {
|
|
116
|
+
throw response.body;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (this.verbose) {
|
|
121
|
+
await logger.logToStderr(`Removing ${userIdsToRemove.length} ${role}...`);
|
|
122
|
+
}
|
|
123
|
+
for (let i = 0; i < userIdsToRemove.length; i += 20) {
|
|
124
|
+
const userIdsBatch = userIdsToRemove.slice(i, i + 20);
|
|
125
|
+
const batchRequestOptions = this.getBatchRequestOptions();
|
|
126
|
+
userIdsBatch.map(userId => {
|
|
127
|
+
batchRequestOptions.data.requests.push({
|
|
128
|
+
id: userId,
|
|
129
|
+
method: 'DELETE',
|
|
130
|
+
url: `/groups/${groupId}/${role}/${userId}/$ref`
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
const res = await request.post(batchRequestOptions);
|
|
134
|
+
for (const response of res.responses) {
|
|
135
|
+
if (response.status !== 204) {
|
|
136
|
+
throw response.body;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
getBatchRequestOptions() {
|
|
142
|
+
const requestOptions = {
|
|
143
|
+
url: `${this.resource}/v1.0/$batch`,
|
|
144
|
+
headers: {
|
|
145
|
+
'content-type': 'application/json;odata.metadata=none',
|
|
146
|
+
accept: 'application/json;odata.metadata=none'
|
|
147
|
+
},
|
|
148
|
+
responseType: 'json',
|
|
149
|
+
data: {
|
|
150
|
+
requests: []
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
return requestOptions;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
_EntraGroupSetCommand_instances = new WeakSet(), _EntraGroupSetCommand_initTelemetry = function _EntraGroupSetCommand_initTelemetry() {
|
|
157
|
+
this.telemetry.push((args) => {
|
|
158
|
+
Object.assign(this.telemetryProperties, {
|
|
159
|
+
id: typeof args.options.id !== 'undefined',
|
|
160
|
+
displayName: typeof args.options.displayName !== 'undefined',
|
|
161
|
+
newDisplayName: typeof args.options.newDisplayName !== 'undefined',
|
|
162
|
+
description: typeof args.options.description !== 'undefined',
|
|
163
|
+
mailNickname: typeof args.options.mailNickname !== 'undefined',
|
|
164
|
+
ownerIds: typeof args.options.ownerIds !== 'undefined',
|
|
165
|
+
ownerUserNames: typeof args.options.ownerUserNames !== 'undefined',
|
|
166
|
+
memberIds: typeof args.options.memberIds !== 'undefined',
|
|
167
|
+
memberUserNames: typeof args.options.memberUserNames !== 'undefined',
|
|
168
|
+
visibility: typeof args.options.visibility !== 'undefined'
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
}, _EntraGroupSetCommand_initOptions = function _EntraGroupSetCommand_initOptions() {
|
|
172
|
+
this.options.unshift({
|
|
173
|
+
option: '-i, --id [id]'
|
|
174
|
+
}, {
|
|
175
|
+
option: '--mailNickname [mailNickname]'
|
|
176
|
+
}, {
|
|
177
|
+
option: '-n, --displayName [displayName]'
|
|
178
|
+
}, {
|
|
179
|
+
option: '--newDisplayName [newDisplayName]'
|
|
180
|
+
}, {
|
|
181
|
+
option: '--description [description]'
|
|
182
|
+
}, {
|
|
183
|
+
option: '--ownerIds [ownerIds]'
|
|
184
|
+
}, {
|
|
185
|
+
option: '--ownerUserNames [ownerUserNames]'
|
|
186
|
+
}, {
|
|
187
|
+
option: '--memberIds [memberIds]'
|
|
188
|
+
}, {
|
|
189
|
+
option: '--memberUserNames [memberUserNames]'
|
|
190
|
+
}, {
|
|
191
|
+
option: '--visibility [visibility]',
|
|
192
|
+
autocomplete: this.allowedVisibility
|
|
193
|
+
});
|
|
194
|
+
}, _EntraGroupSetCommand_initValidators = function _EntraGroupSetCommand_initValidators() {
|
|
195
|
+
this.validators.push(async (args) => {
|
|
196
|
+
if (args.options.id && !validation.isValidGuid(args.options.id)) {
|
|
197
|
+
return `Value '${args.options.id}' is not a valid GUID for option 'id'.`;
|
|
198
|
+
}
|
|
199
|
+
if (args.options.newDisplayName && args.options.newDisplayName.length > 256) {
|
|
200
|
+
return `The maximum amount of characters for 'newDisplayName' is 256.`;
|
|
201
|
+
}
|
|
202
|
+
if (args.options.mailNickname) {
|
|
203
|
+
if (!validation.isValidMailNickname(args.options.mailNickname)) {
|
|
204
|
+
return `Value '${args.options.mailNickname}' for option 'mailNickname' must contain only characters in the ASCII character set 0-127 except the following: @ () \ [] " ; : <> , SPACE.`;
|
|
205
|
+
}
|
|
206
|
+
if (args.options.mailNickname.length > 64) {
|
|
207
|
+
return `The maximum amount of characters for 'mailNickname' is 64.`;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (args.options.ownerIds) {
|
|
211
|
+
const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.ownerIds);
|
|
212
|
+
if (isValidGUIDArrayResult !== true) {
|
|
213
|
+
return `The following GUIDs are invalid for option 'ownerIds': ${isValidGUIDArrayResult}.`;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (args.options.ownerUserNames) {
|
|
217
|
+
const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.ownerUserNames);
|
|
218
|
+
if (isValidUPNArrayResult !== true) {
|
|
219
|
+
return `The following user principal names are invalid for option 'ownerUserNames': ${isValidUPNArrayResult}.`;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (args.options.memberIds) {
|
|
223
|
+
const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.memberIds);
|
|
224
|
+
if (isValidGUIDArrayResult !== true) {
|
|
225
|
+
return `The following GUIDs are invalid for option 'memberIds': ${isValidGUIDArrayResult}.`;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (args.options.memberUserNames) {
|
|
229
|
+
const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.memberUserNames);
|
|
230
|
+
if (isValidUPNArrayResult !== true) {
|
|
231
|
+
return `The following user principal names are invalid for option 'memberUserNames': ${isValidUPNArrayResult}.`;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (args.options.visibility && !this.allowedVisibility.includes(args.options.visibility)) {
|
|
235
|
+
return `Option 'visibility' must be one of the following values: ${this.allowedVisibility.join(', ')}.`;
|
|
236
|
+
}
|
|
237
|
+
if (args.options.newDisplayName === undefined && args.options.description === undefined && args.options.visibility === undefined
|
|
238
|
+
&& args.options.ownerIds === undefined && args.options.ownerUserNames === undefined && args.options.memberIds === undefined
|
|
239
|
+
&& args.options.memberUserNames === undefined && args.options.mailNickname === undefined) {
|
|
240
|
+
return `Specify at least one of the following options: 'newDisplayName', 'description', 'visibility', 'ownerIds', 'ownerUserNames', 'memberIds', 'memberUserNames', 'mailNickname'.`;
|
|
241
|
+
}
|
|
242
|
+
return true;
|
|
243
|
+
});
|
|
244
|
+
}, _EntraGroupSetCommand_initOptionSets = function _EntraGroupSetCommand_initOptionSets() {
|
|
245
|
+
this.optionSets.push({ options: ['id', 'displayName'] }, {
|
|
246
|
+
options: ['ownerIds', 'ownerUserNames'],
|
|
247
|
+
runsWhen: (args) => args.options.ownerIds || args.options.ownerUserNames
|
|
248
|
+
}, {
|
|
249
|
+
options: ['memberIds', 'memberUserNames'],
|
|
250
|
+
runsWhen: (args) => args.options.memberIds || args.options.memberUserNames
|
|
251
|
+
});
|
|
252
|
+
}, _EntraGroupSetCommand_initTypes = function _EntraGroupSetCommand_initTypes() {
|
|
253
|
+
this.types.string.push('id', 'displayName', 'newDisplayName', 'description', 'mailNickname', 'ownerIds', 'ownerUserNames', 'memberIds', 'memberUserNames', 'visibility');
|
|
254
|
+
};
|
|
255
|
+
export default new EntraGroupSetCommand();
|
|
256
|
+
//# sourceMappingURL=group-set.js.map
|
|
@@ -65,7 +65,7 @@ class EntraGroupUserListCommand extends GraphCommand {
|
|
|
65
65
|
if (this.verbose) {
|
|
66
66
|
await logger.logToStderr('Retrieving Group Id...');
|
|
67
67
|
}
|
|
68
|
-
return await entraGroup.getGroupIdByDisplayName(options.
|
|
68
|
+
return await entraGroup.getGroupIdByDisplayName(options.groupName);
|
|
69
69
|
}
|
|
70
70
|
async getUsers(options, role, groupId, logger) {
|
|
71
71
|
const { properties, filter } = options;
|
|
@@ -111,7 +111,7 @@ _EntraGroupUserListCommand_instances = new WeakSet(), _EntraGroupUserListCommand
|
|
|
111
111
|
this.telemetry.push((args) => {
|
|
112
112
|
Object.assign(this.telemetryProperties, {
|
|
113
113
|
groupId: typeof args.options.groupId !== 'undefined',
|
|
114
|
-
|
|
114
|
+
groupName: typeof args.options.groupName !== 'undefined',
|
|
115
115
|
role: typeof args.options.role !== 'undefined',
|
|
116
116
|
properties: typeof args.options.properties !== 'undefined',
|
|
117
117
|
filter: typeof args.options.filter !== 'undefined'
|
|
@@ -121,7 +121,7 @@ _EntraGroupUserListCommand_instances = new WeakSet(), _EntraGroupUserListCommand
|
|
|
121
121
|
this.options.unshift({
|
|
122
122
|
option: "-i, --groupId [groupId]"
|
|
123
123
|
}, {
|
|
124
|
-
option: "-n, --
|
|
124
|
+
option: "-n, --groupName [groupName]"
|
|
125
125
|
}, {
|
|
126
126
|
option: "-r, --role [role]",
|
|
127
127
|
autocomplete: ["Owner", "Member"]
|
|
@@ -132,7 +132,7 @@ _EntraGroupUserListCommand_instances = new WeakSet(), _EntraGroupUserListCommand
|
|
|
132
132
|
});
|
|
133
133
|
}, _EntraGroupUserListCommand_initOptionSets = function _EntraGroupUserListCommand_initOptionSets() {
|
|
134
134
|
this.optionSets.push({
|
|
135
|
-
options: ['groupId', '
|
|
135
|
+
options: ['groupId', 'groupName']
|
|
136
136
|
});
|
|
137
137
|
}, _EntraGroupUserListCommand_initValidators = function _EntraGroupUserListCommand_initValidators() {
|
|
138
138
|
this.validators.push(async (args) => {
|