@pnp/cli-microsoft365 5.0.0-beta.fa7a63b → 5.0.0
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 +2 -2
- package/.devcontainer/devcontainer.json +13 -2
- package/.eslintrc.js +3 -0
- package/.mocharc.json +9 -0
- package/README.md +3 -3
- package/dist/Auth.js +22 -9
- package/dist/Command.js +1 -1
- package/dist/Utils.js +7 -0
- package/dist/api.d.ts +13 -0
- package/dist/api.js +17 -0
- package/dist/appInsights.js +5 -2
- package/dist/cli/Cli.js +42 -7
- package/dist/m365/aad/commands/app/app-add.js +101 -12
- package/dist/m365/aad/commands/app/app-delete.js +123 -0
- package/dist/m365/aad/commands/app/app-get.js +142 -0
- package/dist/m365/aad/commands/app/app-set.js +98 -3
- package/dist/m365/aad/commands/group/group-list.js +54 -0
- package/dist/m365/aad/commands/o365group/{GroupUser.js → GroupExtended.js} +1 -1
- package/dist/m365/aad/commands/o365group/o365group-add.js +56 -50
- package/dist/m365/aad/commands/o365group/o365group-conversation-list.js +41 -0
- package/dist/m365/aad/commands/o365group/o365group-user-set.js +3 -3
- package/dist/m365/aad/commands/oauth2grant/oauth2grant-list.js +4 -4
- package/dist/m365/aad/commands/oauth2grant/oauth2grant-remove.js +36 -12
- package/dist/m365/aad/commands/sp/sp-add.js +107 -0
- package/dist/m365/aad/commands/user/user-get.js +33 -6
- package/dist/m365/aad/commands/user/user-hibp.js +67 -0
- package/dist/m365/aad/commands/user/user-list.js +7 -4
- package/dist/m365/aad/commands/user/user-password-validate.js +42 -0
- package/dist/m365/aad/commands.js +7 -0
- package/dist/m365/app/commands/permission/permission-list.js +266 -0
- package/dist/m365/app/commands.js +7 -0
- package/dist/m365/base/AppCommand.js +76 -0
- package/dist/m365/{aad/commands/o365group/Group.js → base/M365RcJson.js} +1 -1
- package/dist/m365/cli/commands/cli-doctor.js +2 -0
- package/dist/m365/cli/commands/config/config-set.js +5 -1
- package/dist/m365/file/commands/file-add.js +32 -13
- package/dist/m365/file/commands/file-list.js +181 -0
- package/dist/m365/file/commands.js +2 -1
- package/dist/m365/flow/commands/flow-get.js +2 -2
- package/dist/m365/outlook/commands/room/room-list.js +43 -0
- package/dist/m365/outlook/commands/roomlist/roomlist-list.js +25 -0
- package/dist/m365/outlook/commands.js +2 -0
- package/dist/m365/pa/cds-project-mutator.js +1 -1
- package/dist/m365/pa/commands/app/app-list.js +28 -1
- package/dist/m365/planner/AppliedCategories.js +3 -0
- package/dist/m365/planner/commands/task/task-add.js +288 -0
- package/dist/m365/planner/commands/task/task-details-get.js +39 -0
- package/dist/m365/planner/commands/task/task-get.js +37 -0
- package/dist/m365/planner/commands/task/task-list.js +37 -7
- package/dist/m365/planner/commands/task/task-set.js +357 -0
- package/dist/m365/planner/commands.js +5 -1
- package/dist/m365/search/commands/externalconnection/externalconnection-add.js +99 -0
- package/dist/m365/search/commands.js +7 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN006005_CFG_PS_metadata.js +63 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN006006_CFG_PS_features.js +60 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN014008_CODE_launch_hostedWorkbench_type.js +62 -0
- package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.13.1.js +53 -0
- package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.14.0.js +59 -0
- package/dist/m365/spfx/commands/project/project-upgrade.js +3 -1
- package/dist/m365/spfx/commands/spfx-doctor.js +197 -64
- package/dist/m365/spo/commands/contenttype/contenttype-list.js +52 -0
- package/dist/m365/spo/commands/group/group-user-add.js +74 -16
- package/dist/m365/spo/commands/group/group-user-remove.js +100 -0
- package/dist/m365/spo/commands/list/list-get.js +6 -2
- package/dist/m365/spo/commands/page/Page.js +3 -1
- package/dist/m365/spo/commands/page/page-add.js +7 -10
- package/dist/m365/spo/commands/page/page-set.js +7 -10
- package/dist/m365/spo/commands/site/site-ensure.js +1 -1
- package/dist/m365/spo/commands/site/site-recyclebinitem-list.js +76 -0
- package/dist/m365/spo/commands/site/site-remove.js +98 -30
- package/dist/m365/spo/commands/web/web-installedlanguage-list.js +48 -0
- package/dist/m365/spo/commands.js +5 -1
- package/dist/m365/teams/commands/app/app-install.js +75 -21
- package/dist/m365/teams/commands/app/app-list.js +9 -6
- package/dist/m365/teams/commands/app/app-update.js +54 -12
- package/dist/m365/teams/commands/channel/channel-get.js +29 -7
- package/dist/m365/teams/commands/chat/chat-list.js +43 -0
- package/dist/m365/teams/commands/chat/chat-member-list.js +42 -0
- package/dist/m365/teams/commands/chat/chat-message-list.js +60 -0
- package/dist/m365/teams/commands/chat/chat-message-send.js +225 -0
- package/dist/m365/teams/commands/message/message-get.js +1 -1
- package/dist/m365/teams/commands/report/report-directroutingcalls.js +1 -1
- package/dist/m365/teams/commands/tab/tab-get.js +9 -6
- package/dist/m365/teams/commands.js +4 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-health-get.js +57 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-health-list.js +56 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-healthissue-get.js +39 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-healthissue-list.js +38 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-message-get.js +51 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-message-list.js +38 -0
- package/dist/m365/tenant/commands.js +6 -0
- package/dist/request.js +9 -4
- package/dist/settingsNames.js +6 -0
- package/docs/docs/cmd/_global.md +2 -2
- package/docs/docs/cmd/aad/app/app-add.md +11 -0
- package/docs/docs/cmd/aad/app/app-delete.md +51 -0
- package/docs/docs/cmd/aad/app/app-get.md +59 -0
- package/docs/docs/cmd/aad/app/app-set.md +21 -0
- package/docs/docs/cmd/aad/group/group-list.md +30 -0
- package/docs/docs/cmd/aad/o365group/o365group-add.md +1 -0
- package/docs/docs/cmd/aad/o365group/o365group-conversation-list.md +24 -0
- package/docs/docs/cmd/aad/oauth2grant/oauth2grant-list.md +2 -2
- package/docs/docs/cmd/aad/oauth2grant/oauth2grant-remove.md +9 -0
- package/docs/docs/cmd/aad/sp/sp-add.md +53 -0
- package/docs/docs/cmd/aad/user/user-get.md +13 -4
- package/docs/docs/cmd/aad/user/user-hibp.md +46 -0
- package/docs/docs/cmd/aad/user/user-list.md +9 -0
- package/docs/docs/cmd/aad/user/user-password-validate.md +29 -0
- package/docs/docs/cmd/app/permission/permission-list.md +36 -0
- package/docs/docs/cmd/file/file-add.md +11 -0
- package/docs/docs/cmd/file/file-list.md +46 -0
- package/docs/docs/cmd/outlook/room/room-list.md +30 -0
- package/docs/docs/cmd/outlook/roomlist/roomlist-list.md +21 -0
- package/docs/docs/cmd/pa/app/app-list.md +17 -1
- package/docs/docs/cmd/planner/task/task-add.md +78 -0
- package/docs/docs/cmd/planner/task/task-details-get.md +24 -0
- package/docs/docs/cmd/planner/task/task-get.md +29 -0
- package/docs/docs/cmd/planner/task/task-list.md +5 -0
- package/docs/docs/cmd/planner/task/task-set.md +99 -0
- package/docs/docs/cmd/search/externalconnection/externalconnection-add.md +43 -0
- package/docs/docs/cmd/spfx/project/project-externalize.md +1 -1
- package/docs/docs/cmd/spfx/project/project-rename.md +1 -1
- package/docs/docs/cmd/spfx/project/project-upgrade.md +8 -8
- package/docs/docs/cmd/spfx/spfx-doctor.md +1 -1
- package/docs/docs/cmd/spo/contenttype/contenttype-list.md +33 -0
- package/docs/docs/cmd/spo/group/group-user-add.md +28 -6
- package/docs/docs/cmd/spo/group/group-user-remove.md +39 -0
- package/docs/docs/cmd/spo/list/list-get.md +9 -0
- package/docs/docs/cmd/spo/page/page-add.md +2 -2
- package/docs/docs/cmd/spo/page/page-set.md +3 -3
- package/docs/docs/cmd/spo/site/site-recyclebinitem-list.md +40 -0
- package/docs/docs/cmd/spo/site/site-remove.md +3 -1
- package/docs/docs/cmd/spo/web/web-installedlanguage-list.md +24 -0
- package/docs/docs/cmd/teams/app/app-install.md +22 -4
- package/docs/docs/cmd/teams/app/app-update.md +12 -3
- package/docs/docs/cmd/teams/channel/channel-get.md +11 -2
- package/docs/docs/cmd/teams/chat/chat-list.md +30 -0
- package/docs/docs/cmd/teams/chat/chat-member-list.md +24 -0
- package/docs/docs/cmd/teams/chat/chat-message-list.md +24 -0
- package/docs/docs/cmd/teams/chat/chat-message-send.md +55 -0
- package/docs/docs/cmd/teams/message/message-get.md +0 -3
- package/docs/docs/cmd/teams/report/report-directroutingcalls.md +0 -3
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-get.md +33 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-list.md +30 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-get.md +24 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-list.md +34 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-get.md +28 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-list.md +34 -0
- package/npm-shrinkwrap.json +1740 -2288
- package/package.json +47 -34
- package/dist/m365/base/AadCommand.js +0 -10
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const cli_1 = require("../../cli");
|
|
5
|
+
const Command_1 = require("../../Command");
|
|
6
|
+
const Utils_1 = require("../../Utils");
|
|
7
|
+
class AppCommand extends Command_1.default {
|
|
8
|
+
get resource() {
|
|
9
|
+
return 'https://graph.microsoft.com';
|
|
10
|
+
}
|
|
11
|
+
action(logger, args, cb) {
|
|
12
|
+
const m365rcJsonPath = '.m365rc.json';
|
|
13
|
+
if (!fs.existsSync(m365rcJsonPath)) {
|
|
14
|
+
return cb(new Command_1.CommandError(`Could not find file: ${m365rcJsonPath}`));
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const m365rcJsonContents = fs.readFileSync(m365rcJsonPath, 'utf8');
|
|
18
|
+
if (!m365rcJsonContents) {
|
|
19
|
+
return cb(new Command_1.CommandError(`File ${m365rcJsonPath} is empty`));
|
|
20
|
+
}
|
|
21
|
+
this.m365rcJson = JSON.parse(m365rcJsonContents);
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
return cb(new Command_1.CommandError(`Could not parse file: ${m365rcJsonPath}`));
|
|
25
|
+
}
|
|
26
|
+
if (!this.m365rcJson.apps ||
|
|
27
|
+
this.m365rcJson.apps.length === 0) {
|
|
28
|
+
return cb(new Command_1.CommandError(`No Azure AD apps found in ${m365rcJsonPath}`));
|
|
29
|
+
}
|
|
30
|
+
if (args.options.appId) {
|
|
31
|
+
if (!this.m365rcJson.apps.some(app => app.appId === args.options.appId)) {
|
|
32
|
+
return cb(new Command_1.CommandError(`App ${args.options.appId} not found in ${m365rcJsonPath}`));
|
|
33
|
+
}
|
|
34
|
+
this.appId = args.options.appId;
|
|
35
|
+
return super.action(logger, args, cb);
|
|
36
|
+
}
|
|
37
|
+
if (this.m365rcJson.apps.length === 1) {
|
|
38
|
+
this.appId = this.m365rcJson.apps[0].appId;
|
|
39
|
+
return super.action(logger, args, cb);
|
|
40
|
+
}
|
|
41
|
+
if (this.m365rcJson.apps.length > 1) {
|
|
42
|
+
cli_1.Cli.prompt({
|
|
43
|
+
message: `Multiple Azure AD apps found in ${m365rcJsonPath}. Which app would you like to use?`,
|
|
44
|
+
type: 'list',
|
|
45
|
+
choices: this.m365rcJson.apps.map((app, i) => {
|
|
46
|
+
return {
|
|
47
|
+
name: `${app.name} (${app.appId})`,
|
|
48
|
+
value: i
|
|
49
|
+
};
|
|
50
|
+
}),
|
|
51
|
+
default: 0,
|
|
52
|
+
name: 'appIdIndex'
|
|
53
|
+
}, (result) => {
|
|
54
|
+
this.appId = this.m365rcJson.apps[result.appIdIndex].appId;
|
|
55
|
+
super.action(logger, args, cb);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
options() {
|
|
60
|
+
const options = [
|
|
61
|
+
{
|
|
62
|
+
option: '--appId [appId]'
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
const parentOptions = super.options();
|
|
66
|
+
return options.concat(parentOptions);
|
|
67
|
+
}
|
|
68
|
+
validate(args) {
|
|
69
|
+
if (args.options.appId && !Utils_1.default.isValidGuid(args.options.appId)) {
|
|
70
|
+
return `${args.options.appId} is not a valid GUID`;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.default = AppCommand;
|
|
76
|
+
//# sourceMappingURL=AppCommand.js.map
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const os = require("os");
|
|
4
4
|
const Auth_1 = require("../../../Auth");
|
|
5
|
+
const cli_1 = require("../../../cli");
|
|
5
6
|
const Command_1 = require("../../../Command");
|
|
6
7
|
const Utils_1 = require("../../../Utils");
|
|
7
8
|
const commands_1 = require("../commands");
|
|
@@ -33,6 +34,7 @@ class CliDoctorCommand extends Command_1.default {
|
|
|
33
34
|
cliAadAppTenant: Utils_1.default.isValidGuid(Auth_1.default.service.tenant) ? 'single' : Auth_1.default.service.tenant,
|
|
34
35
|
authMode: Auth_1.AuthType[Auth_1.default.service.authType],
|
|
35
36
|
cliEnvironment: process.env.CLIMICROSOFT365_ENV ? process.env.CLIMICROSOFT365_ENV : '',
|
|
37
|
+
cliConfig: cli_1.Cli.getInstance().config.all,
|
|
36
38
|
roles: roles,
|
|
37
39
|
scopes: scopes
|
|
38
40
|
};
|
|
@@ -19,8 +19,12 @@ class CliConfigSetCommand extends AnonymousCommand_1.default {
|
|
|
19
19
|
commandAction(logger, args, cb) {
|
|
20
20
|
let value = undefined;
|
|
21
21
|
switch (args.options.key) {
|
|
22
|
+
case settingsNames_1.settingsNames.autoOpenBrowserOnLogin:
|
|
22
23
|
case settingsNames_1.settingsNames.showHelpOnFailure:
|
|
23
24
|
case settingsNames_1.settingsNames.printErrorsAsPlainText:
|
|
25
|
+
case settingsNames_1.settingsNames.csvHeader:
|
|
26
|
+
case settingsNames_1.settingsNames.csvQuoted:
|
|
27
|
+
case settingsNames_1.settingsNames.csvQuotedEmpty:
|
|
24
28
|
value = args.options.value === 'true';
|
|
25
29
|
break;
|
|
26
30
|
default:
|
|
@@ -47,7 +51,7 @@ class CliConfigSetCommand extends AnonymousCommand_1.default {
|
|
|
47
51
|
if (CliConfigSetCommand.optionNames.indexOf(args.options.key) < 0) {
|
|
48
52
|
return `${args.options.key} is not a valid setting. Allowed values: ${CliConfigSetCommand.optionNames.join(', ')}`;
|
|
49
53
|
}
|
|
50
|
-
const allowedOutputs = ['text', 'json'];
|
|
54
|
+
const allowedOutputs = ['text', 'json', 'csv'];
|
|
51
55
|
if (args.options.key === settingsNames_1.settingsNames.output &&
|
|
52
56
|
allowedOutputs.indexOf(args.options.value) === -1) {
|
|
53
57
|
return `${args.options.value} is not a valid value for the option ${args.options.key}. Allowed values: ${allowedOutputs.join(', ')}`;
|
|
@@ -20,7 +20,7 @@ class FileAddCommand extends GraphCommand_1.default {
|
|
|
20
20
|
folderUrlWithoutTrailingSlash = folderUrlWithoutTrailingSlash.substr(0, folderUrlWithoutTrailingSlash.length - 1);
|
|
21
21
|
}
|
|
22
22
|
this
|
|
23
|
-
.getGraphFileUrl(logger, `${folderUrlWithoutTrailingSlash}/${path.basename(args.options.filePath)}
|
|
23
|
+
.getGraphFileUrl(logger, `${folderUrlWithoutTrailingSlash}/${path.basename(args.options.filePath)}`, args.options.siteUrl)
|
|
24
24
|
.then(graphFileUrl => this.uploadFile(args.options.filePath, graphFileUrl))
|
|
25
25
|
.then(_ => cb(), rawRes => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
|
|
26
26
|
}
|
|
@@ -80,20 +80,23 @@ class FileAddCommand extends GraphCommand_1.default {
|
|
|
80
80
|
*
|
|
81
81
|
* @param logger Logger instance
|
|
82
82
|
* @param fileWebUrl Web URL of the file for which to get drive item URL
|
|
83
|
+
* @param siteUrl URL of the site to which upload the file. Optional. Specify to suppress lookup.
|
|
83
84
|
* @returns Graph's drive item URL for the specified file
|
|
84
85
|
*/
|
|
85
|
-
getGraphFileUrl(logger, fileWebUrl) {
|
|
86
|
+
getGraphFileUrl(logger, fileWebUrl, siteUrl) {
|
|
86
87
|
if (this.debug) {
|
|
87
88
|
logger.logToStderr(`Resolving Graph drive item URL for ${fileWebUrl}`);
|
|
88
89
|
}
|
|
89
|
-
const
|
|
90
|
+
const _fileWebUrl = url.parse(fileWebUrl);
|
|
91
|
+
const _siteUrl = url.parse(siteUrl || fileWebUrl);
|
|
92
|
+
const isSiteUrl = typeof siteUrl !== 'undefined';
|
|
90
93
|
let siteId = '';
|
|
91
94
|
let driveRelativeFileUrl = '';
|
|
92
95
|
return this
|
|
93
|
-
.getGraphSiteInfoFromFullUrl(
|
|
96
|
+
.getGraphSiteInfoFromFullUrl(_siteUrl.host, _siteUrl.path, isSiteUrl)
|
|
94
97
|
.then(siteInfo => {
|
|
95
98
|
siteId = siteInfo.id;
|
|
96
|
-
let siteRelativeFileUrl =
|
|
99
|
+
let siteRelativeFileUrl = _fileWebUrl.path.replace(siteInfo.serverRelativeUrl, '');
|
|
97
100
|
// normalize site-relative URLs for root site collections and root sites
|
|
98
101
|
if (!siteRelativeFileUrl.startsWith('/')) {
|
|
99
102
|
siteRelativeFileUrl = '/' + siteRelativeFileUrl;
|
|
@@ -116,13 +119,14 @@ class FileAddCommand extends GraphCommand_1.default {
|
|
|
116
119
|
* Automatically detects which path chunks correspond to (sub)site.
|
|
117
120
|
* @param hostName SharePoint host name, eg. contoso.sharepoint.com
|
|
118
121
|
* @param urlPath Server-relative file URL, eg. /sites/site/docs/file1.aspx
|
|
122
|
+
* @param isSiteUrl Set to true to indicate that the specified URL is a site URL
|
|
119
123
|
* @returns ID and server-relative URL of the site denoted by urlPath
|
|
120
124
|
*/
|
|
121
|
-
getGraphSiteInfoFromFullUrl(hostName, urlPath) {
|
|
125
|
+
getGraphSiteInfoFromFullUrl(hostName, urlPath, isSiteUrl) {
|
|
122
126
|
const siteId = '';
|
|
123
127
|
const urlChunks = urlPath.split('/');
|
|
124
128
|
return new Promise((resolve, reject) => {
|
|
125
|
-
this.getGraphSiteInfo(hostName, urlChunks, 0, siteId, resolve, reject);
|
|
129
|
+
this.getGraphSiteInfo(hostName, urlChunks, isSiteUrl ? urlChunks.length - 1 : 0, siteId, resolve, reject);
|
|
126
130
|
});
|
|
127
131
|
}
|
|
128
132
|
/**
|
|
@@ -156,20 +160,28 @@ class FileAddCommand extends GraphCommand_1.default {
|
|
|
156
160
|
},
|
|
157
161
|
responseType: 'json'
|
|
158
162
|
};
|
|
163
|
+
const getResult = (id, serverRelativeUrl) => {
|
|
164
|
+
return {
|
|
165
|
+
id,
|
|
166
|
+
serverRelativeUrl
|
|
167
|
+
};
|
|
168
|
+
};
|
|
159
169
|
request_1.default
|
|
160
170
|
.get(requestOptions)
|
|
161
171
|
.then((res) => {
|
|
162
|
-
|
|
172
|
+
if (currentChunk === urlChunks.length - 1) {
|
|
173
|
+
resolve(getResult(res.id, currentPath));
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
this.getGraphSiteInfo(hostName, urlChunks, ++currentChunk, res.id, resolve, reject);
|
|
177
|
+
}
|
|
163
178
|
}, err => {
|
|
164
179
|
if (lastSiteId) {
|
|
165
180
|
let serverRelativeUrl = `${urlChunks.slice(0, currentChunk).join('/')}`;
|
|
166
181
|
if (!serverRelativeUrl.startsWith('/')) {
|
|
167
182
|
serverRelativeUrl = '/' + serverRelativeUrl;
|
|
168
183
|
}
|
|
169
|
-
resolve(
|
|
170
|
-
id: lastSiteId,
|
|
171
|
-
serverRelativeUrl: serverRelativeUrl
|
|
172
|
-
});
|
|
184
|
+
resolve(getResult(lastSiteId, serverRelativeUrl));
|
|
173
185
|
}
|
|
174
186
|
else {
|
|
175
187
|
reject(err);
|
|
@@ -206,7 +218,8 @@ class FileAddCommand extends GraphCommand_1.default {
|
|
|
206
218
|
options() {
|
|
207
219
|
const options = [
|
|
208
220
|
{ option: '-u, --folderUrl <folderUrl>' },
|
|
209
|
-
{ option: '-p, --filePath <filePath>' }
|
|
221
|
+
{ option: '-p, --filePath <filePath>' },
|
|
222
|
+
{ option: '--siteUrl [siteUrl]' }
|
|
210
223
|
];
|
|
211
224
|
const parentOptions = super.options();
|
|
212
225
|
return options.concat(parentOptions);
|
|
@@ -215,6 +228,12 @@ class FileAddCommand extends GraphCommand_1.default {
|
|
|
215
228
|
if (!fs.existsSync(args.options.filePath)) {
|
|
216
229
|
return `Specified source file ${args.options.sourceFile} doesn't exist`;
|
|
217
230
|
}
|
|
231
|
+
if (args.options.siteUrl) {
|
|
232
|
+
const isValidSiteUrl = SpoCommand_1.default.isValidSharePointUrl(args.options.siteUrl);
|
|
233
|
+
if (isValidSiteUrl !== true) {
|
|
234
|
+
return isValidSiteUrl;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
218
237
|
return SpoCommand_1.default.isValidSharePointUrl(args.options.folderUrl);
|
|
219
238
|
}
|
|
220
239
|
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const request_1 = require("../../../request");
|
|
4
|
+
const GraphItemsListCommand_1 = require("../../base/GraphItemsListCommand");
|
|
5
|
+
const SpoCommand_1 = require("../../base/SpoCommand");
|
|
6
|
+
const commands_1 = require("../commands");
|
|
7
|
+
class FileListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.foldersToGetFilesFrom = [];
|
|
11
|
+
}
|
|
12
|
+
get name() {
|
|
13
|
+
return commands_1.default.LIST;
|
|
14
|
+
}
|
|
15
|
+
get description() {
|
|
16
|
+
return 'Retrieves files from the specified folder and site';
|
|
17
|
+
}
|
|
18
|
+
defaultProperties() {
|
|
19
|
+
return ['name', 'lastModifiedByUser'];
|
|
20
|
+
}
|
|
21
|
+
commandAction(logger, args, cb) {
|
|
22
|
+
let webUrl = args.options.webUrl;
|
|
23
|
+
if (!webUrl.endsWith('/')) {
|
|
24
|
+
webUrl += '/';
|
|
25
|
+
}
|
|
26
|
+
const folderUrl = new URL(args.options.folderUrl, webUrl);
|
|
27
|
+
let driveId = '';
|
|
28
|
+
this
|
|
29
|
+
.getSiteId(args.options.webUrl, logger)
|
|
30
|
+
.then((siteId) => this.getDocumentLibrary(siteId, folderUrl, args.options.folderUrl, logger))
|
|
31
|
+
.then((drive) => {
|
|
32
|
+
driveId = drive.id;
|
|
33
|
+
return this.getStartingFolderId(drive, folderUrl, logger);
|
|
34
|
+
})
|
|
35
|
+
.then((folderId) => {
|
|
36
|
+
if (this.verbose) {
|
|
37
|
+
logger.logToStderr(`Loading folders to get files from...`);
|
|
38
|
+
}
|
|
39
|
+
// add the starting folder to the list of folders to get files from
|
|
40
|
+
this.foldersToGetFilesFrom.push(folderId);
|
|
41
|
+
return this.loadFoldersToGetFilesFrom(folderId, driveId, args.options.recursive);
|
|
42
|
+
})
|
|
43
|
+
.then(_ => {
|
|
44
|
+
if (this.debug) {
|
|
45
|
+
logger.logToStderr(`Folders to get files from: ${this.foldersToGetFilesFrom.join(', ')}`);
|
|
46
|
+
}
|
|
47
|
+
return this.loadFilesFromFolders(driveId, this.foldersToGetFilesFrom, logger);
|
|
48
|
+
})
|
|
49
|
+
.then(_ => {
|
|
50
|
+
logger.log(this.items);
|
|
51
|
+
cb();
|
|
52
|
+
}, err => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
53
|
+
}
|
|
54
|
+
getSiteId(webUrl, logger) {
|
|
55
|
+
if (this.verbose) {
|
|
56
|
+
logger.logToStderr(`Getting site id...`);
|
|
57
|
+
}
|
|
58
|
+
const url = new URL(webUrl);
|
|
59
|
+
const requestOptions = {
|
|
60
|
+
url: `${this.resource}/v1.0/sites/${encodeURIComponent(url.host)}:${url.pathname}?$select=id`,
|
|
61
|
+
headers: {
|
|
62
|
+
accept: 'application/json;odata.metadata=none'
|
|
63
|
+
},
|
|
64
|
+
responseType: 'json'
|
|
65
|
+
};
|
|
66
|
+
return request_1.default
|
|
67
|
+
.get(requestOptions)
|
|
68
|
+
.then((site) => {
|
|
69
|
+
if (this.verbose) {
|
|
70
|
+
logger.logToStderr(`Site id: ${site.id}`);
|
|
71
|
+
}
|
|
72
|
+
return site.id;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
getDocumentLibrary(siteId, folderUrl, folderUrlFromUser, logger) {
|
|
76
|
+
if (this.verbose) {
|
|
77
|
+
logger.logToStderr(`Getting document library...`);
|
|
78
|
+
}
|
|
79
|
+
const requestOptions = {
|
|
80
|
+
url: `${this.resource}/v1.0/sites/${siteId}/drives?$select=webUrl,id`,
|
|
81
|
+
headers: {
|
|
82
|
+
accept: 'application/json;odata.metadata=none'
|
|
83
|
+
},
|
|
84
|
+
responseType: 'json'
|
|
85
|
+
};
|
|
86
|
+
return request_1.default
|
|
87
|
+
.get(requestOptions)
|
|
88
|
+
.then((drives) => {
|
|
89
|
+
const lowerCaseFolderUrl = folderUrl.href.toLowerCase();
|
|
90
|
+
const drive = drives.value
|
|
91
|
+
.sort((a, b) => b.webUrl.localeCompare(a.webUrl))
|
|
92
|
+
.find((d) => {
|
|
93
|
+
const driveUrl = d.webUrl.toLowerCase();
|
|
94
|
+
// ensure that the drive url is a prefix of the folder url
|
|
95
|
+
return lowerCaseFolderUrl.startsWith(driveUrl) &&
|
|
96
|
+
(driveUrl.length === lowerCaseFolderUrl.length ||
|
|
97
|
+
lowerCaseFolderUrl[driveUrl.length] === '/');
|
|
98
|
+
});
|
|
99
|
+
if (!drive) {
|
|
100
|
+
return Promise.reject(`Document library '${folderUrlFromUser}' not found`);
|
|
101
|
+
}
|
|
102
|
+
if (this.verbose) {
|
|
103
|
+
logger.logToStderr(`Document library: ${drive.webUrl}, ${drive.id}`);
|
|
104
|
+
}
|
|
105
|
+
return Promise.resolve(drive);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
getStartingFolderId(documentLibrary, folderUrl, logger) {
|
|
109
|
+
if (this.verbose) {
|
|
110
|
+
logger.logToStderr(`Getting starting folder id...`);
|
|
111
|
+
}
|
|
112
|
+
const documentLibraryRelativeFolderUrl = folderUrl.href.replace(new RegExp(documentLibrary.webUrl, 'i'), '');
|
|
113
|
+
const requestOptions = {
|
|
114
|
+
url: `${this.resource}/v1.0/drives/${documentLibrary.id}/root${documentLibraryRelativeFolderUrl.length > 0 ? `:${documentLibraryRelativeFolderUrl}` : ''}?$select=id`,
|
|
115
|
+
headers: {
|
|
116
|
+
accept: 'application/json;odata.metadata=none'
|
|
117
|
+
},
|
|
118
|
+
responseType: 'json'
|
|
119
|
+
};
|
|
120
|
+
return request_1.default
|
|
121
|
+
.get(requestOptions)
|
|
122
|
+
.then((folder) => {
|
|
123
|
+
if (this.verbose) {
|
|
124
|
+
logger.logToStderr(`Starting folder id: ${folder.id}`);
|
|
125
|
+
}
|
|
126
|
+
return folder.id;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
loadFoldersToGetFilesFrom(folderId, driveId, recursive) {
|
|
130
|
+
if (!recursive) {
|
|
131
|
+
return Promise.resolve();
|
|
132
|
+
}
|
|
133
|
+
const requestOptions = {
|
|
134
|
+
url: `${this.resource}/v1.0/drives/${driveId}/items('${folderId}')/children?$filter=folder ne null&$select=id`,
|
|
135
|
+
headers: {
|
|
136
|
+
accept: 'application/json;odata.metadata=none'
|
|
137
|
+
},
|
|
138
|
+
responseType: 'json'
|
|
139
|
+
};
|
|
140
|
+
return request_1.default
|
|
141
|
+
.get(requestOptions)
|
|
142
|
+
.then((subfolders) => {
|
|
143
|
+
const subfolderIds = subfolders.value.map((subfolder) => subfolder.id);
|
|
144
|
+
this.foldersToGetFilesFrom = this.foldersToGetFilesFrom.concat(subfolderIds);
|
|
145
|
+
return Promise
|
|
146
|
+
.all(subfolderIds.map((subfolderId) => this.loadFoldersToGetFilesFrom(subfolderId, driveId, recursive)))
|
|
147
|
+
.then(_ => Promise.resolve());
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
loadFilesFromFolders(driveId, folderIds, logger) {
|
|
151
|
+
if (this.verbose) {
|
|
152
|
+
logger.logToStderr(`Loading files from folders...`);
|
|
153
|
+
}
|
|
154
|
+
this.items = [];
|
|
155
|
+
return Promise
|
|
156
|
+
.all(folderIds.map((folderId) =>
|
|
157
|
+
// get items from folder. Because we can't filter out folders here
|
|
158
|
+
// we need to get all items from the folder and filter them out later
|
|
159
|
+
this.getAllItems(`${this.resource}/v1.0/drives/${driveId}/items/${folderId}/children`, logger, false)))
|
|
160
|
+
.then(_ => {
|
|
161
|
+
// remove folders from the list of files
|
|
162
|
+
this.items = this.items.filter((item) => item.file);
|
|
163
|
+
this.items.forEach(file => { var _a, _b; return file.lastModifiedByUser = (_b = (_a = file.lastModifiedBy) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.displayName; });
|
|
164
|
+
return Promise.resolve();
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
options() {
|
|
168
|
+
const options = [
|
|
169
|
+
{ option: '-u, --webUrl <webUrl>' },
|
|
170
|
+
{ option: '-f, --folderUrl <folderUrl>' },
|
|
171
|
+
{ option: '--recursive' }
|
|
172
|
+
];
|
|
173
|
+
const parentOptions = super.options();
|
|
174
|
+
return options.concat(parentOptions);
|
|
175
|
+
}
|
|
176
|
+
validate(args) {
|
|
177
|
+
return SpoCommand_1.default.isValidSharePointUrl(args.options.webUrl);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
module.exports = new FileListCommand();
|
|
181
|
+
//# sourceMappingURL=file-list.js.map
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const prefix = 'file';
|
|
4
4
|
exports.default = {
|
|
5
5
|
ADD: `${prefix} add`,
|
|
6
|
-
CONVERT_PDF: `${prefix} convert pdf
|
|
6
|
+
CONVERT_PDF: `${prefix} convert pdf`,
|
|
7
|
+
LIST: `${prefix} list`
|
|
7
8
|
};
|
|
8
9
|
//# sourceMappingURL=commands.js.map
|
|
@@ -29,8 +29,8 @@ class FlowGetCommand extends AzmgmtCommand_1.default {
|
|
|
29
29
|
.then((res) => {
|
|
30
30
|
res.displayName = res.properties.displayName;
|
|
31
31
|
res.description = res.properties.definitionSummary.description || '';
|
|
32
|
-
res.triggers =
|
|
33
|
-
res.actions =
|
|
32
|
+
res.triggers = res.properties.definitionSummary.triggers.map((t) => (t.type + (t.kind ? "-" + t.kind : ''))).join(', ');
|
|
33
|
+
res.actions = res.properties.definitionSummary.actions.map((a) => (a.type + (a.swaggerOperationId ? "-" + a.swaggerOperationId : ''))).join(', ');
|
|
34
34
|
logger.log(res);
|
|
35
35
|
cb();
|
|
36
36
|
}, (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const GraphItemsListCommand_1 = require("../../../base/GraphItemsListCommand");
|
|
4
|
+
const commands_1 = require("../../commands");
|
|
5
|
+
class OutlookRoomListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
6
|
+
get name() {
|
|
7
|
+
return commands_1.default.ROOM_LIST;
|
|
8
|
+
}
|
|
9
|
+
get description() {
|
|
10
|
+
return 'Get a collection of all available rooms';
|
|
11
|
+
}
|
|
12
|
+
getTelemetryProperties(args) {
|
|
13
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
14
|
+
telemetryProps.roomlistEmail = typeof args.options.roomlistEmail !== 'undefined';
|
|
15
|
+
return telemetryProps;
|
|
16
|
+
}
|
|
17
|
+
defaultProperties() {
|
|
18
|
+
return ['id', 'displayName', 'phone', 'emailAddress'];
|
|
19
|
+
}
|
|
20
|
+
commandAction(logger, args, cb) {
|
|
21
|
+
let endpoint = `${this.resource}/v1.0/places/microsoft.graph.room`;
|
|
22
|
+
if (args.options.roomlistEmail) {
|
|
23
|
+
endpoint = `${this.resource}/v1.0/places/${args.options.roomlistEmail}/microsoft.graph.roomlist/rooms`;
|
|
24
|
+
}
|
|
25
|
+
this
|
|
26
|
+
.getAllItems(endpoint, logger, true)
|
|
27
|
+
.then(() => {
|
|
28
|
+
logger.log(this.items);
|
|
29
|
+
cb();
|
|
30
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
31
|
+
}
|
|
32
|
+
options() {
|
|
33
|
+
const options = [
|
|
34
|
+
{
|
|
35
|
+
option: '--roomlistEmail [roomlistEmail]'
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
const parentOptions = super.options();
|
|
39
|
+
return options.concat(parentOptions);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
module.exports = new OutlookRoomListCommand();
|
|
43
|
+
//# sourceMappingURL=room-list.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const GraphItemsListCommand_1 = require("../../../base/GraphItemsListCommand");
|
|
4
|
+
const commands_1 = require("../../commands");
|
|
5
|
+
class OutlookRoomListListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
6
|
+
get name() {
|
|
7
|
+
return commands_1.default.ROOMLIST_LIST;
|
|
8
|
+
}
|
|
9
|
+
get description() {
|
|
10
|
+
return 'Get a collection of available roomlists';
|
|
11
|
+
}
|
|
12
|
+
defaultProperties() {
|
|
13
|
+
return ['id', 'displayName', 'phone', 'emailAddress'];
|
|
14
|
+
}
|
|
15
|
+
commandAction(logger, args, cb) {
|
|
16
|
+
this
|
|
17
|
+
.getAllItems(`${this.resource}/v1.0/places/microsoft.graph.roomlist`, logger, true)
|
|
18
|
+
.then(() => {
|
|
19
|
+
logger.log(this.items);
|
|
20
|
+
cb();
|
|
21
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
module.exports = new OutlookRoomListListCommand();
|
|
25
|
+
//# sourceMappingURL=roomlist-list.js.map
|
|
@@ -16,6 +16,8 @@ exports.default = {
|
|
|
16
16
|
REPORT_MAILBOXUSAGEMAILBOXCOUNT: `${prefix} report mailboxusagemailboxcount`,
|
|
17
17
|
REPORT_MAILBOXUSAGEQUOTASTATUSMAILBOXCOUNTS: `${prefix} report mailboxusagequotastatusmailboxcounts`,
|
|
18
18
|
REPORT_MAILBOXUSAGESTORAGE: `${prefix} report mailboxusagestorage`,
|
|
19
|
+
ROOM_LIST: `${prefix} room list`,
|
|
20
|
+
ROOMLIST_LIST: `${prefix} roomlist list`,
|
|
19
21
|
SENDMAIL: `${prefix} sendmail`
|
|
20
22
|
};
|
|
21
23
|
//# sourceMappingURL=commands.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const path = require("path");
|
|
4
|
-
const xmldom_1 = require("xmldom");
|
|
4
|
+
const xmldom_1 = require("@xmldom/xmldom");
|
|
5
5
|
/*
|
|
6
6
|
* Logic extracted from bolt.module.solution.dll
|
|
7
7
|
* Version: 0.4.3
|
|
@@ -12,8 +12,14 @@ class PaAppListCommand extends AzmgmtItemsListCommand_1.AzmgmtItemsListCommand {
|
|
|
12
12
|
defaultProperties() {
|
|
13
13
|
return ['name', 'displayName'];
|
|
14
14
|
}
|
|
15
|
+
getTelemetryProperties(args) {
|
|
16
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
17
|
+
telemetryProps.asAdmin = args.options.asAdmin === true;
|
|
18
|
+
telemetryProps.environment = typeof args.options.environment !== 'undefined';
|
|
19
|
+
return telemetryProps;
|
|
20
|
+
}
|
|
15
21
|
commandAction(logger, args, cb) {
|
|
16
|
-
const url = `${this.resource}providers/Microsoft.PowerApps/apps?api-version=2017-08-01`;
|
|
22
|
+
const url = `${this.resource}providers/Microsoft.PowerApps${args.options.asAdmin ? '/scopes/admin' : ''}${args.options.environment ? '/environments/' + encodeURIComponent(args.options.environment) : ''}/apps?api-version=2017-08-01`;
|
|
17
23
|
this
|
|
18
24
|
.getAllItems(url, logger, true)
|
|
19
25
|
.then(() => {
|
|
@@ -31,6 +37,27 @@ class PaAppListCommand extends AzmgmtItemsListCommand_1.AzmgmtItemsListCommand {
|
|
|
31
37
|
cb();
|
|
32
38
|
}, (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
|
|
33
39
|
}
|
|
40
|
+
options() {
|
|
41
|
+
const options = [
|
|
42
|
+
{
|
|
43
|
+
option: '-e, --environment [environment]'
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
option: '--asAdmin'
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
const parentOptions = super.options();
|
|
50
|
+
return options.concat(parentOptions);
|
|
51
|
+
}
|
|
52
|
+
validate(args) {
|
|
53
|
+
if (args.options.asAdmin && !args.options.environment) {
|
|
54
|
+
return 'When specifying the asAdmin option the environment option is required as well';
|
|
55
|
+
}
|
|
56
|
+
if (args.options.environment && !args.options.asAdmin) {
|
|
57
|
+
return 'When specifying the environment option the asAdmin option is required as well';
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
34
61
|
}
|
|
35
62
|
module.exports = new PaAppListCommand();
|
|
36
63
|
//# sourceMappingURL=app-list.js.map
|