@pnp/cli-microsoft365 6.3.0-beta.fee5cdb → 6.4.0-beta.3946b02

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 (107) hide show
  1. package/.eslintrc.js +1 -0
  2. package/dist/Command.js +1 -0
  3. package/dist/appInsights.js +2 -1
  4. package/dist/cli/Cli.js +70 -2
  5. package/dist/m365/aad/commands/license/license-list.js +41 -0
  6. package/dist/m365/aad/commands/user/user-add.js +223 -0
  7. package/dist/m365/aad/commands/user/user-license-add.js +88 -0
  8. package/dist/m365/aad/commands/user/user-license-list.js +99 -0
  9. package/dist/m365/aad/commands/user/user-license-remove.js +115 -0
  10. package/dist/m365/aad/commands/user/user-recyclebinitem-clear.js +1 -1
  11. package/dist/m365/aad/commands/user/user-recyclebinitem-list.js +41 -0
  12. package/dist/m365/aad/commands/user/user-recyclebinitem-remove.js +92 -0
  13. package/dist/m365/aad/commands/user/user-recyclebinitem-restore.js +70 -0
  14. package/dist/m365/aad/commands/user/user-remove.js +107 -0
  15. package/dist/m365/aad/commands.js +9 -0
  16. package/dist/m365/flow/commands/environment/FlowEnvironmentDetails.js +3 -0
  17. package/dist/m365/flow/commands/environment/environment-get.js +26 -11
  18. package/dist/m365/flow/commands/flow-disable.js +9 -2
  19. package/dist/m365/flow/commands/flow-enable.js +9 -2
  20. package/dist/m365/flow/commands/flow-get.js +9 -2
  21. package/dist/m365/flow/commands/flow-list.js +1 -1
  22. package/dist/m365/flow/commands/flow-remove.js +2 -2
  23. package/dist/m365/flow/commands/owner/owner-list.js +89 -0
  24. package/dist/m365/flow/commands/run/run-cancel.js +9 -2
  25. package/dist/m365/flow/commands.js +1 -0
  26. package/dist/m365/pp/commands/environment/environment-get.js +18 -9
  27. package/dist/m365/spo/commands/file/file-move.js +0 -2
  28. package/dist/m365/spo/commands/folder/folder-copy.js +0 -2
  29. package/dist/m365/spo/commands/folder/folder-move.js +0 -2
  30. package/dist/m365/spo/commands/site/site-add.js +0 -3
  31. package/dist/m365/spo/commands/site/site-remove.js +0 -3
  32. package/dist/m365/spo/commands/site/site-set.js +0 -2
  33. package/dist/m365/spo/commands/tenant/tenant-recyclebinitem-remove.js +0 -1
  34. package/dist/m365/spo/commands/term/term-get.js +68 -48
  35. package/dist/m365/teams/commands/team/team-add.js +3 -8
  36. package/dist/utils/session.js +18 -0
  37. package/dist/utils/spo.js +3 -12
  38. package/docs/docs/cmd/aad/approleassignment/approleassignment-add.md +5 -5
  39. package/docs/docs/cmd/aad/approleassignment/approleassignment-remove.md +3 -3
  40. package/docs/docs/cmd/aad/license/license-list.md +87 -0
  41. package/docs/docs/cmd/aad/user/user-add.md +168 -0
  42. package/docs/docs/cmd/aad/user/user-license-add.md +108 -0
  43. package/docs/docs/cmd/aad/user/user-license-list.md +98 -0
  44. package/docs/docs/cmd/aad/user/user-license-remove.md +43 -0
  45. package/docs/docs/cmd/aad/user/user-recyclebinitem-clear.md +1 -1
  46. package/docs/docs/cmd/aad/user/user-recyclebinitem-list.md +82 -0
  47. package/docs/docs/cmd/aad/user/user-recyclebinitem-remove.md +45 -0
  48. package/docs/docs/cmd/aad/user/user-recyclebinitem-restore.md +99 -0
  49. package/docs/docs/cmd/aad/user/user-remove.md +51 -0
  50. package/docs/docs/cmd/aad/user/user-set.md +1 -1
  51. package/docs/docs/cmd/flow/environment/environment-get.md +31 -3
  52. package/docs/docs/cmd/flow/owner/owner-list.md +90 -0
  53. package/docs/docs/cmd/spo/group/group-member-add.md +4 -4
  54. package/docs/docs/cmd/spo/homesite/homesite-get.md +20 -1
  55. package/docs/docs/cmd/spo/homesite/homesite-remove.md +8 -2
  56. package/docs/docs/cmd/spo/homesite/homesite-set.md +8 -2
  57. package/docs/docs/cmd/spo/hubsite/hubsite-connect.md +9 -9
  58. package/docs/docs/cmd/spo/hubsite/hubsite-data-get.md +34 -5
  59. package/docs/docs/cmd/spo/hubsite/hubsite-disconnect.md +6 -6
  60. package/docs/docs/cmd/spo/hubsite/hubsite-get.md +36 -19
  61. package/docs/docs/cmd/spo/hubsite/hubsite-list.md +59 -1
  62. package/docs/docs/cmd/spo/hubsite/hubsite-register.md +30 -1
  63. package/docs/docs/cmd/spo/hubsite/hubsite-rights-grant.md +6 -6
  64. package/docs/docs/cmd/spo/hubsite/hubsite-rights-revoke.md +4 -4
  65. package/docs/docs/cmd/spo/hubsite/hubsite-set.md +40 -15
  66. package/docs/docs/cmd/spo/hubsite/hubsite-unregister.md +4 -4
  67. package/docs/docs/cmd/spo/knowledgehub/knowledgehub-get.md +7 -1
  68. package/docs/docs/cmd/spo/knowledgehub/knowledgehub-remove.md +9 -3
  69. package/docs/docs/cmd/spo/knowledgehub/knowledgehub-set.md +8 -2
  70. package/docs/docs/cmd/spo/list/list-add.md +123 -57
  71. package/docs/docs/cmd/spo/list/list-contenttype-add.md +50 -5
  72. package/docs/docs/cmd/spo/list/list-contenttype-default-set.md +4 -4
  73. package/docs/docs/cmd/spo/list/list-contenttype-list.md +49 -4
  74. package/docs/docs/cmd/spo/list/list-contenttype-remove.md +6 -6
  75. package/docs/docs/cmd/spo/list/list-get.md +70 -4
  76. package/docs/docs/cmd/spo/list/list-list.md +70 -2
  77. package/docs/docs/cmd/spo/list/list-remove.md +6 -6
  78. package/docs/docs/cmd/spo/list/list-retentionlabel-ensure.md +2 -2
  79. package/docs/docs/cmd/spo/list/list-retentionlabel-get.md +36 -3
  80. package/docs/docs/cmd/spo/list/list-retentionlabel-remove.md +3 -3
  81. package/docs/docs/cmd/spo/list/list-roleassignment-add.md +6 -6
  82. package/docs/docs/cmd/spo/list/list-roleassignment-remove.md +3 -3
  83. package/docs/docs/cmd/spo/list/list-roleinheritance-break.md +9 -9
  84. package/docs/docs/cmd/spo/list/list-roleinheritance-reset.md +7 -7
  85. package/docs/docs/cmd/spo/list/list-set.md +61 -61
  86. package/docs/docs/cmd/spo/list/list-sitescript-get.md +35 -3
  87. package/docs/docs/cmd/spo/list/list-view-add.md +66 -5
  88. package/docs/docs/cmd/spo/list/list-view-field-add.md +10 -10
  89. package/docs/docs/cmd/spo/list/list-view-get.md +61 -0
  90. package/docs/docs/cmd/spo/list/list-view-list.md +61 -0
  91. package/docs/docs/cmd/spo/list/list-view-set.md +1 -1
  92. package/docs/docs/cmd/spo/list/list-webhook-add.md +19 -0
  93. package/docs/docs/cmd/spo/list/list-webhook-get.md +19 -0
  94. package/docs/docs/cmd/spo/list/list-webhook-list.md +19 -0
  95. package/docs/docs/cmd/spo/listitem/listitem-add.md +29 -0
  96. package/docs/docs/cmd/spo/listitem/listitem-attachment-list.md +17 -2
  97. package/docs/docs/cmd/spo/listitem/listitem-get.md +57 -0
  98. package/docs/docs/cmd/spo/listitem/listitem-isrecord.md +6 -0
  99. package/docs/docs/cmd/spo/listitem/listitem-list.md +28 -0
  100. package/docs/docs/cmd/spo/listitem/listitem-record-declare.md +15 -0
  101. package/docs/docs/cmd/spo/listitem/listitem-set.md +30 -0
  102. package/docs/docs/cmd/spo/navigation/navigation-node-add.md +23 -1
  103. package/docs/docs/cmd/spo/navigation/navigation-node-set.md +1 -1
  104. package/docs/docs/cmd/spo/tenant/tenant-settings-set.md +26 -26
  105. package/docs/docs/cmd/teams/channel/channel-member-add.md +2 -2
  106. package/npm-shrinkwrap.json +3 -2
  107. package/package.json +2 -1
