@pnp/cli-microsoft365 4.4.0-beta.ffe290f → 5.0.0-beta.156f91b

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.
Files changed (63) hide show
  1. package/.eslintrc.js +1 -0
  2. package/dist/Command.js +1 -1
  3. package/dist/api.d.ts +11 -0
  4. package/dist/api.js +17 -0
  5. package/dist/cli/Cli.js +19 -4
  6. package/dist/m365/aad/commands/app/app-add.js +43 -7
  7. package/dist/m365/aad/commands/app/app-delete.js +126 -0
  8. package/dist/m365/aad/commands/group/group-list.js +9 -1
  9. package/dist/m365/aad/commands/oauth2grant/oauth2grant-list.js +7 -7
  10. package/dist/m365/aad/commands/oauth2grant/oauth2grant-remove.js +36 -12
  11. package/dist/m365/aad/commands/sp/sp-get.js +44 -21
  12. package/dist/m365/aad/commands/user/user-list.js +7 -4
  13. package/dist/m365/aad/commands.js +1 -0
  14. package/dist/m365/flow/commands/flow-get.js +2 -2
  15. package/dist/m365/planner/AppliedCategories.js +3 -0
  16. package/dist/m365/planner/commands/task/task-details-get.js +39 -0
  17. package/dist/m365/planner/commands/task/task-get.js +50 -0
  18. package/dist/m365/planner/commands/task/task-list.js +37 -7
  19. package/dist/m365/planner/commands/task/task-set.js +357 -0
  20. package/dist/m365/planner/commands.js +4 -1
  21. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN014008_CODE_launch_hostedWorkbench_type.js +62 -0
  22. package/dist/m365/spfx/commands/project/project-upgrade/{upgrade-1.14.0-beta.4.js → upgrade-1.14.0-rc.2.js} +27 -25
  23. package/dist/m365/spfx/commands/project/project-upgrade.js +1 -1
  24. package/dist/m365/spo/commands/group/group-user-add.js +64 -13
  25. package/dist/m365/spo/commands/group/group-user-remove.js +100 -0
  26. package/dist/m365/spo/commands/site/site-recyclebinitem-list.js +76 -0
  27. package/dist/m365/spo/commands.js +2 -0
  28. package/dist/m365/teams/commands/app/app-list.js +9 -6
  29. package/dist/m365/teams/commands/chat/chat-message-list.js +60 -0
  30. package/dist/m365/teams/commands/tab/tab-get.js +9 -6
  31. package/dist/m365/teams/commands.js +1 -0
  32. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-health-get.js +57 -0
  33. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-health-list.js +56 -0
  34. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-healthissue-get.js +39 -0
  35. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-healthissue-list.js +38 -0
  36. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-message-get.js +51 -0
  37. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-message-list.js +38 -0
  38. package/dist/m365/tenant/commands.js +6 -0
  39. package/docs/docs/cmd/aad/app/app-delete.md +51 -0
  40. package/docs/docs/cmd/aad/group/group-list.md +9 -0
  41. package/docs/docs/cmd/aad/oauth2grant/oauth2grant-list.md +4 -3
  42. package/docs/docs/cmd/aad/oauth2grant/oauth2grant-remove.md +9 -0
  43. package/docs/docs/cmd/aad/sp/sp-get.md +2 -1
  44. package/docs/docs/cmd/aad/user/user-list.md +9 -0
  45. package/docs/docs/cmd/planner/task/task-details-get.md +24 -0
  46. package/docs/docs/cmd/planner/task/task-get.md +29 -0
  47. package/docs/docs/cmd/planner/task/task-list.md +5 -0
  48. package/docs/docs/cmd/planner/task/task-set.md +99 -0
  49. package/docs/docs/cmd/search/externalconnection/externalconnection-add.md +3 -3
  50. package/docs/docs/cmd/spo/group/group-user-add.md +24 -6
  51. package/docs/docs/cmd/spo/group/group-user-remove.md +39 -0
  52. package/docs/docs/cmd/spo/site/site-recyclebinitem-list.md +40 -0
  53. package/docs/docs/cmd/teams/channel/channel-get.md +1 -1
  54. package/docs/docs/cmd/teams/chat/chat-message-list.md +24 -0
  55. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-get.md +33 -0
  56. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-list.md +30 -0
  57. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-get.md +24 -0
  58. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-list.md +34 -0
  59. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-get.md +28 -0
  60. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-list.md +34 -0
  61. package/npm-shrinkwrap.json +810 -772
  62. package/package.json +19 -18
  63. package/dist/m365/base/AadCommand.js +0 -10
