@pnp/cli-microsoft365 5.3.0-beta.b46b892 → 5.3.0-beta.d2ec1f4

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.
@@ -0,0 +1,84 @@
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 SpoFieldListCommand extends SpoCommand_1.default {
8
+ get name() {
9
+ return commands_1.default.FIELD_LIST;
10
+ }
11
+ get description() {
12
+ return 'Retrieves columns for the specified list or site';
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
+ telemetryProps.listUrl = typeof args.options.listUrl !== 'undefined';
19
+ return telemetryProps;
20
+ }
21
+ defaultProperties() {
22
+ return ['Id', 'Title', 'Group', 'Hidden'];
23
+ }
24
+ commandAction(logger, args, cb) {
25
+ let listUrl = '';
26
+ if (args.options.listId) {
27
+ listUrl = `lists(guid'${encodeURIComponent(args.options.listId)}')/`;
28
+ }
29
+ else if (args.options.listTitle) {
30
+ listUrl = `lists/getByTitle('${encodeURIComponent(args.options.listTitle)}')/`;
31
+ }
32
+ else if (args.options.listUrl) {
33
+ const listServerRelativeUrl = utils_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
34
+ listUrl = `GetList('${encodeURIComponent(listServerRelativeUrl)}')/`;
35
+ }
36
+ const requestOptions = {
37
+ url: `${args.options.webUrl}/_api/web/${listUrl}fields`,
38
+ headers: {
39
+ accept: 'application/json;odata=nometadata'
40
+ },
41
+ responseType: 'json'
42
+ };
43
+ request_1.default
44
+ .get(requestOptions)
45
+ .then((res) => {
46
+ logger.log(res.value);
47
+ cb();
48
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
49
+ }
50
+ options() {
51
+ const options = [
52
+ {
53
+ option: '-u, --webUrl <webUrl>'
54
+ },
55
+ {
56
+ option: '-t, --listTitle [listTitle]'
57
+ },
58
+ {
59
+ option: '-i, --listId [listId]'
60
+ },
61
+ {
62
+ option: '--listUrl [listUrl]'
63
+ }
64
+ ];
65
+ const parentOptions = super.options();
66
+ return options.concat(parentOptions);
67
+ }
68
+ validate(args) {
69
+ const isValidSharePointUrl = utils_1.validation.isValidSharePointUrl(args.options.webUrl);
70
+ if (isValidSharePointUrl !== true) {
71
+ return isValidSharePointUrl;
72
+ }
73
+ if (args.options.listId && !utils_1.validation.isValidGuid(args.options.listId)) {
74
+ return `${args.options.listId} is not a valid GUID`;
75
+ }
76
+ const listOptions = [args.options.listId, args.options.listTitle, args.options.listUrl];
77
+ if (listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1) {
78
+ return `Specify either list id or title or list url`;
79
+ }
80
+ return true;
81
+ }
82
+ }
83
+ module.exports = new SpoFieldListCommand();
84
+ //# sourceMappingURL=field-list.js.map
@@ -41,6 +41,7 @@ exports.default = {
41
41
  FEATURE_LIST: `${prefix} feature list`,
42
42
  FIELD_ADD: `${prefix} field add`,
43
43
  FIELD_GET: `${prefix} field get`,
44
+ FIELD_LIST: `${prefix} field list`,
44
45
  FIELD_REMOVE: `${prefix} field remove`,
45
46
  FIELD_SET: `${prefix} field set`,
46
47
  FILE_ADD: `${prefix} file add`,
@@ -0,0 +1,51 @@
1
+ # spo field list
2
+
3
+ Retrieves columns for the specified list or site
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 spo field list [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-u, --webUrl <webUrl>`
14
+ : Absolute URL of the site where fields are located
15
+
16
+ `-t, --listTitle [listTitle]`
17
+ : Title of the list where fields are located. Specify `listTitle`, `listId` or `listUrl`
18
+
19
+ `-i --listId [listId]`
20
+ : ID of the list where fields are located. Specify `listTitle`, `listId` or `listUrl`
21
+
22
+ `--listUrl [listUrl]`
23
+ : Server- or web-relative URL of the list where fields are located. Specify `listTitle`, `listId` or `listUrl`
24
+
25
+ --8<-- "docs/cmd/_global.md"
26
+
27
+ ## Examples
28
+
29
+ Retrieves site columns for site _https://contoso.sharepoint.com/sites/contoso-sales_.
30
+
31
+ ```sh
32
+ m365 spo field list --webUrl https://contoso.sharepoint.com/sites/contoso-sales
33
+ ```
34
+
35
+ Retrieves list columns for list _Events_ in site _https://contoso.sharepoint.com/sites/contoso-sales_
36
+
37
+ ```sh
38
+ m365 spo field list --webUrl https://contoso.sharepoint.com/sites/contoso-sales --listTitle Events
39
+ ```
40
+
41
+ Retrieves list columns for list _202b8199-b9de-43fd-9737-7f213f51c991_ in site _https://contoso.sharepoint.com/sites/contoso-sales_
42
+
43
+ ```sh
44
+ m365 spo field list --webUrl https://contoso.sharepoint.com/sites/contoso-sales --listId '202b8199-b9de-43fd-9737-7f213f51c991'
45
+ ```
46
+
47
+ Retrieves list columns for list _/sites/contoso-sales/lists/Events_ in site _https://contoso.sharepoint.com/sites/contoso-sales_
48
+
49
+ ```sh
50
+ m365 spo field list --webUrl https://contoso.sharepoint.com/sites/contoso-sales --listUrl '/sites/contoso-sales/lists/Events'
51
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "5.3.0-beta.b46b892",
3
+ "version": "5.3.0-beta.d2ec1f4",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",