@pnp/cli-microsoft365 4.1.0 → 4.2.0-beta.148750f

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.
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const request_1 = require("../../../../request");
4
4
  const Utils_1 = require("../../../../Utils");
5
- const AadCommand_1 = require("../../../base/AadCommand");
5
+ const GraphCommand_1 = require("../../../base/GraphCommand");
6
6
  const commands_1 = require("../../commands");
7
- class AadOAuth2GrantAddCommand extends AadCommand_1.default {
7
+ class AadOAuth2GrantAddCommand extends GraphCommand_1.default {
8
8
  get name() {
9
9
  return commands_1.default.OAUTH2GRANT_ADD;
10
10
  }
@@ -16,20 +16,17 @@ class AadOAuth2GrantAddCommand extends AadCommand_1.default {
16
16
  logger.logToStderr(`Granting the service principal specified permissions...`);
17
17
  }
18
18
  const requestOptions = {
19
- url: `${this.resource}/myorganization/oauth2PermissionGrants?api-version=1.6`,
19
+ url: `${this.resource}/v1.0/oauth2PermissionGrants`,
20
20
  headers: {
21
- 'content-type': 'application/json'
21
+ 'content-type': 'application/json;odata.metadata=none'
22
22
  },
23
23
  responseType: 'json',
24
24
  data: {
25
- "odata.type": "Microsoft.DirectoryServices.OAuth2PermissionGrant",
26
25
  "clientId": args.options.clientId,
27
26
  "consentType": "AllPrincipals",
28
27
  "principalId": null,
29
28
  "resourceId": args.options.resourceId,
30
- "scope": args.options.scope,
31
- "startTime": "0001-01-01T00:00:00",
32
- "expiryTime": "9000-01-01T00:00:00"
29
+ "scope": args.options.scope
33
30
  }
34
31
  };
35
32
  request_1.default
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const request_1 = require("../../../../request");
4
- const AadCommand_1 = require("../../../base/AadCommand");
4
+ const GraphCommand_1 = require("../../../base/GraphCommand");
5
5
  const commands_1 = require("../../commands");
6
- class AadOAuth2GrantRemoveCommand extends AadCommand_1.default {
6
+ class AadOAuth2GrantRemoveCommand extends GraphCommand_1.default {
7
7
  get name() {
8
8
  return commands_1.default.OAUTH2GRANT_REMOVE;
9
9
  }
@@ -15,7 +15,10 @@ class AadOAuth2GrantRemoveCommand extends AadCommand_1.default {
15
15
  logger.logToStderr(`Removing OAuth2 permissions...`);
16
16
  }
17
17
  const requestOptions = {
18
- url: `${this.resource}/myorganization/oauth2PermissionGrants/${encodeURIComponent(args.options.grantId)}?api-version=1.6`,
18
+ url: `${this.resource}/v1.0/oauth2PermissionGrants/${encodeURIComponent(args.options.grantId)}`,
19
+ headers: {
20
+ 'accept': 'application/json;odata.metadata=none'
21
+ },
19
22
  responseType: 'json'
20
23
  };
21
24
  request_1.default
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const request_1 = require("../../../../request");
4
- const AadCommand_1 = require("../../../base/AadCommand");
4
+ const GraphCommand_1 = require("../../../base/GraphCommand");
5
5
  const commands_1 = require("../../commands");
6
- class AadOAuth2GrantSetCommand extends AadCommand_1.default {
6
+ class AadOAuth2GrantSetCommand extends GraphCommand_1.default {
7
7
  get name() {
8
8
  return commands_1.default.OAUTH2GRANT_SET;
9
9
  }
@@ -15,7 +15,7 @@ class AadOAuth2GrantSetCommand extends AadCommand_1.default {
15
15
  logger.logToStderr(`Updating OAuth2 permissions...`);
16
16
  }
17
17
  const requestOptions = {
18
- url: `${this.resource}/myorganization/oauth2PermissionGrants/${encodeURIComponent(args.options.grantId)}?api-version=1.6`,
18
+ url: `${this.resource}/v1.0/oauth2PermissionGrants/${encodeURIComponent(args.options.grantId)}`,
19
19
  headers: {
20
20
  'content-type': 'application/json'
21
21
  },
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const request_1 = require("../../../../request");
4
4
  const Utils_1 = require("../../../../Utils");
5
- const AadCommand_1 = require("../../../base/AadCommand");
5
+ const GraphCommand_1 = require("../../../base/GraphCommand");
6
6
  const commands_1 = require("../../commands");
7
- class AadSpGetCommand extends AadCommand_1.default {
7
+ class AadSpGetCommand extends GraphCommand_1.default {
8
8
  get name() {
9
9
  return commands_1.default.SP_GET;
10
10
  }
@@ -18,35 +18,58 @@ class AadSpGetCommand extends AadCommand_1.default {
18
18
  telemetryProps.objectId = (!(!args.options.objectId)).toString();
19
19
  return telemetryProps;
20
20
  }
21
- commandAction(logger, args, cb) {
22
- if (this.verbose) {
23
- logger.logToStderr(`Retrieving service principal information...`);
21
+ getSpId(args) {
22
+ if (args.options.objectId) {
23
+ return Promise.resolve(args.options.objectId);
24
24
  }
25
25
  let spMatchQuery = '';
26
- if (args.options.appId) {
27
- spMatchQuery = `appId eq '${encodeURIComponent(args.options.appId)}'`;
28
- }
29
- else if (args.options.objectId) {
30
- spMatchQuery = `objectId eq '${encodeURIComponent(args.options.objectId)}'`;
31
- }
32
- else {
26
+ if (args.options.displayName) {
33
27
  spMatchQuery = `displayName eq '${encodeURIComponent(args.options.displayName)}'`;
34
28
  }
35
- const requestOptions = {
36
- url: `${this.resource}/myorganization/servicePrincipals?api-version=1.6&$filter=${spMatchQuery}`,
29
+ else if (args.options.appId) {
30
+ spMatchQuery = `appId eq '${encodeURIComponent(args.options.appId)}'`;
31
+ }
32
+ const idRequestOptions = {
33
+ url: `${this.resource}/v1.0/servicePrincipals?$filter=${spMatchQuery}`,
37
34
  headers: {
38
- accept: 'application/json;odata=nometadata'
35
+ accept: 'application/json;odata.metadata=none'
39
36
  },
40
37
  responseType: 'json'
41
38
  };
42
- request_1.default
43
- .get(requestOptions)
44
- .then((res) => {
45
- if (res.value && res.value.length > 0) {
46
- logger.log(res.value[0]);
39
+ return request_1.default
40
+ .get(idRequestOptions)
41
+ .then(response => {
42
+ const spItem = response.value[0];
43
+ if (!spItem) {
44
+ return Promise.reject(`The specified Azure AD app does not exist`);
45
+ }
46
+ if (response.value.length > 1) {
47
+ return Promise.reject(`Multiple Azure AD apps with name ${args.options.displayName} found: ${response.value.map(x => x.id)}`);
47
48
  }
49
+ return Promise.resolve(spItem.id);
50
+ });
51
+ }
52
+ commandAction(logger, args, cb) {
53
+ if (this.verbose) {
54
+ logger.logToStderr(`Retrieving service principal information...`);
55
+ }
56
+ this
57
+ .getSpId(args)
58
+ .then((id) => {
59
+ const requestOptions = {
60
+ url: `${this.resource}/v1.0/servicePrincipals/${id}`,
61
+ headers: {
62
+ accept: 'application/json;odata.metadata=none',
63
+ 'content-type': 'application/json;odata.metadata=none'
64
+ },
65
+ responseType: 'json'
66
+ };
67
+ return request_1.default.get(requestOptions);
68
+ })
69
+ .then((res) => {
70
+ logger.log(res);
48
71
  cb();
49
- }, (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
72
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
50
73
  }
51
74
  options() {
52
75
  const options = [
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const request_1 = require("../../../../request");
4
+ const Utils_1 = require("../../../../Utils");
5
+ const SpoCommand_1 = require("../../../base/SpoCommand");
6
+ const commands_1 = require("../../commands");
7
+ class SpoListItemAttachmentListCommand extends SpoCommand_1.default {
8
+ get name() {
9
+ return commands_1.default.LISTITEM_ATTACHMENT_LIST;
10
+ }
11
+ get description() {
12
+ return 'Gets the attachments associated to a list item';
13
+ }
14
+ getTelemetryProperties(args) {
15
+ const telemetryProps = super.getTelemetryProperties(args);
16
+ telemetryProps.listId = typeof args.options.listId !== 'undefined';
17
+ telemetryProps.listTitle = typeof args.options.listTitle !== 'undefined';
18
+ return telemetryProps;
19
+ }
20
+ defaultProperties() {
21
+ return ['FileName', 'ServerRelativeUrl'];
22
+ }
23
+ commandAction(logger, args, cb) {
24
+ const listIdArgument = args.options.listId || '';
25
+ const listTitleArgument = args.options.listTitle || '';
26
+ const listRestUrl = (args.options.listId ?
27
+ `${args.options.webUrl}/_api/web/lists(guid'${encodeURIComponent(listIdArgument)}')`
28
+ : `${args.options.webUrl}/_api/web/lists/getByTitle('${encodeURIComponent(listTitleArgument)}')`);
29
+ const requestOptions = {
30
+ url: `${listRestUrl}/items(${args.options.itemId})?$select=AttachmentFiles&$expand=AttachmentFiles`,
31
+ method: 'GET',
32
+ headers: {
33
+ 'accept': 'application/json;odata=nometadata'
34
+ },
35
+ responseType: 'json'
36
+ };
37
+ request_1.default
38
+ .get(requestOptions)
39
+ .then((attachmentFiles) => {
40
+ if (attachmentFiles.AttachmentFiles && attachmentFiles.AttachmentFiles.length > 0) {
41
+ logger.log(attachmentFiles.AttachmentFiles);
42
+ }
43
+ else {
44
+ if (this.verbose) {
45
+ logger.logToStderr('No attachments found');
46
+ }
47
+ }
48
+ cb();
49
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
50
+ }
51
+ options() {
52
+ const options = [
53
+ {
54
+ option: '-u, --webUrl <webUrl>'
55
+ },
56
+ {
57
+ option: '--itemId <itemId>'
58
+ },
59
+ {
60
+ option: '--listId [listId]'
61
+ },
62
+ {
63
+ option: '--listTitle [listTitle]'
64
+ }
65
+ ];
66
+ const parentOptions = super.options();
67
+ return options.concat(parentOptions);
68
+ }
69
+ validate(args) {
70
+ const isValidSharePointUrl = SpoCommand_1.default.isValidSharePointUrl(args.options.webUrl);
71
+ if (isValidSharePointUrl !== true) {
72
+ return isValidSharePointUrl;
73
+ }
74
+ if (!args.options.listId && !args.options.listTitle) {
75
+ return `Specify listId or listTitle`;
76
+ }
77
+ if (args.options.listId && args.options.listTitle) {
78
+ return `Specify listId or listTitle but not both`;
79
+ }
80
+ if (args.options.listId && !Utils_1.default.isValidGuid(args.options.listId)) {
81
+ return `${args.options.listId} in option listId is not a valid GUID`;
82
+ }
83
+ if (isNaN(parseInt(args.options.itemId))) {
84
+ return `${args.options.itemId} is not a number`;
85
+ }
86
+ return true;
87
+ }
88
+ }
89
+ module.exports = new SpoListItemAttachmentListCommand();
90
+ //# sourceMappingURL=listitem-attachment-list.js.map
@@ -107,6 +107,7 @@ exports.default = {
107
107
  LIST_WEBHOOK_REMOVE: `${prefix} list webhook remove`,
108
108
  LIST_WEBHOOK_SET: `${prefix} list webhook set`,
109
109
  LISTITEM_ADD: `${prefix} listitem add`,
110
+ LISTITEM_ATTACHMENT_LIST: `${prefix} listitem attachment list`,
110
111
  LISTITEM_GET: `${prefix} listitem get`,
111
112
  LISTITEM_ISRECORD: `${prefix} listitem isrecord`,
112
113
  LISTITEM_LIST: `${prefix} listitem list`,
@@ -22,7 +22,7 @@ class TeamsReportPstncallsCommand extends GraphCommand_1.default {
22
22
  commandAction(logger, args, cb) {
23
23
  const toDateTimeParameter = encodeURIComponent(args.options.toDateTime ? args.options.toDateTime : new Date().toISOString());
24
24
  const requestOptions = {
25
- url: `${this.resource}/beta/communications/callRecords/getPstnCalls(fromDateTime=${encodeURIComponent(args.options.fromDateTime)},toDateTime=${toDateTimeParameter})`,
25
+ url: `${this.resource}/v1.0/communications/callRecords/getPstnCalls(fromDateTime=${encodeURIComponent(args.options.fromDateTime)},toDateTime=${toDateTimeParameter})`,
26
26
  headers: {
27
27
  accept: 'application/json;odata.metadata=none'
28
28
  },
@@ -35,4 +35,5 @@ m365 aad oauth2grant remove --grantId YgA60KYa4UOPSdc-lpxYEnQkr8KVLDpCsOXkiV8i-e
35
35
 
36
36
  ## More information
37
37
 
38
- - Application and service principal objects in Azure Active Directory (Azure AD): [https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects)
38
+ - Application and service principal objects in Azure Active Directory (Azure AD): [https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects)
39
+ - Delete a delegated permission grant (oAuth2PermissionGrant): [https://docs.microsoft.com/en-us/graph/api/oauth2permissiongrant-delete?view=graph-rest-1.0](https://docs.microsoft.com/en-us/graph/api/oauth2permissiongrant-delete?view=graph-rest-1.0)
@@ -22,7 +22,7 @@ m365 aad oauth2grant set [options]
22
22
 
23
23
  Before you can update service principal's OAuth2 permissions, you need to get the `objectId` of the permissions grant to update. You can retrieve it using the [aad oauth2grant list](./oauth2grant-list.md) command.
24
24
 
25
- If the `objectId` listed when using the [aad oauth2grant list](./oauth2grant-list.md) command has a minus sign ('-') prefix, you may receive an error indicating `--grantId` is missing. To resolve this issue simply escape the leading '-'.
25
+ If the `objectId` listed when using the [aad oauth2grant list](./oauth2grant-list.md) command has a minus sign ('-') prefix, you may receive an error indicating `--grantId` is missing. To resolve this issue simply escape the leading '-'.
26
26
 
27
27
  ```sh
28
28
  m365 aad oauth2grant set --grantId \\-Zc1JRY8REeLxmXz5KtixAYU3Q6noCBPlhwGiX7pxmU
@@ -38,4 +38,5 @@ m365 aad oauth2grant set --grantId YgA60KYa4UOPSdc-lpxYEnQkr8KVLDpCsOXkiV8i-ek -
38
38
 
39
39
  ## More information
40
40
 
41
- - Application and service principal objects in Azure Active Directory (Azure AD): [https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects)
41
+ - Application and service principal objects in Azure Active Directory (Azure AD): [https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects)
42
+ - Update a delegated permission grant (oAuth2PermissionGrant): [https://docs.microsoft.com/en-us/graph/api/oauth2permissiongrant-update?view=graph-rest-1.0](https://docs.microsoft.com/en-us/graph/api/oauth2permissiongrant-update?view=graph-rest-1.0)
@@ -47,4 +47,5 @@ m365 aad sp get --objectId b2307a39-e878-458b-bc90-03bc578531dd
47
47
 
48
48
  ## More information
49
49
 
50
- - Application and service principal objects in Azure Active Directory (Azure AD): [https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects)
50
+ - Application and service principal objects in Azure Active Directory (Azure AD): [https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects)
51
+ - Get servicePrincipal: [https://docs.microsoft.com/en-us/graph/api/serviceprincipal-get?view=graph-rest-1.0](https://docs.microsoft.com/en-us/graph/api/serviceprincipal-get?view=graph-rest-1.0)
@@ -0,0 +1,39 @@
1
+ # spo listitem attachment list
2
+
3
+ Gets the attachments associated to a list item
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 spo listitem attachment list [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-u, --webUrl <webUrl>`
14
+ URL of the site from which the item should be retrieved
15
+
16
+ `--listId [listId]`
17
+ : ID of the list from which to retrieve the item. Specify listId or listTitle but not both
18
+
19
+ `--listTitle [listTitle]`
20
+ : Title of the list from which to retrieve the item. Specify listId or listTitle but not both
21
+
22
+ `--itemId <itemId>`
23
+ ID of the list item to in question
24
+
25
+ --8<-- "docs/cmd/_global.md"
26
+
27
+ ## Examples
28
+
29
+ Gets the attachments from list item with itemId _147_ in list with title _Demo List_ in site _https://contoso.sharepoint.com/sites/project-x_
30
+
31
+ ```sh
32
+ m365 spo listitem attachment list --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle "Demo List" --itemId 147
33
+ ```
34
+
35
+ Gets the attachments from list item with itemId _147_ in list with id _0cd891ef-afce-4e55-b836-fce03286cccf_ in site _https://contoso.sharepoint.com/sites/project-x_
36
+
37
+ ```sh
38
+ m365 spo listitem attachment list --webUrl https://contoso.sharepoint.com/sites/project-x --listId 0cd891ef-afce-4e55-b836-fce03286cccf --itemId 147
39
+ ```
@@ -24,9 +24,6 @@ This command only works with app-only permissions. You will need to create your
24
24
 
25
25
  The difference between `fromDateTime` and `toDateTime` cannot exceed a period of 90 days
26
26
 
27
- !!! attention
28
- This command is based on an API that is currently in preview and is subject to change once the API reached general availability.
29
-
30
27
  ## Examples
31
28
 
32
29
  Get details about PSTN calls made between 2020-10-31 and today
@@ -46,3 +43,7 @@ Get details about PSTN calls made between 2020-10-31 and 2020-12-31 and exports
46
43
  ```sh
47
44
  m365 teams report pstncalls --fromDateTime 2020-10-31 --toDateTime 2020-12-31 --output json > "pstncalls.json"
48
45
  ```
46
+
47
+ ## More information
48
+
49
+ - List PSTN calls: [https://docs.microsoft.com/en-us/graph/api/callrecords-callrecord-getpstncalls?view=graph-rest-1.0](https://docs.microsoft.com/en-us/graph/api/callrecords-callrecord-getpstncalls?view=graph-rest-1.0)
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@pnp/cli-microsoft365",
9
- "version": "4.1.0",
9
+ "version": "4.2.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@azure/msal-node": "^1.3.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "4.1.0",
3
+ "version": "4.2.0-beta.148750f",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -218,4 +218,4 @@
218
218
  "rimraf": "^3.0.2",
219
219
  "sinon": "^11.1.2"
220
220
  }
221
- }
221
+ }