package/.eslintrc.js CHANGED
@@ -23,6 +23,7 @@ const dictionary = [
23
23
  'group',
24
24
  'groupify',
25
25
  'guest',
26
+ 'health',
26
27
  'hide',
27
28
  'historical',
28
29
  'home',
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'
package/dist/api.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export interface CommandOutput {
2
+ error?: {
3
+ message: string;
4
+ code?: number;
5
+ }
6
+ stdout: string;
7
+ stderr: string;
8
+ }
9
+
10
+ export declare function executeCommand(commandName: string, options: any): Promise<CommandOutput>;
11
+ export declare function on(eventName: string, listener: (...args: any[]) => void): void;
package/dist/api.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeCommand = void 0;
4
+ const cli_1 = require("./cli");
5
+ const path = require("path");
6
+ function executeCommand(commandName, options, listener) {
7
+ const cli = cli_1.Cli.getInstance();
8
+ cli.commandsFolder = path.join(__dirname, 'm365');
9
+ cli.commands = [];
10
+ cli.loadCommandFromArgs(commandName.split(' '));
11
+ if (cli.commands.length !== 1) {
12
+ return Promise.reject(`Command not found: ${commandName}`);
13
+ }
14
+ return cli_1.Cli.executeCommandWithOutput(cli.commands[0].command, { options: options !== null && options !== void 0 ? options : {} }, listener);
15
+ }
16
+ exports.executeCommand = executeCommand;
17
+ //# sourceMappingURL=api.js.map
package/dist/cli/Cli.js CHANGED
@@ -189,23 +189,38 @@ class Cli {
189
189
  });
190
190
  });
191
191
  }
