@pnp/cli-microsoft365 4.3.0-beta.e2f87dd → 4.3.0-beta.fa07425

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.
@@ -2,7 +2,15 @@
2
2
  "name": "CLI for Microsoft 365",
3
3
  "dockerFile": "Dockerfile",
4
4
  "settings": {
5
- "terminal.integrated.shell.linux": "/bin/zsh"
5
+ "terminal.integrated.profiles.linux": {
6
+ "zsh": {
7
+ "path": "/bin/zsh",
8
+ "args": [
9
+ "-l"
10
+ ]
11
+ }
12
+ },
13
+ "terminal.integrated.defaultProfile.linux": "zsh"
6
14
  },
7
15
  "postCreateCommand": "npm i && npm run clean && npm run build && npm link",
8
16
  "extensions": [
package/dist/Utils.js CHANGED
@@ -40,6 +40,9 @@ class Utils {
40
40
  }
41
41
  });
42
42
  }
43
+ static isValidGuidArray(guids) {
44
+ return guids.every(guid => this.isValidGuid(guid));
45
+ }
43
46
  static isValidGuid(guid) {
44
47
  const guidRegEx = new RegExp(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);
45
48
  return guidRegEx.test(guid);
package/dist/cli/Cli.js CHANGED
@@ -17,6 +17,7 @@ const path = require("path");
17
17
  const appInsights_1 = require("../appInsights");
18
18
  const Command_1 = require("../Command");
19
19
  const config_1 = require("../config");
20
+ const request_1 = require("../request");
20
21
  const settingsNames_1 = require("../settingsNames");
21
22
  const Utils_1 = require("../Utils");
22
23
  const packageJSON = require('../../package.json');
@@ -204,16 +205,20 @@ class Cli {
204
205
  }
205
206
  };
206
207
  if (args.options.debug) {
207
- Cli.log(`Executing command ${command.name} with options ${JSON.stringify(args)}`);
208
+ logErr.push(`Executing command ${command.name} with options ${JSON.stringify(args)}`);
208
209
  }
209
210
  // store the current command name, if any and set the name to the name of
210
211
  // the command to execute
211
212
  const cli = Cli.getInstance();
212
213
  const parentCommandName = cli.currentCommandName;
213
214
  cli.currentCommandName = command.getCommandName();
