@pnp/cli-microsoft365 5.3.0-beta.9caead4 → 5.3.0-beta.cb66cfd

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.
@@ -22,29 +22,14 @@ class AadAppRoleAssignmentListCommand extends GraphCommand_1.default {
22
22
  return ['resourceDisplayName', 'roleName'];
23
23
  }
24
24
  commandAction(logger, args, cb) {
25
- let sp;
26
- // get the service principal associated with the appId
27
- let spMatchQuery = '';
28
- if (args.options.appId) {
29
- spMatchQuery = `appId eq '${encodeURIComponent(args.options.appId)}'`;
30
- }
31
- else if (args.options.objectId) {
32
- spMatchQuery = `id eq '${encodeURIComponent(args.options.objectId)}'`;
33
- }
34
- else {
35
- spMatchQuery = `displayName eq '${encodeURIComponent(args.options.displayName)}'`;
36
- }
37
- this
38
- .getServicePrincipalForApp(spMatchQuery)
39
- .then((resp) => {
40
- if (!resp.value.length) {
41
- return Promise.reject('app registration not found');
42
- }
43
- sp = resp.value[0];
25
+ let spAppRoleAssignments;
26
+ this.getAppRoleAssignments(args.options)
27
+ .then((appRoleAssignments) => {
28
+ spAppRoleAssignments = appRoleAssignments;
44
29
  // the role assignment has an appRoleId but no name. To get the name,
45
30
  // we need to get all the roles from the resource. the resource is
46
31
  // a service principal. Multiple roles may have same resource id.
47
- const resourceIds = sp.appRoleAssignments.map((item) => item.resourceId);
32
+ const resourceIds = appRoleAssignments.map((item) => item.resourceId);
48
33
  const tasks = [];
49
34
  for (let i = 0; i < resourceIds.length; i++) {
50
35
  tasks.push(this.getServicePrincipal(resourceIds[i]));
@@ -55,7 +40,7 @@ class AadAppRoleAssignmentListCommand extends GraphCommand_1.default {
55
40
  // loop through all appRoleAssignments for the servicePrincipal
56
41
  // and lookup the appRole.Id in the resources[resourceId].appRoles array...
57
42
  const results = [];
58
- sp.appRoleAssignments.map((appRoleAssignment) => {
43
+ spAppRoleAssignments.map((appRoleAssignment) => {
59
44
  const resource = resources.find((r) => r.id === appRoleAssignment.resourceId);
60
45
  if (resource) {
61
46
  const appRole = resource.appRoles.find((r) => r.id === appRoleAssignment.appRoleId);
@@ -65,7 +50,9 @@ class AadAppRoleAssignmentListCommand extends GraphCommand_1.default {
65
50
  resourceDisplayName: appRoleAssignment.resourceDisplayName,
66
51
  resourceId: appRoleAssignment.resourceId,
67
52
  roleId: appRole.id,
68
- roleName: appRole.value
53
+ roleName: appRole.value,
54
+ created: appRoleAssignment.createdDateTime,
55
+ deleted: appRoleAssignment.deletedDateTime
69
56
  });
70
57
  }
71
58
  }
@@ -74,6 +61,52 @@ class AadAppRoleAssignmentListCommand extends GraphCommand_1.default {
74
61
  cb();
75
62
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
76
63
  }
64
+ getAppRoleAssignments(argOptions) {
65
+ return new Promise((resolve, reject) => {
66
+ if (argOptions.objectId) {
67
+ this.getSPAppRoleAssignments(argOptions.objectId)
68
+ .then((spAppRoleAssignments) => {
69
+ if (!spAppRoleAssignments.value.length) {
70
+ reject('no app role assignments found');
71
+ }
72
+ resolve(spAppRoleAssignments.value);
73
+ })
74
+ .catch((err) => {
75
+ reject(err);
76
+ });
77
+ }
78
+ else {
79
+ // Use existing way to get service principal object
80
+ let spMatchQuery = '';
81
+ if (argOptions.appId) {
82
+ spMatchQuery = `appId eq '${encodeURIComponent(argOptions.appId)}'`;
83
+ }
84
+ else {
85
+ spMatchQuery = `displayName eq '${encodeURIComponent(argOptions.displayName)}'`;
86
+ }
87
+ this.getServicePrincipalForApp(spMatchQuery)
88
+ .then((resp) => {
89
+ if (!resp.value.length) {
90
+ reject('app registration not found');
91
+ }
92
+ resolve(resp.value[0].appRoleAssignments);
93
+ })
94
+ .catch((err) => {
95
+ reject(err);
96
+ });
97
+ }
98
+ });
99
+ }
100
+ getSPAppRoleAssignments(spId) {
101
+ const spRequestOptions = {
102
+ url: `${this.resource}/v1.0/servicePrincipals/${spId}/appRoleAssignments`,
103
+ headers: {
104
+ accept: 'application/json'
105
+ },
106
+ responseType: 'json'
107
+ };
108
+ return request_1.default.get(spRequestOptions);
109
+ }
77
110
  getServicePrincipalForApp(filterParam) {
78
111
  const spRequestOptions = {
79
112
  url: `${this.resource}/v1.0/servicePrincipals?$expand=appRoleAssignments&$filter=${filterParam}`,
@@ -6,11 +6,11 @@ exports.default = {
6
6
  APP_DELETE: `${prefix} app delete`,
7
7
  APP_GET: `${prefix} app get`,
8
8
  APP_REMOVE: `${prefix} app remove`,
9
- APP_SET: `${prefix} app set`,
10
9
  APP_ROLE_ADD: `${prefix} app role add`,
11
10
  APP_ROLE_DELETE: `${prefix} app role delete`,
12
11
  APP_ROLE_LIST: `${prefix} app role list`,
13
12
  APP_ROLE_REMOVE: `${prefix} app role remove`,
13
+ APP_SET: `${prefix} app set`,
14
14
  APPROLEASSIGNMENT_ADD: `${prefix} approleassignment add`,
15
15
  APPROLEASSIGNMENT_LIST: `${prefix} approleassignment list`,
16
16
  APPROLEASSIGNMENT_REMOVE: `${prefix} approleassignment remove`,
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_1 = require("../../../cli");
4
+ const validation_1 = require("../../../utils/validation");
5
+ const settingsNames_1 = require("../../../settingsNames");
6
+ const AppCommand_1 = require("../../base/AppCommand");
7
+ const commands_1 = require("../commands");
8
+ class AppOpenCommand extends AppCommand_1.default {
9
+ get name() {
10
+ return commands_1.default.OPEN;
11
+ }
12
+ get description() {
13
+ return 'Opens Azure AD app in the Azure AD portal';
14
+ }
15
+ getTelemetryProperties(args) {
16
+ const telemetryProps = super.getTelemetryProperties(args);
17
+ telemetryProps.appId = typeof args.options.appId !== 'undefined';
18
+ telemetryProps.preview = typeof args.options.preview !== 'undefined';
19
+ return telemetryProps;
20
+ }
21
+ commandAction(logger, args, cb) {
22
+ this.logOrOpenUrl(args, logger)
23
+ .then(_ => cb(), (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
24
+ }
25
+ logOrOpenUrl(args, logger) {
26
+ return new Promise((resolve, reject) => {
27
+ const previewPrefix = args.options.preview === true ? "preview." : "";
28
+ const url = `https://${previewPrefix}portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/Overview/appId/${this.appId}/isMSAApp/`;
29
+ if (cli_1.Cli.getInstance().getSettingWithDefaultValue(settingsNames_1.settingsNames.autoOpenLinksInBrowser, false) === false) {
30
+ logger.log(`Use a web browser to open the page ${url}`);
31
+ return resolve();
32
+ }
33
+ logger.log(`Opening the following page in your browser: ${url}`);
34
+ // 'open' is required here so we can lazy load the dependency.
35
+ // _open is never set before hitting this line, but this check
36
+ // is implemented so that we can stub it when testing.
37
+ /* c8 ignore next 3 */
38
+ if (!this._open) {
39
+ this._open = require('open');
40
+ }
41
+ this._open(url).then(() => {
42
+ resolve();
43
+ }, (error) => {
44
+ reject(error);
45
+ });
46
+ });
47
+ }
48
+ options() {
49
+ const options = [
50
+ { option: '--appId [appId]' },
51
+ { option: '--preview' }
52
+ ];
53
+ const parentOptions = super.options();
54
+ return options.concat(parentOptions);
55
+ }
56
+ validate(args) {
57
+ if (args.options.appId && !validation_1.validation.isValidGuid(args.options.appId)) {
58
+ return `${args.options.appId} is not a valid GUID`;
59
+ }
60
+ return true;
61
+ }
62
+ }
63
+ module.exports = new AppOpenCommand();
64
+ //# sourceMappingURL=app-open.js.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'app';
4
4
  exports.default = {
5
5
  GET: `${prefix} get`,
6
+ OPEN: `${prefix} open`,
6
7
  PERMISSION_LIST: `${prefix} permission list`
7
8
  };
8
9
  //# sourceMappingURL=commands.js.map
@@ -0,0 +1,198 @@
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 request_1 = require("../../../../request");
13
+ const utils_1 = require("../../../../utils");
14
+ const GraphCommand_1 = require("../../../base/GraphCommand");
15
+ const commands_1 = require("../../commands");
16
+ class PlannerBucketGetCommand extends GraphCommand_1.default {
17
+ get name() {
18
+ return commands_1.default.BUCKET_GET;
19
+ }
20
+ get description() {
21
+ return 'Gets the Microsoft Planner bucket in a plan';
22
+ }
23
+ getTelemetryProperties(args) {
24
+ const telemetryProps = super.getTelemetryProperties(args);
25
+ telemetryProps.id = typeof args.options.id !== 'undefined';
26
+ telemetryProps.name = typeof args.options.name !== 'undefined';
27
+ telemetryProps.planId = typeof args.options.planId !== 'undefined';
28
+ telemetryProps.planName = typeof args.options.planName !== 'undefined';
29
+ telemetryProps.ownerGroupId = typeof args.options.ownerGroupId !== 'undefined';
30
+ telemetryProps.ownerGroupName = typeof args.options.ownerGroupName !== 'undefined';
31
+ return telemetryProps;
32
+ }
33
+ commandAction(logger, args, cb) {
34
+ this
35
+ .getBucketId(args)
36
+ .then((bucketId) => this.getBucketById(bucketId))
37
+ .then((bucket) => {
38
+ logger.log(bucket);
39
+ cb();
40
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
41
+ }
42
+ getBucketId(args) {
43
+ const { id, name } = args.options;
44
+ if (id) {
45
+ return Promise.resolve(id);
46
+ }
47
+ return this
48
+ .getPlanId(args)
49
+ .then((planId) => {
50
+ const requestOptions = {
51
+ url: `${this.resource}/v1.0/planner/plans/${planId}/buckets`,
52
+ headers: {
53
+ accept: 'application/json;odata.metadata=none'
54
+ },
55
+ responseType: 'json'
56
+ };
57
+ return request_1.default.get(requestOptions);
58
+ })
59
+ .then(buckets => {
60
+ const filteredBuckets = buckets.value.filter(b => name.toLowerCase() === b.name.toLowerCase());
61
+ if (!filteredBuckets.length) {
62
+ return Promise.reject(`The specified bucket ${name} does not exist`);
63
+ }
64
+ if (filteredBuckets.length > 1) {
65
+ return Promise.reject(`Multiple buckets with name ${name} found: ${filteredBuckets.map(x => x.id)}`);
66
+ }
67
+ return Promise.resolve(filteredBuckets[0].id.toString());
68
+ });
69
+ }
70
+ getPlanId(args) {
71
+ const { planId, planName } = args.options;
72
+ if (planId) {
73
+ return Promise.resolve(planId);
74
+ }
75
+ return this
76
+ .getGroupId(args)
77
+ .then(groupId => {
78
+ const requestOptions = {
79
+ url: `${this.resource}/v1.0/planner/plans?$filter=owner eq '${groupId}'`,
80
+ headers: {
81
+ accept: 'application/json;odata.metadata=none'
82
+ },
83
+ responseType: 'json'
84
+ };
85
+ return request_1.default.get(requestOptions);
86
+ })
87
+ .then(plans => {
88
+ const filteredPlans = plans.value.filter(p => p.title.toLowerCase() === planName.toLowerCase());
89
+ if (filteredPlans.length === 0) {
90
+ return Promise.reject(`The specified plan ${planName} does not exist`);
91
+ }
92
+ if (filteredPlans.length > 1) {
93
+ return Promise.reject(`Multiple plans with name ${planName} found: ${filteredPlans.map(x => x.id)}`);
94
+ }
95
+ return Promise.resolve(filteredPlans[0].id);
96
+ });
97
+ }
98
+ getBucketById(id) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ const requestOptions = {
101
+ url: `${this.resource}/v1.0/planner/buckets/${id}`,
102
+ headers: {
103
+ accept: 'application/json'
104
+ },
105
+ responseType: 'json'
106
+ };
107
+ return request_1.default.get(requestOptions);
108
+ });
109
+ }
110
+ getGroupId(args) {
111
+ const { ownerGroupId, ownerGroupName } = args.options;
112
+ if (ownerGroupId) {
113
+ return Promise.resolve(ownerGroupId);
114
+ }
115
+ const requestOptions = {
116
+ url: `${this.resource}/v1.0/groups?$filter=displayName eq '${encodeURIComponent(ownerGroupName)}'`,
117
+ headers: {
118
+ accept: 'application/json;odata.metadata=none'
119
+ },
120
+ responseType: 'json'
121
+ };
122
+ return request_1.default
123
+ .get(requestOptions)
124
+ .then(response => {
125
+ if (!response.value.length) {
126
+ return Promise.reject(`The specified owner group ${ownerGroupName} does not exist`);
127
+ }
128
+ if (response.value.length > 1) {
129
+ return Promise.reject(`Multiple owner groups with name ${ownerGroupName} found: ${response.value.map(x => x.id)}`);
130
+ }
131
+ return Promise.resolve(response.value[0].id);
132
+ });
133
+ }
134
+ options() {
135
+ const options = [
136
+ {
137
+ option: '-i, --id [id]'
138
+ },
139
+ {
140
+ option: '--name [name]'
141
+ },
142
+ {
143
+ option: '--planId [planId]'
144
+ },
145
+ {
146
+ option: '--planName [planName]'
147
+ },
148
+ {
149
+ option: '--ownerGroupId [ownerGroupId]'
150
+ },
151
+ {
152
+ option: '--ownerGroupName [ownerGroupName]'
153
+ }
154
+ ];
155
+ const parentOptions = super.options();
156
+ return options.concat(parentOptions);
157
+ }
158
+ validate(args) {
159
+ if (args.options.id) {
160
+ if (args.options.planId || args.options.planName || args.options.ownerGroupId || args.options.ownerGroupName) {
161
+ return 'Don\'t specify planId, planName, ownerGroupId or ownerGroupName when using id';
162
+ }
163
+ if (args.options.name) {
164
+ return 'Specify either id or name';
165
+ }
166
+ }
167
+ if (args.options.name) {
168
+ if (!args.options.planId && !args.options.planName) {
169
+ return 'Specify either planId or planName when using name';
170
+ }
171
+ if (args.options.planId && args.options.planName) {
172
+ return 'Specify either planId or planName when using name but not both';
173
+ }
174
+ if (args.options.planName) {
175
+ if (!args.options.ownerGroupId && !args.options.ownerGroupName) {
176
+ return 'Specify either ownerGroupId or ownerGroupName when using planName';
177
+ }
178
+ if (args.options.ownerGroupId && args.options.ownerGroupName) {
179
+ return 'Specify either ownerGroupId or ownerGroupName when using planName but not both';
180
+ }
181
+ if (args.options.ownerGroupId && !utils_1.validation.isValidGuid(args.options.ownerGroupId)) {
182
+ return `${args.options.ownerGroupId} is not a valid GUID`;
183
+ }
184
+ }
185
+ if (args.options.planId) {
186
+ if (args.options.ownerGroupId || args.options.ownerGroupName) {
187
+ return 'Don\'t specify ownerGroupId or ownerGroupName when using planId';
188
+ }
189
+ }
190
+ }
191
+ if (!args.options.id && !args.options.name) {
192
+ return 'Please specify id or name';
193
+ }
194
+ return true;
195
+ }
196
+ }
197
+ module.exports = new PlannerBucketGetCommand();
198
+ //# sourceMappingURL=bucket-get.js.map
@@ -6,6 +6,7 @@ exports.default = {
6
6
  BUCKET_LIST: `${prefix} bucket list`,
7
7
  BUCKET_SET: `${prefix} bucket set`,
8
8
  BUCKET_REMOVE: `${prefix} bucket remove`,
9
+ BUCKET_GET: `${prefix} bucket get`,
9
10
  PLAN_ADD: `${prefix} plan add`,
10
11
  PLAN_GET: `${prefix} plan get`,
11
12
  PLAN_DETAILS_GET: `${prefix} plan details get`,
@@ -0,0 +1,45 @@
1
+ # aad app open
2
+
3
+ Returns deep link of the current AD app to open the Azure portal on the Azure AD app registration management page.
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 app open [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `--appId [appId]`
14
+ : Optional Application (client) ID of the Azure AD application registration to open. Uses the app from the `.m365rc.json` file corresponding to the `appId`. If multiple apps are available, this will evade the prompt to choose an app. If the `appId` is not available in the list of apps, an error is thrown.
15
+
16
+ `--preview`
17
+ : Use to open the url of the Azure AD preview portal.
18
+
19
+ --8<-- "docs/cmd/_global.md"
20
+
21
+ ## Remarks
22
+
23
+ If config setting `autoOpenLinksInBrowser` is configured to true, the command will automatically open the link to the Azure Portal in the browser.
24
+
25
+ Gets the app from the `.m365rc.json` file in the current directory. If the `--appId` option is not used and multiple apps are available, it will prompt the user to choose one.
26
+
27
+ ## Examples
28
+
29
+ Prints the URL to the Azure AD application registration management page on the Azure Portal.
30
+
31
+ ```sh
32
+ m365 app open
33
+ ```
34
+
35
+ Prints the url of the Azure AD application registration management page on the preview Azure Portal.
36
+
37
+ ```sh
38
+ m365 app open --preview
39
+ ```
40
+
41
+ Prints the URL to the Azure AD application registration management page on the Azure Portal, evading a possible choice prompt in the case of multiple saved apps in the `.m365rc.json` file.
42
+
43
+ ```sh
44
+ m365 app open --appId d75be2e1-0204-4f95-857d-51a37cf40be8
45
+ ```
@@ -0,0 +1,57 @@
1
+ # planner bucket get
2
+
3
+ Gets the Microsoft Planner bucket in a plan
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 planner bucket get [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-i, --id [id]`
14
+ : ID of the bucket to retrieve details. Specify either `id` or `name` but not both.
15
+
16
+ `-name, --name [name]`
17
+ : Name of the bucket to retrieve details. Specify either `id` or `name` but not both.
18
+
19
+ `--planId [planId]`
20
+ : Plan ID to which the bucket belongs. Specify either `planId` or `planName` when using `name`.
21
+
22
+ `--planName [planName]`
23
+ : Plan Name to which the bucket belongs. Specify either `planId` or `planName` when using `name`.
24
+
25
+ `--ownerGroupId [ownerGroupId]`
26
+ : ID of the group to which the plan belongs. Specify `ownerGroupId` or `ownerGroupName` when using `planName`.
27
+
28
+ `--ownerGroupName [ownerGroupName]`
29
+ : Name of the group to which the plan belongs. Specify `ownerGroupId` or `ownerGroupName` when using `planName`.
30
+
31
+ --8<-- "docs/cmd/_global.md"
32
+
33
+ ## Examples
34
+
35
+ Gets the specified Microsoft Planner bucket
36
+
37
+ ```sh
38
+ m365 planner bucket get --id "5h1uuYFk4kKQ0hfoTUkRLpgALtYi"
39
+ ```
40
+
41
+ Gets the Microsoft Planner bucket in the PlanId xqQg5FS2LkCp935s-FIFm2QAFkHM
42
+
43
+ ```sh
44
+ m365 planner bucket get --name "Planner Bucket A" --planId "xqQg5FS2LkCp935s-FIFm2QAFkHM"
45
+ ```
46
+
47
+ Gets the Microsoft Planner bucket in the Plan _My Plan_ owned by group _My Group_
48
+
49
+ ```sh
50
+ m365 planner bucket get --name "Planner Bucket A" --planName "My Plan" --ownerGroupName "My Group"
51
+ ```
52
+
53
+ Gets the Microsoft Planner bucket in the Plan _My Plan_ owned by groupId ee0f40fc-b2f7-45c7-b62d-11b90dd2ea8e
54
+
55
+ ```sh
56
+ m365 planner bucket get --name "Planner Bucket A" --planName "My Plan" --ownerGroupId "ee0f40fc-b2f7-45c7-b62d-11b90dd2ea8e"
57
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "5.3.0-beta.9caead4",
3
+ "version": "5.3.0-beta.cb66cfd",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",