@pnp/cli-microsoft365 6.3.0-beta.c3dc921 → 6.3.0-beta.e0fa4e0

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 (188) hide show
  1. package/.eslintrc.js +8 -0
  2. package/dist/Auth.js +0 -18
  3. package/dist/Command.js +12 -1
  4. package/dist/cli/Cli.js +42 -1
  5. package/dist/m365/aad/commands/group/group-list.js +2 -1
  6. package/dist/m365/aad/commands/user/user-recyclebinitem-clear.js +103 -0
  7. package/dist/m365/aad/commands/user/user-recyclebinitem-remove.js +92 -0
  8. package/dist/m365/aad/commands.js +2 -0
  9. package/dist/m365/base/O365MgmtCommand.js +10 -0
  10. package/dist/m365/context/commands/option/option-list.js +54 -0
  11. package/dist/m365/context/commands.js +1 -0
  12. package/dist/m365/file/commands/convert/convert-pdf.js +7 -6
  13. package/dist/m365/flow/commands/run/run-list.js +55 -3
  14. package/dist/m365/graph/commands/changelog/changelog-list.js +3 -2
  15. package/dist/m365/onenote/commands/notebook/notebook-list.js +50 -53
  16. package/dist/m365/onenote/commands/page/page-list.js +2 -16
  17. package/dist/m365/outlook/commands/mail/mail-send.js +3 -2
  18. package/dist/m365/outlook/commands/message/message-get.js +4 -3
  19. package/dist/m365/pa/commands/environment/environment-get.js +13 -5
  20. package/dist/m365/planner/commands/plan/plan-add.js +20 -6
  21. package/dist/m365/planner/commands/plan/plan-get.js +40 -26
  22. package/dist/m365/planner/commands/plan/plan-list.js +24 -14
  23. package/dist/m365/planner/commands/plan/plan-remove.js +1 -1
  24. package/dist/m365/planner/commands/plan/plan-set.js +21 -10
  25. package/dist/m365/planner/commands/roster/roster-add.js +47 -0
  26. package/dist/m365/planner/commands/roster/roster-get.js +61 -0
  27. package/dist/m365/planner/commands/roster/roster-member-add.js +113 -0
  28. package/dist/m365/planner/commands/roster/roster-member-list.js +54 -0
  29. package/dist/m365/planner/commands/roster/roster-member-remove.js +140 -0
  30. package/dist/m365/planner/commands/roster/roster-remove.js +88 -0
  31. package/dist/m365/planner/commands/task/task-add.js +3 -0
  32. package/dist/m365/planner/commands/task/task-checklistitem-add.js +2 -1
  33. package/dist/m365/planner/commands/task/task-checklistitem-list.js +2 -1
  34. package/dist/m365/planner/commands.js +6 -0
  35. package/dist/m365/pp/commands/environment/environment-get.js +18 -9
  36. package/dist/m365/pp/commands/solution/solution-get.js +2 -1
  37. package/dist/m365/pp/commands/solution/solution-list.js +2 -1
  38. package/dist/m365/purview/commands/auditlog/auditlog-list.js +205 -0
  39. package/dist/m365/purview/commands/retentionevent/retentionevent-get.js +75 -0
  40. package/dist/m365/purview/commands/retentionevent/retentionevent-list.js +46 -0
  41. package/dist/m365/purview/commands/retentionevent/retentionevent-remove.js +97 -0
  42. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-add.js +77 -0
  43. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-get.js +75 -0
  44. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-list.js +43 -0
  45. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-remove.js +97 -0
  46. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-set.js +90 -0
  47. package/dist/m365/purview/commands/retentionlabel/retentionlabel-add.js +5 -0
  48. package/dist/m365/purview/commands/retentionlabel/retentionlabel-get.js +5 -0
  49. package/dist/m365/purview/commands/retentionlabel/retentionlabel-list.js +5 -0
  50. package/dist/m365/purview/commands/retentionlabel/retentionlabel-remove.js +5 -0
  51. package/dist/m365/purview/commands/retentionlabel/retentionlabel-set.js +11 -1
  52. package/dist/m365/purview/commands.js +9 -0
  53. package/dist/m365/spfx/commands/project/WebApiPermissionRequests.js +3 -0
  54. package/dist/m365/spfx/commands/project/project-permissions-grant.js +81 -0
  55. package/dist/m365/spfx/commands.js +3 -2
  56. package/dist/m365/spo/commands/app/app-add.js +2 -1
  57. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-add.js +95 -0
  58. package/dist/m365/spo/commands/customaction/customaction-get.js +17 -66
  59. package/dist/m365/spo/commands/customaction/customaction-list.js +2 -36
  60. package/dist/m365/spo/commands/customaction/customaction-remove.js +11 -18
  61. package/dist/m365/spo/commands/file/GraphFileDetails.js +0 -1
  62. package/dist/m365/spo/commands/file/file-sharinginfo-get.js +2 -1
  63. package/dist/m365/spo/commands/file/file-sharinglink-add.js +2 -22
  64. package/dist/m365/spo/commands/file/file-sharinglink-clear.js +137 -0
  65. package/dist/m365/spo/commands/file/file-sharinglink-get.js +2 -25
  66. package/dist/m365/spo/commands/file/file-sharinglink-list.js +9 -29
  67. package/dist/m365/spo/commands/file/file-sharinglink-remove.js +2 -25
  68. package/dist/m365/spo/commands/file/file-sharinglink-set.js +104 -0
  69. package/dist/m365/spo/commands/group/group-list.js +2 -1
  70. package/dist/m365/spo/commands/hubsite/hubsite-get.js +1 -1
  71. package/dist/m365/spo/commands/listitem/listitem-add.js +2 -1
  72. package/dist/m365/spo/commands/listitem/listitem-list.js +2 -1
  73. package/dist/m365/spo/commands/navigation/navigation-node-add.js +17 -3
  74. package/dist/m365/spo/commands/navigation/navigation-node-get.js +73 -0
  75. package/dist/m365/spo/commands/navigation/navigation-node-list.js +4 -7
  76. package/dist/m365/spo/commands/navigation/navigation-node-set.js +118 -0
  77. package/dist/m365/spo/commands/page/page-column-get.js +2 -1
  78. package/dist/m365/spo/commands/page/page-column-list.js +2 -1
  79. package/dist/m365/spo/commands/page/page-section-get.js +2 -1
  80. package/dist/m365/spo/commands/page/page-section-list.js +2 -1
  81. package/dist/m365/spo/commands/site/site-apppermission-add.js +2 -14
  82. package/dist/m365/spo/commands/site/site-apppermission-get.js +2 -14
  83. package/dist/m365/spo/commands/site/site-apppermission-list.js +2 -14
  84. package/dist/m365/spo/commands/site/site-apppermission-remove.js +2 -14
  85. package/dist/m365/spo/commands/site/site-apppermission-set.js +2 -14
  86. package/dist/m365/spo/commands/sitedesign/sitedesign-add.js +6 -0
  87. package/dist/m365/spo/commands/spo-search.js +2 -1
  88. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-add.js +179 -0
  89. package/dist/m365/spo/commands/term/term-list.js +2 -1
  90. package/dist/m365/spo/commands/userprofile/userprofile-get.js +2 -2
  91. package/dist/m365/spo/commands/web/web-set.js +11 -4
  92. package/dist/m365/spo/commands.js +6 -0
  93. package/dist/m365/teams/commands/chat/chat-list.js +4 -4
  94. package/dist/m365/teams/commands/meeting/meeting-attendancereport-list.js +5 -5
  95. package/dist/m365/teams/commands/meeting/meeting-get.js +5 -5
  96. package/dist/m365/teams/commands/meeting/meeting-list.js +5 -4
  97. package/dist/m365/teams/commands/team/team-app-list.js +1 -1
  98. package/dist/m365/teams/commands/user/user-app-list.js +2 -1
  99. package/dist/m365/todo/commands/task/task-get.js +2 -1
  100. package/dist/m365/todo/commands/task/task-list.js +2 -1
  101. package/dist/m365/yammer/commands/yammer-search.js +2 -1
  102. package/dist/utils/aadUser.js +38 -0
  103. package/dist/utils/accessToken.js +1 -1
  104. package/dist/utils/planner.js +16 -5
  105. package/dist/utils/spo.js +116 -0
  106. package/docs/docs/cmd/aad/app/app-list.md +3 -0
  107. package/docs/docs/cmd/aad/user/user-recyclebinitem-clear.md +42 -0
  108. package/docs/docs/cmd/aad/user/user-recyclebinitem-remove.md +45 -0
  109. package/docs/docs/cmd/aad/user/user-set.md +1 -1
  110. package/docs/docs/cmd/context/option/option-list.md +63 -0
  111. package/docs/docs/cmd/flow/run/run-list.md +21 -0
  112. package/docs/docs/cmd/login.md +26 -0
  113. package/docs/docs/cmd/logout.md +4 -0
  114. package/docs/docs/cmd/pa/app/app-get.md +24 -0
  115. package/docs/docs/cmd/pa/app/app-list.md +21 -0
  116. package/docs/docs/cmd/pa/connector/connector-list.md +17 -0
  117. package/docs/docs/cmd/pa/environment/environment-get.md +26 -2
  118. package/docs/docs/cmd/pa/environment/environment-list.md +19 -0
  119. package/docs/docs/cmd/planner/plan/plan-add.md +17 -6
  120. package/docs/docs/cmd/planner/plan/plan-get.md +21 -7
  121. package/docs/docs/cmd/planner/plan/plan-list.md +16 -2
  122. package/docs/docs/cmd/planner/plan/plan-remove.md +4 -0
  123. package/docs/docs/cmd/planner/plan/plan-set.md +10 -4
  124. package/docs/docs/cmd/planner/roster/roster-add.md +60 -0
  125. package/docs/docs/cmd/planner/roster/roster-get.md +73 -0
  126. package/docs/docs/cmd/planner/roster/roster-member-add.md +87 -0
  127. package/docs/docs/cmd/planner/roster/roster-member-list.md +76 -0
  128. package/docs/docs/cmd/planner/roster/roster-member-remove.md +51 -0
  129. package/docs/docs/cmd/planner/roster/roster-remove.md +48 -0
  130. package/docs/docs/cmd/pp/aibuildermodel/aibuildermodel-get.md +43 -0
  131. package/docs/docs/cmd/pp/aibuildermodel/aibuildermodel-list.md +43 -0
  132. package/docs/docs/cmd/pp/card/card-clone.md +12 -0
  133. package/docs/docs/cmd/pp/card/card-get.md +49 -0
  134. package/docs/docs/cmd/pp/card/card-list.md +49 -0
  135. package/docs/docs/cmd/pp/chatbot/chatbot-get.md +55 -0
  136. package/docs/docs/cmd/pp/chatbot/chatbot-list.md +36 -0
  137. package/docs/docs/cmd/pp/dataverse/dataverse-table-get.md +30 -0
  138. package/docs/docs/cmd/pp/dataverse/dataverse-table-list.md +30 -0
  139. package/docs/docs/cmd/pp/dataverse/dataverse-table-row-list.md +30 -0
  140. package/docs/docs/cmd/pp/environment/environment-get.md +19 -0
  141. package/docs/docs/cmd/pp/environment/environment-list.md +19 -0
  142. package/docs/docs/cmd/pp/gateway/gateway-get.md +19 -0
  143. package/docs/docs/cmd/pp/gateway/gateway-list.md +19 -0
  144. package/docs/docs/cmd/pp/managementapp/managementapp-add.md +12 -0
  145. package/docs/docs/cmd/pp/managementapp/managementapp-list.md +12 -0
  146. package/docs/docs/cmd/pp/solution/solution-get.md +14 -0
  147. package/docs/docs/cmd/pp/solution/solution-list.md +14 -0
  148. package/docs/docs/cmd/pp/solution/solution-publisher-get.md +20 -1
  149. package/docs/docs/cmd/pp/solution/solution-publisher-list.md +18 -0
  150. package/docs/docs/cmd/pp/tenant/tenant-settings-list.md +21 -0
  151. package/docs/docs/cmd/purview/auditlog/auditlog-list.md +123 -0
  152. package/docs/docs/cmd/purview/retentionevent/retentionevent-get.md +132 -0
  153. package/docs/docs/cmd/purview/retentionevent/retentionevent-list.md +107 -0
  154. package/docs/docs/cmd/purview/retentionevent/retentionevent-remove.md +45 -0
  155. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-add.md +106 -0
  156. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-get.md +103 -0
  157. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-list.md +97 -0
  158. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-remove.md +43 -0
  159. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-set.md +43 -0
  160. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-add.md +3 -0
  161. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-get.md +3 -0
  162. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-list.md +3 -0
  163. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-remove.md +3 -0
  164. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-set.md +3 -0
  165. package/docs/docs/cmd/request.md +74 -0
  166. package/docs/docs/cmd/spfx/project/project-permissions-grant.md +65 -0
  167. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-add.md +56 -0
  168. package/docs/docs/cmd/spo/file/file-sharinglink-clear.md +46 -0
  169. package/docs/docs/cmd/spo/file/file-sharinglink-list.md +1 -1
  170. package/docs/docs/cmd/spo/file/file-sharinglink-set.md +104 -0
  171. package/docs/docs/cmd/spo/list/list-contenttype-add.md +1 -1
  172. package/docs/docs/cmd/spo/list/list-contenttype-default-set.md +1 -1
  173. package/docs/docs/cmd/spo/list/list-contenttype-list.md +1 -1
  174. package/docs/docs/cmd/spo/list/list-contenttype-remove.md +1 -1
  175. package/docs/docs/cmd/spo/listitem/listitem-attachment-list.md +2 -2
  176. package/docs/docs/cmd/spo/listitem/listitem-isrecord.md +2 -2
  177. package/docs/docs/cmd/spo/navigation/navigation-node-add.md +18 -3
  178. package/docs/docs/cmd/spo/navigation/navigation-node-get.md +91 -0
  179. package/docs/docs/cmd/spo/navigation/navigation-node-list.md +30 -0
  180. package/docs/docs/cmd/spo/navigation/navigation-node-remove.md +1 -1
  181. package/docs/docs/cmd/spo/navigation/navigation-node-set.md +59 -0
  182. package/docs/docs/cmd/spo/sitedesign/sitedesign-add.md +3 -0
  183. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-add.md +59 -0
  184. package/docs/docs/cmd/spo/web/web-set.md +9 -0
  185. package/docs/docs/cmd/status.md +46 -0
  186. package/docs/docs/cmd/version.md +26 -0
  187. package/npm-shrinkwrap.json +911 -876
  188. package/package.json +12 -12
