@microsoft/omnichannel-chat-widget 1.0.1 → 1.0.2-main.2112105

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.
@@ -1756,13 +1756,19 @@ const dummyDefaultProps = {
1756
1756
  }
1757
1757
  },
1758
1758
  localizedTexts: {
1759
+ /*
1760
+ MIDDLEWARE_BANNER_FILE parameters:
1761
+ {0} = File limit size
1762
+ {1} = File extension
1763
+ {2} = File name
1764
+ */
1759
1765
  MIDDLEWARE_BANNER_FILE_NULL_ERROR: "There was an error uploading the file, please try again.",
1760
- MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
1761
- MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and {1} files are not supported.",
1762
- MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file with an appropriate file extension.",
1763
- MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{0} files are not supported.",
1764
- MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File exceeds the allowed limit of {0} MB.",
1765
- MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file can't be attached because it's empty. Please try again with a different file.",
1766
+ MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
1767
+ MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and {1} files are not supported.",
1768
+ MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file {2} with an appropriate file extension.",
1769
+ MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{1} files are not supported.",
1770
+ MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File {2} exceeds the allowed limit of {0} MB.",
1771
+ MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file {2} can't be attached because it's empty. Please try again with a different file.",
1766
1772
  MIDDLEWARE_BANNER_ERROR_MESSAGE: "Upload failed, please try again.",
1767
1773
  MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE: "You're back online.",
1768
1774
  MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION: "Unable to connect—please check your internet connection.",
@@ -4,14 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.defaultMiddlewareLocalizedTexts = void 0;
7
+ /*
8
+ MIDDLEWARE_BANNER_FILE parameters:
9
+ {0} = File limit size
10
+ {1} = File extension
11
+ {2} = File name
12
+ */
13
+
7
14
  const defaultMiddlewareLocalizedTexts = {
8
15
  MIDDLEWARE_BANNER_FILE_NULL_ERROR: "There was an error uploading the file, please try again.",
9
- MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
10
- MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and {1} files are not supported.",
11
- MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file with an appropriate file extension.",
12
- MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{0} files are not supported.",
13
- MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File exceeds the allowed limit of {0} MB.",
14
- MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file can't be attached because it's empty. Please try again with a different file.",
16
+ MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
17
+ MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and {1} files are not supported.",
18
+ MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file {2} with an appropriate file extension.",
19
+ MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{1} files are not supported.",
20
+ MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File {2} exceeds the allowed limit of {0} MB.",
21
+ MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file {2} can't be attached because it's empty. Please try again with a different file.",
15
22
  MIDDLEWARE_BANNER_ERROR_MESSAGE: "Upload failed, please try again.",
16
23
  MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE: "You’re back online.",
17
24
  MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION: "Unable to connect—please check your internet connection.",
@@ -76,6 +76,11 @@ const getMaxUploadFileSize = (maxFileSizeSupportedByDynamicsStr, contentType) =>
76
76
  const isImage = contentType => {
77
77
  return _Constants.AMSConstants.supportedImagesMimeTypes.includes(contentType);
78
78
  };
79
+ const textEllipsis = function (str) {
80
+ let maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
81
+ const ellipsis = "...";
82
+ return str.length > maxLength ? str.slice(0, maxLength - ellipsis.length) + ellipsis : str;
83
+ };
79
84
  const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize, fileIsEmpty, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
80
85
  let errorMessage = "";
81
86
  if (!fileName || !maxUploadFileSize) {
@@ -91,10 +96,11 @@ const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize,
91
96
  if (!supportedFileExtension && !supportedFileSize) {
92
97
  errorMessage = getFileSizeAndFileExtensionErrorMessage(fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
93
98
  } else if (!supportedFileSize) {
94
- errorMessage = getFileSizeErrorMessage(maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
99
+ errorMessage = getFileSizeErrorMessage(fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
95
100
  } else if (!supportedFileExtension) {
96
101
  errorMessage = getFileExtensionErrorMessage(fileName, localizedTexts);
97
102
  } else if (fileIsEmpty) {
103
+ var _errorMessage;
98
104
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
99
105
  Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
100
106
  Description: "Attachment validation failed",
@@ -102,7 +108,8 @@ const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize,
102
108
  ErrorDetails: "File provided is empty"
103
109
  }
104
110
  });
105
- errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR ?? "";
111
+ errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR || "";
112
+ if ((_errorMessage = errorMessage) !== null && _errorMessage !== void 0 && _errorMessage.includes("{2}")) errorMessage = errorMessage.replace("{2}", textEllipsis(fileName));
106
113
  } else {
107
114
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
108
115
  Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
@@ -116,19 +123,18 @@ const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize,
116
123
  return errorMessage;
117
124
  };
118
125
  const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
126
+ var _errorMessage3;
119
127
  const index = fileName.lastIndexOf(".");
120
128
  let errorMessage, exceptionDetails;
121
129
  if (index < 0) {
122
130
  errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR;
123
131
  exceptionDetails = `File exceeded the allowed limit of ${maxUploadFileSize} MB and File provided without file extension`;
124
132
  } else {
125
- var _errorMessage;
133
+ var _errorMessage2;
126
134
  const fileExtension = fileName.substring(index);
127
135
  errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR;
136
+ if ((_errorMessage2 = errorMessage) !== null && _errorMessage2 !== void 0 && _errorMessage2.includes("{1}")) errorMessage = errorMessage.replace("{1}", fileExtension);
128
137
  exceptionDetails = `File exceeds the allowed limit of ${maxUploadFileSize} MB and ${fileExtension} files are not supported`;
129
- if ((_errorMessage = errorMessage) !== null && _errorMessage !== void 0 && _errorMessage.includes("{1}")) {
130
- errorMessage = errorMessage.replace("{1}", fileExtension);
131
- }
132
138
  }
133
139
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
134
140
  Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
@@ -137,10 +143,12 @@ const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, ma
137
143
  ErrorDetails: `${exceptionDetails} Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${_Constants.AMSConstants.maxSupportedImageSize} AMS file size limit=${_Constants.AMSConstants.maxSupportedFileSize}`
138
144
  }
139
145
  });
