@pnp/cli-microsoft365 6.7.0-beta.54db310 → 6.7.0-beta.7321771
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.
- package/.devcontainer/Dockerfile +1 -1
- package/README.md +10 -10
- package/dist/Auth.js +75 -4
- package/dist/AuthServer.js +2 -1
- package/dist/Command.js +56 -7
- package/dist/m365/aad/commands/user/user-set.js +145 -30
- package/dist/m365/base/AzmgmtCommand.js +11 -0
- package/dist/m365/base/PowerAppsCommand.js +11 -0
- package/dist/m365/base/PowerPlatformCommand.js +11 -0
- package/dist/m365/commands/login.js +17 -1
- package/dist/m365/commands/status.js +4 -2
- package/dist/m365/flow/commands/run/run-get.js +31 -1
- package/dist/m365/spo/commands/file/file-list.js +108 -32
- package/dist/m365/spo/commands/folder/folder-list.js +73 -16
- package/dist/m365/spo/commands/listitem/listitem-list.js +113 -55
- package/dist/m365/spo/commands/site/site-recyclebinitem-clear.js +115 -0
- package/dist/m365/spo/commands.js +1 -0
- package/dist/request.js +7 -0
- package/dist/utils/misc.js +11 -0
- package/docs/docs/cmd/aad/user/user-set.md +53 -8
- package/docs/docs/cmd/flow/run/run-get.md +110 -9
- package/docs/docs/cmd/login.md +5 -2
- package/docs/docs/cmd/planner/task/task-add.md +3 -1
- package/docs/docs/cmd/planner/task/task-set.md +6 -4
- package/docs/docs/cmd/spo/file/file-list.md +87 -2
- package/docs/docs/cmd/spo/folder/folder-list.md +36 -1
- package/docs/docs/cmd/spo/listitem/listitem-list.md +22 -8
- package/docs/docs/cmd/spo/site/site-recyclebinitem-clear.md +45 -0
- package/docs/docs/cmd/spo/spo-get.md +12 -0
- package/docs/docs/cmd/spo/spo-search.md +16 -3
- package/docs/docs/cmd/spo/user/user-ensure.md +1 -2
- package/docs/docs/cmd/spo/user/user-get.md +24 -0
- package/docs/docs/cmd/spo/user/user-list.md +27 -3
- package/docs/docs/cmd/spo/userprofile/userprofile-get.md +21 -0
- package/docs/docs/cmd/spo/web/web-add.md +24 -0
- package/docs/docs/cmd/spo/web/web-clientsidewebpart-list.md +16 -0
- package/docs/docs/cmd/spo/web/web-get.md +124 -0
- package/docs/docs/cmd/spo/web/web-installedlanguage-list.md +16 -0
- package/docs/docs/cmd/spo/web/web-list.md +16 -0
- package/docs/docs/cmd/spo/web/web-retentionlabel-list.md +29 -2
- package/docs/docs/cmd/tenant/id/id-get.md +6 -0
- package/docs/docs/cmd/tenant/report/report-activeusercounts.md +7 -0
- package/docs/docs/cmd/tenant/report/report-activeuserdetail.md +7 -0
- package/docs/docs/cmd/tenant/report/report-office365activationcounts.md +7 -0
- package/docs/docs/cmd/tenant/report/report-office365activationsusercounts.md +7 -0
- package/docs/docs/cmd/tenant/report/report-office365activationsuserdetail.md +7 -0
- package/docs/docs/cmd/tenant/report/report-servicesusercounts.md +7 -0
- package/docs/docs/cmd/tenant/security/security-alerts-list.md +23 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-get.md +32 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-list.md +32 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-get.md +26 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-list.md +26 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-get.md +22 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-list.md +22 -0
- package/package.json +3 -1
- package/dist/m365/spo/commands/file/FilePropertiesCollection.js +0 -3
- package/dist/m365/spo/commands/folder/FileFolderCollection.js +0 -3
|
@@ -19,6 +19,7 @@ const fs = require("fs");
|
|
|
19
19
|
const Auth_1 = require("../../Auth");
|
|
20
20
|
const Command_1 = require("../../Command");
|
|
21
21
|
const config_1 = require("../../config");
|
|
22
|
+
const misc_1 = require("../../utils/misc");
|
|
22
23
|
const commands_1 = require("./commands");
|
|
23
24
|
class LoginCommand extends Command_1.default {
|
|
24
25
|
get name() {
|
|
@@ -71,6 +72,12 @@ class LoginCommand extends Command_1.default {
|
|
|
71
72
|
Auth_1.default.service.secret = args.options.secret;
|
|
72
73
|
break;
|
|
73
74
|
}
|
|
75
|
+
if (args.options.cloud) {
|
|
76
|
+
Auth_1.default.service.cloudType = Auth_1.CloudType[args.options.cloud];
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
Auth_1.default.service.cloudType = Auth_1.CloudType.Public;
|
|
80
|
+
}
|
|
74
81
|
try {
|
|
75
82
|
yield Auth_1.default.ensureAccessToken(Auth_1.default.defaultResource, logger, this.debug);
|
|
76
83
|
Auth_1.default.service.connected = true;
|
|
@@ -113,8 +120,10 @@ class LoginCommand extends Command_1.default {
|
|
|
113
120
|
}
|
|
114
121
|
_LoginCommand_instances = new WeakSet(), _LoginCommand_initTelemetry = function _LoginCommand_initTelemetry() {
|
|
115
122
|
this.telemetry.push((args) => {
|
|
123
|
+
var _a;
|
|
116
124
|
Object.assign(this.telemetryProperties, {
|
|
117
|
-
authType: args.options.authType || 'deviceCode'
|
|
125
|
+
authType: args.options.authType || 'deviceCode',
|
|
126
|
+
cloud: (_a = args.options.cloud) !== null && _a !== void 0 ? _a : Auth_1.CloudType.Public
|
|
118
127
|
});
|
|
119
128
|
});
|
|
120
129
|
}, _LoginCommand_initOptions = function _LoginCommand_initOptions() {
|
|
@@ -137,6 +146,9 @@ _LoginCommand_instances = new WeakSet(), _LoginCommand_initTelemetry = function
|
|
|
137
146
|
option: '--tenant [tenant]'
|
|
138
147
|
}, {
|
|
139
148
|
option: '--secret [secret]'
|
|
149
|
+
}, {
|
|
150
|
+
option: '--cloud [cloud]',
|
|
151
|
+
autocomplete: misc_1.misc.getEnums(Auth_1.CloudType)
|
|
140
152
|
});
|
|
141
153
|
}, _LoginCommand_initValidators = function _LoginCommand_initValidators() {
|
|
142
154
|
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -170,6 +182,10 @@ _LoginCommand_instances = new WeakSet(), _LoginCommand_initTelemetry = function
|
|
|
170
182
|
return 'Required option secret missing';
|
|
171
183
|
}
|
|
172
184
|
}
|
|
185
|
+
if (args.options.cloud &&
|
|
186
|
+
typeof Auth_1.CloudType[args.options.cloud] === 'undefined') {
|
|
187
|
+
return `${args.options.cloud} is not a valid value for cloud. Valid options are ${misc_1.misc.getEnums(Auth_1.CloudType).join(', ')}`;
|
|
188
|
+
}
|
|
173
189
|
return true;
|
|
174
190
|
}));
|
|
175
191
|
};
|
|
@@ -39,7 +39,8 @@ class StatusCommand extends Command_1.default {
|
|
|
39
39
|
authType: Auth_1.AuthType[Auth_1.default.service.authType],
|
|
40
40
|
appId: Auth_1.default.service.appId,
|
|
41
41
|
appTenant: Auth_1.default.service.tenant,
|
|
42
|
-
accessTokens: JSON.stringify(Auth_1.default.service.accessTokens, null, 2)
|
|
42
|
+
accessTokens: JSON.stringify(Auth_1.default.service.accessTokens, null, 2),
|
|
43
|
+
cloudType: Auth_1.CloudType[Auth_1.default.service.cloudType]
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
else {
|
|
@@ -47,7 +48,8 @@ class StatusCommand extends Command_1.default {
|
|
|
47
48
|
connectedAs: accessToken_1.accessToken.getUserNameFromAccessToken(Auth_1.default.service.accessTokens[Auth_1.default.defaultResource].accessToken),
|
|
48
49
|
authType: Auth_1.AuthType[Auth_1.default.service.authType],
|
|
49
50
|
appId: Auth_1.default.service.appId,
|
|
50
|
-
appTenant: Auth_1.default.service.tenant
|
|
51
|
+
appTenant: Auth_1.default.service.tenant,
|
|
52
|
+
cloudType: Auth_1.CloudType[Auth_1.default.service.cloudType]
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
}
|
|
@@ -13,10 +13,11 @@ 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 _FlowRunGetCommand_instances, _FlowRunGetCommand_initOptions;
|
|
16
|
+
var _FlowRunGetCommand_instances, _FlowRunGetCommand_initOptions, _FlowRunGetCommand_initValidators, _FlowRunGetCommand_initTelemetry;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
const request_1 = require("../../../../request");
|
|
19
19
|
const formatting_1 = require("../../../../utils/formatting");
|
|
20
|
+
const validation_1 = require("../../../../utils/validation");
|
|
20
21
|
const AzmgmtCommand_1 = require("../../../base/AzmgmtCommand");
|
|
21
22
|
const commands_1 = require("../../commands");
|
|
22
23
|
class FlowRunGetCommand extends AzmgmtCommand_1.default {
|
|
@@ -32,7 +33,9 @@ class FlowRunGetCommand extends AzmgmtCommand_1.default {
|
|
|
32
33
|
constructor() {
|
|
33
34
|
super();
|
|
34
35
|
_FlowRunGetCommand_instances.add(this);
|
|
36
|
+
__classPrivateFieldGet(this, _FlowRunGetCommand_instances, "m", _FlowRunGetCommand_initTelemetry).call(this);
|
|
35
37
|
__classPrivateFieldGet(this, _FlowRunGetCommand_instances, "m", _FlowRunGetCommand_initOptions).call(this);
|
|
38
|
+
__classPrivateFieldGet(this, _FlowRunGetCommand_instances, "m", _FlowRunGetCommand_initValidators).call(this);
|
|
36
39
|
}
|
|
37
40
|
commandAction(logger, args) {
|
|
38
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -52,6 +55,18 @@ class FlowRunGetCommand extends AzmgmtCommand_1.default {
|
|
|
52
55
|
res.endTime = res.properties.endTime || '';
|
|
53
56
|
res.status = res.properties.status;
|
|
54
57
|
res.triggerName = res.properties.trigger.name;
|
|
58
|
+
if (args.options.includeTriggerInformation && res.properties.trigger.outputsLink) {
|
|
59
|
+
const triggerInformationOptions = {
|
|
60
|
+
url: res.properties.trigger.outputsLink.uri,
|
|
61
|
+
headers: {
|
|
62
|
+
accept: 'application/json',
|
|
63
|
+
'x-anonymous': true
|
|
64
|
+
},
|
|
65
|
+
responseType: 'json'
|
|
66
|
+
};
|
|
67
|
+
const triggerInformationResponse = yield request_1.default.get(triggerInformationOptions);
|
|
68
|
+
res.triggerInformation = triggerInformationResponse.body;
|
|
69
|
+
}
|
|
55
70
|
logger.log(res);
|
|
56
71
|
}
|
|
57
72
|
catch (err) {
|
|
@@ -67,6 +82,21 @@ _FlowRunGetCommand_instances = new WeakSet(), _FlowRunGetCommand_initOptions = f
|
|
|
67
82
|
option: '-f, --flowName <flowName>'
|
|
68
83
|
}, {
|
|
69
84
|
option: '-e, --environmentName <environmentName>'
|
|
85
|
+
}, {
|
|
86
|
+
option: '--includeTriggerInformation'
|
|
87
|
+
});
|
|
88
|
+
}, _FlowRunGetCommand_initValidators = function _FlowRunGetCommand_initValidators() {
|
|
89
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
if (!validation_1.validation.isValidGuid(args.options.flowName)) {
|
|
91
|
+
return `${args.options.flowName} is not a valid GUID`;
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}));
|
|
95
|
+
}, _FlowRunGetCommand_initTelemetry = function _FlowRunGetCommand_initTelemetry() {
|
|
96
|
+
this.telemetry.push((args) => {
|
|
97
|
+
Object.assign(this.telemetryProperties, {
|
|
98
|
+
includeTriggerInformation: !!args.options.includeTriggerInformation
|
|
99
|
+
});
|
|
70
100
|
});
|
|
71
101
|
};
|
|
72
102
|
module.exports = new FlowRunGetCommand();
|
|
@@ -17,6 +17,7 @@ var _SpoFileListCommand_instances, _SpoFileListCommand_initTelemetry, _SpoFileLi
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
const request_1 = require("../../../../request");
|
|
19
19
|
const formatting_1 = require("../../../../utils/formatting");
|
|
20
|
+
const urlUtil_1 = require("../../../../utils/urlUtil");
|
|
20
21
|
const validation_1 = require("../../../../utils/validation");
|
|
21
22
|
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
22
23
|
const commands_1 = require("../../commands");
|
|
@@ -37,53 +38,123 @@ class SpoFileListCommand extends SpoCommand_1.default {
|
|
|
37
38
|
commandAction(logger, args) {
|
|
38
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
40
|
if (this.verbose) {
|
|
40
|
-
logger.logToStderr(`Retrieving all files in folder ${args.options.folder} at site ${args.options.webUrl}...`);
|
|
41
|
+
logger.logToStderr(`Retrieving all files in folder '${args.options.folder}' at site '${args.options.webUrl}'${args.options.recursive ? ' (recursive)' : ''}...`);
|
|
41
42
|
}
|
|
42
43
|
try {
|
|
43
|
-
const
|
|
44
|
-
|
|
44
|
+
const fieldProperties = this.formatSelectProperties(args.options.fields, args.options.output);
|
|
45
|
+
const allFiles = [];
|
|
46
|
+
const allFolders = args.options.recursive
|
|
47
|
+
? [...yield this.getFolders(args.options.folder, args, logger), args.options.folder]
|
|
48
|
+
: [args.options.folder];
|
|
49
|
+
for (const folder of allFolders) {
|
|
50
|
+
const files = yield this.getFiles(folder, fieldProperties, args, logger);
|
|
51
|
+
files.forEach((file) => allFiles.push(file));
|
|
52
|
+
}
|
|
53
|
+
// Clean ListItemAllFields.ID property from the output if included
|
|
54
|
+
// Reason: It causes a casing conflict with 'Id' when parsing JSON in PowerShell
|
|
55
|
+
if (fieldProperties.selectProperties.some(p => p.toLowerCase().indexOf('listitemallfields') > -1)) {
|
|
56
|
+
allFiles.filter(file => { var _a; return ((_a = file.ListItemAllFields) === null || _a === void 0 ? void 0 : _a.ID) !== undefined; }).forEach(file => delete file.ListItemAllFields['ID']);
|
|
57
|
+
}
|
|
58
|
+
logger.log(allFiles);
|
|
45
59
|
}
|
|
46
60
|
catch (err) {
|
|
47
61
|
this.handleRejectedODataJsonPromise(err);
|
|
48
62
|
}
|
|
49
63
|
});
|
|
50
64
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
return request_1.default
|
|
68
|
-
.get(requestOptions)
|
|
69
|
-
.then((filesAndFoldersResult) => {
|
|
70
|
-
filesAndFoldersResult.Files.forEach((file) => files.value.push(file));
|
|
71
|
-
// If the request is --recursive, call this method for other folders.
|
|
72
|
-
if (args.options.recursive &&
|
|
73
|
-
filesAndFoldersResult.Folders !== undefined &&
|
|
74
|
-
filesAndFoldersResult.Folders.length !== 0) {
|
|
75
|
-
return Promise.all(filesAndFoldersResult.Folders.map((folder) => this.getFiles(folder.ServerRelativeUrl, args, files)));
|
|
65
|
+
getFiles(folderUrl, fieldProperties, args, logger, skip = 0) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
if (this.verbose) {
|
|
68
|
+
const page = Math.ceil(skip / SpoFileListCommand.pageSize) + 1;
|
|
69
|
+
logger.logToStderr(`Retrieving files in folder '${folderUrl}'${page > 1 ? ', page ' + page : ''}...`);
|
|
70
|
+
}
|
|
71
|
+
const allFiles = [];
|
|
72
|
+
const serverRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, folderUrl);
|
|
73
|
+
const requestUrl = `${args.options.webUrl}/_api/web/GetFolderByServerRelativeUrl(@url)/Files?@url='${formatting_1.formatting.encodeQueryParameter(serverRelativeUrl)}'`;
|
|
74
|
+
const queryParams = [`$skip=${skip}`, `$top=${SpoFileListCommand.pageSize}`];
|
|
75
|
+
if (fieldProperties.expandProperties.length > 0) {
|
|
76
|
+
queryParams.push(`$expand=${fieldProperties.expandProperties.join(',')}`);
|
|
77
|
+
}
|
|
78
|
+
if (fieldProperties.selectProperties.length > 0) {
|
|
79
|
+
queryParams.push(`$select=${fieldProperties.selectProperties.join(',')}`);
|
|
76
80
|
}
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
if (args.options.filter) {
|
|
82
|
+
queryParams.push(`$filter=${args.options.filter}`);
|
|
79
83
|
}
|
|
80
|
-
|
|
84
|
+
const requestOptions = {
|
|
85
|
+
url: `${requestUrl}&${queryParams.join('&')}`,
|
|
86
|
+
method: 'GET',
|
|
87
|
+
headers: {
|
|
88
|
+
'accept': 'application/json;odata=nometadata'
|
|
89
|
+
},
|
|
90
|
+
responseType: 'json'
|
|
91
|
+
};
|
|
92
|
+
const response = yield request_1.default.get(requestOptions);
|
|
93
|
+
response.value.forEach(file => allFiles.push(file));
|
|
94
|
+
if (response.value.length === SpoFileListCommand.pageSize) {
|
|
95
|
+
const files = yield this.getFiles(folderUrl, fieldProperties, args, logger, skip + SpoFileListCommand.pageSize);
|
|
96
|
+
files.forEach(file => allFiles.push(file));
|
|
97
|
+
}
|
|
98
|
+
return allFiles;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
getFolders(folderUrl, args, logger, skip = 0) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
if (this.verbose) {
|
|
104
|
+
const page = Math.ceil(skip / SpoFileListCommand.pageSize) + 1;
|
|
105
|
+
logger.logToStderr(`Retrieving folders in folder '${folderUrl}'${page > 1 ? ', page ' + page : ''}...`);
|
|
106
|
+
}
|
|
107
|
+
const allFolders = [];
|
|
108
|
+
const serverRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, folderUrl);
|
|
109
|
+
const requestUrl = `${args.options.webUrl}/_api/web/GetFolderByServerRelativeUrl(@url)/Folders?@url='${formatting_1.formatting.encodeQueryParameter(serverRelativeUrl)}'`;
|
|
110
|
+
const requestOptions = {
|
|
111
|
+
url: `${requestUrl}&$skip=${skip}&$top=${SpoFileListCommand.pageSize}&$select=ServerRelativeUrl`,
|
|
112
|
+
method: 'GET',
|
|
113
|
+
headers: {
|
|
114
|
+
'accept': 'application/json;odata=nometadata'
|
|
115
|
+
},
|
|
116
|
+
responseType: 'json'
|
|
117
|
+
};
|
|
118
|
+
const response = yield request_1.default.get(requestOptions);
|
|
119
|
+
for (const folder of response.value) {
|
|
120
|
+
allFolders.push(folder.ServerRelativeUrl);
|
|
121
|
+
const subfolders = yield this.getFolders(folder.ServerRelativeUrl, args, logger);
|
|
122
|
+
subfolders.forEach(folder => allFolders.push(folder));
|
|
123
|
+
}
|
|
124
|
+
if (response.value.length === SpoFileListCommand.pageSize) {
|
|
125
|
+
const folders = yield this.getFolders(folderUrl, args, logger, skip + SpoFileListCommand.pageSize);
|
|
126
|
+
folders.forEach(folder => allFolders.push(folder));
|
|
127
|
+
}
|
|
128
|
+
return allFolders;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
formatSelectProperties(fields, output) {
|
|
132
|
+
let selectProperties = [];
|
|
133
|
+
const expandProperties = [];
|
|
134
|
+
if (output === 'text' && !fields) {
|
|
135
|
+
selectProperties = ['UniqueId', 'Name', 'ServerRelativeUrl'];
|
|
136
|
+
}
|
|
137
|
+
if (fields) {
|
|
138
|
+
fields.split(',').forEach((field) => {
|
|
139
|
+
const subparts = field.trim().split('/');
|
|
140
|
+
if (subparts.length > 1) {
|
|
141
|
+
expandProperties.push(subparts[0]);
|
|
142
|
+
}
|
|
143
|
+
selectProperties.push(field.trim());
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
selectProperties: [...new Set(selectProperties)],
|
|
148
|
+
expandProperties: [...new Set(expandProperties)]
|
|
149
|
+
};
|
|
81
150
|
}
|
|
82
151
|
}
|
|
83
152
|
_SpoFileListCommand_instances = new WeakSet(), _SpoFileListCommand_initTelemetry = function _SpoFileListCommand_initTelemetry() {
|
|
84
153
|
this.telemetry.push((args) => {
|
|
85
154
|
Object.assign(this.telemetryProperties, {
|
|
86
|
-
recursive: args.options.recursive
|
|
155
|
+
recursive: args.options.recursive,
|
|
156
|
+
fields: typeof args.options.fields !== 'undefined',
|
|
157
|
+
filter: typeof args.options.filter !== 'undefined'
|
|
87
158
|
});
|
|
88
159
|
});
|
|
89
160
|
}, _SpoFileListCommand_initOptions = function _SpoFileListCommand_initOptions() {
|
|
@@ -91,11 +162,16 @@ _SpoFileListCommand_instances = new WeakSet(), _SpoFileListCommand_initTelemetry
|
|
|
91
162
|
option: '-u, --webUrl <webUrl>'
|
|
92
163
|
}, {
|
|
93
164
|
option: '-f, --folder <folder>'
|
|
165
|
+
}, {
|
|
166
|
+
option: '--fields [fields]'
|
|
167
|
+
}, {
|
|
168
|
+
option: '--filter [filter]'
|
|
94
169
|
}, {
|
|
95
170
|
option: '-r, --recursive'
|
|
96
171
|
});
|
|
97
172
|
}, _SpoFileListCommand_initValidators = function _SpoFileListCommand_initValidators() {
|
|
98
173
|
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () { return validation_1.validation.isValidSharePointUrl(args.options.webUrl); }));
|
|
99
174
|
};
|
|
175
|
+
SpoFileListCommand.pageSize = 5000;
|
|
100
176
|
module.exports = new SpoFileListCommand();
|
|
101
177
|
//# sourceMappingURL=file-list.js.map
|
|
@@ -15,8 +15,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
15
15
|
};
|
|
16
16
|
var _SpoFolderListCommand_instances, _SpoFolderListCommand_initTelemetry, _SpoFolderListCommand_initOptions, _SpoFolderListCommand_initValidators;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const request_1 = require("../../../../request");
|
|
18
19
|
const formatting_1 = require("../../../../utils/formatting");
|
|
19
|
-
const odata_1 = require("../../../../utils/odata");
|
|
20
20
|
const urlUtil_1 = require("../../../../utils/urlUtil");
|
|
21
21
|
const validation_1 = require("../../../../utils/validation");
|
|
22
22
|
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
@@ -41,37 +41,89 @@ class SpoFolderListCommand extends SpoCommand_1.default {
|
|
|
41
41
|
commandAction(logger, args) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
43
|
if (this.verbose) {
|
|
44
|
-
logger.logToStderr(`Retrieving folders
|
|
44
|
+
logger.logToStderr(`Retrieving all folders in folder '${args.options.parentFolderUrl}' at site '${args.options.webUrl}'${args.options.recursive ? ' (recursive)' : ''}...`);
|
|
45
45
|
}
|
|
46
46
|
try {
|
|
47
|
-
const
|
|
48
|
-
|
|
47
|
+
const fieldProperties = this.formatSelectProperties(args.options.fields);
|
|
48
|
+
const allFiles = yield this.getFolders(args.options.parentFolderUrl, fieldProperties, args, logger);
|
|
49
|
+
// Clean ListItemAllFields.ID property from the output if included
|
|
50
|
+
// Reason: It causes a casing conflict with 'Id' when parsing JSON in PowerShell
|
|
51
|
+
if (fieldProperties.selectProperties.some(p => p.toLowerCase().indexOf('listitemallfields') > -1)) {
|
|
52
|
+
allFiles.filter(folder => { var _a; return ((_a = folder.ListItemAllFields) === null || _a === void 0 ? void 0 : _a.ID) !== undefined; }).forEach(folder => delete folder.ListItemAllFields['ID']);
|
|
53
|
+
}
|
|
54
|
+
logger.log(allFiles);
|
|
49
55
|
}
|
|
50
56
|
catch (err) {
|
|
51
57
|
this.handleRejectedODataJsonPromise(err);
|
|
52
58
|
}
|
|
53
59
|
});
|
|
54
60
|
}
|
|
55
|
-
|
|
61
|
+
getFolders(parentFolderUrl, fieldProperties, args, logger, skip = 0) {
|
|
56
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
if (this.verbose) {
|
|
64
|
+
const page = Math.ceil(skip / SpoFolderListCommand.pageSize) + 1;
|
|
65
|
+
logger.logToStderr(`Retrieving folders in folder '${parentFolderUrl}'${page > 1 ? ', page ' + page : ''}...`);
|
|
66
|
+
}
|
|
67
|
+
const allFolders = [];
|
|
68
|
+
const serverRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, parentFolderUrl);
|
|
69
|
+
const requestUrl = `${args.options.webUrl}/_api/web/GetFolderByServerRelativeUrl(@url)/Folders?@url='${formatting_1.formatting.encodeQueryParameter(serverRelativeUrl)}'`;
|
|
70
|
+
const queryParams = [`$skip=${skip}`, `$top=${SpoFolderListCommand.pageSize}`];
|
|
71
|
+
if (fieldProperties.expandProperties.length > 0) {
|
|
72
|
+
queryParams.push(`$expand=${fieldProperties.expandProperties.join(',')}`);
|
|
73
|
+
}
|
|
74
|
+
if (fieldProperties.selectProperties.length > 0) {
|
|
75
|
+
queryParams.push(`$select=${fieldProperties.selectProperties.join(',')}`);
|
|
76
|
+
}
|
|
77
|
+
if (args.options.filter) {
|
|
78
|
+
queryParams.push(`$filter=${args.options.filter}`);
|
|
79
|
+
}
|
|
80
|
+
const requestOptions = {
|
|
81
|
+
url: `${requestUrl}&${queryParams.join('&')}`,
|
|
82
|
+
method: 'GET',
|
|
83
|
+
headers: {
|
|
84
|
+
'accept': 'application/json;odata=nometadata'
|
|
85
|
+
},
|
|
86
|
+
responseType: 'json'
|
|
87
|
+
};
|
|
88
|
+
const response = yield request_1.default.get(requestOptions);
|
|
89
|
+
for (const folder of response.value) {
|
|
90
|
+
allFolders.push(folder);
|
|
91
|
+
if (args.options.recursive) {
|
|
92
|
+
const subFolders = yield this.getFolders(folder.ServerRelativeUrl, fieldProperties, args, logger);
|
|
93
|
+
subFolders.forEach(subFolder => allFolders.push(subFolder));
|
|
65
94
|
}
|
|
66
95
|
}
|
|
67
|
-
|
|
96
|
+
if (response.value.length === SpoFolderListCommand.pageSize) {
|
|
97
|
+
const folders = yield this.getFolders(parentFolderUrl, fieldProperties, args, logger, skip + SpoFolderListCommand.pageSize);
|
|
98
|
+
folders.forEach(folder => allFolders.push(folder));
|
|
99
|
+
}
|
|
100
|
+
return allFolders;
|
|
68
101
|
});
|
|
69
102
|
}
|
|
103
|
+
formatSelectProperties(fields) {
|
|
104
|
+
const selectProperties = [];
|
|
105
|
+
const expandProperties = [];
|
|
106
|
+
if (fields) {
|
|
107
|
+
fields.split(',').forEach((field) => {
|
|
108
|
+
const subparts = field.trim().split('/');
|
|
109
|
+
if (subparts.length > 1) {
|
|
110
|
+
expandProperties.push(subparts[0]);
|
|
111
|
+
}
|
|
112
|
+
selectProperties.push(field.trim());
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
selectProperties: [...new Set(selectProperties)],
|
|
117
|
+
expandProperties: [...new Set(expandProperties)]
|
|
118
|
+
};
|
|
119
|
+
}
|
|
70
120
|
}
|
|
71
121
|
_SpoFolderListCommand_instances = new WeakSet(), _SpoFolderListCommand_initTelemetry = function _SpoFolderListCommand_initTelemetry() {
|
|
72
122
|
this.telemetry.push((args) => {
|
|
73
123
|
Object.assign(this.telemetryProperties, {
|
|
74
|
-
recursive: !!args.options.recursive
|
|
124
|
+
recursive: !!args.options.recursive,
|
|
125
|
+
fields: typeof args.options.fields !== 'undefined',
|
|
126
|
+
filter: typeof args.options.filter !== 'undefined'
|
|
75
127
|
});
|
|
76
128
|
});
|
|
77
129
|
}, _SpoFolderListCommand_initOptions = function _SpoFolderListCommand_initOptions() {
|
|
@@ -80,10 +132,15 @@ _SpoFolderListCommand_instances = new WeakSet(), _SpoFolderListCommand_initTelem
|
|
|
80
132
|
}, {
|
|
81
133
|
option: '-p, --parentFolderUrl <parentFolderUrl>'
|
|
82
134
|
}, {
|
|
83
|
-
option: '--
|
|
135
|
+
option: '-f, --fields [fields]'
|
|
136
|
+
}, {
|
|
137
|
+
option: '--filter [filter]'
|
|
138
|
+
}, {
|
|
139
|
+
option: '-r, --recursive [recursive]'
|
|
84
140
|
});
|
|
85
141
|
}, _SpoFolderListCommand_initValidators = function _SpoFolderListCommand_initValidators() {
|
|
86
142
|
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () { return validation_1.validation.isValidSharePointUrl(args.options.webUrl); }));
|
|
87
143
|
};
|
|
144
|
+
SpoFolderListCommand.pageSize = 5000;
|
|
88
145
|
module.exports = new SpoFolderListCommand();
|
|
89
146
|
//# sourceMappingURL=folder-list.js.map
|