@@ -82,8 +82,8 @@ class FlowRemoveCommand extends AzmgmtCommand_1.default {
82
82
  _FlowRemoveCommand_instances = new WeakSet(), _FlowRemoveCommand_initTelemetry = function _FlowRemoveCommand_initTelemetry() {
83
83
  this.telemetry.push((args) => {
84
84
  Object.assign(this.telemetryProperties, {
85
- asAdmin: typeof args.options.asAdmin !== 'undefined',
86
- confirm: typeof args.options.confirm !== 'undefined'
85
+ asAdmin: !!args.options.asAdmin,
86
+ confirm: !!args.options.confirm
87
87
  });
88
88
  });
89
89
  }, _FlowRemoveCommand_initOptions = function _FlowRemoveCommand_initOptions() {
@@ -0,0 +1,89 @@
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 _FlowOwnerListCommand_instances, _FlowOwnerListCommand_initTelemetry, _FlowOwnerListCommand_initOptions, _FlowOwnerListCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const formatting_1 = require("../../../../utils/formatting");
20
+ const odata_1 = require("../../../../utils/odata");
21
+ const validation_1 = require("../../../../utils/validation");
22
+ const AzmgmtCommand_1 = require("../../../base/AzmgmtCommand");
23
+ const commands_1 = require("../../commands");
24
+ class FlowOwnerListCommand extends AzmgmtCommand_1.default {
25
+ get name() {
26
+ return commands_1.default.OWNER_LIST;
27
+ }
28
+ get description() {
29
+ return 'Lists all owners of a Power Automate flow';
30
+ }
31
+ defaultProperties() {
32
+ return ['roleName', 'id', 'type'];
33
+ }
34
+ constructor() {
35
+ super();
36
+ _FlowOwnerListCommand_instances.add(this);
37
+ __classPrivateFieldGet(this, _FlowOwnerListCommand_instances, "m", _FlowOwnerListCommand_initTelemetry).call(this);
38
+ __classPrivateFieldGet(this, _FlowOwnerListCommand_instances, "m", _FlowOwnerListCommand_initOptions).call(this);
39
+ __classPrivateFieldGet(this, _FlowOwnerListCommand_instances, "m", _FlowOwnerListCommand_initValidators).call(this);
40
+ }
41
+ commandAction(logger, args) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ try {
44
+ if (this.verbose) {
45
+ logger.logToStderr(`Listing owners for flow ${args.options.flowName} in environment ${args.options.environmentName}`);
46
+ }
47
+ const response = yield odata_1.odata.getAllItems(`${this.resource}providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting_1.formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting_1.formatting.encodeQueryParameter(args.options.flowName)}/permissions?api-version=2016-11-01`);
48
+ if (!Cli_1.Cli.shouldTrimOutput(args.options.output)) {
49
+ logger.log(response);
50
+ }
51
+ else {
52
+ //converted to text friendly output
53
+ logger.log(response.map(res => ({
54
+ roleName: res.properties.roleName,
55
+ id: res.properties.principal.id,
56
+ type: res.properties.principal.type
57
+ })));
58
+ }
59
+ }
60
+ catch (err) {
61
+ this.handleRejectedODataJsonPromise(err);
62
+ }
63
+ });
64
+ }
65
+ }
66
+ _FlowOwnerListCommand_instances = new WeakSet(), _FlowOwnerListCommand_initTelemetry = function _FlowOwnerListCommand_initTelemetry() {
67
+ this.telemetry.push((args) => {
68
+ Object.assign(this.telemetryProperties, {
69
+ asAdmin: !!args.options.asAdmin
70
+ });
71
+ });
72
+ }, _FlowOwnerListCommand_initOptions = function _FlowOwnerListCommand_initOptions() {
73
+ this.options.unshift({
74
+ option: '-e, --environmentName <environmentName>'
75
+ }, {
76
+ option: '-f, --flowName <flowName>'
77
+ }, {
78
+ option: '--asAdmin'
79
+ });
80
+ }, _FlowOwnerListCommand_initValidators = function _FlowOwnerListCommand_initValidators() {
81
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
82
+ if (!validation_1.validation.isValidGuid(args.options.flowName)) {
83
+ return `${args.options.flowName} is not a valid GUID.`;
84
+ }
85
+ return true;
86
+ }));
87
+ };
88
+ module.exports = new FlowOwnerListCommand();
89
+ //# sourceMappingURL=owner-list.js.map
@@ -13,7 +13,7 @@ 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 _FlowRunCancelCommand_instances, _FlowRunCancelCommand_initOptions, _FlowRunCancelCommand_initValidators;
16
+ var _FlowRunCancelCommand_instances, _FlowRunCancelCommand_initTelemetry, _FlowRunCancelCommand_initOptions, _FlowRunCancelCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const Cli_1 = require("../../../../cli/Cli");
19
19
  const request_1 = require("../../../../request");