215
+ // store the current logger if any
216
+ const currentLogger = request_1.default.logger;
214
217
  command.action(logger, args, (err) => {
215
218
  // restore the original command name
216
219
  cli.currentCommandName = parentCommandName;
220
+ // restore the original logger
221
+ request_1.default.logger = currentLogger;
217
222
  if (err) {
218
223
  return reject({
219
224
  error: err,
@@ -416,11 +421,11 @@ class Cli {
416
421
  if (arrayType !== 'object') {
417
422
  return logStatement.join(os.EOL);
418
423
  }
419
- // if output type has been set to 'text', process the retrieved
424
+ // if output type has been set to 'text' or 'csv', process the retrieved
420
425
  // data so that returned objects contain only default properties specified
421
426
  // on the current command. If there is no current command or the
422
427
  // command doesn't specify default properties, return original data
423
- if (options.output === 'text') {
428
+ if (options.output === 'text' || options.output === 'csv') {
424
429
  const cli = Cli.getInstance();
425
430
  const currentCommand = cli.commandToExecute;
426
431
  if (arrayType === 'object' &&
@@ -440,6 +445,20 @@ class Cli {
440
445
  }
441
446
  }
442
447
  }
448
+ if (options.output === 'csv') {
449
+ const { stringify } = require('csv-stringify/sync');
450
+ /*
451
+ https://csv.js.org/stringify/options/
452
+ header: Display the column names on the first line if the columns option is provided or discovered.
453
+ escape: Single character used for escaping; only apply to characters matching the quote and the escape options default to ".
454
+ quote: The quote characters surrounding a field, defaults to the " (double quotation marks), an empty quote value will preserve the original field, whether it contains quotation marks or not.
455
+ quoted: Boolean, default to false, quote all the non-empty fields even if not required.
456
+ quotedEmpty: Quote empty strings and overrides quoted_string on empty strings when defined; default is false.
457
+ */
458
+ return stringify(logStatement, {
459
+ header: true
460
+ });
461
+ }
443
462
  // display object as a list of key-value pairs
444
463
  if (logStatement.length === 1) {
445
464
  const obj = logStatement[0];
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=Group.js.map
3
+ //# sourceMappingURL=GroupExtended.js.map
@@ -37,14 +37,14 @@ class AadO365GroupUserSetCommand extends GraphItemsListCommand_1.GraphItemsListC
37
37
  logger.logToStderr(this.items);
38
38
  logger.logToStderr('');
39
39
  }
40
- if (this.items.filter(i => i.userPrincipalName.toLocaleLowerCase() === args.options.userName.toLocaleLowerCase()).length <= 0) {
40
+ if (this.items.filter(i => args.options.userName.toUpperCase() === i.userPrincipalName.toUpperCase()).length <= 0) {
41
41
  const userNotInGroup = (typeof args.options.groupId !== 'undefined') ?
42
42
  'The specified user does not belong to the given Microsoft 365 Group. Please use the \'o365group user add\' command to add new users.' :
43
43
  'The specified user does not belong to the given Microsoft Teams team. Please use the \'graph teams user add\' command to add new users.';
44
44
  throw new Error(userNotInGroup);
45
45
  }
46
46
  if (args.options.role === "Owner") {
47
- const foundMember = this.items.find(e => e.userPrincipalName.toLocaleLowerCase() === args.options.userName.toLocaleLowerCase() && e.userType === 'Member');
47
+ const foundMember = this.items.find(e => args.options.userName.toUpperCase() === e.userPrincipalName.toUpperCase() && e.userType === 'Member');
48
48
  if (foundMember !== undefined) {
49
49
  const endpoint = `${this.resource}/v1.0/groups/${groupId}/owners/$ref`;
50
50
  const requestOptions = {
@@ -65,7 +65,7 @@ class AadO365GroupUserSetCommand extends GraphItemsListCommand_1.GraphItemsListC
65
65
  }
66
66
  }
67
67
  else {
68
- const foundOwner = this.items.find(e => e.userPrincipalName.toLocaleLowerCase() === args.options.userName.toLocaleLowerCase() && e.userType === 'Owner');
68
+ const foundOwner = this.items.find(e => args.options.userName.toUpperCase() === e.userPrincipalName.toUpperCase() && e.userType === 'Owner');
69
69
  if (foundOwner !== undefined) {
70
70
  const endpoint = `${this.resource}/v1.0/groups/${groupId}/owners/${foundOwner.id}/$ref`;
71
71
  const requestOptions = {
@@ -20,10 +20,20 @@ class AadUserGetCommand extends GraphCommand_1.default {
20
20
  }
21
21
  commandAction(logger, args, cb) {
22
22
  const properties = args.options.properties ?
23
- `?$select=${args.options.properties.split(',').map(p => encodeURIComponent(p.trim())).join(',')}` :
23
+ `&$select=${args.options.properties.split(',').map(p => encodeURIComponent(p.trim())).join(',')}` :
24
24
  '';
25
+ let requestUrl = `${this.resource}/v1.0/users`;
26
+ if (args.options.id) {
27
+ requestUrl += `?$filter=id eq '${encodeURIComponent(args.options.id)}'${properties}`;
28
+ }
29
+ else if (args.options.userName) {
30
+ requestUrl += `?$filter=userPrincipalName eq '${encodeURIComponent(args.options.userName)}'${properties}`;
31
+ }
32
+ else if (args.options.email) {
33
+ requestUrl += `?$filter=mail eq '${encodeURIComponent(args.options.email)}'${properties}`;
34
+ }
25
35
  const requestOptions = {
26
- url: `${this.resource}/v1.0/users/${encodeURIComponent(args.options.id ? args.options.id : args.options.userName)}${properties}`,
36
+ url: requestUrl,
27
37
  headers: {
28
38
  accept: 'application/json;odata.metadata=none'
29
39
  },
@@ -31,6 +41,18 @@ class AadUserGetCommand extends GraphCommand_1.default {
31
41
  };
32
42
  request_1.default
33
43
  .get(requestOptions)
44
+ .then((res) => {
45
+ if (res.value.length === 1) {
46
+ return Promise.resolve(res.value[0]);
47
+ }
48
+ const identifier = args.options.id ? `id ${args.options.id}`
49
+ : args.options.userName ? `user name ${args.options.userName}`
50
+ : `email ${args.options.email}`;
51
+ if (res.value.length === 0) {
52
+ return Promise.reject(`The specified user with ${identifier} does not exist`);
53
+ }
54
+ return Promise.reject(`Multiple users with ${identifier} found. Please disambiguate (user names): ${res.value.map(a => a.userPrincipalName).join(', ')} or (ids): ${res.value.map(a => a.id).join(', ')}`);
55
+ })
34
56
  .then((res) => {
35
57
  logger.log(res);
36
58
  cb();
@@ -44,6 +66,9 @@ class AadUserGetCommand extends GraphCommand_1.default {
44
66
  {
45
67
  option: '-n, --userName [userName]'
46
68
  },
69
+ {
70
+ option: '--email [email]'
71
+ },
47
72
  {
48
73
  option: '-p, --properties [properties]'
49
74
  }
@@ -52,11 +77,13 @@ class AadUserGetCommand extends GraphCommand_1.default {
52
77
  return options.concat(parentOptions);
53
78
  }
54
79
  validate(args) {
55
- if (!args.options.id && !args.options.userName) {
56
- return 'Specify either id or userName';
80
+ if (!args.options.id && !args.options.userName && !args.options.email) {
81
+ return 'Specify id, userName or email, one is required';
57
82
  }
58
- if (args.options.id && args.options.userName) {
59
- return 'Specify either id or userName but not both';
83
+ if ((args.options.id && args.options.email) ||
84
+ (args.options.id && args.options.userName) ||
85
+ (args.options.userName && args.options.email)) {
86
+ return 'Use either id, userName or email, but not all';
60
87
  }
61
88
  if (args.options.id &&
62
89
  !Utils_1.default.isValidGuid(args.options.id)) {
@@ -0,0 +1,266 @@
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 cli_1 = require("../../../../cli");
13
+ const request_1 = require("../../../../request");
14
+ const appGetCommand = require("../../../aad/commands/app/app-get");
15
+ const AppCommand_1 = require("../../../base/AppCommand");
16
+ const commands_1 = require("../../commands");
17
+ var GetServicePrincipal;
18
+ (function (GetServicePrincipal) {
19
+ GetServicePrincipal[GetServicePrincipal["withPermissions"] = 0] = "withPermissions";
20
+ GetServicePrincipal[GetServicePrincipal["withPermissionDefinitions"] = 1] = "withPermissionDefinitions";
21
+ })(GetServicePrincipal || (GetServicePrincipal = {}));
22
+ class AppPermissionListCommand extends AppCommand_1.default {
23
+ get name() {
24
+ return commands_1.default.PERMISSION_LIST;
25
+ }
26
+ get description() {
27
+ return 'Lists API permissions for the current AAD app';
28
+ }
29
+ commandAction(logger, args, cb) {
30
+ this
31
+ .getServicePrincipal({ appId: this.appId }, logger, GetServicePrincipal.withPermissions)
32
+ .then(servicePrincipal => {
33
+ if (servicePrincipal) {
34
+ // service principal found, get permissions from the service principal
35
+ return this.getServicePrincipalPermissions(servicePrincipal, logger);
36
+ }
37
+ else {
38
+ // service principal not found, get permissions from app registration
39
+ return this.getAppRegPermissions(this.appId, logger);
40
+ }
41
+ })
42
+ .then(permissions => {
43
+ logger.log(permissions);
44
+ cb();
45
+ }, err => this.handleRejectedODataJsonPromise(err, logger, cb));
46
+ }
47
+ getServicePrincipal(servicePrincipalInfo, logger, mode) {
48
+ var _a;
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ if (this.verbose) {
51
+ logger.logToStderr(`Retrieving service principal ${(_a = servicePrincipalInfo.appId) !== null && _a !== void 0 ? _a : servicePrincipalInfo.id}`);
52
+ }
53
+ const lookupUrl = servicePrincipalInfo.appId ? `?$filter=appId eq '${servicePrincipalInfo.appId}'&` : `/${servicePrincipalInfo.id}?`;
54
+ const requestOptions = {
55
+ url: `${this.resource}/v1.0/servicePrincipals${lookupUrl}$select=appId,id,displayName`,
56
+ headers: {
57
+ accept: 'application/json;odata.metadata=none'
58
+ },
59
+ responseType: 'json'
60
+ };
61
+ const response = yield request_1.default.get(requestOptions);
62
+ if ((servicePrincipalInfo.id && !response) ||
63
+ (servicePrincipalInfo.appId && response.value.length === 0)) {
64
+ return undefined;
65
+ }
66
+ const servicePrincipal = servicePrincipalInfo.appId ?
67
+ response.value[0] :
68
+ response;
69
+ if (this.verbose) {
70
+ logger.logToStderr(`Retrieving permissions for service principal ${servicePrincipal.id}...`);
71
+ }
72
+ const permissionsPromises = [];
73
+ switch (mode) {
74
+ case GetServicePrincipal.withPermissions:
75
+ const appRoleAssignmentsRequestOptions = {
76
+ url: `${this.resource}/v1.0/servicePrincipals/${servicePrincipal.id}/appRoleAssignments`,
77
+ headers: {
78
+ accept: 'application/json;odata.metadata=none'
79
+ },
80
+ responseType: 'json'
81
+ };
82
+ const oauth2PermissionGrantsRequestOptions = {
83
+ url: `${this.resource}/v1.0/servicePrincipals/${servicePrincipal.id}/oauth2PermissionGrants`,
84
+ headers: {
85
+ accept: 'application/json;odata.metadata=none'
86
+ },
87
+ responseType: 'json'
88
+ };
89
+ permissionsPromises.push(...[
90
+ request_1.default.get(appRoleAssignmentsRequestOptions),
91
+ request_1.default.get(oauth2PermissionGrantsRequestOptions)
92
+ ]);
93
+ break;
94
+ case GetServicePrincipal.withPermissionDefinitions:
95
+ const oauth2PermissionScopesRequestOptions = {
96
+ url: `${this.resource}/v1.0/servicePrincipals/${servicePrincipal.id}/oauth2PermissionScopes`,
97
+ headers: {
98
+ accept: 'application/json;odata.metadata=none'
99
+ },
100
+ responseType: 'json'
101
+ };
102
+ const appRolesRequestOptions = {
103
+ url: `${this.resource}/v1.0/servicePrincipals/${servicePrincipal.id}/appRoles`,
104
+ headers: {
105
+ accept: 'application/json;odata.metadata=none'
106
+ },
107
+ responseType: 'json'
108
+ };
109
+ permissionsPromises.push(...[
110
+ request_1.default.get(oauth2PermissionScopesRequestOptions),
111
+ request_1.default.get(appRolesRequestOptions)
112
+ ]);
113
+ break;
114
+ }
115
+ const permissions = yield Promise.all(permissionsPromises);
116
+ switch (mode) {
117
+ case GetServicePrincipal.withPermissions:
118
+ servicePrincipal.appRoleAssignments = permissions[0].value;
119
+ servicePrincipal.oauth2PermissionGrants = permissions[1].value;
120
+ break;
121
+ case GetServicePrincipal.withPermissionDefinitions:
122
+ servicePrincipal.oauth2PermissionScopes = permissions[0].value;
123
+ servicePrincipal.appRoles = permissions[1].value;
124
+ break;
125
+ }
126
+ return servicePrincipal;
127
+ });
128
+ }
129
+ getServicePrincipalPermissions(servicePrincipal, logger) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ if (this.verbose) {
132
+ logger.logToStderr(`Resolving permissions for the service principal...`);
133
+ }
134
+ const apiPermissions = [];
135
+ // hash table for resolving resource IDs to names
136
+ const resourceLookup = {};
137
+ // list of service principals for which to load permissions
138
+ const servicePrincipalsToResolve = [];
139
+ const appRoleAssignments = servicePrincipal.appRoleAssignments;
140
+ apiPermissions.push(...appRoleAssignments.map(appRoleAssignment => {
141
+ // store resource name for resolving OAuth2 grants
142
+ resourceLookup[appRoleAssignment.resourceId] = appRoleAssignment.resourceDisplayName;
143
+ // add to the list of service principals to load to get the app role
144
+ // display name
145
+ if (!servicePrincipalsToResolve.find(r => r.id === appRoleAssignment.resourceId)) {
146
+ servicePrincipalsToResolve.push({ id: appRoleAssignment.resourceId });
147
+ }
148
+ return {
149
+ resource: appRoleAssignment.resourceDisplayName,
150
+ // we store the app role ID temporarily and will later resolve to display name
151
+ permission: appRoleAssignment.appRoleId,
152
+ type: 'Application'
153
+ };
154
+ }));
155
+ const oauth2Grants = servicePrincipal.oauth2PermissionGrants;
156
+ oauth2Grants.forEach(oauth2Grant => {
157
+ var _a;
158
+ // see if we can resolve the resource name from the resources
159
+ // retrieved from app role assignments
160
+ const resource = (_a = resourceLookup[oauth2Grant.resourceId]) !== null && _a !== void 0 ? _a : oauth2Grant.resourceId;
161
+ if (resource === oauth2Grant.resourceId &&
162
+ !servicePrincipalsToResolve.find(r => r.id === oauth2Grant.resourceId)) {
163
+ // resource name not found in the resources
164
+ // add it to the list of resources to resolve
165
+ servicePrincipalsToResolve.push({ id: oauth2Grant.resourceId });
166
+ }
167
+ const scopes = oauth2Grant.scope.split(' ');
168
+ scopes.forEach(scope => {
169
+ apiPermissions.push({
170
+ resource,
171
+ permission: scope,
172
+ type: 'Delegated'
173
+ });
174
+ });
175
+ });
176
+ if (servicePrincipalsToResolve.length > 0) {
177
+ const servicePrincipals = yield Promise
178
+ .all(servicePrincipalsToResolve
179
+ .map(servicePrincipalInfo => this.getServicePrincipal(servicePrincipalInfo, logger, GetServicePrincipal.withPermissionDefinitions)));
180
+ servicePrincipals.forEach(servicePrincipal => {
181
+ apiPermissions.forEach(apiPermission => {
182
+ var _a, _b;
183
+ if (apiPermission.resource === servicePrincipal.id) {
184
+ apiPermission.resource = servicePrincipal.displayName;
185
+ }
186
+ if (apiPermission.resource === servicePrincipal.displayName &&
187
+ apiPermission.type === 'Application') {
188
+ apiPermission.permission = (_b = (_a = servicePrincipal.appRoles
189
+ .find(appRole => appRole.id === apiPermission.permission)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : apiPermission.permission;
190
+ }
191
+ });
192
+ });
193
+ }
194
+ return apiPermissions;
195
+ });
196
+ }
197
+ getAppRegistration(appId, logger) {
198
+ return __awaiter(this, void 0, void 0, function* () {
199
+ if (this.verbose) {
200
+ logger.logToStderr(`Retrieving Azure AD application registration ${appId}`);
201
+ }
202
+ const options = {
203
+ appId: appId,
204
+ output: 'json',
205
+ debug: this.debug,
206
+ verbose: this.verbose
207
+ };
208
+ const output = yield cli_1.Cli.executeCommandWithOutput(appGetCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
209
+ if (this.debug) {
210
+ logger.logToStderr(output.stderr);
211
+ }
212
+ return JSON.parse(output.stdout);
213
+ });
214
+ }
215
+ getAppRegPermissions(appId, logger) {
216
+ return __awaiter(this, void 0, void 0, function* () {
217
+ const application = yield this.getAppRegistration(appId, logger);
218
+ if (application.requiredResourceAccess.length === 0) {
219
+ return [];
220
+ }
221
+ const servicePrincipalsToResolve = application.requiredResourceAccess
222
+ .map(resourceAccess => {
223
+ return {
224
+ appId: resourceAccess.resourceAppId
225
+ };
226
+ });
227
+ const servicePrincipals = yield Promise
228
+ .all(servicePrincipalsToResolve.map(servicePrincipalInfo => this.getServicePrincipal(servicePrincipalInfo, logger, GetServicePrincipal.withPermissionDefinitions)));
229
+ const apiPermissions = [];
230
+ application.requiredResourceAccess.forEach(requiredResourceAccess => {
231
+ var _a;
232
+ const servicePrincipal = servicePrincipals
233
+ .find(servicePrincipal => (servicePrincipal === null || servicePrincipal === void 0 ? void 0 : servicePrincipal.appId) === requiredResourceAccess.resourceAppId);
234
+ const resourceName = (_a = servicePrincipal === null || servicePrincipal === void 0 ? void 0 : servicePrincipal.displayName) !== null && _a !== void 0 ? _a : requiredResourceAccess.resourceAppId;
235
+ requiredResourceAccess.resourceAccess.forEach(permission => {
236
+ apiPermissions.push({
237
+ resource: resourceName,
238
+ permission: this.getPermissionName(permission.id, permission.type, servicePrincipal),
239
+ type: permission.type === 'Role' ? 'Application' : 'Delegated'
240
+ });
241
+ });
242
+ });
243
+ return apiPermissions;
244
+ });
245
+ }
246
+ getPermissionName(permissionId, permissionType, servicePrincipal) {
247
+ var _a, _b, _c, _d;
248
+ if (!servicePrincipal) {
249
+ return permissionId;
250
+ }
251
+ switch (permissionType) {
252
+ case 'Role':
253
+ return (_b = (_a = servicePrincipal.appRoles
254
+ .find(appRole => appRole.id === permissionId)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : permissionId;
255
+ case 'Scope':
256
+ return (_d = (_c = servicePrincipal.oauth2PermissionScopes
257
+ .find(permissionScope => permissionScope.id === permissionId)) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : permissionId;
258
+ }
259
+ /* c8 ignore next 4 */
260
+ // permissionType is either 'Scope' or 'Role' but we need a safe default
261
+ // to avoid building errors. This code will never be reached.
262
+ return permissionId;
263
+ }
264
+ }
265
+ module.exports = new AppPermissionListCommand();
266
+ //# sourceMappingURL=permission-list.js.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const prefix = 'app';
4
+ exports.default = {
5
+ PERMISSION_LIST: `${prefix} permission list`
6
+ };
7
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fs = require("fs");
4
+ const cli_1 = require("../../cli");
5
+ const Command_1 = require("../../Command");
6
+ const Utils_1 = require("../../Utils");
7
+ class AppCommand extends Command_1.default {
8
+ get resource() {
9
+ return 'https://graph.microsoft.com';
10
+ }
11
+ action(logger, args, cb) {
12
+ const m365rcJsonPath = '.m365rc.json';
13
+ if (!fs.existsSync(m365rcJsonPath)) {
14
+ return cb(new Command_1.CommandError(`Could not find file: ${m365rcJsonPath}`));
15
+ }
16
+ try {
17
+ const m365rcJsonContents = fs.readFileSync(m365rcJsonPath, 'utf8');
18
+ if (!m365rcJsonContents) {
19
+ return cb(new Command_1.CommandError(`File ${m365rcJsonPath} is empty`));
20
+ }
21
+ this.m365rcJson = JSON.parse(m365rcJsonContents);
22
+ }
23
+ catch (e) {
24
+ return cb(new Command_1.CommandError(`Could not parse file: ${m365rcJsonPath}`));
25
+ }
26
+ if (!this.m365rcJson.apps ||
27
+ this.m365rcJson.apps.length === 0) {
28
+ return cb(new Command_1.CommandError(`No Azure AD apps found in ${m365rcJsonPath}`));
29
+ }
30
+ if (args.options.appId) {
31
+ if (!this.m365rcJson.apps.some(app => app.appId === args.options.appId)) {
32
+ return cb(new Command_1.CommandError(`App ${args.options.appId} not found in ${m365rcJsonPath}`));
33
+ }
34
+ this.appId = args.options.appId;
35
+ return super.action(logger, args, cb);
36
+ }
37
+ if (this.m365rcJson.apps.length === 1) {
38
+ this.appId = this.m365rcJson.apps[0].appId;
39
+ return super.action(logger, args, cb);
40
+ }
41
+ if (this.m365rcJson.apps.length > 1) {
42
+ cli_1.Cli.prompt({
43
+ message: `Multiple Azure AD apps found in ${m365rcJsonPath}. Which app would you like to use?`,
44
+ type: 'list',
45
+ choices: this.m365rcJson.apps.map((app, i) => {
46
+ return {
47
+ name: `${app.name} (${app.appId})`,
48
+ value: i
49
+ };
50
+ }),
51
+ default: 0,
52
+ name: 'appIdIndex'
53
+ }, (result) => {
54
+ this.appId = this.m365rcJson.apps[result.appIdIndex].appId;
55
+ super.action(logger, args, cb);
56
+ });
57
+ }
58
+ }
59
+ options() {
60
+ const options = [
61
+ {
62
+ option: '--appId [appId]'
63
+ }
64
+ ];
65
+ const parentOptions = super.options();
66
+ return options.concat(parentOptions);
67
+ }
68
+ validate(args) {
69
+ if (args.options.appId && !Utils_1.default.isValidGuid(args.options.appId)) {
70
+ return `${args.options.appId} is not a valid GUID`;
71
+ }
72
+ return true;
73
+ }
74
+ }
75
+ exports.default = AppCommand;
76
+ //# sourceMappingURL=AppCommand.js.map
@@ -12,8 +12,14 @@ class PaAppListCommand extends AzmgmtItemsListCommand_1.AzmgmtItemsListCommand {
12
12
  defaultProperties() {
13
13
  return ['name', 'displayName'];
14
14
  }
15
+ getTelemetryProperties(args) {
16
+ const telemetryProps = super.getTelemetryProperties(args);
17
+ telemetryProps.asAdmin = args.options.asAdmin === true;
18
+ telemetryProps.environment = typeof args.options.environment !== 'undefined';
19
+ return telemetryProps;
20
+ }
15
21
  commandAction(logger, args, cb) {
16
- const url = `${this.resource}providers/Microsoft.PowerApps/apps?api-version=2017-08-01`;
22
+ const url = `${this.resource}providers/Microsoft.PowerApps${args.options.asAdmin ? '/scopes/admin' : ''}${args.options.environment ? '/environments/' + encodeURIComponent(args.options.environment) : ''}/apps?api-version=2017-08-01`;
17
23
  this
18
24
  .getAllItems(url, logger, true)
19
25
  .then(() => {
@@ -31,6 +37,27 @@ class PaAppListCommand extends AzmgmtItemsListCommand_1.AzmgmtItemsListCommand {
31
37
  cb();
32
38
  }, (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
33
39
  }
40
+ options() {
41
+ const options = [
42
+ {
43
+ option: '-e, --environment [environment]'
44
+ },
45
+ {
46
+ option: '--asAdmin'
47
+ }
48
+ ];
49
+ const parentOptions = super.options();
50
+ return options.concat(parentOptions);
51
+ }
52
+ validate(args) {
53
+ if (args.options.asAdmin && !args.options.environment) {
54
+ return 'When specifying the asAdmin option the environment option is required as well';
55
+ }
56
+ if (args.options.environment && !args.options.asAdmin) {
57
+ return 'When specifying the environment option the asAdmin option is required as well';
58
+ }
59
+ return true;
60
+ }
34
61
  }
35
62
  module.exports = new PaAppListCommand();
36
63
  //# sourceMappingURL=app-list.js.map
@@ -0,0 +1,288 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const request_1 = require("../../../../request");
4
+ const Utils_1 = require("../../../../Utils");
5
+ const GraphCommand_1 = require("../../../base/GraphCommand");
6
+ const commands_1 = require("../../commands");
7
+ class PlannerTaskAddCommand extends GraphCommand_1.default {
8
+ get name() {
9
+ return commands_1.default.TASK_ADD;
10
+ }
11
+ get description() {
12
+ return 'Adds a new Microsoft Planner Task';
13
+ }
14
+ getTelemetryProperties(args) {
15
+ const telemetryProps = super.getTelemetryProperties(args);
16
+ telemetryProps.planId = typeof args.options.planId !== 'undefined';
17
+ telemetryProps.planName = typeof args.options.planName !== 'undefined';
18
+ telemetryProps.ownerGroupId = typeof args.options.ownerGroupId !== 'undefined';
19
+ telemetryProps.ownerGroupName = typeof args.options.ownerGroupName !== 'undefined';
20
+ telemetryProps.bucketId = typeof args.options.bucketId !== 'undefined';
21
+ telemetryProps.bucketName = typeof args.options.bucketName !== 'undefined';
22
+ telemetryProps.startDateTime = typeof args.options.startDateTime !== 'undefined';
23
+ telemetryProps.dueDateTime = typeof args.options.dueDateTime !== 'undefined';
24
+ telemetryProps.percentComplete = typeof args.options.percentComplete !== 'undefined';
25
+ telemetryProps.assignedToUserIds = typeof args.options.assignedToUserIds !== 'undefined';
26
+ telemetryProps.assignedToUserNames = typeof args.options.assignedToUserNames !== 'undefined';
27
+ telemetryProps.description = typeof args.options.description !== 'undefined';
28
+ telemetryProps.orderHint = typeof args.options.orderHint !== 'undefined';
29
+ return telemetryProps;
30
+ }
31
+ commandAction(logger, args, cb) {
32
+ this
33
+ .getPlanId(args)
34
+ .then(planId => {
35
+ this.planId = planId;
36
+ return this.getBucketId(args, planId);
37
+ })
38
+ .then(bucketId => {
39
+ this.bucketId = bucketId;
40
+ return this.generateUserAssignments(args);
41
+ })
42
+ .then(assignments => {
43
+ const requestOptions = {
44
+ url: `${this.resource}/v1.0/planner/tasks`,
45
+ headers: {
46
+ 'accept': 'application/json;odata.metadata=none'
47
+ },
48
+ responseType: 'json',
49
+ data: {
50
+ planId: this.planId,
51
+ bucketId: this.bucketId,
52
+ title: args.options.title,
53
+ startDateTime: args.options.startDateTime,
54
+ dueDateTime: args.options.dueDateTime,
55
+ percentComplete: args.options.percentComplete,
56
+ assignments: assignments,
57
+ orderHint: args.options.orderHint
58
+ }
59
+ };
60
+ return request_1.default.post(requestOptions);
61
+ })
62
+ .then(newTask => this.updateTaskDetails(args.options, newTask))
63
+ .then((res) => {
64
+ logger.log(res);
65
+ cb();
66
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
67
+ }
68
+ getTaskDetailsEtag(taskId) {
69
+ const requestOptions = {
70
+ url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(taskId)}/details`,
71
+ headers: {
72
+ accept: 'application/json'
73
+ },
74
+ responseType: 'json'
75
+ };
76
+ return request_1.default
77
+ .get(requestOptions)
78
+ .then((response) => {
79
+ const etag = response ? response['@odata.etag'] : undefined;
80
+ if (!etag) {
81
+ return Promise.reject(`Error fetching task details`);
82
+ }
83
+ return Promise.resolve(etag);
84
+ });
85
+ }
86
+ updateTaskDetails(options, newTask) {
87
+ const taskId = newTask.id;
88
+ if (!options.description) {
89
+ return Promise.resolve(newTask);
90
+ }
91
+ return this
92
+ .getTaskDetailsEtag(taskId)
93
+ .then(etag => {
94
+ const requestOptionsTaskDetails = {
95
+ url: `${this.resource}/v1.0/planner/tasks/${taskId}/details`,
96
+ headers: {
97
+ 'accept': 'application/json;odata.metadata=none',
98
+ 'If-Match': etag,
99
+ 'Prefer': 'return=representation'
100
+ },
101
+ responseType: 'json',
102
+ data: {
103
+ description: options.description
104
+ }
105
+ };
106
+ return request_1.default.patch(requestOptionsTaskDetails);
107
+ })
108
+ .then(taskDetails => {
109
+ return Object.assign(Object.assign({}, newTask), taskDetails);
110
+ });
111
+ }
112
+ generateUserAssignments(args) {
113
+ const assignments = {};
114
+ if (!args.options.assignedToUserIds && !args.options.assignedToUserNames) {
115
+ return Promise.resolve(assignments);
116
+ }
117
+ return this
118
+ .getUserIds(args.options)
119
+ .then((userIds) => {
120
+ userIds.map(x => assignments[x] = {
121
+ '@odata.type': '#microsoft.graph.plannerAssignment',
122
+ orderHint: ' !'
123
+ });
124
+ return Promise.resolve(assignments);
125
+ });
126
+ }
127
+ getBucketId(args, planId) {
128
+ if (args.options.bucketId) {
129
+ return Promise.resolve(args.options.bucketId);
130
+ }
131
+ const requestOptions = {
132
+ url: `${this.resource}/v1.0/planner/plans/${planId}/buckets`,
133
+ headers: {
134
+ accept: 'application/json;odata.metadata=none'
135
+ },
136
+ responseType: 'json'
137
+ };
138
+ return request_1.default
139
+ .get(requestOptions)
140
+ .then((response) => {
141
+ const bucket = response.value.find(val => val.name === args.options.bucketName);
142
+ if (!bucket) {
143
+ return Promise.reject(`The specified bucket does not exist`);
144
+ }
145
+ return Promise.resolve(bucket.id);
146
+ });
147
+ }
148
+ getPlanId(args) {
149
+ if (args.options.planId) {
150
+ return Promise.resolve(args.options.planId);
151
+ }
152
+ return this
153
+ .getGroupId(args)
154
+ .then((groupId) => {
155
+ const requestOptions = {
156
+ url: `${this.resource}/v1.0/planner/plans?$filter=(owner eq '${groupId}')`,
157
+ headers: {
158
+ accept: 'application/json;odata.metadata=none'
159
+ },
160
+ responseType: 'json'
161
+ };
162
+ return request_1.default.get(requestOptions);
163
+ }).then((response) => {
164
+ const plan = response.value.find(val => val.title === args.options.planName);
165
+ if (!plan) {
166
+ return Promise.reject(`The specified plan does not exist`);
167
+ }
168
+ return Promise.resolve(plan.id);
169
+ });
170
+ }
171
+ getGroupId(args) {
172
+ if (args.options.ownerGroupId) {
173
+ return Promise.resolve(args.options.ownerGroupId);
174
+ }
175
+ const requestOptions = {
176
+ url: `${this.resource}/v1.0/groups?$filter=displayName eq '${encodeURIComponent(args.options.ownerGroupName)}'`,
177
+ headers: {
178
+ accept: 'application/json;odata.metadata=none'
179
+ },
180
+ responseType: 'json'
181
+ };
182
+ return request_1.default
183
+ .get(requestOptions)
184
+ .then(response => {
185
+ const group = response.value[0];
186
+ if (!group) {
187
+ return Promise.reject(`The specified owner group does not exist`);
188
+ }
189
+ return Promise.resolve(group.id);
190
+ });
191
+ }
192
+ getUserIds(options) {
193
+ if (options.assignedToUserIds) {
194
+ return Promise.resolve(options.assignedToUserIds.split(','));
195
+ }
196
+ // Hitting this section means assignedToUserNames won't be undefined
197
+ const userNames = options.assignedToUserNames;
198
+ const userArr = userNames.split(',').map(o => o.trim());
199
+ let userIds = [];
200
+ const promises = userArr.map(user => {
201
+ const requestOptions = {
202
+ url: `${this.resource}/v1.0/users?$filter=userPrincipalName eq '${Utils_1.default.encodeQueryParameter(user)}'&$select=id,userPrincipalName`,
203
+ headers: {
204
+ 'content-type': 'application/json'
205
+ },
206
+ responseType: 'json'
207
+ };
208
+ return request_1.default.get(requestOptions);
209
+ });
210
+ return Promise
211
+ .all(promises)
212
+ .then((usersRes) => {
213
+ let userUpns = [];
214
+ userUpns = usersRes.map(res => { var _a; return (_a = res.value[0]) === null || _a === void 0 ? void 0 : _a.userPrincipalName; });
215
+ userIds = usersRes.map(res => { var _a; return (_a = res.value[0]) === null || _a === void 0 ? void 0 : _a.id; });
216
+ // Find the members where no graph response was found
217
+ const invalidUsers = userArr.filter(user => !userUpns.some((upn) => (upn === null || upn === void 0 ? void 0 : upn.toLowerCase()) === user.toLowerCase()));
218
+ if (invalidUsers && invalidUsers.length > 0) {
219
+ return Promise.reject(`Cannot proceed with planner task creation. The following users provided are invalid : ${invalidUsers.join(',')}`);
220
+ }
221
+ return Promise.resolve(userIds);
222
+ });
223
+ }
224
+ options() {
225
+ const options = [
226
+ { option: '-t, --title <title>' },
227
+ { option: '--planId [planId]' },
228
+ { option: '--planName [planName]' },
229
+ { option: '--ownerGroupId [ownerGroupId]' },
230
+ { option: '--ownerGroupName [ownerGroupName]' },
231
+ { option: '--bucketId [bucketId]' },
232
+ { option: '--bucketName [bucketName]' },
233
+ { option: '--startDateTime [startDateTime]' },
234
+ { option: '--dueDateTime [dueDateTime]' },
235
+ { option: '--percentComplete [percentComplete]' },
236
+ { option: '--assignedToUserIds [assignedToUserIds]' },
237
+ { option: '--assignedToUserNames [assignedToUserNames]' },
238
+ { option: '--description [description]' },
239
+ { option: '--orderHint [orderHint]' }
240
+ ];
241
+ const parentOptions = super.options();
242
+ return options.concat(parentOptions);
243
+ }
244
+ validate(args) {
245
+ if (!args.options.planId && !args.options.planName) {
246
+ return 'Specify either planId or planName';
247
+ }
248
+ if (args.options.planId && args.options.planName) {
249
+ return 'Specify either planId or planName but not both';
250
+ }
251
+ if (args.options.planName && !args.options.ownerGroupId && !args.options.ownerGroupName) {
252
+ return 'Specify either ownerGroupId or ownerGroupName when using planName';
253
+ }
254
+ if (args.options.planName && args.options.ownerGroupId && args.options.ownerGroupName) {
255
+ return 'Specify either ownerGroupId or ownerGroupName when using planName but not both';
256
+ }
257
+ if (args.options.ownerGroupId && !Utils_1.default.isValidGuid(args.options.ownerGroupId)) {
258
+ return `${args.options.ownerGroupId} is not a valid GUID`;
259
+ }
260
+ if (!args.options.bucketId && !args.options.bucketName) {
261
+ return 'Specify either bucketId or bucketName';
262
+ }
263
+ if (args.options.bucketId && args.options.bucketName) {
264
+ return 'Specify either bucketId or bucketName but not both';
265
+ }
266
+ if (args.options.startDateTime && !Utils_1.default.isValidISODateTime(args.options.startDateTime)) {
267
+ return 'The startDateTime is not a valid ISO date string';
268
+ }
269
+ if (args.options.dueDateTime && !Utils_1.default.isValidISODateTime(args.options.dueDateTime)) {
270
+ return 'The dueDateTime is not a valid ISO date string';
271
+ }
272
+ if (args.options.percentComplete && isNaN(args.options.percentComplete)) {
273
+ return `percentComplete is not a number`;
274
+ }
275
+ if (args.options.percentComplete && (args.options.percentComplete < 0 || args.options.percentComplete > 100)) {
276
+ return `percentComplete should be between 0 and 100 `;
277
+ }
278
+ if (args.options.assignedToUserIds && !Utils_1.default.isValidGuidArray(args.options.assignedToUserIds.split(','))) {
279
+ return 'assignedToUserIds contains invalid GUID';
280
+ }
281
+ if (args.options.assignedToUserIds && args.options.assignedToUserNames) {
282
+ return 'Specify either assignedToUserIds or assignedToUserNames but not both';
283
+ }
284
+ return true;
285
+ }
286
+ }
287
+ module.exports = new PlannerTaskAddCommand();
288
+ //# sourceMappingURL=task-add.js.map
@@ -7,6 +7,7 @@ exports.default = {
7
7
  PLAN_ADD: `${prefix} plan add`,
8
8
  PLAN_GET: `${prefix} plan get`,
9
9
  PLAN_LIST: `${prefix} plan list`,
10
+ TASK_ADD: `${prefix} task add`,
10
11
  TASK_LIST: `${prefix} task list`
11
12
  };
12
13
  //# sourceMappingURL=commands.js.map
@@ -59,7 +59,7 @@ class SpoSiteEnsureCommand extends SpoCommand_1.default {
59
59
  if (this.debug) {
60
60
  logger.logToStderr(err.stderr);
61
61
  }
62
- if (err.error.message !== 'Request failed with status code 404') {
62
+ if (err.error.message !== '404 FILE NOT FOUND') {
63
63
  return Promise.reject(err);
64
64
  }
65
65
  if (this.verbose) {
@@ -13,7 +13,7 @@ class TeamsMessageGetCommand extends GraphCommand_1.default {
13
13
  }
14
14
  commandAction(logger, args, cb) {
15
15
  const requestOptions = {
16
- url: `${this.resource}/beta/teams/${args.options.teamId}/channels/${args.options.channelId}/messages/${args.options.messageId}`,
16
+ url: `${this.resource}/v1.0/teams/${args.options.teamId}/channels/${args.options.channelId}/messages/${args.options.messageId}`,
17
17
  headers: {
18
18
  accept: 'application/json;odata.metadata=none'
19
19
  },
package/dist/request.js CHANGED
@@ -66,7 +66,7 @@ class Request {
66
66
  });
67
67
  // since we're stubbing requests, response interceptor is never called in
68
68
  // tests, so let's exclude it from coverage
69
- /* c8 ignore next 22 */
69
+ /* c8 ignore next 26 */
70
70
  this.req.interceptors.response.use((response) => {
71
71
  if (this._logger) {
72
72
  this._logger.logToStderr('Response:');
@@ -75,19 +75,22 @@ class Request {
75
75
  response.headers['content-type'].indexOf('json') > -1) {
76
76
  properties.push('data');
77
77
  }
78
- this._logger.logToStderr(JSON.stringify(Utils_1.default.filterObject(response, properties), null, 2));
78
+ this._logger.logToStderr(JSON.stringify(Object.assign({ url: response.config.url }, Utils_1.default.filterObject(response, properties)), null, 2));
79
79
  }
80
80
  return response;
81
81
  }, (error) => {
82
82
  if (this._logger) {
83
83
  const properties = ['status', 'statusText', 'headers'];
84
84
  this._logger.logToStderr('Request error:');
85
- this._logger.logToStderr(JSON.stringify(Object.assign(Object.assign({}, Utils_1.default.filterObject(error.response, properties)), { error: error.error }), null, 2));
85
+ this._logger.logToStderr(JSON.stringify(Object.assign(Object.assign({ url: error.config.url }, Utils_1.default.filterObject(error.response, properties)), { error: error.error }), null, 2));
86
86
  }
87
87
  throw error;
88
88
  });
89
89
  }
90
90
  }
91
+ get logger() {
92
+ return this._logger;
93
+ }
91
94
  set logger(logger) {
92
95
  this._logger = logger;
93
96
  }
@@ -5,10 +5,10 @@
5
5
  : JMESPath query string. See [http://jmespath.org/](http://jmespath.org/) for more information and examples
6
6
 
7
7
  `-o, --output [output]`
8
- : Output type. `json,text`. Default `text`
8
+ : Output type. `json,text,csv`. Default `json`
9
9
 
10
10
  `--verbose`
11
11
  : Runs command with verbose logging
12
12
 
13
13
  `--debug`
14
- : Runs command with debug logging
14
+ : Runs command with debug logging
@@ -11,10 +11,13 @@ m365 aad user get [options]
11
11
  ## Options
12
12
 
13
13
  `-i, --id [id]`
14
- : The ID of the user to retrieve information for. Specify `id` or `userName` but not both
14
+ : The ID of the user to retrieve information for. Use either `id`, `userName` or `email`, but not all.
15
15
 
16
16
  `-n, --userName [userName]`
17
- : The name of the user to retrieve information for. Specify `id` or `userName` but not both
17
+ : The name of the user to retrieve information for. Use either `id`, `userName` or `email`, but not all.
18
+
19
+ `--email [email]`
20
+ : The email of the user to retrieve information for. Use either `id`, `userName` or `email`, but not all.
18
21
 
19
22
  `-p, --properties [properties]`
20
23
  : Comma-separated list of properties to retrieve
@@ -23,9 +26,9 @@ m365 aad user get [options]
23
26
 
24
27
  ## Remarks
25
28
 
26
- You can retrieve information about a user, either by specifying that user's id or user name (`userPrincipalName`), but not both.
29
+ You can retrieve information about a user, either by specifying that user's id, user name (`userPrincipalName`), or email (`mail`), but not all.
27
30
 
28
- If the user with the specified id or user name doesn't exist, you will get a `Resource 'xyz' does not exist or one of its queried reference-property objects are not present.` error.
31
+ If the user with the specified id, user name, or email doesn't exist, you will get a `Resource 'xyz' does not exist or one of its queried reference-property objects are not present.` error.
29
32
 
30
33
  ## Examples
31
34
 
@@ -41,6 +44,12 @@ Get information about the user with user name _AarifS@contoso.onmicrosoft.com_
41
44
  m365 aad user get --userName AarifS@contoso.onmicrosoft.com
42
45
  ```
43
46
 
47
+ Get information about the user with email _AarifS@contoso.onmicrosoft.com_
48
+
49
+ ```sh
50
+ m365 aad user get --email AarifS@contoso.onmicrosoft.com
51
+ ```
52
+
44
53
  For the user with id _1caf7dcd-7e83-4c3a-94f7-932a1299c844_ retrieve the user name, e-mail address and full name
45
54
 
46
55
  ```sh
@@ -0,0 +1,36 @@
1
+ # app permission list
2
+
3
+ Lists API permissions for the current AAD app
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 app permission list [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `--appId [appId]`
14
+ : Client ID of the Azure AD app registered in the .m365rc.json file to retrieve API permissions for
15
+
16
+ --8<-- "docs/cmd/_global.md"
17
+
18
+ ## Remarks
19
+
20
+ Use this command to quickly look up API permissions for the Azure AD application registration registered in the .m365rc.json file in your current project (folder).
21
+
22
+ If you have multiple apps registered in your .m365rc.json file, you can specify the app for which you'd like to retrieve permissions using the `--appId` option. If you don't specify the app using the `--appId` option, you'll be prompted to select one of the applications from your .m365rc.json file.
23
+
24
+ ## Examples
25
+
26
+ Retrieve API permissions for your current Azure AD app
27
+
28
+ ```sh
29
+ m365 app permission list
30
+ ```
31
+
32
+ Retrieve API permissions for the Azure AD app with client ID _e23d235c-fcdf-45d1-ac5f-24ab2ee0695d_ specified in the _.m365rc.json_ file
33
+
34
+ ```sh
35
+ m365 app permission list --appId e23d235c-fcdf-45d1-ac5f-24ab2ee0695d
36
+ ```
@@ -10,6 +10,12 @@ pa app list [options]
10
10
 
11
11
  ## Options
12
12
 
13
+ `-e, --environment [environment]`
14
+ : The name of the environment for which to retrieve available apps
15
+
16
+ `--asAdmin`
17
+ : Set, to list all Power Apps as admin. Otherwise will return only your own apps
18
+
13
19
  --8<-- "docs/cmd/_global.md"
14
20
 
15
21
  ## Remarks
@@ -17,10 +23,20 @@ pa app list [options]
17
23
  !!! attention
18
24
  This command is based on an API that is currently in preview and is subject to change once the API reaches general availability.
19
25
 
26
+ If the environment with the name you specified doesn't exist, you will get the `Access to the environment 'xyz' is denied.` error.
27
+
28
+ By default, the `app list` command returns only your apps. To list all apps, use the `asAdmin` option and make sure to specify the `environment` option. You cannot specify only one of the options, when specifying the `environment` option the `asAdmin` option has to be present as well.
29
+
20
30
  ## Examples
21
31
 
22
- List all apps
32
+ List all your apps
23
33
 
24
34
  ```sh
25
35
  m365 pa app list
26
36
  ```
37
+
38
+ List all apps in a given environment
39
+
40
+ ```sh
41
+ m365 pa app list --environment Default-d87a7535-dd31-4437-bfe1-95340acd55c5 --asAdmin
42
+ ```
@@ -0,0 +1,78 @@
1
+ # planner task add
2
+
3
+ Adds a new Microsoft Planner task
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 planner task add [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-t, --title <title>`
14
+ : Title of the task to add.
15
+
16
+ `--planId [planId]`
17
+ : Plan ID to which the task belongs. Specify either `planId` or `planName` but not both.
18
+
19
+ `--planName [planName]`
20
+ : Plan Name to which the task belongs. Specify either `planId` or `planName` but not both.
21
+
22
+ `--ownerGroupId [ownerGroupId]`
23
+ : ID of the group to which the plan belongs. Specify `ownerGroupId` or `ownerGroupName` when using `planName`.
24
+
25
+ `--ownerGroupName [ownerGroupName]`
26
+ : Name of the group to which the plan belongs. Specify `ownerGroupId` or `ownerGroupName` when using `planName`.
27
+
28
+ `--bucketId [bucketId]`
29
+ : Bucket ID to which the task belongs. The bucket needs to exist in the selected plan. Specify either `bucketId` or `bucketName` but not both.
30
+
31
+ `--bucketName [bucketName]`
32
+ : Bucket Name to which the task belongs. The bucket needs to exist in the selected plan. Specify either `bucketId` or `bucketName` but not both.
33
+
34
+ `--startDateTime [startDateTime]`
35
+ : The date and time when the task started. This should be defined as a valid ISO 8601 string. `2021-12-16T18:28:48.6964197Z`
36
+
37
+ `--dueDateTime [dueDateTime]`
38
+ : The date and time when the task is due. This should be defined as a valid ISO 8601 string. `2021-12-16T18:28:48.6964197Z`
39
+
40
+ `--percentComplete [percentComplete]`
41
+ : Percentage of task completion. Number between 0 and 100.
42
+ - When set to 0, the task is considered _Not started_.
43
+ - When set between 1 and 99, the task is considered _In progress_.
44
+ - When set to 100, the task is considered _Completed_.
45
+
46
+ `--assignedToUserIds [assignedToUserIds]`
47
+ : The comma-separated IDs of the assignees the task is assigned to. Specify either `assignedToUserIds` or `assignedToUserNames` but not both.
48
+
49
+ `--assignedToUserNames [assignedToUserNames]`
50
+ : The comma-separated UPNs of the assignees the task is assigned to. Specify either `assignedToUserIds` or `assignedToUserNames` but not both.
51
+
52
+ `--description [description]`
53
+ : Description of the task
54
+
55
+ `--orderHint [orderHint]`
56
+ : Hint used to order items of this type in a list view. The format is defined as outlined [here](https://docs.microsoft.com/en-us/graph/api/resources/planner-order-hint-format?view=graph-rest-1.0).
57
+
58
+ --8<-- "docs/cmd/_global.md"
59
+
60
+ ## Examples
61
+
62
+ Adds a Microsoft Planner task with the name _My Planner Task_ for plan with the ID _8QZEH7b3wkSbGQobscsM5gADCBa_ and for the bucket with the ID _IK8tuFTwQEa5vTonM7ZMRZgAKdna_
63
+
64
+ ```sh
65
+ m365 planner task add --title "My Planner Task" --planId "8QZEH7b3wkSbGQobscsM5gADCBa" --bucketId "IK8tuFTwQEa5vTonM7ZMRZgAKdna"
66
+ ```
67
+
68
+ Adds a Completed Microsoft Planner task with the name _My Planner Task_ for plan with the name _My Planner Plan_ owned by group _My Planner Group_ and for the bucket with the ID _IK8tuFTwQEa5vTonM7ZMRZgAKdna_
69
+
70
+ ```sh
71
+ m365 planner task add --title "My Planner task" --planName "My Planner Plan" --ownerGroupName "My Planner Group" --bucketId "IK8tuFTwQEa5vTonM7ZMRZgAKdna" --percentComplete 100
72
+ ```
73
+
74
+ Adds a Microsoft Planner task with the name _My Planner Task_ for plan with the ID _8QZEH7b3wkbGQobscsM5gADCBa_ and for the bucket with the ID _IK8tuFTwQEa5vTonM7ZMRZgAKdna_. The new task will be assigned to the users _Allan.Carroll@contoso.com_ and _Ida.Stevens@contoso.com_ and receive a due date for _2021-12-16_
75
+
76
+ ```sh
77
+ m365 planner task add --title "My Planner Task" --planId "8QZEH7b3wkSbGQobscsM5gADCBa" --bucketId "IK8tuFTwQEa5vTonM7ZMRZgAKdna" --assignedToUserNames "Allan.Carroll@contoso.com,Ida.Stevens@contoso.com" --dueDateTime "2021-12-16"
78
+ ```
@@ -20,7 +20,7 @@ m365 spfx project externalize [options]
20
20
  : JMESPath query string. See [http://jmespath.org/](http://jmespath.org/) for more information and examples
21
21
 
22
22
  `-o, --output [output]`
23
- : Output type. `json,text,md`. Default `text`
23
+ : Output type. `json,text,csv,md`. Default `json`
24
24
 
25
25
  `--verbose`
26
26
  : Runs command with verbose logging
@@ -23,7 +23,7 @@ m365 spfx project rename [options]
23
23
  : JMESPath query string. See [http://jmespath.org/](http://jmespath.org/) for more information and examples
24
24
 
25
25
  `-o, --output [output]`
26
- : Output type. `json,text,md`. Default `text`
26
+ : Output type. `json,text,csv,md`. Default `json`
27
27
 
28
28
  `--verbose`
29
29
  : Runs command with verbose logging
@@ -20,7 +20,7 @@ m365 spfx doctor [options]
20
20
  : JMESPath query string. See [http://jmespath.org/](http://jmespath.org/) for more information and examples
21
21
 
22
22
  `-o, --output [output]`
23
- : Output type. `json,text,md`. Default `text`
23
+ : Output type. `json,text,csv,md`. Default `json`
24
24
 
25
25
  `--verbose`
26
26
  : Runs command with verbose logging
@@ -23,9 +23,6 @@ m365 teams message get [options]
23
23
 
24
24
  ## Remarks
25
25
 
26
- !!! attention
27
- This command is based on an API that is currently in preview and is subject to change once the API reached general availability.
28
-
29
26
  You can only retrieve a message from a Microsoft Teams team if you are a member of that team.
30
27
 
31
28
  ## Examples
@@ -17,6 +17,7 @@
17
17
  "applicationinsights": "^2.2.0",
18
18
  "axios": "^0.24.0",
19
19
  "chalk": "^4.1.2",
20
+ "csv-stringify": "^6.0.4",
20
21
  "easy-table": "^1.2.0",
21
22
  "inquirer": "^8.2.0",
22
23
  "jmespath": "^0.15.0",
@@ -1785,6 +1786,11 @@
1785
1786
  "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz",
1786
1787
  "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg=="
1787
1788
  },
1789
+ "node_modules/csv-stringify": {
1790
+ "version": "6.0.4",
1791
+ "resolved": "https://registry.npmjs.org/csv-stringify/-/csv-stringify-6.0.4.tgz",
1792
+ "integrity": "sha512-Z3EbRQWwkOV3Qc2fQnJmfjrxRgAwH9AncnNK2jmtTvBvFjj/hESZUGm42YvTh9kMw2OOGPHQn5Yt0EbqoRtUVQ=="
1793
+ },
1788
1794
  "node_modules/d3-format": {
1789
1795
  "version": "1.4.5",
1790
1796
  "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-1.4.5.tgz",
@@ -7553,6 +7559,11 @@
7553
7559
  }
7554
7560
  }
7555
7561
  },
7562
+ "csv-stringify": {
7563
+ "version": "6.0.4",
7564
+ "resolved": "https://registry.npmjs.org/csv-stringify/-/csv-stringify-6.0.4.tgz",
7565
+ "integrity": "sha512-Z3EbRQWwkOV3Qc2fQnJmfjrxRgAwH9AncnNK2jmtTvBvFjj/hESZUGm42YvTh9kMw2OOGPHQn5Yt0EbqoRtUVQ=="
7566
+ },
7556
7567
  "d3-format": {
7557
7568
  "version": "1.4.5",
7558
7569
  "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-1.4.5.tgz",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "4.3.0-beta.e2f87dd",
3
+ "version": "4.3.0-beta.fa07425",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -164,6 +164,7 @@
164
164
  "van Iersel, Cas <cvaniersel@portiva.nl>",
165
165
  "van Rousselt, Rick <rick.vanrousselt@outlook.com>",
166
166
  "Velliah, Joseph <joseph@sprider.org>",
167
+ "Waegebaert, Jasey <jaseyw@gmigroup.be>",
167
168
  "Wilen, Wictor <wictor@wictorwilen.se>",
168
169
  "Williams, Rabia <rabiawilliams@gmail.com>",
169
170
  "Wojcik, Adam <adam.wojcik.it@gmail.com>"
@@ -177,6 +178,7 @@
177
178
  "applicationinsights": "^2.2.0",
178
179
  "axios": "^0.24.0",
179
180
  "chalk": "^4.1.2",
181
+ "csv-stringify": "^6.0.4",
180
182
  "easy-table": "^1.2.0",
181
183
  "inquirer": "^8.2.0",
182
184
  "jmespath": "^0.15.0",
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=GroupUser.js.map