@pnp/cli-microsoft365 6.3.0-beta.c3dc921 → 6.3.0-beta.e40d7b4
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.js +8 -0
- package/dist/Auth.js +0 -18
- package/dist/Command.js +12 -1
- package/dist/cli/Cli.js +42 -1
- package/dist/m365/aad/commands/group/group-list.js +2 -1
- package/dist/m365/aad/commands/user/user-add.js +223 -0
- package/dist/m365/aad/commands/user/user-license-list.js +99 -0
- package/dist/m365/aad/commands/user/user-recyclebinitem-clear.js +103 -0
- 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-remove.js +107 -0
- package/dist/m365/aad/commands.js +6 -0
- package/dist/m365/base/O365MgmtCommand.js +10 -0
- package/dist/m365/context/commands/option/option-list.js +54 -0
- package/dist/m365/context/commands.js +1 -0
- package/dist/m365/file/commands/convert/convert-pdf.js +7 -6
- package/dist/m365/flow/commands/environment/FlowEnvironmentDetails.js +3 -0
- package/dist/m365/flow/commands/environment/environment-get.js +26 -11
- package/dist/m365/flow/commands/run/run-list.js +55 -3
- package/dist/m365/graph/commands/changelog/changelog-list.js +3 -2
- package/dist/m365/onenote/commands/notebook/notebook-list.js +50 -53
- package/dist/m365/onenote/commands/page/page-list.js +2 -16
- package/dist/m365/outlook/commands/mail/mail-send.js +3 -2
- package/dist/m365/outlook/commands/message/message-get.js +4 -3
- package/dist/m365/pa/commands/environment/environment-get.js +13 -5
- package/dist/m365/planner/commands/plan/plan-add.js +20 -6
- package/dist/m365/planner/commands/plan/plan-get.js +40 -26
- package/dist/m365/planner/commands/plan/plan-list.js +24 -14
- package/dist/m365/planner/commands/plan/plan-remove.js +1 -1
- package/dist/m365/planner/commands/plan/plan-set.js +21 -10
- package/dist/m365/planner/commands/roster/roster-add.js +47 -0
- package/dist/m365/planner/commands/roster/roster-get.js +61 -0
- package/dist/m365/planner/commands/roster/roster-member-add.js +113 -0
- package/dist/m365/planner/commands/roster/roster-member-list.js +54 -0
- package/dist/m365/planner/commands/roster/roster-member-remove.js +140 -0
- package/dist/m365/planner/commands/roster/roster-remove.js +88 -0
- package/dist/m365/planner/commands/task/task-add.js +3 -0
- package/dist/m365/planner/commands/task/task-checklistitem-add.js +2 -1
- package/dist/m365/planner/commands/task/task-checklistitem-list.js +2 -1
- package/dist/m365/planner/commands.js +6 -0
- package/dist/m365/pp/commands/environment/environment-get.js +18 -9
- package/dist/m365/pp/commands/solution/solution-get.js +2 -1
- package/dist/m365/pp/commands/solution/solution-list.js +2 -1
- package/dist/m365/purview/commands/auditlog/auditlog-list.js +205 -0
- package/dist/m365/purview/commands/retentionevent/retentionevent-get.js +75 -0
- package/dist/m365/purview/commands/retentionevent/retentionevent-list.js +46 -0
- package/dist/m365/purview/commands/retentionevent/retentionevent-remove.js +97 -0
- package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-add.js +77 -0
- package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-get.js +75 -0
- package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-list.js +43 -0
- package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-remove.js +97 -0
- package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-set.js +90 -0
- package/dist/m365/purview/commands/retentionlabel/retentionlabel-add.js +5 -0
- package/dist/m365/purview/commands/retentionlabel/retentionlabel-get.js +5 -0
- package/dist/m365/purview/commands/retentionlabel/retentionlabel-list.js +5 -0
- package/dist/m365/purview/commands/retentionlabel/retentionlabel-remove.js +5 -0
- package/dist/m365/purview/commands/retentionlabel/retentionlabel-set.js +11 -1
- package/dist/m365/purview/commands.js +9 -0
- package/dist/m365/spfx/commands/project/WebApiPermissionRequests.js +3 -0
- package/dist/m365/spfx/commands/project/project-permissions-grant.js +81 -0
- package/dist/m365/spfx/commands.js +3 -2
- package/dist/m365/spo/commands/app/app-add.js +2 -1
- package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-add.js +95 -0
- package/dist/m365/spo/commands/customaction/customaction-get.js +17 -66
- package/dist/m365/spo/commands/customaction/customaction-list.js +2 -36
- package/dist/m365/spo/commands/customaction/customaction-remove.js +11 -18
- package/dist/m365/spo/commands/file/GraphFileDetails.js +0 -1
- package/dist/m365/spo/commands/file/file-sharinginfo-get.js +2 -1
- package/dist/m365/spo/commands/file/file-sharinglink-add.js +2 -22
- package/dist/m365/spo/commands/file/file-sharinglink-clear.js +137 -0
- package/dist/m365/spo/commands/file/file-sharinglink-get.js +2 -25
- package/dist/m365/spo/commands/file/file-sharinglink-list.js +9 -29
- package/dist/m365/spo/commands/file/file-sharinglink-remove.js +2 -25
- package/dist/m365/spo/commands/file/file-sharinglink-set.js +104 -0
- package/dist/m365/spo/commands/group/group-list.js +2 -1
- package/dist/m365/spo/commands/hubsite/hubsite-get.js +1 -1
- package/dist/m365/spo/commands/listitem/listitem-add.js +2 -1
- package/dist/m365/spo/commands/listitem/listitem-list.js +2 -1
- package/dist/m365/spo/commands/navigation/navigation-node-add.js +17 -3
- package/dist/m365/spo/commands/navigation/navigation-node-get.js +73 -0
- package/dist/m365/spo/commands/navigation/navigation-node-list.js +4 -7
- package/dist/m365/spo/commands/navigation/navigation-node-set.js +118 -0
- package/dist/m365/spo/commands/page/page-column-get.js +2 -1
- package/dist/m365/spo/commands/page/page-column-list.js +2 -1
- package/dist/m365/spo/commands/page/page-section-get.js +2 -1
- package/dist/m365/spo/commands/page/page-section-list.js +2 -1
- package/dist/m365/spo/commands/site/site-apppermission-add.js +2 -14
- package/dist/m365/spo/commands/site/site-apppermission-get.js +2 -14
- package/dist/m365/spo/commands/site/site-apppermission-list.js +2 -14
- package/dist/m365/spo/commands/site/site-apppermission-remove.js +2 -14
- package/dist/m365/spo/commands/site/site-apppermission-set.js +2 -14
- package/dist/m365/spo/commands/sitedesign/sitedesign-add.js +6 -0
- package/dist/m365/spo/commands/spo-search.js +2 -1
- package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-add.js +179 -0
- package/dist/m365/spo/commands/term/term-list.js +2 -1
- package/dist/m365/spo/commands/userprofile/userprofile-get.js +2 -2
- package/dist/m365/spo/commands/web/web-set.js +11 -4
- package/dist/m365/spo/commands.js +6 -0
- package/dist/m365/teams/commands/chat/chat-list.js +4 -4
- package/dist/m365/teams/commands/meeting/meeting-attendancereport-list.js +5 -5
- package/dist/m365/teams/commands/meeting/meeting-get.js +5 -5
- package/dist/m365/teams/commands/meeting/meeting-list.js +5 -4
- package/dist/m365/teams/commands/team/team-app-list.js +1 -1
- package/dist/m365/teams/commands/user/user-app-list.js +2 -1
- package/dist/m365/todo/commands/task/task-get.js +2 -1
- package/dist/m365/todo/commands/task/task-list.js +2 -1
- package/dist/m365/yammer/commands/yammer-search.js +2 -1
- package/dist/utils/aadUser.js +38 -0
- package/dist/utils/accessToken.js +1 -1
- package/dist/utils/planner.js +16 -5
- package/dist/utils/spo.js +116 -0
- package/docs/docs/cmd/aad/app/app-list.md +3 -0
- package/docs/docs/cmd/aad/user/user-add.md +168 -0
- package/docs/docs/cmd/aad/user/user-license-list.md +98 -0
- package/docs/docs/cmd/aad/user/user-recyclebinitem-clear.md +42 -0
- 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-remove.md +51 -0
- package/docs/docs/cmd/aad/user/user-set.md +2 -2
- package/docs/docs/cmd/context/option/option-list.md +63 -0
- package/docs/docs/cmd/flow/environment/environment-get.md +31 -3
- package/docs/docs/cmd/flow/run/run-list.md +21 -0
- package/docs/docs/cmd/login.md +26 -0
- package/docs/docs/cmd/logout.md +4 -0
- package/docs/docs/cmd/pa/app/app-get.md +24 -0
- package/docs/docs/cmd/pa/app/app-list.md +21 -0
- package/docs/docs/cmd/pa/connector/connector-list.md +17 -0
- package/docs/docs/cmd/pa/environment/environment-get.md +26 -2
- package/docs/docs/cmd/pa/environment/environment-list.md +19 -0
- package/docs/docs/cmd/planner/plan/plan-add.md +17 -6
- package/docs/docs/cmd/planner/plan/plan-get.md +21 -7
- package/docs/docs/cmd/planner/plan/plan-list.md +16 -2
- package/docs/docs/cmd/planner/plan/plan-remove.md +4 -0
- package/docs/docs/cmd/planner/plan/plan-set.md +10 -4
- package/docs/docs/cmd/planner/roster/roster-add.md +60 -0
- package/docs/docs/cmd/planner/roster/roster-get.md +73 -0
- package/docs/docs/cmd/planner/roster/roster-member-add.md +87 -0
- package/docs/docs/cmd/planner/roster/roster-member-list.md +76 -0
- package/docs/docs/cmd/planner/roster/roster-member-remove.md +51 -0
- package/docs/docs/cmd/planner/roster/roster-remove.md +48 -0
- package/docs/docs/cmd/pp/aibuildermodel/aibuildermodel-get.md +43 -0
- package/docs/docs/cmd/pp/aibuildermodel/aibuildermodel-list.md +43 -0
- package/docs/docs/cmd/pp/card/card-clone.md +12 -0
- package/docs/docs/cmd/pp/card/card-get.md +49 -0
- package/docs/docs/cmd/pp/card/card-list.md +49 -0
- package/docs/docs/cmd/pp/chatbot/chatbot-get.md +55 -0
- package/docs/docs/cmd/pp/chatbot/chatbot-list.md +36 -0
- package/docs/docs/cmd/pp/dataverse/dataverse-table-get.md +30 -0
- package/docs/docs/cmd/pp/dataverse/dataverse-table-list.md +30 -0
- package/docs/docs/cmd/pp/dataverse/dataverse-table-row-list.md +30 -0
- package/docs/docs/cmd/pp/environment/environment-get.md +19 -0
- package/docs/docs/cmd/pp/environment/environment-list.md +19 -0
- package/docs/docs/cmd/pp/gateway/gateway-get.md +19 -0
- package/docs/docs/cmd/pp/gateway/gateway-list.md +19 -0
- package/docs/docs/cmd/pp/managementapp/managementapp-add.md +12 -0
- package/docs/docs/cmd/pp/managementapp/managementapp-list.md +12 -0
- package/docs/docs/cmd/pp/solution/solution-get.md +14 -0
- package/docs/docs/cmd/pp/solution/solution-list.md +14 -0
- package/docs/docs/cmd/pp/solution/solution-publisher-get.md +20 -1
- package/docs/docs/cmd/pp/solution/solution-publisher-list.md +18 -0
- package/docs/docs/cmd/pp/tenant/tenant-settings-list.md +21 -0
- package/docs/docs/cmd/purview/auditlog/auditlog-list.md +123 -0
- package/docs/docs/cmd/purview/retentionevent/retentionevent-get.md +132 -0
- package/docs/docs/cmd/purview/retentionevent/retentionevent-list.md +107 -0
- package/docs/docs/cmd/purview/retentionevent/retentionevent-remove.md +45 -0
- package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-add.md +106 -0
- package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-get.md +103 -0
- package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-list.md +97 -0
- package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-remove.md +43 -0
- package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-set.md +43 -0
- package/docs/docs/cmd/purview/retentionlabel/retentionlabel-add.md +3 -0
- package/docs/docs/cmd/purview/retentionlabel/retentionlabel-get.md +3 -0
- package/docs/docs/cmd/purview/retentionlabel/retentionlabel-list.md +3 -0
- package/docs/docs/cmd/purview/retentionlabel/retentionlabel-remove.md +3 -0
- package/docs/docs/cmd/purview/retentionlabel/retentionlabel-set.md +3 -0
- package/docs/docs/cmd/request.md +74 -0
- package/docs/docs/cmd/spfx/project/project-permissions-grant.md +65 -0
- package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-add.md +56 -0
- package/docs/docs/cmd/spo/file/file-sharinglink-clear.md +46 -0
- package/docs/docs/cmd/spo/file/file-sharinglink-list.md +1 -1
- package/docs/docs/cmd/spo/file/file-sharinglink-set.md +104 -0
- 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 +19 -4
- package/docs/docs/cmd/spo/listitem/listitem-get.md +57 -0
- package/docs/docs/cmd/spo/listitem/listitem-isrecord.md +8 -2
- 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 +40 -3
- package/docs/docs/cmd/spo/navigation/navigation-node-get.md +91 -0
- package/docs/docs/cmd/spo/navigation/navigation-node-list.md +30 -0
- package/docs/docs/cmd/spo/navigation/navigation-node-remove.md +1 -1
- package/docs/docs/cmd/spo/navigation/navigation-node-set.md +59 -0
- package/docs/docs/cmd/spo/sitedesign/sitedesign-add.md +3 -0
- package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-add.md +59 -0
- package/docs/docs/cmd/spo/web/web-set.md +9 -0
- package/docs/docs/cmd/status.md +46 -0
- package/docs/docs/cmd/version.md +26 -0
- package/npm-shrinkwrap.json +911 -876
- package/package.json +12 -12
package/.eslintrc.js
CHANGED
|
@@ -7,9 +7,11 @@ const dictionary = [
|
|
|
7
7
|
'adaptive',
|
|
8
8
|
'ai',
|
|
9
9
|
'app',
|
|
10
|
+
'application',
|
|
10
11
|
'apply',
|
|
11
12
|
'approve',
|
|
12
13
|
'assets',
|
|
14
|
+
'audit',
|
|
13
15
|
'bin',
|
|
14
16
|
'builder',
|
|
15
17
|
'catalog',
|
|
@@ -19,8 +21,11 @@ const dictionary = [
|
|
|
19
21
|
'content',
|
|
20
22
|
'conversation',
|
|
21
23
|
'custom',
|
|
24
|
+
'customizer',
|
|
22
25
|
'dataverse',
|
|
23
26
|
'default',
|
|
27
|
+
'event',
|
|
28
|
+
'eventreceiver',
|
|
24
29
|
'external',
|
|
25
30
|
'externalize',
|
|
26
31
|
'fun',
|
|
@@ -43,6 +48,9 @@ const dictionary = [
|
|
|
43
48
|
'label',
|
|
44
49
|
'list',
|
|
45
50
|
'link',
|
|
51
|
+
'log',
|
|
52
|
+
'login',
|
|
53
|
+
'logout',
|
|
46
54
|
'management',
|
|
47
55
|
'member',
|
|
48
56
|
'messaging',
|
package/dist/Auth.js
CHANGED
|
@@ -573,24 +573,6 @@ class Auth {
|
|
|
573
573
|
getMsalCacheStorage() {
|
|
574
574
|
return new FileTokenStorage_1.FileTokenStorage(FileTokenStorage_1.FileTokenStorage.msalCacheFilePath());
|
|
575
575
|
}
|
|
576
|
-
static isAppOnlyAuth(accessToken) {
|
|
577
|
-
let isAppOnlyAuth;
|
|
578
|
-
if (!accessToken || accessToken.length === 0) {
|
|
579
|
-
return isAppOnlyAuth;
|
|
580
|
-
}
|
|
581
|
-
const chunks = accessToken.split('.');
|
|
582
|
-
if (chunks.length !== 3) {
|
|
583
|
-
return isAppOnlyAuth;
|
|
584
|
-
}
|
|
585
|
-
const tokenString = Buffer.from(chunks[1], 'base64').toString();
|
|
586
|
-
try {
|
|
587
|
-
const token = JSON.parse(tokenString);
|
|
588
|
-
isAppOnlyAuth = !token.upn;
|
|
589
|
-
}
|
|
590
|
-
catch (_a) {
|
|
591
|
-
}
|
|
592
|
-
return isAppOnlyAuth;
|
|
593
|
-
}
|
|
594
576
|
}
|
|
595
577
|
exports.Auth = Auth;
|
|
596
578
|
exports.default = new Auth();
|
package/dist/Command.js
CHANGED
|
@@ -481,7 +481,18 @@ class Command {
|
|
|
481
481
|
if (!l) {
|
|
482
482
|
return;
|
|
483
483
|
}
|
|
484
|
-
|
|
484
|
+
const title = this.getLogItemTitle(l);
|
|
485
|
+
const id = this.getLogItemId(l);
|
|
486
|
+
if (title && id) {
|
|
487
|
+
output.push(`## ${title} (${id})`, os.EOL, os.EOL);
|
|
488
|
+
}
|
|
489
|
+
else if (title) {
|
|
490
|
+
output.push(`## ${title}`, os.EOL, os.EOL);
|
|
491
|
+
}
|
|
492
|
+
else if (id) {
|
|
493
|
+
output.push(`## ${id}`, os.EOL, os.EOL);
|
|
494
|
+
}
|
|
495
|
+
output.push(`Property | Value`, os.EOL, `---------|-------`, os.EOL);
|
|
485
496
|
output.push(Object.keys(l).map(k => {
|
|
486
497
|
const value = l[k];
|
|
487
498
|
let stringValue = value;
|
package/dist/cli/Cli.js
CHANGED
|
@@ -118,6 +118,8 @@ class Cli {
|
|
|
118
118
|
}
|
|
119
119
|
try {
|
|
120
120
|
// process options before passing them on to validation stage
|
|
121
|
+
const contextCommandOptions = this.loadOptionsFromContext(this.commandToExecute.options, optionsWithoutShorts.options.debug);
|
|
122
|
+
optionsWithoutShorts.options = Object.assign(Object.assign({}, contextCommandOptions), optionsWithoutShorts.options);
|
|
121
123
|
yield this.commandToExecute.command.processOptions(optionsWithoutShorts.options);
|
|
122
124
|
}
|
|
123
125
|
catch (e) {
|
|
@@ -283,6 +285,42 @@ class Cli {
|
|
|
283
285
|
}
|
|
284
286
|
this.loadCommandFromFile(commandFilePath);
|
|
285
287
|
}
|
|
288
|
+
loadOptionsFromContext(commandOptions, debug) {
|
|
289
|
+
const filePath = '.m365rc.json';
|
|
290
|
+
let m365rc = {};
|
|
291
|
+
if (!fs.existsSync(filePath)) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (debug) {
|
|
295
|
+
Cli.error('found .m365rc.json file');
|
|
296
|
+
}
|
|
297
|
+
try {
|
|
298
|
+
const fileContents = fs.readFileSync(filePath, 'utf8');
|
|
299
|
+
if (fileContents) {
|
|
300
|
+
m365rc = JSON.parse(fileContents);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
catch (e) {
|
|
304
|
+
this.closeWithError(`Error parsing ${filePath}`, { options: {} });
|
|
305
|
+
}
|
|
306
|
+
if (!m365rc.context) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (debug) {
|
|
310
|
+
Cli.error('found context in .m365rc.json file');
|
|
311
|
+
}
|
|
312
|
+
const context = m365rc.context;
|
|
313
|
+
const foundOptions = {};
|
|
314
|
+
commandOptions.forEach(option => {
|
|
315
|
+
if (context[option.name]) {
|
|
316
|
+
foundOptions[option.name] = context[option.name];
|
|
317
|
+
if (debug) {
|
|
318
|
+
Cli.error(`returning ${option.name} option from context`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
return foundOptions;
|
|
323
|
+
}
|
|
286
324
|
/**
|
|
287
325
|
* Loads command from the specified file into CLI. If can't find the file
|
|
288
326
|
* or the file doesn't contain a command, loads all available commands.
|
|
@@ -458,7 +496,7 @@ class Cli {
|
|
|
458
496
|
// data so that returned objects contain only default properties specified
|
|
459
497
|
// on the current command. If there is no current command or the
|
|
460
498
|
// command doesn't specify default properties, return original data
|
|
461
|
-
if (
|
|
499
|
+
if (this.shouldTrimOutput(options.output)) {
|
|
462
500
|
const cli = Cli.getInstance();
|
|
463
501
|
const currentCommand = cli.commandToExecute;
|
|
464
502
|
if (arrayType === 'object' &&
|
|
@@ -753,6 +791,9 @@ class Cli {
|
|
|
753
791
|
}
|
|
754
792
|
});
|
|
755
793
|
}
|
|
794
|
+
static shouldTrimOutput(output) {
|
|
795
|
+
return output === 'text' || output === 'csv';
|
|
796
|
+
}
|
|
756
797
|
}
|
|
757
798
|
exports.Cli = Cli;
|
|
758
799
|
Cli.defaultHelpMode = 'full';
|
|
@@ -15,6 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
15
15
|
};
|
|
16
16
|
var _AadGroupListCommand_instances, _AadGroupListCommand_initTelemetry, _AadGroupListCommand_initOptions;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const Cli_1 = require("../../../../cli/Cli");
|
|
18
19
|
const odata_1 = require("../../../../utils/odata");
|
|
19
20
|
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
20
21
|
const commands_1 = require("../../commands");
|
|
@@ -39,7 +40,7 @@ class AadGroupListCommand extends GraphCommand_1.default {
|
|
|
39
40
|
const endpoint = args.options.deleted ? 'directory/deletedItems/microsoft.graph.group' : 'groups';
|
|
40
41
|
try {
|
|
41
42
|
const groups = yield odata_1.odata.getAllItems(`${this.resource}/v1.0/${endpoint}`);
|
|
42
|
-
if (args.options.output
|
|
43
|
+
if (Cli_1.Cli.shouldTrimOutput(args.options.output)) {
|
|
43
44
|
groups.forEach((group) => {
|
|
44
45
|
if (group.groupTypes && group.groupTypes.length > 0 && group.groupTypes[0] === 'Unified') {
|
|
45
46
|
group.groupType = 'Microsoft 365';
|
|
@@ -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,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
|
|
@@ -0,0 +1,103 @@
|
|
|
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 _AadUserRecycleBinItemClearCommand_instances, _AadUserRecycleBinItemClearCommand_initTelemetry, _AadUserRecycleBinItemClearCommand_initOptions;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const Cli_1 = require("../../../../cli/Cli");
|
|
19
|
+
const request_1 = require("../../../../request");
|
|
20
|
+
const odata_1 = require("../../../../utils/odata");
|
|
21
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
22
|
+
const commands_1 = require("../../commands");
|
|
23
|
+
class AadUserRecycleBinItemClearCommand extends GraphCommand_1.default {
|
|
24
|
+
get name() {
|
|
25
|
+
return commands_1.default.USER_RECYCLEBINITEM_CLEAR;
|
|
26
|
+
}
|
|
27
|
+
get description() {
|
|
28
|
+
return 'Removes all users from the tenant recycle bin';
|
|
29
|
+
}
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
_AadUserRecycleBinItemClearCommand_instances.add(this);
|
|
33
|
+
__classPrivateFieldGet(this, _AadUserRecycleBinItemClearCommand_instances, "m", _AadUserRecycleBinItemClearCommand_initTelemetry).call(this);
|
|
34
|
+
__classPrivateFieldGet(this, _AadUserRecycleBinItemClearCommand_instances, "m", _AadUserRecycleBinItemClearCommand_initOptions).call(this);
|
|
35
|
+
}
|
|
36
|
+
commandAction(logger, args) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const clearRecycleBinUsers = () => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
try {
|
|
40
|
+
const users = yield odata_1.odata.getAllItems(`${this.resource}/v1.0/directory/deletedItems/microsoft.graph.user?$select=id`);
|
|
41
|
+
if (this.verbose) {
|
|
42
|
+
logger.logToStderr(`Amount of users to permanently delete: ${users.length}`);
|
|
43
|
+
}
|
|
44
|
+
const batchRequests = users.map((user, index) => {
|
|
45
|
+
return {
|
|
46
|
+
id: index,
|
|
47
|
+
method: 'DELETE',
|
|
48
|
+
url: `/directory/deletedItems/${user.id}`
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
for (let i = 0; i < batchRequests.length; i += 20) {
|
|
52
|
+
const batchRequestChunk = batchRequests.slice(i, i + 20);
|
|
53
|
+
if (this.verbose) {
|
|
54
|
+
logger.logToStderr(`Deleting users: ${i + batchRequestChunk.length}/${users.length}`);
|
|
55
|
+
}
|
|
56
|
+
const requestOptions = {
|
|
57
|
+
url: `${this.resource}/v1.0/$batch`,
|
|
58
|
+
headers: {
|
|
59
|
+
accept: 'application/json',
|
|
60
|
+
'content-type': 'application/json'
|
|
61
|
+
},
|
|
62
|
+
responseType: 'json',
|
|
63
|
+
data: {
|
|
64
|
+
requests: batchRequestChunk
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
yield request_1.default.post(requestOptions);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
this.handleRejectedODataJsonPromise(err);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (args.options.confirm) {
|
|
75
|
+
yield clearRecycleBinUsers();
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const result = yield Cli_1.Cli.prompt({
|
|
79
|
+
type: 'confirm',
|
|
80
|
+
name: 'continue',
|
|
81
|
+
default: false,
|
|
82
|
+
message: 'Are you sure you want to permanently delete all deleted users?'
|
|
83
|
+
});
|
|
84
|
+
if (result.continue) {
|
|
85
|
+
yield clearRecycleBinUsers();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
_AadUserRecycleBinItemClearCommand_instances = new WeakSet(), _AadUserRecycleBinItemClearCommand_initTelemetry = function _AadUserRecycleBinItemClearCommand_initTelemetry() {
|
|
92
|
+
this.telemetry.push((args) => {
|
|
93
|
+
Object.assign(this.telemetryProperties, {
|
|
94
|
+
confirm: !!args.options.confirm
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}, _AadUserRecycleBinItemClearCommand_initOptions = function _AadUserRecycleBinItemClearCommand_initOptions() {
|
|
98
|
+
this.options.unshift({
|
|
99
|
+
option: '--confirm'
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
module.exports = new AadUserRecycleBinItemClearCommand();
|
|
103
|
+
//# sourceMappingURL=user-recyclebinitem-clear.js.map
|
|
@@ -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 AadUserRecycleBinItemListCommand extends GraphCommand_1.default {
|
|
16
|
+
get name() {
|
|
17
|
+
return commands_1.default.USER_RECYCLEBINITEM_LIST;
|
|
18
|
+
}
|
|
19
|
+
get description() {
|
|
20
|
+
return 'Lists users from the recycle bin in the current tenant';
|
|
21
|
+
}
|
|
22
|
+
defaultProperties() {
|
|
23
|
+
return ['id', 'displayName', 'userPrincipalName'];
|
|
24
|
+
}
|
|
25
|
+
commandAction(logger) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
if (this.verbose) {
|
|
28
|
+
logger.logToStderr('Retrieving users from the recycle bin...');
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const users = yield odata_1.odata.getAllItems(`${this.resource}/v1.0/directory/deletedItems/microsoft.graph.user`);
|
|
32
|
+
logger.log(users);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
this.handleRejectedODataJsonPromise(err);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
module.exports = new AadUserRecycleBinItemListCommand();
|
|
41
|
+
//# sourceMappingURL=user-recyclebinitem-list.js.map
|