@@ -31,6 +31,7 @@ class FlowRunCancelCommand extends AzmgmtCommand_1.default {
31
31
  constructor() {
32
32
  super();
33
33
  _FlowRunCancelCommand_instances.add(this);
34
+ __classPrivateFieldGet(this, _FlowRunCancelCommand_instances, "m", _FlowRunCancelCommand_initTelemetry).call(this);
34
35
  __classPrivateFieldGet(this, _FlowRunCancelCommand_instances, "m", _FlowRunCancelCommand_initOptions).call(this);
35
36
  __classPrivateFieldGet(this, _FlowRunCancelCommand_instances, "m", _FlowRunCancelCommand_initValidators).call(this);
36
37
  }
@@ -71,7 +72,13 @@ class FlowRunCancelCommand extends AzmgmtCommand_1.default {
71
72
  });
72
73
  }
73
74
  }
74
- _FlowRunCancelCommand_instances = new WeakSet(), _FlowRunCancelCommand_initOptions = function _FlowRunCancelCommand_initOptions() {
75
+ _FlowRunCancelCommand_instances = new WeakSet(), _FlowRunCancelCommand_initTelemetry = function _FlowRunCancelCommand_initTelemetry() {
76
+ this.telemetry.push((args) => {
77
+ Object.assign(this.telemetryProperties, {
78
+ confirm: !!args.options.confirm
79
+ });
80
+ });
81
+ }, _FlowRunCancelCommand_initOptions = function _FlowRunCancelCommand_initOptions() {
75
82
  this.options.unshift({
76
83
  option: '-n, --name <name>'
77
84
  }, {
@@ -11,6 +11,7 @@ exports.default = {
11
11
  EXPORT: `${prefix} export`,
12
12
  GET: `${prefix} get`,
13
13
  LIST: `${prefix} list`,
14
+ OWNER_LIST: `${prefix} owner list`,
14
15
  REMOVE: `${prefix} remove`,
15
16
  RUN_CANCEL: `${prefix} run cancel`,
16
17
  RUN_GET: `${prefix} run get`,
@@ -15,9 +15,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _PpEnvironmentGetCommand_instances, _PpEnvironmentGetCommand_initTelemetry, _PpEnvironmentGetCommand_initOptions;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- const odata_1 = require("../../../../utils/odata");
19
18
  const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
20
19
  const commands_1 = require("../../commands");
20
+ const request_1 = require("../../../../request");
21
+ const formatting_1 = require("../../../../utils/formatting");
21
22
  class PpEnvironmentGetCommand extends PowerPlatformCommand_1.default {
22
23
  get name() {
23
24
  return commands_1.default.ENVIRONMENT_GET;
@@ -36,16 +37,24 @@ class PpEnvironmentGetCommand extends PowerPlatformCommand_1.default {
36
37
  }
37
38
  commandAction(logger, args) {
38
39
  return __awaiter(this, void 0, void 0, function* () {
39
- let url = `${this.resource}/providers/Microsoft.BusinessAppPlatform/environments`;
40
- if (args.options.asAdmin) {
41
- url = `${this.resource}/providers/Microsoft.BusinessAppPlatform/scopes/admin/environments`;
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Retrieving environment: ${args.options.name || 'default'}`);
42
42
  }
43
- const res = yield odata_1.odata.getAllItems(`${url}?api-version=2020-10-01`);
44
- const environmentItem = res.filter((env) => args.options.name ? env.name === args.options.name : env.properties.isDefault === true)[0];
45
- if (!environmentItem) {
46
- throw `The specified Power Platform environment does not exist`;
43
+ let url = `${this.resource}/providers/Microsoft.BusinessAppPlatform`;
44
+ if (args.options.asAdmin) {
45
+ url += '/scopes/admin';
47
46
  }
48
- logger.log(environmentItem);
47
+ const envName = args.options.name ? formatting_1.formatting.encodeQueryParameter(args.options.name) : '~Default';
48
+ url += `/environments/${envName}?api-version=2020-10-01`;
49
+ const requestOptions = {
50
+ url: url,
51
+ headers: {
52
+ accept: 'application/json;odata.metadata=none'
53
+ },
54
+ responseType: 'json'
55
+ };
56
+ const response = yield request_1.default.get(requestOptions);
57
+ logger.log(response);
49
58
  });
50
59
  }
51
60
  }
@@ -82,7 +82,6 @@ class SpoFileMoveCommand extends SpoCommand_1.default {
82
82
  responseType: 'json'
83
83
  };
84
84
  const jobInfo = yield request_1.default.post(requestOptions);
85
- this.dots = '';
86
85
  const copyJobInfo = jobInfo.value[0];
87
86
  const progressPollInterval = 1800; // 30 * 60; //used previously implemented interval. The API does not provide guidance on what value should be used.
88
87
  yield new Promise((resolve, reject) => {
@@ -94,7 +93,6 @@ class SpoFileMoveCommand extends SpoCommand_1.default {
94
93
  resolve,
95
94
  reject,
96
95
  logger,
97
- dots: this.dots,
98
96
  debug: this.debug,
99
97
  verbose: this.verbose
100
98
  });
@@ -64,7 +64,6 @@ class SpoFolderCopyCommand extends SpoCommand_1.default {
64
64
  };
65
65
  try {
66
66
  const jobInfo = yield request_1.default.post(requestOptions);
67
- this.dots = '';
68
67
  const copyJobInfo = jobInfo.value[0];
69
68
  const progressPollInterval = 30 * 60; //used previously implemented interval. The API does not provide guidance on what value should be used.
70
69
  yield new Promise((resolve, reject) => {
@@ -76,7 +75,6 @@ class SpoFolderCopyCommand extends SpoCommand_1.default {
76
75
  resolve,
77
76
  reject,
78
77
  logger,
79
- dots: this.dots,
80
78
  debug: this.debug,
81
79
  verbose: this.verbose
82
80
  });
@@ -65,7 +65,6 @@ class SpoFolderMoveCommand extends SpoCommand_1.default {
65
65
  };
66
66
  try {
67
67
  const jobInfo = yield request_1.default.post(requestOptions);
68
- this.dots = '';
69
68
  const copyJobInfo = jobInfo.value[0];
70
69
  const progressPollInterval = 30 * 60; //used previously implemented interval. The API does not provide guidance on what value should be used.
71
70
  yield new Promise((resolve, reject) => {
@@ -77,7 +76,6 @@ class SpoFolderMoveCommand extends SpoCommand_1.default {
77
76
  resolve,
78
77
  reject,
79
78
  logger,
80
- dots: this.dots,
81
79
  debug: this.debug,
82
80
  verbose: this.verbose
83
81
  });
@@ -166,7 +166,6 @@ class SpoSiteAddCommand extends SpoCommand_1.default {
166
166
  }
167
167
  createClassicSite(logger, args) {
168
168
  return __awaiter(this, void 0, void 0, function* () {
169
- this.dots = '';
170
169
  try {
171
170
  this.spoAdminUrl = yield spo_1.spo.getSpoAdminUrl(logger, this.debug);
172
171
  this.context = yield spo_1.spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
@@ -228,7 +227,6 @@ class SpoSiteAddCommand extends SpoCommand_1.default {
228
227
  reject,
229
228
  logger,
230
229
  currentContext: this.context,
231
- dots: this.dots,
232
230
  verbose: this.verbose,
233
231
  debug: this.debug
234
232
  });
@@ -362,7 +360,6 @@ class SpoSiteAddCommand extends SpoCommand_1.default {
362
360
  reject,
363
361
  logger,
364
362
  currentContext: this.context,
365
- dots: this.dots,
366
363
  verbose: this.verbose,
367
364
  debug: this.debug
368
365
  });
@@ -43,7 +43,6 @@ class SpoSiteRemoveCommand extends SpoCommand_1.default {
43
43
  return __awaiter(this, void 0, void 0, function* () {
44
44
  const removeSite = () => __awaiter(this, void 0, void 0, function* () {
45
45
  try {
46
- this.dots = '';
47
46
  if (args.options.fromRecycleBin) {
48
47
  yield this.deleteSiteWithoutGroup(logger, args);
49
48
  }
@@ -203,7 +202,6 @@ class SpoSiteRemoveCommand extends SpoCommand_1.default {
203
202
  reject,
204
203
  logger,
205
204
  currentContext: this.context,
206
- dots: this.dots,
207
205
  debug: this.debug,
208
206
  verbose: this.verbose
209
207
  });
@@ -248,7 +246,6 @@ class SpoSiteRemoveCommand extends SpoCommand_1.default {
248
246
  reject,
249
247
  logger,
250
248
  currentContext: this.context,
251
- dots: this.dots,
252
249
  debug: this.debug,
253
250
  verbose: this.verbose
254
251
  });
@@ -46,7 +46,6 @@ class SpoSiteSetCommand extends SpoCommand_1.default {
46
46
  commandAction(logger, args) {
47
47
  return __awaiter(this, void 0, void 0, function* () {
48
48
  try {
49
- this.dots = '';
50
49
  this.tenantId = yield spo_1.spo.getTenantId(logger, this.debug);
51
50
  this.spoAdminUrl = yield spo_1.spo.getSpoAdminUrl(logger, this.debug);
52
51
  this.context = yield spo_1.spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
@@ -128,7 +127,6 @@ class SpoSiteSetCommand extends SpoCommand_1.default {
128
127
  reject,
129
128
  logger,
130
129
  currentContext: this.context,
131
- dots: this.dots,
132
130
  debug: this.debug,
133
131
  verbose: this.verbose
134
132
  });
@@ -74,7 +74,6 @@ class SpoTenantRecycleBinItemRemoveCommand extends SpoCommand_1.default {
74
74
  reject,
75
75
  logger,
76
76
  currentContext: this.context,
77
- dots: this.dots,
78
77
  debug: this.debug,
79
78
  verbose: this.verbose
80
79
  });
@@ -22,6 +22,7 @@ const spo_1 = require("../../../../utils/spo");
22
22
  const validation_1 = require("../../../../utils/validation");
23
23
  const SpoCommand_1 = require("../../../base/SpoCommand");
24
24
  const commands_1 = require("../../commands");
25
+ const os = require("os");
25
26
  class SpoTermGetCommand extends SpoCommand_1.default {
26
27
  get name() {
27
28
  return commands_1.default.TERM_GET;
@@ -50,32 +51,34 @@ class SpoTermGetCommand extends SpoCommand_1.default {
50
51
  data = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="14" ObjectPathId="13" /><ObjectIdentityQuery Id="15" ObjectPathId="13" /><Query Id="16" ObjectPathId="13"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><StaticMethod Id="6" Name="GetTaxonomySession" TypeId="{981cbc68-9edc-4f8d-872f-71146fcbb84f}" /><Method Id="7" ParentId="6" Name="GetDefaultSiteCollectionTermStore" /><Method Id="13" ParentId="7" Name="GetTerm"><Parameters><Parameter Type="Guid">{${args.options.id}}</Parameter></Parameters></Method></ObjectPaths></Request>`;
51
52
  }
52
53
  else {
53
- const termGroupQuery = args.options.termGroupId ? `<Method Id="98" ParentId="96" Name="GetById"><Parameters><Parameter Type="Guid">{${args.options.termGroupId}}</Parameter></Parameters></Method>` : `<Method Id="98" ParentId="96" Name="GetByName"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(args.options.termGroupName)}</Parameter></Parameters></Method>`;
54
- const termSetQuery = args.options.termSetId ? `<Method Id="103" ParentId="101" Name="GetById"><Parameters><Parameter Type="Guid">{${args.options.termSetId}}</Parameter></Parameters></Method>` : `<Method Id="103" ParentId="101" Name="GetByName"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(args.options.termSetName)}</Parameter></Parameters></Method>`;
55
- data = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="91" ObjectPathId="90" /><ObjectIdentityQuery Id="92" ObjectPathId="90" /><ObjectPath Id="94" ObjectPathId="93" /><ObjectIdentityQuery Id="95" ObjectPathId="93" /><ObjectPath Id="97" ObjectPathId="96" /><ObjectPath Id="99" ObjectPathId="98" /><ObjectIdentityQuery Id="100" ObjectPathId="98" /><ObjectPath Id="102" ObjectPathId="101" /><ObjectPath Id="104" ObjectPathId="103" /><ObjectIdentityQuery Id="105" ObjectPathId="103" /><ObjectPath Id="107" ObjectPathId="106" /><ObjectPath Id="109" ObjectPathId="108" /><ObjectIdentityQuery Id="110" ObjectPathId="108" /><Query Id="111" ObjectPathId="108"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><StaticMethod Id="90" Name="GetTaxonomySession" TypeId="{981cbc68-9edc-4f8d-872f-71146fcbb84f}" /><Method Id="93" ParentId="90" Name="GetDefaultSiteCollectionTermStore" /><Property Id="96" ParentId="93" Name="Groups" />${termGroupQuery}<Property Id="101" ParentId="98" Name="TermSets" />${termSetQuery}<Property Id="106" ParentId="103" Name="Terms" /><Method Id="108" ParentId="106" Name="GetByName"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(args.options.name)}</Parameter></Parameters></Method></ObjectPaths></Request>`;
54
+ data = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="2" ObjectPathId="1" /><ObjectIdentityQuery Id="3" ObjectPathId="1" /><ObjectPath Id="5" ObjectPathId="4" /><ObjectIdentityQuery Id="6" ObjectPathId="4" /><ObjectPath Id="8" ObjectPathId="7" /><ObjectPath Id="10" ObjectPathId="9" /><ObjectIdentityQuery Id="11" ObjectPathId="9" /><ObjectPath Id="13" ObjectPathId="12" /><ObjectPath Id="15" ObjectPathId="14" /><ObjectIdentityQuery Id="16" ObjectPathId="14" /><ObjectPath Id="18" ObjectPathId="17" /><SetProperty Id="19" ObjectPathId="17" Name="TrimUnavailable"><Parameter Type="Boolean">true</Parameter></SetProperty><SetProperty Id="20" ObjectPathId="17" Name="TermLabel"><Parameter Type="String">${formatting_1.formatting.escapeXml(args.options.name)}</Parameter></SetProperty><ObjectPath Id="22" ObjectPathId="21" /><Query Id="23" ObjectPathId="21"><Query SelectAllProperties="true"><Properties /></Query><ChildItemQuery SelectAllProperties="true"><Properties /></ChildItemQuery></Query></Actions><ObjectPaths><StaticMethod Id="1" Name="GetTaxonomySession" TypeId="{981cbc68-9edc-4f8d-872f-71146fcbb84f}" /><Method Id="4" ParentId="1" Name="GetDefaultSiteCollectionTermStore" /><Property Id="7" ParentId="4" Name="Groups" /><Method Id="9" ParentId="7" Name="${args.options.termGroupName === undefined ? "GetById" : "GetByName"}"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(args.options.termGroupName) || args.options.termGroupId}</Parameter></Parameters></Method><Property Id="12" ParentId="9" Name="TermSets" /><Method Id="14" ParentId="12" Name="${args.options.termSetName === undefined ? "GetById" : "GetByName"}"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(args.options.termSetName) || args.options.termSetId}</Parameter></Parameters></Method><Constructor Id="17" TypeId="{61a1d689-2744-4ea3-a88b-c95bee9803aa}" /><Method Id="21" ParentId="14" Name="GetTerms"><Parameters><Parameter ObjectPathId="17" /></Parameters></Method></ObjectPaths></Request>`;
56
55
  }
57
- const requestOptions = {
58
- url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
59
- headers: {
60
- 'X-RequestDigest': res.FormDigestValue
61
- },
62
- data: data
63
- };
64
- const processQuery = yield request_1.default.post(requestOptions);
65
- const json = JSON.parse(processQuery);
66
- const response = json[0];
67
- if (response.ErrorInfo) {
68
- throw response.ErrorInfo.ErrorMessage;
56
+ let term;
57
+ const csomResponse = yield this.executeCsomCall(data, spoAdminUrl, res);
58
+ if (csomResponse === null) {
59
+ throw `Term with id '${args.options.id}' could not be found.`;
69
60
  }
70
- const term = json[json.length - 1];
71
- if (!term) {
72
- return;
61
+ else if (csomResponse._Child_Items_ !== undefined) {
62
+ const terms = csomResponse;
63
+ if (terms._Child_Items_.length === 0) {
64
+ throw `Term with name '${args.options.name}' could not be found.`;
65
+ }
66
+ if (terms._Child_Items_.length > 1) {
67
+ const disambiguationText = terms._Child_Items_.map(c => {
68
+ return `- ${this.getTermId(c.Id)} - ${c.PathOfTerm}`;
69
+ }).join(os.EOL);
70
+ throw new Error(`Multiple terms with the specific term name found. Please disambiguate:${os.EOL}${disambiguationText}`);
71
+ }
72
+ term = terms._Child_Items_[0];
73
+ }
74
+ else {
75
+ term = csomResponse;
73
76
  }
74
77
  delete term._ObjectIdentity_;
75
78
  delete term._ObjectType_;
76
- term.CreatedDate = new Date(Number(term.CreatedDate.replace('/Date(', '').replace(')/', ''))).toISOString();
77
- term.Id = term.Id.replace('/Guid(', '').replace(')/', '');
78
- term.LastModifiedDate = new Date(Number(term.LastModifiedDate.replace('/Date(', '').replace(')/', ''))).toISOString();
79
+ term.CreatedDate = this.parseTermDateToIsoString(term.CreatedDate);
80
+ term.Id = this.getTermId(term.Id);
81
+ term.LastModifiedDate = this.parseTermDateToIsoString(term.LastModifiedDate);
79
82
  logger.log(term);
80
83
  }
81
84
  catch (err) {
@@ -83,6 +86,31 @@ class SpoTermGetCommand extends SpoCommand_1.default {
83
86
  }
84
87
  });
85
88
  }
89
+ executeCsomCall(data, spoAdminUrl, res) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const requestOptions = {
92
+ url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
93
+ headers: {
94
+ 'X-RequestDigest': res.FormDigestValue
95
+ },
96
+ data: data
97
+ };
98
+ const processQuery = yield request_1.default.post(requestOptions);
99
+ const json = JSON.parse(processQuery);
100
+ const response = json[0];
101
+ if (response.ErrorInfo) {
102
+ throw response.ErrorInfo.ErrorMessage;
103
+ }
104
+ const responseObject = json[json.length - 1];
105
+ return responseObject;
106
+ });
107
+ }
108
+ getTermId(termId) {
109
+ return termId.replace('/Guid(', '').replace(')/', '');
110
+ }
111
+ parseTermDateToIsoString(dateAsString) {
112
+ return new Date(Number(dateAsString.replace('/Date(', '').replace(')/', ''))).toISOString();
113
+ }
86
114
  }
87
115
  _SpoTermGetCommand_instances = new WeakSet(), _SpoTermGetCommand_initTelemetry = function _SpoTermGetCommand_initTelemetry() {
88
116
  this.telemetry.push((args) => {
@@ -111,39 +139,31 @@ _SpoTermGetCommand_instances = new WeakSet(), _SpoTermGetCommand_initTelemetry =
111
139
  });
112
140
  }, _SpoTermGetCommand_initValidators = function _SpoTermGetCommand_initValidators() {
113
141
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
114
- if (args.options.id) {
115
- if (!validation_1.validation.isValidGuid(args.options.id)) {
116
- return `${args.options.id} is not a valid GUID`;
117
- }
142
+ if (args.options.id && !validation_1.validation.isValidGuid(args.options.id)) {
143
+ return `${args.options.id} is not a valid GUID`;
118
144
  }
119
- if (args.options.name) {
120
- if (!args.options.termGroupId && !args.options.termGroupName) {
121
- return 'Specify termGroupId or termGroupName';
122
- }
123
- if (!args.options.termSetId && !args.options.termSetName) {
124
- return 'Specify termSetId or termSetName';
125
- }
145
+ if (args.options.termGroupId && !validation_1.validation.isValidGuid(args.options.termGroupId)) {
146
+ return `${args.options.termGroupId} is not a valid GUID`;
126
147
  }
127
- if (args.options.termGroupId && args.options.termGroupName) {
128
- return 'Specify termGroupId or termGroupName but not both';
129
- }
130
- if (args.options.termGroupId) {
131
- if (!validation_1.validation.isValidGuid(args.options.termGroupId)) {
132
- return `${args.options.termGroupId} is not a valid GUID`;
133
- }
134
- }
135
- if (args.options.termSetId && args.options.termSetName) {
136
- return 'Specify termSetId or termSetName but not both';
137
- }
138
- if (args.options.termSetId) {
139
- if (!validation_1.validation.isValidGuid(args.options.termSetId)) {
140
- return `${args.options.termSetId} is not a valid GUID`;
141
- }
148
+ if (args.options.termSetId && !validation_1.validation.isValidGuid(args.options.termSetId)) {
149
+ return `${args.options.termSetId} is not a valid GUID`;
142
150
  }
143
151
  return true;
144
152
  }));
145
153
  }, _SpoTermGetCommand_initOptionSets = function _SpoTermGetCommand_initOptionSets() {
146
- this.optionSets.push({ options: ['id', 'name'] });
154
+ this.optionSets.push({
155
+ options: ['id', 'name']
156
+ }, {
157
+ options: ['termGroupId', 'termGroupName'],
158
+ runsWhen: (args) => {
159
+ return args.options.name !== undefined;
160
+ }
161
+ }, {
162
+ options: ['termSetId', 'termSetName'],
163
+ runsWhen: (args) => {
164
+ return args.options.name !== undefined;
165
+ }
166
+ });
147
167
  };
148
168
  module.exports = new SpoTermGetCommand();
149
169
  //# sourceMappingURL=term-get.js.map
@@ -44,7 +44,6 @@ class TeamsTeamAddCommand extends GraphCommand_1.default {
44
44
  }
45
45
  commandAction(logger, args) {
46
46
  return __awaiter(this, void 0, void 0, function* () {
47
- this.dots = '';
48
47
  let requestBody;
49
48
  if (args.options.template) {
50
49
  if (this.verbose) {
@@ -95,7 +94,7 @@ class TeamsTeamAddCommand extends GraphCommand_1.default {
95
94
  }
96
95
  else {
97
96
  setTimeout(() => {
98
- this.waitUntilFinished(requestOptions, resolve, reject, logger, this.dots);
97
+ this.waitUntilFinished(requestOptions, resolve, reject, logger);
99
98
  }, this.pollingInterval);
100
99
  }
101
100
  }));
@@ -113,11 +112,7 @@ class TeamsTeamAddCommand extends GraphCommand_1.default {
113
112
  }
114
113
  });
115
114
  }
116
- waitUntilFinished(requestOptions, resolve, reject, logger, dots) {
117
- if (!this.debug && this.verbose) {
118
- dots += '.';
119
- process.stdout.write(`\r${dots}`);
120
- }
115
+ waitUntilFinished(requestOptions, resolve, reject, logger) {
121
116
  request_1.default
122
117
  .get(requestOptions)
123
118
  .then((teamsAsyncOperation) => {
@@ -133,7 +128,7 @@ class TeamsTeamAddCommand extends GraphCommand_1.default {
133
128
  return;
134
129
  }
135
130
  setTimeout(() => {
136
- this.waitUntilFinished(requestOptions, resolve, reject, logger, dots);
131
+ this.waitUntilFinished(requestOptions, resolve, reject, logger);
137
132
  }, this.pollingInterval);
138
133
  }).catch(err => reject(err));
139
134
  }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.session = void 0;
4
+ const crypto = require("crypto");
5
+ const cache_1 = require("./cache");
6
+ exports.session = {
7
+ getId(pid) {
8
+ const key = `${pid.toString()}_session`;
9
+ let sessionId = cache_1.cache.getValue(key);
10
+ if (sessionId) {
11
+ return sessionId;
12
+ }
13
+ sessionId = crypto.randomBytes(24).toString('base64');
14
+ cache_1.cache.setValue(key, sessionId);
15
+ return sessionId;
16
+ }
17
+ };
18
+ //# sourceMappingURL=session.js.map
package/dist/utils/spo.js CHANGED
@@ -56,7 +56,7 @@ exports.spo = {
56
56
  });
57
57
  });
58
58
  },
