@pnp/cli-microsoft365 6.3.0-beta.fee5cdb → 6.3.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/dist/appInsights.js +2 -1
- package/dist/cli/Cli.js +70 -2
- package/dist/m365/aad/commands/license/license-list.js +41 -0
- package/dist/m365/aad/commands/user/user-add.js +223 -0
- package/dist/m365/aad/commands/user/user-license-add.js +88 -0
- package/dist/m365/aad/commands/user/user-license-list.js +99 -0
- package/dist/m365/aad/commands/user/user-license-remove.js +114 -0
- package/dist/m365/aad/commands/user/user-recyclebinitem-clear.js +1 -1
- package/dist/m365/aad/commands/user/user-recyclebinitem-list.js +41 -0
- package/dist/m365/aad/commands/user/user-recyclebinitem-remove.js +92 -0
- package/dist/m365/aad/commands/user/user-recyclebinitem-restore.js +77 -0
- package/dist/m365/aad/commands/user/user-remove.js +107 -0
- package/dist/m365/aad/commands.js +9 -0
- package/dist/m365/flow/commands/environment/FlowEnvironmentDetails.js +3 -0
- package/dist/m365/flow/commands/environment/environment-get.js +26 -11
- package/dist/m365/pp/commands/environment/environment-get.js +18 -9
- package/dist/m365/spo/commands/file/file-move.js +0 -2
- package/dist/m365/spo/commands/folder/folder-copy.js +0 -2
- package/dist/m365/spo/commands/folder/folder-move.js +0 -2
- package/dist/m365/spo/commands/site/site-add.js +0 -3
- package/dist/m365/spo/commands/site/site-remove.js +0 -3
- package/dist/m365/spo/commands/site/site-set.js +0 -2
- package/dist/m365/spo/commands/tenant/tenant-recyclebinitem-remove.js +0 -1
- package/dist/m365/teams/commands/team/team-add.js +3 -8
- package/dist/utils/session.js +18 -0
- package/dist/utils/spo.js +3 -12
- package/docs/docs/cmd/aad/license/license-list.md +87 -0
- package/docs/docs/cmd/aad/user/user-add.md +168 -0
- package/docs/docs/cmd/aad/user/user-license-add.md +108 -0
- package/docs/docs/cmd/aad/user/user-license-list.md +98 -0
- package/docs/docs/cmd/aad/user/user-license-remove.md +43 -0
- package/docs/docs/cmd/aad/user/user-recyclebinitem-clear.md +1 -1
- package/docs/docs/cmd/aad/user/user-recyclebinitem-list.md +82 -0
- package/docs/docs/cmd/aad/user/user-recyclebinitem-remove.md +45 -0
- package/docs/docs/cmd/aad/user/user-recyclebinitem-restore.md +99 -0
- package/docs/docs/cmd/aad/user/user-remove.md +51 -0
- package/docs/docs/cmd/aad/user/user-set.md +1 -1
- package/docs/docs/cmd/flow/environment/environment-get.md +31 -3
- package/docs/docs/cmd/spo/homesite/homesite-get.md +20 -1
- package/docs/docs/cmd/spo/homesite/homesite-remove.md +8 -2
- package/docs/docs/cmd/spo/homesite/homesite-set.md +8 -2
- package/docs/docs/cmd/spo/hubsite/hubsite-connect.md +9 -9
- package/docs/docs/cmd/spo/hubsite/hubsite-data-get.md +34 -5
- package/docs/docs/cmd/spo/hubsite/hubsite-disconnect.md +6 -6
- package/docs/docs/cmd/spo/hubsite/hubsite-get.md +36 -19
- package/docs/docs/cmd/spo/hubsite/hubsite-list.md +59 -1
- package/docs/docs/cmd/spo/hubsite/hubsite-register.md +30 -1
- package/docs/docs/cmd/spo/hubsite/hubsite-rights-grant.md +6 -6
- package/docs/docs/cmd/spo/hubsite/hubsite-rights-revoke.md +4 -4
- package/docs/docs/cmd/spo/hubsite/hubsite-set.md +40 -15
- package/docs/docs/cmd/spo/hubsite/hubsite-unregister.md +4 -4
- package/docs/docs/cmd/spo/knowledgehub/knowledgehub-get.md +7 -1
- package/docs/docs/cmd/spo/knowledgehub/knowledgehub-remove.md +9 -3
- package/docs/docs/cmd/spo/knowledgehub/knowledgehub-set.md +8 -2
- package/docs/docs/cmd/spo/list/list-add.md +123 -57
- package/docs/docs/cmd/spo/list/list-contenttype-add.md +50 -5
- package/docs/docs/cmd/spo/list/list-contenttype-default-set.md +4 -4
- package/docs/docs/cmd/spo/list/list-contenttype-list.md +49 -4
- package/docs/docs/cmd/spo/list/list-contenttype-remove.md +6 -6
- package/docs/docs/cmd/spo/list/list-get.md +70 -4
- package/docs/docs/cmd/spo/list/list-list.md +70 -2
- package/docs/docs/cmd/spo/list/list-remove.md +6 -6
- package/docs/docs/cmd/spo/list/list-retentionlabel-ensure.md +2 -2
- package/docs/docs/cmd/spo/list/list-retentionlabel-get.md +36 -3
- package/docs/docs/cmd/spo/list/list-retentionlabel-remove.md +3 -3
- package/docs/docs/cmd/spo/list/list-roleassignment-add.md +6 -6
- package/docs/docs/cmd/spo/list/list-roleassignment-remove.md +3 -3
- package/docs/docs/cmd/spo/list/list-roleinheritance-break.md +9 -9
- package/docs/docs/cmd/spo/list/list-roleinheritance-reset.md +7 -7
- package/docs/docs/cmd/spo/list/list-set.md +61 -61
- package/docs/docs/cmd/spo/list/list-sitescript-get.md +35 -3
- package/docs/docs/cmd/spo/list/list-view-add.md +66 -5
- package/docs/docs/cmd/spo/list/list-view-field-add.md +10 -10
- package/docs/docs/cmd/spo/list/list-view-get.md +61 -0
- package/docs/docs/cmd/spo/list/list-view-list.md +61 -0
- package/docs/docs/cmd/spo/list/list-view-set.md +1 -1
- package/docs/docs/cmd/spo/list/list-webhook-add.md +19 -0
- package/docs/docs/cmd/spo/list/list-webhook-get.md +19 -0
- package/docs/docs/cmd/spo/list/list-webhook-list.md +19 -0
- package/docs/docs/cmd/spo/listitem/listitem-add.md +29 -0
- package/docs/docs/cmd/spo/listitem/listitem-attachment-list.md +17 -2
- package/docs/docs/cmd/spo/listitem/listitem-get.md +57 -0
- package/docs/docs/cmd/spo/listitem/listitem-isrecord.md +6 -0
- package/docs/docs/cmd/spo/listitem/listitem-list.md +28 -0
- package/docs/docs/cmd/spo/listitem/listitem-record-declare.md +15 -0
- package/docs/docs/cmd/spo/listitem/listitem-set.md +30 -0
- package/docs/docs/cmd/spo/navigation/navigation-node-add.md +22 -0
- package/npm-shrinkwrap.json +1 -0
- package/package.json +3 -2
package/dist/appInsights.js
CHANGED
|
@@ -11,6 +11,7 @@ const crypto = require("crypto");
|
|
|
11
11
|
const fs = require("fs");
|
|
12
12
|
const path = require("path");
|
|
13
13
|
const pid_1 = require("./utils/pid");
|
|
14
|
+
const session_1 = require("./utils/session");
|
|
14
15
|
const config = appInsights.setup('6b908c80-d09f-4cf6-8274-e54349a0149a');
|
|
15
16
|
config.setInternalLogging(false, false);
|
|
16
17
|
// append -dev to the version number when ran locally
|
|
@@ -25,7 +26,7 @@ appInsights.defaultClient.commonProperties = {
|
|
|
25
26
|
env: env,
|
|
26
27
|
ci: Boolean(process.env.CI).toString()
|
|
27
28
|
};
|
|
28
|
-
appInsights.defaultClient.context.tags['ai.session.id'] =
|
|
29
|
+
appInsights.defaultClient.context.tags['ai.session.id'] = session_1.session.getId(process.ppid);
|
|
29
30
|
appInsights.defaultClient.context.tags['ai.cloud.roleInstance'] = crypto.createHash('sha256').update(appInsights.defaultClient.context.tags['ai.cloud.roleInstance']).digest('hex');
|
|
30
31
|
delete appInsights.defaultClient.context.tags['ai.cloud.role'];
|
|
31
32
|
exports.default = appInsights.defaultClient;
|
package/dist/cli/Cli.js
CHANGED
|
@@ -12,17 +12,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.Cli = void 0;
|
|
13
13
|
const fs = require("fs");
|
|
14
14
|
const minimist = require("minimist");
|
|
15
|
+
const ora = require("ora");
|
|
15
16
|
const os = require("os");
|
|
16
17
|
const path = require("path");
|
|
17
18
|
const Command_1 = require("../Command");
|
|
18
19
|
const config_1 = require("../config");
|
|
19
20
|
const request_1 = require("../request");
|
|
20
21
|
const settingsNames_1 = require("../settingsNames");
|
|
22
|
+
const telemetry_1 = require("../telemetry");
|
|
21
23
|
const formatting_1 = require("../utils/formatting");
|
|
22
24
|
const fsUtil_1 = require("../utils/fsUtil");
|
|
23
25
|
const md_1 = require("../utils/md");
|
|
24
26
|
const validation_1 = require("../utils/validation");
|
|
25
|
-
const telemetry_1 = require("../telemetry");
|
|
26
27
|
const packageJSON = require('../../package.json');
|
|
27
28
|
class Cli {
|
|
28
29
|
get config() {
|
|
@@ -45,6 +46,7 @@ class Cli {
|
|
|
45
46
|
constructor() {
|
|
46
47
|
this.commands = [];
|
|
47
48
|
this.commandsFolder = '';
|
|
49
|
+
this.spinner = ora('Running command...');
|
|
48
50
|
}
|
|
49
51
|
static getInstance() {
|
|
50
52
|
if (!Cli.instance) {
|
|
@@ -118,6 +120,8 @@ class Cli {
|
|
|
118
120
|
}
|
|
119
121
|
try {
|
|
120
122
|
// process options before passing them on to validation stage
|
|
123
|
+
const contextCommandOptions = this.loadOptionsFromContext(this.commandToExecute.options, optionsWithoutShorts.options.debug);
|
|
124
|
+
optionsWithoutShorts.options = Object.assign(Object.assign({}, contextCommandOptions), optionsWithoutShorts.options);
|
|
121
125
|
yield this.commandToExecute.command.processOptions(optionsWithoutShorts.options);
|
|
122
126
|
}
|
|
123
127
|
catch (e) {
|
|
@@ -154,6 +158,11 @@ class Cli {
|
|
|
154
158
|
const cli = Cli.getInstance();
|
|
155
159
|
const parentCommandName = cli.currentCommandName;
|
|
156
160
|
cli.currentCommandName = command.getCommandName(cli.currentCommandName);
|
|
161
|
+
// don't show spinner if running tests
|
|
162
|
+
/* c8 ignore next 3 */
|
|
163
|
+
if (typeof global.it === 'undefined') {
|
|
164
|
+
cli.spinner.start();
|
|
165
|
+
}
|
|
157
166
|
try {
|
|
158
167
|
yield command.action(logger, args);
|
|
159
168
|
if (args.options.debug || args.options.verbose) {
|
|
@@ -164,6 +173,10 @@ class Cli {
|
|
|
164
173
|
finally {
|
|
165
174
|
// restore the original command name
|
|
166
175
|
cli.currentCommandName = parentCommandName;
|
|
176
|
+
/* c8 ignore next 3 */
|
|
177
|
+
if (cli.spinner.isSpinning) {
|
|
178
|
+
cli.spinner.stop();
|
|
179
|
+
}
|
|
167
180
|
}
|
|
168
181
|
});
|
|
169
182
|
}
|
|
@@ -283,6 +296,42 @@ class Cli {
|
|
|
283
296
|
}
|
|
284
297
|
this.loadCommandFromFile(commandFilePath);
|
|
285
298
|
}
|
|
299
|
+
loadOptionsFromContext(commandOptions, debug) {
|
|
300
|
+
const filePath = '.m365rc.json';
|
|
301
|
+
let m365rc = {};
|
|
302
|
+
if (!fs.existsSync(filePath)) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (debug) {
|
|
306
|
+
Cli.error('found .m365rc.json file');
|
|
307
|
+
}
|
|
308
|
+
try {
|
|
309
|
+
const fileContents = fs.readFileSync(filePath, 'utf8');
|
|
310
|
+
if (fileContents) {
|
|
311
|
+
m365rc = JSON.parse(fileContents);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
catch (e) {
|
|
315
|
+
this.closeWithError(`Error parsing ${filePath}`, { options: {} });
|
|
316
|
+
}
|
|
317
|
+
if (!m365rc.context) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (debug) {
|
|
321
|
+
Cli.error('found context in .m365rc.json file');
|
|
322
|
+
}
|
|
323
|
+
const context = m365rc.context;
|
|
324
|
+
const foundOptions = {};
|
|
325
|
+
commandOptions.forEach(option => {
|
|
326
|
+
if (context[option.name]) {
|
|
327
|
+
foundOptions[option.name] = context[option.name];
|
|
328
|
+
if (debug) {
|
|
329
|
+
Cli.error(`returning ${option.name} option from context`);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
return foundOptions;
|
|
334
|
+
}
|
|
286
335
|
/**
|
|
287
336
|
* Loads command from the specified file into CLI. If can't find the file
|
|
288
337
|
* or the file doesn't contain a command, loads all available commands.
|
|
@@ -707,6 +756,10 @@ class Cli {
|
|
|
707
756
|
/* c8 ignore next */
|
|
708
757
|
}
|
|
709
758
|
static log(message, ...optionalParams) {
|
|
759
|
+
/* c8 ignore next 3 */
|
|
760
|
+
if (Cli.getInstance().spinner.isSpinning) {
|
|
761
|
+
Cli.getInstance().spinner.stop();
|
|
762
|
+
}
|
|
710
763
|
if (message) {
|
|
711
764
|
console.log(message, ...optionalParams);
|
|
712
765
|
}
|
|
@@ -715,6 +768,10 @@ class Cli {
|
|
|
715
768
|
}
|
|
716
769
|
}
|
|
717
770
|
static error(message, ...optionalParams) {
|
|
771
|
+
/* c8 ignore next 3 */
|
|
772
|
+
if (Cli.getInstance().spinner.isSpinning) {
|
|
773
|
+
Cli.getInstance().spinner.stop();
|
|
774
|
+
}
|
|
718
775
|
const errorOutput = Cli.getInstance().getSettingWithDefaultValue(settingsNames_1.settingsNames.errorOutput, 'stderr');
|
|
719
776
|
if (errorOutput === 'stdout') {
|
|
720
777
|
console.log(message, ...optionalParams);
|
|
@@ -726,7 +783,18 @@ class Cli {
|
|
|
726
783
|
static prompt(options) {
|
|
727
784
|
return __awaiter(this, void 0, void 0, function* () {
|
|
728
785
|
const inquirer = require('inquirer');
|
|
729
|
-
|
|
786
|
+
const spinnerSpinning = Cli.getInstance().spinner.isSpinning;
|
|
787
|
+
/* c8 ignore next 3 */
|
|
788
|
+
if (spinnerSpinning) {
|
|
789
|
+
Cli.getInstance().spinner.stop();
|
|
790
|
+
}
|
|
791
|
+
const response = yield inquirer.prompt(options);
|
|
792
|
+
// Restart the spinner if it was running before the prompt
|
|
793
|
+
/* c8 ignore next 3 */
|
|
794
|
+
if (spinnerSpinning) {
|
|
795
|
+
Cli.getInstance().spinner.start();
|
|
796
|
+
}
|
|
797
|
+
return response;
|
|
730
798
|
});
|
|
731
799
|
}
|
|
732
800
|
static removeShortOptions(args) {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const odata_1 = require("../../../../utils/odata");
|
|
13
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
14
|
+
const commands_1 = require("../../commands");
|
|
15
|
+
class AadLicenseListCommand extends GraphCommand_1.default {
|
|
16
|
+
get name() {
|
|
17
|
+
return commands_1.default.LICENSE_LIST;
|
|
18
|
+
}
|
|
19
|
+
get description() {
|
|
20
|
+
return 'Lists commercial subscriptions that an organization has acquired';
|
|
21
|
+
}
|
|
22
|
+
defaultProperties() {
|
|
23
|
+
return ['id', 'skuId', 'skuPartNumber'];
|
|
24
|
+
}
|
|
25
|
+
commandAction(logger) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
if (this.verbose) {
|
|
28
|
+
logger.logToStderr(`Retrieving the commercial subscriptions that an organization has acquired`);
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const items = yield odata_1.odata.getAllItems(`${this.resource}/v1.0/subscribedSkus`);
|
|
32
|
+
logger.log(items);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
this.handleRejectedODataJsonPromise(err);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
module.exports = new AadLicenseListCommand();
|
|
41
|
+
//# sourceMappingURL=license-list.js.map
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
12
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13
|
+
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");
|
|
14
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
15
|
+
};
|
|
16
|
+
var _AadUserAddCommand_instances, _AadUserAddCommand_initTelemetry, _AadUserAddCommand_initOptions, _AadUserAddCommand_initValidators, _AadUserAddCommand_initOptionSets, _AadUserAddCommand_initTypes;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const request_1 = require("../../../../request");
|
|
19
|
+
const validation_1 = require("../../../../utils/validation");
|
|
20
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
21
|
+
const commands_1 = require("../../commands");
|
|
22
|
+
class AadUserAddCommand extends GraphCommand_1.default {
|
|
23
|
+
get name() {
|
|
24
|
+
return commands_1.default.USER_ADD;
|
|
25
|
+
}
|
|
26
|
+
get description() {
|
|
27
|
+
return 'Creates a new user';
|
|
28
|
+
}
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
_AadUserAddCommand_instances.add(this);
|
|
32
|
+
__classPrivateFieldGet(this, _AadUserAddCommand_instances, "m", _AadUserAddCommand_initTelemetry).call(this);
|
|
33
|
+
__classPrivateFieldGet(this, _AadUserAddCommand_instances, "m", _AadUserAddCommand_initOptions).call(this);
|
|
34
|
+
__classPrivateFieldGet(this, _AadUserAddCommand_instances, "m", _AadUserAddCommand_initValidators).call(this);
|
|
35
|
+
__classPrivateFieldGet(this, _AadUserAddCommand_instances, "m", _AadUserAddCommand_initOptionSets).call(this);
|
|
36
|
+
__classPrivateFieldGet(this, _AadUserAddCommand_instances, "m", _AadUserAddCommand_initTypes).call(this);
|
|
37
|
+
}
|
|
38
|
+
commandAction(logger, args) {
|
|
39
|
+
var _a, _b, _c;
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
if (this.verbose) {
|
|
42
|
+
logger.logToStderr(`Adding user to AAD with displayName ${args.options.displayName} and userPrincipalName ${args.options.userName}`);
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const requestOptions = {
|
|
46
|
+
url: `${this.resource}/v1.0/users`,
|
|
47
|
+
headers: {
|
|
48
|
+
accept: 'application/json;odata.metadata=none'
|
|
49
|
+
},
|
|
50
|
+
responseType: 'json',
|
|
51
|
+
data: {
|
|
52
|
+
accountEnabled: (_a = args.options.accountEnabled) !== null && _a !== void 0 ? _a : true,
|
|
53
|
+
displayName: args.options.displayName,
|
|
54
|
+
userPrincipalName: args.options.userName,
|
|
55
|
+
mailNickName: (_b = args.options.mailNickname) !== null && _b !== void 0 ? _b : args.options.userName.split('@')[0],
|
|
56
|
+
passwordProfile: {
|
|
57
|
+
forceChangePasswordNextSignIn: args.options.forceChangePasswordNextSignIn || false,
|
|
58
|
+
forceChangePasswordNextSignInWithMfa: args.options.forceChangePasswordNextSignInWithMfa || false,
|
|
59
|
+
password: (_c = args.options.password) !== null && _c !== void 0 ? _c : this.generatePassword()
|
|
60
|
+
},
|
|
61
|
+
givenName: args.options.firstName,
|
|
62
|
+
surName: args.options.lastName,
|
|
63
|
+
usageLocation: args.options.usageLocation,
|
|
64
|
+
officeLocation: args.options.officeLocation,
|
|
65
|
+
jobTitle: args.options.jobTitle,
|
|
66
|
+
companyName: args.options.companyName,
|
|
67
|
+
department: args.options.department,
|
|
68
|
+
preferredLanguage: args.options.preferredLanguage
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const user = yield request_1.default.post(requestOptions);
|
|
72
|
+
user.password = requestOptions.data.passwordProfile.password;
|
|
73
|
+
if (args.options.managerUserId || args.options.managerUserName) {
|
|
74
|
+
const managerRequestOptions = {
|
|
75
|
+
url: `${this.resource}/v1.0/users/${user.id}/manager/$ref`,
|
|
76
|
+
headers: {
|
|
77
|
+
accept: 'application/json;odata.metadata=none'
|
|
78
|
+
},
|
|
79
|
+
data: {
|
|
80
|
+
'@odata.id': `${this.resource}/v1.0/users/${args.options.managerUserId || args.options.managerUserName}`
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
yield request_1.default.put(managerRequestOptions);
|
|
84
|
+
}
|
|
85
|
+
logger.log(user);
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
this.handleRejectedODataJsonPromise(err);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Generate a password with at least: one digit, one lowercase chracter, one uppercase character and special character.
|
|
94
|
+
*/
|
|
95
|
+
generatePassword() {
|
|
96
|
+
const numberChars = '0123456789';
|
|
97
|
+
const upperChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
98
|
+
const lowerChars = 'abcdefghijklmnopqrstuvwxyz';
|
|
99
|
+
const specialChars = '-_@%$#*&';
|
|
100
|
+
const allChars = numberChars + upperChars + lowerChars + specialChars;
|
|
101
|
+
let randPasswordArray = Array(15);
|
|
102
|
+
randPasswordArray[0] = numberChars;
|
|
103
|
+
randPasswordArray[1] = upperChars;
|
|
104
|
+
randPasswordArray[2] = lowerChars;
|
|
105
|
+
randPasswordArray[3] = specialChars;
|
|
106
|
+
randPasswordArray = randPasswordArray.fill(allChars, 4);
|
|
107
|
+
const randomCharacterArray = randPasswordArray.map((charSet) => charSet[Math.floor(Math.random() * charSet.length)]);
|
|
108
|
+
return this.shuffleArray(randomCharacterArray).join('');
|
|
109
|
+
}
|
|
110
|
+
shuffleArray(characterArray) {
|
|
111
|
+
for (let i = characterArray.length - 1; i > 0; i--) {
|
|
112
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
113
|
+
const temp = characterArray[i];
|
|
114
|
+
characterArray[i] = characterArray[j];
|
|
115
|
+
characterArray[j] = temp;
|
|
116
|
+
}
|
|
117
|
+
return characterArray;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
_AadUserAddCommand_instances = new WeakSet(), _AadUserAddCommand_initTelemetry = function _AadUserAddCommand_initTelemetry() {
|
|
121
|
+
this.telemetry.push((args) => {
|
|
122
|
+
Object.assign(this.telemetryProperties, {
|
|
123
|
+
accountEnabled: typeof args.options.accountEnabled !== 'undefined',
|
|
124
|
+
mailNickname: typeof args.options.mailNickname !== 'undefined',
|
|
125
|
+
password: typeof args.options.password !== 'undefined',
|
|
126
|
+
firstName: typeof args.options.firstName !== 'undefined',
|
|
127
|
+
lastName: typeof args.options.lastName !== 'undefined',
|
|
128
|
+
forceChangePasswordNextSignIn: !!args.options.forceChangePasswordNextSignIn,
|
|
129
|
+
forceChangePasswordNextSignInWithMfa: !!args.options.forceChangePasswordNextSignInWithMfa,
|
|
130
|
+
usageLocation: typeof args.options.usageLocation !== 'undefined',
|
|
131
|
+
officeLocation: typeof args.options.officeLocation !== 'undefined',
|
|
132
|
+
jobTitle: typeof args.options.jobTitle !== 'undefined',
|
|
133
|
+
companyName: typeof args.options.companyName !== 'undefined',
|
|
134
|
+
department: typeof args.options.department !== 'undefined',
|
|
135
|
+
preferredLanguage: typeof args.options.preferredLanguage !== 'undefined',
|
|
136
|
+
managerUserId: typeof args.options.managerUserId !== 'undefined',
|
|
137
|
+
managerUserName: typeof args.options.managerUserName !== 'undefined'
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}, _AadUserAddCommand_initOptions = function _AadUserAddCommand_initOptions() {
|
|
141
|
+
this.options.unshift({
|
|
142
|
+
option: '--displayName <displayName>'
|
|
143
|
+
}, {
|
|
144
|
+
option: '--userName <userName>'
|
|
145
|
+
}, {
|
|
146
|
+
option: '--accountEnabled [accountEnabled]',
|
|
147
|
+
autocomplete: ['true', 'false']
|
|
148
|
+
}, {
|
|
149
|
+
option: '--mailNickname [mailNickname]'
|
|
150
|
+
}, {
|
|
151
|
+
option: '--password [password]'
|
|
152
|
+
}, {
|
|
153
|
+
option: '--firstName [firstName]'
|
|
154
|
+
}, {
|
|
155
|
+
option: '--lastName [lastName]'
|
|
156
|
+
}, {
|
|
157
|
+
option: '--forceChangePasswordNextSignIn'
|
|
158
|
+
}, {
|
|
159
|
+
option: '--forceChangePasswordNextSignInWithMfa'
|
|
160
|
+
}, {
|
|
161
|
+
option: '--usageLocation [usageLocation]'
|
|
162
|
+
}, {
|
|
163
|
+
option: '--officeLocation [officeLocation]'
|
|
164
|
+
}, {
|
|
165
|
+
option: '--jobTitle [jobTitle]'
|
|
166
|
+
}, {
|
|
167
|
+
option: '--companyName [companyName]'
|
|
168
|
+
}, {
|
|
169
|
+
option: '--department [department]'
|
|
170
|
+
}, {
|
|
171
|
+
option: '--preferredLanguage [preferredLanguage]'
|
|
172
|
+
}, {
|
|
173
|
+
option: '--managerUserId [managerUserId]'
|
|
174
|
+
}, {
|
|
175
|
+
option: '--managerUserName [managerUserName]'
|
|
176
|
+
});
|
|
177
|
+
}, _AadUserAddCommand_initValidators = function _AadUserAddCommand_initValidators() {
|
|
178
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
179
|
+
if (!validation_1.validation.isValidUserPrincipalName(args.options.userName)) {
|
|
180
|
+
return `${args.options.userName} is not a valid userName`;
|
|
181
|
+
}
|
|
182
|
+
if (args.options.usageLocation) {
|
|
183
|
+
const regex = new RegExp('^[a-zA-Z]{2}$');
|
|
184
|
+
if (!regex.test(args.options.usageLocation)) {
|
|
185
|
+
return `'${args.options.usageLocation}' is not a valid usageLocation.`;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (args.options.preferredLanguage && args.options.preferredLanguage.length < 2) {
|
|
189
|
+
return `'${args.options.preferredLanguage}' is not a valid preferredLanguage`;
|
|
190
|
+
}
|
|
191
|
+
if (args.options.firstName && args.options.firstName.length > 64) {
|
|
192
|
+
return `The maximum amount of characters for 'firstName' is 64.`;
|
|
193
|
+
}
|
|
194
|
+
if (args.options.lastName && args.options.lastName.length > 64) {
|
|
195
|
+
return `The maximum amount of characters for 'lastName' is 64.`;
|
|
196
|
+
}
|
|
197
|
+
if (args.options.jobTitle && args.options.jobTitle.length > 128) {
|
|
198
|
+
return `The maximum amount of characters for 'jobTitle' is 128.`;
|
|
199
|
+
}
|
|
200
|
+
if (args.options.companyName && args.options.companyName.length > 64) {
|
|
201
|
+
return `The maximum amount of characters for 'companyName' is 64.`;
|
|
202
|
+
}
|
|
203
|
+
if (args.options.department && args.options.department.length > 64) {
|
|
204
|
+
return `The maximum amount of characters for 'department' is 64.`;
|
|
205
|
+
}
|
|
206
|
+
if (args.options.managerUserName && !validation_1.validation.isValidUserPrincipalName(args.options.managerUserName)) {
|
|
207
|
+
return `'${args.options.managerUserName}' is not a valid user principal name.`;
|
|
208
|
+
}
|
|
209
|
+
if (args.options.managerUserId && !validation_1.validation.isValidGuid(args.options.managerUserId)) {
|
|
210
|
+
return `'${args.options.managerUserId}' is not a valid GUID.`;
|
|
211
|
+
}
|
|
212
|
+
return true;
|
|
213
|
+
}));
|
|
214
|
+
}, _AadUserAddCommand_initOptionSets = function _AadUserAddCommand_initOptionSets() {
|
|
215
|
+
this.optionSets.push({
|
|
216
|
+
options: ['managerUserId', 'managerUserName'],
|
|
217
|
+
runsWhen: (args) => args.options.managerId || args.options.managerUserName
|
|
218
|
+
});
|
|
219
|
+
}, _AadUserAddCommand_initTypes = function _AadUserAddCommand_initTypes() {
|
|
220
|
+
this.types.boolean.push('accountEnabled');
|
|
221
|
+
};
|
|
222
|
+
module.exports = new AadUserAddCommand();
|
|
223
|
+
//# sourceMappingURL=user-add.js.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
12
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13
|
+
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");
|
|
14
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
15
|
+
};
|
|
16
|
+
var _AadUserLicenseAddCommand_instances, _AadUserLicenseAddCommand_initTelemetry, _AadUserLicenseAddCommand_initOptions, _AadUserLicenseAddCommand_initValidators, _AadUserLicenseAddCommand_initOptionSets;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const request_1 = require("../../../../request");
|
|
19
|
+
const validation_1 = require("../../../../utils/validation");
|
|
20
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
21
|
+
const commands_1 = require("../../commands");
|
|
22
|
+
class AadUserLicenseAddCommand extends GraphCommand_1.default {
|
|
23
|
+
get name() {
|
|
24
|
+
return commands_1.default.USER_LICENSE_ADD;
|
|
25
|
+
}
|
|
26
|
+
get description() {
|
|
27
|
+
return 'Assigns a license to a user';
|
|
28
|
+
}
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
_AadUserLicenseAddCommand_instances.add(this);
|
|
32
|
+
__classPrivateFieldGet(this, _AadUserLicenseAddCommand_instances, "m", _AadUserLicenseAddCommand_initTelemetry).call(this);
|
|
33
|
+
__classPrivateFieldGet(this, _AadUserLicenseAddCommand_instances, "m", _AadUserLicenseAddCommand_initOptions).call(this);
|
|
34
|
+
__classPrivateFieldGet(this, _AadUserLicenseAddCommand_instances, "m", _AadUserLicenseAddCommand_initValidators).call(this);
|
|
35
|
+
__classPrivateFieldGet(this, _AadUserLicenseAddCommand_instances, "m", _AadUserLicenseAddCommand_initOptionSets).call(this);
|
|
36
|
+
}
|
|
37
|
+
commandAction(logger, args) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const addLicenses = args.options.ids.split(',').map(x => { return { "disabledPlans": [], "skuId": x }; });
|
|
40
|
+
const requestBody = { "addLicenses": addLicenses, "removeLicenses": [] };
|
|
41
|
+
const requestOptions = {
|
|
42
|
+
url: `${this.resource}/v1.0/users/${args.options.userId || args.options.userName}/assignLicense`,
|
|
43
|
+
headers: {
|
|
44
|
+
accept: 'application/json;odata.metadata=none'
|
|
45
|
+
},
|
|
46
|
+
data: requestBody,
|
|
47
|
+
responseType: 'json'
|
|
48
|
+
};
|
|
49
|
+
try {
|
|
50
|
+
const response = yield request_1.default.post(requestOptions);
|
|
51
|
+
logger.log(response);
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
this.handleRejectedODataJsonPromise(err);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
_AadUserLicenseAddCommand_instances = new WeakSet(), _AadUserLicenseAddCommand_initTelemetry = function _AadUserLicenseAddCommand_initTelemetry() {
|
|
60
|
+
this.telemetry.push((args) => {
|
|
61
|
+
Object.assign(this.telemetryProperties, {
|
|
62
|
+
userId: typeof args.options.userId !== 'undefined',
|
|
63
|
+
userName: typeof args.options.userName !== 'undefined'
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}, _AadUserLicenseAddCommand_initOptions = function _AadUserLicenseAddCommand_initOptions() {
|
|
67
|
+
this.options.unshift({
|
|
68
|
+
option: '--userId [userId]'
|
|
69
|
+
}, {
|
|
70
|
+
option: '--userName [userName]'
|
|
71
|
+
}, {
|
|
72
|
+
option: '--ids <ids>'
|
|
73
|
+
});
|
|
74
|
+
}, _AadUserLicenseAddCommand_initValidators = function _AadUserLicenseAddCommand_initValidators() {
|
|
75
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
if (args.options.userId && !validation_1.validation.isValidGuid(args.options.userId)) {
|
|
77
|
+
return `${args.options.userId} is not a valid GUID`;
|
|
78
|
+
}
|
|
79
|
+
if (args.options.ids && args.options.ids.split(',').some(e => !validation_1.validation.isValidGuid(e))) {
|
|
80
|
+
return `${args.options.ids} contains one or more invalid GUIDs`;
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
}));
|
|
84
|
+
}, _AadUserLicenseAddCommand_initOptionSets = function _AadUserLicenseAddCommand_initOptionSets() {
|
|
85
|
+
this.optionSets.push({ options: ['userId', 'userName'] });
|
|
86
|
+
};
|
|
87
|
+
module.exports = new AadUserLicenseAddCommand();
|
|
88
|
+
//# sourceMappingURL=user-license-add.js.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
12
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13
|
+
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");
|
|
14
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
15
|
+
};
|
|
16
|
+
var _AadUserLicenseListCommand_instances, _AadUserLicenseListCommand_initTelemetry, _AadUserLicenseListCommand_initOptions, _AadUserLicenseListCommand_initValidators, _AadUserLicenseListCommand_initOptionSets;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const accessToken_1 = require("../../../../utils/accessToken");
|
|
19
|
+
const odata_1 = require("../../../../utils/odata");
|
|
20
|
+
const validation_1 = require("../../../../utils/validation");
|
|
21
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
22
|
+
const commands_1 = require("../../commands");
|
|
23
|
+
const Auth_1 = require("../../../../Auth");
|
|
24
|
+
class AadUserLicenseListCommand extends GraphCommand_1.default {
|
|
25
|
+
get name() {
|
|
26
|
+
return commands_1.default.USER_LICENSE_LIST;
|
|
27
|
+
}
|
|
28
|
+
get description() {
|
|
29
|
+
return 'Lists the license details for a given user';
|
|
30
|
+
}
|
|
31
|
+
defaultProperties() {
|
|
32
|
+
return ['id', 'skuId', 'skuPartNumber'];
|
|
33
|
+
}
|
|
34
|
+
constructor() {
|
|
35
|
+
super();
|
|
36
|
+
_AadUserLicenseListCommand_instances.add(this);
|
|
37
|
+
__classPrivateFieldGet(this, _AadUserLicenseListCommand_instances, "m", _AadUserLicenseListCommand_initTelemetry).call(this);
|
|
38
|
+
__classPrivateFieldGet(this, _AadUserLicenseListCommand_instances, "m", _AadUserLicenseListCommand_initOptions).call(this);
|
|
39
|
+
__classPrivateFieldGet(this, _AadUserLicenseListCommand_instances, "m", _AadUserLicenseListCommand_initValidators).call(this);
|
|
40
|
+
__classPrivateFieldGet(this, _AadUserLicenseListCommand_instances, "m", _AadUserLicenseListCommand_initOptionSets).call(this);
|
|
41
|
+
}
|
|
42
|
+
commandAction(logger, args) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const isAppOnlyAccessToken = accessToken_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken);
|
|
45
|
+
if (isAppOnlyAccessToken && !args.options.userId && !args.options.userName) {
|
|
46
|
+
this.handleError(`Specify at least 'userId' or 'userName' when using application permissions.`);
|
|
47
|
+
}
|
|
48
|
+
if (this.verbose) {
|
|
49
|
+
logger.logToStderr(`Retrieving licenses from user: ${args.options.userId || args.options.userName || 'current user'}.`);
|
|
50
|
+
}
|
|
51
|
+
let requestUrl = `${this.resource}/v1.0/`;
|
|
52
|
+
if (args.options.userId || args.options.userName) {
|
|
53
|
+
requestUrl += `users/${args.options.userId || args.options.userName}`;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
requestUrl += 'me';
|
|
57
|
+
}
|
|
58
|
+
requestUrl += '/licenseDetails';
|
|
59
|
+
try {
|
|
60
|
+
const items = yield odata_1.odata.getAllItems(requestUrl);
|
|
61
|
+
logger.log(items);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
this.handleRejectedODataJsonPromise(err);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
_AadUserLicenseListCommand_instances = new WeakSet(), _AadUserLicenseListCommand_initTelemetry = function _AadUserLicenseListCommand_initTelemetry() {
|
|
70
|
+
this.telemetry.push((args) => {
|
|
71
|
+
Object.assign(this.telemetryProperties, {
|
|
72
|
+
userId: typeof args.options.userId !== 'undefined',
|
|
73
|
+
userName: typeof args.options.userName !== 'undefined'
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}, _AadUserLicenseListCommand_initOptions = function _AadUserLicenseListCommand_initOptions() {
|
|
77
|
+
this.options.unshift({
|
|
78
|
+
option: '--userId [userId]'
|
|
79
|
+
}, {
|
|
80
|
+
option: '--userName [userName]'
|
|
81
|
+
});
|
|
82
|
+
}, _AadUserLicenseListCommand_initValidators = function _AadUserLicenseListCommand_initValidators() {
|
|
83
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
if (args.options.userId && !validation_1.validation.isValidGuid(args.options.userId)) {
|
|
85
|
+
return `${args.options.userId} is not a valid GUID`;
|
|
86
|
+
}
|
|
87
|
+
if (args.options.userName && !validation_1.validation.isValidUserPrincipalName(args.options.userName)) {
|
|
88
|
+
return `${args.options.userName} is not a valid user principal name (UPN)`;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}));
|
|
92
|
+
}, _AadUserLicenseListCommand_initOptionSets = function _AadUserLicenseListCommand_initOptionSets() {
|
|
93
|
+
this.optionSets.push({
|
|
94
|
+
options: ['userId', 'userName'],
|
|
95
|
+
runsWhen: (args) => args.options.userId || args.options.userName
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
module.exports = new AadUserLicenseListCommand();
|
|
99
|
+
//# sourceMappingURL=user-license-list.js.map
|