140
- return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", maxUploadFileSize) : errorMessage : "";
146
+ if ((_errorMessage3 = errorMessage) !== null && _errorMessage3 !== void 0 && _errorMessage3.includes("{0}")) errorMessage = errorMessage.replace("{0}", maxUploadFileSize);
147
+ return errorMessage ? errorMessage.includes("{2}") ? errorMessage.replace("{2}", textEllipsis(fileName)) : errorMessage : "";
141
148
  };
142
149
  const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
143
150
  const index = fileName.lastIndexOf(".");
151
+ let errorMessage;
144
152
  if (index < 0) {
145
153
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
146
154
  Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
@@ -149,8 +157,10 @@ const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
149
157
  ErrorDetails: "File provided without file extension"
150
158
  }
151
159
  });
152
- return localizedTexts.MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION ?? "";
160
+ errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION;
161
+ return errorMessage ? errorMessage.includes("{2}") ? errorMessage.replace("{2}", textEllipsis(fileName)) : errorMessage : "";
153
162
  } else {
163
+ var _errorMessage4, _errorMessage5;
154
164
  const fileExtension = fileName.substring(index);
155
165
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
156
166
  Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
@@ -159,11 +169,14 @@ const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
159
169
  ErrorDetails: `${fileExtension} files extension is not supported.`
160
170
  }
161
171
  });
162
- const errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR;
163
- return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", fileExtension) : errorMessage : "";
172
+ errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR;
173
+ if ((_errorMessage4 = errorMessage) !== null && _errorMessage4 !== void 0 && _errorMessage4.includes("{0}")) errorMessage = errorMessage.replace("{0}", fileExtension); //keeping backwards compatibility for this localized string
174
+ if ((_errorMessage5 = errorMessage) !== null && _errorMessage5 !== void 0 && _errorMessage5.includes("{1}")) errorMessage = errorMessage.replace("{1}", fileExtension);
175
+ return errorMessage && errorMessage.length > 0 ? errorMessage : "";
164
176
  }
165
177
  };
166
- const getFileSizeErrorMessage = (maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
178
+ const getFileSizeErrorMessage = (fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
179
+ var _errorMessage6;
167
180
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
168
181
  Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
169
182
  Description: "Attachment validation failed",
@@ -171,8 +184,9 @@ const getFileSizeErrorMessage = (maxUploadFileSize, maxFileSizeSupportedByDynami
171
184
  ErrorDetails: `File exceeds the allowed limit of ${maxUploadFileSize}MB. Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${_Constants.AMSConstants.maxSupportedImageSize} AMS file size limit=${_Constants.AMSConstants.maxSupportedFileSize}`
172
185
  }
173
186
  });
174
- const errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_ERROR;
175
- return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", maxUploadFileSize) : errorMessage : "";
187
+ let errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_ERROR;
188
+ if ((_errorMessage6 = errorMessage) !== null && _errorMessage6 !== void 0 && _errorMessage6.includes("{0}")) errorMessage = errorMessage.replace("{0}", maxUploadFileSize);
189
+ return errorMessage ? errorMessage.includes("{2}") ? errorMessage.replace("{2}", textEllipsis(fileName)) : errorMessage : "";
176
190
  };
