@pnp/cli-microsoft365 7.1.0-beta.d53f0d9 → 7.2.0-beta.0642f3a
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 +0 -1
- package/.eslintrc.cjs +4 -0
- package/Dockerfile +0 -1
- package/dist/Auth.js +1 -1
- package/dist/Command.js +18 -28
- package/dist/cli/Cli.js +6 -4
- package/dist/m365/aad/commands/administrativeunit/administrativeunit-add.js +61 -0
- package/dist/m365/aad/commands/administrativeunit/administrativeunit-get.js +80 -0
- package/dist/m365/aad/commands/administrativeunit/administrativeunit-list.js +25 -0
- package/dist/m365/aad/commands/administrativeunit/administrativeunit-remove.js +96 -0
- package/dist/m365/aad/commands/group/group-user-list.js +146 -0
- package/dist/m365/aad/commands/m365group/m365group-remove.js +109 -15
- package/dist/m365/aad/commands.js +5 -0
- package/dist/m365/base/AppCommand.js +3 -12
- package/dist/m365/cli/commands/cli-doctor.js +11 -6
- package/dist/m365/commands/setup.js +6 -1
- package/dist/m365/{search/commands/externalconnection/externalconnection-add.js → external/commands/connection/connection-add.js} +16 -13
- package/dist/m365/{search/commands/externalconnection/externalconnection-get.js → external/commands/connection/connection-get.js} +16 -13
- package/dist/m365/{search/commands/externalconnection/externalconnection-list.js → external/commands/connection/connection-list.js} +7 -4
- package/dist/m365/{search/commands/externalconnection/externalconnection-remove.js → external/commands/connection/connection-remove.js} +17 -14
- package/dist/m365/{search/commands/externalconnection/externalconnection-schema-add.js → external/commands/connection/connection-schema-add.js} +14 -11
- package/dist/m365/external/commands.js +15 -0
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.18.1-rc.0.js +21 -0
- package/dist/m365/spfx/commands/project/project-doctor.js +2 -1
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN014010_CODE_settings_filesexclude_jest.js +44 -0
- package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.18.1-rc.0.js +57 -0
- package/dist/m365/spfx/commands/project/project-upgrade.js +16 -13
- package/dist/m365/spfx/commands/spfx-doctor.js +15 -0
- package/dist/m365/spo/commands/site/site-set.js +33 -1
- package/dist/m365/spo/commands/sitedesign/sitedesign-get.js +15 -14
- package/dist/m365/spo/commands/sitedesign/sitedesign-remove.js +22 -22
- package/dist/m365/teams/commands/app/app-update.js +9 -6
- package/dist/m365/tenant/commands/people/people-profilecardproperty-add.js +131 -0
- package/dist/m365/tenant/commands/people/people-profilecardproperty-get.js +75 -0
- package/dist/m365/tenant/commands/people/people-profilecardproperty-list.js +53 -0
- package/dist/m365/tenant/commands/people/people-profilecardproperty-remove.js +84 -0
- package/dist/m365/tenant/commands/people/people-profilecardproperty-set.js +118 -0
- package/dist/m365/tenant/commands/people/profileCardProperties.js +24 -0
- package/dist/m365/tenant/commands.js +5 -0
- package/dist/m365/todo/commands/task/task-list.js +8 -10
- package/dist/m365/todo/commands/task/task-remove.js +36 -36
- package/dist/m365/todo/commands/task/task-set.js +11 -13
- package/dist/m365/yammer/commands/group/group-user-remove.js +22 -23
- package/dist/utils/aadAdministrativeUnit.js +25 -0
- package/dist/utils/aadGroup.js +3 -1
- package/dist/utils/odata.js +20 -19
- package/dist/utils/prompt.js +16 -0
- package/docs/docs/cmd/aad/administrativeunit/administrativeunit-add.mdx +119 -0
- package/docs/docs/cmd/aad/administrativeunit/administrativeunit-get.mdx +102 -0
- package/docs/docs/cmd/aad/administrativeunit/administrativeunit-list.mdx +87 -0
- package/docs/docs/cmd/aad/administrativeunit/administrativeunit-remove.mdx +56 -0
- package/docs/docs/cmd/aad/group/group-user-list.mdx +135 -0
- package/docs/docs/cmd/aad/m365group/m365group-remove.mdx +11 -1
- package/docs/docs/cmd/{search/externalconnection/externalconnection-add.mdx → external/connection/connection-add.mdx} +16 -10
- package/docs/docs/cmd/{search/externalconnection/externalconnection-get.mdx → external/connection/connection-get.mdx} +16 -11
- package/docs/docs/cmd/{search/externalconnection/externalconnection-list.mdx → external/connection/connection-list.mdx} +12 -7
- package/docs/docs/cmd/external/connection/connection-remove.mdx +54 -0
- package/docs/docs/cmd/external/connection/connection-schema-add.mdx +41 -0
- package/docs/docs/cmd/spfx/project/project-upgrade.mdx +1 -1
- package/docs/docs/cmd/spo/field/field-get.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-rename.mdx +2 -0
- package/docs/docs/cmd/spo/site/site-set.mdx +15 -0
- package/docs/docs/cmd/tenant/people/people-profilecardproperty-add.mdx +126 -0
- package/docs/docs/cmd/tenant/people/people-profilecardproperty-get.mdx +101 -0
- package/docs/docs/cmd/tenant/people/people-profilecardproperty-list.mdx +98 -0
- package/docs/docs/cmd/tenant/people/people-profilecardproperty-remove.mdx +61 -0
- package/docs/docs/cmd/tenant/people/people-profilecardproperty-set.mdx +120 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +36 -18
- package/dist/m365/search/commands.js +0 -9
- package/docs/docs/cmd/search/externalconnection/externalconnection-remove.mdx +0 -48
- package/docs/docs/cmd/search/externalconnection/externalconnection-schema-add.mdx +0 -35
package/.devcontainer/Dockerfile
CHANGED
|
@@ -6,7 +6,6 @@ LABEL name="CLI for Microsoft 365 Development" \
|
|
|
6
6
|
maintainers="Waldek Mastykarz <waldek@mastykarz.nl>, \
|
|
7
7
|
Garry Trinder <garry.trinder@live.com>, \
|
|
8
8
|
Albert-Jan Schot <appie@digiwijs.nl>, \
|
|
9
|
-
Patrick Lamber <patrick@nubo.eu>, \
|
|
10
9
|
Arjun Menon <arjun.umenon@gmail.com>, \
|
|
11
10
|
Adam Wojcik <adam.wojcik.it@gmail.com>, \
|
|
12
11
|
Martin Lingstuyl <mlingstuyl@live.com>, \
|
package/.eslintrc.cjs
CHANGED
|
@@ -5,6 +5,7 @@ const dictionary = [
|
|
|
5
5
|
'activation',
|
|
6
6
|
'activations',
|
|
7
7
|
'adaptive',
|
|
8
|
+
'administrative',
|
|
8
9
|
'ai',
|
|
9
10
|
'app',
|
|
10
11
|
'application',
|
|
@@ -15,6 +16,7 @@ const dictionary = [
|
|
|
15
16
|
'audit',
|
|
16
17
|
'bin',
|
|
17
18
|
'builder',
|
|
19
|
+
'card',
|
|
18
20
|
'catalog',
|
|
19
21
|
'checklist',
|
|
20
22
|
'client',
|
|
@@ -67,6 +69,7 @@ const dictionary = [
|
|
|
67
69
|
'permission',
|
|
68
70
|
'place',
|
|
69
71
|
'policy',
|
|
72
|
+
'profile',
|
|
70
73
|
'property',
|
|
71
74
|
'records',
|
|
72
75
|
'recycle',
|
|
@@ -90,6 +93,7 @@ const dictionary = [
|
|
|
90
93
|
'threat',
|
|
91
94
|
'token',
|
|
92
95
|
'type',
|
|
96
|
+
'unit',
|
|
93
97
|
'user',
|
|
94
98
|
'web',
|
|
95
99
|
'webhook'
|
package/Dockerfile
CHANGED
|
@@ -8,7 +8,6 @@ LABEL name="m365pnp/cli-microsoft365:${CLI_VERSION}" \
|
|
|
8
8
|
maintainers="Waldek Mastykarz <waldek@mastykarz.nl>, \
|
|
9
9
|
Garry Trinder <garry.trinder@live.com>, \
|
|
10
10
|
Albert-Jan Schot <appie@digiwijs.nl>, \
|
|
11
|
-
Patrick Lamber <patrick@nubo.eu>, \
|
|
12
11
|
Arjun Menon <arjun.umenon@gmail.com>, \
|
|
13
12
|
Adam Wojcik <adam.wojcik.it@gmail.com>, \
|
|
14
13
|
Martin Lingstuyl <mlingstuyl@live.com>, \
|
package/dist/Auth.js
CHANGED
|
@@ -289,7 +289,7 @@ export class Auth {
|
|
|
289
289
|
// but also stub it for testing
|
|
290
290
|
/* c8 ignore next 3 */
|
|
291
291
|
if (!this._authServer) {
|
|
292
|
-
this._authServer = (await import('./AuthServer')).default;
|
|
292
|
+
this._authServer = (await import('./AuthServer.js')).default;
|
|
293
293
|
}
|
|
294
294
|
this._authServer.initializeServer(this.service, resource, resolve, reject, logger, debug);
|
|
295
295
|
});
|
package/dist/Command.js
CHANGED
|
@@ -12,6 +12,7 @@ import { settingsNames } from './settingsNames.js';
|
|
|
12
12
|
import { telemetry } from './telemetry.js';
|
|
13
13
|
import { accessToken } from './utils/accessToken.js';
|
|
14
14
|
import { md } from './utils/md.js';
|
|
15
|
+
import { prompt } from './utils/prompt.js';
|
|
15
16
|
export class CommandError {
|
|
16
17
|
constructor(message, code) {
|
|
17
18
|
this.message = message;
|
|
@@ -75,7 +76,6 @@ class Command {
|
|
|
75
76
|
}
|
|
76
77
|
async validateRequiredOptions(args, command) {
|
|
77
78
|
const shouldPrompt = Cli.getInstance().getSettingWithDefaultValue(settingsNames.prompt, true);
|
|
78
|
-
let inquirer;
|
|
79
79
|
let prompted = false;
|
|
80
80
|
for (let i = 0; i < command.options.length; i++) {
|
|
81
81
|
if (!command.options[i].required ||
|
|
@@ -87,19 +87,17 @@ class Command {
|
|
|
87
87
|
}
|
|
88
88
|
if (!prompted) {
|
|
89
89
|
prompted = true;
|
|
90
|
-
Cli.
|
|
90
|
+
Cli.error('🌶️ Provide values for the following parameters:');
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
inquirer = await import('inquirer');
|
|
94
|
-
}
|
|
95
|
-
const missingRequireOptionValue = await inquirer.default
|
|
96
|
-
.prompt({
|
|
92
|
+
const missingRequireOptionValue = await prompt.forInput({
|
|
97
93
|
name: 'missingRequireOptionValue',
|
|
98
94
|
message: `${command.options[i].name}: `
|
|
99
|
-
})
|
|
100
|
-
.then(result => result.missingRequireOptionValue);
|
|
95
|
+
}).then(result => result.missingRequireOptionValue);
|
|
101
96
|
args.options[command.options[i].name] = missingRequireOptionValue;
|
|
102
97
|
}
|
|
98
|
+
if (prompted) {
|
|
99
|
+
Cli.error('');
|
|
100
|
+
}
|
|
103
101
|
this.processOptions(args.options);
|
|
104
102
|
return true;
|
|
105
103
|
}
|
|
@@ -108,7 +106,6 @@ class Command {
|
|
|
108
106
|
if (!optionsSets || optionsSets.length === 0) {
|
|
109
107
|
return true;
|
|
110
108
|
}
|
|
111
|
-
let inquirer;
|
|
112
109
|
const shouldPrompt = Cli.getInstance().getSettingWithDefaultValue(settingsNames.prompt, true);
|
|
113
110
|
const argsOptions = Object.keys(args.options);
|
|
114
111
|
for (const optionSet of optionsSets.sort(opt => opt.runsWhen ? 0 : 1)) {
|
|
@@ -120,50 +117,43 @@ class Command {
|
|
|
120
117
|
if (!shouldPrompt) {
|
|
121
118
|
return `Specify one of the following options: ${optionSet.options.join(', ')}.`;
|
|
122
119
|
}
|
|
123
|
-
await this.promptForOptionSetNameAndValue(args, optionSet
|
|
120
|
+
await this.promptForOptionSetNameAndValue(args, optionSet);
|
|
124
121
|
}
|
|
125
122
|
if (commonOptions.length > 1) {
|
|
126
123
|
if (!shouldPrompt) {
|
|
127
124
|
return `Specify one of the following options: ${optionSet.options.join(', ')}, but not multiple.`;
|
|
128
125
|
}
|
|
129
|
-
await this.promptForSpecificOption(args, commonOptions
|
|
126
|
+
await this.promptForSpecificOption(args, commonOptions);
|
|
130
127
|
}
|
|
131
128
|
}
|
|
132
129
|
return true;
|
|
133
130
|
}
|
|
134
|
-
async promptForOptionSetNameAndValue(args, optionSet
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
Cli.log(`Please specify one of the following options:`);
|
|
139
|
-
const resultOptionName = await inquirer.default.prompt({
|
|
131
|
+
async promptForOptionSetNameAndValue(args, optionSet) {
|
|
132
|
+
Cli.error(`🌶️ Please specify one of the following options:`);
|
|
133
|
+
const resultOptionName = await prompt.forInput({
|
|
140
134
|
type: 'list',
|
|
141
135
|
name: 'missingRequiredOptionName',
|
|
142
136
|
message: `Option to use:`,
|
|
143
137
|
choices: optionSet.options
|
|
144
138
|
});
|
|
145
139
|
const missingRequiredOptionName = resultOptionName.missingRequiredOptionName;
|
|
146
|
-
const resultOptionValue = await
|
|
147
|
-
.prompt({
|
|
140
|
+
const resultOptionValue = await prompt.forInput({
|
|
148
141
|
name: 'missingRequiredOptionValue',
|
|
149
142
|
message: `${missingRequiredOptionName}:`
|
|
150
143
|
});
|
|
151
144
|
args.options[missingRequiredOptionName] = resultOptionValue.missingRequiredOptionValue;
|
|
152
|
-
Cli.
|
|
145
|
+
Cli.error('');
|
|
153
146
|
}
|
|
154
|
-
async promptForSpecificOption(args, commonOptions
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
Cli.log(`Multiple options for an option set specified. Please specify the correct option that you wish to use.`);
|
|
159
|
-
const requiredOptionNameResult = await inquirer.default.prompt({
|
|
147
|
+
async promptForSpecificOption(args, commonOptions) {
|
|
148
|
+
Cli.error(`🌶️ Multiple options for an option set specified. Please specify the correct option that you wish to use.`);
|
|
149
|
+
const requiredOptionNameResult = await prompt.forInput({
|
|
160
150
|
type: 'list',
|
|
161
151
|
name: 'missingRequiredOptionName',
|
|
162
152
|
message: `Option to use:`,
|
|
163
153
|
choices: commonOptions
|
|
164
154
|
});
|
|
165
155
|
commonOptions.filter(y => y !== requiredOptionNameResult.missingRequiredOptionName).map(optionName => args.options[optionName] = undefined);
|
|
166
|
-
Cli.
|
|
156
|
+
Cli.error('');
|
|
167
157
|
}
|
|
168
158
|
async validateOutput(args) {
|
|
169
159
|
if (args.options.output &&
|
package/dist/cli/Cli.js
CHANGED
|
@@ -15,6 +15,7 @@ import { formatting } from '../utils/formatting.js';
|
|
|
15
15
|
import { fsUtil } from '../utils/fsUtil.js';
|
|
16
16
|
import { md } from '../utils/md.js';
|
|
17
17
|
import { validation } from '../utils/validation.js';
|
|
18
|
+
import { prompt } from '../utils/prompt.js';
|
|
18
19
|
export class Cli {
|
|
19
20
|
get config() {
|
|
20
21
|
if (!this._config) {
|
|
@@ -706,9 +707,10 @@ export class Cli {
|
|
|
706
707
|
const maxLength = Math.max(...namesOfCommandsToPrint.map(s => s.length)) + 10;
|
|
707
708
|
Cli.log(`Commands:`);
|
|
708
709
|
Cli.log();
|
|
709
|
-
|
|
710
|
+
const sortedCommandNamesToPrint = Object.getOwnPropertyNames(commandsToPrint).sort();
|
|
711
|
+
sortedCommandNamesToPrint.forEach(commandName => {
|
|
710
712
|
Cli.log(` ${`${commandName} [options]`.padEnd(maxLength, ' ')} ${commandsToPrint[commandName].command.description}`);
|
|
711
|
-
}
|
|
713
|
+
});
|
|
712
714
|
}
|
|
713
715
|
const namesOfCommandGroupsToPrint = Object.keys(commandGroupsToPrint);
|
|
714
716
|
if (namesOfCommandGroupsToPrint.length > 0) {
|
|
@@ -803,14 +805,13 @@ export class Cli {
|
|
|
803
805
|
}
|
|
804
806
|
}
|
|
805
807
|
static async prompt(options, answers) {
|
|
806
|
-
const inquirer = await import('inquirer');
|
|
807
808
|
const cli = Cli.getInstance();
|
|
808
809
|
const spinnerSpinning = cli.spinner.isSpinning;
|
|
809
810
|
/* c8 ignore next 3 */
|
|
810
811
|
if (spinnerSpinning) {
|
|
811
812
|
cli.spinner.stop();
|
|
812
813
|
}
|
|
813
|
-
const response = await
|
|
814
|
+
const response = await prompt.forInput(options, answers);
|
|
814
815
|
// Restart the spinner if it was running before the prompt
|
|
815
816
|
/* c8 ignore next 3 */
|
|
816
817
|
if (spinnerSpinning) {
|
|
@@ -827,6 +828,7 @@ export class Cli {
|
|
|
827
828
|
type: 'list',
|
|
828
829
|
name: 'select',
|
|
829
830
|
default: 0,
|
|
831
|
+
prefix: '🌶️ ',
|
|
830
832
|
message: `${message} Please choose one:`,
|
|
831
833
|
choices: Object.keys(values)
|
|
832
834
|
});
|
|
@@ -0,0 +1,61 @@
|
|
|
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 _AadAdministrativeUnitAddCommand_instances, _AadAdministrativeUnitAddCommand_initTelemetry, _AadAdministrativeUnitAddCommand_initOptions;
|
|
7
|
+
import request from "../../../../request.js";
|
|
8
|
+
import GraphCommand from "../../../base/GraphCommand.js";
|
|
9
|
+
import commands from "../../commands.js";
|
|
10
|
+
class AadAdministrativeUnitAddCommand extends GraphCommand {
|
|
11
|
+
get name() {
|
|
12
|
+
return commands.ADMINISTRATIVEUNIT_ADD;
|
|
13
|
+
}
|
|
14
|
+
get description() {
|
|
15
|
+
return 'Creates an administrative unit';
|
|
16
|
+
}
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
_AadAdministrativeUnitAddCommand_instances.add(this);
|
|
20
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitAddCommand_instances, "m", _AadAdministrativeUnitAddCommand_initTelemetry).call(this);
|
|
21
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitAddCommand_instances, "m", _AadAdministrativeUnitAddCommand_initOptions).call(this);
|
|
22
|
+
}
|
|
23
|
+
async commandAction(logger, args) {
|
|
24
|
+
const requestOptions = {
|
|
25
|
+
url: `${this.resource}/v1.0/directory/administrativeUnits`,
|
|
26
|
+
headers: {
|
|
27
|
+
accept: 'application/json;odata.metadata=none'
|
|
28
|
+
},
|
|
29
|
+
responseType: 'json',
|
|
30
|
+
data: {
|
|
31
|
+
description: args.options.description,
|
|
32
|
+
displayName: args.options.displayName,
|
|
33
|
+
visibility: args.options.hiddenMembership ? 'HiddenMembership' : null
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
try {
|
|
37
|
+
const administrativeUnit = await request.post(requestOptions);
|
|
38
|
+
await logger.log(administrativeUnit);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
this.handleRejectedODataJsonPromise(err);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
_AadAdministrativeUnitAddCommand_instances = new WeakSet(), _AadAdministrativeUnitAddCommand_initTelemetry = function _AadAdministrativeUnitAddCommand_initTelemetry() {
|
|
46
|
+
this.telemetry.push((args) => {
|
|
47
|
+
Object.assign(this.telemetryProperties, {
|
|
48
|
+
hiddenMembership: !!args.options.hiddenMembership
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}, _AadAdministrativeUnitAddCommand_initOptions = function _AadAdministrativeUnitAddCommand_initOptions() {
|
|
52
|
+
this.options.unshift({
|
|
53
|
+
option: '-n, --displayName <displayName>'
|
|
54
|
+
}, {
|
|
55
|
+
option: '-d, --description [description]'
|
|
56
|
+
}, {
|
|
57
|
+
option: '--hiddenMembership'
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
export default new AadAdministrativeUnitAddCommand();
|
|
61
|
+
//# sourceMappingURL=administrativeunit-add.js.map
|
|
@@ -0,0 +1,80 @@
|
|
|
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 _AadAdministrativeUnitGetCommand_instances, _AadAdministrativeUnitGetCommand_initTelemetry, _AadAdministrativeUnitGetCommand_initOptions, _AadAdministrativeUnitGetCommand_initValidators, _AadAdministrativeUnitGetCommand_initOptionSets, _AadAdministrativeUnitGetCommand_initTypes;
|
|
7
|
+
import { validation } from "../../../../utils/validation.js";
|
|
8
|
+
import request from "../../../../request.js";
|
|
9
|
+
import GraphCommand from "../../../base/GraphCommand.js";
|
|
10
|
+
import commands from "../../commands.js";
|
|
11
|
+
import { aadAdministrativeUnit } from "../../../../utils/aadAdministrativeUnit.js";
|
|
12
|
+
class AadAdministrativeUnitGetCommand extends GraphCommand {
|
|
13
|
+
get name() {
|
|
14
|
+
return commands.ADMINISTRATIVEUNIT_GET;
|
|
15
|
+
}
|
|
16
|
+
get description() {
|
|
17
|
+
return 'Gets information about a specific administrative unit';
|
|
18
|
+
}
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
_AadAdministrativeUnitGetCommand_instances.add(this);
|
|
22
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitGetCommand_instances, "m", _AadAdministrativeUnitGetCommand_initTelemetry).call(this);
|
|
23
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitGetCommand_instances, "m", _AadAdministrativeUnitGetCommand_initOptions).call(this);
|
|
24
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitGetCommand_instances, "m", _AadAdministrativeUnitGetCommand_initValidators).call(this);
|
|
25
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitGetCommand_instances, "m", _AadAdministrativeUnitGetCommand_initOptionSets).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitGetCommand_instances, "m", _AadAdministrativeUnitGetCommand_initTypes).call(this);
|
|
27
|
+
}
|
|
28
|
+
async commandAction(logger, args) {
|
|
29
|
+
let administrativeUnit;
|
|
30
|
+
try {
|
|
31
|
+
if (args.options.id) {
|
|
32
|
+
administrativeUnit = await this.getAdministrativeUnitById(args.options.id);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
administrativeUnit = await aadAdministrativeUnit.getAdministrativeUnitByDisplayName(args.options.displayName);
|
|
36
|
+
}
|
|
37
|
+
await logger.log(administrativeUnit);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
this.handleRejectedODataJsonPromise(err);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async getAdministrativeUnitById(id) {
|
|
44
|
+
const requestOptions = {
|
|
45
|
+
url: `${this.resource}/v1.0/directory/administrativeUnits/${id}`,
|
|
46
|
+
headers: {
|
|
47
|
+
accept: 'application/json;odata.metadata=none'
|
|
48
|
+
},
|
|
49
|
+
responseType: 'json'
|
|
50
|
+
};
|
|
51
|
+
return await request.get(requestOptions);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
_AadAdministrativeUnitGetCommand_instances = new WeakSet(), _AadAdministrativeUnitGetCommand_initTelemetry = function _AadAdministrativeUnitGetCommand_initTelemetry() {
|
|
55
|
+
this.telemetry.push((args) => {
|
|
56
|
+
Object.assign(this.telemetryProperties, {
|
|
57
|
+
id: typeof args.options.id !== 'undefined',
|
|
58
|
+
displayName: typeof args.options.displayName !== 'undefined'
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}, _AadAdministrativeUnitGetCommand_initOptions = function _AadAdministrativeUnitGetCommand_initOptions() {
|
|
62
|
+
this.options.unshift({
|
|
63
|
+
option: '-i, --id [id]'
|
|
64
|
+
}, {
|
|
65
|
+
option: '-n, --displayName [displayName]'
|
|
66
|
+
});
|
|
67
|
+
}, _AadAdministrativeUnitGetCommand_initValidators = function _AadAdministrativeUnitGetCommand_initValidators() {
|
|
68
|
+
this.validators.push(async (args) => {
|
|
69
|
+
if (args.options.id && !validation.isValidGuid(args.options.id)) {
|
|
70
|
+
return `${args.options.id} is not a valid GUID`;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
});
|
|
74
|
+
}, _AadAdministrativeUnitGetCommand_initOptionSets = function _AadAdministrativeUnitGetCommand_initOptionSets() {
|
|
75
|
+
this.optionSets.push({ options: ['id', 'displayName'] });
|
|
76
|
+
}, _AadAdministrativeUnitGetCommand_initTypes = function _AadAdministrativeUnitGetCommand_initTypes() {
|
|
77
|
+
this.types.string.push('displayName');
|
|
78
|
+
};
|
|
79
|
+
export default new AadAdministrativeUnitGetCommand();
|
|
80
|
+
//# sourceMappingURL=administrativeunit-get.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { odata } from '../../../../utils/odata.js';
|
|
2
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
3
|
+
import commands from '../../commands.js';
|
|
4
|
+
class AadAdministrativeUnitListCommand extends GraphCommand {
|
|
5
|
+
get name() {
|
|
6
|
+
return commands.ADMINISTRATIVEUNIT_LIST;
|
|
7
|
+
}
|
|
8
|
+
get description() {
|
|
9
|
+
return 'Retrieves a list of administrative units';
|
|
10
|
+
}
|
|
11
|
+
defaultProperties() {
|
|
12
|
+
return ['id', 'displayName', 'visibility'];
|
|
13
|
+
}
|
|
14
|
+
async commandAction(logger) {
|
|
15
|
+
try {
|
|
16
|
+
const results = await odata.getAllItems(`${this.resource}/v1.0/directory/administrativeUnits`);
|
|
17
|
+
await logger.log(results);
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
this.handleRejectedODataJsonPromise(err);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export default new AadAdministrativeUnitListCommand();
|
|
25
|
+
//# sourceMappingURL=administrativeunit-list.js.map
|
|
@@ -0,0 +1,96 @@
|
|
|
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 _AadAdministrativeUnitRemoveCommand_instances, _AadAdministrativeUnitRemoveCommand_initTelemetry, _AadAdministrativeUnitRemoveCommand_initOptions, _AadAdministrativeUnitRemoveCommand_initOptionSets, _AadAdministrativeUnitRemoveCommand_initValidators, _AadAdministrativeUnitRemoveCommand_initTypes;
|
|
7
|
+
import { aadAdministrativeUnit } from '../../../../utils/aadAdministrativeUnit.js';
|
|
8
|
+
import { validation } from "../../../../utils/validation.js";
|
|
9
|
+
import request from "../../../../request.js";
|
|
10
|
+
import GraphCommand from "../../../base/GraphCommand.js";
|
|
11
|
+
import commands from "../../commands.js";
|
|
12
|
+
import { Cli } from "../../../../cli/Cli.js";
|
|
13
|
+
class AadAdministrativeUnitRemoveCommand extends GraphCommand {
|
|
14
|
+
get name() {
|
|
15
|
+
return commands.ADMINISTRATIVEUNIT_REMOVE;
|
|
16
|
+
}
|
|
17
|
+
get description() {
|
|
18
|
+
return 'Removes an administrative unit';
|
|
19
|
+
}
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
_AadAdministrativeUnitRemoveCommand_instances.add(this);
|
|
23
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitRemoveCommand_instances, "m", _AadAdministrativeUnitRemoveCommand_initOptions).call(this);
|
|
24
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitRemoveCommand_instances, "m", _AadAdministrativeUnitRemoveCommand_initValidators).call(this);
|
|
25
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitRemoveCommand_instances, "m", _AadAdministrativeUnitRemoveCommand_initOptionSets).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitRemoveCommand_instances, "m", _AadAdministrativeUnitRemoveCommand_initTelemetry).call(this);
|
|
27
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitRemoveCommand_instances, "m", _AadAdministrativeUnitRemoveCommand_initTypes).call(this);
|
|
28
|
+
}
|
|
29
|
+
async commandAction(logger, args) {
|
|
30
|
+
const removeAdministrativeUnit = async () => {
|
|
31
|
+
try {
|
|
32
|
+
let administrativeUnitId = args.options.id;
|
|
33
|
+
if (args.options.displayName) {
|
|
34
|
+
const administrativeUnit = await aadAdministrativeUnit.getAdministrativeUnitByDisplayName(args.options.displayName);
|
|
35
|
+
administrativeUnitId = administrativeUnit.id;
|
|
36
|
+
}
|
|
37
|
+
const requestOptions = {
|
|
38
|
+
url: `${this.resource}/v1.0/directory/administrativeUnits/${administrativeUnitId}`,
|
|
39
|
+
headers: {
|
|
40
|
+
accept: 'application/json;odata.metadata=none'
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
await request.delete(requestOptions);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
this.handleRejectedODataJsonPromise(err);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
if (args.options.force) {
|
|
50
|
+
await removeAdministrativeUnit();
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const result = await Cli.prompt({
|
|
54
|
+
type: 'confirm',
|
|
55
|
+
name: 'continue',
|
|
56
|
+
default: false,
|
|
57
|
+
message: `Are you sure you want to remove administrative unit '${args.options.id || args.options.displayName}'?`
|
|
58
|
+
});
|
|
59
|
+
if (result.continue) {
|
|
60
|
+
await removeAdministrativeUnit();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
_AadAdministrativeUnitRemoveCommand_instances = new WeakSet(), _AadAdministrativeUnitRemoveCommand_initTelemetry = function _AadAdministrativeUnitRemoveCommand_initTelemetry() {
|
|
66
|
+
this.telemetry.push((args) => {
|
|
67
|
+
Object.assign(this.telemetryProperties, {
|
|
68
|
+
id: args.options.id !== 'undefined',
|
|
69
|
+
displayName: args.options.displayName !== 'undefined',
|
|
70
|
+
force: !!args.options.force
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}, _AadAdministrativeUnitRemoveCommand_initOptions = function _AadAdministrativeUnitRemoveCommand_initOptions() {
|
|
74
|
+
this.options.unshift({
|
|
75
|
+
option: '-i, --id [id]'
|
|
76
|
+
}, {
|
|
77
|
+
option: '-n, --displayName [displayName]'
|
|
78
|
+
}, {
|
|
79
|
+
option: '-f, --force'
|
|
80
|
+
});
|
|
81
|
+
}, _AadAdministrativeUnitRemoveCommand_initOptionSets = function _AadAdministrativeUnitRemoveCommand_initOptionSets() {
|
|
82
|
+
this.optionSets.push({
|
|
83
|
+
options: ['id', 'displayName']
|
|
84
|
+
});
|
|
85
|
+
}, _AadAdministrativeUnitRemoveCommand_initValidators = function _AadAdministrativeUnitRemoveCommand_initValidators() {
|
|
86
|
+
this.validators.push(async (args) => {
|
|
87
|
+
if (args.options.id && !validation.isValidGuid(args.options.id)) {
|
|
88
|
+
return `${args.options.id} is not a valid GUID for option id.`;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
});
|
|
92
|
+
}, _AadAdministrativeUnitRemoveCommand_initTypes = function _AadAdministrativeUnitRemoveCommand_initTypes() {
|
|
93
|
+
this.types.string.push('id', 'displayName');
|
|
94
|
+
};
|
|
95
|
+
export default new AadAdministrativeUnitRemoveCommand();
|
|
96
|
+
//# sourceMappingURL=administrativeunit-remove.js.map
|
|
@@ -0,0 +1,146 @@
|
|
|
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 _AadGroupUserListCommand_instances, _AadGroupUserListCommand_initTelemetry, _AadGroupUserListCommand_initOptions, _AadGroupUserListCommand_initOptionSets, _AadGroupUserListCommand_initValidators;
|
|
7
|
+
import { aadGroup } from '../../../../utils/aadGroup.js';
|
|
8
|
+
import { odata } from '../../../../utils/odata.js';
|
|
9
|
+
import { validation } from '../../../../utils/validation.js';
|
|
10
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
11
|
+
import commands from '../../commands.js';
|
|
12
|
+
class AadGroupUserListCommand extends GraphCommand {
|
|
13
|
+
get name() {
|
|
14
|
+
return commands.GROUP_USER_LIST;
|
|
15
|
+
}
|
|
16
|
+
get description() {
|
|
17
|
+
return 'Lists users of a specific Azure AD group';
|
|
18
|
+
}
|
|
19
|
+
defaultProperties() {
|
|
20
|
+
return ['id', 'displayName', 'userPrincipalName', 'roles'];
|
|
21
|
+
}
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
_AadGroupUserListCommand_instances.add(this);
|
|
25
|
+
__classPrivateFieldGet(this, _AadGroupUserListCommand_instances, "m", _AadGroupUserListCommand_initTelemetry).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _AadGroupUserListCommand_instances, "m", _AadGroupUserListCommand_initOptions).call(this);
|
|
27
|
+
__classPrivateFieldGet(this, _AadGroupUserListCommand_instances, "m", _AadGroupUserListCommand_initOptionSets).call(this);
|
|
28
|
+
__classPrivateFieldGet(this, _AadGroupUserListCommand_instances, "m", _AadGroupUserListCommand_initValidators).call(this);
|
|
29
|
+
}
|
|
30
|
+
async commandAction(logger, args) {
|
|
31
|
+
try {
|
|
32
|
+
const groupId = await this.getGroupId(args.options, logger);
|
|
33
|
+
const users = [];
|
|
34
|
+
if (!args.options.role || args.options.role === 'Owner') {
|
|
35
|
+
const owners = await this.getUsers(args.options, 'Owners', groupId, logger);
|
|
36
|
+
owners.forEach(owner => users.push({ ...owner, roles: ['Owner'] }));
|
|
37
|
+
}
|
|
38
|
+
if (!args.options.role || args.options.role === 'Member') {
|
|
39
|
+
const members = await this.getUsers(args.options, 'Members', groupId, logger);
|
|
40
|
+
members.forEach((member) => {
|
|
41
|
+
const user = users.find((u) => u.id === member.id);
|
|
42
|
+
if (user !== undefined) {
|
|
43
|
+
user.roles.push('Member');
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
users.push({ ...member, roles: ['Member'] });
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
await logger.log(users);
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
this.handleRejectedODataJsonPromise(err);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async getGroupId(options, logger) {
|
|
57
|
+
if (options.groupId) {
|
|
58
|
+
return options.groupId;
|
|
59
|
+
}
|
|
60
|
+
if (this.verbose) {
|
|
61
|
+
await logger.logToStderr('Retrieving Group Id...');
|
|
62
|
+
}
|
|
63
|
+
return await aadGroup.getGroupIdByDisplayName(options.groupDisplayName);
|
|
64
|
+
}
|
|
65
|
+
async getUsers(options, role, groupId, logger) {
|
|
66
|
+
const { properties, filter } = options;
|
|
67
|
+
if (this.verbose) {
|
|
68
|
+
await logger.logToStderr(`Retrieving ${role} of the group with id ${groupId}`);
|
|
69
|
+
}
|
|
70
|
+
const selectProperties = properties ?
|
|
71
|
+
`${properties.split(',').filter(f => f.toLowerCase() !== 'id').concat('id').map(p => p.trim()).join(',')}` :
|
|
72
|
+
'id,displayName,userPrincipalName,givenName,surname';
|
|
73
|
+
const allSelectProperties = selectProperties.split(',');
|
|
74
|
+
const propertiesWithSlash = allSelectProperties.filter(item => item.includes('/'));
|
|
75
|
+
let fieldExpand = '';
|
|
76
|
+
propertiesWithSlash.forEach(p => {
|
|
77
|
+
if (fieldExpand.length > 0) {
|
|
78
|
+
fieldExpand += ',';
|
|
79
|
+
}
|
|
80
|
+
fieldExpand += `${p.split('/')[0]}($select=${p.split('/')[1]})`;
|
|
81
|
+
});
|
|
82
|
+
const expandParam = fieldExpand.length > 0 ? `&$expand=${fieldExpand}` : '';
|
|
83
|
+
const selectParam = allSelectProperties.filter(item => !item.includes('/'));
|
|
84
|
+
const endpoint = `${this.resource}/v1.0/groups/${groupId}/${role}/microsoft.graph.user?$select=${selectParam}${expandParam}`;
|
|
85
|
+
let users = [];
|
|
86
|
+
if (filter) {
|
|
87
|
+
// While using the filter, we need to specify the ConsistencyLevel header.
|
|
88
|
+
// Can be refactored when the header is no longer necessary.
|
|
89
|
+
const requestOptions = {
|
|
90
|
+
url: `${endpoint}&$filter=${encodeURIComponent(filter)}&$count=true`,
|
|
91
|
+
headers: {
|
|
92
|
+
accept: 'application/json;odata.metadata=none',
|
|
93
|
+
ConsistencyLevel: 'eventual'
|
|
94
|
+
},
|
|
95
|
+
responseType: 'json'
|
|
96
|
+
};
|
|
97
|
+
users = await odata.getAllItems(requestOptions);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
users = await odata.getAllItems(endpoint);
|
|
101
|
+
}
|
|
102
|
+
return users;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
_AadGroupUserListCommand_instances = new WeakSet(), _AadGroupUserListCommand_initTelemetry = function _AadGroupUserListCommand_initTelemetry() {
|
|
106
|
+
this.telemetry.push((args) => {
|
|
107
|
+
Object.assign(this.telemetryProperties, {
|
|
108
|
+
groupId: typeof args.options.groupId !== 'undefined',
|
|
109
|
+
groupDisplayName: typeof args.options.groupDisplayName !== 'undefined',
|
|
110
|
+
role: typeof args.options.role !== 'undefined',
|
|
111
|
+
properties: typeof args.options.properties !== 'undefined',
|
|
112
|
+
filter: typeof args.options.filter !== 'undefined'
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}, _AadGroupUserListCommand_initOptions = function _AadGroupUserListCommand_initOptions() {
|
|
116
|
+
this.options.unshift({
|
|
117
|
+
option: "-i, --groupId [groupId]"
|
|
118
|
+
}, {
|
|
119
|
+
option: "-n, --groupDisplayName [groupDisplayName]"
|
|
120
|
+
}, {
|
|
121
|
+
option: "-r, --role [role]",
|
|
122
|
+
autocomplete: ["Owner", "Member"]
|
|
123
|
+
}, {
|
|
124
|
+
option: "-p, --properties [properties]"
|
|
125
|
+
}, {
|
|
126
|
+
option: "-f, --filter [filter]"
|
|
127
|
+
});
|
|
128
|
+
}, _AadGroupUserListCommand_initOptionSets = function _AadGroupUserListCommand_initOptionSets() {
|
|
129
|
+
this.optionSets.push({
|
|
130
|
+
options: ['groupId', 'groupDisplayName']
|
|
131
|
+
});
|
|
132
|
+
}, _AadGroupUserListCommand_initValidators = function _AadGroupUserListCommand_initValidators() {
|
|
133
|
+
this.validators.push(async (args) => {
|
|
134
|
+
if (args.options.groupId && !validation.isValidGuid(args.options.groupId)) {
|
|
135
|
+
return `${args.options.groupId} is not a valid GUID`;
|
|
136
|
+
}
|
|
137
|
+
if (args.options.role) {
|
|
138
|
+
if (['Owner', 'Member'].indexOf(args.options.role) === -1) {
|
|
139
|
+
return `${args.options.role} is not a valid role value. Allowed values Owner|Member`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
export default new AadGroupUserListCommand();
|
|
146
|
+
//# sourceMappingURL=group-user-list.js.map
|