@microsoft/omnichannel-chat-widget 1.8.4-main.a953701 → 1.8.4-main.acea70c
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/lib/cjs/common/Constants.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +34 -0
- package/lib/esm/common/Constants.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +34 -0
- package/lib/types/common/Constants.d.ts +2 -0
- package/package.json +1 -1
|
@@ -82,6 +82,8 @@ _defineProperty(Constants, "audioMediaRegex", /(\.)(aac|aiff|alac|amr|flac|mp2|m
|
|
|
82
82
|
_defineProperty(Constants, "videoMediaRegex", /(\.)(avchd|avi|flv|mpe|mpeg|mpg|mpv|mp4|m4p|m4v|mov|qt|swf|webm|wmv)$/i);
|
|
83
83
|
_defineProperty(Constants, "chromeSupportedInlineMediaRegex", /(\.)(aac|mp3|wav|mp4)$/i);
|
|
84
84
|
_defineProperty(Constants, "firefoxSupportedInlineMediaRegex", /(\.)(aac|flac|mp3|wav|mp4|mov)$/i);
|
|
85
|
+
_defineProperty(Constants, "AdaptiveCardType", "adaptivecard");
|
|
86
|
+
_defineProperty(Constants, "SuggestedActionsType", "suggestedactions");
|
|
85
87
|
// calling container event names
|
|
86
88
|
_defineProperty(Constants, "CallAdded", "callAdded");
|
|
87
89
|
_defineProperty(Constants, "LocalVideoStreamAdded", "localVideoStreamAdded");
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _Constants = require("../../../../common/Constants");
|
|
8
|
+
var _SupportedAdaptiveCards = require("@microsoft/omnichannel-chat-sdk/lib/utils/printers/interfaces/SupportedAdaptiveCards");
|
|
8
9
|
var _botActivity = _interopRequireDefault(require("../activities/botActivity"));
|
|
9
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -75,6 +76,39 @@ const convertPersistentChatHistoryMessageToActivity = message => {
|
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
78
|
if (content) {
|
|
79
|
+
var _from$application2, _parsedContent, _parsedContent$value;
|
|
80
|
+
// Check if content contains adaptive card or rich card JSON using SupportedAdaptiveCards enum
|
|
81
|
+
const isAdaptiveCard = content.toLowerCase().includes(_Constants.Constants.AdaptiveCardType);
|
|
82
|
+
const isSuggestedActions = content.toLowerCase().includes(_Constants.Constants.SuggestedActionsType);
|
|
83
|
+
const containsSupportedCard = Object.values(_SupportedAdaptiveCards.SupportedAdaptiveCards).some(type => content.toLowerCase().includes(type.toLowerCase()));
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
|
+
let parsedContent;
|
|
86
|
+
try {
|
|
87
|
+
parsedContent = JSON.parse(content);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
console.error("Failed to parse content as JSON:", error);
|
|
90
|
+
parsedContent = null; // fall back to normal text handling
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Check if this is a customer form submission response (e.g., RichObjectMessage_Form)
|
|
94
|
+
// These should be ignored as they are form submission data, not displayable content
|
|
95
|
+
const isFromCustomer = (from === null || from === void 0 ? void 0 : (_from$application2 = from.application) === null || _from$application2 === void 0 ? void 0 : _from$application2.displayName) === "Customer";
|
|
96
|
+
if (isFromCustomer && ((_parsedContent = parsedContent) === null || _parsedContent === void 0 ? void 0 : (_parsedContent$value = _parsedContent.value) === null || _parsedContent$value === void 0 ? void 0 : _parsedContent$value.type) === "RichObjectMessage_Form") {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
if (parsedContent && (isAdaptiveCard || isSuggestedActions || containsSupportedCard)) {
|
|
100
|
+
return {
|
|
101
|
+
...activity,
|
|
102
|
+
...parsedContent,
|
|
103
|
+
timestamp,
|
|
104
|
+
channelData: {
|
|
105
|
+
...activity.channelData,
|
|
106
|
+
"webchat:sequence-id": webchatSequenceId
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Plain text message
|
|
78
112
|
return {
|
|
79
113
|
...activity,
|
|
80
114
|
text: content,
|
|
@@ -75,6 +75,8 @@ _defineProperty(Constants, "audioMediaRegex", /(\.)(aac|aiff|alac|amr|flac|mp2|m
|
|
|
75
75
|
_defineProperty(Constants, "videoMediaRegex", /(\.)(avchd|avi|flv|mpe|mpeg|mpg|mpv|mp4|m4p|m4v|mov|qt|swf|webm|wmv)$/i);
|
|
76
76
|
_defineProperty(Constants, "chromeSupportedInlineMediaRegex", /(\.)(aac|mp3|wav|mp4)$/i);
|
|
77
77
|
_defineProperty(Constants, "firefoxSupportedInlineMediaRegex", /(\.)(aac|flac|mp3|wav|mp4|mov)$/i);
|
|
78
|
+
_defineProperty(Constants, "AdaptiveCardType", "adaptivecard");
|
|
79
|
+
_defineProperty(Constants, "SuggestedActionsType", "suggestedactions");
|
|
78
80
|
// calling container event names
|
|
79
81
|
_defineProperty(Constants, "CallAdded", "callAdded");
|
|
80
82
|
_defineProperty(Constants, "LocalVideoStreamAdded", "localVideoStreamAdded");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Constants } from "../../../../common/Constants";
|
|
2
|
+
import { SupportedAdaptiveCards } from "@microsoft/omnichannel-chat-sdk/lib/utils/printers/interfaces/SupportedAdaptiveCards";
|
|
2
3
|
import botActivity from "../activities/botActivity";
|
|
3
4
|
|
|
4
5
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -69,6 +70,39 @@ const convertPersistentChatHistoryMessageToActivity = message => {
|
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
72
|
if (content) {
|
|
73
|
+
var _from$application2, _parsedContent, _parsedContent$value;
|
|
74
|
+
// Check if content contains adaptive card or rich card JSON using SupportedAdaptiveCards enum
|
|
75
|
+
const isAdaptiveCard = content.toLowerCase().includes(Constants.AdaptiveCardType);
|
|
76
|
+
const isSuggestedActions = content.toLowerCase().includes(Constants.SuggestedActionsType);
|
|
77
|
+
const containsSupportedCard = Object.values(SupportedAdaptiveCards).some(type => content.toLowerCase().includes(type.toLowerCase()));
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
+
let parsedContent;
|
|
80
|
+
try {
|
|
81
|
+
parsedContent = JSON.parse(content);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.error("Failed to parse content as JSON:", error);
|
|
84
|
+
parsedContent = null; // fall back to normal text handling
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Check if this is a customer form submission response (e.g., RichObjectMessage_Form)
|
|
88
|
+
// These should be ignored as they are form submission data, not displayable content
|
|
89
|
+
const isFromCustomer = (from === null || from === void 0 ? void 0 : (_from$application2 = from.application) === null || _from$application2 === void 0 ? void 0 : _from$application2.displayName) === "Customer";
|
|
90
|
+
if (isFromCustomer && ((_parsedContent = parsedContent) === null || _parsedContent === void 0 ? void 0 : (_parsedContent$value = _parsedContent.value) === null || _parsedContent$value === void 0 ? void 0 : _parsedContent$value.type) === "RichObjectMessage_Form") {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
if (parsedContent && (isAdaptiveCard || isSuggestedActions || containsSupportedCard)) {
|
|
94
|
+
return {
|
|
95
|
+
...activity,
|
|
96
|
+
...parsedContent,
|
|
97
|
+
timestamp,
|
|
98
|
+
channelData: {
|
|
99
|
+
...activity.channelData,
|
|
100
|
+
"webchat:sequence-id": webchatSequenceId
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Plain text message
|
|
72
106
|
return {
|
|
73
107
|
...activity,
|
|
74
108
|
text: content,
|
|
@@ -58,6 +58,8 @@ export declare class Constants {
|
|
|
58
58
|
static readonly videoMediaRegex: RegExp;
|
|
59
59
|
static readonly chromeSupportedInlineMediaRegex: RegExp;
|
|
60
60
|
static readonly firefoxSupportedInlineMediaRegex: RegExp;
|
|
61
|
+
static readonly AdaptiveCardType = "adaptivecard";
|
|
62
|
+
static readonly SuggestedActionsType = "suggestedactions";
|
|
61
63
|
static readonly CallAdded = "callAdded";
|
|
62
64
|
static readonly LocalVideoStreamAdded = "localVideoStreamAdded";
|
|
63
65
|
static readonly LocalVideoStreamRemoved = "localVideoStreamRemoved";
|