@pnp/cli-microsoft365 5.0.0-beta.fe151d6 → 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/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 +3 -2
- package/dist/cli/Cli.js +38 -6
- package/dist/m365/aad/commands/app/app-add.js +43 -7
- 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/{Group.js → GroupExtended.js} +1 -1
- 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/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 +6 -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/cli/commands/cli-doctor.js +2 -0
- package/dist/m365/cli/commands/config/config-set.js +5 -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/{aad/commands/o365group/GroupUser.js → planner/AppliedCategories.js} +1 -1
- 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.14.0.js +59 -0
- package/dist/m365/spfx/commands/project/project-upgrade.js +2 -1
- package/dist/m365/spfx/commands/spfx-doctor.js +25 -6
- 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/site/site-ensure.js +1 -1
- package/dist/m365/spo/commands/site/site-recyclebinitem-list.js +76 -0
- package/dist/m365/spo/commands/web/web-installedlanguage-list.js +48 -0
- package/dist/m365/spo/commands.js +3 -0
- 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/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-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-conversation-list.md +24 -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/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/group/group-user-add.md +28 -6
- package/docs/docs/cmd/spo/group/group-user-remove.md +39 -0
- package/docs/docs/cmd/spo/site/site-recyclebinitem-list.md +40 -0
- 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/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 +1327 -1497
- package/package.json +40 -28
- package/dist/m365/base/AadCommand.js +0 -10
|
@@ -25,24 +25,27 @@ class TeamsAppListCommand extends GraphItemsListCommand_1.GraphItemsListCommand
|
|
|
25
25
|
if (args.options.teamId) {
|
|
26
26
|
return Promise.resolve(args.options.teamId);
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
url: `${this.resource}/v1.0/
|
|
28
|
+
const requestOptions = {
|
|
29
|
+
url: `${this.resource}/v1.0/groups?$filter=displayName eq '${encodeURIComponent(args.options.teamName)}'`,
|
|
30
30
|
headers: {
|
|
31
31
|
accept: 'application/json;odata.metadata=none'
|
|
32
32
|
},
|
|
33
33
|
responseType: 'json'
|
|
34
34
|
};
|
|
35
35
|
return request_1.default
|
|
36
|
-
.get(
|
|
36
|
+
.get(requestOptions)
|
|
37
37
|
.then(response => {
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
38
|
+
const groupItem = response.value[0];
|
|
39
|
+
if (!groupItem) {
|
|
40
|
+
return Promise.reject(`The specified team does not exist in the Microsoft Teams`);
|
|
41
|
+
}
|
|
42
|
+
if (groupItem.resourceProvisioningOptions.indexOf('Team') === -1) {
|
|
40
43
|
return Promise.reject(`The specified team does not exist in the Microsoft Teams`);
|
|
41
44
|
}
|
|
42
45
|
if (response.value.length > 1) {
|
|
43
46
|
return Promise.reject(`Multiple Microsoft Teams teams with name ${args.options.teamName} found: ${response.value.map(x => x.id)}`);
|
|
44
47
|
}
|
|
45
|
-
return Promise.resolve(
|
|
48
|
+
return Promise.resolve(groupItem.id);
|
|
46
49
|
});
|
|
47
50
|
}
|
|
48
51
|
getEndpointUrl(args) {
|
|
@@ -13,27 +13,63 @@ class TeamsAppUpdateCommand extends GraphCommand_1.default {
|
|
|
13
13
|
get description() {
|
|
14
14
|
return 'Updates Teams app in the organization\'s app catalog';
|
|
15
15
|
}
|
|
16
|
+
getTelemetryProperties(args) {
|
|
17
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
18
|
+
telemetryProps.id = typeof args.options.id !== 'undefined';
|
|
19
|
+
telemetryProps.name = typeof args.options.name !== 'undefined';
|
|
20
|
+
return telemetryProps;
|
|
21
|
+
}
|
|
16
22
|
commandAction(logger, args, cb) {
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
const { filePath } = args.options;
|
|
24
|
+
this
|
|
25
|
+
.getAppId(args)
|
|
26
|
+
.then((appId) => {
|
|
27
|
+
const fullPath = path.resolve(filePath);
|
|
28
|
+
if (this.verbose) {
|
|
29
|
+
logger.logToStderr(`Updating app with id '${appId}' and file '${fullPath}' in the app catalog...`);
|
|
30
|
+
}
|
|
31
|
+
const requestOptions = {
|
|
32
|
+
url: `${this.resource}/v1.0/appCatalogs/teamsApps/${appId}`,
|
|
33
|
+
headers: {
|
|
34
|
+
"content-type": "application/zip"
|
|
35
|
+
},
|
|
36
|
+
data: fs.readFileSync(fullPath)
|
|
37
|
+
};
|
|
38
|
+
return request_1.default.put(requestOptions);
|
|
39
|
+
})
|
|
40
|
+
.then(_ => cb(), (res) => this.handleRejectedODataJsonPromise(res, logger, cb));
|
|
41
|
+
}
|
|
42
|
+
getAppId(args) {
|
|
43
|
+
if (args.options.id) {
|
|
44
|
+
return Promise.resolve(args.options.id);
|
|
21
45
|
}
|
|
22
46
|
const requestOptions = {
|
|
23
|
-
url: `${this.resource}/v1.0/appCatalogs/teamsApps
|
|
47
|
+
url: `${this.resource}/v1.0/appCatalogs/teamsApps?$filter=displayName eq '${encodeURIComponent(args.options.name)}'`,
|
|
24
48
|
headers: {
|
|
25
|
-
|
|
49
|
+
accept: 'application/json;odata.metadata=none'
|
|
26
50
|
},
|
|
27
|
-
|
|
51
|
+
responseType: 'json'
|
|
28
52
|
};
|
|
29
|
-
request_1.default
|
|
30
|
-
.
|
|
31
|
-
.then(
|
|
53
|
+
return request_1.default
|
|
54
|
+
.get(requestOptions)
|
|
55
|
+
.then(response => {
|
|
56
|
+
const app = response.value[0];
|
|
57
|
+
if (!app) {
|
|
58
|
+
return Promise.reject(`The specified Teams app does not exist`);
|
|
59
|
+
}
|
|
60
|
+
if (response.value.length > 1) {
|
|
61
|
+
return Promise.reject(`Multiple Teams apps with name ${args.options.name} found. Please choose one of these ids: ${response.value.map(x => x.id).join(', ')}`);
|
|
62
|
+
}
|
|
63
|
+
return Promise.resolve(app.id);
|
|
64
|
+
});
|
|
32
65
|
}
|
|
33
66
|
options() {
|
|
34
67
|
const options = [
|
|
35
68
|
{
|
|
36
|
-
option: '-i, --id
|
|
69
|
+
option: '-i, --id [id]'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
option: '-n, --name [name]'
|
|
37
73
|
},
|
|
38
74
|
{
|
|
39
75
|
option: '-p, --filePath <filePath>'
|
|
@@ -43,7 +79,13 @@ class TeamsAppUpdateCommand extends GraphCommand_1.default {
|
|
|
43
79
|
return options.concat(parentOptions);
|
|
44
80
|
}
|
|
45
81
|
validate(args) {
|
|
46
|
-
if (!
|
|
82
|
+
if (!args.options.id && !args.options.name) {
|
|
83
|
+
return 'Specify either id or name';
|
|
84
|
+
}
|
|
85
|
+
if (args.options.id && args.options.name) {
|
|
86
|
+
return 'Specify either id or name, but not both';
|
|
87
|
+
}
|
|
88
|
+
if (args.options.id && !Utils_1.default.isValidGuid(args.options.id)) {
|
|
47
89
|
return `${args.options.id} is not a valid GUID`;
|
|
48
90
|
}
|
|
49
91
|
const fullPath = path.resolve(args.options.filePath);
|
|
@@ -21,6 +21,7 @@ class TeamsChannelGetCommand extends GraphCommand_1.default {
|
|
|
21
21
|
telemetryProps.teamName = typeof args.options.teamName !== 'undefined';
|
|
22
22
|
telemetryProps.channelId = typeof args.options.channelId !== 'undefined';
|
|
23
23
|
telemetryProps.channelName = typeof args.options.channelName !== 'undefined';
|
|
24
|
+
telemetryProps.primary = (!(!args.options.primary)).toString();
|
|
24
25
|
return telemetryProps;
|
|
25
26
|
}
|
|
26
27
|
getTeamId(args) {
|
|
@@ -54,6 +55,9 @@ class TeamsChannelGetCommand extends GraphCommand_1.default {
|
|
|
54
55
|
if (args.options.channelId) {
|
|
55
56
|
return Promise.resolve(args.options.channelId);
|
|
56
57
|
}
|
|
58
|
+
if (args.options.primary) {
|
|
59
|
+
return Promise.resolve('');
|
|
60
|
+
}
|
|
57
61
|
const channelRequestOptions = {
|
|
58
62
|
url: `${this.resource}/v1.0/teams/${encodeURIComponent(this.teamId)}/channels?$filter=displayName eq '${encodeURIComponent(args.options.channelName)}'`,
|
|
59
63
|
headers: {
|
|
@@ -79,15 +83,21 @@ class TeamsChannelGetCommand extends GraphCommand_1.default {
|
|
|
79
83
|
return this.getChannelId(args);
|
|
80
84
|
})
|
|
81
85
|
.then((channelId) => {
|
|
86
|
+
let url = '';
|
|
87
|
+
if (args.options.primary) {
|
|
88
|
+
url = `${this.resource}/v1.0/teams/${encodeURIComponent(this.teamId)}/primaryChannel`;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
url = `${this.resource}/v1.0/teams/${encodeURIComponent(this.teamId)}/channels/${encodeURIComponent(channelId)}`;
|
|
92
|
+
}
|
|
82
93
|
const requestOptions = {
|
|
83
|
-
url:
|
|
94
|
+
url: url,
|
|
84
95
|
headers: {
|
|
85
96
|
accept: 'application/json;odata.metadata=none'
|
|
86
97
|
},
|
|
87
98
|
responseType: 'json'
|
|
88
99
|
};
|
|
89
|
-
return request_1.default
|
|
90
|
-
.get(requestOptions);
|
|
100
|
+
return request_1.default.get(requestOptions);
|
|
91
101
|
})
|
|
92
102
|
.then((res) => {
|
|
93
103
|
logger.log(res);
|
|
@@ -107,6 +117,9 @@ class TeamsChannelGetCommand extends GraphCommand_1.default {
|
|
|
107
117
|
},
|
|
108
118
|
{
|
|
109
119
|
option: '--channelName [channelName]'
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
option: '--primary'
|
|
110
123
|
}
|
|
111
124
|
];
|
|
112
125
|
const parentOptions = super.options();
|
|
@@ -122,11 +135,20 @@ class TeamsChannelGetCommand extends GraphCommand_1.default {
|
|
|
122
135
|
if (args.options.teamId && !Utils_1.default.isValidGuid(args.options.teamId)) {
|
|
123
136
|
return `${args.options.teamId} is not a valid GUID`;
|
|
124
137
|
}
|
|
125
|
-
if (args.options.channelId && args.options.channelName) {
|
|
126
|
-
return 'Specify
|
|
138
|
+
if (args.options.channelId && args.options.channelName && args.options.primary) {
|
|
139
|
+
return 'Specify channelId, channelName or primary';
|
|
140
|
+
}
|
|
141
|
+
if (!args.options.channelId && args.options.channelName && args.options.primary) {
|
|
142
|
+
return 'Specify channelId, channelName or primary.';
|
|
143
|
+
}
|
|
144
|
+
if (args.options.channelId && !args.options.channelName && args.options.primary) {
|
|
145
|
+
return 'Specify channelId, channelName or primary.';
|
|
146
|
+
}
|
|
147
|
+
if (args.options.channelId && args.options.channelName && !args.options.primary) {
|
|
148
|
+
return 'Specify channelId, channelName or primary.';
|
|
127
149
|
}
|
|
128
|
-
if (!args.options.channelId && !args.options.channelName) {
|
|
129
|
-
return 'Specify channelId or
|
|
150
|
+
if (!args.options.channelId && !args.options.channelName && !args.options.primary) {
|
|
151
|
+
return 'Specify channelId, channelName or primary, one is required';
|
|
130
152
|
}
|
|
131
153
|
if (args.options.channelId && !Utils_1.default.isValidTeamsChannelId(args.options.channelId)) {
|
|
132
154
|
return `${args.options.channelId} is not a valid Teams ChannelId`;
|
|
@@ -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 TeamsChatListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
6
|
+
get name() {
|
|
7
|
+
return commands_1.default.CHAT_LIST;
|
|
8
|
+
}
|
|
9
|
+
get description() {
|
|
10
|
+
return 'Lists all chat conversations';
|
|
11
|
+
}
|
|
12
|
+
defaultProperties() {
|
|
13
|
+
return ['id', 'topic', 'chatType'];
|
|
14
|
+
}
|
|
15
|
+
commandAction(logger, args, cb) {
|
|
16
|
+
const filter = args.options.type !== undefined ? `?$filter=chatType eq '${args.options.type}'` : '';
|
|
17
|
+
const endpoint = `${this.resource}/v1.0/chats${filter}`;
|
|
18
|
+
this
|
|
19
|
+
.getAllItems(endpoint, logger, true)
|
|
20
|
+
.then(() => {
|
|
21
|
+
logger.log(this.items);
|
|
22
|
+
cb();
|
|
23
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
24
|
+
}
|
|
25
|
+
options() {
|
|
26
|
+
const options = [
|
|
27
|
+
{
|
|
28
|
+
option: '-t, --type [chatType]'
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
const parentOptions = super.options();
|
|
32
|
+
return options.concat(parentOptions);
|
|
33
|
+
}
|
|
34
|
+
validate(args) {
|
|
35
|
+
const supportedTypes = ['oneOnOne', 'group', 'meeting'];
|
|
36
|
+
if (args.options.type !== undefined && supportedTypes.indexOf(args.options.type) === -1) {
|
|
37
|
+
return `${args.options.type} is not a valid chatType. Accepted values are ${supportedTypes.join(', ')}`;
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
module.exports = new TeamsChatListCommand();
|
|
43
|
+
//# sourceMappingURL=chat-list.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Utils_1 = require("../../../../Utils");
|
|
4
|
+
const GraphItemsListCommand_1 = require("../../../base/GraphItemsListCommand");
|
|
5
|
+
const commands_1 = require("../../commands");
|
|
6
|
+
class TeamsChatMemberListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
7
|
+
get name() {
|
|
8
|
+
return commands_1.default.CHAT_MEMBER_LIST;
|
|
9
|
+
}
|
|
10
|
+
get description() {
|
|
11
|
+
return 'Lists all members from a chat';
|
|
12
|
+
}
|
|
13
|
+
defaultProperties() {
|
|
14
|
+
return ['userId', 'displayName', 'email'];
|
|
15
|
+
}
|
|
16
|
+
commandAction(logger, args, cb) {
|
|
17
|
+
const endpoint = `${this.resource}/v1.0/chats/${args.options.chatId}/members`;
|
|
18
|
+
this
|
|
19
|
+
.getAllItems(endpoint, logger, true)
|
|
20
|
+
.then(() => {
|
|
21
|
+
logger.log(this.items);
|
|
22
|
+
cb();
|
|
23
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
24
|
+
}
|
|
25
|
+
options() {
|
|
26
|
+
const options = [
|
|
27
|
+
{
|
|
28
|
+
option: '-i, --chatId <chatId>'
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
const parentOptions = super.options();
|
|
32
|
+
return options.concat(parentOptions);
|
|
33
|
+
}
|
|
34
|
+
validate(args) {
|
|
35
|
+
if (!Utils_1.default.isValidTeamsChatId(args.options.chatId)) {
|
|
36
|
+
return `${args.options.chatId} is not a valid Teams ChatId`;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
module.exports = new TeamsChatMemberListCommand();
|
|
42
|
+
//# sourceMappingURL=chat-member-list.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Utils_1 = require("../../../../Utils");
|
|
4
|
+
const GraphItemsListCommand_1 = require("../../../base/GraphItemsListCommand");
|
|
5
|
+
const commands_1 = require("../../commands");
|
|
6
|
+
class TeamsChatMessageListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
7
|
+
get name() {
|
|
8
|
+
return commands_1.default.CHAT_MESSAGE_LIST;
|
|
9
|
+
}
|
|
10
|
+
get description() {
|
|
11
|
+
return 'Lists all messages from a chat';
|
|
12
|
+
}
|
|
13
|
+
defaultProperties() {
|
|
14
|
+
return ['id', 'shortBody'];
|
|
15
|
+
}
|
|
16
|
+
commandAction(logger, args, cb) {
|
|
17
|
+
const endpoint = `${this.resource}/v1.0/chats/${args.options.chatId}/messages`;
|
|
18
|
+
this
|
|
19
|
+
.getAllItems(endpoint, logger, true)
|
|
20
|
+
.then(() => {
|
|
21
|
+
if (args.options.output !== 'json') {
|
|
22
|
+
this.items.forEach(i => {
|
|
23
|
+
// hoist the content to body for readability
|
|
24
|
+
i.body = i.body.content;
|
|
25
|
+
let shortBody;
|
|
26
|
+
const bodyToProcess = i.body;
|
|
27
|
+
if (bodyToProcess) {
|
|
28
|
+
let maxLength = 50;
|
|
29
|
+
let addedDots = '...';
|
|
30
|
+
if (bodyToProcess.length < maxLength) {
|
|
31
|
+
maxLength = bodyToProcess.length;
|
|
32
|
+
addedDots = '';
|
|
33
|
+
}
|
|
34
|
+
shortBody = bodyToProcess.replace(/\n/g, ' ').substring(0, maxLength) + addedDots;
|
|
35
|
+
}
|
|
36
|
+
i.shortBody = shortBody;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
logger.log(this.items);
|
|
40
|
+
cb();
|
|
41
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
42
|
+
}
|
|
43
|
+
options() {
|
|
44
|
+
const options = [
|
|
45
|
+
{
|
|
46
|
+
option: '-i, --chatId <chatId>'
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
const parentOptions = super.options();
|
|
50
|
+
return options.concat(parentOptions);
|
|
51
|
+
}
|
|
52
|
+
validate(args) {
|
|
53
|
+
if (!Utils_1.default.isValidTeamsChatId(args.options.chatId)) {
|
|
54
|
+
return `${args.options.chatId} is not a valid Teams chat ID`;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
module.exports = new TeamsChatMessageListCommand();
|
|
60
|
+
//# sourceMappingURL=chat-message-list.js.map
|
|
@@ -0,0 +1,225 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const os = require("os");
|
|
13
|
+
const Auth_1 = require("../../../../Auth");
|
|
14
|
+
const request_1 = require("../../../../request");
|
|
15
|
+
const Utils_1 = require("../../../../Utils");
|
|
16
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
17
|
+
const commands_1 = require("../../commands");
|
|
18
|
+
class TeamsChatMessageSendCommand extends GraphCommand_1.default {
|
|
19
|
+
get name() {
|
|
20
|
+
return commands_1.default.CHAT_MESSAGE_SEND;
|
|
21
|
+
}
|
|
22
|
+
get description() {
|
|
23
|
+
return 'Send a message to an existing or new chat conversation.';
|
|
24
|
+
}
|
|
25
|
+
commandAction(logger, args, cb) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
try {
|
|
28
|
+
const chatId = args.options.chatId
|
|
29
|
+
|| args.options.userEmails && (yield this.ensureChatIdByUserEmails(args.options.userEmails))
|
|
30
|
+
|| args.options.chatName && (yield this.getChatIdByName(args.options.chatName));
|
|
31
|
+
yield this.sendChatMessage(chatId, args.options);
|
|
32
|
+
cb();
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
this.handleRejectedODataJsonPromise(error, logger, cb);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
options() {
|
|
40
|
+
const options = [
|
|
41
|
+
{
|
|
42
|
+
option: '--chatId [chatId]'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
option: '-e, --userEmails [userEmails]'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
option: '--chatName [chatName]'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
option: '-m, --message <message>'
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
const parentOptions = super.options();
|
|
55
|
+
return options.concat(parentOptions);
|
|
56
|
+
}
|
|
57
|
+
validate(args) {
|
|
58
|
+
if (!args.options.chatId && !args.options.userEmails && !args.options.chatName) {
|
|
59
|
+
return 'Specify chatId or userEmails or chatName, one is required.';
|
|
60
|
+
}
|
|
61
|
+
let nrOfMutuallyExclusiveOptionsInUse = 0;
|
|
62
|
+
if (args.options.chatId) {
|
|
63
|
+
nrOfMutuallyExclusiveOptionsInUse++;
|
|
64
|
+
}
|
|
65
|
+
if (args.options.userEmails) {
|
|
66
|
+
nrOfMutuallyExclusiveOptionsInUse++;
|
|
67
|
+
}
|
|
68
|
+
if (args.options.chatName) {
|
|
69
|
+
nrOfMutuallyExclusiveOptionsInUse++;
|
|
70
|
+
}
|
|
71
|
+
if (nrOfMutuallyExclusiveOptionsInUse > 1) {
|
|
72
|
+
return 'Specify either chatId or userEmails or chatName, but not multiple.';
|
|
73
|
+
}
|
|
74
|
+
if (!args.options.message) {
|
|
75
|
+
return 'Specify a message to send.';
|
|
76
|
+
}
|
|
77
|
+
if (args.options.chatId && !Utils_1.default.isValidTeamsChatId(args.options.chatId)) {
|
|
78
|
+
return `${args.options.chatId} is not a valid Teams ChatId.`;
|
|
79
|
+
}
|
|
80
|
+
if (args.options.userEmails) {
|
|
81
|
+
const userEmails = args.options.userEmails.toLowerCase().replace(/\s/g, '').split(',').filter(e => e && e !== '');
|
|
82
|
+
if (!userEmails || userEmails.length === 0 || userEmails.some(e => !Utils_1.default.isValidUserPrincipalName(e))) {
|
|
83
|
+
return `${args.options.userEmails} contains one or more invalid email addresses.`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
ensureChatIdByUserEmails(userEmailsOption) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const userEmails = userEmailsOption.toLowerCase().replace(/\s/g, '').split(',').filter(e => e && e !== '');
|
|
91
|
+
const currentUserEmail = Utils_1.default.getUserNameFromAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken).toLowerCase();
|
|
92
|
+
const existingChats = yield this.findExistingGroupChatsByMembers([currentUserEmail, ...userEmails]);
|
|
93
|
+
if (existingChats && existingChats.length > 0) {
|
|
94
|
+
if (existingChats.length > 1) {
|
|
95
|
+
const disambiguationText = existingChats.map(c => {
|
|
96
|
+
return `- ${c.id}${c.topic && ' - '}${c.topic} - ${c.createdDateTime && new Date(c.createdDateTime).toLocaleString()}`;
|
|
97
|
+
}).join(os.EOL);
|
|
98
|
+
throw new Error(`Multiple chat conversations with this topic found. Please disambiguate:${os.EOL}${disambiguationText}`);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return existingChats[0].id;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const chat = yield this.createConversation([currentUserEmail, ...userEmails]);
|
|
105
|
+
return chat.id;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
getChatIdByName(chatName) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const existingChats = yield this.findExistingGroupChatsByTopic(chatName);
|
|
111
|
+
if (!existingChats || existingChats.length === 0) {
|
|
112
|
+
throw new Error('No chat conversation was found with this name.');
|
|
113
|
+
}
|
|
114
|
+
if (existingChats.length === 1) {
|
|
115
|
+
return existingChats[0].id;
|
|
116
|
+
}
|
|
117
|
+
const disambiguationText = existingChats.map(c => {
|
|
118
|
+
const memberstring = c.members.map(m => m.email).join(', ');
|
|
119
|
+
return `- ${c.id} - ${c.createdDateTime && new Date(c.createdDateTime).toLocaleString()} - ${memberstring}`;
|
|
120
|
+
}).join(os.EOL);
|
|
121
|
+
throw new Error(`Multiple chat conversations with this topic found. Please disambiguate:${os.EOL}${disambiguationText}`);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
// This Microsoft Graph API request throws an intermittent 404 exception, saying that it cannot find the principal.
|
|
125
|
+
// The same behavior occurs when creating the conversation through the Graph Explorer.
|
|
126
|
+
// It seems to happen when the userEmail casing does not match the casing of the actual UPN.
|
|
127
|
+
// When the first request throws an error, the second request does succeed.
|
|
128
|
+
// Therefore a retry-mechanism is implemented here.
|
|
129
|
+
createConversation(memberEmails, retried = 0) {
|
|
130
|
+
var _a;
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
try {
|
|
133
|
+
const jsonBody = {
|
|
134
|
+
chatType: memberEmails.length > 2 ? 'group' : 'oneOnOne',
|
|
135
|
+
members: memberEmails.map(email => {
|
|
136
|
+
return {
|
|
137
|
+
'@odata.type': '#microsoft.graph.aadUserConversationMember',
|
|
138
|
+
roles: ['owner'],
|
|
139
|
+
'user@odata.bind': `https://graph.microsoft.com/v1.0/users/${email}`
|
|
140
|
+
};
|
|
141
|
+
})
|
|
142
|
+
};
|
|
143
|
+
const requestOptions = {
|
|
144
|
+
url: `${this.resource}/v1.0/chats`,
|
|
145
|
+
headers: {
|
|
146
|
+
accept: 'application/json;odata.metadata=none',
|
|
147
|
+
'content-type': 'application/json;odata=nometadata'
|
|
148
|
+
},
|
|
149
|
+
responseType: 'json',
|
|
150
|
+
data: jsonBody
|
|
151
|
+
};
|
|
152
|
+
return yield request_1.default.post(requestOptions);
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
if (((_a = err.message) === null || _a === void 0 ? void 0 : _a.indexOf('404')) > -1 && retried < 4) {
|
|
156
|
+
return yield this.createConversation(memberEmails, retried + 1);
|
|
157
|
+
}
|
|
158
|
+
throw err;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
sendChatMessage(chatId, options) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
const requestOptions = {
|
|
165
|
+
url: `${this.resource}/v1.0/chats/${chatId}/messages`,
|
|
166
|
+
headers: {
|
|
167
|
+
accept: 'application/json;odata.metadata=none',
|
|
168
|
+
'content-type': 'application/json;odata=nometadata'
|
|
169
|
+
},
|
|
170
|
+
responseType: 'json',
|
|
171
|
+
data: {
|
|
172
|
+
body: {
|
|
173
|
+
content: options.message
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
yield request_1.default.post(requestOptions);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
findExistingGroupChatsByMembers(expectedMemberEmails) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
const endpoint = `${this.resource}/v1.0/chats?$filter=chatType eq 'group'&$expand=members&$select=id,topic,createdDateTime,members`;
|
|
183
|
+
const foundChats = [];
|
|
184
|
+
const chats = yield this.getAllChats(endpoint, []);
|
|
185
|
+
for (const chat of chats) {
|
|
186
|
+
const chatMembers = chat.members;
|
|
187
|
+
if (chatMembers.length === expectedMemberEmails.length) {
|
|
188
|
+
const chatMemberEmails = chatMembers.map(member => { var _a; return (_a = member.email) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
|
|
189
|
+
if (expectedMemberEmails.every(email => chatMemberEmails.some(memberEmail => memberEmail === email))) {
|
|
190
|
+
foundChats.push(chat);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return foundChats;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
findExistingGroupChatsByTopic(topic) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
const endpoint = `${this.resource}/v1.0/chats?$filter=topic eq '${encodeURIComponent(topic)}'&$expand=members&$select=id,topic,createdDateTime,chatType`;
|
|
200
|
+
const chats = yield this.getAllChats(endpoint, []);
|
|
201
|
+
return chats;
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
getAllChats(url, items) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
const requestOptions = {
|
|
207
|
+
url: url,
|
|
208
|
+
headers: {
|
|
209
|
+
accept: 'application/json;odata.metadata=none'
|
|
210
|
+
},
|
|
211
|
+
responseType: 'json'
|
|
212
|
+
};
|
|
213
|
+
const res = yield request_1.default.get(requestOptions);
|
|
214
|
+
items = items.concat(res.value);
|
|
215
|
+
if (res['@odata.nextLink']) {
|
|
216
|
+
return yield this.getAllChats(res['@odata.nextLink'], items);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
return items;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
module.exports = new TeamsChatMessageSendCommand();
|
|
225
|
+
//# sourceMappingURL=chat-message-send.js.map
|
|
@@ -13,7 +13,7 @@ class TeamsMessageGetCommand extends GraphCommand_1.default {
|
|
|
13
13
|
}
|
|
14
14
|
commandAction(logger, args, cb) {
|
|
15
15
|
const requestOptions = {
|
|
16
|
-
url: `${this.resource}/
|
|
16
|
+
url: `${this.resource}/v1.0/teams/${args.options.teamId}/channels/${args.options.channelId}/messages/${args.options.messageId}`,
|
|
17
17
|
headers: {
|
|
18
18
|
accept: 'application/json;odata.metadata=none'
|
|
19
19
|
},
|
|
@@ -30,24 +30,27 @@ class TeamsTabGetCommand extends GraphCommand_1.default {
|
|
|
30
30
|
if (args.options.teamId) {
|
|
31
31
|
return Promise.resolve(args.options.teamId);
|
|
32
32
|
}
|
|
33
|
-
const
|
|
34
|
-
url: `${this.resource}/v1.0/
|
|
33
|
+
const requestOptions = {
|
|
34
|
+
url: `${this.resource}/v1.0/groups?$filter=displayName eq '${encodeURIComponent(args.options.teamName)}'`,
|
|
35
35
|
headers: {
|
|
36
36
|
accept: 'application/json;odata.metadata=none'
|
|
37
37
|
},
|
|
38
38
|
responseType: 'json'
|
|
39
39
|
};
|
|
40
40
|
return request_1.default
|
|
41
|
-
.get(
|
|
41
|
+
.get(requestOptions)
|
|
42
42
|
.then(response => {
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
43
|
+
const groupItem = response.value[0];
|
|
44
|
+
if (!groupItem) {
|
|
45
|
+
return Promise.reject(`The specified team does not exist in the Microsoft Teams`);
|
|
46
|
+
}
|
|
47
|
+
if (groupItem.resourceProvisioningOptions.indexOf('Team') === -1) {
|
|
45
48
|
return Promise.reject(`The specified team does not exist in the Microsoft Teams`);
|
|
46
49
|
}
|
|
47
50
|
if (response.value.length > 1) {
|
|
48
51
|
return Promise.reject(`Multiple Microsoft Teams teams with name ${args.options.teamName} found: ${response.value.map(x => x.id)}`);
|
|
49
52
|
}
|
|
50
|
-
return Promise.resolve(
|
|
53
|
+
return Promise.resolve(groupItem.id);
|
|
51
54
|
});
|
|
52
55
|
}
|
|
53
56
|
getChannelId(args) {
|
|
@@ -13,6 +13,10 @@ exports.default = {
|
|
|
13
13
|
CHANNEL_LIST: `${prefix} channel list`,
|
|
14
14
|
CHANNEL_REMOVE: `${prefix} channel remove`,
|
|
15
15
|
CHANNEL_SET: `${prefix} channel set`,
|
|
16
|
+
CHAT_LIST: `${prefix} chat list`,
|
|
17
|
+
CHAT_MEMBER_LIST: `${prefix} chat member list`,
|
|
18
|
+
CHAT_MESSAGE_LIST: `${prefix} chat message list`,
|
|
19
|
+
CHAT_MESSAGE_SEND: `${prefix} chat message send`,
|
|
16
20
|
CONVERSATIONMEMBER_ADD: `${prefix} conversationmember add`,
|
|
17
21
|
CONVERSATIONMEMBER_LIST: `${prefix} conversationmember list`,
|
|
18
22
|
FUNSETTINGS_LIST: `${prefix} funsettings list`,
|