192
- static executeCommandWithOutput(command, args) {
192
+ static executeCommandWithOutput(command, args, listener) {
193
193
  return new Promise((resolve, reject) => {
194
194
  const log = [];
195
195
  const logErr = [];
196
196
  const logger = {
197
197
  log: (message) => {
198
- log.push(Cli.formatOutput(message, args.options));
198
+ const formattedMessage = Cli.formatOutput(message, args.options);
199
+ if (listener && listener.stdout) {
200
+ listener.stdout(formattedMessage);
201
+ }
202
+ log.push(formattedMessage);
199
203
  },
200
204
  logRaw: (message) => {
201
- log.push(Cli.formatOutput(message, args.options));
205
+ const formattedMessage = Cli.formatOutput(message, args.options);
206
+ if (listener && listener.stdout) {
207
+ listener.stdout(formattedMessage);
208
+ }
209
+ log.push(formattedMessage);
202
210
  },
203
211
  logToStderr: (message) => {
212
+ if (listener && listener.stderr) {
213
+ listener.stderr(message);
214
+ }
204
215
  logErr.push(message);
205
216
  }
206
217
  };
207
218
  if (args.options.debug) {
208
- logErr.push(`Executing command ${command.name} with options ${JSON.stringify(args)}`);
219
+ const message = `Executing command ${command.name} with options ${JSON.stringify(args)}`;
220
+ if (listener && listener.stderr) {
221
+ listener.stderr(message);
222
+ }
223
+ logErr.push(message);
209
224
  }
210
225
  // store the current command name, if any and set the name to the name of
211
226
  // the command to execute
@@ -105,21 +105,49 @@ class AadAppAddCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
105
105
  if (!args.options.manifest) {
106
106
  return Promise.resolve(appInfo);
107
107
  }
108
- const manifest = JSON.parse(args.options.manifest);
108
+ const v2Manifest = JSON.parse(args.options.manifest);
109
109
  // remove properties that might be coming from the original app that was
110
110
  // used to create the manifest and which can't be updated
111
- delete manifest.id;
112
- delete manifest.appId;
113
- delete manifest.publisherDomain;
111
+ delete v2Manifest.id;
112
+ delete v2Manifest.appId;
113
+ delete v2Manifest.publisherDomain;
114
114
  // Azure Portal returns v2 manifest whereas the Graph API expects a v1.6
115
- const transformedManifest = this.transformManifest(manifest);
115
+ const graphManifest = this.transformManifest(v2Manifest);
116
116
  const updateAppRequestOptions = {
117
117
  url: `${this.resource}/v1.0/myorganization/applications/${appInfo.id}`,
118
118
  headers: {
119
119
  'content-type': 'application/json'
120
120
  },
121
121
  responseType: 'json',
122
- data: transformedManifest
122
+ data: graphManifest
123
+ };
124
+ return request_1.default
125
+ .patch(updateAppRequestOptions)
126
+ .then(_ => this.updatePreAuthorizedAppsFromManifest(v2Manifest, appInfo))
127
+ .then(_ => Promise.resolve(appInfo));
128
+ }
129
+ updatePreAuthorizedAppsFromManifest(manifest, appInfo) {
130
+ if (!manifest ||
131
+ !manifest.preAuthorizedApplications ||
132
+ manifest.preAuthorizedApplications.length === 0) {
133
+ return Promise.resolve(appInfo);
134
+ }
135
+ const graphManifest = {
136
+ api: {
137
+ preAuthorizedApplications: manifest.preAuthorizedApplications
138
+ }
139
+ };
140
+ graphManifest.api.preAuthorizedApplications.forEach((p) => {
141
+ p.delegatedPermissionIds = p.permissionIds;
142
+ delete p.permissionIds;
143
+ });
144
+ const updateAppRequestOptions = {
145
+ url: `${this.resource}/v1.0/myorganization/applications/${appInfo.id}`,
146
+ headers: {
147
+ 'content-type': 'application/json'
148
+ },
149
+ responseType: 'json',
150
+ data: graphManifest
123
151
  };
124
152
  return request_1.default
125
153
  .patch(updateAppRequestOptions)
@@ -180,8 +208,16 @@ class AadAppAddCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
180
208
  delete graphManifest.oauth2AllowIdTokenImplicitFlow;
181
209
  graphManifest.api.oauth2PermissionScopes = v2Manifest.oauth2Permissions;
182
210
  delete graphManifest.oauth2Permissions;
211
+ if (graphManifest.api.oauth2PermissionScopes) {
212
+ graphManifest.api.oauth2PermissionScopes.forEach((scope) => {
213
+ delete scope.lang;
214
+ delete scope.origin;
215
+ });
216
+ }
183
217
  delete graphManifest.oauth2RequiredPostResponse;
184
- graphManifest.api.preAuthorizedApplications = v2Manifest.preAuthorizedApplications;
218
+ // MS Graph doesn't support creating OAuth2 permissions and pre-authorized
219
+ // apps in one request. This is why we need to remove it here and do it in
220
+ // the next request
185
221
  delete graphManifest.preAuthorizedApplications;
186
222
  if (v2Manifest.replyUrlsWithType) {
187
223
  v2Manifest.replyUrlsWithType.forEach((urlWithType) => {
@@ -0,0 +1,126 @@
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
+ return telemetryProps;
21
+ }
22
+ commandAction(logger, args, cb) {
23
+ const deleteApp = () => {
24
+ this
25
+ .processAppDelete(logger, args)
26
+ .then(_ => cb(), (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
27
+ };
28
+ if (args.options.confirm) {
29
+ deleteApp();
30
+ }
31
+ else {
32
+ cli_1.Cli.prompt({
33
+ type: 'confirm',
34
+ name: 'continue',
35
+ default: false,
36
+ message: `Are you sure you want to delete the App?`
37
+ }, (result) => {
38
+ if (!result.continue) {
39
+ cb();
40
+ }
41
+ else {
42
+ deleteApp();
43
+ }
44
+ });
45
+ }
46
+ }
47
+ processAppDelete(logger, args) {
48
+ return this
49
+ .getAadApp(args, logger)
50
+ .then((aadAppId) => {
51
+ if (this.verbose) {
52
+ logger.logToStderr(`Deleting Azure AD app ${aadAppId}...`);
53
+ }
54
+ const requestOptions = {
55
+ url: `${this.resource}/v1.0/myorganization/applications/${aadAppId}`,
56
+ headers: {
57
+ accept: 'application/json;odata.metadata=none'
58
+ },
59
+ responseType: 'json'
60
+ };
61
+ return request_1.default.delete(requestOptions);
62
+ });
63
+ }
64
+ getAadApp(args, logger) {
65
+ if (args.options.objectId) {
66
+ return Promise.resolve(args.options.objectId);
67
+ }
68
+ const { appId, name } = args.options;
69
+ if (this.verbose) {
70
+ logger.logToStderr(`Retrieving information about Azure AD app ${appId ? appId : name}...`);
71
+ }
72
+ const filter = appId ?
73
+ `appId eq '${encodeURIComponent(appId)}'` :
74
+ `displayName eq '${encodeURIComponent(name)}'`;
75
+ const requestOptions = {
76
+ url: `${this.resource}/v1.0/myorganization/applications?$filter=${filter}&$select=id`,
77
+ headers: {
78
+ accept: 'application/json;odata.metadata=none'
79
+ },
80
+ responseType: 'json'
81
+ };
82
+ return request_1.default
83
+ .get(requestOptions)
84
+ .then((res) => {
85
+ if (res.value.length === 1) {
86
+ return Promise.resolve(res.value[0].id);
87
+ }
88
+ if (res.value.length === 0) {
89
+ const applicationIdentifier = appId ? `ID ${appId}` : `name ${name}`;
90
+ return Promise.reject(`No Azure AD application registration with ${applicationIdentifier} found`);
91
+ }
92
+ return Promise.reject(`Multiple Azure AD application registration with name ${name} found. Please choose from one of the app object IDs: ${res.value.map(a => a.id).join(', ')}`);
93
+ });
94
+ }
95
+ options() {
96
+ const options = [
97
+ { option: '--appId [appId]' },
98
+ { option: '--objectId [objectId]' },
99
+ { option: '--name [name]' },
100
+ { option: '--confirm' }
101
+ ];
102
+ const parentOptions = super.options();
103
+ return options.concat(parentOptions);
104
+ }
105
+ validate(args) {
106
+ if (!args.options.appId &&
107
+ !args.options.objectId &&
108
+ !args.options.name) {
109
+ return 'Specify either appId, objectId, or name';
110
+ }
111
+ if ((args.options.appId && args.options.objectId) ||
112
+ (args.options.appId && args.options.name) ||
113
+ (args.options.objectId && args.options.name)) {
114
+ return 'Specify either appId, objectId, or name';
115
+ }
116
+ if (args.options.appId && !Utils_1.default.isValidGuid(args.options.appId)) {
117
+ return `${args.options.appId} is not a valid GUID`;
118
+ }
119
+ if (args.options.objectId && !Utils_1.default.isValidGuid(args.options.objectId)) {
120
+ return `${args.options.objectId} is not a valid GUID`;
121
+ }
122
+ return true;
123
+ }
124
+ }
125
+ module.exports = new AadAppDeleteCommand();
126
+ //# sourceMappingURL=app-delete.js.map
@@ -13,8 +13,9 @@ class AadGroupListCommand extends GraphItemsListCommand_1.GraphItemsListCommand
13
13
  return ['id', 'displayName', 'groupType'];
14
14
  }
15
15
  commandAction(logger, args, cb) {
16
+ const endpoint = args.options.deleted ? 'directory/deletedItems/microsoft.graph.group' : 'groups';
16
17
  this
17
- .getAllItems(`${this.resource}/v1.0/groups`, logger, true)
18
+ .getAllItems(`${this.resource}/v1.0/${endpoint}`, logger, true)
18
19
  .then(() => {
19
20
  if (args.options.output === 'text') {
20
21
  this.items.forEach((group) => {
@@ -36,6 +37,13 @@ class AadGroupListCommand extends GraphItemsListCommand_1.GraphItemsListCommand
36
37
  cb();
37
38
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
38
39
  }
40
+ options() {
41
+ const options = [
42
+ { option: '-d, --deleted' }
43
+ ];
44
+ const parentOptions = super.options();
45
+ return options.concat(parentOptions);
46
+ }
39
47
  }
40
48
  module.exports = new AadGroupListCommand();
41
49
  //# sourceMappingURL=group-list.js.map
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const request_1 = require("../../../../request");
4
4
  const Utils_1 = require("../../../../Utils");
5
- const AadCommand_1 = require("../../../base/AadCommand");
5
+ const GraphCommand_1 = require("../../../base/GraphCommand");
6
6
  const commands_1 = require("../../commands");
7
- class AadOAuth2GrantListCommand extends AadCommand_1.default {
7
+ class AadOAuth2GrantListCommand extends GraphCommand_1.default {
8
8
  get name() {
9
9
  return commands_1.default.OAUTH2GRANT_LIST;
10
10
  }
@@ -19,9 +19,9 @@ class AadOAuth2GrantListCommand extends AadCommand_1.default {
19
19
  logger.logToStderr(`Retrieving list of OAuth grants for the service principal...`);
20
20
  }
21
21
  const requestOptions = {
22
- url: `${this.resource}/myorganization/oauth2PermissionGrants?api-version=1.6&$filter=clientId eq '${encodeURIComponent(args.options.clientId)}'`,
22
+ url: `${this.resource}/v1.0/oauth2PermissionGrants?$filter=clientId eq '${encodeURIComponent(args.options.spObjectId)}'`,
23
23
  headers: {
24
- accept: 'application/json;odata=nometadata'
24
+ accept: 'application/json;odata.metadata=none'
25
25
  },
26
26
  responseType: 'json'
27
27
  };
@@ -37,15 +37,15 @@ class AadOAuth2GrantListCommand extends AadCommand_1.default {
37
37
  options() {
38
38
  const options = [
39
39
  {
40
- option: '-i, --clientId <clientId>'
40
+ option: '-i, --spObjectId <spObjectId>'
41
41
  }
42
42
  ];
43
43
  const parentOptions = super.options();
44
44
  return options.concat(parentOptions);
45
45
  }
46
46
  validate(args) {
47
- if (!Utils_1.default.isValidGuid(args.options.clientId)) {
48
- return `${args.options.clientId} is not a valid GUID`;
47
+ if (!Utils_1.default.isValidGuid(args.options.spObjectId)) {
48
+ return `${args.options.spObjectId} is not a valid GUID`;
49
49
  }
50
50
  return true;
51
51
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_1 = require("../../../../cli");
3
4
  const request_1 = require("../../../../request");
4
5
  const GraphCommand_1 = require("../../../base/GraphCommand");
5
6
  const commands_1 = require("../../commands");
@@ -11,24 +12,47 @@ class AadOAuth2GrantRemoveCommand extends GraphCommand_1.default {
11
12
  return 'Remove specified service principal OAuth2 permissions';
12
13
  }
13
14
  commandAction(logger, args, cb) {
14
- if (this.verbose) {
15
- logger.logToStderr(`Removing OAuth2 permissions...`);
16
- }
17
- const requestOptions = {
18
- url: `${this.resource}/v1.0/oauth2PermissionGrants/${encodeURIComponent(args.options.grantId)}`,
19
- headers: {
20
- 'accept': 'application/json;odata.metadata=none'
21
- },
22
- responseType: 'json'
15
+ const removeOauth2Grant = () => {
16
+ if (this.verbose) {
17
+ logger.logToStderr(`Removing OAuth2 permissions...`);
18
+ }
19
+ const requestOptions = {
20
+ url: `${this.resource}/v1.0/oauth2PermissionGrants/${encodeURIComponent(args.options.grantId)}`,
21
+ headers: {
22
+ 'accept': 'application/json;odata.metadata=none'
23
+ },
24
+ responseType: 'json'
25
+ };
26
+ request_1.default
27
+ .delete(requestOptions)
28
+ .then(_ => cb(), (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
23
29
  };
24
- request_1.default
25
- .delete(requestOptions)
26
- .then(_ => cb(), (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
30
+ if (args.options.confirm) {
31
+ removeOauth2Grant();
32
+ }
33
+ else {
34
+ cli_1.Cli.prompt({
35
+ type: 'confirm',
36
+ name: 'continue',
37
+ default: false,
38
+ message: `Are you sure you want to remove the OAuth2 permissions for ${args.options.grantId}?`
39
+ }, (result) => {
40
+ if (!result.continue) {
41
+ cb();
42
+ }
43
+ else {
44
+ removeOauth2Grant();
45
+ }
46
+ });
47
+ }
27
48
  }
28
49
  options() {
29
50
  const options = [
30
51
  {
31
52
  option: '-i, --grantId <grantId>'
53
+ },
54
+ {
55
+ option: '--confirm'
32
56
  }
33
57
  ];
34
58
  const parentOptions = super.options();
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const request_1 = require("../../../../request");
4
4
  const Utils_1 = require("../../../../Utils");
5
- const AadCommand_1 = require("../../../base/AadCommand");
5
+ const GraphCommand_1 = require("../../../base/GraphCommand");
6
6
  const commands_1 = require("../../commands");
7
- class AadSpGetCommand extends AadCommand_1.default {
7
+ class AadSpGetCommand extends GraphCommand_1.default {
8
8
  get name() {
9
9
  return commands_1.default.SP_GET;
10
10
  }
@@ -18,35 +18,58 @@ class AadSpGetCommand extends AadCommand_1.default {
18
18
  telemetryProps.objectId = (!(!args.options.objectId)).toString();
19
19
  return telemetryProps;
20
20
  }
21
- commandAction(logger, args, cb) {
22
- if (this.verbose) {
23
- logger.logToStderr(`Retrieving service principal information...`);
21
+ getSpId(args) {
22
+ if (args.options.objectId) {
23
+ return Promise.resolve(args.options.objectId);
24
24
  }
25
25
  let spMatchQuery = '';
26
- if (args.options.appId) {
27
- spMatchQuery = `appId eq '${encodeURIComponent(args.options.appId)}'`;
28
- }
29
- else if (args.options.objectId) {
30
- spMatchQuery = `objectId eq '${encodeURIComponent(args.options.objectId)}'`;
31
- }
32
- else {
26
+ if (args.options.displayName) {
33
27
  spMatchQuery = `displayName eq '${encodeURIComponent(args.options.displayName)}'`;
34
28
  }
35
- const requestOptions = {
36
- url: `${this.resource}/myorganization/servicePrincipals?api-version=1.6&$filter=${spMatchQuery}`,
29
+ else if (args.options.appId) {
30
+ spMatchQuery = `appId eq '${encodeURIComponent(args.options.appId)}'`;
31
+ }
32
+ const idRequestOptions = {
33
+ url: `${this.resource}/v1.0/servicePrincipals?$filter=${spMatchQuery}`,
37
34
  headers: {
38
- accept: 'application/json;odata=nometadata'
35
+ accept: 'application/json;odata.metadata=none'
39
36
  },
40
37
  responseType: 'json'
41
38
  };
42
- request_1.default
43
- .get(requestOptions)
44
- .then((res) => {
45
- if (res.value && res.value.length > 0) {
46
- logger.log(res.value[0]);
39
+ return request_1.default
40
+ .get(idRequestOptions)
41
+ .then(response => {
42
+ const spItem = response.value[0];
43
+ if (!spItem) {
44
+ return Promise.reject(`The specified Azure AD app does not exist`);
45
+ }
46
+ if (response.value.length > 1) {
47
+ return Promise.reject(`Multiple Azure AD apps with name ${args.options.displayName} found: ${response.value.map(x => x.id)}`);
47
48
  }
49
+ return Promise.resolve(spItem.id);
50
+ });
51
+ }
52
+ commandAction(logger, args, cb) {
53
+ if (this.verbose) {
54
+ logger.logToStderr(`Retrieving service principal information...`);
55
+ }
56
+ this
57
+ .getSpId(args)
58
+ .then((id) => {
59
+ const requestOptions = {
60
+ url: `${this.resource}/v1.0/servicePrincipals/${id}`,
61
+ headers: {
62
+ accept: 'application/json;odata.metadata=none',
63
+ 'content-type': 'application/json;odata.metadata=none'
64
+ },
65
+ responseType: 'json'
66
+ };
67
+ return request_1.default.get(requestOptions);
68
+ })
69
+ .then((res) => {
70
+ logger.log(res);
48
71
  cb();
49
- }, (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
72
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
50
73
  }
51
74
  options() {
52
75
  const options = [
@@ -15,6 +15,7 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
15
15
  getTelemetryProperties(args) {
16
16
  const telemetryProps = super.getTelemetryProperties(args);
17
17
  telemetryProps.properties = args.options.properties;
18
+ telemetryProps.deleted = typeof args.options.deleted !== 'undefined';
18
19
  return telemetryProps;
19
20
  }
20
21
  commandAction(logger, args, cb) {
@@ -22,7 +23,8 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
22
23
  args.options.properties.split(',').map(p => p.trim()) :
23
24
  ['userPrincipalName', 'displayName'];
24
25
  const filter = this.getFilter(args.options);
25
- const url = `${this.resource}/v1.0/users?$select=${properties.join(',')}${(filter.length > 0 ? '&' + filter : '')}&$top=100`;
26
+ const endpoint = args.options.deleted ? 'directory/deletedItems/microsoft.graph.user' : 'users';
27
+ const url = `${this.resource}/v1.0/${endpoint}?$select=${properties.join(',')}${(filter.length > 0 ? '&' + filter : '')}&$top=100`;
26
28
  this
27
29
  .getAllItems(url, logger, true)
28
30
  .then(() => {
@@ -35,6 +37,8 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
35
37
  const excludeOptions = [
36
38
  'properties',
37
39
  'p',
40
+ 'deleted',
41
+ 'd',
38
42
  'debug',
39
43
  'verbose',
40
44
  'output',
@@ -55,9 +59,8 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
55
59
  }
56
60
  options() {
57
61
  const options = [
58
- {
59
- option: '-p, --properties [properties]'
60
- }
62
+ { option: '-p, --properties [properties]' },
63
+ { option: '-d, --deleted' }
61
64
  ];
62
65
  const parentOptions = super.options();
63
66
  return options.concat(parentOptions);
@@ -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`,
@@ -29,8 +29,8 @@ class FlowGetCommand extends AzmgmtCommand_1.default {
29
29
  .then((res) => {
30
30
  res.displayName = res.properties.displayName;
31
31
  res.description = res.properties.definitionSummary.description || '';
32
- res.triggers = Object.keys(res.properties.definition.triggers).join(', ');
33
- res.actions = Object.keys(res.properties.definition.actions).join(', ');
32
+ res.triggers = res.properties.definitionSummary.triggers.map((t) => (t.type + (t.kind ? "-" + t.kind : ''))).join(', ');
33
+ res.actions = res.properties.definitionSummary.actions.map((a) => (a.type + (a.swaggerOperationId ? "-" + a.swaggerOperationId : ''))).join(', ');
34
34
  logger.log(res);
35
35
  cb();
36
36
  }, (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AppliedCategories.js.map
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const request_1 = require("../../../../request");
4
+ const GraphItemsListCommand_1 = require("../../../base/GraphItemsListCommand");
5
+ const commands_1 = require("../../commands");
6
+ class PlannerTaskDetailsGetCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
7
+ get name() {
8
+ return commands_1.default.TASK_DETAILS_GET;
9
+ }
10
+ get description() {
11
+ return 'Retrieve the details of the specified planner task';
12
+ }
13
+ commandAction(logger, args, cb) {
14
+ const requestOptions = {
15
+ url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(args.options.taskId)}/details`,
16
+ headers: {
17
+ accept: 'application/json;odata.metadata=none'
18
+ },
19
+ responseType: 'json'
20
+ };
21
+ request_1.default
22
+ .get(requestOptions)
23
+ .then((res) => {
24
+ logger.log(res);
25
+ cb();
26
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
27
+ }
28
+ options() {
29
+ const options = [
30
+ {
31
+ option: '-i, --taskId <taskId>'
32
+ }
33
+ ];
34
+ const parentOptions = super.options();
35
+ return options.concat(parentOptions);
36
+ }
37
+ }
38
+ module.exports = new PlannerTaskDetailsGetCommand();
39
+ //# sourceMappingURL=task-details-get.js.map