@pnp/cli-microsoft365 10.8.0-beta.a51d886 → 10.8.0
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/.eslintrc.cjs +2 -1
- package/README.md +3 -1
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/cli/cli.js +1 -1
- package/dist/config.js +1 -0
- package/dist/m365/adaptivecard/commands/adaptivecard-send.js +54 -67
- package/dist/m365/app/commands/app-get.js +5 -2
- package/dist/m365/app/commands/app-open.js +9 -22
- package/dist/m365/app/commands/permission/permission-add.js +18 -30
- package/dist/m365/app/commands/permission/permission-list.js +5 -2
- package/dist/m365/base/AppCommand.js +9 -25
- package/dist/m365/booking/commands/business/business-get.js +18 -25
- package/dist/m365/cli/commands/app/app-reconsent.js +103 -0
- package/dist/m365/cli/commands.js +1 -0
- package/dist/m365/context/commands/context-remove.js +12 -25
- package/dist/m365/context/commands/option/option-remove.js +11 -25
- package/dist/m365/entra/commands/organization/organization-list.js +51 -0
- package/dist/m365/entra/commands.js +1 -0
- package/dist/m365/graph/commands/directoryextension/directoryextension-list.js +74 -0
- package/dist/m365/graph/commands/openextension/openextension-set.js +107 -0
- package/dist/m365/graph/commands.js +2 -0
- package/dist/m365/spe/commands/container/container-add.js +85 -0
- package/dist/m365/spe/commands/container/container-list.js +2 -9
- package/dist/m365/spe/commands/container/container-recyclebinitem-list.js +62 -0
- package/dist/m365/spe/commands/container/container-remove.js +99 -0
- package/dist/m365/spe/commands/containertype/containertype-add.js +11 -11
- package/dist/m365/spe/commands/containertype/containertype-get.js +28 -32
- package/dist/m365/spe/commands/containertype/containertype-list.js +14 -4
- package/dist/m365/spe/commands/containertype/containertype-remove.js +81 -0
- package/dist/m365/spe/commands.js +5 -1
- package/dist/m365/spo/commands/list/list-get.js +12 -6
- package/dist/m365/spp/commands/model/model-apply.js +130 -0
- package/dist/m365/spp/commands/model/model-get.js +7 -24
- package/dist/m365/spp/commands/model/model-list.js +1 -1
- package/dist/m365/spp/commands/model/model-remove.js +1 -1
- package/dist/m365/spp/commands.js +1 -0
- package/dist/utils/entraServicePrincipal.js +11 -0
- package/dist/utils/formatting.js +12 -0
- package/dist/utils/spe.js +77 -0
- package/dist/utils/spo.js +0 -18
- package/dist/utils/spp.js +59 -1
- package/dist/utils/zod.js +26 -1
- package/docs/docs/cmd/adaptivecard/adaptivecard-send.mdx +1 -1
- package/docs/docs/cmd/cli/app/app-reconsent.mdx +63 -0
- package/docs/docs/cmd/entra/organization/organization-list.mdx +154 -0
- package/docs/docs/cmd/graph/directoryextension/directoryextension-list.mdx +135 -0
- package/docs/docs/cmd/graph/openextension/openextension-set.mdx +97 -0
- package/docs/docs/cmd/spe/container/container-activate.mdx +0 -2
- package/docs/docs/cmd/spe/container/container-add.mdx +128 -0
- package/docs/docs/cmd/spe/container/container-recyclebinitem-list.mdx +96 -0
- package/docs/docs/cmd/spe/container/container-remove.mdx +65 -0
- package/docs/docs/cmd/spe/containertype/containertype-add.mdx +9 -1
- package/docs/docs/cmd/spe/containertype/containertype-get.mdx +8 -0
- package/docs/docs/cmd/spe/containertype/containertype-list.mdx +8 -0
- package/docs/docs/cmd/spe/containertype/containertype-remove.mdx +52 -0
- package/docs/docs/cmd/spo/list/list-get.mdx +12 -3
- package/docs/docs/cmd/spp/model/model-apply.mdx +79 -0
- package/package.json +3 -3
- package/dist/m365/spe/ContainerProperties.js +0 -2
package/dist/cli/cli.js
CHANGED
|
@@ -406,7 +406,7 @@ async function loadCommandFromFile(commandFileUrl) {
|
|
|
406
406
|
catch { }
|
|
407
407
|
}
|
|
408
408
|
function getCommandInfo(command, filePath = '', helpFilePath = '') {
|
|
409
|
-
const options = command.schema ? zod.
|
|
409
|
+
const options = command.schema ? zod.schemaToOptionInfo(command.schema) : getCommandOptions(command);
|
|
410
410
|
command.optionsInfo = options;
|
|
411
411
|
return {
|
|
412
412
|
aliases: command.alias(),
|
package/dist/config.js
CHANGED
|
@@ -18,6 +18,7 @@ export default {
|
|
|
18
18
|
'https://graph.microsoft.com/Directory.ReadWrite.All',
|
|
19
19
|
'https://graph.microsoft.com/ExternalConnection.ReadWrite.All',
|
|
20
20
|
'https://graph.microsoft.com/ExternalItem.ReadWrite.All',
|
|
21
|
+
'https://graph.microsoft.com/FileStorageContainer.Selected',
|
|
21
22
|
'https://graph.microsoft.com/Group.ReadWrite.All',
|
|
22
23
|
'https://graph.microsoft.com/IdentityProvider.ReadWrite.All',
|
|
23
24
|
'https://graph.microsoft.com/InformationProtectionPolicy.Read',
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 _AdaptiveCardSendCommand_instances, _AdaptiveCardSendCommand_initTelemetry, _AdaptiveCardSendCommand_initOptions, _AdaptiveCardSendCommand_initValidators, _AdaptiveCardSendCommand_initOptionSets;
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { globalOptionsZod } from '../../../Command.js';
|
|
7
3
|
import request from '../../../request.js';
|
|
4
|
+
import { optionsUtils } from '../../../utils/optionsUtils.js';
|
|
5
|
+
import { zod } from '../../../utils/zod.js';
|
|
8
6
|
import AnonymousCommand from '../../base/AnonymousCommand.js';
|
|
9
7
|
import commands from '../commands.js';
|
|
10
|
-
|
|
8
|
+
export const options = globalOptionsZod
|
|
9
|
+
.extend({
|
|
10
|
+
url: z.string(),
|
|
11
|
+
title: zod.alias('t', z.string().optional()),
|
|
12
|
+
description: zod.alias('d', z.string().optional()),
|
|
13
|
+
imageUrl: zod.alias('i', z.string().optional()),
|
|
14
|
+
actionUrl: zod.alias('a', z.string().optional()),
|
|
15
|
+
card: z.string().optional(),
|
|
16
|
+
cardData: z.string().optional()
|
|
17
|
+
})
|
|
18
|
+
.and(z.any());
|
|
11
19
|
class AdaptiveCardSendCommand extends AnonymousCommand {
|
|
12
20
|
get name() {
|
|
13
21
|
return commands.SEND;
|
|
@@ -15,19 +23,48 @@ class AdaptiveCardSendCommand extends AnonymousCommand {
|
|
|
15
23
|
get description() {
|
|
16
24
|
return 'Sends adaptive card to the specified URL';
|
|
17
25
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
_AdaptiveCardSendCommand_instances.add(this);
|
|
21
|
-
__classPrivateFieldGet(this, _AdaptiveCardSendCommand_instances, "m", _AdaptiveCardSendCommand_initTelemetry).call(this);
|
|
22
|
-
__classPrivateFieldGet(this, _AdaptiveCardSendCommand_instances, "m", _AdaptiveCardSendCommand_initOptions).call(this);
|
|
23
|
-
__classPrivateFieldGet(this, _AdaptiveCardSendCommand_instances, "m", _AdaptiveCardSendCommand_initValidators).call(this);
|
|
24
|
-
__classPrivateFieldGet(this, _AdaptiveCardSendCommand_instances, "m", _AdaptiveCardSendCommand_initOptionSets).call(this);
|
|
26
|
+
get schema() {
|
|
27
|
+
return options;
|
|
25
28
|
}
|
|
26
|
-
|
|
27
|
-
return
|
|
29
|
+
getRefinedSchema(schema) {
|
|
30
|
+
return schema
|
|
31
|
+
.refine(options => !options.cardData || options.card, {
|
|
32
|
+
message: 'When you specify cardData, you must also specify card.',
|
|
33
|
+
path: ['cardData']
|
|
34
|
+
})
|
|
35
|
+
.refine(options => {
|
|
36
|
+
if (options.card) {
|
|
37
|
+
try {
|
|
38
|
+
JSON.parse(options.card);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}, {
|
|
47
|
+
message: 'Specified card is not a valid JSON string.',
|
|
48
|
+
path: ['card']
|
|
49
|
+
})
|
|
50
|
+
.refine(options => {
|
|
51
|
+
if (options.cardData) {
|
|
52
|
+
try {
|
|
53
|
+
JSON.parse(options.cardData);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
}, {
|
|
62
|
+
message: 'Specified cardData is not a valid JSON string.',
|
|
63
|
+
path: ['cardData']
|
|
64
|
+
});
|
|
28
65
|
}
|
|
29
66
|
async commandAction(logger, args) {
|
|
30
|
-
const unknownOptions = optionsUtils.getUnknownOptions(args.options, this.
|
|
67
|
+
const unknownOptions = optionsUtils.getUnknownOptions(args.options, zod.schemaToOptions(this.schema));
|
|
31
68
|
const unknownOptionNames = Object.getOwnPropertyNames(unknownOptions);
|
|
32
69
|
const card = await this.getCard(args, unknownOptionNames, unknownOptions);
|
|
33
70
|
const requestOptions = {
|
|
@@ -166,55 +203,5 @@ class AdaptiveCardSendCommand extends AnonymousCommand {
|
|
|
166
203
|
return cardData;
|
|
167
204
|
}
|
|
168
205
|
}
|
|
169
|
-
_AdaptiveCardSendCommand_instances = new WeakSet(), _AdaptiveCardSendCommand_initTelemetry = function _AdaptiveCardSendCommand_initTelemetry() {
|
|
170
|
-
this.telemetry.push((args) => {
|
|
171
|
-
Object.assign(this.telemetryProperties, {
|
|
172
|
-
actionUrl: typeof args.options.actionUrl !== 'undefined',
|
|
173
|
-
card: typeof args.options.card !== 'undefined',
|
|
174
|
-
cardData: typeof args.options.cardData !== 'undefined',
|
|
175
|
-
description: typeof args.options.description !== 'undefined',
|
|
176
|
-
imageUrl: typeof args.options.imageUrl !== 'undefined',
|
|
177
|
-
title: typeof args.options.title !== 'undefined'
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
}, _AdaptiveCardSendCommand_initOptions = function _AdaptiveCardSendCommand_initOptions() {
|
|
181
|
-
this.options.unshift({
|
|
182
|
-
option: '-u, --url <url>'
|
|
183
|
-
}, {
|
|
184
|
-
option: '-t, --title [title]'
|
|
185
|
-
}, {
|
|
186
|
-
option: '-d, --description [description]'
|
|
187
|
-
}, {
|
|
188
|
-
option: '-i, --imageUrl [imageUrl]'
|
|
189
|
-
}, {
|
|
190
|
-
option: '-a, --actionUrl [actionUrl]'
|
|
191
|
-
}, {
|
|
192
|
-
option: '--card [card]'
|
|
193
|
-
}, {
|
|
194
|
-
option: '--cardData [cardData]'
|
|
195
|
-
});
|
|
196
|
-
}, _AdaptiveCardSendCommand_initValidators = function _AdaptiveCardSendCommand_initValidators() {
|
|
197
|
-
this.validators.push(async (args) => {
|
|
198
|
-
if (args.options.card) {
|
|
199
|
-
try {
|
|
200
|
-
JSON.parse(args.options.card);
|
|
201
|
-
}
|
|
202
|
-
catch (e) {
|
|
203
|
-
return `Error while parsing the card: ${e}`;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (args.options.cardData) {
|
|
207
|
-
try {
|
|
208
|
-
JSON.parse(args.options.cardData);
|
|
209
|
-
}
|
|
210
|
-
catch (e) {
|
|
211
|
-
return `Error while parsing card data: ${e}`;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return true;
|
|
215
|
-
});
|
|
216
|
-
}, _AdaptiveCardSendCommand_initOptionSets = function _AdaptiveCardSendCommand_initOptionSets() {
|
|
217
|
-
this.optionSets.push({ options: ['title', 'card'] });
|
|
218
|
-
};
|
|
219
206
|
export default new AdaptiveCardSendCommand();
|
|
220
207
|
//# sourceMappingURL=adaptivecard-send.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import AppCommand from '../../base/AppCommand.js';
|
|
2
|
-
import commands from '../commands.js';
|
|
3
1
|
import { entraApp } from '../../../utils/entraApp.js';
|
|
2
|
+
import AppCommand, { appCommandOptions } from '../../base/AppCommand.js';
|
|
3
|
+
import commands from '../commands.js';
|
|
4
4
|
class AppGetCommand extends AppCommand {
|
|
5
5
|
get name() {
|
|
6
6
|
return commands.GET;
|
|
@@ -8,6 +8,9 @@ class AppGetCommand extends AppCommand {
|
|
|
8
8
|
get description() {
|
|
9
9
|
return 'Retrieves information about the current Microsoft Entra app';
|
|
10
10
|
}
|
|
11
|
+
get schema() {
|
|
12
|
+
return appCommandOptions;
|
|
13
|
+
}
|
|
11
14
|
async commandAction(logger, args) {
|
|
12
15
|
try {
|
|
13
16
|
const app = await entraApp.getAppRegistrationByAppId(args.options.appId);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
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 _AppOpenCommand_instances, _AppOpenCommand_initTelemetry, _AppOpenCommand_initOptions;
|
|
1
|
+
import { z } from 'zod';
|
|
7
2
|
import { cli } from '../../../cli/cli.js';
|
|
8
3
|
import { settingsNames } from '../../../settingsNames.js';
|
|
9
4
|
import { browserUtil } from '../../../utils/browserUtil.js';
|
|
10
|
-
import AppCommand from '../../base/AppCommand.js';
|
|
5
|
+
import AppCommand, { appCommandOptions } from '../../base/AppCommand.js';
|
|
11
6
|
import commands from '../commands.js';
|
|
7
|
+
const options = appCommandOptions
|
|
8
|
+
.extend({
|
|
9
|
+
preview: z.boolean().optional().default(false)
|
|
10
|
+
})
|
|
11
|
+
.strict();
|
|
12
12
|
class AppOpenCommand extends AppCommand {
|
|
13
13
|
get name() {
|
|
14
14
|
return commands.OPEN;
|
|
@@ -16,11 +16,8 @@ class AppOpenCommand extends AppCommand {
|
|
|
16
16
|
get description() {
|
|
17
17
|
return 'Opens Microsoft Entra app in the Microsoft Entra ID portal';
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
_AppOpenCommand_instances.add(this);
|
|
22
|
-
__classPrivateFieldGet(this, _AppOpenCommand_instances, "m", _AppOpenCommand_initTelemetry).call(this);
|
|
23
|
-
__classPrivateFieldGet(this, _AppOpenCommand_instances, "m", _AppOpenCommand_initOptions).call(this);
|
|
19
|
+
get schema() {
|
|
20
|
+
return options;
|
|
24
21
|
}
|
|
25
22
|
async commandAction(logger, args) {
|
|
26
23
|
try {
|
|
@@ -41,15 +38,5 @@ class AppOpenCommand extends AppCommand {
|
|
|
41
38
|
await browserUtil.open(url);
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
|
-
_AppOpenCommand_instances = new WeakSet(), _AppOpenCommand_initTelemetry = function _AppOpenCommand_initTelemetry() {
|
|
45
|
-
this.telemetry.push((args) => {
|
|
46
|
-
Object.assign(this.telemetryProperties, {
|
|
47
|
-
appId: typeof args.options.appId !== 'undefined',
|
|
48
|
-
preview: typeof args.options.preview !== 'undefined'
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
}, _AppOpenCommand_initOptions = function _AppOpenCommand_initOptions() {
|
|
52
|
-
this.options.unshift({ option: '--appId [appId]' }, { option: '--preview' });
|
|
53
|
-
};
|
|
54
41
|
export default new AppOpenCommand();
|
|
55
42
|
//# sourceMappingURL=app-open.js.map
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
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 _AppPermissionAddCommand_instances, _AppPermissionAddCommand_initTelemetry, _AppPermissionAddCommand_initOptions, _AppPermissionAddCommand_initOptionSets;
|
|
1
|
+
import { z } from 'zod';
|
|
7
2
|
import request from '../../../../request.js';
|
|
8
3
|
import { formatting } from '../../../../utils/formatting.js';
|
|
9
4
|
import { odata } from '../../../../utils/odata.js';
|
|
10
|
-
import AppCommand from '../../../base/AppCommand.js';
|
|
5
|
+
import AppCommand, { appCommandOptions } from '../../../base/AppCommand.js';
|
|
11
6
|
import commands from '../../commands.js';
|
|
7
|
+
const options = appCommandOptions
|
|
8
|
+
.extend({
|
|
9
|
+
applicationPermissions: z.string().optional(),
|
|
10
|
+
delegatedPermissions: z.string().optional(),
|
|
11
|
+
grantAdminConsent: z.boolean().optional()
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
12
14
|
var ScopeType;
|
|
13
15
|
(function (ScopeType) {
|
|
14
16
|
ScopeType["Role"] = "Role";
|
|
@@ -21,12 +23,15 @@ class AppPermissionAddCommand extends AppCommand {
|
|
|
21
23
|
get description() {
|
|
22
24
|
return 'Adds the specified application and/or delegated permissions to the current Microsoft Entra app API permissions';
|
|
23
25
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
get schema() {
|
|
27
|
+
return options;
|
|
28
|
+
}
|
|
29
|
+
getRefinedSchema(schema) {
|
|
30
|
+
return schema
|
|
31
|
+
.refine(options => options.applicationPermissions || options.delegatedPermissions, {
|
|
32
|
+
message: 'Specify at least one of applicationPermissions or delegatedPermissions, or both.',
|
|
33
|
+
path: ['delegatedPermissions']
|
|
34
|
+
});
|
|
30
35
|
}
|
|
31
36
|
async commandAction(logger, args) {
|
|
32
37
|
try {
|
|
@@ -194,22 +199,5 @@ class AppPermissionAddCommand extends AppCommand {
|
|
|
194
199
|
return request.post(requestOptions);
|
|
195
200
|
}
|
|
196
201
|
}
|
|
197
|
-
_AppPermissionAddCommand_instances = new WeakSet(), _AppPermissionAddCommand_initTelemetry = function _AppPermissionAddCommand_initTelemetry() {
|
|
198
|
-
this.telemetry.push((args) => {
|
|
199
|
-
Object.assign(this.telemetryProperties, {
|
|
200
|
-
appId: typeof args.options.appId !== 'undefined',
|
|
201
|
-
applicationPermissions: typeof args.options.applicationPermissions !== 'undefined',
|
|
202
|
-
delegatedPermissions: typeof args.options.delegatedPermissions !== 'undefined',
|
|
203
|
-
grantAdminConsent: !!args.options.grantAdminConsent
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
}, _AppPermissionAddCommand_initOptions = function _AppPermissionAddCommand_initOptions() {
|
|
207
|
-
this.options.unshift({ option: '--appId [appId]' }, { option: '--applicationPermissions [applicationPermissions]' }, { option: '--delegatedPermissions [delegatedPermissions]' }, { option: '--grantAdminConsent' });
|
|
208
|
-
}, _AppPermissionAddCommand_initOptionSets = function _AppPermissionAddCommand_initOptionSets() {
|
|
209
|
-
this.optionSets.push({
|
|
210
|
-
options: ['applicationPermissions', 'delegatedPermissions'],
|
|
211
|
-
runsWhen: (args) => args.options.delegatedPermissions === undefined && args.options.applicationPermissions === undefined
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
202
|
export default new AppPermissionAddCommand();
|
|
215
203
|
//# sourceMappingURL=permission-add.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import request from '../../../../request.js';
|
|
2
|
-
import AppCommand from '../../../base/AppCommand.js';
|
|
3
|
-
import commands from '../../commands.js';
|
|
4
2
|
import { entraApp } from '../../../../utils/entraApp.js';
|
|
3
|
+
import AppCommand, { appCommandOptions } from '../../../base/AppCommand.js';
|
|
4
|
+
import commands from '../../commands.js';
|
|
5
5
|
var GetServicePrincipal;
|
|
6
6
|
(function (GetServicePrincipal) {
|
|
7
7
|
GetServicePrincipal[GetServicePrincipal["withPermissions"] = 0] = "withPermissions";
|
|
@@ -14,6 +14,9 @@ class AppPermissionListCommand extends AppCommand {
|
|
|
14
14
|
get description() {
|
|
15
15
|
return 'Lists API permissions for the current Microsoft Entra app';
|
|
16
16
|
}
|
|
17
|
+
get schema() {
|
|
18
|
+
return appCommandOptions;
|
|
19
|
+
}
|
|
17
20
|
async commandAction(logger) {
|
|
18
21
|
try {
|
|
19
22
|
const servicePrincipal = await this.getServicePrincipal({ appId: this.appId }, logger, GetServicePrincipal.withPermissions);
|
|
@@ -1,23 +1,18 @@
|
|
|
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 _AppCommand_instances, _AppCommand_initOptions, _AppCommand_initValidators;
|
|
7
1
|
import fs from 'fs';
|
|
2
|
+
import { z } from 'zod';
|
|
8
3
|
import { cli } from '../../cli/cli.js';
|
|
9
|
-
import Command, { CommandError } from '../../Command.js';
|
|
10
|
-
import { validation } from '../../utils/validation.js';
|
|
4
|
+
import Command, { CommandError, globalOptionsZod } from '../../Command.js';
|
|
11
5
|
import { formatting } from '../../utils/formatting.js';
|
|
12
|
-
|
|
6
|
+
export const appCommandOptions = globalOptionsZod
|
|
7
|
+
.extend({
|
|
8
|
+
appId: z.string().uuid().optional()
|
|
9
|
+
});
|
|
10
|
+
export default class AppCommand extends Command {
|
|
13
11
|
get resource() {
|
|
14
12
|
return 'https://graph.microsoft.com';
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
_AppCommand_instances.add(this);
|
|
19
|
-
__classPrivateFieldGet(this, _AppCommand_instances, "m", _AppCommand_initOptions).call(this);
|
|
20
|
-
__classPrivateFieldGet(this, _AppCommand_instances, "m", _AppCommand_initValidators).call(this);
|
|
14
|
+
get schema() {
|
|
15
|
+
return appCommandOptions;
|
|
21
16
|
}
|
|
22
17
|
async action(logger, args) {
|
|
23
18
|
const m365rcJsonPath = '.m365rc.json';
|
|
@@ -63,15 +58,4 @@ class AppCommand extends Command {
|
|
|
63
58
|
}
|
|
64
59
|
}
|
|
65
60
|
}
|
|
66
|
-
_AppCommand_instances = new WeakSet(), _AppCommand_initOptions = function _AppCommand_initOptions() {
|
|
67
|
-
this.options.unshift({ option: '--appId [appId]' });
|
|
68
|
-
}, _AppCommand_initValidators = function _AppCommand_initValidators() {
|
|
69
|
-
this.validators.push(async (args) => {
|
|
70
|
-
if (args.options.appId && !validation.isValidGuid(args.options.appId)) {
|
|
71
|
-
return `${args.options.appId} is not a valid GUID`;
|
|
72
|
-
}
|
|
73
|
-
return true;
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
export default AppCommand;
|
|
77
61
|
//# sourceMappingURL=AppCommand.js.map
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var _BookingBusinessGetCommand_instances, _BookingBusinessGetCommand_initTelemetry, _BookingBusinessGetCommand_initOptions, _BookingBusinessGetCommand_initOptionSets;
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { cli } from '../../../../cli/cli.js';
|
|
3
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
7
4
|
import request from '../../../../request.js';
|
|
8
5
|
import { formatting } from '../../../../utils/formatting.js';
|
|
6
|
+
import { zod } from '../../../../utils/zod.js';
|
|
9
7
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
10
8
|
import commands from '../../commands.js';
|
|
11
|
-
|
|
9
|
+
const options = globalOptionsZod
|
|
10
|
+
.extend({
|
|
11
|
+
id: zod.alias('i', z.string().optional()),
|
|
12
|
+
name: zod.alias('n', z.string().optional())
|
|
13
|
+
})
|
|
14
|
+
.strict();
|
|
12
15
|
class BookingBusinessGetCommand extends GraphCommand {
|
|
13
16
|
get name() {
|
|
14
17
|
return commands.BUSINESS_GET;
|
|
@@ -16,12 +19,14 @@ class BookingBusinessGetCommand extends GraphCommand {
|
|
|
16
19
|
get description() {
|
|
17
20
|
return 'Retrieve the specified Microsoft Bookings business.';
|
|
18
21
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
get schema() {
|
|
23
|
+
return options;
|
|
24
|
+
}
|
|
25
|
+
getRefinedSchema(schema) {
|
|
26
|
+
return schema
|
|
27
|
+
.refine(options => options.id || options.name, {
|
|
28
|
+
message: 'Specify either id or name'
|
|
29
|
+
});
|
|
25
30
|
}
|
|
26
31
|
async commandAction(logger, args) {
|
|
27
32
|
try {
|
|
@@ -65,17 +70,5 @@ class BookingBusinessGetCommand extends GraphCommand {
|
|
|
65
70
|
return bookingBusinesses[0].id;
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
|
-
_BookingBusinessGetCommand_instances = new WeakSet(), _BookingBusinessGetCommand_initTelemetry = function _BookingBusinessGetCommand_initTelemetry() {
|
|
69
|
-
this.telemetry.push((args) => {
|
|
70
|
-
Object.assign(this.telemetryProperties, {
|
|
71
|
-
id: typeof args.options.id !== 'undefined',
|
|
72
|
-
name: typeof args.options.name !== 'undefined'
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
}, _BookingBusinessGetCommand_initOptions = function _BookingBusinessGetCommand_initOptions() {
|
|
76
|
-
this.options.unshift({ option: '-i, --id [id]' }, { option: '-n, --name [name]' });
|
|
77
|
-
}, _BookingBusinessGetCommand_initOptionSets = function _BookingBusinessGetCommand_initOptionSets() {
|
|
78
|
-
this.optionSets.push({ options: ['id', 'name'] });
|
|
79
|
-
};
|
|
80
73
|
export default new BookingBusinessGetCommand();
|
|
81
74
|
//# sourceMappingURL=business-get.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
2
|
+
import commands from '../../commands.js';
|
|
3
|
+
import auth from '../../../../Auth.js';
|
|
4
|
+
import config from '../../../../config.js';
|
|
5
|
+
import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
6
|
+
import request from '../../../../request.js';
|
|
7
|
+
import { cli } from '../../../../cli/cli.js';
|
|
8
|
+
import { settingsNames } from '../../../../settingsNames.js';
|
|
9
|
+
import { browserUtil } from '../../../../utils/browserUtil.js';
|
|
10
|
+
import { entraApp } from '../../../../utils/entraApp.js';
|
|
11
|
+
import { entraServicePrincipal } from '../../../../utils/entraServicePrincipal.js';
|
|
12
|
+
class CliAppReconsentCommand extends GraphCommand {
|
|
13
|
+
get name() {
|
|
14
|
+
return commands.APP_RECONSENT;
|
|
15
|
+
}
|
|
16
|
+
get description() {
|
|
17
|
+
return 'Reconsent all permission scopes used in CLI for Microsoft 365';
|
|
18
|
+
}
|
|
19
|
+
async commandAction(logger) {
|
|
20
|
+
try {
|
|
21
|
+
const appId = auth.connection.appId;
|
|
22
|
+
if (this.verbose) {
|
|
23
|
+
await logger.logToStderr(`Adding all missing permission scopes used in CLI for Microsoft 365 to application with ID '${appId}'...`);
|
|
24
|
+
}
|
|
25
|
+
const application = await entraApp.getAppRegistrationByAppId(appId, ['requiredResourceAccess', 'id']);
|
|
26
|
+
await this.addCliAppScopes(logger, application.requiredResourceAccess);
|
|
27
|
+
await this.updateAppScopes(logger, application.id, application.requiredResourceAccess);
|
|
28
|
+
const consentUrl = `https://login.microsoftonline.com/${auth.connection.tenant}/adminconsent?client_id=${appId}`;
|
|
29
|
+
await logger.log(`To consent to the new scopes for your Microsoft Entra application registration, please navigate to the following URL: ${consentUrl}`);
|
|
30
|
+
if (cli.getSettingWithDefaultValue(settingsNames.autoOpenLinksInBrowser, false)) {
|
|
31
|
+
await browserUtil.open(consentUrl);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
this.handleRejectedODataJsonPromise(err);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async addCliAppScopes(logger, appScopes) {
|
|
39
|
+
const allCliScopes = config.allScopes;
|
|
40
|
+
const servicePrincipals = await entraServicePrincipal.getServicePrincipals('displayName,appId,oauth2PermissionScopes,servicePrincipalNames');
|
|
41
|
+
if (this.verbose) {
|
|
42
|
+
await logger.logToStderr(`Verifying if all ${allCliScopes.length} permission scopes are present in the app registration...`);
|
|
43
|
+
}
|
|
44
|
+
for (const cliScope of allCliScopes) {
|
|
45
|
+
// Extract service principal name and scope from the URL string
|
|
46
|
+
const spName = urlUtil.removeTrailingSlashes(cliScope.substring(0, cliScope.lastIndexOf('/')));
|
|
47
|
+
const scopeName = cliScope.substring(cliScope.lastIndexOf('/') + 1);
|
|
48
|
+
// Find the matching service principal by name
|
|
49
|
+
const servicePrincipal = servicePrincipals.find(sp => sp.servicePrincipalNames?.some(name => urlUtil.removeTrailingSlashes(name).toLowerCase() === spName.toLowerCase()));
|
|
50
|
+
if (!servicePrincipal) {
|
|
51
|
+
if (this.verbose) {
|
|
52
|
+
await logger.logToStderr(`Service principal with name '${spName}' not found. Skipping scope '${scopeName}'.`);
|
|
53
|
+
}
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
// Find the matching scope in the service principal
|
|
57
|
+
const scope = servicePrincipal.oauth2PermissionScopes?.find(s => s.value?.toLowerCase() === scopeName.toLowerCase());
|
|
58
|
+
if (!scope) {
|
|
59
|
+
if (this.verbose) {
|
|
60
|
+
await logger.logToStderr(`Scope '${scopeName}' not found in service principal '${spName}'. Skipping scope...`);
|
|
61
|
+
}
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
// Check if the service principal is already present in the app registration
|
|
65
|
+
let appSp = appScopes.find(sp => sp.resourceAppId?.toLowerCase() === servicePrincipal.appId.toLowerCase());
|
|
66
|
+
if (!appSp) {
|
|
67
|
+
// Service principal is not present in the app registration, let's add it
|
|
68
|
+
appSp = {
|
|
69
|
+
resourceAppId: servicePrincipal.appId,
|
|
70
|
+
resourceAccess: []
|
|
71
|
+
};
|
|
72
|
+
appScopes.push(appSp);
|
|
73
|
+
}
|
|
74
|
+
// Check if the scope is already present in the app registration
|
|
75
|
+
const isAppScopePresent = appSp.resourceAccess.some(s => s.id?.toLowerCase() === scope.id.toLowerCase());
|
|
76
|
+
if (!isAppScopePresent) {
|
|
77
|
+
// Scope is not present in the app registration, let's add it
|
|
78
|
+
appSp.resourceAccess.push({
|
|
79
|
+
id: scope.id,
|
|
80
|
+
type: 'Scope'
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async updateAppScopes(logger, appId, appScopes) {
|
|
86
|
+
if (this.verbose) {
|
|
87
|
+
await logger.logToStderr(`Updating permission scopes of application with ID '${appId}'...`);
|
|
88
|
+
}
|
|
89
|
+
const requestOptions = {
|
|
90
|
+
url: `${this.resource}/v1.0/applications/${appId}`,
|
|
91
|
+
headers: {
|
|
92
|
+
accept: 'application/json;odata.metadata=none'
|
|
93
|
+
},
|
|
94
|
+
responseType: 'json',
|
|
95
|
+
data: {
|
|
96
|
+
requiredResourceAccess: appScopes
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
await request.patch(requestOptions);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export default new CliAppReconsentCommand();
|
|
103
|
+
//# sourceMappingURL=app-reconsent.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const prefix = 'cli';
|
|
2
2
|
export default {
|
|
3
|
+
APP_RECONSENT: `${prefix} app reconsent`,
|
|
3
4
|
COMPLETION_CLINK_UPDATE: `${prefix} completion clink update`,
|
|
4
5
|
COMPLETION_PWSH_SETUP: `${prefix} completion pwsh setup`,
|
|
5
6
|
COMPLETION_PWSH_UPDATE: `${prefix} completion pwsh update`,
|
|
@@ -1,14 +1,15 @@
|
|
|
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 _ContextRemoveCommand_instances, _ContextRemoveCommand_initTelemetry, _ContextRemoveCommand_initOptions;
|
|
7
1
|
import fs from 'fs';
|
|
2
|
+
import { z } from 'zod';
|
|
8
3
|
import { cli } from '../../../cli/cli.js';
|
|
9
|
-
import { CommandError } from '../../../Command.js';
|
|
4
|
+
import { CommandError, globalOptionsZod } from '../../../Command.js';
|
|
5
|
+
import { zod } from '../../../utils/zod.js';
|
|
10
6
|
import AnonymousCommand from '../../base/AnonymousCommand.js';
|
|
11
7
|
import commands from '../commands.js';
|
|
8
|
+
const options = globalOptionsZod
|
|
9
|
+
.extend({
|
|
10
|
+
force: zod.alias('f', z.boolean().optional())
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
12
13
|
class ContextRemoveCommand extends AnonymousCommand {
|
|
13
14
|
get name() {
|
|
14
15
|
return commands.REMOVE;
|
|
@@ -16,20 +17,17 @@ class ContextRemoveCommand extends AnonymousCommand {
|
|
|
16
17
|
get description() {
|
|
17
18
|
return 'Removes the CLI for Microsoft 365 context in the current working folder';
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
_ContextRemoveCommand_instances.add(this);
|
|
22
|
-
__classPrivateFieldGet(this, _ContextRemoveCommand_instances, "m", _ContextRemoveCommand_initTelemetry).call(this);
|
|
23
|
-
__classPrivateFieldGet(this, _ContextRemoveCommand_instances, "m", _ContextRemoveCommand_initOptions).call(this);
|
|
20
|
+
get schema() {
|
|
21
|
+
return options;
|
|
24
22
|
}
|
|
25
23
|
async commandAction(logger, args) {
|
|
26
24
|
if (args.options.force) {
|
|
27
|
-
|
|
25
|
+
this.removeContext();
|
|
28
26
|
}
|
|
29
27
|
else {
|
|
30
28
|
const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove the context?` });
|
|
31
29
|
if (result) {
|
|
32
|
-
|
|
30
|
+
this.removeContext();
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
}
|
|
@@ -70,16 +68,5 @@ class ContextRemoveCommand extends AnonymousCommand {
|
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
|
-
_ContextRemoveCommand_instances = new WeakSet(), _ContextRemoveCommand_initTelemetry = function _ContextRemoveCommand_initTelemetry() {
|
|
74
|
-
this.telemetry.push((args) => {
|
|
75
|
-
Object.assign(this.telemetryProperties, {
|
|
76
|
-
force: !!args.options.force
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
}, _ContextRemoveCommand_initOptions = function _ContextRemoveCommand_initOptions() {
|
|
80
|
-
this.options.unshift({
|
|
81
|
-
option: '-f, --force'
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
71
|
export default new ContextRemoveCommand();
|
|
85
72
|
//# sourceMappingURL=context-remove.js.map
|