59
- waitUntilFinished({ operationId, siteUrl, resolve, reject, logger, currentContext, dots, debug, verbose }) {
59
+ waitUntilFinished({ operationId, siteUrl, resolve, reject, logger, currentContext, debug, verbose }) {
60
60
  exports.spo
61
61
  .ensureFormDigest(siteUrl, logger, currentContext, debug)
62
62
  .then((res) => {
@@ -64,10 +64,6 @@ exports.spo = {
64
64
  if (debug) {
65
65
  logger.logToStderr(`Checking if operation ${operationId} completed...`);
66
66
  }
67
- if (!debug && verbose) {
68
- dots += '.';
69
- process.stdout.write(`\r${dots}`);
70
- }
71
67
  const requestOptions = {
72
68
  url: `${siteUrl}/_vti_bin/client.svc/ProcessQuery`,
73
69
  headers: {
@@ -101,7 +97,6 @@ exports.spo = {
101
97
  reject,
102
98
  logger,
103
99
  currentContext,
104
- dots,
105
100
  debug,
106
101
  verbose
107
102
  });
@@ -109,7 +104,7 @@ exports.spo = {
109
104
  }
110
105
  });
111
106
  },
112
- waitUntilCopyJobFinished({ copyJobInfo, siteUrl, pollingInterval, resolve, reject, logger, dots, debug, verbose }) {
107
+ waitUntilCopyJobFinished({ copyJobInfo, siteUrl, pollingInterval, resolve, reject, logger, debug, verbose }) {
113
108
  const requestUrl = `${siteUrl}/_api/site/GetCopyJobProgress`;
114
109
  const requestOptions = {
115
110
  url: requestUrl,
@@ -119,10 +114,6 @@ exports.spo = {
119
114
  data: { "copyJobInfo": copyJobInfo },
120
115
  responseType: 'json'
121
116
  };
122
- if (!debug && verbose) {
123
- dots += '.';
124
- process.stdout.write(`\r${dots}`);
125
- }
126
117
  request_1.default
127
118
  .post(requestOptions)
128
119
  .then((resp) => {
@@ -149,7 +140,7 @@ exports.spo = {
149
140
  }
150
141
  else {
151
142
  setTimeout(() => {
152
- exports.spo.waitUntilCopyJobFinished({ copyJobInfo, siteUrl, pollingInterval, resolve, reject, logger, dots, debug, verbose });
143
+ exports.spo.waitUntilCopyJobFinished({ copyJobInfo, siteUrl, pollingInterval, resolve, reject, logger, debug, verbose });
153
144
  }, pollingInterval);
154
145
  }
155
146
  });
@@ -20,10 +20,10 @@ m365 aad approleassignment add [options]
20
20
  : Application name of the App Registration to which the configured scopes (app roles) should be applied
21
21
 
22
22
  `-r, --resource <resource>`
23
- : Service principal name, appId or objectId that has the scopes (roles) ex. `SharePoint`.
23
+ : Service principal name, appId or objectId that has the scopes (roles) e.g. `SharePoint`.
24
24
 
25
25
  `-s, --scope <scope>`
26
- : Permissions known also as scopes and roles to grant the application with. If multiple permissions have to be granted, they have to be comma separated ex. `Sites.Read.All,Sites.ReadWrite.all`
26
+ : Permissions known also as scopes and roles to grant the application with. If multiple permissions have to be granted, they have to be comma-separated e.g. `Sites.Read.All,Sites.ReadWrite.all`
27
27
 
28
28
  --8<-- "docs/cmd/_global.md"
29
29
 
@@ -33,7 +33,7 @@ This command requires tenant administrator permissions.
33
33
 
34
34
  Specify either the `appId`, `appObjectId` or `appDisplayName` but not multiple. If you specify more than one option value, the command will fail with an error.
35
35
 
36
- Autocomplete values for the `resource` option do not mean allowed values. The autocomplete will just suggest some known names, but that doesn't restrict you to use name of your own custom application or other application within your tenant.
36
+ Autocomplete values for the `resource` option do not mean allowed values. The autocomplete will just suggest some known names, but that doesn't restrict you to use the name of your own custom application or other application within your tenant.
37
37
 
38
38
  This command can also be used to assign permissions to system or user-assigned managed identity.
39
39
 
@@ -45,13 +45,13 @@ Adds SharePoint _Sites.Read.All_ application permissions to Azure AD application
45
45
  m365 aad approleassignment add --appId "57907bf8-73fa-43a6-89a5-1f603e29e451" --resource "SharePoint" --scope "Sites.Read.All"
46
46
  ```
47
47
 
48
- Adds multiple Microsoft Graph application permissions to an Azure AD application with name _MyAppName_
48
+ Adds multiple Microsoft Graph application permissions to an Azure AD application with the name _MyAppName__
49
49
 
50
50
  ```sh
51
51
  m365 aad approleassignment add --appDisplayName "MyAppName" --resource "Microsoft Graph" --scope "Mail.Read,Mail.Send"
52
52
  ```
53
53
 
54
- Adds Microsoft Graph _Mail.Read_ application permissions to a system managed identity app with objectId _57907bf8-73fa-43a6-89a5-1f603e29e451_
54
+ Adds Microsoft Graph _Mail.Read_ application permissions to a system-managed identity app with objectId _57907bf8-73fa-43a6-89a5-1f603e29e451_
55
55
 
56
56
  ```sh
57
57
  m365 aad approleassignment add --appObjectId "57907bf8-73fa-43a6-89a5-1f603e29e451" --resource "Microsoft Graph" --scope "Mail.Read"