177
191
 
178
192
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
@@ -1750,13 +1750,19 @@ export const dummyDefaultProps = {
1750
1750
  }
1751
1751
  },
1752
1752
  localizedTexts: {
1753
+ /*
1754
+ MIDDLEWARE_BANNER_FILE parameters:
1755
+ {0} = File limit size
1756
+ {1} = File extension
1757
+ {2} = File name
1758
+ */
1753
1759
  MIDDLEWARE_BANNER_FILE_NULL_ERROR: "There was an error uploading the file, please try again.",
1754
- MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
1755
- MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and {1} files are not supported.",
1756
- MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file with an appropriate file extension.",
1757
- MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{0} files are not supported.",
1758
- MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File exceeds the allowed limit of {0} MB.",
1759
- MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file can't be attached because it's empty. Please try again with a different file.",
1760
+ MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
1761
+ MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and {1} files are not supported.",
1762
+ MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file {2} with an appropriate file extension.",
1763
+ MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{1} files are not supported.",
1764
+ MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File {2} exceeds the allowed limit of {0} MB.",
1765
+ MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file {2} can't be attached because it's empty. Please try again with a different file.",
1760
1766
  MIDDLEWARE_BANNER_ERROR_MESSAGE: "Upload failed, please try again.",
1761
1767
  MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE: "You're back online.",
1762
1768
  MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION: "Unable to connect—please check your internet connection.",
@@ -1,11 +1,18 @@
1
+ /*
2
+ MIDDLEWARE_BANNER_FILE parameters:
3
+ {0} = File limit size
4
+ {1} = File extension
5
+ {2} = File name
6
+ */
7
+
1
8
  export const defaultMiddlewareLocalizedTexts = {
2
9
  MIDDLEWARE_BANNER_FILE_NULL_ERROR: "There was an error uploading the file, please try again.",
3
- MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
4
- MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and {1} files are not supported.",
5
- MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file with an appropriate file extension.",
6
- MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{0} files are not supported.",
7
- MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File exceeds the allowed limit of {0} MB.",
8
- MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file can't be attached because it's empty. Please try again with a different file.",
10
+ MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
11
+ MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and {1} files are not supported.",
12
+ MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file {2} with an appropriate file extension.",
13
+ MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{1} files are not supported.",
14
+ MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File {2} exceeds the allowed limit of {0} MB.",
15
+ MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file {2} can't be attached because it's empty. Please try again with a different file.",
9
16
  MIDDLEWARE_BANNER_ERROR_MESSAGE: "Upload failed, please try again.",
10
17
  MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE: "You’re back online.",
11
18
  MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION: "Unable to connect—please check your internet connection.",
@@ -70,6 +70,11 @@ const getMaxUploadFileSize = (maxFileSizeSupportedByDynamicsStr, contentType) =>
70
70
  const isImage = contentType => {
71
71
  return AMSConstants.supportedImagesMimeTypes.includes(contentType);
72
72
  };
73
+ const textEllipsis = function (str) {
74
+ let maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
75
+ const ellipsis = "...";
76
+ return str.length > maxLength ? str.slice(0, maxLength - ellipsis.length) + ellipsis : str;
77
+ };
73
78
  const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize, fileIsEmpty, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
74
79
  let errorMessage = "";
75
80
  if (!fileName || !maxUploadFileSize) {
@@ -85,10 +90,11 @@ const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize,
85
90
  if (!supportedFileExtension && !supportedFileSize) {
86
91
  errorMessage = getFileSizeAndFileExtensionErrorMessage(fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
87
92
  } else if (!supportedFileSize) {
88
- errorMessage = getFileSizeErrorMessage(maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
93
+ errorMessage = getFileSizeErrorMessage(fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
89
94
  } else if (!supportedFileExtension) {
90
95
  errorMessage = getFileExtensionErrorMessage(fileName, localizedTexts);
91
96
  } else if (fileIsEmpty) {
97
+ var _errorMessage;
92
98
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
93
99
  Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
94
100
  Description: "Attachment validation failed",
@@ -96,7 +102,8 @@ const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize,
96
102
  ErrorDetails: "File provided is empty"
97
103
  }
98
104
  });
99
- errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR ?? "";
105
+ errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR || "";
106
+ if ((_errorMessage = errorMessage) !== null && _errorMessage !== void 0 && _errorMessage.includes("{2}")) errorMessage = errorMessage.replace("{2}", textEllipsis(fileName));
100
107
  } else {
101
108
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
102
109
  Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
@@ -110,19 +117,18 @@ const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize,
110
117
  return errorMessage;
111
118
  };
112
119
  const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
120
+ var _errorMessage3;
113
121
  const index = fileName.lastIndexOf(".");
114
122
  let errorMessage, exceptionDetails;
115
123
  if (index < 0) {
116
124
  errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR;
117
125
  exceptionDetails = `File exceeded the allowed limit of ${maxUploadFileSize} MB and File provided without file extension`;
118
126
  } else {
119
- var _errorMessage;
127
+ var _errorMessage2;
120
128
  const fileExtension = fileName.substring(index);
121
129
  errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR;
130
+ if ((_errorMessage2 = errorMessage) !== null && _errorMessage2 !== void 0 && _errorMessage2.includes("{1}")) errorMessage = errorMessage.replace("{1}", fileExtension);
122
131
  exceptionDetails = `File exceeds the allowed limit of ${maxUploadFileSize} MB and ${fileExtension} files are not supported`;
123
- if ((_errorMessage = errorMessage) !== null && _errorMessage !== void 0 && _errorMessage.includes("{1}")) {
124
- errorMessage = errorMessage.replace("{1}", fileExtension);
125
- }
126
132
  }
127
133
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
128
134
  Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
@@ -131,10 +137,12 @@ const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, ma
131
137
  ErrorDetails: `${exceptionDetails} Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${AMSConstants.maxSupportedImageSize} AMS file size limit=${AMSConstants.maxSupportedFileSize}`
132
138
  }
133
139
  });
