@pnp/cli-microsoft365 5.0.0-beta.d025005 → 5.0.0-beta.d17a15f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Command.js CHANGED
@@ -113,7 +113,7 @@ class Command {
113
113
  },
114
114
  {
115
115
  option: '-o, --output [output]',
116
- autocomplete: ['json', 'text']
116
+ autocomplete: ['csv', 'json', 'text']
117
117
  },
118
118
  {
119
119
  option: '--verbose'
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_1 = require("../../../../cli");
4
+ const request_1 = require("../../../../request");
5
+ const Utils_1 = require("../../../../Utils");
6
+ const GraphCommand_1 = require("../../../base/GraphCommand");
7
+ const commands_1 = require("../../commands");
8
+ class AadAppDeleteCommand extends GraphCommand_1.default {
9
+ get name() {
10
+ return commands_1.default.APP_DELETE;
11
+ }
12
+ get description() {
13
+ return 'Removes an Azure AD app registration';
14
+ }
15
+ getTelemetryProperties(args) {
16
+ const telemetryProps = super.getTelemetryProperties(args);
17
+ telemetryProps.appId = typeof args.options.appId !== 'undefined';
18
+ telemetryProps.objectId = typeof args.options.objectId !== 'undefined';
19
+ telemetryProps.name = typeof args.options.name !== 'undefined';
20
+ telemetryProps.confirm = (!(!args.options.confirm)).toString();
21
+ return telemetryProps;
22
+ }
23
+ commandAction(logger, args, cb) {
24
+ const deleteApp = () => {
25
+ this
26
+ .getObjectId(args, logger)
27
+ .then((objectId) => {
28
+ if (this.verbose) {
29
+ logger.logToStderr(`Deleting Azure AD app ${objectId}...`);
30
+ }
31
+ const requestOptions = {
32
+ url: `${this.resource}/v1.0/myorganization/applications/${objectId}`,
33
+ headers: {
34
+ accept: 'application/json;odata.metadata=none'
35
+ },
36
+ responseType: 'json'
37
+ };
38
+ return request_1.default.delete(requestOptions);
39
+ })
40
+ .then(_ => cb(), (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
41
+ };
42
+ if (args.options.confirm) {
43
+ deleteApp();
44
+ }
45
+ else {
46
+ cli_1.Cli.prompt({
47
+ type: 'confirm',
48
+ name: 'continue',
49
+ default: false,
50
+ message: `Are you sure you want to delete the App?`
51
+ }, (result) => {
52
+ if (!result.continue) {
53
+ cb();
54
+ }
55
+ else {
56
+ deleteApp();
57
+ }
58
+ });
59
+ }
60
+ }
61
+ getObjectId(args, logger) {
62
+ if (args.options.objectId) {
63
+ return Promise.resolve(args.options.objectId);
64
+ }
65
+ const { appId, name } = args.options;
66
+ if (this.verbose) {
67
+ logger.logToStderr(`Retrieving information about Azure AD app ${appId ? appId : name}...`);
68
+ }
69
+ const filter = appId ?
70
+ `appId eq '${encodeURIComponent(appId)}'` :
71
+ `displayName eq '${encodeURIComponent(name)}'`;
72
+ const requestOptions = {
73
+ url: `${this.resource}/v1.0/myorganization/applications?$filter=${filter}&$select=id`,
74
+ headers: {
75
+ accept: 'application/json;odata.metadata=none'
76
+ },
77
+ responseType: 'json'
78
+ };
79
+ return request_1.default
80
+ .get(requestOptions)
81
+ .then((res) => {
82
+ if (res.value.length === 1) {
83
+ return Promise.resolve(res.value[0].id);
84
+ }
85
+ if (res.value.length === 0) {
86
+ const applicationIdentifier = appId ? `ID ${appId}` : `name ${name}`;
87
+ return Promise.reject(`No Azure AD application registration with ${applicationIdentifier} found`);
88
+ }
89
+ return Promise.reject(`Multiple Azure AD application registration with name ${name} found. Please choose one of the object IDs: ${res.value.map(a => a.id).join(', ')}`);
90
+ });
91
+ }
92
+ options() {
93
+ const options = [
94
+ { option: '--appId [appId]' },
95
+ { option: '--objectId [objectId]' },
96
+ { option: '--name [name]' },
97
+ { option: '--confirm' }
98
+ ];
99
+ const parentOptions = super.options();
100
+ return options.concat(parentOptions);
101
+ }
102
+ validate(args) {
103
+ if (!args.options.appId &&
104
+ !args.options.objectId &&
105
+ !args.options.name) {
106
+ return 'Specify either appId, objectId, or name';
107
+ }
108
+ if ((args.options.appId && args.options.objectId) ||
109
+ (args.options.appId && args.options.name) ||
110
+ (args.options.objectId && args.options.name)) {
111
+ return 'Specify either appId, objectId, or name';
112
+ }
113
+ if (args.options.appId && !Utils_1.default.isValidGuid(args.options.appId)) {
114
+ return `${args.options.appId} is not a valid GUID`;
115
+ }
116
+ if (args.options.objectId && !Utils_1.default.isValidGuid(args.options.objectId)) {
117
+ return `${args.options.objectId} is not a valid GUID`;
118
+ }
119
+ return true;
120
+ }
121
+ }
122
+ module.exports = new AadAppDeleteCommand();
123
+ //# sourceMappingURL=app-delete.js.map
@@ -9,12 +9,18 @@ class AadGroupListCommand extends GraphItemsListCommand_1.GraphItemsListCommand
9
9
  get description() {
10
10
  return 'Lists all groups defined in Azure Active Directory.';
11
11
  }
12
+ getTelemetryProperties(args) {
13
+ const telemetryProps = super.getTelemetryProperties(args);
14
+ telemetryProps.deleted = args.options.deleted;
15
+ return telemetryProps;
16
+ }
12
17
  defaultProperties() {
13
18
  return ['id', 'displayName', 'groupType'];
14
19
  }
15
20
  commandAction(logger, args, cb) {
21
+ const endpoint = args.options.deleted ? 'directory/deletedItems/microsoft.graph.group' : 'groups';
16
22
  this
17
- .getAllItems(`${this.resource}/v1.0/groups`, logger, true)
23
+ .getAllItems(`${this.resource}/v1.0/${endpoint}`, logger, true)
18
24
  .then(() => {
19
25
  if (args.options.output === 'text') {
20
26
  this.items.forEach((group) => {
@@ -36,6 +42,13 @@ class AadGroupListCommand extends GraphItemsListCommand_1.GraphItemsListCommand
36
42
  cb();
37
43
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
38
44
  }
45
+ options() {
46
+ const options = [
47
+ { option: '-d, --deleted' }
48
+ ];
49
+ const parentOptions = super.options();
50
+ return options.concat(parentOptions);
51
+ }
39
52
  }
40
53
  module.exports = new AadGroupListCommand();
41
54
  //# sourceMappingURL=group-list.js.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'aad';
4
4
  exports.default = {
5
5
  APP_ADD: `${prefix} app add`,
6
+ APP_DELETE: `${prefix} app delete`,
6
7
  APP_GET: `${prefix} app get`,
7
8
  APP_SET: `${prefix} app set`,
8
9
  APP_ROLE_ADD: `${prefix} app role add`,
@@ -12,7 +12,7 @@ class PlannerTaskGetCommand extends GraphCommand_1.default {
12
12
  }
13
13
  commandAction(logger, args, cb) {
14
14
  const requestOptions = {
15
- url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(args.options.id)}`,
15
+ url: `${this.resource}/beta/planner/tasks/${encodeURIComponent(args.options.id)}`,
16
16
  headers: {
17
17
  accept: 'application/json;odata.metadata=none'
18
18
  },
@@ -25,25 +25,40 @@ class PlannerTaskListCommand extends GraphItemsListCommand_1.GraphItemsListComma
25
25
  return ['id', 'title', 'startDateTime', 'dueDateTime', 'completedDateTime'];
26
26
  }
27
27
  commandAction(logger, args, cb) {
28
- const bucketId = args.options.bucketId;
29
28
  const bucketName = args.options.bucketName;
30
- const planId = args.options.planId;
29
+ let bucketId = args.options.bucketId;
31
30
  const planName = args.options.planName;
31
+ let planId = args.options.planId;
32
+ let taskItems = [];
32
33
  if (bucketId || bucketName) {
33
34
  this
34
35
  .getBucketId(args)
35
- .then((bucketId) => this.getAllItems(`${this.resource}/v1.0/planner/buckets/${bucketId}/tasks`, logger, true))
36
+ .then((retrievedBucketId) => {
37
+ bucketId = retrievedBucketId;
38
+ return this.getAllItems(`${this.resource}/v1.0/planner/buckets/${bucketId}/tasks`, logger, true);
39
+ })
36
40
  .then(() => {
37
- logger.log(this.items);
41
+ taskItems = this.items;
42
+ return this.getAllItems(`${this.resource}/beta/planner/buckets/${bucketId}/tasks`, logger, true);
43
+ })
44
+ .then(() => {
45
+ logger.log(this.mergeTaskPriority(taskItems, this.items));
38
46
  cb();
39
47
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
40
48
  }
41
49
  else if (planId || planName) {
42
50
  this
43
51
  .getPlanId(args)
44
- .then((planId) => this.getAllItems(`${this.resource}/v1.0/planner/plans/${planId}/tasks`, logger, true))
52
+ .then((retrievedPlanId) => {
53
+ planId = retrievedPlanId;
54
+ return this.getAllItems(`${this.resource}/v1.0/planner/plans/${planId}/tasks`, logger, true);
55
+ })
56
+ .then(() => {
57
+ taskItems = this.items;
58
+ return this.getAllItems(`${this.resource}/beta/planner/plans/${planId}/tasks`, logger, true);
59
+ })
45
60
  .then(() => {
46
- logger.log(this.items);
61
+ logger.log(this.mergeTaskPriority(taskItems, this.items));
47
62
  cb();
48
63
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
49
64
  }
@@ -51,7 +66,11 @@ class PlannerTaskListCommand extends GraphItemsListCommand_1.GraphItemsListComma
51
66
  this
52
67
  .getAllItems(`${this.resource}/v1.0/me/planner/tasks`, logger, true)
53
68
  .then(() => {
54
- logger.log(this.items);
69
+ taskItems = this.items;
70
+ return this.getAllItems(`${this.resource}/beta/me/planner/tasks`, logger, true);
71
+ })
72
+ .then(() => {
73
+ logger.log(this.mergeTaskPriority(taskItems, this.items));
55
74
  cb();
56
75
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
57
76
  }
@@ -125,6 +144,17 @@ class PlannerTaskListCommand extends GraphItemsListCommand_1.GraphItemsListComma
125
144
  return Promise.resolve(group.id);
126
145
  });
127
146
  }
147
+ mergeTaskPriority(taskItems, betaTaskItems) {
148
+ const findBetaTask = (id) => betaTaskItems.find(task => task.id === id);
149
+ taskItems.forEach(task => {
150
+ const betaTaskItem = findBetaTask(task.id);
151
+ if (betaTaskItem) {
152
+ const { priority } = betaTaskItem;
153
+ Object.assign(task, { priority });
154
+ }
155
+ });
156
+ return taskItems;
157
+ }
128
158
  options() {
129
159
  const options = [
130
160
  {
@@ -21,6 +21,7 @@ class TeamsChannelGetCommand extends GraphCommand_1.default {
21
21
  telemetryProps.teamName = typeof args.options.teamName !== 'undefined';
22
22
  telemetryProps.channelId = typeof args.options.channelId !== 'undefined';
23
23
  telemetryProps.channelName = typeof args.options.channelName !== 'undefined';
24
+ telemetryProps.primary = (!(!args.options.primary)).toString();
24
25
  return telemetryProps;
25
26
  }
26
27
  getTeamId(args) {
@@ -54,6 +55,9 @@ class TeamsChannelGetCommand extends GraphCommand_1.default {
54
55
  if (args.options.channelId) {
55
56
  return Promise.resolve(args.options.channelId);
56
57
  }
58
+ if (args.options.primary) {
59
+ return Promise.resolve('');
60
+ }
57
61
  const channelRequestOptions = {
58
62
  url: `${this.resource}/v1.0/teams/${encodeURIComponent(this.teamId)}/channels?$filter=displayName eq '${encodeURIComponent(args.options.channelName)}'`,
59
63
  headers: {
@@ -79,15 +83,21 @@ class TeamsChannelGetCommand extends GraphCommand_1.default {
79
83
  return this.getChannelId(args);
80
84
  })
81
85
  .then((channelId) => {
86
+ let url = '';
87
+ if (args.options.primary) {
88
+ url = `${this.resource}/v1.0/teams/${encodeURIComponent(this.teamId)}/primaryChannel`;
89
+ }
90
+ else {
91
+ url = `${this.resource}/v1.0/teams/${encodeURIComponent(this.teamId)}/channels/${encodeURIComponent(channelId)}`;
92
+ }
82
93
  const requestOptions = {
83
- url: `${this.resource}/v1.0/teams/${encodeURIComponent(this.teamId)}/channels/${encodeURIComponent(channelId)}`,
94
+ url: url,
84
95
  headers: {
85
96
  accept: 'application/json;odata.metadata=none'
86
97
  },
87
98
  responseType: 'json'
88
99
  };
89
- return request_1.default
90
- .get(requestOptions);
100
+ return request_1.default.get(requestOptions);
91
101
  })
92
102
  .then((res) => {
93
103
  logger.log(res);
@@ -107,6 +117,9 @@ class TeamsChannelGetCommand extends GraphCommand_1.default {
107
117
  },
108
118
  {
109
119
  option: '--channelName [channelName]'
120
+ },
121
+ {
122
+ option: '--primary'
110
123
  }
111
124
  ];
112
125
  const parentOptions = super.options();
@@ -122,11 +135,20 @@ class TeamsChannelGetCommand extends GraphCommand_1.default {
122
135
  if (args.options.teamId && !Utils_1.default.isValidGuid(args.options.teamId)) {
123
136
  return `${args.options.teamId} is not a valid GUID`;
124
137
  }
125
- if (args.options.channelId && args.options.channelName) {
126
- return 'Specify either channelId or channelName, but not both.';
138
+ if (args.options.channelId && args.options.channelName && args.options.primary) {
139
+ return 'Specify channelId, channelName or primary';
140
+ }
141
+ if (!args.options.channelId && args.options.channelName && args.options.primary) {
142
+ return 'Specify channelId, channelName or primary.';
143
+ }
144
+ if (args.options.channelId && !args.options.channelName && args.options.primary) {
145
+ return 'Specify channelId, channelName or primary.';
146
+ }
147
+ if (args.options.channelId && args.options.channelName && !args.options.primary) {
148
+ return 'Specify channelId, channelName or primary.';
127
149
  }
128
- if (!args.options.channelId && !args.options.channelName) {
129
- return 'Specify channelId or channelName, one is required';
150
+ if (!args.options.channelId && !args.options.channelName && !args.options.primary) {
151
+ return 'Specify channelId, channelName or primary, one is required';
130
152
  }
131
153
  if (args.options.channelId && !Utils_1.default.isValidTeamsChannelId(args.options.channelId)) {
132
154
  return `${args.options.channelId} is not a valid Teams ChannelId`;
@@ -0,0 +1,51 @@
1
+ # aad app delete
2
+
3
+ Removes an Azure AD app registration
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 aad app delete [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `--appId [appId]`
14
+ : Application (client) ID of the Azure AD application registration to remove. Specify either `appId`, `objectId` or `name`
15
+
16
+ `--objectId [objectId]`
17
+ : Object ID of the Azure AD application registration to remove. Specify either `appId`, `objectId` or `name`
18
+
19
+ `--name [name]`
20
+ : Name of the Azure AD application registration to remove. Specify either `appId`, `objectId` or `name`
21
+
22
+ `--confirm`:
23
+ : Don't prompt for confirmation to delete the app
24
+
25
+ --8<-- "docs/cmd/_global.md"
26
+
27
+ ## Remarks
28
+
29
+ For best performance use the `objectId` option to reference the Azure AD application registration to delete. If you use `appId` or `name`, this command will first need to find the corresponding object ID for that application.
30
+
31
+ If the command finds multiple Azure AD application registrations with the specified app name, it will prompt you to disambiguate which app it should use, listing the discovered object IDs.
32
+
33
+ ## Examples
34
+
35
+ Delete the Azure AD application registration by its app (client) ID
36
+
37
+ ```sh
38
+ m365 aad app delete --appId d75be2e1-0204-4f95-857d-51a37cf40be8
39
+ ```
40
+
41
+ Delete the Azure AD application registration by its object ID
42
+
43
+ ```sh
44
+ m365 aad app delete --objectId d75be2e1-0204-4f95-857d-51a37cf40be8
45
+ ```
46
+
47
+ Delete the Azure AD application registration by its name. Will NOT prompt for confirmation before deleting.
48
+
49
+ ```sh
50
+ m365 aad app delete --name "My app" --confirm
51
+ ```
@@ -10,6 +10,9 @@ m365 aad group list [options]
10
10
 
11
11
  ## Options
12
12
 
13
+ `-d, --deleted`
14
+ : Use to retrieve deleted groups
15
+
13
16
  --8<-- "docs/cmd/_global.md"
14
17
 
15
18
  ## Examples
@@ -18,4 +21,10 @@ Lists all groups defined in Azure Active Directory.
18
21
 
19
22
  ```sh
20
23
  m365 aad group list
24
+ ```
25
+
26
+ List all recently deleted groups in the tenant
27
+
28
+ ```sh
29
+ m365 aad group list --deleted
21
30
  ```
@@ -15,6 +15,11 @@ m365 planner task get [options]
15
15
 
16
16
  --8<-- "docs/cmd/_global.md"
17
17
 
18
+ ## Remarks
19
+
20
+ !!! attention
21
+ This command uses an API that is currently in preview to enrich the results with the `priority` field. Keep in mind that this preview API is subject to change once the API reached general availability.
22
+
18
23
  ## Examples
19
24
 
20
25
  Retrieve the the specified planner task
@@ -30,6 +30,11 @@ m365 planner task list [options]
30
30
 
31
31
  --8<-- "docs/cmd/_global.md"
32
32
 
33
+ ## Remarks
34
+
35
+ !!! attention
36
+ This command uses API that is currently in preview to enrich the results with the `priority` field. Keep in mind that this preview API is subject to change once the API reached general availability.
37
+
33
38
  ## Examples
34
39
 
35
40
  List tasks for the currently logged in user
@@ -22,6 +22,9 @@ m365 teams channel get [options]
22
22
  `--channelName [channelName]`
23
23
  : The display name of the channel for which to retrieve more information. Specify either channelId or channelName but not both
24
24
 
25
+ `--primary`
26
+ : Gets the default channel, General, of a team. If specified, channelId or channelName are not needed
27
+
25
28
  --8<-- "docs/cmd/_global.md"
26
29
 
27
30
  ## Examples
@@ -36,4 +39,10 @@ Get information about Microsoft Teams team channel with name _Channel Name_
36
39
 
37
40
  ```sh
38
41
  m365 teams channel get --teamName "Team Name" --channelName "Channel Name"
39
- ```
42
+ ```
43
+
44
+ Get information about Microsoft Teams team primary channel , i.e. General
45
+
46
+ ```sh
47
+ m365 teams channel get --teamName "Team Name" --primary
48
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "5.0.0-beta.d025005",
3
+ "version": "5.0.0-beta.d17a15f",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",
@@ -86,6 +86,7 @@
86
86
  "contributors": [
87
87
  "Ågren, Simon <simon.agren@sogeti.com>",
88
88
  "Albany, Bruce <bruce.albany@gmail.com>",
89
+ "Auckloo, Reshmee <reshmee011@gmail.com>",
89
90
  "Balasubramaniam, Jayakumar <jayakumar@live.in>",
90
91
  "Bauer, Stefan <stefan.bauer@n8d.at>",
91
92
  "Bernier, Hugo <hugoabernier@live.ca>",