@pnp/cli-microsoft365 5.8.0-beta.85a4dec → 5.8.0-beta.9cf7616

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.
@@ -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,15 +32,19 @@ 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
  alias() {
36
38
  return [commands_1.default.SENDMAIL];
37
39
  }
38
40
  commandAction(logger, args, cb) {
39
41
  const bodyContents = args.options.bodyContents;
42
+ const isAppOnlyAuth = Auth_1.Auth.isAppOnlyAuth(Auth_1.default.service.accessTokens[this.resource].accessToken);
43
+ if (isAppOnlyAuth === true && !args.options.sender) {
44
+ return cb(new Command_1.CommandError(`Specify a upn or user id in the 'sender' option when using app only authentication.`));
45
+ }
40
46
  const requestOptions = {
41
- url: `${this.resource}/v1.0/me/sendMail`,
47
+ url: `${this.resource}/v1.0/${args.options.sender ? 'users/' + encodeURIComponent(args.options.sender) : 'me'}/sendMail`,
42
48
  headers: {
43
49
  accept: 'application/json;odata.metadata=none',
44
50
  'content-type': 'application/json'
@@ -62,6 +68,13 @@ class OutlookMailSendCommand extends GraphCommand_1.default {
62
68
  saveToSentItems: args.options.saveToSentItems
63
69
  }
64
70
  };
71
+ if (args.options.mailbox) {
72
+ requestOptions.data.message.from = {
73
+ emailAddress: {
74
+ address: args.options.mailbox
75
+ }
76
+ };
77
+ }
65
78
  request_1.default
66
79
  .post(requestOptions)
67
80
  .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
@@ -72,7 +85,9 @@ _OutlookMailSendCommand_instances = new WeakSet(), _OutlookMailSendCommand_initT
72
85
  Object.assign(this.telemetryProperties, {
73
86
  bodyContents: typeof args.options.bodyContents !== 'undefined',
74
87
  bodyContentType: args.options.bodyContentType,
75
- saveToSentItems: args.options.saveToSentItems
88
+ saveToSentItems: args.options.saveToSentItems,
89
+ mailbox: typeof args.options.mailbox !== 'undefined',
90
+ sender: typeof args.options.sender !== 'undefined'
76
91
  });
77
92
  });