package/.eslintrc.js CHANGED
@@ -7,9 +7,11 @@ const dictionary = [
7
7
  'adaptive',
8
8
  'ai',
9
9
  'app',
10
+ 'application',
10
11
  'apply',
11
12
  'approve',
12
13
  'assets',
14
+ 'audit',
13
15
  'bin',
14
16
  'builder',
15
17
  'catalog',
@@ -19,8 +21,11 @@ const dictionary = [
19
21
  'content',
20
22
  'conversation',
21
23
  'custom',
24
+ 'customizer',
22
25
  'dataverse',
23
26
  'default',
27
+ 'event',
28
+ 'eventreceiver',
24
29
  'external',
25
30
  'externalize',
26
31
  'fun',
@@ -43,6 +48,9 @@ const dictionary = [
43
48
  'label',
44
49
  'list',
45
50
  'link',
51
+ 'log',
52
+ 'login',
53
+ 'logout',
46
54
  'management',
47
55
  'member',
48
56
  'messaging',
package/dist/Auth.js CHANGED
@@ -573,24 +573,6 @@ class Auth {
573
573
  getMsalCacheStorage() {
574
574
  return new FileTokenStorage_1.FileTokenStorage(FileTokenStorage_1.FileTokenStorage.msalCacheFilePath());
575
575
  }
576
- static isAppOnlyAuth(accessToken) {
577
- let isAppOnlyAuth;
578
- if (!accessToken || accessToken.length === 0) {
579
- return isAppOnlyAuth;
580
- }
581
- const chunks = accessToken.split('.');
582
- if (chunks.length !== 3) {
583
- return isAppOnlyAuth;
584
- }
585
- const tokenString = Buffer.from(chunks[1], 'base64').toString();
586
- try {
587
- const token = JSON.parse(tokenString);
588
- isAppOnlyAuth = !token.upn;
589
- }
590
- catch (_a) {
591
- }
592
- return isAppOnlyAuth;
593
- }
594
576
  }
595
577
  exports.Auth = Auth;
596
578
  exports.default = new Auth();
package/dist/Command.js CHANGED
@@ -481,7 +481,18 @@ class Command {
481
481
  if (!l) {
482
482
  return;
483
483
  }
484
- output.push(`## ${this.getLogItemTitle(l)} (${this.getLogItemId(l)})`, os.EOL, os.EOL, `Property | Value`, os.EOL, `---------|-------`, os.EOL);
484
+ const title = this.getLogItemTitle(l);
485
+ const id = this.getLogItemId(l);
486
+ if (title && id) {
487
+ output.push(`## ${title} (${id})`, os.EOL, os.EOL);
488
+ }
489
+ else if (title) {
490
+ output.push(`## ${title}`, os.EOL, os.EOL);
491
+ }
492
+ else if (id) {
493
+ output.push(`## ${id}`, os.EOL, os.EOL);
494
+ }
495
+ output.push(`Property | Value`, os.EOL, `---------|-------`, os.EOL);
485
496
  output.push(Object.keys(l).map(k => {
486
497
  const value = l[k];
487
498
  let stringValue = value;
package/dist/cli/Cli.js CHANGED
@@ -118,6 +118,8 @@ class Cli {
118
118
  }
119
119
  try {
120
120
  // process options before passing them on to validation stage
121
+ const contextCommandOptions = this.loadOptionsFromContext(this.commandToExecute.options, optionsWithoutShorts.options.debug);
122
+ optionsWithoutShorts.options = Object.assign(Object.assign({}, contextCommandOptions), optionsWithoutShorts.options);
121
123
  yield this.commandToExecute.command.processOptions(optionsWithoutShorts.options);
122
124
  }
123
125
  catch (e) {
@@ -283,6 +285,42 @@ class Cli {
283
285
  }
284
286
  this.loadCommandFromFile(commandFilePath);
285
287
  }
288
+ loadOptionsFromContext(commandOptions, debug) {
289
+ const filePath = '.m365rc.json';
290
+ let m365rc = {};
291
+ if (!fs.existsSync(filePath)) {
292
+ return;
293
+ }
294
+ if (debug) {
295
+ Cli.error('found .m365rc.json file');
296
+ }
297
+ try {
298
+ const fileContents = fs.readFileSync(filePath, 'utf8');
299
+ if (fileContents) {
300
+ m365rc = JSON.parse(fileContents);
301
+ }
302
+ }
303
+ catch (e) {
304
+ this.closeWithError(`Error parsing ${filePath}`, { options: {} });
305
+ }
306
+ if (!m365rc.context) {
307
+ return;
308
+ }
309
+ if (debug) {
310
+ Cli.error('found context in .m365rc.json file');
311
+ }
312
+ const context = m365rc.context;
313
+ const foundOptions = {};
314
+ commandOptions.forEach(option => {
315
+ if (context[option.name]) {
316
+ foundOptions[option.name] = context[option.name];
317
+ if (debug) {
318
+ Cli.error(`returning ${option.name} option from context`);
319
+ }
320
+ }
321
+ });
322
+ return foundOptions;
323
+ }
286
324
  /**
287
325
  * Loads command from the specified file into CLI. If can't find the file
288
326
  * or the file doesn't contain a command, loads all available commands.
@@ -458,7 +496,7 @@ class Cli {
458
496
  // data so that returned objects contain only default properties specified
459
497
  // on the current command. If there is no current command or the
460
498
  // command doesn't specify default properties, return original data
461
- if (options.output === 'text' || options.output === 'csv') {
499
+ if (this.shouldTrimOutput(options.output)) {
462
500
  const cli = Cli.getInstance();
463
501
  const currentCommand = cli.commandToExecute;
464
502
  if (arrayType === 'object' &&
@@ -753,6 +791,9 @@ class Cli {
753
791
  }
754
792
  });
755
793
  }
794
+ static shouldTrimOutput(output) {
795
+ return output === 'text' || output === 'csv';
796
+ }
756
797
  }
757
798
  exports.Cli = Cli;
758
799
  Cli.defaultHelpMode = 'full';
@@ -15,6 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _AadGroupListCommand_instances, _AadGroupListCommand_initTelemetry, _AadGroupListCommand_initOptions;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
18
19
  const odata_1 = require("../../../../utils/odata");
19
20
  const GraphCommand_1 = require("../../../base/GraphCommand");
20
21
  const commands_1 = require("../../commands");
@@ -39,7 +40,7 @@ class AadGroupListCommand extends GraphCommand_1.default {
39
40
  const endpoint = args.options.deleted ? 'directory/deletedItems/microsoft.graph.group' : 'groups';
40
41
  try {
41
42
  const groups = yield odata_1.odata.getAllItems(`${this.resource}/v1.0/${endpoint}`);
42
- if (args.options.output === 'text') {
43
+ if (Cli_1.Cli.shouldTrimOutput(args.options.output)) {
43
44
  groups.forEach((group) => {
44
45
  if (group.groupTypes && group.groupTypes.length > 0 && group.groupTypes[0] === 'Unified') {
45
46
  group.groupType = 'Microsoft 365';
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _AadUserRecycleBinItemClearCommand_instances, _AadUserRecycleBinItemClearCommand_initTelemetry, _AadUserRecycleBinItemClearCommand_initOptions;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const request_1 = require("../../../../request");
20
+ const odata_1 = require("../../../../utils/odata");
21
+ const GraphCommand_1 = require("../../../base/GraphCommand");
22
+ const commands_1 = require("../../commands");
23
+ class AadUserRecycleBinItemClearCommand extends GraphCommand_1.default {
24
+ get name() {
25
+ return commands_1.default.USER_RECYCLEBINITEM_CLEAR;
26
+ }
27
+ get description() {
28
+ return 'Removes all users from the tenant recycle bin';
29
+ }
30
+ constructor() {
31
+ super();
32
+ _AadUserRecycleBinItemClearCommand_instances.add(this);
33
+ __classPrivateFieldGet(this, _AadUserRecycleBinItemClearCommand_instances, "m", _AadUserRecycleBinItemClearCommand_initTelemetry).call(this);
34
+ __classPrivateFieldGet(this, _AadUserRecycleBinItemClearCommand_instances, "m", _AadUserRecycleBinItemClearCommand_initOptions).call(this);
35
+ }
36
+ commandAction(logger, args) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const clearRecycleBinUsers = () => __awaiter(this, void 0, void 0, function* () {
39
+ try {
40
+ const users = yield odata_1.odata.getAllItems(`${this.resource}/v1.0/directory/deletedItems/microsoft.graph.user?$select=id`);
41
+ if (this.verbose) {
42
+ logger.logToStderr(`Amount of users to permanently delete: ${users.length}`);
43
+ }
44
+ const batchRequests = users.map((user, index) => {
45
+ return {
46
+ id: index,
47
+ method: 'DELETE',
48
+ url: `/directory/deletedItems/${user.id}`
49
+ };
50
+ });
51
+ for (let i = 0; i < batchRequests.length; i += 20) {
52
+ const batchRequestChunk = batchRequests.slice(i, i + 20);
53
+ if (this.verbose) {
54
+ logger.logToStderr(`Deleting users: ${i + batchRequestChunk.length}/${users.length}`);
55
+ }
56
+ const requestOptions = {
57
+ url: `${this.resource}/v1.0/$batch`,
58
+ headers: {
59
+ accept: 'application/json',
60
+ 'content-type': 'application/json'
61
+ },
62
+ responseType: 'json',
63
+ data: {
64
+ requests: batchRequestChunk
65
+ }
66
+ };
67
+ yield request_1.default.post(requestOptions);
68
+ }
69
+ }
70
+ catch (err) {
71
+ this.handleRejectedODataJsonPromise(err);
72
+ }
73
+ });
74
+ if (args.options.confirm) {
75
+ yield clearRecycleBinUsers();
76
+ }
77
+ else {
78
+ const result = yield Cli_1.Cli.prompt({
79
+ type: 'confirm',
80
+ name: 'continue',
81
+ default: false,
82
+ message: 'Are you sure you want to permanently delete all deleted users?'
83
+ });
84
+ if (result.continue) {
85
+ yield clearRecycleBinUsers();
86
+ }
87
+ }
88
+ });
89
+ }
90
+ }
91
+ _AadUserRecycleBinItemClearCommand_instances = new WeakSet(), _AadUserRecycleBinItemClearCommand_initTelemetry = function _AadUserRecycleBinItemClearCommand_initTelemetry() {
92
+ this.telemetry.push((args) => {
93
+ Object.assign(this.telemetryProperties, {
94
+ confirm: !!args.options.confirm
95
+ });
96
+ });
97
+ }, _AadUserRecycleBinItemClearCommand_initOptions = function _AadUserRecycleBinItemClearCommand_initOptions() {
98
+ this.options.unshift({
99
+ option: '--confirm'
100
+ });
101
+ };
102
+ module.exports = new AadUserRecycleBinItemClearCommand();
103
+ //# sourceMappingURL=user-recyclebinitem-clear.js.map
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _AadUserRecycleBinItemRemoveCommand_instances, _AadUserRecycleBinItemRemoveCommand_initTelemetry, _AadUserRecycleBinItemRemoveCommand_initOptions, _AadUserRecycleBinItemRemoveCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const request_1 = require("../../../../request");
20
+ const validation_1 = require("../../../../utils/validation");
21
+ const GraphCommand_1 = require("../../../base/GraphCommand");
22
+ const commands_1 = require("../../commands");
23
+ class AadUserRecycleBinItemRemoveCommand extends GraphCommand_1.default {
24
+ get name() {
25
+ return commands_1.default.USER_RECYCLEBINITEM_REMOVE;
26
+ }
27
+ get description() {
28
+ return 'Removes a user from the recycle bin in the current tenant';
29
+ }
30
+ constructor() {
31
+ super();
32
+ _AadUserRecycleBinItemRemoveCommand_instances.add(this);
33
+ __classPrivateFieldGet(this, _AadUserRecycleBinItemRemoveCommand_instances, "m", _AadUserRecycleBinItemRemoveCommand_initTelemetry).call(this);
34
+ __classPrivateFieldGet(this, _AadUserRecycleBinItemRemoveCommand_instances, "m", _AadUserRecycleBinItemRemoveCommand_initOptions).call(this);
35
+ __classPrivateFieldGet(this, _AadUserRecycleBinItemRemoveCommand_instances, "m", _AadUserRecycleBinItemRemoveCommand_initValidators).call(this);
36
+ }
37
+ commandAction(logger, args) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const clearRecycleBinItem = () => __awaiter(this, void 0, void 0, function* () {
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Permanently deleting user with id ${args.options.id} from Azure Active Directory`);
42
+ }
43
+ try {
44
+ const requestOptions = {
45
+ url: `${this.resource}/v1.0/directory/deletedItems/${args.options.id}`,
46
+ headers: {}
47
+ };
48
+ yield request_1.default.delete(requestOptions);
49
+ }
50
+ catch (err) {
51
+ this.handleRejectedODataJsonPromise(err);
52
+ }
53
+ });
54
+ if (args.options.confirm) {
55
+ yield clearRecycleBinItem();
56
+ }
57
+ else {
58
+ const result = yield Cli_1.Cli.prompt({
59
+ type: 'confirm',
60
+ name: 'continue',
61
+ default: false,
62
+ message: `Are you sure you want to permanently delete the user with id ${args.options.id}?`
63
+ });
64
+ if (result.continue) {
65
+ yield clearRecycleBinItem();
66
+ }
67
+ }
68
+ });
69
+ }
70
+ }
71
+ _AadUserRecycleBinItemRemoveCommand_instances = new WeakSet(), _AadUserRecycleBinItemRemoveCommand_initTelemetry = function _AadUserRecycleBinItemRemoveCommand_initTelemetry() {
72
+ this.telemetry.push((args) => {
73
+ Object.assign(this.telemetryProperties, {
74
+ confirm: !!args.options.confirm
75
+ });
76
+ });
77
+ }, _AadUserRecycleBinItemRemoveCommand_initOptions = function _AadUserRecycleBinItemRemoveCommand_initOptions() {
78
+ this.options.unshift({
79
+ option: '--id <id>'
80
+ }, {
81
+ option: '--confirm'
82
+ });
83
+ }, _AadUserRecycleBinItemRemoveCommand_initValidators = function _AadUserRecycleBinItemRemoveCommand_initValidators() {
84
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
85
+ if (args.options.id && !validation_1.validation.isValidGuid(args.options.id)) {
86
+ return `${args.options.id} is not a valid GUID`;
87
+ }
88
+ return true;
89
+ }));
90
+ };
91
+ module.exports = new AadUserRecycleBinItemRemoveCommand();
92
+ //# sourceMappingURL=user-recyclebinitem-remove.js.map
@@ -60,6 +60,8 @@ exports.default = {
60
60
  USER_HIBP: `${prefix} user hibp`,
61
61
  USER_LIST: `${prefix} user list`,
62
62
  USER_PASSWORD_VALIDATE: `${prefix} user password validate`,
63
+ USER_RECYCLEBINITEM_CLEAR: `${prefix} user recyclebinitem clear`,
64
+ USER_RECYCLEBINITEM_REMOVE: `${prefix} user recyclebinitem remove`,
63
65
  USER_SET: `${prefix} user set`,
64
66
  USER_SIGNIN_LIST: `${prefix} user signin list`
65
67
  };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Command_1 = require("../../Command");
4
+ class O365MgmtCommand extends Command_1.default {
5
+ get resource() {
6
+ return 'https://manage.office.com';
7
+ }
8
+ }
9
+ exports.default = O365MgmtCommand;
10
+ //# sourceMappingURL=O365MgmtCommand.js.map
@@ -0,0 +1,54 @@
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 fs = require("fs");
13
+ const Command_1 = require("../../../../Command");
14
+ const ContextCommand_1 = require("../../../base/ContextCommand");
15
+ const commands_1 = require("../../commands");
16
+ class ContextOptionListCommand extends ContextCommand_1.default {
17
+ get name() {
18
+ return commands_1.default.OPTION_LIST;
19
+ }
20
+ get description() {
21
+ return 'List all options added to the context';
22
+ }
23
+ commandAction(logger) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ if (this.verbose) {
26
+ logger.logToStderr(`Retrieving context options...`);
27
+ }
28
+ const filePath = '.m365rc.json';
29
+ let m365rc = {};
30
+ if (fs.existsSync(filePath)) {
31
+ try {
32
+ if (this.verbose) {
33
+ logger.logToStderr(`Reading context file...`);
34
+ }
35
+ const fileContents = fs.readFileSync(filePath, 'utf8');
36
+ if (fileContents) {
37
+ m365rc = JSON.parse(fileContents);
38
+ }
39
+ }
40
+ catch (e) {
41
+ throw new Command_1.CommandError(`Error reading ${filePath}: ${e}. Please retrieve context options from ${filePath} manually.`);
42
+ }
43
+ }
44
+ if (!m365rc.context) {
45
+ throw new Command_1.CommandError(`No context present`);
46
+ }
47
+ else {
48
+ logger.log(m365rc.context);
49
+ }
50
+ });
51
+ }
52
+ }
53
+ module.exports = new ContextOptionListCommand();
54
+ //# sourceMappingURL=option-list.js.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'context';
4
4
  exports.default = {
5
5
  INIT: `${prefix} init`,
6
+ OPTION_LIST: `${prefix} option list`,
6
7
  OPTION_REMOVE: `${prefix} option remove`,
7
8
  OPTION_SET: `${prefix} option set`,
8
9
  REMOVE: `${prefix} remove`
@@ -23,6 +23,7 @@ const uuid_1 = require("uuid");
23
23
  const Auth_1 = require("../../../../Auth");
24
24
  const Command_1 = require("../../../../Command");
25
25
  const request_1 = require("../../../../request");
26
+ const accessToken_1 = require("../../../../utils/accessToken");
26
27
  const GraphCommand_1 = require("../../../base/GraphCommand");
27
28
  const commands_1 = require("../../commands");
28
29
  class FileConvertPdfCommand extends GraphCommand_1.default {
@@ -46,8 +47,8 @@ class FileConvertPdfCommand extends GraphCommand_1.default {
46
47
  let sourceIsLocalFile = true;
47
48
  let targetIsLocalFile = true;
48
49
  let error;
49
- const isAppOnlyAuth = Auth_1.Auth.isAppOnlyAuth(Auth_1.default.service.accessTokens[Auth_1.default.defaultResource].accessToken);
50
- if (typeof isAppOnlyAuth === 'undefined') {
50
+ const isAppOnlyAccessToken = accessToken_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[Auth_1.default.defaultResource].accessToken);
51
+ if (typeof isAppOnlyAccessToken === 'undefined') {
51
52
  throw 'Unable to determine authentication type';
52
53
  }
53
54
  if (args.options.sourceFile.toLowerCase().startsWith('https://')) {
@@ -62,7 +63,7 @@ class FileConvertPdfCommand extends GraphCommand_1.default {
62
63
  }
63
64
  try {
64
65
  try {
65
- sourceFileUrl = yield this.getSourceFileUrl(logger, args, isAppOnlyAuth);
66
+ sourceFileUrl = yield this.getSourceFileUrl(logger, args, isAppOnlyAccessToken);
66
67
  const graphFileUrl = yield this.getGraphFileUrl(logger, sourceFileUrl, this.sourceFileGraphUrl);
67
68
  const fileResponse = yield this.convertFile(logger, graphFileUrl);
68
69
  yield this.writeFileToDisk(logger, fileResponse, localTargetFilePath);
@@ -114,17 +115,17 @@ class FileConvertPdfCommand extends GraphCommand_1.default {
114
115
  * file to the user's OneDrive for Business
115
116
  * @param logger Logger instance
116
117
  * @param args Command args
117
- * @param isAppOnlyAuth True if CLI is authenticated in app-only mode
118
+ * @param isAppOnlyAccessToken True if CLI is authenticated in app-only mode
118
119
  * @returns Web URL of the file to upload
119
120
  */
120
- getSourceFileUrl(logger, args, isAppOnlyAuth) {
121
+ getSourceFileUrl(logger, args, isAppOnlyAccessToken) {
121
122
  if (args.options.sourceFile.toLowerCase().startsWith('https://')) {
122
123
  return Promise.resolve(args.options.sourceFile);
123
124
  }
124
125
  if (this.verbose) {
125
126
  logger.logToStderr('Uploading local file temporarily for conversion...');
126
127
  }
127
- const driveUrl = `${this.resource}/v1.0/${isAppOnlyAuth ? 'drive/root' : 'me/drive/root'}`;
128
+ const driveUrl = `${this.resource}/v1.0/${isAppOnlyAccessToken ? 'drive/root' : 'me/drive/root'}`;
128
129
  // we need the original file extension because otherwise Graph won't be able
129
130
  // to convert the file to PDF
130
131
  this.sourceFileGraphUrl = `${driveUrl}:/${(0, uuid_1.v4)()}${path.extname(args.options.sourceFile)}`;
@@ -13,9 +13,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
14
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
15
  };
16
- var _FlowRunListCommand_instances, _FlowRunListCommand_initOptions;
16
+ var _FlowRunListCommand_instances, _FlowRunListCommand_initTelemetry, _FlowRunListCommand_initOptions, _FlowRunListCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const formatting_1 = require("../../../../utils/formatting");
19
+ const validation_1 = require("../../../../utils/validation");
19
20
  const AzmgmtItemsListCommand_1 = require("../../../base/AzmgmtItemsListCommand");
20
21
  const commands_1 = require("../../commands");
21
22
  class FlowRunListCommand extends AzmgmtItemsListCommand_1.AzmgmtItemsListCommand {
@@ -31,14 +32,21 @@ class FlowRunListCommand extends AzmgmtItemsListCommand_1.AzmgmtItemsListCommand
31
32
  constructor() {
32
33
  super();
33
34
  _FlowRunListCommand_instances.add(this);
35
+ this.allowedStatusses = ['Succeeded', 'Running', 'Failed', 'Cancelled'];
36
+ __classPrivateFieldGet(this, _FlowRunListCommand_instances, "m", _FlowRunListCommand_initTelemetry).call(this);
34
37
  __classPrivateFieldGet(this, _FlowRunListCommand_instances, "m", _FlowRunListCommand_initOptions).call(this);
38
+ __classPrivateFieldGet(this, _FlowRunListCommand_instances, "m", _FlowRunListCommand_initValidators).call(this);
35
39
  }
36
40
  commandAction(logger, args) {
37
41
  return __awaiter(this, void 0, void 0, function* () {
38
42
  if (this.verbose) {
39
43
  logger.logToStderr(`Retrieving list of runs for Microsoft Flow ${args.options.flowName}...`);
40
44
  }
41
- const url = `${this.resource}providers/Microsoft.ProcessSimple/environments/${formatting_1.formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting_1.formatting.encodeQueryParameter(args.options.flowName)}/runs?api-version=2016-11-01`;
45
+ let url = `${this.resource}providers/Microsoft.ProcessSimple/environments/${formatting_1.formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting_1.formatting.encodeQueryParameter(args.options.flowName)}/runs?api-version=2016-11-01`;
46
+ const filters = this.getFilters(args.options);
47
+ if (filters.length > 0) {
48
+ url += `&$filter=${filters.join(' and ')}`;
49
+ }
42
50
  try {
43
51
  yield this.getAllItems(url, logger, true);
44
52
  if (this.items.length > 0) {
@@ -59,13 +67,57 @@ class FlowRunListCommand extends AzmgmtItemsListCommand_1.AzmgmtItemsListCommand
59
67
  }
60
68
  });
61
69
  }
70
+ getFilters(options) {
71
+ const filters = [];
72
+ if (options.status) {
73
+ filters.push(`status eq '${options.status}'`);
74
+ }
75
+ if (options.triggerStartTime) {
76
+ filters.push(`startTime ge ${options.triggerStartTime}`);
77
+ }
78
+ if (options.triggerEndTime) {
79
+ filters.push(`startTime lt ${options.triggerEndTime}`);
80
+ }
81
+ return filters;
82
+ }
62
83
  }
63
- _FlowRunListCommand_instances = new WeakSet(), _FlowRunListCommand_initOptions = function _FlowRunListCommand_initOptions() {
84
+ _FlowRunListCommand_instances = new WeakSet(), _FlowRunListCommand_initTelemetry = function _FlowRunListCommand_initTelemetry() {
85
+ this.telemetry.push((args) => {
86
+ Object.assign(this.telemetryProperties, {
87
+ status: typeof args.options.status !== 'undefined',
88
+ triggerStartTime: typeof args.options.triggerStartTime !== 'undefined',
89
+ triggerEndTime: typeof args.options.triggerEndTime !== 'undefined'
90
+ });
91
+ });
92
+ }, _FlowRunListCommand_initOptions = function _FlowRunListCommand_initOptions() {
64
93
  this.options.unshift({
65
94
  option: '-f, --flowName <flowName>'
66
95
  }, {
67
96
  option: '-e, --environmentName <environmentName>'
97
+ }, {
98
+ option: '--status [status]',
99
+ autocomplete: this.allowedStatusses
100
+ }, {
101
+ option: '--triggerStartTime [triggerStartTime]'
102
+ }, {
103
+ option: '--triggerEndTime [triggerEndTime]'
68
104
  });
105
+ }, _FlowRunListCommand_initValidators = function _FlowRunListCommand_initValidators() {
106
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
107
+ if (!validation_1.validation.isValidGuid(args.options.flowName)) {
108
+ return `${args.options.flowName} is not a valid GUID`;
109
+ }
110
+ if (args.options.status && this.allowedStatusses.indexOf(args.options.status) === -1) {
111
+ return `'${args.options.status}' is not a valid status. Allowed values are: ${this.allowedStatusses.join(',')}`;
112
+ }
113
+ if (args.options.triggerStartTime && !validation_1.validation.isValidISODateTime(args.options.triggerStartTime)) {
114
+ return `'${args.options.triggerStartTime}' is not a valid datetime.`;
115
+ }
116
+ if (args.options.triggerEndTime && !validation_1.validation.isValidISODateTime(args.options.triggerEndTime)) {
117
+ return `'${args.options.triggerEndTime}' is not a valid datetime.`;
118
+ }
119
+ return true;
120
+ }));
69
121
  };
70
122
  module.exports = new FlowRunListCommand();
71
123
  //# sourceMappingURL=run-list.js.map
@@ -21,6 +21,7 @@ const AnonymousCommand_1 = require("../../../base/AnonymousCommand");
21
21
  const commands_1 = require("../../commands");
22
22
  const request_1 = require("../../../../request");
23
23
  const xmldom_1 = require("@xmldom/xmldom");
24
+ const Cli_1 = require("../../../../cli/Cli");
24
25
  class GraphChangelogListCommand extends AnonymousCommand_1.default {
25
26
  get name() {
26
27
  return commands_1.default.CHANGELOG_LIST;
@@ -106,14 +107,14 @@ class GraphChangelogListCommand extends AnonymousCommand_1.default {
106
107
  items: []
107
108
  };
108
109
  Array.from(xmlDoc.getElementsByTagName('item')).forEach((item) => {
109
- const description = args.options.output === 'text' ?
110
+ const description = Cli_1.Cli.shouldTrimOutput(args.options.output) ?
110
111
  md_1.md.md2plain(item.getElementsByTagName('description').item(0).textContent, '') :
111
112
  item.getElementsByTagName('description').item(0).textContent;
112
113
  changelog.items.push({
113
114
  guid: item.getElementsByTagName('guid').item(0).textContent,
114
115
  category: item.getElementsByTagName('category').item(1).textContent,
115
116
  title: item.getElementsByTagName('title').item(0).textContent,
116
- description: args.options.output === 'text' ?
117
+ description: Cli_1.Cli.shouldTrimOutput(args.options.output) ?
117
118
  description.length > 50 ? `${description.substring(0, 47)}...` : description :
118
119
  description,
119
120
  pubDate: new Date(item.getElementsByTagName('pubDate').item(0).textContent)