@pnp/cli-microsoft365 11.4.0-beta.312ca0b → 11.4.0-beta.40f818c
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/README.md +1 -1
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/AuthServer.js +2 -4
- package/dist/m365/entra/commands/m365group/m365group-remove.js +1 -1
- package/dist/m365/teams/commands/chat/chat-message-list.js +26 -27
- package/dist/m365/teams/commands/chat/chat-message-send.js +12 -3
- package/dist/m365/teams/commands/chat/chatUtil.js +1 -1
- package/docs/docs/cmd/teams/chat/chat-message-list.mdx +34 -7
- package/docs/docs/cmd/teams/chat/chat-message-send.mdx +23 -1
- package/npm-shrinkwrap.json +274 -241
- package/package.json +11 -11
package/dist/AuthServer.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import http from 'http';
|
|
2
|
-
import url from 'url';
|
|
3
2
|
import { Auth } from './Auth.js';
|
|
4
3
|
import { browserUtil } from './utils/browserUtil.js';
|
|
5
4
|
export class AuthServer {
|
|
@@ -34,9 +33,8 @@ export class AuthServer {
|
|
|
34
33
|
await this.logger.logToStderr(request.url);
|
|
35
34
|
await this.logger.logToStderr('');
|
|
36
35
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const queryString = url.parse(request.url, true).query;
|
|
36
|
+
const urlObj = new URL(request.url, 'http://localhost');
|
|
37
|
+
const queryString = Object.fromEntries(urlObj.searchParams.entries());
|
|
40
38
|
const hasCode = queryString.code !== undefined;
|
|
41
39
|
const hasError = queryString.error !== undefined;
|
|
42
40
|
let body = "";
|
|
@@ -89,7 +89,7 @@ class EntraM365GroupRemoveCommand extends GraphCommand {
|
|
|
89
89
|
await logger.logToStderr(`Deleting the group site: '${url}'...`);
|
|
90
90
|
}
|
|
91
91
|
const requestOptions = {
|
|
92
|
-
url: `${spoAdminUrl}/_api/GroupSiteManager/Delete?siteUrl='${url}'`,
|
|
92
|
+
url: `${spoAdminUrl}/_api/GroupSiteManager/Delete?siteUrl='${formatting.encodeQueryParameter(url)}'`,
|
|
93
93
|
headers: {
|
|
94
94
|
accept: 'application/json;odata=nometadata'
|
|
95
95
|
},
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
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");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var _TeamsChatMessageListCommand_instances, _TeamsChatMessageListCommand_initOptions, _TeamsChatMessageListCommand_initValidators;
|
|
7
1
|
import { odata } from '../../../../utils/odata.js';
|
|
8
2
|
import { validation } from '../../../../utils/validation.js';
|
|
9
3
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
10
4
|
import commands from '../../commands.js';
|
|
5
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export const options = z.strictObject({
|
|
8
|
+
...globalOptionsZod.shape,
|
|
9
|
+
chatId: z.string()
|
|
10
|
+
.refine(id => validation.isValidTeamsChatId(id), {
|
|
11
|
+
error: e => `'${e.input}' is not a valid value for option chatId.`
|
|
12
|
+
})
|
|
13
|
+
.alias('i'),
|
|
14
|
+
endDateTime: z.string()
|
|
15
|
+
.refine(time => validation.isValidISODateTime(time), {
|
|
16
|
+
error: e => `'${e.input}' is not a valid ISO date-time string for option endDateTime.`
|
|
17
|
+
})
|
|
18
|
+
.optional()
|
|
19
|
+
});
|
|
11
20
|
class TeamsChatMessageListCommand extends GraphCommand {
|
|
12
21
|
get name() {
|
|
13
22
|
return commands.CHAT_MESSAGE_LIST;
|
|
@@ -16,19 +25,21 @@ class TeamsChatMessageListCommand extends GraphCommand {
|
|
|
16
25
|
return 'Lists all messages from a chat';
|
|
17
26
|
}
|
|
18
27
|
defaultProperties() {
|
|
19
|
-
return ['id', 'shortBody'];
|
|
28
|
+
return ['id', 'createdDateTime', 'shortBody'];
|
|
20
29
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
_TeamsChatMessageListCommand_instances.add(this);
|
|
24
|
-
__classPrivateFieldGet(this, _TeamsChatMessageListCommand_instances, "m", _TeamsChatMessageListCommand_initOptions).call(this);
|
|
25
|
-
__classPrivateFieldGet(this, _TeamsChatMessageListCommand_instances, "m", _TeamsChatMessageListCommand_initValidators).call(this);
|
|
30
|
+
get schema() {
|
|
31
|
+
return options;
|
|
26
32
|
}
|
|
27
33
|
async commandAction(logger, args) {
|
|
28
|
-
const endpoint = `${this.resource}/v1.0/chats/${args.options.chatId}/messages`;
|
|
29
34
|
try {
|
|
30
|
-
|
|
31
|
-
if (args.options.
|
|
35
|
+
let apiUrl = `${this.resource}/v1.0/chats/${args.options.chatId}/messages`;
|
|
36
|
+
if (args.options.endDateTime) {
|
|
37
|
+
// You can only filter results if the request URL contains the $orderby and $filter query parameters configured for the same property;
|
|
38
|
+
// otherwise, the $filter query option is ignored.
|
|
39
|
+
apiUrl += `?$filter=createdDateTime lt ${args.options.endDateTime}&$orderby=createdDateTime desc`;
|
|
40
|
+
}
|
|
41
|
+
const items = await odata.getAllItems(apiUrl);
|
|
42
|
+
if (args.options.output && args.options.output !== 'json') {
|
|
32
43
|
items.forEach(i => {
|
|
33
44
|
// hoist the content to body for readability
|
|
34
45
|
i.body = i.body.content;
|
|
@@ -53,17 +64,5 @@ class TeamsChatMessageListCommand extends GraphCommand {
|
|
|
53
64
|
}
|
|
54
65
|
}
|
|
55
66
|
}
|
|
56
|
-
_TeamsChatMessageListCommand_instances = new WeakSet(), _TeamsChatMessageListCommand_initOptions = function _TeamsChatMessageListCommand_initOptions() {
|
|
57
|
-
this.options.unshift({
|
|
58
|
-
option: '-i, --chatId <chatId>'
|
|
59
|
-
});
|
|
60
|
-
}, _TeamsChatMessageListCommand_initValidators = function _TeamsChatMessageListCommand_initValidators() {
|
|
61
|
-
this.validators.push(async (args) => {
|
|
62
|
-
if (!validation.isValidTeamsChatId(args.options.chatId)) {
|
|
63
|
-
return `${args.options.chatId} is not a valid Teams chat ID`;
|
|
64
|
-
}
|
|
65
|
-
return true;
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
67
|
export default new TeamsChatMessageListCommand();
|
|
69
68
|
//# sourceMappingURL=chat-message-list.js.map
|
|
@@ -23,6 +23,7 @@ class TeamsChatMessageSendCommand extends GraphDelegatedCommand {
|
|
|
23
23
|
constructor() {
|
|
24
24
|
super();
|
|
25
25
|
_TeamsChatMessageSendCommand_instances.add(this);
|
|
26
|
+
this.contentTypes = ['text', 'html'];
|
|
26
27
|
__classPrivateFieldGet(this, _TeamsChatMessageSendCommand_instances, "m", _TeamsChatMessageSendCommand_initTelemetry).call(this);
|
|
27
28
|
__classPrivateFieldGet(this, _TeamsChatMessageSendCommand_instances, "m", _TeamsChatMessageSendCommand_initOptions).call(this);
|
|
28
29
|
__classPrivateFieldGet(this, _TeamsChatMessageSendCommand_instances, "m", _TeamsChatMessageSendCommand_initValidators).call(this);
|
|
@@ -47,7 +48,7 @@ class TeamsChatMessageSendCommand extends GraphDelegatedCommand {
|
|
|
47
48
|
}
|
|
48
49
|
async ensureChatIdByUserEmails(userEmailsOption) {
|
|
49
50
|
const userEmails = userEmailsOption.trim().toLowerCase().split(',').filter(e => e && e !== '');
|
|
50
|
-
const currentUserEmail = accessToken.getUserNameFromAccessToken(auth.connection.accessTokens[
|
|
51
|
+
const currentUserEmail = accessToken.getUserNameFromAccessToken(auth.connection.accessTokens[auth.defaultResource].accessToken).toLowerCase();
|
|
51
52
|
const existingChats = await chatUtil.findExistingChatsByParticipants([currentUserEmail, ...userEmails]);
|
|
52
53
|
if (!existingChats || existingChats.length === 0) {
|
|
53
54
|
const chat = await this.createConversation([currentUserEmail, ...userEmails]);
|
|
@@ -112,11 +113,12 @@ class TeamsChatMessageSendCommand extends GraphDelegatedCommand {
|
|
|
112
113
|
url: `${this.resource}/v1.0/chats/${chatId}/messages`,
|
|
113
114
|
headers: {
|
|
114
115
|
accept: 'application/json;odata.metadata=none',
|
|
115
|
-
'content-type': 'application/json
|
|
116
|
+
'content-type': 'application/json'
|
|
116
117
|
},
|
|
117
118
|
responseType: 'json',
|
|
118
119
|
data: {
|
|
119
120
|
body: {
|
|
121
|
+
contentType: args.options.contentType || 'text',
|
|
120
122
|
content: args.options.message
|
|
121
123
|
}
|
|
122
124
|
}
|
|
@@ -129,7 +131,8 @@ _TeamsChatMessageSendCommand_instances = new WeakSet(), _TeamsChatMessageSendCom
|
|
|
129
131
|
Object.assign(this.telemetryProperties, {
|
|
130
132
|
chatId: typeof args.options.chatId !== 'undefined',
|
|
131
133
|
userEmails: typeof args.options.userEmails !== 'undefined',
|
|
132
|
-
chatName: typeof args.options.chatName !== 'undefined'
|
|
134
|
+
chatName: typeof args.options.chatName !== 'undefined',
|
|
135
|
+
contentType: args.options.contentType ?? 'text'
|
|
133
136
|
});
|
|
134
137
|
});
|
|
135
138
|
}, _TeamsChatMessageSendCommand_initOptions = function _TeamsChatMessageSendCommand_initOptions() {
|
|
@@ -141,6 +144,9 @@ _TeamsChatMessageSendCommand_instances = new WeakSet(), _TeamsChatMessageSendCom
|
|
|
141
144
|
option: '--chatName [chatName]'
|
|
142
145
|
}, {
|
|
143
146
|
option: '-m, --message <message>'
|
|
147
|
+
}, {
|
|
148
|
+
option: '--contentType [contentType]',
|
|
149
|
+
autocomplete: this.contentTypes
|
|
144
150
|
});
|
|
145
151
|
}, _TeamsChatMessageSendCommand_initValidators = function _TeamsChatMessageSendCommand_initValidators() {
|
|
146
152
|
this.validators.push(async (args) => {
|
|
@@ -153,6 +159,9 @@ _TeamsChatMessageSendCommand_instances = new WeakSet(), _TeamsChatMessageSendCom
|
|
|
153
159
|
return `${args.options.userEmails} contains one or more invalid email addresses.`;
|
|
154
160
|
}
|
|
155
161
|
}
|
|
162
|
+
if (args.options.contentType && !this.contentTypes.includes(args.options.contentType)) {
|
|
163
|
+
return `'${args.options.contentType}' is not a valid value for option contentType. Allowed values are ${this.contentTypes.join(', ')}.`;
|
|
164
|
+
}
|
|
156
165
|
return true;
|
|
157
166
|
});
|
|
158
167
|
}, _TeamsChatMessageSendCommand_initOptionSets = function _TeamsChatMessageSendCommand_initOptionSets() {
|
|
@@ -3,7 +3,7 @@ import { odata } from '../../../../utils/odata.js';
|
|
|
3
3
|
export const chatUtil = {
|
|
4
4
|
/**
|
|
5
5
|
* Finds existing Microsoft Teams chats by participants, using the Microsoft Graph
|
|
6
|
-
* @param expectedMemberEmails a string array of participant
|
|
6
|
+
* @param expectedMemberEmails a string array of participant email addresses
|
|
7
7
|
* @param logger a logger to pipe into the graph request odata helper.
|
|
8
8
|
*/
|
|
9
9
|
async findExistingChatsByParticipants(expectedMemberEmails) {
|
|
@@ -16,11 +16,33 @@ m365 teams chat message list [options]
|
|
|
16
16
|
|
|
17
17
|
```md definition-list
|
|
18
18
|
`-i, --chatId <chatId>`
|
|
19
|
-
: The ID of the chat conversation
|
|
19
|
+
: The ID of the chat conversation.
|
|
20
|
+
|
|
21
|
+
`--endDateTime [endDateTime]`
|
|
22
|
+
: Time indicating the exclusive end of a time range when the message was created.
|
|
20
23
|
```
|
|
21
24
|
|
|
22
25
|
<Global />
|
|
23
26
|
|
|
27
|
+
## Permissions
|
|
28
|
+
|
|
29
|
+
<Tabs>
|
|
30
|
+
<TabItem value="Delegated">
|
|
31
|
+
|
|
32
|
+
| Resource | Permissions |
|
|
33
|
+
|-----------------|------------------|
|
|
34
|
+
| Microsoft Graph | ChatMessage.Read |
|
|
35
|
+
|
|
36
|
+
</TabItem>
|
|
37
|
+
<TabItem value="Application">
|
|
38
|
+
|
|
39
|
+
| Resource | Permissions |
|
|
40
|
+
|-----------------|----------------------|
|
|
41
|
+
| Microsoft Graph | ChatMessage.Read.All |
|
|
42
|
+
|
|
43
|
+
</TabItem>
|
|
44
|
+
</Tabs>
|
|
45
|
+
|
|
24
46
|
## Examples
|
|
25
47
|
|
|
26
48
|
List the messages from a Microsoft Teams chat conversation
|
|
@@ -29,6 +51,12 @@ List the messages from a Microsoft Teams chat conversation
|
|
|
29
51
|
m365 teams chat message list --chatId 19:2da4c29f6d7041eca70b638b43d45437@thread.v2
|
|
30
52
|
```
|
|
31
53
|
|
|
54
|
+
List messages from a Microsoft Teams chat conversation created before November 1, 2022
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
m365 teams chat message list --chatId 19:2da4c29f6d7041eca70b638b43d45437@thread.v2 --endDateTime 2022-11-01T00:00:00Z
|
|
58
|
+
```
|
|
59
|
+
|
|
32
60
|
## Response
|
|
33
61
|
|
|
34
62
|
<Tabs>
|
|
@@ -79,17 +107,17 @@ m365 teams chat message list --chatId 19:2da4c29f6d7041eca70b638b43d45437@thread
|
|
|
79
107
|
<TabItem value="Text">
|
|
80
108
|
|
|
81
109
|
```text
|
|
82
|
-
id shortBody
|
|
83
|
-
-------------
|
|
84
|
-
1667653590582 <p>Hello world</p>
|
|
110
|
+
id createdDateTime shortBody
|
|
111
|
+
------------- ------------------------ ------------------
|
|
112
|
+
1667653590582 2022-11-05T13:06:30.582Z <p>Hello world</p>
|
|
85
113
|
```
|
|
86
114
|
|
|
87
115
|
</TabItem>
|
|
88
116
|
<TabItem value="CSV">
|
|
89
117
|
|
|
90
118
|
```csv
|
|
91
|
-
id,shortBody
|
|
92
|
-
1667653590582,<p>Hello world</p>
|
|
119
|
+
id,createdDateTime,shortBody
|
|
120
|
+
1667653590582,2022-11-05T13:06:30.582Z,<p>Hello world</p>
|
|
93
121
|
```
|
|
94
122
|
|
|
95
123
|
</TabItem>
|
|
@@ -118,4 +146,3 @@ m365 teams chat message list --chatId 19:2da4c29f6d7041eca70b638b43d45437@thread
|
|
|
118
146
|
|
|
119
147
|
</TabItem>
|
|
120
148
|
</Tabs>
|
|
121
|
-
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import Tabs from '@theme/Tabs';
|
|
2
|
+
import TabItem from '@theme/TabItem';
|
|
1
3
|
import Global from '/docs/cmd/_global.mdx';
|
|
2
4
|
|
|
3
5
|
# teams chat message send
|
|
@@ -24,6 +26,9 @@ m365 teams chat message send [options]
|
|
|
24
26
|
|
|
25
27
|
`-m, --message <message>`
|
|
26
28
|
: The message to send
|
|
29
|
+
|
|
30
|
+
`--contentType [contentType]`
|
|
31
|
+
: The content type of the message. Allowed values are `text` and `html`. Default is `text`.
|
|
27
32
|
```
|
|
28
33
|
|
|
29
34
|
<Global />
|
|
@@ -32,12 +37,29 @@ m365 teams chat message send [options]
|
|
|
32
37
|
|
|
33
38
|
A new chat conversation will be created if no existing conversation with the participants specified with emails is found.
|
|
34
39
|
|
|
40
|
+
## Permissions
|
|
41
|
+
|
|
42
|
+
<Tabs>
|
|
43
|
+
<TabItem value="Delegated">
|
|
44
|
+
|
|
45
|
+
| Resource | Permissions |
|
|
46
|
+
|-----------------|-----------------------------|
|
|
47
|
+
| Microsoft Graph | Chat.Read, ChatMessage.Send |
|
|
48
|
+
|
|
49
|
+
</TabItem>
|
|
50
|
+
<TabItem value="Application">
|
|
51
|
+
|
|
52
|
+
This command does not support application permissions.
|
|
53
|
+
|
|
54
|
+
</TabItem>
|
|
55
|
+
</Tabs>
|
|
56
|
+
|
|
35
57
|
## Examples
|
|
36
58
|
|
|
37
59
|
Send a message to a Microsoft Teams chat conversation by id
|
|
38
60
|
|
|
39
61
|
```sh
|
|
40
|
-
m365 teams chat message send --chatId 19:2da4c29f6d7041eca70b638b43d45437@thread.v2 --message "Welcome to Teams"
|
|
62
|
+
m365 teams chat message send --chatId 19:2da4c29f6d7041eca70b638b43d45437@thread.v2 --message "<b>Welcome</b> to Teams" --contentType html
|
|
41
63
|
```
|
|
42
64
|
|
|
43
65
|
Send a message to a single person
|