@microsoft/agents-activity 0.2.14 → 0.4.1
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/dist/src/action/actionTypes.d.ts +33 -0
- package/dist/src/action/actionTypes.js +33 -0
- package/dist/src/action/actionTypes.js.map +1 -1
- package/dist/src/action/semanticActionStateTypes.d.ts +9 -0
- package/dist/src/action/semanticActionStateTypes.js +9 -0
- package/dist/src/action/semanticActionStateTypes.js.map +1 -1
- package/dist/src/activity.d.ts +166 -17
- package/dist/src/activity.js +90 -11
- package/dist/src/activity.js.map +1 -1
- package/dist/src/activityEventNames.d.ts +6 -0
- package/dist/src/activityEventNames.js +6 -0
- package/dist/src/activityEventNames.js.map +1 -1
- package/dist/src/activityImportance.d.ts +9 -0
- package/dist/src/activityImportance.js +9 -0
- package/dist/src/activityImportance.js.map +1 -1
- package/dist/src/activityTypes.d.ts +57 -0
- package/dist/src/activityTypes.js +57 -0
- package/dist/src/activityTypes.js.map +1 -1
- package/dist/src/attachment/attachment.d.ts +17 -2
- package/dist/src/attachment/attachment.js.map +1 -1
- package/dist/src/attachment/attachmentLayoutTypes.d.ts +6 -0
- package/dist/src/attachment/attachmentLayoutTypes.js +6 -0
- package/dist/src/attachment/attachmentLayoutTypes.js.map +1 -1
- package/dist/src/conversation/channelAccount.d.ts +15 -0
- package/dist/src/conversation/channelAccount.js.map +1 -1
- package/dist/src/conversation/channels.d.ts +57 -0
- package/dist/src/conversation/channels.js +57 -0
- package/dist/src/conversation/channels.js.map +1 -1
- package/dist/src/conversation/conversationAccount.d.ts +24 -0
- package/dist/src/conversation/conversationAccount.js.map +1 -1
- package/dist/src/conversation/conversationReference.d.ts +21 -0
- package/dist/src/conversation/conversationReference.js.map +1 -1
- package/dist/src/conversation/endOfConversationCodes.d.ts +18 -0
- package/dist/src/conversation/endOfConversationCodes.js +18 -0
- package/dist/src/conversation/endOfConversationCodes.js.map +1 -1
- package/dist/src/conversation/roleTypes.d.ts +9 -0
- package/dist/src/conversation/roleTypes.js +9 -0
- package/dist/src/conversation/roleTypes.js.map +1 -1
- package/dist/src/deliveryModes.d.ts +12 -0
- package/dist/src/deliveryModes.js +12 -0
- package/dist/src/deliveryModes.js.map +1 -1
- package/dist/src/inputHints.d.ts +9 -0
- package/dist/src/inputHints.js +9 -0
- package/dist/src/inputHints.js.map +1 -1
- package/dist/src/messageReactionTypes.d.ts +6 -0
- package/dist/src/messageReactionTypes.js +6 -0
- package/dist/src/messageReactionTypes.js.map +1 -1
- package/dist/src/textFormatTypes.d.ts +9 -0
- package/dist/src/textFormatTypes.js +9 -0
- package/dist/src/textFormatTypes.js.map +1 -1
- package/package.json +2 -2
- package/src/action/actionTypes.ts +43 -0
- package/src/action/semanticActionStateTypes.ts +11 -0
- package/src/activity.ts +285 -11
- package/src/activityEventNames.ts +7 -0
- package/src/activityImportance.ts +11 -0
- package/src/activityTypes.ts +75 -0
- package/src/attachment/attachment.ts +19 -0
- package/src/attachment/attachmentLayoutTypes.ts +7 -0
- package/src/conversation/channelAccount.ts +19 -0
- package/src/conversation/channels.ts +75 -0
- package/src/conversation/conversationAccount.ts +31 -0
- package/src/conversation/conversationReference.ts +27 -0
- package/src/conversation/endOfConversationCodes.ts +23 -0
- package/src/conversation/roleTypes.ts +11 -0
- package/src/deliveryModes.ts +15 -0
- package/src/inputHints.ts +11 -0
- package/src/messageReactionTypes.ts +7 -0
- package/src/textFormatTypes.ts +11 -0
|
@@ -7,8 +7,17 @@ import { z } from 'zod';
|
|
|
7
7
|
* Enum representing the different role types in a conversation.
|
|
8
8
|
*/
|
|
9
9
|
export declare enum RoleTypes {
|
|
10
|
+
/**
|
|
11
|
+
* Represents a user in the conversation.
|
|
12
|
+
*/
|
|
10
13
|
User = "user",
|
|
14
|
+
/**
|
|
15
|
+
* Represents an agent or bot in the conversation.
|
|
16
|
+
*/
|
|
11
17
|
Agent = "bot",
|
|
18
|
+
/**
|
|
19
|
+
* Represents a skill in the conversation.
|
|
20
|
+
*/
|
|
12
21
|
Skill = "skill"
|
|
13
22
|
}
|
|
14
23
|
/**
|
|
@@ -11,8 +11,17 @@ const zod_1 = require("zod");
|
|
|
11
11
|
*/
|
|
12
12
|
var RoleTypes;
|
|
13
13
|
(function (RoleTypes) {
|
|
14
|
+
/**
|
|
15
|
+
* Represents a user in the conversation.
|
|
16
|
+
*/
|
|
14
17
|
RoleTypes["User"] = "user";
|
|
18
|
+
/**
|
|
19
|
+
* Represents an agent or bot in the conversation.
|
|
20
|
+
*/
|
|
15
21
|
RoleTypes["Agent"] = "bot";
|
|
22
|
+
/**
|
|
23
|
+
* Represents a skill in the conversation.
|
|
24
|
+
*/
|
|
16
25
|
RoleTypes["Skill"] = "skill";
|
|
17
26
|
})(RoleTypes || (exports.RoleTypes = RoleTypes = {}));
|
|
18
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roleTypes.js","sourceRoot":"","sources":["../../../src/conversation/roleTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAuB;AAEvB;;GAEG;AACH,IAAY,
|
|
1
|
+
{"version":3,"file":"roleTypes.js","sourceRoot":"","sources":["../../../src/conversation/roleTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAuB;AAEvB;;GAEG;AACH,IAAY,SAeX;AAfD,WAAY,SAAS;IACnB;;OAEG;IACH,0BAAa,CAAA;IAEb;;OAEG;IACH,0BAAa,CAAA;IAEb;;OAEG;IACH,4BAAe,CAAA;AACjB,CAAC,EAfW,SAAS,yBAAT,SAAS,QAepB;AAED;;GAEG;AACU,QAAA,iBAAiB,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA"}
|
|
@@ -7,9 +7,21 @@ import { z } from 'zod';
|
|
|
7
7
|
* Enum representing delivery modes.
|
|
8
8
|
*/
|
|
9
9
|
export declare enum DeliveryModes {
|
|
10
|
+
/**
|
|
11
|
+
* Represents the normal delivery mode.
|
|
12
|
+
*/
|
|
10
13
|
Normal = "normal",
|
|
14
|
+
/**
|
|
15
|
+
* Represents a notification delivery mode.
|
|
16
|
+
*/
|
|
11
17
|
Notification = "notification",
|
|
18
|
+
/**
|
|
19
|
+
* Represents a delivery mode where replies are expected.
|
|
20
|
+
*/
|
|
12
21
|
ExpectReplies = "expectReplies",
|
|
22
|
+
/**
|
|
23
|
+
* Represents an ephemeral delivery mode.
|
|
24
|
+
*/
|
|
13
25
|
Ephemeral = "ephemeral"
|
|
14
26
|
}
|
|
15
27
|
/**
|
|
@@ -11,9 +11,21 @@ const zod_1 = require("zod");
|
|
|
11
11
|
*/
|
|
12
12
|
var DeliveryModes;
|
|
13
13
|
(function (DeliveryModes) {
|
|
14
|
+
/**
|
|
15
|
+
* Represents the normal delivery mode.
|
|
16
|
+
*/
|
|
14
17
|
DeliveryModes["Normal"] = "normal";
|
|
18
|
+
/**
|
|
19
|
+
* Represents a notification delivery mode.
|
|
20
|
+
*/
|
|
15
21
|
DeliveryModes["Notification"] = "notification";
|
|
22
|
+
/**
|
|
23
|
+
* Represents a delivery mode where replies are expected.
|
|
24
|
+
*/
|
|
16
25
|
DeliveryModes["ExpectReplies"] = "expectReplies";
|
|
26
|
+
/**
|
|
27
|
+
* Represents an ephemeral delivery mode.
|
|
28
|
+
*/
|
|
17
29
|
DeliveryModes["Ephemeral"] = "ephemeral";
|
|
18
30
|
})(DeliveryModes || (exports.DeliveryModes = DeliveryModes = {}));
|
|
19
31
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deliveryModes.js","sourceRoot":"","sources":["../../src/deliveryModes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAuB;AAEvB;;GAEG;AACH,IAAY,
|
|
1
|
+
{"version":3,"file":"deliveryModes.js","sourceRoot":"","sources":["../../src/deliveryModes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAuB;AAEvB;;GAEG;AACH,IAAY,aAoBX;AApBD,WAAY,aAAa;IACvB;;OAEG;IACH,kCAAiB,CAAA;IAEjB;;OAEG;IACH,8CAA6B,CAAA;IAE7B;;OAEG;IACH,gDAA+B,CAAA;IAE/B;;OAEG;IACH,wCAAuB,CAAA;AACzB,CAAC,EApBW,aAAa,6BAAb,aAAa,QAoBxB;AAED;;GAEG;AACU,QAAA,sBAAsB,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC,CAAA"}
|
package/dist/src/inputHints.d.ts
CHANGED
|
@@ -7,8 +7,17 @@ import { z } from 'zod';
|
|
|
7
7
|
* Enum representing input hints.
|
|
8
8
|
*/
|
|
9
9
|
export declare enum InputHints {
|
|
10
|
+
/**
|
|
11
|
+
* Indicates that the bot is ready to accept input from the user.
|
|
12
|
+
*/
|
|
10
13
|
AcceptingInput = "acceptingInput",
|
|
14
|
+
/**
|
|
15
|
+
* Indicates that the bot is ignoring input from the user.
|
|
16
|
+
*/
|
|
11
17
|
IgnoringInput = "ignoringInput",
|
|
18
|
+
/**
|
|
19
|
+
* Indicates that the bot is expecting input from the user.
|
|
20
|
+
*/
|
|
12
21
|
ExpectingInput = "expectingInput"
|
|
13
22
|
}
|
|
14
23
|
/**
|
package/dist/src/inputHints.js
CHANGED
|
@@ -11,8 +11,17 @@ const zod_1 = require("zod");
|
|
|
11
11
|
*/
|
|
12
12
|
var InputHints;
|
|
13
13
|
(function (InputHints) {
|
|
14
|
+
/**
|
|
15
|
+
* Indicates that the bot is ready to accept input from the user.
|
|
16
|
+
*/
|
|
14
17
|
InputHints["AcceptingInput"] = "acceptingInput";
|
|
18
|
+
/**
|
|
19
|
+
* Indicates that the bot is ignoring input from the user.
|
|
20
|
+
*/
|
|
15
21
|
InputHints["IgnoringInput"] = "ignoringInput";
|
|
22
|
+
/**
|
|
23
|
+
* Indicates that the bot is expecting input from the user.
|
|
24
|
+
*/
|
|
16
25
|
InputHints["ExpectingInput"] = "expectingInput";
|
|
17
26
|
})(InputHints || (exports.InputHints = InputHints = {}));
|
|
18
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputHints.js","sourceRoot":"","sources":["../../src/inputHints.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAuB;AAEvB;;GAEG;AACH,IAAY,
|
|
1
|
+
{"version":3,"file":"inputHints.js","sourceRoot":"","sources":["../../src/inputHints.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAuB;AAEvB;;GAEG;AACH,IAAY,UAeX;AAfD,WAAY,UAAU;IACpB;;OAEG;IACH,+CAAiC,CAAA;IAEjC;;OAEG;IACH,6CAA+B,CAAA;IAE/B;;OAEG;IACH,+CAAiC,CAAA;AACnC,CAAC,EAfW,UAAU,0BAAV,UAAU,QAerB;AAED;;GAEG;AACU,QAAA,mBAAmB,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAA"}
|
|
@@ -7,7 +7,13 @@ import { z } from 'zod';
|
|
|
7
7
|
* Enum representing message reaction types.
|
|
8
8
|
*/
|
|
9
9
|
export declare enum MessageReactionTypes {
|
|
10
|
+
/**
|
|
11
|
+
* Represents a 'like' reaction to a message.
|
|
12
|
+
*/
|
|
10
13
|
Like = "like",
|
|
14
|
+
/**
|
|
15
|
+
* Represents a '+1' reaction to a message.
|
|
16
|
+
*/
|
|
11
17
|
PlusOne = "plusOne"
|
|
12
18
|
}
|
|
13
19
|
/**
|
|
@@ -11,7 +11,13 @@ const zod_1 = require("zod");
|
|
|
11
11
|
*/
|
|
12
12
|
var MessageReactionTypes;
|
|
13
13
|
(function (MessageReactionTypes) {
|
|
14
|
+
/**
|
|
15
|
+
* Represents a 'like' reaction to a message.
|
|
16
|
+
*/
|
|
14
17
|
MessageReactionTypes["Like"] = "like";
|
|
18
|
+
/**
|
|
19
|
+
* Represents a '+1' reaction to a message.
|
|
20
|
+
*/
|
|
15
21
|
MessageReactionTypes["PlusOne"] = "plusOne";
|
|
16
22
|
})(MessageReactionTypes || (exports.MessageReactionTypes = MessageReactionTypes = {}));
|
|
17
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageReactionTypes.js","sourceRoot":"","sources":["../../src/messageReactionTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAuB;AAEvB;;GAEG;AACH,IAAY,
|
|
1
|
+
{"version":3,"file":"messageReactionTypes.js","sourceRoot":"","sources":["../../src/messageReactionTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAuB;AAEvB;;GAEG;AACH,IAAY,oBAUX;AAVD,WAAY,oBAAoB;IAC9B;;OAEG;IACH,qCAAa,CAAA;IAEb;;OAEG;IACH,2CAAmB,CAAA;AACrB,CAAC,EAVW,oBAAoB,oCAApB,oBAAoB,QAU/B;AAED;;GAEG;AACU,QAAA,6BAA6B,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAA"}
|
|
@@ -7,8 +7,17 @@ import { z } from 'zod';
|
|
|
7
7
|
* Enum representing text format types.
|
|
8
8
|
*/
|
|
9
9
|
export declare enum TextFormatTypes {
|
|
10
|
+
/**
|
|
11
|
+
* Represents text formatted using Markdown.
|
|
12
|
+
*/
|
|
10
13
|
Markdown = "markdown",
|
|
14
|
+
/**
|
|
15
|
+
* Represents plain text without any formatting.
|
|
16
|
+
*/
|
|
11
17
|
Plain = "plain",
|
|
18
|
+
/**
|
|
19
|
+
* Represents text formatted using XML.
|
|
20
|
+
*/
|
|
12
21
|
Xml = "xml"
|
|
13
22
|
}
|
|
14
23
|
/**
|
|
@@ -11,8 +11,17 @@ const zod_1 = require("zod");
|
|
|
11
11
|
*/
|
|
12
12
|
var TextFormatTypes;
|
|
13
13
|
(function (TextFormatTypes) {
|
|
14
|
+
/**
|
|
15
|
+
* Represents text formatted using Markdown.
|
|
16
|
+
*/
|
|
14
17
|
TextFormatTypes["Markdown"] = "markdown";
|
|
18
|
+
/**
|
|
19
|
+
* Represents plain text without any formatting.
|
|
20
|
+
*/
|
|
15
21
|
TextFormatTypes["Plain"] = "plain";
|
|
22
|
+
/**
|
|
23
|
+
* Represents text formatted using XML.
|
|
24
|
+
*/
|
|
16
25
|
TextFormatTypes["Xml"] = "xml";
|
|
17
26
|
})(TextFormatTypes || (exports.TextFormatTypes = TextFormatTypes = {}));
|
|
18
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textFormatTypes.js","sourceRoot":"","sources":["../../src/textFormatTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAuB;AAEvB;;GAEG;AACH,IAAY,
|
|
1
|
+
{"version":3,"file":"textFormatTypes.js","sourceRoot":"","sources":["../../src/textFormatTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAuB;AAEvB;;GAEG;AACH,IAAY,eAeX;AAfD,WAAY,eAAe;IACzB;;OAEG;IACH,wCAAqB,CAAA;IAErB;;OAEG;IACH,kCAAe,CAAA;IAEf;;OAEG;IACH,8BAAW,CAAA;AACb,CAAC,EAfW,eAAe,+BAAf,eAAe,QAe1B;AAED;;GAEG;AACU,QAAA,wBAAwB,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@microsoft/agents-activity",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.1",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"types": "dist/src/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"uuid": "^11.1.0",
|
|
23
|
-
"zod": "^3.24.
|
|
23
|
+
"zod": "^3.24.4"
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"files": [
|
|
@@ -9,16 +9,59 @@ import { z } from 'zod'
|
|
|
9
9
|
* Enum representing the types of actions.
|
|
10
10
|
*/
|
|
11
11
|
export enum ActionTypes {
|
|
12
|
+
/**
|
|
13
|
+
* Opens a URL in the default browser.
|
|
14
|
+
*/
|
|
12
15
|
OpenUrl = 'openUrl',
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Sends a message back to the bot as a simple string.
|
|
19
|
+
*/
|
|
13
20
|
ImBack = 'imBack',
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Sends a message back to the bot with additional data.
|
|
24
|
+
*/
|
|
14
25
|
PostBack = 'postBack',
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Plays an audio file.
|
|
29
|
+
*/
|
|
15
30
|
PlayAudio = 'playAudio',
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Plays a video file.
|
|
34
|
+
*/
|
|
16
35
|
PlayVideo = 'playVideo',
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Displays an image.
|
|
39
|
+
*/
|
|
17
40
|
ShowImage = 'showImage',
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Downloads a file.
|
|
44
|
+
*/
|
|
18
45
|
DownloadFile = 'downloadFile',
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Initiates a sign-in process.
|
|
49
|
+
*/
|
|
19
50
|
Signin = 'signin',
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Initiates a phone call.
|
|
54
|
+
*/
|
|
20
55
|
Call = 'call',
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Sends a message back to the bot with additional metadata.
|
|
59
|
+
*/
|
|
21
60
|
MessageBack = 'messageBack',
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Opens an application.
|
|
64
|
+
*/
|
|
22
65
|
OpenApp = 'openApp',
|
|
23
66
|
}
|
|
24
67
|
|
|
@@ -9,8 +9,19 @@ import { z } from 'zod'
|
|
|
9
9
|
* Enum representing the state types of a semantic action.
|
|
10
10
|
*/
|
|
11
11
|
export enum SemanticActionStateTypes {
|
|
12
|
+
/**
|
|
13
|
+
* Indicates the start of a semantic action.
|
|
14
|
+
*/
|
|
12
15
|
Start = 'start',
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Indicates the continuation of a semantic action.
|
|
19
|
+
*/
|
|
13
20
|
Continue = 'continue',
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Indicates the completion of a semantic action.
|
|
24
|
+
*/
|
|
14
25
|
Done = 'done',
|
|
15
26
|
}
|
|
16
27
|
|
package/src/activity.ts
CHANGED
|
@@ -3,27 +3,27 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { z } from 'zod'
|
|
7
6
|
import { v4 as uuid } from 'uuid'
|
|
8
|
-
import {
|
|
7
|
+
import { z } from 'zod'
|
|
8
|
+
import { SemanticAction, semanticActionZodSchema } from './action/semanticAction'
|
|
9
9
|
import { SuggestedActions, suggestedActionsZodSchema } from './action/suggestedActions'
|
|
10
10
|
import { ActivityEventNames, activityEventNamesZodSchema } from './activityEventNames'
|
|
11
11
|
import { ActivityImportance, activityImportanceZodSchema } from './activityImportance'
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { ActivityTypes, activityTypesZodSchema } from './activityTypes'
|
|
13
|
+
import { Attachment, attachmentZodSchema } from './attachment/attachment'
|
|
14
|
+
import { AttachmentLayoutTypes, attachmentLayoutTypesZodSchema } from './attachment/attachmentLayoutTypes'
|
|
14
15
|
import { ChannelAccount, channelAccountZodSchema } from './conversation/channelAccount'
|
|
16
|
+
import { Channels } from './conversation/channels'
|
|
15
17
|
import { ConversationAccount, conversationAccountZodSchema } from './conversation/conversationAccount'
|
|
16
|
-
import { TextFormatTypes, textFormatTypesZodSchema } from './textFormatTypes'
|
|
17
|
-
import { AttachmentLayoutTypes, attachmentLayoutTypesZodSchema } from './attachment/attachmentLayoutTypes'
|
|
18
|
-
import { MessageReaction, messageReactionZodSchema } from './messageReaction'
|
|
19
|
-
import { InputHints, inputHintsZodSchema } from './inputHints'
|
|
20
|
-
import { Attachment, attachmentZodSchema } from './attachment/attachment'
|
|
21
|
-
import { Entity, entityZodSchema } from './entity/entity'
|
|
22
18
|
import { ConversationReference, conversationReferenceZodSchema } from './conversation/conversationReference'
|
|
23
19
|
import { EndOfConversationCodes, endOfConversationCodesZodSchema } from './conversation/endOfConversationCodes'
|
|
24
20
|
import { DeliveryModes, deliveryModesZodSchema } from './deliveryModes'
|
|
25
|
-
import {
|
|
21
|
+
import { Entity, entityZodSchema } from './entity/entity'
|
|
26
22
|
import { Mention } from './entity/mention'
|
|
23
|
+
import { InputHints, inputHintsZodSchema } from './inputHints'
|
|
24
|
+
import { MessageReaction, messageReactionZodSchema } from './messageReaction'
|
|
25
|
+
import { TextFormatTypes, textFormatTypesZodSchema } from './textFormatTypes'
|
|
26
|
+
import { TextHighlight, textHighlightZodSchema } from './textHighlight'
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Zod schema for validating an Activity object.
|
|
@@ -77,51 +77,234 @@ export const activityZodSchema = z.object({
|
|
|
77
77
|
* Represents an activity in a conversation.
|
|
78
78
|
*/
|
|
79
79
|
export class Activity {
|
|
80
|
+
/**
|
|
81
|
+
* The type of the activity.
|
|
82
|
+
*/
|
|
80
83
|
type: ActivityTypes | string
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The text content of the activity.
|
|
87
|
+
*/
|
|
81
88
|
text?: string
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The unique identifier of the activity.
|
|
92
|
+
*/
|
|
82
93
|
id?: string
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The channel ID where the activity originated.
|
|
97
|
+
*/
|
|
83
98
|
channelId?: string
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The account of the sender of the activity.
|
|
102
|
+
*/
|
|
84
103
|
from?: ChannelAccount
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The timestamp of the activity.
|
|
107
|
+
*/
|
|
85
108
|
timestamp?: Date | string
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The local timestamp of the activity.
|
|
112
|
+
*/
|
|
86
113
|
localTimestamp?: Date | string
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The local timezone of the activity.
|
|
117
|
+
*/
|
|
87
118
|
localTimezone?: string
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The caller ID of the activity.
|
|
122
|
+
*/
|
|
88
123
|
callerId?: string
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The service URL of the activity.
|
|
127
|
+
*/
|
|
89
128
|
serviceUrl?: string
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The conversation account associated with the activity.
|
|
132
|
+
*/
|
|
90
133
|
conversation?: ConversationAccount
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The recipient of the activity.
|
|
137
|
+
*/
|
|
91
138
|
recipient?: ChannelAccount
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The text format of the activity.
|
|
142
|
+
*/
|
|
92
143
|
textFormat?: TextFormatTypes | string
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The attachment layout of the activity.
|
|
147
|
+
*/
|
|
93
148
|
attachmentLayout?: AttachmentLayoutTypes | string
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The members added to the conversation.
|
|
152
|
+
*/
|
|
94
153
|
membersAdded?: ChannelAccount[]
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The members removed from the conversation.
|
|
157
|
+
*/
|
|
95
158
|
membersRemoved?: ChannelAccount[]
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The reactions added to the activity.
|
|
162
|
+
*/
|
|
96
163
|
reactionsAdded?: MessageReaction[]
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The reactions removed from the activity.
|
|
167
|
+
*/
|
|
97
168
|
reactionsRemoved?: MessageReaction[]
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The topic name of the activity.
|
|
172
|
+
*/
|
|
98
173
|
topicName?: string
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Indicates whether the history is disclosed.
|
|
177
|
+
*/
|
|
99
178
|
historyDisclosed?: boolean
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The locale of the activity.
|
|
182
|
+
*/
|
|
100
183
|
locale?: string
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The speech text of the activity.
|
|
187
|
+
*/
|
|
101
188
|
speak?: string
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The input hint for the activity.
|
|
192
|
+
*/
|
|
102
193
|
inputHint?: InputHints | string
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The summary of the activity.
|
|
197
|
+
*/
|
|
103
198
|
summary?: string
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* The suggested actions for the activity.
|
|
202
|
+
*/
|
|
104
203
|
suggestedActions?: SuggestedActions
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* The attachments of the activity.
|
|
207
|
+
*/
|
|
105
208
|
attachments?: Attachment[]
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The entities associated with the activity.
|
|
212
|
+
*/
|
|
106
213
|
entities?: Entity[]
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* The channel-specific data for the activity.
|
|
217
|
+
*/
|
|
107
218
|
channelData?: any
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The action associated with the activity.
|
|
222
|
+
*/
|
|
108
223
|
action?: string
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The ID of the activity being replied to.
|
|
227
|
+
*/
|
|
109
228
|
replyToId?: string
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* The label for the activity.
|
|
232
|
+
*/
|
|
110
233
|
label?: string
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The value type of the activity.
|
|
237
|
+
*/
|
|
111
238
|
valueType?: string
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* The value associated with the activity.
|
|
242
|
+
*/
|
|
112
243
|
value?: unknown
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* The name of the activity event.
|
|
247
|
+
*/
|
|
113
248
|
name?: ActivityEventNames | string
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* The conversation reference for the activity.
|
|
252
|
+
*/
|
|
114
253
|
relatesTo?: ConversationReference
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* The end-of-conversation code for the activity.
|
|
257
|
+
*/
|
|
115
258
|
code?: EndOfConversationCodes | string
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The expiration time of the activity.
|
|
262
|
+
*/
|
|
116
263
|
expiration?: string | Date
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* The importance of the activity.
|
|
267
|
+
*/
|
|
117
268
|
importance?: ActivityImportance | string
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* The delivery mode of the activity.
|
|
272
|
+
*/
|
|
118
273
|
deliveryMode?: DeliveryModes | string
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* The list of keywords to listen for in the activity.
|
|
277
|
+
*/
|
|
119
278
|
listenFor?: string[]
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* The text highlights in the activity.
|
|
282
|
+
*/
|
|
120
283
|
textHighlights?: TextHighlight[]
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* The semantic action associated with the activity.
|
|
287
|
+
*/
|
|
121
288
|
semanticAction?: SemanticAction
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* The raw timestamp of the activity.
|
|
292
|
+
*/
|
|
122
293
|
rawTimestamp?: string
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* The raw expiration time of the activity.
|
|
297
|
+
*/
|
|
123
298
|
rawExpiration?: string
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* The raw local timestamp of the activity.
|
|
302
|
+
*/
|
|
124
303
|
rawLocalTimestamp?: string
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Additional properties of the activity.
|
|
307
|
+
*/
|
|
125
308
|
[x: string]: unknown
|
|
126
309
|
|
|
127
310
|
/**
|
|
@@ -292,6 +475,97 @@ export class Activity {
|
|
|
292
475
|
return result
|
|
293
476
|
}
|
|
294
477
|
|
|
478
|
+
/**
|
|
479
|
+
* Normalizes mentions in the activity by removing mention tags and optionally removing recipient mention.
|
|
480
|
+
* @param removeMention Whether to remove the recipient mention from the activity.
|
|
481
|
+
*/
|
|
482
|
+
public normalizeMentions (removeMention: boolean = false): void {
|
|
483
|
+
if (this.type === ActivityTypes.Message) {
|
|
484
|
+
if (removeMention) {
|
|
485
|
+
// Strip recipient mention tags and text
|
|
486
|
+
this.removeRecipientMention()
|
|
487
|
+
|
|
488
|
+
// Strip entity.mention records for recipient id
|
|
489
|
+
if (this.entities !== undefined && this.recipient?.id) {
|
|
490
|
+
this.entities = this.entities.filter((entity) => {
|
|
491
|
+
if (entity.type.toLowerCase() === 'mention') {
|
|
492
|
+
const mention = entity as unknown as Mention
|
|
493
|
+
return mention.mentioned.id !== this.recipient?.id
|
|
494
|
+
}
|
|
495
|
+
return true
|
|
496
|
+
})
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// Remove <at> </at> tags keeping the inner text
|
|
501
|
+
if (this.text) {
|
|
502
|
+
this.text = Activity.removeAt(this.text)
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// Remove <at> </at> tags from mention records keeping the inner text
|
|
506
|
+
if (this.entities !== undefined) {
|
|
507
|
+
const mentions = this.getMentions(this)
|
|
508
|
+
for (const mention of mentions) {
|
|
509
|
+
if (mention.text) {
|
|
510
|
+
mention.text = Activity.removeAt(mention.text)?.trim()
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Removes <at> </at> tags from the specified text.
|
|
519
|
+
* @param text The text to process.
|
|
520
|
+
* @returns The text with <at> </at> tags removed.
|
|
521
|
+
*/
|
|
522
|
+
private static removeAt (text: string): string {
|
|
523
|
+
if (!text) {
|
|
524
|
+
return text
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
let foundTag: boolean
|
|
528
|
+
do {
|
|
529
|
+
foundTag = false
|
|
530
|
+
const iAtStart = text.toLowerCase().indexOf('<at')
|
|
531
|
+
if (iAtStart >= 0) {
|
|
532
|
+
const iAtEnd = text.indexOf('>', iAtStart)
|
|
533
|
+
if (iAtEnd > 0) {
|
|
534
|
+
const iAtClose = text.toLowerCase().indexOf('</at>', iAtEnd)
|
|
535
|
+
if (iAtClose > 0) {
|
|
536
|
+
// Replace </at>
|
|
537
|
+
let followingText = text.substring(iAtClose + 5)
|
|
538
|
+
|
|
539
|
+
// If first char of followingText is not whitespace, insert space
|
|
540
|
+
if (followingText.length > 0 && !(/\s/.test(followingText[0]))) {
|
|
541
|
+
followingText = ` ${followingText}`
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
text = text.substring(0, iAtClose) + followingText
|
|
545
|
+
|
|
546
|
+
// Get tag content (text between <at...> and </at>)
|
|
547
|
+
const tagContent = text.substring(iAtEnd + 1, iAtClose)
|
|
548
|
+
|
|
549
|
+
// Replace <at ...> with just the tag content
|
|
550
|
+
let prefixText = text.substring(0, iAtStart)
|
|
551
|
+
|
|
552
|
+
// If prefixText is not empty and doesn't end with whitespace, add a space
|
|
553
|
+
if (prefixText.length > 0 && !(/\s$/.test(prefixText))) {
|
|
554
|
+
prefixText += ' '
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
text = prefixText + tagContent + followingText
|
|
558
|
+
|
|
559
|
+
// We found one, try again, there may be more
|
|
560
|
+
foundTag = true
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
} while (foundTag)
|
|
565
|
+
|
|
566
|
+
return text
|
|
567
|
+
}
|
|
568
|
+
|
|
295
569
|
/**
|
|
296
570
|
* Removes the mention text for a given ID.
|
|
297
571
|
* @param id The ID of the mention to remove.
|