@pnp/cli-microsoft365 6.0.0-beta.4e32416 → 6.0.0-beta.550f33a

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.
@@ -61,9 +61,6 @@ class AadAppAddCommand extends GraphCommand_1.default {
61
61
  objectId: _appInfo.id,
62
62
  tenantId: _appInfo.tenantId
63
63
  };
64
- if (_appInfo.secret) {
65
- appInfo.secret = _appInfo.secret;
66
- }
67
64
  if (_appInfo.secrets) {
68
65
  appInfo.secrets = _appInfo.secrets;
69
66
  }
@@ -558,7 +555,10 @@ class AadAppAddCommand extends GraphCommand_1.default {
558
555
  return this
559
556
  .createSecret({ appObjectId: appInfo.id })
560
557
  .then(secret => {
561
- appInfo.secret = secret.value;
558
+ if (!appInfo.secrets) {
559
+ appInfo.secrets = [];
560
+ }
561
+ appInfo.secrets.push(secret);
562
562
  return Promise.resolve(appInfo);
563
563
  });
564
564
  }
@@ -13,18 +13,29 @@ class StatusCommand extends Command_1.default {
13
13
  }
14
14
  commandAction(logger, args, cb) {
15
15
  if (Auth_1.default.service.connected) {
16
- if (this.debug) {
17
- logger.logToStderr({
18
- connectedAs: utils_1.accessToken.getUserNameFromAccessToken(Auth_1.default.service.accessTokens[Auth_1.default.defaultResource].accessToken),
19
- authType: Auth_1.AuthType[Auth_1.default.service.authType],
20
- accessTokens: JSON.stringify(Auth_1.default.service.accessTokens, null, 2)
21
- });
22
- }
23
- else {
24
- logger.log({
25
- connectedAs: utils_1.accessToken.getUserNameFromAccessToken(Auth_1.default.service.accessTokens[Auth_1.default.defaultResource].accessToken)
26
- });
27
- }
16
+ Auth_1.default
17
+ .ensureAccessToken(Auth_1.default.defaultResource, logger, this.debug)
18
+ .then(() => {
19
+ if (this.debug) {
20
+ logger.logToStderr({
21
+ connectedAs: utils_1.accessToken.getUserNameFromAccessToken(Auth_1.default.service.accessTokens[Auth_1.default.defaultResource].accessToken),
22
+ authType: Auth_1.AuthType[Auth_1.default.service.authType],
23
+ accessTokens: JSON.stringify(Auth_1.default.service.accessTokens, null, 2)
24
+ });
25
+ }
26
+ else {
27
+ logger.log({
28
+ connectedAs: utils_1.accessToken.getUserNameFromAccessToken(Auth_1.default.service.accessTokens[Auth_1.default.defaultResource].accessToken)
29
+ });
30
+ }
31
+ cb();
32
+ }, (rej) => {
33
+ if (this.debug) {
34
+ logger.logToStderr(rej);
35
+ }
36
+ Auth_1.default.service.logout();
37
+ cb(new Command_1.CommandError(`Your login has expired. Sign in again to continue. ${rej.message}`));
38
+ });
28
39
  }
29
40
  else {
30
41
  if (this.verbose) {
@@ -33,8 +44,8 @@ class StatusCommand extends Command_1.default {
33
44
  else {
34
45
  logger.log('Logged out');
35
46
  }
47
+ cb();
36
48
  }
37
- cb();
38
49
  }
39
50
  action(logger, args, cb) {
40
51
  Auth_1.default
@@ -15,6 +15,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _OutlookMailSendCommand_instances, _OutlookMailSendCommand_initTelemetry, _OutlookMailSendCommand_initOptions, _OutlookMailSendCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Auth_1 = require("../../../../Auth");
19
+ const Command_1 = require("../../../../Command");
18
20
  const request_1 = require("../../../../request");
19
21
  const GraphCommand_1 = require("../../../base/GraphCommand");
20
22
  const commands_1 = require("../../commands");
@@ -30,12 +32,16 @@ class OutlookMailSendCommand extends GraphCommand_1.default {
30
32
  return commands_1.default.MAIL_SEND;
31
33
  }
32
34
  get description() {
33
- return 'Sends e-mail on behalf of the current user';
35
+ return 'Sends an e-mail';
34
36
  }
35
37
  commandAction(logger, args, cb) {
36
38
  const bodyContents = args.options.bodyContents;
39
+ const isAppOnlyAuth = Auth_1.Auth.isAppOnlyAuth(Auth_1.default.service.accessTokens[this.resource].accessToken);
40
+ if (isAppOnlyAuth === true && !args.options.sender) {
41
+ return cb(new Command_1.CommandError(`Specify a upn or user id in the 'sender' option when using app only authentication.`));
42
+ }
37
43
  const requestOptions = {
38
- url: `${this.resource}/v1.0/me/sendMail`,
44
+ url: `${this.resource}/v1.0/${args.options.sender ? 'users/' + encodeURIComponent(args.options.sender) : 'me'}/sendMail`,
39
45
  headers: {
40
46
  accept: 'application/json;odata.metadata=none',
41
47
  'content-type': 'application/json'
@@ -59,6 +65,13 @@ class OutlookMailSendCommand extends GraphCommand_1.default {
59
65
  saveToSentItems: args.options.saveToSentItems
60
66
  }
61
67
  };
68
+ if (args.options.mailbox) {
69
+ requestOptions.data.message.from = {
70
+ emailAddress: {
71
+ address: args.options.mailbox
72
+ }
73
+ };
74
+ }
62
75
  request_1.default
63
76
  .post(requestOptions)
64
77
  .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
@@ -69,7 +82,9 @@ _OutlookMailSendCommand_instances = new WeakSet(), _OutlookMailSendCommand_initT
69
82
  Object.assign(this.telemetryProperties, {
70
83
  bodyContents: typeof args.options.bodyContents !== 'undefined',
71
84
  bodyContentType: args.options.bodyContentType,
72
- saveToSentItems: args.options.saveToSentItems
85
+ saveToSentItems: args.options.saveToSentItems,
86
+ mailbox: typeof args.options.mailbox !== 'undefined',
87
+ sender: typeof args.options.sender !== 'undefined'
73
88
  });
74
89
  });
75
90
  }, _OutlookMailSendCommand_initOptions = function _OutlookMailSendCommand_initOptions() {
@@ -77,6 +92,10 @@ _OutlookMailSendCommand_instances = new WeakSet(), _OutlookMailSendCommand_initT
77
92
  option: '-s, --subject <subject>'
78
93
  }, {
79
94
  option: '-t, --to <to>'
95
+ }, {
96
+ option: '--sender [sender]'
97
+ }, {
98
+ option: '-m, --mailbox [mailbox]'
80
99
  }, {
81
100
  option: '--bodyContents <bodyContents>'
82
101
  }, {
@@ -40,9 +40,6 @@ class SpoFieldSetCommand extends SpoCommand_1.default {
40
40
  return true;
41
41
  }
42
42
  commandAction(logger, args, cb) {
43
- if (args.options.name) {
44
- this.warn(logger, `Option 'name' is deprecated. Please use 'title' instead.`);
45
- }
46
43
  let requestDigest = '';
47
44
  utils_1.spo
48
45
  .getRequestDigest(args.options.webUrl)
@@ -78,7 +75,7 @@ class SpoFieldSetCommand extends SpoCommand_1.default {
78
75
  // retrieve column CSOM object id
79
76
  const fieldQuery = args.options.id ?
80
77
  `<Method Id="663" ParentId="7" Name="GetById"><Parameters><Parameter Type="Guid">${utils_1.formatting.escapeXml(args.options.id)}</Parameter></Parameters></Method>` :
81
- `<Method Id="663" ParentId="7" Name="GetByInternalNameOrTitle"><Parameters><Parameter Type="String">${utils_1.formatting.escapeXml(args.options.name || args.options.title)}</Parameter></Parameters></Method>`;
78
+ `<Method Id="663" ParentId="7" Name="GetByInternalNameOrTitle"><Parameters><Parameter Type="String">${utils_1.formatting.escapeXml(args.options.title)}</Parameter></Parameters></Method>`;
82
79
  const requestOptions = {
83
80
  url: `${args.options.webUrl}/_vti_bin/client.svc/ProcessQuery`,
84
81
  headers: {
@@ -121,7 +118,6 @@ class SpoFieldSetCommand extends SpoCommand_1.default {
121
118
  'listId',
122
119
  'listTitle',
123
120
  'id',
124
- 'name',
125
121
  'title',
126
122
  'updateExistingLists',
127
123
  'debug',
@@ -140,7 +136,6 @@ _SpoFieldSetCommand_instances = new WeakSet(), _SpoFieldSetCommand_initTelemetry
140
136
  Object.assign(this.telemetryProperties, {
141
137
  id: typeof args.options.id !== 'undefined',
142
138
  title: typeof args.options.title !== 'undefined',
143
- name: typeof args.options.name !== 'undefined',
144
139
  listId: typeof args.options.listId !== 'undefined',
145
140
  listTitle: typeof args.options.listTitle !== 'undefined',
146
141
  updateExistingLists: !!args.options.updateExistingLists
@@ -155,8 +150,6 @@ _SpoFieldSetCommand_instances = new WeakSet(), _SpoFieldSetCommand_initTelemetry
155
150
  option: '--listTitle [listTitle]'
156
151
  }, {
157
152
  option: '-i, --id [id]'
158
- }, {
159
- option: '-n, --name [name]'
160
153
  }, {
161
154
  option: '-t, --title [title]'
162
155
  }, {
@@ -182,7 +175,7 @@ _SpoFieldSetCommand_instances = new WeakSet(), _SpoFieldSetCommand_initTelemetry
182
175
  return true;
183
176
  }));
184
177
  }, _SpoFieldSetCommand_initOptionSets = function _SpoFieldSetCommand_initOptionSets() {
185
- this.optionSets.push(['id', 'title', 'name']);
178
+ this.optionSets.push(['id', 'title']);
186
179
  };
187
180
  module.exports = new SpoFieldSetCommand();
188
181
  //# sourceMappingURL=field-set.js.map
@@ -15,6 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _SpoListRoleInheritanceBreakCommand_instances, _SpoListRoleInheritanceBreakCommand_initTelemetry, _SpoListRoleInheritanceBreakCommand_initOptions, _SpoListRoleInheritanceBreakCommand_initValidators, _SpoListRoleInheritanceBreakCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ const cli_1 = require("../../../../cli");
18
19
  const request_1 = require("../../../../request");
19
20
  const utils_1 = require("../../../../utils");
20
21
  const SpoCommand_1 = require("../../../base/SpoCommand");
@@ -35,32 +36,53 @@ class SpoListRoleInheritanceBreakCommand extends SpoCommand_1.default {
35
36
  return 'Breaks role inheritance on list or library';
36
37
  }
37
38
  commandAction(logger, args, cb) {
39
+ var _a;
38
40
  if (this.verbose) {
39
41
  logger.logToStderr(`Breaking role inheritance of list in site at ${args.options.webUrl}...`);
40
42
  }
41
- let requestUrl = `${args.options.webUrl}/_api/web/lists`;
42
- if (args.options.listId) {
43
- requestUrl += `(guid'${utils_1.formatting.encodeQueryParameter(args.options.listId)}')`;
43
+ const breakListRoleInheritance = () => {
44
+ let requestUrl = `${args.options.webUrl}/_api/web/lists`;
45
+ if (args.options.listId) {
46
+ requestUrl += `(guid'${utils_1.formatting.encodeQueryParameter(args.options.listId)}')`;
47
+ }
48
+ else {
49
+ requestUrl += `/getbytitle('${utils_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
50
+ }
51
+ let keepExistingPermissions = true;
52
+ if (args.options.clearExistingPermissions) {
53
+ keepExistingPermissions = !args.options.clearExistingPermissions;
54
+ }
55
+ const requestOptions = {
56
+ url: `${requestUrl}/breakroleinheritance(${keepExistingPermissions})`,
57
+ method: 'POST',
58
+ headers: {
59
+ 'accept': 'application/json;odata=nometadata',
60
+ 'content-type': 'application/json'
61
+ },
62
+ responseType: 'json'
63
+ };
64
+ request_1.default
65
+ .post(requestOptions)
66
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
67
+ };
68
+ if (args.options.confirm) {
69
+ breakListRoleInheritance();
44
70
  }
45
71
  else {
46
- requestUrl += `/getbytitle('${utils_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
47
- }
48
- let keepExistingPermissions = true;
49
- if (args.options.clearExistingPermissions) {
50
- keepExistingPermissions = !args.options.clearExistingPermissions;
72
+ cli_1.Cli.prompt({
73
+ type: 'confirm',
74
+ name: 'continue',
75
+ default: false,
76
+ message: `Are you sure you want to break the role inheritance of ${(_a = args.options.listId) !== null && _a !== void 0 ? _a : args.options.listTitle}?`
77
+ }, (result) => {
78
+ if (!result.continue) {
79
+ cb();
80
+ }
81
+ else {
82
+ breakListRoleInheritance();
83
+ }
84
+ });
51
85
  }
52
- const requestOptions = {
53
- url: `${requestUrl}/breakroleinheritance(${keepExistingPermissions})`,
54
- method: 'POST',
55
- headers: {
56
- 'accept': 'application/json;odata=nometadata',
57
- 'content-type': 'application/json'
58
- },
59
- responseType: 'json'
60
- };
61
- request_1.default
62
- .post(requestOptions)
63
- .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
64
86
  }
65
87
  }
66
88
  _SpoListRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoListRoleInheritanceBreakCommand_initTelemetry = function _SpoListRoleInheritanceBreakCommand_initTelemetry() {
@@ -68,7 +90,8 @@ _SpoListRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoListRoleInher
68
90
  Object.assign(this.telemetryProperties, {
69
91
  listId: typeof args.options.listId !== 'undefined',
70
92
  listTitle: typeof args.options.listTitle !== 'undefined',
71
- clearExistingPermissions: args.options.clearExistingPermissions === true
93
+ clearExistingPermissions: args.options.clearExistingPermissions === true,
94
+ confirm: (!(!args.options.confirm)).toString()
72
95
  });
73
96
  });
74
97
  }, _SpoListRoleInheritanceBreakCommand_initOptions = function _SpoListRoleInheritanceBreakCommand_initOptions() {
@@ -80,6 +103,8 @@ _SpoListRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoListRoleInher
80
103
  option: '-t, --listTitle [listTitle]'
81
104
  }, {
82
105
  option: '-c, --clearExistingPermissions'
106
+ }, {
107
+ option: '--confirm'
83
108
  });
84
109
  }, _SpoListRoleInheritanceBreakCommand_initValidators = function _SpoListRoleInheritanceBreakCommand_initValidators() {
85
110
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -15,6 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _SpoListRoleInheritanceResetCommand_instances, _SpoListRoleInheritanceResetCommand_initTelemetry, _SpoListRoleInheritanceResetCommand_initOptions, _SpoListRoleInheritanceResetCommand_initValidators, _SpoListRoleInheritanceResetCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ const cli_1 = require("../../../../cli");
18
19
  const request_1 = require("../../../../request");
19
20
  const utils_1 = require("../../../../utils");
20
21
  const SpoCommand_1 = require("../../../base/SpoCommand");
@@ -35,35 +36,57 @@ class SpoListRoleInheritanceResetCommand extends SpoCommand_1.default {
35
36
  return 'Restores role inheritance on list or library';
36
37
  }
37
38
  commandAction(logger, args, cb) {
39
+ var _a;
38
40
  if (this.verbose) {
39
41
  logger.logToStderr(`Restore role inheritance of list in site at ${args.options.webUrl}...`);
40
42
  }
41
- let requestUrl = `${args.options.webUrl}/_api/web/lists`;
42
- if (args.options.listId) {
43
- requestUrl += `(guid'${utils_1.formatting.encodeQueryParameter(args.options.listId)}')`;
43
+ const resetListRoleInheritance = () => {
44
+ let requestUrl = `${args.options.webUrl}/_api/web/lists`;
45
+ if (args.options.listId) {
46
+ requestUrl += `(guid'${utils_1.formatting.encodeQueryParameter(args.options.listId)}')`;
47
+ }
48
+ else {
49
+ requestUrl += `/getbytitle('${utils_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
50
+ }
51
+ const requestOptions = {
52
+ url: `${requestUrl}/resetroleinheritance`,
53
+ method: 'POST',
54
+ headers: {
55
+ 'accept': 'application/json;odata=nometadata',
56
+ 'content-type': 'application/json'
57
+ },
58
+ responseType: 'json'
59
+ };
60
+ request_1.default
61
+ .post(requestOptions)
62
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
63
+ };
64
+ if (args.options.confirm) {
65
+ resetListRoleInheritance();
44
66
  }
45
67
  else {
46
- requestUrl += `/getbytitle('${utils_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
68
+ cli_1.Cli.prompt({
69
+ type: 'confirm',
70
+ name: 'continue',
71
+ default: false,
72
+ message: `Are you sure you want to reset the role inheritance of ${(_a = args.options.listId) !== null && _a !== void 0 ? _a : args.options.listTitle}?`
73
+ }, (result) => {
74
+ if (!result.continue) {
75
+ cb();
76
+ }
77
+ else {
78
+ resetListRoleInheritance();
79
+ }
80
+ });
47
81
  }
48
- const requestOptions = {
49
- url: `${requestUrl}/resetroleinheritance`,
50
- method: 'POST',
51
- headers: {
52
- 'accept': 'application/json;odata=nometadata',
53
- 'content-type': 'application/json'
54
- },
55
- responseType: 'json'
56
- };
57
- request_1.default
58
- .post(requestOptions)
59
- .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
60
82
  }
61
83
  }
62
84
  _SpoListRoleInheritanceResetCommand_instances = new WeakSet(), _SpoListRoleInheritanceResetCommand_initTelemetry = function _SpoListRoleInheritanceResetCommand_initTelemetry() {
63
85
  this.telemetry.push((args) => {
64
86
  Object.assign(this.telemetryProperties, {
65
87
  listId: typeof args.options.listId !== 'undefined',
66
- listTitle: typeof args.options.listTitle !== 'undefined'
88
+ listTitle: typeof args.options.listTitle !== 'undefined',
89
+ confirm: (!(!args.options.confirm)).toString()
67
90
  });
68
91
  });
69
92
  }, _SpoListRoleInheritanceResetCommand_initOptions = function _SpoListRoleInheritanceResetCommand_initOptions() {
@@ -73,6 +96,8 @@ _SpoListRoleInheritanceResetCommand_instances = new WeakSet(), _SpoListRoleInher
73
96
  option: '-i, --listId [listId]'
74
97
  }, {
75
98
  option: '-t, --listTitle [listTitle]'
99
+ }, {
100
+ option: '--confirm'
76
101
  });
77
102
  }, _SpoListRoleInheritanceResetCommand_initValidators = function _SpoListRoleInheritanceResetCommand_initValidators() {
78
103
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -15,6 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _SpoListItemRoleInheritanceBreakCommand_instances, _SpoListItemRoleInheritanceBreakCommand_initTelemetry, _SpoListItemRoleInheritanceBreakCommand_initOptions, _SpoListItemRoleInheritanceBreakCommand_initValidators, _SpoListItemRoleInheritanceBreakCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ const cli_1 = require("../../../../cli");
18
19
  const request_1 = require("../../../../request");
19
20
  const utils_1 = require("../../../../utils");
20
21
  const SpoCommand_1 = require("../../../base/SpoCommand");
@@ -35,32 +36,53 @@ class SpoListItemRoleInheritanceBreakCommand extends SpoCommand_1.default {
35
36
  return 'Break inheritance of list item';
36
37
  }
37
38
  commandAction(logger, args, cb) {
39
+ var _a;
38
40
  if (this.verbose) {
39
41
  logger.logToStderr(`Breaking role inheritance of list item in site at ${args.options.webUrl}...`);
40
42
  }
41
- let requestUrl = `${args.options.webUrl}/_api/web/lists`;
42
- if (args.options.listId) {
43
- requestUrl += `(guid'${utils_1.formatting.encodeQueryParameter(args.options.listId)}')`;
43
+ const breakListItemRoleInheritance = () => {
44
+ let requestUrl = `${args.options.webUrl}/_api/web/lists`;
45
+ if (args.options.listId) {
46
+ requestUrl += `(guid'${utils_1.formatting.encodeQueryParameter(args.options.listId)}')`;
47
+ }
48
+ else {
49
+ requestUrl += `/getbytitle('${utils_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
50
+ }
51
+ let keepExistingPermissions = true;
52
+ if (args.options.clearExistingPermissions) {
53
+ keepExistingPermissions = !args.options.clearExistingPermissions;
54
+ }
55
+ const requestOptions = {
56
+ url: `${requestUrl}/items(${args.options.listItemId})/breakroleinheritance(${keepExistingPermissions})`,
57
+ method: 'POST',
58
+ headers: {
59
+ 'accept': 'application/json;odata=nometadata',
60
+ 'content-type': 'application/json'
61
+ },
62
+ responseType: 'json'
63
+ };
64
+ request_1.default
65
+ .post(requestOptions)
66
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
67
+ };
68
+ if (args.options.confirm) {
69
+ breakListItemRoleInheritance();
44
70
  }
45
71
  else {
46
- requestUrl += `/getbytitle('${utils_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
47
- }
48
- let keepExistingPermissions = true;
49
- if (args.options.clearExistingPermissions) {
50
- keepExistingPermissions = !args.options.clearExistingPermissions;
72
+ cli_1.Cli.prompt({
73
+ type: 'confirm',
74
+ name: 'continue',
75
+ default: false,
76
+ message: `Are you sure you want to break the role inheritance of ${args.options.listItemId} in list ${(_a = args.options.listId) !== null && _a !== void 0 ? _a : args.options.listTitle}?`
77
+ }, (result) => {
78
+ if (!result.continue) {
79
+ cb();
80
+ }
81
+ else {
82
+ breakListItemRoleInheritance();
83
+ }
84
+ });
51
85
  }
52
- const requestOptions = {
53
- url: `${requestUrl}/items(${args.options.listItemId})/breakroleinheritance(${keepExistingPermissions})`,
54
- method: 'POST',
55
- headers: {
56
- 'accept': 'application/json;odata=nometadata',
57
- 'content-type': 'application/json'
58
- },
59
- responseType: 'json'
60
- };
61
- request_1.default
62
- .post(requestOptions)
63
- .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
64
86
  }
65
87
  }
66
88
  _SpoListItemRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoListItemRoleInheritanceBreakCommand_initTelemetry = function _SpoListItemRoleInheritanceBreakCommand_initTelemetry() {
@@ -68,7 +90,8 @@ _SpoListItemRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoListItemR
68
90
  Object.assign(this.telemetryProperties, {
69
91
  listId: typeof args.options.listId !== 'undefined',
70
92
  listTitle: typeof args.options.listTitle !== 'undefined',
71
- clearExistingPermissions: args.options.clearExistingPermissions === true
93
+ clearExistingPermissions: args.options.clearExistingPermissions === true,
94
+ confirm: (!(!args.options.confirm)).toString()
72
95
  });
73
96
  });
74
97
  }, _SpoListItemRoleInheritanceBreakCommand_initOptions = function _SpoListItemRoleInheritanceBreakCommand_initOptions() {
@@ -82,6 +105,8 @@ _SpoListItemRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoListItemR
82
105
  option: '-t, --listTitle [listTitle]'
83
106
  }, {
84
107
  option: '-c, --clearExistingPermissions'
108
+ }, {
109
+ option: '--confirm'
85
110
  });
86
111
  }, _SpoListItemRoleInheritanceBreakCommand_initValidators = function _SpoListItemRoleInheritanceBreakCommand_initValidators() {
87
112
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -15,6 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _SpoListItemRoleInheritanceResetCommand_instances, _SpoListItemRoleInheritanceResetCommand_initTelemetry, _SpoListItemRoleInheritanceResetCommand_initOptions, _SpoListItemRoleInheritanceResetCommand_initValidators, _SpoListItemRoleInheritanceResetCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ const cli_1 = require("../../../../cli");
18
19
  const request_1 = require("../../../../request");
19
20
  const utils_1 = require("../../../../utils");
20
21
  const SpoCommand_1 = require("../../../base/SpoCommand");
@@ -35,32 +36,57 @@ class SpoListItemRoleInheritanceResetCommand extends SpoCommand_1.default {
35
36
  return 'Restores the role inheritance of list item, file, or folder';
36
37
  }
37
38
  commandAction(logger, args, cb) {
38
- let requestUrl = `${args.options.webUrl}/_api/web/lists`;
39
- if (args.options.listId) {
40
- requestUrl += `(guid'${utils_1.formatting.encodeQueryParameter(args.options.listId)}')`;
39
+ var _a;
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Restore role inheritance of list item in site at ${args.options.webUrl}...`);
42
+ }
43
+ const resetListItemRoleInheritance = () => {
44
+ let requestUrl = `${args.options.webUrl}/_api/web/lists`;
45
+ if (args.options.listId) {
46
+ requestUrl += `(guid'${utils_1.formatting.encodeQueryParameter(args.options.listId)}')`;
47
+ }
48
+ else {
49
+ requestUrl += `/getbytitle('${utils_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
50
+ }
51
+ const requestOptions = {
52
+ url: `${requestUrl}/items(${args.options.listItemId})/resetroleinheritance`,
53
+ method: 'POST',
54
+ headers: {
55
+ 'accept': 'application/json;odata=nometadata',
56
+ 'content-type': 'application/json'
57
+ },
58
+ responseType: 'json'
59
+ };
60
+ request_1.default
61
+ .post(requestOptions)
62
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
63
+ };
64
+ if (args.options.confirm) {
65
+ resetListItemRoleInheritance();
41
66
  }
42
67
  else {
43
- requestUrl += `/getbytitle('${utils_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
68
+ cli_1.Cli.prompt({
69
+ type: 'confirm',
70
+ name: 'continue',
71
+ default: false,
72
+ message: `Are you sure you want to reset the role inheritance of ${args.options.listItemId} in list ${(_a = args.options.listId) !== null && _a !== void 0 ? _a : args.options.listTitle}?`
73
+ }, (result) => {
74
+ if (!result.continue) {
75
+ cb();
76
+ }
77
+ else {
78
+ resetListItemRoleInheritance();
79
+ }
80
+ });
44
81
  }
45
- const requestOptions = {
46
- url: `${requestUrl}/items(${args.options.listItemId})/resetroleinheritance`,
47
- method: 'POST',
48
- headers: {
49
- 'accept': 'application/json;odata=nometadata',
50
- 'content-type': 'application/json'
51
- },
52
- responseType: 'json'
53
- };
54
- request_1.default
55
- .post(requestOptions)
56
- .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
57
82
  }
58
83
  }
59
84
  _SpoListItemRoleInheritanceResetCommand_instances = new WeakSet(), _SpoListItemRoleInheritanceResetCommand_initTelemetry = function _SpoListItemRoleInheritanceResetCommand_initTelemetry() {
60
85
  this.telemetry.push((args) => {
61
86
  Object.assign(this.telemetryProperties, {
62
87
  listId: typeof args.options.listId !== 'undefined',
63
- listTitle: typeof args.options.listTitle !== 'undefined'
88
+ listTitle: typeof args.options.listTitle !== 'undefined',
89
+ confirm: (!(!args.options.confirm)).toString()
64
90
  });
65
91
  });
66
92
  }, _SpoListItemRoleInheritanceResetCommand_initOptions = function _SpoListItemRoleInheritanceResetCommand_initOptions() {
@@ -72,6 +98,8 @@ _SpoListItemRoleInheritanceResetCommand_instances = new WeakSet(), _SpoListItemR
72
98
  option: '--listId [listId]'
73
99
  }, {
74
100
  option: '--listTitle [listTitle]'
101
+ }, {
102
+ option: '--confirm'
75
103
  });
76
104
  }, _SpoListItemRoleInheritanceResetCommand_initValidators = function _SpoListItemRoleInheritanceResetCommand_initValidators() {
77
105
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -13,8 +13,9 @@ 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 _SpoWebRoleInheritanceResetCommand_instances, _SpoWebRoleInheritanceResetCommand_initOptions, _SpoWebRoleInheritanceResetCommand_initValidators;
16
+ var _SpoWebRoleInheritanceResetCommand_instances, _SpoWebRoleInheritanceResetCommand_initTelemetry, _SpoWebRoleInheritanceResetCommand_initOptions, _SpoWebRoleInheritanceResetCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ const cli_1 = require("../../../../cli");
18
19
  const request_1 = require("../../../../request");
19
20
  const utils_1 = require("../../../../utils");
20
21
  const SpoCommand_1 = require("../../../base/SpoCommand");
@@ -23,6 +24,7 @@ class SpoWebRoleInheritanceResetCommand extends SpoCommand_1.default {
23
24
  constructor() {
24
25
  super();
25
26
  _SpoWebRoleInheritanceResetCommand_instances.add(this);
27
+ __classPrivateFieldGet(this, _SpoWebRoleInheritanceResetCommand_instances, "m", _SpoWebRoleInheritanceResetCommand_initTelemetry).call(this);
26
28
  __classPrivateFieldGet(this, _SpoWebRoleInheritanceResetCommand_instances, "m", _SpoWebRoleInheritanceResetCommand_initOptions).call(this);
27
29
  __classPrivateFieldGet(this, _SpoWebRoleInheritanceResetCommand_instances, "m", _SpoWebRoleInheritanceResetCommand_initValidators).call(this);
28
30
  }
@@ -36,23 +38,51 @@ class SpoWebRoleInheritanceResetCommand extends SpoCommand_1.default {
36
38
  if (this.verbose) {
37
39
  logger.logToStderr(`Restore role inheritance of subsite at ${args.options.webUrl}...`);
38
40
  }
39
- const requestOptions = {
40
- url: `${args.options.webUrl}/_api/web/resetroleinheritance`,
41
- method: 'POST',
42
- headers: {
43
- 'accept': 'application/json;odata=nometadata',
44
- 'content-type': 'application/json'
45
- },
46
- responseType: 'json'
41
+ const resetWebRoleInheritance = () => {
42
+ const requestOptions = {
43
+ url: `${args.options.webUrl}/_api/web/resetroleinheritance`,
44
+ method: 'POST',
45
+ headers: {
46
+ 'accept': 'application/json;odata=nometadata',
47
+ 'content-type': 'application/json'
48
+ },
49
+ responseType: 'json'
50
+ };
51
+ request_1.default
52
+ .post(requestOptions)
53
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
47
54
  };
48
- request_1.default
49
- .post(requestOptions)
50
- .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
55
+ if (args.options.confirm) {
56
+ resetWebRoleInheritance();
57
+ }
58
+ else {
59
+ cli_1.Cli.prompt({
60
+ type: 'confirm',
61
+ name: 'continue',
62
+ default: false,
63
+ message: `Are you sure you want to reset the role inheritance of ${args.options.webUrl}`
64
+ }, (result) => {
65
+ if (!result.continue) {
66
+ cb();
67
+ }
68
+ else {
69
+ resetWebRoleInheritance();
70
+ }
71
+ });
72
+ }
51
73
  }
52
74
  }
53
- _SpoWebRoleInheritanceResetCommand_instances = new WeakSet(), _SpoWebRoleInheritanceResetCommand_initOptions = function _SpoWebRoleInheritanceResetCommand_initOptions() {
75
+ _SpoWebRoleInheritanceResetCommand_instances = new WeakSet(), _SpoWebRoleInheritanceResetCommand_initTelemetry = function _SpoWebRoleInheritanceResetCommand_initTelemetry() {
76
+ this.telemetry.push((args) => {
77
+ Object.assign(this.telemetryProperties, {
78
+ confirm: (!(!args.options.confirm)).toString()
79
+ });
80
+ });
81
+ }, _SpoWebRoleInheritanceResetCommand_initOptions = function _SpoWebRoleInheritanceResetCommand_initOptions() {
54
82
  this.options.unshift({
55
83
  option: '-u, --webUrl <webUrl>'
84
+ }, {
85
+ option: '--confirm'
56
86
  });
57
87
  }, _SpoWebRoleInheritanceResetCommand_initValidators = function _SpoWebRoleInheritanceResetCommand_initValidators() {
58
88
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -42,12 +42,10 @@ const addFileCommands = {
42
42
  addFileCommand: 'cat > [FILEPATH] << EOF [FILECONTENT]EOF'
43
43
  },
44
44
  powershell: {
45
- addFileCommand: `@"[FILECONTENT]"@ | Out-File -FilePath "[FILEPATH]"
46
- `
45
+ addFileCommand: `@"[FILECONTENT]"@ | Out-File -FilePath [FILEPATH]`
47
46
  },
48
47
  cmd: {
49
- addFileCommand: `echo [FILECONTENT] > "[FILEPATH]"
50
- `
48
+ addFileCommand: `echo [FILECONTENT] > [FILEPATH]`
51
49
  }
52
50
  };
53
51
  const removeFileCommands = {
package/dist/utils/md.js CHANGED
@@ -46,7 +46,7 @@ function convertHyperlinks(md) {
46
46
  });
47
47
  }
48
48
  function convertCodeFences(md) {
49
- const regex = new RegExp('^```.*?' + os_1.EOL + '(.*?)```' + os_1.EOL, 'gms');
49
+ const regex = new RegExp('^```.*?(?:\r\n|\n)(.*?)```(?:\r\n|\n)', 'gms');
50
50
  return md.replace(regex, (match, code) => {
51
51
  return ` ${code}${os_1.EOL}`;
52
52
  });
@@ -1,6 +1,6 @@
1
1
  # outlook mail send
2
2
 
3
- Sends e-mail on behalf of the current user
3
+ Sends an e-mail
4
4
 
5
5
  ## Usage
6
6
 
@@ -16,6 +16,12 @@ m365 outlook mail send [options]
16
16
  `-t, --to <to>`
17
17
  : Comma-separated list of e-mails to send the message to
18
18
 
19
+ `--sender [sender]`
20
+ : Optional upn or user id to specify what account to send the message from. Also see the remarks section.
21
+
22
+ `-m, --mailbox [mailbox]`
23
+ : Specify this option to send the email on behalf of another mailbox, for example a shared mailbox, group or distribution list. The sender needs to be a delegate on the specified mailbox. Also see the remarks section.
24
+
19
25
  `--bodyContents <bodyContents>`
20
26
  : String containing the body of the e-mail to send
21
27
 
@@ -27,6 +33,25 @@ m365 outlook mail send [options]
27
33
 
28
34
  --8<-- "docs/cmd/_global.md"
29
35
 
36
+ ## Remarks
37
+
38
+ ### If you are connected using app only authentication
39
+
40
+ - Always specify a user id or upn in the `--sender` option. The email will be sent as if it came from the specified user, and can optionally be saved in the sent folder of that user account.
41
+ - You can optionally also specify the `--mailbox` option to send mail on behalf of a shared mailbox, group or distribution list. The account used in the `--sender` option, needs to have 'Send on behalf of' permissions on the mailbox in question.
42
+
43
+ !!! important
44
+ You need `Mail.Send` application permissions on the Microsoft Graph to be able to send mails using an application identity.
45
+
46
+ ### If you are connected with a regular user account
47
+
48
+ - Specify the `--mailbox` option if you want to send an email on behalf of another mailbox. This can be a shared mailbox, group or distribution list. It will be visible in the email that the email was sent by you. You need to be assigned `Send on behalf of` permissions on the mailbox in question.
49
+ - You can specify the `--sender` option if you want to send an email as if you were the other user.
50
+ The sent email can optionally be saved in the sent folder of that user account. You'll need `Read and manage (Full Access)` permissions on the mailbox of the other user. You can combine the `--sender` and `--mailbox` options to let the other user send a mail on behalf of the specified mailbox.
51
+
52
+ !!! important
53
+ You need at least `Mail.Send` delegated permissions on the Microsoft Graph to be able to send emails. When specifying another user as sender, you'll need `Mail.Send.Shared` permissions.
54
+
30
55
  ## Examples
31
56
 
32
57
  Send a text e-mail to the specified e-mail address
@@ -52,3 +77,21 @@ Send a text e-mail to the specified e-mail address. Don't store the e-mail in se
52
77
  ```sh
53
78
  m365 outlook mail send --to chris@contoso.com --subject "DG2000 Data Sheets" --bodyContents "The latest data sheets are in the team site" --saveToSentItems false
54
79
  ```
80
+
81
+ Send an email on behalf of a shared mailbox using the signed in user
82
+
83
+ ```sh
84
+ m365 outlook mail send --to chris@contoso.com --subject "DG2000 Data Sheets" --bodyContents "The latest data sheets are in the team site" --mailbox sales@contoso.com
85
+ ```
86
+
87
+ Send an email as another user
88
+
89
+ ```sh
90
+ m365 outlook mail send --to chris@contoso.com --subject "DG2000 Data Sheets" --bodyContents "The latest data sheets are in the team site" --sender svc_project@contoso.com
91
+ ```
92
+
93
+ Send an email as another user, on behalf of a shared mailbox
94
+
95
+ ```sh
96
+ m365 outlook mail send --to chris@contoso.com --subject "DG2000 Data Sheets" --bodyContents "The latest data sheets are in the team site" --sender svc_project@contoso.com --mailbox sales@contoso.com
97
+ ```
@@ -25,9 +25,6 @@ m365 spo field set [options]
25
25
  `-t, --title [title]`
26
26
  : Title or internal name of the field to update. Specify `id` or `title` but not both
27
27
 
28
- `-n, --name [name]`
29
- : (deprecated. Use `title` instead) Title or internal name of the field to update. Specify `id` or `name` but not both
30
-
31
28
  `--updateExistingLists`
32
29
  : Set, to push the update to existing lists. Otherwise, the changes will apply to new lists only
33
30
 
@@ -22,6 +22,9 @@ m365 spo list roleinheritance break [options]
22
22
  `-c, --clearExistingPermissions`
23
23
  : Flag if used clears all roles from the list
24
24
 
25
+ `--confirm`
26
+ : Do not prompt for confirmation before breaking role inheritance.
27
+
25
28
  --8<-- "docs/cmd/_global.md"
26
29
 
27
30
  ## Remarks
@@ -53,3 +56,9 @@ Break inheritance of list with ID _202b8199-b9de-43fd-9737-7f213f51c991_ located
53
56
  ```sh
54
57
  m365 spo list roleinheritance break --webUrl "https://contoso.sharepoint.com/sites/project-x" --listId "202b8199-b9de-43fd-9737-7f213f51c991" --clearExistingPermissions
55
58
  ```
59
+
60
+ Break inheritance of list with ID _202b8199-b9de-43fd-9737-7f213f51c991_ located in site _https://contoso.sharepoint.com/sites/project-x_ with clearing permissions without prompting for confirmation
61
+
62
+ ```sh
63
+ m365 spo list roleinheritance break --webUrl "https://contoso.sharepoint.com/sites/project-x" --listId "202b8199-b9de-43fd-9737-7f213f51c991" --clearExistingPermissions --confirm
64
+ ```
@@ -19,6 +19,9 @@ m365 spo list roleinheritance reset [options]
19
19
  `-t, --listTitle [listTitle]`
20
20
  : Title of the list. Specify either id or title but not both
21
21
 
22
+ `--confirm`
23
+ : Do not prompt for confirmation before resetting role inheritance.
24
+
22
25
  --8<-- "docs/cmd/_global.md"
23
26
 
24
27
  ## Examples
@@ -34,3 +37,9 @@ Restore role inheritance of list with title _test_ located in site _https://cont
34
37
  ```sh
35
38
  m365 spo list roleinheritance reset --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle test
36
39
  ```
40
+
41
+ Restore role inheritance of list with title _test_ located in site _https://contoso.sharepoint.com/sites/project-x_ without prompting for confirmation
42
+
43
+ ```sh
44
+ m365 spo list roleinheritance reset --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle test --confirm
45
+ ```
@@ -25,6 +25,9 @@ m365 spo listitem roleinheritance break [options]
25
25
  `-c, --clearExistingPermissions`
26
26
  : Set to clear existing roles from the list item
27
27
 
28
+ `--confirm`
29
+ : Do not prompt for confirmation before breaking role inheritance.
30
+
28
31
  --8<-- "docs/cmd/_global.md"
29
32
 
30
33
  ## Remarks
@@ -56,3 +59,9 @@ Break inheritance of list item _1_ in list with ID _202b8199-b9de-43fd-9737-7f21
56
59
  ```sh
57
60
  m365 spo listitem roleinheritance break --webUrl https://contoso.sharepoint.com/sites/project-x --listId 202b8199-b9de-43fd-9737-7f213f51c991 --listItemId 1 --clearExistingPermissions
58
61
  ```
62
+
63
+ Break inheritance of list item _1_ in list with ID _202b8199-b9de-43fd-9737-7f213f51c991_ located in site _https://contoso.sharepoint.com/sites/project-x_ with clearing permissions without prompting for confirmation
64
+
65
+ ```sh
66
+ m365 spo listitem roleinheritance break --webUrl https://contoso.sharepoint.com/sites/project-x --listId 202b8199-b9de-43fd-9737-7f213f51c991 --listItemId 1 --clearExistingPermissions --confirm
67
+ ```
@@ -22,6 +22,9 @@ m365 spo listitem roleinheritance reset [options]
22
22
  `--listTitle [listTitle]`
23
23
  : Title of the list. Specify listId or listTitle but not both
24
24
 
25
+ `--confirm`
26
+ : Do not prompt for confirmation before resetting role inheritance.
27
+
25
28
  --8<-- "docs/cmd/_global.md"
26
29
 
27
30
  ## Examples
@@ -37,3 +40,9 @@ Restore role inheritance of list item with id 8 from list with title _test_ loca
37
40
  ```sh
38
41
  m365 spo listitem roleinheritance reset --webUrl https://contoso.sharepoint.com/sites/project-x --listItemId 8 --listTitle test
39
42
  ```
43
+
44
+ Restore role inheritance of list item with id 8 from list with title _test_ located in site _https://contoso.sharepoint.com/sites/project-x_ without prompting for confirmation
45
+
46
+ ```sh
47
+ m365 spo listitem roleinheritance reset --webUrl https://contoso.sharepoint.com/sites/project-x --listItemId 8 --listTitle test --confirm
48
+ ```
@@ -13,6 +13,9 @@ m365 spo web roleinheritance reset [options]
13
13
  `-u, --webUrl <webUrl>`
14
14
  : URL of the site
15
15
 
16
+ `--confirm`
17
+ : Do not prompt for confirmation before resetting role inheritance.
18
+
16
19
  --8<-- "docs/cmd/_global.md"
17
20
 
18
21
  ## Examples
@@ -21,4 +24,10 @@ Restore role inheritance of subsite _https://contoso.sharepoint.com/sites/projec
21
24
 
22
25
  ```sh
23
26
  m365 spo web roleinheritance reset --webUrl https://contoso.sharepoint.com/sites/project-x
27
+ ```
28
+
29
+ Restore role inheritance of subsite _https://contoso.sharepoint.com/sites/project-x_ without prompting for confirmation
30
+
31
+ ```sh
32
+ m365 spo web roleinheritance reset --webUrl https://contoso.sharepoint.com/sites/project-x --confirm
24
33
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "6.0.0-beta.4e32416",
3
+ "version": "6.0.0-beta.550f33a",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",