78
93
  }, _OutlookMailSendCommand_initOptions = function _OutlookMailSendCommand_initOptions() {
@@ -80,6 +95,10 @@ _OutlookMailSendCommand_instances = new WeakSet(), _OutlookMailSendCommand_initT
80
95
  option: '-s, --subject <subject>'
81
96
  }, {
82
97
  option: '-t, --to <to>'
98
+ }, {
99
+ option: '--sender [sender]'
100
+ }, {
101
+ option: '-m, --mailbox [mailbox]'
83
102
  }, {
84
103
  option: '--bodyContents <bodyContents>'
85
104
  }, {
@@ -19,7 +19,7 @@ class FN010008_YORC_nodeVersion extends JsonRule_1.JsonRule {
19
19
  get resolution() {
20
20
  return `{
21
21
  "@microsoft/generator-sharepoint": {
22
- "nodeVersion": ${process.version.substring(1)}
22
+ "nodeVersion": "${process.version.substring(1)}"
23
23
  }
24
24
  }`;
25
25
  }
@@ -0,0 +1,112 @@
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 _SpoRoleDefinitionAddCommand_instances, _SpoRoleDefinitionAddCommand_initTelemetry, _SpoRoleDefinitionAddCommand_initOptions, _SpoRoleDefinitionAddCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const utils_1 = require("../../../../utils");
20
+ const SpoCommand_1 = require("../../../base/SpoCommand");
21
+ const base_permissions_1 = require("../../base-permissions");
22
+ const commands_1 = require("../../commands");
23
+ class SpoRoleDefinitionAddCommand extends SpoCommand_1.default {
24
+ constructor() {
25
+ super();
26
+ _SpoRoleDefinitionAddCommand_instances.add(this);
27
+ __classPrivateFieldGet(this, _SpoRoleDefinitionAddCommand_instances, "m", _SpoRoleDefinitionAddCommand_initTelemetry).call(this);
28
+ __classPrivateFieldGet(this, _SpoRoleDefinitionAddCommand_instances, "m", _SpoRoleDefinitionAddCommand_initOptions).call(this);
29
+ __classPrivateFieldGet(this, _SpoRoleDefinitionAddCommand_instances, "m", _SpoRoleDefinitionAddCommand_initValidators).call(this);
30
+ }
31
+ get name() {
32
+ return commands_1.default.ROLEDEFINITION_ADD;
33
+ }
34
+ get description() {
35
+ return 'Adds a new roledefinition to web';
36
+ }
37
+ get permissionsKindMap() {
38
+ const result = [];
39
+ for (const kind in base_permissions_1.PermissionKind) {
40
+ if (typeof base_permissions_1.PermissionKind[kind] === 'number') {
41
+ result.push(kind);
42
+ }
43
+ }
44
+ return result;
45
+ }
46
+ commandAction(logger, args, cb) {
47
+ if (this.verbose) {
48
+ logger.logToStderr(`Adding role definition to ${args.options.webUrl}...`);
49
+ }
50
+ const description = args.options.description || '';
51
+ const permissions = new base_permissions_1.BasePermissions();
52
+ if (args.options.rights) {
53
+ const rights = args.options.rights.split(',');
54
+ for (const item of rights) {
55
+ const kind = base_permissions_1.PermissionKind[item.trim()];
56
+ permissions.set(kind);
57
+ }
58
+ }
59
+ const requestOptions = {
60
+ url: `${args.options.webUrl}/_api/web/roledefinitions`,
61
+ headers: {
62
+ 'accept': 'application/json;odata=nometadata'
63
+ },
64
+ responseType: 'json',
65
+ data: {
66
+ 'BasePermissions': {
67
+ 'High': permissions.high.toString(),
68
+ 'Low': permissions.low.toString()
69
+ },
70
+ 'Description': `${description}`,
71
+ 'Name': `${args.options.name}`
72
+ }
73
+ };
74
+ request_1.default
75
+ .post(requestOptions)
76
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
77
+ }
78
+ }
79
+ _SpoRoleDefinitionAddCommand_instances = new WeakSet(), _SpoRoleDefinitionAddCommand_initTelemetry = function _SpoRoleDefinitionAddCommand_initTelemetry() {
80
+ this.telemetry.push((args) => {
81
+ Object.assign(this.telemetryProperties, {
82
+ rights: args.options.rights,
83
+ description: (!(!args.options.description)).toString()
84
+ });
85
+ });
86
+ }, _SpoRoleDefinitionAddCommand_initOptions = function _SpoRoleDefinitionAddCommand_initOptions() {
87
+ this.options.unshift({
88
+ option: '-u, --webUrl <webUrl>'
89
+ }, {
90
+ option: '-n, --name <name>'
91
+ }, {
92
+ option: '-d, --description [description]'
93
+ }, {
94
+ option: '--rights [rights]',
95
+ autocomplete: this.permissionsKindMap
96
+ });
97
+ }, _SpoRoleDefinitionAddCommand_initValidators = function _SpoRoleDefinitionAddCommand_initValidators() {
98
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
99
+ if (args.options.rights) {
100
+ const rights = args.options.rights.split(',');
101
+ for (const item of rights) {
102
+ const kind = base_permissions_1.PermissionKind[item.trim()];
103
+ if (!kind) {
104
+ return `Rights option '${item}' is not recognized as valid PermissionKind choice. Please note it is case-sensitive. Allowed values are ${this.permissionsKindMap.join('|')}.`;
105
+ }
106
+ }
107
+ }
108
+ return utils_1.validation.isValidSharePointUrl(args.options.webUrl);
109
+ }));
110
+ };
111
+ module.exports = new SpoRoleDefinitionAddCommand();
112
+ //# sourceMappingURL=roledefinition-add.js.map
@@ -173,6 +173,7 @@ exports.default = {
173
173
  REPORT_SITEUSAGEPAGES: `${prefix} report siteusagepages`,
174
174
  REPORT_SITEUSAGESITECOUNTS: `${prefix} report siteusagesitecounts`,
175
175
  REPORT_SITEUSAGESTORAGE: `${prefix} report siteusagestorage`,
176
+ ROLEDEFINITION_ADD: `${prefix} roledefinition add`,
176
177
  ROLEDEFINITION_GET: `${prefix} roledefinition get`,
177
178
  ROLEDEFINITION_LIST: `${prefix} roledefinition list`,
178
179
  ROLEDEFINITION_REMOVE: `${prefix} roledefinition remove`,
@@ -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 sendmail
2
2
 
3
- Sends e-mail on behalf of the current user
3
+ Sends an e-mail
4
4
 
5
5
  ## Usage
6
6
 
@@ -22,6 +22,12 @@ m365 outlook sendmail [options]
22
22
  `-t, --to <to>`
23
23
  : Comma-separated list of e-mails to send the message to
24
24
 
25
+ `--sender [sender]`
26
+ : Optional upn or user id to specify what account to send the message from. Also see the remarks section.
27
+
28
+ `-m, --mailbox [mailbox]`
29
+ : 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.
30
+
25
31
  `--bodyContents <bodyContents>`
26
32
  : String containing the body of the e-mail to send
27
33
 
@@ -33,6 +39,25 @@ m365 outlook sendmail [options]
33
39
 
34
40
  --8<-- "docs/cmd/_global.md"
35
41
 
42
+ ## Remarks
43
+
44
+ ### If you are connected using app only authentication
45
+
46
+ - 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.
47
+ - 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.
48
+
49
+ !!! important
50
+ You need `Mail.Send` application permissions on the Microsoft Graph to be able to send mails using an application identity.
51
+
52
+ ### If you are connected with a regular user account
53
+
54
+ - 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.
55
+ - You can specify the `--sender` option if you want to send an email as if you were the other user.
56
+ 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.
57
+
58
+ !!! important
59
+ 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.
60
+
36
61
  ## Examples
37
62
 
38
63
  Send a text e-mail to the specified e-mail address
@@ -58,3 +83,21 @@ Send a text e-mail to the specified e-mail address. Don't store the e-mail in se
58
83
  ```sh
59
84
  m365 outlook mail send --to chris@contoso.com --subject "DG2000 Data Sheets" --bodyContents "The latest data sheets are in the team site" --saveToSentItems false
60
85
  ```
86
+
87
+ Send an email on behalf of a shared mailbox using the signed in 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" --mailbox sales@contoso.com
91
+ ```
92
+
93
+ Send an email as another user
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
97
+ ```
98
+
99
+ Send an email as another user, on behalf of a shared mailbox
100
+
101
+ ```sh
102
+ 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
103
+ ```
@@ -0,0 +1,43 @@
1
+ # spo roledefinition add
2
+
3
+ Adds a new roledefinition to web
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 spo roledefinition add [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-u, --webUrl <webUrl>`
14
+ : URL of the site to which role should be added
15
+
16
+ `-n, --name <name>`
17
+ : role definition name
18
+
19
+ `-d, --description [description]`
20
+ : role definition description
21
+
22
+ `--rights [rights]`
23
+ : A case-sensitive string array that contain the permissions needed for the custom action. Allowed values `EmptyMask,ViewListItems,AddListItems,EditListItems,DeleteListItems,ApproveItems,OpenItems,ViewVersions,DeleteVersions,CancelCheckout,ManagePersonalViews,ManageLists,ViewFormPages,AnonymousSearchAccessList,Open,ViewPages,AddAndCustomizePages,ApplyThemeAndBorder,ApplyStyleSheets,ViewUsageData,CreateSSCSite,ManageSubwebs,CreateGroups,ManagePermissions,BrowseDirectories,BrowseUserInfo,AddDelPrivateWebParts,UpdatePersonalWebParts,ManageWeb,AnonymousSearchAccessWebLists,UseClientIntegration,UseRemoteAPIs,ManageAlerts,CreateAlerts,EditMyUserInfo,EnumeratePermissions,FullMask`. Default `EmptyMask`
24
+
25
+ --8<-- "docs/cmd/_global.md"
26
+
27
+ ## Remarks
28
+
29
+ The `--rights` option accepts **case-sensitive** values.
30
+
31
+ ## Examples
32
+
33
+ Adds the role definition for site _https://contoso.sharepoint.com/sites/project-x_ with name _test_
34
+
35
+ ```sh
36
+ m365 spo roledefinition add --webUrl https://contoso.sharepoint.com/sites/project-x --name test
37
+ ```
38
+
39
+ Adds the role definition for site _https://contoso.sharepoint.com/sites/project-x_ with name _test_ and description _test description_ and rights _ViewListItems,AddListItems,EditListItems,DeleteListItems_
40
+
41
+ ```sh
42
+ m365 spo roledefinition add --webUrl https://contoso.sharepoint.com/sites/project-x --name test --description "test description" --rights "ViewListItems,AddListItems,EditListItems,DeleteListItems"
43
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "5.8.0-beta.85a4dec",
3
+ "version": "5.8.0-beta.9cf7616",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",