134
- return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", maxUploadFileSize) : errorMessage : "";
140
+ if ((_errorMessage3 = errorMessage) !== null && _errorMessage3 !== void 0 && _errorMessage3.includes("{0}")) errorMessage = errorMessage.replace("{0}", maxUploadFileSize);
141
+ return errorMessage ? errorMessage.includes("{2}") ? errorMessage.replace("{2}", textEllipsis(fileName)) : errorMessage : "";
135
142
  };
136
143
  const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
137
144
  const index = fileName.lastIndexOf(".");
145
+ let errorMessage;
138
146
  if (index < 0) {
139
147
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
140
148
  Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
@@ -143,8 +151,10 @@ const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
143
151
  ErrorDetails: "File provided without file extension"
144
152
  }
145
153
  });
146
- return localizedTexts.MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION ?? "";
154
+ errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION;
155
+ return errorMessage ? errorMessage.includes("{2}") ? errorMessage.replace("{2}", textEllipsis(fileName)) : errorMessage : "";
147
156
  } else {
157
+ var _errorMessage4, _errorMessage5;
148
158
  const fileExtension = fileName.substring(index);
149
159
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
150
160
  Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
@@ -153,11 +163,14 @@ const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
153
163
  ErrorDetails: `${fileExtension} files extension is not supported.`
154
164
  }
155
165
  });
156
- const errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR;
157
- return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", fileExtension) : errorMessage : "";
166
+ errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR;
167
+ if ((_errorMessage4 = errorMessage) !== null && _errorMessage4 !== void 0 && _errorMessage4.includes("{0}")) errorMessage = errorMessage.replace("{0}", fileExtension); //keeping backwards compatibility for this localized string
168
+ if ((_errorMessage5 = errorMessage) !== null && _errorMessage5 !== void 0 && _errorMessage5.includes("{1}")) errorMessage = errorMessage.replace("{1}", fileExtension);
169
+ return errorMessage && errorMessage.length > 0 ? errorMessage : "";
158
170
  }
159
171
  };
160
- const getFileSizeErrorMessage = (maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
172
+ const getFileSizeErrorMessage = (fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
173
+ var _errorMessage6;
161
174
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
162
175
  Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
163
176
  Description: "Attachment validation failed",
@@ -165,8 +178,9 @@ const getFileSizeErrorMessage = (maxUploadFileSize, maxFileSizeSupportedByDynami
165
178
  ErrorDetails: `File exceeds the allowed limit of ${maxUploadFileSize}MB. Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${AMSConstants.maxSupportedImageSize} AMS file size limit=${AMSConstants.maxSupportedFileSize}`
166
179
  }
167
180
  });
168
- const errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_ERROR;
169
- return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", maxUploadFileSize) : errorMessage : "";
181
+ let errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_ERROR;
182
+ if ((_errorMessage6 = errorMessage) !== null && _errorMessage6 !== void 0 && _errorMessage6.includes("{0}")) errorMessage = errorMessage.replace("{0}", maxUploadFileSize);
183
+ return errorMessage ? errorMessage.includes("{2}") ? errorMessage.replace("{2}", textEllipsis(fileName)) : errorMessage : "";
170
184
  };
171
185
 
172
186
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.0.1",
3
+ "version": "1.0.2-main.2112105",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",